dotquilt 0.0.0-stage → 0.1.1

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 +698 -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 @@
1
+ export declare const regionCss = "dotquilt-region:state(unstyled)::part(placeholder),dotquilt-region:state(unstyled)::part(refresh-indicator){visibility:hidden;pointer-events:none}dotquilt-region:state(unstyled)[data-presentation=pending]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=handoff]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=refreshing]::part(refresh-indicator){visibility:inherit}dotquilt-region:state(unstyled)[data-presentation=pending]::part(content){visibility:hidden}:host{display:grid;position:relative}:host(:focus){outline:none}:host(:focus-visible:not([data-dotquilt-focus=pointer])),:host([data-dotquilt-focus=\"\"]:focus){outline:2px solid currentColor;outline-offset:3px}:host .f{display:grid;min-width:0;min-height:100%}:host [part]{display:block;grid-area:1/1;min-width:0}:host .p,:host .r{visibility:hidden;pointer-events:none}:host([data-presentation=pending]) .p,:host([data-presentation=handoff]) .p,:host([data-presentation=refreshing]) .r{visibility:inherit}:host([data-presentation=pending]) .c{visibility:hidden}:host([hidden]){display:none}:host > svg{position:absolute;inset:0;pointer-events:none}:host .fallback{display:block;min-height:1em;border:1px dotted currentColor}:host([data-dotquilt-waiting]) .p{visibility:hidden}";
@@ -0,0 +1,6 @@
1
+ // Plain CSS with nothing built at load time, so TextLoader takes it without
2
+ // the region's refresh cue.
3
+ // The layers are slots (`display: contents` until styled), so they need boxes.
4
+ // The `:state(unstyled)` rules apply in the document while a region's external
5
+ // stylesheet loads, mirroring the layer visibility below.
6
+ export const regionCss = `dotquilt-region:state(unstyled)::part(placeholder),dotquilt-region:state(unstyled)::part(refresh-indicator){visibility:hidden;pointer-events:none}dotquilt-region:state(unstyled)[data-presentation=pending]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=handoff]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=refreshing]::part(refresh-indicator){visibility:inherit}dotquilt-region:state(unstyled)[data-presentation=pending]::part(content){visibility:hidden}:host{display:grid;position:relative}:host(:focus){outline:none}:host(:focus-visible:not([data-dotquilt-focus=pointer])),:host([data-dotquilt-focus=""]:focus){outline:2px solid currentColor;outline-offset:3px}:host .f{display:grid;min-width:0;min-height:100%}:host [part]{display:block;grid-area:1/1;min-width:0}:host .p,:host .r{visibility:hidden;pointer-events:none}:host([data-presentation=pending]) .p,:host([data-presentation=handoff]) .p,:host([data-presentation=refreshing]) .r{visibility:inherit}:host([data-presentation=pending]) .c{visibility:hidden}:host([hidden]){display:none}:host > svg{position:absolute;inset:0;pointer-events:none}:host .fallback{display:block;min-height:1em;border:1px dotted currentColor}:host([data-dotquilt-waiting]) .p{visibility:hidden}`;
@@ -0,0 +1,3 @@
1
+ import { regionCss } from './region-css.js';
2
+ export { regionCss };
3
+ export declare const regionStyles: readonly string[];
@@ -0,0 +1,15 @@
1
+ import { glowColor, markColor, markGap, markSize, peakOpacity, restOpacity, } from './internal/marks.js';
2
+ import { regionCss } from './region-css.js';
3
+ export { regionCss };
4
+ // Its own module: LoadingRegion loads these styles without the skeleton
5
+ // stylesheets that styles.ts builds when it loads.
6
+ /**
7
+ * The refresh cue: a row of whole marks just above the region's top edge
8
+ * (`--dotquilt-refresh-gap` above it), and an accent copy of it (`.glow`)
9
+ * that the glow drifts along. Forced colours draw a dotted line. Kept short:
10
+ * it counts towards the 9 KB gate for a page's external stylesheets.
11
+ */
12
+ const threadCss = `.thread{position:absolute;inset:auto 0 calc(100% + var(--dotquilt-refresh-gap,6px));height:var(--s);--s:${markSize};background:radial-gradient(circle closest-side,${markColor} 75%,#0000) 0/calc(var(--s) + ${markGap}) space no-repeat;opacity:${restOpacity}}.glow{--dotquilt-color:${glowColor};opacity:${peakOpacity};mask:linear-gradient(90deg,#0000,#000,#0000) -70%/40% no-repeat}@media(forced-colors:active){.thread{background:none;border-top:1px dotted;opacity:1}.glow{display:none}}`;
13
+ export const regionStyles = /* @__PURE__ */ Object.freeze([
14
+ regionCss + threadCss,
15
+ ]);
@@ -0,0 +1 @@
1
+ dotquilt-region:state(unstyled)::part(placeholder),dotquilt-region:state(unstyled)::part(refresh-indicator){visibility:hidden;pointer-events:none}dotquilt-region:state(unstyled)[data-presentation=pending]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=handoff]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=refreshing]::part(refresh-indicator){visibility:inherit}dotquilt-region:state(unstyled)[data-presentation=pending]::part(content){visibility:hidden}:host{display:grid;position:relative}:host(:focus){outline:none}:host(:focus-visible:not([data-dotquilt-focus=pointer])),:host([data-dotquilt-focus=""]:focus){outline:2px solid currentColor;outline-offset:3px}:host .f{display:grid;min-width:0;min-height:100%}:host [part]{display:block;grid-area:1/1;min-width:0}:host .p,:host .r{visibility:hidden;pointer-events:none}:host([data-presentation=pending]) .p,:host([data-presentation=handoff]) .p,:host([data-presentation=refreshing]) .r{visibility:inherit}:host([data-presentation=pending]) .c{visibility:hidden}:host([hidden]){display:none}:host > svg{position:absolute;inset:0;pointer-events:none}:host .fallback{display:block;min-height:1em;border:1px dotted currentColor}:host([data-dotquilt-waiting]) .p{visibility:hidden}.thread{position:absolute;inset:auto 0 calc(100% + var(--dotquilt-refresh-gap,6px));height:var(--s);--s:var(--dotquilt-dot-size,4.4px);background:radial-gradient(circle closest-side,var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 75%,#0000) 0/calc(var(--s) + var(--dotquilt-dot-gap,4.6px)) space no-repeat;opacity:0.37}.glow{--dotquilt-color:var(--dotquilt-accent-color,light-dark(#4f8f93,#8dc4c5));opacity:0.9;mask:linear-gradient(90deg,#0000,#000,#0000) -70%/40% no-repeat}@media(forced-colors:active){.thread{background:none;border-top:1px dotted;opacity:1}.glow{display:none}}
@@ -0,0 +1,31 @@
1
+ import type { ChartLoader } from './chart.js';
2
+ import type { HandoffSource } from './internal/handoff.js';
3
+ import { LoadingController } from './internal/loading-controller.js';
4
+ import type { SkeletonBlock } from './skeleton.js';
5
+ import type { TableLoader } from './table.js';
6
+ import type { LoadingState } from './types.js';
7
+ import type { TypingDots } from './typing.js';
8
+ export declare class LoadingRegion extends LoadingController<'region'> {
9
+ #private;
10
+ /**
11
+ * The refresh cue (design/SPEC.md): a row of marks along the top edge.
12
+ * It sits just above the region, so the content never moves.
13
+ */
14
+ protected refreshCue(): Element;
15
+ /** It eases in, and the glow drifts along it once (2.8 s, under the 4 s limit). */
16
+ protected refreshStarted(cue: Element): void;
17
+ disconnectedCallback(): void;
18
+ /** A region draws no marks of its own; its placeholder takes `mark`. */
19
+ protected get optionNames(): readonly string[];
20
+ protected contentChanged(): void;
21
+ protected settled(): void;
22
+ protected get family(): 'region';
23
+ protected get styles(): readonly string[];
24
+ protected placeholderChanged(placeholder: HTMLSlotElement, state: LoadingState): void;
25
+ protected participants(): (SkeletonBlock | TypingDots | ChartLoader | TableLoader)[];
26
+ protected refreshParticipants(): void;
27
+ protected handoffSource(): HandoffSource;
28
+ }
29
+ export declare function registerLoadingRegion(): void;
30
+ export { refreshStyles } from './internal/element.js';
31
+ export type RegionPreset = import('./internal/preset.js').Preset<'region'>;
package/dist/region.js ADDED
@@ -0,0 +1,100 @@
1
+ import { chartHandoff, richHandoff } from './internal/chart-participant.js';
2
+ import { node, register } from './internal/dom.js';
3
+ import { LoadingController } from './internal/loading-controller.js';
4
+ import { curves } from './internal/marks.js';
5
+ import { createSkeletonSource, loadMorph } from './internal/skeleton-source.js';
6
+ import { regionStyles } from './region-styles.js';
7
+ export class LoadingRegion extends LoadingController {
8
+ #thread;
9
+ #pass = [];
10
+ /**
11
+ * The refresh cue (design/SPEC.md): a row of marks along the top edge.
12
+ * It sits just above the region, so the content never moves.
13
+ */
14
+ refreshCue() {
15
+ if (!this.#thread) {
16
+ // The marks, and their accent copy beside them for the glow; the
17
+ // wrapper fades both in.
18
+ this.#thread = node(this.ownerDocument, 'span', {
19
+ part: 'refresh-thread',
20
+ 'aria-hidden': 'true',
21
+ });
22
+ this.#thread.append(node(this.ownerDocument, 'span', { class: 'thread' }), node(this.ownerDocument, 'span', { class: 'thread glow' }));
23
+ }
24
+ return this.#thread;
25
+ }
26
+ /** It eases in, and the glow drifts along it once (2.8 s, under the 4 s limit). */
27
+ refreshStarted(cue) {
28
+ for (const animation of this.#pass.splice(0))
29
+ animation.cancel();
30
+ if (!this.canAnimate())
31
+ return;
32
+ try {
33
+ this.#pass.push(cue.animate({ opacity: [0, 1] }, { duration: 320, easing: curves.settle }), cue.lastElementChild.animate({ maskPosition: ['-70% 0', '170% 0'] }, { duration: 2800, easing: curves.sine }));
34
+ }
35
+ catch {
36
+ this.report('animation-failed', 'animations');
37
+ }
38
+ }
39
+ disconnectedCallback() {
40
+ super.disconnectedCallback();
41
+ for (const animation of this.#pass.splice(0))
42
+ animation.cancel();
43
+ }
44
+ /** A region draws no marks of its own; its placeholder takes `mark`. */
45
+ get optionNames() {
46
+ return super.optionNames.filter((name) => name !== 'mark');
47
+ }
48
+ contentChanged() {
49
+ this.refresh();
50
+ }
51
+ settled() { }
52
+ get family() {
53
+ return 'region';
54
+ }
55
+ get styles() {
56
+ return regionStyles;
57
+ }
58
+ placeholderChanged(placeholder, state) {
59
+ // The placeholder shows: fetch the reveal it will hand over with.
60
+ if (state === 'pending')
61
+ loadMorph();
62
+ if (state === 'pending' && !placeholder.assignedNodes().length) {
63
+ if (!placeholder.firstChild)
64
+ placeholder.append(node(this.ownerDocument, 'span', { class: 'fallback' }));
65
+ this.report('missing-placeholder', 'placeholder');
66
+ }
67
+ }
68
+ participants() {
69
+ return [
70
+ ...this.querySelectorAll('[data-dotquilt-surface]'),
71
+ ].filter((child) => child.owner === this);
72
+ }
73
+ refreshParticipants() {
74
+ for (const child of this.participants())
75
+ child.refresh();
76
+ }
77
+ handoffSource() {
78
+ const participants = this.participants();
79
+ const rich = participants.filter((participant) => chartHandoff in participant);
80
+ const chart = rich[0];
81
+ // A table hands over like every other placeholder (morph.ts) unless a
82
+ // chart is in the placeholder or anyone picks an animation.
83
+ const morph = !rich.some((participant) => participant.localName === 'dotquilt-chart-loader') &&
84
+ !this.animations.handoff &&
85
+ !this.preset?.animations?.handoff &&
86
+ !rich.some((participant) => participant[richHandoff]);
87
+ if (chart && !morph) {
88
+ const binding = this.animations.handoff ?? this.preset?.animations?.handoff;
89
+ if (binding)
90
+ return { binding, host: this, animation: binding.id };
91
+ return chart[chartHandoff](this, rich);
92
+ }
93
+ const child = participants.find((participant) => 'animations' in participant && !(chartHandoff in participant));
94
+ return createSkeletonSource(child, this, participants);
95
+ }
96
+ }
97
+ export function registerLoadingRegion() {
98
+ register('dotquilt-region', LoadingRegion);
99
+ }
100
+ export { refreshStyles } from './internal/element.js';
@@ -0,0 +1,2 @@
1
+ /** Explicit convenience setup. Importing this module never registers elements. */
2
+ export declare function registerAll(): void;
@@ -0,0 +1,33 @@
1
+ import { ChartLoader } from './chart.js';
2
+ import { register } from './internal/dom.js';
3
+ import { LoadingRegion } from './region.js';
4
+ import { SkeletonBlock, SkeletonCircle, SkeletonLine, SkeletonText, } from './skeleton.js';
5
+ import { TableLoader } from './table.js';
6
+ import { TextLoader } from './text.js';
7
+ import { LoaderRegistrationError } from './types.js';
8
+ import { TypingDots } from './typing.js';
9
+ /** Explicit convenience setup. Importing this module never registers elements. */
10
+ export function registerAll() {
11
+ if (typeof customElements === 'undefined')
12
+ throw new Error('Registration requires a browser');
13
+ const definitions = [
14
+ ['dotquilt-skeleton-block', SkeletonBlock],
15
+ ['dotquilt-skeleton-line', SkeletonLine],
16
+ ['dotquilt-skeleton-circle', SkeletonCircle],
17
+ ['dotquilt-skeleton-text', SkeletonText],
18
+ ['dotquilt-typing-dots', TypingDots],
19
+ ['dotquilt-text-loader', TextLoader],
20
+ ['dotquilt-chart-loader', ChartLoader],
21
+ ['dotquilt-table-loader', TableLoader],
22
+ ['dotquilt-region', LoadingRegion],
23
+ ];
24
+ // Check the entire batch before avoidable writes. Reentrant upgrades still use
25
+ // each definition's normal conflict check; there is no rollback promise.
26
+ for (const [name, definition] of definitions) {
27
+ const existing = customElements.get(name);
28
+ if (existing && existing !== definition)
29
+ throw new LoaderRegistrationError(name);
30
+ }
31
+ for (const [name, definition] of definitions)
32
+ register(name, definition);
33
+ }
@@ -0,0 +1,63 @@
1
+ import { skeletonCircleStyles, skeletonLineStyles, skeletonTextStyles, typingStyles } from './catalog-styles.js';
2
+ import { chartStyles, staticChartMarkStyles, staticChartStyles } from './chart-styles.js';
3
+ import { type Preset } from './internal/preset.js';
4
+ import { staticCircleMarkStyles, staticCircleStyles, staticLineMarkStyles, staticLineStyles, staticTextMarkStyles, staticTextStyles, staticTypingMarkStyles, staticTypingStyles } from './static-catalog-styles.js';
5
+ import { regionStyles, skeletonStyles, staticSkeletonMarkStyles, staticSkeletonStyles } from './styles.js';
6
+ import { staticTableStyles, tableStyles } from './table-styles.js';
7
+ import { staticTextLoaderMarkStyles, staticTextLoaderStyles, textStyles } from './text-styles.js';
8
+ import { type LoadingState, type Mark, type StylePolicy } from './types.js';
9
+ export { chartStyles, skeletonCircleStyles, skeletonLineStyles, skeletonTextStyles, staticChartMarkStyles, staticChartStyles, staticCircleMarkStyles, staticCircleStyles, staticLineMarkStyles, staticLineStyles, staticSkeletonMarkStyles, staticTableStyles, staticTextLoaderMarkStyles, staticTextLoaderStyles, staticTextMarkStyles, staticTextStyles, staticTypingMarkStyles, staticTypingStyles, tableStyles, textStyles, typingStyles, };
10
+ export type DecorativeDescription = Readonly<{
11
+ kind: 'table-loader';
12
+ preset?: Preset<'table'>;
13
+ rows?: number;
14
+ rowHeight?: number;
15
+ columns?: readonly import('./table.js').TableColumn[];
16
+ mark?: Mark;
17
+ stylePolicy?: StylePolicy;
18
+ }> | Readonly<{
19
+ kind: 'chart-loader';
20
+ preset?: Preset<'chart'>;
21
+ variant?: import('./chart.js').ChartVariant;
22
+ mark?: Mark;
23
+ stylePolicy?: StylePolicy;
24
+ }> | {
25
+ [K in 'skeleton-block' | 'skeleton-line' | 'skeleton-circle']: Readonly<{
26
+ kind: K;
27
+ preset?: Preset<'skeleton'>;
28
+ mark?: Mark;
29
+ stylePolicy?: StylePolicy;
30
+ }>;
31
+ }['skeleton-block' | 'skeleton-line' | 'skeleton-circle'] | Readonly<{
32
+ kind: 'skeleton-text';
33
+ preset?: Preset<'skeleton'>;
34
+ lines?: number;
35
+ widths?: readonly number[];
36
+ mark?: Mark;
37
+ stylePolicy?: StylePolicy;
38
+ }> | Readonly<{
39
+ kind: 'typing-dots';
40
+ preset?: Preset<'typing'>;
41
+ count?: number;
42
+ mark?: Mark;
43
+ stylePolicy?: StylePolicy;
44
+ }>;
45
+ export { regionStyles, skeletonStyles, staticSkeletonStyles };
46
+ export type StaticDescription = DecorativeDescription | Readonly<{
47
+ kind: 'text-loader';
48
+ preset?: Preset<'text'>;
49
+ text?: string | number;
50
+ mask?: string;
51
+ state?: LoadingState;
52
+ mark?: Mark;
53
+ stylePolicy?: StylePolicy;
54
+ }> | Readonly<{
55
+ kind: 'region';
56
+ preset?: Preset<'region'>;
57
+ state?: LoadingState;
58
+ label?: string;
59
+ placeholder?: DecorativeDescription;
60
+ stylePolicy?: StylePolicy;
61
+ }>;
62
+ /** Renders only library decoration. Applications render real content using their own templates. */
63
+ export declare function renderStatic(description: StaticDescription): string;
package/dist/server.js ADDED
@@ -0,0 +1,141 @@
1
+ import { skeletonCircleStyles, skeletonLineStyles, skeletonTextStyles, typingStyles, } from './catalog-styles.js';
2
+ import { chartStyles, staticChartMarkStyles, staticChartStyles, } from './chart-styles.js';
3
+ import { boundedCount, lineWidths } from './internal/count.js';
4
+ import { capturePreset } from './internal/preset.js';
5
+ import { tableColumns, tableHeight, tableRows, tableStaticParts, } from './internal/table-model.js';
6
+ import { staticCircleMarkStyles, staticCircleStyles, staticLineMarkStyles, staticLineStyles, staticTextMarkStyles, staticTextStyles, staticTypingMarkStyles, staticTypingStyles, } from './static-catalog-styles.js';
7
+ import { regionStyles, skeletonStyles, staticSkeletonMarkStyles, staticSkeletonStyles, } from './styles.js';
8
+ import { staticTableStyles, tableStyles } from './table-styles.js';
9
+ import { staticTextLoaderMarkStyles, staticTextLoaderStyles, textStyles, } from './text-styles.js';
10
+ import { LoaderConfigurationError, marks, } from './types.js';
11
+ export { chartStyles, skeletonCircleStyles, skeletonLineStyles, skeletonTextStyles, staticChartMarkStyles, staticChartStyles, staticCircleMarkStyles, staticCircleStyles, staticLineMarkStyles, staticLineStyles, staticSkeletonMarkStyles, staticTableStyles, staticTextLoaderMarkStyles, staticTextLoaderStyles, staticTextMarkStyles, staticTextStyles, staticTypingMarkStyles, staticTypingStyles, tableStyles, textStyles, typingStyles, };
12
+ export { regionStyles, skeletonStyles, staticSkeletonStyles };
13
+ const escapeHTML = (value) => value.replace(/[&<>"']/g, (char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char] ?? char);
14
+ function style(css, policy) {
15
+ if (policy?.mode === 'inline' &&
16
+ policy.nonce !== undefined &&
17
+ (typeof policy.nonce !== 'string' || policy.nonce.length > 256))
18
+ throw new LoaderConfigurationError('invalid-style-policy', 'Invalid nonce');
19
+ if (policy?.mode === 'external') {
20
+ if (typeof policy.href !== 'string' ||
21
+ policy.href.length > 2048 ||
22
+ !/^(https?:\/\/|\/[^/]|\.\.?\/)/.test(policy.href))
23
+ throw new LoaderConfigurationError('invalid-style-policy', 'Invalid stylesheet URL');
24
+ return `<link data-dotquilt-style rel="stylesheet" href="${escapeHTML(policy.href)}">`;
25
+ }
26
+ if (policy && policy.mode !== 'inline')
27
+ throw new LoaderConfigurationError('invalid-style-policy', 'Invalid style policy');
28
+ return css
29
+ .map((text) => `<style data-dotquilt-style${policy?.nonce ? ` nonce="${escapeHTML(policy.nonce)}"` : ''}>${text}</style>`)
30
+ .join('');
31
+ }
32
+ /** Renders only library decoration. Applications render real content using their own templates. */
33
+ export function renderStatic(description) {
34
+ // The shape the static marks use; the default dot needs no attribute.
35
+ const html = renderDescription(description);
36
+ const mark = shapeOf(description);
37
+ return mark
38
+ ? html.replace(/^<dotquilt-[a-z-]+/, (tag) => `${tag} mark="${mark}"`)
39
+ : html;
40
+ }
41
+ /** A square or dash this markup draws, or undefined for the default dot. */
42
+ function shapeOf(description) {
43
+ const mark = description?.mark;
44
+ if (mark === undefined || mark === 'dot' || description.kind === 'region')
45
+ return undefined;
46
+ if (!marks.includes(mark))
47
+ throw new LoaderConfigurationError('invalid-option', 'Invalid mark');
48
+ return mark;
49
+ }
50
+ /** A mark's rules ship only with markup that uses it, keeping default output small. */
51
+ function marked(css, markCss, description) {
52
+ return shapeOf(description) ? [...css, ...markCss] : css;
53
+ }
54
+ function renderDescription(description) {
55
+ if (!description ||
56
+ ![
57
+ 'skeleton-block',
58
+ 'skeleton-line',
59
+ 'skeleton-circle',
60
+ 'skeleton-text',
61
+ 'typing-dots',
62
+ 'region',
63
+ 'text-loader',
64
+ 'chart-loader',
65
+ 'table-loader',
66
+ ].includes(description.kind))
67
+ throw new LoaderConfigurationError('invalid-static-description', 'Unsupported static description');
68
+ const preset = description.preset === undefined
69
+ ? undefined
70
+ : capturePreset(description.preset, description.kind.startsWith('skeleton-')
71
+ ? 'skeleton'
72
+ : description.kind === 'typing-dots'
73
+ ? 'typing'
74
+ : description.kind === 'region'
75
+ ? 'region'
76
+ : description.kind === 'text-loader'
77
+ ? 'text'
78
+ : description.kind === 'chart-loader'
79
+ ? 'chart'
80
+ : 'table');
81
+ if (description.kind === 'table-loader') {
82
+ const columns = tableColumns(description.columns), rows = tableRows(description.rows ?? 5, columns.length), height = tableHeight(description.rowHeight ?? 32);
83
+ const paths = tableStaticParts(rows, height, columns)
84
+ .map((attrs) => `<path ${Object.entries(attrs)
85
+ .map(([k, v]) => `${k}="${escapeHTML(v)}"`)
86
+ .join(' ')}></path>`)
87
+ .join('');
88
+ return `<dotquilt-table-loader rows="${rows}" row-height="${height}" aria-hidden="true" data-dotquilt-surface>${style(staticTableStyles, description.stylePolicy)}<svg data-dotquilt-static width="100%" height="${rows * height}" viewBox="0 0 100 ${rows * height}" preserveAspectRatio="none" fill="none" stroke="currentColor" opacity=".25">${paths}</svg></dotquilt-table-loader>`;
89
+ }
90
+ if (description.kind === 'chart-loader') {
91
+ const variant = description.variant ?? preset?.variant ?? 'line';
92
+ if (!['line', 'bar', 'scatter'].includes(variant))
93
+ throw new LoaderConfigurationError('invalid-static-description', 'Invalid chart variant');
94
+ return `<dotquilt-chart-loader variant="${variant}"${description.variant === undefined && preset?.variant !== undefined ? ` data-dotquilt-preset-variant="${variant}"` : ''} aria-hidden="true" data-dotquilt-surface>${style(marked(staticChartStyles, staticChartMarkStyles, description), description.stylePolicy)}<span data-dotquilt-static></span></dotquilt-chart-loader>`;
95
+ }
96
+ if (description.kind === 'text-loader') {
97
+ const state = description.state ?? 'ready';
98
+ if (!['ready', 'pending', 'refreshing'].includes(state) ||
99
+ (description.text !== undefined &&
100
+ typeof description.text !== 'string' &&
101
+ typeof description.text !== 'number') ||
102
+ (typeof description.text === 'number' &&
103
+ !Number.isFinite(description.text)) ||
104
+ (description.mask !== undefined && typeof description.mask !== 'string'))
105
+ throw new LoaderConfigurationError('invalid-static-description', 'Invalid text description');
106
+ const value = String(description.text ?? '');
107
+ const requestedMask = description.mask ?? value;
108
+ const mask = requestedMask.length <= 256 ? requestedMask : '';
109
+ return `<dotquilt-text-loader state="${state}" mask="${escapeHTML(mask)}">${style(marked(staticTextLoaderStyles, staticTextLoaderMarkStyles, description), description.stylePolicy)}<span slot="placeholder" data-dotquilt-text-placeholder aria-hidden="true" inert>${escapeHTML(mask)}</span><span data-dotquilt-text-content${state === 'pending' ? ' aria-hidden="true" inert' : ''}>${escapeHTML(value)}</span></dotquilt-text-loader>`;
110
+ }
111
+ if (description.kind === 'skeleton-block')
112
+ return `<dotquilt-skeleton-block aria-hidden="true" data-dotquilt-surface>${style(marked(staticSkeletonStyles, staticSkeletonMarkStyles, description), description.stylePolicy)}<span data-dotquilt-static></span></dotquilt-skeleton-block>`;
113
+ if (description.kind === 'skeleton-line' ||
114
+ description.kind === 'skeleton-circle') {
115
+ const css = description.kind === 'skeleton-line'
116
+ ? marked(staticLineStyles, staticLineMarkStyles, description)
117
+ : marked(staticCircleStyles, staticCircleMarkStyles, description);
118
+ return `<dotquilt-${description.kind} aria-hidden="true" data-dotquilt-surface>${style(css, description.stylePolicy)}<span data-dotquilt-static></span></dotquilt-${description.kind}>`;
119
+ }
120
+ if (description.kind === 'skeleton-text') {
121
+ const lines = boundedCount(description.lines ?? 3, 3, 50);
122
+ const widths = lineWidths(lines, Array.isArray(description.widths) ? description.widths : []);
123
+ // SVG geometry attributes are data, not inline style; strict CSP needs no per-instance CSS.
124
+ const content = widths.map((width) => `<svg data-dotquilt-static-line aria-hidden="true" width="${width * 100}%" height="14"></svg>`);
125
+ return `<dotquilt-skeleton-text lines="${lines}" aria-hidden="true" data-dotquilt-surface>${style(marked(staticTextStyles, staticTextMarkStyles, description), description.stylePolicy)}<span data-dotquilt-static>${content.join('')}</span></dotquilt-skeleton-text>`;
126
+ }
127
+ if (description.kind === 'typing-dots') {
128
+ const count = boundedCount(description.count ?? preset?.count ?? 3, 3, 8);
129
+ return `<dotquilt-typing-dots count="${count}"${description.count === undefined && preset?.count !== undefined ? ` data-dotquilt-preset-count="${count}"` : ''} aria-hidden="true" data-dotquilt-surface>${style(marked(staticTypingStyles, staticTypingMarkStyles, description), description.stylePolicy)}<span data-dotquilt-static>${'<i class="dot"></i>'.repeat(count)}</span></dotquilt-typing-dots>`;
130
+ }
131
+ if (description.label !== undefined && typeof description.label !== 'string')
132
+ throw new LoaderConfigurationError('invalid-static-description', 'Label must be text');
133
+ const state = description.state ?? 'ready';
134
+ if (!['ready', 'pending', 'refreshing'].includes(state) ||
135
+ (description.label?.length ?? 0) > 1024)
136
+ throw new LoaderConfigurationError('invalid-static-description', 'Invalid region state or label');
137
+ const placeholder = description.placeholder
138
+ ? `<span slot="placeholder" data-dotquilt-placeholder${state === 'ready' ? ' hidden' : ''}>${renderStatic(description.placeholder)}</span>`
139
+ : '';
140
+ return `<dotquilt-region state="${state}"${description.label ? ` aria-label="${escapeHTML(description.label)}"` : ''}>${style(regionStyles, description.stylePolicy)}${placeholder}</dotquilt-region>`;
141
+ }
@@ -0,0 +1,10 @@
1
+ import type { AnimationFactory } from './animations.js';
2
+ export interface PulseOptions {
3
+ readonly periodMs: number;
4
+ }
5
+ export interface DissolveOptions {
6
+ readonly duration: number;
7
+ readonly fallPx: number;
8
+ }
9
+ export declare const pulse: AnimationFactory<'skeleton', 'idle', PulseOptions>;
10
+ export declare const dissolve: AnimationFactory<'skeleton', 'handoff', DissolveOptions>;
@@ -0,0 +1,35 @@
1
+ import { brand } from './internal/binding.js';
2
+ import { dissolveDefinition, pulseDefinition } from './internal/defaults.js';
3
+ export const pulse = (options = {}) => {
4
+ if (Object.keys(options).some((k) => k !== 'periodMs') ||
5
+ (options.periodMs !== undefined && !Number.isFinite(options.periodMs)))
6
+ throw new TypeError('Invalid pulse options');
7
+ return Object.freeze({
8
+ contractVersion: 1,
9
+ id: 'dotquilt/pulse',
10
+ family: 'skeleton',
11
+ phase: 'idle',
12
+ options: Object.freeze({
13
+ periodMs: Math.max(800, Math.min(4000, options.periodMs ?? 2800)),
14
+ }),
15
+ [brand]: pulseDefinition,
16
+ });
17
+ };
18
+ export const dissolve = (options = {}) => {
19
+ if (Object.keys(options).some((k) => k !== 'duration' && k !== 'fallPx') ||
20
+ (options.fallPx !== undefined && !Number.isFinite(options.fallPx)) ||
21
+ (options.duration !== undefined &&
22
+ (!Number.isFinite(options.duration) || options.duration < 0)))
23
+ throw new TypeError('Invalid dissolve options');
24
+ return Object.freeze({
25
+ contractVersion: 1,
26
+ id: 'dotquilt/dissolve',
27
+ family: 'skeleton',
28
+ phase: 'handoff',
29
+ options: Object.freeze({
30
+ duration: options.duration ?? 300,
31
+ fallPx: Math.max(0, Math.min(8, options.fallPx ?? 5)),
32
+ }),
33
+ [brand]: dissolveDefinition,
34
+ });
35
+ };
@@ -0,0 +1,50 @@
1
+ import type { Animations } from './animations.js';
2
+ import { type Activity, ManagedElement } from './internal/element.js';
3
+ import type { Preset } from './internal/preset.js';
4
+ import { type SkeletonExit, skeletonHandoff } from './internal/skeleton-handoff.js';
5
+ import type { Motion } from './types.js';
6
+ interface Owner extends HTMLElement {
7
+ activity: Activity;
8
+ state: string;
9
+ presentation: string;
10
+ }
11
+ export declare class SkeletonBlock extends ManagedElement {
12
+ #private;
13
+ protected get styles(): readonly string[];
14
+ protected upgrade(): void;
15
+ protected capturePreset(value: Preset<'skeleton'>): Preset<'skeleton'>;
16
+ static observedAttributes: string[];
17
+ get speed(): number;
18
+ set speed(value: number | undefined);
19
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
20
+ get animations(): Animations<'skeleton'>;
21
+ set animations(value: Animations<'skeleton'> | undefined);
22
+ get pointerResponse(): 'none' | 'lift';
23
+ set pointerResponse(value: 'none' | 'lift' | undefined);
24
+ protected presetChanged(): void;
25
+ /** How its marks leave when a region hands it over (skeleton-handoff.ts). */
26
+ [skeletonHandoff](): SkeletonExit;
27
+ get owner(): Owner | undefined;
28
+ get activity(): Activity;
29
+ connectedCallback(): void;
30
+ disconnectedCallback(): void;
31
+ update(patch: {
32
+ readonly animations?: Animations<'skeleton'> | undefined;
33
+ readonly motion?: Motion | undefined;
34
+ readonly speed?: number | undefined;
35
+ readonly pointerResponse?: 'none' | 'lift' | undefined;
36
+ readonly preset?: SkeletonPreset | undefined;
37
+ readonly stylePolicy?: import('./types.js').StylePolicy;
38
+ }): void;
39
+ protected get optionNames(): readonly string[];
40
+ refresh(): void;
41
+ /**
42
+ * The layer whose marks light up around the pointer, made only for a
43
+ * loader that asks for `lift`: a copy of the surface under a round mask.
44
+ */
45
+ protected ensureLift(): void;
46
+ protected render(): void;
47
+ }
48
+ export type SkeletonPreset = import('./internal/preset.js').Preset<'skeleton'>;
49
+ export declare function registerSkeletonBlock(): void;
50
+ export { refreshStyles } from './internal/element.js';