solid-js 1.7.12 → 1.8.0-beta.0

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 (47) hide show
  1. package/dist/dev.cjs +14 -11
  2. package/dist/dev.js +544 -306
  3. package/dist/server.cjs +4 -4
  4. package/dist/server.js +172 -78
  5. package/dist/solid.cjs +14 -11
  6. package/dist/solid.js +471 -264
  7. package/h/dist/h.js +34 -8
  8. package/h/jsx-runtime/dist/jsx.js +1 -1
  9. package/h/jsx-runtime/types/index.d.ts +11 -8
  10. package/h/types/hyperscript.d.ts +11 -11
  11. package/html/dist/html.js +216 -94
  12. package/html/types/lit.d.ts +45 -31
  13. package/package.json +2 -2
  14. package/store/dist/dev.js +114 -42
  15. package/store/dist/server.js +19 -8
  16. package/store/dist/store.js +105 -39
  17. package/store/types/index.d.ts +21 -7
  18. package/store/types/modifiers.d.ts +6 -3
  19. package/store/types/mutable.d.ts +5 -2
  20. package/store/types/server.d.ts +12 -4
  21. package/store/types/store.d.ts +218 -61
  22. package/types/index.d.ts +72 -9
  23. package/types/reactive/array.d.ts +12 -4
  24. package/types/reactive/observable.d.ts +25 -17
  25. package/types/reactive/scheduler.d.ts +9 -6
  26. package/types/reactive/signal.d.ts +228 -140
  27. package/types/render/Suspense.d.ts +5 -5
  28. package/types/render/component.d.ts +62 -31
  29. package/types/render/flow.d.ts +43 -31
  30. package/types/render/hydration.d.ts +12 -12
  31. package/types/server/index.d.ts +56 -2
  32. package/types/server/reactive.d.ts +67 -40
  33. package/types/server/rendering.d.ts +166 -95
  34. package/universal/dist/dev.js +28 -12
  35. package/universal/dist/universal.js +28 -12
  36. package/universal/types/index.d.ts +3 -1
  37. package/universal/types/universal.d.ts +0 -1
  38. package/web/dist/dev.cjs +8 -5
  39. package/web/dist/dev.js +616 -82
  40. package/web/dist/server.cjs +91 -56
  41. package/web/dist/server.js +244 -125
  42. package/web/dist/web.cjs +8 -5
  43. package/web/dist/web.js +616 -82
  44. package/web/types/client.d.ts +2 -2
  45. package/web/types/core.d.ts +10 -1
  46. package/web/types/index.d.ts +27 -10
  47. package/web/types/server-mock.d.ts +47 -32
@@ -1,39 +1,98 @@
1
- import { sharedConfig, createRoot, splitProps } from 'solid-js';
2
- export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, mergeProps } from 'solid-js';
3
- import { serialize, Feature } from 'seroval';
1
+ import { sharedConfig, createRoot, splitProps } from "solid-js";
2
+ export {
3
+ ErrorBoundary,
4
+ For,
5
+ Index,
6
+ Match,
7
+ Show,
8
+ Suspense,
9
+ SuspenseList,
10
+ Switch,
11
+ createComponent,
12
+ mergeProps
13
+ } from "solid-js";
14
+ import { Feature, Serializer, GLOBAL_CONTEXT_API_SCRIPT, getCrossReferenceHeader } from "seroval";
4
15
 
5
- const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
6
- const BooleanAttributes = /*#__PURE__*/new Set(booleans);
7
- const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
8
- const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
16
+ const booleans = [
17
+ "allowfullscreen",
18
+ "async",
19
+ "autofocus",
20
+ "autoplay",
21
+ "checked",
22
+ "controls",
23
+ "default",
24
+ "disabled",
25
+ "formnovalidate",
26
+ "hidden",
27
+ "indeterminate",
28
+ "ismap",
29
+ "loop",
30
+ "multiple",
31
+ "muted",
32
+ "nomodule",
33
+ "novalidate",
34
+ "open",
35
+ "playsinline",
36
+ "readonly",
37
+ "required",
38
+ "reversed",
39
+ "seamless",
40
+ "selected"
41
+ ];
42
+ const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
43
+ const ChildProperties = /*#__PURE__*/ new Set([
44
+ "innerHTML",
45
+ "textContent",
46
+ "innerText",
47
+ "children"
48
+ ]);
49
+ const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
9
50
  className: "class",
10
51
  htmlFor: "for"
11
52
  });
12
53
 
