solid-js 1.8.22 → 1.9.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 (59) hide show
  1. package/dist/dev.cjs +7 -6
  2. package/dist/dev.js +567 -325
  3. package/dist/server.cjs +1 -1
  4. package/dist/server.js +169 -75
  5. package/dist/solid.cjs +7 -6
  6. package/dist/solid.js +494 -283
  7. package/h/dist/h.js +40 -9
  8. package/h/jsx-runtime/dist/jsx.js +1 -1
  9. package/h/jsx-runtime/types/index.d.ts +13 -10
  10. package/h/jsx-runtime/types/jsx.d.ts +22 -1
  11. package/h/types/hyperscript.d.ts +11 -11
  12. package/h/types/index.d.ts +1 -1
  13. package/html/dist/html.cjs +4 -2
  14. package/html/dist/html.js +222 -95
  15. package/html/types/index.d.ts +1 -1
  16. package/html/types/lit.d.ts +52 -33
  17. package/package.json +1 -5
  18. package/store/dist/dev.cjs +1 -1
  19. package/store/dist/dev.js +123 -43
  20. package/store/dist/server.cjs +4 -0
  21. package/store/dist/server.js +23 -8
  22. package/store/dist/store.cjs +1 -1
  23. package/store/dist/store.js +114 -40
  24. package/store/package.json +0 -4
  25. package/store/types/index.d.ts +21 -7
  26. package/store/types/modifiers.d.ts +6 -3
  27. package/store/types/mutable.d.ts +5 -2
  28. package/store/types/server.d.ts +26 -5
  29. package/store/types/store.d.ts +219 -62
  30. package/types/index.d.ts +75 -10
  31. package/types/jsx.d.ts +35 -8
  32. package/types/reactive/array.d.ts +12 -4
  33. package/types/reactive/observable.d.ts +25 -17
  34. package/types/reactive/scheduler.d.ts +9 -6
  35. package/types/reactive/signal.d.ts +236 -143
  36. package/types/render/Suspense.d.ts +5 -5
  37. package/types/render/component.d.ts +64 -33
  38. package/types/render/flow.d.ts +43 -31
  39. package/types/render/hydration.d.ts +15 -15
  40. package/types/server/index.d.ts +57 -2
  41. package/types/server/reactive.d.ts +73 -42
  42. package/types/server/rendering.d.ts +169 -98
  43. package/universal/dist/dev.js +28 -12
  44. package/universal/dist/universal.js +28 -12
  45. package/universal/types/index.d.ts +3 -1
  46. package/universal/types/universal.d.ts +0 -1
  47. package/web/dist/dev.cjs +57 -24
  48. package/web/dist/dev.js +679 -101
  49. package/web/dist/server.cjs +96 -15
  50. package/web/dist/server.js +676 -105
  51. package/web/dist/web.cjs +53 -23
  52. package/web/dist/web.js +664 -99
  53. package/web/package.json +0 -4
  54. package/web/storage/dist/storage.js +3 -3
  55. package/web/types/client.d.ts +5 -3
  56. package/web/types/core.d.ts +10 -1
  57. package/web/types/index.d.ts +27 -10
  58. package/web/types/server-mock.d.ts +47 -32
  59. package/web/types/server.d.ts +88 -0
package/h/dist/h.js CHANGED
@@ -1,4 +1,11 @@
1
- import { spread, assign, insert, createComponent, dynamicProperty, SVGElements } from 'solid-js/web';
1
+ import {
2
+ spread,
3
+ assign,
4
+ insert,
5
+ createComponent,
6
+ dynamicProperty,
7
+ SVGElements
8
+ } from "solid-js/web";
2
9
 
3
10
  const $ELEMENT = Symbol("hyper-element");
