@things-factory/figure-ui 10.1.271 → 10.1.273

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 (112) hide show
  1. package/client/modeller/canvas.ts +4 -2
  2. package/client/modeller/clips.ts +74 -4
  3. package/client/modeller/data-interface.ts +30 -18
  4. package/client/modeller/editor-styles.ts +17 -6
  5. package/client/modeller/editor.ts +2 -0
  6. package/client/modeller/fasten-form.ts +81 -6
  7. package/client/modeller/fasten-geometry.ts +5 -3
  8. package/client/modeller/figure-cavity-drawing.ts +1 -3
  9. package/client/modeller/figure-clips.ts +101 -8
  10. package/client/modeller/figure-data-panel.ts +384 -200
  11. package/client/modeller/figure-fasten-dialog.ts +41 -30
  12. package/client/modeller/figure-fasten-drawing.ts +24 -14
  13. package/client/modeller/figure-first-save.ts +4 -3
  14. package/client/modeller/figure-links.ts +109 -37
  15. package/client/modeller/figure-parts.ts +7 -11
  16. package/client/modeller/figure-preview.ts +299 -79
  17. package/client/modeller/figure-size-editor.ts +7 -2
  18. package/client/modeller/first-save.ts +8 -0
  19. package/client/modeller/focus-on-render.ts +4 -0
  20. package/client/modeller/pivot.ts +76 -0
  21. package/client/modeller/size-response.ts +14 -0
  22. package/client/modeller/stage-model.ts +50 -6
  23. package/dist-client/modeller/canvas.d.ts +1 -0
  24. package/dist-client/modeller/canvas.js +3 -2
  25. package/dist-client/modeller/canvas.js.map +1 -1
  26. package/dist-client/modeller/clips.d.ts +17 -3
  27. package/dist-client/modeller/clips.js +69 -4
  28. package/dist-client/modeller/clips.js.map +1 -1
  29. package/dist-client/modeller/data-interface.d.ts +11 -8
  30. package/dist-client/modeller/data-interface.js +27 -17
  31. package/dist-client/modeller/data-interface.js.map +1 -1
  32. package/dist-client/modeller/editor-styles.js +17 -6
  33. package/dist-client/modeller/editor-styles.js.map +1 -1
  34. package/dist-client/modeller/editor.js +2 -0
  35. package/dist-client/modeller/editor.js.map +1 -1
  36. package/dist-client/modeller/fasten-form.d.ts +13 -0
  37. package/dist-client/modeller/fasten-form.js +72 -7
  38. package/dist-client/modeller/fasten-form.js.map +1 -1
  39. package/dist-client/modeller/fasten-geometry.d.ts +3 -2
  40. package/dist-client/modeller/fasten-geometry.js +5 -3
  41. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  42. package/dist-client/modeller/figure-cavity-drawing.js +1 -3
  43. package/dist-client/modeller/figure-cavity-drawing.js.map +1 -1
  44. package/dist-client/modeller/figure-clips.d.ts +9 -0
  45. package/dist-client/modeller/figure-clips.js +104 -8
  46. package/dist-client/modeller/figure-clips.js.map +1 -1
  47. package/dist-client/modeller/figure-data-panel.d.ts +10 -19
  48. package/dist-client/modeller/figure-data-panel.js +382 -190
  49. package/dist-client/modeller/figure-data-panel.js.map +1 -1
  50. package/dist-client/modeller/figure-fasten-dialog.js +39 -24
  51. package/dist-client/modeller/figure-fasten-dialog.js.map +1 -1
  52. package/dist-client/modeller/figure-fasten-drawing.js +24 -14
  53. package/dist-client/modeller/figure-fasten-drawing.js.map +1 -1
  54. package/dist-client/modeller/figure-first-save.js +4 -3
  55. package/dist-client/modeller/figure-first-save.js.map +1 -1
  56. package/dist-client/modeller/figure-links.d.ts +9 -0
  57. package/dist-client/modeller/figure-links.js +120 -51
  58. package/dist-client/modeller/figure-links.js.map +1 -1
  59. package/dist-client/modeller/figure-parts.js +7 -11
  60. package/dist-client/modeller/figure-parts.js.map +1 -1
  61. package/dist-client/modeller/figure-preview.d.ts +13 -0
  62. package/dist-client/modeller/figure-preview.js +296 -80
  63. package/dist-client/modeller/figure-preview.js.map +1 -1
  64. package/dist-client/modeller/figure-size-editor.js +7 -3
  65. package/dist-client/modeller/figure-size-editor.js.map +1 -1
  66. package/dist-client/modeller/first-save.d.ts +5 -0
  67. package/dist-client/modeller/first-save.js +7 -0
  68. package/dist-client/modeller/first-save.js.map +1 -1
  69. package/dist-client/modeller/focus-on-render.d.ts +2 -0
  70. package/dist-client/modeller/focus-on-render.js +4 -0
  71. package/dist-client/modeller/focus-on-render.js.map +1 -0
  72. package/dist-client/modeller/pivot.d.ts +12 -0
  73. package/dist-client/modeller/pivot.js +59 -0
  74. package/dist-client/modeller/pivot.js.map +1 -0
  75. package/dist-client/modeller/size-response.d.ts +6 -0
  76. package/dist-client/modeller/size-response.js +14 -0
  77. package/dist-client/modeller/size-response.js.map +1 -1
  78. package/dist-client/modeller/stage-model.d.ts +17 -3
  79. package/dist-client/modeller/stage-model.js +44 -6
  80. package/dist-client/modeller/stage-model.js.map +1 -1
  81. package/dist-client/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +8 -7
  83. package/test/browser/editing-page.js +1 -1
  84. package/test/browser/editing.check.mjs +6 -5
  85. package/test/browser/links.check.mjs +30 -0
  86. package/test/browser/modeller.check.mjs +2 -2
  87. package/test/browser/parts-page.js +4 -0
  88. package/test/browser/parts.check.mjs +16 -10
  89. package/test/browser/screen-page.js +12 -1
  90. package/test/browser/screen.check.mjs +142 -11
  91. package/test/browser/section.check.mjs +21 -0
  92. package/test/browser/serve-response.mjs +5 -2
  93. package/test/browser/side-panel-sweep.check.mjs +171 -10
  94. package/test/clips.test.ts +49 -4
  95. package/test/data-motion.test.ts +39 -8
  96. package/test/fasten-form.test.ts +69 -0
  97. package/test/fasten-geometry.test.ts +13 -0
  98. package/test/first-save.test.ts +11 -1
  99. package/test/pivot.test.ts +57 -0
  100. package/test/size-response.test.ts +10 -2
  101. package/test/stage-model.test.ts +23 -1
  102. package/translations/en.json +31 -11
  103. package/translations/es.json +30 -10
  104. package/translations/ja.json +30 -10
  105. package/translations/ko.json +32 -12
  106. package/translations/ms.json +30 -10
  107. package/translations/zh.json +30 -10
  108. package/tutorial/humanoid/README.md +22 -0
  109. package/tutorial/humanoid/chapters.mjs +247 -0
  110. package/tutorial/humanoid/encode.mjs +26 -0
  111. package/tutorial/humanoid/lib.mjs +197 -0
  112. package/tutorial/humanoid/record.mjs +65 -0
