@things-factory/figure-viewer 10.1.213 → 10.1.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/capability-rung.ts +2 -2
- package/client/detail-facts.ts +3 -3
- package/client/detail-motion.ts +11 -8
- package/dist-client/capability-rung.d.ts +1 -1
- package/dist-client/capability-rung.js +2 -2
- package/dist-client/capability-rung.js.map +1 -1
- package/dist-client/detail-facts.d.ts +2 -2
- package/dist-client/detail-facts.js +2 -2
- package/dist-client/detail-facts.js.map +1 -1
- package/dist-client/detail-motion.d.ts +3 -2
- package/dist-client/detail-motion.js +6 -6
- package/dist-client/detail-motion.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/test/detail-facts.test.ts +2 -0
- package/test/detail-motion.test.ts +6 -3
- package/translations/en.json +2 -1
- package/translations/es.json +2 -1
- package/translations/ja.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +2 -1
|
@@ -11,9 +11,9 @@ export const RUNGS: Readonly<Record<Rung, readonly FigureCapability[]>> = Object
|
|
|
11
11
|
flow: ['FlowNode']
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
/** Which rung a set of names is, or null when it is none of them -- not invented. */
|
|
14
|
+
/** Which rung a set of names is, or null when it is none of them -- not invented. A product's capability (`<namespace>.<Name>`, ADR-0167) is beside the ladder. */
|
|
15
15
|
export function rungOf(names: readonly string[] | undefined): Rung | null {
|
|
16
|
-
const has = new Set(names ?? [])
|
|
16
|
+
const has = new Set((names ?? []).filter(name => !name.includes('.')))
|
|
17
17
|
if (has.size === 0) return 'none'
|
|
18
18
|
for (const [rung, wanted] of Object.entries(RUNGS) as [Rung, readonly FigureCapability[]][])
|
|
19
19
|
if (wanted.length === has.size && wanted.every(name => has.has(name))) return rung
|
package/client/detail-facts.ts
CHANGED
|
@@ -19,12 +19,12 @@ export interface DetailFactsRow {
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A place in words, as every screen that lists places says it: its role (파지 · 안착), what it accepts and how many it
|
|
22
|
-
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1
|
|
22
|
+
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1」, or 「받는 것 모든 아이템」 for a place that names no type.
|
|
23
23
|
*/
|
|
24
|
-
export function placeTerms(place: { role: string; accepts
|
|
24
|
+
export function placeTerms(place: { role: string; accepts?: readonly string[]; capacity: number }, say: Say): string {
|
|
25
25
|
return [
|
|
26
26
|
say(`figure.label.role-${place.role}`),
|
|
27
|
-
say('figure.text.place-accepts', { accepts: place.accepts.join(', ') }),
|
|
27
|
+
place.accepts?.length ? say('figure.text.place-accepts', { accepts: place.accepts.join(', ') }) : say('figure.text.place-accepts-any'),
|
|
28
28
|
say('figure.label.place-holds', { count: place.capacity })
|
|
29
29
|
].join(' · ')
|
|
30
30
|
}
|
package/client/detail-motion.ts
CHANGED
|
@@ -15,8 +15,9 @@ export function clipsDriving(asset: FigureAsset, id: string) {
|
|
|
15
15
|
* How the detail view plays a clip (ADR-0051 §3.2, §8). A clip in no motion group plays at its own speed (the board's
|
|
16
16
|
* `clips`). A clip of a group is the group's selection (the board's `motion`); and when the figure's data chooses that
|
|
17
17
|
* group's clip, the data wins -- its default too -- so the clip is chosen through a data value the figure's own binding
|
|
18
|
-
* turns into it, given as a saved value (`figureValues`), the way a board would
|
|
19
|
-
*
|
|
18
|
+
* turns into it, given as a saved value (`figureValues`), the way a board would: the value itself, or the code of a
|
|
19
|
+
* table whose look names the clip (ADR-0166). A clip no data value turns into (an interval, a scale, or only another
|
|
20
|
+
* value's fallback of an open field) cannot be chosen here.
|
|
20
21
|
*/
|
|
21
22
|
export type ClipPlay =
|
|
22
23
|
| { kind: 'free' }
|
|
@@ -28,7 +29,9 @@ export function clipPlayOf(asset: FigureAsset, clip: string): ClipPlay {
|
|
|
28
29
|
const group = (asset.motionGroups ?? []).find(g => g.clips.includes(clip))
|
|
29
30
|
if (!group) return { kind: 'free' }
|
|
30
31
|
const plan = asset.dataInterface ? compileFigureDataInterface(asset) : null
|
|
31
|
-
const ready = plan?.bindings.find(
|
|
32
|
+
const ready = plan?.bindings.find(({ binding: b }) =>
|
|
33
|
+
b.rule === 'table' ? b.targets.group === group.id && Object.values(b.table).some(look => look.clip !== undefined) : b.behavior.kind === 'motion-clip' && b.behavior.group === group.id
|
|
34
|
+
)
|
|
32
35
|
if (!ready) return { kind: 'group', group: group.id }
|
|
33
36
|
const { binding, node } = ready
|
|
34
37
|
const reached = (value: FigureDataValue): ClipPlay => ({ kind: 'data', group: group.id, accessor: binding.accessor, value })
|
|
@@ -36,12 +39,12 @@ export function clipPlayOf(asset: FigureAsset, clip: string): ClipPlay {
|
|
|
36
39
|
const closed = node.kind === 'boolean' ? ['false', 'true'] : node.kind === 'text' && node.values ? node.values : null
|
|
37
40
|
const typed = (key: string): FigureDataValue => (node.kind === 'boolean' ? key === 'true' : node.kind === 'number' ? Number(key) : key)
|
|
38
41
|
if (binding.rule === 'value') return node.kind === 'text' && (!closed || closed.includes(clip)) ? reached(clip) : unreachable
|
|
39
|
-
if (binding.rule !== '
|
|
40
|
-
const
|
|
41
|
-
const key = Object.keys(
|
|
42
|
+
if (binding.rule !== 'table' || binding.lookup !== 'code') return unreachable
|
|
43
|
+
const table = binding.table
|
|
44
|
+
const key = Object.keys(table).find(k => k !== 'default' && table[k].clip === clip)
|
|
42
45
|
if (key !== undefined) return reached(typed(key))
|
|
43
|
-
/* Only the
|
|
44
|
-
const spare =
|
|
46
|
+
/* Only the default turns into it: a value of a closed field the table does not name. */
|
|
47
|
+
const spare = table.default?.clip === clip ? closed?.find(v => !Object.hasOwn(table, v)) : undefined
|
|
45
48
|
return spare !== undefined ? reached(typed(spare)) : unreachable
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FigureCapability } from '@hatiolab/figure-model';
|
|
2
2
|
export type Rung = 'none' | 'hold' | 'flow';
|
|
3
3
|
export declare const RUNGS: Readonly<Record<Rung, readonly FigureCapability[]>>;
|
|
4
|
-
/** Which rung a set of names is, or null when it is none of them -- not invented. */
|
|
4
|
+
/** Which rung a set of names is, or null when it is none of them -- not invented. A product's capability (`<namespace>.<Name>`, ADR-0167) is beside the ladder. */
|
|
5
5
|
export declare function rungOf(names: readonly string[] | undefined): Rung | null;
|
|
@@ -3,9 +3,9 @@ export const RUNGS = Object.freeze({
|
|
|
3
3
|
hold: ['Capacity', 'Holdable'],
|
|
4
4
|
flow: ['FlowNode']
|
|
5
5
|
});
|
|
6
|
-
/** Which rung a set of names is, or null when it is none of them -- not invented. */
|
|
6
|
+
/** Which rung a set of names is, or null when it is none of them -- not invented. A product's capability (`<namespace>.<Name>`, ADR-0167) is beside the ladder. */
|
|
7
7
|
export function rungOf(names) {
|
|
8
|
-
const has = new Set(names ?? []);
|
|
8
|
+
const has = new Set((names ?? []).filter(name => !name.includes('.')));
|
|
9
9
|
if (has.size === 0)
|
|
10
10
|
return 'none';
|
|
11
11
|
for (const [rung, wanted] of Object.entries(RUNGS))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-rung.js","sourceRoot":"","sources":["../client/capability-rung.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,KAAK,GAAwD,MAAM,CAAC,MAAM,CAAC;IACtF,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC,CAAA;AAEF,
|
|
1
|
+
{"version":3,"file":"capability-rung.js","sourceRoot":"","sources":["../client/capability-rung.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,KAAK,GAAwD,MAAM,CAAC,MAAM,CAAC;IACtF,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC,CAAA;AAEF,mKAAmK;AACnK,MAAM,UAAU,MAAM,CAAC,KAAoC;IACzD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACtE,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,MAAM,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAA0C;QACzF,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAA;IACpF,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { FigureCapability } from '@hatiolab/figure-model'\n\n/*\n One rung per set of the format's capability names. Typed as the format's names, so a misspelt rung does not pass\n (ADR-0051 ④).\n*/\nexport type Rung = 'none' | 'hold' | 'flow'\nexport const RUNGS: Readonly<Record<Rung, readonly FigureCapability[]>> = Object.freeze({\n none: [],\n hold: ['Capacity', 'Holdable'],\n flow: ['FlowNode']\n})\n\n/** Which rung a set of names is, or null when it is none of them -- not invented. A product's capability (`<namespace>.<Name>`, ADR-0167) is beside the ladder. */\nexport function rungOf(names: readonly string[] | undefined): Rung | null {\n const has = new Set((names ?? []).filter(name => !name.includes('.')))\n if (has.size === 0) return 'none'\n for (const [rung, wanted] of Object.entries(RUNGS) as [Rung, readonly FigureCapability[]][])\n if (wanted.length === has.size && wanted.every(name => has.has(name))) return rung\n return null\n}\n\n"]}
|
|
@@ -15,11 +15,11 @@ export interface DetailFactsRow {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* A place in words, as every screen that lists places says it: its role (파지 · 안착), what it accepts and how many it
|
|
18
|
-
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1
|
|
18
|
+
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1」, or 「받는 것 모든 아이템」 for a place that names no type.
|
|
19
19
|
*/
|
|
20
20
|
export declare function placeTerms(place: {
|
|
21
21
|
role: string;
|
|
22
|
-
accepts
|
|
22
|
+
accepts?: readonly string[];
|
|
23
23
|
capacity: number;
|
|
24
24
|
}, say: Say): string;
|
|
25
25
|
/** One line of what the preview tells about a figure: its label, its value, and for places one line each. */
|
|
@@ -3,12 +3,12 @@ import { rungOf } from './capability-rung.js';
|
|
|
3
3
|
import { authoredSizeOf, sizeRangeOf } from './preview-model.js';
|
|
4
4
|
/**
|
|
5
5
|
* A place in words, as every screen that lists places says it: its role (파지 · 안착), what it accepts and how many it
|
|
6
|
-
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1
|
|
6
|
+
* holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1」, or 「받는 것 모든 아이템」 for a place that names no type.
|
|
7
7
|
*/
|
|
8
8
|
export function placeTerms(place, say) {
|
|
9
9
|
return [
|
|
10
10
|
say(`figure.label.role-${place.role}`),
|
|
11
|
-
say('figure.text.place-accepts', { accepts: place.accepts.join(', ') }),
|
|
11
|
+
place.accepts?.length ? say('figure.text.place-accepts', { accepts: place.accepts.join(', ') }) : say('figure.text.place-accepts-any'),
|
|
12
12
|
say('figure.label.place-holds', { count: place.capacity })
|
|
13
13
|
].join(' · ');
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail-facts.js","sourceRoot":"","sources":["../client/detail-facts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAoB,MAAM,wBAAwB,CAAA;AAE3F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE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f, type FigureAsset } from '@hatiolab/figure-model'\n\nimport { rungOf } from './capability-rung.js'\nimport { authoredSizeOf, sizeRangeOf } from './preview-model.js'\n\ntype Say = (key: string, params?: Record<string, unknown>) => string\n\n/**\n * What the facts read off a figure's row besides its asset. figure-ui's catalogue row and figure-library's release both\n * give it. `score` absent means the caller does not keep one (no line); null means not measured yet.\n */\nexport interface DetailFactsRow {\n category?: string | null\n tags?: string[] | null\n score?: number | null\n updatedAt?: string | Date | null\n updater?: { name?: string | null } | null\n}\n\n/**\n * A place in words, as every screen that lists places says it: its role (파지 · 안착), what it accepts and how many it\n * holds -- 「파지 · 받는 것 BOX, WORKPIECE · 최대 1」, or 「받는 것 모든 아이템」 for a place that names no type.\n */\nexport function placeTerms(place: { role: string; accepts?: readonly string[]; capacity: number }, say: Say): string {\n return [\n say(`figure.label.role-${place.role}`),\n place.accepts?.length ? say('figure.text.place-accepts', { accepts: place.accepts.join(', ') }) : say('figure.text.place-accepts-any'),\n say('figure.label.place-holds', { count: place.capacity })\n ].join(' · ')\n}\n\n/** One line of what the preview tells about a figure: its label, its value, and for places one line each. */\nexport interface DetailFact {\n key: string\n label: string\n value: string\n lines?: string[]\n}\n\nconst number = (n: number) => Math.round(n).toLocaleString()\n\n/**\n * What a figure is, read off its asset and its row, in the words the modeller's properties already use. Nothing is\n * defaulted: what the figure does not say reads as a dash, and a score not yet measured is said so, not 0.\n */\nexport function detailFactsOf(asset: FigureAsset, row: DetailFactsRow, say: Say): DetailFact[] {\n const facts: DetailFact[] = []\n const dash = '—'\n\n facts.push({ key: 'category', label: say('figure.label.category'), value: row.category || dash })\n facts.push({ key: 'tags', label: say('figure.label.tags'), value: row.tags?.length ? row.tags.join(', ') : dash })\n facts.push({ key: 'placement', label: say('figure.label.figure-placement'), value: asset.placement ? say(`figure.label.placement-${asset.placement}`) : dash })\n\n /* The sizes a board may give it: a range on an axis that opens one, the authored size on one that is fixed. */\n const base = authoredSizeOf(asset)\n const axes = (['x', 'y', 'z'] as const).map(axis => {\n const range = sizeRangeOf(asset, axis)\n return `${axis.toUpperCase()} ${range ? `${number(range.min)}–${Number.isFinite(range.max) ? number(range.max) : '∞'}` : number(base[axis])}`\n })\n facts.push({ key: 'size', label: say('figure.label.instance-range'), value: `${axes.join(' · ')} mm` })\n if (asset.sizing === 'uniform') facts.push({ key: 'sizing', label: say('figure.label.sizing-rule'), value: say('figure.label.sizing-uniform') })\n\n const names = asset.document.capabilities.names ?? []\n const rung = rungOf(names)\n facts.push({ key: 'does', label: say('figure.label.what-this-does'), value: rung ? say(`figure.label.rung-${rung}`) : names.join(' · ') })\n\n const places = figureBindingsOf(asset)\n facts.push({\n key: 'places',\n label: say('figure.label.places'),\n value: places.length ? String(places.length) : dash,\n lines: places.map(place => `${place.label} · ${placeTerms(place, say)}`)\n })\n\n facts.push({ key: 'joints', label: say('figure.label.joint'), value: String(figureJointsOf(asset).joints.length) })\n const extensions = Object.keys((asset as { extensions?: Record<string, unknown> }).extensions ?? {})\n if (extensions.length) facts.push({ key: 'extensions', label: say('figure.label.extensions'), value: extensions.join(', ') })\n\n if ('score' in row)\n facts.push({ key: 'maturity', label: say('figure.label.maturity'), value: row.score == null ? say('figure.text.not-measured-yet') : String(Math.round(row.score)) })\n if (row.updatedAt) {\n const at = new Date(row.updatedAt).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })\n facts.push({ key: 'updated', label: say('field.updated_at'), value: row.updater?.name ? `${at} · ${row.updater.name}` : at })\n }\n return facts\n}\n"]}
|
|
@@ -9,8 +9,9 @@ export declare function clipsDriving(asset: FigureAsset, id: string): string[];
|
|
|
9
9
|
* How the detail view plays a clip (ADR-0051 §3.2, §8). A clip in no motion group plays at its own speed (the board's
|
|
10
10
|
* `clips`). A clip of a group is the group's selection (the board's `motion`); and when the figure's data chooses that
|
|
11
11
|
* group's clip, the data wins -- its default too -- so the clip is chosen through a data value the figure's own binding
|
|
12
|
-
* turns into it, given as a saved value (`figureValues`), the way a board would
|
|
13
|
-
*
|
|
12
|
+
* turns into it, given as a saved value (`figureValues`), the way a board would: the value itself, or the code of a
|
|
13
|
+
* table whose look names the clip (ADR-0166). A clip no data value turns into (an interval, a scale, or only another
|
|
14
|
+
* value's fallback of an open field) cannot be chosen here.
|
|
14
15
|
*/
|
|
15
16
|
export type ClipPlay = {
|
|
16
17
|
kind: 'free';
|
|
@@ -13,7 +13,7 @@ export function clipPlayOf(asset, clip) {
|
|
|
13
13
|
if (!group)
|
|
14
14
|
return { kind: 'free' };
|
|
15
15
|
const plan = asset.dataInterface ? compileFigureDataInterface(asset) : null;
|
|
16
|
-
const ready = plan?.bindings.find(
|
|
16
|
+
const ready = plan?.bindings.find(({ binding: b }) => b.rule === 'table' ? b.targets.group === group.id && Object.values(b.table).some(look => look.clip !== undefined) : b.behavior.kind === 'motion-clip' && b.behavior.group === group.id);
|
|
17
17
|
if (!ready)
|
|
18
18
|
return { kind: 'group', group: group.id };
|
|
19
19
|
const { binding, node } = ready;
|
|
@@ -23,14 +23,14 @@ export function clipPlayOf(asset, clip) {
|
|
|
23
23
|
const typed = (key) => (node.kind === 'boolean' ? key === 'true' : node.kind === 'number' ? Number(key) : key);
|
|
24
24
|
if (binding.rule === 'value')
|
|
25
25
|
return node.kind === 'text' && (!closed || closed.includes(clip)) ? reached(clip) : unreachable;
|
|
26
|
-
if (binding.rule !== '
|
|
26
|
+
if (binding.rule !== 'table' || binding.lookup !== 'code')
|
|
27
27
|
return unreachable;
|
|
28
|
-
const
|
|
29
|
-
const key = Object.keys(
|
|
28
|
+
const table = binding.table;
|
|
29
|
+
const key = Object.keys(table).find(k => k !== 'default' && table[k].clip === clip);
|
|
30
30
|
if (key !== undefined)
|
|
31
31
|
return reached(typed(key));
|
|
32
|
-
/* Only the
|
|
33
|
-
const spare =
|
|
32
|
+
/* Only the default turns into it: a value of a closed field the table does not name. */
|
|
33
|
+
const spare = table.default?.clip === clip ? closed?.find(v => !Object.hasOwn(table, v)) : undefined;
|
|
34
34
|
return spare !== undefined ? reached(typed(spare)) : unreachable;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail-motion.js","sourceRoot":"","sources":["../client/detail-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAA0C,MAAM,wBAAwB,CAAA;AAE3G,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB,CAAC,KAAkB,EAAE,MAA8B,EAAE,IAAY;IAChG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5F,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACrF,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,EAAU;IACzD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACzF,CAAC;
|
|
1
|
+
{"version":3,"file":"detail-motion.js","sourceRoot":"","sources":["../client/detail-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAA0C,MAAM,wBAAwB,CAAA;AAE3G,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB,CAA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C","sourcesContent":["import { compileFigureDataInterface, type FigureAsset, type FigureDataValue } from '@hatiolab/figure-model'\n\n/** External values win over drivers; release only the controls owned by the chosen clip. */\nexport function parametersForClip(asset: FigureAsset, values: Record<string, number>, clip: string) {\n const driven = new Set((asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state))\n return Object.fromEntries(Object.entries(values).filter(([id]) => !driven.has(id)))\n}\n\n/** The clips that move an input. A clip can move many inputs, so it plays on its own row, never on an input's. */\nexport function clipsDriving(asset: FigureAsset, id: string) {\n return [...new Set((asset.drivers ?? []).filter(d => d.state === id).map(d => d.clip))]\n}\n\n/**\n * How the detail view plays a clip (ADR-0051 §3.2, §8). A clip in no motion group plays at its own speed (the board's\n * `clips`). A clip of a group is the group's selection (the board's `motion`); and when the figure's data chooses that\n * group's clip, the data wins -- its default too -- so the clip is chosen through a data value the figure's own binding\n * turns into it, given as a saved value (`figureValues`), the way a board would: the value itself, or the code of a\n * table whose look names the clip (ADR-0166). A clip no data value turns into (an interval, a scale, or only another\n * value's fallback of an open field) cannot be chosen here.\n */\nexport type ClipPlay =\n | { kind: 'free' }\n | { kind: 'group'; group: string }\n | { kind: 'data'; group: string; accessor: string; value: FigureDataValue }\n | { kind: 'unreachable'; group: string }\n\nexport function clipPlayOf(asset: FigureAsset, clip: string): ClipPlay {\n const group = (asset.motionGroups ?? []).find(g => g.clips.includes(clip))\n if (!group) return { kind: 'free' }\n const plan = asset.dataInterface ? compileFigureDataInterface(asset) : null\n const ready = plan?.bindings.find(({ binding: b }) =>\n b.rule === 'table' ? b.targets.group === group.id && Object.values(b.table).some(look => look.clip !== undefined) : b.behavior.kind === 'motion-clip' && b.behavior.group === group.id\n )\n if (!ready) return { kind: 'group', group: group.id }\n const { binding, node } = ready\n const reached = (value: FigureDataValue): ClipPlay => ({ kind: 'data', group: group.id, accessor: binding.accessor, value })\n const unreachable: ClipPlay = { kind: 'unreachable', group: group.id }\n const closed = node.kind === 'boolean' ? ['false', 'true'] : node.kind === 'text' && node.values ? node.values : null\n const typed = (key: string): FigureDataValue => (node.kind === 'boolean' ? key === 'true' : node.kind === 'number' ? Number(key) : key)\n if (binding.rule === 'value') return node.kind === 'text' && (!closed || closed.includes(clip)) ? reached(clip) : unreachable\n if (binding.rule !== 'table' || binding.lookup !== 'code') return unreachable\n const table = binding.table\n const key = Object.keys(table).find(k => k !== 'default' && table[k].clip === clip)\n if (key !== undefined) return reached(typed(key))\n /* Only the default turns into it: a value of a closed field the table does not name. */\n const spare = table.default?.clip === clip ? closed?.find(v => !Object.hasOwn(table, v)) : undefined\n return spare !== undefined ? reached(typed(spare)) : unreachable\n}\n\n/**\n * What the board is told for the clip playing (none: ''): the free clips' speeds, the group's selection, and the saved\n * data value that chooses it. Every key is written whole, so the clip played before is let go.\n */\nexport function playSettingsOf(asset: FigureAsset, playing: string) {\n const play = playing ? clipPlayOf(asset, playing) : null\n const clips = Object.fromEntries([...new Set((asset.drivers ?? []).filter(d => !(asset.motionGroups ?? []).some(g => g.clips.includes(d.clip))).map(d => d.clip))].map(c => [c, c === playing ? 1 : 0]))\n const motion = play && play.kind !== 'free' && play.kind !== 'unreachable' ? { [play.group]: { clip: playing, speed: 1, paused: false } } : {}\n const figureValues = play?.kind === 'data' ? { [play.accessor]: play.value } : {}\n return { clips, motion, figureValues }\n}\n"]}
|