@things-factory/figure-viewer 10.1.247 → 10.1.258
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/data-connection.ts +82 -0
- package/client/data-words.ts +31 -0
- package/client/figure-asset-viewer.ts +124 -10
- package/client/figure-data-list.ts +87 -0
- package/client/figure-data-report.ts +142 -0
- package/client/index.ts +5 -0
- package/client/unit-words.ts +11 -0
- package/dist-client/data-connection.d.ts +32 -0
- package/dist-client/data-connection.js +49 -0
- package/dist-client/data-connection.js.map +1 -0
- package/dist-client/data-words.d.ts +9 -0
- package/dist-client/data-words.js +25 -0
- package/dist-client/data-words.js.map +1 -0
- package/dist-client/figure-asset-viewer.d.ts +13 -3
- package/dist-client/figure-asset-viewer.js +115 -7
- package/dist-client/figure-asset-viewer.js.map +1 -1
- package/dist-client/figure-data-list.d.ts +25 -0
- package/dist-client/figure-data-list.js +88 -0
- package/dist-client/figure-data-list.js.map +1 -0
- package/dist-client/figure-data-report.d.ts +59 -0
- package/dist-client/figure-data-report.js +96 -0
- package/dist-client/figure-data-report.js.map +1 -0
- package/dist-client/index.d.ts +5 -0
- package/dist-client/index.js +5 -0
- package/dist-client/index.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/unit-words.d.ts +5 -0
- package/dist-client/unit-words.js +12 -0
- package/dist-client/unit-words.js.map +1 -0
- package/package.json +4 -4
- package/test/data-connection.test.ts +35 -0
- package/test/detail-motion.test.ts +3 -1
- package/test/figure-data-report.test.ts +88 -0
- package/translations/en.json +67 -1
- package/translations/es.json +67 -1
- package/translations/ja.json +67 -1
- package/translations/ko.json +67 -1
- package/translations/ms.json +67 -1
- package/translations/zh.json +67 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
4
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
|
+
import { i18next, localize } from '@operato/i18n';
|
|
6
|
+
import { dataMoveOf } from './data-connection.js';
|
|
7
|
+
import { itemFieldWords, kindWords, moveWords } from './data-words.js';
|
|
8
|
+
import { SidePanelStyles } from './side-panel-styles.js';
|
|
9
|
+
/**
|
|
10
|
+
* A figure's data as a person reads it (data binding design, decision 3): the shape as a tree, each value now and where
|
|
11
|
+
* it came from when there is one, what each field moves, a control the board's own state values hold, why data was
|
|
12
|
+
* refused, the fields the data has that the shape does not name, and an example to copy. The board's 「피규어 데이터」
|
|
13
|
+
* section shows a placed figure's; the preview's 「데이터」 tab shows a release's, with no data given, so each field
|
|
14
|
+
* says its kind (user 2026-11-05: what a board or a connector binds to, seen before placing it).
|
|
15
|
+
*/
|
|
16
|
+
let FigureDataList = class FigureDataList extends localize(i18next)(LitElement) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.copied = false;
|
|
20
|
+
}
|
|
21
|
+
/* The copy is the side panel's action under what it acts on (SidePanelStyles' button[act]), not a boxed button. */
|
|
22
|
+
static { this.styles = [SidePanelStyles, css `
|
|
23
|
+
:host { display: grid; gap: 6px; }
|
|
24
|
+
ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
|
|
25
|
+
li { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
|
|
26
|
+
li [meta] { margin-left: auto; color: var(--md-sys-color-on-surface-variant); text-align: right; }
|
|
27
|
+
[source] { padding: 0 4px; border-radius: 4px; background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }
|
|
28
|
+
[moves], [hint] { width: 100%; color: var(--md-sys-color-on-surface-variant); }
|
|
29
|
+
p { margin: 0; }
|
|
30
|
+
[warn] { color: var(--md-sys-color-error); }
|
|
31
|
+
`]; }
|
|
32
|
+
render() {
|
|
33
|
+
const report = this.report;
|
|
34
|
+
if (!report)
|
|
35
|
+
return nothing;
|
|
36
|
+
return html `<ul>
|
|
37
|
+
${report.rows.map(row => this.renderRow(row))}
|
|
38
|
+
</ul>
|
|
39
|
+
${report.refused.length
|
|
40
|
+
? html `<p warn>
|
|
41
|
+
${report.refused.map(r => r.issues?.length
|
|
42
|
+
? r.issues.map(i => i18next.t('figure.text.board-data-value-' + i.reason, { path: i.path || '-' })).join(' · ')
|
|
43
|
+
: i18next.t('figure.text.board-data-refused', { reason: r.reason }))}
|
|
44
|
+
</p>`
|
|
45
|
+
: nothing}
|
|
46
|
+
${report.unused.length ? html `<p hint>${i18next.t('figure.text.board-data-unused', { fields: report.unused.join(', ') })}</p>` : nothing}
|
|
47
|
+
<button act @click=${() => this.copy(report)}>
|
|
48
|
+
<md-icon>${this.copied ? 'check' : 'content_copy'}</md-icon>${i18next.t(this.copied ? 'figure.button.board-data-copied' : 'figure.button.board-data-copy-example')}
|
|
49
|
+
</button>`;
|
|
50
|
+
}
|
|
51
|
+
renderRow(row) {
|
|
52
|
+
const shown = (v) => (typeof v === 'boolean' ? i18next.t(v ? 'figure.label.board-data-true' : 'figure.label.board-data-false') : String(v));
|
|
53
|
+
return html `<li style="padding-left: ${row.depth * 12}px">
|
|
54
|
+
<span>${row.name}${row.label ? html ` <small>${row.label}</small>` : nothing}</span>
|
|
55
|
+
<span meta>
|
|
56
|
+
${row.value !== undefined ? html `<b>${shown(row.value)}</b>` : row.count !== undefined ? html `<b>${i18next.t('figure.label.board-data-count', { count: row.count })}</b>` : nothing}
|
|
57
|
+
${row.source ? html `<span source>${i18next.t('figure.label.board-data-source-' + row.source)}</span>` : nothing}
|
|
58
|
+
${row.value === undefined && row.count === undefined ? kindWords(row.node) : nothing}
|
|
59
|
+
</span>
|
|
60
|
+
${row.itemField ? html `<span moves>${itemFieldWords(row.itemField)}</span>` : nothing}
|
|
61
|
+
${row.behaviors.length ? html `<span moves>→ ${row.behaviors.map(b => moveWords(dataMoveOf(this.report.asset, b))).join(', ')}</span>` : nothing}
|
|
62
|
+
${row.heldByBoard.length ? html `<span warn moves>${i18next.t('figure.text.board-data-held', { controls: row.heldByBoard.join(', ') })}</span>` : nothing}
|
|
63
|
+
</li>`;
|
|
64
|
+
}
|
|
65
|
+
async copy(report) {
|
|
66
|
+
try {
|
|
67
|
+
await navigator.clipboard.writeText(JSON.stringify(report.example, null, 2));
|
|
68
|
+
this.copied = true;
|
|
69
|
+
setTimeout(() => (this.copied = false), 1500);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* No clipboard here (an insecure page): the button stays as it was. */
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
__decorate([
|
|
77
|
+
property({ attribute: false }),
|
|
78
|
+
__metadata("design:type", Object)
|
|
79
|
+
], FigureDataList.prototype, "report", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
state(),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], FigureDataList.prototype, "copied", void 0);
|
|
84
|
+
FigureDataList = __decorate([
|
|
85
|
+
customElement('figure-data-list')
|
|
86
|
+
], FigureDataList);
|
|
87
|
+
export { FigureDataList };
|
|
88
|
+
//# sourceMappingURL=figure-data-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-data-list.js","sourceRoot":"","sources":["../client/figure-data-list.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CA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Q,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;8CAA0B;AACxC;IAAhB,KAAK,EAAE;;8CAAuB;AAdpB,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA6D1B","sourcesContent":["import '@material/web/icon/icon.js'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { i18next, localize } from '@operato/i18n'\nimport type { FigureDataValue } from '@hatiolab/figure-model'\n\nimport { dataMoveOf } from './data-connection.js'\nimport { itemFieldWords, kindWords, moveWords } from './data-words.js'\nimport type { FigureDataReport } from './figure-data-report.js'\nimport { SidePanelStyles } from './side-panel-styles.js'\n\n/**\n * A figure's data as a person reads it (data binding design, decision 3): the shape as a tree, each value now and where\n * it came from when there is one, what each field moves, a control the board's own state values hold, why data was\n * refused, the fields the data has that the shape does not name, and an example to copy. The board's 「피규어 데이터」\n * section shows a placed figure's; the preview's 「데이터」 tab shows a release's, with no data given, so each field\n * says its kind (user 2026-11-05: what a board or a connector binds to, seen before placing it).\n */\n@customElement('figure-data-list')\nexport class FigureDataList extends localize(i18next)(LitElement) {\n /* The copy is the side panel's action under what it acts on (SidePanelStyles' button[act]), not a boxed button. */\n static styles = [SidePanelStyles, css`\n :host { display: grid; gap: 6px; }\n ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }\n li { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }\n li [meta] { margin-left: auto; color: var(--md-sys-color-on-surface-variant); text-align: right; }\n [source] { padding: 0 4px; border-radius: 4px; background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }\n [moves], [hint] { width: 100%; color: var(--md-sys-color-on-surface-variant); }\n p { margin: 0; }\n [warn] { color: var(--md-sys-color-error); }\n `]\n\n @property({ attribute: false }) report?: FigureDataReport\n @state() private copied = false\n\n render() {\n const report = this.report\n if (!report) return nothing\n return html`<ul>\n ${report.rows.map(row => this.renderRow(row))}\n </ul>\n ${report.refused.length\n ? html`<p warn>\n ${report.refused.map(r =>\n r.issues?.length\n ? r.issues.map(i => i18next.t('figure.text.board-data-value-' + i.reason, { path: i.path || '-' })).join(' · ')\n : i18next.t('figure.text.board-data-refused', { reason: r.reason })\n )}\n </p>`\n : nothing}\n ${report.unused.length ? html`<p hint>${i18next.t('figure.text.board-data-unused', { fields: report.unused.join(', ') })}</p>` : nothing}\n <button act @click=${() => this.copy(report)}>\n <md-icon>${this.copied ? 'check' : 'content_copy'}</md-icon>${i18next.t(this.copied ? 'figure.button.board-data-copied' : 'figure.button.board-data-copy-example')}\n </button>`\n }\n\n private renderRow(row: FigureDataReport['rows'][number]) {\n const shown = (v: FigureDataValue) => (typeof v === 'boolean' ? i18next.t(v ? 'figure.label.board-data-true' : 'figure.label.board-data-false') : String(v))\n return html`<li style=\"padding-left: ${row.depth * 12}px\">\n <span>${row.name}${row.label ? html` <small>${row.label}</small>` : nothing}</span>\n <span meta>\n ${row.value !== undefined ? html`<b>${shown(row.value)}</b>` : row.count !== undefined ? html`<b>${i18next.t('figure.label.board-data-count', { count: row.count })}</b>` : nothing}\n ${row.source ? html`<span source>${i18next.t('figure.label.board-data-source-' + row.source)}</span>` : nothing}\n ${row.value === undefined && row.count === undefined ? kindWords(row.node) : nothing}\n </span>\n ${row.itemField ? html`<span moves>${itemFieldWords(row.itemField)}</span>` : nothing}\n ${row.behaviors.length ? html`<span moves>→ ${row.behaviors.map(b => moveWords(dataMoveOf(this.report!.asset, b))).join(', ')}</span>` : nothing}\n ${row.heldByBoard.length ? html`<span warn moves>${i18next.t('figure.text.board-data-held', { controls: row.heldByBoard.join(', ') })}</span>` : nothing}\n </li>`\n }\n\n private async copy(report: FigureDataReport) {\n try {\n await navigator.clipboard.writeText(JSON.stringify(report.example, null, 2))\n this.copied = true\n setTimeout(() => (this.copied = false), 1500)\n } catch {\n /* No clipboard here (an insecure page): the button stays as it was. */\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'figure-data-list': FigureDataList\n }\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type FigureItemField } from './data-connection.js';
|
|
2
|
+
import type { FigureAsset, FigureDataBehavior, FigureDataNode, FigureDataTargets, FigureDataValue, FigureDataValueIssue } from '@hatiolab/figure-model';
|
|
3
|
+
/** Where a value came from, as things-scene's figure inputs say. */
|
|
4
|
+
export type FigureDataSource = 'live' | 'manual' | 'default' | 'absent';
|
|
5
|
+
/** A placed figure as the section reads it: its asset, its state, and what its figure inputs worked out. */
|
|
6
|
+
export interface FigureDataSnapshot {
|
|
7
|
+
asset: FigureAsset;
|
|
8
|
+
/** The component's data, as the board's data source or a mapping gave it. */
|
|
9
|
+
data: unknown;
|
|
10
|
+
/** The board's own state values (`parameters`), by control. */
|
|
11
|
+
parameters?: Record<string, unknown> | null;
|
|
12
|
+
/** Each binding's value now and its source, by binding id (figure inputs' `dataValues`). */
|
|
13
|
+
values: Readonly<Record<string, {
|
|
14
|
+
value: FigureDataValue | undefined;
|
|
15
|
+
source: FigureDataSource;
|
|
16
|
+
}>>;
|
|
17
|
+
/** Why the last things given were refused (figure inputs' `diagnostics()`). */
|
|
18
|
+
refused: ReadonlyArray<{
|
|
19
|
+
source: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
issues?: FigureDataValueIssue[];
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export interface FigureDataReportRow {
|
|
25
|
+
path: string;
|
|
26
|
+
depth: number;
|
|
27
|
+
name: string;
|
|
28
|
+
label?: string;
|
|
29
|
+
node: FigureDataNode;
|
|
30
|
+
/** A value field's value now; a list's element count in the data. */
|
|
31
|
+
value?: FigureDataValue;
|
|
32
|
+
count?: number;
|
|
33
|
+
source?: FigureDataSource;
|
|
34
|
+
/** What the bindings reading it move: a behavior each, or a table and its targets. */
|
|
35
|
+
behaviors: FigureDataMove[];
|
|
36
|
+
/** Controls it moves that the board's state values hold instead. */
|
|
37
|
+
heldByBoard: string[];
|
|
38
|
+
/**
|
|
39
|
+
* A field inside an items list's element, the part of an item it says: its id, its type, the place it is in, its
|
|
40
|
+
* height in the stack, its status. Its row says that instead of repeating the list's behavior.
|
|
41
|
+
*/
|
|
42
|
+
itemField?: FigureItemField;
|
|
43
|
+
}
|
|
44
|
+
/** What one binding moves: a value binding's behavior, or a table's targets (ADR-0166 3). */
|
|
45
|
+
export type FigureDataMove = FigureDataBehavior | {
|
|
46
|
+
kind: 'table';
|
|
47
|
+
targets: FigureDataTargets;
|
|
48
|
+
};
|
|
49
|
+
export interface FigureDataReport {
|
|
50
|
+
/** The figure, for the names of what its fields move (dataMoveOf). */
|
|
51
|
+
asset: FigureAsset;
|
|
52
|
+
rows: FigureDataReportRow[];
|
|
53
|
+
/** Fields the data has that the shape does not name, as paths (`[]` for a list's elements). */
|
|
54
|
+
unused: string[];
|
|
55
|
+
refused: FigureDataSnapshot['refused'];
|
|
56
|
+
/** Data with every field of the shape, to copy. */
|
|
57
|
+
example: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export declare function figureDataReportOf(s: FigureDataSnapshot): FigureDataReport | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What a figure's data list shows (data binding design, decision 3) -- the board's 「피규어 데이터」 section for a placed
|
|
3
|
+
* figure, the preview's 「데이터」 tab for a release with no data given: the figure's data
|
|
4
|
+
* shape as a tree, each value now and where it came from -- the component's data, a value saved on the board, the
|
|
5
|
+
* shape's default, or none -- what it moves, a control the board's own state values hold over the data, why data was
|
|
6
|
+
* refused, the fields the data has that the shape does not name, and an example to copy.
|
|
7
|
+
*
|
|
8
|
+
* Nothing here reads data: the values and their sources are things-scene's figure inputs', given in. Kept apart from the
|
|
9
|
+
* element so it is tested without a board.
|
|
10
|
+
*/
|
|
11
|
+
import { figureDataExample, figureDataRows } from '@hatiolab/figure-model';
|
|
12
|
+
import { ITEM_FIELDS } from './data-connection.js';
|
|
13
|
+
const isRecord = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
14
|
+
/** The value at a path with no list in it (`A.B`), or undefined. */
|
|
15
|
+
function valueAt(data, path) {
|
|
16
|
+
let at = data;
|
|
17
|
+
for (const name of path.split('.')) {
|
|
18
|
+
if (!isRecord(at))
|
|
19
|
+
return undefined;
|
|
20
|
+
at = at[name];
|
|
21
|
+
}
|
|
22
|
+
return at;
|
|
23
|
+
}
|
|
24
|
+
/** Every field path the data has that the shape does not name. A JSON text in place of an object or a list is not looked into. */
|
|
25
|
+
function unusedOf(data, fields, at, out) {
|
|
26
|
+
if (!isRecord(data))
|
|
27
|
+
return;
|
|
28
|
+
for (const [key, value] of Object.entries(data)) {
|
|
29
|
+
const path = at ? `${at}.${key}` : key;
|
|
30
|
+
const field = fields.find(f => f.name === key);
|
|
31
|
+
if (!field) {
|
|
32
|
+
out.add(path);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
let node = field;
|
|
36
|
+
let value_ = value;
|
|
37
|
+
let p = path;
|
|
38
|
+
while (node.kind === 'list' && Array.isArray(value_)) {
|
|
39
|
+
const item = node.item;
|
|
40
|
+
p = `${p}[]`;
|
|
41
|
+
for (const element of value_)
|
|
42
|
+
if (item.kind === 'object')
|
|
43
|
+
unusedOf(element, item.fields, p, out);
|
|
44
|
+
value_ = undefined;
|
|
45
|
+
node = item;
|
|
46
|
+
}
|
|
47
|
+
if (node.kind === 'object' && isRecord(value_))
|
|
48
|
+
unusedOf(value_, node.fields, p, out);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function figureDataReportOf(s) {
|
|
52
|
+
const di = s.asset.dataInterface;
|
|
53
|
+
if (!di)
|
|
54
|
+
return null;
|
|
55
|
+
const bindings = new Map(di.bindings.map(b => [b.id, b]));
|
|
56
|
+
const held = new Set(Object.keys(s.parameters ?? {}));
|
|
57
|
+
/* The row path of each field an items binding reads inside its list's element, as figureDataRows writes it. */
|
|
58
|
+
const asRow = (accessor) => accessor.replace(/\[\d+\]/g, '[]');
|
|
59
|
+
const itemFields = new Map();
|
|
60
|
+
for (const b of di.bindings)
|
|
61
|
+
if (b.rule !== 'table' && b.behavior.kind === 'items')
|
|
62
|
+
for (const field of ITEM_FIELDS) {
|
|
63
|
+
const rel = b.behavior[field];
|
|
64
|
+
if (rel)
|
|
65
|
+
itemFields.set(`${asRow(b.accessor)}[].${asRow(rel)}`, field);
|
|
66
|
+
}
|
|
67
|
+
const rows = figureDataRows(di).map((row) => {
|
|
68
|
+
const itemField = itemFields.get(row.path);
|
|
69
|
+
/* An item's field says its part of the item; the list's own row says the items go into the places. */
|
|
70
|
+
const reading = row.bindings.map(id => bindings.get(id))
|
|
71
|
+
.filter((b) => !!b && !(itemField && b.rule !== 'table' && b.behavior.kind === 'items'));
|
|
72
|
+
const behaviors = reading.map((b) => (b.rule === 'table' ? { kind: 'table', targets: b.targets } : b.behavior));
|
|
73
|
+
const heldByBoard = behaviors.flatMap(b => (b.kind === 'state' ? [b.input] : b.kind === 'table' ? (b.targets.inputs ?? []) : []).filter(input => held.has(input)));
|
|
74
|
+
const out = { path: row.path, depth: row.depth, name: row.name, ...(row.label ? { label: row.label } : {}), node: row.node, behaviors, heldByBoard, ...(itemField ? { itemField } : {}) };
|
|
75
|
+
if (row.node.kind === 'list') {
|
|
76
|
+
const list = row.path.includes('[]') ? undefined : valueAt(s.data, row.path);
|
|
77
|
+
if (Array.isArray(list))
|
|
78
|
+
out.count = list.length;
|
|
79
|
+
}
|
|
80
|
+
else if (row.node.kind !== 'object') {
|
|
81
|
+
/* The value a binding read: the first that reads this place and is not an items binding (items read the list). */
|
|
82
|
+
const read = reading.find(b => (b.rule === 'table' || b.behavior.kind !== 'items') && s.values[b.id]);
|
|
83
|
+
if (read) {
|
|
84
|
+
const { value, source } = s.values[read.id];
|
|
85
|
+
out.source = source;
|
|
86
|
+
if (value !== undefined)
|
|
87
|
+
out.value = value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
});
|
|
92
|
+
const unused = new Set();
|
|
93
|
+
unusedOf(s.data, di.schema, '', unused);
|
|
94
|
+
return { asset: s.asset, rows, unused: [...unused], refused: s.refused, example: figureDataExample(di) };
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=figure-data-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-data-report.js","sourceRoot":"","sources":["../client/figure-data-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAwB,MAAM,sBAAsB,CAAA;AAuDxE,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAEhH,oEAAoE;AACpE,SAAS,OAAO,CAAC,IAAa,EAAE,IAAY;IAC1C,IAAI,EAAE,GAAY,IAAI,CAAA;IACtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAAE,OAAO,SAAS,CAAA;QACnC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAED,kIAAkI;AAClI,SAAS,QAAQ,CAAC,IAAa,EAAE,MAAwD,EAAE,EAAU,EAAE,GAAgB;IACrH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAM;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC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CAAC","sourcesContent":["/*\n * What a figure's data list shows (data binding design, decision 3) -- the board's 「피규어 데이터」 section for a placed\n * figure, the preview's 「데이터」 tab for a release with no data given: the figure's data\n * shape as a tree, each value now and where it came from -- the component's data, a value saved on the board, the\n * shape's default, or none -- what it moves, a control the board's own state values hold over the data, why data was\n * refused, the fields the data has that the shape does not name, and an example to copy.\n *\n * Nothing here reads data: the values and their sources are things-scene's figure inputs', given in. Kept apart from the\n * element so it is tested without a board.\n */\nimport { figureDataExample, figureDataRows } from '@hatiolab/figure-model'\nimport { ITEM_FIELDS, type FigureItemField } from './data-connection.js'\nimport type { FigureAsset, FigureDataBehavior, FigureDataBinding, FigureDataNode, FigureDataTargets, FigureDataValue, FigureDataValueIssue } from '@hatiolab/figure-model'\n\n/** Where a value came from, as things-scene's figure inputs say. */\nexport type FigureDataSource = 'live' | 'manual' | 'default' | 'absent'\n\n/** A placed figure as the section reads it: its asset, its state, and what its figure inputs worked out. */\nexport interface FigureDataSnapshot {\n asset: FigureAsset\n /** The component's data, as the board's data source or a mapping gave it. */\n data: unknown\n /** The board's own state values (`parameters`), by control. */\n parameters?: Record<string, unknown> | null\n /** Each binding's value now and its source, by binding id (figure inputs' `dataValues`). */\n values: Readonly<Record<string, { value: FigureDataValue | undefined; source: FigureDataSource }>>\n /** Why the last things given were refused (figure inputs' `diagnostics()`). */\n refused: ReadonlyArray<{ source: string; reason: string; issues?: FigureDataValueIssue[] }>\n}\n\nexport interface FigureDataReportRow {\n path: string\n depth: number\n name: string\n label?: string\n node: FigureDataNode\n /** A value field's value now; a list's element count in the data. */\n value?: FigureDataValue\n count?: number\n source?: FigureDataSource\n /** What the bindings reading it move: a behavior each, or a table and its targets. */\n behaviors: FigureDataMove[]\n /** Controls it moves that the board's state values hold instead. */\n heldByBoard: string[]\n /**\n * A field inside an items list's element, the part of an item it says: its id, its type, the place it is in, its\n * height in the stack, its status. Its row says that instead of repeating the list's behavior.\n */\n itemField?: FigureItemField\n}\n\n\n/** What one binding moves: a value binding's behavior, or a table's targets (ADR-0166 3). */\nexport type FigureDataMove = FigureDataBehavior | { kind: 'table'; targets: FigureDataTargets }\n\nexport interface FigureDataReport {\n /** The figure, for the names of what its fields move (dataMoveOf). */\n asset: FigureAsset\n rows: FigureDataReportRow[]\n /** Fields the data has that the shape does not name, as paths (`[]` for a list's elements). */\n unused: string[]\n refused: FigureDataSnapshot['refused']\n /** Data with every field of the shape, to copy. */\n example: Record<string, unknown>\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v)\n\n/** The value at a path with no list in it (`A.B`), or undefined. */\nfunction valueAt(data: unknown, path: string): unknown {\n let at: unknown = data\n for (const name of path.split('.')) {\n if (!isRecord(at)) return undefined\n at = at[name]\n }\n return at\n}\n\n/** Every field path the data has that the shape does not name. A JSON text in place of an object or a list is not looked into. */\nfunction unusedOf(data: unknown, fields: ReadonlyArray<{ name: string } & FigureDataNode>, at: string, out: Set<string>): void {\n if (!isRecord(data)) return\n for (const [key, value] of Object.entries(data)) {\n const path = at ? `${at}.${key}` : key\n const field = fields.find(f => f.name === key)\n if (!field) {\n out.add(path)\n continue\n }\n let node: FigureDataNode = field\n let value_: unknown = value\n let p = path\n while (node.kind === 'list' && Array.isArray(value_)) {\n const item: FigureDataNode = node.item\n p = `${p}[]`\n for (const element of value_) if (item.kind === 'object') unusedOf(element, item.fields, p, out)\n value_ = undefined\n node = item\n }\n if (node.kind === 'object' && isRecord(value_)) unusedOf(value_, node.fields, p, out)\n }\n}\n\nexport function figureDataReportOf(s: FigureDataSnapshot): FigureDataReport | null {\n const di = s.asset.dataInterface\n if (!di) return null\n const bindings = new Map(di.bindings.map(b => [b.id, b] as const))\n const held = new Set(Object.keys(s.parameters ?? {}))\n /* The row path of each field an items binding reads inside its list's element, as figureDataRows writes it. */\n const asRow = (accessor: string) => accessor.replace(/\\[\\d+\\]/g, '[]')\n const itemFields = new Map<string, FigureItemField>()\n for (const b of di.bindings)\n if (b.rule !== 'table' && b.behavior.kind === 'items')\n for (const field of ITEM_FIELDS) {\n const rel = b.behavior[field]\n if (rel) itemFields.set(`${asRow(b.accessor)}[].${asRow(rel)}`, field)\n }\n const rows = figureDataRows(di).map((row): FigureDataReportRow => {\n const itemField = itemFields.get(row.path)\n /* An item's field says its part of the item; the list's own row says the items go into the places. */\n const reading = row.bindings.map(id => bindings.get(id))\n .filter((b): b is FigureDataBinding => !!b && !(itemField && b.rule !== 'table' && b.behavior.kind === 'items'))\n const behaviors = reading.map((b): FigureDataMove => (b.rule === 'table' ? { kind: 'table', targets: b.targets } : b.behavior))\n const heldByBoard = behaviors.flatMap(b => (b.kind === 'state' ? [b.input] : b.kind === 'table' ? (b.targets.inputs ?? []) : []).filter(input => held.has(input)))\n const out: FigureDataReportRow = { path: row.path, depth: row.depth, name: row.name, ...(row.label ? { label: row.label } : {}), node: row.node, behaviors, heldByBoard, ...(itemField ? { itemField } : {}) }\n if (row.node.kind === 'list') {\n const list = row.path.includes('[]') ? undefined : valueAt(s.data, row.path)\n if (Array.isArray(list)) out.count = list.length\n } else if (row.node.kind !== 'object') {\n /* The value a binding read: the first that reads this place and is not an items binding (items read the list). */\n const read = reading.find(b => (b.rule === 'table' || b.behavior.kind !== 'items') && s.values[b.id])\n if (read) {\n const { value, source } = s.values[read.id]!\n out.source = source\n if (value !== undefined) out.value = value\n }\n }\n return out\n })\n const unused = new Set<string>()\n unusedOf(s.data, di.schema, '', unused)\n return { asset: s.asset, rows, unused: [...unused], refused: s.refused, example: figureDataExample(di) }\n}\n"]}
|
package/dist-client/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from './capability-rung.js';
|
|
2
2
|
export * from './controls.js';
|
|
3
|
+
export * from './data-connection.js';
|
|
4
|
+
export * from './data-words.js';
|
|
3
5
|
export * from './detail-facts.js';
|
|
4
6
|
export * from './detail-motion.js';
|
|
7
|
+
export * from './figure-data-list.js';
|
|
8
|
+
export * from './figure-data-report.js';
|
|
5
9
|
export * from './figure-asset-viewer.js';
|
|
6
10
|
export * from './figure-facts-list.js';
|
|
7
11
|
export * from './figure-thumb-mark.js';
|
|
8
12
|
export * from './figure-view.js';
|
|
9
13
|
export * from './preview-model.js';
|
|
10
14
|
export * from './side-panel-styles.js';
|
|
15
|
+
export * from './unit-words.js';
|
package/dist-client/index.js
CHANGED
|
@@ -4,12 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export * from './capability-rung.js';
|
|
6
6
|
export * from './controls.js';
|
|
7
|
+
export * from './data-connection.js';
|
|
8
|
+
export * from './data-words.js';
|
|
7
9
|
export * from './detail-facts.js';
|
|
8
10
|
export * from './detail-motion.js';
|
|
11
|
+
export * from './figure-data-list.js';
|
|
12
|
+
export * from './figure-data-report.js';
|
|
9
13
|
export * from './figure-asset-viewer.js';
|
|
10
14
|
export * from './figure-facts-list.js';
|
|
11
15
|
export * from './figure-thumb-mark.js';
|
|
12
16
|
export * from './figure-view.js';
|
|
13
17
|
export * from './preview-model.js';
|
|
14
18
|
export * from './side-panel-styles.js';
|
|
19
|
+
export * from './unit-words.js';
|
|
15
20
|
//# sourceMappingURL=index.js.map
|
package/dist-client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA","sourcesContent":["/*\n * A released figure on a live canvas, shared by figure-ui (the authoring catalogue) and figure-library (a board\n * server's library). Importers use the files by path (`@things-factory/figure-viewer/dist-client/<file>.js`).\n */\nexport * from './capability-rung.js'\nexport * from './controls.js'\nexport * from './detail-facts.js'\nexport * from './detail-motion.js'\nexport * from './figure-asset-viewer.js'\nexport * from './figure-facts-list.js'\nexport * from './figure-thumb-mark.js'\nexport * from './figure-view.js'\nexport * from './preview-model.js'\nexport * from './side-panel-styles.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA","sourcesContent":["/*\n * A released figure on a live canvas, shared by figure-ui (the authoring catalogue) and figure-library (a board\n * server's library). Importers use the files by path (`@things-factory/figure-viewer/dist-client/<file>.js`).\n */\nexport * from './capability-rung.js'\nexport * from './controls.js'\nexport * from './data-connection.js'\nexport * from './data-words.js'\nexport * from './detail-facts.js'\nexport * from './detail-motion.js'\nexport * from './figure-data-list.js'\nexport * from './figure-data-report.js'\nexport * from './figure-asset-viewer.js'\nexport * from './figure-facts-list.js'\nexport * from './figure-thumb-mark.js'\nexport * from './figure-view.js'\nexport * from './preview-model.js'\nexport * from './side-panel-styles.js'\nexport * from './unit-words.js'\n"]}
|