@xgis/xgis3d-build 0.3.48 → 0.3.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"cesiumAssets.js","sources":["../src/cesiumAssets.ts"],"sourcesContent":["import { cpSync, existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\n\n// Cesium loads these dynamically at runtime; a bundler bundles the JS library but never sees them.\nexport const CESIUM_ASSET_ENTRIES = ['Workers', 'ThirdParty', 'Assets', 'Widgets'] as const\n\nexport interface CesiumAssetsOptions {\n /**\n * Directory the assets are served under. Must match the base URL the runtime reads.\n * Defaults to `cesium-<version>`, which is what `ensureCesiumBaseUrl()` sets.\n */\n base?: string\n}\n\nexport interface CesiumAssetPlan {\n readonly source: string\n readonly licenseFile: string\n readonly dir: string\n readonly entries: readonly string[]\n}\n\n// Read rather than imported: the library build strips the attribute a bare .json import needs.\nconst requireFromHere = createRequire(import.meta.url)\n\n// Through @xgis/xgis3d, so the copied assets are the ones its runtime was built against.\nfunction cesiumPackageDir(): string {\n const xgis3dManifest = requireFromHere.resolve('@xgis/xgis3d/package.json')\n const requireFromXgis3d = createRequire(xgis3dManifest)\n\n return dirname(realpathSync(requireFromXgis3d.resolve('cesium/package.json')))\n}\n\n// `dir` is used as both a URL segment and a filesystem segment, so it has to be safe as both.\nfunction normaliseDir(base: string): string {\n const dir = base\n .replace(/^\\/+/, '')\n .replace(/\\/+$/, '')\n .replace(/\\/{2,}/g, '/')\n\n if (!dir) {\n throw new Error(`cesiumAssets: base must name a directory, got ${JSON.stringify(base)}`)\n }\n\n if (dir.includes('\\\\')) {\n throw new Error(`cesiumAssets: base must use \"/\" as a separator, got ${JSON.stringify(base)}`)\n }\n\n // Without this, `--base ../..` writes Cesium's build tree outside the output directory.\n if (dir.split('/').includes('..')) {\n throw new Error(`cesiumAssets: base must not traverse upwards, got ${JSON.stringify(base)}`)\n }\n\n return dir\n}\n\nexport function planCesiumAssets(options: CesiumAssetsOptions = {}): CesiumAssetPlan {\n const packageDir = cesiumPackageDir()\n const manifest = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')) as {\n version: string\n }\n const source = join(packageDir, 'Build', 'Cesium')\n\n // Named here rather than as a bare ENOENT at the end of a long build.\n if (!existsSync(source)) {\n throw new Error(`cesiumAssets: Cesium build output not found at ${source}`)\n }\n\n return {\n source,\n licenseFile: join(packageDir, 'LICENSE.md'),\n dir: normaliseDir(options.base ?? `cesium-${manifest.version}`),\n entries: CESIUM_ASSET_ENTRIES,\n }\n}\n\nexport function copyCesiumAssets(plan: CesiumAssetPlan, outDir: string): void {\n for (const entry of plan.entries) {\n cpSync(join(plan.source, entry), join(outDir, plan.dir, entry), { recursive: true })\n }\n\n // Redistribution: Apache-2.0 4(a) for Cesium, BSD-3-Clause for ThirdParty/. LICENSE.md covers both.\n cpSync(plan.licenseFile, join(outDir, plan.dir, 'LICENSE.md'))\n}\n\n/**\n * Joins a build-tool path prefix (Vite `base`, Rspack `output.publicPath`) with the asset\n * directory. An empty prefix means \"relative to the document\", which is a deliberate setting.\n */\nexport function joinPublicPath(prefix: string, dir: string): string {\n if (!prefix) {\n return dir\n }\n\n // Only the path collapses; `https://cdn/` would otherwise become `https:/cdn/`.\n const origin = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(prefix)?.[0] ?? ''\n const path = `${prefix.slice(origin.length)}/${dir}`.replace(/\\/{2,}/g, '/')\n\n return `${origin}${path}`\n}\n\nexport const CESIUM_BASE_URL_META = 'xgis-cesium-base-url'\n\nexport interface CesiumBaseUrlMeta {\n readonly name: string\n readonly content: string\n}\n\n// Validated, not escaped: the CLI hands this to a person to paste with no bundler in between.\nexport function cesiumBaseUrlMeta(publicPath: string): CesiumBaseUrlMeta {\n if (/[\"<>]/.test(publicPath)) {\n throw new Error(\n `cesiumAssets: public path must not contain quotes or angle brackets, got ${JSON.stringify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AAA,CAAK,MAAM,CAAA,GAAI,CAAC,CAAA,IAAK,EAAA;AACpE,EAAA,MAAM,IAAA,GAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,MAAM,CAAC,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,CAAG,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA;AAE3E,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AACzB;AAEO,MAAM,oBAAA,GAAuB;AAQ7B,SAAS,kBAAkB,UAAA,EAAuC;AACvE,EAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,yEAAA,EAA4E,IAAA,CAAK,SAAA,CAAU,UAAU,CAAC,CAAA;AAAA,KACxG;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,oBAAA,EAAsB,OAAA,EAAS,UAAA,EAAW;AAC3D;;;;"}
1
+ {"version":3,"file":"cesiumAssets.js","sources":["../src/cesiumAssets.ts"],"sourcesContent":["import { cpSync, existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\n\n// Cesium loads these dynamically at runtime; a bundler bundles the JS library but never sees them.\nexport const CESIUM_ASSET_ENTRIES = ['Workers', 'ThirdParty', 'Assets', 'Widgets'] as const\n\nexport interface CesiumAssetsOptions {\n /**\n * Directory the assets are served under. Must match the base URL the runtime reads.\n * Defaults to `cesium-<version>`, which is what `ensureCesiumBaseUrl()` sets.\n */\n base?: string\n}\n\nexport interface CesiumAssetPlan {\n readonly source: string\n readonly licenseFile: string\n readonly dir: string\n readonly entries: readonly string[]\n}\n\n// Read rather than imported: the library build strips the attribute a bare .json import needs.\nconst requireFromHere = createRequire(import.meta.url)\n\n// Through @xgis/xgis3d, so the copied assets are the ones its runtime was built against.\nfunction cesiumPackageDir(): string {\n const xgis3dManifest = requireFromHere.resolve('@xgis/xgis3d/package.json')\n const requireFromXgis3d = createRequire(xgis3dManifest)\n\n return dirname(realpathSync(requireFromXgis3d.resolve('cesium/package.json')))\n}\n\n// `dir` is used as both a URL segment and a filesystem segment, so it has to be safe as both.\nfunction normaliseDir(base: string): string {\n const dir = base\n .replace(/^\\/+/, '')\n .replace(/\\/+$/, '')\n .replace(/\\/{2,}/g, '/')\n\n if (!dir) {\n throw new Error(`cesiumAssets: base must name a directory, got ${JSON.stringify(base)}`)\n }\n\n if (dir.includes('\\\\')) {\n throw new Error(`cesiumAssets: base must use \"/\" as a separator, got ${JSON.stringify(base)}`)\n }\n\n // Without this, `--base ../..` writes Cesium's build tree outside the output directory.\n if (dir.split('/').includes('..')) {\n throw new Error(`cesiumAssets: base must not traverse upwards, got ${JSON.stringify(base)}`)\n }\n\n return dir\n}\n\nexport function planCesiumAssets(options: CesiumAssetsOptions = {}): CesiumAssetPlan {\n const packageDir = cesiumPackageDir()\n const manifest = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')) as {\n version: string\n }\n const source = join(packageDir, 'Build', 'Cesium')\n\n // Named here rather than as a bare ENOENT at the end of a long build.\n if (!existsSync(source)) {\n throw new Error(`cesiumAssets: Cesium build output not found at ${source}`)\n }\n\n return {\n source,\n licenseFile: join(packageDir, 'LICENSE.md'),\n dir: normaliseDir(options.base ?? `cesium-${manifest.version}`),\n entries: CESIUM_ASSET_ENTRIES,\n }\n}\n\nexport function copyCesiumAssets(plan: CesiumAssetPlan, outDir: string): void {\n for (const entry of plan.entries) {\n cpSync(join(plan.source, entry), join(outDir, plan.dir, entry), { recursive: true })\n }\n\n // Redistribution: Apache-2.0 4(a) for Cesium, BSD-3-Clause for ThirdParty/. LICENSE.md covers both.\n cpSync(plan.licenseFile, join(outDir, plan.dir, 'LICENSE.md'))\n}\n\n/**\n * Joins a build-tool path prefix (Vite `base`, Rspack `output.publicPath`) with the asset\n * directory. An empty prefix means \"relative to the document\", which is a deliberate setting.\n */\nexport function joinPublicPath(prefix: string, dir: string): string {\n if (!prefix) {\n return dir\n }\n\n // Only the path collapses; `https://cdn/` would otherwise become `https:/cdn/`.\n const origin = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(prefix)?.[0] ?? ''\n const path = `${prefix.slice(origin.length)}/${dir}`.replace(/\\/{2,}/g, '/')\n\n return `${origin}${path}`\n}\n\nexport const CESIUM_BASE_URL_META = 'xgis-cesium-base-url'\n\nexport interface CesiumBaseUrlMeta {\n readonly name: string\n readonly content: string\n}\n\n// Validated, not escaped: the CLI hands this to a person to paste with no bundler in between.\nexport function cesiumBaseUrlMeta(publicPath: string): CesiumBaseUrlMeta {\n if (/[\"<>]/.test(publicPath)) {\n throw new Error(\n `cesiumAssets: public path must not contain quotes or angle brackets, got ${JSON.stringify(publicPath)}`,\n )\n }\n\n return { name: CESIUM_BASE_URL_META, content: publicPath }\n}\n"],"names":[],"mappings":";;;;AAKO,MAAM,oBAAA,GAAuB,CAAC,SAAA,EAAW,YAAA,EAAc,UAAU,SAAS;AAkBjF,MAAM,eAAA,GAAkB,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAGrD,SAAS,gBAAA,GAA2B;AAClC,EAAA,MAAM,cAAA,GAAiB,eAAA,CAAgB,OAAA,CAAQ,2BAA2B,CAAA;AAC1E,EAAA,MAAM,iBAAA,GAAoB,cAAc,cAAc,CAAA;AAEtD,EAAA,OAAO,QAAQ,YAAA,CAAa,iBAAA,CAAkB,OAAA,CAAQ,qBAAqB,CAAC,CAAC,CAAA;AAC/E;AAGA,SAAS,aAAa,IAAA,EAAsB;AAC1C,EAAA,MAAM,GAAA,GAAM,IAAA,CACT,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,CAClB,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,CAClB,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA;AAEzB,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,M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port {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nconst USAGE = 'Usage: xgis-cesium-assets copy <dir> [--base <name>] [--public-path <prefix>]'\n\nexport function runCli(argv: string[]): string {\n const [command, target, ...rest] = argv\n\n if (command !== 'copy') {\n throw new Error(`Unknown command: ${command ?? '(none)'}\\n${USAGE}`)\n }\n\n if (!target || target.startsWith('-')) {\n throw new Error(`Expected a target directory, got ${target ?? '(none)'}\\n${USAGE}`)\n }\n\n const plan = planCesiumAssets({ base: readFlag(rest, '--base') })\n const outDir = resolve(process.cwd(), target)\n\n copyCesiumAssets(plan, outDir)\n\n // Disk location says nothing about the served URL, so the prefix is given rather than guessed.\n const publicPath = joinPublicPath(readFlag(rest, '--public-path') ?? '/', plan.dir)\n\n return [\n `Copied ${plan.entries.length} Cesium asset directories and LICENSE.md to ${outDir}/${plan.dir}`,\n '',\n 'Add this to the <head> of your HTML, before any bundle script:',\n ` <meta name=\"${cesiumBaseUrlMeta(publicPath).name}\" content=\"${publicPath}\" />`,\n '',\n `If ${target} is not served at the site root, re-run with --public-path <prefix> to get the`,\n 'right value, or adjust the path above to match.',\n ].join('\\n')\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const inline = args.find((arg) => arg.startsWith(`${flag}=`))\n\n if (inline) {\n return requireValue(inline.slice(flag.length + 1), flag)\n }\n\n const index = args.indexOf(flag)\n\n if (index === -1) {\n return undefined\n }\n\n const value = args[index + 1]\n\n if (value === undefined || value.startsWith('-')) {\n throw new Error(`${flag} needs a value\\n${USAGE}`)\n }\n\n return requireValue(value, flag)\n}\n\nfunction requireValue(value: string, flag: string): string {\n if (!value) {\n throw new Error(`${flag} needs a value\\n${USAGE}`)\n }\n\n return value\n}\n"],"names":[],"mappings":";;;AASA,MAAM,KAAA,GAAQ,+EAAA;AAEP,SAAS,OAAO,IAAA,EAAwB;AAC7C,EAAA,MAAM,CAAC,OAAA,EAAS,MAAA,EAA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AAA,EAAG,IAAI,CAAA,CAAA,CAAG,CAAC,CAAA;AAE5D,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,OAAO,aAAa,MAAA,CAAO,KAAA,CAAM,KAAK,MAAA,GAAS,CAAC,GAAG,IAAI,CAAA;AAAA,EACzD;AAEA,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA;AAE/B,EAAA,IAAI,UAAU,EAAA,EAAI;AAChB,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,GAAQ,CAAC,CAAA;AAE5B,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,CAAM,UAAA,CAAW,GAAG,CAAA,EAAG;AAChD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA;AAAA,EAAmB,KAAK,CAAA,CAAE,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,YAAA,CAAa,OAAO,IAAI,CAAA;AACjC;AAEA,SAAS,YAAA,CAAa,OAAe,IAAA,EAAsB;AACzD,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA;AAAA,EAAmB,KAAK,CAAA,CAAE,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,KAAA;AACT;;;;"}
1
+ {"version":3,"file":"cliRun.js","sources":["../src/cliRun.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nconst USAGE = 'Usage: xgis-cesium-assets copy <dir> [--base <name>] [--public-path <prefix>]'\n\nexport function runCli(argv: string[]): string {\n const [command, target, ...rest] = argv\n\n if (command !== 'copy') {\n throw new Error(`Unknown command: ${command ?? '(none)'}\\n${USAGE}`)\n }\n\n if (!target || target.startsWith('-')) {\n throw new Error(`Expected a target directory, got ${target ?? '(none)'}\\n${USAGE}`)\n }\n\n const plan = planCesiumAssets({ base: readFlag(rest, '--base') })\n const outDir = resolve(process.cwd(), target)\n\n copyCesiumAssets(plan, outDir)\n\n // Disk location says nothing about the served URL, so the prefix is given rather than guessed.\n const publicPath = joinPublicPath(readFlag(rest, '--public-path') ?? '/', plan.dir)\n\n return [\n `Copied ${plan.entries.length} Cesium asset directories and LICENSE.md to ${outDir}/${plan.dir}`,\n '',\n 'Add this to the <head> of your HTML, before any bundle script:',\n ` <meta name=\"${cesiumBaseUrlMeta(publicPath).name}\" content=\"${publicPath}\" />`,\n '',\n `If ${target} is not served at the site root, re-run with --public-path <prefix> to get the`,\n 'right value, or adjust the path above to match.',\n ].join('\\n')\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const inline = args.find((arg) => arg.startsWith(`${flag}=`))\n\n if (inline) {\n return requireValue(inline.slice(flag.length + 1), flag)\n }\n\n const index = args.indexOf(flag)\n\n if (index === -1) {\n return undefined\n }\n\n const value = args[index + 1]\n\n if (value === undefined || value.startsWith('-')) {\n throw new Error(`${flag} needs a value\\n${USAGE}`)\n }\n\n return requireValue(value, flag)\n}\n\nfunction requireValue(value: string, flag: string): string {\n if (!value) {\n throw new Error(`${flag} needs a value\\n${USAGE}`)\n }\n\n return value\n}\n"],"names":[],"mappings":";;;AASA,MAAM,KAAA,GAAQ,+EAAA;AAEP,SAAS,OAAO,IAAA,EAAwB;AAC7C,EAAA,MAAM,CAAC,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA,GAAI,IAAA;AAEnC,EAAA,IAAI,YAAY,MAAA,EAAQ;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,OAAA,IAAW,QAAQ;AAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAAA,EACrE;AAEA,EAAA,IAAI,CAAC,MAAA,IAAU,MAAA,CAAO,UAAA,CAAW,GAAG,CAAA,EAAG;AACrC,IAAA,MAAM,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IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,GAAQ,CAAC,CAAA;AAE5B,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,CAAM,UAAA,CAAW,GAAG,CAAA,EAAG;AAChD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA;AAAA,EAAmB,KAAK,CAAA,CAAE,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,YAAA,CAAa,OAAO,IAAI,CAAA;AACjC;AAEA,SAAS,YAAA,CAAa,OAAe,IAAA,EAAsB;AACzD,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA;AAAA,EAAmB,KAAK,CAAA,CAAE,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,KAAA;AACT;;"}
@@ -67,4 +67,4 @@ function resolvePublicPath(configured, dir) {
67
67
  }
