what-core 0.14.0 → 0.15.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -38
  3. package/a11y.d.ts +128 -0
  4. package/data.d.ts +294 -0
  5. package/dist/a11y.js +510 -0
  6. package/dist/a11y.min.js +413 -0
  7. package/dist/actions.js +158 -0
  8. package/dist/actions.min.js +112 -0
  9. package/dist/animation.js +481 -0
  10. package/dist/animation.min.js +295 -0
  11. package/dist/async.js +180 -0
  12. package/dist/async.min.js +134 -0
  13. package/dist/components.js +577 -0
  14. package/dist/components.min.js +413 -0
  15. package/dist/data.js +1212 -0
  16. package/dist/data.min.js +918 -0
  17. package/dist/diagnostics.js +187 -0
  18. package/dist/diagnostics.min.js +134 -0
  19. package/dist/dom.js +796 -0
  20. package/dist/dom.min.js +603 -0
  21. package/dist/entries/a11y.js +43 -0
  22. package/dist/entries/a11y.min.js +43 -0
  23. package/dist/entries/data.js +29 -0
  24. package/dist/entries/data.min.js +29 -0
  25. package/dist/entries/dom.js +45 -0
  26. package/dist/entries/dom.min.js +45 -0
  27. package/dist/entries/form.js +31 -0
  28. package/dist/entries/form.min.js +31 -0
  29. package/dist/entries/internal.js +123 -0
  30. package/dist/entries/internal.min.js +123 -0
  31. package/dist/entries/motion.js +23 -0
  32. package/dist/entries/motion.min.js +23 -0
  33. package/dist/entries/ui.js +25 -0
  34. package/dist/entries/ui.min.js +25 -0
  35. package/dist/env.js +5 -0
  36. package/dist/env.min.js +5 -0
  37. package/dist/errors.js +1518 -0
  38. package/dist/errors.min.js +548 -0
  39. package/dist/form.js +936 -0
  40. package/dist/form.min.js +703 -0
  41. package/dist/guardrails.js +84 -0
  42. package/dist/guardrails.min.js +55 -0
  43. package/dist/h.js +232 -0
  44. package/dist/h.min.js +171 -0
  45. package/dist/head.js +241 -0
  46. package/dist/head.min.js +207 -0
  47. package/dist/helpers.js +126 -0
  48. package/dist/helpers.min.js +98 -0
  49. package/dist/hooks.js +255 -0
  50. package/dist/hooks.min.js +153 -0
  51. package/dist/hot.js +215 -0
  52. package/dist/hot.min.js +24 -0
  53. package/dist/hydration-data.js +495 -0
  54. package/dist/hydration-data.min.js +371 -0
  55. package/dist/import-changes.js +273 -0
  56. package/dist/import-changes.min.js +272 -0
  57. package/dist/index.js +95 -0
  58. package/dist/index.min.js +95 -227
  59. package/dist/jsx-dev-runtime.js +10 -0
  60. package/dist/jsx-dev-runtime.min.js +10 -1
  61. package/dist/jsx-runtime.js +27 -0
  62. package/dist/jsx-runtime.min.js +15 -1
  63. package/dist/live.js +54 -0
  64. package/dist/live.min.js +49 -0
  65. package/dist/markup-rules.js +250 -0
  66. package/dist/markup-rules.min.js +213 -0
  67. package/dist/reactive.js +3334 -0
  68. package/dist/reactive.min.js +2033 -0
  69. package/dist/render.js +4746 -0
  70. package/dist/render.min.js +2797 -1
  71. package/dist/scheduler.js +225 -0
  72. package/dist/scheduler.min.js +162 -0
  73. package/dist/selector.js +11 -0
  74. package/dist/selector.min.js +10 -0
  75. package/dist/server-context.js +148 -0
  76. package/dist/server-context.min.js +121 -0
  77. package/dist/skeleton.js +342 -0
  78. package/dist/skeleton.min.js +310 -0
  79. package/dist/store.js +72 -0
  80. package/dist/store.min.js +50 -0
  81. package/dist/testing.js +720 -0
  82. package/dist/testing.min.js +458 -1
  83. package/dist/vnode-adoption.js +19 -0
  84. package/dist/vnode-adoption.min.js +19 -0
  85. package/dist/vnode-renderer.js +61 -0
  86. package/dist/vnode-renderer.min.js +47 -0
  87. package/dom.d.ts +44 -0
  88. package/form.d.ts +218 -0
  89. package/hot.d.ts +35 -0
  90. package/index.d.ts +421 -736
  91. package/internal.d.ts +284 -0
  92. package/jsx-runtime.d.ts +160 -137
  93. package/markup-rules.d.ts +83 -0
  94. package/motion.d.ts +156 -0
  95. package/package.json +117 -3
  96. package/render.d.ts +278 -29
  97. package/src/a11y.js +64 -59
  98. package/src/actions.js +226 -0
  99. package/src/animation.js +105 -57
  100. package/src/async.js +259 -0
  101. package/src/components.js +495 -144
  102. package/src/data.js +1410 -1159
  103. package/src/diagnostics.js +263 -0
  104. package/src/dom.js +1159 -872
  105. package/src/entries/a11y.js +24 -0
  106. package/src/entries/data.js +17 -0
  107. package/src/entries/dom.js +29 -0
  108. package/src/entries/form.js +16 -0
  109. package/src/entries/internal.js +63 -0
  110. package/src/entries/motion.js +13 -0
  111. package/src/entries/ui.js +13 -0
  112. package/src/env-development.js +12 -0
  113. package/src/env.js +33 -0
  114. package/src/errors.js +1144 -168
  115. package/src/form.js +723 -225
  116. package/src/guardrails.js +38 -126
  117. package/src/h.js +227 -152
  118. package/src/head.js +189 -19
  119. package/src/helpers.js +47 -75
  120. package/src/hooks.js +233 -248
  121. package/src/hot.js +316 -0
  122. package/src/hydration-data.js +859 -16
  123. package/src/import-changes.js +156 -0
  124. package/src/index.js +38 -188
  125. package/src/jsx-dev-runtime.js +7 -14
  126. package/src/jsx-runtime.js +25 -9
  127. package/src/live.js +80 -0
  128. package/src/markup-rules.js +387 -0
  129. package/src/reactive.js +4400 -862
  130. package/src/render.js +6502 -2570
  131. package/src/scheduler.js +56 -21
  132. package/src/selector.js +31 -0
  133. package/src/server-context.js +252 -22
  134. package/src/skeleton.js +22 -12
  135. package/src/store.js +17 -31
  136. package/src/testing.js +389 -63
  137. package/src/vnode-adoption.js +48 -0
  138. package/src/vnode-renderer.js +114 -0
  139. package/testing.d.ts +81 -1
  140. package/ui.d.ts +20 -0
  141. package/dist/chunk-6YOUZ6T4.min.js +0 -1
  142. package/dist/chunk-FN6HXME3.min.js +0 -11
  143. package/dist/chunk-VKZY7JPN.min.js +0 -1
  144. package/src/agent-context.js +0 -127
  145. package/src/warnings.js +0 -193
