solid-js 1.9.11 → 2.0.0-beta.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 (82) hide show
  1. package/dist/dev.cjs +733 -1678
  2. package/dist/dev.js +598 -1643
  3. package/dist/server.cjs +769 -703
  4. package/dist/server.js +682 -670
  5. package/dist/solid.cjs +699 -1618
  6. package/dist/solid.js +563 -1582
  7. package/package.json +7 -151
  8. package/types/{render → client}/component.d.ts +1 -38
  9. package/types/client/core.d.ts +65 -0
  10. package/types/client/flow.d.ts +100 -0
  11. package/types/client/hydration.d.ts +76 -0
  12. package/types/index.d.ts +11 -14
  13. package/types/jsx.d.ts +1508 -1633
  14. package/types/server/component.d.ts +66 -0
  15. package/types/server/core.d.ts +44 -0
  16. package/types/server/flow.d.ts +60 -0
  17. package/types/server/hydration.d.ts +21 -0
  18. package/types/server/index.d.ts +12 -3
  19. package/types/server/shared.d.ts +45 -0
  20. package/types/server/signals.d.ts +60 -0
  21. package/h/dist/h.cjs +0 -115
  22. package/h/dist/h.js +0 -113
  23. package/h/jsx-dev-runtime/package.json +0 -8
  24. package/h/jsx-runtime/dist/jsx.cjs +0 -15
  25. package/h/jsx-runtime/dist/jsx.js +0 -10
  26. package/h/jsx-runtime/package.json +0 -8
  27. package/h/jsx-runtime/types/index.d.ts +0 -11
  28. package/h/jsx-runtime/types/jsx.d.ts +0 -4242
  29. package/h/package.json +0 -8
  30. package/h/types/hyperscript.d.ts +0 -20
  31. package/h/types/index.d.ts +0 -3
  32. package/html/dist/html.cjs +0 -583
  33. package/html/dist/html.js +0 -581
  34. package/html/package.json +0 -8
  35. package/html/types/index.d.ts +0 -3
  36. package/html/types/lit.d.ts +0 -41
  37. package/store/dist/dev.cjs +0 -458
  38. package/store/dist/dev.js +0 -449
  39. package/store/dist/server.cjs +0 -126
  40. package/store/dist/server.js +0 -114
  41. package/store/dist/store.cjs +0 -438
  42. package/store/dist/store.js +0 -429
  43. package/store/package.json +0 -46
  44. package/store/types/index.d.ts +0 -12
  45. package/store/types/modifiers.d.ts +0 -6
  46. package/store/types/mutable.d.ts +0 -5
  47. package/store/types/server.d.ts +0 -17
  48. package/store/types/store.d.ts +0 -107
  49. package/types/reactive/array.d.ts +0 -44
  50. package/types/reactive/observable.d.ts +0 -36
  51. package/types/reactive/scheduler.d.ts +0 -10
  52. package/types/reactive/signal.d.ts +0 -577
  53. package/types/render/Suspense.d.ts +0 -26
  54. package/types/render/flow.d.ts +0 -118
  55. package/types/render/hydration.d.ts +0 -24
  56. package/types/render/index.d.ts +0 -4
  57. package/types/server/reactive.d.ts +0 -98
  58. package/types/server/rendering.d.ts +0 -159
  59. package/universal/dist/dev.cjs +0 -245
  60. package/universal/dist/dev.js +0 -243
  61. package/universal/dist/universal.cjs +0 -245
  62. package/universal/dist/universal.js +0 -243
  63. package/universal/package.json +0 -20
  64. package/universal/types/index.d.ts +0 -3
  65. package/universal/types/universal.d.ts +0 -30
  66. package/web/dist/dev.cjs +0 -894
  67. package/web/dist/dev.js +0 -782
  68. package/web/dist/server.cjs +0 -892
  69. package/web/dist/server.js +0 -782
  70. package/web/dist/web.cjs +0 -883
  71. package/web/dist/web.js +0 -771
  72. package/web/package.json +0 -46
  73. package/web/storage/dist/storage.cjs +0 -12
  74. package/web/storage/dist/storage.js +0 -10
  75. package/web/storage/package.json +0 -15
  76. package/web/storage/types/index.d.ts +0 -2
  77. package/web/types/client.d.ts +0 -79
  78. package/web/types/core.d.ts +0 -2
  79. package/web/types/index.d.ts +0 -50
  80. package/web/types/jsx.d.ts +0 -1
  81. package/web/types/server-mock.d.ts +0 -65
  82. package/web/types/server.d.ts +0 -177
