solid-js 2.0.0-beta.1 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHEATSHEET.md +640 -0
  2. package/README.md +42 -188
  3. package/dist/dev.cjs +431 -283
  4. package/dist/dev.js +411 -286
  5. package/dist/server.cjs +701 -281
  6. package/dist/server.js +684 -284
  7. package/dist/solid.cjs +423 -255
  8. package/dist/solid.js +403 -258
  9. package/package.json +67 -39
  10. package/types/client/component.d.ts +64 -19
  11. package/types/client/core.d.ts +110 -34
  12. package/types/client/flow.d.ts +176 -42
  13. package/types/client/hydration.d.ts +514 -36
  14. package/types/index.d.ts +9 -12
  15. package/types/server/component.d.ts +11 -11
  16. package/types/server/core.d.ts +19 -14
  17. package/types/server/flow.d.ts +76 -21
  18. package/types/server/hydration.d.ts +34 -9
  19. package/types/server/index.d.ts +5 -7
  20. package/types/server/shared.d.ts +5 -1
  21. package/types/server/signals.d.ts +44 -19
  22. package/types/types.d.ts +15 -0
  23. package/types-cjs/client/component.d.cts +120 -0
  24. package/types-cjs/client/core.d.cts +141 -0
  25. package/types-cjs/client/flow.d.cts +234 -0
  26. package/types-cjs/client/hydration.d.cts +570 -0
  27. package/types-cjs/index.d.cts +17 -0
  28. package/types-cjs/package.json +3 -0
  29. package/types-cjs/server/component.d.cts +67 -0
  30. package/types-cjs/server/core.d.cts +49 -0
  31. package/types-cjs/server/flow.d.cts +115 -0
  32. package/types-cjs/server/hydration.d.cts +63 -0
  33. package/types-cjs/server/index.d.cts +10 -0
  34. package/types-cjs/server/shared.d.cts +50 -0
  35. package/types-cjs/server/signals.d.cts +87 -0
  36. package/types-cjs/types.d.cts +15 -0
  37. package/jsx-runtime.d.ts +0 -1
  38. package/types/jsx.d.ts +0 -4129
package/dist/dev.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, setStrictRead, createLoadBoundary, onCleanup, isDisposed, runWithOwner, createOwner, 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, 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';
1
+ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, untrack, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$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, onCleanup, isDisposed, peekNextChildId, clearSnapshots, flush, markSnapshotScope, mapArray, repeat, createRevealOrder, DEV as DEV$1 } from '@solidjs/signals';
2
+ export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createOwner, createReaction, createRevealOrder, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
3
3
 
4
4
  const $DEVCOMP = Symbol("COMPONENT_DEV" );
