@hypen-space/core 0.4.980 → 0.5.3

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 (100) hide show
  1. package/README.md +5 -8
  2. package/dist/a11y.d.ts +82 -0
  3. package/dist/app.js +13 -1168
  4. package/dist/app.js.map +3 -9
  5. package/dist/chunk-00zt3w6e.js +58 -0
  6. package/dist/chunk-00zt3w6e.js.map +10 -0
  7. package/dist/chunk-3zvyth50.js +87 -0
  8. package/dist/chunk-3zvyth50.js.map +10 -0
  9. package/dist/chunk-5gtx3pza.js +11 -0
  10. package/dist/chunk-5gtx3pza.js.map +9 -0
  11. package/dist/chunk-7222131a.js +191 -0
  12. package/dist/chunk-7222131a.js.map +10 -0
  13. package/dist/chunk-avchpwhf.js +200 -0
  14. package/dist/chunk-avchpwhf.js.map +10 -0
  15. package/dist/chunk-ec0tgy9a.js +154 -0
  16. package/dist/chunk-ec0tgy9a.js.map +10 -0
  17. package/dist/chunk-fnss4dm2.js +479 -0
  18. package/dist/chunk-fnss4dm2.js.map +10 -0
  19. package/dist/chunk-g2gz9pgg.js +133 -0
  20. package/dist/chunk-g2gz9pgg.js.map +10 -0
  21. package/dist/chunk-g72v6mmf.js +341 -0
  22. package/dist/chunk-g72v6mmf.js.map +10 -0
  23. package/dist/chunk-g7g3jxty.js +351 -0
  24. package/dist/chunk-g7g3jxty.js.map +10 -0
  25. package/dist/chunk-g830re2c.js +50 -0
  26. package/dist/chunk-g830re2c.js.map +10 -0
  27. package/dist/chunk-gtwh1sg7.js +127 -0
  28. package/dist/chunk-gtwh1sg7.js.map +10 -0
  29. package/dist/chunk-k12cwfst.js +72 -0
  30. package/dist/chunk-k12cwfst.js.map +10 -0
  31. package/dist/chunk-mbqqsz6r.js +128 -0
  32. package/dist/chunk-mbqqsz6r.js.map +10 -0
  33. package/dist/chunk-ne632swm.js +209 -0
  34. package/dist/chunk-ne632swm.js.map +10 -0
  35. package/dist/chunk-p3pj1bax.js +206 -0
  36. package/dist/chunk-p3pj1bax.js.map +10 -0
  37. package/dist/chunk-vshdk2pw.js +56 -0
  38. package/dist/chunk-vshdk2pw.js.map +10 -0
  39. package/dist/chunk-wp2ebn2m.js +51 -0
  40. package/dist/chunk-wp2ebn2m.js.map +10 -0
  41. package/dist/chunk-x4qv4jm9.js +88 -0
  42. package/dist/chunk-x4qv4jm9.js.map +10 -0
  43. package/dist/chunk-ycxp4drd.js +211 -0
  44. package/dist/chunk-ycxp4drd.js.map +10 -0
  45. package/dist/components/builtin.js +14 -1246
  46. package/dist/components/builtin.js.map +3 -10
  47. package/dist/context.js +7 -362
  48. package/dist/context.js.map +3 -6
  49. package/dist/datasource.js +5 -76
  50. package/dist/datasource.js.map +3 -4
  51. package/dist/disposable.js +20 -367
  52. package/dist/disposable.js.map +3 -5
  53. package/dist/engine-base.d.ts +38 -2
  54. package/dist/engine-base.js +45 -412
  55. package/dist/engine-base.js.map +4 -6
  56. package/dist/events.js +7 -285
  57. package/dist/events.js.map +3 -5
  58. package/dist/hypen.js +8 -71
  59. package/dist/hypen.js.map +3 -4
  60. package/dist/index.browser.js +58 -2152
  61. package/dist/index.browser.js.map +3 -16
  62. package/dist/index.d.ts +4 -0
  63. package/dist/index.js +175 -3057
  64. package/dist/index.js.map +5 -22
  65. package/dist/logger.js +16 -220
  66. package/dist/logger.js.map +3 -4
  67. package/dist/managed-router.js +12 -1367
  68. package/dist/managed-router.js.map +3 -10
  69. package/dist/portable.js +6 -70
  70. package/dist/portable.js.map +3 -4
  71. package/dist/remote/client.js +9 -1010
  72. package/dist/remote/client.js.map +3 -8
  73. package/dist/remote/index.d.ts +2 -0
  74. package/dist/remote/index.js +511 -1066
  75. package/dist/remote/index.js.map +4 -9
  76. package/dist/remote/remote-session.d.ts +245 -0
  77. package/dist/remote/session.js +5 -147
  78. package/dist/remote/session.js.map +3 -4
  79. package/dist/renderer.js +7 -271
  80. package/dist/renderer.js.map +3 -5
  81. package/dist/resolver.js +5 -484
  82. package/dist/resolver.js.map +3 -5
  83. package/dist/result.js +25 -211
  84. package/dist/result.js.map +3 -4
  85. package/dist/retry.js +10 -336
  86. package/dist/retry.js.map +3 -5
  87. package/dist/router.js +9 -807
  88. package/dist/router.js.map +3 -8
  89. package/dist/state.js +10 -274
  90. package/dist/state.js.map +3 -5
  91. package/dist/types.d.ts +129 -1
  92. package/dist/validate.d.ts +19 -0
  93. package/package.json +13 -1
  94. package/src/a11y.ts +127 -0
  95. package/src/engine-base.ts +87 -4
  96. package/src/index.ts +10 -0
  97. package/src/remote/index.ts +16 -0
  98. package/src/remote/remote-session.ts +998 -0
  99. package/src/types.ts +131 -1
  100. package/src/validate.ts +37 -0