@@ -1 +1 @@
1
- {"version":3,"file":"clips.js","sourceRo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,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QACzJ,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import { driverValue, figureShiftedDriverKeys } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureDriver, FigureInputChange } from '@hatiolab/figure-model'\n\n/*\n * The figure's clips: controls played by keys over time, grouped into clips that each run on one\n * clock. Kept apart from the element so the reading is tested without a browser.\n */\nexport interface ClipKey {\n seconds: number\n value: number\n}\nexport interface ClipTrack {\n state: string\n label: string\n unit: string\n min: number\n max: number\n keys: ClipKey[]\n interpolation: 'linear' | 'step' | 'smooth'\n loop: 'wrap' | 'hold'\n accumulates: boolean\n}\nexport interface Clip {\n name: string\n duration: number\n tracks: ClipTrack[]\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000\n\nexport function clipsOf(asset: FigureAsset): Clip[] {\n const inputs = new Map(asset.document.model.inputs.map(i => [i.id, i]))\n const clips = new Map<string, Clip>()\n for (const d of asset.drivers ?? []) {\n const input = inputs.get(d.state)\n const clip = clips.get(d.clip) ?? { name: d.clip, duration: d.time.duration, tracks: [] }\n clip.tracks.push({\n state: d.state,\n label: asset.stateInputs?.[d.state]?.label ?? d.state,\n unit: input?.unit ?? '',\n min: input?.min ?? 0,\n max: input?.max ?? 0,\n keys: d.keys.map(k => ({ seconds: round(k.at * d.time.duration), value: k.value })),\n interpolation: d.interpolation,\n loop: d.loop,\n accumulates: d.accumulates\n })\n clips.set(d.clip, clip)\n }\n return [...clips.values()]\n}\n\n/**\n * The controls a new track of `clip` can take (ADR-0051 §3.2): one the clip does not play yet, and that no clip plays\n * outside the clip's motion group -- `group` for a clip not made yet. A clip in no group takes only a control no clip\n * plays. Without a clip, the controls no clip plays at all.\n */\nexport function undrivenOf(asset: FigureAsset, clip = '', group?: string): string[] {\n const groupOf = new Map((asset.motionGroups ?? []).flatMap(g => g.clips.map(c => [c, g.id] as const)))\n const mine = group ?? (clip ? groupOf.get(clip) : undefined)\n const taken = (state: string) =>\n (asset.drivers ?? []).some(d => d.state === state && (d.clip === clip || mine === undefined || groupOf.get(d.clip) !== mine))\n return asset.document.model.inputs.filter(i => i.role === 'state' && !taken(i.id)).map(i => i.id)\n}\n\n/** A motion group as the panel shows it: its setting, and the clips it holds in the clips' order. */\nexport interface ClipGroup {\n id: string\n label: string\n clips: string[]\n defaultClip: string\n transitionSeconds: number\n}\n\n/** The figure's motion groups, and the clips in none -- the ones a group can take. */\nexport function clipGroupsOf(asset: FigureAsset): { groups: ClipGroup[]; free: string[] } {\n const groups = (asset.motionGroups ?? []).map(g => ({ ...g, clips: [...g.clips] }))\n const grouped = new Set(groups.flatMap(g => g.clips))\n const free = [...new Set((asset.drivers ?? []).map(d => d.clip))].filter(c => !grouped.has(c))\n return { groups, free }\n}\n\n/** A group id not yet taken: `motion`, then `motion-2`, `motion-3`, … An id is not made from a label a person types. */\nexport function freeGroupIdOf(asset: FigureAsset): string {\n const taken = new Set((asset.motionGroups ?? []).map(g => g.id))\n if (!taken.has('motion')) return 'motion'\n let n = 2\n while (taken.has(`motion-${n}`)) n++\n return `motion-${n}`\n}\n\n/** The edit that writes a group back with a change: one whole group, as the kernel takes it. */\nexport const groupEdit = (group: ClipGroup, patch: Partial<Omit<ClipGroup, 'id'>> = {}) => ({\n kind: 'set-motion-group' as const,\n group: { id: group.id, label: patch.label ?? group.label, clips: patch.clips ?? group.clips, defaultClip: patch.defaultClip ?? group.defaultClip, transitionSeconds: patch.transitionSeconds ?? group.transitionSeconds }\n})\n\n/** The pose a clip gives at a moment, as one batch of state changes -- one step of the history. */\nexport function poseAt(asset: FigureAsset, clip: string, seconds: number): FigureInputChange[] {\n const units = new Map(asset.document.model.inputs.map(i => [i.id, i.unit]))\n return (asset.drivers ?? [])\n .filter((d: FigureDriver) => d.clip === clip)\n .map(d => {\n const unit = units.get(d.state)!\n return { kind: 'set-state' as const, input: d.state, unit, value: driverValue(d, seconds, unit === 'deg' || unit === 'rad' ? unit : 'other') }\n })\n}\n\n/** A key added at a moment, replacing one already there; the keys stay in time order. */\nexport function withKey(keys: readonly ClipKey[], key: ClipKey): ClipKey[] {\n return [...keys.filter(k => k.seconds !== key.seconds), key].sort((a, b) => a.seconds - b.seconds)\n}\n\n/**\n * A key typed where it stands: its moment, its value, or both. The first key stays at 0 (a track starts there); a moment\n * outside the clip, or on another key's, is refused (null) rather than taking that key's place unseen.\n */\nexport function withKeyChanged(keys: readonly ClipKey[], index: number, patch: Partial<ClipKey>, duration: number): ClipKey[] | null {\n const was = keys[index]\n if (!was) return null\n const next = { seconds: patch.seconds ?? was.seconds, value: patch.value ?? was.value }\n if (!Number.isFinite(next.seconds) || !Number.isFinite(next.value)) return null\n if (index === 0 && next.seconds !== 0) return null\n if (next.seconds < 0 || next.seconds > duration) return null\n if (keys.some((k, i) => i !== index && k.seconds === next.seconds)) return null\n return keys.map((k, i) => (i === index ? next : k)).sort((a, b) => a.seconds - b.seconds)\n}\n\n/** A track's keys without one; a track keeps at least its two ends, as the format asks. */\nexport function withoutKey(keys: readonly ClipKey[], index: number): ClipKey[] | null {\n if (keys.length <= 2 || index === 0) return null\n return keys.filter((_, i) => i !== index)\n}\n\n/** A name no clip has, for a copy: `walk-copy`, then `walk-copy-2`, … */\nexport function freeClipNameOf(asset: FigureAsset, clip: string): string {\n const taken = new Set((asset.drivers ?? []).map(d => d.clip))\n const base = `${clip}-copy`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/** The controls a track of `clip` can be copied onto: those it plays already, and those it may take. */\nexport const copyTargetsOf = (asset: FigureAsset, clip: string): string[] => [\n ...new Set([...(asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state), ...undrivenOf(asset, clip)])\n]\n\n/**\n * Where a smooth track may be moved round its loop to, in seconds later, when `seconds` is not one of them: figure-model\n * moves a smooth track only so that its new start is one of its keys (`driver-shift-off-key`). Null when it may go there.\n */\nexport function shiftOffKeyOf(track: ClipTrack, duration: number, seconds: number): number[] | null {\n if (track.interpolation !== 'smooth' || !seconds) return null\n const D = duration\n const phase = ((seconds % D) + D) % D\n const fits = [...new Set(track.keys.map(k => round((D - k.seconds) % D)))].sort((a, b) => a - b)\n return fits.some(s => Math.abs(s - phase) < 1e-6) ? null : fits\n}\n\n/** Whether a track can be moved round its loop: one that wraps and does not add up (figure-model's rule). */\nexport const shiftable = (track: ClipTrack) => track.loop === 'wrap' && !track.accumulates\n\n/**\n * A track copied onto `target` -- itself, or another control -- played `seconds` later round its loop (robot dog\n * 2026-11-03: a leg's swing half a period after another's). One edit; a track the clip plays on `target` is replaced.\n */\nexport function copiedTrackEdit(asset: FigureAsset, clip: Clip, track: ClipTrack, target: string, seconds: number) {\n const driver = (asset.drivers ?? []).find(d => d.clip === clip.name && d.state === track.state)!\n return {\n kind: 'set-driver' as const,\n state: target,\n clip: clip.name,\n keys: seconds ? figureShiftedDriverKeys(driver, seconds) : track.keys,\n loop: track.loop,\n interpolation: track.interpolation,\n accumulates: track.accumulates\n }\n}\n\n/** The edit that writes a track back. */\nexport const trackEdit = (clip: Clip, track: ClipTrack, patch: Partial<Pick<ClipTrack, 'keys' | 'loop' | 'interpolation'>> = {}) => ({\n kind: 'set-driver' as const,\n state: track.state,\n clip: clip.name,\n keys: patch.keys ?? track.keys,\n loop: patch.loop ?? track.loop,\n interpolation: patch.interpolation ?? track.interpolation\n})\n\n/** Whether two control values are one: the figure's numbers carry float noise past a millionth. */\nconst same = (a: number, b: number) => Math.abs(a - b) < 1e-6\n\n/**\n * A new track's keys. By default it holds the pose the figure stands in now, from start to end: a track added to a pose\n * made with care does not throw it to the control's ends (review 2026-11-09). `range` is the preset that swings the\n * control over its whole range and back, so the loop closes where it began.\n */\nexport function newTrackKeys(input: { min?: number; max?: number }, current: number | undefined, duration: number, how: 'hold' | 'range' = 'hold'): ClipKey[] {\n const min = input.min ?? 0\n const max = input.max ?? min\n if (how === 'range') return [{ seconds: 0, value: min }, { seconds: round(duration / 2), value: max }, { seconds: duration, value: min }]\n const value = current ?? min\n return [{ seconds: 0, value }, { seconds: duration, value }]\n}\n\n/** What a new clip on a control joins, so that it may play it: nothing, a group already there, or a group made with the clip that plays it now. */\nexport type TrackJoin = { kind: 'free' } | { kind: 'group'; group: string; label: string } | { kind: 'new-group'; group: string; label: string; clip: string }\n\n/**\n * The edits that make a new clip `clip` with one track on `state` (ADR-0051 §3.2: only clips of one motion group play\n * one control). A control no clip plays is taken as it is. A control a group's clips play puts the new clip in that\n * group. A control one clip in no group plays makes a group of that clip and the new one -- the person adds 「열기」 to a\n * door that has 「닫기」, and the two become one group, one playing at a time, without having to design the group first.\n * All of it one step of the history.\n */\nexport function newClipEdits(asset: FigureAsset, state: string, clip: string, duration: number, keys: ClipKey[]): { edits: unknown[]; join: TrackJoin } {\n const track = { kind: 'set-driver' as const, state, clip, duration, keys }\n const writers = [...new Set((asset.drivers ?? []).filter(d => d.state === state).map(d => d.clip))]\n if (!writers.length) return { edits: [track], join: { kind: 'free' } }\n const group = (asset.motionGroups ?? []).find(g => writers.some(c => g.clips.includes(c)))\n if (group) return { edits: [{ ...track, group: group.id }], join: { kind: 'group', group: group.id, label: group.label } }\n const id = freeGroupIdOf(asset)\n const label = asset.stateInputs?.[state]?.label ?? state\n const other = writers[0]!\n return {\n edits: [{ kind: 'set-motion-group' as const, group: { id, label, clips: [other], defaultClip: other, transitionSeconds: 0.2 } }, { ...track, group: id }],\n join: { kind: 'new-group', group: id, label, clip: other }\n }\n}\n\n/**\n * 「이 자세 기억하기」: the pose the figure stands in now, kept in `clip` at `seconds` in one step (review 2026-11-09:\n * a six-axis pose was six tracks keyed one by one). A track whose value there differs gets a key; a control the clip\n * does not play yet and that moved since `base` -- the pose the clip was last shown or kept in -- gets a track that\n * starts from where it was and reaches the pose at that moment (from the start when the moment is 0). A moved control\n * another clip outside this clip's group plays is not taken; it is named in `skipped`.\n */\nexport function rememberedPoseEdits(asset: FigureAsset, clip: string, seconds: number, values: Record<string, number>, base: Record<string, number>): { edits: unknown[]; skipped: string[] } {\n const found = clipsOf(asset).find(c => c.name === clip)\n if (!found) return { edits: [], skipped: [] }\n const at = round(Math.min(Math.max(seconds, 0), found.duration))\n const there = new Map(poseAt(asset, clip, at).map(c => [c.input, c.value]))\n const edits: unknown[] = []\n for (const track of found.tracks) {\n const now = values[track.state]\n if (now === undefined || same(now, there.get(track.state) ?? now)) continue\n edits.push(trackEdit(found, track, { keys: withKey(track.keys, { seconds: at, value: now }) }))\n }\n const free = new Set(undrivenOf(asset, clip))\n const skipped: string[] = []\n const played = new Set(found.tracks.map(t => t.state))\n for (const input of asset.document.model.inputs) {\n if (input.role !== 'state' || played.has(input.id)) continue\n const now = values[input.id]\n const was = base[input.id]\n if (now === undefined || was === undefined || same(now, was)) continue\n if (!free.has(input.id)) {\n skipped.push(input.id)\n continue\n }\n const keys = at === 0 ? [{ seconds: 0, value: now }, { seconds: found.duration, value: now }] : [{ seconds: 0, value: was }, { seconds: at, value: now }]\n edits.push({ kind: 'set-driver' as const, state: input.id, clip, keys })\n }\n return { edits, skipped }\n}\n"]}
1
+ {"version":3,"file":"clips.js","sourceRoot":"","sources":["../../client/modeller/clips.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AA4B7E,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;AAExD,MAAM,UAAU,OAAO,CAAC,KAAkB;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KA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AA;QACzJ,wHAAwH;QACxH,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,QAAiB,EAAE,CAAC,CAAA;IAC5G,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import { driverValue, figureShiftedDriverKeys } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureDriver, FigureInputChange } from '@hatiolab/figure-model'\n\n/*\n * The figure's clips: controls played by keys over time, grouped into clips that each run on one\n * clock. Kept apart from the element so the reading is tested without a browser.\n */\nexport interface ClipKey {\n seconds: number\n value: number\n}\nexport interface ClipTrack {\n state: string\n label: string\n unit: string\n min: number\n max: number\n keys: ClipKey[]\n interpolation: 'linear' | 'step' | 'smooth'\n loop: 'wrap' | 'hold'\n accumulates: boolean\n}\nexport interface Clip {\n name: string\n duration: number\n tracks: ClipTrack[]\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000\n\nexport function clipsOf(asset: FigureAsset): Clip[] {\n const inputs = new Map(asset.document.model.inputs.map(i => [i.id, i]))\n const clips = new Map<string, Clip>()\n for (const d of asset.drivers ?? []) {\n const input = inputs.get(d.state)\n const clip = clips.get(d.clip) ?? { name: d.clip, duration: d.time.duration, tracks: [] }\n clip.tracks.push({\n state: d.state,\n label: asset.stateInputs?.[d.state]?.label ?? d.state,\n unit: input?.unit ?? '',\n min: input?.min ?? 0,\n max: input?.max ?? 0,\n keys: d.keys.map(k => ({ seconds: round(k.at * d.time.duration), value: k.value })),\n interpolation: d.interpolation,\n loop: d.loop,\n accumulates: d.accumulates\n })\n clips.set(d.clip, clip)\n }\n /*\n Tracks in the order the controls are listed, not the order their drivers were last written: an edit writes a\n driver anew at the end, and a track keyed jumped to the bottom of its clip (tutorial run 2026-11-12).\n */\n const order = new Map(asset.document.model.inputs.map((i, n) => [i.id, n]))\n for (const clip of clips.values()) clip.tracks.sort((a, b) => (order.get(a.state) ?? 0) - (order.get(b.state) ?? 0))\n return [...clips.values()]\n}\n\n/**\n * The controls a new track of `clip` can take (ADR-0051 §3.2): one the clip does not play yet, and that no clip plays\n * outside the clip's motion group -- `group` for a clip not made yet. A clip in no group takes only a control no clip\n * plays. Without a clip, the controls no clip plays at all.\n */\nexport function undrivenOf(asset: FigureAsset, clip = '', group?: string): string[] {\n const groupOf = new Map((asset.motionGroups ?? []).flatMap(g => g.clips.map(c => [c, g.id] as const)))\n const mine = group ?? (clip ? groupOf.get(clip) : undefined)\n const taken = (state: string) =>\n (asset.drivers ?? []).some(d => d.state === state && (d.clip === clip || mine === undefined || groupOf.get(d.clip) !== mine))\n return asset.document.model.inputs.filter(i => i.role === 'state' && !taken(i.id)).map(i => i.id)\n}\n\n/** A motion group as the panel shows it: its setting, and the clips it holds in the clips' order. */\nexport interface ClipGroup {\n id: string\n label: string\n clips: string[]\n defaultClip: string\n transitionSeconds: number\n}\n\n/** The figure's motion groups, and the clips in none -- the ones a group can take. */\nexport function clipGroupsOf(asset: FigureAsset): { groups: ClipGroup[]; free: string[] } {\n const groups = (asset.motionGroups ?? []).map(g => ({ ...g, clips: [...g.clips] }))\n const grouped = new Set(groups.flatMap(g => g.clips))\n const free = [...new Set((asset.drivers ?? []).map(d => d.clip))].filter(c => !grouped.has(c))\n return { groups, free }\n}\n\n/** A group id not yet taken: `motion`, then `motion-2`, `motion-3`, … An id is not made from a label a person types. */\nexport function freeGroupIdOf(asset: FigureAsset): string {\n const taken = new Set((asset.motionGroups ?? []).map(g => g.id))\n if (!taken.has('motion')) return 'motion'\n let n = 2\n while (taken.has(`motion-${n}`)) n++\n return `motion-${n}`\n}\n\n/** The edit that writes a group back with a change: one whole group, as the kernel takes it. */\nexport const groupEdit = (group: ClipGroup, patch: Partial<Omit<ClipGroup, 'id'>> = {}) => ({\n kind: 'set-motion-group' as const,\n group: { id: group.id, label: patch.label ?? group.label, clips: patch.clips ?? group.clips, defaultClip: patch.defaultClip ?? group.defaultClip, transitionSeconds: patch.transitionSeconds ?? group.transitionSeconds }\n})\n\n/**\n * The controls a playing clip drives in the preview, each with that clip: a clip in no group played at a speed above 0,\n * or the clip a motion group plays at a speed above 0 (its default until one is chosen).\n */\nexport function playedControlsOf(\n asset: FigureAsset,\n driving: Record<string, number>,\n moving: Record<string, { clip: string; speed: number }>\n): Map<string, string> {\n const playing = new Set(Object.entries(driving).filter(([, speed]) => speed > 0).map(([clip]) => clip))\n for (const group of asset.motionGroups ?? []) {\n const m = moving[group.id]\n if (m && m.speed > 0) playing.add(m.clip || group.defaultClip)\n }\n const played = new Map<string, string>()\n for (const d of asset.drivers ?? []) if (playing.has(d.clip) && !played.has(d.state)) played.set(d.state, d.clip)\n return played\n}\n\n/** The pose a clip gives at a moment, as one batch of state changes -- one step of the history. */\nexport function poseAt(asset: FigureAsset, clip: string, seconds: number): FigureInputChange[] {\n const units = new Map(asset.document.model.inputs.map(i => [i.id, i.unit]))\n return (asset.drivers ?? [])\n .filter((d: FigureDriver) => d.clip === clip)\n .map(d => {\n const unit = units.get(d.state)!\n return { kind: 'set-state' as const, input: d.state, unit, value: driverValue(d, seconds, unit === 'deg' || unit === 'rad' ? unit : 'other') }\n })\n}\n\n/** A key added at a moment, replacing one already there; the keys stay in time order. */\nexport function withKey(keys: readonly ClipKey[], key: ClipKey): ClipKey[] {\n return [...keys.filter(k => k.seconds !== key.seconds), key].sort((a, b) => a.seconds - b.seconds)\n}\n\n/**\n * A key typed where it stands: its moment, its value, or both. The first key stays at 0 (a track starts there); a moment\n * outside the clip, or on another key's, is refused (null) rather than taking that key's place unseen.\n */\nexport function withKeyChanged(keys: readonly ClipKey[], index: number, patch: Partial<ClipKey>, duration: number): ClipKey[] | null {\n const was = keys[index]\n if (!was) return null\n const next = { seconds: patch.seconds ?? was.seconds, value: patch.value ?? was.value }\n if (!Number.isFinite(next.seconds) || !Number.isFinite(next.value)) return null\n if (index === 0 && next.seconds !== 0) return null\n if (next.seconds < 0 || next.seconds > duration) return null\n if (keys.some((k, i) => i !== index && k.seconds === next.seconds)) return null\n return keys.map((k, i) => (i === index ? next : k)).sort((a, b) => a.seconds - b.seconds)\n}\n\n/** A track's keys without one; a track keeps at least its two ends, as the format asks. */\nexport function withoutKey(keys: readonly ClipKey[], index: number): ClipKey[] | null {\n if (keys.length <= 2 || index === 0) return null\n return keys.filter((_, i) => i !== index)\n}\n\n/** A name no clip has, for a copy: `walk-copy`, then `walk-copy-2`, … */\n/**\n * A clip copied as one step (review 2026-11-11: a walk copied into a run had to be put in a motion group first, by a\n * section further down, the button grey until then). A copy plays the same controls, so the two are one group: a clip in\n * none is put in a new one, named after it, before it is copied.\n */\nexport function copyClipEdits(asset: FigureAsset, clip: string, named = 'motion'): unknown[] {\n const copy = { kind: 'copy-clip' as const, clip, name: freeClipNameOf(asset, clip) }\n if ((asset.motionGroups ?? []).some(g => g.clips.includes(clip))) return [copy]\n /*\n The group is named for what it is, not after the first clip: the preview reads \"<group> clip · walk | run\", and a\n group named \"walk\" read as if run were a kind of walk (tutorial run 2026-11-12).\n */\n const labels = new Set((asset.motionGroups ?? []).map(g => g.label))\n let label = named\n for (let n = 2; labels.has(label); n++) label = `${named} ${n}`\n const group = { id: freeGroupIdOf(asset), label, clips: [clip], defaultClip: clip, transitionSeconds: 0.2 }\n return [{ kind: 'set-motion-group' as const, group }, copy]\n}\n\nexport function freeClipNameOf(asset: FigureAsset, clip: string): string {\n const taken = new Set((asset.drivers ?? []).map(d => d.clip))\n const base = `${clip}-copy`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/** The controls a track of `clip` can be copied onto: those it plays already, and those it may take. */\nexport const copyTargetsOf = (asset: FigureAsset, clip: string): string[] => [\n ...new Set([...(asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state), ...undrivenOf(asset, clip)])\n]\n\n/**\n * Where a smooth track may be moved round its loop to, in seconds later, when `seconds` is not one of them: figure-model\n * moves a smooth track only so that its new start is one of its keys (`driver-shift-off-key`). Null when it may go there.\n */\nexport function shiftOffKeyOf(track: ClipTrack, duration: number, seconds: number): number[] | null {\n if (track.interpolation !== 'smooth' || !seconds) return null\n const D = duration\n const phase = ((seconds % D) + D) % D\n const fits = [...new Set(track.keys.map(k => round((D - k.seconds) % D)))].sort((a, b) => a - b)\n return fits.some(s => Math.abs(s - phase) < 1e-6) ? null : fits\n}\n\n/** Whether a track can be moved round its loop: one that wraps and does not add up (figure-model's rule). */\nexport const shiftable = (track: ClipTrack) => track.loop === 'wrap' && !track.accumulates\n\n/**\n * A track copied onto `target` -- itself, or another control -- played `seconds` later round its loop (robot dog\n * 2026-11-03: a leg's swing half a period after another's). One edit; a track the clip plays on `target` is replaced.\n */\nexport function copiedTrackEdit(asset: FigureAsset, clip: Clip, track: ClipTrack, target: string, seconds: number) {\n const driver = (asset.drivers ?? []).find(d => d.clip === clip.name && d.state === track.state)!\n return {\n kind: 'set-driver' as const,\n state: target,\n clip: clip.name,\n keys: seconds ? figureShiftedDriverKeys(driver, seconds) : track.keys,\n loop: track.loop,\n interpolation: track.interpolation,\n accumulates: track.accumulates\n }\n}\n\n/** The edit that writes a track back. */\nexport const trackEdit = (clip: Clip, track: ClipTrack, patch: Partial<Pick<ClipTrack, 'keys' | 'loop' | 'interpolation'>> = {}) => ({\n kind: 'set-driver' as const,\n state: track.state,\n clip: clip.name,\n keys: patch.keys ?? track.keys,\n loop: patch.loop ?? track.loop,\n interpolation: patch.interpolation ?? track.interpolation\n})\n\n/** Whether two control values are one: the figure's numbers carry float noise past a millionth. */\nconst same = (a: number, b: number) => Math.abs(a - b) < 1e-6\n\n/**\n * A new track's keys. By default it holds the pose the figure stands in now, from start to end: a track added to a pose\n * made with care does not throw it to the control's ends (review 2026-11-09). `range` is the preset that swings the\n * control over its whole range and back, so the loop closes where it began.\n */\nexport function newTrackKeys(input: { min?: number; max?: number }, current: number | undefined, duration: number, how: 'hold' | 'range' = 'hold'): ClipKey[] {\n const min = input.min ?? 0\n const max = input.max ?? min\n if (how === 'range') return [{ seconds: 0, value: min }, { seconds: round(duration / 2), value: max }, { seconds: duration, value: min }]\n const value = current ?? min\n return [{ seconds: 0, value }, { seconds: duration, value }]\n}\n\n/** What a new clip on a control joins, so that it may play it: nothing, a group already there, or a group made with the clip that plays it now. */\nexport type TrackJoin = { kind: 'free' } | { kind: 'group'; group: string; label: string } | { kind: 'new-group'; group: string; label: string; clip: string }\n\n/**\n * The edits that make a new clip `clip` with one track on `state` (ADR-0051 §3.2: only clips of one motion group play\n * one control). A control no clip plays is taken as it is. A control a group's clips play puts the new clip in that\n * group. A control one clip in no group plays makes a group of that clip and the new one -- the person adds 「열기」 to a\n * door that has 「닫기」, and the two become one group, one playing at a time, without having to design the group first.\n * All of it one step of the history.\n */\nexport function newClipEdits(\n asset: FigureAsset,\n state: string,\n clip: string,\n duration: number,\n keys: ClipKey[],\n interpolation?: ClipTrack['interpolation']\n): { edits: unknown[]; join: TrackJoin } {\n const track = { kind: 'set-driver' as const, state, clip, duration, keys, ...(interpolation ? { interpolation } : {}) }\n const writers = [...new Set((asset.drivers ?? []).filter(d => d.state === state).map(d => d.clip))]\n if (!writers.length) return { edits: [track], join: { kind: 'free' } }\n const group = (asset.motionGroups ?? []).find(g => writers.some(c => g.clips.includes(c)))\n if (group) return { edits: [{ ...track, group: group.id }], join: { kind: 'group', group: group.id, label: group.label } }\n const id = freeGroupIdOf(asset)\n const label = asset.stateInputs?.[state]?.label ?? state\n const other = writers[0]!\n return {\n edits: [{ kind: 'set-motion-group' as const, group: { id, label, clips: [other], defaultClip: other, transitionSeconds: 0.2 } }, { ...track, group: id }],\n join: { kind: 'new-group', group: id, label, clip: other }\n }\n}\n\n/**\n * 「이 자세 기억하기」: the pose the figure stands in now, kept in `clip` at `seconds` in one step (review 2026-11-09:\n * a six-axis pose was six tracks keyed one by one). A track whose value there differs gets a key; a control the clip\n * does not play yet and that moved since `base` -- the pose the clip was last shown or kept in -- gets a track that\n * starts from where it was and reaches the pose at that moment (from the start when the moment is 0). A moved control\n * another clip outside this clip's group plays is not taken; it is named in `skipped`.\n */\nexport function rememberedPoseEdits(asset: FigureAsset, clip: string, seconds: number, values: Record<string, number>, base: Record<string, number>): { edits: unknown[]; skipped: string[] } {\n const found = clipsOf(asset).find(c => c.name === clip)\n if (!found) return { edits: [], skipped: [] }\n const at = round(Math.min(Math.max(seconds, 0), found.duration))\n const there = new Map(poseAt(asset, clip, at).map(c => [c.input, c.value]))\n const edits: unknown[] = []\n for (const track of found.tracks) {\n const now = values[track.state]\n if (now === undefined) continue\n /*\n * A wrapping track's end reads as its start (review 2026-11-11: a walk kept at its end changed nothing, and a pose\n * kept at 0 left the end key behind -- the loop jumped at its seam). So at either end the key there is compared and\n * written itself, and a loop that closed -- start and end alike -- stays closed. A loop left open on purpose (a ramp\n * that starts over) keeps its other end. A track that adds up turns on past its end and is read as before.\n */\n if (shiftable(track) && (at === 0 || at === found.duration)) {\n const keyAt = (s: number) => track.keys.find(k => k.seconds === s)?.value\n const start = keyAt(0)\n const end = keyAt(found.duration)\n const mine = at === 0 ? start : end\n if (same(now, mine ?? (there.get(track.state) ?? now))) continue\n const closed = start !== undefined && end !== undefined && same(start, end)\n const keys = withKey(track.keys, { seconds: at, value: now })\n edits.push(trackEdit(found, track, { keys: closed ? withKey(keys, { seconds: at === 0 ? found.duration : 0, value: now }) : keys }))\n continue\n }\n if (same(now, there.get(track.state) ?? now)) continue\n edits.push(trackEdit(found, track, { keys: withKey(track.keys, { seconds: at, value: now }) }))\n }\n const free = new Set(undrivenOf(asset, clip))\n const skipped: string[] = []\n const played = new Set(found.tracks.map(t => t.state))\n for (const input of asset.document.model.inputs) {\n if (input.role !== 'state' || played.has(input.id)) continue\n const now = values[input.id]\n const was = base[input.id]\n if (now === undefined || was === undefined || same(now, was)) continue\n if (!free.has(input.id)) {\n skipped.push(input.id)\n continue\n }\n const keys = at === 0 ? [{ seconds: 0, value: now }, { seconds: found.duration, value: now }] : [{ seconds: 0, value: was }, { seconds: at, value: now }]\n /* A track a kept pose starts goes from pose to pose: eased in and out of each, as a shown move is (motion contract). */\n edits.push({ kind: 'set-driver' as const, state: input.id, clip, keys, interpolation: 'smooth' as const })\n }\n return { edits, skipped }\n}\n"]}
@@ -30,8 +30,9 @@ export declare function fitsField(node: FigureDataNode, choice: BehaviorChoice):
30
30
  import { methodOf, type DataMethod } from '@things-factory/figure-viewer/dist-client/data-connection.js';
