@vobs/runtime 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/async-boundary.cjs.map +1 -1
  2. package/dist/async-boundary.js +1 -1
  3. package/dist/async-boundary.js.map +1 -1
  4. package/dist/bind.cjs +18 -0
  5. package/dist/bind.cjs.map +1 -1
  6. package/dist/bind.js +19 -1
  7. package/dist/bind.js.map +1 -1
  8. package/dist/boundary.cjs.map +1 -1
  9. package/dist/boundary.js +1 -1
  10. package/dist/boundary.js.map +1 -1
  11. package/dist/dynamic.cjs.map +1 -1
  12. package/dist/dynamic.js +1 -1
  13. package/dist/dynamic.js.map +1 -1
  14. package/dist/error-boundary.cjs +5 -1
  15. package/dist/error-boundary.cjs.map +1 -1
  16. package/dist/error-boundary.d.cts +7 -3
  17. package/dist/error-boundary.d.ts +7 -3
  18. package/dist/error-boundary.js +6 -2
  19. package/dist/error-boundary.js.map +1 -1
  20. package/dist/fragment.cjs.map +1 -1
  21. package/dist/fragment.js +1 -1
  22. package/dist/fragment.js.map +1 -1
  23. package/dist/hmr.cjs +11 -0
  24. package/dist/hmr.cjs.map +1 -1
  25. package/dist/hmr.d.cts +7 -1
  26. package/dist/hmr.d.ts +7 -1
  27. package/dist/hmr.js +10 -0
  28. package/dist/hmr.js.map +1 -1
  29. package/dist/index.cjs +37 -3
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +37 -4
  34. package/dist/index.js.map +1 -1
  35. package/dist/ops.cjs +21 -2
  36. package/dist/ops.cjs.map +1 -1
  37. package/dist/ops.js +22 -3
  38. package/dist/ops.js.map +1 -1
  39. package/dist/profiler.cjs.map +1 -1
  40. package/dist/profiler.js +1 -1
  41. package/dist/profiler.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/dynamic.test.ts +65 -1
  44. package/src/error-boundary.ts +13 -3
  45. package/src/hmr.test.ts +17 -0
  46. package/src/hmr.ts +14 -0
  47. package/src/index.ts +1 -0
  48. package/src/ops.ts +38 -3
  49. package/src/props.test.ts +32 -1