package/src/types.ts CHANGED
@@ -28,10 +28,22 @@ export type Patch = {
28
28
  | "attachEvent"
29
29
  | "detachEvent"
30
30
  | "detach"
31
- | "attach";
31
+ | "attach"
32
+ | "setSemantics";
32
33
  id?: string;
33
34
  elementType?: string;
34
35
  props?: Record<string, any>;
36
+ /**
37
+ * Accessibility semantics derived by the engine for this node. Carried on
38
+ * `create` (first paint) and on `setSemantics` (reactive change — a
39
+ * templated accessible name or bound state whose source path changed).
40
+ * A `setSemantics` always carries the node's **complete** resolved block;
41
+ * renderers re-apply it with the same translation they run at create,
42
+ * clearing anything the new block no longer sets. Absent on `create` when
43
+ * the node has nothing derivable; absent on `setSemantics` when the node
44
+ * lost all semantics (→ clear everything).
45
+ */
46
+ semantics?: Semantics;
35
47
  name?: string;
36
48
  value?: any;
37
49
  text?: string;
@@ -40,6 +52,124 @@ export type Patch = {
40
52
  eventName?: string;
41
53
  };
42
54
 
55
+ /**
56
+ * Platform-neutral accessibility semantics for a node, derived in the engine
57
+ * and carried on `create` patches. Each renderer maps this onto its native
58
+ * accessibility model (ARIA attributes on DOM, `Modifier.semantics` on
59
+ * Compose, accessibility traits on SwiftUI).
60
+ *
61
+ * Every field is optional; an absent field means "nothing derivable".
62
+ */
63
+ export type Semantics = {
64
+ /**
65
+ * What this node is, as a platform-neutral role token (e.g. `"button"`).
66
+ * Mirrors the ARIA role vocabulary. Emitted only where the role is
67
+ * structurally certain from the component type.
68
+ */
69
+ role?: string;
70
+ /** Heading level (1–6) when known. */
71
+ level?: number;
72
+ /** Whether the node represents in-progress content (maps to `aria-busy`). */
73
+ busy?: boolean;
74
+ /**
75
+ * Live-region politeness (`.liveRegion("polite" | "assertive")`) →
76
+ * `aria-live` on DOM and the Canvas shadow tree. The engine validates the
77
+ * token, so only those two values arrive. Travels untranslated to the
78
+ * native renderers (no direct analog wired yet).
79
+ */
80
+ live?: string;
81
+ /**
82
+ * Accessible name derived from the element's text content, for roles that
83
+ * require one. On DOM this is usually left unapplied — the browser derives
84
+ * the name from visible content — but renderers without that affordance
85
+ * (Canvas shadow tree, iOS, Android) use it directly.
86
+ */
87
+ name?: string;
88
+ /**
89
+ * `true` when the element's role requires a name but none could be derived
90
+ * (e.g. an icon-only button). Surfaced by dev-mode conformance checks; the
91
+ * fix is an explicit label.
92
+ */
93
+ nameMissing?: boolean;
94
+ /**
95
+ * `true` when {@link name} came from an explicit author `.label(...)` rather
96
+ * than derived content. DOM applies an explicit name as `aria-label` (an
97
+ * intentional override) but leaves a derived name to the visible content.
98
+ */
99
+ nameExplicit?: boolean;
100
+ /**
101
+ * `true` when the element was marked decorative via `.hidden()`. It is
102
+ * removed from the accessibility tree (`aria-hidden`).
103
+ */
104
+ hidden?: boolean;
105
+ /**
106
+ * Supplementary description (`.description(...)`) — extra context beyond the
107
+ * name. Applied as `aria-description` on DOM.
108
+ */
109
+ description?: string;
110
+ /** Disclosure state → `aria-expanded`. */
111
+ expanded?: boolean;
112
+ /** Toggle-button state → `aria-pressed`. */
113
+ pressed?: boolean;
114
+ /** Selected state (e.g. a tab) → `aria-selected`. */
115
+ selected?: boolean;
116
+ /** Current-item token (page/step/…) → `aria-current`. */
117
+ current?: string;
118
+ /**
119
+ * Checked state for a `Checkbox`/`Switch` bound via `.bind(@state.x)` →
120
+ * `aria-checked`. Resolved at reconcile from the control's bind-target value.
121
+ */
122
+ checked?: boolean;
123
+ /**
124
+ * Validity state for a form control (`.invalid(bool | @state.hasError)`) →
125
+ * `aria-invalid`. A bound value resolves at reconcile and stays live via
126
+ * `setSemantics` re-emits. DOM only for now.
127
+ */
128
+ invalid?: boolean;
129
+ /**
130
+ * Cross-node relationship: id of the element this node controls →
131
+ * `aria-controls`. Web-leaning (DOM only); id references do not survive to
132
+ * the string-hint native APIs. See the guide's "Platform support" section
133
+ * (`hypen-docs/content/docs/guide/accessibility.mdx`).
134
+ */
135
+ controls?: string;
136
+ /**
137
+ * Cross-node relationship: id of the element that describes this node →
138
+ * `aria-describedby`. Web-leaning (DOM only), as with `controls`.
139
+ */
140
+ describedby?: string;
141
+ /**
142
+ * The author-supplied stable id of this node (`.id("details-panel")`) —
143
+ * the anchor id-reference relationships resolve against. Applied as the
144
+ * DOM `id` attribute.
145
+ */
146
+ id?: string;
147
+ /**
148
+ * Cross-node relationship: id of the element that labels this node →
149
+ * `aria-labelledby` (the tabpanel→tab half of the Tabs pattern). DOM only.
150
+ */
151
+ labelledby?: string;
152
+ /**
153
+ * Reactive cross-node reference: id of the currently-active descendant →
154
+ * `aria-activedescendant` (the roving focus pointer of composite widgets).
155
+ * Usually bound (`.activedescendant(@state.focusedId)`); kept live via
156
+ * `setSemantics` re-emits. DOM only.
157
+ */
158
+ activeDescendant?: string;
159
+ /**
160
+ * Cross-node relationship: id of an element that is logically this node's
161
+ * child but rendered elsewhere (a portaled popup) → `aria-owns`. DOM only.
162
+ */
163
+ owns?: string;
164
+ /**
165
+ * Base text direction (`.dir("rtl" | "ltr" | "auto")`) → the HTML `dir`
166
+ * attribute on DOM. The engine validates the token, so only those three
167
+ * values arrive. Native renderers translate to their layout-direction
168
+ * APIs (follow-up; the value already travels on the block).
169
+ */
170
+ dir?: string;
171
+ };
172
+
43
173
  export type Action = {
44
174
  name: string;
45
175
  payload?: any;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Patch-stream validation. A `create` patch whose `elementType` is neither a
3
+ * known primitive nor a resolved component is a silent resolver miss — the
4
+ * renderer drops the node, no error surfaces. `validatePatches` turns that into
5
+ * a one-line test/CI assertion.
6
+ */
7
+
8
+ import type { Patch } from "./types.js";
9
+
10
+ export interface PatchValidationResult {
11
+ /** Distinct `create` `elementType`s not in `knownTypes` (i.e. dropped nodes). */
12
+ unknownTypes: string[];
13
+ }
14
+
15
+ /**
16
+ * Distinct `create` `elementType`s not in `knownTypes`.
17
+ *
18
+ * `knownTypes` is caller-supplied (engine primitives + the app's resolvable
19
+ * component names) rather than read from the engine: the wasm-bindgen build
20
+ * exposes no primitive list, and hardcoding the built-ins would drift from Rust.
21
+ */
22
+ export function validatePatches(
23
+ patches: Patch[],
24
+ knownTypes: Iterable<string>,
25
+ ): PatchValidationResult {
26
+ const known = knownTypes instanceof Set ? knownTypes : new Set(knownTypes);
27
+ const unknown = new Set<string>();
28
+
29
+ for (const patch of patches) {
30
+ if (patch.type !== "create") continue;
31
+ const elementType = patch.elementType;
32
+ if (typeof elementType !== "string") continue;
33
+ if (!known.has(elementType)) unknown.add(elementType);
34
+ }
35
+
36
+ return { unknownTypes: [...unknown] };
37
+ }