web-toolkit-x 0.0.1 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS +3 -0
- package/LICENSE +1 -1
- package/NOTICE +7 -0
- package/README.md +162 -6
- package/dist/release/index.d.ts +650 -0
- package/dist/release/index.d.ts.map +1 -0
- package/dist/release/index.js +2831 -0
- package/dist/release/index.js.map +1 -0
- package/dist/release/toolkit-0.70.0.js +2834 -0
- package/dist/release/toolkit-0.70.0.js.map +1 -0
- package/package.json +71 -18
- package/src/core/bragi.ts +122 -0
- package/src/core/browser.ts +538 -0
- package/src/core/child-nodes.ts +77 -0
- package/src/core/comment.ts +24 -0
- package/src/core/component.ts +190 -0
- package/src/core/created-roots.ts +38 -0
- package/src/core/custom-element.ts +191 -0
- package/src/core/description.ts +241 -0
- package/src/core/diff.ts +590 -0
- package/src/core/dispatcher.ts +221 -0
- package/src/core/dom.ts +124 -0
- package/src/core/draft.ts +609 -0
- package/src/core/lifecycle.ts +301 -0
- package/src/core/nodes.ts +13 -0
- package/src/core/patch.ts +412 -0
- package/src/core/plugins.ts +231 -0
- package/src/core/reconciler.ts +185 -0
- package/src/core/renderer.ts +75 -0
- package/src/core/runtime.ts +36 -0
- package/src/core/sandbox.ts +128 -0
- package/src/core/service.ts +39 -0
- package/src/core/template.ts +472 -0
- package/src/core/text.ts +24 -0
- package/src/core/toolkit.ts +220 -0
- package/src/core/utils.ts +148 -0
- package/src/core/virtual-dom.ts +118 -0
- package/src/core/virtual-element.ts +72 -0
- package/src/core/virtual-node.ts +87 -0
- package/src/core/web-component.ts +285 -0
- package/src/globals.d.ts +10 -0
- package/src/index.ts +62 -0
- package/src/plugins/logger.ts +38 -0
- package/src/release.ts +3 -0
- package/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["unsupported"],"sources":["../../src/core/virtual-node.ts","../../src/core/comment.ts","../../src/core/description.ts","../../src/core/utils.ts","../../src/core/runtime.ts","../../src/core/sandbox.ts","../../src/core/browser.ts","../../src/core/template.ts","../../src/core/component.ts","../../src/core/text.ts","../../src/core/child-nodes.ts","../../src/core/dom.ts","../../src/core/virtual-element.ts","../../src/core/created-roots.ts","../../src/core/patch.ts","../../src/core/lifecycle.ts","../../src/core/plugins.ts","../../src/core/custom-element.ts","../../src/core/draft.ts","../../src/core/dispatcher.ts","../../src/core/web-component.ts","../../src/core/service.ts","../../src/core/reconciler.ts","../../src/core/virtual-dom.ts","../../src/core/diff.ts","../../src/core/renderer.ts","../../src/core/toolkit.ts","../../src/index.ts"],"sourcesContent":["import type Comment from './comment.js'\nimport type Component from './component.js'\nimport type { NodeDescription } from './description.js'\nimport type Text from './text.js'\nimport type VirtualElement from './virtual-element.js'\nimport type WebComponent from './web-component.js'\n\n/* The DOM node rendered for a virtual node. */\nexport type NodeRef = Element | CharacterData\n\n/*\n * An abstract parent node.\n */\nabstract class VirtualNode {\n declare description: NodeDescription\n declare key?: string\n declare parentNode: VirtualNode | null\n declare context: WebComponent | null\n\n abstract ref: NodeRef\n abstract get nodeType(): string\n abstract attachDOM(): void\n\n constructor(\n description: NodeDescription,\n parentNode: VirtualNode | null = null,\n context: WebComponent | null = null,\n ) {\n this.description = description\n this.key = description.key\n this.parentNode = parentNode\n this.context = context\n }\n\n get parentElement(): VirtualNode | null {\n if (this.parentNode) {\n return this.parentNode.isElement()\n ? this.parentNode\n : this.parentNode.parentElement\n }\n return null\n }\n\n get container(): Element | VirtualNode | undefined {\n if (this.parentNode) {\n return this.parentNode.container\n }\n return this\n }\n\n get rootNode(): WebComponent {\n if (this.isRoot()) {\n return this\n }\n if (this.parentNode) {\n return this.parentNode.rootNode\n }\n throw new Error('Inconsistent virtual DOM tree detected!')\n }\n\n isRoot(): this is WebComponent {\n return this.nodeType === 'root'\n }\n\n isComponent(): this is Component {\n const { nodeType } = this\n return nodeType === 'component' || nodeType === 'root'\n }\n\n isElement(): this is VirtualElement {\n return this.nodeType === 'element'\n }\n\n isComment(): this is Comment {\n return this.nodeType === 'comment'\n }\n\n isText(): this is Text {\n return this.nodeType === 'text'\n }\n\n isCompatible(node: VirtualNode | null | undefined) {\n return node && this.nodeType === node.nodeType && this.key === node.key\n }\n}\n\nexport default VirtualNode\n","import type { CommentDescription } from './description.js'\nimport VirtualNode from './virtual-node.js'\n\nclass Comment extends VirtualNode {\n static NodeType = 'comment'\n\n declare description: CommentDescription\n declare ref: globalThis.Comment\n\n constructor(description: CommentDescription, parentNode?: VirtualNode) {\n super(description, parentNode)\n this.attachDOM()\n }\n\n get nodeType(): string {\n return Comment.NodeType\n }\n\n attachDOM() {\n this.ref = document.createComment(` ${this.description.text} `)\n }\n}\n\nexport default Comment\n","import type { ComponentClass } from './nodes.js'\n\nexport type Props = Record<string, unknown>\n\n/* An event listener, possibly bound to a component by its sandbox. */\nexport type Listener = ((event: Event) => unknown) & { source?: unknown }\n\nexport type NodeDescription =\n | ComponentDescription\n | ElementDescription\n | CommentDescription\n | TextDescription\n\n/* A normalized template, as returned by the asTemplate getters. */\nexport type NormalizedTemplate = unknown[] | string | null\n\n/*\n * Normalized description of a template.\n * Is used to calculate differences between nodes.\n */\nabstract class Description {\n declare static ElementDescription: typeof ElementDescription\n declare static ComponentDescription: typeof ComponentDescription\n declare static CommentDescription: typeof CommentDescription\n declare static TextDescription: typeof TextDescription\n\n declare key?: string\n declare children?: NodeDescription[]\n\n abstract get asTemplate(): NormalizedTemplate\n\n get childrenAsTemplates(): NormalizedTemplate[] | undefined {\n if (this.children) {\n return this.children.map(child => child.asTemplate)\n }\n return undefined\n }\n\n isCompatible(description: Description): boolean {\n return this.constructor === description.constructor\n }\n}\n\n/*\n * Defines a normalized description of a component.\n *\n * Enumerable properties:\n * - key (a unique node identifier within its parent),\n * - component (an object with meta information)\n * - children (an array of child nodes)\n * - props (an object of any component rendering props)\n *\n * Non-enumerable properties:\n * - asTemplate: returns component description as a normalized template\n */\nclass ComponentDescription extends Description {\n declare component: ComponentClass\n declare type: 'component'\n declare props?: Props\n declare attrs?: Record<string, string>\n\n constructor(component: ComponentClass) {\n super()\n this.component = component\n this.type = 'component'\n }\n\n isCompatible(description: Description): boolean {\n return (\n super.isCompatible(description) &&\n this.component === (description as ComponentDescription).component\n )\n }\n\n get isRoot(): boolean {\n // the node type is inherited from the Root class\n return this.component.NodeType === 'root'\n }\n\n get asTemplate(): unknown[] {\n const template: unknown[] = [this.component]\n if (this.props) {\n template.push(this.props)\n }\n if (this.children) {\n template.push(...this.children.map(child => child.asTemplate))\n }\n return template\n }\n}\n\n/*\n * Defines a normalized description of an element.\n *\n * Enumerable properties:\n * - key (a unique node identifier within its parent),\n * - name (a string representing tag name),\n * - children (an array of child nodes),\n * - props (an object) defining:\n * - class (a class name string)\n * - style (an object for style property to string value mapping)\n * - listeners (an object for event name to listener mapping)\n * - attrs (an object for normalized attribute name to value mapping)\n * - dataset (an object representing data attributes)\n * - properties (an object for properties set directly on DOM element)\n *\n * Non-enumerable properties:\n * - asTemplate: returns element description as a normalized template\n */\nclass ElementDescription extends Description {\n declare name: string\n declare type: 'element'\n declare class?: string\n declare style?: Record<string, string>\n declare attrs?: Record<string, string>\n declare dataset?: Record<string, string>\n declare listeners?: Record<string, Listener>\n declare properties?: Record<string, unknown>\n declare custom?: {\n attrs?: Record<string, string>\n listeners?: Record<string, Listener>\n }\n\n constructor(name: string) {\n super()\n this.name = name\n this.type = 'element'\n }\n\n isCompatible(description: Description): boolean {\n return (\n super.isCompatible(description) &&\n this.name === (description as ElementDescription).name\n )\n }\n\n get asTemplate(): unknown[] {\n const template: unknown[] = [this.name]\n const props: Record<string, unknown> = {}\n if (this.key) {\n props.key = this.key\n }\n if (this.class) {\n props.class = this.class\n }\n if (this.style) {\n props.style = this.style\n }\n if (this.attrs) {\n Object.assign(props, this.attrs)\n }\n if (this.dataset) {\n props.dataset = this.dataset\n }\n if (this.listeners) {\n Object.assign(props, this.listeners)\n }\n if (this.properties) {\n props.properties = this.properties\n }\n if (this.custom?.attrs) {\n props.attrs = this.custom.attrs\n }\n if (this.custom?.listeners) {\n props.on = this.custom.listeners\n }\n if (Object.keys(props).length) {\n template.push(props)\n }\n if (this.children) {\n template.push(...this.children.map(child => child.asTemplate))\n }\n return template\n }\n}\n\n/*\n * Description of a Comment node.\n */\nclass CommentDescription extends Description {\n declare text: string\n declare type: 'comment'\n\n constructor(text: string) {\n super()\n this.text = text\n this.type = 'comment'\n }\n\n get asTemplate(): null {\n return null\n }\n\n isCompatible(description: Description): boolean {\n return (\n super.isCompatible(description) &&\n this.text === (description as CommentDescription).text\n )\n }\n}\n\n/*\n * Description of a Text node.\n */\nclass TextDescription extends Description {\n declare text: string\n declare type: 'text'\n\n constructor(text: string) {\n super()\n this.text = text\n this.type = 'text'\n }\n\n get asTemplate(): string {\n return this.text\n }\n\n isCompatible(description: Description): boolean {\n return (\n super.isCompatible(description) &&\n this.text === (description as TextDescription).text\n )\n }\n}\n\nObject.assign(Description, {\n ElementDescription,\n ComponentDescription,\n CommentDescription,\n TextDescription,\n})\n\nexport {\n ElementDescription,\n ComponentDescription,\n CommentDescription,\n TextDescription,\n}\n\nexport default Description\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => unknown\n\n/*\n * Checks a condition the toolkit relies on internally. Unlike\n * toolkit.assert, which reports invalid usage, it throws in all modes.\n */\nexport function invariant(\n condition: unknown,\n message: string,\n): asserts condition {\n if (!condition) {\n throw new Error(message)\n }\n}\n\nconst throttle = <T extends AnyFunction>(\n fn: T,\n wait = 200,\n delayFirstEvent = false,\n) => {\n let lastTimestamp = 0\n let taskId: ReturnType<typeof setTimeout> | null = null\n\n let context: unknown\n let params: Parameters<T>\n\n return function throttled(this: unknown, ...args: Parameters<T>) {\n if (!taskId) {\n const timestamp = Date.now()\n const elapsed = timestamp - lastTimestamp\n const scheduleTask = (delay: number) => {\n taskId = setTimeout(() => {\n taskId = null\n lastTimestamp = Date.now()\n return fn.call(context, ...params)\n }, delay)\n }\n if (elapsed >= wait) {\n lastTimestamp = timestamp\n if (!delayFirstEvent) {\n return fn.call(this, ...args)\n }\n scheduleTask(wait)\n } else {\n scheduleTask(wait - elapsed)\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias -- kept for the delayed call\n context = this\n params = args\n }\n}\n\nconst debounce = <T extends AnyFunction>(\n fn: T,\n wait = 200,\n leading = false,\n) => {\n let taskId: ReturnType<typeof setTimeout> | null = null\n // whether the delayed call is needed, not when only the leading call was made\n let isTrailing = false\n\n let context: unknown\n let params: Parameters<T>\n\n return function debounced(this: unknown, ...args: Parameters<T>) {\n const isFirstInvocation = !taskId\n if (taskId) {\n clearTimeout(taskId)\n }\n isTrailing = !(isFirstInvocation && leading)\n taskId = setTimeout(() => {\n taskId = null\n if (isTrailing) {\n fn.call(context, ...params)\n }\n }, wait)\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias -- kept for the delayed call\n context = this\n params = args\n\n if (!isTrailing) {\n return fn.call(context, ...params)\n }\n }\n}\n\nconst createUUID = () => {\n const s4 = () =>\n Math.floor((1 + Math.random()) * 0x10000)\n .toString(16)\n .substring(1)\n return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`\n}\n\nexport const lowerDash = (name: string) =>\n name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()\n\nexport const getAttributeName = (key: string) => {\n if (key === 'acceptCharset' || key === 'httpEquiv') {\n return lowerDash(key)\n } else if (key.startsWith('aria')) {\n return `aria-${key.slice(4).toLowerCase()}`\n }\n return key.toLowerCase()\n}\n\nexport const getEventName = (key: string) =>\n key === 'onDoubleClick' ? 'dblclick' : key.slice(2).toLowerCase()\n\nconst postRender = (fn: FrameRequestCallback) => {\n // since Chromium 64 there are some problems with animations not being\n // triggered correctly, this hack solves the problem across all OS-es\n\n /* eslint-disable prefer-arrow-callback */\n requestAnimationFrame(function () {\n requestAnimationFrame(fn)\n })\n /* eslint-enable prefer-arrow-callback */\n}\n\n/* Checks if the arrays have the same items, in the same order. */\nexport const isSameList = (a: readonly unknown[], b: readonly unknown[]) =>\n a.length === b.length && a.every((item, index) => item === b[index])\n\nexport const deepFreeze = <T>(obj: T): T => {\n if (obj === null || typeof obj !== 'object' || Object.isFrozen(obj)) {\n // functions are intentionally not frozen\n return obj\n }\n Object.freeze(obj)\n for (const property of Object.getOwnPropertyNames(obj)) {\n deepFreeze((obj as Record<string, unknown>)[property])\n }\n return obj\n}\n\n/* The helpers of the public API, the others are used internally. */\nconst Utils = {\n throttle,\n debounce,\n createUUID,\n postRender,\n}\n\nexport default Utils\n","import type { Command, State } from './dispatcher.js'\nimport type { ComponentClass, WebComponent } from './nodes.js'\nimport type Plugins from './plugins.js'\nimport type { ItemType } from './template.js'\nimport { invariant } from './utils.js'\n\n/*\n * The services of the Toolkit instance the core modules rely on,\n * provided by the instance, so that the modules do not import it.\n */\nexport interface Runtime {\n readonly plugins: Plugins\n assert(condition: unknown, message?: string): void\n isDebug(): boolean\n warn(...messages: unknown[]): void\n track(root: WebComponent): void\n resolveComponentClass(component: unknown, type: ItemType): ComponentClass\n /* Renders the state of the root, see Renderer.update(). */\n update(\n root: WebComponent,\n from: State | undefined,\n to: State,\n commands: Command[],\n ): void\n}\n\nlet provided: Runtime | null = null\n\nexport const provideRuntime = (runtime: Runtime) => {\n provided = runtime\n}\n\nexport const runtime = (): Runtime => {\n invariant(provided, 'No Toolkit runtime provided!')\n return provided\n}\n","import type { Props } from './description.js'\nimport type { Component, WebComponent } from './nodes.js'\nimport type { AnyFunction } from './utils.js'\n\n/*\n * The component proxy passed as `this` to render and lifecycle methods,\n * exposing props and children and binding the component methods.\n */\nexport type ComponentSandbox = Omit<Component, 'children'> & {\n props: Props\n children: unknown[]\n}\n\ntype BoundListener = AnyFunction & { source?: unknown; component?: Component }\n\n/* Reads a property as `target[property]` does. */\nconst get = (target: object, property: PropertyKey): unknown =>\n Reflect.get(target, property)\n\nconst isFunction = (target: object, property: PropertyKey) =>\n typeof get(target, property) === 'function'\n\nconst delegated: PropertyKey[] = [\n 'commands',\n 'constructor',\n 'container',\n 'elementName',\n]\nconst methods: PropertyKey[] = ['connectTo']\n/* Registered again with each root the plugins are inherited by. */\nconst pluginMethods = new Set<PropertyKey>()\n\nconst createBoundListener = (\n listener: AnyFunction,\n component: Component,\n context: unknown,\n) => {\n const boundListener: BoundListener = listener.bind(context)\n boundListener.source = listener\n boundListener.component = component\n return boundListener\n}\n\nclass Sandbox {\n static registerPluginMethod(name: string) {\n pluginMethods.add(name)\n }\n\n static clearPluginMethods() {\n pluginMethods.clear()\n }\n\n /**\n * Creates the sandbox of a component, hiding the given properties\n * of the Component class from the component methods.\n */\n static create(\n component: Component,\n hidden: readonly PropertyKey[],\n ): ComponentSandbox {\n const state: { props?: Props; children?: unknown[] } = {}\n const autobound: Record<PropertyKey, BoundListener> = {}\n return new Proxy(component, {\n get: (target, property, receiver) => {\n if (property === 'props') {\n return state.props || (target as WebComponent).state || {}\n }\n if (property === 'children') {\n return state.children || []\n }\n if (property === 'host') {\n return target.isRoot() ? target.shadow!.host : null\n }\n if (property === 'ref') {\n if (target.isRoot()) {\n // returns rendered node instead of custom element for usage of\n // this.ref.querySelector\n return target.content!.ref\n }\n return target.ref\n }\n if (property === '$component') {\n return component\n }\n if (delegated.includes(property)) {\n return get(target, property)\n }\n if (methods.includes(property) && isFunction(target, property)) {\n return createBoundListener(\n get(target, property) as AnyFunction,\n target,\n target,\n )\n }\n if (pluginMethods.has(property)) {\n return get(target.rootNode, property)\n }\n if (hidden.includes(property)) {\n return undefined\n }\n if (isFunction(autobound, property)) {\n return autobound[property]\n }\n if (isFunction(target, property)) {\n return (autobound[property] = createBoundListener(\n get(target, property) as AnyFunction,\n target,\n receiver,\n ))\n }\n return get(target, property)\n },\n set: (target, property, value) => {\n if (property === 'props') {\n state.props = value as Props\n return true\n }\n if (property === 'children') {\n state.children = (value as unknown[]) || []\n return true\n }\n return false\n },\n }) as ComponentSandbox\n }\n}\n\nexport default Sandbox\n","import { getEventName } from './utils.js'\n\n/*\n * Names of the event listeners supported in templates, in camel case, e.g.\n * onPointerDown, generated from the events of Chromium 153, with the alias\n * onDoubleClick of onDblClick. Only a type, as the events are checked\n * against the browser in debug mode.\n */\nexport type EventName =\n | 'onAbort'\n | 'onAfterPrint'\n | 'onAnimationCancel'\n | 'onAnimationEnd'\n | 'onAnimationIteration'\n | 'onAnimationStart'\n | 'onAppInstalled'\n | 'onAuxClick'\n | 'onBeforeCopy'\n | 'onBeforeCut'\n | 'onBeforeInput'\n | 'onBeforeInstallPrompt'\n | 'onBeforeMatch'\n | 'onBeforePaste'\n | 'onBeforePrint'\n | 'onBeforeToggle'\n | 'onBeforeUnload'\n | 'onBeforeXRSelect'\n | 'onBlur'\n | 'onCancel'\n | 'onCanPlay'\n | 'onCanPlayThrough'\n | 'onChange'\n | 'onClick'\n | 'onClose'\n | 'onCommand'\n | 'onCompositionEnd'\n | 'onCompositionStart'\n | 'onCompositionUpdate'\n | 'onContentVisibilityAutoStateChange'\n | 'onContextLost'\n | 'onContextMenu'\n | 'onContextRestored'\n | 'onCopy'\n | 'onCueChange'\n | 'onCut'\n | 'onDblClick'\n | 'onDeviceMotion'\n | 'onDeviceOrientation'\n | 'onDeviceOrientationAbsolute'\n | 'onDoubleClick'\n | 'onDrag'\n | 'onDragEnd'\n | 'onDragEnter'\n | 'onDragLeave'\n | 'onDragOver'\n | 'onDragStart'\n | 'onDrop'\n | 'onDurationChange'\n | 'onEmptied'\n | 'onEncrypted'\n | 'onEnded'\n | 'onEnterPictureInPicture'\n | 'onError'\n | 'onFocus'\n | 'onFormData'\n | 'onFreeze'\n | 'onFullscreenChange'\n | 'onFullscreenError'\n | 'onGamepadConnected'\n | 'onGamepadDisconnected'\n | 'onGotPointerCapture'\n | 'onHashChange'\n | 'onInput'\n | 'onInvalid'\n | 'onKeyDown'\n | 'onKeyPress'\n | 'onKeyUp'\n | 'onLanguageChange'\n | 'onLeavePictureInPicture'\n | 'onLoad'\n | 'onLoadedData'\n | 'onLoadedMetadata'\n | 'onLoadStart'\n | 'onLostPointerCapture'\n | 'onMessage'\n | 'onMessageError'\n | 'onMouseDown'\n | 'onMouseEnter'\n | 'onMouseLeave'\n | 'onMouseMove'\n | 'onMouseOut'\n | 'onMouseOver'\n | 'onMouseUp'\n | 'onMouseWheel'\n | 'onOffline'\n | 'onOnline'\n | 'onPageHide'\n | 'onPageReveal'\n | 'onPageShow'\n | 'onPageSwap'\n | 'onPaste'\n | 'onPause'\n | 'onPlay'\n | 'onPlaying'\n | 'onPointerCancel'\n | 'onPointerDown'\n | 'onPointerEnter'\n | 'onPointerLeave'\n | 'onPointerLockChange'\n | 'onPointerLockError'\n | 'onPointerMove'\n | 'onPointerOut'\n | 'onPointerOver'\n | 'onPointerRawUpdate'\n | 'onPointerUp'\n | 'onPopState'\n | 'onPrerenderingChange'\n | 'onProgress'\n | 'onRateChange'\n | 'onReadyStateChange'\n | 'onRejectionHandled'\n | 'onReset'\n | 'onResize'\n | 'onResume'\n | 'onScroll'\n | 'onScrollEnd'\n | 'onScrollSnapChange'\n | 'onScrollSnapChanging'\n | 'onSearch'\n | 'onSecurityPolicyViolation'\n | 'onSeeked'\n | 'onSeeking'\n | 'onSelect'\n | 'onSelectionChange'\n | 'onSelectStart'\n | 'onSlotChange'\n | 'onStalled'\n | 'onStorage'\n | 'onSubmit'\n | 'onSuspend'\n | 'onTimeUpdate'\n | 'onToggle'\n | 'onTouchCancel'\n | 'onTouchEnd'\n | 'onTouchMove'\n | 'onTouchStart'\n | 'onTransitionCancel'\n | 'onTransitionEnd'\n | 'onTransitionRun'\n | 'onTransitionStart'\n | 'onUnhandledRejection'\n | 'onUnload'\n | 'onVisibilityChange'\n | 'onVolumeChange'\n | 'onWaiting'\n | 'onWaitingForKey'\n | 'onWebkitAnimationEnd'\n | 'onWebkitAnimationIteration'\n | 'onWebkitAnimationStart'\n | 'onWebkitFullscreenChange'\n | 'onWebkitFullscreenError'\n | 'onWebkitTransitionEnd'\n | 'onWheel'\n\n/*\n * Names of the element attributes supported in templates, in camel case,\n * e.g. tabIndex, generated from the attributes of Chromium 153, with the\n * names supported before, e.g. allowFullScreen. Only a type, as the\n * attributes are checked against the browser in debug mode.\n */\nexport type AttributeName =\n | 'abbr'\n | 'accept'\n | 'acceptCharset'\n | 'accessKey'\n | 'action'\n | 'adAuctionHeaders'\n | 'align'\n | 'aLink'\n | 'allow'\n | 'allowFullscreen'\n | 'allowFullScreen'\n | 'allowPaymentRequest'\n | 'alt'\n | 'archive'\n | 'ariaActions'\n | 'ariaActiveDescendant'\n | 'ariaAtomic'\n | 'ariaAutoComplete'\n | 'ariaBrailleLabel'\n | 'ariaBrailleRoleDescription'\n | 'ariaBusy'\n | 'ariaChecked'\n | 'ariaColCount'\n | 'ariaColIndex'\n | 'ariaColIndexText'\n | 'ariaColSpan'\n | 'ariaControls'\n | 'ariaCurrent'\n | 'ariaDescribedBy'\n | 'ariaDescription'\n | 'ariaDetails'\n | 'ariaDisabled'\n | 'ariaErrorMessage'\n | 'ariaExpanded'\n | 'ariaFlowTo'\n | 'ariaHasPopup'\n | 'ariaHidden'\n | 'ariaInvalid'\n | 'ariaKeyShortcuts'\n | 'ariaLabel'\n | 'ariaLabelledBy'\n | 'ariaLabelLedBy'\n | 'ariaLevel'\n | 'ariaLive'\n | 'ariaModal'\n | 'ariaMultiLine'\n | 'ariaMultiSelectable'\n | 'ariaOrientation'\n | 'ariaOwns'\n | 'ariaPlaceholder'\n | 'ariaPosInSet'\n | 'ariaPressed'\n | 'ariaReadOnly'\n | 'ariaRelevant'\n | 'ariaRequired'\n | 'ariaRoleDescription'\n | 'ariaRowCount'\n | 'ariaRowIndex'\n | 'ariaRowIndexText'\n | 'ariaRowSpan'\n | 'ariaSelected'\n | 'ariaSetSize'\n | 'ariaSort'\n | 'ariaValueMax'\n | 'ariaValueMin'\n | 'ariaValueNow'\n | 'ariaValueText'\n | 'as'\n | 'async'\n | 'attributionSrc'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'autoFocus'\n | 'autoPlay'\n | 'axis'\n | 'background'\n | 'bgColor'\n | 'blocking'\n | 'border'\n | 'browsingTopics'\n | 'cellPadding'\n | 'cellSpacing'\n | 'charset'\n | 'checked'\n | 'cite'\n | 'clear'\n | 'closedBy'\n | 'code'\n | 'codeBase'\n | 'codeType'\n | 'color'\n | 'cols'\n | 'colSpan'\n | 'command'\n | 'commandFor'\n | 'compact'\n | 'content'\n | 'contentEditable'\n | 'controls'\n | 'coords'\n | 'credentialless'\n | 'crossOrigin'\n | 'csp'\n | 'data'\n | 'dateTime'\n | 'declare'\n | 'decoding'\n | 'default'\n | 'defer'\n | 'dir'\n | 'dirName'\n | 'disabled'\n | 'disablePictureInPicture'\n | 'disableRemotePlayback'\n | 'download'\n | 'draggable'\n | 'elementTiming'\n | 'encoding'\n | 'encType'\n | 'enterKeyHint'\n | 'event'\n | 'fetchPriority'\n | 'focusGroupStart'\n | 'for'\n | 'form'\n | 'formAction'\n | 'formEnctype'\n | 'formMethod'\n | 'formNoValidate'\n | 'formTarget'\n | 'frame'\n | 'frameBorder'\n | 'headers'\n | 'height'\n | 'hidden'\n | 'high'\n | 'href'\n | 'hrefLang'\n | 'hspace'\n | 'httpEquiv'\n | 'id'\n | 'imageSizes'\n | 'imageSrcset'\n | 'incremental'\n | 'inert'\n | 'inputMode'\n | 'integrity'\n | 'interestFor'\n | 'is'\n | 'isMap'\n | 'itemProp'\n | 'kind'\n | 'label'\n | 'lang'\n | 'link'\n | 'list'\n | 'loading'\n | 'longDesc'\n | 'loop'\n | 'low'\n | 'lowSrc'\n | 'marginHeight'\n | 'marginWidth'\n | 'max'\n | 'maxLength'\n | 'media'\n | 'method'\n | 'min'\n | 'minLength'\n | 'multiple'\n | 'muted'\n | 'name'\n | 'noHref'\n | 'noModule'\n | 'nonce'\n | 'noShade'\n | 'noValidate'\n | 'noWrap'\n | 'open'\n | 'optimum'\n | 'part'\n | 'pattern'\n | 'ping'\n | 'placeholder'\n | 'playsInline'\n | 'popover'\n | 'popoverTarget'\n | 'popoverTargetAction'\n | 'poster'\n | 'preload'\n | 'privateToken'\n | 'readOnly'\n | 'referrerPolicy'\n | 'rel'\n | 'required'\n | 'rev'\n | 'reversed'\n | 'role'\n | 'rows'\n | 'rowSpan'\n | 'rules'\n | 'sandbox'\n | 'scheme'\n | 'scope'\n | 'scrolling'\n | 'selected'\n | 'shadowRootClonable'\n | 'shadowRootCustomElementRegistry'\n | 'shadowRootDelegatesFocus'\n | 'shadowRootMode'\n | 'shadowRootReferenceTarget'\n | 'shadowRootSerializable'\n | 'shadowRootSlotAssignment'\n | 'shape'\n | 'size'\n | 'sizes'\n | 'slot'\n | 'span'\n | 'spellCheck'\n | 'src'\n | 'srcDoc'\n | 'srcLang'\n | 'srcSet'\n | 'standby'\n | 'start'\n | 'step'\n | 'summary'\n | 'tabIndex'\n | 'target'\n | 'title'\n | 'translate'\n | 'type'\n | 'useMap'\n | 'vAlign'\n | 'value'\n | 'version'\n | 'virtualKeyboardPolicy'\n | 'vLink'\n | 'vspace'\n | 'webkitDirectory'\n | 'width'\n | 'wrap'\n | 'writingSuggestions'\n\n/* Attributes set by other names than those of the element properties. */\nconst ATTRIBUTE_PROPERTIES: Record<string, string> = { for: 'htmlFor' }\n\n/* Attributes valid on all elements, not reflected as element properties. */\nconst UNREFLECTED_ATTRIBUTES = new Set(['ariaOwns', 'is', 'itemProp'])\n\n/* The lower-cased property names of the elements, read when first needed. */\nconst elementProperties = new Map<string, Set<string>>()\n\nconst getElementProperties = (tagName: string) => {\n let properties = elementProperties.get(tagName)\n if (!properties) {\n properties = new Set()\n // the attributes are reflected as properties, in the prototype chain\n for (const name in document.createElement(tagName)) {\n properties.add(name.toLowerCase())\n }\n elementProperties.set(tagName, properties)\n }\n return properties\n}\n\n/*\n * Events without handler properties, e.g. oncompositionend, or with them\n * only on touch devices, e.g. ontouchstart.\n */\nconst EVENTS_WITHOUT_HANDLERS = new Set([\n 'compositionstart',\n 'compositionupdate',\n 'compositionend',\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'touchcancel',\n])\n\n/* The style properties of the browser, read when first needed. */\nlet supportedStyles: Set<string> | null = null\nconst getSupportedStyles = () =>\n (supportedStyles ??= new Set(Object.keys(document.documentElement.style)))\n\nconst Browser = {\n /**\n * Checks if the browser supports the attribute on the element, as\n * a property of the element in any letter case, e.g. tabIndex. Meant\n * for debug mode, as the check creates an element of each tag name.\n */\n isAttributeSupported(this: void, key: string, tagName: string): boolean {\n if (UNREFLECTED_ATTRIBUTES.has(key)) {\n return true\n }\n const properties = getElementProperties(tagName)\n const name = (ATTRIBUTE_PROPERTIES[key] ?? key).toLowerCase()\n // the ARIA relations are reflected as the related elements\n return (\n properties.has(name) ||\n properties.has(`${name}element`) ||\n properties.has(`${name}elements`)\n )\n },\n\n /**\n * Checks if the browser supports the event of the listener, e.g. onClick,\n * on the element, as its handler property, e.g. onclick. Meant for debug\n * mode, as the check creates an element of each tag name.\n */\n isEventSupported(this: void, key: string, tagName: string): boolean {\n const event = getEventName(key)\n return (\n EVENTS_WITHOUT_HANDLERS.has(event) ||\n getElementProperties(tagName).has(`on${event}`)\n )\n },\n\n isStyleSupported(this: void, key: string): boolean {\n return key.startsWith('--') || getSupportedStyles().has(key)\n },\n}\n\n/*\n * The filter functions of Chromium 153, in camel case, e.g. dropShadow for\n * drop-shadow in CSS. Only a type, as the functions are checked against\n * the browser in debug mode.\n */\nexport type FilterName =\n | 'blur'\n | 'brightness'\n | 'contrast'\n | 'dropShadow'\n | 'grayscale'\n | 'hueRotate'\n | 'invert'\n | 'opacity'\n | 'saturate'\n | 'sepia'\n | 'url'\n\n/* The transform functions of Chromium 153, as named in CSS, e.g. translateX. */\nexport type TransformName =\n | 'matrix'\n | 'matrix3d'\n | 'translate'\n | 'translate3d'\n | 'translateX'\n | 'translateY'\n | 'translateZ'\n | 'scale'\n | 'scale3d'\n | 'scaleX'\n | 'scaleY'\n | 'scaleZ'\n | 'rotate'\n | 'rotate3d'\n | 'rotateX'\n | 'rotateY'\n | 'rotateZ'\n | 'skew'\n | 'skewX'\n | 'skewY'\n | 'perspective'\n\nexport default Browser\n","import type { Template as BragiTemplate } from './bragi.js'\nimport Browser from './browser.js'\nimport {\n ComponentDescription,\n ElementDescription,\n type Listener,\n type NodeDescription,\n type Props,\n TextDescription,\n} from './description.js'\nimport type { ComponentClass } from './nodes.js'\nimport { runtime } from './runtime.js'\nimport { deepFreeze, lowerDash } from './utils.js'\n\nexport type ItemType =\n | 'component'\n | 'function'\n | 'null'\n | 'node'\n | 'props'\n | 'unknown'\n | 'string'\n | 'number'\n | 'bigint'\n | 'boolean'\n | 'symbol'\n | 'undefined'\n\nconst isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== undefined && value !== null\nconst isFalsy = (template: unknown) => template === null || template === false\nconst isNotEmpty = (object: object) => Boolean(Object.keys(object).length)\n\nconst Template = {\n /**\n * Creates a normalized Description of given template.\n */\n describe(template: unknown): NodeDescription | null {\n if (isFalsy(template)) {\n return null\n }\n\n if (Array.isArray(template) && template.length) {\n let description!: ComponentDescription | ElementDescription\n for (const [item, type, index] of (template as unknown[]).map(\n (item, index): [unknown, ItemType, number] => [\n item,\n this.getItemType(item),\n index,\n ],\n )) {\n if (index === 0) {\n switch (type) {\n case 'string':\n description = new ElementDescription(item as string)\n break\n case 'component':\n case 'function':\n description = new ComponentDescription(\n runtime().resolveComponentClass(item, type),\n )\n break\n default:\n console.error(\n 'Invalid node type:',\n item,\n `(${type}) at index: ${index}, template:`,\n template,\n )\n throw new Error(`Invalid node type specified: ${type}`)\n }\n continue\n }\n if (index === 1 && type === 'props') {\n if (description.type === 'component') {\n this.assignPropsToComponent(item as Props, description)\n } else if (description.type === 'element') {\n this.assignPropsToElement(item as Props, description)\n }\n continue\n }\n if (isFalsy(item)) {\n continue\n }\n if (type === 'string' || type === 'number' || item === true) {\n description.children = description.children || []\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- only strings, numbers and true\n description.children.push(new TextDescription(String(item)))\n continue\n } else if (type === 'node') {\n description.children = description.children || []\n description.children.push(this.describe(item)!)\n } else {\n console.error(\n 'Invalid item',\n item,\n `at index: ${index}, template:`,\n template,\n )\n throw new Error(`Invalid item specified: ${type}`)\n }\n }\n\n if (runtime().isDebug()) {\n deepFreeze(description)\n }\n return description\n }\n\n console.error('Invalid template definition:', template)\n throw new Error('Expecting array, null or false')\n },\n\n /**\n * Returns a new props object supplemented by overridden values.\n */\n normalizeProps(...overrides: Array<Props | undefined>): Props {\n const result: Props = {}\n for (const override of overrides) {\n for (const [key, value] of Object.entries(override || {})) {\n if (result[key] === undefined && value !== undefined) {\n result[key] = value\n }\n }\n }\n return result\n },\n\n /**\n * Normalizes specified element props object and returns either\n * a non-empty object containing only supported props or null.\n */\n normalizeComponentProps(\n props: Props | undefined,\n ComponentClass: { defaultProps?: Props },\n ): Props {\n return this.normalizeProps(props, ComponentClass.defaultProps || {})\n },\n\n assignPropsToComponent(object: Props, description: ComponentDescription) {\n const props = this.getComponentProps(\n object,\n description.component,\n description.isRoot,\n )\n if (props) {\n description.props = props\n if (isDefined(props.key)) {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- keys are stringified as given\n description.key = String(props.key)\n }\n if (props.attrs) {\n const attrs = this.getCustomAttributes(props.attrs as Props, true)\n if (attrs) {\n description.attrs = attrs\n }\n }\n }\n },\n\n getComponentProps(\n object: Props,\n ComponentClass: ComponentClass,\n isRoot: boolean,\n ): Props | null {\n const props = isRoot\n ? object\n : this.normalizeComponentProps(object, ComponentClass)\n return isNotEmpty(props) ? props : null\n },\n\n assignPropsToElement(props: Props, description: ElementDescription) {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key') {\n if (isDefined(value)) {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- keys are stringified as given\n description.key = String(value)\n }\n } else if (key === 'class') {\n const className = this.getClassName(value)\n if (className) {\n description.class = className\n }\n } else if (key === 'style') {\n const style = this.getStyle(value as Props)\n if (style) {\n description.style = style\n }\n } else if (key === 'dataset') {\n const dataset = this.getDataset(value as Props)\n if (dataset) {\n description.dataset = dataset\n }\n } else if (key === 'properties') {\n const properties = this.getProperties(value as Props)\n if (properties) {\n description.properties = properties\n }\n } else if (key === 'attrs') {\n const customAttrs = this.getCustomAttributes(value as Props)\n if (customAttrs) {\n description.custom = description.custom || {}\n description.custom.attrs = customAttrs\n }\n } else if (key === 'on') {\n const customListeners = this.getCustomListeners(value as Props)\n if (customListeners) {\n description.custom = description.custom || {}\n description.custom.listeners = customListeners\n }\n } else if (/^on[A-Z]/.test(key)) {\n const listener = this.getListener(value, key)\n if (listener) {\n description.listeners = description.listeners || {}\n description.listeners[key] = value as Listener\n }\n const element = description.name\n // custom elements define their events themselves\n if (\n runtime().isDebug() &&\n !element.includes('-') &&\n !Browser.isEventSupported(key, element)\n ) {\n console.warn(\n `The \"${key}\" listener is not supported on \"${element}\" elements.`,\n )\n }\n } else {\n const attr = this.getAttributeValue(value)\n if (isDefined(attr)) {\n description.attrs = description.attrs || {}\n description.attrs[key] = attr\n }\n if (runtime().isDebug()) {\n const element = description.name\n if (attr === undefined) {\n console.warn(\n `Invalid undefined value for attribute \"${key}\"`,\n `on element \"${element}\".`,\n )\n }\n // custom elements define their attributes themselves\n if (\n !element.includes('-') &&\n !Browser.isAttributeSupported(key, element)\n ) {\n console.warn(\n `The \"${key}\" attribute is not supported on \"${element}\" elements.`,\n )\n }\n }\n }\n }\n },\n\n /**\n * Returns the type of item used in the array representing node template.\n */\n getItemType(item: unknown): ItemType {\n const type = typeof item\n switch (type) {\n case 'function':\n // the node type is inherited from the Component or Root class\n if (\n (item as ComponentClass).NodeType === 'component' ||\n (item as ComponentClass).NodeType === 'root'\n ) {\n return 'component'\n }\n return 'function'\n case 'object':\n if (item === null) {\n return 'null'\n } else if (Array.isArray(item)) {\n return 'node'\n } else if ((item as object).constructor === Object) {\n return 'props'\n }\n return 'unknown'\n default:\n return type\n }\n },\n\n /**\n * Resolves any object to a space separated string of class names.\n */\n getClassName(value: unknown): string {\n if (!value) {\n return ''\n }\n if (typeof value === 'string') {\n return value\n }\n if (Array.isArray(value)) {\n return value\n .map(item => this.getClassName(item))\n .filter(className => className)\n .join(' ')\n }\n if (typeof value === 'object') {\n return Object.keys(value)\n .filter(key => key && (value as Props)[key])\n .join(' ')\n }\n throw new Error(`Invalid value: ${JSON.stringify(value)}`)\n },\n\n /**\n * Returns either a non-empty style object containing only understood\n * styling rules or null.\n */\n getStyle(object: Props): Record<string, string> | null {\n runtime().assert(\n object.constructor === Object,\n 'Style must be a plain object!',\n )\n\n const style: Record<string, string> = {}\n for (const [name, value] of Object.entries(object)) {\n if (runtime().isDebug() && !Browser.isStyleSupported(name)) {\n console.warn(`Unsupported style property, key: ${name}, value:`, value)\n }\n const string = this.getStyleProperty(value, name)\n if (isDefined(string)) {\n style[name] = string\n }\n }\n return isNotEmpty(style) ? style : null\n },\n\n getStyleProperty(value: unknown, name: string): string | null {\n if (typeof value === 'string') {\n return value || \"''\"\n } else if ([true, false, null, undefined].includes(value as boolean)) {\n return null\n } else if (Array.isArray(value)) {\n return value.join('')\n } else if (typeof value === 'number') {\n return String(value)\n } else if (typeof value === 'object') {\n if (name !== 'filter' && name !== 'transform') {\n throw new Error(`Unknown function list: ${JSON.stringify(value)}`)\n }\n // the filter functions are named in camel case, e.g. dropShadow for\n // drop-shadow, the transform functions are in CSS too, e.g. translateX\n const functions = this.getFunctionList(\n value as Props,\n name === 'filter' ? lowerDash : undefined,\n )\n if (runtime().isDebug() && functions && !CSS.supports(name, functions)) {\n console.warn(`Unsupported ${name} functions: ${functions}`)\n }\n return functions\n }\n throw new Error(`Invalid style property value: ${JSON.stringify(value)}`)\n },\n\n /**\n * Returns a multi-property string value.\n */\n getFunctionList(\n object: Props,\n getCSSName: (name: string) => string = name => name,\n ): string {\n const composite: Record<string, string> = {}\n for (const [key, value] of Object.entries(object)) {\n const stringValue = this.getAttributeValue(value, /*= allowEmpty */ false)\n if (isDefined(stringValue)) {\n composite[getCSSName(key)] = stringValue\n }\n }\n return Object.entries(composite)\n .map(([key, value]) => `${key}(${value})`)\n .join(' ')\n },\n\n getListener(value: unknown, name: string): Listener | null {\n if (typeof value === 'function') {\n return value as Listener\n }\n if (value === null || value === false || value === undefined) {\n return null\n }\n throw new Error(`Invalid listener specified for event: ${name}`)\n },\n\n /**\n * Resolves given value to a string.\n */\n getAttributeValue(\n value: unknown,\n allowEmpty = true,\n ): string | null | undefined {\n if (value === true || value === '') {\n return allowEmpty ? '' : null\n } else if (typeof value === 'string') {\n return value\n } else if (value === null || value === false) {\n return null\n } else if (value === undefined) {\n return undefined\n } else if (Array.isArray(value)) {\n return value.join('')\n } else if (['object', 'function', 'symbol'].includes(typeof value)) {\n throw new Error(`Invalid attribute value: ${JSON.stringify(value)}!`)\n }\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- objects are rejected above\n return String(value)\n },\n\n /**\n * Returns either a non-empty dataset object or null.\n */\n getDataset(object: Props): Record<string, string> | null {\n const dataset: Record<string, string> = {}\n for (const key of Object.keys(object)) {\n const value = this.getAttributeValue(object[key])\n if (isDefined(value)) {\n dataset[key] = value\n }\n }\n return isNotEmpty(dataset) ? dataset : null\n },\n\n /**\n * Returns either a non-empty object containing properties set\n * directly on a rendered DOM Element or null.\n */\n getProperties(object: Props): Props | null {\n return isNotEmpty(object) ? object : null\n },\n\n getCustomAttributes(\n object: Props,\n forComponent?: boolean,\n ): Record<string, string> | null {\n runtime().assert(\n object.constructor === Object,\n 'Expecting object for custom attributes!',\n )\n const attrs: Record<string, string> = {}\n for (const [key, value] of Object.entries(object)) {\n const attr = this.getAttributeValue(value, /*= allowEmpty */ true)\n if (isDefined(attr)) {\n const name = forComponent ? lowerDash(key) : key\n attrs[name] = attr\n }\n }\n return isNotEmpty(attrs) ? attrs : null\n },\n\n getCustomListeners(object: Props): Record<string, Listener> | null {\n runtime().assert(\n object.constructor === Object,\n 'Expecting object for custom listeners!',\n )\n const listeners: Record<string, Listener> = {}\n for (const [key, value] of Object.entries(object)) {\n const listener = this.getListener(value, key)\n if (listener) {\n listeners[key] = listener\n }\n }\n return isNotEmpty(listeners) ? listeners : null\n },\n}\n\n/* A Bragi template, see bragi.ts, sharing its name with the module above. */\ntype Template = BragiTemplate\n\nexport default Template\n","import type { Child, RenderResult } from './bragi.js'\nimport {\n CommentDescription,\n type ComponentDescription,\n type NodeDescription,\n type Props,\n} from './description.js'\nimport type Dispatcher from './dispatcher.js'\nimport type { Commands, CommandsAPI } from './dispatcher.js'\nimport { runtime } from './runtime.js'\nimport Sandbox, { type ComponentSandbox } from './sandbox.js'\nimport Template from './template.js'\nimport { type AnyFunction, invariant } from './utils.js'\nimport VirtualNode, { type NodeRef } from './virtual-node.js'\nimport type WebComponent from './web-component.js'\n\n/* A task run when a component is destroyed, e.g. disconnecting a service. */\nexport type CleanUpTask = (() => void) & { service?: unknown }\n\n/* A service components connect to, e.g. a subclass of Service. */\nexport interface Connectable {\n connect(listeners: Record<string, unknown>): () => void\n}\n\n/* The class of any component, whatever its props. */\nexport type ComponentClass = typeof Component<object>\n\n/*\n * Node representing Component in the virtual DOM tree.\n * Components\n */\nclass Component<P extends object = object> extends VirtualNode {\n static NodeType = 'component'\n\n declare static elementName?: string\n declare static defaultProps?: Props\n declare static commands?: CommandsAPI | CommandsAPI[]\n\n static get displayName(): string {\n return this.name\n }\n\n declare description: ComponentDescription\n declare sandbox: ComponentSandbox\n declare cleanUpTasks: CleanUpTask[]\n declare isInitialized: boolean\n declare content: VirtualNode | null\n\n /* The component props, available on the sandbox passed as `this`. */\n declare props: P\n\n /* The child templates, available on the sandbox passed as `this`. */\n declare children: Child[]\n\n onCreated?(): void\n onAttached?(): void\n onPropsReceived?(nextProps: P): void\n onUpdated?(prevProps: P): void\n onDestroyed?(): void\n onDetached?(): void\n\n constructor(\n description: ComponentDescription,\n parent?: VirtualNode | null,\n context?: WebComponent | null,\n attachDOM = true,\n ) {\n super(description, parent, context)\n this.sandbox = Sandbox.create(this, COMPONENT_PROPERTIES)\n this.cleanUpTasks = []\n this.isInitialized = attachDOM\n if (attachDOM) {\n this.attachDOM()\n }\n // the rendered content is inserted right after instantiation\n this.content = null\n }\n\n /**\n * Sets the component content.\n */\n setContent(node: VirtualNode) {\n invariant(\n node.parentNode === this,\n 'Specified node does not have a valid parent!',\n )\n this.content!.parentNode = null\n node.parentNode = this\n this.content!.ref.replaceWith(node.ref)\n this.content = node\n }\n\n hasOwnMethod(method: string): boolean {\n // eslint-disable-next-line no-prototype-builtins\n return (this.constructor as ComponentClass).prototype.hasOwnProperty(method)\n }\n\n connectTo(service: Connectable, listeners: Record<string, unknown>) {\n runtime().assert(\n typeof service.connect === 'function',\n 'Services have to define the connect() method',\n )\n const disconnect: CleanUpTask = service.connect(listeners)\n runtime().assert(\n typeof disconnect === 'function',\n 'The result of the connect() method has to be a disconnect() method',\n )\n disconnect.service = service\n this.cleanUpTasks.push(disconnect)\n }\n\n get childElement(): VirtualNode | null {\n if (this.content) {\n if (this.content.isElement() || this.content.isRoot()) {\n return this.content\n }\n if (this.content.isComponent()) {\n return this.content.childElement\n }\n }\n return null\n }\n\n get placeholder(): VirtualNode | null {\n if (this.content!.isComment()) {\n return this.content\n }\n return (this.content as Component).placeholder || null\n }\n\n render(): RenderResult {\n return undefined\n }\n\n /**\n * Calls the render method and transforms the returned template\n * into the normalised description of the rendered node.\n */\n renderDescription(\n props: Props = {},\n children: unknown[] = [],\n ): NodeDescription | null {\n this.sandbox.props = props\n this.sandbox.children = children\n const template = this.render.call(this.sandbox)\n if (template) {\n return Template.describe(template)\n }\n const text = (this.constructor as ComponentClass).displayName\n return new CommentDescription(text)\n }\n\n /* The commands of the root component, whose types are not known here. */\n get commands(): Commands<unknown> & Record<string, AnyFunction> {\n return this.context ? this.context.commands : this.rootNode.commands\n }\n\n get dispatcher(): Dispatcher {\n return this.context ? this.context.dispatcher : this.rootNode.dispatcher\n }\n\n destroy() {\n for (const cleanUpTask of this.cleanUpTasks) {\n cleanUpTask()\n }\n }\n\n get nodeType(): string {\n return Component.NodeType\n }\n\n get ref(): NodeRef {\n return this.content!.ref\n }\n\n isCompatible(node: VirtualNode | null | undefined) {\n return super.isCompatible(node) && this.constructor === node!.constructor\n }\n\n attachDOM() {\n if (this.content) {\n this.content.attachDOM()\n }\n }\n}\n\n/* The properties of the Component class hidden from the sandbox. */\nconst COMPONENT_PROPERTIES = Object.getOwnPropertyNames(Component.prototype)\n\nexport default Component\n","import type { TextDescription } from './description.js'\nimport VirtualNode from './virtual-node.js'\n\nclass Text extends VirtualNode {\n static NodeType = 'text'\n\n declare description: TextDescription\n declare ref: globalThis.Text\n\n constructor(description: TextDescription, parentNode?: VirtualNode) {\n super(description, parentNode)\n this.attachDOM()\n }\n\n get nodeType(): string {\n return Text.NodeType\n }\n\n attachDOM() {\n this.ref = document.createTextNode(this.description.text)\n }\n}\n\nexport default Text\n","import { invariant } from './utils.js'\nimport type VirtualElement from './virtual-element.js'\nimport type VirtualNode from './virtual-node.js'\nimport type WebComponent from './web-component.js'\n\n/*\n * A node with child nodes: an element, or a Web Component\n * with the child nodes rendered in its light DOM.\n */\nexport type ParentVirtualNode = VirtualElement | WebComponent\n\n/*\n * Operations on the child nodes of the parent nodes, which store them\n * as `children` of an element or `childNodes` of a Web Component.\n */\nconst ChildNodes = {\n set(parent: ParentVirtualNode, nodes: VirtualNode[]) {\n parent.childNodes = nodes\n for (const child of nodes) {\n parent.ref.appendChild(child.ref)\n }\n },\n\n insert(parent: ParentVirtualNode, child: VirtualNode, index?: number) {\n const nodes = parent.childNodes ?? []\n if (index === undefined) {\n index = nodes.length\n }\n const nextChild = nodes[index]\n nodes.splice(index, 0, child)\n parent.childNodes = nodes\n parent.ref.insertBefore(child.ref, (nextChild && nextChild.ref) || null)\n child.parentNode = parent\n },\n\n replace(parent: ParentVirtualNode, child: VirtualNode, node: VirtualNode) {\n const nodes = parent.childNodes ?? []\n const index = nodes.indexOf(child)\n invariant(index >= 0, 'Specified node is not a child of this element!')\n nodes.splice(index, 1, node)\n child.parentNode = null\n node.parentNode = parent\n child.ref.replaceWith(node.ref)\n },\n\n move(\n parent: ParentVirtualNode,\n child: VirtualNode,\n from: number,\n to: number,\n ) {\n const nodes = parent.childNodes ?? []\n invariant(\n nodes[from] === child,\n 'Specified node is not a child of this element!',\n )\n nodes.splice(from, 1)\n nodes.splice(to, 0, child)\n // the DOM position is taken from the virtual children, as element\n // children would skip the text and comment nodes\n const nextChild = nodes[to + 1]\n parent.ref.insertBefore(child.ref, nextChild ? nextChild.ref : null)\n },\n\n remove(parent: ParentVirtualNode, child: VirtualNode) {\n const nodes = parent.childNodes ?? []\n const index = nodes.indexOf(child)\n invariant(index >= 0, 'Specified node is not a child of this element!')\n nodes.splice(index, 1)\n if (!nodes.length) {\n parent.childNodes = undefined\n }\n parent.ref.removeChild(child.ref)\n },\n}\n\nexport default ChildNodes\n","import type { ElementDescription, Listener } from './description.js'\nimport { getAttributeName, getEventName } from './utils.js'\n\n/* Style and properties are set by name, as by the original assignments. */\ntype StyleMap = Record<string, string | null>\ntype PropertyMap = Record<string, unknown>\n\n/*\n * Writes to the rendered elements, shared by the initial rendering and\n * the patches, so that both follow the same rules. Custom attributes and\n * listeners use the names as given, others are mapped to the DOM names.\n */\nconst DOM = {\n setClassName(element: HTMLElement, className: string) {\n element.className = className\n },\n\n setStyleProperty(element: HTMLElement, name: string, value: string) {\n if (name.startsWith('--')) {\n element.style.setProperty(name, ` ${value}`)\n } else {\n ;(element.style as unknown as StyleMap)[name] = value\n }\n },\n\n removeStyleProperty(element: HTMLElement, name: string) {\n if (name.startsWith('--')) {\n element.style.removeProperty(name)\n } else {\n ;(element.style as unknown as StyleMap)[name] = null\n }\n },\n\n setAttribute(\n element: HTMLElement,\n name: string,\n value: string,\n isCustom: boolean,\n ) {\n const attr = isCustom ? name : getAttributeName(name)\n element.setAttribute(attr, value)\n },\n\n removeAttribute(element: HTMLElement, name: string, isCustom: boolean) {\n const attr = isCustom ? name : getAttributeName(name)\n element.removeAttribute(attr)\n },\n\n setDataAttribute(element: HTMLElement, name: string, value: string) {\n element.dataset[name] = value\n },\n\n removeDataAttribute(element: HTMLElement, name: string) {\n delete element.dataset[name]\n },\n\n addListener(\n element: HTMLElement,\n name: string,\n listener: Listener,\n isCustom: boolean,\n ) {\n const event = isCustom ? name : getEventName(name)\n element.addEventListener(event, listener)\n },\n\n removeListener(\n element: HTMLElement,\n name: string,\n listener: Listener,\n isCustom: boolean,\n ) {\n const event = isCustom ? name : getEventName(name)\n element.removeEventListener(event, listener)\n },\n\n setProperty(element: HTMLElement, key: string, value: unknown) {\n ;(element as unknown as PropertyMap)[key] = value\n },\n\n deleteProperty(element: HTMLElement, key: string) {\n delete (element as unknown as PropertyMap)[key]\n },\n\n /**\n * Creates a new DOM Element based on the specified description.\n */\n createElement(description: ElementDescription): HTMLElement {\n const element = document.createElement(description.name)\n if (description.class) {\n this.setClassName(element, description.class)\n }\n for (const [name, value] of Object.entries(description.style ?? {})) {\n this.setStyleProperty(element, name, value)\n }\n for (const [name, listener] of Object.entries(\n description.listeners ?? {},\n )) {\n this.addListener(element, name, listener, false)\n }\n for (const [name, value] of Object.entries(description.attrs ?? {})) {\n this.setAttribute(element, name, value, false)\n }\n for (const [name, value] of Object.entries(description.dataset ?? {})) {\n this.setDataAttribute(element, name, value)\n }\n for (const [key, value] of Object.entries(description.properties ?? {})) {\n this.setProperty(element, key, value)\n }\n for (const [name, value] of Object.entries(\n description.custom?.attrs ?? {},\n )) {\n this.setAttribute(element, name, value, true)\n }\n for (const [name, listener] of Object.entries(\n description.custom?.listeners ?? {},\n )) {\n this.addListener(element, name, listener, true)\n }\n return element\n },\n}\n\nexport default DOM\n","import ChildNodes from './child-nodes.js'\nimport type { ElementDescription } from './description.js'\nimport DOM from './dom.js'\nimport VirtualNode from './virtual-node.js'\nimport type WebComponent from './web-component.js'\n\nclass VirtualElement extends VirtualNode {\n static NodeType = 'element'\n\n declare description: ElementDescription\n declare ref: HTMLElement\n declare children?: VirtualNode[]\n\n constructor(\n description: ElementDescription,\n parent?: VirtualNode | null,\n context?: WebComponent | null,\n ) {\n super(description, parent, context)\n this.attachDOM()\n }\n\n /* The child nodes, as shared with Web Components. */\n get childNodes(): VirtualNode[] | undefined {\n return this.children\n }\n\n set childNodes(nodes: VirtualNode[] | undefined) {\n if (nodes) {\n this.children = nodes\n } else {\n delete this.children\n }\n }\n\n get nodeType(): string {\n return VirtualElement.NodeType\n }\n\n isCompatible(node: VirtualNode | null | undefined) {\n return (\n super.isCompatible(node) &&\n this.description.name === (node as VirtualElement).description.name\n )\n }\n\n setChildNodes(nodes: VirtualNode[]) {\n ChildNodes.set(this, nodes)\n }\n\n insertChild(child: VirtualNode, index?: number) {\n ChildNodes.insert(this, child, index)\n }\n\n replaceChild(child: VirtualNode, node: VirtualNode) {\n ChildNodes.replace(this, child, node)\n }\n\n moveChild(child: VirtualNode, from: number, to: number) {\n ChildNodes.move(this, child, from, to)\n }\n\n removeChild(child: VirtualNode) {\n ChildNodes.remove(this, child)\n }\n\n attachDOM() {\n this.ref = DOM.createElement(this.description)\n }\n}\n\nexport default VirtualElement\n","import type { WebComponent } from './nodes.js'\n\n/* The roots created by the function called by destroyingRootsOnError(). */\nlet createdRoots: WebComponent[] | null = null\n\nconst CreatedRoots = {\n /**\n * Calls the function, destroying the roots it creates when it throws.\n * They are neither attached nor destroyed by the lifecycle then, but\n * would stay tracked, with the plugins installed.\n */\n destroyingRootsOnError<T>(fn: () => T): T {\n const outerRoots = createdRoots\n const roots: WebComponent[] = []\n createdRoots = roots\n try {\n const result = fn()\n outerRoots?.push(...roots)\n return result\n } catch (error) {\n for (const root of roots.reverse()) {\n root.destroy()\n }\n throw error\n } finally {\n createdRoots = outerRoots\n }\n },\n\n /**\n * Records a root being created, see destroyingRootsOnError().\n */\n collectRoot(root: WebComponent) {\n createdRoots?.push(root)\n },\n}\n\nexport default CreatedRoots\n","import type {\n ComponentDescription,\n Listener,\n NodeDescription,\n} from './description.js'\nimport DOM from './dom.js'\nimport type {\n Component,\n ParentVirtualNode,\n VirtualElement,\n VirtualNode,\n WebComponent,\n} from './nodes.js'\n\n/* A node rendered as an HTML element, e.g. a root with a custom element. */\ntype PatchTarget = VirtualNode & { ref: HTMLElement }\n\nconst Type = {\n INIT_ROOT_COMPONENT: 'init-root-component',\n UPDATE_NODE: 'update-node',\n UPDATE_ROOT: 'update-root',\n SET_ATTRIBUTE: 'set-attribute',\n REMOVE_ATTRIBUTE: 'remove-attribute',\n SET_DATA_ATTRIBUTE: 'set-data-attribute',\n REMOVE_DATA_ATTRIBUTE: 'remove-data-attribute',\n SET_STYLE_PROPERTY: 'set-style-property',\n REMOVE_STYLE_PROPERTY: 'remove-style-property',\n SET_CLASS_NAME: 'set-class-name',\n ADD_LISTENER: 'add-listener',\n REPLACE_LISTENER: 'replace-listener',\n REMOVE_LISTENER: 'remove-listener',\n SET_PROPERTY: 'set-property',\n DELETE_PROPERTY: 'delete-property',\n INSERT_CHILD: 'insert-child',\n REPLACE_CHILD: 'replace-child',\n MOVE_CHILD: 'move-child',\n REMOVE_CHILD: 'remove-child',\n SET_CONTENT: 'set-content',\n} as const\n\n/*\n * A single change of the virtual and rendered DOM, applied by Patch.apply().\n */\ntype Patch =\n | { type: 'init-root-component'; root: WebComponent }\n | {\n type: 'update-node'\n node: VirtualNode\n prevDescription: NodeDescription\n description: NodeDescription\n }\n | {\n type: 'update-root'\n root: WebComponent\n description: ComponentDescription\n }\n | {\n type: 'set-attribute'\n name: string\n value: string\n target: PatchTarget\n isCustom: boolean\n }\n | {\n type: 'remove-attribute'\n name: string\n target: PatchTarget\n isCustom: boolean\n }\n | {\n type: 'set-data-attribute'\n name: string\n value: string\n target: PatchTarget\n }\n | { type: 'remove-data-attribute'; name: string; target: PatchTarget }\n | {\n type: 'set-style-property'\n property: string\n value: string\n target: PatchTarget\n }\n | { type: 'remove-style-property'; property: string; target: PatchTarget }\n | { type: 'set-class-name'; className: string; target: PatchTarget }\n | {\n type: 'add-listener'\n name: string\n listener: Listener\n target: PatchTarget\n isCustom: boolean\n }\n | {\n type: 'replace-listener'\n name: string\n removed: Listener\n added: Listener\n target: PatchTarget\n isCustom: boolean\n }\n | {\n type: 'remove-listener'\n name: string\n listener: Listener\n target: PatchTarget\n isCustom: boolean\n }\n | { type: 'set-property'; key: string; value: unknown; target: PatchTarget }\n | { type: 'delete-property'; key: string; target: PatchTarget }\n | {\n type: 'insert-child'\n node: VirtualNode\n at: number\n parent: ParentVirtualNode\n }\n | {\n type: 'replace-child'\n child: VirtualNode\n node: VirtualNode\n parent: ParentVirtualNode\n }\n | {\n type: 'move-child'\n child: VirtualNode\n from: number\n to: number\n parent: ParentVirtualNode\n }\n | {\n type: 'remove-child'\n child: VirtualNode\n at: number\n parent: ParentVirtualNode\n }\n | {\n type: 'set-content'\n node: VirtualNode\n child: VirtualNode\n parent: Component\n }\n\n/* The patch of the given type. */\ntype PatchOf<T extends Patch['type']> = Extract<Patch, { type: T }>\n\nconst Patch = {\n Type,\n\n /**\n * Applies the change to the virtual and rendered DOM.\n */\n apply(patch: Patch) {\n switch (patch.type) {\n case Type.INIT_ROOT_COMPONENT: {\n const container = patch.root.container\n ? patch.root.container\n : patch.root.shadow!\n container.appendChild(patch.root.content!.ref)\n return\n }\n case Type.UPDATE_NODE:\n patch.node.description = patch.description\n return\n case Type.UPDATE_ROOT:\n patch.root.update(patch.description)\n return\n case Type.SET_ATTRIBUTE: {\n const { target, name, value, isCustom } = patch\n DOM.setAttribute(target.ref, name, value, isCustom)\n return\n }\n case Type.REMOVE_ATTRIBUTE:\n DOM.removeAttribute(patch.target.ref, patch.name, patch.isCustom)\n return\n case Type.SET_DATA_ATTRIBUTE:\n DOM.setDataAttribute(patch.target.ref, patch.name, patch.value)\n return\n case Type.REMOVE_DATA_ATTRIBUTE:\n DOM.removeDataAttribute(patch.target.ref, patch.name)\n return\n case Type.SET_STYLE_PROPERTY:\n DOM.setStyleProperty(patch.target.ref, patch.property, patch.value)\n return\n case Type.REMOVE_STYLE_PROPERTY:\n DOM.removeStyleProperty(patch.target.ref, patch.property)\n return\n case Type.SET_CLASS_NAME:\n DOM.setClassName(patch.target.ref, patch.className)\n return\n case Type.ADD_LISTENER: {\n const { target, name, listener, isCustom } = patch\n DOM.addListener(target.ref, name, listener, isCustom)\n return\n }\n case Type.REPLACE_LISTENER: {\n const { target, name, removed, added, isCustom } = patch\n DOM.removeListener(target.ref, name, removed, isCustom)\n DOM.addListener(target.ref, name, added, isCustom)\n return\n }\n case Type.REMOVE_LISTENER: {\n const { target, name, listener, isCustom } = patch\n DOM.removeListener(target.ref, name, listener, isCustom)\n return\n }\n case Type.SET_PROPERTY:\n DOM.setProperty(patch.target.ref, patch.key, patch.value)\n return\n case Type.DELETE_PROPERTY:\n DOM.deleteProperty(patch.target.ref, patch.key)\n return\n case Type.INSERT_CHILD:\n patch.parent.insertChild(patch.node, patch.at)\n return\n case Type.REPLACE_CHILD:\n patch.parent.replaceChild(patch.child, patch.node)\n return\n case Type.MOVE_CHILD:\n patch.parent.moveChild(patch.child, patch.from, patch.to)\n return\n case Type.REMOVE_CHILD:\n patch.parent.removeChild(patch.child)\n return\n case Type.SET_CONTENT:\n patch.parent.setContent(patch.node)\n return\n default: {\n // fails to compile when a patch type is not handled above\n const unsupported: never = patch\n throw new Error(\n `Unsupported patch type: ${(unsupported as Patch).type}`,\n )\n }\n }\n },\n\n initRootComponent(root: WebComponent): PatchOf<'init-root-component'> {\n return { type: Type.INIT_ROOT_COMPONENT, root }\n },\n\n updateNode(\n node: VirtualNode,\n description: NodeDescription,\n ): PatchOf<'update-node'> {\n return {\n type: Type.UPDATE_NODE,\n node,\n prevDescription: node.description,\n description,\n }\n },\n\n /* Passes the props to a nested root, which renders them itself. */\n updateRoot(\n root: WebComponent,\n description: ComponentDescription,\n ): PatchOf<'update-root'> {\n return { type: Type.UPDATE_ROOT, root, description }\n },\n\n insertChild(\n node: VirtualNode,\n at: number,\n parent: ParentVirtualNode,\n ): PatchOf<'insert-child'> {\n return { type: Type.INSERT_CHILD, node, at, parent }\n },\n\n moveChild(\n child: VirtualNode,\n from: number,\n to: number,\n parent: ParentVirtualNode,\n ): PatchOf<'move-child'> {\n return { type: Type.MOVE_CHILD, child, from, to, parent }\n },\n\n replaceChild(\n child: VirtualNode,\n node: VirtualNode,\n parent: ParentVirtualNode,\n ): PatchOf<'replace-child'> {\n return { type: Type.REPLACE_CHILD, child, node, parent }\n },\n\n removeChild(\n child: VirtualNode,\n at: number,\n parent: ParentVirtualNode,\n ): PatchOf<'remove-child'> {\n return { type: Type.REMOVE_CHILD, child, at, parent }\n },\n\n setContent(node: VirtualNode, parent: Component): PatchOf<'set-content'> {\n return { type: Type.SET_CONTENT, node, child: parent.content!, parent }\n },\n\n setAttribute(\n name: string,\n value: string,\n target: VirtualElement | WebComponent,\n isCustom: boolean,\n ): PatchOf<'set-attribute'> {\n return {\n type: Type.SET_ATTRIBUTE,\n name,\n value,\n target: target as PatchTarget,\n isCustom,\n }\n },\n\n removeAttribute(\n name: string,\n target: VirtualElement | WebComponent,\n isCustom: boolean,\n ): PatchOf<'remove-attribute'> {\n return {\n type: Type.REMOVE_ATTRIBUTE,\n name,\n target: target as PatchTarget,\n isCustom,\n }\n },\n\n setDataAttribute(\n name: string,\n value: string,\n target: VirtualElement,\n ): PatchOf<'set-data-attribute'> {\n return { type: Type.SET_DATA_ATTRIBUTE, name, value, target }\n },\n\n removeDataAttribute(\n name: string,\n target: VirtualElement,\n ): PatchOf<'remove-data-attribute'> {\n return { type: Type.REMOVE_DATA_ATTRIBUTE, name, target }\n },\n\n setStyleProperty(\n property: string,\n value: string,\n target: VirtualElement,\n ): PatchOf<'set-style-property'> {\n return { type: Type.SET_STYLE_PROPERTY, property, value, target }\n },\n\n removeStyleProperty(\n property: string,\n target: VirtualElement,\n ): PatchOf<'remove-style-property'> {\n return { type: Type.REMOVE_STYLE_PROPERTY, property, target }\n },\n\n setClassName(\n className: string,\n target: VirtualElement,\n ): PatchOf<'set-class-name'> {\n return { type: Type.SET_CLASS_NAME, className, target }\n },\n\n addListener(\n name: string,\n listener: Listener,\n target: VirtualElement,\n isCustom: boolean,\n ): PatchOf<'add-listener'> {\n return { type: Type.ADD_LISTENER, name, listener, target, isCustom }\n },\n\n replaceListener(\n name: string,\n removed: Listener,\n added: Listener,\n target: VirtualElement,\n isCustom: boolean,\n ): PatchOf<'replace-listener'> {\n return {\n type: Type.REPLACE_LISTENER,\n name,\n removed,\n added,\n target,\n isCustom,\n }\n },\n\n removeListener(\n name: string,\n listener: Listener,\n target: VirtualElement,\n isCustom: boolean,\n ): PatchOf<'remove-listener'> {\n return { type: Type.REMOVE_LISTENER, name, listener, target, isCustom }\n },\n\n setProperty(\n key: string,\n value: unknown,\n target: VirtualElement,\n ): PatchOf<'set-property'> {\n return { type: Type.SET_PROPERTY, key, value, target }\n },\n\n deleteProperty(\n key: string,\n target: VirtualElement,\n ): PatchOf<'delete-property'> {\n return { type: Type.DELETE_PROPERTY, key, target }\n },\n}\n\nexport default Patch\n","import type {\n ComponentDescription,\n NodeDescription,\n Props,\n} from './description.js'\nimport type {\n Component,\n ParentVirtualNode,\n VirtualNode,\n WebComponent,\n} from './nodes.js'\nimport Patch from './patch.js'\n\n/* The errors of the hooks called while collecting them, if collecting. */\nlet hookErrors: unknown[] | null = null\n\n/*\n * Calls a hook, collecting its error if collecting, so that a throwing hook\n * does not stop the other hooks from being called.\n */\nconst callHook = (hook: () => void) => {\n if (!hookErrors) {\n return hook()\n }\n try {\n hook()\n } catch (error) {\n hookErrors.push(error)\n }\n}\n\n/*\n * Calls the hook of a component being removed, ignoring the commands it\n * issues. The dispatcher is shared with the root, so its mode is restored.\n */\nconst callIgnoringCommands = (component: Component, hook: () => void) => {\n const { dispatcher } = component\n const { mode } = dispatcher\n dispatcher.ignoreIncoming()\n try {\n callHook(hook)\n } finally {\n dispatcher.mode = mode\n }\n}\n\n/* Throws the errors, aggregated when there are more of them. */\nexport const throwErrors = (errors: unknown[], message: string) => {\n if (errors.length === 1) {\n throw errors[0]\n }\n if (errors.length > 1) {\n throw new AggregateError(errors, message)\n }\n}\n\nconst Lifecycle = {\n /**\n * Calls the hooks in the callback, collecting the errors they throw in\n * the given list instead of stopping at the first one.\n */\n collectingErrors(errors: unknown[], callback: () => void) {\n const prevErrors = hookErrors\n hookErrors = errors\n try {\n callback()\n } finally {\n hookErrors = prevErrors\n }\n },\n\n onComponentCreated(component: Component) {\n if (component.hasOwnMethod('onCreated')) {\n callHook(() => component.onCreated!.call(component.sandbox))\n }\n if (component.content) {\n this.onNodeCreated(component.content)\n }\n },\n\n onElementCreated(element: ParentVirtualNode) {\n if (element.childNodes) {\n for (const child of element.childNodes) {\n this.onNodeCreated(child)\n }\n }\n },\n\n onNodeCreated(node: VirtualNode): void {\n if (node.isElement()) {\n return this.onElementCreated(node)\n } else if (node.isComponent() && !node.isRoot()) {\n return this.onComponentCreated(node)\n }\n },\n\n onRootCreated(root: WebComponent) {\n if (root.hasOwnMethod('onCreated')) {\n callHook(() => root.onCreated!.call(root.sandbox))\n }\n const { childNodes } = root\n if (childNodes) {\n for (const child of childNodes) {\n this.onNodeCreated(child)\n }\n }\n },\n\n onComponentAttached(component: Component) {\n if (component.content) {\n this.onNodeAttached(component.content)\n }\n if (component.hasOwnMethod('onAttached')) {\n callHook(() => component.onAttached!.call(component.sandbox))\n }\n },\n\n onElementAttached(element: ParentVirtualNode) {\n if (element.childNodes) {\n for (const child of element.childNodes) {\n this.onNodeAttached(child)\n }\n }\n },\n\n onNodeAttached(node: VirtualNode): void {\n if (node.isElement()) {\n return this.onElementAttached(node)\n } else if (node.isComponent() && !node.isRoot()) {\n return this.onComponentAttached(node)\n }\n },\n\n onNodeReceivedDescription(node: VirtualNode, description: NodeDescription) {\n if (node.isComponent()) {\n this.onComponentReceivedProps(\n node,\n (description as ComponentDescription).props,\n )\n }\n },\n\n onNodeUpdated(node: VirtualNode, prevDescription: NodeDescription) {\n if (node.isComponent()) {\n this.onComponentUpdated(\n node,\n (prevDescription as ComponentDescription).props,\n )\n }\n },\n\n onRootAttached(root: WebComponent) {\n const { childNodes } = root\n if (childNodes) {\n for (const child of childNodes) {\n this.onNodeAttached(child)\n }\n }\n if (root.hasOwnMethod('onAttached')) {\n callHook(() => root.onAttached!.call(root.sandbox))\n }\n },\n\n onComponentReceivedProps(component: Component, nextProps: Props = {}) {\n if (component.hasOwnMethod('onPropsReceived')) {\n callHook(() =>\n component.onPropsReceived!.call(component.sandbox, nextProps),\n )\n }\n },\n\n onComponentUpdated(component: Component, prevProps: Props = {}) {\n if (component.hasOwnMethod('onUpdated')) {\n callHook(() => component.onUpdated!.call(component.sandbox, prevProps))\n }\n },\n\n onComponentDestroyed(component: Component) {\n component.destroy()\n if (component.hasOwnMethod('onDestroyed')) {\n callIgnoringCommands(component, () =>\n component.onDestroyed!.call(component.sandbox),\n )\n }\n if (component.content) {\n this.onNodeDestroyed(component.content)\n }\n if (component.isRoot()) {\n this.onElementDestroyed(component)\n }\n },\n\n onElementDestroyed(element: ParentVirtualNode) {\n if (element.childNodes) {\n for (const child of element.childNodes) {\n this.onNodeDestroyed(child)\n }\n }\n },\n\n onNodeDestroyed(node: VirtualNode): void {\n if (node.isElement()) {\n return this.onElementDestroyed(node)\n } else if (node.isComponent() && !node.isRoot()) {\n return this.onComponentDestroyed(node)\n }\n },\n\n onComponentDetached(component: Component) {\n if (component.isRoot()) {\n this.onElementDetached(component)\n }\n if (component.content) {\n this.onNodeDetached(component.content)\n }\n if (component.hasOwnMethod('onDetached')) {\n callIgnoringCommands(component, () =>\n component.onDetached!.call(component.sandbox),\n )\n }\n },\n\n onElementDetached(element: ParentVirtualNode) {\n if (element.childNodes) {\n for (const child of element.childNodes) {\n this.onNodeDetached(child)\n }\n }\n },\n\n onNodeDetached(node: VirtualNode) {\n if (node.isElement()) {\n this.onElementDetached(node)\n node.parentNode = null\n } else if (node.isComponent() && !node.isRoot()) {\n this.onComponentDetached(node)\n node.parentNode = null\n }\n },\n\n beforeUpdate(patches: Patch[]) {\n for (const patch of patches) {\n this.beforePatchApplied(patch)\n }\n },\n\n beforePatchApplied(patch: Patch) {\n const Type = Patch.Type\n switch (patch.type) {\n case Type.INIT_ROOT_COMPONENT:\n this.onRootCreated(patch.root)\n return\n case Type.INSERT_CHILD:\n this.onNodeCreated(patch.node)\n return\n case Type.REPLACE_CHILD:\n case Type.SET_CONTENT:\n this.onNodeDestroyed(patch.child)\n this.onNodeCreated(patch.node)\n return\n case Type.REMOVE_CHILD:\n this.onNodeDestroyed(patch.child)\n return\n case Type.UPDATE_NODE:\n this.onNodeReceivedDescription(patch.node, patch.description)\n return\n }\n },\n\n afterUpdate(patches: Patch[]) {\n patches = [...patches].reverse()\n for (const patch of patches) {\n this.afterPatchApplied(patch)\n }\n },\n\n afterPatchApplied(patch: Patch) {\n const Type = Patch.Type\n switch (patch.type) {\n case Type.INIT_ROOT_COMPONENT:\n this.onRootAttached(patch.root)\n return\n case Type.INSERT_CHILD:\n this.onNodeAttached(patch.node)\n return\n case Type.REPLACE_CHILD:\n case Type.SET_CONTENT:\n this.onNodeDetached(patch.child)\n this.onNodeAttached(patch.node)\n return\n case Type.REMOVE_CHILD:\n this.onNodeDetached(patch.child)\n return\n case Type.UPDATE_NODE:\n this.onNodeUpdated(patch.node, patch.prevDescription)\n return\n }\n },\n}\n\nexport default Lifecycle\n","import type { WebComponent } from './nodes.js'\nimport type { Update } from './renderer.js'\nimport Sandbox from './sandbox.js'\nimport { runtime } from './runtime.js'\n\nconst Permission = {\n LISTEN_FOR_UPDATES: 'listen-for-updates',\n REGISTER_METHOD: 'register-method',\n INJECT_STYLESHEETS: 'inject-stylesheets',\n}\n\n/* The API a plugin receives in its register() method. */\nexport interface PluginSandbox {\n registerMethod?(name: string): void\n}\n\nexport interface PluginManifest {\n name: string\n permissions?: string[]\n register?(sandbox: PluginSandbox): void\n install?(root: WebComponent): () => void\n onBeforeUpdate?(update: Update): void\n onAfterUpdate?(update: Update): void\n getStylesheets?(): string[]\n [key: string]: unknown\n}\n\nclass Plugin {\n declare name: string\n declare permissions: string[]\n declare origin: PluginManifest\n declare register?: () => void\n declare install?: (root: WebComponent) => () => void\n declare onBeforeUpdate?: (update: Update) => void\n declare onAfterUpdate?: (update: Update) => void\n declare getStylesheets?: () => string[]\n\n constructor(manifest: PluginManifest) {\n runtime().assert(\n typeof manifest.name === 'string' && manifest.name.length,\n 'Plugin name must be a non-empty string!',\n )\n\n Object.assign(this, manifest)\n this.origin = manifest\n\n if (this.permissions === undefined) {\n this.permissions = []\n } else {\n runtime().assert(\n Array.isArray(this.permissions),\n 'Plugin permissions must be an array',\n )\n this.permissions = this.permissions.filter(permission =>\n Object.values(Permission).includes(permission),\n )\n }\n\n const sandbox = this.createSandbox()\n if (typeof manifest.register === 'function') {\n this.register = () => manifest.register!(sandbox)\n }\n if (typeof manifest.install === 'function') {\n this.install = root => {\n const uninstall = manifest.install!(root)\n runtime().assert(\n typeof uninstall === 'function',\n 'The plugin installation must return the uninstall function!',\n )\n return uninstall\n }\n }\n }\n\n isListener(): boolean {\n return this.permissions.includes(Permission.LISTEN_FOR_UPDATES)\n }\n\n isStylesheetProvider(): boolean {\n return this.permissions.includes(Permission.INJECT_STYLESHEETS)\n }\n\n createSandbox(): PluginSandbox {\n const sandbox: PluginSandbox = {}\n for (const permission of this.permissions) {\n switch (permission) {\n case Permission.REGISTER_METHOD:\n sandbox.registerMethod = name => Sandbox.registerPluginMethod(name)\n }\n }\n return sandbox\n }\n}\n\nclass Registry {\n declare plugins: Map<string, Plugin>\n declare cache: { listeners: Plugin[] };\n declare [Symbol.iterator]: () => Iterator<Plugin>\n\n constructor() {\n this.plugins = new Map()\n this.cache = {\n listeners: [],\n }\n this[Symbol.iterator] = () => this.plugins.values()[Symbol.iterator]()\n }\n\n /**\n * Adds the plugin to the registry\n */\n add(plugin: Plugin) {\n runtime().assert(\n !this.isRegistered(plugin.name),\n `Plugin '${plugin.name}' is already registered!`,\n )\n this.plugins.set(plugin.name, plugin)\n this.updateCache()\n }\n\n /**\n * Removes the plugin with specified name from the registry.\n */\n remove(name: string) {\n this.plugins.delete(name)\n this.updateCache()\n }\n\n /**\n * Checks if plugin with specified name exists in the registry.\n */\n isRegistered(name: string): boolean {\n return this.plugins.has(name)\n }\n\n /**\n * Updates the cache.\n */\n updateCache() {\n const plugins = [...this.plugins.values()]\n this.cache.listeners = plugins.filter(plugin => plugin.isListener())\n }\n}\n\nclass Plugins {\n static Plugin = Plugin\n\n declare root: WebComponent | null\n declare registry: Registry\n declare uninstalls: Map<string, () => void>;\n declare [Symbol.iterator]: () => Iterator<Plugin>\n\n constructor(root: WebComponent | null) {\n this.root = root\n this.registry = new Registry()\n this.uninstalls = new Map()\n this[Symbol.iterator] = () => this.registry[Symbol.iterator]()\n }\n\n /**\n * Creates a Plugin instance from the manifest object and registers it.\n */\n register(plugin: Plugin | PluginManifest) {\n if (!(plugin instanceof Plugin)) {\n plugin = new Plugin(plugin)\n }\n if (plugin.register) {\n plugin.register()\n }\n this.registry.add(plugin)\n }\n\n installAll() {\n for (const plugin of this.registry) {\n this.install(plugin)\n }\n }\n\n install(plugin: Plugin | PluginManifest) {\n if (this.root && plugin.install) {\n const uninstall = plugin.install(this.root)\n this.uninstalls.set(plugin.name, uninstall)\n }\n }\n\n /**\n * Removes the plugin from the registry and invokes it's uninstall method\n * if present.\n */\n uninstall(name: string) {\n const uninstall = this.uninstalls.get(name)\n this.uninstalls.delete(name)\n this.registry.remove(name)\n if (uninstall) {\n uninstall()\n }\n }\n\n /**\n * Uninstalls all the plugins from the registry.\n */\n destroy() {\n for (const plugin of this.registry) {\n this.uninstall(plugin.name)\n }\n this.root = null\n }\n\n /**\n * Invokes listener methods on registered listener plugins.\n */\n notify(action: 'before-update' | 'after-update', event: Update) {\n switch (action) {\n case 'before-update':\n for (const listener of this.registry.cache.listeners) {\n listener.onBeforeUpdate!(event)\n }\n return\n case 'after-update':\n for (const listener of this.registry.cache.listeners) {\n listener.onAfterUpdate!(event)\n }\n return\n default:\n throw new Error(`Unknown action: ${action as string}`)\n }\n }\n}\n\nexport type { Plugin }\n\nexport default Plugins\n","import DOM from './dom.js'\nimport Lifecycle, { throwErrors } from './lifecycle.js'\nimport type { WebComponent } from './nodes.js'\nimport Plugins, { type Plugin, type PluginManifest } from './plugins.js'\nimport { isSameList } from './utils.js'\n\nconst cssImports = (paths: string[]) =>\n paths.map(path => `@import url(${path});`).join('\\n')\n\ntype PluginOrManifest = Plugin | PluginManifest\n\nexport class ComponentElement extends HTMLElement {\n declare $root: WebComponent | null\n declare pendingDestruction?: ReturnType<typeof setTimeout>\n declare stylesheets: string[]\n declare styleElement: HTMLStyleElement | null\n declare stylesheetsLoaded: Promise<void>\n declare install: (plugin: PluginOrManifest, cascade?: boolean) => void\n declare uninstall: (\n plugin: PluginOrManifest | string,\n cascade?: boolean,\n ) => void\n\n constructor(root: WebComponent) {\n super()\n this.$root = root\n this.stylesheets = []\n this.styleElement = null\n this.stylesheetsLoaded = Promise.resolve()\n\n addPluginsAPI(this)\n\n root.shadow = this.attachShadow({\n mode: 'open',\n })\n\n const stylesheets = root.getStylesheets()\n\n const init = () => {\n root.init().catch((error: Error) => root.markAsFailed(error))\n }\n\n if (stylesheets.length) {\n // rejects mounting, as the errors are not thrown to the caller\n this.loadStylesheets(stylesheets).then(init, (error: Error) =>\n root.markAsFailed(error),\n )\n } else {\n init()\n }\n }\n\n /**\n * Replaces the stylesheets imported in the shadow root, keeping the\n * previous ones until the new ones are loaded.\n */\n loadStylesheets(stylesheets: string[]): Promise<void> {\n const previous = this.styleElement\n this.stylesheets = stylesheets\n let loaded = Promise.resolve()\n if (stylesheets.length) {\n const style = document.createElement('style')\n style.textContent = cssImports(stylesheets)\n loaded = new Promise((resolve, reject) => {\n style.onload = () => resolve()\n style.onerror = () =>\n reject(\n new Error(`Error loading stylesheets: ${stylesheets.join(', ')}`),\n )\n })\n if (previous) {\n previous.after(style)\n } else {\n this.shadowRoot!.prepend(style)\n }\n this.styleElement = style\n } else {\n this.styleElement = null\n }\n if (previous) {\n // removed once loaded, as the root may be waiting to be initialized\n void Promise.allSettled([this.stylesheetsLoaded, loaded]).then(() =>\n previous.remove(),\n )\n }\n this.stylesheetsLoaded = loaded\n return loaded\n }\n\n get isComponentElement() {\n return true\n }\n\n connectedCallback() {\n clearTimeout(this.pendingDestruction)\n }\n\n disconnectedCallback() {\n this.pendingDestruction = setTimeout(() => this.destroy(), 50)\n }\n\n destroy() {\n const root = this.$root\n if (!root) {\n // already destroyed, e.g. directly before the scheduled destruction\n return\n }\n // the hooks of all the components are called when some of them throw\n const errors: unknown[] = []\n Lifecycle.collectingErrors(errors, () => {\n Lifecycle.onComponentDestroyed(root)\n Lifecycle.onComponentDetached(root)\n })\n root.ref = null\n this.$root = null\n throwErrors(errors, 'Errors destroying the component')\n }\n}\n\nconst addPluginsAPI = (element: ComponentElement) => {\n const { Plugin } = Plugins\n element.install = (plugin, cascade = true) => {\n const installTo = (root: WebComponent) => {\n if (plugin instanceof Plugin) {\n root.plugins!.registry.add(plugin)\n root.plugins!.install(plugin)\n } else {\n root.plugins!.install(plugin)\n }\n if (cascade) {\n for (const subroot of root.subroots) {\n installTo(subroot)\n }\n }\n }\n installTo(element.$root!)\n }\n element.uninstall = (plugin, cascade = true) => {\n const name = typeof plugin === 'string' ? plugin : plugin.name\n const uninstallFrom = (root: WebComponent) => {\n root.plugins!.uninstall(name)\n if (cascade) {\n for (const subroot of root.subroots) {\n uninstallFrom(subroot)\n }\n }\n }\n uninstallFrom(element.$root!)\n }\n}\n\n/**\n * Loads the stylesheets of the root in its custom element when they\n * changed, e.g. with the plugins reconfigured.\n */\nexport const updateStylesheets = (root: WebComponent) => {\n const element = root.ref as ComponentElement\n const stylesheets = root.getStylesheets()\n if (!isSameList(stylesheets, element.stylesheets)) {\n element\n .loadStylesheets(stylesheets)\n .catch((error: unknown) => console.error(error))\n }\n}\n\n/**\n * Creates a new Custom Element instance assigned to specified Web Component.\n */\nexport const createComponentElement = (\n root: WebComponent,\n): ComponentElement => {\n const defineCustomElementClass = (RootClass: typeof WebComponent) => {\n let ElementClass = customElements.get(RootClass.elementName!) as\n typeof ComponentElement | undefined\n if (!ElementClass) {\n ElementClass = class RootElement extends ComponentElement {}\n customElements.define(RootClass.elementName!, ElementClass)\n RootClass.prototype.elementClass = ElementClass\n }\n return ElementClass\n }\n const ElementClass = defineCustomElementClass(\n root.constructor as typeof WebComponent,\n )\n const element = new ElementClass(root)\n // the attributes of a root are custom, as set by the diff\n for (const [name, value] of Object.entries(root.description.attrs ?? {})) {\n DOM.setAttribute(element, name, value, true)\n }\n return element\n}\n","import { invariant } from './utils.js'\n\n/*\n * Drafts let commands change the state as if it was mutable. A draft is\n * a proxy recording the changes on a shallow copy of its object, with the\n * nested objects drafted when accessed. The next state is made of the\n * copies, sharing the parts left unchanged with the previous state.\n */\n\ntype Kind = 'object' | 'array' | 'map' | 'set' | 'date' | 'typed-array'\n\ntype Entries = Record<PropertyKey, unknown>\n\n/* Any of the typed arrays, as Uint8Array or Float32Array. */\ninterface TypedArray extends ArrayBufferView {\n slice(): TypedArray\n}\n\ninterface Draft {\n kind: Kind\n base: object\n copy: object | null\n parent: Draft | null\n scope: Scope\n modified: boolean\n proxy: object\n result: object | null\n // the drafts of the items of a set, replacing them in the copy\n items: Map<unknown, object> | null\n}\n\ninterface Scope {\n revokes: (() => void)[]\n // the new values checked for drafts when finalizing\n visited: WeakSet<object>\n}\n\n/* The drafts by their proxies. */\nconst drafts = new WeakMap<object, Draft>()\n\n/* The drafts by the targets of their proxies. */\nconst targets = new WeakMap<object, Draft>()\n\n// matching the original objects of the drafts as well as the drafts\nconst ARRAY_SEARCHES = new Set<PropertyKey>([\n 'includes',\n 'indexOf',\n 'lastIndexOf',\n])\n\n// with subarray() writing to the memory of the array, as a view of it\nconst TYPED_ARRAY_MUTATORS = new Set<PropertyKey>([\n 'copyWithin',\n 'fill',\n 'reverse',\n 'set',\n 'sort',\n 'subarray',\n])\n\nconst getKind = (value: unknown): Kind | null => {\n if (typeof value !== 'object' || value === null) {\n return null\n }\n if (ArrayBuffer.isView(value)) {\n return value instanceof DataView ? null : 'typed-array'\n }\n switch (Object.getPrototypeOf(value)) {\n case Object.prototype:\n case null:\n return 'object'\n case Array.prototype:\n return 'array'\n case Map.prototype:\n return 'map'\n case Set.prototype:\n return 'set'\n case Date.prototype:\n return 'date'\n default:\n return null\n }\n}\n\nconst INVALID_VALUE =\n 'The state can contain only primitives, functions, plain objects, arrays, maps, sets, dates and typed arrays'\n\n/* Returns the kind of a value allowed in the state, null when not drafted. */\nconst checkValue = (value: unknown): Kind | null => {\n const kind = getKind(value)\n invariant(kind || typeof value !== 'object' || value === null, INVALID_VALUE)\n return kind\n}\n\nconst current = (draft: Draft) => draft.copy ?? draft.base\n\nconst createDraft = (\n base: object,\n kind: Kind,\n parent: Draft | null,\n scope: Scope,\n): object => {\n // arrays need an array target to be recognized by Array.isArray()\n const target: object =\n kind === 'array'\n ? []\n : (Object.create(Object.getPrototypeOf(base) as object | null) as object)\n const { proxy, revoke } = Proxy.revocable(target, handler)\n const draft: Draft = {\n kind,\n base,\n copy: null,\n parent,\n scope,\n modified: false,\n proxy,\n result: null,\n items: null,\n }\n drafts.set(proxy, draft)\n targets.set(target, draft)\n scope.revokes.push(revoke)\n return proxy\n}\n\nconst prepareCopy = (draft: Draft) => {\n if (draft.copy) {\n return\n }\n const { base } = draft\n switch (draft.kind) {\n case 'object':\n draft.copy = Object.assign(\n Object.create(Object.getPrototypeOf(base) as object | null) as object,\n base,\n )\n break\n case 'array':\n draft.copy = (base as unknown[]).slice()\n break\n case 'map':\n draft.copy = new Map(base as Map<unknown, unknown>)\n break\n case 'set': {\n // the items are drafted up front, as sets have no keys to draft them by\n const copy = new Set<unknown>()\n draft.items = new Map()\n for (const item of base as Set<unknown>) {\n const kind = checkValue(item)\n if (kind) {\n const itemDraft = createDraft(\n item as object,\n kind,\n draft,\n draft.scope,\n )\n draft.items.set(item, itemDraft)\n copy.add(itemDraft)\n } else {\n copy.add(item)\n }\n }\n draft.copy = copy\n break\n }\n case 'date':\n draft.copy = new Date((base as Date).getTime())\n break\n case 'typed-array':\n // of the same type, as slice() creates the array with its constructor\n draft.copy = (base as TypedArray).slice()\n break\n }\n}\n\nconst markModified = (draft: Draft | null) => {\n while (draft && !draft.modified) {\n prepareCopy(draft)\n draft.modified = true\n draft = draft.parent\n }\n}\n\n/*\n * Returns the value under the key, drafted when it is a draftable value\n * of the base object, left unchanged.\n */\nconst getValue = (\n draft: Draft,\n value: unknown,\n baseValue: unknown,\n store: (copy: object, child: object) => void,\n): unknown => {\n if (drafts.has(value as object)) {\n return value\n }\n const kind = checkValue(value)\n if (!kind || value !== baseValue) {\n return value\n }\n prepareCopy(draft)\n const child = createDraft(value as object, kind, draft, draft.scope)\n store(draft.copy!, child)\n return child\n}\n\n/* Returns the original object of a draft, or the value itself. */\nconst getOriginal = (value: unknown): unknown =>\n (typeof value === 'object' && value !== null && drafts.get(value)?.base) ||\n value\n\nconst getProperty = (draft: Draft, key: PropertyKey): unknown => {\n const source = current(draft) as Entries\n if (draft.kind === 'array' && ARRAY_SEARCHES.has(key)) {\n // the objects passed to commands, e.g. from props, are not the drafts\n return (value: unknown, ...args: [number?]) => {\n const items = (current(draft) as unknown[]).map(getOriginal)\n return items[key as 'indexOf'](getOriginal(value), ...args)\n }\n }\n if (!Object.hasOwn(source, key)) {\n // the array methods work through the proxy\n return Reflect.get(source, key, draft.proxy)\n }\n const base = draft.base as Entries\n return getValue(\n draft,\n source[key],\n Object.hasOwn(base, key) ? base[key] : undefined,\n (copy, child) => ((copy as Entries)[key] = child),\n )\n}\n\nconst getMapValue = (draft: Draft, key: unknown): unknown => {\n const source = current(draft) as Map<unknown, unknown>\n return getValue(\n draft,\n source.get(key),\n (draft.base as Map<unknown, unknown>).get(key),\n (copy, child) => (copy as Map<unknown, unknown>).set(key, child),\n )\n}\n\n/* The methods of a map draft, keeping the copy in sync. */\nconst mapMethods = new Map<PropertyKey, (draft: Draft) => unknown>([\n ['get', draft => (key: unknown) => getMapValue(draft, key)],\n [\n 'set',\n draft => (key: unknown, value: unknown) => {\n const source = current(draft) as Map<unknown, unknown>\n if (!source.has(key) || !Object.is(source.get(key), value)) {\n markModified(draft)\n ;(draft.copy as Map<unknown, unknown>).set(key, value)\n }\n return draft.proxy\n },\n ],\n [\n 'delete',\n draft => (key: unknown) => {\n if (!(current(draft) as Map<unknown, unknown>).has(key)) {\n return false\n }\n markModified(draft)\n return (draft.copy as Map<unknown, unknown>).delete(key)\n },\n ],\n [\n 'clear',\n draft => () => {\n if ((current(draft) as Map<unknown, unknown>).size) {\n markModified(draft)\n ;(draft.copy as Map<unknown, unknown>).clear()\n }\n },\n ],\n [\n 'forEach',\n draft =>\n (\n callback: (value: unknown, key: unknown, map: object) => void,\n thisArg?: unknown,\n ) => {\n for (const key of [\n ...(current(draft) as Map<unknown, unknown>).keys(),\n ]) {\n callback.call(thisArg, getMapValue(draft, key), key, draft.proxy)\n }\n },\n ],\n [\n 'keys',\n draft => () =>\n [...(current(draft) as Map<unknown, unknown>).keys()].values(),\n ],\n [\n 'values',\n draft =>\n function* () {\n for (const key of [\n ...(current(draft) as Map<unknown, unknown>).keys(),\n ]) {\n yield getMapValue(draft, key)\n }\n },\n ],\n ['entries', draft => () => mapEntries(draft)],\n [Symbol.iterator, draft => () => mapEntries(draft)],\n])\n\nfunction* mapEntries(draft: Draft) {\n for (const key of [...(current(draft) as Map<unknown, unknown>).keys()]) {\n yield [key, getMapValue(draft, key)]\n }\n}\n\nconst hasSetItem = (draft: Draft, item: unknown) => {\n const source = current(draft) as Set<unknown>\n if (source.has(item)) {\n return true\n }\n const itemDraft = draft.items?.get(item)\n return itemDraft !== undefined && source.has(itemDraft)\n}\n\n/* The methods of a set draft, iterating over the drafted items. */\nconst setMethods = new Map<PropertyKey, (draft: Draft) => unknown>([\n ['has', draft => (item: unknown) => hasSetItem(draft, item)],\n [\n 'add',\n draft => (item: unknown) => {\n if (!hasSetItem(draft, item)) {\n markModified(draft)\n ;(draft.copy as Set<unknown>).add(item)\n }\n return draft.proxy\n },\n ],\n [\n 'delete',\n draft => (item: unknown) => {\n if (!hasSetItem(draft, item)) {\n return false\n }\n markModified(draft)\n const copy = draft.copy as Set<unknown>\n return copy.delete(item) || copy.delete(draft.items!.get(item))\n },\n ],\n [\n 'clear',\n draft => () => {\n if ((current(draft) as Set<unknown>).size) {\n markModified(draft)\n ;(draft.copy as Set<unknown>).clear()\n }\n },\n ],\n [\n 'forEach',\n draft =>\n (\n callback: (value: unknown, key: unknown, set: object) => void,\n thisArg?: unknown,\n ) => {\n for (const item of setItems(draft)) {\n callback.call(thisArg, item, item, draft.proxy)\n }\n },\n ],\n ['keys', draft => () => setItems(draft).values()],\n ['values', draft => () => setItems(draft).values()],\n [Symbol.iterator, draft => () => setItems(draft).values()],\n [\n 'entries',\n draft => () =>\n setItems(draft)\n .map(item => [item, item] as const)\n .values(),\n ],\n])\n\nconst setItems = (draft: Draft) => {\n prepareCopy(draft)\n return [...(draft.copy as Set<unknown>)]\n}\n\n/*\n * Reads the property of a map, set, date or typed array, keeping their\n * internal slots out of the proxy.\n */\nconst getSlotProperty = (draft: Draft, key: PropertyKey): unknown => {\n if (draft.kind === 'map' || draft.kind === 'set') {\n const method = (draft.kind === 'map' ? mapMethods : setMethods).get(key)\n if (method) {\n return method(draft)\n }\n if (draft.kind === 'set' && key !== 'size') {\n // the other methods, as union(), take the drafted items\n prepareCopy(draft)\n }\n }\n if (draft.kind === 'typed-array' && key === 'buffer') {\n // the memory of the copy, as it can be written to\n markModified(draft)\n return (draft.copy as TypedArray).buffer\n }\n const source = current(draft) as Entries\n if (draft.kind === 'typed-array' && Object.hasOwn(source, key)) {\n return source[key]\n }\n const value = Reflect.get(source, key, source)\n if (typeof value !== 'function' || key === 'constructor') {\n return value\n }\n const method = value as (...args: unknown[]) => unknown\n const mutates =\n draft.kind === 'date'\n ? typeof key === 'string' && key.startsWith('set')\n : draft.kind === 'typed-array' && TYPED_ARRAY_MUTATORS.has(key)\n if (!mutates) {\n return method.bind(source)\n }\n return (...args: unknown[]) => {\n prepareCopy(draft)\n const copy = draft.copy!\n const time = draft.kind === 'date' ? (copy as Date).getTime() : null\n const result = method.apply(copy, args)\n if (draft.kind !== 'date' || !Object.is(time, (copy as Date).getTime())) {\n markModified(draft)\n }\n return result === copy ? draft.proxy : result\n }\n}\n\nconst handler: ProxyHandler<object> = {\n get(target, key) {\n const draft = targets.get(target)!\n return draft.kind === 'object' || draft.kind === 'array'\n ? getProperty(draft, key)\n : getSlotProperty(draft, key)\n },\n set(target, key, value) {\n const draft = targets.get(target)!\n const source = current(draft) as Entries\n if (Object.hasOwn(source, key) && Object.is(source[key], value)) {\n return true\n }\n markModified(draft)\n ;(draft.copy as Entries)[key] = value\n return true\n },\n deleteProperty(target, key) {\n const draft = targets.get(target)!\n if (Object.hasOwn(current(draft), key)) {\n markModified(draft)\n delete (draft.copy as Entries)[key]\n }\n return true\n },\n has(target, key) {\n return key in current(targets.get(target)!)\n },\n ownKeys(target) {\n return Reflect.ownKeys(current(targets.get(target)!))\n },\n getOwnPropertyDescriptor(target, key) {\n const draft = targets.get(target)!\n const source = current(draft) as Entries\n const descriptor = Reflect.getOwnPropertyDescriptor(source, key)\n if (!descriptor) {\n return undefined\n }\n // the length of the array target is not configurable\n const configurable = draft.kind !== 'array' || key !== 'length'\n return 'value' in descriptor\n ? { ...descriptor, value: source[key], writable: true, configurable }\n : { ...descriptor, configurable }\n },\n defineProperty(target, key, descriptor) {\n const draft = targets.get(target)!\n markModified(draft)\n return Reflect.defineProperty(draft.copy!, key, descriptor)\n },\n setPrototypeOf() {\n return false\n },\n preventExtensions() {\n return false\n },\n}\n\n/*\n * Replaces the drafts with their results, also in the new values assigned\n * to the drafts, as the drafts are revoked once the next state is created.\n */\nconst finalize = (value: unknown, scope: Scope): unknown => {\n if (typeof value !== 'object' || value === null) {\n return value\n }\n const draft = drafts.get(value)\n if (draft) {\n return finalizeDraft(draft)\n }\n const kind = checkValue(value)\n if (scope.visited.has(value) || Object.isFrozen(value)) {\n return value\n }\n scope.visited.add(value)\n switch (kind) {\n case 'object':\n case 'array': {\n const entries = value as Entries\n for (const key of Reflect.ownKeys(entries)) {\n const next = finalize(entries[key], scope)\n if (next !== entries[key]) {\n entries[key] = next\n }\n }\n break\n }\n case 'map': {\n const map = value as Map<unknown, unknown>\n for (const [key, item] of map) {\n const next = finalize(item, scope)\n if (next !== item) {\n map.set(key, next)\n }\n }\n break\n }\n case 'set': {\n const set = value as Set<unknown>\n const items = [...set]\n const nextItems = items.map(item => finalize(item, scope))\n if (nextItems.some((item, index) => item !== items[index])) {\n set.clear()\n nextItems.forEach(item => set.add(item))\n }\n break\n }\n }\n return value\n}\n\nconst finalizeDraft = (draft: Draft): object => {\n if (draft.result) {\n return draft.result\n }\n if (!draft.modified) {\n return (draft.result = draft.base)\n }\n const { base, copy, scope } = draft\n draft.result = copy\n switch (draft.kind) {\n case 'object':\n case 'array': {\n const entries = copy as Entries\n for (const key of Reflect.ownKeys(entries)) {\n const value = entries[key]\n if (value !== (base as Entries)[key]) {\n const next = finalize(value, scope)\n if (next !== value) {\n entries[key] = next\n }\n }\n }\n break\n }\n case 'map': {\n const map = copy as Map<unknown, unknown>\n for (const [key, value] of map) {\n if (value !== (base as Map<unknown, unknown>).get(key)) {\n map.set(key, finalize(value, scope))\n }\n }\n break\n }\n case 'set': {\n // in place, for the items referring to the set to get the result\n const set = copy as Set<unknown>\n const items = [...set]\n set.clear()\n items.forEach(item => set.add(finalize(item, scope)))\n break\n }\n }\n return draft.result!\n}\n\n/*\n * Calls the recipe with a draft of the base object and returns the result\n * of the changes made to it, or the base object when nothing has changed.\n * Plain objects, arrays, maps, sets, dates and typed arrays are drafted,\n * primitives and functions are kept as they are, to be replaced only,\n * and other values, as class instances, throw when read or assigned.\n */\nexport const produce = <T>(base: T, recipe: (draft: T) => void): T => {\n const kind = getKind(base)\n invariant(kind, INVALID_VALUE)\n const scope: Scope = { revokes: [], visited: new WeakSet() }\n const root = createDraft(base as object, kind, null, scope)\n try {\n recipe(root as T)\n return finalizeDraft(drafts.get(root)!) as T\n } finally {\n scope.revokes.forEach(revoke => revoke())\n }\n}\n","import { produce } from './draft.js'\nimport type { WebComponent } from './nodes.js'\nimport { runtime } from './runtime.js'\nimport type { AnyFunction } from './utils.js'\n\n/* The state of a root component. */\nexport type State = Record<string, unknown>\n\n/* A state transformation, calculating the next state. */\nexport type StateUpdate<S = State> = (state: S) => S\n\n/*\n * A command changing a draft of the state, available as `this`,\n * which becomes the next immutable state.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- commands take any arguments\nexport type CommandMethod<S> = (this: S, ...args: any[]) => void\n\n/* A map of command names to their methods. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- commands of any state by default\nexport type CommandsAPI<S = any> = Record<string, CommandMethod<S>>\n\n/* The core commands available on every component. */\nexport type Commands<S = State> = {\n update(overrides: Partial<S>): Promise<boolean>\n replace(state: S): Promise<boolean>\n}\n\n/*\n * The commands of an API, called with the arguments of the API methods.\n * They resolve with true once rendered, or with false when ignored.\n */\nexport type BoundCommands<C extends CommandsAPI> = {\n [K in keyof C]: (...args: Parameters<C[K]>) => Promise<boolean>\n}\n\nconst Mode = {\n EXECUTE: Symbol('execute-commands'),\n IGNORE: Symbol('ignore-commands'),\n}\n\n/*\n * The limit of updates in a row, the one with the commands issued together\n * followed by the ones with the commands issued in lifecycle methods.\n */\nconst MAX_FLUSH_CYCLES = 4\n\n/* The core commands, also setting the initial state, with no draft yet. */\nconst coreAPI: Record<keyof Commands, (arg: State) => StateUpdate> = {\n update(overrides) {\n return state => ({\n ...state,\n ...overrides,\n })\n },\n replace(state) {\n return () => state\n },\n}\n\nclass Command {\n declare name: string\n declare args: unknown[]\n declare update: StateUpdate\n declare resolve?: (executed: boolean) => void\n declare reject?: (error: unknown) => void\n\n constructor(name: string, args: unknown[], update: StateUpdate) {\n this.name = name\n this.args = args\n this.update = update\n }\n\n invoke(state: State | undefined): State {\n return this.update(state as State)\n }\n}\n\nconst createCommandsAPI = (...apis: CommandsAPI[]) => {\n const commandsAPI: CommandsAPI = {}\n for (const api of apis) {\n const overridden = Object.keys(api).find(\n key => Object.hasOwn(coreAPI, key) || Object.hasOwn(commandsAPI, key),\n )\n if (overridden) {\n throw new Error(`The \"${overridden}\" command is already defined!`)\n }\n Object.assign(commandsAPI, api)\n }\n return commandsAPI\n}\n\nexport type { Command }\n\n/*\n * Queues the issued commands and executes the ones issued together\n * in a single update, once the current task has completed.\n */\nclass Dispatcher {\n declare mode: symbol\n declare queue: Command[]\n declare isFlushing: boolean\n declare root: WebComponent\n declare api: CommandsAPI\n declare commands: Commands & Record<string, AnyFunction>\n declare names: string[]\n\n ignoreIncoming() {\n this.mode = Mode.IGNORE\n }\n\n constructor(root: WebComponent) {\n this.mode = Mode.EXECUTE\n this.queue = []\n this.isFlushing = false\n this.root = root\n this.commands = {} as Commands & Record<string, AnyFunction>\n\n const { commands = [] } = root.constructor as typeof WebComponent\n this.api = createCommandsAPI(\n ...(Array.isArray(commands) ? commands : [commands]),\n )\n this.names = [...Object.keys(coreAPI), ...Object.keys(this.api)]\n\n for (const name of this.names) {\n this.commands[name] = (...args: unknown[]) => this.issue(name, args)\n }\n }\n\n createCommand(name: string, args: unknown[]) {\n const method = this.api[name]\n const update: StateUpdate = method\n ? state =>\n produce(state, draft => {\n const result: unknown = method.apply(draft, args)\n // the draft is revoked before the rest of an async command runs\n if (result instanceof Promise) {\n result.catch(() => {})\n throw new Error(`The \"${name}\" command must be synchronous!`)\n }\n })\n : coreAPI[name as keyof Commands](...(args as [State]))\n return new Command(name, args, update)\n }\n\n issue(name: string, args: unknown[]): Promise<boolean> {\n if (this.mode === Mode.IGNORE) {\n return Promise.resolve(false)\n }\n const command = this.createCommand(name, args)\n const done = new Promise<boolean>((resolve, reject) => {\n command.resolve = resolve\n command.reject = reject\n })\n this.queue.push(command)\n // the commands issued while flushing are executed in the next cycle\n if (this.queue.length === 1 && !this.isFlushing) {\n queueMicrotask(() => this.flush())\n }\n return done\n }\n\n /**\n * Sets the state right away, when the root is rendered or receives\n * new props from its parent.\n */\n setState(state: State) {\n if (this.mode === Mode.IGNORE) {\n return\n }\n this.execute([this.createCommand('replace', [state])])\n }\n\n /**\n * Updates the root with the state calculated by the commands in turn.\n */\n execute(commands: Command[]) {\n const prevState = this.root.state as State | undefined\n const nextState = commands.reduce<State | undefined>(\n (state, command) => command.invoke(state),\n prevState,\n )!\n runtime().update(this.root, prevState, nextState, commands)\n }\n\n /**\n * Executes the queued commands, followed by the ones issued in lifecycle\n * methods in turn, until there are none left. When an update fails, its\n * commands reject, and the ones issued in its lifecycle methods are still\n * executed, as the update is completed.\n */\n flush() {\n this.isFlushing = true\n try {\n for (let cycle = 1; this.queue.length; cycle++) {\n const commands = this.queue.splice(0)\n // the root can be destroyed before the queued commands are executed\n if (this.mode === Mode.IGNORE) {\n commands.forEach(command => command.resolve!(false))\n continue\n }\n try {\n if (cycle > MAX_FLUSH_CYCLES) {\n throw new Error(\n 'Too many cycles updating state in lifecycle methods!',\n )\n }\n this.execute(commands)\n } catch (error) {\n commands.forEach(command => command.reject!(error))\n continue\n }\n commands.forEach(command => command.resolve!(true))\n }\n } finally {\n this.isFlushing = false\n }\n }\n}\n\nexport default Dispatcher\n","import ChildNodes from './child-nodes.js'\nimport Comment from './comment.js'\nimport Component from './component.js'\nimport CreatedRoots from './created-roots.js'\nimport { createComponentElement } from './custom-element.js'\nimport { CommentDescription, type ComponentDescription } from './description.js'\nimport Dispatcher, {\n type BoundCommands,\n type Commands,\n type CommandsAPI,\n type State,\n} from './dispatcher.js'\nimport Plugins from './plugins.js'\nimport { runtime } from './runtime.js'\nimport Template from './template.js'\nimport type VirtualNode from './virtual-node.js'\nimport type { NodeRef } from './virtual-node.js'\n\nconst CONTAINER = Symbol('container')\nconst CUSTOM_ELEMENT = Symbol('custom-element')\nconst DISPATCHER = Symbol('dispatcher')\n\n/*\n * A root component with its own state, commands and plugins, rendered\n * in a custom element when elementName is defined.\n *\n * P: props received from the parent,\n * S: state, available as `this.props` when rendering,\n * C: commands API set as the static commands, changing the state.\n */\nclass WebComponent<\n P extends object = object,\n S extends object = P,\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- no commands besides the core ones\n C extends CommandsAPI<S> = {},\n> extends Component<S> {\n static NodeType = 'root'\n\n static styles: string[] = []\n\n /*\n * The child nodes rendered in the light DOM of the custom element,\n * separate from the `children` templates available when rendering.\n */\n declare childNodes?: VirtualNode[]\n declare subroots: Set<WebComponent>\n declare ready: Promise<void>\n declare markAsReady: () => void\n declare markAsFailed: (error: Error) => void\n declare plugins: Plugins | null\n declare shadow: ShadowRoot | null\n declare state?: S\n declare pendingDescription?: ComponentDescription\n declare stopTracking?: () => void\n declare elementClass?: CustomElementConstructor;\n declare [CONTAINER]?: Element;\n declare [CUSTOM_ELEMENT]?: HTMLElement | null;\n declare [DISPATCHER]: Dispatcher\n\n constructor(\n description: ComponentDescription,\n parent: VirtualNode | null = null,\n context: WebComponent | null = null,\n ) {\n super(description, parent, context, /*= attachDOM */ false)\n // before being tracked, to be destroyed when rendering it fails\n CreatedRoots.collectRoot(this)\n this.subroots = new Set()\n this.dispatcher = new Dispatcher(this)\n this.ready = new Promise((resolve, reject) => {\n this.markAsReady = resolve\n this.markAsFailed = reject\n })\n this.plugins = this.createPlugins()\n // from the start, for the plugins to be replaced when reconfigured\n runtime().track(this)\n this.content = this.createPlaceholder()\n this.shadow = null\n this.attachDOM()\n }\n\n attachDOM() {\n if ((this.constructor as typeof WebComponent).elementName) {\n this.ref = createComponentElement(this)\n this.plugins!.installAll()\n } else {\n this.plugins!.installAll()\n super.attachDOM()\n }\n }\n\n createPlaceholder(): VirtualNode {\n return new Comment(\n new CommentDescription(\n (this.constructor as typeof WebComponent).displayName,\n ),\n )\n }\n\n /**\n * Triggers the initial rendering of the component in given container.\n */\n async init() {\n // props are passed from templates, which are not checked against P\n const state = await this.getInitialState.call(\n this.sandbox,\n (this.description.props || {}) as P,\n )\n this.setState(state)\n\n if (this.pendingDescription) {\n const description = this.pendingDescription\n delete this.pendingDescription\n setTimeout(() => this.update(description))\n }\n this.isInitialized = true\n this.markAsReady()\n }\n\n setState(state: S) {\n if (state.constructor !== Object) {\n throw new Error('Web Component state must be a plain object!')\n }\n this.dispatcher.setState(\n Template.normalizeComponentProps(\n state as State,\n this.constructor as typeof WebComponent,\n ),\n )\n }\n\n /**\n * Triggers the component update.\n */\n update(description: ComponentDescription) {\n if (!this.isInitialized) {\n this.pendingDescription = description\n return\n }\n const state = this.getUpdatedState(\n (description.props || {}) as P,\n this.state || ({} as S),\n )\n this.setState(state)\n }\n\n /**\n * The default implementation delegating the calculation of initial state\n * to the state manager.\n */\n getInitialState(props: P): S | Promise<S> {\n // the default state is a copy of the props\n return { ...props } as unknown as S\n }\n\n /**\n * The default implementation delegating the calculation of updated state\n * to the state manager.\n */\n getUpdatedState(props: P, state: S): S {\n return {\n ...state,\n ...props,\n }\n }\n\n get dispatcher(): Dispatcher {\n return this[DISPATCHER]\n }\n\n set dispatcher(dispatcher: Dispatcher) {\n this[DISPATCHER] = dispatcher\n }\n\n get commands(): Commands<S> & BoundCommands<C> {\n return this.dispatcher.commands as Commands<S> & BoundCommands<C>\n }\n\n createPlugins(): Plugins {\n const plugins = new Plugins(this)\n const inherited = this.parentNode\n ? (this.parentNode as WebComponent).plugins\n : runtime().plugins\n for (const plugin of inherited!) {\n plugins.register(plugin)\n }\n return plugins\n }\n\n async mount(container: Element): Promise<this> {\n if ((this.constructor as typeof WebComponent).elementName) {\n // triggers this.init() from element's connected callback\n container.appendChild(this.ref)\n await this.ready\n } else {\n this.container = container\n await this.init()\n }\n return this\n }\n\n getStylesheets(): string[] {\n const stylesheets: string[] = []\n const stylesheetProviders = [...this.plugins!].filter(plugin =>\n plugin.isStylesheetProvider(),\n )\n for (const plugin of stylesheetProviders) {\n if (typeof plugin.getStylesheets !== 'function') {\n throw new Error(\n `Plugin '${plugin.name}' must provide the getStylesheets() method!`,\n )\n }\n stylesheets.push(...plugin.getStylesheets())\n }\n const RootClass = this.constructor as typeof WebComponent\n if (Array.isArray(RootClass.styles)) {\n stylesheets.push(...RootClass.styles)\n }\n return stylesheets\n }\n\n get ref(): NodeRef {\n return this[CUSTOM_ELEMENT] || super.ref\n }\n\n set ref(ref: HTMLElement | null) {\n this[CUSTOM_ELEMENT] = ref\n }\n\n set container(container: Element | undefined) {\n this[CONTAINER] = container\n }\n\n get container(): Element | undefined {\n return this[CONTAINER]\n }\n\n get tracked(): WebComponent[] {\n const tracked: WebComponent[] = []\n for (const root of this.subroots) {\n tracked.push(root, ...root.tracked)\n }\n return tracked\n }\n\n destroy() {\n if (!this.plugins) {\n // already destroyed\n return\n }\n super.destroy()\n // not tracked when destroyed before being initialized\n this.stopTracking?.()\n this.dispatcher.ignoreIncoming()\n this.plugins.destroy()\n this.plugins = null\n this.parentNode = null\n }\n\n setChildNodes(nodes: VirtualNode[]) {\n ChildNodes.set(this, nodes)\n }\n\n insertChild(child: VirtualNode, index?: number) {\n ChildNodes.insert(this, child, index)\n }\n\n replaceChild(child: VirtualNode, node: VirtualNode) {\n ChildNodes.replace(this, child, node)\n }\n\n moveChild(child: VirtualNode, from: number, to: number) {\n ChildNodes.move(this, child, from, to)\n }\n\n removeChild(child: VirtualNode) {\n ChildNodes.remove(this, child)\n }\n\n get nodeType(): string {\n return WebComponent.NodeType\n }\n}\n\nexport default WebComponent\n","import { runtime } from './runtime.js'\n\nclass Service {\n declare static events: string[]\n\n static validate(listeners: Record<string, unknown>): string[] {\n if (runtime().isDebug()) {\n const keys = Object.keys(listeners)\n runtime().assert(\n this.events instanceof Array,\n `Service \"${this.name}\" does not provide information about valid events, implement \"static events = ['foo', 'bar']\"`,\n )\n runtime().assert(\n this.events.length > 0,\n `Service \"${this.name}\" returned an empty list of valid events, the \"static events\" list must contain at least one event name`,\n )\n const unsupportedKeys = keys.filter(key => !this.events.includes(key))\n for (const unsupportedKey of unsupportedKeys) {\n runtime().warn(\n `Unsupported listener specified \"${unsupportedKey}\" when connecting to ${this.name}`,\n )\n }\n const supportedKeys = this.events.filter(event => keys.includes(event))\n runtime().assert(\n supportedKeys.length > 0,\n `No valid listener specified when connecting to ${this.name}, use one of [${this.events.join(', ')}]`,\n )\n for (const supportedKey of supportedKeys) {\n runtime().assert(\n listeners[supportedKey] instanceof Function,\n `Specified listener \"${supportedKey}\" for ${this.name} is not a function`,\n )\n }\n }\n return this.events.filter(event => listeners[event] instanceof Function)\n }\n}\n\nexport default Service\n","const Name = {\n INSERT: Symbol('insert'),\n MOVE: Symbol('move'),\n REMOVE: Symbol('remove'),\n}\n\ninterface MoveProps {\n at?: number\n from?: number\n to?: number\n}\n\nclass Move<T = unknown> {\n static Name = Name\n\n declare name: symbol\n declare item: T\n declare at?: number\n declare from?: number\n declare to?: number\n declare make: (items: T[]) => void\n\n constructor(\n name: symbol,\n item: T,\n props: MoveProps,\n make: (items: T[]) => void,\n ) {\n this.name = name\n this.item = item\n this.at = props.at\n this.from = props.from\n this.to = props.to\n this.make = make\n }\n\n static insert<T>(item: T, at: number): Move<T> {\n return new Move(Name.INSERT, item, { at }, items => {\n items.splice(at, 0, item)\n })\n }\n\n static move<T>(item: T, from: number, to: number): Move<T> {\n return new Move(Name.MOVE, item, { from, to }, items => {\n items.splice(from, 1)\n items.splice(to, 0, item)\n })\n }\n\n static remove<T>(item: T, at: number): Move<T> {\n return new Move(Name.REMOVE, item, { at }, items => {\n items.splice(at, 1)\n })\n }\n}\n\n/* The moves transforming the source into the target, with the result. */\nexport type Moves = Move<string>[] & { result?: string[] }\n\ninterface Item {\n key: string\n index: number\n}\n\nconst Reconciler = {\n comparator(this: void, a: Item, b: Item): number {\n if (Object.is(a.key, b.key)) {\n return 0\n }\n return a.key > b.key ? 1 : -1\n },\n\n calculateMoves(source: string[], target: string[]): Moves {\n const moves: Moves = []\n\n const createItem = function (key: string, index: number): Item {\n return { key, index }\n }\n\n const before = source.map(createItem).sort(this.comparator)\n const after = target.map(createItem).sort(this.comparator)\n\n let removed: Item[] = []\n let inserted: Item[] = []\n\n while (before.length || after.length) {\n if (!before.length) {\n inserted = inserted.concat(after)\n break\n }\n if (!after.length) {\n removed = removed.concat(before)\n break\n }\n const result = this.comparator(after[0]!, before[0]!)\n if (result === 0) {\n before.shift()\n after.shift()\n } else if (result === 1) {\n removed.push(before.shift()!)\n } else {\n inserted.push(after.shift()!)\n }\n }\n\n const sortByIndex = function (foo: Item, bar: Item) {\n return foo.index - bar.index\n }\n\n removed.sort(sortByIndex).reverse()\n inserted.sort(sortByIndex)\n\n const result = [...source]\n\n for (const item of removed) {\n const move = Move.remove(item.key, item.index)\n move.make(result)\n moves.push(move)\n }\n for (const item of inserted) {\n const move = Move.insert(item.key, item.index)\n move.make(result)\n moves.push(move)\n }\n\n if (\n result.length === target.length &&\n result.every((key, index) => key === target[index])\n ) {\n moves.result = result\n return moves\n }\n\n const calculateIndexChanges = (\n source: string[],\n target: string[],\n reversed = false,\n ) => {\n const moves: Moves = []\n\n const moveItemIfNeeded = (index: number) => {\n const item = target[index]!\n if (source[index] !== item) {\n const from = source.indexOf(item)\n const move = Move.move(item, from, index)\n move.make(source)\n moves.push(move)\n }\n }\n\n if (reversed) {\n for (let i = target.length - 1; i >= 0; i--) {\n moveItemIfNeeded(i)\n }\n } else {\n for (let i = 0; i < target.length; i++) {\n moveItemIfNeeded(i)\n }\n }\n moves.result = source\n return moves\n }\n\n const defaultMoves = calculateIndexChanges([...result], target)\n if (defaultMoves.length > 1) {\n const alternativeMoves = calculateIndexChanges(\n [...result],\n target,\n /*= reversed */ true,\n )\n if (alternativeMoves.length <= defaultMoves.length) {\n moves.push(...alternativeMoves)\n moves.result = alternativeMoves.result\n return moves\n }\n }\n moves.push(...defaultMoves)\n moves.result = defaultMoves.result\n return moves\n },\n\n Move,\n}\n\nexport default Reconciler\n","import type { ComponentDescription, NodeDescription } from './description.js'\nimport {\n Comment,\n type Component,\n type ParentVirtualNode,\n Text,\n VirtualElement,\n type VirtualNode,\n WebComponent,\n} from './nodes.js'\n\nconst VirtualDOM = {\n /**\n * Creates a new Virtual DOM structure from given description.\n */\n createFromDescription(\n description: NodeDescription | null,\n parent?: VirtualNode | null,\n context?: WebComponent | null,\n ): VirtualNode | null {\n if (!description) {\n return null\n }\n switch (description.type) {\n case 'component':\n return this.createComponent(description, parent, context)\n case 'element': {\n const element = new VirtualElement(description, parent, context)\n this.createChildNodes(element)\n return element\n }\n case 'comment':\n return new Comment(description, parent!)\n case 'text':\n return new Text(description, parent!)\n default:\n throw new Error(\n `Unsupported node type: ${(description as NodeDescription).type}`,\n )\n }\n },\n\n /**\n * Creates the child nodes of an element or a Web Component.\n */\n createChildNodes(parent: ParentVirtualNode) {\n const { children } = parent.description\n if (children) {\n parent.setChildNodes(\n children.map(description =>\n this.createFromDescription(description, parent, parent.context)!,\n ),\n )\n }\n },\n\n /**\n * Creates a new component instance from given description.\n */\n createComponent(\n description: ComponentDescription,\n parent?: VirtualNode | null,\n context?: WebComponent | null,\n ): Component {\n const ComponentClass = description.component\n if (ComponentClass.prototype instanceof WebComponent) {\n return this.createWebComponent(\n description,\n parent && parent.rootNode,\n context,\n /*= requireCustomElement */ true,\n )\n }\n const component = new ComponentClass(description, parent, context)\n const nodeDescription = component.renderDescription(\n description.props,\n description.childrenAsTemplates,\n )\n component.content = this.createFromDescription(\n nodeDescription,\n component,\n context,\n )\n return component\n },\n\n /**\n * Creates a new Web Component instance from given description.\n */\n createWebComponent(\n description: ComponentDescription,\n parent?: VirtualNode | null,\n context?: WebComponent | null,\n requireCustomElement = false,\n ): WebComponent {\n try {\n const ComponentClass = description.component as typeof WebComponent\n if (requireCustomElement && !ComponentClass.elementName) {\n throw new Error(\n `Root component \"${\n ComponentClass.displayName\n }\" does not define custom element name!`,\n )\n }\n const root = new ComponentClass(description, parent, context)\n if (ComponentClass.elementName) {\n // rendered in the light DOM of the custom element\n this.createChildNodes(root)\n }\n return root\n } catch (error) {\n console.error('Error rendering root component:', description)\n throw error\n }\n },\n}\n\nexport default VirtualDOM\n","import type {\n ComponentDescription,\n ElementDescription,\n Listener,\n NodeDescription,\n} from './description.js'\nimport CreatedRoots from './created-roots.js'\nimport Lifecycle, { throwErrors } from './lifecycle.js'\nimport type {\n Component,\n ParentVirtualNode,\n VirtualElement,\n VirtualNode,\n WebComponent,\n} from './nodes.js'\nimport Patch from './patch.js'\nimport Reconciler from './reconciler.js'\nimport type { State } from './dispatcher.js'\nimport Template from './template.js'\nimport { runtime } from './runtime.js'\nimport VirtualDOM from './virtual-dom.js'\n\n/*\n * Returns the keys added to, removed from and changed in the next object,\n * in the order of the objects.\n */\nconst compareKeys = <T>(\n current: Record<string, T>,\n next: Record<string, T>,\n isEqual: (value: T, nextValue: T) => boolean = (value, nextValue) =>\n value === nextValue,\n) => {\n const keys = Object.keys(current)\n const nextKeys = Object.keys(next)\n return {\n added: nextKeys.filter(key => !keys.includes(key)),\n removed: keys.filter(key => !nextKeys.includes(key)),\n changed: keys.filter(\n key => nextKeys.includes(key) && !isEqual(current[key]!, next[key]!),\n ),\n }\n}\n\nclass Diff {\n declare root: WebComponent\n declare patches: Patch[]\n\n /**\n * Creates a new instance bound to a root component\n * with an empty list of patches.\n */\n constructor(\n root: WebComponent,\n currentState: State | undefined,\n nextState: State,\n ) {\n this.root = root\n this.patches = []\n // nothing is applied when the calculation fails, e.g. when rendering\n CreatedRoots.destroyingRootsOnError(() =>\n this.calculate(currentState, nextState),\n )\n }\n\n /**\n * Adds the patch to the underlying list.\n */\n addPatch(patch: Patch) {\n return this.patches.push(patch)\n }\n\n /**\n * Applies all the patches onto the bound root node.\n */\n apply(): Patch[] {\n if (this.patches.length) {\n // the update is completed when hooks or patches throw, as stopping\n // would leave the DOM, the virtual nodes and the hooks called out of\n // sync, and the errors are thrown once it is applied\n const errors: unknown[] = []\n Lifecycle.collectingErrors(errors, () =>\n Lifecycle.beforeUpdate(this.patches),\n )\n // a nested root failing to render its props keeps its description,\n // to render them on the next update\n const failedRoots = new Set<VirtualNode>()\n const applied: Patch[] = []\n for (const patch of this.patches) {\n if (\n patch.type === Patch.Type.UPDATE_NODE &&\n failedRoots.has(patch.node)\n ) {\n continue\n }\n try {\n Patch.apply(patch)\n } catch (error) {\n errors.push(error)\n if (patch.type === Patch.Type.UPDATE_ROOT) {\n failedRoots.add(patch.root)\n }\n continue\n }\n applied.push(patch)\n }\n Lifecycle.collectingErrors(errors, () => Lifecycle.afterUpdate(applied))\n throwErrors(errors, 'Errors applying the update')\n }\n return this.patches\n }\n\n /**\n * Calculates and returns all patches needed for transformation\n * of the rendered DOM fragment from one state to another.\n */\n calculate(currentState: State | undefined, nextState: State) {\n if (!currentState) {\n this.addPatch(Patch.initRootComponent(this.root))\n }\n\n if (Diff.deepEqual(currentState, nextState)) {\n return\n }\n\n const template: unknown[] = [this.root.constructor, nextState]\n if (this.root.description.children) {\n template.push(\n ...this.root.description.children.map(child => child.asTemplate),\n )\n }\n\n const description = Template.describe(template) as ComponentDescription\n\n // the root is rendered initially even when the description is equal\n if (\n !this.root.isInitialized ||\n !Diff.deepEqual(this.root.description, description)\n ) {\n this.componentPatches(this.root, description)\n }\n if (this.root.description.attrs || description.attrs) {\n this.attributePatches(\n this.root.description.attrs,\n description.attrs,\n this.root,\n true,\n )\n }\n }\n\n /**\n * Renders the descendants with normalized props and children passed\n * from the parent component.\n *\n * Calculates the patches needed for transformation of a component\n * to match the given description.\n */\n componentPatches(component: Component, description: ComponentDescription) {\n const nodeDescription = component.renderDescription(\n description.props,\n description.childrenAsTemplates,\n )\n this.componentContentPatches(nodeDescription, component)\n\n this.addPatch(Patch.updateNode(component, description))\n }\n\n componentContentPatches(\n description: NodeDescription | null,\n parent: Component,\n ) {\n const content = parent.content\n\n if (!content && !description) {\n return\n }\n\n // content and description are either both present or both missing\n if (!content || !description) {\n throw new Error('Invalid component state!')\n }\n\n // update\n if (content.description.isCompatible(description)) {\n this.childPatches(content, description)\n return\n }\n\n // replace\n const node = VirtualDOM.createFromDescription(\n description,\n parent,\n this.root,\n )\n this.addPatch(Patch.setContent(node!, parent))\n }\n\n /**\n * Calculates patches for transformation of specified child node\n * to match given description.\n */\n childPatches(child: VirtualNode, description: NodeDescription): void {\n // the only comparison of the descriptions, as they are compared deeply\n if (Diff.deepEqual(child.description, description)) {\n return\n }\n if (child.isComponent()) {\n if (child.isRoot()) {\n // the child nodes of a Web Component are rendered in the light DOM\n this.childrenPatches(child.childNodes, description.children, child)\n // the root renders its own content when the patches are applied,\n // before the node is updated, as it compares its description\n this.addPatch(\n Patch.updateRoot(child, description as ComponentDescription),\n )\n this.addPatch(Patch.updateNode(child, description))\n return\n }\n return this.componentPatches(child, description as ComponentDescription)\n }\n if (child.isElement()) {\n return this.elementPatches(child, description as ElementDescription)\n }\n throw new Error(`Unsupported node type: ${child.nodeType}`)\n }\n\n /**\n * Calculates patches for transformation of an element to match given\n * description.\n */\n elementPatches(element: VirtualElement, description: ElementDescription) {\n this.classNamePatches(element.description.class, description.class, element)\n this.stylePatches(element.description.style, description.style, element)\n this.attributePatches(element.description.attrs, description.attrs, element)\n this.listenerPatches(\n element.description.listeners,\n description.listeners,\n element,\n )\n this.datasetPatches(\n element.description.dataset,\n description.dataset,\n element,\n )\n this.propertiesPatches(\n element.description.properties,\n description.properties,\n element,\n )\n\n if (element.description.custom || description.custom) {\n this.attributePatches(\n element.description.custom && element.description.custom.attrs,\n description.custom && description.custom.attrs,\n element,\n true,\n )\n this.listenerPatches(\n element.description.custom && element.description.custom.listeners,\n description.custom && description.custom.listeners,\n element,\n true,\n )\n }\n\n if (element.children || description.children) {\n this.childrenPatches(element.children, description.children, element)\n }\n this.addPatch(Patch.updateNode(element, description))\n }\n\n classNamePatches(current = '', next = '', target: VirtualElement) {\n if (current !== next) {\n this.addPatch(Patch.setClassName(next, target))\n }\n }\n\n stylePatches(\n current: Record<string, string> = {},\n next: Record<string, string> = {},\n target: VirtualElement,\n ) {\n const { added, removed, changed } = compareKeys(current, next)\n\n for (const prop of added) {\n this.addPatch(Patch.setStyleProperty(prop, next[prop]!, target))\n }\n for (const prop of removed) {\n this.addPatch(Patch.removeStyleProperty(prop, target))\n }\n for (const prop of changed) {\n this.addPatch(Patch.setStyleProperty(prop, next[prop]!, target))\n }\n }\n\n attributePatches(\n current: Record<string, string> = {},\n next: Record<string, string> = {},\n target: VirtualElement | WebComponent,\n isCustom = false,\n ) {\n const { added, removed, changed } = compareKeys(current, next)\n\n for (const attr of added) {\n this.addPatch(Patch.setAttribute(attr, next[attr]!, target, isCustom))\n }\n for (const attr of removed) {\n this.addPatch(Patch.removeAttribute(attr, target, isCustom))\n }\n for (const attr of changed) {\n this.addPatch(Patch.setAttribute(attr, next[attr]!, target, isCustom))\n }\n }\n\n listenerPatches(\n current: Record<string, Listener> = {},\n next: Record<string, Listener> = {},\n target: VirtualElement,\n isCustom = false,\n ) {\n // listeners bound by the sandbox are equal when bound to the same method\n const { added, removed, changed } = compareKeys(\n current,\n next,\n (listener, nextListener) =>\n listener === nextListener ||\n (listener.source !== undefined &&\n listener.source === nextListener.source),\n )\n\n for (const event of added) {\n this.addPatch(Patch.addListener(event, next[event]!, target, isCustom))\n }\n for (const event of removed) {\n this.addPatch(\n Patch.removeListener(event, current[event]!, target, isCustom),\n )\n }\n for (const event of changed) {\n this.addPatch(\n Patch.replaceListener(\n event,\n current[event]!,\n next[event]!,\n target,\n isCustom,\n ),\n )\n }\n }\n\n datasetPatches(\n current: Record<string, string> = {},\n next: Record<string, string> = {},\n target: VirtualElement,\n ) {\n const { added, removed, changed } = compareKeys(current, next)\n\n for (const attr of added) {\n this.addPatch(Patch.setDataAttribute(attr, next[attr]!, target))\n }\n for (const attr of removed) {\n this.addPatch(Patch.removeDataAttribute(attr, target))\n }\n for (const attr of changed) {\n this.addPatch(Patch.setDataAttribute(attr, next[attr]!, target))\n }\n }\n\n propertiesPatches(\n current: Record<string, unknown> = {},\n next: Record<string, unknown> = {},\n target: VirtualElement,\n ) {\n const { added, removed, changed } = compareKeys(\n current,\n next,\n (value, nextValue) => Diff.deepEqual(value, nextValue),\n )\n\n for (const key of added) {\n this.addPatch(Patch.setProperty(key, next[key], target))\n }\n for (const key of removed) {\n this.addPatch(Patch.deleteProperty(key, target))\n }\n for (const key of changed) {\n this.addPatch(Patch.setProperty(key, next[key], target))\n }\n }\n\n childrenPatches(\n sourceNodes: VirtualNode[] = [],\n targetDescriptions: NodeDescription[] = [],\n parent: ParentVirtualNode,\n ) {\n const Move = Reconciler.Move\n\n const created = new Set<VirtualNode>()\n const createdNodesMap = new Map<string, VirtualNode>()\n\n const createNode = (description: NodeDescription, key: string) => {\n const node = VirtualDOM.createFromDescription(\n description,\n parent,\n this.root,\n )\n created.add(node!)\n createdNodesMap.set(key, node!)\n return node!\n }\n\n const from = sourceNodes.map(\n (node, index) => node.key || Diff.createKey(index),\n )\n const to = targetDescriptions.map(\n (description, index) => description.key || Diff.createKey(index),\n )\n\n if (runtime().isDebug()) {\n const assertUniqueKeys = (keys: string[]) => {\n if (keys.length) {\n const uniqueKeys = [...new Set(keys)]\n if (uniqueKeys.length !== keys.length) {\n throw new Error(`Non-unique keys detected in: ${keys.join(', ')}`)\n }\n }\n }\n assertUniqueKeys(from)\n assertUniqueKeys(to)\n }\n\n // with the same keys in the same order, there are no nodes to move\n if (from.length === to.length && from.every((key, i) => key === to[i])) {\n for (let i = 0; i < sourceNodes.length; i++) {\n this.elementChildPatches(\n sourceNodes[i]!,\n targetDescriptions[i]!,\n parent,\n )\n }\n return\n }\n\n // the first of the items with the same key, which only debug rejects\n const mapByKey = <T>(keys: string[], items: T[]) => {\n const map = new Map<string, T>()\n keys.forEach((key, index) => {\n if (!map.has(key)) {\n map.set(key, items[index]!)\n }\n })\n return map\n }\n const sourceNodesMap = mapByKey(from, sourceNodes)\n const targetDescriptionsMap = mapByKey(to, targetDescriptions)\n\n const getNode = (key: string, isMove: boolean): VirtualNode => {\n const sourceNode = sourceNodesMap.get(key)\n if (sourceNode) {\n return sourceNode\n }\n if (isMove) {\n return createdNodesMap.get(key)!\n }\n return createNode(targetDescriptionsMap.get(key)!, key)\n }\n\n const moves = Reconciler.calculateMoves(from, to)\n\n const children = [...sourceNodes]\n for (const move of moves) {\n const node = getNode(move.item, move.name === Move.Name.MOVE)\n switch (move.name) {\n case Move.Name.REMOVE:\n this.addPatch(Patch.removeChild(node, move.at!, parent))\n Move.remove(node, move.at!).make(children)\n continue\n case Move.Name.INSERT:\n this.addPatch(Patch.insertChild(node, move.at!, parent))\n Move.insert(node, move.at!).make(children)\n continue\n case Move.Name.MOVE:\n this.addPatch(Patch.moveChild(node, move.from!, move.to!, parent))\n Move.move(node, move.from!, move.to!).make(children)\n continue\n }\n }\n for (let i = 0; i < children.length; i++) {\n const child = children[i]!\n if (!created.has(child)) {\n const targetDescription = targetDescriptions[i]!\n this.elementChildPatches(child, targetDescription, parent)\n }\n }\n }\n\n elementChildPatches(\n child: VirtualNode,\n description: NodeDescription,\n parent: ParentVirtualNode,\n ) {\n if (child.description.isCompatible(description)) {\n this.childPatches(child, description)\n } else {\n const node = VirtualDOM.createFromDescription(\n description,\n parent,\n this.root,\n )\n this.addPatch(Patch.replaceChild(child, node!, parent))\n }\n }\n\n /**\n * Returns a normalized type of given item.\n */\n static getType(item: unknown): string {\n const type = typeof item\n if (type !== 'object') {\n return type\n }\n if (item === null) {\n return 'null'\n }\n if (Array.isArray(item)) {\n return 'array'\n }\n return 'object'\n }\n\n static createKey(index: number): string {\n return String(index).padStart(8, '0')\n }\n\n static deepEqual(current: unknown, next: unknown): boolean {\n if (Object.is(current, next)) {\n return true\n }\n const type = this.getType(current)\n const nextType = this.getType(next)\n if (type !== nextType) {\n return false\n }\n if (type === 'array') {\n const currentArray = current as unknown[]\n const nextArray = next as unknown[]\n if (currentArray.length !== nextArray.length) {\n return false\n }\n for (let i = 0; i < currentArray.length; i++) {\n const equal = this.deepEqual(currentArray[i], nextArray[i])\n if (!equal) {\n return false\n }\n }\n return true\n } else if (type === 'object') {\n const currentObject = current as Record<string, unknown>\n const nextObject = next as Record<string, unknown>\n if (currentObject.constructor !== nextObject.constructor) {\n return false\n }\n // these keep their values in internal slots, not in own keys\n if (current instanceof Date) {\n return Object.is(current.getTime(), (next as Date).getTime())\n }\n if (current instanceof Map || current instanceof Set) {\n return this.deepEqual([...current], [...(next as typeof current)])\n }\n const keys = Object.keys(currentObject)\n if (keys.length !== Object.keys(nextObject).length) {\n return false\n }\n // with as many keys, the same keys when each one is in both objects\n for (const key of keys) {\n if (\n !Object.prototype.propertyIsEnumerable.call(nextObject, key) ||\n !this.deepEqual(currentObject[key], nextObject[key])\n ) {\n return false\n }\n }\n return true\n }\n return false\n }\n}\n\nexport default Diff\n","import type { NodeDescription, Props } from './description.js'\nimport Diff from './diff.js'\nimport type { Command, State } from './dispatcher.js'\nimport type { Component, WebComponent } from './nodes.js'\nimport type Patch from './patch.js'\n\n/* Information about a root component update, passed to plugin listeners. */\nexport interface Update {\n commands: Command[]\n root: WebComponent\n state: {\n from: State | undefined\n to: State\n }\n patches?: Patch[]\n}\n\nconst Renderer = {\n /**\n * Calls the component render method and transforms the returned template\n * into the normalised description of the rendered node.\n */\n render(\n component: Component,\n props: Props = {},\n children: unknown[] = [],\n ): NodeDescription | null {\n return component.renderDescription(props, children)\n },\n\n /**\n * Updates the Web component and patches the DOM tree\n * to match the new component state.\n */\n update(\n root: WebComponent,\n from: State | undefined,\n to: State,\n commands: Command[],\n ) {\n const update: Update = {\n commands,\n root,\n state: {\n from,\n to,\n },\n }\n\n this.onBeforeUpdate(update, root)\n\n const diff = new Diff(root, from, to)\n // set when the patches are calculated, kept when rendering them fails\n root.state = to\n update.patches = diff.apply()\n\n this.onAfterUpdate(update, root)\n },\n\n /**\n * Notifies the observers about upcoming update.\n */\n onBeforeUpdate(update: Update, root: WebComponent) {\n root.plugins!.notify('before-update', update)\n },\n\n /**\n * Notifies the observers about completed update.\n */\n onAfterUpdate(update: Update, root: WebComponent) {\n root.plugins!.notify('after-update', update)\n },\n}\n\nexport default Renderer\n","import type { PureComponent, RenderResult } from './bragi.js'\nimport CreatedRoots from './created-roots.js'\nimport { updateStylesheets } from './custom-element.js'\nimport type { ComponentDescription, Props } from './description.js'\nimport { Component, type ComponentClass, WebComponent } from './nodes.js'\nimport Plugins, { type PluginManifest } from './plugins.js'\nimport Renderer from './renderer.js'\nimport { provideRuntime } from './runtime.js'\nimport Sandbox from './sandbox.js'\nimport Template, { type ItemType } from './template.js'\nimport { isSameList } from './utils.js'\nimport VirtualDOM from './virtual-dom.js'\n\nexport interface Settings {\n readonly debug: boolean\n}\n\nexport interface Options {\n debug?: boolean\n plugins?: PluginManifest[]\n}\n\n/*\n * The state used by the core modules through the runtime, kept out of\n * the public Toolkit instance.\n */\n\n/* The top-level root components, tracking their subroots. */\nconst roots = new Set<WebComponent>()\n\n/* The settings used until Toolkit is configured. */\nconst defaultSettings: Settings = Object.freeze({ debug: false })\n\n/* Function to Component mapping. */\nconst pureComponentClassRegistry = new Map<PureComponent, ComponentClass>()\n\nconst createPlugins = (manifests: PluginManifest[] = []): Plugins => {\n const plugins = new Plugins(null)\n for (const manifest of manifests) {\n plugins.register(manifest)\n }\n return plugins\n}\n\n/* The plugins configured for all root components. */\nlet plugins = createPlugins()\n\n/**\n * Returns a PureComponent class rendering the template\n * provided by the specified function.\n */\nconst resolvePureComponentClass = (fn: PureComponent): ComponentClass => {\n let ComponentClass = pureComponentClassRegistry.get(fn)\n if (ComponentClass) {\n return ComponentClass\n }\n ComponentClass = class PureComponent extends Component {\n static renderer = fn\n\n render(): RenderResult {\n // the props type of a pure component is not known here\n return fn.call(this, this.props as never)\n }\n }\n pureComponentClassRegistry.set(fn, ComponentClass)\n return ComponentClass\n}\n\n/**\n * Returns resolved Component class.\n */\nconst resolveComponentClass = (\n component: unknown,\n type: ItemType,\n): ComponentClass => {\n switch (type) {\n case 'component':\n return component as ComponentClass\n case 'function':\n return resolvePureComponentClass(component as PureComponent)\n default:\n throw new Error(`Unsupported component type: ${type}`)\n }\n}\n\nconst track = (root: WebComponent) => {\n if (root.parentNode) {\n const parentRootNode = root.parentNode.rootNode\n parentRootNode.subroots.add(root)\n root.stopTracking = () => {\n parentRootNode.subroots.delete(root)\n }\n } else {\n roots.add(root)\n root.stopTracking = () => {\n roots.delete(root)\n }\n }\n}\n\nclass Toolkit {\n declare settings: Settings\n declare assert: (condition: unknown, message?: string) => void\n\n constructor() {\n this.settings = defaultSettings\n this.assert = console.assert as Toolkit['assert']\n }\n\n /**\n * Configures Toolkit with given options, keeping the current values\n * of the options not provided, by default no debug mode and no plugins.\n * Changed plugins are uninstalled from the created roots, and the new\n * ones installed in their place, with their stylesheets loaded.\n */\n configure(options: Options) {\n if (options.debug !== undefined) {\n this.settings = Object.freeze({ debug: options.debug })\n }\n const manifests = options.plugins\n const previous = [...plugins]\n const origins = previous.map(plugin => plugin.origin)\n if (!manifests || isSameList(origins, manifests)) {\n return\n }\n // the methods of the remaining plugins are registered again below\n Sandbox.clearPluginMethods()\n plugins = createPlugins(manifests)\n for (const root of this.tracked) {\n for (const plugin of previous) {\n root.plugins!.uninstall(plugin.name)\n }\n for (const plugin of root.plugins!) {\n plugin.register?.()\n }\n for (const plugin of plugins) {\n root.plugins!.register(plugin)\n root.plugins!.install(plugin)\n }\n if (root.shadow) {\n updateStylesheets(root)\n }\n }\n }\n\n /**\n * Resets Toolkit to a pristine state, with the default settings\n * and no plugins, forgetting the created roots.\n */\n reset() {\n plugins.destroy()\n plugins = createPlugins()\n roots.clear()\n this.settings = defaultSettings\n pureComponentClassRegistry.clear()\n Sandbox.clearPluginMethods()\n }\n\n /* The created root components, with their subroots, until destroyed. */\n get tracked(): WebComponent[] {\n const tracked: WebComponent[] = []\n for (const root of roots) {\n tracked.push(root, ...root.tracked)\n }\n return tracked\n }\n\n isDebug(): boolean {\n return this.settings.debug\n }\n\n warn(...messages: unknown[]) {\n if (this.isDebug()) {\n console.warn(...messages)\n }\n }\n\n async createRoot(\n component: ComponentClass,\n props: Props = {},\n ): Promise<WebComponent> {\n const description = Template.describe([\n component,\n props,\n ]) as ComponentDescription\n // not to stay tracked, with the plugins installed, when it throws\n return CreatedRoots.destroyingRootsOnError(() =>\n VirtualDOM.createWebComponent(description, null),\n )\n }\n\n async render(\n component: ComponentClass,\n container: Element,\n props: Props = {},\n ): Promise<WebComponent> {\n const root = await this.createRoot(component, props)\n return root.mount(container)\n }\n}\n\n/* The Toolkit singleton, exposed globally as toolkit. */\nexport const toolkit = new Toolkit()\n\n// asserts, debug mode and warnings are read from the instance, which\n// can be configured, e.g. with the assert function throwing in tests\nprovideRuntime({\n get plugins() {\n return plugins\n },\n assert: (condition, message) => toolkit.assert(condition, message),\n isDebug: () => toolkit.isDebug(),\n warn: (...messages) => toolkit.warn(...messages),\n track,\n resolveComponentClass,\n update: (root, from, to, commands) =>\n Renderer.update(root, from, to, commands),\n})\n\nexport default Toolkit\n","import { Component, Root, WebComponent } from './core/nodes.js'\nimport Service from './core/service.js'\nimport Toolkit, { toolkit } from './core/toolkit.js'\nimport utils from './core/utils.js'\n\n/* The classes and helpers available on the Toolkit instance. */\ntype ToolkitClasses = {\n Component: typeof Component\n WebComponent: typeof WebComponent\n Root: typeof Root\n Service: typeof Service\n utils: typeof utils\n noop: () => void\n}\n\nconst classes: ToolkitClasses = {\n Component,\n WebComponent,\n Root,\n Service,\n utils,\n noop: () => {},\n}\n\nObject.assign(Toolkit.prototype, classes)\n\nexport type {\n AttributeValue,\n Child,\n ClassName,\n ComponentTemplate,\n ComponentType,\n ElementProps,\n ElementTemplate,\n EventListenerFor,\n Listener,\n PureComponent,\n RenderResult,\n Style,\n TagName,\n Template,\n} from './core/bragi.js'\nexport type { AttributeName, EventName } from './core/browser.js'\nexport type { Props } from './core/description.js'\nexport type {\n BoundCommands,\n CommandMethod,\n Commands,\n CommandsAPI,\n State,\n} from './core/dispatcher.js'\nexport type { ComponentClass, Connectable } from './core/nodes.js'\nexport type { PluginManifest, PluginSandbox } from './core/plugins.js'\nexport type { Update } from './core/renderer.js'\nexport type { Options, Settings } from './core/toolkit.js'\n\nexport { Component, Root, Service, WebComponent, utils }\n\n/* The Toolkit instance, with the classes and helpers assigned above. */\nexport type ToolkitAPI = Toolkit & ToolkitClasses\n\nexport default toolkit as ToolkitAPI\n"],"mappings":";AAaA,IAAe,cAAf,MAA2B;CAUzB,YACE,aACA,aAAiC,MACjC,UAA+B,MAC/B;EACA,KAAK,cAAc;EACnB,KAAK,MAAM,YAAY;EACvB,KAAK,aAAa;EAClB,KAAK,UAAU;CACjB;CAEA,IAAI,gBAAoC;EACtC,IAAI,KAAK,YACP,OAAO,KAAK,WAAW,UAAU,IAC7B,KAAK,aACL,KAAK,WAAW;EAEtB,OAAO;CACT;CAEA,IAAI,YAA+C;EACjD,IAAI,KAAK,YACP,OAAO,KAAK,WAAW;EAEzB,OAAO;CACT;CAEA,IAAI,WAAyB;EAC3B,IAAI,KAAK,OAAO,GACd,OAAO;EAET,IAAI,KAAK,YACP,OAAO,KAAK,WAAW;EAEzB,MAAM,IAAI,MAAM,yCAAyC;CAC3D;CAEA,SAA+B;EAC7B,OAAO,KAAK,aAAa;CAC3B;CAEA,cAAiC;EAC/B,MAAM,EAAE,aAAa;EACrB,OAAO,aAAa,eAAe,aAAa;CAClD;CAEA,YAAoC;EAClC,OAAO,KAAK,aAAa;CAC3B;CAEA,YAA6B;EAC3B,OAAO,KAAK,aAAa;CAC3B;CAEA,SAAuB;EACrB,OAAO,KAAK,aAAa;CAC3B;CAEA,aAAa,MAAsC;EACjD,OAAO,QAAQ,KAAK,aAAa,KAAK,YAAY,KAAK,QAAQ,KAAK;CACtE;AACF;;;ACjFA,IAAM,UAAN,MAAM,gBAAgB,YAAY;CAChC,OAAO,WAAW;CAKlB,YAAY,aAAiC,YAA0B;EACrE,MAAM,aAAa,UAAU;EAC7B,KAAK,UAAU;CACjB;CAEA,IAAI,WAAmB;EACrB,OAAO,QAAQ;CACjB;CAEA,YAAY;EACV,KAAK,MAAM,SAAS,cAAc,IAAI,KAAK,YAAY,KAAK,EAAE;CAChE;AACF;;;AC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