@things-factory/figure-ui 10.1.168 → 10.1.170

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 (123) hide show
  1. package/client/figure-assistant.ts +10 -1
  2. package/client/modeller/affected-parts.ts +11 -0
  3. package/client/modeller/ai-proposal.ts +40 -9
  4. package/client/modeller/canvas.ts +15 -1
  5. package/client/modeller/editor-styles.ts +98 -6
  6. package/client/modeller/editor.ts +212 -53
  7. package/client/modeller/fasten-geometry.ts +19 -0
  8. package/client/modeller/figure-fasten-drawing.ts +4 -3
  9. package/client/modeller/figure-links.ts +80 -37
  10. package/client/modeller/figure-material-panel.ts +20 -1
  11. package/client/modeller/figure-preview.ts +117 -8
  12. package/client/modeller/figure-properties.ts +1 -2
  13. package/client/modeller/figure-section-panel.ts +5 -0
  14. package/client/modeller/figure-verdict.ts +9 -2
  15. package/client/modeller/gate-findings.ts +12 -4
  16. package/client/modeller/group-menu.ts +57 -0
  17. package/client/modeller/links.ts +22 -1
  18. package/client/modeller/modeller-keys.ts +6 -0
  19. package/client/modeller/preview-size.ts +32 -0
  20. package/client/modeller/product-session.ts +23 -9
  21. package/client/modeller/refusals.ts +14 -0
  22. package/client/modeller/stage-model.ts +11 -0
  23. package/client/pages/figure-modeller-page.ts +15 -6
  24. package/dist-client/figure-assistant.d.ts +6 -0
  25. package/dist-client/figure-assistant.js +9 -1
  26. package/dist-client/figure-assistant.js.map +1 -1
  27. package/dist-client/modeller/affected-parts.d.ts +6 -0
  28. package/dist-client/modeller/affected-parts.js +12 -0
  29. package/dist-client/modeller/affected-parts.js.map +1 -0
  30. package/dist-client/modeller/ai-proposal.d.ts +15 -5
  31. package/dist-client/modeller/ai-proposal.js +39 -10
  32. package/dist-client/modeller/ai-proposal.js.map +1 -1
  33. package/dist-client/modeller/canvas.d.ts +3 -0
  34. package/dist-client/modeller/canvas.js +12 -1
  35. package/dist-client/modeller/canvas.js.map +1 -1
  36. package/dist-client/modeller/editor-styles.js +98 -6
  37. package/dist-client/modeller/editor-styles.js.map +1 -1
  38. package/dist-client/modeller/editor.d.ts +42 -1
  39. package/dist-client/modeller/editor.js +220 -51
  40. package/dist-client/modeller/editor.js.map +1 -1
  41. package/dist-client/modeller/fasten-geometry.d.ts +27 -0
  42. package/dist-client/modeller/fasten-geometry.js +14 -0
  43. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  44. package/dist-client/modeller/figure-fasten-drawing.js +4 -3
  45. package/dist-client/modeller/figure-fasten-drawing.js.map +1 -1
  46. package/dist-client/modeller/figure-links.d.ts +3 -1
  47. package/dist-client/modeller/figure-links.js +84 -38
  48. package/dist-client/modeller/figure-links.js.map +1 -1
  49. package/dist-client/modeller/figure-material-panel.d.ts +8 -1
  50. package/dist-client/modeller/figure-material-panel.js +24 -1
  51. package/dist-client/modeller/figure-material-panel.js.map +1 -1
  52. package/dist-client/modeller/figure-preview.d.ts +12 -0
  53. package/dist-client/modeller/figure-preview.js +116 -5
  54. package/dist-client/modeller/figure-preview.js.map +1 -1
  55. package/dist-client/modeller/figure-properties.js +1 -2
  56. package/dist-client/modeller/figure-properties.js.map +1 -1
  57. package/dist-client/modeller/figure-section-panel.d.ts +1 -1
  58. package/dist-client/modeller/figure-section-panel.js +5 -0
  59. package/dist-client/modeller/figure-section-panel.js.map +1 -1
  60. package/dist-client/modeller/figure-verdict.d.ts +1 -0
  61. package/dist-client/modeller/figure-verdict.js +8 -2
  62. package/dist-client/modeller/figure-verdict.js.map +1 -1
  63. package/dist-client/modeller/gate-findings.d.ts +3 -1
  64. package/dist-client/modeller/gate-findings.js +8 -4
  65. package/dist-client/modeller/gate-findings.js.map +1 -1
  66. package/dist-client/modeller/group-menu.d.ts +18 -0
  67. package/dist-client/modeller/group-menu.js +52 -0
  68. package/dist-client/modeller/group-menu.js.map +1 -0
  69. package/dist-client/modeller/links.d.ts +5 -0
  70. package/dist-client/modeller/links.js +21 -1
  71. package/dist-client/modeller/links.js.map +1 -1
  72. package/dist-client/modeller/modeller-keys.js +7 -0
  73. package/dist-client/modeller/modeller-keys.js.map +1 -1
  74. package/dist-client/modeller/preview-size.d.ts +23 -0
  75. package/dist-client/modeller/preview-size.js +32 -0
  76. package/dist-client/modeller/preview-size.js.map +1 -0
  77. package/dist-client/modeller/product-session.d.ts +0 -1
  78. package/dist-client/modeller/product-session.js +22 -9
  79. package/dist-client/modeller/product-session.js.map +1 -1
  80. package/dist-client/modeller/refusals.d.ts +1 -5
  81. package/dist-client/modeller/refusals.js +14 -1
  82. package/dist-client/modeller/refusals.js.map +1 -1
  83. package/dist-client/modeller/stage-model.d.ts +11 -0
  84. package/dist-client/modeller/stage-model.js +11 -0
  85. package/dist-client/modeller/stage-model.js.map +1 -1
  86. package/dist-client/pages/figure-modeller-page.d.ts +3 -0
  87. package/dist-client/pages/figure-modeller-page.js +18 -5
  88. package/dist-client/pages/figure-modeller-page.js.map +1 -1
  89. package/dist-client/route.d.ts +1 -1
  90. package/dist-client/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +8 -8
  92. package/test/ai-proposal.test.ts +43 -4
  93. package/test/browser/editing-page.js +3 -1
  94. package/test/browser/editing.check.mjs +2 -1
  95. package/test/browser/links-page.js +1 -0
  96. package/test/browser/links.check.mjs +20 -5
  97. package/test/browser/modeller.check.mjs +6 -0
  98. package/test/browser/more-open.js +11 -0
  99. package/test/browser/parts.check.mjs +11 -1
  100. package/test/browser/places-mesh.check.mjs +9 -3
  101. package/test/browser/product-page.check.mjs +9 -4
  102. package/test/browser/props.check.mjs +224 -0
  103. package/test/browser/screen-page.js +17 -0
  104. package/test/browser/screen.check.mjs +171 -29
  105. package/test/browser/section-page.js +1 -0
  106. package/test/browser/section.check.mjs +6 -0
  107. package/test/command-preview.test.ts +2 -2
  108. package/test/fasten-geometry.test.ts +15 -0
  109. package/test/fields.test.ts +4 -2
  110. package/test/figure-assistant-surface.test.ts +38 -0
  111. package/test/first-minute.test.ts +15 -2
  112. package/test/layout.test.ts +1 -1
  113. package/test/preview-size.test.ts +33 -0
  114. package/test/refusals.test.ts +1 -1
  115. package/test/resize-with-placement.test.ts +1 -1
  116. package/test/stage-model.test.ts +11 -1
  117. package/test/verdict.test.ts +7 -0
  118. package/translations/en.json +43 -27
  119. package/translations/es.json +24 -8
  120. package/translations/ja.json +25 -9
  121. package/translations/ko.json +56 -40
  122. package/translations/ms.json +25 -9
  123. package/translations/zh.json +25 -9
@@ -0,0 +1,32 @@
1
+ import { figureRowOf, FIGURE_INSTANCE_SIZE_INPUTS } from '@hatiolab/figure-model';
2
+ /**
3
+ * What the preview's one figure is at the size being tried, in a line the author reads beside it -- its size in
4
+ * millimetres and how many copies each row holds there (first 15 minutes, 2026-10-16: the author stretched the conveyor
5
+ * and could not tell that the rollers grew in number). The counts are figure-model's reading of what the figure draws at
6
+ * that size (`figureRowOf`), never worked out again here.
7
+ */
8
+ export function previewSizeWordsOf(asset, size, say) {
9
+ const mm = (v) => Math.round(v).toLocaleString();
10
+ const words = [`${mm(size.x)} × ${mm(size.y)} × ${mm(size.z)} mm`];
11
+ for (const row of rowCountsAt(asset, size))
12
+ words.push(say('figure.text.preview-copies', { part: row.part, n: String(row.count) }));
13
+ return words.join(' · ');
14
+ }
15
+ /** Each row's count at the size given, in the order the parts are listed. */
16
+ export function rowCountsAt(asset, size) {
17
+ const values = { [FIGURE_INSTANCE_SIZE_INPUTS.x]: size.x, [FIGURE_INSTANCE_SIZE_INPUTS.y]: size.y, [FIGURE_INSTANCE_SIZE_INPUTS.z]: size.z };
18
+ const rows = [];
19
+ for (const look of asset.appearance) {
20
+ let reading;
21
+ try {
22
+ reading = figureRowOf(asset, look.target, values);
23
+ }
24
+ catch {
25
+ reading = undefined;
26
+ }
27
+ if (reading)
28
+ rows.push({ part: reading.part, count: reading.count });
29
+ }
30
+ return rows;
31
+ }
32
+ //# sourceMappingURL=preview-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-size.js","sourceRoot":"","sources":["../../client/modeller/preview-size.ts"],"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CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,SAAS,CAAA;QACrB,CAAC;QACD,IAAI,OAAO;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { figureRowOf, FIGURE_INSTANCE_SIZE_INPUTS, type FigureAsset } from '@hatiolab/figure-model'\n\ntype Say = (key: string, params?: Record<string, string>) => string\n\n/**\n * What the preview's one figure is at the size being tried, in a line the author reads beside it -- its size in\n * millimetres and how many copies each row holds there (first 15 minutes, 2026-10-16: the author stretched the conveyor\n * and could not tell that the rollers grew in number). The counts are figure-model's reading of what the figure draws at\n * that size (`figureRowOf`), never worked out again here.\n */\nexport function previewSizeWordsOf(asset: FigureAsset, size: { x: number; y: number; z: number }, say: Say): string {\n const mm = (v: number) => Math.round(v).toLocaleString()\n const words = [`${mm(size.x)} × ${mm(size.y)} × ${mm(size.z)} mm`]\n for (const row of rowCountsAt(asset, size)) words.push(say('figure.text.preview-copies', { part: row.part, n: String(row.count) }))\n return words.join(' · ')\n}\n\n/** Each row's count at the size given, in the order the parts are listed. */\nexport function rowCountsAt(asset: FigureAsset, size: { x: number; y: number; z: number }): Array<{ part: string; count: number }> {\n const values = { [FIGURE_INSTANCE_SIZE_INPUTS.x]: size.x, [FIGURE_INSTANCE_SIZE_INPUTS.y]: size.y, [FIGURE_INSTANCE_SIZE_INPUTS.z]: size.z }\n const rows: Array<{ part: string; count: number }> = []\n for (const look of asset.appearance) {\n let reading: ReturnType<typeof figureRowOf>\n try {\n reading = figureRowOf(asset, look.target, values)\n } catch {\n reading = undefined\n }\n if (reading) rows.push({ part: reading.part, count: reading.count })\n }\n return rows\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { type FigureRevision } from './revision.js';
2
2
  import { type FigureInputChange, type FigurePrimitiveCreation, type FigurePartEdit, type FigureAuthoringAction, type FigureProposalStep, type FigureClipConsent } from '@hatiolab/figure-model';
