@nebula-spatial/studio 0.1.0 → 0.1.2

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.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
  3. package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
  4. package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
  5. package/dist/{builders-BAXRR5o5.js → builders-lydx4-Rh.js} +1 -1
  6. package/dist/core/session-persistence-controller.d.ts +55 -0
  7. package/dist/doc/placement-policy.d.ts +4 -0
  8. package/dist/editor/editor.d.ts +3 -1
  9. package/dist/editor/index.d.ts +2 -0
  10. package/dist/editor/session-persistence.d.ts +54 -0
  11. package/dist/editor.js +727 -490
  12. package/dist/export-evidence-z2Ne7Trf.js +2387 -0
  13. package/dist/generalization.js +2 -2
  14. package/dist/index.d.ts +4 -2
  15. package/dist/index.js +314 -306
  16. package/dist/mjcf-visual-IOy-ucto.js +72 -0
  17. package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
  18. package/dist/persist/indexeddb-store.d.ts +22 -2
  19. package/dist/persist/session.d.ts +22 -0
  20. package/dist/persist/snapshot.d.ts +24 -0
  21. package/dist/{physics-facts-tfQYyNTD.js → physics-facts-D-URIBrt.js} +8 -7
  22. package/dist/{placement-policy-DY_FNRDu.js → placement-policy-C6dV6Tf-.js} +161 -141
  23. package/dist/ports/persistence.d.ts +45 -1
  24. package/dist/project/contracts.d.ts +3 -0
  25. package/dist/remote-asset-resolver-D-UeyDMD.js +311 -0
  26. package/dist/{scene-graph-DBLKAhxa.js → scene-graph-DVOXjMmp.js} +2 -2
  27. package/dist/scene-session-PhoFXFCY.js +22006 -0
  28. package/dist/scene.js +2 -2
  29. package/dist/session-2bp8YOA4.js +963 -0
  30. package/dist/session-B3WbC7Y2.js +296 -0
  31. package/dist/session-B9kEf4xN.js +915 -0
  32. package/dist/session-DYThdzLZ.js +825 -0
  33. package/dist/studio/index.d.ts +5 -0
  34. package/dist/studio/indexeddb-persistence.d.ts +2 -0
  35. package/dist/studio/indexeddb-session-persistence.d.ts +11 -0
  36. package/dist/studio/scene-package-asset-sources.d.ts +14 -0
  37. package/dist/studio.js +1423 -1220
  38. package/dist/urdf-session-CRXL4bHf.js +1230 -0
  39. package/dist/usd-session-CTzInpNy.js +7385 -0
  40. package/dist/version.d.ts +1 -1
  41. package/dist/view/scene-session.d.ts +5 -1
  42. package/dist/wasm-module-DZn2AM1W.js +13 -0
  43. package/dist/xacro-IpPHTMYs.js +76 -0
  44. package/package.json +1 -1
  45. package/dist/asset-source-BExlEcRt.js +0 -444
  46. package/dist/assets/usd-export-worker-BsGubtAE.js +0 -1
  47. package/dist/editorial-BkAFWfbg.js +0 -83
  48. package/dist/export-evidence-B_0zRmb8.js +0 -5027
  49. package/dist/remote-asset-resolver-Cb8cfNmw.js +0 -136
  50. package/dist/scene-session-BV1HnxNh.js +0 -3506
package/dist/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * Sim Studio 版本号。必须与 package.json 的 version 保持一致,
3
3
  * check-boundary 脚本会在构建前校验两者是否漂移。
4
4
  */
