solid-js 1.7.8 → 1.7.9

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 (49) hide show
  1. package/dist/dev.js +534 -296
  2. package/dist/server.js +175 -77
  3. package/dist/solid.js +461 -254
  4. package/h/dist/h.cjs +2 -2
  5. package/h/dist/h.js +36 -10
  6. package/h/jsx-runtime/dist/jsx.js +1 -1
  7. package/h/jsx-runtime/types/index.d.ts +11 -8
  8. package/h/jsx-runtime/types/jsx.d.ts +3 -0
  9. package/h/types/hyperscript.d.ts +11 -11
  10. package/h/types/index.d.ts +3 -2
  11. package/html/dist/html.cjs +2 -2
  12. package/html/dist/html.js +218 -96
  13. package/html/types/index.d.ts +3 -2
  14. package/html/types/lit.d.ts +45 -31
  15. package/package.json +1 -1
  16. package/store/dist/dev.cjs +34 -32
  17. package/store/dist/dev.js +141 -67
  18. package/store/dist/server.js +19 -8
  19. package/store/dist/store.cjs +34 -32
  20. package/store/dist/store.js +132 -64
  21. package/store/types/index.d.ts +21 -7
  22. package/store/types/modifiers.d.ts +6 -3
  23. package/store/types/mutable.d.ts +5 -2
  24. package/store/types/server.d.ts +12 -4
  25. package/store/types/store.d.ts +217 -63
  26. package/types/index.d.ts +69 -9
  27. package/types/jsx.d.ts +3 -0
  28. package/types/reactive/array.d.ts +12 -4
  29. package/types/reactive/observable.d.ts +25 -17
  30. package/types/reactive/scheduler.d.ts +9 -6
  31. package/types/reactive/signal.d.ts +227 -136
  32. package/types/render/Suspense.d.ts +5 -5
  33. package/types/render/component.d.ts +62 -31
  34. package/types/render/flow.d.ts +43 -31
  35. package/types/render/hydration.d.ts +12 -12
  36. package/types/server/index.d.ts +55 -2
  37. package/types/server/reactive.d.ts +67 -40
  38. package/types/server/rendering.d.ts +171 -95
  39. package/universal/dist/dev.js +28 -12
  40. package/universal/dist/universal.js +28 -12
  41. package/universal/types/index.d.ts +3 -1
  42. package/universal/types/universal.d.ts +0 -1
  43. package/web/dist/dev.js +610 -79
  44. package/web/dist/server.js +176 -77
  45. package/web/dist/web.js +610 -79
  46. package/web/types/client.d.ts +2 -2
  47. package/web/types/core.d.ts +10 -1
  48. package/web/types/index.d.ts +27 -10
  49. package/web/types/server-mock.d.ts +47 -32
@@ -1,25 +1,65 @@
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 { serialize, Feature } 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;
54
+ const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
16
55
  function stringify(data) {
17
56
  return serialize(data, {
18
57
  disabledFeatures: ES2017FLAG
19
58
  });
20
59
  }
21
60
 