4
11
  function createHyperScript(r) {
@@ -19,9 +26,18 @@ function createHyperScript(r) {
19
26
  return ret;
20
27
  function item(l) {
21
28
  const type = typeof l;
22
- if (l == null) ;else if ("string" === type) {
23
- if (!e) parseClass(l);else e.appendChild(document.createTextNode(l));
24
- } else if ("number" === type || "boolean" === type || "bigint" === type || "symbol" === type || l instanceof Date || l instanceof RegExp) {
29
+ if (l == null);
30
+ else if ("string" === type) {
31
+ if (!e) parseClass(l);
32
+ else e.appendChild(document.createTextNode(l));
33
+ } else if (
34
+ "number" === type ||
35
+ "boolean" === type ||
36
+ "bigint" === type ||
37
+ "symbol" === type ||
38
+ l instanceof Date ||
39
+ l instanceof RegExp
40
+ ) {
25
41
  e.appendChild(document.createTextNode(l.toString()));
26
42
  } else if (Array.isArray(l)) {
27
43
  for (let i = 0; i < l.length; i++) item(l[i]);
@@ -33,7 +49,10 @@ function createHyperScript(r) {
33
49
  for (const k in d) {
34
50
  if (k === "class" && classes.length !== 0) {
35
51
  const fixedClasses = classes.join(" "),
36
- value = typeof d["class"].value === "function" ? () => fixedClasses + " " + d["class"].value() : fixedClasses + " " + l["class"];
52
+ value =
53
+ typeof d["class"].value === "function"
54
+ ? () => fixedClasses + " " + d["class"].value()
55
+ : fixedClasses + " " + l["class"];
37
56
  Object.defineProperty(l, "class", {
38
57
  ...d[k],
39
58
  value
@@ -45,12 +64,18 @@ function createHyperScript(r) {
45
64
  dynamic = true;
46
65
  } else if (d[k].get) dynamic = true;
47
66
  }
48
- dynamic ? r.spread(e, l, e instanceof SVGElement, !!args.length) : r.assign(e, l, e instanceof SVGElement, !!args.length);
67
+ dynamic
68
+ ? r.spread(e, l, e instanceof SVGElement, !!args.length)
69
+ : r.assign(e, l, e instanceof SVGElement, !!args.length);
49
70
  } else if ("function" === type) {
50
71
  if (!e) {
51
72
  let props,
52
73
  next = args[0];
53
- if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift();
74
+ if (
75
+ next == null ||
76
+ (typeof next === "object" && !Array.isArray(next) && !(next instanceof Element))
77
+ )
78
+ props = args.shift();
54
79
  props || (props = {});
55
80
  if (args.length) {
56
81
  props.children = args.length > 1 ? args : args[0];
@@ -66,7 +91,8 @@ function createHyperScript(r) {
66
91
  return list;
67
92
  };
68
93
  r.dynamicProperty(props, k);
69
- } else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
94
+ } else if (typeof d[k].value === "function" && !d[k].value.length)
95
+ r.dynamicProperty(props, k);
70
96
  }
71
97
  e = r.createComponent(l, props);
72
98
  args = [];
@@ -83,7 +109,12 @@ function createHyperScript(r) {
83
109
  const v = m[i],
84
110
  s = v.substring(1, v.length);
85
111
  if (!v) continue;
86
- if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") classes.push(s);else if (v[0] === "#") e.setAttribute("id", s);
112
+ if (!e)
113
+ e = r.SVGElements.has(v)
114
+ ? document.createElementNS("http://www.w3.org/2000/svg", v)
115
+ : document.createElement(v);
116
+ else if (v[0] === ".") classes.push(s);
117
+ else if (v[0] === "#") e.setAttribute("id", s);
87
118
  }
88
119
  }
89
120
  function detectMultiExpression(list) {
@@ -1,4 +1,4 @@
1
- import h from 'solid-js/h';
1
+ import h from "solid-js/h";
2
2
 
3
3
  function Fragment(props) {
4
4
  return props.children;
@@ -1,11 +1,14 @@
1
- export type { JSX } from "./jsx";
2
- import type { JSX } from "./jsx";
3
- declare function Fragment(props: {
4
- children: JSX.Element;
5
- }): JSX.Element;
6
- declare function jsx(type: any, props: any): () => (Node & {
7
- [key: string]: any;
8
- }) | (Node & {
9
- [key: string]: any;
10
- })[];
1
+ export type { JSX } from "./jsx.d.ts";
2
+ import type { JSX } from "./jsx.d.ts";
3
+ declare function Fragment(props: { children: JSX.Element }): JSX.Element;
4
+ declare function jsx(
5
+ type: any,
6
+ props: any
7
+ ): () =>
8
+ | (Node & {
9
+ [key: string]: any;
10
+ })
11
+ | (Node & {
12
+ [key: string]: any;
13
+ })[];
11
14
  export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
@@ -40,6 +40,7 @@ export namespace JSX {
40
40
  }
41
41
  ): void;
42
42
  }
43
+
43
44
  interface BoundEventHandler<T, E extends Event> {
44
45
  0: (
45
46
  data: any,
@@ -52,6 +53,19 @@ export namespace JSX {
52
53
  }
53
54
  type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
54
55
 
56
+ interface EventHandlerWithOptions<T, E extends Event> extends AddEventListenerOptions {
57
+ handleEvent: (
58
+ e: E & {
59
+ currentTarget: T;
60
+ target: Element;
61
+ }
62
+ ) => void;
63
+ }
64
+
65
+ type CustomEventHandlerUnion<T, E extends Event> =
66
+ | EventHandler<T, E>
67
+ | EventHandlerWithOptions<T, E>;
68
+
55
69
  const SERIALIZABLE: unique symbol;
56
70
  interface SerializableAttributeValue {
57
71
  toString(): string;
@@ -75,7 +89,11 @@ export namespace JSX {
75
89
  }
76
90
  interface ExplicitProperties {}
77
91
  interface ExplicitAttributes {}
92
+ interface ExplicitBoolAttributes {}
78
93
  interface CustomEvents {}
94
+ /**
95
+ * @deprecated Replaced by CustomEvents
96
+ */
79
97
  interface CustomCaptureEvents {}
80
98
  type DirectiveAttributes = {
81
99
  [Key in keyof Directives as `use:${Key}`]?: Directives[Key];
@@ -102,8 +120,11 @@ export namespace JSX {
102
120
  type AttrAttributes = {
103
121
  [Key in keyof ExplicitAttributes as `attr:${Key}`]?: ExplicitAttributes[Key];
104
122
  };
123
+ type BoolAttributes = {
124
+ [Key in keyof ExplicitBoolAttributes as `bool:${Key}`]?: ExplicitBoolAttributes[Key];
125
+ };
105
126
  type OnAttributes<T> = {
106
- [Key in keyof CustomEvents as `on:${Key}`]?: EventHandler<T, CustomEvents[Key]>;
127
+ [Key in keyof CustomEvents as `on:${Key}`]?: CustomEventHandlerUnion<T, CustomEvents[Key]>;
107
128
  };
108
129
  type OnCaptureAttributes<T> = {
109
130
  [Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<
@@ -1,20 +1,20 @@
1
1
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
2
2
  interface Runtime {
3
- insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
4
- spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
5
- assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
6
- createComponent(Comp: (props: any) => any, props: any): any;
7
- dynamicProperty(props: any, key: string): any;
8
- SVGElements: Set<string>;
3
+ insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
4
+ spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
5
+ assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
6
+ createComponent(Comp: (props: any) => any, props: any): any;
7
+ dynamicProperty(props: any, key: string): any;
8
+ SVGElements: Set<string>;
9
9
  }
10
10
  type ExpandableNode = Node & {
11
- [key: string]: any;
11
+ [key: string]: any;
12
12
  };
13
13
  export type HyperScript = {
14
- (...args: any[]): () => ExpandableNode | ExpandableNode[];
15
- Fragment: (props: {
16
- children: (() => ExpandableNode) | (() => ExpandableNode)[];
17
- }) => ExpandableNode[];
14
+ (...args: any[]): () => ExpandableNode | ExpandableNode[];
15
+ Fragment: (props: {
16
+ children: (() => ExpandableNode) | (() => ExpandableNode)[];
17
+ }) => ExpandableNode[];
18
18
  };
19
19
  export declare function createHyperScript(r: Runtime): HyperScript;
20
20
  export {};
@@ -1,3 +1,3 @@
1
- import type { HyperScript } from "./hyperscript";
1
+ import type { HyperScript } from "./hyperscript.js";
2
2
  declare const h: HyperScript;
3
3
  export default h;
@@ -330,6 +330,7 @@ function createHTML(r, {
330
330
  options.counter = childOptions.counter;
331
331
  options.templateId = childOptions.templateId;
332
332
  options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
333
+ options.isImportNode = options.isImportNode || childOptions.isImportNode;
333
334
  }
334
335
  function processComponentProps(propGroups) {
335
336
  let result = [];
@@ -440,8 +441,9 @@ function createHTML(r, {
440
441
  const templateId = options.templateId;
441
442
  options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
442
443
  const isSVG = r.SVGElements.has(node.name);
443
- const isCE = node.name.includes("-");
444
+ const isCE = node.name.includes("-") || node.attrs.some(e => e.name === "is");
444
445
  options.hasCustomElement = isCE;
446
+ options.isImportNode = (node.name === 'img' || node.name === 'iframe') && node.attrs.some(e => e.name === "loading" && e.value === 'lazy');
445
447
  if (node.attrs.some(e => e.name === "###")) {
446
448
  const spreadArgs = [];
447
449
  let current = "";
@@ -498,7 +500,7 @@ function createHTML(r, {
498
500
  options.first = false;
499
501
  processChildren(node, options);
500
502
  if (topDecl) {
501
- options.decl[0] = options.hasCustomElement ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
503
+ options.decl[0] = options.hasCustomElement || options.isImportNode ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
502
504
  }
503
505
  } else if (node.type === "text") {
504
506
  const tag = `_$el${uuid++}`;