lithent 1.22.0 → 1.22.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 (45) hide show
  1. package/README.md +9 -0
  2. package/dist/lithent-agent-addon.md +15 -2
  3. package/dist/lithent.mjs +1 -1
  4. package/dist/lithent.mjs.map +1 -1
  5. package/dist/lithent.umd.js +1 -1
  6. package/dist/lithent.umd.js.map +1 -1
  7. package/dist/skills/lithent/SKILL.md +32 -3
  8. package/dist/skills/lithent/constraints/mistakes.md +4 -1
  9. package/dist/skills/lithent/constraints/rules.md +2 -1
  10. package/dist/skills/lithent/constraints/troubleshooting.md +4 -1
  11. package/dist/skills/lithent/examples/quick-examples.md +1 -1
  12. package/dist/skills/lithent/reference/children-type.md +1 -1
  13. package/dist/skills/lithent/reference/concurrent.md +104 -0
  14. package/dist/skills/lithent/reference/lstore-inference.md +1 -1
  15. package/dist/skills/lithent/reference/props-types.md +1 -1
  16. package/examples/dist/assets/index-oBwBT33f.js +2 -0
  17. package/examples/dist/assets/index-oBwBT33f.js.map +1 -0
  18. package/examples/dist/index.html +1 -1
  19. package/helper/dist/lithentHelper.mjs +96 -87
  20. package/helper/dist/lithentHelper.mjs.map +1 -1
  21. package/helper/dist/lithentHelper.umd.js +1 -1
  22. package/helper/dist/lithentHelper.umd.js.map +1 -1
  23. package/helper/package.json +4 -2
  24. package/helper/src/hook/lstore.ts +14 -0
  25. package/helper/src/hook/store.ts +14 -0
  26. package/helper/src/tests/contextRemoval.tsx +83 -0
  27. package/helper/src/tests/laneInteraction.tsx +324 -0
  28. package/helper/src/tests/storeVersion.tsx +88 -0
  29. package/jsx-runtime/dist/index.d.ts +8 -2
  30. package/jsx-runtime/dist/jsxRuntime.mjs +10 -7
  31. package/jsx-runtime/dist/jsxRuntime.mjs.map +1 -1
  32. package/jsx-runtime/dist/jsxRuntime.umd.js +1 -1
  33. package/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
  34. package/jsx-runtime/package.json +4 -2
  35. package/jsx-runtime/src/index.ts +17 -5
  36. package/package.json +28 -4
  37. package/src/hook/internal/unmount.ts +3 -0
  38. package/src/tests/core-removedRedraw.test.tsx +70 -0
  39. package/ssr/dist/lithentSsr.mjs +80 -77
  40. package/ssr/dist/lithentSsr.mjs.map +1 -1
  41. package/ssr/dist/lithentSsr.umd.js +2 -2
  42. package/ssr/dist/lithentSsr.umd.js.map +1 -1
  43. package/ssr/src/tests/laneHydration.tsx +91 -0
  44. package/examples/dist/assets/index-fEEXG6OR.js +0 -2
  45. package/examples/dist/assets/index-fEEXG6OR.js.map +0 -1