68
68
 
69
69
  export { CesiumAssetsRspackPlugin, resolvePublicPath };
70
- //# sourceMappingURL=rspack-plugin.js.map
70
+ //# sourceMappingURL=rspackPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rspackPlugin.js","sources":["../src/rspackPlugin.ts"],"sourcesContent":["import type { Compiler } from '@rspack/core'\n\nimport type { CesiumAssetPlan, CesiumAssetsOptions } from './cesiumAssets'\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nconst PLUGIN_NAME = 'CesiumAssetsRspackPlugin'\n\n/**\n * Copies Cesium's runtime assets (workers, textures, widget CSS) into the compilation output,\n * serves them in dev, and injects `window.CESIUM_BASE_URL` into the HTML HtmlRspackPlugin emits.\n */\nexport class CesiumAssetsRspackPlugin {\n private readonly plan: CesiumAssetPlan\n\n private copied = false\n\n constructor(options: CesiumAssetsOptions = {}) {\n this.plan = planCesiumAssets(options)\n }\n\n apply(compiler: Compiler): void {\n const publicPath = resolvePublicPath(compiler.options.output.publicPath, this.plan.dir)\n // Off the compiler: getCompilationHooks rejects a compilation from a different instance.\n const { HtmlRspackPlugin } = compiler.rspack\n\n // The copy is on disk but the dev server serves from memory, so it needs the source directory.\n compiler.options.devServer = {\n ...compiler.options.devServer,\n static: [\n ...normaliseStatic(compiler.options.devServer?.static),\n { directory: this.plan.source, publicPath: `/${this.plan.dir}` },\n ],\n }\n\n // afterEmit fires per rebuild; the tree is tens of megabytes and never changes within a run.\n compiler.hooks.afterEmit.tap(PLUGIN_NAME, () => {\n if (this.copied) {\n return\n }\n\n copyCesiumAssets(this.plan, compiler.outputPath)\n this.copied = true\n })\n\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n // The hook exists even with no HTML plugin driving it, so absence is otherwise silent.\n if (!hasHtmlPlugin(compiler, HtmlRspackPlugin)) {\n compilation.warnings.push(\n new Error(\n `${PLUGIN_NAME}: HtmlRspackPlugin is required to inject the Cesium base URL meta tag. ` +\n `Set it to \"${publicPath}\" yourself if you generate HTML another way.`,\n ),\n )\n\n return\n }\n\n // First in <head> so it is parsed before any module, beating ensureCesiumBaseUrl()'s default.\n HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTagGroups.tap(\n PLUGIN_NAME,\n (data) => {\n data.headTags.unshift({\n tagName: 'meta',\n voidTag: true,\n attributes: { ...cesiumBaseUrlMeta(publicPath) },\n })\n\n return data\n },\n )\n })\n }\n}\n\nfunction hasHtmlPlugin(compiler: Compiler, HtmlRspackPlugin: unknown): boolean {\n const plugins = compiler.options.plugins ?? []\n\n return plugins.some(\n (plugin) =>\n plugin instanceof (HtmlRspackPlugin as new () => object) ||\n plugin?.constructor?.name === 'HtmlRspackPlugin',\n )\n}\n\ntype DevServerStatic = NonNullable<NonNullable<Compiler['options']['devServer']>['static']>\ntype StaticEntry = Extract<DevServerStatic, readonly unknown[]>[number]\n\n// `static` accepts a single entry, an array, or a boolean; only the first two carry entries to keep.\nfunction normaliseStatic(configured: DevServerStatic | undefined): StaticEntry[] {\n if (configured === undefined || typeof configured === 'boolean') {\n return []\n }\n\n return Array.isArray(configured) ? [...configured] : [configured as StaticEntry]\n}\n\n/**\n * `output.publicPath` may be `'auto'` (a bundler marker, not a URL), `''` (deliberately relative to\n * the document) or a function, which cannot be resolved before a compilation exists.\n */\nexport function resolvePublicPath(configured: unknown, dir: string): string {\n if (typeof configured === 'function' || configured === undefined || configured === 'auto') {\n return joinPublicPath('/', dir)\n }\n\n return joinPublicPath(String(configured), dir)\n}\n"],"names":[],"mappings":";;AAUA,MAAM,WAAA,GAAc,0BAAA;AAMb,MAAM,wBAAA,CAAyB;AAAA,EACnB,IAAA;AAAA,EAET,MAAA,GAAS,KAAA;AAAA,EAEjB,WAAA,CAAY,OAAA,GAA+B,EAAC,EAAG;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAiB,OAAO,CAAA;AAAA,EACtC;AAAA,EAEA,MAAM,QAAA,EAA0B;AAC9B,IAAA,MAAM,UAAA,GAAa,kBAAkB,QAAA,CAAS,OAAA,CAAQ,OAAO,UAAA,EAAY,IAAA,CAAK,KAAK,GAAG,CAAA;AAEtF,IAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,QAAA,CAAS,MAAA;AAGtC,IAAA,QAAA,CAAS,QAAQ,SAAA,GAAY;AAAA,MAC3B,GAAG,SAAS,OAAA,CAAQ,SAAA;AAAA,MACpB,MAAA,EAAQ;AAAA,QACN,GAAG,eAAA,CAAgB,QAAA,CAAS,OAAA,CAAQ,WAAW,MAAM,CAAA;AAAA,QACrD,EAAE,SAAA,EAAW,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,YAAY,CAAA,CAAA,EAAI,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,CAAA;AAAG;AACjE,KACF;AAGA,IAAA,QAAA,CAAS,KAAA,CAAM,SAAA,CAAU,GAAA,CAAI,WAAA,EAAa,MAAM;AAC9C,MAAA,IAAI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e,MAAA,IAAa,OAAO,UAAA,KAAe,SAAA,EAAW;AAC/D,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,OAAO,KAAA,CAAM,QAAQ,UAAU,CAAA,GAAI,CAAC,GAAG,UAAU,CAAA,GAAI,CAAC,UAAyB,CAAA;AACjF;AAMO,SAAS,iBAAA,CAAkB,YAAqB,GAAA,EAAqB;AAC1E,EAAA,IAAI,OAAO,UAAA,KAAe,UAAA,IAAc,UAAA,KAAe,MAAA,IAAa,eAAe,MAAA,EAAQ;AACzF,IAAA,OAAO,cAAA,CAAe,KAAK,GAAG,CAAA;AAAA,EAChC;AAEA,EAAA,OAAO,cAAA,CAAe,MAAA,CAAO,UAAU,CAAA,EAAG,GAAG,CAAA;AAC/C;;"}
@@ -37,4 +37,4 @@ function cesiumAssets(options = {}) {
37
37
  }