13
- const ES2017FLAG = Feature.AggregateError
14
- | Feature.BigInt
15
- | Feature.BigIntTypedArray;
16
- function stringify(data) {
17
- return serialize(data, {
18
- disabledFeatures: ES2017FLAG
54
+ const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
55
+ const GLOBAL_IDENTIFIER = "_$HY.r";
56
+ function createSerializer({ onData, onDone, scopeId }) {
57
+ return new Serializer({
58
+ scopeId,
59
+ globalIdentifier: GLOBAL_IDENTIFIER,
60
+ disabledFeatures: ES2017FLAG,
61
+ onData,
62
+ onDone
19
63
  });
20
64
  }
65
+ function getGlobalHeaderScript() {
66
+ return GLOBAL_CONTEXT_API_SCRIPT;
67
+ }
68
+ function getLocalHeaderScript(id) {
69
+ return getCrossReferenceHeader(id);
70
+ }
21
71
 
22
- const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
23
- const REPLACE_SCRIPT = `function $df(e,n,t,o,d){if(t=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;_$HY.done?o.remove():o.replaceWith(t.content)}t.remove(),_$HY.set(e,n),_$HY.fe(e)}`;
72
+ const VOID_ELEMENTS =
73
+ /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
74
+ const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content)}n.remove(),_$HY.fe(e)}`;
24
75
  function renderToString(code, options = {}) {
76
+ const { renderId } = options;
25
77
  let scripts = "";
78
+ const serializer = createSerializer({
79
+ scopeId: renderId,
80
+ onData(script) {
81
+ if (!scripts) {
82
+ scripts = getLocalHeaderScript(renderId);
83
+ }
84
+ scripts += script;
85
+ }
86
+ });
26
87
  sharedConfig.context = {
27
- id: options.renderId || "",
88
+ id: renderId || "",
28
89
  count: 0,
29
90
  suspense: {},
30
91
  lazy: {},
31
92
  assets: [],
32
93
  nonce: options.nonce,
33
- writeResource(id, p, error) {
34
- if (sharedConfig.context.noHydrate) return;
35
- if (error) return scripts += `_$HY.set("${id}", ${stringify(p)});`;
36
- scripts += `_$HY.set("${id}", ${stringify(p)});`;
94
+ serialize(id, p) {
95
+ !sharedConfig.context.noHydrate && serializer.write(id, p);
37
96
  }
38
97
  };
39
98
  let html = createRoot(d => {
@@ -41,14 +100,13 @@ function renderToString(code, options = {}) {
41
100
  return resolveSSRNode(escape(code()));
42
101
  });
43
102
  sharedConfig.context.noHydrate = true;
103
+ serializer.close();
44
104
  html = injectAssets(sharedConfig.context.assets, html);
45
105
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
46
106
  return html;
47
107
  }
48
108
  function renderToStringAsync(code, options = {}) {
49
- const {
50
- timeoutMs = 30000
51
- } = options;
109
+ const { timeoutMs = 30000 } = options;
52
110
  let timeoutHandle;
53
111
  const timeout = new Promise((_, reject) => {
54
112
  timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
@@ -59,36 +117,44 @@ function renderToStringAsync(code, options = {}) {
59
117
  });
60
118
  }
61
119
  function renderToStream(code, options = {}) {
62
- let {
63
- nonce,
64
- onCompleteShell,
65
- onCompleteAll,
66
- renderId
67
- } = options;
120
+ let { nonce, onCompleteShell, onCompleteAll, renderId } = options;
68
121
  let dispose;
69
- const blockingResources = [];
70
- const registry = new Map();
71
- const dedupe = new WeakMap();
122
+ const blockingPromises = [];
123
+ const pushTask = task => {
124
+ if (!tasks && !firstFlushed) {
125
+ tasks = getLocalHeaderScript(renderId);
126
+ }
127
+ tasks += task + ";";
128
+ if (!scheduled && firstFlushed) {
129
+ Promise.resolve().then(writeTasks);
130
+ scheduled = true;
131
+ }
132
+ };
72
133
  const checkEnd = () => {
73
134
  if (!registry.size && !completed) {
74
135
  writeTasks();
75
- onCompleteAll && onCompleteAll({
76
- write(v) {
77
- !completed && buffer.write(v);
78
- }
79
- });
136
+ onCompleteAll &&
137
+ onCompleteAll({
138
+ write(v) {
139
+ !completed && buffer.write(v);
140
+ }
141
+ });
80
142
  writable && writable.end();
81
143
  completed = true;
82
144
  setTimeout(dispose);
83
145
  }
84
146
  };
85
- const pushTask = task => {
86
- tasks += task + ";";
87
- if (!scheduled && firstFlushed) {
88
- Promise.resolve().then(writeTasks);
89
- scheduled = true;
147
+ const serializer = createSerializer({
148
+ scopeId: options.renderId,
149
+ onData: pushTask,
150
+ onDone: checkEnd
151
+ });
152
+ const flushEnd = () => {
153
+ if (!registry.size) {
154
+ serializer.flush();
90
155
  }
91
156
  };
157
+ const registry = new Map();
92
158
  const writeTasks = () => {
93
159
  if (tasks.length && !completed && firstFlushed) {
94
160
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
@@ -119,7 +185,7 @@ function renderToStream(code, options = {}) {
119
185
  assets: [],
120
186
  nonce,
121
187
  block(p) {
122
- if (!firstFlushed) blockingResources.push(p);
188
+ if (!firstFlushed) blockingPromises.push(p);
123
189
  },
124
190
  replace(id, payloadFn) {
125
191
  if (firstFlushed) return;
@@ -127,42 +193,58 @@ function renderToStream(code, options = {}) {
127
193
  const first = html.indexOf(placeholder);
128
194
  if (first === -1) return;
129
195
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
130
- html = html.replace(html.slice(first, last + placeholder.length + 1), resolveSSRNode(payloadFn()));
196
+ html = html.replace(
197
+ html.slice(first, last + placeholder.length + 1),
198
+ resolveSSRNode(payloadFn())
199
+ );
131
200
  },
132
- writeResource(id, p, error, wait) {
201
+ serialize(id, p, wait) {
133
202
  const serverOnly = sharedConfig.context.noHydrate;
134
- if (error) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
135
- if (!p || typeof p !== "object" || !("then" in p)) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
136
- if (!firstFlushed) wait && blockingResources.push(p);else !serverOnly && pushTask(`_$HY.init("${id}")`);
137
- if (serverOnly) return;
138
- p.then(d => {
139
- !completed && pushTask(serializeSet(dedupe, id, d));
140
- }).catch(() => {
141
- !completed && pushTask(`_$HY.set("${id}", {})`);
142
- });
203
+ if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
204
+ blockingPromises.push(p);
205
+ !serverOnly &&
206
+ p
207
+ .then(d => {
208
+ serializer.write(id, d);
209
+ })
210
+ .catch(e => {
211
+ serializer.write(id, e);
212
+ });
213
+ } else if (!serverOnly) serializer.write(id, p);
143
214
  },
144
215
  registerFragment(key) {
145
216
  if (!registry.has(key)) {
146
- registry.set(key, []);
147
- firstFlushed && pushTask(`_$HY.init("${key}")`);
217
+ let resolve, reject;
218
+ const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
219
+ registry.set(key, {
220
+ resolve,
221
+ reject
222
+ });
223
+ serializer.write(key, p);
148
224
  }
149
225
  return (value, error) => {
150
226
  if (registry.has(key)) {
151
- const keys = registry.get(key);
227
+ const { resolve, reject } = registry.get(key);
152
228
  registry.delete(key);
153
- if (waitForFragments(registry, key)) return;
229
+ if (waitForFragments(registry, key)) {
230
+ resolve(true);
231
+ return;
232
+ }
154
233
  if ((value !== undefined || error) && !completed) {
155
234
  if (!firstFlushed) {
156
- Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
157
- error && pushTask(serializeSet(dedupe, key, error));
235
+ Promise.resolve().then(
236
+ () => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
237
+ );
238
+ error ? reject(error) : resolve(true);
158
239
  } else {
159
240
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
160
- pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + stringify(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
241
+ pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
242
+ resolve(true);
161
243
  scriptFlushed = true;
162
244
  }
163
245
  }
164
246
  }
165
- if (!registry.size) Promise.resolve().then(checkEnd);
247
+ if (!registry.size) Promise.resolve().then(flushEnd);
166
248
  return firstFlushed;
167
249
  };
168
250
  }
@@ -175,19 +257,16 @@ function renderToStream(code, options = {}) {
175
257
  sharedConfig.context = context;
176
258
  context.noHydrate = true;
177
259
  html = injectAssets(context.assets, html);
178
- for (const key in context.resources) {
179
- if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
180
- }
181
- for (const key of registry.keys()) pushTask(`_$HY.init("${key}")`);
182
260
  if (tasks.length) html = injectScripts(html, tasks, nonce);
183
261
  buffer.write(html);
184
262
  tasks = "";
185
263
  scheduled = false;
186
- onCompleteShell && onCompleteShell({
187
- write(v) {
188
- !completed && buffer.write(v);
189
- }
190
- });
264
+ onCompleteShell &&
265
+ onCompleteShell({
266
+ write(v) {
267
+ !completed && buffer.write(v);
268
+ }
269
+ });
191
270
  }
192
271
  return {
193
272
  then(fn) {
@@ -202,24 +281,25 @@ function renderToStream(code, options = {}) {
202
281
  complete();
203
282
  };
204
283
  } else onCompleteAll = complete;
205
- if (!registry.size) Promise.resolve().then(checkEnd);
284
+ if (!registry.size) Promise.resolve().then(flushEnd);
206
285
  },
207
286
  pipe(w) {
208
- Promise.allSettled(blockingResources).then(() => {
287
+ Promise.allSettled(blockingPromises).then(() => {
209
288
  doShell();
210
289
  buffer = writable = w;
211
290
  buffer.write(tmp);
212
291
  firstFlushed = true;
213
- if (completed) writable.end();else setTimeout(checkEnd);
292
+ if (completed) writable.end();
293
+ else setTimeout(flushEnd);
214
294
  });
215
295
  },
216
296
  pipeTo(w) {
217
- return Promise.allSettled(blockingResources).then(() => {
297
+ return Promise.allSettled(blockingPromises).then(() => {
218
298
  doShell();
219
299
  const encoder = new TextEncoder();
220
300
  const writer = w.getWriter();
221
301
  let resolve;
222
- const p = new Promise(r => resolve = r);
302
+ const p = new Promise(r => (resolve = r));
223
303
  writable = {
224
304
  end() {
225
305
  writer.releaseLock();
@@ -234,20 +314,21 @@ function renderToStream(code, options = {}) {
234
314
  };
235
315
  buffer.write(tmp);
236
316
  firstFlushed = true;
237
- if (completed) writable.end();else setTimeout(checkEnd);
317
+ if (completed) writable.end();
318
+ else setTimeout(flushEnd);
238
319
  return p;
239
320
  });
240
321
  }
241
322
  };
242
323
  }
243
324
  function HydrationScript(props) {
244
- const {
245
- nonce
246
- } = sharedConfig.context;
247
- return ssr(generateHydrationScript({
248
- nonce,
249
- ...props
250
- }));
325
+ const { nonce } = sharedConfig.context;
326
+ return ssr(
327
+ generateHydrationScript({
328
+ nonce,
329
+ ...props
330
+ })
331
+ );
251
332
  }
252
333
  function ssr(t, ...nodes) {
253
334
  if (nodes.length) {
@@ -292,7 +373,8 @@ function ssrStyle(value) {
292
373
  return result;
293
374
  }
294
375
  function ssrElement(tag, props, children, needsId) {
295
- if (props == null) props = {};else if (typeof props === "function") props = props();
376
+ if (props == null) props = {};
377
+ else if (typeof props === "function") props = props();
296
378
  const skipChildren = VOID_ELEMENTS.test(tag);
297
379
  const keys = Object.keys(props);
298
380
  let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
@@ -300,7 +382,8 @@ function ssrElement(tag, props, children, needsId) {
300
382
  for (let i = 0; i < keys.length; i++) {
301
383
  const prop = keys[i];
302
384
  if (ChildProperties.has(prop)) {
303
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
385
+ if (children === undefined && !skipChildren)
386
+ children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
304
387
  continue;
305
388
  }
306
389
  const value = props[prop];
@@ -309,10 +392,14 @@ function ssrElement(tag, props, children, needsId) {
309
392
  } else if (prop === "class" || prop === "className" || prop === "classList") {
310
393
  if (classResolved) continue;
311
394
  let n;
312
- result += `class="${escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) + ssrClassList(props.classList)}"`;
395
+ result += `class="${
396
+ escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
397
+ ssrClassList(props.classList)
398
+ }"`;
313
399
  classResolved = true;