5
- export declare const simStudioVersion = "0.1.0";
5
+ export declare const simStudioVersion = "0.1.2";
@@ -146,7 +146,9 @@ export interface StudioSceneSession {
146
146
  setEditorial(editorial: Readonly<Record<string, StudioEditorialState>>): void;
147
147
  /** Measures a hidden asset preview, seats its real footprint at the point,
148
148
  * then removes the preview. Returns data for one subsequent Add Command. */
149
- preparePlacement(assetId: string, point: Vec3, snap?: number | 'adaptive'): Promise<LocalTransform>;
149
+ preparePlacement(assetId: string, point: Vec3, snap?: number | 'adaptive', options?: {
150
+ readonly avoidOverlap?: boolean;
151
+ }): Promise<LocalTransform>;
150
152
  beginPlacementPreview(assetId: string, transform: LocalTransform): Promise<boolean>;
151
153
  updatePlacementPreview(transform: LocalTransform): Promise<boolean>;
152
154
  confirmPlacementPreview(): Promise<LocalTransform | null>;
@@ -157,6 +159,8 @@ export interface StudioSceneSession {
157
159
  */
158
160
  measureAssets(assetIds: readonly string[]): Promise<Record<string, Vec3>>;
159
161
  measureAssetBounds(assetId: string): Promise<Vec3Bounds>;
162
+ /** Last runtime-measured source-local bounds for an asset revision. */
163
+ getMeasuredAssetBounds?(assetId: string): Vec3Bounds | null;
160
164
  /** The transform gizmo is centered on the editable selection. */
161
165
  select(ids: readonly string[], primary?: string | null): void;
162
166
  selectRegion(regionId: string | null): void;
@@ -0,0 +1,13 @@
1
+ function s(e, i, n) {
2
+ return WebAssembly.instantiate(e, i).then(
3
+ (t) => n(t, e),
4
+ (t) => {
5
+ setTimeout(() => {
6
+ throw t;
7
+ });
8
+ }
9
+ ), {};
10
+ }
11
+ export {
12
+ s as i
13
+ };
@@ -0,0 +1,76 @@
1
+ import { XacroParser as y } from "xacro-parser";
2
+ import { n as g } from "./session-DYThdzLZ.js";
3
+ const A = "http://wiki.ros.org/xacro", o = (n) => Object.assign(new Error(n), { code: "E_XACRO_EXPAND" });
4
+ async function X(n, m, u, c, s) {
5
+ var w, b;
6
+ s.throwIfAborted();
7
+ const i = new Map(Object.entries((c == null ? void 0 : c.packages) ?? {})), l = /* @__PURE__ */ new Map();
8
+ for (const t of u.paths().filter((e) => /(^|\/)package\.xml$/.test(e))) {
9
+ const r = (b = (w = new DOMParser().parseFromString(await u.text(t), "text/xml").querySelector("package > name")) == null ? void 0 : w.textContent) == null ? void 0 : b.trim();
10
+ r && l.set(r, [...l.get(r) ?? [], t.slice(0, -11)]);
11
+ }
12
+ for (const [t, e] of l)
13
+ if (!i.has(t)) {
14
+ if (e.length !== 1) throw o(`Ambiguous ROS package: ${t}. Set xacro.packages explicitly.`);
15
+ i.set(t, e[0]);
16
+ }
17
+ const p = (t) => {
18
+ if (!i.has(t)) throw o(`Unknown ROS package: ${t}. Upload package.xml or set xacro.packages.`);
19
+ return "/" + g(i.get(t));
20
+ }, h = (t, e) => {
21
+ if (t.length > 4 * 1024 * 1024) throw o(`Xacro input exceeds 4 MiB: ${e}`);
22
+ const r = new DOMParser().parseFromString(t, "text/xml");
23
+ if (r.querySelector("parsererror") || r.doctype) throw o(`Invalid XML or unsupported DOCTYPE: ${e}`);
24
+ for (const a of Array.from(r.getElementsByTagName("*"))) {
25
+ if (a.namespaceURI === A && a.prefix !== "xacro") throw o(`Use the xacro: namespace prefix: ${e}`);
26
+ if (a.tagName === "xacro:call" || a.tagName === "xacro:include" && a.hasAttribute("ns") || a.tagName === "xacro:macro" && /:=\^/.test(a.getAttribute("params") ?? ""))
27
+ throw o(`Unsupported Xacro feature ${a.tagName}: ${e}`);
28
+ }
29
+ };
30
+ h(n, m);
31
+ const f = new y(), d = /* @__PURE__ */ Object.create(null), $ = new DOMParser().parseFromString(n, "text/xml");
32
+ for (const t of Array.from($.documentElement.children))
33
+ if (t.tagName === "xacro:arg" && t.hasAttribute("name") && t.hasAttribute("default")) {
34
+ const e = t.getAttribute("name");
35
+ e in d || (d[e] = t.getAttribute("default"));
36
+ }
37
+ f.arguments = Object.assign(/* @__PURE__ */ Object.create(null), d, c == null ? void 0 : c.arguments), f.workingPath = "/" + m.replaceAll("\\", "/").split("/").slice(0, -1).join("/");
38
+ let k = 0, x;
39
+ f.getFileContents = async (t) => {
40
+ try {
41
+ if (s.throwIfAborted(), ++k > 128) throw o("Xacro include limit exceeded (128); check for include cycles.");
42
+ const e = g(t);
43
+ if (e === ".." || e.startsWith("../") || /^[a-z]+:/i.test(e)) throw o(`Unsupported include path: ${t}`);
44
+ const r = await u.text(e);
45
+ return s.throwIfAborted(), h(r, e), r;
46
+ } catch (e) {
47
+ throw x = e, e;
48
+ }
49
+ }, f.rospackCommands = (t, ...e) => {
50
+ if (t !== "arg") {
51
+ if (t === "find" && e.length === 1) return p(e[0]);
52
+ throw o(`Unsupported Xacro substitution: $(${t} ${e.join(" ")})`);
53
+ }
54
+ };
55
+ try {
56
+ const t = await f.parse(n);
57
+ if (s.throwIfAborted(), t.documentElement.tagName !== "robot") throw o("Expanded Xacro must have a robot root.");
58
+ for (const e of Array.from(t.getElementsByTagName("*"))) {
59
+ if (e.prefix === "xacro" || e.namespaceURI === A) throw o(`Unexpanded Xacro element: ${e.tagName}`);
60
+ for (const r of Array.from(e.attributes))
61
+ if (/\$\{|\$\(/.test(r.value)) throw o(`Unexpanded Xacro expression: ${r.value}`);
62
+ if (e.tagName === "mesh" || e.tagName === "texture") {
63
+ const r = e.getAttribute("filename") ?? "", a = /^package:\/\/([^/]+)\/(.+)$/.exec(r);
64
+ a && i.has(a[1]) && e.setAttribute("filename", g(`${p(a[1])}/${a[2]}`));
65
+ }
66
+ }
67
+ return t.documentElement.outerHTML;
68
+ } catch (t) {
69
+ s.throwIfAborted();
70
+ const e = x ?? t;
71
+ throw Object.assign(o(`Xacro expansion failed (${m}): ${e instanceof Error ? e.message : String(e)}`), { cause: e });
72
+ }
73
+ }
74
+ export {
75
+ X as expandXacro
76
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula-spatial/studio",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Simulation scene authoring studio with USD package export",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -1,444 +0,0 @@
1
- import { k as p, s as b, g as _ } from "./builders-BAXRR5o5.js";
2
- const I = "application/octet-stream", C = {
3
- ".usda": "model/vnd.usda",
4
- ".usd": "model/vnd.usda",
5
- ".usdc": "model/vnd.usdc",
6
- ".usdz": "model/vnd.usdz+zip",
7
- ".glb": "model/gltf-binary",
8
- ".gltf": "model/gltf+json",
9
- ".ply": "application/x-ply",
10
- ".spz": "application/x-spz",
11
- ".splat": "application/x-gaussian-splat",
12
- ".ksplat": "application/x-ksplat",
13
- ".rad": "application/x-rad",
14
- ".zip": "application/zip",
15
- ".json": "application/json",
16
- ".png": "image/png",
17
- ".jpg": "image/jpeg",
18
- ".jpeg": "image/jpeg",
19
- ".webp": "image/webp",
20
- ".ktx2": "image/ktx2",
21
- ".exr": "image/x-exr",
22
- ".mdl": "text/plain"
23
- }, O = /* @__PURE__ */ new Set([
24
- I,
25
- "binary/octet-stream"
26
- ]);
27
- function $(t) {
28
- return C[M(t)] ?? null;
29
- }
30
- function H(t) {
31
- return $(t) ?? I;
32
- }
33
- function z(t, ...e) {
34
- for (const o of e) {
35
- const n = F(o);
36
- if (n) return n;
37
- }
38
- return $(t);
39
- }
40
- function M(t) {
41
- const e = t.replaceAll("\\", "/"), o = e.slice(e.lastIndexOf("/") + 1).toLowerCase(), n = o.lastIndexOf(".");
42
- return n >= 0 ? o.slice(n) : "";
43
- }
44
- function F(t) {
45
- const e = t == null ? void 0 : t.trim();
46
- return !e || O.has(e.toLowerCase()) ? null : e;
47
- }
48
- const w = "ASSET_SOURCE_INVALID_LOCATOR";
49
- function m(t) {
50
- if (!t || t.startsWith("/") || t.includes("\\"))
51
- throw new p(
52
- w,
53
- `Package resource path must be a non-empty forward-slash relative path: ${t}.`
54
- );
55
- const e = [];
56
- for (const n of t.split("/"))
57
- if (!(!n || n === ".")) {
58
- if (n === "..") {
59
- if (e.length === 0)
60
- throw new p(
61
- w,
62
- `Package resource path escapes its logical root: ${t}.`
63
- );
64
- e.pop();
65
- continue;
66
- }
67
- e.push(n);
68
- }
69
- const o = e.join("/");
70
- if (!o)
71
- throw new p(
72
- w,
73
- `Package resource path normalizes to an empty value: ${t}.`
74
- );
75
- return o;
76
- }
77
- function S(t) {
78
- const e = new URL(t);
79
- if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password || e.hash)
80
- throw new p(
81
- w,
82
- `Remote resource URL must be an absolute HTTP(S) URL without credentials or fragment: ${t}.`
83
- );
84
- return `${e.origin}${e.pathname}`;
85
- }
86
- function k(t) {
87
- return t.kind === "package-path" ? { kind: "package-path", path: m(t.path) } : { kind: "remote-url", url: S(t.url) };
88
- }
89
- function l(t) {
90
- const e = k(t);
91
- return e.kind === "package-path" ? `package:${e.path}` : `remote:${e.url}`;
92
- }
93
- function j(t, e) {
94
- return `res_${b(`${l(t)}\0${e}`).slice(0, 32)}`;
95
- }
96
- function Y(t) {
97
- return t.kind === "package-path" ? m(t.path) : null;
98
- }
99
- function G(t) {
100
- return t.kind === "remote-url" ? S(t.url) : null;
101
- }
102
- function K(t) {
103
- const e = k(t);
104
- if (e.kind === "package-path") return e.path;
105
- const o = new URL(e.url), n = o.pathname.split("/").filter(Boolean), s = n.length === 0 ? "r-root" : [
106
- `p-${encodeURIComponent(n[0])}`,
107
- ...n.slice(1)
108
- ].join("/");
109
- return m(
110
- `remote-assets/${encodeURIComponent(o.origin)}/${s}`
111
- );
112
- }
113
- function X(t, e, o = []) {
114
- const n = e.trim();
115
- if (!n) return null;
116
- const s = k(t), u = new Set(o.map(l));
117
- if (s.kind === "remote-url")
118
- try {
119
- const c = new URL(n, s.url);
120
- return {
121
- kind: "remote-url",
122
- url: S(c.href)
123
- };
124
- } catch {
125
- return null;
126
- }
127
- if (/^[a-z][a-z\d+.-]*:/i.test(n)) return null;
128
- if (n.startsWith("/"))
129
- try {
130
- return { kind: "package-path", path: m(n.slice(1)) };
131
- } catch {
132
- return null;
133
- }
134
- const r = s.path.split("/");
135
- r.pop();
136
- let a = null;
137
- for (let c = r.length; c >= 0; c -= 1) {
138
- const i = r.slice(0, c).join("/");
139
- try {
140
- const d = {
141
- kind: "package-path",
142
- path: m(i ? `${i}/${n}` : n)
143
- };
144
- if (a ?? (a = d), u.size === 0 || u.has(l(d)))
145
- return d;
146
- } catch {
147
- }
148
- }
149
- return a;
150
- }
151
- const f = {
152
- unavailable: "ASSET_SOURCE_UNAVAILABLE",
153
- conflict: "SOURCE_REVISION_CONFLICT",
154
- unverifiable: "SOURCE_FACTS_UNVERIFIABLE",
155
- factsMismatch: "ASSET_SOURCE_FACTS_MISMATCH",
156
- invalidLocator: "ASSET_SOURCE_INVALID_LOCATOR"
157
- };
158
- function U(t) {
159
- const e = new URL(t.entryUrl);
160
- if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password || e.hash)
161
- throw new p(
162
- f.invalidLocator,
163
- `Remote asset entry URL must be an absolute HTTP(S) URL without credentials or fragment: ${t.entryUrl}.`
164
- );
165
- const o = t.allowedScopes ? t.allowedScopes.map(R) : void 0, n = {
166
- kind: "remote-entry",
167
- revisionId: t.revisionId,
168
- entryUrl: e.href,
169
- ...t.request ? { request: t.request } : {},
170
- ...o ? { allowedScopes: o } : {}
171
- };
172
- if (!A(n, e))
173
- throw new p(
174
- f.invalidLocator,
175
- `Remote asset entry URL is outside its allowed scopes: ${e.href}.`
176
- );
177
- return n;
178
- }
179
- function v(t) {
180
- if (!t.allowedScopes) return [];
181
- const e = /* @__PURE__ */ new Map();
182
- for (const o of t.allowedScopes) {
183
- const n = R(o);
184
- e.set(`${n.origin}\0${n.pathPrefix}`, n);
185
- }
186
- return [...e.values()].sort((o, n) => o.origin.localeCompare(n.origin) || o.pathPrefix.localeCompare(n.pathPrefix));
187
- }
188
- function A(t, e) {
189
- return t.allowedScopes ? v(t).some((o) => N(e, o)) : e.protocol === "http:" || e.protocol === "https:";
190
- }
191
- function D(t, e) {
192
- const o = E(t), n = T(e), s = o.endsWith("/") ? o : `${o}/`;
193
- return n === "/" || s === n || o.startsWith(n);
194
- }
195
- function N(t, e) {
196
- const o = R(e);
197
- return t.origin === o.origin && D(t.pathname, o.pathPrefix);
198
- }
199
- function P(t) {
200
- return S(t.entryUrl);
201
- }
202
- function R(t) {
203
- const e = new URL(t.origin);
204
- if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password || e.pathname !== "/" || e.search || e.hash)
205
- throw new p(
206
- f.invalidLocator,
207
- `Asset scope origin must be a canonical HTTP(S) origin: ${t.origin}.`
208
- );
209
- return {
210
- origin: e.origin,
211
- pathPrefix: T(t.pathPrefix)
212
- };
213
- }
214
- function T(t) {
215
- if (!t.startsWith("/"))
216
- throw new p(
217
- f.invalidLocator,
218
- `Asset scope pathPrefix must be absolute: ${t}.`
219
- );
220
- const e = E(t);
221
- return e.endsWith("/") ? e : `${e}/`;
222
- }
223
- function E(t) {
224
- const e = new URL(t, "https://scope.invalid");
225
- let o;
226
- try {
227
- o = decodeURIComponent(e.pathname);
228
- } catch {
229
- throw new p(
230
- f.invalidLocator,
231
- `Asset resource path contains invalid URL escaping: ${t}.`
232
- );
233
- }
234
- const n = [];
235
- for (const s of o.split("/"))
236
- !s || s === "." || (s === ".." ? n.pop() : n.push(s));
237
- return `/${n.join("/")}${o.endsWith("/") && n.length ? "/" : ""}`;
238
- }
239
- function q(t) {
240
- return "visualRevisionId" in t ? t.visualRevisionId : t.revisionId;
241
- }
242
- function J(t) {
243
- return t.kind === "local-package" ? {
244
- kind: "local-package",
245
- revisionId: t.revisionId,
246
- entryPath: t.entryPath,
247
- files: t.files.map((e) => ({ locator: e.locator, blob: e.blob }))
248
- } : {
249
- kind: "remote-entry",
250
- revisionId: t.revisionId,
251
- entryUrl: t.entryUrl,
252
- ...t.request ? { request: t.request } : {},
253
- ...t.allowedScopes ? { allowedScopes: t.allowedScopes.map((e) => ({ ...e })) } : {}
254
- };
255
- }
256
- async function W(t, e = {}) {
257
- var r, a, c;
258
- if ((r = e.signal) == null || r.throwIfAborted(), t.kind === "remote-entry") {
259
- const i = U(t);
260
- return {
261
- source: i,
262
- facts: [],
263
- fingerprint: L(i)
264
- };
265
- }
266
- const o = [];
267
- for (const i of t.files) {
268
- (a = e.signal) == null || a.throwIfAborted();
269
- const d = k(i.locator);
270
- if (d.kind !== "package-path")
271
- throw new p(
272
- f.invalidLocator,
273
- `Local asset sources cannot contain remote resources: ${d.url}.`
274
- );
275
- const g = m(d.path), y = new Uint8Array(await i.blob.arrayBuffer());
276
- (c = e.signal) == null || c.throwIfAborted(), o.push({
277
- locator: { kind: "package-path", path: g },
278
- blob: i.blob,
279
- resourceId: j(
280
- { kind: "package-path", path: g },
281
- b(y)
282
- ),
283
- sha256: b(y),
284
- byteSize: y.byteLength,
285
- mediaType: z(g, i.blob.type) ?? I
286
- });
287
- }
288
- o.sort((i, d) => i.resourceId.localeCompare(d.resourceId));
289
- const n = m(t.entryPath);
290
- if (!o.some((i) => i.locator.kind === "package-path" && i.locator.path === n))
291
- throw new p(
292
- f.unverifiable,
293
- `Local asset source is missing its entry: ${t.entryPath}.`
294
- );
295
- const s = {
296
- kind: "local-package",
297
- revisionId: t.revisionId,
298
- entryPath: n,
299
- files: o.map((i) => ({ locator: i.locator, blob: i.blob }))
300
- }, u = o.map(({ resourceId: i, locator: d, sha256: g, byteSize: y, mediaType: x }) => ({
301
- resourceId: i,
302
- locator: d,
303
- sha256: g,
304
- byteSize: y,
305
- mediaType: x
306
- }));
307
- return {
308
- source: s,
309
- facts: u,
310
- fingerprint: L(s, u)
311
- };
312
- }
313
- function B(t, e) {
314
- const o = q(e);
315
- if (t.revisionId !== o)
316
- throw h(
317
- `Asset source revision ${t.revisionId} does not match requested revision ${o}.`
318
- );
319
- const n = e.resources.find((r) => r.resourceId === e.entryResourceId);
320
- if (!n)
321
- throw h(
322
- `Asset source entry does not match revision facts for ${o}.`
323
- );
324
- if (t.kind === "remote-entry") {
325
- if (U(t), n.locator.kind !== "remote-url" || n.locator.url !== P(t))
326
- throw h(
327
- `Remote asset source entry does not match revision facts for ${o}.`
328
- );
329
- for (const r of e.resources) {
330
- if (r.locator.kind !== "remote-url")
331
- throw h(
332
- `Remote asset source does not authorize revision resource ${l(r.locator)}.`
333
- );
334
- const a = new URL(r.locator.url);
335
- if (!A(t, a))
336
- throw h(
337
- `Remote asset source does not authorize revision resource ${l(r.locator)}.`
338
- );
339
- }
340
- return;
341
- }
342
- if (n.locator.kind !== "package-path" || n.locator.path !== t.entryPath)
343
- throw h(
344
- `Local asset source entry does not match revision facts for ${o}.`
345
- );
346
- const s = new Map(e.resources.map((r) => [
347
- l(r.locator),
348
- r
349
- ])), u = new Map(t.files.map((r) => [
350
- l(r.locator),
351
- r
352
- ]));
353
- if (s.size !== u.size)
354
- throw h(`Local asset source path set does not match ${o}.`);
355
- for (const [r, a] of u) {
356
- const c = s.get(r);
357
- if (!c || a.blob.size !== c.byteSize)
358
- throw h(`Local asset source facts do not match ${o}/${r}.`);
359
- }
360
- }
361
- async function Q(t, e, o = {}) {
362
- var r;
363
- if (B(t, e), t.kind === "remote-entry") return;
364
- const n = await W(t, o), s = new Map(e.resources.map((a) => [
365
- l(a.locator),
366
- a
367
- ])), u = new Map(t.files.map((a) => [
368
- l(a.locator),
369
- a.blob
370
- ]));
371
- for (const a of n.facts) {
372
- const c = s.get(l(a.locator));
373
- if (!c || c.sha256 !== a.sha256 || c.byteSize !== a.byteSize)
374
- throw h(`Local asset source bytes do not match ${t.revisionId}/${l(a.locator)}.`);
375
- const i = z(
376
- a.locator.kind === "package-path" ? a.locator.path : a.locator.url,
377
- (r = u.get(l(a.locator))) == null ? void 0 : r.type
378
- );
379
- if (i && i !== c.mediaType)
380
- throw h(
381
- `Local asset source mediaType does not match ${t.revisionId}/${l(a.locator)}.`
382
- );
383
- }
384
- }
385
- function L(t, e = []) {
386
- return _(
387
- t.kind === "local-package" ? {
388
- kind: t.kind,
389
- revisionId: t.revisionId,
390
- entryPath: t.entryPath,
391
- facts: e.map((o) => ({
392
- locator: o.locator,
393
- sha256: o.sha256,
394
- byteSize: o.byteSize,
395
- mediaType: o.mediaType
396
- })).sort((o, n) => l(o.locator).localeCompare(
397
- l(n.locator)
398
- ))
399
- } : {
400
- kind: t.kind,
401
- revisionId: t.revisionId,
402
- entryUrl: P(t),
403
- scopePolicy: t.allowedScopes === void 0 ? "unrestricted-http" : "explicit",
404
- scopes: v(t).map((o) => `${o.origin}${o.pathPrefix}`)
405
- }
406
- );
407
- }
408
- function Z(t) {
409
- return {
410
- assetId: t.revisionId,
411
- entryLocator: { kind: "package-path", path: t.entryPath },
412
- files: t.files.map((e) => ({ locator: e.locator, blob: e.blob }))
413
- };
414
- }
415
- function h(t) {
416
- return new p(f.factsMismatch, t);
417
- }
418
- export {
419
- I as D,
420
- f as S,
421
- l as a,
422
- X as b,
423
- S as c,
424
- B as d,
425
- P as e,
426
- J as f,
427
- m as g,
428
- U as h,
429
- v as i,
430
- D as j,
431
- W as k,
432
- G as l,
433
- H as m,
434
- k as n,
435
- q as o,
436
- Y as p,
437
- L as q,
438
- z as r,
439
- Z as s,
440
- K as t,
441
- j as u,
442
- Q as v,
443
- A as w
444
- };
@@ -1 +0,0 @@
1
- (function(){"use strict";function c(t){if(t instanceof Error){const e=t;return{name:e.name,message:e.message,...typeof e.code=="string"?{code:e.code}:{},...typeof e.stage=="string"?{stage:e.stage}:{},...e.detail&&typeof e.detail=="object"?{detail:e.detail}:{}}}return{name:"Error",message:String(t)}}const l=globalThis;let u=null,d="",i=null;function s(t,e=[]){l.postMessage(t,e)}function a(t,e,r){if(!u)throw new Error("OpenUSD exporter runtime is not initialized.");const n=u.ccall(t,"string",r,e);if(typeof n!="string")throw new Error(`${t} did not return JSON.`);const o=JSON.parse(n);if(o.ok===!1)throw Object.assign(new Error(String(o.message??`${t} failed.`)),{code:typeof o.code=="string"?o.code:`${t.toUpperCase()}_FAILED`,stage:typeof o.stage=="string"?o.stage:"worker",detail:o});return o}async function p(t){u=await(await import(t.moduleUrl)).default({locateFile:n=>n.endsWith(".wasm")?t.wasmUrl:n});const r=u._usd_exporter_api_version();if(r!==t.apiVersion)throw Object.assign(new Error(`OpenUSD exporter API ${r} does not match expected ${t.apiVersion}.`),{code:"EXPORT_RUNTIME_API_MISMATCH",stage:"worker-load"});d=t.runtimeId,s({type:"ready",apiVersion:r,runtimeId:d})}function f(t,e){const r=a("usd_export_begin",[JSON.stringify(t),JSON.stringify(e)],["string","string"]),n=Number(r.handle);if(!Number.isInteger(n)||n<=0)throw Object.assign(new Error("Exporter returned an invalid session handle."),{code:"EXPORT_HANDLE_INVALID",stage:"stage-build"});return i=n,{handle:n,planDigest:String(r.planDigest??"")}}function b(t,e){if(!u||i===null)throw new Error("Exporter session is not initialized.");const r=new Uint8Array(e),n=u._malloc(Math.max(1,r.byteLength));if(!n)throw new Error(`Unable to allocate ${r.byteLength} bytes for ${t}.`);try{u.HEAPU8.set(r,n),a("usd_export_write_resource",[i,t,n,r.byteLength],["number","string","number","number"])}finally{u._free(n)}}function _(t){if(!u||i===null)throw new Error("Exporter session is not initialized.");const e=a("usd_export_output_info",[i,t],["number","string"]),r=Number(u.ccall("usd_export_output_size","number",["number","string"],[i,t]));if(!Number.isInteger(r)||r<0||r!==e.byteSize)throw Object.assign(new Error(`Invalid exporter output size for ${t}.`),{code:"EXPORT_OUTPUT_SIZE_INVALID",stage:"final-validate"});const n=Number(u.ccall("usd_export_output_data","number",["number","string"],[i,t]));if(r>0&&!n)throw new Error(`Exporter output pointer is null for ${t}.`);const o=u.HEAPU8.slice(n,n+r);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}async function y(t){switch(t.type){case"init":await p(t.runtime);return;case"begin":s({type:"result",id:t.id,value:f(t.plan,t.options)});return;case"write-resource":b(t.path,t.bytes),s({type:"result",id:t.id,value:{path:t.path}});return;case"build-stage":s({type:"result",id:t.id,value:a("usd_export_build_stage",[i],["number"])});return;case"write-output":s({type:"result",id:t.id,value:a("usd_export_write_layer",[i,t.encoding,t.path],["number","string","string"])});return;case"package-usdz":s({type:"result",id:t.id,value:a("usd_export_package_usdz",[i,t.entryPath,t.outputPath],["number","string","string"])});return;case"validate":s({type:"result",id:t.id,value:a("usd_export_validate",[i,JSON.stringify(t.expectation)],["number","string"])});return;case"read-output":{const e=_(t.path);s({type:"output",id:t.id,path:t.path,bytes:e},[e]);return}case"release":i!==null?(s({type:"result",id:t.id,value:a("usd_export_release",[i],["number"])}),i=null):s({type:"result",id:t.id,value:{ok:!0}})}}l.onmessage=t=>{const e=t.data;y(e).catch(r=>{s({type:"error",..."id"in e?{id:e.id}:{},error:c(r)})})}})();
@@ -1,83 +0,0 @@
1
- import { w as l } from "./scene-graph-DBLKAhxa.js";
2
- const f = Object.freeze({ hidden: !1, locked: !1 });
3
- function E(e) {
4
- const t = u(e.document).flatMap((a) => {
5
- const d = e.editorial[a] ?? f;
6
- return d.hidden || d.locked ? [{ nodeId: a, hidden: d.hidden, locked: d.locked }] : [];
7
- }), n = [...new Set(e.selection.instanceIds)], i = e.selection.primaryId, r = {
8
- format: "sim-studio.editorial-state@1",
9
- schemaVersion: 1,
10
- selection: { nodeIds: n, primaryNodeId: i },
11
- nodeStates: t,
12
- camera: e.camera ? s(e.camera) : null
13
- };
14
- return h(r, e.document), r;
15
- }
16
- function h(e, o) {
17
- if (e.format !== "sim-studio.editorial-state@1" || e.schemaVersion !== 1)
18
- throw new Error("Unsupported editorial state format.");
19
- const t = new Set(l(o.root).map((r) => r.nodeId)), n = /* @__PURE__ */ new Set();
20
- for (const r of e.nodeStates) {
21
- if (c(r.nodeId, t), n.has(r.nodeId))
22
- throw new Error(`Editorial state repeats node ${r.nodeId}.`);
23
- n.add(r.nodeId);
24
- }
25
- const i = /* @__PURE__ */ new Set();
26
- for (const r of e.selection.nodeIds) {
27
- if (c(r, t), i.has(r))
28
- throw new Error(`Editorial selection repeats node ${r}.`);
29
- i.add(r);
30
- }
31
- if (e.selection.primaryNodeId !== null && !i.has(e.selection.primaryNodeId))
32
- throw new Error(`Editorial primary selection is not in the selection: ${e.selection.primaryNodeId}`);
33
- e.camera && s(e.camera);
34
- }
35
- function I(e) {
36
- return Object.freeze(Object.fromEntries(
37
- e.nodeStates.map((o) => [
38
- o.nodeId,
39
- Object.freeze({ hidden: o.hidden, locked: o.locked })
40
- ])
41
- ));
42
- }
43
- function p(e) {
44
- return s(e);
45
- }
46
- function s(e) {
47
- if (e.schemaVersion !== 1 || e.viewMode !== "2d" && e.viewMode !== "3d")
48
- throw new Error("Editorial camera schema or view mode is invalid.");
49
- if (e.viewMode === "2d" && !e.orthographic)
50
- throw new Error("A 2D editorial camera requires orthographic facts.");
51
- if (e.viewMode === "3d" && !e.orbit)
52
- throw new Error("A 3D editorial camera requires orbit facts.");
53
- for (const o of w(e))
54
- if (!Number.isFinite(o)) throw new Error("Editorial camera contains a non-finite value.");
55
- return {
56
- schemaVersion: 1,
57
- viewMode: e.viewMode,
58
- ...e.orbit ? { orbit: { ...e.orbit } } : {},
59
- ...e.orthographic ? { orthographic: { ...e.orthographic } } : {}
60
- };
61
- }
62
- function w(e) {
63
- return [
64
- ...e.orbit ? Object.values(e.orbit) : [],
65
- ...e.orthographic ? Object.values(e.orthographic) : []
66
- ];
67
- }
68
- function u(e) {
69
- return l(e.root).filter((o) => o.nodeId !== e.root.nodeId).map((o) => o.nodeId).sort((o, t) => o.localeCompare(t));
70
- }
71
- function c(e, o) {
72
- if (!o.has(e)) throw new Error(`Editorial state references unknown node ${e}.`);
73
- }
74
- function b(e, o) {
75
- return e.nodeStates.find((t) => t.nodeId === o) ?? { nodeId: o, hidden: !1, locked: !1 };
76
- }
77
- export {
78
- h as a,
79
- I as b,
80
- E as c,
81
- b as e,
82
- p as n
83
- };