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.
- package/LICENSE +21 -0
- package/README.md +64 -38
- package/a11y.d.ts +128 -0
- package/data.d.ts +294 -0
- package/dist/a11y.js +510 -0
- package/dist/a11y.min.js +413 -0
- package/dist/actions.js +158 -0
- package/dist/actions.min.js +112 -0
- package/dist/animation.js +481 -0
- package/dist/animation.min.js +295 -0
- package/dist/async.js +180 -0
- package/dist/async.min.js +134 -0
- package/dist/components.js +577 -0
- package/dist/components.min.js +413 -0
- package/dist/data.js +1212 -0
- package/dist/data.min.js +918 -0
- package/dist/diagnostics.js +187 -0
- package/dist/diagnostics.min.js +134 -0
- package/dist/dom.js +796 -0
- package/dist/dom.min.js +603 -0
- package/dist/entries/a11y.js +43 -0
- package/dist/entries/a11y.min.js +43 -0
- package/dist/entries/data.js +29 -0
- package/dist/entries/data.min.js +29 -0
- package/dist/entries/dom.js +45 -0
- package/dist/entries/dom.min.js +45 -0
- package/dist/entries/form.js +31 -0
- package/dist/entries/form.min.js +31 -0
- package/dist/entries/internal.js +123 -0
- package/dist/entries/internal.min.js +123 -0
- package/dist/entries/motion.js +23 -0
- package/dist/entries/motion.min.js +23 -0
- package/dist/entries/ui.js +25 -0
- package/dist/entries/ui.min.js +25 -0
- package/dist/env.js +5 -0
- package/dist/env.min.js +5 -0
- package/dist/errors.js +1518 -0
- package/dist/errors.min.js +548 -0
- package/dist/form.js +936 -0
- package/dist/form.min.js +703 -0
- package/dist/guardrails.js +84 -0
- package/dist/guardrails.min.js +55 -0
- package/dist/h.js +232 -0
- package/dist/h.min.js +171 -0
- package/dist/head.js +241 -0
- package/dist/head.min.js +207 -0
- package/dist/helpers.js +126 -0
- package/dist/helpers.min.js +98 -0
- package/dist/hooks.js +255 -0
- package/dist/hooks.min.js +153 -0
- package/dist/hot.js +215 -0
- package/dist/hot.min.js +24 -0
- package/dist/hydration-data.js +495 -0
- package/dist/hydration-data.min.js +371 -0
- package/dist/import-changes.js +273 -0
- package/dist/import-changes.min.js +272 -0
- package/dist/index.js +95 -0
- package/dist/index.min.js +95 -227
- package/dist/jsx-dev-runtime.js +10 -0
- package/dist/jsx-dev-runtime.min.js +10 -1
- package/dist/jsx-runtime.js +27 -0
- package/dist/jsx-runtime.min.js +15 -1
- package/dist/live.js +54 -0
- package/dist/live.min.js +49 -0
- package/dist/markup-rules.js +250 -0
- package/dist/markup-rules.min.js +213 -0
- package/dist/reactive.js +3334 -0
- package/dist/reactive.min.js +2033 -0
- package/dist/render.js +4746 -0
- package/dist/render.min.js +2797 -1
- package/dist/scheduler.js +225 -0
- package/dist/scheduler.min.js +162 -0
- package/dist/selector.js +11 -0
- package/dist/selector.min.js +10 -0
- package/dist/server-context.js +148 -0
- package/dist/server-context.min.js +121 -0
- package/dist/skeleton.js +342 -0
- package/dist/skeleton.min.js +310 -0
- package/dist/store.js +72 -0
- package/dist/store.min.js +50 -0
- package/dist/testing.js +720 -0
- package/dist/testing.min.js +458 -1
- package/dist/vnode-adoption.js +19 -0
- package/dist/vnode-adoption.min.js +19 -0
- package/dist/vnode-renderer.js +61 -0
- package/dist/vnode-renderer.min.js +47 -0
- package/dom.d.ts +44 -0
- package/form.d.ts +218 -0
- package/hot.d.ts +35 -0
- package/index.d.ts +421 -736
- package/internal.d.ts +284 -0
- package/jsx-runtime.d.ts +160 -137
- package/markup-rules.d.ts +83 -0
- package/motion.d.ts +156 -0
- package/package.json +117 -3
- package/render.d.ts +278 -29
- package/src/a11y.js +64 -59
- package/src/actions.js +226 -0
- package/src/animation.js +105 -57
- package/src/async.js +259 -0
- package/src/components.js +495 -144
- package/src/data.js +1410 -1159
- package/src/diagnostics.js +263 -0
- package/src/dom.js +1159 -872
- package/src/entries/a11y.js +24 -0
- package/src/entries/data.js +17 -0
- package/src/entries/dom.js +29 -0
- package/src/entries/form.js +16 -0
- package/src/entries/internal.js +63 -0
- package/src/entries/motion.js +13 -0
- package/src/entries/ui.js +13 -0
- package/src/env-development.js +12 -0
- package/src/env.js +33 -0
- package/src/errors.js +1144 -168
- package/src/form.js +723 -225
- package/src/guardrails.js +38 -126
- package/src/h.js +227 -152
- package/src/head.js +189 -19
- package/src/helpers.js +47 -75
- package/src/hooks.js +233 -248
- package/src/hot.js +316 -0
- package/src/hydration-data.js +859 -16
- package/src/import-changes.js +156 -0
- package/src/index.js +38 -188
- package/src/jsx-dev-runtime.js +7 -14
- package/src/jsx-runtime.js +25 -9
- package/src/live.js +80 -0
- package/src/markup-rules.js +387 -0
- package/src/reactive.js +4400 -862
- package/src/render.js +6502 -2570
- package/src/scheduler.js +56 -21
- package/src/selector.js +31 -0
- package/src/server-context.js +252 -22
- package/src/skeleton.js +22 -12
- package/src/store.js +17 -31
- package/src/testing.js +389 -63
- package/src/vnode-adoption.js +48 -0
- package/src/vnode-renderer.js +114 -0
- package/testing.d.ts +81 -1
- package/ui.d.ts +20 -0
- package/dist/chunk-6YOUZ6T4.min.js +0 -1
- package/dist/chunk-FN6HXME3.min.js +0 -11
- package/dist/chunk-VKZY7JPN.min.js +0 -1
- package/src/agent-context.js +0 -127
- package/src/warnings.js +0 -193
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// src/scheduler.js
|
|
2
|
+
import { effect, getOwner, runWithOwner, onCleanup } from "./reactive.js";
|
|
3
|
+
var readQueue = [];
|
|
4
|
+
var writeQueue = [];
|
|
5
|
+
var scheduled = false;
|
|
6
|
+
function scheduleRead(fn) {
|
|
7
|
+
readQueue.push(fn);
|
|
8
|
+
schedule();
|
|
9
|
+
return () => {
|
|
10
|
+
const idx = readQueue.indexOf(fn);
|
|
11
|
+
if (idx !== -1) readQueue.splice(idx, 1);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function scheduleWrite(fn) {
|
|
15
|
+
writeQueue.push(fn);
|
|
16
|
+
schedule();
|
|
17
|
+
return () => {
|
|
18
|
+
const idx = writeQueue.indexOf(fn);
|
|
19
|
+
if (idx !== -1) writeQueue.splice(idx, 1);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function flushScheduler() {
|
|
23
|
+
while (readQueue.length > 0) {
|
|
24
|
+
const fn = readQueue.shift();
|
|
25
|
+
try {
|
|
26
|
+
fn();
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error("[what] Scheduler read error:", e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
while (writeQueue.length > 0) {
|
|
32
|
+
const fn = writeQueue.shift();
|
|
33
|
+
try {
|
|
34
|
+
fn();
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.error("[what] Scheduler write error:", e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
scheduled = false;
|
|
40
|
+
if (readQueue.length > 0 || writeQueue.length > 0) schedule();
|
|
41
|
+
}
|
|
42
|
+
function schedule() {
|
|
43
|
+
if (scheduled) return;
|
|
44
|
+
scheduled = true;
|
|
45
|
+
requestAnimationFrame(flushScheduler);
|
|
46
|
+
}
|
|
47
|
+
function measure(fn) {
|
|
48
|
+
return (
|
|
49
|
+
/** @type {Promise<void>} */
|
|
50
|
+
new Promise((resolve) => {
|
|
51
|
+
scheduleRead(() => {
|
|
52
|
+
resolve(fn());
|
|
53
|
+
});
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function mutate(fn) {
|
|
58
|
+
return (
|
|
59
|
+
/** @type {Promise<void>} */
|
|
60
|
+
new Promise((resolve) => {
|
|
61
|
+
scheduleWrite(() => {
|
|
62
|
+
fn();
|
|
63
|
+
resolve();
|
|
64
|
+
});
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function useScheduledEffect(readFn, writeFn) {
|
|
69
|
+
const owner = getOwner();
|
|
70
|
+
let disposed = false;
|
|
71
|
+
let cancel = null;
|
|
72
|
+
let tracking = noop;
|
|
73
|
+
const schedule2 = () => {
|
|
74
|
+
if (cancel === null && !disposed) cancel = scheduleRead(read);
|
|
75
|
+
};
|
|
76
|
+
const read = () => {
|
|
77
|
+
cancel = null;
|
|
78
|
+
tracking();
|
|
79
|
+
let first = true;
|
|
80
|
+
let data;
|
|
81
|
+
tracking = runWithOwner(owner, () => effect(() => {
|
|
82
|
+
if (!first) {
|
|
83
|
+
schedule2();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
first = false;
|
|
87
|
+
data = readFn();
|
|
88
|
+
}));
|
|
89
|
+
if (writeFn) scheduleWrite(() => {
|
|
90
|
+
if (!disposed) writeFn(data);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const dispose = () => {
|
|
94
|
+
disposed = true;
|
|
95
|
+
if (cancel !== null) cancel();
|
|
96
|
+
cancel = null;
|
|
97
|
+
tracking();
|
|
98
|
+
tracking = noop;
|
|
99
|
+
};
|
|
100
|
+
if (owner !== null) onCleanup(dispose);
|
|
101
|
+
schedule2();
|
|
102
|
+
return dispose;
|
|
103
|
+
}
|
|
104
|
+
function noop() {
|
|
105
|
+
}
|
|
106
|
+
function nextFrame() {
|
|
107
|
+
let cancel;
|
|
108
|
+
const promise = new Promise((resolve, reject) => {
|
|
109
|
+
const id = requestAnimationFrame(resolve);
|
|
110
|
+
cancel = () => {
|
|
111
|
+
cancelAnimationFrame(id);
|
|
112
|
+
reject(new Error("Cancelled"));
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
promise.cancel = cancel;
|
|
116
|
+
return promise;
|
|
117
|
+
}
|
|
118
|
+
var debouncedCallbacks = /* @__PURE__ */ new Map();
|
|
119
|
+
function raf(key, fn) {
|
|
120
|
+
if (debouncedCallbacks.has(key)) {
|
|
121
|
+
debouncedCallbacks.set(key, fn);
|
|
122
|
+
} else {
|
|
123
|
+
debouncedCallbacks.set(key, fn);
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
const callback = debouncedCallbacks.get(key);
|
|
126
|
+
debouncedCallbacks.delete(key);
|
|
127
|
+
if (callback) callback();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var resizeObservers = /* @__PURE__ */ new WeakMap();
|
|
132
|
+
var sharedResizeObserver = null;
|
|
133
|
+
function onResize(element, callback) {
|
|
134
|
+
if (typeof ResizeObserver === "undefined") {
|
|
135
|
+
callback(element.getBoundingClientRect());
|
|
136
|
+
return () => {
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (!sharedResizeObserver) {
|
|
140
|
+
sharedResizeObserver = new ResizeObserver((entries) => {
|
|
141
|
+
scheduleRead(() => {
|
|
142
|
+
for (const entry2 of entries) {
|
|
143
|
+
const callbacks2 = resizeObservers.get(entry2.target);
|
|
144
|
+
if (callbacks2) for (const cb of [...callbacks2]) cb(entry2.contentRect);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const observer = sharedResizeObserver;
|
|
150
|
+
let callbacks = resizeObservers.get(element);
|
|
151
|
+
if (!callbacks) {
|
|
152
|
+
resizeObservers.set(element, callbacks = /* @__PURE__ */ new Set());
|
|
153
|
+
observer.observe(element);
|
|
154
|
+
}
|
|
155
|
+
const entry = (rect) => callback(rect);
|
|
156
|
+
callbacks.add(entry);
|
|
157
|
+
return () => {
|
|
158
|
+
if (!callbacks.delete(entry) || callbacks.size) return;
|
|
159
|
+
resizeObservers.delete(element);
|
|
160
|
+
observer.unobserve(element);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function onIntersect(element, callback, options = {}) {
|
|
164
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
165
|
+
callback({ isIntersecting: true, intersectionRatio: 1 });
|
|
166
|
+
return () => {
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const observer = new IntersectionObserver((entries) => {
|
|
170
|
+
scheduleRead(() => {
|
|
171
|
+
for (const entry of entries) {
|
|
172
|
+
callback(entry);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}, options);
|
|
176
|
+
observer.observe(element);
|
|
177
|
+
return () => observer.disconnect();
|
|
178
|
+
}
|
|
179
|
+
function smoothScrollTo(element, options = {}) {
|
|
180
|
+
const { duration = 300, easing = (t) => t * (2 - t) } = options;
|
|
181
|
+
return (
|
|
182
|
+
/** @type {Promise<void>} */
|
|
183
|
+
new Promise((resolve) => {
|
|
184
|
+
let startY;
|
|
185
|
+
let targetY;
|
|
186
|
+
let startTime;
|
|
187
|
+
scheduleRead(() => {
|
|
188
|
+
startY = window.scrollY;
|
|
189
|
+
const rect = element.getBoundingClientRect();
|
|
190
|
+
targetY = startY + rect.top;
|
|
191
|
+
startTime = performance.now();
|
|
192
|
+
tick();
|
|
193
|
+
});
|
|
194
|
+
function tick() {
|
|
195
|
+
scheduleRead(() => {
|
|
196
|
+
const elapsed = performance.now() - startTime;
|
|
197
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
198
|
+
const easedProgress = easing(progress);
|
|
199
|
+
const currentY = startY + (targetY - startY) * easedProgress;
|
|
200
|
+
scheduleWrite(() => {
|
|
201
|
+
window.scrollTo(0, currentY);
|
|
202
|
+
if (progress < 1) {
|
|
203
|
+
requestAnimationFrame(tick);
|
|
204
|
+
} else {
|
|
205
|
+
resolve();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
export {
|
|
214
|
+
flushScheduler,
|
|
215
|
+
measure,
|
|
216
|
+
mutate,
|
|
217
|
+
nextFrame,
|
|
218
|
+
onIntersect,
|
|
219
|
+
onResize,
|
|
220
|
+
raf,
|
|
221
|
+
scheduleRead,
|
|
222
|
+
scheduleWrite,
|
|
223
|
+
smoothScrollTo,
|
|
224
|
+
useScheduledEffect
|
|
225
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// src/scheduler.js
|
|
2
|
+
import { effect as S, getOwner as A, runWithOwner as C, onCleanup as F } from "./reactive.min.js";
|
|
3
|
+
var f = [], a = [], g = !1;
|
|
4
|
+
function d(e) {
|
|
5
|
+
return f.push(e), b(), () => {
|
|
6
|
+
let t = f.indexOf(e);
|
|
7
|
+
t !== -1 && f.splice(t, 1);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function x(e) {
|
|
11
|
+
return a.push(e), b(), () => {
|
|
12
|
+
let t = a.indexOf(e);
|
|
13
|
+
t !== -1 && a.splice(t, 1);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function z() {
|
|
17
|
+
for (; f.length > 0; ) {
|
|
18
|
+
let e = f.shift();
|
|
19
|
+
try {
|
|
20
|
+
e();
|
|
21
|
+
} catch (t) {
|
|
22
|
+
console.error("[what] Scheduler read error:", t);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (; a.length > 0; ) {
|
|
26
|
+
let e = a.shift();
|
|
27
|
+
try {
|
|
28
|
+
e();
|
|
29
|
+
} catch (t) {
|
|
30
|
+
console.error("[what] Scheduler write error:", t);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
g = !1, (f.length > 0 || a.length > 0) && b();
|
|
34
|
+
}
|
|
35
|
+
function b() {
|
|
36
|
+
g || (g = !0, requestAnimationFrame(z));
|
|
37
|
+
}
|
|
38
|
+
function P(e) {
|
|
39
|
+
return (
|
|
40
|
+
/** @type {Promise<void>} */
|
|
41
|
+
new Promise((t) => {
|
|
42
|
+
d(() => {
|
|
43
|
+
t(e());
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function q(e) {
|
|
49
|
+
return (
|
|
50
|
+
/** @type {Promise<void>} */
|
|
51
|
+
new Promise((t) => {
|
|
52
|
+
x(() => {
|
|
53
|
+
e(), t();
|
|
54
|
+
});
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function Y(e, t) {
|
|
59
|
+
let s = A(), r = !1, n = null, o = v, c = () => {
|
|
60
|
+
n === null && !r && (n = d(i));
|
|
61
|
+
}, i = () => {
|
|
62
|
+
n = null, o();
|
|
63
|
+
let l = !0, p;
|
|
64
|
+
o = C(s, () => S(() => {
|
|
65
|
+
if (!l) {
|
|
66
|
+
c();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
l = !1, p = e();
|
|
70
|
+
})), t && x(() => {
|
|
71
|
+
r || t(p);
|
|
72
|
+
});
|
|
73
|
+
}, u = () => {
|
|
74
|
+
r = !0, n !== null && n(), n = null, o(), o = v;
|
|
75
|
+
};
|
|
76
|
+
return s !== null && F(u), c(), u;
|
|
77
|
+
}
|
|
78
|
+
function v() {
|
|
79
|
+
}
|
|
80
|
+
function y() {
|
|
81
|
+
let e, t = new Promise((s, r) => {
|
|
82
|
+
let n = requestAnimationFrame(s);
|
|
83
|
+
e = () => {
|
|
84
|
+
cancelAnimationFrame(n), r(new Error("Cancelled"));
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
return t.cancel = e, t;
|
|
88
|
+
}
|
|
89
|
+
var h = /* @__PURE__ */ new Map();
|
|
90
|
+
function M(e, t) {
|
|
91
|
+
h.has(e) ? h.set(e, t) : (h.set(e, t), requestAnimationFrame(() => {
|
|
92
|
+
let s = h.get(e);
|
|
93
|
+
h.delete(e), s && s();
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
var w = /* @__PURE__ */ new WeakMap(), m = null;
|
|
97
|
+
function T(e, t) {
|
|
98
|
+
if (typeof ResizeObserver > "u")
|
|
99
|
+
return t(e.getBoundingClientRect()), () => {
|
|
100
|
+
};
|
|
101
|
+
m || (m = new ResizeObserver((o) => {
|
|
102
|
+
d(() => {
|
|
103
|
+
for (let c of o) {
|
|
104
|
+
let i = w.get(c.target);
|
|
105
|
+
if (i) for (let u of [...i]) u(c.contentRect);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}));
|
|
109
|
+
let s = m, r = w.get(e);
|
|
110
|
+
r || (w.set(e, r = /* @__PURE__ */ new Set()), s.observe(e));
|
|
111
|
+
let n = (o) => t(o);
|
|
112
|
+
return r.add(n), () => {
|
|
113
|
+
!r.delete(n) || r.size || (w.delete(e), s.unobserve(e));
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function W(e, t, s = {}) {
|
|
117
|
+
if (typeof IntersectionObserver > "u")
|
|
118
|
+
return t({ isIntersecting: !0, intersectionRatio: 1 }), () => {
|
|
119
|
+
};
|
|
120
|
+
let r = new IntersectionObserver((n) => {
|
|
121
|
+
d(() => {
|
|
122
|
+
for (let o of n)
|
|
123
|
+
t(o);
|
|
124
|
+
});
|
|
125
|
+
}, s);
|
|
126
|
+
return r.observe(e), () => r.disconnect();
|
|
127
|
+
}
|
|
128
|
+
function B(e, t = {}) {
|
|
129
|
+
let { duration: s = 300, easing: r = (n) => n * (2 - n) } = t;
|
|
130
|
+
return (
|
|
131
|
+
/** @type {Promise<void>} */
|
|
132
|
+
new Promise((n) => {
|
|
133
|
+
let o, c, i;
|
|
134
|
+
d(() => {
|
|
135
|
+
o = window.scrollY;
|
|
136
|
+
let l = e.getBoundingClientRect();
|
|
137
|
+
c = o + l.top, i = performance.now(), u();
|
|
138
|
+
});
|
|
139
|
+
function u() {
|
|
140
|
+
d(() => {
|
|
141
|
+
let l = performance.now() - i, p = Math.min(l / s, 1), O = r(p), R = o + (c - o) * O;
|
|
142
|
+
x(() => {
|
|
143
|
+
window.scrollTo(0, R), p < 1 ? requestAnimationFrame(u) : n();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
z as flushScheduler,
|
|
152
|
+
P as measure,
|
|
153
|
+
q as mutate,
|
|
154
|
+
y as nextFrame,
|
|
155
|
+
W as onIntersect,
|
|
156
|
+
T as onResize,
|
|
157
|
+
M as raf,
|
|
158
|
+
d as scheduleRead,
|
|
159
|
+
x as scheduleWrite,
|
|
160
|
+
B as smoothScrollTo,
|
|
161
|
+
Y as useScheduledEffect
|
|
162
|
+
};
|
package/dist/selector.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/selector.js
|
|
2
|
+
import { _createSelector } from "./reactive.js";
|
|
3
|
+
function createSelector(source) {
|
|
4
|
+
if (typeof source !== "function") {
|
|
5
|
+
throw new TypeError((process.env.NODE_ENV !== "production") ? "[what] createSelector(source) needs a signal or accessor function, e.g. createSelector(selectedId)." : "[what] createSelector: source must be a function");
|
|
6
|
+
}
|
|
7
|
+
return _createSelector(source);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
createSelector
|
|
11
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// src/server-context.js
|
|
2
|
+
import { runWithOwner, flushSync, _detached, _engine, _setOwnerFallback, _isDisposed, _serverStoreKey as STORE } from "./reactive.js";
|
|
3
|
+
import { _installServerSeeding } from "./hydration-data.js";
|
|
4
|
+
import { _thrownMessage } from "./diagnostics.js";
|
|
5
|
+
var shared = null;
|
|
6
|
+
function store() {
|
|
7
|
+
if (shared === null) _setOwnerFallback(renderOwner);
|
|
8
|
+
return shared ??= /** @type {any} */
|
|
9
|
+
globalThis[STORE] ??= { current: null, storage: null, frames: null, server: false, withDocument: false };
|
|
10
|
+
}
|
|
11
|
+
function serving() {
|
|
12
|
+
_installServerSeeding();
|
|
13
|
+
const state = store();
|
|
14
|
+
state.adopt = adopt;
|
|
15
|
+
state.refuse = refuse;
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
function refuse() {
|
|
19
|
+
if (getServerContext() != null) {
|
|
20
|
+
throw Object.assign(new Error((process.env.NODE_ENV !== "production") ? _thrownMessage("ERR_FOREIGN_ENGINE_IN_SSR", "An async value was made by a second copy of what-core during a server render. Bundle one copy of what-framework.") : "[what] An async value was made by a second copy of what-core during a server render. Bundle one copy of what-framework."), { code: "ERR_FOREIGN_ENGINE_IN_SSR" });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function adopt(setFallback, engine) {
|
|
24
|
+
setFallback(() => {
|
|
25
|
+
const ctx = getServerContext();
|
|
26
|
+
return ctx != null && typeof ctx.rootFor === "function" ? ctx.rootFor(engine) : null;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function renderOwner() {
|
|
30
|
+
const frames = (
|
|
31
|
+
/** @type {any} */
|
|
32
|
+
shared.frames
|
|
33
|
+
);
|
|
34
|
+
const resumed = frames !== null ? frames.getStore() : void 0;
|
|
35
|
+
if (resumed != null && resumed.engine === _engine && !_isDisposed(resumed.frame)) return resumed.frame;
|
|
36
|
+
const ctx = getServerContext();
|
|
37
|
+
return ctx != null && typeof ctx.rootFor === "function" ? ctx.rootFor(_engine) : null;
|
|
38
|
+
}
|
|
39
|
+
var installed = false;
|
|
40
|
+
function __installServerContextStorage(storage, frames) {
|
|
41
|
+
if (installed) return;
|
|
42
|
+
installed = true;
|
|
43
|
+
const state = serving();
|
|
44
|
+
if (state.storage === null) {
|
|
45
|
+
state.storage = storage;
|
|
46
|
+
state.frames = frames ?? null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function inBody(frame, fn, arg) {
|
|
50
|
+
frame._inBody = true;
|
|
51
|
+
try {
|
|
52
|
+
return fn(arg);
|
|
53
|
+
} finally {
|
|
54
|
+
frame._inBody = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function _runComponentAsync(frame, fn, arg) {
|
|
58
|
+
const frames = store().frames;
|
|
59
|
+
if ((process.env.NODE_ENV !== "production")) return frames === null ? inBody(frame, fn, arg) : frames.run({ engine: _engine, frame }, inBody, frame, fn, arg);
|
|
60
|
+
return frames === null ? fn(arg) : frames.run({ engine: _engine, frame }, fn, arg);
|
|
61
|
+
}
|
|
62
|
+
function _runComponentSync(frame, fn, arg) {
|
|
63
|
+
return (process.env.NODE_ENV !== "production") ? inBody(frame, fn, arg) : fn(arg);
|
|
64
|
+
}
|
|
65
|
+
function __markServerProcess() {
|
|
66
|
+
const state = store();
|
|
67
|
+
state.server = true;
|
|
68
|
+
state.withDocument = typeof document !== "undefined";
|
|
69
|
+
}
|
|
70
|
+
function _isServerProcess() {
|
|
71
|
+
const state = shared ?? /** @type {any} */
|
|
72
|
+
globalThis[STORE];
|
|
73
|
+
return state != null && state.server && (!state.withDocument || state.storage === null);
|
|
74
|
+
}
|
|
75
|
+
function getServerContext() {
|
|
76
|
+
const state = shared ?? /** @type {any} */
|
|
77
|
+
globalThis[STORE];
|
|
78
|
+
if (state == null) return null;
|
|
79
|
+
if (state.current != null) return state.current;
|
|
80
|
+
return state.storage ? state.storage.getStore() ?? null : null;
|
|
81
|
+
}
|
|
82
|
+
function isServerRender() {
|
|
83
|
+
return typeof document === "undefined" || getServerContext() != null;
|
|
84
|
+
}
|
|
85
|
+
function setServerContext(ctx) {
|
|
86
|
+
const state = serving();
|
|
87
|
+
const prev = state.current;
|
|
88
|
+
state.current = ctx;
|
|
89
|
+
return prev;
|
|
90
|
+
}
|
|
91
|
+
function runWithServerContext(ctx, fn) {
|
|
92
|
+
const state = serving();
|
|
93
|
+
const prev = state.current;
|
|
94
|
+
state.current = ctx;
|
|
95
|
+
const run = ctx && ctx.owner ? () => runWithOwner(ctx.owner, fn) : fn;
|
|
96
|
+
try {
|
|
97
|
+
return state.storage ? state.storage.run(ctx, run) : run();
|
|
98
|
+
} finally {
|
|
99
|
+
state.current = prev;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function __flushOutsideServerContext() {
|
|
103
|
+
__outsideServerContext(flushSync);
|
|
104
|
+
}
|
|
105
|
+
function __outsideServerContext(fn) {
|
|
106
|
+
const state = store();
|
|
107
|
+
const prev = state.current;
|
|
108
|
+
const storage = state.storage;
|
|
109
|
+
const frames = state.frames;
|
|
110
|
+
state.current = null;
|
|
111
|
+
const outside = frames ? () => frames.run(null, fn) : fn;
|
|
112
|
+
try {
|
|
113
|
+
return _detached(storage ? () => storage.run(null, outside) : outside);
|
|
114
|
+
} finally {
|
|
115
|
+
state.current = prev;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var NO_RESPONSE = /* @__PURE__ */ Object.freeze({
|
|
119
|
+
status: 200,
|
|
120
|
+
location: null,
|
|
121
|
+
committed: false,
|
|
122
|
+
setStatus() {
|
|
123
|
+
},
|
|
124
|
+
setHeader() {
|
|
125
|
+
},
|
|
126
|
+
redirect() {
|
|
127
|
+
},
|
|
128
|
+
redirectExternal() {
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
function getResponse() {
|
|
132
|
+
const ctx = getServerContext();
|
|
133
|
+
return ctx && ctx.response || NO_RESPONSE;
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
__flushOutsideServerContext,
|
|
137
|
+
__installServerContextStorage,
|
|
138
|
+
__markServerProcess,
|
|
139
|
+
__outsideServerContext,
|
|
140
|
+
_isServerProcess,
|
|
141
|
+
_runComponentAsync,
|
|
142
|
+
_runComponentSync,
|
|
143
|
+
getResponse,
|
|
144
|
+
getServerContext,
|
|
145
|
+
isServerRender,
|
|
146
|
+
runWithServerContext,
|
|
147
|
+
setServerContext
|
|
148
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/server-context.js
|
|
2
|
+
import { runWithOwner as _, flushSync as m, _detached as p, _engine as a, _setOwnerFallback as g, _isDisposed as y, _serverStoreKey as c } from "./reactive.min.js";
|
|
3
|
+
import { _installServerSeeding as S } from "./hydration-data.min.js";
|
|
4
|
+
var u = null;
|
|
5
|
+
function l() {
|
|
6
|
+
return u === null && g(h), u ??= /** @type {any} */
|
|
7
|
+
globalThis[c] ??= { current: null, storage: null, frames: null, server: !1, withDocument: !1 };
|
|
8
|
+
}
|
|
9
|
+
function i() {
|
|
10
|
+
S();
|
|
11
|
+
let e = l();
|
|
12
|
+
return e.adopt = w, e.refuse = v, e;
|
|
13
|
+
}
|
|
14
|
+
function v() {
|
|
15
|
+
if (s() != null)
|
|
16
|
+
throw Object.assign(new Error("[what] An async value was made by a second copy of what-core during a server render. Bundle one copy of what-framework."), { code: "ERR_FOREIGN_ENGINE_IN_SSR" });
|
|
17
|
+
}
|
|
18
|
+
function w(e, n) {
|
|
19
|
+
e(() => {
|
|
20
|
+
let r = s();
|
|
21
|
+
return r != null && typeof r.rootFor == "function" ? r.rootFor(n) : null;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function h() {
|
|
25
|
+
let e = (
|
|
26
|
+
/** @type {any} */
|
|
27
|
+
u.frames
|
|
28
|
+
), n = e !== null ? e.getStore() : void 0;
|
|
29
|
+
if (n != null && n.engine === a && !y(n.frame)) return n.frame;
|
|
30
|
+
let r = s();
|
|
31
|
+
return r != null && typeof r.rootFor == "function" ? r.rootFor(a) : null;
|
|
32
|
+
}
|
|
33
|
+
var d = !1;
|
|
34
|
+
function N(e, n) {
|
|
35
|
+
if (d) return;
|
|
36
|
+
d = !0;
|
|
37
|
+
let r = i();
|
|
38
|
+
r.storage === null && (r.storage = e, r.frames = n ?? null);
|
|
39
|
+
}
|
|
40
|
+
function b(e, n, r) {
|
|
41
|
+
let t = l().frames;
|
|
42
|
+
return t === null ? n(r) : t.run({ engine: a, frame: e }, n, r);
|
|
43
|
+
}
|
|
44
|
+
function B(e, n, r) {
|
|
45
|
+
return n(r);
|
|
46
|
+
}
|
|
47
|
+
function C() {
|
|
48
|
+
let e = l();
|
|
49
|
+
e.server = !0, e.withDocument = typeof document < "u";
|
|
50
|
+
}
|
|
51
|
+
function D() {
|
|
52
|
+
let e = u ?? /** @type {any} */
|
|
53
|
+
globalThis[c];
|
|
54
|
+
return e != null && e.server && (!e.withDocument || e.storage === null);
|
|
55
|
+
}
|
|
56
|
+
function s() {
|
|
57
|
+
let e = u ?? /** @type {any} */
|
|
58
|
+
globalThis[c];
|
|
59
|
+
return e == null ? null : e.current != null ? e.current : e.storage ? e.storage.getStore() ?? null : null;
|
|
60
|
+
}
|
|
61
|
+
function F() {
|
|
62
|
+
return typeof document > "u" || s() != null;
|
|
63
|
+
}
|
|
64
|
+
function I(e) {
|
|
65
|
+
let n = i(), r = n.current;
|
|
66
|
+
return n.current = e, r;
|
|
67
|
+
}
|
|
68
|
+
function k(e, n) {
|
|
69
|
+
let r = i(), t = r.current;
|
|
70
|
+
r.current = e;
|
|
71
|
+
let o = e && e.owner ? () => _(e.owner, n) : n;
|
|
72
|
+
try {
|
|
73
|
+
return r.storage ? r.storage.run(e, o) : o();
|
|
74
|
+
} finally {
|
|
75
|
+
r.current = t;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function G() {
|
|
79
|
+
x(m);
|
|
80
|
+
}
|
|
81
|
+
function x(e) {
|
|
82
|
+
let n = l(), r = n.current, t = n.storage, o = n.frames;
|
|
83
|
+
n.current = null;
|
|
84
|
+
let f = o ? () => o.run(null, e) : e;
|
|
85
|
+
try {
|
|
86
|
+
return p(t ? () => t.run(null, f) : f);
|
|
87
|
+
} finally {
|
|
88
|
+
n.current = r;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
var E = /* @__PURE__ */ Object.freeze({
|
|
92
|
+
status: 200,
|
|
93
|
+
location: null,
|
|
94
|
+
committed: !1,
|
|
95
|
+
setStatus() {
|
|
96
|
+
},
|
|
97
|
+
setHeader() {
|
|
98
|
+
},
|
|
99
|
+
redirect() {
|
|
100
|
+
},
|
|
101
|
+
redirectExternal() {
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
function T() {
|
|
105
|
+
let e = s();
|
|
106
|
+
return e && e.response || E;
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
G as __flushOutsideServerContext,
|
|
110
|
+
N as __installServerContextStorage,
|
|
111
|
+
C as __markServerProcess,
|
|
112
|
+
x as __outsideServerContext,
|
|
113
|
+
D as _isServerProcess,
|
|
114
|
+
b as _runComponentAsync,
|
|
115
|
+
B as _runComponentSync,
|
|
116
|
+
T as getResponse,
|
|
117
|
+
s as getServerContext,
|
|
118
|
+
F as isServerRender,
|
|
119
|
+
k as runWithServerContext,
|
|
120
|
+
I as setServerContext
|
|
121
|
+
};
|