@solidjs/web 2.0.0-rc.2 → 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.
Files changed (124) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +5165 -0
  3. package/dist/server.js +1876 -374
  4. package/dist/{server.cjs → server.observe.js} +2070 -577
  5. package/dist/{dev.cjs → web.dev.js} +955 -567
  6. package/dist/web.js +646 -350
  7. package/dist/{dev.js → web.observe.js} +699 -421
  8. package/frames/dist/assets.js +92 -0
  9. package/frames/dist/client.dev.js +1296 -1198
  10. package/frames/dist/client.js +1128 -1191
  11. package/frames/dist/client.observe.js +2041 -0
  12. package/frames/dist/regions.js +171 -0
  13. package/frames/dist/server.dev.js +2545 -0
  14. package/frames/dist/server.js +1683 -3004
  15. package/frames/dist/server.observe.js +2544 -0
  16. package/frames/dist/trace.js +45 -0
  17. package/frames/dist/wire.js +594 -0
  18. package/frames/package.json +2 -25
  19. package/package.json +244 -256
  20. package/performance-tracks/dist/performance-tracks.dev.js +679 -0
  21. package/performance-tracks/dist/performance-tracks.js +6 -0
  22. package/performance-tracks/dist/performance-tracks.observe.js +667 -0
  23. package/performance-tracks/package.json +7 -0
  24. package/performance-tracks/types/index.d.ts +69 -0
  25. package/serialization/decode/package.json +2 -15
  26. package/serialization/dist/decode.js +121 -25
  27. package/serialization/dist/serialization.js +282 -88
  28. package/serialization/package.json +2 -15
  29. package/serialization/types/index.d.ts +115 -153
  30. package/serialization/types/serializer-decode.d.ts +173 -114
  31. package/serialization/types/serializer.d.ts +144 -0
  32. package/server-functions/dist/client.dev.js +1462 -0
  33. package/server-functions/dist/client.js +667 -165
  34. package/server-functions/dist/client.observe.js +1441 -0
  35. package/server-functions/dist/rich-args.js +102 -1
  36. package/server-functions/dist/server.dev.js +2802 -299
  37. package/server-functions/dist/server.js +2724 -314
  38. package/server-functions/dist/server.observe.js +3680 -0
  39. package/server-functions/package.json +2 -35
  40. package/server-functions/rich-args/package.json +2 -15
  41. package/skills/server-components/SKILL.md +117 -0
  42. package/storage/package.json +2 -15
  43. package/types/client.d.ts +342 -288
  44. package/types/constants.d.ts +22 -0
  45. package/types/cookies.d.ts +32 -84
  46. package/types/diagnostics.d.ts +80 -0
  47. package/types/frames/assets-tier.d.ts +78 -0
  48. package/types/frames/client.d.ts +40 -1
  49. package/types/frames/frame-client.d.ts +443 -280
  50. package/types/frames/frame-container-plugin.d.ts +64 -0
  51. package/types/frames/frame-morph.d.ts +29 -0
  52. package/types/frames/frame-sink.d.ts +141 -161
  53. package/types/frames/frame-transport.d.ts +263 -184
  54. package/types/frames/regions-tier.d.ts +60 -0
  55. package/types/frames/serializer-decode.d.ts +241 -0
  56. package/types/frames/serializer.d.ts +115 -153
  57. package/types/frames/server.d.ts +2 -2
  58. package/types/frames/trace-tier.d.ts +2 -0
  59. package/types/frames/tree-rewrite.d.ts +39 -0
  60. package/types/frames/wire-tier.d.ts +169 -0
  61. package/types/head.d.ts +20 -0
  62. package/types/index.d.ts +98 -81
  63. package/types/index.server.d.ts +159 -0
  64. package/types/jsx.d.ts +49 -44
  65. package/types/observe.d.ts +535 -0
  66. package/types/reconcile.d.ts +1 -0
  67. package/types/render.d.ts +11 -0
  68. package/types/request-error-hook.d.ts +5 -0
  69. package/types/response.d.ts +95 -147
  70. package/types/serializer-decode.d.ts +173 -114
  71. package/types/serializer.d.ts +115 -153
  72. package/types/server-functions/argument-codec.d.ts +30 -0
  73. package/types/server-functions/client.d.ts +237 -223
  74. package/types/server-functions/flash.d.ts +28 -30
  75. package/types/server-functions/registry.d.ts +105 -0
  76. package/types/server-functions/rich-args.d.ts +1 -10
  77. package/types/server-functions/server.d.ts +538 -531
  78. package/types/server-functions/shared.d.ts +398 -425
  79. package/types/server-functions/uploads.d.ts +53 -0
  80. package/types/server-mock.d.ts +154 -20
  81. package/types/server-observe.d.ts +86 -0
  82. package/types/server.d.ts +601 -422
  83. package/types/trace.d.ts +127 -0
  84. package/LICENSE +0 -21
  85. package/dist/web.cjs +0 -2033
  86. package/frames/dist/client.cjs +0 -2002
  87. package/frames/dist/client.dev.cjs +0 -2022
  88. package/frames/dist/server.cjs +0 -3877
  89. package/serialization/dist/decode.cjs +0 -139
  90. package/serialization/dist/serialization.cjs +0 -261
  91. package/serialization/types-cjs/index.d.cts +0 -182
  92. package/serialization/types-cjs/package.json +0 -3
  93. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  94. package/server-functions/dist/client.cjs +0 -834
  95. package/server-functions/dist/rich-args.cjs +0 -11
  96. package/server-functions/dist/server.cjs +0 -1242
  97. package/server-functions/dist/server.dev.cjs +0 -1242
  98. package/storage/dist/storage.cjs +0 -12
  99. package/storage/types-cjs/index.d.cts +0 -28
  100. package/storage/types-cjs/package.json +0 -3
  101. package/types/core.d.ts +0 -9
  102. package/types-cjs/client.d.cts +0 -337
  103. package/types-cjs/cookies.d.cts +0 -93
  104. package/types-cjs/core.d.cts +0 -9
  105. package/types-cjs/frames/client.d.cts +0 -36
  106. package/types-cjs/frames/frame-client.d.cts +0 -356
  107. package/types-cjs/frames/frame-sink.d.cts +0 -194
  108. package/types-cjs/frames/frame-transport.d.cts +0 -222
  109. package/types-cjs/frames/serializer.d.cts +0 -182
  110. package/types-cjs/frames/server.d.cts +0 -52
  111. package/types-cjs/index.d.cts +0 -244
  112. package/types-cjs/jsx-properties.d.cts +0 -93
  113. package/types-cjs/jsx.d.cts +0 -4159
  114. package/types-cjs/package.json +0 -3
  115. package/types-cjs/response.d.cts +0 -174
  116. package/types-cjs/serializer-decode.d.cts +0 -182
  117. package/types-cjs/serializer.d.cts +0 -182
  118. package/types-cjs/server-functions/client.d.cts +0 -262
  119. package/types-cjs/server-functions/flash.d.cts +0 -38
  120. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  121. package/types-cjs/server-functions/server.d.cts +0 -681
  122. package/types-cjs/server-functions/shared.d.cts +0 -523
  123. package/types-cjs/server-mock.d.cts +0 -286
  124. package/types-cjs/server.d.cts +0 -544
