diff --git a/cjs/index.js b/cjs/index.js deleted file mode 100644 index fbf4c3d..0000000 --- a/cjs/index.js +++ /dev/null @@ -1,200 +0,0 @@ -'use strict'; -const {render, html, svg} = require('uhtml'); -const umap = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('umap')); -const css = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('plain-tag')); - -const domHandler = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('reactive-props/dom')); -const reactive = domHandler({dom: true}); - -const CE = customElements; -const {define: defineCustomElement} = CE; -const {parse, stringify} = JSON; -const {create, defineProperties, getOwnPropertyDescriptor, keys} = Object; - -const element = 'element'; -const ownProps = new WeakMap; -const constructors = umap(new Map([[element, {c: HTMLElement, e: element}]])); - -const el = name => document.createElement(name); - -const info = e => constructors.get(e) || constructors.set(e, { - c: el(e).constructor, - e -}); - -const define = (tagName, definition) => { - const { - attachShadow, - attributeChanged, - bound, - connected, - disconnected, - formAssociated, - handleEvent, - init, - observedAttributes, - props, - render, - style - } = definition; - const initialized = new WeakMap; - const statics = {}; - const proto = {}; - const listeners = []; - const retype = create(null); - const bootstrap = (element, key, value) => { - if (!initialized.has(element)) { - initialized.set(element, 0); - defineProperties(element, { - html: { - configurable: true, - value: content.bind( - attachShadow ? element.attachShadow(attachShadow) : element - ) - } - }); - for (let i = 0; i < length; i++) { - const {type, options} = listeners[i]; - element.addEventListener(type, element, options); - } - if (bound) - bound.forEach(bind, element); - if (props) { - const reProps = {}; - for (let k = keys(props), i = 0; i < k.length; i++) { - const key = k[i]; - const value = props[key]; - reProps[key] = typeof value === 'object' ? parse(stringify(value)) : value; - } - ownProps.set(element, reProps); - reactive(element, reProps, render); - } - if (init || render) - (init || render).call(element); - if (key) - element[key] = value; - } - }; - for (let k = keys(definition), i = 0, {length} = k; i < length; i++) { - const key = k[i]; - if (/^on./.test(key) && !/Options$/.test(key)) { - const options = definition[key + 'Options'] || false; - const lower = key.toLowerCase(); - let type = lower.slice(2); - listeners.push({type, options}); - retype[type] = key; - if (lower !== key) { - type = lower.slice(2, 3) + key.slice(3); - retype[type] = key; - listeners.push({type, options}); - } - } - switch (key) { - case 'attachShadow': - case 'constructor': - case 'observedAttributes': - case 'style': - break; - default: - proto[key] = getOwnPropertyDescriptor(definition, key); - } - } - const {length} = listeners; - if (length && !handleEvent) - proto.handleEvent = {value(event) { - this[retype[event.type]](event); - }}; - - // [props] - if (props !== null) { - if (props) { - for (let k = keys(props), i = 0; i < k.length; i++) { - const key = k[i]; - proto[key] = { - get() { - bootstrap(this); - return ownProps.get(this)[key]; - }, - set(value) { - bootstrap(this, key, value); - } - }; - } - } - else { - proto.props = {get() { - const props = {}; - for (let {attributes} = this, {length} = attributes, i = 0; i < length; i++) { - const {name, value} = attributes[i]; - props[name] = value; - } - return props; - }}; - } - } - // [/props] - - if (observedAttributes) - statics.observedAttributes = {value: observedAttributes}; - proto.attributeChangedCallback = {value() { - bootstrap(this); - if (attributeChanged) - attributeChanged.apply(this, arguments); - }}; - - if (formAssociated) { - statics.formAssociated = {value: formAssociated}; - } - - proto.connectedCallback = {value() { - bootstrap(this); - if (connected) - connected.call(this); - }}; - - if (disconnected) - proto.disconnectedCallback = {value: disconnected}; - - const {c, e} = info(definition.extends || element); - class MicroElement extends c {}; - defineProperties(MicroElement, statics); - defineProperties(MicroElement.prototype, proto); - const args = [tagName, MicroElement]; - if (e !== element) - args.push({extends: e}); - defineCustomElement.apply(CE, args); - constructors.set(tagName, {c: MicroElement, e}); - if (style) - document.head.appendChild(el('style')).textContent = style( - e === element ? tagName : (e + '[is="' + tagName + '"]') - ); - return MicroElement; -}; - -exports.define = define; -exports.render = render; -exports.html = html; -exports.svg = svg; -exports.css = css; - -/* istanbul ignore else */ -if (!CE.get('uce-lib')) - // theoretically this could be just class { ... } - // however, if there is for whatever reason a - // element on the page, it will break once the registry - // will try to upgrade such element so ... HTMLElement it is. - CE.define('uce-lib', class extends info(element).c { - static get define() { return define; } - static get render() { return render; } - static get html() { return html; } - static get svg() { return svg; } - static get css() { return css; } - }); - -function bind(method) { - this[method] = this[method].bind(this); -} - -function content() { - return render(this, html.apply(null, arguments)); -} diff --git a/cjs/package.json b/cjs/package.json deleted file mode 100644 index 0292b99..0000000 --- a/cjs/package.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"commonjs"} \ No newline at end of file diff --git a/esm/index.js b/esm/index.js index fb0b85d..658532e 100644 --- a/esm/index.js +++ b/esm/index.js @@ -1,4 +1,4 @@ -import {render, html, svg} from 'uhtml'; +import {render, html, svg, unsafe, Hole, signal, computed, effect, untracked, batch, fragment} from 'uhtml'; import umap from 'umap'; import css from 'plain-tag'; @@ -170,7 +170,7 @@ const define = (tagName, definition) => { return MicroElement; }; -export {define, render, html, svg, css}; +export {define, render, html, svg, css, unsafe, Hole, signal, computed, effect, untracked, batch, fragment}; /* istanbul ignore else */ if (!CE.get('uce-lib')) diff --git a/index.js b/index.js index f3186b6..bdf5d15 100644 --- a/index.js +++ b/index.js @@ -1,1005 +1,1448 @@ var uce = (function (exports) { 'use strict'; - function _typeof(obj) { + function _typeof(o) { "@babel/helpers - typeof"; - return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }, _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, _typeof(o); } - function _toPrimitive(input, hint) { - if (_typeof(input) !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (_typeof(res) !== "object") return res; + function toPrimitive(t, r) { + if ("object" != _typeof(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r); + if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } - return (hint === "string" ? String : Number)(input); + return (String )(t); } - function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return _typeof(key) === "symbol" ? key : String(key); + function toPropertyKey(t) { + var i = toPrimitive(t, "string"); + return "symbol" == _typeof(i) ? i : i + ""; } - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + function _defineProperties(e, r) { + for (var t = 0; t < r.length; t++) { + var o = r[t]; + o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o); } } - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { + function _createClass(e, r, t) { + return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: false - }); - return Constructor; + }), e; } - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } + function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _setPrototypeOf(o, p); + function _assertThisInitialized(e) { + if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return e; } - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - Object.defineProperty(subClass, "prototype", { - writable: false - }); - if (superClass) _setPrototypeOf(subClass, superClass); + function _possibleConstructorReturn(t, e) { + if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; + if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); + return _assertThisInitialized(t); } - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; + function _getPrototypeOf(t) { + return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { + return t.__proto__ || Object.getPrototypeOf(t); + }, _getPrototypeOf(t); } - function _possibleConstructorReturn(self, call) { - if (call && (_typeof(call) === "object" || typeof call === "function")) { - return call; - } else if (call !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - return _assertThisInitialized(self); + function _setPrototypeOf(t, e) { + return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { + return t.__proto__ = e, t; + }, _setPrototypeOf(t, e); } - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = _getPrototypeOf(object); - if (object === null) break; - } - return object; + function _inherits(t, e) { + if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); + t.prototype = Object.create(e && e.prototype, { + constructor: { + value: t, + writable: true, + configurable: true + } + }), Object.defineProperty(t, "prototype", { + writable: false + }), e && _setPrototypeOf(t, e); } - function _get() { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get.bind(); - } else { - _get = function _get(target, property, receiver) { - var base = _superPropBase(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(arguments.length < 3 ? target : receiver); - } - return desc.value; - }; + function _isNativeFunction(t) { + try { + return -1 !== Function.toString.call(t).indexOf("[native code]"); + } catch (n) { + return "function" == typeof t; } - return _get.apply(this, arguments); - } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _isNativeReflectConstruct$2() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - return true; - } catch (e) { - return false; - } + var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (t) {} + return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() { + return !!t; + })(); } - function _construct(Parent, args, Class) { - if (_isNativeReflectConstruct$2()) { - _construct = Reflect.construct.bind(); - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - return _construct.apply(null, arguments); + function _construct(t, e, r) { + if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments); + var o = [null]; + o.push.apply(o, e); + var p = new (t.bind.apply(t, o))(); + return r && _setPrototypeOf(p, r.prototype), p; } - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - _cache.set(Class, Wrapper); + function _wrapNativeSuper(t) { + var r = "function" == typeof Map ? new Map() : void 0; + return _wrapNativeSuper = function _wrapNativeSuper(t) { + if (null === t || !_isNativeFunction(t)) return t; + if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); + if (void 0 !== r) { + if (r.has(t)) return r.get(t); + r.set(t, Wrapper); } function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); + return _construct(t, arguments, _getPrototypeOf(this).constructor); } - Wrapper.prototype = Object.create(Class.prototype, { + return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } - }); - return _setPrototypeOf(Wrapper, Class); - }; - return _wrapNativeSuper(Class); + }), _setPrototypeOf(Wrapper, t); + }, _wrapNativeSuper(t); } - function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } - function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } - var MapSet = /*#__PURE__*/function (_Map) { - _inherits(MapSet, _Map); - var _super = _createSuper$1(MapSet); - function MapSet() { - _classCallCheck(this, MapSet); - return _super.apply(this, arguments); - } - _createClass(MapSet, [{ - key: "set", - value: function set(key, value) { - _get(_getPrototypeOf(MapSet.prototype), "set", this).call(this, key, value); - return value; + function _arrayWithHoles(r) { + if (Array.isArray(r)) return r; + } + + function _iterableToArrayLimit(r, l) { + var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; + if (null != t) { + var e, + n, + i, + u, + a = [], + f = true, + o = false; + try { + if (i = (t = t.call(r)).next, 0 === l) { + if (Object(t) !== t) return; + f = !1; + } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); + } catch (r) { + o = true, n = r; + } finally { + try { + if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; + } finally { + if (o) throw n; + } } - }]); - return MapSet; - }( /*#__PURE__*/_wrapNativeSuper(Map)); - var WeakMapSet = /*#__PURE__*/function (_WeakMap) { - _inherits(WeakMapSet, _WeakMap); - var _super2 = _createSuper$1(WeakMapSet); - function WeakMapSet() { - _classCallCheck(this, WeakMapSet); - return _super2.apply(this, arguments); + return a; } - _createClass(WeakMapSet, [{ - key: "set", - value: function set(key, value) { - _get(_getPrototypeOf(WeakMapSet.prototype), "set", this).call(this, key, value); - return value; - } - }]); - return WeakMapSet; - }( /*#__PURE__*/_wrapNativeSuper(WeakMap)); + } - /*! (c) Andrea Giammarchi - ISC */ - var empty = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; - var elements = /<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g; - var attributes = /([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g; - var holes = /[\x01\x02]/g; + function _arrayLikeToArray$1(r, a) { + (null == a || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; + } - // \x01 Node.ELEMENT_NODE - // \x02 Node.ATTRIBUTE_NODE + function _unsupportedIterableToArray$1(r, a) { + if (r) { + if ("string" == typeof r) return _arrayLikeToArray$1(r, a); + var t = {}.toString.call(r).slice(8, -1); + return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; + } + } - /** - * Given a template, find holes as both nodes and attributes and - * return a string with holes as either comment nodes or named attributes. - * @param {string[]} template a template literal tag array - * @param {string} prefix prefix to use per each comment/attribute - * @param {boolean} svg enforces self-closing tags - * @returns {string} X/HTML with prefixed comments or attributes - */ - var instrument = (function (template, prefix, svg) { - var i = 0; - return template.join('\x01').trim().replace(elements, function (_, name, attrs, selfClosing) { - var ml = name + attrs.replace(attributes, '\x02=$2$1').trimEnd(); - if (selfClosing.length) ml += svg || empty.test(name) ? ' /' : '>'; - }).replace(holes, function (hole) { - return hole === '\x01' ? '' : prefix + i++; - }); - }); + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - return arr2; + function _slicedToArray(r, e) { + return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest(); } - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); + function _defineProperty(e, r, t) { + return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: true, + configurable: true, + writable: true + }) : e[r] = t, e; } - function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); + function _arrayWithoutHoles(r) { + if (Array.isArray(r)) return _arrayLikeToArray$1(r); } - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + function _iterableToArray(r) { + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + function _toConsumableArray(r) { + return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread(); } - var ELEMENT_NODE = 1; - var nodeType = 111; - var remove = function remove(_ref) { - var firstChild = _ref.firstChild, - lastChild = _ref.lastChild; - var range = document.createRange(); - range.setStartAfter(firstChild); - range.setEndAfter(lastChild); - range.deleteContents(); - return firstChild; - }; - var diffable = function diffable(node, operation) { - return node.nodeType === nodeType ? 1 / operation < 0 ? operation ? remove(node) : node.lastChild : operation ? node.valueOf() : node.firstChild : node; - }; - var persistent = function persistent(fragment) { - var firstChild = fragment.firstChild, - lastChild = fragment.lastChild; - if (firstChild === lastChild) return lastChild || fragment; - var childNodes = fragment.childNodes; - var nodes = _toConsumableArray(childNodes); - return { - ELEMENT_NODE: ELEMENT_NODE, - nodeType: nodeType, - firstChild: firstChild, - lastChild: lastChild, - valueOf: function valueOf() { - if (childNodes.length !== nodes.length) fragment.append.apply(fragment, _toConsumableArray(nodes)); - return fragment; - } - }; - }; + function _superPropBase(t, o) { + for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); + return t; + } - var isArray$1 = Array.isArray; + function set(e, r, t, o) { + return set = "undefined" != typeof Reflect && Reflect.set ? Reflect.set : function (e, r, t, o) { + var f, + i = _superPropBase(e, r); + if (i) { + if ((f = Object.getOwnPropertyDescriptor(i, r)).set) return f.set.call(o, t), true; + if (!f.writable) return false; + } + if (f = Object.getOwnPropertyDescriptor(o, r)) { + if (!f.writable) return false; + f.value = t, Object.defineProperty(o, r, f); + } else _defineProperty(o, r, t); + return true; + }, set(e, r, t, o); + } + function _set(e, r, t, o, f) { + if (!set(e, r, t, o || e) && f) throw new TypeError("failed to set property"); + return t; + } - var aria = function aria(node) { - return function (values) { - for (var key in values) { - var name = key === 'role' ? key : "aria-".concat(key); - var value = values[key]; - if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); + function _get() { + return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { + var p = _superPropBase(e, t); + if (p) { + var n = Object.getOwnPropertyDescriptor(p, t); + return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } - }; - }; - var getValue = function getValue(value) { - return value == null ? value : value.valueOf(); - }; - var attribute = function attribute(node, name) { - var oldValue, - orphan = true; - var attributeNode = document.createAttributeNS(null, name); - return function (newValue) { - var value = getValue(newValue); - if (oldValue !== value) { - if ((oldValue = value) == null) { - if (!orphan) { - node.removeAttributeNode(attributeNode); - orphan = true; + }, _get.apply(null, arguments); + } + + function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n1 = 0, F = function F() {}; return { s: F, n: function n() { return _n1 >= r.length ? { done: true } : { done: false, value: r[_n1++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } + function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } + function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } + function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } + function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } + function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } + function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } + function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } + function _superPropSet(t, e, o, r, p, f) { return _set(_getPrototypeOf(t.prototype ), e, o, r, p); } + function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; } + function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); } + var e; + !function (e) { + e[e.None = 0] = "None", e[e.Mutable = 1] = "Mutable", e[e.Watching = 2] = "Watching", e[e.RecursedCheck = 4] = "RecursedCheck", e[e.Recursed = 8] = "Recursed", e[e.Dirty = 16] = "Dirty", e[e.Pending = 32] = "Pending"; + }(e || (e = {})); + var t = [], + n = [], + _ref = function (_ref2) { + var e = _ref2.update, + t = _ref2.notify, + n = _ref2.unwatched; + var s = 0; + return { + link: function link(e, t) { + var n = t.depsTail; + if (void 0 !== n && n.dep === e) return; + var i; + if (4 & t.flags && (i = void 0 !== n ? n.nextDep : t.deps, void 0 !== i && i.dep === e)) return i.version = s, void (t.depsTail = i); + var r = e.subsTail; + if (void 0 !== r && r.version === s && r.sub === t) return; + var o = t.depsTail = e.subsTail = { + version: s, + dep: e, + sub: t, + prevDep: n, + nextDep: i, + prevSub: r, + nextSub: void 0 + }; + void 0 !== i && (i.prevDep = o); + void 0 !== n ? n.nextDep = o : t.deps = o; + void 0 !== r ? r.nextSub = o : e.subs = o; + }, + unlink: i, + propagate: function propagate(e) { + var n, + s = e.nextSub; + e: for (;;) { + var _i = e.sub; + var _r = _i.flags; + if (3 & _r && (60 & _r ? 12 & _r ? 4 & _r ? 48 & _r || !o(e, _i) ? _r = 0 : (_i.flags = 40 | _r, _r &= 1) : _i.flags = -9 & _r | 32 : _r = 0 : _i.flags = 32 | _r, 2 & _r && t(_i), 1 & _r)) { + var _t = _i.subs; + if (void 0 !== _t) { + e = _t, void 0 !== _t.nextSub && (n = { + value: s, + prev: n + }, s = e.nextSub); + continue; + } + } + if (void 0 === (e = s)) { + for (; void 0 !== n;) if (e = n.value, n = n.prev, void 0 !== e) { + s = e.nextSub; + continue e; + } + break; + } + s = e.nextSub; } - } else { - attributeNode.value = value; - if (orphan) { - node.setAttributeNodeNS(attributeNode); - orphan = false; + }, + checkDirty: function checkDirty(t, n) { + var s, + i = 0; + e: for (;;) { + var _o = t.dep, + _l = _o.flags; + var _a = false; + if (16 & n.flags) _a = true;else if (17 & ~_l) { + if (!(33 & ~_l)) { + void 0 === t.nextSub && void 0 === t.prevSub || (s = { + value: t, + prev: s + }), t = _o.deps, n = _o, ++i; + continue; + } + } else if (e(_o)) { + var _e2 = _o.subs; + void 0 !== _e2.nextSub && r(_e2), _a = true; + } + if (_a || void 0 === t.nextDep) { + for (; i;) { + --i; + var _o2 = n.subs, + _l2 = void 0 !== _o2.nextSub; + if (_l2 ? (t = s.value, s = s.prev) : t = _o2, _a) { + if (e(n)) { + _l2 && r(_o2), n = t.sub; + continue; + } + } else n.flags &= -33; + if (n = t.sub, void 0 !== t.nextDep) { + t = t.nextDep; + continue e; + } + _a = false; + } + return _a; + } + t = t.nextDep; } + }, + endTracking: function endTracking(e) { + var t = e.depsTail; + var n = void 0 !== t ? t.nextDep : e.deps; + for (; void 0 !== n;) n = i(n, e); + e.flags &= -5; + }, + startTracking: function startTracking(e) { + ++s, e.depsTail = void 0, e.flags = -57 & e.flags | 4; + }, + shallowPropagate: r + }; + function i(e) { + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.sub; + var s = e.dep, + i = e.prevDep, + r = e.nextDep, + o = e.nextSub, + l = e.prevSub; + return void 0 !== r ? r.prevDep = i : t.depsTail = i, void 0 !== i ? i.nextDep = r : t.deps = r, void 0 !== o ? o.prevSub = l : s.subsTail = l, void 0 !== l ? l.nextSub = o : void 0 === (s.subs = o) && n(s), r; + } + function r(e) { + do { + var _n = e.sub, + _s = e.nextSub, + _i2 = _n.flags; + 32 == (48 & _i2) && (_n.flags = 16 | _i2, 2 & _i2 && t(_n)), e = _s; + } while (void 0 !== e); + } + function o(e, t) { + var n = t.depsTail; + if (void 0 !== n) { + var _s2 = t.deps; + do { + if (_s2 === e) return true; + if (_s2 === n) break; + _s2 = _s2.nextDep; + } while (void 0 !== _s2); } + return false; } - }; - }; - var _boolean = function _boolean(node, key, oldValue) { - return function (newValue) { - var value = !!getValue(newValue); - if (oldValue !== value) { - // when IE won't be around anymore ... - // node.toggleAttribute(key, oldValue = !!value); - if (oldValue = value) node.setAttribute(key, '');else node.removeAttribute(key); + }({ + update: function update(e) { + return "getter" in e ? y(e) : w(e, e.value); + }, + notify: function e(t) { + var s = t.flags; + if (!(64 & s)) { + t.flags = 64 | s; + var _i3 = t.subs; + void 0 !== _i3 ? e(_i3.sub) : n[h++] = t; + } + }, + unwatched: function unwatched(e) { + if ("getter" in e) { + var _t2 = e.deps; + if (void 0 !== _t2) { + e.flags = 17; + do { + _t2 = i(_t2, e); + } while (void 0 !== _t2); + } + } else "previousValue" in e || D.call(e); } + }), + s = _ref.link, + i = _ref.unlink, + r = _ref.propagate, + o = _ref.checkDirty, + l = _ref.endTracking, + a = _ref.startTracking, + c = _ref.shallowPropagate; + var u, + d, + f = 0, + p = 0, + h = 0; + function v(e) { + var t = u; + return u = e, t; + } + function g(e) { + var t = d; + return d = e, t; + } + function b(e) { + return T.bind({ + previousValue: e, + value: e, + subs: void 0, + subsTail: void 0, + flags: 1 + }); + } + function m(e) { + return C.bind({ + value: void 0, + subs: void 0, + subsTail: void 0, + deps: void 0, + depsTail: void 0, + flags: 17, + getter: e + }); + } + function x(e) { + var t = { + fn: e, + subs: void 0, + subsTail: void 0, + deps: void 0, + depsTail: void 0, + flags: 2 }; - }; - var data = function data(_ref) { - var dataset = _ref.dataset; - return function (values) { - for (var key in values) { - var value = values[key]; - if (value == null) delete dataset[key];else dataset[key] = value; + void 0 !== u ? s(t, u) : void 0 !== d && s(t, d); + var n = v(t); + try { + t.fn(); + } finally { + v(n); + } + return D.bind(t); + } + function y(e) { + var t = v(e); + a(e); + try { + var _t3 = e.value; + return _t3 !== (e.value = e.getter(_t3)); + } finally { + v(t), l(e); + } + } + function w(e, t) { + return e.flags = 1, e.previousValue !== (e.previousValue = t); + } + function S(e, t) { + if (16 & t || 32 & t && o(e.deps, e)) { + var _t4 = v(e); + a(e); + try { + e.fn(); + } finally { + v(_t4), l(e); } - }; - }; - var event = function event(node, name) { - var oldValue, - lower, - type = name.slice(2); - if (!(name in node) && (lower = name.toLowerCase()) in node) type = lower.slice(2); - return function (newValue) { - var info = isArray$1(newValue) ? newValue : [newValue, false]; - if (oldValue !== info[0]) { - if (oldValue) node.removeEventListener(type, oldValue, info[1]); - if (oldValue = info[0]) node.addEventListener(type, oldValue, info[1]); + return; + } + 32 & t && (e.flags = -33 & t); + var n = e.deps; + for (; void 0 !== n;) { + var _e3 = n.dep, + _t5 = _e3.flags; + 64 & _t5 && S(_e3, _e3.flags = -65 & _t5), n = n.nextDep; + } + } + function k() { + for (; p < h;) { + var _e4 = n[p]; + n[p++] = void 0, S(_e4, _e4.flags &= -65); + } + p = 0, h = 0; + } + function C() { + var e = this.flags; + if (16 & e || 32 & e && o(this.deps, this)) { + if (y(this)) { + var _e5 = this.subs; + void 0 !== _e5 && c(_e5); } - }; - }; - var ref = function ref(node) { - var oldValue; - return function (value) { - if (oldValue !== value) { - oldValue = value; - if (typeof value === 'function') value(node);else value.current = node; + } else 32 & e && (this.flags = -33 & e); + return void 0 !== u ? s(this, u) : void 0 !== d && s(this, d), this.value; + } + function T() { + if (!arguments.length) { + var _e6 = this.value; + if (16 & this.flags && w(this, _e6)) { + var _e7 = this.subs; + void 0 !== _e7 && c(_e7); + } + return void 0 !== u && s(this, u), _e6; + } + { + var _t6 = arguments.length <= 0 ? undefined : arguments[0]; + if (this.value !== (this.value = _t6)) { + this.flags = 17; + var _e8 = this.subs; + void 0 !== _e8 && (r(_e8), f || k()); + } + } + } + function D() { + var e = this.deps; + for (; void 0 !== e;) e = i(e, this); + var t = this.subs; + void 0 !== t && i(t), this.flags = 0; + } + var O = { + greedy: false + }, + N = function N(e) { + return new A(e); + }, + $ = function $(e) { + t.push(v(void 0)); + try { + return e(); + } finally { + v(t.pop()); } }; + var W = /*#__PURE__*/function () { + function W(e, t) { + _classCallCheck(this, W); + this._ = e(t); + } + return _createClass(W, [{ + key: "value", + get: function get() { + return this._(); + }, + set: function set(e) { + this._(e); + } + }, { + key: "peek", + value: function peek() { + return $(this._); + } + }, { + key: "valueOf", + value: function valueOf() { + return this.value; + } + }]); + }(); + var A = /*#__PURE__*/function (_W) { + function A(e) { + _classCallCheck(this, A); + return _callSuper$1(this, A, [m, e]); + } + _inherits(A, _W); + return _createClass(A, [{ + key: "value", + get: function get() { + return this._(); + }, + set: function set(e) { + throw new Error("Computed values are read-only"); + } + }]); + }(W); + var E = /*#__PURE__*/function (_W2) { + function E(e) { + _classCallCheck(this, E); + return _callSuper$1(this, E, [b, [e]]); + } + _inherits(E, _W2); + return _createClass(E, [{ + key: "value", + get: function get() { + return _superPropGet(E, "value", this, 1)[0]; + }, + set: function set(e) { + _superPropSet(E, "value", [e], this, 1); + } + }, { + key: "peek", + value: function peek() { + return _superPropGet(E, "peek", this, 3)([])[0]; + } + }]); + }(W); + var M = function M(e) { + ++f; + try { + return e(); + } finally { + --f || k(); + } }; - var setter = function setter(node, key) { - return key === 'dataset' ? data(node) : function (value) { - node[key] = value; - }; + var R = function R(e) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : O, + _ref3$greedy = _ref3.greedy, + t = _ref3$greedy === void 0 ? false : _ref3$greedy; + return t ? new E(e) : new W(b, e); }; - var text = function text(node) { - var oldValue; - return function (newValue) { - var value = getValue(newValue); - if (oldValue != value) { - oldValue = value; - node.textContent = value == null ? '' : value; + function L() { + return R.apply(null, arguments); + } + var _ = function _(e) { + R = e; + }, + j = Array.isArray, + F = Object.assign, + P = Object.defineProperties, + B = Object.entries, + J = Object.freeze; + var _e9 = /*#__PURE__*/new WeakMap(); + var V = /*#__PURE__*/function () { + function V(e) { + _classCallCheck(this, V); + _classPrivateFieldInitSpec(this, _e9, void 0); + _classPrivateFieldSet(_e9, this, e); + } + return _createClass(V, [{ + key: "valueOf", + value: function valueOf() { + return _classPrivateFieldGet(_e9, this); + } + }, { + key: "toString", + value: function toString() { + return String(_classPrivateFieldGet(_e9, this)); } + }]); + }(); + var z = function z(e) { + return new V(e); + }, + H = function H(e) { + return document.createComment(e); + }, + q = 42, + G = new Set(["plaintext", "script", "style", "textarea", "title", "xmp"]), + I = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"]), + K = J({}), + Q = J([]), + U = function U(e, t) { + return e.children === Q && (e.children = []), e.children.push(t), t.parent = e, t; + }, + X = function X(e, t, n) { + e.props === K && (e.props = {}), e.props[t] = n; + }, + Y = function Y(e, t, n) { + e !== t && n.push(e); }; - }; - - /** - * ISC License - * - * Copyright (c) 2020, Andrea Giammarchi, @WebReflection - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - /** - * @param {Node} parentNode The container where children live - * @param {Node[]} a The list of current/live children - * @param {Node[]} b The list of future children - * @param {(entry: Node, action: number) => Node} get - * The callback invoked per each entry related DOM operation. - * @param {Node} [before] The optional node used as anchor to insert before. - * @returns {Node[]} The same list of future children. - */ - var udomdiff = (function (parentNode, a, b, get, before) { - var bLength = b.length; - var aEnd = a.length; - var bEnd = bLength; - var aStart = 0; - var bStart = 0; - var map = null; - while (aStart < aEnd || bStart < bEnd) { - // append head, tail, or nodes in between: fast path - if (aEnd === aStart) { - // we could be in a situation where the rest of nodes that - // need to be added are not at the end, and in such case - // the node to `insertBefore`, if the index is more than 0 - // must be retrieved, otherwise it's gonna be the first item. - var node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before; - while (bStart < bEnd) parentNode.insertBefore(get(b[bStart++], 1), node); + var Z = /*#__PURE__*/function () { + function Z(e) { + _classCallCheck(this, Z); + this.type = e, this.parent = null; + } + return _createClass(Z, [{ + key: "toJSON", + value: function toJSON() { + return [this.type, this.data]; } - // remove head or tail: fast path - else if (bEnd === bStart) { - while (aStart < aEnd) { - // remove the node only if it's unknown or not live - if (!map || !map.has(a[aStart])) parentNode.removeChild(get(a[aStart], -1)); - aStart++; - } + }]); + }(); + var ee = /*#__PURE__*/function (_Z) { + function ee(e) { + var _this; + _classCallCheck(this, ee); + _this = _callSuper$1(this, ee, [8]), _this.data = e; + return _this; + } + _inherits(ee, _Z); + return _createClass(ee, [{ + key: "toString", + value: function toString() { + return ""); } - // same node: fast path - else if (a[aStart] === b[bStart]) { - aStart++; - bStart++; + }]); + }(Z); + var te = /*#__PURE__*/function (_Z2) { + function te(e) { + var _this2; + _classCallCheck(this, te); + _this2 = _callSuper$1(this, te, [10]), _this2.data = e; + return _this2; + } + _inherits(te, _Z2); + return _createClass(te, [{ + key: "toString", + value: function toString() { + return ""); } - // same tail: fast path - else if (a[aEnd - 1] === b[bEnd - 1]) { - aEnd--; - bEnd--; + }]); + }(Z); + var ne = /*#__PURE__*/function (_Z3) { + function ne(e) { + var _this3; + _classCallCheck(this, ne); + _this3 = _callSuper$1(this, ne, [3]), _this3.data = e; + return _this3; + } + _inherits(ne, _Z3); + return _createClass(ne, [{ + key: "toString", + value: function toString() { + return this.data; } - // The once here single last swap "fast path" has been removed in v1.1.0 - // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85 - // reverse swap: also fast path - else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) { - // this is a "shrink" operation that could happen in these cases: - // [1, 2, 3, 4, 5] - // [1, 4, 3, 2, 5] - // or asymmetric too - // [1, 2, 3, 4, 5] - // [1, 2, 3, 5, 6, 4] - var _node = get(a[--aEnd], -1).nextSibling; - parentNode.insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling); - parentNode.insertBefore(get(b[--bEnd], 1), _node); - // mark the future index as identical (yeah, it's dirty, but cheap 👍) - // The main reason to do this, is that when a[aEnd] will be reached, - // the loop will likely be on the fast path, as identical to b[bEnd]. - // In the best case scenario, the next loop will skip the tail, - // but in the worst one, this node will be considered as already - // processed, bailing out pretty quickly from the map index check - a[aEnd] = b[bEnd]; + }]); + }(Z); + var se = /*#__PURE__*/function (_Z4) { + function se() { + var _this4; + _classCallCheck(this, se); + _this4 = _callSuper$1(this, se, [q]), _this4.name = "template", _this4.props = K, _this4.children = Q; + return _this4; + } + _inherits(se, _Z4); + return _createClass(se, [{ + key: "toJSON", + value: function toJSON() { + var e = [q]; + return Y(this.props, K, e), Y(this.children, Q, e), e; } - // map based fallback, "slow" path - else { - // the map requires an O(bEnd - bStart) operation once - // to store all future nodes indexes for later purposes. - // In the worst case scenario, this is a full O(N) cost, - // and such scenario happens at least when all nodes are different, - // but also if both first and last items of the lists are different - if (!map) { - map = new Map(); - var i = bStart; - while (i < bEnd) map.set(b[i], i++); + }, { + key: "toString", + value: function toString() { + var e = ""; + for (var _t7 in this.props) { + var _n2 = this.props[_t7]; + null != _n2 && ("boolean" == typeof _n2 ? _n2 && (e += " ".concat(_t7)) : e += " ".concat(_t7, "=\"").concat(_n2, "\"")); } - // if it's a future node, hence it needs some handling - if (map.has(a[aStart])) { - // grab the index of such node, 'cause it might have been processed - var index = map.get(a[aStart]); - // if it's not already processed, look on demand for the next LCS - if (bStart < index && index < bEnd) { - var _i = aStart; - // counts the amount of nodes that are the same in the future - var sequence = 1; - while (++_i < aEnd && _i < bEnd && map.get(a[_i]) === index + sequence) sequence++; - // effort decision here: if the sequence is longer than replaces - // needed to reach such sequence, which would brings again this loop - // to the fast path, prepend the difference before a sequence, - // and move only the future list index forward, so that aStart - // and bStart will be aligned again, hence on the fast path. - // An example considering aStart and bStart are both 0: - // a: [1, 2, 3, 4] - // b: [7, 1, 2, 3, 6] - // this would place 7 before 1 and, from that time on, 1, 2, and 3 - // will be processed at zero cost - if (sequence > index - bStart) { - var _node2 = get(a[aStart], 0); - while (bStart < index) parentNode.insertBefore(get(b[bStart++], 1), _node2); - } - // if the effort wasn't good enough, fallback to a replace, - // moving both source and target indexes forward, hoping that some - // similar node will be found later on, to go back to the fast path - else { - parentNode.replaceChild(get(b[bStart++], 1), get(a[aStart++], -1)); - } - } - // otherwise move the source forward, 'cause there's nothing to do - else aStart++; + return "").concat(this.children.join(""), ""); + } + }]); + }(Z); + var ie = /*#__PURE__*/function (_Z5) { + function ie(e) { + var _this5; + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + _classCallCheck(this, ie); + _this5 = _callSuper$1(this, ie, [1]), _this5.name = e, _this5.xml = t, _this5.props = K, _this5.children = Q; + return _this5; + } + _inherits(ie, _Z5); + return _createClass(ie, [{ + key: "toJSON", + value: function toJSON() { + var e = [1, this.name, +this.xml]; + return Y(this.props, K, e), Y(this.children, Q, e), e; + } + }, { + key: "toString", + value: function toString() { + var e = this.xml, + t = this.name, + n = this.props, + s = this.children, + i = s.length; + var r = "<".concat(t); + for (var _t8 in n) { + var _s3 = n[_t8]; + null != _s3 && ("boolean" == typeof _s3 ? _s3 && (r += e ? " ".concat(_t8, "=\"\"") : " ".concat(_t8)) : r += " ".concat(_t8, "=\"").concat(_s3, "\"")); } - // this node has no meaning in the future list, so it's more than safe - // to remove it, and check the next live node out instead, meaning - // that only the live list index should be forwarded - else parentNode.removeChild(get(a[aStart++], -1)); + if (i) { + r += ">"; + for (var _n3 = !e && G.has(t), _o3 = 0; _o3 < i; _o3++) r += _n3 ? s[_o3].data : s[_o3]; + r += ""); + } else r += e ? " />" : I.has(t) ? ">" : ">"); + return r; } + }]); + }(Z); + var re = /*#__PURE__*/function (_Z6) { + function re() { + var _this6; + _classCallCheck(this, re); + _this6 = _callSuper$1(this, re, [11]), _this6.name = "#fragment", _this6.children = Q; + return _this6; } - return b; - }); - - var isArray = Array.isArray, - prototype = Array.prototype; - var indexOf = prototype.indexOf; - var _Proxy = new Proxy(document, { - get: function get(target, method) { - return target[method].bind(target); + _inherits(re, _Z6); + return _createClass(re, [{ + key: "toJSON", + value: function toJSON() { + var e = [11]; + return Y(this.children, Q, e), e; } - }), - createDocumentFragment = _Proxy.createDocumentFragment, - createElement = _Proxy.createElement, - createElementNS = _Proxy.createElementNS, - createTextNode = _Proxy.createTextNode, - createTreeWalker = _Proxy.createTreeWalker, - importNode = _Proxy.importNode; - var createHTML = function createHTML(html) { - var template = createElement('template'); - template.innerHTML = html; - return template.content; - }; - var xml; - var createSVG = function createSVG(svg) { - if (!xml) xml = createElementNS('http://www.w3.org/2000/svg', 'svg'); - xml.innerHTML = svg; - var content = createDocumentFragment(); - content.append.apply(content, _toConsumableArray(xml.childNodes)); - return content; - }; - var createContent = function createContent(text, svg) { - return svg ? createSVG(text) : createHTML(text); - }; - - // from a generic path, retrieves the exact targeted node - var reducePath = function reducePath(_ref, i) { - var childNodes = _ref.childNodes; - return childNodes[i]; + }, { + key: "toString", + value: function toString() { + return this.children.join(""); + } + }]); + }(Z); + var oe = "\0", + le = "\"".concat(oe, "\""), + ae = "'".concat(oe, "'"), + ce = /\x00|<[^><\s]+/g, + ue = /([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g, + de = function de(e, t, n, s, i) { + return [t, n, s]; + }, + fe = function fe(e) { + var t = []; + for (; e.parent;) { + switch (e.type) { + case q: + case 1: + "template" === e.name && t.push(-1); + } + t.push(e.parent.children.indexOf(e)), e = e.parent; + } + return t; + }, + pe = function pe(e, t) { + do { + e = e.parent; + } while (t.has(e)); + return e; + }; + var he = function he(e, t) { + return t < 0 ? e.content : e.childNodes[t]; }; - - // this helper avoid code bloat around handleAnything() callback - var diff = function diff(comment, oldNodes, newNodes) { - return udomdiff(comment.parentNode, - // TODO: there is a possible edge case where a node has been - // removed manually, or it was a keyed one, attached - // to a shared reference between renders. - // In this case udomdiff might fail at removing such node - // as its parent won't be the expected one. - // The best way to avoid this issue is to filter oldNodes - // in search of those not live, or not in the current parent - // anymore, but this would require both a change to uwire, - // exposing a parentNode from the firstChild, as example, - // but also a filter per each diff that should exclude nodes - // that are not in there, penalizing performance quite a lot. - // As this has been also a potential issue with domdiff, - // and both lighterhtml and hyperHTML might fail with this - // very specific edge case, I might as well document this possible - // "diffing shenanigan" and call it a day. - oldNodes, newNodes, diffable, comment); + var ve = function ve(e, t) { + return t.reduceRight(he, e); }; - - // if an interpolation represents a comment, the whole - // diffing will be related to such comment. - // This helper is in charge of understanding how the new - // content for such interpolation/hole should be updated - var handleAnything = function handleAnything(comment) { - var oldValue, - text, - nodes = []; - var anyContent = function anyContent(newValue) { - switch (_typeof(newValue)) { - // primitives are handled as text content - case 'string': - case 'number': - case 'boolean': - if (oldValue !== newValue) { - oldValue = newValue; - if (!text) text = createTextNode(''); - text.data = newValue; - nodes = diff(comment, nodes, [text]); - } - break; - // null, and undefined are used to cleanup previous content - case 'object': - case 'undefined': - if (newValue == null) { - if (oldValue != newValue) { - oldValue = newValue; - nodes = diff(comment, nodes, []); - } - break; - } - // arrays and nodes have a special treatment - if (isArray(newValue)) { - oldValue = newValue; - // arrays can be used to cleanup, if empty - if (newValue.length === 0) nodes = diff(comment, nodes, []); - // or diffed, if these contains nodes or "wires" - else if (_typeof(newValue[0]) === 'object') nodes = diff(comment, nodes, newValue); - // in all other cases the content is stringified as is - else anyContent(String(newValue)); - break; - } - // if the new value is a DOM node, or a wire, and it's - // different from the one already live, then it's diffed. - // if the node is a fragment, it's appended once via its childNodes - // There is no `else` here, meaning if the content - // is not expected one, nothing happens, as easy as that. - if (oldValue !== newValue) { - if ('ELEMENT_NODE' in newValue) { - oldValue = newValue; - nodes = diff(comment, nodes, newValue.nodeType === 11 ? _toConsumableArray(newValue.childNodes) : [newValue]); - } else { - var value = newValue.valueOf(); - if (value !== newValue) anyContent(value); - } + var ge, + be = false; + var me = function me(_ref4) { + var e = _ref4.firstChild, + t = _ref4.lastChild; + var n = ge || (ge = document.createRange()); + return n.setStartAfter(e), n.setEndAfter(t), n.deleteContents(), e; + }, + xe = function xe(e, t) { + return be && 11 === e.nodeType ? 1 / t < 0 ? t ? me(e) : e.lastChild : t ? e.valueOf() : e.firstChild : e; + }, + ye = Symbol("nodes"), + we = { + get: function get() { + return this.firstChild.parentNode; + } + }, + Se = { + value: function value(e) { + me(this).replaceWith(e); + } + }, + ke = { + value: function value() { + me(this).remove(); + } + }, + Ce = { + value: function value() { + var e = this.parentNode; + if (e === this) this[ye] === Q && (this[ye] = _toConsumableArray(this.childNodes));else { + if (e) { + var _e0 = this.firstChild, + _t9 = this.lastChild; + for (this[ye] = [_e0]; _e0 !== _t9;) this[ye].push(_e0 = _e0.nextSibling); } - break; - case 'function': - anyContent(newValue(comment)); - break; + this.replaceChildren.apply(this, _toConsumableArray(this[ye])); + } + return this; } }; - return anyContent; - }; - - // attributes can be: - // * ref=${...} for hooks and other purposes - // * aria=${...} for aria attributes - // * ?boolean=${...} for boolean attributes - // * .dataset=${...} for dataset related attributes - // * .setter=${...} for Custom Elements setters or nodes with setters - // such as buttons, details, options, select, etc - // * @event=${...} to explicitly handle event listeners - // * onevent=${...} to automatically handle event listeners - // * generic=${...} to handle an attribute just like an attribute - var handleAttribute = function handleAttribute(node, name /*, svg*/) { - switch (name[0]) { - case '?': - return _boolean(node, name.slice(1), false); - case '.': - return setter(node, name.slice(1)); - case '@': - return event(node, 'on' + name.slice(1)); - case 'o': - if (name[1] === 'n') return event(node, name); - } - switch (name) { - case 'ref': - return ref(node); - case 'aria': - return aria(node); - } - return attribute(node, name /*, svg*/); - }; - - // each mapped update carries the update type and its path - // the type is either node, attribute, or text, while - // the path is how to retrieve the related node to update. - // In the attribute case, the attribute name is also carried along. - function handlers(options) { - var type = options.type, - path = options.path; - var node = path.reduceRight(reducePath, this); - return type === 'node' ? handleAnything(node) : type === 'attr' ? handleAttribute(node, options.name /*, options.svg*/) : text(node); + function Te(e) { + var t = H("<>"), + n = H(""); + return e.replaceChildren.apply(e, [t].concat(_toConsumableArray(e.childNodes), [n])), be = true, P(e, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ye, { + writable: true, + value: Q + }), "firstChild", { + value: t + }), "lastChild", { + value: n + }), "parentNode", we), "valueOf", Ce), "replaceWith", Se), "remove", ke)); } - - // from a fragment container, create an array of indexes - // related to its child nodes, so that it's possible - // to retrieve later on exact node via reducePath - var createPath = function createPath(node) { - var path = []; - var _node = node, - parentNode = _node.parentNode; - while (parentNode) { - path.push(indexOf.call(parentNode.childNodes, node)); - node = parentNode; - var _node2 = node; - parentNode = _node2.parentNode; - } - return path; - }; - - // the prefix is used to identify either comments, attributes, or nodes - // that contain the related unique id. In the attribute cases - // isµX="attribute-name" will be used to map current X update to that - // attribute name, while comments will be like , to map - // the update to that specific comment node, hence its parent. - // style and textarea will have text content, and are handled - // directly through text-only updates. - var prefix = 'isµ'; - - // Template Literals are unique per scope and static, meaning a template - // should be parsed once, and once only, as it will always represent the same - // content, within the exact same amount of updates each time. - // This cache relates each template to its unique content and updates. - var cache$1 = new WeakMapSet(); - - // a RegExp that helps checking nodes that cannot contain comments - var textOnly = /^(?:textarea|script|style|title|plaintext|xmp)$/; - var createCache = function createCache() { - return { - stack: [], - // each template gets a stack for each interpolation "hole" - - entry: null, - // each entry contains details, such as: - // * the template that is representing - // * the type of node it represents (html or svg) - // * the content fragment with all nodes - // * the list of updates per each node (template holes) - // * the "wired" node or fragment that will get updates - // if the template or type are different from the previous one - // the entry gets re-created each time - - wire: null // each rendered node represent some wired content and - // this reference to the latest one. If different, the node - // will be cleaned up and the new "wire" will be appended - }; - }; - - // the entry stored in the rendered node cache, and per each "hole" - var createEntry = function createEntry(type, template) { - var _mapUpdates = mapUpdates(type, template), - content = _mapUpdates.content, - updates = _mapUpdates.updates; - return { - type: type, - template: template, - content: content, - updates: updates, - wire: null - }; - }; - - // a template is instrumented to be able to retrieve where updates are needed. - // Each unique template becomes a fragment, cloned once per each other - // operation based on the same template, i.e. data => html`

${data}

` - var mapTemplate = function mapTemplate(type, template) { - var svg = type === 'svg'; - var text = instrument(template, prefix, svg); - var content = createContent(text, svg); - // once instrumented and reproduced as fragment, it's crawled - // to find out where each update is in the fragment tree - var tw = createTreeWalker(content, 1 | 128); - var nodes = []; - var length = template.length - 1; - var i = 0; - // updates are searched via unique names, linearly increased across the tree - //
- var search = "".concat(prefix).concat(i); - while (i < length) { - var node = tw.nextNode(); - // if not all updates are bound but there's nothing else to crawl - // it means that there is something wrong with the template. - if (!node) throw "bad template: ".concat(text); - // if the current node is a comment, and it contains isµX - // it means the update should take care of any content - if (node.nodeType === 8) { - // The only comments to be considered are those - // which content is exactly the same as the searched one. - if (node.data === search) { - nodes.push({ - type: 'node', - path: createPath(node) - }); - search = "".concat(prefix).concat(++i); + Te.prototype = DocumentFragment.prototype; + var De = 16, + Oe = 32768, + Ne = function () { + var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalThis.document; + var t, + n = e.createElement("template"); + return function (s) { + var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + if (i) return t || (t = e.createRange(), t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg", "svg"))), t.createContextualFragment(s); + n.innerHTML = s; + var r = n.content; + return n = n.cloneNode(false), r; + }; + }(document), + $e = Symbol("ref"), + We = function We(e, t) { + var _iterator = _createForOfIteratorHelper(B(t)), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _slicedToArray(_step.value, 2), + _n4 = _step$value[0], + _s4 = _step$value[1]; + var _t0 = "role" === _n4 ? _n4 : "aria-".concat(_n4.toLowerCase()); + null == _s4 ? e.removeAttribute(_t0) : e.setAttribute(_t0, _s4); } - } else { - // if the node is not a comment, loop through all its attributes - // named isµX and relate attribute updates to this node and the - // attribute name, retrieved through node.getAttribute("isµX") - // the isµX attribute will be removed as irrelevant for the layout - // let svg = -1; - while (node.hasAttribute(search)) { - nodes.push({ - type: 'attr', - path: createPath(node), - name: node.getAttribute(search) - }); - node.removeAttribute(search); - search = "".concat(prefix).concat(++i); + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + }, + Ae = function Ae(e) { + return function (t, n) { + null == n ? t.removeAttribute(e) : t.setAttribute(e, n); + }; + }, + Ee = function Ee(e, t) { + e[ye] = function (e, t, n, s) { + var i = s.parentNode, + r = t.length; + var o = e.length, + l = r, + a = 0, + c = 0, + u = null; + for (; a < o || c < l;) if (o === a) { + var _e1 = l < r ? c ? n(t[c - 1], -0).nextSibling : n(t[l], 0) : s; + for (; c < l;) i.insertBefore(n(t[c++], 1), _e1); + } else if (l === c) for (; a < o;) u && u.has(e[a]) || n(e[a], -1).remove(), a++;else if (e[a] === t[c]) a++, c++;else if (e[o - 1] === t[l - 1]) o--, l--;else if (e[a] === t[l - 1] && t[c] === e[o - 1]) { + var _s5 = n(e[--o], -0).nextSibling; + i.insertBefore(n(t[c++], 1), n(e[a++], -0).nextSibling), i.insertBefore(n(t[--l], 1), _s5), e[o] = t[l]; + } else { + var _u$get; + if (!u) { + u = new Map(); + var _e10 = c; + for (; _e10 < l;) u.set(t[_e10], _e10++); + } + var _s6 = (_u$get = u.get(e[a])) !== null && _u$get !== void 0 ? _u$get : -1; + if (_s6 < 0) n(e[a++], -1).remove();else if (c < _s6 && _s6 < l) { + var _r2 = a, + _d = 1; + for (; ++_r2 < o && _r2 < l && u.get(e[_r2]) === _s6 + _d;) _d++; + if (_d > _s6 - c) { + var _r3 = n(e[a], 0); + for (; c < _s6;) i.insertBefore(n(t[c++], 1), _r3); + } else i.replaceChild(n(t[c++], 1), n(e[a++], -1)); + } else a++; } - // if the node was a style, textarea, or others, check its content - // and if it is then update tex-only this node - if (textOnly.test(node.localName) && node.textContent.trim() === "")) { - node.textContent = ''; - nodes.push({ - type: 'text', - path: createPath(node) - }); - search = "".concat(prefix).concat(++i); + return t; + }(e[ye] || Q, t, xe, e); + }, + Me = new WeakMap(), + Re = function Re(e, t) { + var _e$ye; + var n = "object" == _typeof(t) ? t !== null && t !== void 0 ? t : e : function (e, t) { + var n = Me.get(e); + return n ? n.data = t : Me.set(e, n = document.createTextNode(t)), n; + }(e, t), + s = (_e$ye = e[ye]) !== null && _e$ye !== void 0 ? _e$ye : e; + n !== s && s.replaceWith(xe(e[ye] = n, 1)); + }, + Le = function Le(e, t) { + Re(e, t instanceof W ? t.value : t); + }, + _e = function _e(_ref5, t) { + var e = _ref5.dataset; + var _iterator2 = _createForOfIteratorHelper(B(t)), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _slicedToArray(_step2.value, 2), + _n5 = _step2$value[0], + _s7 = _step2$value[1]; + null == _s7 ? delete e[_n5] : e[_n5] = _s7; } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } - } - // once all nodes to update, or their attributes, are known, the content - // will be cloned in the future to represent the template, and all updates - // related to such content retrieved right away without needing to re-crawl - // the exact same template, and its content, more than once. - return { - content: content, - nodes: nodes - }; - }; - - // if a template is unknown, perform the previous mapping, otherwise grab - // its details such as the fragment with all nodes, and updates info. - var mapUpdates = function mapUpdates(type, template) { - var _ref = cache$1.get(template) || cache$1.set(template, mapTemplate(type, template)), - content = _ref.content, - nodes = _ref.nodes; - // clone deeply the fragment - var fragment = importNode(content, true); - // and relate an update handler per each node that needs one - var updates = nodes.map(handlers, fragment); - // return the fragment and all updates to use within its nodes - return { - content: fragment, - updates: updates - }; - }; - - // as html and svg can be nested calls, but no parent node is known - // until rendered somewhere, the unroll operation is needed to - // discover what to do with each interpolation, which will result - // into an update operation. - var unroll = function unroll(info, _ref2) { - var type = _ref2.type, - template = _ref2.template, - values = _ref2.values; - // interpolations can contain holes and arrays, so these need - // to be recursively discovered - var length = unrollValues(info, values); - var entry = info.entry; - // if the cache entry is either null or different from the template - // and the type this unroll should resolve, create a new entry - // assigning a new content fragment and the list of updates. - if (!entry || entry.template !== template || entry.type !== type) info.entry = entry = createEntry(type, template); - var _entry = entry, - content = _entry.content, - updates = _entry.updates, - wire = _entry.wire; - // even if the fragment and its nodes is not live yet, - // it is already possible to update via interpolations values. - for (var i = 0; i < length; i++) updates[i](values[i]); - // if the entry was new, or representing a different template or type, - // create a new persistent entity to use during diffing. - // This is simply a DOM node, when the template has a single container, - // as in `

`, or a "wire" in `

` and similar cases. - return wire || (entry.wire = persistent(content)); - }; - - // the stack retains, per each interpolation value, the cache - // related to each interpolation value, or null, if the render - // was conditional and the value is not special (Array or Hole) - var unrollValues = function unrollValues(_ref3, values) { - var stack = _ref3.stack; - var length = values.length; - for (var i = 0; i < length; i++) { - var hole = values[i]; - // each Hole gets unrolled and re-assigned as value - // so that domdiff will deal with a node/wire, not with a hole - if (hole instanceof Hole) values[i] = unroll(stack[i] || (stack[i] = createCache()), hole); - // arrays are recursively resolved so that each entry will contain - // also a DOM node or a wire, hence it can be diffed if/when needed - else if (isArray(hole)) unrollValues(stack[i] || (stack[i] = createCache()), hole); - // if the value is nothing special, the stack doesn't need to retain data - // this is useful also to cleanup previously retained data, if the value - // was a Hole, or an Array, but not anymore, i.e.: - // const update = content => html`
${content}
`; - // update(listOfItems); update(null); update(html`hole`) - else stack[i] = null; - } - if (length < stack.length) stack.splice(length); - return length; - }; - - /** - * Holds all details wrappers needed to render the content further on. - * @constructor - * @param {string} type The hole type, either `html` or `svg`. - * @param {string[]} template The template literals used to the define the content. - * @param {Array} values Zero, one, or more interpolated values to render. - */ - var Hole = /*#__PURE__*/_createClass(function Hole(type, template, values) { - _classCallCheck(this, Hole); - this.type = type; - this.template = template; - this.values = values; - }); - - // both `html` and `svg` template literal tags are polluted - // with a `for(ref[, id])` and a `node` tag too - var tag = function tag(type) { - // both `html` and `svg` tags have their own cache - var keyed = new WeakMapSet(); - // keyed operations always re-use the same cache and unroll - // the template and its interpolations right away - var fixed = function fixed(cache) { - return function (template) { - for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - values[_key - 1] = arguments[_key]; + }, + je = new Map(), + Fe = function Fe(e) { + var t = je.get(e); + return t || je.set(e, t = Pe(e)), t; + }, + Pe = function Pe(e) { + return function (t, n) { + t[e] = n; + }; + }, + Be = function Be(e, t) { + var _iterator3 = _createForOfIteratorHelper(B(t)), + _step3; + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var _step3$value = _slicedToArray(_step3.value, 2), + _n6 = _step3$value[0], + _s8 = _step3$value[1]; + Ae(_n6)(e, _s8); } - return unroll(cache, { - type: type, - template: template, - values: values - }); + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + }, + Je = function Je(e, t, n) { + return n ? function (n, s) { + var i = n[t]; + i !== null && i !== void 0 && i.length && n.removeEventListener.apply(n, [e].concat(_toConsumableArray(i))), s && n.addEventListener.apply(n, [e].concat(_toConsumableArray(s))), n[t] = s; + } : function (n, s) { + var i = n[t]; + i && n.removeEventListener(e, i), s && n.addEventListener(e, s), n[t] = s; + }; + }, + Ve = function Ve(e) { + return function (t, n) { + t.toggleAttribute(e, !!n); }; }; - return Object.assign( - // non keyed operations are recognized as instance of Hole - // during the "unroll", recursively resolved and updated - function (template) { - for (var _len2 = arguments.length, values = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - values[_key2 - 1] = arguments[_key2]; + var ze = false; + var He = true; + var qe = function qe(e) { + He = e; + }, + Ge = function Ge() { + return He; + }, + Ie = function Ie(e) { + return xe(e.n ? e.update(e) : e.valueOf(false), 1); + }, + Ke = function Ke(e, t) { + var n = [], + s = e.length, + i = t.length; + for (var _r4, _o4, _l3 = 0, _a2 = 0; _a2 < i; _a2++) _r4 = t[_a2], n[_a2] = _l3 < s && (_o4 = e[_l3++]).t === _r4.t ? (t[_a2] = _o4).update(_r4) : _r4.valueOf(false); + return n; + }, + Qe = function Qe(e, t, n) { + var s = R, + i = n.length; + var r = 0; + _(function (e) { + return r < i ? n[r++] : n[r++] = e instanceof W ? e : s(e); + }); + var o = Ge(); + o && qe(!o); + try { + return e(t, Ze); + } finally { + o && qe(o), _(s); + } + }, + Ue = function Ue(e, t) { + return e.t === t.t ? e.update(t) : (e.n.replaceWith(Ie(t)), e = t), e; + }, + Xe = function Xe(e, t, n) { + var s, + i = [], + r = [De, null, n], + o = true; + return x(function () { + if (o) o = false, s = Qe(t, n, i), i.length || (i = Q), s ? (e.replaceWith(Ie(s)), r[1] = s) : e.remove();else { + var _e11 = Qe(t, n, i); + s && Ue(s, _e11) === _e11 && (r[2] = s = _e11); + } + }), r; + }, + Ye = Symbol(), + Ze = {}; + var et = /*#__PURE__*/function () { + function et(e, t) { + _classCallCheck(this, et); + this.t = e, this.v = t, this.n = null, this.k = -1; + } + return _createClass(et, [{ + key: "valueOf", + value: function valueOf() { + var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Ge(); + var _this$t = _slicedToArray(this.t, 3), + t = _this$t[0], + n = _this$t[1], + s = _this$t[2], + i = document.importNode(t, true), + r = this.v; + var o, + l, + a, + c = r.length, + u = Q; + if (0 < c) { + for (u = n.slice(0); c--;) { + var _n$c = _slicedToArray(n[c], 3), + _t1 = _n$c[0], + _s9 = _n$c[1], + _d2 = _n$c[2], + _f = r[c]; + if (l !== _t1 && (o = ve(i, _t1), l = _t1), _d2 & De) { + var _e12 = o[Ye] || (o[Ye] = {}); + if (_d2 === De) { + var _e12$children; + var _iterator4 = _createForOfIteratorHelper(o.attributes), + _step4; + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _e12$_t; + var _step4$value = _step4.value, + _t10 = _step4$value.name, + _n7 = _step4$value.value; + (_e12$_t = _e12[_t10]) !== null && _e12$_t !== void 0 ? _e12$_t : _e12[_t10] = _n7; + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); + } + (_e12$children = _e12.children) !== null && _e12$children !== void 0 ? _e12$children : _e12.children = _toConsumableArray(o.content.childNodes), u[c] = Xe(o, _f, _e12); + } else _s9(_e12, _f), u[c] = [_d2, _s9, _e12]; + } else { + var _t11 = true; + e || !(8 & _d2) || _d2 & Oe || (1 & _d2 ? (_t11 = false, _f.length && _s9(o, _f[0] instanceof et ? Ke(Q, _f) : _f)) : _f instanceof et && (_t11 = false, _s9(o, Ie(_f)))), _t11 && (512 === _d2 ? this.k = c : (16384 === _d2 && (a !== null && a !== void 0 ? a : a = new Set()).add(o), _s9(o, _f))), u[c] = [_d2, _s9, _f, o], e && 8 & _d2 && o.remove(); + } + } + a && function (e) { + var _iterator5 = _createForOfIteratorHelper(e), + _step5; + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _t12 = _step5.value; + var _e13 = _t12[$e]; + "function" == typeof _e13 ? _e13(_t12) : _e13 instanceof W ? _e13.value = _t12 : _e13 && (_e13.current = _t12); + } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + }(a); + } + var d = i.childNodes, + f = d.length, + p = 1 === f ? d[0] : f ? Te(i) : i; + return this.v = u, this.n = p, -1 < this.k && s.set(u[this.k][2], p, this), p; } - return new Hole(type, template, values); }, { - // keyed operations need a reference object, usually the parent node - // which is showing keyed results, and optionally a unique id per each - // related node, handy with JSON results and mutable list of objects - // that usually carry a unique identifier - "for": function _for(ref, id) { - var memo = keyed.get(ref) || keyed.set(ref, new MapSet()); - return memo.get(id) || memo.set(id, fixed(createCache())); - }, - // it is possible to create one-off content out of the box via node tag - // this might return the single created node, or a fragment with all - // nodes present at the root level and, of course, their child nodes - node: function node(template) { - for (var _len3 = arguments.length, values = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - values[_key3 - 1] = arguments[_key3]; + key: "update", + value: function update(e) { + var t = this.k, + n = this.v, + s = e.v; + if (-1 < t && n[t][2] !== s[t]) return function (e, t, _e$t$2$get$update, _e$t$2$get) { + return (_e$t$2$get$update = (_e$t$2$get = e.t[2].get(t)) === null || _e$t$2$get === void 0 ? void 0 : _e$t$2$get.update(e)) !== null && _e$t$2$get$update !== void 0 ? _e$t$2$get$update : e.valueOf(false); + }(e, s[t]); + var i = n.length; + for (; i--;) { + var _e15 = n[i], + _e14 = _slicedToArray(_e15, 3), + _t13 = _e14[0], + _r5 = _e14[1], + _o5 = _e14[2]; + if (512 === _t13) continue; + var _l4 = s[i]; + if (_t13 & De) { + if (_t13 === De) { + var _t14 = _l4(_o5, Ze); + _r5 && Ue(_r5, _t14) === _t14 && (_e15[2] = _t14); + } else _r5(_o5, _l4); + } else { + var _n8 = _l4; + if (1 & _t13) { + if (8 & _t13) _l4.length && _l4[0] instanceof et && (_n8 = Ke(_o5, _l4));else if (256 & _t13 && _l4[0] === _o5[0]) continue; + } else if (8 & _t13) if (_t13 & Oe) { + if (_l4 === _o5) { + _r5(_e15[3], _n8); + continue; + } + } else _o5 instanceof et && (_l4 = Ue(_o5, _l4), _n8 = _l4.n); + _l4 !== _o5 && (_e15[2] = _l4, _r5(_e15[3], _n8)); + } } - return unroll(createCache(), new Hole(type, template, values)).valueOf(); + return this.n; } - }); - }; - - // each rendered node gets its own cache - var cache = new WeakMapSet(); - - // rendering means understanding what `html` or `svg` tags returned - // and it relates a specific node to its own unique cache. - // Each time the content to render changes, the node is cleaned up - // and the new new content is appended, and if such content is a Hole - // then it's "unrolled" to resolve all its inner nodes. - var render = function render(where, what) { - var hole = typeof what === 'function' ? what() : what; - var info = cache.get(where) || cache.set(where, createCache()); - var wire = hole instanceof Hole ? unroll(info, hole) : hole; - if (wire !== info.wire) { - info.wire = wire; - // valueOf() simply returns the node itself, but in case it was a "wire" - // it will eventually re-append all nodes to its fragment so that such - // fragment can be re-appended many times in a meaningful way - // (wires are basically persistent fragments facades with special behavior) - where.replaceChildren(wire.valueOf()); + }]); + }(); + var tt = new WeakMap(); + var nt = /*#__PURE__*/function (_Map) { + function nt() { + var _this7; + _classCallCheck(this, nt); + (_this7 = _callSuper$1(this, nt))._ = new FinalizationRegistry(function (e) { + return _this7["delete"](e); + }); + return _this7; } - return where; + _inherits(nt, _Map); + return _createClass(nt, [{ + key: "get", + value: function get(e) { + var _superPropGet2; + var t = (_superPropGet2 = _superPropGet(nt, "get", this, 3)([e])) === null || _superPropGet2 === void 0 ? void 0 : _superPropGet2.deref(); + return t && tt.get(t); + } + }, { + key: "set", + value: function set(e, t, n) { + tt.set(t, n), this._.register(t, e), _superPropGet(nt, "set", this, 3)([e, new WeakRef(t)]); + } + }]); + }(/*#__PURE__*/_wrapNativeSuper(Map)); + var st = function (_ref6) { + var _ref6$Comment = _ref6.Comment, + e = _ref6$Comment === void 0 ? ee : _ref6$Comment, + _ref6$DocumentType = _ref6.DocumentType, + t = _ref6$DocumentType === void 0 ? te : _ref6$DocumentType, + _ref6$Text = _ref6.Text, + n = _ref6$Text === void 0 ? ne : _ref6$Text, + _ref6$Fragment = _ref6.Fragment, + s = _ref6$Fragment === void 0 ? re : _ref6$Fragment, + _ref6$Element = _ref6.Element, + i = _ref6$Element === void 0 ? ie : _ref6$Element, + _ref6$Component = _ref6.Component, + r = _ref6$Component === void 0 ? se : _ref6$Component, + _ref6$update = _ref6.update, + o = _ref6$update === void 0 ? de : _ref6$update; + return function (l, a, c) { + var u = l.join(oe).trim(), + d = new Set(), + f = []; + var p = new s(), + h = 0, + v = 0, + g = 0, + b = Q; + var _iterator6 = _createForOfIteratorHelper(u.matchAll(ce)), + _step6; + try { + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + var _s0 = _step6.value; + if (0 < v) { + v--; + continue; + } + var _l5 = _s0[0], + _m = _s0.index; + if (h < _m && U(p, new n(u.slice(h, _m))), _l5 === oe) { + "table" === p.name && (p = U(p, new i("tbody", c)), d.add(p)); + var _t15 = U(p, new e("◦")); + f.push(o(_t15, 8, fe(_t15), "", a[g++])), h = _m + 1; + } else if (_l5.startsWith("", _m + 2); + if ("--\x3e" === u.slice(_n9 - 2, _n9 + 1)) { + var _t16 = u.slice(_m + 4, _n9 - 2); + "!" === _t16[0] && U(p, new e(_t16.slice(1).replace(/!$/, ""))); + } else U(p, new t(u.slice(_m + 2, _n9))); + h = _n9 + 1; + } else if (_l5.startsWith("", _m + 2); + c && "svg" === p.name && (c = !1), p = pe(p, d), h = _e16 + 1; + } else { + var _e17 = _m + _l5.length, + _t17 = u.indexOf(">", _e17), + _s1 = _l5.slice(1); + var _x = _s1; + if (_s1 === oe ? (_x = "template", p = U(p, new r()), b = fe(p).slice(1), f.push(o(p, q, b, "", a[g++]))) : (c || (_x = _x.toLowerCase(), "table" !== p.name || "tr" !== _x && "td" !== _x || (p = U(p, new i("tbody", c)), d.add(p)), "tbody" === p.name && "td" === _x && (p = U(p, new i("tr", c)), d.add(p))), p = U(p, new i(_x, !!c && "svg" !== _x)), b = Q), _e17 < _t17) { + var _n0 = !1; + var _iterator7 = _createForOfIteratorHelper(u.slice(_e17, _t17).matchAll(ue)), + _step7; + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var _step7$value = _slicedToArray(_step7.value, 3), + _s10 = _step7$value[0], + _i4 = _step7$value[1], + _r6 = _step7$value[2]; + if (_r6 === oe || _r6 === le || _r6 === ae || (_n0 = _i4.endsWith(oe))) { + var _e18 = b === Q ? b = fe(p) : b; + f.push(o(p, 2, _e18, _n0 ? _i4.slice(0, -1) : _i4, a[g++])), _n0 = !1, v++; + } else X(p, _i4, !_r6 || _r6.slice(1, -1)); + } + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); + } + b = Q; + } + h = _t17 + 1; + var _y = 0 < _t17 && "/" === u[_t17 - 1]; + if (c) _y && (p = p.parent);else if (_y || I.has(_x)) p = _y ? pe(p, d) : p.parent;else if ("svg" === _x) c = !0;else if (G.has(_x)) { + var _e19 = u.indexOf(""), h), + _t18 = u.slice(h, _e19); + _t18.trim() === oe ? (v++, f.push(o(p, 3, fe(p), "", a[g++]))) : U(p, new n(_t18)), p = p.parent, h = _e19 + _s1.length + 3, v++; + continue; + } + } + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); + } + return h < u.length && U(p, new n(u.slice(h))), [p, f]; + }; + }({ + Comment: ee, + DocumentType: te, + Text: ne, + Fragment: re, + Element: ie, + Component: se, + update: function update(e, t, n, s, i) { + switch (t) { + case q: + return [n, i, De]; + case 8: + return j(i) ? [n, Ee, 9] : i instanceof V ? [n, (r = e.xml, function (e, t) { + var _e$$e; + var n = (_e$$e = e[$e]) !== null && _e$$e !== void 0 ? _e$$e : e[$e] = {}; + n.v !== t && (n.f = Te(Ne(t, r)), n.v = t), Re(e, n.f); + }), 8192] : i instanceof W ? [n, Le, 32776] : [n, Re, 8]; + case 3: + return [n, Fe("textContent"), 2048]; + case 2: + { + var _t19 = e.type === q; + switch (s.at(0)) { + case "@": + { + var _e20 = j(i); + return [n, Je(s.slice(1), Symbol(s), _e20), _e20 ? 257 : 256]; + } + case "?": + return [n, Ve(s.slice(1)), 4096]; + case ".": + return "..." === s ? [n, _t19 ? F : Be, _t19 ? 144 : 128] : [n, Pe(s.slice(1)), _t19 ? 80 : 64]; + default: + return _t19 ? [n, Pe(s), 1040] : "aria" === s ? [n, We, 2] : "data" !== s || /^object$/i.test(e.name) ? "key" === s ? [n, ze = true, 512] : "ref" === s ? [n, Fe($e), 16384] : s.startsWith("on") ? [n, Fe(s.toLowerCase()), 64] : [n, Ae(s), 4] : [n, _e, 32]; + } + } + } + var r; + } + }), + it = function it(e) { + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap(); + return function (n) { + var i = t.get(n); + for (var _len = arguments.length, s = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + s[_key - 1] = arguments[_key]; + } + return i || (i = st(n, s, e), i.push(function () { + var e = ze; + return ze = false, e; + }() ? new nt() : null), i[0] = Ne(i[0].toString(), e), t.set(n, i)), new et(i, s); + }; + }, + rt = it(false), + ot = it(true), + lt = new WeakMap(); + function at(e) { + for (var _len2 = arguments.length, t = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + t[_key2 - 1] = arguments[_key2]; + } + var n = rt.apply(null, arguments); + return Ge() ? n.valueOf(true) : n; + } + function ct(e) { + for (var _len3 = arguments.length, t = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + t[_key3 - 1] = arguments[_key3]; + } + var n = ot.apply(null, arguments); + return Ge() ? n.valueOf(true) : n; + } + var ut = function ut(e, t) { + var n = lt.get(e); + if (n && n[0](), "function" == typeof t) { + var _i5; + qe(false); + var _r7 = function (e) { + var t = { + deps: void 0, + depsTail: void 0, + subs: void 0, + subsTail: void 0, + flags: 0 + }; + void 0 !== d && s(t, d); + var n = v(void 0), + i = g(t); + try { + e(); + } finally { + g(i), v(n); + } + return D.bind(t); + }(function () { + _i5 = t(); + }); + if (n && n[1].t === _i5.t) n[1].update(_i5);else { + var _t20 = _i5.valueOf(false); + e.replaceChildren(_t20); + } + lt.set(e, [_r7, _i5]); + } else qe(true), lt["delete"](e), e.replaceChildren(t instanceof et ? Ie(t) : xe(t, 1)); + return e; }; - var html = tag('html'); - var svg = tag('svg'); var umap = (function (_) { return { @@ -1082,8 +1525,8 @@ var uce = (function (exports) { }; }); - function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } - function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } var reactive = domHandler({ dom: true }); @@ -1257,12 +1700,11 @@ var uce = (function (exports) { c = _info.c, e = _info.e; var MicroElement = /*#__PURE__*/function (_c) { - _inherits(MicroElement, _c); - var _super = _createSuper(MicroElement); function MicroElement() { _classCallCheck(this, MicroElement); - return _super.apply(this, arguments); + return _callSuper(this, MicroElement, arguments); } + _inherits(MicroElement, _c); return _createClass(MicroElement); }(c); defineProperties(MicroElement, statics); @@ -1287,13 +1729,12 @@ var uce = (function (exports) { // element on the page, it will break once the registry // will try to upgrade such element so ... HTMLElement it is. CE.define('uce-lib', /*#__PURE__*/function (_info$c) { - _inherits(_class, _info$c); - var _super2 = _createSuper(_class); function _class() { _classCallCheck(this, _class); - return _super2.apply(this, arguments); + return _callSuper(this, _class, arguments); } - _createClass(_class, null, [{ + _inherits(_class, _info$c); + return _createClass(_class, null, [{ key: "define", get: function get() { return define; @@ -1301,17 +1742,17 @@ var uce = (function (exports) { }, { key: "render", get: function get() { - return render; + return ut; } }, { key: "html", get: function get() { - return html; + return at; } }, { key: "svg", get: function get() { - return svg; + return ct; } }, { key: "css", @@ -1319,20 +1760,27 @@ var uce = (function (exports) { return css; } }]); - return _class; }(info(element).c)); function bind(method) { this[method] = this[method].bind(this); } function content() { - return render(this, html.apply(null, arguments)); + return ut(this, at.apply(null, arguments)); } + exports.Hole = et; + exports.batch = M; + exports.computed = N; exports.css = css; exports.define = define; - exports.html = html; - exports.render = render; - exports.svg = svg; + exports.effect = x; + exports.fragment = Ne; + exports.html = at; + exports.render = ut; + exports.signal = L; + exports.svg = ct; + exports.unsafe = z; + exports.untracked = $; return exports; diff --git a/min.js b/min.js index 388d4f6..c8ac4da 100644 --- a/min.js +++ b/min.js @@ -1 +1 @@ -var uce=function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"===e(n)?n:String(n)}function r(t,e){for(var r=0;r]*?)(\/?)>/g,g=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,m=/[\x01\x02]/g;function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);nd-l)for(var b=r(e[a],0);l"})).replace(m,(function(t){return""===t?"\x3c!--"+e+r+++"--\x3e":e+r++}))}(e,I,n),o=L(r,n),i=_(o,129),u=[],c=e.length-1,a=0,l="".concat(I).concat(a);a1?n-1:0),o=1;o1?r-1:0),i=1;i1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{},n=t.all,r=void 0!==n&&n,o=t.shallow,i=void 0===o||o,u=t.useState,c=void 0===u?it:u,a=t.getAttribute,l=void 0===a?function(t,e){return t.getAttribute(e)}:a;return function(t,n,o){var u=function(t,e,n,r,o,i){for(var u={},c=o!==it,a=[n,r,c],l=rt(t),f=0;fe.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,o=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw o}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&void 0!==arguments[1]?arguments[1]:e.sub,n=e.dep,i=e.prevDep,o=e.nextDep,u=e.nextSub,a=e.prevSub;return void 0!==o?o.prevDep=i:t.depsTail=i,void 0!==i?i.nextDep=o:t.deps=o,void 0!==u?u.prevSub=a:n.subsTail=a,void 0!==a?a.nextSub=u:void 0===(n.subs=u)&&r(n),o}function u(e){do{var t=e.sub,r=e.nextSub,i=t.flags;32==(48&i)&&(t.flags=16|i,2&i&&n(t)),e=r}while(void 0!==e)}function a(e,t){var n=t.depsTail;if(void 0!==n){var r=t.deps;do{if(r===e)return!0;if(r===n)break;r=r.nextDep}while(void 0!==r)}return!1}}({update:function(e){return"getter"in e?Q(e):X(e,e.value)},notify:function e(t){var n=t.flags;if(!(64&n)){t.flags=64|n;var r=t.subs;void 0!==r?e(r.sub):R[z++]=t}},unwatched:function(e){if("getter"in e){var t=e.deps;if(void 0!==t){e.flags=17;do{t=_(t,e)}while(void 0!==t)}}else"previousValue"in e||ne.call(e)}}),W=M.link,_=M.unlink,L=M.propagate,B=M.checkDirty,I=M.endTracking,F=M.startTracking,J=M.shallowPropagate,$=0,V=0,z=0;function H(e){var t=D;return D=e,t}function U(e){var t=P;return P=e,t}function q(e){return te.bind({previousValue:e,value:e,subs:void 0,subsTail:void 0,flags:1})}function G(e){return ee.bind({value:void 0,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:17,getter:e})}function K(e){var t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==D?W(t,D):void 0!==P&&W(t,P);var n=H(t);try{t.fn()}finally{H(n)}return ne.bind(t)}function Q(e){var t=H(e);F(e);try{var n=e.value;return n!==(e.value=e.getter(n))}finally{H(t),I(e)}}function X(e,t){return e.flags=1,e.previousValue!==(e.previousValue=t)}function Y(e,t){if(16&t||32&t&&B(e.deps,e)){var n=H(e);F(e);try{e.fn()}finally{H(n),I(e)}}else{32&t&&(e.flags=-33&t);for(var r=e.deps;void 0!==r;){var i=r.dep,o=i.flags;64&o&&Y(i,i.flags=-65&o),r=r.nextDep}}}function Z(){for(;V1&&void 0!==arguments[1]?arguments[1]:re).greedy;return void 0!==t&&t?new ae(e):new oe(q,e)};var ce,fe=function(e){le=e},se=Array.isArray,ve=Object.assign,de=Object.defineProperties,pe=Object.entries,he=Object.freeze,ye=new WeakMap,be=function(){return i(function e(t){o(this,e),k(this,ye,void 0),function(e,t,n){e.set(x(e,t),n)}(ye,this,t)},[{key:"valueOf",value:function(){return O(ye,this)}},{key:"toString",value:function(){return String(O(ye,this))}}])}(),ge=function(e){return document.createComment(e)},me=42,we=new Set(["plaintext","script","style","textarea","title","xmp"]),Se=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),ke=he({}),Oe=he([]),xe=function(e,t){return e.children===Oe&&(e.children=[]),e.children.push(t),t.parent=e,t},je=function(e,t,n){e.props===ke&&(e.props={}),e.props[t]=n},Ce=function(e,t,n){e!==t&&n.push(e)},Te=function(){return i(function e(t){o(this,e),this.type=t,this.parent=null},[{key:"toJSON",value:function(){return[this.type,this.data]}}])}(),Ae=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[8])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return"\x3c!--".concat(this.data,"--\x3e")}}])}(Te),Ee=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[10])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return"")}}])}(Te),De=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[3])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return this.data}}])}(Te),Pe=function(e){function t(){var e;return o(this,t),(e=T(this,t,[me])).name="template",e.props=ke,e.children=Oe,e}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[me];return Ce(this.props,ke,e),Ce(this.children,Oe,e),e}},{key:"toString",value:function(){var e="";for(var t in this.props){var n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=" ".concat(t)):e+=" ".concat(t,'="').concat(n,'"'))}return"").concat(this.children.join(""),"")}}])}(Te),Ne=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o(this,t),(n=T(this,t,[1])).name=e,n.xml=r,n.props=ke,n.children=Oe,n}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[1,this.name,+this.xml];return Ce(this.props,ke,e),Ce(this.children,Oe,e),e}},{key:"toString",value:function(){var e=this.xml,t=this.name,n=this.props,r=this.children,i=r.length,o="<".concat(t);for(var u in n){var a=n[u];null!=a&&("boolean"==typeof a?a&&(o+=e?" ".concat(u,'=""'):" ".concat(u)):o+=" ".concat(u,'="').concat(a,'"'))}if(i){o+=">";for(var l=!e&&we.has(t),c=0;c")}else o+=e?" />":Se.has(t)?">":">");return o}}])}(Te),Re=function(e){function t(){var e;return o(this,t),(e=T(this,t,[11])).name="#fragment",e.children=Oe,e}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[11];return Ce(this.children,Oe,e),e}},{key:"toString",value:function(){return this.children.join("")}}])}(Te),Me="\0",We='"'.concat(Me,'"'),_e="'".concat(Me,"'"),Le=/\x00|<[^><\s]+/g,Be=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,Ie=function(e,t,n,r,i){return[t,n,r]},Fe=function(e){for(var t=[];e.parent;){switch(e.type){case me:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},Je=function(e,t){do{e=e.parent}while(t.has(e));return e},$e=function(e,t){return t<0?e.content:e.childNodes[t]},Ve=function(e,t){return t.reduceRight($e,e)},ze=!1,He=function(e){var t=e.firstChild,n=e.lastChild,r=ce||(ce=document.createRange());return r.setStartAfter(t),r.setEndAfter(n),r.deleteContents(),t},Ue=function(e,t){return ze&&11===e.nodeType?1/t<0?t?He(e):e.lastChild:t?e.valueOf():e.firstChild:e},qe=Symbol("nodes"),Ge={get:function(){return this.firstChild.parentNode}},Ke={value:function(e){He(this).replaceWith(e)}},Qe={value:function(){He(this).remove()}},Xe={value:function(){var e=this.parentNode;if(e===this)this[qe]===Oe&&(this[qe]=y(this.childNodes));else{if(e){var t=this.firstChild,n=this.lastChild;for(this[qe]=[t];t!==n;)this[qe].push(t=t.nextSibling)}this.replaceChildren.apply(this,y(this[qe]))}return this}};function Ye(e){var t=ge("<>"),n=ge("");return e.replaceChildren.apply(e,[t].concat(y(e.childNodes),[n])),ze=!0,de(e,h(h(h(h(h(h(h({},qe,{writable:!0,value:Oe}),"firstChild",{value:t}),"lastChild",{value:n}),"parentNode",Ge),"valueOf",Xe),"replaceWith",Ke),"remove",Qe))}Ye.prototype=DocumentFragment.prototype;var Ze=16,et=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis.document,n=t.createElement("template");return function(r){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return e||(e=t.createRange()).selectNodeContents(t.createElementNS("http://www.w3.org/2000/svg","svg")),e.createContextualFragment(r);n.innerHTML=r;var i=n.content;return n=n.cloneNode(!1),i}}(document),tt=Symbol("ref"),nt=function(e,t){var n,r=w(pe(t));try{for(r.s();!(n=r.n()).done;){var i=p(n.value,2),o=i[0],u=i[1],a="role"===o?o:"aria-".concat(o.toLowerCase());null==u?e.removeAttribute(a):e.setAttribute(a,u)}}catch(e){r.e(e)}finally{r.f()}},rt=function(e){return function(t,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}},it=function(e,t){e[qe]=function(e,t,n,r){for(var i=r.parentNode,o=t.length,u=e.length,a=o,l=0,c=0,f=null;lh-c)for(var g=n(e[l],0);c0&&void 0!==arguments[0]?arguments[0]:gt(),o=p(this.t,3),u=o[0],a=o[1],l=o[2],c=document.importNode(u,!0),f=this.v,s=f.length,v=Oe;if(0",x+2);if("--\x3e"===a.slice(C-2,C+1)){var T=a.slice(x+4,C-2);"!"===T[0]&&xe(d,new n(T.slice(1).replace(/!$/,"")))}else xe(d,new i(a.slice(x+2,C)));y=C+1}else if(O.startsWith("",x+2);r&&"svg"===d.name&&(r=!1),d=Je(d,c),y=A+1}else{var E=x+O.length,D=a.indexOf(">",E),P=O.slice(1),N=P;if(P===Me?(N="template",d=xe(d,new v),m=Fe(d).slice(1),s.push(h(d,me,m,"",t[g++]))):(r||(N=N.toLowerCase(),"table"!==d.name||"tr"!==N&&"td"!==N||(d=xe(d,new f("tbody",r)),c.add(d)),"tbody"===d.name&&"td"===N&&(d=xe(d,new f("tr",r)),c.add(d))),d=xe(d,new f(N,!!r&&"svg"!==N)),m=Oe),E"),y),$=a.slice(y,J);$.trim()===Me?(b++,s.push(h(d,3,Fe(d),"",t[g++]))):xe(d,new u($)),d=d.parent,y=J+P.length+3,b++;continue}}}}}catch(e){S.e(e)}finally{S.f()}return y1&&void 0!==arguments[1]?arguments[1]:new WeakMap;return function(n){for(var r=t.get(n),i=arguments.length,o=new Array(i>1?i-1:0),u=1;u1?t-1:0),r=1;r1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},n=e.all,r=void 0!==n&&n,i=e.shallow,o=void 0===i||i,u=e.useState,a=void 0===u?Jt:u,l=e.getAttribute,c=void 0===l?function(e,t){return e.getAttribute(t)}:l;return function(e,n,i){var u=function(e,t,n,r,i,o){for(var u={},a=i!==Jt,l=[n,r,a],c=It(e),f=0;f]*?)(\/?)>/g,l=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,o=/[\x01\x02]/g;const a=(e,t)=>111===e.nodeType?1/t<0?t?(({firstChild:e,lastChild:t})=>{const n=document.createRange();return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e})(e):e.lastChild:t?e.valueOf():e.firstChild:e,{isArray:c}=Array,i=e=>null==e?e:e.valueOf(),u=(e,t)=>{let n,s,r=t.slice(2);return!(t in e)&&(s=t.toLowerCase())in e&&(r=s.slice(2)),t=>{const s=c(t)?t:[t,!1];n!==s[0]&&(n&&e.removeEventListener(r,n,s[1]),(n=s[0])&&e.addEventListener(r,n,s[1]))}};const{isArray:d,prototype:p}=Array,{indexOf:h}=p,{createDocumentFragment:f,createElement:g,createElementNS:b,createTextNode:m,createTreeWalker:y,importNode:v}=new Proxy(document,{get:(e,t)=>e[t].bind(e)});let w;const x=(e,t)=>t?(e=>{w||(w=b("http://www.w3.org/2000/svg","svg")),w.innerHTML=e;const t=f();return t.append(...w.childNodes),t})(e):(e=>{const t=g("template");return t.innerHTML=e,t.content})(e),C=({childNodes:e},t)=>e[t],A=(e,t,n)=>((e,t,n,s,r)=>{const l=n.length;let o=t.length,a=l,c=0,i=0,u=null;for(;cr-i){const l=s(t[c],0);for(;i{switch(t[0]){case"?":return((e,t,n)=>s=>{const r=!!i(s);n!==r&&((n=r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const s=t[n];null==s?delete e[n]:e[n]=s}})(e):n=>{e[t]=n})(e,t.slice(1));case"@":return u(e,"on"+t.slice(1));case"o":if("n"===t[1])return u(e,t)}switch(t){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(e);case"aria":return(e=>t=>{for(const n in t){const s="role"===n?n:`aria-${n}`,r=t[n];null==r?e.removeAttribute(s):e.setAttribute(s,r)}})(e)}return((e,t)=>{let n,s=!0;const r=document.createAttributeNS(null,t);return t=>{const l=i(t);n!==l&&(null==(n=l)?s||(e.removeAttributeNode(r),s=!0):(r.value=l,s&&(e.setAttributeNodeNS(r),s=!1)))}})(e,t)};function N(e){const{type:t,path:n}=e,s=n.reduceRight(C,this);return"node"===t?(e=>{let t,n,s=[];const r=l=>{switch(typeof l){case"string":case"number":case"boolean":t!==l&&(t=l,n||(n=m("")),n.data=l,s=A(e,s,[n]));break;case"object":case"undefined":if(null==l){t!=l&&(t=l,s=A(e,s,[]));break}if(d(l)){t=l,0===l.length?s=A(e,s,[]):"object"==typeof l[0]?s=A(e,s,l):r(String(l));break}if(t!==l)if("ELEMENT_NODE"in l)t=l,s=A(e,s,11===l.nodeType?[...l.childNodes]:[l]);else{const e=l.valueOf();e!==l&&r(e)}break;case"function":r(l(e))}};return r})(s):"attr"===t?k(s,e.name):(e=>{let t;return n=>{const s=i(n);t!=s&&(t=s,e.textContent=null==s?"":s)}})(s)}const E=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(h.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},O="isµ",$=new n,S=/^(?:textarea|script|style|title|plaintext|xmp)$/,M=(e,t)=>{const n="svg"===e,a=((e,t,n)=>{let a=0;return e.join("").trim().replace(r,((e,t,r,o)=>{let a=t+r.replace(l,"=$2$1").trimEnd();return o.length&&(a+=n||s.test(t)?" /":">"})).replace(o,(e=>""===e?"\x3c!--"+t+a+++"--\x3e":t+a++))})(t,O,n),c=x(a,n),i=y(c,129),u=[],d=t.length-1;let p=0,h=`${O}${p}`;for(;p{const{content:n,nodes:s}=$.get(t)||$.set(t,M(e,t)),r=v(n,!0);return{content:r,updates:s.map(N,r)}},L=(e,{type:t,template:n,values:s})=>{const r=j(e,s);let{entry:l}=e;l&&l.template===n&&l.type===t||(e.entry=l=((e,t)=>{const{content:n,updates:s}=T(e,t);return{type:e,template:t,content:n,updates:s,wire:null}})(t,n));const{content:o,updates:a,wire:c}=l;for(let e=0;e{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:s}=e,r=[...s];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(s.length!==r.length&&e.append(...r),e)}})(o))},j=({stack:e},t)=>{const{length:n}=t;for(let s=0;s{const s=new n;return Object.assign(((t,...n)=>new P(e,t,n)),{for(n,r){const l=s.get(n)||s.set(n,new t);return l.get(r)||l.set(r,(t=>(n,...s)=>L(t,{type:e,template:n,values:s}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>L({stack:[],entry:null,wire:null},new P(e,t,n)).valueOf()})},D=new n,W=(e,t)=>{const n="function"==typeof t?t():t,s=D.get(e)||D.set(e,{stack:[],entry:null,wire:null}),r=n instanceof P?L(s,n):n;return r!==s.wire&&(s.wire=r,e.replaceChildren(r.valueOf())),e},H=B("html"),_=B("svg");function z(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(l){(e||l!==s||t&&"object"==typeof l&&l)&&(s=l,n?r.call(this,s):r.call(this))}}),q=()=>{};const G=(({all:e=!1,shallow:t=!0,useState:n=q,getAttribute:s=((e,t)=>e.getAttribute(t))}={})=>(r,l,o)=>{const a=((e,t,n,s,r,l)=>{const o={},a=r!==q,c=[n,s,a];for(let n=F(e),s=0;s{let n=e[t],l=typeof n;return r.hasOwnProperty(t)?(n=r[t],delete r[t]):r.hasAttribute(t)&&(n=s(r,t),"number"==l?n=+n:"boolean"==l&&(n=!/^(?:false|0|)$/.test(n))),n}),e,t,n,o);return R(r,a)})({dom:!0}),I=customElements,{define:K}=I,{parse:Q,stringify:U}=JSON,{create:V,defineProperties:X,getOwnPropertyDescriptor:Y,keys:Z}=Object,ee="element",te=new WeakMap,ne=(se=new Map([[ee,{c:HTMLElement,e:ee}]]),{get:e=>se.get(e),set:(e,t)=>(se.set(e,t),t)});var se;const re=e=>document.createElement(e),le=e=>ne.get(e)||ne.set(e,{c:re(e).constructor,e:e}),oe=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:r,connected:l,disconnected:o,formAssociated:a,handleEvent:c,init:i,observedAttributes:u,props:d,render:p,style:h}=t,f=new WeakMap,g={},b={},m=[],y=V(null),v=(e,t,s)=>{if(!f.has(e)){f.set(e,0),X(e,{html:{configurable:!0,value:ce.bind(n?e.attachShadow(n):e)}});for(let t=0;t"getter"in e?w(e):S(e,e.value),notify:function e(t){const n=t.flags;if(!(64&n)){t.flags=64|n;const i=t.subs;void 0!==i?e(i.sub):s[v++]=t}},unwatched(e){if("getter"in e){let t=e.deps;if(void 0!==t){e.flags=17;do{t=r(t,e)}while(void 0!==t)}}else"previousValue"in e||D.call(e)}});let d,f,h=0,p=0,v=0;function g(e){const t=d;return d=e,t}function b(e){const t=f;return f=e,t}function m(e){return O.bind({previousValue:e,value:e,subs:void 0,subsTail:void 0,flags:1})}function y(e){return T.bind({value:void 0,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:17,getter:e})}function x(e){const t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==d?i(t,d):void 0!==f&&i(t,f);const n=g(t);try{t.fn()}finally{g(n)}return D.bind(t)}function w(e){const t=g(e);c(e);try{const t=e.value;return t!==(e.value=e.getter(t))}finally{g(t),a(e)}}function S(e,t){return e.flags=1,e.previousValue!==(e.previousValue=t)}function k(e,t){if(16&t||32&t&&l(e.deps,e)){const t=g(e);c(e);try{e.fn()}finally{g(t),a(e)}return}32&t&&(e.flags=-33&t);let n=e.deps;for(;void 0!==n;){const e=n.dep,t=e.flags;64&t&&k(e,e.flags=-65&t),n=n.nextDep}}function C(){for(;p{n.push(g(void 0));try{return e()}finally{g(n.pop())}};class A{constructor(e,t){this._=e(t)}get value(){return this._()}set value(e){this._(e)}peek(){return N(this._)}valueOf(){return this.value}}class W extends A{constructor(e){super(y,e)}get value(){return this._()}set value(e){throw new Error("Computed values are read-only")}}class E extends A{constructor(e){super(m,[e])}get value(){return super.value[0]}set value(e){super.value=[e]}peek(){return super.peek()[0]}}let M=(e,{greedy:t=!1}=$)=>t?new E(e):new A(m,e);const L=e=>{M=e},{isArray:j}=Array,{assign:P,defineProperties:R,entries:_,freeze:F}=Object;class J{#e;constructor(e){this.#e=e}valueOf(){return this.#e}toString(){return String(this.#e)}}const B=e=>document.createComment(e),V=42,H=new Set(["plaintext","script","style","textarea","title","xmp"]),z=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),q=F({}),G=F([]),I=(e,t)=>(e.children===G&&(e.children=[]),e.children.push(t),t.parent=e,t),K=(e,t,n)=>{e.props===q&&(e.props={}),e.props[t]=n},Q=(e,t,n)=>{e!==t&&n.push(e)};class U{constructor(e){this.type=e,this.parent=null}toJSON(){return[this.type,this.data]}}class X extends U{constructor(e){super(8),this.data=e}toString(){return`\x3c!--${this.data}--\x3e`}}class Y extends U{constructor(e){super(10),this.data=e}toString(){return``}}class Z extends U{constructor(e){super(3),this.data=e}toString(){return this.data}}class ee extends U{constructor(){super(V),this.name="template",this.props=q,this.children=G}toJSON(){const e=[V];return Q(this.props,q,e),Q(this.children,G,e),e}toString(){let e="";for(const t in this.props){const n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=` ${t}`):e+=` ${t}="${n}"`)}return`${this.children.join("")}`}}class te extends U{constructor(e,t=!1){super(1),this.name=e,this.xml=t,this.props=q,this.children=G}toJSON(){const e=[1,this.name,+this.xml];return Q(this.props,q,e),Q(this.children,G,e),e}toString(){const{xml:e,name:t,props:n,children:s}=this,{length:i}=s;let r=`<${t}`;for(const t in n){const s=n[t];null!=s&&("boolean"==typeof s?s&&(r+=e?` ${t}=""`:` ${t}`):r+=` ${t}="${s}"`)}if(i){r+=">";for(let n=!e&&H.has(t),o=0;o`}else r+=e?" />":z.has(t)?">":`>`;return r}}class ne extends U{constructor(){super(11),this.name="#fragment",this.children=G}toJSON(){const e=[11];return Q(this.children,G,e),e}toString(){return this.children.join("")}}const se="\0",ie=`"${se}"`,re=`'${se}'`,oe=/\x00|<[^><\s]+/g,le=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,ae=(e,t,n,s,i)=>[t,n,s],ce=e=>{const t=[];for(;e.parent;){switch(e.type){case V:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},ue=(e,t)=>{do{e=e.parent}while(t.has(e));return e},de=(e,t)=>t<0?e.content:e.childNodes[t];var fe=(e,t)=>t.reduceRight(de,e);let he,pe=!1;const ve=({firstChild:e,lastChild:t})=>{const n=he||(he=document.createRange());return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e},ge=(e,t)=>pe&&11===e.nodeType?1/t<0?t?ve(e):e.lastChild:t?e.valueOf():e.firstChild:e,be=Symbol("nodes"),me={get(){return this.firstChild.parentNode}},ye={value(e){ve(this).replaceWith(e)}},xe={value(){ve(this).remove()}},we={value(){const{parentNode:e}=this;if(e===this)this[be]===G&&(this[be]=[...this.childNodes]);else{if(e){let{firstChild:e,lastChild:t}=this;for(this[be]=[e];e!==t;)this[be].push(e=e.nextSibling)}this.replaceChildren(...this[be])}return this}};function Se(e){const t=B("<>"),n=B("");return e.replaceChildren(t,...e.childNodes,n),pe=!0,R(e,{[be]:{writable:!0,value:G},firstChild:{value:t},lastChild:{value:n},parentNode:me,valueOf:we,replaceWith:ye,remove:xe})}Se.prototype=DocumentFragment.prototype;const ke=16,Ce=((e=globalThis.document)=>{let t,n=e.createElement("template");return(s,i=!1)=>{if(i)return t||(t=e.createRange(),t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg"))),t.createContextualFragment(s);n.innerHTML=s;const r=n.content;return n=n.cloneNode(!1),r}})(document),Te=Symbol("ref"),Oe=(e,t)=>{for(const[n,s]of _(t)){const t="role"===n?n:`aria-${n.toLowerCase()}`;null==s?e.removeAttribute(t):e.setAttribute(t,s)}},De=e=>(t,n)=>{null==n?t.removeAttribute(e):t.setAttribute(e,n)},$e=(e,t)=>{e[be]=((e,t,n,s)=>{const i=s.parentNode,r=t.length;let o=e.length,l=r,a=0,c=0,u=null;for(;as-c){const r=n(e[a],0);for(;c{const n="object"==typeof t?t??e:((e,t)=>{let n=Ne.get(e);return n?n.data=t:Ne.set(e,n=document.createTextNode(t)),n})(e,t),s=e[be]??e;n!==s&&s.replaceWith(ge(e[be]=n,1))},We=(e,t)=>{Ae(e,t instanceof A?t.value:t)},Ee=({dataset:e},t)=>{for(const[n,s]of _(t))null==s?delete e[n]:e[n]=s},Me=new Map,Le=e=>{let t=Me.get(e);return t||Me.set(e,t=je(e)),t},je=e=>(t,n)=>{t[e]=n},Pe=(e,t)=>{for(const[n,s]of _(t))De(n)(e,s)},Re=(e,t,n)=>n?(n,s)=>{const i=n[t];i?.length&&n.removeEventListener(e,...i),s&&n.addEventListener(e,...s),n[t]=s}:(n,s)=>{const i=n[t];i&&n.removeEventListener(e,i),s&&n.addEventListener(e,s),n[t]=s},_e=e=>(t,n)=>{t.toggleAttribute(e,!!n)};let Fe=!1,Je=!0;const Be=e=>{Je=e},Ve=()=>Je,He=e=>ge(e.n?e.update(e):e.valueOf(!1),1),ze=(e,t)=>{const n=[],s=e.length,i=t.length;for(let r,o,l=0,a=0;a{const s=M,i=n.length;let r=0;L(e=>r(e.t===t.t?e.update(t):(e.n.replaceWith(He(t)),e=t),e),Ie=(e,t,n)=>{let s,i=[],r=[ke,null,n],o=!0;return x(()=>{if(o)o=!1,s=qe(t,n,i),i.length||(i=G),s?(e.replaceWith(He(s)),r[1]=s):e.remove();else{const e=qe(t,n,i);s&&Ge(s,e)===e&&(r[2]=s=e)}}),r},Ke=Symbol(),Qe={};class Ue{constructor(e,t){this.t=e,this.v=t,this.n=null,this.k=-1}valueOf(e=Ve()){const[t,n,s]=this.t,i=document.importNode(t,!0),r=this.v;let o,l,a,c=r.length,u=G;if(0{for(const t of e){const e=t[Te];"function"==typeof e?e(t):e instanceof A?e.value=t:e&&(e.current=t)}})(a)}const{childNodes:d}=i,f=d.length,h=1===f?d[0]:f?Se(i):i;return this.v=u,this.n=h,-1e.t[2].get(t)?.update(e)??e.valueOf(!1))(e,s[t]);let{length:i}=n;for(;i--;){const e=n[i],[t,r,o]=e;if(512===t)continue;let l=s[i];if(t&ke)if(t===ke){const t=l(o,Qe);r&&Ge(r,t)===t&&(e[2]=t)}else r(o,l);else{let n=l;if(1&t){if(8&t)l.length&&l[0]instanceof Ue&&(n=ze(o,l));else if(256&t&&l[0]===o[0])continue}else if(8&t)if(32768&t){if(l===o){r(e[3],n);continue}}else o instanceof Ue&&(l=Ge(o,l),n=l.n);l!==o&&(e[2]=l,r(e[3],n))}}return this.n}}const Xe=new WeakMap;class Ye extends Map{constructor(){super()._=new FinalizationRegistry(e=>this.delete(e))}get(e){const t=super.get(e)?.deref();return t&&Xe.get(t)}set(e,t,n){Xe.set(t,n),this._.register(t,e),super.set(e,new WeakRef(t))}}const Ze=(({Comment:e=X,DocumentType:t=Y,Text:n=Z,Fragment:s=ne,Element:i=te,Component:r=ee,update:o=ae})=>(l,a,c)=>{const u=l.join(se).trim(),d=new Set,f=[];let h=new s,p=0,v=0,g=0,b=G;for(const s of u.matchAll(oe)){if(0",m+2);if("--\x3e"===u.slice(n-2,n+1)){const t=u.slice(m+4,n-2);"!"===t[0]&&I(h,new e(t.slice(1).replace(/!$/,"")))}else I(h,new t(u.slice(m+2,n)));p=n+1}else if(l.startsWith("",m+2);c&&"svg"===h.name&&(c=!1),h=ue(h,d),p=e+1}else{const e=m+l.length,t=u.indexOf(">",e),s=l.slice(1);let y=s;if(s===se?(y="template",h=I(h,new r),b=ce(h).slice(1),f.push(o(h,V,b,"",a[g++]))):(c||(y=y.toLowerCase(),"table"!==h.name||"tr"!==y&&"td"!==y||(h=I(h,new i("tbody",c)),d.add(h)),"tbody"===h.name&&"td"===y&&(h=I(h,new i("tr",c)),d.add(h))),h=I(h,new i(y,!!c&&"svg"!==y)),b=G),e`,p),t=u.slice(p,e);t.trim()===se?(v++,f.push(o(h,3,ce(h),"",a[g++]))):I(h,new n(t)),h=h.parent,p=e+s.length+3,v++;continue}}}return p{switch(t){case V:return[n,i,ke];case 8:return j(i)?[n,$e,9]:i instanceof J?[n,(r=e.xml,(e,t)=>{const n=e[Te]??(e[Te]={});n.v!==t&&(n.f=Se(Ce(t,r)),n.v=t),Ae(e,n.f)}),8192]:i instanceof A?[n,We,32776]:[n,Ae,8];case 3:return[n,Le("textContent"),2048];case 2:{const t=e.type===V;switch(s.at(0)){case"@":{const e=j(i);return[n,Re(s.slice(1),Symbol(s),e),e?257:256]}case"?":return[n,_e(s.slice(1)),4096];case".":return"..."===s?[n,t?P:Pe,t?144:128]:[n,je(s.slice(1)),t?80:64];default:return t?[n,je(s),1040]:"aria"===s?[n,Oe,2]:"data"!==s||/^object$/i.test(e.name)?"key"===s?[n,Fe=!0,512]:"ref"===s?[n,Le(Te),16384]:s.startsWith("on")?[n,Le(s.toLowerCase()),64]:[n,De(s),4]:[n,Ee,32]}}}var r}}),et=(e,t=new WeakMap)=>(n,...s)=>{let i=t.get(n);return i||(i=Ze(n,s,e),i.push((()=>{const e=Fe;return Fe=!1,e})()?new Ye:null),i[0]=Ce(i[0].toString(),e),t.set(n,i)),new Ue(i,s)},tt=et(!1),nt=et(!0),st=new WeakMap;function it(e,...t){const n=tt.apply(null,arguments);return Ve()?n.valueOf(!0):n}function rt(e,...t){const n=nt.apply(null,arguments);return Ve()?n.valueOf(!0):n}const ot=(e,t)=>{const n=st.get(e);if(n&&n[0](),"function"==typeof t){let s;Be(!1);const r=function(e){const t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:0};void 0!==f&&i(t,f);const n=g(void 0),s=b(t);try{e()}finally{b(s),g(n)}return D.bind(t)}(()=>{s=t()});if(n&&n[1].t===s.t)n[1].update(s);else{const t=s.valueOf(!1);e.replaceChildren(t)}st.set(e,[r,s])}else Be(!0),st.delete(e),e.replaceChildren(t instanceof Ue?He(t):ge(t,1));return e};function lt(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(r){(e||r!==s||t&&"object"==typeof r&&r)&&(s=r,n?i.call(this,s):i.call(this))}}),dt=()=>{};const ft=(({all:e=!1,shallow:t=!0,useState:n=dt,getAttribute:s=(e,t)=>e.getAttribute(t)}={})=>(i,r,o)=>{const l=((e,t,n,s,i,r)=>{const o={},l=i!==dt,a=[n,s,l];for(let n=ct(e),s=0;s{let n=e[t],r=typeof n;return i.hasOwnProperty(t)?(n=i[t],delete i[t]):i.hasAttribute(t)&&(n=s(i,t),"number"==r?n=+n:"boolean"==r&&(n=!/^(?:false|0|)$/.test(n))),n},e,t,n,o);return at(i,l)})({}),ht=customElements,{define:pt}=ht,{parse:vt,stringify:gt}=JSON,{create:bt,defineProperties:mt,getOwnPropertyDescriptor:yt,keys:xt}=Object,wt="element",St=new WeakMap,kt=(e=>({get:t=>e.get(t),set:(t,n)=>(e.set(t,n),n)}))(new Map([[wt,{c:HTMLElement,e:wt}]])),Ct=e=>document.createElement(e),Tt=e=>kt.get(e)||kt.set(e,{c:Ct(e).constructor,e:e}),Ot=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:i,connected:r,disconnected:o,formAssociated:l,handleEvent:a,init:c,observedAttributes:u,props:d,render:f,style:h}=t,p=new WeakMap,v={},g={},b=[],m=bt(null),y=(e,t,s)=>{if(!p.has(e)){p.set(e,0),mt(e,{html:{configurable:!0,value:$t.bind(n?e.attachShadow(n):e)}});for(let t=0;t{++h;try{return e()}finally{--h||C()}},e.computed=e=>new W(e),e.css=lt,e.define=Ot,e.effect=x,e.fragment=Ce,e.html=it,e.render=ot,e.signal=function(){return M.apply(null,arguments)},e.svg=rt,e.unsafe=e=>new J(e),e.untracked=N,e}({}); diff --git a/package.json b/package.json index c08d2f8..84ce04d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "types": "index.d.ts", "type": "module", "scripts": { - "build": "npm run cjs && npm run rollup:new && npm run rollup:babel && npm run min && npm run test && npm run size", - "cjs": "rm cjs/* && ascjs esm cjs && sed -i 's/esm\\/dom\\.js/dom/' cjs/index.js", + "build": "npm run rollup:new && npm run rollup:babel && npm run min && npm run test && npm run size", "rollup:new": "rollup --config rollup/new.config.js", "rollup:babel": "rollup --config rollup/babel.config.js", "min": "terser index.js -c -m -o min.js", @@ -24,28 +23,28 @@ "author": "Andrea Giammarchi", "license": "ISC", "devDependencies": { - "@babel/core": "^7.21.8", - "@babel/plugin-transform-runtime": "^7.21.4", - "@babel/preset-env": "^7.21.5", - "@babel/runtime": "^7.21.5", - "@rollup/plugin-babel": "^6.0.3", - "@rollup/plugin-node-resolve": "^15.0.2", - "@rollup/plugin-terser": "^0.4.1", + "@babel/core": "^7.23.9", + "@babel/plugin-transform-runtime": "^7.23.9", + "@babel/preset-env": "^7.23.9", + "@babel/runtime": "^7.23.9", + "@rollup/plugin-babel": "^6.0.4", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-terser": "^0.4.4", "@ungap/degap": "^0.2.8", - "ascjs": "^5.0.1", - "c8": "^7.13.0", - "coveralls": "^3.1.1", - "linkedom": "^0.14.26", - "rollup": "^3.21.6", + "ascjs": "^6.0.3", + "c8": "^10.1.3", + "coveralls-next": "^6.0.1", + "linkedom": "^0.18.12", + "rollup": "^4.9.6", "rollup-plugin-includepaths": "^0.2.4", - "terser": "^5.17.3" + "terser": "^5.27.0" }, "module": "esm/index.js", "unpkg": "min.js", "dependencies": { "plain-tag": "^0.1.3", "reactive-props": "^0.2.2", - "uhtml": "^3.1.0", + "uhtml": "^5.0.9", "umap": "^1.0.2" }, "repository": { diff --git a/test/index.js b/test/index.js index c8c1901..f1e58de 100644 --- a/test/index.js +++ b/test/index.js @@ -1,97 +1,104 @@ // require('basichtml').init({}); -const {parseHTML} = require('linkedom'); +import {parseHTML} from 'linkedom'; -const {document, customElements, HTMLElement,} = parseHTML(''); +const {document, customElements, HTMLElement, DocumentFragment} = parseHTML(''); const items = []; globalThis.document = document; globalThis.customElements = customElements; globalThis.HTMLElement = HTMLElement; +globalThis.DocumentFragment = DocumentFragment; + +(async () => { + await import("uhtml"); + const {css, define } = await import('../esm/index.js'); + console.assert(css`1${2}3` === '123', 'css works'); + + define('el-0', {props: {}, attachShadow: {mode: 'open'}}); + define('el-1', {init() {}, style(selector) { return `${selector}{color:green}` }}); + define('el-2', {onClick() {}, ontest() {}, onCamelCase() {}}); + define('el-3', {onClick() {}, onClickOptions: true}); + define('el-4', {props: null, onClick() {}, handleEvent() {}}); + define('el-5', { + props: {test: true}, + attachShadow: {mode: 'open'}, + observedAttributes: ['test'], + attributeChanged() {} + }); + define('el-6', { + observedAttributes: ['test'], + props: {test: true, items}, + bound: ['render'], + constructor() {}, + connected() {}, + disconnected() {}, + render() {} + }); + + define('el-7', {extends: 'div', style(selector) { return `${selector}{color:green}` }}); + define('el-8', {props: {}, formAssociated: true}) + + const El1 = customElements.get('el-1'); + const el1 = new El1(document); + el1.connectedCallback(); + el1.attributeChangedCallback(); + el1.setAttribute('test', 123); + console.assert(el1.props.test == 123, 'props working'); + + const El2 = customElements.get('el-2'); + const el2 = new El2(document); + el2.connectedCallback(); + el2.handleEvent({type: 'click'}); + el2.handleEvent({type: 'test'}); + el2.handleEvent({type: 'camelCase'}); + + const El5 = customElements.get('el-5'); + const el5 = new El5(document); + console.assert(el5.test === true, 'defined props working as getter'); + el5.test = false; + console.assert(el5.test === false, 'defined props working as setter'); + el5.attributeChangedCallback('test'); + + const el5b = new El5(document); + el5b.test = false; + console.assert(el5.test === false, 'defined props working as setter'); + + const El6 = customElements.get('el-6'); + const el6 = new El6(document); + console.assert(el6.test === true, 'defined props working as getter'); + el6.test = false; + console.assert(el6.test === false, 'defined props working as setter'); + el6.connectedCallback(); + + const el7 = document.createElement('div', {is: 'el-7'}); + el7.connectedCallback(); + el7.html``; + + el7.innerHTML = ``; + console.assert(el7.firstChild.test === false, 'props over attributes'); + console.assert(el7.firstChild.items !== items, 'props not shared'); + console.assert(el7.firstChild.items.join('') === '', 'props not shared'); + + const e18 = document.createElement("el-8"); + console.assert(e18.formAssociated === true) + + /* https://github.com/whatwg/html/issues/5552 + ((c,w,m)=>{ + m=c[w];c[w]=n=>m.call(c,n).then(()=>c.get(n)); + })(customElements,'whenDefined'); + //*/ + customElements.whenDefined('uce-lib').then( + ({css, html, svg, render, define: udefine} = customElements.get('uce-lib')) => { + console.assert(css`1${2}3` === '123', 'css works'); + console.assert(udefine === define, 'define is OK'); + console.assert(typeof html === 'function', 'html is OK'); + console.assert(typeof svg === 'function', 'svg is OK'); + console.assert(typeof render === 'function', 'render is OK'); + console.log('OK'); + } + ); +})(); -const uhtml = require('uhtml'); -const {define, css} = require('../cjs'); - -console.assert(css`1${2}3` === '123', 'css works'); - -define('el-0', {props: {}, attachShadow: {mode: 'open'}}); -define('el-1', {init() {}, style(selector) { return `${selector}{color:green}` }}); -define('el-2', {onClick() {}, ontest() {}, onCamelCase() {}}); -define('el-3', {onClick() {}, onClickOptions: true}); -define('el-4', {props: null, onClick() {}, handleEvent() {}}); -define('el-5', { - props: {test: true}, - attachShadow: {mode: 'open'}, - observedAttributes: ['test'], - attributeChanged() {} -}); -define('el-6', { - observedAttributes: ['test'], - props: {test: true, items}, - bound: ['render'], - constructor() {}, - connected() {}, - disconnected() {}, - render() {} -}); - -define('el-7', {extends: 'div', style(selector) { return `${selector}{color:green}` }}); - -const El1 = customElements.get('el-1'); -const el1 = new El1(document); -el1.connectedCallback(); -el1.attributeChangedCallback(); -el1.setAttribute('test', 123); -console.assert(el1.props.test == 123, 'props working'); - -const El2 = customElements.get('el-2'); -const el2 = new El2(document); -el2.connectedCallback(); -el2.handleEvent({type: 'click'}); -el2.handleEvent({type: 'test'}); -el2.handleEvent({type: 'camelCase'}); - -const El5 = customElements.get('el-5'); -const el5 = new El5(document); -console.assert(el5.test === true, 'defined props working as getter'); -el5.test = false; -console.assert(el5.test === false, 'defined props working as setter'); -el5.attributeChangedCallback('test'); - -const el5b = new El5(document); -el5b.test = false; -console.assert(el5.test === false, 'defined props working as setter'); - -const El6 = customElements.get('el-6'); -const el6 = new El6(document); -console.assert(el6.test === true, 'defined props working as getter'); -el6.test = false; -console.assert(el6.test === false, 'defined props working as setter'); -el6.connectedCallback(); - -const el7 = document.createElement('div', {is: 'el-7'}); -el7.connectedCallback(); -el7.html``; - -el7.innerHTML = ``; -console.assert(el7.firstChild.test === false, 'props over attributes'); -console.assert(el7.firstChild.items !== items, 'props not shared'); -console.assert(el7.firstChild.items.join('') === '', 'props not shared'); - -/* https://github.com/whatwg/html/issues/5552 -((c,w,m)=>{ - m=c[w];c[w]=n=>m.call(c,n).then(()=>c.get(n)); -})(customElements,'whenDefined'); -//*/ -customElements.whenDefined('uce-lib').then( - ({css, html, svg, render, define: udefine} = customElements.get('uce-lib')) => { - console.assert(css`1${2}3` === '123', 'css works'); - console.assert(udefine === define, 'define is OK'); - console.assert(typeof html === 'function', 'html is OK'); - console.assert(typeof svg === 'function', 'svg is OK'); - console.assert(typeof render === 'function', 'render is OK'); - console.log('OK'); - } -); diff --git a/test/package.json b/test/package.json index 0292b99..7c34deb 100644 --- a/test/package.json +++ b/test/package.json @@ -1 +1 @@ -{"type":"commonjs"} \ No newline at end of file +{"type":"module"} \ No newline at end of file