Explorar el Código

Add example env.

master
Palash Bansal hace 1 año
padre
commit
739ebae861
No account linked to committer's email address

+ 2
- 0
.gitignore Ver fichero

@@ -3,6 +3,8 @@ lib
docs
examples/**/*.js
examples/**/*.js.map
examples/globals.js
examples/.env

# Logs
logs

+ 1
- 0
examples/globals.d.ts Ver fichero

@@ -0,0 +1 @@
export const CESIUM_ION_API_TOKEN: string

+ 2
- 1
examples/ogc-tiles-google-maps-3d/script.ts Ver fichero

@@ -1,5 +1,6 @@
import {_testFinish, LoadingScreenPlugin, MathUtils, OrbitControls3, ThreeViewer} from 'threepipe'
import {TilesRendererPlugin, UnloadTilesPlugin, TileCompressionPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {CESIUM_ION_API_TOKEN} from '../globals.js'

async function init() {

@@ -32,7 +33,7 @@ async function init() {

const result = await tiles.loadCesiumIon({
assetId: '2275207',
apiToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0M2VkOWIxYy00NGEyLTQ1N2QtOWYxYy01ZDNlYjdkN2U4N2MiLCJpZCI6Mjk5NTY5LCJpYXQiOjE3NDY0MzE1NTl9.iOdIsjY4zSnTfIXBx0Pl-yfsG24OuHTt2CQnIP5JRrQ',
apiToken: CESIUM_ION_API_TOKEN,
autoRefreshToken: true,
}, {
autoCenter: false,

+ 2
- 1
examples/ogc-tiles-google-maps/script.ts Ver fichero

@@ -1,5 +1,6 @@
import {_testFinish, LoadingScreenPlugin, OrbitControls3, ThreeViewer} from 'threepipe'
import {TileCompressionPlugin, TilesRendererPlugin, UnloadTilesPlugin} from '@threepipe/plugin-3d-tiles-renderer'
import {CESIUM_ION_API_TOKEN} from '../globals.js'

async function init() {

@@ -36,7 +37,7 @@ async function init() {

const result = await tiles.loadCesiumIon({
assetId: '2275207',
apiToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0M2VkOWIxYy00NGEyLTQ1N2QtOWYxYy01ZDNlYjdkN2U4N2MiLCJpZCI6Mjk5NTY5LCJpYXQiOjE3NDY0MzE1NTl9.iOdIsjY4zSnTfIXBx0Pl-yfsG24OuHTt2CQnIP5JRrQ',
apiToken: CESIUM_ION_API_TOKEN,
autoRefreshToken: true,
}, {
autoCenter: false,

+ 1
- 0
examples/sample.env Ver fichero

@@ -0,0 +1 @@
TP_EX_CESIUM_ION_API_TOKEN="CESIUM_ION_API_TOKEN"

+ 4
- 3
package-lock.json Ver fichero

@@ -26,6 +26,7 @@
"@typescript-eslint/parser": "^5.59.5",
"clean-package": "^2.2.0",
"copyfiles": "^2.4.1",
"dotenv": "^16.5.0",
"eslint": "^8.40.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-deprecation": "^1.4.1",
@@ -4321,9 +4322,9 @@
}
},
"node_modules/dotenv": {
"version": "16.4.7",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
"version": "16.5.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {

+ 8
- 6
package.json Ver fichero

@@ -35,8 +35,8 @@
"new:publish": "git diff --exit-code --name-only HEAD * && npm run prepare && clean-package && npm publish && clean-package restore && git tag v$npm_package_version",
"build": "npm run update-version && npm run compile && vite build",
"dev": "NODE_ENV=development vite build --watch",
"build-examples": "tsc --project examples/tsconfig.build.json",
"dev-examples": "tsc --project examples/tsconfig.build.json -w",
"build-examples": "npm run generate-example-env && tsc --project examples/tsconfig.build.json",
"dev-examples": "npm run generate-example-env && tsc --project examples/tsconfig.build.json -w",
"serve-docs": "ws -d docs -p 8080",
"serve": "ws -d . -p 9229",
"docs": "npx typedoc && npm run website:build",
@@ -48,7 +48,8 @@
"website:dev": "vitepress dev website",
"website:build": "vitepress build website",
"website:preview": "vitepress preview website",
"build-site": "bash ./scripts/build-site.sh"
"build-site": "bash ./scripts/build-site.sh",
"generate-example-env": "node ./scripts/generate-example-env.mjs"
},
"clean-package": {
"remove": [
@@ -93,12 +94,13 @@
"devDependencies": {
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-replace": "^5.0.2",
"@types/node": "^22.10.2",
"@types/stats.js": "^0.17.0",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.5",
"clean-package": "^2.2.0",
"@types/node": "^22.10.2",
"copyfiles": "^2.4.1",
"dotenv": "^16.5.0",
"eslint": "^8.40.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-deprecation": "^1.4.1",
@@ -122,10 +124,10 @@
"@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.157.1005/package.tgz",
"@types/webxr": "^0.5.1",
"@types/wicg-file-system-access": "^2020.9.5",
"popmotion": "^11.0.5",
"stats.js": "^0.17.0",
"ts-browser-helpers": "^0.16.2",
"uiconfig.js": "^0.1.3",
"popmotion": "^11.0.5"
"uiconfig.js": "^0.1.3"
},
"peerDependencies": {
"three": "https://github.com/repalash/three.js-modded/releases/download/v0.157.1007/package.tgz"

+ 31
- 0
scripts/generate-example-env.mjs Ver fichero

@@ -0,0 +1,31 @@
import fs from 'fs'
import dotenv from 'dotenv'

// read .env file if exists
const envFilePath = './examples/.env'
if (fs.existsSync(envFilePath)) {
dotenv.config({ path: envFilePath })
}

// Filter EX_ variables from environment
const envVars = Object.entries(process.env)
.filter(([key]) => key.startsWith('TP_EX_'))
.reduce((acc, [key, value]) => {
acc[key.replace('TP_EX_', '')] = value
return acc
}, {})

// Generate globals.js
const jsOutput = Object.entries(envVars)
.map(([key, val]) => `export const ${key} = ${JSON.stringify(val)}`)
.join('\n') + '\n'
fs.writeFileSync('./examples/globals.js', jsOutput, 'utf8')

// Generate globals.d.ts
const dtsOutput = Object.entries(envVars)
.map(([key, value]) => `export const ${key}: ${typeof value}`)
.join('\n') + '\n'

fs.writeFileSync('./examples/globals.d.ts', dtsOutput, 'utf8')

console.log('✅ globals.js and globals.d.ts generated.')

Cargando…
Cancelar
Guardar