@b9g/crank 0.5.0-beta.0 → 0.5.0-beta.1

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/crank.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"crank.cjs","sources":["../src/crank.ts"],"sourcesContent":["const NOOP = () => {};\nconst IDENTITY = <T>(value: T): T => value;\n\nfunction wrap<T>(value: Array<T> | T | undefined): Array<T> {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n\nfunction unwrap<T>(arr: Array<T>): Array<T> | T | undefined {\n\treturn arr.length === 0 ? undefined : arr.length === 1 ? arr[0] : arr;\n}\n\ntype NonStringIterable<T> = Iterable<T> & object;\n\n/**\n * Ensures a value is an array.\n *\n * This function does the same thing as wrap() above except it handles nulls\n * and iterables, so it is appropriate for wrapping user-provided element\n * children.\n */\nfunction arrayify<T>(\n\tvalue: NonStringIterable<T> | T | null | undefined,\n): Array<T> {\n\treturn value == null\n\t\t? []\n\t\t: Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"string\" ||\n\t\t typeof (value as any)[Symbol.iterator] !== \"function\"\n\t\t? [value]\n\t\t: [...(value as NonStringIterable<T>)];\n}\n\nfunction isIteratorLike(\n\tvalue: any,\n): value is Iterator<unknown> | AsyncIterator<unknown> {\n\treturn value != null && typeof value.next === \"function\";\n}\n\nfunction isPromiseLike(value: any): value is PromiseLike<unknown> {\n\treturn value != null && typeof value.then === \"function\";\n}\n\n/**\n * A type which represents all valid values for an element tag.\n */\nexport type Tag = string | symbol | Component;\n\n/**\n * A helper type to map the tag of an element to its expected props.\n *\n * @template TTag - The tag associated with the props. Can be a string, symbol\n * or a component function.\n */\nexport type TagProps<TTag extends Tag> = TTag extends string\n\t? JSX.IntrinsicElements[TTag]\n\t: TTag extends Component<infer TProps>\n\t? TProps\n\t: Record<string, unknown>;\n\n/***\n * SPECIAL TAGS\n *\n * Crank provides a couple tags which have special meaning for the renderer.\n ***/\n\n/**\n * A special tag for grouping multiple children within the same parent.\n *\n * All non-string iterables which appear in the element tree are implicitly\n * wrapped in a fragment element.\n *\n * This tag is just the empty string, and you can use the empty string in\n * createElement calls or transpiler options directly to avoid having to\n * reference this export.\n */\nexport const Fragment = \"\";\nexport type Fragment = typeof Fragment;\n\n// TODO: We assert the following symbol tags as any because TypeScript support\n// for symbol tags in JSX doesn’t exist yet.\n// https://github.com/microsoft/TypeScript/issues/38367\n\n/**\n * A special tag for rendering into a new root node via a root prop.\n *\n * This tag is useful for creating element trees with multiple roots, for\n * things like modals or tooltips.\n *\n * Renderer.prototype.render() will implicitly wrap top-level element trees in\n * a Portal element.\n */\nexport const Portal = Symbol.for(\"crank.Portal\") as any;\nexport type Portal = typeof Portal;\n\n/**\n * A special tag which preserves whatever was previously rendered in the\n * element’s position.\n *\n * Copy elements are useful for when you want to prevent a subtree from\n * rerendering as a performance optimization. Copy elements can also be keyed,\n * in which case the previously rendered keyed element will be copied.\n */\nexport const Copy = Symbol.for(\"crank.Copy\") as any;\nexport type Copy = typeof Copy;\n\n/**\n * A special tag for injecting raw nodes or strings via a value prop.\n *\n * If the value prop is a string, Renderer.prototype.parse() will be called on\n * the string and the result will be set as the element’s value.\n */\nexport const Raw = Symbol.for(\"crank.Raw\") as any;\nexport type Raw = typeof Raw;\n\n/**\n * Describes all valid values of an element tree, excluding iterables.\n *\n * Arbitrary objects can also be safely rendered, but will be converted to a\n * string using the toString() method. We exclude them from this type to catch\n * potential mistakes.\n */\nexport type Child = Element | string | number | boolean | null | undefined;\n\n/**\n * An arbitrarily nested iterable of Child values.\n *\n * We use a recursive interface here rather than making the Children type\n * directly recursive because recursive type aliases were added in TypeScript\n * 3.7.\n *\n * You should avoid referencing this type directly, as it is mainly exported to\n * prevent TypeScript errors.\n */\nexport interface ChildIterable extends Iterable<Child | ChildIterable> {}\n\n/**\n * Describes all valid values of an element tree, including arbitrarily nested\n * iterables of such values.\n */\nexport type Children = Child | ChildIterable;\n\n/**\n * Represents all functions which can be used as a component.\n *\n * @template [TProps=*] - The expected props for the component.\n */\nexport type Component<TProps extends Record<string, unknown> = any> = (\n\tthis: Context<TProps>,\n\tprops: TProps,\n) =>\n\t| Children\n\t| PromiseLike<Children>\n\t// The return type of iterators must include void because TypeScript will\n\t// infer generators which return implicitly as having a void return type.\n\t| Iterator<Children, Children | void, any>\n\t| AsyncIterator<Children, Children | void, any>;\n\ntype ChildrenIteration =\n\t| Promise<IteratorResult<Children, Children | void>>\n\t| IteratorResult<Children, Children | void>;\n\n/**\n * A type to keep track of keys. Any value can be a key, though null and\n * undefined are ignored.\n */\ntype Key = unknown;\n\nconst ElementSymbol = Symbol.for(\"crank.Element\");\n\n// To maximize compatibility between Crank versions, starting with 0.2.0, any\n// changes to the Element properties will be considered a breaking change.\nexport interface Element<TTag extends Tag = Tag> {\n\t/**\n\t * @internal\n\t * A unique symbol to identify elements as elements across versions and\n\t * realms, and to protect against basic injection attacks.\n\t * https://overreacted.io/why-do-react-elements-have-typeof-property/\n\t *\n\t * This property is defined on the element prototype rather than per\n\t * instance, because it is the same for every Element.\n\t */\n\t$$typeof: typeof ElementSymbol;\n\n\t/**\n\t * The tag of the element. Can be a string, symbol or function.\n\t */\n\ttag: TTag;\n\n\t/**\n\t * An object containing the “properties” of an element. These correspond to\n\t * the attribute syntax from JSX.\n\t */\n\tprops: TagProps<TTag>;\n\n\t/**\n\t * A value which uniquely identifies an element from its siblings so that it\n\t * can be added/updated/moved/removed by key rather than position.\n\t *\n\t * Passed in createElement() as the prop \"c-key\".\n\t */\n\tkey: Key;\n\n\t/**\n\t * A callback which is called with the element’s result when it is committed.\n\t *\n\t * Passed in createElement() as the prop \"c-ref\".\n\t */\n\tref: ((value: unknown) => unknown) | undefined;\n\n\t/**\n\t * A possible boolean which indicates that element should NOT be rerendered.\n\t * If the element has never been rendered, this property has no effect.\n\t *\n\t * Passed in createElement() as the prop \"c-static\".\n\t */\n\tstatic_: boolean | undefined;\n}\n\n/**\n * Elements are the basic building blocks of Crank applications. They are\n * JavaScript objects which are interpreted by special classes called renderers\n * to produce and manage stateful nodes.\n *\n * @template {Tag} [TTag=Tag] - The type of the tag of the element.\n *\n * @example\n * // specific element types\n * let div: Element<\"div\">;\n * let portal: Element<Portal>;\n * let myEl: Element<MyComponent>;\n *\n * // general element types\n * let host: Element<string | symbol>;\n * let component: Element<Component>;\n *\n * Typically, you use a helper function like createElement to create elements\n * rather than instatiating this class directly.\n */\nexport class Element<TTag extends Tag = Tag> {\n\tconstructor(\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t\tkey: Key,\n\t\tref?: ((value: unknown) => unknown) | undefined,\n\t\tstatic_?: boolean | undefined,\n\t) {\n\t\tthis.tag = tag;\n\t\tthis.props = props;\n\t\tthis.key = key;\n\t\tthis.ref = ref;\n\t\tthis.static_ = static_;\n\t}\n}\n\n// See Element interface\nElement.prototype.$$typeof = ElementSymbol;\n\nexport function isElement(value: any): value is Element {\n\treturn value != null && value.$$typeof === ElementSymbol;\n}\n\n/**\n * Creates an element with the specified tag, props and children.\n *\n * This function is usually used as a transpilation target for JSX transpilers,\n * but it can also be called directly. It additionally extracts special props so\n * they aren’t accessible to renderer methods or components, and assigns the\n * children prop according to any additional arguments passed to the function.\n */\nexport function createElement<TTag extends Tag>(\n\ttag: TTag,\n\tprops?: TagProps<TTag> | null | undefined,\n\t...children: Array<unknown>\n): Element<TTag> {\n\tlet key: Key;\n\tlet ref: ((value: unknown) => unknown) | undefined;\n\tlet static_ = false;\n\tconst props1 = {} as TagProps<TTag>;\n\tif (props != null) {\n\t\tfor (const name in props) {\n\t\t\tswitch (name) {\n\t\t\t\tcase \"crank-key\":\n\t\t\t\tcase \"c-key\":\n\t\t\t\tcase \"$key\":\n\t\t\t\t\t// We have to make sure we don’t assign null to the key because we\n\t\t\t\t\t// don’t check for null keys in the diffing functions.\n\t\t\t\t\tif (props[name] != null) {\n\t\t\t\t\t\tkey = props[name];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"crank-ref\":\n\t\t\t\tcase \"c-ref\":\n\t\t\t\tcase \"$ref\":\n\t\t\t\t\tif (typeof props[name] === \"function\") {\n\t\t\t\t\t\tref = props[name];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"crank-static\":\n\t\t\t\tcase \"c-static\":\n\t\t\t\tcase \"$static\":\n\t\t\t\t\tstatic_ = !!props[name];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tprops1[name] = props[name];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (children.length > 1) {\n\t\tprops1.children = children;\n\t} else if (children.length === 1) {\n\t\tprops1.children = children[0];\n\t}\n\n\t// string aliases for the special tags\n\t// TODO: Does this logic belong here, or in the Element constructor\n\tswitch (tag) {\n\t\tcase \"$FRAGMENT\":\n\t\t\ttag = Fragment as any;\n\t\t\tbreak;\n\t\tcase \"$PORTAL\":\n\t\t\ttag = Portal as any;\n\t\t\tbreak;\n\t\tcase \"$COPY\":\n\t\t\ttag = Copy as any;\n\t\t\tbreak;\n\t\tcase \"$RAW\":\n\t\t\ttag = Raw as any;\n\t\t\tbreak;\n\t}\n\n\treturn new Element(tag, props1, key, ref, static_);\n}\n\n/** A single-letter alias for createElement */\nexport const c = createElement;\n\n/** Clones a given element, shallowly copying the props object. */\nexport function cloneElement<TTag extends Tag>(\n\tel: Element<TTag>,\n): Element<TTag> {\n\tif (!isElement(el)) {\n\t\tthrow new TypeError(\"Cannot clone non-element\");\n\t}\n\n\treturn new Element(el.tag, {...el.props}, el.key, el.ref);\n}\n\n/*** ELEMENT UTILITIES ***/\n\n// WHAT ARE WE DOING TO THE CHILDREN???\n/**\n * All values in the element tree are narrowed from the union in Child to\n * NarrowedChild during rendering, to simplify element diffing.\n */\ntype NarrowedChild = Element | string | undefined;\n\nfunction narrow(value: Children): NarrowedChild {\n\tif (typeof value === \"boolean\" || value == null) {\n\t\treturn undefined;\n\t} else if (typeof value === \"string\" || isElement(value)) {\n\t\treturn value;\n\t} else if (typeof (value as any)[Symbol.iterator] === \"function\") {\n\t\treturn createElement(Fragment, null, value);\n\t}\n\n\treturn value.toString();\n}\n\n/**\n * A helper type which repesents all possible rendered values of an element.\n *\n * @template TNode - The node type for the element provided by the renderer.\n *\n * When asking the question, what is the “value” of a specific element, the\n * answer varies depending on the tag:\n *\n * For host elements, the value is the nodes created for the element.\n *\n * For fragments, the value is usually an array of nodes.\n *\n * For portals, the value is undefined, because a Portal element’s root and\n * children are opaque to its parent.\n *\n * For components, the value can be any of the above, because the value of a\n * component is determined by its immediate children.\n *\n * Rendered values can also be strings or arrays of nodes and strings, in the\n * case of component or fragment elements with strings or multiple children.\n *\n * All of these possible values are reflected in this utility type.\n */\nexport type ElementValue<TNode> =\n\t| Array<TNode | string>\n\t| TNode\n\t| string\n\t| undefined;\n\n/**\n * Takes an array of element values and normalizes the output as an array of\n * nodes and strings.\n *\n * @returns Normalized array of nodes and/or strings.\n *\n * Normalize will flatten only one level of nested arrays, because it is\n * designed to be called once at each level of the tree. It will also\n * concatenate adjacent strings and remove all undefined values.\n */\nfunction normalize<TNode>(\n\tvalues: Array<ElementValue<TNode>>,\n): Array<TNode | string> {\n\tconst result: Array<TNode | string> = [];\n\tlet buffer: string | undefined;\n\tfor (let i = 0; i < values.length; i++) {\n\t\tconst value = values[i];\n\t\tif (!value) {\n\t\t\t// pass\n\t\t} else if (typeof value === \"string\") {\n\t\t\tbuffer = (buffer || \"\") + value;\n\t\t} else if (!Array.isArray(value)) {\n\t\t\tif (buffer) {\n\t\t\t\tresult.push(buffer);\n\t\t\t\tbuffer = undefined;\n\t\t\t}\n\n\t\t\tresult.push(value);\n\t\t} else {\n\t\t\t// We could use recursion here but it’s just easier to do it inline.\n\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\tconst value1 = value[j];\n\t\t\t\tif (!value1) {\n\t\t\t\t\t// pass\n\t\t\t\t} else if (typeof value1 === \"string\") {\n\t\t\t\t\tbuffer = (buffer || \"\") + value1;\n\t\t\t\t} else {\n\t\t\t\t\tif (buffer) {\n\t\t\t\t\t\tresult.push(buffer);\n\t\t\t\t\t\tbuffer = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tresult.push(value1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (buffer) {\n\t\tresult.push(buffer);\n\t}\n\n\treturn result;\n}\n\n/**\n * @internal\n * The internal nodes which are cached and diffed against new elements when\n * rendering element trees.\n */\nclass Retainer<TNode> {\n\t/**\n\t * The element associated with this retainer.\n\t */\n\tdeclare el: Element;\n\t/**\n\t * The context associated with this element. Will only be defined for\n\t * component elements.\n\t */\n\tdeclare ctx: ContextImpl<TNode> | undefined;\n\t/**\n\t * The retainer children of this element. Retainers form a tree which mirrors\n\t * elements. Can be a single child or undefined as a memory optimization.\n\t */\n\tdeclare children: Array<RetainerChild<TNode>> | RetainerChild<TNode>;\n\t/**\n\t * The value associated with this element.\n\t */\n\tdeclare value: ElementValue<TNode>;\n\t/**\n\t * The cached child values of this element. Only host and component elements\n\t * will use this property.\n\t */\n\tdeclare cached: ElementValue<TNode>;\n\t/**\n\t * The child which this retainer replaces. This property is used when an\n\t * async retainer tree replaces previously rendered elements, so that the\n\t * previously rendered elements can remain visible until the async tree\n\t * fulfills. Will be set to undefined once this subtree fully renders.\n\t */\n\tdeclare fallback: RetainerChild<TNode>;\n\tdeclare inflight: Promise<ElementValue<TNode>> | undefined;\n\tdeclare onCommit: Function | undefined;\n\tconstructor(el: Element) {\n\t\tthis.el = el;\n\t\tthis.value = undefined;\n\t\tthis.ctx = undefined;\n\t\tthis.children = undefined;\n\t\tthis.cached = undefined;\n\t\tthis.fallback = undefined;\n\t\tthis.inflight = undefined;\n\t\tthis.onCommit = undefined;\n\t}\n}\n\n/**\n * The retainer equivalent of ElementValue\n */\ntype RetainerChild<TNode> = Retainer<TNode> | string | undefined;\n\n/**\n * Finds the value of the element according to its type.\n *\n * @returns The value of the element.\n */\nfunction getValue<TNode>(ret: Retainer<TNode>): ElementValue<TNode> {\n\tif (typeof ret.fallback !== \"undefined\") {\n\t\treturn typeof ret.fallback === \"object\"\n\t\t\t? getValue(ret.fallback)\n\t\t\t: ret.fallback;\n\t} else if (ret.el.tag === Portal) {\n\t\treturn;\n\t} else if (typeof ret.el.tag !== \"function\" && ret.el.tag !== Fragment) {\n\t\treturn ret.value;\n\t}\n\n\treturn unwrap(getChildValues(ret));\n}\n\n/**\n * Walks an element’s children to find its child values.\n *\n * @returns A normalized array of nodes and strings.\n */\nfunction getChildValues<TNode>(ret: Retainer<TNode>): Array<TNode | string> {\n\tif (ret.cached) {\n\t\treturn wrap(ret.cached);\n\t}\n\n\tconst values: Array<ElementValue<TNode>> = [];\n\tconst children = wrap(ret.children);\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (child) {\n\t\t\tvalues.push(typeof child === \"string\" ? child : getValue(child));\n\t\t}\n\t}\n\n\tconst values1 = normalize(values);\n\tconst tag = ret.el.tag;\n\tif (typeof tag === \"function\" || (tag !== Fragment && tag !== Raw)) {\n\t\tret.cached = unwrap(values1);\n\t}\n\treturn values1;\n}\n\n// TODO: Document the interface and methods\nexport interface RendererImpl<\n\tTNode,\n\tTScope,\n\tTRoot extends TNode = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\tscope<TTag extends string | symbol>(\n\t\tscope: TScope | undefined,\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t): TScope | undefined;\n\n\tcreate<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t\tscope: TScope | undefined,\n\t): TNode;\n\n\t/**\n\t * Called when an element’s rendered value is exposed via render, schedule,\n\t * refresh, refs, or generator yield expressions.\n\t *\n\t * @param value - The value of the element being read. Can be a node, a\n\t * string, undefined, or an array of nodes and strings, depending on the\n\t * element.\n\t *\n\t * @returns Varies according to the specific renderer subclass. By default,\n\t * it exposes the element’s value.\n\t *\n\t * This is useful for renderers which don’t want to expose their internal\n\t * nodes. For instance, the HTML renderer will convert all internal nodes to\n\t * strings.\n\t */\n\tread(value: ElementValue<TNode>): TResult;\n\n\t/**\n\t * Called for each string in an element tree.\n\t *\n\t * @param text - The string child.\n\t * @param scope - The current scope.\n\t *\n\t * @returns The escaped string.\n\t *\n\t * Rather than returning text nodes for whatever environment we’re rendering\n\t * to, we defer that step for Renderer.prototype.arrange. We do this so that\n\t * adjacent strings can be concatenated and the actual element tree can be\n\t * rendered in a normalized form.\n\t */\n\tescape(text: string, scope: TScope | undefined): string;\n\n\t/**\n\t * Called for each Raw element whose value prop is a string.\n\t *\n\t * @param text - The string child.\n\t * @param scope - The current scope.\n\t *\n\t * @returns The parsed node or string.\n\t */\n\tparse(text: string, scope: TScope | undefined): ElementValue<TNode>;\n\n\tpatch<TTag extends string | symbol, TName extends string>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tname: TName,\n\t\tvalue: TagProps<TTag>[TName],\n\t\toldValue: TagProps<TTag>[TName] | undefined,\n\t\tscope: TScope,\n\t): unknown;\n\n\tarrange<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tprops: TagProps<TTag>,\n\t\tchildren: Array<TNode | string>,\n\t\toldProps: TagProps<TTag> | undefined,\n\t\toldChildren: Array<TNode | string> | undefined,\n\t): unknown;\n\n\tdispose<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tprops: TagProps<TTag>,\n\t): unknown;\n\n\tflush(root: TRoot): unknown;\n}\n\nconst defaultRendererImpl: RendererImpl<unknown, unknown, unknown, unknown> = {\n\tcreate() {\n\t\tthrow new Error(\"Not implemented\");\n\t},\n\tscope: IDENTITY,\n\tread: IDENTITY,\n\tescape: IDENTITY,\n\tparse: IDENTITY,\n\tpatch: NOOP,\n\tarrange: NOOP,\n\tdispose: NOOP,\n\tflush: NOOP,\n};\n\nconst $RendererImpl = Symbol.for(\"crank.RendererImpl\");\n/**\n * An abstract class which is subclassed to render to different target\n * environments. This class is responsible for kicking off the rendering\n * process and caching previous trees by root.\n *\n * @template TNode - The type of the node for a rendering environment.\n * @template TScope - Data which is passed down the tree.\n * @template TRoot - The type of the root for a rendering environment.\n * @template TResult - The type of exposed values.\n */\nexport class Renderer<\n\tTNode extends object = object,\n\tTScope = unknown,\n\tTRoot extends TNode = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\t/**\n\t * @internal\n\t * A weakmap which stores element trees by root.\n\t */\n\tdeclare cache: WeakMap<object, Retainer<TNode>>;\n\n\tdeclare [$RendererImpl]: RendererImpl<TNode, TScope, TRoot, TResult>;\n\tconstructor(impl: Partial<RendererImpl<TNode, TScope, TRoot, TResult>>) {\n\t\tthis.cache = new WeakMap();\n\t\tthis[$RendererImpl] = {\n\t\t\t...(defaultRendererImpl as RendererImpl<TNode, TScope, TRoot, TResult>),\n\t\t\t...impl,\n\t\t};\n\t}\n\n\t/**\n\t * Renders an element tree into a specific root.\n\t *\n\t * @param children - An element tree. You can render null with a previously\n\t * used root to delete the previously rendered element tree from the cache.\n\t * @param root - The node to be rendered into. The renderer will cache\n\t * element trees per root.\n\t * @param ctx - An optional context that will be the ancestor context of all\n\t * elements in the tree. Useful for connecting different renderers so that\n\t * events/provisions properly propagate. The context for a given root must be\n\t * the same or an error will be thrown.\n\t *\n\t * @returns The result of rendering the children, or a possible promise of\n\t * the result if the element tree renders asynchronously.\n\t */\n\trender(\n\t\tchildren: Children,\n\t\troot?: TRoot | undefined,\n\t\tbridge?: Context | undefined,\n\t): Promise<TResult> | TResult {\n\t\tlet ret: Retainer<TNode> | undefined;\n\t\tconst ctx = bridge && (bridge[$ContextImpl] as ContextImpl<TNode>);\n\t\tif (typeof root === \"object\" && root !== null) {\n\t\t\tret = this.cache.get(root);\n\t\t}\n\n\t\tlet oldProps: Record<string, any> | undefined;\n\t\tif (ret === undefined) {\n\t\t\tret = new Retainer(createElement(Portal, {children, root}));\n\t\t\tret.value = root;\n\t\t\tret.ctx = ctx;\n\t\t\tif (typeof root === \"object\" && root !== null && children != null) {\n\t\t\t\tthis.cache.set(root, ret);\n\t\t\t}\n\t\t} else if (ret.ctx !== ctx) {\n\t\t\tthrow new Error(\"Context mismatch\");\n\t\t} else {\n\t\t\toldProps = ret.el.props;\n\t\t\tret.el = createElement(Portal, {children, root});\n\t\t\tif (typeof root === \"object\" && root !== null && children == null) {\n\t\t\t\tthis.cache.delete(root);\n\t\t\t}\n\t\t}\n\n\t\tconst impl = this[$RendererImpl];\n\t\tconst childValues = diffChildren(\n\t\t\timpl,\n\t\t\troot,\n\t\t\tret,\n\t\t\tctx,\n\t\t\timpl.scope(undefined, Portal, ret.el.props),\n\t\t\tret,\n\t\t\tchildren,\n\t\t);\n\n\t\t// We return the child values of the portal because portal elements\n\t\t// themselves have no readable value.\n\t\tif (isPromiseLike(childValues)) {\n\t\t\treturn childValues.then((childValues) =>\n\t\t\t\tcommitRootRender(impl, root, ctx, ret!, childValues, oldProps),\n\t\t\t);\n\t\t}\n\n\t\treturn commitRootRender(impl, root, ctx, ret, childValues, oldProps);\n\t}\n}\n\n/*** PRIVATE RENDERER FUNCTIONS ***/\nfunction commitRootRender<TNode, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, unknown, TRoot, TResult>,\n\troot: TRoot | undefined,\n\tctx: ContextImpl<TNode> | undefined,\n\tret: Retainer<TNode>,\n\tchildValues: Array<TNode | string>,\n\toldProps: Record<string, any> | undefined,\n): TResult {\n\t// element is a host or portal element\n\tif (root !== undefined) {\n\t\trenderer.arrange(\n\t\t\tPortal,\n\t\t\troot,\n\t\t\tret.el.props,\n\t\t\tchildValues,\n\t\t\toldProps,\n\t\t\twrap(ret.cached),\n\t\t);\n\t\tflush(renderer, root);\n\t}\n\n\tret.cached = unwrap(childValues);\n\tif (root == null) {\n\t\tunmount(renderer, ret, ctx, ret);\n\t}\n\n\treturn renderer.read(ret.cached);\n}\n\nfunction diffChildren<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\tparent: Retainer<TNode>,\n\tchildren: Children,\n): Promise<Array<TNode | string>> | Array<TNode | string> {\n\tconst oldRetained = wrap(parent.children);\n\tconst newRetained: typeof oldRetained = [];\n\tconst newChildren = arrayify(children);\n\tconst values: Array<Promise<ElementValue<TNode>> | ElementValue<TNode>> = [];\n\tlet graveyard: Array<Retainer<TNode>> | undefined;\n\tlet childrenByKey: Map<Key, Retainer<TNode>> | undefined;\n\tlet seenKeys: Set<Key> | undefined;\n\tlet isAsync = false;\n\tlet oi = 0,\n\t\toldLength = oldRetained.length;\n\tfor (let ni = 0, newLength = newChildren.length; ni < newLength; ni++) {\n\t\t// We make sure we don’t access indices out of bounds to prevent\n\t\t// deoptimizations.\n\t\tlet ret = oi >= oldLength ? undefined : oldRetained[oi];\n\t\tlet child = narrow(newChildren[ni]);\n\t\t{\n\t\t\t// Aligning new children with old retainers\n\t\t\tlet oldKey = typeof ret === \"object\" ? ret.el.key : undefined;\n\t\t\tlet newKey = typeof child === \"object\" ? child.key : undefined;\n\t\t\tif (newKey !== undefined && seenKeys && seenKeys.has(newKey)) {\n\t\t\t\tconsole.error(\"Duplicate key\", newKey);\n\t\t\t\tnewKey = undefined;\n\t\t\t}\n\n\t\t\tif (oldKey === newKey) {\n\t\t\t\tif (childrenByKey !== undefined && newKey !== undefined) {\n\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t}\n\n\t\t\t\toi++;\n\t\t\t} else {\n\t\t\t\tchildrenByKey = childrenByKey || createChildrenByKey(oldRetained, oi);\n\t\t\t\tif (newKey === undefined) {\n\t\t\t\t\twhile (ret !== undefined && oldKey !== undefined) {\n\t\t\t\t\t\toi++;\n\t\t\t\t\t\tret = oldRetained[oi];\n\t\t\t\t\t\toldKey = typeof ret === \"object\" ? ret.el.key : undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\toi++;\n\t\t\t\t} else {\n\t\t\t\t\tret = childrenByKey.get(newKey);\n\t\t\t\t\tif (ret !== undefined) {\n\t\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t\t}\n\n\t\t\t\t\t(seenKeys = seenKeys || new Set()).add(newKey);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Updating\n\t\tlet value: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\t\tif (typeof child === \"object\") {\n\t\t\tif (typeof ret === \"object\" && child.static_) {\n\t\t\t\tret.el = child;\n\t\t\t\tvalue = getInflightValue(ret);\n\t\t\t} else if (child.tag === Copy) {\n\t\t\t\tvalue = getInflightValue(ret);\n\t\t\t} else {\n\t\t\t\tlet oldProps: Record<string, any> | undefined;\n\t\t\t\tif (typeof ret === \"object\" && ret.el.tag === child.tag) {\n\t\t\t\t\toldProps = ret.el.props;\n\t\t\t\t\tret.el = child;\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fallback = ret;\n\t\t\t\t\tret = new Retainer<TNode>(child);\n\t\t\t\t\tret.fallback = fallback;\n\t\t\t\t}\n\n\t\t\t\tif (child.tag === Raw) {\n\t\t\t\t\tvalue = updateRaw(renderer, ret, scope, oldProps);\n\t\t\t\t} else if (child.tag === Fragment) {\n\t\t\t\t\tvalue = updateFragment(renderer, root, host, ctx, scope, ret);\n\t\t\t\t} else if (typeof child.tag === \"function\") {\n\t\t\t\t\tvalue = updateComponent(\n\t\t\t\t\t\trenderer,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tret,\n\t\t\t\t\t\toldProps,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tvalue = updateHost(renderer, root, ctx, scope, ret, oldProps);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ref = child.ref;\n\t\t\tif (isPromiseLike(value)) {\n\t\t\t\tisAsync = true;\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tvalue = value.then((value) => {\n\t\t\t\t\t\tref(renderer.read(value));\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (typeof ref === \"function\") {\n\t\t\t\tref(renderer.read(value));\n\t\t\t}\n\t\t} else {\n\t\t\t// child is a string or undefined\n\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t}\n\n\t\t\tif (typeof child === \"string\") {\n\t\t\t\tvalue = ret = renderer.escape(child, scope);\n\t\t\t} else {\n\t\t\t\tret = undefined;\n\t\t\t}\n\t\t}\n\n\t\tvalues[ni] = value;\n\t\tnewRetained[ni] = ret;\n\t}\n\n\t// cleanup remaining retainers\n\tfor (; oi < oldLength; oi++) {\n\t\tconst ret = oldRetained[oi];\n\t\tif (typeof ret === \"object\" && typeof ret.el.key === \"undefined\") {\n\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t}\n\t}\n\n\tif (childrenByKey !== undefined && childrenByKey.size > 0) {\n\t\t(graveyard = graveyard || []).push(...childrenByKey.values());\n\t}\n\n\tparent.children = unwrap(newRetained);\n\tif (isAsync) {\n\t\tlet childValues1 = Promise.all(values).finally(() => {\n\t\t\tif (graveyard) {\n\t\t\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\t\t\tunmount(renderer, host, ctx, graveyard[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tlet onChildValues!: Function;\n\t\tchildValues1 = Promise.race([\n\t\t\tchildValues1,\n\t\t\tnew Promise<any>((resolve) => (onChildValues = resolve)),\n\t\t]);\n\n\t\tif (parent.onCommit) {\n\t\t\tparent.onCommit(childValues1);\n\t\t}\n\n\t\tparent.onCommit = onChildValues;\n\t\treturn childValues1.then((childValues) => {\n\t\t\tparent.inflight = parent.fallback = undefined;\n\t\t\treturn normalize(childValues);\n\t\t});\n\t}\n\n\tif (graveyard) {\n\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\tunmount(renderer, host, ctx, graveyard[i]);\n\t\t}\n\t}\n\n\tif (parent.onCommit) {\n\t\tparent.onCommit(values);\n\t\tparent.onCommit = undefined;\n\t}\n\n\tparent.inflight = parent.fallback = undefined;\n\t// We can assert there are no promises in the array because isAsync is false\n\treturn normalize(values as Array<ElementValue<TNode>>);\n}\n\nfunction createChildrenByKey<TNode>(\n\tchildren: Array<RetainerChild<TNode>>,\n\toffset: number,\n): Map<Key, Retainer<TNode>> {\n\tconst childrenByKey = new Map<Key, Retainer<TNode>>();\n\tfor (let i = offset; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (typeof child === \"object\" && typeof child.el.key !== \"undefined\") {\n\t\t\tchildrenByKey.set(child.el.key, child);\n\t\t}\n\t}\n\n\treturn childrenByKey;\n}\n\nfunction getInflightValue<TNode>(\n\tchild: RetainerChild<TNode>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (typeof child !== \"object\") {\n\t\treturn child;\n\t}\n\n\tconst ctx: ContextImpl<TNode> | undefined =\n\t\ttypeof child.el.tag === \"function\" ? child.ctx : undefined;\n\tif (ctx && ctx.f & IsUpdating && ctx.inflightValue) {\n\t\treturn ctx.inflightValue;\n\t} else if (child.inflight) {\n\t\treturn child.inflight;\n\t}\n\n\treturn getValue(child);\n}\n\nfunction updateRaw<TNode, TScope>(\n\trenderer: RendererImpl<TNode, TScope, TNode, unknown>,\n\tret: Retainer<TNode>,\n\tscope: TScope | undefined,\n\toldProps: Record<string, any> | undefined,\n): ElementValue<TNode> {\n\tconst props = ret.el.props;\n\tif (typeof props.value === \"string\") {\n\t\tif (!oldProps || oldProps.value !== props.value) {\n\t\t\tret.value = renderer.parse(props.value, scope);\n\t\t}\n\t} else {\n\t\tret.value = props.value;\n\t}\n\n\treturn ret.value;\n}\n\nfunction updateFragment<TNode, TScope, TRoot extends TNode>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, unknown>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tconst childValues = diffChildren(\n\t\trenderer,\n\t\troot,\n\t\thost,\n\t\tctx,\n\t\tscope,\n\t\tret,\n\t\tret.el.props.children,\n\t);\n\n\tif (isPromiseLike(childValues)) {\n\t\tret.inflight = childValues.then((childValues) => unwrap(childValues));\n\t\treturn ret.inflight;\n\t}\n\n\treturn unwrap(childValues);\n}\n\nfunction updateHost<TNode, TScope, TRoot extends TNode>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, unknown>,\n\troot: TRoot | undefined,\n\tctx: ContextImpl<TNode, TScope, TRoot> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n\toldProps: Record<string, any> | undefined,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tconst el = ret.el;\n\tconst tag = el.tag as string | symbol;\n\tif (el.tag === Portal) {\n\t\troot = ret.value = el.props.root;\n\t} else if (!oldProps) {\n\t\t// We use the truthiness of oldProps to determine if this the first render.\n\t\tret.value = renderer.create(tag, el.props, scope);\n\t}\n\n\tscope = renderer.scope(scope, tag, el.props);\n\tconst childValues = diffChildren(\n\t\trenderer,\n\t\troot,\n\t\tret,\n\t\tctx,\n\t\tscope,\n\t\tret,\n\t\tret.el.props.children,\n\t);\n\n\tif (isPromiseLike(childValues)) {\n\t\tret.inflight = childValues.then((childValues) =>\n\t\t\tcommitHost(renderer, scope, ret, childValues, oldProps),\n\t\t);\n\n\t\treturn ret.inflight;\n\t}\n\n\treturn commitHost(renderer, scope, ret, childValues, oldProps);\n}\n\nfunction commitHost<TNode, TScope>(\n\trenderer: RendererImpl<TNode, TScope, TNode, unknown>,\n\tscope: TScope,\n\tret: Retainer<TNode>,\n\tchildValues: Array<TNode | string>,\n\toldProps: Record<string, any> | undefined,\n): ElementValue<TNode> {\n\tconst tag = ret.el.tag as string | symbol;\n\tconst value = ret.value as TNode;\n\tlet props = ret.el.props;\n\tlet copied: Set<string> | undefined;\n\tif (tag !== Portal) {\n\t\tfor (const propName in {...oldProps, ...props}) {\n\t\t\tconst propValue = props[propName];\n\t\t\tif (propValue === Copy) {\n\t\t\t\t(copied = copied || new Set()).add(propName);\n\t\t\t} else if (propName !== \"children\") {\n\t\t\t\trenderer.patch(\n\t\t\t\t\ttag,\n\t\t\t\t\tvalue,\n\t\t\t\t\tpropName,\n\t\t\t\t\tpropValue,\n\t\t\t\t\toldProps && oldProps[propName],\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copied) {\n\t\tprops = {...ret.el.props};\n\t\tfor (const name of copied) {\n\t\t\tprops[name] = oldProps && oldProps[name];\n\t\t}\n\n\t\tret.el = new Element(tag, props, ret.el.key, ret.el.ref);\n\t}\n\n\trenderer.arrange(tag, value, props, childValues, oldProps, wrap(ret.cached));\n\tret.cached = unwrap(childValues);\n\tif (tag === Portal) {\n\t\tflush(renderer, ret.value);\n\t\treturn;\n\t}\n\n\treturn value;\n}\n\nfunction flush<TRoot>(\n\trenderer: RendererImpl<unknown, unknown, TRoot>,\n\troot: TRoot,\n\tinitiator?: ContextImpl,\n) {\n\trenderer.flush(root);\n\tif (typeof root !== \"object\" || root === null) {\n\t\treturn;\n\t}\n\n\tconst flushMap = flushMaps.get(root as any);\n\tif (flushMap) {\n\t\tif (initiator) {\n\t\t\tconst flushMap1 = new Map<ContextImpl, Set<Function>>();\n\t\t\tfor (let [ctx, callbacks] of flushMap) {\n\t\t\t\tif (!ctxContains(initiator, ctx)) {\n\t\t\t\t\tflushMap.delete(ctx);\n\t\t\t\t\tflushMap1.set(ctx, callbacks);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (flushMap1.size) {\n\t\t\t\tflushMaps.set(root as any, flushMap1);\n\t\t\t} else {\n\t\t\t\tflushMaps.delete(root as any);\n\t\t\t}\n\t\t} else {\n\t\t\tflushMaps.delete(root as any);\n\t\t}\n\n\t\tfor (const [ctx, callbacks] of flushMap) {\n\t\t\tconst value = renderer.read(getValue(ctx.ret));\n\t\t\tfor (const callback of callbacks) {\n\t\t\t\tcallback(value);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction unmount<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tret: Retainer<TNode>,\n): void {\n\tif (typeof ret.el.tag === \"function\") {\n\t\tctx = ret.ctx as ContextImpl<TNode, TScope, TRoot, TResult>;\n\t\tunmountComponent(ctx);\n\t} else if (ret.el.tag === Portal) {\n\t\thost = ret;\n\t\trenderer.arrange(\n\t\t\tPortal,\n\t\t\thost.value as TNode,\n\t\t\thost.el.props,\n\t\t\t[],\n\t\t\thost.el.props,\n\t\t\twrap(host.cached),\n\t\t);\n\t\tflush(renderer, host.value);\n\t} else if (ret.el.tag !== Fragment) {\n\t\tif (isEventTarget(ret.value)) {\n\t\t\tconst records = getListenerRecords(ctx, host);\n\t\t\tfor (let i = 0; i < records.length; i++) {\n\t\t\t\tconst record = records[i];\n\t\t\t\tret.value.removeEventListener(\n\t\t\t\t\trecord.type,\n\t\t\t\t\trecord.callback,\n\t\t\t\t\trecord.options,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\trenderer.dispose(ret.el.tag, ret.value as TNode, ret.el.props);\n\t\thost = ret;\n\t}\n\n\tconst children = wrap(ret.children);\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (typeof child === \"object\") {\n\t\t\tunmount(renderer, host, ctx, child);\n\t\t}\n\t}\n}\n\n/*** CONTEXT FLAGS ***/\n/**\n * A flag which is set when the component is being updated by the parent and\n * cleared when the component has committed. Used to determine things like\n * whether the nearest host ancestor needs to be rearranged.\n */\nconst IsUpdating = 1 << 0;\n\n/**\n * A flag which is set when the component function or generator is\n * synchronously executing. This flags is used to ensure that a component which\n * triggers a second update in the course of rendering does not cause a stack\n * overflow or a generator error.\n */\nconst IsExecuting = 1 << 1;\n\n/**\n * A flag used to make sure multiple values are not pulled from context prop\n * iterators without a yield.\n */\nconst IsIterating = 1 << 2;\n\n/**\n * A flag used by async generator components in conjunction with the\n * onavailable (_oa) callback to mark whether new props can be pulled via the\n * context async iterator. See the Symbol.asyncIterator method and the\n * resumeCtxIterator function.\n */\nconst IsAvailable = 1 << 3;\n\n/**\n * A flag which is set when a generator components returns, i.e. the done\n * property on the iteration is set to true. Generator components will stick to\n * their last rendered value and ignore further updates.\n */\nconst IsDone = 1 << 4;\n\n/**\n * A flag which is set when a generator component errors.\n *\n * NOTE: This is mainly used to prevent some false positives in component\n * yields or returns undefined warnings. The reason we’re using this versus\n * IsUnmounted is a very troubling test (cascades sync generator parent and\n * sync generator child) where synchronous code causes a stack overflow error\n * in a non-deterministic way. Deeply disturbing stuff.\n */\nconst IsErrored = 1 << 5;\n\n/**\n * A flag which is set when the component is unmounted. Unmounted components\n * are no longer in the element tree and cannot refresh or rerender.\n */\nconst IsUnmounted = 1 << 6;\n\n/**\n * A flag which indicates that the component is a sync generator component.\n */\nconst IsSyncGen = 1 << 7;\n\n/**\n * A flag which indicates that the component is an async generator component.\n */\nconst IsAsyncGen = 1 << 8;\n\n/**\n * A flag which is set while schedule callbacks are called.\n */\nconst IsScheduling = 1 << 9;\n\n/**\n * A flag which is set when a schedule callback calls refresh.\n */\nconst IsSchedulingRefresh = 1 << 10;\n\nexport interface Context extends Crank.Context {}\n\n/**\n * An interface which can be extended to provide strongly typed provisions.\n * See Context.prototype.consume and Context.prototype.provide.\n */\nexport interface ProvisionMap extends Crank.ProvisionMap {}\n\nconst provisionMaps = new WeakMap<ContextImpl, Map<unknown, unknown>>();\n\nconst scheduleMap = new WeakMap<ContextImpl, Set<Function>>();\n\nconst cleanupMap = new WeakMap<ContextImpl, Set<Function>>();\n\n// keys are roots\nconst flushMaps = new WeakMap<object, Map<ContextImpl, Set<Function>>>();\n\n/**\n * @internal\n * The internal class which holds all context data.\n */\nclass ContextImpl<\n\tTNode = unknown,\n\tTScope = unknown,\n\tTRoot extends TNode = TNode,\n\tTResult = unknown,\n> {\n\t/**\n\t * flags - A bitmask. See CONTEXT FLAGS above.\n\t */\n\tdeclare f: number;\n\n\t/**\n\t * ctx - The actual object passed as this to components.\n\t */\n\tdeclare ctx: Context<unknown, TResult>;\n\n\t/**\n\t * renderer - The renderer which created this context.\n\t */\n\tdeclare renderer: RendererImpl<TNode, TScope, TRoot, TResult>;\n\n\t/**\n\t * root - The root node as set by the nearest ancestor portal.\n\t */\n\tdeclare root: TRoot | undefined;\n\n\t/**\n\t * host - The nearest host or portal retainer.\n\t *\n\t * When refresh is called, the host element will be arranged as the last step\n\t * of the commit, to make sure the parent’s children properly reflects the\n\t * components’s children.\n\t */\n\tdeclare host: Retainer<TNode>;\n\n\t/**\n\t * parent - The parent context.\n\t */\n\tdeclare parent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined;\n\n\t/**\n\t * scope - The value of the scope at the point of element’s creation.\n\t */\n\tdeclare scope: TScope | undefined;\n\n\t/**\n\t * retainer - The internal node associated with this context.\n\t */\n\tdeclare ret: Retainer<TNode>;\n\n\t/**\n\t * iterator - The iterator returned by the component function.\n\t */\n\tdeclare iterator:\n\t\t| Iterator<Children, Children | void, unknown>\n\t\t| AsyncIterator<Children, Children | void, unknown>\n\t\t| undefined;\n\n\t/*** async properties ***/\n\t// See the runComponent/stepComponent/advanceComponent functions for more\n\t// notes on the inflight/enqueued block/value properties.\n\t/**\n\t * inflightBlock\n\t */\n\tdeclare inflightBlock: Promise<unknown> | undefined;\n\n\t// TODO: Can we combine this with retainer.inflight somehow please.\n\t/**\n\t * inflightValue\n\t */\n\tdeclare inflightValue: Promise<ElementValue<TNode>> | undefined;\n\n\t/**\n\t * enqueuedBlock\n\t */\n\tdeclare enqueuedBlock: Promise<unknown> | undefined;\n\n\t/**\n\t * enqueuedValue\n\t */\n\tdeclare enqueuedValue: Promise<ElementValue<TNode>> | undefined;\n\n\t/**\n\t * onavailable - A callback used in conjunction with the IsAvailable flag to\n\t * implement the props async iterator. See the Symbol.asyncIterator method\n\t * and the resumeCtxIterator function.\n\t */\n\tdeclare onAvailable: Function | undefined;\n\n\tconstructor(\n\t\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\t\troot: TRoot | undefined,\n\t\thost: Retainer<TNode>,\n\t\tparent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\t\tscope: TScope | undefined,\n\t\tret: Retainer<TNode>,\n\t) {\n\t\tthis.f = 0;\n\t\tthis.ctx = new Context(this);\n\t\tthis.renderer = renderer;\n\t\tthis.root = root;\n\t\tthis.host = host;\n\t\tthis.parent = parent;\n\t\tthis.scope = scope;\n\t\tthis.ret = ret;\n\t\tthis.iterator = undefined;\n\t\tthis.inflightBlock = undefined;\n\t\tthis.inflightValue = undefined;\n\t\tthis.enqueuedBlock = undefined;\n\t\tthis.enqueuedValue = undefined;\n\t\tthis.onAvailable = undefined;\n\t}\n}\n\nconst $ContextImpl = Symbol.for(\"crank.ContextImpl\");\n\n/**\n * A class which is instantiated and passed to every component as its this\n * value. Contexts form a tree just like elements and all components in the\n * element tree are connected via contexts. Components can use this tree to\n * communicate data upwards via events and downwards via provisions.\n *\n * @template [TProps=*] - The expected shape of the props passed to the\n * component. Used to strongly type the Context iterator methods.\n * @template [TResult=*] - The readable element value type. It is used in\n * places such as the return value of refresh and the argument passed to\n * schedule and cleanup callbacks.\n */\nexport class Context<TProps = any, TResult = any> implements EventTarget {\n\t/**\n\t * @internal\n\t */\n\tdeclare [$ContextImpl]: ContextImpl<unknown, unknown, unknown, TResult>;\n\n\tconstructor(impl: ContextImpl<unknown, unknown, unknown, TResult>) {\n\t\tthis[$ContextImpl] = impl;\n\t}\n\n\t/**\n\t * The current props of the associated element.\n\t *\n\t * Typically, you should read props either via the first parameter of the\n\t * component or via the context iterator methods. This property is mainly for\n\t * plugins or utilities which wrap contexts.\n\t */\n\tget props(): TProps {\n\t\treturn this[$ContextImpl].ret.el.props;\n\t}\n\n\t// TODO: Should we rename this???\n\t/**\n\t * The current value of the associated element.\n\t *\n\t * Typically, you should read values via refs, generator yield expressions,\n\t * or the refresh, schedule, cleanup, or flush methods. This property is\n\t * mainly for plugins or utilities which wrap contexts.\n\t */\n\tget value(): TResult {\n\t\treturn this[$ContextImpl].renderer.read(getValue(this[$ContextImpl].ret));\n\t}\n\n\t*[Symbol.iterator](): Generator<TProps> {\n\t\tconst impl = this[$ContextImpl];\n\t\twhile (!(impl.f & IsDone)) {\n\t\t\tif (impl.f & IsIterating) {\n\t\t\t\tthrow new Error(\"Context iterated twice without a yield\");\n\t\t\t} else if (impl.f & IsAsyncGen) {\n\t\t\t\tthrow new Error(\"Use for await…of in async generator components\");\n\t\t\t}\n\n\t\t\timpl.f |= IsIterating;\n\t\t\tyield impl.ret.el.props!;\n\t\t}\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<TProps> {\n\t\t// We use a do while loop rather than a while loop to handle an edge case\n\t\t// where an async generator component is unmounted synchronously and\n\t\t// therefore “done” before it starts iterating over the context.\n\t\tconst impl = this[$ContextImpl];\n\t\tdo {\n\t\t\tif (impl.f & IsIterating) {\n\t\t\t\tthrow new Error(\"Context iterated twice without a yield\");\n\t\t\t} else if (impl.f & IsSyncGen) {\n\t\t\t\tthrow new Error(\"Use for…of in sync generator components\");\n\t\t\t}\n\n\t\t\timpl.f |= IsIterating;\n\t\t\tif (impl.f & IsAvailable) {\n\t\t\t\timpl.f &= ~IsAvailable;\n\t\t\t} else {\n\t\t\t\tawait new Promise((resolve) => (impl.onAvailable = resolve));\n\t\t\t\tif (impl.f & IsDone) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield impl.ret.el.props;\n\t\t} while (!(impl.f & IsDone));\n\t}\n\n\t/**\n\t * Re-executes a component.\n\t *\n\t * @returns The rendered value of the component or a promise thereof if the\n\t * component or its children execute asynchronously.\n\t *\n\t * The refresh method works a little differently for async generator\n\t * components, in that it will resume the Context’s props async iterator\n\t * rather than resuming execution. This is because async generator components\n\t * are perpetually resumed independent of updates, and rely on the props\n\t * async iterator to suspend.\n\t */\n\trefresh(): Promise<TResult> | TResult {\n\t\tconst impl = this[$ContextImpl];\n\t\tif (impl.f & IsUnmounted) {\n\t\t\tconsole.error(\"Component is unmounted\");\n\t\t\treturn impl.renderer.read(undefined);\n\t\t} else if (impl.f & IsExecuting) {\n\t\t\tconsole.error(\"Component is already executing\");\n\t\t\treturn this.value;\n\t\t}\n\n\t\tresumeCtxIterator(impl);\n\t\tconst value = runComponent(impl);\n\t\tif (isPromiseLike(value)) {\n\t\t\treturn (value as Promise<any>).then((value) => impl.renderer.read(value));\n\t\t}\n\n\t\treturn impl.renderer.read(value);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component commits. Will only\n\t * fire once per callback and update.\n\t */\n\tschedule(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet callbacks = scheduleMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tscheduleMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component’s children are\n\t * rendered into the root. Will only fire once per callback and render.\n\t */\n\tflush(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tif (typeof impl.root !== \"object\" || impl.root === null) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet flushMap = flushMaps.get(impl.root);\n\t\tif (!flushMap) {\n\t\t\tflushMap = new Map<ContextImpl, Set<Function>>();\n\t\t\tflushMaps.set(impl.root, flushMap);\n\t\t}\n\n\t\tlet callbacks = flushMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tflushMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component unmounts. Will only\n\t * fire once per callback.\n\t */\n\tcleanup(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet callbacks = cleanupMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tcleanupMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\tconsume<TKey extends keyof ProvisionMap>(key: TKey): ProvisionMap[TKey];\n\tconsume(key: unknown): any;\n\tconsume(key: unknown): any {\n\t\tfor (\n\t\t\tlet parent = this[$ContextImpl].parent;\n\t\t\tparent !== undefined;\n\t\t\tparent = parent.parent\n\t\t) {\n\t\t\tconst provisions = provisionMaps.get(parent);\n\t\t\tif (provisions && provisions.has(key)) {\n\t\t\t\treturn provisions.get(key)!;\n\t\t\t}\n\t\t}\n\t}\n\n\tprovide<TKey extends keyof ProvisionMap>(\n\t\tkey: TKey,\n\t\tvalue: ProvisionMap[TKey],\n\t): void;\n\tprovide(key: unknown, value: any): void;\n\tprovide(key: unknown, value: any): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet provisions = provisionMaps.get(impl);\n\t\tif (!provisions) {\n\t\t\tprovisions = new Map();\n\t\t\tprovisionMaps.set(impl, provisions);\n\t\t}\n\n\t\tprovisions.set(key, value);\n\t}\n\n\taddEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet listeners: Array<EventListenerRecord>;\n\t\tif (!isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tconst listeners1 = listenersMap.get(impl);\n\t\t\tif (listeners1) {\n\t\t\t\tlisteners = listeners1;\n\t\t\t} else {\n\t\t\t\tlisteners = [];\n\t\t\t\tlistenersMap.set(impl, listeners);\n\t\t\t}\n\t\t}\n\n\t\toptions = normalizeListenerOptions(options);\n\t\tlet callback: MappedEventListener<T>;\n\t\tif (typeof listener === \"object\") {\n\t\t\tcallback = () => listener.handleEvent.apply(listener, arguments as any);\n\t\t} else {\n\t\t\tcallback = listener;\n\t\t}\n\n\t\tconst record: EventListenerRecord = {type, callback, listener, options};\n\t\tif (options.once) {\n\t\t\trecord.callback = function (this: any) {\n\t\t\t\tconst i = listeners.indexOf(record);\n\t\t\t\tif (i !== -1) {\n\t\t\t\t\tlisteners.splice(i, 1);\n\t\t\t\t}\n\n\t\t\t\treturn callback.apply(this, arguments as any);\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tlisteners.some(\n\t\t\t\t(record1) =>\n\t\t\t\t\trecord.type === record1.type &&\n\t\t\t\t\trecord.listener === record1.listener &&\n\t\t\t\t\t!record.options.capture === !record1.options.capture,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tlisteners.push(record);\n\n\t\t// TODO: is it possible to separate out the EventTarget delegation logic\n\t\tfor (const value of getChildValues(impl.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tvalue.addEventListener(record.type, record.callback, record.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tremoveEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: EventListenerOptions | boolean,\n\t): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tconst listeners = listenersMap.get(impl);\n\t\tif (listeners == null || !isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options1 = normalizeListenerOptions(options);\n\t\tconst i = listeners.findIndex(\n\t\t\t(record) =>\n\t\t\t\trecord.type === type &&\n\t\t\t\trecord.listener === listener &&\n\t\t\t\t!record.options.capture === !options1.capture,\n\t\t);\n\n\t\tif (i === -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = listeners[i];\n\t\tlisteners.splice(i, 1);\n\n\t\t// TODO: is it possible to separate out the EventTarget delegation logic\n\t\tfor (const value of getChildValues(impl.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tvalue.removeEventListener(record.type, record.callback, record.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatchEvent(ev: Event): boolean {\n\t\tconst impl = this[$ContextImpl];\n\t\tconst path: Array<ContextImpl> = [];\n\t\tfor (\n\t\t\tlet parent = impl.parent;\n\t\t\tparent !== undefined;\n\t\t\tparent = parent.parent\n\t\t) {\n\t\t\tpath.push(parent);\n\t\t}\n\n\t\t// We patch the stopImmediatePropagation method because ev.cancelBubble\n\t\t// only informs us if stopPropagation was called and there are no\n\t\t// properties which inform us if stopImmediatePropagation was called.\n\t\tlet immediateCancelBubble = false;\n\t\tconst stopImmediatePropagation = ev.stopImmediatePropagation;\n\t\tsetEventProperty(ev, \"stopImmediatePropagation\", () => {\n\t\t\timmediateCancelBubble = true;\n\t\t\treturn stopImmediatePropagation.call(ev);\n\t\t});\n\t\tsetEventProperty(ev, \"target\", impl.ctx);\n\n\t\t// The only possible errors in this block are errors thrown by callbacks,\n\t\t// and dispatchEvent will only log these errors rather than throwing\n\t\t// them. Therefore, we place all code in a try block, log errors in the\n\t\t// catch block, and use an unsafe return statement in the finally block.\n\t\t//\n\t\t// Each early return within the try block returns true because while the\n\t\t// return value is overridden in the finally block, TypeScript\n\t\t// (justifiably) does not recognize the unsafe return statement.\n\t\t//\n\t\t// TODO: Run all callbacks even if one of them errors\n\t\ttry {\n\t\t\tsetEventProperty(ev, \"eventPhase\", CAPTURING_PHASE);\n\t\t\tfor (let i = path.length - 1; i >= 0; i--) {\n\t\t\t\tconst target = path[i];\n\t\t\t\tconst listeners = listenersMap.get(target);\n\t\t\t\tif (listeners) {\n\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", target.ctx);\n\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\tif (record.type === ev.type && record.options.capture) {\n\t\t\t\t\t\t\trecord.callback.call(target.ctx, ev);\n\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t{\n\t\t\t\tconst listeners = listenersMap.get(impl);\n\t\t\t\tif (listeners) {\n\t\t\t\t\tsetEventProperty(ev, \"eventPhase\", AT_TARGET);\n\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", impl.ctx);\n\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\tif (record.type === ev.type) {\n\t\t\t\t\t\t\trecord.callback.call(impl.ctx, ev);\n\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ev.bubbles) {\n\t\t\t\tsetEventProperty(ev, \"eventPhase\", BUBBLING_PHASE);\n\t\t\t\tfor (let i = 0; i < path.length; i++) {\n\t\t\t\t\tconst target = path[i];\n\t\t\t\t\tconst listeners = listenersMap.get(target);\n\t\t\t\t\tif (listeners) {\n\t\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", target.ctx);\n\t\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\t\tif (record.type === ev.type && !record.options.capture) {\n\t\t\t\t\t\t\t\trecord.callback.call(target.ctx, ev);\n\t\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\t// TODO: Use setTimeout to rethrow the error.\n\t\t\tconsole.error(err);\n\t\t} finally {\n\t\t\tsetEventProperty(ev, \"eventPhase\", NONE);\n\t\t\tsetEventProperty(ev, \"currentTarget\", null);\n\t\t\t// eslint-disable-next-line no-unsafe-finally\n\t\t\treturn !ev.defaultPrevented;\n\t\t}\n\t}\n}\n\n/*** PRIVATE CONTEXT FUNCTIONS ***/\nfunction ctxContains(parent: ContextImpl, child: ContextImpl): boolean {\n\tfor (\n\t\tlet current: ContextImpl | undefined = child;\n\t\tcurrent !== undefined;\n\t\tcurrent = current.parent\n\t) {\n\t\tif (current === parent) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction updateComponent<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tparent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n\toldProps: Record<string, any> | undefined,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tlet ctx: ContextImpl<TNode, TScope, TRoot, TResult>;\n\tif (oldProps) {\n\t\tctx = ret.ctx as ContextImpl<TNode, TScope, TRoot, TResult>;\n\t\tif (ctx.f & IsExecuting) {\n\t\t\tconsole.error(\"Component is already executing\");\n\t\t\treturn ret.cached;\n\t\t}\n\t} else {\n\t\tctx = ret.ctx = new ContextImpl(renderer, root, host, parent, scope, ret);\n\t}\n\n\tctx.f |= IsUpdating;\n\tresumeCtxIterator(ctx);\n\treturn runComponent(ctx);\n}\n\nfunction updateComponentChildren<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n\tchildren: Children,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (ctx.f & IsUnmounted || ctx.f & IsErrored) {\n\t\treturn;\n\t} else if (children === undefined) {\n\t\tconsole.error(\n\t\t\t\"A component has returned or yielded undefined. If this was intentional, return or yield null instead.\",\n\t\t);\n\t}\n\n\tlet childValues: Promise<Array<string | TNode>> | Array<string | TNode>;\n\t// We set the isExecuting flag in case a child component dispatches an event\n\t// which bubbles to this component and causes a synchronous refresh().\n\tctx.f |= IsExecuting;\n\ttry {\n\t\tchildValues = diffChildren(\n\t\t\tctx.renderer,\n\t\t\tctx.root,\n\t\t\tctx.host,\n\t\t\tctx,\n\t\t\tctx.scope,\n\t\t\tctx.ret,\n\t\t\tnarrow(children),\n\t\t);\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(childValues)) {\n\t\tctx.ret.inflight = childValues.then((childValues) =>\n\t\t\tcommitComponent(ctx, childValues),\n\t\t);\n\n\t\treturn ctx.ret.inflight;\n\t}\n\n\treturn commitComponent(ctx, childValues);\n}\n\nfunction commitComponent<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode>,\n\tvalues: Array<TNode | string>,\n): ElementValue<TNode> {\n\tif (ctx.f & IsUnmounted) {\n\t\treturn;\n\t}\n\n\tconst listeners = listenersMap.get(ctx);\n\tif (listeners && listeners.length) {\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tconst value = values[i];\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tfor (let j = 0; j < listeners.length; j++) {\n\t\t\t\t\tconst record = listeners[j];\n\t\t\t\t\tvalue.addEventListener(record.type, record.callback, record.options);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst oldValues = wrap(ctx.ret.cached);\n\tlet value = (ctx.ret.cached = unwrap(values));\n\tif (ctx.f & IsScheduling) {\n\t\tctx.f |= IsSchedulingRefresh;\n\t} else if (!(ctx.f & IsUpdating)) {\n\t\t// If we’re not updating the component, which happens when components are\n\t\t// refreshed, or when async generator components iterate, we have to do a\n\t\t// little bit housekeeping when a component’s child values have changed.\n\t\tif (!valuesEqual(oldValues, values)) {\n\t\t\tconst records = getListenerRecords(ctx.parent, ctx.host);\n\t\t\tif (records.length) {\n\t\t\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\t\t\tconst value = values[i];\n\t\t\t\t\tif (isEventTarget(value)) {\n\t\t\t\t\t\tfor (let j = 0; j < records.length; j++) {\n\t\t\t\t\t\t\tconst record = records[j];\n\t\t\t\t\t\t\tvalue.addEventListener(\n\t\t\t\t\t\t\t\trecord.type,\n\t\t\t\t\t\t\t\trecord.callback,\n\t\t\t\t\t\t\t\trecord.options,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// rearranging the nearest ancestor host element\n\t\t\tconst host = ctx.host;\n\t\t\tconst oldHostValues = wrap(host.cached);\n\t\t\tinvalidate(ctx, host);\n\t\t\tconst hostValues = getChildValues(host);\n\t\t\tctx.renderer.arrange(\n\t\t\t\thost.el.tag as string | symbol,\n\t\t\t\thost.value as TNode,\n\t\t\t\thost.el.props,\n\t\t\t\thostValues,\n\t\t\t\t// props and oldProps are the same because the host isn’t updated.\n\t\t\t\thost.el.props,\n\t\t\t\toldHostValues,\n\t\t\t);\n\t\t}\n\n\t\tflush(ctx.renderer, ctx.root, ctx);\n\t}\n\n\tconst callbacks = scheduleMap.get(ctx);\n\tif (callbacks) {\n\t\tscheduleMap.delete(ctx);\n\t\tctx.f |= IsScheduling;\n\t\tconst value1 = ctx.renderer.read(value);\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(value1);\n\t\t}\n\n\t\tctx.f &= ~IsScheduling;\n\t\t// Handles an edge case where refresh() is called during a schedule().\n\t\tif (ctx.f & IsSchedulingRefresh) {\n\t\t\tctx.f &= ~IsSchedulingRefresh;\n\t\t\tvalue = getValue(ctx.ret);\n\t\t}\n\t}\n\n\tctx.f &= ~IsUpdating;\n\treturn value;\n}\n\nfunction invalidate(ctx: ContextImpl, host: Retainer<unknown>): void {\n\tfor (\n\t\tlet parent = ctx.parent;\n\t\tparent !== undefined && parent.host === host;\n\t\tparent = parent.parent\n\t) {\n\t\tparent.ret.cached = undefined;\n\t}\n\n\thost.cached = undefined;\n}\n\nfunction valuesEqual<TValue>(\n\tvalues1: Array<TValue>,\n\tvalues2: Array<TValue>,\n): boolean {\n\tif (values1.length !== values2.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < values1.length; i++) {\n\t\tconst value1 = values1[i];\n\t\tconst value2 = values2[i];\n\t\tif (value1 !== value2) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Enqueues and executes the component associated with the context.\n *\n * The functions stepComponent and runComponent work together\n * to implement the async queueing behavior of components. The runComponent\n * function calls the stepComponent function, which returns two results in a\n * tuple. The first result, called the “block,” is a possible promise which\n * represents the duration for which the component is blocked from accepting\n * new updates. The second result, called the “value,” is the actual result of\n * the update. The runComponent function caches block/value from the\n * stepComponent function on the context, according to whether the component\n * blocks. The “inflight” block/value properties are the currently executing\n * update, and the “enqueued” block/value properties represent an enqueued next\n * stepComponent. Enqueued steps are dequeued every time the current block\n * promise settles.\n */\nfunction runComponent<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (!ctx.inflightBlock) {\n\t\ttry {\n\t\t\tconst [block, value] = stepComponent<TNode, TResult>(ctx);\n\t\t\tif (block) {\n\t\t\t\tctx.inflightBlock = block\n\t\t\t\t\t.catch((err) => {\n\t\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => advanceComponent(ctx));\n\t\t\t\t// stepComponent will only return a block if the value is asynchronous\n\t\t\t\tctx.inflightValue = value as Promise<ElementValue<TNode>>;\n\t\t\t}\n\n\t\t\treturn value;\n\t\t} catch (err) {\n\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t}\n\n\t\t\tthrow err;\n\t\t}\n\t} else if (ctx.f & IsAsyncGen) {\n\t\treturn ctx.inflightValue;\n\t} else if (!ctx.enqueuedBlock) {\n\t\tlet resolve: Function;\n\t\tctx.enqueuedBlock = ctx.inflightBlock\n\t\t\t.then(() => {\n\t\t\t\ttry {\n\t\t\t\t\tconst [block, value] = stepComponent<TNode, TResult>(ctx);\n\t\t\t\t\tresolve(value);\n\t\t\t\t\tif (block) {\n\t\t\t\t\t\treturn block.catch((err) => {\n\t\t\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => advanceComponent(ctx));\n\t\tctx.enqueuedValue = new Promise((resolve1) => (resolve = resolve1));\n\t}\n\n\treturn ctx.enqueuedValue;\n}\n\n/**\n * This function is responsible for executing the component and handling all\n * the different component types.\n *\n * @returns {[block, value]} A tuple where\n * block - A possible promise which represents the duration during which the\n * component is blocked from updating.\n * value - A possible promise resolving to the rendered value of children.\n *\n * Each component type will block according to the type of the component.\n * - Sync function components never block and will transparently pass updates\n * to children.\n * - Async function components and async generator components block while\n * executing itself, but will not block for async children.\n * - Sync generator components block while any children are executing, because\n * they are expected to only resume when they’ve actually rendered.\n */\nfunction stepComponent<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n): [\n\tPromise<unknown> | undefined,\n\tPromise<ElementValue<TNode>> | ElementValue<TNode>,\n] {\n\tconst ret = ctx.ret;\n\tif (ctx.f & IsDone) {\n\t\treturn [undefined, getValue(ret)];\n\t}\n\n\tconst initial = !ctx.iterator;\n\tif (initial) {\n\t\tctx.f |= IsExecuting;\n\t\tclearEventListeners(ctx);\n\t\tlet result: ReturnType<Component>;\n\t\ttry {\n\t\t\tresult = (ret.el.tag as Component).call(ctx.ctx, ret.el.props);\n\t\t} catch (err) {\n\t\t\tctx.f |= IsErrored;\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tctx.f &= ~IsExecuting;\n\t\t}\n\n\t\tif (isIteratorLike(result)) {\n\t\t\tctx.iterator = result;\n\t\t} else if (isPromiseLike(result)) {\n\t\t\t// async function component\n\t\t\tconst result1 =\n\t\t\t\tresult instanceof Promise ? result : Promise.resolve(result);\n\t\t\tconst value = result1.then(\n\t\t\t\t(result) => updateComponentChildren<TNode, TResult>(ctx, result),\n\t\t\t\t(err) => {\n\t\t\t\t\tctx.f |= IsErrored;\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn [result1, value];\n\t\t} else {\n\t\t\t// sync function component\n\t\t\treturn [undefined, updateComponentChildren<TNode, TResult>(ctx, result)];\n\t\t}\n\t}\n\n\tlet oldValue: Promise<TResult> | TResult;\n\tif (initial) {\n\t\t// The argument passed to the first call to next is ignored.\n\t\toldValue = undefined as any;\n\t} else if (ctx.ret.inflight) {\n\t\t// The value passed back into the generator as the argument to the next\n\t\t// method is a promise if an async generator component has async children.\n\t\t// Sync generator components only resume when their children have fulfilled\n\t\t// so the element’s inflight child values will never be defined.\n\t\toldValue = ctx.ret.inflight.then(\n\t\t\t(value) => ctx.renderer.read(value),\n\t\t\t() => ctx.renderer.read(undefined),\n\t\t);\n\t} else {\n\t\toldValue = ctx.renderer.read(getValue(ret));\n\t}\n\n\tlet iteration: ChildrenIteration;\n\tctx.f |= IsExecuting;\n\ttry {\n\t\titeration = ctx.iterator!.next(oldValue);\n\t} catch (err) {\n\t\tctx.f |= IsDone | IsErrored;\n\t\tthrow err;\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(iteration)) {\n\t\t// async generator component\n\t\tif (initial) {\n\t\t\tctx.f |= IsAsyncGen;\n\t\t}\n\n\t\tconst value: Promise<ElementValue<TNode>> = iteration.then(\n\t\t\t(iteration) => {\n\t\t\t\tif (!(ctx.f & IsIterating)) {\n\t\t\t\t\tctx.f &= ~IsAvailable;\n\t\t\t\t}\n\n\t\t\t\tctx.f &= ~IsIterating;\n\t\t\t\tif (iteration.done) {\n\t\t\t\t\tctx.f |= IsDone;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst value = updateComponentChildren<TNode, TResult>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\titeration.value as Children,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (isPromiseLike(value)) {\n\t\t\t\t\t\treturn value.catch((err) => handleChildError(ctx, err));\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t} catch (err) {\n\t\t\t\t\treturn handleChildError(ctx, err);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tctx.f |= IsDone | IsErrored;\n\t\t\t\tthrow err;\n\t\t\t},\n\t\t);\n\n\t\treturn [iteration, value];\n\t}\n\n\t// sync generator component\n\tif (initial) {\n\t\tctx.f |= IsSyncGen;\n\t}\n\n\tctx.f &= ~IsIterating;\n\tif (iteration.done) {\n\t\tctx.f |= IsDone;\n\t}\n\n\tlet value: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\ttry {\n\t\tvalue = updateComponentChildren<TNode, TResult>(\n\t\t\tctx,\n\t\t\titeration.value as Children,\n\t\t);\n\t\tif (isPromiseLike(value)) {\n\t\t\tvalue = value.catch((err) => handleChildError(ctx, err));\n\t\t}\n\t} catch (err) {\n\t\tvalue = handleChildError(ctx, err);\n\t}\n\n\tif (isPromiseLike(value)) {\n\t\treturn [value.catch(NOOP), value];\n\t}\n\n\treturn [undefined, value];\n}\n\n/**\n * Called when the inflight block promise settles.\n */\nfunction advanceComponent(ctx: ContextImpl): void {\n\tctx.inflightBlock = ctx.enqueuedBlock;\n\tctx.inflightValue = ctx.enqueuedValue;\n\tctx.enqueuedBlock = undefined;\n\tctx.enqueuedValue = undefined;\n\tif (ctx.f & IsAsyncGen && !(ctx.f & IsDone) && !(ctx.f & IsUnmounted)) {\n\t\trunComponent(ctx);\n\t}\n}\n\n/**\n * Called to make props available to the props async iterator for async\n * generator components.\n */\nfunction resumeCtxIterator(ctx: ContextImpl): void {\n\tif (ctx.onAvailable) {\n\t\tctx.onAvailable();\n\t\tctx.onAvailable = undefined;\n\t} else {\n\t\tctx.f |= IsAvailable;\n\t}\n}\n\n// TODO: async unmounting\nfunction unmountComponent(ctx: ContextImpl): void {\n\tctx.f |= IsUnmounted;\n\tclearEventListeners(ctx);\n\tconst callbacks = cleanupMap.get(ctx);\n\tif (callbacks) {\n\t\tcleanupMap.delete(ctx);\n\t\tconst value = ctx.renderer.read(getValue(ctx.ret));\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(value);\n\t\t}\n\t}\n\n\tif (!(ctx.f & IsDone)) {\n\t\tctx.f |= IsDone;\n\t\tresumeCtxIterator(ctx);\n\t\tif (ctx.iterator && typeof ctx.iterator.return === \"function\") {\n\t\t\tctx.f |= IsExecuting;\n\t\t\ttry {\n\t\t\t\tconst iteration = ctx.iterator.return();\n\t\t\t\tif (isPromiseLike(iteration)) {\n\t\t\t\t\titeration.catch((err) => propagateError<unknown>(ctx.parent, err));\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tctx.f &= ~IsExecuting;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*** EVENT TARGET UTILITIES ***/\n// EVENT PHASE CONSTANTS\n// https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase\nconst NONE = 0;\nconst CAPTURING_PHASE = 1;\nconst AT_TARGET = 2;\nconst BUBBLING_PHASE = 3;\n\nconst listenersMap = new WeakMap<ContextImpl, Array<EventListenerRecord>>();\n/**\n * A map of event type strings to Event subclasses. Can be extended via\n * TypeScript module augmentation to have strongly typed event listeners.\n */\nexport interface EventMap extends Crank.EventMap {\n\t[type: string]: Event;\n}\n\ntype MappedEventListener<T extends string> = (ev: EventMap[T]) => unknown;\n\ntype MappedEventListenerOrEventListenerObject<T extends string> =\n\t| MappedEventListener<T>\n\t| {handleEvent: MappedEventListener<T>};\n\nfunction isListenerOrListenerObject(\n\tvalue: unknown,\n): value is MappedEventListenerOrEventListenerObject<string> {\n\treturn (\n\t\ttypeof value === \"function\" ||\n\t\t(value !== null &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\ttypeof (value as any).handleEvent === \"function\")\n\t);\n}\n\ninterface EventListenerRecord {\n\ttype: string;\n\tcallback: MappedEventListener<any>;\n\tlistener: MappedEventListenerOrEventListenerObject<any>;\n\toptions: AddEventListenerOptions;\n}\n\nfunction normalizeListenerOptions(\n\toptions: AddEventListenerOptions | boolean | null | undefined,\n): AddEventListenerOptions {\n\tif (typeof options === \"boolean\") {\n\t\treturn {capture: options};\n\t} else if (options == null) {\n\t\treturn {};\n\t}\n\n\treturn options;\n}\n\nfunction isEventTarget(value: any): value is EventTarget {\n\treturn (\n\t\tvalue != null &&\n\t\ttypeof value.addEventListener === \"function\" &&\n\t\ttypeof value.removeEventListener === \"function\" &&\n\t\ttypeof value.dispatchEvent === \"function\"\n\t);\n}\n\nfunction setEventProperty<T extends keyof Event>(\n\tev: Event,\n\tkey: T,\n\tvalue: Event[T],\n): void {\n\tObject.defineProperty(ev, key, {value, writable: false, configurable: true});\n}\n\n// TODO: Maybe we can pass in the current context directly, rather than\n// starting from the parent?\n/**\n * A function to reconstruct an array of every listener given a context and a\n * host element.\n *\n * This function exploits the fact that contexts retain their nearest ancestor\n * host element. We can determine all the contexts which are directly listening\n * to an element by traversing up the context tree and checking that the host\n * element passed in matches the parent context’s host element.\n */\nfunction getListenerRecords(\n\tctx: ContextImpl | undefined,\n\tret: Retainer<unknown>,\n): Array<EventListenerRecord> {\n\tlet listeners: Array<EventListenerRecord> = [];\n\twhile (ctx !== undefined && ctx.host === ret) {\n\t\tconst listeners1 = listenersMap.get(ctx);\n\t\tif (listeners1) {\n\t\t\tlisteners = listeners.concat(listeners1);\n\t\t}\n\n\t\tctx = ctx.parent;\n\t}\n\n\treturn listeners;\n}\n\nfunction clearEventListeners(ctx: ContextImpl): void {\n\tconst listeners = listenersMap.get(ctx);\n\tif (listeners && listeners.length) {\n\t\tfor (const value of getChildValues(ctx.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\tvalue.removeEventListener(\n\t\t\t\t\t\trecord.type,\n\t\t\t\t\t\trecord.callback,\n\t\t\t\t\t\trecord.options,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlisteners.length = 0;\n\t}\n}\n\n/*** ERROR HANDLING UTILITIES ***/\n// TODO: generator components which throw errors should be recoverable\nfunction handleChildError<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode>,\n\terr: unknown,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (\n\t\tctx.f & IsDone ||\n\t\t!ctx.iterator ||\n\t\ttypeof ctx.iterator.throw !== \"function\"\n\t) {\n\t\tthrow err;\n\t}\n\n\tresumeCtxIterator(ctx);\n\tlet iteration: ChildrenIteration;\n\ttry {\n\t\tctx.f |= IsExecuting;\n\t\titeration = ctx.iterator.throw(err);\n\t} catch (err) {\n\t\tctx.f |= IsDone | IsErrored;\n\t\tthrow err;\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(iteration)) {\n\t\treturn iteration.then(\n\t\t\t(iteration) => {\n\t\t\t\tif (iteration.done) {\n\t\t\t\t\tctx.f |= IsDone;\n\t\t\t\t}\n\n\t\t\t\treturn updateComponentChildren(ctx, iteration.value as Children);\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tctx.f |= IsDone | IsErrored;\n\t\t\t\tthrow err;\n\t\t\t},\n\t\t);\n\t}\n\n\tif (iteration.done) {\n\t\tctx.f |= IsDone;\n\t}\n\n\treturn updateComponentChildren(ctx, iteration.value as Children);\n}\n\nfunction propagateError<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode> | undefined,\n\terr: unknown,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (ctx === undefined) {\n\t\tthrow err;\n\t}\n\n\tlet result: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\ttry {\n\t\tresult = handleChildError(ctx, err);\n\t} catch (err) {\n\t\treturn propagateError<TNode>(ctx.parent, err);\n\t}\n\n\tif (isPromiseLike(result)) {\n\t\treturn result.catch((err) => propagateError<TNode>(ctx.parent, err));\n\t}\n\n\treturn result;\n}\n\n// TODO: uncomment and use in the Element interface below\n// type CrankElement = Element;\ndeclare global {\n\tnamespace Crank {\n\t\texport interface EventMap {}\n\n\t\texport interface ProvisionMap {}\n\n\t\texport interface Context {}\n\t}\n\n\tnamespace JSX {\n\t\t// TODO: JSX Element type (the result of JSX expressions) don’t work\n\t\t// because TypeScript demands that all Components return JSX elements for\n\t\t// some reason.\n\t\t// interface Element extends CrankElement {}\n\n\t\texport interface IntrinsicElements {\n\t\t\t[tag: string]: any;\n\t\t}\n\n\t\texport interface ElementChildrenAttribute {\n\t\t\tchildren: {};\n\t\t}\n\t}\n}\n\n// Some JSX transpilation tools expect these functions to be defined on the\n// default export. Prefer named exports when importing directly.\nexport default {createElement, Fragment};\n"],"names":[],"mappings":";;;;AAAA,MAAM,IAAI,GAAG,MAAK,GAAG,CAAC;AACtB,MAAM,QAAQ,GAAG,CAAI,KAAQ,KAAQ,KAAK,CAAC;AAE3C,SAAS,IAAI,CAAI,KAA+B,EA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O,uBAAuB,CAAC,GAAG,EAAE,SAAS,CAAC,KAAiB,CAAC,CAAC;AAClE,SAAC,EACD,CAAC,GAAG,KAAI;AACP,YAAA,GAAG,CAAC,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;AAC5B,YAAA,MAAM,GAAG,CAAC;AACX,SAAC,CACD,CAAC;AACF,KAAA;IAED,IAAI,SAAS,CAAC,IAAI,EAAE;AACnB,QAAA,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC;AAChB,KAAA;IAED,OAAO,uBAAuB,CAAC,GAAG,EAAE,SAAS,CAAC,KAAiB,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CACtB,GAAmD,EACnD,GAAY,EAAA;IAEZ,IAAI,GAAG,KAAK,SAAS,EAAE;AACtB,QAAA,MAAM,GAAG,CAAC;AACV,KAAA;AAED,IAAA,IAAI,MAA0D,CAAC;IAC/D,IAAI;AACH,QAAA,MAAM,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACpC,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE;QACb,OAAO,cAAc,CAAQ,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC9C,KAAA;AAED,IAAA,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;AAC1B,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,cAAc,CAAQ,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACrE,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AACf,CAAC;AA6BD;AACA;AACA,YAAe,EAAC,aAAa,EAAE,QAAQ,EAAC;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"crank.cjs","sources":["../src/crank.ts"],"sourcesContent":["const NOOP = () => {};\nconst IDENTITY = <T>(value: T): T => value;\n\nfunction wrap<T>(value: Array<T> | T | undefined): Array<T> {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n\nfunction unwrap<T>(arr: Array<T>): Array<T> | T | undefined {\n\treturn arr.length === 0 ? undefined : arr.length === 1 ? arr[0] : arr;\n}\n\ntype NonStringIterable<T> = Iterable<T> & object;\n\n/**\n * Ensures a value is an array.\n *\n * This function does the same thing as wrap() above except it handles nulls\n * and iterables, so it is appropriate for wrapping user-provided element\n * children.\n */\nfunction arrayify<T>(\n\tvalue: NonStringIterable<T> | T | null | undefined,\n): Array<T> {\n\treturn value == null\n\t\t? []\n\t\t: Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"string\" ||\n\t\t typeof (value as any)[Symbol.iterator] !== \"function\"\n\t\t? [value]\n\t\t: [...(value as NonStringIterable<T>)];\n}\n\nfunction isIteratorLike(\n\tvalue: any,\n): value is Iterator<unknown> | AsyncIterator<unknown> {\n\treturn value != null && typeof value.next === \"function\";\n}\n\nfunction isPromiseLike(value: any): value is PromiseLike<unknown> {\n\treturn value != null && typeof value.then === \"function\";\n}\n\n/**\n * A type which represents all valid values for an element tag.\n */\nexport type Tag = string | symbol | Component;\n\n/**\n * A helper type to map the tag of an element to its expected props.\n *\n * @template TTag - The tag associated with the props. Can be a string, symbol\n * or a component function.\n */\nexport type TagProps<TTag extends Tag> = TTag extends string\n\t? JSX.IntrinsicElements[TTag]\n\t: TTag extends Component<infer TProps>\n\t? TProps\n\t: Record<string, unknown>;\n\n/***\n * SPECIAL TAGS\n *\n * Crank provides a couple tags which have special meaning for the renderer.\n ***/\n\n/**\n * A special tag for grouping multiple children within the same parent.\n *\n * All non-string iterables which appear in the element tree are implicitly\n * wrapped in a fragment element.\n *\n * This tag is just the empty string, and you can use the empty string in\n * createElement calls or transpiler options directly to avoid having to\n * reference this export.\n */\nexport const Fragment = \"\";\nexport type Fragment = typeof Fragment;\n\n// TODO: We assert the following symbol tags as any because TypeScript support\n// for symbol tags in JSX doesn’t exist yet.\n// https://github.com/microsoft/TypeScript/issues/38367\n\n/**\n * A special tag for rendering into a new root node via a root prop.\n *\n * This tag is useful for creating element trees with multiple roots, for\n * things like modals or tooltips.\n *\n * Renderer.prototype.render() will implicitly wrap top-level element trees in\n * a Portal element.\n */\nexport const Portal = Symbol.for(\"crank.Portal\") as any;\nexport type Portal = typeof Portal;\n\n/**\n * A special tag which preserves whatever was previously rendered in the\n * element’s position.\n *\n * Copy elements are useful for when you want to prevent a subtree from\n * rerendering as a performance optimization. Copy elements can also be keyed,\n * in which case the previously rendered keyed element will be copied.\n */\nexport const Copy = Symbol.for(\"crank.Copy\") as any;\nexport type Copy = typeof Copy;\n\n/**\n * A special tag for injecting raw nodes or strings via a value prop.\n *\n * If the value prop is a string, Renderer.prototype.parse() will be called on\n * the string and the result will be set as the element’s value.\n */\nexport const Raw = Symbol.for(\"crank.Raw\") as any;\nexport type Raw = typeof Raw;\n\n/**\n * Describes all valid values of an element tree, excluding iterables.\n *\n * Arbitrary objects can also be safely rendered, but will be converted to a\n * string using the toString() method. We exclude them from this type to catch\n * potential mistakes.\n */\nexport type Child = Element | string | number | boolean | null | undefined;\n\n/**\n * An arbitrarily nested iterable of Child values.\n *\n * We use a recursive interface here rather than making the Children type\n * directly recursive because recursive type aliases were added in TypeScript\n * 3.7.\n *\n * You should avoid referencing this type directly, as it is mainly exported to\n * prevent TypeScript errors.\n */\nexport interface ChildIterable extends Iterable<Child | ChildIterable> {}\n\n/**\n * Describes all valid values of an element tree, including arbitrarily nested\n * iterables of such values.\n */\nexport type Children = Child | ChildIterable;\n\n/**\n * Represents all functions which can be used as a component.\n *\n * @template [TProps=*] - The expected props for the component.\n */\nexport type Component<TProps extends Record<string, unknown> = any> = (\n\tthis: Context<TProps>,\n\tprops: TProps,\n) =>\n\t| Children\n\t| PromiseLike<Children>\n\t// The return type of iterators must include void because TypeScript will\n\t// infer generators which return implicitly as having a void return type.\n\t| Iterator<Children, Children | void, any>\n\t| AsyncIterator<Children, Children | void, any>;\n\ntype ChildrenIteration =\n\t| Promise<IteratorResult<Children, Children | void>>\n\t| IteratorResult<Children, Children | void>;\n\n/**\n * A type to keep track of keys. Any value can be a key, though null and\n * undefined are ignored.\n */\ntype Key = unknown;\n\nconst ElementSymbol = Symbol.for(\"crank.Element\");\n\n// To maximize compatibility between Crank versions, starting with 0.2.0, any\n// changes to the Element properties will be considered a breaking change.\nexport interface Element<TTag extends Tag = Tag> {\n\t/**\n\t * @internal\n\t * A unique symbol to identify elements as elements across versions and\n\t * realms, and to protect against basic injection attacks.\n\t * https://overreacted.io/why-do-react-elements-have-typeof-property/\n\t *\n\t * This property is defined on the element prototype rather than per\n\t * instance, because it is the same for every Element.\n\t */\n\t$$typeof: typeof ElementSymbol;\n\n\t/**\n\t * The tag of the element. Can be a string, symbol or function.\n\t */\n\ttag: TTag;\n\n\t/**\n\t * An object containing the “properties” of an element. These correspond to\n\t * the attribute syntax from JSX.\n\t */\n\tprops: TagProps<TTag>;\n\n\t/**\n\t * A value which uniquely identifies an element from its siblings so that it\n\t * can be added/updated/moved/removed by key rather than position.\n\t *\n\t * Passed in createElement() as the prop \"c-key\".\n\t */\n\tkey: Key;\n\n\t/**\n\t * A callback which is called with the element’s result when it is committed.\n\t *\n\t * Passed in createElement() as the prop \"c-ref\".\n\t */\n\tref: ((value: unknown) => unknown) | undefined;\n\n\t/**\n\t * A possible boolean which indicates that element should NOT be rerendered.\n\t * If the element has never been rendered, this property has no effect.\n\t *\n\t * Passed in createElement() as the prop \"c-static\".\n\t */\n\tstatic_: boolean | undefined;\n}\n\n/**\n * Elements are the basic building blocks of Crank applications. They are\n * JavaScript objects which are interpreted by special classes called renderers\n * to produce and manage stateful nodes.\n *\n * @template {Tag} [TTag=Tag] - The type of the tag of the element.\n *\n * @example\n * // specific element types\n * let div: Element<\"div\">;\n * let portal: Element<Portal>;\n * let myEl: Element<MyComponent>;\n *\n * // general element types\n * let host: Element<string | symbol>;\n * let component: Element<Component>;\n *\n * Typically, you use a helper function like createElement to create elements\n * rather than instatiating this class directly.\n */\nexport class Element<TTag extends Tag = Tag> {\n\tconstructor(\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t\tkey: Key,\n\t\tref?: ((value: unknown) => unknown) | undefined,\n\t\tstatic_?: boolean | undefined,\n\t) {\n\t\tthis.tag = tag;\n\t\tthis.props = props;\n\t\tthis.key = key;\n\t\tthis.ref = ref;\n\t\tthis.static_ = static_;\n\t}\n}\n\n// See Element interface\nElement.prototype.$$typeof = ElementSymbol;\n\nexport function isElement(value: any): value is Element {\n\treturn value != null && value.$$typeof === ElementSymbol;\n}\n\n/**\n * Creates an element with the specified tag, props and children.\n *\n * This function is usually used as a transpilation target for JSX transpilers,\n * but it can also be called directly. It additionally extracts special props so\n * they aren’t accessible to renderer methods or components, and assigns the\n * children prop according to any additional arguments passed to the function.\n */\nexport function createElement<TTag extends Tag>(\n\ttag: TTag,\n\tprops?: TagProps<TTag> | null | undefined,\n\t...children: Array<unknown>\n): Element<TTag> {\n\tlet key: Key;\n\tlet ref: ((value: unknown) => unknown) | undefined;\n\tlet static_ = false;\n\tconst props1 = {} as TagProps<TTag>;\n\tif (props != null) {\n\t\tfor (const name in props) {\n\t\t\tswitch (name) {\n\t\t\t\tcase \"crank-key\":\n\t\t\t\tcase \"c-key\":\n\t\t\t\tcase \"$key\":\n\t\t\t\t\t// We have to make sure we don’t assign null to the key because we\n\t\t\t\t\t// don’t check for null keys in the diffing functions.\n\t\t\t\t\tif (props[name] != null) {\n\t\t\t\t\t\tkey = props[name];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"crank-ref\":\n\t\t\t\tcase \"c-ref\":\n\t\t\t\tcase \"$ref\":\n\t\t\t\t\tif (typeof props[name] === \"function\") {\n\t\t\t\t\t\tref = props[name];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"crank-static\":\n\t\t\t\tcase \"c-static\":\n\t\t\t\tcase \"$static\":\n\t\t\t\t\tstatic_ = !!props[name];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tprops1[name] = props[name];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (children.length > 1) {\n\t\tprops1.children = children;\n\t} else if (children.length === 1) {\n\t\tprops1.children = children[0];\n\t}\n\n\t// string aliases for the special tags\n\t// TODO: Does this logic belong here, or in the Element constructor\n\tswitch (tag) {\n\t\tcase \"$FRAGMENT\":\n\t\t\ttag = Fragment as any;\n\t\t\tbreak;\n\t\tcase \"$PORTAL\":\n\t\t\ttag = Portal as any;\n\t\t\tbreak;\n\t\tcase \"$COPY\":\n\t\t\ttag = Copy as any;\n\t\t\tbreak;\n\t\tcase \"$RAW\":\n\t\t\ttag = Raw as any;\n\t\t\tbreak;\n\t}\n\n\treturn new Element(tag, props1, key, ref, static_);\n}\n\n/** Clones a given element, shallowly copying the props object. */\nexport function cloneElement<TTag extends Tag>(\n\tel: Element<TTag>,\n): Element<TTag> {\n\tif (!isElement(el)) {\n\t\tthrow new TypeError(\"Cannot clone non-element\");\n\t}\n\n\treturn new Element(el.tag, {...el.props}, el.key, el.ref);\n}\n\n/*** ELEMENT UTILITIES ***/\n\n// WHAT ARE WE DOING TO THE CHILDREN???\n/**\n * All values in the element tree are narrowed from the union in Child to\n * NarrowedChild during rendering, to simplify element diffing.\n */\ntype NarrowedChild = Element | string | undefined;\n\nfunction narrow(value: Children): NarrowedChild {\n\tif (typeof value === \"boolean\" || value == null) {\n\t\treturn undefined;\n\t} else if (typeof value === \"string\" || isElement(value)) {\n\t\treturn value;\n\t} else if (typeof (value as any)[Symbol.iterator] === \"function\") {\n\t\treturn createElement(Fragment, null, value);\n\t}\n\n\treturn value.toString();\n}\n\n/**\n * A helper type which repesents all possible rendered values of an element.\n *\n * @template TNode - The node type for the element provided by the renderer.\n *\n * When asking the question, what is the “value” of a specific element, the\n * answer varies depending on the tag:\n *\n * For host elements, the value is the nodes created for the element.\n *\n * For fragments, the value is usually an array of nodes.\n *\n * For portals, the value is undefined, because a Portal element’s root and\n * children are opaque to its parent.\n *\n * For components, the value can be any of the above, because the value of a\n * component is determined by its immediate children.\n *\n * Rendered values can also be strings or arrays of nodes and strings, in the\n * case of component or fragment elements with strings or multiple children.\n *\n * All of these possible values are reflected in this utility type.\n */\nexport type ElementValue<TNode> =\n\t| Array<TNode | string>\n\t| TNode\n\t| string\n\t| undefined;\n\n/**\n * Takes an array of element values and normalizes the output as an array of\n * nodes and strings.\n *\n * @returns Normalized array of nodes and/or strings.\n *\n * Normalize will flatten only one level of nested arrays, because it is\n * designed to be called once at each level of the tree. It will also\n * concatenate adjacent strings and remove all undefined values.\n */\nfunction normalize<TNode>(\n\tvalues: Array<ElementValue<TNode>>,\n): Array<TNode | string> {\n\tconst result: Array<TNode | string> = [];\n\tlet buffer: string | undefined;\n\tfor (let i = 0; i < values.length; i++) {\n\t\tconst value = values[i];\n\t\tif (!value) {\n\t\t\t// pass\n\t\t} else if (typeof value === \"string\") {\n\t\t\tbuffer = (buffer || \"\") + value;\n\t\t} else if (!Array.isArray(value)) {\n\t\t\tif (buffer) {\n\t\t\t\tresult.push(buffer);\n\t\t\t\tbuffer = undefined;\n\t\t\t}\n\n\t\t\tresult.push(value);\n\t\t} else {\n\t\t\t// We could use recursion here but it’s just easier to do it inline.\n\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\tconst value1 = value[j];\n\t\t\t\tif (!value1) {\n\t\t\t\t\t// pass\n\t\t\t\t} else if (typeof value1 === \"string\") {\n\t\t\t\t\tbuffer = (buffer || \"\") + value1;\n\t\t\t\t} else {\n\t\t\t\t\tif (buffer) {\n\t\t\t\t\t\tresult.push(buffer);\n\t\t\t\t\t\tbuffer = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tresult.push(value1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (buffer) {\n\t\tresult.push(buffer);\n\t}\n\n\treturn result;\n}\n\n/**\n * @internal\n * The internal nodes which are cached and diffed against new elements when\n * rendering element trees.\n */\nclass Retainer<TNode> {\n\t/**\n\t * The element associated with this retainer.\n\t */\n\tdeclare el: Element;\n\t/**\n\t * The context associated with this element. Will only be defined for\n\t * component elements.\n\t */\n\tdeclare ctx: ContextImpl<TNode> | undefined;\n\t/**\n\t * The retainer children of this element. Retainers form a tree which mirrors\n\t * elements. Can be a single child or undefined as a memory optimization.\n\t */\n\tdeclare children: Array<RetainerChild<TNode>> | RetainerChild<TNode>;\n\t/**\n\t * The value associated with this element.\n\t */\n\tdeclare value: ElementValue<TNode>;\n\t/**\n\t * The cached child values of this element. Only host and component elements\n\t * will use this property.\n\t */\n\tdeclare cached: ElementValue<TNode>;\n\t/**\n\t * The child which this retainer replaces. This property is used when an\n\t * async retainer tree replaces previously rendered elements, so that the\n\t * previously rendered elements can remain visible until the async tree\n\t * fulfills. Will be set to undefined once this subtree fully renders.\n\t */\n\tdeclare fallback: RetainerChild<TNode>;\n\tdeclare inflight: Promise<ElementValue<TNode>> | undefined;\n\tdeclare onCommit: Function | undefined;\n\tconstructor(el: Element) {\n\t\tthis.el = el;\n\t\tthis.value = undefined;\n\t\tthis.ctx = undefined;\n\t\tthis.children = undefined;\n\t\tthis.cached = undefined;\n\t\tthis.fallback = undefined;\n\t\tthis.inflight = undefined;\n\t\tthis.onCommit = undefined;\n\t}\n}\n\n/**\n * The retainer equivalent of ElementValue\n */\ntype RetainerChild<TNode> = Retainer<TNode> | string | undefined;\n\n/**\n * Finds the value of the element according to its type.\n *\n * @returns The value of the element.\n */\nfunction getValue<TNode>(ret: Retainer<TNode>): ElementValue<TNode> {\n\tif (typeof ret.fallback !== \"undefined\") {\n\t\treturn typeof ret.fallback === \"object\"\n\t\t\t? getValue(ret.fallback)\n\t\t\t: ret.fallback;\n\t} else if (ret.el.tag === Portal) {\n\t\treturn;\n\t} else if (typeof ret.el.tag !== \"function\" && ret.el.tag !== Fragment) {\n\t\treturn ret.value;\n\t}\n\n\treturn unwrap(getChildValues(ret));\n}\n\n/**\n * Walks an element’s children to find its child values.\n *\n * @returns A normalized array of nodes and strings.\n */\nfunction getChildValues<TNode>(ret: Retainer<TNode>): Array<TNode | string> {\n\tif (ret.cached) {\n\t\treturn wrap(ret.cached);\n\t}\n\n\tconst values: Array<ElementValue<TNode>> = [];\n\tconst children = wrap(ret.children);\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (child) {\n\t\t\tvalues.push(typeof child === \"string\" ? child : getValue(child));\n\t\t}\n\t}\n\n\tconst values1 = normalize(values);\n\tconst tag = ret.el.tag;\n\tif (typeof tag === \"function\" || (tag !== Fragment && tag !== Raw)) {\n\t\tret.cached = unwrap(values1);\n\t}\n\treturn values1;\n}\n\n// TODO: Document the interface and methods\nexport interface RendererImpl<\n\tTNode,\n\tTScope,\n\tTRoot extends TNode = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\tscope<TTag extends string | symbol>(\n\t\tscope: TScope | undefined,\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t): TScope | undefined;\n\n\tcreate<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tprops: TagProps<TTag>,\n\t\tscope: TScope | undefined,\n\t): TNode;\n\n\t/**\n\t * Called when an element’s rendered value is exposed via render, schedule,\n\t * refresh, refs, or generator yield expressions.\n\t *\n\t * @param value - The value of the element being read. Can be a node, a\n\t * string, undefined, or an array of nodes and strings, depending on the\n\t * element.\n\t *\n\t * @returns Varies according to the specific renderer subclass. By default,\n\t * it exposes the element’s value.\n\t *\n\t * This is useful for renderers which don’t want to expose their internal\n\t * nodes. For instance, the HTML renderer will convert all internal nodes to\n\t * strings.\n\t */\n\tread(value: ElementValue<TNode>): TResult;\n\n\t/**\n\t * Called for each string in an element tree.\n\t *\n\t * @param text - The string child.\n\t * @param scope - The current scope.\n\t *\n\t * @returns The escaped string.\n\t *\n\t * Rather than returning text nodes for whatever environment we’re rendering\n\t * to, we defer that step for Renderer.prototype.arrange. We do this so that\n\t * adjacent strings can be concatenated and the actual element tree can be\n\t * rendered in a normalized form.\n\t */\n\tescape(text: string, scope: TScope | undefined): string;\n\n\t/**\n\t * Called for each Raw element whose value prop is a string.\n\t *\n\t * @param text - The string child.\n\t * @param scope - The current scope.\n\t *\n\t * @returns The parsed node or string.\n\t */\n\tparse(text: string, scope: TScope | undefined): ElementValue<TNode>;\n\n\tpatch<TTag extends string | symbol, TName extends string>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tname: TName,\n\t\tvalue: TagProps<TTag>[TName],\n\t\toldValue: TagProps<TTag>[TName] | undefined,\n\t\tscope: TScope,\n\t): unknown;\n\n\tarrange<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tprops: TagProps<TTag>,\n\t\tchildren: Array<TNode | string>,\n\t\toldProps: TagProps<TTag> | undefined,\n\t\toldChildren: Array<TNode | string> | undefined,\n\t): unknown;\n\n\tdispose<TTag extends string | symbol>(\n\t\ttag: TTag,\n\t\tnode: TNode,\n\t\tprops: TagProps<TTag>,\n\t): unknown;\n\n\tflush(root: TRoot): unknown;\n}\n\nconst defaultRendererImpl: RendererImpl<unknown, unknown, unknown, unknown> = {\n\tcreate() {\n\t\tthrow new Error(\"Not implemented\");\n\t},\n\tscope: IDENTITY,\n\tread: IDENTITY,\n\tescape: IDENTITY,\n\tparse: IDENTITY,\n\tpatch: NOOP,\n\tarrange: NOOP,\n\tdispose: NOOP,\n\tflush: NOOP,\n};\n\nconst $RendererImpl = Symbol.for(\"crank.RendererImpl\");\n/**\n * An abstract class which is subclassed to render to different target\n * environments. This class is responsible for kicking off the rendering\n * process and caching previous trees by root.\n *\n * @template TNode - The type of the node for a rendering environment.\n * @template TScope - Data which is passed down the tree.\n * @template TRoot - The type of the root for a rendering environment.\n * @template TResult - The type of exposed values.\n */\nexport class Renderer<\n\tTNode extends object = object,\n\tTScope = unknown,\n\tTRoot extends TNode = TNode,\n\tTResult = ElementValue<TNode>,\n> {\n\t/**\n\t * @internal\n\t * A weakmap which stores element trees by root.\n\t */\n\tdeclare cache: WeakMap<object, Retainer<TNode>>;\n\n\tdeclare [$RendererImpl]: RendererImpl<TNode, TScope, TRoot, TResult>;\n\tconstructor(impl: Partial<RendererImpl<TNode, TScope, TRoot, TResult>>) {\n\t\tthis.cache = new WeakMap();\n\t\tthis[$RendererImpl] = {\n\t\t\t...(defaultRendererImpl as RendererImpl<TNode, TScope, TRoot, TResult>),\n\t\t\t...impl,\n\t\t};\n\t}\n\n\t/**\n\t * Renders an element tree into a specific root.\n\t *\n\t * @param children - An element tree. You can render null with a previously\n\t * used root to delete the previously rendered element tree from the cache.\n\t * @param root - The node to be rendered into. The renderer will cache\n\t * element trees per root.\n\t * @param ctx - An optional context that will be the ancestor context of all\n\t * elements in the tree. Useful for connecting different renderers so that\n\t * events/provisions properly propagate. The context for a given root must be\n\t * the same or an error will be thrown.\n\t *\n\t * @returns The result of rendering the children, or a possible promise of\n\t * the result if the element tree renders asynchronously.\n\t */\n\trender(\n\t\tchildren: Children,\n\t\troot?: TRoot | undefined,\n\t\tbridge?: Context | undefined,\n\t): Promise<TResult> | TResult {\n\t\tlet ret: Retainer<TNode> | undefined;\n\t\tconst ctx = bridge && (bridge[$ContextImpl] as ContextImpl<TNode>);\n\t\tif (typeof root === \"object\" && root !== null) {\n\t\t\tret = this.cache.get(root);\n\t\t}\n\n\t\tlet oldProps: Record<string, any> | undefined;\n\t\tif (ret === undefined) {\n\t\t\tret = new Retainer(createElement(Portal, {children, root}));\n\t\t\tret.value = root;\n\t\t\tret.ctx = ctx;\n\t\t\tif (typeof root === \"object\" && root !== null && children != null) {\n\t\t\t\tthis.cache.set(root, ret);\n\t\t\t}\n\t\t} else if (ret.ctx !== ctx) {\n\t\t\tthrow new Error(\"Context mismatch\");\n\t\t} else {\n\t\t\toldProps = ret.el.props;\n\t\t\tret.el = createElement(Portal, {children, root});\n\t\t\tif (typeof root === \"object\" && root !== null && children == null) {\n\t\t\t\tthis.cache.delete(root);\n\t\t\t}\n\t\t}\n\n\t\tconst impl = this[$RendererImpl];\n\t\tconst childValues = diffChildren(\n\t\t\timpl,\n\t\t\troot,\n\t\t\tret,\n\t\t\tctx,\n\t\t\timpl.scope(undefined, Portal, ret.el.props),\n\t\t\tret,\n\t\t\tchildren,\n\t\t);\n\n\t\t// We return the child values of the portal because portal elements\n\t\t// themselves have no readable value.\n\t\tif (isPromiseLike(childValues)) {\n\t\t\treturn childValues.then((childValues) =>\n\t\t\t\tcommitRootRender(impl, root, ctx, ret!, childValues, oldProps),\n\t\t\t);\n\t\t}\n\n\t\treturn commitRootRender(impl, root, ctx, ret, childValues, oldProps);\n\t}\n}\n\n/*** PRIVATE RENDERER FUNCTIONS ***/\nfunction commitRootRender<TNode, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, unknown, TRoot, TResult>,\n\troot: TRoot | undefined,\n\tctx: ContextImpl<TNode> | undefined,\n\tret: Retainer<TNode>,\n\tchildValues: Array<TNode | string>,\n\toldProps: Record<string, any> | undefined,\n): TResult {\n\t// element is a host or portal element\n\tif (root !== undefined) {\n\t\trenderer.arrange(\n\t\t\tPortal,\n\t\t\troot,\n\t\t\tret.el.props,\n\t\t\tchildValues,\n\t\t\toldProps,\n\t\t\twrap(ret.cached),\n\t\t);\n\t\tflush(renderer, root);\n\t}\n\n\tret.cached = unwrap(childValues);\n\tif (root == null) {\n\t\tunmount(renderer, ret, ctx, ret);\n\t}\n\n\treturn renderer.read(ret.cached);\n}\n\nfunction diffChildren<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\tparent: Retainer<TNode>,\n\tchildren: Children,\n): Promise<Array<TNode | string>> | Array<TNode | string> {\n\tconst oldRetained = wrap(parent.children);\n\tconst newRetained: typeof oldRetained = [];\n\tconst newChildren = arrayify(children);\n\tconst values: Array<Promise<ElementValue<TNode>> | ElementValue<TNode>> = [];\n\tlet graveyard: Array<Retainer<TNode>> | undefined;\n\tlet childrenByKey: Map<Key, Retainer<TNode>> | undefined;\n\tlet seenKeys: Set<Key> | undefined;\n\tlet isAsync = false;\n\tlet oi = 0,\n\t\toldLength = oldRetained.length;\n\tfor (let ni = 0, newLength = newChildren.length; ni < newLength; ni++) {\n\t\t// We make sure we don’t access indices out of bounds to prevent\n\t\t// deoptimizations.\n\t\tlet ret = oi >= oldLength ? undefined : oldRetained[oi];\n\t\tlet child = narrow(newChildren[ni]);\n\t\t{\n\t\t\t// Aligning new children with old retainers\n\t\t\tlet oldKey = typeof ret === \"object\" ? ret.el.key : undefined;\n\t\t\tlet newKey = typeof child === \"object\" ? child.key : undefined;\n\t\t\tif (newKey !== undefined && seenKeys && seenKeys.has(newKey)) {\n\t\t\t\tconsole.error(\"Duplicate key\", newKey);\n\t\t\t\tnewKey = undefined;\n\t\t\t}\n\n\t\t\tif (oldKey === newKey) {\n\t\t\t\tif (childrenByKey !== undefined && newKey !== undefined) {\n\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t}\n\n\t\t\t\toi++;\n\t\t\t} else {\n\t\t\t\tchildrenByKey = childrenByKey || createChildrenByKey(oldRetained, oi);\n\t\t\t\tif (newKey === undefined) {\n\t\t\t\t\twhile (ret !== undefined && oldKey !== undefined) {\n\t\t\t\t\t\toi++;\n\t\t\t\t\t\tret = oldRetained[oi];\n\t\t\t\t\t\toldKey = typeof ret === \"object\" ? ret.el.key : undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\toi++;\n\t\t\t\t} else {\n\t\t\t\t\tret = childrenByKey.get(newKey);\n\t\t\t\t\tif (ret !== undefined) {\n\t\t\t\t\t\tchildrenByKey.delete(newKey);\n\t\t\t\t\t}\n\n\t\t\t\t\t(seenKeys = seenKeys || new Set()).add(newKey);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Updating\n\t\tlet value: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\t\tif (typeof child === \"object\") {\n\t\t\tif (typeof ret === \"object\" && child.static_) {\n\t\t\t\tret.el = child;\n\t\t\t\tvalue = getInflightValue(ret);\n\t\t\t} else if (child.tag === Copy) {\n\t\t\t\tvalue = getInflightValue(ret);\n\t\t\t} else {\n\t\t\t\tlet oldProps: Record<string, any> | undefined;\n\t\t\t\tif (typeof ret === \"object\" && ret.el.tag === child.tag) {\n\t\t\t\t\toldProps = ret.el.props;\n\t\t\t\t\tret.el = child;\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fallback = ret;\n\t\t\t\t\tret = new Retainer<TNode>(child);\n\t\t\t\t\tret.fallback = fallback;\n\t\t\t\t}\n\n\t\t\t\tif (child.tag === Raw) {\n\t\t\t\t\tvalue = updateRaw(renderer, ret, scope, oldProps);\n\t\t\t\t} else if (child.tag === Fragment) {\n\t\t\t\t\tvalue = updateFragment(renderer, root, host, ctx, scope, ret);\n\t\t\t\t} else if (typeof child.tag === \"function\") {\n\t\t\t\t\tvalue = updateComponent(\n\t\t\t\t\t\trenderer,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tret,\n\t\t\t\t\t\toldProps,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tvalue = updateHost(renderer, root, ctx, scope, ret, oldProps);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ref = child.ref;\n\t\t\tif (isPromiseLike(value)) {\n\t\t\t\tisAsync = true;\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tvalue = value.then((value) => {\n\t\t\t\t\t\tref(renderer.read(value));\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (typeof ref === \"function\") {\n\t\t\t\tref(renderer.read(value));\n\t\t\t}\n\t\t} else {\n\t\t\t// child is a string or undefined\n\t\t\tif (typeof ret === \"object\") {\n\t\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t\t}\n\n\t\t\tif (typeof child === \"string\") {\n\t\t\t\tvalue = ret = renderer.escape(child, scope);\n\t\t\t} else {\n\t\t\t\tret = undefined;\n\t\t\t}\n\t\t}\n\n\t\tvalues[ni] = value;\n\t\tnewRetained[ni] = ret;\n\t}\n\n\t// cleanup remaining retainers\n\tfor (; oi < oldLength; oi++) {\n\t\tconst ret = oldRetained[oi];\n\t\tif (typeof ret === \"object\" && typeof ret.el.key === \"undefined\") {\n\t\t\t(graveyard = graveyard || []).push(ret);\n\t\t}\n\t}\n\n\tif (childrenByKey !== undefined && childrenByKey.size > 0) {\n\t\t(graveyard = graveyard || []).push(...childrenByKey.values());\n\t}\n\n\tparent.children = unwrap(newRetained);\n\tif (isAsync) {\n\t\tlet childValues1 = Promise.all(values).finally(() => {\n\t\t\tif (graveyard) {\n\t\t\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\t\t\tunmount(renderer, host, ctx, graveyard[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tlet onChildValues!: Function;\n\t\tchildValues1 = Promise.race([\n\t\t\tchildValues1,\n\t\t\tnew Promise<any>((resolve) => (onChildValues = resolve)),\n\t\t]);\n\n\t\tif (parent.onCommit) {\n\t\t\tparent.onCommit(childValues1);\n\t\t}\n\n\t\tparent.onCommit = onChildValues;\n\t\treturn childValues1.then((childValues) => {\n\t\t\tparent.inflight = parent.fallback = undefined;\n\t\t\treturn normalize(childValues);\n\t\t});\n\t}\n\n\tif (graveyard) {\n\t\tfor (let i = 0; i < graveyard.length; i++) {\n\t\t\tunmount(renderer, host, ctx, graveyard[i]);\n\t\t}\n\t}\n\n\tif (parent.onCommit) {\n\t\tparent.onCommit(values);\n\t\tparent.onCommit = undefined;\n\t}\n\n\tparent.inflight = parent.fallback = undefined;\n\t// We can assert there are no promises in the array because isAsync is false\n\treturn normalize(values as Array<ElementValue<TNode>>);\n}\n\nfunction createChildrenByKey<TNode>(\n\tchildren: Array<RetainerChild<TNode>>,\n\toffset: number,\n): Map<Key, Retainer<TNode>> {\n\tconst childrenByKey = new Map<Key, Retainer<TNode>>();\n\tfor (let i = offset; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (typeof child === \"object\" && typeof child.el.key !== \"undefined\") {\n\t\t\tchildrenByKey.set(child.el.key, child);\n\t\t}\n\t}\n\n\treturn childrenByKey;\n}\n\nfunction getInflightValue<TNode>(\n\tchild: RetainerChild<TNode>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (typeof child !== \"object\") {\n\t\treturn child;\n\t}\n\n\tconst ctx: ContextImpl<TNode> | undefined =\n\t\ttypeof child.el.tag === \"function\" ? child.ctx : undefined;\n\tif (ctx && ctx.f & IsUpdating && ctx.inflightValue) {\n\t\treturn ctx.inflightValue;\n\t} else if (child.inflight) {\n\t\treturn child.inflight;\n\t}\n\n\treturn getValue(child);\n}\n\nfunction updateRaw<TNode, TScope>(\n\trenderer: RendererImpl<TNode, TScope, TNode, unknown>,\n\tret: Retainer<TNode>,\n\tscope: TScope | undefined,\n\toldProps: Record<string, any> | undefined,\n): ElementValue<TNode> {\n\tconst props = ret.el.props;\n\tif (typeof props.value === \"string\") {\n\t\tif (!oldProps || oldProps.value !== props.value) {\n\t\t\tret.value = renderer.parse(props.value, scope);\n\t\t}\n\t} else {\n\t\tret.value = props.value;\n\t}\n\n\treturn ret.value;\n}\n\nfunction updateFragment<TNode, TScope, TRoot extends TNode>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, unknown>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tconst childValues = diffChildren(\n\t\trenderer,\n\t\troot,\n\t\thost,\n\t\tctx,\n\t\tscope,\n\t\tret,\n\t\tret.el.props.children,\n\t);\n\n\tif (isPromiseLike(childValues)) {\n\t\tret.inflight = childValues.then((childValues) => unwrap(childValues));\n\t\treturn ret.inflight;\n\t}\n\n\treturn unwrap(childValues);\n}\n\nfunction updateHost<TNode, TScope, TRoot extends TNode>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, unknown>,\n\troot: TRoot | undefined,\n\tctx: ContextImpl<TNode, TScope, TRoot> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n\toldProps: Record<string, any> | undefined,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tconst el = ret.el;\n\tconst tag = el.tag as string | symbol;\n\tif (el.tag === Portal) {\n\t\troot = ret.value = el.props.root;\n\t} else if (!oldProps) {\n\t\t// We use the truthiness of oldProps to determine if this the first render.\n\t\tret.value = renderer.create(tag, el.props, scope);\n\t}\n\n\tscope = renderer.scope(scope, tag, el.props);\n\tconst childValues = diffChildren(\n\t\trenderer,\n\t\troot,\n\t\tret,\n\t\tctx,\n\t\tscope,\n\t\tret,\n\t\tret.el.props.children,\n\t);\n\n\tif (isPromiseLike(childValues)) {\n\t\tret.inflight = childValues.then((childValues) =>\n\t\t\tcommitHost(renderer, scope, ret, childValues, oldProps),\n\t\t);\n\n\t\treturn ret.inflight;\n\t}\n\n\treturn commitHost(renderer, scope, ret, childValues, oldProps);\n}\n\nfunction commitHost<TNode, TScope>(\n\trenderer: RendererImpl<TNode, TScope, TNode, unknown>,\n\tscope: TScope,\n\tret: Retainer<TNode>,\n\tchildValues: Array<TNode | string>,\n\toldProps: Record<string, any> | undefined,\n): ElementValue<TNode> {\n\tconst tag = ret.el.tag as string | symbol;\n\tconst value = ret.value as TNode;\n\tlet props = ret.el.props;\n\tlet copied: Set<string> | undefined;\n\tif (tag !== Portal) {\n\t\tfor (const propName in {...oldProps, ...props}) {\n\t\t\tconst propValue = props[propName];\n\t\t\tif (propValue === Copy) {\n\t\t\t\t(copied = copied || new Set()).add(propName);\n\t\t\t} else if (propName !== \"children\") {\n\t\t\t\trenderer.patch(\n\t\t\t\t\ttag,\n\t\t\t\t\tvalue,\n\t\t\t\t\tpropName,\n\t\t\t\t\tpropValue,\n\t\t\t\t\toldProps && oldProps[propName],\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copied) {\n\t\tprops = {...ret.el.props};\n\t\tfor (const name of copied) {\n\t\t\tprops[name] = oldProps && oldProps[name];\n\t\t}\n\n\t\tret.el = new Element(tag, props, ret.el.key, ret.el.ref);\n\t}\n\n\trenderer.arrange(tag, value, props, childValues, oldProps, wrap(ret.cached));\n\tret.cached = unwrap(childValues);\n\tif (tag === Portal) {\n\t\tflush(renderer, ret.value);\n\t\treturn;\n\t}\n\n\treturn value;\n}\n\nfunction flush<TRoot>(\n\trenderer: RendererImpl<unknown, unknown, TRoot>,\n\troot: TRoot,\n\tinitiator?: ContextImpl,\n) {\n\trenderer.flush(root);\n\tif (typeof root !== \"object\" || root === null) {\n\t\treturn;\n\t}\n\n\tconst flushMap = flushMaps.get(root as any);\n\tif (flushMap) {\n\t\tif (initiator) {\n\t\t\tconst flushMap1 = new Map<ContextImpl, Set<Function>>();\n\t\t\tfor (let [ctx, callbacks] of flushMap) {\n\t\t\t\tif (!ctxContains(initiator, ctx)) {\n\t\t\t\t\tflushMap.delete(ctx);\n\t\t\t\t\tflushMap1.set(ctx, callbacks);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (flushMap1.size) {\n\t\t\t\tflushMaps.set(root as any, flushMap1);\n\t\t\t} else {\n\t\t\t\tflushMaps.delete(root as any);\n\t\t\t}\n\t\t} else {\n\t\t\tflushMaps.delete(root as any);\n\t\t}\n\n\t\tfor (const [ctx, callbacks] of flushMap) {\n\t\t\tconst value = renderer.read(getValue(ctx.ret));\n\t\t\tfor (const callback of callbacks) {\n\t\t\t\tcallback(value);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction unmount<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\thost: Retainer<TNode>,\n\tctx: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tret: Retainer<TNode>,\n): void {\n\tif (typeof ret.el.tag === \"function\") {\n\t\tctx = ret.ctx as ContextImpl<TNode, TScope, TRoot, TResult>;\n\t\tunmountComponent(ctx);\n\t} else if (ret.el.tag === Portal) {\n\t\thost = ret;\n\t\trenderer.arrange(\n\t\t\tPortal,\n\t\t\thost.value as TNode,\n\t\t\thost.el.props,\n\t\t\t[],\n\t\t\thost.el.props,\n\t\t\twrap(host.cached),\n\t\t);\n\t\tflush(renderer, host.value);\n\t} else if (ret.el.tag !== Fragment) {\n\t\tif (isEventTarget(ret.value)) {\n\t\t\tconst records = getListenerRecords(ctx, host);\n\t\t\tfor (let i = 0; i < records.length; i++) {\n\t\t\t\tconst record = records[i];\n\t\t\t\tret.value.removeEventListener(\n\t\t\t\t\trecord.type,\n\t\t\t\t\trecord.callback,\n\t\t\t\t\trecord.options,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\trenderer.dispose(ret.el.tag, ret.value as TNode, ret.el.props);\n\t\thost = ret;\n\t}\n\n\tconst children = wrap(ret.children);\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (typeof child === \"object\") {\n\t\t\tunmount(renderer, host, ctx, child);\n\t\t}\n\t}\n}\n\n/*** CONTEXT FLAGS ***/\n/**\n * A flag which is set when the component is being updated by the parent and\n * cleared when the component has committed. Used to determine things like\n * whether the nearest host ancestor needs to be rearranged.\n */\nconst IsUpdating = 1 << 0;\n\n/**\n * A flag which is set when the component function or generator is\n * synchronously executing. This flags is used to ensure that a component which\n * triggers a second update in the course of rendering does not cause a stack\n * overflow or a generator error.\n */\nconst IsExecuting = 1 << 1;\n\n/**\n * A flag used to make sure multiple values are not pulled from context prop\n * iterators without a yield.\n */\nconst IsIterating = 1 << 2;\n\n/**\n * A flag used by async generator components in conjunction with the\n * onavailable (_oa) callback to mark whether new props can be pulled via the\n * context async iterator. See the Symbol.asyncIterator method and the\n * resumeCtxIterator function.\n */\nconst IsAvailable = 1 << 3;\n\n/**\n * A flag which is set when a generator components returns, i.e. the done\n * property on the iteration is set to true. Generator components will stick to\n * their last rendered value and ignore further updates.\n */\nconst IsDone = 1 << 4;\n\n/**\n * A flag which is set when a generator component errors.\n *\n * NOTE: This is mainly used to prevent some false positives in component\n * yields or returns undefined warnings. The reason we’re using this versus\n * IsUnmounted is a very troubling test (cascades sync generator parent and\n * sync generator child) where synchronous code causes a stack overflow error\n * in a non-deterministic way. Deeply disturbing stuff.\n */\nconst IsErrored = 1 << 5;\n\n/**\n * A flag which is set when the component is unmounted. Unmounted components\n * are no longer in the element tree and cannot refresh or rerender.\n */\nconst IsUnmounted = 1 << 6;\n\n/**\n * A flag which indicates that the component is a sync generator component.\n */\nconst IsSyncGen = 1 << 7;\n\n/**\n * A flag which indicates that the component is an async generator component.\n */\nconst IsAsyncGen = 1 << 8;\n\n/**\n * A flag which is set while schedule callbacks are called.\n */\nconst IsScheduling = 1 << 9;\n\n/**\n * A flag which is set when a schedule callback calls refresh.\n */\nconst IsSchedulingRefresh = 1 << 10;\n\nexport interface Context extends Crank.Context {}\n\n/**\n * An interface which can be extended to provide strongly typed provisions.\n * See Context.prototype.consume and Context.prototype.provide.\n */\nexport interface ProvisionMap extends Crank.ProvisionMap {}\n\nconst provisionMaps = new WeakMap<ContextImpl, Map<unknown, unknown>>();\n\nconst scheduleMap = new WeakMap<ContextImpl, Set<Function>>();\n\nconst cleanupMap = new WeakMap<ContextImpl, Set<Function>>();\n\n// keys are roots\nconst flushMaps = new WeakMap<object, Map<ContextImpl, Set<Function>>>();\n\n/**\n * @internal\n * The internal class which holds all context data.\n */\nclass ContextImpl<\n\tTNode = unknown,\n\tTScope = unknown,\n\tTRoot extends TNode = TNode,\n\tTResult = unknown,\n> {\n\t/**\n\t * flags - A bitmask. See CONTEXT FLAGS above.\n\t */\n\tdeclare f: number;\n\n\t/**\n\t * ctx - The actual object passed as this to components.\n\t */\n\tdeclare ctx: Context<unknown, TResult>;\n\n\t/**\n\t * renderer - The renderer which created this context.\n\t */\n\tdeclare renderer: RendererImpl<TNode, TScope, TRoot, TResult>;\n\n\t/**\n\t * root - The root node as set by the nearest ancestor portal.\n\t */\n\tdeclare root: TRoot | undefined;\n\n\t/**\n\t * host - The nearest host or portal retainer.\n\t *\n\t * When refresh is called, the host element will be arranged as the last step\n\t * of the commit, to make sure the parent’s children properly reflects the\n\t * components’s children.\n\t */\n\tdeclare host: Retainer<TNode>;\n\n\t/**\n\t * parent - The parent context.\n\t */\n\tdeclare parent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined;\n\n\t/**\n\t * scope - The value of the scope at the point of element’s creation.\n\t */\n\tdeclare scope: TScope | undefined;\n\n\t/**\n\t * retainer - The internal node associated with this context.\n\t */\n\tdeclare ret: Retainer<TNode>;\n\n\t/**\n\t * iterator - The iterator returned by the component function.\n\t */\n\tdeclare iterator:\n\t\t| Iterator<Children, Children | void, unknown>\n\t\t| AsyncIterator<Children, Children | void, unknown>\n\t\t| undefined;\n\n\t/*** async properties ***/\n\t// See the runComponent/stepComponent/advanceComponent functions for more\n\t// notes on the inflight/enqueued block/value properties.\n\t/**\n\t * inflightBlock\n\t */\n\tdeclare inflightBlock: Promise<unknown> | undefined;\n\n\t// TODO: Can we combine this with retainer.inflight somehow please.\n\t/**\n\t * inflightValue\n\t */\n\tdeclare inflightValue: Promise<ElementValue<TNode>> | undefined;\n\n\t/**\n\t * enqueuedBlock\n\t */\n\tdeclare enqueuedBlock: Promise<unknown> | undefined;\n\n\t/**\n\t * enqueuedValue\n\t */\n\tdeclare enqueuedValue: Promise<ElementValue<TNode>> | undefined;\n\n\t/**\n\t * onavailable - A callback used in conjunction with the IsAvailable flag to\n\t * implement the props async iterator. See the Symbol.asyncIterator method\n\t * and the resumeCtxIterator function.\n\t */\n\tdeclare onAvailable: Function | undefined;\n\n\tconstructor(\n\t\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\t\troot: TRoot | undefined,\n\t\thost: Retainer<TNode>,\n\t\tparent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\t\tscope: TScope | undefined,\n\t\tret: Retainer<TNode>,\n\t) {\n\t\tthis.f = 0;\n\t\tthis.ctx = new Context(this);\n\t\tthis.renderer = renderer;\n\t\tthis.root = root;\n\t\tthis.host = host;\n\t\tthis.parent = parent;\n\t\tthis.scope = scope;\n\t\tthis.ret = ret;\n\t\tthis.iterator = undefined;\n\t\tthis.inflightBlock = undefined;\n\t\tthis.inflightValue = undefined;\n\t\tthis.enqueuedBlock = undefined;\n\t\tthis.enqueuedValue = undefined;\n\t\tthis.onAvailable = undefined;\n\t}\n}\n\nconst $ContextImpl = Symbol.for(\"crank.ContextImpl\");\n\n/**\n * A class which is instantiated and passed to every component as its this\n * value. Contexts form a tree just like elements and all components in the\n * element tree are connected via contexts. Components can use this tree to\n * communicate data upwards via events and downwards via provisions.\n *\n * @template [TProps=*] - The expected shape of the props passed to the\n * component. Used to strongly type the Context iterator methods.\n * @template [TResult=*] - The readable element value type. It is used in\n * places such as the return value of refresh and the argument passed to\n * schedule and cleanup callbacks.\n */\nexport class Context<TProps = any, TResult = any> implements EventTarget {\n\t/**\n\t * @internal\n\t */\n\tdeclare [$ContextImpl]: ContextImpl<unknown, unknown, unknown, TResult>;\n\n\tconstructor(impl: ContextImpl<unknown, unknown, unknown, TResult>) {\n\t\tthis[$ContextImpl] = impl;\n\t}\n\n\t/**\n\t * The current props of the associated element.\n\t *\n\t * Typically, you should read props either via the first parameter of the\n\t * component or via the context iterator methods. This property is mainly for\n\t * plugins or utilities which wrap contexts.\n\t */\n\tget props(): TProps {\n\t\treturn this[$ContextImpl].ret.el.props;\n\t}\n\n\t// TODO: Should we rename this???\n\t/**\n\t * The current value of the associated element.\n\t *\n\t * Typically, you should read values via refs, generator yield expressions,\n\t * or the refresh, schedule, cleanup, or flush methods. This property is\n\t * mainly for plugins or utilities which wrap contexts.\n\t */\n\tget value(): TResult {\n\t\treturn this[$ContextImpl].renderer.read(getValue(this[$ContextImpl].ret));\n\t}\n\n\t*[Symbol.iterator](): Generator<TProps> {\n\t\tconst impl = this[$ContextImpl];\n\t\twhile (!(impl.f & IsDone)) {\n\t\t\tif (impl.f & IsIterating) {\n\t\t\t\tthrow new Error(\"Context iterated twice without a yield\");\n\t\t\t} else if (impl.f & IsAsyncGen) {\n\t\t\t\tthrow new Error(\"Use for await…of in async generator components\");\n\t\t\t}\n\n\t\t\timpl.f |= IsIterating;\n\t\t\tyield impl.ret.el.props!;\n\t\t}\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<TProps> {\n\t\t// We use a do while loop rather than a while loop to handle an edge case\n\t\t// where an async generator component is unmounted synchronously and\n\t\t// therefore “done” before it starts iterating over the context.\n\t\tconst impl = this[$ContextImpl];\n\t\tdo {\n\t\t\tif (impl.f & IsIterating) {\n\t\t\t\tthrow new Error(\"Context iterated twice without a yield\");\n\t\t\t} else if (impl.f & IsSyncGen) {\n\t\t\t\tthrow new Error(\"Use for…of in sync generator components\");\n\t\t\t}\n\n\t\t\timpl.f |= IsIterating;\n\t\t\tif (impl.f & IsAvailable) {\n\t\t\t\timpl.f &= ~IsAvailable;\n\t\t\t} else {\n\t\t\t\tawait new Promise((resolve) => (impl.onAvailable = resolve));\n\t\t\t\tif (impl.f & IsDone) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield impl.ret.el.props;\n\t\t} while (!(impl.f & IsDone));\n\t}\n\n\t/**\n\t * Re-executes a component.\n\t *\n\t * @returns The rendered value of the component or a promise thereof if the\n\t * component or its children execute asynchronously.\n\t *\n\t * The refresh method works a little differently for async generator\n\t * components, in that it will resume the Context’s props async iterator\n\t * rather than resuming execution. This is because async generator components\n\t * are perpetually resumed independent of updates, and rely on the props\n\t * async iterator to suspend.\n\t */\n\trefresh(): Promise<TResult> | TResult {\n\t\tconst impl = this[$ContextImpl];\n\t\tif (impl.f & IsUnmounted) {\n\t\t\tconsole.error(\"Component is unmounted\");\n\t\t\treturn impl.renderer.read(undefined);\n\t\t} else if (impl.f & IsExecuting) {\n\t\t\tconsole.error(\"Component is already executing\");\n\t\t\treturn this.value;\n\t\t}\n\n\t\tresumeCtxIterator(impl);\n\t\tconst value = runComponent(impl);\n\t\tif (isPromiseLike(value)) {\n\t\t\treturn (value as Promise<any>).then((value) => impl.renderer.read(value));\n\t\t}\n\n\t\treturn impl.renderer.read(value);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component commits. Will only\n\t * fire once per callback and update.\n\t */\n\tschedule(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet callbacks = scheduleMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tscheduleMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component’s children are\n\t * rendered into the root. Will only fire once per callback and render.\n\t */\n\tflush(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tif (typeof impl.root !== \"object\" || impl.root === null) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet flushMap = flushMaps.get(impl.root);\n\t\tif (!flushMap) {\n\t\t\tflushMap = new Map<ContextImpl, Set<Function>>();\n\t\t\tflushMaps.set(impl.root, flushMap);\n\t\t}\n\n\t\tlet callbacks = flushMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tflushMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\t/**\n\t * Registers a callback which fires when the component unmounts. Will only\n\t * fire once per callback.\n\t */\n\tcleanup(callback: (value: TResult) => unknown): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet callbacks = cleanupMap.get(impl);\n\t\tif (!callbacks) {\n\t\t\tcallbacks = new Set<Function>();\n\t\t\tcleanupMap.set(impl, callbacks);\n\t\t}\n\n\t\tcallbacks.add(callback);\n\t}\n\n\tconsume<TKey extends keyof ProvisionMap>(key: TKey): ProvisionMap[TKey];\n\tconsume(key: unknown): any;\n\tconsume(key: unknown): any {\n\t\tfor (\n\t\t\tlet parent = this[$ContextImpl].parent;\n\t\t\tparent !== undefined;\n\t\t\tparent = parent.parent\n\t\t) {\n\t\t\tconst provisions = provisionMaps.get(parent);\n\t\t\tif (provisions && provisions.has(key)) {\n\t\t\t\treturn provisions.get(key)!;\n\t\t\t}\n\t\t}\n\t}\n\n\tprovide<TKey extends keyof ProvisionMap>(\n\t\tkey: TKey,\n\t\tvalue: ProvisionMap[TKey],\n\t): void;\n\tprovide(key: unknown, value: any): void;\n\tprovide(key: unknown, value: any): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet provisions = provisionMaps.get(impl);\n\t\tif (!provisions) {\n\t\t\tprovisions = new Map();\n\t\t\tprovisionMaps.set(impl, provisions);\n\t\t}\n\n\t\tprovisions.set(key, value);\n\t}\n\n\taddEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tlet listeners: Array<EventListenerRecord>;\n\t\tif (!isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tconst listeners1 = listenersMap.get(impl);\n\t\t\tif (listeners1) {\n\t\t\t\tlisteners = listeners1;\n\t\t\t} else {\n\t\t\t\tlisteners = [];\n\t\t\t\tlistenersMap.set(impl, listeners);\n\t\t\t}\n\t\t}\n\n\t\toptions = normalizeListenerOptions(options);\n\t\tlet callback: MappedEventListener<T>;\n\t\tif (typeof listener === \"object\") {\n\t\t\tcallback = () => listener.handleEvent.apply(listener, arguments as any);\n\t\t} else {\n\t\t\tcallback = listener;\n\t\t}\n\n\t\tconst record: EventListenerRecord = {type, callback, listener, options};\n\t\tif (options.once) {\n\t\t\trecord.callback = function (this: any) {\n\t\t\t\tconst i = listeners.indexOf(record);\n\t\t\t\tif (i !== -1) {\n\t\t\t\t\tlisteners.splice(i, 1);\n\t\t\t\t}\n\n\t\t\t\treturn callback.apply(this, arguments as any);\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tlisteners.some(\n\t\t\t\t(record1) =>\n\t\t\t\t\trecord.type === record1.type &&\n\t\t\t\t\trecord.listener === record1.listener &&\n\t\t\t\t\t!record.options.capture === !record1.options.capture,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tlisteners.push(record);\n\n\t\t// TODO: is it possible to separate out the EventTarget delegation logic\n\t\tfor (const value of getChildValues(impl.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tvalue.addEventListener(record.type, record.callback, record.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tremoveEventListener<T extends string>(\n\t\ttype: T,\n\t\tlistener: MappedEventListenerOrEventListenerObject<T> | null,\n\t\toptions?: EventListenerOptions | boolean,\n\t): void {\n\t\tconst impl = this[$ContextImpl];\n\t\tconst listeners = listenersMap.get(impl);\n\t\tif (listeners == null || !isListenerOrListenerObject(listener)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options1 = normalizeListenerOptions(options);\n\t\tconst i = listeners.findIndex(\n\t\t\t(record) =>\n\t\t\t\trecord.type === type &&\n\t\t\t\trecord.listener === listener &&\n\t\t\t\t!record.options.capture === !options1.capture,\n\t\t);\n\n\t\tif (i === -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = listeners[i];\n\t\tlisteners.splice(i, 1);\n\n\t\t// TODO: is it possible to separate out the EventTarget delegation logic\n\t\tfor (const value of getChildValues(impl.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tvalue.removeEventListener(record.type, record.callback, record.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatchEvent(ev: Event): boolean {\n\t\tconst impl = this[$ContextImpl];\n\t\tconst path: Array<ContextImpl> = [];\n\t\tfor (\n\t\t\tlet parent = impl.parent;\n\t\t\tparent !== undefined;\n\t\t\tparent = parent.parent\n\t\t) {\n\t\t\tpath.push(parent);\n\t\t}\n\n\t\t// We patch the stopImmediatePropagation method because ev.cancelBubble\n\t\t// only informs us if stopPropagation was called and there are no\n\t\t// properties which inform us if stopImmediatePropagation was called.\n\t\tlet immediateCancelBubble = false;\n\t\tconst stopImmediatePropagation = ev.stopImmediatePropagation;\n\t\tsetEventProperty(ev, \"stopImmediatePropagation\", () => {\n\t\t\timmediateCancelBubble = true;\n\t\t\treturn stopImmediatePropagation.call(ev);\n\t\t});\n\t\tsetEventProperty(ev, \"target\", impl.ctx);\n\n\t\t// The only possible errors in this block are errors thrown by callbacks,\n\t\t// and dispatchEvent will only log these errors rather than throwing\n\t\t// them. Therefore, we place all code in a try block, log errors in the\n\t\t// catch block, and use an unsafe return statement in the finally block.\n\t\t//\n\t\t// Each early return within the try block returns true because while the\n\t\t// return value is overridden in the finally block, TypeScript\n\t\t// (justifiably) does not recognize the unsafe return statement.\n\t\t//\n\t\t// TODO: Run all callbacks even if one of them errors\n\t\ttry {\n\t\t\tsetEventProperty(ev, \"eventPhase\", CAPTURING_PHASE);\n\t\t\tfor (let i = path.length - 1; i >= 0; i--) {\n\t\t\t\tconst target = path[i];\n\t\t\t\tconst listeners = listenersMap.get(target);\n\t\t\t\tif (listeners) {\n\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", target.ctx);\n\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\tif (record.type === ev.type && record.options.capture) {\n\t\t\t\t\t\t\trecord.callback.call(target.ctx, ev);\n\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t{\n\t\t\t\tconst listeners = listenersMap.get(impl);\n\t\t\t\tif (listeners) {\n\t\t\t\t\tsetEventProperty(ev, \"eventPhase\", AT_TARGET);\n\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", impl.ctx);\n\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\tif (record.type === ev.type) {\n\t\t\t\t\t\t\trecord.callback.call(impl.ctx, ev);\n\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ev.bubbles) {\n\t\t\t\tsetEventProperty(ev, \"eventPhase\", BUBBLING_PHASE);\n\t\t\t\tfor (let i = 0; i < path.length; i++) {\n\t\t\t\t\tconst target = path[i];\n\t\t\t\t\tconst listeners = listenersMap.get(target);\n\t\t\t\t\tif (listeners) {\n\t\t\t\t\t\tsetEventProperty(ev, \"currentTarget\", target.ctx);\n\t\t\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\t\t\tif (record.type === ev.type && !record.options.capture) {\n\t\t\t\t\t\t\t\trecord.callback.call(target.ctx, ev);\n\t\t\t\t\t\t\t\tif (immediateCancelBubble) {\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ev.cancelBubble) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\t// TODO: Use setTimeout to rethrow the error.\n\t\t\tconsole.error(err);\n\t\t} finally {\n\t\t\tsetEventProperty(ev, \"eventPhase\", NONE);\n\t\t\tsetEventProperty(ev, \"currentTarget\", null);\n\t\t\t// eslint-disable-next-line no-unsafe-finally\n\t\t\treturn !ev.defaultPrevented;\n\t\t}\n\t}\n}\n\n/*** PRIVATE CONTEXT FUNCTIONS ***/\nfunction ctxContains(parent: ContextImpl, child: ContextImpl): boolean {\n\tfor (\n\t\tlet current: ContextImpl | undefined = child;\n\t\tcurrent !== undefined;\n\t\tcurrent = current.parent\n\t) {\n\t\tif (current === parent) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction updateComponent<TNode, TScope, TRoot extends TNode, TResult>(\n\trenderer: RendererImpl<TNode, TScope, TRoot, TResult>,\n\troot: TRoot | undefined,\n\thost: Retainer<TNode>,\n\tparent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined,\n\tscope: TScope | undefined,\n\tret: Retainer<TNode>,\n\toldProps: Record<string, any> | undefined,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tlet ctx: ContextImpl<TNode, TScope, TRoot, TResult>;\n\tif (oldProps) {\n\t\tctx = ret.ctx as ContextImpl<TNode, TScope, TRoot, TResult>;\n\t\tif (ctx.f & IsExecuting) {\n\t\t\tconsole.error(\"Component is already executing\");\n\t\t\treturn ret.cached;\n\t\t}\n\t} else {\n\t\tctx = ret.ctx = new ContextImpl(renderer, root, host, parent, scope, ret);\n\t}\n\n\tctx.f |= IsUpdating;\n\tresumeCtxIterator(ctx);\n\treturn runComponent(ctx);\n}\n\nfunction updateComponentChildren<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n\tchildren: Children,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (ctx.f & IsUnmounted || ctx.f & IsErrored) {\n\t\treturn;\n\t} else if (children === undefined) {\n\t\tconsole.error(\n\t\t\t\"A component has returned or yielded undefined. If this was intentional, return or yield null instead.\",\n\t\t);\n\t}\n\n\tlet childValues: Promise<Array<string | TNode>> | Array<string | TNode>;\n\t// We set the isExecuting flag in case a child component dispatches an event\n\t// which bubbles to this component and causes a synchronous refresh().\n\tctx.f |= IsExecuting;\n\ttry {\n\t\tchildValues = diffChildren(\n\t\t\tctx.renderer,\n\t\t\tctx.root,\n\t\t\tctx.host,\n\t\t\tctx,\n\t\t\tctx.scope,\n\t\t\tctx.ret,\n\t\t\tnarrow(children),\n\t\t);\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(childValues)) {\n\t\tctx.ret.inflight = childValues.then((childValues) =>\n\t\t\tcommitComponent(ctx, childValues),\n\t\t);\n\n\t\treturn ctx.ret.inflight;\n\t}\n\n\treturn commitComponent(ctx, childValues);\n}\n\nfunction commitComponent<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode>,\n\tvalues: Array<TNode | string>,\n): ElementValue<TNode> {\n\tif (ctx.f & IsUnmounted) {\n\t\treturn;\n\t}\n\n\tconst listeners = listenersMap.get(ctx);\n\tif (listeners && listeners.length) {\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tconst value = values[i];\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tfor (let j = 0; j < listeners.length; j++) {\n\t\t\t\t\tconst record = listeners[j];\n\t\t\t\t\tvalue.addEventListener(record.type, record.callback, record.options);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst oldValues = wrap(ctx.ret.cached);\n\tlet value = (ctx.ret.cached = unwrap(values));\n\tif (ctx.f & IsScheduling) {\n\t\tctx.f |= IsSchedulingRefresh;\n\t} else if (!(ctx.f & IsUpdating)) {\n\t\t// If we’re not updating the component, which happens when components are\n\t\t// refreshed, or when async generator components iterate, we have to do a\n\t\t// little bit housekeeping when a component’s child values have changed.\n\t\tif (!valuesEqual(oldValues, values)) {\n\t\t\tconst records = getListenerRecords(ctx.parent, ctx.host);\n\t\t\tif (records.length) {\n\t\t\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\t\t\tconst value = values[i];\n\t\t\t\t\tif (isEventTarget(value)) {\n\t\t\t\t\t\tfor (let j = 0; j < records.length; j++) {\n\t\t\t\t\t\t\tconst record = records[j];\n\t\t\t\t\t\t\tvalue.addEventListener(\n\t\t\t\t\t\t\t\trecord.type,\n\t\t\t\t\t\t\t\trecord.callback,\n\t\t\t\t\t\t\t\trecord.options,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// rearranging the nearest ancestor host element\n\t\t\tconst host = ctx.host;\n\t\t\tconst oldHostValues = wrap(host.cached);\n\t\t\tinvalidate(ctx, host);\n\t\t\tconst hostValues = getChildValues(host);\n\t\t\tctx.renderer.arrange(\n\t\t\t\thost.el.tag as string | symbol,\n\t\t\t\thost.value as TNode,\n\t\t\t\thost.el.props,\n\t\t\t\thostValues,\n\t\t\t\t// props and oldProps are the same because the host isn’t updated.\n\t\t\t\thost.el.props,\n\t\t\t\toldHostValues,\n\t\t\t);\n\t\t}\n\n\t\tflush(ctx.renderer, ctx.root, ctx);\n\t}\n\n\tconst callbacks = scheduleMap.get(ctx);\n\tif (callbacks) {\n\t\tscheduleMap.delete(ctx);\n\t\tctx.f |= IsScheduling;\n\t\tconst value1 = ctx.renderer.read(value);\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(value1);\n\t\t}\n\n\t\tctx.f &= ~IsScheduling;\n\t\t// Handles an edge case where refresh() is called during a schedule().\n\t\tif (ctx.f & IsSchedulingRefresh) {\n\t\t\tctx.f &= ~IsSchedulingRefresh;\n\t\t\tvalue = getValue(ctx.ret);\n\t\t}\n\t}\n\n\tctx.f &= ~IsUpdating;\n\treturn value;\n}\n\nfunction invalidate(ctx: ContextImpl, host: Retainer<unknown>): void {\n\tfor (\n\t\tlet parent = ctx.parent;\n\t\tparent !== undefined && parent.host === host;\n\t\tparent = parent.parent\n\t) {\n\t\tparent.ret.cached = undefined;\n\t}\n\n\thost.cached = undefined;\n}\n\nfunction valuesEqual<TValue>(\n\tvalues1: Array<TValue>,\n\tvalues2: Array<TValue>,\n): boolean {\n\tif (values1.length !== values2.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < values1.length; i++) {\n\t\tconst value1 = values1[i];\n\t\tconst value2 = values2[i];\n\t\tif (value1 !== value2) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Enqueues and executes the component associated with the context.\n *\n * The functions stepComponent and runComponent work together\n * to implement the async queueing behavior of components. The runComponent\n * function calls the stepComponent function, which returns two results in a\n * tuple. The first result, called the “block,” is a possible promise which\n * represents the duration for which the component is blocked from accepting\n * new updates. The second result, called the “value,” is the actual result of\n * the update. The runComponent function caches block/value from the\n * stepComponent function on the context, according to whether the component\n * blocks. The “inflight” block/value properties are the currently executing\n * update, and the “enqueued” block/value properties represent an enqueued next\n * stepComponent. Enqueued steps are dequeued every time the current block\n * promise settles.\n */\nfunction runComponent<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (!ctx.inflightBlock) {\n\t\ttry {\n\t\t\tconst [block, value] = stepComponent<TNode, TResult>(ctx);\n\t\t\tif (block) {\n\t\t\t\tctx.inflightBlock = block\n\t\t\t\t\t.catch((err) => {\n\t\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => advanceComponent(ctx));\n\t\t\t\t// stepComponent will only return a block if the value is asynchronous\n\t\t\t\tctx.inflightValue = value as Promise<ElementValue<TNode>>;\n\t\t\t}\n\n\t\t\treturn value;\n\t\t} catch (err) {\n\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t}\n\n\t\t\tthrow err;\n\t\t}\n\t} else if (ctx.f & IsAsyncGen) {\n\t\treturn ctx.inflightValue;\n\t} else if (!ctx.enqueuedBlock) {\n\t\tlet resolve: Function;\n\t\tctx.enqueuedBlock = ctx.inflightBlock\n\t\t\t.then(() => {\n\t\t\t\ttry {\n\t\t\t\t\tconst [block, value] = stepComponent<TNode, TResult>(ctx);\n\t\t\t\t\tresolve(value);\n\t\t\t\t\tif (block) {\n\t\t\t\t\t\treturn block.catch((err) => {\n\t\t\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (!(ctx.f & IsUpdating)) {\n\t\t\t\t\t\treturn propagateError<TNode>(ctx.parent, err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => advanceComponent(ctx));\n\t\tctx.enqueuedValue = new Promise((resolve1) => (resolve = resolve1));\n\t}\n\n\treturn ctx.enqueuedValue;\n}\n\n/**\n * This function is responsible for executing the component and handling all\n * the different component types.\n *\n * @returns {[block, value]} A tuple where\n * block - A possible promise which represents the duration during which the\n * component is blocked from updating.\n * value - A possible promise resolving to the rendered value of children.\n *\n * Each component type will block according to the type of the component.\n * - Sync function components never block and will transparently pass updates\n * to children.\n * - Async function components and async generator components block while\n * executing itself, but will not block for async children.\n * - Sync generator components block while any children are executing, because\n * they are expected to only resume when they’ve actually rendered.\n */\nfunction stepComponent<TNode, TResult>(\n\tctx: ContextImpl<TNode, unknown, TNode, TResult>,\n): [\n\tPromise<unknown> | undefined,\n\tPromise<ElementValue<TNode>> | ElementValue<TNode>,\n] {\n\tconst ret = ctx.ret;\n\tif (ctx.f & IsDone) {\n\t\treturn [undefined, getValue(ret)];\n\t}\n\n\tconst initial = !ctx.iterator;\n\tif (initial) {\n\t\tctx.f |= IsExecuting;\n\t\tclearEventListeners(ctx);\n\t\tlet result: ReturnType<Component>;\n\t\ttry {\n\t\t\tresult = (ret.el.tag as Component).call(ctx.ctx, ret.el.props);\n\t\t} catch (err) {\n\t\t\tctx.f |= IsErrored;\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tctx.f &= ~IsExecuting;\n\t\t}\n\n\t\tif (isIteratorLike(result)) {\n\t\t\tctx.iterator = result;\n\t\t} else if (isPromiseLike(result)) {\n\t\t\t// async function component\n\t\t\tconst result1 =\n\t\t\t\tresult instanceof Promise ? result : Promise.resolve(result);\n\t\t\tconst value = result1.then(\n\t\t\t\t(result) => updateComponentChildren<TNode, TResult>(ctx, result),\n\t\t\t\t(err) => {\n\t\t\t\t\tctx.f |= IsErrored;\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn [result1, value];\n\t\t} else {\n\t\t\t// sync function component\n\t\t\treturn [undefined, updateComponentChildren<TNode, TResult>(ctx, result)];\n\t\t}\n\t}\n\n\tlet oldValue: Promise<TResult> | TResult;\n\tif (initial) {\n\t\t// The argument passed to the first call to next is ignored.\n\t\toldValue = undefined as any;\n\t} else if (ctx.ret.inflight) {\n\t\t// The value passed back into the generator as the argument to the next\n\t\t// method is a promise if an async generator component has async children.\n\t\t// Sync generator components only resume when their children have fulfilled\n\t\t// so the element’s inflight child values will never be defined.\n\t\toldValue = ctx.ret.inflight.then(\n\t\t\t(value) => ctx.renderer.read(value),\n\t\t\t() => ctx.renderer.read(undefined),\n\t\t);\n\t} else {\n\t\toldValue = ctx.renderer.read(getValue(ret));\n\t}\n\n\tlet iteration: ChildrenIteration;\n\tctx.f |= IsExecuting;\n\ttry {\n\t\titeration = ctx.iterator!.next(oldValue);\n\t} catch (err) {\n\t\tctx.f |= IsDone | IsErrored;\n\t\tthrow err;\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(iteration)) {\n\t\t// async generator component\n\t\tif (initial) {\n\t\t\tctx.f |= IsAsyncGen;\n\t\t}\n\n\t\tconst value: Promise<ElementValue<TNode>> = iteration.then(\n\t\t\t(iteration) => {\n\t\t\t\tif (!(ctx.f & IsIterating)) {\n\t\t\t\t\tctx.f &= ~IsAvailable;\n\t\t\t\t}\n\n\t\t\t\tctx.f &= ~IsIterating;\n\t\t\t\tif (iteration.done) {\n\t\t\t\t\tctx.f |= IsDone;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst value = updateComponentChildren<TNode, TResult>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\titeration.value as Children,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (isPromiseLike(value)) {\n\t\t\t\t\t\treturn value.catch((err) => handleChildError(ctx, err));\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t} catch (err) {\n\t\t\t\t\treturn handleChildError(ctx, err);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tctx.f |= IsDone | IsErrored;\n\t\t\t\tthrow err;\n\t\t\t},\n\t\t);\n\n\t\treturn [iteration, value];\n\t}\n\n\t// sync generator component\n\tif (initial) {\n\t\tctx.f |= IsSyncGen;\n\t}\n\n\tctx.f &= ~IsIterating;\n\tif (iteration.done) {\n\t\tctx.f |= IsDone;\n\t}\n\n\tlet value: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\ttry {\n\t\tvalue = updateComponentChildren<TNode, TResult>(\n\t\t\tctx,\n\t\t\titeration.value as Children,\n\t\t);\n\t\tif (isPromiseLike(value)) {\n\t\t\tvalue = value.catch((err) => handleChildError(ctx, err));\n\t\t}\n\t} catch (err) {\n\t\tvalue = handleChildError(ctx, err);\n\t}\n\n\tif (isPromiseLike(value)) {\n\t\treturn [value.catch(NOOP), value];\n\t}\n\n\treturn [undefined, value];\n}\n\n/**\n * Called when the inflight block promise settles.\n */\nfunction advanceComponent(ctx: ContextImpl): void {\n\tctx.inflightBlock = ctx.enqueuedBlock;\n\tctx.inflightValue = ctx.enqueuedValue;\n\tctx.enqueuedBlock = undefined;\n\tctx.enqueuedValue = undefined;\n\tif (ctx.f & IsAsyncGen && !(ctx.f & IsDone) && !(ctx.f & IsUnmounted)) {\n\t\trunComponent(ctx);\n\t}\n}\n\n/**\n * Called to make props available to the props async iterator for async\n * generator components.\n */\nfunction resumeCtxIterator(ctx: ContextImpl): void {\n\tif (ctx.onAvailable) {\n\t\tctx.onAvailable();\n\t\tctx.onAvailable = undefined;\n\t} else {\n\t\tctx.f |= IsAvailable;\n\t}\n}\n\n// TODO: async unmounting\nfunction unmountComponent(ctx: ContextImpl): void {\n\tctx.f |= IsUnmounted;\n\tclearEventListeners(ctx);\n\tconst callbacks = cleanupMap.get(ctx);\n\tif (callbacks) {\n\t\tcleanupMap.delete(ctx);\n\t\tconst value = ctx.renderer.read(getValue(ctx.ret));\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(value);\n\t\t}\n\t}\n\n\tif (!(ctx.f & IsDone)) {\n\t\tctx.f |= IsDone;\n\t\tresumeCtxIterator(ctx);\n\t\tif (ctx.iterator && typeof ctx.iterator.return === \"function\") {\n\t\t\tctx.f |= IsExecuting;\n\t\t\ttry {\n\t\t\t\tconst iteration = ctx.iterator.return();\n\t\t\t\tif (isPromiseLike(iteration)) {\n\t\t\t\t\titeration.catch((err) => propagateError<unknown>(ctx.parent, err));\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tctx.f &= ~IsExecuting;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*** EVENT TARGET UTILITIES ***/\n// EVENT PHASE CONSTANTS\n// https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase\nconst NONE = 0;\nconst CAPTURING_PHASE = 1;\nconst AT_TARGET = 2;\nconst BUBBLING_PHASE = 3;\n\nconst listenersMap = new WeakMap<ContextImpl, Array<EventListenerRecord>>();\n/**\n * A map of event type strings to Event subclasses. Can be extended via\n * TypeScript module augmentation to have strongly typed event listeners.\n */\nexport interface EventMap extends Crank.EventMap {\n\t[type: string]: Event;\n}\n\ntype MappedEventListener<T extends string> = (ev: EventMap[T]) => unknown;\n\ntype MappedEventListenerOrEventListenerObject<T extends string> =\n\t| MappedEventListener<T>\n\t| {handleEvent: MappedEventListener<T>};\n\nfunction isListenerOrListenerObject(\n\tvalue: unknown,\n): value is MappedEventListenerOrEventListenerObject<string> {\n\treturn (\n\t\ttypeof value === \"function\" ||\n\t\t(value !== null &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\ttypeof (value as any).handleEvent === \"function\")\n\t);\n}\n\ninterface EventListenerRecord {\n\ttype: string;\n\tcallback: MappedEventListener<any>;\n\tlistener: MappedEventListenerOrEventListenerObject<any>;\n\toptions: AddEventListenerOptions;\n}\n\nfunction normalizeListenerOptions(\n\toptions: AddEventListenerOptions | boolean | null | undefined,\n): AddEventListenerOptions {\n\tif (typeof options === \"boolean\") {\n\t\treturn {capture: options};\n\t} else if (options == null) {\n\t\treturn {};\n\t}\n\n\treturn options;\n}\n\nfunction isEventTarget(value: any): value is EventTarget {\n\treturn (\n\t\tvalue != null &&\n\t\ttypeof value.addEventListener === \"function\" &&\n\t\ttypeof value.removeEventListener === \"function\" &&\n\t\ttypeof value.dispatchEvent === \"function\"\n\t);\n}\n\nfunction setEventProperty<T extends keyof Event>(\n\tev: Event,\n\tkey: T,\n\tvalue: Event[T],\n): void {\n\tObject.defineProperty(ev, key, {value, writable: false, configurable: true});\n}\n\n// TODO: Maybe we can pass in the current context directly, rather than\n// starting from the parent?\n/**\n * A function to reconstruct an array of every listener given a context and a\n * host element.\n *\n * This function exploits the fact that contexts retain their nearest ancestor\n * host element. We can determine all the contexts which are directly listening\n * to an element by traversing up the context tree and checking that the host\n * element passed in matches the parent context’s host element.\n */\nfunction getListenerRecords(\n\tctx: ContextImpl | undefined,\n\tret: Retainer<unknown>,\n): Array<EventListenerRecord> {\n\tlet listeners: Array<EventListenerRecord> = [];\n\twhile (ctx !== undefined && ctx.host === ret) {\n\t\tconst listeners1 = listenersMap.get(ctx);\n\t\tif (listeners1) {\n\t\t\tlisteners = listeners.concat(listeners1);\n\t\t}\n\n\t\tctx = ctx.parent;\n\t}\n\n\treturn listeners;\n}\n\nfunction clearEventListeners(ctx: ContextImpl): void {\n\tconst listeners = listenersMap.get(ctx);\n\tif (listeners && listeners.length) {\n\t\tfor (const value of getChildValues(ctx.ret)) {\n\t\t\tif (isEventTarget(value)) {\n\t\t\t\tfor (const record of listeners) {\n\t\t\t\t\tvalue.removeEventListener(\n\t\t\t\t\t\trecord.type,\n\t\t\t\t\t\trecord.callback,\n\t\t\t\t\t\trecord.options,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlisteners.length = 0;\n\t}\n}\n\n/*** ERROR HANDLING UTILITIES ***/\n// TODO: generator components which throw errors should be recoverable\nfunction handleChildError<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode>,\n\terr: unknown,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (\n\t\tctx.f & IsDone ||\n\t\t!ctx.iterator ||\n\t\ttypeof ctx.iterator.throw !== \"function\"\n\t) {\n\t\tthrow err;\n\t}\n\n\tresumeCtxIterator(ctx);\n\tlet iteration: ChildrenIteration;\n\ttry {\n\t\tctx.f |= IsExecuting;\n\t\titeration = ctx.iterator.throw(err);\n\t} catch (err) {\n\t\tctx.f |= IsDone | IsErrored;\n\t\tthrow err;\n\t} finally {\n\t\tctx.f &= ~IsExecuting;\n\t}\n\n\tif (isPromiseLike(iteration)) {\n\t\treturn iteration.then(\n\t\t\t(iteration) => {\n\t\t\t\tif (iteration.done) {\n\t\t\t\t\tctx.f |= IsDone;\n\t\t\t\t}\n\n\t\t\t\treturn updateComponentChildren(ctx, iteration.value as Children);\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tctx.f |= IsDone | IsErrored;\n\t\t\t\tthrow err;\n\t\t\t},\n\t\t);\n\t}\n\n\tif (iteration.done) {\n\t\tctx.f |= IsDone;\n\t}\n\n\treturn updateComponentChildren(ctx, iteration.value as Children);\n}\n\nfunction propagateError<TNode>(\n\tctx: ContextImpl<TNode, unknown, TNode> | undefined,\n\terr: unknown,\n): Promise<ElementValue<TNode>> | ElementValue<TNode> {\n\tif (ctx === undefined) {\n\t\tthrow err;\n\t}\n\n\tlet result: Promise<ElementValue<TNode>> | ElementValue<TNode>;\n\ttry {\n\t\tresult = handleChildError(ctx, err);\n\t} catch (err) {\n\t\treturn propagateError<TNode>(ctx.parent, err);\n\t}\n\n\tif (isPromiseLike(result)) {\n\t\treturn result.catch((err) => propagateError<TNode>(ctx.parent, err));\n\t}\n\n\treturn result;\n}\n\n// TODO: uncomment and use in the Element interface below\n// type CrankElement = Element;\ndeclare global {\n\tnamespace Crank {\n\t\texport interface EventMap {}\n\n\t\texport interface ProvisionMap {}\n\n\t\texport interface Context {}\n\t}\n\n\tnamespace JSX {\n\t\t// TODO: JSX Element type (the result of JSX expressions) don’t work\n\t\t// because TypeScript demands that all Components return JSX elements for\n\t\t// some reason.\n\t\t// interface Element extends CrankElement {}\n\n\t\texport interface IntrinsicElements {\n\t\t\t[tag: string]: any;\n\t\t}\n\n\t\texport interface ElementChildrenAttribute {\n\t\t\tchildren: {};\n\t\t}\n\t}\n}\n\n// Some JSX transpilation tools expect these functions to be defined on the\n// default export. Prefer named exports when importing directly.\nexport default {createElement, Fragment};\n"],"names":[],"mappings":";;;;AAAA,MAAM,IAAI,GAAG,MAAK,GAAG,CAAC;AACtB,MAAM,QAAQ,GAAG,CAAI,KAAQ,KAAQ,KAAK,CAAC;AAE3C,SAAS,IAAI,CAAI,KAA+B,EAAA;IAC/C,OAAO,KAAK,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,MAAM,CAAI,GAAa,EAAA;AAC/B,IAAA,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACvE,CAAC;AAID;;;;;;AAMG;AACH,SAAS,QAAQ,C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