314
400
  } else if (BooleanAttributes.has(prop)) {
315
- if (value) result += prop;else continue;
401
+ if (value) result += prop;
402
+ else continue;
316
403
  } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
317
404
  continue;
318
405
  } else {
@@ -320,16 +407,17 @@ function ssrElement(tag, props, children, needsId) {
320
407
  }
321
408
  if (i !== keys.length - 1) result += " ";
322
409
  }
323
- if (skipChildren) return {
324
- t: result + "/>"
325
- };
410
+ if (skipChildren)
411
+ return {
412
+ t: result + "/>"
413
+ };
326
414
  if (typeof children === "function") children = children();
327
415
  return {
328
416
  t: result + `>${resolveSSRNode(children, true)}</${tag}>`
329
417
  };
330
418
  }
331
419
  function ssrAttribute(key, value, isBoolean) {
332
- return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
420
+ return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
333
421
  }
334
422
  function ssrHydrationKey() {
335
423
  const hk = getHydrationKey();
@@ -373,12 +461,13 @@ function escape(s, attr) {
373
461
  left = iDelim + 1;
374
462
  iDelim = s.indexOf(delim, left);
375
463
  } while (iDelim >= 0);
376
- } else while (iAmp >= 0) {
377
- if (left < iAmp) out += s.substring(left, iAmp);
378
- out += "&amp;";
379
- left = iAmp + 1;
380
- iAmp = s.indexOf("&", left);
381
- }
464
+ } else
465
+ while (iAmp >= 0) {
466
+ if (left < iAmp) out += s.substring(left, iAmp);
467
+ out += "&amp;";
468
+ left = iAmp + 1;
469
+ iAmp = s.indexOf("&", left);
470
+ }
382
471
  return left < s.length ? out + s.substring(left) : out;
