@solidjs/web 2.0.0-rc.0 → 2.0.0-rc.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 (108) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +4472 -0
  3. package/dist/server.js +1363 -224
  4. package/dist/{server.cjs → server.observe.js} +1563 -424
  5. package/dist/{dev.cjs → web.dev.js} +708 -365
  6. package/dist/web.js +460 -144
  7. package/dist/{dev.js → web.observe.js} +511 -213
  8. package/frames/dist/client.dev.js +464 -72
  9. package/frames/dist/client.js +364 -71
  10. package/frames/dist/{client.dev.cjs → client.observe.js} +487 -134
  11. package/frames/dist/server.dev.js +1713 -0
  12. package/frames/dist/server.js +553 -2495
  13. package/frames/dist/server.observe.js +1713 -0
  14. package/frames/package.json +2 -25
  15. package/package.json +214 -254
  16. package/performance-tracks/dist/performance-tracks.dev.js +678 -0
  17. package/performance-tracks/dist/performance-tracks.js +6 -0
  18. package/performance-tracks/dist/performance-tracks.observe.js +666 -0
  19. package/performance-tracks/package.json +7 -0
  20. package/performance-tracks/types/index.d.ts +67 -0
  21. package/serialization/decode/package.json +2 -15
  22. package/serialization/dist/decode.js +101 -12
  23. package/serialization/dist/serialization.js +112 -20
  24. package/serialization/package.json +2 -15
  25. package/serialization/types/index.d.ts +76 -157
  26. package/serialization/types/serializer-decode.d.ts +149 -112
  27. package/serialization/types/serializer.d.ts +101 -0
  28. package/server-functions/dist/client.dev.js +1364 -0
  29. package/server-functions/dist/client.js +745 -85
  30. package/server-functions/dist/client.observe.js +1343 -0
  31. package/server-functions/dist/server.dev.js +2203 -175
  32. package/server-functions/dist/server.js +2111 -176
  33. package/server-functions/dist/server.observe.js +3043 -0
  34. package/server-functions/package.json +2 -35
  35. package/server-functions/rich-args/package.json +2 -15
  36. package/storage/package.json +2 -15
  37. package/types/client.d.ts +193 -288
  38. package/types/constants.d.ts +20 -0
  39. package/types/cookies.d.ts +32 -84
  40. package/types/diagnostics.d.ts +56 -0
  41. package/types/frames/client.d.ts +1 -1
  42. package/types/frames/frame-client.d.ts +323 -259
  43. package/types/frames/frame-container-plugin.d.ts +72 -0
  44. package/types/frames/frame-sink.d.ts +101 -158
  45. package/types/frames/frame-transport.d.ts +192 -190
  46. package/types/frames/serializer-decode.d.ts +219 -0
  47. package/types/frames/serializer.d.ts +76 -157
  48. package/types/frames/server.d.ts +1 -1
  49. package/types/head.d.ts +19 -0
  50. package/types/index.d.ts +62 -76
  51. package/types/index.server.d.ts +174 -0
  52. package/types/jsx.d.ts +33 -26
  53. package/types/observe.d.ts +358 -0
  54. package/types/reconcile.d.ts +1 -0
  55. package/types/render.d.ts +9 -0
  56. package/types/response.d.ts +75 -150
  57. package/types/serializer-decode.d.ts +149 -112
  58. package/types/serializer.d.ts +76 -157
  59. package/types/server-functions/client.d.ts +202 -174
  60. package/types/server-functions/flash.d.ts +28 -30
  61. package/types/server-functions/registry.d.ts +102 -0
  62. package/types/server-functions/rich-args.d.ts +1 -10
  63. package/types/server-functions/server.d.ts +518 -454
  64. package/types/server-functions/shared.d.ts +366 -425
  65. package/types/server-mock.d.ts +110 -13
  66. package/types/server-observe.d.ts +77 -0
  67. package/types/server.d.ts +425 -425
  68. package/types/trace.d.ts +127 -0
  69. package/LICENSE +0 -21
  70. package/dist/web.cjs +0 -2007
  71. package/frames/dist/client.cjs +0 -1916
  72. package/frames/dist/server.cjs +0 -3667
  73. package/serialization/dist/decode.cjs +0 -110
  74. package/serialization/dist/serialization.cjs +0 -232
  75. package/serialization/types-cjs/index.d.cts +0 -182
  76. package/serialization/types-cjs/package.json +0 -3
  77. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  78. package/server-functions/dist/client.cjs +0 -646
  79. package/server-functions/dist/rich-args.cjs +0 -11
  80. package/server-functions/dist/server.cjs +0 -1077
  81. package/server-functions/dist/server.dev.cjs +0 -1077
  82. package/storage/dist/storage.cjs +0 -12
  83. package/storage/types-cjs/index.d.cts +0 -28
  84. package/storage/types-cjs/package.json +0 -3
  85. package/types/core.d.ts +0 -6
  86. package/types-cjs/client.d.cts +0 -337
  87. package/types-cjs/cookies.d.cts +0 -93
  88. package/types-cjs/core.d.cts +0 -6
  89. package/types-cjs/frames/client.d.cts +0 -36
  90. package/types-cjs/frames/frame-client.d.cts +0 -338
  91. package/types-cjs/frames/frame-sink.d.cts +0 -194
  92. package/types-cjs/frames/frame-transport.d.cts +0 -222
  93. package/types-cjs/frames/serializer.d.cts +0 -182
  94. package/types-cjs/frames/server.d.cts +0 -52
  95. package/types-cjs/index.d.cts +0 -230
  96. package/types-cjs/jsx-properties.d.cts +0 -93
  97. package/types-cjs/jsx.d.cts +0 -4150
  98. package/types-cjs/package.json +0 -3
  99. package/types-cjs/response.d.cts +0 -174
  100. package/types-cjs/serializer-decode.d.cts +0 -182
  101. package/types-cjs/serializer.d.cts +0 -182
  102. package/types-cjs/server-functions/client.d.cts +0 -201
  103. package/types-cjs/server-functions/flash.d.cts +0 -38
  104. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  105. package/types-cjs/server-functions/server.d.cts +0 -588
  106. package/types-cjs/server-functions/shared.d.cts +0 -523
  107. package/types-cjs/server-mock.d.cts +0 -277
  108. package/types-cjs/server.d.cts +0 -523