22
- const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
61
+ const VOID_ELEMENTS =
62
+ /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
23
63
  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)}`;
24
64
  function renderToString(code, options = {}) {
25
65
  let scripts = "";
@@ -32,7 +72,7 @@ function renderToString(code, options = {}) {
32
72
  nonce: options.nonce,
33
73
  writeResource(id, p, error) {
34
74
  if (sharedConfig.context.noHydrate) return;
35
- if (error) return scripts += `_$HY.set("${id}", ${stringify(p)});`;
75
+ if (error) return (scripts += `_$HY.set("${id}", ${stringify(p)});`);
36
76
  scripts += `_$HY.set("${id}", ${stringify(p)});`;
37
77
  }
38
78
  };
@@ -46,9 +86,7 @@ function renderToString(code, options = {}) {
46
86
  return html;
47
87
  }
48
88
  function renderToStringAsync(code, options = {}) {
49
- const {
50
- timeoutMs = 30000
51
- } = options;
89
+ const { timeoutMs = 30000 } = options;
52
90
  let timeoutHandle;
53
91
  const timeout = new Promise((_, reject) => {
54
92
  timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
@@ -59,12 +97,7 @@ function renderToStringAsync(code, options = {}) {
59
97
  });
60
98
  }
61
99
  function renderToStream(code, options = {}) {
62
- let {
63
- nonce,
64
- onCompleteShell,
65
- onCompleteAll,
66
- renderId
67
- } = options;
100
+ let { nonce, onCompleteShell, onCompleteAll, renderId } = options;
68
101
  let dispose;
69
102
  const blockingResources = [];
70
103
  const registry = new Map();
@@ -72,11 +105,12 @@ function renderToStream(code, options = {}) {
72
105
  const checkEnd = () => {
73
106
  if (!registry.size && !completed) {
74
107
  writeTasks();
75
- onCompleteAll && onCompleteAll({
76
- write(v) {
77
- !completed && buffer.write(v);
78
- }
79
- });
108
+ onCompleteAll &&
109
+ onCompleteAll({
110
+ write(v) {
111
+ !completed && buffer.write(v);
112
+ }
113
+ });
80
114
  writable && writable.end();
81
115
  completed = true;
82
116
  setTimeout(dispose);
@@ -127,13 +161,18 @@ function renderToStream(code, options = {}) {
127
161
  const first = html.indexOf(placeholder);
128
162
  if (first === -1) return;
129
163
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
130
- html = html.replace(html.slice(first, last + placeholder.length + 1), resolveSSRNode(payloadFn()));
164
+ html = html.replace(
165
+ html.slice(first, last + placeholder.length + 1),
166
+ resolveSSRNode(payloadFn())
167
+ );
131
168
  },
132
169
  writeResource(id, p, error, wait) {
133
170
  const serverOnly = sharedConfig.context.noHydrate;
134
171
  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}")`);
172
+ if (!p || typeof p !== "object" || !("then" in p))
173
+ return !serverOnly && pushTask(serializeSet(dedupe, id, p));
174
+ if (!firstFlushed) wait && blockingResources.push(p);
175
+ else !serverOnly && pushTask(`_$HY.init("${id}")`);
137
176
  if (serverOnly) return;
