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,159 @@
1
+ const services = new WeakMap();
2
+ export function subscribe(client) {
3
+ const doc = client.host.ownerDocument;
4
+ let add = services.get(doc);
5
+ if (!add) {
6
+ const win = doc.defaultView;
7
+ if (!win)
8
+ return { eligible: () => false, watch() { }, release() { } };
9
+ const clients = new Set();
10
+ // Elements each client watches for size changes (its host, plus extras).
11
+ const watchers = new Map();
12
+ // Clients are notified once per microtask, and only when a change can
13
+ // affect them: their own size or visibility, an attribute on the host or
14
+ // one of its ancestors, or a document-wide motion/visibility change.
15
+ const pending = new Set();
16
+ const flush = () => {
17
+ const batch = [...pending];
18
+ pending.clear();
19
+ for (const c of batch) {
20
+ if (!clients.has(c))
21
+ continue;
22
+ c.visible = undefined;
23
+ // One failing handler must not drop the rest of the batch, or leave
24
+ // the queue non-empty so that no later flush is ever scheduled.
25
+ try {
26
+ c.changed();
27
+ }
28
+ catch (error) {
29
+ win.reportError?.(error);
30
+ }
31
+ }
32
+ };
33
+ const queue = (c) => {
34
+ if (!pending.size)
35
+ queueMicrotask(flush);
36
+ pending.add(c);
37
+ };
38
+ const notify = () => {
39
+ for (const c of clients)
40
+ queue(c);
41
+ };
42
+ const notifyWatchers = (element) => {
43
+ for (const c of watchers.get(element) ?? [])
44
+ queue(c);
45
+ };
46
+ /** True when `target` is the host or one of its ancestors, across shadow roots. */
47
+ const affects = (targets, host) => {
48
+ for (let n = host; n;) {
49
+ if (targets.has(n))
50
+ return true;
51
+ n = n.parentNode ?? n.host ?? null;
52
+ }
53
+ return false;
54
+ };
55
+ const media = win.matchMedia('(prefers-reduced-motion: reduce), (forced-colors: active)');
56
+ const mutation = new win.MutationObserver((records) => {
57
+ const targets = new Set();
58
+ for (const record of records)
59
+ if (record.attributeName !== 'data-presentation' ||
60
+ record.oldValue !==
61
+ record.target.getAttribute('data-presentation'))
62
+ targets.add(record.target);
63
+ if (!targets.size)
64
+ return;
65
+ for (const c of clients)
66
+ if (affects(targets, c.host))
67
+ queue(c);
68
+ });
69
+ mutation.observe(doc.documentElement, {
70
+ attributes: true,
71
+ attributeOldValue: true,
72
+ subtree: true,
73
+ attributeFilter: [
74
+ 'motion',
75
+ 'slot',
76
+ 'data-dotquilt-disabled',
77
+ 'data-dotquilt-offscreen',
78
+ 'data-dotquilt-paused',
79
+ 'data-presentation',
80
+ 'hidden',
81
+ 'class',
82
+ 'style',
83
+ 'dir',
84
+ ],
85
+ });
86
+ const resize = new win.ResizeObserver((entries) => {
87
+ for (const entry of entries)
88
+ notifyWatchers(entry.target);
89
+ });
90
+ const intersection = new win.IntersectionObserver((entries) => {
91
+ for (const entry of entries) {
92
+ entry.target.toggleAttribute('data-dotquilt-offscreen', !entry.intersectionRatio);
93
+ notifyWatchers(entry.target);
94
+ }
95
+ });
96
+ media.addEventListener('change', notify);
97
+ doc.addEventListener('visibilitychange', notify);
98
+ const observe = (element, c) => {
99
+ const set = watchers.get(element) ?? new Set();
100
+ watchers.set(element, set);
101
+ set.add(c);
102
+ };
103
+ add = (c) => {
104
+ clients.add(c);
105
+ const watched = new Set([c.host]);
106
+ observe(c.host, c);
107
+ resize.observe(c.host);
108
+ intersection.observe(c.host);
109
+ return {
110
+ watch(element) {
111
+ watched.add(element);
112
+ observe(element, c);
113
+ resize.observe(element);
114
+ },
115
+ eligible(invalidate) {
116
+ // Invalidation is write-only: geometry is measured by the queued render.
117
+ if (invalidate) {
118
+ c.visible = undefined;
119
+ return false;
120
+ }
121
+ if (doc.hidden || media.matches)
122
+ return false;
123
+ if (c.visible === undefined) {
124
+ const { width, height } = c.host.getBoundingClientRect();
125
+ c.visible =
126
+ width > 0 &&
127
+ height > 0 &&
128
+ win.getComputedStyle(c.host).visibility !== 'hidden';
129
+ }
130
+ return c.visible;
131
+ },
132
+ release() {
133
+ clients.delete(c);
134
+ pending.delete(c);
135
+ for (const element of watched) {
136
+ const set = watchers.get(element);
137
+ set?.delete(c);
138
+ if (!set?.size) {
139
+ watchers.delete(element);
140
+ resize.unobserve(element);
141
+ }
142
+ }
143
+ watched.clear();
144
+ intersection.unobserve(c.host);
145
+ if (!clients.size) {
146
+ mutation.disconnect();
147
+ resize.disconnect();
148
+ intersection.disconnect();
149
+ media.removeEventListener('change', notify);
150
+ doc.removeEventListener('visibilitychange', notify);
151
+ services.delete(doc);
152
+ }
153
+ },
154
+ };
155
+ };
156
+ services.set(doc, add);
157
+ }
158
+ return add(client);
159
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What a skeleton tells the region that hands it over. The region owns the
3
+ * time, the restrictions and the dissolve itself (dissolve.ts); the skeleton
4
+ * only says how its marks should leave.
5
+ */
6
+ export declare const skeletonHandoff: unique symbol;
7
+ /** How the marks leave: vertical drift (negative is up) and how much they shrink. */
8
+ export interface Departure {
9
+ readonly driftPx: number;
10
+ readonly shrink: number;
11
+ }
12
+ export interface SkeletonExit {
13
+ /** False when the skeleton's own handoff animation replaces the dissolve. */
14
+ readonly dissolves: boolean;
15
+ readonly departure: Departure;
16
+ canAnimate(): boolean;
17
+ report(code: string): void;
18
+ /**
19
+ * Hands the skeleton the dissolve's geometry check, which it runs when it
20
+ * redraws mid-handoff. Returns the release.
21
+ */
22
+ watch(check: () => void): () => void;
23
+ }
24
+ export interface SkeletonParticipant extends HTMLElement {
25
+ [skeletonHandoff](): SkeletonExit;
26
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * What a skeleton tells the region that hands it over. The region owns the
3
+ * time, the restrictions and the dissolve itself (dissolve.ts); the skeleton
4
+ * only says how its marks should leave.
5
+ */
6
+ export const skeletonHandoff = Symbol('dotquilt.skeleton-handoff');
@@ -0,0 +1,5 @@
1
+ import type { LoadingRegion } from '../region.js';
2
+ import type { SkeletonBlock } from '../skeleton-block.js';
3
+ import type { HandoffSource } from './handoff.js';
4
+ export declare function loadMorph(): void;
5
+ export declare function createSkeletonSource(child: SkeletonBlock | undefined, owner: LoadingRegion, participants: readonly HTMLElement[]): HandoffSource;
@@ -0,0 +1,106 @@
1
+ import { definitionOf } from './binding.js';
2
+ import { dissolveSkeleton } from './dissolve.js';
3
+ import { media } from './dom.js';
4
+ import { handoff } from './marks.js';
5
+ import { skeletonHandoff, } from './skeleton-handoff.js';
6
+ import { targetChanges } from './target-changes.js';
7
+ /**
8
+ * The morph (morph.ts) is about a third of the region's code and runs only
9
+ * when data arrives, so it loads on its own: the first time a region shows
10
+ * its placeholder (owner decision, 2026-11-20). A region that becomes ready
11
+ * before it has loaded hands over with the spec's dissolve or fade instead.
12
+ */
13
+ let morph;
14
+ let requested = false;
15
+ export function loadMorph() {
16
+ if (requested)
17
+ return;
18
+ requested = true;
19
+ import('./morph.js').then((module) => {
20
+ morph = module;
21
+ },
22
+ // A failed load leaves the dissolve and fade in place.
23
+ () => { });
24
+ }
25
+ /**
26
+ * Starts one skeleton's dissolve and returns its release. The dissolve is
27
+ * the region's code (dissolve.ts): only a region hands a skeleton over.
28
+ */
29
+ function launch(skeleton, exit, duration, easing, own, invalidate) {
30
+ if (!exit.dissolves || !exit.canAnimate())
31
+ return () => { };
32
+ const effect = dissolveSkeleton(skeleton, duration, easing, exit.departure, own, invalidate, exit.report);
33
+ const unwatch = exit.watch(effect.check);
34
+ return () => {
35
+ unwatch();
36
+ effect.dispose();
37
+ };
38
+ }
39
+ export function createSkeletonSource(child, owner, participants) {
40
+ const exits = participants.flatMap((participant) => skeletonHandoff in participant
41
+ ? [
42
+ [
43
+ participant,
44
+ participant[skeletonHandoff](),
45
+ ],
46
+ ]
47
+ : []);
48
+ const easing = owner.timing.easing;
49
+ return {
50
+ binding: child?.animations.handoff ?? child?.preset?.animations?.handoff,
51
+ host: child ?? owner,
52
+ animation: child ? 'dotquilt/dissolve' : 'dotquilt/fade',
53
+ prepare(binding, request) {
54
+ const { targets, duration: requestedDuration, current, own } = request;
55
+ // With no animation chosen anywhere, the placeholder takes the content's
56
+ // shape and then hands over (morph.ts). Anything it can't read, or a
57
+ // morph that hasn't loaded yet, falls back to the spec's dissolve.
58
+ const win = owner.ownerDocument.defaultView;
59
+ // Only for Dotquilt placeholders: a region around anything else fades.
60
+ if (morph &&
61
+ !binding &&
62
+ request.placeholder &&
63
+ participants.length &&
64
+ win &&
65
+ !media(win, '(forced-colors: active)'))
66
+ try {
67
+ return morph.createMorph(owner, participants, request.placeholder, request, requestedDuration ?? handoff.duration);
68
+ }
69
+ catch { }
70
+ const definition = binding && definitionOf(binding);
71
+ const driver = binding && definition?.handoff?.(binding, request);
72
+ // The controller validates a missing/malformed custom fade driver and settles
73
+ // with the same animation-failed diagnostic as the original strict route.
74
+ if (!child && binding)
75
+ return driver;
76
+ const duration = driver?.duration ??
77
+ requestedDuration ??
78
+ binding?.options?.duration ??
79
+ handoff.duration;
80
+ const releases = [];
81
+ return {
82
+ duration,
83
+ targetsChanged: targetChanges(targets),
84
+ draw: driver?.draw,
85
+ activate(callback) {
86
+ if (!definition || definition.dissolve) {
87
+ for (const [skeleton, exit] of exits) {
88
+ releases.push(launch(skeleton, exit, duration, easing, own, () => owner.refresh()));
89
+ if (!current()) {
90
+ for (const release of releases)
91
+ release();
92
+ return;
93
+ }
94
+ }
95
+ }
96
+ driver?.activate(callback);
97
+ },
98
+ dispose() {
99
+ driver?.dispose();
100
+ for (const release of releases)
101
+ release();
102
+ },
103
+ };
104
+ },
105
+ };
106
+ }
@@ -0,0 +1,4 @@
1
+ import type { AnimationFamily, AnimationSurface } from '../animations.js';
2
+ export declare const readSurface: unique symbol;
3
+ export declare function nativeSurface<F extends AnimationFamily>(host: HTMLElement, family: F, ids?: readonly string[]): AnimationSurface<F>;
4
+ export declare function surface<F extends AnimationFamily>(host: HTMLElement, family: F, ids?: readonly string[]): AnimationSurface<F>;
@@ -0,0 +1,21 @@
1
+ export const readSurface = Symbol.for('dotquilt.surface.v1');
2
+ export function nativeSurface(host, family, ids = []) {
3
+ return host[readSurface](family, ids);
4
+ }
5
+ export function surface(host, family, ids = []) {
6
+ if (host[readSurface])
7
+ return nativeSurface(host, family, ids);
8
+ const { width, height } = host.getBoundingClientRect();
9
+ return Object.freeze({
10
+ family,
11
+ width,
12
+ height,
13
+ input: Object.freeze({
14
+ shapes: Object.freeze(family === 'skeleton'
15
+ ? [Object.freeze({ x: 0, y: 0, width, height })]
16
+ : []),
17
+ }),
18
+ source: Object.freeze([]),
19
+ revealTargetIds: Object.freeze([...ids]),
20
+ });
21
+ }
@@ -0,0 +1,27 @@
1
+ import type { RowsOptions, TypeOnOptions } from '../table-animations.js';
2
+ import { createDenseRunner as createRunner } from './dense/runner.js';
3
+ import type { IdleFrame } from './paint.js';
4
+ import { nativeSurface } from './surface.js';
5
+ export declare function tableIdle(shimmer?: boolean): Readonly<{
6
+ id: "dotquilt/table/shimmer" | "dotquilt/table/type-on";
7
+ family: 'table';
8
+ phase: 'idle';
9
+ runner: typeof createRunner;
10
+ snapshot: typeof nativeSurface;
11
+ draw: ({ surface, options, timeMs, still, dot, }: IdleFrame<'table', TypeOnOptions>) => undefined;
12
+ }>;
13
+ export declare const typeOnFactory: import("../animations.js").AnimationFactory<"table", "idle", TypeOnOptions>;
14
+ export declare const defaultTypeOn: import("../animations.js").AnimationBinding<"table", "idle", {
15
+ cadenceMs: number;
16
+ cellStyle: 'auto';
17
+ }>;
18
+ export declare const shimmerFactory: import("../animations.js").AnimationFactory<"table", "idle", TypeOnOptions>;
19
+ export declare const defaultShimmer: import("../animations.js").AnimationBinding<"table", "idle", {
20
+ cadenceMs: number;
21
+ cellStyle: 'auto';
22
+ }>;
23
+ export declare const rowsFactory: import("../animations.js").AnimationFactory<"table", "handoff", RowsOptions>;
24
+ export declare const defaultRows: import("../animations.js").AnimationBinding<"table", "handoff", {
25
+ staggerMs: number;
26
+ settlePx: number;
27
+ }>;
@@ -0,0 +1,139 @@
1
+ import { mix, smooth } from './chart-math.js';
2
+ import { managedPainter } from './dense/managed-painter.js';
3
+ import { createDenseRunner as createRunner } from './dense/runner.js';
4
+ import { createHandoff } from './handoff.js';
5
+ import { handoff } from './marks.js';
6
+ import { clamp } from './math.js';
7
+ import { createRevealEffect } from './reveal-effect.js';
8
+ import { nativeSurface } from './surface.js';
9
+ import { tableBinding, tableFactory } from './table-factory.js';
10
+ import { tableField } from './table-field.js';
11
+ import { createTargets } from './targets.js';
12
+ import { glyph } from './text-glyphs.js';
13
+ export function tableIdle(shimmer = false) {
14
+ return Object.freeze({
15
+ id: `dotquilt/table/${shimmer ? 'shimmer' : 'type-on'}`,
16
+ family: 'table',
17
+ phase: 'idle',
18
+ runner: createRunner,
19
+ snapshot: nativeSurface,
20
+ draw: ({ surface, options, timeMs, still, dot, }) => tableField(surface, options, timeMs, still, dot, shimmer),
21
+ });
22
+ }
23
+ const typeOnDefinition = /* @__PURE__ */ tableIdle();
24
+ export const typeOnFactory = /* @__PURE__ */ tableFactory(typeOnDefinition, { cadenceMs: [600, 250, 1200] }, true);
25
+ export const defaultTypeOn = /* @__PURE__ */ tableBinding(typeOnDefinition, {
26
+ cadenceMs: 600,
27
+ cellStyle: 'auto',
28
+ });
29
+ // The spec's idle (still bars under the drifting glow) is the default.
30
+ const shimmerDefinition = /* @__PURE__ */ tableIdle(true);
31
+ export const shimmerFactory = /* @__PURE__ */ tableFactory(shimmerDefinition, { cadenceMs: [600, 250, 1200] }, true);
32
+ export const defaultShimmer = /* @__PURE__ */ tableBinding(shimmerDefinition, {
33
+ cadenceMs: 600,
34
+ cellStyle: 'auto',
35
+ });
36
+ /**
37
+ * Rows handoff timing (design/SPEC.md): rows start 80 ms apart and cells
38
+ * 28 ms apart, up to 7 rows and 6 columns, and each cell takes the rest of
39
+ * the 1.1 s handoff.
40
+ */
41
+ const cellStaggerMs = 28, cellWindowMs = 372;
42
+ const rowsDuration = (o) => 7 * o.staggerMs + 6 * cellStaggerMs + cellWindowMs;
43
+ const precise = (s) => s.revealTargetIds.length > 0 &&
44
+ s.input.cells.length > 0 &&
45
+ s.input.cells.every((c) => s.revealTargetIds.includes(c.rowId) && c.glyphs.length > 0);
46
+ const rowsDefinition = /* @__PURE__ */ Object.freeze({
47
+ id: 'dotquilt/table/rows',
48
+ family: 'table',
49
+ phase: 'handoff',
50
+ handoff: createHandoff,
51
+ painter: managedPainter,
52
+ snapshot: nativeSurface,
53
+ reveal: createRevealEffect,
54
+ targets: createTargets,
55
+ duration: (s, o) => precise(s) ? rowsDuration(o) : handoff.contentFade,
56
+ prepare(s) {
57
+ const used = new Set();
58
+ let count = 0, commands = 0;
59
+ const cells = !precise(s)
60
+ ? []
61
+ : s.input.cells.map((cell) => {
62
+ const b = cell.bounds, from = s.source.filter((d) => !used.has(d) &&
63
+ d.x >= b.x &&
64
+ d.x < b.x + b.width &&
65
+ d.y >= b.y &&
66
+ d.y < b.y + b.height), to = [];
67
+ for (const d of from)
68
+ used.add(d);
69
+ for (const g of cell.glyphs)
70
+ glyph(g, g.character, (d) => {
71
+ if (++count > 4096)
72
+ throw new TypeError('table-dot-limit');
73
+ to.push(Object.freeze(d));
74
+ });
75
+ commands += Math.max(from.length, to.length);
76
+ if (commands > 4096)
77
+ throw new TypeError('table-dot-limit');
78
+ return Object.freeze({
79
+ from: Object.freeze(from),
80
+ to: Object.freeze(to),
81
+ row: cell.rowIndex,
82
+ column: cell.columnIndex,
83
+ tone: cell.tone,
84
+ });
85
+ });
86
+ const rest = s.source.filter((d) => !used.has(d));
87
+ if (cells.length && commands + rest.length > 4096)
88
+ throw new TypeError('table-dot-limit');
89
+ return Object.freeze({
90
+ cells: Object.freeze(cells),
91
+ rest: Object.freeze(rest),
92
+ });
93
+ },
94
+ draw({ surface: s, options: o, prepared, progress: p, dot, reveal, revealTarget: target, }) {
95
+ const plans = prepared.cells;
96
+ if (!plans.length) {
97
+ // No per-row targets: the marks fade while the content fades and rises.
98
+ const q = 1 - (1 - clamp(p)) ** 3;
99
+ for (const d of s.source)
100
+ dot({ ...d, opacity: d.opacity * (1 - q) });
101
+ reveal({ opacity: q, translateY: (1 - q) * handoff.risePx });
102
+ return;
103
+ }
104
+ for (const d of prepared.rest)
105
+ dot({ ...d, opacity: d.opacity * (1 - clamp(p)) ** 3 });
106
+ const ms = p * rowsDuration(o);
107
+ reveal({ opacity: 1 });
108
+ for (const id of s.revealTargetIds) {
109
+ const cell = s.input.cells.find((c) => c.rowId === id);
110
+ if (!cell)
111
+ continue;
112
+ const q = clamp((ms - Math.min(cell?.rowIndex ?? 0, 7) * o.staggerMs) / cellWindowMs), show = 1 - (1 - clamp((q - 0.35) / 0.45)) ** 3;
113
+ target(id, { opacity: show, translateY: (1 - show) * o.settlePx });
114
+ }
115
+ for (const plan of plans) {
116
+ const q = clamp((ms -
117
+ Math.min(plan.row, 7) * o.staggerMs -
118
+ Math.min(plan.column, 6) * cellStaggerMs) /
119
+ cellWindowMs), morph = smooth(q / 0.65), alpha = (1 - clamp((q - 0.45) / 0.55)) ** 3;
120
+ for (let k = 0; k < Math.max(plan.from.length, plan.to.length); k++) {
121
+ const a = plan.from[k % Math.max(1, plan.from.length)] ?? plan.to[k], b = plan.to[k % Math.max(1, plan.to.length)] ?? a;
122
+ if (!a || !b)
123
+ continue;
124
+ dot({
125
+ x: mix(a.x, b.x, morph),
126
+ y: mix(a.y, b.y, morph),
127
+ size: mix(a.size, b.size, morph),
128
+ opacity: mix(a.opacity, b.opacity, morph) * alpha,
129
+ tone: morph > 0.3 ? plan.tone : a.tone,
130
+ });
131
+ }
132
+ }
133
+ },
134
+ });
135
+ export const rowsFactory = /* @__PURE__ */ tableFactory(rowsDefinition, { staggerMs: [80, 0, 120], settlePx: [5, 0, 8] });
136
+ export const defaultRows = /* @__PURE__ */ tableBinding(rowsDefinition, {
137
+ staggerMs: 80,
138
+ settlePx: 5,
139
+ });
@@ -0,0 +1,12 @@
1
+ import type { AnimationBinding, AnimationFactory, AnimationPhase } from '../animations.js';
2
+ export declare const tableCellStyles: readonly string[];
3
+ export declare function tableBinding<P extends AnimationPhase, O extends object>(definition: Readonly<{
4
+ family: 'table';
5
+ phase: P;
6
+ id: string;
7
+ }>, options: O): AnimationBinding<'table', P, O>;
8
+ export declare function tableFactory<P extends AnimationPhase, O extends object>(definition: Readonly<{
9
+ family: 'table';
10
+ phase: P;
11
+ id: string;
12
+ }>, schema: Record<string, readonly [number, number, number]>, styles?: boolean): AnimationFactory<'table', P, O>;
@@ -0,0 +1,44 @@
1
+ import { LoaderConfigurationError } from '../types.js';
2
+ import { brand } from './binding.js';
3
+ import { clamp } from './math.js';
4
+ export const tableCellStyles = /* @__PURE__ */ Object.freeze([
5
+ 'auto',
6
+ 'text',
7
+ 'number',
8
+ 'badge',
9
+ 'date',
10
+ 'badge-text',
11
+ 'text-badge',
12
+ ]);
13
+ export function tableBinding(definition, options) {
14
+ return Object.freeze({
15
+ contractVersion: 1,
16
+ family: 'table',
17
+ phase: definition.phase,
18
+ id: definition.id,
19
+ options: Object.freeze(options),
20
+ [brand]: definition,
21
+ });
22
+ }
23
+ export function tableFactory(definition, schema, styles = false) {
24
+ return (options = {}) => {
25
+ if (!options ||
26
+ Object.getPrototypeOf(options) !== Object.prototype ||
27
+ Reflect.ownKeys(options).some((k) => !Object.hasOwn(schema, k) && !(styles && k === 'cellStyle')))
28
+ throw new LoaderConfigurationError('invalid-options', 'Invalid table options');
29
+ const out = { ...options };
30
+ for (const [key, [fallback, min, max]] of Object.entries(schema)) {
31
+ const n = out[key] ?? fallback;
32
+ if (!Number.isFinite(n))
33
+ throw new LoaderConfigurationError('invalid-options', 'Invalid table options');
34
+ out[key] = clamp(n, min, max);
35
+ }
36
+ if (styles) {
37
+ const style = out.cellStyle ?? 'auto';
38
+ if (!tableCellStyles.includes(style))
39
+ throw new LoaderConfigurationError('invalid-options', 'Invalid cell style');
40
+ out.cellStyle = style;
41
+ }
42
+ return tableBinding(definition, out);
43
+ };
44
+ }
@@ -0,0 +1,12 @@
1
+ import type { AnimationSurface, Dot } from '../animations.js';
2
+ import type { TypeOnOptions } from '../table-animations.js';
3
+ export declare const tableAppearance: unique symbol;
4
+ /**
5
+ * The table idle (design/SPEC.md). Each cell shows bars of marks, two rows
6
+ * tall, at the resting opacity; the field breathes ±7% every 3.2 s. The
7
+ * default (`shimmer`) keeps the bars still under a teal glow that drifts
8
+ * across every 2.8 s; type-on grows them instead, with an accent caret.
9
+ * Every mark is the same size. Bounded command generation, no per-frame
10
+ * layout or geometry discovery.
11
+ */
12
+ export declare function tableField(surface: AnimationSurface<'table'>, options: Readonly<TypeOnOptions>, time: number, still: boolean, dot: (d: Dot) => void, shimmer?: boolean): undefined;
@@ -0,0 +1,75 @@
1
+ import { peakOpacity, restOpacity } from './marks.js';
2
+ import { clamp } from './math.js';
3
+ export const tableAppearance = Symbol('dotquilt.table-appearance');
4
+ /**
5
+ * The table idle (design/SPEC.md). Each cell shows bars of marks, two rows
6
+ * tall, at the resting opacity; the field breathes ±7% every 3.2 s. The
7
+ * default (`shimmer`) keeps the bars still under a teal glow that drifts
8
+ * across every 2.8 s; type-on grows them instead, with an accent caret.
9
+ * Every mark is the same size. Bounded command generation, no per-frame
10
+ * layout or geometry discovery.
11
+ */
12
+ export function tableField(surface, options, time, still, dot, shimmer = false) {
13
+ const appearance = Reflect.get(surface, tableAppearance), pitch = appearance?.pitch ?? 9, rows = appearance?.rows ?? pitch, scale = appearance?.scale ?? 2.2;
14
+ const cells = surface.input.cells;
15
+ const area = cells.reduce((n, c) => n + Math.max(0, c.bounds.width) * Math.max(0, c.bounds.height) * 0.35, 0);
16
+ // Large tables spread their marks out; rows keep the mark's proportions.
17
+ const step = Math.max(pitch, Math.sqrt(area / 3000)), rowStep = (step / pitch) * rows;
18
+ let count = 0;
19
+ const t = (time * 600) / options.cadenceMs, seconds = time / 1000, breath = still ? 1 : 0.93 + 0.07 * Math.sin((2 * Math.PI * seconds) / 3.2), glowAt = -0.5 + 2 * (0.5 - 0.5 * Math.cos(Math.PI * ((seconds / 2.8) % 1))), fieldWidth = Math.max(1, surface.width), fieldHeight = Math.max(1, surface.height);
20
+ for (const cell of cells) {
21
+ const b = cell.bounds, phase = (((t - cell.rowIndex * 80 - cell.columnIndex * 60) % 1600) + 1600) %
22
+ 1600;
23
+ const run = still || shimmer
24
+ ? 0.72
25
+ : 0.12 +
26
+ 0.74 * (clamp(phase / 600) - clamp((phase - 1150) / 350) * 0.85);
27
+ const available = Math.max(0, b.width - 12), barWidth = available * run, kind = options.cellStyle === 'auto' ? cell.kind : options.cellStyle;
28
+ // Two rows of marks centred on the cell, like a line placeholder.
29
+ const middle = b.y + b.height / 2;
30
+ const band = (start, w) => {
31
+ for (let x = start + step / 2; x < Math.min(b.x + b.width, start + w); x += step)
32
+ for (const y of [middle - rowStep / 2, middle + rowStep / 2]) {
33
+ if (++count > 4096)
34
+ return;
35
+ const caret = shimmer || still ? 0 : Math.exp(-(((x - start - w) / 9) ** 2));
36
+ dot({
37
+ x,
38
+ y,
39
+ size: scale,
40
+ opacity: restOpacity * breath + caret * 0.3,
41
+ tone: caret > 0.5 ? 'accent' : 'base',
42
+ });
43
+ if (!shimmer || still)
44
+ continue;
45
+ const d = (x / fieldWidth) * 0.8 + (y / fieldHeight) * 0.2 - glowAt, glow = Math.abs(d / 0.2) > 3.2 ? 0 : Math.exp(-((d / 0.2) ** 2));
46
+ if (glow * peakOpacity >= 0.02 && ++count <= 4096)
47
+ dot({
48
+ x,
49
+ y,
50
+ size: scale,
51
+ opacity: glow * peakOpacity,
52
+ tone: 'accent',
53
+ });
54
+ }
55
+ };
56
+ if (kind === 'badge')
57
+ band(b.x + 4, available * 0.45);
58
+ else if (kind === 'badge-text') {
59
+ const w = Math.min(24, available * 0.22);
60
+ band(b.x + 4, w);
61
+ band(b.x + w + 12, Math.min(barWidth, Math.max(0, available - w - 8)));
62
+ }
63
+ else if (kind === 'text-badge') {
64
+ const w = Math.min(barWidth, available * 0.58);
65
+ band(b.x + 4, w);
66
+ band(b.x + w + 12, Math.min(24, Math.max(0, available - w - 8)));
67
+ }
68
+ else if (kind === 'date') {
69
+ for (let g = 0; g < 3; g++)
70
+ band(b.x + 4 + g * available * 0.24, available * 0.17);
71
+ }
72
+ else
73
+ band(kind === 'number' ? b.x + b.width - barWidth - 4 : b.x + 4, barWidth);
74
+ }
75
+ }