package/web/dist/dev.js DELETED
@@ -1,782 +0,0 @@
1
- import { createMemo, createRoot, createRenderEffect, untrack, sharedConfig, enableHydration, getOwner, createEffect, runWithOwner, createSignal, onCleanup, $DEVCOMP, splitProps } from 'solid-js';
2
- export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps, untrack } from 'solid-js';
3
-
4
- const booleans = ["allowfullscreen", "async", "alpha",
5
- "autofocus",
6
- "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden",
7
- "indeterminate", "inert",
8
- "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless",
9
- "selected", "adauctionheaders",
10
- "browsingtopics",
11
- "credentialless",
12
- "defaultchecked", "defaultmuted", "defaultselected", "defer", "disablepictureinpicture", "disableremoteplayback", "preservespitch",
13
- "shadowrootclonable", "shadowrootcustomelementregistry",
14
- "shadowrootdelegatesfocus", "shadowrootserializable",
15
- "sharedstoragewritable"
16
- ];
17
- const Properties = /*#__PURE__*/new Set([
18
- "className", "value",
19
- "readOnly", "noValidate", "formNoValidate", "isMap", "noModule", "playsInline", "adAuctionHeaders",
20
- "allowFullscreen", "browsingTopics",
21
- "defaultChecked", "defaultMuted", "defaultSelected", "disablePictureInPicture", "disableRemotePlayback", "preservesPitch", "shadowRootClonable", "shadowRootCustomElementRegistry",
22
- "shadowRootDelegatesFocus", "shadowRootSerializable",
23
- "sharedStorageWritable",
24
- ...booleans]);
25
- const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
26
- const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
27
- className: "class",
28
- htmlFor: "for"
29
- });
30
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
31
- class: "className",
32
- novalidate: {
33
- $: "noValidate",
34
- FORM: 1
35
- },
36
- formnovalidate: {
37
- $: "formNoValidate",
38
- BUTTON: 1,
39
- INPUT: 1
40
- },
41
- ismap: {
42
- $: "isMap",
43
- IMG: 1
44
- },
45
- nomodule: {
46
- $: "noModule",
47
- SCRIPT: 1
48
- },
49
- playsinline: {
50
- $: "playsInline",
51
- VIDEO: 1
52
- },
53
- readonly: {
54
- $: "readOnly",
55
- INPUT: 1,
56
- TEXTAREA: 1
57
- },
58
- adauctionheaders: {
59
- $: "adAuctionHeaders",
60
- IFRAME: 1
61
- },
62
- allowfullscreen: {
63
- $: "allowFullscreen",
64
- IFRAME: 1
65
- },
66
- browsingtopics: {
67
- $: "browsingTopics",
68
- IMG: 1
69
- },
70
- defaultchecked: {
71
- $: "defaultChecked",
72
- INPUT: 1
73
- },
74
- defaultmuted: {
75
- $: "defaultMuted",
76
- AUDIO: 1,
77
- VIDEO: 1
78
- },
79
- defaultselected: {
80
- $: "defaultSelected",
81
- OPTION: 1
82
- },
83
- disablepictureinpicture: {
84
- $: "disablePictureInPicture",
85
- VIDEO: 1
86
- },
87
- disableremoteplayback: {
88
- $: "disableRemotePlayback",
89
- AUDIO: 1,
90
- VIDEO: 1
91
- },
92
- preservespitch: {
93
- $: "preservesPitch",
94
- AUDIO: 1,
95
- VIDEO: 1
96
- },
97
- shadowrootclonable: {
98
- $: "shadowRootClonable",
99
- TEMPLATE: 1
100
- },
101
- shadowrootdelegatesfocus: {
102
- $: "shadowRootDelegatesFocus",
103
- TEMPLATE: 1
104
- },
105
- shadowrootserializable: {
106
- $: "shadowRootSerializable",
107
- TEMPLATE: 1
108
- },
109
- sharedstoragewritable: {
110
- $: "sharedStorageWritable",
111
- IFRAME: 1,
112
- IMG: 1
113
- }
114
- });
115
- function getPropAlias(prop, tagName) {
116
- const a = PropAliases[prop];
117
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
118
- }
119
- 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"]);
120
- const SVGElements = /*#__PURE__*/new Set([
121
- "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",
122
- "set", "stop",
123
- "svg", "switch", "symbol", "text", "textPath",
124
- "tref", "tspan", "use", "view", "vkern"]);
125
- const SVGNamespace = {
126
- xlink: "http://www.w3.org/1999/xlink",
127
- xml: "http://www.w3.org/XML/1998/namespace"
128
- };
129
- 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",
130
- "webview",
131
- "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
132
-
133
- const memo = fn => createMemo(() => fn());
134
-
135
- function reconcileArrays(parentNode, a, b) {
136
- let bLength = b.length,
137
- aEnd = a.length,
138
- bEnd = bLength,
139
- aStart = 0,
140
- bStart = 0,
141
- after = a[aEnd - 1].nextSibling,
142
- map = null;
143
- while (aStart < aEnd || bStart < bEnd) {
144
- if (a[aStart] === b[bStart]) {
145
- aStart++;
146
- bStart++;
147
- continue;
148
- }
149
- while (a[aEnd - 1] === b[bEnd - 1]) {
150
- aEnd--;
151
- bEnd--;
152
- }
153
- if (aEnd === aStart) {
154
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
155
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
156
- } else if (bEnd === bStart) {
157
- while (aStart < aEnd) {
158
- if (!map || !map.has(a[aStart])) a[aStart].remove();
159
- aStart++;
160
- }
161
- } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
162
- const node = a[--aEnd].nextSibling;
163
- parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
164
- parentNode.insertBefore(b[--bEnd], node);
165
- a[aEnd] = b[bEnd];
166
- } else {
167
- if (!map) {
168
- map = new Map();
169
- let i = bStart;
170
- while (i < bEnd) map.set(b[i], i++);
171
- }
172
- const index = map.get(a[aStart]);
173
- if (index != null) {
174
- if (bStart < index && index < bEnd) {
175
- let i = aStart,
176
- sequence = 1,
177
- t;
178
- while (++i < aEnd && i < bEnd) {
179
- if ((t = map.get(a[i])) == null || t !== index + sequence) break;
180
- sequence++;
181
- }
182
- if (sequence > index - bStart) {
183
- const node = a[aStart];
184
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
185
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
186
- } else aStart++;
187
- } else a[aStart++].remove();
188
- }
189
- }
190
- }
191
-
192
- const $$EVENTS = "_$DX_DELEGATE";
193
- function render(code, element, init, options = {}) {
194
- if (!element) {
195
- throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
196
- }
197
- let disposer;
198
- createRoot(dispose => {
199
- disposer = dispose;
200
- element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
201
- }, options.owner);
202
- return () => {
203
- disposer();
204
- element.textContent = "";
205
- };
206
- }
207
- function template(html, isImportNode, isSVG, isMathML) {
208
- let node;
209
- const create = () => {
210
- if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
211
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
212
- t.innerHTML = html;
213
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
214
- };
215
- const fn = isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
216
- fn.cloneNode = fn;
217
- return fn;
218
- }
219
- function delegateEvents(eventNames, document = window.document) {
220
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
221
- for (let i = 0, l = eventNames.length; i < l; i++) {
222
- const name = eventNames[i];
223
- if (!e.has(name)) {
224
- e.add(name);
225
- document.addEventListener(name, eventHandler);
226
- }
227
- }
228
- }
229
- function clearDelegatedEvents(document = window.document) {
230
- if (document[$$EVENTS]) {
231
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
232
- delete document[$$EVENTS];
233
- }
234
- }
235
- function setProperty(node, name, value) {
236
- if (isHydrating(node)) return;
237
- node[name] = value;
238
- }
239
- function setAttribute(node, name, value) {
240
- if (isHydrating(node)) return;
241
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
242
- }
243
- function setAttributeNS(node, namespace, name, value) {
244
- if (isHydrating(node)) return;
245
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
246
- }
247
- function setBoolAttribute(node, name, value) {
248
- if (isHydrating(node)) return;
249
- value ? node.setAttribute(name, "") : node.removeAttribute(name);
250
- }
251
- function className(node, value) {
252
- if (isHydrating(node)) return;
253
- if (value == null) node.removeAttribute("class");else node.className = value;
254
- }
255
- function addEventListener(node, name, handler, delegate) {
256
- if (delegate) {
257
- if (Array.isArray(handler)) {
258
- node[`$$${name}`] = handler[0];
259
- node[`$$${name}Data`] = handler[1];
260
- } else node[`$$${name}`] = handler;
261
- } else if (Array.isArray(handler)) {
262
- const handlerFn = handler[0];
263
- node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
264
- } else node.addEventListener(name, handler, typeof handler !== "function" && handler);
265
- }
266
- function classList(node, value, prev = {}) {
267
- const classKeys = Object.keys(value || {}),
268
- prevKeys = Object.keys(prev);
269
- let i, len;
270
- for (i = 0, len = prevKeys.length; i < len; i++) {
271
- const key = prevKeys[i];
272
- if (!key || key === "undefined" || value[key]) continue;
273
- toggleClassKey(node, key, false);
274
- delete prev[key];
275
- }
276
- for (i = 0, len = classKeys.length; i < len; i++) {
277
- const key = classKeys[i],
278
- classValue = !!value[key];
279
- if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
280
- toggleClassKey(node, key, true);
281
- prev[key] = classValue;
282
- }
283
- return prev;
284
- }
285
- function style(node, value, prev) {
286
- if (!value) return prev ? setAttribute(node, "style") : value;
287
- const nodeStyle = node.style;
288
- if (typeof value === "string") return nodeStyle.cssText = value;
289
- typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
290
- prev || (prev = {});
291
- value || (value = {});
292
- let v, s;
293
- for (s in prev) {
294
- value[s] == null && nodeStyle.removeProperty(s);
295
- delete prev[s];
296
- }
297
- for (s in value) {
298
- v = value[s];
299
- if (v !== prev[s]) {
300
- nodeStyle.setProperty(s, v);
301
- prev[s] = v;
302
- }
303
- }
304
- return prev;
305
- }
306
- function setStyleProperty(node, name, value) {
307
- value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
308
- }
309
- function spread(node, props = {}, isSVG, skipChildren) {
310
- const prevProps = {};
311
- if (!skipChildren) {
312
- createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
313
- }
314
- createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node));
315
- createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
316
- return prevProps;
317
- }
318
- function dynamicProperty(props, key) {
319
- const src = props[key];
320
- Object.defineProperty(props, key, {
321
- get() {
322
- return src();
323
- },
324
- enumerable: true
325
- });
326
- return props;
327
- }
328
- function use(fn, element, arg) {
329
- return untrack(() => fn(element, arg));
330
- }
331
- function insert(parent, accessor, marker, initial) {
332
- if (marker !== undefined && !initial) initial = [];
333
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
334
- createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
335
- }
336
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
337
- props || (props = {});
338
- for (const prop in prevProps) {
339
- if (!(prop in props)) {
340
- if (prop === "children") continue;
341
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
342
- }
343
- }
344
- for (const prop in props) {
345
- if (prop === "children") {
346
- if (!skipChildren) insertExpression(node, props.children);
347
- continue;
348
- }
349
- const value = props[prop];
350
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
351
- }
352
- }
353
- function hydrate$1(code, element, options = {}) {
354
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
355
- sharedConfig.completed = globalThis._$HY.completed;
356
- sharedConfig.events = globalThis._$HY.events;
357
- sharedConfig.load = id => globalThis._$HY.r[id];
358
- sharedConfig.has = id => id in globalThis._$HY.r;
359
- sharedConfig.gather = root => gatherHydratable(element, root);
360
- sharedConfig.registry = new Map();
361
- sharedConfig.context = {
362
- id: options.renderId || "",
363
- count: 0
364
- };
365
- try {
366
- gatherHydratable(element, options.renderId);
367
- return render(code, element, [...element.childNodes], options);
368
- } finally {
369
- sharedConfig.context = null;
370
- }
371
- }
372
- function getNextElement(template) {
373
- let node,
374
- key,
375
- hydrating = isHydrating();
376
- if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
377
- if (hydrating) {
378
- sharedConfig.done = true;
379
- throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${template ? template().outerHTML : ""}`);
380
- }
381
- return template();
382
- }
383
- if (sharedConfig.completed) sharedConfig.completed.add(node);
384
- sharedConfig.registry.delete(key);
385
- return node;
386
- }
387
- function getNextMatch(el, nodeName) {
388
- while (el && el.localName !== nodeName) el = el.nextSibling;
389
- return el;
390
- }
391
- function getNextMarker(start) {
392
- let end = start,
393
- count = 0,
394
- current = [];
395
- if (isHydrating(start)) {
396
- while (end) {
397
- if (end.nodeType === 8) {
398
- const v = end.nodeValue;
399
- if (v === "$") count++;else if (v === "/") {
400
- if (count === 0) return [end, current];
401
- count--;
402
- }
403
- }
404
- current.push(end);
405
- end = end.nextSibling;
406
- }
407
- }
408
- return [end, current];
409
- }
410
- function runHydrationEvents() {
411
- if (sharedConfig.events && !sharedConfig.events.queued) {
412
- queueMicrotask(() => {
413
- const {
414
- completed,
415
- events
416
- } = sharedConfig;
417
- if (!events) return;
418
- events.queued = false;
419
- while (events.length) {
420
- const [el, e] = events[0];
421
- if (!completed.has(el)) return;
422
- events.shift();
423
- eventHandler(e);
424
- }
425
- if (sharedConfig.done) {
426
- sharedConfig.events = _$HY.events = null;
427
- sharedConfig.completed = _$HY.completed = null;
428
- }
429
- });
430
- sharedConfig.events.queued = true;
431
- }
432
- }
433
- function isHydrating(node) {
434
- return !!sharedConfig.context && !sharedConfig.done && (!node || node.isConnected);
435
- }
436
- function toPropertyName(name) {
437
- return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
438
- }
439
- function toggleClassKey(node, key, value) {
440
- const classNames = key.trim().split(/\s+/);
441
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
442
- }
443
- function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
444
- let isCE, isProp, isChildProp, propAlias, forceProp;
445
- if (prop === "style") return style(node, value, prev);
446
- if (prop === "classList") return classList(node, value, prev);
447
- if (value === prev) return prev;
448
- if (prop === "ref") {
449
- if (!skipRef) value(node);
450
- } else if (prop.slice(0, 3) === "on:") {
451
- const e = prop.slice(3);
452
- prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
453
- value && node.addEventListener(e, value, typeof value !== "function" && value);
454
- } else if (prop.slice(0, 10) === "oncapture:") {
455
- const e = prop.slice(10);
456
- prev && node.removeEventListener(e, prev, true);
457
- value && node.addEventListener(e, value, true);
458
- } else if (prop.slice(0, 2) === "on") {
459
- const name = prop.slice(2).toLowerCase();
460
- const delegate = DelegatedEvents.has(name);
461
- if (!delegate && prev) {
462
- const h = Array.isArray(prev) ? prev[0] : prev;
463
- node.removeEventListener(name, h);
464
- }
465
- if (delegate || value) {
466
- addEventListener(node, name, value, delegate);
467
- delegate && delegateEvents([name]);
468
- }
469
- } else if (prop.slice(0, 5) === "attr:") {
470
- setAttribute(node, prop.slice(5), value);
471
- } else if (prop.slice(0, 5) === "bool:") {
472
- setBoolAttribute(node, prop.slice(5), value);
473
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || "is" in props)) {
474
- if (forceProp) {
475
- prop = prop.slice(5);
476
- isProp = true;
477
- } else if (isHydrating(node)) return value;
478
- if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
479
- } else {
480
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
481
- if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
482
- }
483
- return value;
484
- }
485
- function eventHandler(e) {
486
- if (sharedConfig.registry && sharedConfig.events) {
487
- if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
488
- }
489
- let node = e.target;
490
- const key = `$$${e.type}`;
491
- const oriTarget = e.target;
492
- const oriCurrentTarget = e.currentTarget;
493
- const retarget = value => Object.defineProperty(e, "target", {
494
- configurable: true,
495
- value
496
- });
497
- const handleNode = () => {
498
- const handler = node[key];
499
- if (handler && !node.disabled) {
500
- const data = node[`${key}Data`];
501
- data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
502
- if (e.cancelBubble) return;
503
- }
504
- node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
505
- return true;
506
- };
507
- const walkUpTree = () => {
508
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
509
- };
510
- Object.defineProperty(e, "currentTarget", {
511
- configurable: true,
512
- get() {
513
- return node || document;
514
- }
515
- });
516
- if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
517
- if (e.composedPath) {
518
- const path = e.composedPath();
519
- retarget(path[0]);
520
- for (let i = 0; i < path.length - 2; i++) {
521
- node = path[i];
522
- if (!handleNode()) break;
523
- if (node._$host) {
524
- node = node._$host;
525
- walkUpTree();
526
- break;
527
- }
528
- if (node.parentNode === oriCurrentTarget) {
529
- break;
530
- }
531
- }
532
- }
533
- else walkUpTree();
534
- retarget(oriTarget);
535
- }
536
- function insertExpression(parent, value, current, marker, unwrapArray) {
537
- const hydrating = isHydrating(parent);
538
- if (hydrating) {
539
- !current && (current = [...parent.childNodes]);
540
- let cleaned = [];
541
- for (let i = 0; i < current.length; i++) {
542
- const node = current[i];
543
- if (node.nodeType === 8 && node.data.slice(0, 2) === "!$") node.remove();else cleaned.push(node);
544
- }
545
- current = cleaned;
546
- }
547
- while (typeof current === "function") current = current();
548
- if (value === current) return current;
549
- const t = typeof value,
550
- multi = marker !== undefined;
551
- parent = multi && current[0] && current[0].parentNode || parent;
552
- if (t === "string" || t === "number") {
553
- if (hydrating) return current;
554
- if (t === "number") {
555
- value = value.toString();
556
- if (value === current) return current;
557
- }
558
- if (multi) {
559
- let node = current[0];
560
- if (node && node.nodeType === 3) {
561
- node.data !== value && (node.data = value);
562
- } else node = document.createTextNode(value);
563
- current = cleanChildren(parent, current, marker, node);
564
- } else {
565
- if (current !== "" && typeof current === "string") {
566
- current = parent.firstChild.data = value;
567
- } else current = parent.textContent = value;
568
- }
569
- } else if (value == null || t === "boolean") {
570
- if (hydrating) return current;
571
- current = cleanChildren(parent, current, marker);
572
- } else if (t === "function") {
573
- createRenderEffect(() => {
574
- let v = value();
575
- while (typeof v === "function") v = v();
576
- current = insertExpression(parent, v, current, marker);
577
- });
578
- return () => current;
579
- } else if (Array.isArray(value)) {
580
- const array = [];
581
- const currentArray = current && Array.isArray(current);
582
- if (normalizeIncomingArray(array, value, current, unwrapArray)) {
583
- createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
584
- return () => current;
585
- }
586
- if (hydrating) {
587
- if (!array.length) return current;
588
- if (marker === undefined) return current = [...parent.childNodes];
589
- let node = array[0];
590
- if (node.parentNode !== parent) return current;
591
- const nodes = [node];
592
- while ((node = node.nextSibling) !== marker) nodes.push(node);
593
- return current = nodes;
594
- }
595
- if (array.length === 0) {
596
- current = cleanChildren(parent, current, marker);
597
- if (multi) return current;
598
- } else if (currentArray) {
599
- if (current.length === 0) {
600
- appendNodes(parent, array, marker);
601
- } else reconcileArrays(parent, current, array);
602
- } else {
603
- current && cleanChildren(parent);
604
- appendNodes(parent, array);
605
- }
606
- current = array;
607
- } else if (value.nodeType) {
608
- if (hydrating && value.parentNode) return current = multi ? [value] : value;
609
- if (Array.isArray(current)) {
610
- if (multi) return current = cleanChildren(parent, current, marker, value);
611
- cleanChildren(parent, current, null, value);
612
- } else if (current == null || current === "" || !parent.firstChild) {
613
- parent.appendChild(value);
614
- } else parent.replaceChild(value, parent.firstChild);
615
- current = value;
616
- } else console.warn(`Unrecognized value. Skipped inserting`, value);
617
- return current;
618
- }
619
- function normalizeIncomingArray(normalized, array, current, unwrap) {
620
- let dynamic = false;
621
- for (let i = 0, len = array.length; i < len; i++) {
622
- let item = array[i],
623
- prev = current && current[normalized.length],
624
- t;
625
- if (item == null || item === true || item === false) ; else if ((t = typeof item) === "object" && item.nodeType) {
626
- normalized.push(item);
627
- } else if (Array.isArray(item)) {
628
- dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
629
- } else if (t === "function") {
630
- if (unwrap) {
631
- while (typeof item === "function") item = item();
632
- dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], Array.isArray(prev) ? prev : [prev]) || dynamic;
633
- } else {
634
- normalized.push(item);
635
- dynamic = true;
636
- }
637
- } else {
638
- const value = String(item);
639
- if (prev && prev.nodeType === 3 && prev.data === value) normalized.push(prev);else normalized.push(document.createTextNode(value));
640
- }
641
- }
642
- return dynamic;
643
- }
644
- function appendNodes(parent, array, marker = null) {
645
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
646
- }
647
- function cleanChildren(parent, current, marker, replacement) {
648
- if (marker === undefined) return parent.textContent = "";
649
- const node = replacement || document.createTextNode("");
650
- if (current.length) {
651
- let inserted = false;
652
- for (let i = current.length - 1; i >= 0; i--) {
653
- const el = current[i];
654
- if (node !== el) {
655
- const isParent = el.parentNode === parent;
656
- if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
657
- } else inserted = true;
658
- }
659
- } else parent.insertBefore(node, marker);
660
- return [node];
661
- }
662
- function gatherHydratable(element, root) {
663
- const templates = element.querySelectorAll(`*[data-hk]`);
664
- for (let i = 0; i < templates.length; i++) {
665
- const node = templates[i];
666
- const key = node.getAttribute("data-hk");
667
- if ((!root || key.startsWith(root)) && !sharedConfig.registry.has(key)) sharedConfig.registry.set(key, node);
668
- }
669
- }
670
- function getHydrationKey() {
671
- return sharedConfig.getNextContextId();
672
- }
673
- function NoHydration(props) {
674
- return sharedConfig.context ? undefined : props.children;
675
- }
676
- function Hydration(props) {
677
- return props.children;
678
- }
679
- const voidFn = () => undefined;
680
- const RequestContext = Symbol();
681
- function innerHTML(parent, content) {
682
- !sharedConfig.context && (parent.innerHTML = content);
683
- }
684
-
685
- function throwInBrowser(func) {
686
- const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
687
- console.error(err);
688
- }
689
- function renderToString(fn, options) {
690
- throwInBrowser(renderToString);
691
- }
692
- function renderToStringAsync(fn, options) {
693
- throwInBrowser(renderToStringAsync);
694
- }
695
- function renderToStream(fn, options) {
696
- throwInBrowser(renderToStream);
697
- }
698
- function ssr(template, ...nodes) {}
699
- function ssrElement(name, props, children, needsId) {}
700
- function ssrClassList(value) {}
701
- function ssrStyle(value) {}
702
- function ssrAttribute(key, value) {}
703
- function ssrHydrationKey() {}
704
- function resolveSSRNode(node) {}
705
- function escape(html) {}
706
- function ssrSpread(props, isSVG, skipChildren) {}
707
-
708
- const isServer = false;
709
- const isDev = true;
710
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
711
- function createElement(tagName, isSVG = false, is = undefined) {
712
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
713
- is
714
- });
715
- }
716
- const hydrate = (...args) => {
717
- enableHydration();
718
- return hydrate$1(...args);
719
- };
720
- function Portal(props) {
721
- const {
722
- useShadow
723
- } = props,
724
- marker = document.createTextNode(""),
725
- mount = () => props.mount || document.body,
726
- owner = getOwner();
727
- let content;
728
- let hydrating = !!sharedConfig.context;
729
- createEffect(() => {
730
- if (hydrating) getOwner().user = hydrating = false;
731
- content || (content = runWithOwner(owner, () => createMemo(() => props.children)));
732
- const el = mount();
733
- if (el instanceof HTMLHeadElement) {
734
- const [clean, setClean] = createSignal(false);
735
- const cleanup = () => setClean(true);
736
- createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
737
- onCleanup(cleanup);
738
- } else {
739
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
740
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
741
- mode: "open"
742
- }) : container;
743
- Object.defineProperty(container, "_$host", {
744
- get() {
745
- return marker.parentNode;
746
- },
747
- configurable: true
748
- });
749
- insert(renderRoot, content);
750
- el.appendChild(container);
751
- props.ref && props.ref(container);
752
- onCleanup(() => el.removeChild(container));
753
- }
754
- }, undefined, {
755
- render: !hydrating
756
- });
757
- return marker;
758
- }
759
- function createDynamic(component, props) {
760
- const cached = createMemo(component);
761
- return createMemo(() => {
762
- const component = cached();
763
- switch (typeof component) {
764
- case "function":
765
- Object.assign(component, {
766
- [$DEVCOMP]: true
767
- });
768
- return untrack(() => component(props));
769
- case "string":
770
- const isSvg = SVGElements.has(component);
771
- const el = sharedConfig.context ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
772
- spread(el, props, isSvg);
773
- return el;
774
- }
775
- });
776
- }
777
- function Dynamic(props) {
778
- const [, others] = splitProps(props, ["component"]);
779
- return createDynamic(() => props.component, others);
780
- }
781
-
782
- export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getPropAlias, voidFn as getRequestEvent, hydrate, innerHTML, insert, isDev, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setBoolAttribute, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };