solid-js 1.7.10 → 1.7.12

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