@@ -0,0 +1,67 @@
1
+ import { type AttributionOptions } from "solid-js/attribution";
2
+ export interface PerformanceTracksOptions {
3
+ /**
4
+ * Options for the engine hold this adapter takes
5
+ * (`attribution.enable({ log: false, ...attribution })`). The adapter asks
6
+ * for no console log — the timeline is the output — which, the engine
7
+ * combining holds by the most demanding request, quiets the console only
8
+ * while nobody else wants it: a console session beside the tracks keeps
9
+ * its log. `checks` is left to the engine's default; pass `checks: false`
10
+ * for records only (honoured while no other holder wants the checks).
11
+ */
12
+ attribution?: AttributionOptions;
13
+ /**
14
+ * Floor for run spans on `Propagation`, `Effects` and `Memos` — compute
15
+ * runs (by `totalMs`), creation runs and effect callbacks (by their
16
+ * duration): spans under it are not painted. The wave span on
17
+ * `Propagation` always is, and its label carries the counts, so a
18
+ * fan-out of runs too small to paint still reads as `47 runs`. Default
19
+ * `0` in dev (every run; Chrome shows zero-width spans zoomed in) and
20
+ * `0.05` in observe builds, so a production trace carries the runs that
21
+ * cost something.
22
+ */
23
+ minMs?: number;
24
+ /**
25
+ * Emit through `performance.measure` with `detail.devtools` — tooltips
26
+ * (the why-chain of a re-run) and properties (causes, deps, blockers…)
27
+ * on every span — instead of `console.timeStamp`. Costs a User Timing
28
+ * entry per span; the adapter clears the entries it made in batches (a
29
+ * name it shares with an app measure is left alone). Default: dev builds.
30
+ * Each path falls back to the other where its API is missing.
31
+ */
32
+ rich?: boolean;
33
+ }
34
+ /**
35
+ * Paint the attribution engine's records — and the web runtime's
36
+ * server-function `call` and `frame` records, with the server's own timing
37
+ * for each response under them (its `Server-Timing` metrics, placed by the
38
+ * browser's resource timing; the document's at enable) — as tracks in the
39
+ * Chrome Performance panel, from now until the returned function is called. The
40
+ * tracks themselves are Chrome's (its `detail.devtools` extension); in rich
41
+ * mode the spans are standard User Timing measures underneath, so any tool
42
+ * that reads those — Firefox's profiler, Lighthouse, RUM — sees the same
43
+ * spans as plain measures.
44
+ *
45
+ * Takes its own hold on the engine (`attribution.enable`): enabling beside
46
+ * a diagnostics capture or an APM adapter disturbs neither, and releasing
47
+ * here leaves theirs in place. Subscribing
48
+ * to the engine's timeline records (`create`, `effect`, `flush`, `flight`,
49
+ * `fallback`) is what turns them on — they are built only while a listener
50
+ * exists, so the engine pays for them only while the tracks are enabled.
51
+ * Every diagnostic delivered while enabled becomes a marker on the panel's
52
+ * Timings track (`SILENT_HOLD — <Search>`), annotated as a
53
+ * performance issue for the Insights sidebar when its severity is a
54
+ * warning or worse. In dev, spans and markers are emitted inside the
55
+ * `console.createTask` task of the component they belong to, so an entry's
56
+ * stack in the panel points at the JSX site that rendered the component.
57
+ *
58
+ * One instance per page: the tracks are a view of one engine, and a second
59
+ * painter would paint every span twice. A call while enabled joins the
60
+ * running instance — its options are not re-read; the first call's apply —
61
+ * and returns a release of its own; the instance is torn down when every
62
+ * release has been called (a module re-evaluated by HMR that enables again
63
+ * and disposes the old one lands back on one instance either way). A no-op
64
+ * (returning a no-op) in prod builds, where the observe tier is absent, and
65
+ * in an environment without `console.timeStamp` or `performance.measure`.
66
+ */
67
+ export declare function enablePerformanceTracks(options?: PerformanceTracksOptions): () => void;
@@ -1,20 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/serialization/decode",
3
- "main": "../dist/decode.cjs",
2
+ "main": "../dist/decode.js",
4
3
  "module": "../dist/decode.js",
