solid-js 1.10.0-beta.0 → 2.0.0-beta.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/dist/dev.cjs +730 -1723
- package/dist/dev.js +595 -1688
- package/dist/server.cjs +769 -703
- package/dist/server.js +682 -670
- package/dist/solid.cjs +696 -1667
- package/dist/solid.js +560 -1631
- package/package.json +7 -151
- package/types/{render → client}/component.d.ts +1 -38
- package/types/client/core.d.ts +65 -0
- package/types/client/flow.d.ts +100 -0
- package/types/client/hydration.d.ts +76 -0
- package/types/index.d.ts +11 -14
- package/types/jsx.d.ts +1508 -1633
- package/types/server/component.d.ts +66 -0
- package/types/server/core.d.ts +44 -0
- package/types/server/flow.d.ts +60 -0
- package/types/server/hydration.d.ts +21 -0
- package/types/server/index.d.ts +12 -3
- package/types/server/shared.d.ts +45 -0
- package/types/server/signals.d.ts +60 -0
- package/h/dist/h.cjs +0 -115
- package/h/dist/h.js +0 -113
- package/h/jsx-dev-runtime/package.json +0 -8
- package/h/jsx-runtime/dist/jsx.cjs +0 -15
- package/h/jsx-runtime/dist/jsx.js +0 -10
- package/h/jsx-runtime/package.json +0 -8
- package/h/jsx-runtime/types/index.d.ts +0 -11
- package/h/jsx-runtime/types/jsx.d.ts +0 -4242
- package/h/package.json +0 -8
- package/h/types/hyperscript.d.ts +0 -20
- package/h/types/index.d.ts +0 -3
- package/html/dist/html.cjs +0 -583
- package/html/dist/html.js +0 -581
- package/html/package.json +0 -8
- package/html/types/index.d.ts +0 -3
- package/html/types/lit.d.ts +0 -41
- package/store/dist/dev.cjs +0 -458
- package/store/dist/dev.js +0 -449
- package/store/dist/server.cjs +0 -126
- package/store/dist/server.js +0 -114
- package/store/dist/store.cjs +0 -438
- package/store/dist/store.js +0 -429
- package/store/package.json +0 -46
- package/store/types/index.d.ts +0 -12
- package/store/types/modifiers.d.ts +0 -6
- package/store/types/mutable.d.ts +0 -5
- package/store/types/server.d.ts +0 -17
- package/store/types/store.d.ts +0 -107
- package/types/reactive/array.d.ts +0 -44
- package/types/reactive/observable.d.ts +0 -36
- package/types/reactive/scheduler.d.ts +0 -10
- package/types/reactive/signal.d.ts +0 -586
- package/types/render/Suspense.d.ts +0 -26
- package/types/render/flow.d.ts +0 -118
- package/types/render/hydration.d.ts +0 -24
- package/types/render/index.d.ts +0 -4
- package/types/server/reactive.d.ts +0 -98
- package/types/server/rendering.d.ts +0 -159
- package/universal/dist/dev.cjs +0 -245
- package/universal/dist/dev.js +0 -243
- package/universal/dist/universal.cjs +0 -245
- package/universal/dist/universal.js +0 -243
- package/universal/package.json +0 -20
- package/universal/types/index.d.ts +0 -3
- package/universal/types/universal.d.ts +0 -30
- package/web/dist/dev.cjs +0 -894
- package/web/dist/dev.js +0 -782
- package/web/dist/server.cjs +0 -892
- package/web/dist/server.js +0 -782
- package/web/dist/web.cjs +0 -883
- package/web/dist/web.js +0 -771
- package/web/package.json +0 -46
- package/web/storage/dist/storage.cjs +0 -12
- package/web/storage/dist/storage.js +0 -10
- package/web/storage/package.json +0 -15
- package/web/storage/types/index.d.ts +0 -2
- package/web/types/client.d.ts +0 -79
- package/web/types/core.d.ts +0 -2
- package/web/types/index.d.ts +0 -50
- package/web/types/jsx.d.ts +0 -1
- package/web/types/server-mock.d.ts +0 -65
- package/web/types/server.d.ts +0 -177
package/dist/solid.js
CHANGED
|
@@ -1,1489 +1,586 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
scheduledCallback = null;
|
|
13
|
-
const maxSigned31BitInt = 1073741823;
|
|
14
|
-
function setupScheduler() {
|
|
15
|
-
const channel = new MessageChannel(),
|
|
16
|
-
port = channel.port2;
|
|
17
|
-
scheduleCallback = () => port.postMessage(null);
|
|
18
|
-
channel.port1.onmessage = () => {
|
|
19
|
-
if (scheduledCallback !== null) {
|
|
20
|
-
const currentTime = performance.now();
|
|
21
|
-
deadline = currentTime + yieldInterval;
|
|
22
|
-
maxDeadline = currentTime + maxYieldInterval;
|
|
23
|
-
try {
|
|
24
|
-
const hasMoreWork = scheduledCallback(currentTime);
|
|
25
|
-
if (!hasMoreWork) {
|
|
26
|
-
scheduledCallback = null;
|
|
27
|
-
} else port.postMessage(null);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
port.postMessage(null);
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
if (navigator && navigator.scheduling && navigator.scheduling.isInputPending) {
|
|
35
|
-
const scheduling = navigator.scheduling;
|
|
36
|
-
shouldYieldToHost = () => {
|
|
37
|
-
const currentTime = performance.now();
|
|
38
|
-
if (currentTime >= deadline) {
|
|
39
|
-
if (scheduling.isInputPending()) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return currentTime >= maxDeadline;
|
|
43
|
-
} else {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
} else {
|
|
48
|
-
shouldYieldToHost = () => performance.now() >= deadline;
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadBoundary, getOwner, onCleanup, isDisposed, runWithOwner, createEffect as createEffect$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, createErrorBoundary as createErrorBoundary$1, markSnapshotScope, flush, clearSnapshots, peekNextChildId, untrack, mapArray, repeat } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $TRACK, NotReadyError, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
|
|
3
|
+
|
|
4
|
+
const $DEVCOMP = Symbol(0);
|
|
5
|
+
function createContext(defaultValue, options) {
|
|
6
|
+
const id = Symbol(options && options.name || "");
|
|
7
|
+
function provider(props) {
|
|
8
|
+
return createRoot(() => {
|
|
9
|
+
setContext(provider, props.value);
|
|
10
|
+
return children(() => props.children);
|
|
11
|
+
});
|
|
49
12
|
}
|
|
13
|
+
provider.id = id;
|
|
14
|
+
provider.defaultValue = defaultValue;
|
|
15
|
+
return provider;
|
|
50
16
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
let m = 0;
|
|
54
|
-
let n = taskQueue.length - 1;
|
|
55
|
-
while (m <= n) {
|
|
56
|
-
const k = n + m >> 1;
|
|
57
|
-
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
58
|
-
if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
|
|
59
|
-
}
|
|
60
|
-
return m;
|
|
61
|
-
}
|
|
62
|
-
taskQueue.splice(findIndex(), 0, task);
|
|
17
|
+
function useContext(context) {
|
|
18
|
+
return getContext(context);
|
|
63
19
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
20
|
+
function children(fn) {
|
|
21
|
+
const c = createMemo$1(fn, undefined, {
|
|
22
|
+
lazy: true
|
|
23
|
+
});
|
|
24
|
+
const memo = createMemo$1(() => flatten(c()), undefined, {
|
|
25
|
+
lazy: true
|
|
26
|
+
});
|
|
27
|
+
memo.toArray = () => {
|
|
28
|
+
const v = memo();
|
|
29
|
+
return Array.isArray(v) ? v : v != null ? [v] : [];
|
|
74
30
|
};
|
|
75
|
-
|
|
76
|
-
if (!isCallbackScheduled && !isPerformingWork) {
|
|
77
|
-
isCallbackScheduled = true;
|
|
78
|
-
scheduledCallback = flushWork;
|
|
79
|
-
scheduleCallback();
|
|
80
|
-
}
|
|
81
|
-
return newTask;
|
|
82
|
-
}
|
|
83
|
-
function cancelCallback(task) {
|
|
84
|
-
task.fn = null;
|
|
85
|
-
}
|
|
86
|
-
function flushWork(initialTime) {
|
|
87
|
-
isCallbackScheduled = false;
|
|
88
|
-
isPerformingWork = true;
|
|
89
|
-
try {
|
|
90
|
-
return workLoop(initialTime);
|
|
91
|
-
} finally {
|
|
92
|
-
currentTask = null;
|
|
93
|
-
isPerformingWork = false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function workLoop(initialTime) {
|
|
97
|
-
let currentTime = initialTime;
|
|
98
|
-
currentTask = taskQueue[0] || null;
|
|
99
|
-
while (currentTask !== null) {
|
|
100
|
-
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
const callback = currentTask.fn;
|
|
104
|
-
if (callback !== null) {
|
|
105
|
-
currentTask.fn = null;
|
|
106
|
-
const didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
107
|
-
callback(didUserCallbackTimeout);
|
|
108
|
-
currentTime = performance.now();
|
|
109
|
-
if (currentTask === taskQueue[0]) {
|
|
110
|
-
taskQueue.shift();
|
|
111
|
-
}
|
|
112
|
-
} else taskQueue.shift();
|
|
113
|
-
currentTask = taskQueue[0] || null;
|
|
114
|
-
}
|
|
115
|
-
return currentTask !== null;
|
|
31
|
+
return memo;
|
|
116
32
|
}
|
|
117
33
|
|
|
118
34
|
const sharedConfig = {
|
|
119
|
-
|
|
35
|
+
hydrating: false,
|
|
120
36
|
registry: undefined,
|
|
121
|
-
effects: undefined,
|
|
122
37
|
done: false,
|
|
123
|
-
getContextId() {
|
|
124
|
-
return getContextId(this.context.count);
|
|
125
|
-
},
|
|
126
38
|
getNextContextId() {
|
|
127
|
-
|
|
39
|
+
const o = getOwner();
|
|
40
|
+
if (!o) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
41
|
+
return getNextChildId(o);
|
|
128
42
|
}
|
|
129
43
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
155
|
-
let ERROR = null;
|
|
156
|
-
let runEffects = runQueue;
|
|
157
|
-
const STALE = 1;
|
|
158
|
-
const PENDING = 2;
|
|
159
|
-
const UNOWNED = {
|
|
160
|
-
owned: null,
|
|
161
|
-
cleanups: null,
|
|
162
|
-
context: null,
|
|
163
|
-
owner: null
|
|
164
|
-
};
|
|
165
|
-
const NO_INIT = {};
|
|
166
|
-
var Owner = null;
|
|
167
|
-
let Transition = null;
|
|
168
|
-
let Scheduler = null;
|
|
169
|
-
let ExternalSourceConfig = null;
|
|
170
|
-
let Listener = null;
|
|
171
|
-
let Updates = null;
|
|
172
|
-
let Effects = null;
|
|
173
|
-
let ExecCount = 0;
|
|
174
|
-
function createRoot(fn, detachedOwner) {
|
|
175
|
-
const listener = Listener,
|
|
176
|
-
owner = Owner,
|
|
177
|
-
unowned = fn.length === 0,
|
|
178
|
-
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
179
|
-
root = unowned ? UNOWNED : {
|
|
180
|
-
owned: null,
|
|
181
|
-
cleanups: null,
|
|
182
|
-
context: current ? current.context : null,
|
|
183
|
-
owner: current
|
|
184
|
-
},
|
|
185
|
-
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanupRoot(root)));
|
|
186
|
-
Owner = root;
|
|
187
|
-
Listener = null;
|
|
188
|
-
try {
|
|
189
|
-
return runUpdates(updateFn, true);
|
|
190
|
-
} finally {
|
|
191
|
-
Listener = listener;
|
|
192
|
-
Owner = owner;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function createSignal(value, options) {
|
|
196
|
-
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
197
|
-
const s = {
|
|
198
|
-
value,
|
|
199
|
-
observers: null,
|
|
200
|
-
observersTail: null,
|
|
201
|
-
comparator: options.equals || undefined
|
|
202
|
-
};
|
|
203
|
-
const setter = value => {
|
|
204
|
-
if (typeof value === "function") {
|
|
205
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
206
|
-
}
|
|
207
|
-
return writeSignal(s, value);
|
|
208
|
-
};
|
|
209
|
-
return [readSignal.bind(s), setter];
|
|
210
|
-
}
|
|
211
|
-
function createComputed(fn, value, options) {
|
|
212
|
-
const c = createComputation(fn, value, true, STALE);
|
|
213
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
214
|
-
}
|
|
215
|
-
function createRenderEffect(fn, value, options) {
|
|
216
|
-
const c = createComputation(fn, value, false, STALE);
|
|
217
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
218
|
-
}
|
|
219
|
-
function createEffect(fn, value, options) {
|
|
220
|
-
runEffects = runUserEffects;
|
|
221
|
-
const c = createComputation(fn, value, false, STALE),
|
|
222
|
-
s = SuspenseContext && useContext(SuspenseContext);
|
|
223
|
-
if (s) c.suspense = s;
|
|
224
|
-
if (!options || !options.render) c.user = true;
|
|
225
|
-
Effects ? Effects.push(c) : updateComputation(c);
|
|
226
|
-
}
|
|
227
|
-
function createReaction(onInvalidate, options) {
|
|
228
|
-
let fn;
|
|
229
|
-
const c = createComputation(() => {
|
|
230
|
-
fn ? fn() : untrack(onInvalidate);
|
|
231
|
-
fn = undefined;
|
|
232
|
-
}, undefined, false, 0),
|
|
233
|
-
s = SuspenseContext && useContext(SuspenseContext);
|
|
234
|
-
if (s) c.suspense = s;
|
|
235
|
-
c.user = true;
|
|
236
|
-
return tracking => {
|
|
237
|
-
fn = tracking;
|
|
238
|
-
updateComputation(c);
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function createMemo(fn, value, options) {
|
|
242
|
-
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
243
|
-
const c = createComputation(fn, value, true, 0);
|
|
244
|
-
c.observers = null;
|
|
245
|
-
c.observersTail = null;
|
|
246
|
-
c.comparator = options.equals || undefined;
|
|
247
|
-
if (Scheduler && Transition && Transition.running) {
|
|
248
|
-
c.tState = STALE;
|
|
249
|
-
Updates.push(c);
|
|
250
|
-
} else updateComputation(c);
|
|
251
|
-
return readSignal.bind(c);
|
|
252
|
-
}
|
|
253
|
-
function isPromise(v) {
|
|
254
|
-
return v && typeof v === "object" && "then" in v;
|
|
255
|
-
}
|
|
256
|
-
function createResource(pSource, pFetcher, pOptions) {
|
|
257
|
-
let source;
|
|
258
|
-
let fetcher;
|
|
259
|
-
let options;
|
|
260
|
-
if (typeof pFetcher === "function") {
|
|
261
|
-
source = pSource;
|
|
262
|
-
fetcher = pFetcher;
|
|
263
|
-
options = pOptions || {};
|
|
264
|
-
} else {
|
|
265
|
-
source = true;
|
|
266
|
-
fetcher = pSource;
|
|
267
|
-
options = pFetcher || {};
|
|
268
|
-
}
|
|
269
|
-
let pr = null,
|
|
270
|
-
initP = NO_INIT,
|
|
271
|
-
id = null,
|
|
272
|
-
loadedUnderTransition = false,
|
|
273
|
-
scheduled = false,
|
|
274
|
-
resolved = "initialValue" in options,
|
|
275
|
-
dynamic = typeof source === "function" && createMemo(source);
|
|
276
|
-
const contexts = new Set(),
|
|
277
|
-
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
278
|
-
[error, setError] = createSignal(undefined),
|
|
279
|
-
[track, trigger] = createSignal(undefined, {
|
|
280
|
-
equals: false
|
|
281
|
-
}),
|
|
282
|
-
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
283
|
-
if (sharedConfig.context) {
|
|
284
|
-
id = sharedConfig.getNextContextId();
|
|
285
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
286
|
-
}
|
|
287
|
-
function loadEnd(p, v, error, key) {
|
|
288
|
-
if (pr === p) {
|
|
289
|
-
pr = null;
|
|
290
|
-
key !== undefined && (resolved = true);
|
|
291
|
-
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
292
|
-
value: v
|
|
293
|
-
}));
|
|
294
|
-
initP = NO_INIT;
|
|
295
|
-
if (Transition && p && loadedUnderTransition) {
|
|
296
|
-
Transition.promises.delete(p);
|
|
297
|
-
loadedUnderTransition = false;
|
|
298
|
-
runUpdates(() => {
|
|
299
|
-
Transition.running = true;
|
|
300
|
-
completeLoad(v, error);
|
|
301
|
-
}, false);
|
|
302
|
-
} else completeLoad(v, error);
|
|
303
|
-
}
|
|
304
|
-
return v;
|
|
305
|
-
}
|
|
306
|
-
function completeLoad(v, err) {
|
|
307
|
-
runUpdates(() => {
|
|
308
|
-
if (err === undefined) setValue(() => v);
|
|
309
|
-
setState(err !== undefined ? "errored" : resolved ? "ready" : "unresolved");
|
|
310
|
-
setError(err);
|
|
311
|
-
for (const c of contexts.keys()) c.decrement();
|
|
312
|
-
contexts.clear();
|
|
313
|
-
}, false);
|
|
314
|
-
}
|
|
315
|
-
function read() {
|
|
316
|
-
const c = SuspenseContext && useContext(SuspenseContext),
|
|
317
|
-
v = value(),
|
|
318
|
-
err = error();
|
|
319
|
-
if (err !== undefined && !pr) throw err;
|
|
320
|
-
if (Listener && !Listener.user && c) {
|
|
321
|
-
createComputed(() => {
|
|
322
|
-
track();
|
|
323
|
-
if (pr) {
|
|
324
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
325
|
-
c.increment();
|
|
326
|
-
contexts.add(c);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
return v;
|
|
332
|
-
}
|
|
333
|
-
function load(refetching = true) {
|
|
334
|
-
if (refetching !== false && scheduled) return;
|
|
335
|
-
scheduled = false;
|
|
336
|
-
const lookup = dynamic ? dynamic() : source;
|
|
337
|
-
loadedUnderTransition = Transition && Transition.running;
|
|
338
|
-
if (lookup == null || lookup === false) {
|
|
339
|
-
loadEnd(pr, untrack(value));
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
if (Transition && pr) Transition.promises.delete(pr);
|
|
343
|
-
let error;
|
|
344
|
-
const p = initP !== NO_INIT ? initP : untrack(() => {
|
|
345
|
-
try {
|
|
346
|
-
return fetcher(lookup, {
|
|
347
|
-
value: value(),
|
|
348
|
-
refetching
|
|
349
|
-
});
|
|
350
|
-
} catch (fetcherError) {
|
|
351
|
-
error = fetcherError;
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
if (error !== undefined) {
|
|
355
|
-
loadEnd(pr, undefined, castError(error), lookup);
|
|
356
|
-
return;
|
|
357
|
-
} else if (!isPromise(p)) {
|
|
358
|
-
loadEnd(pr, p, undefined, lookup);
|
|
359
|
-
return p;
|
|
360
|
-
}
|
|
361
|
-
pr = p;
|
|
362
|
-
if ("v" in p) {
|
|
363
|
-
if (p.s === 1) loadEnd(pr, p.v, undefined, lookup);else loadEnd(pr, undefined, castError(p.v), lookup);
|
|
364
|
-
return p;
|
|
365
|
-
}
|
|
366
|
-
scheduled = true;
|
|
367
|
-
queueMicrotask(() => scheduled = false);
|
|
368
|
-
runUpdates(() => {
|
|
369
|
-
setState(resolved ? "refreshing" : "pending");
|
|
370
|
-
trigger();
|
|
371
|
-
}, false);
|
|
372
|
-
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
373
|
-
}
|
|
374
|
-
Object.defineProperties(read, {
|
|
375
|
-
state: {
|
|
376
|
-
get: () => state()
|
|
377
|
-
},
|
|
378
|
-
error: {
|
|
379
|
-
get: () => error()
|
|
380
|
-
},
|
|
381
|
-
loading: {
|
|
382
|
-
get() {
|
|
383
|
-
const s = state();
|
|
384
|
-
return s === "pending" || s === "refreshing";
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
latest: {
|
|
388
|
-
get() {
|
|
389
|
-
if (!resolved) return read();
|
|
390
|
-
const err = error();
|
|
391
|
-
if (err && !pr) throw err;
|
|
392
|
-
return value();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
let owner = Owner;
|
|
397
|
-
if (dynamic) createComputed(() => (owner = Owner, load(false)));else load(false);
|
|
398
|
-
return [read, {
|
|
399
|
-
refetch: info => runWithOwner(owner, () => load(info)),
|
|
400
|
-
mutate: setValue
|
|
401
|
-
}];
|
|
402
|
-
}
|
|
403
|
-
function createDeferred(source, options) {
|
|
404
|
-
let t,
|
|
405
|
-
timeout = options ? options.timeoutMs : undefined;
|
|
406
|
-
const node = createComputation(() => {
|
|
407
|
-
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
408
|
-
timeout
|
|
409
|
-
} : undefined);
|
|
410
|
-
return source();
|
|
411
|
-
}, undefined, true);
|
|
412
|
-
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
413
|
-
updateComputation(node);
|
|
414
|
-
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
415
|
-
return deferred;
|
|
416
|
-
}
|
|
417
|
-
function createSelector(source, fn = equalFn, options) {
|
|
418
|
-
const subs = new Map();
|
|
419
|
-
const node = createComputation(p => {
|
|
420
|
-
const v = source();
|
|
421
|
-
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
422
|
-
for (const c of val.values()) {
|
|
423
|
-
c.state = STALE;
|
|
424
|
-
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return v;
|
|
428
|
-
}, undefined, true, STALE);
|
|
429
|
-
updateComputation(node);
|
|
430
|
-
return key => {
|
|
431
|
-
const listener = Listener;
|
|
432
|
-
if (listener) {
|
|
433
|
-
let l;
|
|
434
|
-
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
435
|
-
onCleanup(() => {
|
|
436
|
-
l.delete(listener);
|
|
437
|
-
!l.size && subs.delete(key);
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
function batch(fn) {
|
|
444
|
-
return runUpdates(fn, false);
|
|
445
|
-
}
|
|
446
|
-
function untrack(fn) {
|
|
447
|
-
if (!ExternalSourceConfig && Listener === null) return fn();
|
|
448
|
-
const listener = Listener;
|
|
449
|
-
Listener = null;
|
|
450
|
-
try {
|
|
451
|
-
if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
|
|
452
|
-
return fn();
|
|
453
|
-
} finally {
|
|
454
|
-
Listener = listener;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function on(deps, fn, options) {
|
|
458
|
-
const isArray = Array.isArray(deps);
|
|
459
|
-
let prevInput;
|
|
460
|
-
let defer = options && options.defer;
|
|
461
|
-
return prevValue => {
|
|
462
|
-
let input;
|
|
463
|
-
if (isArray) {
|
|
464
|
-
input = Array(deps.length);
|
|
465
|
-
for (let i = 0; i < deps.length; i++) input[i] = deps[i]();
|
|
466
|
-
} else input = deps();
|
|
467
|
-
if (defer) {
|
|
468
|
-
defer = false;
|
|
469
|
-
return prevValue;
|
|
470
|
-
}
|
|
471
|
-
const result = untrack(() => fn(input, prevInput, prevValue));
|
|
472
|
-
prevInput = input;
|
|
473
|
-
return result;
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
function onMount(fn) {
|
|
477
|
-
createEffect(() => untrack(fn));
|
|
478
|
-
}
|
|
479
|
-
function onCleanup(fn) {
|
|
480
|
-
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
481
|
-
return fn;
|
|
482
|
-
}
|
|
483
|
-
function catchError(fn, handler) {
|
|
484
|
-
ERROR || (ERROR = Symbol("error"));
|
|
485
|
-
Owner = createComputation(undefined, undefined, true);
|
|
486
|
-
Owner.context = {
|
|
487
|
-
...Owner.context,
|
|
488
|
-
[ERROR]: [handler]
|
|
489
|
-
};
|
|
490
|
-
if (Transition && Transition.running) Transition.sources.add(Owner);
|
|
491
|
-
try {
|
|
492
|
-
return fn();
|
|
493
|
-
} catch (err) {
|
|
494
|
-
handleError(err);
|
|
495
|
-
} finally {
|
|
496
|
-
Owner = Owner.owner;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function getListener() {
|
|
500
|
-
return Listener;
|
|
501
|
-
}
|
|
502
|
-
function getOwner() {
|
|
503
|
-
return Owner;
|
|
504
|
-
}
|
|
505
|
-
function runWithOwner(o, fn) {
|
|
506
|
-
const prev = Owner;
|
|
507
|
-
const prevListener = Listener;
|
|
508
|
-
Owner = o;
|
|
509
|
-
Listener = null;
|
|
510
|
-
try {
|
|
511
|
-
return runUpdates(fn, true);
|
|
512
|
-
} catch (err) {
|
|
513
|
-
handleError(err);
|
|
514
|
-
} finally {
|
|
515
|
-
Owner = prev;
|
|
516
|
-
Listener = prevListener;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
function enableScheduling(scheduler = requestCallback) {
|
|
520
|
-
Scheduler = scheduler;
|
|
521
|
-
}
|
|
522
|
-
function startTransition(fn) {
|
|
523
|
-
if (Transition && Transition.running) {
|
|
524
|
-
fn();
|
|
525
|
-
return Transition.done;
|
|
526
|
-
}
|
|
527
|
-
const l = Listener;
|
|
528
|
-
const o = Owner;
|
|
529
|
-
return Promise.resolve().then(() => {
|
|
530
|
-
Listener = l;
|
|
531
|
-
Owner = o;
|
|
532
|
-
let t;
|
|
533
|
-
if (Scheduler || SuspenseContext) {
|
|
534
|
-
t = Transition || (Transition = {
|
|
535
|
-
sources: new Set(),
|
|
536
|
-
effects: [],
|
|
537
|
-
promises: new Set(),
|
|
538
|
-
disposed: new Set(),
|
|
539
|
-
queue: new Set(),
|
|
540
|
-
running: true
|
|
541
|
-
});
|
|
542
|
-
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
543
|
-
t.running = true;
|
|
544
|
-
}
|
|
545
|
-
runUpdates(fn, false);
|
|
546
|
-
Listener = Owner = null;
|
|
547
|
-
return t ? t.done : undefined;
|
|
44
|
+
let _hydrationEndCallbacks = null;
|
|
45
|
+
let _pendingBoundaries = 0;
|
|
46
|
+
let _hydrationDone = false;
|
|
47
|
+
let _snapshotRootOwner = null;
|
|
48
|
+
function markTopLevelSnapshotScope() {
|
|
49
|
+
if (_snapshotRootOwner) return;
|
|
50
|
+
let owner = getOwner();
|
|
51
|
+
if (!owner) return;
|
|
52
|
+
while (owner._parent) owner = owner._parent;
|
|
53
|
+
markSnapshotScope(owner);
|
|
54
|
+
_snapshotRootOwner = owner;
|
|
55
|
+
}
|
|
56
|
+
function drainHydrationCallbacks() {
|
|
57
|
+
if (_hydrationDone) return;
|
|
58
|
+
_hydrationDone = true;
|
|
59
|
+
_doneValue = true;
|
|
60
|
+
clearSnapshots();
|
|
61
|
+
setSnapshotCapture(false);
|
|
62
|
+
flush();
|
|
63
|
+
const cbs = _hydrationEndCallbacks;
|
|
64
|
+
_hydrationEndCallbacks = null;
|
|
65
|
+
if (cbs) for (const cb of cbs) cb();
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
if (globalThis._$HY) globalThis._$HY.done = true;
|
|
548
68
|
});
|
|
549
69
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return [transPending, startTransition];
|
|
553
|
-
}
|
|
554
|
-
function resumeEffects(e) {
|
|
555
|
-
Effects.push.apply(Effects, e);
|
|
556
|
-
e.length = 0;
|
|
557
|
-
}
|
|
558
|
-
function createContext(defaultValue, options) {
|
|
559
|
-
const id = Symbol("context");
|
|
560
|
-
return {
|
|
561
|
-
id,
|
|
562
|
-
Provider: createProvider(id),
|
|
563
|
-
defaultValue
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function useContext(context) {
|
|
567
|
-
let value;
|
|
568
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
|
|
569
|
-
}
|
|
570
|
-
function children(fn) {
|
|
571
|
-
const children = createMemo(fn);
|
|
572
|
-
const memo = createMemo(() => resolveChildren(children()));
|
|
573
|
-
memo.toArray = () => {
|
|
574
|
-
const c = memo();
|
|
575
|
-
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
576
|
-
};
|
|
577
|
-
return memo;
|
|
578
|
-
}
|
|
579
|
-
let SuspenseContext;
|
|
580
|
-
function getSuspenseContext() {
|
|
581
|
-
return SuspenseContext || (SuspenseContext = createContext());
|
|
582
|
-
}
|
|
583
|
-
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
584
|
-
if (ExternalSourceConfig) {
|
|
585
|
-
const {
|
|
586
|
-
factory: oldFactory,
|
|
587
|
-
untrack: oldUntrack
|
|
588
|
-
} = ExternalSourceConfig;
|
|
589
|
-
ExternalSourceConfig = {
|
|
590
|
-
factory: (fn, trigger) => {
|
|
591
|
-
const oldSource = oldFactory(fn, trigger);
|
|
592
|
-
const source = factory(x => oldSource.track(x), trigger);
|
|
593
|
-
return {
|
|
594
|
-
track: x => source.track(x),
|
|
595
|
-
dispose() {
|
|
596
|
-
source.dispose();
|
|
597
|
-
oldSource.dispose();
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
},
|
|
601
|
-
untrack: fn => oldUntrack(() => untrack(fn))
|
|
602
|
-
};
|
|
603
|
-
} else {
|
|
604
|
-
ExternalSourceConfig = {
|
|
605
|
-
factory,
|
|
606
|
-
untrack
|
|
607
|
-
};
|
|
608
|
-
}
|
|
70
|
+
function checkHydrationComplete() {
|
|
71
|
+
if (_pendingBoundaries === 0) drainHydrationCallbacks();
|
|
609
72
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
73
|
+
let _hydratingValue = false;
|
|
74
|
+
let _doneValue = false;
|
|
75
|
+
let _createMemo;
|
|
76
|
+
let _createSignal;
|
|
77
|
+
let _createErrorBoundary;
|
|
78
|
+
let _createOptimistic;
|
|
79
|
+
let _createProjection;
|
|
80
|
+
let _createStore;
|
|
81
|
+
let _createOptimisticStore;
|
|
82
|
+
let _createRenderEffect;
|
|
83
|
+
let _createEffect;
|
|
84
|
+
class MockPromise {
|
|
85
|
+
static all() {
|
|
86
|
+
return new MockPromise();
|
|
619
87
|
}
|
|
620
|
-
|
|
621
|
-
|
|
88
|
+
static allSettled() {
|
|
89
|
+
return new MockPromise();
|
|
622
90
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
function link(source, observer) {
|
|
627
|
-
const prevSource = observer.sourcesTail;
|
|
628
|
-
if (prevSource !== null && prevSource.source === source) {
|
|
629
|
-
return;
|
|
91
|
+
static any() {
|
|
92
|
+
return new MockPromise();
|
|
630
93
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (nextSource !== null && nextSource.source === source) {
|
|
634
|
-
nextSource.version = time;
|
|
635
|
-
observer.sourcesTail = nextSource;
|
|
636
|
-
return;
|
|
94
|
+
static race() {
|
|
95
|
+
return new MockPromise();
|
|
637
96
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
return;
|
|
97
|
+
static reject() {
|
|
98
|
+
return new MockPromise();
|
|
641
99
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
observer: observer,
|
|
645
|
-
nextSource: nextSource,
|
|
646
|
-
prevObserver: prevObserver,
|
|
647
|
-
nextObserver: null,
|
|
648
|
-
version: time
|
|
649
|
-
};
|
|
650
|
-
if (prevSource !== null) {
|
|
651
|
-
prevSource.nextSource = newLink;
|
|
652
|
-
} else {
|
|
653
|
-
observer.sources = newLink;
|
|
100
|
+
static resolve() {
|
|
101
|
+
return new MockPromise();
|
|
654
102
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
} else {
|
|
658
|
-
source.observers = newLink;
|
|
103
|
+
catch() {
|
|
104
|
+
return new MockPromise();
|
|
659
105
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
663
|
-
if (!node.comparator || !node.comparator(current, value)) {
|
|
664
|
-
if (Transition) {
|
|
665
|
-
const TransitionRunning = Transition.running;
|
|
666
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
667
|
-
Transition.sources.add(node);
|
|
668
|
-
node.tValue = value;
|
|
669
|
-
}
|
|
670
|
-
if (!TransitionRunning) node.value = value;
|
|
671
|
-
} else node.value = value;
|
|
672
|
-
if (node.observers && node.observers) {
|
|
673
|
-
runUpdates(() => {
|
|
674
|
-
for (let link = node.observers; link !== null; link = link.nextObserver) {
|
|
675
|
-
const o = link.observer;
|
|
676
|
-
if (link.version < o.relinkTime) continue;
|
|
677
|
-
const TransitionRunning = Transition && Transition.running;
|
|
678
|
-
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
679
|
-
if (TransitionRunning ? !o.tState : !o.state) {
|
|
680
|
-
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
681
|
-
if (o.observers) markDownstream(o);
|
|
682
|
-
}
|
|
683
|
-
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
684
|
-
}
|
|
685
|
-
if (Updates.length > 10e5) {
|
|
686
|
-
Updates = [];
|
|
687
|
-
if (IS_DEV) ;
|
|
688
|
-
throw new Error();
|
|
689
|
-
}
|
|
690
|
-
}, false);
|
|
691
|
-
}
|
|
106
|
+
then() {
|
|
107
|
+
return new MockPromise();
|
|
692
108
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
function updateComputation(node) {
|
|
696
|
-
if (!node.fn) return;
|
|
697
|
-
node.sourcesTail = null;
|
|
698
|
-
node.relinkTime = ExecCount;
|
|
699
|
-
cleanupRoot(node);
|
|
700
|
-
const time = ExecCount;
|
|
701
|
-
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
702
|
-
afterComputation(node);
|
|
703
|
-
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
704
|
-
queueMicrotask(() => {
|
|
705
|
-
runUpdates(() => {
|
|
706
|
-
Transition && (Transition.running = true);
|
|
707
|
-
Listener = Owner = node;
|
|
708
|
-
runComputation(node, node.tValue, time);
|
|
709
|
-
Listener = Owner = null;
|
|
710
|
-
}, false);
|
|
711
|
-
});
|
|
109
|
+
finally() {
|
|
110
|
+
return new MockPromise();
|
|
712
111
|
}
|
|
713
112
|
}
|
|
714
|
-
function
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
listener = Listener;
|
|
718
|
-
Listener = Owner = node;
|
|
113
|
+
function subFetch(fn, prev) {
|
|
114
|
+
const ogFetch = fetch;
|
|
115
|
+
const ogPromise = Promise;
|
|
719
116
|
try {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
node.tOwned && node.tOwned.forEach(destroyNode);
|
|
726
|
-
node.tOwned = undefined;
|
|
727
|
-
} else {
|
|
728
|
-
node.state = STALE;
|
|
729
|
-
node.owned && node.owned.forEach(destroyNode);
|
|
730
|
-
node.owned = null;
|
|
731
|
-
}
|
|
117
|
+
window.fetch = () => new MockPromise();
|
|
118
|
+
Promise = MockPromise;
|
|
119
|
+
const result = fn(prev);
|
|
120
|
+
if (result && typeof result[Symbol.asyncIterator] === "function") {
|
|
121
|
+
result[Symbol.asyncIterator]().next();
|
|
732
122
|
}
|
|
733
|
-
|
|
734
|
-
return handleError(err);
|
|
123
|
+
return result;
|
|
735
124
|
} finally {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
sourcesTail: null,
|
|
757
|
-
cleanups: null,
|
|
758
|
-
value: init,
|
|
759
|
-
owner: Owner,
|
|
760
|
-
relinkTime: 0,
|
|
761
|
-
context: Owner ? Owner.context : null,
|
|
762
|
-
pure
|
|
763
|
-
};
|
|
764
|
-
if (Transition && Transition.running) {
|
|
765
|
-
c.state = 0;
|
|
766
|
-
c.tState = state;
|
|
767
|
-
}
|
|
768
|
-
if (Owner === null) ;else if (Owner !== UNOWNED) {
|
|
769
|
-
if (Transition && Transition.running && Owner.pure) {
|
|
770
|
-
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
125
|
+
window.fetch = ogFetch;
|
|
126
|
+
Promise = ogPromise;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function consumeFirstSync(ai) {
|
|
130
|
+
const iter = ai[Symbol.asyncIterator]();
|
|
131
|
+
const r = iter.next();
|
|
132
|
+
const value = !(r instanceof Promise) && !r.done ? r.value : undefined;
|
|
133
|
+
return [value, iter];
|
|
134
|
+
}
|
|
135
|
+
function applyPatches(target, patches) {
|
|
136
|
+
for (const patch of patches) {
|
|
137
|
+
const path = patch[0];
|
|
138
|
+
let current = target;
|
|
139
|
+
for (let i = 0; i < path.length - 1; i++) current = current[path[i]];
|
|
140
|
+
const key = path[path.length - 1];
|
|
141
|
+
if (patch.length === 1) {
|
|
142
|
+
Array.isArray(current) ? current.splice(key, 1) : delete current[key];
|
|
143
|
+
} else if (patch.length === 3) {
|
|
144
|
+
current.splice(key, 0, patch[1]);
|
|
771
145
|
} else {
|
|
772
|
-
|
|
146
|
+
current[key] = patch[1];
|
|
773
147
|
}
|
|
774
148
|
}
|
|
775
|
-
if (ExternalSourceConfig && c.fn) {
|
|
776
|
-
const [track, trigger] = createSignal(undefined, {
|
|
777
|
-
equals: false
|
|
778
|
-
});
|
|
779
|
-
const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
|
|
780
|
-
onCleanup(() => ordinary.dispose());
|
|
781
|
-
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
782
|
-
const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
|
|
783
|
-
c.fn = x => {
|
|
784
|
-
track();
|
|
785
|
-
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
return c;
|
|
789
149
|
}
|
|
790
|
-
function
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
node = ancestors[i];
|
|
802
|
-
if (runningTransition) {
|
|
803
|
-
let top = node,
|
|
804
|
-
prev = ancestors[i + 1];
|
|
805
|
-
while ((top = top.owner) && top !== prev) {
|
|
806
|
-
if (Transition.disposed.has(top)) return;
|
|
150
|
+
function scheduleIteratorConsumption(iter, apply) {
|
|
151
|
+
const consume = () => {
|
|
152
|
+
while (true) {
|
|
153
|
+
const n = iter.next();
|
|
154
|
+
if (n instanceof Promise) {
|
|
155
|
+
n.then(r => {
|
|
156
|
+
if (r.done) return;
|
|
157
|
+
apply(r.value);
|
|
158
|
+
consume();
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
807
161
|
}
|
|
162
|
+
if (n.done) break;
|
|
163
|
+
apply(n.value);
|
|
808
164
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
if (
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
165
|
+
};
|
|
166
|
+
consume();
|
|
167
|
+
}
|
|
168
|
+
function isAsyncIterable(v) {
|
|
169
|
+
return v != null && typeof v[Symbol.asyncIterator] === "function";
|
|
170
|
+
}
|
|
171
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
172
|
+
const parent = getOwner();
|
|
173
|
+
const expectedId = peekNextChildId(parent);
|
|
174
|
+
if (!sharedConfig.has(expectedId)) return null;
|
|
175
|
+
const initP = sharedConfig.load(expectedId);
|
|
176
|
+
if (!isAsyncIterable(initP)) return null;
|
|
177
|
+
const [firstValue, iter] = consumeFirstSync(initP);
|
|
178
|
+
const [get, set] = createSignal$1(firstValue);
|
|
179
|
+
const result = coreFn(() => get(), firstValue, options);
|
|
180
|
+
scheduleIteratorConsumption(iter, v => {
|
|
181
|
+
set(() => v);
|
|
182
|
+
flush();
|
|
183
|
+
});
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
187
|
+
const parent = getOwner();
|
|
188
|
+
const expectedId = peekNextChildId(parent);
|
|
189
|
+
if (!sharedConfig.has(expectedId)) return null;
|
|
190
|
+
const initP = sharedConfig.load(expectedId);
|
|
191
|
+
if (!isAsyncIterable(initP)) return null;
|
|
192
|
+
const [firstState, iter] = consumeFirstSync(initP);
|
|
193
|
+
const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options);
|
|
194
|
+
scheduleIteratorConsumption(iter, patches => {
|
|
195
|
+
setStore(d => {
|
|
196
|
+
applyPatches(d, patches);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
return [store, setStore];
|
|
200
|
+
}
|
|
201
|
+
function hydratedCreateMemo(compute, value, options) {
|
|
202
|
+
if (!sharedConfig.hydrating) return createMemo$1(compute, value, options);
|
|
203
|
+
markTopLevelSnapshotScope();
|
|
204
|
+
const ssrSource = options?.ssrSource;
|
|
205
|
+
if (ssrSource === "client") {
|
|
206
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
207
|
+
const memo = createMemo$1(prev => {
|
|
208
|
+
if (!hydrated()) return prev ?? value;
|
|
209
|
+
return compute(prev);
|
|
210
|
+
}, value, options);
|
|
211
|
+
setHydrated(true);
|
|
212
|
+
return memo;
|
|
213
|
+
}
|
|
214
|
+
if (ssrSource === "initial") {
|
|
215
|
+
return createMemo$1(prev => {
|
|
216
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
217
|
+
subFetch(compute, prev);
|
|
218
|
+
return prev ?? value;
|
|
219
|
+
}, value, options);
|
|
220
|
+
}
|
|
221
|
+
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
|
|
222
|
+
if (aiResult !== null) return aiResult;
|
|
223
|
+
return createMemo$1(prev => {
|
|
224
|
+
const o = getOwner();
|
|
225
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
226
|
+
let initP;
|
|
227
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
228
|
+
const init = initP?.v ?? initP;
|
|
229
|
+
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
230
|
+
}, value, options);
|
|
231
|
+
}
|
|
232
|
+
function hydratedCreateSignal(fn, second, third) {
|
|
233
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
|
|
234
|
+
markTopLevelSnapshotScope();
|
|
235
|
+
const ssrSource = third?.ssrSource;
|
|
236
|
+
if (ssrSource === "client") {
|
|
237
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
238
|
+
const sig = createSignal$1(prev => {
|
|
239
|
+
if (!hydrated()) return prev ?? second;
|
|
240
|
+
return fn(prev);
|
|
241
|
+
}, second, third);
|
|
242
|
+
setHydrated(true);
|
|
243
|
+
return sig;
|
|
244
|
+
}
|
|
245
|
+
if (ssrSource === "initial") {
|
|
246
|
+
return createSignal$1(prev => {
|
|
247
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
248
|
+
subFetch(fn, prev);
|
|
249
|
+
return prev ?? second;
|
|
250
|
+
}, second, third);
|
|
251
|
+
}
|
|
252
|
+
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
|
|
253
|
+
if (aiResult !== null) return aiResult;
|
|
254
|
+
return createSignal$1(prev => {
|
|
255
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
256
|
+
const o = getOwner();
|
|
257
|
+
let initP;
|
|
258
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
259
|
+
const init = initP?.v ?? initP;
|
|
260
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
261
|
+
}, second, third);
|
|
262
|
+
}
|
|
263
|
+
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
264
|
+
if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
|
|
265
|
+
markTopLevelSnapshotScope();
|
|
266
|
+
const parent = getOwner();
|
|
267
|
+
const expectedId = peekNextChildId(parent);
|
|
268
|
+
if (sharedConfig.has(expectedId)) {
|
|
269
|
+
const err = sharedConfig.load(expectedId);
|
|
270
|
+
if (err !== undefined) {
|
|
271
|
+
let hydrated = true;
|
|
272
|
+
return createErrorBoundary$1(() => {
|
|
273
|
+
if (hydrated) {
|
|
274
|
+
hydrated = false;
|
|
275
|
+
throw err;
|
|
864
276
|
}
|
|
865
|
-
|
|
866
|
-
},
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
sharedConfig.effects || (sharedConfig.effects = []);
|
|
910
|
-
sharedConfig.effects.push(...queue.slice(0, userLength));
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
setHydrateContext();
|
|
914
|
-
}
|
|
915
|
-
if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
|
|
916
|
-
queue = [...sharedConfig.effects, ...queue];
|
|
917
|
-
userLength += sharedConfig.effects.length;
|
|
918
|
-
delete sharedConfig.effects;
|
|
919
|
-
}
|
|
920
|
-
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
921
|
-
}
|
|
922
|
-
function lookUpstream(node, ignore) {
|
|
923
|
-
const runningTransition = Transition && Transition.running;
|
|
924
|
-
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
925
|
-
for (let link = node.sources; link !== null; link = link.nextSource) {
|
|
926
|
-
const source = link.source;
|
|
927
|
-
if (source.sources) {
|
|
928
|
-
const state = runningTransition ? source.tState : source.state;
|
|
929
|
-
if (state === STALE) {
|
|
930
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
931
|
-
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
function markDownstream(node) {
|
|
936
|
-
const runningTransition = Transition && Transition.running;
|
|
937
|
-
for (let link = node.observers; link !== null; link = link.nextObserver) {
|
|
938
|
-
const o = link.observer;
|
|
939
|
-
if (link.version < o.relinkTime) continue;
|
|
940
|
-
if (runningTransition ? !o.tState : !o.state) {
|
|
941
|
-
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
942
|
-
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
943
|
-
o.observers && markDownstream(o);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
function cleanupRoot(node) {
|
|
948
|
-
let i;
|
|
949
|
-
if (node.tOwned) {
|
|
950
|
-
for (i = node.tOwned.length - 1; i >= 0; i--) destroyNode(node.tOwned[i]);
|
|
951
|
-
delete node.tOwned;
|
|
952
|
-
}
|
|
953
|
-
if (Transition && Transition.running && node.pure) {
|
|
954
|
-
reset(node, true);
|
|
955
|
-
} else if (node.owned) {
|
|
956
|
-
for (i = node.owned.length - 1; i >= 0; i--) destroyNode(node.owned[i]);
|
|
957
|
-
node.owned = null;
|
|
958
|
-
}
|
|
959
|
-
if (node.cleanups) {
|
|
960
|
-
for (let i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
961
|
-
node.cleanups = null;
|
|
962
|
-
}
|
|
963
|
-
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
964
|
-
}
|
|
965
|
-
function afterComputation(node) {
|
|
966
|
-
const sourcesTail = node.sourcesTail;
|
|
967
|
-
let toRemove = sourcesTail !== null ? sourcesTail.nextSource : node.sources;
|
|
968
|
-
if (toRemove !== null) {
|
|
969
|
-
do {
|
|
970
|
-
toRemove = unlinkFromObservers(toRemove);
|
|
971
|
-
} while (toRemove !== null);
|
|
972
|
-
if (sourcesTail !== null) {
|
|
973
|
-
sourcesTail.nextSource = null;
|
|
974
|
-
} else {
|
|
975
|
-
node.sources = null;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
function unlinkFromObservers(link) {
|
|
980
|
-
const source = link.source;
|
|
981
|
-
const nextSource = link.nextSource;
|
|
982
|
-
const nextObserver = link.nextObserver;
|
|
983
|
-
const prevObserver = link.prevObserver;
|
|
984
|
-
if (nextObserver !== null) {
|
|
985
|
-
nextObserver.prevObserver = prevObserver;
|
|
986
|
-
} else {
|
|
987
|
-
source.observersTail = prevObserver;
|
|
988
|
-
}
|
|
989
|
-
if (prevObserver !== null) {
|
|
990
|
-
prevObserver.nextObserver = nextObserver;
|
|
991
|
-
} else {
|
|
992
|
-
source.observers = nextObserver;
|
|
993
|
-
}
|
|
994
|
-
return nextSource;
|
|
995
|
-
}
|
|
996
|
-
function destroyNode(node) {
|
|
997
|
-
let link = node.sources;
|
|
998
|
-
while (link) {
|
|
999
|
-
link = unlinkFromObservers(link);
|
|
277
|
+
return fn();
|
|
278
|
+
}, fallback);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return createErrorBoundary$1(fn, fallback);
|
|
282
|
+
}
|
|
283
|
+
function hydratedCreateOptimistic(fn, second, third) {
|
|
284
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second, third);
|
|
285
|
+
markTopLevelSnapshotScope();
|
|
286
|
+
const ssrSource = third?.ssrSource;
|
|
287
|
+
if (ssrSource === "client") {
|
|
288
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
289
|
+
const sig = createOptimistic$1(prev => {
|
|
290
|
+
if (!hydrated()) return prev ?? second;
|
|
291
|
+
return fn(prev);
|
|
292
|
+
}, second, third);
|
|
293
|
+
setHydrated(true);
|
|
294
|
+
return sig;
|
|
295
|
+
}
|
|
296
|
+
if (ssrSource === "initial") {
|
|
297
|
+
return createOptimistic$1(prev => {
|
|
298
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
299
|
+
subFetch(fn, prev);
|
|
300
|
+
return prev ?? second;
|
|
301
|
+
}, second, third);
|
|
302
|
+
}
|
|
303
|
+
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
|
|
304
|
+
if (aiResult !== null) return aiResult;
|
|
305
|
+
return createOptimistic$1(prev => {
|
|
306
|
+
const o = getOwner();
|
|
307
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
308
|
+
let initP;
|
|
309
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
310
|
+
const init = initP?.v ?? initP;
|
|
311
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
312
|
+
}, second, third);
|
|
313
|
+
}
|
|
314
|
+
function wrapStoreFn(fn, ssrSource) {
|
|
315
|
+
if (ssrSource === "initial") {
|
|
316
|
+
return draft => {
|
|
317
|
+
if (!sharedConfig.hydrating) return fn(draft);
|
|
318
|
+
subFetch(fn, draft);
|
|
319
|
+
return undefined;
|
|
320
|
+
};
|
|
1000
321
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
322
|
+
return draft => {
|
|
323
|
+
const o = getOwner();
|
|
324
|
+
if (!sharedConfig.hydrating) return fn(draft);
|
|
325
|
+
let initP;
|
|
326
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
327
|
+
const init = initP?.v ?? initP;
|
|
328
|
+
return init != null ? (subFetch(fn, draft), init) : fn(draft);
|
|
329
|
+
};
|
|
1004
330
|
}
|
|
1005
|
-
function
|
|
1006
|
-
if (!
|
|
1007
|
-
|
|
1008
|
-
|
|
331
|
+
function hydratedCreateStore(first, second, third) {
|
|
332
|
+
if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
|
|
333
|
+
markTopLevelSnapshotScope();
|
|
334
|
+
const ssrSource = third?.ssrSource;
|
|
335
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
336
|
+
return createStore$1(second ?? {}, undefined, third);
|
|
337
|
+
}
|
|
338
|
+
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
|
|
339
|
+
if (aiResult !== null) return aiResult;
|
|
340
|
+
return createStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
341
|
+
}
|
|
342
|
+
function hydratedCreateOptimisticStore(first, second, third) {
|
|
343
|
+
if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
|
|
344
|
+
markTopLevelSnapshotScope();
|
|
345
|
+
const ssrSource = third?.ssrSource;
|
|
346
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
347
|
+
return createOptimisticStore$1(second ?? {}, undefined, third);
|
|
348
|
+
}
|
|
349
|
+
const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
|
|
350
|
+
if (aiResult !== null) return aiResult;
|
|
351
|
+
return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
352
|
+
}
|
|
353
|
+
function hydratedCreateProjection(fn, initialValue, options) {
|
|
354
|
+
if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
|
|
355
|
+
markTopLevelSnapshotScope();
|
|
356
|
+
const ssrSource = options?.ssrSource;
|
|
357
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
358
|
+
return createProjection$1(draft => draft, initialValue, options);
|
|
359
|
+
}
|
|
360
|
+
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options);
|
|
361
|
+
if (aiResult !== null) return aiResult[0];
|
|
362
|
+
return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
|
|
363
|
+
}
|
|
364
|
+
function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
365
|
+
if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
|
|
366
|
+
const ssrSource = options?.ssrSource;
|
|
367
|
+
if (ssrSource === "client") {
|
|
368
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
369
|
+
let active = false;
|
|
370
|
+
coreFn(prev => {
|
|
371
|
+
if (!hydrated()) return value;
|
|
372
|
+
active = true;
|
|
373
|
+
return compute(prev);
|
|
374
|
+
}, (next, prev) => {
|
|
375
|
+
if (!active) return;
|
|
376
|
+
return effectFn(next, prev);
|
|
377
|
+
}, value, options);
|
|
378
|
+
setHydrated(true);
|
|
379
|
+
return;
|
|
1009
380
|
}
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
381
|
+
if (ssrSource === "initial") {
|
|
382
|
+
coreFn(prev => {
|
|
383
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
384
|
+
subFetch(compute, prev);
|
|
385
|
+
return prev ?? value;
|
|
386
|
+
}, effectFn, value, options);
|
|
387
|
+
return;
|
|
1012
388
|
}
|
|
389
|
+
markTopLevelSnapshotScope();
|
|
390
|
+
coreFn(prev => {
|
|
391
|
+
const o = getOwner();
|
|
392
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
393
|
+
let initP;
|
|
394
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
395
|
+
const init = initP?.v ?? initP;
|
|
396
|
+
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
397
|
+
}, effectFn, value, options);
|
|
1013
398
|
}
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
return new Error(typeof err === "string" ? err : "Unknown error", {
|
|
1017
|
-
cause: err
|
|
1018
|
-
});
|
|
399
|
+
function hydratedCreateRenderEffect(compute, effectFn, value, options) {
|
|
400
|
+
return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options);
|
|
1019
401
|
}
|
|
1020
|
-
function
|
|
1021
|
-
|
|
1022
|
-
for (const f of fns) f(err);
|
|
1023
|
-
} catch (e) {
|
|
1024
|
-
handleError(e, owner && owner.owner || null);
|
|
1025
|
-
}
|
|
402
|
+
function hydratedCreateEffect(compute, effectFn, value, options) {
|
|
403
|
+
return hydratedEffect(createEffect$1, compute, effectFn, value, options);
|
|
1026
404
|
}
|
|
1027
|
-
function
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
405
|
+
function enableHydration() {
|
|
406
|
+
_createMemo = hydratedCreateMemo;
|
|
407
|
+
_createSignal = hydratedCreateSignal;
|
|
408
|
+
_createErrorBoundary = hydratedCreateErrorBoundary;
|
|
409
|
+
_createOptimistic = hydratedCreateOptimistic;
|
|
410
|
+
_createProjection = hydratedCreateProjection;
|
|
411
|
+
_createStore = hydratedCreateStore;
|
|
412
|
+
_createOptimisticStore = hydratedCreateOptimisticStore;
|
|
413
|
+
_createRenderEffect = hydratedCreateRenderEffect;
|
|
414
|
+
_createEffect = hydratedCreateEffect;
|
|
415
|
+
_hydratingValue = sharedConfig.hydrating;
|
|
416
|
+
_doneValue = sharedConfig.done;
|
|
417
|
+
Object.defineProperty(sharedConfig, "hydrating", {
|
|
418
|
+
get() {
|
|
419
|
+
return _hydratingValue;
|
|
1034
420
|
},
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
function createProvider(id, options) {
|
|
1052
|
-
return function provider(props) {
|
|
1053
|
-
let res;
|
|
1054
|
-
createRenderEffect(() => res = untrack(() => {
|
|
1055
|
-
Owner.context = {
|
|
1056
|
-
...Owner.context,
|
|
1057
|
-
[id]: props.value
|
|
1058
|
-
};
|
|
1059
|
-
return children(() => props.children);
|
|
1060
|
-
}), undefined);
|
|
1061
|
-
return res;
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
function onError(fn) {
|
|
1065
|
-
ERROR || (ERROR = Symbol("error"));
|
|
1066
|
-
if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1067
|
-
Owner.context = {
|
|
1068
|
-
...Owner.context,
|
|
1069
|
-
[ERROR]: [fn]
|
|
1070
|
-
};
|
|
1071
|
-
mutateContext(Owner, ERROR, [fn]);
|
|
1072
|
-
} else Owner.context[ERROR].push(fn);
|
|
1073
|
-
}
|
|
1074
|
-
function mutateContext(o, key, value) {
|
|
1075
|
-
if (o.owned) {
|
|
1076
|
-
for (let i = 0; i < o.owned.length; i++) {
|
|
1077
|
-
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
1078
|
-
if (!o.owned[i].context) {
|
|
1079
|
-
o.owned[i].context = o.context;
|
|
1080
|
-
mutateContext(o.owned[i], key, value);
|
|
1081
|
-
} else if (!o.owned[i].context[key]) {
|
|
1082
|
-
o.owned[i].context[key] = value;
|
|
1083
|
-
mutateContext(o.owned[i], key, value);
|
|
421
|
+
set(v) {
|
|
422
|
+
const was = _hydratingValue;
|
|
423
|
+
_hydratingValue = v;
|
|
424
|
+
if (!was && v) {
|
|
425
|
+
_hydrationDone = false;
|
|
426
|
+
_doneValue = false;
|
|
427
|
+
_pendingBoundaries = 0;
|
|
428
|
+
setSnapshotCapture(true);
|
|
429
|
+
_snapshotRootOwner = null;
|
|
430
|
+
} else if (was && !v) {
|
|
431
|
+
if (_snapshotRootOwner) {
|
|
432
|
+
releaseSnapshotScope(_snapshotRootOwner);
|
|
433
|
+
_snapshotRootOwner = null;
|
|
434
|
+
}
|
|
435
|
+
checkHydrationComplete();
|
|
1084
436
|
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
437
|
+
},
|
|
438
|
+
configurable: true,
|
|
439
|
+
enumerable: true
|
|
440
|
+
});
|
|
441
|
+
Object.defineProperty(sharedConfig, "done", {
|
|
442
|
+
get() {
|
|
443
|
+
return _doneValue;
|
|
444
|
+
},
|
|
445
|
+
set(v) {
|
|
446
|
+
_doneValue = v;
|
|
447
|
+
if (v) drainHydrationCallbacks();
|
|
448
|
+
},
|
|
449
|
+
configurable: true,
|
|
450
|
+
enumerable: true
|
|
451
|
+
});
|
|
1087
452
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
453
|
+
const createMemo = (...args) => (_createMemo || createMemo$1)(...args);
|
|
454
|
+
const createSignal = (...args) => (_createSignal || createSignal$1)(...args);
|
|
455
|
+
const createErrorBoundary = (...args) => (_createErrorBoundary || createErrorBoundary$1)(...args);
|
|
456
|
+
const createOptimistic = (...args) => (_createOptimistic || createOptimistic$1)(...args);
|
|
457
|
+
const createProjection = (...args) => (_createProjection || createProjection$1)(...args);
|
|
458
|
+
const createStore = (...args) => (_createStore || createStore$1)(...args);
|
|
459
|
+
const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args);
|
|
460
|
+
const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args);
|
|
461
|
+
const createEffect = (...args) => (_createEffect || createEffect$1)(...args);
|
|
462
|
+
function loadModuleAssets(mapping) {
|
|
463
|
+
const hy = globalThis._$HY;
|
|
464
|
+
if (!hy) return;
|
|
465
|
+
if (!hy.modules) hy.modules = {};
|
|
466
|
+
if (!hy.loading) hy.loading = {};
|
|
467
|
+
const pending = [];
|
|
468
|
+
for (const moduleUrl in mapping) {
|
|
469
|
+
if (hy.modules[moduleUrl]) continue;
|
|
470
|
+
const entryUrl = mapping[moduleUrl];
|
|
471
|
+
if (!hy.loading[moduleUrl]) {
|
|
472
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
473
|
+
hy.modules[moduleUrl] = mod;
|
|
1107
474
|
});
|
|
1108
|
-
if (getOwner()) onCleanup(dispose);
|
|
1109
|
-
return {
|
|
1110
|
-
unsubscribe() {
|
|
1111
|
-
dispose();
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
},
|
|
1115
|
-
[Symbol.observable || "@@observable"]() {
|
|
1116
|
-
return this;
|
|
1117
475
|
}
|
|
1118
|
-
|
|
476
|
+
pending.push(hy.loading[moduleUrl]);
|
|
477
|
+
}
|
|
478
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
1119
479
|
}
|
|
1120
|
-
function
|
|
1121
|
-
|
|
480
|
+
function createBoundaryTrigger() {
|
|
481
|
+
setSnapshotCapture(false);
|
|
482
|
+
const [s, set] = createSignal$1(undefined, {
|
|
1122
483
|
equals: false
|
|
1123
484
|
});
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
485
|
+
s();
|
|
486
|
+
setSnapshotCapture(true);
|
|
487
|
+
return set;
|
|
488
|
+
}
|
|
489
|
+
function resumeBoundaryHydration(o, id, set) {
|
|
490
|
+
_pendingBoundaries--;
|
|
491
|
+
if (isDisposed(o)) {
|
|
492
|
+
checkHydrationComplete();
|
|
493
|
+
return;
|
|
1130
494
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
return () => {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
mapped = [];
|
|
1159
|
-
len = 0;
|
|
1160
|
-
indexes && (indexes = []);
|
|
1161
|
-
}
|
|
1162
|
-
if (options.fallback) {
|
|
1163
|
-
items = [FALLBACK];
|
|
1164
|
-
mapped[0] = createRoot(disposer => {
|
|
1165
|
-
disposers[0] = disposer;
|
|
1166
|
-
return options.fallback();
|
|
1167
|
-
});
|
|
1168
|
-
len = 1;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
else if (len === 0) {
|
|
1172
|
-
mapped = new Array(newLen);
|
|
1173
|
-
for (j = 0; j < newLen; j++) {
|
|
1174
|
-
items[j] = newItems[j];
|
|
1175
|
-
mapped[j] = createRoot(mapper);
|
|
1176
|
-
}
|
|
1177
|
-
len = newLen;
|
|
1178
|
-
} else {
|
|
1179
|
-
temp = new Array(newLen);
|
|
1180
|
-
tempdisposers = new Array(newLen);
|
|
1181
|
-
indexes && (tempIndexes = new Array(newLen));
|
|
1182
|
-
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1183
|
-
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1184
|
-
temp[newEnd] = mapped[end];
|
|
1185
|
-
tempdisposers[newEnd] = disposers[end];
|
|
1186
|
-
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
1187
|
-
}
|
|
1188
|
-
newIndices = new Map();
|
|
1189
|
-
newIndicesNext = new Array(newEnd + 1);
|
|
1190
|
-
for (j = newEnd; j >= start; j--) {
|
|
1191
|
-
item = newItems[j];
|
|
1192
|
-
i = newIndices.get(item);
|
|
1193
|
-
newIndicesNext[j] = i === undefined ? -1 : i;
|
|
1194
|
-
newIndices.set(item, j);
|
|
1195
|
-
}
|
|
1196
|
-
for (i = start; i <= end; i++) {
|
|
1197
|
-
item = items[i];
|
|
1198
|
-
j = newIndices.get(item);
|
|
1199
|
-
if (j !== undefined && j !== -1) {
|
|
1200
|
-
temp[j] = mapped[i];
|
|
1201
|
-
tempdisposers[j] = disposers[i];
|
|
1202
|
-
indexes && (tempIndexes[j] = indexes[i]);
|
|
1203
|
-
j = newIndicesNext[j];
|
|
1204
|
-
newIndices.set(item, j);
|
|
1205
|
-
} else disposers[i]();
|
|
1206
|
-
}
|
|
1207
|
-
for (j = start; j < newLen; j++) {
|
|
1208
|
-
if (j in temp) {
|
|
1209
|
-
mapped[j] = temp[j];
|
|
1210
|
-
disposers[j] = tempdisposers[j];
|
|
1211
|
-
if (indexes) {
|
|
1212
|
-
indexes[j] = tempIndexes[j];
|
|
1213
|
-
indexes[j](j);
|
|
1214
|
-
}
|
|
1215
|
-
} else mapped[j] = createRoot(mapper);
|
|
1216
|
-
}
|
|
1217
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1218
|
-
items = newItems.slice(0);
|
|
1219
|
-
}
|
|
1220
|
-
return mapped;
|
|
1221
|
-
});
|
|
1222
|
-
function mapper(disposer) {
|
|
1223
|
-
disposers[j] = disposer;
|
|
1224
|
-
if (indexes) {
|
|
1225
|
-
const [s, set] = createSignal(j);
|
|
1226
|
-
indexes[j] = set;
|
|
1227
|
-
return mapFn(newItems[j], s);
|
|
495
|
+
sharedConfig.gather(id);
|
|
496
|
+
_hydratingValue = true;
|
|
497
|
+
markSnapshotScope(o);
|
|
498
|
+
_snapshotRootOwner = o;
|
|
499
|
+
set();
|
|
500
|
+
flush();
|
|
501
|
+
_snapshotRootOwner = null;
|
|
502
|
+
_hydratingValue = false;
|
|
503
|
+
releaseSnapshotScope(o);
|
|
504
|
+
flush();
|
|
505
|
+
checkHydrationComplete();
|
|
506
|
+
}
|
|
507
|
+
function Loading(props) {
|
|
508
|
+
if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
|
|
509
|
+
return createMemo$1(() => {
|
|
510
|
+
const o = getOwner();
|
|
511
|
+
const id = o.id;
|
|
512
|
+
let assetPromise;
|
|
513
|
+
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
514
|
+
const mapping = sharedConfig.load(id + "_assets");
|
|
515
|
+
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
516
|
+
}
|
|
517
|
+
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
518
|
+
let ref = sharedConfig.load(id);
|
|
519
|
+
let p;
|
|
520
|
+
if (ref) {
|
|
521
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
|
|
1228
522
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
newItems[$TRACK];
|
|
1245
|
-
return untrack(() => {
|
|
1246
|
-
if (newLen === 0) {
|
|
1247
|
-
if (len !== 0) {
|
|
1248
|
-
dispose(disposers);
|
|
1249
|
-
disposers = [];
|
|
1250
|
-
items = [];
|
|
1251
|
-
mapped = [];
|
|
1252
|
-
len = 0;
|
|
1253
|
-
signals = [];
|
|
1254
|
-
}
|
|
1255
|
-
if (options.fallback) {
|
|
1256
|
-
items = [FALLBACK];
|
|
1257
|
-
mapped[0] = createRoot(disposer => {
|
|
1258
|
-
disposers[0] = disposer;
|
|
1259
|
-
return options.fallback();
|
|
523
|
+
if (p) {
|
|
524
|
+
_pendingBoundaries++;
|
|
525
|
+
onCleanup(() => {
|
|
526
|
+
if (!isDisposed(o)) return;
|
|
527
|
+
sharedConfig.cleanupFragment?.(id);
|
|
528
|
+
});
|
|
529
|
+
const set = createBoundaryTrigger();
|
|
530
|
+
if (p !== "$$f") {
|
|
531
|
+
const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
|
|
532
|
+
waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
|
|
533
|
+
_pendingBoundaries--;
|
|
534
|
+
checkHydrationComplete();
|
|
535
|
+
runWithOwner(o, () => {
|
|
536
|
+
throw err;
|
|
537
|
+
});
|
|
1260
538
|
});
|
|
1261
|
-
|
|
539
|
+
} else {
|
|
540
|
+
const afterAssets = () => {
|
|
541
|
+
_pendingBoundaries--;
|
|
542
|
+
set();
|
|
543
|
+
checkHydrationComplete();
|
|
544
|
+
};
|
|
545
|
+
if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
|
|
1262
546
|
}
|
|
1263
|
-
return
|
|
1264
|
-
}
|
|
1265
|
-
if (items[0] === FALLBACK) {
|
|
1266
|
-
disposers[0]();
|
|
1267
|
-
disposers = [];
|
|
1268
|
-
items = [];
|
|
1269
|
-
mapped = [];
|
|
1270
|
-
len = 0;
|
|
1271
|
-
}
|
|
1272
|
-
for (i = 0; i < newLen; i++) {
|
|
1273
|
-
if (i < items.length && items[i] !== newItems[i]) {
|
|
1274
|
-
signals[i](() => newItems[i]);
|
|
1275
|
-
} else if (i >= items.length) {
|
|
1276
|
-
mapped[i] = createRoot(mapper);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
for (; i < items.length; i++) {
|
|
1280
|
-
disposers[i]();
|
|
547
|
+
return props.fallback;
|
|
1281
548
|
}
|
|
1282
|
-
len = signals.length = disposers.length = newLen;
|
|
1283
|
-
items = newItems.slice(0);
|
|
1284
|
-
return mapped = mapped.slice(0, len);
|
|
1285
|
-
});
|
|
1286
|
-
function mapper(disposer) {
|
|
1287
|
-
disposers[i] = disposer;
|
|
1288
|
-
const [s, set] = createSignal(newItems[i]);
|
|
1289
|
-
signals[i] = set;
|
|
1290
|
-
return mapFn(s, i);
|
|
1291
549
|
}
|
|
1292
|
-
|
|
550
|
+
if (assetPromise) {
|
|
551
|
+
_pendingBoundaries++;
|
|
552
|
+
const set = createBoundaryTrigger();
|
|
553
|
+
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
554
|
+
return undefined;
|
|
555
|
+
}
|
|
556
|
+
return createLoadBoundary(() => props.children, () => props.fallback);
|
|
557
|
+
});
|
|
1293
558
|
}
|
|
1294
559
|
|
|
1295
|
-
let hydrationEnabled = false;
|
|
1296
|
-
function enableHydration() {
|
|
1297
|
-
hydrationEnabled = true;
|
|
1298
|
-
}
|
|
1299
560
|
function createComponent(Comp, props) {
|
|
1300
|
-
if (hydrationEnabled) {
|
|
1301
|
-
if (sharedConfig.context) {
|
|
1302
|
-
const c = sharedConfig.context;
|
|
1303
|
-
setHydrateContext(nextHydrateContext());
|
|
1304
|
-
const r = untrack(() => Comp(props || {}));
|
|
1305
|
-
setHydrateContext(c);
|
|
1306
|
-
return r;
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
561
|
return untrack(() => Comp(props || {}));
|
|
1310
562
|
}
|
|
1311
|
-
function
|
|
1312
|
-
return true;
|
|
1313
|
-
}
|
|
1314
|
-
const propTraps = {
|
|
1315
|
-
get(_, property, receiver) {
|
|
1316
|
-
if (property === $PROXY) return receiver;
|
|
1317
|
-
return _.get(property);
|
|
1318
|
-
},
|
|
1319
|
-
has(_, property) {
|
|
1320
|
-
if (property === $PROXY) return true;
|
|
1321
|
-
return _.has(property);
|
|
1322
|
-
},
|
|
1323
|
-
set: trueFn,
|
|
1324
|
-
deleteProperty: trueFn,
|
|
1325
|
-
getOwnPropertyDescriptor(_, property) {
|
|
1326
|
-
return {
|
|
1327
|
-
configurable: true,
|
|
1328
|
-
enumerable: true,
|
|
1329
|
-
get() {
|
|
1330
|
-
return _.get(property);
|
|
1331
|
-
},
|
|
1332
|
-
set: trueFn,
|
|
1333
|
-
deleteProperty: trueFn
|
|
1334
|
-
};
|
|
1335
|
-
},
|
|
1336
|
-
ownKeys(_) {
|
|
1337
|
-
return _.keys();
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
function resolveSource(s) {
|
|
1341
|
-
return !(s = typeof s === "function" ? s() : s) ? {} : s;
|
|
1342
|
-
}
|
|
1343
|
-
function resolveSources() {
|
|
1344
|
-
for (let i = 0, length = this.length; i < length; ++i) {
|
|
1345
|
-
const v = this[i]();
|
|
1346
|
-
if (v !== undefined) return v;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
function mergeProps(...sources) {
|
|
1350
|
-
let proxy = false;
|
|
1351
|
-
for (let i = 0; i < sources.length; i++) {
|
|
1352
|
-
const s = sources[i];
|
|
1353
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1354
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1355
|
-
}
|
|
1356
|
-
if (SUPPORTS_PROXY && proxy) {
|
|
1357
|
-
return new Proxy({
|
|
1358
|
-
get(property) {
|
|
1359
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1360
|
-
const v = resolveSource(sources[i])[property];
|
|
1361
|
-
if (v !== undefined) return v;
|
|
1362
|
-
}
|
|
1363
|
-
},
|
|
1364
|
-
has(property) {
|
|
1365
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1366
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1367
|
-
}
|
|
1368
|
-
return false;
|
|
1369
|
-
},
|
|
1370
|
-
keys() {
|
|
1371
|
-
const keys = [];
|
|
1372
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1373
|
-
return [...new Set(keys)];
|
|
1374
|
-
}
|
|
1375
|
-
}, propTraps);
|
|
1376
|
-
}
|
|
1377
|
-
const sourcesMap = {};
|
|
1378
|
-
const defined = Object.create(null);
|
|
1379
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1380
|
-
const source = sources[i];
|
|
1381
|
-
if (!source) continue;
|
|
1382
|
-
const sourceKeys = Object.getOwnPropertyNames(source);
|
|
1383
|
-
for (let i = sourceKeys.length - 1; i >= 0; i--) {
|
|
1384
|
-
const key = sourceKeys[i];
|
|
1385
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
1386
|
-
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1387
|
-
if (!defined[key]) {
|
|
1388
|
-
defined[key] = desc.get ? {
|
|
1389
|
-
enumerable: true,
|
|
1390
|
-
configurable: true,
|
|
1391
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1392
|
-
} : desc.value !== undefined ? desc : undefined;
|
|
1393
|
-
} else {
|
|
1394
|
-
const sources = sourcesMap[key];
|
|
1395
|
-
if (sources) {
|
|
1396
|
-
if (desc.get) sources.push(desc.get.bind(source));else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
const target = {};
|
|
1402
|
-
const definedKeys = Object.keys(defined);
|
|
1403
|
-
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1404
|
-
const key = definedKeys[i],
|
|
1405
|
-
desc = defined[key];
|
|
1406
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);else target[key] = desc ? desc.value : undefined;
|
|
1407
|
-
}
|
|
1408
|
-
return target;
|
|
1409
|
-
}
|
|
1410
|
-
function splitProps(props, ...keys) {
|
|
1411
|
-
const len = keys.length;
|
|
1412
|
-
if (SUPPORTS_PROXY && $PROXY in props) {
|
|
1413
|
-
const blocked = len > 1 ? keys.flat() : keys[0];
|
|
1414
|
-
const res = keys.map(k => {
|
|
1415
|
-
return new Proxy({
|
|
1416
|
-
get(property) {
|
|
1417
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1418
|
-
},
|
|
1419
|
-
has(property) {
|
|
1420
|
-
return k.includes(property) && property in props;
|
|
1421
|
-
},
|
|
1422
|
-
keys() {
|
|
1423
|
-
return k.filter(property => property in props);
|
|
1424
|
-
}
|
|
1425
|
-
}, propTraps);
|
|
1426
|
-
});
|
|
1427
|
-
res.push(new Proxy({
|
|
1428
|
-
get(property) {
|
|
1429
|
-
return blocked.includes(property) ? undefined : props[property];
|
|
1430
|
-
},
|
|
1431
|
-
has(property) {
|
|
1432
|
-
return blocked.includes(property) ? false : property in props;
|
|
1433
|
-
},
|
|
1434
|
-
keys() {
|
|
1435
|
-
return Object.keys(props).filter(k => !blocked.includes(k));
|
|
1436
|
-
}
|
|
1437
|
-
}, propTraps));
|
|
1438
|
-
return res;
|
|
1439
|
-
}
|
|
1440
|
-
const objects = [];
|
|
1441
|
-
for (let i = 0; i <= len; i++) {
|
|
1442
|
-
objects[i] = {};
|
|
1443
|
-
}
|
|
1444
|
-
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1445
|
-
let keyIndex = len;
|
|
1446
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1447
|
-
if (keys[i].includes(propName)) {
|
|
1448
|
-
keyIndex = i;
|
|
1449
|
-
break;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1453
|
-
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1454
|
-
isDefaultDesc ? objects[keyIndex][propName] = desc.value : Object.defineProperty(objects[keyIndex], propName, desc);
|
|
1455
|
-
}
|
|
1456
|
-
return objects;
|
|
1457
|
-
}
|
|
1458
|
-
function lazy(fn) {
|
|
563
|
+
function lazy(fn, moduleUrl) {
|
|
1459
564
|
let comp;
|
|
1460
565
|
let p;
|
|
1461
566
|
const wrap = props => {
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
567
|
+
if (sharedConfig.hydrating && moduleUrl) {
|
|
568
|
+
const cached = globalThis._$HY?.modules?.[moduleUrl];
|
|
569
|
+
if (!cached) {
|
|
570
|
+
throw new Error(`lazy() module "${moduleUrl}" was not preloaded before hydration. ` + "Ensure it is inside a Loading boundary.");
|
|
571
|
+
}
|
|
572
|
+
comp = () => cached.default;
|
|
573
|
+
}
|
|
574
|
+
if (!comp) {
|
|
575
|
+
p || (p = fn());
|
|
576
|
+
p.then(mod => {
|
|
577
|
+
comp = () => mod.default;
|
|
1472
578
|
});
|
|
1473
|
-
comp =
|
|
1474
|
-
} else if (!comp) {
|
|
1475
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1476
|
-
comp = s;
|
|
579
|
+
comp = createMemo$1(() => p.then(mod => mod.default));
|
|
1477
580
|
}
|
|
1478
581
|
let Comp;
|
|
1479
|
-
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1480
|
-
|
|
1481
|
-
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1482
|
-
const c = sharedConfig.context;
|
|
1483
|
-
setHydrateContext(ctx);
|
|
1484
|
-
const r = Comp(props);
|
|
1485
|
-
setHydrateContext(c);
|
|
1486
|
-
return r;
|
|
582
|
+
return createMemo$1(() => (Comp = comp()) ? untrack(() => {
|
|
583
|
+
return Comp(props);
|
|
1487
584
|
}) : "");
|
|
1488
585
|
};
|
|
1489
586
|
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
@@ -1491,264 +588,96 @@ function lazy(fn) {
|
|
|
1491
588
|
}
|
|
1492
589
|
let counter = 0;
|
|
1493
590
|
function createUniqueId() {
|
|
1494
|
-
|
|
1495
|
-
return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
591
|
+
return sharedConfig.hydrating ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
1496
592
|
}
|
|
1497
593
|
|
|
1498
594
|
const narrowedError = name => `Stale read from <${name}>.`;
|
|
1499
595
|
function For(props) {
|
|
1500
|
-
const
|
|
596
|
+
const options = "fallback" in props ? {
|
|
597
|
+
keyed: props.keyed,
|
|
1501
598
|
fallback: () => props.fallback
|
|
599
|
+
} : {
|
|
600
|
+
keyed: props.keyed
|
|
1502
601
|
};
|
|
1503
|
-
return
|
|
602
|
+
return mapArray(() => props.each, props.children, options);
|
|
1504
603
|
}
|
|
1505
|
-
function
|
|
1506
|
-
const
|
|
604
|
+
function Repeat(props) {
|
|
605
|
+
const options = "fallback" in props ? {
|
|
1507
606
|
fallback: () => props.fallback
|
|
1508
|
-
};
|
|
1509
|
-
|
|
607
|
+
} : {};
|
|
608
|
+
options.from = () => props.from;
|
|
609
|
+
return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
|
|
1510
610
|
}
|
|
1511
611
|
function Show(props) {
|
|
1512
612
|
const keyed = props.keyed;
|
|
1513
|
-
const conditionValue = createMemo(() => props.when, undefined, undefined);
|
|
1514
|
-
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
613
|
+
const conditionValue = createMemo$1(() => props.when, undefined, undefined);
|
|
614
|
+
const condition = keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
1515
615
|
equals: (a, b) => !a === !b
|
|
1516
616
|
});
|
|
1517
|
-
return createMemo(() => {
|
|
617
|
+
return createMemo$1(() => {
|
|
1518
618
|
const c = condition();
|
|
1519
619
|
if (c) {
|
|
1520
620
|
const child = props.children;
|
|
1521
621
|
const fn = typeof child === "function" && child.length > 0;
|
|
1522
|
-
return fn ? untrack(() =>
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
622
|
+
return fn ? untrack(() => {
|
|
623
|
+
try {
|
|
624
|
+
return child(() => {
|
|
625
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
626
|
+
return conditionValue();
|
|
627
|
+
});
|
|
628
|
+
} finally {
|
|
629
|
+
}
|
|
630
|
+
}) : child;
|
|
1526
631
|
}
|
|
1527
632
|
return props.fallback;
|
|
1528
633
|
}, undefined, undefined);
|
|
1529
634
|
}
|
|
1530
635
|
function Switch(props) {
|
|
1531
636
|
const chs = children(() => props.children);
|
|
1532
|
-
const switchFunc = createMemo(() => {
|
|
1533
|
-
const
|
|
1534
|
-
const mps = Array.isArray(ch) ? ch : [ch];
|
|
637
|
+
const switchFunc = createMemo$1(() => {
|
|
638
|
+
const mps = chs.toArray();
|
|
1535
639
|
let func = () => undefined;
|
|
1536
640
|
for (let i = 0; i < mps.length; i++) {
|
|
1537
641
|
const index = i;
|
|
1538
642
|
const mp = mps[i];
|
|
1539
643
|
const prevFunc = func;
|
|
1540
|
-
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
1541
|
-
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
644
|
+
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
645
|
+
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
1542
646
|
equals: (a, b) => !a === !b
|
|
1543
647
|
});
|
|
1544
648
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1545
649
|
}
|
|
1546
650
|
return func;
|
|
1547
651
|
});
|
|
1548
|
-
return createMemo(() => {
|
|
652
|
+
return createMemo$1(() => {
|
|
1549
653
|
const sel = switchFunc()();
|
|
1550
654
|
if (!sel) return props.fallback;
|
|
1551
655
|
const [index, conditionValue, mp] = sel;
|
|
1552
656
|
const child = mp.children;
|
|
1553
657
|
const fn = typeof child === "function" && child.length > 0;
|
|
1554
|
-
return fn ? untrack(() =>
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
658
|
+
return fn ? untrack(() => {
|
|
659
|
+
try {
|
|
660
|
+
return child(() => {
|
|
661
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
662
|
+
return conditionValue();
|
|
663
|
+
});
|
|
664
|
+
} finally {
|
|
665
|
+
}
|
|
666
|
+
}) : child;
|
|
1558
667
|
}, undefined, undefined);
|
|
1559
668
|
}
|
|
1560
669
|
function Match(props) {
|
|
1561
670
|
return props;
|
|
1562
671
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
function ErrorBoundary(props) {
|
|
1568
|
-
let err;
|
|
1569
|
-
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.getContextId());
|
|
1570
|
-
const [errored, setErrored] = createSignal(err, undefined);
|
|
1571
|
-
Errors || (Errors = new Set());
|
|
1572
|
-
Errors.add(setErrored);
|
|
1573
|
-
onCleanup(() => Errors.delete(setErrored));
|
|
1574
|
-
return createMemo(() => {
|
|
1575
|
-
let e;
|
|
1576
|
-
if (e = errored()) {
|
|
1577
|
-
const f = props.fallback;
|
|
1578
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1579
|
-
}
|
|
1580
|
-
return catchError(() => props.children, setErrored);
|
|
1581
|
-
}, undefined, undefined);
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1585
|
-
const SuspenseListContext = /* #__PURE__ */createContext();
|
|
1586
|
-
function SuspenseList(props) {
|
|
1587
|
-
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1588
|
-
inFallback: false
|
|
1589
|
-
})),
|
|
1590
|
-
show;
|
|
1591
|
-
const listContext = useContext(SuspenseListContext);
|
|
1592
|
-
const [registry, setRegistry] = createSignal([]);
|
|
1593
|
-
if (listContext) {
|
|
1594
|
-
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1595
|
-
}
|
|
1596
|
-
const resolved = createMemo(prev => {
|
|
1597
|
-
const reveal = props.revealOrder,
|
|
1598
|
-
tail = props.tail,
|
|
1599
|
-
{
|
|
1600
|
-
showContent = true,
|
|
1601
|
-
showFallback = true
|
|
1602
|
-
} = show ? show() : {},
|
|
1603
|
-
reg = registry(),
|
|
1604
|
-
reverse = reveal === "backwards";
|
|
1605
|
-
if (reveal === "together") {
|
|
1606
|
-
const all = reg.every(inFallback => !inFallback());
|
|
1607
|
-
const res = reg.map(() => ({
|
|
1608
|
-
showContent: all && showContent,
|
|
1609
|
-
showFallback
|
|
1610
|
-
}));
|
|
1611
|
-
res.inFallback = !all;
|
|
1612
|
-
return res;
|
|
1613
|
-
}
|
|
1614
|
-
let stop = false;
|
|
1615
|
-
let inFallback = prev.inFallback;
|
|
1616
|
-
const res = [];
|
|
1617
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1618
|
-
const n = reverse ? len - i - 1 : i,
|
|
1619
|
-
s = reg[n]();
|
|
1620
|
-
if (!stop && !s) {
|
|
1621
|
-
res[n] = {
|
|
1622
|
-
showContent,
|
|
1623
|
-
showFallback
|
|
1624
|
-
};
|
|
1625
|
-
} else {
|
|
1626
|
-
const next = !stop;
|
|
1627
|
-
if (next) inFallback = true;
|
|
1628
|
-
res[n] = {
|
|
1629
|
-
showContent: next,
|
|
1630
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1631
|
-
};
|
|
1632
|
-
stop = true;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
if (!stop) inFallback = false;
|
|
1636
|
-
res.inFallback = inFallback;
|
|
1637
|
-
return res;
|
|
1638
|
-
}, {
|
|
1639
|
-
inFallback: false
|
|
1640
|
-
});
|
|
1641
|
-
setWrapper(() => resolved);
|
|
1642
|
-
return createComponent(SuspenseListContext.Provider, {
|
|
1643
|
-
value: {
|
|
1644
|
-
register: inFallback => {
|
|
1645
|
-
let index;
|
|
1646
|
-
setRegistry(registry => {
|
|
1647
|
-
index = registry.length;
|
|
1648
|
-
return [...registry, inFallback];
|
|
1649
|
-
});
|
|
1650
|
-
return createMemo(() => resolved()[index], undefined, {
|
|
1651
|
-
equals: suspenseListEquals
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
},
|
|
1655
|
-
get children() {
|
|
1656
|
-
return props.children;
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
function Suspense(props) {
|
|
1661
|
-
let counter = 0,
|
|
1662
|
-
show,
|
|
1663
|
-
ctx,
|
|
1664
|
-
p,
|
|
1665
|
-
flicker,
|
|
1666
|
-
error;
|
|
1667
|
-
const [inFallback, setFallback] = createSignal(false),
|
|
1668
|
-
SuspenseContext = getSuspenseContext(),
|
|
1669
|
-
store = {
|
|
1670
|
-
increment: () => {
|
|
1671
|
-
if (++counter === 1) setFallback(true);
|
|
1672
|
-
},
|
|
1673
|
-
decrement: () => {
|
|
1674
|
-
if (--counter === 0) setFallback(false);
|
|
1675
|
-
},
|
|
1676
|
-
inFallback,
|
|
1677
|
-
effects: [],
|
|
1678
|
-
resolved: false
|
|
1679
|
-
},
|
|
1680
|
-
owner = getOwner();
|
|
1681
|
-
if (sharedConfig.context && sharedConfig.load) {
|
|
1682
|
-
const key = sharedConfig.getContextId();
|
|
1683
|
-
let ref = sharedConfig.load(key);
|
|
1684
|
-
if (ref) {
|
|
1685
|
-
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(key);
|
|
1686
|
-
}
|
|
1687
|
-
if (p && p !== "$$f") {
|
|
1688
|
-
const [s, set] = createSignal(undefined, {
|
|
1689
|
-
equals: false
|
|
1690
|
-
});
|
|
1691
|
-
flicker = s;
|
|
1692
|
-
p.then(() => {
|
|
1693
|
-
if (sharedConfig.done) return set();
|
|
1694
|
-
sharedConfig.gather(key);
|
|
1695
|
-
setHydrateContext(ctx);
|
|
1696
|
-
set();
|
|
1697
|
-
setHydrateContext();
|
|
1698
|
-
}, err => {
|
|
1699
|
-
error = err;
|
|
1700
|
-
set();
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
const listContext = useContext(SuspenseListContext);
|
|
1705
|
-
if (listContext) show = listContext.register(store.inFallback);
|
|
1706
|
-
let dispose;
|
|
1707
|
-
onCleanup(() => dispose && dispose());
|
|
1708
|
-
return createComponent(SuspenseContext.Provider, {
|
|
1709
|
-
value: store,
|
|
1710
|
-
get children() {
|
|
1711
|
-
return createMemo(() => {
|
|
1712
|
-
if (error) throw error;
|
|
1713
|
-
ctx = sharedConfig.context;
|
|
1714
|
-
if (flicker) {
|
|
1715
|
-
flicker();
|
|
1716
|
-
return flicker = undefined;
|
|
1717
|
-
}
|
|
1718
|
-
if (ctx && p === "$$f") setHydrateContext();
|
|
1719
|
-
const rendered = createMemo(() => props.children);
|
|
1720
|
-
return createMemo(prev => {
|
|
1721
|
-
const inFallback = store.inFallback(),
|
|
1722
|
-
{
|
|
1723
|
-
showContent = true,
|
|
1724
|
-
showFallback = true
|
|
1725
|
-
} = show ? show() : {};
|
|
1726
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1727
|
-
store.resolved = true;
|
|
1728
|
-
dispose && dispose();
|
|
1729
|
-
dispose = ctx = p = undefined;
|
|
1730
|
-
resumeEffects(store.effects);
|
|
1731
|
-
return rendered();
|
|
1732
|
-
}
|
|
1733
|
-
if (!showFallback) return;
|
|
1734
|
-
if (dispose) return prev;
|
|
1735
|
-
return createRoot(disposer => {
|
|
1736
|
-
dispose = disposer;
|
|
1737
|
-
if (ctx) {
|
|
1738
|
-
setHydrateContext({
|
|
1739
|
-
id: ctx.id + "F",
|
|
1740
|
-
count: 0
|
|
1741
|
-
});
|
|
1742
|
-
ctx = undefined;
|
|
1743
|
-
}
|
|
1744
|
-
return props.fallback;
|
|
1745
|
-
}, owner);
|
|
1746
|
-
});
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
672
|
+
function Errored(props) {
|
|
673
|
+
return createErrorBoundary(() => props.children, (err, reset) => {
|
|
674
|
+
const f = props.fallback;
|
|
675
|
+
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
1749
676
|
});
|
|
1750
677
|
}
|
|
1751
678
|
|
|
679
|
+
function ssrHandleError() {}
|
|
680
|
+
function ssrRunInScope() {}
|
|
1752
681
|
const DEV = undefined;
|
|
1753
682
|
|
|
1754
|
-
export { $DEVCOMP,
|
|
683
|
+
export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|