@solidjs/web 2.0.0-experimental.5 → 2.0.0-experimental.7

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/dist/server.js CHANGED
@@ -1,41 +1,11 @@
1
1
  import { createMemo, sharedConfig, createRoot, ssrHandleError, omit } from 'solid-js';
2
- export { ErrorBoundary, For, Match, Repeat, Show, Suspense, Switch, createComponent, createRenderEffect as effect, getOwner, untrack } from 'solid-js';
2
+ export { ErrorBoundary, For, Match, Repeat, Show, Suspense, Switch, createComponent, createRenderEffect as effect, getOwner, ssrRunInScope, untrack } from 'solid-js';
3
3
  import { Feature, Serializer, getCrossReferenceHeader } from 'seroval';
4
- import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
4
+ import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
 
6
- const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
7
- const BooleanAttributes = /*#__PURE__*/new Set(booleans);
8
- const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
6
+ const Properties = /*#__PURE__*/new Set([
7
+ "value", "checked", "selected", "muted"]);
9
8
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
10
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
11
- class: "className",
12
- formnovalidate: {
13
- $: "formNoValidate",
14
- BUTTON: 1,
15
- INPUT: 1
16
- },
17
- ismap: {
18
- $: "isMap",
19
- IMG: 1
20
- },
21
- nomodule: {
22
- $: "noModule",
23
- SCRIPT: 1
24
- },
25
- playsinline: {
26
- $: "playsInline",
27
- VIDEO: 1
28
- },
29
- readonly: {
30
- $: "readOnly",
31
- INPUT: 1,
32
- TEXTAREA: 1
33
- }
34
- });
35
- function getPropAlias(prop, tagName) {
36
- const a = PropAliases[prop];
37
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
38
- }
39
9
  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"]);
