@solidjs/web 2.0.0-beta.8 → 2.0.0-beta.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.
package/README.md CHANGED
@@ -1,7 +1,30 @@
1
- # Solid Web
1
+ # @solidjs/web
2
2
 
3
- This submodule contains the web specific APIs for Solid that are mostly internal methods imported during compilation. It has all the code to render for the web on the server and the browser.
3
+ Solid 2.0's web platform runtime DOM rendering, hydration, server-side rendering, and the web-only control-flow components (`Portal`, `Dynamic`).
4
4
 
5
- In addition this modules provides the primary entry point methods `render`, `hydrate`, `renderToString`, `renderToStringAsync`, `pipeToNodeWritable`, and `pipeToWritable`. As well as a few web specific control flow components `<Portal>` and `<Dynamic>`.
5
+ > **Solid 2.0 (experimental beta).** In 1.x this package was the `solid-js/web` subpath; in 2.0 it's a separate `@solidjs/web` package.
6
+ >
7
+ > See [`solid-js`'s CHEATSHEET](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md) and [MIGRATION guide](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md) for the 2.0 surface.
6
8
 
7
- Refer to the [website](https://docs.solidjs.com) for documentation.
9
+ ## Entry points
10
+
11
+ ```ts
12
+ // Browser / hydration
13
+ import { render, hydrate, Portal, Dynamic, dynamic } from "@solidjs/web";
14
+
15
+ // Server (SSR)
16
+ import {
17
+ renderToString,
18
+ renderToStringAsync,
19
+ renderToStream,
20
+ isServer
21
+ } from "@solidjs/web";
22
+ ```
23
+
24
+ The control-flow components from `solid-js` (`For`, `Show`, `Switch`/`Match`, `Loading`, `Errored`, `Repeat`, `Reveal`) are also re-exported from `@solidjs/web` for convenience.
25
+
26
+ ## More
27
+
28
+ - [Documentation](https://docs.solidjs.com)
29
+ - [Cheatsheet (2.0 public API)](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md)
30
+ - [Migration guide (1.x → 2.0)](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md)
package/dist/dev.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var solidJs = require('solid-js');
4
- var signals = require('@solidjs/signals');
5
4
 
6
5
  const DOMWithState = {
7
6
  INPUT: {
@@ -45,6 +44,8 @@ const Namespaces = {
45
44
  xlink: "http://www.w3.org/1999/xlink",
46
45
  xml: "http://www.w3.org/XML/1998/namespace"
47
46
  };
47
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
48
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
48
49
  const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
49
50
  "webview",
50
51
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
@@ -56,9 +57,7 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
56
57
  transparent: true,
57
58
  ...options
58
59
  } : transparentOptions);
59
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
60
- transparent: true
61
- }) : solidJs.createMemo(() => fn());
60
+ const memo = fn => solidJs.createMemo(() => fn());
62
61
 
63
62
  function reconcileArrays(parentNode, a, b) {
64
63
  let bLength = b.length,
@@ -118,6 +117,7 @@ function reconcileArrays(parentNode, a, b) {
118
117
  }
119
118
 
120
119
  const $$EVENTS = "_$DX_DELEGATE";
120
+ const INNER_OWNED = {};
121
121
  function render$1(code, element, init, options = {}) {
122
122
  if (!element) {
123
123
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
@@ -126,7 +126,12 @@ function render$1(code, element, init, options = {}) {
126
126
  let disposer;
127
127
  solidJs.createRoot(dispose => {
128
128
  disposer = dispose;
129
- element === document ? solidJs.flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
129
+ if (element === document) {
130
+ solidJs.flatten(code);
131
+ } else {
132
+ const tree = code();
133
+ insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
134
+ }
130
135
  }, {
131
136
  id: options.renderId
132
137
  });
@@ -173,7 +178,7 @@ function setAttribute(node, name, value) {
173
178
  }
174
179
  function setAttributeNS(node, namespace, name, value) {
175
180
  if (isHydrating(node)) return;
176
- if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
181
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
177
182
  }
178
183
  function className(node, value, prev) {
179
184
  if (isHydrating(node)) return;
@@ -225,7 +230,6 @@ function style(node, value, prev) {
225
230
  if (typeof value === "string") return nodeStyle.cssText = value;
226
231
  typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
227
232
  prev || (prev = {});
228
- value || (value = {});
229
233
  let v, s;
230
234
  for (s in value) {
231
235
  v = value[s];
@@ -289,13 +293,25 @@ function insert(parent, accessor, marker, initial, options) {
289
293
  accessor = normalize(accessor, initial, multi, true);
290
294
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
291
295
  }
292
- accessor = memo(accessor, true);
293
296
  if (multi && initial.length === 0) {
294
297
  const placeholder = document.createTextNode("");
295
298
  childRoot.insertBefore(placeholder, marker);
296
299
  initial = [placeholder];
297
300
  }
298
- effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker), options);
301
+ let current = initial;
302
+ effect(() => {
303
+ const value = normalize(accessor(), current, multi, true);
304
+ if (typeof value !== "function") return value;
305
+ effect(() => normalize(value, current, multi), inner => {
306
+ insertExpression(parent, inner, current, marker);
307
+ current = inner;
308
+ }, options);
309
+ return INNER_OWNED;
310
+ }, value => {
311
+ if (value === INNER_OWNED) return;
312
+ insertExpression(parent, value, current, marker);
313
+ current = value;
314
+ }, options);
299
315
  }
300
316
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
301
317
  const nodeName = node.nodeName;
@@ -718,35 +734,19 @@ function escape(html) {}
718
734
  const isServer = false;
719
735
  const isDev = true;
720
736
  function render(code, element, init, options = {}) {
721
- if (!element) {
722
- throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
723
- }
724
- const renderRoot = element.localName === "template" ? element.content : element;
725
- let disposer;
726
- solidJs.createRoot(dispose => {
727
- disposer = dispose;
728
- if (element === document) {
729
- solidJs.flatten(code);
730
- return;
731
- }
732
- const marker = renderRoot.firstChild ? null : undefined;
733
- solidJs.enforceLoadingBoundary(true);
734
- try {
735
- const tree = code();
736
- insert(element, () => tree, marker, init, {
737
+ solidJs.enforceLoadingBoundary(true);
738
+ try {
739
+ const dispose = render$1(code, element, init, {
740
+ ...options,
741
+ insertOptions: {
737
742
  schedule: true
738
- });
739
- } finally {
740
- solidJs.enforceLoadingBoundary(false);
741
- }
742
- }, {
743
- id: options.renderId
744
- });
745
- solidJs.flush();
746
- return () => {
747
- disposer();
748
- renderRoot.textContent = "";
749
- };
743
+ }
744
+ });
745
+ solidJs.flush();
746
+ return dispose;
747
+ } finally {
748
+ solidJs.enforceLoadingBoundary(false);
749
+ }
750
750
  }
751
751
  const hydrate = (...args) => {
752
752
  solidJs.enableHydration();
@@ -772,26 +772,30 @@ function Portal(props) {
772
772
  });
773
773
  return treeMarker;
774
774
  }
775
- function createDynamic(component, props) {
776
- const cached = solidJs.createMemo(component);
777
- return solidJs.createMemo(() => {
778
- const component = cached();
779
- switch (typeof component) {
780
- case "function":
781
- Object.assign(component, {
782
- [solidJs.$DEVCOMP]: true
783
- });
784
- return solidJs.untrack(() => component(props));
785
- case "string":
786
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
787
- spread(el, props);
788
- return el;
789
- }
775
+ function dynamic(source) {
776
+ const cached = solidJs.createMemo(source, {
777
+ lazy: true
790
778
  });
779
+ return props => {
780
+ return solidJs.createMemo(() => {
781
+ const component = cached();
782
+ switch (typeof component) {
783
+ case "function":
784
+ Object.assign(component, {
785
+ [solidJs.$DEVCOMP]: true
786
+ });
787
+ return solidJs.untrack(() => component(props));
788
+ case "string":
789
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
790
+ spread(el, props);
791
+ return el;
792
+ }
793
+ });
794
+ };
791
795
  }
792
796
  function Dynamic(props) {
793
- const others = solidJs.omit(props, "component");
794
- return createDynamic(() => props.component, others);
797
+ const Comp = dynamic(() => props.component);
798
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
795
799
  }
796
800
  function createElement(tagName, is = undefined) {
797
801
  return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
@@ -882,15 +886,17 @@ exports.HydrationScript = voidFn;
882
886
  exports.MathMLElements = MathMLElements;
883
887
  exports.Namespaces = Namespaces;
884
888
  exports.Portal = Portal;
889
+ exports.RawTextElements = RawTextElements;
885
890
  exports.RequestContext = RequestContext;
886
891
  exports.SVGElements = SVGElements;
892
+ exports.VoidElements = VoidElements;
887
893
  exports.addEventListener = addEventListener;
888
894
  exports.applyRef = applyRef;
889
895
  exports.assign = assign;
890
896
  exports.className = className;
891
897
  exports.clearDelegatedEvents = clearDelegatedEvents;
892
- exports.createDynamic = createDynamic;
893
898
  exports.delegateEvents = delegateEvents;
899
+ exports.dynamic = dynamic;
894
900
  exports.dynamicProperty = dynamicProperty;
895
901
  exports.effect = effect;
896
902
  exports.escape = escape;
package/dist/dev.js CHANGED
@@ -1,6 +1,5 @@
1
- import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { createMemo } from '@solidjs/signals';
4
3
 
5
4
  const DOMWithState = {
6
5
  INPUT: {
@@ -44,6 +43,8 @@ const Namespaces = {
44
43
  xlink: "http://www.w3.org/1999/xlink",
45
44
  xml: "http://www.w3.org/XML/1998/namespace"
46
45
  };
46
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
47
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
47
48
  const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
48
49
  "webview",
49
50
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
@@ -55,9 +56,7 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
55
56
  transparent: true,
56
57
  ...options
57
58
  } : transparentOptions);
58
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
59
- transparent: true
60
- }) : createMemo$1(() => fn());
59
+ const memo = fn => createMemo(() => fn());
61
60
 
62
61
  function reconcileArrays(parentNode, a, b) {
63
62
  let bLength = b.length,
@@ -117,6 +116,7 @@ function reconcileArrays(parentNode, a, b) {
117
116
  }
118
117
 
119
118
  const $$EVENTS = "_$DX_DELEGATE";
119
+ const INNER_OWNED = {};
120
120
  function render$1(code, element, init, options = {}) {
121
121
  if (!element) {
122
122
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
@@ -125,7 +125,12 @@ function render$1(code, element, init, options = {}) {
125
125
  let disposer;
126
126
  createRoot(dispose => {
127
127
  disposer = dispose;
128
- element === document ? flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
128
+ if (element === document) {
129
+ flatten(code);
130
+ } else {
131
+ const tree = code();
132
+ insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
133
+ }
129
134
  }, {
130
135
  id: options.renderId
131
136
  });
@@ -172,7 +177,7 @@ function setAttribute(node, name, value) {
172
177
  }
173
178
  function setAttributeNS(node, namespace, name, value) {
174
179
  if (isHydrating(node)) return;
175
- if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
180
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
176
181
  }
177
182
  function className(node, value, prev) {
178
183
  if (isHydrating(node)) return;
@@ -224,7 +229,6 @@ function style(node, value, prev) {
224
229
  if (typeof value === "string") return nodeStyle.cssText = value;
225
230
  typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
226
231
  prev || (prev = {});
227
- value || (value = {});
228
232
  let v, s;
229
233
  for (s in value) {
230
234
  v = value[s];
@@ -288,13 +292,25 @@ function insert(parent, accessor, marker, initial, options) {
288
292
  accessor = normalize(accessor, initial, multi, true);
289
293
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
290
294
  }
291
- accessor = memo(accessor, true);
292
295
  if (multi && initial.length === 0) {
293
296
  const placeholder = document.createTextNode("");
294
297
  childRoot.insertBefore(placeholder, marker);
295
298
  initial = [placeholder];
296
299
  }
297
- effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker), options);
300
+ let current = initial;
301
+ effect(() => {
302
+ const value = normalize(accessor(), current, multi, true);
303
+ if (typeof value !== "function") return value;
304
+ effect(() => normalize(value, current, multi), inner => {
305
+ insertExpression(parent, inner, current, marker);
306
+ current = inner;
307
+ }, options);
308
+ return INNER_OWNED;
309
+ }, value => {
310
+ if (value === INNER_OWNED) return;
311
+ insertExpression(parent, value, current, marker);
312
+ current = value;
313
+ }, options);
298
314
  }
299
315
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
300
316
  const nodeName = node.nodeName;
@@ -717,35 +733,19 @@ function escape(html) {}
717
733
  const isServer = false;
718
734
  const isDev = true;
719
735
  function render(code, element, init, options = {}) {
720
- if (!element) {
721
- throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
722
- }
723
- const renderRoot = element.localName === "template" ? element.content : element;
724
- let disposer;
725
- createRoot(dispose => {
726
- disposer = dispose;
727
- if (element === document) {
728
- flatten(code);
729
- return;
730
- }
731
- const marker = renderRoot.firstChild ? null : undefined;
732
- enforceLoadingBoundary(true);
733
- try {
734
- const tree = code();
735
- insert(element, () => tree, marker, init, {
736
+ enforceLoadingBoundary(true);
737
+ try {
738
+ const dispose = render$1(code, element, init, {
739
+ ...options,
740
+ insertOptions: {
736
741
  schedule: true
737
- });
738
- } finally {
739
- enforceLoadingBoundary(false);
740
- }
741
- }, {
742
- id: options.renderId
743
- });
744
- flush();
745
- return () => {
746
- disposer();
747
- renderRoot.textContent = "";
748
- };
742
+ }
743
+ });
744
+ flush();
745
+ return dispose;
746
+ } finally {
747
+ enforceLoadingBoundary(false);
748
+ }
749
749
  }
750
750
  const hydrate = (...args) => {
751
751
  enableHydration();
@@ -756,7 +756,7 @@ function Portal(props) {
756
756
  startMarker = document.createTextNode(""),
757
757
  endMarker = document.createTextNode(""),
758
758
  mount = () => createElementProxy(props.mount || document.body, treeMarker);
759
- let content = createMemo$1(() => [startMarker, props.children]);
759
+ let content = createMemo(() => [startMarker, props.children]);
760
760
  createRenderEffect(() => [mount(), content()], ([m, c]) => {
761
761
  m.appendChild(endMarker);
762
762
  insert(m, c, endMarker);
@@ -771,26 +771,30 @@ function Portal(props) {
771
771
  });
772
772
  return treeMarker;
773
773
  }
774
- function createDynamic(component, props) {
775
- const cached = createMemo$1(component);
776
- return createMemo$1(() => {
777
- const component = cached();
778
- switch (typeof component) {
779
- case "function":
780
- Object.assign(component, {
781
- [$DEVCOMP]: true
782
- });
783
- return untrack(() => component(props));
784
- case "string":
785
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
786
- spread(el, props);
787
- return el;
788
- }
774
+ function dynamic(source) {
775
+ const cached = createMemo(source, {
776
+ lazy: true
789
777
  });
778
+ return props => {
779
+ return createMemo(() => {
780
+ const component = cached();
781
+ switch (typeof component) {
782
+ case "function":
783
+ Object.assign(component, {
784
+ [$DEVCOMP]: true
785
+ });
786
+ return untrack(() => component(props));
787
+ case "string":
788
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
789
+ spread(el, props);
790
+ return el;
791
+ }
792
+ });
793
+ };
790
794
  }
791
795
  function Dynamic(props) {
792
- const others = omit(props, "component");
793
- return createDynamic(() => props.component, others);
796
+ const Comp = dynamic(() => props.component);
797
+ return createComponent(Comp, omit(props, "component"));
794
798
  }
795
799
  function createElement(tagName, is = undefined) {
796
800
  return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
@@ -815,4 +819,4 @@ function createElementProxy(el, marker) {
815
819
  });
816
820
  }
817
821
 
818
- export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RequestContext, SVGElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
822
+ export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
package/dist/server.cjs CHANGED
@@ -3,7 +3,6 @@
3
3
  var solidJs = require('solid-js');
4
4
  var seroval = require('seroval');
5
5
  var web = require('seroval-plugins/web');
6
- var signals = require('@solidjs/signals');
7
6
 
8
7
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
9
8
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
@@ -19,6 +18,8 @@ const Namespaces = {
19
18
  xlink: "http://www.w3.org/1999/xlink",
20
19
  xml: "http://www.w3.org/XML/1998/namespace"
21
20
  };
21
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
22
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
22
23
  const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
23
24
  "webview",
24
25
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
@@ -30,9 +31,7 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
30
31
  transparent: true,
31
32
  ...options
32
33
  } : transparentOptions);
33
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
34
- transparent: true
35
- }) : solidJs.createMemo(() => fn());
34
+ const memo = fn => solidJs.createMemo(() => fn());
36
35
 
37
36
  const ES2017FLAG = seroval.Feature.AggregateError |
38
37
  seroval.Feature.BigIntTypedArray;
@@ -610,7 +609,7 @@ function ssrClassName(value) {
610
609
  classValue = !!value[key];
611
610
  if (!key || key === "undefined" || !classValue) continue;
612
611
  i && (result += " ");
613
- result += escape(key);
612
+ result += escape(key, true);
614
613
  }
615
614
  return result;
616
615
  }
@@ -620,8 +619,8 @@ function ssrStyle(value) {
620
619
  let result = "";
621
620
  const k = Object.keys(value);
622
621
  for (let i = 0; i < k.length; i++) {
623
- const s = k[i];
624
- const v = value[s];
622
+ const s = escape(k[i], true);
623
+ const v = value[k[i]];
625
624
  if (v != undefined) {
626
625
  if (i) result += ";";
627
626
  const r = escape(v, true);
@@ -763,7 +762,7 @@ function generateHydrationScript({
763
762
  eventNames = ["click", "input"],
764
763
  nonce
765
764
  } = {}) {
766
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
765
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
767
766
  }
768
767
  function queue(fn) {
769
768
  return Promise.resolve().then(fn);
@@ -930,23 +929,25 @@ function notSup() {
930
929
 
931
930
  const isServer = true;
932
931
  const isDev = false;
933
- function createDynamic(component, props) {
932
+ function dynamic(source) {
934
933
  const o = solidJs.getOwner();
935
934
  if (o?.id != null) solidJs.getNextChildId(o);
936
- const memoOwner = solidJs.createOwner();
937
- return solidJs.runWithOwner(memoOwner, () => {
938
- const comp = component(),
939
- t = typeof comp;
940
- if (comp) {
941
- if (t === "function") return comp(props);else if (t === "string") {
942
- return ssrElement(comp, props, undefined, true);
935
+ return props => {
936
+ const memoOwner = solidJs.createOwner();
937
+ return solidJs.runWithOwner(memoOwner, () => {
938
+ const comp = source(),
939
+ t = typeof comp;
940
+ if (comp) {
941
+ if (t === "function") return comp(props);else if (t === "string") {
942
+ return ssrElement(comp, props, undefined, true);
943
+ }
943
944
  }
944
- }
945
- });
945
+ });
946
+ };
946
947
  }
947
948
  function Dynamic(props) {
948
- const others = solidJs.omit(props, "component");
949
- return createDynamic(() => props.component, others);
949
+ const Comp = dynamic(() => props.component);
950
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
950
951
  }
951
952
  function Portal(props) {
952
953
  throw new Error("Portal is not supported on the server");
@@ -1016,14 +1017,16 @@ exports.HydrationScript = HydrationScript;
1016
1017
  exports.MathMLElements = MathMLElements;
1017
1018
  exports.Namespaces = Namespaces;
1018
1019
  exports.Portal = Portal;
1020
+ exports.RawTextElements = RawTextElements;
1019
1021
  exports.RequestContext = RequestContext;
1020
1022
  exports.SVGElements = SVGElements;
1023
+ exports.VoidElements = VoidElements;
1021
1024
  exports.addEventListener = notSup;
1022
1025
  exports.applyRef = applyRef;
1023
1026
  exports.assign = notSup;
1024
1027
  exports.className = notSup;
1025
- exports.createDynamic = createDynamic;
1026
1028
  exports.delegateEvents = notSup;
1029
+ exports.dynamic = dynamic;
1027
1030
  exports.dynamicProperty = notSup;
1028
1031
  exports.effect = effect;
1029
1032
  exports.escape = escape;