@things-factory/figure-ui 10.1.37 → 10.1.38

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 (49) hide show
  1. package/client/graphql/v3-store.ts +8 -2
  2. package/client/modeller/figure-history-panel.ts +22 -2
  3. package/client/modeller/figure-v3-parts.ts +365 -0
  4. package/client/modeller/v3-editor.ts +11 -2
  5. package/client/modeller/v3-occupancy.ts +22 -0
  6. package/client/modeller/v3-product-session.ts +23 -4
  7. package/client/modeller/v3-renderer.ts +27 -18
  8. package/client/modeller/v3-thumbnail.ts +97 -0
  9. package/client/pages/figure-v3-modeller-page.ts +94 -12
  10. package/client/route.ts +8 -0
  11. package/dist-client/graphql/v3-store.js +8 -2
  12. package/dist-client/graphql/v3-store.js.map +1 -1
  13. package/dist-client/modeller/figure-history-panel.d.ts +15 -0
  14. package/dist-client/modeller/figure-history-panel.js +25 -2
  15. package/dist-client/modeller/figure-history-panel.js.map +1 -1
  16. package/dist-client/modeller/figure-v3-parts.d.ts +41 -0
  17. package/dist-client/modeller/figure-v3-parts.js +352 -0
  18. package/dist-client/modeller/figure-v3-parts.js.map +1 -0
  19. package/dist-client/modeller/v3-editor.js +11 -2
  20. package/dist-client/modeller/v3-editor.js.map +1 -1
  21. package/dist-client/modeller/v3-occupancy.d.ts +14 -0
  22. package/dist-client/modeller/v3-occupancy.js +22 -0
  23. package/dist-client/modeller/v3-occupancy.js.map +1 -0
  24. package/dist-client/modeller/v3-product-session.d.ts +44 -2
  25. package/dist-client/modeller/v3-product-session.js +13 -2
  26. package/dist-client/modeller/v3-product-session.js.map +1 -1
  27. package/dist-client/modeller/v3-renderer.d.ts +9 -0
  28. package/dist-client/modeller/v3-renderer.js +22 -30
  29. package/dist-client/modeller/v3-renderer.js.map +1 -1
  30. package/dist-client/modeller/v3-thumbnail.d.ts +3 -0
  31. package/dist-client/modeller/v3-thumbnail.js +74 -0
  32. package/dist-client/modeller/v3-thumbnail.js.map +1 -0
  33. package/dist-client/pages/figure-v3-modeller-page.d.ts +26 -1
  34. package/dist-client/pages/figure-v3-modeller-page.js +104 -12
  35. package/dist-client/pages/figure-v3-modeller-page.js.map +1 -1
  36. package/dist-client/route.d.ts +1 -1
  37. package/dist-client/route.js +7 -0
  38. package/dist-client/route.js.map +1 -1
  39. package/dist-client/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +5 -5
  41. package/test/resolve-ts-siblings.mjs +18 -0
  42. package/test/v3-product-write.test.ts +14 -2
  43. package/test/v3-release-panel.test.ts +73 -0
  44. package/things-factory.config.js +6 -1
  45. package/translations/en.json +73 -1
  46. package/translations/ja.json +73 -1
  47. package/translations/ko.json +73 -1
  48. package/translations/ms.json +73 -1
  49. package/translations/zh.json +73 -1
@@ -93,6 +93,10 @@ export function createV3ProductSession(store) {
93
93
  edit(edit) {
94
94
  return workspace.editPart({ ...writable(), edit });
95
95
  },
96
+ /** One authoring command — what a person means, not a graph edit — as one step of the same history. */
97
+ command(action) {
98
+ return workspace.command({ ...writable(), action });
99
+ },
96
100
  undo() {
97
101
  return workspace.undo(writable());
98
102
  },
@@ -103,12 +107,19 @@ export function createV3ProductSession(store) {
103
107
  const { context } = writable();
104
108
  return workspace.export({ context }).text;
105
109
  },
106
- async save() {
110
+ /**
111
+ * Saves the model, and the card's picture when the caller managed to take one.
112
+ *
113
+ * The picture is the caller's because taking it needs a canvas, and this session is the place that knows
114
+ * nothing about drawing. A save with no picture is a save: a tab in the background cannot draw, and the
115
+ * source matters more than the card (see `v3-thumbnail.ts`).
116
+ */
117
+ async save({ thumbnail } = {}) {
107
118
  const control = writable(), requestEpoch = epoch;
108
119
  const exported = workspace.export(control);
109
120
  saving = true;
110
121
  try {
111
- const record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId });
122
+ const record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail });
112
123
  if (requestEpoch !== epoch)
113
124
  return read();
114
125
  if (!record.id || (id !== undefined && record.id !== id))