31
31
  export { methodOf, type DataMethod };
32
32
  /**
33
- * The methods a field allows (ADR-0166 2): a number as it is, scaled or by a range table; a text or true/false by a code
34
- * table, or as it is where a behavior takes it so; a list as it is (its items). A new field is made by a table.
33
+ * The methods a field allows (ADR-0166 2, amendment 1): a number as it is, scaled, by a code table (status codes sent as
34
+ * numbers, 4002) or by a range table; a text or true/false by a code table, or as it is where a behavior takes it so; a
35
+ * list as it is (its items). A new field is made by a table.
35
36
  */
36
37
  export declare function methodsOf(node: FigureDataNode | null, choices: BehaviorChoice[]): DataMethod[];
37
38
  /** The method a binding is shown by. */
@@ -45,28 +46,30 @@ export declare const domainOf: (node: FigureDataNode) => FigureDataValue[];
45
46
  */
46
47
  export declare function bindingDraftOf(asset: FigureAsset, accessor: string, node: FigureDataNode, choice: BehaviorChoice, method?: 'value' | 'scale'): FigureDataValueBinding;
47
48
  /** The first code a new code table names, and the next ones: `CODE`, `CODE2`, … */
49
+ /** A new code for a number field's code table: one past the largest taken, or 0 (ADR-0166 amendment 1). */
50
+ export declare function freeNumberCodeOf(taken: string[]): string;
48
51
  export declare function freeCodeOf(taken: string[]): string;
49
52
  /** A legend role from a binding's id: lower case letters, digits and `-`. */
50
53
  export declare const legendRoleOf: (id: string) => string;
51
54
  /**
52
55
  * A first table on a field (ADR-0166 10): a row per value of a closed field, an open field's rows typed later, one
53
- * interval over the whole of a number. A new field is made by the table (P2): a code table's a text whose values are the
54
- * table's keys, starting with one code; a range table's a number. Returns the binding and, for a new field, the schema
55
- * with it.
56
+ * interval over the whole of a number. The field is one the schema has: the data tab adds a binding in the field's row.
56
57
  */
57
58
  export declare function tableDraftOf(asset: FigureAsset, field: {
58
59
  path: string;
59
60
  node: FigureDataNode;
60
- } | {
61
- name: string;
62
61
  }, method: 'code' | 'ranges', targets: FigureDataTargets): {
63
62
  binding: FigureDataTableBinding;
64
- schema?: FigureDataField[];
65
63
  };
66
64
  /** The table with these targets: each look keeps only the columns they take. */
67
65
  export declare function tableWithTargets(b: FigureDataTableBinding, targets: FigureDataTargets): FigureDataTableBinding;