5
5
  function createContext(defaultValue, options) {
@@ -18,10 +18,10 @@ function useContext(context) {
18
18
  return getContext(context);
19
19
  }
20
20
  function children(fn) {
21
- const c = createMemo$1(fn, undefined, {
21
+ const c = createMemo$1(fn, {
22
22
  lazy: true
23
23
  });
24
- const memo = createMemo$1(() => flatten(c()), undefined, {
24
+ const memo = createMemo$1(() => flatten(c()), {
25
25
  name: "children",
26
26
  lazy: true
27
27
  } );
@@ -34,30 +34,19 @@ function children(fn) {
34
34
  function devComponent(Comp, props) {
35
35
  return createRoot(() => {
36
36
  const owner = getOwner();
37
- owner._props = props;
38
- owner._name = Comp.name;
39
- owner._component = Comp;
40
- return untrack(() => {
41
- Object.assign(Comp, {
42
- [$DEVCOMP]: true
43
- });
44
- setStrictRead(`<${Comp.name || "Anonymous"}>`);
45
- try {
46
- return Comp(props);
47
- } finally {
48
- setStrictRead(false);
49
- }
37
+ owner._component = {
38
+ fn: Comp,
39
+ props,
40
+ name: Comp.name
41
+ };
42
+ Object.assign(Comp, {
43
+ [$DEVCOMP]: true
50
44
  });
45
+ return untrack(() => Comp(props), `<${Comp.name || "Anonymous"}>`);
51
46
  }, {
52
47
  transparent: true
53
48
  });
54
49
  }
55
- function registerGraph(value) {
56
- const owner = getOwner();
57
- if (!owner) return;
58
- if (owner.sourceMap) owner.sourceMap.push(value);else owner.sourceMap = [value];
59
- value.graph = owner;
60
- }
61
50
 
62
51
  const NoHydrateContext = {
63
52
  id: Symbol("NoHydrateContext"),
@@ -99,6 +88,7 @@ function drainHydrationCallbacks() {
99
88
  setTimeout(() => {
100
89
  if (sharedConfig.verifyHydration) sharedConfig.verifyHydration();
101
90
  if (globalThis._$HY) globalThis._$HY.done = true;
91
+ sharedConfig.registry?.clear();
102
92
  });
103
93
  }
104
94
  function checkHydrationComplete() {
@@ -116,23 +106,10 @@ let _createOptimisticStore;
116
106
  let _createRenderEffect;
117
107
  let _createEffect;
118
108
  class MockPromise {
119
- static all() {
120
- return new MockPromise();
121
- }
122
- static allSettled() {
123
- return new MockPromise();
124
- }
125
- static any() {
126
- return new MockPromise();
127
- }
128
- static race() {
129
- return new MockPromise();
130
- }
131
- static reject() {
132
- return new MockPromise();
133
- }
134
- static resolve() {
135
- return new MockPromise();
109
+ static {
110
+ for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
111
+ MockPromise[k] = () => new MockPromise();
112
+ }
136
113
  }
137
114
  catch() {
138
115
  return new MockPromise();
@@ -160,11 +137,67 @@ function subFetch(fn, prev) {
160
137
  Promise = ogPromise;
161
138
  }
162
139
  }
163
- function consumeFirstSync(ai) {
164
- const iter = ai[Symbol.asyncIterator]();
165
- const r = iter.next();
166
- const value = !(r instanceof Promise) && !r.done ? r.value : undefined;
167
- return [value, iter];
140
+ function syncThenable(value) {
141
+ return {
142
+ then(fn) {
143
+ fn(value);
144
+ }
145
+ };
146
+ }
147
+ const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
148
+ function readHydratedValue(initP, refresh) {
149
+ if (initP == null) return NO_HYDRATED_VALUE;
150
+ refresh();
151
+ if (typeof initP === "object" && initP.s === 2) throw initP.v;
152
+ return initP?.v ?? initP;
153
+ }
154
+ function readSerializedOrCompute(compute, prev) {
155
+ if (!sharedConfig.hydrating) return compute(prev);
156
+ const o = getOwner();
157
+ let initP;
158
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
159
+ const init = readHydratedValue(initP, () => subFetch(compute, prev));
160
+ return init !== NO_HYDRATED_VALUE ? init : compute(prev);
161
+ }
162
+ function forwardIteratorReturn(it, value) {
163
+ const returned = it.return?.(value);
164
+ return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
165
+ done: true,
166
+ value
167
+ });
168
+ }
169
+ function normalizeIterator(it) {
170
+ let first = true;
171
+ let buffered = null;
172
+ return {
173
+ next() {
174
+ if (first) {
175
+ first = false;
176
+ const r = it.next();
177
+ return r && typeof r.then === "function" ? r : syncThenable(r);
178
+ }
179
+ if (buffered) {
180
+ const b = buffered;
181
+ buffered = null;
182
+ return b;
183
+ }
184
+ let latest = it.next();
185
+ if (latest && typeof latest.then === "function") return latest;
186
+ while (!latest.done) {
187
+ const peek = it.next();
188
+ if (peek && typeof peek.then === "function") {
189
+ buffered = peek;
190
+ break;
191
+ }
192
+ latest = peek;
193
+ }
194
+ return Promise.resolve(latest);
195
+ },
196
+ return(value) {
197
+ buffered = null;
198
+ return forwardIteratorReturn(it, value);
199
+ }
200
+ };
168
201
  }
169
202
  function applyPatches(target, patches) {
170
203
  for (const patch of patches) {
@@ -181,118 +214,211 @@ function applyPatches(target, patches) {
181
214
  }
182
215
  }
183
216
  }
184
- function scheduleIteratorConsumption(iter, apply) {
185
- const consume = () => {
186
- while (true) {
187
- const n = iter.next();
188
- if (n instanceof Promise) {
189
- n.then(r => {
190
- if (r.done) return;
191
- apply(r.value);
192
- consume();
193
- });
194
- return;
217
+ function isAsyncIterable(v) {
218
+ return v != null && typeof v[Symbol.asyncIterator] === "function";
219
+ }
220
+ function createShadowDraft(realDraft) {
221
+ const shadow = JSON.parse(JSON.stringify(realDraft));
222
+ let useShadow = true;
223
+ return {
224
+ proxy: new Proxy(shadow, {
225
+ get(_, prop) {
226
+ return useShadow ? shadow[prop] : realDraft[prop];
227
+ },
228
+ set(_, prop, value) {
229
+ if (useShadow) {
230
+ shadow[prop] = value;
231
+ return true;
232
+ }
233
+ return Reflect.set(realDraft, prop, value);
234
+ },
235
+ deleteProperty(_, prop) {
236
+ if (useShadow) {
237
+ delete shadow[prop];
238
+ return true;
239
+ }
240
+ return Reflect.deleteProperty(realDraft, prop);
241
+ },
242
+ has(_, prop) {
243
+ return prop in (useShadow ? shadow : realDraft);
244
+ },
245
+ ownKeys() {
246
+ return Reflect.ownKeys(useShadow ? shadow : realDraft);
247
+ },
248
+ getOwnPropertyDescriptor(_, prop) {
249
+ return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
195
250
  }
196
- if (n.done) break;
197
- apply(n.value);
251
+ }),
252
+ activate() {
253
+ useShadow = false;
198
254
  }
199
255
  };
200
- consume();
201
256
  }
202
- function isAsyncIterable(v) {
203
- return v != null && typeof v[Symbol.asyncIterator] === "function";
257
+ function wrapFirstYield(iterable, activate) {
258
+ const srcIt = iterable[Symbol.asyncIterator]();
259
+ let first = true;
260
+ return {
261
+ [Symbol.asyncIterator]() {
262
+ return {
263
+ next() {
264
+ const p = srcIt.next();
265
+ if (first) {
266
+ first = false;
267
+ return p.then(r => {
268
+ activate();
269
+ return r.done ? r : {
270
+ done: false,
271
+ value: undefined
272
+ };
273
+ });
274
+ }
275
+ return p;
276
+ },
277
+ return(value) {
278
+ return forwardIteratorReturn(srcIt, value);
279
+ }
280
+ };
281
+ }
282
+ };
204
283
  }
205
- function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
284
+ function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
206
285
  const parent = getOwner();
207
286
  const expectedId = peekNextChildId(parent);
208
287
  if (!sharedConfig.has(expectedId)) return null;
209
- const initP = sharedConfig.load(expectedId);
210
- if (!isAsyncIterable(initP)) return null;
211
- const [firstValue, iter] = consumeFirstSync(initP);
212
- const [get, set] = createSignal$1(firstValue);
213
- const result = coreFn(() => get(), firstValue, options);
214
- scheduleIteratorConsumption(iter, v => {
215
- set(() => v);
216
- flush();
217
- });
218
- return result;
288
+ const loaded = sharedConfig.load(expectedId);
289
+ if (!isAsyncIterable(loaded)) return null;
290
+ const it = normalizeIterator(loaded[Symbol.asyncIterator]());
291
+ const iterable = {
292
+ [Symbol.asyncIterator]() {
293
+ return it;
294
+ }
295
+ };
296
+ return coreFn(prev => {
297
+ subFetch(compute, prev);
298
+ return iterable;
299
+ }, options);
219
300
  }
220
- function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
301
+ function hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options) {
221
302
  const parent = getOwner();
222
303
  const expectedId = peekNextChildId(parent);
223
304
  if (!sharedConfig.has(expectedId)) return null;
224
- const initP = sharedConfig.load(expectedId);
225
- if (!isAsyncIterable(initP)) return null;
226
- const [firstState, iter] = consumeFirstSync(initP);
227
- const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options);
228
- scheduleIteratorConsumption(iter, patches => {
229
- setStore(d => {
230
- applyPatches(d, patches);
231
- });
232
- });
233
- return [store, setStore];
305
+ const loaded = sharedConfig.load(expectedId);
306
+ if (!isAsyncIterable(loaded)) return null;
307
+ const srcIt = loaded[Symbol.asyncIterator]();
308
+ let isFirst = true;
309
+ let buffered = null;
310
+ return coreFn(draft => {
311
+ const {
312
+ proxy
313
+ } = createShadowDraft(draft);
314
+ subFetch(fn, proxy);
315
+ const process = res => {
316
+ if (res.done) return {
317
+ done: true,
318
+ value: undefined
319
+ };
320
+ if (isFirst) {
321
+ isFirst = false;
322
+ setSnapshotCapture(false);
323
+ try {
324
+ if (Array.isArray(res.value)) {
325
+ for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i];
326
+ draft.length = res.value.length;
327
+ } else {
328
+ Object.assign(draft, res.value);
329
+ }
330
+ } finally {
331
+ setSnapshotCapture(true);
332
+ }
333
+ } else {
334
+ applyPatches(draft, res.value);
335
+ }
336
+ return {
337
+ done: false,
338
+ value: undefined
339
+ };
340
+ };
341
+ return {
342
+ [Symbol.asyncIterator]() {
343
+ return {
344
+ next() {
345
+ if (isFirst) {
346
+ const r = srcIt.next();
347
+ return r && typeof r.then === "function" ? {
348
+ then(fn, rej) {
349
+ r.then(v => fn(process(v)), rej);
350
+ }
351
+ } : syncThenable(process(r));
352
+ }
353
+ if (buffered) {
354
+ const b = buffered;
355
+ buffered = null;
356
+ return b.then(process);
357
+ }
358
+ let r = srcIt.next();
359
+ if (r && typeof r.then === "function") {
360
+ return r.then(process);
361
+ }
362
+ let result = process(r);
363
+ while (!r.done) {
364
+ const peek = srcIt.next();
365
+ if (peek && typeof peek.then === "function") {
366
+ buffered = peek;
367
+ break;
368
+ }
369
+ r = peek;
370
+ if (!r.done) result = process(r);
371
+ }
372
+ return Promise.resolve(result);
373
+ },
374
+ return(value) {
375
+ buffered = null;
376
+ return forwardIteratorReturn(srcIt, value);
377
+ }
378
+ };
379
+ }
380
+ };
381
+ }, initialValue, options);
234
382
  }
235
- function hydratedCreateMemo(compute, value, options) {
236
- if (!sharedConfig.hydrating) return createMemo$1(compute, value, options);
383
+ function hydratedCreateMemo(compute, options) {
384
+ if (!sharedConfig.hydrating || options?.transparent) {
385
+ return createMemo$1(compute, options);
386
+ }
237
387
  markTopLevelSnapshotScope();
238
388
  const ssrSource = options?.ssrSource;
239
389
  if (ssrSource === "client") {
240
- const [hydrated, setHydrated] = createSignal$1(false);
390
+ const [hydrated, setHydrated] = createSignal$1(false, {
391
+ ownedWrite: true
392
+ });
241
393
  const memo = createMemo$1(prev => {
242
- if (!hydrated()) return prev ?? value;
394
+ if (!hydrated()) return prev;
243
395
  return compute(prev);
244
- }, value, options);
396
+ }, options);
245
397
  setHydrated(true);
246
398
  return memo;
247
399
  }
248
- if (ssrSource === "initial") {
249
- return createMemo$1(prev => {
250
- if (!sharedConfig.hydrating) return compute(prev);
251
- subFetch(compute, prev);
252
- return prev ?? value;
253
- }, value, options);
254
- }
255
- const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
400
+ const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, options);
256
401
  if (aiResult !== null) return aiResult;
257
- return createMemo$1(prev => {
258
- const o = getOwner();
259
- if (!sharedConfig.hydrating) return compute(prev);
260
- let initP;
261
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
262
- const init = initP?.v ?? initP;
263
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
264
- }, value, options);
265
- }
266
- function hydratedCreateSignal(fn, second, third) {
267
- if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
402
+ return createMemo$1(prev => readSerializedOrCompute(compute, prev), options);
403
+ }
404
+ function hydratedCreateSignal(fn, second) {
405
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second);
268
406
  markTopLevelSnapshotScope();
269
- const ssrSource = third?.ssrSource;
407
+ const ssrSource = second?.ssrSource;
270
408
  if (ssrSource === "client") {
271
- const [hydrated, setHydrated] = createSignal$1(false);
409
+ const [hydrated, setHydrated] = createSignal$1(false, {
410
+ ownedWrite: true
411
+ });
272
412
  const sig = createSignal$1(prev => {
273
- if (!hydrated()) return prev ?? second;
413
+ if (!hydrated()) return prev;
274
414
  return fn(prev);
275
- }, second, third);
415
+ }, second);
276
416
  setHydrated(true);
277
417
  return sig;
278
418
  }
279
- if (ssrSource === "initial") {
280
- return createSignal$1(prev => {
281
- if (!sharedConfig.hydrating) return fn(prev);
282
- subFetch(fn, prev);
283
- return prev ?? second;
284
- }, second, third);
285
- }
286
- const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
419
+ const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second);
287
420
  if (aiResult !== null) return aiResult;
288
- return createSignal$1(prev => {
289
- if (!sharedConfig.hydrating) return fn(prev);
290
- const o = getOwner();
291
- let initP;
292
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
293
- const init = initP?.v ?? initP;
294
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
295
- }, second, third);
421
+ return createSignal$1(prev => readSerializedOrCompute(fn, prev), second);
296
422
  }
297
423
  function hydratedCreateErrorBoundary(fn, fallback) {
298
424
  if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
@@ -314,127 +440,113 @@ function hydratedCreateErrorBoundary(fn, fallback) {
314
440
  }
315
441
  return createErrorBoundary$1(fn, fallback);
316
442
  }
317
- function hydratedCreateOptimistic(fn, second, third) {
318
- if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second, third);
443
+ function hydratedCreateOptimistic(fn, second) {
444
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second);
319
445
  markTopLevelSnapshotScope();
320
- const ssrSource = third?.ssrSource;
446
+ const ssrSource = second?.ssrSource;
321
447
  if (ssrSource === "client") {
322
- const [hydrated, setHydrated] = createSignal$1(false);
448
+ const [hydrated, setHydrated] = createSignal$1(false, {
449
+ ownedWrite: true
450
+ });
323
451
  const sig = createOptimistic$1(prev => {
324
- if (!hydrated()) return prev ?? second;
452
+ if (!hydrated()) return prev;
325
453
  return fn(prev);
326
- }, second, third);
454
+ }, second);
327
455
  setHydrated(true);
328
456
  return sig;
329
457
  }
330
- if (ssrSource === "initial") {
331
- return createOptimistic$1(prev => {
332
- if (!sharedConfig.hydrating) return fn(prev);
333
- subFetch(fn, prev);
334
- return prev ?? second;
335
- }, second, third);
336
- }
337
- const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
458
+ const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second);
338
459
  if (aiResult !== null) return aiResult;
339
- return createOptimistic$1(prev => {
340
- const o = getOwner();
341
- if (!sharedConfig.hydrating) return fn(prev);
342
- let initP;
343
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
344
- const init = initP?.v ?? initP;
345
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
346
- }, second, third);
347
- }
348
- function wrapStoreFn(fn, ssrSource) {
349
- if (ssrSource === "initial") {
350
- return draft => {
351
- if (!sharedConfig.hydrating) return fn(draft);
352
- subFetch(fn, draft);
353
- return undefined;
354
- };
460
+ return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second);
461
+ }
462
+ function wrapStoreFn(fn) {
463
+ return draft => readSerializedOrCompute(() => fn(draft), draft);
464
+ }
465
+ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
466
+ if (ssrSource === "client") {
467
+ const [hydrated, setHydrated] = createSignal$1(false, {
468
+ ownedWrite: true
469
+ });
470
+ const result = coreFn(draft => {
471
+ if (!hydrated()) return;
472
+ return fn(draft);
473
+ }, initialValue, options);
474
+ setHydrated(true);
475
+ return result;
355
476
  }
356
- return draft => {
357
- const o = getOwner();
358
- if (!sharedConfig.hydrating) return fn(draft);
359
- let initP;
360
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
361
- const init = initP?.v ?? initP;
362
- return init != null ? (subFetch(fn, draft), init) : fn(draft);
363
- };
477
+ if (ssrSource === "hybrid") {
478
+ const [hydrated, setHydrated] = createSignal$1(false, {
479
+ ownedWrite: true
480
+ });
481
+ const result = coreFn(draft => {
482
+ const o = getOwner();
483
+ if (!hydrated()) {
484
+ if (sharedConfig.has(o.id)) {
485
+ const initP = sharedConfig.load(o.id);
486
+ const init = readHydratedValue(initP, () => subFetch(fn, draft));
487
+ if (init !== NO_HYDRATED_VALUE) return init;
488
+ }
489
+ return fn(draft);
490
+ }
491
+ const {
492
+ proxy,
493
+ activate
494
+ } = createShadowDraft(draft);
495
+ const r = fn(proxy);
496
+ return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
497
+ }, initialValue, options);
498
+ setHydrated(true);
499
+ return result;
500
+ }
501
+ const aiResult = hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options);
502
+ if (aiResult !== null) return aiResult;
503
+ return coreFn(wrapStoreFn(fn), initialValue, options);
364
504
  }