3
- /** Consent to let clips go, and the figure and version it was given on. */
4
3
  export interface FigureClipConsentFor extends FigureClipConsent {
5
4
  context: string;
6
5
  revision: number;
@@ -1,6 +1,14 @@
1
1
  import { thumbnailHashOf } from './thumbnail-hash.js';
2
2
  import { revisionFromView } from './revision.js';
3
3
  import { createFigureAsset, createFigureEditorWorkspace, serializeFigureAsset, parseFigureAsset } from '@hatiolab/figure-model';
4
+ /** Consent to let clips go, and the figure and version it was given on. */
5
+ /**
6
+ * A request the session refuses, with its code: a screen says it from the code (`sessionRefusalOf`), never from the
7
+ * message, which stays for logs (ADR-0054; figure audit 2026-10-16 N6 -- an AI card put the message in its note).
8
+ */
9
+ function refusal(code, message) {
10
+ return Object.assign(Error(message), { code });
11
+ }
4
12
  /** Product lifecycle boundary. A late response can never change another editor's asset or ID. */
5
13
  export function createFigureProductSession(store) {
6
14
  const workspace = createFigureEditorWorkspace();
@@ -70,14 +78,19 @@ export function createFigureProductSession(store) {
70
78
  }
71
79
  return { dropClips: given.dropClips };
72
80
  };
73
- function writable() {
81
+ /* A model open to read: the draft is read during a save too -- the dock reads it when the person sends (audit N5). */
82
+ function readable() {
74
83
  const view = workspace.read();
75
84
  if (loading || error || !view.context || view.revision === null)
76
- throw Error('먼저 모델을 정상적으로 열어 주세요.');
85
+ throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.');
86
+ return { context: view.context, expectedRevision: view.revision, origin: 'ui' };
87
+ }
88
+ function writable() {
89
+ const open = readable();
77
90
  // Serializing writes also makes create retries safe: no second create while the first is pending.
78
91
  if (saving)
79
- throw Error('저장이 끝난 뒤 편집해 주세요.');
80
- return { context: view.context, expectedRevision: view.revision, origin: 'ui' };
92
+ throw refusal('SESSION_SAVING', '저장이 끝난 뒤 편집해 주세요.');
93
+ return open;
81
94
  }
82
95
  function clear() {
83
96
  workspace.close({ discardDesignChanges: true });
@@ -149,7 +162,7 @@ export function createFigureProductSession(store) {
149
162
  const control = writable();
150
163
  // AI must supply the context AND revision captured when it started. Never substitute current values.
151
164
  if (origin === 'ai' && (context === undefined || expectedRevision === undefined))
152
- throw Error('AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.');
165
+ throw refusal('SESSION_VERSION_MISSING', 'AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.');
153
166
  return tracked('do', () => workspace.apply({
154
167
  ...control,
155
168
  origin,
@@ -175,9 +188,9 @@ export function createFigureProductSession(store) {
175
188
  */
176
189
  createUnder(key) {
177
190
  if (id || workspace.read().dirty)
178
- throw Error('손대지 않은 새 모델에만 쓸 수 있습니다.');
191
+ throw refusal('SESSION_NEW_FIGURE_TOUCHED', '손대지 않은 새 모델에만 쓸 수 있습니다.');
179
192
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(key))
180
- throw Error('제안 식별자가 올바르지 않습니다.');
193
+ throw refusal('SESSION_PROPOSAL_KEY', '제안 식별자가 올바르지 않습니다.');
181
194
  creationId = key;
182
195
  },
183
196
  /** The AI proposals whose steps are in the model now, each once. */
@@ -200,7 +213,7 @@ export function createFigureProductSession(store) {
200
213
  previewCommand(action) {
201
214
  const view = workspace.read();
202
215
  if (loading || error || !view.context || view.revision === null)
203
- throw Error('먼저 모델을 정상적으로 열어 주세요.');
216
+ throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.');
204
217
  return workspace.previewCommand({ context: view.context, action });
205
218
  },
206
219
  /** One authoring command — what a person means, not a graph edit — as one step of the same history. */
@@ -228,7 +241,7 @@ export function createFigureProductSession(store) {
228
241
  return tracked('redo', () => workspace.redo(writable()));
229
242
  },
230
243
  source() {
231
- const { context } = writable();
244
+ const { context } = readable();
232
245
  return workspace.export({ context }).text;
233
246
  },
234
247
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"product-session.js","sourceRoot":"","sources":["../../client/modeller/product-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,eAAe,CAAA;AACrE,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAOjB,MAAM,wBAAwB,CAAA;AAgC/B,iGAAiG;AACjG,MAAM,UAAU,0BAA0B,CAAC,KAAyB;IAClE,MAAM,SAAS,GAAG,2BAA2B,EAAE,CAAA;IAC/C,IAAI,KAAK,GAAG,CAAC,EACX,EAAsB,EACtB,QAA4B,CAAA;IAC9B,IAAI,OAAO,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,KAAyB,CAAA;IAC3B,IAAI,UAA8B,CAAA;IAClC;;;;MAIE;IACF,IAAI,IAAI,GAA8B,EAAE,EACtC,MAAM,GAA8B,EAAE,CAAA;IACxC,SAAS,OAAO,CAAI,IAA4B,EAAE,GAAY,EAAE,GAAY;QAC1E,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAA;QACxC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAA;QACpB,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,KAAK,MAAM;YAAE,OAAO,MAAM,CAAA;QACvD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACd,MAAM,GAAG,EAAE,CAAA;QACb,CAAC;aAAM,IAAI,IAAI,KAAK,MAAM;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;;YAC9C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;QAC5B,OAAO,MAAM,CAAA;IACf,CAAC;IACD,MAAM,Q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K,SAAS,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;oBAAE,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;gBAChG,IAAI,oBAAoB,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,IAAI;oBACzE,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAA;gBACvD,yFAAyF;gBACzF,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;gBACd,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAA;gBACxB,WAAW,CAAC,KAAK,EAAE,CAAA;gBACnB;;;kBAGE;gBACF,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ;oBAAE,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;YAC3F,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 { thumbnailHashOf } from './thumbnail-hash.js'\nimport { revisionFromView, type FigureRevision } from './revision.js'\nimport {\n createFigureAsset,\n createFigureEditorWorkspace,\n serializeFigureAsset,\n parseFigureAsset,\n type FigureInputChange,\n type FigurePrimitiveCreation,\n type FigurePartEdit,\n type FigureAuthoringAction,\n type FigureProposalStep,\n type FigureClipConsent\n} from '@hatiolab/figure-model'\n\n/** Consent to let clips go, and the figure and version it was given on. */\nexport interface FigureClipConsentFor extends FigureClipConsent {\n context: string\n revision: number\n}\n\nexport interface FigureProductRecord {\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 FigureProductStore {\n load(id: string): Promise<FigureProductRecord>\n /** Every field a save writes, as the server holds it now: to tell whether a save whose answer was lost landed. */\n readBack?(id: string): Promise<FigureProductRecord & { thumbnailHash?: string; type?: string }>\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 /** The type name a new figure is created under (the first save asks for it). Not sent for an existing one. */\n type?: string\n /** Keys of the AI proposals whose steps the source holds: the server records them with the save. */\n proposalKeys?: string[]\n }): Promise<FigureProductRecord>\n}\n\n/** Product lifecycle boundary. A late response can never change another editor's asset or ID. */\nexport function createFigureProductSession(store: FigureProductStore) {\n const workspace = createFigureEditorWorkspace()\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 /*\n The history as steps, each tagged with the AI proposal it came from (or nothing): mirrored here, since the\n workspace's history does not say where a step came from. A proposal is in the model while its step is on `done` --\n undone, it is not; undone and written past, it never comes back. What a save sends as `proposalKeys`.\n */\n let done: Array<string | undefined> = [],\n undone: Array<string | undefined> = []\n function tracked<T>(kind: 'do' | 'undo' | 'redo', run: () => T, tag?: string): T {\n const before = workspace.read().revision\n const result = run()\n if (workspace.read().revision === before) return result\n if (kind === 'do') {\n done.push(tag)\n undone = []\n } else if (kind === 'undo') undone.push(done.pop())\n else done.push(undone.pop())\n return result\n }\n const inEffect = () => [...new Set(done.filter((tag): tag is string => !!tag))]\n /*\n The creation id is read with the rest: a figure not saved yet is named by it (ADR-0061 decision 3) -- its AI\n conversation is anchored on it, and its first save inserts the row under it, so the name holds across that save.\n */\n function read() {\n return { ...workspace.read(), id, creationId, loading, saving, error }\n }\n /*\n The version on screen, one object for as long as it is the version: the workspace hands out one asset per version\n (and another once a save is acknowledged, or the figure moves on), so that object says whether the last one holds.\n */\n let shown: FigureRevision | undefined\n function revisionNow(): FigureRevision | undefined {\n const view = workspace.read()\n if (!view.context || view.revision === null) return (shown = undefined)\n const context = view.context\n if (shown?.asset !== view.asset) shown = revisionFromView(view, () => workspace.export({ context }).text)\n return shown\n }\n /* Texts sent whose save was never answered: found on the server, the server is confirmed to hold what was sent. */\n const unconfirmed = new Map<string, { thumbnail?: string }>()\n /*\n Consent to let clips go: given for one edit, on the figure and the version it was asked on. The first edit made under\n it takes it; an edit on another figure or another version is refused rather than let clips go that were never named\n for it (designer 2026-09-27).\n */\n let consent: FigureClipConsentFor | undefined\n const consented = () => {\n if (!consent) return {}\n const given = consent\n consent = undefined\n const view = workspace.read()\n if (view.context !== given.context || view.revision !== given.revision) {\n const stale = Object.assign(Error('확인한 뒤 모델이 바뀌어 적용하지 않았습니다. 다시 해 주세요.'), { code: 'CONSENT_STALE' })\n throw stale\n }\n return { dropClips: given.dropClips }\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 done = []\n undone = []\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 /** The figure on screen at its version, for every panel and helper to read; none while nothing is open. Readable while saving. */\n revisionNow,\n /**\n * The source the server is confirmed to hold: loaded, or answered by a save. What a revert sends as `expectedSource`\n * -- the server writes over it only while it still holds this. Nothing for a figure not saved yet.\n */\n confirmedSource: () => (id ? baseline : undefined),\n startNew({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n workspace.open(serializeFigureAsset(createFigureAsset('새 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: FigureInputChange[], 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 tracked('do', () =>\n workspace.apply({\n ...control,\n origin,\n context: context ?? control.context,\n expectedRevision: expectedRevision ?? control.expectedRevision,\n changes\n })\n )\n },\n /**\n * An AI proposal (ADR-0094): the modeller's commands, as one step of the history, on the version the model saw.\n * Never on the current one instead -- a person's edit in between makes the proposal stale, and it is refused.\n */\n applyProposal(steps: readonly FigureProposalStep[], expectedRevision: number, context: string, key?: string) {\n writable()\n /* Never with consent: only the person may let a clip go, and an AI proposal is not the person (designer 2026-09-27). */\n return tracked('do', () => workspace.applyProposal({ origin: 'ai', context, expectedRevision, steps }), key)\n },\n /**\n * A new figure opened for an AI proposal from another screen is created under the proposal's key (ADR-0097 §5.6\n * item 5). Only before the modeller names the figure to the AI dock: once a conversation is anchored on the creation\n * id it stays (ADR-0061 decision 3), and the save's record of the proposal keeps one proposal one figure. Only on a\n * new figure not yet touched -- one being made is the person's, and keeps its own.\n */\n createUnder(key: string) {\n if (id || workspace.read().dirty) throw Error('손대지 않은 새 모델에만 쓸 수 있습니다.')\n if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(key)) throw Error('제안 식별자가 올바르지 않습니다.')\n creationId = key\n },\n /** The AI proposals whose steps are in the model now, each once. */\n proposalsInEffect: inEffect,\n /**\n * A recipe put in by the person (ADR-0095): its resolved commands, as one step of the history, on the version open\n * now. The same path as a proposal; the person is its origin.\n */\n applyRecipe(steps: readonly FigureProposalStep[]) {\n const at = writable()\n return tracked('do', () => workspace.applyProposal({ origin: 'ui', context: at.context, expectedRevision: at.expectedRevision, steps, ...consented() }))\n },\n add(part: FigurePrimitiveCreation) {\n return tracked('do', () => workspace.addPrimitive({ ...writable(), part }))\n },\n edit(edit: FigurePartEdit) {\n return tracked('do', () => workspace.editPart({ ...writable(), edit, ...consented() }))\n },\n /** What a command would do, on a copy (ADR-0097 §5.5): nothing is written, and the answer names its version. */\n previewCommand(action: FigureAuthoringAction) {\n const view = workspace.read()\n if (loading || error || !view.context || view.revision === null) throw Error('먼저 모델을 정상적으로 열어 주세요.')\n return workspace.previewCommand({ context: view.context, action })\n },\n /** One authoring command — what a person means, not a graph edit — as one step of the same history. */\n command(action: FigureAuthoringAction) {\n return tracked('do', () => workspace.command({ ...writable(), action, ...consented() }))\n },\n /**\n * The first edit made inside `run` may let go of exactly these clips -- the ones a CLIPS_DROPPED refusal named and\n * the person agreed to -- on the figure and version they were named on (designer 2026-09-27). Any other edit that\n * would stop a clip is refused and asked about.\n */\n withConsent<T>(given: FigureClipConsentFor, run: () => T): T {\n consent = given\n try {\n return run()\n } finally {\n consent = undefined\n }\n },\n undo() {\n return tracked('undo', () => workspace.undo(writable()))\n },\n redo() {\n return tracked('redo', () => 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 `thumbnail.ts`).\n */\n async save({ thumbnail, type }: { thumbnail?: string; type?: string } = {}) {\n const control = writable(),\n requestEpoch = epoch\n const exported = workspace.export(control)\n /* Read with the text it goes with: an edit while saving is not what this save holds. */\n const proposalKeys = inEffect()\n saving = true\n try {\n let record: FigureProductRecord\n try {\n record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail, proposalKeys, ...(id || !type ? {} : { type }) })\n } catch (error) {\n /*\n A save that failed may still have landed: the answer lost on the way back (SAVE_UNREACHABLE), or a second\n try refused because the first did land -- its expected source is the old one (FIGURE_SOURCE_CONFLICT). Only\n those are read back; a refusal on grounds -- permission, validation -- stays a failure whatever the row\n holds. Read back, every field the save writes must be what was sent: the source, the picture, the type\n (designer 2026-09-27: a network failure alone does not say nothing was saved; nor does a matching source\n alone say it was).\n */\n const code = (error as { code?: string })?.code\n const unknown = code === 'SAVE_UNREACHABLE' || code === 'FIGURE_SOURCE_CONFLICT'\n const landed = unknown && id !== undefined && requestEpoch === epoch && store.readBack ? await store.readBack(id).catch(() => undefined) : undefined\n const held = landed ? serializeFigureAsset(parseFigureAsset(landed.source)) : undefined\n /* The picture is compared by the name the server keeps it under: the hash of its bytes (ADR-0104). */\n const holds = async (sent?: string) => sent === undefined || (!!landed && landed.thumbnailHash !== undefined && landed.thumbnailHash === (await thumbnailHashOf(sent)))\n const same = !!landed && held === exported.text && (await holds(thumbnail)) && (type === undefined || landed.type === type)\n if (same) record = landed!\n else if (\n code === 'FIGURE_SOURCE_CONFLICT' &&\n landed &&\n held !== undefined &&\n unconfirmed.has(held) &&\n /* Every field that earlier save wrote, not the source alone: nothing not compared is written over. */\n (await holds(unconfirmed.get(held)!.thumbnail))\n ) {\n /*\n The row holds a text this session sent and never heard back about -- edited further since, the new text\n is not it. The server is known to hold what was sent: this save is sent again, once, conditional on that\n server text as the expected source (designer 2026-09-27: \"the sent content is confirmed on the server\").\n */\n baseline = landed.source\n unconfirmed.clear()\n record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail, proposalKeys, ...(id || !type ? {} : { type }) })\n } else {\n if (code === 'SAVE_UNREACHABLE') unconfirmed.set(exported.text, { thumbnail })\n throw error\n }\n }\n if (requestEpoch !== epoch) return read()\n if (!record.id || (id !== undefined && record.id !== id)) throw Error('저장 응답의 Figure 대상이 다릅니다.')\n if (serializeFigureAsset(parseFigureAsset(record.source)) !== exported.text)\n throw Error('저장 응답이 보낸 모델과 다릅니다. 저장 상태를 다시 확인해 주세요.')\n /* The server has it: the next save expects it, whatever happened on screen meanwhile. */\n id = record.id\n baseline = record.source\n unconfirmed.clear()\n /*\n Edited while it was saving: what was sent is saved, the edits since are not -- they stay, and the model stays\n unsaved (the workspace refuses a stale acknowledgement). Never marked saved, never wiped.\n */\n if (workspace.read().revision === exported.revision) workspace.acknowledgeSaved(exported)\n } finally {\n if (requestEpoch === epoch) saving = false\n }\n return read()\n }\n }\n}\nexport type FigureProductSession = ReturnType<typeof createFigureProductSession>\n"]}
1
+ {"version":3,"file":"product-session.js","sourceRoot":"","sources":["../../client/modeller/product-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,eAAe,CAAA;AACrE,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAOjB,MAAM,wBAAwB,CAAA;AAE/B,2EAA2E;AAE3E;;;GAGG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,OAAe;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAChD,CAAC;AA+BD,iGAAiG;AACjG,MAAM,UAAU,0BAA0B,CAAC,KAAyB;IAClE,MAAM,SAAS,GAAG,2BAA2B,EAAE,CAAA;IAC/C,IAAI,KAAK,GAAG,CAAC,EACX,EAAsB,EACtB,QAA4B,CAAA;IAC9B,IAAI,OAAO,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,KAAyB,CAAA;IAC3B,IAAI,UAA8B,CAAA;IAClC;;;;MAIE;IACF,IAAI,IAAI,GAA8B,EAAE,EACtC,MAAM,GAA8B,EAAE,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AAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ;oBAAE,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;YAC3F,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 { thumbnailHashOf } from './thumbnail-hash.js'\nimport { revisionFromView, type FigureRevision } from './revision.js'\nimport {\n createFigureAsset,\n createFigureEditorWorkspace,\n serializeFigureAsset,\n parseFigureAsset,\n type FigureInputChange,\n type FigurePrimitiveCreation,\n type FigurePartEdit,\n type FigureAuthoringAction,\n type FigureProposalStep,\n type FigureClipConsent\n} from '@hatiolab/figure-model'\n\n/** Consent to let clips go, and the figure and version it was given on. */\n\n/**\n * A request the session refuses, with its code: a screen says it from the code (`sessionRefusalOf`), never from the\n * message, which stays for logs (ADR-0054; figure audit 2026-10-16 N6 -- an AI card put the message in its note).\n */\nfunction refusal(code: string, message: string): Error & { code: string } {\n return Object.assign(Error(message), { code })\n}\n\nexport interface FigureClipConsentFor extends FigureClipConsent {\n context: string\n revision: number\n}\n\nexport interface FigureProductRecord {\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 FigureProductStore {\n load(id: string): Promise<FigureProductRecord>\n /** Every field a save writes, as the server holds it now: to tell whether a save whose answer was lost landed. */\n readBack?(id: string): Promise<FigureProductRecord & { thumbnailHash?: string; type?: string }>\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 /** The type name a new figure is created under (the first save asks for it). Not sent for an existing one. */\n type?: string\n /** Keys of the AI proposals whose steps the source holds: the server records them with the save. */\n proposalKeys?: string[]\n }): Promise<FigureProductRecord>\n}\n\n/** Product lifecycle boundary. A late response can never change another editor's asset or ID. */\nexport function createFigureProductSession(store: FigureProductStore) {\n const workspace = createFigureEditorWorkspace()\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 /*\n The history as steps, each tagged with the AI proposal it came from (or nothing): mirrored here, since the\n workspace's history does not say where a step came from. A proposal is in the model while its step is on `done` --\n undone, it is not; undone and written past, it never comes back. What a save sends as `proposalKeys`.\n */\n let done: Array<string | undefined> = [],\n undone: Array<string | undefined> = []\n function tracked<T>(kind: 'do' | 'undo' | 'redo', run: () => T, tag?: string): T {\n const before = workspace.read().revision\n const result = run()\n if (workspace.read().revision === before) return result\n if (kind === 'do') {\n done.push(tag)\n undone = []\n } else if (kind === 'undo') undone.push(done.pop())\n else done.push(undone.pop())\n return result\n }\n const inEffect = () => [...new Set(done.filter((tag): tag is string => !!tag))]\n /*\n The creation id is read with the rest: a figure not saved yet is named by it (ADR-0061 decision 3) -- its AI\n conversation is anchored on it, and its first save inserts the row under it, so the name holds across that save.\n */\n function read() {\n return { ...workspace.read(), id, creationId, loading, saving, error }\n }\n /*\n The version on screen, one object for as long as it is the version: the workspace hands out one asset per version\n (and another once a save is acknowledged, or the figure moves on), so that object says whether the last one holds.\n */\n let shown: FigureRevision | undefined\n function revisionNow(): FigureRevision | undefined {\n const view = workspace.read()\n if (!view.context || view.revision === null) return (shown = undefined)\n const context = view.context\n if (shown?.asset !== view.asset) shown = revisionFromView(view, () => workspace.export({ context }).text)\n return shown\n }\n /* Texts sent whose save was never answered: found on the server, the server is confirmed to hold what was sent. */\n const unconfirmed = new Map<string, { thumbnail?: string }>()\n /*\n Consent to let clips go: given for one edit, on the figure and the version it was asked on. The first edit made under\n it takes it; an edit on another figure or another version is refused rather than let clips go that were never named\n for it (designer 2026-09-27).\n */\n let consent: FigureClipConsentFor | undefined\n const consented = () => {\n if (!consent) return {}\n const given = consent\n consent = undefined\n const view = workspace.read()\n if (view.context !== given.context || view.revision !== given.revision) {\n const stale = Object.assign(Error('확인한 뒤 모델이 바뀌어 적용하지 않았습니다. 다시 해 주세요.'), { code: 'CONSENT_STALE' })\n throw stale\n }\n return { dropClips: given.dropClips }\n }\n /* A model open to read: the draft is read during a save too -- the dock reads it when the person sends (audit N5). */\n function readable() {\n const view = workspace.read()\n if (loading || error || !view.context || view.revision === null) throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.')\n return { context: view.context, expectedRevision: view.revision, origin: 'ui' as const }\n }\n function writable() {\n const open = readable()\n // Serializing writes also makes create retries safe: no second create while the first is pending.\n if (saving) throw refusal('SESSION_SAVING', '저장이 끝난 뒤 편집해 주세요.')\n return open\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 done = []\n undone = []\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 /** The figure on screen at its version, for every panel and helper to read; none while nothing is open. Readable while saving. */\n revisionNow,\n /**\n * The source the server is confirmed to hold: loaded, or answered by a save. What a revert sends as `expectedSource`\n * -- the server writes over it only while it still holds this. Nothing for a figure not saved yet.\n */\n confirmedSource: () => (id ? baseline : undefined),\n startNew({ discard = false } = {}) {\n canLeave(discard)\n ++epoch\n clear()\n loading = false\n workspace.open(serializeFigureAsset(createFigureAsset('새 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: FigureInputChange[], 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 refusal('SESSION_VERSION_MISSING', 'AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.')\n return tracked('do', () =>\n workspace.apply({\n ...control,\n origin,\n context: context ?? control.context,\n expectedRevision: expectedRevision ?? control.expectedRevision,\n changes\n })\n )\n },\n /**\n * An AI proposal (ADR-0094): the modeller's commands, as one step of the history, on the version the model saw.\n * Never on the current one instead -- a person's edit in between makes the proposal stale, and it is refused.\n */\n applyProposal(steps: readonly FigureProposalStep[], expectedRevision: number, context: string, key?: string) {\n writable()\n /* Never with consent: only the person may let a clip go, and an AI proposal is not the person (designer 2026-09-27). */\n return tracked('do', () => workspace.applyProposal({ origin: 'ai', context, expectedRevision, steps }), key)\n },\n /**\n * A new figure opened for an AI proposal from another screen is created under the proposal's key (ADR-0097 §5.6\n * item 5). Only before the modeller names the figure to the AI dock: once a conversation is anchored on the creation\n * id it stays (ADR-0061 decision 3), and the save's record of the proposal keeps one proposal one figure. Only on a\n * new figure not yet touched -- one being made is the person's, and keeps its own.\n */\n createUnder(key: string) {\n if (id || workspace.read().dirty) throw refusal('SESSION_NEW_FIGURE_TOUCHED', '손대지 않은 새 모델에만 쓸 수 있습니다.')\n if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(key)) throw refusal('SESSION_PROPOSAL_KEY', '제안 식별자가 올바르지 않습니다.')\n creationId = key\n },\n /** The AI proposals whose steps are in the model now, each once. */\n proposalsInEffect: inEffect,\n /**\n * A recipe put in by the person (ADR-0095): its resolved commands, as one step of the history, on the version open\n * now. The same path as a proposal; the person is its origin.\n */\n applyRecipe(steps: readonly FigureProposalStep[]) {\n const at = writable()\n return tracked('do', () => workspace.applyProposal({ origin: 'ui', context: at.context, expectedRevision: at.expectedRevision, steps, ...consented() }))\n },\n add(part: FigurePrimitiveCreation) {\n return tracked('do', () => workspace.addPrimitive({ ...writable(), part }))\n },\n edit(edit: FigurePartEdit) {\n return tracked('do', () => workspace.editPart({ ...writable(), edit, ...consented() }))\n },\n /** What a command would do, on a copy (ADR-0097 §5.5): nothing is written, and the answer names its version. */\n previewCommand(action: FigureAuthoringAction) {\n const view = workspace.read()\n if (loading || error || !view.context || view.revision === null) throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.')\n return workspace.previewCommand({ context: view.context, action })\n },\n /** One authoring command — what a person means, not a graph edit — as one step of the same history. */\n command(action: FigureAuthoringAction) {\n return tracked('do', () => workspace.command({ ...writable(), action, ...consented() }))\n },\n /**\n * The first edit made inside `run` may let go of exactly these clips -- the ones a CLIPS_DROPPED refusal named and\n * the person agreed to -- on the figure and version they were named on (designer 2026-09-27). Any other edit that\n * would stop a clip is refused and asked about.\n */\n withConsent<T>(given: FigureClipConsentFor, run: () => T): T {\n consent = given\n try {\n return run()\n } finally {\n consent = undefined\n }\n },\n undo() {\n return tracked('undo', () => workspace.undo(writable()))\n },\n redo() {\n return tracked('redo', () => workspace.redo(writable()))\n },\n source() {\n const { context } = readable()\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 `thumbnail.ts`).\n */\n async save({ thumbnail, type }: { thumbnail?: string; type?: string } = {}) {\n const control = writable(),\n requestEpoch = epoch\n const exported = workspace.export(control)\n /* Read with the text it goes with: an edit while saving is not what this save holds. */\n const proposalKeys = inEffect()\n saving = true\n try {\n let record: FigureProductRecord\n try {\n record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail, proposalKeys, ...(id || !type ? {} : { type }) })\n } catch (error) {\n /*\n A save that failed may still have landed: the answer lost on the way back (SAVE_UNREACHABLE), or a second\n try refused because the first did land -- its expected source is the old one (FIGURE_SOURCE_CONFLICT). Only\n those are read back; a refusal on grounds -- permission, validation -- stays a failure whatever the row\n holds. Read back, every field the save writes must be what was sent: the source, the picture, the type\n (designer 2026-09-27: a network failure alone does not say nothing was saved; nor does a matching source\n alone say it was).\n */\n const code = (error as { code?: string })?.code\n const unknown = code === 'SAVE_UNREACHABLE' || code === 'FIGURE_SOURCE_CONFLICT'\n const landed = unknown && id !== undefined && requestEpoch === epoch && store.readBack ? await store.readBack(id).catch(() => undefined) : undefined\n const held = landed ? serializeFigureAsset(parseFigureAsset(landed.source)) : undefined\n /* The picture is compared by the name the server keeps it under: the hash of its bytes (ADR-0104). */\n const holds = async (sent?: string) => sent === undefined || (!!landed && landed.thumbnailHash !== undefined && landed.thumbnailHash === (await thumbnailHashOf(sent)))\n const same = !!landed && held === exported.text && (await holds(thumbnail)) && (type === undefined || landed.type === type)\n if (same) record = landed!\n else if (\n code === 'FIGURE_SOURCE_CONFLICT' &&\n landed &&\n held !== undefined &&\n unconfirmed.has(held) &&\n /* Every field that earlier save wrote, not the source alone: nothing not compared is written over. */\n (await holds(unconfirmed.get(held)!.thumbnail))\n ) {\n /*\n The row holds a text this session sent and never heard back about -- edited further since, the new text\n is not it. The server is known to hold what was sent: this save is sent again, once, conditional on that\n server text as the expected source (designer 2026-09-27: \"the sent content is confirmed on the server\").\n */\n baseline = landed.source\n unconfirmed.clear()\n record = await store.save({ id, source: exported.text, expectedSource: baseline, creationId, thumbnail, proposalKeys, ...(id || !type ? {} : { type }) })\n } else {\n if (code === 'SAVE_UNREACHABLE') unconfirmed.set(exported.text, { thumbnail })\n throw error\n }\n }\n if (requestEpoch !== epoch) return read()\n if (!record.id || (id !== undefined && record.id !== id)) throw Error('저장 응답의 Figure 대상이 다릅니다.')\n if (serializeFigureAsset(parseFigureAsset(record.source)) !== exported.text)\n throw Error('저장 응답이 보낸 모델과 다릅니다. 저장 상태를 다시 확인해 주세요.')\n /* The server has it: the next save expects it, whatever happened on screen meanwhile. */\n id = record.id\n baseline = record.source\n unconfirmed.clear()\n /*\n Edited while it was saving: what was sent is saved, the edits since are not -- they stay, and the model stays\n unsaved (the workspace refuses a stale acknowledgement). Never marked saved, never wiped.\n */\n if (workspace.read().revision === exported.revision) workspace.acknowledgeSaved(exported)\n } finally {\n if (requestEpoch === epoch) saving = false\n }\n return read()\n }\n }\n}\nexport type FigureProductSession = ReturnType<typeof createFigureProductSession>\n"]}
@@ -73,11 +73,7 @@ export declare function recipeRefusalOf(error: unknown, say: Say): string | null
73
73
  * by where they are; the editor checks them before Apply, so they rarely reach here.
74
74
  */
75
75
  export declare function slotLayoutRefusalOf(error: unknown, say: Say): string | null;
76
- /**
77
- * A refusal in the author's words when the screen has words for it, otherwise said as a refusal with its code -- never
78
- * the kernel's English on the screen (the duplicate of a row's part showed 「EDIT_TARGET: … not a repeated template」,
79
- * 2026-09-27).
80
- */
76
+ export declare function sessionRefusalOf(error: unknown, say: Say): string | null;
81
77
  export declare function editRefusalOf(error: unknown, say: Say): string;
82
78
  /**
83
79
  * A data field, a binding, a status port, a motion group or a clip's tracks refused (ADR-0051 §8, §3.2), said with the ids
@@ -234,8 +234,21 @@ function documentLimitRefusalOf(error, say) {
234
234
  * the kernel's English on the screen (the duplicate of a row's part showed 「EDIT_TARGET: … not a repeated template」,
235
235
  * 2026-09-27).
236
236
  */
237
+ /** The modeller session's own refusals (`product-session.ts`), by their code. Nothing for any other refusal. */
238
+ const SESSION_REFUSALS = {
239
+ SESSION_NOT_OPEN: 'figure.text.session-not-open',
240
+ SESSION_SAVING: 'figure.text.session-saving',
241
+ SESSION_VERSION_MISSING: 'figure.text.session-version-missing',
242
+ SESSION_NEW_FIGURE_TOUCHED: 'figure.text.session-new-figure-touched',
243
+ SESSION_PROPOSAL_KEY: 'figure.text.session-proposal-key'
244
+ };
245
+ export function sessionRefusalOf(error, say) {
246
+ const key = SESSION_REFUSALS[codeOf(error) ?? ''];
247
+ return key ? say(key, {}) : null;
248
+ }
237
249
  export function editRefusalOf(error, say) {
238
- return (sizeRangeRefusalOf(error, say) ??
250
+ return (sessionRefusalOf(error, say) ??
251
+ sizeRangeRefusalOf(error, say) ??
239
252
  inputRangeRefusalOf(error, say) ??
240
253
  repeatPitchRefusalOf(error, say) ??
241
254
  rowLimitRefusalOf(error, say) ??
@@ -1 +1 @@
1
- {"version":3,"file":"refusals.js","sourceRoot":"","sources":["../../client/modeller/refusals.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,2BAA2B,EAAkD,MAAM,wBAAwB,CAAA;AAKpH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAE,KAA8C,EAAE,IAAI,CAAA;AACxF,sEAAsE;AACtE,SAAS,SAAS,CAAmB,KAAc,EAAE,MAAS;IAC5D,MAAM,OAAO,GAAI,KAA+D,EAAE,OAAO,CAAA;IACzF,OAAO,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAE,OAAwD,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3G,CAAC;AACD,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAA;AACvF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAA;AACjG,6FAA6F;AAC7F,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,cAAc,EAAE,CAAA;AAEzE,kIAAkI;AAClI,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE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C,EAAE,CAAC,CAAC,EAAE,CAAA;IAC5I,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;IAC5H,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,8BAA8B,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACnI,OAAO,GAAG,CAAC,0BAA0B,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AAChE,CAAC","sourcesContent":["/*\n * A command figure-model refused, in the author's words with the numbers and where to put it right -- not the kernel's\n * English (user, 2026-09-24: 「what is this warning message means?」). Kept apart from the element so it is tested\n * without a browser.\n *\n * Every sentence here is made from the refusal's `code` and `details` (ADR-0127), never from its message: the kernel's\n * English is for logs and readers of the kernel, and a screen that read it went quiet whenever a sentence changed or a\n * new one came under the same code (ADR-0054). A refusal with no details the screen knows is said with its code.\n */\nimport { FIGURE_INSTANCE_SIZE_INPUTS, type FigureClipLoss, type FigureRefusalDetails } from '@hatiolab/figure-model'\n\ntype Say = (key: string, params: Record<string, string>) => string\ntype Reason = FigureRefusalDetails['reason']\n\nconst codeOf = (error: unknown) => (error as { code?: string } | null | undefined)?.code\n/** The refusal's details when they are of this reason, or nothing. */\nfunction detailsOf<R extends Reason>(error: unknown, reason: R): Extract<FigureRefusalDetails, { reason: R }> | undefined {\n const details = (error as { details?: FigureRefusalDetails } | null | undefined)?.details\n return details?.reason === reason ? (details as Extract<FigureRefusalDetails, { reason: R }>) : undefined\n}\nconst mmOf = (mm: number) => mm.toLocaleString(undefined, { maximumFractionDigits: 1 })\nconst numberOf = (value: number) => value.toLocaleString(undefined, { maximumFractionDigits: 3 })\n/** Bytes in KiB, rounded up: a figure a few bytes over its limit is not said to be at it. */\nconst kibOf = (bytes: number) => Math.ceil(bytes / 1024).toLocaleString()\n\n/** A size range the figure cannot be drawn over, or one that leaves out its own size, in words; nothing for any other refusal. */\nexport function sizeRangeRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INSTANCE_SIZE_RANGE') return null\n const reach = detailsOf(error, 'size-cannot-reach')\n if (reach)\n return say(reach.bound === 'min' ? 'figure.text.size-range-too-small' : 'figure.text.size-range-too-large', { axis: reach.axis.toUpperCase(), mm: mmOf(reach.need), part: reach.part ?? '' })\n const outside = detailsOf(error, 'size-outside-range')\n if (outside) return say('figure.text.size-range-leaves-out-size', { axis: outside.axis.toUpperCase(), at: mmOf(outside.at), min: mmOf(outside.min), max: mmOf(outside.max) })\n const zero = detailsOf(error, 'size-min-not-positive')\n if (zero) return say('figure.text.size-range-from-zero', { axis: zero.axis.toUpperCase() })\n const gone = detailsOf(error, 'size-already-gone')\n if (gone) return say('figure.text.size-range-part-gone', { axis: gone.axis.toUpperCase(), at: mmOf(gone.at) })\n return null\n}\n\n/**\n * A link refused because the size range it would leave cannot hold: measuring again cannot help (the link is not there\n * to measure), so the author is offered the same link that narrows the range to what the figure then allows.\n */\nexport function narrowingRetryOf<A extends { kind: string }>(action: A, error: unknown, say: Say): { message: string; label: string; retry: A & { narrowRange: true } } | null {\n if (action.kind !== 'link-dimension' || codeOf(error) !== 'INSTANCE_SIZE_RANGE') return null\n const reach = detailsOf(error, 'size-cannot-reach')\n if (!reach) return null\n const words = { axis: reach.axis.toUpperCase(), mm: mmOf(reach.need), part: reach.part ?? '' }\n const below = reach.bound === 'min'\n return {\n message: say(below ? 'figure.text.link-needs-smaller-range' : 'figure.text.link-needs-larger-range', words),\n label: say(below ? 'figure.button.narrow-range-from' : 'figure.button.narrow-range-to', words),\n retry: { ...action, narrowRange: true }\n }\n}\n\n/**\n * A placement refused because a part is fastened to the mounting plane by a face the new plane does not take (a bottom\n * on the floor, when the figure is to hang on a wall), said in the author's words with the parts it names.\n */\nexport function placementRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'PLACEMENT_PLANE') return null\n const misfit = detailsOf(error, 'placement-face')\n if (!misfit) return null\n return say('figure.text.placement-plane-refused', {\n parts: misfit.parts.map(p => `${p.part} (${p.face})`).join(', '),\n placement: say('figure.label.placement-' + misfit.placement, {}),\n faces: misfit.takes.join(', ')\n })\n}\n\n/** A refusal carried on in a record (an AI proposal's outcome) in figure-model's own shape: its code and details. */\nexport interface FigureRefusalRecord {\n code?: string\n details?: FigureRefusalDetails\n}\n\n/** The record of a refusal: figure-model's code and details, copied as they are. */\nexport function refusalRecordOf(error: unknown): FigureRefusalRecord {\n const { details } = (error ?? {}) as FigureRefusalRecord\n return { code: codeOf(error), ...(details ? { details } : {}) }\n}\n\n/** The clips an edit would stop, as figure-model named them (CLIPS_DROPPED) -- the person is asked before any go; nothing for any other refusal. */\nexport function clipLossOf(error: unknown): FigureClipLoss[] | null {\n return codeOf(error) === 'CLIPS_DROPPED' ? (detailsOf(error, 'clips-dropped')?.clips ?? []) : null\n}\n\n/** A part refused because the declared room reads it -- the one refusal deleting it with the room refitted answers. */\nexport function inDeclaredRoom(error: unknown): boolean {\n return codeOf(error) === 'PART_REFERENCED' && !!detailsOf(error, 'in-declared-space')\n}\n\n/**\n * Why a part cannot be deleted, in the author's words. Since the chief architect's ruling of 2026-09-27 a part that\n * holds others, leads a motion or is followed goes, and what depended on it is let go of (`removalNoticeOf`); what is\n * left is the declared space (with a way on: fit it again) and a row -- one laid along the part, or hanging in its row.\n */\nexport function partRefusalOf(error: unknown, part: string, say: Say): string | null {\n const code = codeOf(error)\n if (code !== 'PART_REFERENCED' && code !== 'PART_ROW') return null\n if (detailsOf(error, 'in-declared-space')) return say('figure.text.part-in-declared-space', { part })\n const along = detailsOf(error, 'row-along')\n if (along) return say('figure.text.part-row-along', { part, rows: along.rows.join(', ') })\n const carried = detailsOf(error, 'hangs-in-row')\n if (carried) return say('figure.text.part-row-carries', { part, others: carried.parts.join(', ') })\n return say('figure.text.part-is-referenced', { part })\n}\n\n/** A part the gizmo cannot move because a joint or a fastening places it, named as the author knows it (`part`). */\nexport function placedRefusalOf(error: unknown, part: string, say: Say): string | null {\n if (codeOf(error) !== 'EDIT_TARGET') return null\n if (detailsOf(error, 'placed-by-joint')) return say('figure.text.gizmo-joint-places', { part })\n if (detailsOf(error, 'placed-by-fastening')) return say('figure.text.gizmo-fastening-places', { part })\n return null\n}\n\n/** A part name refused: not a name, already used, or another part is named under the part. The rule is the kernel's. */\nexport function partNameRefusalOf(error: unknown, say: Say): string | null {\n /* A new part named as one already is: the same sentence as a part renamed so. */\n const takenId = detailsOf(error, 'part-id-taken')\n if (takenId) return say('figure.text.part-name-taken', { name: takenId.part })\n if (codeOf(error) !== 'PART_ID') return null\n const invalid = detailsOf(error, 'name-invalid')\n if (invalid) return say('figure.text.part-name-invalid', { name: invalid.name })\n const taken = detailsOf(error, 'name-taken')\n if (taken) return say('figure.text.part-name-taken', { name: taken.name })\n const nested = detailsOf(error, 'name-has-nested')\n if (nested) return say('figure.text.part-name-has-nested', { nested: nested.nested })\n return null\n}\n\n/** What removing a part let go of (figure-model's `RemovalNotice`), said in one line, or nothing when it let go of nothing. */\nexport function removalNoticeOf(\n notice:\n | {\n released: Array<{ part: string; control?: string }>\n fixed: Array<{ part: string }>\n controls: Array<{ part: string; control: string; min: number; max: number }>\n mountingFace?: boolean\n bindings?: Array<{ id: string; label?: string }>\n }\n | undefined,\n say: Say\n): string | null {\n if (!notice) return null\n const lines: string[] = []\n const still = notice.released.filter(r => !r.control).map(r => r.part)\n if (still.length) lines.push(say('figure.text.removal-released', { parts: still.join(', ') }))\n for (const r of notice.released.filter(r => r.control)) lines.push(say('figure.text.removal-released-motion', { part: r.part, control: r.control! }))\n for (const c of notice.controls) lines.push(say('figure.text.removal-own-control', { part: c.part, control: c.control, min: numberOf(c.min), max: numberOf(c.max) }))\n const fixed = [...new Set(notice.fixed.map(f => f.part))]\n if (fixed.length) lines.push(say('figure.text.removal-fixed', { parts: fixed.join(', ') }))\n if (notice.bindings?.length) lines.push(say('figure.text.removal-bindings', { places: notice.bindings.map(b => b.label ?? b.id).join(', ') }))\n if (notice.mountingFace) lines.push(say('figure.text.removal-mounting-face', {}))\n return lines.length ? lines.join(' ') : null\n}\n\n/**\n * A recipe refused at one of its steps: which step, and why -- the particular sentence when there is one (a size\n * range, a value's range, a placement), otherwise the kernel's code. The step is the refusal's path, `steps[2]`: the\n * contract's path grammar, not its English (ADR-0127 decision 6).\n */\nexport function recipeRefusalOf(error: unknown, say: Say): string | null {\n const step = /^steps\\[(\\d+)\\]$/.exec((error as { path?: string })?.path ?? '')\n if (!step) return null\n const why = sizeRangeRefusalOf(error, say) ?? inputRangeRefusalOf(error, say) ?? placementRefusalOf(error, say)\n return say('figure.text.recipe-step-refused', { step: String(Number(step[1]) + 1), why: why ?? '', code: codeOf(error) ?? '' })\n}\n\n/**\n * A corner or an inside the part cannot take (ADR-0100 stage 1): what was too large or too thick, or what holds on\n * to what the edit would take away.\n */\nfunction sectionRefusalOf(error: unknown, say: Say): string | null {\n const mapping = detailsOf(error, 'faces-taken-away')\n if (mapping) return say('figure.text.section-face-in-use', { faces: mapping.lost.map(l => say('figure.label.face-' + l.face, {})).join(', ') })\n if (codeOf(error) === 'DIMENSION_LINKED') return say('figure.text.section-dimension-linked', {})\n if (detailsOf(error, 'section-invalid')?.issues.some(i => i.code === 'CORNER_TOO_LARGE')) return say('figure.text.section-corner-too-large', {})\n const inside = detailsOf(error, 'inside-invalid')?.refusal\n if (inside?.code === 'CAVITY' && inside.refused === 'NO_ROOM_INSIDE') return say('figure.text.section-wall-too-thick', {})\n if (inside?.code === 'CAVITY_NO_LENGTH') return say('figure.text.section-ends-too-thick', {})\n return null\n}\n\n/**\n * A slot layout refused (ADR-0118): the anchor, slot or value it was refused for. The layout's own findings are named\n * by where they are; the editor checks them before Apply, so they rarely reach here.\n */\nexport function slotLayoutRefusalOf(error: unknown, say: Say): string | null {\n if (detailsOf(error, 'slot-layout-label-missing')) return say('figure.text.slot-layout-label-missing', {})\n if (detailsOf(error, 'slot-anchors-missing')) return say('figure.text.slot-anchors-missing', {})\n const twice = detailsOf(error, 'slot-anchor-duplicate')\n if (twice) return say('figure.text.slot-anchor-duplicate', { anchor: twice.anchor })\n const flat = detailsOf(error, 'slot-anchor-not-flat')\n if (flat) return say('figure.text.slot-anchor-not-flat', { anchor: flat.anchor, part: flat.part })\n const gone = detailsOf(error, 'slot-anchor-no-part')\n if (gone) return say('figure.text.slot-anchor-no-part', { anchor: gone.anchor, part: gone.part })\n const issues = detailsOf(error, 'slot-layout-issues')\n if (issues) return say('figure.text.slot-layout-issues', { path: issues.issues[0]?.path ?? '' })\n const empty = detailsOf(error, 'slot-accepts-empty')\n if (empty) return say('figure.text.slot-accepts-empty', { slot: empty.slot })\n const taken = detailsOf(error, 'slot-id-taken')\n if (taken) return say('figure.text.slot-id-taken', { slot: taken.slot })\n return null\n}\n\n/** The figure's limits: its nodes, its size saved, how deep it nests. */\nfunction documentLimitRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'DOCUMENT_LIMIT') return null\n const nodes = detailsOf(error, 'node-limit')\n if (nodes) return say('figure.text.edit-refused-node-limit', { max: String(nodes.max) })\n const large = detailsOf(error, 'document-too-large')\n if (large)\n return large.at === undefined\n ? say('figure.text.document-too-large-unmeasured', { max: kibOf(large.max) })\n : say('figure.text.document-too-large', { max: kibOf(large.max), at: kibOf(large.at) })\n const deep = detailsOf(error, 'nesting-too-deep')\n if (deep) return say('figure.text.document-nesting-too-deep', { max: String(deep.max), at: String(deep.at) })\n return null\n}\n\n/**\n * A refusal in the author's words when the screen has words for it, otherwise said as a refusal with its code -- never\n * the kernel's English on the screen (the duplicate of a row's part showed 「EDIT_TARGET: … not a repeated template」,\n * 2026-09-27).\n */\nexport function editRefusalOf(error: unknown, say: Say): string {\n return (\n sizeRangeRefusalOf(error, say) ??\n inputRangeRefusalOf(error, say) ??\n repeatPitchRefusalOf(error, say) ??\n rowLimitRefusalOf(error, say) ??\n placementRefusalOf(error, say) ??\n partNameRefusalOf(error, say) ??\n documentLimitRefusalOf(error, say) ??\n sectionRefusalOf(error, say) ??\n slotLayoutRefusalOf(error, say) ??\n dataMotionRefusalOf(error, say) ??\n say('figure.text.edit-refused', { code: codeOf(error) ?? '' })\n )\n}\n\n/**\n * A data field, a binding, a status port, a motion group or a clip's tracks refused (ADR-0051 §8, §3.2), said with the ids\n * and numbers the kernel gave. Nothing for any other refusal.\n */\nexport function dataMotionRefusalOf(error: unknown, say: Say): string | null {\n const invalidId = detailsOf(error, 'data-id-invalid')\n if (invalidId) return say('figure.text.data-id-invalid', { id: invalidId.id })\n const twice = detailsOf(error, 'data-id-duplicate')\n if (twice) return say('figure.text.data-id-duplicate', { id: twice.id })\n const field = detailsOf(error, 'data-field-invalid')\n if (field) return say('figure.text.data-field-invalid-' + field.what, {})\n const fieldTwice = detailsOf(error, 'data-field-duplicate')\n if (fieldTwice) return say('figure.text.data-field-duplicate', { name: fieldTwice.name })\n const accessor = detailsOf(error, 'data-accessor-invalid')\n if (accessor) return say('figure.text.data-accessor-invalid-' + accessor.why, { accessor: accessor.accessor })\n const behavior = detailsOf(error, 'data-behavior-absent')\n if (behavior) return say('figure.text.data-behavior-absent-' + behavior.behavior, { id: behavior.id })\n const writers = detailsOf(error, 'data-behavior-duplicate')\n if (writers) return say('figure.text.data-behavior-duplicate', { a: writers.bindings[0], b: writers.bindings[1], id: writers.id })\n const domain = detailsOf(error, 'data-rule-domain')\n if (domain)\n return say('figure.text.data-rule-' + domain.why, {\n from: domain.from ?? '',\n to: domain.to ?? '',\n min: domain.min === undefined ? '' : numberOf(domain.min),\n max: domain.max === undefined ? '' : numberOf(domain.max),\n low: domain.within ? numberOf(domain.within[0]) : '',\n high: domain.within ? numberOf(domain.within[1]) : '',\n value: domain.value === undefined ? '' : String(domain.value)\n })\n const port = detailsOf(error, 'data-port-invalid')\n if (port) return say('figure.text.data-port-invalid-' + port.what, { port: port.port, id: port.id ?? '' })\n const bound = detailsOf(error, 'data-port-bound')\n if (bound) return say('figure.text.data-port-bound', { port: bound.port, bindings: bound.bindings.join(', ') })\n const clipAbsent = detailsOf(error, 'motion-clip-absent')\n if (clipAbsent) return say('figure.text.motion-clip-absent', { clip: clipAbsent.clip, group: clipAbsent.group })\n const shared = detailsOf(error, 'motion-clip-shared')\n if (shared) return say('figure.text.motion-clip-shared', { clip: shared.clip, group: shared.groups[0] })\n const many = detailsOf(error, 'driver-writers')\n if (many) return say('figure.text.driver-writers', { state: many.state, clips: many.clips.join(', ') })\n const which = detailsOf(error, 'driver-clip-required')\n if (which) return say('figure.text.driver-clip-required', { state: which.state, clips: which.clips.join(', ') })\n const setting = detailsOf(error, 'motion-setting')\n if (setting) return say('figure.text.motion-setting-' + setting.why, { group: setting.group, clip: setting.clip ?? '' })\n const key = codeOf(error) === 'MOTION_GROUP' ? detailsOf(error, 'value-outside-range') : undefined\n if (key) return say('figure.text.motion-key-outside-range', { input: key.input, value: numberOf(key.value), min: numberOf(key.min), max: numberOf(key.max) })\n return null\n}\n\n/**\n * A value outside the range its input declares, with the range and the value given. The figure's own size is named by\n * its axis; any other input by its range only.\n */\nexport function inputRangeRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INPUT_RANGE') return null\n const range = detailsOf(error, 'value-outside-range')\n if (!range) return null\n const axis = (Object.entries(FIGURE_INSTANCE_SIZE_INPUTS) as Array<[string, string]>).find(([, id]) => id === range.input)?.[0]\n const params = { value: numberOf(range.value), min: numberOf(range.min), max: numberOf(range.max) }\n return axis ? say('figure.text.input-range-size', { ...params, axis: axis.toUpperCase() }) : say('figure.text.input-range', params)\n}\n\n/**\n * A row past its limits: a pitch so fine it would hold more copies than a row takes, a row that would expand to more\n * bodies than a figure draws, a number of copies outside what a row may have or more than its length holds apart, a\n * row inside a row along the same axis, or a part whose face something holds made into a row.\n */\nexport function rowLimitRefusalOf(error: unknown, say: Say): string | null {\n const copies = detailsOf(error, 'copies-over-limit')\n if (copies) return say('figure.text.row-copies-over-limit', { count: copies.count.toLocaleString(), limit: copies.limit.toLocaleString() })\n const bodies = detailsOf(error, 'geometry-over-limit')\n if (bodies) return say('figure.text.row-geometry-over-limit', { count: bodies.count.toLocaleString(), limit: bodies.limit.toLocaleString() })\n const count = detailsOf(error, 'row-copies-out-of-range')\n if (count) return say('figure.text.row-copies-out-of-range', { count: count.count.toLocaleString(), min: String(count.min), max: String(count.max) })\n const fit = detailsOf(error, 'row-does-not-fit')\n if (fit) return say('figure.text.row-does-not-fit', { count: fit.count.toLocaleString(), length: mmOf(fit.length), extent: mmOf(fit.extent) })\n const axis = detailsOf(error, 'row-same-axis')\n if (axis) return say('figure.text.row-same-axis', { part: axis.part, outer: axis.outer, axis: axis.axis.toUpperCase() })\n const held = detailsOf(error, 'surface-on-row')\n if (held) return say(`figure.text.row-face-held-${heldByOf(held.at)}`, { part: held.part })\n return null\n}\n\n/* What holds a face, from the contract path the kernel names it by: the slot layout, a place, the footprint. */\nconst heldByOf = (at: string) => (at.startsWith('slotLayout') ? 'slot-layout' : at.startsWith('bindings') ? 'place' : at.startsWith('occupancy') ? 'footprint' : 'other')\n\n/** A row's pitch under which the figure, at the length it is authored, would hold more copies than a row takes. */\nexport function repeatPitchRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INPUT_RANGE') return null\n const pitch = detailsOf(error, 'pitch-too-many-copies')\n if (!pitch) return null\n return say('figure.text.repeat-pitch-too-small', { length: pitch.length.toLocaleString(), min: String(pitch.least), limit: String(pitch.limit) })\n}\n\n/**\n * Why \"follow the size and keep where the figure is placed\" was not applied, in the author's words (ADR-0097): the plan\n * says what it would have had to overwrite, and for a part through the plane how far. A code the screen has no words\n * for is said as a refusal with its code, never in the kernel's English.\n */\nexport function resizeRefusalOf(plan: { mode: string; refusal?: { code: string; axis?: string; mm?: number } }, part: string, say: Say): string {\n const refusal = plan.refusal\n if (!refusal) return ''\n const place = say(`figure.label.resize-place-${plan.mode}`, {})\n const params = { part, place, axis: (refusal.axis ?? '').toUpperCase(), mm: refusal.mm === undefined ? '' : String(Math.round(refusal.mm)) }\n const known = ['HELD', 'TURNED', 'UNIFORM_POLICY', 'SHAPE_EDIT', 'DIMENSION_RULE', 'POSITION_RULE', 'GAP_CHOICE', 'NO_FACE']\n if (known.includes(refusal.code)) return say(`figure.text.resize-refused-${refusal.code.toLowerCase().replace(/_/g, '-')}`, params)\n return say('figure.text.edit-refused', { code: refusal.code })\n}\n"]}
1
+ {"version":3,"file":"refusals.js","sourceRoot":"","sources":["../../client/modeller/refusals.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,2BAA2B,EAAkD,MAAM,wBAAwB,CAAA;AAKpH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAE,KAA8C,EAAE,IAAI,CAAA;AACxF,sEAAsE;AACtE,SAAS,SAAS,CAAmB,KAAc,EAAE,MAAS;IAC5D,MAAM,OAAO,GAAI,KAA+D,EAAE,OAAO,CAAA;IACzF,OAAO,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAE,OAAwD,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3G,CAAC;AACD,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAA;AACvF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAA;AACjG,6FAA6F;AAC7F,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,cAAc,EAAE,CAAA;AAEzE,kIAAkI;AAClI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AAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAA8E,EAAE,IAAY,EAAE,GAAQ;IACpI,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;IAC5B,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;IACvB,MAAM,KAAK,GAAG,GAAG,CAAC,6BAA6B,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/D,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;IAC5I,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;IAC5H,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,8BAA8B,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACnI,OAAO,GAAG,CAAC,0BAA0B,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AAChE,CAAC","sourcesContent":["/*\n * A command figure-model refused, in the author's words with the numbers and where to put it right -- not the kernel's\n * English (user, 2026-09-24: 「what is this warning message means?」). Kept apart from the element so it is tested\n * without a browser.\n *\n * Every sentence here is made from the refusal's `code` and `details` (ADR-0127), never from its message: the kernel's\n * English is for logs and readers of the kernel, and a screen that read it went quiet whenever a sentence changed or a\n * new one came under the same code (ADR-0054). A refusal with no details the screen knows is said with its code.\n */\nimport { FIGURE_INSTANCE_SIZE_INPUTS, type FigureClipLoss, type FigureRefusalDetails } from '@hatiolab/figure-model'\n\ntype Say = (key: string, params: Record<string, string>) => string\ntype Reason = FigureRefusalDetails['reason']\n\nconst codeOf = (error: unknown) => (error as { code?: string } | null | undefined)?.code\n/** The refusal's details when they are of this reason, or nothing. */\nfunction detailsOf<R extends Reason>(error: unknown, reason: R): Extract<FigureRefusalDetails, { reason: R }> | undefined {\n const details = (error as { details?: FigureRefusalDetails } | null | undefined)?.details\n return details?.reason === reason ? (details as Extract<FigureRefusalDetails, { reason: R }>) : undefined\n}\nconst mmOf = (mm: number) => mm.toLocaleString(undefined, { maximumFractionDigits: 1 })\nconst numberOf = (value: number) => value.toLocaleString(undefined, { maximumFractionDigits: 3 })\n/** Bytes in KiB, rounded up: a figure a few bytes over its limit is not said to be at it. */\nconst kibOf = (bytes: number) => Math.ceil(bytes / 1024).toLocaleString()\n\n/** A size range the figure cannot be drawn over, or one that leaves out its own size, in words; nothing for any other refusal. */\nexport function sizeRangeRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INSTANCE_SIZE_RANGE') return null\n const reach = detailsOf(error, 'size-cannot-reach')\n if (reach)\n return say(reach.bound === 'min' ? 'figure.text.size-range-too-small' : 'figure.text.size-range-too-large', { axis: reach.axis.toUpperCase(), mm: mmOf(reach.need), part: reach.part ?? '' })\n const outside = detailsOf(error, 'size-outside-range')\n if (outside) return say('figure.text.size-range-leaves-out-size', { axis: outside.axis.toUpperCase(), at: mmOf(outside.at), min: mmOf(outside.min), max: mmOf(outside.max) })\n const zero = detailsOf(error, 'size-min-not-positive')\n if (zero) return say('figure.text.size-range-from-zero', { axis: zero.axis.toUpperCase() })\n const gone = detailsOf(error, 'size-already-gone')\n if (gone) return say('figure.text.size-range-part-gone', { axis: gone.axis.toUpperCase(), at: mmOf(gone.at) })\n return null\n}\n\n/**\n * A link refused because the size range it would leave cannot hold: measuring again cannot help (the link is not there\n * to measure), so the author is offered the same link that narrows the range to what the figure then allows.\n */\nexport function narrowingRetryOf<A extends { kind: string }>(action: A, error: unknown, say: Say): { message: string; label: string; retry: A & { narrowRange: true } } | null {\n if (action.kind !== 'link-dimension' || codeOf(error) !== 'INSTANCE_SIZE_RANGE') return null\n const reach = detailsOf(error, 'size-cannot-reach')\n if (!reach) return null\n const words = { axis: reach.axis.toUpperCase(), mm: mmOf(reach.need), part: reach.part ?? '' }\n const below = reach.bound === 'min'\n return {\n message: say(below ? 'figure.text.link-needs-smaller-range' : 'figure.text.link-needs-larger-range', words),\n label: say(below ? 'figure.button.narrow-range-from' : 'figure.button.narrow-range-to', words),\n retry: { ...action, narrowRange: true }\n }\n}\n\n/**\n * A placement refused because a part is fastened to the mounting plane by a face the new plane does not take (a bottom\n * on the floor, when the figure is to hang on a wall), said in the author's words with the parts it names.\n */\nexport function placementRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'PLACEMENT_PLANE') return null\n const misfit = detailsOf(error, 'placement-face')\n if (!misfit) return null\n return say('figure.text.placement-plane-refused', {\n parts: misfit.parts.map(p => `${p.part} (${p.face})`).join(', '),\n placement: say('figure.label.placement-' + misfit.placement, {}),\n faces: misfit.takes.join(', ')\n })\n}\n\n/** A refusal carried on in a record (an AI proposal's outcome) in figure-model's own shape: its code and details. */\nexport interface FigureRefusalRecord {\n code?: string\n details?: FigureRefusalDetails\n}\n\n/** The record of a refusal: figure-model's code and details, copied as they are. */\nexport function refusalRecordOf(error: unknown): FigureRefusalRecord {\n const { details } = (error ?? {}) as FigureRefusalRecord\n return { code: codeOf(error), ...(details ? { details } : {}) }\n}\n\n/** The clips an edit would stop, as figure-model named them (CLIPS_DROPPED) -- the person is asked before any go; nothing for any other refusal. */\nexport function clipLossOf(error: unknown): FigureClipLoss[] | null {\n return codeOf(error) === 'CLIPS_DROPPED' ? (detailsOf(error, 'clips-dropped')?.clips ?? []) : null\n}\n\n/** A part refused because the declared room reads it -- the one refusal deleting it with the room refitted answers. */\nexport function inDeclaredRoom(error: unknown): boolean {\n return codeOf(error) === 'PART_REFERENCED' && !!detailsOf(error, 'in-declared-space')\n}\n\n/**\n * Why a part cannot be deleted, in the author's words. Since the chief architect's ruling of 2026-09-27 a part that\n * holds others, leads a motion or is followed goes, and what depended on it is let go of (`removalNoticeOf`); what is\n * left is the declared space (with a way on: fit it again) and a row -- one laid along the part, or hanging in its row.\n */\nexport function partRefusalOf(error: unknown, part: string, say: Say): string | null {\n const code = codeOf(error)\n if (code !== 'PART_REFERENCED' && code !== 'PART_ROW') return null\n if (detailsOf(error, 'in-declared-space')) return say('figure.text.part-in-declared-space', { part })\n const along = detailsOf(error, 'row-along')\n if (along) return say('figure.text.part-row-along', { part, rows: along.rows.join(', ') })\n const carried = detailsOf(error, 'hangs-in-row')\n if (carried) return say('figure.text.part-row-carries', { part, others: carried.parts.join(', ') })\n return say('figure.text.part-is-referenced', { part })\n}\n\n/** A part the gizmo cannot move because a joint or a fastening places it, named as the author knows it (`part`). */\nexport function placedRefusalOf(error: unknown, part: string, say: Say): string | null {\n if (codeOf(error) !== 'EDIT_TARGET') return null\n if (detailsOf(error, 'placed-by-joint')) return say('figure.text.gizmo-joint-places', { part })\n if (detailsOf(error, 'placed-by-fastening')) return say('figure.text.gizmo-fastening-places', { part })\n return null\n}\n\n/** A part name refused: not a name, already used, or another part is named under the part. The rule is the kernel's. */\nexport function partNameRefusalOf(error: unknown, say: Say): string | null {\n /* A new part named as one already is: the same sentence as a part renamed so. */\n const takenId = detailsOf(error, 'part-id-taken')\n if (takenId) return say('figure.text.part-name-taken', { name: takenId.part })\n if (codeOf(error) !== 'PART_ID') return null\n const invalid = detailsOf(error, 'name-invalid')\n if (invalid) return say('figure.text.part-name-invalid', { name: invalid.name })\n const taken = detailsOf(error, 'name-taken')\n if (taken) return say('figure.text.part-name-taken', { name: taken.name })\n const nested = detailsOf(error, 'name-has-nested')\n if (nested) return say('figure.text.part-name-has-nested', { nested: nested.nested })\n return null\n}\n\n/** What removing a part let go of (figure-model's `RemovalNotice`), said in one line, or nothing when it let go of nothing. */\nexport function removalNoticeOf(\n notice:\n | {\n released: Array<{ part: string; control?: string }>\n fixed: Array<{ part: string }>\n controls: Array<{ part: string; control: string; min: number; max: number }>\n mountingFace?: boolean\n bindings?: Array<{ id: string; label?: string }>\n }\n | undefined,\n say: Say\n): string | null {\n if (!notice) return null\n const lines: string[] = []\n const still = notice.released.filter(r => !r.control).map(r => r.part)\n if (still.length) lines.push(say('figure.text.removal-released', { parts: still.join(', ') }))\n for (const r of notice.released.filter(r => r.control)) lines.push(say('figure.text.removal-released-motion', { part: r.part, control: r.control! }))\n for (const c of notice.controls) lines.push(say('figure.text.removal-own-control', { part: c.part, control: c.control, min: numberOf(c.min), max: numberOf(c.max) }))\n const fixed = [...new Set(notice.fixed.map(f => f.part))]\n if (fixed.length) lines.push(say('figure.text.removal-fixed', { parts: fixed.join(', ') }))\n if (notice.bindings?.length) lines.push(say('figure.text.removal-bindings', { places: notice.bindings.map(b => b.label ?? b.id).join(', ') }))\n if (notice.mountingFace) lines.push(say('figure.text.removal-mounting-face', {}))\n return lines.length ? lines.join(' ') : null\n}\n\n/**\n * A recipe refused at one of its steps: which step, and why -- the particular sentence when there is one (a size\n * range, a value's range, a placement), otherwise the kernel's code. The step is the refusal's path, `steps[2]`: the\n * contract's path grammar, not its English (ADR-0127 decision 6).\n */\nexport function recipeRefusalOf(error: unknown, say: Say): string | null {\n const step = /^steps\\[(\\d+)\\]$/.exec((error as { path?: string })?.path ?? '')\n if (!step) return null\n const why = sizeRangeRefusalOf(error, say) ?? inputRangeRefusalOf(error, say) ?? placementRefusalOf(error, say)\n return say('figure.text.recipe-step-refused', { step: String(Number(step[1]) + 1), why: why ?? '', code: codeOf(error) ?? '' })\n}\n\n/**\n * A corner or an inside the part cannot take (ADR-0100 stage 1): what was too large or too thick, or what holds on\n * to what the edit would take away.\n */\nfunction sectionRefusalOf(error: unknown, say: Say): string | null {\n const mapping = detailsOf(error, 'faces-taken-away')\n if (mapping) return say('figure.text.section-face-in-use', { faces: mapping.lost.map(l => say('figure.label.face-' + l.face, {})).join(', ') })\n if (codeOf(error) === 'DIMENSION_LINKED') return say('figure.text.section-dimension-linked', {})\n if (detailsOf(error, 'section-invalid')?.issues.some(i => i.code === 'CORNER_TOO_LARGE')) return say('figure.text.section-corner-too-large', {})\n const inside = detailsOf(error, 'inside-invalid')?.refusal\n if (inside?.code === 'CAVITY' && inside.refused === 'NO_ROOM_INSIDE') return say('figure.text.section-wall-too-thick', {})\n if (inside?.code === 'CAVITY_NO_LENGTH') return say('figure.text.section-ends-too-thick', {})\n return null\n}\n\n/**\n * A slot layout refused (ADR-0118): the anchor, slot or value it was refused for. The layout's own findings are named\n * by where they are; the editor checks them before Apply, so they rarely reach here.\n */\nexport function slotLayoutRefusalOf(error: unknown, say: Say): string | null {\n if (detailsOf(error, 'slot-layout-label-missing')) return say('figure.text.slot-layout-label-missing', {})\n if (detailsOf(error, 'slot-anchors-missing')) return say('figure.text.slot-anchors-missing', {})\n const twice = detailsOf(error, 'slot-anchor-duplicate')\n if (twice) return say('figure.text.slot-anchor-duplicate', { anchor: twice.anchor })\n const flat = detailsOf(error, 'slot-anchor-not-flat')\n if (flat) return say('figure.text.slot-anchor-not-flat', { anchor: flat.anchor, part: flat.part })\n const gone = detailsOf(error, 'slot-anchor-no-part')\n if (gone) return say('figure.text.slot-anchor-no-part', { anchor: gone.anchor, part: gone.part })\n const issues = detailsOf(error, 'slot-layout-issues')\n if (issues) return say('figure.text.slot-layout-issues', { path: issues.issues[0]?.path ?? '' })\n const empty = detailsOf(error, 'slot-accepts-empty')\n if (empty) return say('figure.text.slot-accepts-empty', { slot: empty.slot })\n const taken = detailsOf(error, 'slot-id-taken')\n if (taken) return say('figure.text.slot-id-taken', { slot: taken.slot })\n return null\n}\n\n/** The figure's limits: its nodes, its size saved, how deep it nests. */\nfunction documentLimitRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'DOCUMENT_LIMIT') return null\n const nodes = detailsOf(error, 'node-limit')\n if (nodes) return say('figure.text.edit-refused-node-limit', { max: String(nodes.max) })\n const large = detailsOf(error, 'document-too-large')\n if (large)\n return large.at === undefined\n ? say('figure.text.document-too-large-unmeasured', { max: kibOf(large.max) })\n : say('figure.text.document-too-large', { max: kibOf(large.max), at: kibOf(large.at) })\n const deep = detailsOf(error, 'nesting-too-deep')\n if (deep) return say('figure.text.document-nesting-too-deep', { max: String(deep.max), at: String(deep.at) })\n return null\n}\n\n/**\n * A refusal in the author's words when the screen has words for it, otherwise said as a refusal with its code -- never\n * the kernel's English on the screen (the duplicate of a row's part showed 「EDIT_TARGET: … not a repeated template」,\n * 2026-09-27).\n */\n/** The modeller session's own refusals (`product-session.ts`), by their code. Nothing for any other refusal. */\nconst SESSION_REFUSALS: Record<string, string> = {\n SESSION_NOT_OPEN: 'figure.text.session-not-open',\n SESSION_SAVING: 'figure.text.session-saving',\n SESSION_VERSION_MISSING: 'figure.text.session-version-missing',\n SESSION_NEW_FIGURE_TOUCHED: 'figure.text.session-new-figure-touched',\n SESSION_PROPOSAL_KEY: 'figure.text.session-proposal-key'\n}\nexport function sessionRefusalOf(error: unknown, say: Say): string | null {\n const key = SESSION_REFUSALS[codeOf(error) ?? '']\n return key ? say(key, {}) : null\n}\n\nexport function editRefusalOf(error: unknown, say: Say): string {\n return (\n sessionRefusalOf(error, say) ??\n sizeRangeRefusalOf(error, say) ??\n inputRangeRefusalOf(error, say) ??\n repeatPitchRefusalOf(error, say) ??\n rowLimitRefusalOf(error, say) ??\n placementRefusalOf(error, say) ??\n partNameRefusalOf(error, say) ??\n documentLimitRefusalOf(error, say) ??\n sectionRefusalOf(error, say) ??\n slotLayoutRefusalOf(error, say) ??\n dataMotionRefusalOf(error, say) ??\n say('figure.text.edit-refused', { code: codeOf(error) ?? '' })\n )\n}\n\n/**\n * A data field, a binding, a status port, a motion group or a clip's tracks refused (ADR-0051 §8, §3.2), said with the ids\n * and numbers the kernel gave. Nothing for any other refusal.\n */\nexport function dataMotionRefusalOf(error: unknown, say: Say): string | null {\n const invalidId = detailsOf(error, 'data-id-invalid')\n if (invalidId) return say('figure.text.data-id-invalid', { id: invalidId.id })\n const twice = detailsOf(error, 'data-id-duplicate')\n if (twice) return say('figure.text.data-id-duplicate', { id: twice.id })\n const field = detailsOf(error, 'data-field-invalid')\n if (field) return say('figure.text.data-field-invalid-' + field.what, {})\n const fieldTwice = detailsOf(error, 'data-field-duplicate')\n if (fieldTwice) return say('figure.text.data-field-duplicate', { name: fieldTwice.name })\n const accessor = detailsOf(error, 'data-accessor-invalid')\n if (accessor) return say('figure.text.data-accessor-invalid-' + accessor.why, { accessor: accessor.accessor })\n const behavior = detailsOf(error, 'data-behavior-absent')\n if (behavior) return say('figure.text.data-behavior-absent-' + behavior.behavior, { id: behavior.id })\n const writers = detailsOf(error, 'data-behavior-duplicate')\n if (writers) return say('figure.text.data-behavior-duplicate', { a: writers.bindings[0], b: writers.bindings[1], id: writers.id })\n const domain = detailsOf(error, 'data-rule-domain')\n if (domain)\n return say('figure.text.data-rule-' + domain.why, {\n from: domain.from ?? '',\n to: domain.to ?? '',\n min: domain.min === undefined ? '' : numberOf(domain.min),\n max: domain.max === undefined ? '' : numberOf(domain.max),\n low: domain.within ? numberOf(domain.within[0]) : '',\n high: domain.within ? numberOf(domain.within[1]) : '',\n value: domain.value === undefined ? '' : String(domain.value)\n })\n const port = detailsOf(error, 'data-port-invalid')\n if (port) return say('figure.text.data-port-invalid-' + port.what, { port: port.port, id: port.id ?? '' })\n const bound = detailsOf(error, 'data-port-bound')\n if (bound) return say('figure.text.data-port-bound', { port: bound.port, bindings: bound.bindings.join(', ') })\n const clipAbsent = detailsOf(error, 'motion-clip-absent')\n if (clipAbsent) return say('figure.text.motion-clip-absent', { clip: clipAbsent.clip, group: clipAbsent.group })\n const shared = detailsOf(error, 'motion-clip-shared')\n if (shared) return say('figure.text.motion-clip-shared', { clip: shared.clip, group: shared.groups[0] })\n const many = detailsOf(error, 'driver-writers')\n if (many) return say('figure.text.driver-writers', { state: many.state, clips: many.clips.join(', ') })\n const which = detailsOf(error, 'driver-clip-required')\n if (which) return say('figure.text.driver-clip-required', { state: which.state, clips: which.clips.join(', ') })\n const setting = detailsOf(error, 'motion-setting')\n if (setting) return say('figure.text.motion-setting-' + setting.why, { group: setting.group, clip: setting.clip ?? '' })\n const key = codeOf(error) === 'MOTION_GROUP' ? detailsOf(error, 'value-outside-range') : undefined\n if (key) return say('figure.text.motion-key-outside-range', { input: key.input, value: numberOf(key.value), min: numberOf(key.min), max: numberOf(key.max) })\n return null\n}\n\n/**\n * A value outside the range its input declares, with the range and the value given. The figure's own size is named by\n * its axis; any other input by its range only.\n */\nexport function inputRangeRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INPUT_RANGE') return null\n const range = detailsOf(error, 'value-outside-range')\n if (!range) return null\n const axis = (Object.entries(FIGURE_INSTANCE_SIZE_INPUTS) as Array<[string, string]>).find(([, id]) => id === range.input)?.[0]\n const params = { value: numberOf(range.value), min: numberOf(range.min), max: numberOf(range.max) }\n return axis ? say('figure.text.input-range-size', { ...params, axis: axis.toUpperCase() }) : say('figure.text.input-range', params)\n}\n\n/**\n * A row past its limits: a pitch so fine it would hold more copies than a row takes, a row that would expand to more\n * bodies than a figure draws, a number of copies outside what a row may have or more than its length holds apart, a\n * row inside a row along the same axis, or a part whose face something holds made into a row.\n */\nexport function rowLimitRefusalOf(error: unknown, say: Say): string | null {\n const copies = detailsOf(error, 'copies-over-limit')\n if (copies) return say('figure.text.row-copies-over-limit', { count: copies.count.toLocaleString(), limit: copies.limit.toLocaleString() })\n const bodies = detailsOf(error, 'geometry-over-limit')\n if (bodies) return say('figure.text.row-geometry-over-limit', { count: bodies.count.toLocaleString(), limit: bodies.limit.toLocaleString() })\n const count = detailsOf(error, 'row-copies-out-of-range')\n if (count) return say('figure.text.row-copies-out-of-range', { count: count.count.toLocaleString(), min: String(count.min), max: String(count.max) })\n const fit = detailsOf(error, 'row-does-not-fit')\n if (fit) return say('figure.text.row-does-not-fit', { count: fit.count.toLocaleString(), length: mmOf(fit.length), extent: mmOf(fit.extent) })\n const axis = detailsOf(error, 'row-same-axis')\n if (axis) return say('figure.text.row-same-axis', { part: axis.part, outer: axis.outer, axis: axis.axis.toUpperCase() })\n const held = detailsOf(error, 'surface-on-row')\n if (held) return say(`figure.text.row-face-held-${heldByOf(held.at)}`, { part: held.part })\n return null\n}\n\n/* What holds a face, from the contract path the kernel names it by: the slot layout, a place, the footprint. */\nconst heldByOf = (at: string) => (at.startsWith('slotLayout') ? 'slot-layout' : at.startsWith('bindings') ? 'place' : at.startsWith('occupancy') ? 'footprint' : 'other')\n\n/** A row's pitch under which the figure, at the length it is authored, would hold more copies than a row takes. */\nexport function repeatPitchRefusalOf(error: unknown, say: Say): string | null {\n if (codeOf(error) !== 'INPUT_RANGE') return null\n const pitch = detailsOf(error, 'pitch-too-many-copies')\n if (!pitch) return null\n return say('figure.text.repeat-pitch-too-small', { length: pitch.length.toLocaleString(), min: String(pitch.least), limit: String(pitch.limit) })\n}\n\n/**\n * Why \"follow the size and keep where the figure is placed\" was not applied, in the author's words (ADR-0097): the plan\n * says what it would have had to overwrite, and for a part through the plane how far. A code the screen has no words\n * for is said as a refusal with its code, never in the kernel's English.\n */\nexport function resizeRefusalOf(plan: { mode: string; refusal?: { code: string; axis?: string; mm?: number } }, part: string, say: Say): string {\n const refusal = plan.refusal\n if (!refusal) return ''\n const place = say(`figure.label.resize-place-${plan.mode}`, {})\n const params = { part, place, axis: (refusal.axis ?? '').toUpperCase(), mm: refusal.mm === undefined ? '' : String(Math.round(refusal.mm)) }\n const known = ['HELD', 'TURNED', 'UNIFORM_POLICY', 'SHAPE_EDIT', 'DIMENSION_RULE', 'POSITION_RULE', 'GAP_CHOICE', 'NO_FACE']\n if (known.includes(refusal.code)) return say(`figure.text.resize-refused-${refusal.code.toLowerCase().replace(/_/g, '-')}`, params)\n return say('figure.text.edit-refused', { code: refusal.code })\n}\n"]}
@@ -44,6 +44,17 @@ export declare function boardFor(parts: readonly FigureRenderPart[], at?: Board
44
44
  }): Board & {
45
45
  depth: number;
46
46
  };
47
+ /**
48
+ * Whether the figure's reach has changed so far since the view was last fitted that the camera should fit it again:
49
+ * more than twice, or less than half, on any axis (first 15 minutes, 2026-10-16: a 100 mm box typed to 3000 × 800 × 600
50
+ * put the camera inside it, and the author saw grey until pressing 「화면에 맞추기」). A drag that nudges a part does not
51
+ * move the camera.
52
+ */
53
+ export declare function needsRefit(fitted: (Board & {
54
+ depth: number;
55
+ }) | undefined, now: Board & {
56
+ depth: number;
57
+ }): boolean;
47
58
  /**
48
59
  * A body's placement as its fields would read it: its origin in mm and its turn in degrees (rigid@1's X·Y·Z order, as
49
60
  * `componentOf` reads it). For a field a rule sets -- a fastened part's height, a turn its joint fixes -- the screen shows
@@ -150,6 +150,17 @@ export function boardFor(parts, at = { width: 0, height: 0 }) {
150
150
  depth: Math.max(at.depth ?? 0, Math.ceil(size.y * 1.1), 200)
151
151
  };
152
152
  }
153
+ /**
154
+ * Whether the figure's reach has changed so far since the view was last fitted that the camera should fit it again:
155
+ * more than twice, or less than half, on any axis (first 15 minutes, 2026-10-16: a 100 mm box typed to 3000 × 800 × 600
156
+ * put the camera inside it, and the author saw grey until pressing 「화면에 맞추기」). A drag that nudges a part does not
157
+ * move the camera.
158
+ */
159
+ export function needsRefit(fitted, now) {
160
+ if (!fitted)
161
+ return false;
162
+ return ['width', 'height', 'depth'].some(key => now[key] > fitted[key] * 2 || now[key] < fitted[key] / 2);
163
+ }
153
164
  /**
154
165
  * A body's placement as its fields would read it: its origin in mm and its turn in degrees (rigid@1's X·Y·Z order, as
155
166
  * `componentOf` reads it). For a field a rule sets -- a fastened part's height, a turn its joint fixes -- the screen shows