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.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -2
  3. package/dist/animations.d.ts +105 -0
  4. package/dist/animations.js +107 -0
  5. package/dist/catalog-styles.d.ts +4 -0
  6. package/dist/catalog-styles.js +12 -0
  7. package/dist/chart-animations.d.ts +36 -0
  8. package/dist/chart-animations.js +25 -0
  9. package/dist/chart-styles.d.ts +3 -0
  10. package/dist/chart-styles.js +23 -0
  11. package/dist/chart.css +4 -0
  12. package/dist/chart.d.ts +73 -0
  13. package/dist/chart.js +80 -0
  14. package/dist/circle.css +5 -0
  15. package/dist/index.d.ts +11 -0
  16. package/dist/index.js +9 -0
  17. package/dist/internal/binding.d.ts +13 -0
  18. package/dist/internal/binding.js +21 -0
  19. package/dist/internal/capture.d.ts +4 -0
  20. package/dist/internal/capture.js +13 -0
  21. package/dist/internal/chart-appearance.d.ts +12 -0
  22. package/dist/internal/chart-appearance.js +2 -0
  23. package/dist/internal/chart-definitions.d.ts +19 -0
  24. package/dist/internal/chart-definitions.js +149 -0
  25. package/dist/internal/chart-factory.d.ts +12 -0
  26. package/dist/internal/chart-factory.js +31 -0
  27. package/dist/internal/chart-field.d.ts +22 -0
  28. package/dist/internal/chart-field.js +74 -0
  29. package/dist/internal/chart-idle.d.ts +3 -0
  30. package/dist/internal/chart-idle.js +96 -0
  31. package/dist/internal/chart-math.d.ts +8 -0
  32. package/dist/internal/chart-math.js +19 -0
  33. package/dist/internal/chart-participant.d.ts +8 -0
  34. package/dist/internal/chart-participant.js +4 -0
  35. package/dist/internal/chart-projection.d.ts +11 -0
  36. package/dist/internal/chart-projection.js +69 -0
  37. package/dist/internal/content-box.d.ts +11 -0
  38. package/dist/internal/content-box.js +36 -0
  39. package/dist/internal/coordinated-handoff.d.ts +4 -0
  40. package/dist/internal/coordinated-handoff.js +158 -0
  41. package/dist/internal/count.d.ts +3 -0
  42. package/dist/internal/count.js +20 -0
  43. package/dist/internal/defaults.d.ts +11 -0
  44. package/dist/internal/defaults.js +11 -0
  45. package/dist/internal/dense/managed-painter.d.ts +4 -0
  46. package/dist/internal/dense/managed-painter.js +361 -0
  47. package/dist/internal/dense/runner.d.ts +2 -0
  48. package/dist/internal/dense/runner.js +5 -0
  49. package/dist/internal/dense-loader.d.ts +83 -0
  50. package/dist/internal/dense-loader.js +331 -0
  51. package/dist/internal/dissolve.d.ts +27 -0
  52. package/dist/internal/dissolve.js +216 -0
  53. package/dist/internal/dom.d.ts +23 -0
  54. package/dist/internal/dom.js +104 -0
  55. package/dist/internal/effect.d.ts +2 -0
  56. package/dist/internal/effect.js +17 -0
  57. package/dist/internal/element.d.ts +89 -0
  58. package/dist/internal/element.js +384 -0
  59. package/dist/internal/event-element.d.ts +8 -0
  60. package/dist/internal/event-element.js +20 -0
  61. package/dist/internal/frames.d.ts +1 -0
  62. package/dist/internal/frames.js +51 -0
  63. package/dist/internal/handoff.d.ts +56 -0
  64. package/dist/internal/handoff.js +102 -0
  65. package/dist/internal/ledger.d.ts +13 -0
  66. package/dist/internal/ledger.js +78 -0
  67. package/dist/internal/loading-controller.d.ts +62 -0
  68. package/dist/internal/loading-controller.js +694 -0
  69. package/dist/internal/marks.d.ts +153 -0
  70. package/dist/internal/marks.js +227 -0
  71. package/dist/internal/math.d.ts +2 -0
  72. package/dist/internal/math.js +2 -0
  73. package/dist/internal/morph-marks.d.ts +62 -0
  74. package/dist/internal/morph-marks.js +205 -0
  75. package/dist/internal/morph.d.ts +35 -0
  76. package/dist/internal/morph.js +488 -0
  77. package/dist/internal/paint.d.ts +29 -0
  78. package/dist/internal/paint.js +1 -0
  79. package/dist/internal/painter.d.ts +20 -0
  80. package/dist/internal/painter.js +155 -0
  81. package/dist/internal/preset-data.d.ts +12 -0
  82. package/dist/internal/preset-data.js +31 -0
  83. package/dist/internal/preset.d.ts +22 -0
  84. package/dist/internal/preset.js +86 -0
  85. package/dist/internal/pulse.d.ts +7 -0
  86. package/dist/internal/pulse.js +74 -0
  87. package/dist/internal/reveal-effect.d.ts +7 -0
  88. package/dist/internal/reveal-effect.js +24 -0
  89. package/dist/internal/reveal.d.ts +5 -0
  90. package/dist/internal/reveal.js +11 -0
  91. package/dist/internal/runner.d.ts +9 -0
  92. package/dist/internal/runner.js +70 -0
  93. package/dist/internal/services.d.ts +12 -0
  94. package/dist/internal/services.js +159 -0
  95. package/dist/internal/skeleton-handoff.d.ts +26 -0
  96. package/dist/internal/skeleton-handoff.js +6 -0
  97. package/dist/internal/skeleton-source.d.ts +5 -0
  98. package/dist/internal/skeleton-source.js +106 -0
  99. package/dist/internal/surface.d.ts +4 -0
  100. package/dist/internal/surface.js +21 -0
  101. package/dist/internal/table-definitions.d.ts +27 -0
  102. package/dist/internal/table-definitions.js +139 -0
  103. package/dist/internal/table-factory.d.ts +12 -0
  104. package/dist/internal/table-factory.js +44 -0
  105. package/dist/internal/table-field.d.ts +12 -0
  106. package/dist/internal/table-field.js +75 -0
  107. package/dist/internal/table-model.d.ts +21 -0
  108. package/dist/internal/table-model.js +117 -0
  109. package/dist/internal/table-projection.d.ts +7 -0
  110. package/dist/internal/table-projection.js +110 -0
  111. package/dist/internal/target-changes.d.ts +3 -0
  112. package/dist/internal/target-changes.js +2 -0
  113. package/dist/internal/target-tracker.d.ts +18 -0
  114. package/dist/internal/target-tracker.js +33 -0
  115. package/dist/internal/targets.d.ts +3 -0
  116. package/dist/internal/targets.js +15 -0
  117. package/dist/internal/text-definitions.d.ts +141 -0
  118. package/dist/internal/text-definitions.js +228 -0
  119. package/dist/internal/text-glyphs.d.ts +4 -0
  120. package/dist/internal/text-glyphs.js +32 -0
  121. package/dist/internal/text-morph.d.ts +32 -0
  122. package/dist/internal/text-morph.js +113 -0
  123. package/dist/internal/text-playback.d.ts +4 -0
  124. package/dist/internal/text-playback.js +119 -0
  125. package/dist/internal/text-scramble.d.ts +18 -0
  126. package/dist/internal/text-scramble.js +47 -0
  127. package/dist/internal/time.d.ts +9 -0
  128. package/dist/internal/time.js +13 -0
  129. package/dist/internal/unstyled.d.ts +8 -0
  130. package/dist/internal/unstyled.js +8 -0
  131. package/dist/line.css +5 -0
  132. package/dist/region-css.d.ts +1 -0
  133. package/dist/region-css.js +6 -0
  134. package/dist/region-styles.d.ts +3 -0
  135. package/dist/region-styles.js +15 -0
  136. package/dist/region.css +1 -0
  137. package/dist/region.d.ts +31 -0
  138. package/dist/region.js +100 -0
  139. package/dist/register-all.d.ts +2 -0
  140. package/dist/register-all.js +33 -0
  141. package/dist/server.d.ts +63 -0
  142. package/dist/server.js +141 -0
  143. package/dist/skeleton-animations.d.ts +10 -0
  144. package/dist/skeleton-animations.js +35 -0
  145. package/dist/skeleton-block.d.ts +50 -0
  146. package/dist/skeleton-block.js +260 -0
  147. package/dist/skeleton-circle.d.ts +5 -0
  148. package/dist/skeleton-circle.js +11 -0
  149. package/dist/skeleton-family.css +13 -0
  150. package/dist/skeleton-line.d.ts +5 -0
  151. package/dist/skeleton-line.js +11 -0
  152. package/dist/skeleton-text.css +5 -0
  153. package/dist/skeleton-text.d.ts +22 -0
  154. package/dist/skeleton-text.js +115 -0
  155. package/dist/skeleton.css +4 -0
  156. package/dist/skeleton.d.ts +5 -0
  157. package/dist/skeleton.js +4 -0
  158. package/dist/static-catalog-styles.d.ts +8 -0
  159. package/dist/static-catalog-styles.js +44 -0
  160. package/dist/styles.d.ts +4 -0
  161. package/dist/styles.js +18 -0
  162. package/dist/table-animations.d.ts +11 -0
  163. package/dist/table-animations.js +4 -0
  164. package/dist/table-styles.d.ts +2 -0
  165. package/dist/table-styles.js +12 -0
  166. package/dist/table.css +3 -0
  167. package/dist/table.d.ts +88 -0
  168. package/dist/table.js +126 -0
  169. package/dist/text-animations.d.ts +31 -0
  170. package/dist/text-animations.js +40 -0
  171. package/dist/text-styles.d.ts +3 -0
  172. package/dist/text-styles.js +24 -0
  173. package/dist/text.css +3 -0
  174. package/dist/text.d.ts +42 -0
  175. package/dist/text.js +402 -0
  176. package/dist/types.d.ts +56 -0
  177. package/dist/types.js +18 -0
  178. package/dist/typing-styles.d.ts +1 -0
  179. package/dist/typing-styles.js +7 -0
  180. package/dist/typing.css +4 -0
  181. package/dist/typing.d.ts +35 -0
  182. package/dist/typing.js +164 -0
  183. package/package.json +100 -4