package/README.md CHANGED
@@ -122,8 +122,17 @@ const Counter = lmount(() => {
122
122
  | [lithent/ssr](https://www.npmjs.com/package/lithent) | Server‑side rendering |
123
123
  | [lithent/ftags](https://www.npmjs.com/package/lithent) | Function‑style tag API |
124
124
  | [lithent/tag](https://www.npmjs.com/package/lithent) | HTM template support |
125
+ | [lithent-concurrent](./lithentConcurrent/README.md) | Separate core with priority scheduling and interruptible low-priority builds |
126
+ | [lithent-concurrent/helper](./lithentConcurrent/README.md#lithent-concurrenthelper) | Deferred state and component-local pending queries |
125
127
  | [create-lithent](https://www.npmjs.com/package/create-lithent) | Project scaffolding tool |
126
128
 
129
+ For expensive component trees, select the concurrent core with an exact
130
+ `/^lithent$/` bundler alias. `deferRender` defers rendering while state writes
131
+ remain immediate; `whenIdle` waits for deferred work. Keep urgent input and
132
+ heavy rendering in separate components. See the [concurrent rendering
133
+ guide](https://superlucky84.github.io/lithent/#/guide/concurrent-rendering) and
134
+ [release notes](./CHANGELOG.md).
135
+
127
136
  <br />
128
137
 
129
138
  ## License
@@ -1,6 +1,6 @@
1
1
  # Lithent Agent Addon
2
2
 
3
- > Version: 1.22.0
3
+ > Version: 1.22.1
4
4
 
5
5
  You are a coding agent with Lithent virtual DOM guidance enabled.
6
6
 
@@ -47,7 +47,7 @@ CODING GUIDELINES:
47
47
  4. LIFECYCLE HOOKS
48
48
  - Use `mountCallback` for setup after mount (return cleanup function)
49
49
  - Use `updateCallback` for logic before each update
50
- - Use `mountReadyCallback` for logic after initial render
50
+ - Use `mountReadyCallback` for logic right after the WDom is created (before DOM insertion)
51
51
  - Place hooks in mounter function, not in updater
52
52
 
53
53
  5. LIST RENDERING
@@ -82,12 +82,22 @@ CODING GUIDELINES:
82
82
  - Access children as third parameter in mounter function
83
83
  - Don't modify children directly, wrap or filter them
84
84
 
85
+ 11. CONCURRENT RENDERING (only when `lithent-concurrent` is installed or requested)
86
+ - Suggest it only for very large trees (thousands of rows); plain `lithent` otherwise
87
+ - Select the core with an exact `/^lithent$/` alias; never alias `lithent/*` subpaths
88
+ - Keep urgent input state and the heavy list in separate components
89
+ - `deferRender` runs its scope synchronously; only rendering is deferred
90
+ - `await nextTick()` covers sync commits; use `await whenIdle()` for deferred renders
91
+ - `hasPendingRender` is a query, not reactive; show pending from a sync parent
92
+ - No Suspense or `use()`; updateCallback's return value is not an unmount cleanup
93
+
85
94
  IMPORT PATHS:
86
95
  - Core: `import { mount, lmount, render, h, Fragment, portal, ref, nextTick } from 'lithent'`
87
96
  - Lifecycle: `import { mountCallback, updateCallback, mountReadyCallback } from 'lithent'`
88
97
  - Helper (manual): `import { state, store, createContext, computed, effect } from 'lithent/helper'`
89
98
  - Helper (light): `import { lstate, lstore, createLContext } from 'lithent/helper'`
90
99
  - Helper (utils): `import { cacheUpdate, nextTickRender, unwrapChildren } from 'lithent/helper'`
100
+ - Concurrent (optional): `import { deferRender, whenIdle } from 'lithent-concurrent'` and `import { deferred, ldeferred, hasPendingRender } from 'lithent-concurrent/helper'`
91
101
  - SSR: `import { renderToString, hydration } from 'lithent/ssr'`
92
102
  - FTags: `import { fTags, fFragment, fMount } from 'lithent/ftags'`
93
103
  - HTM: `import { lTag } from 'lithent/tag'`
@@ -116,11 +126,14 @@ COMMON MISTAKES TO CATCH:
116
126
  - Missing `key` prop in list iterations
117
127
  - Calling hooks inside updater instead of mounter
118
128
  - Mutating state directly instead of using `.value`
129
+ - Using `deferRender` while the urgent state and heavy list share one component
130
+ - Aliasing `lithent` with a prefix match so `lithent/helper` is rewritten too
119
131
 
120
132
  REFERENCE MATERIALS (NOT PART OF BEHAVIORAL RULES):
121
133
 
122
134
  For detailed code examples and API usage, refer to:
123
135
  node_modules/lithent/dist/skills/lithent/SKILL.md
136
+ (concurrent details: node_modules/lithent/dist/skills/lithent/reference/concurrent.md)
124
137
 
125
138
  This reference material provides comprehensive examples, patterns,
126
139
  and import references that complement the behavioral guidelines above.
package/dist/lithent.mjs CHANGED
@@ -54,7 +54,7 @@ const Pe = (e) => {
54
54
  }
55
55
  }, L = (e) => {
56
56
  const { compKey: t } = e;
57
- t && Qe(t), ue(e);
57
+ t && (e.il = !0, Qe(t)), ue(e);
58
58
  }, ue = (e) => {
59
59
  (e.children || []).forEach((t) => {
60
60
  t.compKey ? L(t) : ue(t);
@@ -1 +1 @@
1
- {"version":3,"file":"lithent.mjs","sources":["../src/utils/universalRef.ts","../src/utils/index.ts","../src/utils/predicator.ts","../src/hook/internal/unmount.ts","../src/hook/mountCallback.ts","../src/hook/mountReadyCallback.ts","../src/hook/internal/useUpdate.ts","../src/render.ts","../src/diff.ts","../src/utils/redraw.ts","../src/hook/updateCallback.ts","../src/wDom.ts","../src/hook/ref.ts","../src/hook/useRenew.ts"],"sourcesContent":["import { ComponentMap, ComponentSubKey, CompKey, ComponentInfo } from '@/types';\n\nexport const wdomSymbol = Symbol.for('lithentWDomSymbol');\nexport const xmlnsRef: { value: string } = { value: '' };\nexport const compKeyRef: { value: CompKey | null } = { value: null };\nexport const needDiffRef: { value: boolean } = { value: false };\nexport const componentMap: ComponentMap = new WeakMap();\nexport const lmountComponentSet: WeakSet<Function> = new WeakSet();\nlet componentMapManualMode = false;\n\nconst setComponetRef = (compKey: CompKey): void => {\n componentMap.set(compKey, {\n vd: { value: null },\n up: () => {},\n upR: [],\n upS: { value: 0 },\n upD: [],\n upCB: [],\n mts: [],\n umts: [],\n wdCB: [], // WDom creation callback queue\n });\n};\n\nexport const getComponentKey = (): CompKey | null => compKeyRef.value;\n\nexport const getComponentSubInfo = <K extends ComponentSubKey>(\n compKey: CompKey,\n subKey: K\n): ComponentInfo[K] | null => {\n const component = componentMap.get(compKey);\n if (component) {\n return component[subKey];\n }\n return null;\n};\n\nexport const initUpdateHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n};\n\nexport const initMountHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n setComponetRef(compKey);\n};\n\nexport const setComponentMapManualMode = (enabled: boolean): void => {\n componentMapManualMode = enabled;\n};\n\nexport const isComponentMapManualMode = (): boolean => componentMapManualMode;\n\nexport const runUnmountEffects = (compKey: CompKey): void => {\n const subInfo = componentMap.get(compKey);\n if (subInfo) {\n subInfo.umts.forEach(effect => effect());\n subInfo.umts = [];\n }\n};\n\nexport const disposeComponentEntry = (compKey: CompKey): void => {\n runUnmountEffects(compKey);\n componentMap.delete(compKey);\n};\n","import { WDom, Props } from '@/types';\n\nimport { wdomSymbol } from '@/utils/universalRef';\n\nexport const getParent = (vDom: WDom) =>\n (vDom.getParent && vDom.getParent()) as WDom;\n\nexport const entries = Object.entries;\nexport const keys = Object.keys;\n\nexport const isObject = (target: unknown): target is Record<string, unknown> =>\n typeof target === 'object' && target !== null;\n\nexport const assign = Object.assign;\nexport const isPropType = (obj: unknown): obj is Props => {\n return (\n isObject(obj) &&\n !Array.isArray(obj) &&\n !Object.getOwnPropertySymbols(obj).includes(wdomSymbol)\n );\n};\n","import { Fragment } from '@/wDom';\nimport {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n WDomType,\n} from '@/types';\nimport { isObject } from '@/utils';\n\ntype WDomParam =\n | string\n | WDom\n | TagFunction\n | TagFunctionResolver\n | FragmentFunction;\n\n/**\n * Predicator\n */\n\nconst checkPlainWDomType = (wDom: WDomParam): wDom is WDom =>\n isObject(wDom) && !('resolve' in wDom);\n\nconst checkPlainType = (wDom: WDomParam, typeName: string) =>\n checkPlainWDomType(wDom) && wDom.type === typeName;\n\nconst checkSameCustomComponent = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n 'ctor' in newWDom\n ? newWDom.ctor === (originalWDom && originalWDom.ctor)\n : newWDom === (originalWDom && originalWDom.ctor);\n\nconst checkSameFragment = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === 'f' &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkSameTagElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === 'e' &&\n originalWDom.tag === newWDom.tag &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkNormalTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type\n );\n\nconst checkLoopTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type &&\n ((checkExistyKey((newWDom.children || [])[0]) &&\n checkExistyKey((originalWDom.children || [])[0])) ||\n (originalWDom.children &&\n newWDom.children &&\n originalWDom.children.length === newWDom.children.length))\n );\n\nexport const getKey = (target: WDom) =>\n (target && target.compProps && target.compProps.key) ??\n (target && target.props && target.props.key);\n\n/**\n * Check if the type is virtual (fragment or loop)\n * Virtual types don't create real DOM elements themselves\n */\nexport const checkVirtualType = (\n type?: string | null // 'f': fragment, 'l': loop\n) => type === 'f' || type === 'l';\n\nexport const checkCustemComponentFunction = (\n target: WDomParam\n): target is TagFunction | TagFunctionResolver =>\n (typeof target === 'function' && !checkFragmentFunction(target)) ||\n (isObject(target) && 'resolve' in target);\n\nexport const checkFragmentFunction = (\n target: unknown\n): target is FragmentFunction =>\n typeof target === 'function' && target === Fragment;\n\nexport const checkEmptyElement = (wDom: WDomParam) =>\n checkPlainWDomType(wDom) && !wDom.type;\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\n\nexport const checkExisty = (value: unknown) =>\n value !== null && value !== undefined;\n\nexport const checkStyleData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is Record<string, string> =>\n dataKey === 'style' && isObject(dataValue);\n\nexport const checkRefData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is {\n value: HTMLElement | Element | DocumentFragment | Text | undefined;\n} => dataKey === 'ref' && isObject(dataValue);\n\n// Descriptor lookups are cached per nodeName+key (HTML nodeName is uppercase,\n// SVG lowercase, so the two prototypes never collide on the same cache key).\nconst accessorCache = new Map<string, boolean>();\n\nexport const hasAccessorMethods = (target: unknown, dataKey: string) => {\n const cacheKey = (target as HTMLElement).nodeName + '|' + dataKey;\n let result = accessorCache.get(cacheKey);\n\n if (result === undefined) {\n const descriptor = Object.getOwnPropertyDescriptor(\n target!.constructor.prototype,\n dataKey\n );\n result = !!(descriptor && descriptor.get && descriptor.set);\n accessorCache.set(cacheKey, result);\n }\n\n return result;\n};\n\n/**\n * Get WDom type as a single character code\n * 'c': component, 'f': fragment, 'e': element, 'l': loop, 't': text, 'et': empty/null\n */\nexport const getWDomType = (\n wDom: WDom | TagFunction | TagFunctionResolver\n): WDomType =>\n checkCustemComponentFunction(wDom)\n ? 'c'\n : checkPlainType(wDom, 'f')\n ? 'f'\n : checkPlainType(wDom, 'e')\n ? 'e'\n : checkPlainType(wDom, 'l')\n ? 'l'\n : checkPlainType(wDom, 't')\n ? 't'\n : 'et';\n\nexport const checkSameWDomWithOriginal = {\n c: checkSameCustomComponent,\n l: checkLoopTypeElement,\n t: checkNormalTypeElement,\n e: checkSameTagElement,\n f: checkSameFragment,\n et: checkNormalTypeElement,\n};\n","import { WDom, CompKey } from '@/types';\nimport {\n componentMap,\n getComponentKey,\n isComponentMapManualMode,\n runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.umts.push(effectAction);\n }\n};\n\nexport const runUnmountQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n removeItem(compKey);\n }\n recursiveRunUnmount(newWDom);\n};\n\nconst recursiveRunUnmount = (wDom: WDom) => {\n (wDom.children || []).forEach(item => {\n const childComKey = item.compKey;\n if (childComKey) {\n runUnmountQueueFromWDom(item);\n } else {\n recursiveRunUnmount(item);\n }\n });\n};\n\nconst removeItem = (compKey: CompKey) => {\n runUnmountEffects(compKey);\n\n if (!isComponentMapManualMode()) {\n componentMap.delete(compKey);\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\nlet mountedQueue: WDom[] = [];\n\n/**\n * WDom을 mountedQueue에 추가\n */\nexport const addMountedQueue = (wDom: WDom) => {\n if (wDom.compKey) {\n mountedQueue.push(wDom);\n }\n};\n\n/**\n * DOM 렌더링 후 mountCallback 실행\n */\nexport const execMountedQueue = () => {\n mountedQueue.forEach(item => runMountedQueueFromWDom(item));\n mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.mts.push(effectAction);\n }\n }\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { mts: mountQueue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (mountQueue) {\n component.mts = [];\n\n mountQueue.forEach((effect: Function) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.wdCB.push(effectAction);\n }\n};\n\n/**\n * 특정 WDom의 wdomCallback 즉시 실행\n * wDomToDom() 내부에서 각 WDom 생성 시점에 호출됨\n */\nexport const runWDomCallbacksFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n const wdCBQueue = component && component.wdCB;\n\n compKeyRef.value = compKey;\n\n if (wdCBQueue && wdCBQueue.length > 0) {\n component.wdCB = [];\n\n wdCBQueue.forEach((effect: Function) => {\n const cleanup = effect();\n if (cleanup && typeof cleanup === 'function') {\n unmount(cleanup);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\n if (!component) return;\n\n const { upD, upS } = component;\n const def = upD[upS.value];\n\n const nextDependencies = dependencies();\n\n if (def && checkNeedPushQueue(def, nextDependencies)) {\n const callback = effectAction();\n if (callback) {\n component.upCB.push(callback);\n }\n }\n\n upD[upS.value] = nextDependencies;\n upS.value += 1;\n};\n\nexport const runUpdatedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { upCB: queue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (newWDom.ctor && queue) {\n component.upCB = [];\n queue.forEach((effect: Function) => effect());\n }\n }\n};\n\nconst checkNeedPushQueue = (originalDefs: unknown[], newDefs: unknown[]) =>\n !originalDefs.length\n ? true\n : originalDefs.some((def, index) => def !== newDefs[index]);\n","import { WDom, Props } from '@/types';\nimport {\n checkStyleData,\n checkRefData,\n checkExisty,\n checkVirtualType,\n hasAccessorMethods,\n} from '@/utils/predicator';\n\nimport { componentMap, xmlnsRef } from '@/utils/universalRef';\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { execMountedQueue, addMountedQueue } from '@/hook/mountCallback';\nimport { runWDomCallbacksFromWDom } from '@/hook/mountReadyCallback';\nimport { runUpdatedQueueFromWDom } from '@/hook/internal/useUpdate';\nimport { getParent, isObject } from '@/utils';\n\nconst DF = () => new DocumentFragment();\nconst CE = (t: string) => document.createElement(t);\n\nexport const render = (\n wDom: WDom,\n wrapElement: HTMLElement | null,\n afterElement?: HTMLElement | null,\n isHydration?: boolean\n) => {\n wDom.isRoot = true;\n wrapElement = wrapElement || document.body;\n wDom.we = wrapElement;\n\n const Dom = wDomToDom(wDom, isHydration);\n\n if (afterElement) {\n wDom.ae = afterElement;\n wrapElement.insertBefore(Dom, afterElement);\n } else if (!isHydration) {\n if (wrapElement.tagName === 'HTML') {\n wrapElement.replaceWith(Dom);\n } else {\n wrapElement.appendChild(Dom);\n }\n }\n\n execMountedQueue();\n\n return () => {\n const compData = componentMap.get(wDom.compProps || {});\n const comp = (compData && compData.vd.value) || wDom;\n if (comp !== wDom) runUnmountQueueFromWDom(comp);\n recursiveRemoveEvent(comp);\n rootDelete(comp);\n };\n};\n\nexport const recursiveRemoveEvent = (originalWDom: WDom) => {\n if (originalWDom.props && originalWDom.el) {\n removeEvent(originalWDom.props, originalWDom.el);\n }\n\n (originalWDom.children || []).forEach((childItem: WDom) => {\n recursiveRemoveEvent(childItem);\n });\n};\n\nconst rootDelete = (newWDom: WDom) =>\n deleteRealDom(newWDom, newWDom.we as HTMLElement);\n\nexport const typeDelete = (newWDom: WDom) => {\n if (newWDom.op && newWDom.el) {\n removeEvent(newWDom.op, newWDom.el);\n }\n\n const parentWDom = getParent(newWDom);\n const parentElement = newWDom.isRoot\n ? newWDom.we\n : parentWDom\n ? findRealParentElement(parentWDom)\n : undefined;\n\n if (parentElement) {\n deleteRealDom(newWDom, parentElement as HTMLElement);\n }\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n if (parent && newWDom.el) {\n const nt = newWDom.el.nodeType;\n if (nt === 11 || newWDom?.tag === 'portal') {\n findChildWithRemoveElement(newWDom, parent);\n } else if (nt === 1 || nt === 3) {\n parent.removeChild(newWDom.el);\n }\n\n delete newWDom.el;\n }\n};\n\nconst findChildWithRemoveElement = (newWDom: WDom, parent: HTMLElement) => {\n const items = (newWDom && newWDom.oc) || (newWDom && newWDom.children) || [];\n\n // Bulk fast path: the parent element contains exactly these children,\n // so they can all be dropped in a single operation.\n // (counted via sibling pointers -- childNodes would materialize a live list)\n let count = 0;\n for (let node = parent.firstChild; node; node = node.nextSibling) {\n count++;\n }\n\n if (\n items.length > 1 &&\n count === items.length &&\n items.every(item => {\n const nt = item.el && item.el.nodeType;\n return (\n (nt === 1 || nt === 3) &&\n (item.el as HTMLElement).tagName !== 'HTML' &&\n item.tag !== 'portal'\n );\n })\n ) {\n parent.textContent = '';\n items.forEach(item => delete item.el);\n return;\n }\n\n items.forEach(item => {\n const nt = item.el && item.el.nodeType;\n if (nt) {\n if (nt === 1 || nt === 3) {\n const el = item.el as HTMLElement;\n el.tagName === 'HTML' ? (el.innerHTML = '') : el.remove();\n } else if (nt === 11) {\n findChildWithRemoveElement(item, parent);\n }\n }\n });\n};\n\n/**\n * Unmount, detach events, and remove unused keyed children.\n */\nexport const typeDeleteUnused = (items: WDom[]) => {\n items.forEach(item => {\n runUnmountQueueFromWDom(item);\n recursiveRemoveEvent(item);\n typeDelete(item);\n });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\n\nconst typeSortedUpdate = (newWDom: WDom) => {\n typeUpdate(newWDom);\n\n if (getParent(newWDom) || newWDom.isRoot) {\n typeAdd(newWDom, getElementFromFragment(newWDom));\n }\n};\n\nconst typeAdd = (\n newWDom: WDom,\n newElement?: HTMLElement | DocumentFragment | Text\n) => {\n if (!newElement) {\n newElement = wDomToDom(newWDom) as HTMLElement;\n }\n\n const parentWDom = getParent(newWDom);\n if (!parentWDom || !parentWDom.type) {\n if (\n newWDom.isRoot &&\n newWDom.we &&\n newElement &&\n newWDom.tag !== 'portal'\n ) {\n if (newWDom.ae) {\n newWDom.we.insertBefore(newElement, newWDom.ae);\n } else if (newWDom.we.tagName === 'HTML') {\n newWDom.we.replaceWith(newElement);\n } else {\n newWDom.we.appendChild(newElement);\n }\n execMountedQueue();\n }\n return;\n }\n\n const parentEl = findRealParentElement(parentWDom);\n const nextEl =\n parentWDom.type === 'l' && parentWDom.nr\n ? startFindNextBrotherElement(parentWDom, getParent(parentWDom))\n : startFindNextBrotherElement(newWDom, parentWDom);\n\n if (newElement && parentEl) {\n if (newWDom.tag !== 'portal') {\n parentEl.insertBefore(newElement, nextEl || null);\n }\n execMountedQueue();\n }\n};\n\nconst getElementFromFragment = (newWDom: WDom) => {\n if (checkVirtualType(newWDom.type)) {\n return ((newWDom && newWDom.children) || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n\n if (element) {\n acc.appendChild(element);\n }\n return acc;\n }, DF());\n }\n\n return newWDom.el;\n};\n\nconst startFindNextBrotherElement = (\n wDom: WDom,\n parentWDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const brothers = parentWDom.children || [];\n const index = brothers.indexOf(wDom);\n const nextIndex = index + 1;\n const candidiateBrothers = brothers.slice(nextIndex);\n\n const finedNextEl = findChildFragmentNextElement(candidiateBrothers);\n const parentType = parentWDom.type || '';\n\n if (finedNextEl) {\n return finedNextEl;\n }\n\n if (!parentWDom.isRoot && checkVirtualType(parentType)) {\n return startFindNextBrotherElement(parentWDom, getParent(parentWDom));\n } else if (\n parentWDom.isRoot &&\n checkVirtualType(parentType) &&\n parentWDom.ae\n ) {\n return parentWDom.ae;\n }\n\n return undefined;\n};\n\nconst findChildFragmentNextElement = (\n candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n (targetEl, bItem) => {\n if (targetEl) return targetEl;\n const { type, el } = bItem;\n if (type && checkVirtualType(type)) {\n const found = findChildFragmentNextElement(bItem.children || []);\n if (found) return found;\n }\n if (el && el.nodeType !== 11) return el;\n return targetEl;\n },\n undefined\n );\n\nconst typeReplace = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n const orignalElement = newWDom.el;\n\n if (newWDom.isRoot && !parentWDom && orignalElement) {\n typeSortedReplace(newWDom);\n return;\n }\n\n if (parentWDom && parentWDom.type && orignalElement) {\n if (orignalElement.nodeType === 11) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement && newWDom.tag !== 'portal') {\n parentElement.replaceChild(newElement, orignalElement);\n }\n execMountedQueue();\n }\n }\n};\n\nconst removeEvent = (\n oldProps: Props,\n element: HTMLElement | DocumentFragment | Text\n) => {\n for (const dataKey in oldProps) {\n if (dataKey[0] === 'o' && dataKey[1] === 'n') {\n element.removeEventListener(\n dataKey.slice(2).toLowerCase(),\n oldProps[dataKey] as (e: Event) => void\n );\n }\n }\n};\n\nconst typeUpdate = (newWDom: WDom) => {\n if (newWDom.type === 't') {\n updateText(newWDom);\n return;\n }\n\n if (newWDom.el) {\n const { op: oldProps, props } = newWDom;\n updateProps(props, newWDom.el, oldProps);\n delete newWDom.op;\n\n if (newWDom.tag === 'input') {\n (newWDom.el as HTMLInputElement).value = String(\n (props && props.value) || ''\n );\n }\n }\n\n updateChildren(newWDom);\n runUpdatedQueueFromWDom(newWDom);\n};\n\n/**\n * Process child updates. Loop parents with added/moved children are handled\n * in O(n): a left-to-right content pass (keeps lifecycle order), an LIS over\n * the matched original indices (oi, recorded by the diff phase) to pick the\n * children that can stay in place, and a right-to-left placement pass that\n * inserts only added children and non-LIS moves before a running anchor.\n */\nconst updateChildren = (newWDom: WDom) => {\n const children = newWDom.children || [];\n let needPlace = false;\n\n if (newWDom.type === 'l') {\n for (const item of children) {\n if ('ATS'.includes(item.nr as string) || item.oi !== undefined) {\n needPlace = true;\n break;\n }\n }\n }\n\n if (!needPlace) {\n children.forEach(childItem => wDomUpdate(childItem));\n return;\n }\n\n // Content pass (left-to-right, keeps lifecycle order).\n // Added children are created here but inserted in the placement pass.\n const created: (HTMLElement | DocumentFragment | Text | undefined)[] = [];\n const matchedIndexes: number[] = [];\n const oiSeq: number[] = [];\n let createdCount = 0;\n\n children.forEach((item, index) => {\n const nr = item.nr;\n\n if (nr === 'A' || nr === 'S') {\n if (nr === 'S') {\n typeDelete(item);\n }\n created[index] = wDomToDom(item);\n createdCount++;\n } else if (nr === 'T') {\n typeUpdate(item);\n } else {\n wDomUpdate(item);\n }\n\n if (item.oi !== undefined && created[index] === undefined) {\n matchedIndexes.push(index);\n oiSeq.push(item.oi);\n }\n });\n\n const stay = new Set(getLisPositions(oiSeq).map(pos => matchedIndexes[pos]));\n const parentEl = findRealParentElement(newWDom);\n const baseAnchor = newWDom.isRoot\n ? newWDom.ae\n : startFindNextBrotherElement(newWDom, getParent(newWDom));\n\n // Fast-append the trailing run of added children in order\n // (a null anchor makes insertBefore behave as appendChild).\n let tail = children.length;\n while (tail > 0 && created[tail - 1] !== undefined) {\n tail--;\n }\n\n for (let i = tail; i < children.length; i++) {\n const el = created[i];\n\n if (el && parentEl && children[i].tag !== 'portal') {\n parentEl.insertBefore(el, baseAnchor || null);\n }\n }\n\n if (\n stay.size !== matchedIndexes.length ||\n createdCount > children.length - tail\n ) {\n // Placement pass (right-to-left): insert added children and non-LIS\n // moves before a running anchor.\n let anchor =\n findChildFragmentNextElement(children.slice(tail)) || baseAnchor;\n\n for (let i = tail - 1; i >= 0; i--) {\n const item = children[i];\n const isNew = created[i] !== undefined;\n const needMove = item.oi !== undefined && !isNew && !stay.has(i);\n\n if ((isNew || needMove) && parentEl && item.tag !== 'portal') {\n const el = isNew ? created[i] : getElementFromFragment(item);\n\n if (el) {\n parentEl.insertBefore(el, anchor || null);\n }\n }\n\n const first = findChildFragmentNextElement([item]);\n if (first) {\n anchor = first;\n }\n }\n }\n\n children.forEach(clearDiffMeta);\n execMountedQueue();\n};\n\nconst clearDiffMeta = (item: WDom) => {\n delete item.oi;\n delete item.nr;\n delete item.oc;\n delete item.op;\n};\n\n/**\n * Longest increasing subsequence positions (binary search, O(n log n)).\n * Returns the positions in seq that form the LIS.\n */\nconst getLisPositions = (seq: number[]) => {\n const result: number[] = [];\n\n if (!seq.length) {\n return result;\n }\n\n const prev = new Array(seq.length);\n result.push(0);\n\n for (let i = 1; i < seq.length; i++) {\n const value = seq[i];\n\n if (seq[result[result.length - 1]] < value) {\n prev[i] = result[result.length - 1];\n result.push(i);\n continue;\n }\n\n let lo = 0;\n let hi = result.length - 1;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (seq[result[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n\n if (value < seq[result[lo]]) {\n if (lo > 0) {\n prev[i] = result[lo - 1];\n }\n result[lo] = i;\n }\n }\n\n let i = result.length;\n let last = result[i - 1];\n while (i-- > 0) {\n result[i] = last;\n last = prev[last];\n }\n\n return result;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n const { nr: needRerender } = newWDomTree;\n\n if (needRerender !== undefined && needRerender !== 'N') {\n renderHandlers[needRerender](newWDomTree);\n clearDiffMeta(newWDomTree);\n }\n};\n\nconst renderHandlers = {\n A: typeAdd,\n D: typeDelete,\n R: typeReplace,\n U: typeUpdate,\n S: typeSortedReplace,\n T: typeSortedUpdate,\n} as const;\n\nconst updateText = (newWDom: WDom) => {\n if (newWDom.el) {\n newWDom.el.nodeValue = String(newWDom.text);\n }\n};\n\nconst updateProps = (\n props?: Props,\n element?: HTMLElement | Element | DocumentFragment | Text,\n oldProps?: Props | null,\n isHydration?: boolean\n) => {\n const originalProps = oldProps || {};\n\n for (const dataKey in props) {\n const dataValue: unknown = props[dataKey];\n\n if (dataValue === originalProps[dataKey]) {\n delete originalProps[dataKey];\n continue;\n }\n\n const isEvent = dataKey[0] === 'o' && dataKey[1] === 'n';\n\n if (isHydration && isEvent) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else {\n if (dataKey === 'key') {\n // Do nothing\n } else if (dataKey === 'portal' && isObject(dataValue)) {\n // Do nothing\n } else if (dataKey === 'innerHTML' && typeof dataValue === 'string') {\n (element as HTMLElement).innerHTML = dataValue;\n } else if (checkStyleData(dataKey, dataValue)) {\n updateStyle(\n dataValue,\n checkStyleData(dataKey, originalProps.style)\n ? originalProps.style\n : {},\n element\n );\n } else if (checkRefData(dataKey, dataValue)) {\n dataValue.value = element;\n } else if (isEvent) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else if (dataKey) {\n if (dataKey !== 'type' && hasAccessorMethods(element, dataKey)) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n } else {\n setAttr(\n dataKey === 'className' ? 'class' : dataKey,\n element as HTMLElement,\n dataValue as string\n );\n }\n }\n\n delete originalProps[dataKey];\n }\n }\n\n for (const dataKey in originalProps) {\n (element as HTMLElement).removeAttribute(dataKey);\n }\n};\n\nconst setAttr = (k: string, el: HTMLElement, v: string) =>\n xmlnsRef.value && k !== 'xmlns'\n ? el.setAttributeNS(null, k, v)\n : el.setAttribute(k, v);\n\nconst wDomToDom = (wDom: WDom, isHydration?: boolean): HTMLElement => {\n let element;\n const { type, tag, text, props, children = [] } = wDom;\n const isVirtualType = checkVirtualType(type);\n\n runWDomCallbacksFromWDom(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = String(props && props.xmlns);\n }\n\n if (!isHydration) {\n if (!type) {\n element = DF();\n } else if (isVirtualType) {\n element = DF();\n } else if (type === 'e' && tag) {\n // element\n if (tag === 'portal' && props && props.portal) {\n element = props.portal as HTMLElement;\n } else {\n element = xmlnsRef.value\n ? document.createElementNS(xmlnsRef.value, tag)\n : CE(tag);\n }\n } else if (type === 't' && checkExisty(text)) {\n // text node\n element = document.createTextNode(String(text));\n } else {\n throw Error('Invalid wDom');\n }\n\n wDom.el = element as HTMLElement;\n } else {\n element = wDom.el;\n }\n\n wDomChildrenToDom(children, element, isHydration);\n\n updateProps(props, element, null, isHydration);\n\n addMountedQueue(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = '';\n }\n\n return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\n children: WDom[],\n parentElement?: HTMLElement | Element | DocumentFragment | Text,\n isHydration?: boolean\n) => {\n // The parent is not attached to the document yet, so children can be\n // appended directly (no intermediate fragment allocation).\n children.forEach((childItem: WDom) => {\n if (childItem.type) {\n const childElement = wDomToDom(childItem, isHydration);\n if (childItem.tag !== 'portal' && !isHydration && parentElement) {\n parentElement.appendChild(childElement);\n }\n }\n });\n};\n\nconst updateEvent = (\n element: HTMLElement,\n eventKey: string,\n newEventHandler: (e: Event) => void,\n oldEventHandler: (e: Event) => void\n) => {\n const eventName = eventKey.slice(2).toLowerCase();\n\n if (oldEventHandler !== newEventHandler) {\n if (oldEventHandler) {\n element.removeEventListener(eventName, oldEventHandler);\n }\n\n if (newEventHandler) {\n element.addEventListener(eventName, newEventHandler);\n }\n }\n};\n\nconst updateStyle = (\n style: Record<string, string>,\n oldStyle: Record<string, string>,\n element?: HTMLElement | Element | DocumentFragment | Text\n) => {\n const orig = { ...oldStyle };\n const htmlElement = element instanceof HTMLElement ? element : null;\n const cssStyle = htmlElement?.style;\n\n if (!cssStyle) return;\n\n const styleProxy = cssStyle as unknown as Record<string, string>;\n\n for (const k in style) {\n styleProxy[k] = style[k];\n delete orig[k];\n }\n\n for (const k in orig) {\n styleProxy[k] = '';\n }\n};\n\nconst findRealParentElement = (\n vDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const isVirtualType = checkVirtualType(vDom.type);\n if (vDom.isRoot && isVirtualType) {\n return vDom.we;\n }\n\n if (!isVirtualType) {\n return vDom.el as HTMLElement;\n }\n\n return findRealParentElement(getParent(vDom));\n};\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent } from '@/utils';\nimport { typeDeleteUnused, recursiveRemoveEvent } from '@/render';\nimport {\n checkEmptyElement,\n checkSameWDomWithOriginal,\n getWDomType,\n checkExistyKey,\n} from '@/utils/predicator';\n\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { keys, entries } from '@/utils';\n\n/**\n * The starting point of the diffing process between the original virtual DOM and the new virtual DOM for re-rendering.\n */\nexport const makeNewWDomTree = (\n newWDom: WDom | TagFunctionResolver,\n originalWDom?: WDom\n) =>\n remakeNewWDom(\n newWDom,\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\n );\n\n/**\n * Create a new virtual DOM after comparing with the previous virtual DOM\n */\nconst remakeNewWDom = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n) => {\n const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n const needRerender = addReRenderTypeProperty(\n remakeWDom,\n isSameType,\n originalWDom\n );\n const isNoting = needRerender === 'N';\n\n if (!isNoting) {\n remakeWDom.children = remakeChildrenForDiff(\n remakeWDom,\n isSameType,\n originalWDom\n );\n }\n\n // NOTE: short-key metadata (nr = needRerender) keeps bundle size down\n remakeWDom.nr = needRerender;\n inheritPropForRender(remakeWDom, originalWDom, needRerender);\n\n if (!isNoting && originalWDom) {\n originalWDom.il = true;\n delete originalWDom.children;\n }\n if (originalWDom?.tag === 'portal') {\n remakeWDom.tag = 'portal';\n }\n\n return remakeWDom;\n};\n\n/**\n * Handle what the new virtual DOM should inherit or reconcile from the original virtual DOM.\n */\nconst inheritPropForRender = (\n remakeWDom: WDom,\n originalWDom?: WDom,\n needRerender?: RenderType\n) => {\n if (needRerender !== 'A' && originalWDom) {\n remakeWDom.el = originalWDom.el;\n }\n\n if (needRerender === 'D' || needRerender === 'R' || needRerender === 'S') {\n if (originalWDom) {\n runUnmountQueueFromWDom(originalWDom);\n recursiveRemoveEvent(originalWDom);\n }\n remakeWDom.oc = originalWDom && originalWDom.children;\n }\n\n remakeWDom.op = originalWDom && originalWDom.props;\n};\n\n/**\n * Determine the render operation type (Add/Delete/Replace/Update/etc)\n * based on comparison between new and original WDom\n */\nconst addReRenderTypeProperty = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n): RenderType | undefined => {\n if (checkEmptyElement(newWDom)) return 'D';\n\n const isSameText =\n newWDom.type === 't' &&\n isSameType &&\n newWDom.text === (originalWDom && originalWDom.text);\n if (isSameText || newWDom === originalWDom) return 'N';\n\n const existOriginalWDom = originalWDom && originalWDom.type;\n if (!existOriginalWDom) return 'A';\n\n const parent = getParent(originalWDom);\n const isKeyChecked =\n !newWDom.isRoot && parent && parent.type === 'l' && checkExistyKey(newWDom);\n\n return isSameType ? (isKeyChecked ? 'T' : 'U') : isKeyChecked ? 'S' : 'R';\n};\n\n/**\n * Handling virtual DOM attribute updates.\n */\nconst syncResolverProps = (props: Props, infoProps: Props) => {\n if (props && infoProps !== props) {\n keys(props).forEach(key => delete props[key]);\n entries(infoProps || {}).forEach(([key, value]) => (props[key] = value));\n }\n};\n\nconst syncResolverChildren = (children: WDom[], infoChidren: WDom[]) => {\n if (children) {\n children.splice(0, children.length);\n\n if (infoChidren) {\n infoChidren.forEach(childrenItem => children.push(childrenItem));\n }\n }\n};\n\n/**\n * Keep the existing component node while injecting the props/children from the freshly computed TagFunctionResolver.\n * originalWDom is the fully evaluated node from the previous render, whereas infoVdom is the intermediate resolver,\n * so updating compProps/compChild in place lets reRender() evaluate with the latest slots and props.\n * It is crucial that props and children references remain stable as nodes update—many ancestors/closures share these arrays,\n * so mutate the existing arrays instead of replacing their references.\n */\nconst runUpdate = (vDom: WDom, infoVdom: TagFunctionResolver) => {\n const { compProps: props, compChild: children } = vDom;\n const { props: infoProps, children: infoChidren } = infoVdom;\n\n if (props) {\n syncResolverProps(props, infoProps);\n }\n\n /**\n * In runUpdate, the original DOM (vDom) is already fully evaluated and completed, whereas infoVdom represents an intermediate state. Therefore, vdom.compChild and infoVdom.children are indeed the correct counterparts to compare.\n\n * Keep shared child array references intact (<= same slot array instance)\n * When the reference changes, sync the stored compChild contents so reRender sees fresh nodes\n * Only update children if they're different references\n * If it's the same Fragment reference, the diff process will handle updating its children\n */\n if (children && infoChidren && children !== infoChidren) {\n syncResolverChildren(children, infoChidren);\n }\n\n const newVDom = vDom.reRender && vDom.reRender();\n\n return newVDom as WDom;\n};\n\n/**\n * Replace the compared virtual DOM with the new virtual DOM or simply update it.\n */\nconst generalize = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n): WDom => {\n return checkCustemComponentFunction(newWDom)\n ? isSameType && originalWDom\n ? runUpdate(originalWDom, newWDom)\n : newWDom.resolve()\n : newWDom;\n};\n\n/**\n * 자식 가상돔들도 전부 재귀처리하며 똑같은 처리를 해준다.\n */\nconst remakeChildrenForDiff = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n) =>\n isSameType && originalWDom\n ? remakeChildrenForUpdate(newWDom, originalWDom)\n : remakeChildrenForAdd(newWDom);\n\n/**\n * Recursive handling for the creation of a new virtual DOM.\n */\nconst remakeChildrenForAdd = (newWDom: WDom) => {\n const getParent = () => newWDom;\n\n return (newWDom.children || []).map((item: WDom) => {\n const child = makeNewWDomTree(item);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling for updates, not additions.\n * Uses key-based diffing for loops, index-based for others\n */\nconst remakeChildrenForUpdate = (newWDom: WDom, originalWDom: WDom) => {\n if (newWDom.type === 'l' && checkExistyKey((newWDom.children || [])[0])) {\n return remakeChildrenForLoopUpdate(newWDom, originalWDom);\n }\n\n const origChildren = originalWDom.children || [];\n const getParent = () => newWDom;\n\n return (newWDom.children || []).map((item: WDom, index: number) => {\n const child = makeNewWDomTree(item, origChildren[index]);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Handling virtual DOM of loop-type elements.\n */\nconst remakeChildrenForLoopUpdate = (newWDom: WDom, originalWDom: WDom) => {\n const [remakedChildren, unUsedChildren] = diffLoopChildren(\n newWDom,\n originalWDom\n );\n\n typeDeleteUnused(unUsedChildren);\n\n return remakedChildren;\n};\n\n/**\n * Recursive handling of loop-type virtual DOM elements.\n * Matches children against the originals by key via a Map in O(n) and\n * records each match's original index (oi) for the render phase to\n * minimize moves via LIS.\n */\nconst diffLoopChildren = (newWDom: WDom, originalWDom: WDom) => {\n const origChildren = originalWDom.children || [];\n const keyMap = new Map<unknown, number>();\n origChildren.forEach((item, index) => {\n const key = getKey(item);\n if (!keyMap.has(key)) {\n keyMap.set(key, index);\n }\n });\n\n const getParent = () => newWDom;\n const remaked = (newWDom.children || []).map(item => {\n const key = getKey(item);\n const origIndex = keyMap.get(key);\n const matched = origIndex !== undefined;\n\n if (matched) {\n keyMap.delete(key);\n }\n\n const child = makeNewWDomTree(\n item,\n matched ? origChildren[origIndex] : undefined\n );\n if (matched) {\n child.oi = origIndex;\n }\n child.getParent = getParent;\n\n return child;\n });\n\n return [remaked, [...keyMap.values()].map(index => origChildren[index])];\n};\n","import { Props } from '@/types';\nimport { componentMap } from '@/utils/universalRef';\n\nconst redrawQueue = new Map<Props, () => void>();\nlet redrawQueueTimeout: boolean = false;\n\nexport const setRedrawAction = (compKey: Props, exec: () => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => {\n redrawQueue.set(compKey, exec);\n\n if (!redrawQueueTimeout) {\n redrawQueueTimeout = true;\n queueMicrotask(execRedrawQueue);\n }\n };\n }\n};\n\nexport const componentUpdate = (compKey: Props) => () => {\n const comp = componentMap.get(compKey);\n const up = comp && comp.up;\n if (up) {\n up();\n return true;\n }\n return false;\n};\n\nconst execRedrawQueue = () => {\n redrawQueue.forEach((item: () => void) => {\n item();\n });\n\n redrawQueue.clear();\n redrawQueueTimeout = false;\n};\n","import { componentMap, getComponentKey } from '@/utils/universalRef';\n\nimport { useUpdated } from '@/hook/internal/useUpdate';\n\ntype DependencyFactory = () => unknown[];\n\nexport const updateCallback = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\n if (!component) return;\n\n component.upR.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const comp = componentMap.get(compKey);\n const updateReqs = comp && comp.upR;\n\n if (updateReqs && updateReqs.length) {\n updateReqs.forEach(callback => callback());\n }\n};\n","import {\n WDom,\n TagFunction,\n FragmentFunction,\n Props,\n MiddleStateWDomChildren,\n MiddleStateWDom,\n NodePointer,\n Component,\n LComponent,\n} from '@/types';\n\nimport { makeNewWDomTree } from '@/diff';\nimport { wDomUpdate } from '@/render';\nimport {\n initUpdateHookState,\n initMountHookState,\n needDiffRef,\n getComponentSubInfo,\n wdomSymbol,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { setRedrawAction, componentUpdate } from '@/utils/redraw';\nimport { runUpdateCallback } from '@/hook/updateCallback';\nimport {\n checkFragmentFunction,\n checkCustemComponentFunction,\n} from '@/utils/predicator';\nimport { assign } from '@/utils';\n\n// ============================================================================\n// Public API - Highest Level (User-facing API)\n// ============================================================================\n\n/**\n * It allows grouping multiple elements together.\n */\nexport const Fragment = (_props: Props, ...children: WDom[]) =>\n ({\n type: 'f', // fragment\n [wdomSymbol]: true,\n children,\n }) as WDom;\n\n/**\n * Element creation\n */\nexport const h = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n ...children: MiddleStateWDomChildren\n) => {\n const nodeParentPointer: NodePointer = { value: undefined };\n const newChildren = remakeChildren(nodeParentPointer, children);\n const node = makeNode(tag, props || {}, newChildren);\n\n if (!checkCustemComponentFunction(node)) {\n nodeParentPointer.value = node;\n }\n\n return node;\n};\n\n/**\n * Enables portals\n */\nexport const portal = (wDom: WDom, portal: HTMLElement) =>\n h('portal', { portal }, wDom);\n\n/**\n * It helps with component creation.\n */\nexport const mount =\n <T>(component: Component<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) =>\n component;\n\n/**\n * It helps with component creation without renew parameter.\n * Use useRenew() hook to get renew function if needed.\n */\nexport const lmount =\n <T>(component: LComponent<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) => {\n lmountComponentSet.add(component);\n return component;\n };\n\n/**\n * Maintain compChild references for upward updates (render props, slots, etc.).\n * JSX always returns a fresh children array, so when a subtree re-renders\n * bottom-up we must manually swap the old child instance out of each ancestor's\n * compChild.\n *\n * Fragment-wrapping solved this by keeping a stable wrapper node,\n * but that hides the actual child tree. We prefer this explicit sync for DX.\n *\n * In practice slot consumers rarely thread children more than a layer or two—\n * usually shallow composed pieces like dropdowns or drag-and-drop shells—so the\n * directed walk keeps DX high without introducing observable overhead.\n */\nconst syncAncestorComponentChildren = (\n parent: WDom | undefined,\n prevChild: WDom,\n nextChild: WDom\n) => {\n const walk = (node: WDom | undefined, visited: Set<WDom>): void => {\n if (!node || visited.has(node)) {\n return;\n }\n\n visited.add(node);\n\n if (node.compChild) {\n const childIndex = node.compChild.indexOf(prevChild);\n\n if (childIndex !== -1) {\n node.compChild.splice(childIndex, 1, nextChild);\n }\n }\n\n walk(node.getParent ? node.getParent() : undefined, visited);\n };\n\n walk(parent, new Set<WDom>());\n};\n\n/**\n * It re-renders starting from a specific component.\n */\nexport const replaceWDom = (\n tag: TagFunction,\n props: Props,\n children: WDom[],\n originalWDom: WDom\n) => {\n if (originalWDom.il) {\n return;\n }\n needDiffRef.value = true;\n\n const newWDom = makeWDomResolver(tag, props, children);\n const newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n // NOTE: we/ae are short for wrapElement/afterElement\n const { isRoot, getParent, we, ae } = originalWDom;\n\n newWDomTree.getParent = getParent;\n\n if (!isRoot && getParent) {\n const parent = getParent();\n const brothers = (parent && parent.children) || [];\n const index = brothers.indexOf(originalWDom);\n\n if (index !== -1) {\n brothers.splice(index, 1, newWDomTree);\n }\n\n syncAncestorComponentChildren(parent, originalWDom, newWDomTree);\n } else {\n newWDomTree.isRoot = true;\n newWDomTree.we = we;\n newWDomTree.ae = ae;\n }\n\n needDiffRef.value = false;\n\n wDomUpdate(newWDomTree);\n};\n\n// ============================================================================\n// Mid-Level - Virtual DOM Node Creation (Intermediate abstraction level)\n// ============================================================================\n\n/**\n * The starting point where the virtual DOM is created from the h function.\n */\nconst makeNode = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n children: WDom[]\n) => {\n if (checkFragmentFunction(tag)) {\n return Fragment(props, ...children);\n } else if (checkCustemComponentFunction(tag)) {\n const componetMakeResolver = makeWDomResolver(tag, props, children);\n\n return needDiffRef.value\n ? componetMakeResolver\n : componetMakeResolver.resolve();\n }\n\n return {\n type: 'e', // element\n [wdomSymbol]: true,\n tag,\n props,\n children,\n } as WDom;\n};\n\n/**\n * The starting point for recursively processing the child virtual DOM elements.\n */\nconst remakeChildren = (\n nodeParentPointer: NodePointer,\n children: MiddleStateWDomChildren\n): WDom[] => {\n // Siblings share a single getParent closure (one allocation per parent)\n const getParent = () => nodeParentPointer.value;\n\n return children.map((item: MiddleStateWDom) => {\n const childItem = makeChildrenItem(item);\n childItem.getParent = getParent;\n return childItem;\n });\n};\n\n/**\n * Recursively process the child virtual DOM elements.\n */\nconst makeChildrenItem = (item: MiddleStateWDom): WDom => {\n if (item === null || item === undefined || item === false) {\n return { type: null, [wdomSymbol]: true } as WDom;\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = {\n type: 'l', // loop (array mapping)\n [wdomSymbol]: true,\n children,\n } as WDom;\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return { type: 't', [wdomSymbol]: true, text: item } as WDom; // text node\n }\n\n return item;\n};\n\n// ============================================================================\n// Component Lifecycle - Component Creation & Re-rendering\n// ============================================================================\n\n/**\n * Create component resolver function\n */\nconst createComponentResolver = (\n tag: TagFunction,\n props: Props,\n wrappedChildren: WDom[]\n) => {\n return (compKey = props) => {\n // Diff mode sets needDiffRef to true so h()/makeNode return a resolver\n // placeholder. During actual resolution we must force a real WDom tree,\n // otherwise nested components leave only resolvers (no getParent/children)\n // and CSR renders a blank area. Temporarily drop needDiffRef, then restore.\n // Regression tests: src/tests/core-composedRenew.test.tsx,\n // src/tests/core-component-remount.test.tsx\n const prevNeedDiff = needDiffRef.value;\n needDiffRef.value = false;\n\n initMountHookState(compKey);\n\n const initialComponent = tag(props, wrappedChildren);\n\n let componentMaker: (nextProps: Props) => MiddleStateWDom;\n\n if (typeof initialComponent === 'function') {\n const component = initialComponent;\n // Check if component is created with lmount (no renew parameter)\n // TypeScript cannot infer that component is LComponent when has() returns true,\n // because WeakSet.has() is a runtime check that doesn't narrow types.\n // We use 'as any' since the runtime check guarantees type safety.\n componentMaker = lmountComponentSet.has(component)\n ? (component as any)(props, wrappedChildren)\n : component(componentUpdate(compKey), props, wrappedChildren);\n } else {\n // For components that directly return a VDom, recreate it each render.\n componentMaker = (nextProps: Props) =>\n tag(nextProps, wrappedChildren) as MiddleStateWDom;\n }\n\n const node = makeCustomNode(\n componentMaker,\n compKey,\n tag,\n props,\n wrappedChildren\n );\n needDiffRef.value = prevNeedDiff;\n return node;\n };\n};\n\n/**\n * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (tag: TagFunction, props: Props, children: WDom[]) => {\n const ctor = tag;\n\n const wrappedChildren = children;\n\n const resolve = createComponentResolver(tag, props, wrappedChildren);\n\n return { ctor, props, children: wrappedChildren, resolve };\n};\n\n/**\n * Create the actual virtual DOM node from the component.\n */\nconst makeCustomNode = (\n componentMaker: (props: Props) => MiddleStateWDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const normalizedComponentMaker = (nextProps: Props): WDom =>\n makeChildrenItem(componentMaker(nextProps));\n const { wrappedComponentMaker, customNode } = wrapComponentMakerIfNeeded(\n normalizedComponentMaker,\n props\n );\n const reRender = makeReRender(\n wrappedComponentMaker,\n compKey,\n tag,\n props,\n children\n );\n\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n return customNode;\n};\n\n/**\n * When the virtual DOM is actually created from the component, generate a re-render method for future redraws.\n */\nconst makeReRender = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const reRender = () =>\n wDomMaker(componentMaker, compKey, tag, props, children, reRender);\n return reRender;\n};\n\n/**\n * The starting point for redrawing from the re-render method\n */\nconst wDomMaker = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n initUpdateHookState(compKey);\n runUpdateCallback();\n\n const customNode = componentMaker(props);\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n\n return customNode;\n};\n\n// ============================================================================\n// Low-Level Utilities - Component Node Manipulation\n// ============================================================================\n\n/**\n * Wrap component output in a stable Fragment so component metadata lives on a\n * dedicated node. This prevents parent/child sharing when a component returns\n * another component and keeps updates stable even when output becomes empty.\n */\nconst wrapComponentMakerIfNeeded = (\n componentMaker: (props: Props) => WDom,\n props: Props\n): { wrappedComponentMaker: (props: Props) => WDom; customNode: WDom } => {\n const wrappedComponentMaker = (newProps: Props): WDom => {\n const next = componentMaker(newProps);\n const wrapper = Fragment({}, next);\n next.getParent = () => wrapper;\n return wrapper;\n };\n\n const customNode = wrappedComponentMaker(props);\n\n return { wrappedComponentMaker, customNode };\n};\n\n/**\n * When creating a custom component node, attach additional information attributes to the virtual DOM object.\n */\nconst addComponentProps = (\n wDom: WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n assign(wDom, {\n compProps: props,\n compChild: children,\n ctor: tag,\n compKey,\n reRender,\n });\n\n setRedrawAction(compKey, () =>\n replaceWDom(\n tag,\n (wDom.compProps as Props) || props,\n (wDom.compChild as WDom[]) || children,\n wDom\n )\n );\n\n if (getComponentSubInfo(compKey, 'vd')) {\n (getComponentSubInfo(compKey, 'vd') as { value: WDom }).value = wDom;\n }\n};\n","export const ref = <T>(initValue: T) => ({ value: initValue });\nexport const nextTick = () => Promise.resolve();\n","import { Renew } from '@/types';\nimport { getComponentKey } from '@/utils/universalRef';\nimport { componentUpdate } from '@/utils/redraw';\n\n/**\n * Hook to get the renew (component update) function.\n * Useful for lmount components that need to trigger updates.\n */\nexport const useRenew = (): Renew => {\n const compKey = getComponentKey();\n\n if (!compKey) {\n return () => false;\n }\n\n return componentUpdate(compKey);\n};\n"],"names":["wdomSymbol","xmlnsRef","compKeyRef","needDiffRef","componentMap","lmountComponentSet","componentMapManualMode","setComponetRef","compKey","getComponentKey","getComponentSubInfo","subKey","component","initUpdateHookState","initMountHookState","setComponentMapManualMode","enabled","isComponentMapManualMode","runUnmountEffects","subInfo","effect","disposeComponentEntry","getParent","vDom","entries","keys","isObject","target","assign","isPropType","obj","checkPlainWDomType","wDom","checkPlainType","typeName","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkExistyKey","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","checkExisty","value","checkStyleData","dataKey","dataValue","checkRefData","accessorCache","hasAccessorMethods","cacheKey","result","descriptor","getWDomType","checkSameWDomWithOriginal","unmount","effectAction","comp","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","mountedQueue","addMountedQueue","execMountedQueue","runMountedQueueFromWDom","mountCallback","mountQueue","sequence","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","CE","t","render","wrapElement","afterElement","isHydration","Dom","wDomToDom","compData","recursiveRemoveEvent","rootDelete","removeEvent","childItem","deleteRealDom","typeDelete","parentWDom","parentElement","findRealParentElement","parent","nt","findChildWithRemoveElement","items","count","node","el","typeDeleteUnused","typeSortedReplace","typeAdd","typeSortedUpdate","typeUpdate","getElementFromFragment","newElement","parentEl","nextEl","startFindNextBrotherElement","acc","element","brothers","nextIndex","candidiateBrothers","finedNextEl","findChildFragmentNextElement","parentType","targetEl","bItem","found","typeReplace","orignalElement","oldProps","updateText","props","updateProps","updateChildren","children","needPlace","wDomUpdate","created","matchedIndexes","oiSeq","createdCount","nr","stay","getLisPositions","pos","baseAnchor","tail","anchor","i","isNew","needMove","first","clearDiffMeta","seq","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","isEvent","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","htmlElement","cssStyle","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","key","syncResolverChildren","infoChidren","childrenItem","runUpdate","infoVdom","remakeChildrenForUpdate","remakeChildrenForAdd","child","remakeChildrenForLoopUpdate","origChildren","remakedChildren","unUsedChildren","diffLoopChildren","keyMap","origIndex","matched","redrawQueue","redrawQueueTimeout","setRedrawAction","exec","execRedrawQueue","componentUpdate","up","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newChildren","remakeChildren","makeNode","portal","mount","_children","lmount","syncAncestorComponentChildren","prevChild","nextChild","walk","visited","childIndex","replaceWDom","makeWDomResolver","isRoot","we","ae","componetMakeResolver","makeChildrenItem","createComponentResolver","wrappedChildren","prevNeedDiff","initialComponent","componentMaker","nextProps","makeCustomNode","ctor","resolve","normalizedComponentMaker","wrappedComponentMaker","customNode","wrapComponentMakerIfNeeded","reRender","makeReRender","addComponentProps","wDomMaker","newProps","next","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"AAEa,MAAAA,IAAa,OAAO,IAAI,mBAAmB,GAC3CC,IAA8B,EAAE,OAAO,MACvCC,IAAwC,EAAE,OAAO,QACjDC,IAAkC,EAAE,OAAO,MAC3CC,wBAAiC,QAAQ,GACzCC,yBAA4C,QAAQ;AACjE,IAAIC,KAAyB;AAE7B,MAAMC,KAAiB,CAACC,MAA2B;AACjD,EAAAJ,EAAa,IAAII,GAAS;AAAA,IACxB,IAAI,EAAE,OAAO,KAAK;AAAA,IAClB,IAAI,MAAM;AAAA,IAAC;AAAA,IACX,KAAK,CAAC;AAAA,IACN,KAAK,EAAE,OAAO,EAAE;AAAA,IAChB,KAAK,CAAC;AAAA,IACN,MAAM,CAAC;AAAA,IACP,KAAK,CAAC;AAAA,IACN,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA;AAAA,EAAA,CACR;AACH,GAEaC,IAAkB,MAAsBP,EAAW,OAEnDQ,IAAsB,CACjCF,GACAG,MAC4B;AACtB,QAAAC,IAAYR,EAAa,IAAII,CAAO;AAC1C,SAAII,IACKA,EAAUD,CAAM,IAElB;AACT,GAEaE,KAAsB,CAACL,MAA2B;AAC7D,EAAAN,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H,CAAK;AACvC,SAAAkI,GAAkBJ,GAAYvQ,GAAS+K,GAAKtC,GAAOG,GAAU6H,CAAQ,GAE9DF;AACT,GAWMC,KAA6B,CACjCR,GACAvH,MACwE;AAClE,QAAA6H,IAAwB,CAACO,MAA0B;AACjD,UAAAC,IAAOd,EAAea,CAAQ,GAC9BE,IAAUvO,EAAS,CAAC,GAAGsO,CAAI;AACjC,WAAAA,EAAK,YAAY,MAAMC,GAChBA;AAAA,EAAA,GAGHR,IAAaD,EAAsB7H,CAAK;AAEvC,SAAA,EAAE,uBAAA6H,GAAuB,YAAAC;AAClC,GAKMI,KAAoB,CACxBnP,GACAxB,GACA+K,GACAtC,GACAG,GACA6H,MACG;AACH,EAAArP,GAAOI,GAAM;AAAA,IACX,WAAWiH;AAAA,IACX,WAAWG;AAAA,IACX,MAAMmC;AAAA,IACN,SAAA/K;AAAA,IACA,UAAAyQ;AAAA,EAAA,CACD,GAED5C;AAAA,IAAgB7N;AAAA,IAAS,MACvBqP;AAAA,MACEtE;AAAA,MACCvJ,EAAK,aAAuBiH;AAAA,MAC5BjH,EAAK,aAAwBoH;AAAA,MAC9BpH;AAAA,IACF;AAAA,EAAA,GAGEtB,EAAoBF,GAAS,IAAI,MAClCE,EAAoBF,GAAS,IAAI,EAAsB,QAAQwB;AAEpE,GC5aawP,KAAM,CAAIC,OAAkB,EAAE,OAAOA,EAAU,IAC/CC,KAAW,MAAM,QAAQ,QAAQ,GCOjCC,KAAW,MAAa;AACnC,QAAMnR,IAAUC;AAEhB,SAAKD,IAIEgO,GAAgBhO,CAAO,IAHrB,MAAM;AAIjB;"}
1
+ {"version":3,"file":"lithent.mjs","sources":["../src/utils/universalRef.ts","../src/utils/index.ts","../src/utils/predicator.ts","../src/hook/internal/unmount.ts","../src/hook/mountCallback.ts","../src/hook/mountReadyCallback.ts","../src/hook/internal/useUpdate.ts","../src/render.ts","../src/diff.ts","../src/utils/redraw.ts","../src/hook/updateCallback.ts","../src/wDom.ts","../src/hook/ref.ts","../src/hook/useRenew.ts"],"sourcesContent":["import { ComponentMap, ComponentSubKey, CompKey, ComponentInfo } from '@/types';\n\nexport const wdomSymbol = Symbol.for('lithentWDomSymbol');\nexport const xmlnsRef: { value: string } = { value: '' };\nexport const compKeyRef: { value: CompKey | null } = { value: null };\nexport const needDiffRef: { value: boolean } = { value: false };\nexport const componentMap: ComponentMap = new WeakMap();\nexport const lmountComponentSet: WeakSet<Function> = new WeakSet();\nlet componentMapManualMode = false;\n\nconst setComponetRef = (compKey: CompKey): void => {\n componentMap.set(compKey, {\n vd: { value: null },\n up: () => {},\n upR: [],\n upS: { value: 0 },\n upD: [],\n upCB: [],\n mts: [],\n umts: [],\n wdCB: [], // WDom creation callback queue\n });\n};\n\nexport const getComponentKey = (): CompKey | null => compKeyRef.value;\n\nexport const getComponentSubInfo = <K extends ComponentSubKey>(\n compKey: CompKey,\n subKey: K\n): ComponentInfo[K] | null => {\n const component = componentMap.get(compKey);\n if (component) {\n return component[subKey];\n }\n return null;\n};\n\nexport const initUpdateHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n};\n\nexport const initMountHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n setComponetRef(compKey);\n};\n\nexport const setComponentMapManualMode = (enabled: boolean): void => {\n componentMapManualMode = enabled;\n};\n\nexport const isComponentMapManualMode = (): boolean => componentMapManualMode;\n\nexport const runUnmountEffects = (compKey: CompKey): void => {\n const subInfo = componentMap.get(compKey);\n if (subInfo) {\n subInfo.umts.forEach(effect => effect());\n subInfo.umts = [];\n }\n};\n\nexport const disposeComponentEntry = (compKey: CompKey): void => {\n runUnmountEffects(compKey);\n componentMap.delete(compKey);\n};\n","import { WDom, Props } from '@/types';\n\nimport { wdomSymbol } from '@/utils/universalRef';\n\nexport const getParent = (vDom: WDom) =>\n (vDom.getParent && vDom.getParent()) as WDom;\n\nexport const entries = Object.entries;\nexport const keys = Object.keys;\n\nexport const isObject = (target: unknown): target is Record<string, unknown> =>\n typeof target === 'object' && target !== null;\n\nexport const assign = Object.assign;\nexport const isPropType = (obj: unknown): obj is Props => {\n return (\n isObject(obj) &&\n !Array.isArray(obj) &&\n !Object.getOwnPropertySymbols(obj).includes(wdomSymbol)\n );\n};\n","import { Fragment } from '@/wDom';\nimport {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n WDomType,\n} from '@/types';\nimport { isObject } from '@/utils';\n\ntype WDomParam =\n | string\n | WDom\n | TagFunction\n | TagFunctionResolver\n | FragmentFunction;\n\n/**\n * Predicator\n */\n\nconst checkPlainWDomType = (wDom: WDomParam): wDom is WDom =>\n isObject(wDom) && !('resolve' in wDom);\n\nconst checkPlainType = (wDom: WDomParam, typeName: string) =>\n checkPlainWDomType(wDom) && wDom.type === typeName;\n\nconst checkSameCustomComponent = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n 'ctor' in newWDom\n ? newWDom.ctor === (originalWDom && originalWDom.ctor)\n : newWDom === (originalWDom && originalWDom.ctor);\n\nconst checkSameFragment = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === 'f' &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkSameTagElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === 'e' &&\n originalWDom.tag === newWDom.tag &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkNormalTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type\n );\n\nconst checkLoopTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type &&\n ((checkExistyKey((newWDom.children || [])[0]) &&\n checkExistyKey((originalWDom.children || [])[0])) ||\n (originalWDom.children &&\n newWDom.children &&\n originalWDom.children.length === newWDom.children.length))\n );\n\nexport const getKey = (target: WDom) =>\n (target && target.compProps && target.compProps.key) ??\n (target && target.props && target.props.key);\n\n/**\n * Check if the type is virtual (fragment or loop)\n * Virtual types don't create real DOM elements themselves\n */\nexport const checkVirtualType = (\n type?: string | null // 'f': fragment, 'l': loop\n) => type === 'f' || type === 'l';\n\nexport const checkCustemComponentFunction = (\n target: WDomParam\n): target is TagFunction | TagFunctionResolver =>\n (typeof target === 'function' && !checkFragmentFunction(target)) ||\n (isObject(target) && 'resolve' in target);\n\nexport const checkFragmentFunction = (\n target: unknown\n): target is FragmentFunction =>\n typeof target === 'function' && target === Fragment;\n\nexport const checkEmptyElement = (wDom: WDomParam) =>\n checkPlainWDomType(wDom) && !wDom.type;\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\n\nexport const checkExisty = (value: unknown) =>\n value !== null && value !== undefined;\n\nexport const checkStyleData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is Record<string, string> =>\n dataKey === 'style' && isObject(dataValue);\n\nexport const checkRefData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is {\n value: HTMLElement | Element | DocumentFragment | Text | undefined;\n} => dataKey === 'ref' && isObject(dataValue);\n\n// Descriptor lookups are cached per nodeName+key (HTML nodeName is uppercase,\n// SVG lowercase, so the two prototypes never collide on the same cache key).\nconst accessorCache = new Map<string, boolean>();\n\nexport const hasAccessorMethods = (target: unknown, dataKey: string) => {\n const cacheKey = (target as HTMLElement).nodeName + '|' + dataKey;\n let result = accessorCache.get(cacheKey);\n\n if (result === undefined) {\n const descriptor = Object.getOwnPropertyDescriptor(\n target!.constructor.prototype,\n dataKey\n );\n result = !!(descriptor && descriptor.get && descriptor.set);\n accessorCache.set(cacheKey, result);\n }\n\n return result;\n};\n\n/**\n * Get WDom type as a single character code\n * 'c': component, 'f': fragment, 'e': element, 'l': loop, 't': text, 'et': empty/null\n */\nexport const getWDomType = (\n wDom: WDom | TagFunction | TagFunctionResolver\n): WDomType =>\n checkCustemComponentFunction(wDom)\n ? 'c'\n : checkPlainType(wDom, 'f')\n ? 'f'\n : checkPlainType(wDom, 'e')\n ? 'e'\n : checkPlainType(wDom, 'l')\n ? 'l'\n : checkPlainType(wDom, 't')\n ? 't'\n : 'et';\n\nexport const checkSameWDomWithOriginal = {\n c: checkSameCustomComponent,\n l: checkLoopTypeElement,\n t: checkNormalTypeElement,\n e: checkSameTagElement,\n f: checkSameFragment,\n et: checkNormalTypeElement,\n};\n","import { WDom, CompKey } from '@/types';\nimport {\n componentMap,\n getComponentKey,\n isComponentMapManualMode,\n runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.umts.push(effectAction);\n }\n};\n\nexport const runUnmountQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n // A redraw queued before this removal still holds the node. Marking it\n // retired makes that stale redraw a no-op instead of drawing it back in.\n newWDom.il = true;\n removeItem(compKey);\n }\n recursiveRunUnmount(newWDom);\n};\n\nconst recursiveRunUnmount = (wDom: WDom) => {\n (wDom.children || []).forEach(item => {\n const childComKey = item.compKey;\n if (childComKey) {\n runUnmountQueueFromWDom(item);\n } else {\n recursiveRunUnmount(item);\n }\n });\n};\n\nconst removeItem = (compKey: CompKey) => {\n runUnmountEffects(compKey);\n\n if (!isComponentMapManualMode()) {\n componentMap.delete(compKey);\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\nlet mountedQueue: WDom[] = [];\n\n/**\n * WDom을 mountedQueue에 추가\n */\nexport const addMountedQueue = (wDom: WDom) => {\n if (wDom.compKey) {\n mountedQueue.push(wDom);\n }\n};\n\n/**\n * DOM 렌더링 후 mountCallback 실행\n */\nexport const execMountedQueue = () => {\n mountedQueue.forEach(item => runMountedQueueFromWDom(item));\n mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.mts.push(effectAction);\n }\n }\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { mts: mountQueue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (mountQueue) {\n component.mts = [];\n\n mountQueue.forEach((effect: Function) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.wdCB.push(effectAction);\n }\n};\n\n/**\n * 특정 WDom의 wdomCallback 즉시 실행\n * wDomToDom() 내부에서 각 WDom 생성 시점에 호출됨\n */\nexport const runWDomCallbacksFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n const wdCBQueue = component && component.wdCB;\n\n compKeyRef.value = compKey;\n\n if (wdCBQueue && wdCBQueue.length > 0) {\n component.wdCB = [];\n\n wdCBQueue.forEach((effect: Function) => {\n const cleanup = effect();\n if (cleanup && typeof cleanup === 'function') {\n unmount(cleanup);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\n if (!component) return;\n\n const { upD, upS } = component;\n const def = upD[upS.value];\n\n const nextDependencies = dependencies();\n\n if (def && checkNeedPushQueue(def, nextDependencies)) {\n const callback = effectAction();\n if (callback) {\n component.upCB.push(callback);\n }\n }\n\n upD[upS.value] = nextDependencies;\n upS.value += 1;\n};\n\nexport const runUpdatedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { upCB: queue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (newWDom.ctor && queue) {\n component.upCB = [];\n queue.forEach((effect: Function) => effect());\n }\n }\n};\n\nconst checkNeedPushQueue = (originalDefs: unknown[], newDefs: unknown[]) =>\n !originalDefs.length\n ? true\n : originalDefs.some((def, index) => def !== newDefs[index]);\n","import { WDom, Props } from '@/types';\nimport {\n checkStyleData,\n checkRefData,\n checkExisty,\n checkVirtualType,\n hasAccessorMethods,\n} from '@/utils/predicator';\n\nimport { componentMap, xmlnsRef } from '@/utils/universalRef';\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { execMountedQueue, addMountedQueue } from '@/hook/mountCallback';\nimport { runWDomCallbacksFromWDom } from '@/hook/mountReadyCallback';\nimport { runUpdatedQueueFromWDom } from '@/hook/internal/useUpdate';\nimport { getParent, isObject } from '@/utils';\n\nconst DF = () => new DocumentFragment();\nconst CE = (t: string) => document.createElement(t);\n\nexport const render = (\n wDom: WDom,\n wrapElement: HTMLElement | null,\n afterElement?: HTMLElement | null,\n isHydration?: boolean\n) => {\n wDom.isRoot = true;\n wrapElement = wrapElement || document.body;\n wDom.we = wrapElement;\n\n const Dom = wDomToDom(wDom, isHydration);\n\n if (afterElement) {\n wDom.ae = afterElement;\n wrapElement.insertBefore(Dom, afterElement);\n } else if (!isHydration) {\n if (wrapElement.tagName === 'HTML') {\n wrapElement.replaceWith(Dom);\n } else {\n wrapElement.appendChild(Dom);\n }\n }\n\n execMountedQueue();\n\n return () => {\n const compData = componentMap.get(wDom.compProps || {});\n const comp = (compData && compData.vd.value) || wDom;\n if (comp !== wDom) runUnmountQueueFromWDom(comp);\n recursiveRemoveEvent(comp);\n rootDelete(comp);\n };\n};\n\nexport const recursiveRemoveEvent = (originalWDom: WDom) => {\n if (originalWDom.props && originalWDom.el) {\n removeEvent(originalWDom.props, originalWDom.el);\n }\n\n (originalWDom.children || []).forEach((childItem: WDom) => {\n recursiveRemoveEvent(childItem);\n });\n};\n\nconst rootDelete = (newWDom: WDom) =>\n deleteRealDom(newWDom, newWDom.we as HTMLElement);\n\nexport const typeDelete = (newWDom: WDom) => {\n if (newWDom.op && newWDom.el) {\n removeEvent(newWDom.op, newWDom.el);\n }\n\n const parentWDom = getParent(newWDom);\n const parentElement = newWDom.isRoot\n ? newWDom.we\n : parentWDom\n ? findRealParentElement(parentWDom)\n : undefined;\n\n if (parentElement) {\n deleteRealDom(newWDom, parentElement as HTMLElement);\n }\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n if (parent && newWDom.el) {\n const nt = newWDom.el.nodeType;\n if (nt === 11 || newWDom?.tag === 'portal') {\n findChildWithRemoveElement(newWDom, parent);\n } else if (nt === 1 || nt === 3) {\n parent.removeChild(newWDom.el);\n }\n\n delete newWDom.el;\n }\n};\n\nconst findChildWithRemoveElement = (newWDom: WDom, parent: HTMLElement) => {\n const items = (newWDom && newWDom.oc) || (newWDom && newWDom.children) || [];\n\n // Bulk fast path: the parent element contains exactly these children,\n // so they can all be dropped in a single operation.\n // (counted via sibling pointers -- childNodes would materialize a live list)\n let count = 0;\n for (let node = parent.firstChild; node; node = node.nextSibling) {\n count++;\n }\n\n if (\n items.length > 1 &&\n count === items.length &&\n items.every(item => {\n const nt = item.el && item.el.nodeType;\n return (\n (nt === 1 || nt === 3) &&\n (item.el as HTMLElement).tagName !== 'HTML' &&\n item.tag !== 'portal'\n );\n })\n ) {\n parent.textContent = '';\n items.forEach(item => delete item.el);\n return;\n }\n\n items.forEach(item => {\n const nt = item.el && item.el.nodeType;\n if (nt) {\n if (nt === 1 || nt === 3) {\n const el = item.el as HTMLElement;\n el.tagName === 'HTML' ? (el.innerHTML = '') : el.remove();\n } else if (nt === 11) {\n findChildWithRemoveElement(item, parent);\n }\n }\n });\n};\n\n/**\n * Unmount, detach events, and remove unused keyed children.\n */\nexport const typeDeleteUnused = (items: WDom[]) => {\n items.forEach(item => {\n runUnmountQueueFromWDom(item);\n recursiveRemoveEvent(item);\n typeDelete(item);\n });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\n\nconst typeSortedUpdate = (newWDom: WDom) => {\n typeUpdate(newWDom);\n\n if (getParent(newWDom) || newWDom.isRoot) {\n typeAdd(newWDom, getElementFromFragment(newWDom));\n }\n};\n\nconst typeAdd = (\n newWDom: WDom,\n newElement?: HTMLElement | DocumentFragment | Text\n) => {\n if (!newElement) {\n newElement = wDomToDom(newWDom) as HTMLElement;\n }\n\n const parentWDom = getParent(newWDom);\n if (!parentWDom || !parentWDom.type) {\n if (\n newWDom.isRoot &&\n newWDom.we &&\n newElement &&\n newWDom.tag !== 'portal'\n ) {\n if (newWDom.ae) {\n newWDom.we.insertBefore(newElement, newWDom.ae);\n } else if (newWDom.we.tagName === 'HTML') {\n newWDom.we.replaceWith(newElement);\n } else {\n newWDom.we.appendChild(newElement);\n }\n execMountedQueue();\n }\n return;\n }\n\n const parentEl = findRealParentElement(parentWDom);\n const nextEl =\n parentWDom.type === 'l' && parentWDom.nr\n ? startFindNextBrotherElement(parentWDom, getParent(parentWDom))\n : startFindNextBrotherElement(newWDom, parentWDom);\n\n if (newElement && parentEl) {\n if (newWDom.tag !== 'portal') {\n parentEl.insertBefore(newElement, nextEl || null);\n }\n execMountedQueue();\n }\n};\n\nconst getElementFromFragment = (newWDom: WDom) => {\n if (checkVirtualType(newWDom.type)) {\n return ((newWDom && newWDom.children) || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n\n if (element) {\n acc.appendChild(element);\n }\n return acc;\n }, DF());\n }\n\n return newWDom.el;\n};\n\nconst startFindNextBrotherElement = (\n wDom: WDom,\n parentWDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const brothers = parentWDom.children || [];\n const index = brothers.indexOf(wDom);\n const nextIndex = index + 1;\n const candidiateBrothers = brothers.slice(nextIndex);\n\n const finedNextEl = findChildFragmentNextElement(candidiateBrothers);\n const parentType = parentWDom.type || '';\n\n if (finedNextEl) {\n return finedNextEl;\n }\n\n if (!parentWDom.isRoot && checkVirtualType(parentType)) {\n return startFindNextBrotherElement(parentWDom, getParent(parentWDom));\n } else if (\n parentWDom.isRoot &&\n checkVirtualType(parentType) &&\n parentWDom.ae\n ) {\n return parentWDom.ae;\n }\n\n return undefined;\n};\n\nconst findChildFragmentNextElement = (\n candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n (targetEl, bItem) => {\n if (targetEl) return targetEl;\n const { type, el } = bItem;\n if (type && checkVirtualType(type)) {\n const found = findChildFragmentNextElement(bItem.children || []);\n if (found) return found;\n }\n if (el && el.nodeType !== 11) return el;\n return targetEl;\n },\n undefined\n );\n\nconst typeReplace = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n const orignalElement = newWDom.el;\n\n if (newWDom.isRoot && !parentWDom && orignalElement) {\n typeSortedReplace(newWDom);\n return;\n }\n\n if (parentWDom && parentWDom.type && orignalElement) {\n if (orignalElement.nodeType === 11) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement && newWDom.tag !== 'portal') {\n parentElement.replaceChild(newElement, orignalElement);\n }\n execMountedQueue();\n }\n }\n};\n\nconst removeEvent = (\n oldProps: Props,\n element: HTMLElement | DocumentFragment | Text\n) => {\n for (const dataKey in oldProps) {\n if (dataKey[0] === 'o' && dataKey[1] === 'n') {\n element.removeEventListener(\n dataKey.slice(2).toLowerCase(),\n oldProps[dataKey] as (e: Event) => void\n );\n }\n }\n};\n\nconst typeUpdate = (newWDom: WDom) => {\n if (newWDom.type === 't') {\n updateText(newWDom);\n return;\n }\n\n if (newWDom.el) {\n const { op: oldProps, props } = newWDom;\n updateProps(props, newWDom.el, oldProps);\n delete newWDom.op;\n\n if (newWDom.tag === 'input') {\n (newWDom.el as HTMLInputElement).value = String(\n (props && props.value) || ''\n );\n }\n }\n\n updateChildren(newWDom);\n runUpdatedQueueFromWDom(newWDom);\n};\n\n/**\n * Process child updates. Loop parents with added/moved children are handled\n * in O(n): a left-to-right content pass (keeps lifecycle order), an LIS over\n * the matched original indices (oi, recorded by the diff phase) to pick the\n * children that can stay in place, and a right-to-left placement pass that\n * inserts only added children and non-LIS moves before a running anchor.\n */\nconst updateChildren = (newWDom: WDom) => {\n const children = newWDom.children || [];\n let needPlace = false;\n\n if (newWDom.type === 'l') {\n for (const item of children) {\n if ('ATS'.includes(item.nr as string) || item.oi !== undefined) {\n needPlace = true;\n break;\n }\n }\n }\n\n if (!needPlace) {\n children.forEach(childItem => wDomUpdate(childItem));\n return;\n }\n\n // Content pass (left-to-right, keeps lifecycle order).\n // Added children are created here but inserted in the placement pass.\n const created: (HTMLElement | DocumentFragment | Text | undefined)[] = [];\n const matchedIndexes: number[] = [];\n const oiSeq: number[] = [];\n let createdCount = 0;\n\n children.forEach((item, index) => {\n const nr = item.nr;\n\n if (nr === 'A' || nr === 'S') {\n if (nr === 'S') {\n typeDelete(item);\n }\n created[index] = wDomToDom(item);\n createdCount++;\n } else if (nr === 'T') {\n typeUpdate(item);\n } else {\n wDomUpdate(item);\n }\n\n if (item.oi !== undefined && created[index] === undefined) {\n matchedIndexes.push(index);\n oiSeq.push(item.oi);\n }\n });\n\n const stay = new Set(getLisPositions(oiSeq).map(pos => matchedIndexes[pos]));\n const parentEl = findRealParentElement(newWDom);\n const baseAnchor = newWDom.isRoot\n ? newWDom.ae\n : startFindNextBrotherElement(newWDom, getParent(newWDom));\n\n // Fast-append the trailing run of added children in order\n // (a null anchor makes insertBefore behave as appendChild).\n let tail = children.length;\n while (tail > 0 && created[tail - 1] !== undefined) {\n tail--;\n }\n\n for (let i = tail; i < children.length; i++) {\n const el = created[i];\n\n if (el && parentEl && children[i].tag !== 'portal') {\n parentEl.insertBefore(el, baseAnchor || null);\n }\n }\n\n if (\n stay.size !== matchedIndexes.length ||\n createdCount > children.length - tail\n ) {\n // Placement pass (right-to-left): insert added children and non-LIS\n // moves before a running anchor.\n let anchor =\n findChildFragmentNextElement(children.slice(tail)) || baseAnchor;\n\n for (let i = tail - 1; i >= 0; i--) {\n const item = children[i];\n const isNew = created[i] !== undefined;\n const needMove = item.oi !== undefined && !isNew && !stay.has(i);\n\n if ((isNew || needMove) && parentEl && item.tag !== 'portal') {\n const el = isNew ? created[i] : getElementFromFragment(item);\n\n if (el) {\n parentEl.insertBefore(el, anchor || null);\n }\n }\n\n const first = findChildFragmentNextElement([item]);\n if (first) {\n anchor = first;\n }\n }\n }\n\n children.forEach(clearDiffMeta);\n execMountedQueue();\n};\n\nconst clearDiffMeta = (item: WDom) => {\n delete item.oi;\n delete item.nr;\n delete item.oc;\n delete item.op;\n};\n\n/**\n * Longest increasing subsequence positions (binary search, O(n log n)).\n * Returns the positions in seq that form the LIS.\n */\nconst getLisPositions = (seq: number[]) => {\n const result: number[] = [];\n\n if (!seq.length) {\n return result;\n }\n\n const prev = new Array(seq.length);\n result.push(0);\n\n for (let i = 1; i < seq.length; i++) {\n const value = seq[i];\n\n if (seq[result[result.length - 1]] < value) {\n prev[i] = result[result.length - 1];\n result.push(i);\n continue;\n }\n\n let lo = 0;\n let hi = result.length - 1;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (seq[result[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n\n if (value < seq[result[lo]]) {\n if (lo > 0) {\n prev[i] = result[lo - 1];\n }\n result[lo] = i;\n }\n }\n\n let i = result.length;\n let last = result[i - 1];\n while (i-- > 0) {\n result[i] = last;\n last = prev[last];\n }\n\n return result;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n const { nr: needRerender } = newWDomTree;\n\n if (needRerender !== undefined && needRerender !== 'N') {\n renderHandlers[needRerender](newWDomTree);\n clearDiffMeta(newWDomTree);\n }\n};\n\nconst renderHandlers = {\n A: typeAdd,\n D: typeDelete,\n R: typeReplace,\n U: typeUpdate,\n S: typeSortedReplace,\n T: typeSortedUpdate,\n} as const;\n\nconst updateText = (newWDom: WDom) => {\n if (newWDom.el) {\n newWDom.el.nodeValue = String(newWDom.text);\n }\n};\n\nconst updateProps = (\n props?: Props,\n element?: HTMLElement | Element | DocumentFragment | Text,\n oldProps?: Props | null,\n isHydration?: boolean\n) => {\n const originalProps = oldProps || {};\n\n for (const dataKey in props) {\n const dataValue: unknown = props[dataKey];\n\n if (dataValue === originalProps[dataKey]) {\n delete originalProps[dataKey];\n continue;\n }\n\n const isEvent = dataKey[0] === 'o' && dataKey[1] === 'n';\n\n if (isHydration && isEvent) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else {\n if (dataKey === 'key') {\n // Do nothing\n } else if (dataKey === 'portal' && isObject(dataValue)) {\n // Do nothing\n } else if (dataKey === 'innerHTML' && typeof dataValue === 'string') {\n (element as HTMLElement).innerHTML = dataValue;\n } else if (checkStyleData(dataKey, dataValue)) {\n updateStyle(\n dataValue,\n checkStyleData(dataKey, originalProps.style)\n ? originalProps.style\n : {},\n element\n );\n } else if (checkRefData(dataKey, dataValue)) {\n dataValue.value = element;\n } else if (isEvent) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else if (dataKey) {\n if (dataKey !== 'type' && hasAccessorMethods(element, dataKey)) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n } else {\n setAttr(\n dataKey === 'className' ? 'class' : dataKey,\n element as HTMLElement,\n dataValue as string\n );\n }\n }\n\n delete originalProps[dataKey];\n }\n }\n\n for (const dataKey in originalProps) {\n (element as HTMLElement).removeAttribute(dataKey);\n }\n};\n\nconst setAttr = (k: string, el: HTMLElement, v: string) =>\n xmlnsRef.value && k !== 'xmlns'\n ? el.setAttributeNS(null, k, v)\n : el.setAttribute(k, v);\n\nconst wDomToDom = (wDom: WDom, isHydration?: boolean): HTMLElement => {\n let element;\n const { type, tag, text, props, children = [] } = wDom;\n const isVirtualType = checkVirtualType(type);\n\n runWDomCallbacksFromWDom(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = String(props && props.xmlns);\n }\n\n if (!isHydration) {\n if (!type) {\n element = DF();\n } else if (isVirtualType) {\n element = DF();\n } else if (type === 'e' && tag) {\n // element\n if (tag === 'portal' && props && props.portal) {\n element = props.portal as HTMLElement;\n } else {\n element = xmlnsRef.value\n ? document.createElementNS(xmlnsRef.value, tag)\n : CE(tag);\n }\n } else if (type === 't' && checkExisty(text)) {\n // text node\n element = document.createTextNode(String(text));\n } else {\n throw Error('Invalid wDom');\n }\n\n wDom.el = element as HTMLElement;\n } else {\n element = wDom.el;\n }\n\n wDomChildrenToDom(children, element, isHydration);\n\n updateProps(props, element, null, isHydration);\n\n addMountedQueue(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = '';\n }\n\n return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\n children: WDom[],\n parentElement?: HTMLElement | Element | DocumentFragment | Text,\n isHydration?: boolean\n) => {\n // The parent is not attached to the document yet, so children can be\n // appended directly (no intermediate fragment allocation).\n children.forEach((childItem: WDom) => {\n if (childItem.type) {\n const childElement = wDomToDom(childItem, isHydration);\n if (childItem.tag !== 'portal' && !isHydration && parentElement) {\n parentElement.appendChild(childElement);\n }\n }\n });\n};\n\nconst updateEvent = (\n element: HTMLElement,\n eventKey: string,\n newEventHandler: (e: Event) => void,\n oldEventHandler: (e: Event) => void\n) => {\n const eventName = eventKey.slice(2).toLowerCase();\n\n if (oldEventHandler !== newEventHandler) {\n if (oldEventHandler) {\n element.removeEventListener(eventName, oldEventHandler);\n }\n\n if (newEventHandler) {\n element.addEventListener(eventName, newEventHandler);\n }\n }\n};\n\nconst updateStyle = (\n style: Record<string, string>,\n oldStyle: Record<string, string>,\n element?: HTMLElement | Element | DocumentFragment | Text\n) => {\n const orig = { ...oldStyle };\n const htmlElement = element instanceof HTMLElement ? element : null;\n const cssStyle = htmlElement?.style;\n\n if (!cssStyle) return;\n\n const styleProxy = cssStyle as unknown as Record<string, string>;\n\n for (const k in style) {\n styleProxy[k] = style[k];\n delete orig[k];\n }\n\n for (const k in orig) {\n styleProxy[k] = '';\n }\n};\n\nconst findRealParentElement = (\n vDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const isVirtualType = checkVirtualType(vDom.type);\n if (vDom.isRoot && isVirtualType) {\n return vDom.we;\n }\n\n if (!isVirtualType) {\n return vDom.el as HTMLElement;\n }\n\n return findRealParentElement(getParent(vDom));\n};\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent } from '@/utils';\nimport { typeDeleteUnused, recursiveRemoveEvent } from '@/render';\nimport {\n checkEmptyElement,\n checkSameWDomWithOriginal,\n getWDomType,\n checkExistyKey,\n} from '@/utils/predicator';\n\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { keys, entries } from '@/utils';\n\n/**\n * The starting point of the diffing process between the original virtual DOM and the new virtual DOM for re-rendering.\n */\nexport const makeNewWDomTree = (\n newWDom: WDom | TagFunctionResolver,\n originalWDom?: WDom\n) =>\n remakeNewWDom(\n newWDom,\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\n );\n\n/**\n * Create a new virtual DOM after comparing with the previous virtual DOM\n */\nconst remakeNewWDom = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n) => {\n const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n const needRerender = addReRenderTypeProperty(\n remakeWDom,\n isSameType,\n originalWDom\n );\n const isNoting = needRerender === 'N';\n\n if (!isNoting) {\n remakeWDom.children = remakeChildrenForDiff(\n remakeWDom,\n isSameType,\n originalWDom\n );\n }\n\n // NOTE: short-key metadata (nr = needRerender) keeps bundle size down\n remakeWDom.nr = needRerender;\n inheritPropForRender(remakeWDom, originalWDom, needRerender);\n\n if (!isNoting && originalWDom) {\n originalWDom.il = true;\n delete originalWDom.children;\n }\n if (originalWDom?.tag === 'portal') {\n remakeWDom.tag = 'portal';\n }\n\n return remakeWDom;\n};\n\n/**\n * Handle what the new virtual DOM should inherit or reconcile from the original virtual DOM.\n */\nconst inheritPropForRender = (\n remakeWDom: WDom,\n originalWDom?: WDom,\n needRerender?: RenderType\n) => {\n if (needRerender !== 'A' && originalWDom) {\n remakeWDom.el = originalWDom.el;\n }\n\n if (needRerender === 'D' || needRerender === 'R' || needRerender === 'S') {\n if (originalWDom) {\n runUnmountQueueFromWDom(originalWDom);\n recursiveRemoveEvent(originalWDom);\n }\n remakeWDom.oc = originalWDom && originalWDom.children;\n }\n\n remakeWDom.op = originalWDom && originalWDom.props;\n};\n\n/**\n * Determine the render operation type (Add/Delete/Replace/Update/etc)\n * based on comparison between new and original WDom\n */\nconst addReRenderTypeProperty = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n): RenderType | undefined => {\n if (checkEmptyElement(newWDom)) return 'D';\n\n const isSameText =\n newWDom.type === 't' &&\n isSameType &&\n newWDom.text === (originalWDom && originalWDom.text);\n if (isSameText || newWDom === originalWDom) return 'N';\n\n const existOriginalWDom = originalWDom && originalWDom.type;\n if (!existOriginalWDom) return 'A';\n\n const parent = getParent(originalWDom);\n const isKeyChecked =\n !newWDom.isRoot && parent && parent.type === 'l' && checkExistyKey(newWDom);\n\n return isSameType ? (isKeyChecked ? 'T' : 'U') : isKeyChecked ? 'S' : 'R';\n};\n\n/**\n * Handling virtual DOM attribute updates.\n */\nconst syncResolverProps = (props: Props, infoProps: Props) => {\n if (props && infoProps !== props) {\n keys(props).forEach(key => delete props[key]);\n entries(infoProps || {}).forEach(([key, value]) => (props[key] = value));\n }\n};\n\nconst syncResolverChildren = (children: WDom[], infoChidren: WDom[]) => {\n if (children) {\n children.splice(0, children.length);\n\n if (infoChidren) {\n infoChidren.forEach(childrenItem => children.push(childrenItem));\n }\n }\n};\n\n/**\n * Keep the existing component node while injecting the props/children from the freshly computed TagFunctionResolver.\n * originalWDom is the fully evaluated node from the previous render, whereas infoVdom is the intermediate resolver,\n * so updating compProps/compChild in place lets reRender() evaluate with the latest slots and props.\n * It is crucial that props and children references remain stable as nodes update—many ancestors/closures share these arrays,\n * so mutate the existing arrays instead of replacing their references.\n */\nconst runUpdate = (vDom: WDom, infoVdom: TagFunctionResolver) => {\n const { compProps: props, compChild: children } = vDom;\n const { props: infoProps, children: infoChidren } = infoVdom;\n\n if (props) {\n syncResolverProps(props, infoProps);\n }\n\n /**\n * In runUpdate, the original DOM (vDom) is already fully evaluated and completed, whereas infoVdom represents an intermediate state. Therefore, vdom.compChild and infoVdom.children are indeed the correct counterparts to compare.\n\n * Keep shared child array references intact (<= same slot array instance)\n * When the reference changes, sync the stored compChild contents so reRender sees fresh nodes\n * Only update children if they're different references\n * If it's the same Fragment reference, the diff process will handle updating its children\n */\n if (children && infoChidren && children !== infoChidren) {\n syncResolverChildren(children, infoChidren);\n }\n\n const newVDom = vDom.reRender && vDom.reRender();\n\n return newVDom as WDom;\n};\n\n/**\n * Replace the compared virtual DOM with the new virtual DOM or simply update it.\n */\nconst generalize = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n): WDom => {\n return checkCustemComponentFunction(newWDom)\n ? isSameType && originalWDom\n ? runUpdate(originalWDom, newWDom)\n : newWDom.resolve()\n : newWDom;\n};\n\n/**\n * 자식 가상돔들도 전부 재귀처리하며 똑같은 처리를 해준다.\n */\nconst remakeChildrenForDiff = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n) =>\n isSameType && originalWDom\n ? remakeChildrenForUpdate(newWDom, originalWDom)\n : remakeChildrenForAdd(newWDom);\n\n/**\n * Recursive handling for the creation of a new virtual DOM.\n */\nconst remakeChildrenForAdd = (newWDom: WDom) => {\n const getParent = () => newWDom;\n\n return (newWDom.children || []).map((item: WDom) => {\n const child = makeNewWDomTree(item);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling for updates, not additions.\n * Uses key-based diffing for loops, index-based for others\n */\nconst remakeChildrenForUpdate = (newWDom: WDom, originalWDom: WDom) => {\n if (newWDom.type === 'l' && checkExistyKey((newWDom.children || [])[0])) {\n return remakeChildrenForLoopUpdate(newWDom, originalWDom);\n }\n\n const origChildren = originalWDom.children || [];\n const getParent = () => newWDom;\n\n return (newWDom.children || []).map((item: WDom, index: number) => {\n const child = makeNewWDomTree(item, origChildren[index]);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Handling virtual DOM of loop-type elements.\n */\nconst remakeChildrenForLoopUpdate = (newWDom: WDom, originalWDom: WDom) => {\n const [remakedChildren, unUsedChildren] = diffLoopChildren(\n newWDom,\n originalWDom\n );\n\n typeDeleteUnused(unUsedChildren);\n\n return remakedChildren;\n};\n\n/**\n * Recursive handling of loop-type virtual DOM elements.\n * Matches children against the originals by key via a Map in O(n) and\n * records each match's original index (oi) for the render phase to\n * minimize moves via LIS.\n */\nconst diffLoopChildren = (newWDom: WDom, originalWDom: WDom) => {\n const origChildren = originalWDom.children || [];\n const keyMap = new Map<unknown, number>();\n origChildren.forEach((item, index) => {\n const key = getKey(item);\n if (!keyMap.has(key)) {\n keyMap.set(key, index);\n }\n });\n\n const getParent = () => newWDom;\n const remaked = (newWDom.children || []).map(item => {\n const key = getKey(item);\n const origIndex = keyMap.get(key);\n const matched = origIndex !== undefined;\n\n if (matched) {\n keyMap.delete(key);\n }\n\n const child = makeNewWDomTree(\n item,\n matched ? origChildren[origIndex] : undefined\n );\n if (matched) {\n child.oi = origIndex;\n }\n child.getParent = getParent;\n\n return child;\n });\n\n return [remaked, [...keyMap.values()].map(index => origChildren[index])];\n};\n","import { Props } from '@/types';\nimport { componentMap } from '@/utils/universalRef';\n\nconst redrawQueue = new Map<Props, () => void>();\nlet redrawQueueTimeout: boolean = false;\n\nexport const setRedrawAction = (compKey: Props, exec: () => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => {\n redrawQueue.set(compKey, exec);\n\n if (!redrawQueueTimeout) {\n redrawQueueTimeout = true;\n queueMicrotask(execRedrawQueue);\n }\n };\n }\n};\n\nexport const componentUpdate = (compKey: Props) => () => {\n const comp = componentMap.get(compKey);\n const up = comp && comp.up;\n if (up) {\n up();\n return true;\n }\n return false;\n};\n\nconst execRedrawQueue = () => {\n redrawQueue.forEach((item: () => void) => {\n item();\n });\n\n redrawQueue.clear();\n redrawQueueTimeout = false;\n};\n","import { componentMap, getComponentKey } from '@/utils/universalRef';\n\nimport { useUpdated } from '@/hook/internal/useUpdate';\n\ntype DependencyFactory = () => unknown[];\n\nexport const updateCallback = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\n if (!component) return;\n\n component.upR.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const comp = componentMap.get(compKey);\n const updateReqs = comp && comp.upR;\n\n if (updateReqs && updateReqs.length) {\n updateReqs.forEach(callback => callback());\n }\n};\n","import {\n WDom,\n TagFunction,\n FragmentFunction,\n Props,\n MiddleStateWDomChildren,\n MiddleStateWDom,\n NodePointer,\n Component,\n LComponent,\n} from '@/types';\n\nimport { makeNewWDomTree } from '@/diff';\nimport { wDomUpdate } from '@/render';\nimport {\n initUpdateHookState,\n initMountHookState,\n needDiffRef,\n getComponentSubInfo,\n wdomSymbol,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { setRedrawAction, componentUpdate } from '@/utils/redraw';\nimport { runUpdateCallback } from '@/hook/updateCallback';\nimport {\n checkFragmentFunction,\n checkCustemComponentFunction,\n} from '@/utils/predicator';\nimport { assign } from '@/utils';\n\n// ============================================================================\n// Public API - Highest Level (User-facing API)\n// ============================================================================\n\n/**\n * It allows grouping multiple elements together.\n */\nexport const Fragment = (_props: Props, ...children: WDom[]) =>\n ({\n type: 'f', // fragment\n [wdomSymbol]: true,\n children,\n }) as WDom;\n\n/**\n * Element creation\n */\nexport const h = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n ...children: MiddleStateWDomChildren\n) => {\n const nodeParentPointer: NodePointer = { value: undefined };\n const newChildren = remakeChildren(nodeParentPointer, children);\n const node = makeNode(tag, props || {}, newChildren);\n\n if (!checkCustemComponentFunction(node)) {\n nodeParentPointer.value = node;\n }\n\n return node;\n};\n\n/**\n * Enables portals\n */\nexport const portal = (wDom: WDom, portal: HTMLElement) =>\n h('portal', { portal }, wDom);\n\n/**\n * It helps with component creation.\n */\nexport const mount =\n <T>(component: Component<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) =>\n component;\n\n/**\n * It helps with component creation without renew parameter.\n * Use useRenew() hook to get renew function if needed.\n */\nexport const lmount =\n <T>(component: LComponent<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) => {\n lmountComponentSet.add(component);\n return component;\n };\n\n/**\n * Maintain compChild references for upward updates (render props, slots, etc.).\n * JSX always returns a fresh children array, so when a subtree re-renders\n * bottom-up we must manually swap the old child instance out of each ancestor's\n * compChild.\n *\n * Fragment-wrapping solved this by keeping a stable wrapper node,\n * but that hides the actual child tree. We prefer this explicit sync for DX.\n *\n * In practice slot consumers rarely thread children more than a layer or two—\n * usually shallow composed pieces like dropdowns or drag-and-drop shells—so the\n * directed walk keeps DX high without introducing observable overhead.\n */\nconst syncAncestorComponentChildren = (\n parent: WDom | undefined,\n prevChild: WDom,\n nextChild: WDom\n) => {\n const walk = (node: WDom | undefined, visited: Set<WDom>): void => {\n if (!node || visited.has(node)) {\n return;\n }\n\n visited.add(node);\n\n if (node.compChild) {\n const childIndex = node.compChild.indexOf(prevChild);\n\n if (childIndex !== -1) {\n node.compChild.splice(childIndex, 1, nextChild);\n }\n }\n\n walk(node.getParent ? node.getParent() : undefined, visited);\n };\n\n walk(parent, new Set<WDom>());\n};\n\n/**\n * It re-renders starting from a specific component.\n */\nexport const replaceWDom = (\n tag: TagFunction,\n props: Props,\n children: WDom[],\n originalWDom: WDom\n) => {\n if (originalWDom.il) {\n return;\n }\n needDiffRef.value = true;\n\n const newWDom = makeWDomResolver(tag, props, children);\n const newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n // NOTE: we/ae are short for wrapElement/afterElement\n const { isRoot, getParent, we, ae } = originalWDom;\n\n newWDomTree.getParent = getParent;\n\n if (!isRoot && getParent) {\n const parent = getParent();\n const brothers = (parent && parent.children) || [];\n const index = brothers.indexOf(originalWDom);\n\n if (index !== -1) {\n brothers.splice(index, 1, newWDomTree);\n }\n\n syncAncestorComponentChildren(parent, originalWDom, newWDomTree);\n } else {\n newWDomTree.isRoot = true;\n newWDomTree.we = we;\n newWDomTree.ae = ae;\n }\n\n needDiffRef.value = false;\n\n wDomUpdate(newWDomTree);\n};\n\n// ============================================================================\n// Mid-Level - Virtual DOM Node Creation (Intermediate abstraction level)\n// ============================================================================\n\n/**\n * The starting point where the virtual DOM is created from the h function.\n */\nconst makeNode = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n children: WDom[]\n) => {\n if (checkFragmentFunction(tag)) {\n return Fragment(props, ...children);\n } else if (checkCustemComponentFunction(tag)) {\n const componetMakeResolver = makeWDomResolver(tag, props, children);\n\n return needDiffRef.value\n ? componetMakeResolver\n : componetMakeResolver.resolve();\n }\n\n return {\n type: 'e', // element\n [wdomSymbol]: true,\n tag,\n props,\n children,\n } as WDom;\n};\n\n/**\n * The starting point for recursively processing the child virtual DOM elements.\n */\nconst remakeChildren = (\n nodeParentPointer: NodePointer,\n children: MiddleStateWDomChildren\n): WDom[] => {\n // Siblings share a single getParent closure (one allocation per parent)\n const getParent = () => nodeParentPointer.value;\n\n return children.map((item: MiddleStateWDom) => {\n const childItem = makeChildrenItem(item);\n childItem.getParent = getParent;\n return childItem;\n });\n};\n\n/**\n * Recursively process the child virtual DOM elements.\n */\nconst makeChildrenItem = (item: MiddleStateWDom): WDom => {\n if (item === null || item === undefined || item === false) {\n return { type: null, [wdomSymbol]: true } as WDom;\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = {\n type: 'l', // loop (array mapping)\n [wdomSymbol]: true,\n children,\n } as WDom;\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return { type: 't', [wdomSymbol]: true, text: item } as WDom; // text node\n }\n\n return item;\n};\n\n// ============================================================================\n// Component Lifecycle - Component Creation & Re-rendering\n// ============================================================================\n\n/**\n * Create component resolver function\n */\nconst createComponentResolver = (\n tag: TagFunction,\n props: Props,\n wrappedChildren: WDom[]\n) => {\n return (compKey = props) => {\n // Diff mode sets needDiffRef to true so h()/makeNode return a resolver\n // placeholder. During actual resolution we must force a real WDom tree,\n // otherwise nested components leave only resolvers (no getParent/children)\n // and CSR renders a blank area. Temporarily drop needDiffRef, then restore.\n // Regression tests: src/tests/core-composedRenew.test.tsx,\n // src/tests/core-component-remount.test.tsx\n const prevNeedDiff = needDiffRef.value;\n needDiffRef.value = false;\n\n initMountHookState(compKey);\n\n const initialComponent = tag(props, wrappedChildren);\n\n let componentMaker: (nextProps: Props) => MiddleStateWDom;\n\n if (typeof initialComponent === 'function') {\n const component = initialComponent;\n // Check if component is created with lmount (no renew parameter)\n // TypeScript cannot infer that component is LComponent when has() returns true,\n // because WeakSet.has() is a runtime check that doesn't narrow types.\n // We use 'as any' since the runtime check guarantees type safety.\n componentMaker = lmountComponentSet.has(component)\n ? (component as any)(props, wrappedChildren)\n : component(componentUpdate(compKey), props, wrappedChildren);\n } else {\n // For components that directly return a VDom, recreate it each render.\n componentMaker = (nextProps: Props) =>\n tag(nextProps, wrappedChildren) as MiddleStateWDom;\n }\n\n const node = makeCustomNode(\n componentMaker,\n compKey,\n tag,\n props,\n wrappedChildren\n );\n needDiffRef.value = prevNeedDiff;\n return node;\n };\n};\n\n/**\n * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (tag: TagFunction, props: Props, children: WDom[]) => {\n const ctor = tag;\n\n const wrappedChildren = children;\n\n const resolve = createComponentResolver(tag, props, wrappedChildren);\n\n return { ctor, props, children: wrappedChildren, resolve };\n};\n\n/**\n * Create the actual virtual DOM node from the component.\n */\nconst makeCustomNode = (\n componentMaker: (props: Props) => MiddleStateWDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const normalizedComponentMaker = (nextProps: Props): WDom =>\n makeChildrenItem(componentMaker(nextProps));\n const { wrappedComponentMaker, customNode } = wrapComponentMakerIfNeeded(\n normalizedComponentMaker,\n props\n );\n const reRender = makeReRender(\n wrappedComponentMaker,\n compKey,\n tag,\n props,\n children\n );\n\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n return customNode;\n};\n\n/**\n * When the virtual DOM is actually created from the component, generate a re-render method for future redraws.\n */\nconst makeReRender = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const reRender = () =>\n wDomMaker(componentMaker, compKey, tag, props, children, reRender);\n return reRender;\n};\n\n/**\n * The starting point for redrawing from the re-render method\n */\nconst wDomMaker = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n initUpdateHookState(compKey);\n runUpdateCallback();\n\n const customNode = componentMaker(props);\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n\n return customNode;\n};\n\n// ============================================================================\n// Low-Level Utilities - Component Node Manipulation\n// ============================================================================\n\n/**\n * Wrap component output in a stable Fragment so component metadata lives on a\n * dedicated node. This prevents parent/child sharing when a component returns\n * another component and keeps updates stable even when output becomes empty.\n */\nconst wrapComponentMakerIfNeeded = (\n componentMaker: (props: Props) => WDom,\n props: Props\n): { wrappedComponentMaker: (props: Props) => WDom; customNode: WDom } => {\n const wrappedComponentMaker = (newProps: Props): WDom => {\n const next = componentMaker(newProps);\n const wrapper = Fragment({}, next);\n next.getParent = () => wrapper;\n return wrapper;\n };\n\n const customNode = wrappedComponentMaker(props);\n\n return { wrappedComponentMaker, customNode };\n};\n\n/**\n * When creating a custom component node, attach additional information attributes to the virtual DOM object.\n */\nconst addComponentProps = (\n wDom: WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n assign(wDom, {\n compProps: props,\n compChild: children,\n ctor: tag,\n compKey,\n reRender,\n });\n\n setRedrawAction(compKey, () =>\n replaceWDom(\n tag,\n (wDom.compProps as Props) || props,\n (wDom.compChild as WDom[]) || children,\n wDom\n )\n );\n\n if (getComponentSubInfo(compKey, 'vd')) {\n (getComponentSubInfo(compKey, 'vd') as { value: WDom }).value = wDom;\n }\n};\n","export const ref = <T>(initValue: T) => ({ value: initValue });\nexport const nextTick = () => Promise.resolve();\n","import { Renew } from '@/types';\nimport { getComponentKey } from '@/utils/universalRef';\nimport { componentUpdate } from '@/utils/redraw';\n\n/**\n * Hook to get the renew (component update) function.\n * Useful for lmount components that need to trigger updates.\n */\nexport const useRenew = (): Renew => {\n const compKey = getComponentKey();\n\n if (!compKey) {\n return () => false;\n }\n\n return componentUpdate(compKey);\n};\n"],"names":["wdomSymbol","xmlnsRef","compKeyRef","needDiffRef","componentMap","lmountComponentSet","componentMapManualMode","setComponetRef","compKey","getComponentKey","getComponentSubInfo","subKey","component","initUpdateHookState","initMountHookState","setComponentMapManualMode","enabled","isComponentMapManualMode","runUnmountEffects","subInfo","effect","disposeComponentEntry","getParent","vDom","entries","keys","isObject","target","assign","isPropType","obj","checkPlainWDomType","wDom","checkPlainType","typeName","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkExistyKey","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","checkExisty","value","checkStyleData","dataKey","dataValue","checkRefData","accessorCache","hasAccessorMethods","cacheKey","result","descriptor","getWDomType","checkSameWDomWithOriginal","unmount","effectAction","comp","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","mountedQueue","addMountedQueue","execMountedQueue","runMountedQueueFromWDom","mountCallback","mountQueue","sequence","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","CE","t","render","wrapElement","afterElement","isHydration","Dom","wDomToDom","compData","recursiveRemoveEvent","rootDelete","removeEvent","childItem","deleteRealDom","typeDelete","parentWDom","parentElement","findRealParentElement","parent","nt","findChildWithRemoveElement","items","count","node","el","typeDeleteUnused","typeSortedReplace","typeAdd","typeSortedUpdate","typeUpdate","getElementFromFragment","newElement","parentEl","nextEl","startFindNextBrotherElement","acc","element","brothers","nextIndex","candidiateBrothers","finedNextEl","findChildFragmentNextElement","parentType","targetEl","bItem","found","typeReplace","orignalElement","oldProps","updateText","props","updateProps","updateChildren","children","needPlace","wDomUpdate","created","matchedIndexes","oiSeq","createdCount","nr","stay","getLisPositions","pos","baseAnchor","tail","anchor","i","isNew","needMove","first","clearDiffMeta","seq","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","isEvent","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","htmlElement","cssStyle","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","key","syncResolverChildren","infoChidren","childrenItem","runUpdate","infoVdom","remakeChildrenForUpdate","remakeChildrenForAdd","child","remakeChildrenForLoopUpdate","origChildren","remakedChildren","unUsedChildren","diffLoopChildren","keyMap","origIndex","matched","redrawQueue","redrawQueueTimeout","setRedrawAction","exec","execRedrawQueue","componentUpdate","up","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newChildren","remakeChildren","makeNode","portal","mount","_children","lmount","syncAncestorComponentChildren","prevChild","nextChild","walk","visited","childIndex","replaceWDom","makeWDomResolver","isRoot","we","ae","componetMakeResolver","makeChildrenItem","createComponentResolver","wrappedChildren","prevNeedDiff","initialComponent","componentMaker","nextProps","makeCustomNode","ctor","resolve","normalizedComponentMaker","wrappedComponentMaker","customNode","wrapComponentMakerIfNeeded","reRender","makeReRender","addComponentProps","wDomMaker","newProps","next","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"AAEa,MAAAA,IAAa,OAAO,IAAI,mBAAmB,GAC3CC,IAA8B,EAAE,OAAO,MACvCC,IAAwC,EAAE,OAAO,QACjDC,IAAkC,EAAE,OAAO,MAC3CC,wBAAiC,QAAQ,GACzCC,yBAA4C,QAAQ;AACjE,IAAIC,KAAyB;AAE7B,MAAMC,KAAiB,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C9BpH;AAAA,IACF;AAAA,EAAA,GAGEtB,EAAoBF,GAAS,IAAI,MAClCE,EAAoBF,GAAS,IAAI,EAAsB,QAAQwB;AAEpE,GC5aawP,KAAM,CAAIC,OAAkB,EAAE,OAAOA,EAAU,IAC/CC,KAAW,MAAM,QAAQ,QAAQ,GCOjCC,KAAW,MAAa;AACnC,QAAMnR,IAAUC;AAEhB,SAAKD,IAIEgO,GAAgBhO,CAAO,IAHrB,MAAM;AAIjB;"}
@@ -1,2 +1,2 @@
1
- (function(i,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(i=typeof globalThis<"u"?globalThis:i||self,y(i.lithent={}))})(this,function(i){"use strict";const y=Symbol.for("lithentWDomSymbol"),T={value:""},R={value:null},P={value:!1},a=new WeakMap,j=new WeakSet;let W=!1;const Me=e=>{a.set(e,{vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},k=()=>R.value,V=(e,t)=>{const n=a.get(e);return n?n[t]:null},Se=e=>{R.value=e},Te=e=>{R.value=e,Me(e)},be=e=>{W=e},Ee=()=>W,D=e=>{const t=a.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ne=e=>{D(e),a.delete(e)},v=e=>e.getParent&&e.getParent(),Fe=Object.entries,xe=Object.keys,g=e=>typeof e=="object"&&e!==null,Ae=Object.assign,Ue=e=>g(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(y),M=e=>g(e)&&!("resolve"in e),F=(e,t)=>M(e)&&e.type===t,Le=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Be=(e,t)=>!!(M(e)&&t&&t.type==="f"&&t.children&&t.children.length===(e.children&&e.children.length)),Oe=(e,t)=>!!(M(e)&&t&&t.type==="e"&&t.tag===e.tag&&t.children&&t.children.length===(e.children&&e.children.length)),ee=(e,t)=>!!(M(e)&&t&&t.type===e.type),Ke=(e,t)=>!!(M(e)&&t&&t.type===e.type&&(A((e.children||[])[0])&&A((t.children||[])[0])||t.children&&e.children&&t.children.length===e.children.length)),_=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),S=e=>e==="f"||e==="l",x=e=>typeof e=="function"&&!te(e)||g(e)&&"resolve"in e,te=e=>typeof e=="function"&&e===I,Qe=e=>M(e)&&!e.type,A=e=>ne(_(e)),ne=e=>e!=null,ce=(e,t)=>e==="style"&&g(t),Ie=(e,t)=>e==="ref"&&g(t),se=new Map,je=(e,t)=>{const n=e.nodeName+"|"+t;let c=se.get(n);if(c===void 0){const s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);c=!!(s&&s.get&&s.set),se.set(n,c)}return c},Ve=e=>x(e)?"c":F(e,"f")?"f":F(e,"e")?"e":F(e,"l")?"l":F(e,"t")?"t":"et",_e={c:Le,l:Ke,t:ee,e:Oe,f:Be,et:ee},oe=e=>{const t=k();if(t){const n=a.get(t);n&&n.umts.push(e)}},U=e=>{const{compKey:t}=e;t&&ze(t),re(e)},re=e=>{(e.children||[]).forEach(t=>{t.compKey?U(t):re(t)})},ze=e=>{D(e),Ee()||a.delete(e)};let z=[];const He=e=>{e.compKey&&z.push(e)},b=()=>{z.forEach(e=>Ge(e)),z=[]},qe=e=>{const t=k();if(t){const n=a.get(t);n&&n.mts.push(e)}},Ge=e=>{const{compKey:t}=e;if(t){const n=a.get(t);if(!n)return;const{mts:c,upS:s}=n;R.value=t,s&&(s.value=0),c&&(n.mts=[],c.forEach(o=>{const r=o();r&&oe(r)}))}},Je=e=>{const t=k();if(t){const n=a.get(t);n&&n.wdCB.push(e)}},Xe=e=>{const{compKey:t}=e;if(t){const n=a.get(t),c=n&&n.wdCB;R.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(s=>{const o=s();o&&typeof o=="function"&&oe(o)}))}},le=(e,t=()=>[])=>{const n=k();if(!n)return;const c=a.get(n);if(!c)return;const{upD:s,upS:o}=c,r=s[o.value],l=t();if(r&&Ze(r,l)){const u=e();u&&c.upCB.push(u)}s[o.value]=l,o.value+=1},Ye=e=>{const{compKey:t}=e;if(t){const n=a.get(t);if(!n)return;const{upCB:c,upS:s}=n;R.value=t,s&&(s.value=0),e.ctor&&c&&(n.upCB=[],c.forEach(o=>o()))}},Ze=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,H=()=>new DocumentFragment,$e=e=>document.createElement(e),me=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const s=E(e,c);return n?(e.ae=n,t.insertBefore(s,n)):c||(t.tagName==="HTML"?t.replaceWith(s):t.appendChild(s)),b(),()=>{const o=a.get(e.compProps||{}),r=o&&o.vd.value||e;r!==e&&U(r),L(r),we(r)}},L=e=>{e.props&&e.el&&fe(e.props,e.el),(e.children||[]).forEach(t=>{L(t)})},we=e=>ue(e,e.we),B=e=>{e.op&&e.el&&fe(e.op,e.el);const t=v(e),n=e.isRoot?e.we:t?N(t):void 0;n&&ue(e,n)},ue=(e,t)=>{if(t&&e.el){const n=e.el.nodeType;n===11||(e==null?void 0:e.tag)==="portal"?ie(e,t):(n===1||n===3)&&t.removeChild(e.el),delete e.el}},ie=(e,t)=>{const n=e&&e.oc||e&&e.children||[];let c=0;for(let s=t.firstChild;s;s=s.nextSibling)c++;if(n.length>1&&c===n.length&&n.every(s=>{const o=s.el&&s.el.nodeType;return(o===1||o===3)&&s.el.tagName!=="HTML"&&s.tag!=="portal"})){t.textContent="",n.forEach(s=>delete s.el);return}n.forEach(s=>{const o=s.el&&s.el.nodeType;if(o)if(o===1||o===3){const r=s.el;r.tagName==="HTML"?r.innerHTML="":r.remove()}else o===11&&ie(s,t)})},We=e=>{e.forEach(t=>{U(t),L(t),B(t)})},q=e=>{B(e),G(e)},De=e=>{X(e),(v(e)||e.isRoot)&&G(e,J(e))},G=(e,t)=>{t||(t=E(e));const n=v(e);if(!n||!n.type){e.isRoot&&e.we&&t&&e.tag!=="portal"&&(e.ae?e.we.insertBefore(t,e.ae):e.we.tagName==="HTML"?e.we.replaceWith(t):e.we.appendChild(t),b());return}const c=N(n),s=n.type==="l"&&n.nr?O(n,v(n)):O(e,n);t&&c&&(e.tag!=="portal"&&c.insertBefore(t,s||null),b())},J=e=>S(e.type)?(e&&e.children||[]).reduce((t,n)=>{const c=J(n);return c&&t.appendChild(c),t},H()):e.el,O=(e,t)=>{const n=t.children||[],s=n.indexOf(e)+1,o=n.slice(s),r=K(o),l=t.type||"";if(r)return r;if(!t.isRoot&&S(l))return O(t,v(t));if(t.isRoot&&S(l)&&t.ae)return t.ae},K=e=>e.reduce((t,n)=>{if(t)return t;const{type:c,el:s}=n;if(c&&S(c)){const o=K(n.children||[]);if(o)return o}return s&&s.nodeType!==11?s:t},void 0),et=e=>{const t=v(e),n=e.el;if(e.isRoot&&!t&&n){q(e);return}if(t&&t.type&&n)if(n.nodeType===11)q(e);else{const c=N(t),s=E(e);c&&e.tag!=="portal"&&c.replaceChild(s,n),b()}},fe=(e,t)=>{for(const n in e)n[0]==="o"&&n[1]==="n"&&t.removeEventListener(n.slice(2).toLowerCase(),e[n])},X=e=>{if(e.type==="t"){st(e);return}if(e.el){const{op:t,props:n}=e;de(n,e.el,t),delete e.op,e.tag==="input"&&(e.el.value=String(n&&n.value||""))}tt(e),Ye(e)},tt=e=>{const t=e.children||[];let n=!1;if(e.type==="l"){for(const f of t)if("ATS".includes(f.nr)||f.oi!==void 0){n=!0;break}}if(!n){t.forEach(f=>Y(f));return}const c=[],s=[],o=[];let r=0;t.forEach((f,d)=>{const C=f.nr;C==="A"||C==="S"?(C==="S"&&B(f),c[d]=E(f),r++):C==="T"?X(f):Y(f),f.oi!==void 0&&c[d]===void 0&&(s.push(d),o.push(f.oi))});const l=new Set(nt(o).map(f=>s[f])),u=N(e),h=e.isRoot?e.ae:O(e,v(e));let p=t.length;for(;p>0&&c[p-1]!==void 0;)p--;for(let f=p;f<t.length;f++){const d=c[f];d&&u&&t[f].tag!=="portal"&&u.insertBefore(d,h||null)}if(l.size!==s.length||r>t.length-p){let f=K(t.slice(p))||h;for(let d=p-1;d>=0;d--){const C=t[d],w=c[d]!==void 0,It=C.oi!==void 0&&!w&&!l.has(d);if((w||It)&&u&&C.tag!=="portal"){const ge=w?c[d]:J(C);ge&&u.insertBefore(ge,f||null)}const Pe=K([C]);Pe&&(f=Pe)}}t.forEach(ae),b()},ae=e=>{delete e.oi,delete e.nr,delete e.oc,delete e.op},nt=e=>{const t=[];if(!e.length)return t;const n=new Array(e.length);t.push(0);for(let o=1;o<e.length;o++){const r=e[o];if(e[t[t.length-1]]<r){n[o]=t[t.length-1],t.push(o);continue}let l=0,u=t.length-1;for(;l<u;){const h=l+u>>1;e[t[h]]<r?l=h+1:u=h}r<e[t[l]]&&(l>0&&(n[o]=t[l-1]),t[l]=o)}let c=t.length,s=t[c-1];for(;c-- >0;)t[c]=s,s=n[s];return t},Y=e=>{const{nr:t}=e;t!==void 0&&t!=="N"&&(ct[t](e),ae(e))},ct={A:G,D:B,R:et,U:X,S:q,T:De},st=e=>{e.el&&(e.el.nodeValue=String(e.text))},de=(e,t,n,c)=>{const s=n||{};for(const o in e){const r=e[o];if(r===s[o]){delete s[o];continue}const l=o[0]==="o"&&o[1]==="n";c&&l?pe(t,o,r,s[o]):(o==="key"||o==="portal"&&g(r)||(o==="innerHTML"&&typeof r=="string"?t.innerHTML=r:ce(o,r)?lt(r,ce(o,s.style)?s.style:{},t):Ie(o,r)?r.value=t:l?pe(t,o,r,s[o]):o&&(o!=="type"&&je(t,o)?t[o]=r:ot(o==="className"?"class":o,t,r))),delete s[o])}for(const o in s)t.removeAttribute(o)},ot=(e,t,n)=>T.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),E=(e,t)=>{let n;const{type:c,tag:s,text:o,props:r,children:l=[]}=e,u=S(c);if(Xe(e),s==="svg"&&(T.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c)n=H();else if(u)n=H();else if(c==="e"&&s)s==="portal"&&r&&r.portal?n=r.portal:n=T.value?document.createElementNS(T.value,s):$e(s);else if(c==="t"&&ne(o))n=document.createTextNode(String(o));else throw Error("Invalid wDom");e.el=n}return rt(l,n,t),de(r,n,null,t),He(e),s==="svg"&&(T.value=""),n},rt=(e,t,n)=>{e.forEach(c=>{if(c.type){const s=E(c,n);c.tag!=="portal"&&!n&&t&&t.appendChild(s)}})},pe=(e,t,n,c)=>{const s=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(s,c),n&&e.addEventListener(s,n))},lt=(e,t,n)=>{const c={...t},s=n instanceof HTMLElement?n:null,o=s==null?void 0:s.style;if(!o)return;const r=o;for(const l in e)r[l]=e[l],delete c[l];for(const l in c)r[l]=""},N=e=>{const t=S(e.type);return e.isRoot&&t?e.we:t?N(v(e)):e.el},Q=(e,t)=>ut(e,_e[Ve(e)](e,t),t),ut=(e,t,n)=>{const c=ht(e,t,n),s=ft(c,t,n),o=s==="N";return o||(c.children=yt(c,t,n)),c.nr=s,it(c,n,s),!o&&n&&(n.il=!0,delete n.children),(n==null?void 0:n.tag)==="portal"&&(c.tag="portal"),c},it=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&(U(t),L(t)),e.oc=t&&t.children),e.op=t&&t.props},ft=(e,t,n)=>{if(Qe(e))return"D";if(e.type==="t"&&t&&e.text===(n&&n.text)||e===n)return"N";if(!(n&&n.type))return"A";const o=v(n),r=!e.isRoot&&o&&o.type==="l"&&A(e);return t?r?"T":"U":r?"S":"R"},at=(e,t)=>{e&&t!==e&&(xe(e).forEach(n=>delete e[n]),Fe(t||{}).forEach(([n,c])=>e[n]=c))},dt=(e,t)=>{e&&(e.splice(0,e.length),t&&t.forEach(n=>e.push(n)))},pt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:s,children:o}=t;return n&&at(n,s),c&&o&&c!==o&&dt(c,o),e.reRender&&e.reRender()},ht=(e,t,n)=>x(e)?t&&n?pt(n,e):e.resolve():e,yt=(e,t,n)=>t&&n?Ct(e,n):vt(e),vt=e=>{const t=()=>e;return(e.children||[]).map(n=>{const c=Q(n);return c.getParent=t,c})},Ct=(e,t)=>{if(e.type==="l"&&A((e.children||[])[0]))return kt(e,t);const n=t.children||[],c=()=>e;return(e.children||[]).map((s,o)=>{const r=Q(s,n[o]);return r.getParent=c,r})},kt=(e,t)=>{const[n,c]=Rt(e,t);return We(c),n},Rt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((r,l)=>{const u=_(r);c.has(u)||c.set(u,l)});const s=()=>e;return[(e.children||[]).map(r=>{const l=_(r),u=c.get(l),h=u!==void 0;h&&c.delete(l);const p=Q(r,h?n[u]:void 0);return h&&(p.oi=u),p.getParent=s,p}),[...c.values()].map(r=>n[r])]},Z=new Map;let $=!1;const Pt=(e,t)=>{const n=a.get(e);n&&(n.up=()=>{Z.set(e,t),$||($=!0,queueMicrotask(gt))})},m=e=>()=>{const t=a.get(e),n=t&&t.up;return n?(n(),!0):!1},gt=()=>{Z.forEach(e=>{e()}),Z.clear(),$=!1},Mt=(e,t=()=>[])=>{const n=k();if(!n)return;const c=a.get(n);c&&(c.upR.push(()=>le(e,t)),le(e,t))},St=()=>{const e=k();if(!e)return;const t=a.get(e),n=t&&t.upR;n&&n.length&&n.forEach(c=>c())},I=(e,...t)=>({type:"f",[y]:!0,children:t}),he=(e,t,...n)=>{const c={value:void 0},s=ve(c,n),o=Ft(e,t||{},s);return x(o)||(c.value=o),o},Tt=(e,t)=>he("portal",{portal:t},e),bt=e=>(t,n)=>e,Et=e=>(t,n)=>(j.add(e),e),Nt=(e,t,n)=>{const c=(s,o)=>{if(!(!s||o.has(s))){if(o.add(s),s.compChild){const r=s.compChild.indexOf(t);r!==-1&&s.compChild.splice(r,1,n)}c(s.getParent?s.getParent():void 0,o)}};c(e,new Set)},ye=(e,t,n,c)=>{if(c.il)return;P.value=!0;const s=ke(e,t,n),o=Q(s,c),{isRoot:r,getParent:l,we:u,ae:h}=c;if(o.getParent=l,!r&&l){const p=l(),f=p&&p.children||[],d=f.indexOf(c);d!==-1&&f.splice(d,1,o),Nt(p,c,o)}else o.isRoot=!0,o.we=u,o.ae=h;P.value=!1,Y(o)},Ft=(e,t,n)=>{if(te(e))return I(t,...n);if(x(e)){const c=ke(e,t,n);return P.value?c:c.resolve()}return{type:"e",[y]:!0,tag:e,props:t,children:n}},ve=(e,t)=>{const n=()=>e.value;return t.map(c=>{const s=Ce(c);return s.getParent=n,s})},Ce=e=>{if(e==null||e===!1)return{type:null,[y]:!0};if(Array.isArray(e)){const t={value:void 0},n=ve(t,e),c={type:"l",[y]:!0,children:n};return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return{type:"t",[y]:!0,text:e};return e},xt=(e,t,n)=>(c=t)=>{const s=P.value;P.value=!1,Te(c);const o=e(t,n);let r;if(typeof o=="function"){const u=o;r=j.has(u)?u(t,n):u(m(c),t,n)}else r=u=>e(u,n);const l=At(r,c,e,t,n);return P.value=s,l},ke=(e,t,n)=>{const c=e,s=n,o=xt(e,t,s);return{ctor:c,props:t,children:s,resolve:o}},At=(e,t,n,c,s)=>{const o=h=>Ce(e(h)),{wrappedComponentMaker:r,customNode:l}=Bt(o,c),u=Ut(r,t,n,c,s);return Re(l,t,n,c,s,u),l},Ut=(e,t,n,c,s)=>{const o=()=>Lt(e,t,n,c,s,o);return o},Lt=(e,t,n,c,s,o)=>{Se(t),St();const r=e(c);return Re(r,t,n,c,s,o),r},Bt=(e,t)=>{const n=s=>{const o=e(s),r=I({},o);return o.getParent=()=>r,r},c=n(t);return{wrappedComponentMaker:n,customNode:c}},Re=(e,t,n,c,s,o)=>{Ae(e,{compProps:c,compChild:s,ctor:n,compKey:t,reRender:o}),Pt(t,()=>ye(n,e.compProps||c,e.compChild||s,e)),V(t,"vd")&&(V(t,"vd").value=e)},Ot=e=>({value:e}),Kt=()=>Promise.resolve(),Qt=()=>{const e=k();return e?m(e):()=>!1};i.Fragment=I,i.componentMap=a,i.componentUpdate=m,i.disposeComponentEntry=Ne,i.getComponentKey=k,i.getComponentSubInfo=V,i.h=he,i.isPropType=Ue,i.lmount=Et,i.lmountComponentSet=j,i.mount=bt,i.mountCallback=qe,i.mountReadyCallback=Je,i.nextTick=Kt,i.portal=Tt,i.ref=Ot,i.render=me,i.replaceWDom=ye,i.setComponentMapManualMode=be,i.updateCallback=Mt,i.useRenew=Qt,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(i=typeof globalThis<"u"?globalThis:i||self,y(i.lithent={}))})(this,function(i){"use strict";const y=Symbol.for("lithentWDomSymbol"),T={value:""},R={value:null},P={value:!1},a=new WeakMap,j=new WeakSet;let W=!1;const Me=e=>{a.set(e,{vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},k=()=>R.value,V=(e,t)=>{const n=a.get(e);return n?n[t]:null},Se=e=>{R.value=e},Te=e=>{R.value=e,Me(e)},be=e=>{W=e},Ee=()=>W,D=e=>{const t=a.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ne=e=>{D(e),a.delete(e)},v=e=>e.getParent&&e.getParent(),Fe=Object.entries,xe=Object.keys,g=e=>typeof e=="object"&&e!==null,Ae=Object.assign,Ue=e=>g(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(y),M=e=>g(e)&&!("resolve"in e),F=(e,t)=>M(e)&&e.type===t,Le=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Be=(e,t)=>!!(M(e)&&t&&t.type==="f"&&t.children&&t.children.length===(e.children&&e.children.length)),Oe=(e,t)=>!!(M(e)&&t&&t.type==="e"&&t.tag===e.tag&&t.children&&t.children.length===(e.children&&e.children.length)),ee=(e,t)=>!!(M(e)&&t&&t.type===e.type),Ke=(e,t)=>!!(M(e)&&t&&t.type===e.type&&(A((e.children||[])[0])&&A((t.children||[])[0])||t.children&&e.children&&t.children.length===e.children.length)),_=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),S=e=>e==="f"||e==="l",x=e=>typeof e=="function"&&!te(e)||g(e)&&"resolve"in e,te=e=>typeof e=="function"&&e===I,Qe=e=>M(e)&&!e.type,A=e=>ne(_(e)),ne=e=>e!=null,ce=(e,t)=>e==="style"&&g(t),Ie=(e,t)=>e==="ref"&&g(t),se=new Map,je=(e,t)=>{const n=e.nodeName+"|"+t;let c=se.get(n);if(c===void 0){const s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);c=!!(s&&s.get&&s.set),se.set(n,c)}return c},Ve=e=>x(e)?"c":F(e,"f")?"f":F(e,"e")?"e":F(e,"l")?"l":F(e,"t")?"t":"et",_e={c:Le,l:Ke,t:ee,e:Oe,f:Be,et:ee},oe=e=>{const t=k();if(t){const n=a.get(t);n&&n.umts.push(e)}},U=e=>{const{compKey:t}=e;t&&(e.il=!0,ze(t)),re(e)},re=e=>{(e.children||[]).forEach(t=>{t.compKey?U(t):re(t)})},ze=e=>{D(e),Ee()||a.delete(e)};let z=[];const He=e=>{e.compKey&&z.push(e)},b=()=>{z.forEach(e=>Ge(e)),z=[]},qe=e=>{const t=k();if(t){const n=a.get(t);n&&n.mts.push(e)}},Ge=e=>{const{compKey:t}=e;if(t){const n=a.get(t);if(!n)return;const{mts:c,upS:s}=n;R.value=t,s&&(s.value=0),c&&(n.mts=[],c.forEach(o=>{const r=o();r&&oe(r)}))}},Je=e=>{const t=k();if(t){const n=a.get(t);n&&n.wdCB.push(e)}},Xe=e=>{const{compKey:t}=e;if(t){const n=a.get(t),c=n&&n.wdCB;R.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(s=>{const o=s();o&&typeof o=="function"&&oe(o)}))}},le=(e,t=()=>[])=>{const n=k();if(!n)return;const c=a.get(n);if(!c)return;const{upD:s,upS:o}=c,r=s[o.value],l=t();if(r&&Ze(r,l)){const u=e();u&&c.upCB.push(u)}s[o.value]=l,o.value+=1},Ye=e=>{const{compKey:t}=e;if(t){const n=a.get(t);if(!n)return;const{upCB:c,upS:s}=n;R.value=t,s&&(s.value=0),e.ctor&&c&&(n.upCB=[],c.forEach(o=>o()))}},Ze=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,H=()=>new DocumentFragment,$e=e=>document.createElement(e),me=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const s=E(e,c);return n?(e.ae=n,t.insertBefore(s,n)):c||(t.tagName==="HTML"?t.replaceWith(s):t.appendChild(s)),b(),()=>{const o=a.get(e.compProps||{}),r=o&&o.vd.value||e;r!==e&&U(r),L(r),we(r)}},L=e=>{e.props&&e.el&&fe(e.props,e.el),(e.children||[]).forEach(t=>{L(t)})},we=e=>ue(e,e.we),B=e=>{e.op&&e.el&&fe(e.op,e.el);const t=v(e),n=e.isRoot?e.we:t?N(t):void 0;n&&ue(e,n)},ue=(e,t)=>{if(t&&e.el){const n=e.el.nodeType;n===11||(e==null?void 0:e.tag)==="portal"?ie(e,t):(n===1||n===3)&&t.removeChild(e.el),delete e.el}},ie=(e,t)=>{const n=e&&e.oc||e&&e.children||[];let c=0;for(let s=t.firstChild;s;s=s.nextSibling)c++;if(n.length>1&&c===n.length&&n.every(s=>{const o=s.el&&s.el.nodeType;return(o===1||o===3)&&s.el.tagName!=="HTML"&&s.tag!=="portal"})){t.textContent="",n.forEach(s=>delete s.el);return}n.forEach(s=>{const o=s.el&&s.el.nodeType;if(o)if(o===1||o===3){const r=s.el;r.tagName==="HTML"?r.innerHTML="":r.remove()}else o===11&&ie(s,t)})},We=e=>{e.forEach(t=>{U(t),L(t),B(t)})},q=e=>{B(e),G(e)},De=e=>{X(e),(v(e)||e.isRoot)&&G(e,J(e))},G=(e,t)=>{t||(t=E(e));const n=v(e);if(!n||!n.type){e.isRoot&&e.we&&t&&e.tag!=="portal"&&(e.ae?e.we.insertBefore(t,e.ae):e.we.tagName==="HTML"?e.we.replaceWith(t):e.we.appendChild(t),b());return}const c=N(n),s=n.type==="l"&&n.nr?O(n,v(n)):O(e,n);t&&c&&(e.tag!=="portal"&&c.insertBefore(t,s||null),b())},J=e=>S(e.type)?(e&&e.children||[]).reduce((t,n)=>{const c=J(n);return c&&t.appendChild(c),t},H()):e.el,O=(e,t)=>{const n=t.children||[],s=n.indexOf(e)+1,o=n.slice(s),r=K(o),l=t.type||"";if(r)return r;if(!t.isRoot&&S(l))return O(t,v(t));if(t.isRoot&&S(l)&&t.ae)return t.ae},K=e=>e.reduce((t,n)=>{if(t)return t;const{type:c,el:s}=n;if(c&&S(c)){const o=K(n.children||[]);if(o)return o}return s&&s.nodeType!==11?s:t},void 0),et=e=>{const t=v(e),n=e.el;if(e.isRoot&&!t&&n){q(e);return}if(t&&t.type&&n)if(n.nodeType===11)q(e);else{const c=N(t),s=E(e);c&&e.tag!=="portal"&&c.replaceChild(s,n),b()}},fe=(e,t)=>{for(const n in e)n[0]==="o"&&n[1]==="n"&&t.removeEventListener(n.slice(2).toLowerCase(),e[n])},X=e=>{if(e.type==="t"){st(e);return}if(e.el){const{op:t,props:n}=e;de(n,e.el,t),delete e.op,e.tag==="input"&&(e.el.value=String(n&&n.value||""))}tt(e),Ye(e)},tt=e=>{const t=e.children||[];let n=!1;if(e.type==="l"){for(const f of t)if("ATS".includes(f.nr)||f.oi!==void 0){n=!0;break}}if(!n){t.forEach(f=>Y(f));return}const c=[],s=[],o=[];let r=0;t.forEach((f,d)=>{const C=f.nr;C==="A"||C==="S"?(C==="S"&&B(f),c[d]=E(f),r++):C==="T"?X(f):Y(f),f.oi!==void 0&&c[d]===void 0&&(s.push(d),o.push(f.oi))});const l=new Set(nt(o).map(f=>s[f])),u=N(e),h=e.isRoot?e.ae:O(e,v(e));let p=t.length;for(;p>0&&c[p-1]!==void 0;)p--;for(let f=p;f<t.length;f++){const d=c[f];d&&u&&t[f].tag!=="portal"&&u.insertBefore(d,h||null)}if(l.size!==s.length||r>t.length-p){let f=K(t.slice(p))||h;for(let d=p-1;d>=0;d--){const C=t[d],w=c[d]!==void 0,It=C.oi!==void 0&&!w&&!l.has(d);if((w||It)&&u&&C.tag!=="portal"){const ge=w?c[d]:J(C);ge&&u.insertBefore(ge,f||null)}const Pe=K([C]);Pe&&(f=Pe)}}t.forEach(ae),b()},ae=e=>{delete e.oi,delete e.nr,delete e.oc,delete e.op},nt=e=>{const t=[];if(!e.length)return t;const n=new Array(e.length);t.push(0);for(let o=1;o<e.length;o++){const r=e[o];if(e[t[t.length-1]]<r){n[o]=t[t.length-1],t.push(o);continue}let l=0,u=t.length-1;for(;l<u;){const h=l+u>>1;e[t[h]]<r?l=h+1:u=h}r<e[t[l]]&&(l>0&&(n[o]=t[l-1]),t[l]=o)}let c=t.length,s=t[c-1];for(;c-- >0;)t[c]=s,s=n[s];return t},Y=e=>{const{nr:t}=e;t!==void 0&&t!=="N"&&(ct[t](e),ae(e))},ct={A:G,D:B,R:et,U:X,S:q,T:De},st=e=>{e.el&&(e.el.nodeValue=String(e.text))},de=(e,t,n,c)=>{const s=n||{};for(const o in e){const r=e[o];if(r===s[o]){delete s[o];continue}const l=o[0]==="o"&&o[1]==="n";c&&l?pe(t,o,r,s[o]):(o==="key"||o==="portal"&&g(r)||(o==="innerHTML"&&typeof r=="string"?t.innerHTML=r:ce(o,r)?lt(r,ce(o,s.style)?s.style:{},t):Ie(o,r)?r.value=t:l?pe(t,o,r,s[o]):o&&(o!=="type"&&je(t,o)?t[o]=r:ot(o==="className"?"class":o,t,r))),delete s[o])}for(const o in s)t.removeAttribute(o)},ot=(e,t,n)=>T.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),E=(e,t)=>{let n;const{type:c,tag:s,text:o,props:r,children:l=[]}=e,u=S(c);if(Xe(e),s==="svg"&&(T.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c)n=H();else if(u)n=H();else if(c==="e"&&s)s==="portal"&&r&&r.portal?n=r.portal:n=T.value?document.createElementNS(T.value,s):$e(s);else if(c==="t"&&ne(o))n=document.createTextNode(String(o));else throw Error("Invalid wDom");e.el=n}return rt(l,n,t),de(r,n,null,t),He(e),s==="svg"&&(T.value=""),n},rt=(e,t,n)=>{e.forEach(c=>{if(c.type){const s=E(c,n);c.tag!=="portal"&&!n&&t&&t.appendChild(s)}})},pe=(e,t,n,c)=>{const s=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(s,c),n&&e.addEventListener(s,n))},lt=(e,t,n)=>{const c={...t},s=n instanceof HTMLElement?n:null,o=s==null?void 0:s.style;if(!o)return;const r=o;for(const l in e)r[l]=e[l],delete c[l];for(const l in c)r[l]=""},N=e=>{const t=S(e.type);return e.isRoot&&t?e.we:t?N(v(e)):e.el},Q=(e,t)=>ut(e,_e[Ve(e)](e,t),t),ut=(e,t,n)=>{const c=ht(e,t,n),s=ft(c,t,n),o=s==="N";return o||(c.children=yt(c,t,n)),c.nr=s,it(c,n,s),!o&&n&&(n.il=!0,delete n.children),(n==null?void 0:n.tag)==="portal"&&(c.tag="portal"),c},it=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&(U(t),L(t)),e.oc=t&&t.children),e.op=t&&t.props},ft=(e,t,n)=>{if(Qe(e))return"D";if(e.type==="t"&&t&&e.text===(n&&n.text)||e===n)return"N";if(!(n&&n.type))return"A";const o=v(n),r=!e.isRoot&&o&&o.type==="l"&&A(e);return t?r?"T":"U":r?"S":"R"},at=(e,t)=>{e&&t!==e&&(xe(e).forEach(n=>delete e[n]),Fe(t||{}).forEach(([n,c])=>e[n]=c))},dt=(e,t)=>{e&&(e.splice(0,e.length),t&&t.forEach(n=>e.push(n)))},pt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:s,children:o}=t;return n&&at(n,s),c&&o&&c!==o&&dt(c,o),e.reRender&&e.reRender()},ht=(e,t,n)=>x(e)?t&&n?pt(n,e):e.resolve():e,yt=(e,t,n)=>t&&n?Ct(e,n):vt(e),vt=e=>{const t=()=>e;return(e.children||[]).map(n=>{const c=Q(n);return c.getParent=t,c})},Ct=(e,t)=>{if(e.type==="l"&&A((e.children||[])[0]))return kt(e,t);const n=t.children||[],c=()=>e;return(e.children||[]).map((s,o)=>{const r=Q(s,n[o]);return r.getParent=c,r})},kt=(e,t)=>{const[n,c]=Rt(e,t);return We(c),n},Rt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((r,l)=>{const u=_(r);c.has(u)||c.set(u,l)});const s=()=>e;return[(e.children||[]).map(r=>{const l=_(r),u=c.get(l),h=u!==void 0;h&&c.delete(l);const p=Q(r,h?n[u]:void 0);return h&&(p.oi=u),p.getParent=s,p}),[...c.values()].map(r=>n[r])]},Z=new Map;let $=!1;const Pt=(e,t)=>{const n=a.get(e);n&&(n.up=()=>{Z.set(e,t),$||($=!0,queueMicrotask(gt))})},m=e=>()=>{const t=a.get(e),n=t&&t.up;return n?(n(),!0):!1},gt=()=>{Z.forEach(e=>{e()}),Z.clear(),$=!1},Mt=(e,t=()=>[])=>{const n=k();if(!n)return;const c=a.get(n);c&&(c.upR.push(()=>le(e,t)),le(e,t))},St=()=>{const e=k();if(!e)return;const t=a.get(e),n=t&&t.upR;n&&n.length&&n.forEach(c=>c())},I=(e,...t)=>({type:"f",[y]:!0,children:t}),he=(e,t,...n)=>{const c={value:void 0},s=ve(c,n),o=Ft(e,t||{},s);return x(o)||(c.value=o),o},Tt=(e,t)=>he("portal",{portal:t},e),bt=e=>(t,n)=>e,Et=e=>(t,n)=>(j.add(e),e),Nt=(e,t,n)=>{const c=(s,o)=>{if(!(!s||o.has(s))){if(o.add(s),s.compChild){const r=s.compChild.indexOf(t);r!==-1&&s.compChild.splice(r,1,n)}c(s.getParent?s.getParent():void 0,o)}};c(e,new Set)},ye=(e,t,n,c)=>{if(c.il)return;P.value=!0;const s=ke(e,t,n),o=Q(s,c),{isRoot:r,getParent:l,we:u,ae:h}=c;if(o.getParent=l,!r&&l){const p=l(),f=p&&p.children||[],d=f.indexOf(c);d!==-1&&f.splice(d,1,o),Nt(p,c,o)}else o.isRoot=!0,o.we=u,o.ae=h;P.value=!1,Y(o)},Ft=(e,t,n)=>{if(te(e))return I(t,...n);if(x(e)){const c=ke(e,t,n);return P.value?c:c.resolve()}return{type:"e",[y]:!0,tag:e,props:t,children:n}},ve=(e,t)=>{const n=()=>e.value;return t.map(c=>{const s=Ce(c);return s.getParent=n,s})},Ce=e=>{if(e==null||e===!1)return{type:null,[y]:!0};if(Array.isArray(e)){const t={value:void 0},n=ve(t,e),c={type:"l",[y]:!0,children:n};return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return{type:"t",[y]:!0,text:e};return e},xt=(e,t,n)=>(c=t)=>{const s=P.value;P.value=!1,Te(c);const o=e(t,n);let r;if(typeof o=="function"){const u=o;r=j.has(u)?u(t,n):u(m(c),t,n)}else r=u=>e(u,n);const l=At(r,c,e,t,n);return P.value=s,l},ke=(e,t,n)=>{const c=e,s=n,o=xt(e,t,s);return{ctor:c,props:t,children:s,resolve:o}},At=(e,t,n,c,s)=>{const o=h=>Ce(e(h)),{wrappedComponentMaker:r,customNode:l}=Bt(o,c),u=Ut(r,t,n,c,s);return Re(l,t,n,c,s,u),l},Ut=(e,t,n,c,s)=>{const o=()=>Lt(e,t,n,c,s,o);return o},Lt=(e,t,n,c,s,o)=>{Se(t),St();const r=e(c);return Re(r,t,n,c,s,o),r},Bt=(e,t)=>{const n=s=>{const o=e(s),r=I({},o);return o.getParent=()=>r,r},c=n(t);return{wrappedComponentMaker:n,customNode:c}},Re=(e,t,n,c,s,o)=>{Ae(e,{compProps:c,compChild:s,ctor:n,compKey:t,reRender:o}),Pt(t,()=>ye(n,e.compProps||c,e.compChild||s,e)),V(t,"vd")&&(V(t,"vd").value=e)},Ot=e=>({value:e}),Kt=()=>Promise.resolve(),Qt=()=>{const e=k();return e?m(e):()=>!1};i.Fragment=I,i.componentMap=a,i.componentUpdate=m,i.disposeComponentEntry=Ne,i.getComponentKey=k,i.getComponentSubInfo=V,i.h=he,i.isPropType=Ue,i.lmount=Et,i.lmountComponentSet=j,i.mount=bt,i.mountCallback=qe,i.mountReadyCallback=Je,i.nextTick=Kt,i.portal=Tt,i.ref=Ot,i.render=me,i.replaceWDom=ye,i.setComponentMapManualMode=be,i.updateCallback=Mt,i.useRenew=Qt,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=lithent.umd.js.map