package/dist/hmr.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hmr.ts"],"sourcesContent":["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}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>() }\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\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,IAAM,eAAe;AACrB,IAAM,YAAY,aAAa,gBAAgB,EAAE,SAAS,oBAAI,IAA4B,EAAE;AAC5F,aAAa,eAAe;AAErB,SAAS,iBACd,WACA,UACA,YACqB;AACrB,QAAMA,UAAS,U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OAAO;AACpG,aAAO,MAAM,IAAI,GAAG;AAAA,IACtB;AAAA,IACA,IAAO,KAAa,OAAgB;AAClC,YAAM,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,KAAK,gCAAO,MAAM,IAAI,GAAG,GAApB;AAAA,IACL,QAAQ,gCAAO;AAAE,YAAM,OAAO,GAAG;AAAA,IAAE,GAA3B;AAAA,IACR,OAAO,6BAAM;AAAE,YAAM,MAAM;AAAA,IAAE,GAAtB;AAAA,EACT;AACF;AAdgB;AAgBT,SAAS,oBAAoB,UAAkB,UAAmC;AACvF,QAAM,YAAY,UAAU,QAAQ,EAAE;AACtC,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAJgB;AAMT,SAAS,uBAAuB,MAAgB,QAAoB;AACzE,QAAM,WAAW,aAAa,IAAI,IAAc;AAChD,MAAI,SAAU,UAAS,SAAS;AAClC;AAHgB;AAKhB,SAAS,UAAU,UAAkC;AACnD,MAAIA,UAAS,UAAU,QAAQ,IAAI,QAAQ;AAC3C,MAAI,CAACA,SAAQ;AACX,IAAAA,UAAS,EAAE,YAAY,oBAAI,IAAI,GAAG,OAAO,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACzE,cAAU,QAAQ,IAAI,UAAUA,OAAM;AAAA,EACxC;AACA,SAAOA;AACT;AAPS;AAST,IAAM,eAAe,oBAAI,QAA6B;AAE/C,SAAS,qBAAqB,MAAgB,UAA6B;AAChF,eAAa,IAAI,MAAgB,QAAQ;AAC3C;AAFgB;","names":["module"]}
1
+ {"version":3,"sources":["../src/hmr.ts"],"sourcesContent":["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}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>() }\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() 声明生成的取值入口(`#state:` 前缀与手动 store 键隔离)。\n * 模块热更新重执行时复用既有信号实例:旧导入方持有的实例与新模块实例共享同一份状态,\n * 消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(moduleId: string, key: string, create: () => T): T {\n const state = getModule(moduleId).state\n const registryKey = `#state:${key}`\n if (state.has(registryKey)) return state.get(registryKey) as T\n const value = create()\n state.set(registryKey, 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,IAAM,eAAe;AACrB,IAAM,YAAY,aAAa,gBAAgB,EAAE,SAAS,oBAAI,IAA4B,EAAE;AAC5F,aAAa,eAAe;AAErB,SAAS,iBACd,WACA,UACA,YACqB;AACrB,QAAMA,UAAS,UAAU,QAAQ;AACjC,QAAM,WAAWA,QAAO,WAAW,IAAI,UAAU;AACjD,MAAI,SAAU,QAAO;AAErB,QA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M,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,KAAK,gCAAO,MAAM,IAAI,GAAG,GAApB;AAAA,IACL,QAAQ,gCAAO;AAAE,YAAM,OAAO,GAAG;AAAA,IAAE,GAA3B;AAAA,IACR,OAAO,6BAAM;AAAE,YAAM,MAAM;AAAA,IAAE,GAAtB;AAAA,EACT;AACF;AAdgB;AAqBT,SAAS,YAAe,UAAkB,KAAa,QAAoB;AAChF,QAAM,QAAQ,UAAU,QAAQ,EAAE;AAClC,QAAM,cAAc,UAAU,GAAG;AACjC,MAAI,MAAM,IAAI,WAAW,EAAG,QAAO,MAAM,IAAI,WAAW;AACxD,QAAM,QAAQ,OAAO;AACrB,QAAM,IAAI,aAAa,KAAK;AAC5B,SAAO;AACT;AAPgB;AAST,SAAS,oBAAoB,UAAkB,UAAmC;AACvF,QAAM,YAAY,UAAU,QAAQ,EAAE;AACtC,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAJgB;AAMT,SAAS,uBAAuB,MAAgB,QAAoB;AACzE,QAAM,WAAW,aAAa,IAAI,IAAc;AAChD,MAAI,SAAU,UAAS,SAAS;AAClC;AAHgB;AAKhB,SAAS,UAAU,UAAkC;AACnD,MAAIA,UAAS,UAAU,QAAQ,IAAI,QAAQ;AAC3C,MAAI,CAACA,SAAQ;AACX,IAAAA,UAAS,EAAE,YAAY,oBAAI,IAAI,GAAG,OAAO,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACzE,cAAU,QAAQ,IAAI,UAAUA,OAAM;AAAA,EACxC;AACA,SAAOA;AACT;AAPS;AAST,IAAM,eAAe,oBAAI,QAA6B;AAE/C,SAAS,qBAAqB,MAAgB,UAA6B;AAChF,eAAa,IAAI,MAAgB,QAAQ;AAC3C;AAFgB;","names":["module"]}
package/dist/hmr.d.cts CHANGED
@@ -17,8 +17,14 @@ declare function resolveComponent<Props extends object>(component: HmrComponent<
17
17
  declare function updateHmrModule(_moduleId: string, nextModule: Record<string, unknown>): void;
18
18
  declare function disposeHmrModule(_moduleId: string): void;
19
19
  declare function createHmrStateStore(moduleId: string): HmrStateStore;
20
+ /**
21
+ * 编译器为模块顶层 state() 声明生成的取值入口(`#state:` 前缀与手动 store 键隔离)。
22
+ * 模块热更新重执行时复用既有信号实例:旧导入方持有的实例与新模块实例共享同一份状态,
23
+ * 消除"两份模块、两份状态"导致的编辑不生效/页面半边失灵。
24
+ */
25
+ declare function hmrStateRef<T>(moduleId: string, key: string, create: () => T): T;
20
26
  declare function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void;
21
27
  declare function markHmrInstanceMounted(node: VobsNode, parent: Node): void;
22
28
  declare function associateHmrInstance(node: VobsNode, instance: HmrInstance): void;
23
29
 
24
- export { type HmrComponent, type HmrInstance, type HmrStateStore, associateHmrInstance, createHmrStateStore, disposeHmrModule, markHmrInstanceMounted, registerHmrInstance, resolveComponent, updateHmrModule };
30
+ export { type HmrComponent, type HmrInstance, type HmrStateStore, associateHmrInstance, createHmrStateStore, disposeHmrModule, hmrStateRef, markHmrInstanceMounted, registerHmrInstance, resolveComponent, updateHmrModule };
package/dist/hmr.d.ts CHANGED
@@ -17,8 +17,14 @@ declare function resolveComponent<Props extends object>(component: HmrComponent<
17
17
  declare function updateHmrModule(_moduleId: string, nextModule: Record<string, unknown>): void;
18
18
  declare function disposeHmrModule(_moduleId: string): void;
19
19
  declare function createHmrStateStore(moduleId: string): HmrStateStore;
20
+ /**
21
+ * 编译器为模块顶层 state() 声明生成的取值入口(`#state:` 前缀与手动 store 键隔离)。
22
+ * 模块热更新重执行时复用既有信号实例:旧导入方持有的实例与新模块实例共享同一份状态,
23
+ * 消除"两份模块、两份状态"导致的编辑不生效/页面半边失灵。
24
+ */
25
+ declare function hmrStateRef<T>(moduleId: string, key: string, create: () => T): T;
20
26
  declare function registerHmrInstance(moduleId: string, instance: HmrInstance): () => void;
21
27
  declare function markHmrInstanceMounted(node: VobsNode, parent: Node): void;
22
28
  declare function associateHmrInstance(node: VobsNode, instance: HmrInstance): void;
23
29
 
24
- export { type HmrComponent, type HmrInstance, type HmrStateStore, associateHmrInstance, createHmrStateStore, disposeHmrModule, markHmrInstanceMounted, registerHmrInstance, resolveComponent, updateHmrModule };
30
+ export { type HmrComponent, type HmrInstance, type HmrStateStore, associateHmrInstance, createHmrStateStore, disposeHmrModule, hmrStateRef, markHmrInstanceMounted, registerHmrInstance, resolveComponent, updateHmrModule };
package/dist/hmr.js CHANGED
@@ -67,6 +67,15 @@ function createHmrStateStore(moduleId) {
67
67
  };
68
68
  }
69
69
  __name(createHmrStateStore, "createHmrStateStore");
70
+ function hmrStateRef(moduleId, key, create) {
71
+ const state = getModule(moduleId).state;
72
+ const registryKey = `#state:${key}`;
73
+ if (state.has(registryKey)) return state.get(registryKey);
74
+ const value = create();
75
+ state.set(registryKey, value);
76
+ return value;
77
+ }
78
+ __name(hmrStateRef, "hmrStateRef");
70
79
  function registerHmrInstance(moduleId, instance) {
71
80
  const instances = getModule(moduleId).instances;
72
81
  instances.add(instance);
@@ -96,6 +105,7 @@ export {
96
105
  associateHmrInstance,
97
106
  createHmrStateStore,
98
107
  disposeHmrModule,
108
+ hmrStateRef,
99
109
  markHmrInstanceMounted,
100
110
  registerHmrInstance,
101
111
  resolveComponent,
package/dist/hmr.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hmr.ts"],"sourcesContent":["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}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>() }\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\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"],"mappings":";;;;AA6BA,IAAM,eAAe;AACrB,IAAM,YAAY,aAAa,gBAAgB,EAAE,SAAS,oBAAI,IAA4B,EAAE;AAC5F,aAAa,eAAe;AAErB,SAAS,iBACd,WACA,UACA,YACqB;AACrB,QAAM,SAAS,UAAU,QAAQ;AACjC,QAAM,WAAW,OAAO,WAAW,IAAI,UAAU;AACjD,MAAI,SAAU,QAAO;AAErB,QAAM,QAAS,yBAAC,UAAiB;AAC/B,UAAM,UAAW,MAAiE;AAClF,WAAO,QAAQ,KAAK;AAAA,EACtB,IAHe;AAIf,QAAM,UAAU;AAChB,SAAO,iBAAiB,OAAO;AAAA,IAC7B,aAAa,EAAE,cAAc,MAAM,OAAO,UAAU,QAAQ,WAAW;AAAA,IACvE,QAAQ,EAAE,cAAc,OAAO,OAAO,GAAG,QAAQ,IAAI,UAAU,GAAG;AAAA,EACpE,CAAC;AACD,SAAO,WAAW,IAAI,YAAY,KAAqB;AACvD,SAAO;AACT;AApBgB;AAsBT,SAAS,gBAAgB,WAAmB,YAA2C;AAC5F,QAAM,UAAU,CAAC,GAAG,UAAU,QAAQ,OAAO,CAAC;AAC9C,aAAW,UAAU,SAAS;AAC5B,QAAI,UAAU;AACd,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,YAAY;AAC7C,Y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AI,QAAQ;AAC3C,MAAI,CAAC,QAAQ;AACX,aAAS,EAAE,YAAY,oBAAI,IAAI,GAAG,OAAO,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACzE,cAAU,QAAQ,IAAI,UAAU,MAAM;AAAA,EACxC;AACA,SAAO;AACT;AAPS;AAST,IAAM,eAAe,oBAAI,QAA6B;AAE/C,SAAS,qBAAqB,MAAgB,UAA6B;AAChF,eAAa,IAAI,MAAgB,QAAQ;AAC3C;AAFgB;","names":[]}
1
+ {"version":3,"sources":["../src/hmr.ts"],"sourcesContent":["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}\n\nconst globalTarget = globalThis as typeof globalThis & { __VOBS_HMR__?: HmrGlobal }\nconst hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: new Map<string, HmrModuleState>() }\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() 声明生成的取值入口(`#state:` 前缀与手动 store 键隔离)。\n * 模块热更新重执行时复用既有信号实例:旧导入方持有的实例与新模块实例共享同一份状态,\n * 消除\"两份模块、两份状态\"导致的编辑不生效/页面半边失灵。\n */\nexport function hmrStateRef<T>(moduleId: string, key: string, create: () => T): T {\n const state = getModule(moduleId).state\n const registryKey = `#state:${key}`\n if (state.has(registryKey)) return state.get(registryKey) as T\n const value = create()\n state.set(registryKey, 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"],"mappings":";;;;AA6BA,IAAM,eAAe;AACrB,IAAM,YAAY,aAAa,gBAAgB,EAAE,SAAS,oBAAI,IAA4B,EAAE;AAC5F,aAAa,eAAe;AAErB,SAAS,iBACd,WACA,UACA,YACqB;AACrB,QAAM,SAAS,UAAU,QAAQ;AACjC,QAAM,WAAW,OAAO,WAAW,IAAI,UAAU;AACjD,MAAI,SAAU,QAAO;AAErB,QAAM,QAAS,yBAAC,UAAiB;AAC/B,UAAM,UAAW,MAAiE;AAClF,WAAO,QAAQ,KAAK;AAAA,EACtB,IAHe;AAIf,QAAM,UAAU;AAChB,SAAO,iBAAiB,OAAO;AAAA,IAC7B,aAAa,EAAE,cAAc,MAAM,OAAO,UAAU,QAAQ,WAAW;AAAA,IACvE,QAAQ,EAAE,cAAc,OAAO,OAAO,GAAG,QAAQ,IAAI,UAAU,GAAG;AAAA,EACpE,CAAC;AACD,SAAO,WAAW,IAAI,YAAY,KAAqB;AACvD,SAAO;AACT;AApBgB;AAsBT,SAAS,gBAAgB,WAAmB,YAA2C;AAC5F,QAAM,UAAU,CAAC,GAAG,UAAU,QAAQ,OAAO,CAAC;AAC9C,aAAW,UAAU,SAAS;AAC5B,QAAI,UAAU;AACd,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,YAAY;AAC7C,YAAM,OAAO,WAAW,IAAI;AAC5B,UAAI,OAAO,SAAS,WAAY;AAChC,YAAM,WAAW;AACjB,eAAS,UAAU;AACnB,aAAO,eAAe,UAAU,eAAe,EAAE,cAAc,MAAM,OAAO,KAAK,QAAQ,KAAK,CAAC;AAC/F,gBAAU;AAAA,IACZ;AACA,QAAI,C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AkC;AACnD,MAAI,SAAS,UAAU,QAAQ,IAAI,QAAQ;AAC3C,MAAI,CAAC,QAAQ;AACX,aAAS,EAAE,YAAY,oBAAI,IAAI,GAAG,OAAO,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACzE,cAAU,QAAQ,IAAI,UAAU,MAAM;AAAA,EACxC;AACA,SAAO;AACT;AAPS;AAST,IAAM,eAAe,oBAAI,QAA6B;AAE/C,SAAS,qBAAqB,MAAgB,UAA6B;AAChF,eAAa,IAAI,MAAgB,QAAQ;AAC3C;AAFgB;","names":[]}
package/dist/index.cjs CHANGED
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  getRenderer: () => getRenderer,
49
49
  getRuntimeDebugContext: () => getRuntimeDebugContext,
50
50
  getRuntimeDebugHooks: () => getRuntimeDebugHooks,
51
+ hmrStateRef: () => hmrStateRef,
51
52
  insertAsyncBoundary: () => insertAsyncBoundary,
52
53
  insertBefore: () => insertBefore,
53
54
  insertBoundary: () => insertBoundary,
@@ -232,6 +233,15 @@ function createHmrStateStore(moduleId) {
232
233
  };
233
234
  }
234
235
  __name(createHmrStateStore, "createHmrStateStore");
236
+ function hmrStateRef(moduleId, key, create) {
237
+ const state4 = getModule(moduleId).state;
238
+ const registryKey = `#state:${key}`;
239
+ if (state4.has(registryKey)) return state4.get(registryKey);
240
+ const value = create();
241
+ state4.set(registryKey, value);
242
+ return value;
243
+ }
244
+ __name(hmrStateRef, "hmrStateRef");
235
245
  function registerHmrInstance(moduleId, instance) {
236
246
  const instances = getModule(moduleId).instances;
237
247
  instances.add(instance);
@@ -372,6 +382,9 @@ __name(setTextContent, "setTextContent");
372
382
  function setProperty(node, key, value) {
373
383
  const previousValue = getRuntimeDebugHooks() ? readDebugValue(() => Reflect.get(node, key)) : void 0;
374
384
  getRenderer().setProperty(node, key, value);
385
+ if (key === "value" && node.tagName === "SELECT") {
386
+ scheduleSelectValueSync(node, value);
387
+ }
375
388
  if (getRuntimeDebugHooks()) {
376
389
  invokeRuntimeDebug("domMutation", {
377
390
  operation: "property",
@@ -383,6 +396,21 @@ function setProperty(node, key, value) {
383
396
  }
384
397
  }
385
398
  __name(setProperty, "setProperty");
399
+ var pendingSelectValues = /* @__PURE__ */ new WeakMap();
400
+ var selectSyncScheduled = /* @__PURE__ */ new WeakSet();
401
+ function scheduleSelectValueSync(node, value) {
402
+ pendingSelectValues.set(node, value);
403
+ if (selectSyncScheduled.has(node)) return;
404
+ selectSyncScheduled.add(node);
405
+ queueMicrotask(() => {
406
+ selectSyncScheduled.delete(node);
407
+ if (!pendingSelectValues.has(node)) return;
408
+ const pending = pendingSelectValues.get(node);
409
+ pendingSelectValues.delete(node);
410
+ getRenderer().setProperty(node, "value", pending);
411
+ });
412
+ }
413
+ __name(scheduleSelectValueSync, "scheduleSelectValueSync");
386
414
  function setAttribute(node, key, value) {
387
415
  const previousValue = getRuntimeDebugHooks() ? readDebugValue(() => typeof node.getAttribute === "function" ? node.getAttribute(key) : void 0) : void 0;
388
416
  getRenderer().setAttribute(node, key, value);
@@ -445,6 +473,7 @@ function addEventListener(node, event, handler) {
445
473
  if (previous && previous.original === handler && previous.owner === owner) return;
446
474
  if (previous) renderer.removeEventListener(node, event, previous.handler);
447
475
  const listener = owner ? (reason) => {
476
+ if (owner.disposed) return;
448
477
  try {
449
478
  owner.run(() => handler(reason));
450
479
  } catch (error) {
@@ -491,7 +520,7 @@ function createComponent(component, props, source) {
491
520
  });
492
521
  let node;
493
522
  try {
494
- node = owner.run(() => component(props));
523
+ node = owner.run(() => (0, import_reactivity2.untrack)(() => component(props)));
495
524
  } catch (error) {
496
525
  owner.dispose();
497
526
  attachSourceLocation(error, source);
@@ -506,7 +535,7 @@ function createComponent(component, props, source) {
506
535
  parent: null,
507
536
  refresh() {
508
537
  const previous = instance.node;
509
- const next = owner.run(() => component(props));
538
+ const next = owner.run(() => (0, import_reactivity2.untrack)(() => component(props)));
510
539
  if (instance.parent && !isVobsFragment(previous) && !isVobsFragment(next)) {
511
540
  getRenderer().insertBefore(instance.parent, next, previous);
512
541
  getRenderer().removeChild(instance.parent, previous);
@@ -1140,8 +1169,12 @@ function insertBoundary(parent, anchor, options) {
1140
1169
  __name(insertBoundary, "insertBoundary");
1141
1170
 
1142
1171
  // packages/runtime/src/error-boundary.ts
1172
+ function resolveBoundaryChildren(children) {
1173
+ return typeof children === "function" ? children : () => children;
1174
+ }
1175
+ __name(resolveBoundaryChildren, "resolveBoundaryChildren");
1143
1176
  function insertErrorBoundary(parent, anchor, options) {
1144
- insertBoundary(parent, anchor, options);
1177
+ insertBoundary(parent, anchor, { ...options, children: resolveBoundaryChildren(options.children) });
1145
1178
  }
1146
1179
  __name(insertErrorBoundary, "insertErrorBoundary");
1147
1180
  function ErrorBoundary(props) {
@@ -1294,6 +1327,7 @@ __name(now, "now");
1294
1327
  getRenderer,
1295
1328
  getRuntimeDebugContext,
1296
1329
  getRuntimeDebugHooks,
1330
+ hmrStateRef,
1297
1331
  insertAsyncBoundary,
1298
1332
  insertBefore,
1299
1333
  insertBoundary,