38
38
 
39
39
  export { cesiumAssets };
40
- //# sourceMappingURL=vite-plugin.js.map
40
+ //# sourceMappingURL=vitePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitePlugin.js","sources":["../src/vitePlugin.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport sirv from 'sirv'\nimport type { Plugin, ResolvedConfig } from 'vite'\n\nimport type { CesiumAssetsOptions } from './cesiumAssets'\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nexport type { CesiumAssetsOptions }\n\n// Runs before Vite strips `base`, so the mount has to carry it. A CDN base has no local path.\nfunction devMountPath(publicPath: string): string {\n const origin = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(publicPath)?.[0] ?? ''\n const path = publicPath.slice(origin.length)\n\n return path.startsWith('/') ? path : `/${path}`\n}\n\n/**\n * Serves Cesium's runtime assets (workers, textures, widget CSS) in dev and copies them into a\n * version-prefixed directory on build, so the directory can be cached immutably.\n */\nexport function cesiumAssets(options: CesiumAssetsOptions = {}): Plugin {\n const plan = planCesiumAssets(options)\n\n let outDir: string\n let publicPath: string\n\n return {\n name: 'cesium-assets',\n configResolved(config: ResolvedConfig) {\n outDir = resolve(config.root, config.build.outDir)\n // Without the base prefix a path-deployed app 404s every worker while the globe still renders.\n publicPath = joinPublicPath(config.base, plan.dir)\n },\n configureServer(server) {\n server.middlewares.use(devMountPath(publicPath), sirv(plan.source, { dev: true }))\n },\n // In <head> so it is parsed before any module, beating ensureCesiumBaseUrl()'s default.\n transformIndexHtml() {\n return [\n {\n tag: 'meta',\n injectTo: 'head-prepend',\n attrs: { ...cesiumBaseUrlMeta(publicPath) },\n },\n ]\n },\n writeBundle() {\n copyCesiumAssets(plan, outDir)\n },\n }\n}\n"],"names":[],"mappings":";;;;AAgBA,SAAS,aAAa,UAAA,EAA4B;AAChD,EAAA,MAAM,SAAS,+BAAA,CAAgC,IAAA,CAAK,UAAU,CAAA,GAAI,CAAC,CAAA,IAAK,EAAA;AACxE,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,KAAA,CAAM,MAAA,CAAO,MAAM,CAAA;AAE3C,EAAA,OAAO,KAAK,UAAA,CAAW,GAAG,CAAA,GAAI,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;AAC/C;AAMO,SAAS,YAAA,CAAa,OAAA,GAA+B,EAAC,EAAW;AACtE,EAAA,MAAM,IAAA,GAAO,iBAAiB,OAAO,CAAA;AAErC,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,UAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,eAAA;AAAA,IACN,eAAe,MAAA,EAAwB;AACrC,MAAA,MAAA,GAAS,OAAA,CAAQ,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,MAAM,MAAM,CAAA;AAEjD,MAAA,UAAA,GAAa,cAAA,CAAe,MAAA,CAAO,IAAA,EAAM,IAAA,CAAK,GAAG,CAAA;AAAA,IACnD,CAAA;AAAA,IACA,gBAAgB,MAAA,EAAQ;AACtB,MAAA,MAAA,CAAO,WAAA,CAAY,GAAA,CAAI,YAAA,CAAa,UAAU,CAAA,EAAG,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,EAAE,GAAA,EAAK,IAAA,EAAM,CAAC,CAAA;AAAA,IACnF,CAAA;AAAA;AAAA,IAEA,kBAAA,GAAqB;AACnB,MAAA,OAAO;AAAA,QACL;AAAA,UACE,GAAA,EAAK,MAAA;AAAA,UACL,QAAA,EAAU,cAAA;AAAA,UACV,KAAA,EAAO,EAAE,GAAG,iBAAA,CAAkB,UAAU,CAAA;AAAE;AAC5C,OACF;AAAA,IACF,CAAA;AAAA,IACA,WAAA,GAAc;AACZ,MAAA,gBAAA,CAAiB,MAAM,MAAM,CAAA;AAAA,IAC/B;AAAA,GACF;AACF;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xgis/xgis3d-build",
3
- "version": "0.3.48",
3
+ "version": "0.3.54",
4
4
  "description": "Build-tool integration for @xgis/xgis3d — serves and copies CesiumJS runtime assets.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,12 +17,12 @@
