lithent 1.25.2 → 1.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -14
- package/devHelper/package.json +2 -2
- package/dist/lithent-agent-addon.md +21 -1
- package/dist/lithent.cjs +1 -1
- package/dist/lithent.cjs.map +1 -1
- package/dist/lithent.mjs +401 -402
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/skills/lithent/SKILL.md +96 -45
- package/dist/skills/lithent/constraints/mistakes.md +1 -1
- package/dist/skills/lithent/constraints/rules.md +1 -1
- package/dist/skills/lithent/constraints/troubleshooting.md +1 -1
- package/dist/skills/lithent/examples/quick-examples.md +1 -1
- package/dist/skills/lithent/reference/children-type.md +1 -1
- package/dist/skills/lithent/reference/concurrent.md +1 -1
- package/dist/skills/lithent/reference/element.md +1 -1
- package/dist/skills/lithent/reference/events.md +74 -0
- package/dist/skills/lithent/reference/lstore-inference.md +1 -1
- package/dist/skills/lithent/reference/props-types.md +1 -1
- package/dist/utils/createWDom.d.cts +2 -0
- package/dist/utils/createWDom.d.ts +2 -0
- package/dist/utils/event.d.cts +12 -0
- package/dist/utils/event.d.ts +12 -0
- package/dist/utils/predicator.d.cts +1 -0
- package/dist/utils/predicator.d.ts +1 -0
- package/element/package.json +2 -2
- package/examples/dist/assets/index-BXMpKnXD.js +2 -0
- package/examples/dist/assets/index-BXMpKnXD.js.map +1 -0
- package/examples/dist/assets/index-C4K2fQqQ.js +2 -0
- package/examples/dist/assets/index-C4K2fQqQ.js.map +1 -0
- package/examples/dist/assets/index-CDu5iCaJ.js +2 -0
- package/examples/dist/assets/index-CDu5iCaJ.js.map +1 -0
- package/examples/dist/assets/index-Ch4u_8Bx.js +2 -0
- package/examples/dist/assets/index-Ch4u_8Bx.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/examples/package.json +2 -2
- package/ftags/package.json +2 -2
- package/helper/package.json +2 -2
- package/jsx-runtime/package.json +2 -2
- package/package.json +2 -3
- package/src/diff.ts +0 -4
- package/src/render.ts +49 -38
- package/src/tests/core-bulkRemoval.test.tsx +253 -0
- package/src/tests/core-eventContract.test.ts +242 -0
- package/src/tests/core-eventDispatch.test.ts +140 -0
- package/src/tests/core-keyedConsumption.test.tsx +103 -0
- package/src/tests/core-keyedFastPath.test.tsx +226 -0
- package/src/tests/core-parentPosition.test.tsx +177 -0
- package/src/tests/core-parentUpdateContract.test.tsx +225 -0
- package/src/tests/core-placementProof.test.tsx +509 -0
- package/src/tests/core-portalSiblings.test.tsx +281 -0
- package/src/utils/createWDom.ts +26 -0
- package/src/utils/predicator.ts +7 -0
- package/src/wDom.ts +14 -34
- package/ssr/package.json +2 -2
- package/tag/package.json +2 -2
- package/examples/dist/assets/index-B52a09eX.js +0 -2
- package/examples/dist/assets/index-B52a09eX.js.map +0 -1
package/README.md
CHANGED
|
@@ -20,12 +20,13 @@ It trims away unnecessary magic and complex APIs so your UI code stays simple, e
|
|
|
20
20
|
|
|
21
21
|
## Why Lithent?
|
|
22
22
|
|
|
23
|
-
**Lightweight DOM manipulation without the framework weight.** The
|
|
23
|
+
**Lightweight DOM manipulation without the framework weight.** The ~4.8KB Brotli core (minified UMD) drives complete UIs. Need state management? Opt into helpers like expansion packs instead of adopting a full stack.
|
|
24
24
|
|
|
25
25
|
Bring in only what you need — let the stack scale with your project.
|
|
26
26
|
|
|
27
27
|
**Design philosophy:**
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
- **Small Bundle** — ~4.8KB Brotli core (minified UMD) with optional extensions
|
|
29
30
|
- **Closure-based State** — No magic, just JavaScript
|
|
30
31
|
- **Manual or Reactive** — Choose your update strategy
|
|
31
32
|
- **Progressive Enhancement** — From static HTML to full SPA
|
|
@@ -66,16 +67,27 @@ npm install lithent
|
|
|
66
67
|
Lithent offers two complementary styles you can freely mix in the same project.
|
|
67
68
|
|
|
68
69
|
**Manual Mode** — Explicit control with `renew()`
|
|
70
|
+
|
|
69
71
|
```tsx
|
|
70
72
|
import { mount } from 'lithent';
|
|
71
73
|
|
|
72
74
|
const Counter = mount(renew => {
|
|
73
75
|
let count = 0;
|
|
74
|
-
return () =>
|
|
76
|
+
return () => (
|
|
77
|
+
<button
|
|
78
|
+
onClick={() => {
|
|
79
|
+
count++;
|
|
80
|
+
renew();
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{count}
|
|
84
|
+
</button>
|
|
85
|
+
);
|
|
75
86
|
});
|
|
76
87
|
```
|
|
77
88
|
|
|
78
89
|
**Light API Mode** — Automatic reactivity
|
|
90
|
+
|
|
79
91
|
```tsx
|
|
80
92
|
import { lmount } from 'lithent';
|
|
81
93
|
import { lstate } from 'lithent/helper';
|
|
@@ -88,17 +100,26 @@ const Counter = lmount(() => {
|
|
|
88
100
|
|
|
89
101
|
> **[📚 Explore component patterns in detail](https://superlucky84.github.io/lithent/#/guide/mounter)**
|
|
90
102
|
|
|
103
|
+
Component updates use `renew()` from `mount`, or `useRenew()` inside `lmount`.
|
|
104
|
+
The instance's props object is stable, but it is not guaranteed to be the
|
|
105
|
+
original object passed to `h()`. Since 1.25.2, components created outside a diff
|
|
106
|
+
receive shallow copies of props. If you previously used
|
|
107
|
+
`componentUpdate(originalProps)()`, see the [props guide](https://superlucky84.github.io/lithent/#/guide/props)
|
|
108
|
+
for the lookup contract and an external-data migration example.
|
|
109
|
+
|
|
91
110
|
<br />
|
|
92
111
|
|
|
93
112
|
## Key features
|
|
94
113
|
|
|
95
114
|
### Core
|
|
115
|
+
|
|
96
116
|
- **mount / lmount** — Component initialization
|
|
97
117
|
- **Portal** — Render outside parent DOM
|
|
98
118
|
- **Hooks** — Lifecycle callbacks (`mountCallback`, `updateCallback`, `mountReadyCallback`)
|
|
99
119
|
- **Ref** — Direct DOM access
|
|
100
120
|
|
|
101
121
|
### Helpers (optional)
|
|
122
|
+
|
|
102
123
|
- **state / lstate** — Reactive state management
|
|
103
124
|
- **computed** — Derived values
|
|
104
125
|
- **effect** — Side effects
|
|
@@ -106,6 +127,7 @@ const Counter = lmount(() => {
|
|
|
106
127
|
- **context / lcontext** — Cross-component data sharing
|
|
107
128
|
|
|
108
129
|
### Custom Elements (optional)
|
|
130
|
+
|
|
109
131
|
- **lithent/element** — Register a component as a standard Custom Element and embed it in any page (plain HTML, server templates, React, Vue) with a script and a tag. Shadow DOM style isolation, attribute/property props, DOM events. Under 1KB on top of the core.
|
|
110
132
|
|
|
111
133
|
```js
|
|
@@ -118,6 +140,7 @@ defineElement('pay-button', PayButton, { props: { amount: Number } });
|
|
|
118
140
|
> **[🧩 Custom Elements guide](https://superlucky84.github.io/lithent/#/guide/element)**
|
|
119
141
|
|
|
120
142
|
### Template options
|
|
143
|
+
|
|
121
144
|
- **JSX** — Via Vite plugin
|
|
122
145
|
- **FTags** — Function-style tags (no build step)
|
|
123
146
|
- **HTM** — Tagged template literals
|
|
@@ -125,21 +148,26 @@ defineElement('pay-button', PayButton, { props: { amount: Number } });
|
|
|
125
148
|
|
|
126
149
|
> **[📖 View full API reference](https://superlucky84.github.io/lithent/#/)**
|
|
127
150
|
|
|
151
|
+
Event props such as `onClick` register the original native callback. Replacing a
|
|
152
|
+
handler follows native removal and registration rules. For listener options,
|
|
153
|
+
use `ref` and `mountCallback` with cleanup. See the
|
|
154
|
+
[DOM event contract and example](skills/lithent/reference/events.md).
|
|
155
|
+
|
|
128
156
|
<br />
|
|
129
157
|
|
|
130
158
|
## Ecosystem
|
|
131
159
|
|
|
132
|
-
| Package
|
|
133
|
-
|
|
134
|
-
| [lithent](https://www.npmjs.com/package/lithent)
|
|
135
|
-
| [lithent/helper](https://www.npmjs.com/package/lithent)
|
|
136
|
-
| [lithent/ssr](https://www.npmjs.com/package/lithent)
|
|
137
|
-
| [lithent/ftags](https://www.npmjs.com/package/lithent)
|
|
138
|
-
| [lithent/tag](https://www.npmjs.com/package/lithent)
|
|
139
|
-
| [lithent/element](./element/README.md)
|
|
140
|
-
| [lithent-concurrent](./lithentConcurrent/README.md)
|
|
141
|
-
| [lithent-concurrent/helper](./lithentConcurrent/README.md#lithent-concurrenthelper) | Deferred state and component-local pending queries
|
|
142
|
-
| [create-lithent](https://www.npmjs.com/package/create-lithent)
|
|
160
|
+
| Package | Description |
|
|
161
|
+
| ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
162
|
+
| [lithent](https://www.npmjs.com/package/lithent) | Core library (~4.8KB Brotli, minified UMD) |
|
|
163
|
+
| [lithent/helper](https://www.npmjs.com/package/lithent) | Reactive state helpers |
|
|
164
|
+
| [lithent/ssr](https://www.npmjs.com/package/lithent) | Server‑side rendering |
|
|
165
|
+
| [lithent/ftags](https://www.npmjs.com/package/lithent) | Function‑style tag API |
|
|
166
|
+
| [lithent/tag](https://www.npmjs.com/package/lithent) | HTM template support |
|
|
167
|
+
| [lithent/element](./element/README.md) | Register components as Custom Elements, embeddable in any page ([guide](https://superlucky84.github.io/lithent/#/guide/element)) |
|
|
168
|
+
| [lithent-concurrent](./lithentConcurrent/README.md) | Separate core with priority scheduling and interruptible low-priority builds |
|
|
169
|
+
| [lithent-concurrent/helper](./lithentConcurrent/README.md#lithent-concurrenthelper) | Deferred state and component-local pending queries |
|
|
170
|
+
| [create-lithent](https://www.npmjs.com/package/create-lithent) | Project scaffolding tool |
|
|
143
171
|
|
|
144
172
|
For expensive component trees, select the concurrent core with an exact
|
|
145
173
|
`/^lithent$/` bundler alias. `deferRender` defers rendering while state writes
|
package/devHelper/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"version": "0.21.1",
|
|
5
5
|
"description": "Lithent development helper utilities",
|
|
6
6
|
"private": true,
|
|
7
|
-
"packageManager": "pnpm@
|
|
7
|
+
"packageManager": "pnpm@12.15.0",
|
|
8
8
|
"main": "./dist/lithentDevHelper.cjs",
|
|
9
9
|
"module": "./dist/lithentDevHelper.mjs",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"lithent": "workspace:*"
|
|
33
33
|
},
|
|
34
34
|
"volta": {
|
|
35
|
-
"node": "
|
|
35
|
+
"node": "24.22.1"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lithent Agent Addon
|
|
2
2
|
|
|
3
|
-
> Version: 1.25.
|
|
3
|
+
> Version: 1.25.4
|
|
4
4
|
|
|
5
5
|
You are a coding agent with Lithent virtual DOM guidance enabled.
|
|
6
6
|
|
|
@@ -9,16 +9,19 @@ ACTIVATION CONDITIONS:
|
|
|
9
9
|
These guidelines apply ONLY when Lithent is installed in the current project.
|
|
10
10
|
|
|
11
11
|
Before suggesting Lithent patterns, verify Lithent availability:
|
|
12
|
+
|
|
12
13
|
1. Check if `package.json` contains lithent in dependencies or devDependencies
|
|
13
14
|
2. Check if `node_modules/lithent` directory exists
|
|
14
15
|
3. Check if lithent imports are present in existing code
|
|
15
16
|
|
|
16
17
|
If Lithent is NOT installed:
|
|
18
|
+
|
|
17
19
|
- Do not enforce these guidelines
|
|
18
20
|
- Use standard coding practices appropriate for the project
|
|
19
21
|
- Never suggest installing lithent unless explicitly requested
|
|
20
22
|
|
|
21
23
|
If Lithent IS installed:
|
|
24
|
+
|
|
22
25
|
- Apply all guidelines below
|
|
23
26
|
- Suggest Lithent patterns for UI component creation
|
|
24
27
|
- Prioritize closure-based state management patterns
|
|
@@ -26,18 +29,21 @@ If Lithent IS installed:
|
|
|
26
29
|
CODING GUIDELINES:
|
|
27
30
|
|
|
28
31
|
1. COMPONENT MODE SELECTION
|
|
32
|
+
|
|
29
33
|
- Use `mount` for explicit render control with `renew()`
|
|
30
34
|
- Use `lmount` for automatic reactivity with `lstate`/`lstore`
|
|
31
35
|
- Don't mix modes: use `state`/`store` with `mount`, use `lstate`/`lstore` with `lmount`
|
|
32
36
|
- Suggest `lmount` for simpler components, `mount` for fine-grained control
|
|
33
37
|
|
|
34
38
|
2. COMPONENT STRUCTURE
|
|
39
|
+
|
|
35
40
|
- Outer function (mounter) runs once for initialization
|
|
36
41
|
- Inner function (updater) runs on every render
|
|
37
42
|
- Keep state setup in mounter, return JSX from updater
|
|
38
43
|
- Always return a function from mounter, never JSX directly
|
|
39
44
|
|
|
40
45
|
3. STATE MANAGEMENT
|
|
46
|
+
|
|
41
47
|
- Use `state(initialValue, renew)` with `mount` components
|
|
42
48
|
- Use `lstate(initialValue)` with `lmount` components
|
|
43
49
|
- Access values via `.value` property
|
|
@@ -45,44 +51,53 @@ CODING GUIDELINES:
|
|
|
45
51
|
- Use `computed` for derived values, `effect` for side effects
|
|
46
52
|
|
|
47
53
|
4. LIFECYCLE HOOKS
|
|
54
|
+
|
|
48
55
|
- Use `mountCallback` for setup after mount (return cleanup function)
|
|
49
56
|
- Use `updateCallback` for logic before each update
|
|
50
57
|
- Use `mountReadyCallback` for logic right after the WDom is created (before DOM insertion)
|
|
51
58
|
- Place hooks in mounter function, not in updater
|
|
52
59
|
|
|
53
60
|
5. LIST RENDERING
|
|
61
|
+
|
|
54
62
|
- Always use `key` prop for list items
|
|
55
63
|
- Keys must be unique and stable (prefer IDs over indices)
|
|
56
64
|
- Suggest adding keys when iterating over arrays without them
|
|
57
65
|
|
|
58
66
|
6. PERFORMANCE OPTIMIZATION
|
|
67
|
+
|
|
59
68
|
- Suggest `cacheUpdate` when multiple state updates cause re-renders
|
|
60
69
|
- Suggest `nextTickRender` for deferring expensive renders
|
|
61
70
|
- Avoid creating new functions in updater when possible
|
|
62
71
|
- Move event handlers to mounter scope when they don't need updater closure
|
|
72
|
+
- Event props register original callbacks directly; replacing a callback removes and re-registers it in native order. For listener options or independent setup, use `ref`/`mountCallback` and return native listener cleanup; see [event contracts](skills/lithent/reference/events.md).
|
|
63
73
|
|
|
64
74
|
7. SSR AND HYDRATION
|
|
75
|
+
|
|
65
76
|
- Use `renderToString` for server-side rendering
|
|
66
77
|
- Use `hydration` flag with `render` for client-side hydration
|
|
67
78
|
- Ensure component output is deterministic for hydration to work
|
|
68
79
|
|
|
69
80
|
8. TEMPLATE ALTERNATIVES
|
|
81
|
+
|
|
70
82
|
- Prefer JSX for most cases
|
|
71
83
|
- Suggest `fTags` for no-build-step environments
|
|
72
84
|
- Suggest `lTag` (HTM) for template literal preference
|
|
73
85
|
- Don't mix template styles within a single component
|
|
74
86
|
|
|
75
87
|
9. CONTEXT USAGE
|
|
88
|
+
|
|
76
89
|
- Use `createContext` with `mount`, `createLContext` with `lmount`
|
|
77
90
|
- Pass `renew` to `useContext()` in manual mode
|
|
78
91
|
- Suggest context over deep prop drilling (3+ levels)
|
|
79
92
|
|
|
80
93
|
10. CHILDREN HANDLING
|
|
94
|
+
|
|
81
95
|
- Use `unwrapChildren` helper when manipulating children
|
|
82
96
|
- Access children as third parameter in mounter function
|
|
83
97
|
- Don't modify children directly, wrap or filter them
|
|
84
98
|
|
|
85
99
|
11. CONCURRENT RENDERING (only when `lithent-concurrent` is installed or requested)
|
|
100
|
+
|
|
86
101
|
- Suggest it only for very large trees (thousands of rows); plain `lithent` otherwise
|
|
87
102
|
- Select the core with an exact `/^lithent$/` alias; never alias `lithent/*` subpaths
|
|
88
103
|
- Keep urgent input state and the heavy list in separate components
|
|
@@ -100,6 +115,7 @@ CODING GUIDELINES:
|
|
|
100
115
|
- Avoid native property names (`title`, `hidden`) as props
|
|
101
116
|
|
|
102
117
|
IMPORT PATHS:
|
|
118
|
+
|
|
103
119
|
- Core: `import { mount, lmount, render, h, Fragment, portal, ref, nextTick } from 'lithent'`
|
|
104
120
|
- Lifecycle: `import { mountCallback, updateCallback, mountReadyCallback } from 'lithent'`
|
|
105
121
|
- Helper (manual): `import { state, store, createContext, computed, effect } from 'lithent/helper'`
|
|
@@ -114,21 +130,25 @@ IMPORT PATHS:
|
|
|
114
130
|
GUIDANCE APPROACH:
|
|
115
131
|
|
|
116
132
|
When user creates UI components:
|
|
133
|
+
|
|
117
134
|
1. Suggest appropriate component mode (mount vs lmount)
|
|
118
135
|
2. Ensure proper mounter/updater structure
|
|
119
136
|
3. Add keys to list renderings if missing
|
|
120
137
|
|
|
121
138
|
When reviewing existing Lithent code:
|
|
139
|
+
|
|
122
140
|
1. Check for mode consistency (don't mix state/lstate)
|
|
123
141
|
2. Suggest lifecycle hooks for side effects
|
|
124
142
|
3. Recommend performance optimizations when applicable
|
|
125
143
|
|
|
126
144
|
When user requests could benefit from Lithent patterns:
|
|
145
|
+
|
|
127
146
|
1. Provide solution using Lithent idioms
|
|
128
147
|
2. Explain the closure-based component model
|
|
129
148
|
3. If user prefers different approach, respect their choice
|
|
130
149
|
|
|
131
150
|
COMMON MISTAKES TO CATCH:
|
|
151
|
+
|
|
132
152
|
- Returning JSX directly from mounter instead of returning a function
|
|
133
153
|
- Using `state` without passing `renew` parameter
|
|
134
154
|
- Using `lstate` with `mount` instead of `lmount`
|
package/dist/lithent.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=Symbol.for("lithentWDomSymbol"),M={value:""},v={value:null},g={value:!1},d=new WeakMap,I=new WeakSet;let ue=!1;const Oe=(e,t)=>{d.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},ae=()=>v.value,P=()=>d.get(v.value),Ue=(e,t)=>{const n=d.get(e);return n?n[t]:null},Be=e=>{v.value=e},Qe=(e,t)=>{v.value=e,Oe(e,t)},Ke=e=>{ue=e},je=()=>ue,ie=e=>{const t=d.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},_e=e=>{ie(e),d.delete(e)},k=e=>e.getParent&&e.getParent(),U=e=>()=>e,D=Object.keys,pe=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),fe=(e,t)=>{if(pe(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&fe(n,t)},S=e=>typeof e=="object"&&e!==null,He=e=>S(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(C),Ve=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),qe=(e,t)=>t.type==="f"&&!t.ctor&&!e.ctor&&!!t.children&&t.children.length===(e.children&&e.children.length),ze=(e,t)=>t.type==="e"&&t.tag===e.tag&&!!t.children&&t.children.length===(e.children&&e.children.length),ee=(e,t)=>t.type===e.type,Ie=(e,t)=>t.type===e.type&&(V(e)&&V(t)||!!t.children&&t.children.length===(e.children&&e.children.length)),_=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),x=e=>e==="f"||e==="l",B=e=>typeof e=="function"&&!de(e)||S(e)&&"resolve"in e,de=e=>e===j,Ge=e=>!e.type,H=e=>e[0]==="o"&&e[1]==="n",G=e=>F(_(e)),V=e=>!!e&&!!e.children&&e.children.some(G),F=e=>e!=null,te=(e,t)=>e==="style"&&S(t),Je=(e,t)=>e==="ref"&&S(t),ne=new WeakMap,ce=(e,t)=>{const n=e.constructor.prototype;let c=ne.get(n);c||ne.set(n,c=new Map);let o=c.get(t);if(o===void 0){const s=Object.getOwnPropertyDescriptor(n,t);o=!!(s&&s.get&&s.set),c.set(t,o)}return o},oe=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Xe=e=>B(e)?"c":e.type||"et",Ye={c:Ve,l:Ie,t:ee,e:ze,f:qe,et:ee},he=e=>{const t=P();t&&t.umts.push(e)},Q=e=>{const{compKey:t}=e;t&&(e.il=!0,Ze(t)),ye(e)},ye=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)H(t)&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?Q(t):ye(t)})},Ze=e=>{ie(e),je()||d.delete(e)};let q=[];const $e=e=>{e.compKey&&q.push(e)},b=()=>{q.forEach(we),q=[]},me=e=>{const t=P();t&&t.mts.push(e)},we=e=>{const{compKey:t}=e,n=t&&d.get(t);if(n){const c=n.mts;v.value=t,n.upS.value=0,n.mts=[],c.forEach(o=>{const s=o();s&&he(s)})}},We=e=>{const t=P();t&&t.wdCB.push(e)},De=e=>{const{compKey:t}=e;if(t){const n=d.get(t),c=n&&n.wdCB;v.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(o=>{const s=o();typeof s=="function"&&he(s)}))}},se=(e,t=()=>[])=>{const n=P();if(!n)return;const{upD:c,upS:o}=n,s=c[o.value],r=t();if(s&&tt(s,r)){const l=e();l&&n.upCB.push(l)}c[o.value]=r,o.value+=1},et=e=>{const{compKey:t}=e,n=t&&d.get(t);if(n){const c=n.upCB;v.value=t,n.upS.value=0,e.ctor&&(n.upCB=[],c.forEach(o=>o()))}},tt=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,ve=()=>new DocumentFragment,Ce=(e,t,n)=>n?e.insertBefore(t,n):e.tagName==="HTML"?e.replaceWith(t):e.appendChild(t),nt=e=>document.createElement(e),ct=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const o=T(e,c);return e.ae=n,(n||!c)&&Ce(t,o,n),b(),()=>{const s=d.get(e.compProps),r=s&&s.vd.value||e;Q(r),ot(r)}},ot=e=>X(e,e.we),J=e=>{const t=k(e);X(e,e.isRoot?e.we:t&&R(t))},X=(e,t)=>{if(t&&e.el){const n=e.el.nodeType;n===11||e.tag==="portal"?ke(e,t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},ke=(e,t)=>{const n=e.oc||e.children||[];if(n.length>1&&n.every(c=>{const o=c.el&&c.el.nodeType;return(o===1||o===3)&&c.el.tagName!=="HTML"&&c.tag!=="portal"})){let c=0;for(let o=t.firstChild;o&&c<=n.length;o=o.nextSibling)c++;if(c===n.length){t.textContent="",n.forEach(o=>o.el=void 0);return}}n.forEach(c=>{const o=c.el&&c.el.nodeType;if(o)if(o===1||o===3){const s=c.el;s.tagName==="HTML"?s.innerHTML="":s.remove()}else o===11&&ke(c,t)})},st=(e,t)=>{const n=R(t);e.forEach(c=>{Q(c),X(c,n)})},ge=e=>{J(e),Pe(e)},Pe=(e,t)=>{t=t||T(e);const n=k(e);if(!n||!n.type){e.isRoot&&e.we&&e.tag!=="portal"&&(Ce(e.we,t,e.ae),b());return}const c=R(n),o=Y(e,n);c&&(e.tag!=="portal"&&c.insertBefore(t,o||null),b())},Re=e=>x(e.type)?(e.children||[]).reduce((t,n)=>{const c=Re(n);return c&&t.appendChild(c),t},ve()):e.el,Y=(e,t)=>{const n=t.children||[];return L(n.slice(n.indexOf(e)+1))||(x(t.type)?t.isRoot?t.ae:Y(t,k(t)):void 0)},A=new Set,L=e=>e.reduce((t,n)=>{if(t||A.size&&A.has(n))return t;const{type:c,el:o}=n;if(c&&x(c)){const s=L(n.children||[]);if(s)return s}return o&&o.nodeType!==11?o:t},void 0),rt=e=>{const t=k(e),n=e.el;if(n&&(t?t.type:e.isRoot))if(!t||n.nodeType===11)ge(e);else{const c=R(t),o=T(e);c&&e.tag!=="portal"&&c.replaceChild(o,n),b()}},re=e=>{if(e.type==="t"){it(e);return}if(e.el){const{op:t,props:n}=e;Me(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}lt(e),et(e)},lt=e=>{const t=e.children||[];if(e.type!=="l"||!t.some(u=>"ATS".includes(u.nr)||u.oi!==void 0)){t.forEach(z);return}const n=[],c=[],o=[];let s=!0;t.forEach((u,p)=>{const y=u.oi,E=u.nr;E==="S"?o.push(u):E!=="A"&&y!==void 0&&(y<c[c.length-1]&&(s=!1),n.push(p),c.push(y))});let r;if(!s){const u=r=[];ut(c).forEach(p=>u[n[p]]=!0),n.forEach(p=>u[p]||(u[p]=!1,o.push(t[p])))}const l=[];let a=0;o.forEach(u=>A.add(u));try{t.forEach((u,p)=>{const y=u.nr;y==="A"||y==="S"?(y==="S"&&J(u),l[p]=T(u),a++):z(u)})}finally{o.forEach(u=>A.delete(u))}const i=R(e),h=e.isRoot?e.ae:Y(e,k(e));let f=t.length;for(;f>0&&l[f-1]!==void 0;)f--;for(let u=f;u<t.length;u++){const p=l[u];p&&i&&t[u].tag!=="portal"&&i.insertBefore(p,h||null)}if(r||a>t.length-f){let u=L(t.slice(f))||h;for(let p=f-1;p>=0;p--){const y=t[p],E=l[p]!==void 0,Le=!!r&&r[p]===!1;if((E||Le)&&i&&y.tag!=="portal"){const W=E?l[p]:Re(y);W&&i.insertBefore(W,u||null)}const w=L([y]);w&&(u=w)}}t.forEach(Ee),b()},Ee=e=>{e.oi=e.oc=e.op=void 0,e.nr="N"},ut=e=>{const t=[],n=[];e.forEach((s,r)=>{let l=0,a=t.length;if(a&&e[t[a-1]]<s)l=a;else for(;l<a;){const i=l+a>>1;e[t[i]]<s?l=i+1:a=i}n[r]=l?t[l-1]:-1,t[l]=r});let c=t.length,o=t[c-1];for(;c-- >0;)t[c]=o,o=n[o];return t},z=e=>{const{nr:t}=e;t&&t!=="N"&&(at[t](e),Ee(e))},at={A:Pe,D:J,R:rt,U:re,S:ge,T:re},it=e=>{e.el&&(e.el.nodeValue=String(e.text))},Me=(e,t,n)=>{const c=n||{};for(const o in e){const s=e[o];s!==c[o]&&(H(o)?le(t,o,s,c[o]):o==="key"||o==="portal"&&S(s)||(o==="innerHTML"&&typeof s=="string"?t.innerHTML=s:te(o,s)?dt(s,te(o,c.style)?c.style:{},t):Je(o,s)?s.value=t:o&&(o!=="type"&&ce(t,o)?t[o]=s:(pt(o==="className"?"class":o,t,s),oe(t)&&!(o in HTMLElement.prototype)&&(t[o]=s)))))}for(const o in c)if(!(e&&fe(e,o))){if(H(o)){le(t,o,void 0,c[o]);continue}t.removeAttribute(o),oe(t)?delete t[o]:t.localName.includes("-")&&ce(t,o)&&(t[o]=void 0)}},pt=(e,t,n)=>M.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),T=(e,t)=>{let n;const{type:c,tag:o,text:s,props:r,children:l=[]}=e,a=x(c);if(De(e),o==="svg"&&(M.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c||a)n=ve();else if(c==="e"&&o)o==="portal"&&r&&r.portal?n=r.portal:n=M.value?document.createElementNS(M.value,o):nt(o);else if(c==="t"&&F(s))n=document.createTextNode(String(s));else throw Error("Invalid wDom");e.el=n}return ft(e,l,n,t),Me(r,n,null),$e(e),o==="svg"&&(M.value=""),n},ft=(e,t,n,c)=>{const o=U(e);t.forEach((s,r)=>{if(s.nr==="N"&&!c){const l=Fe(s);s=t[r]="resolve"in l?l.resolve():l}if(s.getParent=o,s.nr="N",s.type){const l=T(s,c);s.tag!=="portal"&&!c&&n&&n.appendChild(l)}})},le=(e,t,n,c)=>{const o=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(o,c),n&&e.addEventListener(o,n))},dt=(e,t,n)=>{const c={...t};if(!(n instanceof HTMLElement))return;const o=n.style;for(const s in e)o[s]=e[s],delete c[s];for(const s in c)o[s]=""},R=e=>x(e.type)?e.isRoot?e.we:R(k(e)):e.el,K=(e,t)=>(e!==t&&e.nr&&(e=Fe(e)),ht(e,!!t&&Ye[Xe(e)](e,t),t)),ht=(e,t,n)=>{const c=gt(e,t,n),o=vt(c,t,n),s=o==="N";return s||(c.children=Pt(c,t,n)),c.nr=o,yt(c,n,o),!s&&n&&(n.il=!0,n.ctor&&(n.children=void 0)),n&&n.tag==="portal"&&(c.tag="portal"),c},yt=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&Q(t),e.oc=t&&t.children),e.op=t&&t.props},vt=(e,t,n)=>{if(Ge(e))return"D";if(e===n||t&&e.type==="t"&&e.text===n.text)return"N";if(!(n&&n.type))return"A";const c=k(n),o=!e.isRoot&&c&&c.type==="l"&&G(e);return t?o?"T":"U":o?"S":"R"},Ct=(e,t)=>{e&&t!==e&&(t=t||{},D(e).forEach(n=>pe(t,n)||delete e[n]),D(t).forEach(n=>e[n]=t[n]))},kt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:o,children:s}=t;return n&&Ct(n,o),c&&s&&c!==s&&c.splice(0,c.length,...s),e.reRender&&e.reRender()},gt=(e,t,n)=>B(e)?t&&n?kt(n,e):(e.rd?$(e):(e.rd=!0,e)).resolve():e,Pt=(e,t,n)=>t&&n?Et(e,n):Rt(e),Rt=e=>{const t=U(e);return(e.children||[]).map(n=>{const c=K(n);return c.getParent=t,c})},Et=(e,t)=>{if(e.type==="l"&&V(e))return Mt(e,t);const n=t.children||[],c=U(e);return(e.children||[]).map((o,s)=>{const r=K(o,n[s]);return r.getParent=c,r})},Mt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,a)=>{const i=_(l);F(i)&&!c.has(i)&&c.set(i,a)});const o=[],s=U(e),r=(e.children||[]).map((l,a)=>{const i=_(l),h=F(i)?c.get(i):a<n.length&&!G(n[a])?a:void 0;let f;h!==void 0&&(c.delete(i),o[h]=!0,f=n[h]);const u=K(l,f);return f&&(u.oi=h),u.getParent=s,u});return st(n.filter((l,a)=>!o[a]),t),r},N=new Map;let O=!1;const bt=(e,t)=>{N.set(e,t),O||(O=!0,queueMicrotask(be))},St=(e,t)=>{const n=d.get(e);n&&(n.up=()=>{const c=n.vd.value;bt(e,()=>t(c))})},Z=e=>()=>{const t=d.get(e),n=t&&t.up;return n?(n(),!0):!1},be=()=>{try{N.forEach((e,t)=>{N.delete(t),e()})}finally{O=!!N.size,O&&queueMicrotask(be)}},xt=(e,t=()=>[])=>{const n=P();n&&(n.upR.push(()=>se(e,t)),se(e,t))},Tt=()=>{const e=P(),t=e&&e.upR;t&&t.length&&t.forEach(n=>n())},j=(e,...t)=>({type:"f",nr:void 0,[C]:!0,children:t}),Se=(e,t,...n)=>{const c={value:void 0},o=Te(c,n),s=Ot(e,t||{},o);return B(s)||(c.value=s),s},Nt=(e,t)=>Se("portal",{portal:t},e),Ft=e=>(t,n)=>e,At=e=>(t,n)=>(I.add(e),e),Lt=(e,t,n)=>{const c=(o,s)=>{if(!(!o||s.has(o))){if(s.add(o),o.compChild){const r=o.compChild.indexOf(t);r!==-1&&o.compChild.splice(r,1,n)}c(o.getParent?o.getParent():void 0,s)}};c(e,new Set)},xe=(e,t,n,c)=>{if(c.il)return;g.value=!0;let o;try{const s=m(e,t,n);o=K(s,c);const{isRoot:r,getParent:l,we:a,ae:i}=c;if(o.getParent=l,!r&&l){const h=l(),f=h&&h.children||[],u=f.indexOf(c);u!==-1&&f.splice(u,1,o),Lt(h,c,o)}else o.isRoot=!0,o.we=a,o.ae=i}finally{g.value=!1}z(o)},Ot=(e,t,n)=>{if(de(e))return j(t,...n);if(B(e)){const c=m(e,t,n);if(g.value)return c;const o=$(c).resolve();return o.rs=c,o}return{type:"e",nr:void 0,[C]:!0,tag:e,props:t,children:n}},Te=(e,t)=>{const n=()=>e.value;return t.map(c=>{const o=Ne(c);return o.getParent=n,o})},Ne=e=>{if(e==null||typeof e=="boolean")return{type:null,nr:void 0,[C]:!0};if(Array.isArray(e)){const t={value:void 0},n=Te(t,e),c={type:"l",nr:void 0,[C]:!0,children:n};return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return{type:"t",nr:void 0,[C]:!0,text:e};return e},Ut=(e,t,n)=>(c=t)=>{const o=g.value,s=v.value;g.value=!1;try{Qe(c,e);const r=e(t,n);let l;if(typeof r=="function"){const a=r;l=I.has(a)?a(t,n):a(Z(c),t,n)}else{let a=!0;l=i=>a?(a=!1,r):e(i,n)}return Bt(l,c,e,t,n)}finally{v.value=s,g.value=o}},Fe=e=>e.ctor?$(e.rs||{ctor:e.ctor,props:e.compProps,children:e.compChild}):{type:e.type,tag:e.tag,props:e.props,text:e.text,children:e.children&&[...e.children],getParent:e.getParent,[C]:!0},$=({ctor:e,props:t,children:n})=>m(e,{...t},[...n||[]]),m=(e,t,n)=>({ctor:e,props:t,children:n,resolve:Ut(e,t,n)}),Bt=(e,t,n,c,o)=>{const s=Kt(e),r=s(c),l=Qt(s,t,n,c,o);return Ae(r,t,n,c,o,l),St(t,a=>xe(n,a.compProps||c,a.compChild||o,a)),r},Qt=(e,t,n,c,o)=>{const s=()=>{const r=v.value;try{Be(t),Tt();const l=e(c);return Ae(l,t,n,c,o,s),l}finally{v.value=r}};return s},Kt=e=>t=>{const n=Ne(e(t)),c=j({},n);return n.getParent=()=>c,c},Ae=(e,t,n,c,o,s)=>{e.compProps=c,e.compChild=o,e.ctor=n,e.compKey=t,e.reRender=s;const r=d.get(t);r&&(r.vd.value=e)},jt=e=>({value:e}),_t=()=>Promise.resolve(),Ht=()=>{const e=ae();return e?Z(e):()=>!1};exports.Fragment=j;exports.componentMap=d;exports.componentUpdate=Z;exports.disposeComponentEntry=_e;exports.getComponentKey=ae;exports.getComponentSubInfo=Ue;exports.h=Se;exports.isPropType=He;exports.lmount=At;exports.lmountComponentSet=I;exports.mount=Ft;exports.mountCallback=me;exports.mountReadyCallback=We;exports.nextTick=_t;exports.portal=Nt;exports.ref=jt;exports.render=ct;exports.replaceWDom=xe;exports.setComponentMapManualMode=Ke;exports.updateCallback=xt;exports.useRenew=Ht;
|
|
1
|
+
"use strict";const ae=Symbol.for("lithentWDomSymbol"),S={value:""},v={value:null},k={value:!1},p=new WeakMap,J=new WeakSet;let fe=!1;const Be=(e,t)=>{p.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},de=()=>v.value,E=()=>p.get(v.value),Qe=(e,t)=>{const n=p.get(e);return n?n[t]:null},Ke=e=>{v.value=e},je=(e,t)=>{v.value=e,Be(e,t)},_e=e=>{fe=e},He=()=>fe,pe=e=>{const t=p.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ve=e=>{pe(e),p.delete(e)},C=e=>e.getParent&&e.getParent(),B=e=>()=>e,te=Object.keys,he=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),ye=(e,t)=>{if(he(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&ye(n,t)},x=e=>typeof e=="object"&&e!==null,qe=e=>x(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(ae),ze=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Ge=(e,t)=>t.type==="f"&&!t.ctor&&!e.ctor&&!!t.children&&t.children.length===(e.children&&e.children.length),Ie=(e,t)=>t.type==="e"&&t.tag===e.tag&&!!t.children&&t.children.length===(e.children&&e.children.length),ne=(e,t)=>t.type===e.type,Je=(e,t)=>t.type===e.type&&(q(e)&&q(t)||!!t.children&&t.children.length===(e.children&&e.children.length)),H=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),T=e=>e==="f"||e==="l",Q=e=>typeof e=="function"&&!ve(e)||x(e)&&"resolve"in e,ve=e=>e===_,Xe=e=>!e.type,R=({el:e,op:t,props:n})=>!!e&&(e===(t&&t.portal)||e===(n&&n.portal)),V=e=>e[0]==="o"&&e[1]==="n",X=e=>A(H(e)),q=e=>!!e&&!!e.children&&e.children.some(X),A=e=>e!=null,ce=(e,t)=>e==="style"&&x(t),Ye=(e,t)=>e==="ref"&&x(t),oe=new WeakMap,se=(e,t)=>{const n=e.constructor.prototype;let c=oe.get(n);c||oe.set(n,c=new Map);let o=c.get(t);if(o===void 0){const s=Object.getOwnPropertyDescriptor(n,t);o=!!(s&&s.get&&s.set),c.set(t,o)}return o},re=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Ze=e=>Q(e)?"c":e.type||"et",$e={c:ze,l:Je,t:ne,e:Ie,f:Ge,et:ne},Ce=e=>{const t=E();t&&t.umts.push(e)},K=e=>{const{compKey:t}=e;t&&(e.il=!0,me(t)),ke(e)},ke=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)V(t)&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?K(t):ke(t)})},me=e=>{pe(e),He()||p.delete(e)};let z=[];const we=e=>{e.compKey&&z.push(e)},b=()=>{z.forEach(De),z=[]},We=e=>{const t=E();t&&t.mts.push(e)},De=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.mts;v.value=t,n.upS.value=0,n.mts=[],c.forEach(o=>{const s=o();s&&Ce(s)})}},et=e=>{const t=E();t&&t.wdCB.push(e)},tt=e=>{const{compKey:t}=e;if(t){const n=p.get(t),c=n&&n.wdCB;v.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(o=>{const s=o();typeof s=="function"&&Ce(s)}))}},le=(e,t=()=>[])=>{const n=E();if(!n)return;const{upD:c,upS:o}=n,s=c[o.value],r=t();if(s&&ct(s,r)){const l=e();l&&n.upCB.push(l)}c[o.value]=r,o.value+=1},nt=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.upCB;v.value=t,n.upS.value=0,e.ctor&&(n.upCB=[],c.forEach(o=>o()))}},ct=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,Pe=()=>new DocumentFragment,Re=(e,t,n)=>n?e.insertBefore(t,n):e.tagName==="HTML"?e.replaceWith(t):e.appendChild(t),ot=e=>document.createElement(e),st=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const o=N(e,c);return e.ae=n,(n||!c)&&Re(t,o,n),b(),()=>{const s=p.get(e.compProps),r=s&&s.vd.value||e;K(r),rt(r)}},rt=e=>Z(e,e.we),Y=e=>{const t=C(e);Z(e,e.isRoot?e.we:t&&g(t))},Z=(e,t)=>{if(t&&e.el){const n=e.el.nodeType,c=R(e);n===11||c?G(e,c?e.el:t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},G=(e,t)=>{const n=e.oc||e.children||[];if(n.length>1){let c=t.firstChild;const o=s=>{const r=s.el;if(!r||R(s))return!r;if(r.nodeType===11)return(s.oc||s.children||[]).every(o);const l=r===c&&r.tagName!=="HTML";return c=r.nextSibling,l};if(n.every(o)&&!c){t.textContent="",n.forEach(s=>s.el=void 0);return}}n.forEach(c=>{const o=c.el&&c.el.nodeType;if(R(c))G(c,c.el);else if(o===1||o===3){const s=c.el;s.tagName==="HTML"?s.innerHTML="":s.remove()}else o===11&&G(c,t)})},lt=(e,t)=>{const n=g(t);e.forEach(c=>{K(c),Z(c,n)})},Ee=e=>{Y(e),ge(e)},ge=(e,t)=>{t=t||N(e);const n=C(e);if(!n||!n.type){e.isRoot&&e.we&&e.tag!=="portal"&&(Re(e.we,t,e.ae),b());return}const c=g(n),o=$(e,n);c&&(e.tag!=="portal"&&c.insertBefore(t,o||null),b())},Me=e=>T(e.type)?(e.children||[]).reduce((t,n)=>{const c=Me(n);return c&&!R(n)&&t.appendChild(c),t},Pe()):e.el,$=(e,t)=>{const n=t.children||[];return U(n.slice(n.indexOf(e)+1))||(T(t.type)?t.isRoot?t.ae:$(t,C(t)):void 0)},L=new Set,U=e=>e.reduce((t,n)=>{if(t||R(n)||L.size&&L.has(n))return t;const{type:c,el:o}=n;if(c&&T(c)){const s=U(n.children||[]);if(s)return s}return o&&o.nodeType!==11?o:t},void 0),ut=e=>{const t=C(e),n=e.el;if(n&&(t?t.type:e.isRoot))if(!t||n.nodeType===11||R(e)||e.tag==="portal")Ee(e);else{const c=g(t),o=N(e);c&&c.replaceChild(o,n),b()}},ue=e=>{if(e.type==="t"){dt(e);return}if(e.el){const{op:t,props:n}=e;be(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}it(e),nt(e)},it=e=>{const t=e.children||[];if(e.type!=="l"||!t.some(u=>"ATS".includes(u.nr)||u.oi!==void 0)){t.forEach(I);return}const n=[],c=[],o=[];let s=!0;t.forEach((u,f)=>{const y=u.oi,M=u.nr;M==="S"?o.push(u):M!=="A"&&y!==void 0&&(y<c[c.length-1]&&(s=!1),n.push(f),c.push(y))});let r;if(!s){const u=r=[];at(c).forEach(f=>u[n[f]]=!0),n.forEach(f=>u[f]||(u[f]=!1,o.push(t[f])))}const l=[];let i=0;o.forEach(u=>L.add(u));try{t.forEach((u,f)=>{const y=u.nr;y==="A"||y==="S"?(y==="S"&&Y(u),l[f]=N(u),i++):I(u)})}finally{o.forEach(u=>L.delete(u))}const a=g(e),h=e.isRoot?e.ae:$(e,C(e));let d=t.length;for(;d>0&&l[d-1]!==void 0;)d--;for(let u=d;u<t.length;u++){const f=l[u];f&&a&&t[u].tag!=="portal"&&a.insertBefore(f,h||null)}if(r||i>t.length-d){let u=U(t.slice(d))||h;for(let f=d-1;f>=0;f--){const y=t[f],M=l[f]!==void 0,Oe=!!r&&r[f]===!1;if((M||Oe)&&a&&y.tag!=="portal"){const ee=M?l[f]:Me(y);ee&&a.insertBefore(ee,u||null)}const D=U([y]);D&&(u=D)}}t.forEach(Se),b()},Se=e=>{e.oi=e.oc=e.op=void 0,e.nr="N"},at=e=>{const t=[],n=[];e.forEach((s,r)=>{let l=0,i=t.length;if(i&&e[t[i-1]]<s)l=i;else for(;l<i;){const a=l+i>>1;e[t[a]]<s?l=a+1:i=a}n[r]=l?t[l-1]:-1,t[l]=r});let c=t.length,o=t[c-1];for(;c-- >0;)t[c]=o,o=n[o];return t},I=e=>{const{nr:t}=e;t&&t!=="N"&&(ft[t](e),Se(e))},ft={A:ge,D:Y,R:ut,U:ue,S:Ee,T:ue},dt=e=>{e.el&&(e.el.nodeValue=String(e.text))},be=(e,t,n)=>{const c=n||{};for(const o in e){const s=e[o];s!==c[o]&&(V(o)?ie(t,o,s,c[o]):o==="key"||o==="portal"&&x(s)||(o==="innerHTML"&&typeof s=="string"?t.innerHTML=s:ce(o,s)?yt(s,ce(o,c.style)?c.style:{},t):Ye(o,s)?s.value=t:o&&(o!=="type"&&se(t,o)?t[o]=s:(pt(o==="className"?"class":o,t,s),re(t)&&!(o in HTMLElement.prototype)&&(t[o]=s)))))}for(const o in c)if(!(e&&ye(e,o))){if(V(o)){ie(t,o,void 0,c[o]);continue}t.removeAttribute(o),re(t)?delete t[o]:t.localName.includes("-")&&se(t,o)&&(t[o]=void 0)}},pt=(e,t,n)=>S.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),N=(e,t)=>{let n;const{type:c,tag:o,text:s,props:r,children:l=[]}=e,i=T(c);if(tt(e),o==="svg"&&(S.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c||i)n=Pe();else if(c==="e"&&o)o==="portal"&&r&&r.portal?n=r.portal:n=S.value?document.createElementNS(S.value,o):ot(o);else if(c==="t"&&A(s))n=document.createTextNode(String(s));else throw Error("Invalid wDom");e.el=n}return ht(e,l,n,t),be(r,n,null),we(e),o==="svg"&&(S.value=""),n},ht=(e,t,n,c)=>{const o=B(e);t.forEach((s,r)=>{if(s.nr==="N"&&!c){const l=Le(s);s=t[r]="resolve"in l?l.resolve():l}if(s.getParent=o,s.nr="N",s.type){const l=N(s,c);s.tag!=="portal"&&!c&&n&&n.appendChild(l)}})},ie=(e,t,n,c)=>{const o=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(o,c),n&&e.addEventListener(o,n))},yt=(e,t,n)=>{const c={...t};if(!(n instanceof HTMLElement))return;const o=n.style;for(const s in e)o[s]=e[s],delete c[s];for(const s in c)o[s]=""},g=e=>T(e.type)?e.isRoot?e.we:g(C(e)):e.el,j=(e,t)=>(e!==t&&e.nr&&(e=Le(e)),vt(e,!!t&&$e[Ze(e)](e,t),t)),vt=(e,t,n)=>{const c=Et(e,t,n),o=kt(c,t,n),s=o==="N";return s||(c.children=gt(c,t,n)),c.nr=o,Ct(c,n,o),!s&&n&&(n.il=!0,n.ctor&&(n.children=void 0)),c},Ct=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&K(t),e.oc=t&&t.children),e.op=t&&t.props},kt=(e,t,n)=>{if(Xe(e))return"D";if(e===n||t&&e.type==="t"&&e.text===n.text)return"N";if(!(n&&n.type))return"A";const c=C(n),o=!e.isRoot&&c&&c.type==="l"&&X(e);return t?o?"T":"U":o?"S":"R"},Pt=(e,t)=>{e&&t!==e&&(t=t||{},te(e).forEach(n=>he(t,n)||delete e[n]),te(t).forEach(n=>e[n]=t[n]))},Rt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:o,children:s}=t;return n&&Pt(n,o),c&&s&&c!==s&&c.splice(0,c.length,...s),e.reRender&&e.reRender()},Et=(e,t,n)=>Q(e)?t&&n?Rt(n,e):(e.rd?w(e):(e.rd=!0,e)).resolve():e,gt=(e,t,n)=>t&&n?St(e,n):Mt(e),Mt=e=>{const t=B(e);return(e.children||[]).map(n=>{const c=j(n);return c.getParent=t,c})},St=(e,t)=>{if(e.type==="l"&&q(e))return bt(e,t);const n=t.children||[],c=B(e);return(e.children||[]).map((o,s)=>{const r=j(o,n[s]);return r.getParent=c,r})},bt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,i)=>{const a=H(l);A(a)&&!c.has(a)&&c.set(a,i)});const o=[],s=B(e),r=(e.children||[]).map((l,i)=>{const a=H(l),h=A(a)?c.get(a):i<n.length&&!X(n[i])?i:void 0;let d;h!==void 0&&(c.delete(a),o[h]=!0,d=n[h]);const u=j(l,d);return d&&(u.oi=h),u.getParent=s,u});return lt(n.filter((l,i)=>!o[i]),t),r},F=new Map;let O=!1;const xt=(e,t)=>{F.set(e,t),O||(O=!0,queueMicrotask(xe))},Tt=(e,t)=>{const n=p.get(e);n&&(n.up=()=>{const c=n.vd.value;xt(e,()=>t(c))})},m=e=>()=>{const t=p.get(e),n=t&&t.up;return n?(n(),!0):!1},xe=()=>{try{F.forEach((e,t)=>{F.delete(t),e()})}finally{O=!!F.size,O&&queueMicrotask(xe)}},P=(e,t,n,c,o,s)=>({type:e,nr:void 0,tag:t,props:n,text:c,children:o,getParent:s,el:void 0,oi:void 0,oc:void 0,op:void 0,il:void 0,[ae]:!0}),Nt=(e,t=()=>[])=>{const n=E();n&&(n.upR.push(()=>le(e,t)),le(e,t))},Ft=()=>{const e=E(),t=e&&e.upR;t&&t.length&&t.forEach(n=>n())},_=(e,...t)=>P("f",void 0,void 0,void 0,t),Te=(e,t,...n)=>{const c={value:void 0},o=Fe(c,n),s=Bt(e,t||{},o);return Q(s)||(c.value=s),s},At=(e,t)=>Te("portal",{portal:t},e),Lt=e=>(t,n)=>e,Ut=e=>(t,n)=>(J.add(e),e),Ot=(e,t,n)=>{const c=(o,s)=>{if(!(!o||s.has(o))){if(s.add(o),o.compChild){const r=o.compChild.indexOf(t);r!==-1&&o.compChild.splice(r,1,n)}c(o.getParent?o.getParent():void 0,s)}};c(e,new Set)},Ne=(e,t,n,c)=>{if(c.il)return;k.value=!0;let o;try{const s=W(e,t,n);o=j(s,c);const{isRoot:r,getParent:l,we:i,ae:a}=c;if(o.getParent=l,!r&&l){const h=l(),d=h&&h.children||[],u=d.indexOf(c);u!==-1&&d.splice(u,1,o),Ot(h,c,o)}else o.isRoot=!0,o.we=i,o.ae=a}finally{k.value=!1}I(o)},Bt=(e,t,n)=>{if(ve(e))return _(t,...n);if(Q(e)){const c=W(e,t,n);if(k.value)return c;const o=w(c).resolve();return o.rs=c,o}return P("e",e,t,void 0,n)},Fe=(e,t)=>{const n=()=>e.value;return t.map(c=>{const o=Ae(c);return o.getParent=n,o})},Ae=e=>{if(e==null||typeof e=="boolean")return P(null);if(Array.isArray(e)){const t={value:void 0},n=Fe(t,e),c=P("l",void 0,void 0,void 0,n);return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return P("t",void 0,void 0,e);return e},Qt=(e,t,n)=>(c=t)=>{const o=k.value,s=v.value;k.value=!1;try{je(c,e);const r=e(t,n);let l;if(typeof r=="function"){const i=r;l=J.has(i)?i(t,n):i(m(c),t,n)}else{let i=!0;l=a=>i?(i=!1,r):e(a,n)}return Kt(l,c,e,t,n)}finally{v.value=s,k.value=o}},Le=e=>e.ctor?w(e.rs||{ctor:e.ctor,props:e.compProps,children:e.compChild}):P(e.type,e.tag,e.props,e.text,e.children&&[...e.children],e.getParent),w=({ctor:e,props:t,children:n})=>W(e,{...t},[...n||[]]),W=(e,t,n)=>({ctor:e,props:t,children:n,resolve:Qt(e,t,n)}),Kt=(e,t,n,c,o)=>{const s=_t(e),r=s(c),l=jt(s,t,n,c,o);return Ue(r,t,n,c,o,l),Tt(t,i=>Ne(n,i.compProps||c,i.compChild||o,i)),r},jt=(e,t,n,c,o)=>{const s=()=>{const r=v.value;try{Ke(t),Ft();const l=e(c);return Ue(l,t,n,c,o,s),l}finally{v.value=r}};return s},_t=e=>t=>{const n=Ae(e(t)),c=_({},n);return n.getParent=()=>c,c},Ue=(e,t,n,c,o,s)=>{e.compProps=c,e.compChild=o,e.ctor=n,e.compKey=t,e.reRender=s;const r=p.get(t);r&&(r.vd.value=e)},Ht=e=>({value:e}),Vt=()=>Promise.resolve(),qt=()=>{const e=de();return e?m(e):()=>!1};exports.Fragment=_;exports.componentMap=p;exports.componentUpdate=m;exports.disposeComponentEntry=Ve;exports.getComponentKey=de;exports.getComponentSubInfo=Qe;exports.h=Te;exports.isPropType=qe;exports.lmount=Ut;exports.lmountComponentSet=J;exports.mount=Lt;exports.mountCallback=We;exports.mountReadyCallback=et;exports.nextTick=Vt;exports.portal=At;exports.ref=Ht;exports.render=st;exports.replaceWDom=Ne;exports.setComponentMapManualMode=_e;exports.updateCallback=Nt;exports.useRenew=qt;
|
|
2
2
|
//# sourceMappingURL=lithent.cjs.map
|