solid-js 2.0.0-experimental.14 → 2.0.0-experimental.16

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/server.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getOwner, getNextChildId, createOwner, runWithOwner, isWrappable, NotReadyError, setContext, getContext, createRoot, flatten } from '@solidjs/signals';
2
- export { $PROXY, $TRACK, NotReadyError, createRoot, flatten, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot } from '@solidjs/signals';
1
+ import { getOwner, getNextChildId, createOwner, runWithOwner, onCleanup, NotReadyError, isWrappable, setContext, getContext, flatten, createRoot } from '@solidjs/signals';
2
+ export { $PROXY, $TRACK, NotReadyError, createOwner, createRoot, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot, storePath } from '@solidjs/signals';
3
3
 
4
4
  const sharedConfig = {
5
5
  getNextContextId() {
@@ -24,12 +24,24 @@ function getObserver() {
24
24
  }
25
25
  function createSignal(first, second, third) {
26
26
  if (typeof first === "function") {
27
+ const ssrSource = third?.ssrSource;
28
+ if (ssrSource === "initial" || ssrSource === "client") {
29
+ createOwner();
30
+ let value = second;
31
+ return [() => value, v => {
32
+ return value = typeof v === "function" ? v(value) : v;
33
+ }];
34
+ }
35
+ const memoOpts = third?.deferStream || ssrSource ? {
36
+ deferStream: third?.deferStream,
37
+ ssrSource
38
+ } : undefined;
27
39
  const memo = createMemo(p => {
28
40
  let value = first(p ? p[0]() : second);
29
41
  return [() => value, v => {
30
42
  return value = typeof v === "function" ? v(value) : v;
31
43
  }];
32
- });
44
+ }, undefined, memoOpts);
33
45
  return [() => memo()[0](), v => memo()[1](v)];
34
46
  }
35
47
  return [() => first, v => {
@@ -44,14 +56,19 @@ function createMemo(compute, value, options) {
44
56
  value: value,
45
57
  compute: compute,
46
58
  error: undefined,
47
- computed: false
59
+ computed: false,
60
+ disposed: false
48
61
  };
62
+ runWithOwner(owner, () => onCleanup(() => {
63
+ comp.disposed = true;
64
+ }));
49
65
  function update() {
66
+ if (comp.disposed) return;
50
67
  try {
51
68
  comp.error = undefined;
52
69
  const result = runWithOwner(owner, () => runWithObserver(comp, () => comp.compute(comp.value)));
53
70
  comp.computed = true;
54
- processResult(comp, result, owner, ctx);
71
+ processResult(comp, result, owner, ctx, options?.deferStream, options?.ssrSource);
55
72
  } catch (err) {
56
73
  if (err instanceof NotReadyError) {
57
74
  err.source?.then(() => update());
@@ -60,7 +77,10 @@ function createMemo(compute, value, options) {
60
77
  comp.computed = true;
61
78
  }
62
79
  }
63
- if (!options?.lazy) {
80
+ const ssrSource = options?.ssrSource;
81
+ if (ssrSource === "initial" || ssrSource === "client") {
82
+ comp.computed = true;
83
+ } else if (!options?.lazy) {
64
84
  update();
65
85
  }
66
86
  return () => {
@@ -73,16 +93,79 @@ function createMemo(compute, value, options) {
73
93
  return comp.value;
74
94
  };
75
95
  }
76
- function processResult(comp, result, owner, ctx) {
96
+ function createDeepProxy(target, patches, basePath = []) {
97
+ const childProxies = new Map();
98
+ const handler = {
99
+ get(obj, key, receiver) {
100
+ if (Array.isArray(obj)) {
101
+ if (key === "shift") {
102
+ return function () {
103
+ if (obj.length === 0) return undefined;
104
+ const removed = obj[0];
105
+ Array.prototype.shift.call(obj);
106
+ childProxies.clear();
107
+ patches.push([[...basePath, 0]]);
108
+ return removed;
109
+ };
110
+ }
111
+ if (key === "unshift") {
112
+ return function (...items) {
113
+ const result = Array.prototype.unshift.apply(obj, items);
114
+ childProxies.clear();
115
+ for (let i = 0; i < items.length; i++) {
116
+ patches.push([[...basePath, i], items[i], 1]);
117
+ }
118
+ return result;
119
+ };
120
+ }
121
+ if (key === "splice") {
122
+ return function (start, deleteCount, ...items) {
123
+ const len = obj.length;
124
+ const s = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
125
+ const d = deleteCount === undefined ? len - s : Math.min(Math.max(deleteCount, 0), len - s);
126
+ const removed = Array.prototype.splice.apply(obj, [s, d, ...items]);
127
+ childProxies.clear();
128
+ for (let i = 0; i < d; i++) patches.push([[...basePath, s]]);
129
+ for (let i = 0; i < items.length; i++) patches.push([[...basePath, s + i], items[i], 1]);
130
+ return removed;
131
+ };
132
+ }
133
+ }
134
+ const value = Reflect.get(obj, key, receiver);
135
+ if (value !== null && typeof value === "object" && typeof key !== "symbol") {
136
+ if (!childProxies.has(key)) {
137
+ childProxies.set(key, createDeepProxy(value, patches, [...basePath, key]));
138
+ }
139
+ return childProxies.get(key);
140
+ }
141
+ return value;
142
+ },
143
+ set(obj, key, value) {
144
+ childProxies.delete(key);
145
+ patches.push([[...basePath, key], value]);
146
+ return Reflect.set(obj, key, value);
147
+ },
148
+ deleteProperty(obj, key) {
149
+ childProxies.delete(key);
150
+ patches.push([[...basePath, key]]);
151
+ return Reflect.deleteProperty(obj, key);
152
+ }
153
+ };
154
+ return new Proxy(target, handler);
155
+ }
156
+ function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
157
+ if (comp.disposed) return;
77
158
  const id = owner.id;
78
159
  const uninitialized = comp.value === undefined;
79
160
  if (result instanceof Promise) {
80
161
  result.then(v => {
81
162
  result.s = 1;
82
- result.v = comp.value = v;
163
+ result.v = v;
164
+ if (comp.disposed) return;
165
+ comp.value = v;
83
166
  comp.error = undefined;
84
- });
85
- if (ctx?.serialize && id) ctx.serialize(id, result);
167
+ }, () => {});
168
+ if (ctx?.async && ctx.serialize && id) ctx.serialize(id, result, deferStream);
86
169
  if (uninitialized) {
87
170
  comp.error = new NotReadyError(result);
88
171
  }
@@ -91,37 +174,87 @@ function processResult(comp, result, owner, ctx) {
91
174
  const iterator = result?.[Symbol.asyncIterator];
92
175
  if (typeof iterator === "function") {
93
176
  const iter = iterator.call(result);
94
- const promise = iter.next().then(v => {
95
- promise.s = 1;
96
- promise.v = comp.value = v.value;
97
- comp.error = undefined;
98
- });
99
- if (ctx?.serialize && id) ctx.serialize(id, promise);
100
- if (uninitialized) {
101
- comp.error = new NotReadyError(promise);
177
+ if (ssrSource === "hybrid") {
178
+ const promise = iter.next().then(v => {
179
+ promise.s = 1;
180
+ promise.v = v.value;
181
+ if (comp.disposed) return;
182
+ comp.value = v.value;
183
+ comp.error = undefined;
184
+ }, () => {});
185
+ if (ctx?.async && ctx.serialize && id) ctx.serialize(id, promise, deferStream);
186
+ if (uninitialized) {
187
+ comp.error = new NotReadyError(promise);
188
+ }
189
+ } else {
190
+ const firstNext = iter.next();
191
+ const firstReady = firstNext.then(r => {
192
+ if (comp.disposed) return;
193
+ if (!r.done) {
194
+ comp.value = r.value;
195
+ comp.error = undefined;
196
+ }
197
+ }, () => {});
198
+ let servedFirst = false;
199
+ const tapped = {
200
+ [Symbol.asyncIterator]: () => ({
201
+ next() {
202
+ if (!servedFirst) {
203
+ servedFirst = true;
204
+ return firstNext.then(r => {
205
+ if (!r.done && !comp.disposed) comp.value = r.value;
206
+ return r;
207
+ });
208
+ }
209
+ return iter.next().then(r => r);
210
+ }
211
+ })
212
+ };
213
+ if (ctx?.async && ctx.serialize && id) ctx.serialize(id, tapped, deferStream);
214
+ if (uninitialized) {
215
+ comp.error = new NotReadyError(firstReady);
216
+ }
102
217
  }
103
218
  return;
104
219
  }
105
220
  comp.value = result;
106
221
  }
107
- function createEffect(compute, effect, value, options) {
108
- const o = getOwner();
109
- if (o?.id != null) getNextChildId(o);
110
- }
111
- function createRenderEffect(compute, effectFn, value, options) {
222
+ function serverEffect(compute, effectFn, value, options) {
223
+ const ssrSource = options?.ssrSource;
224
+ if (ssrSource === "client" || ssrSource === "initial") {
225
+ createOwner();
226
+ return;
227
+ }
228
+ const ctx = sharedConfig.context;
112
229
  const owner = createOwner();
230
+ const comp = {
231
+ owner,
232
+ value: value,
233
+ compute: compute,
234
+ error: undefined,
235
+ computed: true,
236
+ disposed: false
237
+ };
238
+ if (ssrSource) {
239
+ runWithOwner(owner, () => onCleanup(() => {
240
+ comp.disposed = true;
241
+ }));
242
+ }
113
243
  try {
114
- const result = runWithOwner(owner, () => runWithObserver({
115
- owner,
116
- value: value,
117
- compute: compute,
118
- error: undefined,
119
- computed: true
120
- }, () => compute(value)));
121
- effectFn(result, value);
244
+ const result = runWithOwner(owner, () => runWithObserver(comp, () => compute(value)));
245
+ if (ssrSource) {
246
+ processResult(comp, result, owner, ctx, options?.deferStream, ssrSource);
247
+ }
248
+ effectFn?.(ssrSource ? comp.value ?? result : result, value);
122
249
  } catch (err) {
123
250
  }
124
251
  }
252
+ function createEffect(compute, effect, value, options) {
253
+ serverEffect(compute, undefined, value, options);
254
+ }
255
+ function createRenderEffect(compute, effectFn, value, options) {
256
+ serverEffect(compute, effectFn, value, options);
257
+ }
125
258
  function createTrackedEffect(compute, options) {
126
259
  const o = getOwner();
127
260
  if (o?.id != null) getNextChildId(o);
@@ -132,7 +265,7 @@ function createReaction(effectFn, options) {
132
265
  };
133
266
  }
134
267
  function createOptimistic(first, second, third) {
135
- return createSignal(first, second);
268
+ return createSignal(first, second, third);
136
269
  }
137
270
  function setProperty(state, property, value) {
138
271
  if (state[property] === value) return;
@@ -140,16 +273,145 @@ function setProperty(state, property, value) {
140
273
  delete state[property];
141
274
  } else state[property] = value;
142
275
  }
143
- function createStore(state) {
144
- function setStore(fn) {
145
- fn(state);
276
+ function createStore(first, second) {
277
+ if (typeof first === "function") {
278
+ const store = createProjection(first, second ?? {});
279
+ return [store, fn => fn(store)];
146
280
  }
147
- return [state, setStore];
281
+ const state = first;
282
+ return [state, fn => fn(state)];
148
283
  }
149
284
  const createOptimisticStore = createStore;
150
- function createProjection(fn, initialValue = {}) {
285
+ function createPendingProxy(state, source) {
286
+ let pending = true;
287
+ let readTarget = state;
288
+ const proxy = new Proxy(state, {
289
+ get(obj, key, receiver) {
290
+ if (pending && typeof key !== "symbol") {
291
+ throw new NotReadyError(source);
292
+ }
293
+ return Reflect.get(readTarget, key);
294
+ }
295
+ });
296
+ return [proxy, frozen => {
297
+ if (frozen) readTarget = frozen;
298
+ pending = false;
299
+ }];
300
+ }
301
+ function createProjection(fn, initialValue = {}, options) {
302
+ const ctx = sharedConfig.context;
303
+ const owner = createOwner();
151
304
  const [state] = createStore(initialValue);
152
- fn(state);
305
+ if (options?.ssrSource === "initial" || options?.ssrSource === "client") {
306
+ return state;
307
+ }
308
+ let disposed = false;
309
+ runWithOwner(owner, () => onCleanup(() => {
310
+ disposed = true;
311
+ }));
312
+ const ssrSource = options?.ssrSource;
313
+ const useProxy = ssrSource !== "hybrid";
314
+ const patches = [];
315
+ const draft = useProxy ? createDeepProxy(state, patches) : state;
316
+ const result = runWithOwner(owner, () => fn(draft));
317
+ const iteratorFn = result?.[Symbol.asyncIterator];
318
+ if (typeof iteratorFn === "function") {
319
+ const iter = iteratorFn.call(result);
320
+ if (ssrSource === "hybrid") {
321
+ const promise = iter.next().then(r => {
322
+ promise.s = 1;
323
+ if (disposed) {
324
+ promise.v = state;
325
+ return;
326
+ }
327
+ if (r.value !== undefined && r.value !== state) {
328
+ Object.assign(state, r.value);
329
+ }
330
+ promise.v = state;
331
+ markReady();
332
+ }, () => {});
333
+ if (ctx?.async && !ctx.noHydrate && owner.id) ctx.serialize(owner.id, promise, options?.deferStream);
334
+ const [pending, markReady] = createPendingProxy(state, promise);
335
+ return pending;
336
+ } else {
337
+ const firstNext = iter.next();
338
+ const firstReady = firstNext.then(r => {
339
+ if (disposed) return;
340
+ patches.length = 0;
341
+ if (!r.done) {
342
+ if (r.value !== undefined && r.value !== draft) {
343
+ Object.assign(state, r.value);
344
+ }
345
+ }
346
+ markReady(JSON.parse(JSON.stringify(state)));
347
+ }, () => {
348
+ markReady();
349
+ });
350
+ let servedFirst = false;
351
+ const tapped = {
352
+ [Symbol.asyncIterator]: () => ({
353
+ next() {
354
+ if (!servedFirst) {
355
+ servedFirst = true;
356
+ return firstNext.then(r => {
357
+ if (!r.done && !disposed) return {
358
+ done: false,
359
+ value: state
360
+ };
361
+ return {
362
+ done: r.done,
363
+ value: undefined
364
+ };
365
+ });
366
+ }
367
+ return iter.next().then(r => {
368
+ if (disposed) return {
369
+ done: true,
370
+ value: undefined
371
+ };
372
+ const flushed = patches.splice(0);
373
+ if (!r.done) {
374
+ if (r.value !== undefined && r.value !== draft) {
375
+ Object.assign(state, r.value);
376
+ }
377
+ return {
378
+ done: false,
379
+ value: flushed
380
+ };
381
+ }
382
+ return {
383
+ done: true,
384
+ value: undefined
385
+ };
386
+ });
387
+ }
388
+ })
389
+ };
390
+ if (ctx?.async && !ctx.noHydrate && owner.id) ctx.serialize(owner.id, tapped, options?.deferStream);
391
+ const [pending, markReady] = createPendingProxy(state, firstReady);
392
+ return pending;
393
+ }
394
+ }
395
+ if (result instanceof Promise) {
396
+ const promise = result.then(v => {
397
+ promise.s = 1;
398
+ if (disposed) {
399
+ promise.v = state;
400
+ return;
401
+ }
402
+ if (v !== undefined && v !== state) {
403
+ Object.assign(state, v);
404
+ }
405
+ promise.v = state;
406
+ markReady();
407
+ }, () => {});
408
+ if (ctx?.async && !ctx.noHydrate && owner.id) ctx.serialize(owner.id, promise, options?.deferStream);
409
+ const [pending, markReady] = createPendingProxy(state, promise);
410
+ return pending;
411
+ }
412
+ if (result !== undefined && result !== state && result !== draft) {
413
+ Object.assign(state, result);
414
+ }
153
415
  return state;
154
416
  }
155
417
  function reconcile(value) {
@@ -188,12 +450,23 @@ function mapArray(list, mapFn, options = {}) {
188
450
  };
189
451
  }
190
452
  function repeat(count, mapFn, options = {}) {
453
+ const owner = createOwner();
191
454
  const len = count();
192
455
  const offset = options.from?.() || 0;
193
456
  let s = [];
194
457
  if (len) {
195
- for (let i = 0; i < len; i++) s.push(mapFn(i + offset));
196
- } else if (options.fallback) s = [options.fallback()];
458
+ runWithOwner(owner, () => {
459
+ for (let i = 0; i < len; i++) {
460
+ const itemOwner = createOwner();
461
+ s.push(runWithOwner(itemOwner, () => mapFn(i + offset)));
462
+ }
463
+ });
464
+ } else if (options.fallback) {
465
+ s = [runWithOwner(owner, () => {
466
+ const fo = createOwner();
467
+ return runWithOwner(fo, () => options.fallback());
468
+ })];
469
+ }
197
470
  return () => s;
198
471
  }
199
472
  const ErrorContext = {
@@ -201,15 +474,21 @@ const ErrorContext = {
201
474
  defaultValue: null
202
475
  };
203
476
  function createErrorBoundary(fn, fallback) {
477
+ const ctx = sharedConfig.context;
204
478
  const owner = createOwner();
479
+ const parent = getOwner();
480
+ if (parent?.id != null) getNextChildId(parent);
481
+ owner.id = owner.id + "0";
205
482
  return runWithOwner(owner, () => {
206
483
  let result;
207
484
  setContext(ErrorContext, err => {
485
+ if (ctx && !ctx.noHydrate && owner.id) ctx.serialize(owner.id, err);
208
486
  result = fallback(err, () => {});
209
487
  });
210
488
  try {
211
489
  result = fn();
212
490
  } catch (err) {
491
+ if (ctx && !ctx.noHydrate && owner.id) ctx.serialize(owner.id, err);
213
492
  result = fallback(err, () => {});
214
493
  }
215
494
  return () => result;
@@ -244,7 +523,7 @@ function isPending(fn, fallback) {
244
523
  throw err;
245
524
  }
246
525
  }
247
- function pending(fn) {
526
+ function latest(fn) {
248
527
  return fn();
249
528
  }
250
529
  function isRefreshing() {
@@ -278,29 +557,29 @@ function useContext(context) {
278
557
  return getContext(context);
279
558
  }
280
559
  function children(fn) {
281
- const childrenMemo = createMemo(fn);
282
- const memo = createMemo(() => flatten(childrenMemo()));
560
+ const c = createMemo(fn, undefined, {
561
+ lazy: true
562
+ });
563
+ const memo = createMemo(() => flatten(c()), undefined, {
564
+ lazy: true
565
+ });
283
566
  memo.toArray = () => {
284
- const c = memo();
285
- return Array.isArray(c) ? c : c != null ? [c] : [];
567
+ const v = memo();
568
+ return Array.isArray(v) ? v : v != null ? [v] : [];
286
569
  };
287
570
  return memo;
288
571
  }
289
572
  function ssrRunInScope(fn) {
290
- if (Array.isArray(fn)) {
291
- const o = createOwner();
292
- return fn.map(f => runWithOwner.bind(null, o, f));
293
- }
294
- return runWithOwner.bind(null, createOwner(), fn);
573
+ return fn;
295
574
  }
296
575
 
297
576
  function enableHydration() {}
298
577
  function createComponent(Comp, props) {
299
578
  return Comp(props || {});
300
579
  }
301
- function lazy(fn) {
580
+ function lazy(fn, moduleUrl) {
302
581
  let p;
303
- let load = id => {
582
+ let load = () => {
304
583
  if (!p) {
305
584
  p = fn();
306
585
  p.then(mod => {
@@ -310,15 +589,30 @@ function lazy(fn) {
310
589
  return p;
311
590
  };
312
591
  const wrap = props => {
313
- sharedConfig.getNextContextId();
592
+ if (!moduleUrl) {
593
+ throw new Error("lazy() used in SSR without a moduleUrl. " + "All lazy() components require a moduleUrl for correct hydration. " + "This is typically injected by the bundler plugin.");
594
+ }
595
+ if (!sharedConfig.context?.resolveAssets) {
596
+ throw new Error(`lazy() called with moduleUrl "${moduleUrl}" but no asset manifest is set. ` + "Pass a manifest option to renderToStream/renderToString.");
597
+ }
314
598
  load();
315
- if (p.v) return p.v(props);
316
- if (sharedConfig.context?.async) {
317
- sharedConfig.context.block(p.then(() => {
599
+ const ctx = sharedConfig.context;
600
+ if (!ctx?.registerAsset || !ctx.resolveAssets) return;
601
+ const assets = ctx.resolveAssets(moduleUrl);
602
+ if (assets) {
603
+ for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
604
+ for (let i = 0; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
605
+ ctx.registerModule?.(moduleUrl, assets.js[0]);
606
+ }
607
+ if (ctx?.async) {
608
+ ctx.block(p.then(() => {
318
609
  p.s = "success";
319
610
  }));
320
611
  }
321
- throw new NotReadyError(p);
612
+ return createMemo(() => {
613
+ if (!p.v) throw new NotReadyError(p);
614
+ return p.v(props);
615
+ });
322
616
  };
323
617
  wrap.preload = load;
324
618
  return wrap;
@@ -344,20 +638,27 @@ function Repeat(props) {
344
638
  return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
345
639
  }
346
640
  function Show(props) {
347
- const when = props.when;
348
- if (when) {
349
- const child = props.children;
350
- if (typeof child === "function" && child.length > 0) {
351
- return child(() => when);
352
- }
353
- return child;
641
+ const o = getOwner();
642
+ if (o?.id != null) {
643
+ getNextChildId(o);
644
+ if (!props.keyed) getNextChildId(o);
354
645
  }
355
- return props.fallback;
646
+ return createMemo(() => {
647
+ const when = props.when;
648
+ if (when) {
649
+ const child = props.children;
650
+ if (typeof child === "function" && child.length > 0) {
651
+ return child(() => when);
652
+ }
653
+ return child;
654
+ }
655
+ return props.fallback;
656
+ });
356
657
  }
357
658
  function Switch(props) {
358
659
  const chs = children(() => props.children);
359
660
  const o = getOwner();
360
- if (o) getNextChildId(o);
661
+ if (o?.id != null) getNextChildId(o);
361
662
  return createMemo(() => {
362
663
  let conds = chs();
363
664
  if (!Array.isArray(conds)) conds = [conds];
@@ -401,18 +702,35 @@ function Loading(props) {
401
702
  const id = o.id;
402
703
  o.id = id + "00";
403
704
  let runPromise;
705
+ let serializeBuffer = [];
706
+ const origSerialize = ctx.serialize;
404
707
  function runInitially() {
405
708
  o.dispose(false);
406
- return runWithOwner(o, () => {
709
+ serializeBuffer = [];
710
+ ctx.serialize = (id, p, deferStream) => {
711
+ serializeBuffer.push([id, p, deferStream]);
712
+ };
713
+ const prevBoundary = ctx._currentBoundaryId;
714
+ ctx._currentBoundaryId = id;
715
+ const result = runWithOwner(o, () => {
407
716
  try {
408
- return ctx.resolve(flatten(props.children));
717
+ return ctx.resolve(props.children);
409
718
  } catch (err) {
410
719
  runPromise = ssrHandleError(err);
411
720
  }
412
721
  });
722
+ ctx._currentBoundaryId = prevBoundary;
723
+ ctx.serialize = origSerialize;
724
+ return result;
413
725
  }
414
726
  let ret = runInitially();
415
- if (!(runPromise || ret?.p?.length)) return ret;
727
+ if (!(runPromise || ret?.p?.length)) {
728
+ for (const args of serializeBuffer) origSerialize(args[0], args[1], args[2]);
729
+ serializeBuffer = [];
730
+ const modules = ctx.getBoundaryModules?.(id);
731
+ if (modules) ctx.serialize(id + "_assets", modules);
732
+ return ret;
733
+ }
416
734
  const fallbackOwner = createOwner({
417
735
  id
418
736
  });
@@ -420,23 +738,34 @@ function Loading(props) {
420
738
  if (ctx.async) {
421
739
  const done = ctx.registerFragment(id);
422
740
  (async () => {
423
- while (runPromise) {
424
- await runPromise;
425
- runPromise = undefined;
426
- ret = runInitially();
427
- }
428
- while (ret.p.length) {
429
- await Promise.all(ret.p);
430
- ret = ctx.ssr(ret.t, ...ret.h);
741
+ try {
742
+ while (runPromise) {
743
+ o.dispose(false);
744
+ await runPromise;
745
+ runPromise = undefined;
746
+ ret = runInitially();
747
+ }
748
+ for (const args of serializeBuffer) origSerialize(args[0], args[1], args[2]);
749
+ serializeBuffer = [];
750
+ while (ret.p.length) {
751
+ await Promise.all(ret.p);
752
+ ret = runWithOwner(o, () => ctx.ssr(ret.t, ...ret.h));
753
+ }
754
+ done(ret.t[0]);
755
+ } catch (err) {
756
+ done(undefined, err);
431
757
  }
432
- done(ret.t[0]);
433
758
  })();
434
759
  return runWithOwner(fallbackOwner, () => ctx.ssr([`<template id="pl-${id}"></template>`, `<!--pl-${id}-->`], ctx.escape(props.fallback)));
435
760
  }
761
+ for (const args of serializeBuffer) origSerialize(args[0], args[1], args[2]);
762
+ serializeBuffer = [];
763
+ const modules = ctx.getBoundaryModules?.(id);
764
+ if (modules) ctx.serialize(id + "_assets", modules);
436
765
  ctx.serialize(id, "$$f");
437
766
  return runWithOwner(fallbackOwner, () => props.fallback);
438
767
  }
439
768
 
440
769
  const DEV = undefined;
441
770
 
442
- export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, action, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, lazy, mapArray, onSettled, pending, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };
771
+ export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };