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