@@ -0,0 +1,155 @@
1
+ import { paintLayer } from './dom.js';
2
+ import { lease } from './ledger.js';
3
+ import { glowColor, markBox, markColor, markOf, peakOpacity, } from './marks.js';
4
+ import { clamp } from './math.js';
5
+ // Optional authoring support, reached only through an imported custom definition.
6
+ // The engine creates/disposes this painter. Author callbacks see bounded commands only.
7
+ export const pointer = Symbol.for('dotquilt.pointer.v1');
8
+ /**
9
+ * The pointer lift (design/SPEC.md): marks within 56 px of the pointer light
10
+ * up in the accent, strongest at the pointer, like the skeleton's lift layer.
11
+ * Returns the accent's opacity at offset (dx, dy).
12
+ */
13
+ export function liftAt(dx, dy) {
14
+ return peakOpacity * Math.max(0, 1 - Math.hypot(dx, dy) / 56);
15
+ }
16
+ const svgns = 'http://www.w3.org/2000/svg';
17
+ /**
18
+ * TextLoader's glyph marks sit on a matrix whose pitch is about 2.8 radii, much
19
+ * tighter than a field's: squares and dashes are fitted to it, so the marks of
20
+ * a character stay distinct. A dash spans nearly the whole pitch, like a
21
+ * scanline; a square is two thirds of it.
22
+ */
23
+ function glyphBox(mark, r) {
24
+ return mark === 'square'
25
+ ? { width: 1.85 * r, height: 1.85 * r, radius: 0.45 * r }
26
+ : { width: 2.55 * r, height: 0.9 * r, radius: 0.45 * r };
27
+ }
28
+ /**
29
+ * Places a dot as a circle, or a square or dash as a rounded rectangle,
30
+ * turned about its centre by `angle` radians.
31
+ */
32
+ function place(entry, mark, x, y, r, angle, glyphs) {
33
+ if (mark === 'dot') {
34
+ entry.setAttribute('cx', String(x));
35
+ entry.setAttribute('cy', String(y));
36
+ entry.setAttribute('r', String(r));
37
+ return;
38
+ }
39
+ const box = glyphs ? glyphBox(mark, r) : markBox(mark, r);
40
+ entry.setAttribute('x', String(x - box.width / 2));
41
+ entry.setAttribute('y', String(y - box.height / 2));
42
+ entry.setAttribute('width', String(box.width));
43
+ entry.setAttribute('height', String(box.height));
44
+ entry.setAttribute('rx', String(box.radius));
45
+ if (angle)
46
+ entry.setAttribute('transform', `rotate(${(angle * 180) / Math.PI} ${x} ${y})`);
47
+ else
48
+ entry.removeAttribute('transform');
49
+ }
50
+ export function createPainter(host, report, part,
51
+ /** Draws glyph marks (TextLoader), fitted to their matrix. */
52
+ glyphs = false) {
53
+ const doc = host.ownerDocument;
54
+ // The surface cap is checked per command below, so a refused lease means
55
+ // the document is full.
56
+ const budget = lease(doc, (code) => report(code === 'dots-limit' ? 'document-dot-limit' : code));
57
+ let disposed = false;
58
+ const svg = doc.createElementNS(svgns, 'svg');
59
+ svg.setAttribute('aria-hidden', 'true');
60
+ if (part)
61
+ svg.setAttribute('part', part);
62
+ svg.setAttribute('data-dotquilt-painter', '');
63
+ if (host.shadowRoot)
64
+ paintLayer(host.shadowRoot).append(svg);
65
+ host.setAttribute('data-custom', '');
66
+ // Remember only the primitives written by this painter, bounded by admitted nodes.
67
+ const dots = [];
68
+ // The mark the entries draw; a new mark replaces them.
69
+ let shape = 'dot';
70
+ return {
71
+ points: dots,
72
+ draw(callback) {
73
+ if (disposed)
74
+ return;
75
+ let active = true;
76
+ let count = 0;
77
+ const position = Reflect.get(host, pointer);
78
+ const mark = markOf(host);
79
+ if (mark !== shape) {
80
+ for (const entry of dots.splice(0))
81
+ entry.remove();
82
+ budget.set('dots', 0);
83
+ shape = mark;
84
+ }
85
+ try {
86
+ const write = (x, y, size, opacity, accent, angle) => {
87
+ if (++count > 4096) {
88
+ report('dot-limit');
89
+ return;
90
+ }
91
+ let entry = dots[count - 1];
92
+ if (!entry) {
93
+ if (!budget.set('dots', dots.length + 1))
94
+ return;
95
+ entry = doc.createElementNS(svgns, mark === 'dot' ? 'circle' : 'rect');
96
+ dots.push(entry);
97
+ svg.append(entry);
98
+ }
99
+ const r = clamp(size, 0, 32);
100
+ if (entry[0] !== x ||
101
+ entry[1] !== y ||
102
+ entry[2] !== r ||
103
+ (entry[5] ?? 0) !== angle) {
104
+ place(entry, mark, x, y, r, angle, glyphs);
105
+ entry[0] = x;
106
+ entry[1] = y;
107
+ entry[2] = r;
108
+ entry[5] = angle;
109
+ }
110
+ opacity = clamp(opacity);
111
+ if (entry[3] !== opacity) {
112
+ entry.setAttribute('opacity', String(opacity));
113
+ entry[3] = opacity;
114
+ }
115
+ if (entry[4] !== accent) {
116
+ entry.setAttribute('fill', accent ? glowColor : markColor);
117
+ entry[4] = accent;
118
+ }
119
+ };
120
+ callback((value) => {
121
+ if (!active || disposed)
122
+ return;
123
+ const { x, y, size, opacity, tone, angle = 0 } = value;
124
+ if (![x, y, size, opacity, angle].every(Number.isFinite)) {
125
+ report('invalid-dot');
126
+ return;
127
+ }
128
+ write(x, y, size, opacity, tone === 'accent', angle);
129
+ // The pointer lights the marks around it, as a skeleton's lift does.
130
+ const halo = position ? liftAt(x - position.x, y - position.y) : 0;
131
+ if (halo > 0.02 && tone !== 'accent')
132
+ write(x, y, size, halo * Math.min(1, opacity * 3), true, angle);
133
+ });
134
+ }
135
+ finally {
136
+ active = false;
137
+ }
138
+ if (dots.length > count) {
139
+ for (const entry of dots.splice(count))
140
+ entry.remove();
141
+ budget.set('dots', dots.length);
142
+ }
143
+ },
144
+ dispose() {
145
+ if (disposed)
146
+ return;
147
+ disposed = true;
148
+ budget.close();
149
+ dots.length = 0;
150
+ svg.remove();
151
+ if (!host.shadowRoot?.querySelector('[data-dotquilt-painter]'))
152
+ host.removeAttribute('data-custom');
153
+ },
154
+ };
155
+ }
@@ -0,0 +1,12 @@
1
+ import type { Preset, PresetKind } from './preset.js';
2
+ type Rule = (value: never, kind: PresetKind) => unknown;
3
+ export type PresetSchema = Readonly<Record<string, Rule>>;
4
+ export declare function plain(value: unknown): value is Record<string, unknown>;
5
+ export declare function capturePresetData<K extends PresetKind>(value: Preset<K>, expected: K | undefined, schemaFor: (kind: K) => PresetSchema | undefined): Preset<K>;
6
+ export declare function accept<T>(value: T, valid: boolean): T;
7
+ export declare const motionRule: (value: unknown) => unknown;
8
+ export declare const speedRule: (value: unknown) => unknown;
9
+ export declare const pointerRule: (value: unknown) => unknown;
10
+ export declare const countRule: (value: unknown) => unknown;
11
+ export declare const variantRule: (value: unknown) => unknown;
12
+ export {};
@@ -0,0 +1,31 @@
1
+ export function plain(value) {
2
+ return !!value && Object.getPrototypeOf(value) === Object.prototype;
3
+ }
4
+ export function capturePresetData(value, expected, schemaFor) {
5
+ if (!plain(value))
6
+ throw new TypeError();
7
+ const keys = Reflect.ownKeys(value);
8
+ value = { ...value };
9
+ const schema = schemaFor(value.kind);
10
+ if (!schema ||
11
+ (expected !== undefined && value.kind !== expected) ||
12
+ keys.some((key) => key !== 'kind' &&
13
+ (typeof key !== 'string' || !Object.hasOwn(schema, key))))
14
+ throw new TypeError();
15
+ for (const key of Object.keys(schema)) {
16
+ const field = value[key];
17
+ if (field !== undefined)
18
+ Reflect.set(value, key, schema[key](field, value.kind));
19
+ }
20
+ return Object.freeze(value);
21
+ }
22
+ export function accept(value, valid) {
23
+ if (!valid)
24
+ throw new TypeError();
25
+ return value;
26
+ }
27
+ export const motionRule = (value) => accept(value, ['system', 'paused'].includes(value));
28
+ export const speedRule = (value) => accept(value, Number.isFinite(value) && value > 0);
29
+ export const pointerRule = (value) => accept(value, ['none', 'lift'].includes(value));
30
+ export const countRule = (value) => accept(value, Number.isInteger(value) && value >= 1 && value <= 8);
31
+ export const variantRule = (value) => accept(value, ['line', 'bar', 'scatter'].includes(value));
@@ -0,0 +1,22 @@
1
+ import type { AnimationFamily, Animations } from '../animations.js';
2
+ import { type Motion, type Timing } from '../types.js';
3
+ import { type PresetSchema } from './preset-data.js';
4
+ export type PresetKind = AnimationFamily | 'typing';
5
+ /** Local defaults only: application content, readiness and style credentials stay outside presets. */
6
+ export interface Preset<K extends PresetKind = PresetKind> {
7
+ readonly kind: K;
8
+ readonly motion?: Motion | undefined;
9
+ readonly speed?: K extends 'region' ? never : number | undefined;
10
+ readonly pointerResponse?: K extends 'region' | 'typing' ? never : 'none' | 'lift' | undefined;
11
+ readonly variant?: K extends 'chart' ? import('../chart.js').ChartVariant | undefined : never;
12
+ readonly count?: K extends 'typing' ? number | undefined : never;
13
+ readonly timing?: K extends 'text' | 'region' ? Timing | undefined : never;
14
+ readonly animations?: K extends AnimationFamily ? (K extends 'region' ? Pick<Animations<K>, 'handoff'> : Animations<K>) | undefined : never;
15
+ }
16
+ export declare const skeletonPreset: PresetSchema;
17
+ export declare const regionPreset: PresetSchema;
18
+ export declare const textPreset: PresetSchema;
19
+ export declare const chartPreset: PresetSchema;
20
+ export declare const tablePreset: PresetSchema;
21
+ export declare const typingPreset: PresetSchema;
22
+ export declare function capturePreset<K extends PresetKind>(value: Preset<K>, expected?: K): Preset<K>;
@@ -0,0 +1,86 @@
1
+ import { LoaderConfigurationError, } from '../types.js';
2
+ import { validateBindings } from './binding.js';
3
+ import { accept, capturePresetData, countRule, motionRule, plain, pointerRule, speedRule, variantRule, } from './preset-data.js';
4
+ function easing(value) {
5
+ if (typeof value !== 'string')
6
+ return false;
7
+ if (/^(linear|ease(-in)?(-out)?)$/.test(value))
8
+ return true;
9
+ const match = /^cubic-bezier\(([^()]+)\)$/.exec(value);
10
+ const parts = match?.[1]?.split(',').map((part) => part.trim());
11
+ if (parts?.length !== 4 ||
12
+ parts.some((part) => !/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(part)))
13
+ return false;
14
+ const numbers = parts.map(Number);
15
+ return (numbers.every(Number.isFinite) &&
16
+ [numbers[0], numbers[2]].every((number) => number !== undefined && number >= 0 && number <= 1));
17
+ }
18
+ const timingRule = (input) => {
19
+ if (!plain(input))
20
+ throw new TypeError();
21
+ const value = { ...input };
22
+ return Object.freeze(accept(value, !Reflect.ownKeys(value).some((key) => key !== 'duration' && key !== 'easing') &&
23
+ (value.duration === undefined ||
24
+ (typeof value.duration === 'number' &&
25
+ Number.isFinite(value.duration) &&
26
+ value.duration >= 0)) &&
27
+ (value.easing === undefined || easing(value.easing))));
28
+ };
29
+ const animationRule = (input, kind) => {
30
+ if (!plain(input))
31
+ throw new TypeError();
32
+ const value = { ...input };
33
+ if (Reflect.ownKeys(value).some((key) => key !== 'handoff' && (key !== 'idle' || kind === 'region')))
34
+ throw new TypeError();
35
+ validateBindings(value, kind);
36
+ return Object.freeze(value);
37
+ };
38
+ export const skeletonPreset = /*@__PURE__*/ Object.freeze({
39
+ animations: animationRule,
40
+ motion: motionRule,
41
+ speed: speedRule,
42
+ pointerResponse: pointerRule,
43
+ });
44
+ export const regionPreset = /*@__PURE__*/ Object.freeze({
45
+ timing: timingRule,
46
+ animations: animationRule,
47
+ motion: motionRule,
48
+ });
49
+ export const textPreset = /*@__PURE__*/ Object.freeze({
50
+ timing: timingRule,
51
+ animations: animationRule,
52
+ motion: motionRule,
53
+ speed: speedRule,
54
+ pointerResponse: pointerRule,
55
+ });
56
+ export const chartPreset = /*@__PURE__*/ Object.freeze({
57
+ animations: animationRule,
58
+ motion: motionRule,
59
+ speed: speedRule,
60
+ pointerResponse: pointerRule,
61
+ variant: variantRule,
62
+ });
63
+ export const tablePreset = skeletonPreset;
64
+ export const typingPreset = /*@__PURE__*/ Object.freeze({
65
+ motion: motionRule,
66
+ speed: speedRule,
67
+ count: countRule,
68
+ });
69
+ const schemas = /*@__PURE__*/ Object.freeze({
70
+ skeleton: skeletonPreset,
71
+ region: regionPreset,
72
+ text: textPreset,
73
+ chart: chartPreset,
74
+ table: tablePreset,
75
+ typing: typingPreset,
76
+ });
77
+ export function capturePreset(value, expected) {
78
+ try {
79
+ return capturePresetData(value, expected, (kind) => typeof kind === 'string' && Object.hasOwn(schemas, kind)
80
+ ? schemas[kind]
81
+ : undefined);
82
+ }
83
+ catch {
84
+ throw new LoaderConfigurationError('invalid-preset', 'Invalid family preset configuration');
85
+ }
86
+ }
@@ -0,0 +1,7 @@
1
+ import type { Runner } from './runner.js';
2
+ /**
3
+ * The skeleton idle (design/SPEC.md): a soft glow drifts across the field
4
+ * every 2.8 s, and the whole field breathes ±7% every 3.2 s. WAAPI owns the
5
+ * phase while running; only the normalized positions are kept at a boundary.
6
+ */
7
+ export declare function createPulse(host: HTMLElement, report: (code: string) => void): Runner;
@@ -0,0 +1,74 @@
1
+ import { curves, peakOpacity, restOpacity } from './marks.js';
2
+ /** Sine in-out, the curve the spec gives marks and the idle glow. */
3
+ const sine = curves.sine;
4
+ const glowPeriod = 2800;
5
+ const breathPeriod = 3200;
6
+ /**
7
+ * The skeleton idle (design/SPEC.md): a soft glow drifts across the field
8
+ * every 2.8 s, and the whole field breathes ±7% every 3.2 s. WAAPI owns the
9
+ * phase while running; only the normalized positions are kept at a boundary.
10
+ */
11
+ export function createPulse(host, report) {
12
+ let glow;
13
+ let breath;
14
+ let phase = 0;
15
+ let breathPhase = 0;
16
+ let failed = false;
17
+ const stop = () => {
18
+ phase = glow?.effect?.getComputedTiming().progress ?? phase;
19
+ breathPhase = breath?.effect?.getComputedTiming().progress ?? breathPhase;
20
+ glow?.cancel();
21
+ breath?.cancel();
22
+ glow = breath = undefined;
23
+ };
24
+ return {
25
+ reset() {
26
+ failed = false;
27
+ },
28
+ draw(binding, still, speed, remaining = 0) {
29
+ if (failed)
30
+ return;
31
+ try {
32
+ if (still) {
33
+ stop();
34
+ return;
35
+ }
36
+ const period = (binding?.options?.periodMs ??
37
+ glowPeriod) / speed;
38
+ if (glow?.effect?.getTiming().duration === period)
39
+ return;
40
+ stop();
41
+ // `:scope` matches nothing in ShadowRoot.querySelector; walk the children.
42
+ const layer = [...(host.shadowRoot?.children ?? [])].find((child) => child.classList.contains('pulse'));
43
+ // The glow's centre travels from half a field before the start to
44
+ // half a field past the end, so it enters and leaves fully.
45
+ // Easing goes on the keyframe, not the timing, so `progress` stays
46
+ // linear and a resumed glow continues from the same position.
47
+ glow = layer?.animate([
48
+ { maskPosition: '407% 0', opacity: peakOpacity, easing: sine },
49
+ { maskPosition: '-307% 0', opacity: peakOpacity },
50
+ ], {
51
+ duration: period,
52
+ iterations: remaining / period,
53
+ iterationStart: phase,
54
+ });
55
+ const breathing = (breathPeriod * period) / glowPeriod;
56
+ breath = layer?.previousElementSibling?.animate([
57
+ { opacity: restOpacity, easing: sine },
58
+ { opacity: restOpacity * 0.86, easing: sine },
59
+ { opacity: restOpacity },
60
+ ], {
61
+ duration: breathing,
62
+ iterations: remaining / breathing,
63
+ iterationStart: breathPhase,
64
+ });
65
+ }
66
+ catch {
67
+ failed = true;
68
+ stop();
69
+ report('animation-failed');
70
+ }
71
+ },
72
+ dispose: stop,
73
+ };
74
+ }
@@ -0,0 +1,7 @@
1
+ import type { RevealFrame } from '../animations.js';
2
+ export declare function revealValues(opacity: number, translateY: number, clipStart: number, clip: boolean): PropertyIndexedKeyframes;
3
+ /** Trusted engine commands; custom definitions provide the validated mapper. */
4
+ export declare function createRevealEffect(element: HTMLElement, own: (animation: Animation) => void, clip: boolean, map?: typeof revealValues): {
5
+ readonly animation: Animation | undefined;
6
+ draw({ opacity, translateY, clipStart }: RevealFrame): void;
7
+ };
@@ -0,0 +1,24 @@
1
+ import { createEffect } from './effect.js';
2
+ export function revealValues(opacity, translateY, clipStart, clip) {
3
+ return {
4
+ opacity,
5
+ translate: `0 ${translateY}px`,
6
+ ...(clip ? { clipPath: `inset(0 ${(1 - clipStart) * 100}% 0 0)` } : {}),
7
+ };
8
+ }
9
+ /** Trusted engine commands; custom definitions provide the validated mapper. */
10
+ export function createRevealEffect(element, own, clip, map = revealValues) {
11
+ let animation;
12
+ const effect = createEffect(element, (value) => {
13
+ animation = value;
14
+ own(value);
15
+ });
16
+ return {
17
+ get animation() {
18
+ return animation;
19
+ },
20
+ draw({ opacity, translateY = 0, clipStart = 1 }) {
21
+ effect(map(opacity, translateY, clipStart, clip));
22
+ },
23
+ };
24
+ }
@@ -0,0 +1,5 @@
1
+ /** Authored/proof commands retain finite validation and the established clamps. */
2
+ export declare function createReveal(element: HTMLElement, own: (animation: Animation) => void, clip: boolean): {
3
+ readonly animation: Animation | undefined;
4
+ draw({ opacity, translateY, clipStart }: import("../animations.js").RevealFrame): void;
5
+ };
@@ -0,0 +1,11 @@
1
+ import { clamp } from './math.js';
2
+ import { createRevealEffect, revealValues } from './reveal-effect.js';
3
+ function validatedValues(opacity, translateY, clipStart, clip) {
4
+ if (![opacity, translateY, clipStart].every(Number.isFinite))
5
+ throw new TypeError();
6
+ return revealValues(clamp(opacity), clamp(translateY, -8, 8), clamp(clipStart), clip);
7
+ }
8
+ /** Authored/proof commands retain finite validation and the established clamps. */
9
+ export function createReveal(element, own, clip) {
10
+ return createRevealEffect(element, own, clip, validatedValues);
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { AnimationBinding, AnimationFamily } from '../animations.js';
2
+ import { createPainter } from './painter.js';
3
+ export interface Runner {
4
+ draw(binding: AnimationBinding<AnimationFamily, 'idle'> | undefined, still: boolean, speed: number, remaining?: number): void;
5
+ capture?(): readonly import('../animations.js').Dot[];
6
+ reset?(): void;
7
+ dispose(): void;
8
+ }
9
+ export declare function createRunner(host: HTMLElement, report: (code: string) => void, invalidate: () => void, makePainter?: typeof createPainter): Runner;
@@ -0,0 +1,70 @@
1
+ import { definitionOf } from './binding.js';
2
+ import { capturePainter } from './capture.js';
3
+ import { frames } from './frames.js';
4
+ import { createPainter } from './painter.js';
5
+ import { now } from './time.js';
6
+ export function createRunner(host, report, invalidate, makePainter = createPainter) {
7
+ let painter;
8
+ let release;
9
+ let failed = false;
10
+ let last = 0, phase = 0, previousSpeed = 1;
11
+ const schedule = (active, callback) => {
12
+ if (active)
13
+ release ??= frames(host, callback);
14
+ else {
15
+ release?.();
16
+ release = undefined;
17
+ }
18
+ };
19
+ const dispose = () => {
20
+ schedule(false, invalidate);
21
+ painter?.dispose();
22
+ painter = undefined;
23
+ last = 0;
24
+ };
25
+ return {
26
+ capture: () => capturePainter(painter),
27
+ reset() {
28
+ failed = false;
29
+ },
30
+ draw(binding, still, speed) {
31
+ if (still &&
32
+ (host.ownerDocument.hidden ||
33
+ host.matches('[hidden],[data-dotquilt-offscreen]') ||
34
+ !host.clientWidth ||
35
+ !host.clientHeight)) {
36
+ dispose();
37
+ return;
38
+ }
39
+ if (failed)
40
+ return;
41
+ try {
42
+ const time = now(host), deltaMs = last ? Math.min(100, time - last) : 0;
43
+ phase += deltaMs * previousSpeed;
44
+ last = still ? 0 : time;
45
+ previousSpeed = speed;
46
+ if (!binding)
47
+ return;
48
+ const definition = definitionOf(binding);
49
+ painter ??= makePainter(host, report, binding.family === 'chart' || binding.family === 'table'
50
+ ? 'surface'
51
+ : undefined);
52
+ painter.draw((dot) => definition.draw({
53
+ surface: definition.snapshot(host, binding.family),
54
+ options: binding.options,
55
+ timeMs: phase,
56
+ deltaMs,
57
+ still,
58
+ dot,
59
+ }));
60
+ schedule(!still && host.isConnected, invalidate);
61
+ }
62
+ catch {
63
+ failed = true;
64
+ dispose();
65
+ report('animation-failed');
66
+ }
67
+ },
68
+ dispose,
69
+ };
70
+ }
@@ -0,0 +1,12 @@
1
+ interface Client {
2
+ host: HTMLElement;
3
+ changed(): void;
4
+ visible?: boolean | undefined;
5
+ }
6
+ interface Subscription {
7
+ eligible(invalidate?: boolean): boolean;
8
+ watch(element: Element): void;
9
+ release(): void;
10
+ }
11
+ export declare function subscribe(client: Client): Subscription;
12
+ export {};