@mica-js/document 0.4.0 → 0.6.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.
- package/dist/fused/index.d.ts +21 -4
- package/dist/fused/index.js +24 -683
- package/dist/fused/index.js.map +1 -1
- package/dist/instance-data-CX-ElHak.js +704 -0
- package/dist/instance-data-CX-ElHak.js.map +1 -0
- package/dist/scene-3d/index.d.ts +203 -0
- package/dist/scene-3d/index.js +473 -0
- package/dist/scene-3d/index.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { t as isUuidV4 } from "../uuid-DegOw3iI.js";
|
|
2
|
+
import { C as isColor, L as report, R as toPointer, a as forbidUnknownFields, b as deviceIdProblem, c as isRecord, f as readIntegerField, h as readStringField, i as deepFreeze, l as parseJsonInput, m as readObjectField, n as readProperties, s as hasOwn, t as readDependencies, u as readArrayField } from "../instance-data-CX-ElHak.js";
|
|
3
|
+
//#region src/scene-3d/types.ts
|
|
4
|
+
var SCENE_3D_VERSION = 2;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/scene-3d/naming.ts
|
|
7
|
+
var SCENE_NAME_MAX_LENGTH = 64;
|
|
8
|
+
/** Describes why an instance name is unusable, or returns undefined when it is valid. */
|
|
9
|
+
function sceneNameProblem(name) {
|
|
10
|
+
if (name.length === 0) return "must not be empty";
|
|
11
|
+
if (name.length > 64) return `must be at most 64 characters`;
|
|
12
|
+
for (const character of name) {
|
|
13
|
+
const code = character.codePointAt(0) ?? 0;
|
|
14
|
+
if (code < 32 || code === 127) return "must not contain control characters";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Appends a numeric suffix until the name is free within `taken`. */
|
|
18
|
+
function uniqueSceneName(taken, base) {
|
|
19
|
+
const trimmed = base.trim();
|
|
20
|
+
if (!taken.has(trimmed)) return trimmed;
|
|
21
|
+
for (let index = 2;; index++) {
|
|
22
|
+
const suffix = ` ${index}`;
|
|
23
|
+
const candidate = `${trimmed.slice(0, 64 - suffix.length)}${suffix}`;
|
|
24
|
+
if (!taken.has(candidate)) return candidate;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/scene-3d/validation.ts
|
|
29
|
+
function sceneDiagnostic(code, path, message) {
|
|
30
|
+
return {
|
|
31
|
+
severity: "error",
|
|
32
|
+
code,
|
|
33
|
+
pointer: toPointer(path),
|
|
34
|
+
message
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function validateScene3D(document, bodies) {
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
const report = (code, path, message) => {
|
|
40
|
+
diagnostics.push(sceneDiagnostic(code, path, message));
|
|
41
|
+
};
|
|
42
|
+
const ids = /* @__PURE__ */ new Set();
|
|
43
|
+
const instanceIds = new Set(document.instances.map(({ id }) => id));
|
|
44
|
+
const names = /* @__PURE__ */ new Map();
|
|
45
|
+
const mounted = /* @__PURE__ */ new Set();
|
|
46
|
+
const parents = /* @__PURE__ */ new Map();
|
|
47
|
+
document.mounts.forEach(({ child, parent }, index) => {
|
|
48
|
+
const path = ["mounts", String(index)];
|
|
49
|
+
if (mounted.has(child)) report("mount/multiple-parents", [...path, "child"], `Instance "${child}" already has a mount.`);
|
|
50
|
+
mounted.add(child);
|
|
51
|
+
const childExists = instanceIds.has(child);
|
|
52
|
+
const parentExists = instanceIds.has(parent.instance);
|
|
53
|
+
if (!childExists) report("mount/unknown-instance", [...path, "child"], `Unknown mount child "${child}".`);
|
|
54
|
+
if (!parentExists) report("mount/unknown-instance", [
|
|
55
|
+
...path,
|
|
56
|
+
"parent",
|
|
57
|
+
"instance"
|
|
58
|
+
], `Unknown mount parent "${parent.instance}" for "${child}".`);
|
|
59
|
+
if (childExists && parentExists) {
|
|
60
|
+
const edge = {
|
|
61
|
+
parent: parent.instance,
|
|
62
|
+
index
|
|
63
|
+
};
|
|
64
|
+
const edges = parents.get(child);
|
|
65
|
+
if (edges === void 0) parents.set(child, [edge]);
|
|
66
|
+
else edges.push(edge);
|
|
67
|
+
}
|
|
68
|
+
if (bodies !== void 0 && parentExists && parent.body !== void 0) {
|
|
69
|
+
const registered = bodies.get(parent.instance);
|
|
70
|
+
const bodyPath = [
|
|
71
|
+
...path,
|
|
72
|
+
"parent",
|
|
73
|
+
"body"
|
|
74
|
+
];
|
|
75
|
+
if (registered === void 0) report("mount/bodies-unregistered", bodyPath, `Bodies have not been registered for parent "${parent.instance}" of "${child}".`);
|
|
76
|
+
else if (!registered.has(parent.body)) report("mount/unknown-body", bodyPath, `Parent "${parent.instance}" of "${child}" has no body "${parent.body}".`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
function checkId(id, path) {
|
|
80
|
+
if (ids.has(id)) report("document/duplicate-id", path, `Duplicate scene ID "${id}".`);
|
|
81
|
+
ids.add(id);
|
|
82
|
+
}
|
|
83
|
+
document.instances.forEach(({ id, device, pose, name }, index) => {
|
|
84
|
+
const path = ["instances", String(index)];
|
|
85
|
+
checkId(id, [...path, "id"]);
|
|
86
|
+
if (name !== void 0) {
|
|
87
|
+
const problem = sceneNameProblem(name);
|
|
88
|
+
if (problem !== void 0) report("instance/invalid-name", [...path, "name"], `Instance "${id}" name ${problem}.`);
|
|
89
|
+
else {
|
|
90
|
+
const owner = names.get(name);
|
|
91
|
+
if (owner !== void 0) report("instance/duplicate-name", [...path, "name"], `Instance "${id}" reuses name "${name}" from "${owner}".`);
|
|
92
|
+
else names.set(name, id);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!hasOwn(document.dependencies, device)) report("document/unlocked-device", [...path, "device"], `Instance "${id}" refers to unlocked device "${device}".`);
|
|
96
|
+
if (mounted.has(id) === (pose !== void 0)) report("mount/invalid-root-pose", [...path, "pose"], `Instance "${id}" must have either a root pose or a mount.`);
|
|
97
|
+
});
|
|
98
|
+
document.connections.forEach(({ id, from, to }, index) => {
|
|
99
|
+
const path = ["connections", String(index)];
|
|
100
|
+
checkId(id, [...path, "id"]);
|
|
101
|
+
for (const [key, endpoint] of [["from", from], ["to", to]]) if (!instanceIds.has(endpoint.instance)) report("connection/unknown-endpoint", [
|
|
102
|
+
...path,
|
|
103
|
+
key,
|
|
104
|
+
"instance"
|
|
105
|
+
], `Connection "${id}" refers to unknown instance "${endpoint.instance}".`);
|
|
106
|
+
if (from.instance === to.instance && from.contact === to.contact) report("connection/self-edge", [...path, "to"], `Connection "${id}" joins a contact to itself.`);
|
|
107
|
+
});
|
|
108
|
+
const active = /* @__PURE__ */ new Set();
|
|
109
|
+
const complete = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const id of parents.keys()) {
|
|
111
|
+
if (complete.has(id)) continue;
|
|
112
|
+
const stack = [{
|
|
113
|
+
id,
|
|
114
|
+
next: 0
|
|
115
|
+
}];
|
|
116
|
+
active.add(id);
|
|
117
|
+
for (let frame = stack.at(-1); frame !== void 0; frame = stack.at(-1)) {
|
|
118
|
+
const edge = parents.get(frame.id)?.[frame.next];
|
|
119
|
+
frame.next += 1;
|
|
120
|
+
if (edge === void 0) {
|
|
121
|
+
active.delete(frame.id);
|
|
122
|
+
complete.add(frame.id);
|
|
123
|
+
stack.pop();
|
|
124
|
+
} else if (active.has(edge.parent)) report("mount/cycle", [
|
|
125
|
+
"mounts",
|
|
126
|
+
String(edge.index),
|
|
127
|
+
"parent",
|
|
128
|
+
"instance"
|
|
129
|
+
], `Mount from "${frame.id}" to "${edge.parent}" closes a cycle.`);
|
|
130
|
+
else if (!complete.has(edge.parent)) {
|
|
131
|
+
active.add(edge.parent);
|
|
132
|
+
stack.push({
|
|
133
|
+
id: edge.parent,
|
|
134
|
+
next: 0
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return diagnostics;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/scene-3d/open.ts
|
|
143
|
+
/** Opens the versioned format. Structurally valid records survive unresolved references. */
|
|
144
|
+
function openScene3D(input, bodies) {
|
|
145
|
+
const diagnostics = [];
|
|
146
|
+
const parsed = parseJsonInput(input, diagnostics);
|
|
147
|
+
if (!parsed.ok) return {
|
|
148
|
+
ok: false,
|
|
149
|
+
diagnostics
|
|
150
|
+
};
|
|
151
|
+
const value = parsed.value;
|
|
152
|
+
if (!isRecord(value)) {
|
|
153
|
+
report(diagnostics, "json/not-object", "3D scene must be a JSON object.", []);
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
diagnostics
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (value["version"] === 1 && hasOwn(value, "entities")) return {
|
|
160
|
+
ok: false,
|
|
161
|
+
diagnostics: [sceneDiagnostic("scene/legacy-format", ["version"], "Legacy 3D scenes and assemblies cannot be opened as module scenes.")]
|
|
162
|
+
};
|
|
163
|
+
const version = readIntegerField(value, "version", [], diagnostics);
|
|
164
|
+
if (version !== 2) {
|
|
165
|
+
if (version !== void 0) report(diagnostics, "schema/unsupported-version", `Unsupported 3D scene version ${version}; expected 2.`, ["version"]);
|
|
166
|
+
return {
|
|
167
|
+
ok: false,
|
|
168
|
+
diagnostics
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
forbidUnknownFields(value, [
|
|
172
|
+
"version",
|
|
173
|
+
"dependencies",
|
|
174
|
+
"instances",
|
|
175
|
+
"mounts",
|
|
176
|
+
"connections"
|
|
177
|
+
], [], diagnostics);
|
|
178
|
+
const dependencies = readDependencies(readObjectField(value, "dependencies", [], diagnostics), ["dependencies"], diagnostics);
|
|
179
|
+
const instances = readCollection(value, "instances", diagnostics, readInstance);
|
|
180
|
+
const mounts = readCollection(value, "mounts", diagnostics, readMount);
|
|
181
|
+
const connections = readCollection(value, "connections", diagnostics, readConnection);
|
|
182
|
+
if (dependencies === void 0 || diagnostics.length > 0) return {
|
|
183
|
+
ok: false,
|
|
184
|
+
diagnostics
|
|
185
|
+
};
|
|
186
|
+
const document = deepFreeze({
|
|
187
|
+
version,
|
|
188
|
+
dependencies,
|
|
189
|
+
instances,
|
|
190
|
+
mounts,
|
|
191
|
+
connections
|
|
192
|
+
});
|
|
193
|
+
return {
|
|
194
|
+
ok: true,
|
|
195
|
+
document,
|
|
196
|
+
diagnostics: validateScene3D(document, bodies)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** Runtime gate after device scripts have registered their bodies. */
|
|
200
|
+
function prepareScene3DRun(input, bodies) {
|
|
201
|
+
const opened = openScene3D(input, bodies);
|
|
202
|
+
return opened.diagnostics.length === 0 ? opened : {
|
|
203
|
+
ok: false,
|
|
204
|
+
diagnostics: opened.diagnostics
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function readCollection(root, key, diagnostics, read) {
|
|
208
|
+
const values = readArrayField(root, key, [], diagnostics) ?? [];
|
|
209
|
+
const items = [];
|
|
210
|
+
for (const [index, value] of values.entries()) {
|
|
211
|
+
const path = [key, String(index)];
|
|
212
|
+
if (!isRecord(value)) {
|
|
213
|
+
report(diagnostics, "schema/invalid-type", "Expected an object.", path);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const item = read(value, path, diagnostics);
|
|
217
|
+
if (item !== void 0) items.push(item);
|
|
218
|
+
}
|
|
219
|
+
return items;
|
|
220
|
+
}
|
|
221
|
+
function readInstance(value, path, diagnostics) {
|
|
222
|
+
forbidUnknownFields(value, [
|
|
223
|
+
"id",
|
|
224
|
+
"device",
|
|
225
|
+
"name",
|
|
226
|
+
"properties",
|
|
227
|
+
"pose"
|
|
228
|
+
], path, diagnostics);
|
|
229
|
+
const id = readStringField(value, "id", path, diagnostics, true, { nonEmpty: true });
|
|
230
|
+
const device = readStringField(value, "device", path, diagnostics, true, { nonEmpty: true });
|
|
231
|
+
const name = readStringField(value, "name", path, diagnostics, false);
|
|
232
|
+
const problem = device === void 0 ? void 0 : deviceIdProblem(device);
|
|
233
|
+
if (problem !== void 0) report(diagnostics, "schema/invalid-value", `Field "device" ${problem}.`, [...path, "device"]);
|
|
234
|
+
const pose = hasOwn(value, "pose") ? readPoseField(value, "pose", path, diagnostics) : void 0;
|
|
235
|
+
const properties = hasOwn(value, "properties") ? readProperties(value["properties"], [...path, "properties"], diagnostics) : void 0;
|
|
236
|
+
if (id === void 0 || device === void 0) return void 0;
|
|
237
|
+
return {
|
|
238
|
+
id,
|
|
239
|
+
device,
|
|
240
|
+
...name === void 0 ? {} : { name: name.trim() },
|
|
241
|
+
...properties === void 0 ? {} : { properties },
|
|
242
|
+
...pose === void 0 ? {} : { pose }
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function readMount(value, path, diagnostics) {
|
|
246
|
+
forbidUnknownFields(value, [
|
|
247
|
+
"child",
|
|
248
|
+
"parent",
|
|
249
|
+
"localPose"
|
|
250
|
+
], path, diagnostics);
|
|
251
|
+
const child = readStringField(value, "child", path, diagnostics, true, { nonEmpty: true });
|
|
252
|
+
const target = readObjectField(value, "parent", path, diagnostics);
|
|
253
|
+
const localPose = readPoseField(value, "localPose", path, diagnostics);
|
|
254
|
+
if (target === void 0) return void 0;
|
|
255
|
+
const targetPath = [...path, "parent"];
|
|
256
|
+
forbidUnknownFields(target, ["instance", "body"], targetPath, diagnostics);
|
|
257
|
+
const instance = readStringField(target, "instance", targetPath, diagnostics, true, { nonEmpty: true });
|
|
258
|
+
const body = readStringField(target, "body", targetPath, diagnostics, false, { nonEmpty: true });
|
|
259
|
+
if (child === void 0 || instance === void 0 || localPose === void 0) return void 0;
|
|
260
|
+
return {
|
|
261
|
+
child,
|
|
262
|
+
parent: {
|
|
263
|
+
instance,
|
|
264
|
+
...body === void 0 ? {} : { body }
|
|
265
|
+
},
|
|
266
|
+
localPose
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function readConnection(value, path, diagnostics) {
|
|
270
|
+
forbidUnknownFields(value, [
|
|
271
|
+
"id",
|
|
272
|
+
"from",
|
|
273
|
+
"to",
|
|
274
|
+
"color"
|
|
275
|
+
], path, diagnostics);
|
|
276
|
+
const id = readStringField(value, "id", path, diagnostics, true, { nonEmpty: true });
|
|
277
|
+
if (id !== void 0 && !isUuidV4(id)) report(diagnostics, "schema/invalid-value", "Connection ID must be a UUID v4.", [...path, "id"]);
|
|
278
|
+
const from = readContactField(value, "from", path, diagnostics);
|
|
279
|
+
const to = readContactField(value, "to", path, diagnostics);
|
|
280
|
+
const color = readStringField(value, "color", path, diagnostics, false);
|
|
281
|
+
if (color !== void 0 && (color.length !== 7 || !isColor(color))) report(diagnostics, "schema/invalid-value", "Expected a wire color in #RRGGBB format.", [...path, "color"]);
|
|
282
|
+
if (id === void 0 || from === void 0 || to === void 0) return void 0;
|
|
283
|
+
return {
|
|
284
|
+
id,
|
|
285
|
+
from,
|
|
286
|
+
to,
|
|
287
|
+
...color === void 0 ? {} : { color }
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function readContactField(value, key, path, diagnostics) {
|
|
291
|
+
const endpoint = readObjectField(value, key, path, diagnostics);
|
|
292
|
+
if (endpoint === void 0) return void 0;
|
|
293
|
+
const endpointPath = [...path, key];
|
|
294
|
+
forbidUnknownFields(endpoint, ["instance", "contact"], endpointPath, diagnostics);
|
|
295
|
+
const instance = readStringField(endpoint, "instance", endpointPath, diagnostics, true, { nonEmpty: true });
|
|
296
|
+
const contact = readStringField(endpoint, "contact", endpointPath, diagnostics, true, { nonEmpty: true });
|
|
297
|
+
return instance === void 0 || contact === void 0 ? void 0 : {
|
|
298
|
+
instance,
|
|
299
|
+
contact
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function readPoseField(value, key, path, diagnostics) {
|
|
303
|
+
const pose = readObjectField(value, key, path, diagnostics);
|
|
304
|
+
if (pose === void 0) return void 0;
|
|
305
|
+
const posePath = [...path, key];
|
|
306
|
+
forbidUnknownFields(pose, ["positionMm", "orientation"], posePath, diagnostics);
|
|
307
|
+
const position = readArrayField(pose, "positionMm", posePath, diagnostics);
|
|
308
|
+
const rotation = readArrayField(pose, "orientation", posePath, diagnostics);
|
|
309
|
+
const [px, py, pz] = position ?? [];
|
|
310
|
+
const [x, y, z, w] = rotation ?? [];
|
|
311
|
+
const positionValid = position?.length === 3 && finite(px) && finite(py) && finite(pz);
|
|
312
|
+
const orientationValid = rotation?.length === 4 && finite(x) && finite(y) && finite(z) && finite(w) && Math.abs(Math.hypot(x, y, z, w) - 1) <= 1e-6;
|
|
313
|
+
if (position !== void 0 && !positionValid) report(diagnostics, "schema/invalid-value", "Expected three finite millimetre coordinates.", [...posePath, "positionMm"]);
|
|
314
|
+
if (rotation !== void 0 && !orientationValid) report(diagnostics, "schema/invalid-value", "Expected a unit quaternion [x,y,z,w].", [...posePath, "orientation"]);
|
|
315
|
+
return positionValid && orientationValid ? {
|
|
316
|
+
positionMm: [
|
|
317
|
+
px,
|
|
318
|
+
py,
|
|
319
|
+
pz
|
|
320
|
+
],
|
|
321
|
+
orientation: [
|
|
322
|
+
x,
|
|
323
|
+
y,
|
|
324
|
+
z,
|
|
325
|
+
w
|
|
326
|
+
]
|
|
327
|
+
} : void 0;
|
|
328
|
+
}
|
|
329
|
+
function finite(value) {
|
|
330
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/scene-3d/commands.ts
|
|
334
|
+
function openScene3DSession(input) {
|
|
335
|
+
const opened = openScene3D(input);
|
|
336
|
+
if (!opened.ok) return opened;
|
|
337
|
+
let current = opened;
|
|
338
|
+
const undo = [];
|
|
339
|
+
const redo = [];
|
|
340
|
+
return {
|
|
341
|
+
ok: true,
|
|
342
|
+
session: {
|
|
343
|
+
get document() {
|
|
344
|
+
return current.document;
|
|
345
|
+
},
|
|
346
|
+
get canUndo() {
|
|
347
|
+
return undo.length > 0;
|
|
348
|
+
},
|
|
349
|
+
get canRedo() {
|
|
350
|
+
return redo.length > 0;
|
|
351
|
+
},
|
|
352
|
+
get undoDocument() {
|
|
353
|
+
return undo.at(-1)?.document;
|
|
354
|
+
},
|
|
355
|
+
get redoDocument() {
|
|
356
|
+
return redo.at(-1)?.document;
|
|
357
|
+
},
|
|
358
|
+
execute(command) {
|
|
359
|
+
switch (command.type) {
|
|
360
|
+
case "save": return {
|
|
361
|
+
...current,
|
|
362
|
+
text: JSON.stringify(current.document, null, 2) + "\n"
|
|
363
|
+
};
|
|
364
|
+
case "undo": {
|
|
365
|
+
const previous = undo.pop();
|
|
366
|
+
if (previous !== void 0) {
|
|
367
|
+
redo.push(current);
|
|
368
|
+
current = previous;
|
|
369
|
+
}
|
|
370
|
+
return current;
|
|
371
|
+
}
|
|
372
|
+
case "redo": {
|
|
373
|
+
const next = redo.pop();
|
|
374
|
+
if (next !== void 0) {
|
|
375
|
+
undo.push(current);
|
|
376
|
+
current = next;
|
|
377
|
+
}
|
|
378
|
+
return current;
|
|
379
|
+
}
|
|
380
|
+
case "replace":
|
|
381
|
+
case "insertTemplate": {
|
|
382
|
+
const candidate = command.type === "replace" ? openScene3D(command.document) : insertTemplate(current.document, command.template);
|
|
383
|
+
if (!candidate.ok || candidate.diagnostics.length > 0) return {
|
|
384
|
+
ok: false,
|
|
385
|
+
diagnostics: candidate.diagnostics
|
|
386
|
+
};
|
|
387
|
+
undo.push(current);
|
|
388
|
+
redo.length = 0;
|
|
389
|
+
current = candidate;
|
|
390
|
+
return current;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
diagnostics: current.diagnostics
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function insertTemplate(document, input) {
|
|
399
|
+
const opened = openScene3D(input);
|
|
400
|
+
if (!opened.ok || opened.diagnostics.length > 0) return opened;
|
|
401
|
+
const template = opened.document;
|
|
402
|
+
for (const [device, lock] of Object.entries(template.dependencies)) {
|
|
403
|
+
const existing = document.dependencies[device];
|
|
404
|
+
if (existing !== void 0 && (existing.version !== lock.version || existing.integrity !== lock.integrity)) return {
|
|
405
|
+
ok: false,
|
|
406
|
+
diagnostics: [sceneDiagnostic("scene/dependency-conflict", ["dependencies", device], `Template lock for "${device}" conflicts with the scene lock.`)]
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const used = new Set([
|
|
410
|
+
...document.instances,
|
|
411
|
+
...document.connections,
|
|
412
|
+
...template.instances,
|
|
413
|
+
...template.connections
|
|
414
|
+
].map(({ id }) => id));
|
|
415
|
+
const freshId = () => {
|
|
416
|
+
let id = globalThis.crypto.randomUUID();
|
|
417
|
+
while (used.has(id)) id = globalThis.crypto.randomUUID();
|
|
418
|
+
used.add(id);
|
|
419
|
+
return id;
|
|
420
|
+
};
|
|
421
|
+
const instanceIds = new Map(template.instances.map(({ id }) => [id, freshId()]));
|
|
422
|
+
const takenNames = new Set(document.instances.flatMap(({ name }) => name === void 0 ? [] : [name]));
|
|
423
|
+
const remap = (id) => {
|
|
424
|
+
const mapped = instanceIds.get(id);
|
|
425
|
+
if (mapped === void 0) throw new Error(`Validated template is missing instance "${id}".`);
|
|
426
|
+
return mapped;
|
|
427
|
+
};
|
|
428
|
+
return openScene3D({
|
|
429
|
+
...document,
|
|
430
|
+
dependencies: {
|
|
431
|
+
...document.dependencies,
|
|
432
|
+
...template.dependencies
|
|
433
|
+
},
|
|
434
|
+
instances: [...document.instances, ...template.instances.map((instance) => {
|
|
435
|
+
const id = remap(instance.id);
|
|
436
|
+
if (instance.name === void 0) return {
|
|
437
|
+
...instance,
|
|
438
|
+
id
|
|
439
|
+
};
|
|
440
|
+
const name = uniqueSceneName(takenNames, instance.name);
|
|
441
|
+
takenNames.add(name);
|
|
442
|
+
return {
|
|
443
|
+
...instance,
|
|
444
|
+
id,
|
|
445
|
+
name
|
|
446
|
+
};
|
|
447
|
+
})],
|
|
448
|
+
mounts: [...document.mounts, ...template.mounts.map((mount) => ({
|
|
449
|
+
...mount,
|
|
450
|
+
child: remap(mount.child),
|
|
451
|
+
parent: {
|
|
452
|
+
...mount.parent,
|
|
453
|
+
instance: remap(mount.parent.instance)
|
|
454
|
+
}
|
|
455
|
+
}))],
|
|
456
|
+
connections: [...document.connections, ...template.connections.map(({ from, to, ...connection }) => ({
|
|
457
|
+
...connection,
|
|
458
|
+
id: freshId(),
|
|
459
|
+
from: {
|
|
460
|
+
...from,
|
|
461
|
+
instance: remap(from.instance)
|
|
462
|
+
},
|
|
463
|
+
to: {
|
|
464
|
+
...to,
|
|
465
|
+
instance: remap(to.instance)
|
|
466
|
+
}
|
|
467
|
+
}))]
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
//#endregion
|
|
471
|
+
export { SCENE_3D_VERSION, SCENE_NAME_MAX_LENGTH, openScene3D, openScene3DSession, prepareScene3DRun, sceneNameProblem, uniqueSceneName };
|
|
472
|
+
|
|
473
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/scene-3d/types.ts","../../src/scene-3d/naming.ts","../../src/scene-3d/validation.ts","../../src/scene-3d/open.ts","../../src/scene-3d/commands.ts"],"sourcesContent":["import type { FusedDiagnostic } from '../fused/diagnostics';\nimport type { DeviceDependency } from '../fused/types/document';\nimport type { PropertyValue } from '../fused/types/property';\n\nexport const SCENE_3D_VERSION = 2;\n\nexport interface Scene3DPose {\n readonly positionMm: readonly [x: number, y: number, z: number];\n readonly orientation: readonly [x: number, y: number, z: number, w: number];\n}\n\nexport interface Scene3DInstance {\n readonly id: string;\n readonly device: string;\n /** User-facing display name. Distinct instances may omit it and fall back to the manifest name. */\n readonly name?: string;\n readonly properties?: Readonly<Record<string, PropertyValue>>;\n readonly pose?: Scene3DPose;\n}\n\nexport interface Scene3DMount {\n readonly child: string;\n readonly parent: { readonly instance: string; readonly body?: string };\n readonly localPose: Scene3DPose;\n}\n\nexport interface Scene3DContactEndpoint {\n readonly instance: string;\n readonly contact: string;\n}\n\nexport interface Scene3DConnection {\n readonly id: string;\n readonly from: Scene3DContactEndpoint;\n readonly to: Scene3DContactEndpoint;\n readonly color?: string;\n}\n\nexport interface Scene3DDocument {\n readonly version: typeof SCENE_3D_VERSION;\n readonly dependencies: Readonly<Record<string, DeviceDependency>>;\n readonly instances: readonly Scene3DInstance[];\n readonly mounts: readonly Scene3DMount[];\n readonly connections: readonly Scene3DConnection[];\n}\n\nexport interface Scene3DDiagnostic extends Pick<\n FusedDiagnostic,\n 'severity' | 'pointer' | 'message'\n> {\n readonly code:\n | FusedDiagnostic['code']\n | 'scene/legacy-format'\n | 'scene/dependency-conflict'\n | 'mount/unknown-instance'\n | 'mount/multiple-parents'\n | 'mount/cycle'\n | 'mount/invalid-root-pose'\n | 'mount/bodies-unregistered'\n | 'mount/unknown-body'\n | 'instance/invalid-name'\n | 'instance/duplicate-name';\n}\n\nexport type Scene3DOpenResult =\n | {\n readonly ok: true;\n readonly document: Scene3DDocument;\n readonly diagnostics: readonly Scene3DDiagnostic[];\n }\n | { readonly ok: false; readonly diagnostics: readonly Scene3DDiagnostic[] };\n\n/** Instantiated packages register their public body IDs under the corresponding scene instance ID. */\nexport type Scene3DBodyRegistry = ReadonlyMap<string, ReadonlySet<string>>;\n","export const SCENE_NAME_MAX_LENGTH = 64;\n\n/** Describes why an instance name is unusable, or returns undefined when it is valid. */\nexport function sceneNameProblem(name: string): string | undefined {\n if (name.length === 0) return 'must not be empty';\n if (name.length > SCENE_NAME_MAX_LENGTH)\n return `must be at most ${SCENE_NAME_MAX_LENGTH} characters`;\n for (const character of name) {\n const code = character.codePointAt(0) ?? 0;\n if (code < 0x20 || code === 0x7f) return 'must not contain control characters';\n }\n return undefined;\n}\n\n/** Appends a numeric suffix until the name is free within `taken`. */\nexport function uniqueSceneName(taken: ReadonlySet<string>, base: string): string {\n const trimmed = base.trim();\n if (!taken.has(trimmed)) return trimmed;\n for (let index = 2; ; index++) {\n const suffix = ` ${index}`;\n const candidate = `${trimmed.slice(0, SCENE_NAME_MAX_LENGTH - suffix.length)}${suffix}`;\n if (!taken.has(candidate)) return candidate;\n }\n}\n","import { hasOwn, toPointer } from '../fused/read';\nimport { sceneNameProblem } from './naming';\nimport type { Scene3DBodyRegistry, Scene3DDiagnostic, Scene3DDocument } from './types';\n\nexport function sceneDiagnostic(\n code: Scene3DDiagnostic['code'],\n path: readonly string[],\n message: string,\n): Scene3DDiagnostic {\n return { severity: 'error', code, pointer: toPointer(path), message };\n}\n\nexport function validateScene3D(\n document: Scene3DDocument,\n bodies?: Scene3DBodyRegistry,\n): readonly Scene3DDiagnostic[] {\n const diagnostics: Scene3DDiagnostic[] = [];\n const report = (code: Scene3DDiagnostic['code'], path: readonly string[], message: string) => {\n diagnostics.push(sceneDiagnostic(code, path, message));\n };\n const ids = new Set<string>();\n const instanceIds = new Set(document.instances.map(({ id }) => id));\n const names = new Map<string, string>();\n const mounted = new Set<string>();\n const parents = new Map<string, { parent: string; index: number }[]>();\n\n document.mounts.forEach(({ child, parent }, index) => {\n const path = ['mounts', String(index)];\n if (mounted.has(child)) {\n report(\n 'mount/multiple-parents',\n [...path, 'child'],\n `Instance \"${child}\" already has a mount.`,\n );\n }\n mounted.add(child);\n const childExists = instanceIds.has(child);\n const parentExists = instanceIds.has(parent.instance);\n if (!childExists) {\n report('mount/unknown-instance', [...path, 'child'], `Unknown mount child \"${child}\".`);\n }\n if (!parentExists) {\n report(\n 'mount/unknown-instance',\n [...path, 'parent', 'instance'],\n `Unknown mount parent \"${parent.instance}\" for \"${child}\".`,\n );\n }\n if (childExists && parentExists) {\n const edge = { parent: parent.instance, index };\n const edges = parents.get(child);\n if (edges === undefined) parents.set(child, [edge]);\n else edges.push(edge);\n }\n if (bodies !== undefined && parentExists && parent.body !== undefined) {\n const registered = bodies.get(parent.instance);\n const bodyPath = [...path, 'parent', 'body'];\n if (registered === undefined) {\n report(\n 'mount/bodies-unregistered',\n bodyPath,\n `Bodies have not been registered for parent \"${parent.instance}\" of \"${child}\".`,\n );\n } else if (!registered.has(parent.body)) {\n report(\n 'mount/unknown-body',\n bodyPath,\n `Parent \"${parent.instance}\" of \"${child}\" has no body \"${parent.body}\".`,\n );\n }\n }\n });\n\n function checkId(id: string, path: readonly string[]): void {\n if (ids.has(id)) report('document/duplicate-id', path, `Duplicate scene ID \"${id}\".`);\n ids.add(id);\n }\n\n document.instances.forEach(({ id, device, pose, name }, index) => {\n const path = ['instances', String(index)];\n checkId(id, [...path, 'id']);\n if (name !== undefined) {\n const problem = sceneNameProblem(name);\n if (problem !== undefined) {\n report('instance/invalid-name', [...path, 'name'], `Instance \"${id}\" name ${problem}.`);\n } else {\n const owner = names.get(name);\n if (owner !== undefined) {\n report(\n 'instance/duplicate-name',\n [...path, 'name'],\n `Instance \"${id}\" reuses name \"${name}\" from \"${owner}\".`,\n );\n } else {\n names.set(name, id);\n }\n }\n }\n if (!hasOwn(document.dependencies, device)) {\n report(\n 'document/unlocked-device',\n [...path, 'device'],\n `Instance \"${id}\" refers to unlocked device \"${device}\".`,\n );\n }\n if (mounted.has(id) === (pose !== undefined)) {\n report(\n 'mount/invalid-root-pose',\n [...path, 'pose'],\n `Instance \"${id}\" must have either a root pose or a mount.`,\n );\n }\n });\n\n document.connections.forEach(({ id, from, to }, index) => {\n const path = ['connections', String(index)];\n checkId(id, [...path, 'id']);\n for (const [key, endpoint] of [\n ['from', from],\n ['to', to],\n ] as const) {\n if (!instanceIds.has(endpoint.instance)) {\n report(\n 'connection/unknown-endpoint',\n [...path, key, 'instance'],\n `Connection \"${id}\" refers to unknown instance \"${endpoint.instance}\".`,\n );\n }\n }\n if (from.instance === to.instance && from.contact === to.contact) {\n report(\n 'connection/self-edge',\n [...path, 'to'],\n `Connection \"${id}\" joins a contact to itself.`,\n );\n }\n });\n\n // Traverse all edges, including additional parents in damaged documents, without recursing.\n const active = new Set<string>();\n const complete = new Set<string>();\n for (const id of parents.keys()) {\n if (complete.has(id)) continue;\n const stack = [{ id, next: 0 }];\n active.add(id);\n for (let frame = stack.at(-1); frame !== undefined; frame = stack.at(-1)) {\n const edge = parents.get(frame.id)?.[frame.next];\n frame.next += 1;\n if (edge === undefined) {\n active.delete(frame.id);\n complete.add(frame.id);\n stack.pop();\n } else if (active.has(edge.parent)) {\n report(\n 'mount/cycle',\n ['mounts', String(edge.index), 'parent', 'instance'],\n `Mount from \"${frame.id}\" to \"${edge.parent}\" closes a cycle.`,\n );\n } else if (!complete.has(edge.parent)) {\n active.add(edge.parent);\n stack.push({ id: edge.parent, next: 0 });\n }\n }\n }\n return diagnostics;\n}\n","import { isUuidV4 } from '../format/uuid';\nimport type { FusedDiagnostic } from '../fused/diagnostics';\nimport { readDependencies, readProperties } from '../fused/instance-data';\nimport {\n deepFreeze,\n forbidUnknownFields,\n hasOwn,\n isRecord,\n parseJsonInput,\n readArrayField,\n readIntegerField,\n readObjectField,\n readStringField,\n report,\n} from '../fused/read';\nimport { deviceIdProblem, isColor } from '../fused/rules';\nimport {\n SCENE_3D_VERSION,\n type Scene3DBodyRegistry,\n type Scene3DConnection,\n type Scene3DContactEndpoint,\n type Scene3DDocument,\n type Scene3DInstance,\n type Scene3DMount,\n type Scene3DOpenResult,\n type Scene3DPose,\n} from './types';\nimport { sceneDiagnostic, validateScene3D } from './validation';\n\ntype Path = readonly string[];\n\n/** Opens the versioned format. Structurally valid records survive unresolved references. */\nexport function openScene3D(input: unknown, bodies?: Scene3DBodyRegistry): Scene3DOpenResult {\n const diagnostics: FusedDiagnostic[] = [];\n const parsed = parseJsonInput(input, diagnostics);\n if (!parsed.ok) return { ok: false, diagnostics };\n const value = parsed.value;\n if (!isRecord(value)) {\n report(diagnostics, 'json/not-object', '3D scene must be a JSON object.', []);\n return { ok: false, diagnostics };\n }\n if (value['version'] === 1 && hasOwn(value, 'entities')) {\n return {\n ok: false,\n diagnostics: [\n sceneDiagnostic(\n 'scene/legacy-format',\n ['version'],\n 'Legacy 3D scenes and assemblies cannot be opened as module scenes.',\n ),\n ],\n };\n }\n const version = readIntegerField(value, 'version', [], diagnostics);\n if (version !== SCENE_3D_VERSION) {\n if (version !== undefined) {\n report(\n diagnostics,\n 'schema/unsupported-version',\n `Unsupported 3D scene version ${version}; expected ${SCENE_3D_VERSION}.`,\n ['version'],\n );\n }\n return { ok: false, diagnostics };\n }\n\n forbidUnknownFields(\n value,\n ['version', 'dependencies', 'instances', 'mounts', 'connections'],\n [],\n diagnostics,\n );\n const dependencies = readDependencies(\n readObjectField(value, 'dependencies', [], diagnostics),\n ['dependencies'],\n diagnostics,\n );\n const instances = readCollection(value, 'instances', diagnostics, readInstance);\n const mounts = readCollection(value, 'mounts', diagnostics, readMount);\n const connections = readCollection(value, 'connections', diagnostics, readConnection);\n if (dependencies === undefined || diagnostics.length > 0) return { ok: false, diagnostics };\n\n const document = deepFreeze<Scene3DDocument>({\n version,\n dependencies,\n instances,\n mounts,\n connections,\n });\n return { ok: true, document, diagnostics: validateScene3D(document, bodies) };\n}\n\n/** Runtime gate after device scripts have registered their bodies. */\nexport function prepareScene3DRun(input: unknown, bodies: Scene3DBodyRegistry): Scene3DOpenResult {\n const opened = openScene3D(input, bodies);\n return opened.diagnostics.length === 0 ? opened : { ok: false, diagnostics: opened.diagnostics };\n}\n\nfunction readCollection<T>(\n root: Record<string, unknown>,\n key: string,\n diagnostics: FusedDiagnostic[],\n read: (\n value: Record<string, unknown>,\n path: Path,\n diagnostics: FusedDiagnostic[],\n ) => T | undefined,\n): readonly T[] {\n const values = readArrayField(root, key, [], diagnostics) ?? [];\n const items: T[] = [];\n for (const [index, value] of values.entries()) {\n const path = [key, String(index)];\n if (!isRecord(value)) {\n report(diagnostics, 'schema/invalid-type', 'Expected an object.', path);\n continue;\n }\n const item = read(value, path, diagnostics);\n if (item !== undefined) items.push(item);\n }\n return items;\n}\n\nfunction readInstance(\n value: Record<string, unknown>,\n path: Path,\n diagnostics: FusedDiagnostic[],\n): Scene3DInstance | undefined {\n forbidUnknownFields(value, ['id', 'device', 'name', 'properties', 'pose'], path, diagnostics);\n const id = readStringField(value, 'id', path, diagnostics, true, { nonEmpty: true });\n const device = readStringField(value, 'device', path, diagnostics, true, { nonEmpty: true });\n const name = readStringField(value, 'name', path, diagnostics, false);\n const problem = device === undefined ? undefined : deviceIdProblem(device);\n if (problem !== undefined) {\n report(diagnostics, 'schema/invalid-value', `Field \"device\" ${problem}.`, [...path, 'device']);\n }\n const pose = hasOwn(value, 'pose') ? readPoseField(value, 'pose', path, diagnostics) : undefined;\n const properties = hasOwn(value, 'properties')\n ? readProperties(value['properties'], [...path, 'properties'], diagnostics)\n : undefined;\n if (id === undefined || device === undefined) return undefined;\n return {\n id,\n device,\n ...(name === undefined ? {} : { name: name.trim() }),\n ...(properties === undefined ? {} : { properties }),\n ...(pose === undefined ? {} : { pose }),\n };\n}\n\nfunction readMount(\n value: Record<string, unknown>,\n path: Path,\n diagnostics: FusedDiagnostic[],\n): Scene3DMount | undefined {\n forbidUnknownFields(value, ['child', 'parent', 'localPose'], path, diagnostics);\n const child = readStringField(value, 'child', path, diagnostics, true, { nonEmpty: true });\n const target = readObjectField(value, 'parent', path, diagnostics);\n const localPose = readPoseField(value, 'localPose', path, diagnostics);\n if (target === undefined) return undefined;\n const targetPath = [...path, 'parent'];\n forbidUnknownFields(target, ['instance', 'body'], targetPath, diagnostics);\n const instance = readStringField(target, 'instance', targetPath, diagnostics, true, {\n nonEmpty: true,\n });\n const body = readStringField(target, 'body', targetPath, diagnostics, false, { nonEmpty: true });\n if (child === undefined || instance === undefined || localPose === undefined) return undefined;\n return { child, parent: { instance, ...(body === undefined ? {} : { body }) }, localPose };\n}\n\nfunction readConnection(\n value: Record<string, unknown>,\n path: Path,\n diagnostics: FusedDiagnostic[],\n): Scene3DConnection | undefined {\n forbidUnknownFields(value, ['id', 'from', 'to', 'color'], path, diagnostics);\n const id = readStringField(value, 'id', path, diagnostics, true, { nonEmpty: true });\n if (id !== undefined && !isUuidV4(id)) {\n report(diagnostics, 'schema/invalid-value', 'Connection ID must be a UUID v4.', [\n ...path,\n 'id',\n ]);\n }\n const from = readContactField(value, 'from', path, diagnostics);\n const to = readContactField(value, 'to', path, diagnostics);\n const color = readStringField(value, 'color', path, diagnostics, false);\n if (color !== undefined && (color.length !== 7 || !isColor(color))) {\n report(diagnostics, 'schema/invalid-value', 'Expected a wire color in #RRGGBB format.', [\n ...path,\n 'color',\n ]);\n }\n if (id === undefined || from === undefined || to === undefined) return undefined;\n return { id, from, to, ...(color === undefined ? {} : { color }) };\n}\n\nfunction readContactField(\n value: Record<string, unknown>,\n key: string,\n path: Path,\n diagnostics: FusedDiagnostic[],\n): Scene3DContactEndpoint | undefined {\n const endpoint = readObjectField(value, key, path, diagnostics);\n if (endpoint === undefined) return undefined;\n const endpointPath = [...path, key];\n forbidUnknownFields(endpoint, ['instance', 'contact'], endpointPath, diagnostics);\n const instance = readStringField(endpoint, 'instance', endpointPath, diagnostics, true, {\n nonEmpty: true,\n });\n const contact = readStringField(endpoint, 'contact', endpointPath, diagnostics, true, {\n nonEmpty: true,\n });\n return instance === undefined || contact === undefined ? undefined : { instance, contact };\n}\n\nfunction readPoseField(\n value: Record<string, unknown>,\n key: string,\n path: Path,\n diagnostics: FusedDiagnostic[],\n): Scene3DPose | undefined {\n const pose = readObjectField(value, key, path, diagnostics);\n if (pose === undefined) return undefined;\n const posePath = [...path, key];\n forbidUnknownFields(pose, ['positionMm', 'orientation'], posePath, diagnostics);\n const position = readArrayField(pose, 'positionMm', posePath, diagnostics);\n const rotation = readArrayField(pose, 'orientation', posePath, diagnostics);\n const [px, py, pz] = position ?? [];\n const [x, y, z, w] = rotation ?? [];\n const positionValid = position?.length === 3 && finite(px) && finite(py) && finite(pz);\n const orientationValid =\n rotation?.length === 4 &&\n finite(x) &&\n finite(y) &&\n finite(z) &&\n finite(w) &&\n Math.abs(Math.hypot(x, y, z, w) - 1) <= 1e-6;\n if (position !== undefined && !positionValid) {\n report(diagnostics, 'schema/invalid-value', 'Expected three finite millimetre coordinates.', [\n ...posePath,\n 'positionMm',\n ]);\n }\n if (rotation !== undefined && !orientationValid) {\n report(diagnostics, 'schema/invalid-value', 'Expected a unit quaternion [x,y,z,w].', [\n ...posePath,\n 'orientation',\n ]);\n }\n return positionValid && orientationValid\n ? { positionMm: [px, py, pz], orientation: [x, y, z, w] }\n : undefined;\n}\n\nfunction finite(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n","import { openScene3D } from './open';\nimport { uniqueSceneName } from './naming';\nimport type { Scene3DDiagnostic, Scene3DDocument } from './types';\nimport { sceneDiagnostic } from './validation';\n\nexport type Scene3DCommand =\n | { readonly type: 'replace'; readonly document: Scene3DDocument }\n | { readonly type: 'insertTemplate'; readonly template: Scene3DDocument }\n | { readonly type: 'undo' }\n | { readonly type: 'redo' }\n | { readonly type: 'save' };\n\nexport type Scene3DCommandResult =\n | {\n readonly ok: true;\n readonly document: Scene3DDocument;\n readonly diagnostics: readonly Scene3DDiagnostic[];\n readonly text?: string;\n }\n | { readonly ok: false; readonly diagnostics: readonly Scene3DDiagnostic[] };\n\nexport interface Scene3DSession {\n readonly document: Scene3DDocument;\n readonly canUndo: boolean;\n readonly canRedo: boolean;\n readonly undoDocument: Scene3DDocument | undefined;\n readonly redoDocument: Scene3DDocument | undefined;\n execute(command: Scene3DCommand): Scene3DCommandResult;\n}\n\nexport type Scene3DSessionResult =\n | {\n readonly ok: true;\n readonly session: Scene3DSession;\n readonly diagnostics: readonly Scene3DDiagnostic[];\n }\n | { readonly ok: false; readonly diagnostics: readonly Scene3DDiagnostic[] };\n\nexport function openScene3DSession(input: unknown): Scene3DSessionResult {\n const opened = openScene3D(input);\n if (!opened.ok) return opened;\n let current = opened;\n const undo: (typeof current)[] = [];\n const redo: (typeof current)[] = [];\n const session: Scene3DSession = {\n get document() {\n return current.document;\n },\n get canUndo() {\n return undo.length > 0;\n },\n get canRedo() {\n return redo.length > 0;\n },\n get undoDocument() {\n return undo.at(-1)?.document;\n },\n get redoDocument() {\n return redo.at(-1)?.document;\n },\n execute(command) {\n switch (command.type) {\n case 'save':\n return { ...current, text: JSON.stringify(current.document, null, 2) + '\\n' };\n case 'undo': {\n const previous = undo.pop();\n if (previous !== undefined) {\n redo.push(current);\n current = previous;\n }\n return current;\n }\n case 'redo': {\n const next = redo.pop();\n if (next !== undefined) {\n undo.push(current);\n current = next;\n }\n return current;\n }\n case 'replace':\n case 'insertTemplate': {\n const candidate =\n command.type === 'replace'\n ? openScene3D(command.document)\n : insertTemplate(current.document, command.template);\n if (!candidate.ok || candidate.diagnostics.length > 0) {\n return { ok: false, diagnostics: candidate.diagnostics };\n }\n undo.push(current);\n redo.length = 0;\n current = candidate;\n return current;\n }\n }\n },\n };\n return { ok: true, session, diagnostics: current.diagnostics };\n}\n\nfunction insertTemplate(document: Scene3DDocument, input: Scene3DDocument) {\n const opened = openScene3D(input);\n if (!opened.ok || opened.diagnostics.length > 0) return opened;\n const template = opened.document;\n\n for (const [device, lock] of Object.entries(template.dependencies)) {\n const existing = document.dependencies[device];\n if (\n existing !== undefined &&\n (existing.version !== lock.version || existing.integrity !== lock.integrity)\n ) {\n return {\n ok: false as const,\n diagnostics: [\n sceneDiagnostic(\n 'scene/dependency-conflict',\n ['dependencies', device],\n `Template lock for \"${device}\" conflicts with the scene lock.`,\n ),\n ],\n };\n }\n }\n const used = new Set(\n [\n ...document.instances,\n ...document.connections,\n ...template.instances,\n ...template.connections,\n ].map(({ id }) => id),\n );\n const freshId = () => {\n let id = globalThis.crypto.randomUUID();\n while (used.has(id)) id = globalThis.crypto.randomUUID();\n used.add(id);\n return id;\n };\n const instanceIds = new Map(template.instances.map(({ id }) => [id, freshId()]));\n const takenNames = new Set(\n document.instances.flatMap(({ name }) => (name === undefined ? [] : [name])),\n );\n const remap = (id: string) => {\n const mapped = instanceIds.get(id);\n if (mapped === undefined) throw new Error(`Validated template is missing instance \"${id}\".`);\n return mapped;\n };\n return openScene3D({\n ...document,\n dependencies: { ...document.dependencies, ...template.dependencies },\n instances: [\n ...document.instances,\n ...template.instances.map((instance) => {\n const id = remap(instance.id);\n if (instance.name === undefined) return { ...instance, id };\n const name = uniqueSceneName(takenNames, instance.name);\n takenNames.add(name);\n return { ...instance, id, name };\n }),\n ],\n mounts: [\n ...document.mounts,\n ...template.mounts.map((mount) => ({\n ...mount,\n child: remap(mount.child),\n parent: { ...mount.parent, instance: remap(mount.parent.instance) },\n })),\n ],\n connections: [\n ...document.connections,\n ...template.connections.map(({ from, to, ...connection }) => ({\n ...connection,\n id: freshId(),\n from: { ...from, instance: remap(from.instance) },\n to: { ...to, instance: remap(to.instance) },\n })),\n ],\n } satisfies Scene3DDocument);\n}\n"],"mappings":";;;AAIA,IAAa,mBAAmB;;;ACJhC,IAAa,wBAAwB;;AAGrC,SAAgB,iBAAiB,MAAkC;CACjE,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,IAAI,KAAK,SAAA,IACP,OAAO;CACT,KAAK,MAAM,aAAa,MAAM;EAC5B,MAAM,OAAO,UAAU,YAAY,CAAC,KAAK;EACzC,IAAI,OAAO,MAAQ,SAAS,KAAM,OAAO;CAC3C;AAEF;;AAGA,SAAgB,gBAAgB,OAA4B,MAAsB;CAChF,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,MAAM,IAAI,OAAO,GAAG,OAAO;CAChC,KAAK,IAAI,QAAQ,IAAK,SAAS;EAC7B,MAAM,SAAS,IAAI;EACnB,MAAM,YAAY,GAAG,QAAQ,MAAM,GAAA,KAA2B,OAAO,MAAM,IAAI;EAC/E,IAAI,CAAC,MAAM,IAAI,SAAS,GAAG,OAAO;CACpC;AACF;;;ACnBA,SAAgB,gBACd,MACA,MACA,SACmB;CACnB,OAAO;EAAE,UAAU;EAAS;EAAM,SAAS,UAAU,IAAI;EAAG;CAAQ;AACtE;AAEA,SAAgB,gBACd,UACA,QAC8B;CAC9B,MAAM,cAAmC,CAAC;CAC1C,MAAM,UAAU,MAAiC,MAAyB,YAAoB;EAC5F,YAAY,KAAK,gBAAgB,MAAM,MAAM,OAAO,CAAC;CACvD;CACA,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,cAAc,IAAI,IAAI,SAAS,UAAU,KAAK,EAAE,SAAS,EA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BAAkB;GAC5D,GAAG;GACH,IAAI,QAAQ;GACZ,MAAM;IAAE,GAAG;IAAM,UAAU,MAAM,KAAK,QAAQ;GAAE;GAChD,IAAI;IAAE,GAAG;IAAI,UAAU,MAAM,GAAG,QAAQ;GAAE;EAC5C,EAAE,CACJ;CACF,CAA2B;AAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mica-js/document",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Mica document contracts: schematic and canvas formats, topic delivery and shared format models",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"./fused": {
|
|
27
27
|
"types": "./dist/fused/index.d.ts",
|
|
28
28
|
"import": "./dist/fused/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./scene-3d": {
|
|
31
|
+
"types": "./dist/scene-3d/index.d.ts",
|
|
32
|
+
"import": "./dist/scene-3d/index.js"
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
35
|
"files": [
|