383
472
  }
384
473
  function resolveSSRNode(node, top) {
@@ -390,7 +479,7 @@ function resolveSSRNode(node, top) {
390
479
  let mapped = "";
391
480
  for (let i = 0, len = node.length; i < len; i++) {
392
481
  if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
393
- mapped += resolveSSRNode(prev = node[i]);
482
+ mapped += resolveSSRNode((prev = node[i]));
394
483
  }
395
484
  return mapped;
396
485
  }
@@ -411,11 +500,12 @@ function getAssets() {
411
500
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
412
501
  return out;
413
502
  }
414
- function generateHydrationScript({
415
- eventNames = ["click", "input"],
416
- nonce
417
- } = {}) {
418
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,a=t(s);a&&!e.completed.has(a)&&e.events.push([a,o])}))))})(window._$HY||(_$HY={events:[],completed:new WeakSet,r:{},fe(){},init(e,t){_$HY.r[e]=[new Promise((e=>t=e)),t]},set(e,t,o){(o=_$HY.r[e])&&o[1](t),_$HY.r[e]=[t]},unset(e){delete _$HY.r[e]},load:e=>_$HY.r[e]}));</script><!--xs-->`;
503
+ function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
504
+ return `<script${
505
+ nonce ? ` nonce="${nonce}"` : ""
506
+ }>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
507
+ '", "'
508
+ )}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});${getGlobalHeaderScript()}</script><!--xs-->`;
419
509
  }
420
510
  function Hydration(props) {
421
511
  if (!sharedConfig.context.noHydrate) return props.children;
@@ -450,19 +540,10 @@ function injectScripts(html, scripts, nonce) {
450
540
  }
451
541
  function waitForFragments(registry, key) {
452
542
  for (const k of [...registry.keys()].reverse()) {
453
- if (key.startsWith(k)) {
454
- registry.get(k).push(key);
455
- return true;
456
- }
543
+ if (key.startsWith(k)) return true;
457
544
  }
458
545
  return false;
459
546
  }
460
- function serializeSet(registry, key, value) {
461
- const exist = registry.get(value);
462
- if (exist) return `_$HY.set("${key}", _$HY.r["${exist}"][0])`;
463
- value !== null && typeof value === "object" && registry.set(value, key);
464
- return `_$HY.set("${key}", ${stringify(value)})`;
465
- }
466
547
  function replacePlaceholder(html, key, value) {
467
548
  const marker = `<template id="pl-${key}">`;
468
549
  const close = `<!--pl-${key}-->`;
@@ -476,9 +557,7 @@ function Assets(props) {
476
557
  }
477
558
  function pipeToNodeWritable(code, writable, options = {}) {
478
559
  if (options.onReady) {
479
- options.onCompleteShell = ({
480
- write
481
- }) => {
560
+ options.onCompleteShell = ({ write }) => {
482
561
  options.onReady({
483
562
  write,
484
563
  startWriting() {
@@ -492,9 +571,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
492
571
  }
493
572
  function pipeToWritable(code, writable, options = {}) {
494
573
  if (options.onReady) {
495
- options.onCompleteShell = ({
496
- write
497
- }) => {
574
+ options.onCompleteShell = ({ write }) => {
498
575
  options.onReady({
499
576
  write,
500
577
  startWriting() {
@@ -524,11 +601,19 @@ function ssrSpread(props, isSVG, skipChildren) {
524
601
  } else if (prop === "class" || prop === "className" || prop === "classList") {
525
602
  if (classResolved) continue;
526
603
  let n;
527
- result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
604
+ result += `class="${(n = props.class) ? n + " " : ""}${
605
+ (n = props.className) ? n + " " : ""
606
+ }${ssrClassList(props.classList)}"`;
528
607
  classResolved = true;