@@ -0,0 +1,69 @@
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, checks: false, ...attribution })`).
6
+ * The adapter asks for no console log and records only — the timeline is
7
+ * the output — which, the engine combining holds by the most demanding
8
+ * request, quiets the console and the cost checks (`hotRuns`, `hotTime`,
9
+ * `wideDeps`, `unstableMemos`, `fanOut`, `wastedRecompute`) only while
10
+ * nobody else wants them: a console session beside the tracks keeps its
11
+ * log and its checks. Pass `checks: true` to have the tracks' own hold
12
+ * run them, their findings painted as markers like any other.
13
+ */
14
+ attribution?: AttributionOptions;
15
+ /**
16
+ * Floor for run spans on `Propagation`, `Effects` and `Memos` — compute
17
+ * runs (by `totalMs`), creation runs and effect callbacks (by their
18
+ * duration): spans under it are not painted. The wave span on
19
+ * `Propagation` always is, and its label carries the counts, so a
20
+ * fan-out of runs too small to paint still reads as `47 runs`. Default
21
+ * `0` in dev (every run; Chrome shows zero-width spans zoomed in) and
22
+ * `0.05` in observe builds, so a production trace carries the runs that
23
+ * cost something.
24
+ */
25
+ minMs?: number;
26
+ /**
27
+ * Emit through `performance.measure` with `detail.devtools` — tooltips
28
+ * (the why-chain of a re-run) and properties (causes, deps, blockers…)
29
+ * on every span — instead of `console.timeStamp`. Costs a User Timing
30
+ * entry per span; the adapter clears the entries it made in batches (a
31
+ * name it shares with an app measure is left alone). Default: dev builds.
32
+ * Each path falls back to the other where its API is missing.
33
+ */
34
+ rich?: boolean;
35
+ }
36
+ /**
37
+ * Paint the attribution engine's records — and the web runtime's
38
+ * server-function `call` and `frame` records, with the server's own timing
39
+ * for each response under them (its `Server-Timing` metrics, placed by the
40
+ * browser's resource timing; the document's at enable) — as tracks in the
41
+ * Chrome Performance panel, from now until the returned function is called. The
42
+ * tracks themselves are Chrome's (its `detail.devtools` extension); in rich
43
+ * mode the spans are standard User Timing measures underneath, so any tool
44
+ * that reads those — Firefox's profiler, Lighthouse, RUM — sees the same
45
+ * spans as plain measures.
46
+ *
47
+ * Takes its own hold on the engine (`attribution.enable`): enabling beside
48
+ * a diagnostics capture or an APM adapter disturbs neither, and releasing
49
+ * here leaves theirs in place. Subscribing
50
+ * to the engine's timeline records (`create`, `effect`, `flush`, `flight`,
51
+ * `fallback`) is what turns them on — they are built only while a listener
52
+ * exists, so the engine pays for them only while the tracks are enabled.
53
+ * Every diagnostic delivered while enabled becomes a marker on the panel's
54
+ * Timings track (`SILENT_HOLD — <Search>`), annotated as a
55
+ * performance issue for the Insights sidebar when its severity is a
56
+ * warning or worse. In dev, spans and markers are emitted inside the
57
+ * `console.createTask` task of the component they belong to, so an entry's
58
+ * stack in the panel points at the JSX site that rendered the component.
59
+ *
60
+ * One instance per page: the tracks are a view of one engine, and a second
61
+ * painter would paint every span twice. A call while enabled joins the
62
+ * running instance — its options are not re-read; the first call's apply —
63
+ * and returns a release of its own; the instance is torn down when every
64
+ * release has been called (a module re-evaluated by HMR that enables again
65
+ * and disposes the old one lands back on one instance either way). A no-op
66
+ * (returning a no-op) in prod builds, where the observe tier is absent, and
67
+ * in an environment without `console.timeStamp` or `performance.measure`.
68
+ */
69
+ 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,7 +1,7 @@
1
- import { Feature, fromCrossJSON, createStream } from 'seroval';
1
+ import { fromCrossJSON, isStream, Feature, 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()
@@ -9,11 +9,11 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
9
9
  function setContainerTraceStreamMint(fn) {
10
10
  state.streamOf = fn;
11
11
  }
12
- const TRACE = Symbol.for("dom-expressions.container-trace");
13
- function materialize(marker) {
12
+ const TRACE = Symbol.for("solid.container-trace");
13
+ function materialize(marker, claiming) {
14
14
  let value = state.materialized.get(marker.$tr);
15
15
  if (value === undefined) {
16
- value = state.materializeTrace(marker);
16
+ value = state.materializeTrace(marker, claiming);
17
17
  state.materialized.set(marker.$tr, value);
18
18
  if (value !== null && typeof value === "object") state.materializedValues.add(value);
19
19
  }
@@ -28,7 +28,7 @@ function parseTrace(value, ctx) {
28
28
  };
29
29
  }
30
30
  const ContainerTracePlugin = {
31
- tag: "dom-expressions/container-trace",
31
+ tag: "solid/container-trace",
32
32
  test(value) {
33
33
  return value != null && typeof value === "object" && TRACE in value;
34
34
  },
@@ -71,61 +71,157 @@ setContainerTraceStreamMint(iterable => {
71
71
  })();
72
72
  return stream;
73
73
  });
74
- const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
74
+ const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
75
75
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
76
76
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
77
77
  ContainerTracePlugin]);
78
78
  function resolveSerializerPlugins(customPlugins) {
79
79
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
80
80
  }
81
- const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
81
+ const jsonCodecDisabledFeatures = () => Feature.RegExp;
82
82
  const JSON_CODEC_DEPTH_LIMIT = 64;
83
- function resolveCodecOptions({
84
- plugins,
85
- disabledFeatures,
86
- depthLimit
87
- } = {}) {
83
+ const RESOLVED_PLUGINS = Symbol.for("solid.codec.resolvedPlugins");
84
+ function resolveCodecOptions(options = {}) {
85
+ const {
86
+ plugins,
87
+ disabledFeatures,
88
+ depthLimit,
89
+ serializeErrorStacks
90
+ } = options;
88
91
  return {
89
- plugins: resolveSerializerPlugins(plugins),
90
- disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
91
- depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
92
+ plugins: options[RESOLVED_PLUGINS] || resolveSerializerPlugins(plugins),
93
+ disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
94
+ depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
95
+ serializeErrorStacks
92
96
  };
93
97
  }
94
98
  function createJSONDeserializer(options) {
95
99
  const refs = new Map();
96
100
  const resolved = resolveCodecOptions(options);
101
+ let owned = 0;
102
+ const pendingResolvers = new Set();
103
+ const streams = new Set();
104
+ const STREAM = 1;
105
+ const RESOLVER = 2;
106
+ function classify(value) {
107
+ if (value === null || typeof value !== "object") return 0;
108
+ try {
109
+ if (isStream(value) && typeof value.on === "function") return STREAM;
110
+ if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) return RESOLVER;
111
+ } catch {}
112
+ return 0;
113
+ }
114
+ function ownDecodedPromises() {
115
+ if (refs.size === owned) return;
116
+ let index = 0;
117
+ for (const value of refs.values()) {
118
+ if (index++ < owned) continue;
119
+ if (value instanceof Promise) value.then(undefined, () => {});else {
120
+ const kind = classify(value);
121
+ if (kind === STREAM) streams.add(value);else if (kind === RESOLVER) {
122
+ pendingResolvers.add(value);
123
+ const settled = () => pendingResolvers.delete(value);
124
+ value.p.then(settled, settled);
125
+ }
126
+ }
127
+ }
128
+ owned = refs.size;
129
+ }
130
+ function isOpenStream(stream) {
131
+ let alive = true;
132
+ const close = () => {
133
+ alive = false;
134
+ };
135
+ let off;
136
+ try {
137
+ off = stream.on({
138
+ next() {},
139
+ throw: close,
140
+ return: close
141
+ });
142
+ } catch {
143
+ return stream.alive !== false;
144
+ }
145
+ if (typeof off === "function") off();
146
+ return alive;
147
+ }
97
148
  function deserializeJSONChunk(node) {
98
- return fromCrossJSON(node, {
99
- refs,
100
- ...resolved
101
- });
149
+ try {
150
+ return fromCrossJSON(node, {
151
+ refs,
152
+ ...resolved
153
+ });
154
+ } finally {
155
+ ownDecodedPromises();
156
+ }
102
157
  }
103
158
  deserializeJSONChunk.abort = function abort(error) {
104
159
  for (const value of refs.values()) {
105
- if (value === null || typeof value !== "object") continue;
106
- if (value.__SEROVAL_STREAM__) {
160
+ const kind = classify(value);
161
+ if (kind === STREAM) {
107
162
  value.throw(error);
108
- } else if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) {
163
+ } else if (kind === RESOLVER) {
109
164
  value.p.then(undefined, () => {});
110
165
  value.f(error);
111
166
  }
112
167
  }
113
168
  };
169
+ deserializeJSONChunk.close = function close() {
170
+ for (const value of refs.values()) {
171
+ if (classify(value) === STREAM) value.return(undefined);
172
+ }
173
+ };
174
+ deserializeJSONChunk.open = function open() {
175
+ let count = pendingResolvers.size;
176
+ for (const stream of streams) {
177
+ if (isOpenStream(stream)) count++;else streams.delete(stream);
178
+ }
179
+ return count;
180
+ };
114
181
  return deserializeJSONChunk;
115
182
  }
116
183
  function createJSONDataTable(options) {
117
184
  const deserialize = createJSONDeserializer(options);
118
185
  const table = new Map();
186
+ const waits = new Map();
187
+ const settle = (w, s, value) => {
188
+ const p = w.p;
189
+ p.s = s;
190
+ p.v = value;
191
+ s === 1 ? w.r(value) : w.j(value);
192
+ for (const c of p.c) c();
193
+ };
119
194
  return {
120
195
  apply(record) {
121
196
  const value = deserialize(record.node);
122
- if (record.initial) table.set(record.key, value);
197
+ if (record.initial) {
198
+ table.set(record.key, value);
199
+ const w = waits.get(record.key);
200
+ if (w) {
201
+ waits.delete(record.key);
202
+ settle(w, 1, value);
203
+ }
204
+ }
123
205
  },
124
206
  get(key) {
125
207
  return table.get(key);
126
208
  },
127
209
  resolve(ref) {
128
- return table.get(ref.$ref);
210
+ const key = ref.$ref;
211
+ if (table.has(key)) return table.get(key);
212
+ let w = waits.get(key);
213
+ if (!w) {
214
+ waits.set(key, w = {});
215
+ const p = w.p = new Promise((r, j) => (w.r = r, w.j = j));
216
+ p.s = 0;
217
+ p.c = [];
218
+ p.then(undefined, () => {});
219
+ }
220
+ return w.p;
221
+ },
222
+ close(error) {
223
+ for (const [key, w] of waits) settle(w, 2, error || new Error(`Stream ended without delivering {$ref: "${key}"}`));
224
+ waits.clear();
129
225
  }
130
226
  };
131
227
  }