365
505
  function hydratedCreateStore(first, second, third) {
366
506
  if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
367
507
  markTopLevelSnapshotScope();
368
508
  const ssrSource = third?.ssrSource;
369
- if (ssrSource === "client" || ssrSource === "initial") {
370
- return createStore$1(second ?? {}, undefined, third);
371
- }
372
- const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
373
- if (aiResult !== null) return aiResult;
374
- return createStore$1(wrapStoreFn(first, ssrSource), second, third);
509
+ return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
375
510
  }
376
511
  function hydratedCreateOptimisticStore(first, second, third) {
377
512
  if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
378
513
  markTopLevelSnapshotScope();
379
514
  const ssrSource = third?.ssrSource;
380
- if (ssrSource === "client" || ssrSource === "initial") {
381
- return createOptimisticStore$1(second ?? {}, undefined, third);
382
- }
383
- const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
384
- if (aiResult !== null) return aiResult;
385
- return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
515
+ return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
386
516
  }
387
517
  function hydratedCreateProjection(fn, initialValue, options) {
388
518
  if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
389
519
  markTopLevelSnapshotScope();
390
520
  const ssrSource = options?.ssrSource;
391
- if (ssrSource === "client" || ssrSource === "initial") {
392
- return createProjection$1(draft => draft, initialValue, options);
393
- }
394
- const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options);
395
- if (aiResult !== null) return aiResult[0];
396
- return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
521
+ return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
397
522
  }