529
608
  } else if (BooleanAttributes.has(prop)) {
530
- if (value) result += prop;else continue;
531
- } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
609
+ if (value) result += prop;
610
+ else continue;
611
+ } else if (
612
+ value == undefined ||
613
+ prop === "ref" ||
614
+ prop.slice(0, 2) === "on" ||
615
+ prop.slice(0, 5) === "prop:"
616
+ ) {
532
617
  continue;
533
618
  } else {
534
619
  if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
@@ -552,7 +637,8 @@ function Dynamic(props) {
552
637
  const comp = p.component,
553
638
  t = typeof comp;
554
639
  if (comp) {
555
- if (t === "function") return comp(others);else if (t === "string") {
640
+ if (t === "function") return comp(others);
641
+ else if (t === "string") {
556
642
  return ssrElement(comp, others, undefined, true);
557
643
  }
558
644
  }
@@ -561,4 +647,37 @@ function Portal(props) {
561
647
  return "";
562
648
  }
563
649
 
564
- export { Assets, Dynamic, Hydration, HydrationScript, NoHydration, Portal, addEventListener, delegateEvents, escape, generateHydrationScript, getAssets, getHydrationKey, hydrate, insert, isDev, isServer, pipeToNodeWritable, pipeToWritable, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, stringify, useAssets };
650
+ export {
651
+ Assets,
652
+ Dynamic,
653
+ Hydration,
654
+ HydrationScript,
655
+ NoHydration,
656
+ Portal,
657
+ addEventListener,
658
+ delegateEvents,
659
+ escape,
660
+ generateHydrationScript,
661
+ getAssets,
662
+ getHydrationKey,
663
+ hydrate,
664
+ insert,
665
+ isDev,
666
+ isServer,
667
+ pipeToNodeWritable,
668
+ pipeToWritable,
669
+ render,
670
+ renderToStream,
671
+ renderToString,
672
+ renderToStringAsync,
673
+ resolveSSRNode,
674
+ spread,
675
+ ssr,
676
+ ssrAttribute,
677
+ ssrClassList,
678
+ ssrElement,
679
+ ssrHydrationKey,
680
+ ssrSpread,
681
+ ssrStyle,
682
+ useAssets
683
+ };
package/web/dist/web.cjs CHANGED
@@ -256,7 +256,8 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
256
256
  function hydrate$1(code, element, options = {}) {
257
257
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
258
258
  solidJs.sharedConfig.events = globalThis._$HY.events;
259
- solidJs.sharedConfig.load = globalThis._$HY.load;
259
+ solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
260
+ solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
260
261
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
261
262
  solidJs.sharedConfig.registry = new Map();
262
263
  solidJs.sharedConfig.context = {
@@ -291,7 +292,7 @@ function getNextMarker(start) {
291
292
  while (end) {
292
293
  if (end.nodeType === 8) {
293
294
  const v = end.nodeValue;
294
- if (v === "#") count++;else if (v === "/") {
295
+ if (v === "$") count++;else if (v === "/") {
295
296
  if (count === 0) return [end, current];
296
297
  count--;
297
298
  }
@@ -441,9 +442,11 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
441
442
  }
442
443
  if (solidJs.sharedConfig.context) {
443
444
  if (!array.length) return current;
444
- for (let i = 0; i < array.length; i++) {
445
- if (array[i].parentNode) return current = array;
446
- }
445
+ if (marker === undefined) return [...parent.childNodes];
446
+ let node = array[0];
447
+ let nodes = [node];
448
+ while ((node = node.nextSibling) !== marker) nodes.push(node);
449
+ return current = nodes;
447
450
  }
448
451
  if (array.length === 0) {
449
452
  current = cleanChildren(parent, current, marker);