lithent 1.22.1 → 1.24.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.
Files changed (72) hide show
  1. package/README.md +15 -0
  2. package/dist/lithent-agent-addon.md +11 -1
  3. package/dist/lithent.mjs +342 -332
  4. package/dist/lithent.mjs.map +1 -1
  5. package/dist/lithent.umd.js +1 -1
  6. package/dist/lithent.umd.js.map +1 -1
  7. package/dist/render.d.ts +2 -2
  8. package/dist/skills/lithent/SKILL.md +25 -3
  9. package/dist/skills/lithent/constraints/mistakes.md +1 -1
  10. package/dist/skills/lithent/constraints/rules.md +1 -1
  11. package/dist/skills/lithent/constraints/troubleshooting.md +1 -1
  12. package/dist/skills/lithent/examples/quick-examples.md +1 -1
  13. package/dist/skills/lithent/reference/children-type.md +1 -1
  14. package/dist/skills/lithent/reference/concurrent.md +1 -1
  15. package/dist/skills/lithent/reference/element.md +69 -0
  16. package/dist/skills/lithent/reference/lstore-inference.md +1 -1
  17. package/dist/skills/lithent/reference/props-types.md +1 -1
  18. package/dist/utils/index.d.ts +4 -1
  19. package/dist/utils/predicator.d.ts +1 -0
  20. package/dist/utils/redraw.d.ts +7 -1
  21. package/element/dist/index.d.ts +56 -0
  22. package/element/dist/lithentElement.mjs +99 -0
  23. package/element/dist/lithentElement.mjs.map +1 -0
  24. package/element/dist/lithentElement.umd.js +3 -0
  25. package/element/dist/lithentElement.umd.js.map +1 -0
  26. package/element/package.json +37 -0
  27. package/element/src/index.ts +295 -0
  28. package/element/src/tests/element-attributes.test.ts +176 -0
  29. package/element/src/tests/element-boundaries.test.ts +198 -0
  30. package/element/src/tests/element-events.test.ts +198 -0
  31. package/element/src/tests/element-hardening.test.ts +268 -0
  32. package/element/src/tests/element-lifecycle.test.ts +175 -0
  33. package/element/src/tests/element-move.test.ts +146 -0
  34. package/element/src/tests/element-properties.test.ts +149 -0
  35. package/element/src/tests/element-shadow.test.ts +221 -0
  36. package/element/src/tests/element-smoke.test.ts +21 -0
  37. package/element/src/tests/element-ssr.test.ts +20 -0
  38. package/element/src/tests/element-types.test.ts +104 -0
  39. package/examples/dist/assets/index-Ch4u_8Bx.js +2 -0
  40. package/examples/dist/assets/index-Ch4u_8Bx.js.map +1 -0
  41. package/examples/dist/index.html +1 -1
  42. package/helper/dist/lithentHelper.mjs +8 -8
  43. package/helper/dist/lithentHelper.mjs.map +1 -1
  44. package/helper/dist/lithentHelper.umd.js +1 -1
  45. package/helper/dist/lithentHelper.umd.js.map +1 -1
  46. package/helper/src/hook/cacheUpdate.ts +3 -1
  47. package/helper/src/tests/cacheupdate-contract.tsx +64 -0
  48. package/helper/src/tests/cacheupdate.tsx +10 -12
  49. package/package.json +16 -3
  50. package/src/diff.ts +16 -11
  51. package/src/hook/internal/unmount.ts +12 -0
  52. package/src/render.ts +68 -53
  53. package/src/tests/core-accessorUpgrade.test.tsx +288 -0
  54. package/src/tests/core-addedSubtrees.test.tsx +77 -0
  55. package/src/tests/core-cachedIdentity.test.tsx +150 -0
  56. package/src/tests/core-destroyUnmount.test.tsx +77 -0
  57. package/src/tests/core-discardedListeners.test.tsx +281 -0
  58. package/src/tests/core-portal-events.test.ts +201 -0
  59. package/src/tests/core-props-enumeration.test.ts +142 -0
  60. package/src/tests/core-updatePaths.test.tsx +242 -0
  61. package/src/utils/index.ts +18 -0
  62. package/src/utils/predicator.ts +17 -10
  63. package/src/utils/redraw.ts +24 -7
  64. package/src/wDom.ts +21 -22
  65. package/ssr/dist/lithentSsr.mjs +69 -65
  66. package/ssr/dist/lithentSsr.mjs.map +1 -1
  67. package/ssr/dist/lithentSsr.umd.js +2 -2
  68. package/ssr/dist/lithentSsr.umd.js.map +1 -1
  69. package/ssr/src/renderToString.ts +20 -3
  70. package/ssr/src/tests/renderToString.test.tsx +46 -0
  71. package/examples/dist/assets/index-oBwBT33f.js +0 -2
  72. package/examples/dist/assets/index-oBwBT33f.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,6 +136,7 @@ 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)) |
125
140
  | [lithent-concurrent](./lithentConcurrent/README.md) | Separate core with priority scheduling and interruptible low-priority builds |
126
141
  | [lithent-concurrent/helper](./lithentConcurrent/README.md#lithent-concurrenthelper) | Deferred state and component-local pending queries |
127
142
  | [create-lithent](https://www.npmjs.com/package/create-lithent) | Project scaffolding tool |
@@ -1,6 +1,6 @@
1
1
  # Lithent Agent Addon
2
2
 
3
- > Version: 1.22.1
3
+ > Version: 1.24.0
4
4
 
5
5
  You are a coding agent with Lithent virtual DOM guidance enabled.
6
6
 
@@ -91,6 +91,14 @@ CODING GUIDELINES:
91
91
  - `hasPendingRender` is a query, not reactive; show pending from a sync parent
92
92
  - No Suspense or `use()`; updateCallback's return value is not an unmount cleanup
93
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
+
94
102
  IMPORT PATHS:
95
103
  - Core: `import { mount, lmount, render, h, Fragment, portal, ref, nextTick } from 'lithent'`
96
104
  - Lifecycle: `import { mountCallback, updateCallback, mountReadyCallback } from 'lithent'`
@@ -99,6 +107,7 @@ IMPORT PATHS:
99
107
  - Helper (utils): `import { cacheUpdate, nextTickRender, unwrapChildren } from 'lithent/helper'`
100
108
  - Concurrent (optional): `import { deferRender, whenIdle } from 'lithent-concurrent'` and `import { deferred, ldeferred, hasPendingRender } from 'lithent-concurrent/helper'`
101
109
  - SSR: `import { renderToString, hydration } from 'lithent/ssr'`
110
+ - Custom Elements: `import { defineElement, emit } from 'lithent/element'`
102
111
  - FTags: `import { fTags, fFragment, fMount } from 'lithent/ftags'`
103
112
  - HTM: `import { lTag } from 'lithent/tag'`
104
113
 
@@ -134,6 +143,7 @@ REFERENCE MATERIALS (NOT PART OF BEHAVIORAL RULES):
134
143
  For detailed code examples and API usage, refer to:
135
144
  node_modules/lithent/dist/skills/lithent/SKILL.md
136
145
  (concurrent details: node_modules/lithent/dist/skills/lithent/reference/concurrent.md)
146
+ (custom elements: node_modules/lithent/dist/skills/lithent/reference/element.md)
137
147
 
138
148
  This reference material provides comprehensive examples, patterns,
139
149
  and import references that complement the behavioral guidelines above.