138
177
  p.then(d => {
139
178
  !completed && pushTask(serializeSet(dedupe, id, d));
@@ -153,11 +192,19 @@ function renderToStream(code, options = {}) {
153
192
  if (waitForFragments(registry, key)) return;
154
193
  if ((value !== undefined || error) && !completed) {
155
194
  if (!firstFlushed) {
156
- Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
195
+ Promise.resolve().then(
196
+ () => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
197
+ );
157
198
  error && pushTask(serializeSet(dedupe, key, error));
158
199
  } else {
159
200
  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 : ""}`);
201
+ pushTask(
202
+ `${
203
+ keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""
204
+ }$df("${key}"${error ? "," + stringify(error) : ""})${
205
+ !scriptFlushed ? ";" + REPLACE_SCRIPT : ""
206
+ }`
207
+ );
161
208
  scriptFlushed = true;
162
209
  }
163
210
  }
@@ -176,18 +223,20 @@ function renderToStream(code, options = {}) {
176
223
  context.noHydrate = true;
177
224
  html = injectAssets(context.assets, html);
178
225
  for (const key in context.resources) {
179
- if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
226
+ if (!("data" in context.resources[key] || context.resources[key].ref[0].error))
227
+ pushTask(`_$HY.init("${key}")`);
180
228
  }
181
229
  for (const key of registry.keys()) pushTask(`_$HY.init("${key}")`);
182
230
  if (tasks.length) html = injectScripts(html, tasks, nonce);
183
231
  buffer.write(html);
184
232
  tasks = "";
185
233
  scheduled = false;
186
- onCompleteShell && onCompleteShell({
187
- write(v) {
188
- !completed && buffer.write(v);
189
- }
190
- });
234
+ onCompleteShell &&
235
+ onCompleteShell({
236
+ write(v) {
237
+ !completed && buffer.write(v);
238
+ }
239
+ });
191
240
  }
192
241
  return {
193
242
  then(fn) {
@@ -210,7 +259,8 @@ function renderToStream(code, options = {}) {
210
259
  buffer = writable = w;
211
260
  buffer.write(tmp);
212
261
  firstFlushed = true;
213
- if (completed) writable.end();else setTimeout(checkEnd);
262
+ if (completed) writable.end();
263
+ else setTimeout(checkEnd);
214
264
  });
215
265
  },
216
266
  pipeTo(w) {
@@ -231,19 +281,20 @@ function renderToStream(code, options = {}) {
231
281
  };
232
282
  buffer.write(tmp);
233
283
  firstFlushed = true;
234
- if (completed) writable.end();else setTimeout(checkEnd);
284
+ if (completed) writable.end();
285
+ else setTimeout(checkEnd);
235
286
  });
236
287
  }
237
288
  };
238
289
  }
239
290
  function HydrationScript(props) {
240
- const {
241
- nonce
242
- } = sharedConfig.context;
243
- return ssr(generateHydrationScript({
244
- nonce,
245
- ...props
246
- }));
291
+ const { nonce } = sharedConfig.context;
292
+ return ssr(
293
+ generateHydrationScript({
294
+ nonce,
295
+ ...props
296
+ })
297
+ );
247
298
  }
248
299
  function ssr(t, ...nodes) {
249
300
  if (nodes.length) {
@@ -288,7 +339,8 @@ function ssrStyle(value) {
288
339
  return result;
289
340
  }
290
341
  function ssrElement(tag, props, children, needsId) {
291
- if (props == null) props = {};else if (typeof props === "function") props = props();
342
+ if (props == null) props = {};
343
+ else if (typeof props === "function") props = props();
292
344
  const skipChildren = VOID_ELEMENTS.test(tag);
293
345
  const keys = Object.keys(props);
294
346
  let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
@@ -296,7 +348,8 @@ function ssrElement(tag, props, children, needsId) {
296
348
  for (let i = 0; i < keys.length; i++) {
297
349
  const prop = keys[i];
298
350
  if (ChildProperties.has(prop)) {
299
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
351
+ if (children === undefined && !skipChildren)
352
+ children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
300
353
  continue;
301
354
  }
302
355
  const value = props[prop];
@@ -305,10 +358,14 @@ function ssrElement(tag, props, children, needsId) {
305
358
  } else if (prop === "class" || prop === "className" || prop === "classList") {
306
359
  if (classResolved) continue;
307
360
  let n;
308
- result += `class="${escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) + ssrClassList(props.classList)}"`;
361
+ result += `class="${
362
+ escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
363
+ ssrClassList(props.classList)
364
+ }"`;
309
365
  classResolved = true;
310
366
  } else if (BooleanAttributes.has(prop)) {
311
- if (value) result += prop;else continue;
367
+ if (value) result += prop;
368
+ else continue;
312
369
  } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
313
370
  continue;
314
371
  } else {
@@ -316,16 +373,17 @@ function ssrElement(tag, props, children, needsId) {
316
373
  }
317
374
  if (i !== keys.length - 1) result += " ";
318
375
  }
319
- if (skipChildren) return {
320
- t: result + "/>"
321
- };
376
+ if (skipChildren)
377
+ return {
378
+ t: result + "/>"
379
+ };
322
380
  if (typeof children === "function") children = children();
323
381
  return {
324
382
  t: result + `>${resolveSSRNode(children, true)}</${tag}>`
325
383
  };
326
384
  }
327
385
  function ssrAttribute(key, value, isBoolean) {
328
- return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
386
+ return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
329
387
  }
330
388
  function ssrHydrationKey() {
331
389
  const hk = getHydrationKey();
@@ -369,12 +427,13 @@ function escape(s, attr) {
369
427
  left = iDelim + 1;
370
428
  iDelim = s.indexOf(delim, left);
371
429
  } while (iDelim >= 0);
372
- } else while (iAmp >= 0) {
373
- if (left < iAmp) out += s.substring(left, iAmp);
374
- out += "&amp;";
375
- left = iAmp + 1;
376
- iAmp = s.indexOf("&", left);
377
- }
430
+ } else
431
+ while (iAmp >= 0) {
432
+ if (left < iAmp) out += s.substring(left, iAmp);
433
+ out += "&amp;";
434
+ left = iAmp + 1;
435
+ iAmp = s.indexOf("&", left);
436
+ }
378
437
  return left < s.length ? out + s.substring(left) : out;
379
438
  }
