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.
Files changed (44) hide show
  1. package/README.md +26 -23
  2. package/dist/lithent.mjs +360 -804
  3. package/dist/lithent.mjs.map +1 -1
  4. package/dist/lithent.umd.js +1 -1
  5. package/dist/lithent.umd.js.map +1 -1
  6. package/dist/types/index.d.ts +6 -6
  7. package/dist/utils/index.d.ts +16 -0
  8. package/dist/utils/universalRef.d.ts +6 -6
  9. package/dist/wDom.d.ts +2 -2
  10. package/examples/dist/assets/index.1e9792b7.js +2 -0
  11. package/examples/dist/assets/index.1e9792b7.js.map +1 -0
  12. package/examples/dist/assets/index.48a8de86.js +2 -0
  13. package/examples/dist/assets/index.48a8de86.js.map +1 -0
  14. package/examples/dist/index.html +1 -1
  15. package/package.json +1 -1
  16. package/src/diff.ts +28 -39
  17. package/src/hook/mountCallback.ts +6 -6
  18. package/src/hook/unmount.ts +7 -7
  19. package/src/hook/useUpdate.ts +6 -6
  20. package/src/render.ts +51 -57
  21. package/src/types/index.ts +6 -6
  22. package/src/utils/index.ts +7 -5
  23. package/src/utils/predicator.ts +5 -2
  24. package/src/utils/universalRef.ts +23 -28
  25. package/src/wDom.ts +28 -37
  26. package/examples/dist/assets/index.c9e026ab.js +0 -2
  27. package/examples/dist/assets/index.c9e026ab.js.map +0 -1
  28. /package/src/tests/{example1.tsx → test1.tsx} +0 -0
  29. /package/src/tests/{example10.tsx → test10.tsx} +0 -0
  30. /package/src/tests/{example11.tsx → test11.tsx} +0 -0
  31. /package/src/tests/{example12.tsx → test12.tsx} +0 -0
  32. /package/src/tests/{example13.tsx → test13.tsx} +0 -0
  33. /package/src/tests/{example14.tsx → test14.tsx} +0 -0
  34. /package/src/tests/{example15.tsx → test15.tsx} +0 -0
  35. /package/src/tests/{example16.tsx → test16.tsx} +0 -0
  36. /package/src/tests/{example17.tsx → test17.tsx} +0 -0
  37. /package/src/tests/{example2.tsx → test2.tsx} +0 -0
  38. /package/src/tests/{example3.tsx → test3.tsx} +0 -0
  39. /package/src/tests/{example4.tsx → test4.tsx} +0 -0
  40. /package/src/tests/{example5.tsx → test5.tsx} +0 -0
  41. /package/src/tests/{example6.tsx → test6.tsx} +0 -0
  42. /package/src/tests/{example7.tsx → test7.tsx} +0 -0
  43. /package/src/tests/{example8.tsx → test8.tsx} +0 -0
  44. /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.68 KiB / gzip: 3.60 KiB)`
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
- Since 'react' and 'vue', there have been a lot of UI libraries coming out that boast full-stack functionality.
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
- However, in the real world of development, there are times when you need to build something using only the bare minimum of key features, rather than a full-stack, full-featured library.
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 talented users can extend and develop custom helpers for their own projects.
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.1/dist/lithent.umd.js
65
- * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.1/helper/dist/lithentHelper.umd.js
66
- * ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.1/dist/lithent.mjs
67
- * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.1/helper/dist/lithentHelper.mjs
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((r, _props) => {
102
- const count = state(0, r);
101
+ const Component = mount((renew, _props) => {
102
+ const count = state(0, renew);
103
103
 
104
- const change = () => (count.v += 1);
104
+ const change = () => {
105
+ count.value += 1;
106
+ };
105
107
 
106
108
  // Updater
107
109
  return () => html`
108
110
  <${Fragment}>
109
- <li>count: ${count.v}</li>
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.1/dist/lithent.umd.js"></script>
126
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.1/helper/dist/lithentHelper.umd.js"></script-->
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
+