@b9g/crank 0.5.7 → 0.6.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/README.md +225 -22
- package/crank.cjs +2008 -1984
- package/crank.cjs.map +1 -1
- package/crank.d.ts +491 -486
- package/crank.js +2008 -1984
- package/crank.js.map +1 -1
- package/dom.cjs +320 -289
- package/dom.cjs.map +1 -1
- package/dom.d.ts +14 -14
- package/dom.js +321 -290
- package/dom.js.map +1 -1
- package/html.cjs +154 -136
- package/html.cjs.map +1 -1
- package/html.d.ts +17 -17
- package/html.js +155 -137
- package/html.js.map +1 -1
- package/jsx-runtime.cjs +13 -8
- package/jsx-runtime.cjs.map +1 -1
- package/jsx-runtime.d.ts +6 -5
- package/jsx-runtime.js +13 -9
- package/jsx-runtime.js.map +1 -1
- package/jsx-tag.cjs +424 -421
- package/jsx-tag.cjs.map +1 -1
- package/jsx-tag.d.ts +4 -2
- package/jsx-tag.js +424 -422
- package/jsx-tag.js.map +1 -1
- package/package.json +30 -30
- package/standalone.cjs +1 -0
- package/standalone.cjs.map +1 -1
- package/standalone.d.ts +2 -2
- package/standalone.js +1 -1
- package/umd.d.ts +3 -3
- package/umd.js +2479 -2406
- package/umd.js.map +1 -1
package/dom.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.cjs","sources":["../src/dom.ts"],"sourcesContent":["import {\n\tChildren,\n\tContext,\n\tElementValue,\n\tHydrationData,\n\tPortal,\n\tRenderer,\n\tRendererImpl,\n} from \"./crank.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\n\nexport const impl: Partial<RendererImpl<Node, string>> = {\n\tscope(\n\t\txmlns: string | undefined,\n\t\ttag: string | symbol,\n\t\tprops: Record<string, any>,\n\t): string | undefined {\n\t\tswitch (tag) {\n\t\t\tcase Portal:\n\t\t\t\txmlns = undefined;\n\t\t\t\tbreak;\n\t\t\tcase \"svg\":\n\t\t\t\txmlns = SVG_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate(\n\t\ttag: string | symbol,\n\t\t_props: unknown,\n\t\txmlns: string | undefined,\n\t): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tag.toString()}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t}\n\n\t\treturn xmlns\n\t\t\t? document.createElementNS(xmlns, tag)\n\t\t\t: document.createElement(tag);\n\t},\n\n\thydrate(\n\t\ttag: string | symbol,\n\t\tnode: Element,\n\t\tprops: Record<string, unknown>,\n\t): HydrationData<Element> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tag.toString()}`);\n\t\t}\n\n\t\tif (\n\t\t\ttypeof tag === \"string\" &&\n\t\t\ttag.toUpperCase() !== (node as Element).tagName\n\t\t) {\n\t\t\t// TODO: consider pros and cons of hydration warnings\n\t\t\t//console.error(`Expected <${tag}> while hydrating but found:`, node);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst children: Array<string | Element> = [];\n\t\tfor (let i = 0; i < node.childNodes.length; i++) {\n\t\t\tconst child = node.childNodes[i];\n\t\t\tif (child.nodeType === Node.TEXT_NODE) {\n\t\t\t\tchildren.push((child as Text).data);\n\t\t\t} else if (child.nodeType === Node.ELEMENT_NODE) {\n\t\t\t\tchildren.push(child as Element);\n\t\t\t}\n\t\t}\n\n\t\t// TODO: extract props from nodes\n\t\treturn {props, children};\n\t},\n\n\tpatch(\n\t\t_tag: string | symbol,\n\t\t// TODO: Why does this assignment work?\n\t\tnode: HTMLElement | SVGElement,\n\t\tname: string,\n\t\t// TODO: Stricter typings?\n\t\tvalue: unknown,\n\t\toldValue: unknown,\n\t\txmlns: string | undefined,\n\t): void {\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tswitch (name) {\n\t\t\tcase \"style\": {\n\t\t\t\tconst style: CSSStyleDeclaration = node.style;\n\t\t\t\tif (style == null) {\n\t\t\t\t\tnode.setAttribute(\"style\", value as string);\n\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\tnode.removeAttribute(\"style\");\n\t\t\t\t} else if (value === true) {\n\t\t\t\t\tnode.setAttribute(\"style\", \"\");\n\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const styleName in {...(oldValue as {}), ...(value as {})}) {\n\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\tstyle.removeProperty(styleName);\n\t\t\t\t\t\t} else if (style.getPropertyValue(styleName) !== styleValue) {\n\t\t\t\t\t\t\tstyle.setProperty(styleName, styleValue);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"class\":\n\t\t\tcase \"className\":\n\t\t\t\tif (value === true) {\n\t\t\t\t\tnode.setAttribute(\"class\", \"\");\n\t\t\t\t} else if (value == null) {\n\t\t\t\t\tnode.removeAttribute(\"class\");\n\t\t\t\t} else if (!isSVG) {\n\t\t\t\t\tif (node.className !== value) {\n\t\t\t\t\t\t(node as any)[\"className\"] = value;\n\t\t\t\t\t}\n\t\t\t\t} else if (node.getAttribute(\"class\") !== value) {\n\t\t\t\t\tnode.setAttribute(\"class\", value as string);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"innerHTML\":\n\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\tnode.innerHTML = value as any;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (\n\t\t\t\t\tname in node &&\n\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t// falsy properties, so we use attributes in this case.\n\t\t\t\t\t!(\n\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\ttypeof (node as any)[name] === \"boolean\"\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// walk up the object's prototype chain to find the owner of the\n\t\t\t\t\t// named property\n\t\t\t\t\tlet obj = node;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(obj, name)) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} while ((obj = Object.getPrototypeOf(obj)));\n\n\t\t\t\t\t// get the descriptor for the named property and check whether it\n\t\t\t\t\t// implies that the property is writable\n\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(obj, name);\n\t\t\t\t\tif (\n\t\t\t\t\t\tdescriptor != null &&\n\t\t\t\t\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ((node as any)[name] !== value || oldValue === undefined) {\n\t\t\t\t\t\t\t(node as any)[name] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// if the property wasn't writable, fall through to the code below\n\t\t\t\t\t// which uses setAttribute() instead of assigning directly.\n\t\t\t\t}\n\n\t\t\t\tif (value === true) {\n\t\t\t\t\tvalue = \"\";\n\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\tnode.removeAttribute(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (node.getAttribute(name) !== value) {\n\t\t\t\t\tnode.setAttribute(name, value as any);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange(\n\t\ttag: string | symbol,\n\t\tnode: Node,\n\t\tprops: Record<string, any>,\n\t\tchildren: Array<Element | string>,\n\t\t_oldProps: Record<string, any> | undefined,\n\t\toldChildren: Array<Element | string> | undefined,\n\t): void {\n\t\tif (tag === Portal && (node == null || typeof node.nodeType !== \"number\")) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Portal root is not a node. Received: ${JSON.stringify(\n\t\t\t\t\tnode && node.toString(),\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!(\"innerHTML\" in props) &&\n\t\t\t// We don’t want to update elements without explicit children (<div/>),\n\t\t\t// because these elements sometimes have child nodes added via raw\n\t\t\t// DOM manipulations.\n\t\t\t// However, if an element has previously rendered children, we clear the\n\t\t\t// them because it would be surprising not to clear Crank managed\n\t\t\t// children, even if the new element does not have explicit children.\n\t\t\t(\"children\" in props || (oldChildren && oldChildren.length))\n\t\t) {\n\t\t\tif (children.length === 0) {\n\t\t\t\tnode.textContent = \"\";\n\t\t\t} else {\n\t\t\t\tlet oldChild = node.firstChild;\n\t\t\t\tlet i = 0;\n\t\t\t\twhile (oldChild !== null && i < children.length) {\n\t\t\t\t\tconst newChild = children[i];\n\t\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (typeof newChild === \"string\") {\n\t\t\t\t\t\tif (oldChild.nodeType === Node.TEXT_NODE) {\n\t\t\t\t\t\t\tif ((oldChild as Text).data !== newChild) {\n\t\t\t\t\t\t\t\t(oldChild as Text).data = newChild;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.insertBefore(document.createTextNode(newChild), oldChild);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (oldChild.nodeType === Node.TEXT_NODE) {\n\t\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\t// TODO: This is an optimization but we need to think a little more about other cases like prepending.\n\t\t\t\t\t\tif (oldChild !== children[i]) {\n\t\t\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// remove excess DOM nodes\n\t\t\t\twhile (oldChild !== null) {\n\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t}\n\n\t\t\t\t// append excess children\n\t\t\t\tfor (; i < children.length; i++) {\n\t\t\t\t\tconst newChild = children[i];\n\t\t\t\t\tnode.appendChild(\n\t\t\t\t\t\ttypeof newChild === \"string\"\n\t\t\t\t\t\t\t? document.createTextNode(newChild)\n\t\t\t\t\t\t\t: newChild,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\ttext(\n\t\ttext: string,\n\t\t_scope: string | undefined,\n\t\thydrationData: HydrationData<Element> | undefined,\n\t): string {\n\t\tif (hydrationData != null) {\n\t\t\tlet value = hydrationData.children.shift();\n\t\t\tif (typeof value !== \"string\" || !value.startsWith(text)) {\n\t\t\t\t// TODO: consider pros and cons of hydration warnings\n\t\t\t\t//console.error(`Expected \"${text}\" while hydrating but found:`, value);\n\t\t\t} else if (text.length < value.length) {\n\t\t\t\tvalue = value.slice(text.length);\n\t\t\t\thydrationData.children.unshift(value);\n\t\t\t}\n\t\t}\n\n\t\treturn text;\n\t},\n\n\traw(\n\t\tvalue: string | Node,\n\t\txmlns: string | undefined,\n\t\thydrationData: HydrationData<Element> | undefined,\n\t): ElementValue<Node> {\n\t\tlet result: ElementValue<Node>;\n\t\tif (typeof value === \"string\") {\n\t\t\tconst el =\n\t\t\t\txmlns == null\n\t\t\t\t\t? document.createElement(\"div\")\n\t\t\t\t\t: document.createElementNS(xmlns, \"svg\");\n\t\t\tel.innerHTML = value;\n\t\t\tif (el.childNodes.length === 0) {\n\t\t\t\tresult = undefined;\n\t\t\t} else if (el.childNodes.length === 1) {\n\t\t\t\tresult = el.childNodes[0];\n\t\t\t} else {\n\t\t\t\tresult = Array.from(el.childNodes);\n\t\t\t}\n\t\t} else {\n\t\t\tresult = value;\n\t\t}\n\n\t\tif (hydrationData != null) {\n\t\t\t// TODO: maybe we should warn on incorrect values\n\t\t\tif (Array.isArray(result)) {\n\t\t\t\tfor (let i = 0; i < result.length; i++) {\n\t\t\t\t\tconst node = result[i];\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof node !== \"string\" &&\n\t\t\t\t\t\t(node.nodeType === Node.ELEMENT_NODE ||\n\t\t\t\t\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t\t\t\t\t) {\n\t\t\t\t\t\thydrationData.children.shift();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (result != null && typeof result !== \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tresult.nodeType === Node.ELEMENT_NODE ||\n\t\t\t\t\tresult.nodeType === Node.TEXT_NODE\n\t\t\t\t) {\n\t\t\t\t\thydrationData.children.shift();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string> {\n\tconstructor() {\n\t\tsuper(impl);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Node,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.render(children, root, ctx);\n\t}\n\n\thydrate(\n\t\tchildren: Children,\n\t\troot: Node,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.hydrate(children, root, ctx);\n\t}\n}\n\nfunction validateRoot(root: unknown): asserts root is Node {\n\tif (\n\t\troot === null ||\n\t\t(typeof root === \"object\" && typeof (root as any).nodeType !== \"number\")\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`Render root is not a node. Received: ${JSON.stringify(\n\t\t\t\troot && root.toString(),\n\t\t\t)}`,\n\t\t);\n\t}\n}\n\nexport const renderer = new DOMRenderer();\n\ndeclare global {\n\tmodule Crank {\n\t\tinterface EventMap extends GlobalEventHandlersEventMap {}\n\t}\n}\n"],"names":["Portal","Renderer"],"mappings":";;;;AAUA,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAEtC,MAAA,IAAI,GAAwC;AACxD,IAAA,KAAK,CACJ,KAAyB,EACzB,GAAoB,EACpB,KAA0B,EAAA;AAE1B,QAAA,QAAQ,GAAG;AACV,YAAA,KAAKA,YAAM;gBACV,KAAK,GAAG,SAAS,CAAC;gBAClB,MAAM;AACP,YAAA,KAAK,KAAK;gBACT,KAAK,GAAG,aAAa,CAAC;gBACtB,MAAM;AACP,SAAA;AAED,QAAA,OAAO,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC;KAC5B;AAED,IAAA,MAAM,CACL,GAAoB,EACpB,MAAe,EACf,KAAyB,EAAA;AAEzB,QAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,CAAgB,aAAA,EAAA,GAAG,CAAC,QAAQ,EAAE,CAAE,CAAA,CAAC,CAAC;AAClD,SAAA;AAAM,aAAA,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACvC,KAAK,GAAG,aAAa,CAAC;AACtB,SAAA;AAED,QAAA,OAAO,KAAK;cACT,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC;AACtC,cAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAA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AAC;AACF,KAAA;AACF,CAAC;AAEY,MAAA,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
|
1
|
+
{"version":3,"file":"dom.cjs","sources":["../src/dom.ts"],"sourcesContent":["import {\n\tChildren,\n\tContext,\n\tElementValue,\n\tHydrationData,\n\tPortal,\n\tRenderer,\n\tRendererImpl,\n} from \"./crank.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\n\nexport const impl: Partial<RendererImpl<Node, string>> = {\n\tscope(\n\t\txmlns: string | undefined,\n\t\ttag: string | symbol,\n\t\tprops: Record<string, any>,\n\t): string | undefined {\n\t\tswitch (tag) {\n\t\t\tcase Portal:\n\t\t\t\txmlns = undefined;\n\t\t\t\tbreak;\n\t\t\tcase \"svg\":\n\t\t\t\txmlns = SVG_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate(\n\t\ttag: string | symbol,\n\t\t_props: unknown,\n\t\txmlns: string | undefined,\n\t): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tag.toString()}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t}\n\n\t\treturn xmlns\n\t\t\t? document.createElementNS(xmlns, tag)\n\t\t\t: document.createElement(tag);\n\t},\n\n\thydrate(\n\t\ttag: string | symbol,\n\t\tnode: Element,\n\t\tprops: Record<string, unknown>,\n\t): HydrationData<Element> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tag.toString()}`);\n\t\t}\n\n\t\tif (\n\t\t\ttypeof tag === \"string\" &&\n\t\t\ttag.toUpperCase() !== (node as Element).tagName\n\t\t) {\n\t\t\t// TODO: consider pros and cons of hydration warnings\n\t\t\t//console.error(`Expected <${tag}> while hydrating but found:`, node);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst children: Array<string | Element> = [];\n\t\tfor (let i = 0; i < node.childNodes.length; i++) {\n\t\t\tconst child = node.childNodes[i];\n\t\t\tif (child.nodeType === Node.TEXT_NODE) {\n\t\t\t\tchildren.push((child as Text).data);\n\t\t\t} else if (child.nodeType === Node.ELEMENT_NODE) {\n\t\t\t\tchildren.push(child as Element);\n\t\t\t}\n\t\t}\n\n\t\t// TODO: extract props from nodes\n\t\treturn {props, children};\n\t},\n\n\tpatch(\n\t\t_tag: string | symbol,\n\t\t// TODO: Why does this assignment work?\n\t\tnode: HTMLElement | SVGElement,\n\t\tname: string,\n\t\t// TODO: Stricter typings?\n\t\tvalue: unknown,\n\t\toldValue: unknown,\n\t\txmlns: string | undefined,\n\t): void {\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tconst colonIndex = name.indexOf(\":\");\n\t\tif (colonIndex !== -1) {\n\t\t\tconst ns = name.slice(0, colonIndex);\n\t\t\tconst name1 = name.slice(colonIndex + 1);\n\t\t\tswitch (ns) {\n\t\t\t\tcase \"prop\":\n\t\t\t\t\t(node as any)[name1] = value;\n\t\t\t\t\treturn;\n\t\t\t\tcase \"attr\":\n\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\tnode.removeAttribute(name1);\n\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\tnode.setAttribute(name1, \"\");\n\t\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\t\tnode.setAttribute(name1, value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.setAttribute(name, String(value));\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tswitch (name) {\n\t\t\tcase \"style\": {\n\t\t\t\tconst style: CSSStyleDeclaration = node.style;\n\t\t\t\tif (style == null) {\n\t\t\t\t\tnode.setAttribute(\"style\", value as string);\n\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\tnode.removeAttribute(\"style\");\n\t\t\t\t} else if (value === true) {\n\t\t\t\t\tnode.setAttribute(\"style\", \"\");\n\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const styleName in {...(oldValue as {}), ...(value as {})}) {\n\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\tstyle.removeProperty(styleName);\n\t\t\t\t\t\t} else if (style.getPropertyValue(styleName) !== styleValue) {\n\t\t\t\t\t\t\tstyle.setProperty(styleName, styleValue);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"class\":\n\t\t\tcase \"className\":\n\t\t\t\tif (value === true) {\n\t\t\t\t\tnode.setAttribute(\"class\", \"\");\n\t\t\t\t} else if (value == null) {\n\t\t\t\t\tnode.removeAttribute(\"class\");\n\t\t\t\t} else if (!isSVG) {\n\t\t\t\t\tif (node.className !== value) {\n\t\t\t\t\t\t(node as any)[\"className\"] = value;\n\t\t\t\t\t}\n\t\t\t\t} else if (node.getAttribute(\"class\") !== value) {\n\t\t\t\t\tnode.setAttribute(\"class\", value as string);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"innerHTML\":\n\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\tnode.innerHTML = value as any;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (\n\t\t\t\t\tname[0] === \"o\" &&\n\t\t\t\t\tname[1] === \"n\" &&\n\t\t\t\t\tname[2] === name[2].toUpperCase() &&\n\t\t\t\t\ttypeof value === \"function\"\n\t\t\t\t) {\n\t\t\t\t\t// Support React-style event names (onClick, onChange, etc.)\n\t\t\t\t\tname = name.toLowerCase();\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tname in node &&\n\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t// falsy properties, so we use attributes in this case.\n\t\t\t\t\t!(\n\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\ttypeof (node as any)[name] === \"boolean\"\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// walk up the object's prototype chain to find the owner of the\n\t\t\t\t\t// named property\n\t\t\t\t\tlet obj = node;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(obj, name)) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} while ((obj = Object.getPrototypeOf(obj)));\n\n\t\t\t\t\t// get the descriptor for the named property and check whether it\n\t\t\t\t\t// implies that the property is writable\n\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(obj, name);\n\t\t\t\t\tif (\n\t\t\t\t\t\tdescriptor != null &&\n\t\t\t\t\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ((node as any)[name] !== value || oldValue === undefined) {\n\t\t\t\t\t\t\t(node as any)[name] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// if the property wasn't writable, fall through to the code below\n\t\t\t\t\t// which uses setAttribute() instead of assigning directly.\n\t\t\t\t}\n\n\t\t\t\tif (value === true) {\n\t\t\t\t\tvalue = \"\";\n\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\tnode.removeAttribute(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (node.getAttribute(name) !== value) {\n\t\t\t\t\tnode.setAttribute(name, value as any);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange(\n\t\ttag: string | symbol,\n\t\tnode: Node,\n\t\tprops: Record<string, any>,\n\t\tchildren: Array<Element | string>,\n\t\t_oldProps: Record<string, any> | undefined,\n\t\toldChildren: Array<Element | string> | undefined,\n\t): void {\n\t\tif (tag === Portal && (node == null || typeof node.nodeType !== \"number\")) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Portal root is not a node. Received: ${JSON.stringify(\n\t\t\t\t\tnode && node.toString(),\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!(\"innerHTML\" in props) &&\n\t\t\t// We don’t want to update elements without explicit children (<div/>),\n\t\t\t// because these elements sometimes have child nodes added via raw\n\t\t\t// DOM manipulations.\n\t\t\t// However, if an element has previously rendered children, we clear the\n\t\t\t// them because it would be surprising not to clear Crank managed\n\t\t\t// children, even if the new element does not have explicit children.\n\t\t\t(\"children\" in props || (oldChildren && oldChildren.length))\n\t\t) {\n\t\t\tif (children.length === 0) {\n\t\t\t\tnode.textContent = \"\";\n\t\t\t} else {\n\t\t\t\tlet oldChild = node.firstChild;\n\t\t\t\tlet i = 0;\n\t\t\t\twhile (oldChild !== null && i < children.length) {\n\t\t\t\t\tconst newChild = children[i];\n\t\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (typeof newChild === \"string\") {\n\t\t\t\t\t\tif (oldChild.nodeType === Node.TEXT_NODE) {\n\t\t\t\t\t\t\tif ((oldChild as Text).data !== newChild) {\n\t\t\t\t\t\t\t\t(oldChild as Text).data = newChild;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.insertBefore(document.createTextNode(newChild), oldChild);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ti++;\n\t\t\t\t\t} else if (oldChild.nodeType === Node.TEXT_NODE) {\n\t\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\t// TODO: This is an optimization but we need to think a little more about other cases like prepending.\n\t\t\t\t\t\tif (oldChild !== children[i]) {\n\t\t\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// remove excess DOM nodes\n\t\t\t\twhile (oldChild !== null) {\n\t\t\t\t\tconst nextSibling = oldChild.nextSibling;\n\t\t\t\t\tnode.removeChild(oldChild);\n\t\t\t\t\toldChild = nextSibling;\n\t\t\t\t}\n\n\t\t\t\t// append excess children\n\t\t\t\tfor (; i < children.length; i++) {\n\t\t\t\t\tconst newChild = children[i];\n\t\t\t\t\tnode.appendChild(\n\t\t\t\t\t\ttypeof newChild === \"string\"\n\t\t\t\t\t\t\t? document.createTextNode(newChild)\n\t\t\t\t\t\t\t: newChild,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\ttext(\n\t\ttext: string,\n\t\t_scope: string | undefined,\n\t\thydrationData: HydrationData<Element> | undefined,\n\t): string {\n\t\tif (hydrationData != null) {\n\t\t\tlet value = hydrationData.children.shift();\n\t\t\tif (typeof value !== \"string\" || !value.startsWith(text)) {\n\t\t\t\t// TODO: consider pros and cons of hydration warnings\n\t\t\t\t//console.error(`Expected \"${text}\" while hydrating but found:`, value);\n\t\t\t} else if (text.length < value.length) {\n\t\t\t\tvalue = value.slice(text.length);\n\t\t\t\thydrationData.children.unshift(value);\n\t\t\t}\n\t\t}\n\n\t\treturn text;\n\t},\n\n\traw(\n\t\tvalue: string | Node,\n\t\txmlns: string | undefined,\n\t\thydrationData: HydrationData<Element> | undefined,\n\t): ElementValue<Node> {\n\t\tlet result: ElementValue<Node>;\n\t\tif (typeof value === \"string\") {\n\t\t\tconst el =\n\t\t\t\txmlns == null\n\t\t\t\t\t? document.createElement(\"div\")\n\t\t\t\t\t: document.createElementNS(xmlns, \"svg\");\n\t\t\tel.innerHTML = value;\n\t\t\tif (el.childNodes.length === 0) {\n\t\t\t\tresult = undefined;\n\t\t\t} else if (el.childNodes.length === 1) {\n\t\t\t\tresult = el.childNodes[0];\n\t\t\t} else {\n\t\t\t\tresult = Array.from(el.childNodes);\n\t\t\t}\n\t\t} else {\n\t\t\tresult = value;\n\t\t}\n\n\t\tif (hydrationData != null) {\n\t\t\t// TODO: maybe we should warn on incorrect values\n\t\t\tif (Array.isArray(result)) {\n\t\t\t\tfor (let i = 0; i < result.length; i++) {\n\t\t\t\t\tconst node = result[i];\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof node !== \"string\" &&\n\t\t\t\t\t\t(node.nodeType === Node.ELEMENT_NODE ||\n\t\t\t\t\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t\t\t\t\t) {\n\t\t\t\t\t\thydrationData.children.shift();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (result != null && typeof result !== \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tresult.nodeType === Node.ELEMENT_NODE ||\n\t\t\t\t\tresult.nodeType === Node.TEXT_NODE\n\t\t\t\t) {\n\t\t\t\t\thydrationData.children.shift();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string> {\n\tconstructor() {\n\t\tsuper(impl);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Node,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.render(children, root, ctx);\n\t}\n\n\thydrate(\n\t\tchildren: Children,\n\t\troot: Node,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.hydrate(children, root, ctx);\n\t}\n}\n\nfunction validateRoot(root: unknown): asserts root is Node {\n\tif (\n\t\troot === null ||\n\t\t(typeof root === \"object\" && typeof (root as any).nodeType !== \"number\")\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`Render root is not a node. Received: ${JSON.stringify(\n\t\t\t\troot && root.toString(),\n\t\t\t)}`,\n\t\t);\n\t}\n}\n\nexport const renderer = new DOMRenderer();\n\ndeclare global {\n\tmodule Crank {\n\t\tinterface EventMap extends GlobalEventHandlersEventMap {}\n\t}\n}\n"],"names":["Portal","Renderer"],"mappings":";;;;AAUA,MAAM,aAAa,GAAG,4BAA4B;AAErC,MAAA,IAAI,GAAwC;AACxD,IAAA,KAAK,CACJ,KAAyB,EACzB,GAAoB,EACpB,KAA0B,EAAA;QAE1B,QAAQ,GAAG;AACV,YAAA,KAAKA,YAAM;gBACV,KAAK,GAAG,SAAS;gBACjB;AACD,YAAA,KAAK,KAAK;gBACT,KAAK,GAAG,aAAa;gBACrB;;AAGF,QAAA,OAAO,KAAK,CAAC,KAAK,IAAI,KAAK;KAC3B;AAED,IAAA,MAAM,CACL,GAAoB,EACpB,MAAe,EACf,KAAyB,EAAA;AAEzB,QAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,CAAgB,aAAA,EAAA,GAAG,CAAC,QAAQ,EAAE,CAAE,CAAA,CAAC;;AAC3C,aAAA,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACvC,KAAK,GAAG,aAAa;;AAGtB,QAAA,OAAO;cACJ,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG;AACrC,cAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;KAC9B;AAED,IAAA,OAAO,CACN,GAAoB,EACpB,IAAa,EACb,KAA8B,EAAA;QAE9B,IAAI,OAAO,GAAG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AG1B,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AACxD,gBAAA,IACC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;AACrC,oBAAA,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,EACjC;AACD,oBAAA,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE;;;;AAKjC,QAAA,OAAO,MAAM;KACb;;AAGI,MAAO,WAAY,SAAQC,cAAsB,CAAA;AACtD,IAAA,WAAA,GAAA;QACC,KAAK,CAAC,IAAI,CAAC;;AAGZ,IAAA,MAAM,CACL,QAAkB,EAClB,IAAU,EACV,GAAa,EAAA;QAEb,YAAY,CAAC,IAAI,CAAC;QAClB,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC;;AAGzC,IAAA,OAAO,CACN,QAAkB,EAClB,IAAU,EACV,GAAa,EAAA;QAEb,YAAY,CAAC,IAAI,CAAC;QAClB,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC;;AAE1C;AAED,SAAS,YAAY,CAAC,IAAa,EAAA;IAClC,IACC,IAAI,KAAK,IAAI;AACb,SAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ,CAAC,EACvE;AACD,QAAA,MAAM,IAAI,SAAS,CAClB,CAAwC,qCAAA,EAAA,IAAI,CAAC,SAAS,CACrD,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CACvB,CAAA,CAAE,CACH;;AAEH;AAEa,MAAA,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
package/dom.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Children, Context, ElementValue, Renderer, RendererImpl } from "./crank.js";
|
|
2
|
-
export declare const impl: Partial<RendererImpl<Node, string>>;
|
|
3
|
-
export declare class DOMRenderer extends Renderer<Node, string> {
|
|
4
|
-
constructor();
|
|
5
|
-
render(children: Children, root: Node, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;
|
|
6
|
-
hydrate(children: Children, root: Node, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;
|
|
7
|
-
}
|
|
8
|
-
export declare const renderer: DOMRenderer;
|
|
9
|
-
declare global {
|
|
10
|
-
|
|
11
|
-
interface EventMap extends GlobalEventHandlersEventMap {
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { Children, Context, ElementValue, Renderer, RendererImpl } from "./crank.js";
|
|
2
|
+
export declare const impl: Partial<RendererImpl<Node, string>>;
|
|
3
|
+
export declare class DOMRenderer extends Renderer<Node, string> {
|
|
4
|
+
constructor();
|
|
5
|
+
render(children: Children, root: Node, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;
|
|
6
|
+
hydrate(children: Children, root: Node, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;
|
|
7
|
+
}
|
|
8
|
+
export declare const renderer: DOMRenderer;
|
|
9
|
+
declare global {
|
|
10
|
+
namespace Crank {
|
|
11
|
+
interface EventMap extends GlobalEventHandlersEventMap {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|