lithent 1.20.2 → 1.21.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.
- package/README.md +83 -224
- package/devHelper/dist/lithentDevHelper.mjs +48 -31
- package/devHelper/dist/lithentDevHelper.mjs.map +1 -1
- package/devHelper/dist/lithentDevHelper.umd.js +1 -1
- package/devHelper/dist/lithentDevHelper.umd.js.map +1 -1
- package/devHelper/src/createBoundary.ts +44 -4
- package/devHelper/src/tests/createBoundaryRetry.test.ts +52 -0
- package/devHelper/src/tests/hmrBoundary.tsx +1 -1
- package/dist/hook/useRenew.d.ts +6 -0
- package/dist/index.d.ts +4 -3
- package/dist/lithent.mjs +363 -308
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/types/index.d.ts +9 -10
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/predicator.d.ts +1 -0
- package/dist/utils/universalRef.d.ts +1 -0
- package/dist/wDom.d.ts +6 -3
- package/examples/dist/assets/index-C8ubEFcX.js +2 -0
- package/examples/dist/assets/index-C8ubEFcX.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/ftags/dist/index.d.ts +7 -3
- package/ftags/dist/lithentFTags.mjs +19 -12
- package/ftags/dist/lithentFTags.mjs.map +1 -1
- package/ftags/dist/lithentFTags.umd.js +1 -1
- package/ftags/dist/lithentFTags.umd.js.map +1 -1
- package/ftags/src/index.ts +26 -1
- package/ftags/src/tests/ftags.ts +36 -1
- package/helper/dist/hook/context.d.ts +8 -1
- package/helper/dist/hook/lcontext.d.ts +18 -0
- package/helper/dist/hook/lstate.d.ts +5 -0
- package/helper/dist/hook/lstore.d.ts +28 -0
- package/helper/dist/index.d.ts +4 -0
- package/helper/dist/lithentHelper.mjs +297 -129
- package/helper/dist/lithentHelper.mjs.map +1 -1
- package/helper/dist/lithentHelper.umd.js +1 -1
- package/helper/dist/lithentHelper.umd.js.map +1 -1
- package/helper/src/hook/context.tsx +4 -4
- package/helper/src/hook/lcontext.tsx +197 -0
- package/helper/src/hook/lstate.ts +28 -0
- package/helper/src/hook/lstore.ts +243 -0
- package/helper/src/index.ts +8 -0
- package/helper/src/tests/lcontext.tsx +316 -0
- package/helper/src/tests/lstore.tsx +198 -0
- package/helper/src/tests/state.tsx +88 -0
- package/jsx-runtime/dist/index.d.ts +0 -1
- package/jsx-runtime/package.json +1 -1
- package/package.json +3 -2
- package/src/diff.ts +24 -13
- package/src/hook/internal/useUpdate.ts +2 -2
- package/src/hook/mountCallback.ts +5 -3
- package/src/hook/useRenew.ts +17 -0
- package/src/index.ts +4 -1
- package/src/render.ts +67 -68
- package/src/tests/core-component-remount.test.tsx +35 -0
- package/src/tests/core-composedRenew.test.tsx +62 -0
- package/src/tests/core-functional-vdom.test.tsx +47 -0
- package/src/tests/core-lmount.tsx +101 -0
- package/src/tests/core-loopDomReuseWithoutKey.tsx +68 -0
- package/src/tests/loopWithoutKey.tsx +49 -0
- package/src/types/index.ts +17 -12
- package/src/utils/index.ts +5 -1
- package/src/utils/predicator.ts +10 -7
- package/src/utils/redraw.ts +3 -2
- package/src/utils/universalRef.ts +1 -0
- package/src/wDom.ts +84 -20
- package/ssr/package.json +1 -1
- package/tag/dist/index.d.ts +0 -2
- package/examples/dist/assets/index-Ch3C2eh3.js +0 -2
- package/examples/dist/assets/index-Ch3C2eh3.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,278 +1,137 @@
|
|
|
1
|
+
<img src="./lithentDocs/public/lithent.png" alt="Lithent" height="60" align="left" style="margin-right: 10px;" />
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
> An extensible JSX-based virtual DOM library for lightweight use in a variety of environments.
|
|
3
|
+
# Lithent [](https://www.npmjs.com/package/lithent) [](https://bundlephobia.com/package/lithent) [](LICENSE) [](https://www.typescriptlang.org/)
|
|
4
4
|
|
|
5
|
+
<br clear="left"/>
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
**Lithent is a JavaScript library for building lightweight, predictable UIs with familiar closure-based patterns.**
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
9
|
+
It trims away unnecessary magic and complex APIs so your UI code stays simple, explicit, and easy to reason about.
|
|
12
10
|
|
|
11
|
+
<br />
|
|
13
12
|
|
|
13
|
+
<div align="left">
|
|
14
14
|
|
|
15
|
+
### 🚀 [Get Started](https://superlucky84.github.io/lithent/#/guide/quick-start) · 📖 [Documentation](https://superlucky84.github.io/lithent/#/) · 💡 [Examples](https://superlucky84.github.io/lithent/#/examples/1)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
- [Korean Manual](https://medium.com/@superlucky84/lithent-전체-기능-설명서-3cfab04c0722)
|
|
18
|
-
- [Home Page](https://superlucky84.github.io/lithent) - (This page is written in lithent.)
|
|
17
|
+
</div>
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
fragments into pages already drawn with SSR, and are intended to be
|
|
22
|
-
used lightly in a variety of situations.
|
|
19
|
+
<br />
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
`(lithent.umd.js 10.39 kB │ gzip: 4.03 kB │ map: 58.16 kB)`
|
|
21
|
+
## Why Lithent?
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
- [Thanks for the introduction](#thanks-for-the-introduction)
|
|
29
|
-
- [Why Use Lithent](#why-use-lithent)
|
|
30
|
-
- [Basic Guide](#basic-guide)
|
|
31
|
-
- [Lithent Ssr Boilerplate](#lithent-ssr-boilerplate)
|
|
32
|
-
- [How To Install](#how-to-install)
|
|
33
|
-
- [Use NPM](#use-npm)
|
|
34
|
-
- [Use CDN](#or-use-cdn)
|
|
35
|
-
- [With JSX](#with-jsx)
|
|
36
|
-
- [With FTAGS](#with-ftags)
|
|
37
|
-
- [With HTM](#with-htm)
|
|
38
|
-
- [Examples](#examples)
|
|
39
|
-
- [With ESM](#with-esm)
|
|
40
|
-
- [With UMD](#with-umd)
|
|
41
|
-
- [Related Projects](#related-projects)
|
|
42
|
-
- [Develop Guide](#develop-guide)
|
|
43
|
-
- [Test](#test)
|
|
23
|
+
**Lightweight DOM manipulation without the framework weight.** The 4KB core drives complete UIs. Need state management? Opt into helpers like expansion packs instead of adopting a full stack.
|
|
44
24
|
|
|
45
|
-
|
|
46
|
-
- [unsuckjs](https://unsuckjs.com/)
|
|
47
|
-
- [jster](https://jster.net/blog/jster-198/)
|
|
48
|
-
- [webtoolsweekly](https://webtoolsweekly.com/archives/issue-531/)
|
|
25
|
+
Bring in only what you need — let the stack scale with your project.
|
|
49
26
|
|
|
50
|
-
|
|
27
|
+
**Design philosophy:**
|
|
28
|
+
- **Small Bundle** — 4KB core with optional extensions
|
|
29
|
+
- **Closure-based State** — No magic, just JavaScript
|
|
30
|
+
- **Manual or Reactive** — Choose your update strategy
|
|
31
|
+
- **Progressive Enhancement** — From static HTML to full SPA
|
|
51
32
|
|
|
52
|
-
|
|
33
|
+
<br />
|
|
53
34
|
|
|
54
|
-
|
|
35
|
+
## Quick start
|
|
55
36
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"Lithent" has implemented the bare minimum functionality needed to create and update virtual DOM in general (we only need to know 'render', 'mounter', 'updater', 'renewer', 'mountCallback', and 'updateCallback').
|
|
59
|
-
|
|
60
|
-
We provide code in the form of 'helpers' that extend the basic functionality, but using the helpers is only optional and users can extend and develop custom helpers for their own projects.
|
|
61
|
-
|
|
62
|
-
### Approach with the developer-friendly concept of closures between "component mounter" and "renderer"
|
|
63
|
-
|
|
64
|
-
JavaScript users are used to using closures and love to develop with them.
|
|
65
|
-
|
|
66
|
-
"Lithent" provides a familiar approach to my JavaScript development, as it leverages the properties of higher-order functions and closures to define and recycle the state of a component.
|
|
67
|
-
|
|
68
|
-
## Basic Guide
|
|
69
|
-
|
|
70
|
-
- https://superlucky84.github.io/lithent/
|
|
71
|
-
|
|
72
|
-
## Lithent Ssr Boilerplate
|
|
73
|
-
|
|
74
|
-
`Lithent-Ssr-Boilerplate` is a boilerplate designed for building server-side rendering (SSR) websites using the [Lithent](https://superlucky84.github.io/lithent/) UI library.
|
|
75
|
-
|
|
76
|
-
* [README](https://github.com/superlucky84/lithent/tree/master/createLithent#readme)
|
|
37
|
+
### Create a new project
|
|
77
38
|
|
|
78
39
|
```bash
|
|
79
|
-
npx create-lithent
|
|
40
|
+
npx create-lithent@latest
|
|
80
41
|
```
|
|
81
42
|
|
|
43
|
+
Pick a project name and template (SSR/SPA) and you’re ready to go.
|
|
82
44
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#### Use NPM
|
|
45
|
+
### Install via npm
|
|
86
46
|
|
|
87
47
|
```bash
|
|
88
|
-
|
|
48
|
+
npm install lithent
|
|
89
49
|
```
|
|
90
50
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js
|
|
94
|
-
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js
|
|
95
|
-
* UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js
|
|
96
|
-
* UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.umd.js
|
|
97
|
-
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.mjs
|
|
98
|
-
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.mjs
|
|
99
|
-
* ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.mjs
|
|
100
|
-
* ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.mjs
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
It's easier to use lithent with JSX or HTM.
|
|
104
|
-
|
|
105
|
-
#### With JSX
|
|
106
|
-
|
|
107
|
-
* Lithent is built on top of JSX.
|
|
108
|
-
* [Setting Guide](https://superlucky84.github.io/lithent/#install)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
#### With FTAGS
|
|
112
|
-
|
|
113
|
-
You don't need to use h functions or JSX, you can call functions to mark them up.
|
|
114
|
-
When creating a component, use `fMount` instead of `mount`.
|
|
115
|
-
When creating a fragment, use `fFragment` instead of `Fragment`.
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
/* ESM */
|
|
119
|
-
import { render, h } from 'lithent';
|
|
120
|
-
import { fTags, fFragment, fMount } from 'lithent/ftags';
|
|
121
|
-
|
|
122
|
-
const { section, div, p, br, strong } = fTags;
|
|
123
|
-
|
|
124
|
-
/* UMD
|
|
125
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js"></script>
|
|
126
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js"></script>
|
|
127
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js"></script>
|
|
128
|
-
|
|
129
|
-
const { render } = lithent;
|
|
130
|
-
const { fTags, fMount, fFragment } = lithentFTags;
|
|
131
|
-
const { section, div, p, br, strong } = fTags;
|
|
132
|
-
*/
|
|
51
|
+
### Use directly from a CDN
|
|
133
52
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'first inner',
|
|
138
|
-
div({ style: { border: '1px solid red' } }, 'second inner'),
|
|
139
|
-
div('The props argument can be omitted.'),
|
|
140
|
-
props.firstProp,
|
|
141
|
-
...children
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
render(
|
|
146
|
-
fTagComponent(
|
|
147
|
-
{ firstProp: 3 }, // The props argument can be omitted.
|
|
148
|
-
div({ style: { border: '1px solid green' } }, `Fchildren1`),
|
|
149
|
-
'Fchildren2',
|
|
150
|
-
br()
|
|
151
|
-
),
|
|
152
|
-
document.getElementById('root')
|
|
153
|
-
);
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
#### With HTM
|
|
157
|
-
|
|
158
|
-
- [Htm Github](https://github.com/developit/htm)
|
|
159
|
-
|
|
160
|
-
```js
|
|
161
|
-
import { lTag } from 'lithent/tag';
|
|
162
|
-
const destroy = render(lTag`<${Component} />`, document.getElementById('root'), document.getElementById('#insert-before-this-element'));
|
|
53
|
+
```html
|
|
54
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent/dist/lithent.umd.js"></script>
|
|
55
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent/ftags/dist/lithentFTags.umd.js"></script>
|
|
163
56
|
```
|
|
164
57
|
|
|
58
|
+
> **[📦 View all available CDN URLs](https://superlucky84.github.io/lithent/#/guide/quick-start)**
|
|
165
59
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- [More Examples](https://superlucky84.github.io/lithent/#examples)
|
|
60
|
+
<br />
|
|
169
61
|
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
import { h, render, mount, Fragment } from 'lithent';
|
|
173
|
-
import { lTag } from 'lithent/tag';
|
|
174
|
-
import { state } from 'lithent/helper';
|
|
62
|
+
## Two ways to build components
|
|
175
63
|
|
|
176
|
-
|
|
177
|
-
const count = state(0, renew);
|
|
64
|
+
Lithent offers two complementary styles you can freely mix in the same project.
|
|
178
65
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
66
|
+
**Manual Mode** — Explicit control with `renew()`
|
|
67
|
+
```tsx
|
|
68
|
+
import { mount } from 'lithent';
|
|
182
69
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
<li>count: ${count.value}</li>
|
|
187
|
-
<button onClick=${change}>increase</button>
|
|
188
|
-
<//>
|
|
189
|
-
`;
|
|
70
|
+
const Counter = mount(renew => {
|
|
71
|
+
let count = 0;
|
|
72
|
+
return () => <button onClick={() => { count++; renew(); }}>{count}</button>;
|
|
190
73
|
});
|
|
191
|
-
|
|
192
|
-
// appendChild or insertBefore
|
|
193
|
-
// The third argument is an optional value for insertBefore.
|
|
194
|
-
const destroy = render(lTag`<${Component} />`, document.getElementById('root'), document.getElementById('#insert-before-this-element'));
|
|
195
74
|
```
|
|
196
75
|
|
|
197
|
-
|
|
76
|
+
**Light API Mode** — Automatic reactivity
|
|
77
|
+
```tsx
|
|
78
|
+
import { lmount } from 'lithent';
|
|
79
|
+
import { lstate } from 'lithent/helper';
|
|
198
80
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.umd.js"></script>
|
|
203
|
-
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js"></script-->
|
|
204
|
-
|
|
205
|
-
<div id="root"></div>
|
|
206
|
-
|
|
207
|
-
<script>
|
|
208
|
-
const { h, Fragment, render, mount } = lithent;
|
|
209
|
-
const { lTag } = lithentTag;
|
|
210
|
-
// const { state } = lithentHelper;
|
|
211
|
-
|
|
212
|
-
const Component = mount(renew => {
|
|
213
|
-
count = 0;
|
|
214
|
-
|
|
215
|
-
const change = () => {
|
|
216
|
-
count += 1;
|
|
217
|
-
renew();
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// Updater
|
|
221
|
-
return () => lTag`
|
|
222
|
-
<${Fragment}>
|
|
223
|
-
<li>count: ${count}</li>
|
|
224
|
-
<button onClick=${change}>increase</button>
|
|
225
|
-
<//>
|
|
226
|
-
`;
|
|
81
|
+
const Counter = lmount(() => {
|
|
82
|
+
const count = lstate(0);
|
|
83
|
+
return () => <button onClick={() => count.value++}>{count.value}</button>;
|
|
227
84
|
});
|
|
228
|
-
|
|
229
|
-
// appendChild or insertBefore
|
|
230
|
-
// The third argument is an optional value for insertBefore.
|
|
231
|
-
const destroy = render(lTag`<${Component} />`, document.getElementById('root'), document.getElementById('#insert-before-this-element'));
|
|
232
|
-
</script>
|
|
233
85
|
```
|
|
234
86
|
|
|
235
|
-
|
|
236
|
-
- [htm](https://www.npmjs.com/package/htm) - making **H**yperscript **T**agged **M**arkup possible
|
|
87
|
+
> **[📚 Explore component patterns in detail](https://superlucky84.github.io/lithent/#/guide/mounter)**
|
|
237
88
|
|
|
238
|
-
|
|
89
|
+
<br />
|
|
239
90
|
|
|
240
|
-
|
|
91
|
+
## Key features
|
|
241
92
|
|
|
242
|
-
###
|
|
93
|
+
### Core
|
|
94
|
+
- **mount / lmount** — Component initialization
|
|
95
|
+
- **Portal** — Render outside parent DOM
|
|
96
|
+
- **Hooks** — Lifecycle callbacks (`mountCallback`, `updateCallback`, `mountReadyCallback`)
|
|
97
|
+
- **Ref** — Direct DOM access
|
|
243
98
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
99
|
+
### Helpers (optional)
|
|
100
|
+
- **state / lstate** — Reactive state management
|
|
101
|
+
- **computed** — Derived values
|
|
102
|
+
- **effect** — Side effects
|
|
103
|
+
- **store / lstore** — Global state
|
|
104
|
+
- **context / lcontext** — Cross-component data sharing
|
|
247
105
|
|
|
248
|
-
###
|
|
106
|
+
### Template options
|
|
107
|
+
- **JSX** — Via Vite plugin
|
|
108
|
+
- **FTags** — Function-style tags (no build step)
|
|
109
|
+
- **HTM** — Tagged template literals
|
|
110
|
+
- **Template Strings** — Custom templates
|
|
249
111
|
|
|
250
|
-
|
|
251
|
-
git clone https://github.com/superlucky84/lithent.git
|
|
112
|
+
> **[📖 View full API reference](https://superlucky84.github.io/lithent/#/)**
|
|
252
113
|
|
|
253
|
-
|
|
114
|
+
<br />
|
|
254
115
|
|
|
255
|
-
|
|
256
|
-
```
|
|
116
|
+
## Ecosystem
|
|
257
117
|
|
|
258
|
-
|
|
118
|
+
| Package | Description |
|
|
119
|
+
|--------|-------------|
|
|
120
|
+
| [lithent](https://www.npmjs.com/package/lithent) | Core library (~4KB) |
|
|
121
|
+
| [lithent/helper](https://www.npmjs.com/package/lithent) | Reactive state helpers |
|
|
122
|
+
| [lithent/ssr](https://www.npmjs.com/package/lithent) | Server‑side rendering |
|
|
123
|
+
| [lithent/ftags](https://www.npmjs.com/package/lithent) | Function‑style tag API |
|
|
124
|
+
| [lithent/tag](https://www.npmjs.com/package/lithent) | HTM template support |
|
|
125
|
+
| [create-lithent](https://www.npmjs.com/package/create-lithent) | Project scaffolding tool |
|
|
259
126
|
|
|
260
|
-
|
|
261
|
-
pnpm build
|
|
262
|
-
```
|
|
127
|
+
<br />
|
|
263
128
|
|
|
264
|
-
|
|
129
|
+
## License
|
|
265
130
|
|
|
266
|
-
|
|
267
|
-
pnpm dev // or pnpm dev:core
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Test
|
|
131
|
+
[MIT](LICENSE) © [superlucky84](https://github.com/superlucky84)
|
|
271
132
|
|
|
272
|
-
|
|
133
|
+
<br />
|
|
273
134
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
pnpm test
|
|
278
|
-
```
|
|
135
|
+
<div align="center">
|
|
136
|
+
<sub>Built with ❤️ by the Lithent community</sub>
|
|
137
|
+
</div>
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { setComponentMapManualMode as
|
|
1
|
+
import { setComponentMapManualMode as R, disposeComponentEntry as b, componentMap as p, replaceWDom as B } from "lithent";
|
|
2
2
|
let c = 0;
|
|
3
|
-
const
|
|
4
|
-
c += 1,
|
|
5
|
-
},
|
|
6
|
-
c = Math.max(0, c - 1), c === 0 &&
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
}, s = /* @__PURE__ */ new Map(),
|
|
3
|
+
const w = () => {
|
|
4
|
+
c += 1, R(!0);
|
|
5
|
+
}, E = () => {
|
|
6
|
+
c = Math.max(0, c - 1), c === 0 && R(!1);
|
|
7
|
+
}, x = (t) => {
|
|
8
|
+
b(t);
|
|
9
|
+
}, D = 3, s = /* @__PURE__ */ new Map(), U = (t) => {
|
|
10
10
|
let e = s.get(t);
|
|
11
11
|
return e || (e = {
|
|
12
12
|
instances: /* @__PURE__ */ new Set(),
|
|
13
13
|
domMap: /* @__PURE__ */ new Map(),
|
|
14
14
|
scheduled: !1,
|
|
15
|
-
pendingCtor: void 0
|
|
15
|
+
pendingCtor: void 0,
|
|
16
|
+
retryCount: 0
|
|
16
17
|
}, s.set(t, e)), e;
|
|
17
|
-
},
|
|
18
|
-
const n =
|
|
18
|
+
}, W = (t, e) => {
|
|
19
|
+
const n = U(t);
|
|
19
20
|
return n.instances.add(e), queueMicrotask(() => {
|
|
20
21
|
var o;
|
|
21
22
|
const r = p.get(e), a = ((o = r == null ? void 0 : r.vd) == null ? void 0 : o.value) ?? null;
|
|
@@ -24,15 +25,15 @@ const R = () => {
|
|
|
24
25
|
const r = s.get(t);
|
|
25
26
|
r && (r.instances.delete(e), r.domMap.delete(e), r.instances.size || s.delete(t));
|
|
26
27
|
};
|
|
27
|
-
},
|
|
28
|
+
}, $ = (t) => {
|
|
28
29
|
const e = s.get(t);
|
|
29
30
|
e && Array.from(e.instances).forEach(
|
|
30
|
-
(n) =>
|
|
31
|
-
), s.delete(t),
|
|
31
|
+
(n) => x(n)
|
|
32
|
+
), s.delete(t), E();
|
|
32
33
|
}, k = (t, e) => {
|
|
33
34
|
const n = s.get(t);
|
|
34
|
-
return n ? (n.pendingCtor = e, n.scheduled || (n.scheduled = !0, queueMicrotask(() =>
|
|
35
|
-
},
|
|
35
|
+
return n ? (n.pendingCtor = e, n.retryCount = 0, n.scheduled || (n.scheduled = !0, queueMicrotask(() => v(t))), !0) : !1;
|
|
36
|
+
}, v = (t) => {
|
|
36
37
|
const e = s.get(t);
|
|
37
38
|
if (!e) return;
|
|
38
39
|
e.scheduled = !1;
|
|
@@ -41,32 +42,48 @@ const R = () => {
|
|
|
41
42
|
return;
|
|
42
43
|
e.pendingCtor = void 0;
|
|
43
44
|
let r = !1, a = !1;
|
|
44
|
-
e.instances.forEach((
|
|
45
|
-
var
|
|
46
|
-
const
|
|
45
|
+
e.instances.forEach((u) => {
|
|
46
|
+
var h, y, C;
|
|
47
|
+
const d = p.get(u), m = e.domMap.get(u), i = ((h = d == null ? void 0 : d.vd) == null ? void 0 : h.value) || m;
|
|
47
48
|
if (!i || !i.el) {
|
|
48
49
|
a = !0;
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
const { compProps:
|
|
52
|
-
if (!
|
|
52
|
+
const { compProps: g, compChild: M } = i;
|
|
53
|
+
if (!g || !M) {
|
|
53
54
|
a = !0;
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
|
-
B(n,
|
|
58
|
-
const
|
|
59
|
-
e.domMap.set(
|
|
60
|
-
} catch (
|
|
61
|
-
console.warn(`[Lithent HMR] boundary update 실패: ${t}`,
|
|
58
|
+
B(n, g, M, i);
|
|
59
|
+
const l = ((C = (y = p.get(u)) == null ? void 0 : y.vd) == null ? void 0 : C.value) || i;
|
|
60
|
+
e.domMap.set(u, l), r = !0;
|
|
61
|
+
} catch (l) {
|
|
62
|
+
console.warn(`[Lithent HMR] boundary update 실패: ${t}`, l);
|
|
62
63
|
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
});
|
|
65
|
+
let o = e.pendingCtor;
|
|
66
|
+
const f = a && !r;
|
|
67
|
+
if (!(f || !!o)) {
|
|
68
|
+
e.retryCount = 0;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (f) {
|
|
72
|
+
if (e.retryCount += 1, e.retryCount > D) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`[Lithent HMR] boundary update failed after ${e.retryCount} attempts; aborting: ${t}`
|
|
75
|
+
), e.pendingCtor = void 0, e.scheduled = !1;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
o || (o = n);
|
|
79
|
+
}
|
|
80
|
+
e.pendingCtor = o, e.scheduled || (e.scheduled = !0, setTimeout(() => v(t), 0));
|
|
81
|
+
}, L = (t) => (w(), {
|
|
82
|
+
register: (e) => W(t, e),
|
|
66
83
|
update: (e) => k(t, e),
|
|
67
|
-
dispose: () =>
|
|
84
|
+
dispose: () => $(t)
|
|
68
85
|
});
|
|
69
86
|
export {
|
|
70
|
-
|
|
87
|
+
L as createBoundary
|
|
71
88
|
};
|
|
72
89
|
//# sourceMappingURL=lithentDevHelper.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lithentDevHelper.mjs","sources":["../src/componentMapControl.ts","../src/createBoundary.ts"],"sourcesContent":["import type { CompKey } from 'lithent';\nimport { setComponentMapManualMode, disposeComponentEntry } from 'lithent';\n\nlet manualModeRefCount = 0;\n\nexport const enableComponentMapManualMode = (): void => {\n manualModeRefCount += 1;\n setComponentMapManualMode(true);\n};\n\nexport const disableComponentMapManualMode = (): void => {\n manualModeRefCount = Math.max(0, manualModeRefCount - 1);\n if (manualModeRefCount === 0) {\n setComponentMapManualMode(false);\n }\n};\n\nexport const removeComponentEntry = (compKey: CompKey): void => {\n disposeComponentEntry(compKey);\n};\n","import type { CompKey, TagFunction, WDom } from 'lithent';\nimport { componentMap, replaceWDom } from 'lithent';\nimport {\n disableComponentMapManualMode,\n enableComponentMapManualMode,\n removeComponentEntry,\n} from './componentMapControl';\n\ntype InstanceRegistry = {\n instances: Set<CompKey>;\n domMap: Map<CompKey, WDom>;\n scheduled: boolean;\n pendingCtor?: TagFunction;\n};\n\nconst boundaryRegistry = new Map<string, InstanceRegistry>();\n\nconst getRegistry = (moduleId: string): InstanceRegistry => {\n let registry = boundaryRegistry.get(moduleId);\n\n if (!registry) {\n registry = {\n instances: new Set(),\n domMap: new Map(),\n scheduled: false,\n pendingCtor: undefined,\n };\n boundaryRegistry.set(moduleId, registry);\n }\n\n return registry;\n};\n\nexport type BoundaryController = {\n register: (compKey: CompKey) => () => void;\n update: (nextCtor: TagFunction) => boolean;\n dispose: () => void;\n};\n\nexport const registerBoundaryInstance = (\n moduleId: string,\n compKey: CompKey\n) => {\n const registry = getRegistry(moduleId);\n\n registry.instances.add(compKey);\n\n queueMicrotask(() => {\n const entry = componentMap.get(compKey);\n const currentWDom = entry?.vd?.value ?? null;\n\n if (currentWDom) {\n registry.domMap.set(compKey, currentWDom);\n }\n });\n\n return () => {\n const currentRegistry = boundaryRegistry.get(moduleId);\n if (!currentRegistry) return;\n\n currentRegistry.instances.delete(compKey);\n currentRegistry.domMap.delete(compKey);\n\n if (!currentRegistry.instances.size) {\n boundaryRegistry.delete(moduleId);\n }\n };\n};\n\nexport const disposeBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (registry) {\n Array.from(registry.instances).forEach(compKey =>\n removeComponentEntry(compKey)\n );\n }\n\n boundaryRegistry.delete(moduleId);\n disableComponentMapManualMode();\n};\n\nexport const applyBoundaryUpdate = (\n moduleId: string,\n nextCtor: TagFunction\n) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (!registry) return false;\n\n registry.pendingCtor = nextCtor;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n queueMicrotask(() => flushBoundary(moduleId));\n }\n\n return true;\n};\n\nconst flushBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n if (!registry) return;\n\n registry.scheduled = false;\n\n const ctor = registry.pendingCtor;\n if (!ctor) {\n return;\n }\n\n registry.pendingCtor = undefined;\n\n let updated = false;\n let hasMissing = false;\n\n registry.instances.forEach(compKey => {\n const entry = componentMap.get(compKey);\n const cached = registry.domMap.get(compKey);\n const currentWDom = entry?.vd?.value || cached;\n\n if (!currentWDom || !currentWDom.el) {\n hasMissing = true;\n return;\n }\n\n const { compProps, compChild } = currentWDom;\n\n if (!compProps || !compChild) {\n hasMissing = true;\n return;\n }\n\n try {\n replaceWDom(ctor, compProps, compChild, currentWDom as any);\n const refreshed = componentMap.get(compKey)?.vd?.value || currentWDom;\n registry.domMap.set(compKey, refreshed as WDom);\n updated = true;\n } catch (error) {\n console.warn(`[Lithent HMR] boundary update 실패: ${moduleId}`, error);\n }\n });\n\n
|
|
1
|
+
{"version":3,"file":"lithentDevHelper.mjs","sources":["../src/componentMapControl.ts","../src/createBoundary.ts"],"sourcesContent":["import type { CompKey } from 'lithent';\nimport { setComponentMapManualMode, disposeComponentEntry } from 'lithent';\n\nlet manualModeRefCount = 0;\n\nexport const enableComponentMapManualMode = (): void => {\n manualModeRefCount += 1;\n setComponentMapManualMode(true);\n};\n\nexport const disableComponentMapManualMode = (): void => {\n manualModeRefCount = Math.max(0, manualModeRefCount - 1);\n if (manualModeRefCount === 0) {\n setComponentMapManualMode(false);\n }\n};\n\nexport const removeComponentEntry = (compKey: CompKey): void => {\n disposeComponentEntry(compKey);\n};\n","import type { CompKey, TagFunction, WDom } from 'lithent';\nimport { componentMap, replaceWDom } from 'lithent';\nimport {\n disableComponentMapManualMode,\n enableComponentMapManualMode,\n removeComponentEntry,\n} from './componentMapControl';\n\nconst MAX_RETRY = 3;\n\ntype InstanceRegistry = {\n instances: Set<CompKey>;\n domMap: Map<CompKey, WDom>;\n scheduled: boolean;\n pendingCtor?: TagFunction;\n retryCount: number;\n};\n\nconst boundaryRegistry = new Map<string, InstanceRegistry>();\n\nconst getRegistry = (moduleId: string): InstanceRegistry => {\n let registry = boundaryRegistry.get(moduleId);\n\n if (!registry) {\n registry = {\n instances: new Set(),\n domMap: new Map(),\n scheduled: false,\n pendingCtor: undefined,\n retryCount: 0,\n };\n boundaryRegistry.set(moduleId, registry);\n }\n\n return registry;\n};\n\nexport type BoundaryController = {\n register: (compKey: CompKey) => () => void;\n update: (nextCtor: TagFunction) => boolean;\n dispose: () => void;\n};\n\nexport const registerBoundaryInstance = (\n moduleId: string,\n compKey: CompKey\n) => {\n const registry = getRegistry(moduleId);\n\n registry.instances.add(compKey);\n\n queueMicrotask(() => {\n const entry = componentMap.get(compKey);\n const currentWDom = entry?.vd?.value ?? null;\n\n if (currentWDom) {\n registry.domMap.set(compKey, currentWDom);\n }\n });\n\n return () => {\n const currentRegistry = boundaryRegistry.get(moduleId);\n if (!currentRegistry) return;\n\n currentRegistry.instances.delete(compKey);\n currentRegistry.domMap.delete(compKey);\n\n if (!currentRegistry.instances.size) {\n boundaryRegistry.delete(moduleId);\n }\n };\n};\n\nexport const disposeBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (registry) {\n Array.from(registry.instances).forEach(compKey =>\n removeComponentEntry(compKey)\n );\n }\n\n boundaryRegistry.delete(moduleId);\n disableComponentMapManualMode();\n};\n\nexport const applyBoundaryUpdate = (\n moduleId: string,\n nextCtor: TagFunction\n) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (!registry) return false;\n\n registry.pendingCtor = nextCtor;\n registry.retryCount = 0;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n queueMicrotask(() => flushBoundary(moduleId));\n }\n\n return true;\n};\n\nconst flushBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n if (!registry) return;\n\n registry.scheduled = false;\n\n const ctor = registry.pendingCtor;\n if (!ctor) {\n return;\n }\n\n registry.pendingCtor = undefined;\n\n let updated = false;\n let hasMissing = false;\n\n registry.instances.forEach(compKey => {\n const entry = componentMap.get(compKey);\n const cached = registry.domMap.get(compKey);\n const currentWDom = entry?.vd?.value || cached;\n\n if (!currentWDom || !currentWDom.el) {\n hasMissing = true;\n return;\n }\n\n const { compProps, compChild } = currentWDom;\n\n if (!compProps || !compChild) {\n hasMissing = true;\n return;\n }\n\n try {\n replaceWDom(ctor, compProps, compChild, currentWDom as any);\n const refreshed = componentMap.get(compKey)?.vd?.value || currentWDom;\n registry.domMap.set(compKey, refreshed as WDom);\n updated = true;\n } catch (error) {\n console.warn(`[Lithent HMR] boundary update 실패: ${moduleId}`, error);\n }\n });\n\n let nextPendingCtor: TagFunction | undefined = registry.pendingCtor;\n const shouldRetryMissing = hasMissing && !updated;\n const hasQueuedUpdate = Boolean(nextPendingCtor);\n const shouldRetry = shouldRetryMissing || hasQueuedUpdate;\n\n if (!shouldRetry) {\n registry.retryCount = 0;\n return;\n }\n\n if (shouldRetryMissing) {\n registry.retryCount += 1;\n\n if (registry.retryCount > MAX_RETRY) {\n console.warn(\n `[Lithent HMR] boundary update failed after ${registry.retryCount} attempts; aborting: ${moduleId}`\n );\n\n const hot = (\n import.meta as unknown as {\n hot?: { invalidate?: () => void };\n }\n ).hot;\n hot?.invalidate?.();\n\n registry.pendingCtor = undefined;\n registry.scheduled = false;\n return;\n }\n\n if (!nextPendingCtor) {\n nextPendingCtor = ctor;\n }\n }\n\n registry.pendingCtor = nextPendingCtor;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n setTimeout(() => flushBoundary(moduleId), 0);\n }\n};\n\nexport const createBoundary = (moduleId: string): BoundaryController => {\n enableComponentMapManualMode();\n\n return {\n register: (compKey: CompKey) => registerBoundaryInstance(moduleId, compKey),\n update: (nextCtor: TagFunction) => applyBoundaryUpdate(moduleId, nextCtor),\n dispose: () => disposeBoundary(moduleId),\n };\n};\n"],"names":["manualModeRefCount","enableComponentMapManualMode","setComponentMapManualMode","disableComponentMapManualMode","removeComponentEntry","compKey","disposeComponentEntry","MAX_RETRY","boundaryRegistry","getRegistry","moduleId","registry","registerBoundaryInstance","entry","componentMap","currentWDom","_a","currentRegistry","disposeBoundary","applyBoundaryUpdate","nextCtor","flushBoundary","ctor","updated","hasMissing","cached","compProps","compChild","replaceWDom","refreshed","_c","_b","error","nextPendingCtor","shouldRetryMissing","createBoundary"],"mappings":";AAGA,IAAIA,IAAqB;AAElB,MAAMC,IAA+B,MAAY;AAChC,EAAAD,KAAA,GACtBE,EAA0B,EAAI;AAChC,GAEaC,IAAgC,MAAY;AACvD,EAAAH,IAAqB,KAAK,IAAI,GAAGA,IAAqB,CAAC,GACnDA,MAAuB,KACzBE,EAA0B,EAAK;AAEnC,GAEaE,IAAuB,CAACC,MAA2B;AAC9D,EAAAC,EAAsBD,CAAO;AAC/B,GCXME,IAAY,GAUZC,wBAAuB,OAEvBC,IAAc,CAACC,MAAuC;AACtD,MAAAC,IAA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F;AAEA,IAAKsB,MACeA,IAAAX;AAAA,EAEtB;AAEA,EAAAX,EAAS,cAAcsB,GAElBtB,EAAS,cACZA,EAAS,YAAY,IACrB,WAAW,MAAMU,EAAcX,CAAQ,GAAG,CAAC;AAE/C,GAEayB,IAAiB,CAACzB,OACAT,KAEtB;AAAA,EACL,UAAU,CAACI,MAAqBO,EAAyBF,GAAUL,CAAO;AAAA,EAC1E,QAAQ,CAACe,MAA0BD,EAAoBT,GAAUU,CAAQ;AAAA,EACzE,SAAS,MAAMF,EAAgBR,CAAQ;AAAA;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("lithent")):typeof define=="function"&&define.amd?define(["exports","lithent"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.lithentDevHelper={},a.lithent))})(this,function(a,r){"use strict";let
|
|
1
|
+
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("lithent")):typeof define=="function"&&define.amd?define(["exports","lithent"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.lithentDevHelper={},a.lithent))})(this,function(a,r){"use strict";let c=0;const R=()=>{c+=1,r.setComponentMapManualMode(!0)},b=()=>{c=Math.max(0,c-1),c===0&&r.setComponentMapManualMode(!1)},B=t=>{r.disposeComponentEntry(t)},w=3,s=new Map,E=t=>{let e=s.get(t);return e||(e={instances:new Set,domMap:new Map,scheduled:!1,pendingCtor:void 0,retryCount:0},s.set(t,e)),e},T=(t,e)=>{const n=E(t);return n.instances.add(e),queueMicrotask(()=>{var i;const o=r.componentMap.get(e),u=((i=o==null?void 0:o.vd)==null?void 0:i.value)??null;u&&n.domMap.set(e,u)}),()=>{const o=s.get(t);o&&(o.instances.delete(e),o.domMap.delete(e),o.instances.size||s.delete(t))}},x=t=>{const e=s.get(t);e&&Array.from(e.instances).forEach(n=>B(n)),s.delete(t),b()},D=(t,e)=>{const n=s.get(t);return n?(n.pendingCtor=e,n.retryCount=0,n.scheduled||(n.scheduled=!0,queueMicrotask(()=>g(t))),!0):!1},g=t=>{const e=s.get(t);if(!e)return;e.scheduled=!1;const n=e.pendingCtor;if(!n)return;e.pendingCtor=void 0;let o=!1,u=!1;e.instances.forEach(p=>{var C,v,m;const f=r.componentMap.get(p),H=e.domMap.get(p),d=((C=f==null?void 0:f.vd)==null?void 0:C.value)||H;if(!d||!d.el){u=!0;return}const{compProps:y,compChild:h}=d;if(!y||!h){u=!0;return}try{r.replaceWDom(n,y,h,d);const l=((m=(v=r.componentMap.get(p))==null?void 0:v.vd)==null?void 0:m.value)||d;e.domMap.set(p,l),o=!0}catch(l){console.warn(`[Lithent HMR] boundary update 실패: ${t}`,l)}});let i=e.pendingCtor;const M=u&&!o;if(!(M||!!i)){e.retryCount=0;return}if(M){if(e.retryCount+=1,e.retryCount>w){console.warn(`[Lithent HMR] boundary update failed after ${e.retryCount} attempts; aborting: ${t}`),e.pendingCtor=void 0,e.scheduled=!1;return}i||(i=n)}e.pendingCtor=i,e.scheduled||(e.scheduled=!0,setTimeout(()=>g(t),0))},q=t=>(R(),{register:e=>T(t,e),update:e=>D(t,e),dispose:()=>x(t)});a.createBoundary=q,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=lithentDevHelper.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lithentDevHelper.umd.js","sources":["../src/componentMapControl.ts","../src/createBoundary.ts"],"sourcesContent":["import type { CompKey } from 'lithent';\nimport { setComponentMapManualMode, disposeComponentEntry } from 'lithent';\n\nlet manualModeRefCount = 0;\n\nexport const enableComponentMapManualMode = (): void => {\n manualModeRefCount += 1;\n setComponentMapManualMode(true);\n};\n\nexport const disableComponentMapManualMode = (): void => {\n manualModeRefCount = Math.max(0, manualModeRefCount - 1);\n if (manualModeRefCount === 0) {\n setComponentMapManualMode(false);\n }\n};\n\nexport const removeComponentEntry = (compKey: CompKey): void => {\n disposeComponentEntry(compKey);\n};\n","import type { CompKey, TagFunction, WDom } from 'lithent';\nimport { componentMap, replaceWDom } from 'lithent';\nimport {\n disableComponentMapManualMode,\n enableComponentMapManualMode,\n removeComponentEntry,\n} from './componentMapControl';\n\ntype InstanceRegistry = {\n instances: Set<CompKey>;\n domMap: Map<CompKey, WDom>;\n scheduled: boolean;\n pendingCtor?: TagFunction;\n};\n\nconst boundaryRegistry = new Map<string, InstanceRegistry>();\n\nconst getRegistry = (moduleId: string): InstanceRegistry => {\n let registry = boundaryRegistry.get(moduleId);\n\n if (!registry) {\n registry = {\n instances: new Set(),\n domMap: new Map(),\n scheduled: false,\n pendingCtor: undefined,\n };\n boundaryRegistry.set(moduleId, registry);\n }\n\n return registry;\n};\n\nexport type BoundaryController = {\n register: (compKey: CompKey) => () => void;\n update: (nextCtor: TagFunction) => boolean;\n dispose: () => void;\n};\n\nexport const registerBoundaryInstance = (\n moduleId: string,\n compKey: CompKey\n) => {\n const registry = getRegistry(moduleId);\n\n registry.instances.add(compKey);\n\n queueMicrotask(() => {\n const entry = componentMap.get(compKey);\n const currentWDom = entry?.vd?.value ?? null;\n\n if (currentWDom) {\n registry.domMap.set(compKey, currentWDom);\n }\n });\n\n return () => {\n const currentRegistry = boundaryRegistry.get(moduleId);\n if (!currentRegistry) return;\n\n currentRegistry.instances.delete(compKey);\n currentRegistry.domMap.delete(compKey);\n\n if (!currentRegistry.instances.size) {\n boundaryRegistry.delete(moduleId);\n }\n };\n};\n\nexport const disposeBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (registry) {\n Array.from(registry.instances).forEach(compKey =>\n removeComponentEntry(compKey)\n );\n }\n\n boundaryRegistry.delete(moduleId);\n disableComponentMapManualMode();\n};\n\nexport const applyBoundaryUpdate = (\n moduleId: string,\n nextCtor: TagFunction\n) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (!registry) return false;\n\n registry.pendingCtor = nextCtor;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n queueMicrotask(() => flushBoundary(moduleId));\n }\n\n return true;\n};\n\nconst flushBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n if (!registry) return;\n\n registry.scheduled = false;\n\n const ctor = registry.pendingCtor;\n if (!ctor) {\n return;\n }\n\n registry.pendingCtor = undefined;\n\n let updated = false;\n let hasMissing = false;\n\n registry.instances.forEach(compKey => {\n const entry = componentMap.get(compKey);\n const cached = registry.domMap.get(compKey);\n const currentWDom = entry?.vd?.value || cached;\n\n if (!currentWDom || !currentWDom.el) {\n hasMissing = true;\n return;\n }\n\n const { compProps, compChild } = currentWDom;\n\n if (!compProps || !compChild) {\n hasMissing = true;\n return;\n }\n\n try {\n replaceWDom(ctor, compProps, compChild, currentWDom as any);\n const refreshed = componentMap.get(compKey)?.vd?.value || currentWDom;\n registry.domMap.set(compKey, refreshed as WDom);\n updated = true;\n } catch (error) {\n console.warn(`[Lithent HMR] boundary update 실패: ${moduleId}`, error);\n }\n });\n\n
|
|
1
|
+
{"version":3,"file":"lithentDevHelper.umd.js","sources":["../src/componentMapControl.ts","../src/createBoundary.ts"],"sourcesContent":["import type { CompKey } from 'lithent';\nimport { setComponentMapManualMode, disposeComponentEntry } from 'lithent';\n\nlet manualModeRefCount = 0;\n\nexport const enableComponentMapManualMode = (): void => {\n manualModeRefCount += 1;\n setComponentMapManualMode(true);\n};\n\nexport const disableComponentMapManualMode = (): void => {\n manualModeRefCount = Math.max(0, manualModeRefCount - 1);\n if (manualModeRefCount === 0) {\n setComponentMapManualMode(false);\n }\n};\n\nexport const removeComponentEntry = (compKey: CompKey): void => {\n disposeComponentEntry(compKey);\n};\n","import type { CompKey, TagFunction, WDom } from 'lithent';\nimport { componentMap, replaceWDom } from 'lithent';\nimport {\n disableComponentMapManualMode,\n enableComponentMapManualMode,\n removeComponentEntry,\n} from './componentMapControl';\n\nconst MAX_RETRY = 3;\n\ntype InstanceRegistry = {\n instances: Set<CompKey>;\n domMap: Map<CompKey, WDom>;\n scheduled: boolean;\n pendingCtor?: TagFunction;\n retryCount: number;\n};\n\nconst boundaryRegistry = new Map<string, InstanceRegistry>();\n\nconst getRegistry = (moduleId: string): InstanceRegistry => {\n let registry = boundaryRegistry.get(moduleId);\n\n if (!registry) {\n registry = {\n instances: new Set(),\n domMap: new Map(),\n scheduled: false,\n pendingCtor: undefined,\n retryCount: 0,\n };\n boundaryRegistry.set(moduleId, registry);\n }\n\n return registry;\n};\n\nexport type BoundaryController = {\n register: (compKey: CompKey) => () => void;\n update: (nextCtor: TagFunction) => boolean;\n dispose: () => void;\n};\n\nexport const registerBoundaryInstance = (\n moduleId: string,\n compKey: CompKey\n) => {\n const registry = getRegistry(moduleId);\n\n registry.instances.add(compKey);\n\n queueMicrotask(() => {\n const entry = componentMap.get(compKey);\n const currentWDom = entry?.vd?.value ?? null;\n\n if (currentWDom) {\n registry.domMap.set(compKey, currentWDom);\n }\n });\n\n return () => {\n const currentRegistry = boundaryRegistry.get(moduleId);\n if (!currentRegistry) return;\n\n currentRegistry.instances.delete(compKey);\n currentRegistry.domMap.delete(compKey);\n\n if (!currentRegistry.instances.size) {\n boundaryRegistry.delete(moduleId);\n }\n };\n};\n\nexport const disposeBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (registry) {\n Array.from(registry.instances).forEach(compKey =>\n removeComponentEntry(compKey)\n );\n }\n\n boundaryRegistry.delete(moduleId);\n disableComponentMapManualMode();\n};\n\nexport const applyBoundaryUpdate = (\n moduleId: string,\n nextCtor: TagFunction\n) => {\n const registry = boundaryRegistry.get(moduleId);\n\n if (!registry) return false;\n\n registry.pendingCtor = nextCtor;\n registry.retryCount = 0;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n queueMicrotask(() => flushBoundary(moduleId));\n }\n\n return true;\n};\n\nconst flushBoundary = (moduleId: string) => {\n const registry = boundaryRegistry.get(moduleId);\n if (!registry) return;\n\n registry.scheduled = false;\n\n const ctor = registry.pendingCtor;\n if (!ctor) {\n return;\n }\n\n registry.pendingCtor = undefined;\n\n let updated = false;\n let hasMissing = false;\n\n registry.instances.forEach(compKey => {\n const entry = componentMap.get(compKey);\n const cached = registry.domMap.get(compKey);\n const currentWDom = entry?.vd?.value || cached;\n\n if (!currentWDom || !currentWDom.el) {\n hasMissing = true;\n return;\n }\n\n const { compProps, compChild } = currentWDom;\n\n if (!compProps || !compChild) {\n hasMissing = true;\n return;\n }\n\n try {\n replaceWDom(ctor, compProps, compChild, currentWDom as any);\n const refreshed = componentMap.get(compKey)?.vd?.value || currentWDom;\n registry.domMap.set(compKey, refreshed as WDom);\n updated = true;\n } catch (error) {\n console.warn(`[Lithent HMR] boundary update 실패: ${moduleId}`, error);\n }\n });\n\n let nextPendingCtor: TagFunction | undefined = registry.pendingCtor;\n const shouldRetryMissing = hasMissing && !updated;\n const hasQueuedUpdate = Boolean(nextPendingCtor);\n const shouldRetry = shouldRetryMissing || hasQueuedUpdate;\n\n if (!shouldRetry) {\n registry.retryCount = 0;\n return;\n }\n\n if (shouldRetryMissing) {\n registry.retryCount += 1;\n\n if (registry.retryCount > MAX_RETRY) {\n console.warn(\n `[Lithent HMR] boundary update failed after ${registry.retryCount} attempts; aborting: ${moduleId}`\n );\n\n const hot = (\n import.meta as unknown as {\n hot?: { invalidate?: () => void };\n }\n ).hot;\n hot?.invalidate?.();\n\n registry.pendingCtor = undefined;\n registry.scheduled = false;\n return;\n }\n\n if (!nextPendingCtor) {\n nextPendingCtor = ctor;\n }\n }\n\n registry.pendingCtor = nextPendingCtor;\n\n if (!registry.scheduled) {\n registry.scheduled = true;\n setTimeout(() => flushBoundary(moduleId), 0);\n }\n};\n\nexport const createBoundary = (moduleId: string): BoundaryController => {\n enableComponentMapManualMode();\n\n return {\n register: (compKey: CompKey) => registerBoundaryInstance(moduleId, compKey),\n update: (nextCtor: TagFunction) => applyBoundaryUpdate(moduleId, nextCtor),\n dispose: () => disposeBoundary(moduleId),\n };\n};\n"],"names":["manualModeRefCount","enableComponentMapManualMode","setComponentMapManualMode","disableComponentMapManualMode","removeComponentEntry","compKey","disposeComponentEntry","MAX_RETRY","boundaryRegistry","getRegistry","moduleId","registry","registerBoundaryInstance","entry","componentMap","currentWDom","_a","currentRegistry","disposeBoundary","applyBoundaryUpdate","nextCtor","flushBoundary","ctor","updated","hasMissing","cached","compProps","compChild","replaceWDom","refreshed","error","nextPendingCtor","shouldRetryMissing","createBoundary"],"mappings":"iRAGA,IAAIA,EAAqB,EAElB,MAAMC,EAA+B,IAAY,CAChCD,GAAA,EACtBE,EAAA,0BAA0B,EAAI,CAChC,EAEaC,EAAgC,IAAY,CACvDH,EAAqB,KAAK,IAAI,EAAGA,EAAqB,CAAC,EACnDA,IAAuB,GACzBE,EAAA,0BAA0B,EAAK,CAEnC,EAEaE,EAAwBC,GAA2B,CAC9DC,EAAA,sBAAsBD,CAAO,CAC/B,ECXME,EAAY,EAUZC,MAAuB,IAEvBC,EAAeC,GAAuC,CACtD,IAAAC,EAAWH,EAAiB,IAAIE,CAAQ,EAE5C,OAAKC,IACQA,EAAA,CACT,cAAe,IACf,WAAY,IACZ,UAAW,GACX,YAAa,OACb,WAAY,CAAA,EAEGH,EAAA,IAAIE,EAAUC,CAAQ,GAGlCA,CACT,EAQaC,EAA2B,CACtCF,EACAL,IACG,CACG,MAAAM,EAAWF,EAAYC,CAAQ,EAE5B,OAAAC,EAAA,UAAU,IAAIN,CAAO,EAE9B,eAAe,IAAM,OACb,MAAAQ,EAAQC,EAAAA,aAAa,IAAIT,CAAO,EAChCU,IAAcC,EAAAH,GAAA,YAAAA,EAAO,KAAP,YAAAG,EAAW,QAAS,KAEpCD,GACOJ,EAAA,OAAO,IAAIN,EAASU,CAAW,CAC1C,CACD,EAEM,IAAM,CACL,MAAAE,EAAkBT,EAAiB,IAAIE,CAAQ,EAChDO,IAEWA,EAAA,UAAU,OAAOZ,CAAO,EACxBY,EAAA,OAAO,OAAOZ,CAAO,EAEhCY,EAAgB,UAAU,MAC7BT,EAAiB,OAAOE,CAAQ,EAClC,CAEJ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