lithent 1.22.0 → 1.23.0
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 +24 -0
- package/dist/lithent-agent-addon.md +25 -2
- package/dist/lithent.mjs +270 -271
- 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 +55 -4
- package/dist/skills/lithent/constraints/mistakes.md +4 -1
- package/dist/skills/lithent/constraints/rules.md +2 -1
- package/dist/skills/lithent/constraints/troubleshooting.md +4 -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 +104 -0
- package/dist/skills/lithent/reference/element.md +69 -0
- package/dist/skills/lithent/reference/lstore-inference.md +1 -1
- package/dist/skills/lithent/reference/props-types.md +1 -1
- package/dist/utils/predicator.d.ts +1 -0
- package/element/dist/index.d.ts +56 -0
- package/element/dist/lithentElement.mjs +99 -0
- package/element/dist/lithentElement.mjs.map +1 -0
- package/element/dist/lithentElement.umd.js +3 -0
- package/element/dist/lithentElement.umd.js.map +1 -0
- package/element/package.json +37 -0
- package/element/src/index.ts +295 -0
- package/element/src/tests/element-attributes.test.ts +176 -0
- package/element/src/tests/element-boundaries.test.ts +198 -0
- package/element/src/tests/element-events.test.ts +198 -0
- package/element/src/tests/element-hardening.test.ts +268 -0
- package/element/src/tests/element-lifecycle.test.ts +175 -0
- package/element/src/tests/element-move.test.ts +146 -0
- package/element/src/tests/element-properties.test.ts +149 -0
- package/element/src/tests/element-shadow.test.ts +221 -0
- package/element/src/tests/element-smoke.test.ts +21 -0
- package/element/src/tests/element-ssr.test.ts +20 -0
- package/element/src/tests/element-types.test.ts +104 -0
- package/examples/dist/assets/index-BZ7HvV5V.js +2 -0
- package/examples/dist/assets/index-BZ7HvV5V.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/helper/dist/lithentHelper.mjs +96 -87
- 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/package.json +4 -2
- package/helper/src/hook/lstore.ts +14 -0
- package/helper/src/hook/store.ts +14 -0
- package/helper/src/tests/contextRemoval.tsx +83 -0
- package/helper/src/tests/laneInteraction.tsx +324 -0
- package/helper/src/tests/storeVersion.tsx +88 -0
- package/jsx-runtime/dist/index.d.ts +8 -2
- package/jsx-runtime/dist/jsxRuntime.mjs +10 -7
- package/jsx-runtime/dist/jsxRuntime.mjs.map +1 -1
- package/jsx-runtime/dist/jsxRuntime.umd.js +1 -1
- package/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
- package/jsx-runtime/package.json +4 -2
- package/jsx-runtime/src/index.ts +17 -5
- package/package.json +41 -4
- package/src/hook/internal/unmount.ts +3 -0
- package/src/render.ts +27 -1
- package/src/tests/core-accessorUpgrade.test.tsx +288 -0
- package/src/tests/core-destroyUnmount.test.tsx +77 -0
- package/src/tests/core-removedRedraw.test.tsx +70 -0
- package/src/utils/predicator.ts +17 -10
- package/ssr/dist/lithentSsr.mjs +80 -77
- package/ssr/dist/lithentSsr.mjs.map +1 -1
- package/ssr/dist/lithentSsr.umd.js +2 -2
- package/ssr/dist/lithentSsr.umd.js.map +1 -1
- package/ssr/src/tests/laneHydration.tsx +91 -0
- package/examples/dist/assets/index-fEEXG6OR.js +0 -2
- package/examples/dist/assets/index-fEEXG6OR.js.map +0 -1
package/README.md
CHANGED
|
@@ -53,6 +53,8 @@ npm install lithent
|
|
|
53
53
|
```html
|
|
54
54
|
<script src="https://cdn.jsdelivr.net/npm/lithent/dist/lithent.umd.js"></script>
|
|
55
55
|
<script src="https://cdn.jsdelivr.net/npm/lithent/ftags/dist/lithentFTags.umd.js"></script>
|
|
56
|
+
<!-- Custom Elements (optional) -->
|
|
57
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent/element/dist/lithentElement.umd.js"></script>
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
> **[📦 View all available CDN URLs](https://superlucky84.github.io/lithent/#/guide/quick-start)**
|
|
@@ -103,6 +105,18 @@ const Counter = lmount(() => {
|
|
|
103
105
|
- **store / lstore** — Global state
|
|
104
106
|
- **context / lcontext** — Cross-component data sharing
|
|
105
107
|
|
|
108
|
+
### Custom Elements (optional)
|
|
109
|
+
- **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
|
+
|
|
111
|
+
```js
|
|
112
|
+
import { defineElement, emit } from 'lithent/element';
|
|
113
|
+
|
|
114
|
+
defineElement('pay-button', PayButton, { props: { amount: Number } });
|
|
115
|
+
// <pay-button amount="1000"></pay-button>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
> **[🧩 Custom Elements guide](https://superlucky84.github.io/lithent/#/guide/element)**
|
|
119
|
+
|
|
106
120
|
### Template options
|
|
107
121
|
- **JSX** — Via Vite plugin
|
|
108
122
|
- **FTags** — Function-style tags (no build step)
|
|
@@ -122,8 +136,18 @@ const Counter = lmount(() => {
|
|
|
122
136
|
| [lithent/ssr](https://www.npmjs.com/package/lithent) | Server‑side rendering |
|
|
123
137
|
| [lithent/ftags](https://www.npmjs.com/package/lithent) | Function‑style tag API |
|
|
124
138
|
| [lithent/tag](https://www.npmjs.com/package/lithent) | HTM template support |
|
|
139
|
+
| [lithent/element](./element/README.md) | Register components as Custom Elements, embeddable in any page ([guide](https://superlucky84.github.io/lithent/#/guide/element)) |
|
|
140
|
+
| [lithent-concurrent](./lithentConcurrent/README.md) | Separate core with priority scheduling and interruptible low-priority builds |
|
|
141
|
+
| [lithent-concurrent/helper](./lithentConcurrent/README.md#lithent-concurrenthelper) | Deferred state and component-local pending queries |
|
|
125
142
|
| [create-lithent](https://www.npmjs.com/package/create-lithent) | Project scaffolding tool |
|
|
126
143
|
|
|
144
|
+
For expensive component trees, select the concurrent core with an exact
|
|
145
|
+
`/^lithent$/` bundler alias. `deferRender` defers rendering while state writes
|
|
146
|
+
remain immediate; `whenIdle` waits for deferred work. Keep urgent input and
|
|
147
|
+
heavy rendering in separate components. See the [concurrent rendering
|
|
148
|
+
guide](https://superlucky84.github.io/lithent/#/guide/concurrent-rendering) and
|
|
149
|
+
[release notes](./CHANGELOG.md).
|
|
150
|
+
|
|
127
151
|
<br />
|
|
128
152
|
|
|
129
153
|
## License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lithent Agent Addon
|
|
2
2
|
|
|
3
|
-
> Version: 1.
|
|
3
|
+
> Version: 1.23.0
|
|
4
4
|
|
|
5
5
|
You are a coding agent with Lithent virtual DOM guidance enabled.
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ CODING GUIDELINES:
|
|
|
47
47
|
4. LIFECYCLE HOOKS
|
|
48
48
|
- Use `mountCallback` for setup after mount (return cleanup function)
|
|
49
49
|
- Use `updateCallback` for logic before each update
|
|
50
|
-
- Use `mountReadyCallback` for logic after
|
|
50
|
+
- Use `mountReadyCallback` for logic right after the WDom is created (before DOM insertion)
|
|
51
51
|
- Place hooks in mounter function, not in updater
|
|
52
52
|
|
|
53
53
|
5. LIST RENDERING
|
|
@@ -82,13 +82,32 @@ CODING GUIDELINES:
|
|
|
82
82
|
- Access children as third parameter in mounter function
|
|
83
83
|
- Don't modify children directly, wrap or filter them
|
|
84
84
|
|
|
85
|
+
11. CONCURRENT RENDERING (only when `lithent-concurrent` is installed or requested)
|
|
86
|
+
- Suggest it only for very large trees (thousands of rows); plain `lithent` otherwise
|
|
87
|
+
- Select the core with an exact `/^lithent$/` alias; never alias `lithent/*` subpaths
|
|
88
|
+
- Keep urgent input state and the heavy list in separate components
|
|
89
|
+
- `deferRender` runs its scope synchronously; only rendering is deferred
|
|
90
|
+
- `await nextTick()` covers sync commits; use `await whenIdle()` for deferred renders
|
|
91
|
+
- `hasPendingRender` is a query, not reactive; show pending from a sync parent
|
|
92
|
+
- No Suspense or `use()`; updateCallback's return value is not an unmount cleanup
|
|
93
|
+
|
|
94
|
+
12. CUSTOM ELEMENTS (when the user embeds UI in pages they do not own)
|
|
95
|
+
- Suggest `lithent/element`: `defineElement('my-widget', Component, { props: { amount: Number } })`
|
|
96
|
+
- Declared props are optional in the component (Boolean props are boolean); never require them
|
|
97
|
+
- Objects, arrays, functions go through properties; attributes only carry strings
|
|
98
|
+
- Use `props.host` with `emit(host, name, detail)` for events out; `host` is reserved
|
|
99
|
+
- Default is an open shadow root; ship CSS with `styles`, theme via CSS variables and `::part()`
|
|
100
|
+
- Avoid native property names (`title`, `hidden`) as props
|
|
101
|
+
|
|
85
102
|
IMPORT PATHS:
|
|
86
103
|
- Core: `import { mount, lmount, render, h, Fragment, portal, ref, nextTick } from 'lithent'`
|
|
87
104
|
- Lifecycle: `import { mountCallback, updateCallback, mountReadyCallback } from 'lithent'`
|
|
88
105
|
- Helper (manual): `import { state, store, createContext, computed, effect } from 'lithent/helper'`
|
|
89
106
|
- Helper (light): `import { lstate, lstore, createLContext } from 'lithent/helper'`
|
|
90
107
|
- Helper (utils): `import { cacheUpdate, nextTickRender, unwrapChildren } from 'lithent/helper'`
|
|
108
|
+
- Concurrent (optional): `import { deferRender, whenIdle } from 'lithent-concurrent'` and `import { deferred, ldeferred, hasPendingRender } from 'lithent-concurrent/helper'`
|
|
91
109
|
- SSR: `import { renderToString, hydration } from 'lithent/ssr'`
|
|
110
|
+
- Custom Elements: `import { defineElement, emit } from 'lithent/element'`
|
|
92
111
|
- FTags: `import { fTags, fFragment, fMount } from 'lithent/ftags'`
|
|
93
112
|
- HTM: `import { lTag } from 'lithent/tag'`
|
|
94
113
|
|
|
@@ -116,11 +135,15 @@ COMMON MISTAKES TO CATCH:
|
|
|
116
135
|
- Missing `key` prop in list iterations
|
|
117
136
|
- Calling hooks inside updater instead of mounter
|
|
118
137
|
- Mutating state directly instead of using `.value`
|
|
138
|
+
- Using `deferRender` while the urgent state and heavy list share one component
|
|
139
|
+
- Aliasing `lithent` with a prefix match so `lithent/helper` is rewritten too
|
|
119
140
|
|
|
120
141
|
REFERENCE MATERIALS (NOT PART OF BEHAVIORAL RULES):
|
|
121
142
|
|
|
122
143
|
For detailed code examples and API usage, refer to:
|
|
123
144
|
node_modules/lithent/dist/skills/lithent/SKILL.md
|
|
145
|
+
(concurrent details: node_modules/lithent/dist/skills/lithent/reference/concurrent.md)
|
|
146
|
+
(custom elements: node_modules/lithent/dist/skills/lithent/reference/element.md)
|
|
124
147
|
|
|
125
148
|
This reference material provides comprehensive examples, patterns,
|
|
126
149
|
and import references that complement the behavioral guidelines above.
|