dotquilt 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/animations.d.ts +105 -0
- package/dist/animations.js +107 -0
- package/dist/catalog-styles.d.ts +4 -0
- package/dist/catalog-styles.js +12 -0
- package/dist/chart-animations.d.ts +36 -0
- package/dist/chart-animations.js +25 -0
- package/dist/chart-styles.d.ts +3 -0
- package/dist/chart-styles.js +23 -0
- package/dist/chart.css +4 -0
- package/dist/chart.d.ts +73 -0
- package/dist/chart.js +80 -0
- package/dist/circle.css +5 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/internal/binding.d.ts +13 -0
- package/dist/internal/binding.js +21 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +13 -0
- package/dist/internal/chart-appearance.d.ts +12 -0
- package/dist/internal/chart-appearance.js +2 -0
- package/dist/internal/chart-definitions.d.ts +19 -0
- package/dist/internal/chart-definitions.js +149 -0
- package/dist/internal/chart-factory.d.ts +12 -0
- package/dist/internal/chart-factory.js +31 -0
- package/dist/internal/chart-field.d.ts +22 -0
- package/dist/internal/chart-field.js +74 -0
- package/dist/internal/chart-idle.d.ts +3 -0
- package/dist/internal/chart-idle.js +96 -0
- package/dist/internal/chart-math.d.ts +8 -0
- package/dist/internal/chart-math.js +19 -0
- package/dist/internal/chart-participant.d.ts +8 -0
- package/dist/internal/chart-participant.js +4 -0
- package/dist/internal/chart-projection.d.ts +11 -0
- package/dist/internal/chart-projection.js +69 -0
- package/dist/internal/content-box.d.ts +11 -0
- package/dist/internal/content-box.js +36 -0
- package/dist/internal/coordinated-handoff.d.ts +4 -0
- package/dist/internal/coordinated-handoff.js +158 -0
- package/dist/internal/count.d.ts +3 -0
- package/dist/internal/count.js +20 -0
- package/dist/internal/defaults.d.ts +11 -0
- package/dist/internal/defaults.js +11 -0
- package/dist/internal/dense/managed-painter.d.ts +4 -0
- package/dist/internal/dense/managed-painter.js +361 -0
- package/dist/internal/dense/runner.d.ts +2 -0
- package/dist/internal/dense/runner.js +5 -0
- package/dist/internal/dense-loader.d.ts +83 -0
- package/dist/internal/dense-loader.js +331 -0
- package/dist/internal/dissolve.d.ts +27 -0
- package/dist/internal/dissolve.js +216 -0
- package/dist/internal/dom.d.ts +23 -0
- package/dist/internal/dom.js +104 -0
- package/dist/internal/effect.d.ts +2 -0
- package/dist/internal/effect.js +17 -0
- package/dist/internal/element.d.ts +89 -0
- package/dist/internal/element.js +384 -0
- package/dist/internal/event-element.d.ts +8 -0
- package/dist/internal/event-element.js +20 -0
- package/dist/internal/frames.d.ts +1 -0
- package/dist/internal/frames.js +51 -0
- package/dist/internal/handoff.d.ts +56 -0
- package/dist/internal/handoff.js +102 -0
- package/dist/internal/ledger.d.ts +13 -0
- package/dist/internal/ledger.js +78 -0
- package/dist/internal/loading-controller.d.ts +62 -0
- package/dist/internal/loading-controller.js +694 -0
- package/dist/internal/marks.d.ts +153 -0
- package/dist/internal/marks.js +227 -0
- package/dist/internal/math.d.ts +2 -0
- package/dist/internal/math.js +2 -0
- package/dist/internal/morph-marks.d.ts +62 -0
- package/dist/internal/morph-marks.js +205 -0
- package/dist/internal/morph.d.ts +35 -0
- package/dist/internal/morph.js +488 -0
- package/dist/internal/paint.d.ts +29 -0
- package/dist/internal/paint.js +1 -0
- package/dist/internal/painter.d.ts +20 -0
- package/dist/internal/painter.js +155 -0
- package/dist/internal/preset-data.d.ts +12 -0
- package/dist/internal/preset-data.js +31 -0
- package/dist/internal/preset.d.ts +22 -0
- package/dist/internal/preset.js +86 -0
- package/dist/internal/pulse.d.ts +7 -0
- package/dist/internal/pulse.js +74 -0
- package/dist/internal/reveal-effect.d.ts +7 -0
- package/dist/internal/reveal-effect.js +24 -0
- package/dist/internal/reveal.d.ts +5 -0
- package/dist/internal/reveal.js +11 -0
- package/dist/internal/runner.d.ts +9 -0
- package/dist/internal/runner.js +70 -0
- package/dist/internal/services.d.ts +12 -0
- package/dist/internal/services.js +159 -0
- package/dist/internal/skeleton-handoff.d.ts +26 -0
- package/dist/internal/skeleton-handoff.js +6 -0
- package/dist/internal/skeleton-source.d.ts +5 -0
- package/dist/internal/skeleton-source.js +106 -0
- package/dist/internal/surface.d.ts +4 -0
- package/dist/internal/surface.js +21 -0
- package/dist/internal/table-definitions.d.ts +27 -0
- package/dist/internal/table-definitions.js +139 -0
- package/dist/internal/table-factory.d.ts +12 -0
- package/dist/internal/table-factory.js +44 -0
- package/dist/internal/table-field.d.ts +12 -0
- package/dist/internal/table-field.js +75 -0
- package/dist/internal/table-model.d.ts +21 -0
- package/dist/internal/table-model.js +117 -0
- package/dist/internal/table-projection.d.ts +7 -0
- package/dist/internal/table-projection.js +110 -0
- package/dist/internal/target-changes.d.ts +3 -0
- package/dist/internal/target-changes.js +2 -0
- package/dist/internal/target-tracker.d.ts +18 -0
- package/dist/internal/target-tracker.js +33 -0
- package/dist/internal/targets.d.ts +3 -0
- package/dist/internal/targets.js +15 -0
- package/dist/internal/text-definitions.d.ts +141 -0
- package/dist/internal/text-definitions.js +228 -0
- package/dist/internal/text-glyphs.d.ts +4 -0
- package/dist/internal/text-glyphs.js +32 -0
- package/dist/internal/text-morph.d.ts +32 -0
- package/dist/internal/text-morph.js +113 -0
- package/dist/internal/text-playback.d.ts +4 -0
- package/dist/internal/text-playback.js +119 -0
- package/dist/internal/text-scramble.d.ts +18 -0
- package/dist/internal/text-scramble.js +47 -0
- package/dist/internal/time.d.ts +9 -0
- package/dist/internal/time.js +13 -0
- package/dist/internal/unstyled.d.ts +8 -0
- package/dist/internal/unstyled.js +8 -0
- package/dist/line.css +5 -0
- package/dist/region-css.d.ts +1 -0
- package/dist/region-css.js +6 -0
- package/dist/region-styles.d.ts +3 -0
- package/dist/region-styles.js +15 -0
- package/dist/region.css +1 -0
- package/dist/region.d.ts +31 -0
- package/dist/region.js +100 -0
- package/dist/register-all.d.ts +2 -0
- package/dist/register-all.js +33 -0
- package/dist/server.d.ts +63 -0
- package/dist/server.js +141 -0
- package/dist/skeleton-animations.d.ts +10 -0
- package/dist/skeleton-animations.js +35 -0
- package/dist/skeleton-block.d.ts +50 -0
- package/dist/skeleton-block.js +260 -0
- package/dist/skeleton-circle.d.ts +5 -0
- package/dist/skeleton-circle.js +11 -0
- package/dist/skeleton-family.css +13 -0
- package/dist/skeleton-line.d.ts +5 -0
- package/dist/skeleton-line.js +11 -0
- package/dist/skeleton-text.css +5 -0
- package/dist/skeleton-text.d.ts +22 -0
- package/dist/skeleton-text.js +115 -0
- package/dist/skeleton.css +4 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.js +4 -0
- package/dist/static-catalog-styles.d.ts +8 -0
- package/dist/static-catalog-styles.js +44 -0
- package/dist/styles.d.ts +4 -0
- package/dist/styles.js +18 -0
- package/dist/table-animations.d.ts +11 -0
- package/dist/table-animations.js +4 -0
- package/dist/table-styles.d.ts +2 -0
- package/dist/table-styles.js +12 -0
- package/dist/table.css +3 -0
- package/dist/table.d.ts +88 -0
- package/dist/table.js +126 -0
- package/dist/text-animations.d.ts +31 -0
- package/dist/text-animations.js +40 -0
- package/dist/text-styles.d.ts +3 -0
- package/dist/text-styles.js +24 -0
- package/dist/text.css +3 -0
- package/dist/text.d.ts +42 -0
- package/dist/text.js +402 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +18 -0
- package/dist/typing-styles.d.ts +1 -0
- package/dist/typing-styles.js +7 -0
- package/dist/typing.css +4 -0
- package/dist/typing.d.ts +35 -0
- package/dist/typing.js +164 -0
- package/package.json +100 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TableColumn, TableInput } from '../table.js';
|
|
2
|
+
export declare const cellKinds: readonly string[];
|
|
3
|
+
export declare function tableColumns(value: readonly TableColumn[] | undefined, report?: (code: string) => void): readonly TableColumn[];
|
|
4
|
+
export declare const tableRows: (value: number, columns: number) => number;
|
|
5
|
+
export declare const tableHeight: (value: number) => number;
|
|
6
|
+
export declare function tableCells(width: number, rows: number, height: number, columns: readonly TableColumn[]): TableInput;
|
|
7
|
+
/** Compact inert vector bands reserve intrinsic height, even without JavaScript. */
|
|
8
|
+
export declare function tableStaticParts(rows: number, height: number, columns: readonly TableColumn[]): readonly Readonly<Record<string, string>>[];
|
|
9
|
+
export declare function staticTableSVG(doc: Document, rows: number, height: number, columns: readonly TableColumn[]): SVGSVGElement;
|
|
10
|
+
export interface StaticTableLayout {
|
|
11
|
+
readonly rows: number;
|
|
12
|
+
readonly rowHeight: number;
|
|
13
|
+
/** Attributes of each `<path>` in the static outline, in drawing order. */
|
|
14
|
+
readonly parts: readonly Readonly<Record<string, string>>[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The static table outline for the given options, normalized the same way
|
|
18
|
+
* TableLoader normalizes them. Pure and DOM-free, so framework adapters can
|
|
19
|
+
* render the identical server markup without registering the element.
|
|
20
|
+
*/
|
|
21
|
+
export declare function staticTableLayout(rows?: number, rowHeight?: number, columns?: readonly TableColumn[]): StaticTableLayout;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export const cellKinds = /* @__PURE__ */ Object.freeze([
|
|
2
|
+
'text',
|
|
3
|
+
'number',
|
|
4
|
+
'badge',
|
|
5
|
+
'date',
|
|
6
|
+
]);
|
|
7
|
+
const defaults = /* @__PURE__ */ Object.freeze([
|
|
8
|
+
Object.freeze({ kind: 'text', width: 1 }),
|
|
9
|
+
Object.freeze({ kind: 'text', width: 1 }),
|
|
10
|
+
Object.freeze({ kind: 'text', width: 1 }),
|
|
11
|
+
]);
|
|
12
|
+
export function tableColumns(value, report = () => { }) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return defaults;
|
|
15
|
+
try {
|
|
16
|
+
if (!Array.isArray(value) || !value.length)
|
|
17
|
+
throw new TypeError();
|
|
18
|
+
if (value.length > 20)
|
|
19
|
+
report('table-limit');
|
|
20
|
+
return Object.freeze(Array.from(value.slice(0, 20), (c) => {
|
|
21
|
+
const kind = c?.kind, width = c?.width ?? 1;
|
|
22
|
+
if (!cellKinds.includes(kind) || !Number.isFinite(width) || width <= 0)
|
|
23
|
+
throw new TypeError();
|
|
24
|
+
return Object.freeze({ kind, width });
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
report('invalid-columns');
|
|
29
|
+
return defaults;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const tableRows = (value, columns) => Math.min(Number.isInteger(value) && value > 0 ? value : 5, 100, Math.floor(1000 / columns));
|
|
33
|
+
export const tableHeight = (value) => Number.isFinite(value) && value > 0 && value <= Number.MAX_SAFE_INTEGER / 100
|
|
34
|
+
? value
|
|
35
|
+
: 32;
|
|
36
|
+
/** Normalize weighted columns once per geometry snapshot, not once per row. */
|
|
37
|
+
function columnLayout(width, columns) {
|
|
38
|
+
const max = Math.max(...columns.map((c) => c.width ?? 1));
|
|
39
|
+
const total = columns.reduce((n, c) => n + (c.width ?? 1) / max, 0);
|
|
40
|
+
let x = 0;
|
|
41
|
+
return columns.map((c) => {
|
|
42
|
+
const w = width * ((c.width ?? 1) / max / total);
|
|
43
|
+
const out = { x, width: w, kind: c.kind };
|
|
44
|
+
x += w;
|
|
45
|
+
return out;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const noGlyphs = /* @__PURE__ */ Object.freeze([]);
|
|
49
|
+
export function tableCells(width, rows, height, columns) {
|
|
50
|
+
const layout = columnLayout(width, columns), cells = [];
|
|
51
|
+
for (let r = 0; r < rows; r++)
|
|
52
|
+
for (const [c, col] of layout.entries())
|
|
53
|
+
cells.push(Object.freeze({
|
|
54
|
+
bounds: Object.freeze({
|
|
55
|
+
x: col.x,
|
|
56
|
+
y: r * height,
|
|
57
|
+
width: col.width,
|
|
58
|
+
height,
|
|
59
|
+
}),
|
|
60
|
+
text: '',
|
|
61
|
+
baseline: (r + 0.7) * height,
|
|
62
|
+
tone: 'base',
|
|
63
|
+
rowId: `row-${r}`,
|
|
64
|
+
rowIndex: r,
|
|
65
|
+
columnIndex: c,
|
|
66
|
+
kind: col.kind,
|
|
67
|
+
glyphs: noGlyphs,
|
|
68
|
+
}));
|
|
69
|
+
return Object.freeze({ kind: 'table', cells: Object.freeze(cells) });
|
|
70
|
+
}
|
|
71
|
+
/** Compact inert vector bands reserve intrinsic height, even without JavaScript. */
|
|
72
|
+
export function tableStaticParts(rows, height, columns) {
|
|
73
|
+
return columnLayout(100, columns).map(({ x, width }) => Object.freeze({
|
|
74
|
+
d: `M ${x + width / 2} ${height / 2} V ${rows * height}`,
|
|
75
|
+
'stroke-width': String(width * 0.7),
|
|
76
|
+
'stroke-dasharray': `${Math.min(8, height * 0.4)} ${height - Math.min(8, height * 0.4)}`,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
export function staticTableSVG(doc, rows, height, columns) {
|
|
80
|
+
const svg = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
81
|
+
for (const [k, v] of Object.entries({
|
|
82
|
+
'data-table-static': '',
|
|
83
|
+
class: 'surface',
|
|
84
|
+
'aria-hidden': 'true',
|
|
85
|
+
part: 'surface',
|
|
86
|
+
width: '100%',
|
|
87
|
+
height: String(rows * height),
|
|
88
|
+
viewBox: `0 0 100 ${rows * height}`,
|
|
89
|
+
preserveAspectRatio: 'none',
|
|
90
|
+
fill: 'none',
|
|
91
|
+
stroke: 'currentColor',
|
|
92
|
+
opacity: '.25',
|
|
93
|
+
}))
|
|
94
|
+
svg.setAttribute(k, v);
|
|
95
|
+
for (const attrs of tableStaticParts(rows, height, columns)) {
|
|
96
|
+
const path = doc.createElementNS(svg.namespaceURI, 'path');
|
|
97
|
+
for (const [k, v] of Object.entries(attrs))
|
|
98
|
+
path.setAttribute(k, v);
|
|
99
|
+
svg.append(path);
|
|
100
|
+
}
|
|
101
|
+
return svg;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The static table outline for the given options, normalized the same way
|
|
105
|
+
* TableLoader normalizes them. Pure and DOM-free, so framework adapters can
|
|
106
|
+
* render the identical server markup without registering the element.
|
|
107
|
+
*/
|
|
108
|
+
export function staticTableLayout(rows = 5, rowHeight = 32, columns) {
|
|
109
|
+
const normalized = tableColumns(columns);
|
|
110
|
+
const count = tableRows(rows, normalized.length);
|
|
111
|
+
const height = tableHeight(rowHeight);
|
|
112
|
+
return {
|
|
113
|
+
rows: count,
|
|
114
|
+
rowHeight: height,
|
|
115
|
+
parts: tableStaticParts(count, height, normalized),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TableInput, TableTargetProvider } from '../table.js';
|
|
2
|
+
export declare const emptyTableInput: TableInput;
|
|
3
|
+
/** Synchronous copied data only. Nested glyphs count against the same 2,048-item cap. */
|
|
4
|
+
export declare function tableProjection(provider: TableTargetProvider | undefined, bounds: Readonly<{
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}>, report: (code: string) => void): TableInput;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { cellKinds } from './table-model.js';
|
|
2
|
+
export const emptyTableInput = /* @__PURE__ */ Object.freeze({
|
|
3
|
+
kind: 'table',
|
|
4
|
+
cells: Object.freeze([]),
|
|
5
|
+
});
|
|
6
|
+
const finite = (n) => {
|
|
7
|
+
if (!Number.isFinite(n))
|
|
8
|
+
throw new TypeError();
|
|
9
|
+
return n;
|
|
10
|
+
};
|
|
11
|
+
const rect = (raw) => {
|
|
12
|
+
const x = finite(raw.x), y = finite(raw.y), width = finite(raw.width), height = finite(raw.height);
|
|
13
|
+
if (width < 0 || height < 0)
|
|
14
|
+
throw new TypeError();
|
|
15
|
+
return Object.freeze({ x, y, width, height });
|
|
16
|
+
};
|
|
17
|
+
/** Synchronous copied data only. Nested glyphs count against the same 2,048-item cap. */
|
|
18
|
+
export function tableProjection(provider, bounds, report) {
|
|
19
|
+
if (!provider)
|
|
20
|
+
return emptyTableInput;
|
|
21
|
+
try {
|
|
22
|
+
let raw = provider(bounds);
|
|
23
|
+
if (raw === null)
|
|
24
|
+
raw = provider(bounds);
|
|
25
|
+
if (raw === null)
|
|
26
|
+
return emptyTableInput;
|
|
27
|
+
if (!raw || typeof raw !== 'object')
|
|
28
|
+
throw new TypeError();
|
|
29
|
+
let used = 0;
|
|
30
|
+
if (raw.kind === 'points' || raw.kind === 'rects') {
|
|
31
|
+
const items = raw.kind === 'points' ? raw.points : raw.rects;
|
|
32
|
+
if (!Array.isArray(items) || items.length > 2048)
|
|
33
|
+
throw new TypeError();
|
|
34
|
+
// The original finite point/rectangle bridge remains accepted. It does not
|
|
35
|
+
// invent text or row ownership; without semantic cells the simple reveal wins.
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
if (raw.kind === 'rects')
|
|
38
|
+
rect(item);
|
|
39
|
+
else {
|
|
40
|
+
finite(item.x);
|
|
41
|
+
finite(item.y);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return emptyTableInput;
|
|
45
|
+
}
|
|
46
|
+
if (raw.kind !== 'table' ||
|
|
47
|
+
!Array.isArray(raw.cells) ||
|
|
48
|
+
raw.cells.length > 1000)
|
|
49
|
+
throw new TypeError();
|
|
50
|
+
const occupied = new Set();
|
|
51
|
+
const rows = new Map();
|
|
52
|
+
const cells = Array.from(raw.cells, (c) => {
|
|
53
|
+
if (++used > 2048)
|
|
54
|
+
throw new TypeError();
|
|
55
|
+
const b = rect(c.bounds), text = c.text, baseline = finite(c.baseline), rowId = c.rowId, rowIndex = c.rowIndex, columnIndex = c.columnIndex, kind = c.kind, tone = c.tone, glyphs = c.glyphs;
|
|
56
|
+
if (typeof text !== 'string' ||
|
|
57
|
+
text.length > 256 ||
|
|
58
|
+
!/^[\x20-\x7e]*$/.test(text) ||
|
|
59
|
+
typeof rowId !== 'string' ||
|
|
60
|
+
!rowId ||
|
|
61
|
+
rowId.length > 256 ||
|
|
62
|
+
!Number.isInteger(rowIndex) ||
|
|
63
|
+
rowIndex < 0 ||
|
|
64
|
+
rowIndex >= 100 ||
|
|
65
|
+
!Number.isInteger(columnIndex) ||
|
|
66
|
+
columnIndex < 0 ||
|
|
67
|
+
columnIndex >= 20 ||
|
|
68
|
+
!cellKinds.includes(kind) ||
|
|
69
|
+
!['base', 'accent'].includes(tone) ||
|
|
70
|
+
!Array.isArray(glyphs) ||
|
|
71
|
+
glyphs.length > 256 ||
|
|
72
|
+
used + glyphs.length > 2048)
|
|
73
|
+
throw new TypeError();
|
|
74
|
+
const key = `${rowIndex}:${columnIndex}`;
|
|
75
|
+
if (occupied.has(key))
|
|
76
|
+
throw new TypeError();
|
|
77
|
+
occupied.add(key);
|
|
78
|
+
if ((rows.has(rowIndex) && rows.get(rowIndex) !== rowId) ||
|
|
79
|
+
(rows.has(rowId) && rows.get(rowId) !== rowIndex))
|
|
80
|
+
throw new TypeError();
|
|
81
|
+
rows.set(rowIndex, rowId);
|
|
82
|
+
rows.set(rowId, rowIndex);
|
|
83
|
+
used += glyphs.length;
|
|
84
|
+
const copied = Object.freeze(Array.from(glyphs, (g) => {
|
|
85
|
+
const character = g.character;
|
|
86
|
+
if (typeof character !== 'string' ||
|
|
87
|
+
character.length !== 1 ||
|
|
88
|
+
!/^[\x20-\x7e]$/.test(character))
|
|
89
|
+
throw new TypeError();
|
|
90
|
+
return Object.freeze({ character, bounds: rect(g.bounds) });
|
|
91
|
+
}));
|
|
92
|
+
return Object.freeze({
|
|
93
|
+
bounds: b,
|
|
94
|
+
text,
|
|
95
|
+
baseline,
|
|
96
|
+
rowId,
|
|
97
|
+
rowIndex,
|
|
98
|
+
columnIndex,
|
|
99
|
+
kind,
|
|
100
|
+
tone,
|
|
101
|
+
glyphs: copied,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
return Object.freeze({ kind: 'table', cells: Object.freeze(cells) });
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
report('invalid-geometry');
|
|
108
|
+
return emptyTableInput;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RevealFrame, RevealTarget } from '../animations.js';
|
|
2
|
+
import type { createReveal } from './reveal.js';
|
|
3
|
+
export interface TargetTracker {
|
|
4
|
+
changed(next: readonly RevealTarget[]): boolean;
|
|
5
|
+
check(): void;
|
|
6
|
+
draw?: (id: string, frame: RevealFrame) => void;
|
|
7
|
+
}
|
|
8
|
+
export type TargetFactory = (content: HTMLElement, targets: readonly RevealTarget[], own: (animation: Animation) => void) => TargetTracker;
|
|
9
|
+
interface TargetRecord extends RevealTarget {
|
|
10
|
+
effect?: ReturnType<typeof createReveal>;
|
|
11
|
+
}
|
|
12
|
+
/** Records retain ownership checks without importing custom target drawing. */
|
|
13
|
+
export declare function createTargetTracker(content: HTMLElement, targets: readonly RevealTarget[]): {
|
|
14
|
+
records: TargetRecord[];
|
|
15
|
+
changed: (next: readonly RevealTarget[]) => boolean;
|
|
16
|
+
check(): void;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ancestors } from './dom.js';
|
|
2
|
+
import { targetChanges } from './target-changes.js';
|
|
3
|
+
/** Records retain ownership checks without importing custom target drawing. */
|
|
4
|
+
export function createTargetTracker(content, targets) {
|
|
5
|
+
const owner = content.getRootNode();
|
|
6
|
+
const assigned = content.firstElementChild.assignedElements();
|
|
7
|
+
const records = targets.map(({ id, element }, i) => {
|
|
8
|
+
if (!id ||
|
|
9
|
+
targets.some((t, j) => j < i && (t.id === id || t.element === element)) ||
|
|
10
|
+
element.matches('dotquilt-region,dotquilt-text-loader') ||
|
|
11
|
+
ancestors(element).find((el) => el.matches('dotquilt-region,dotquilt-text-loader')) !== owner.host ||
|
|
12
|
+
!assigned.some((el) => el === element || el.contains(element)))
|
|
13
|
+
throw new TypeError();
|
|
14
|
+
return { id, element };
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
records,
|
|
18
|
+
changed: targetChanges(targets),
|
|
19
|
+
check() {
|
|
20
|
+
for (const { element, effect } of records)
|
|
21
|
+
if (element
|
|
22
|
+
.getAnimations()
|
|
23
|
+
.some((animation) => animation !== effect?.animation &&
|
|
24
|
+
animation.effect &&
|
|
25
|
+
animation.effect
|
|
26
|
+
.getKeyframes()
|
|
27
|
+
.some((frame) => 'opacity' in frame ||
|
|
28
|
+
'translate' in frame ||
|
|
29
|
+
'clipPath' in frame)))
|
|
30
|
+
throw new TypeError();
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createReveal } from './reveal.js';
|
|
2
|
+
import { createTargetTracker } from './target-tracker.js';
|
|
3
|
+
export function createTargets(content, targets, own) {
|
|
4
|
+
const tracker = createTargetTracker(content, targets);
|
|
5
|
+
return {
|
|
6
|
+
...tracker,
|
|
7
|
+
draw(id, frame) {
|
|
8
|
+
const target = tracker.records.find((t) => t.id === id);
|
|
9
|
+
if (!target?.element.isConnected)
|
|
10
|
+
throw new TypeError();
|
|
11
|
+
target.effect ??= createReveal(target.element, own, false);
|
|
12
|
+
target.effect.draw(frame);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { AnimationSurface, Dot, RevealFrame } from '../animations.js';
|
|
2
|
+
import type { LabelPulseOptions, ScrambleOptions, TextHandoffOptions } from '../text-animations.js';
|
|
3
|
+
import { brand } from './binding.js';
|
|
4
|
+
import { createTextRunner } from './text-playback.js';
|
|
5
|
+
export interface TextDraw {
|
|
6
|
+
readonly surface: AnimationSurface<'text'>;
|
|
7
|
+
readonly timeMs: number;
|
|
8
|
+
dot(value: Dot): void;
|
|
9
|
+
}
|
|
10
|
+
export interface TextReveal<P = unknown> extends TextDraw {
|
|
11
|
+
readonly progress: number;
|
|
12
|
+
readonly prepared: Readonly<P>;
|
|
13
|
+
/** Whether the text runs right to left. */
|
|
14
|
+
readonly rtl?: boolean;
|
|
15
|
+
reveal(frame: TextRevealFrame): void;
|
|
16
|
+
}
|
|
17
|
+
/** A reveal frame; `front` wipes the text in behind a soft edge `edge` px wide. */
|
|
18
|
+
export interface TextRevealFrame extends RevealFrame {
|
|
19
|
+
readonly front?: number;
|
|
20
|
+
readonly edge?: number;
|
|
21
|
+
readonly rtl?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function textBinding<P extends 'idle' | 'handoff', O extends object>(definition: {
|
|
24
|
+
family: 'text';
|
|
25
|
+
phase: P;
|
|
26
|
+
id: string;
|
|
27
|
+
}, options: O): import('../animations.js').AnimationBinding<'text', P, O>;
|
|
28
|
+
export declare const noise: (seed: number) => number;
|
|
29
|
+
export declare const randomCharacter: (character: string, seed: number) => string;
|
|
30
|
+
declare function still(context: TextDraw): undefined;
|
|
31
|
+
export declare const scrambleDefinition: Readonly<{
|
|
32
|
+
family: 'text';
|
|
33
|
+
phase: 'idle';
|
|
34
|
+
id: "dotquilt/scramble";
|
|
35
|
+
runner: typeof createTextRunner;
|
|
36
|
+
still: typeof still;
|
|
37
|
+
/**
|
|
38
|
+
* design/SPEC.md: each character changes every ~280 ms (with a small
|
|
39
|
+
* per-character offset, so they don't flip together) and cross-fades to
|
|
40
|
+
* the next over 260 ms. A teal glow drifts across every 2.8 s.
|
|
41
|
+
*/
|
|
42
|
+
frame(context: TextDraw, options: ScrambleOptions): undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const labelPulseDefinition: Readonly<{
|
|
45
|
+
family: 'text';
|
|
46
|
+
phase: "idle";
|
|
47
|
+
id: `dotquilt/${string}`;
|
|
48
|
+
runner: typeof createTextRunner;
|
|
49
|
+
handoff: import("./handoff.js").HandoffFactory;
|
|
50
|
+
} & {
|
|
51
|
+
still: typeof still;
|
|
52
|
+
frame(context: TextDraw, options: LabelPulseOptions): undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const lockDefinition: Readonly<{
|
|
55
|
+
family: 'text';
|
|
56
|
+
phase: 'handoff';
|
|
57
|
+
id: "dotquilt/lock";
|
|
58
|
+
handoff: import("./handoff.js").HandoffFactory;
|
|
59
|
+
duration(surface: AnimationSurface<'text'>, options: TextHandoffOptions): number;
|
|
60
|
+
prepare(surface: AnimationSurface<'text'>, options: TextHandoffOptions): {
|
|
61
|
+
span: number;
|
|
62
|
+
length: number;
|
|
63
|
+
};
|
|
64
|
+
frame(context: TextReveal<{
|
|
65
|
+
span: number;
|
|
66
|
+
length: number;
|
|
67
|
+
}>, options: TextHandoffOptions): undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export declare const printDefinition: Readonly<{
|
|
70
|
+
family: 'text';
|
|
71
|
+
phase: "handoff";
|
|
72
|
+
id: `dotquilt/${string}`;
|
|
73
|
+
runner: typeof createTextRunner;
|
|
74
|
+
handoff: import("./handoff.js").HandoffFactory;
|
|
75
|
+
} & {
|
|
76
|
+
prepare: (surface: AnimationSurface<'text'>, options: TextHandoffOptions) => {
|
|
77
|
+
span: number;
|
|
78
|
+
length: number;
|
|
79
|
+
};
|
|
80
|
+
duration(surface: AnimationSurface<'text'>, options: TextHandoffOptions): number;
|
|
81
|
+
frame(context: TextReveal<{
|
|
82
|
+
span: number;
|
|
83
|
+
length: number;
|
|
84
|
+
}>, options: TextHandoffOptions): undefined;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const fadeDefinition: Readonly<{
|
|
87
|
+
family: 'text';
|
|
88
|
+
phase: "handoff";
|
|
89
|
+
id: `dotquilt/${string}`;
|
|
90
|
+
runner: typeof createTextRunner;
|
|
91
|
+
handoff: import("./handoff.js").HandoffFactory;
|
|
92
|
+
} & {
|
|
93
|
+
duration(_surface: AnimationSurface<'text'>, options: {
|
|
94
|
+
duration: number;
|
|
95
|
+
}): number;
|
|
96
|
+
prepare(): undefined;
|
|
97
|
+
frame(context: TextReveal<undefined>): undefined;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const defaultTextIdle: Readonly<{
|
|
100
|
+
contractVersion: 1;
|
|
101
|
+
family: 'text';
|
|
102
|
+
phase: 'idle';
|
|
103
|
+
id: "dotquilt/scramble";
|
|
104
|
+
options: Readonly<{
|
|
105
|
+
changesPerSecond: number;
|
|
106
|
+
}>;
|
|
107
|
+
[brand]: Readonly<{
|
|
108
|
+
family: 'text';
|
|
109
|
+
phase: 'idle';
|
|
110
|
+
id: "dotquilt/scramble";
|
|
111
|
+
runner: typeof createTextRunner;
|
|
112
|
+
still: typeof still;
|
|
113
|
+
/**
|
|
114
|
+
* design/SPEC.md: each character changes every ~280 ms (with a small
|
|
115
|
+
* per-character offset, so they don't flip together) and cross-fades to
|
|
116
|
+
* the next over 260 ms. A teal glow drifts across every 2.8 s.
|
|
117
|
+
*/
|
|
118
|
+
frame(context: TextDraw, options: ScrambleOptions): undefined;
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const defaultTextHandoff: Readonly<{
|
|
122
|
+
contractVersion: 1;
|
|
123
|
+
family: 'text';
|
|
124
|
+
phase: 'handoff';
|
|
125
|
+
id: "dotquilt/text/morph-wipe";
|
|
126
|
+
options: Readonly<{
|
|
127
|
+
travel: 0.34;
|
|
128
|
+
wipeStart: 0.46;
|
|
129
|
+
edge: 36;
|
|
130
|
+
}>;
|
|
131
|
+
[brand]: Readonly<{
|
|
132
|
+
family: 'text';
|
|
133
|
+
phase: 'handoff';
|
|
134
|
+
id: "dotquilt/text/morph-wipe";
|
|
135
|
+
handoff: import("./handoff.js").HandoffFactory;
|
|
136
|
+
duration(surface: AnimationSurface<'text'>): 150 | 1100;
|
|
137
|
+
prepare(surface: AnimationSurface<'text'>): readonly import("./text-morph.js").Travel[];
|
|
138
|
+
frame(context: TextReveal<readonly import("./text-morph.js").Travel[]>, options: import("./text-morph.js").TextMorphOptions): undefined;
|
|
139
|
+
}>;
|
|
140
|
+
}>;
|
|
141
|
+
export {};
|