lithent 1.0.1 → 1.0.3
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 +26 -23
- package/dist/lithent.mjs +360 -804
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/universalRef.d.ts +6 -6
- package/dist/wDom.d.ts +2 -2
- package/examples/dist/assets/index.1e9792b7.js +2 -0
- package/examples/dist/assets/index.1e9792b7.js.map +1 -0
- package/examples/dist/assets/index.48a8de86.js +2 -0
- package/examples/dist/assets/index.48a8de86.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/diff.ts +28 -39
- package/src/hook/mountCallback.ts +6 -6
- package/src/hook/unmount.ts +7 -7
- package/src/hook/useUpdate.ts +6 -6
- package/src/render.ts +51 -57
- package/src/types/index.ts +6 -6
- package/src/utils/index.ts +7 -5
- package/src/utils/predicator.ts +5 -2
- package/src/utils/universalRef.ts +23 -28
- package/src/wDom.ts +28 -37
- package/examples/dist/assets/index.c9e026ab.js +0 -2
- package/examples/dist/assets/index.c9e026ab.js.map +0 -1
- /package/src/tests/{example1.tsx → test1.tsx} +0 -0
- /package/src/tests/{example10.tsx → test10.tsx} +0 -0
- /package/src/tests/{example11.tsx → test11.tsx} +0 -0
- /package/src/tests/{example12.tsx → test12.tsx} +0 -0
- /package/src/tests/{example13.tsx → test13.tsx} +0 -0
- /package/src/tests/{example14.tsx → test14.tsx} +0 -0
- /package/src/tests/{example15.tsx → test15.tsx} +0 -0
- /package/src/tests/{example16.tsx → test16.tsx} +0 -0
- /package/src/tests/{example17.tsx → test17.tsx} +0 -0
- /package/src/tests/{example2.tsx → test2.tsx} +0 -0
- /package/src/tests/{example3.tsx → test3.tsx} +0 -0
- /package/src/tests/{example4.tsx → test4.tsx} +0 -0
- /package/src/tests/{example5.tsx → test5.tsx} +0 -0
- /package/src/tests/{example6.tsx → test6.tsx} +0 -0
- /package/src/tests/{example7.tsx → test7.tsx} +0 -0
- /package/src/tests/{example8.tsx → test8.tsx} +0 -0
- /package/src/tests/{example9.tsx → test9.tsx} +0 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ used lightly in a variety of situations.
|
|
|
9
9
|
- https://superlucky84.github.io/lithent
|
|
10
10
|
- (This guide page is written in lithent.)
|
|
11
11
|
|
|
12
|
-
`(9.
|
|
12
|
+
`(9.60 KiB / gzip: 3.72 KiB)`
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
## 🚩 Table of Contents
|
|
@@ -24,20 +24,20 @@ used lightly in a variety of situations.
|
|
|
24
24
|
- [Examples](#examples)
|
|
25
25
|
- [With ESM](#with-esm)
|
|
26
26
|
- [With UMD](#with-umd)
|
|
27
|
-
- [Test](#test)
|
|
28
27
|
- [Develop Guide](#develop-guide)
|
|
28
|
+
- [Test](#test)
|
|
29
29
|
|
|
30
30
|
## Why use Lithent?
|
|
31
31
|
|
|
32
32
|
### Lithent have the bare minimum of necessary functionality, with no unnecessary features.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
In a real-world development environment, you may want to use Virtual DOM lightly, with only the bare minimum of core functionality.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
"Lithent" makes it easy to add, remove, and update virtual domes to specific parts of a pre-drawn SSR page.
|
|
37
37
|
|
|
38
|
-
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').
|
|
38
|
+
"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').
|
|
39
39
|
|
|
40
|
-
We provide code in the form of 'helpers' that extend the basic functionality, but using the helpers is only optional and
|
|
40
|
+
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.
|
|
41
41
|
|
|
42
42
|
### Approach with the developer-friendly concept of closures between "component mounter" and "renderer"
|
|
43
43
|
|
|
@@ -61,10 +61,10 @@ pnpm add lithent
|
|
|
61
61
|
|
|
62
62
|
#### Or Use CDN
|
|
63
63
|
|
|
64
|
-
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
65
|
-
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
66
|
-
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
67
|
-
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
64
|
+
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.0.3/dist/lithent.umd.js
|
|
65
|
+
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.3/helper/dist/lithentHelper.umd.js
|
|
66
|
+
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.3/dist/lithent.mjs
|
|
67
|
+
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.3/helper/dist/lithentHelper.mjs
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
It's easier to use lithent with JSX or HTM.
|
|
@@ -98,15 +98,17 @@ import { state } from 'lithent/helper';
|
|
|
98
98
|
import htm from 'htm';
|
|
99
99
|
const html = htm.bind(h);
|
|
100
100
|
|
|
101
|
-
const Component = mount((
|
|
102
|
-
const count = state(0,
|
|
101
|
+
const Component = mount((renew, _props) => {
|
|
102
|
+
const count = state(0, renew);
|
|
103
103
|
|
|
104
|
-
const change = () =>
|
|
104
|
+
const change = () => {
|
|
105
|
+
count.value += 1;
|
|
106
|
+
};
|
|
105
107
|
|
|
106
108
|
// Updater
|
|
107
109
|
return () => html`
|
|
108
110
|
<${Fragment}>
|
|
109
|
-
<li>count: ${count.
|
|
111
|
+
<li>count: ${count.value}</li>
|
|
110
112
|
<button onClick=${change}>increase</button>
|
|
111
113
|
<//>
|
|
112
114
|
`;
|
|
@@ -122,8 +124,8 @@ const destroy = render(html`<${Component} />`, document.getElementById('root'));
|
|
|
122
124
|
#### With UMD
|
|
123
125
|
|
|
124
126
|
```html
|
|
125
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
126
|
-
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
127
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.0.3/dist/lithent.umd.js"></script>
|
|
128
|
+
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.3/helper/dist/lithentHelper.umd.js"></script-->
|
|
127
129
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/htm/3.1.1/htm.js"></script>
|
|
128
130
|
|
|
129
131
|
<div id="root"></div>
|
|
@@ -154,13 +156,6 @@ const destroy = render(html`<${Component} />`, document.getElementById('root'));
|
|
|
154
156
|
</script>
|
|
155
157
|
```
|
|
156
158
|
|
|
157
|
-
## Test
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
// pnpm install
|
|
161
|
-
pnpm test
|
|
162
|
-
```
|
|
163
|
-
|
|
164
159
|
## Develop Guide
|
|
165
160
|
|
|
166
161
|
It's open source, so you can develop and contribute together.
|
|
@@ -192,3 +187,11 @@ pnpm build
|
|
|
192
187
|
```bash
|
|
193
188
|
pnpm dev // or pnpm dev:core
|
|
194
189
|
```
|
|
190
|
+
|
|
191
|
+
## Test
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
// pnpm install
|
|
195
|
+
pnpm test
|
|
196
|
+
```
|
|
197
|
+
|