@kite3d/engine 0.16.0 → 0.17.0

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,11 +1,26 @@
1
- import { parse as w } from "jsonc-parser";
2
- const b = "kite3d", S = `/${b}/`;
3
- function v(t, e) {
1
+ import { parse as j } from "jsonc-parser";
2
+ const S = "kite3d", y = `/${S}/`;
3
+ function O(t, e) {
4
+ const n = `${y}@`;
5
+ return (o) => {
6
+ var c;
7
+ if (o.startsWith(n)) {
8
+ const p = new URL(o, "https://kite3d.invalid"), a = decodeURIComponent(p.pathname.slice(n.length)), r = a.indexOf("/"), d = r < 0 ? a : a.slice(0, r), f = r < 0 ? "" : a.slice(r + 1), s = e.files[d];
9
+ if (!(s != null && s.path)) throw new Error(`Unknown asset id in URL: ${d}`);
10
+ const i = (c = s.files) == null ? void 0 : c[f];
11
+ if (i) return new URL(i, t).href;
12
+ if (s.files) throw new Error(`Unknown file for asset ${d}: ${f}`);
13
+ return /^f\.[^/]+$/i.test(f) ? new URL(s.path, t).href : new URL(f, new URL(s.path, t)).href;
14
+ }
15
+ return o.startsWith(y) ? new URL(o.slice(y.length), t).href : o;
16
+ };
17
+ }
18
+ function b(t, e) {
4
19
  const n = e.dependencies;
5
- return g(n) && Object.prototype.hasOwnProperty.call(n, t);
20
+ return h(n) && Object.prototype.hasOwnProperty.call(n, t);
6
21
  }
7
- function O(t) {
8
- const e = w(t);
22
+ function x(t) {
23
+ const e = j(t);
9
24
  if (!e || typeof e != "object" || Array.isArray(e))
10
25
  throw new Error("Invalid package.json file: expected an object");
11
26
  const n = e;
@@ -13,96 +28,97 @@ function O(t) {
13
28
  throw new Error("package.json mainScene must name a text .gltf file");
14
29
  return n;
15
30
  }
16
- function x(t) {
17
- const e = w(t);
31
+ function U(t) {
32
+ const e = j(t);
18
33
  if (e.files && typeof e.files != "object")
19
34
  throw new Error("Invalid assets.json file: files should be an object");
20
35
  if (e.version !== void 0 && typeof e.version != "number")
21
36
  throw new Error("Invalid assets.json file: version should be a number");
22
37
  return e.files || (e.files = {}), e.version || (e.version = 1), e;
23
38
  }
24
- function N(t, e) {
39
+ function k(t, e) {
25
40
  const n = JSON.parse(e);
26
41
  if (!n || typeof n != "object" || !n.asset)
27
42
  throw new Error(`${t} is not a JSON glTF document`);
28
43
  }
29
- function k(t) {
44
+ function P(t) {
30
45
  var e;
31
46
  try {
32
- const n = JSON.parse(t), i = [];
33
- for (const [c, a] of (n.nodes || []).entries())
34
- for (const [p, o] of Object.entries(((e = a.extras) == null ? void 0 : e.EntityComponentPlugin) || {}))
35
- o.type !== "Generator" || !g(o.state) || i.push({
36
- componentId: p,
37
- module: typeof o.state.module == "string" ? o.state.module : "",
47
+ const n = JSON.parse(t), o = [];
48
+ for (const [c, p] of (n.nodes || []).entries())
49
+ for (const [a, r] of Object.entries(((e = p.extras) == null ? void 0 : e.EntityComponentPlugin) || {}))
50
+ r.type !== "Generator" || !h(r.state) || o.push({
51
+ componentId: a,
52
+ module: typeof r.state.module == "string" ? r.state.module : "",
38
53
  nodeIndex: c,
39
- nodeName: typeof a.name == "string" ? a.name : `Node ${c}`,
40
- params: g(o.state.params) ? o.state.params : {}
54
+ nodeName: typeof p.name == "string" ? p.name : `Node ${c}`,
55
+ params: h(r.state.params) ? r.state.params : {}
41
56
  });
42
- return i;
57
+ return o;
43
58
  } catch {
44
59
  return [];
45
60
  }
46
61
  }
47
- function A(t, e, n) {
48
- var a, p, o, f, d;
49
- const i = JSON.parse(t), c = (d = (f = (o = (p = (a = i.nodes) == null ? void 0 : a[e.nodeIndex]) == null ? void 0 : p.extras) == null ? void 0 : o.EntityComponentPlugin) == null ? void 0 : f[e.componentId]) == null ? void 0 : d.state;
50
- if (!g(c)) throw new Error(`Generator component is missing on ${e.nodeName}`);
51
- return Object.assign(c, n), { text: JSON.stringify(i, null, 2), state: c };
62
+ function E(t, e, n) {
63
+ var p, a, r, d, f;
64
+ const o = JSON.parse(t), c = (f = (d = (r = (a = (p = o.nodes) == null ? void 0 : p[e.nodeIndex]) == null ? void 0 : a.extras) == null ? void 0 : r.EntityComponentPlugin) == null ? void 0 : d[e.componentId]) == null ? void 0 : f.state;
65
+ if (!h(c)) throw new Error(`Generator component is missing on ${e.nodeName}`);
66
+ return Object.assign(c, n), { text: JSON.stringify(o, null, 2), state: c };
52
67
  }
53
- async function E(t, e) {
54
- var f, d;
55
- const n = t[b] ?? {}, i = [], a = {
68
+ async function N(t, e) {
69
+ var d, f;
70
+ const n = t[S] ?? {}, o = [], p = {
56
71
  ...t.dependencies && typeof t.dependencies == "object" && !Array.isArray(t.dependencies) ? t.dependencies : {}
57
72
  };
58
- i.push(...Object.entries(a).map(([s, r]) => ({ key: s, version: r }))), n.imports && i.push(...Object.entries(n.imports).map(([s, r]) => ({
73
+ o.push(...Object.entries(p).map(([s, i]) => ({ key: s, version: i }))), n.imports && o.push(...Object.entries(n.imports).map(([s, i]) => ({
59
74
  key: s,
60
- url: r.startsWith("@") ? void 0 : r,
61
- version: r.startsWith("@") ? r.slice(1) : ""
75
+ url: i.startsWith("@") ? void 0 : i,
76
+ version: i.startsWith("@") ? i.slice(1) : ""
62
77
  })));
63
- const p = ((f = n.plugins) == null ? void 0 : f.map((s) => {
78
+ const a = ((d = n.plugins) == null ? void 0 : d.map((s) => {
64
79
  if (typeof s != "string") return s;
65
- const r = s.match(/\((.*)\)$/);
66
- let y, l = s;
67
- if (r) {
68
- const h = r[1].trim();
69
- if (l = s.slice(0, r.index).trim(), h)
80
+ const i = s.match(/\((.*)\)$/);
81
+ let g, l = s;
82
+ if (i) {
83
+ const w = i[1].trim();
84
+ if (l = s.slice(0, i.index).trim(), w)
70
85
  try {
71
86
  const m = [];
72
- if (y = w(`[${h}]`, m), !Array.isArray(y) || m.length)
87
+ if (g = j(`[${w}]`, m), !Array.isArray(g) || m.length)
73
88
  throw console.error(m), new Error("Plugin params is not a valid array");
74
89
  } catch (m) {
75
- return console.error("Unable to parse plugin params, skipping plugin", s, h, m), null;
90
+ return console.error("Unable to parse plugin params, skipping plugin", s, w, m), null;
76
91
  }
77
92
  }
78
93
  const u = l.lastIndexOf(":");
79
94
  return {
80
95
  import: u !== -1 ? l.slice(0, u) : l,
81
96
  className: u !== -1 ? l.slice(u + 1) : void 0,
82
- params: y
97
+ params: g
83
98
  };
84
- })) || [], o = ((d = n.scripts) == null ? void 0 : d.map(
99
+ })) || [], r = ((f = n.scripts) == null ? void 0 : f.map(
85
100
  (s) => typeof s == "string" ? { import: s } : s
86
101
  )) || [];
87
102
  return {
88
- plugins: p.filter(Boolean),
89
- scripts: o,
90
- dependencies: i,
103
+ plugins: a.filter(Boolean),
104
+ scripts: r,
105
+ dependencies: o,
91
106
  viewer: n.viewer || {}
92
107
  };
93
108
  }
94
- function g(t) {
109
+ function h(t) {
95
110
  return !!t && typeof t == "object" && !Array.isArray(t);
96
111
  }
97
112
  export {
98
- S as assetUrlPrefix,
99
- v as isDependencyModuleSpecifier,
100
- x as parseAssetsJSONManifest,
101
- O as parsePackageJSON,
102
- E as parsePackageJsonSettingsConfig,
103
- k as readProjectGeneratorStates,
104
- b as settingsKey,
105
- A as updateProjectGeneratorState,
106
- N as validateSceneSource
113
+ y as assetUrlPrefix,
114
+ O as createProjectAssetURLModifier,
115
+ b as isDependencyModuleSpecifier,
116
+ U as parseAssetsJSONManifest,
117
+ x as parsePackageJSON,
118
+ N as parsePackageJsonSettingsConfig,
119
+ P as readProjectGeneratorStates,
120
+ S as settingsKey,
121
+ E as updateProjectGeneratorState,
122
+ k as validateSceneSource
107
123
  };
108
124
  //# sourceMappingURL=projectFormat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectFormat.js","sources":["../src/runtime/projectFormat.ts"],"sourcesContent":["import {parse, ParseError} from 'jsonc-parser'\n\nexport const settingsKey = 'kite3d'\nexport const assetUrlPrefix = `/${settingsKey}/`\n\nexport type JSONValue = string | number | boolean | null | JSONValue[] | {[key: string]: JSONValue}\nexport type ProjectPackageJSON = Record<string, JSONValue> & {mainScene: string}\n\nexport interface ProjectGeneratorState {\n componentId: string\n module: string\n nodeIndex: number\n nodeName: string\n params: Record<string, unknown>\n}\n\nexport interface AssetsJSONManifest {\n files: Record<string, {\n path: string\n }>\n version: number\n}\n\nexport interface ProjectDependency {\n key: string\n version: string\n url?: string\n}\n\nexport interface ExternalPlugin {\n import: string\n /** @default `default` */\n className?: string\n /** @default true */\n active?: boolean\n /** Constructor parameters. */\n params?: JSONValue[]\n}\n\nexport interface ExternalScript {\n import: string\n /** @default true */\n active?: boolean\n}\n\nexport interface ProjectViewerSettings {\n msaa?: boolean\n rgbm?: boolean\n zPrepass?: boolean\n renderScale?: number | 'auto'\n maxRenderScale?: number\n backgroundColor?: string | number | null\n modelRootScale?: number\n stencil?: boolean\n debug?: boolean\n tonemap?: boolean\n camera?: {\n type?: 'perspective' | 'orthographic'\n controlsMode?: string\n position?: [number, number, number]\n target?: [number, number, number]\n }\n maxHDRIntensity?: number\n powerPreference?: 'default' | 'high-performance' | 'low-power'\n}\n\nexport interface ProjectConfigSettings {\n plugins: ExternalPlugin[]\n scripts: ExternalScript[]\n dependencies: ProjectDependency[]\n viewer: ProjectViewerSettings\n}\n\nexport interface ProjectConfigSettingsJSON {\n plugins?: (ExternalPlugin | string)[]\n imports?: Record<string, string>\n scripts?: (ExternalScript | string)[]\n viewer?: ProjectViewerSettings\n}\n\n/** A configured script or plugin is package-backed only when it names a declared dependency exactly. */\nexport function isDependencyModuleSpecifier(\n specifier: string,\n packageJson: ProjectPackageJSON,\n): boolean {\n const dependencies = packageJson.dependencies\n return isRecord(dependencies) && Object.prototype.hasOwnProperty.call(dependencies, specifier)\n}\n\nexport function parsePackageJSON(text: string): ProjectPackageJSON {\n const json = parse(text) as unknown\n if (!json || typeof json !== 'object' || Array.isArray(json)) {\n throw new Error('Invalid package.json file: expected an object')\n }\n const packageJson = json as ProjectPackageJSON\n if (typeof packageJson.mainScene !== 'string' || !packageJson.mainScene.toLowerCase().endsWith('.gltf')) {\n throw new Error('package.json mainScene must name a text .gltf file')\n }\n return packageJson\n}\n\nexport function parseAssetsJSONManifest(text: string): AssetsJSONManifest {\n const json = parse(text) as AssetsJSONManifest\n\n if (json.files && typeof json.files !== 'object') {\n throw new Error('Invalid assets.json file: files should be an object')\n }\n if (json.version !== undefined && typeof json.version !== 'number') {\n throw new Error('Invalid assets.json file: version should be a number')\n }\n\n if (!json.files) json.files = {}\n if (!json.version) json.version = 1\n\n return json\n}\n\nexport function validateSceneSource(path: string, text: string): void {\n const document = JSON.parse(text) as {asset?: unknown}\n if (!document || typeof document !== 'object' || !document.asset) {\n throw new Error(`${path} is not a JSON glTF document`)\n }\n}\n\nexport function readProjectGeneratorStates(text: string): ProjectGeneratorState[] {\n try {\n const document = JSON.parse(text) as {\n nodes?: Array<{\n name?: unknown\n extras?: {EntityComponentPlugin?: Record<string, {type?: unknown, state?: unknown}>}\n }>\n }\n const generators: ProjectGeneratorState[] = []\n for (const [nodeIndex, node] of (document.nodes || []).entries()) {\n for (const [componentId, component] of Object.entries(node.extras?.EntityComponentPlugin || {})) {\n if (component.type !== 'Generator' || !isRecord(component.state)) continue\n generators.push({\n componentId,\n module: typeof component.state.module === 'string' ? component.state.module : '',\n nodeIndex,\n nodeName: typeof node.name === 'string' ? node.name : `Node ${nodeIndex}`,\n params: isRecord(component.state.params) ? component.state.params : {},\n })\n }\n }\n return generators\n } catch {\n return []\n }\n}\n\nexport function updateProjectGeneratorState(\n text: string,\n generator: Pick<ProjectGeneratorState, 'componentId' | 'nodeIndex' | 'nodeName'>,\n update: Partial<Pick<ProjectGeneratorState, 'module' | 'params'>>,\n): {text: string, state: Record<string, unknown>} {\n const document = JSON.parse(text) as {\n nodes?: Array<{extras?: {EntityComponentPlugin?: Record<string, {state?: unknown}>}}>\n }\n const state = document.nodes?.[generator.nodeIndex]?.extras?.EntityComponentPlugin?.[generator.componentId]?.state\n if (!isRecord(state)) throw new Error(`Generator component is missing on ${generator.nodeName}`)\n Object.assign(state, update)\n return {text: JSON.stringify(document, null, 2), state}\n}\n\nexport async function parsePackageJsonSettingsConfig(json: ProjectPackageJSON, _project?: unknown): Promise<ProjectConfigSettings> {\n const config = (json[settingsKey] ?? {}) as ProjectConfigSettingsJSON\n const dependencies: ProjectDependency[] = []\n const packageDependencies = json.dependencies && typeof json.dependencies === 'object' && !Array.isArray(json.dependencies)\n ? json.dependencies as Record<string, string>\n : {}\n const deps: Record<string, string> = {\n ...packageDependencies,\n }\n\n dependencies.push(...Object.entries(deps).map(([key, version]) => ({key, version})))\n\n if (config.imports) {\n dependencies.push(...Object.entries(config.imports).map(([key, url]) => ({\n key,\n url: !url.startsWith('@') ? url : undefined,\n version: url.startsWith('@') ? url.slice(1) : '',\n })))\n }\n\n const plugins = config.plugins?.map((entry) => {\n if (typeof entry !== 'string') return entry\n\n const match = entry.match(/\\((.*)\\)$/)\n let params: JSONValue[] | undefined\n let spec = entry\n\n if (match) {\n const paramString = match[1].trim()\n spec = entry.slice(0, match.index).trim()\n if (paramString) {\n try {\n const errors: ParseError[] = []\n params = parse(`[${paramString}]`, errors)\n if (!Array.isArray(params) || errors.length) {\n console.error(errors)\n throw new Error('Plugin params is not a valid array')\n }\n } catch (error) {\n console.error('Unable to parse plugin params, skipping plugin', entry, paramString, error)\n return null\n }\n }\n }\n\n const separator = spec.lastIndexOf(':')\n return {\n import: separator !== -1 ? spec.slice(0, separator) : spec,\n className: separator !== -1 ? spec.slice(separator + 1) : undefined,\n params,\n } satisfies ExternalPlugin\n }) || []\n\n const scripts = config.scripts?.map((entry) =>\n typeof entry === 'string' ? {import: entry} : entry\n ) || []\n\n return {\n plugins: plugins.filter(Boolean) as ExternalPlugin[],\n scripts,\n dependencies,\n viewer: config.viewer || {},\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n"],"names":["settingsKey","assetUrlPrefix","isDependencyModuleSpecifier","specifier","packageJson","dependencies","isRecord","parsePackageJSON","text","json","parse","parseAssetsJSONManifest","validateSceneSource","path","document","readProjectGeneratorStates","generators","nodeIndex","node","componentId","component","_a","updateProjectGeneratorState","generator","update","state","_e","_d","_c","_b","parsePackageJsonSettingsConfig","_project","config","deps","key","version","url","plugins","entry","match","params","spec","paramString","errors","error","separator","scripts","value"],"mappings":";AAEO,MAAMA,IAAc,UACdC,IAAiB,IAAID,CAAW;AA8EtC,SAASE,EACZC,GACAC,GACO;AACP,QAAMC,IAAeD,EAAY;AACjC,SAAOE,EAASD,CAAY,KAAK,OAAO,UAAU,eAAe,KAAKA,GAAcF,CAAS;AACjG;AAEO,SAASI,EAAiBC,GAAkC;AAC/D,QAAMC,IAAOC,EAAMF,CAAI;AACvB,MAAI,CAACC,KAAQ,OAAOA,KAAS,YAAY,MAAM,QAAQA,CAAI;AACvD,UAAM,IAAI,MAAM,+CAA+C;AAEnE,QAAML,IAAcK;AACpB,MAAI,OAAOL,EAAY,aAAc,YAAY,CAACA,EAAY,UAAU,YAAA,EAAc,SAAS,OAAO;AAClG,UAAM,IAAI,MAAM,oDAAoD;AAExE,SAAOA;AACX;AAEO,SAASO,EAAwBH,GAAkC;AACtE,QAAMC,IAAOC,EAAMF,CAAI;AAEvB,MAAIC,EAAK,SAAS,OAAOA,EAAK,SAAU;AACpC,UAAM,IAAI,MAAM,qDAAqD;AAEzE,MAAIA,EAAK,YAAY,UAAa,OAAOA,EAAK,WAAY;AACtD,UAAM,IAAI,MAAM,sDAAsD;AAG1E,SAAKA,EAAK,UAAOA,EAAK,QAAQ,CAAA,IACzBA,EAAK,YAASA,EAAK,UAAU,IAE3BA;AACX;AAEO,SAASG,EAAoBC,GAAcL,GAAoB;AAClE,QAAMM,IAAW,KAAK,MAAMN,CAAI;AAChC,MAAI,CAACM,KAAY,OAAOA,KAAa,YAAY,CAACA,EAAS;AACvD,UAAM,IAAI,MAAM,GAAGD,CAAI,8BAA8B;AAE7D;AAEO,SAASE,EAA2BP,GAAuC;;AAC9E,MAAI;AACA,UAAMM,I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AM,GAAGI,CAAS,IAAIJ;AAAA,MACtD,WAAWI,MAAc,KAAKJ,EAAK,MAAMI,IAAY,CAAC,IAAI;AAAA,MAC1D,QAAAL;AAAA,IAAA;AAAA,EAER,OAAM,CAAA,GAEAM,MAAUjB,IAAAG,EAAO,YAAP,gBAAAH,EAAgB;AAAA,IAAI,CAACS,MACjC,OAAOA,KAAU,WAAW,EAAC,QAAQA,MAASA;AAAA,QAC7C,CAAA;AAEL,SAAO;AAAA,IACH,SAASD,EAAQ,OAAO,OAAO;AAAA,IAC/B,SAAAS;AAAA,IACA,cAAAzC;AAAA,IACA,QAAQ2B,EAAO,UAAU,CAAA;AAAA,EAAC;AAElC;AAEA,SAAS1B,EAASyC,GAAkD;AAChE,SAAO,EAAQA,KAAU,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAC9E;"}
1
+ {"version":3,"file":"projectFormat.js","sources":["../src/runtime/projectFormat.ts"],"sourcesContent":["import {parse, ParseError} from 'jsonc-parser'\n\nexport const settingsKey = 'kite3d'\nexport const assetUrlPrefix = `/${settingsKey}/`\n\nexport type JSONValue = string | number | boolean | null | JSONValue[] | {[key: string]: JSONValue}\nexport type ProjectPackageJSON = Record<string, JSONValue> & {mainScene: string}\n\nexport interface ProjectGeneratorState {\n componentId: string\n module: string\n nodeIndex: number\n nodeName: string\n params: Record<string, unknown>\n}\n\nexport interface AssetsJSONManifest {\n files: Record<string, {\n path: string\n files?: Record<string, string>\n }>\n version: number\n}\n\nexport function createProjectAssetURLModifier(base: URL, assets: AssetsJSONManifest) {\n const assetIdPrefix = `${assetUrlPrefix}@`\n return (url: string): string => {\n if (url.startsWith(assetIdPrefix)) {\n const request = new URL(url, 'https://kite3d.invalid')\n const relative = decodeURIComponent(request.pathname.slice(assetIdPrefix.length))\n const slash = relative.indexOf('/')\n const id = slash < 0 ? relative : relative.slice(0, slash)\n const assetPath = slash < 0 ? '' : relative.slice(slash + 1)\n const asset = assets.files[id]\n if (!asset?.path) throw new Error(`Unknown asset id in URL: ${id}`)\n const registered = asset.files?.[assetPath]\n if (registered) return new URL(registered, base).href\n if (asset.files) throw new Error(`Unknown file for asset ${id}: ${assetPath}`)\n if (/^f\\.[^/]+$/i.test(assetPath)) return new URL(asset.path, base).href\n return new URL(assetPath, new URL(asset.path, base)).href\n }\n if (url.startsWith(assetUrlPrefix)) {\n return new URL(url.slice(assetUrlPrefix.length), base).href\n }\n return url\n }\n}\n\nexport interface ProjectDependency {\n key: string\n version: string\n url?: string\n}\n\nexport interface ExternalPlugin {\n import: string\n /** @default `default` */\n className?: string\n /** @default true */\n active?: boolean\n /** Constructor parameters. */\n params?: JSONValue[]\n}\n\nexport interface ExternalScript {\n import: string\n /** @default true */\n active?: boolean\n}\n\nexport interface ProjectViewerSettings {\n msaa?: boolean\n rgbm?: boolean\n zPrepass?: boolean\n renderScale?: number | 'auto'\n maxRenderScale?: number\n backgroundColor?: string | number | null\n modelRootScale?: number\n stencil?: boolean\n debug?: boolean\n tonemap?: boolean\n camera?: {\n type?: 'perspective' | 'orthographic'\n controlsMode?: string\n position?: [number, number, number]\n target?: [number, number, number]\n }\n maxHDRIntensity?: number\n powerPreference?: 'default' | 'high-performance' | 'low-power'\n}\n\nexport interface ProjectConfigSettings {\n plugins: ExternalPlugin[]\n scripts: ExternalScript[]\n dependencies: ProjectDependency[]\n viewer: ProjectViewerSettings\n}\n\nexport interface ProjectConfigSettingsJSON {\n plugins?: (ExternalPlugin | string)[]\n imports?: Record<string, string>\n scripts?: (ExternalScript | string)[]\n viewer?: ProjectViewerSettings\n}\n\n/** A configured script or plugin is package-backed only when it names a declared dependency exactly. */\nexport function isDependencyModuleSpecifier(\n specifier: string,\n packageJson: ProjectPackageJSON,\n): boolean {\n const dependencies = packageJson.dependencies\n return isRecord(dependencies) && Object.prototype.hasOwnProperty.call(dependencies, specifier)\n}\n\nexport function parsePackageJSON(text: string): ProjectPackageJSON {\n const json = parse(text) as unknown\n if (!json || typeof json !== 'object' || Array.isArray(json)) {\n throw new Error('Invalid package.json file: expected an object')\n }\n const packageJson = json as ProjectPackageJSON\n if (typeof packageJson.mainScene !== 'string' || !packageJson.mainScene.toLowerCase().endsWith('.gltf')) {\n throw new Error('package.json mainScene must name a text .gltf file')\n }\n return packageJson\n}\n\nexport function parseAssetsJSONManifest(text: string): AssetsJSONManifest {\n const json = parse(text) as AssetsJSONManifest\n\n if (json.files && typeof json.files !== 'object') {\n throw new Error('Invalid assets.json file: files should be an object')\n }\n if (json.version !== undefined && typeof json.version !== 'number') {\n throw new Error('Invalid assets.json file: version should be a number')\n }\n\n if (!json.files) json.files = {}\n if (!json.version) json.version = 1\n\n return json\n}\n\nexport function validateSceneSource(path: string, text: string): void {\n const document = JSON.parse(text) as {asset?: unknown}\n if (!document || typeof document !== 'object' || !document.asset) {\n throw new Error(`${path} is not a JSON glTF document`)\n }\n}\n\nexport function readProjectGeneratorStates(text: string): ProjectGeneratorState[] {\n try {\n const document = JSON.parse(text) as {\n nodes?: Array<{\n name?: unknown\n extras?: {EntityComponentPlugin?: Record<string, {type?: unknown, state?: unknown}>}\n }>\n }\n const generators: ProjectGeneratorState[] = []\n for (const [nodeIndex, node] of (document.nodes || []).entries()) {\n for (const [componentId, component] of Object.entries(node.extras?.EntityComponentPlugin || {})) {\n if (component.type !== 'Generator' || !isRecord(component.state)) continue\n generators.push({\n componentId,\n module: typeof component.state.module === 'string' ? component.state.module : '',\n nodeIndex,\n nodeName: typeof node.name === 'string' ? node.name : `Node ${nodeIndex}`,\n params: isRecord(component.state.params) ? component.state.params : {},\n })\n }\n }\n return generators\n } catch {\n return []\n }\n}\n\nexport function updateProjectGeneratorState(\n text: string,\n generator: Pick<ProjectGeneratorState, 'componentId' | 'nodeIndex' | 'nodeName'>,\n update: Partial<Pick<ProjectGeneratorState, 'module' | 'params'>>,\n): {text: string, state: Record<string, unknown>} {\n const document = JSON.parse(text) as {\n nodes?: Array<{extras?: {EntityComponentPlugin?: Record<string, {state?: unknown}>}}>\n }\n const state = document.nodes?.[generator.nodeIndex]?.extras?.EntityComponentPlugin?.[generator.componentId]?.state\n if (!isRecord(state)) throw new Error(`Generator component is missing on ${generator.nodeName}`)\n Object.assign(state, update)\n return {text: JSON.stringify(document, null, 2), state}\n}\n\nexport async function parsePackageJsonSettingsConfig(json: ProjectPackageJSON, _project?: unknown): Promise<ProjectConfigSettings> {\n const config = (json[settingsKey] ?? {}) as ProjectConfigSettingsJSON\n const dependencies: ProjectDependency[] = []\n const packageDependencies = json.dependencies && typeof json.dependencies === 'object' && !Array.isArray(json.dependencies)\n ? json.dependencies as Record<string, string>\n : {}\n const deps: Record<string, string> = {\n ...packageDependencies,\n }\n\n dependencies.push(...Object.entries(deps).map(([key, version]) => ({key, version})))\n\n if (config.imports) {\n dependencies.push(...Object.entries(config.imports).map(([key, url]) => ({\n key,\n url: !url.startsWith('@') ? url : undefined,\n version: url.startsWith('@') ? url.slice(1) : '',\n })))\n }\n\n const plugins = config.plugins?.map((entry) => {\n if (typeof entry !== 'string') return entry\n\n const match = entry.match(/\\((.*)\\)$/)\n let params: JSONValue[] | undefined\n let spec = entry\n\n if (match) {\n const paramString = match[1].trim()\n spec = entry.slice(0, match.index).trim()\n if (paramString) {\n try {\n const errors: ParseError[] = []\n params = parse(`[${paramString}]`, errors)\n if (!Array.isArray(params) || errors.length) {\n console.error(errors)\n throw new Error('Plugin params is not a valid array')\n }\n } catch (error) {\n console.error('Unable to parse plugin params, skipping plugin', entry, paramString, error)\n return null\n }\n }\n }\n\n const separator = spec.lastIndexOf(':')\n return {\n import: separator !== -1 ? spec.slice(0, separator) : spec,\n className: separator !== -1 ? spec.slice(separator + 1) : undefined,\n params,\n } satisfies ExternalPlugin\n }) || []\n\n const scripts = config.scripts?.map((entry) =>\n typeof entry === 'string' ? {import: entry} : entry\n ) || []\n\n return {\n plugins: plugins.filter(Boolean) as ExternalPlugin[],\n scripts,\n dependencies,\n viewer: config.viewer || {},\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n"],"names":["settingsKey","assetUrlPrefix","createProjectAssetURLModifier","base","assets","assetIdPrefix","url","request","relative","slash","id","assetPath","asset","registered","_a","isDependencyModuleSpecifier","specifier","packageJson","dependencies","isRecord","parsePackageJSON","text","json","parse","parseAssetsJSONManifest","validateSceneSource","path","document","readProjectGeneratorStates","generators","nodeIndex","node","componentId","component","updateProjectGeneratorState","generator","update","state","_e","_d","_c","_b","parsePackageJsonSettingsConfig","_project","config","deps","key","version","plugins","entry","match","params","spec","paramString","errors","error","separator","scripts","value"],"mappings":";AAEO,MAAMA,IAAc,UACdC,IAAiB,IAAID,CAAW;AAqBtC,SAASE,EAA8BC,GAAWC,GAA4B;AACjF,QAAMC,IAAgB,GAAGJ,CAAc;AACvC,SAAO,CAACK,MAAwB;;AAC5B,QAAIA,EAAI,WAAWD,CAAa,GAAG;AAC/B,YAAME,IAAU,IAAI,IAAID,GAAK,wBAAwB,GAC/CE,IAAW,mBAAmBD,EAAQ,SAAS,MAAMF,EAAc,MAAM,CAAC,GAC1EI,IAAQD,EAAS,QAAQ,GAAG,GAC5BE,IAAKD,IAAQ,IAAID,IAAWA,EAAS,MAAM,GAAGC,CAAK,GACnDE,IAAYF,IAAQ,IAAI,KAAKD,EAAS,MAAMC,IAAQ,CAAC,GACrDG,IAAQR,EAAO,MAAMM,CAAE;AAC7B,UAAI,EAACE,KAAA,QAAAA,EAAO,MAAM,OAAM,IAAI,MAAM,4BAA4BF,CAAE,EAAE;AAClE,YAAMG,KAAaC,IAAAF,EAAM,UAAN,gBAAAE,EAAcH;AACjC,UAAIE,EAAY,QAAO,IAAI,IAAIA,GAAYV,CAAI,EAAE;AACjD,UAAIS,EAAM,MAAO,OAAM,IAAI,MAAM,0BAA0BF,CAAE,KAAKC,CAAS,EAAE;AAC7E,aAAI,cAAc,KAAKA,CAAS,IAAU,IAAI,IAAIC,EAAM,MAAMT,CAAI,EAAE,OAC7D,IAAI,IAAIQ,GA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I,MAAc,KAAKJ,EAAK,MAAMI,IAAY,CAAC,IAAI;AAAA,MAC1D,QAAAL;AAAA,IAAA;AAAA,EAER,OAAM,CAAA,GAEAM,MAAUhB,IAAAG,EAAO,YAAP,gBAAAH,EAAgB;AAAA,IAAI,CAACQ,MACjC,OAAOA,KAAU,WAAW,EAAC,QAAQA,MAASA;AAAA,QAC7C,CAAA;AAEL,SAAO;AAAA,IACH,SAASD,EAAQ,OAAO,OAAO;AAAA,IAC/B,SAAAS;AAAA,IACA,cAAAvC;AAAA,IACA,QAAQ0B,EAAO,UAAU,CAAA;AAAA,EAAC;AAElC;AAEA,SAASzB,EAASuC,GAAkD;AAChE,SAAO,EAAQA,KAAU,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAC9E;"}
@@ -16,9 +16,11 @@ export interface ProjectGeneratorState {
16
16
  export interface AssetsJSONManifest {
17
17
  files: Record<string, {
18
18
  path: string;
19
+ files?: Record<string, string>;
19
20
  }>;
20
21
  version: number;
21
22
  }
23
+ export declare function createProjectAssetURLModifier(base: URL, assets: AssetsJSONManifest): (url: string) => string;
22
24
  export interface ProjectDependency {
23
25
  key: string;
24
26
  version: string;
package/dist/runtime.js CHANGED
@@ -71388,11 +71388,26 @@ var E1;
71388
71388
  n[n.InvalidSymbol = 1] = "InvalidSymbol", n[n.InvalidNumberFormat = 2] = "InvalidNumberFormat", n[n.PropertyNameExpected = 3] = "PropertyNameExpected", n[n.ValueExpected = 4] = "ValueExpected", n[n.ColonExpected = 5] = "ColonExpected", n[n.CommaExpected = 6] = "CommaExpected", n[n.CloseBraceExpected = 7] = "CloseBraceExpected", n[n.CloseBracketExpected = 8] = "CloseBracketExpected", n[n.EndOfFileExpected = 9] = "EndOfFileExpected", n[n.InvalidCommentToken = 10] = "InvalidCommentToken", n[n.UnexpectedEndOfComment = 11] = "UnexpectedEndOfComment", n[n.UnexpectedEndOfString = 12] = "UnexpectedEndOfString", n[n.UnexpectedEndOfNumber = 13] = "UnexpectedEndOfNumber", n[n.InvalidUnicode = 14] = "InvalidUnicode", n[n.InvalidEscapeCharacter = 15] = "InvalidEscapeCharacter", n[n.InvalidCharacter = 16] = "InvalidCharacter";
71389
71389
  })(E1 || (E1 = {}));
71390
71390
  const $2 = "kite3d", Hv = `/${$2}/`;
71391
+ function e$(n, e) {
71392
+ const t = `${Hv}@`;
71393
+ return (i) => {
71394
+ var s;
71395
+ if (i.startsWith(t)) {
71396
+ const r = new URL(i, "https://kite3d.invalid"), a = decodeURIComponent(r.pathname.slice(t.length)), o = a.indexOf("/"), l = o < 0 ? a : a.slice(0, o), c = o < 0 ? "" : a.slice(o + 1), h = e.files[l];
71397
+ if (!(h != null && h.path)) throw new Error(`Unknown asset id in URL: ${l}`);
71398
+ const u = (s = h.files) == null ? void 0 : s[c];
71399
+ if (u) return new URL(u, n).href;
71400
+ if (h.files) throw new Error(`Unknown file for asset ${l}: ${c}`);
71401
+ return /^f\.[^/]+$/i.test(c) ? new URL(h.path, n).href : new URL(c, new URL(h.path, n)).href;
71402
+ }
71403
+ return i.startsWith(Hv) ? new URL(i.slice(Hv.length), n).href : i;
71404
+ };
71405
+ }
71391
71406
  function eL(n, e) {
71392
71407
  const t = e.dependencies;
71393
71408
  return CA(t) && Object.prototype.hasOwnProperty.call(t, n);
71394
71409
  }
71395
- function e$(n) {
71410
+ function t$(n) {
71396
71411
  const e = Ox(n);
71397
71412
  if (!e || typeof e != "object" || Array.isArray(e))
71398
71413
  throw new Error("Invalid package.json file: expected an object");
@@ -71401,7 +71416,7 @@ function e$(n) {
71401
71416
  throw new Error("package.json mainScene must name a text .gltf file");
71402
71417
  return t;
71403
71418
  }
71404
- function t$(n) {
71419
+ function i$(n) {
71405
71420
  const e = Ox(n);
71406
71421
  if (e.files && typeof e.files != "object")
71407
71422
  throw new Error("Invalid assets.json file: files should be an object");
@@ -71438,7 +71453,7 @@ function Bee(n, e, t) {
71438
71453
  if (!CA(s)) throw new Error(`Generator component is missing on ${e.nodeName}`);
71439
71454
  return Object.assign(s, t), { text: JSON.stringify(i, null, 2), state: s };
71440
71455
  }
71441
- async function i$(n, e) {
71456
+ async function n$(n, e) {
71442
71457
  var l, c;
71443
71458
  const t = n[$2] ?? {}, i = [], r = {
71444
71459
  ...n.dependencies && typeof n.dependencies == "object" && !Array.isArray(n.dependencies) ? n.dependencies : {}
@@ -71501,7 +71516,7 @@ async function tL({
71501
71516
  const u = l$(n), [d, p] = await Promise.all([
71502
71517
  S1(new URL("package.json", u)),
71503
71518
  S1(new URL("assets.json", u))
71504
- ]), f = e$(d), g = await i$(f), m = t$(p), A = {
71519
+ ]), f = t$(d), g = await n$(f), m = i$(p), A = {
71505
71520
  packageJson: f,
71506
71521
  config: g,
71507
71522
  assetsManifest: m,
@@ -71529,8 +71544,8 @@ async function tL({
71529
71544
  new kB()
71530
71545
  ]
71531
71546
  }), o.timeline.endTime = 0, h = FZ(), y.addComponentType(p_), y.addComponentType(wp), wp.configureViewer(o, { base: u, onError: a });
71532
- const v = r$(u, m);
71533
- o.assetManager.importer.addURLModifier(v), c = () => o == null ? void 0 : o.assetManager.importer.removeURLModifier(v), l = new KZ(o, a), await s$(o, A, u, i, s), await n$(o, A, u, i, s);
71547
+ const v = e$(u, m);
71548
+ o.assetManager.importer.addURLModifier(v), c = () => o == null ? void 0 : o.assetManager.importer.removeURLModifier(v), l = new KZ(o, a), await r$(o, A, u, i, s), await s$(o, A, u, i, s);
71534
71549
  const _ = new URL(A.mainScene, u).href, w = await o.load(_, { importAsModelRoot: !0 });
71535
71550
  if (!(w != null && w.isObject3D))
71536
71551
  throw new Error(`The main scene did not load as an Object3D: ${_}`);
@@ -71559,7 +71574,7 @@ async function tL({
71559
71574
  throw l == null || l.dispose(), c == null || c(), h == null || h.dispose(), o == null || o.dispose(), a(u), u;
71560
71575
  }
71561
71576
  }
71562
- async function n$(n, e, t, i, s) {
71577
+ async function s$(n, e, t, i, s) {
71563
71578
  const { config: r, packageJson: a } = e;
71564
71579
  for (const o of r.plugins) {
71565
71580
  if (o.active === !1) continue;
@@ -71567,7 +71582,7 @@ async function n$(n, e, t, i, s) {
71567
71582
  n.getPlugin(h) || await n.addPlugin(h, ...o.params || []);
71568
71583
  }
71569
71584
  }
71570
- async function s$(n, e, t, i, s) {
71585
+ async function r$(n, e, t, i, s) {
71571
71586
  const { config: r, packageJson: a } = e, o = [];
71572
71587
  for (const l of r.scripts) {
71573
71588
  if (l.active === !1) continue;
@@ -71576,17 +71591,6 @@ async function s$(n, e, t, i, s) {
71576
71591
  }
71577
71592
  await r7(n, o);
71578
71593
  }
71579
- function r$(n, e) {
71580
- const t = `${Hv}@`;
71581
- return (i) => {
71582
- if (i.startsWith(t)) {
71583
- const s = i.slice(t.length).split("/", 1)[0], r = e.files[s];
71584
- if (!(r != null && r.path)) throw new Error(`Unknown asset id in URL: ${s}`);
71585
- return new URL(r.path, n).href;
71586
- }
71587
- return i.startsWith(Hv) ? new URL(i.slice(Hv.length), n).href : i;
71588
- };
71589
- }
71590
71594
  function a$(n, e, t, i, s) {
71591
71595
  return eL(n.import, e) ? n.import : Fx(n.import, t, i, s).href;
71592
71596
  }
@@ -71633,7 +71637,7 @@ function h$(n) {
71633
71637
  console.error("[kite3d] Runtime error", e), n == null || n(e);
71634
71638
  };
71635
71639
  }
71636
- const u$ = "0.16.0", d$ = {
71640
+ const u$ = "0.17.0", d$ = {
71637
71641
  version: u$
71638
71642
  }, Fee = d$.version, Uee = [], iL = new TextEncoder();
71639
71643
  async function kee(n, e = {}) {
@@ -72586,6 +72590,7 @@ export {
72586
72590
  Ca as createDiv,
72587
72591
  Lee as createGame,
72588
72592
  VT as createImage,
72593
+ e$ as createProjectAssetURLModifier,
72589
72594
  oP as createRenderTargetKey,
72590
72595
  Rj as createScriptFromURL,
72591
72596
  Sx as createShapeFromPreset,
@@ -72724,10 +72729,10 @@ export {
72724
72729
  st as onChange3,
72725
72730
  Ol as onChangeDispatchEvent,
72726
72731
  eD as overrideThreeCache,
72727
- t$ as parseAssetsJSONManifest,
72732
+ i$ as parseAssetsJSONManifest,
72728
72733
  Ip as parseFileExtension,
72729
- e$ as parsePackageJSON,
72730
- i$ as parsePackageJsonSettingsConfig,
72734
+ t$ as parsePackageJSON,
72735
+ n$ as parsePackageJsonSettingsConfig,
72731
72736
  lz as pathJoin,
72732
72737
  Tee as persistenceReport,
72733
72738
  Nj as prettyScrollbar,