398
- function hydratedEffect(coreFn, compute, effectFn, value, options) {
399
- if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
523
+ function hydratedEffect(coreFn, compute, effectFn, options) {
524
+ if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
400
525
  const ssrSource = options?.ssrSource;
401
526
  if (ssrSource === "client") {
402
- const [hydrated, setHydrated] = createSignal$1(false);
527
+ const [hydrated, setHydrated] = createSignal$1(false, {
528
+ ownedWrite: true
529
+ });
403
530
  let active = false;
404
531
  coreFn(prev => {
405
- if (!hydrated()) return value;
532
+ if (!hydrated()) return prev;
406
533
  active = true;
407
534
  return compute(prev);
408
535
  }, (next, prev) => {
409
536
  if (!active) return;
410
537
  return effectFn(next, prev);
411
- }, value, options);
538
+ }, options);
412
539
  setHydrated(true);
413
540
  return;
414
541
  }
415
- if (ssrSource === "initial") {
416
- coreFn(prev => {
417
- if (!sharedConfig.hydrating) return compute(prev);
418
- subFetch(compute, prev);
419
- return prev ?? value;
420
- }, effectFn, value, options);
421
- return;
422
- }
423
542
  markTopLevelSnapshotScope();
424
- coreFn(prev => {
425
- const o = getOwner();
426
- if (!sharedConfig.hydrating) return compute(prev);
427
- let initP;
428
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
429
- const init = initP?.v ?? initP;
430
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
431
- }, effectFn, value, options);
543
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
432
544
  }
