@xgis/xgis3d-build 0.3.55 → 0.4.1
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.
package/dist/cesiumAssets.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
export declare const CESIUM_ASSET_ENTRIES: readonly ["Workers", "ThirdParty", "Assets", "Widgets"];
|
|
2
|
-
export interface
|
|
2
|
+
export interface ICesiumAssetsOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Directory the assets are served under. Must match the base URL the runtime reads.
|
|
5
5
|
* Defaults to `cesium-<version>`, which is what `ensureCesiumBaseUrl()` sets.
|
|
6
6
|
*/
|
|
7
7
|
base?: string;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface ICesiumAssetPlan {
|
|
10
10
|
readonly source: string;
|
|
11
11
|
readonly licenseFile: string;
|
|
12
12
|
readonly dir: string;
|
|
13
13
|
readonly entries: readonly string[];
|
|
14
14
|
}
|
|
15
|
-
export declare function planCesiumAssets(options?:
|
|
16
|
-
export declare function copyCesiumAssets(plan:
|
|
15
|
+
export declare function planCesiumAssets(options?: ICesiumAssetsOptions): ICesiumAssetPlan;
|
|
16
|
+
export declare function copyCesiumAssets(plan: ICesiumAssetPlan, outDir: string): void;
|
|
17
17
|
/**
|
|
18
18
|
* Joins a build-tool path prefix (Vite `base`, Rspack `output.publicPath`) with the asset
|
|
19
19
|
* directory. An empty prefix means "relative to the document", which is a deliberate setting.
|
|
20
20
|
*/
|
|
21
21
|
export declare function joinPublicPath(prefix: string, dir: string): string;
|
|
22
22
|
export declare const CESIUM_BASE_URL_META = "xgis-cesium-base-url";
|
|
23
|
-
export interface
|
|
23
|
+
export interface ICesiumBaseUrlMeta {
|
|
24
24
|
readonly name: string;
|
|
25
25
|
readonly content: string;
|
|
26
26
|
}
|
|
27
|
-
export declare function cesiumBaseUrlMeta(publicPath: string):
|
|
27
|
+
export declare function cesiumBaseUrlMeta(publicPath: string): ICesiumBaseUrlMeta;
|
package/dist/cesiumAssets.js.map
CHANGED
|
@@ -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
|
|
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 ICesiumAssetsOptions {\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 ICesiumAssetPlan {\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: ICesiumAssetsOptions = {}): ICesiumAssetPlan {\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: ICesiumAssetPlan, 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 ICesiumBaseUrlMeta {\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): ICesiumBaseUrlMeta {\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,MAAM,IAAI,KAAA,CAAM,CAAA,8CAAA,EAAiD,KAAK,SAAA,CAAU,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AAEA,EAAA,IAAI,GAAA,CAAI,QAAA,CAAS,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,oDAAA,EAAuD,KAAK,SAAA,CAAU,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EAC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EAAa,IAAA,CAAK,QAAQ,IAAA,CAAK,GAAA,EAAK,YAAY,CAAC,CAAA;AAC/D;AAMO,SAAS,cAAA,CAAe,QAAgB,GAAA,EAAqB;AAClE,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,GAAA;AAAA,EACT;AAGA,EAAA,MAAM,SAAS,+BAAA,CAAgC,IAAA,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,EAAwC;AACxE,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;;"}
|
package/dist/rspackPlugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ICesiumAssetsOptions } from './cesiumAssets';
|
|
3
3
|
/**
|
|
4
4
|
* Copies Cesium's runtime assets (workers, textures, widget CSS) into the compilation output,
|
|
5
5
|
* serves them in dev, and injects `window.CESIUM_BASE_URL` into the HTML HtmlRspackPlugin emits.
|
|
@@ -7,7 +7,7 @@ import type { CesiumAssetsOptions } from './cesiumAssets';
|
|
|
7
7
|
export declare class CesiumAssetsRspackPlugin {
|
|
8
8
|
private readonly plan;
|
|
9
9
|
private copied;
|
|
10
|
-
constructor(options?:
|
|
10
|
+
constructor(options?: ICesiumAssetsOptions);
|
|
11
11
|
apply(compiler: Compiler): void;
|
|
12
12
|
}
|
|
13
13
|
/**
|
package/dist/rspackPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspackPlugin.js","sources":["../src/rspackPlugin.ts"],"sourcesContent":["import type { Compiler } from '@rspack/core'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"rspackPlugin.js","sources":["../src/rspackPlugin.ts"],"sourcesContent":["import type { Compiler } from '@rspack/core'\n\nimport type { ICesiumAssetPlan, ICesiumAssetsOptions } 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: ICesiumAssetPlan\n\n private copied = false\n\n constructor(options: ICesiumAssetsOptions = {}) {\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,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,cAAA,CAAe,MAAA,CAAO,UAAU,CAAA,EAAG,GAAG,CAAA;AAC/C;;"}
|
package/dist/vitePlugin.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import type {
|
|
3
|
-
export type {
|
|
2
|
+
import type { ICesiumAssetsOptions } from './cesiumAssets';
|
|
3
|
+
export type { ICesiumAssetsOptions };
|
|
4
4
|
/**
|
|
5
5
|
* Serves Cesium's runtime assets (workers, textures, widget CSS) in dev and copies them into a
|
|
6
6
|
* version-prefixed directory on build, so the directory can be cached immutably.
|
|
7
7
|
*/
|
|
8
|
-
export declare function cesiumAssets(options?:
|
|
8
|
+
export declare function cesiumAssets(options?: ICesiumAssetsOptions): Plugin;
|
package/dist/vitePlugin.js.map
CHANGED
|
@@ -1 +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 {
|
|
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 { ICesiumAssetsOptions } from './cesiumAssets'\nimport {\n cesiumBaseUrlMeta,\n copyCesiumAssets,\n joinPublicPath,\n planCesiumAssets,\n} from './cesiumAssets'\n\nexport type { ICesiumAssetsOptions }\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: ICesiumAssetsOptions = {}): 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,GAAgC,EAAC,EAAW;AACvE,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
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Build-tool integration for @xgis/xgis3d — serves and copies CesiumJS runtime assets.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -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.
|
|
34
|
+
"@xgis/xgis3d": "^0.4.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@rspack/core": {
|
|
@@ -47,19 +47,17 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@rspack/core": "^1.7.12",
|
|
49
49
|
"@types/node": "^22.20.1",
|
|
50
|
-
"@vitest/coverage-v8": "^4.1.12",
|
|
51
50
|
"typescript": "^6.0.3",
|
|
52
51
|
"vite": "^6.4.4",
|
|
53
52
|
"vitest": "^4.1.12",
|
|
53
|
+
"@xgis/eslint-config": "0.0.0",
|
|
54
54
|
"@xgis/tsconfig": "0.0.0",
|
|
55
|
-
"@xgis/xgis3d": "0.
|
|
56
|
-
"@xgis/eslint-config": "0.0.0"
|
|
55
|
+
"@xgis/xgis3d": "0.4.1"
|
|
57
56
|
},
|
|
58
57
|
"scripts": {
|
|
59
58
|
"lint": "eslint src",
|
|
60
59
|
"typecheck": "tsc --noEmit",
|
|
61
60
|
"test": "vitest run",
|
|
62
|
-
"test:coverage": "vitest run --coverage",
|
|
63
61
|
"build:lib": "vite build --config vite.lib.config.ts && tsc -p tsconfig.build.json"
|
|
64
62
|
},
|
|
65
63
|
"main": "./dist/cesiumAssets.js",
|