@b9g/crank 0.7.2 → 0.7.3
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 +27 -14
- package/_css.js.map +1 -1
- package/_utils.js.map +1 -1
- package/dom.cjs +16 -1
- package/dom.cjs.map +1 -1
- package/dom.js +16 -1
- package/dom.js.map +1 -1
- package/package.json +1 -1
- package/umd.js +16 -1
- package/umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -11,21 +11,20 @@ The fastest way to try Crank is via the [online playground](https://crank.js.org
|
|
|
11
11
|
|
|
12
12
|
Other links:
|
|
13
13
|
- [crank.js.org](https://crank.js.org)
|
|
14
|
-
- [
|
|
14
|
+
- [Introducing Crank.js](https://crank.js.org/blog/introducing-crank/)
|
|
15
15
|
- [Examples](https://github.com/bikeshaving/crank/tree/main/examples)
|
|
16
|
+
- [Deep Wiki](https://deepwiki.com/bikeshaving/crank)
|
|
16
17
|
|
|
17
18
|
## Motivation
|
|
18
19
|
**A framework that feels like JavaScript.**
|
|
19
20
|
|
|
20
21
|
While other frameworks invent new paradigms and force you to learn
|
|
21
22
|
framework-specific APIs, Crank embraces the language features you already know.
|
|
22
|
-
No hooks to memorize, no dependency arrays to debug, no cache invalidation to
|
|
23
|
-
manage.
|
|
24
23
|
|
|
25
24
|
### Pure JavaScript, No Compromises
|
|
26
25
|
|
|
27
26
|
```javascript
|
|
28
|
-
// Async components just work
|
|
27
|
+
// Async components just work, in the browser and on servers
|
|
29
28
|
async function UserProfile({userId}) {
|
|
30
29
|
const user = await fetchUser(userId);
|
|
31
30
|
return <div>Hello, {user.name}!</div>;
|
|
@@ -33,11 +32,14 @@ async function UserProfile({userId}) {
|
|
|
33
32
|
|
|
34
33
|
// Lifecycle logic with generators feels natural
|
|
35
34
|
function* Timer() {
|
|
35
|
+
// setup goes here
|
|
36
36
|
let seconds = 0;
|
|
37
37
|
const interval = setInterval(() => this.refresh(() => seconds++), 1000);
|
|
38
|
+
|
|
38
39
|
for ({} of this) {
|
|
39
40
|
yield <div>Seconds: {seconds}</div>;
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
clearInterval(interval); // Cleanup just works
|
|
42
44
|
}
|
|
43
45
|
```
|
|
@@ -45,7 +47,7 @@ function* Timer() {
|
|
|
45
47
|
### Why Developers Choose Crank
|
|
46
48
|
|
|
47
49
|
- **Intuitive**: Use `async`/`await` for loading states and `function*` for lifecycles — no new APIs to learn
|
|
48
|
-
- **Fast**: Outperforms React in benchmarks while weighing
|
|
50
|
+
- **Fast**: Outperforms React in benchmarks while weighing at 13.55KB with zero dependencies
|
|
49
51
|
- **Flexible**: Write components in vanilla JavaScript with template literals, or use JSX
|
|
50
52
|
- **Clean**: State lives in function scope, lifecycle code goes where it belongs, no mysterious re-render bugs
|
|
51
53
|
- **Future-proof**: Built on stable JavaScript features, not evolving framework abstractions
|
|
@@ -98,7 +100,8 @@ renderer.render(jsx`
|
|
|
98
100
|
### ECMAScript Module CDNs
|
|
99
101
|
Crank is also available on CDNs like [unpkg](https://unpkg.com)
|
|
100
102
|
(https://unpkg.com/@b9g/crank?module), [esm.sh](https://esm.sh)
|
|
101
|
-
(https://esm.sh/@b9g/crank), and [esm.run](https://esm.run/@b9g/crank)
|
|
103
|
+
(https://esm.sh/@b9g/crank), and [esm.run](https://esm.run/@b9g/crank)
|
|
104
|
+
(https://esm.run/@b9g/crank) for usage in ESM-ready environments.
|
|
102
105
|
|
|
103
106
|
```jsx live
|
|
104
107
|
/** @jsx createElement */
|
|
@@ -259,13 +262,13 @@ Here’s the configuration you will need to set up automatic JSX transpilation.
|
|
|
259
262
|
}
|
|
260
263
|
```
|
|
261
264
|
|
|
262
|
-
Crank is written in TypeScript. Refer to [the guide on
|
|
265
|
+
Crank is written in TypeScript and comes with types. Refer to [the guide on
|
|
263
266
|
TypeScript](https://crank.js.org/guides/working-with-typescript) for more
|
|
264
267
|
information about Crank types.
|
|
265
268
|
|
|
266
269
|
```tsx
|
|
267
270
|
import type {Context} from "@b9g/crank";
|
|
268
|
-
function *Timer(this: Context) {
|
|
271
|
+
function *Timer(this: Context<typeof Timer>) {
|
|
269
272
|
let seconds = 0;
|
|
270
273
|
const interval = setInterval(() => this.refresh(() => seconds++), 1000);
|
|
271
274
|
for ({} of this) {
|
|
@@ -428,20 +431,30 @@ function Component(props, ctx) {
|
|
|
428
431
|
|
|
429
432
|
#### Methods
|
|
430
433
|
|
|
431
|
-
**`this.refresh(callback?)`** - Trigger re-
|
|
434
|
+
**`this.refresh(callback?)`** - Trigger re-execution
|
|
432
435
|
```javascript
|
|
433
436
|
this.refresh(); // Simple refresh
|
|
434
437
|
this.refresh(() => count++); // With state update (v0.7+)
|
|
435
438
|
```
|
|
436
439
|
|
|
437
|
-
**`this.schedule(callback)`** - Execute after
|
|
440
|
+
**`this.schedule(callback?)`** - Execute after DOM is rendered
|
|
441
|
+
```javascript
|
|
442
|
+
// el is whatever the component returns Node/Text/HTMLElement/null, an array of dom nodes, etc
|
|
443
|
+
this.schedule((el) => {
|
|
444
|
+
console.log("Component rendered". el.innerHTML);
|
|
445
|
+
});
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**`this.after(callback?)`** - Execute after DOM is live
|
|
438
449
|
```javascript
|
|
439
|
-
this
|
|
440
|
-
|
|
450
|
+
// this runs after the DOM nodes have finally entered the DOM
|
|
451
|
+
// this is where you put things like autofocus
|
|
452
|
+
this.after((el) => {
|
|
453
|
+
console.log(el.isConnected); // true
|
|
441
454
|
});
|
|
442
455
|
```
|
|
443
456
|
|
|
444
|
-
**`this.cleanup(callback)`** -
|
|
457
|
+
**`this.cleanup(callback?)`** - Execute on unmount
|
|
445
458
|
```javascript
|
|
446
459
|
function* Component() {
|
|
447
460
|
const interval = setInterval(() => this.refresh(), 1000);
|
|
@@ -511,7 +524,7 @@ async function* AsyncComponent() {
|
|
|
511
524
|
|
|
512
525
|
**`key`** - Unique identifier for reconciliation
|
|
513
526
|
```javascript
|
|
514
|
-
{items.map(item => <li key={item.id}>{item.name}</li>)}
|
|
527
|
+
<ul>{items.map(item => <li key={item.id}>{item.name}</li>)}</ul>
|
|
515
528
|
```
|
|
516
529
|
|
|
517
530
|
**`ref`** - Access rendered DOM element
|
package/_css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_css.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_css.js","sources":["../src/_css.ts"],"sourcesContent":["/**\n * CSS utility functions for style property transformation.\n *\n * This module handles camelCase to kebab-case conversion and automatic\n * px unit conversion for numeric CSS values, making Crank more React-compatible.\n */\n\n/**\n * Converts camelCase CSS property names to kebab-case.\n * Handles vendor prefixes correctly (WebkitTransform -> -webkit-transform).\n */\nexport function camelToKebabCase(str: string): string {\n\t// Handle vendor prefixes that start with capital letters (WebkitTransform -> -webkit-transform)\n\tif (/^[A-Z]/.test(str)) {\n\t\treturn `-${str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`).slice(1)}`;\n\t}\n\t// Handle normal camelCase (fontSize -> font-size)\n\treturn str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n}\n\n/**\n * CSS properties that should remain unitless when given numeric values.\n * Based on React's list of unitless properties.\n */\nexport const UNITLESS_PROPERTIES = new Set([\n\t\"animation-iteration-count\",\n\t\"aspect-ratio\",\n\t\"border-image-outset\",\n\t\"border-image-slice\",\n\t\"border-image-width\",\n\t\"box-flex\",\n\t\"box-flex-group\",\n\t\"box-ordinal-group\",\n\t\"column-count\",\n\t\"columns\",\n\t\"flex\",\n\t\"flex-grow\",\n\t\"flex-positive\",\n\t\"flex-shrink\",\n\t\"flex-negative\",\n\t\"flex-order\",\n\t\"font-weight\",\n\t\"grid-area\",\n\t\"grid-column\",\n\t\"grid-column-end\",\n\t\"grid-column-span\",\n\t\"grid-column-start\",\n\t\"grid-row\",\n\t\"grid-row-end\",\n\t\"grid-row-span\",\n\t\"grid-row-start\",\n\t\"line-height\",\n\t\"opacity\",\n\t\"order\",\n\t\"orphans\",\n\t\"tab-size\",\n\t\"widows\",\n\t\"z-index\",\n\t\"zoom\",\n]);\n\n/**\n * Formats CSS property values, automatically adding \"px\" to numeric values\n * for properties that are not unitless.\n */\nexport function formatStyleValue(name: string, value: unknown): string {\n\tif (typeof value === \"number\") {\n\t\t// If the property should remain unitless, keep the number as-is\n\t\tif (UNITLESS_PROPERTIES.has(name)) {\n\t\t\treturn String(value);\n\t\t}\n\t\t// Otherwise, append \"px\" for numeric values\n\t\treturn `${value}px`;\n\t}\n\treturn String(value);\n}\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;;;AAGG;AACG,SAAU,gBAAgB,CAAC,GAAW,EAAA;;AAE3C,IAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,WAAW,EAAE,CAAE,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAE;;;AAGlF,IAAA,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,WAAW,EAAE,CAAA,CAAE,CAAC;AACnE;AAEA;;;AAGG;AACU,MAAA,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAC1C,2BAA2B;IAC3B,cAAc;IACd,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,UAAU;IACV,gBAAgB;IAChB,mBAAmB;IACnB,cAAc;IACd,SAAS;IACT,MAAM;IACN,WAAW;IACX,eAAe;IACf,aAAa;IACb,eAAe;IACf,YAAY;IACZ,aAAa;IACb,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,UAAU;IACV,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,OAAO;IACP,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,MAAM;AACN,CAAA;AAED;;;AAGG;AACa,SAAA,gBAAgB,CAAC,IAAY,EAAE,KAAc,EAAA;AAC5D,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;;AAE9B,QAAA,IAAI,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AAClC,YAAA,OAAO,MAAM,CAAC,KAAK,CAAC;;;QAGrB,OAAO,CAAA,EAAG,KAAK,CAAA,EAAA,CAAI;;AAEpB,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB;;;;"}
|
package/_utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"_utils.js","sources":["../src/_utils.ts"],"sourcesContent":["export function wrap<T>(value: Array<T> | T | undefined): Array<T> {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n\nexport function unwrap<T>(arr: Array<T>): Array<T> | T | undefined {\n\treturn arr.length === 0 ? undefined : arr.length === 1 ? arr[0] : arr;\n}\n\nexport type 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 */\nexport function 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\t? value\n\t\t\t: typeof value === \"string\" ||\n\t\t\t\t typeof (value as any)[Symbol.iterator] !== \"function\"\n\t\t\t\t? [value as T]\n\t\t\t\t: [...(value as NonStringIterable<T>)];\n}\n\nexport function isIteratorLike(\n\tvalue: any,\n): value is Iterator<unknown> | AsyncIterator<unknown> {\n\treturn value != null && typeof value.next === \"function\";\n}\n\nexport function isPromiseLike(value: any): value is PromiseLike<unknown> {\n\treturn value != null && typeof value.then === \"function\";\n}\n\ntype Deferred<T = unknown> = {\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: unknown) => void;\n};\n\ntype RaceRecord = {\n\tdeferreds: Set<Deferred>;\n\tsettled: boolean;\n};\n\nfunction createRaceRecord(contender: PromiseLike<unknown>): RaceRecord {\n\tconst deferreds = new Set<Deferred>();\n\tconst record = {deferreds, settled: false};\n\n\t// This call to `then` happens once for the lifetime of the value.\n\tPromise.resolve(contender).then(\n\t\t(value) => {\n\t\t\tfor (const {resolve} of deferreds) {\n\t\t\t\tresolve(value);\n\t\t\t}\n\n\t\t\tdeferreds.clear();\n\t\t\trecord.settled = true;\n\t\t},\n\t\t(err) => {\n\t\t\tfor (const {reject} of deferreds) {\n\t\t\t\treject(err);\n\t\t\t}\n\n\t\t\tdeferreds.clear();\n\t\t\trecord.settled = true;\n\t\t},\n\t);\n\treturn record;\n}\n\n// Promise.race is memory unsafe. This is alternative which is. See:\n// https://github.com/nodejs/node/issues/17469#issuecomment-685235106\n// Keys are the values passed to race.\n// Values are a record of data containing a set of deferreds and whether the\n// value has settled.\nconst wm = new WeakMap<object, RaceRecord>();\nexport function safeRace<T>(\n\tcontenders: Iterable<T | PromiseLike<T>>,\n): Promise<Awaited<T>> {\n\tlet deferred: Deferred;\n\tconst result = new Promise((resolve, reject) => {\n\t\tdeferred = {resolve, reject};\n\t\tfor (const contender of contenders) {\n\t\t\tif (!isPromiseLike(contender)) {\n\t\t\t\t// If the contender is a not a then-able, attempting to use it as a key\n\t\t\t\t// in the weakmap would throw an error. Luckily, it is safe to call\n\t\t\t\t// `Promise.resolve(contender).then` on regular values multiple\n\t\t\t\t// times because the promise fulfills immediately.\n\t\t\t\tPromise.resolve(contender).then(resolve, reject);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet record = wm.get(contender);\n\t\t\tif (record === undefined) {\n\t\t\t\trecord = createRaceRecord(contender);\n\t\t\t\trecord.deferreds.add(deferred);\n\t\t\t\twm.set(contender, record);\n\t\t\t} else if (record.settled) {\n\t\t\t\t// If the value has settled, it is safe to call\n\t\t\t\t// `Promise.resolve(contender).then` on it.\n\t\t\t\tPromise.resolve(contender).then(resolve, reject);\n\t\t\t} else {\n\t\t\t\trecord.deferreds.add(deferred);\n\t\t\t}\n\t\t}\n\t});\n\n\t// The finally callback executes when any value settles, preventing any of\n\t// the unresolved values from retaining a reference to the resolved value.\n\treturn result.finally(() => {\n\t\tfor (const contender of contenders) {\n\t\t\tif (isPromiseLike(contender)) {\n\t\t\t\tconst record = wm.get(contender);\n\t\t\t\tif (record) {\n\t\t\t\t\trecord.deferreds.delete(deferred);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}) as Promise<Awaited<T>>;\n}\n"],"names":[],"mappings":"AAAM,SAAU,IAAI,CAAI,KAA+B,EAAA;IACtD,OAAO,KAAK,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AACzE;AAEM,SAAU,MAAM,CAAI,GAAa,EAAA;AACtC,IAAA,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;AACtE;AAIA;;;;;;AAMG;AACG,SAAU,QAAQ,CACvB,KAAkD,EAAA;IAElD,OAAO,KAAK,IAAI;AACf,UAAE;AACF,UAAE,KAAK,CAAC,OAAO,CAAC,KAAK;AACpB,cAAE;AACF,cAAE,OAAO,KAAK,KAAK,QAAQ;AACxB,gBAAA,OAAQ,KAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK;kBAC3C,CAAC,KAAU;AACb,kBAAE,CAAC,GAAI,KAA8B,CAAC;AAC1C;AAEM,SAAU,cAAc,CAC7B,KAAU,EAAA;IAEV,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,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C;gBAChD;;YAGD,IAAI,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC;AAC9B,YAAA,IAAI,MAAM,KAAK,SAAS,EAAE;AACzB,gBAAA,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC;AACpC,gBAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9B,gBAAA,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC;;AACnB,iBAAA,IAAI,MAAM,CAAC,OAAO,EAAE;;;AAG1B,gBAAA,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;;iBAC1C;AACN,gBAAA,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;;;AAGjC,KAAC,CAAC;;;AAIF,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,MAAK;AAC1B,QAAA,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;AACnC,YAAA,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE;gBAC7B,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC;gBAChC,IAAI,MAAM,EAAE;AACX,oBAAA,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;;;;AAIrC,KAAC,CAAwB;AAC1B;;;;"}
|
package/dom.cjs
CHANGED
|
@@ -300,7 +300,22 @@ const adapter = {
|
|
|
300
300
|
!(typeof value === "string" &&
|
|
301
301
|
typeof element[name] === "boolean") &&
|
|
302
302
|
isWritableProperty(element, name)) {
|
|
303
|
-
|
|
303
|
+
// For URL properties like src and href, the DOM property returns the
|
|
304
|
+
// resolved absolute URL. We need to resolve the prop value the same way
|
|
305
|
+
// to compare correctly.
|
|
306
|
+
let domValue = element[name];
|
|
307
|
+
let propValue = value;
|
|
308
|
+
if ((name === "src" || name === "href") &&
|
|
309
|
+
typeof value === "string" &&
|
|
310
|
+
typeof domValue === "string") {
|
|
311
|
+
try {
|
|
312
|
+
propValue = new URL(value, element.baseURI).href;
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// Invalid URL, use original value for comparison
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (propValue !== domValue || oldValue === undefined) {
|
|
304
319
|
if (isHydrating &&
|
|
305
320
|
typeof element[name] === "string" &&
|
|
306
321
|
element[name] !== value) {
|
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\tPortal,\n\tRenderer,\n\tRenderAdapter,\n} from \"./crank.js\";\nimport {camelToKebabCase, formatStyleValue} from \"./_css.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\nconst MATHML_NAMESPACE = \"http://www.w3.org/1998/Math/MathML\";\n\nfunction isWritableProperty(element: Element, name: string): boolean {\n\t// walk up the object's prototype chain to find the owner\n\tlet propOwner = element;\n\tdo {\n\t\tif (Object.prototype.hasOwnProperty.call(propOwner, name)) {\n\t\t\tbreak;\n\t\t}\n\t} while ((propOwner = Object.getPrototypeOf(propOwner)));\n\n\tif (propOwner === null) {\n\t\treturn false;\n\t}\n\n\t// get the descriptor for the named property and check whether it implies\n\t// that the property is writable\n\tconst descriptor = Object.getOwnPropertyDescriptor(propOwner, name);\n\tif (\n\t\tdescriptor != null &&\n\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction emitHydrationWarning(\n\tpropName: string,\n\tquietProps: Set<string> | undefined,\n\texpectedValue: any,\n\tactualValue: any,\n\telement: Element,\n\tdisplayName?: string,\n) {\n\tconst checkName = propName;\n\tconst showName = displayName || propName;\n\tif (!quietProps || !quietProps.has(checkName)) {\n\t\tif (expectedValue === null || expectedValue === false) {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be missing but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (expectedValue === true || expectedValue === \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be ${expectedValue === true ? \"present\" : '\"\"'} but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof window !== \"undefined\" &&\n\t\t\twindow.location &&\n\t\t\tnew URL(expectedValue, window.location.origin).href ===\n\t\t\t\tnew URL(actualValue, window.location.origin).href\n\t\t) {\n\t\t\t// attrs which are URLs will often be resolved to their full\n\t\t\t// href in the DOM, so we squash these errors\n\t\t} else {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be \"${String(expectedValue)}\" but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport const adapter: Partial<RenderAdapter<Node, string, Element>> = {\n\tscope({\n\t\tscope: xmlns,\n\t\ttag,\n\t\tprops,\n\t}: {\n\t\tscope: 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\t// TODO: read the namespace from the portal root element\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\tcase \"math\":\n\t\t\t\txmlns = MATHML_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate({\n\t\ttag,\n\t\ttagName,\n\t\tscope: xmlns,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tscope: string | undefined;\n\t}): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t} else if (tag.toLowerCase() === \"math\") {\n\t\t\txmlns = MATHML_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\tadopt({\n\t\ttag,\n\t\ttagName,\n\t\tnode,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: Node | undefined;\n\t}): Array<Node> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t}\n\n\t\tif (\n\t\t\tnode === document.body ||\n\t\t\tnode === document.head ||\n\t\t\tnode === document.documentElement ||\n\t\t\tnode === document\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tnode == null ||\n\t\t\t(typeof tag === \"string\" &&\n\t\t\t\t(node.nodeType !== Node.ELEMENT_NODE ||\n\t\t\t\t\ttag.toLowerCase() !== (node as Element).tagName.toLowerCase()))\n\t\t) {\n\t\t\tconsole.warn(`Expected <${tagName}> while hydrating but found: `, node);\n\t\t\treturn;\n\t\t}\n\n\t\treturn Array.from(node.childNodes);\n\t},\n\n\tpatch({\n\t\ttagName,\n\t\tnode,\n\t\tprops,\n\t\toldProps,\n\t\tscope: xmlns,\n\t\tcopyProps,\n\t\tquietProps,\n\t\tisHydrating,\n\t}: {\n\t\tnode: Node;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\toldProps: Record<string, any> | undefined;\n\t\tscope: string | undefined;\n\t\tcopyProps: Set<string> | undefined;\n\t\tquietProps: Set<string> | undefined;\n\t\tisHydrating: boolean;\n\t}): void {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tthrow new TypeError(`Cannot patch node: ${String(node)}`);\n\t\t} else if (props.class && props.className) {\n\t\t\tconsole.error(\n\t\t\t\t`Both \"class\" and \"className\" set in props for <${tagName}>. Use one or the other.`,\n\t\t\t);\n\t\t}\n\n\t\tconst element = node as Element;\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tconst isMathML = xmlns === MATHML_NAMESPACE;\n\t\tfor (let name in {...oldProps, ...props}) {\n\t\t\tlet value = props[name];\n\t\t\tconst oldValue = oldProps ? oldProps[name] : undefined;\n\t\t\t{\n\t\t\t\tif (copyProps != null && copyProps.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// handle prop:name or attr:name properties\n\t\t\t\tconst colonIndex = name.indexOf(\":\");\n\t\t\t\tif (colonIndex !== -1) {\n\t\t\t\t\tconst [ns, name1] = [\n\t\t\t\t\t\tname.slice(0, colonIndex),\n\t\t\t\t\t\tname.slice(colonIndex + 1),\n\t\t\t\t\t];\n\t\t\t\t\tswitch (ns) {\n\t\t\t\t\t\tcase \"prop\":\n\t\t\t\t\t\t\t(node as any)[name1] = value;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase \"attr\":\n\t\t\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.removeAttribute(name1);\n\t\t\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\t\t\tif (isHydrating && !element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(name, quietProps, value, null, element);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.setAttribute(name1, \"\");\n\t\t\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isHydrating && element.getAttribute(name1) !== value) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\telement.setAttribute(name1, String(value));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (name) {\n\t\t\t\t// TODO: fix hydration warnings for the style prop\n\t\t\t\tcase \"style\": {\n\t\t\t\t\tconst style = (element as HTMLElement | SVGElement).style;\n\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.removeAttribute(\"style\");\n\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"style\", \"\");\n\t\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\t\t// TODO: Fix hydration warnings for styles\n\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t//\t\tvalue,\n\t\t\t\t\t\t\t//\t\tstyle.cssText,\n\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t//}\n\n\t\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear the style\n\t\t\t\t\t\t\t// TODO: only clear the styles enumerated in the old value\n\t\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const styleName in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst cssName = camelToKebabCase(styleName);\n\t\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\t\tif (isHydrating && style.getPropertyValue(cssName) !== \"\") {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle.removeProperty(cssName);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst formattedValue = formatStyleValue(cssName, styleValue);\n\t\t\t\t\t\t\t\tif (style.getPropertyValue(cssName) !== formattedValue) {\n\t\t\t\t\t\t\t\t\t// TODO: hydration warnings for style props\n\t\t\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t\t\t//\t\tformattedValue,\n\t\t\t\t\t\t\t\t\t//\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t\t\t//\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t\t\t\tstyle.setProperty(cssName, formattedValue);\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\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"class\":\n\t\t\t\tcase \"className\":\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tif (isHydrating && element.getAttribute(\"class\") !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t} else if (value == null) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(\"class\")) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(\"class\");\n\t\t\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\t\t\t// class={{\"included-class\": true, \"excluded-class\": false}} syntax\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear all classes\n\t\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet shouldIssueWarning = false;\n\t\t\t\t\t\tconst hydratingClasses = isHydrating\n\t\t\t\t\t\t\t? new Set(Array.from(element.classList))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tconst hydratingClassName = isHydrating\n\t\t\t\t\t\t\t? element.getAttribute(\"class\")\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\tfor (const className in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst classValue = value && value[className];\n\t\t\t\t\t\t\tif (classValue) {\n\t\t\t\t\t\t\t\telement.classList.add(className);\n\t\t\t\t\t\t\t\tif (hydratingClasses && hydratingClasses.has(className)) {\n\t\t\t\t\t\t\t\t\thydratingClasses.delete(className);\n\t\t\t\t\t\t\t\t} else if (isHydrating) {\n\t\t\t\t\t\t\t\t\tshouldIssueWarning = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\telement.classList.remove(className);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldIssueWarning ||\n\t\t\t\t\t\t\t(hydratingClasses && hydratingClasses.size > 0)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tObject.keys(value)\n\t\t\t\t\t\t\t\t\t.filter((k) => value[k])\n\t\t\t\t\t\t\t\t\t.join(\" \"),\n\t\t\t\t\t\t\t\thydratingClassName || \"\",\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!isSVG && !isMathML) {\n\t\t\t\t\t\tif (element.className !== value) {\n\t\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.className,\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telement.className = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (element.getAttribute(\"class\") !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", value as string);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"innerHTML\":\n\t\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.innerHTML,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.innerHTML = value as any;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tname[0] === \"o\" &&\n\t\t\t\t\t\tname[1] === \"n\" &&\n\t\t\t\t\t\tname[2] === name[2].toUpperCase() &&\n\t\t\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Support React-style event names (onClick, onChange, etc.)\n\t\t\t\t\t\tname = name.toLowerCase();\n\t\t\t\t\t}\n\n\t\t\t\t\t// try to set the property directly\n\t\t\t\t\tif (\n\t\t\t\t\t\tname in element &&\n\t\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t\t// falsy properties, so we force using setAttribute.\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof (element as any)[name] === \"boolean\"\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tisWritableProperty(element, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ((element as any)[name] !== value || oldValue === undefined) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisHydrating &&\n\t\t\t\t\t\t\t\ttypeof (element as any)[name] === \"string\" &&\n\t\t\t\t\t\t\t\t(element as any)[name] !== value\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t(element as any)[name],\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// if the property is writable, assign it directly\n\t\t\t\t\t\t\t(element as any)[name] = value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tvalue = \"\";\n\t\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name)) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(name);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (element.getAttribute(name) !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.setAttribute(name, value as any);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange({\n\t\ttag,\n\t\tnode,\n\t\tprops,\n\t\tchildren,\n\t}: {\n\t\ttag: string | symbol;\n\t\tnode: Node;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<Node>;\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: ${String(node)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"innerHTML\" in props)) {\n\t\t\tlet oldChild = node.firstChild;\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tconst newChild = children[i];\n\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t// the child is already in the right place, so we can skip it\n\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t} else {\n\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\tif (\n\t\t\t\t\t\ttag !== Portal &&\n\t\t\t\t\t\toldChild &&\n\t\t\t\t\t\ti + 1 < children.length &&\n\t\t\t\t\t\toldChild !== children[i + 1]\n\t\t\t\t\t) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremove({\n\t\tnode,\n\t\tparentNode,\n\t\tisNested,\n\t}: {\n\t\tnode: Node;\n\t\tparentNode: Node;\n\t\tisNested: boolean;\n\t}): void {\n\t\tif (!isNested && node.parentNode === parentNode) {\n\t\t\tparentNode.removeChild(node);\n\t\t}\n\t},\n\n\ttext({\n\t\tvalue,\n\t\toldNode,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string;\n\t\thydrationNodes: Array<Node> | undefined;\n\t\toldNode: Node | undefined;\n\t}): Node {\n\t\tif (hydrationNodes != null) {\n\t\t\tlet node = hydrationNodes.shift();\n\t\t\tif (!node || node.nodeType !== Node.TEXT_NODE) {\n\t\t\t\tconsole.warn(`Expected \"${value}\" while hydrating but found:`, node);\n\t\t\t} else {\n\t\t\t\t// value is a text node, check if it matches the expected text\n\t\t\t\tconst textData = (node as Text).data;\n\t\t\t\tif (textData.length > value.length) {\n\t\t\t\t\tif (textData.startsWith(value)) {\n\t\t\t\t\t\t// the text node is longer than the expected text, so we\n\t\t\t\t\t\t// reuse the existing text node, but truncate it and unshift the rest\n\t\t\t\t\t\t(node as Text).data = value;\n\t\t\t\t\t\thydrationNodes.unshift(\n\t\t\t\t\t\t\tdocument.createTextNode(textData.slice(value.length)),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn node;\n\t\t\t\t\t}\n\t\t\t\t} else if (textData === value) {\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\n\t\t\t\t// We log textData and not node because node will be mutated\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Expected \"${value}\" while hydrating but found:`,\n\t\t\t\t\ttextData,\n\t\t\t\t);\n\t\t\t\toldNode = node;\n\t\t\t}\n\t\t}\n\n\t\tif (oldNode != null) {\n\t\t\tif ((oldNode as Text).data !== value) {\n\t\t\t\t(oldNode as Text).data = value;\n\t\t\t}\n\n\t\t\treturn oldNode;\n\t\t}\n\n\t\treturn document.createTextNode(value);\n\t},\n\n\traw({\n\t\tvalue,\n\t\tscope: xmlns,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string | Node;\n\t\tscope: string | undefined;\n\t\thydrationNodes: Array<Node> | undefined;\n\t}): ElementValue<Node> {\n\t\tlet nodes: Array<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: xmlns === SVG_NAMESPACE\n\t\t\t\t\t\t? document.createElementNS(xmlns, \"svg\")\n\t\t\t\t\t\t: document.createElementNS(xmlns, \"math\");\n\t\t\tel.innerHTML = value;\n\t\t\tnodes = Array.from(el.childNodes);\n\t\t} else {\n\t\t\tnodes = value == null ? [] : Array.isArray(value) ? [...value] : [value];\n\t\t}\n\n\t\tif (hydrationNodes != null) {\n\t\t\tfor (let i = 0; i < nodes.length; i++) {\n\t\t\t\tconst node = nodes[i];\n\t\t\t\t// check if node is equal to the next node in the hydration array\n\t\t\t\tconst hydrationNode = hydrationNodes.shift();\n\t\t\t\tif (\n\t\t\t\t\thydrationNode &&\n\t\t\t\t\ttypeof hydrationNode === \"object\" &&\n\t\t\t\t\ttypeof hydrationNode.nodeType === \"number\" &&\n\t\t\t\t\tnode.isEqualNode(hydrationNode as Node)\n\t\t\t\t) {\n\t\t\t\t\tnodes[i] = hydrationNode as Node;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Expected <Raw value=\"${String(value)}\"> while hydrating but found:`,\n\t\t\t\t\t\thydrationNode,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes.length === 0\n\t\t\t? undefined\n\t\t\t: nodes.length === 1\n\t\t\t\t? nodes[0]\n\t\t\t\t: nodes;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string, Element> {\n\tconstructor() {\n\t\tsuper(adapter);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Element,\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: Element,\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 Element {\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(`Render root is not a node. Received: ${String(root)}`);\n\t} else if ((root as Node).nodeType !== Node.ELEMENT_NODE) {\n\t\tthrow new TypeError(\n\t\t\t`Render root must be an element node. Received: ${String(root)}`,\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","camelToKebabCase","formatStyleValue","Renderer"],"mappings":";;;;;AAUA,MAAM,aAAa,GAAG,4BAA4B;AAClD,MAAM,gBAAgB,GAAG,oCAAoC;AAE7D,SAAS,kBAAkB,CAAC,OAAgB,EAAE,IAAY,EAAA;;IAEzD,IAAI,SAAS,GAAG,OAAO;AACvB,IAAA,GAAG;AACF,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE;YAC1D;;KAED,SAAS,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC;AAEtD,IAAA,IAAI,SAAS,KAAK,IAAI,EAAE;AACvB,QAAA,OAAO,KAAK;;;;IAKb,MAAM,UAAU,GAAG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,KAAK;AACvB,cAAE;AACF,cAAE,KAAK,CAAC,MAAM,KAAK;AAClB,kBAAE,KAAK,CAAC,CAAC;kBACP,KAAK;KACT;;AAGI,MAAO,WAAY,SAAQG,cAA+B,CAAA;AAC/D,IAAA,WAAA,GAAA;QACC,KAAK,CAAC,OAAO,CAAC;;AAGf,IAAA,MAAM,CACL,QAAkB,EAClB,IAAa,EACb,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,IAAa,EACb,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,IAAI,IAAI;AACZ,SAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ,CAAC,EACvE;QACD,MAAM,IAAI,SAAS,CAAC,CAAwC,qCAAA,EAAA,MAAM,CAAC,IAAI,CAAC,CAAE,CAAA,CAAC;;SACrE,IAAK,IAAa,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;QACzD,MAAM,IAAI,SAAS,CAClB,CAAkD,+CAAA,EAAA,MAAM,CAAC,IAAI,CAAC,CAAE,CAAA,CAChE;;AAEH;AAEa,MAAA,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
|
1
|
+
{"version":3,"file":"dom.cjs","sources":["../src/dom.ts"],"sourcesContent":["import {\n\tChildren,\n\tContext,\n\tElementValue,\n\tPortal,\n\tRenderer,\n\tRenderAdapter,\n} from \"./crank.js\";\nimport {camelToKebabCase, formatStyleValue} from \"./_css.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\nconst MATHML_NAMESPACE = \"http://www.w3.org/1998/Math/MathML\";\n\nfunction isWritableProperty(element: Element, name: string): boolean {\n\t// walk up the object's prototype chain to find the owner\n\tlet propOwner = element;\n\tdo {\n\t\tif (Object.prototype.hasOwnProperty.call(propOwner, name)) {\n\t\t\tbreak;\n\t\t}\n\t} while ((propOwner = Object.getPrototypeOf(propOwner)));\n\n\tif (propOwner === null) {\n\t\treturn false;\n\t}\n\n\t// get the descriptor for the named property and check whether it implies\n\t// that the property is writable\n\tconst descriptor = Object.getOwnPropertyDescriptor(propOwner, name);\n\tif (\n\t\tdescriptor != null &&\n\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction emitHydrationWarning(\n\tpropName: string,\n\tquietProps: Set<string> | undefined,\n\texpectedValue: any,\n\tactualValue: any,\n\telement: Element,\n\tdisplayName?: string,\n) {\n\tconst checkName = propName;\n\tconst showName = displayName || propName;\n\tif (!quietProps || !quietProps.has(checkName)) {\n\t\tif (expectedValue === null || expectedValue === false) {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be missing but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (expectedValue === true || expectedValue === \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be ${expectedValue === true ? \"present\" : '\"\"'} but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof window !== \"undefined\" &&\n\t\t\twindow.location &&\n\t\t\tnew URL(expectedValue, window.location.origin).href ===\n\t\t\t\tnew URL(actualValue, window.location.origin).href\n\t\t) {\n\t\t\t// attrs which are URLs will often be resolved to their full\n\t\t\t// href in the DOM, so we squash these errors\n\t\t} else {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be \"${String(expectedValue)}\" but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport const adapter: Partial<RenderAdapter<Node, string, Element>> = {\n\tscope({\n\t\tscope: xmlns,\n\t\ttag,\n\t\tprops,\n\t}: {\n\t\tscope: 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\t// TODO: read the namespace from the portal root element\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\tcase \"math\":\n\t\t\t\txmlns = MATHML_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate({\n\t\ttag,\n\t\ttagName,\n\t\tscope: xmlns,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tscope: string | undefined;\n\t}): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t} else if (tag.toLowerCase() === \"math\") {\n\t\t\txmlns = MATHML_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\tadopt({\n\t\ttag,\n\t\ttagName,\n\t\tnode,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: Node | undefined;\n\t}): Array<Node> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t}\n\n\t\tif (\n\t\t\tnode === document.body ||\n\t\t\tnode === document.head ||\n\t\t\tnode === document.documentElement ||\n\t\t\tnode === document\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tnode == null ||\n\t\t\t(typeof tag === \"string\" &&\n\t\t\t\t(node.nodeType !== Node.ELEMENT_NODE ||\n\t\t\t\t\ttag.toLowerCase() !== (node as Element).tagName.toLowerCase()))\n\t\t) {\n\t\t\tconsole.warn(`Expected <${tagName}> while hydrating but found: `, node);\n\t\t\treturn;\n\t\t}\n\n\t\treturn Array.from(node.childNodes);\n\t},\n\n\tpatch({\n\t\ttagName,\n\t\tnode,\n\t\tprops,\n\t\toldProps,\n\t\tscope: xmlns,\n\t\tcopyProps,\n\t\tquietProps,\n\t\tisHydrating,\n\t}: {\n\t\tnode: Node;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\toldProps: Record<string, any> | undefined;\n\t\tscope: string | undefined;\n\t\tcopyProps: Set<string> | undefined;\n\t\tquietProps: Set<string> | undefined;\n\t\tisHydrating: boolean;\n\t}): void {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tthrow new TypeError(`Cannot patch node: ${String(node)}`);\n\t\t} else if (props.class && props.className) {\n\t\t\tconsole.error(\n\t\t\t\t`Both \"class\" and \"className\" set in props for <${tagName}>. Use one or the other.`,\n\t\t\t);\n\t\t}\n\n\t\tconst element = node as Element;\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tconst isMathML = xmlns === MATHML_NAMESPACE;\n\t\tfor (let name in {...oldProps, ...props}) {\n\t\t\tlet value = props[name];\n\t\t\tconst oldValue = oldProps ? oldProps[name] : undefined;\n\t\t\t{\n\t\t\t\tif (copyProps != null && copyProps.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// handle prop:name or attr:name properties\n\t\t\t\tconst colonIndex = name.indexOf(\":\");\n\t\t\t\tif (colonIndex !== -1) {\n\t\t\t\t\tconst [ns, name1] = [\n\t\t\t\t\t\tname.slice(0, colonIndex),\n\t\t\t\t\t\tname.slice(colonIndex + 1),\n\t\t\t\t\t];\n\t\t\t\t\tswitch (ns) {\n\t\t\t\t\t\tcase \"prop\":\n\t\t\t\t\t\t\t(node as any)[name1] = value;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase \"attr\":\n\t\t\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.removeAttribute(name1);\n\t\t\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\t\t\tif (isHydrating && !element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(name, quietProps, value, null, element);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.setAttribute(name1, \"\");\n\t\t\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isHydrating && element.getAttribute(name1) !== value) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\telement.setAttribute(name1, String(value));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (name) {\n\t\t\t\t// TODO: fix hydration warnings for the style prop\n\t\t\t\tcase \"style\": {\n\t\t\t\t\tconst style = (element as HTMLElement | SVGElement).style;\n\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.removeAttribute(\"style\");\n\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"style\", \"\");\n\t\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\t\t// TODO: Fix hydration warnings for styles\n\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t//\t\tvalue,\n\t\t\t\t\t\t\t//\t\tstyle.cssText,\n\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t//}\n\n\t\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear the style\n\t\t\t\t\t\t\t// TODO: only clear the styles enumerated in the old value\n\t\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const styleName in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst cssName = camelToKebabCase(styleName);\n\t\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\t\tif (isHydrating && style.getPropertyValue(cssName) !== \"\") {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle.removeProperty(cssName);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst formattedValue = formatStyleValue(cssName, styleValue);\n\t\t\t\t\t\t\t\tif (style.getPropertyValue(cssName) !== formattedValue) {\n\t\t\t\t\t\t\t\t\t// TODO: hydration warnings for style props\n\t\t\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t\t\t//\t\tformattedValue,\n\t\t\t\t\t\t\t\t\t//\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t\t\t//\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t\t\t\tstyle.setProperty(cssName, formattedValue);\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\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"class\":\n\t\t\t\tcase \"className\":\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tif (isHydrating && element.getAttribute(\"class\") !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t} else if (value == null) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(\"class\")) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(\"class\");\n\t\t\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\t\t\t// class={{\"included-class\": true, \"excluded-class\": false}} syntax\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear all classes\n\t\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet shouldIssueWarning = false;\n\t\t\t\t\t\tconst hydratingClasses = isHydrating\n\t\t\t\t\t\t\t? new Set(Array.from(element.classList))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tconst hydratingClassName = isHydrating\n\t\t\t\t\t\t\t? element.getAttribute(\"class\")\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\tfor (const className in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst classValue = value && value[className];\n\t\t\t\t\t\t\tif (classValue) {\n\t\t\t\t\t\t\t\telement.classList.add(className);\n\t\t\t\t\t\t\t\tif (hydratingClasses && hydratingClasses.has(className)) {\n\t\t\t\t\t\t\t\t\thydratingClasses.delete(className);\n\t\t\t\t\t\t\t\t} else if (isHydrating) {\n\t\t\t\t\t\t\t\t\tshouldIssueWarning = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\telement.classList.remove(className);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldIssueWarning ||\n\t\t\t\t\t\t\t(hydratingClasses && hydratingClasses.size > 0)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tObject.keys(value)\n\t\t\t\t\t\t\t\t\t.filter((k) => value[k])\n\t\t\t\t\t\t\t\t\t.join(\" \"),\n\t\t\t\t\t\t\t\thydratingClassName || \"\",\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!isSVG && !isMathML) {\n\t\t\t\t\t\tif (element.className !== value) {\n\t\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.className,\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telement.className = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (element.getAttribute(\"class\") !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", value as string);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"innerHTML\":\n\t\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.innerHTML,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.innerHTML = value as any;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tname[0] === \"o\" &&\n\t\t\t\t\t\tname[1] === \"n\" &&\n\t\t\t\t\t\tname[2] === name[2].toUpperCase() &&\n\t\t\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Support React-style event names (onClick, onChange, etc.)\n\t\t\t\t\t\tname = name.toLowerCase();\n\t\t\t\t\t}\n\n\t\t\t\t\t// try to set the property directly\n\t\t\t\t\tif (\n\t\t\t\t\t\tname in element &&\n\t\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t\t// falsy properties, so we force using setAttribute.\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof (element as any)[name] === \"boolean\"\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tisWritableProperty(element, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// For URL properties like src and href, the DOM property returns the\n\t\t\t\t\t\t// resolved absolute URL. We need to resolve the prop value the same way\n\t\t\t\t\t\t// to compare correctly.\n\t\t\t\t\t\tlet domValue = (element as any)[name];\n\t\t\t\t\t\tlet propValue = value;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(name === \"src\" || name === \"href\") &&\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof domValue === \"string\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tpropValue = new URL(value, element.baseURI).href;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Invalid URL, use original value for comparison\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (propValue !== domValue || oldValue === undefined) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisHydrating &&\n\t\t\t\t\t\t\t\ttypeof (element as any)[name] === \"string\" &&\n\t\t\t\t\t\t\t\t(element as any)[name] !== value\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t(element as any)[name],\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// if the property is writable, assign it directly\n\t\t\t\t\t\t\t(element as any)[name] = value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tvalue = \"\";\n\t\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name)) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(name);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (element.getAttribute(name) !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.setAttribute(name, value as any);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange({\n\t\ttag,\n\t\tnode,\n\t\tprops,\n\t\tchildren,\n\t}: {\n\t\ttag: string | symbol;\n\t\tnode: Node;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<Node>;\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: ${String(node)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"innerHTML\" in props)) {\n\t\t\tlet oldChild = node.firstChild;\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tconst newChild = children[i];\n\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t// the child is already in the right place, so we can skip it\n\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t} else {\n\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\tif (\n\t\t\t\t\t\ttag !== Portal &&\n\t\t\t\t\t\toldChild &&\n\t\t\t\t\t\ti + 1 < children.length &&\n\t\t\t\t\t\toldChild !== children[i + 1]\n\t\t\t\t\t) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremove({\n\t\tnode,\n\t\tparentNode,\n\t\tisNested,\n\t}: {\n\t\tnode: Node;\n\t\tparentNode: Node;\n\t\tisNested: boolean;\n\t}): void {\n\t\tif (!isNested && node.parentNode === parentNode) {\n\t\t\tparentNode.removeChild(node);\n\t\t}\n\t},\n\n\ttext({\n\t\tvalue,\n\t\toldNode,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string;\n\t\thydrationNodes: Array<Node> | undefined;\n\t\toldNode: Node | undefined;\n\t}): Node {\n\t\tif (hydrationNodes != null) {\n\t\t\tlet node = hydrationNodes.shift();\n\t\t\tif (!node || node.nodeType !== Node.TEXT_NODE) {\n\t\t\t\tconsole.warn(`Expected \"${value}\" while hydrating but found:`, node);\n\t\t\t} else {\n\t\t\t\t// value is a text node, check if it matches the expected text\n\t\t\t\tconst textData = (node as Text).data;\n\t\t\t\tif (textData.length > value.length) {\n\t\t\t\t\tif (textData.startsWith(value)) {\n\t\t\t\t\t\t// the text node is longer than the expected text, so we\n\t\t\t\t\t\t// reuse the existing text node, but truncate it and unshift the rest\n\t\t\t\t\t\t(node as Text).data = value;\n\t\t\t\t\t\thydrationNodes.unshift(\n\t\t\t\t\t\t\tdocument.createTextNode(textData.slice(value.length)),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn node;\n\t\t\t\t\t}\n\t\t\t\t} else if (textData === value) {\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\n\t\t\t\t// We log textData and not node because node will be mutated\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Expected \"${value}\" while hydrating but found:`,\n\t\t\t\t\ttextData,\n\t\t\t\t);\n\t\t\t\toldNode = node;\n\t\t\t}\n\t\t}\n\n\t\tif (oldNode != null) {\n\t\t\tif ((oldNode as Text).data !== value) {\n\t\t\t\t(oldNode as Text).data = value;\n\t\t\t}\n\n\t\t\treturn oldNode;\n\t\t}\n\n\t\treturn document.createTextNode(value);\n\t},\n\n\traw({\n\t\tvalue,\n\t\tscope: xmlns,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string | Node;\n\t\tscope: string | undefined;\n\t\thydrationNodes: Array<Node> | undefined;\n\t}): ElementValue<Node> {\n\t\tlet nodes: Array<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: xmlns === SVG_NAMESPACE\n\t\t\t\t\t\t? document.createElementNS(xmlns, \"svg\")\n\t\t\t\t\t\t: document.createElementNS(xmlns, \"math\");\n\t\t\tel.innerHTML = value;\n\t\t\tnodes = Array.from(el.childNodes);\n\t\t} else {\n\t\t\tnodes = value == null ? [] : Array.isArray(value) ? [...value] : [value];\n\t\t}\n\n\t\tif (hydrationNodes != null) {\n\t\t\tfor (let i = 0; i < nodes.length; i++) {\n\t\t\t\tconst node = nodes[i];\n\t\t\t\t// check if node is equal to the next node in the hydration array\n\t\t\t\tconst hydrationNode = hydrationNodes.shift();\n\t\t\t\tif (\n\t\t\t\t\thydrationNode &&\n\t\t\t\t\ttypeof hydrationNode === \"object\" &&\n\t\t\t\t\ttypeof hydrationNode.nodeType === \"number\" &&\n\t\t\t\t\tnode.isEqualNode(hydrationNode as Node)\n\t\t\t\t) {\n\t\t\t\t\tnodes[i] = hydrationNode as Node;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Expected <Raw value=\"${String(value)}\"> while hydrating but found:`,\n\t\t\t\t\t\thydrationNode,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes.length === 0\n\t\t\t? undefined\n\t\t\t: nodes.length === 1\n\t\t\t\t? nodes[0]\n\t\t\t\t: nodes;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string, Element> {\n\tconstructor() {\n\t\tsuper(adapter);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Element,\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: Element,\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 Element {\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(`Render root is not a node. Received: ${String(root)}`);\n\t} else if ((root as Node).nodeType !== Node.ELEMENT_NODE) {\n\t\tthrow new TypeError(\n\t\t\t`Render root must be an element node. Received: ${String(root)}`,\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","camelToKebabCase","formatStyleValue","Renderer"],"mappings":";;;;;AAUA,MAAM,aAAa,GAAG,4BAA4B;AAClD,MAAM,gBAAgB,GAAG,oCAAoC;AAE7D,SAAS,kBAAkB,CAAC,OAAgB,EAAE,IAAY,EAAA;;IAEzD,IAAI,SAAS,GAAG,OAAO;AACvB,IAAA,GAAG;AACF,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE;YAC1D;;KAED,SAAS,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC;AAEtD,IAAA,IAAI,SAAS,KAAK,IAAI,EAAE;AACvB,QAAA,OAAO,KAAK;;;;IAKb,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAC;IACnE,IACC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AEa,MAAA,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
package/dom.js
CHANGED
|
@@ -299,7 +299,22 @@ const adapter = {
|
|
|
299
299
|
!(typeof value === "string" &&
|
|
300
300
|
typeof element[name] === "boolean") &&
|
|
301
301
|
isWritableProperty(element, name)) {
|
|
302
|
-
|
|
302
|
+
// For URL properties like src and href, the DOM property returns the
|
|
303
|
+
// resolved absolute URL. We need to resolve the prop value the same way
|
|
304
|
+
// to compare correctly.
|
|
305
|
+
let domValue = element[name];
|
|
306
|
+
let propValue = value;
|
|
307
|
+
if ((name === "src" || name === "href") &&
|
|
308
|
+
typeof value === "string" &&
|
|
309
|
+
typeof domValue === "string") {
|
|
310
|
+
try {
|
|
311
|
+
propValue = new URL(value, element.baseURI).href;
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
// Invalid URL, use original value for comparison
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (propValue !== domValue || oldValue === undefined) {
|
|
303
318
|
if (isHydrating &&
|
|
304
319
|
typeof element[name] === "string" &&
|
|
305
320
|
element[name] !== value) {
|