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
package/dist/text.js ADDED
@@ -0,0 +1,402 @@
1
+ import { definitionOf } from './internal/binding.js';
2
+ import { ancestors, media, node, register, upgradeProperties, } from './internal/dom.js';
3
+ import { documentDots } from './internal/ledger.js';
4
+ import { LoadingController } from './internal/loading-controller.js';
5
+ import { pointer } from './internal/painter.js';
6
+ import { textPreset } from './internal/preset.js';
7
+ import { capturePresetData } from './internal/preset-data.js';
8
+ import { readSurface } from './internal/surface.js';
9
+ import { defaultTextHandoff as handoff, defaultTextIdle as idle, } from './internal/text-definitions.js';
10
+ import { textStyles } from './text-styles.js';
11
+ export class TextLoader extends LoadingController {
12
+ upgrade() {
13
+ super.upgrade();
14
+ upgradeProperties(this, ['speed', 'pointerResponse']);
15
+ }
16
+ capturePreset(value) {
17
+ return capturePresetData(value, 'text', () => textPreset);
18
+ }
19
+ static observedAttributes = [
20
+ ...LoadingController.observedAttributes,
21
+ 'mask',
22
+ 'speed',
23
+ 'pointer-response',
24
+ ];
25
+ get family() {
26
+ return 'text';
27
+ }
28
+ get styles() {
29
+ return textStyles;
30
+ }
31
+ handoffSource() {
32
+ return {
33
+ binding: this.preset?.animations?.handoff ?? handoff,
34
+ host: this,
35
+ animation: 'dotquilt/fade',
36
+ };
37
+ }
38
+ #runner;
39
+ #runnerDefinition;
40
+ #mask;
41
+ #surface;
42
+ #source = [];
43
+ #nodes = [];
44
+ #value = '';
45
+ #geometry;
46
+ #owner;
47
+ #ownerObserver;
48
+ get activity() {
49
+ return this.#owner?.activity ?? super.activity;
50
+ }
51
+ get animations() {
52
+ return super.animations;
53
+ }
54
+ set animations(value) {
55
+ super.animations = value;
56
+ this.#runner?.reset?.();
57
+ }
58
+ update(patch) {
59
+ super.update(patch);
60
+ }
61
+ get optionNames() {
62
+ return [...super.optionNames, 'mask', 'speed', 'pointerResponse'];
63
+ }
64
+ get mask() {
65
+ return this.getAttribute('mask') ?? undefined;
66
+ }
67
+ set mask(value) {
68
+ if (value === undefined)
69
+ this.removeAttribute('mask');
70
+ else
71
+ this.setAttribute('mask', String(value));
72
+ }
73
+ get speed() {
74
+ const n = Number(this.getAttribute('speed') ?? this.preset?.speed ?? 1);
75
+ return Number.isFinite(n) && n > 0 ? Math.min(4, n) : 1;
76
+ }
77
+ set speed(value) {
78
+ if (value === undefined)
79
+ this.removeAttribute('speed');
80
+ else
81
+ this.setAttribute('speed', String(value));
82
+ }
83
+ get pointerResponse() {
84
+ return (this.getAttribute('pointer-response') ??
85
+ this.preset?.pointerResponse) === 'lift'
86
+ ? 'lift'
87
+ : 'none';
88
+ }
89
+ set pointerResponse(value) {
90
+ if (value === undefined)
91
+ this.removeAttribute('pointer-response');
92
+ else
93
+ this.setAttribute('pointer-response', String(value));
94
+ }
95
+ presetChanged() {
96
+ this.#runner?.reset?.();
97
+ }
98
+ connectedCallback() {
99
+ upgradeProperties(this, ['mask']);
100
+ super.connectedCallback();
101
+ let placeholder = this.slot === 'placeholder';
102
+ for (const parent of ancestors(this)) {
103
+ if (parent.localName === 'dotquilt-region') {
104
+ if (placeholder) {
105
+ this.#owner = parent;
106
+ this.#ownerObserver = new MutationObserver(() => this.requestRender());
107
+ this.#ownerObserver.observe(parent, {
108
+ attributes: true,
109
+ attributeFilter: ['data-presentation', 'state', 'cycle'],
110
+ });
111
+ }
112
+ break;
113
+ }
114
+ placeholder ||= parent.slot === 'placeholder';
115
+ }
116
+ // Unstyled, the mask would render as plain text beside the static one.
117
+ this.whenStyled(() => {
118
+ const placeholderLayer = this.shadowRoot?.querySelector('.p');
119
+ if (placeholderLayer && !this.#mask) {
120
+ this.#mask = node(this.ownerDocument, 'span', {
121
+ class: 'mask',
122
+ 'aria-hidden': 'true',
123
+ });
124
+ placeholderLayer.append(this.#mask);
125
+ // A surface measured before the mask existed has no mask glyphs, and
126
+ // the geometry may not change again to replace it: measure anew.
127
+ this.#surface = undefined;
128
+ }
129
+ });
130
+ for (const content of this.querySelectorAll(':scope > [data-dotquilt-text-content]')) {
131
+ content.removeAttribute('aria-hidden');
132
+ content.removeAttribute('inert');
133
+ }
134
+ this.listen(this.ownerDocument.fonts, 'loadingdone', this.#fontChanged);
135
+ this.listen(this.shadowRoot, 'load', this.#fontChanged, true);
136
+ this.listen(this, 'pointermove', this.#pointer);
137
+ this.listen(this, 'pointerleave', this.#leave);
138
+ }
139
+ disconnectedCallback() {
140
+ this.#stopIdle(true);
141
+ this.#ownerObserver?.disconnect();
142
+ this.#ownerObserver = undefined;
143
+ this.#owner = undefined;
144
+ this.#surface = undefined;
145
+ this.#source = [];
146
+ this.#nodes = [];
147
+ this.#value = '';
148
+ this.#geometry = undefined;
149
+ super.disconnectedCallback();
150
+ }
151
+ environmentChanged() {
152
+ // Re-measure glyphs only when the text's size or font actually changed.
153
+ const changed = this.#geometry !== undefined && this.#geometry !== this.#geometryKey();
154
+ if (changed)
155
+ this.#surface = undefined;
156
+ if (changed && this.presentation === 'handoff')
157
+ super.refresh();
158
+ else
159
+ super.environmentChanged();
160
+ }
161
+ #geometryKey() {
162
+ const win = this.ownerDocument.defaultView;
163
+ const properties = [
164
+ 'font',
165
+ 'letterSpacing',
166
+ 'wordSpacing',
167
+ 'lineHeight',
168
+ 'direction',
169
+ 'writingMode',
170
+ 'whiteSpace',
171
+ 'textTransform',
172
+ 'padding',
173
+ 'borderWidth',
174
+ ];
175
+ return JSON.stringify([this, this.shadowRoot?.querySelector('.c')].flatMap((element) => {
176
+ const css = element && win?.getComputedStyle(element);
177
+ const bounds = element?.getBoundingClientRect();
178
+ return [
179
+ // A translated DOMRect can gain float noise in WebKit. Keep the
180
+ // same 1/64px geometry precision as the handoff bounds checks.
181
+ bounds && Math.round(bounds.width * 64) / 64,
182
+ bounds && Math.round(bounds.height * 64) / 64,
183
+ ...properties.map((property) => css?.[property]),
184
+ ];
185
+ }));
186
+ }
187
+ // A font or stylesheet finished loading somewhere on the page. Re-measure
188
+ // only if this text's geometry changed, so an unrelated font doesn't end a
189
+ // handoff in flight.
190
+ #fontChanged = () => this.environmentChanged();
191
+ #leave = () => {
192
+ Reflect.deleteProperty(this, pointer);
193
+ this.#drawIdle();
194
+ };
195
+ #pointer = (event) => {
196
+ if (this.pointerResponse !== 'lift' ||
197
+ !this.hasAttribute('data-moving') ||
198
+ event.pointerType === 'touch' ||
199
+ !media(this.ownerDocument.defaultView, '(hover:hover) and (pointer:fine)')) {
200
+ // Lift no longer applies (touch, no hover, paused): drop the old position
201
+ // so the drawing does not stay lifted at a stale point.
202
+ Reflect.deleteProperty(this, pointer);
203
+ return;
204
+ }
205
+ const rect = this.getBoundingClientRect();
206
+ Reflect.set(this, pointer, {
207
+ x: event.clientX - rect.left,
208
+ y: event.clientY - rect.top,
209
+ });
210
+ };
211
+ attributeChangedCallback(name, old, value) {
212
+ if (old !== value && name === 'mask')
213
+ this.#surface = undefined;
214
+ if (value !== null &&
215
+ (name === 'speed'
216
+ ? !Number.isFinite(+value) || +value <= 0
217
+ : name === 'pointer-response' && !['none', 'lift'].includes(value)))
218
+ this.invalidOption(name);
219
+ super.attributeChangedCallback(name, old, value);
220
+ }
221
+ refresh() {
222
+ this.#surface = undefined;
223
+ super.refresh();
224
+ }
225
+ contentChanged() {
226
+ const [nodes, value, precise] = this.#plain();
227
+ if (!precise ||
228
+ value !== this.#value ||
229
+ nodes.length !== this.#nodes.length ||
230
+ nodes.some((node, i) => node !== this.#nodes[i]))
231
+ this.refresh();
232
+ }
233
+ settled() {
234
+ this.#source = [];
235
+ this.#surface = undefined;
236
+ }
237
+ #plain() {
238
+ const nodes = [];
239
+ if (this.childNodes.length > 258)
240
+ return [nodes, '', false];
241
+ let value = '', precise = true;
242
+ for (const child of this.childNodes) {
243
+ // The static stylesheet stays until the shadow stylesheet applies.
244
+ if (child instanceof Element &&
245
+ (child.hasAttribute('slot') ||
246
+ child.hasAttribute('data-dotquilt-style')))
247
+ continue;
248
+ if (child.childNodes.length > 256)
249
+ return [nodes, '', false];
250
+ const contents = child instanceof Element &&
251
+ child.hasAttribute('data-dotquilt-text-content')
252
+ ? child.childNodes
253
+ : [child];
254
+ for (const content of contents) {
255
+ if (content.nodeType !== 3) {
256
+ if (content.nodeType !== 8)
257
+ precise = false;
258
+ continue;
259
+ }
260
+ const text = content;
261
+ if (value.length + text.length > 256) {
262
+ precise = false;
263
+ continue;
264
+ }
265
+ nodes.push(text);
266
+ value += text.data;
267
+ }
268
+ }
269
+ return [nodes, value, precise && /^[\x20-\x7e]*$/.test(value)];
270
+ }
271
+ [readSurface](_family, ids = []) {
272
+ if (this.#surface)
273
+ return this.#surface;
274
+ this.#geometry = this.#geometryKey();
275
+ const [nodes, value, plain] = this.#plain();
276
+ this.#nodes = nodes;
277
+ this.#value = value;
278
+ const mask = this.mask ?? value;
279
+ const displayMask = mask.length <= 256 ? mask : '';
280
+ if (this.#mask && this.#mask.textContent !== displayMask)
281
+ this.#mask.textContent = displayMask;
282
+ const rect = this.getBoundingClientRect();
283
+ const measure = (texts) => {
284
+ const cells = [];
285
+ const range = this.ownerDocument.createRange();
286
+ for (const text of texts)
287
+ for (let i = 0; i < text.length; i++) {
288
+ range.setStart(text, i);
289
+ range.setEnd(text, i + 1);
290
+ const b = range.getBoundingClientRect();
291
+ cells.push(Object.freeze({
292
+ character: text.data[i] ?? '',
293
+ bounds: Object.freeze({
294
+ x: b.x - rect.x,
295
+ y: b.y - rect.y + b.height * 0.13,
296
+ width: b.width,
297
+ height: b.height * 0.74,
298
+ }),
299
+ }));
300
+ }
301
+ return Object.freeze(cells);
302
+ };
303
+ const supported = plain &&
304
+ mask.length <= 256 &&
305
+ /^[\x20-\x7e]*$/.test(mask) &&
306
+ this.ownerDocument.defaultView?.getComputedStyle(this).direction !==
307
+ 'rtl';
308
+ const maskCells = supported && this.#mask?.firstChild
309
+ ? measure([this.#mask.firstChild])
310
+ : [];
311
+ const valueCells = supported ? measure(nodes) : [];
312
+ const singleLine = (cells) => cells.every((cell) => Math.abs(cell.bounds.y - (cells[0]?.bounds.y ?? 0)) < 1);
313
+ const count = Math.max(maskCells.length * 35, valueCells.length * 35 + this.#source.length);
314
+ const precise = !!supported &&
315
+ singleLine(maskCells) &&
316
+ singleLine(valueCells) &&
317
+ count <= 4096 &&
318
+ documentDots(this.ownerDocument) + count <= 16384 &&
319
+ rect.width > 0 &&
320
+ rect.height > 0;
321
+ this.toggleAttribute('data-dotquilt-glyphs', precise);
322
+ // Content that isn't plain text reports again only after it was plain.
323
+ if (!plain)
324
+ this.report('generic-text-fallback', 'children');
325
+ else
326
+ this.accept('children');
327
+ this.#surface = Object.freeze({
328
+ family: 'text',
329
+ width: rect.width,
330
+ height: rect.height,
331
+ input: Object.freeze({
332
+ shapes: Object.freeze([]),
333
+ mask: Object.freeze(maskCells),
334
+ value: Object.freeze(valueCells),
335
+ precise,
336
+ }),
337
+ source: this.#source,
338
+ revealTargetIds: Object.freeze([...ids]),
339
+ });
340
+ return this.#surface;
341
+ }
342
+ #stopIdle(discard = false) {
343
+ this.#runner?.dispose();
344
+ if (discard) {
345
+ this.#runner = undefined;
346
+ this.#runnerDefinition = undefined;
347
+ }
348
+ this.clearDeadline();
349
+ this.removeAttribute('data-moving');
350
+ Reflect.deleteProperty(this, pointer);
351
+ }
352
+ #drawIdle = () => {
353
+ if (!this.isConnected || this.state !== 'pending') {
354
+ this.#stopIdle(true);
355
+ return;
356
+ }
357
+ if (this.#owner && this.#owner.presentation !== 'pending') {
358
+ this.#stopIdle();
359
+ return;
360
+ }
361
+ const surface = this[readSurface]('text');
362
+ if (!surface.input.precise ||
363
+ !surface.input.mask.length ||
364
+ media(this.ownerDocument.defaultView, '(forced-colors: active)')) {
365
+ this.#stopIdle();
366
+ return;
367
+ }
368
+ const binding = this.animations.idle ?? this.preset?.animations?.idle ?? idle;
369
+ const definition = definitionOf(binding);
370
+ if (this.#runnerDefinition !== definition) {
371
+ this.#runner?.dispose();
372
+ this.#runner = definition.runner?.(this, (code) => this.report(code, 'animations'), this.#drawIdle);
373
+ this.#runnerDefinition = definition;
374
+ }
375
+ const moving = this.allowed(this.activity);
376
+ this.toggleAttribute('data-moving', moving);
377
+ if (!moving || this.pointerResponse !== 'lift')
378
+ Reflect.deleteProperty(this, pointer);
379
+ if (!moving)
380
+ this.clearDeadline();
381
+ this.#runner?.draw(binding, !moving, this.speed);
382
+ if (moving && this.deadline === undefined)
383
+ this.arm(this.activity);
384
+ };
385
+ render() {
386
+ if (this.state !== 'pending') {
387
+ if (this.#runner) {
388
+ this.#source = this.#runner.capture?.() ?? Object.freeze([]);
389
+ this.#stopIdle(true);
390
+ this.#surface = undefined;
391
+ if (this.state !== 'ready')
392
+ this.#source = [];
393
+ }
394
+ }
395
+ this[readSurface]('text');
396
+ super.render();
397
+ this.#drawIdle();
398
+ }
399
+ }
400
+ export function registerTextLoader() {
401
+ register('dotquilt-text-loader', TextLoader);
402
+ }
@@ -0,0 +1,56 @@
1
+ export type LoadingState = 'pending' | 'refreshing' | 'ready';
2
+ export type Motion = 'system' | 'paused';
3
+ /** The shape loaders draw: round dots (default), dashes or squares (design/SPEC.md). */
4
+ export type Mark = 'dot' | 'dash' | 'square';
5
+ export declare const marks: readonly Mark[];
6
+ export type StylePolicy = Readonly<{
7
+ mode: 'inline';
8
+ nonce?: string;
9
+ }> | Readonly<{
10
+ mode: 'external';
11
+ href: string;
12
+ }>;
13
+ export interface Timing {
14
+ readonly duration?: number;
15
+ readonly easing?: string;
16
+ }
17
+ export interface HandoffDetail {
18
+ readonly cycle: string | undefined;
19
+ readonly handoffId: number;
20
+ readonly animation: string;
21
+ readonly reason?: string;
22
+ }
23
+ export interface LoaderErrorDetail {
24
+ readonly code: string;
25
+ readonly field: string;
26
+ }
27
+ export declare class LoaderRegistrationError extends Error {
28
+ readonly elementName: string;
29
+ readonly code = "registration-conflict";
30
+ constructor(elementName: string);
31
+ }
32
+ export declare class LoaderConfigurationError extends TypeError {
33
+ readonly code: string;
34
+ constructor(code: string, message: string);
35
+ }
36
+ export interface DotquiltEventMap {
37
+ 'dotquilt-handoff-start': CustomEvent<HandoffDetail>;
38
+ 'dotquilt-handoff-end': CustomEvent<HandoffDetail>;
39
+ 'dotquilt-handoff-cancel': CustomEvent<HandoffDetail>;
40
+ 'dotquilt-error': CustomEvent<LoaderErrorDetail>;
41
+ }
42
+ declare global {
43
+ interface HTMLElementEventMap extends DotquiltEventMap {
44
+ }
45
+ interface HTMLElementTagNameMap {
46
+ 'dotquilt-table-loader': import('./table.js').TableLoader;
47
+ 'dotquilt-chart-loader': import('./chart.js').ChartLoader;
48
+ 'dotquilt-text-loader': import('./text.js').TextLoader;
49
+ 'dotquilt-region': import('./region.js').LoadingRegion;
50
+ 'dotquilt-skeleton-block': import('./skeleton.js').SkeletonBlock;
51
+ 'dotquilt-skeleton-line': import('./skeleton-line.js').SkeletonLine;
52
+ 'dotquilt-skeleton-circle': import('./skeleton-circle.js').SkeletonCircle;
53
+ 'dotquilt-skeleton-text': import('./skeleton-text.js').SkeletonText;
54
+ 'dotquilt-typing-dots': import('./typing.js').TypingDots;
55
+ }
56
+ }
package/dist/types.js ADDED
@@ -0,0 +1,18 @@
1
+ export const marks = Object.freeze(['dot', 'dash', 'square']);
2
+ export class LoaderRegistrationError extends Error {
3
+ elementName;
4
+ code = 'registration-conflict';
5
+ constructor(elementName) {
6
+ super(`${elementName} is already defined by other code. Load one copy of Dotquilt per page.`);
7
+ this.elementName = elementName;
8
+ this.name = 'LoaderRegistrationError';
9
+ }
10
+ }
11
+ export class LoaderConfigurationError extends TypeError {
12
+ code;
13
+ constructor(code, message) {
14
+ super(message);
15
+ this.code = code;
16
+ this.name = 'LoaderConfigurationError';
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export declare const typingStyles: readonly string[];
@@ -0,0 +1,7 @@
1
+ import { markColor, typingGap, typingShapes, typingSize, } from './internal/marks.js';
2
+ import { unstyledHold } from './internal/unstyled.js';
3
+ // Its own module, so TypingDots loads none of the skeleton stylesheets.
4
+ export const typingStyles = /* @__PURE__ */ Object.freeze([
5
+ `:host,dotquilt-typing-dots{display:inline-flex;position:relative;align-items:center;height:1em}:host .dot{display:inline-block;vertical-align:middle;width:${typingSize};height:${typingSize};border-radius:50%;background:${markColor};opacity:.3}:host .dot+.dot{margin-inline-start:${typingGap}}${typingShapes((mark) => `:host([mark=${mark}])`, '.dot')}:host([hidden]){display:none}@media(forced-colors:active){:host .dot{background:CanvasText}}`,
6
+ unstyledHold,
7
+ ]);
@@ -0,0 +1,4 @@
1
+ :host,dotquilt-typing-dots{display:inline-flex;position:relative;align-items:center;height:1em}:host .dot{display:inline-block;vertical-align:middle;width:var(--dotquilt-dot-size,8px);height:var(--dotquilt-dot-size,8px);border-radius:50%;background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2));opacity:.3}:host .dot+.dot{margin-inline-start:var(--dotquilt-dot-gap,6px)}:host([mark=square]) .dot{width:calc(var(--dotquilt-dot-size,8px)*.9);height:calc(var(--dotquilt-dot-size,8px)*.9);border-radius:calc(var(--dotquilt-dot-size,8px)*.25)}:host([mark=dash]) .dot{width:calc(var(--dotquilt-dot-size,8px)*2.16);height:calc(var(--dotquilt-dot-size,8px)*.8);border-radius:999px}:host([hidden]){display:none}@media(forced-colors:active){:host .dot{background:CanvasText}}
2
+ :host(:state(unstyled)) > :not(slot){display:none!important}
3
+ dotquilt-typing-dots{display:inline-flex;align-items:center;height:1em}dotquilt-typing-dots [data-dotquilt-static]{display:inline-flex;align-items:center;gap:var(--dotquilt-dot-gap,6px)}dotquilt-typing-dots .dot{display:block;width:var(--dotquilt-dot-size,8px);height:var(--dotquilt-dot-size,8px);border-radius:50%;background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2));opacity:.3}@media(forced-colors:active){dotquilt-typing-dots .dot{background:CanvasText}}
4
+ dotquilt-typing-dots[mark=square] .dot{width:calc(var(--dotquilt-dot-size,8px)*.9);height:calc(var(--dotquilt-dot-size,8px)*.9);border-radius:calc(var(--dotquilt-dot-size,8px)*.25)}dotquilt-typing-dots[mark=dash] .dot{width:calc(var(--dotquilt-dot-size,8px)*2.16);height:calc(var(--dotquilt-dot-size,8px)*.8);border-radius:999px}
@@ -0,0 +1,35 @@
1
+ import { type Activity, ManagedElement } from './internal/element.js';
2
+ import type { Preset } from './internal/preset.js';
3
+ interface Owner extends HTMLElement {
4
+ activity: Activity;
5
+ presentation: string;
6
+ }
7
+ /** Decorative activity only. Application readiness belongs to LoadingRegion. */
8
+ export declare class TypingDots extends ManagedElement<'typing'> {
9
+ #private;
10
+ protected upgrade(): void;
11
+ protected capturePreset(value: Preset<'typing'>): Preset<'typing'>;
12
+ static observedAttributes: string[];
13
+ get count(): number;
14
+ set count(value: number | undefined);
15
+ get speed(): number;
16
+ set speed(value: number | undefined);
17
+ get owner(): Owner | undefined;
18
+ get activity(): Activity;
19
+ connectedCallback(): void;
20
+ disconnectedCallback(): void;
21
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
22
+ update(patch: {
23
+ readonly count?: number | undefined;
24
+ readonly speed?: number | undefined;
25
+ readonly motion?: import('./types.js').Motion | undefined;
26
+ readonly preset?: TypingPreset | undefined;
27
+ readonly stylePolicy?: import('./types.js').StylePolicy;
28
+ }): void;
29
+ protected get optionNames(): readonly string[];
30
+ refresh(): void;
31
+ protected render(): void;
32
+ }
33
+ export declare function registerTypingDots(): void;
34
+ export type TypingPreset = import('./internal/preset.js').Preset<'typing'>;
35
+ export {};