@askrjs/askr 0.0.50 → 0.0.51
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/bench/components/benchmark-table.js.map +1 -1
- package/dist/benchmark.js +5 -4
- package/dist/benchmark.js.map +1 -1
- package/dist/bin/askr-ssg.d.ts.map +1 -1
- package/dist/bin/askr-ssg.js.map +1 -1
- package/dist/boot/hydration.js.map +1 -1
- package/dist/boot/index.js +2 -1
- package/dist/boot/index.js.map +1 -1
- package/dist/boot/root-lifecycle.d.ts.map +1 -1
- package/dist/boot/root-lifecycle.js +4 -4
- package/dist/boot/root-lifecycle.js.map +1 -1
- package/dist/boot/route-startup.js.map +1 -1
- package/dist/common/error-boundary.d.ts +16 -0
- package/dist/common/error-boundary.d.ts.map +1 -0
- package/dist/common/invariant.js +17 -0
- package/dist/common/invariant.js.map +1 -0
- package/dist/{dev → common}/logger.js +5 -6
- package/dist/common/logger.js.map +1 -0
- package/dist/common/vnode.js.map +1 -1
- package/dist/components/error-boundary.d.ts +2 -15
- package/dist/components/error-boundary.d.ts.map +1 -1
- package/dist/components/error-boundary.js +2 -74
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/link.js +2 -0
- package/dist/components/link.js.map +1 -1
- package/dist/control/case.d.ts.map +1 -1
- package/dist/control/case.js +1 -0
- package/dist/control/case.js.map +1 -1
- package/dist/control/for.d.ts +3 -3
- package/dist/control/for.d.ts.map +1 -1
- package/dist/control/for.js +2 -2
- package/dist/control/for.js.map +1 -1
- package/dist/control/show.js +1 -0
- package/dist/control/show.js.map +1 -1
- package/dist/data/data-runtime.js.map +1 -1
- package/dist/data/invalidation.js +2 -2
- package/dist/data/invalidation.js.map +1 -1
- package/dist/data/mutation-cell.d.ts.map +1 -1
- package/dist/data/mutation-cell.js +1 -1
- package/dist/data/mutation-cell.js.map +1 -1
- package/dist/data/query-cell.js +2 -2
- package/dist/data/query-cell.js.map +1 -1
- package/dist/data/shared.js +1 -0
- package/dist/data/shared.js.map +1 -1
- package/dist/data/testing.js +2 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/state/controllable.d.ts +0 -1
- package/dist/foundations/state/controllable.d.ts.map +1 -1
- package/dist/foundations/state/controllable.js +1 -0
- package/dist/foundations/state/controllable.js.map +1 -1
- package/dist/foundations/structures/index.d.ts +1 -1
- package/dist/foundations/structures/index.js +2 -1
- package/dist/foundations/structures/portal.d.ts +2 -24
- package/dist/foundations/structures/portal.js +3 -187
- package/dist/fx/fx.js +2 -2
- package/dist/fx/fx.js.map +1 -1
- package/dist/fx/index.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/jsx/types.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.js +1 -0
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/renderer/attributes.js +1 -0
- package/dist/renderer/attributes.js.map +1 -1
- package/dist/renderer/boundaries.js +5 -5
- package/dist/renderer/boundaries.js.map +1 -1
- package/dist/renderer/child-shape.js +2 -2
- package/dist/renderer/child-shape.js.map +1 -1
- package/dist/renderer/children-fastpath.js +149 -0
- package/dist/renderer/children-fastpath.js.map +1 -0
- package/dist/renderer/children.js +3 -138
- package/dist/renderer/children.js.map +1 -1
- package/dist/renderer/cleanup.js +2 -2
- package/dist/renderer/cleanup.js.map +1 -1
- package/dist/renderer/component-host-cleanup.js +1 -1
- package/dist/renderer/component-host-cleanup.js.map +1 -1
- package/dist/renderer/component-host-instances.js +1 -1
- package/dist/renderer/component-host-instances.js.map +1 -1
- package/dist/renderer/component-host.js +1 -1
- package/dist/renderer/component-host.js.map +1 -1
- package/dist/renderer/dom-host.js.map +1 -1
- package/dist/renderer/dom-internal.js +5 -4
- package/dist/renderer/dom-internal.js.map +1 -1
- package/dist/renderer/dom.js +2 -1
- package/dist/renderer/element-children.js.map +1 -1
- package/dist/renderer/error-boundary-dom.js +51 -2
- package/dist/renderer/error-boundary-dom.js.map +1 -1
- package/dist/renderer/evaluate-reconcile.js +6 -5
- package/dist/renderer/evaluate-reconcile.js.map +1 -1
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +3 -2
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/renderer/for-commit-dom-map.js.map +1 -1
- package/dist/renderer/for-commit-removal.js +2 -2
- package/dist/renderer/for-commit-removal.js.map +1 -1
- package/dist/renderer/for-commit-reorder.js +2 -2
- package/dist/renderer/for-commit-reorder.js.map +1 -1
- package/dist/renderer/for-commit.js +3 -3
- package/dist/renderer/for-commit.js.map +1 -1
- package/dist/renderer/index.js +3 -1
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/prop-bindings.js +4 -4
- package/dist/renderer/prop-bindings.js.map +1 -1
- package/dist/renderer/reactive-child-dom.js.map +1 -1
- package/dist/renderer/reactive-children.js +4 -4
- package/dist/renderer/reactive-children.js.map +1 -1
- package/dist/renderer/reconcile-fastpaths.js +2 -1
- package/dist/renderer/reconcile-fastpaths.js.map +1 -1
- package/dist/renderer/reconcile-resolution.js +3 -3
- package/dist/renderer/reconcile-resolution.js.map +1 -1
- package/dist/renderer/retained-element-rollback.js +2 -1
- package/dist/renderer/retained-element-rollback.js.map +1 -1
- package/dist/renderer/stable-patch.js +2 -3
- package/dist/renderer/stable-patch.js.map +1 -1
- package/dist/renderer/utils.js +2 -1
- package/dist/renderer/utils.js.map +1 -1
- package/dist/resources/index.js +1 -2
- package/dist/router/activity.d.ts.map +1 -1
- package/dist/router/activity.js +20 -22
- package/dist/router/activity.js.map +1 -1
- package/dist/router/authoring.js +1 -1
- package/dist/router/authoring.js.map +1 -1
- package/dist/router/index.d.ts +1 -1
- package/dist/router/navigate.js +1 -1
- package/dist/router/navigate.js.map +1 -1
- package/dist/router/navigation-registry.js +1 -1
- package/dist/router/navigation-registry.js.map +1 -1
- package/dist/router/navigation-targets.d.ts.map +1 -1
- package/dist/router/navigation-targets.js +7 -5
- package/dist/router/navigation-targets.js.map +1 -1
- package/dist/router/rendering.js +1 -0
- package/dist/router/rendering.js.map +1 -1
- package/dist/router/resolution.d.ts +1 -14
- package/dist/router/resolution.d.ts.map +1 -1
- package/dist/router/resolution.js +6 -173
- package/dist/router/resolution.js.map +1 -1
- package/dist/router/route-matching.d.ts +20 -0
- package/dist/router/route-matching.d.ts.map +1 -0
- package/dist/router/route-matching.js +175 -0
- package/dist/router/route-matching.js.map +1 -0
- package/dist/router/route.js +4 -2
- package/dist/router/testing.js +4 -0
- package/dist/runtime/access.d.ts +20 -0
- package/dist/runtime/access.d.ts.map +1 -0
- package/dist/runtime/component-cleanup.js +1 -1
- package/dist/runtime/component-cleanup.js.map +1 -1
- package/dist/runtime/component-commit.js +1 -1
- package/dist/runtime/component-commit.js.map +1 -1
- package/dist/runtime/component-internal.d.ts +1 -1
- package/dist/runtime/component-internal.js +1 -1
- package/dist/runtime/component-internal.js.map +1 -1
- package/dist/runtime/component-lifecycle.d.ts +1 -1
- package/dist/runtime/component-lifecycle.js +1 -1
- package/dist/runtime/component-lifecycle.js.map +1 -1
- package/dist/runtime/component-scope.d.ts +1 -1
- package/dist/runtime/dev-namespace.d.ts +31 -0
- package/dist/runtime/dev-namespace.d.ts.map +1 -0
- package/dist/runtime/error-boundary.d.ts +5 -0
- package/dist/runtime/error-boundary.d.ts.map +1 -0
- package/dist/runtime/error-boundary.js +31 -0
- package/dist/runtime/error-boundary.js.map +1 -0
- package/dist/runtime/events.d.ts +58 -0
- package/dist/runtime/events.d.ts.map +1 -0
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/execution-model.d.ts +7 -0
- package/dist/runtime/execution-model.d.ts.map +1 -0
- package/dist/runtime/fastlane.d.ts +34 -0
- package/dist/runtime/fastlane.d.ts.map +1 -0
- package/dist/runtime/for-internal.d.ts +5 -5
- package/dist/runtime/for-internal.d.ts.map +1 -1
- package/dist/runtime/for-internal.js.map +1 -1
- package/dist/runtime/for-signals.d.ts +1 -1
- package/dist/runtime/for-signals.d.ts.map +1 -1
- package/dist/runtime/for-signals.js +1 -1
- package/dist/runtime/for-signals.js.map +1 -1
- package/dist/runtime/for-types.d.ts +9 -0
- package/dist/runtime/for-types.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +24 -0
- package/dist/runtime/index.js +31 -0
- package/dist/runtime/perf-metrics.d.ts +26 -0
- package/dist/runtime/perf-metrics.d.ts.map +1 -0
- package/dist/runtime/portal.d.ts +22 -0
- package/dist/runtime/portal.d.ts.map +1 -0
- package/dist/runtime/portal.js +213 -0
- package/dist/runtime/portal.js.map +1 -0
- package/dist/runtime/resource-cell.js +1 -1
- package/dist/runtime/resource-cell.js.map +1 -1
- package/dist/runtime/resource-operation.js +1 -1
- package/dist/runtime/runtime.d.ts +1 -1
- package/dist/runtime/scheduler.js +2 -2
- package/dist/runtime/scheduler.js.map +1 -1
- package/dist/runtime/selector-store.js +24 -0
- package/dist/runtime/selector-store.js.map +1 -0
- package/dist/runtime/selector.d.ts.map +1 -1
- package/dist/runtime/selector.js +3 -18
- package/dist/runtime/selector.js.map +1 -1
- package/dist/ssg/create-static-gen.js +1 -0
- package/dist/ssg/create-static-gen.js.map +1 -1
- package/dist/ssg/static-routes.js +1 -0
- package/dist/ssg/static-routes.js.map +1 -1
- package/dist/ssr/boundaries.js +2 -2
- package/dist/ssr/boundaries.js.map +1 -1
- package/dist/ssr/component-runtime.js +3 -3
- package/dist/ssr/component-runtime.js.map +1 -1
- package/dist/ssr/render-resolved.js +1 -1
- package/dist/ssr/render-sync.js +1 -1
- package/dist/ssr/render-sync.js.map +1 -1
- package/dist/ssr/route-policy-resolution.js +2 -1
- package/dist/ssr/route-policy-resolution.js.map +1 -1
- package/dist/ssr/route-render.js +2 -1
- package/dist/ssr/route-render.js.map +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/dev/invariant.js +0 -29
- package/dist/dev/invariant.js.map +0 -1
- package/dist/dev/logger.js.map +0 -1
- package/dist/foundations/structures/portal.d.ts.map +0 -1
- package/dist/foundations/structures/portal.js.map +0 -1
- package/dist/runtime/component-contracts.js +0 -5
|
@@ -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 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,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a,SAAS,YAAY;EAC1D,6BAA6B,cAAc,gBAAgB;CAC7D;CAEA,qBAAqB,gBAAgB;CACrC,OAAO;AACT;AAEA,SAAS,8BAA8B,MAAiC;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
|
+
{"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';\nimport {\n getCurrentContextFrame,\n getVNodeContextFrame,\n markVNodeTreeWithContextFrame,\n withContext,\n type ContextFrame,\n} from '../runtime';\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 {\n _isDOMElement,\n type DOMElement,\n type JSXComponent,\n type VNode,\n} 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":";;;;;;;;;;;;;;;AAsDA,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,IAAI,gBAAgB;CACpB,IAAI,iBAAiB;CACrB,IAAI,QAAQ;CAEZ,OACE,cAAc,aAAa,KAC3B,OAAO,cAAc,SAAS,cAC9B,QAAQ,IACR;EACA,MAAM,iBACJ,qBAAqB,aAAa,KAAK;EACzC,MAAM,iBAAiB,wBACrB,wBAAwB,GACxB,cAAc,MACZ,cAA6B,SAAS,CAAC,GACzC,IACF;EACA,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AG/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-host.js","names":[],"sources":["../../src/renderer/dom-host.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"dom-host.js","names":[],"sources":["../../src/renderer/dom-host.ts"],"sourcesContent":["import type { ComponentFunction, ComponentInstance } from '../runtime';\nimport type { ContextFrame } from '../runtime';\nimport type { DOMElement, VNode } from './types';\n\nexport type ElementWithContext = DOMElement & {\n [key: symbol]: ContextFrame | boolean | undefined;\n __instance?: ComponentInstance;\n};\n\nexport type InstanceHostElement = Element & {\n __ASKR_INSTANCE?: ComponentInstance;\n __ASKR_INSTANCES?: ComponentInstance[];\n __ASKR_WRAPPER_HOST?: boolean;\n};\n\nexport interface RendererDOMHost {\n createDOMNode(node: unknown, parentNamespace?: string): Node | null;\n syncComponentElement(\n currentDom: Node | null,\n node: ElementWithContext,\n type: ComponentFunction,\n props: Record<string, unknown>,\n parentNamespace?: string,\n forceChildrenUpdate?: boolean,\n retainedHostInstances?: Iterable<ComponentInstance>\n ): Node | null;\n updateElementFromVnode(\n el: Element,\n vnode: VNode,\n updateChildren?: boolean,\n forceChildrenUpdate?: boolean\n ): void;\n updateElementChildren(\n el: Element,\n children: VNode | VNode[] | undefined,\n forceUpdate?: boolean\n ): void;\n tryPatchStableForDirtyItem(scope: { dom?: Node; vnode?: VNode }): boolean;\n}\n\nlet rendererDOMHost: RendererDOMHost | null = null;\n\nexport function configureRendererDOMHost(host: RendererDOMHost): void {\n rendererDOMHost = host;\n}\n\nexport function getRendererDOMHost(): RendererDOMHost {\n if (!rendererDOMHost) {\n throw new Error('[askr] Renderer DOM host is not configured.');\n }\n return rendererDOMHost;\n}\n"],"mappings":";AAwCA,IAAI,kBAA0C;AAE9C,SAAgB,yBAAyB,MAA6B;CACpE,kBAAkB;AACpB;AAEA,SAAgB,qBAAsC;CACpD,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,6CAA6C;CAE/D,OAAO;AACT"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { __ERROR_BOUNDARY__, __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
|
|
2
2
|
import "./types.js";
|
|
3
3
|
import { getRuntimeEnv } from "../common/env.js";
|
|
4
|
-
import { logger } from "../
|
|
4
|
+
import { logger } from "../common/logger.js";
|
|
5
5
|
import { Fragment } from "../common/jsx.js";
|
|
6
|
+
import { isBenchMetricScopeActive, recordBenchCounter } from "../runtime/for-bench.js";
|
|
7
|
+
import "../runtime/index.js";
|
|
6
8
|
import { removeAllListeners, removeElementReactiveProps, teardownNodeSubtree, updateElementRef } from "./cleanup.js";
|
|
7
9
|
import "./env.js";
|
|
8
10
|
import "../jsx-runtime.js";
|
|
9
|
-
import { isBenchMetricScopeActive, recordBenchCounter } from "../runtime/for-bench.js";
|
|
10
|
-
import "../runtime/for.js";
|
|
11
11
|
import { applyStaticScalarPropsToElement, hasMatchingStaticProps, materializeKey } from "./attributes.js";
|
|
12
12
|
import { createElementForNamespace, resolveChildNamespace } from "./namespaces.js";
|
|
13
13
|
import { configureBoundaryDOMHost, createForBoundary, getControlBoundaryState, getDirectControlBoundaryVNode, registerControlBoundaryCommitOwner } from "./boundaries.js";
|
|
14
|
-
import {
|
|
14
|
+
import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
|
|
15
|
+
import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
|
|
15
16
|
import { maybeWarnMissingKeys, tryGetStaticCreateFastPathShape } from "./child-shape.js";
|
|
16
17
|
import { configureRendererDOMHost } from "./dom-host.js";
|
|
17
18
|
import { createComponentElement, syncComponentElement } from "./component-host.js";
|
|
@@ -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 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,a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
|
|
1
|
+
{"version":3,"file":"dom-internal.js","names":[],"sources":["../../src/renderer/dom-internal.ts"],"sourcesContent":["import { logger } from '../common/logger';\nimport { Fragment } from '../jsx/jsx-runtime';\nimport { isBenchMetricScopeActive, recordBenchCounter } from '../runtime';\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 {\n _isDOMElement,\n type DOMElement,\n type JSXComponent,\n type VNode,\n} 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,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,UAAU;EAC5B,IAAI,yBAAyB,YAAY,GACvC,mBAAmB,iBAAiB;EAEtC,OAAO,SAAS,eAAe,IAAI;CACrC;CACA,IAAI,OAAO,SAAS,UAAU;EAC5B,IAAI,yBAAyB,YAAY,GACvC,mBAAmB,iBAAiB;EAEtC,OAAO,SAAS,eAAe,OAAO,IAAI,CAAC;CAC7C;CAEA,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,qBAAqB,IAAI;EACzB,MAAM,WAAW,SAAS,uBAAuB;EACjD,KAAK,MAAM,SAAS,MAAM;GACxB,MAAM,MAAM,cAAc,OAAO,eAAe;GAChD,IAAI,KAAK,SAAS,YAAY,GAAG;E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G;EAC1B,8BAA8B,EAAE;EAChC;CACF;CAEA,eAAe,IAAI,OAAO,KAAK;CAC/B,iBAAiB,IAAI,MAAM,GAAG;CAE9B,IAAI,CAAC,8BAA8B,EAAE,GACnC;MACE,CAAC,uBACD,uBAAuB,IAAI,OAAO,MAAM,IAAc,GACtD;GACA,IAAI,gBAAgB;IAClB,MAAM,WACH,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"}
|
package/dist/renderer/dom.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./boundaries.js";
|
|
2
|
-
import {
|
|
2
|
+
import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
|
|
3
|
+
import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
|
|
3
4
|
import { syncComponentElement } from "./component-host.js";
|
|
4
5
|
import { setStaticChildSlotsCacheEnabled } from "./static-reuse.js";
|
|
5
6
|
import { updateElementChildren, updateUnkeyedChildren } from "./element-children.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-children.js","names":[],"sources":["../../src/renderer/element-children.ts"],"sourcesContent":["import type { ComponentFunction } from '../runtime/component-contracts';\nimport { clearControlBoundaryCommitOwner } from './boundaries';\nimport {\n commitForBoundaryChildren,\n evaluateControlBoundaryState,\n getControlBoundaryState,\n getDirectControlBoundaryVNode,\n registerControlBoundaryCommitOwner,\n trySyncControlBoundaryChild,\n} from './boundaries';\nimport { isBulkTextFastPathEligible, performBulkTextReplace } from './children';\nimport { isFragmentVNode, normalizeComponentChildren } from './child-shape';\nimport { teardownNodeSubtree } from './cleanup';\nimport { getRendererDOMHost, type ElementWithContext } from './dom-host';\nimport { keyedElements } from './keyed';\nimport { getParentNamespace } from './namespaces';\nimport {\n trySyncScalarChildSequenceInPlace,\n type ReactiveChildDOMHost,\n} from './reactive-children';\nimport { reconcileKeyedChildren } from './reconcile';\nimport { tagsEqualIgnoreCase } from './static-reuse';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport { extractKey } from './utils';\n\nexport const rendererReactiveChildDOMHost: ReactiveChildDOMHost = {\n createDOMNode: (node, parentNamespace) =>\n getRendererDOMHost().createDOMNode(node, parentNamespace),\n updateElementChildren: (el, children, forceUpdate) =>\n updateElementChildren(el, children, forceUpdate),\n};\n\nexport function updateElementChildren(\n el: Element,\n children: VNode | VNode[] | undefined,\n forceUpdate = false\n): void {\n const directControlBoundary = getDirectControlBoundaryVNode(children);\n if (directControlBoundary) {\n const controlState = getControlBoundaryState(directControlBoundary);\n if (!controlState) {\n throw new Error(\n '[updateElementChildren] Control boundary missing internal state'\n );\n }\n\n registerControlBoundaryCommitOwner(el, controlState);\n const childrenVNodes = evaluateControlBoundaryState(controlState);\n commitForBoundaryChildren(el, controlState, childrenVNodes as VNode[]);\n return;\n }\n\n clearControlBoundaryCommitOwner(el);\n\n if (children === null || children === undefined) {\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = '';\n return;\n }\n\n if (!Array.isArray(children) && isFragmentVNode(children)) {\n updateUnkeyedChildren(\n el,\n normalizeComponentChildren(children),\n forceUpdate\n );\n return;\n }\n\n if (\n !Array.isArray(children) &&\n (typeof children === 'string' || typeof children === 'number')\n ) {\n if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {\n const s = String(children);\n const t = el.firstChild as Text;\n if (t.data !== s) t.data = s;\n } else {\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = String(children);\n }\n return;\n }\n\n if (Array.isArray(children)) {\n const normalizedChildren = normalizeComponentChildren(children) as VNode[];\n\n if (\n trySyncScalarChildSequenceInPlace(\n el,\n normalizedChildren,\n rendererReactiveChildDOMHost\n )\n ) {\n keyedElements.delete(el);\n return;\n }\n\n if (hasKeyedVNodeChildren(normalizedChildren)) {\n const oldKeyMap = getOrBuildDomKeyMap(el);\n const newKeyMap = reconcileKeyedChildren(\n el,\n normalizedChildren,\n oldKeyMap\n );\n keyedElements.set(el, newKeyMap);\n return;\n }\n if (isBulkTextFastPathEligible(el, normalizedChildren)) {\n performBulkTextReplace(el, normalizedChildren);\n keyedElements.delete(el);\n return;\n }\n updateUnkeyedChildren(el, normalizedChildren, forceUpdate);\n return;\n }\n\n if (_isDOMElement(children)) {\n updateUnkeyedChildren(el, [children], forceUpdate);\n return;\n }\n\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = '';\n const dom = getRendererDOMHost().createDOMNode(children);\n if (dom) el.appendChild(dom);\n}\n\nfunction hasKeyedVNodeChildren(children: VNode[]): boolean {\n for (let i = 0; i < children.length; i++) {\n if (extractKey(children[i]) !== undefined) return true;\n }\n return false;\n}\n\nfunction isEmptyChild(child: unknown): boolean {\n return child === null || child === undefined || child === false;\n}\n\nfunction getOrBuildDomKeyMap(\n parent: Element\n): Map<string | number, Element> | undefined {\n let keyMap = keyedElements.get(parent);\n if (!keyMap) {\n keyMap = new Map<string | number, Element>();\n for (\n let child = parent.firstElementChild;\n child;\n child = child.nextElementSibling\n ) {\n const key = child.getAttribute('data-key');\n if (key !== null) {\n keyMap.set(key, child);\n const numericKey = Number(key);\n if (!Number.isNaN(numericKey)) keyMap.set(numericKey, child);\n }\n }\n if (keyMap.size > 0) keyedElements.set(parent, keyMap);\n }\n return keyMap.size > 0 ? keyMap : undefined;\n}\n\nexport function updateUnkeyedChildren(\n parent: Element,\n newChildren: unknown[],\n forceUpdate = false\n): void {\n const parentNamespace = getParentNamespace(parent);\n const domHost = getRendererDOMHost();\n\n const trySyncComponentChild = (\n currentDom: Element,\n next: DOMElement\n ): Node | null => {\n if (typeof next.type !== 'function') {\n return null;\n }\n\n return domHost.syncComponentElement(\n currentDom,\n next as ElementWithContext,\n next.type as ComponentFunction,\n (((next as DOMElement).props ?? {}) as Record<string, unknown>) || {},\n parentNamespace,\n forceUpdate\n );\n };\n\n const hasText = newChildren.some(\n (c) => typeof c === 'string' || typeof c === 'number'\n );\n const hasElements = newChildren.some((c) => _isDOMElement(c));\n const hasEmptyChildren = newChildren.some(isEmptyChild);\n const hasComponentChildren = newChildren.some(\n (c) => _isDOMElement(c) && typeof (c as DOMElement).type === 'function'\n );\n const hasNonElementDomChildren =\n parent.childNodes.length !== parent.children.length;\n\n if (\n !hasEmptyChildren &&\n !hasText &&\n !hasComponentChildren &&\n !hasNonElementDomChildren &&\n hasElements &&\n parent.children.length === newChildren.length\n ) {\n const c = parent.children;\n for (let i = 0; i < newChildren.length; i++) {\n const next = newChildren[i];\n const current = c[i];\n if (!current || next === undefined) continue;\n if (_isDOMElement(next) && typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(current.tagName, next.type)) {\n domHost.updateElementFromVnode(current, next, true, forceUpdate);\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else if (_isDOMElement(next)) {\n if (trySyncControlBoundaryChild(parent, current, next)) {\n continue;\n }\n\n const synced = trySyncComponentChild(current, next);\n if (synced && synced !== current) {\n teardownNodeSubtree(current);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n return;\n }\n\n const existing = Array.from(parent.children);\n\n if (\n hasText ||\n hasComponentChildren ||\n hasEmptyChildren ||\n hasNonElementDomChildren\n ) {\n const allNodes = Array.from(parent.childNodes);\n const max = Math.max(allNodes.length, newChildren.length);\n\n for (let i = 0; i < max; i++) {\n const currentNode = allNodes[i];\n const next = newChildren[i];\n const nextIsEmpty = isEmptyChild(next);\n\n if (nextIsEmpty && currentNode) {\n teardownNodeSubtree(currentNode);\n currentNode.remove();\n continue;\n }\n\n if (!currentNode && !nextIsEmpty) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.appendChild(dom);\n continue;\n }\n\n if (!currentNode || nextIsEmpty) continue;\n\n if (typeof next === 'string' || typeof next === 'number') {\n if (currentNode.nodeType === 3) {\n (currentNode as Text).data = String(next);\n } else {\n const textNode = document.createTextNode(String(next));\n parent.replaceChild(textNode, currentNode);\n }\n } else if (_isDOMElement(next)) {\n if (currentNode.nodeType === 1) {\n const currentEl = currentNode as Element;\n if (typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(currentEl.tagName, next.type)) {\n domHost.updateElementFromVnode(\n currentEl,\n next,\n true,\n forceUpdate\n );\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(currentEl);\n parent.replaceChild(dom, currentNode);\n }\n }\n } else {\n if (trySyncControlBoundaryChild(parent, currentNode, next)) {\n continue;\n }\n\n const synced = trySyncComponentChild(currentEl, next);\n if (synced && synced !== currentNode) {\n teardownNodeSubtree(currentEl);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(currentEl);\n parent.replaceChild(dom, currentNode);\n }\n }\n }\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.replaceChild(dom, currentNode);\n }\n }\n }\n return;\n }\n\n if (\n newChildren.length === 1 &&\n existing.length === 0 &&\n parent.childNodes.length === 1\n ) {\n const firstNewChild = newChildren[0];\n const firstExisting = parent.firstChild;\n if (\n (typeof firstNewChild === 'string' ||\n typeof firstNewChild === 'number') &&\n firstExisting?.nodeType === 3\n ) {\n (firstExisting as Text).data = String(firstNewChild);\n return;\n }\n }\n\n if (existing.length === 0 && parent.childNodes.length > 0) {\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n parent.textContent = '';\n }\n const max = Math.max(existing.length, newChildren.length);\n\n for (let i = 0; i < max; i++) {\n const current = existing[i];\n const next = newChildren[i];\n const nextIsEmpty = isEmptyChild(next);\n\n if (nextIsEmpty && current) {\n teardownNodeSubtree(current);\n current.remove();\n continue;\n }\n\n if (!current && !nextIsEmpty) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.appendChild(dom);\n continue;\n }\n\n if (!current || nextIsEmpty) continue;\n\n if (typeof next === 'string' || typeof next === 'number') {\n const textNode = document.createTextNode(String(next));\n teardownNodeSubtree(current);\n parent.replaceChild(textNode, current);\n } else if (_isDOMElement(next)) {\n if (typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(current.tagName, next.type)) {\n domHost.updateElementFromVnode(current, next, true, forceUpdate);\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else {\n const synced = trySyncComponentChild(current, next);\n if (synced && synced !== current) {\n teardownNodeSubtree(current);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n } else {\n const dom = domHost.createDOMNode(next);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,+BAAqD;CAChE,gBA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BAAoB,OAAO;GAC3B,QAAQ,OAAO;GACf;EACF;EAEA,IAAI,CAAC,WAAW,CAAC,aAAa;GAC5B,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;GACvD,IAAI,KAAK,OAAO,YAAY,GAAG;GAC/B;EACF;EAEA,IAAI,CAAC,WAAW,aAAa;EAE7B,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;GACxD,MAAM,WAAW,SAAS,eAAe,OAAO,IAAI,CAAC;GACrD,oBAAoB,OAAO;GAC3B,OAAO,aAAa,UAAU,OAAO;EACvC,OAAO,IAAI,cAAc,IAAI,GAC3B,IAAI,OAAO,KAAK,SAAS,UACvB,IAAI,oBAAoB,QAAQ,SAAS,KAAK,IAAI,GAChD,QAAQ,uBAAuB,SAAS,MAAM,MAAM,WAAW;OAC1D;GACL,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;GACvD,IAAI,KAAK;IACP,oBAAoB,OAAO;IAC3B,OAAO,aAAa,KAAK,OAAO;GAClC;EACF;OACK;GACL,MAAM,SAAS,sBAAsB,SAAS,IAAI;GAClD,IAAI,UAAU,WAAW,SACvB,oBAAoB,OAAO;QACtB,IAAI,CAAC,QAAQ;IAClB,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;IACvD,IAAI,KAAK;KACP,oBAAoB,OAAO;KAC3B,OAAO,aAAa,KAAK,OAAO;IAClC;GACF;EACF;OACK;GACL,MAAM,MAAM,QAAQ,cAAc,IAAI;GACtC,IAAI,KAAK;IACP,oBAAoB,OAAO;IAC3B,OAAO,aAAa,KAAK,OAAO;GAClC;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"element-children.js","names":[],"sources":["../../src/renderer/element-children.ts"],"sourcesContent":["import type { ComponentFunction } from '../runtime';\nimport { clearControlBoundaryCommitOwner } from './boundaries';\nimport {\n commitForBoundaryChildren,\n evaluateControlBoundaryState,\n getControlBoundaryState,\n getDirectControlBoundaryVNode,\n registerControlBoundaryCommitOwner,\n trySyncControlBoundaryChild,\n} from './boundaries';\nimport { isBulkTextFastPathEligible, performBulkTextReplace } from './children';\nimport { isFragmentVNode, normalizeComponentChildren } from './child-shape';\nimport { teardownNodeSubtree } from './cleanup';\nimport { getRendererDOMHost, type ElementWithContext } from './dom-host';\nimport { keyedElements } from './keyed';\nimport { getParentNamespace } from './namespaces';\nimport {\n trySyncScalarChildSequenceInPlace,\n type ReactiveChildDOMHost,\n} from './reactive-children';\nimport { reconcileKeyedChildren } from './reconcile';\nimport { tagsEqualIgnoreCase } from './static-reuse';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport { extractKey } from './utils';\n\nexport const rendererReactiveChildDOMHost: ReactiveChildDOMHost = {\n createDOMNode: (node, parentNamespace) =>\n getRendererDOMHost().createDOMNode(node, parentNamespace),\n updateElementChildren: (el, children, forceUpdate) =>\n updateElementChildren(el, children, forceUpdate),\n};\n\nexport function updateElementChildren(\n el: Element,\n children: VNode | VNode[] | undefined,\n forceUpdate = false\n): void {\n const directControlBoundary = getDirectControlBoundaryVNode(children);\n if (directControlBoundary) {\n const controlState = getControlBoundaryState(directControlBoundary);\n if (!controlState) {\n throw new Error(\n '[updateElementChildren] Control boundary missing internal state'\n );\n }\n\n registerControlBoundaryCommitOwner(el, controlState);\n const childrenVNodes = evaluateControlBoundaryState(controlState);\n commitForBoundaryChildren(el, controlState, childrenVNodes as VNode[]);\n return;\n }\n\n clearControlBoundaryCommitOwner(el);\n\n if (children === null || children === undefined) {\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = '';\n return;\n }\n\n if (!Array.isArray(children) && isFragmentVNode(children)) {\n updateUnkeyedChildren(\n el,\n normalizeComponentChildren(children),\n forceUpdate\n );\n return;\n }\n\n if (\n !Array.isArray(children) &&\n (typeof children === 'string' || typeof children === 'number')\n ) {\n if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {\n const s = String(children);\n const t = el.firstChild as Text;\n if (t.data !== s) t.data = s;\n } else {\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = String(children);\n }\n return;\n }\n\n if (Array.isArray(children)) {\n const normalizedChildren = normalizeComponentChildren(children) as VNode[];\n\n if (\n trySyncScalarChildSequenceInPlace(\n el,\n normalizedChildren,\n rendererReactiveChildDOMHost\n )\n ) {\n keyedElements.delete(el);\n return;\n }\n\n if (hasKeyedVNodeChildren(normalizedChildren)) {\n const oldKeyMap = getOrBuildDomKeyMap(el);\n const newKeyMap = reconcileKeyedChildren(\n el,\n normalizedChildren,\n oldKeyMap\n );\n keyedElements.set(el, newKeyMap);\n return;\n }\n if (isBulkTextFastPathEligible(el, normalizedChildren)) {\n performBulkTextReplace(el, normalizedChildren);\n keyedElements.delete(el);\n return;\n }\n updateUnkeyedChildren(el, normalizedChildren, forceUpdate);\n return;\n }\n\n if (_isDOMElement(children)) {\n updateUnkeyedChildren(el, [children], forceUpdate);\n return;\n }\n\n for (let n = el.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n el.textContent = '';\n const dom = getRendererDOMHost().createDOMNode(children);\n if (dom) el.appendChild(dom);\n}\n\nfunction hasKeyedVNodeChildren(children: VNode[]): boolean {\n for (let i = 0; i < children.length; i++) {\n if (extractKey(children[i]) !== undefined) return true;\n }\n return false;\n}\n\nfunction isEmptyChild(child: unknown): boolean {\n return child === null || child === undefined || child === false;\n}\n\nfunction getOrBuildDomKeyMap(\n parent: Element\n): Map<string | number, Element> | undefined {\n let keyMap = keyedElements.get(parent);\n if (!keyMap) {\n keyMap = new Map<string | number, Element>();\n for (\n let child = parent.firstElementChild;\n child;\n child = child.nextElementSibling\n ) {\n const key = child.getAttribute('data-key');\n if (key !== null) {\n keyMap.set(key, child);\n const numericKey = Number(key);\n if (!Number.isNaN(numericKey)) keyMap.set(numericKey, child);\n }\n }\n if (keyMap.size > 0) keyedElements.set(parent, keyMap);\n }\n return keyMap.size > 0 ? keyMap : undefined;\n}\n\nexport function updateUnkeyedChildren(\n parent: Element,\n newChildren: unknown[],\n forceUpdate = false\n): void {\n const parentNamespace = getParentNamespace(parent);\n const domHost = getRendererDOMHost();\n\n const trySyncComponentChild = (\n currentDom: Element,\n next: DOMElement\n ): Node | null => {\n if (typeof next.type !== 'function') {\n return null;\n }\n\n return domHost.syncComponentElement(\n currentDom,\n next as ElementWithContext,\n next.type as ComponentFunction,\n (((next as DOMElement).props ?? {}) as Record<string, unknown>) || {},\n parentNamespace,\n forceUpdate\n );\n };\n\n const hasText = newChildren.some(\n (c) => typeof c === 'string' || typeof c === 'number'\n );\n const hasElements = newChildren.some((c) => _isDOMElement(c));\n const hasEmptyChildren = newChildren.some(isEmptyChild);\n const hasComponentChildren = newChildren.some(\n (c) => _isDOMElement(c) && typeof (c as DOMElement).type === 'function'\n );\n const hasNonElementDomChildren =\n parent.childNodes.length !== parent.children.length;\n\n if (\n !hasEmptyChildren &&\n !hasText &&\n !hasComponentChildren &&\n !hasNonElementDomChildren &&\n hasElements &&\n parent.children.length === newChildren.length\n ) {\n const c = parent.children;\n for (let i = 0; i < newChildren.length; i++) {\n const next = newChildren[i];\n const current = c[i];\n if (!current || next === undefined) continue;\n if (_isDOMElement(next) && typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(current.tagName, next.type)) {\n domHost.updateElementFromVnode(current, next, true, forceUpdate);\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else if (_isDOMElement(next)) {\n if (trySyncControlBoundaryChild(parent, current, next)) {\n continue;\n }\n\n const synced = trySyncComponentChild(current, next);\n if (synced && synced !== current) {\n teardownNodeSubtree(current);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n return;\n }\n\n const existing = Array.from(parent.children);\n\n if (\n hasText ||\n hasComponentChildren ||\n hasEmptyChildren ||\n hasNonElementDomChildren\n ) {\n const allNodes = Array.from(parent.childNodes);\n const max = Math.max(allNodes.length, newChildren.length);\n\n for (let i = 0; i < max; i++) {\n const currentNode = allNodes[i];\n const next = newChildren[i];\n const nextIsEmpty = isEmptyChild(next);\n\n if (nextIsEmpty && currentNode) {\n teardownNodeSubtree(currentNode);\n currentNode.remove();\n continue;\n }\n\n if (!currentNode && !nextIsEmpty) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.appendChild(dom);\n continue;\n }\n\n if (!currentNode || nextIsEmpty) continue;\n\n if (typeof next === 'string' || typeof next === 'number') {\n if (currentNode.nodeType === 3) {\n (currentNode as Text).data = String(next);\n } else {\n const textNode = document.createTextNode(String(next));\n parent.replaceChild(textNode, currentNode);\n }\n } else if (_isDOMElement(next)) {\n if (currentNode.nodeType === 1) {\n const currentEl = currentNode as Element;\n if (typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(currentEl.tagName, next.type)) {\n domHost.updateElementFromVnode(\n currentEl,\n next,\n true,\n forceUpdate\n );\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(currentEl);\n parent.replaceChild(dom, currentNode);\n }\n }\n } else {\n if (trySyncControlBoundaryChild(parent, currentNode, next)) {\n continue;\n }\n\n const synced = trySyncComponentChild(currentEl, next);\n if (synced && synced !== currentNode) {\n teardownNodeSubtree(currentEl);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(currentEl);\n parent.replaceChild(dom, currentNode);\n }\n }\n }\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.replaceChild(dom, currentNode);\n }\n }\n }\n return;\n }\n\n if (\n newChildren.length === 1 &&\n existing.length === 0 &&\n parent.childNodes.length === 1\n ) {\n const firstNewChild = newChildren[0];\n const firstExisting = parent.firstChild;\n if (\n (typeof firstNewChild === 'string' ||\n typeof firstNewChild === 'number') &&\n firstExisting?.nodeType === 3\n ) {\n (firstExisting as Text).data = String(firstNewChild);\n return;\n }\n }\n\n if (existing.length === 0 && parent.childNodes.length > 0) {\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n parent.textContent = '';\n }\n const max = Math.max(existing.length, newChildren.length);\n\n for (let i = 0; i < max; i++) {\n const current = existing[i];\n const next = newChildren[i];\n const nextIsEmpty = isEmptyChild(next);\n\n if (nextIsEmpty && current) {\n teardownNodeSubtree(current);\n current.remove();\n continue;\n }\n\n if (!current && !nextIsEmpty) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) parent.appendChild(dom);\n continue;\n }\n\n if (!current || nextIsEmpty) continue;\n\n if (typeof next === 'string' || typeof next === 'number') {\n const textNode = document.createTextNode(String(next));\n teardownNodeSubtree(current);\n parent.replaceChild(textNode, current);\n } else if (_isDOMElement(next)) {\n if (typeof next.type === 'string') {\n if (tagsEqualIgnoreCase(current.tagName, next.type)) {\n domHost.updateElementFromVnode(current, next, true, forceUpdate);\n } else {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n } else {\n const synced = trySyncComponentChild(current, next);\n if (synced && synced !== current) {\n teardownNodeSubtree(current);\n } else if (!synced) {\n const dom = domHost.createDOMNode(next, parentNamespace);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n } else {\n const dom = domHost.createDOMNode(next);\n if (dom) {\n teardownNodeSubtree(current);\n parent.replaceChild(dom, current);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,+BAAqD;CAChE,gBAAgB,MAAM,oBACpB,mBAAmB,CAAC,CAAC,cAAc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EAEA,IAAI,CAAC,WAAW,CAAC,aAAa;GAC5B,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;GACvD,IAAI,KAAK,OAAO,YAAY,GAAG;GAC/B;EACF;EAEA,IAAI,CAAC,WAAW,aAAa;EAE7B,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;GACxD,MAAM,WAAW,SAAS,eAAe,OAAO,IAAI,CAAC;GACrD,oBAAoB,OAAO;GAC3B,OAAO,aAAa,UAAU,OAAO;EACvC,OAAO,IAAI,cAAc,IAAI,GAC3B,IAAI,OAAO,KAAK,SAAS,UACvB,IAAI,oBAAoB,QAAQ,SAAS,KAAK,IAAI,GAChD,QAAQ,uBAAuB,SAAS,MAAM,MAAM,WAAW;OAC1D;GACL,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;GACvD,IAAI,KAAK;IACP,oBAAoB,OAAO;IAC3B,OAAO,aAAa,KAAK,OAAO;GAClC;EACF;OACK;GACL,MAAM,SAAS,sBAAsB,SAAS,IAAI;GAClD,IAAI,UAAU,WAAW,SACvB,oBAAoB,OAAO;QACtB,IAAI,CAAC,QAAQ;IAClB,MAAM,MAAM,QAAQ,cAAc,MAAM,eAAe;IACvD,IAAI,KAAK;KACP,oBAAoB,OAAO;KAC3B,OAAO,aAAa,KAAK,OAAO;IAClC;GACF;EACF;OACK;GACL,MAAM,MAAM,QAAQ,cAAc,IAAI;GACtC,IAAI,KAAK;IACP,oBAAoB,OAAO;IAC3B,OAAO,aAAa,KAAK,OAAO;GAClC;EACF;CACF;AACF"}
|
|
@@ -1,7 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isDevelopmentEnvironment } from "../common/env.js";
|
|
2
|
+
import { logger } from "../common/logger.js";
|
|
3
|
+
import { createBoundaryReset, reportBoundaryError } from "../runtime/error-boundary.js";
|
|
4
|
+
import "../runtime/index.js";
|
|
2
5
|
import { getRendererDOMHost } from "./dom-host.js";
|
|
3
|
-
import { createBoundaryReset, reportBoundaryError, resolveErrorBoundaryFallback } from "../components/error-boundary.js";
|
|
4
6
|
//#region src/renderer/error-boundary-dom.ts
|
|
7
|
+
function getBoundaryMessage(error) {
|
|
8
|
+
if (error instanceof Error) return error.message || error.name || "Unknown error";
|
|
9
|
+
if (typeof error === "string") return error;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.stringify(error);
|
|
12
|
+
} catch {
|
|
13
|
+
return String(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createDefaultFallbackNode(error, reset) {
|
|
17
|
+
const message = getBoundaryMessage(error);
|
|
18
|
+
const wrapper = document.createElement("div");
|
|
19
|
+
wrapper.setAttribute("role", "alert");
|
|
20
|
+
wrapper.setAttribute("data-askr-error-boundary", "true");
|
|
21
|
+
wrapper.style.boxSizing = "border-box";
|
|
22
|
+
wrapper.style.padding = "1rem";
|
|
23
|
+
wrapper.style.border = "1px solid currentColor";
|
|
24
|
+
wrapper.style.borderRadius = "0.75rem";
|
|
25
|
+
wrapper.style.display = "grid";
|
|
26
|
+
wrapper.style.gap = "0.75rem";
|
|
27
|
+
wrapper.style.maxWidth = "100%";
|
|
28
|
+
const title = document.createElement("strong");
|
|
29
|
+
title.textContent = "Something went wrong while rendering this view.";
|
|
30
|
+
const summary = document.createElement("p");
|
|
31
|
+
summary.textContent = "The app recovered into a visible fallback so the error is not hidden in the console.";
|
|
32
|
+
summary.style.margin = "0";
|
|
33
|
+
const details = document.createElement("details");
|
|
34
|
+
details.open = isDevelopmentEnvironment();
|
|
35
|
+
const detailsSummary = document.createElement("summary");
|
|
36
|
+
detailsSummary.textContent = "Error details";
|
|
37
|
+
const pre = document.createElement("pre");
|
|
38
|
+
pre.textContent = message;
|
|
39
|
+
pre.style.margin = "0";
|
|
40
|
+
pre.style.whiteSpace = "pre-wrap";
|
|
41
|
+
pre.style.wordBreak = "break-word";
|
|
42
|
+
const button = document.createElement("button");
|
|
43
|
+
button.type = "button";
|
|
44
|
+
button.textContent = "Try again";
|
|
45
|
+
button.addEventListener("click", () => reset());
|
|
46
|
+
details.append(detailsSummary, pre);
|
|
47
|
+
wrapper.append(title, summary, details, button);
|
|
48
|
+
return wrapper;
|
|
49
|
+
}
|
|
50
|
+
function resolveErrorBoundaryFallback(fallback, error, reset) {
|
|
51
|
+
if (typeof fallback === "function") return fallback(error, reset);
|
|
52
|
+
return fallback ?? createDefaultFallbackNode(error, reset);
|
|
53
|
+
}
|
|
5
54
|
function createErrorBoundaryElement(node, props, parentNamespace) {
|
|
6
55
|
const boundaryState = node.__instance?.errorBoundaryState ?? null;
|
|
7
56
|
const reset = node.__instance ? createBoundaryReset(node.__instance) : () => {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary-dom.js","names":[],"sources":["../../src/renderer/error-boundary-dom.ts"],"sourcesContent":["import { logger } from '../
|
|
1
|
+
{"version":3,"file":"error-boundary-dom.js","names":[],"sources":["../../src/renderer/error-boundary-dom.ts"],"sourcesContent":["import {\n type ErrorBoundaryFallbackValue,\n type ErrorBoundaryProps,\n} from '../common/error-boundary';\nimport { isDevelopmentEnvironment } from '../common/env';\nimport { logger } from '../common/logger';\nimport { createBoundaryReset, reportBoundaryError } from '../runtime';\nimport type { ComponentInstance } from '../runtime';\nimport { getRendererDOMHost } from './dom-host';\nimport type { DOMElement } from './types';\n\nexport type ErrorBoundaryVNode = DOMElement & {\n __instance?: ComponentInstance;\n};\n\nfunction getBoundaryMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message || error.name || 'Unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n}\n\nfunction createDefaultFallbackNode(error: unknown, reset: () => void): Node {\n const message = getBoundaryMessage(error);\n const wrapper = document.createElement('div');\n wrapper.setAttribute('role', 'alert');\n wrapper.setAttribute('data-askr-error-boundary', 'true');\n wrapper.style.boxSizing = 'border-box';\n wrapper.style.padding = '1rem';\n wrapper.style.border = '1px solid currentColor';\n wrapper.style.borderRadius = '0.75rem';\n wrapper.style.display = 'grid';\n wrapper.style.gap = '0.75rem';\n wrapper.style.maxWidth = '100%';\n\n const title = document.createElement('strong');\n title.textContent = 'Something went wrong while rendering this view.';\n\n const summary = document.createElement('p');\n summary.textContent =\n 'The app recovered into a visible fallback so the error is not hidden in the console.';\n summary.style.margin = '0';\n\n const details = document.createElement('details');\n details.open = isDevelopmentEnvironment();\n\n const detailsSummary = document.createElement('summary');\n detailsSummary.textContent = 'Error details';\n\n const pre = document.createElement('pre');\n pre.textContent = message;\n pre.style.margin = '0';\n pre.style.whiteSpace = 'pre-wrap';\n pre.style.wordBreak = 'break-word';\n\n const button = document.createElement('button');\n button.type = 'button';\n button.textContent = 'Try again';\n button.addEventListener('click', () => reset());\n\n details.append(detailsSummary, pre);\n wrapper.append(title, summary, details, button);\n return wrapper;\n}\n\nfunction resolveErrorBoundaryFallback(\n fallback: ErrorBoundaryProps['fallback'],\n error: unknown,\n reset: () => void\n): ErrorBoundaryFallbackValue {\n if (typeof fallback === 'function') {\n return fallback(error, reset);\n }\n\n return fallback ?? createDefaultFallbackNode(error, reset);\n}\n\nexport function createErrorBoundaryElement(\n node: ErrorBoundaryVNode,\n props: Record<string, unknown>,\n parentNamespace?: string\n): Node {\n const boundaryState = node.__instance?.errorBoundaryState ?? null;\n const reset = node.__instance\n ? createBoundaryReset(node.__instance)\n : () => {};\n const fallback = props.fallback as ErrorBoundaryProps['fallback'];\n const children = props.children as ErrorBoundaryProps['children'];\n const domHost = getRendererDOMHost();\n\n if (boundaryState?.error != null) {\n const fallbackValue = resolveErrorBoundaryFallback(\n fallback,\n boundaryState.error,\n reset\n );\n if (fallbackValue instanceof Node) {\n return fallbackValue;\n }\n const fallbackDom = domHost.createDOMNode(fallbackValue, parentNamespace);\n return fallbackDom ?? document.createComment('');\n }\n\n try {\n const dom = domHost.createDOMNode(children, parentNamespace);\n return dom ?? document.createComment('');\n } catch (error) {\n if (node.__instance) {\n reportBoundaryError(\n node.__instance,\n error,\n props.onError as ((next: unknown) => void) | undefined\n );\n } else {\n logger.error('[Askr] ErrorBoundary caught render error:', error);\n }\n\n const fallbackValue = resolveErrorBoundaryFallback(fallback, error, reset);\n if (fallbackValue instanceof Node) {\n return fallbackValue;\n }\n const fallbackDom = domHost.createDOMNode(fallbackValue, parentNamespace);\n return fallbackDom ?? document.createComment('');\n }\n}\n"],"mappings":";;;;;;AAeA,SAAS,mBAAmB,OAAwB;CAClD,IAAI,iBAAiB,OACnB,OAAO,MAAM,WAAW,MAAM,QAAQ;CAGxC,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;AAEA,SAAS,0BAA0B,OAAgB,OAAyB;CAC1E,MAAM,UAAU,mBAAmB,KAAK;CACxC,MAAM,UAAU,SAAS,cAAc,KAAK;CAC5C,QAAQ,aAAa,QAAQ,OAAO;CACpC,QAAQ,aAAa,4BAA4B,MAAM;CACvD,QAAQ,MAAM,YAAY;CAC1B,QAAQ,MAAM,UAAU;CACxB,QAAQ,MAAM,SAAS;CACvB,QAAQ,MAAM,eAAe;CAC7B,QAAQ,MAAM,UAAU;CACxB,QAAQ,MAAM,MAAM;CACpB,QAAQ,MAAM,WAAW;CAEzB,MAAM,QAAQ,SAAS,cAAc,QAAQ;CAC7C,MAAM,cAAc;CAEpB,MAAM,UAAU,SAAS,cAAc,GAAG;CAC1C,QAAQ,cACN;CACF,QAAQ,MAAM,SAAS;CAEvB,MAAM,UAAU,SAAS,cAAc,SAAS;CAChD,QAAQ,OAAO,yBAAyB;CAExC,MAAM,iBAAiB,SAAS,cAAc,SAAS;CACvD,eAAe,cAAc;CAE7B,MAAM,MAAM,SAAS,cAAc,KAAK;CACxC,IAAI,cAAc;CAClB,IAAI,MAAM,SAAS;CACnB,IAAI,MAAM,aAAa;CACvB,IAAI,MAAM,YAAY;CAEtB,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,OAAO,OAAO;CACd,OAAO,cAAc;CACrB,OAAO,iBAAiB,eAAe,MAAM,CAAC;CAE9C,QAAQ,OAAO,gBAAgB,GAAG;CAClC,QAAQ,OAAO,OAAO,SAAS,SAAS,MAAM;CAC9C,OAAO;AACT;AAEA,SAAS,6BACP,UACA,OACA,OAC4B;CAC5B,IAAI,OAAO,aAAa,YACtB,OAAO,SAAS,OAAO,KAAK;CAG9B,OAAO,YAAY,0BAA0B,OAAO,KAAK;AAC3D;AAEA,SAAgB,2BACd,MACA,OACA,iBACM;CACN,MAAM,gBAAgB,KAAK,YAAY,sBAAsB;CAC7D,MAAM,QAAQ,KAAK,aACf,oBAAoB,KAAK,UAAU,UAC7B,CAAC;CACX,MAAM,WAAW,MAAM;CACvB,MAAM,WAAW,MAAM;CACvB,MAAM,UAAU,mBAAmB;CAEnC,IAAI,eAAe,SAAS,MAAM;EAChC,MAAM,gBAAgB,6BACpB,UACA,cAAc,OACd,KACF;EACA,IAAI,yBAAyB,MAC3B,OAAO;EAGT,OADoB,QAAQ,cAAc,eAAe,eAClD,KAAe,SAAS,cAAc,EAAE;CACjD;CAEA,IAAI;EAEF,OADY,QAAQ,cAAc,UAAU,eACrC,KAAO,SAAS,cAAc,EAAE;CACzC,SAAS,OAAO;EACd,IAAI,KAAK,YACP,oBACE,KAAK,YACL,OACA,MAAM,OACR;OAEA,OAAO,MAAM,6CAA6C,KAAK;EAGjE,MAAM,gBAAgB,6BAA6B,UAAU,OAAO,KAAK;EACzE,IAAI,yBAAyB,MAC3B,OAAO;EAGT,OADoB,QAAQ,cAAc,eAAe,eAClD,KAAe,SAAS,cAAc,EAAE;CACjD;AACF"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
|
|
2
2
|
import "./types.js";
|
|
3
3
|
import { getRuntimeEnv } from "../common/env.js";
|
|
4
|
-
import { logger } from "../
|
|
4
|
+
import { logger } from "../common/logger.js";
|
|
5
5
|
import { Fragment } from "../common/jsx.js";
|
|
6
6
|
import { incDevCounter, setDevValue } from "../runtime/dev-namespace.js";
|
|
7
|
+
import { evaluateCaseState, evaluateShowState } from "../runtime/control.js";
|
|
8
|
+
import { evaluateForState } from "../runtime/for-internal.js";
|
|
9
|
+
import "../runtime/index.js";
|
|
7
10
|
import { elementListeners } from "./cleanup.js";
|
|
8
11
|
import "./env.js";
|
|
9
12
|
import { createWrappedHandler, extractKey, getEventListenerKey, getEventListenerOptions, parseEventProp, setRenderedAttribute, tagNamesEqualIgnoreCase as tagNamesEqualIgnoreCase$1, writeElementClassName } from "./utils.js";
|
|
10
13
|
import { keyedElements } from "./keyed.js";
|
|
11
|
-
import { evaluateForState } from "../runtime/for-internal.js";
|
|
12
|
-
import "../runtime/for.js";
|
|
13
|
-
import { evaluateCaseState, evaluateShowState } from "../runtime/control.js";
|
|
14
14
|
import { createElementForNamespace, getParentNamespace } from "./namespaces.js";
|
|
15
15
|
import { commitForBoundaryChildren } from "./boundaries.js";
|
|
16
|
-
import {
|
|
16
|
+
import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
|
|
17
|
+
import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
|
|
17
18
|
import { getRendererDOMHost } from "./dom-host.js";
|
|
18
19
|
import { reconcileKeyedChildren } from "./reconcile.js";
|
|
19
20
|
import { updateUnkeyedChildren } from "./element-children.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate-reconcile.js","names":["sharedTagNamesEqualIgnoreCase"],"sources":["../../src/renderer/evaluate-reconcile.ts"],"sourcesContent":["import { logger } from '../dev/logger';\nimport { getRuntimeEnv } from './env';\nimport type { Props } from '../common/props';\nimport type { ComponentInstance } from '../runtime/component-contracts';\nimport { elementListeners } from './cleanup';\nimport { keyedElements } from './keyed';\nimport { createElementForNamespace, getParentNamespace } from './namespaces';\nimport { reconcileKeyedChildren } from './reconcile';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport { __FOR_BOUNDARY__ } from '../common/vnode';\nimport { evaluateForState } from '../runtime/for';\nimport {\n evaluateCaseState,\n evaluateShowState,\n type ControlBoundaryState,\n} from '../runtime/control';\nimport { commitForBoundaryChildren } from './boundaries';\nimport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n} from './children';\nimport { getRendererDOMHost } from './dom-host';\nimport { updateUnkeyedChildren } from './element-children';\nimport { setDevValue, incDevCounter } from '../runtime/dev-namespace';\nimport { Fragment } from '../common/jsx';\nimport {\n createWrappedHandler,\n extractKey,\n getEventListenerKey,\n getEventListenerOptions,\n parseEventProp,\n setRenderedAttribute,\n tagNamesEqualIgnoreCase as sharedTagNamesEqualIgnoreCase,\n writeElementClassName,\n} from './utils';\nimport { runRetainedElementUpdate } from './retained-element-rollback';\n\ntype ComponentHostElement = Element & {\n __ASKR_INSTANCE?: ComponentInstance;\n __ASKR_INSTANCES?: ComponentInstance[];\n};\n\nexport function getRetainedHostOwnerChain(\n host: ComponentHostElement,\n owner: ComponentInstance\n): ComponentInstance[] {\n const instances = host.__ASKR_INSTANCES ?? [];\n const ownerIndex = instances.indexOf(owner);\n\n return ownerIndex >= 0 ? instances.slice(ownerIndex) : [owner];\n}\n\nexport function retainHostOwnerChain(\n host: Element,\n owner: ComponentInstance,\n retainedInstances: ComponentInstance[]\n): void {\n const componentHost = host as ComponentHostElement;\n const existing = componentHost.__ASKR_INSTANCES ?? [];\n const nextInstances = [...existing];\n\n for (const instance of retainedInstances) {\n if (!nextInstances.includes(instance)) {\n nextInstances.push(instance);\n }\n }\n\n componentHost.__ASKR_INSTANCES = nextInstances;\n componentHost.__ASKR_INSTANCE = owner;\n}\n\ninterface SimpleTextResult {\n isSimple: true;\n text: string;\n}\n\ninterface NotSimpleTextResult {\n isSimple: false;\n text?: undefined;\n}\n\ntype TextCheckResult = SimpleTextResult | NotSimpleTextResult;\n\nexport function tagNamesEqualIgnoreCase(a: string, b: string): boolean {\n return sharedTagNamesEqualIgnoreCase(a, b);\n}\n\nfunction checkSimpleText(vnodeChildren: unknown): TextCheckResult {\n if (!Array.isArray(vnodeChildren)) {\n if (\n typeof vnodeChildren === 'string' ||\n typeof vnodeChildren === 'number'\n ) {\n return { isSimple: true, text: String(vnodeChildren) };\n }\n } else if (vnodeChildren.length === 1) {\n const child = vnodeChildren[0];\n if (typeof child === 'string' || typeof child === 'number') {\n return { isSimple: true, text: String(child) };\n }\n }\n return { isSimple: false };\n}\n\nfunction tryUpdateTextInPlace(element: Element, text: string): boolean {\n if (element.childNodes.length === 1 && element.firstChild?.nodeType === 3) {\n (element.firstChild as Text).data = text;\n return true;\n }\n return false;\n}\n\nfunction buildKeyMapFromDOM(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n for (\n let child = parent.firstElementChild;\n child;\n child = child.nextElementSibling\n ) {\n const k = child.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, child);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, child);\n }\n }\n return keyMap;\n}\n\nfunction getOrBuildKeyMap(\n parent: Element\n): Map<string | number, Element> | undefined {\n let keyMap = keyedElements.get(parent);\n if (!keyMap) {\n keyMap = buildKeyMapFromDOM(parent);\n if (keyMap.size > 0) {\n keyedElements.set(parent, keyMap);\n }\n }\n return keyMap.size > 0 ? keyMap : undefined;\n}\n\nfunction hasKeyedChildren(children: unknown[]): boolean {\n for (let i = 0; i < children.length; i++) {\n if (extractKey(children[i]) !== undefined) return true;\n }\n return false;\n}\n\nfunction trackBulkTextStats(\n stats: ReturnType<typeof performBulkTextReplace>\n): void {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n setDevValue('__LAST_BULK_TEXT_FASTPATH_STATS', stats);\n incDevCounter('bulkTextHits');\n } catch {\n // ignore\n }\n }\n}\n\nfunction trackBulkTextMiss(): void {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n incDevCounter('bulkTextMisses');\n } catch {\n // ignore\n }\n }\n}\n\nfunction reconcileKeyed(\n parent: Element,\n children: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): void {\n if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE === '1') {\n const result = tryForcedBulkKeyedPath(parent, children);\n if (result) return;\n }\n\n const newKeyMap = reconcileKeyedChildren(parent, children, oldKeyMap);\n keyedElements.set(parent, newKeyMap);\n}\n\nfunction tryForcedBulkKeyedPath(parent: Element, children: VNode[]): boolean {\n try {\n const keyedVnodes: Array<{ key: string | number; vnode: VNode }> = [];\n for (const child of children) {\n const key = extractKey(child);\n if (_isDOMElement(child) && key !== undefined) {\n keyedVnodes.push({\n key,\n vnode: child,\n });\n }\n }\n\n if (keyedVnodes.length === 0 || keyedVnodes.length !== children.length) {\n return false;\n }\n\n const fastPathEnv = getRuntimeEnv();\n if (\n fastPathEnv.ASKR_FASTPATH_DEBUG === '1' ||\n fastPathEnv.ASKR_FASTPATH_DEBUG === 'true'\n ) {\n logger.warn(\n '[Askr][FASTPATH] forced positional bulk keyed reuse (evaluate-level)'\n );\n }\n\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n\n const statsEnv = getRuntimeEnv();\n if (\n statsEnv.NODE_ENV !== 'production' ||\n statsEnv.ASKR_FASTPATH_DEBUG === '1'\n ) {\n try {\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n incDevCounter('bulkKeyedPositionalForced');\n } catch {\n // ignore\n }\n }\n\n const newMap = buildKeyMapFromDOM(parent);\n keyedElements.set(parent, newMap);\n return true;\n } catch (err) {\n const fallbackEnv = getRuntimeEnv();\n if (\n fallbackEnv.ASKR_FASTPATH_DEBUG === '1' ||\n fallbackEnv.ASKR_FASTPATH_DEBUG === 'true'\n ) {\n logger.warn(\n '[Askr][FASTPATH] forced bulk path failed, falling back',\n err\n );\n }\n return false;\n }\n}\n\nfunction reconcileUnkeyed(parent: Element, children: VNode[]): void {\n if (isBulkTextFastPathEligible(parent, children)) {\n const stats = performBulkTextReplace(parent, children);\n trackBulkTextStats(stats);\n } else {\n trackBulkTextMiss();\n updateUnkeyedChildren(parent, children);\n }\n keyedElements.delete(parent);\n}\n\nexport function updateForBoundaryChildren(\n element: Element,\n forVnode: DOMElement\n): void {\n const controlState =\n forVnode._controlState ??\n (forVnode._forState as ControlBoundaryState | undefined);\n if (!controlState) return;\n\n const childrenVNodes =\n controlState.kind === 'for'\n ? evaluateForState(controlState)\n : controlState.kind === 'show'\n ? evaluateShowState(controlState)\n : evaluateCaseState(controlState);\n commitForBoundaryChildren(element, controlState, childrenVNodes);\n}\n\nexport function updateElementChildren(\n element: Element,\n vnodeChildren: unknown,\n cleanupRangeNode: (node: Node) => void\n): void {\n const domHost = getRendererDOMHost();\n\n if (vnodeChildren === null || vnodeChildren === undefined) {\n for (let n = element.firstChild; n; ) {\n const next = n.nextSibling;\n cleanupRangeNode(n);\n n = next;\n }\n element.textContent = '';\n keyedElements.delete(element);\n return;\n }\n\n if (\n !Array.isArray(vnodeChildren) &&\n _isDOMElement(vnodeChildren) &&\n (vnodeChildren as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateForBoundaryChildren(element, vnodeChildren as DOMElement);\n return;\n }\n\n if (!Array.isArray(vnodeChildren) && isFragment(vnodeChildren)) {\n updateElementChildren(\n element,\n getFragmentChildren(vnodeChildren),\n cleanupRangeNode\n );\n return;\n }\n\n if (!Array.isArray(vnodeChildren)) {\n for (let n = element.firstChild; n; ) {\n const next = n.nextSibling;\n cleanupRangeNode(n);\n n = next;\n }\n element.textContent = '';\n const dom = domHost.createDOMNode(vnodeChildren);\n if (dom) element.appendChild(dom);\n keyedElements.delete(element);\n return;\n }\n\n if (\n vnodeChildren.length === 1 &&\n _isDOMElement(vnodeChildren[0]) &&\n (vnodeChildren[0] as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateForBoundaryChildren(element, vnodeChildren[0] as DOMElement);\n return;\n }\n\n if (hasKeyedChildren(vnodeChildren)) {\n const oldKeyMap = getOrBuildKeyMap(element);\n try {\n reconcileKeyed(element, vnodeChildren, oldKeyMap);\n } catch {\n const newKeyMap = reconcileKeyedChildren(\n element,\n vnodeChildren,\n oldKeyMap\n );\n keyedElements.set(element, newKeyMap);\n }\n } else {\n reconcileUnkeyed(element, vnodeChildren);\n }\n}\n\nexport function smartUpdateElement(\n element: Element,\n vnode: DOMElement,\n cleanupRangeNode: (node: Node) => void\n): void {\n const hadVNodeKey = Object.prototype.hasOwnProperty.call(vnode, 'key');\n const previousVNodeKey = vnode.key;\n\n runRetainedElementUpdate(\n element,\n cleanupRangeNode,\n () => applySmartUpdateElement(element, vnode, cleanupRangeNode),\n () => {\n if (hadVNodeKey) vnode.key = previousVNodeKey;\n else delete vnode.key;\n }\n );\n}\n\nfunction applySmartUpdateElement(\n element: Element,\n vnode: DOMElement,\n cleanupRangeNode: (node: Node) => void\n): void {\n const domHost = getRendererDOMHost();\n\n if (vnode.key == null && element.hasAttribute('data-key')) {\n const existingKey = element.getAttribute('data-key');\n if (existingKey !== null) {\n const numericKey = Number(existingKey);\n vnode.key = Number.isNaN(numericKey) ? existingKey : numericKey;\n }\n }\n\n let vnodeChildren = vnode.props?.children ?? vnode.children;\n\n if (\n vnodeChildren &&\n _isDOMElement(vnodeChildren) &&\n (vnodeChildren as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateElementChildren(element, vnodeChildren, cleanupRangeNode);\n domHost.updateElementFromVnode(element, vnode, false);\n return;\n }\n\n if (vnodeChildren && !Array.isArray(vnodeChildren)) {\n vnodeChildren = [vnodeChildren];\n }\n\n const textCheck = checkSimpleText(vnodeChildren);\n\n if (textCheck.isSimple && tryUpdateTextInPlace(element, textCheck.text)) {\n // Text updated in place.\n } else {\n updateElementChildren(element, vnodeChildren, cleanupRangeNode);\n }\n\n domHost.updateElementFromVnode(element, vnode, false);\n}\n\nexport function processFragmentChildren(\n target: Element,\n childArray: unknown[],\n cleanupRangeNode: (node: Node) => void\n): void {\n updateElementChildren(target, childArray, cleanupRangeNode);\n}\n\nfunction applyPropsToElement(el: Element, props: Props): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'children' || key === 'key') continue;\n if (value === undefined || value === null || value === false) continue;\n\n if (key === 'ref') {\n applyRef(el, value);\n continue;\n }\n\n const eventProp = parseEventProp(key);\n if (eventProp) {\n const { eventName, capture } = eventProp;\n const wrappedHandler = createWrappedHandler(value as EventListener, true);\n const options = getEventListenerOptions(eventName, capture);\n const listenerKey = getEventListenerKey(eventName, capture);\n\n if (options !== undefined)\n el.addEventListener(eventName, wrappedHandler, options);\n else el.addEventListener(eventName, wrappedHandler);\n\n if (!elementListeners.has(el)) elementListeners.set(el, new Map());\n elementListeners.get(el)!.set(listenerKey, {\n handler: wrappedHandler,\n original: value as EventListener,\n eventName,\n options,\n });\n continue;\n }\n\n if (key === 'class' || key === 'className') {\n writeElementClassName(el, String(value));\n } else if (key === 'value' || key === 'checked') {\n (el as HTMLElement & Props)[key] = value;\n } else {\n setRenderedAttribute(el, key, String(value));\n }\n }\n}\n\ntype Ref<T> =\n | ((value: T | null) => void)\n | { current: T | null }\n | null\n | undefined;\n\nfunction applyRef<T>(el: T, ref: unknown): void {\n const r = ref as Ref<T>;\n if (!r) return;\n if (typeof r === 'function') {\n r(el);\n return;\n }\n try {\n (r as { current: T | null }).current = el;\n } catch {\n // Ignore write failures.\n }\n}\n\nexport function tryFirstRenderKeyedChildren(\n target: Element,\n vnode: DOMElement\n): boolean {\n const children = vnode.children;\n if (!Array.isArray(children) || !hasKeyedChildren(children)) {\n return false;\n }\n\n const el = createElementForNamespace(\n vnode.type as string,\n getParentNamespace(target)\n );\n target.appendChild(el);\n\n applyPropsToElement(el, vnode.props || {});\n\n const newKeyMap = reconcileKeyedChildren(el, children, undefined);\n keyedElements.set(el, newKeyMap);\n return true;\n}\n\nexport function isFragment(vnode: unknown): vnode is DOMElement {\n return (\n _isDOMElement(vnode) &&\n typeof (vnode as DOMElement).type === 'symbol' &&\n ((vnode as DOMElement).type === Fragment ||\n String((vnode as DOMElement).type) === 'Symbol(askr.fragment)')\n );\n}\n\nexport function getFragmentChildren(vnode: DOMElement): unknown[] {\n const fragmentChildren = vnode.props?.children ?? vnode.children ?? [];\n return Array.isArray(fragmentChildren)\n ? fragmentChildren\n : [fragmentChildren];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,0BACd,MACA,OACqB;CACrB,MAAM,YAAY,KAAK,oBAAoB,CAAC;CAC5C,MAAM,aAAa,UAAU,QAAQ,KAAK;CAE1C,OAAO,cAAc,IAAI,UAAU,MAAM,UAAU,IAAI,CAAC,KAAK;AAC/D;AAEA,SAAgB,qBACd,MACA,OACA,mBACM;CACN,MAAM,gBAAgB;CAEtB,MAAM,gBAAgB,CAAC,GADN,cAAc,oBAAoB,CAAC,CAClB;CAElC,KAAK,MAAM,YAAY,mBACrB,IAAI,CAAC,cAAc,SAAS,QAAQ,GAClC,cAAc,KAAK,QAAQ;CAI/B,cAAc,mBAAmB;CACjC,cAAc,kBAAkB;AAClC;AAcA,SAAgB,wBAAwB,GAAW,GAAoB;CACrE,OAAOA,0BAA8B,GAAG,CAAC;AAC3C;AAEA,SAAS,gBAAgB,eAAyC;CAChE,IAAI,CAAC,MAAM,QAAQ,aAAa,GAC9B;MACE,OAAO,kBAAkB,YACzB,OAAO,kBAAkB,UAEzB,OAAO;GAAE,UAAU;GAAM,MAAM,OAAO,aAAa;EAAE;CACvD,OACK,IAAI,cAAc,WAAW,GAAG;EACrC,MAAM,QAAQ,cAAc;EAC5B,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,OAAO;GAAE,UAAU;GAAM,MAAM,OAAO,KAAK;EAAE;CAEjD;CACA,OAAO,EAAE,UAAU,MAAM;AAC3B;AAEA,SAAS,qBAAqB,SAAkB,MAAuB;CACrE,IAAI,QAAQ,WAAW,WAAW,KAAK,QAAQ,YAAY,aAAa,GAAG;E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AAE7C;AAEA,SAAgB,oBAAoB,OAA8B;CAChE,MAAM,mBAAmB,MAAM,OAAO,YAAY,MAAM,YAAY,CAAC;CACrE,OAAO,MAAM,QAAQ,gBAAgB,IACjC,mBACA,CAAC,gBAAgB;AACvB"}
|
|
1
|
+
{"version":3,"file":"evaluate-reconcile.js","names":["sharedTagNamesEqualIgnoreCase"],"sources":["../../src/renderer/evaluate-reconcile.ts"],"sourcesContent":["import { logger } from '../common/logger';\nimport { getRuntimeEnv } from './env';\nimport type { Props } from '../common/props';\nimport type { ComponentInstance } from '../runtime';\nimport { elementListeners } from './cleanup';\nimport { keyedElements } from './keyed';\nimport { createElementForNamespace, getParentNamespace } from './namespaces';\nimport { reconcileKeyedChildren } from './reconcile';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport { __FOR_BOUNDARY__ } from '../common/vnode';\nimport { evaluateForState } from '../runtime';\nimport {\n evaluateCaseState,\n evaluateShowState,\n type ControlBoundaryState,\n} from '../runtime';\nimport { commitForBoundaryChildren } from './boundaries';\nimport {\n isBulkTextFastPathEligible,\n performBulkPositionalKeyedTextUpdate,\n performBulkTextReplace,\n} from './children';\nimport { getRendererDOMHost } from './dom-host';\nimport { updateUnkeyedChildren } from './element-children';\nimport { setDevValue, incDevCounter } from '../runtime';\nimport { Fragment } from '../common/jsx';\nimport {\n createWrappedHandler,\n extractKey,\n getEventListenerKey,\n getEventListenerOptions,\n parseEventProp,\n setRenderedAttribute,\n tagNamesEqualIgnoreCase as sharedTagNamesEqualIgnoreCase,\n writeElementClassName,\n} from './utils';\nimport { runRetainedElementUpdate } from './retained-element-rollback';\n\ntype ComponentHostElement = Element & {\n __ASKR_INSTANCE?: ComponentInstance;\n __ASKR_INSTANCES?: ComponentInstance[];\n};\n\nexport function getRetainedHostOwnerChain(\n host: ComponentHostElement,\n owner: ComponentInstance\n): ComponentInstance[] {\n const instances = host.__ASKR_INSTANCES ?? [];\n const ownerIndex = instances.indexOf(owner);\n\n return ownerIndex >= 0 ? instances.slice(ownerIndex) : [owner];\n}\n\nexport function retainHostOwnerChain(\n host: Element,\n owner: ComponentInstance,\n retainedInstances: ComponentInstance[]\n): void {\n const componentHost = host as ComponentHostElement;\n const existing = componentHost.__ASKR_INSTANCES ?? [];\n const nextInstances = [...existing];\n\n for (const instance of retainedInstances) {\n if (!nextInstances.includes(instance)) {\n nextInstances.push(instance);\n }\n }\n\n componentHost.__ASKR_INSTANCES = nextInstances;\n componentHost.__ASKR_INSTANCE = owner;\n}\n\ninterface SimpleTextResult {\n isSimple: true;\n text: string;\n}\n\ninterface NotSimpleTextResult {\n isSimple: false;\n text?: undefined;\n}\n\ntype TextCheckResult = SimpleTextResult | NotSimpleTextResult;\n\nexport function tagNamesEqualIgnoreCase(a: string, b: string): boolean {\n return sharedTagNamesEqualIgnoreCase(a, b);\n}\n\nfunction checkSimpleText(vnodeChildren: unknown): TextCheckResult {\n if (!Array.isArray(vnodeChildren)) {\n if (\n typeof vnodeChildren === 'string' ||\n typeof vnodeChildren === 'number'\n ) {\n return { isSimple: true, text: String(vnodeChildren) };\n }\n } else if (vnodeChildren.length === 1) {\n const child = vnodeChildren[0];\n if (typeof child === 'string' || typeof child === 'number') {\n return { isSimple: true, text: String(child) };\n }\n }\n return { isSimple: false };\n}\n\nfunction tryUpdateTextInPlace(element: Element, text: string): boolean {\n if (element.childNodes.length === 1 && element.firstChild?.nodeType === 3) {\n (element.firstChild as Text).data = text;\n return true;\n }\n return false;\n}\n\nfunction buildKeyMapFromDOM(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n for (\n let child = parent.firstElementChild;\n child;\n child = child.nextElementSibling\n ) {\n const k = child.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, child);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, child);\n }\n }\n return keyMap;\n}\n\nfunction getOrBuildKeyMap(\n parent: Element\n): Map<string | number, Element> | undefined {\n let keyMap = keyedElements.get(parent);\n if (!keyMap) {\n keyMap = buildKeyMapFromDOM(parent);\n if (keyMap.size > 0) {\n keyedElements.set(parent, keyMap);\n }\n }\n return keyMap.size > 0 ? keyMap : undefined;\n}\n\nfunction hasKeyedChildren(children: unknown[]): boolean {\n for (let i = 0; i < children.length; i++) {\n if (extractKey(children[i]) !== undefined) return true;\n }\n return false;\n}\n\nfunction trackBulkTextStats(\n stats: ReturnType<typeof performBulkTextReplace>\n): void {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n setDevValue('__LAST_BULK_TEXT_FASTPATH_STATS', stats);\n incDevCounter('bulkTextHits');\n } catch {\n // ignore\n }\n }\n}\n\nfunction trackBulkTextMiss(): void {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n incDevCounter('bulkTextMisses');\n } catch {\n // ignore\n }\n }\n}\n\nfunction reconcileKeyed(\n parent: Element,\n children: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): void {\n if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE === '1') {\n const result = tryForcedBulkKeyedPath(parent, children);\n if (result) return;\n }\n\n const newKeyMap = reconcileKeyedChildren(parent, children, oldKeyMap);\n keyedElements.set(parent, newKeyMap);\n}\n\nfunction tryForcedBulkKeyedPath(parent: Element, children: VNode[]): boolean {\n try {\n const keyedVnodes: Array<{ key: string | number; vnode: VNode }> = [];\n for (const child of children) {\n const key = extractKey(child);\n if (_isDOMElement(child) && key !== undefined) {\n keyedVnodes.push({\n key,\n vnode: child,\n });\n }\n }\n\n if (keyedVnodes.length === 0 || keyedVnodes.length !== children.length) {\n return false;\n }\n\n const fastPathEnv = getRuntimeEnv();\n if (\n fastPathEnv.ASKR_FASTPATH_DEBUG === '1' ||\n fastPathEnv.ASKR_FASTPATH_DEBUG === 'true'\n ) {\n logger.warn(\n '[Askr][FASTPATH] forced positional bulk keyed reuse (evaluate-level)'\n );\n }\n\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n\n const statsEnv = getRuntimeEnv();\n if (\n statsEnv.NODE_ENV !== 'production' ||\n statsEnv.ASKR_FASTPATH_DEBUG === '1'\n ) {\n try {\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n incDevCounter('bulkKeyedPositionalForced');\n } catch {\n // ignore\n }\n }\n\n const newMap = buildKeyMapFromDOM(parent);\n keyedElements.set(parent, newMap);\n return true;\n } catch (err) {\n const fallbackEnv = getRuntimeEnv();\n if (\n fallbackEnv.ASKR_FASTPATH_DEBUG === '1' ||\n fallbackEnv.ASKR_FASTPATH_DEBUG === 'true'\n ) {\n logger.warn(\n '[Askr][FASTPATH] forced bulk path failed, falling back',\n err\n );\n }\n return false;\n }\n}\n\nfunction reconcileUnkeyed(parent: Element, children: VNode[]): void {\n if (isBulkTextFastPathEligible(parent, children)) {\n const stats = performBulkTextReplace(parent, children);\n trackBulkTextStats(stats);\n } else {\n trackBulkTextMiss();\n updateUnkeyedChildren(parent, children);\n }\n keyedElements.delete(parent);\n}\n\nexport function updateForBoundaryChildren(\n element: Element,\n forVnode: DOMElement\n): void {\n const controlState =\n forVnode._controlState ??\n (forVnode._forState as ControlBoundaryState | undefined);\n if (!controlState) return;\n\n const childrenVNodes =\n controlState.kind === 'for'\n ? evaluateForState(controlState)\n : controlState.kind === 'show'\n ? evaluateShowState(controlState)\n : evaluateCaseState(controlState);\n commitForBoundaryChildren(element, controlState, childrenVNodes);\n}\n\nexport function updateElementChildren(\n element: Element,\n vnodeChildren: unknown,\n cleanupRangeNode: (node: Node) => void\n): void {\n const domHost = getRendererDOMHost();\n\n if (vnodeChildren === null || vnodeChildren === undefined) {\n for (let n = element.firstChild; n; ) {\n const next = n.nextSibling;\n cleanupRangeNode(n);\n n = next;\n }\n element.textContent = '';\n keyedElements.delete(element);\n return;\n }\n\n if (\n !Array.isArray(vnodeChildren) &&\n _isDOMElement(vnodeChildren) &&\n (vnodeChildren as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateForBoundaryChildren(element, vnodeChildren as DOMElement);\n return;\n }\n\n if (!Array.isArray(vnodeChildren) && isFragment(vnodeChildren)) {\n updateElementChildren(\n element,\n getFragmentChildren(vnodeChildren),\n cleanupRangeNode\n );\n return;\n }\n\n if (!Array.isArray(vnodeChildren)) {\n for (let n = element.firstChild; n; ) {\n const next = n.nextSibling;\n cleanupRangeNode(n);\n n = next;\n }\n element.textContent = '';\n const dom = domHost.createDOMNode(vnodeChildren);\n if (dom) element.appendChild(dom);\n keyedElements.delete(element);\n return;\n }\n\n if (\n vnodeChildren.length === 1 &&\n _isDOMElement(vnodeChildren[0]) &&\n (vnodeChildren[0] as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateForBoundaryChildren(element, vnodeChildren[0] as DOMElement);\n return;\n }\n\n if (hasKeyedChildren(vnodeChildren)) {\n const oldKeyMap = getOrBuildKeyMap(element);\n try {\n reconcileKeyed(element, vnodeChildren, oldKeyMap);\n } catch {\n const newKeyMap = reconcileKeyedChildren(\n element,\n vnodeChildren,\n oldKeyMap\n );\n keyedElements.set(element, newKeyMap);\n }\n } else {\n reconcileUnkeyed(element, vnodeChildren);\n }\n}\n\nexport function smartUpdateElement(\n element: Element,\n vnode: DOMElement,\n cleanupRangeNode: (node: Node) => void\n): void {\n const hadVNodeKey = Object.prototype.hasOwnProperty.call(vnode, 'key');\n const previousVNodeKey = vnode.key;\n\n runRetainedElementUpdate(\n element,\n cleanupRangeNode,\n () => applySmartUpdateElement(element, vnode, cleanupRangeNode),\n () => {\n if (hadVNodeKey) vnode.key = previousVNodeKey;\n else delete vnode.key;\n }\n );\n}\n\nfunction applySmartUpdateElement(\n element: Element,\n vnode: DOMElement,\n cleanupRangeNode: (node: Node) => void\n): void {\n const domHost = getRendererDOMHost();\n\n if (vnode.key == null && element.hasAttribute('data-key')) {\n const existingKey = element.getAttribute('data-key');\n if (existingKey !== null) {\n const numericKey = Number(existingKey);\n vnode.key = Number.isNaN(numericKey) ? existingKey : numericKey;\n }\n }\n\n let vnodeChildren = vnode.props?.children ?? vnode.children;\n\n if (\n vnodeChildren &&\n _isDOMElement(vnodeChildren) &&\n (vnodeChildren as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateElementChildren(element, vnodeChildren, cleanupRangeNode);\n domHost.updateElementFromVnode(element, vnode, false);\n return;\n }\n\n if (vnodeChildren && !Array.isArray(vnodeChildren)) {\n vnodeChildren = [vnodeChildren];\n }\n\n const textCheck = checkSimpleText(vnodeChildren);\n\n if (textCheck.isSimple && tryUpdateTextInPlace(element, textCheck.text)) {\n // Text updated in place.\n } else {\n updateElementChildren(element, vnodeChildren, cleanupRangeNode);\n }\n\n domHost.updateElementFromVnode(element, vnode, false);\n}\n\nexport function processFragmentChildren(\n target: Element,\n childArray: unknown[],\n cleanupRangeNode: (node: Node) => void\n): void {\n updateElementChildren(target, childArray, cleanupRangeNode);\n}\n\nfunction applyPropsToElement(el: Element, props: Props): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'children' || key === 'key') continue;\n if (value === undefined || value === null || value === false) continue;\n\n if (key === 'ref') {\n applyRef(el, value);\n continue;\n }\n\n const eventProp = parseEventProp(key);\n if (eventProp) {\n const { eventName, capture } = eventProp;\n const wrappedHandler = createWrappedHandler(value as EventListener, true);\n const options = getEventListenerOptions(eventName, capture);\n const listenerKey = getEventListenerKey(eventName, capture);\n\n if (options !== undefined)\n el.addEventListener(eventName, wrappedHandler, options);\n else el.addEventListener(eventName, wrappedHandler);\n\n if (!elementListeners.has(el)) elementListeners.set(el, new Map());\n elementListeners.get(el)!.set(listenerKey, {\n handler: wrappedHandler,\n original: value as EventListener,\n eventName,\n options,\n });\n continue;\n }\n\n if (key === 'class' || key === 'className') {\n writeElementClassName(el, String(value));\n } else if (key === 'value' || key === 'checked') {\n (el as HTMLElement & Props)[key] = value;\n } else {\n setRenderedAttribute(el, key, String(value));\n }\n }\n}\n\ntype Ref<T> =\n | ((value: T | null) => void)\n | { current: T | null }\n | null\n | undefined;\n\nfunction applyRef<T>(el: T, ref: unknown): void {\n const r = ref as Ref<T>;\n if (!r) return;\n if (typeof r === 'function') {\n r(el);\n return;\n }\n try {\n (r as { current: T | null }).current = el;\n } catch {\n // Ignore write failures.\n }\n}\n\nexport function tryFirstRenderKeyedChildren(\n target: Element,\n vnode: DOMElement\n): boolean {\n const children = vnode.children;\n if (!Array.isArray(children) || !hasKeyedChildren(children)) {\n return false;\n }\n\n const el = createElementForNamespace(\n vnode.type as string,\n getParentNamespace(target)\n );\n target.appendChild(el);\n\n applyPropsToElement(el, vnode.props || {});\n\n const newKeyMap = reconcileKeyedChildren(el, children, undefined);\n keyedElements.set(el, newKeyMap);\n return true;\n}\n\nexport function isFragment(vnode: unknown): vnode is DOMElement {\n return (\n _isDOMElement(vnode) &&\n typeof (vnode as DOMElement).type === 'symbol' &&\n ((vnode as DOMElement).type === Fragment ||\n String((vnode as DOMElement).type) === 'Symbol(askr.fragment)')\n );\n}\n\nexport function getFragmentChildren(vnode: DOMElement): unknown[] {\n const fragmentChildren = vnode.props?.children ?? vnode.children ?? [];\n return Array.isArray(fragmentChildren)\n ? fragmentChildren\n : [fragmentChildren];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,0BACd,MACA,OACqB;CACrB,MAAM,YAAY,KAAK,oBAAoB,CAAC;CAC5C,MAAM,aAAa,UAAU,QAAQ,KAAK;CAE1C,OAAO,cAAc,IAAI,UAAU,MAAM,UAAU,IAAI,CAAC,KAAK;AAC/D;AAEA,SAAgB,qBACd,MACA,OACA,mBACM;CACN,MAAM,gBAAgB;CAEtB,MAAM,gBAAgB,CAAC,GADN,cAAc,oBAAoB,CAAC,CAClB;CAElC,KAAK,MAAM,YAAY,mBACrB,IAAI,CAAC,cAAc,SAAS,QAAQ,GAClC,cAAc,KAAK,QAAQ;CAI/B,cAAc,mBAAmB;CACjC,cAAc,kBAAkB;AAClC;AAcA,SAAgB,wBAAwB,GAAW,GAAoB;CACrE,OAAOA,0BAA8B,GAAG,CAAC;AAC3C;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B,4BACd,QACA,OACS;CACT,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,CAAC,iBAAiB,QAAQ,GACxD,OAAO;CAGT,MAAM,KAAK,0BACT,MAAM,MACN,mBAAmB,MAAM,CAC3B;CACA,OAAO,YAAY,EAAE;CAErB,oBAAoB,IAAI,MAAM,SAAS,CAAC,CAAC;CAEzC,MAAM,YAAY,uBAAuB,IAAI,UAAU,MAAS;CAChE,cAAc,IAAI,IAAI,SAAS;CAC/B,OAAO;AACT;AAEA,SAAgB,WAAW,OAAqC;CAC9D,OACE,cAAc,KAAK,KACnB,OAAQ,MAAqB,SAAS,aACpC,MAAqB,SAAS,YAC9B,OAAQ,MAAqB,IAAI,MAAM;AAE7C;AAEA,SAAgB,oBAAoB,OAA8B;CAChE,MAAM,mBAAmB,MAAM,OAAO,YAAY,MAAM,YAAY,CAAC;CACrE,OAAO,MAAM,QAAQ,gBAAgB,IACjC,mBACA,CAAC,gBAAgB;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","names":[],"sources":["../../src/renderer/evaluate.ts"],"sourcesContent":["import { getRuntimeEnv } from './env';\nimport type {
|
|
1
|
+
{"version":3,"file":"evaluate.js","names":[],"sources":["../../src/renderer/evaluate.ts"],"sourcesContent":["import { getRuntimeEnv } from './env';\nimport type { ComponentFunction, ComponentInstance } from '../runtime';\nimport { removeAllListeners } from './cleanup';\nimport { createDOMNode, syncComponentElement } from './dom';\nimport type { ElementWithContext } from './dom-host';\nimport {\n cleanupRangeNode,\n createDOMRange,\n hasDOMRange,\n updateDOMRangeForContext,\n} from './evaluate-dom-range';\nimport {\n getFragmentChildren,\n getRetainedHostOwnerChain,\n isFragment,\n processFragmentChildren,\n retainHostOwnerChain,\n smartUpdateElement,\n tagNamesEqualIgnoreCase,\n tryFirstRenderKeyedChildren,\n updateElementChildren,\n updateForBoundaryChildren,\n} from './evaluate-reconcile';\nimport { _isDOMElement, type DOMElement } from './types';\nimport { __FOR_BOUNDARY__ } from '../common/vnode';\n\nexport { clearDOMRange } from './evaluate-dom-range';\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\nexport function evaluate(\n node: unknown,\n target: Element | null,\n context?: object,\n retainedOwner?: ComponentInstance\n): void {\n if (!target) return;\n if (typeof document === 'undefined') {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n try {\n console.warn('[Askr] evaluate() called in non-DOM environment; no-op.');\n } catch (e) {\n void e;\n }\n }\n return;\n }\n\n if (context && hasDOMRange(context)) {\n const normalizedChildren =\n node === null || node === undefined || node === false\n ? []\n : isFragment(node)\n ? getFragmentChildren(node as DOMElement)\n : Array.isArray(node)\n ? node\n : [node];\n\n updateDOMRangeForContext(target, context, normalizedChildren);\n } else if (context) {\n createDOMRange(target, context, node);\n } else {\n let vnode = node;\n\n if (isFragment(vnode)) {\n const childArray = getFragmentChildren(vnode as DOMElement);\n if (\n childArray.length === 1 &&\n _isDOMElement(childArray[0]) &&\n typeof (childArray[0] as DOMElement).type === 'string'\n ) {\n vnode = childArray[0];\n } else {\n processFragmentChildren(target, childArray, cleanupRangeNode);\n return;\n }\n }\n\n if (\n _isDOMElement(vnode) &&\n (vnode as DOMElement).type === __FOR_BOUNDARY__\n ) {\n updateForBoundaryChildren(target, vnode as DOMElement);\n return;\n }\n\n if (Array.isArray(vnode)) {\n updateElementChildren(target, vnode, cleanupRangeNode);\n return;\n }\n\n const targetWithInstance = target as Element & {\n __ASKR_INSTANCE?: ComponentInstance;\n };\n const targetInstance =\n retainedOwner?.target === target\n ? retainedOwner\n : targetWithInstance.__ASKR_INSTANCE;\n if (targetInstance && targetInstance.target === target) {\n const retainedHostInstances = getRetainedHostOwnerChain(\n targetWithInstance,\n targetInstance\n );\n\n if (_isDOMElement(vnode) && typeof vnode.type === 'function') {\n const syncedDom = syncComponentElement(\n target,\n vnode as unknown as ElementWithContext,\n vnode.type as ComponentFunction,\n (((vnode as DOMElement).props ?? {}) as Record<string, unknown>) ||\n {},\n undefined,\n false,\n retainedHostInstances\n );\n\n if (syncedDom instanceof Element) {\n retainHostOwnerChain(\n syncedDom,\n targetInstance,\n retainedHostInstances\n );\n targetInstance.target = syncedDom;\n return;\n }\n }\n\n if (\n _isDOMElement(vnode) &&\n typeof vnode.type === 'string' &&\n tagNamesEqualIgnoreCase(target.tagName, vnode.type)\n ) {\n smartUpdateElement(target, vnode as DOMElement, cleanupRangeNode);\n return;\n }\n\n const newDom = createDOMNode(vnode);\n if (newDom && target.parentNode) {\n if (newDom instanceof Element) {\n (\n newDom as Element & { __ASKR_INSTANCE?: ComponentInstance }\n ).__ASKR_INSTANCE = targetInstance;\n targetInstance.target = newDom as Element;\n }\n removeAllListeners(target);\n target.parentNode.replaceChild(newDom, target);\n return;\n }\n }\n\n const firstChild = target.children[0] as Element | undefined;\n\n if (\n firstChild &&\n _isDOMElement(vnode) &&\n typeof vnode.type === 'string' &&\n tagNamesEqualIgnoreCase(firstChild.tagName, vnode.type)\n ) {\n smartUpdateElement(firstChild, vnode as DOMElement, cleanupRangeNode);\n } else {\n for (let node = target.firstChild; node; ) {\n const next = node.nextSibling;\n cleanupRangeNode(node);\n node = next;\n }\n target.textContent = '';\n\n if (\n _isDOMElement(vnode) &&\n typeof vnode.type === 'string' &&\n tryFirstRenderKeyedChildren(target, vnode as DOMElement)\n ) {\n return;\n }\n\n const dom = createDOMNode(vnode);\n if (dom) {\n target.appendChild(dom);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,SACd,MACA,QACA,SACA,eACM;CACN,IAAI,CAAC,QAAQ;CACb,IAAI,OAAO,aAAa,aAAa;EACnC,IAAI,cAAc,CAAC,CAAC,aAAa,cAC/B,IAAI;GACF,QAAQ,KAAK,yDAAyD;EACxE,SAAS,GAAG,CAEZ;EAEF;CACF;CAEA,IAAI,WAAW,YAAY,OAAO,GAUhC,yBAAyB,QAAQ,SAR/B,SAAS,QAAQ,SAAS,UAAa,S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