40
10
  const SVGElements = /*#__PURE__*/new Set([
41
11
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -46,7 +16,9 @@ const SVGNamespace = {
46
16
  xlink: "http://www.w3.org/1999/xlink",
47
17
  xml: "http://www.w3.org/XML/1998/namespace"
48
18
  };
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"]);
19
+ 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",
20
+ "webview",
21
+ "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
50
22
 
51
23
  const memo = fn => createMemo(() => fn());
52
24
 
@@ -61,7 +33,7 @@ function createSerializer({
61
33
  }) {
62
34
  return new Serializer({
63
35
  scopeId,
64
- plugins: [
36
+ plugins: [AbortSignalPlugin,
65
37
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
66
38
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
67
39
  globalIdentifier: GLOBAL_IDENTIFIER,
@@ -96,20 +68,18 @@ function renderToString(code, options = {}) {
96
68
  onError: options.onError
97
69
  });
98
70
  sharedConfig.context = {
99
- id: renderId,
100
- resources: {},
101
71
  assets: [],
102
72
  nonce,
103
- resolve(value) {
104
- return resolveSSRNode(escape(value));
105
- },
73
+ escape: escape,
74
+ resolve: resolveSSRNode,
75
+ ssr: ssr,
106
76
  serialize(id, p) {
107
77
  !sharedConfig.context.noHydrate && serializer.write(id, p);
108
78
  }
109
79
  };
110
80
  let html = createRoot(d => {
111
81
  setTimeout(d);
112
- return resolveSSRNode(escape(code()));
82
+ return resolveSSRSync(escape(code()));
113
83
  }, {
114
84
  id: renderId
115
85
  });
@@ -186,9 +156,7 @@ function renderToStream(code, options = {}) {
186
156
  }
187
157
  };
188
158
  sharedConfig.context = context = {
189
- id: renderId,
190
159
  async: true,
191
- resources: {},
192
160
  assets: [],
193
161
  nonce,
194
162
  block(p) {
@@ -200,7 +168,7 @@ function renderToStream(code, options = {}) {
200
168
  const first = html.indexOf(placeholder);
201
169
  if (first === -1) return;
202
170
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
203
- html = html.slice(0, first) + resolveSSRNode(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
171
+ html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
204
172
  },
205
173
  serialize(id, p, wait) {
206
174
  const serverOnly = sharedConfig.context.noHydrate;
@@ -213,35 +181,46 @@ function renderToStream(code, options = {}) {
213
181
  });
214
182
  } else if (!serverOnly) serializer.write(id, p);
215
183
  },
216
- resolve(value) {
217
- return resolveSSRNode(escape(value));
218
- },
184
+ escape: escape,
185
+ resolve: resolveSSRNode,
186
+ ssr: ssr,
219
187
  registerFragment(key) {
220
188
  if (!registry.has(key)) {
221
189
  let resolve, reject;
222
190
  const p = new Promise((r, rej) => (resolve = r, reject = rej));
223
- registry.set(key, err => queue(() => queue(() => {
224
- err ? reject(err) : resolve(true);
225
- queue(flushEnd);
226
- })));
191
+ registry.set(key, {
192
+ resolve: err => queue(() => queue(() => {
193
+ err ? reject(err) : resolve(true);
194
+ queue(flushEnd);
195
+ }))
196
+ });
227
197
  serializer.write(key, p);
228
198
  }
229
199
  return (value, error) => {
230
200
  if (registry.has(key)) {
231
- const resolve = registry.get(key);
201
+ const item = registry.get(key);
232
202
  registry.delete(key);
233
- if (waitForFragments(registry, key)) {
234
- resolve();
203
+ if (item.children) {
204
+ for (const k in item.children) {
205
+ value = replacePlaceholder(value, k, item.children[k]);
206
+ }
207
+ }
208
+ const parentKey = waitForFragments(registry, key);
209
+ if (parentKey) {
210
+ const parent = registry.get(parentKey);
211
+ parent.children ||= {};
212
+ parent.children[key] = value !== undefined ? value : "";
213
+ item.resolve();
235
214
  return;
236
215
  }
237
216
  if (!completed) {
238
217
  if (!firstFlushed) {
239
218
  queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
240
- resolve(error);
219
+ item.resolve(error);
241
220
  } else {
242
221
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
243
222
  pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
244
- resolve(error);
223
+ item.resolve(error);
245
224
  scriptFlushed = true;
246
225
  }
247
226
  }
@@ -252,14 +231,13 @@ function renderToStream(code, options = {}) {
252
231
  };
253
232
  let html = createRoot(d => {
254
233
  dispose = d;
255
- return resolveSSRNode(escape(code()));
234
+ return resolveSSRSync(escape(code()));
256
235
  }, {
257
236
  id: renderId
258
237
  });
259
238
  function doShell() {
260
239
  if (shellCompleted) return;
261
240
  sharedConfig.context = context;
262
- context.noHydrate = true;
263
241
  html = injectAssets(context.assets, html);
264
242
  if (tasks.length) html = injectScripts(html, tasks, nonce);
265
243
  buffer.write(html);
@@ -342,15 +320,7 @@ function HydrationScript(props) {
342
320
  }));
343
321
  }
344
322
  function ssr(t, ...nodes) {
345
- if (nodes.length) {
346
- let result = "";
347
- for (let i = 0; i < nodes.length; i++) {
348
- result += t[i];
349
- const node = nodes[i];
350
- if (node !== undefined) result += resolveSSRNode(node);
351
- }
352
- t = result + t[nodes.length];
353
- }
323
+ if (nodes.length) return resolveSSR(t, nodes);
354
324
  return {
355
325
  t
356
326
  };
@@ -380,11 +350,17 @@ function ssrStyle(value) {
380
350
  const v = value[s];
381
351
  if (v != undefined) {
382
352
  if (i) result += ";";
383
- result += `${s}:${escape(v, true)}`;
353
+ const r = escape(v, true);
354
+ if (r != undefined && r !== "undefined") {
355
+ result += `${s}:${r}`;
356
+ }
384
357
  }
385
358
  }
386
359
  return result;
387
360
  }
361
+ function ssrStyleProperty(name, value) {
362
+ return value != null ? name + value : "";
363
+ }
388
364
  function ssrElement(tag, props, children, needsId) {
389
365
  if (props == null) props = {};else if (typeof props === "function") props = props();
390
366
  const skipChildren = VOID_ELEMENTS.test(tag);
@@ -401,17 +377,13 @@ function ssrElement(tag, props, children, needsId) {
401
377
  result += `style="${ssrStyle(value)}"`;
402
378
  } else if (prop === "class") {
403
379
  result += `class="${ssrClassName(value)}"`;
404
- } else if (BooleanAttributes.has(prop)) {
405
- if (value) result += prop;else continue;
406
380
  } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
407
381
  continue;
408
- } else if (prop.slice(0, 5) === "bool:") {
382
+ } else if (typeof value === "boolean") {
409
383
  if (!value) continue;
410
- result += escape(prop.slice(5));
411
- } else if (prop.slice(0, 5) === "attr:") {
412
- result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
384
+ result += escape(prop);
413
385
  } else {
414
- result += `${escape(prop)}="${escape(value, true)}"`;
386
+ result += value === "" ? escape(prop) : `${escape(prop)}="${escape(value, true)}"`;
415
387
  }
416
388
  if (i !== keys.length - 1) result += " ";
417
389
  }
@@ -419,12 +391,10 @@ function ssrElement(tag, props, children, needsId) {
419
391
  t: result + "/>"
420
392
  };
421
393
  if (typeof children === "function") children = children();
422
- return {
423
- t: result + `>${resolveSSRNode(children, true)}</${tag}>`
424
- };
394
+ return ssr([result + ">", `</${tag}>`], resolveSSRNode(children, undefined, true));
425
395
  }
426
- function ssrAttribute(key, value, isBoolean) {
427
- return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
396
+ function ssrAttribute(key, value) {
397
+ return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
428
398
  }
429
399
  function ssrHydrationKey() {
430
400
  const hk = getHydrationKey();
@@ -433,12 +403,12 @@ function ssrHydrationKey() {
433
403
  function escape(s, attr) {
434
404
  const t = typeof s;
435
405
  if (t !== "string") {
436
- if (!attr && t === "function") return escape(s());
437
406
  if (!attr && Array.isArray(s)) {
407
+ s = s.slice();
438
408
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
439
409
  return s;
440
410
  }
441
- if (attr && t === "boolean") return String(s);
411
+ if (attr && t === "boolean") return s;
442
412
  return s;
443
413
  }
444
414
  const delim = attr ? '"' : "<";
@@ -476,29 +446,6 @@ function escape(s, attr) {
476
446
  }
477
447
  return left < s.length ? out + s.substring(left) : out;
478
448
  }
479
- function resolveSSRNode(node, top) {
480
- const t = typeof node;
481
- if (t === "string") return node;
482
- if (node == null || t === "boolean") return "";
483
- if (Array.isArray(node)) {
484
- let prev = {};
485
- let mapped = "";
486
- for (let i = 0, len = node.length; i < len; i++) {
487
- if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
488
- mapped += resolveSSRNode(prev = node[i]);
489
- }
490
- return mapped;
491
- }
492
- if (t === "object") return node.t;
493
- if (t === "function") {
494
- try {
495
- return resolveSSRNode(node());
496
- } catch (err) {
497
- if (!ssrHandleError(err)) throw err;
498
- }
499
- }
500
- return String(node);
501
- }
502
449
  function mergeProps(...sources) {
503
450
  const target = {};
504
451
  for (let i = 0; i < sources.length; i++) {
@@ -527,7 +474,7 @@ function getHydrationKey() {
527
474
  return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
528
475
  }
529
476
  function useAssets(fn) {
530
- sharedConfig.context.assets.push(() => resolveSSRNode(escape(fn())));
477
+ sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
531
478
  }
532
479
  function getAssets() {
533
480
  const assets = sharedConfig.context.assets;
@@ -546,8 +493,6 @@ function Hydration(props) {
546
493
  const context = sharedConfig.context;
547
494
  sharedConfig.context = {
548
495
  ...context,
549
- count: 0,
550
- id: sharedConfig.getNextContextId(),
551
496
  noHydrate: false
552
497
  };
553
498
  const res = props.children;
@@ -592,7 +537,7 @@ function injectScripts(html, scripts, nonce) {
592
537
  }
593
538
  function waitForFragments(registry, key) {
594
539
  for (const k of [...registry.keys()].reverse()) {
595
- if (key.startsWith(k)) return true;
540
+ if (key.startsWith(k)) return k;
596
541
  }
597
542
  return false;
598
543
  }
@@ -618,6 +563,62 @@ function flattenClassList(list, result) {
618
563
  if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
619
564
  }
620
565
  }
566
+ function resolveSSR(template, holes, result = {
567
+ t: [""],
568
+ h: [],
569
+ p: []
570
+ }) {
571
+ for (let i = 0; i < holes.length; i++) {
572
+ const hole = holes[i];
573
+ result.t[result.t.length - 1] += template[i];
574
+ if (hole == null || hole === true || hole === false) continue;
575
+ resolveSSRNode(hole, result);
576
+ }
577
+ result.t[result.t.length - 1] += template[template.length - 1];
578
+ return result;
579
+ }
580
+ function resolveSSRNode(node, result = {
581
+ t: [""],
582
+ h: [],
583
+ p: []
584
+ }, top) {
585
+ const t = typeof node;
586
+ if (t === "string" || t === "number") {
587
+ result.t[result.t.length - 1] += node;
588
+ } else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
589
+ let prev = {};
590
+ for (let i = 0, len = node.length; i < len; i++) {
591
+ if (!top && typeof prev !== "object" && typeof node[i] !== "object") result.t[result.t.length - 1] += `<!--!$-->`;
592
+ resolveSSRNode(prev = node[i], result);
593
+ }
594
+ } else if (t === "object") {
595
+ if (node.h) {
596
+ result.t[result.t.length - 1] += node.t[0];
597
+ if (node.t.length > 1) {
598
+ result.t.push(...node.t.slice(1));
599
+ result.h.push(...node.h);
600
+ result.p.push(...node.p);
601
+ }
602
+ } else result.t[result.t.length - 1] += node.t;
603
+ } else if (t === "function") {
604
+ try {
605
+ resolveSSRNode(node(), result);
606
+ } catch (err) {
607
+ const p = ssrHandleError(err);
608
+ if (p) {
609
+ result.h.push(node);
610
+ result.p.push(p);
611
+ result.t.push("");
612
+ }
613
+ }
614
+ }
615
+ return result;
616
+ }
617
+ function resolveSSRSync(node) {
618
+ const res = resolveSSRNode(node);
619
+ if (!res.h.length) return res.t[0];
620
+ throw new Error("This value cannot be rendered synchronously. Are you missing a Suspsense boundary?");
621
+ }
621
622
  const RequestContext = Symbol();
622
623
  function getRequestEvent() {
623
624
  return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.log("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
@@ -648,4 +649,4 @@ function Portal(props) {
648
649
  throw new Error("Portal is not supported on the server");
649
650
  }
650
651
 
651
- export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getPropAlias, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrHydrationKey, ssrStyle, notSup as style, notSup as template, useAssets };
652
+ export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };
package/dist/web.cjs CHANGED
@@ -2,38 +2,9 @@
2
2
 
3
3
  var solidJs = require('solid-js');
4
4
 
5
- const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
6
- const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
5
+ const Properties = /*#__PURE__*/new Set([
6
+ "value", "checked", "selected", "muted"]);
7
7
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
8
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
9
- class: "className",
10
- formnovalidate: {
11
- $: "formNoValidate",
12
- BUTTON: 1,
13
- INPUT: 1
14
- },
15
- ismap: {
16
- $: "isMap",
17
- IMG: 1
18
- },
19
- nomodule: {
20
- $: "noModule",
21
- SCRIPT: 1
22
- },
23
- playsinline: {
24
- $: "playsInline",
25
- VIDEO: 1
26
- },
27
- readonly: {
28
- $: "readOnly",
29
- INPUT: 1,
30
- TEXTAREA: 1
31
- }
32
- });
33
- function getPropAlias(prop, tagName) {
34
- const a = PropAliases[prop];
35
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
36
- }
37
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"]);
38
9
  const SVGElements = /*#__PURE__*/new Set([
39
10
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -44,7 +15,9 @@ const SVGNamespace = {
44
15
  xlink: "http://www.w3.org/1999/xlink",
45
16
  xml: "http://www.w3.org/XML/1998/namespace"
46
17
  };
47
- 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"]);
18
+ 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",
19
+ "webview",
20
+ "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
48
21
 
49
22
  const memo = fn => solidJs.createMemo(() => fn());
50
23
 
@@ -150,19 +123,15 @@ function setProperty(node, name, value) {
150
123
  }
151
124
  function setAttribute(node, name, value) {
152
125
  if (isHydrating(node)) return;
153
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
126
+ if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
154
127
  }
155
128
  function setAttributeNS(node, namespace, name, value) {
156
129
  if (isHydrating(node)) return;
157
130
  if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
158
131
  }
159
- function setBoolAttribute(node, name, value) {
160
- if (isHydrating(node)) return;
161
- value ? node.setAttribute(name, "") : node.removeAttribute(name);
162
- }
163
132
  function className(node, value, isSVG, prev) {
164
133
  if (isHydrating(node)) return;
165
- if (value == null) {
134
+ if (value == null || value === false) {
166
135
  prev && node.removeAttribute("class");
167
136
  return;
168
137
  }
@@ -219,6 +188,9 @@ function style(node, value, prev) {
219
188
  }
220
189
  for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
221
190
  }
191
+ function setStyleProperty(node, name, value) {
192
+ value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
193
+ }
222
194
  function spread(node, props = {}, isSVG, skipChildren) {
223
195
  const prevProps = {};
224
196
  if (!skipChildren) {
@@ -373,7 +345,7 @@ function flattenClassList(list, result) {
373
345
  }
374
346
  }
375
347
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
376
- let propAlias, forceProp;
348
+ let forceProp;
377
349
  if (prop === "style") return style(node, value, prev), value;
378
350
  if (prop === "class") return className(node, value, isSVG, prev), value;
379
351
  if (value === prev) return prev;
@@ -394,13 +366,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
394
366
  addEventListener(node, name, value, delegate);
395
367
  delegate && delegateEvents([name]);
396
368
  }
397
- } else if (prop.slice(0, 5) === "attr:") {
398
- setAttribute(node, prop.slice(5), value);
399
- } else if (prop.slice(0, 5) === "bool:") {
400
- setBoolAttribute(node, prop.slice(5), value);
401
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && (propAlias = getPropAlias(prop, node.tagName)) || Properties.has(prop)) {
369
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
402
370
  if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
403
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[propAlias || prop] = value;
371
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
404
372
  } else {
405
373
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
406
374
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -568,8 +536,10 @@ function escape(html) {}
568
536
  const isServer = false;
569
537
  const isDev = false;
570
538
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
571
- function createElement(tagName, isSVG = false) {
572
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
539
+ function createElement(tagName, isSVG = false, is = undefined) {
540
+ return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
541
+ is
542
+ });
573
543
  }
574
544
  const hydrate = (...args) => {
575
545
  solidJs.enableHydration();
@@ -621,7 +591,7 @@ function createDynamic(component, props) {
621
591
  return solidJs.untrack(() => component(props));
622
592
  case "string":
623
593
  const isSvg = SVGElements.has(component);
624
- const el = solidJs.sharedConfig.context ? getNextElement() : createElement(component, isSvg);
594
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
625
595
  spread(el, props, isSvg);
626
596
  return el;
627
597
  }
@@ -703,7 +673,6 @@ exports.getHydrationKey = getHydrationKey;
703
673
  exports.getNextElement = getNextElement;
704
674
  exports.getNextMarker = getNextMarker;
705
675
  exports.getNextMatch = getNextMatch;
706
- exports.getPropAlias = getPropAlias;
707
676
  exports.getRequestEvent = voidFn;
708
677
  exports.hydrate = hydrate;
709
678
  exports.insert = insert;
@@ -718,8 +687,8 @@ exports.resolveSSRNode = resolveSSRNode;
718
687
  exports.runHydrationEvents = runHydrationEvents;
719
688
  exports.setAttribute = setAttribute;
720
689
  exports.setAttributeNS = setAttributeNS;
721
- exports.setBoolAttribute = setBoolAttribute;
722
690
  exports.setProperty = setProperty;
691
+ exports.setStyleProperty = setStyleProperty;
723
692
  exports.spread = spread;
724
693
  exports.ssr = ssr;
725
694
  exports.ssrAttribute = ssrAttribute;