@@ -1 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,CAAC;oBAAS,CAAC;gBACT,IAAI,YAAY,KAAK,KAAK;oBAAE,MAAM,GAAG,KAAK,CAAA;YAC5C,CAAC;YACD,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n createV3Asset,\n createV3EditorWorkspace,\n serializeV3Asset,\n parseV3Asset,\n type V3InputChange,\n type V3PrimitiveCreation,\n type V3PartEdit\n} from '@hatiolab/figure-model'\n\nexport interface V3ProductRecord {\n id: string\n source: string\n}\n\n/** Persistence is injected; neither the model engine nor the renderer owns the product ID. */\nexport interface V3ProductStore {\n load(id: string): Promise<V3ProductRecord>\n save(request: { id?: string; source: string; expectedSource?: string; creationId?: string }): Promise<V3ProductRecord>\n}\n\n/** Product lifecycle boundary. A late response can never change another editor's asset or ID. */\nexport function createV3ProductSession(store: V3ProductStore) {\n const workspace = createV3EditorWorkspace()\n let epoch = 0,\n id: string | undefined,\n baseline: string | undefined\n let loading = false,\n saving = false,\n error: string | undefined\n let creationId: string | undefined\n function read() {\n return { ...workspace.read(), id, loading, saving, error }\n }\n function writable() {\n const view = workspace.read()\n if (loading || error || !view.context || view.revision === null) throw Error('먼저 모델을 정상적으로 열어 주세요.')\n // Serializing writes also makes create retries safe: no second create while the first is pending.\n if (saving) throw Error('저장이 끝난 뒤 편집해 주세요.')\n return { context: view.context, expectedRevision: view.revision, origin: 'ui' as const }\n }\n function clear() {\n workspace.close({ discardDesignChanges: true })\n id = undefined\n baseline = undefined\n error = undefined\n saving = false\n creationId = undefined\n }\n function canLeave(discard: boolean) {\n if (saving) throw Error('저장이 끝난 뒤 모델을 전환해 주세요.')\n if (workspace.read().dirty && !discard) throw Error('저장하지 않은 변경이 있습니다.')\n }\n return {\n read,\n startNew({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n workspace.open(serializeV3Asset(createV3Asset('새 Figure')))\n creationId = crypto.randomUUID()\n return read()\n },\n async open(nextId: string, { discard = false } = {}) {\n canLeave(discard)\n const requestEpoch = ++epoch\n clear()\n loading = true\n try {\n const record = await store.load(nextId)\n if (requestEpoch !== epoch) return read()\n if (record.id !== nextId) throw Error('요청한 Figure와 응답의 대상이 다릅니다.')\n workspace.open(record.source)\n id = nextId\n baseline = record.source\n } catch (cause) {\n if (requestEpoch === epoch) error = cause instanceof Error ? cause.message : String(cause)\n } finally {\n if (requestEpoch === epoch) loading = false\n }\n return read()\n },\n close({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n return read()\n },\n apply(changes: V3InputChange[], origin: 'ui' | 'ai' = 'ui', expectedRevision?: number, context?: string) {\n const control = writable()\n // AI must supply the context AND revision captured when it started. Never substitute current values.\n if (origin === 'ai' && (context === undefined || expectedRevision === undefined))\n throw Error('AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.')\n return workspace.apply({\n ...control,\n origin,\n context: context ?? control.context,\n expectedRevision: expectedRevision ?? control.expectedRevision,\n changes\n })\n },\n add(part: V3PrimitiveCreation) {\n return workspace.addPrimitive({ ...writable(), part })\n },\n edit(edit: V3PartEdit) {\n return workspace.editPart({ ...writable(), edit })\n },\n undo() {\n return workspace.undo(writable())\n },\n redo() {\n return workspace.redo(writable())\n },\n source() {\n const { context } = writable()\n return workspace.export({ context }).text\n },\n async save() {\n const control = writable(),\n requestEpoch = epoch\n const exported = workspace.export(control)\n saving = true\n try {\n const record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId })\n if (requestEpoch !== epoch) return read()\n if (!record.id || (id !== undefined && record.id !== id)) throw Error('저장 응답의 Figure 대상이 다릅니다.')\n if (serializeV3Asset(parseV3Asset(record.source)) !== exported.text)\n throw Error('저장 응답이 보낸 모델과 다릅니다. 저장 상태를 다시 확인해 주세요.')\n workspace.acknowledgeSaved(exported)\n id = record.id\n baseline = record.source\n } finally {\n if (requestEpoch === epoch) saving = false\n }\n return read()\n }\n }\n}\nexport type V3ProductSession = ReturnType<typeof createV3ProductSession>\n"]}
1
+ {"version":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oBACjE,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAA;gBACvD,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;gBACpC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;gBACd,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAA;YAC1B,CAAC;oBAAS,CAAC;gBACT,IAAI,YAAY,KAAK,KAAK;oBAAE,MAAM,GAAG,KAAK,CAAA;YAC5C,CAAC;YACD,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n createV3Asset,\n createV3EditorWorkspace,\n serializeV3Asset,\n parseV3Asset,\n type V3InputChange,\n type V3PrimitiveCreation,\n type V3PartEdit,\n type V3AuthoringAction\n} from '@hatiolab/figure-model'\n\nexport interface V3ProductRecord {\n id: string\n source: string\n}\n\n/** Persistence is injected; neither the model engine nor the renderer owns the product ID. */\nexport interface V3ProductStore {\n load(id: string): Promise<V3ProductRecord>\n save(request: {\n id?: string\n source: string\n expectedSource?: string\n creationId?: string\n /** The card's picture. Absent when the browser could not draw one; the source is saved either way. */\n thumbnail?: string\n }): Promise<V3ProductRecord>\n}\n\n/** Product lifecycle boundary. A late response can never change another editor's asset or ID. */\nexport function createV3ProductSession(store: V3ProductStore) {\n const workspace = createV3EditorWorkspace()\n let epoch = 0,\n id: string | undefined,\n baseline: string | undefined\n let loading = false,\n saving = false,\n error: string | undefined\n let creationId: string | undefined\n function read() {\n return { ...workspace.read(), id, loading, saving, error }\n }\n function writable() {\n const view = workspace.read()\n if (loading || error || !view.context || view.revision === null) throw Error('먼저 모델을 정상적으로 열어 주세요.')\n // Serializing writes also makes create retries safe: no second create while the first is pending.\n if (saving) throw Error('저장이 끝난 뒤 편집해 주세요.')\n return { context: view.context, expectedRevision: view.revision, origin: 'ui' as const }\n }\n function clear() {\n workspace.close({ discardDesignChanges: true })\n id = undefined\n baseline = undefined\n error = undefined\n saving = false\n creationId = undefined\n }\n function canLeave(discard: boolean) {\n if (saving) throw Error('저장이 끝난 뒤 모델을 전환해 주세요.')\n if (workspace.read().dirty && !discard) throw Error('저장하지 않은 변경이 있습니다.')\n }\n return {\n read,\n startNew({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n workspace.open(serializeV3Asset(createV3Asset('새 Figure')))\n creationId = crypto.randomUUID()\n return read()\n },\n async open(nextId: string, { discard = false } = {}) {\n canLeave(discard)\n const requestEpoch = ++epoch\n clear()\n loading = true\n try {\n const record = await store.load(nextId)\n if (requestEpoch !== epoch) return read()\n if (record.id !== nextId) throw Error('요청한 Figure와 응답의 대상이 다릅니다.')\n workspace.open(record.source)\n id = nextId\n baseline = record.source\n } catch (cause) {\n if (requestEpoch === epoch) error = cause instanceof Error ? cause.message : String(cause)\n } finally {\n if (requestEpoch === epoch) loading = false\n }\n return read()\n },\n close({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n return read()\n },\n apply(changes: V3InputChange[], origin: 'ui' | 'ai' = 'ui', expectedRevision?: number, context?: string) {\n const control = writable()\n // AI must supply the context AND revision captured when it started. Never substitute current values.\n if (origin === 'ai' && (context === undefined || expectedRevision === undefined))\n throw Error('AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.')\n return workspace.apply({\n ...control,\n origin,\n context: context ?? control.context,\n expectedRevision: expectedRevision ?? control.expectedRevision,\n changes\n })\n },\n add(part: V3PrimitiveCreation) {\n return workspace.addPrimitive({ ...writable(), part })\n },\n edit(edit: V3PartEdit) {\n return workspace.editPart({ ...writable(), edit })\n },\n /** One authoring command — what a person means, not a graph edit — as one step of the same history. */\n command(action: V3AuthoringAction) {\n return workspace.command({ ...writable(), action })\n },\n undo() {\n return workspace.undo(writable())\n },\n redo() {\n return workspace.redo(writable())\n },\n source() {\n const { context } = writable()\n return workspace.export({ context }).text\n },\n /**\n * Saves the model, and the card's picture when the caller managed to take one.\n *\n * The picture is the caller's because taking it needs a canvas, and this session is the place that knows\n * nothing about drawing. A save with no picture is a save: a tab in the background cannot draw, and the\n * source matters more than the card (see `v3-thumbnail.ts`).\n */\n async save({ thumbnail }: { thumbnail?: string } = {}) {\n const control = writable(),\n requestEpoch = epoch\n const exported = workspace.export(control)\n saving = true\n try {\n const record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail })\n if (requestEpoch !== epoch) return read()\n if (!record.id || (id !== undefined && record.id !== id)) throw Error('저장 응답의 Figure 대상이 다릅니다.')\n if (serializeV3Asset(parseV3Asset(record.source)) !== exported.text)\n throw Error('저장 응답이 보낸 모델과 다릅니다. 저장 상태를 다시 확인해 주세요.')\n workspace.acknowledgeSaved(exported)\n id = record.id\n baseline = record.source\n } finally {\n if (requestEpoch === epoch) saving = false\n }\n return read()\n }\n }\n}\nexport type V3ProductSession = ReturnType<typeof createV3ProductSession>\n"]}
@@ -26,6 +26,15 @@ export interface V3RenderPart {
26
26
  };
27
27
  segments?: number;
28
28
  }
29
+ /**
30
+ * The bodies a canvas draws, out of everything the asset evaluated.
31
+ *
32
+ * Two are left out. A scalar body carries no shape or pose — it is a number the graph produced, not something
33
+ * on screen. A body the asset hides is evaluated, placed and gated exactly as a shown one, and excluded from
34
+ * rendering, from shadows and from pointer picking (V3 designer's ruling 2026-09-22); drawing it would make
35
+ * "hidden" mean nothing in the modeller while it means something on a board.
36
+ */
37
+ export declare function drawableV3Parts(geometry: readonly unknown[]): V3RenderPart[];
29
38
  export declare function disposeV3Meshes(group: THREE.Group): void;
30
39
  /** Build first, then swap; failed rendering must not erase the previous scene. No old meshes survive a successful swap. */
31
40
  export declare function replaceV3Meshes(group: THREE.Group, parts: readonly V3RenderPart[], palette: Record<string, string>): void;
@@ -1,36 +1,28 @@
1
1
  import * as THREE from 'three';
2
+ import { buildV3Geometry } from '@hatiolab/things-scene';
3
+ /**
4
+ * The bodies a canvas draws, out of everything the asset evaluated.
5
+ *
6
+ * Two are left out. A scalar body carries no shape or pose — it is a number the graph produced, not something
7
+ * on screen. A body the asset hides is evaluated, placed and gated exactly as a shown one, and excluded from
8
+ * rendering, from shadows and from pointer picking (V3 designer's ruling 2026-09-22); drawing it would make
9
+ * "hidden" mean nothing in the modeller while it means something on a board.
10
+ */
11
+ export function drawableV3Parts(geometry) {
12
+ return geometry.filter((body) => !!body && typeof body === 'object' && 'shape' in body && 'pose' in body && body.visible !== false);
13
+ }
14
+ /**
15
+ * The mesh for one body — things-scene's builder, not a copy of it.
16
+ *
17
+ * The modeller kept its own provider switch and it knew four providers; the converter writes eleven. A body the
18
+ * board drew was refused here with "Unsupported V3 provider: roundedBoxXZ" (2026-09-24, the first canvas check of
19
+ * ADR-0087 step 4). One builder, and the canvas an author looks at shows what a board will show.
20
+ */
2
21
  function geometry(part) {
3
- const d = part.shape.dimensions;
4
- let g;
5
- if (part.shape.provider === 'box')
6
- g = new THREE.BoxGeometry(d.width, d.height, d.depth);
7
- else if (part.shape.provider === 'cylinder')
8
- g = new THREE.CylinderGeometry(d.radius, d.radius, d.length, part.segments ?? 12);
9
- else if (part.shape.provider === 'roundedBox') {
10
- const w = d.width / 2, z = d.depth / 2, r = d.round, s = new THREE.Shape();
11
- s.moveTo(-w + r, -z);
12
- s.lineTo(w - r, -z);
13
- s.quadraticCurveTo(w, -z, w, -z + r);
14
- s.lineTo(w, z - r);
15
- s.quadraticCurveTo(w, z, w - r, z);
16
- s.lineTo(-w + r, z);
17
- s.quadraticCurveTo(-w, z, -w, z - r);
18
- s.lineTo(-w, -z + r);
19
- s.quadraticCurveTo(-w, -z, -w + r, -z);
20
- g = new THREE.ExtrudeGeometry(s, { depth: d.height, bevelEnabled: false, steps: 1, curveSegments: 6 });
21
- g.rotateX(Math.PI / 2);
22
- g.translate(0, d.height / 2, 0);
23
- }
24
- else if (part.shape.provider === 'portal') {
25
- if (!part.shape.profile?.length)
26
- throw Error('Portal profile is missing');
27
- const s = new THREE.Shape(part.shape.profile.map(p => new THREE.Vector2(p.x, p.y)));
28
- g = new THREE.ExtrudeGeometry(s, { depth: d.depth, bevelEnabled: false, steps: 1 });
29
- g.translate(0, 0, -d.depth / 2);
30
- }
31
- else
22
+ const built = buildV3Geometry(part.shape, part.segments ?? 12);
23
+ if (!built)
32
24
  throw Error('Unsupported V3 provider: ' + part.shape.provider);
33
- return g;
25
+ return built;
34
26
  }
35
27
  export function disposeV3Meshes(group) {
36
28
  for (const child of [...group.children]) {
@@ -1 +1 @@
1
- {"version":3,"file":"v3-renderer.js","sourceRoot":"","sources":["../../client/modeller/v3-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,SAAS,QAAQ,CAAC,IAAiB;IAClC,MAAM,CAAC,GAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAA;IAC7B,IAAI,CAAsB,CAAA;IAC1B,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAG,KAAK;QAAC,CAAC,GAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAC,CAAC,CAAC,MAAM,EAAC,CAAC,CAAC,KAAK,CAAC,CAAA;SAC3E,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAG,UAAU;QAAC,CAAC,GAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,EAAC,CAAC,CAAC,MAAM,EAAC,CAAC,CAAC,MAAM,EAAC,IAAI,CAAC,QAAQ,IAAE,EAAE,CAAC,CAAA;SAC9G,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAG,YAAY,EAAC,CAAC;QAC3C,MAAM,CAAC,GAAC,CAAC,CAAC,KAAK,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,KAAK,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,CAAC,KAAK,EAAC,CAAC,GAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAA;QAC3D,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAC,CAAC,EAAC,CAAC,CAAC,CAAC,C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G,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAA;YAC3I,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;IACF,CAAC;IAAA,OAAM,KAAK,EAAC,CAAC;QAAA,eAAe,CAAC,MAAM,CAAC,CAAC;QAAA,MAAM,KAAK,CAAA;IAAA,CAAC;IAClD,eAAe,CAAC,KAAK,CAAC,CAAA;IACtB,KAAI,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import * as THREE from 'three'\n\n/** Evaluated V3 boundary: graph values are resolved before reaching the renderer. */\nexport interface V3RenderPart {\n id: string\n shape: { provider: string; dimensions: Record<string, number>; profile?: Array<{x:number;y:number}> }\n pose: {r:number[][];t:number[]}\n material: {token:string;preset?:string;transparent?:boolean;emissive?:{token:string;intensity:number;on:boolean}}\n segments?:number\n}\n\nfunction geometry(part:V3RenderPart):THREE.BufferGeometry {\n const d=part.shape.dimensions\n let g:THREE.BufferGeometry\n if(part.shape.provider==='box')g=new THREE.BoxGeometry(d.width,d.height,d.depth)\n else if(part.shape.provider==='cylinder')g=new THREE.CylinderGeometry(d.radius,d.radius,d.length,part.segments??12)\n else if(part.shape.provider==='roundedBox'){\n const w=d.width/2,z=d.depth/2,r=d.round,s=new THREE.Shape()\n s.moveTo(-w+r,-z);s.lineTo(w-r,-z);s.quadraticCurveTo(w,-z,w,-z+r)\n s.lineTo(w,z-r);s.quadraticCurveTo(w,z,w-r,z);s.lineTo(-w+r,z)\n s.quadraticCurveTo(-w,z,-w,z-r);s.lineTo(-w,-z+r);s.quadraticCurveTo(-w,-z,-w+r,-z)\n g=new THREE.ExtrudeGeometry(s,{depth:d.height,bevelEnabled:false,steps:1,curveSegments:6})\n g.rotateX(Math.PI/2);g.translate(0,d.height/2,0)\n }else if(part.shape.provider==='portal'){\n if(!part.shape.profile?.length)throw Error('Portal profile is missing')\n const s=new THREE.Shape(part.shape.profile.map(p=>new THREE.Vector2(p.x,p.y)))\n g=new THREE.ExtrudeGeometry(s,{depth:d.depth,bevelEnabled:false,steps:1});g.translate(0,0,-d.depth/2)\n }else throw Error('Unsupported V3 provider: '+part.shape.provider)\n return g\n}\n\nexport function disposeV3Meshes(group:THREE.Group):void {\n for(const child of [...group.children]){\n if(child instanceof THREE.Mesh){child.geometry.dispose();const materials=Array.isArray(child.material)?child.material:[child.material];materials.forEach(m=>m.dispose())}\n group.remove(child)\n }\n}\n\n/** Build first, then swap; failed rendering must not erase the previous scene. No old meshes survive a successful swap. */\nexport function replaceV3Meshes(group:THREE.Group,parts:readonly V3RenderPart[],palette:Record<string,string>):void {\n const staged=new THREE.Group(),ids=new Set<string>()\n try{\n for(const part of parts){\n if(ids.has(part.id))throw Error('Duplicate V3 geometry ID: '+part.id);ids.add(part.id)\n const color=palette[part.material.token]\n if(!color||!/^#[0-9a-f]{6}$/i.test(color))throw Error('Unresolved material token: '+part.material.token)\n const {r,t}=part.pose\n if(r.length!==3||r.some(row=>row.length!==3||row.some(x=>!Number.isFinite(x)))||t.length!==3||t.some(x=>!Number.isFinite(x)))throw Error('Invalid V3 pose: '+part.id)\n const emissive=part.material.emissive\n if(emissive?.on&&!/^#[0-9a-f]{6}$/i.test(palette[emissive.token]??''))throw Error('Unresolved emissive token')\n const g=geometry(part)\n const material=new THREE.MeshStandardMaterial({color,metalness:part.material.preset==='metal'?0.8:0,roughness:part.material.preset==='metal'?0.3:0.65,transparent:!!part.material.transparent,opacity:part.material.transparent?0.35:1,emissive:emissive?.on?palette[emissive.token]:0,emissiveIntensity:emissive?.on?emissive.intensity:0})\n const mesh=new THREE.Mesh(g,material);mesh.name=part.id;mesh.userData.figurePartId=part.id\n mesh.matrixAutoUpdate=false;mesh.matrix.set(r[0][0],r[0][1],r[0][2],t[0],r[1][0],r[1][1],r[1][2],t[1],r[2][0],r[2][1],r[2][2],t[2],0,0,0,1)\n staged.add(mesh)\n }\n }catch(error){disposeV3Meshes(staged);throw error}\n disposeV3Meshes(group)\n for(const mesh of [...staged.children])group.add(mesh)\n group.updateMatrixWorld(true)\n}\n"]}
1
+ {"version":3,"file":"v3-renderer.js","sourceRoot":"","sources":["../../client/modeller/v3-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAWxD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,QAA4B;IAC1D,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,IAAI,EAAwB,EAAE,CAC7B,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAK,IAA8B,CAAC,OAAO,KAAK,KAAK,CAC/H,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,IAAkB;IAClC,MAAM,K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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAA;YAC3I,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;IACF,CAAC;IAAA,OAAM,KAAK,EAAC,CAAC;QAAA,eAAe,CAAC,MAAM,CAAC,CAAC;QAAA,MAAM,KAAK,CAAA;IAAA,CAAC;IAClD,eAAe,CAAC,KAAK,CAAC,CAAA;IACtB,KAAI,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import * as THREE from 'three'\nimport { buildV3Geometry } from '@hatiolab/things-scene'\n\n/** Evaluated V3 boundary: graph values are resolved before reaching the renderer. */\nexport interface V3RenderPart {\n id: string\n shape: { provider: string; dimensions: Record<string, number>; profile?: Array<{x:number;y:number}> }\n pose: {r:number[][];t:number[]}\n material: {token:string;preset?:string;transparent?:boolean;emissive?:{token:string;intensity:number;on:boolean}}\n segments?:number\n}\n\n/**\n * The bodies a canvas draws, out of everything the asset evaluated.\n *\n * Two are left out. A scalar body carries no shape or pose — it is a number the graph produced, not something\n * on screen. A body the asset hides is evaluated, placed and gated exactly as a shown one, and excluded from\n * rendering, from shadows and from pointer picking (V3 designer's ruling 2026-09-22); drawing it would make\n * \"hidden\" mean nothing in the modeller while it means something on a board.\n */\nexport function drawableV3Parts(geometry: readonly unknown[]): V3RenderPart[] {\n return geometry.filter(\n (body): body is V3RenderPart =>\n !!body && typeof body === 'object' && 'shape' in body && 'pose' in body && (body as { visible?: boolean }).visible !== false\n )\n}\n\n/**\n * The mesh for one body — things-scene's builder, not a copy of it.\n *\n * The modeller kept its own provider switch and it knew four providers; the converter writes eleven. A body the\n * board drew was refused here with \"Unsupported V3 provider: roundedBoxXZ\" (2026-09-24, the first canvas check of\n * ADR-0087 step 4). One builder, and the canvas an author looks at shows what a board will show.\n */\nfunction geometry(part: V3RenderPart): THREE.BufferGeometry {\n const built = buildV3Geometry(part.shape as never, part.segments ?? 12) as THREE.BufferGeometry | undefined\n if (!built) throw Error('Unsupported V3 provider: ' + part.shape.provider)\n return built\n}\n\nexport function disposeV3Meshes(group:THREE.Group):void {\n for(const child of [...group.children]){\n if(child instanceof THREE.Mesh){child.geometry.dispose();const materials=Array.isArray(child.material)?child.material:[child.material];materials.forEach(m=>m.dispose())}\n group.remove(child)\n }\n}\n\n/** Build first, then swap; failed rendering must not erase the previous scene. No old meshes survive a successful swap. */\nexport function replaceV3Meshes(group:THREE.Group,parts:readonly V3RenderPart[],palette:Record<string,string>):void {\n const staged=new THREE.Group(),ids=new Set<string>()\n try{\n for(const part of parts){\n if(ids.has(part.id))throw Error('Duplicate V3 geometry ID: '+part.id);ids.add(part.id)\n const color=palette[part.material.token]\n if(!color||!/^#[0-9a-f]{6}$/i.test(color))throw Error('Unresolved material token: '+part.material.token)\n const {r,t}=part.pose\n if(r.length!==3||r.some(row=>row.length!==3||row.some(x=>!Number.isFinite(x)))||t.length!==3||t.some(x=>!Number.isFinite(x)))throw Error('Invalid V3 pose: '+part.id)\n const emissive=part.material.emissive\n if(emissive?.on&&!/^#[0-9a-f]{6}$/i.test(palette[emissive.token]??''))throw Error('Unresolved emissive token')\n const g=geometry(part)\n const material=new THREE.MeshStandardMaterial({color,metalness:part.material.preset==='metal'?0.8:0,roughness:part.material.preset==='metal'?0.3:0.65,transparent:!!part.material.transparent,opacity:part.material.transparent?0.35:1,emissive:emissive?.on?palette[emissive.token]:0,emissiveIntensity:emissive?.on?emissive.intensity:0})\n const mesh=new THREE.Mesh(g,material);mesh.name=part.id;mesh.userData.figurePartId=part.id\n mesh.matrixAutoUpdate=false;mesh.matrix.set(r[0][0],r[0][1],r[0][2],t[0],r[1][0],r[1][1],r[1][2],t[1],r[2][0],r[2][1],r[2][2],t[2],0,0,0,1)\n staged.add(mesh)\n }\n }catch(error){disposeV3Meshes(staged);throw error}\n disposeV3Meshes(group)\n for(const mesh of [...staged.children])group.add(mesh)\n group.updateMatrixWorld(true)\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import './v3-canvas.js';
2
+ import type { V3RenderPart } from './v3-renderer.js';
3
+ export declare function captureV3Thumbnail(parts: V3RenderPart[], palette: Record<string, string>): Promise<string | undefined>;
@@ -0,0 +1,74 @@
1
+ import './v3-canvas.js';
2
+ /**
3
+ * 카드에 쓸 그림을 찍는다 — **숨은 자리에 V3 캔버스를 하나 더 세워서.**
4
+ *
5
+ * V2 의 `figure-thumbnail.ts` 와 같은 규율이고, 까닭도 같다.
6
+ *
7
+ * ## 왜 보이는 캔버스를 찍지 않나
8
+ *
9
+ * 저작면의 캔버스는 저작자가 돌려 둔 각도와 확대로 서 있다. 그것을 찍으면 카드마다 프레임이
10
+ * 달라지고, 방금 확대해 보던 나사 하나가 그 자산의 얼굴이 된다. 목록은 견주는 자리이므로 그림은
11
+ * **정해진 크기와 정해진 카메라**로 찍는다. `figure-v3-canvas` 의 `thumbnail()` 은 보이는 캔버스를
12
+ * 그대로 뽑으므로 카드용이 아니다 — 여기서는 새로 세운 캔버스가 스스로 `fit()` 한 자리에서 찍는다.
13
+ *
14
+ * ## 왜 서버가 아니라 브라우저인가
15
+ *
16
+ * 백엔드에 GPU 가 없는 배포가 많아 헤드리스로 3D 를 찍는 것이 자주 실패한다. 도형을 그릴 GPU 는
17
+ * 이미 보는 사람 손에 있다.
18
+ *
19
+ * ## 못 찍어도 저장은 간다
20
+ *
21
+ * 탭이 뒤로 가면 브라우저가 `requestAnimationFrame` 을 멈춘다. 그 위에 저장이 얹혀 있으면 저장이
22
+ * 통째로 멈춘다 — 단추는 잠긴 채로, 아무 말도 없이. 그래서 시계와 경주시키고, 늦으면 그림 없이
23
+ * 간다. 정본이 그림보다 중하고, 그림은 다음에 저작면을 열 때 다시 채운다.
24
+ */
25
+ /** 카드는 4:3 이다. V2 와 같은 크기 — 목록에 두 판이 섞여 있어도 카드가 고르다. */
26
+ const WIDTH = 480;
27
+ const HEIGHT = 360;
28
+ /** 넘으면 그림 없이 저장한다. 빠르기가 아니라 저장이 멈추지 않는 것이 목적이다. */
29
+ const PATIENCE = 5000;
30
+ const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
31
+ /** 씬이 서고 카메라가 자리를 잡을 틈. rAF 가 멈춘 탭에서도 풀리도록 시계와 경주시킨다. */
32
+ function settle() {
33
+ const frames = new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(resolve, 150))));
34
+ return Promise.race([frames, delay(600)]);
35
+ }
36
+ function within(work, ms) {
37
+ return Promise.race([work, delay(ms).then(() => undefined)]);
38
+ }
39
+ export async function captureV3Thumbnail(parts, palette) {
40
+ if (!parts.length)
41
+ return undefined;
42
+ /*
43
+ 화면 밖에 둔다. `display: none` 이면 캔버스가 크기를 못 얻어 아무것도 그리지 못한다.
44
+ WebGL context 는 브라우저가 8~16개에서 끊으므로 찍은 뒤 반드시 버린다(아래 finally).
45
+ */
46
+ const host = document.createElement('div');
47
+ host.setAttribute('figure-v3-thumbnail-stage', '');
48
+ host.style.cssText = `position: fixed; left: -10000px; top: 0; width: ${WIDTH}px; height: ${HEIGHT}px; pointer-events: none;`;
49
+ document.body.appendChild(host);
50
+ const shooter = document.createElement('figure-v3-canvas');
51
+ shooter.parts = parts;
52
+ shooter.palette = palette;
53
+ shooter.context = 'thumbnail';
54
+ shooter.style.cssText = 'display: block; width: 100%; height: 100%;';
55
+ try {
56
+ host.appendChild(shooter);
57
+ const shot = await within((async () => {
58
+ await settle();
59
+ shooter.fit?.();
60
+ return shooter.thumbnail?.();
61
+ })(), PATIENCE);
62
+ if (!shot)
63
+ console.warn(`[thumbnail] ${PATIENCE}ms 안에 못 찍었습니다 — 그림 없이 저장합니다`);
64
+ return shot;
65
+ }
66
+ catch (e) {
67
+ console.warn(`[thumbnail] 세우지 못했습니다 — ${e.message}`);
68
+ return undefined;
69
+ }
70
+ finally {
71
+ host.remove();
72
+ }
73
+ }
74
+ //# sourceMappingURL=v3-thumbnail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3-thumbnail.js","sourceRoot":"","sources":["../../client/modeller/v3-thumbnail.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAIvB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wDAAwD;AACxD,MAAM,KAAK,GAAG,GAAG,CAAA;AACjB,MAAM,MAAM,GAAG,GAAG,CAAA;AAElB,mDAAmD;AACnD,MAAM,QAAQ,GAAG,IAAI,CAAA;AAUrB,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAEnF,yDAAyD;AACzD,SAAS,MAAM;IACb,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CACzC,qBAAqB,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CACnF,CAAA;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,MAAM,CAAI,IAAgB,EAAE,EAAU;IAC7C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAqB,EACrB,OAA+B;IAE/B,IAAI,CAAC,KAAK,CAAC,MAAM;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{ V3RenderPart } from './v3-renderer.js'\n\n/**\n * 카드에 쓸 그림을 찍는다 — **숨은 자리에 V3 캔버스를 하나 더 세워서.**\n *\n * V2 의 `figure-thumbnail.ts` 와 같은 규율이고, 까닭도 같다.\n *\n * ## 왜 보이는 캔버스를 찍지 않나\n *\n * 저작면의 캔버스는 저작자가 돌려 둔 각도와 확대로 서 있다. 그것을 찍으면 카드마다 프레임이\n * 달라지고, 방금 확대해 보던 나사 하나가 그 자산의 얼굴이 된다. 목록은 견주는 자리이므로 그림은\n * **정해진 크기와 정해진 카메라**로 찍는다. `figure-v3-canvas` 의 `thumbnail()` 은 보이는 캔버스를\n * 그대로 뽑으므로 카드용이 아니다 — 여기서는 새로 세운 캔버스가 스스로 `fit()` 한 자리에서 찍는다.\n *\n * ## 왜 서버가 아니라 브라우저인가\n *\n * 백엔드에 GPU 가 없는 배포가 많아 헤드리스로 3D 를 찍는 것이 자주 실패한다. 도형을 그릴 GPU 는\n * 이미 보는 사람 손에 있다.\n *\n * ## 못 찍어도 저장은 간다\n *\n * 탭이 뒤로 가면 브라우저가 `requestAnimationFrame` 을 멈춘다. 그 위에 저장이 얹혀 있으면 저장이\n * 통째로 멈춘다 — 단추는 잠긴 채로, 아무 말도 없이. 그래서 시계와 경주시키고, 늦으면 그림 없이\n * 간다. 정본이 그림보다 중하고, 그림은 다음에 저작면을 열 때 다시 채운다.\n */\n\n/** 카드는 4:3 이다. V2 와 같은 크기 — 목록에 두 판이 섞여 있어도 카드가 고르다. */\nconst WIDTH = 480\nconst HEIGHT = 360\n\n/** 넘으면 그림 없이 저장한다. 빠르기가 아니라 저장이 멈추지 않는 것이 목적이다. */\nconst PATIENCE = 5000\n\ninterface Shooter extends HTMLElement {\n parts?: V3RenderPart[]\n palette?: Record<string, string>\n context?: string\n thumbnail?: () => string | undefined\n fit?: () => void\n}\n\nconst delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))\n\n/** 씬이 서고 카메라가 자리를 잡을 틈. rAF 가 멈춘 탭에서도 풀리도록 시계와 경주시킨다. */\nfunction settle(): Promise<void> {\n const frames = new Promise<void>(resolve =>\n requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(resolve, 150)))\n )\n return Promise.race([frames, delay(600)])\n}\n\nfunction within<T>(work: Promise<T>, ms: number): Promise<T | undefined> {\n return Promise.race([work, delay(ms).then(() => undefined)])\n}\n\nexport async function captureV3Thumbnail(\n parts: V3RenderPart[],\n palette: Record<string, string>\n): Promise<string | undefined> {\n if (!parts.length) return undefined\n\n /*\n 화면 밖에 둔다. `display: none` 이면 캔버스가 크기를 못 얻어 아무것도 그리지 못한다.\n WebGL context 는 브라우저가 8~16개에서 끊으므로 찍은 뒤 반드시 버린다(아래 finally).\n */\n const host = document.createElement('div')\n host.setAttribute('figure-v3-thumbnail-stage', '')\n host.style.cssText = `position: fixed; left: -10000px; top: 0; width: ${WIDTH}px; height: ${HEIGHT}px; pointer-events: none;`\n document.body.appendChild(host)\n\n const shooter = document.createElement('figure-v3-canvas') as Shooter\n shooter.parts = parts\n shooter.palette = palette\n shooter.context = 'thumbnail'\n shooter.style.cssText = 'display: block; width: 100%; height: 100%;'\n\n try {\n host.appendChild(shooter)\n const shot = await within(\n (async () => {\n await settle()\n shooter.fit?.()\n return shooter.thumbnail?.()\n })(),\n PATIENCE\n )\n if (!shot) console.warn(`[thumbnail] ${PATIENCE}ms 안에 못 찍었습니다 — 그림 없이 저장합니다`)\n return shot\n } catch (e) {\n console.warn(`[thumbnail] 세우지 못했습니다 — ${(e as Error).message}`)\n return undefined\n } finally {\n host.remove()\n }\n}\n"]}
@@ -1,6 +1,15 @@
1
1
  import { PageView } from '@operato/shell';
2
2
  import '../modeller/v3-editor.js';
3
- /** The V3 product page has exactly one authoritative workspace for UI and AI input transactions. */
3
+ import '../modeller/figure-history-panel.js';
4
+ /**
5
+ * The V3 product page has exactly one authoritative workspace for UI and AI input transactions.
6
+ *
7
+ * It answers to `figure-v3-modeller` while the catalogue's assets are still V2. The designer's order switches
8
+ * the production data and the consuming paths together (ADR-0087, step 5): until the assets are converted, a
9
+ * `figure-modeller` that opened this page would fail on every figure in the catalogue. Having its own route
10
+ * is what makes steps 3 and 4 — the conversion on a recoverable copy, and the canvas check — possible at all.
11
+ * At step 5 the V2 page goes, and this one takes the `figure-modeller` name and route.
12
+ */
4
13
  export declare class FigureV3ModellerPage extends PageView {
5
14
  static styles: import("lit").CSSResult;
6
15
  private readonly session;
@@ -8,8 +17,24 @@ export declare class FigureV3ModellerPage extends PageView {
8
17
  private discardApproved;
9
18
  private revision;
10
19
  private error;
20
+ /**
21
+ * 발행 패널이 읽는 행의 사실 — 상태와 발행 판 번호. 원본은 세션이 들고, 이 둘은 행에 있다.
22
+ *
23
+ * 이 화면에는 발행 패널이 없었다. 저장은 되고 발행 · 판본 · 복원 · 판정을 볼 자리가 없어서, ADR-0087 5단계에서
24
+ * `figure-modeller` 가 이 화면으로 바뀌면 저작자는 발행을 할 수 없었다. 새 V3 도형은 공간을 선언하기 전에는 전부
25
+ * 발행 판정에 막히는데 그 선언을 할 단추도 없었다(2026-09-24 확인). 서버의 문 하나가 두 형식을 다 읽으므로
26
+ * V2 화면의 패널을 그대로 건다.
27
+ */
28
+ private row;
29
+ private wasDirty;
11
30
  private announce;
12
31
  private changed;
32
+ private readRow;
33
+ /** 「부품에 맞추기」 — 공간을 지금 부품에서 다시 선언한다. 저장은 저작자가 따로 한다. */
34
+ private fitToParts;
35
+ private released;
36
+ /** 과거 판으로 되돌렸으면 서버의 원본이 바뀐 것이다 — 다시 연다. 패널은 저장 안 된 것이 있으면 되돌리기를 막는다. */
37
+ private reverted;
13
38
  /** The dock must explicitly use this checked transaction contract, never an unversioned overwrite. */
14
39
  private applyAI;
15
40
  connectedCallback(): void;
@@ -4,8 +4,19 @@ import { customElement, state } from 'lit/decorators.js';
4
4
  import { PageView } from '@operato/shell';
5
5
  import { createV3ProductSession } from '../modeller/v3-product-session.js';
6
6
  import { v3ProductStore } from '../graphql/v3-store.js';
7
+ import { fetchFigure } from '../graphql/index.js';
8
+ import { occupancyFromParts } from '../modeller/v3-occupancy.js';
7
9
  import '../modeller/v3-editor.js';
8
- /** The V3 product page has exactly one authoritative workspace for UI and AI input transactions. */
10
+ import '../modeller/figure-history-panel.js';
11
+ /**
12
+ * The V3 product page has exactly one authoritative workspace for UI and AI input transactions.
13
+ *
14
+ * It answers to `figure-v3-modeller` while the catalogue's assets are still V2. The designer's order switches
15
+ * the production data and the consuming paths together (ADR-0087, step 5): until the assets are converted, a
16
+ * `figure-modeller` that opened this page would fail on every figure in the catalogue. Having its own route
17
+ * is what makes steps 3 and 4 — the conversion on a recoverable copy, and the canvas check — possible at all.
18
+ * At step 5 the V2 page goes, and this one takes the `figure-modeller` name and route.
19
+ */
9
20
  let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
10
21
  constructor() {
11
22
  super(...arguments);
@@ -13,6 +24,16 @@ let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
13
24
  this.discardApproved = false;
14
25
  this.revision = 0;
15
26
  this.error = '';
27
+ /**
28
+ * 발행 패널이 읽는 행의 사실 — 상태와 발행 판 번호. 원본은 세션이 들고, 이 둘은 행에 있다.
29
+ *
30
+ * 이 화면에는 발행 패널이 없었다. 저장은 되고 발행 · 판본 · 복원 · 판정을 볼 자리가 없어서, ADR-0087 5단계에서
31
+ * `figure-modeller` 가 이 화면으로 바뀌면 저작자는 발행을 할 수 없었다. 새 V3 도형은 공간을 선언하기 전에는 전부
32
+ * 발행 판정에 막히는데 그 선언을 할 단추도 없었다(2026-09-24 확인). 서버의 문 하나가 두 형식을 다 읽으므로
33
+ * V2 화면의 패널을 그대로 건다.
34
+ */
35
+ this.row = { version: 0 };
36
+ this.wasDirty = false;
16
37
  this.announce = () => {
17
38
  const view = this.session.read();
18
39
  if (!this.active || view.loading || view.saving || view.error || !view.context)
@@ -29,8 +50,37 @@ let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
29
50
  };
30
51
  this.changed = () => {
31
52
  this.revision++;
32
- if (!this.session.read().saving)
53
+ const view = this.session.read();
54
+ if (!view.saving)
33
55
  this.announce();
56
+ /* 저장이 끝난 순간 행을 다시 읽는다 — 발행된 도형을 고쳐 저장하면 서버가 초안으로 내린다. */
57
+ if (this.wasDirty && !view.dirty && !view.saving && view.id)
58
+ this.readRow(view.id);
59
+ this.wasDirty = !!view.dirty;
60
+ };
61
+ /** 「부품에 맞추기」 — 공간을 지금 부품에서 다시 선언한다. 저장은 저작자가 따로 한다. */
62
+ this.fitToParts = () => {
63
+ try {
64
+ this.session.command(occupancyFromParts(this.session.source()));
65
+ this.changed();
66
+ }
67
+ catch (error) {
68
+ this.error = error instanceof Error ? error.message : String(error);
69
+ }
70
+ };
71
+ this.released = (event) => {
72
+ const figure = event.detail?.figure;
73
+ if (figure?.id && figure.id === this.session.read().id)
74
+ this.row = { state: figure.state, version: figure.version ?? 0 };
75
+ };
76
+ /** 과거 판으로 되돌렸으면 서버의 원본이 바뀐 것이다 — 다시 연다. 패널은 저장 안 된 것이 있으면 되돌리기를 막는다. */
77
+ this.reverted = async () => {
78
+ const id = this.session.read().id;
79
+ if (!id)
80
+ return;
81
+ await this.session.open(id, { discard: true });
82
+ this.changed();
83
+ this.readRow(id);
34
84
  };
35
85
  /** The dock must explicitly use this checked transaction contract, never an unversioned overwrite. */
36
86
  this.applyAI = (event) => {
@@ -51,19 +101,43 @@ let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
51
101
  static { this.styles = css `
52
102
  :host {
53
103
  display: flex;
54
- flex-direction: column;
104
+ flex-direction: row;
55
105
  height: 100%;
56
106
  min-height: 0;
107
+ /*
108
+ The page must fit the width it is given. Without this the shell sizes it to its content — the editor's
109
+ 660 plus the 320 release panel — and the panel runs off the right edge (seen at 945 px, 2026-09-24). The
110
+ V2 page does the same.
111
+ */
112
+ overflow: hidden;
57
113
  }
58
114
  figure-v3-editor {
59
115
  flex: 1;
116
+ min-width: 0;
60
117
  min-height: 0;
61
118
  }
119
+ figure-history-panel {
120
+ width: 320px;
121
+ flex: none;
122
+ min-height: 0;
123
+ overflow: auto;
124
+ border-left: 1px solid var(--md-sys-color-outline-variant);
125
+ }
62
126
  .error {
63
127
  padding: 16px;
64
128
  color: #922716;
65
129
  }
66
130
  `; }
131
+ async readRow(id) {
132
+ try {
133
+ const figure = await fetchFigure(id);
134
+ if (this.session.read().id === id)
135
+ this.row = { state: figure.state, version: figure.version ?? 0 };
136
+ }
137
+ catch {
138
+ /* 행을 못 읽으면 패널은 판 번호 0 으로 보인다 — 발행 문이 서버에서 다시 판단하므로 여기서 지어내지 않는다. */
139
+ }
140
+ }
67
141
  connectedCallback() {
68
142
  super.connectedCallback();
69
143
  window.addEventListener('figure-ai-context-request', this.announce);
@@ -101,9 +175,12 @@ let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
101
175
  const opening = this.session.open(id, { discard });
102
176
  this.changed();
103
177
  await opening;
178
+ this.readRow(id);
104
179
  }
105
- else
180
+ else {
106
181
  this.session.startNew({ discard });
182
+ this.row = { version: 0 };
183
+ }
107
184
  this.routeId = id;
108
185
  this.error = '';
109
186
  this.changed();
@@ -116,13 +193,24 @@ let FigureV3ModellerPage = class FigureV3ModellerPage extends PageView {
116
193
  return { title: this.session.read().name ?? 'Figure', actions: [] };
117
194
  }
118
195
  render() {
119
- return this.error
120
- ? html `<p role="alert" class="error">${this.error}</p>`
121
- : html `<figure-v3-editor
122
- .session=${this.session}
123
- .revision=${this.revision}
124
- @v3-changed=${this.changed}
125
- ></figure-v3-editor>`;
196
+ if (this.error)
197
+ return html `<p role="alert" class="error">${this.error}</p>`;
198
+ const view = this.session.read();
199
+ return html `<figure-v3-editor
200
+ .session=${this.session}
201
+ .revision=${this.revision}
202
+ @v3-changed=${this.changed}
203
+ ></figure-v3-editor>
204
+ <figure-history-panel
205
+ format="v3"
206
+ .figureId=${view.id}
207
+ .figureState=${this.row.state}
208
+ .figureVersion=${this.row.version}
209
+ .dirty=${!!view.dirty}
210
+ @fit-base-to-parts=${this.fitToParts}
211
+ @figure-released=${this.released}
212
+ @figure-reverted=${this.reverted}
213
+ ></figure-history-panel>`;
126
214
  }
127
215
  };
128
216
  __decorate([
@@ -133,8 +221,12 @@ __decorate([
133
221
  state(),
134
222
  __metadata("design:type", Object)
135
223
  ], FigureV3ModellerPage.prototype, "error", void 0);
224
+ __decorate([
225
+ state(),
226
+ __metadata("design:type", Object)
227
+ ], FigureV3ModellerPage.prototype, "row", void 0);
136
228
  FigureV3ModellerPage = __decorate([
137
- customElement('figure-modeller-page')
229
+ customElement('figure-v3-modeller-page')
138
230
  ], FigureV3ModellerPage);
139
231
  export { FigureV3ModellerPage };
140
232
  //# sourceMappingURL=figure-v3-modeller-page.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"figure-v3-modeller-page.js","sourceRoot":"","sources":["../../client/pages/figure-v3-modeller-page.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,0BAA0B,CAAA;AAEjC,oGAAoG;AAE7F,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,QAAQ;IAA3C;;QAiBY,YAAO,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAA;QAEzD,oBAAe,GAAG,KAAK,CAAA;QACd,aAAQ,GAAG,CAAC,CAAA;QACZ,UAAK,GAAG,EAAE,CAAA;QACnB,aAAQ,GAAG,GAAG,EAAE;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI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CAAC,OAAO;sBACX,IAAI,CAAC,QAAQ;wBACX,IAAI,CAAC,OAAO;6BACP,CAAA;IAC3B,CAAC;;AAtFgB;IAAhB,KAAK,EAAE;;sDAAqB;AACZ;IAAhB,KAAK,EAAE;;mDAAmB;AArBhB,oBAAoB;IADhC,aAAa,CAAC,sBAAsB,CAAC;GACzB,oBAAoB,CA2GhC","sourcesContent":["import { html, css } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\nimport { PageView } from '@operato/shell'\nimport { createV3ProductSession } from '../modeller/v3-product-session.js'\nimport { v3ProductStore } from '../graphql/v3-store.js'\nimport '../modeller/v3-editor.js'\n\n/** The V3 product page has exactly one authoritative workspace for UI and AI input transactions. */\n@customElement('figure-modeller-page')\nexport class FigureV3ModellerPage extends PageView {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n }\n figure-v3-editor {\n flex: 1;\n min-height: 0;\n }\n .error {\n padding: 16px;\n color: #922716;\n }\n `\n private readonly session = createV3ProductSession(v3ProductStore)\n private routeId: string | undefined\n private discardApproved = false\n @state() private revision = 0\n @state() private error = ''\n private announce = () => {\n const view = this.session.read()\n if (!this.active || view.loading || view.saving || view.error || !view.context) return\n window.dispatchEvent(\n new CustomEvent('figure-ai-context', {\n detail: {\n figureId: view.id,\n source: JSON.parse(this.session.source()),\n context: view.context,\n revision: view.revision,\n format: 'v3'\n }\n })\n )\n }\n private changed = () => {\n this.revision++\n if (!this.session.read().saving) this.announce()\n }\n /** The dock must explicitly use this checked transaction contract, never an unversioned overwrite. */\n private applyAI = (event: Event) => {\n const detail = (event as CustomEvent).detail\n if (!this.active || !detail) return\n try {\n this.session.apply(detail.changes, 'ai', detail.revision, detail.context)\n detail.applied = true\n this.changed()\n } catch (error) {\n detail.applied = false\n detail.error = error instanceof Error ? error.message : String(error)\n }\n }\n connectedCallback() {\n super.connectedCallback()\n window.addEventListener('figure-ai-context-request', this.announce)\n window.addEventListener('figure-v3-apply', this.applyAI)\n }\n disconnectedCallback() {\n window.removeEventListener('figure-ai-context-request', this.announce)\n window.removeEventListener('figure-v3-apply', this.applyAI)\n super.disconnectedCallback()\n }\n async canDeactivate() {\n const view = this.session.read()\n if (view.saving) return false\n if (!view.dirty) return true\n // The shell invokes this while the edited model is still visible, before navigating away.\n this.discardApproved = window.confirm('저장하지 않은 변경을 버리고 이동하시겠습니까?')\n return this.discardApproved\n }\n async pageUpdated(changes: Record<string, unknown>, lifecycle: { resourceId?: string }) {\n if (!this.active) {\n if (this.session.read().loading) this.session.close()\n window.dispatchEvent(new CustomEvent('figure-ai-context', { detail: undefined }))\n return\n }\n const id = lifecycle?.resourceId\n if (this.session.read().context && id === this.routeId && !changes.active) return\n try {\n const discard = this.discardApproved\n this.discardApproved = false\n if (id) {\n const opening = this.session.open(id, { discard })\n this.changed()\n await opening\n } else this.session.startNew({ discard })\n this.routeId = id\n this.error = ''\n this.changed()\n } catch (error) {\n this.error = error instanceof Error ? error.message : String(error)\n }\n }\n get context() {\n return { title: this.session.read().name ?? 'Figure', actions: [] }\n }\n render() {\n return this.error\n ? html`<p role=\"alert\" class=\"error\">${this.error}</p>`\n : html`<figure-v3-editor\n .session=${this.session}\n .revision=${this.revision}\n @v3-changed=${this.changed}\n ></figure-v3-editor>`\n }\n}\n"]}
1
+ {"version":3,"file":"figure-v3-modeller-page.js","sourceRoot":"","sources":["../../client/pages/figure-v3-modeller-page.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAA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,OAAO,IAAI,CAAA,iCAAiC,IAAI,CAAC,KAAK,MAAM,CAAA;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QAChC,OAAO,IAAI,CAAA;mBACI,IAAI,CAAC,OAAO;oBACX,IAAI,CAAC,QAAQ;sBACX,IAAI,CAAC,OAAO;;;;oBAId,IAAI,CAAC,EAAE;uBACJ,IAAI,CAAC,GAAG,CAAC,KAAK;yBACZ,IAAI,CAAC,GAAG,CAAC,OAAO;iBACxB,CAAC,CAAC,IAAI,CAAC,KAAK;6BACA,IAAI,CAAC,UAAU;2BACjB,IAAI,CAAC,QAAQ;2BACb,IAAI,CAAC,QAAQ;+BACT,CAAA;IAC7B,CAAC;;AA/IgB;IAAhB,KAAK,EAAE;;sDAAqB;AACZ;IAAhB,KAAK,EAAE;;mDAAmB;AASV;IAAhB,KAAK,EAAE;;iDAAgF;AA5C7E,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAkLhC","sourcesContent":["import { html, css } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\nimport { PageView } from '@operato/shell'\nimport { createV3ProductSession } from '../modeller/v3-product-session.js'\nimport { v3ProductStore } from '../graphql/v3-store.js'\nimport { fetchFigure } from '../graphql/index.js'\nimport { occupancyFromParts } from '../modeller/v3-occupancy.js'\nimport '../modeller/v3-editor.js'\nimport '../modeller/figure-history-panel.js'\n\n/**\n * The V3 product page has exactly one authoritative workspace for UI and AI input transactions.\n *\n * It answers to `figure-v3-modeller` while the catalogue's assets are still V2. The designer's order switches\n * the production data and the consuming paths together (ADR-0087, step 5): until the assets are converted, a\n * `figure-modeller` that opened this page would fail on every figure in the catalogue. Having its own route\n * is what makes steps 3 and 4 — the conversion on a recoverable copy, and the canvas check — possible at all.\n * At step 5 the V2 page goes, and this one takes the `figure-modeller` name and route.\n */\n@customElement('figure-v3-modeller-page')\nexport class FigureV3ModellerPage extends PageView {\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n height: 100%;\n min-height: 0;\n /*\n The page must fit the width it is given. Without this the shell sizes it to its content — the editor's\n 660 plus the 320 release panel — and the panel runs off the right edge (seen at 945 px, 2026-09-24). The\n V2 page does the same.\n */\n overflow: hidden;\n }\n figure-v3-editor {\n flex: 1;\n min-width: 0;\n min-height: 0;\n }\n figure-history-panel {\n width: 320px;\n flex: none;\n min-height: 0;\n overflow: auto;\n border-left: 1px solid var(--md-sys-color-outline-variant);\n }\n .error {\n padding: 16px;\n color: #922716;\n }\n `\n private readonly session = createV3ProductSession(v3ProductStore)\n private routeId: string | undefined\n private discardApproved = false\n @state() private revision = 0\n @state() private error = ''\n /**\n * 발행 패널이 읽는 행의 사실 — 상태와 발행 판 번호. 원본은 세션이 들고, 이 둘은 행에 있다.\n *\n * 이 화면에는 발행 패널이 없었다. 저장은 되고 발행 · 판본 · 복원 · 판정을 볼 자리가 없어서, ADR-0087 5단계에서\n * `figure-modeller` 가 이 화면으로 바뀌면 저작자는 발행을 할 수 없었다. 새 V3 도형은 공간을 선언하기 전에는 전부\n * 발행 판정에 막히는데 그 선언을 할 단추도 없었다(2026-09-24 확인). 서버의 문 하나가 두 형식을 다 읽으므로\n * V2 화면의 패널을 그대로 건다.\n */\n @state() private row: { state?: 'draft' | 'released'; version: number } = { version: 0 }\n private wasDirty = false\n private announce = () => {\n const view = this.session.read()\n if (!this.active || view.loading || view.saving || view.error || !view.context) return\n window.dispatchEvent(\n new CustomEvent('figure-ai-context', {\n detail: {\n figureId: view.id,\n source: JSON.parse(this.session.source()),\n context: view.context,\n revision: view.revision,\n format: 'v3'\n }\n })\n )\n }\n private changed = () => {\n this.revision++\n const view = this.session.read()\n if (!view.saving) this.announce()\n /* 저장이 끝난 순간 행을 다시 읽는다 — 발행된 도형을 고쳐 저장하면 서버가 초안으로 내린다. */\n if (this.wasDirty && !view.dirty && !view.saving && view.id) this.readRow(view.id)\n this.wasDirty = !!view.dirty\n }\n private async readRow(id: string) {\n try {\n const figure = await fetchFigure(id)\n if (this.session.read().id === id) this.row = { state: figure.state as 'draft' | 'released', version: figure.version ?? 0 }\n } catch {\n /* 행을 못 읽으면 패널은 판 번호 0 으로 보인다 — 발행 문이 서버에서 다시 판단하므로 여기서 지어내지 않는다. */\n }\n }\n /** 「부품에 맞추기」 — 공간을 지금 부품에서 다시 선언한다. 저장은 저작자가 따로 한다. */\n private fitToParts = () => {\n try {\n this.session.command(occupancyFromParts(this.session.source()))\n this.changed()\n } catch (error) {\n this.error = error instanceof Error ? error.message : String(error)\n }\n }\n private released = (event: Event) => {\n const figure = (event as CustomEvent).detail?.figure\n if (figure?.id && figure.id === this.session.read().id) this.row = { state: figure.state, version: figure.version ?? 0 }\n }\n /** 과거 판으로 되돌렸으면 서버의 원본이 바뀐 것이다 — 다시 연다. 패널은 저장 안 된 것이 있으면 되돌리기를 막는다. */\n private reverted = async () => {\n const id = this.session.read().id\n if (!id) return\n await this.session.open(id, { discard: true })\n this.changed()\n this.readRow(id)\n }\n /** The dock must explicitly use this checked transaction contract, never an unversioned overwrite. */\n private applyAI = (event: Event) => {\n const detail = (event as CustomEvent).detail\n if (!this.active || !detail) return\n try {\n this.session.apply(detail.changes, 'ai', detail.revision, detail.context)\n detail.applied = true\n this.changed()\n } catch (error) {\n detail.applied = false\n detail.error = error instanceof Error ? error.message : String(error)\n }\n }\n connectedCallback() {\n super.connectedCallback()\n window.addEventListener('figure-ai-context-request', this.announce)\n window.addEventListener('figure-v3-apply', this.applyAI)\n }\n disconnectedCallback() {\n window.removeEventListener('figure-ai-context-request', this.announce)\n window.removeEventListener('figure-v3-apply', this.applyAI)\n super.disconnectedCallback()\n }\n async canDeactivate() {\n const view = this.session.read()\n if (view.saving) return false\n if (!view.dirty) return true\n // The shell invokes this while the edited model is still visible, before navigating away.\n this.discardApproved = window.confirm('저장하지 않은 변경을 버리고 이동하시겠습니까?')\n return this.discardApproved\n }\n async pageUpdated(changes: Record<string, unknown>, lifecycle: { resourceId?: string }) {\n if (!this.active) {\n if (this.session.read().loading) this.session.close()\n window.dispatchEvent(new CustomEvent('figure-ai-context', { detail: undefined }))\n return\n }\n const id = lifecycle?.resourceId\n if (this.session.read().context && id === this.routeId && !changes.active) return\n try {\n const discard = this.discardApproved\n this.discardApproved = false\n if (id) {\n const opening = this.session.open(id, { discard })\n this.changed()\n await opening\n this.readRow(id)\n } else {\n this.session.startNew({ discard })\n this.row = { version: 0 }\n }\n this.routeId = id\n this.error = ''\n this.changed()\n } catch (error) {\n this.error = error instanceof Error ? error.message : String(error)\n }\n }\n get context() {\n return { title: this.session.read().name ?? 'Figure', actions: [] }\n }\n render() {\n if (this.error) return html`<p role=\"alert\" class=\"error\">${this.error}</p>`\n const view = this.session.read()\n return html`<figure-v3-editor\n .session=${this.session}\n .revision=${this.revision}\n @v3-changed=${this.changed}\n ></figure-v3-editor>\n <figure-history-panel\n format=\"v3\"\n .figureId=${view.id}\n .figureState=${this.row.state}\n .figureVersion=${this.row.version}\n .dirty=${!!view.dirty}\n @fit-base-to-parts=${this.fitToParts}\n @figure-released=${this.released}\n @figure-reverted=${this.reverted}\n ></figure-history-panel>`\n }\n}\n"]}
@@ -1 +1 @@
1
- export default function route(page: string): "figure-modeller" | "figure-list" | undefined;
1
+ export default function route(page: string): "figure-list" | "figure-modeller" | "figure-v3-modeller" | undefined;
@@ -6,6 +6,13 @@ export default function route(page) {
6
6
  case 'figure-modeller':
7
7
  import('./pages/figure-modeller-page');
8
8
  return page;
9
+ /*
10
+ The V3 modeller, under its own name until the catalogue's assets are V3 (ADR-0087, step 5). Both pages
11
+ define a custom element, and an element name may be registered once, so they cannot share one.
12
+ */
13
+ case 'figure-v3-modeller':
14
+ import('./pages/figure-v3-modeller-page');
15
+ return page;
9
16
  }
10
17
  }
11
18
  //# sourceMappingURL=route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,aAAa;YAChB,MAAM,CAAC,0BAA0B,CAAC,CAAA;YAClC,OAAO,IAAI,CAAA;QAEb,KAAK,iBAAiB;YACpB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC","sourcesContent":["export default function route(page: string) {\n switch (page) {\n case 'figure-list':\n import('./pages/figure-list-page')\n return page\n\n case 'figure-modeller':\n import('./pages/figure-modeller-page')\n return page\n }\n}\n"]}
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,aAAa;YAChB,MAAM,CAAC,0BAA0B,CAAC,CAAA;YAClC,OAAO,IAAI,CAAA;QAEb,KAAK,iBAAiB;YACpB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,OAAO,IAAI,CAAA;QAEb;;;UAGE;QACF,KAAK,oBAAoB;YACvB,MAAM,CAAC,iCAAiC,CAAC,CAAA;YACzC,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC","sourcesContent":["export default function route(page: string) {\n switch (page) {\n case 'figure-list':\n import('./pages/figure-list-page')\n return page\n\n case 'figure-modeller':\n import('./pages/figure-modeller-page')\n return page\n\n /*\n The V3 modeller, under its own name until the catalogue's assets are V3 (ADR-0087, step 5). Both pages\n define a custom element, and an element name may be registered once, so they cannot share one.\n */\n case 'figure-v3-modeller':\n import('./pages/figure-v3-modeller-page')\n return page\n }\n}\n"]}