@relo-ui/web 0.0.0-stage → 0.1.0-rc.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 (127) hide show
  1. package/README.md +27 -2
  2. package/dist/LICENSE +202 -0
  3. package/dist/NOTICE +5 -0
  4. package/dist/core/contracts.d.ts +72 -0
  5. package/dist/core/contracts.js +76 -0
  6. package/dist/core/document.d.ts +16 -0
  7. package/dist/core/document.js +21 -0
  8. package/dist/core/engine.d.ts +8 -0
  9. package/dist/core/engine.js +28 -0
  10. package/dist/core/index.d.ts +7 -0
  11. package/dist/core/index.js +7 -0
  12. package/dist/core/runtime.d.ts +23 -0
  13. package/dist/core/runtime.js +46 -0
  14. package/dist/core/schema.d.ts +56 -0
  15. package/dist/core/schema.js +72 -0
  16. package/dist/core/session.d.ts +88 -0
  17. package/dist/core/session.js +520 -0
  18. package/dist/core/value.d.ts +18 -0
  19. package/dist/core/value.js +118 -0
  20. package/dist/dom/accessibility.d.ts +2 -0
  21. package/dist/dom/accessibility.js +69 -0
  22. package/dist/dom/icons.d.ts +1 -0
  23. package/dist/dom/icons.js +21 -0
  24. package/dist/dom/images.d.ts +59 -0
  25. package/dist/dom/images.js +406 -0
  26. package/dist/dom/index.d.ts +3 -0
  27. package/dist/dom/index.js +2 -0
  28. package/dist/dom/inputs.d.ts +5 -0
  29. package/dist/dom/inputs.js +85 -0
  30. package/dist/dom/lists.d.ts +7 -0
  31. package/dist/dom/lists.js +48 -0
  32. package/dist/dom/measurement.d.ts +16 -0
  33. package/dist/dom/measurement.js +67 -0
  34. package/dist/dom/motion-lifecycle.d.ts +17 -0
  35. package/dist/dom/motion-lifecycle.js +28 -0
  36. package/dist/dom/motion-plan.d.ts +44 -0
  37. package/dist/dom/motion-plan.js +31 -0
  38. package/dist/dom/motion.d.ts +73 -0
  39. package/dist/dom/motion.js +817 -0
  40. package/dist/dom/mount-plan.d.ts +15 -0
  41. package/dist/dom/mount-plan.js +58 -0
  42. package/dist/dom/presentation.d.ts +11 -0
  43. package/dist/dom/presentation.js +331 -0
  44. package/dist/dom/primitives.d.ts +16 -0
  45. package/dist/dom/primitives.js +378 -0
  46. package/dist/dom/range.d.ts +9 -0
  47. package/dist/dom/range.js +120 -0
  48. package/dist/dom/renderer.d.ts +99 -0
  49. package/dist/dom/renderer.js +1041 -0
  50. package/dist/dom/scroll.d.ts +7 -0
  51. package/dist/dom/scroll.js +167 -0
  52. package/dist/dom/shared-layout.d.ts +40 -0
  53. package/dist/dom/shared-layout.js +440 -0
  54. package/dist/dom/style.d.ts +35 -0
  55. package/dist/dom/style.js +337 -0
  56. package/dist/dom/text-motion.d.ts +17 -0
  57. package/dist/dom/text-motion.js +185 -0
  58. package/dist/dom/theme.d.ts +13 -0
  59. package/dist/dom/theme.js +65 -0
  60. package/dist/index.d.ts +10 -0
  61. package/dist/index.js +18 -0
  62. package/dist/licenses/Rust-COPYRIGHT-library.html +29357 -0
  63. package/dist/licenses/archery-1.2.3/LICENSE.md +21 -0
  64. package/dist/licenses/bytemuck-1.25.2/LICENSE-APACHE +61 -0
  65. package/dist/licenses/bytemuck-1.25.2/LICENSE-MIT +9 -0
  66. package/dist/licenses/bytemuck-1.25.2/LICENSE-ZLIB +11 -0
  67. package/dist/licenses/cargo.json +340 -0
  68. package/dist/licenses/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  69. package/dist/licenses/cfg-if-1.0.5/LICENSE-MIT +25 -0
  70. package/dist/licenses/equivalent-1.0.2/LICENSE-APACHE +201 -0
  71. package/dist/licenses/equivalent-1.0.2/LICENSE-MIT +25 -0
  72. package/dist/licenses/futures-core-0.3.34/LICENSE-APACHE +202 -0
  73. package/dist/licenses/futures-core-0.3.34/LICENSE-MIT +26 -0
  74. package/dist/licenses/futures-task-0.3.34/LICENSE-APACHE +202 -0
  75. package/dist/licenses/futures-task-0.3.34/LICENSE-MIT +26 -0
  76. package/dist/licenses/futures-util-0.3.34/LICENSE-APACHE +202 -0
  77. package/dist/licenses/futures-util-0.3.34/LICENSE-MIT +26 -0
  78. package/dist/licenses/imbl-7.0.2/LICENCE.md +355 -0
  79. package/dist/licenses/imbl-sized-chunks-0.2.0/LICENCE.md +355 -0
  80. package/dist/licenses/itoa-1.0.18/LICENSE-APACHE +176 -0
  81. package/dist/licenses/itoa-1.0.18/LICENSE-MIT +23 -0
  82. package/dist/licenses/js-sys-0.3.106/LICENSE-APACHE +201 -0
  83. package/dist/licenses/js-sys-0.3.106/LICENSE-MIT +25 -0
  84. package/dist/licenses/memchr-2.8.3/COPYING +3 -0
  85. package/dist/licenses/memchr-2.8.3/LICENSE-MIT +21 -0
  86. package/dist/licenses/once_cell-1.21.4/LICENSE-APACHE +201 -0
  87. package/dist/licenses/once_cell-1.21.4/LICENSE-MIT +23 -0
  88. package/dist/licenses/pin-project-lite-0.2.17/LICENSE-APACHE +177 -0
  89. package/dist/licenses/pin-project-lite-0.2.17/LICENSE-MIT +23 -0
  90. package/dist/licenses/rand_core-0.9.5/COPYRIGHT +12 -0
  91. package/dist/licenses/rand_core-0.9.5/LICENSE-APACHE +187 -0
  92. package/dist/licenses/rand_core-0.9.5/LICENSE-MIT +26 -0
  93. package/dist/licenses/rand_xoshiro-0.7.0/COPYRIGHT +12 -0
  94. package/dist/licenses/rand_xoshiro-0.7.0/LICENSE-APACHE +176 -0
  95. package/dist/licenses/rand_xoshiro-0.7.0/LICENSE-MIT +25 -0
  96. package/dist/licenses/roxmltree-0.21.1/LICENSE-APACHE +201 -0
  97. package/dist/licenses/roxmltree-0.21.1/LICENSE-MIT +21 -0
  98. package/dist/licenses/safe_arch-0.7.4/LICENSE-APACHE.md +61 -0
  99. package/dist/licenses/safe_arch-0.7.4/LICENSE-MIT.md +9 -0
  100. package/dist/licenses/safe_arch-0.7.4/LICENSE-ZLIB.md +11 -0
  101. package/dist/licenses/serde-1.0.229/LICENSE-APACHE +176 -0
  102. package/dist/licenses/serde-1.0.229/LICENSE-MIT +23 -0
  103. package/dist/licenses/serde_core-1.0.229/LICENSE-APACHE +176 -0
  104. package/dist/licenses/serde_core-1.0.229/LICENSE-MIT +23 -0
  105. package/dist/licenses/serde_json-1.0.151/LICENSE-APACHE +176 -0
  106. package/dist/licenses/serde_json-1.0.151/LICENSE-MIT +23 -0
  107. package/dist/licenses/slab-0.4.12/LICENSE +25 -0
  108. package/dist/licenses/slotmap-1.1.1/LICENSE +19 -0
  109. package/dist/licenses/smallvec-1.16.3/LICENSE-APACHE +201 -0
  110. package/dist/licenses/smallvec-1.16.3/LICENSE-MIT +25 -0
  111. package/dist/licenses/taffy-0.15.0/taffy-0.15.0-LICENSE +22 -0
  112. package/dist/licenses/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
  113. package/dist/licenses/unicode-ident-1.0.26/LICENSE-MIT +23 -0
  114. package/dist/licenses/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
  115. package/dist/licenses/wasm-bindgen-0.2.129/LICENSE-APACHE +201 -0
  116. package/dist/licenses/wasm-bindgen-0.2.129/LICENSE-MIT +25 -0
  117. package/dist/licenses/wasm-bindgen-shared-0.2.129/LICENSE-APACHE +201 -0
  118. package/dist/licenses/wasm-bindgen-shared-0.2.129/LICENSE-MIT +25 -0
  119. package/dist/licenses/web-time-1.1.0/LICENSE-APACHE +201 -0
  120. package/dist/licenses/web-time-1.1.0/LICENSE-MIT +21 -0
  121. package/dist/licenses/wide-0.7.33/LICENSE-ZLIB.md +11 -0
  122. package/dist/licenses/zmij-1.0.23/LICENSE-MIT +23 -0
  123. package/dist/wasm/relo_wasm.d.ts +179 -0
  124. package/dist/wasm/relo_wasm.js +1228 -0
  125. package/dist/wasm/relo_wasm_bg.wasm +0 -0
  126. package/dist/wasm/relo_wasm_bg.wasm.d.ts +65 -0
  127. package/package.json +25 -4