@@ -0,0 +1,413 @@
1
+ // src/components.js
2
+ import { h as _, _vnode as I, lowered as w } from "./h.min.js";
3
+ import {
4
+ signal as O,
5
+ effect as H,
6
+ untrack as F,
7
+ getOwner as v,
8
+ runWithOwner as E,
9
+ createRoot as S,
10
+ onCleanup as L,
11
+ _handleError as P,
12
+ _isDisposed as T,
13
+ HANDLED as U,
14
+ _trackWork as j,
15
+ _beginWork as $,
16
+ _retryErrors as G,
17
+ _errorSource as J,
18
+ _setUserEffectGate as K,
19
+ _releaseUserEffect as X
20
+ } from "./reactive.min.js";
21
+ import { isServerRender as Y } from "./server-context.min.js";
22
+ import { hydrate as Z, insert as Q, _enableSuspense as V, _hydrationErrorHook as ee, _toFunctionComponent as B, _withCursor as ne } from "./render.min.js";
23
+ import { createDOM as A, _handleNavigationSignal as te, _place as R } from "./dom.min.js";
24
+ import { _islandHost as re } from "./hydration-data.min.js";
25
+ function ke(r, e) {
26
+ let n = B(r), t = function(i) {
27
+ return n(i);
28
+ };
29
+ return t.displayName = `Memo(${r.name || "Anonymous"})`, t;
30
+ }
31
+ function ve(r) {
32
+ V();
33
+ let e = null, n = null, t = null, o = !1, i = /* @__PURE__ */ new Set();
34
+ function u() {
35
+ t = null, o = !1;
36
+ let s = n = new Promise((a) => a(r())).then((a) => {
37
+ e = a.default || a, i.forEach((c) => c()), i.clear();
38
+ }, (a) => {
39
+ o ? t = { error: a } : n === s && (n = null);
40
+ });
41
+ return s;
42
+ }
43
+ function l(s) {
44
+ if (e) return _(e, s);
45
+ if (t !== null) {
46
+ let a = t;
47
+ throw queueMicrotask(() => {
48
+ t === a && (t = n = null);
49
+ }), a.error;
50
+ }
51
+ throw n === null && u(), o = !0, n;
52
+ }
53
+ return l.displayName = "Lazy", l._lazy = !0, l._load = (s) => e ? null : ((n === null || t !== null) && u(), s || (o = !0), n), l._onLoad = (s) => {
54
+ e ? s() : i.add(s);
55
+ }, l;
56
+ }
57
+ function M(r) {
58
+ return r._deferChildren = !0, r;
59
+ }
60
+ var we = /* @__PURE__ */ M(function(e) {
61
+ let n = ae(e), t = e.children;
62
+ return I("__suspense", { get fallback() {
63
+ return n.fallback;
64
+ }, boundary: n }, Array.isArray(t) ? t : [t]);
65
+ }), k = 0;
66
+ function N(r) {
67
+ if (k === 0) return !1;
68
+ let e = null;
69
+ for (let n = r.owner; n != null; n = n.owner) {
70
+ let t = n._suspense;
71
+ t !== void 0 && !t.revealed && (e = t);
72
+ }
73
+ return e === null ? !1 : (e.deferred.push(r), !0);
74
+ }
75
+ function oe(r, e) {
76
+ let n = () => {
77
+ let t = e.b;
78
+ t !== null && (t.links.delete(e), t.thenables--, t.check());
79
+ };
80
+ r.then(n, n);
81
+ }
82
+ function ae(r) {
83
+ V();
84
+ let e = {
85
+ get fallback() {
86
+ return R(r, "fallback");
87
+ },
88
+ revealed: !1,
89
+ hydrating: !1,
90
+ /** @type {Set<any>} held effects and bindings that have not completed a run since */
91
+ waiting: /* @__PURE__ */ new Set(),
92
+ /** promises of suspended components not settled yet */
93
+ thenables: 0,
94
+ /** @type {Set<{ b: any }>} what each of those promises reaches the boundary through */
95
+ links: /* @__PURE__ */ new Set(),
96
+ /** @type {any[]} user-phase effects waiting for the reveal */
97
+ deferred: [],
98
+ /** @type {(() => void) | null} */
99
+ show: null,
100
+ /** @type {(() => void) | null} */
101
+ conceal: null,
102
+ attached: !1,
103
+ queued: !1,
104
+ // `waiting` is a promise a component suspended on, or an effect or
105
+ // binding held on a value that is not ready. For an effect it counts,
106
+ // it returns the function the engine calls when the effect stops waiting.
107
+ onPending(n) {
108
+ if (e.revealed) {
109
+ if (n.showsFallback !== !0) return null;
110
+ e.revealed = !1, k++, queueMicrotask(() => {
111
+ !e.revealed && e.conceal !== null && e.conceal();
112
+ });
113
+ }
114
+ if (typeof n.then != "function")
115
+ return e.waiting.add(n), e.release;
116
+ e.thenables++, j(n);
117
+ let t = { b: e };
118
+ return e.links.add(t), oe(n, t), null;
119
+ },
120
+ // A counted effect completed a run, failed, or was disposed. Look again
121
+ // after the flush that is running (or the current task), when every
122
+ // binding that runs in it has run, and count the look as work settled()
123
+ // waits for.
124
+ release(n) {
125
+ e.waiting.delete(n), e.schedule();
126
+ },
127
+ schedule() {
128
+ if (e.queued || e.revealed) return;
129
+ e.queued = !0;
130
+ let n = $();
131
+ queueMicrotask(() => {
132
+ e.queued = !1, e.check(), n();
133
+ });
134
+ },
135
+ check() {
136
+ if (!(e.revealed || e.hydrating)) {
137
+ for (let n of e.waiting) T(n) && e.waiting.delete(n);
138
+ e.waiting.size === 0 && e.thenables === 0 && e.reveal();
139
+ }
140
+ },
141
+ reveal() {
142
+ e.revealed = !0, k--, e.show !== null && e.show();
143
+ let n = e.deferred;
144
+ e.deferred = [];
145
+ for (let t of n) N(t) || X(t);
146
+ },
147
+ // Start counting: the children are about to be built under `root`.
148
+ attach(n, t) {
149
+ n._onPending = e.onPending, n._suspense = e, !(e.revealed || e.attached) && (e.attached = !0, e.hydrating = t, k++, K(N), E(n.owner, () => L(() => {
150
+ for (let o of e.links) o.b = null;
151
+ e.links.clear(), e.revealed || (e.revealed = !0, k--);
152
+ })));
153
+ },
154
+ // Hydration: the children have been walked. The server's content is on
155
+ // screen unless a component suspended, so that is the reveal; a binding
156
+ // waiting for a value only the client fetches keeps the server's content
157
+ // up meanwhile.
158
+ walked() {
159
+ e.hydrating = !1, e.thenables === 0 && (e.waiting.clear(), e.revealed || e.reveal());
160
+ },
161
+ mount: ie
162
+ };
163
+ return e;
164
+ }
165
+ function D(r, e) {
166
+ return S((n) => {
167
+ for (let t of Array.isArray(r) ? r : [r]) {
168
+ let o = A(t, e.parentNode);
169
+ o && e.parentNode.insertBefore(o, e);
170
+ }
171
+ return n;
172
+ });
173
+ }
174
+ function ie(r, e) {
175
+ let n = r.props.boundary, t = v(), o = document.createComment("sb:start"), i = document.createComment("sb:end");
176
+ o._rangeEnd = i;
177
+ let u = document.createDocumentFragment();
178
+ u.appendChild(o), u.appendChild(i);
179
+ let l = document.createDocumentFragment();
180
+ S(() => {
181
+ n.attach(v(), !1);
182
+ for (let a of r.children) {
183
+ let c = A(a, e);
184
+ c && l.appendChild(c);
185
+ }
186
+ });
187
+ let s = null;
188
+ return n.show = () => {
189
+ if (s !== null) {
190
+ s(), s = null;
191
+ for (let a = o.nextSibling; a !== null && a !== i; a = o.nextSibling) a.remove();
192
+ }
193
+ i.parentNode.insertBefore(l, i);
194
+ }, n.conceal = () => {
195
+ for (let a = o.nextSibling; a !== null && a !== i; a = o.nextSibling) l.appendChild(a);
196
+ s = E(t, () => D(n.fallback, i));
197
+ }, n.check(), n.revealed || (s = D(n.fallback, i)), L(() => {
198
+ s !== null && s();
199
+ }), u;
200
+ }
201
+ var ge = /* @__PURE__ */ M(function(e) {
202
+ let { children: n, onError: t } = e, o = O(null), i = [];
203
+ return I("__errorBoundary", {
204
+ errorState: o,
205
+ handleError: (s) => {
206
+ let a = J(s);
207
+ if (a !== null && i.push(a), o.set(s), t)
208
+ try {
209
+ t(s);
210
+ } catch (c) {
211
+ console.error("Error in onError handler:", c);
212
+ }
213
+ },
214
+ reset: () => {
215
+ G(i.splice(0)), o.set(null);
216
+ },
217
+ mount: se,
218
+ get fallback() {
219
+ return R(e, "fallback");
220
+ }
221
+ }, Array.isArray(n) ? n : [n]);
222
+ });
223
+ function se(r, e) {
224
+ let { errorState: n, handleError: t, reset: o } = r.props, i = r.children, u = document.createComment("eb:start"), l = document.createComment("eb:end");
225
+ u._rangeEnd = l;
226
+ let s = document.createDocumentFragment();
227
+ return s.appendChild(u), s.appendChild(l), H(() => {
228
+ let a = n();
229
+ for (let c = u.nextSibling; c !== null && c !== l; c = u.nextSibling) c.remove();
230
+ F(() => {
231
+ if (a) {
232
+ let c = r.props.fallback;
233
+ q(typeof c == "function" ? B(c)({ error: a, reset: o }) : c, e, l, null);
234
+ return;
235
+ }
236
+ try {
237
+ ne(q, i, e, l, t);
238
+ } catch (c) {
239
+ if (te(c)) return;
240
+ t(c);
241
+ }
242
+ });
243
+ }), s;
244
+ }
245
+ function q(r, e, n, t) {
246
+ S(() => {
247
+ t !== null && (v()._onError = t);
248
+ for (let o of Array.isArray(r) ? r : [r]) {
249
+ let i = A(o, e);
250
+ i && n.parentNode.insertBefore(i, n);
251
+ }
252
+ });
253
+ }
254
+ function Ee(r, e) {
255
+ return P(e === void 0 ? v() : e, r) === U;
256
+ }
257
+ var Se = /* @__PURE__ */ w(function({ when: e, fallback: n = null, children: t }) {
258
+ return () => (typeof e == "function" ? e() : e) ? t : n;
259
+ }), Ae = /* @__PURE__ */ w(function({ each: e, key: n, fallback: t = null, children: o }) {
260
+ let i = Array.isArray(o) ? o[0] : o;
261
+ return typeof i != "function" ? (console.warn("[what] For: children must be a render function, e.g. <For each={items}>{(item) => ...}</For>"), t) : typeof n == "function" ? le(e, n, t, i) : () => {
262
+ let u = typeof e == "function" ? e() : e;
263
+ return !u || u.length === 0 ? t : u.map((l, s) => {
264
+ let a = i(l, s);
265
+ return a && typeof a == "object" && a.key == null && (l != null && typeof l == "object" ? l.id != null ? a.key = l.id : l.key != null && (a.key = l.key) : (typeof l == "string" || typeof l == "number") && (a.key = l, a._itemKey = !0)), a;
266
+ });
267
+ };
268
+ });
269
+ function le(r, e, n, t) {
270
+ let o = /* @__PURE__ */ new Map();
271
+ return () => {
272
+ let i = typeof r == "function" ? r() : r, u = /* @__PURE__ */ new Map();
273
+ if (!i || i.length === 0)
274
+ return o = u, n;
275
+ let l = i.map((s, a) => {
276
+ let c = e(s), h = o.get(c);
277
+ if (h === void 0 || u.has(c)) {
278
+ let b = O(s);
279
+ h = { item: b, vnode: F(() => t(() => b(), a)) }, h.vnode && typeof h.vnode == "object" && (h.vnode.key = c);
280
+ } else
281
+ h.item(s);
282
+ return u.set(c, h), h.vnode;
283
+ });
284
+ return o = u, l;
285
+ };
286
+ }
287
+ var Me = /* @__PURE__ */ w(function({ fallback: e = null, children: n }) {
288
+ let t = Array.isArray(n) ? n : [n];
289
+ return () => {
290
+ for (let o of t)
291
+ if (o && o.tag === ce) {
292
+ let i = o.props.when;
293
+ if (typeof i == "function" ? i() : i) return o.children;
294
+ }
295
+ return e;
296
+ };
297
+ }), ce = /* @__PURE__ */ w(function(e) {
298
+ return () => (typeof e.when == "function" ? e.when() : e.when) ? e.children : null;
299
+ });
300
+ function ue(r) {
301
+ let e = {};
302
+ for (let n in r) {
303
+ let t = r[n];
304
+ typeof t == "function" || typeof t == "symbol" || t === void 0 || (e[n] = t);
305
+ }
306
+ try {
307
+ return JSON.stringify(e);
308
+ } catch {
309
+ return "{}";
310
+ }
311
+ }
312
+ var xe = /* @__PURE__ */ M(function({ component: e, mode: n, mediaQuery: t, name: o, props: i, children: u, ...l }) {
313
+ let s = i === void 0 ? l : i, a = o || e?.name || "Island", c = n || "idle", h = {
314
+ "data-island": a,
315
+ "data-island-mode": c,
316
+ "data-hydrate": c,
317
+ // Tells hydrateIslands() to leave this element alone: a compiler-emitted
318
+ // island holds a direct component reference and hydrates itself, so it
319
+ // needs no registry entry and must not be claimed twice.
320
+ "data-island-self": "1"
321
+ }, b = u == null ? [] : Array.isArray(u) ? u : [u];
322
+ if (Y())
323
+ return re(), _(
324
+ "div",
325
+ { ...h, "data-island-props": ue(s) },
326
+ _(e, s, ...b)
327
+ );
328
+ let x = !1, g = v(), C = ee();
329
+ function W(d) {
330
+ if (x || g !== null && T(g)) return;
331
+ x = !0;
332
+ let f = _(e, s, ...b);
333
+ E(g, () => {
334
+ d.childNodes.length > 0 ? Z(f, d, C === null ? void 0 : { onHydrationError: C }) : Q(d, f, null);
335
+ }), d.removeAttribute("data-hydrate"), d.removeAttribute("data-island-self"), d.setAttribute("data-island-hydrated", "");
336
+ let p = d.ownerDocument?.defaultView ?? globalThis;
337
+ typeof p.CustomEvent == "function" && d.dispatchEvent(new p.CustomEvent("island:hydrated", {
338
+ bubbles: !0,
339
+ detail: { name: a, mode: c }
340
+ }));
341
+ }
342
+ function z(d) {
343
+ let f = () => W(d);
344
+ switch (c) {
345
+ case "load":
346
+ queueMicrotask(f);
347
+ break;
348
+ case "idle":
349
+ typeof requestIdleCallback < "u" ? requestIdleCallback(f) : setTimeout(f, 200);
350
+ break;
351
+ case "visible": {
352
+ if (typeof IntersectionObserver > "u") {
353
+ queueMicrotask(f);
354
+ break;
355
+ }
356
+ let p = new IntersectionObserver((m) => {
357
+ m.some((y) => y.isIntersecting) && (p.disconnect(), f());
358
+ }, { rootMargin: "200px" });
359
+ p.observe(d);
360
+ break;
361
+ }
362
+ case "interaction":
363
+ case "action": {
364
+ if (d.childNodes.length === 0) {
365
+ queueMicrotask(f);
366
+ break;
367
+ }
368
+ let p = ["click", "focus", "mouseenter", "touchstart"], m = () => {
369
+ for (let y of p) d.removeEventListener(y, m, !0);
370
+ f();
371
+ };
372
+ for (let y of p) d.addEventListener(y, m, { capture: !0, once: !0 });
373
+ break;
374
+ }
375
+ case "media": {
376
+ if (!t || typeof window > "u" || !window.matchMedia) {
377
+ f();
378
+ break;
379
+ }
380
+ let p = window.matchMedia(t);
381
+ if (p.matches) {
382
+ queueMicrotask(f);
383
+ break;
384
+ }
385
+ let m = () => {
386
+ p.matches && (p.removeEventListener("change", m), f());
387
+ };
388
+ p.addEventListener("change", m);
389
+ break;
390
+ }
391
+ // 'static' ships no JS at all: the server HTML is the whole island.
392
+ case "static":
393
+ break;
394
+ default:
395
+ queueMicrotask(f);
396
+ }
397
+ }
398
+ return _("div", { ...h, ref: (d) => {
399
+ d && z(d);
400
+ } });
401
+ });
402
+ export {
403
+ ge as ErrorBoundary,
404
+ Ae as For,
405
+ ce as Match,
406
+ Se as Show,
407
+ we as Suspense,
408
+ Me as Switch,
409
+ xe as _$Island,
410
+ ve as lazy,
411
+ ke as memo,
412
+ Ee as reportError
413
+ };