433
- function hydratedCreateRenderEffect(compute, effectFn, value, options) {
434
- return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options);
545
+ function hydratedCreateRenderEffect(compute, effectFn, options) {
546
+ return hydratedEffect(createRenderEffect$1, compute, effectFn, options);
435
547
  }
436
- function hydratedCreateEffect(compute, effectFn, value, options) {
437
- return hydratedEffect(createEffect$1, compute, effectFn, value, options);
548
+ function hydratedCreateEffect(compute, effectFn, options) {
549
+ return hydratedEffect(createEffect$1, compute, effectFn, options);
438
550
  }
439
551
  function enableHydration() {
440
552
  _createMemo = hydratedCreateMemo;
@@ -493,24 +605,6 @@ const createStore = (...args) => (_createStore || createStore$1)(...args);
493
605
  const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args);
494
606
  const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args);
495
607
  const createEffect = (...args) => (_createEffect || createEffect$1)(...args);
496
- function loadModuleAssets(mapping) {
497
- const hy = globalThis._$HY;
498
- if (!hy) return;
499
- if (!hy.modules) hy.modules = {};
500
- if (!hy.loading) hy.loading = {};
501
- const pending = [];
502
- for (const moduleUrl in mapping) {
503
- if (hy.modules[moduleUrl]) continue;
504
- const entryUrl = mapping[moduleUrl];
505
- if (!hy.loading[moduleUrl]) {
506
- hy.loading[moduleUrl] = import(entryUrl).then(mod => {
507
- hy.modules[moduleUrl] = mod;
508
- });
509
- }
510
- pending.push(hy.loading[moduleUrl]);
511
- }
512
- return pending.length ? Promise.all(pending).then(() => {}) : undefined;
513
- }
514
608
  function createBoundaryTrigger() {
515
609
  setSnapshotCapture(false);
516
610
  const [s, set] = createSignal$1(undefined, {
@@ -526,7 +620,7 @@ function resumeBoundaryHydration(o, id, set) {
526
620
  checkHydrationComplete();
527
621
  return;
528
622
  }
529
- sharedConfig.gather(id);
623
+ sharedConfig.gather?.(id);
530
624
  _hydratingValue = true;
531
625
  markSnapshotScope(o);
532
626
  _snapshotRootOwner = o;
@@ -538,38 +632,65 @@ function resumeBoundaryHydration(o, id, set) {
538
632
  flush();
539
633
  checkHydrationComplete();
540
634
  }
541
- function Loading(props) {
542
- if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
635
+ function initBoundaryResume(o, id) {
636
+ _pendingBoundaries++;
637
+ onCleanup(() => {
638
+ if (!isDisposed(o)) return;
639
+ sharedConfig.cleanupFragment?.(id);
640
+ });
641
+ const set = createBoundaryTrigger();
642
+ return [set, () => resumeBoundaryHydration(o, id, set)];
643
+ }
644
+ function waitAndResume(p, resume, assetPromise) {
645
+ const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
646
+ waitFor.then(() => {
647
+ if (p && typeof p === "object") p.s = 1;
648
+ resume();
649
+ }, err => {
650
+ if (p && typeof p === "object") {
651
+ p.s = 2;
652
+ p.v = err;
653
+ }
654
+ resume();
655
+ });
656
+ }
657
+ function scheduleResumeAfterAssets(id, resume, assetPromise) {
658
+ sharedConfig.gather?.(id);
659
+ const doResume = () => queueMicrotask(resume);
660
+ if (assetPromise) {
661
+ assetPromise.then(doResume);
662
+ return true;
663
+ }
664
+ doResume();
665
+ return false;
666
+ }
667
+ function createLoadingBoundary(fn, fallback, options) {
668
+ if (!sharedConfig.hydrating) return createLoadingBoundary$1(fn, fallback, options);
669
+ let settledSerializationResumeQueued = false;
543
670
  return createMemo$1(() => {
544
671
  const o = getOwner();
545
672
  const id = o.id;
546
673
  let assetPromise;
547
674
  if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
548
675
  const mapping = sharedConfig.load(id + "_assets");
549
- if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
676
+ if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
550
677
  }
551
678
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
552
- let ref = sharedConfig.load(id);
679
+ const ref = sharedConfig.load(id);
553
680
  let p;
554
681
  if (ref) {
555
- if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
682
+ if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
683
+ }
684
+ if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
685
+ settledSerializationResumeQueued = true;
686
+ const [, resume] = initBoundaryResume(o, id);
687
+ if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
688
+ return fallback();
556
689
  }
557
690
  if (p) {
558
- _pendingBoundaries++;
559
- onCleanup(() => {
560
- if (!isDisposed(o)) return;
561
- sharedConfig.cleanupFragment?.(id);
562
- });
563
- const set = createBoundaryTrigger();
691
+ const [set, resume] = initBoundaryResume(o, id);
564
692
  if (p !== "$$f") {
565
- const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
566
- waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
567
- _pendingBoundaries--;
568
- checkHydrationComplete();
569
- runWithOwner(o, () => {
570
- throw err;
571
- });
572
- });
693
+ waitAndResume(p, resume, assetPromise);
573
694
  } else {
574
695
  const afterAssets = () => {
575
696
  _pendingBoundaries--;
@@ -578,16 +699,26 @@ function Loading(props) {
578
699
  };
579
700
  if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
580
701
  }
581
- return props.fallback;
702
+ return fallback();
582
703
  }
583
704
  }
584
- if (assetPromise) {
585
- _pendingBoundaries++;
586
- const set = createBoundaryTrigger();
587
- assetPromise.then(() => resumeBoundaryHydration(o, id, set));
705
+ if (sharedConfig.hydrating && sharedConfig.has(id + "_fr") && !settledSerializationResumeQueued) {
706
+ settledSerializationResumeQueued = true;
707
+ const fr = sharedConfig.load(id + "_fr");
708
+ const [, resume] = initBoundaryResume(o, id);
709
+ if (fr && typeof fr === "object" && (fr.s === 1 || fr.s === 2)) {
710
+ if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
711
+ return fallback();
712
+ }
713
+ waitAndResume(fr, resume, assetPromise);
714
+ return fallback();
715
+ }
716
+ if (assetPromise && !sharedConfig.has(id)) {
717
+ const [, resume] = initBoundaryResume(o, id);
718
+ assetPromise.then(resume);
588
719
  return undefined;
589
720
  }
590
- return createLoadBoundary(() => props.children, () => props.fallback);
721
+ return createLoadingBoundary$1(fn, fallback, options);
591
722
  });
592
723
  }
593
724
  function NoHydration(props) {
@@ -661,10 +792,10 @@ function Repeat(props) {
661
792
  }
662
793
  function Show(props) {
663
794
  const keyed = props.keyed;
664
- const conditionValue = createMemo$1(() => props.when, undefined, {
795
+ const conditionValue = createMemo$1(() => props.when, {
665
796
  name: "condition value"
666
797
  } );
667
- const condition = keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
798
+ const condition = keyed ? conditionValue : createMemo$1(conditionValue, {
668
799
  equals: (a, b) => !a === !b,
669
800
  name: "condition"
670
801
  } );
@@ -673,20 +804,13 @@ function Show(props) {
673
804
  if (c) {
674
805
  const child = props.children;
675
806
  const fn = typeof child === "function" && child.length > 0;
676
- return fn ? untrack(() => {
677
- setStrictRead("<Show>");
678
- try {
679
- return child(() => {
680
- if (!untrack(condition)) throw narrowedError("Show");
681
- return conditionValue();
682
- });
683
- } finally {
684
- setStrictRead(false);
685
- }
686
- }) : child;
807
+ return fn ? untrack(() => child(() => {
808
+ if (!untrack(condition)) throw narrowedError("Show");
809
+ return conditionValue();
810
+ }), "<Show>") : child;
687
811
  }
688
812
  return props.fallback;
689
- }, undefined, {
813
+ }, {
690
814
  name: "value"
691
815
  } );
692
816
  }
@@ -699,10 +823,10 @@ function Switch(props) {
699
823
  const index = i;
700
824
  const mp = mps[i];
701
825
  const prevFunc = func;
702
- const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined, {
826
+ const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, {
703
827
  name: "condition value"
704
828
  } );
705
- const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
829
+ const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, {
706
830
  equals: (a, b) => !a === !b,
707
831
  name: "condition"
708
832
  } );
@@ -716,18 +840,11 @@ function Switch(props) {
716
840
  const [index, conditionValue, mp] = sel;
717
841
  const child = mp.children;
718
842
  const fn = typeof child === "function" && child.length > 0;
719
- return fn ? untrack(() => {
720
- setStrictRead("<Match>");
721
- try {
722
- return child(() => {
723
- if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
724
- return conditionValue();
725
- });
726
- } finally {
727
- setStrictRead(false);
728
- }
729
- }) : child;
730
- }, undefined, {
843
+ return fn ? untrack(() => child(() => {
844
+ if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
845
+ return conditionValue();
846
+ }), "<Match>") : child;
847
+ }, {
731
848
  name: "eval conditions"
732
849
  } );
733
850
  }
@@ -741,16 +858,24 @@ function Errored(props) {
741
858
  return typeof f === "function" && f.length ? f(err, reset) : f;
742
859
  });
743
860
  }
861
+ function Loading(props) {
862
+ const onOpt = "on" in props ? {
863
+ on: () => props.on
864
+ } : undefined;
865
+ return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
866
+ }
867
+ function Reveal(props) {
868
+ return createRevealOrder(() => props.children, {
869
+ order: () => props.order ?? "sequential",
870
+ collapsed: () => !!props.collapsed
871
+ });
872
+ }
744
873
 
745
874
  function ssrHandleError() {}
746
875
  function ssrRunInScope() {}
747
- const DevHooks = {};
748
- const DEV = {
749
- hooks: DevHooks,
750
- registerGraph
751
- } ;
876
+ const DEV = DEV$1 ;
752
877
  if (globalThis) {
753
878
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
754
879
  }
755
880
 
756
- export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
881
+ export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };