@solidjs/web 2.0.0-rc.20 → 2.0.0-rc.21

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/web.js CHANGED
@@ -390,16 +390,11 @@ function render(code, element, init, options = {}) {
390
390
  createRoot(dispose => {
391
391
  disposer = dispose;
392
392
  if (options.onError) getOwner()[ROOT_ERROR_HOOK] = options.onError;
393
- if (element === document) {
394
- const tree = code();
395
- effect(() => flatten(tree), () => {});
396
- } else {
397
- const tree = code();
398
- insert(element, () => tree, element.firstChild ? null : undefined, init, {
399
- ...options.insertOptions,
400
- schedule: true
401
- });
402
- }
393
+ const tree = code();
394
+ if (element === document) effect(() => flatten(tree), () => {});else insert(element, () => tree, element.firstChild ? null : undefined, init, {
395
+ ...options.insertOptions,
396
+ schedule: true
397
+ });
403
398
  }, {
404
399
  id: options.renderId
405
400
  });
@@ -419,7 +414,8 @@ function render(code, element, init, options = {}) {
419
414
  function create(html, bypassGuard, flag) {
420
415
  const t = document.createElement("template");
421
416
  t.innerHTML = html;
422
- return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
417
+ const node = t.content.firstChild;
418
+ return flag === 2 ? node.firstChild : node;
423
419
  }
424
420
  function template(html, flag) {
425
421
  let node;
@@ -427,8 +423,7 @@ function template(html, flag) {
427
423
  return fn;
428
424
  }
429
425
  function delegateEvents(eventNames) {
430
- for (let i = 0, l = eventNames.length; i < l; i++) {
431
- const name = eventNames[i];
426
+ for (const name of eventNames) {
432
427
  if (!delegatedEvents.has(name)) {
433
428
  delegatedEvents.add(name);
434
429
  delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
@@ -476,9 +471,10 @@ function dispatchAsInteraction(e, fn) {
476
471
  function getDelegatedRoot(node) {
477
472
  while (node) {
478
473
  if (delegatedContainers.get(node)?.roots) return node;
479
- node = node._$host || node.parentNode || node.host;
474
+ node = parentOf(node);
480
475
  }
481
476
  }
477
+ const parentOf = node => node._$host || node.parentNode || node.host;
482
478
  function findOwner(target, state) {
483
479
  let node = target;
484
480
  let distance = 0;
@@ -488,7 +484,7 @@ function findOwner(target, state) {
488
484
  distance
489
485
  };
490
486
  distance++;
491
- node = node._$host || node.parentNode || node.host;
487
+ node = parentOf(node);
492
488
  }
493
489
  }
494
490
  function setProperty(node, name, value) {
@@ -1004,7 +1000,7 @@ function trackAssetLoad(entry, adopted) {
1004
1000
  }
1005
1001
  entry.loadState = "pending";
1006
1002
  entry.loadPromise = new Promise(resolve => {
1007
- const settle = state => {
1003
+ const settle = entry.settle = state => {
1008
1004
  entry.loadState = state;
1009
1005
  resolve();
1010
1006
  };
@@ -1116,6 +1112,7 @@ function acquireAsset(descriptor) {
1116
1112
  entry.timer = setTimeout(() => {
1117
1113
  assetRegistry.delete(key);
1118
1114
  entry.element && entry.element.remove();
1115
+ if (entry.loadState === "pending") entry.settle("errored");
1119
1116
  }, ASSET_REMOVAL_GRACE);
1120
1117
  };
1121
1118
  }
@@ -1681,11 +1678,9 @@ function eventHandler(e, container, state) {
1681
1678
  node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
1682
1679
  return true;
1683
1680
  };
1681
+ const atOwner = () => node === owner || node.parentNode === owner;
1684
1682
  const walkUpTree = () => {
1685
- while (node && handleNode()) {
1686
- if (node === owner || node.parentNode === owner) break;
1687
- node = node._$host || node.parentNode || node.host;
1688
- }
1683
+ while (node && handleNode() && !atOwner()) node = parentOf(node);
1689
1684
  };
1690
1685
  Object.defineProperty(e, "currentTarget", {
1691
1686
  configurable: true,
@@ -1694,7 +1689,7 @@ function eventHandler(e, container, state) {
1694
1689
  }
1695
1690
  });
1696
1691
  if (resumeNode) {
1697
- if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1692
+ if (resumeNode === e.target) node = parentOf(resumeNode);
1698
1693
  if (node && node !== owner) walkUpTree();
1699
1694
  } else if (e.composedPath) {
1700
1695
  const path = e.composedPath();
@@ -1708,9 +1703,7 @@ function eventHandler(e, container, state) {
1708
1703
  walkUpTree();
1709
1704
  break;
1710
1705
  }
1711
- if (node === owner || node.parentNode === owner) {
1712
- break;
1713
- }
1706
+ if (atOwner()) break;
1714
1707
  }
1715
1708
  } else walkUpTree();
1716
1709
  }
@@ -401,16 +401,11 @@ function render(code, element, init, options = {}) {
401
401
  createRoot(dispose => {
402
402
  disposer = dispose;
403
403
  if (options.onError) getOwner()[ROOT_ERROR_HOOK] = options.onError;
404
- if (element === document) {
405
- const tree = code();
406
- effect(() => flatten(tree), () => {});
407
- } else {
408
- const tree = code();
409
- insert(element, () => tree, element.firstChild ? null : undefined, init, {
410
- ...options.insertOptions,
411
- schedule: true
412
- });
413
- }
404
+ const tree = code();
405
+ if (element === document) effect(() => flatten(tree), () => {});else insert(element, () => tree, element.firstChild ? null : undefined, init, {
406
+ ...options.insertOptions,
407
+ schedule: true
408
+ });
414
409
  }, {
415
410
  id: options.renderId
416
411
  });
@@ -430,7 +425,8 @@ function render(code, element, init, options = {}) {
430
425
  function create(html, bypassGuard, flag) {
431
426
  const t = document.createElement("template");
432
427
  t.innerHTML = html;
433
- return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
428
+ const node = t.content.firstChild;
429
+ return flag === 2 ? node.firstChild : node;
434
430
  }
435
431
  function template(html, flag) {
436
432
  let node;
@@ -438,8 +434,7 @@ function template(html, flag) {
438
434
  return fn;
439
435
  }
440
436
  function delegateEvents(eventNames) {
441
- for (let i = 0, l = eventNames.length; i < l; i++) {
442
- const name = eventNames[i];
437
+ for (const name of eventNames) {
443
438
  if (!delegatedEvents.has(name)) {
444
439
  delegatedEvents.add(name);
445
440
  delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
@@ -507,9 +502,10 @@ function dispatchAsInteraction(e, fn) {
507
502
  function getDelegatedRoot(node) {
508
503
  while (node) {
509
504
  if (delegatedContainers.get(node)?.roots) return node;
510
- node = node._$host || node.parentNode || node.host;
505
+ node = parentOf(node);
511
506
  }
512
507
  }
508
+ const parentOf = node => node._$host || node.parentNode || node.host;
513
509
  function findOwner(target, state) {
514
510
  let node = target;
515
511
  let distance = 0;
@@ -519,7 +515,7 @@ function findOwner(target, state) {
519
515
  distance
520
516
  };
521
517
  distance++;
522
- node = node._$host || node.parentNode || node.host;
518
+ node = parentOf(node);
523
519
  }
524
520
  }
525
521
  function setProperty(node, name, value) {
@@ -1055,7 +1051,7 @@ function trackAssetLoad(entry, adopted) {
1055
1051
  }
1056
1052
  entry.loadState = "pending";
1057
1053
  entry.loadPromise = new Promise(resolve => {
1058
- const settle = state => {
1054
+ const settle = entry.settle = state => {
1059
1055
  entry.loadState = state;
1060
1056
  resolve();
1061
1057
  };
@@ -1167,6 +1163,7 @@ function acquireAsset(descriptor) {
1167
1163
  entry.timer = setTimeout(() => {
1168
1164
  assetRegistry.delete(key);
1169
1165
  entry.element && entry.element.remove();
1166
+ if (entry.loadState === "pending") entry.settle("errored");
1170
1167
  }, ASSET_REMOVAL_GRACE);
1171
1168
  };
1172
1169
  }
@@ -1732,11 +1729,9 @@ function eventHandler(e, container, state) {
1732
1729
  node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
1733
1730
  return true;
1734
1731
  };
1732
+ const atOwner = () => node === owner || node.parentNode === owner;
1735
1733
  const walkUpTree = () => {
1736
- while (node && handleNode()) {
1737
- if (node === owner || node.parentNode === owner) break;
1738
- node = node._$host || node.parentNode || node.host;
1739
- }
1734
+ while (node && handleNode() && !atOwner()) node = parentOf(node);
1740
1735
  };
1741
1736
  Object.defineProperty(e, "currentTarget", {
1742
1737
  configurable: true,
@@ -1745,7 +1740,7 @@ function eventHandler(e, container, state) {
1745
1740
  }
1746
1741
  });
1747
1742
  if (resumeNode) {
1748
- if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1743
+ if (resumeNode === e.target) node = parentOf(resumeNode);
1749
1744
  if (node && node !== owner) walkUpTree();
1750
1745
  } else if (e.composedPath) {
1751
1746
  const path = e.composedPath();
@@ -1759,9 +1754,7 @@ function eventHandler(e, container, state) {
1759
1754
  walkUpTree();
1760
1755
  break;
1761
1756
  }
1762
- if (node === owner || node.parentNode === owner) {
1763
- break;
1764
- }
1757
+ if (atOwner()) break;
1765
1758
  }
1766
1759
  } else walkUpTree();
1767
1760
  }
@@ -242,7 +242,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
242
242
  pendingWrites++;
243
243
  let settled = false;
244
244
  let failed = false;
245
- let started = false;
246
245
  let cancel = null;
247
246
  const settle = () => {
248
247
  if (settled) return;
@@ -263,10 +262,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
263
262
  }
264
263
  }),
265
264
  onDone: settle
266
- }, initial => {
267
- if (initial) started = true;
268
- return !closed;
269
- });
265
+ }, () => !closed);
270
266
  } catch (err) {
271
267
  settle();
272
268
  throw err;
@@ -316,7 +312,7 @@ function createJSONSerializer({
316
312
  plugins: resolved.plugins,
317
313
  disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
318
314
  onParse(node, initial) {
319
- if (live(initial)) onData({
315
+ if (live()) onData({
320
316
  key,
321
317
  node,
322
318
  initial
@@ -242,7 +242,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
242
242
  pendingWrites++;
243
243
  let settled = false;
244
244
  let failed = false;
245
- let started = false;
246
245
  let cancel = null;
247
246
  const settle = () => {
248
247
  if (settled) return;
@@ -263,10 +262,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
263
262
  }
264
263
  }),
265
264
  onDone: settle
266
- }, initial => {
267
- if (initial) started = true;
268
- return !closed;
269
- });
265
+ }, () => !closed);
270
266
  } catch (err) {
271
267
  settle();
272
268
  throw err;
@@ -316,7 +312,7 @@ function createJSONSerializer({
316
312
  plugins: resolved.plugins,
317
313
  disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
318
314
  onParse(node, initial) {
319
- if (live(initial)) onData({
315
+ if (live()) onData({
320
316
  key,
321
317
  node,
322
318
  initial
@@ -242,7 +242,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
242
242
  pendingWrites++;
243
243
  let settled = false;
244
244
  let failed = false;
245
- let started = false;
246
245
  let cancel = null;
247
246
  const settle = () => {
248
247
  if (settled) return;
@@ -263,10 +262,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
263
262
  }
264
263
  }),
265
264
  onDone: settle
266
- }, initial => {
267
- if (initial) started = true;
268
- return !closed;
269
- });
265
+ }, () => !closed);
270
266
  } catch (err) {
271
267
  settle();
272
268
  throw err;
@@ -316,7 +312,7 @@ function createJSONSerializer({
316
312
  plugins: resolved.plugins,
317
313
  disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
318
314
  onParse(node, initial) {
319
- if (live(initial)) onData({
315
+ if (live()) onData({
320
316
  key,
321
317
  node,
322
318
  initial
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
4
- "version": "2.0.0-rc.20",
4
+ "version": "2.0.0-rc.21",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -379,7 +379,7 @@
379
379
  "seroval-plugins": "1.7.0"
380
380
  },
381
381
  "peerDependencies": {
382
- "solid-js": "^2.0.0-rc.20"
382
+ "solid-js": "^2.0.0-rc.21"
383
383
  },
384
384
  "devDependencies": {
385
385
  "@codspeed/vitest-plugin": "^5.4.0",
@@ -256,7 +256,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
256
256
  pendingWrites++;
257
257
  let settled = false;
258
258
  let failed = false;
259
- let started = false;
260
259
  let cancel = null;
261
260
  const settle = () => {
262
261
  if (settled) return;
@@ -277,10 +276,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
277
276
  }
278
277
  }),
279
278
  onDone: settle
280
- }, initial => {
281
- if (initial) started = true;
282
- return !closed;
283
- });
279
+ }, () => !closed);
284
280
  } catch (err) {
285
281
  settle();
286
282
  throw err;
@@ -327,22 +323,66 @@ function createHydrationSerializer({
327
323
  onDone,
328
324
  scopeId,
329
325
  onError,
330
- plugins
326
+ plugins,
327
+ late
331
328
  }) {
332
329
  const resolvedPlugins = resolveSerializerPlugins(plugins);
333
330
  const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
334
331
  const refs = new Map();
335
- return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
332
+ const serialize = (key, value, callbacks, live) => crossSerializeStream(value, {
336
333
  scopeId,
337
334
  refs,
338
335
  plugins: resolvedPlugins,
339
336
  disabledFeatures,
340
337
  onSerialize(data, initial) {
341
- if (!live(initial)) return;
338
+ if (!live()) return;
342
339
  onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
343
340
  },
344
341
  ...callbacks
345
- }), onError, onDone);
342
+ });
343
+ return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
344
+ }
345
+ function rejectUnserializedKey(serialize, refs, onData, scopeId) {
346
+ let taken = 0;
347
+ let fresh = [];
348
+ const set = refs.set;
349
+ refs.set = (value, id) => {
350
+ taken++;
351
+ fresh.push(value);
352
+ return set.call(refs, value, id);
353
+ };
354
+ Object.defineProperty(refs, "size", {
355
+ get: () => taken
356
+ });
357
+ return (key, value, callbacks, live) => {
358
+ const sent = [];
359
+ const failed = () => {
360
+ for (const ref of fresh) refs.delete(ref);
361
+ fresh = [];
362
+ const ids = new Set();
363
+ for (const ref of sent) {
364
+ const id = refs.get(ref);
365
+ if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
366
+ }
367
+ if (!ids.size) return;
368
+ const body = "for(const i of[" + [...ids] + "]){const v=$R[i];v&&(v.f?v.f(e):v.throw&&v.throw(e))}";
369
+ const message = JSON.stringify("Serialization failed: the hydration value for key " + JSON.stringify(key) + " could not be serialized on the server").replace(/[<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
370
+ onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
371
+ };
372
+ return serialize(key, value, {
373
+ ...callbacks,
374
+ onError: callbacks.onError && (err => {
375
+ if (live()) failed();
376
+ callbacks.onError(err);
377
+ })
378
+ },
379
+ () => {
380
+ if (!live()) return false;
381
+ sent.push(...fresh);
382
+ fresh = [];
383
+ return true;
384
+ });
385
+ };
346
386
  }
347
387
  function getLocalHeaderScript(id) {
348
388
  return getCrossReferenceHeader(id) + ";";
@@ -385,7 +425,7 @@ function createJSONSerializer({
385
425
  plugins: resolved.plugins,
386
426
  disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
387
427
  onParse(node, initial) {
388
- if (live(initial)) onData({
428
+ if (live()) onData({
389
429
  key,
390
430
  node,
391
431
  initial
@@ -395,4 +435,4 @@ function createJSONSerializer({
395
435
  }), onError, onDone);
396
436
  }
397
437
 
398
- export { DEFAULT_WEB_PLUGINS, OpaqueReference, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createPlugin, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
438
+ export { DEFAULT_WEB_PLUGINS, OpaqueReference, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createPlugin, createSerializer, getLocalHeaderScript, rejectUnserializedKey, resolveSerializerPlugins, serializeJSON };
@@ -100,6 +100,41 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
100
100
  flush(): void;
101
101
  close(): void;
102
102
  };
103
+ /**
104
+ * `createHydrationSerializer`'s `late`, which wraps its seroval session
105
+ * per write: rejects, on the client, what a write that failed to serialize
106
+ * midstream left pending (#4647; maintainer ruling,
107
+ * 2026-11-03). seroval 1.7 ends a write at its first failure without
108
+ * settling anything it already declared: the key's promise, a promise or
109
+ * async iterable nested in a value it already sent, each would stay pending
110
+ * forever. Every promise the write sent is rejected (its resolver is indexed
111
+ * right after it, `parsePromise`) and every stream it sent is thrown into,
112
+ * with one error naming the key; one that already settled ignores it. The
113
+ * failure's own text went to the error hook and is not sent. The promise is
114
+ * left unmarked (no `s`/`v`, which seroval's own failure call sets for
115
+ * synchronous adoption): the hydrating read sees it pending and takes the
116
+ * rejection after the claim pass, so the reading computation throws into
117
+ * the nearest `<Errored>`, whose fallback then replaces the server's
118
+ * content. Read synchronously, the fallback would be built in the claim pass
119
+ * against markup that is the content's.
120
+ *
121
+ * Which write a reference belongs to: seroval indexes a value into the
122
+ * shared `refs` as it parses it and hands the chunk that declares it to that
123
+ * write's `onSerialize` in the same synchronous step, so the indexes taken
124
+ * since the last chunk are the next chunk's, or the failed parse's when the
125
+ * write fails instead. Those never went out: they leave `refs`, or a later
126
+ * write reaching the same value (a second key on the same promise) would
127
+ * reference a slot the client never filled and resolve `undefined`; it
128
+ * parses the value again and fails on its own. seroval takes the next index
129
+ * from `refs.size`, so the size counts every index ever taken.
130
+ * @internal
131
+ */
132
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
+ * Renderer primitive — returns the cross-reference bootstrap script SSR
134
+ * emits ahead of hydration data for a render scope. Not meant for
135
+ * hand-written code.
136
+ * @internal
137
+ */
103
138
  export declare function getLocalHeaderScript(id?: string): string;
104
139
  export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
105
140
  export declare function createJSONSerializer(options: JSONSerializerOptions): {
@@ -100,6 +100,41 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
100
100
  flush(): void;
101
101
  close(): void;
102
102
  };
103
+ /**
104
+ * `createHydrationSerializer`'s `late`, which wraps its seroval session
105
+ * per write: rejects, on the client, what a write that failed to serialize
106
+ * midstream left pending (#4647; maintainer ruling,
107
+ * 2026-11-03). seroval 1.7 ends a write at its first failure without
108
+ * settling anything it already declared: the key's promise, a promise or
109
+ * async iterable nested in a value it already sent, each would stay pending
110
+ * forever. Every promise the write sent is rejected (its resolver is indexed
111
+ * right after it, `parsePromise`) and every stream it sent is thrown into,
112
+ * with one error naming the key; one that already settled ignores it. The
113
+ * failure's own text went to the error hook and is not sent. The promise is
114
+ * left unmarked (no `s`/`v`, which seroval's own failure call sets for
115
+ * synchronous adoption): the hydrating read sees it pending and takes the
116
+ * rejection after the claim pass, so the reading computation throws into
117
+ * the nearest `<Errored>`, whose fallback then replaces the server's
118
+ * content. Read synchronously, the fallback would be built in the claim pass
119
+ * against markup that is the content's.
120
+ *
121
+ * Which write a reference belongs to: seroval indexes a value into the
122
+ * shared `refs` as it parses it and hands the chunk that declares it to that
123
+ * write's `onSerialize` in the same synchronous step, so the indexes taken
124
+ * since the last chunk are the next chunk's, or the failed parse's when the
125
+ * write fails instead. Those never went out: they leave `refs`, or a later
126
+ * write reaching the same value (a second key on the same promise) would
127
+ * reference a slot the client never filled and resolve `undefined`; it
128
+ * parses the value again and fails on its own. seroval takes the next index
129
+ * from `refs.size`, so the size counts every index ever taken.
130
+ * @internal
131
+ */
132
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
+ * Renderer primitive — returns the cross-reference bootstrap script SSR
134
+ * emits ahead of hydration data for a render scope. Not meant for
135
+ * hand-written code.
136
+ * @internal
137
+ */
103
138
  export declare function getLocalHeaderScript(id?: string): string;
104
139
  export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
105
140
  export declare function createJSONSerializer(options: JSONSerializerOptions): {
@@ -39,6 +39,9 @@ function isBlob(value) {
39
39
  if (typeof Blob !== "undefined" && value instanceof Blob) return true;
40
40
  return typeof value === "object" && value !== null && typeof value.size === "number" && typeof value.type === "string" && typeof value.arrayBuffer === "function" && typeof value.slice === "function";
41
41
  }
42
+ function isFile(value) {
43
+ return typeof value.name === "string" && typeof value.lastModified === "number";
44
+ }
42
45
  function malformed() {
43
46
  return new TypeError("Malformed server function upload");
44
47
  }
@@ -47,19 +50,34 @@ function createUploadSerializer(files) {
47
50
  const index = files.indexOf(value);
48
51
  return index === -1 ? files.push(value) - 1 : index;
49
52
  };
53
+ const parse = (value, ctx) => {
54
+ const node = {
55
+ i: ctx.parse(indexOf(value)),
56
+ t: ctx.parse(value.type)
57
+ };
58
+ if (isFile(value)) {
59
+ node.n = ctx.parse(value.name);
60
+ node.l = ctx.parse(value.lastModified);
61
+ }
62
+ return node;
63
+ };
50
64
  return {
51
65
  tag: UPLOAD_TAG,
52
66
  test: isBlob,
53
67
  parse: {
54
- sync: (value, ctx) => ({
55
- i: ctx.parse(indexOf(value))
56
- }),
57
- async: async (value, ctx) => ({
58
- i: await ctx.parse(indexOf(value))
59
- }),
60
- stream: (value, ctx) => ({
61
- i: ctx.parse(indexOf(value))
62
- })
68
+ sync: parse,
69
+ async: async (value, ctx) => {
70
+ const node = {
71
+ i: await ctx.parse(indexOf(value)),
72
+ t: await ctx.parse(value.type)
73
+ };
74
+ if (isFile(value)) {
75
+ node.n = await ctx.parse(value.name);
76
+ node.l = await ctx.parse(value.lastModified);
77
+ }
78
+ return node;
79
+ },
80
+ stream: parse
63
81
  },
64
82
  serialize: (node, ctx) => ctx.serialize(node.i),
65
83
  deserialize: () => {