@askrjs/askr 0.0.49 → 0.0.50
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/dist/benchmark.js +2 -2
- package/dist/common/jsx.d.ts +6 -2
- package/dist/common/jsx.d.ts.map +1 -1
- package/dist/common/jsx.js.map +1 -1
- package/dist/common/vnode.d.ts +2 -2
- package/dist/common/vnode.d.ts.map +1 -1
- package/dist/common/vnode.js.map +1 -1
- package/dist/jsx/index.d.ts +1 -1
- package/dist/jsx/types.d.ts +2 -2
- package/dist/jsx/types.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime2.d.ts +1 -1
- package/dist/renderer/component-host.js.map +1 -1
- package/dist/renderer/dom-internal.js.map +1 -1
- package/package.json +1 -1
package/dist/benchmark.js
CHANGED
|
@@ -10,8 +10,8 @@ import { BenchmarkTable } from "./bench/components/benchmark-table.js";
|
|
|
10
10
|
installRendererBridge();
|
|
11
11
|
const benchmarkMetadata = {
|
|
12
12
|
packageName: "@askrjs/askr",
|
|
13
|
-
packageVersion: "0.0.
|
|
14
|
-
buildLabel: "0.0.
|
|
13
|
+
packageVersion: "0.0.50",
|
|
14
|
+
buildLabel: "0.0.50-local"
|
|
15
15
|
};
|
|
16
16
|
function getBenchmarkMetadata() {
|
|
17
17
|
return { ...benchmarkMetadata };
|
package/dist/common/jsx.d.ts
CHANGED
|
@@ -4,16 +4,20 @@ import { Props } from "./props.js";
|
|
|
4
4
|
declare const ELEMENT_TYPE: unique symbol;
|
|
5
5
|
declare const Fragment: unique symbol;
|
|
6
6
|
declare const STATIC_CHILDREN: unique symbol;
|
|
7
|
+
type JSXComponent<TProps extends object = Props> = {
|
|
8
|
+
bivarianceHack(props: TProps): unknown;
|
|
9
|
+
}['bivarianceHack'];
|
|
10
|
+
type JSXElementType = string | JSXComponent | symbol;
|
|
7
11
|
interface JSXElement {
|
|
8
12
|
/** Internal element marker */
|
|
9
13
|
$$typeof: symbol;
|
|
10
14
|
/** Element type: string, component, Fragment, etc */
|
|
11
|
-
type:
|
|
15
|
+
type: JSXElementType;
|
|
12
16
|
/** Props bag */
|
|
13
17
|
props: Props;
|
|
14
18
|
/** Optional key (normalized by runtime) */
|
|
15
19
|
key?: string | number | null;
|
|
16
20
|
}
|
|
17
21
|
//#endregion
|
|
18
|
-
export { Fragment, JSXElement };
|
|
22
|
+
export { Fragment, JSXComponent, JSXElement, JSXElementType };
|
|
19
23
|
//# sourceMappingURL=jsx.d.ts.map
|
package/dist/common/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","names":[],"sources":["../../src/common/jsx.ts"],"mappings":";;;cAMa,YAAA;AAAA,cACA,QAAA;AAAA,cACA,eAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","names":[],"sources":["../../src/common/jsx.ts"],"mappings":";;;cAMa,YAAA;AAAA,cACA,QAAA;AAAA,cACA,eAAA;AAAA,KAED,YAAA,yBAAqC,KAAA;EAC/C,cAAA,CAAe,KAAA,EAAO,MAAM;AAAA;AAAA,KAGlB,cAAA,YAA0B,YAAY;AAAA,UAEjC,UAAA;EATkC;EAWjD,QAAA;EAV+D;EAa/D,IAAA,EAAM,cAAA;EAbyD;EAgB/D,KAAA,EAAO,KAAK;EAdF;EAiBV,GAAA;AAAA"}
|
package/dist/common/jsx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.js","names":[],"sources":["../../src/common/jsx.ts"],"sourcesContent":["/**\n * Common call contracts: JSX element shape\n */\n\nimport type { Props } from './props';\n\nexport const ELEMENT_TYPE = Symbol.for('askr.element');\nexport const Fragment = Symbol.for('askr.fragment');\nexport const STATIC_CHILDREN = Symbol.for('askr.static-children');\n\nexport interface JSXElement {\n /** Internal element marker */\n $$typeof: symbol;\n\n /** Element type: string, component, Fragment, etc */\n type:
|
|
1
|
+
{"version":3,"file":"jsx.js","names":[],"sources":["../../src/common/jsx.ts"],"sourcesContent":["/**\n * Common call contracts: JSX element shape\n */\n\nimport type { Props } from './props';\n\nexport const ELEMENT_TYPE = Symbol.for('askr.element');\nexport const Fragment = Symbol.for('askr.fragment');\nexport const STATIC_CHILDREN = Symbol.for('askr.static-children');\n\nexport type JSXComponent<TProps extends object = Props> = {\n bivarianceHack(props: TProps): unknown;\n}['bivarianceHack'];\n\nexport type JSXElementType = string | JSXComponent | symbol;\n\nexport interface JSXElement {\n /** Internal element marker */\n $$typeof: symbol;\n\n /** Element type: string, component, Fragment, etc */\n type: JSXElementType;\n\n /** Props bag */\n props: Props;\n\n /** Optional key (normalized by runtime) */\n key?: string | number | null;\n}\n"],"mappings":";AAMA,MAAa,eAAe,OAAO,IAAI,cAAc;AACrD,MAAa,WAAW,OAAO,IAAI,eAAe;AAClD,MAAa,kBAAkB,OAAO,IAAI,sBAAsB"}
|
package/dist/common/vnode.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Props } from "./props.js";
|
|
2
|
-
import { JSXElement } from "./jsx.js";
|
|
2
|
+
import { JSXElement, JSXElementType } from "./jsx.js";
|
|
3
3
|
import { ForState } from "../runtime/for-internal.js";
|
|
4
4
|
import { ControlBoundaryState } from "../runtime/control.js";
|
|
5
5
|
//#region src/common/vnode.d.ts
|
|
6
6
|
declare const __ERROR_BOUNDARY__: unique symbol;
|
|
7
7
|
interface DOMElement {
|
|
8
|
-
type:
|
|
8
|
+
type: JSXElementType;
|
|
9
9
|
props?: Props;
|
|
10
10
|
children?: VNode[];
|
|
11
11
|
key?: string | number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vnode.d.ts","names":[],"sources":["../../src/common/vnode.ts"],"mappings":";;;;;cAWa,kBAAA;AAAA,UAEI,UAAA;EAIf,IAAA,
|
|
1
|
+
{"version":3,"file":"vnode.d.ts","names":[],"sources":["../../src/common/vnode.ts"],"mappings":";;;;;cAWa,kBAAA;AAAA,UAEI,UAAA;EAIf,IAAA,EAAM,cAAA;EACN,KAAA,GAAQ,KAAA;EACR,QAAA,GAAW,KAAA;EACX,GAAA;EAAA,CACC,MAAA,CAAO,QAAA;EACR,aAAA,GAAgB,oBAAA;EAChB,SAAA,GAAY,QAAA;AAAA;AAAA,KAIF,KAAA,GAAQ,UAAU;AAAA,KAClB,eAAA,GAAkB,KAAA,GAAQ,UAAA,YAAsB,eAAA;AAAA,cAI/C,gBAAA;AAAA,iBAEG,aAAA,CAAc,IAAA,YAAgB,IAAA,IAAQ,UAAU"}
|
package/dist/common/vnode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vnode.js","names":[],"sources":["../../src/common/vnode.ts"],"sourcesContent":["/**\n * Common call contracts: VNode / virtual DOM shapes\n */\n\nimport type { Props } from './props';\nimport type { JSXElement } from './jsx';\nimport type { ControlBoundaryState } from '../runtime/control';\nimport type { ForState } from '../runtime/for';\nexport { __CONTROL_BOUNDARY__ } from './control';\nimport { __CONTROL_BOUNDARY__ } from './control';\n\nexport const __ERROR_BOUNDARY__ = Symbol.for('askr.error-boundary');\n\nexport interface DOMElement {\n // Element `type` can be an intrinsic tag name, a component function, or\n // a special symbol (e.g. `Fragment`). Include `symbol` in the type union\n // so runtime comparisons against `Fragment` are type-safe.\n type:
|
|
1
|
+
{"version":3,"file":"vnode.js","names":[],"sources":["../../src/common/vnode.ts"],"sourcesContent":["/**\n * Common call contracts: VNode / virtual DOM shapes\n */\n\nimport type { Props } from './props';\nimport type { JSXElement, JSXElementType } from './jsx';\nimport type { ControlBoundaryState } from '../runtime/control';\nimport type { ForState } from '../runtime/for';\nexport { __CONTROL_BOUNDARY__ } from './control';\nimport { __CONTROL_BOUNDARY__ } from './control';\n\nexport const __ERROR_BOUNDARY__ = Symbol.for('askr.error-boundary');\n\nexport interface DOMElement {\n // Element `type` can be an intrinsic tag name, a component function, or\n // a special symbol (e.g. `Fragment`). Include `symbol` in the type union\n // so runtime comparisons against `Fragment` are type-safe.\n type: JSXElementType;\n props?: Props;\n children?: VNode[];\n key?: string | number | null;\n [Symbol.iterator]?: never;\n _controlState?: ControlBoundaryState; // Internal: control boundary state\n _forState?: ForState<unknown>; // Deprecated internal alias during migration\n}\n\n// Type for virtual DOM nodes\nexport type VNode = DOMElement | string | number | boolean | null | undefined;\nexport type RenderableChild = VNode | JSXElement | readonly RenderableChild[];\n\n// Backward-compatible internal alias while renderer/runtime migrates away from\n// the old For-only boundary naming.\nexport const __FOR_BOUNDARY__ = __CONTROL_BOUNDARY__;\n\nexport function _isDOMElement(node: unknown): node is DOMElement {\n return typeof node === 'object' && node !== null && 'type' in node;\n}\n"],"mappings":";;AAWA,MAAa,qBAAqB,OAAO,IAAI,qBAAqB;AAqBlE,MAAa,mBAAmB;AAEhC,SAAgB,cAAc,MAAmC;CAC/D,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU;AAChE"}
|
package/dist/jsx/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Fragment, JSXElement } from "../common/jsx.js";
|
|
1
|
+
import { Fragment, JSXComponent, JSXElement, JSXElementType } from "../common/jsx.js";
|
|
2
2
|
export type { JSXElement };
|
package/dist/jsx/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntrinsicFallbackProps, KnownIntrinsicElementProps, Props } from "../common/props.js";
|
|
2
|
-
import { Fragment, JSXElement } from "../common/jsx.js";
|
|
2
|
+
import { Fragment, JSXComponent, JSXElement, JSXElementType } from "../common/jsx.js";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx/types.d.ts
|
|
5
5
|
declare global {
|
|
@@ -19,5 +19,5 @@ declare global {
|
|
|
19
19
|
}
|
|
20
20
|
} //# sourceMappingURL=types.d.ts.map
|
|
21
21
|
//#endregion
|
|
22
|
-
export { Fragment, type JSXElement };
|
|
22
|
+
export { Fragment, type JSXComponent, type JSXElement, type JSXElementType };
|
|
23
23
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/jsx/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/jsx/types.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/jsx/types.ts"],"mappings":";;;;QAwBQ,MAAA;EAAA,UAEI,GAAA;IAAA,UAEE,OAAA,SAAgB,UAAA;MAAA,SACf,qBAAA;IAAA;IAAA,UAGD,iBAAA,SAA0B,0BAAA;MAAA,CACjC,IAAA,WACG,sBAAA,GACA,0BAAA,OAAiC,0BAAA;IAAA;IAAA,UAG7B,yBAAA;MACR,KAAA,EAAO,KAAA;IAAA;IAAA,UAGC,wBAAA;MACR,QAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntrinsicFallbackProps, KnownIntrinsicElementProps, Props } from "./common/props.js";
|
|
2
|
-
import { Fragment, JSXElement } from "./common/jsx.js";
|
|
2
|
+
import { Fragment, JSXComponent, JSXElement, JSXElementType } from "./common/jsx.js";
|
|
3
3
|
import { EagerControlPrimitive } from "./common/control.js";
|
|
4
4
|
//#region src/jsx/jsx-dev-runtime.d.ts
|
|
5
5
|
declare function jsxDEV(type: EagerControlPrimitive, props: Props | null, key?: string | number, isStaticChildren?: boolean): unknown;
|
|
@@ -8,5 +8,5 @@ declare function jsxDEV<TTag extends string>(type: Exclude<TTag, keyof KnownIntr
|
|
|
8
8
|
declare function jsxDEV<TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
|
|
9
9
|
declare function jsxDEV(type: symbol, props: Props | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { Fragment, type JSXElement, jsxDEV };
|
|
11
|
+
export { Fragment, type JSXComponent, type JSXElement, type JSXElementType, jsxDEV };
|
|
12
12
|
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.d.ts","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"mappings":";;;;iBA2CgB,MAAA,CACd,IAAA,EAAM,qBAAA,EACN,KAAA,EAAO,KAAK,SACZ,GAAA,oBACA,gBAAA;AAAA,iBAEc,MAAA,oBAA0B,0BAAA,EACxC,IAAA,EAAM,IAAA,EACN,KAAA,EAAO,0BAAA,CAA2B,IAAA,UAClC,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,sBACd,IAAA,EAAM,OAAA,CAAQ,IAAA,QAAY,0BAAA,GAC1B,KAAA,EAAO,sBAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,wBACd,IAAA,GAAO,KAAA,EAAO,MAAA,cACd,KAAA,EAAO,MAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,CACd,IAAA,UACA,KAAA,EAAO,KAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\nimport type {\n IntrinsicFallbackProps,\n KnownIntrinsicElementProps,\n Props,\n} from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: symbol,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\nimport type {\n IntrinsicFallbackProps,\n KnownIntrinsicElementProps,\n Props,\n} from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElementType,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: symbol,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as JSXElementType,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Re-export Fragment for JSX\nexport { Fragment };\nexport type { JSXComponent, JSXElement, JSXElementType } from './types';\n"],"mappings":";;;;;AAsBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,CAAC;CAEnC,KAAK,MAAM,SAAS,OAAO,OAAO,eAAe,GAC/C,kBAAkB,KAAK;CAGzB,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAqB;CAC/C,IAAI,MAAM,QAAQ,MAAM,QAAQ,GAC9B,OAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;CAChB,CAAC;CAGH,OAAO;AACT;AAgCA,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,KAAK;CAChD,MAAM,gBAAgB,mBAClB,mBAAmB,eAAe,IAClC;CAEJ,IAAI,wBAAwB,IAAI,GAC9B,OAAO,KAAK,aAAa;CAG3B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;CACd;AACF"}
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntrinsicFallbackProps, KnownIntrinsicElementProps, Props } from "./common/props.js";
|
|
2
|
-
import { Fragment, JSXElement } from "./common/jsx.js";
|
|
2
|
+
import { Fragment, JSXComponent, JSXElement, JSXElementType } from "./common/jsx.js";
|
|
3
3
|
import { EagerControlPrimitive } from "./common/control.js";
|
|
4
4
|
//#region src/jsx/jsx-runtime.d.ts
|
|
5
5
|
declare function jsxDEV(type: EagerControlPrimitive, props: Props | null, key?: string | number, isStaticChildren?: boolean): unknown;
|
|
@@ -18,5 +18,5 @@ declare function jsxs<TTag extends string>(type: Exclude<TTag, keyof KnownIntrin
|
|
|
18
18
|
declare function jsxs<TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number): JSXElement;
|
|
19
19
|
declare function jsxs(type: symbol, props: Props | null, key?: string | number): JSXElement;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { Fragment, type JSXElement, jsx, jsxDEV, jsxs };
|
|
21
|
+
export { Fragment, type JSXComponent, type JSXElement, type JSXElementType, jsx, jsxDEV, jsxs };
|
|
22
22
|
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"mappings":";;;;iBA4CgB,MAAA,CACd,IAAA,EAAM,qBAAA,EACN,KAAA,EAAO,KAAK,SACZ,GAAA,oBACA,gBAAA;AAAA,iBAEc,MAAA,oBAA0B,0BAAA,EACxC,IAAA,EAAM,IAAA,EACN,KAAA,EAAO,0BAAA,CAA2B,IAAA,UAClC,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,sBACd,IAAA,EAAM,OAAA,CAAQ,IAAA,QAAY,0BAAA,GAC1B,KAAA,EAAO,sBAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,wBACd,IAAA,GAAO,KAAA,EAAO,MAAA,cACd,KAAA,EAAO,MAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAA;AAAA,iBACa,MAAA,CACd,IAAA,UACA,KAAA,EAAO,KAAA,SACP,GAAA,oBACA,gBAAA,aACC,UAAU;AAAA,iBAyBG,GAAA,CACd,IAAA,EAAM,qBAAA,EACN,KAAA,EAAO,KAAK,SACZ,GAAA;AAAA,iBAEc,GAAA,oBAAuB,0BAAA,EACrC,IAAA,EAAM,IAAA,EACN,KAAA,EAAO,0BAAA,CAA2B,IAAA,UAClC,GAAA,qBACC,UAAA;AAAA,iBACa,GAAA,sBACd,IAAA,EAAM,OAAA,CAAQ,IAAA,QAAY,0BAAA,GAC1B,KAAA,EAAO,sBAAA,SACP,GAAA,qBACC,UAAA;AAAA,iBACa,GAAA,wBACd,IAAA,GAAO,KAAA,EAAO,MAAA,cACd,KAAA,EAAO,MAAA,SACP,GAAA,qBACC,UAAA;AAAA,iBACa,GAAA,CACd,IAAA,UACA,KAAA,EAAO,KAAA,SACP,GAAA,qBACC,UAAU;AAAA,iBASG,IAAA,CACd,IAAA,EAAM,qBAAA,EACN,KAAA,EAAO,KAAK,SACZ,GAAA;AAAA,iBAEc,IAAA,oBAAwB,0BAAA,EACtC,IAAA,EAAM,IAAA,EACN,KAAA,EAAO,0BAAA,CAA2B,IAAA,UAClC,GAAA,qBACC,UAAA;AAAA,iBACa,IAAA,sBACd,IAAA,EAAM,OAAA,CAAQ,IAAA,QAAY,0BAAA,GAC1B,KAAA,EAAO,sBAAA,SACP,GAAA,qBACC,UAAA;AAAA,iBACa,IAAA,wBACd,IAAA,GAAO,KAAA,EAAO,MAAA,cACd,KAAA,EAAO,MAAA,SACP,GAAA,qBACC,UAAA;AAAA,iBACa,IAAA,CACd,IAAA,UACA,KAAA,EAAO,KAAA,SACP,GAAA,qBACC,UAAU"}
|
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime factory\n * Same element shape as production runtime.\n */\n\nimport type {\n IntrinsicFallbackProps,\n KnownIntrinsicElementProps,\n Props,\n} from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: symbol,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime factory\n * Same element shape as production runtime.\n */\n\nimport type {\n IntrinsicFallbackProps,\n KnownIntrinsicElementProps,\n Props,\n} from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElementType,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: symbol,\n props: Props | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as JSXElementType,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Production-style helpers: alias to the DEV factory for now\nexport function jsx(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number\n): unknown;\nexport function jsx<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number\n): JSXElement;\nexport function jsx<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number\n): JSXElement;\nexport function jsx<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number\n): JSXElement;\nexport function jsx(\n type: symbol,\n props: Props | null,\n key?: string | number\n): JSXElement;\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n return jsxDEV(type as never, props, key);\n}\n\nexport function jsxs(\n type: EagerControlPrimitive,\n props: Props | null,\n key?: string | number\n): unknown;\nexport function jsxs<TTag extends keyof KnownIntrinsicElementProps>(\n type: TTag,\n props: KnownIntrinsicElementProps[TTag] | null,\n key?: string | number\n): JSXElement;\nexport function jsxs<TTag extends string>(\n type: Exclude<TTag, keyof KnownIntrinsicElementProps>,\n props: IntrinsicFallbackProps | null,\n key?: string | number\n): JSXElement;\nexport function jsxs<TProps extends object>(\n type: (props: TProps) => unknown,\n props: TProps | null,\n key?: string | number\n): JSXElement;\nexport function jsxs(\n type: symbol,\n props: Props | null,\n key?: string | number\n): JSXElement;\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n const normalizedProps = markStaticChildren(annotatePropsUsage(props));\n\n if (isEagerControlPrimitive(type)) {\n return type(normalizedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as JSXElementType,\n props: normalizedProps,\n key: key ?? null,\n } as JSXElement;\n}\n\n// Re-export Fragment for JSX.\nexport { Fragment };\nexport type { JSXComponent, JSXElement, JSXElementType } from './types';\n"],"mappings":";;;;;AAuBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,CAAC;CAEnC,KAAK,MAAM,SAAS,OAAO,OAAO,eAAe,GAC/C,kBAAkB,KAAK;CAGzB,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAqB;CAC/C,IAAI,MAAM,QAAQ,MAAM,QAAQ,GAC9B,OAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;CAChB,CAAC;CAGH,OAAO;AACT;AAgCA,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,KAAK;CAChD,MAAM,gBAAgB,mBAClB,mBAAmB,eAAe,IAClC;CAEJ,IAAI,wBAAwB,IAAI,GAC9B,OAAO,KAAK,aAAa;CAG3B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;CACd;AACF;AA4BA,SAAgB,IACd,MACA,OACA,KACA;CACA,OAAO,OAAO,MAAe,OAAO,GAAG;AACzC;AA2BA,SAAgB,KACd,MACA,OACA,KACA;CACA,MAAM,kBAAkB,mBAAmB,mBAAmB,KAAK,CAAC;CAEpE,IAAI,wBAAwB,IAAI,GAC9B,OAAO,KAAK,eAAe;CAG7B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;CACd;AACF"}
|
package/dist/jsx-runtime2.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-host.js","names":[],"sources":["../../src/renderer/component-host.ts"],"sourcesContent":["import { isPromiseLike } from '../common/promise';\nimport type { Props } from '../common/props';\nimport {\n captureInlineRenderSnapshot,\n cleanupComponent,\n createComponentInstance,\n getCurrentInstance,\n mountInstanceInline,\n renderComponentInline,\n warnUnusedStateReads,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component-contracts';\nimport {\n getCurrentContextFrame,\n getVNodeContextFrame,\n markVNodeTreeWithContextFrame,\n withContext,\n type ContextFrame,\n} from '../runtime/context';\nimport { materializeKey } from './attributes';\nimport { normalizeComponentChildren } from './child-shape';\nimport {\n cleanupDetachedComponentHost,\n pruneComponentHostInstances,\n} from './component-host-cleanup';\nimport {\n getRendererDOMHost,\n type ElementWithContext,\n type InstanceHostElement,\n} from './dom-host';\nimport {\n findHostInstanceByType,\n getVNodeComponentInstance,\n inheritComponentCleanupStrict,\n inheritComponentKey,\n isRouteRootComponentVNode,\n nextComponentInstanceId,\n setVNodeComponentInstance,\n} from './component-host-instances';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport { tagNamesEqualIgnoreCase } from './utils';\nexport {\n findHostInstanceByType,\n inheritComponentCleanupStrict,\n inheritComponentKey,\n isRouteRootComponentVNode,\n nextComponentInstanceId,\n} from './component-host-instances';\nfunction materializeComponentResultNode(\n childInstance: ComponentInstance,\n result: unknown,\n parentNamespace?: string\n): Node {\n const dom = getRendererDOMHost().createDOMNode(result, parentNamespace);\n\n if (dom instanceof Element) {\n mountInstanceInline(childInstance, dom);\n return dom;\n }\n\n if (!dom) {\n const placeholder = document.createComment('');\n try {\n (\n placeholder as Comment & { __ASKR_INSTANCE?: ComponentInstance }\n ).__ASKR_INSTANCE = childInstance;\n } catch {\n // Ignore placeholder metadata failures.\n }\n childInstance._placeholder = placeholder;\n mountInstanceInline(childInstance, null);\n return placeholder;\n }\n\n const host = document.createElement('div') as InstanceHostElement;\n host.appendChild(dom);\n host.__ASKR_WRAPPER_HOST = true;\n mountInstanceInline(childInstance, host);\n return host;\n}\n\nexport function resolveNestedComponentResult(\n result: unknown,\n snapshot: ContextFrame | null,\n parentInstance: ComponentInstance | null\n): VNode {\n let currentResult = result as VNode;\n let activeSnapshot = snapshot;\n let depth = 0;\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n const nestedInstance = createComponentInstance(\n nextComponentInstanceId(),\n currentResult.type as ComponentFunction,\n ((currentResult as DOMElement).props ?? {}) as Props,\n null\n );\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.parentInstance = parentInstance;\n nestedInstance.portalScope =\n parentInstance?.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n cleanupComponent(nestedInstance);\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = nextResult as VNode;\n depth += 1;\n }\n\n return currentResult;\n}\n\nfunction resolveHostNestedComponentResult(\n host: InstanceHostElement,\n retainedInstance: ComponentInstance,\n result: unknown,\n snapshot: ContextFrame | null,\n retainedHostInstances?: Iterable<ComponentInstance>\n): VNode {\n let currentResult = result as VNode;\n let activeSnapshot = snapshot;\n let depth = 0;\n const retainedInstances = new Set<ComponentInstance>([retainedInstance]);\n if (retainedHostInstances) {\n for (const instance of retainedHostInstances) {\n retainedInstances.add(instance);\n }\n }\n const createdInstances: ComponentInstance[] = [];\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n let nestedInstance = findHostInstanceByType(\n host,\n currentResult.type as ComponentFunction\n );\n const hadNestedInstance = !!nestedInstance;\n\n if (!nestedInstance) {\n nestedInstance = createComponentInstance(\n nextComponentInstanceId(),\n currentResult.type as ComponentFunction,\n ((currentResult as DOMElement).props ?? {}) as Props,\n null\n );\n createdInstances.push(nestedInstance);\n }\n\n if (hadNestedInstance) {\n captureInlineRenderSnapshot(nestedInstance);\n }\n\n setVNodeComponentInstance(currentResult, nestedInstance);\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.parentInstance = retainedInstance;\n nestedInstance.portalScope =\n retainedInstance.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n nestedInstance.props =\n (((currentResult as DOMElement).props ?? {}) as Props) || {};\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n retainedInstances.add(nestedInstance);\n warnUnusedStateReads(nestedInstance);\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = markVNodeTreeWithContextFrame(\n nextResult,\n activeSnapshot\n ) as VNode;\n depth += 1;\n }\n\n const previousInstances = host.__ASKR_INSTANCES ?? [];\n for (const instance of previousInstances) {\n if (!retainedInstances.has(instance)) {\n cleanupComponent(instance);\n }\n }\n\n const nextHostInstances = previousInstances.filter((instance) =>\n retainedInstances.has(instance)\n );\n for (const instance of retainedInstances) {\n if (instance.target === host && !nextHostInstances.includes(instance)) {\n nextHostInstances.push(instance);\n }\n }\n\n host.__ASKR_INSTANCES = nextHostInstances;\n host.__ASKR_INSTANCE = host.__ASKR_INSTANCES[0] ?? retainedInstance;\n\n for (const instance of createdInstances) {\n mountInstanceInline(instance, host);\n }\n\n return currentResult;\n}\n\nfunction resolveWrapperHostResult(\n host: InstanceHostElement,\n result: unknown,\n snapshot: ContextFrame | null\n): unknown {\n let currentResult = result;\n let activeSnapshot = snapshot;\n let depth = 0;\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n const nestedInstance = findHostInstanceByType(\n host,\n currentResult.type as ComponentFunction\n );\n\n if (!nestedInstance) {\n break;\n }\n\n captureInlineRenderSnapshot(nestedInstance);\n\n nestedInstance.props =\n (((currentResult as DOMElement).props ?? {}) as Props) || {};\n nestedInstance.parentInstance = getCurrentInstance();\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.portalScope =\n getCurrentInstance()?.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n warnUnusedStateReads(nestedInstance);\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = nextResult;\n depth += 1;\n }\n\n return markVNodeTreeWithContextFrame(currentResult, activeSnapshot);\n}\n\nexport function syncComponentElement(\n currentDom: Node | null,\n node: ElementWithContext,\n type: ComponentFunction,\n props: Record<string, unknown>,\n parentNamespace?: string,\n forceChildrenUpdate = false,\n retainedHostInstances?: Iterable<ComponentInstance>\n): Node | null {\n const existingHost =\n currentDom instanceof Element ? (currentDom as InstanceHostElement) : null;\n const existingInstance = existingHost\n ? findHostInstanceByType(existingHost, type)\n : null;\n if (!existingHost) {\n return null;\n }\n\n const domHost = getRendererDOMHost();\n\n if (!existingInstance || existingInstance.fn !== type) {\n const snapshot =\n getVNodeContextFrame(node) || getCurrentContextFrame() || null;\n const hydrationInstance = createComponentInstance(\n nextComponentInstanceId(),\n type,\n props || {},\n existingHost\n );\n hydrationInstance.isRoot = isRouteRootComponentVNode(node);\n hydrationInstance.portalScope =\n getCurrentInstance()?.portalScope ?? hydrationInstance.portalScope;\n inheritComponentCleanupStrict(hydrationInstance);\n\n setVNodeComponentInstance(node, hydrationInstance);\n\n if (snapshot) {\n hydrationInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(hydrationInstance)\n );\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n const scopedResult = markVNodeTreeWithContextFrame(\n result,\n snapshot ?? null\n );\n\n if (\n scopedResult &&\n typeof scopedResult === 'object' &&\n 'type' in (scopedResult as DOMElement) &&\n typeof (scopedResult as DOMElement).type === 'string' &&\n tagNamesEqualIgnoreCase(\n existingHost.tagName,\n (scopedResult as DOMElement).type as string\n )\n ) {\n pruneComponentHostInstances(\n existingHost,\n retainedHostInstances\n ? [hydrationInstance, ...retainedHostInstances]\n : [hydrationInstance]\n );\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(scopedResult as DOMElement, node),\n true,\n forceChildrenUpdate || hydrationInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n mountInstanceInline(hydrationInstance, existingHost);\n itemInstanceHydrationComplete(existingHost);\n warnUnusedStateReads(hydrationInstance);\n return existingHost;\n }\n\n const resolvedResult = resolveHostNestedComponentResult(\n existingHost,\n hydrationInstance,\n scopedResult,\n snapshot ?? null,\n retainedHostInstances\n );\n if (\n _isDOMElement(resolvedResult) &&\n typeof resolvedResult.type === 'string' &&\n tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)\n ) {\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(resolvedResult, node),\n true,\n forceChildrenUpdate || hydrationInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n mountInstanceInline(hydrationInstance, existingHost);\n itemInstanceHydrationComplete(existingHost);\n warnUnusedStateReads(hydrationInstance);\n return existingHost;\n }\n\n const nextDom = materializeComponentResultNode(\n hydrationInstance,\n scopedResult,\n parentNamespace\n );\n\n if (nextDom instanceof Element) {\n materializeKey(nextDom, node, props);\n }\n\n if (nextDom !== existingHost && existingHost.parentNode) {\n existingHost.parentNode.replaceChild(nextDom, existingHost);\n cleanupDetachedComponentHost(existingHost, hydrationInstance);\n }\n\n warnUnusedStateReads(hydrationInstance);\n return nextDom;\n }\n\n const snapshot =\n getVNodeContextFrame(node) ||\n getCurrentContextFrame() ||\n existingInstance.ownerFrame ||\n null;\n captureInlineRenderSnapshot(existingInstance);\n existingInstance.props = props || {};\n existingInstance.isRoot = isRouteRootComponentVNode(node);\n existingInstance.portalScope =\n getCurrentInstance()?.portalScope ?? existingInstance.portalScope;\n inheritComponentCleanupStrict(existingInstance);\n\n if (snapshot) {\n existingInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(existingInstance)\n );\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);\n\n if (existingHost.__ASKR_WRAPPER_HOST) {\n const wrapperResult = resolveWrapperHostResult(\n existingHost,\n scopedResult,\n snapshot ?? null\n );\n domHost.updateElementChildren(\n existingHost,\n normalizeComponentChildren(wrapperResult) as VNode[]\n );\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n if (\n scopedResult &&\n typeof scopedResult === 'object' &&\n 'type' in (scopedResult as DOMElement) &&\n typeof (scopedResult as DOMElement).type === 'string' &&\n tagNamesEqualIgnoreCase(\n existingHost.tagName,\n (scopedResult as DOMElement).type as string\n )\n ) {\n pruneComponentHostInstances(\n existingHost,\n retainedHostInstances\n ? [existingInstance, ...retainedHostInstances]\n : [existingInstance]\n );\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(scopedResult as DOMElement, node),\n true,\n forceChildrenUpdate || existingInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n const resolvedResult = resolveHostNestedComponentResult(\n existingHost,\n existingInstance,\n scopedResult,\n snapshot ?? null,\n retainedHostInstances\n );\n if (\n _isDOMElement(resolvedResult) &&\n typeof resolvedResult.type === 'string' &&\n tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)\n ) {\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(resolvedResult, node),\n true,\n forceChildrenUpdate || existingInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n const nextDom = materializeComponentResultNode(\n existingInstance,\n scopedResult,\n parentNamespace\n );\n\n if (nextDom instanceof Element) {\n materializeKey(nextDom, node, props);\n }\n\n if (nextDom !== existingHost && existingHost.parentNode) {\n existingHost.parentNode.replaceChild(nextDom, existingHost);\n cleanupDetachedComponentHost(existingHost, existingInstance);\n }\n\n warnUnusedStateReads(existingInstance);\n return nextDom;\n}\n\nfunction itemInstanceHydrationComplete(host: InstanceHostElement): void {\n const instance = host.__ASKR_INSTANCE;\n if (instance) {\n const scope = (\n instance as unknown as { scope?: { hydrationPending?: boolean } }\n ).scope;\n if (scope) {\n scope.hydrationPending = false;\n }\n }\n}\n\nexport function createComponentElement(\n node: ElementWithContext,\n type: (props: never) => unknown,\n props: Record<string, unknown>,\n parentNamespace?: string\n): Node {\n const frame = getVNodeContextFrame(node);\n const snapshot = frame || getCurrentContextFrame();\n\n const componentFn = type as unknown as (props: Props) => unknown;\n const isAsync = componentFn.constructor.name === 'AsyncFunction';\n\n if (isAsync) {\n throw new Error(\n 'Async components are not supported. Use resource() for async work.'\n );\n }\n\n let childInstance = getVNodeComponentInstance(node);\n const hadChildInstance = !!childInstance;\n if (!childInstance) {\n childInstance = createComponentInstance(\n nextComponentInstanceId(),\n componentFn as ComponentFunction,\n props || {},\n null\n );\n setVNodeComponentInstance(node, childInstance);\n }\n\n if (hadChildInstance) {\n captureInlineRenderSnapshot(childInstance);\n }\n\n childInstance.portalScope =\n getCurrentInstance()?.portalScope ?? childInstance.portalScope;\n childInstance.parentInstance = getCurrentInstance();\n childInstance.props = props || {};\n childInstance.isRoot = isRouteRootComponentVNode(node);\n inheritComponentCleanupStrict(childInstance);\n\n if (snapshot) {\n childInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(childInstance)\n );\n\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);\n\n const dom = withContext(snapshot, () =>\n materializeComponentResultNode(childInstance, scopedResult, parentNamespace)\n );\n\n warnUnusedStateReads(childInstance);\n\n if (dom instanceof Element) {\n materializeKey(dom, node, props);\n }\n return dom;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,SAAS,+BACP,eACA,QACA,iBACM;CACN,MAAM,MAAM,mBAAmB,CAAC,CAAC,cAAc,QAAQ,eAAe;CAEtE,IAAI,eAAe,SAAS;EAC1B,oB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M,YAAY,gBACtB,+BAA+B,eAAe,cAAc,eAAe,CAC7E;CAEA,qBAAqB,aAAa;CAElC,IAAI,eAAe,SACjB,eAAe,KAAK,MAAM,KAAK;CAEjC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"component-host.js","names":[],"sources":["../../src/renderer/component-host.ts"],"sourcesContent":["import { isPromiseLike } from '../common/promise';\nimport type { Props } from '../common/props';\nimport {\n captureInlineRenderSnapshot,\n cleanupComponent,\n createComponentInstance,\n getCurrentInstance,\n mountInstanceInline,\n renderComponentInline,\n warnUnusedStateReads,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component-contracts';\nimport {\n getCurrentContextFrame,\n getVNodeContextFrame,\n markVNodeTreeWithContextFrame,\n withContext,\n type ContextFrame,\n} from '../runtime/context';\nimport { materializeKey } from './attributes';\nimport { normalizeComponentChildren } from './child-shape';\nimport {\n cleanupDetachedComponentHost,\n pruneComponentHostInstances,\n} from './component-host-cleanup';\nimport {\n getRendererDOMHost,\n type ElementWithContext,\n type InstanceHostElement,\n} from './dom-host';\nimport {\n findHostInstanceByType,\n getVNodeComponentInstance,\n inheritComponentCleanupStrict,\n inheritComponentKey,\n isRouteRootComponentVNode,\n nextComponentInstanceId,\n setVNodeComponentInstance,\n} from './component-host-instances';\nimport { _isDOMElement, type DOMElement, type JSXComponent, type VNode } from './types';\nimport { tagNamesEqualIgnoreCase } from './utils';\nexport {\n findHostInstanceByType,\n inheritComponentCleanupStrict,\n inheritComponentKey,\n isRouteRootComponentVNode,\n nextComponentInstanceId,\n} from './component-host-instances';\nfunction materializeComponentResultNode(\n childInstance: ComponentInstance,\n result: unknown,\n parentNamespace?: string\n): Node {\n const dom = getRendererDOMHost().createDOMNode(result, parentNamespace);\n\n if (dom instanceof Element) {\n mountInstanceInline(childInstance, dom);\n return dom;\n }\n\n if (!dom) {\n const placeholder = document.createComment('');\n try {\n (\n placeholder as Comment & { __ASKR_INSTANCE?: ComponentInstance }\n ).__ASKR_INSTANCE = childInstance;\n } catch {\n // Ignore placeholder metadata failures.\n }\n childInstance._placeholder = placeholder;\n mountInstanceInline(childInstance, null);\n return placeholder;\n }\n\n const host = document.createElement('div') as InstanceHostElement;\n host.appendChild(dom);\n host.__ASKR_WRAPPER_HOST = true;\n mountInstanceInline(childInstance, host);\n return host;\n}\n\nexport function resolveNestedComponentResult(\n result: unknown,\n snapshot: ContextFrame | null,\n parentInstance: ComponentInstance | null\n): VNode {\n let currentResult = result as VNode;\n let activeSnapshot = snapshot;\n let depth = 0;\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n const nestedInstance = createComponentInstance(\n nextComponentInstanceId(),\n currentResult.type as ComponentFunction,\n ((currentResult as DOMElement).props ?? {}) as Props,\n null\n );\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.parentInstance = parentInstance;\n nestedInstance.portalScope =\n parentInstance?.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n cleanupComponent(nestedInstance);\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = nextResult as VNode;\n depth += 1;\n }\n\n return currentResult;\n}\n\nfunction resolveHostNestedComponentResult(\n host: InstanceHostElement,\n retainedInstance: ComponentInstance,\n result: unknown,\n snapshot: ContextFrame | null,\n retainedHostInstances?: Iterable<ComponentInstance>\n): VNode {\n let currentResult = result as VNode;\n let activeSnapshot = snapshot;\n let depth = 0;\n const retainedInstances = new Set<ComponentInstance>([retainedInstance]);\n if (retainedHostInstances) {\n for (const instance of retainedHostInstances) {\n retainedInstances.add(instance);\n }\n }\n const createdInstances: ComponentInstance[] = [];\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n let nestedInstance = findHostInstanceByType(\n host,\n currentResult.type as ComponentFunction\n );\n const hadNestedInstance = !!nestedInstance;\n\n if (!nestedInstance) {\n nestedInstance = createComponentInstance(\n nextComponentInstanceId(),\n currentResult.type as ComponentFunction,\n ((currentResult as DOMElement).props ?? {}) as Props,\n null\n );\n createdInstances.push(nestedInstance);\n }\n\n if (hadNestedInstance) {\n captureInlineRenderSnapshot(nestedInstance);\n }\n\n setVNodeComponentInstance(currentResult, nestedInstance);\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.parentInstance = retainedInstance;\n nestedInstance.portalScope =\n retainedInstance.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n nestedInstance.props =\n (((currentResult as DOMElement).props ?? {}) as Props) || {};\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n retainedInstances.add(nestedInstance);\n warnUnusedStateReads(nestedInstance);\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = markVNodeTreeWithContextFrame(\n nextResult,\n activeSnapshot\n ) as VNode;\n depth += 1;\n }\n\n const previousInstances = host.__ASKR_INSTANCES ?? [];\n for (const instance of previousInstances) {\n if (!retainedInstances.has(instance)) {\n cleanupComponent(instance);\n }\n }\n\n const nextHostInstances = previousInstances.filter((instance) =>\n retainedInstances.has(instance)\n );\n for (const instance of retainedInstances) {\n if (instance.target === host && !nextHostInstances.includes(instance)) {\n nextHostInstances.push(instance);\n }\n }\n\n host.__ASKR_INSTANCES = nextHostInstances;\n host.__ASKR_INSTANCE = host.__ASKR_INSTANCES[0] ?? retainedInstance;\n\n for (const instance of createdInstances) {\n mountInstanceInline(instance, host);\n }\n\n return currentResult;\n}\n\nfunction resolveWrapperHostResult(\n host: InstanceHostElement,\n result: unknown,\n snapshot: ContextFrame | null\n): unknown {\n let currentResult = result;\n let activeSnapshot = snapshot;\n let depth = 0;\n\n while (\n _isDOMElement(currentResult) &&\n typeof currentResult.type === 'function' &&\n depth < 16\n ) {\n const nestedSnapshot =\n getVNodeContextFrame(currentResult) ?? activeSnapshot;\n const nestedInstance = findHostInstanceByType(\n host,\n currentResult.type as ComponentFunction\n );\n\n if (!nestedInstance) {\n break;\n }\n\n captureInlineRenderSnapshot(nestedInstance);\n\n nestedInstance.props =\n (((currentResult as DOMElement).props ?? {}) as Props) || {};\n nestedInstance.parentInstance = getCurrentInstance();\n nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);\n nestedInstance.portalScope =\n getCurrentInstance()?.portalScope ?? nestedInstance.portalScope;\n inheritComponentCleanupStrict(nestedInstance);\n\n if (nestedSnapshot) {\n nestedInstance.ownerFrame = nestedSnapshot;\n }\n\n const nextResult = withContext(nestedSnapshot ?? null, () =>\n renderComponentInline(nestedInstance)\n );\n\n if (isPromiseLike(nextResult)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n warnUnusedStateReads(nestedInstance);\n activeSnapshot = nestedSnapshot ?? null;\n currentResult = nextResult;\n depth += 1;\n }\n\n return markVNodeTreeWithContextFrame(currentResult, activeSnapshot);\n}\n\nexport function syncComponentElement(\n currentDom: Node | null,\n node: ElementWithContext,\n type: ComponentFunction,\n props: Record<string, unknown>,\n parentNamespace?: string,\n forceChildrenUpdate = false,\n retainedHostInstances?: Iterable<ComponentInstance>\n): Node | null {\n const existingHost =\n currentDom instanceof Element ? (currentDom as InstanceHostElement) : null;\n const existingInstance = existingHost\n ? findHostInstanceByType(existingHost, type)\n : null;\n if (!existingHost) {\n return null;\n }\n\n const domHost = getRendererDOMHost();\n\n if (!existingInstance || existingInstance.fn !== type) {\n const snapshot =\n getVNodeContextFrame(node) || getCurrentContextFrame() || null;\n const hydrationInstance = createComponentInstance(\n nextComponentInstanceId(),\n type,\n props || {},\n existingHost\n );\n hydrationInstance.isRoot = isRouteRootComponentVNode(node);\n hydrationInstance.portalScope =\n getCurrentInstance()?.portalScope ?? hydrationInstance.portalScope;\n inheritComponentCleanupStrict(hydrationInstance);\n\n setVNodeComponentInstance(node, hydrationInstance);\n\n if (snapshot) {\n hydrationInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(hydrationInstance)\n );\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n const scopedResult = markVNodeTreeWithContextFrame(\n result,\n snapshot ?? null\n );\n\n if (\n scopedResult &&\n typeof scopedResult === 'object' &&\n 'type' in (scopedResult as DOMElement) &&\n typeof (scopedResult as DOMElement).type === 'string' &&\n tagNamesEqualIgnoreCase(\n existingHost.tagName,\n (scopedResult as DOMElement).type as string\n )\n ) {\n pruneComponentHostInstances(\n existingHost,\n retainedHostInstances\n ? [hydrationInstance, ...retainedHostInstances]\n : [hydrationInstance]\n );\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(scopedResult as DOMElement, node),\n true,\n forceChildrenUpdate || hydrationInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n mountInstanceInline(hydrationInstance, existingHost);\n itemInstanceHydrationComplete(existingHost);\n warnUnusedStateReads(hydrationInstance);\n return existingHost;\n }\n\n const resolvedResult = resolveHostNestedComponentResult(\n existingHost,\n hydrationInstance,\n scopedResult,\n snapshot ?? null,\n retainedHostInstances\n );\n if (\n _isDOMElement(resolvedResult) &&\n typeof resolvedResult.type === 'string' &&\n tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)\n ) {\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(resolvedResult, node),\n true,\n forceChildrenUpdate || hydrationInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n mountInstanceInline(hydrationInstance, existingHost);\n itemInstanceHydrationComplete(existingHost);\n warnUnusedStateReads(hydrationInstance);\n return existingHost;\n }\n\n const nextDom = materializeComponentResultNode(\n hydrationInstance,\n scopedResult,\n parentNamespace\n );\n\n if (nextDom instanceof Element) {\n materializeKey(nextDom, node, props);\n }\n\n if (nextDom !== existingHost && existingHost.parentNode) {\n existingHost.parentNode.replaceChild(nextDom, existingHost);\n cleanupDetachedComponentHost(existingHost, hydrationInstance);\n }\n\n warnUnusedStateReads(hydrationInstance);\n return nextDom;\n }\n\n const snapshot =\n getVNodeContextFrame(node) ||\n getCurrentContextFrame() ||\n existingInstance.ownerFrame ||\n null;\n captureInlineRenderSnapshot(existingInstance);\n existingInstance.props = props || {};\n existingInstance.isRoot = isRouteRootComponentVNode(node);\n existingInstance.portalScope =\n getCurrentInstance()?.portalScope ?? existingInstance.portalScope;\n inheritComponentCleanupStrict(existingInstance);\n\n if (snapshot) {\n existingInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(existingInstance)\n );\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);\n\n if (existingHost.__ASKR_WRAPPER_HOST) {\n const wrapperResult = resolveWrapperHostResult(\n existingHost,\n scopedResult,\n snapshot ?? null\n );\n domHost.updateElementChildren(\n existingHost,\n normalizeComponentChildren(wrapperResult) as VNode[]\n );\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n if (\n scopedResult &&\n typeof scopedResult === 'object' &&\n 'type' in (scopedResult as DOMElement) &&\n typeof (scopedResult as DOMElement).type === 'string' &&\n tagNamesEqualIgnoreCase(\n existingHost.tagName,\n (scopedResult as DOMElement).type as string\n )\n ) {\n pruneComponentHostInstances(\n existingHost,\n retainedHostInstances\n ? [existingInstance, ...retainedHostInstances]\n : [existingInstance]\n );\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(scopedResult as DOMElement, node),\n true,\n forceChildrenUpdate || existingInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n const resolvedResult = resolveHostNestedComponentResult(\n existingHost,\n existingInstance,\n scopedResult,\n snapshot ?? null,\n retainedHostInstances\n );\n if (\n _isDOMElement(resolvedResult) &&\n typeof resolvedResult.type === 'string' &&\n tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)\n ) {\n withContext(snapshot, () => {\n domHost.updateElementFromVnode(\n existingHost,\n inheritComponentKey(resolvedResult, node),\n true,\n forceChildrenUpdate || existingInstance.mounted === false\n );\n materializeKey(existingHost, node, props);\n });\n warnUnusedStateReads(existingInstance);\n return existingHost;\n }\n\n const nextDom = materializeComponentResultNode(\n existingInstance,\n scopedResult,\n parentNamespace\n );\n\n if (nextDom instanceof Element) {\n materializeKey(nextDom, node, props);\n }\n\n if (nextDom !== existingHost && existingHost.parentNode) {\n existingHost.parentNode.replaceChild(nextDom, existingHost);\n cleanupDetachedComponentHost(existingHost, existingInstance);\n }\n\n warnUnusedStateReads(existingInstance);\n return nextDom;\n}\n\nfunction itemInstanceHydrationComplete(host: InstanceHostElement): void {\n const instance = host.__ASKR_INSTANCE;\n if (instance) {\n const scope = (\n instance as unknown as { scope?: { hydrationPending?: boolean } }\n ).scope;\n if (scope) {\n scope.hydrationPending = false;\n }\n }\n}\n\nexport function createComponentElement(\n node: ElementWithContext,\n type: JSXComponent,\n props: Record<string, unknown>,\n parentNamespace?: string\n): Node {\n const frame = getVNodeContextFrame(node);\n const snapshot = frame || getCurrentContextFrame();\n\n const componentFn = type as unknown as (props: Props) => unknown;\n const isAsync = componentFn.constructor.name === 'AsyncFunction';\n\n if (isAsync) {\n throw new Error(\n 'Async components are not supported. Use resource() for async work.'\n );\n }\n\n let childInstance = getVNodeComponentInstance(node);\n const hadChildInstance = !!childInstance;\n if (!childInstance) {\n childInstance = createComponentInstance(\n nextComponentInstanceId(),\n componentFn as ComponentFunction,\n props || {},\n null\n );\n setVNodeComponentInstance(node, childInstance);\n }\n\n if (hadChildInstance) {\n captureInlineRenderSnapshot(childInstance);\n }\n\n childInstance.portalScope =\n getCurrentInstance()?.portalScope ?? childInstance.portalScope;\n childInstance.parentInstance = getCurrentInstance();\n childInstance.props = props || {};\n childInstance.isRoot = isRouteRootComponentVNode(node);\n inheritComponentCleanupStrict(childInstance);\n\n if (snapshot) {\n childInstance.ownerFrame = snapshot;\n }\n\n const result = withContext(snapshot, () =>\n renderComponentInline(childInstance)\n );\n\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n\n const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);\n\n const dom = withContext(snapshot, () =>\n materializeComponentResultNode(childInstance, scopedResult, parentNamespace)\n );\n\n warnUnusedStateReads(childInstance);\n\n if (dom instanceof Element) {\n materializeKey(dom, node, props);\n }\n return dom;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,SAAS,+BACP,eACA,QACA,iBACM;CACN,MAAM,MAAM,mBAAmB,CAAC,CAAC,cAAc,QAAQ,eAAe;CAEtE,IAAI,eAAe,SAAS;EAC1B,oBAAoB,eAAe,GAAG;EACtC,OAAO;CACT;CAEA,IAAI,CAAC,KAAK;EACR,MAAM,cAAc,SAAS,cAAc,EAAE;EAC7C,IAAI;GACF,YAEE,kBAAkB;EACtB,QAAQ,CAER;EACA,cAAc,eAAe;EAC7B,oBAAoB,eAAe,IAAI;EACvC,OAAO;CACT;CAEA,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,YAAY,GAAG;CACpB,KAAK,sBAAsB;CAC3B,oBAAoB,eAAe,IAAI;CACvC,OAAO;AACT;AAEA,SAAgB,6BACd,QACA,UACA,gBACO;CACP,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C;CACtE,MAAM,WAAW,KAAK;CACtB,IAAI,UAAU;EACZ,MAAM,QACJ,SACA;EACF,IAAI,OACF,MAAM,mBAAmB;CAE7B;AACF;AAEA,SAAgB,uBACd,MACA,MACA,OACA,iBACM;CAEN,MAAM,WADQ,qBAAqB,IAClB,KAAS,uBAAuB;CAEjD,MAAM,cAAc;CAGpB,IAFgB,YAAY,YAAY,SAAS,iBAG/C,MAAM,IAAI,MACR,oEACF;CAGF,IAAI,gBAAgB,0BAA0B,IAAI;CAClD,MAAM,mBAAmB,CAAC,CAAC;CAC3B,IAAI,CAAC,eAAe;EAClB,gBAAgB,wBACd,wBAAwB,GACxB,aACA,SAAS,CAAC,GACV,IACF;EACA,0BAA0B,MAAM,aAAa;CAC/C;CAEA,IAAI,kBACF,4BAA4B,aAAa;CAG3C,cAAc,cACZ,mBAAmB,CAAC,EAAE,eAAe,cAAc;CACrD,cAAc,iBAAiB,mBAAmB;CAClD,cAAc,QAAQ,SAAS,CAAC;CAChC,cAAc,SAAS,0BAA0B,IAAI;CACrD,8BAA8B,aAAa;CAE3C,IAAI,UACF,cAAc,aAAa;CAG7B,MAAM,SAAS,YAAY,gBACzB,sBAAsB,aAAa,CACrC;CAEA,IAAI,cAAc,MAAM,GACtB,MAAM,IAAI,MACR,2EACF;CAGF,MAAM,eAAe,8BAA8B,QAAQ,YAAY,IAAI;CAE3E,MAAM,MAAM,YAAY,gBACtB,+BAA+B,eAAe,cAAc,eAAe,CAC7E;CAEA,qBAAqB,aAAa;CAElC,IAAI,eAAe,SACjB,eAAe,KAAK,MAAM,KAAK;CAEjC,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-internal.js","names":[],"sources":["../../src/renderer/dom-internal.ts"],"sourcesContent":["import { logger } from '../dev/logger';\nimport { Fragment } from '../jsx/jsx-runtime';\nimport { isBenchMetricScopeActive, recordBenchCounter } from '../runtime/for';\nimport { __ERROR_BOUNDARY__, __FOR_BOUNDARY__ } from '../common/vnode';\nimport {\n applyStaticScalarPropsToElement,\n hasMatchingStaticProps,\n materializeKey,\n} from './attributes';\nimport {\n configureBoundaryDOMHost,\n createForBoundary,\n getControlBoundaryState,\n getDirectControlBoundaryVNode,\n registerControlBoundaryCommitOwner,\n} from './boundaries';\nimport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n} from './children';\nimport {\n maybeWarnMissingKeys,\n tryGetStaticCreateFastPathShape,\n} from './child-shape';\nimport {\n removeAllListeners,\n removeElementReactiveProps,\n teardownNodeSubtree,\n updateElementRef,\n} from './cleanup';\nimport { createComponentElement, syncComponentElement } from './component-host';\nimport { configureRendererDOMHost, type ElementWithContext } from './dom-host';\nimport {\n rendererReactiveChildDOMHost,\n updateElementChildren,\n updateUnkeyedChildren,\n} from './element-children';\nimport {\n createErrorBoundaryElement,\n type ErrorBoundaryVNode,\n} from './error-boundary-dom';\nimport { getRuntimeEnv } from './env';\nimport { createElementForNamespace, resolveChildNamespace } from './namespaces';\nimport {\n applyPropsToElement,\n hasTrackedElementPropBindings,\n syncElementPropBindings,\n} from './prop-bindings';\nimport { syncReactiveScalarChild } from './reactive-children';\nimport { runRetainedElementUpdate } from './retained-element-rollback';\nimport { canReuseStaticSubtree } from './static-reuse';\nimport { tryPatchStableForDirtyItem } from './stable-patch';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\n\nexport { createForBoundary, commitForBoundaryChildren } from './boundaries';\nexport { markReactivePropsDirtySource } from './prop-bindings';\nexport { setStaticChildSlotsCacheEnabled } from './static-reuse';\nexport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n};\nexport {\n syncComponentElement,\n updateElementChildren,\n updateUnkeyedChildren,\n tryPatchStableForDirtyItem,\n};\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\nfunction getHydrationSkipBoundary(el: Element): Element | null {\n return el.closest('[data-skip-hydrate=\"true\"]');\n}\n\nfunction isHydrationSkipped(el: Element): boolean {\n return getHydrationSkipBoundary(el) !== null;\n}\n\nfunction clearHydrationDeferredSubtree(el: Element): void {\n const boundary = getHydrationSkipBoundary(el);\n if (!boundary) return;\n if (boundary === el) {\n removeAllListeners(el);\n removeElementReactiveProps(el);\n }\n}\n\nexport function createDOMNode(\n node: unknown,\n parentNamespace?: string\n): Node | null {\n if (!IS_DOM_AVAILABLE) {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n logger.warn('[Askr] createDOMNode called in non-DOM environment');\n } catch {\n // ignore\n }\n }\n return null;\n }\n\n if (typeof node === 'string') {\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n return document.createTextNode(node);\n }\n if (typeof node === 'number') {\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n return document.createTextNode(String(node));\n }\n\n if (!node) {\n return null;\n }\n\n if (Array.isArray(node)) {\n maybeWarnMissingKeys(node);\n const fragment = document.createDocumentFragment();\n for (const child of node) {\n const dom = createDOMNode(child, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n return fragment;\n }\n\n if (typeof node === 'object' && node !== null && 'type' in node) {\n const type = (node as DOMElement).type;\n const props = ((node as DOMElement).props || {}) as Record<string, unknown>;\n\n if (typeof type === 'string') {\n return createIntrinsicElement(\n node as DOMElement,\n type,\n props,\n parentNamespace\n );\n }\n\n if (typeof type === 'function') {\n return createComponentElement(\n node as ElementWithContext,\n type as (props: never) => unknown,\n props,\n parentNamespace\n );\n }\n\n if (type === __FOR_BOUNDARY__) {\n return createForBoundary(node as DOMElement, props, parentNamespace);\n }\n\n if (type === __ERROR_BOUNDARY__) {\n return createErrorBoundaryElement(\n node as ErrorBoundaryVNode,\n props,\n parentNamespace\n );\n }\n\n if (\n typeof type === 'symbol' &&\n (type === Fragment || String(type) === 'Symbol(Fragment)')\n ) {\n return createFragmentElement(node as DOMElement, props, parentNamespace);\n }\n }\n\n return null;\n}\n\nfunction createIntrinsicElement(\n node: DOMElement,\n type: string,\n props: Record<string, unknown>,\n parentNamespace?: string\n): Element {\n const children = props.children ?? node.children;\n const elementNamespace = resolveChildNamespace(type, parentNamespace);\n const el = createElementForNamespace(type, parentNamespace);\n\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n\n materializeKey(el, node, props);\n\n const staticCreateFastPath = tryGetStaticCreateFastPathShape(props, children);\n\n if (staticCreateFastPath) {\n applyStaticScalarPropsToElement(el, props, type);\n if (staticCreateFastPath.textContent !== null) {\n el.textContent = staticCreateFastPath.textContent;\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n }\n return el;\n }\n\n applyPropsToElement(el, props, type, isHydrationSkipped);\n\n if (children !== null && children !== undefined) {\n const controlBoundaryVNode = getDirectControlBoundaryVNode(children);\n if (controlBoundaryVNode) {\n const controlState = getControlBoundaryState(controlBoundaryVNode);\n if (!controlState) {\n throw new Error(\n '[createIntrinsicElement] Control boundary missing internal state'\n );\n }\n registerControlBoundaryCommitOwner(el, controlState);\n }\n\n if (syncReactiveScalarChild(el, children, rendererReactiveChildDOMHost)) {\n return el;\n }\n\n if (Array.isArray(children)) {\n maybeWarnMissingKeys(children);\n if (children.length > 1) {\n const childFrag = document.createDocumentFragment();\n for (const child of children) {\n const dom = createDOMNode(child, elementNamespace);\n if (dom) childFrag.appendChild(dom);\n }\n el.appendChild(childFrag);\n } else if (children.length === 1) {\n const dom = createDOMNode(children[0], elementNamespace);\n if (dom) el.appendChild(dom);\n }\n } else {\n const dom = createDOMNode(children, elementNamespace);\n if (dom) el.appendChild(dom);\n }\n }\n return el;\n}\n\nfunction createFragmentElement(\n node: DOMElement,\n props: Record<string, unknown>,\n parentNamespace?: string\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const children = props.children ?? node.children;\n if (children) {\n if (Array.isArray(children)) {\n maybeWarnMissingKeys(children);\n for (const child of children) {\n const dom = createDOMNode(child, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n } else {\n const dom = createDOMNode(children, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n }\n return fragment;\n}\n\nexport function updateElementFromVnode(\n el: Element,\n vnode: VNode,\n updateChildren = true,\n forceChildrenUpdate = false\n): void {\n runRetainedElementUpdate(el, teardownNodeSubtree, () => {\n applyElementUpdateFromVnode(el, vnode, updateChildren, forceChildrenUpdate);\n });\n}\n\nfunction applyElementUpdateFromVnode(\n el: Element,\n vnode: VNode,\n updateChildren: boolean,\n forceChildrenUpdate: boolean\n): void {\n if (!_isDOMElement(vnode)) {\n return;\n }\n\n const props = (vnode.props || {}) as Record<string, unknown>;\n const domVNode = vnode as DOMElement;\n\n if (isHydrationSkipped(el)) {\n clearHydrationDeferredSubtree(el);\n return;\n }\n\n materializeKey(el, vnode, props);\n updateElementRef(el, props.ref);\n\n if (!hasTrackedElementPropBindings(el)) {\n if (\n !forceChildrenUpdate &&\n hasMatchingStaticProps(el, props, vnode.type as string)\n ) {\n if (updateChildren) {\n const children =\n (props.children as VNode | VNode[] | undefined) ?? vnode.children;\n if (!forceChildrenUpdate && canReuseStaticSubtree(el, domVNode)) {\n return;\n }\n updateElementChildren(el, children, forceChildrenUpdate);\n }\n return;\n }\n }\n\n const nextChildren = props.children ?? domVNode.children;\n const usesReactiveChildren = syncReactiveScalarChild(\n el,\n nextChildren,\n rendererReactiveChildDOMHost\n );\n syncElementPropBindings(el, domVNode, props, usesReactiveChildren);\n\n if (updateChildren) {\n const children =\n (props.children as VNode | VNode[] | undefined) ?? vnode.children;\n if (usesReactiveChildren) {\n return;\n }\n updateElementChildren(el, children, forceChildrenUpdate);\n }\n}\n\nconfigureRendererDOMHost({\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n updateElementChildren,\n tryPatchStableForDirtyItem,\n});\n\nconfigureBoundaryDOMHost({\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n tryPatchStableForDirtyItem,\n});\n"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,MAAM,YAA4C,MAAM;IAC3D,IAAI,CAAC,uBAAuB,sBAAsB,IAAI,QAAQ,GAC5D;IAEF,sBAAsB,IAAI,UAAU,mBAAmB;GACzD;GACA;EACF;;CAIF,MAAM,uBAAuB,wBAC3B,IAFmB,MAAM,YAAY,SAAS,UAI9C,4BACF;CACA,wBAAwB,IAAI,UAAU,OAAO,oBAAoB;CAEjE,IAAI,gBAAgB;EAClB,MAAM,WACH,MAAM,YAA4C,MAAM;EAC3D,IAAI,sBACF;EAEF,sBAAsB,IAAI,UAAU,mBAAmB;CACzD;AACF;AAEA,yBAAyB;CACvB;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,yBAAyB;CACvB;CACA;CACA;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"dom-internal.js","names":[],"sources":["../../src/renderer/dom-internal.ts"],"sourcesContent":["import { logger } from '../dev/logger';\nimport { Fragment } from '../jsx/jsx-runtime';\nimport { isBenchMetricScopeActive, recordBenchCounter } from '../runtime/for';\nimport { __ERROR_BOUNDARY__, __FOR_BOUNDARY__ } from '../common/vnode';\nimport {\n applyStaticScalarPropsToElement,\n hasMatchingStaticProps,\n materializeKey,\n} from './attributes';\nimport {\n configureBoundaryDOMHost,\n createForBoundary,\n getControlBoundaryState,\n getDirectControlBoundaryVNode,\n registerControlBoundaryCommitOwner,\n} from './boundaries';\nimport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n} from './children';\nimport {\n maybeWarnMissingKeys,\n tryGetStaticCreateFastPathShape,\n} from './child-shape';\nimport {\n removeAllListeners,\n removeElementReactiveProps,\n teardownNodeSubtree,\n updateElementRef,\n} from './cleanup';\nimport { createComponentElement, syncComponentElement } from './component-host';\nimport { configureRendererDOMHost, type ElementWithContext } from './dom-host';\nimport {\n rendererReactiveChildDOMHost,\n updateElementChildren,\n updateUnkeyedChildren,\n} from './element-children';\nimport {\n createErrorBoundaryElement,\n type ErrorBoundaryVNode,\n} from './error-boundary-dom';\nimport { getRuntimeEnv } from './env';\nimport { createElementForNamespace, resolveChildNamespace } from './namespaces';\nimport {\n applyPropsToElement,\n hasTrackedElementPropBindings,\n syncElementPropBindings,\n} from './prop-bindings';\nimport { syncReactiveScalarChild } from './reactive-children';\nimport { runRetainedElementUpdate } from './retained-element-rollback';\nimport { canReuseStaticSubtree } from './static-reuse';\nimport { tryPatchStableForDirtyItem } from './stable-patch';\nimport { _isDOMElement, type DOMElement, type JSXComponent, type VNode } from './types';\n\nexport { createForBoundary, commitForBoundaryChildren } from './boundaries';\nexport { markReactivePropsDirtySource } from './prop-bindings';\nexport { setStaticChildSlotsCacheEnabled } from './static-reuse';\nexport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n};\nexport {\n syncComponentElement,\n updateElementChildren,\n updateUnkeyedChildren,\n tryPatchStableForDirtyItem,\n};\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\nfunction getHydrationSkipBoundary(el: Element): Element | null {\n return el.closest('[data-skip-hydrate=\"true\"]');\n}\n\nfunction isHydrationSkipped(el: Element): boolean {\n return getHydrationSkipBoundary(el) !== null;\n}\n\nfunction clearHydrationDeferredSubtree(el: Element): void {\n const boundary = getHydrationSkipBoundary(el);\n if (!boundary) return;\n if (boundary === el) {\n removeAllListeners(el);\n removeElementReactiveProps(el);\n }\n}\n\nexport function createDOMNode(\n node: unknown,\n parentNamespace?: string\n): Node | null {\n if (!IS_DOM_AVAILABLE) {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n logger.warn('[Askr] createDOMNode called in non-DOM environment');\n } catch {\n // ignore\n }\n }\n return null;\n }\n\n if (typeof node === 'string') {\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n return document.createTextNode(node);\n }\n if (typeof node === 'number') {\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n return document.createTextNode(String(node));\n }\n\n if (!node) {\n return null;\n }\n\n if (Array.isArray(node)) {\n maybeWarnMissingKeys(node);\n const fragment = document.createDocumentFragment();\n for (const child of node) {\n const dom = createDOMNode(child, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n return fragment;\n }\n\n if (typeof node === 'object' && node !== null && 'type' in node) {\n const type = (node as DOMElement).type;\n const props = ((node as DOMElement).props || {}) as Record<string, unknown>;\n\n if (typeof type === 'string') {\n return createIntrinsicElement(\n node as DOMElement,\n type,\n props,\n parentNamespace\n );\n }\n\n if (typeof type === 'function') {\n return createComponentElement(\n node as ElementWithContext,\n type as JSXComponent,\n props,\n parentNamespace\n );\n }\n\n if (type === __FOR_BOUNDARY__) {\n return createForBoundary(node as DOMElement, props, parentNamespace);\n }\n\n if (type === __ERROR_BOUNDARY__) {\n return createErrorBoundaryElement(\n node as ErrorBoundaryVNode,\n props,\n parentNamespace\n );\n }\n\n if (\n typeof type === 'symbol' &&\n (type === Fragment || String(type) === 'Symbol(Fragment)')\n ) {\n return createFragmentElement(node as DOMElement, props, parentNamespace);\n }\n }\n\n return null;\n}\n\nfunction createIntrinsicElement(\n node: DOMElement,\n type: string,\n props: Record<string, unknown>,\n parentNamespace?: string\n): Element {\n const children = props.children ?? node.children;\n const elementNamespace = resolveChildNamespace(type, parentNamespace);\n const el = createElementForNamespace(type, parentNamespace);\n\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n\n materializeKey(el, node, props);\n\n const staticCreateFastPath = tryGetStaticCreateFastPathShape(props, children);\n\n if (staticCreateFastPath) {\n applyStaticScalarPropsToElement(el, props, type);\n if (staticCreateFastPath.textContent !== null) {\n el.textContent = staticCreateFastPath.textContent;\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('domNodesCreated');\n }\n }\n return el;\n }\n\n applyPropsToElement(el, props, type, isHydrationSkipped);\n\n if (children !== null && children !== undefined) {\n const controlBoundaryVNode = getDirectControlBoundaryVNode(children);\n if (controlBoundaryVNode) {\n const controlState = getControlBoundaryState(controlBoundaryVNode);\n if (!controlState) {\n throw new Error(\n '[createIntrinsicElement] Control boundary missing internal state'\n );\n }\n registerControlBoundaryCommitOwner(el, controlState);\n }\n\n if (syncReactiveScalarChild(el, children, rendererReactiveChildDOMHost)) {\n return el;\n }\n\n if (Array.isArray(children)) {\n maybeWarnMissingKeys(children);\n if (children.length > 1) {\n const childFrag = document.createDocumentFragment();\n for (const child of children) {\n const dom = createDOMNode(child, elementNamespace);\n if (dom) childFrag.appendChild(dom);\n }\n el.appendChild(childFrag);\n } else if (children.length === 1) {\n const dom = createDOMNode(children[0], elementNamespace);\n if (dom) el.appendChild(dom);\n }\n } else {\n const dom = createDOMNode(children, elementNamespace);\n if (dom) el.appendChild(dom);\n }\n }\n return el;\n}\n\nfunction createFragmentElement(\n node: DOMElement,\n props: Record<string, unknown>,\n parentNamespace?: string\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const children = props.children ?? node.children;\n if (children) {\n if (Array.isArray(children)) {\n maybeWarnMissingKeys(children);\n for (const child of children) {\n const dom = createDOMNode(child, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n } else {\n const dom = createDOMNode(children, parentNamespace);\n if (dom) fragment.appendChild(dom);\n }\n }\n return fragment;\n}\n\nexport function updateElementFromVnode(\n el: Element,\n vnode: VNode,\n updateChildren = true,\n forceChildrenUpdate = false\n): void {\n runRetainedElementUpdate(el, teardownNodeSubtree, () => {\n applyElementUpdateFromVnode(el, vnode, updateChildren, forceChildrenUpdate);\n });\n}\n\nfunction applyElementUpdateFromVnode(\n el: Element,\n vnode: VNode,\n updateChildren: boolean,\n forceChildrenUpdate: boolean\n): void {\n if (!_isDOMElement(vnode)) {\n return;\n }\n\n const props = (vnode.props || {}) as Record<string, unknown>;\n const domVNode = vnode as DOMElement;\n\n if (isHydrationSkipped(el)) {\n clearHydrationDeferredSubtree(el);\n return;\n }\n\n materializeKey(el, vnode, props);\n updateElementRef(el, props.ref);\n\n if (!hasTrackedElementPropBindings(el)) {\n if (\n !forceChildrenUpdate &&\n hasMatchingStaticProps(el, props, vnode.type as string)\n ) {\n if (updateChildren) {\n const children =\n (props.children as VNode | VNode[] | undefined) ?? vnode.children;\n if (!forceChildrenUpdate && canReuseStaticSubtree(el, domVNode)) {\n return;\n }\n updateElementChildren(el, children, forceChildrenUpdate);\n }\n return;\n }\n }\n\n const nextChildren = props.children ?? domVNode.children;\n const usesReactiveChildren = syncReactiveScalarChild(\n el,\n nextChildren,\n rendererReactiveChildDOMHost\n );\n syncElementPropBindings(el, domVNode, props, usesReactiveChildren);\n\n if (updateChildren) {\n const children =\n (props.children as VNode | VNode[] | undefined) ?? vnode.children;\n if (usesReactiveChildren) {\n return;\n }\n updateElementChildren(el, children, forceChildrenUpdate);\n }\n}\n\nconfigureRendererDOMHost({\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n updateElementChildren,\n tryPatchStableForDirtyItem,\n});\n\nconfigureBoundaryDOMHost({\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n tryPatchStableForDirtyItem,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAa,mBAAmB,OAAO,aAAa;AAEpD,SAAS,yBAAyB,IAA6B;CAC7D,OAAO,GAAG,QAAQ,8BAA4B;AAChD;AAEA,SAAS,mBAAmB,IAAsB;CAChD,OAAO,yBAAyB,EAAE,MAAM;AAC1C;AAEA,SAAS,8BAA8B,IAAmB;CACxD,MAAM,WAAW,yBAAyB,EAAE;CAC5C,IAAI,CAAC,UAAU;CACf,IAAI,aAAa,IAAI;EACnB,mBAAmB,EAAE;EACrB,2BAA2B,EAAE;CAC/B;AACF;AAEA,SAAgB,cACd,MACA,iBACa;CACb,IAAI,CAAC,kBAAkB;EACrB,IAAI,cAAc,CAAC,CAAC,aAAa,cAC/B,IAAI;GACF,OAAO,KAAK,oDAAoD;EAClE,QAAQ,CAER;EAEF,OAAO;CACT;CAEA,IAAI,OAAO,SAAS,UA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