123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- var solidJs = require('solid-js');
- const booleans = ["allowfullscreen", "allowpaymentrequest", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "ismap", "itemscope", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected", "truespeed"];
- const Properties = new Set(["className", "indeterminate", "value", ...booleans]);
- const ChildProperties = new Set(["innerHTML", "textContent", "innerText", "children"]);
- const Aliases = {
- className: "class",
- htmlFor: "for"
- };
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
- const SVGElements = new Set([
- "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "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",
- "set", "stop",
- "svg", "switch", "symbol", "text", "textPath",
- "tref", "tspan", "use", "view", "vkern"]);
- const SVGNamespace = {
- xlink: "http://www.w3.org/1999/xlink",
- xml: "http://www.w3.org/XML/1998/namespace"
- };
- function memo(fn, equals) {
- return solidJs.createMemo(fn, undefined, !equals ? {
- equals
- } : undefined);
- }
- function reconcileArrays(parentNode, a, b) {
- let bLength = b.length,
- aEnd = a.length,
- bEnd = bLength,
- aStart = 0,
- bStart = 0,
- after = a[aEnd - 1].nextSibling,
- map = null;
- while (aStart < aEnd || bStart < bEnd) {
- if (aEnd === aStart) {
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
- } else if (bEnd === bStart) {
- while (aStart < aEnd) {
- if (!map || !map.has(a[aStart])) parentNode.removeChild(a[aStart]);
- aStart++;
- }
- } else if (a[aStart] === b[bStart]) {
- aStart++;
- bStart++;
- } else if (a[aEnd - 1] === b[bEnd - 1]) {
- aEnd--;
- bEnd--;
- } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
- const node = a[--aEnd].nextSibling;
- parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
- parentNode.insertBefore(b[--bEnd], node);
- a[aEnd] = b[bEnd];
- } else {
- if (!map) {
- map = new Map();
- let i = bStart;
- while (i < bEnd) map.set(b[i], i++);
- }
- const index = map.get(a[aStart]);
- if (index != null) {
- if (bStart < index && index < bEnd) {
- let i = aStart,
- sequence = 1,
- t;
- while (++i < aEnd && i < bEnd) {
- if ((t = map.get(a[i])) == null || t !== index + sequence) break;
- sequence++;
- }
- if (sequence > index - bStart) {
- const node = a[aStart];
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
- } else aStart++;
- } else parentNode.removeChild(a[aStart++]);
- }
- }
- }
- const $$EVENTS = Symbol("delegated-events");
- function render(code, element, init) {
- let disposer;
- solidJs.createRoot(dispose => {
- disposer = dispose;
- insert(element, code(), element.firstChild ? null : undefined, init);
- });
- return () => {
- disposer();
- element.textContent = "";
- };
- }
- function template(html, check, isSVG) {
- const t = document.createElement("template");
- t.innerHTML = html;
- if (check && t.innerHTML.split("<").length - 1 !== check) throw `The browser resolved template HTML does not match JSX input:\n${t.innerHTML}\n\n${html}. Is your HTML properly formed?`;
- let node = t.content.firstChild;
- if (isSVG) node = node.firstChild;
- return node;
- }
- function delegateEvents(eventNames) {
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
- for (let i = 0, l = eventNames.length; i < l; i++) {
- const name = eventNames[i];
- if (!e.has(name)) {
- e.add(name);
- document.addEventListener(name, eventHandler);
- }
- }
- }
- function clearDelegatedEvents() {
- if (document[$$EVENTS]) {
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
- delete document[$$EVENTS];
- }
- }
- function setAttribute(node, name, value) {
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
- }
- function setAttributeNS(node, namespace, name, value) {
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
- }
- function addEventListener(node, name, handler, delegate) {
- if (delegate) {
- if (Array.isArray(handler)) {
- node[`$$${name}`] = handler[0];
- node[`$$${name}Data`] = handler[1];
- } else node[`$$${name}`] = handler;
- } else if (Array.isArray(handler)) {
- node.addEventListener(name, e => handler[0](handler[1], e));
- } else node.addEventListener(name, handler);
- }
- function classList(node, value, prev = {}) {
- const classKeys = Object.keys(value),
- prevKeys = Object.keys(prev);
- let i, len;
- for (i = 0, len = prevKeys.length; i < len; i++) {
- const key = prevKeys[i];
- if (!key || key === "undefined" || key in value) continue;
- toggleClassKey(node, key, false);
- delete prev[key];
- }
- for (i = 0, len = classKeys.length; i < len; i++) {
- const key = classKeys[i],
- classValue = !!value[key];
- if (!key || key === "undefined" || prev[key] === classValue) continue;
- toggleClassKey(node, key, classValue);
- prev[key] = classValue;
- }
- return prev;
- }
- function style(node, value, prev = {}) {
- const nodeStyle = node.style;
- if (typeof value === "string") return nodeStyle.cssText = value;
- typeof prev === "string" && (prev = {});
- let v, s;
- for (s in prev) {
- value[s] == null && nodeStyle.removeProperty(s);
- delete prev[s];
- }
- for (s in value) {
- v = value[s];
- if (v !== prev[s]) {
- nodeStyle.setProperty(s, v);
- prev[s] = v;
- }
- }
- return prev;
- }
- function spread(node, accessor, isSVG, skipChildren) {
- if (typeof accessor === "function") {
- solidJs.createRenderEffect(current => spreadExpression(node, accessor(), current, isSVG, skipChildren));
- } else spreadExpression(node, accessor, undefined, isSVG, skipChildren);
- }
- function dynamicProperty(props, key) {
- const src = props[key];
- Object.defineProperty(props, key, {
- get() {
- return src();
- },
- enumerable: true
- });
- return props;
- }
- function insert(parent, accessor, marker, initial) {
- if (marker !== undefined && !initial) initial = [];
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
- solidJs.createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
- }
- function assign(node, props, isSVG, skipChildren, prevProps = {}) {
- let isCE, isProp, isChildProp;
- for (const prop in props) {
- if (prop === "children") {
- if (!skipChildren) insertExpression(node, props.children);
- continue;
- }
- const value = props[prop];
- if (value === prevProps[prop]) continue;
- if (prop === "style") {
- style(node, value, prevProps[prop]);
- } else if (prop === "class" && !isSVG) {
- node.className = value;
- } else if (prop === "classList") {
- classList(node, value, prevProps[prop]);
- } else if (prop === "ref") {
- value(node);
- } else if (prop.slice(0, 3) === "on:") {
- node.addEventListener(prop.slice(3), value);
- } else if (prop.slice(0, 10) === "oncapture:") {
- node.addEventListener(prop.slice(10), value, true);
- } else if (prop.slice(0, 2) === "on") {
- const name = prop.slice(2).toLowerCase();
- const delegate = DelegatedEvents.has(name);
- addEventListener(node, name, value, delegate);
- delegate && delegateEvents([name]);
- } else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (isProp = Properties.has(prop)) || (isCE = node.nodeName.includes("-"))) {
- if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[prop] = value;
- } else {
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
- if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
- }
- prevProps[prop] = value;
- }
- }
- function hydrate(code, element) {
- solidJs.sharedConfig.resources = globalThis._$HYDRATION.resources;
- solidJs.sharedConfig.completed = globalThis._$HYDRATION.completed;
- solidJs.sharedConfig.events = globalThis._$HYDRATION.events;
- solidJs.sharedConfig.context = {
- id: "",
- count: 0,
- loadResource: globalThis._$HYDRATION.loadResource
- };
- solidJs.sharedConfig.registry = new Map();
- gatherHydratable(element);
- const dispose = render(code, element, [...element.childNodes]);
- solidJs.sharedConfig.context = null;
- return dispose;
- }
- function gatherHydratable(element) {
- const templates = element.querySelectorAll(`*[data-hk]`);
- for (let i = 0; i < templates.length; i++) {
- const node = templates[i];
- solidJs.sharedConfig.registry.set(node.getAttribute("data-hk"), node);
- }
- }
- function getNextElement(template) {
- let node, key;
- if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
- return template.cloneNode(true);
- }
- if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
- solidJs.sharedConfig.registry.delete(key);
- return node;
- }
- function getNextMarker(start) {
- let end = start,
- count = 0,
- current = [];
- if (solidJs.sharedConfig.context) {
- while (end) {
- if (end.nodeType === 8) {
- const v = end.nodeValue;
- if (v === "#") count++;else if (v === "/") {
- if (count === 0) return [end, current];
- count--;
- }
- }
- current.push(end);
- end = end.nextSibling;
- }
- }
- return [end, current];
- }
- function runHydrationEvents() {
- if (solidJs.sharedConfig.events && !solidJs.sharedConfig.events.queued) {
- queueMicrotask(() => {
- const {
- completed,
- events
- } = solidJs.sharedConfig;
- events.queued = false;
- while (events.length) {
- const [el, e] = events[0];
- if (!completed.has(el)) return;
- eventHandler(e);
- events.shift();
- }
- });
- solidJs.sharedConfig.events.queued = true;
- }
- }
- function toPropertyName(name) {
- return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
- }
- function toggleClassKey(node, key, value) {
- const classNames = key.split(/\s+/);
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
- }
- function eventHandler(e) {
- const key = `$$${e.type}`;
- let node = e.composedPath && e.composedPath()[0] || e.target;
- if (e.target !== node) {
- Object.defineProperty(e, "target", {
- configurable: true,
- value: node
- });
- }
- Object.defineProperty(e, "currentTarget", {
- configurable: true,
- get() {
- return node;
- }
- });
- while (node !== null) {
- const handler = node[key];
- if (handler) {
- const data = node[`${key}Data`];
- data !== undefined ? handler(data, e) : handler(e);
- if (e.cancelBubble) return;
- }
- node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
- }
- }
- function spreadExpression(node, props, prevProps = {}, isSVG, skipChildren) {
- if (!skipChildren && "children" in props) {
- solidJs.createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
- }
- solidJs.createRenderEffect(() => assign(node, props, isSVG, true, prevProps));
- return prevProps;
- }
- function insertExpression(parent, value, current, marker, unwrapArray) {
- while (typeof current === "function") current = current();
- if (value === current) return current;
- const t = typeof value,
- multi = marker !== undefined;
- parent = multi && current[0] && current[0].parentNode || parent;
- if (t === "string" || t === "number") {
- if (t === "number") value = value.toString();
- if (multi) {
- let node = current[0];
- if (node && node.nodeType === 3) {
- node.data = value;
- } else node = document.createTextNode(value);
- current = cleanChildren(parent, current, marker, node);
- } else {
- if (current !== "" && typeof current === "string") {
- current = parent.firstChild.data = value;
- } else current = parent.textContent = value;
- }
- } else if (value == null || t === "boolean") {
- if (solidJs.sharedConfig.context) return current;
- current = cleanChildren(parent, current, marker);
- } else if (t === "function") {
- solidJs.createRenderEffect(() => {
- let v = value();
- while (typeof v === "function") v = v();
- current = insertExpression(parent, v, current, marker);
- });
- return () => current;
- } else if (Array.isArray(value)) {
- const array = [];
- if (normalizeIncomingArray(array, value, unwrapArray)) {
- solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
- return () => current;
- }
- if (solidJs.sharedConfig.context && current.length) return current;
- if (array.length === 0) {
- current = cleanChildren(parent, current, marker);
- if (multi) return current;
- } else {
- if (Array.isArray(current)) {
- if (current.length === 0) {
- appendNodes(parent, array, marker);
- } else reconcileArrays(parent, current, array);
- } else if (current == null || current === "") {
- appendNodes(parent, array);
- } else {
- reconcileArrays(parent, multi && current || [parent.firstChild], array);
- }
- }
- current = array;
- } else if (value instanceof Node) {
- if (Array.isArray(current)) {
- if (multi) return current = cleanChildren(parent, current, marker, value);
- cleanChildren(parent, current, null, value);
- } else if (current == null || current === "" || !parent.firstChild) {
- parent.appendChild(value);
- } else parent.replaceChild(value, parent.firstChild);
- current = value;
- } else console.warn(`Unrecognized value. Skipped inserting`, value);
- return current;
- }
- function normalizeIncomingArray(normalized, array, unwrap) {
- let dynamic = false;
- for (let i = 0, len = array.length; i < len; i++) {
- let item = array[i],
- t;
- if (item instanceof Node) {
- normalized.push(item);
- } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
- dynamic = normalizeIncomingArray(normalized, item) || dynamic;
- } else if ((t = typeof item) === "string") {
- normalized.push(document.createTextNode(item));
- } else if (t === "function") {
- if (unwrap) {
- while (typeof item === "function") item = item();
- dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
- } else {
- normalized.push(item);
- dynamic = true;
- }
- } else normalized.push(document.createTextNode(item.toString()));
- }
- return dynamic;
- }
- function appendNodes(parent, array, marker) {
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
- }
- function cleanChildren(parent, current, marker, replacement) {
- if (marker === undefined) return parent.textContent = "";
- const node = replacement || document.createTextNode("");
- if (current.length) {
- let inserted = false;
- for (let i = current.length - 1; i >= 0; i--) {
- const el = current[i];
- if (node !== el) {
- const isParent = el.parentNode === parent;
- if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && parent.removeChild(el);
- } else inserted = true;
- }
- } else parent.insertBefore(node, marker);
- return [node];
- }
- function getHydrationKey() {
- const hydrate = solidJs.sharedConfig.context;
- return `${hydrate.id}${hydrate.count++}`;
- }
- function renderToString(fn, options) {}
- function renderToStringAsync(fn, options) {}
- function renderToNodeStream(fn, options) {}
- function renderToWebStream(fn, options) {}
- function ssr(template, ...nodes) {}
- function resolveSSRNode(node) {}
- function ssrClassList(value) {}
- function ssrStyle(value) {}
- function ssrSpread(accessor) {}
- function ssrBoolean(key, value) {}
- function escape(html) {}
- const isServer = false;
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
- function createElement(tagName, isSVG = false) {
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
- }
- function Portal(props) {
- const {
- useShadow
- } = props,
- marker = document.createTextNode(""),
- mount = props.mount || document.body;
- function renderPortal() {
- if (solidJs.sharedConfig.context) {
- const [s, set] = solidJs.createSignal(false);
- queueMicrotask(() => set(true));
- return () => s() && props.children;
- } else return () => props.children;
- }
- if (mount instanceof HTMLHeadElement) {
- const [clean, setClean] = solidJs.createSignal(false);
- const cleanup = () => setClean(true);
- solidJs.createRoot(dispose => insert(mount, () => !clean() ? renderPortal()() : dispose(), null));
- solidJs.onCleanup(() => {
- if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
- });
- } else {
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
- mode: "open"
- }) : container;
- Object.defineProperty(container, "host", {
- get() {
- return marker.parentNode;
- }
- });
- insert(renderRoot, renderPortal());
- mount.appendChild(container);
- props.ref && props.ref(container);
- solidJs.onCleanup(() => mount.removeChild(container));
- }
- return marker;
- }
- function Dynamic(props) {
- const [p, others] = solidJs.splitProps(props, ["component"]);
- return solidJs.createMemo(() => {
- const component = p.component;
- switch (typeof component) {
- case "function":
- return solidJs.untrack(() => component(others));
- case "string":
- const isSvg = SVGElements.has(component);
- const el = createElement(component, isSvg);
- spread(el, others, isSvg);
- return el;
- }
- });
- }
- Object.defineProperty(exports, 'ErrorBoundary', {
- enumerable: true,
- get: function () {
- return solidJs.ErrorBoundary;
- }
- });
- Object.defineProperty(exports, 'For', {
- enumerable: true,
- get: function () {
- return solidJs.For;
- }
- });
- Object.defineProperty(exports, 'Index', {
- enumerable: true,
- get: function () {
- return solidJs.Index;
- }
- });
- Object.defineProperty(exports, 'Match', {
- enumerable: true,
- get: function () {
- return solidJs.Match;
- }
- });
- Object.defineProperty(exports, 'Show', {
- enumerable: true,
- get: function () {
- return solidJs.Show;
- }
- });
- Object.defineProperty(exports, 'Suspense', {
- enumerable: true,
- get: function () {
- return solidJs.Suspense;
- }
- });
- Object.defineProperty(exports, 'SuspenseList', {
- enumerable: true,
- get: function () {
- return solidJs.SuspenseList;
- }
- });
- Object.defineProperty(exports, 'Switch', {
- enumerable: true,
- get: function () {
- return solidJs.Switch;
- }
- });
- Object.defineProperty(exports, 'createComponent', {
- enumerable: true,
- get: function () {
- return solidJs.createComponent;
- }
- });
- Object.defineProperty(exports, 'effect', {
- enumerable: true,
- get: function () {
- return solidJs.createRenderEffect;
- }
- });
- Object.defineProperty(exports, 'getOwner', {
- enumerable: true,
- get: function () {
- return solidJs.getOwner;
- }
- });
- Object.defineProperty(exports, 'mergeProps', {
- enumerable: true,
- get: function () {
- return solidJs.mergeProps;
- }
- });
- exports.Aliases = Aliases;
- exports.ChildProperties = ChildProperties;
- exports.DelegatedEvents = DelegatedEvents;
- exports.Dynamic = Dynamic;
- exports.Portal = Portal;
- exports.Properties = Properties;
- exports.SVGElements = SVGElements;
- exports.SVGNamespace = SVGNamespace;
- exports.addEventListener = addEventListener;
- exports.assign = assign;
- exports.classList = classList;
- exports.clearDelegatedEvents = clearDelegatedEvents;
- exports.delegateEvents = delegateEvents;
- exports.dynamicProperty = dynamicProperty;
- exports.escape = escape;
- exports.gatherHydratable = gatherHydratable;
- exports.getHydrationKey = getHydrationKey;
- exports.getNextElement = getNextElement;
- exports.getNextMarker = getNextMarker;
- exports.hydrate = hydrate;
- exports.insert = insert;
- exports.isServer = isServer;
- exports.memo = memo;
- exports.render = render;
- exports.renderToNodeStream = renderToNodeStream;
- exports.renderToString = renderToString;
- exports.renderToStringAsync = renderToStringAsync;
- exports.renderToWebStream = renderToWebStream;
- exports.resolveSSRNode = resolveSSRNode;
- exports.runHydrationEvents = runHydrationEvents;
- exports.setAttribute = setAttribute;
- exports.setAttributeNS = setAttributeNS;
- exports.spread = spread;
- exports.ssr = ssr;
- exports.ssrBoolean = ssrBoolean;
- exports.ssrClassList = ssrClassList;
- exports.ssrSpread = ssrSpread;
- exports.ssrStyle = ssrStyle;
- exports.style = style;
- exports.template = template;
|