68
66
  /** The table with one look set: the whole look given, a column left out cleared. */
69
67
  export declare const tableWithLook: (b: FigureDataTableBinding, key: string, look: FigureDataTableEntry) => FigureDataTableBinding;
68
+ /**
69
+ * The table whose other values keep what it last showed, or go to the default look (an empty one): the 「그대로 둠」 of
70
+ * the 「그 밖의 값」 row (ADR-0166 amendment 1).
71
+ */
72
+ export declare const tableWithKeep: (b: FigureDataTableBinding, keep: boolean) => FigureDataTableBinding;
70
73
  /** The table's rows renamed, added or taken away, in order; `default` kept last. */
71
74
  export declare function tableWithKeys(b: FigureDataTableBinding, rows: Array<[string, FigureDataTableEntry]>): FigureDataTableBinding;
72
75
  /**
@@ -64,15 +64,16 @@ export function fitsField(node, choice) {
64
64
  import { methodOf } from '@things-factory/figure-viewer/dist-client/data-connection.js';
65
65
  export { methodOf };
66
66
  /**
67
- * The methods a field allows (ADR-0166 2): a number as it is, scaled or by a range table; a text or true/false by a code
68
- * table, or as it is where a behavior takes it so; a list as it is (its items). A new field is made by a table.
67
+ * The methods a field allows (ADR-0166 2, amendment 1): a number as it is, scaled, by a code table (status codes sent as
68
+ * numbers, 4002) or by a range table; a text or true/false by a code table, or as it is where a behavior takes it so; a
69
+ * list as it is (its items). A new field is made by a table.
69
70
  */
70
71
  export function methodsOf(node, choices) {
71
72
  if (!node)
72
73
  return ['code', 'ranges'];
73
74
  const fitting = choices.some(c => fitsField(node, c));
74
75
  if (node.kind === 'number')
75
- return [...(fitting ? ['value', 'scale'] : []), 'ranges'];
76
+ return [...(fitting ? ['value', 'scale'] : []), 'code', 'ranges'];
76
77
  if (node.kind === 'text' || node.kind === 'boolean')
77
78
  return [...(fitting ? ['value'] : []), 'code'];
78
79
  return fitting ? ['value'] : [];
@@ -140,6 +141,11 @@ export function bindingDraftOf(asset, accessor, node, choice, method) {
140
141
  }
141
142
  /* ---------------------------------------------------------------- tables (ADR-0166 3) */
142
143
  /** The first code a new code table names, and the next ones: `CODE`, `CODE2`, … */
144
+ /** A new code for a number field's code table: one past the largest taken, or 0 (ADR-0166 amendment 1). */
145
+ export function freeNumberCodeOf(taken) {
146
+ const numbers = taken.map(Number).filter(n => Number.isInteger(n) && n >= 0);
147
+ return String(numbers.length ? Math.max(...numbers) + 1 : 0);
148
+ }
143
149
  export function freeCodeOf(taken) {
144
150
  if (!taken.includes('CODE'))
145
151
  return 'CODE';
@@ -155,23 +161,20 @@ export const legendRoleOf = (id) => id
155
161
  .replace(/^-+|-+$/g, '') || 'legend';
156
162
  /**
157
163
  * A first table on a field (ADR-0166 10): a row per value of a closed field, an open field's rows typed later, one
158
- * interval over the whole of a number. A new field is made by the table (P2): a code table's a text whose values are the
159
- * table's keys, starting with one code; a range table's a number. Returns the binding and, for a new field, the schema
160
- * with it.
164
+ * interval over the whole of a number. The field is one the schema has: the data tab adds a binding in the field's row.
161
165
  */
162
166
  export function tableDraftOf(asset, field, method, targets) {
163
167
  const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id);
164
- const made = 'name' in field;
165
- const name = made ? field.name : (field.path.replace(/\[\]/g, '').split('.').pop() ?? field.path);
168
+ const name = field.path.replace(/\[\]/g, '').split('.').pop() ?? field.path;
166
169
  const id = freeIdOf(taken, name.toLowerCase());
167
- const node = made ? (method === 'code' ? { kind: 'text', values: ['CODE'] } : { kind: 'number' }) : field.node;
168
- const accessor = made ? field.name : accessorOfRow(field.path);
169
- const table = method === 'code' ? Object.fromEntries(domainOf(node).map(v => [String(v), {}])) : { [`${node.kind === 'number' ? (node.min ?? '') : ''}~`]: {} };
170
- const binding = { id, accessor, rule: 'table', lookup: method, targets: tidyTargets(targets), table };
171
- if (!made)
172
- return { binding };
173
- const schema = [...(asset.dataInterface?.schema ?? []), { name: field.name, ...node }];
174
- return { binding, schema };
170
+ const node = field.node;
171
+ const accessor = accessorOfRow(field.path);
172
+ const table = method === 'code'
173
+ ? node.kind === 'number'
174
+ ? { [freeNumberCodeOf([])]: {} }
175
+ : Object.fromEntries(domainOf(node).map(v => [String(v), {}]))
176
+ : { [`${node.kind === 'number' ? (node.min ?? '') : ''}~`]: {} };
177
+ return { binding: { id, accessor, rule: 'table', lookup: method, targets: tidyTargets(targets), table } };
175
178
  }
176
179
  /** Targets with empty lists left out, as the kernel keeps them. */
177
180
  const tidyTargets = (t) => ({
@@ -179,8 +182,10 @@ const tidyTargets = (t) => ({
179
182
  ...(t.inputs?.length ? { inputs: [...t.inputs] } : {}),
180
183
  ...(t.group ? { group: t.group } : {})
181
184
  });
182
- /** A look with only the columns its targets take: a target taken away takes its columns with it. */
185
+ /** A look with only the columns its targets take: a target taken away takes its columns with it. A look that keeps stays so. */
183
186
  function lookFor(look, t) {
187
+ if (look.keep)
188
+ return { keep: true };
184
189
  const out = {};
185
190
  if (t.parts?.length) {
186
191
  if (look.color !== undefined)
@@ -210,6 +215,11 @@ export function tableWithTargets(b, targets) {
210
215
  }
211
216
  /** The table with one look set: the whole look given, a column left out cleared. */
212
217
  export const tableWithLook = (b, key, look) => ({ ...b, table: { ...b.table, [key]: lookFor(look, b.targets) } });
218
+ /**
219
+ * The table whose other values keep what it last showed, or go to the default look (an empty one): the 「그대로 둠」 of
220
+ * the 「그 밖의 값」 row (ADR-0166 amendment 1).
221
+ */
222
+ export const tableWithKeep = (b, keep) => ({ ...b, table: { ...b.table, default: keep ? { keep: true } : {} } });
213
223
  /** The table's rows renamed, added or taken away, in order; `default` kept last. */
214
224
  export function tableWithKeys(b, rows) {
215
225
  const d = b.table.default;
@@ -1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AAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE;SAClJ,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/*\n * The figure's data and what it moves (ADR-0051 §8, ADR-0166): what the data tab offers and shows -- one binding, its\n * method as the field's kind allows (as it is, scaled, a code table, a range table). Every rule is figure-model's -- which accessor holds, which rule's results a behavior takes -- and the reading\n * of data is things-scene's; this only lists what there is to choose, drafts a binding the kernel then checks, and edits\n * the schema as a tree. Kept apart from the element so it is tested without a browser.\n */\nimport { FIGURE_PART_ID, FIGURE_MOTION_SPEED_MAX, FigureContractError, figureAxesOf, figureDataRows, motionStateIdOf, parseFigureAccessor } from '@hatiolab/figure-model'\nimport type {\n FigureAsset,\n FigureDataBehavior,\n FigureDataBinding,\n FigureDataField,\n FigureDataNode,\n FigureDataRow,\n FigureDataTableBinding,\n FigureDataTableEntry,\n FigureDataTargets,\n FigureDataValue,\n FigureDataValueBinding,\n FigureDataValueIssue,\n FigureProposalStep\n} from '@hatiolab/figure-model'\nimport { FigureInputs, type FigureDataResult, type FigureRuntimeIssue, type FigureTableUse } from '@hatiolab/things-scene'\n\n/** Something a binding can move, with what the screen shows of it. */\nexport interface BehaviorChoice {\n /** One string per behavior, for a select's value. */\n key: string\n behavior: FigureDataBehavior\n /** The screen's word for the kind: a control, a colour, a group's clip, … */\n kind: FigureDataBehavior['kind']\n /** The control's label, the colour token, the group's label, the axis. */\n name: string\n unit?: string\n min?: number\n max?: number\n /** A motion group's clips. */\n clips?: string[]\n}\n\nexport const behaviorKeyOf = (b: FigureDataBehavior): string =>\n b.kind === 'state'\n ? `state:${b.input}`\n : b.kind === 'palette'\n ? `palette:${b.token}`\n : b.kind === 'pose'\n ? `pose:${b.axis}`\n : b.kind === 'items'\n ? `items:${b.slot ?? ''}`\n : `${b.kind}:${b.group}`\n\n/**\n * Everything a value binding may drive: each control, each colour, each motion group's clip, speed and pause, its\n * position and heading, and -- when it has places -- the items in them.\n */\nexport function behaviorsOf(asset: FigureAsset): BehaviorChoice[] {\n const out: BehaviorChoice[] = []\n const add = (behavior: FigureDataBehavior, name: string, more: Partial<BehaviorChoice> = {}) => out.push({ key: behaviorKeyOf(behavior), behavior, kind: behavior.kind, name, ...more })\n for (const input of asset.document.model.inputs) {\n if (input.role !== 'state') continue\n add({ kind: 'state', input: input.id, sourceMode: 'observed' }, asset.stateInputs?.[input.id]?.label ?? input.id, { unit: input.unit, min: input.min, max: input.max })\n }\n for (const token of Object.keys(asset.palette)) add({ kind: 'palette', token }, token)\n for (const group of asset.motionGroups ?? []) {\n add({ kind: 'motion-clip', group: group.id }, group.label, { clips: [...group.clips] })\n add({ kind: 'motion-speed', group: group.id }, group.label, { min: 0, max: FIGURE_MOTION_SPEED_MAX })\n add({ kind: 'motion-paused', group: group.id }, group.label)\n }\n for (const axis of ['x', 'z', 'y', 'heading'] as const) add({ kind: 'pose', axis, seconds: 1 }, axis, { unit: axis === 'heading' ? 'deg' : 'mm' })\n if (asset.document.capabilities.slotLayout || asset.document.capabilities.names?.includes('Holdable')) add({ kind: 'items' }, asset.document.capabilities.slotLayout?.label ?? 'items')\n return out\n}\n\nconst isValue = (n: FigureDataNode): n is Extract<FigureDataNode, { kind: 'number' | 'boolean' | 'text' }> => n.kind === 'number' || n.kind === 'boolean' || n.kind === 'text'\n\n/**\n * Whether a field of this kind drives the behavior as it is or scaled -- the choices a value binding offers for it. A\n * value that picks a look per code is a table (ADR-0166 2).\n */\nexport function fitsField(node: FigureDataNode, choice: BehaviorChoice): boolean {\n if (choice.kind === 'items') return node.kind === 'list' || node.kind === 'text' || node.kind === 'number'\n if (!isValue(node)) return false\n if (choice.kind === 'motion-paused') return node.kind === 'boolean'\n if (choice.kind === 'palette') return node.kind === 'text' && !!node.values?.every(v => /^#[0-9a-f]{6}$/i.test(v))\n if (choice.kind === 'motion-clip') {\n const clips = choice.behavior.kind === 'motion-clip' ? choice.clips : undefined\n return node.kind === 'text' && !!node.values && (!clips || node.values.every(v => clips.includes(v)))\n }\n return node.kind === 'number'\n}\n\n/** How a binding turns a value into what the figure shows (ADR-0166 1): the screen's four methods, figure-viewer's words for every screen. */\nimport { methodOf, type DataMethod } from '@things-factory/figure-viewer/dist-client/data-connection.js'\nexport { methodOf, type DataMethod }\n\n/**\n * The methods a field allows (ADR-0166 2): a number as it is, scaled or by a range table; a text or true/false by a code\n * table, or as it is where a behavior takes it so; a list as it is (its items). A new field is made by a table.\n */\nexport function methodsOf(node: FigureDataNode | null, choices: BehaviorChoice[]): DataMethod[] {\n if (!node) return ['code', 'ranges']\n const fitting = choices.some(c => fitsField(node, c))\n if (node.kind === 'number') return [...(fitting ? (['value', 'scale'] as const) : []), 'ranges']\n if (node.kind === 'text' || node.kind === 'boolean') return [...(fitting ? (['value'] as const) : []), 'code']\n return fitting ? ['value'] : []\n}\n\n/** The method a binding is shown by. */\n\n/** An id not taken among `taken`: `base`, then `base-2`, `base-3`, … made into the kernel's id shape. */\nexport function freeIdOf(taken: Iterable<string>, base: string): string {\n const used = new Set(taken)\n const cleaned = base.replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/^[^a-zA-Z]+/, '').replace(/-+$/, '') || 'binding'\n const id = FIGURE_PART_ID.test(cleaned) ? cleaned : 'binding'\n if (!used.has(id)) return id\n let n = 2\n while (used.has(`${id}-${n}`)) n++\n return `${id}-${n}`\n}\n\n/** How many mm, or degrees, one of a unit is: only lengths and angles are converted. */\nconst TO_MM: Record<string, number> = { mm: 1, cm: 10, m: 1000 }\nconst TO_DEG: Record<string, number> = { deg: 1, rad: 180 / Math.PI }\n\n/** The values a closed field takes: a closed text's values, both booleans. Empty when open. */\nexport const domainOf = (node: FigureDataNode): FigureDataValue[] => (node.kind === 'boolean' ? [false, true] : node.kind === 'text' && node.values ? [...node.values] : [])\n\n/**\n * A first value binding of a field to a behavior, for the author to adjust: the value as it is when it already fits, a\n * scale when only its unit or range differs -- or the method the author chose. The kernel says whether it holds.\n */\nexport function bindingDraftOf(asset: FigureAsset, accessor: string, node: FigureDataNode, choice: BehaviorChoice, method?: 'value' | 'scale'): FigureDataValueBinding {\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const name = accessor.replace(/\\[\\d+\\]/g, '').split('.').pop() ?? accessor\n const id = freeIdOf(taken, `${name}-${choice.kind === 'state' ? (choice.behavior as { input: string }).input : choice.kind}`)\n const behavior = choice.behavior\n const make = (rule: 'value' | 'scale', param?: FigureDataValueBinding['param']): FigureDataValueBinding => ({ id, accessor, behavior, rule, ...(param ? { param } : {}) })\n\n if (behavior.kind === 'items') {\n if (node.kind !== 'list') return make('value')\n const fields = node.item.kind === 'object' ? node.item.fields : []\n const pick = (...words: RegExp[]) => fields.find(f => isValue(f) && words.some(w => w.test(f.name)))?.name\n const itemId = pick(/^id$/i, /name$/i, /id$/i) ?? fields.find(isValue)?.name\n const type = pick(/type$/i)\n const place = pick(/^slot/i, /place/i, /port/i)\n const stack = pick(/stack/i, /level/i)\n return { id, accessor, behavior: { kind: 'items', ...(itemId ? { id: itemId } : {}), ...(type ? { type } : {}), ...(place ? { place } : {}), ...(stack ? { stack } : {}) }, rule: 'value' }\n }\n if (node.kind !== 'number') return make('value')\n if (behavior.kind === 'pose') {\n const want = behavior.axis === 'heading' ? TO_DEG : TO_MM\n const unit = node.unit ?? ''\n if (method === 'value' || unit === (behavior.axis === 'heading' ? 'deg' : 'mm') || (method === undefined && !(unit in want))) return make('value')\n return make('scale', { scale: want[unit] ?? 1, offset: 0 })\n }\n /* state and motion-speed: a number into a range. */\n const [lo, hi, unit] =\n behavior.kind === 'motion-speed' ? [0, FIGURE_MOTION_SPEED_MAX, 'ratio'] : [choice.min ?? 0, choice.max ?? 1, choice.unit ?? '']\n const sameUnit = behavior.kind === 'motion-speed' ? node.unit === undefined || node.unit === 'ratio' : node.unit === unit\n const inside = node.min !== undefined && node.max !== undefined && node.min >= lo && node.max <= hi\n if (method === 'value' || (method === undefined && sameUnit && inside)) return make('value')\n if (node.min !== undefined && node.max !== undefined && node.max > node.min) {\n /* The field's range laid onto the behavior's. */\n const scale = (hi - lo) / (node.max - node.min)\n return make('scale', { scale: round(scale), offset: round(lo - scale * node.min) })\n }\n return method === 'scale' ? make('scale', { scale: 1, offset: 0 }) : make('value')\n}\n\n/* ---------------------------------------------------------------- tables (ADR-0166 3) */\n\n/** The first code a new code table names, and the next ones: `CODE`, `CODE2`, … */\nexport function freeCodeOf(taken: string[]): string {\n if (!taken.includes('CODE')) return 'CODE'\n let n = 2\n while (taken.includes(`CODE${n}`)) n++\n return `CODE${n}`\n}\n\n/** A legend role from a binding's id: lower case letters, digits and `-`. */\nexport const legendRoleOf = (id: string): string =>\n id\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'legend'\n\n/**\n * A first table on a field (ADR-0166 10): a row per value of a closed field, an open field's rows typed later, one\n * interval over the whole of a number. A new field is made by the table (P2): a code table's a text whose values are the\n * table's keys, starting with one code; a range table's a number. Returns the binding and, for a new field, the schema\n * with it.\n */\nexport function tableDraftOf(\n asset: FigureAsset,\n field: { path: string; node: FigureDataNode } | { name: string },\n method: 'code' | 'ranges',\n targets: FigureDataTargets\n): { binding: FigureDataTableBinding; schema?: FigureDataField[] } {\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const made = 'name' in field\n const name = made ? field.name : (field.path.replace(/\\[\\]/g, '').split('.').pop() ?? field.path)\n const id = freeIdOf(taken, name.toLowerCase())\n const node: FigureDataNode = made ? (method === 'code' ? { kind: 'text', values: ['CODE'] } : { kind: 'number' }) : field.node\n const accessor = made ? field.name : accessorOfRow(field.path)\n const table: Record<string, FigureDataTableEntry> =\n method === 'code' ? Object.fromEntries(domainOf(node).map(v => [String(v), {}])) : { [`${node.kind === 'number' ? (node.min ?? '') : ''}~`]: {} }\n const binding: FigureDataTableBinding = { id, accessor, rule: 'table', lookup: method, targets: tidyTargets(targets), table }\n if (!made) return { binding }\n const schema = [...(asset.dataInterface?.schema ?? []), { name: field.name, ...node } as FigureDataField]\n return { binding, schema }\n}\n\n/** Targets with empty lists left out, as the kernel keeps them. */\nconst tidyTargets = (t: FigureDataTargets): FigureDataTargets => ({\n ...(t.parts?.length ? { parts: [...t.parts] } : {}),\n ...(t.inputs?.length ? { inputs: [...t.inputs] } : {}),\n ...(t.group ? { group: t.group } : {})\n})\n\n/** A look with only the columns its targets take: a target taken away takes its columns with it. */\nfunction lookFor(look: FigureDataTableEntry, t: FigureDataTargets): FigureDataTableEntry {\n const out: FigureDataTableEntry = {}\n if (t.parts?.length) {\n if (look.color !== undefined) out.color = look.color\n if (look.effect !== undefined) out.effect = look.effect\n }\n if (t.inputs?.length && look.values) {\n const values = Object.fromEntries(Object.entries(look.values).filter(([id]) => t.inputs!.includes(id)))\n if (Object.keys(values).length) out.values = values\n }\n if (t.group) {\n if (look.clip !== undefined) out.clip = look.clip\n if (look.speed !== undefined) out.speed = look.speed\n if (look.paused !== undefined) out.paused = look.paused\n }\n return out\n}\n\n/** The table with these targets: each look keeps only the columns they take. */\nexport function tableWithTargets(b: FigureDataTableBinding, targets: FigureDataTargets): FigureDataTableBinding {\n const t = tidyTargets(targets)\n return { ...b, targets: t, table: Object.fromEntries(Object.entries(b.table).map(([k, look]) => [k, lookFor(look, t)])) }\n}\n\n/** The table with one look set: the whole look given, a column left out cleared. */\nexport const tableWithLook = (b: FigureDataTableBinding, key: string, look: FigureDataTableEntry): FigureDataTableBinding => ({ ...b, table: { ...b.table, [key]: lookFor(look, b.targets) } })\n\n/** The table's rows renamed, added or taken away, in order; `default` kept last. */\nexport function tableWithKeys(b: FigureDataTableBinding, rows: Array<[string, FigureDataTableEntry]>): FigureDataTableBinding {\n const d = b.table.default\n return { ...b, table: { ...Object.fromEntries(rows), ...(d !== undefined ? { default: d } : {}) } }\n}\n\n/**\n * The columns a table's targets give its looks, as the row editor shows them: colour and effect for parts, a value per\n * state input (its unit and range), the clip, speed and pause of the group.\n */\nexport function tableColumnsOf(asset: FigureAsset, b: FigureDataTableBinding): TableColumn[] {\n const out: TableColumn[] = []\n if (b.targets.parts?.length) out.push({ kind: 'color' }, { kind: 'effect' })\n for (const id of b.targets.inputs ?? []) {\n const input = asset.document.model.inputs.find(i => i.id === id)\n out.push({ kind: 'value', id, label: asset.stateInputs?.[id]?.label ?? id, unit: input?.unit, min: input?.min, max: input?.max })\n }\n if (b.targets.group) {\n const group = (asset.motionGroups ?? []).find(g => g.id === b.targets.group)\n out.push({ kind: 'clip', clips: group?.clips ?? [] }, { kind: 'speed' }, { kind: 'paused' })\n }\n return out\n}\nexport type TableColumn =\n | { kind: 'color' | 'effect' | 'speed' | 'paused' }\n | { kind: 'value'; id: string; label: string; unit?: string; min?: number; max?: number }\n | { kind: 'clip'; clips: string[] }\n\n/** The state inputs a table may give values to: each control, with its label. */\nexport const stateInputsOf = (asset: FigureAsset): Array<{ id: string; label: string }> =>\n asset.document.model.inputs.filter(i => i.role === 'state').map(i => ({ id: i.id, label: asset.stateInputs?.[i.id]?.label ?? i.id }))\n\n/**\n * A code table's field follows its keys (ADR-0166 risk 3): when the field is a closed text, its values are the table's\n * codes. The schema with the field so, or undefined when the field is open or already so.\n */\nexport function schemaFollowingCodes(asset: FigureAsset, b: FigureDataTableBinding, codes: string[]): FigureDataField[] | undefined {\n const schema = asset.dataInterface?.schema ?? []\n const path = b.accessor.replace(/\\[\\d+\\]/g, '[]')\n const field = fieldAt(schema, path)\n if (field?.kind !== 'text' || !field.values || !codes.length) return undefined\n if (field.values.length === codes.length && field.values.every((v, i) => v === codes[i])) return undefined\n const next = { ...field, values: [...codes] } as FigureDataField & { default?: string }\n if (next.default !== undefined && !codes.includes(next.default)) delete next.default\n return schemaWithFieldReplaced(schema, path, next)\n}\n\nconst round = (v: number) => Math.round(v * 1e6) / 1e6\n\n/* ---------------------------------------------------------------- the schema as a tree */\n\n/** A row's path (`L[].F`) as the accessor a value binding reads (`L[0].F`): the first element of each list. */\nexport const accessorOfRow = (path: string): string => path.replace(/\\[\\]/g, '[0]')\n\n/** The field at a row's path, or undefined. */\nexport function fieldAt(schema: readonly FigureDataField[], path: string): FigureDataField | undefined {\n let list: readonly FigureDataField[] = schema\n let found: FigureDataField | undefined\n for (const part of path.split('.')) {\n const name = part.replace(/\\[\\]/g, '')\n found = list.find(f => f.name === name)\n if (!found) return undefined\n let node: FigureDataNode = found\n while (node.kind === 'list') node = node.item\n list = node.kind === 'object' ? node.fields : []\n }\n return found\n}\n\n/** The fields under a row's path, where a new field goes: the top, an object's fields, a list's element's fields. */\nfunction fieldsUnder(schema: FigureDataField[], path: string): FigureDataField[] | undefined {\n if (!path) return schema\n const field = fieldAt(schema, path)\n if (!field) return undefined\n let node: FigureDataNode = field\n while (node.kind === 'list') node = node.item\n return node.kind === 'object' ? node.fields : undefined\n}\n\n/** The schema with a field added under a path ('' for the top): a copy, the given one left as it is. */\nexport function schemaWithField(schema: readonly FigureDataField[], under: string, field: FigureDataField): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n fieldsUnder(out, under)?.push(field)\n return out\n}\n\n/** The schema with the field at a path replaced (its name kept unless the new one says another). */\nexport function schemaWithFieldReplaced(schema: readonly FigureDataField[], path: string, field: FigureDataField): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : ''\n const list = fieldsUnder(out, parent)\n const name = path.split('.').pop()!.replace(/\\[\\]/g, '')\n const at = list?.findIndex(f => f.name === name) ?? -1\n if (list && at >= 0) list[at] = field\n return out\n}\n\n/** The schema without the field at a path. */\nexport function schemaWithoutField(schema: readonly FigureDataField[], path: string): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : ''\n const list = fieldsUnder(out, parent)\n const name = path.split('.').pop()!.replace(/\\[\\]/g, '')\n const at = list?.findIndex(f => f.name === name) ?? -1\n if (list && at >= 0) list.splice(at, 1)\n return out\n}\n\n/** A field of another kind, its name, label and json flag kept, the rest started fresh. */\nexport function fieldOfKind(field: FigureDataField, kind: FigureDataNode['kind']): FigureDataField {\n const head = { name: field.name, ...(field.label ? { label: field.label } : {}) }\n if (kind === 'object') return { ...head, kind, fields: field.kind === 'object' ? field.fields : [] }\n if (kind === 'list') return { ...head, kind, item: field.kind === 'list' ? field.item : { kind: 'object', fields: [] } }\n return { ...head, kind } as FigureDataField\n}\n\n/** The rows of the schema, each with the bindings that read it (figure-model's view). */\nexport const schemaRowsOf = (asset: FigureAsset): FigureDataRow[] => (asset.dataInterface ? figureDataRows(asset.dataInterface) : [])\n\n/* ---------------------------------------------------------------- reading a sample */\n\n/**\n * What a sample of data would do on this figure, read the one way a placed figure reads it (things-scene's figure\n * inputs): what it moves, or why it is refused, each value's reason; each table's look and where it came from, and what\n * of a legend was left out. `legends`: sample legends by role, as a scene's legend of the role's name would be.\n */\nexport function sampleOf(\n asset: FigureAsset,\n sample: unknown,\n legends: Record<string, unknown> = {}\n): { issues: FigureDataValueIssue[]; result: FigureDataResult; uses: Readonly<Record<string, FigureTableUse>>; notes: FigureRuntimeIssue[] } {\n const inputs = new FigureInputs(asset)\n inputs.setThemes({ legends: Object.fromEntries(Object.entries(legends).map(([role, legend]) => [role, { legend, source: 'domain' as const, name: role }])) })\n const taken = inputs.setData(sample)\n return {\n issues: taken.accepted ? [] : (taken.issues[0]?.issues ?? []),\n result: inputs.data,\n uses: inputs.tableUses,\n notes: inputs.diagnostics().filter(i => i.severity === 'note')\n }\n}\n\n/**\n * The state inputs a sample of data sets on this figure, by id: what the preview shows for them instead of a slider. None\n * when there is no sample, or the figure refuses it.\n */\nexport function sampledStatesOf(asset: FigureAsset, sample: unknown): Record<string, number> {\n if (sample === null || sample === undefined || !asset.dataInterface) return {}\n try {\n const read = sampleOf(asset, sample)\n return read.issues.length ? {} : Object.fromEntries(Object.entries(read.result.states).map(([id, s]) => [id, s.value]))\n } catch {\n return {}\n }\n}\n\n/** The rows a person gives a value by hand, as a board's saved values: one value, read by a binding, not inside a list. */\nexport const valueRowsOf = (asset: FigureAsset): FigureDataRow[] => schemaRowsOf(asset).filter(r => isValue(r.node) && r.bindings.length > 0 && !r.path.includes('[]'))\n\n/**\n * What the data gives a row, read the way a placed figure reads its data: when it is there, it is what the figure shows,\n * and a value saved by hand for the row is not read (things-scene's FigureDataReader: live data first). Undefined when\n * the data leaves the row out, or gives it null.\n */\nexport function dataValueAt(data: unknown, path: string): unknown {\n const steps = parseFigureAccessor(path)\n if (!steps) return undefined\n let at: unknown = data\n for (const step of steps) {\n if (at === null || typeof at !== 'object') return undefined\n at = 'field' in step ? (at as Record<string, unknown>)[step.field] : (at as unknown[])[step.index]\n }\n return at === null ? undefined : at\n}\n\n/** A value typed or chosen for a row, as its kind reads it: a number (NaN when empty), true or false, or the text. */\nexport function typedValueOf(node: FigureDataNode, typed: string): FigureDataValue {\n if (node.kind === 'number') return typed.trim() === '' ? Number.NaN : Number(typed)\n if (node.kind === 'boolean') return typed === 'true'\n return typed\n}\n\n/** The parts a table may show on: the parts the figure's appearance names. */\nexport const partsOf = (asset: FigureAsset): string[] => [...new Set(asset.appearance.map(a => a.target))]\n\n/** Whether a text is an accessor the kernel takes. */\nexport const accessorTaken = (accessor: string): boolean => parseFigureAccessor(accessor) !== null\n\n/**\n * Which fields of each motion group the data binds: its clip, its speed. A field bound wins over the group's own setting\n * whenever the data, a saved value or the schema's default gives it a value, so the preview drives it through the data.\n */\nexport function motionWrittenByData(asset: FigureAsset): Record<string, { clip: boolean; speed: boolean }> {\n const out: Record<string, { clip: boolean; speed: boolean }> = {}\n for (const b of asset.dataInterface?.bindings ?? []) {\n if (b.rule === 'table') {\n if (!b.targets.group) continue\n const one = (out[b.targets.group] ??= { clip: false, speed: false })\n const looks = Object.values(b.table)\n if (looks.some(l => l.clip !== undefined)) one.clip = true\n if (looks.some(l => l.speed !== undefined)) one.speed = true\n continue\n }\n if (b.behavior.kind !== 'motion-clip' && b.behavior.kind !== 'motion-speed') continue\n const one = (out[b.behavior.group] ??= { clip: false, speed: false })\n if (b.behavior.kind === 'motion-clip') one.clip = true\n else one.speed = true\n }\n return out\n}\n\n/* ---------------------------------------------------------------- the rotation card */\n\n/** A joint that turns without end (a roller, a fan, a turntable): its control, by the id the clips write. */\nexport interface EndlessJoint {\n input: string\n label: string\n unit: 'deg' | 'rad'\n}\n\n/** The axes that turn without end: revolute, with no limits, following no one (ADR-0159: every axis of every joint). */\nexport function endlessJointsOf(asset: FigureAsset): EndlessJoint[] {\n const out: EndlessJoint[] = []\n for (const { motion: a } of figureAxesOf(asset.joints)) {\n if (a.type !== 'revolute' || a.lowerLimit !== undefined || a.upperLimit !== undefined || a.mimic) continue\n const input = motionStateIdOf(a)\n const unit = asset.document.model.inputs.find(i => i.id === input)?.unit\n if (unit !== 'deg' && unit !== 'rad') continue\n if (!out.some(e => e.input === input)) out.push({ input, label: asset.stateInputs?.[input]?.label ?? input, unit })\n }\n return out\n}\n\n/** What the rotation card is told: the joint, and the data fields that turn it on, set its speed and its direction. */\nexport interface RotationChoice {\n input: string\n /** The motion group's name, shown to a person. */\n label: string\n /** A boolean field: true turns, false stops where it is. */\n on?: string\n /** A number field in turns per minute, and the most it gives; the field's range is set to 0..max when it has none. */\n speed?: { path: string; max: number }\n /** A closed text field, and its value that turns forward and the one that turns back. */\n direction?: { path: string; forward: string; reverse: string }\n}\n\n/**\n * The rotation card's commands (data binding design decision 1, 「회전」): a clip that turns the joint once around and\n * keeps adding the turn (wrap, accumulating), a reverse one when a direction is given, the motion group holding them,\n * and the bindings -- on, by a table, to the group's pause, speed to its speed, direction, by a table, to its clip. Nothing new runs them: they\n * are the drivers, the group and the bindings any author could write, and stay editable one by one.\n *\n * The clip lasts `T = 3 × 60 / max rpm` seconds, so the most the field gives plays at the group's top speed, 3 -- the\n * speed range is not widened. One turn per `T` at speed 1, and speed = rpm × T / 60. A stop is a pause: the joint stays\n * where it is, where a stopped clip would jump back to its first key.\n */\nexport function rotationStepsOf(asset: FigureAsset, c: RotationChoice): FigureProposalStep[] {\n const joint = endlessJointsOf(asset).find(j => j.input === c.input)\n if (!joint) throw new FigureContractError('TARGET_ABSENT', c.input, `${c.input} is not a joint that turns without end`)\n const turn = joint.unit === 'deg' ? 360 : 2 * Math.PI\n const seconds = c.speed && c.speed.max > 0 ? round((3 * 60) / c.speed.max) : 1\n const group = freeIdOf((asset.motionGroups ?? []).map(g => g.id), `${joint.input}-spin`)\n const forward = group\n const reverse = `${group}-reverse`\n const steps: FigureProposalStep[] = []\n const schema = asset.dataInterface?.schema ?? []\n if (c.speed) {\n const field = fieldAt(schema, c.speed.path)\n if (field?.kind === 'number' && (field.min === undefined || field.max === undefined))\n steps.push({ kind: 'set-data-schema', schema: schemaWithFieldReplaced(schema, c.speed.path, { ...field, min: field.min ?? 0, max: field.max ?? c.speed.max }) })\n }\n const spin = (clip: string, way: 1 | -1, inGroup: boolean): FigureProposalStep => ({\n kind: 'set-driver',\n state: joint.input,\n clip,\n duration: seconds,\n keys: [\n { seconds: 0, value: 0 },\n { seconds, value: way * turn }\n ],\n interpolation: 'linear',\n loop: 'wrap',\n accumulates: true,\n ...(inGroup ? { group } : {})\n })\n const clips = c.direction ? [forward, reverse] : [forward]\n steps.push(spin(forward, 1, false))\n steps.push({ kind: 'set-motion-group', group: { id: group, label: c.label, clips: [forward], defaultClip: forward, transitionSeconds: 0 } })\n if (c.direction) {\n steps.push(spin(reverse, -1, true))\n steps.push({ kind: 'set-motion-group', group: { id: group, label: c.label, clips, defaultClip: forward, transitionSeconds: 0 } })\n }\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const bind = (base: string, binding: Omit<FigureDataValueBinding, 'id'> | Omit<FigureDataTableBinding, 'id'>): FigureProposalStep => {\n const id = freeIdOf(taken, base)\n taken.push(id)\n return { kind: 'set-data-binding', binding: { id, ...binding } as FigureDataBinding }\n }\n if (c.on) steps.push(bind(`${group}-on`, { accessor: c.on, rule: 'table', lookup: 'code', targets: { group }, table: { true: { paused: false }, false: { paused: true } } }))\n if (c.speed) steps.push(bind(`${group}-speed`, { accessor: c.speed.path, behavior: { kind: 'motion-speed', group }, rule: 'scale', param: { scale: round(seconds / 60), offset: 0 } }))\n if (c.direction) {\n const values = domainOf(fieldAt(schema, c.direction.path) ?? { kind: 'text' }).map(String)\n const covered = values.every(v => v === c.direction!.forward || v === c.direction!.reverse)\n steps.push(\n bind(`${group}-direction`, {\n accessor: c.direction.path,\n rule: 'table',\n lookup: 'code',\n targets: { group },\n table: { [c.direction.forward]: { clip: forward }, [c.direction.reverse]: { clip: reverse }, ...(covered ? {} : { default: { clip: forward } }) }\n })\n )\n }\n return steps\n}\n"]}
1
+ {"version":3,"file":"data-interface.js","sourceRoot":"","sources":["../../client/modeller/data-interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAgBzK,OAAO,EAAE,YAAY,EAAuE,MAAM,wBAAwB,CAAA;AAkB1H,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAqB,EAAU,EAAE,CAC7D,CAAC,CAAC,IAAI,KAAK,OAAO;IAChB,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE;IACpB,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS;QACpB,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE;QACtB,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM;YACjB,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE;YAClB,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO;gBAClB,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE;gBACzB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;AAElC;;;GAGG;AACH,MAA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AM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,SAAU,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,SAAU,CAAC,OAAO,CAAC,CAAA;QAC3F,KAAK,CAAC,IAAI,CACR,IAAI,CAAC,GAAG,KAAK,YAAY,EAAE;YACzB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI;YAC1B,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,KAAK,EAAE;YAClB,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE;SAClJ,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/*\n * The figure's data and what it moves (ADR-0051 §8, ADR-0166): what the data tab offers and shows -- one binding, its\n * method as the field's kind allows (as it is, scaled, a code table, a range table). Every rule is figure-model's -- which accessor holds, which rule's results a behavior takes -- and the reading\n * of data is things-scene's; this only lists what there is to choose, drafts a binding the kernel then checks, and edits\n * the schema as a tree. Kept apart from the element so it is tested without a browser.\n */\nimport { FIGURE_PART_ID, FIGURE_MOTION_SPEED_MAX, FigureContractError, figureAxesOf, figureDataRows, motionStateIdOf, parseFigureAccessor } from '@hatiolab/figure-model'\nimport type {\n FigureAsset,\n FigureDataBehavior,\n FigureDataBinding,\n FigureDataField,\n FigureDataNode,\n FigureDataRow,\n FigureDataTableBinding,\n FigureDataTableEntry,\n FigureDataTargets,\n FigureDataValue,\n FigureDataValueBinding,\n FigureDataValueIssue,\n FigureProposalStep\n} from '@hatiolab/figure-model'\nimport { FigureInputs, type FigureDataResult, type FigureRuntimeIssue, type FigureTableUse } from '@hatiolab/things-scene'\n\n/** Something a binding can move, with what the screen shows of it. */\nexport interface BehaviorChoice {\n /** One string per behavior, for a select's value. */\n key: string\n behavior: FigureDataBehavior\n /** The screen's word for the kind: a control, a colour, a group's clip, … */\n kind: FigureDataBehavior['kind']\n /** The control's label, the colour token, the group's label, the axis. */\n name: string\n unit?: string\n min?: number\n max?: number\n /** A motion group's clips. */\n clips?: string[]\n}\n\nexport const behaviorKeyOf = (b: FigureDataBehavior): string =>\n b.kind === 'state'\n ? `state:${b.input}`\n : b.kind === 'palette'\n ? `palette:${b.token}`\n : b.kind === 'pose'\n ? `pose:${b.axis}`\n : b.kind === 'items'\n ? `items:${b.slot ?? ''}`\n : `${b.kind}:${b.group}`\n\n/**\n * Everything a value binding may drive: each control, each colour, each motion group's clip, speed and pause, its\n * position and heading, and -- when it has places -- the items in them.\n */\nexport function behaviorsOf(asset: FigureAsset): BehaviorChoice[] {\n const out: BehaviorChoice[] = []\n const add = (behavior: FigureDataBehavior, name: string, more: Partial<BehaviorChoice> = {}) => out.push({ key: behaviorKeyOf(behavior), behavior, kind: behavior.kind, name, ...more })\n for (const input of asset.document.model.inputs) {\n if (input.role !== 'state') continue\n add({ kind: 'state', input: input.id, sourceMode: 'observed' }, asset.stateInputs?.[input.id]?.label ?? input.id, { unit: input.unit, min: input.min, max: input.max })\n }\n for (const token of Object.keys(asset.palette)) add({ kind: 'palette', token }, token)\n for (const group of asset.motionGroups ?? []) {\n add({ kind: 'motion-clip', group: group.id }, group.label, { clips: [...group.clips] })\n add({ kind: 'motion-speed', group: group.id }, group.label, { min: 0, max: FIGURE_MOTION_SPEED_MAX })\n add({ kind: 'motion-paused', group: group.id }, group.label)\n }\n for (const axis of ['x', 'z', 'y', 'heading'] as const) add({ kind: 'pose', axis, seconds: 1 }, axis, { unit: axis === 'heading' ? 'deg' : 'mm' })\n if (asset.document.capabilities.slotLayout || asset.document.capabilities.names?.includes('Holdable')) add({ kind: 'items' }, asset.document.capabilities.slotLayout?.label ?? 'items')\n return out\n}\n\nconst isValue = (n: FigureDataNode): n is Extract<FigureDataNode, { kind: 'number' | 'boolean' | 'text' }> => n.kind === 'number' || n.kind === 'boolean' || n.kind === 'text'\n\n/**\n * Whether a field of this kind drives the behavior as it is or scaled -- the choices a value binding offers for it. A\n * value that picks a look per code is a table (ADR-0166 2).\n */\nexport function fitsField(node: FigureDataNode, choice: BehaviorChoice): boolean {\n if (choice.kind === 'items') return node.kind === 'list' || node.kind === 'text' || node.kind === 'number'\n if (!isValue(node)) return false\n if (choice.kind === 'motion-paused') return node.kind === 'boolean'\n if (choice.kind === 'palette') return node.kind === 'text' && !!node.values?.every(v => /^#[0-9a-f]{6}$/i.test(v))\n if (choice.kind === 'motion-clip') {\n const clips = choice.behavior.kind === 'motion-clip' ? choice.clips : undefined\n return node.kind === 'text' && !!node.values && (!clips || node.values.every(v => clips.includes(v)))\n }\n return node.kind === 'number'\n}\n\n/** How a binding turns a value into what the figure shows (ADR-0166 1): the screen's four methods, figure-viewer's words for every screen. */\nimport { methodOf, type DataMethod } from '@things-factory/figure-viewer/dist-client/data-connection.js'\nexport { methodOf, type DataMethod }\n\n/**\n * The methods a field allows (ADR-0166 2, amendment 1): a number as it is, scaled, by a code table (status codes sent as\n * numbers, 4002) or by a range table; a text or true/false by a code table, or as it is where a behavior takes it so; a\n * list as it is (its items). A new field is made by a table.\n */\nexport function methodsOf(node: FigureDataNode | null, choices: BehaviorChoice[]): DataMethod[] {\n if (!node) return ['code', 'ranges']\n const fitting = choices.some(c => fitsField(node, c))\n if (node.kind === 'number') return [...(fitting ? (['value', 'scale'] as const) : []), 'code', 'ranges']\n if (node.kind === 'text' || node.kind === 'boolean') return [...(fitting ? (['value'] as const) : []), 'code']\n return fitting ? ['value'] : []\n}\n\n/** The method a binding is shown by. */\n\n/** An id not taken among `taken`: `base`, then `base-2`, `base-3`, … made into the kernel's id shape. */\nexport function freeIdOf(taken: Iterable<string>, base: string): string {\n const used = new Set(taken)\n const cleaned = base.replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/^[^a-zA-Z]+/, '').replace(/-+$/, '') || 'binding'\n const id = FIGURE_PART_ID.test(cleaned) ? cleaned : 'binding'\n if (!used.has(id)) return id\n let n = 2\n while (used.has(`${id}-${n}`)) n++\n return `${id}-${n}`\n}\n\n/** How many mm, or degrees, one of a unit is: only lengths and angles are converted. */\nconst TO_MM: Record<string, number> = { mm: 1, cm: 10, m: 1000 }\nconst TO_DEG: Record<string, number> = { deg: 1, rad: 180 / Math.PI }\n\n/** The values a closed field takes: a closed text's values, both booleans. Empty when open. */\nexport const domainOf = (node: FigureDataNode): FigureDataValue[] => (node.kind === 'boolean' ? [false, true] : node.kind === 'text' && node.values ? [...node.values] : [])\n\n/**\n * A first value binding of a field to a behavior, for the author to adjust: the value as it is when it already fits, a\n * scale when only its unit or range differs -- or the method the author chose. The kernel says whether it holds.\n */\nexport function bindingDraftOf(asset: FigureAsset, accessor: string, node: FigureDataNode, choice: BehaviorChoice, method?: 'value' | 'scale'): FigureDataValueBinding {\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const name = accessor.replace(/\\[\\d+\\]/g, '').split('.').pop() ?? accessor\n const id = freeIdOf(taken, `${name}-${choice.kind === 'state' ? (choice.behavior as { input: string }).input : choice.kind}`)\n const behavior = choice.behavior\n const make = (rule: 'value' | 'scale', param?: FigureDataValueBinding['param']): FigureDataValueBinding => ({ id, accessor, behavior, rule, ...(param ? { param } : {}) })\n\n if (behavior.kind === 'items') {\n if (node.kind !== 'list') return make('value')\n const fields = node.item.kind === 'object' ? node.item.fields : []\n const pick = (...words: RegExp[]) => fields.find(f => isValue(f) && words.some(w => w.test(f.name)))?.name\n const itemId = pick(/^id$/i, /name$/i, /id$/i) ?? fields.find(isValue)?.name\n const type = pick(/type$/i)\n const place = pick(/^slot/i, /place/i, /port/i)\n const stack = pick(/stack/i, /level/i)\n return { id, accessor, behavior: { kind: 'items', ...(itemId ? { id: itemId } : {}), ...(type ? { type } : {}), ...(place ? { place } : {}), ...(stack ? { stack } : {}) }, rule: 'value' }\n }\n if (node.kind !== 'number') return make('value')\n if (behavior.kind === 'pose') {\n const want = behavior.axis === 'heading' ? TO_DEG : TO_MM\n const unit = node.unit ?? ''\n if (method === 'value' || unit === (behavior.axis === 'heading' ? 'deg' : 'mm') || (method === undefined && !(unit in want))) return make('value')\n return make('scale', { scale: want[unit] ?? 1, offset: 0 })\n }\n /* state and motion-speed: a number into a range. */\n const [lo, hi, unit] =\n behavior.kind === 'motion-speed' ? [0, FIGURE_MOTION_SPEED_MAX, 'ratio'] : [choice.min ?? 0, choice.max ?? 1, choice.unit ?? '']\n const sameUnit = behavior.kind === 'motion-speed' ? node.unit === undefined || node.unit === 'ratio' : node.unit === unit\n const inside = node.min !== undefined && node.max !== undefined && node.min >= lo && node.max <= hi\n if (method === 'value' || (method === undefined && sameUnit && inside)) return make('value')\n if (node.min !== undefined && node.max !== undefined && node.max > node.min) {\n /* The field's range laid onto the behavior's. */\n const scale = (hi - lo) / (node.max - node.min)\n return make('scale', { scale: round(scale), offset: round(lo - scale * node.min) })\n }\n return method === 'scale' ? make('scale', { scale: 1, offset: 0 }) : make('value')\n}\n\n/* ---------------------------------------------------------------- tables (ADR-0166 3) */\n\n/** The first code a new code table names, and the next ones: `CODE`, `CODE2`, … */\n/** A new code for a number field's code table: one past the largest taken, or 0 (ADR-0166 amendment 1). */\nexport function freeNumberCodeOf(taken: string[]): string {\n const numbers = taken.map(Number).filter(n => Number.isInteger(n) && n >= 0)\n return String(numbers.length ? Math.max(...numbers) + 1 : 0)\n}\n\nexport function freeCodeOf(taken: string[]): string {\n if (!taken.includes('CODE')) return 'CODE'\n let n = 2\n while (taken.includes(`CODE${n}`)) n++\n return `CODE${n}`\n}\n\n/** A legend role from a binding's id: lower case letters, digits and `-`. */\nexport const legendRoleOf = (id: string): string =>\n id\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'legend'\n\n/**\n * A first table on a field (ADR-0166 10): a row per value of a closed field, an open field's rows typed later, one\n * interval over the whole of a number. The field is one the schema has: the data tab adds a binding in the field's row.\n */\nexport function tableDraftOf(\n asset: FigureAsset,\n field: { path: string; node: FigureDataNode },\n method: 'code' | 'ranges',\n targets: FigureDataTargets\n): { binding: FigureDataTableBinding } {\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const name = field.path.replace(/\\[\\]/g, '').split('.').pop() ?? field.path\n const id = freeIdOf(taken, name.toLowerCase())\n const node = field.node\n const accessor = accessorOfRow(field.path)\n const table: Record<string, FigureDataTableEntry> =\n method === 'code'\n ? node.kind === 'number'\n ? { [freeNumberCodeOf([])]: {} }\n : Object.fromEntries(domainOf(node).map(v => [String(v), {}]))\n : { [`${node.kind === 'number' ? (node.min ?? '') : ''}~`]: {} }\n return { binding: { id, accessor, rule: 'table', lookup: method, targets: tidyTargets(targets), table } }\n}\n\n/** Targets with empty lists left out, as the kernel keeps them. */\nconst tidyTargets = (t: FigureDataTargets): FigureDataTargets => ({\n ...(t.parts?.length ? { parts: [...t.parts] } : {}),\n ...(t.inputs?.length ? { inputs: [...t.inputs] } : {}),\n ...(t.group ? { group: t.group } : {})\n})\n\n/** A look with only the columns its targets take: a target taken away takes its columns with it. A look that keeps stays so. */\nfunction lookFor(look: FigureDataTableEntry, t: FigureDataTargets): FigureDataTableEntry {\n if (look.keep) return { keep: true }\n const out: FigureDataTableEntry = {}\n if (t.parts?.length) {\n if (look.color !== undefined) out.color = look.color\n if (look.effect !== undefined) out.effect = look.effect\n }\n if (t.inputs?.length && look.values) {\n const values = Object.fromEntries(Object.entries(look.values).filter(([id]) => t.inputs!.includes(id)))\n if (Object.keys(values).length) out.values = values\n }\n if (t.group) {\n if (look.clip !== undefined) out.clip = look.clip\n if (look.speed !== undefined) out.speed = look.speed\n if (look.paused !== undefined) out.paused = look.paused\n }\n return out\n}\n\n/** The table with these targets: each look keeps only the columns they take. */\nexport function tableWithTargets(b: FigureDataTableBinding, targets: FigureDataTargets): FigureDataTableBinding {\n const t = tidyTargets(targets)\n return { ...b, targets: t, table: Object.fromEntries(Object.entries(b.table).map(([k, look]) => [k, lookFor(look, t)])) }\n}\n\n/** The table with one look set: the whole look given, a column left out cleared. */\nexport const tableWithLook = (b: FigureDataTableBinding, key: string, look: FigureDataTableEntry): FigureDataTableBinding => ({ ...b, table: { ...b.table, [key]: lookFor(look, b.targets) } })\n\n/**\n * The table whose other values keep what it last showed, or go to the default look (an empty one): the 「그대로 둠」 of\n * the 「그 밖의 값」 row (ADR-0166 amendment 1).\n */\nexport const tableWithKeep = (b: FigureDataTableBinding, keep: boolean): FigureDataTableBinding => ({ ...b, table: { ...b.table, default: keep ? { keep: true } : {} } })\n\n/** The table's rows renamed, added or taken away, in order; `default` kept last. */\nexport function tableWithKeys(b: FigureDataTableBinding, rows: Array<[string, FigureDataTableEntry]>): FigureDataTableBinding {\n const d = b.table.default\n return { ...b, table: { ...Object.fromEntries(rows), ...(d !== undefined ? { default: d } : {}) } }\n}\n\n/**\n * The columns a table's targets give its looks, as the row editor shows them: colour and effect for parts, a value per\n * state input (its unit and range), the clip, speed and pause of the group.\n */\nexport function tableColumnsOf(asset: FigureAsset, b: FigureDataTableBinding): TableColumn[] {\n const out: TableColumn[] = []\n if (b.targets.parts?.length) out.push({ kind: 'color' }, { kind: 'effect' })\n for (const id of b.targets.inputs ?? []) {\n const input = asset.document.model.inputs.find(i => i.id === id)\n out.push({ kind: 'value', id, label: asset.stateInputs?.[id]?.label ?? id, unit: input?.unit, min: input?.min, max: input?.max })\n }\n if (b.targets.group) {\n const group = (asset.motionGroups ?? []).find(g => g.id === b.targets.group)\n out.push({ kind: 'clip', clips: group?.clips ?? [] }, { kind: 'speed' }, { kind: 'paused' })\n }\n return out\n}\nexport type TableColumn =\n | { kind: 'color' | 'effect' | 'speed' | 'paused' }\n | { kind: 'value'; id: string; label: string; unit?: string; min?: number; max?: number }\n | { kind: 'clip'; clips: string[] }\n\n/** The state inputs a table may give values to: each control, with its label. */\nexport const stateInputsOf = (asset: FigureAsset): Array<{ id: string; label: string }> =>\n asset.document.model.inputs.filter(i => i.role === 'state').map(i => ({ id: i.id, label: asset.stateInputs?.[i.id]?.label ?? i.id }))\n\n/**\n * A code table's field follows its keys (ADR-0166 risk 3): when the field is a closed text, its values are the table's\n * codes. The schema with the field so, or undefined when the field is open or already so.\n */\nexport function schemaFollowingCodes(asset: FigureAsset, b: FigureDataTableBinding, codes: string[]): FigureDataField[] | undefined {\n const schema = asset.dataInterface?.schema ?? []\n const path = b.accessor.replace(/\\[\\d+\\]/g, '[]')\n const field = fieldAt(schema, path)\n if (field?.kind !== 'text' || !field.values || !codes.length) return undefined\n if (field.values.length === codes.length && field.values.every((v, i) => v === codes[i])) return undefined\n const next = { ...field, values: [...codes] } as FigureDataField & { default?: string }\n if (next.default !== undefined && !codes.includes(next.default)) delete next.default\n return schemaWithFieldReplaced(schema, path, next)\n}\n\nconst round = (v: number) => Math.round(v * 1e6) / 1e6\n\n/* ---------------------------------------------------------------- the schema as a tree */\n\n/** A row's path (`L[].F`) as the accessor a value binding reads (`L[0].F`): the first element of each list. */\nexport const accessorOfRow = (path: string): string => path.replace(/\\[\\]/g, '[0]')\n\n/** The field at a row's path, or undefined. */\nexport function fieldAt(schema: readonly FigureDataField[], path: string): FigureDataField | undefined {\n let list: readonly FigureDataField[] = schema\n let found: FigureDataField | undefined\n for (const part of path.split('.')) {\n const name = part.replace(/\\[\\]/g, '')\n found = list.find(f => f.name === name)\n if (!found) return undefined\n let node: FigureDataNode = found\n while (node.kind === 'list') node = node.item\n list = node.kind === 'object' ? node.fields : []\n }\n return found\n}\n\n/** The fields under a row's path, where a new field goes: the top, an object's fields, a list's element's fields. */\nfunction fieldsUnder(schema: FigureDataField[], path: string): FigureDataField[] | undefined {\n if (!path) return schema\n const field = fieldAt(schema, path)\n if (!field) return undefined\n let node: FigureDataNode = field\n while (node.kind === 'list') node = node.item\n return node.kind === 'object' ? node.fields : undefined\n}\n\n/** The schema with a field added under a path ('' for the top): a copy, the given one left as it is. */\nexport function schemaWithField(schema: readonly FigureDataField[], under: string, field: FigureDataField): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n fieldsUnder(out, under)?.push(field)\n return out\n}\n\n/** The schema with the field at a path replaced (its name kept unless the new one says another). */\nexport function schemaWithFieldReplaced(schema: readonly FigureDataField[], path: string, field: FigureDataField): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : ''\n const list = fieldsUnder(out, parent)\n const name = path.split('.').pop()!.replace(/\\[\\]/g, '')\n const at = list?.findIndex(f => f.name === name) ?? -1\n if (list && at >= 0) list[at] = field\n return out\n}\n\n/** The schema without the field at a path. */\nexport function schemaWithoutField(schema: readonly FigureDataField[], path: string): FigureDataField[] {\n const out = structuredClone(schema) as FigureDataField[]\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : ''\n const list = fieldsUnder(out, parent)\n const name = path.split('.').pop()!.replace(/\\[\\]/g, '')\n const at = list?.findIndex(f => f.name === name) ?? -1\n if (list && at >= 0) list.splice(at, 1)\n return out\n}\n\n/** A field of another kind, its name, label and json flag kept, the rest started fresh. */\nexport function fieldOfKind(field: FigureDataField, kind: FigureDataNode['kind']): FigureDataField {\n const head = { name: field.name, ...(field.label ? { label: field.label } : {}) }\n if (kind === 'object') return { ...head, kind, fields: field.kind === 'object' ? field.fields : [] }\n if (kind === 'list') return { ...head, kind, item: field.kind === 'list' ? field.item : { kind: 'object', fields: [] } }\n return { ...head, kind } as FigureDataField\n}\n\n/** The rows of the schema, each with the bindings that read it (figure-model's view). */\nexport const schemaRowsOf = (asset: FigureAsset): FigureDataRow[] => (asset.dataInterface ? figureDataRows(asset.dataInterface) : [])\n\n/* ---------------------------------------------------------------- reading a sample */\n\n/**\n * What a sample of data would do on this figure, read the one way a placed figure reads it (things-scene's figure\n * inputs): what it moves, or why it is refused, each value's reason; each table's look and where it came from, and what\n * of a legend was left out. `legends`: sample legends by role, as a scene's legend of the role's name would be.\n */\nexport function sampleOf(\n asset: FigureAsset,\n sample: unknown,\n legends: Record<string, unknown> = {}\n): { issues: FigureDataValueIssue[]; result: FigureDataResult; uses: Readonly<Record<string, FigureTableUse>>; notes: FigureRuntimeIssue[] } {\n const inputs = new FigureInputs(asset)\n inputs.setThemes({ legends: Object.fromEntries(Object.entries(legends).map(([role, legend]) => [role, { legend, source: 'domain' as const, name: role }])) })\n const taken = inputs.setData(sample)\n return {\n issues: taken.accepted ? [] : (taken.issues[0]?.issues ?? []),\n result: inputs.data,\n uses: inputs.tableUses,\n notes: inputs.diagnostics().filter(i => i.severity === 'note')\n }\n}\n\n/**\n * The state inputs a sample of data sets on this figure, by id: what the preview shows for them instead of a slider. None\n * when there is no sample, or the figure refuses it.\n */\nexport function sampledStatesOf(asset: FigureAsset, sample: unknown): Record<string, number> {\n if (sample === null || sample === undefined || !asset.dataInterface) return {}\n try {\n const read = sampleOf(asset, sample)\n return read.issues.length ? {} : Object.fromEntries(Object.entries(read.result.states).map(([id, s]) => [id, s.value]))\n } catch {\n return {}\n }\n}\n\n/** The rows a person gives a value by hand, as a board's saved values: one value, read by a binding, not inside a list. */\nexport const valueRowsOf = (asset: FigureAsset): FigureDataRow[] => schemaRowsOf(asset).filter(r => isValue(r.node) && r.bindings.length > 0 && !r.path.includes('[]'))\n\n/**\n * What the data gives a row, read the way a placed figure reads its data: when it is there, it is what the figure shows,\n * and a value saved by hand for the row is not read (things-scene's FigureDataReader: live data first). Undefined when\n * the data leaves the row out, or gives it null.\n */\nexport function dataValueAt(data: unknown, path: string): unknown {\n const steps = parseFigureAccessor(path)\n if (!steps) return undefined\n let at: unknown = data\n for (const step of steps) {\n if (at === null || typeof at !== 'object') return undefined\n at = 'field' in step ? (at as Record<string, unknown>)[step.field] : (at as unknown[])[step.index]\n }\n return at === null ? undefined : at\n}\n\n/** A value typed or chosen for a row, as its kind reads it: a number (NaN when empty), true or false, or the text. */\nexport function typedValueOf(node: FigureDataNode, typed: string): FigureDataValue {\n if (node.kind === 'number') return typed.trim() === '' ? Number.NaN : Number(typed)\n if (node.kind === 'boolean') return typed === 'true'\n return typed\n}\n\n/** The parts a table may show on: the parts the figure's appearance names. */\nexport const partsOf = (asset: FigureAsset): string[] => [...new Set(asset.appearance.map(a => a.target))]\n\n/** Whether a text is an accessor the kernel takes. */\nexport const accessorTaken = (accessor: string): boolean => parseFigureAccessor(accessor) !== null\n\n/**\n * Which fields of each motion group the data binds: its clip, its speed. A field bound wins over the group's own setting\n * whenever the data, a saved value or the schema's default gives it a value, so the preview drives it through the data.\n */\nexport function motionWrittenByData(asset: FigureAsset): Record<string, { clip: boolean; speed: boolean }> {\n const out: Record<string, { clip: boolean; speed: boolean }> = {}\n for (const b of asset.dataInterface?.bindings ?? []) {\n if (b.rule === 'table') {\n if (!b.targets.group) continue\n const one = (out[b.targets.group] ??= { clip: false, speed: false })\n const looks = Object.values(b.table)\n if (looks.some(l => l.clip !== undefined)) one.clip = true\n if (looks.some(l => l.speed !== undefined)) one.speed = true\n continue\n }\n if (b.behavior.kind !== 'motion-clip' && b.behavior.kind !== 'motion-speed') continue\n const one = (out[b.behavior.group] ??= { clip: false, speed: false })\n if (b.behavior.kind === 'motion-clip') one.clip = true\n else one.speed = true\n }\n return out\n}\n\n/* ---------------------------------------------------------------- the rotation card */\n\n/** A joint that turns without end (a roller, a fan, a turntable): its control, by the id the clips write. */\nexport interface EndlessJoint {\n input: string\n label: string\n unit: 'deg' | 'rad'\n}\n\n/** The axes that turn without end: revolute, with no limits, following no one (ADR-0159: every axis of every joint). */\nexport function endlessJointsOf(asset: FigureAsset): EndlessJoint[] {\n const out: EndlessJoint[] = []\n for (const { motion: a } of figureAxesOf(asset.joints)) {\n if (a.type !== 'revolute' || a.lowerLimit !== undefined || a.upperLimit !== undefined || a.mimic) continue\n const input = motionStateIdOf(a)\n const unit = asset.document.model.inputs.find(i => i.id === input)?.unit\n if (unit !== 'deg' && unit !== 'rad') continue\n if (!out.some(e => e.input === input)) out.push({ input, label: asset.stateInputs?.[input]?.label ?? input, unit })\n }\n return out\n}\n\n/** What the rotation card is told: the joint, and the data fields that turn it on, set its speed and its direction. */\nexport interface RotationChoice {\n input: string\n /** The motion group's name, shown to a person. */\n label: string\n /** A boolean field: true turns, false stops where it is. */\n on?: string\n /** A number field in turns per minute, and the most it gives; the field's range is set to 0..max when it has none. */\n speed?: { path: string; max: number }\n /** A closed text field, and its value that turns forward and the one that turns back. */\n direction?: { path: string; forward: string; reverse: string }\n}\n\n/**\n * The rotation card's commands (data binding design decision 1, 「회전」): a clip that turns the joint once around and\n * keeps adding the turn (wrap, accumulating), a reverse one when a direction is given, the motion group holding them,\n * and the bindings -- on, by a table, to the group's pause, speed to its speed, direction, by a table, to its clip. Nothing new runs them: they\n * are the drivers, the group and the bindings any author could write, and stay editable one by one.\n *\n * The clip lasts `T = 3 × 60 / max rpm` seconds, so the most the field gives plays at the group's top speed, 3 -- the\n * speed range is not widened. One turn per `T` at speed 1, and speed = rpm × T / 60. A stop is a pause: the joint stays\n * where it is, where a stopped clip would jump back to its first key.\n */\nexport function rotationStepsOf(asset: FigureAsset, c: RotationChoice): FigureProposalStep[] {\n const joint = endlessJointsOf(asset).find(j => j.input === c.input)\n if (!joint) throw new FigureContractError('TARGET_ABSENT', c.input, `${c.input} is not a joint that turns without end`)\n const turn = joint.unit === 'deg' ? 360 : 2 * Math.PI\n const seconds = c.speed && c.speed.max > 0 ? round((3 * 60) / c.speed.max) : 1\n const group = freeIdOf((asset.motionGroups ?? []).map(g => g.id), `${joint.input}-spin`)\n const forward = group\n const reverse = `${group}-reverse`\n const steps: FigureProposalStep[] = []\n const schema = asset.dataInterface?.schema ?? []\n if (c.speed) {\n const field = fieldAt(schema, c.speed.path)\n if (field?.kind === 'number' && (field.min === undefined || field.max === undefined))\n steps.push({ kind: 'set-data-schema', schema: schemaWithFieldReplaced(schema, c.speed.path, { ...field, min: field.min ?? 0, max: field.max ?? c.speed.max }) })\n }\n const spin = (clip: string, way: 1 | -1, inGroup: boolean): FigureProposalStep => ({\n kind: 'set-driver',\n state: joint.input,\n clip,\n duration: seconds,\n keys: [\n { seconds: 0, value: 0 },\n { seconds, value: way * turn }\n ],\n interpolation: 'linear',\n loop: 'wrap',\n accumulates: true,\n ...(inGroup ? { group } : {})\n })\n const clips = c.direction ? [forward, reverse] : [forward]\n steps.push(spin(forward, 1, false))\n steps.push({ kind: 'set-motion-group', group: { id: group, label: c.label, clips: [forward], defaultClip: forward, transitionSeconds: 0 } })\n if (c.direction) {\n steps.push(spin(reverse, -1, true))\n steps.push({ kind: 'set-motion-group', group: { id: group, label: c.label, clips, defaultClip: forward, transitionSeconds: 0 } })\n }\n const taken = (asset.dataInterface?.bindings ?? []).map(b => b.id)\n const bind = (base: string, binding: Omit<FigureDataValueBinding, 'id'> | Omit<FigureDataTableBinding, 'id'>): FigureProposalStep => {\n const id = freeIdOf(taken, base)\n taken.push(id)\n return { kind: 'set-data-binding', binding: { id, ...binding } as FigureDataBinding }\n }\n if (c.on) steps.push(bind(`${group}-on`, { accessor: c.on, rule: 'table', lookup: 'code', targets: { group }, table: { true: { paused: false }, false: { paused: true } } }))\n if (c.speed) steps.push(bind(`${group}-speed`, { accessor: c.speed.path, behavior: { kind: 'motion-speed', group }, rule: 'scale', param: { scale: round(seconds / 60), offset: 0 } }))\n if (c.direction) {\n const values = domainOf(fieldAt(schema, c.direction.path) ?? { kind: 'text' }).map(String)\n const covered = values.every(v => v === c.direction!.forward || v === c.direction!.reverse)\n steps.push(\n bind(`${group}-direction`, {\n accessor: c.direction.path,\n rule: 'table',\n lookup: 'code',\n targets: { group },\n table: { [c.direction.forward]: { clip: forward }, [c.direction.reverse]: { clip: reverse }, ...(covered ? {} : { default: { clip: forward } }) }\n })\n )\n }\n return steps\n}\n"]}