380
439
  function resolveSSRNode(node, top) {
@@ -386,7 +445,7 @@ function resolveSSRNode(node, top) {
386
445
  let mapped = "";
387
446
  for (let i = 0, len = node.length; i < len; i++) {
388
447
  if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
389
- mapped += resolveSSRNode(prev = node[i]);
448
+ mapped += resolveSSRNode((prev = node[i]));
390
449
  }
391
450
  return mapped;
392
451
  }
@@ -407,11 +466,12 @@ function getAssets() {
407
466
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
408
467
  return out;
409
468
  }
410
- function generateHydrationScript({
411
- eventNames = ["click", "input"],
412
- nonce
413
- } = {}) {
414
- 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-->`;
469
+ function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
470
+ return `<script${
471
+ nonce ? ` nonce="${nonce}"` : ""
472
+ }>(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
473
+ '", "'
474
+ )}"].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-->`;
415
475
  }
416
476
  function Hydration(props) {
417
477
  if (!sharedConfig.context.noHydrate) return props.children;
@@ -472,9 +532,7 @@ function Assets(props) {
472
532
  }
473
533
  function pipeToNodeWritable(code, writable, options = {}) {
474
534
  if (options.onReady) {
475
- options.onCompleteShell = ({
476
- write
477
- }) => {
535
+ options.onCompleteShell = ({ write }) => {
478
536
  options.onReady({
479
537
  write,
480
538
  startWriting() {
@@ -488,9 +546,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
488
546
  }
489
547
  function pipeToWritable(code, writable, options = {}) {
490
548
  if (options.onReady) {
491
- options.onCompleteShell = ({
492
- write
493
- }) => {
549
+ options.onCompleteShell = ({ write }) => {
494
550
  options.onReady({
495
551
  write,
496
552
  startWriting() {
@@ -520,11 +576,19 @@ function ssrSpread(props, isSVG, skipChildren) {
520
576
  } else if (prop === "class" || prop === "className" || prop === "classList") {
521
577
  if (classResolved) continue;
522
578
  let n;
523
- result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
579
+ result += `class="${(n = props.class) ? n + " " : ""}${
580
+ (n = props.className) ? n + " " : ""
581
+ }${ssrClassList(props.classList)}"`;
524
582
  classResolved = true;
525
583
  } else if (BooleanAttributes.has(prop)) {
526
- if (value) result += prop;else continue;
527
- } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
584
+ if (value) result += prop;
585
+ else continue;
586
+ } else if (
587
+ value == undefined ||
588
+ prop === "ref" ||
589
+ prop.slice(0, 2) === "on" ||
590
+ prop.slice(0, 5) === "prop:"
591
+ ) {
528
592
  continue;
529
593
  } else {
530
594
  if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
@@ -548,7 +612,8 @@ function Dynamic(props) {
548
612
  const comp = p.component,
549
613
  t = typeof comp;
550
614
  if (comp) {
551
- if (t === "function") return comp(others);else if (t === "string") {
615
+ if (t === "function") return comp(others);
616
+ else if (t === "string") {
552
617
  return ssrElement(comp, others, undefined, true);
553
618
  }
554
619
  }
@@ -557,4 +622,38 @@ function Portal(props) {
557
622
  return "";
558
623
  }
559
624
 
560
- 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 };
625
+ export {
626
+ Assets,
627
+ Dynamic,
628
+ Hydration,
629
+ HydrationScript,
630
+ NoHydration,
631
+ Portal,
632
+ addEventListener,
633
+ delegateEvents,
634
+ escape,
635
+ generateHydrationScript,
636
+ getAssets,
637
+ getHydrationKey,
638
+ hydrate,
639
+ insert,
640
+ isDev,
641
+ isServer,
642
+ pipeToNodeWritable,
643
+ pipeToWritable,
644
+ render,
645
+ renderToStream,
646
+ renderToString,
647
+ renderToStringAsync,
648
+ resolveSSRNode,
649
+ spread,
650
+ ssr,
651
+ ssrAttribute,
652
+ ssrClassList,
653
+ ssrElement,
654
+ ssrHydrationKey,
655
+ ssrSpread,
656
+ ssrStyle,
657
+ stringify,
658
+ useAssets
659
+ };