@@ -0,0 +1,2 @@
1
+ export { RemoteSurface, supportedBuiltins, } from './renderer.js';
2
+ export { DefaultImageLoader, } from './images.js';
@@ -0,0 +1,5 @@
1
+ import type { Mounted } from './renderer.js';
2
+ export declare function initializeInput(value: Mounted): void;
3
+ export declare function updateInput(value: Mounted): void;
4
+ export declare function measureInput(value: Mounted, width: number, height?: number): number;
5
+ export declare const inputCSS = "\n.relo-surface .relo-inputbox{position:relative;box-sizing:border-box;min-width:0;isolation:isolate}\n.relo-surface .relo-input-label,.relo-surface .relo-input-error{display:block;white-space:pre-wrap;font-size:.8em;line-height:1.4;margin:0 0 4px}\n.relo-surface .relo-input-error{color:var(--relo-danger);margin:4px 0 0}\n.relo-surface .relo-inputbox [hidden]{display:none!important}\n.relo-surface .relo-inputbox input:not([type=checkbox]):focus-visible,.relo-surface .relo-inputbox textarea:focus-visible{outline:0}\n.relo-surface .relo-inputbox input[type=checkbox]{accent-color:var(--relo-accent);width:40px;height:24px!important;margin:12px 0}\n.relo-surface .relo-editor-only::after{content:'';position:absolute;left:0;right:0;top:50%;height:max(100%,48px);transform:translateY(-50%);z-index:-1}\n";
@@ -0,0 +1,85 @@
1
+ let sequence = 0;
2
+ export function initializeInput(value) {
3
+ if (!['TextField', 'TextArea', 'Toggle'].includes(value.node.type))
4
+ return;
5
+ const editor = value.content;
6
+ editor.id = `relo-editor-${++sequence}`;
7
+ const box = document.createElement('div');
8
+ box.className = 'relo-inputbox';
9
+ const label = document.createElement('label');
10
+ label.htmlFor = editor.id;
11
+ label.className = 'relo-input-label';
12
+ const message = document.createElement('div');
13
+ message.id = `relo-error-${sequence}`;
14
+ message.className = 'relo-input-error';
15
+ message.setAttribute('aria-atomic', 'true');
16
+ editor.replaceWith(box);
17
+ box.append(label, editor, message);
18
+ value.extra.inputBox = box;
19
+ value.extra.inputLabel = label;
20
+ value.extra.inputMessage = message;
21
+ box.addEventListener('pointerdown', (event) => {
22
+ if (event.target === box && !value.extra.disabled)
23
+ editor.focus();
24
+ }, { signal: value.controller.signal });
25
+ box.addEventListener('click', (event) => {
26
+ if (event.target !== box || value.extra.disabled)
27
+ return;
28
+ editor.focus();
29
+ if (value.node.type === 'Toggle')
30
+ editor.click();
31
+ }, { signal: value.controller.signal });
32
+ }
33
+ export function updateInput(value) {
34
+ const box = value.extra.inputBox;
35
+ if (!box)
36
+ return;
37
+ const props = value.node.props, editor = value.content, label = value.extra.inputLabel, message = value.extra.inputMessage;
38
+ const compact = props.presentation === 'editor';
39
+ box.classList.toggle('relo-editor-only', compact);
40
+ label.hidden = compact || !props.label;
41
+ if (label.textContent !== props.label)
42
+ label.textContent = props.label ?? '';
43
+ message.hidden = compact || !props.validationMessage;
44
+ message.setAttribute('aria-live', value.focused ? 'polite' : 'off');
45
+ if (message.textContent !== (props.validationMessage ?? ''))
46
+ message.textContent = props.validationMessage ?? '';
47
+ if (props.validationMessage) {
48
+ editor.setAttribute('aria-describedby', message.id);
49
+ editor.setAttribute('aria-errormessage', message.id);
50
+ }
51
+ else {
52
+ editor.removeAttribute('aria-describedby');
53
+ editor.removeAttribute('aria-errormessage');
54
+ }
55
+ editor.style.minHeight = compact ? '0' : '48px';
56
+ if (value.node.type !== 'Toggle')
57
+ Object.assign(editor.style, {
58
+ padding: compact ? '0' : '10px 12px',
59
+ border: compact ? '0' : 'var(--relo-input-border-width,1px) solid',
60
+ borderColor: 'var(--relo-input-border)',
61
+ borderRadius: compact ? '0' : 'var(--relo-input-radius,8px)',
62
+ background: compact ? 'transparent' : 'var(--relo-input-background)',
63
+ });
64
+ }
65
+ export function measureInput(value, width, height) {
66
+ const box = value.extra.inputBox, editor = value.content;
67
+ box.style.width = `${width}px`;
68
+ const compact = value.node.props.presentation === 'editor';
69
+ const label = value.extra.inputLabel, message = value.extra.inputMessage;
70
+ const chrome = (label.hidden ? 0 : label.getBoundingClientRect().height + 4) +
71
+ (message.hidden ? 0 : message.getBoundingClientRect().height + 4);
72
+ editor.style.width = value.node.type === 'Toggle' ? 'auto' : '100%';
73
+ const css = getComputedStyle(editor), line = parseFloat(css.lineHeight) || parseFloat(css.fontSize) * 1.4, insets = ['paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'].reduce((sum, key) => sum + (parseFloat(css[key]) || 0), 0), natural = Math.max(value.node.type === 'TextArea' ? 104 : compact ? 32 : 48, Math.ceil(line * (value.node.type === 'TextArea' ? 3 : 1) + insets));
74
+ editor.style.height = `${height === undefined ? natural : Math.max(compact ? 0 : 48, height - chrome)}px`;
75
+ return box.getBoundingClientRect().height;
76
+ }
77
+ export const inputCSS = `
78
+ .relo-surface .relo-inputbox{position:relative;box-sizing:border-box;min-width:0;isolation:isolate}
79
+ .relo-surface .relo-input-label,.relo-surface .relo-input-error{display:block;white-space:pre-wrap;font-size:.8em;line-height:1.4;margin:0 0 4px}
80
+ .relo-surface .relo-input-error{color:var(--relo-danger);margin:4px 0 0}
81
+ .relo-surface .relo-inputbox [hidden]{display:none!important}
82
+ .relo-surface .relo-inputbox input:not([type=checkbox]):focus-visible,.relo-surface .relo-inputbox textarea:focus-visible{outline:0}
83
+ .relo-surface .relo-inputbox input[type=checkbox]{accent-color:var(--relo-accent);width:40px;height:24px!important;margin:12px 0}
84
+ .relo-surface .relo-editor-only::after{content:'';position:absolute;left:0;right:0;top:50%;height:max(100%,48px);transform:translateY(-50%);z-index:-1}
85
+ `;
@@ -0,0 +1,7 @@
1
+ import type { Mounted } from './renderer.js';
2
+ import type { RenderNode } from '../core/session.js';
3
+ export declare function captureList(value: Mounted): void;
4
+ export declare function listWindow(value: Mounted): RenderNode[];
5
+ export declare function measureList(value: Mounted, width: number, measure: (child: Mounted) => {
6
+ height: number;
7
+ }): void;
@@ -0,0 +1,48 @@
1
+ import { getEngine } from '../core/engine.js';
2
+ const indexes = new WeakMap();
3
+ function rows(value, width) {
4
+ let rows = indexes.get(value);
5
+ if (!rows) {
6
+ rows = { index: new (getEngine().WasmHeightIndex)(), children: [] };
7
+ indexes.set(value, rows);
8
+ const index = rows.index;
9
+ value.controller.signal.addEventListener('abort', () => index.free(), { once: true });
10
+ }
11
+ const resized = width !== undefined && width !== rows.width;
12
+ if (rows.children !== value.node.children || resized) {
13
+ rows.index.reset(JSON.stringify(value.node.children.map((child) => child.id)), 64, resized);
14
+ rows.children = value.node.children;
15
+ if (width !== undefined)
16
+ rows.width = width;
17
+ }
18
+ return rows;
19
+ }
20
+ export function captureList(value) {
21
+ const scroll = value.content;
22
+ const origin = Math.max(0, scroll.scrollTop);
23
+ const anchor = JSON.parse(rows(value).index.anchor(origin));
24
+ value.extra.listAnchor = anchor ? { ...anchor, origin } : undefined;
25
+ }
26
+ export function listWindow(value) {
27
+ const scroll = value.content;
28
+ const window = JSON.parse(rows(value).index.window(Math.max(0, scroll.scrollTop), scroll.clientHeight || 300, 300, 128));
29
+ value.extra.totalHeight = window.total;
30
+ return value.node.children.slice(window.start, window.end);
31
+ }
32
+ export function measureList(value, width, measure) {
33
+ const { index } = rows(value, width);
34
+ for (const child of value.children)
35
+ index.set_height(child.node.id, measure(child).height);
36
+ const total = index.total();
37
+ value.childHost.style.height = `${total}px`;
38
+ value.childHost.style.width = `${width}px`;
39
+ for (const child of value.children) {
40
+ child.element.style.left = '0px';
41
+ child.element.style.top = `${index.offset(child.node.id) ?? 0}px`;
42
+ }
43
+ const anchor = value.extra.listAnchor;
44
+ const offset = anchor ? index.offset(anchor.id) : undefined;
45
+ if (offset !== undefined)
46
+ value.extra.listPendingDelta = offset - anchor.offset - anchor.origin;
47
+ value.extra.totalHeight = total;
48
+ }
@@ -0,0 +1,16 @@
1
+ export declare function textMeasurementStyle(element: HTMLElement | SVGElement): string;
2
+ /** Browser-shaped text sizes, shared across equivalent leaves and proposals.
3
+ * Cache numbers only. Keys include computed typography; font loading clears it.
4
+ */
5
+ export declare class IntrinsicMeasurements {
6
+ private entries;
7
+ private bytes;
8
+ clear(): void;
9
+ measure(key: string, read: () => {
10
+ width: number;
11
+ height: number;
12
+ }): {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ }
@@ -0,0 +1,67 @@
1
+ import { fail } from '../core/value.js';
2
+ const textProperties = [
3
+ 'font',
4
+ 'line-height',
5
+ 'letter-spacing',
6
+ 'word-spacing',
7
+ 'white-space',
8
+ 'text-transform',
9
+ 'text-indent',
10
+ 'word-break',
11
+ 'overflow-wrap',
12
+ 'direction',
13
+ 'box-sizing',
14
+ 'display',
15
+ 'padding-top',
16
+ 'padding-right',
17
+ 'padding-bottom',
18
+ 'padding-left',
19
+ 'border-top-width',
20
+ 'border-right-width',
21
+ 'border-bottom-width',
22
+ 'border-left-width',
23
+ 'min-width',
24
+ 'max-width',
25
+ 'min-height',
26
+ 'max-height',
27
+ '-webkit-line-clamp',
28
+ 'font-feature-settings',
29
+ 'font-variation-settings',
30
+ ];
31
+ export function textMeasurementStyle(element) {
32
+ const css = getComputedStyle(element);
33
+ return JSON.stringify(textProperties.map((property) => css.getPropertyValue(property)));
34
+ }
35
+ /** Browser-shaped text sizes, shared across equivalent leaves and proposals.
36
+ * Cache numbers only. Keys include computed typography; font loading clears it.
37
+ */
38
+ export class IntrinsicMeasurements {
39
+ entries = new Map();
40
+ bytes = 0;
41
+ clear() {
42
+ this.entries.clear();
43
+ this.bytes = 0;
44
+ }
45
+ measure(key, read) {
46
+ const cached = this.entries.get(key);
47
+ if (cached)
48
+ return cached;
49
+ const size = read();
50
+ if (!Number.isFinite(size.width) ||
51
+ !Number.isFinite(size.height) ||
52
+ size.width < 0 ||
53
+ size.height < 0)
54
+ fail('Invalid native text measurement', 'layoutError');
55
+ const bytes = key.length * 2 + 64;
56
+ if (bytes <= 512 * 1024) {
57
+ while (this.entries.size && (this.entries.size >= 512 || this.bytes + bytes > 512 * 1024)) {
58
+ const oldest = this.entries.keys().next().value;
59
+ this.bytes -= oldest.length * 2 + 64;
60
+ this.entries.delete(oldest);
61
+ }
62
+ this.entries.set(key, { width: size.width, height: size.height });
63
+ this.bytes += bytes;
64
+ }
65
+ return size;
66
+ }
67
+ }
@@ -0,0 +1,17 @@
1
+ import type { Plan } from './motion-plan.js';
2
+ export declare function transition(plan: Plan, state: {
3
+ initialized: boolean;
4
+ shown: boolean;
5
+ phaseActive?: boolean;
6
+ requested: boolean;
7
+ running: boolean;
8
+ visible: boolean;
9
+ }): {
10
+ phaseActive: boolean;
11
+ seedEnter: boolean;
12
+ resetVelocity: boolean;
13
+ useExit: boolean;
14
+ settings: import("./motion-plan.js").Settings;
15
+ selects: (channel: number) => boolean;
16
+ animates: (channel: number) => boolean;
17
+ };
@@ -0,0 +1,28 @@
1
+ import { getEngine } from '../core/engine.js';
2
+ // DOM paint channels map once to the shared ABI. Padding uses physical
3
+ // left/top/right/bottom in the ABI and CSS top/right/bottom/left here.
4
+ const channels = [
5
+ 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 17, 18, 19, 20, 13, 14, 15, 16, 6, 7, 8, 27, 28, 22, 23, 24, 21,
6
+ 25, 26, 30, 31, 29, 29,
7
+ ];
8
+ export function transition(plan, state) {
9
+ const prior = (state.initialized ? 1 : 0) | (state.shown ? 2 : 0) | (state.phaseActive ? 4 : 0);
10
+ const features = (state.requested ? 1 : 0) |
11
+ (!plan.disabled ? 2 : 0) |
12
+ (state.running ? 4 : 0) |
13
+ (state.visible ? 8 : 0) |
14
+ (plan.enter.length ? 16 : 0) |
15
+ (plan.exit.length ? 32 : 0) |
16
+ (plan.enter_target.width !== null || plan.exit_target.width !== null ? 64 : 0) |
17
+ (plan.enter_target.height !== null || plan.exit_target.height !== null ? 128 : 0);
18
+ const words = getEngine().motion_transition(prior, features, plan.mask);
19
+ return {
20
+ phaseActive: !!(words[0] & 4),
21
+ seedEnter: !!(words[1] & 1),
22
+ resetVelocity: !!(words[1] & 2),
23
+ useExit: !!(words[1] & 4),
24
+ settings: words[1] & 16 ? plan.exit_settings : words[1] & 8 ? plan.enter_settings : plan.settings,
25
+ selects: (channel) => channels[channel] < 30 && !!(words[2] & (1 << channels[channel])),
26
+ animates: (channel) => channels[channel] < 30 && !!(words[3] & (1 << channels[channel])),
27
+ };
28
+ }
@@ -0,0 +1,44 @@
1
+ export interface Settings {
2
+ mass: number;
3
+ stiffness: number;
4
+ damping: number;
5
+ engine: number;
6
+ duration: number;
7
+ ease: number;
8
+ delay: number;
9
+ }
10
+ export interface Endpoint {
11
+ transform: (number | null)[];
12
+ full: boolean[];
13
+ logical_x: boolean;
14
+ opacity: number | null;
15
+ background: string | null;
16
+ foreground: string | null;
17
+ border: string | null;
18
+ radius: string | null;
19
+ border_width: number | null;
20
+ shadow: number | null;
21
+ width: number | null;
22
+ height: number | null;
23
+ }
24
+ export interface Plan {
25
+ mask: number;
26
+ disabled: boolean;
27
+ layout: boolean;
28
+ looping: number;
29
+ settings: Settings;
30
+ enter_settings: Settings;
31
+ exit_settings: Settings;
32
+ transform: number[];
33
+ full: boolean[];
34
+ origin: number[];
35
+ logical_x: boolean;
36
+ enter_target: Endpoint;
37
+ exit_target: Endpoint;
38
+ enter: string[];
39
+ exit: string[];
40
+ style: string;
41
+ }
42
+ /** Animated stroke width is paint, not a CSS border-box inset. */
43
+ export declare function usesPaintedBorder(plan: Plan): boolean;
44
+ export declare function motionPlan(classes: string, states: number, reduced: boolean): Plan;
@@ -0,0 +1,31 @@
1
+ import { getEngine } from '../core/engine.js';
2
+ /** Animated stroke width is paint, not a CSS border-box inset. */
3
+ export function usesPaintedBorder(plan) {
4
+ return (!!(plan.mask & 16) ||
5
+ plan.enter_target.border_width !== null ||
6
+ plan.exit_target.border_width !== null);
7
+ }
8
+ const cache = new Map();
9
+ const maxBytes = 1024 * 1024;
10
+ let retained = 0;
11
+ export function motionPlan(classes, states, reduced) {
12
+ const key = `${states}:${reduced}:${classes}`, cached = cache.get(key);
13
+ if (cached) {
14
+ cache.delete(key);
15
+ cache.set(key, cached);
16
+ return cached.plan;
17
+ }
18
+ const text = getEngine().motion_compile(classes, states, reduced), plan = JSON.parse(text), bytes = (key.length + text.length) * 2;
19
+ if (bytes <= maxBytes) {
20
+ // Native caches retain 512 plans. A 64-entry browser cache thrashed while
21
+ // walking the gallery's static text styles and interactive state variants.
22
+ while (cache.size >= 512 || retained + bytes > maxBytes) {
23
+ const oldest = cache.keys().next().value;
24
+ retained -= cache.get(oldest).bytes;
25
+ cache.delete(oldest);
26
+ }
27
+ cache.set(key, { plan, bytes });
28
+ retained += bytes;
29
+ }
30
+ return plan;
31
+ }
@@ -0,0 +1,73 @@
1
+ import type { Mounted } from './renderer.js';
2
+ export declare class MotionCoordinator {
3
+ private readonly onFrame;
4
+ private readonly text;
5
+ captureText(nodes: Iterable<Mounted>, policy: 'system' | 'reduced' | 'off', epoch: number): Map<string, import("./text-motion.js").TextCapture> | undefined;
6
+ finishText(captures: ReturnType<MotionCoordinator['captureText']>, nodes: Iterable<Mounted>, policy: 'system' | 'reduced' | 'off'): void;
7
+ private rows;
8
+ private used;
9
+ private firstFree;
10
+ private high;
11
+ private frame;
12
+ private disposed;
13
+ private readonly entries;
14
+ private readonly media;
15
+ private epoch;
16
+ private ghostCount;
17
+ private time;
18
+ private real;
19
+ private paused;
20
+ private readonly controller;
21
+ constructor(onFrame: () => void, refresh: () => void);
22
+ private now;
23
+ setVisible(visible: boolean): void;
24
+ begin(epoch: number): void;
25
+ private allocate;
26
+ private configure;
27
+ beforeUpdate(node: Mounted, nextShown: boolean, dark: boolean): void;
28
+ private running;
29
+ isRetaining(id: string): boolean;
30
+ isCollapsing(id: string): boolean;
31
+ /** Retained visual exits keep their last frames after logical layout removes them. */
32
+ preservesLayout(node: Mounted): boolean;
33
+ private finishHidden;
34
+ get layoutActive(): boolean;
35
+ private values;
36
+ private targets;
37
+ private endpoint;
38
+ commit(nodes: Iterable<Mounted>, policy: 'system' | 'reduced' | 'off', dark: boolean): void;
39
+ private depart;
40
+ remove(id: string, dark: boolean): void;
41
+ /** Physical virtualization ends a presentation, never logical presence. */
42
+ forget(id: string): void;
43
+ private paint;
44
+ overrides(id: string): {
45
+ gapX?: number | undefined;
46
+ gapY?: number | undefined;
47
+ width?: {
48
+ fixed: number;
49
+ } | undefined;
50
+ height?: {
51
+ fixed: number;
52
+ } | undefined;
53
+ };
54
+ /** A layout pass may change an intrinsic target without a document update. */
55
+ layoutTarget(id: string, size: {
56
+ width: number;
57
+ height: number;
58
+ }): void;
59
+ /** Only active geometry channels override the immutable authored layout. */
60
+ layoutOverrides(id: string): {
61
+ width?: number;
62
+ height?: number;
63
+ padding?: number[];
64
+ gapX?: number;
65
+ gapY?: number;
66
+ shown?: boolean;
67
+ } | undefined;
68
+ paintAll(): void;
69
+ private wake;
70
+ private release;
71
+ clear(): void;
72
+ dispose(): void;
73
+ }