17
17
  "import": "./dist/cesiumAssets.js"
18
18
  },
19
19
  "./vite": {
20
- "types": "./dist/vite-plugin.d.ts",
21
- "import": "./dist/vite-plugin.js"
20
+ "types": "./dist/vitePlugin.d.ts",
21
+ "import": "./dist/vitePlugin.js"
22
22
  },
23
23
  "./rspack": {
24
- "types": "./dist/rspack-plugin.d.ts",
25
- "import": "./dist/rspack-plugin.js"
24
+ "types": "./dist/rspackPlugin.d.ts",
25
+ "import": "./dist/rspackPlugin.js"
26
26
  }
27
27
  },
28
28
  "publishConfig": {
@@ -31,7 +31,7 @@
31
31
  "peerDependencies": {
32
32
  "@rspack/core": "^1.0.0",
33
33
  "vite": "^6.0.0 || ^7.0.0",
34
- "@xgis/xgis3d": "^0.3.48"
34
+ "@xgis/xgis3d": "^0.3.54"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@rspack/core": {
@@ -46,14 +46,14 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@rspack/core": "^1.7.12",
49
- "@types/node": "^22.10.2",
50
- "@vitest/coverage-v8": "^4.1.7",
49
+ "@types/node": "^22.20.1",
50
+ "@vitest/coverage-v8": "^4.1.12",
51
51
  "typescript": "^6.0.3",
52
- "vite": "^6.4.3",
53
- "vitest": "^4.1.7",
52
+ "vite": "^6.4.4",
53
+ "vitest": "^4.1.12",
54
54
  "@xgis/tsconfig": "0.0.0",
55
- "@xgis/eslint-config": "0.0.0",
56
- "@xgis/xgis3d": "0.3.48"
55
+ "@xgis/xgis3d": "0.3.54",
56
+ "@xgis/eslint-config": "0.0.0"
57
57
  },
58
58
  "scripts": {
59
59
  "lint": "eslint src",
@@ -1 +0,0 @@
1
- {"version":3,"file":"rspack-plugin.js","sources":["../src/rspack-plugin.ts"],"sourcesContent":["import type { Compiler } from '@rspack/core'\n\nimport type { CesiumAssetPlan, CesiumAssetsOptions } from './cesiumAssets'\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nconst PLUGIN_NAME = 'CesiumAssetsRspackPlugin'\n\n/**\n * Copies Cesium's runtime assets (workers, textures, widget CSS) into the compilation output,\n * serves them in dev, and injects `window.CESIUM_BASE_URL` into the HTML HtmlRspackPlugin emits.\n */\nexport class CesiumAssetsRspackPlugin {\n private readonly plan: CesiumAssetPlan\n\n private copied = false\n\n constructor(options: CesiumAssetsOptions = {}) {\n this.plan = planCesiumAssets(options)\n }\n\n apply(compiler: Compiler): void {\n const publicPath = resolvePublicPath(compiler.options.output.publicPath, this.plan.dir)\n // Off the compiler: getCompilationHooks rejects a compilation from a different instance.\n const { HtmlRspackPlugin } = compiler.rspack\n\n // The copy is on disk but the dev server serves from memory, so it needs the source directory.\n compiler.options.devServer = {\n ...compiler.options.devServer,\n static: [\n ...normaliseStatic(compiler.options.devServer?.static),\n { directory: this.plan.source, publicPath: `/${this.plan.dir}` },\n ],\n }\n\n // afterEmit fires per rebuild; the tree is tens of megabytes and never changes within a run.\n compiler.hooks.afterEmit.tap(PLUGIN_NAME, () => {\n if (this.copied) {\n return\n }\n\n copyCesiumAssets(this.plan, compiler.outputPath)\n this.copied = true\n })\n\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n // The hook exists even with no HTML plugin driving it, so absence is otherwise silent.\n if (!hasHtmlPlugin(compiler, HtmlRspackPlugin)) {\n compilation.warnings.push(\n new Error(\n `${PLUGIN_NAME}: HtmlRspackPlugin is required to inject the Cesium base URL meta tag. ` +\n `Set it to \"${publicPath}\" yourself if you generate HTML another way.`,\n ),\n )\n\n return\n }\n\n // First in <head> so it is parsed before any module, beating ensureCesiumBaseUrl()'s default.\n HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTagGroups.tap(\n PLUGIN_NAME,\n (data) => {\n data.headTags.unshift({\n tagName: 'meta',\n voidTag: true,\n attributes: { ...cesiumBaseUrlMeta(publicPath) },\n })\n\n return data\n },\n )\n })\n }\n}\n\nfunction hasHtmlPlugin(compiler: Compiler, HtmlRspackPlugin: unknown): boolean {\n const plugins = compiler.options.plugins ?? []\n\n return plugins.some(\n (plugin) =>\n plugin instanceof (HtmlRspackPlugin as new () => object) ||\n plugin?.constructor?.name === 'HtmlRspackPlugin',\n )\n}\n\ntype DevServerStatic = NonNullable<NonNullable<Compiler['options']['devServer']>['static']>\ntype StaticEntry = Extract<DevServerStatic, readonly unknown[]>[number]\n\n// `static` accepts a single entry, an array, or a boolean; only the first two carry entries to keep.\nfunction normaliseStatic(configured: DevServerStatic | undefined): StaticEntry[] {\n if (configured === undefined || typeof configured === 'boolean') {\n return []\n }\n\n return Array.isArray(configured) ? [...configured] : [configured as StaticEntry]\n}\n\n/**\n * `output.publicPath` may be `'auto'` (a bundler marker, not a URL), `''` (deliberately relative to\n * the document) or a function, which cannot be resolved before a compilation exists.\n */\nexport function resolvePublicPath(configured: unknown, dir: string): string {\n if (typeof configured === 'function' || configured === undefined || configured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c,UAAA,KAAe,MAAA,IAAa,eAAe,MAAA,EAAQ;AACzF,IAAA,OAAO,cAAA,CAAe,KAAK,GAAG,CAAA;AAAA,EAChC;AAEA,EAAA,OAAO,cAAA,CAAe,MAAA,CAAO,UAAU,CAAA,EAAG,GAAG,CAAA;AAC/C;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin.js","sources":["../src/vite-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport sirv from 'sirv'\nimport type { Plugin, ResolvedConfig } from 'vite'\n\nimport type { CesiumAssetsOptions } from './cesiumAssets'\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nexport type { CesiumAssetsOptions }\n\n// Runs before Vite strips `base`, so the mount has to carry it. A CDN base has no local path.\nfunction devMountPath(publicPath: string): string {\n const origin = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(publicPath)?.[0] ?? ''\n const path = publicPath.slice(origin.length)\n\n return path.startsWith('/') ? path : `/${path}`\n}\n\n/**\n * Serves Cesium's runtime assets (workers, textures, widget CSS) in dev and copies them into a\n * version-prefixed directory on build, so the directory can be cached immutably.\n */\nexport function cesiumAssets(options: CesiumAssetsOptions = {}): Plugin {\n const plan = planCesiumAssets(options)\n\n let outDir: string\n let publicPath: string\n\n return {\n name: 'cesium-assets',\n configResolved(config: ResolvedConfig) {\n outDir = resolve(config.root, config.build.outDir)\n // Without the base prefix a path-deployed app 404s every worker while the globe still renders.\n publicPath = joinPublicPath(config.base, plan.dir)\n },\n configureServer(server) {\n server.middlewares.use(devMountPath(publicPath), sirv(plan.source, { dev: true }))\n },\n // In <head> so it is parsed before any module, beating ensureCesiumBaseUrl()'s default.\n transformIndexHtml() {\n return [\n {\n tag: 'meta',\n injectTo: 'head-prepend',\n attrs: { ...cesiumBaseUrlMeta(publicPath) },\n },\n ]\n },\n writeBundle() {\n copyCesiumAssets(plan, outDir)\n },\n }\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