@vobs/runtime 1.3.6 → 1.4.0
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/async-boundary.cjs +1 -0
- package/dist/async-boundary.cjs.map +1 -1
- package/dist/async-boundary.js +1 -0
- package/dist/async-boundary.js.map +1 -1
- package/dist/bind.cjs.map +1 -1
- package/dist/bind.js.map +1 -1
- package/dist/boundary.cjs +1 -0
- package/dist/boundary.cjs.map +1 -1
- package/dist/boundary.js +1 -0
- package/dist/boundary.js.map +1 -1
- package/dist/dynamic.cjs +1 -0
- package/dist/dynamic.cjs.map +1 -1
- package/dist/dynamic.js +1 -0
- package/dist/dynamic.js.map +1 -1
- package/dist/error-boundary.cjs +1 -0
- package/dist/error-boundary.cjs.map +1 -1
- package/dist/error-boundary.js +1 -0
- package/dist/error-boundary.js.map +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.js.map +1 -1
- package/dist/hmr.cjs +18 -18
- package/dist/hmr.cjs.map +1 -1
- package/dist/hmr.d.cts +1 -1
- package/dist/hmr.d.ts +1 -1
- package/dist/hmr.js +18 -18
- package/dist/hmr.js.map +1 -1
- package/dist/index.cjs +50 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -40
- package/dist/index.js.map +1 -1
- package/dist/ops.cjs +32 -22
- package/dist/ops.cjs.map +1 -1
- package/dist/ops.js +32 -22
- package/dist/ops.js.map +1 -1
- package/dist/profiler.cjs +1 -0
- package/dist/profiler.cjs.map +1 -1
- package/dist/profiler.js +1 -0
- package/dist/profiler.js.map +1 -1
- package/package.json +2 -2
- package/src/events.test.ts +38 -0
- package/src/hmr.test.ts +155 -20
- package/src/hmr.ts +23 -19
- package/src/ops.ts +41 -22
package/dist/ops.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ops.ts","../src/fragment.ts","../src/debug.ts","../src/hmr.ts","../src/ref.ts"],"sourcesContent":["// 编译产物调用的基础操作\n\nimport { createOwner, getCurrentOwner, setOwnerDebugName, untrack, type Owner } from '@vobs/reactivity'\nimport { isVobsFragment, type VobsNode } from './fragment'\nimport { describeDebugNode, getRuntimeDebugHooks, invokeRuntimeDebug, readDebugValue } from './debug'\nimport {\n associateHmrInstance,\n markHmrInstanceMounted,\n registerHmrInstance,\n type HmrInstance\n} from './hmr'\nimport type { VobsRenderer } from './renderer'\nimport { setRef } from './ref'\n\ntype RuntimeRenderer = VobsRenderer<Node, Text, Element, Comment>\n\nlet currentRenderer: RuntimeRenderer | null = null\nconst nodeOwners = new WeakMap<object, Owner>()\ninterface EventBinding {\n readonly handler: EventListener\n readonly owner: Owner | null\n readonly original: EventListener\n}\nconst eventBindings = new WeakMap<object, Map<string, EventBinding>>()\n\nexport function setRenderer<\n NodeType,\n TextNode extends NodeType,\n ElementNode extends NodeType,\n CommentNode extends NodeType\n>(renderer: VobsRenderer<NodeType, TextNode, ElementNode, CommentNode>): void {\n // 编译产物仍使用 DOM 节点声明;实际宿主类型由应用提供的渲染器决定。\n currentRenderer = renderer as unknown as RuntimeRenderer\n}\n\nexport function getRenderer(): RuntimeRenderer {\n if (!currentRenderer) {\n throw new Error('渲染器未初始化')\n }\n return currentRenderer\n}\n\nexport function createText(content: string): Text {\n return getRenderer().createText(content)\n}\n\nexport function createElement(tag: string): Element {\n return getRenderer().createElement(tag)\n}\n\nexport function createComment(content: string): Comment {\n return getRenderer().createComment(content)\n}\n\nexport function insertBefore(\n parent: Node,\n child: VobsNode,\n anchor: VobsNode | null\n): void {\n if (isVobsFragment(child)) {\n child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor)\n return\n }\n getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'insert',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function removeChild(\n parent: Node,\n child: VobsNode\n): void {\n disposeNodeOwner(child)\n if (isVobsFragment(child)) {\n child.unmount(parent)\n return\n }\n getRenderer().removeChild(parent, child)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'remove',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function setTextContent(\n node: Text,\n content: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => node.textContent)\n : undefined\n getRenderer().setTextContent(node, content)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'text',\n target: describeDebugNode(node),\n previousValue,\n nextValue: content\n })\n }\n}\n\nexport function setProperty(\n node: Element,\n key: string,\n value: unknown\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => Reflect.get(node, key))\n : undefined\n getRenderer().setProperty(node, key, value)\n if (key === 'value' && (node as { tagName?: unknown }).tagName === 'SELECT') {\n scheduleSelectValueSync(node, value)\n }\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'property',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nconst pendingSelectValues = new WeakMap<Element, unknown>()\nconst selectSyncScheduled = new WeakSet<Element>()\n\n/**\n * `<select value>` 在 option 子节点存在前赋值不生效(HTML 规范:select 的 value\n * 由已存在的 option 决定)。编译产物先设置属性、后插入子节点,静态写法必然丢初始值\n * (消费方此前只能用 ref + queueMicrotask 规避)。\n * 这里对 select 的 value 赋值统一延迟到微任务重放一次:静态子节点在同一同步任务内\n * 插入完毕,重放即命中。动态(insertList/insertDynamic)插入的 option 晚于该微任务时,\n * 由 value 的绑定 effect 在后续信号更新中正常覆盖。\n */\nfunction scheduleSelectValueSync(node: Element, value: unknown): void {\n pendingSelectValues.set(node, value)\n if (selectSyncScheduled.has(node)) return\n selectSyncScheduled.add(node)\n queueMicrotask(() => {\n selectSyncScheduled.delete(node)\n if (!pendingSelectValues.has(node)) return\n const pending = pendingSelectValues.get(node)\n pendingSelectValues.delete(node)\n getRenderer().setProperty(node, 'value', pending)\n })\n}\n\nexport function setAttribute(\n node: Element,\n key: string,\n value: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => typeof node.getAttribute === 'function' ? node.getAttribute(key) : undefined)\n : undefined\n getRenderer().setAttribute(node, key, value)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'attribute',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nexport function spreadProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || value === null || value === undefined) continue\n if (key === 'ref') {\n setRef(node, value)\n continue\n }\n if (key.startsWith('on') && typeof value === 'function') addEventListener(node, key.slice(2).toLowerCase(), value as EventListener)\n // property 键的 false 有语义(如 disabled={false} 必须清除),不能跳过;\n // attribute 键的 false 表示“不设置”,与 HTML 语义一致。\n else if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\n/** Apply compile-time host properties in one renderer pass. */\nexport function setStaticProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || key === 'ref' || key.startsWith('on')) continue\n if (value === null || value === undefined) continue\n if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\nfunction isPropertyKey(key: string): boolean {\n return key === 'value' || key === 'checked' || key === 'selected' || key === 'disabled'\n || key === 'multiple' || key === 'readOnly' || key === 'required'\n || key === 'autofocus' || key === 'hidden' || key === 'tabIndex'\n}\n\nfunction isStyleObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction formatStyle(value: Record<string, unknown>): string {\n return Object.entries(value).filter(([, entry]) => entry !== null && entry !== undefined && entry !== false)\n .map(([key, entry]) => `${key.replace(/[A-Z]/gu, match => `-${match.toLowerCase()}`)}:${String(entry)}`).join(';')\n}\n\nexport function addEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const owner = getCurrentOwner()\n let bindings = eventBindings.get(node)\n if (!bindings) {\n bindings = new Map()\n eventBindings.set(node, bindings)\n }\n const previous = bindings.get(event)\n if (previous && previous.original === handler && previous.owner === owner) return\n if (previous) renderer.removeEventListener(node, event, previous.handler)\n const listener = owner ? (reason: Event) => {\n // Owner 已销毁说明节点所属子树已被卸载/替换,事件来自游离 DOM,直接忽略。\n // 否则 owner.run 会抛\"已销毁的 Owner\",在事件流里制造无意义的错误噪音。\n if (owner.disposed) return\n try {\n owner.run(() => handler(reason))\n } catch (error) {\n const handled = owner.handleError(error)\n invokeRuntimeDebug('error', {\n error,\n owner,\n phase: 'event',\n handled,\n recovery: handled ? 'handled' : 'propagated'\n })\n if (!handled) throw error\n }\n } : handler\n const binding: EventBinding = { handler: listener, owner, original: handler }\n bindings.set(event, binding)\n renderer.addEventListener(node, event, listener)\n owner?.onDispose(() => {\n if (bindings?.get(event) !== binding) return\n bindings.delete(event)\n renderer.removeEventListener(node, event, listener)\n })\n}\n\nexport function removeEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const binding = eventBindings.get(node)?.get(event)\n renderer.removeEventListener(node, event, binding?.handler ?? handler)\n eventBindings.get(node)?.delete(event)\n}\n\nexport function clear(container: Node): void {\n getRenderer().clear(container)\n}\n\ntype VobsComponent = (...args: any[]) => VobsNode\n\ntype ComponentProps<Component extends VobsComponent> = Component extends (\n props: infer Props\n) => VobsNode\n ? NonNullable<Props> extends object ? NonNullable<Props> : Record<string, never>\n : Record<string, never>\n\nexport function createComponent<Component extends VobsComponent>(\n component: Component,\n props: ComponentProps<Component>,\n source?: VobsSourceLocation\n): VobsNode {\n const owner = createOwner()\n const componentName = (component as typeof component & { displayName?: string }).displayName\n || component.name\n || 'anonymous'\n setOwnerDebugName(owner, source\n ? `${componentName} (${source.file}:${source.line}:${source.column})`\n : componentName)\n owner.onError(reason => {\n attachSourceLocation(reason, source)\n attachComponentContext(reason, componentName, owner.id)\n throw reason\n })\n let node: VobsNode\n try {\n // 组件渲染必须 untrack:组件是 run-once 的,其渲染发生在某次 effect 求值\n // (insertDynamic/insertBoundary 的渲染工厂、路由挂载)内时,若不切断追踪,\n // 组件体内读取的信号会被收集为祖先 effect 的依赖——一次无关编辑就会触发\n // 整棵子树销毁重建(输入框被换掉、焦点丢失、事件监听随旧树一起被清理)。\n // 结构性响应只属于条件工厂与绑定 effect,组件本体渲染一次即止。\n node = owner.run(() => untrack(() => component(props)))\n } catch (error) {\n owner.dispose()\n attachSourceLocation(error, source)\n attachComponentContext(error, componentName, owner.id)\n throw error\n }\n associateNodeOwner(node, owner)\n const hmrKey = (component as typeof component & { hmrKey?: string }).hmrKey\n if (hmrKey) {\n const instance: HmrInstance = {\n node,\n parent: null,\n refresh(): void {\n const previous = instance.node\n const next = owner.run(() => untrack(() => component(props)))\n if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {\n getRenderer().insertBefore(instance.parent, next, previous)\n getRenderer().removeChild(instance.parent, previous)\n }\n nodeOwners.delete(previous as object)\n nodeOwners.set(next as object, owner)\n associateHmrInstance(next, instance)\n instance.node = next\n }\n }\n associateHmrInstance(node, instance)\n const separator = hmrKey.lastIndexOf(':')\n const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator)\n const cleanup = registerHmrInstance(moduleId, instance)\n owner.onDispose(cleanup)\n }\n return node\n}\n\nexport interface VobsSourceLocation {\n readonly file: string\n readonly line: number\n readonly column: number\n}\n\nexport interface VobsLocatedError extends Error {\n readonly vobsSource?: VobsSourceLocation\n readonly vobsComponent?: string\n readonly vobsOwnerId?: string\n}\n\nfunction attachSourceLocation(reason: unknown, source: VobsSourceLocation | undefined): void {\n if (!source || (!reason || (typeof reason !== 'object' && typeof reason !== 'function'))) return\n const error = reason as VobsLocatedError\n if (error.vobsSource) return\n try {\n Object.defineProperty(error, 'vobsSource', {\n configurable: true,\n enumerable: false,\n value: source,\n writable: false\n })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nfunction attachComponentContext(reason: unknown, component: string, ownerId: string): void {\n if (!reason || (typeof reason !== 'object' && typeof reason !== 'function')) return\n const error = reason as VobsLocatedError\n try {\n if (!error.vobsComponent) Object.defineProperty(error, 'vobsComponent', { configurable: true, enumerable: false, value: component, writable: false })\n if (!error.vobsOwnerId) Object.defineProperty(error, 'vobsOwnerId', { configurable: true, enumerable: false, value: ownerId, writable: false })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nexport function createBlock(factory: () => VobsNode | null | undefined | false): VobsNode | null {\n const owner = createOwner()\n setOwnerDebugName(owner, 'dynamic')\n let node: VobsNode | null | undefined | false\n try {\n node = owner.run(factory)\n } catch (error) {\n owner.dispose()\n throw error\n }\n if (!node) {\n owner.dispose()\n return null\n }\n associateNodeOwner(node, owner)\n return node\n}\n\nexport function associateNodeOwner(node: VobsNode, owner: Owner): void {\n nodeOwners.set(node, owner)\n}\n\nexport function disposeNodeOwner(node: VobsNode): void {\n const owner = nodeOwners.get(node)\n if (!owner) return\n nodeOwners.delete(node)\n owner.dispose()\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\nimport { createComment, getRenderer } from './ops'\n\nexport interface VobsFragment {\n readonly kind: 'vobs-fragment'\n readonly start: Node\n readonly end: Node\n readonly mount: (parent: Node, anchor: Node | null) => void\n readonly unmount: (parent: Node) => void\n}\n\nexport type VobsNode = Node | VobsFragment\nexport type FragmentFactory = (parent: Node, anchor: Node) => void\n\nexport function createFragment(factory: FragmentFactory): VobsFragment {\n const start = createComment('vobs:fragment:start')\n const end = createComment('vobs:fragment:end')\n let parent: Node | null = null\n let initialized = false\n const owner = getCurrentOwner()\n\n const fragment: VobsFragment = {\n kind: 'vobs-fragment',\n start,\n end,\n mount(nextParent, anchor): void {\n if (parent && parent !== nextParent) {\n throw new Error('Vobs Fragment: 不能跨父节点移动 Fragment')\n }\n\n if (initialized) {\n moveRange(nextParent, start, end, anchor)\n return\n }\n\n const renderer = getRenderer()\n renderer.insertBefore(nextParent, start, anchor)\n renderer.insertBefore(nextParent, end, anchor)\n parent = nextParent\n initialized = true\n if (owner) owner.run(() => factory(nextParent, end))\n else factory(nextParent, end)\n },\n unmount(nextParent): void {\n if (!initialized || parent !== nextParent) {\n throw new Error('Vobs Fragment: Fragment 不属于指定父节点')\n }\n const renderer = getRenderer()\n let current = renderer.nextSibling(start)\n while (current && current !== end) {\n const next = renderer.nextSibling(current)\n renderer.removeChild(nextParent, current)\n current = next\n }\n renderer.removeChild(nextParent, start)\n renderer.removeChild(nextParent, end)\n parent = null\n initialized = false\n }\n }\n return fragment\n}\n\nexport function isVobsFragment(value: unknown): value is VobsFragment {\n return Boolean(value) && typeof value === 'object' && (value as VobsFragment).kind === 'vobs-fragment'\n}\n\nfunction moveRange(parent: Node, start: Node, end: Node, anchor: Node | null): void {\n const renderer = getRenderer()\n const nodes: Node[] = [start]\n let current = renderer.nextSibling(start)\n while (current) {\n nodes.push(current)\n if (current === end) break\n current = renderer.nextSibling(current)\n }\n if (nodes[nodes.length - 1] !== end) {\n throw new Error('Vobs Fragment: 找不到结束锚点')\n }\n for (const node of nodes) renderer.insertBefore(parent, node, anchor)\n}\n","import type { Owner } from '@vobs/reactivity'\n\nexport type RuntimeDebugEnvironment = 'client' | 'server'\n\n/**\n * Lightweight context copied onto debug events created synchronously inside a\n * Router loader, Effect or SSR render. It is intentionally optional so the\n * runtime remains useful without DevTools.\n */\nexport interface RuntimeDebugContext {\n readonly environment?: RuntimeDebugEnvironment\n readonly sessionId?: string\n readonly route?: string\n readonly navigationId?: number\n readonly dataRequestId?: number\n readonly updateId?: string\n readonly effectId?: string\n readonly source?: string\n}\n\nexport interface RuntimeHydrationMismatch {\n readonly kind: 'missing-node' | 'extra-node' | 'position' | 'content'\n readonly expected: string\n readonly actual: string\n readonly path: string\n readonly message: string\n}\n\nexport type RuntimeDomMutationOperation = 'text' | 'property' | 'attribute' | 'insert' | 'remove'\n\nexport interface RuntimeDomMutation {\n readonly operation: RuntimeDomMutationOperation\n readonly target: string\n readonly parent?: string\n readonly key?: string\n readonly previousValue?: unknown\n readonly nextValue?: unknown\n}\n\nexport interface RuntimeErrorEvent {\n readonly error: unknown\n readonly owner: Owner\n readonly phase: 'event' | 'boundary'\n readonly handled: boolean\n readonly recovery: 'propagated' | 'handled' | 'fallback' | 'retrying' | 'recovered'\n}\n\nexport interface RuntimeDebugHooks {\n domMutation?(mutation: RuntimeDomMutation): void\n error?(event: RuntimeErrorEvent): void\n hydrationMismatch?(event: RuntimeHydrationMismatch): void\n}\n\nlet activeRuntimeDebugHooks: RuntimeDebugHooks | null = null\nlet activeRuntimeDebugContext: RuntimeDebugContext | null = null\n\nexport function setRuntimeDebugHooks(hooks: RuntimeDebugHooks | null): RuntimeDebugHooks | null {\n const previous = activeRuntimeDebugHooks\n activeRuntimeDebugHooks = hooks\n return previous\n}\n\nexport function getRuntimeDebugHooks(): RuntimeDebugHooks | null {\n return activeRuntimeDebugHooks\n}\n\nexport function getRuntimeDebugContext(): RuntimeDebugContext | null {\n return activeRuntimeDebugContext\n}\n\n/** Run a synchronous operation with trace context, preserving async renders. */\nexport function runWithRuntimeDebugContext<T>(context: RuntimeDebugContext, task: () => T): T {\n const previous = activeRuntimeDebugContext\n const next = { ...previous, ...context }\n activeRuntimeDebugContext = next\n let result: T\n try {\n result = task()\n } catch (error) {\n activeRuntimeDebugContext = previous\n throw error\n }\n if (isPromiseLike(result)) {\n return Promise.resolve(result).finally(() => {\n if (activeRuntimeDebugContext === next) activeRuntimeDebugContext = previous\n }) as T\n }\n activeRuntimeDebugContext = previous\n return result\n}\n\n/** Keep a context active across callback boundaries such as Effect execution. */\nexport function pushRuntimeDebugContext(context: RuntimeDebugContext): () => void {\n const previous = activeRuntimeDebugContext\n activeRuntimeDebugContext = { ...previous, ...context }\n let restored = false\n return () => {\n if (restored) return\n restored = true\n activeRuntimeDebugContext = previous\n }\n}\n\nexport function invokeRuntimeDebug<K extends keyof RuntimeDebugHooks>(\n name: K,\n ...args: Parameters<NonNullable<RuntimeDebugHooks[K]>>\n): void {\n const callback = activeRuntimeDebugHooks?.[name] as ((...values: unknown[]) => void) | undefined\n if (!callback) return\n try {\n callback(...args)\n } catch {\n // Debug tooling must never change runtime behavior.\n }\n}\n\nexport function readDebugValue(read: () => unknown): unknown {\n try {\n return read()\n } catch {\n return '[Uninspectable]'\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return Boolean(value) && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as { then?: unknown }).then === 'function'\n}\n\nexport function describeDebugNode(node: unknown): string {\n if (!node || typeof node !== 'object') return 'node'\n const value = node as {\n readonly nodeName?: unknown\n readonly tagName?: unknown\n readonly id?: unknown\n readonly className?: unknown\n }\n const name = typeof value.tagName === 'string'\n ? value.tagName.toLowerCase()\n : typeof value.nodeName === 'string' ? value.nodeName.toLowerCase() : 'node'\n const id = typeof value.id === 'string' && value.id ? `#${value.id}` : ''\n const className = typeof value.className === 'string' && value.className\n ? `.${value.className.trim().split(/\\s+/).filter(Boolean).join('.')}`\n : ''\n return `${name}${id}${className}`\n}\n","import type { VobsNode } from './fragment'\n\nexport type HmrComponent<Props extends object = Record<string, unknown>> =\n (props: Props) => VobsNode\n\nexport interface HmrStateStore {\n get<T>(key: string, initial: T | (() => T)): T\n set<T>(key: string, value: T): void\n has(key: string): boolean\n delete(key: string): void\n clear(): void\n}\n\nexport interface HmrInstance {\n node: VobsNode\n parent: Node | null\n refresh(): void\n}\n\ninterface HmrModuleState {\n readonly components: Map<string, HmrComponent>\n readonly state: Map<string, unknown>\n readonly instances: Set<HmrInstance>\n}\n\ninterface HmrGlobal {\n modules: Map<string, HmrModuleState>\n /** 编译器生成的 hmrStateRef 注册表:键为 `${moduleId}#${声明名}`,值跨模块重执行保活。 */\n states: Map<string, unknown>\n}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>(), states: new Map<string, unknown>() }\nglobalTarget.__VOBS_HMR__ = hmrGlobal\n\nexport function resolveComponent<Props extends object>(\n component: HmrComponent<Props>,\n moduleId: string,\n exportName: string\n): HmrComponent<Props> {\n const module = getModule(moduleId)\n const existing = module.components.get(exportName)\n if (existing) return existing as HmrComponent<Props>\n\n const proxy = ((props: Props) => {\n const current = (proxy as HmrComponent<Props> & { current: HmrComponent<Props> }).current\n return current(props)\n }) as HmrComponent<Props> & { current: HmrComponent<Props> }\n proxy.current = component\n Object.defineProperties(proxy, {\n displayName: { configurable: true, value: component.name || exportName },\n hmrKey: { configurable: false, value: `${moduleId}:${exportName}` }\n })\n module.components.set(exportName, proxy as HmrComponent)\n return proxy\n}\n\nexport function updateHmrModule(_moduleId: string, nextModule: Record<string, unknown>): void {\n const modules = [...hmrGlobal.modules.values()]\n for (const module of modules) {\n let changed = false\n for (const [name, proxy] of module.components) {\n const next = nextModule[name]\n if (typeof next !== 'function') continue\n const hmrProxy = proxy as HmrComponent & { current: HmrComponent; displayName?: string }\n hmrProxy.current = next as HmrComponent\n Object.defineProperty(hmrProxy, 'displayName', { configurable: true, value: next.name || name })\n changed = true\n }\n if (!changed) continue\n for (const instance of module.instances) {\n try {\n instance.refresh()\n } catch {\n // HMR failures remain application errors on the next normal render.\n }\n }\n }\n}\n\nexport function disposeHmrModule(_moduleId: string): void {\n // State and component proxies intentionally survive module disposal.\n}\n\nexport function createHmrStateStore(moduleId: string): HmrStateStore {\n const state = getModule(moduleId).state\n return {\n get<T>(key: string, initial: T | (() => T)): T {\n if (!state.has(key)) state.set(key, typeof initial === 'function' ? (initial as () => T)() : initial)\n return state.get(key) as T\n },\n set<T>(key: string, value: T): void {\n state.set(key, value)\n },\n has: key => state.has(key),\n delete: key => { state.delete(key) },\n clear: () => { state.clear() }\n }\n}\n\n/**\n * 编译器为模块顶层 state() 声明生成的取值入口。键为 `${moduleId}#${声明名}`,\n * 与手动 store 键空间隔离。模块热更新重执行时复用既有信号实例:旧导入方持有的\n * 实例与新模块实例共享同一份状态,消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(key: string, create: () => T): T {\n const states = hmrGlobal.states\n if (states.has(key)) return states.get(key) as T\n const value = create()\n states.set(key, value)\n return value\n}\n\nexport function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void {\n const instances = getModule(moduleId).instances\n instances.add(instance)\n return () => instances.delete(instance)\n}\n\nexport function markHmrInstanceMounted(node: VobsNode, parent: Node): void {\n const instance = hmrInstances.get(node as object)\n if (instance) instance.parent = parent\n}\n\nfunction getModule(moduleId: string): HmrModuleState {\n let module = hmrGlobal.modules.get(moduleId)\n if (!module) {\n module = { components: new Map(), state: new Map(), instances: new Set() }\n hmrGlobal.modules.set(moduleId, module)\n }\n return module\n}\n\nconst hmrInstances = new WeakMap<object, HmrInstance>()\n\nexport function associateHmrInstance(node: VobsNode, instance: HmrInstance): void {\n hmrInstances.set(node as object, instance)\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\n\n/** A mutable reference populated when a host node is mounted. */\nexport interface Ref<T extends object = Node> {\n current: T | null\n}\n\nexport type RefTarget<T extends object = Node> = Ref<T> | ((value: T | null) => void)\n\nexport function ref<T extends object = Node>(initialValue: T | null = null): Ref<T> {\n return { current: initialValue }\n}\n\n/** Bind a host node to an object or callback ref and clear it with its Owner. */\nexport function setRef<T extends object>(node: T, target: unknown): void {\n if (!isRefTarget<T>(target)) return\n // SSR's serializable nodes are never exposed as live refs. Custom renderers\n // may use arbitrary host objects, so only exclude the known SSR shape.\n if (isSSRNode(node)) return\n const owner = getCurrentOwner()\n assignRef(target, node)\n owner?.onDispose(() => {\n // Do not clear a ref that has since been reassigned to another node.\n if (isObjectRef(target) && target.current !== node) return\n assignRef(target, null)\n })\n}\n\nfunction isSSRNode(value: object): boolean {\n const type = (value as { type?: unknown }).type\n return (type === 'element' || type === 'text' || type === 'comment')\n && !('nodeType' in value)\n}\n\nfunction isObjectRef<T extends object>(value: unknown): value is Ref<T> {\n return Boolean(value && typeof value === 'object' && 'current' in value)\n}\n\nfunction isRefTarget<T extends object>(value: unknown): value is RefTarget<T> {\n return isObjectRef<T>(value) || typeof value === 'function'\n}\n\nfunction assignRef<T extends object>(target: RefTarget<T>, value: T | null): void {\n try {\n if (typeof target === 'function') target(value)\n else target.current = value\n } catch {\n // Ref callbacks are user code; never make mounting fail because of them.\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,qBAAqF;;;ACFrF,wBAAgC;AA+DzB,SAAS,eAAe,OAAuC;AACpE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAa,MAAuB,SAAS;AACzF;AAFgB;;;ACVhB,IAAI,0BAAoD;AASjD,SAAS,uBAAiD;AAC/D,SAAO;AACT;AAFgB;AAyCT,SAAS,mBACd,SACG,MACG;AACN,QAAM,WAAW,0BAA0B,IAAI;AAC/C,MAAI,CAAC,SAAU;AACf,MAAI;AACF,aAAS,GAAG,IAAI;AAAA,EAClB,QAAQ;AAAA,EAER;AACF;AAXgB;AAaT,SAAS,eAAe,MAA8B;AAC3D,MAAI;AACF,WAAO,KAAK;AAAA,EACd,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AANgB;AAaT,SAAS,kBAAkB,MAAuB;AACvD,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C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QAAQ;AACd,WAAO;AAAA,EACT;AACA,qBAAmB,MAAM,KAAK;AAC9B,SAAO;AACT;AAhBgB;AAkBT,SAAS,mBAAmB,MAAgB,OAAoB;AACrE,aAAW,IAAI,MAAM,KAAK;AAC5B;AAFgB;AAIT,SAAS,iBAAiB,MAAsB;AACrD,QAAM,QAAQ,WAAW,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO;AACZ,aAAW,OAAO,IAAI;AACtB,QAAM,QAAQ;AAChB;AALgB;","names":["import_reactivity","module","import_reactivity"]}
|
|
1
|
+
{"version":3,"sources":["../src/ops.ts","../src/fragment.ts","../src/debug.ts","../src/hmr.ts","../src/ref.ts"],"sourcesContent":["// 编译产物调用的基础操作\n\nimport { createOwner, getCurrentOwner, setOwnerDebugName, untrack, type Owner } from '@vobs/reactivity'\nimport { isVobsFragment, type VobsNode } from './fragment'\nimport { describeDebugNode, getRuntimeDebugHooks, invokeRuntimeDebug, readDebugValue } from './debug'\nimport {\n associateHmrInstance,\n markHmrInstanceMounted,\n registerHmrInstance,\n type HmrInstance\n} from './hmr'\nimport type { VobsRenderer } from './renderer'\nimport { setRef } from './ref'\n\ntype RuntimeRenderer = VobsRenderer<Node, Text, Element, Comment>\n\nlet currentRenderer: RuntimeRenderer | null = null\nconst nodeOwners = new WeakMap<object, Owner>()\ninterface EventBinding {\n readonly handler: EventListener\n readonly owner: Owner | null\n readonly original: EventListener\n}\nconst eventBindings = new WeakMap<object, Map<string, EventBinding>>()\n\nexport function setRenderer<\n NodeType,\n TextNode extends NodeType,\n ElementNode extends NodeType,\n CommentNode extends NodeType\n>(renderer: VobsRenderer<NodeType, TextNode, ElementNode, CommentNode>): void {\n // 编译产物仍使用 DOM 节点声明;实际宿主类型由应用提供的渲染器决定。\n currentRenderer = renderer as unknown as RuntimeRenderer\n}\n\nexport function getRenderer(): RuntimeRenderer {\n if (!currentRenderer) {\n throw new Error('渲染器未初始化')\n }\n return currentRenderer\n}\n\nexport function createText(content: string): Text {\n return getRenderer().createText(content)\n}\n\nexport function createElement(tag: string): Element {\n return getRenderer().createElement(tag)\n}\n\nexport function createComment(content: string): Comment {\n return getRenderer().createComment(content)\n}\n\nexport function insertBefore(\n parent: Node,\n child: VobsNode,\n anchor: VobsNode | null\n): void {\n if (isVobsFragment(child)) {\n child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n return\n }\n getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'insert',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function removeChild(\n parent: Node,\n child: VobsNode\n): void {\n disposeNodeOwner(child)\n if (isVobsFragment(child)) {\n child.unmount(parent)\n return\n }\n getRenderer().removeChild(parent, child)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'remove',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function setTextContent(\n node: Text,\n content: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => node.textContent)\n : undefined\n getRenderer().setTextContent(node, content)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'text',\n target: describeDebugNode(node),\n previousValue,\n nextValue: content\n })\n }\n}\n\nexport function setProperty(\n node: Element,\n key: string,\n value: unknown\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => Reflect.get(node, key))\n : undefined\n getRenderer().setProperty(node, key, value)\n if (key === 'value' && (node as { tagName?: unknown }).tagName === 'SELECT') {\n scheduleSelectValueSync(node, value)\n }\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'property',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nconst pendingSelectValues = new WeakMap<Element, unknown>()\nconst selectSyncScheduled = new WeakSet<Element>()\n\n/**\n * `<select value>` 在 option 子节点存在前赋值不生效(HTML 规范:select 的 value\n * 由已存在的 option 决定)。编译产物先设置属性、后插入子节点,静态写法必然丢初始值\n * (消费方此前只能用 ref + queueMicrotask 规避)。\n * 这里对 select 的 value 赋值统一延迟到微任务重放一次:静态子节点在同一同步任务内\n * 插入完毕,重放即命中。动态(insertList/insertDynamic)插入的 option 晚于该微任务时,\n * 由 value 的绑定 effect 在后续信号更新中正常覆盖。\n */\nfunction scheduleSelectValueSync(node: Element, value: unknown): void {\n pendingSelectValues.set(node, value)\n if (selectSyncScheduled.has(node)) return\n selectSyncScheduled.add(node)\n queueMicrotask(() => {\n selectSyncScheduled.delete(node)\n if (!pendingSelectValues.has(node)) return\n const pending = pendingSelectValues.get(node)\n pendingSelectValues.delete(node)\n getRenderer().setProperty(node, 'value', pending)\n })\n}\n\nexport function setAttribute(\n node: Element,\n key: string,\n value: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => typeof node.getAttribute === 'function' ? node.getAttribute(key) : undefined)\n : undefined\n getRenderer().setAttribute(node, key, value)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'attribute',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nexport function spreadProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || value === null || value === undefined) continue\n if (key === 'ref') {\n setRef(node, value)\n continue\n }\n if (key.startsWith('on') && typeof value === 'function') addEventListener(node, key.slice(2).toLowerCase(), value as EventListener)\n // property 键的 false 有语义(如 disabled={false} 必须清除),不能跳过;\n // attribute 键的 false 表示“不设置”,与 HTML 语义一致。\n else if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\n/** Apply compile-time host properties in one renderer pass. */\nexport function setStaticProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || key === 'ref' || key.startsWith('on')) continue\n if (value === null || value === undefined) continue\n if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\nfunction isPropertyKey(key: string): boolean {\n return key === 'value' || key === 'checked' || key === 'selected' || key === 'disabled'\n || key === 'multiple' || key === 'readOnly' || key === 'required'\n || key === 'autofocus' || key === 'hidden' || key === 'tabIndex'\n}\n\nfunction isStyleObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction formatStyle(value: Record<string, unknown>): string {\n return Object.entries(value).filter(([, entry]) => entry !== null && entry !== undefined && entry !== false)\n .map(([key, entry]) => `${key.replace(/[A-Z]/gu, match => `-${match.toLowerCase()}`)}:${String(entry)}`).join(';')\n}\n\nexport function addEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const owner = getCurrentOwner()\n let bindings = eventBindings.get(node)\n if (!bindings) {\n bindings = new Map()\n eventBindings.set(node, bindings)\n }\n const previous = bindings.get(event)\n if (previous && previous.original === handler && previous.owner === owner) return\n if (previous) renderer.removeEventListener(node, event, previous.handler)\n const listener = owner ? (reason: Event) => {\n // Owner 已销毁说明节点所属子树已被卸载/替换,事件来自游离 DOM,直接忽略。\n // 否则 owner.run 会抛\"已销毁的 Owner\",在事件流里制造无意义的错误噪音。\n if (owner.disposed) return\n try {\n owner.run(() => handler(reason))\n } catch (error) {\n const handled = owner.handleError(error)\n invokeRuntimeDebug('error', {\n error,\n owner,\n phase: 'event',\n handled,\n recovery: handled ? 'handled' : 'propagated'\n })\n if (!handled) throw error\n }\n } : handler\n const binding: EventBinding = { handler: listener, owner, original: handler }\n bindings.set(event, binding)\n renderer.addEventListener(node, event, listener)\n owner?.onDispose(() => {\n if (bindings?.get(event) !== binding) return\n bindings.delete(event)\n renderer.removeEventListener(node, event, listener)\n })\n}\n\nexport function removeEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const binding = eventBindings.get(node)?.get(event)\n renderer.removeEventListener(node, event, binding?.handler ?? handler)\n eventBindings.get(node)?.delete(event)\n}\n\nexport function clear(container: Node): void {\n getRenderer().clear(container)\n}\n\ntype VobsComponent = (...args: any[]) => VobsNode\n\ntype ComponentProps<Component extends VobsComponent> = Component extends (\n props: infer Props\n) => VobsNode\n ? NonNullable<Props> extends object ? NonNullable<Props> : Record<string, never>\n : Record<string, never>\n\nexport function createComponent<Component extends VobsComponent>(\n component: Component,\n props: ComponentProps<Component>,\n source?: VobsSourceLocation\n): VobsNode {\n const owner = createOwner()\n const componentName = (component as typeof component & { displayName?: string }).displayName\n || component.name\n || 'anonymous'\n setOwnerDebugName(owner, source\n ? `${componentName} (${source.file}:${source.line}:${source.column})`\n : componentName)\n owner.onError(reason => {\n attachSourceLocation(reason, source)\n attachComponentContext(reason, componentName, owner.id)\n throw reason\n })\n // HMR 注册先于渲染作用域标记:注册清理必须跨热更新保活,不能被\n // disposeSince 当作上一轮渲染的清理释放掉。\n const hmrKey = (component as typeof component & { hmrKey?: string }).hmrKey\n let instance: HmrInstance | null = null\n if (hmrKey) {\n const separator = hmrKey.lastIndexOf(':')\n const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator)\n instance = { node: null as unknown as VobsNode, parent: null, refresh: () => refreshInstance() }\n const cleanup = registerHmrInstance(moduleId, instance)\n owner.onDispose(cleanup)\n }\n // 渲染作用域:组件 Owner 只承载 HMR 注册与错误处理,每轮渲染注册的 effect、\n // onDispose(含 portal 清理)与嵌套组件 Owner 都归属该轮作用域。HMR refresh\n // 重渲染前释放上一轮作用域,旧实例的 effect 不再订阅信号、portal 节点不再\n // 残留在 body 中每轮热更新叠加;组件 Owner 与 HMR 注册保活。\n const renderScope = owner.mark()\n let node: VobsNode\n try {\n // 组件渲染必须 untrack:组件是 run-once 的,其渲染发生在某次 effect 求值\n // (insertDynamic/insertBoundary 的渲染工厂、路由挂载)内时,若不切断追踪,\n // 组件体内读取的信号会被收集为祖先 effect 的依赖——一次无关编辑就会触发\n // 整棵子树销毁重建(输入框被换掉、焦点丢失、事件监听随旧树一起被清理)。\n // 结构性响应只属于条件工厂与绑定 effect,组件本体渲染一次即止。\n node = owner.run(() => untrack(() => component(props)))\n } catch (error) {\n owner.dispose()\n attachSourceLocation(error, source)\n attachComponentContext(error, componentName, owner.id)\n throw error\n }\n associateNodeOwner(node, owner)\n if (instance) {\n instance.node = node\n associateHmrInstance(node, instance)\n }\n function refreshInstance(): void {\n // 组件已随旧渲染树一起卸载(如父级在同一次热更新中先完成刷新),\n // 无法也无需再刷新。\n if (owner.disposed) return\n const previous = instance!.node\n owner.disposeSince(renderScope)\n const next = owner.run(() => untrack(() => component(props)))\n const parent = instance!.parent\n if (parent) {\n // 先插入新树再卸载旧树:替换锚点始终取自仍在文档中的旧树,\n // fragment 与普通节点两种形态任意组合都能正确定位插入点。\n const anchor = isVobsFragment(previous) ? previous.start : previous\n if (isVobsFragment(next)) next.mount(parent, anchor)\n else getRenderer().insertBefore(parent, next, anchor)\n if (isVobsFragment(previous)) previous.unmount(parent)\n else getRenderer().removeChild(parent, previous)\n }\n nodeOwners.delete(previous as object)\n nodeOwners.set(next as object, owner)\n associateHmrInstance(next, instance!)\n instance!.node = next\n }\n return node\n}\n\nexport interface VobsSourceLocation {\n readonly file: string\n readonly line: number\n readonly column: number\n}\n\nexport interface VobsLocatedError extends Error {\n readonly vobsSource?: VobsSourceLocation\n readonly vobsComponent?: string\n readonly vobsOwnerId?: string\n}\n\nfunction attachSourceLocation(reason: unknown, source: VobsSourceLocation | undefined): void {\n if (!source || (!reason || (typeof reason !== 'object' && typeof reason !== 'function'))) return\n const error = reason as VobsLocatedError\n if (error.vobsSource) return\n try {\n Object.defineProperty(error, 'vobsSource', {\n configurable: true,\n enumerable: false,\n value: source,\n writable: false\n })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nfunction attachComponentContext(reason: unknown, component: string, ownerId: string): void {\n if (!reason || (typeof reason !== 'object' && typeof reason !== 'function')) return\n const error = reason as VobsLocatedError\n try {\n if (!error.vobsComponent) Object.defineProperty(error, 'vobsComponent', { configurable: true, enumerable: false, value: component, writable: false })\n if (!error.vobsOwnerId) Object.defineProperty(error, 'vobsOwnerId', { configurable: true, enumerable: false, value: ownerId, writable: false })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nexport function createBlock(factory: () => VobsNode | null | undefined | false): VobsNode | null {\n const owner = createOwner()\n setOwnerDebugName(owner, 'dynamic')\n let node: VobsNode | null | undefined | false\n try {\n node = owner.run(factory)\n } catch (error) {\n owner.dispose()\n throw error\n }\n if (!node) {\n owner.dispose()\n return null\n }\n associateNodeOwner(node, owner)\n return node\n}\n\nexport function associateNodeOwner(node: VobsNode, owner: Owner): void {\n nodeOwners.set(node, owner)\n}\n\nexport function disposeNodeOwner(node: VobsNode): void {\n const owner = nodeOwners.get(node)\n if (!owner) return\n nodeOwners.delete(node)\n owner.dispose()\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\nimport { createComment, getRenderer } from './ops'\n\nexport interface VobsFragment {\n readonly kind: 'vobs-fragment'\n readonly start: Node\n readonly end: Node\n readonly mount: (parent: Node, anchor: Node | null) => void\n readonly unmount: (parent: Node) => void\n}\n\nexport type VobsNode = Node | VobsFragment\nexport type FragmentFactory = (parent: Node, anchor: Node) => void\n\nexport function createFragment(factory: FragmentFactory): VobsFragment {\n const start = createComment('vobs:fragment:start')\n const end = createComment('vobs:fragment:end')\n let parent: Node | null = null\n let initialized = false\n const owner = getCurrentOwner()\n\n const fragment: VobsFragment = {\n kind: 'vobs-fragment',\n start,\n end,\n mount(nextParent, anchor): void {\n if (parent && parent !== nextParent) {\n throw new Error('Vobs Fragment: 不能跨父节点移动 Fragment')\n }\n\n if (initialized) {\n moveRange(nextParent, start, end, anchor)\n return\n }\n\n const renderer = getRenderer()\n renderer.insertBefore(nextParent, start, anchor)\n renderer.insertBefore(nextParent, end, anchor)\n parent = nextParent\n initialized = true\n if (owner) owner.run(() => factory(nextParent, end))\n else factory(nextParent, end)\n },\n unmount(nextParent): void {\n if (!initialized || parent !== nextParent) {\n throw new Error('Vobs Fragment: Fragment 不属于指定父节点')\n }\n const renderer = getRenderer()\n let current = renderer.nextSibling(start)\n while (current && current !== end) {\n const next = renderer.nextSibling(current)\n renderer.removeChild(nextParent, current)\n current = next\n }\n renderer.removeChild(nextParent, start)\n renderer.removeChild(nextParent, end)\n parent = null\n initialized = false\n }\n }\n return fragment\n}\n\nexport function isVobsFragment(value: unknown): value is VobsFragment {\n return Boolean(value) && typeof value === 'object' && (value as VobsFragment).kind === 'vobs-fragment'\n}\n\nfunction moveRange(parent: Node, start: Node, end: Node, anchor: Node | null): void {\n const renderer = getRenderer()\n const nodes: Node[] = [start]\n let current = renderer.nextSibling(start)\n while (current) {\n nodes.push(current)\n if (current === end) break\n current = renderer.nextSibling(current)\n }\n if (nodes[nodes.length - 1] !== end) {\n throw new Error('Vobs Fragment: 找不到结束锚点')\n }\n for (const node of nodes) renderer.insertBefore(parent, node, anchor)\n}\n","import type { Owner } from '@vobs/reactivity'\n\nexport type RuntimeDebugEnvironment = 'client' | 'server'\n\n/**\n * Lightweight context copied onto debug events created synchronously inside a\n * Router loader, Effect or SSR render. It is intentionally optional so the\n * runtime remains useful without DevTools.\n */\nexport interface RuntimeDebugContext {\n readonly environment?: RuntimeDebugEnvironment\n readonly sessionId?: string\n readonly route?: string\n readonly navigationId?: number\n readonly dataRequestId?: number\n readonly updateId?: string\n readonly effectId?: string\n readonly source?: string\n}\n\nexport interface RuntimeHydrationMismatch {\n readonly kind: 'missing-node' | 'extra-node' | 'position' | 'content'\n readonly expected: string\n readonly actual: string\n readonly path: string\n readonly message: string\n}\n\nexport type RuntimeDomMutationOperation = 'text' | 'property' | 'attribute' | 'insert' | 'remove'\n\nexport interface RuntimeDomMutation {\n readonly operation: RuntimeDomMutationOperation\n readonly target: string\n readonly parent?: string\n readonly key?: string\n readonly previousValue?: unknown\n readonly nextValue?: unknown\n}\n\nexport interface RuntimeErrorEvent {\n readonly error: unknown\n readonly owner: Owner\n readonly phase: 'event' | 'boundary'\n readonly handled: boolean\n readonly recovery: 'propagated' | 'handled' | 'fallback' | 'retrying' | 'recovered'\n}\n\nexport interface RuntimeDebugHooks {\n domMutation?(mutation: RuntimeDomMutation): void\n error?(event: RuntimeErrorEvent): void\n hydrationMismatch?(event: RuntimeHydrationMismatch): void\n}\n\nlet activeRuntimeDebugHooks: RuntimeDebugHooks | null = null\nlet activeRuntimeDebugContext: RuntimeDebugContext | null = null\n\nexport function setRuntimeDebugHooks(hooks: RuntimeDebugHooks | null): RuntimeDebugHooks | null {\n const previous = activeRuntimeDebugHooks\n activeRuntimeDebugHooks = hooks\n return previous\n}\n\nexport function getRuntimeDebugHooks(): RuntimeDebugHooks | null {\n return activeRuntimeDebugHooks\n}\n\nexport function getRuntimeDebugContext(): RuntimeDebugContext | null {\n return activeRuntimeDebugContext\n}\n\n/** Run a synchronous operation with trace context, preserving async renders. */\nexport function runWithRuntimeDebugContext<T>(context: RuntimeDebugContext, task: () => T): T {\n const previous = activeRuntimeDebugContext\n const next = { ...previous, ...context }\n activeRuntimeDebugContext = next\n let result: T\n try {\n result = task()\n } catch (error) {\n activeRuntimeDebugContext = previous\n throw error\n }\n if (isPromiseLike(result)) {\n return Promise.resolve(result).finally(() => {\n if (activeRuntimeDebugContext === next) activeRuntimeDebugContext = previous\n }) as T\n }\n activeRuntimeDebugContext = previous\n return result\n}\n\n/** Keep a context active across callback boundaries such as Effect execution. */\nexport function pushRuntimeDebugContext(context: RuntimeDebugContext): () => void {\n const previous = activeRuntimeDebugContext\n activeRuntimeDebugContext = { ...previous, ...context }\n let restored = false\n return () => {\n if (restored) return\n restored = true\n activeRuntimeDebugContext = previous\n }\n}\n\nexport function invokeRuntimeDebug<K extends keyof RuntimeDebugHooks>(\n name: K,\n ...args: Parameters<NonNullable<RuntimeDebugHooks[K]>>\n): void {\n const callback = activeRuntimeDebugHooks?.[name] as ((...values: unknown[]) => void) | undefined\n if (!callback) return\n try {\n callback(...args)\n } catch {\n // Debug tooling must never change runtime behavior.\n }\n}\n\nexport function readDebugValue(read: () => unknown): unknown {\n try {\n return read()\n } catch {\n return '[Uninspectable]'\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return Boolean(value) && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as { then?: unknown }).then === 'function'\n}\n\nexport function describeDebugNode(node: unknown): string {\n if (!node || typeof node !== 'object') return 'node'\n const value = node as {\n readonly nodeName?: unknown\n readonly tagName?: unknown\n readonly id?: unknown\n readonly className?: unknown\n }\n const name = typeof value.tagName === 'string'\n ? value.tagName.toLowerCase()\n : typeof value.nodeName === 'string' ? value.nodeName.toLowerCase() : 'node'\n const id = typeof value.id === 'string' && value.id ? `#${value.id}` : ''\n const className = typeof value.className === 'string' && value.className\n ? `.${value.className.trim().split(/\\s+/).filter(Boolean).join('.')}`\n : ''\n return `${name}${id}${className}`\n}\n","import type { VobsNode } from './fragment'\n\nexport type HmrComponent<Props extends object = Record<string, unknown>> =\n (props: Props) => VobsNode\n\nexport interface HmrStateStore {\n get<T>(key: string, initial: T | (() => T)): T\n set<T>(key: string, value: T): void\n has(key: string): boolean\n delete(key: string): void\n clear(): void\n}\n\nexport interface HmrInstance {\n node: VobsNode\n parent: Node | null\n refresh(): void\n}\n\ninterface HmrModuleState {\n readonly components: Map<string, HmrComponent>\n readonly state: Map<string, unknown>\n readonly instances: Set<HmrInstance>\n}\n\ninterface HmrGlobal {\n modules: Map<string, HmrModuleState>\n /** 编译器生成的 hmrStateRef 注册表:键为 `${moduleId}#${声明名}`,值跨模块重执行保活。 */\n states: Map<string, unknown>\n}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>(), states: new Map<string, unknown>() }\nglobalTarget.__VOBS_HMR__ = hmrGlobal\n\nexport function resolveComponent<Props extends object>(\n component: HmrComponent<Props>,\n moduleId: string,\n exportName: string\n): HmrComponent<Props> {\n const module = getModule(moduleId)\n const existing = module.components.get(exportName)\n if (existing) return existing as HmrComponent<Props>\n\n const proxy = ((props: Props) => {\n const current = (proxy as HmrComponent<Props> & { current: HmrComponent<Props> }).current\n return current(props)\n }) as HmrComponent<Props> & { current: HmrComponent<Props> }\n proxy.current = component\n Object.defineProperties(proxy, {\n displayName: { configurable: true, value: component.name || exportName },\n hmrKey: { configurable: false, value: `${moduleId}:${exportName}` }\n })\n module.components.set(exportName, proxy as HmrComponent)\n return proxy\n}\n\nexport function updateHmrModule(moduleId: string, nextModule: Record<string, unknown>): void {\n const module = hmrGlobal.modules.get(moduleId)\n if (!module) return\n let changed = false\n for (const [name, proxy] of module.components) {\n const next = nextModule[name]\n if (typeof next !== 'function') continue\n const hmrProxy = proxy as HmrComponent & { current: HmrComponent; displayName?: string }\n hmrProxy.current = next as HmrComponent\n Object.defineProperty(hmrProxy, 'displayName', { configurable: true, value: next.name || name })\n changed = true\n }\n if (!changed) return\n // 快照后正序遍历:实例在自身渲染开始前注册,祖先必然先于后代入列——\n // 祖先先刷新会 dispose 上一轮渲染作用域,其树内旧后代实例的 refresh\n // 命中已销毁守卫被跳过,避免同一组件在一次热更新中重渲染两次。\n // 同时 refresh 重渲染以新代码创建的全新实例不在快照中,天然不会再刷新。\n const instances = [...module.instances]\n for (const instance of instances) {\n try {\n instance.refresh()\n } catch {\n // HMR failures remain application errors on the next normal render.\n }\n }\n}\n\nexport function disposeHmrModule(_moduleId: string): void {\n // State and component proxies intentionally survive module disposal.\n}\n\nexport function createHmrStateStore(moduleId: string): HmrStateStore {\n const state = getModule(moduleId).state\n return {\n get<T>(key: string, initial: T | (() => T)): T {\n if (!state.has(key)) state.set(key, typeof initial === 'function' ? (initial as () => T)() : initial)\n return state.get(key) as T\n },\n set<T>(key: string, value: T): void {\n state.set(key, value)\n },\n has: key => state.has(key),\n delete: key => { state.delete(key) },\n clear: () => { state.clear() }\n }\n}\n\n/**\n * 编译器为模块顶层 state() 声明生成的取值入口。键为 `${moduleId}#${声明名}`,\n * 与手动 store 键空间隔离。模块热更新重执行时复用既有信号实例:旧导入方持有的\n * 实例与新模块实例共享同一份状态,消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(key: string, create: () => T): T {\n const states = hmrGlobal.states\n if (states.has(key)) return states.get(key) as T\n const value = create()\n states.set(key, value)\n return value\n}\n\nexport function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void {\n const instances = getModule(moduleId).instances\n instances.add(instance)\n return () => instances.delete(instance)\n}\n\nexport function markHmrInstanceMounted(node: VobsNode, parent: Node): void {\n const instance = hmrInstances.get(node as object)\n if (instance) instance.parent = parent\n}\n\nfunction getModule(moduleId: string): HmrModuleState {\n let module = hmrGlobal.modules.get(moduleId)\n if (!module) {\n module = { components: new Map(), state: new Map(), instances: new Set() }\n hmrGlobal.modules.set(moduleId, module)\n }\n return module\n}\n\nconst hmrInstances = new WeakMap<object, HmrInstance>()\n\nexport function associateHmrInstance(node: VobsNode, instance: HmrInstance): void {\n hmrInstances.set(node as object, instance)\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\n\n/** A mutable reference populated when a host node is mounted. */\nexport interface Ref<T extends object = Node> {\n current: T | null\n}\n\nexport type RefTarget<T extends object = Node> = Ref<T> | ((value: T | null) => void)\n\nexport function ref<T extends object = Node>(initialValue: T | null = null): Ref<T> {\n return { current: initialValue }\n}\n\n/** Bind a host node to an object or callback ref and clear it with its Owner. */\nexport function setRef<T extends object>(node: T, target: unknown): void {\n if (!isRefTarget<T>(target)) return\n // SSR's serializable nodes are never exposed as live refs. Custom renderers\n // may use arbitrary host objects, so only exclude the known SSR shape.\n if (isSSRNode(node)) return\n const owner = getCurrentOwner()\n assignRef(target, node)\n owner?.onDispose(() => {\n // Do not clear a ref that has since been reassigned to another node.\n if (isObjectRef(target) && target.current !== node) return\n assignRef(target, null)\n })\n}\n\nfunction isSSRNode(value: object): boolean {\n const type = (value as { type?: unknown }).type\n return (type === 'element' || type === 'text' || type === 'comment')\n && !('nodeType' in value)\n}\n\nfunction isObjectRef<T extends object>(value: unknown): value is Ref<T> {\n return Boolean(value && typeof value === 'object' && 'current' in value)\n}\n\nfunction isRefTarget<T extends object>(value: unknown): value is RefTarget<T> {\n return isObjectRef<T>(value) || typeof value === 'function'\n}\n\nfunction assignRef<T extends object>(target: RefTarget<T>, value: T | null): void {\n try {\n if (typeof target === 'function') target(value)\n else target.current = value\n } catch {\n // Ref callbacks are user code; never make mounting fail because of them.\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,qBAAqF;;;ACFrF,wBAAgC;AA+DzB,SAAS,eAAe,OAAuC;AACpE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAa,MAAuB,SAAS;AACzF;AAFgB;;;ACVhB,IAAI,0BAAoD;AASjD,SAAS,uBAAiD;AAC/D,SAAO;AACT;AAFgB;AAyCT,SAAS,mBACd,SACG,MACG;AACN,QAAM,WAAW,0BAA0B,IAAI;AAC/C,MAAI,CAAC,SAAU;AACf,MAAI;AACF,aAAS,GAAG,IAAI;AAAA,EAClB,QAAQ;AAAA,EAER;AACF;AAXgB;AAaT,SAAS,eAAe,MAA8B;AAC3D,MAAI;AACF,WAAO,KAAK;AAAA,EACd,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AANgB;AAaT,SAAS,kBAAkB,MAAuB;AACvD,MAAI,CAAC,QAA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AAa,QAAO,eAAe,OAAO,eAAe,EAAE,cAAc,MAAM,YAAY,OAAO,OAAO,SAAS,UAAU,MAAM,CAAC;AAAA,EAChJ,QAAQ;AAAA,EAER;AACF;AATS;AAWF,SAAS,YAAY,SAAqE;AAC/F,QAAM,YAAQ,gCAAY;AAC1B,4CAAkB,OAAO,SAAS;AAClC,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACA,MAAI,CAAC,MAAM;AACT,UAAM,QAAQ;AACd,WAAO;AAAA,EACT;AACA,qBAAmB,MAAM,KAAK;AAC9B,SAAO;AACT;AAhBgB;AAkBT,SAAS,mBAAmB,MAAgB,OAAoB;AACrE,aAAW,IAAI,MAAM,KAAK;AAC5B;AAFgB;AAIT,SAAS,iBAAiB,MAAsB;AACrD,QAAM,QAAQ,WAAW,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO;AACZ,aAAW,OAAO,IAAI;AACtB,QAAM,QAAQ;AAChB;AALgB;","names":["import_reactivity","module","import_reactivity"]}
|
package/dist/ops.js
CHANGED
|
@@ -139,6 +139,7 @@ __name(createComment, "createComment");
|
|
|
139
139
|
function insertBefore(parent, child, anchor) {
|
|
140
140
|
if (isVobsFragment(child)) {
|
|
141
141
|
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
142
|
+
markHmrInstanceMounted(child, parent);
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
144
145
|
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
@@ -320,6 +321,16 @@ function createComponent(component, props, source) {
|
|
|
320
321
|
attachComponentContext(reason, componentName, owner.id);
|
|
321
322
|
throw reason;
|
|
322
323
|
});
|
|
324
|
+
const hmrKey = component.hmrKey;
|
|
325
|
+
let instance = null;
|
|
326
|
+
if (hmrKey) {
|
|
327
|
+
const separator = hmrKey.lastIndexOf(":");
|
|
328
|
+
const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator);
|
|
329
|
+
instance = { node: null, parent: null, refresh: /* @__PURE__ */ __name(() => refreshInstance(), "refresh") };
|
|
330
|
+
const cleanup = registerHmrInstance(moduleId, instance);
|
|
331
|
+
owner.onDispose(cleanup);
|
|
332
|
+
}
|
|
333
|
+
const renderScope = owner.mark();
|
|
323
334
|
let node;
|
|
324
335
|
try {
|
|
325
336
|
node = owner.run(() => untrack(() => component(props)));
|
|
@@ -330,30 +341,29 @@ function createComponent(component, props, source) {
|
|
|
330
341
|
throw error;
|
|
331
342
|
}
|
|
332
343
|
associateNodeOwner(node, owner);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const instance = {
|
|
336
|
-
node,
|
|
337
|
-
parent: null,
|
|
338
|
-
refresh() {
|
|
339
|
-
const previous = instance.node;
|
|
340
|
-
const next = owner.run(() => untrack(() => component(props)));
|
|
341
|
-
if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {
|
|
342
|
-
getRenderer().insertBefore(instance.parent, next, previous);
|
|
343
|
-
getRenderer().removeChild(instance.parent, previous);
|
|
344
|
-
}
|
|
345
|
-
nodeOwners.delete(previous);
|
|
346
|
-
nodeOwners.set(next, owner);
|
|
347
|
-
associateHmrInstance(next, instance);
|
|
348
|
-
instance.node = next;
|
|
349
|
-
}
|
|
350
|
-
};
|
|
344
|
+
if (instance) {
|
|
345
|
+
instance.node = node;
|
|
351
346
|
associateHmrInstance(node, instance);
|
|
352
|
-
const separator = hmrKey.lastIndexOf(":");
|
|
353
|
-
const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator);
|
|
354
|
-
const cleanup = registerHmrInstance(moduleId, instance);
|
|
355
|
-
owner.onDispose(cleanup);
|
|
356
347
|
}
|
|
348
|
+
function refreshInstance() {
|
|
349
|
+
if (owner.disposed) return;
|
|
350
|
+
const previous = instance.node;
|
|
351
|
+
owner.disposeSince(renderScope);
|
|
352
|
+
const next = owner.run(() => untrack(() => component(props)));
|
|
353
|
+
const parent = instance.parent;
|
|
354
|
+
if (parent) {
|
|
355
|
+
const anchor = isVobsFragment(previous) ? previous.start : previous;
|
|
356
|
+
if (isVobsFragment(next)) next.mount(parent, anchor);
|
|
357
|
+
else getRenderer().insertBefore(parent, next, anchor);
|
|
358
|
+
if (isVobsFragment(previous)) previous.unmount(parent);
|
|
359
|
+
else getRenderer().removeChild(parent, previous);
|
|
360
|
+
}
|
|
361
|
+
nodeOwners.delete(previous);
|
|
362
|
+
nodeOwners.set(next, owner);
|
|
363
|
+
associateHmrInstance(next, instance);
|
|
364
|
+
instance.node = next;
|
|
365
|
+
}
|
|
366
|
+
__name(refreshInstance, "refreshInstance");
|
|
357
367
|
return node;
|
|
358
368
|
}
|
|
359
369
|
__name(createComponent, "createComponent");
|
package/dist/ops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ops.ts","../src/fragment.ts","../src/debug.ts","../src/hmr.ts","../src/ref.ts"],"sourcesContent":["// 编译产物调用的基础操作\n\nimport { createOwner, getCurrentOwner, setOwnerDebugName, untrack, type Owner } from '@vobs/reactivity'\nimport { isVobsFragment, type VobsNode } from './fragment'\nimport { describeDebugNode, getRuntimeDebugHooks, invokeRuntimeDebug, readDebugValue } from './debug'\nimport {\n associateHmrInstance,\n markHmrInstanceMounted,\n registerHmrInstance,\n type HmrInstance\n} from './hmr'\nimport type { VobsRenderer } from './renderer'\nimport { setRef } from './ref'\n\ntype RuntimeRenderer = VobsRenderer<Node, Text, Element, Comment>\n\nlet currentRenderer: RuntimeRenderer | null = null\nconst nodeOwners = new WeakMap<object, Owner>()\ninterface EventBinding {\n readonly handler: EventListener\n readonly owner: Owner | null\n readonly original: EventListener\n}\nconst eventBindings = new WeakMap<object, Map<string, EventBinding>>()\n\nexport function setRenderer<\n NodeType,\n TextNode extends NodeType,\n ElementNode extends NodeType,\n CommentNode extends NodeType\n>(renderer: VobsRenderer<NodeType, TextNode, ElementNode, CommentNode>): void {\n // 编译产物仍使用 DOM 节点声明;实际宿主类型由应用提供的渲染器决定。\n currentRenderer = renderer as unknown as RuntimeRenderer\n}\n\nexport function getRenderer(): RuntimeRenderer {\n if (!currentRenderer) {\n throw new Error('渲染器未初始化')\n }\n return currentRenderer\n}\n\nexport function createText(content: string): Text {\n return getRenderer().createText(content)\n}\n\nexport function createElement(tag: string): Element {\n return getRenderer().createElement(tag)\n}\n\nexport function createComment(content: string): Comment {\n return getRenderer().createComment(content)\n}\n\nexport function insertBefore(\n parent: Node,\n child: VobsNode,\n anchor: VobsNode | null\n): void {\n if (isVobsFragment(child)) {\n child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor)\n return\n }\n getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'insert',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function removeChild(\n parent: Node,\n child: VobsNode\n): void {\n disposeNodeOwner(child)\n if (isVobsFragment(child)) {\n child.unmount(parent)\n return\n }\n getRenderer().removeChild(parent, child)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'remove',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function setTextContent(\n node: Text,\n content: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => node.textContent)\n : undefined\n getRenderer().setTextContent(node, content)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'text',\n target: describeDebugNode(node),\n previousValue,\n nextValue: content\n })\n }\n}\n\nexport function setProperty(\n node: Element,\n key: string,\n value: unknown\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => Reflect.get(node, key))\n : undefined\n getRenderer().setProperty(node, key, value)\n if (key === 'value' && (node as { tagName?: unknown }).tagName === 'SELECT') {\n scheduleSelectValueSync(node, value)\n }\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'property',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nconst pendingSelectValues = new WeakMap<Element, unknown>()\nconst selectSyncScheduled = new WeakSet<Element>()\n\n/**\n * `<select value>` 在 option 子节点存在前赋值不生效(HTML 规范:select 的 value\n * 由已存在的 option 决定)。编译产物先设置属性、后插入子节点,静态写法必然丢初始值\n * (消费方此前只能用 ref + queueMicrotask 规避)。\n * 这里对 select 的 value 赋值统一延迟到微任务重放一次:静态子节点在同一同步任务内\n * 插入完毕,重放即命中。动态(insertList/insertDynamic)插入的 option 晚于该微任务时,\n * 由 value 的绑定 effect 在后续信号更新中正常覆盖。\n */\nfunction scheduleSelectValueSync(node: Element, value: unknown): void {\n pendingSelectValues.set(node, value)\n if (selectSyncScheduled.has(node)) return\n selectSyncScheduled.add(node)\n queueMicrotask(() => {\n selectSyncScheduled.delete(node)\n if (!pendingSelectValues.has(node)) return\n const pending = pendingSelectValues.get(node)\n pendingSelectValues.delete(node)\n getRenderer().setProperty(node, 'value', pending)\n })\n}\n\nexport function setAttribute(\n node: Element,\n key: string,\n value: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => typeof node.getAttribute === 'function' ? node.getAttribute(key) : undefined)\n : undefined\n getRenderer().setAttribute(node, key, value)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'attribute',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nexport function spreadProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || value === null || value === undefined) continue\n if (key === 'ref') {\n setRef(node, value)\n continue\n }\n if (key.startsWith('on') && typeof value === 'function') addEventListener(node, key.slice(2).toLowerCase(), value as EventListener)\n // property 键的 false 有语义(如 disabled={false} 必须清除),不能跳过;\n // attribute 键的 false 表示“不设置”,与 HTML 语义一致。\n else if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\n/** Apply compile-time host properties in one renderer pass. */\nexport function setStaticProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || key === 'ref' || key.startsWith('on')) continue\n if (value === null || value === undefined) continue\n if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\nfunction isPropertyKey(key: string): boolean {\n return key === 'value' || key === 'checked' || key === 'selected' || key === 'disabled'\n || key === 'multiple' || key === 'readOnly' || key === 'required'\n || key === 'autofocus' || key === 'hidden' || key === 'tabIndex'\n}\n\nfunction isStyleObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction formatStyle(value: Record<string, unknown>): string {\n return Object.entries(value).filter(([, entry]) => entry !== null && entry !== undefined && entry !== false)\n .map(([key, entry]) => `${key.replace(/[A-Z]/gu, match => `-${match.toLowerCase()}`)}:${String(entry)}`).join(';')\n}\n\nexport function addEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const owner = getCurrentOwner()\n let bindings = eventBindings.get(node)\n if (!bindings) {\n bindings = new Map()\n eventBindings.set(node, bindings)\n }\n const previous = bindings.get(event)\n if (previous && previous.original === handler && previous.owner === owner) return\n if (previous) renderer.removeEventListener(node, event, previous.handler)\n const listener = owner ? (reason: Event) => {\n // Owner 已销毁说明节点所属子树已被卸载/替换,事件来自游离 DOM,直接忽略。\n // 否则 owner.run 会抛\"已销毁的 Owner\",在事件流里制造无意义的错误噪音。\n if (owner.disposed) return\n try {\n owner.run(() => handler(reason))\n } catch (error) {\n const handled = owner.handleError(error)\n invokeRuntimeDebug('error', {\n error,\n owner,\n phase: 'event',\n handled,\n recovery: handled ? 'handled' : 'propagated'\n })\n if (!handled) throw error\n }\n } : handler\n const binding: EventBinding = { handler: listener, owner, original: handler }\n bindings.set(event, binding)\n renderer.addEventListener(node, event, listener)\n owner?.onDispose(() => {\n if (bindings?.get(event) !== binding) return\n bindings.delete(event)\n renderer.removeEventListener(node, event, listener)\n })\n}\n\nexport function removeEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const binding = eventBindings.get(node)?.get(event)\n renderer.removeEventListener(node, event, binding?.handler ?? handler)\n eventBindings.get(node)?.delete(event)\n}\n\nexport function clear(container: Node): void {\n getRenderer().clear(container)\n}\n\ntype VobsComponent = (...args: any[]) => VobsNode\n\ntype ComponentProps<Component extends VobsComponent> = Component extends (\n props: infer Props\n) => VobsNode\n ? NonNullable<Props> extends object ? NonNullable<Props> : Record<string, never>\n : Record<string, never>\n\nexport function createComponent<Component extends VobsComponent>(\n component: Component,\n props: ComponentProps<Component>,\n source?: VobsSourceLocation\n): VobsNode {\n const owner = createOwner()\n const componentName = (component as typeof component & { displayName?: string }).displayName\n || component.name\n || 'anonymous'\n setOwnerDebugName(owner, source\n ? `${componentName} (${source.file}:${source.line}:${source.column})`\n : componentName)\n owner.onError(reason => {\n attachSourceLocation(reason, source)\n attachComponentContext(reason, componentName, owner.id)\n throw reason\n })\n let node: VobsNode\n try {\n // 组件渲染必须 untrack:组件是 run-once 的,其渲染发生在某次 effect 求值\n // (insertDynamic/insertBoundary 的渲染工厂、路由挂载)内时,若不切断追踪,\n // 组件体内读取的信号会被收集为祖先 effect 的依赖——一次无关编辑就会触发\n // 整棵子树销毁重建(输入框被换掉、焦点丢失、事件监听随旧树一起被清理)。\n // 结构性响应只属于条件工厂与绑定 effect,组件本体渲染一次即止。\n node = owner.run(() => untrack(() => component(props)))\n } catch (error) {\n owner.dispose()\n attachSourceLocation(error, source)\n attachComponentContext(error, componentName, owner.id)\n throw error\n }\n associateNodeOwner(node, owner)\n const hmrKey = (component as typeof component & { hmrKey?: string }).hmrKey\n if (hmrKey) {\n const instance: HmrInstance = {\n node,\n parent: null,\n refresh(): void {\n const previous = instance.node\n const next = owner.run(() => untrack(() => component(props)))\n if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {\n getRenderer().insertBefore(instance.parent, next, previous)\n getRenderer().removeChild(instance.parent, previous)\n }\n nodeOwners.delete(previous as object)\n nodeOwners.set(next as object, owner)\n associateHmrInstance(next, instance)\n instance.node = next\n }\n }\n associateHmrInstance(node, instance)\n const separator = hmrKey.lastIndexOf(':')\n const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator)\n const cleanup = registerHmrInstance(moduleId, instance)\n owner.onDispose(cleanup)\n }\n return node\n}\n\nexport interface VobsSourceLocation {\n readonly file: string\n readonly line: number\n readonly column: number\n}\n\nexport interface VobsLocatedError extends Error {\n readonly vobsSource?: VobsSourceLocation\n readonly vobsComponent?: string\n readonly vobsOwnerId?: string\n}\n\nfunction attachSourceLocation(reason: unknown, source: VobsSourceLocation | undefined): void {\n if (!source || (!reason || (typeof reason !== 'object' && typeof reason !== 'function'))) return\n const error = reason as VobsLocatedError\n if (error.vobsSource) return\n try {\n Object.defineProperty(error, 'vobsSource', {\n configurable: true,\n enumerable: false,\n value: source,\n writable: false\n })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nfunction attachComponentContext(reason: unknown, component: string, ownerId: string): void {\n if (!reason || (typeof reason !== 'object' && typeof reason !== 'function')) return\n const error = reason as VobsLocatedError\n try {\n if (!error.vobsComponent) Object.defineProperty(error, 'vobsComponent', { configurable: true, enumerable: false, value: component, writable: false })\n if (!error.vobsOwnerId) Object.defineProperty(error, 'vobsOwnerId', { configurable: true, enumerable: false, value: ownerId, writable: false })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nexport function createBlock(factory: () => VobsNode | null | undefined | false): VobsNode | null {\n const owner = createOwner()\n setOwnerDebugName(owner, 'dynamic')\n let node: VobsNode | null | undefined | false\n try {\n node = owner.run(factory)\n } catch (error) {\n owner.dispose()\n throw error\n }\n if (!node) {\n owner.dispose()\n return null\n }\n associateNodeOwner(node, owner)\n return node\n}\n\nexport function associateNodeOwner(node: VobsNode, owner: Owner): void {\n nodeOwners.set(node, owner)\n}\n\nexport function disposeNodeOwner(node: VobsNode): void {\n const owner = nodeOwners.get(node)\n if (!owner) return\n nodeOwners.delete(node)\n owner.dispose()\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\nimport { createComment, getRenderer } from './ops'\n\nexport interface VobsFragment {\n readonly kind: 'vobs-fragment'\n readonly start: Node\n readonly end: Node\n readonly mount: (parent: Node, anchor: Node | null) => void\n readonly unmount: (parent: Node) => void\n}\n\nexport type VobsNode = Node | VobsFragment\nexport type FragmentFactory = (parent: Node, anchor: Node) => void\n\nexport function createFragment(factory: FragmentFactory): VobsFragment {\n const start = createComment('vobs:fragment:start')\n const end = createComment('vobs:fragment:end')\n let parent: Node | null = null\n let initialized = false\n const owner = getCurrentOwner()\n\n const fragment: VobsFragment = {\n kind: 'vobs-fragment',\n start,\n end,\n mount(nextParent, anchor): void {\n if (parent && parent !== nextParent) {\n throw new Error('Vobs Fragment: 不能跨父节点移动 Fragment')\n }\n\n if (initialized) {\n moveRange(nextParent, start, end, anchor)\n return\n }\n\n const renderer = getRenderer()\n renderer.insertBefore(nextParent, start, anchor)\n renderer.insertBefore(nextParent, end, anchor)\n parent = nextParent\n initialized = true\n if (owner) owner.run(() => factory(nextParent, end))\n else factory(nextParent, end)\n },\n unmount(nextParent): void {\n if (!initialized || parent !== nextParent) {\n throw new Error('Vobs Fragment: Fragment 不属于指定父节点')\n }\n const renderer = getRenderer()\n let current = renderer.nextSibling(start)\n while (current && current !== end) {\n const next = renderer.nextSibling(current)\n renderer.removeChild(nextParent, current)\n current = next\n }\n renderer.removeChild(nextParent, start)\n renderer.removeChild(nextParent, end)\n parent = null\n initialized = false\n }\n }\n return fragment\n}\n\nexport function isVobsFragment(value: unknown): value is VobsFragment {\n return Boolean(value) && typeof value === 'object' && (value as VobsFragment).kind === 'vobs-fragment'\n}\n\nfunction moveRange(parent: Node, start: Node, end: Node, anchor: Node | null): void {\n const renderer = getRenderer()\n const nodes: Node[] = [start]\n let current = renderer.nextSibling(start)\n while (current) {\n nodes.push(current)\n if (current === end) break\n current = renderer.nextSibling(current)\n }\n if (nodes[nodes.length - 1] !== end) {\n throw new Error('Vobs Fragment: 找不到结束锚点')\n }\n for (const node of nodes) renderer.insertBefore(parent, node, anchor)\n}\n","import type { Owner } from '@vobs/reactivity'\n\nexport type RuntimeDebugEnvironment = 'client' | 'server'\n\n/**\n * Lightweight context copied onto debug events created synchronously inside a\n * Router loader, Effect or SSR render. It is intentionally optional so the\n * runtime remains useful without DevTools.\n */\nexport interface RuntimeDebugContext {\n readonly environment?: RuntimeDebugEnvironment\n readonly sessionId?: string\n readonly route?: string\n readonly navigationId?: number\n readonly dataRequestId?: number\n readonly updateId?: string\n readonly effectId?: string\n readonly source?: string\n}\n\nexport interface RuntimeHydrationMismatch {\n readonly kind: 'missing-node' | 'extra-node' | 'position' | 'content'\n readonly expected: string\n readonly actual: string\n readonly path: string\n readonly message: string\n}\n\nexport type RuntimeDomMutationOperation = 'text' | 'property' | 'attribute' | 'insert' | 'remove'\n\nexport interface RuntimeDomMutation {\n readonly operation: RuntimeDomMutationOperation\n readonly target: string\n readonly parent?: string\n readonly key?: string\n readonly previousValue?: unknown\n readonly nextValue?: unknown\n}\n\nexport interface RuntimeErrorEvent {\n readonly error: unknown\n readonly owner: Owner\n readonly phase: 'event' | 'boundary'\n readonly handled: boolean\n readonly recovery: 'propagated' | 'handled' | 'fallback' | 'retrying' | 'recovered'\n}\n\nexport interface RuntimeDebugHooks {\n domMutation?(mutation: RuntimeDomMutation): void\n error?(event: RuntimeErrorEvent): void\n hydrationMismatch?(event: RuntimeHydrationMismatch): void\n}\n\nlet activeRuntimeDebugHooks: RuntimeDebugHooks | null = null\nlet activeRuntimeDebugContext: RuntimeDebugContext | null = null\n\nexport function setRuntimeDebugHooks(hooks: RuntimeDebugHooks | null): RuntimeDebugHooks | null {\n const previous = activeRuntimeDebugHooks\n activeRuntimeDebugHooks = hooks\n return previous\n}\n\nexport function getRuntimeDebugHooks(): RuntimeDebugHooks | null {\n return activeRuntimeDebugHooks\n}\n\nexport function getRuntimeDebugContext(): RuntimeDebugContext | null {\n return activeRuntimeDebugContext\n}\n\n/** Run a synchronous operation with trace context, preserving async renders. */\nexport function runWithRuntimeDebugContext<T>(context: RuntimeDebugContext, task: () => T): T {\n const previous = activeRuntimeDebugContext\n const next = { ...previous, ...context }\n activeRuntimeDebugContext = next\n let result: T\n try {\n result = task()\n } catch (error) {\n activeRuntimeDebugContext = previous\n throw error\n }\n if (isPromiseLike(result)) {\n return Promise.resolve(result).finally(() => {\n if (activeRuntimeDebugContext === next) activeRuntimeDebugContext = previous\n }) as T\n }\n activeRuntimeDebugContext = previous\n return result\n}\n\n/** Keep a context active across callback boundaries such as Effect execution. */\nexport function pushRuntimeDebugContext(context: RuntimeDebugContext): () => void {\n const previous = activeRuntimeDebugContext\n activeRuntimeDebugContext = { ...previous, ...context }\n let restored = false\n return () => {\n if (restored) return\n restored = true\n activeRuntimeDebugContext = previous\n }\n}\n\nexport function invokeRuntimeDebug<K extends keyof RuntimeDebugHooks>(\n name: K,\n ...args: Parameters<NonNullable<RuntimeDebugHooks[K]>>\n): void {\n const callback = activeRuntimeDebugHooks?.[name] as ((...values: unknown[]) => void) | undefined\n if (!callback) return\n try {\n callback(...args)\n } catch {\n // Debug tooling must never change runtime behavior.\n }\n}\n\nexport function readDebugValue(read: () => unknown): unknown {\n try {\n return read()\n } catch {\n return '[Uninspectable]'\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return Boolean(value) && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as { then?: unknown }).then === 'function'\n}\n\nexport function describeDebugNode(node: unknown): string {\n if (!node || typeof node !== 'object') return 'node'\n const value = node as {\n readonly nodeName?: unknown\n readonly tagName?: unknown\n readonly id?: unknown\n readonly className?: unknown\n }\n const name = typeof value.tagName === 'string'\n ? value.tagName.toLowerCase()\n : typeof value.nodeName === 'string' ? value.nodeName.toLowerCase() : 'node'\n const id = typeof value.id === 'string' && value.id ? `#${value.id}` : ''\n const className = typeof value.className === 'string' && value.className\n ? `.${value.className.trim().split(/\\s+/).filter(Boolean).join('.')}`\n : ''\n return `${name}${id}${className}`\n}\n","import type { VobsNode } from './fragment'\n\nexport type HmrComponent<Props extends object = Record<string, unknown>> =\n (props: Props) => VobsNode\n\nexport interface HmrStateStore {\n get<T>(key: string, initial: T | (() => T)): T\n set<T>(key: string, value: T): void\n has(key: string): boolean\n delete(key: string): void\n clear(): void\n}\n\nexport interface HmrInstance {\n node: VobsNode\n parent: Node | null\n refresh(): void\n}\n\ninterface HmrModuleState {\n readonly components: Map<string, HmrComponent>\n readonly state: Map<string, unknown>\n readonly instances: Set<HmrInstance>\n}\n\ninterface HmrGlobal {\n modules: Map<string, HmrModuleState>\n /** 编译器生成的 hmrStateRef 注册表:键为 `${moduleId}#${声明名}`,值跨模块重执行保活。 */\n states: Map<string, unknown>\n}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>(), states: new Map<string, unknown>() }\nglobalTarget.__VOBS_HMR__ = hmrGlobal\n\nexport function resolveComponent<Props extends object>(\n component: HmrComponent<Props>,\n moduleId: string,\n exportName: string\n): HmrComponent<Props> {\n const module = getModule(moduleId)\n const existing = module.components.get(exportName)\n if (existing) return existing as HmrComponent<Props>\n\n const proxy = ((props: Props) => {\n const current = (proxy as HmrComponent<Props> & { current: HmrComponent<Props> }).current\n return current(props)\n }) as HmrComponent<Props> & { current: HmrComponent<Props> }\n proxy.current = component\n Object.defineProperties(proxy, {\n displayName: { configurable: true, value: component.name || exportName },\n hmrKey: { configurable: false, value: `${moduleId}:${exportName}` }\n })\n module.components.set(exportName, proxy as HmrComponent)\n return proxy\n}\n\nexport function updateHmrModule(_moduleId: string, nextModule: Record<string, unknown>): void {\n const modules = [...hmrGlobal.modules.values()]\n for (const module of modules) {\n let changed = false\n for (const [name, proxy] of module.components) {\n const next = nextModule[name]\n if (typeof next !== 'function') continue\n const hmrProxy = proxy as HmrComponent & { current: HmrComponent; displayName?: string }\n hmrProxy.current = next as HmrComponent\n Object.defineProperty(hmrProxy, 'displayName', { configurable: true, value: next.name || name })\n changed = true\n }\n if (!changed) continue\n for (const instance of module.instances) {\n try {\n instance.refresh()\n } catch {\n // HMR failures remain application errors on the next normal render.\n }\n }\n }\n}\n\nexport function disposeHmrModule(_moduleId: string): void {\n // State and component proxies intentionally survive module disposal.\n}\n\nexport function createHmrStateStore(moduleId: string): HmrStateStore {\n const state = getModule(moduleId).state\n return {\n get<T>(key: string, initial: T | (() => T)): T {\n if (!state.has(key)) state.set(key, typeof initial === 'function' ? (initial as () => T)() : initial)\n return state.get(key) as T\n },\n set<T>(key: string, value: T): void {\n state.set(key, value)\n },\n has: key => state.has(key),\n delete: key => { state.delete(key) },\n clear: () => { state.clear() }\n }\n}\n\n/**\n * 编译器为模块顶层 state() 声明生成的取值入口。键为 `${moduleId}#${声明名}`,\n * 与手动 store 键空间隔离。模块热更新重执行时复用既有信号实例:旧导入方持有的\n * 实例与新模块实例共享同一份状态,消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(key: string, create: () => T): T {\n const states = hmrGlobal.states\n if (states.has(key)) return states.get(key) as T\n const value = create()\n states.set(key, value)\n return value\n}\n\nexport function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void {\n const instances = getModule(moduleId).instances\n instances.add(instance)\n return () => instances.delete(instance)\n}\n\nexport function markHmrInstanceMounted(node: VobsNode, parent: Node): void {\n const instance = hmrInstances.get(node as object)\n if (instance) instance.parent = parent\n}\n\nfunction getModule(moduleId: string): HmrModuleState {\n let module = hmrGlobal.modules.get(moduleId)\n if (!module) {\n module = { components: new Map(), state: new Map(), instances: new Set() }\n hmrGlobal.modules.set(moduleId, module)\n }\n return module\n}\n\nconst hmrInstances = new WeakMap<object, HmrInstance>()\n\nexport function associateHmrInstance(node: VobsNode, instance: HmrInstance): void {\n hmrInstances.set(node as object, instance)\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\n\n/** A mutable reference populated when a host node is mounted. */\nexport interface Ref<T extends object = Node> {\n current: T | null\n}\n\nexport type RefTarget<T extends object = Node> = Ref<T> | ((value: T | null) => void)\n\nexport function ref<T extends object = Node>(initialValue: T | null = null): Ref<T> {\n return { current: initialValue }\n}\n\n/** Bind a host node to an object or callback ref and clear it with its Owner. */\nexport function setRef<T extends object>(node: T, target: unknown): void {\n if (!isRefTarget<T>(target)) return\n // SSR's serializable nodes are never exposed as live refs. Custom renderers\n // may use arbitrary host objects, so only exclude the known SSR shape.\n if (isSSRNode(node)) return\n const owner = getCurrentOwner()\n assignRef(target, node)\n owner?.onDispose(() => {\n // Do not clear a ref that has since been reassigned to another node.\n if (isObjectRef(target) && target.current !== node) return\n assignRef(target, null)\n })\n}\n\nfunction isSSRNode(value: object): boolean {\n const type = (value as { type?: unknown }).type\n return (type === 'element' || type === 'text' || type === 'comment')\n && !('nodeType' in value)\n}\n\nfunction isObjectRef<T extends object>(value: unknown): value is Ref<T> {\n return Boolean(value && typeof value === 'object' && 'current' in value)\n}\n\nfunction isRefTarget<T extends object>(value: unknown): value is RefTarget<T> {\n return isObjectRef<T>(value) || typeof value === 'function'\n}\n\nfunction assignRef<T extends object>(target: RefTarget<T>, value: T | null): void {\n try {\n if (typeof target === 'function') target(value)\n else target.current = value\n } catch {\n // Ref callbacks are user code; never make mounting fail because of them.\n }\n}\n"],"mappings":";;;;AAEA,SAAS,aAAa,mBAAAA,kBAAiB,mBAAmB,eAA2B;;;ACFrF,SAAS,uBAAuB;AA+DzB,SA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;AACF,QAAI,CAAC,MAAM,cAAe,QAAO,eAAe,OAAO,iBAAiB,EAAE,cAAc,MAAM,YAAY,OAAO,OAAO,WAAW,UAAU,MAAM,CAAC;AACpJ,QAAI,CAAC,MAAM,YAAa,QAAO,eAAe,OAAO,eAAe,EAAE,cAAc,MAAM,YAAY,OAAO,OAAO,SAAS,UAAU,MAAM,CAAC;AAAA,EAChJ,QAAQ;AAAA,EAER;AACF;AATS;AAWF,SAAS,YAAY,SAAqE;AAC/F,QAAM,QAAQ,YAAY;AAC1B,oBAAkB,OAAO,SAAS;AAClC,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACA,MAAI,CAAC,MAAM;AACT,UAAM,QAAQ;AACd,WAAO;AAAA,EACT;AACA,qBAAmB,MAAM,KAAK;AAC9B,SAAO;AACT;AAhBgB;AAkBT,SAAS,mBAAmB,MAAgB,OAAoB;AACrE,aAAW,IAAI,MAAM,KAAK;AAC5B;AAFgB;AAIT,SAAS,iBAAiB,MAAsB;AACrD,QAAM,QAAQ,WAAW,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO;AACZ,aAAW,OAAO,IAAI;AACtB,QAAM,QAAQ;AAChB;AALgB;","names":["getCurrentOwner","getCurrentOwner","getCurrentOwner","getCurrentOwner"]}
|
|
1
|
+
{"version":3,"sources":["../src/ops.ts","../src/fragment.ts","../src/debug.ts","../src/hmr.ts","../src/ref.ts"],"sourcesContent":["// 编译产物调用的基础操作\n\nimport { createOwner, getCurrentOwner, setOwnerDebugName, untrack, type Owner } from '@vobs/reactivity'\nimport { isVobsFragment, type VobsNode } from './fragment'\nimport { describeDebugNode, getRuntimeDebugHooks, invokeRuntimeDebug, readDebugValue } from './debug'\nimport {\n associateHmrInstance,\n markHmrInstanceMounted,\n registerHmrInstance,\n type HmrInstance\n} from './hmr'\nimport type { VobsRenderer } from './renderer'\nimport { setRef } from './ref'\n\ntype RuntimeRenderer = VobsRenderer<Node, Text, Element, Comment>\n\nlet currentRenderer: RuntimeRenderer | null = null\nconst nodeOwners = new WeakMap<object, Owner>()\ninterface EventBinding {\n readonly handler: EventListener\n readonly owner: Owner | null\n readonly original: EventListener\n}\nconst eventBindings = new WeakMap<object, Map<string, EventBinding>>()\n\nexport function setRenderer<\n NodeType,\n TextNode extends NodeType,\n ElementNode extends NodeType,\n CommentNode extends NodeType\n>(renderer: VobsRenderer<NodeType, TextNode, ElementNode, CommentNode>): void {\n // 编译产物仍使用 DOM 节点声明;实际宿主类型由应用提供的渲染器决定。\n currentRenderer = renderer as unknown as RuntimeRenderer\n}\n\nexport function getRenderer(): RuntimeRenderer {\n if (!currentRenderer) {\n throw new Error('渲染器未初始化')\n }\n return currentRenderer\n}\n\nexport function createText(content: string): Text {\n return getRenderer().createText(content)\n}\n\nexport function createElement(tag: string): Element {\n return getRenderer().createElement(tag)\n}\n\nexport function createComment(content: string): Comment {\n return getRenderer().createComment(content)\n}\n\nexport function insertBefore(\n parent: Node,\n child: VobsNode,\n anchor: VobsNode | null\n): void {\n if (isVobsFragment(child)) {\n child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n return\n }\n getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor)\n markHmrInstanceMounted(child, parent)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'insert',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function removeChild(\n parent: Node,\n child: VobsNode\n): void {\n disposeNodeOwner(child)\n if (isVobsFragment(child)) {\n child.unmount(parent)\n return\n }\n getRenderer().removeChild(parent, child)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'remove',\n target: describeDebugNode(child),\n parent: describeDebugNode(parent)\n })\n }\n}\n\nexport function setTextContent(\n node: Text,\n content: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => node.textContent)\n : undefined\n getRenderer().setTextContent(node, content)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'text',\n target: describeDebugNode(node),\n previousValue,\n nextValue: content\n })\n }\n}\n\nexport function setProperty(\n node: Element,\n key: string,\n value: unknown\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => Reflect.get(node, key))\n : undefined\n getRenderer().setProperty(node, key, value)\n if (key === 'value' && (node as { tagName?: unknown }).tagName === 'SELECT') {\n scheduleSelectValueSync(node, value)\n }\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'property',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nconst pendingSelectValues = new WeakMap<Element, unknown>()\nconst selectSyncScheduled = new WeakSet<Element>()\n\n/**\n * `<select value>` 在 option 子节点存在前赋值不生效(HTML 规范:select 的 value\n * 由已存在的 option 决定)。编译产物先设置属性、后插入子节点,静态写法必然丢初始值\n * (消费方此前只能用 ref + queueMicrotask 规避)。\n * 这里对 select 的 value 赋值统一延迟到微任务重放一次:静态子节点在同一同步任务内\n * 插入完毕,重放即命中。动态(insertList/insertDynamic)插入的 option 晚于该微任务时,\n * 由 value 的绑定 effect 在后续信号更新中正常覆盖。\n */\nfunction scheduleSelectValueSync(node: Element, value: unknown): void {\n pendingSelectValues.set(node, value)\n if (selectSyncScheduled.has(node)) return\n selectSyncScheduled.add(node)\n queueMicrotask(() => {\n selectSyncScheduled.delete(node)\n if (!pendingSelectValues.has(node)) return\n const pending = pendingSelectValues.get(node)\n pendingSelectValues.delete(node)\n getRenderer().setProperty(node, 'value', pending)\n })\n}\n\nexport function setAttribute(\n node: Element,\n key: string,\n value: string\n): void {\n const previousValue = getRuntimeDebugHooks()\n ? readDebugValue(() => typeof node.getAttribute === 'function' ? node.getAttribute(key) : undefined)\n : undefined\n getRenderer().setAttribute(node, key, value)\n if (getRuntimeDebugHooks()) {\n invokeRuntimeDebug('domMutation', {\n operation: 'attribute',\n target: describeDebugNode(node),\n key,\n previousValue,\n nextValue: value\n })\n }\n}\n\nexport function spreadProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || value === null || value === undefined) continue\n if (key === 'ref') {\n setRef(node, value)\n continue\n }\n if (key.startsWith('on') && typeof value === 'function') addEventListener(node, key.slice(2).toLowerCase(), value as EventListener)\n // property 键的 false 有语义(如 disabled={false} 必须清除),不能跳过;\n // attribute 键的 false 表示“不设置”,与 HTML 语义一致。\n else if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\n/** Apply compile-time host properties in one renderer pass. */\nexport function setStaticProps(node: Element, props: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(props)) {\n if (key === 'key' || key === 'ref' || key.startsWith('on')) continue\n if (value === null || value === undefined) continue\n if (isPropertyKey(key)) setProperty(node, key, value)\n else if (value === false) continue\n else setAttribute(node, key === 'className' ? 'class' : key, key === 'style' && isStyleObject(value) ? formatStyle(value) : String(value))\n }\n}\n\nfunction isPropertyKey(key: string): boolean {\n return key === 'value' || key === 'checked' || key === 'selected' || key === 'disabled'\n || key === 'multiple' || key === 'readOnly' || key === 'required'\n || key === 'autofocus' || key === 'hidden' || key === 'tabIndex'\n}\n\nfunction isStyleObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction formatStyle(value: Record<string, unknown>): string {\n return Object.entries(value).filter(([, entry]) => entry !== null && entry !== undefined && entry !== false)\n .map(([key, entry]) => `${key.replace(/[A-Z]/gu, match => `-${match.toLowerCase()}`)}:${String(entry)}`).join(';')\n}\n\nexport function addEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const owner = getCurrentOwner()\n let bindings = eventBindings.get(node)\n if (!bindings) {\n bindings = new Map()\n eventBindings.set(node, bindings)\n }\n const previous = bindings.get(event)\n if (previous && previous.original === handler && previous.owner === owner) return\n if (previous) renderer.removeEventListener(node, event, previous.handler)\n const listener = owner ? (reason: Event) => {\n // Owner 已销毁说明节点所属子树已被卸载/替换,事件来自游离 DOM,直接忽略。\n // 否则 owner.run 会抛\"已销毁的 Owner\",在事件流里制造无意义的错误噪音。\n if (owner.disposed) return\n try {\n owner.run(() => handler(reason))\n } catch (error) {\n const handled = owner.handleError(error)\n invokeRuntimeDebug('error', {\n error,\n owner,\n phase: 'event',\n handled,\n recovery: handled ? 'handled' : 'propagated'\n })\n if (!handled) throw error\n }\n } : handler\n const binding: EventBinding = { handler: listener, owner, original: handler }\n bindings.set(event, binding)\n renderer.addEventListener(node, event, listener)\n owner?.onDispose(() => {\n if (bindings?.get(event) !== binding) return\n bindings.delete(event)\n renderer.removeEventListener(node, event, listener)\n })\n}\n\nexport function removeEventListener(\n node: Element,\n event: string,\n handler: EventListener\n): void {\n const renderer = getRenderer()\n const binding = eventBindings.get(node)?.get(event)\n renderer.removeEventListener(node, event, binding?.handler ?? handler)\n eventBindings.get(node)?.delete(event)\n}\n\nexport function clear(container: Node): void {\n getRenderer().clear(container)\n}\n\ntype VobsComponent = (...args: any[]) => VobsNode\n\ntype ComponentProps<Component extends VobsComponent> = Component extends (\n props: infer Props\n) => VobsNode\n ? NonNullable<Props> extends object ? NonNullable<Props> : Record<string, never>\n : Record<string, never>\n\nexport function createComponent<Component extends VobsComponent>(\n component: Component,\n props: ComponentProps<Component>,\n source?: VobsSourceLocation\n): VobsNode {\n const owner = createOwner()\n const componentName = (component as typeof component & { displayName?: string }).displayName\n || component.name\n || 'anonymous'\n setOwnerDebugName(owner, source\n ? `${componentName} (${source.file}:${source.line}:${source.column})`\n : componentName)\n owner.onError(reason => {\n attachSourceLocation(reason, source)\n attachComponentContext(reason, componentName, owner.id)\n throw reason\n })\n // HMR 注册先于渲染作用域标记:注册清理必须跨热更新保活,不能被\n // disposeSince 当作上一轮渲染的清理释放掉。\n const hmrKey = (component as typeof component & { hmrKey?: string }).hmrKey\n let instance: HmrInstance | null = null\n if (hmrKey) {\n const separator = hmrKey.lastIndexOf(':')\n const moduleId = separator < 0 ? hmrKey : hmrKey.slice(0, separator)\n instance = { node: null as unknown as VobsNode, parent: null, refresh: () => refreshInstance() }\n const cleanup = registerHmrInstance(moduleId, instance)\n owner.onDispose(cleanup)\n }\n // 渲染作用域:组件 Owner 只承载 HMR 注册与错误处理,每轮渲染注册的 effect、\n // onDispose(含 portal 清理)与嵌套组件 Owner 都归属该轮作用域。HMR refresh\n // 重渲染前释放上一轮作用域,旧实例的 effect 不再订阅信号、portal 节点不再\n // 残留在 body 中每轮热更新叠加;组件 Owner 与 HMR 注册保活。\n const renderScope = owner.mark()\n let node: VobsNode\n try {\n // 组件渲染必须 untrack:组件是 run-once 的,其渲染发生在某次 effect 求值\n // (insertDynamic/insertBoundary 的渲染工厂、路由挂载)内时,若不切断追踪,\n // 组件体内读取的信号会被收集为祖先 effect 的依赖——一次无关编辑就会触发\n // 整棵子树销毁重建(输入框被换掉、焦点丢失、事件监听随旧树一起被清理)。\n // 结构性响应只属于条件工厂与绑定 effect,组件本体渲染一次即止。\n node = owner.run(() => untrack(() => component(props)))\n } catch (error) {\n owner.dispose()\n attachSourceLocation(error, source)\n attachComponentContext(error, componentName, owner.id)\n throw error\n }\n associateNodeOwner(node, owner)\n if (instance) {\n instance.node = node\n associateHmrInstance(node, instance)\n }\n function refreshInstance(): void {\n // 组件已随旧渲染树一起卸载(如父级在同一次热更新中先完成刷新),\n // 无法也无需再刷新。\n if (owner.disposed) return\n const previous = instance!.node\n owner.disposeSince(renderScope)\n const next = owner.run(() => untrack(() => component(props)))\n const parent = instance!.parent\n if (parent) {\n // 先插入新树再卸载旧树:替换锚点始终取自仍在文档中的旧树,\n // fragment 与普通节点两种形态任意组合都能正确定位插入点。\n const anchor = isVobsFragment(previous) ? previous.start : previous\n if (isVobsFragment(next)) next.mount(parent, anchor)\n else getRenderer().insertBefore(parent, next, anchor)\n if (isVobsFragment(previous)) previous.unmount(parent)\n else getRenderer().removeChild(parent, previous)\n }\n nodeOwners.delete(previous as object)\n nodeOwners.set(next as object, owner)\n associateHmrInstance(next, instance!)\n instance!.node = next\n }\n return node\n}\n\nexport interface VobsSourceLocation {\n readonly file: string\n readonly line: number\n readonly column: number\n}\n\nexport interface VobsLocatedError extends Error {\n readonly vobsSource?: VobsSourceLocation\n readonly vobsComponent?: string\n readonly vobsOwnerId?: string\n}\n\nfunction attachSourceLocation(reason: unknown, source: VobsSourceLocation | undefined): void {\n if (!source || (!reason || (typeof reason !== 'object' && typeof reason !== 'function'))) return\n const error = reason as VobsLocatedError\n if (error.vobsSource) return\n try {\n Object.defineProperty(error, 'vobsSource', {\n configurable: true,\n enumerable: false,\n value: source,\n writable: false\n })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nfunction attachComponentContext(reason: unknown, component: string, ownerId: string): void {\n if (!reason || (typeof reason !== 'object' && typeof reason !== 'function')) return\n const error = reason as VobsLocatedError\n try {\n if (!error.vobsComponent) Object.defineProperty(error, 'vobsComponent', { configurable: true, enumerable: false, value: component, writable: false })\n if (!error.vobsOwnerId) Object.defineProperty(error, 'vobsOwnerId', { configurable: true, enumerable: false, value: ownerId, writable: false })\n } catch {\n // Frozen third-party errors still propagate with their original details.\n }\n}\n\nexport function createBlock(factory: () => VobsNode | null | undefined | false): VobsNode | null {\n const owner = createOwner()\n setOwnerDebugName(owner, 'dynamic')\n let node: VobsNode | null | undefined | false\n try {\n node = owner.run(factory)\n } catch (error) {\n owner.dispose()\n throw error\n }\n if (!node) {\n owner.dispose()\n return null\n }\n associateNodeOwner(node, owner)\n return node\n}\n\nexport function associateNodeOwner(node: VobsNode, owner: Owner): void {\n nodeOwners.set(node, owner)\n}\n\nexport function disposeNodeOwner(node: VobsNode): void {\n const owner = nodeOwners.get(node)\n if (!owner) return\n nodeOwners.delete(node)\n owner.dispose()\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\nimport { createComment, getRenderer } from './ops'\n\nexport interface VobsFragment {\n readonly kind: 'vobs-fragment'\n readonly start: Node\n readonly end: Node\n readonly mount: (parent: Node, anchor: Node | null) => void\n readonly unmount: (parent: Node) => void\n}\n\nexport type VobsNode = Node | VobsFragment\nexport type FragmentFactory = (parent: Node, anchor: Node) => void\n\nexport function createFragment(factory: FragmentFactory): VobsFragment {\n const start = createComment('vobs:fragment:start')\n const end = createComment('vobs:fragment:end')\n let parent: Node | null = null\n let initialized = false\n const owner = getCurrentOwner()\n\n const fragment: VobsFragment = {\n kind: 'vobs-fragment',\n start,\n end,\n mount(nextParent, anchor): void {\n if (parent && parent !== nextParent) {\n throw new Error('Vobs Fragment: 不能跨父节点移动 Fragment')\n }\n\n if (initialized) {\n moveRange(nextParent, start, end, anchor)\n return\n }\n\n const renderer = getRenderer()\n renderer.insertBefore(nextParent, start, anchor)\n renderer.insertBefore(nextParent, end, anchor)\n parent = nextParent\n initialized = true\n if (owner) owner.run(() => factory(nextParent, end))\n else factory(nextParent, end)\n },\n unmount(nextParent): void {\n if (!initialized || parent !== nextParent) {\n throw new Error('Vobs Fragment: Fragment 不属于指定父节点')\n }\n const renderer = getRenderer()\n let current = renderer.nextSibling(start)\n while (current && current !== end) {\n const next = renderer.nextSibling(current)\n renderer.removeChild(nextParent, current)\n current = next\n }\n renderer.removeChild(nextParent, start)\n renderer.removeChild(nextParent, end)\n parent = null\n initialized = false\n }\n }\n return fragment\n}\n\nexport function isVobsFragment(value: unknown): value is VobsFragment {\n return Boolean(value) && typeof value === 'object' && (value as VobsFragment).kind === 'vobs-fragment'\n}\n\nfunction moveRange(parent: Node, start: Node, end: Node, anchor: Node | null): void {\n const renderer = getRenderer()\n const nodes: Node[] = [start]\n let current = renderer.nextSibling(start)\n while (current) {\n nodes.push(current)\n if (current === end) break\n current = renderer.nextSibling(current)\n }\n if (nodes[nodes.length - 1] !== end) {\n throw new Error('Vobs Fragment: 找不到结束锚点')\n }\n for (const node of nodes) renderer.insertBefore(parent, node, anchor)\n}\n","import type { Owner } from '@vobs/reactivity'\n\nexport type RuntimeDebugEnvironment = 'client' | 'server'\n\n/**\n * Lightweight context copied onto debug events created synchronously inside a\n * Router loader, Effect or SSR render. It is intentionally optional so the\n * runtime remains useful without DevTools.\n */\nexport interface RuntimeDebugContext {\n readonly environment?: RuntimeDebugEnvironment\n readonly sessionId?: string\n readonly route?: string\n readonly navigationId?: number\n readonly dataRequestId?: number\n readonly updateId?: string\n readonly effectId?: string\n readonly source?: string\n}\n\nexport interface RuntimeHydrationMismatch {\n readonly kind: 'missing-node' | 'extra-node' | 'position' | 'content'\n readonly expected: string\n readonly actual: string\n readonly path: string\n readonly message: string\n}\n\nexport type RuntimeDomMutationOperation = 'text' | 'property' | 'attribute' | 'insert' | 'remove'\n\nexport interface RuntimeDomMutation {\n readonly operation: RuntimeDomMutationOperation\n readonly target: string\n readonly parent?: string\n readonly key?: string\n readonly previousValue?: unknown\n readonly nextValue?: unknown\n}\n\nexport interface RuntimeErrorEvent {\n readonly error: unknown\n readonly owner: Owner\n readonly phase: 'event' | 'boundary'\n readonly handled: boolean\n readonly recovery: 'propagated' | 'handled' | 'fallback' | 'retrying' | 'recovered'\n}\n\nexport interface RuntimeDebugHooks {\n domMutation?(mutation: RuntimeDomMutation): void\n error?(event: RuntimeErrorEvent): void\n hydrationMismatch?(event: RuntimeHydrationMismatch): void\n}\n\nlet activeRuntimeDebugHooks: RuntimeDebugHooks | null = null\nlet activeRuntimeDebugContext: RuntimeDebugContext | null = null\n\nexport function setRuntimeDebugHooks(hooks: RuntimeDebugHooks | null): RuntimeDebugHooks | null {\n const previous = activeRuntimeDebugHooks\n activeRuntimeDebugHooks = hooks\n return previous\n}\n\nexport function getRuntimeDebugHooks(): RuntimeDebugHooks | null {\n return activeRuntimeDebugHooks\n}\n\nexport function getRuntimeDebugContext(): RuntimeDebugContext | null {\n return activeRuntimeDebugContext\n}\n\n/** Run a synchronous operation with trace context, preserving async renders. */\nexport function runWithRuntimeDebugContext<T>(context: RuntimeDebugContext, task: () => T): T {\n const previous = activeRuntimeDebugContext\n const next = { ...previous, ...context }\n activeRuntimeDebugContext = next\n let result: T\n try {\n result = task()\n } catch (error) {\n activeRuntimeDebugContext = previous\n throw error\n }\n if (isPromiseLike(result)) {\n return Promise.resolve(result).finally(() => {\n if (activeRuntimeDebugContext === next) activeRuntimeDebugContext = previous\n }) as T\n }\n activeRuntimeDebugContext = previous\n return result\n}\n\n/** Keep a context active across callback boundaries such as Effect execution. */\nexport function pushRuntimeDebugContext(context: RuntimeDebugContext): () => void {\n const previous = activeRuntimeDebugContext\n activeRuntimeDebugContext = { ...previous, ...context }\n let restored = false\n return () => {\n if (restored) return\n restored = true\n activeRuntimeDebugContext = previous\n }\n}\n\nexport function invokeRuntimeDebug<K extends keyof RuntimeDebugHooks>(\n name: K,\n ...args: Parameters<NonNullable<RuntimeDebugHooks[K]>>\n): void {\n const callback = activeRuntimeDebugHooks?.[name] as ((...values: unknown[]) => void) | undefined\n if (!callback) return\n try {\n callback(...args)\n } catch {\n // Debug tooling must never change runtime behavior.\n }\n}\n\nexport function readDebugValue(read: () => unknown): unknown {\n try {\n return read()\n } catch {\n return '[Uninspectable]'\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return Boolean(value) && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as { then?: unknown }).then === 'function'\n}\n\nexport function describeDebugNode(node: unknown): string {\n if (!node || typeof node !== 'object') return 'node'\n const value = node as {\n readonly nodeName?: unknown\n readonly tagName?: unknown\n readonly id?: unknown\n readonly className?: unknown\n }\n const name = typeof value.tagName === 'string'\n ? value.tagName.toLowerCase()\n : typeof value.nodeName === 'string' ? value.nodeName.toLowerCase() : 'node'\n const id = typeof value.id === 'string' && value.id ? `#${value.id}` : ''\n const className = typeof value.className === 'string' && value.className\n ? `.${value.className.trim().split(/\\s+/).filter(Boolean).join('.')}`\n : ''\n return `${name}${id}${className}`\n}\n","import type { VobsNode } from './fragment'\n\nexport type HmrComponent<Props extends object = Record<string, unknown>> =\n (props: Props) => VobsNode\n\nexport interface HmrStateStore {\n get<T>(key: string, initial: T | (() => T)): T\n set<T>(key: string, value: T): void\n has(key: string): boolean\n delete(key: string): void\n clear(): void\n}\n\nexport interface HmrInstance {\n node: VobsNode\n parent: Node | null\n refresh(): void\n}\n\ninterface HmrModuleState {\n readonly components: Map<string, HmrComponent>\n readonly state: Map<string, unknown>\n readonly instances: Set<HmrInstance>\n}\n\ninterface HmrGlobal {\n modules: Map<string, HmrModuleState>\n /** 编译器生成的 hmrStateRef 注册表:键为 `${moduleId}#${声明名}`,值跨模块重执行保活。 */\n states: Map<string, unknown>\n}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>(), states: new Map<string, unknown>() }\nglobalTarget.__VOBS_HMR__ = hmrGlobal\n\nexport function resolveComponent<Props extends object>(\n component: HmrComponent<Props>,\n moduleId: string,\n exportName: string\n): HmrComponent<Props> {\n const module = getModule(moduleId)\n const existing = module.components.get(exportName)\n if (existing) return existing as HmrComponent<Props>\n\n const proxy = ((props: Props) => {\n const current = (proxy as HmrComponent<Props> & { current: HmrComponent<Props> }).current\n return current(props)\n }) as HmrComponent<Props> & { current: HmrComponent<Props> }\n proxy.current = component\n Object.defineProperties(proxy, {\n displayName: { configurable: true, value: component.name || exportName },\n hmrKey: { configurable: false, value: `${moduleId}:${exportName}` }\n })\n module.components.set(exportName, proxy as HmrComponent)\n return proxy\n}\n\nexport function updateHmrModule(moduleId: string, nextModule: Record<string, unknown>): void {\n const module = hmrGlobal.modules.get(moduleId)\n if (!module) return\n let changed = false\n for (const [name, proxy] of module.components) {\n const next = nextModule[name]\n if (typeof next !== 'function') continue\n const hmrProxy = proxy as HmrComponent & { current: HmrComponent; displayName?: string }\n hmrProxy.current = next as HmrComponent\n Object.defineProperty(hmrProxy, 'displayName', { configurable: true, value: next.name || name })\n changed = true\n }\n if (!changed) return\n // 快照后正序遍历:实例在自身渲染开始前注册,祖先必然先于后代入列——\n // 祖先先刷新会 dispose 上一轮渲染作用域,其树内旧后代实例的 refresh\n // 命中已销毁守卫被跳过,避免同一组件在一次热更新中重渲染两次。\n // 同时 refresh 重渲染以新代码创建的全新实例不在快照中,天然不会再刷新。\n const instances = [...module.instances]\n for (const instance of instances) {\n try {\n instance.refresh()\n } catch {\n // HMR failures remain application errors on the next normal render.\n }\n }\n}\n\nexport function disposeHmrModule(_moduleId: string): void {\n // State and component proxies intentionally survive module disposal.\n}\n\nexport function createHmrStateStore(moduleId: string): HmrStateStore {\n const state = getModule(moduleId).state\n return {\n get<T>(key: string, initial: T | (() => T)): T {\n if (!state.has(key)) state.set(key, typeof initial === 'function' ? (initial as () => T)() : initial)\n return state.get(key) as T\n },\n set<T>(key: string, value: T): void {\n state.set(key, value)\n },\n has: key => state.has(key),\n delete: key => { state.delete(key) },\n clear: () => { state.clear() }\n }\n}\n\n/**\n * 编译器为模块顶层 state() 声明生成的取值入口。键为 `${moduleId}#${声明名}`,\n * 与手动 store 键空间隔离。模块热更新重执行时复用既有信号实例:旧导入方持有的\n * 实例与新模块实例共享同一份状态,消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(key: string, create: () => T): T {\n const states = hmrGlobal.states\n if (states.has(key)) return states.get(key) as T\n const value = create()\n states.set(key, value)\n return value\n}\n\nexport function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void {\n const instances = getModule(moduleId).instances\n instances.add(instance)\n return () => instances.delete(instance)\n}\n\nexport function markHmrInstanceMounted(node: VobsNode, parent: Node): void {\n const instance = hmrInstances.get(node as object)\n if (instance) instance.parent = parent\n}\n\nfunction getModule(moduleId: string): HmrModuleState {\n let module = hmrGlobal.modules.get(moduleId)\n if (!module) {\n module = { components: new Map(), state: new Map(), instances: new Set() }\n hmrGlobal.modules.set(moduleId, module)\n }\n return module\n}\n\nconst hmrInstances = new WeakMap<object, HmrInstance>()\n\nexport function associateHmrInstance(node: VobsNode, instance: HmrInstance): void {\n hmrInstances.set(node as object, instance)\n}\n","import { getCurrentOwner } from '@vobs/reactivity'\n\n/** A mutable reference populated when a host node is mounted. */\nexport interface Ref<T extends object = Node> {\n current: T | null\n}\n\nexport type RefTarget<T extends object = Node> = Ref<T> | ((value: T | null) => void)\n\nexport function ref<T extends object = Node>(initialValue: T | null = null): Ref<T> {\n return { current: initialValue }\n}\n\n/** Bind a host node to an object or callback ref and clear it with its Owner. */\nexport function setRef<T extends object>(node: T, target: unknown): void {\n if (!isRefTarget<T>(target)) return\n // SSR's serializable nodes are never exposed as live refs. Custom renderers\n // may use arbitrary host objects, so only exclude the known SSR shape.\n if (isSSRNode(node)) return\n const owner = getCurrentOwner()\n assignRef(target, node)\n owner?.onDispose(() => {\n // Do not clear a ref that has since been reassigned to another node.\n if (isObjectRef(target) && target.current !== node) return\n assignRef(target, null)\n })\n}\n\nfunction isSSRNode(value: object): boolean {\n const type = (value as { type?: unknown }).type\n return (type === 'element' || type === 'text' || type === 'comment')\n && !('nodeType' in value)\n}\n\nfunction isObjectRef<T extends object>(value: unknown): value is Ref<T> {\n return Boolean(value && typeof value === 'object' && 'current' in value)\n}\n\nfunction isRefTarget<T extends object>(value: unknown): value is RefTarget<T> {\n return isObjectRef<T>(value) || typeof value === 'function'\n}\n\nfunction assignRef<T extends object>(target: RefTarget<T>, value: T | null): void {\n try {\n if (typeof target === 'function') target(value)\n else target.current = value\n } catch {\n // Ref callbacks are user code; never make mounting fail because of them.\n }\n}\n"],"mappings":";;;;AAEA,SAAS,aAAa,mBAAAA,kBAAiB,mBAAmB,eAA2B;;;ACFrF,SAAS,uBAAuB;AA+DzB,SAAS,eAAe,OAAuC;AACpE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAa,MAAuB,SA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zC,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,UAAU;AAAA,IACZ,CAAC;AAAA,EACH,QAAQ;AAAA,EAER;AACF;AAdS;AAgBT,SAAS,uBAAuB,QAAiB,WAAmB,SAAuB;AACzF,MAAI,CAAC,UAAW,OAAO,WAAW,YAAY,OAAO,WAAW,WAAa;AAC7E,QAAM,QAAQ;AACd,MAAI;AACF,QAAI,CAAC,MAAM,cAAe,QAAO,eAAe,OAAO,iBAAiB,EAAE,cAAc,MAAM,YAAY,OAAO,OAAO,WAAW,UAAU,MAAM,CAAC;AACpJ,QAAI,CAAC,MAAM,YAAa,QAAO,eAAe,OAAO,eAAe,EAAE,cAAc,MAAM,YAAY,OAAO,OAAO,SAAS,UAAU,MAAM,CAAC;AAAA,EAChJ,QAAQ;AAAA,EAER;AACF;AATS;AAWF,SAAS,YAAY,SAAqE;AAC/F,QAAM,QAAQ,YAAY;AAC1B,oBAAkB,OAAO,SAAS;AAClC,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACA,MAAI,CAAC,MAAM;AACT,UAAM,QAAQ;AACd,WAAO;AAAA,EACT;AACA,qBAAmB,MAAM,KAAK;AAC9B,SAAO;AACT;AAhBgB;AAkBT,SAAS,mBAAmB,MAAgB,OAAoB;AACrE,aAAW,IAAI,MAAM,KAAK;AAC5B;AAFgB;AAIT,SAAS,iBAAiB,MAAsB;AACrD,QAAM,QAAQ,WAAW,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO;AACZ,aAAW,OAAO,IAAI;AACtB,QAAM,QAAQ;AAChB;AALgB;","names":["getCurrentOwner","getCurrentOwner","getCurrentOwner","getCurrentOwner"]}
|
package/dist/profiler.cjs
CHANGED
|
@@ -89,6 +89,7 @@ __name(createComment, "createComment");
|
|
|
89
89
|
function insertBefore(parent, child, anchor) {
|
|
90
90
|
if (isVobsFragment(child)) {
|
|
91
91
|
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
92
|
+
markHmrInstanceMounted(child, parent);
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|