lightview 2.0.1 → 2.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.
package/README.md CHANGED
@@ -1,26 +1,23 @@
1
- <!-- SEO-friendly SPA Shim -->
2
- <script src="./lightview-router.js"></script>
3
- <script>
4
- if (window.LightviewRouter) {
5
- LightviewRouter.base('index.html');
6
- }
7
- </script>
1
+
8
2
  # Lightview: README.md
9
3
 
10
4
  A lightweight reactive UI library with signal-based reactivity and a clean API. Build dynamic UIs with automatic DOM synchronization.
11
5
 
12
- Access the full documentaion at [lightview.dev](/index.html).
6
+ Access the full documentaion at [lightview.dev](https://lightview.dev).
7
+
8
+ This NPM package is both the library and the website supporting the library. The website is built using Lightview. The core library files are in the root directory. The Website entry point is index.html and the restr of the site is under ./docs. The site is served by a Cloudflare pages deployment.
13
9
 
14
- **Core**: ~6KB | **With Hypermedia Extensions and Component Library Support**: ~18KB total
10
+ **Core**: ~8KB | **With Hypermedia Extensions and Component Library Support**: ~18KB total
15
11
 
16
- Fast: This [gallery of components](/docs/components) loads in about 1 second:
12
+ Fast: This [gallery of components](https://lightview.dev/docs/components/) loads in about 1 second:
17
13
 
18
14
  ## Modular Architecture
19
15
 
20
- Lightview is split into two files:
16
+ Lightview is split into three files:
21
17
 
22
18
  - **`lightview.js`** - Core reactivity (signals, state, effects, elements)
23
19
  - **`lightview-x.js`** - Hypermedia extension (src fetching, href navigation, template literals, named registries, Object DOM syntax, UI component library support)
20
+ - **`lightview-router.js`** - Router (src fetching, href navigation, template literals, named registries, Object DOM syntax, UI component library support)
24
21
 
25
22
  ### API Behavior
26
23
 
@@ -49,6 +46,11 @@ Lightview is split into two files:
49
46
  <!-- Full features (hypermedia + templates) -->
50
47
  <script src="lightview.js"></script>
51
48
  <script src="lightview-x.js"></script>
49
+
50
+ <!-- Full features (hypermedia + templates + router) -->
51
+ <script src="lightview.js"></script>
52
+ <script src="lightview-x.js"></script>
53
+ <script src="lightview-router.js"></script>
52
54
  ```
53
55
 
54
56
  ## Core Concepts
@@ -56,11 +58,11 @@ Lightview is split into two files:
56
58
  **Lightview** provides four ways to build UIs:
57
59
 
58
60
  1. **Tagged API** - Concise, Bau.js-style syntax: `tags.div(...)`
59
- 2. **Element Function** - Explicit: `element('div', {}, [...])`
60
- 3. **vDOM Syntax** - JSON data structures: `{ tag: "div", attributes: {}, children: [] }`
61
- 4. **Object DOM Syntax** *(lightview-x)* - Compact: `{ div: { class: "foo", children: [] } }`
61
+ 2. **vDOM Syntax** - JSON data structures: `{ tag: "div", attributes: {}, children: [] }`
62
+ 3. **Object DOM Syntax** *(lightview-x)* - Compact: `{ div: { class: "foo", children: [] } }`
63
+ 4. **HTML** *(lightview-x)* - Custom HTML elements.
62
64
 
63
- All four approaches use the same underlying reactive system based on **signals**.
65
+ All four approaches use the same underlying reactive system based on **signals** and **state**.
64
66
 
65
67
  ## Installation
66
68
 
@@ -91,25 +93,7 @@ const app = div({ class: 'container' },
91
93
  document.body.appendChild(app.domEl);
92
94
  ```
93
95
 
94
- ### Style 2: Element Function
95
-
96
- ```javascript
97
- const { signal, element } = new Lightview();
98
-
99
- const count = signal(0);
100
-
101
- const app = element('div', { class: 'container' }, [
102
- element('h1', {}, ['Counter App']),
103
- element('p', {}, [() => `Count: ${count.value}`]),
104
- element('button', {
105
- onclick: () => count.value++
106
- }, ['Increment'])
107
- ]);
108
-
109
- document.body.appendChild(app.domEl);
110
- ```
111
-
112
- ### Style 3: vDOM Syntax (Plain JSON)
96
+ ### Style 2: vDOM Syntax (Plain JSON)
113
97
 
114
98
  ```javascript
115
99
  const { signal, element } = new Lightview();
@@ -138,7 +122,7 @@ const app = element('div', { class: 'container' }, [
138
122
  document.body.appendChild(app.domEl);
139
123
  ```
140
124
 
141
- ### Style 4: Object DOM Syntax (lightview-x)
125
+ ### Style 3: Object DOM Syntax (lightview-x)
142
126
 
143
127
  Object DOM syntax provides a more compact way to define elements. Instead of `{ tag, attributes, children }`, you use `{ tag: { ...attributes, children } }`.
144
128
 
@@ -142,7 +142,7 @@ const { tags, $ } = Lightview;
142
142
  const { div, h1, p, style } = tags;
143
143
 
144
144
  // 1. Build UI using Tagged Functions
145
- // These functions return standard DOM elements
145
+ // These functions return Lightview elements (access raw DOM via .domEl)
146
146
  const App = div({ class: 'hero' },
147
147
  h1('Welcome to Lightview'),
148
148
  p('Lightview is a tiny library for building modern web interfaces.')
@@ -171,11 +171,11 @@ $('#app').content(style({}, \`
171
171
 
172
172
  <h4>Key Concepts:</h4>
173
173
  <ul style="padding-left: 1.25rem; color: var(--site-text-secondary);">
174
- <li style="margin-bottom: 0.75rem;"><code>tags</code> — Every HTML tag is available as a function. <code>div(...)</code> returns a real <code>HTMLDivElement</code>.</li>
174
+ <li style="margin-bottom: 0.75rem;"><code>tags</code> — Every HTML tag is available as a function. <code>div(...)</code> returns a virtual proxy; the real DOM element is accessible via <code>.domEl</code>.</li>
175
175
  <li style="margin-bottom: 0.75rem;"><code>$(selector)</code> — A powerful utility for selecting elements and manipulating them.</li>
176
- <li style="margin-bottom: 0.75rem;"><code>.content(node, location)</code> — Replaces or appends content. Locations like <code>'beforeend'</code> allow injecting styles or scripts dynamicly.</li>
176
+ <li style="margin-bottom: 0.75rem;"><code>.content(node, location)</code> — Replaces or appends content. It automatically unboxes <code>.domEl</code> for you.</li>
177
177
  </ul>
178
- <p>This approach results in standard, lightweight DOM elements with no overhead.</p>
178
+ <p>Lightview elements are thin proxies over standard DOM elements, providing reactivity with minimal overhead.</p>
179
179
  `
180
180
  },
181
181
  2: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightview",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "A lightweight reactive UI library with features of Bau, Juris, and HTMX",
5
5
  "main": "lightview.js",
6
6
  "directories": {