lightview 2.2.2 → 2.3.5
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/docs/about.html +15 -12
- package/docs/api/computed.html +1 -1
- package/docs/api/effects.html +1 -1
- package/docs/api/elements.html +56 -25
- package/docs/api/enhance.html +1 -1
- package/docs/api/hypermedia.html +1 -1
- package/docs/api/index.html +1 -1
- package/docs/api/nav.html +28 -3
- package/docs/api/signals.html +1 -1
- package/docs/api/state.html +283 -85
- package/docs/assets/js/examplify.js +2 -1
- package/docs/calculator.html +427 -0
- package/docs/cdom-nav.html +2 -1
- package/docs/cdom.html +382 -113
- package/jprx/README.md +113 -72
- package/jprx/helpers/calc.js +82 -0
- package/jprx/helpers/lookup.js +39 -0
- package/jprx/helpers/math.js +4 -0
- package/jprx/helpers/state.js +21 -0
- package/jprx/index.js +3 -0
- package/jprx/package.json +2 -2
- package/jprx/parser.js +171 -89
- package/jprx/specs/expressions.json +71 -0
- package/jprx/specs/helpers.json +150 -0
- package/lightview-all.js +2375 -487
- package/lightview-cdom.js +1997 -590
- package/lightview-router.js +6 -0
- package/lightview-x.js +226 -54
- package/lightview.js +351 -42
- package/package.json +3 -1
- package/src/lightview-cdom.js +213 -315
- package/src/lightview-router.js +10 -0
- package/src/lightview-x.js +121 -1
- package/src/lightview.js +88 -16
- package/src/reactivity/signal.js +73 -29
- package/src/reactivity/state.js +84 -21
- package/start-dev.js +1 -1
- package/tests/cdom/fixtures/helpers.cdomc +24 -24
- package/tests/cdom/helpers.test.js +28 -28
- package/tests/cdom/parser.test.js +39 -114
- package/tests/cdom/reactivity.test.js +32 -29
- package/tests/jprx/spec.test.js +99 -0
- package/tests/cdom/loader.test.js +0 -125
package/docs/about.html
CHANGED
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
something that felt more like regular HTML than even HTMX does.
|
|
39
39
|
This would also require thorough and fully interactive documentation accessible via direct URLs and an SPA
|
|
40
40
|
like experience.
|
|
41
|
-
This
|
|
41
|
+
This mandated a router with at least partial "automatic" SSR—where code could execute and replace itself on
|
|
42
42
|
the server with a simple
|
|
43
|
-
DOM emulation and "have-your-cake-and-eat-it-too" single page apps that are SEO
|
|
43
|
+
DOM emulation and "have-your-cake-and-eat-it-too" single page apps that are SEO-enabled without any extra
|
|
44
44
|
work.
|
|
45
45
|
</p>
|
|
46
46
|
|
|
47
47
|
<p>
|
|
48
|
-
In today's age, the ability of an LLM to generate
|
|
49
|
-
to me.
|
|
48
|
+
In today's age, the ability of an LLM to generate cohesive applications using the library is also important
|
|
49
|
+
to me. I figured that if an LLM generated it and it followed conventional patterns, it will be able to use
|
|
50
50
|
it well and perhaps generate a little less slop.
|
|
51
51
|
</p>
|
|
52
52
|
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
combo of HTMX, Bau, and
|
|
56
56
|
Juris with no special attribute names plus HTML template literals, and an SPA router. And, give me a UI
|
|
57
57
|
component library like
|
|
58
|
-
Bau's with automatic custom
|
|
59
|
-
create SEO
|
|
58
|
+
Bau's with automatic custom element creation but don't build it from scratch. Finally, make it possible to
|
|
59
|
+
create SEO-enabled apps with no extra work." I also provided a few examples of the kind of code I wanted to
|
|
60
60
|
write
|
|
61
61
|
using the library.
|
|
62
62
|
</p>
|
|
@@ -64,16 +64,19 @@
|
|
|
64
64
|
<p>
|
|
65
65
|
Naturally, it took a little iterating, but the basic framework was in place after just a few hours of
|
|
66
66
|
working with both Claude Opus 4.5 and Gemini 3 Pro. I then asked for
|
|
67
|
-
an extensive interactive website for documenting and promoting Lightview that also used Lightview,
|
|
67
|
+
an extensive interactive website for documenting and promoting Lightview that also used Lightview, despite
|
|
68
68
|
the fact that in the age of LLM code generation the need for extensive documentation websites is limited.
|
|
69
69
|
This took a lot more work, 3
|
|
70
|
-
weeks in fact. Very little of this time was spent addressing issues with or enhancing
|
|
71
|
-
was spent adding,
|
|
72
|
-
approach that worked
|
|
73
|
-
But, that is a story for another time.
|
|
70
|
+
weeks in fact. Very little of this time was spent addressing issues with or enhancing Lightview. Most of it
|
|
71
|
+
was spent adding, debugging, and testing all the UI components. The LLM would get locked in on a particular
|
|
72
|
+
approach that worked for simple components but not more complex ones.
|
|
73
|
+
But, that is a story for another time. So, 3 weeks later I had about 2,000 lines of code for
|
|
74
74
|
Lightview
|
|
75
75
|
as a whole across three
|
|
76
|
-
files, 25,000 lines of component code, and 30,000 lines of documentation.
|
|
76
|
+
files, 25,000 lines of component code, and 30,000 lines of documentation. Lightview has grown a lot since
|
|
77
|
+
then! You can see my article about initial development after week 4 on <a
|
|
78
|
+
href="https://hackernoon.com/lightview-a-lightweight-javascript-framework-for-building-single-page-applications-1768144869105"
|
|
79
|
+
target="_blank">Hackernoon</a>.
|
|
77
80
|
</p>
|
|
78
81
|
|
|
79
82
|
<p>
|
package/docs/api/computed.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<script src="/lightview-router.js?base=/index.html"></script>
|
|
3
3
|
|
|
4
4
|
<div class="docs-layout">
|
|
5
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
5
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
6
6
|
|
|
7
7
|
<main class="docs-content">
|
|
8
8
|
<h1>Computed</h1>
|
package/docs/api/effects.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- SEO-friendly SPA Shim -->
|
|
2
2
|
<script src="/lightview-router.js?base=/index.html"></script>
|
|
3
3
|
<div class="docs-layout">
|
|
4
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
4
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
5
5
|
<main class="docs-content">
|
|
6
6
|
<h1>Effects</h1>
|
|
7
7
|
<p>
|
package/docs/api/elements.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<link rel="stylesheet" href="../components/index.css">
|
|
5
5
|
|
|
6
6
|
<div class="docs-layout">
|
|
7
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
7
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
8
8
|
|
|
9
9
|
<main class="docs-content">
|
|
10
10
|
<h1>Elements</h1>
|
|
@@ -119,9 +119,58 @@ $('#example').content(app);</code></pre>
|
|
|
119
119
|
|
|
120
120
|
<h2 id="object-dom">Object DOM (oDOM)</h2>
|
|
121
121
|
<p>
|
|
122
|
-
A more compact JSON representation provided by <strong>Lightview X</strong>.
|
|
123
|
-
|
|
122
|
+
A more compact JSON representation provided by <strong>Lightview X</strong>. In oDOM, an object with a
|
|
123
|
+
<strong>single key</strong> and an <strong>object value</strong> represents an element. The key is the
|
|
124
|
+
<strong>tag name</strong> (e.g., <code>"div"</code>, <code>"span"</code>) or a <strong>custom element
|
|
125
|
+
function name</strong>. The value object contains the element's attributes.
|
|
124
126
|
</p>
|
|
127
|
+
|
|
128
|
+
<h3>Reserved Keys</h3>
|
|
129
|
+
<p>
|
|
130
|
+
Certain keys on the value object are reserved and have special meaning instead of being treated as
|
|
131
|
+
attributes:
|
|
132
|
+
</p>
|
|
133
|
+
<table class="api-table">
|
|
134
|
+
<thead>
|
|
135
|
+
<tr>
|
|
136
|
+
<th>Key</th>
|
|
137
|
+
<th>Purpose</th>
|
|
138
|
+
</tr>
|
|
139
|
+
</thead>
|
|
140
|
+
<tbody>
|
|
141
|
+
<tr>
|
|
142
|
+
<td><code>children</code></td>
|
|
143
|
+
<td>An array of child elements, strings, or reactive functions.</td>
|
|
144
|
+
</tr>
|
|
145
|
+
<tr>
|
|
146
|
+
<td><code>attributes</code></td>
|
|
147
|
+
<td>An explicit attributes object (not needed in oDOM since non-reserved keys are attributes). If
|
|
148
|
+
you use this attribute, Lighview MAY assume you are trying to use vDOM not oDOM. Avoid its use
|
|
149
|
+
except for vDOM.
|
|
150
|
+
</td>
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
<td><code>tag</code></td>
|
|
154
|
+
<td>Explicitly sets the tag name. If you use this attribute, Lighview MAY assume you are trying to
|
|
155
|
+
use vDOM not oDOM. Avoid its use except for vDOM.</td>
|
|
156
|
+
</tr>
|
|
157
|
+
</tbody>
|
|
158
|
+
</table>
|
|
159
|
+
<p>
|
|
160
|
+
All other keys on the value object are treated as <strong>attribute names</strong>. Keys starting with
|
|
161
|
+
<code>on</code> (like <code>onclick</code>, <code>onmouseenter</code>) are bound as event handlers.
|
|
162
|
+
</p>
|
|
163
|
+
|
|
164
|
+
<h3>Array Shorthand</h3>
|
|
165
|
+
<p>
|
|
166
|
+
If a tag key has an <strong>array</strong> as its value instead of an object, it is shorthand for
|
|
167
|
+
<code>{ <key>: { children: <array> } }</code>:
|
|
168
|
+
</p>
|
|
169
|
+
<pre><code>// These are equivalent:
|
|
170
|
+
{ ul: [{ li: ['Item 1'] }, { li: ['Item 2'] }] }
|
|
171
|
+
{ ul: { children: [{ li: { children: ['Item 1'] } }, { li: { children: ['Item 2'] } }] } }</code></pre>
|
|
172
|
+
|
|
173
|
+
<h3>Example</h3>
|
|
125
174
|
<div id="syntax-object">
|
|
126
175
|
<pre><script>
|
|
127
176
|
examplify(document.currentScript.nextElementSibling, {
|
|
@@ -134,7 +183,7 @@ $('#example').content(app);</code></pre>
|
|
|
134
183
|
</script><code contenteditable="true">const { signal, tags, $ } = Lightview;
|
|
135
184
|
const count = signal(0);
|
|
136
185
|
const app = { div: { class: 'container', children: [
|
|
137
|
-
{ h1:
|
|
186
|
+
{ h1: ['Hello Lightview'] },
|
|
138
187
|
{ p: { children: [() => `Count: ${count.value}`] } },
|
|
139
188
|
{ button: { onclick: () => count.value++, children: ['Click me'] } }
|
|
140
189
|
]}};
|
|
@@ -197,27 +246,9 @@ const greeting = div(
|
|
|
197
246
|
);
|
|
198
247
|
// Initial result: <div>Hello, John Doe !</div></code></pre>
|
|
199
248
|
|
|
200
|
-
<h2 id="attributes-events">
|
|
201
|
-
<p>
|
|
202
|
-
|
|
203
|
-
</p>
|
|
204
|
-
<pre><code>// Standard attributes
|
|
205
|
-
div({
|
|
206
|
-
id: 'my-div',
|
|
207
|
-
class: 'container active',
|
|
208
|
-
style: 'color: red;',
|
|
209
|
-
'data-value': '42'
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
// Reactive attributes - use functions!
|
|
213
|
-
div({
|
|
214
|
-
class: () => isActive.value ? 'active' : 'inactive',
|
|
215
|
-
style: () => `opacity: ${visible.value ? 1 : 0}`,
|
|
216
|
-
disabled: () => isLoading.value
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
// Event handlers - use "on" prefix
|
|
220
|
-
button({
|
|
249
|
+
<h2 id="attributes-events">Events</h2>
|
|
250
|
+
<p>Use standard event handlers prefixed with "on".</p>
|
|
251
|
+
<pre><code>button({
|
|
221
252
|
onclick: (e) => handleClick(e),
|
|
222
253
|
onmouseenter: () => setHovered(true),
|
|
223
254
|
onmouseleave: () => setHovered(false)
|
package/docs/api/enhance.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<link rel="stylesheet" href="../components/index.css">
|
|
5
5
|
|
|
6
6
|
<div class="docs-layout">
|
|
7
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
7
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
8
8
|
|
|
9
9
|
<main class="docs-content">
|
|
10
10
|
<h1>Enhance</h1>
|
package/docs/api/hypermedia.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<script src="/lightview-router.js?base=/index.html"></script>
|
|
3
3
|
|
|
4
4
|
<div class="docs-layout">
|
|
5
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
5
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
6
6
|
|
|
7
7
|
<main class="docs-content">
|
|
8
8
|
<h1>Hypermedia</h1>
|
package/docs/api/index.html
CHANGED
package/docs/api/nav.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<nav class="docs-nav">
|
|
1
|
+
<nav data-preserve-scroll="docs-nav" class="docs-nav">
|
|
2
2
|
<div class="docs-nav-section">
|
|
3
3
|
<div class="docs-nav-title">Elements</div>
|
|
4
4
|
<a href="./elements.html" class="docs-nav-link">Comparison</a>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<a href="./elements.html#text" class="docs-nav-link" style="font-size: 0.85em;">text</a>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
|
-
<a href="./elements.html#attributes-events" class="docs-nav-link">
|
|
16
|
+
<a href="./elements.html#attributes-events" class="docs-nav-link">Events</a>
|
|
17
17
|
<a href="./elements.html#children" class="docs-nav-link">Children</a>
|
|
18
18
|
<a href="./elements.html#dom-el" class="docs-nav-link">The domEl Property</a>
|
|
19
19
|
</div>
|
|
@@ -28,7 +28,32 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
<div class="docs-nav-section">
|
|
30
30
|
<div class="docs-nav-title">Lightview X</div>
|
|
31
|
-
<
|
|
31
|
+
<div class="docs-nav-item">
|
|
32
|
+
<a href="./state.html" class="docs-nav-link">State (Deep Reactivity)</a>
|
|
33
|
+
<div class="docs-nav-subsection" style="margin-left: 1rem; border-left: 1px solid var(--site-border);">
|
|
34
|
+
<a href="./state.html#shortcomings" class="docs-nav-link" style="font-size: 0.85em;">Shortcomings of
|
|
35
|
+
Signals</a>
|
|
36
|
+
<a href="./state.html#state-to-the-rescue" class="docs-nav-link" style="font-size: 0.85em;">State to the
|
|
37
|
+
Rescue</a>
|
|
38
|
+
<a href="./state.html#state-function" class="docs-nav-link" style="font-size: 0.85em;">State
|
|
39
|
+
Function</a>
|
|
40
|
+
<a href="./state.html#nested-objects" class="docs-nav-link" style="font-size: 0.85em;">Nested
|
|
41
|
+
Objects</a>
|
|
42
|
+
<a href="./state.html#in-the-ui" class="docs-nav-link" style="font-size: 0.85em;">In the UI</a>
|
|
43
|
+
<a href="./state.html#array-methods" class="docs-nav-link" style="font-size: 0.85em;">Array Methods</a>
|
|
44
|
+
<a href="./state.html#date-methods" class="docs-nav-link" style="font-size: 0.85em;">Date Methods</a>
|
|
45
|
+
<a href="./state.html#named-state" class="docs-nav-link" style="font-size: 0.85em;">Named State</a>
|
|
46
|
+
<a href="./state.html#stored-state" class="docs-nav-link" style="font-size: 0.85em;">Stored State</a>
|
|
47
|
+
<a href="./state.html#schema-validation" class="docs-nav-link" style="font-size: 0.85em;">Schema
|
|
48
|
+
Validation</a>
|
|
49
|
+
<a href="./state.html#json-schema-lite" class="docs-nav-link" style="font-size: 0.85em;">JSON Schema
|
|
50
|
+
Lite</a>
|
|
51
|
+
<a href="./state.html#transformations" class="docs-nav-link"
|
|
52
|
+
style="font-size: 0.85em;">Transformations</a>
|
|
53
|
+
<a href="./state.html#lite-vs-full" class="docs-nav-link" style="font-size: 0.85em;">Lite vs. Full
|
|
54
|
+
Validators</a>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
32
57
|
<div class="docs-nav-item">
|
|
33
58
|
<a href="./hypermedia.html" class="docs-nav-link">Hypermedia</a>
|
|
34
59
|
<div class="docs-nav-subsection" style="margin-left: 1rem; border-left: 1px solid var(--site-border);">
|
package/docs/api/signals.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<script src="/lightview-router.js?base=/index.html"></script>
|
|
3
3
|
|
|
4
4
|
<div class="docs-layout">
|
|
5
|
-
<aside class="docs-sidebar" src="./nav.html"></aside>
|
|
5
|
+
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
|
|
6
6
|
|
|
7
7
|
<main class="docs-content">
|
|
8
8
|
<h1>Signals</h1>
|