5
4
  "types": "../types/serializer-decode.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "../types/serializer-decode.d.ts",
12
- "default": "../dist/decode.js"
13
- },
14
- "require": {
15
- "types": "../types-cjs/serializer-decode.d.cts",
16
- "default": "../dist/decode.cjs"
17
- }
18
- }
19
- }
6
+ "sideEffects": false
20
7
  }
@@ -1,12 +1,15 @@
1
- import { Feature, fromCrossJSON } from 'seroval';
1
+ import { Feature, fromCrossJSON, createStream } from 'seroval';
2
2
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
3
3
 
4
- const STATE = Symbol.for("dom-expressions.container-trace-state");
4
+ const STATE = Symbol.for("solid.container-trace-state");
5
5
  const state = globalThis[STATE] || (globalThis[STATE] = {
6
6
  materialized: new WeakMap(),
7
7
  materializedValues: new WeakSet()
8
8
  });
9
- const TRACE = Symbol.for("dom-expressions.container-trace");
9
+ function setContainerTraceStreamMint(fn) {
10
+ state.streamOf = fn;
11
+ }
12
+ const TRACE = Symbol.for("solid.container-trace");
10
13
  function materialize(marker) {
11
14
  let value = state.materialized.get(marker.$tr);
12
15
  if (value === undefined) {
@@ -18,13 +21,14 @@ function materialize(marker) {
18
21
  }
19
22
  function parseTrace(value, ctx) {
20
23
  const trace = value[TRACE];
24
+ const sub = trace.subscribe();
21
25
  return {
22
26
  a: trace.array ? 1 : 0,
23
- i: ctx.parse(trace.subscribe())
27
+ i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
24
28
  };
25
29
  }
26
30
  const ContainerTracePlugin = {
27
- tag: "dom-expressions/container-trace",
31
+ tag: "solid/container-trace",
28
32
  test(value) {
29
33
  return value != null && typeof value === "object" && TRACE in value;
30
34
  },
@@ -34,9 +38,10 @@ const ContainerTracePlugin = {
34
38
  },
35
39
  async async(value, ctx) {
36
40
  const trace = value[TRACE];
41
+ const sub = trace.subscribe();
37
42
  return {
38
43
  a: trace.array ? 1 : 0,
39
- i: await ctx.parse(trace.subscribe())
44
+ i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
40
45
  };
41
46
  },
42
47
  stream: parseTrace
@@ -54,6 +59,18 @@ const ContainerTracePlugin = {
54
59
  }
55
60
  };
56
61
 
62
+ setContainerTraceStreamMint(iterable => {
63
+ const stream = createStream();
64
+ (async () => {
65
+ try {
66
+ for await (const value of iterable) stream.next(value);
67
+ stream.return(undefined);
68
+ } catch (error) {
69
+ stream.throw(error);
70
+ }
71
+ })();
72
+ return stream;
73
+ });
57
74
  const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
58
75
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
59
76
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
@@ -66,23 +83,95 @@ const JSON_CODEC_DEPTH_LIMIT = 64;
66
83
  function resolveCodecOptions({
67
84
  plugins,
68
85
  disabledFeatures,
69
- depthLimit
86
+ depthLimit,
87
+ serializeErrorStacks
70
88
  } = {}) {
71
89
  return {
72
90
  plugins: resolveSerializerPlugins(plugins),
73
91
  disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
74
- depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
92
+ depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
93
+ serializeErrorStacks
75
94
  };
76
95
  }
77
96
  function createJSONDeserializer(options) {
78
97
  const refs = new Map();
79
98
  const resolved = resolveCodecOptions(options);
80
- return function deserializeJSONChunk(node) {
81
- return fromCrossJSON(node, {
82
- refs,
83
- ...resolved
99
+ let owned = 0;
100
+ const pendingResolvers = new Set();
101
+ const streams = new Set();
102
+ const STREAM = 1;
103
+ const RESOLVER = 2;
104
+ function classify(value) {
105
+ if (value === null || typeof value !== "object") return 0;
106
+ try {
107
+ if (value.__SEROVAL_STREAM__) return STREAM;
108
+ if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) return RESOLVER;
109
+ } catch {}
110
+ return 0;
111
+ }
112
+ function ownDecodedPromises() {
113
+ if (refs.size === owned) return;
114
+ let index = 0;
115
+ for (const value of refs.values()) {
116
+ if (index++ < owned) continue;
117
+ if (value instanceof Promise) value.then(undefined, () => {});else {
118
+ const kind = classify(value);
119
+ if (kind === STREAM) streams.add(value);else if (kind === RESOLVER) {
120
+ pendingResolvers.add(value);
121
+ const settled = () => pendingResolvers.delete(value);
122
+ value.p.then(settled, settled);
123
+ }
124
+ }
125
+ }
126
+ owned = refs.size;
127
+ }
128
+ function isOpenStream(stream) {
129
+ let alive = true;
130
+ const close = () => {
131
+ alive = false;
132
+ };
133
+ const off = stream.on({
134
+ next() {},
135
+ throw: close,
136
+ return: close
84
137
  });
138
+ if (typeof off === "function") off();
139
+ return alive;
140
+ }
141
+ function deserializeJSONChunk(node) {
142
+ try {
143
+ return fromCrossJSON(node, {
144
+ refs,
145
+ ...resolved
146
+ });
147
+ } finally {
148
+ ownDecodedPromises();
149
+ }
150
+ }
151
+ deserializeJSONChunk.abort = function abort(error) {
152
+ for (const value of refs.values()) {
153
+ const kind = classify(value);
154
+ if (kind === STREAM) {
155
+ value.throw(error);
156
+ } else if (kind === RESOLVER) {
157
+ value.p.then(undefined, () => {});
158
+ value.f(error);
159
+ }
160
+ }
161
+ };
162
+ deserializeJSONChunk.close = function close() {
163
+ for (const value of refs.values()) {
164
+ if (classify(value) === STREAM) value.return(undefined);
165
+ }
166
+ };
167
+ deserializeJSONChunk.open = function open() {
168
+ let count = pendingResolvers.size;
169
+ for (const stream of streams) {
170
+ if (isOpenStream(stream)) count++;else streams.delete(stream);
171
+ }
172
+ return count;
85
173
  };
174
+ return deserializeJSONChunk;
86
175
  }
87
176
  function createJSONDataTable(options) {
88
177
  const deserialize = createJSONDeserializer(options);
@@ -1,13 +1,15 @@
1
- import { Feature, fromCrossJSON, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
2
- export { OpaqueReference, createPlugin } from 'seroval';
1
+ import { Feature, fromCrossJSON, createStream, OpaqueReference as OpaqueReference$1, createPlugin as createPlugin$1, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
3
2
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
4
3
 
5
- const STATE = Symbol.for("dom-expressions.container-trace-state");
4
+ const STATE = Symbol.for("solid.container-trace-state");
6
5
  const state = globalThis[STATE] || (globalThis[STATE] = {
7
6
  materialized: new WeakMap(),
8
7
  materializedValues: new WeakSet()
9
8
  });
10
- const TRACE = Symbol.for("dom-expressions.container-trace");
9
+ function setContainerTraceStreamMint(fn) {
10
+ state.streamOf = fn;
11
+ }
12
+ const TRACE = Symbol.for("solid.container-trace");
11
13
  function materialize(marker) {
12
14
  let value = state.materialized.get(marker.$tr);
13
15
  if (value === undefined) {
@@ -19,13 +21,14 @@ function materialize(marker) {
19
21
  }
20
22
  function parseTrace(value, ctx) {
21
23
  const trace = value[TRACE];
24
+ const sub = trace.subscribe();
22
25
  return {
23
26
  a: trace.array ? 1 : 0,
24
- i: ctx.parse(trace.subscribe())
27
+ i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
25
28
  };
26
29
  }
27
30
  const ContainerTracePlugin = {
28
- tag: "dom-expressions/container-trace",
31
+ tag: "solid/container-trace",
29
32
  test(value) {
30
33
  return value != null && typeof value === "object" && TRACE in value;
31
34
  },
@@ -35,9 +38,10 @@ const ContainerTracePlugin = {
35
38
  },
36
39
  async async(value, ctx) {
37
40
  const trace = value[TRACE];
41
+ const sub = trace.subscribe();
38
42
  return {
39
43
  a: trace.array ? 1 : 0,
40
- i: await ctx.parse(trace.subscribe())
44
+ i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
41
45
  };
42
46
  },
43
47
  stream: parseTrace
@@ -55,6 +59,18 @@ const ContainerTracePlugin = {
55
59
  }
56
60
  };
57
61
 
62
+ setContainerTraceStreamMint(iterable => {
63
+ const stream = createStream();
64
+ (async () => {
65
+ try {
66
+ for await (const value of iterable) stream.next(value);
67
+ stream.return(undefined);
68
+ } catch (error) {
69
+ stream.throw(error);
70
+ }
71
+ })();
72
+ return stream;
73
+ });
58
74
  const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
59
75
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
60
76
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
@@ -67,23 +83,95 @@ const JSON_CODEC_DEPTH_LIMIT = 64;
67
83
  function resolveCodecOptions({
68
84
  plugins,
69
85
  disabledFeatures,
70
- depthLimit
86
+ depthLimit,
87
+ serializeErrorStacks
71
88
  } = {}) {
72
89
  return {
73
90
  plugins: resolveSerializerPlugins(plugins),
74
91
  disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
75
- depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
92
+ depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
93
+ serializeErrorStacks
76
94
  };
77
95
  }
78
96
  function createJSONDeserializer(options) {
79
97
  const refs = new Map();
80
98
  const resolved = resolveCodecOptions(options);
81
- return function deserializeJSONChunk(node) {
82
- return fromCrossJSON(node, {
83
- refs,
84
- ...resolved
99
+ let owned = 0;
100
+ const pendingResolvers = new Set();
101
+ const streams = new Set();
102
+ const STREAM = 1;
103
+ const RESOLVER = 2;
104
+ function classify(value) {
105
+ if (value === null || typeof value !== "object") return 0;
106
+ try {
107
+ if (value.__SEROVAL_STREAM__) return STREAM;
108
+ if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) return RESOLVER;
109
+ } catch {}
110
+ return 0;
111
+ }
112
+ function ownDecodedPromises() {
113
+ if (refs.size === owned) return;
114
+ let index = 0;
115
+ for (const value of refs.values()) {
116
+ if (index++ < owned) continue;
117
+ if (value instanceof Promise) value.then(undefined, () => {});else {
118
+ const kind = classify(value);
119
+ if (kind === STREAM) streams.add(value);else if (kind === RESOLVER) {
120
+ pendingResolvers.add(value);
121
+ const settled = () => pendingResolvers.delete(value);
122
+ value.p.then(settled, settled);
123
+ }
124
+ }
125
+ }
126
+ owned = refs.size;
127
+ }
128
+ function isOpenStream(stream) {
129
+ let alive = true;
130
+ const close = () => {
131
+ alive = false;
132
+ };
133
+ const off = stream.on({
134
+ next() {},
135
+ throw: close,
136
+ return: close
85
137
  });
138
+ if (typeof off === "function") off();
139
+ return alive;
140
+ }
141
+ function deserializeJSONChunk(node) {
142
+ try {
143
+ return fromCrossJSON(node, {
144
+ refs,
145
+ ...resolved
146
+ });
147
+ } finally {
148
+ ownDecodedPromises();
149
+ }
150
+ }
151
+ deserializeJSONChunk.abort = function abort(error) {
152
+ for (const value of refs.values()) {
153
+ const kind = classify(value);
154
+ if (kind === STREAM) {
155
+ value.throw(error);
156
+ } else if (kind === RESOLVER) {
157
+ value.p.then(undefined, () => {});
158
+ value.f(error);
159
+ }
160
+ }
161
+ };
162
+ deserializeJSONChunk.close = function close() {
163
+ for (const value of refs.values()) {
164
+ if (classify(value) === STREAM) value.return(undefined);
165
+ }
166
+ };
167
+ deserializeJSONChunk.open = function open() {
168
+ let count = pendingResolvers.size;
169
+ for (const stream of streams) {
170
+ if (isOpenStream(stream)) count++;else streams.delete(stream);
171
+ }
172
+ return count;
86
173
  };
174
+ return deserializeJSONChunk;
87
175
  }
88
176
  function createJSONDataTable(options) {
89
177
  const deserialize = createJSONDeserializer(options);
@@ -103,13 +191,15 @@ function createJSONDataTable(options) {
103
191
  }
104
192
 
105
193
  const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
106
- const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : Feature.ErrorPrototypeStack;
194
+ const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
107
195
  const HYDRATION_GLOBAL = "_$HY.r";
196
+ const createPlugin = createPlugin$1;
197
+ const OpaqueReference = OpaqueReference$1;
108
198
  function createSerializer(options) {
109
199
  return new Serializer({
110
200
  ...options,
111
201
  plugins: resolveSerializerPlugins(options.plugins),
112
- disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
202
+ disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
113
203
  });
114
204
  }
115
205
  function createHydrationSerializer({
@@ -143,7 +233,7 @@ function serializeJSON(value, {
143
233
  onDone,
144
234
  onError,
145
235
  ...resolved,
146
- disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
236
+ disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks)
147
237
  });
148
238
  }
149
239
  function createJSONSerializer({
@@ -152,12 +242,14 @@ function createJSONSerializer({
152
242
  onError,
153
243
  plugins,
154
244
  disabledFeatures,
155
- depthLimit
245
+ depthLimit,
246
+ serializeErrorStacks
156
247
  }) {
157
248
  const resolved = resolveCodecOptions({
158
249
  plugins,
159
250
  disabledFeatures,
160
- depthLimit
251
+ depthLimit,
252
+ serializeErrorStacks
161
253
  });
162
254
  const refs = new Map();
163
255
  const cancels = new Set();
@@ -179,7 +271,7 @@ function createJSONSerializer({
179
271
  const stream = toCrossJSONStream(value, {
180
272
  refs,
181
273
  plugins: resolved.plugins,
182
- disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(),
274
+ disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
183
275
  onParse(node, initial) {
184
276
  onData({
185
277
  key,
@@ -212,4 +304,4 @@ function createJSONSerializer({
212
304
  };
213
305
  }
214
306
 
215
- export { DEFAULT_WEB_PLUGINS, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
307
+ export { DEFAULT_WEB_PLUGINS, OpaqueReference, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createPlugin, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
@@ -1,20 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/serialization",
3
- "main": "./dist/serialization.cjs",
2
+ "main": "./dist/serialization.js",
4
3
  "module": "./dist/serialization.js",
5
4
  "types": "./types/index.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "./types/index.d.ts",
12
- "default": "./dist/serialization.js"
13
- },
14
- "require": {
15
- "types": "./types-cjs/index.d.cts",
16
- "default": "./dist/serialization.cjs"
17
- }
18
- }
19
- }
6
+ "sideEffects": false
20
7
  }