lithent 1.20.1 → 1.20.2

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 (2) hide show
  1. package/README.md +15 -79
  2. package/package.json +5 -3
package/README.md CHANGED
@@ -38,8 +38,6 @@ used lightly in a variety of situations.
38
38
  - [Examples](#examples)
39
39
  - [With ESM](#with-esm)
40
40
  - [With UMD](#with-umd)
41
- - [Context API](#context-api)
42
- - [Multi-value Provider Example](#multi-value-provider-example)
43
41
  - [Related Projects](#related-projects)
44
42
  - [Develop Guide](#develop-guide)
45
43
  - [Test](#test)
@@ -92,14 +90,14 @@ pnpm add lithent
92
90
 
93
91
  #### Or Use CDN
94
92
 
95
- * UMD : https://cdn.jsdelivr.net/npm/lithent@1.20.1/dist/lithent.umd.js
96
- * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.1/helper/dist/lithentHelper.umd.js
97
- * UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.1/ftags/dist/lithentFTags.umd.js
98
- * UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.1/tag/dist/lithentTag.umd.js
99
- * ESM : https://cdn.jsdelivr.net/npm/lithent@1.20.1/dist/lithent.mjs
100
- * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.1/helper/dist/lithentHelper.mjs
101
- * ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.1/ftags/dist/lithentFTags.mjs
102
- * ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.1/tag/dist/lithentTag.mjs
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
103
101
 
104
102
 
105
103
  It's easier to use lithent with JSX or HTM.
@@ -124,9 +122,9 @@ import { fTags, fFragment, fMount } from 'lithent/ftags';
124
122
  const { section, div, p, br, strong } = fTags;
125
123
 
126
124
  /* UMD
127
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/dist/lithent.umd.js"></script>
128
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/helper/dist/lithentHelper.umd.js"></script>
129
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/ftags/dist/lithentFTags.umd.js"></script>
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>
130
128
 
131
129
  const { render } = lithent;
132
130
  const { fTags, fMount, fFragment } = lithentFTags;
@@ -199,10 +197,10 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
199
197
  #### With UMD
200
198
 
201
199
  ```html
202
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/dist/lithent.umd.js"></script>
203
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/helper/dist/lithentHelper.umd.js"></script-->
204
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/tag/dist/lithentTag.umd.js"></script>
205
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.1/ftags/dist/lithentFTags.umd.js"></script-->
200
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js"></script>
201
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js"></script-->
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-->
206
204
 
207
205
  <div id="root"></div>
208
206
 
@@ -234,68 +232,6 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
234
232
  </script>
235
233
  ```
236
234
 
237
- ## Context API
238
-
239
- Lithent-helper ships a lightweight context system so you can share state without manual prop drilling. Providers stay isolated from consumer renews and you can subscribe to every key or only the slices you need.
240
-
241
- ### Multi-value Provider Example
242
-
243
- ```tsx
244
- import { h, mount } from 'lithent';
245
- import { createContext } from 'lithent-helper';
246
-
247
- type AppState = { user: string; theme: string; count: number };
248
-
249
- const AppContext = createContext<AppState>();
250
- const { Provider, contextState, useContext } = AppContext;
251
-
252
- const AppProvider = mount((_renew, _props, children) => {
253
- // Provider owns the shared state; consumers cannot trigger its renew directly.
254
- const user = contextState('Alice');
255
- const theme = contextState('dark');
256
- const count = contextState(0);
257
-
258
- return () => (
259
- <Provider user={user} theme={theme} count={count}>
260
- {children}
261
- </Provider>
262
- );
263
- });
264
-
265
- const StatsPanel = mount(renew => {
266
- // Omitting the subscribe list subscribes to every value exposed by the Provider.
267
- const ctx = useContext(AppContext, renew);
268
- return () => (
269
- <section>
270
- <p>User: {ctx.user?.value}</p>
271
- <p>Theme: {ctx.theme?.value}</p>
272
- <p>Count: {ctx.count?.value}</p>
273
- <button onClick={() => ctx.count && (ctx.count.value += 1)}>
274
- Increment
275
- </button>
276
- <button onClick={() => ctx.count && (ctx.count.value = 3)}>
277
- Set count to 3
278
- </button>
279
- </section>
280
- );
281
- });
282
-
283
- const ThemeBadge = mount(renew => {
284
- // Subscribe only to the theme key; user/count updates will not rerender this component.
285
- const ctx = useContext(AppContext, renew, ['theme']);
286
- return () => <span>Theme: {ctx.theme?.value}</span>;
287
- });
288
-
289
- const App = mount(() => {
290
- return () => (
291
- <AppProvider>
292
- <StatsPanel />
293
- <ThemeBadge />
294
- </AppProvider>
295
- );
296
- });
297
- ```
298
-
299
235
  ## Related Projects
300
236
  - [htm](https://www.npmjs.com/package/htm) - making **H**yperscript **T**agged **M**arkup possible
301
237
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "lithent",
4
- "version": "1.20.1",
4
+ "version": "1.20.2",
5
5
  "description": "An extensible virtual DOM library for lightweight use in a variety of environments.",
6
6
  "main": "./dist/lithent.umd.js",
7
7
  "module": "./dist/lithent.mjs",
@@ -116,6 +116,8 @@
116
116
  "build:helper": "pnpm --filter lithent-helper build",
117
117
  "build:devHelper": "pnpm --filter lithent-dev-helper build",
118
118
  "build:hmrParser": "pnpm --filter @lithent/hmr-parser build",
119
+ "build:lithentTemplateParser": "pnpm --filter @lithent/lithent-template-parser build",
120
+ "build:lithentTemplateVite": "pnpm --filter @lithent/lithent-template-vite build",
119
121
  "build:lithentVite": "pnpm --filter @lithent/lithent-vite build",
120
122
  "build:lithentMdx": "pnpm --filter @lithent/lithent-mdx build",
121
123
  "build:jsxruntime": "pnpm --filter jsx-runtime build",
@@ -124,8 +126,8 @@
124
126
  "build:ftags": "pnpm --filter lithent-ftags build",
125
127
  "build:examples": "pnpm --filter lithent-examples build",
126
128
  "build:docs": "pnpm --filter lithent-docs build",
127
- "build:sequence": "pnpm build:core && pnpm build:jsxruntime && pnpm build:helper && pnpm build:devHelper && pnpm build:hmrParser && pnpm build:lithentMdx && pnpm build:lithentVite && pnpm build:ssr",
128
- "build:parallel": "pnpm --filter '!jsx-runtime' --filter '!lithent-helper' --filter '!lithent-dev-helper' --filter '!@lithent/hmr-parser' --filter '!@lithent/lithent-mdx' --filter '!@lithent/lithent-vite' --filter '!lithent-ssr' --filter '!create-lithent-ssr' build",
129
+ "build:sequence": "pnpm build:core && pnpm build:jsxruntime && pnpm build:helper && pnpm build:devHelper && pnpm build:hmrParser && pnpm build:lithentTemplateParser && pnpm build:lithentTemplateVite && pnpm build:lithentMdx && pnpm build:lithentVite && pnpm build:ssr",
130
+ "build:parallel": "pnpm --filter '!jsx-runtime' --filter '!lithent-helper' --filter '!lithent-dev-helper' --filter '!@lithent/hmr-parser' --filter '!@lithent/lithent-template-parser' --filter '!@lithent/lithent-template-vite' --filter '!@lithent/lithent-mdx' --filter '!@lithent/lithent-vite' --filter '!lithent-ssr' --filter '!create-lithent-ssr' build",
129
131
  "build": "pnpm run build:sequence && pnpm run build:parallel",
130
132
  "watch:core": "vite build --watch",
131
133
  "watch:helper": "pnpm --filter lithent-helper watch",