@lmjs/cli 2.8.6 → 2.9.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/dist/lib/files/project/AGENTS.md +374 -25
- package/package.json +2 -2
|
@@ -1,40 +1,389 @@
|
|
|
1
1
|
# AGENTS.md — LumenJS project
|
|
2
2
|
|
|
3
|
-
This is a **LumenJS V2** project (`@lmjs/cli` + `@lmjs/core`). LumenJS is not Vue
|
|
4
|
-
|
|
3
|
+
This is a **LumenJS V2** project (`@lmjs/cli` + `@lmjs/core`), written against **2.8.6**. LumenJS is not Vue and
|
|
4
|
+
not React: no virtual DOM, no components, no props. A view is HTML with `{{ }}` expressions; every top-level
|
|
5
|
+
`var`/`let`/`const` in its `<script>` is reactive; navigating swaps the rendered view.
|
|
6
|
+
|
|
7
|
+
Read before changing any `.view`:
|
|
5
8
|
|
|
6
9
|
- Short guide: https://lumenjs.com/llms.txt
|
|
7
10
|
- Full reference: https://lumenjs.com/llms/lumenjs.txt
|
|
11
|
+
- This file is also published at https://lumenjs.com/AGENTS.md
|
|
12
|
+
|
|
13
|
+
## The four roots
|
|
14
|
+
|
|
15
|
+
Everything on the page belongs to exactly one of these, and they are siblings, not nested:
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
1. **Layout** — `src/layouts/<name>.layout`: the shell. Holds widget regions, the view's body, and slots.
|
|
18
|
+
Its own `<style>` block styles the shell.
|
|
19
|
+
2. **Widgets** — `src/views/widgets/<region>.view`: one persistent mount per region, kept (with its variables
|
|
20
|
+
and DOM) across navigation. Put anything that must not flicker there: nav, sidebar, chat list, cart.
|
|
21
|
+
3. **View** — the route's view (`src/views/<name>.view`) and any sub-views it mounts. A sub-view has its own
|
|
22
|
+
variables; it is rebuilt every time its host renders.
|
|
23
|
+
4. **Global** — `globals` (localStorage-backed), `cookies`, and whatever `src/index.js` sets up.
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
## Folder layout
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/index.html the page: <div app></div>
|
|
29
|
+
src/index.js start-up: Reactor({...}), helpers, auth
|
|
30
|
+
src/layouts/*.layout shells: public.layout, app.layout ...
|
|
31
|
+
src/views/*.view routes and sub-views
|
|
32
|
+
src/views/widgets/*.view persistent regions of a layout
|
|
33
|
+
src/tpls/*.tpl row templates (tpl="name" on a :for element)
|
|
34
|
+
src/css/, src/images/ assets
|
|
35
|
+
src/js/lm.js the runtime, copied in — never edit it
|
|
36
|
+
```
|
|
15
37
|
|
|
16
38
|
## Commands
|
|
17
39
|
|
|
18
|
-
- `lm serve`: dev server. `lm build`: production build into `dist
|
|
19
|
-
`dist/` using `config.json`'s `ftp
|
|
40
|
+
- `lm serve`: dev server. `lm build`: production build into `dist/` (it writes the release into a
|
|
41
|
+
`<meta name="generator">` tag). `lm build --deploy`: build, then upload `dist/` using `config.json`'s `ftp`.
|
|
20
42
|
- `lm create -v name` / `-s name` / `-t name`: new view / sub-view / layout.
|
|
43
|
+
- `lm update-core` after upgrading `@lmjs/cli`: refreshes `src/js/lm.js`.
|
|
21
44
|
- Pin a version without a global install: `npx -y -p @lmjs/cli@<version> lm <command>`.
|
|
45
|
+
- Never put API secrets in `config.json`. Use `lm login` + `lm api set <name>`.
|
|
22
46
|
|
|
23
|
-
## Rules that are easy to get wrong
|
|
24
47
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
## src/index.js — start-up
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
Reactor({
|
|
52
|
+
App: '[app]', // the container in index.html
|
|
53
|
+
defaultView: 'new_chat', // what '/' renders
|
|
54
|
+
authView: 'public_chat', // shown in place of a requireAuth view when nobody is signed in
|
|
55
|
+
auth: function () { return AI.auth.user(); }, // asked on every render; falsy = signed out
|
|
56
|
+
init: function () { /* once, before the first render; `nodes` is ready here */ },
|
|
57
|
+
tick: function () { },
|
|
58
|
+
updateCheck: true // false = no built-in "new version, reload" bar
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Keys: `App`, `defaultView`, `authView`, `auth`, `init`, `tick`, `updateCheck`, `Base` (serve under a
|
|
63
|
+
sub-path), `subDirectory`.
|
|
64
|
+
|
|
65
|
+
## Routing: `nodes[]`
|
|
66
|
+
|
|
67
|
+
`nodes` is the URL path split on `/`. `/` gives `nodes[0] = defaultView`. **Only `nodes[0]` picks the view
|
|
68
|
+
file** — the rest of the path is yours to read:
|
|
69
|
+
|
|
70
|
+
- `/c/abc123` → `nodes = ['c', 'abc123']` → renders `src/views/c.view`, and the chat id is `nodes[1]`.
|
|
71
|
+
- `?q=1` → `View.params` (`{q: '1'}`) in the rendered view.
|
|
72
|
+
- `pushURL(path, data)` → the target view's `View.props` is `data`.
|
|
73
|
+
- `#fragment` only scrolls to an element; never route on it.
|
|
74
|
+
- Aliases are fine: rewrite `nodes[0]` in `init()` before the first render (`download` → `desktop`).
|
|
75
|
+
- Keep the state that identifies what you show (chat, product, order) **in the URL**, never in a global.
|
|
76
|
+
|
|
77
|
+
## Links and pushURL
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<a href="/c/{{ objectId }}" n1="{{ objectId }}">{{ title }}</a>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
An in-app `href` is intercepted and pushed as a route. `target="_blank"` and `http(s)://` links leave the app.
|
|
84
|
+
From a script: `pushURL('/c/' + id)`, `pushURL('/c/' + id, {from: 'list'})`. A page change scrolls to the top
|
|
85
|
+
by itself (2.6.4+) — don't add your own; `st(selector)` scrolls inside a page.
|
|
86
|
+
|
|
87
|
+
## Views and sub-views
|
|
88
|
+
|
|
89
|
+
`src/views/x.view` is the route `/x`. Its first child may be a settings block:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
<settings>
|
|
93
|
+
layout: app,
|
|
94
|
+
requireAuth: true
|
|
95
|
+
</settings>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`layout` picks the layout file; `requireAuth` asks the auth gate (below); `hasNav`/`hasHeader`/`hasFooter`/
|
|
99
|
+
`has<Region>` override the layout's widget regions.
|
|
100
|
+
|
|
101
|
+
A sub-view is an element with `view="name"`: it renders `src/views/name.view` with **its own** variables, and
|
|
102
|
+
is rebuilt every time its host renders. Hand it data at creation with `@init`:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<div view="chatbox" @init="chatData"></div>
|
|
106
|
+
<script>
|
|
107
|
+
function chatData() { return { chatId: nodes[1] }; }
|
|
108
|
+
</script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The handler's plain-object return is merged into that instance's variables, synchronously (a Promise is not
|
|
112
|
+
awaited), and it is one-way: a sub-view cannot write its parent's variables. Reading a parent variable by
|
|
113
|
+
name needs no syntax at all.
|
|
114
|
+
|
|
115
|
+
## Layouts
|
|
116
|
+
|
|
117
|
+
- `<settings> layout: app </settings>` → `src/layouts/app.layout`. No line → `default`. A project with no
|
|
118
|
+
`src/layouts/` gets the V1 shell (nav/header/body/footer).
|
|
119
|
+
- The layout is re-rendered only when its name changes; widget regions are reattached, never re-rendered.
|
|
120
|
+
That is what makes layout switching the natural sign-in mechanism: public views ask for `public`,
|
|
121
|
+
signed-in views for `app`.
|
|
122
|
+
- `<main body></main>` receives the view. `<nav nav>`, `<aside sidebar>` are widget regions.
|
|
123
|
+
`<div slot="side"></div>` receives the view's `<slot name="side">`.
|
|
124
|
+
- Style the shell in the layout's own `<style>`, with logical CSS (`margin-inline`, `padding-inline`,
|
|
125
|
+
`text-align: start`) so `dir="rtl"` mirrors the whole thing.
|
|
126
|
+
|
|
127
|
+
## Widgets (persistent regions)
|
|
128
|
+
|
|
129
|
+
- A **bare attribute** on a layout element declares a region: `<nav nav>`, `<aside sidebar>`, `<footer footer>`.
|
|
130
|
+
The region `sidebar` is filled from `src/views/widgets/sidebar.view`.
|
|
131
|
+
- Per view: `hasSidebar: false` empties the region, `hasSidebar: "sidebar2"` uses
|
|
132
|
+
`src/views/widgets/sidebar2.view`, and leaving it out means `true`.
|
|
133
|
+
- A widget is mounted **once per region** and keeps its variables and DOM across navigation; after a layout
|
|
134
|
+
swap its existing nodes are reattached, not re-rendered. Anything that must not flicker (nav, chat list,
|
|
135
|
+
cart, filters) belongs in a widget.
|
|
136
|
+
- Widgets and the view are siblings: a widget never sees a view's variables. Share through `globals`, the
|
|
137
|
+
URL (`nodes`), or a small API call the widget makes itself.
|
|
138
|
+
|
|
139
|
+
## Slots
|
|
140
|
+
|
|
141
|
+
`<slot name="side">…</slot>` inside a view is injected into the layout's `[slot="side"]` element, after its
|
|
142
|
+
default content — the way one view adds a right pane or a toolbar to the shell without changing the layout.
|
|
143
|
+
|
|
144
|
+
## Templates
|
|
145
|
+
|
|
146
|
+
`tpl="name"` works **only on a `:for` element** and renders `src/tpls/name.tpl` per row (V1 projects may keep
|
|
147
|
+
templates in `src/comps/`). `comp=` no longer exists.
|
|
148
|
+
|
|
149
|
+
## State
|
|
150
|
+
|
|
151
|
+
- Top-level `var`/`let`/`const` in a view, sub-view or layout `<script>` is reactive. There is no `bind=`.
|
|
152
|
+
- `{{ }}` re-renders when a variable **named in it** changes: `{{ items.length }}` updates, `{{ total() }}`
|
|
153
|
+
goes stale if `total()` reads `items` internally.
|
|
154
|
+
- `watch = { myVar: function () { … } }` runs a callback per variable.
|
|
155
|
+
- `globals` is the persisted, localStorage-backed store; `cookies` for small values. A nested mutation
|
|
156
|
+
(`globals.x.y = 1`) needs `touch('x')` to fire a re-render; reassigning the variable does it too.
|
|
157
|
+
- `{{ }}` output is rendered as HTML, not text: escape anything that came from a user.
|
|
158
|
+
- Directives: `:if` / `:else-if` / `:else`, `:for="list as item"` (with `:for-limit`, `:for-offset`, `:for-if`).
|
|
159
|
+
Attribute order is priority: `<i :if="a" :for="xs as x">` gates the loop, `<i :for="xs as x" :if="x.on">`
|
|
30
160
|
filters rows.
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
161
|
+
- Changing the loop variable (`@click="t.done = !t.done"`) writes back into the list when the list is a
|
|
162
|
+
variable (2.5.5+). Looping over a computed list (`todos.filter(...)`) gives copies.
|
|
163
|
+
|
|
164
|
+
## Events — every one is built in
|
|
165
|
+
|
|
166
|
+
`@event="fn"` calls `fn(ev, el)`; `el` is the wrapped element (`el.hasClass(...)`, `el.addClass(...)`,
|
|
167
|
+
`el[0]` for the DOM node). **This is the whole list** — a name that is not here does not fire. Every one comes with an
|
|
168
|
+
example, below the table (the full reference is https://lumenjs.com/llms.txt §6.3).
|
|
169
|
+
|
|
170
|
+
| Attribute | Fires |
|
|
171
|
+
|---|---|
|
|
172
|
+
| `@click` | click **or** tap (a tap runs it once, never twice) |
|
|
173
|
+
| `@tap` | a real tap (touch only) |
|
|
174
|
+
| `@dblclick` / `@dbltap` | double click / double tap |
|
|
175
|
+
| `@singleclick` / `@singletap` | a click that was not a double |
|
|
176
|
+
| `@taphold` / `@clickhold` | a held press |
|
|
177
|
+
| `@click2` / `@tap2`, `@click2hold` / `@tap2hold` | two-finger tap, two fingers held |
|
|
178
|
+
| `@tap-start`, `@tap-move`, `@tap-end` | finger down, moving, lifted |
|
|
179
|
+
| `@swipe`, `@swipe-up`, `@swipe-down`, `@swipe-left`, `@swipe-right`, `@swipe-end` | the gesture, on the element that receives it |
|
|
180
|
+
| `@mouse-over` `@mouse-out` `@mouse-enter` `@mouse-leave` `@mouse-move` `@mouse-down` `@mouse-up` | mouse, hyphenated (`@mouse-over`, never `@mouseover`); down/up answer touch too |
|
|
181
|
+
| `@scroll` | every scroll event, the page's included |
|
|
182
|
+
| `@scroll-start` / `@scroll-end` | the first / last scroll of a burst (150 ms of quiet between them) |
|
|
183
|
+
| `@scroll-top` `@scroll-bottom` `@scroll-left` `@scroll-right` | that edge was reached (checked at `@scroll-end`) |
|
|
184
|
+
| `@input` `@change` `@focus` `@blur` `@keyup` `@keydown` | form and keys; a form submits through `o-sub`, there is no `@submit` |
|
|
185
|
+
| `@click-toggled` | after a `tgl` / `t` / `actv` / `actvt` element, or the `.navTgl` drawer button, applied its class change |
|
|
186
|
+
| `@modal-open` `@modal-close` `@modal-beforeclose` | modals; `return false` in beforeclose keeps it open |
|
|
187
|
+
| `@browse-files` `@files-added` `@queue-changed` `@file-removed` `@upload-start` `@file-uploaded` `@upload-progress` `@upload-complete` `@upload-stop` `@queue-empty` | the `up` uploader |
|
|
188
|
+
| `@drag` `@drag-start` `@drag-stop` `@drop` `@sort` `@sort-start` `@sort-update` `@sort-change` `@sort-stop` `@sort-before-stop` | drag/sort, with `ui` as the third argument and the bare `drag`/`sort` attribute on the element |
|
|
189
|
+
| `@sl-select` / `@sl-unselect` | Select2, called `(ev, el, data)` |
|
|
190
|
+
| `@init` | a sub-view's entry point; returns its starting data |
|
|
191
|
+
| `@before-render` / `@after-render` | around a `:if` / `:for` / `:else` render, and `@after-render` on mount |
|
|
192
|
+
| `@orientationchange` | the phone was rotated |
|
|
193
|
+
| `@before-<event>` | a guard that runs first; `return false` cancels the real handler |
|
|
194
|
+
|
|
195
|
+
Modifiers chain onto the attribute: `@click.stop` (preventDefault first), `@click.up` (let it bubble),
|
|
196
|
+
`@click.confirm` / `@click.econfirm="Delete this?"`, `@click.acl="mayRun"`, `@click.rcl="afterwards"`.
|
|
197
|
+
A bare `stop` attribute stops propagation for every handler on the element.
|
|
198
|
+
|
|
199
|
+
Every one, with an example:
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<!-- click and tap: @click answers the finger too, so a tap never runs twice -->
|
|
203
|
+
<button @click="save">Save</button>
|
|
204
|
+
<a @tap="open(nodes[1])">Open</a>
|
|
205
|
+
<img @dblclick="zoom" @dbltap="zoom" src="/card.png">
|
|
206
|
+
<li @singleclick="pick(ev, el)" @singletap="pick(ev, el)">one, not two</li>
|
|
207
|
+
<div @taphold="confirmDelete(ev, el)" @clickhold="confirmDelete(ev, el)">hold to delete</div>
|
|
208
|
+
<div @click2="zoom(ev)" @tap2="zoom(ev)">two fingers</div>
|
|
209
|
+
<div @click2hold="menu(ev)" @tap2hold="menu(ev)">two fingers, held</div>
|
|
210
|
+
<div @tap-start="track(ev)" @tap-move="track(ev)" @tap-end="drop(ev)">draw</div>
|
|
211
|
+
|
|
212
|
+
<!-- swipe: on the element that receives the gesture -->
|
|
213
|
+
<aside sidebar @swipe-left="closeDrawer" @swipe-right="openDrawer" @swipe-end="settle(ev)">…</aside>
|
|
214
|
+
<div class="card" @swipe="onSwipe(ev)" @swipe-up="next()" @swipe-down="prev()">…</div>
|
|
215
|
+
|
|
216
|
+
<!-- mouse: hyphenated, never @mouseover; down and up answer touch as well -->
|
|
217
|
+
<div class="card" @mouse-enter="el.addClass('lit')" @mouse-leave="el.removeClass('lit')">…</div>
|
|
218
|
+
<td @mouse-over="hint(row)" @mouse-out="hint(null)" @mouse-move="follow(ev)">…</td>
|
|
219
|
+
<div @mouse-down="grab(ev)" @mouse-up="release(ev)">…</div>
|
|
220
|
+
|
|
221
|
+
<!-- scroll: el is what scrolled; the page's own scroll arrives with el = <html> -->
|
|
222
|
+
<div class="chat" @scroll-start="pinned = false" @scroll-bottom="pinned = true">…</div>
|
|
223
|
+
<div class="list" @scroll="el.hasClass('moved') || el.addClass('moved')">…</div>
|
|
224
|
+
<div class="feed" @scroll-end="save()" @scroll-top="refresh()">…</div>
|
|
225
|
+
<div class="strip" @scroll-left="prev()" @scroll-right="next()">…</div>
|
|
226
|
+
|
|
227
|
+
<!-- forms and keys: there is no @submit, a form submits through o-sub -->
|
|
228
|
+
<input @input="search(ev.target.value)" @change="commit(ev.target.value)"
|
|
229
|
+
@focus="el.addClass('on')" @blur="el.removeClass('on')"
|
|
230
|
+
@keyup="onEsc(ev)" @keydown="onTab(ev)">
|
|
231
|
+
|
|
232
|
+
<!-- toggle: the class is already applied when the handler runs -->
|
|
233
|
+
<button class="navTgl" @click-toggled="if (el.hasClass('on')) loadPane()">Menu</button>
|
|
234
|
+
|
|
235
|
+
<!-- modal: a beforeclose handler that returns false keeps it open -->
|
|
236
|
+
<button modal="sheet" @modal-open="loadSheet()">Details</button>
|
|
237
|
+
<button close-modal @modal-close="cleanup()">×</button>
|
|
238
|
+
<button close-modal @modal-beforeclose="keepOpenIfDirty">Close</button>
|
|
239
|
+
|
|
240
|
+
<!-- uploader, the up element: the file list is the third argument -->
|
|
241
|
+
<div up @browse-files="browse(ev, el, files)" @files-added="added(ev, el, files)"
|
|
242
|
+
@queue-changed="sync(ev, el, files)" @file-removed="removed(ev, el, files)">
|
|
243
|
+
<div drpzn @drop="dropped(ev, el, files)">Drop files</div>
|
|
244
|
+
</div>
|
|
245
|
+
<div up @upload-start="busy(true)" @upload-progress="progress(ev, el, files)"
|
|
246
|
+
@file-uploaded="done(ev, el, files)" @upload-complete="busy(false)"
|
|
247
|
+
@upload-stop="busy(false)" @queue-empty="idle()">…</div>
|
|
248
|
+
|
|
249
|
+
<!-- drag and sort: ui is the third argument, the bare attribute marks the element -->
|
|
250
|
+
<div drag @drag-start="grab(ev, el, ui)" @drag="move(ev, el, ui)" @drag-stop="rest(ev, el, ui)">…</div>
|
|
251
|
+
<div sort @sort-start="lock()" @sort-update="preview(ev, el, ui)" @sort-change="saveOrder(ev, el, ui)"
|
|
252
|
+
@sort-stop="unlock()" @sort-before-stop="keepOrder">…</div>
|
|
253
|
+
|
|
254
|
+
<!-- Select2 -->
|
|
255
|
+
<select sl multiple @sl-select="tagged(ev, el, data)" @sl-unselect="untagged(ev, el, data)">…</select>
|
|
256
|
+
|
|
257
|
+
<!-- lifecycle: @init hands a sub-view its starting data, as a returned object -->
|
|
258
|
+
<div view="chatbox" @init="chatData"></div>
|
|
259
|
+
<div :if="open" @before-render="measure" @after-render="focusFirst">…</div>
|
|
260
|
+
<div :for="rows as row" @after-render="wireChart">…</div>
|
|
261
|
+
|
|
262
|
+
<!-- device -->
|
|
263
|
+
<flx @orientationchange="relayout()">…</flx>
|
|
264
|
+
|
|
265
|
+
<!-- guard: runs first, return false cancels the real handler -->
|
|
266
|
+
<button @before-click="isDirty" @click="go">Continue</button>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Server data
|
|
270
|
+
|
|
271
|
+
- `API.get(url)`, `API.post(url, data)`, `API.put`, `API.patch`, `API.delete` — all promises.
|
|
272
|
+
- `LIVE` is the runtime's live socket (advanced); `cl()` is `console.log`.
|
|
273
|
+
|
|
274
|
+
## Auth — the built-in gate, no `/signin` route
|
|
275
|
+
|
|
276
|
+
- `Reactor({ auth: fn, authView: 'name' })`; `auth()` is asked on every render and returns the signed-in
|
|
277
|
+
person or something falsy.
|
|
278
|
+
- A view whose settings say `requireAuth` and a falsy answer is **not rendered**: the runtime renders
|
|
279
|
+
`authView` in its place, **with the URL unchanged**, and passes `View.props = {redirect: nodes[0], data}`.
|
|
280
|
+
- `authView` must not itself require auth — it is the public page (sign-in card, marketing content).
|
|
281
|
+
- After a successful sign-in, navigate again to the path that is already in the address bar, so the whole
|
|
282
|
+
route survives:
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
pushURL(location.pathname.replace(/^\/+/, '')); // '/c/abc' → c.view with nodes[1] = 'abc'
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Never `pushURL(View.props.redirect)`: that is only `nodes[0]` and drops the id.
|
|
289
|
+
|
|
290
|
+
## Active nav: `n0` – `n9`
|
|
291
|
+
|
|
292
|
+
Put `nK="value"` on any element. After **every** render the runtime compares `nodes[K]` with the attribute
|
|
293
|
+
and adds the class `active` on a match, removes it otherwise:
|
|
294
|
+
|
|
295
|
+
```html
|
|
296
|
+
<nav>
|
|
297
|
+
<a href="/services" n0="services">Services</a>
|
|
298
|
+
<a href="/account" n0="account">Account</a>
|
|
299
|
+
</nav>
|
|
300
|
+
<aside>
|
|
301
|
+
<a href="/c/{{ objectId }}" n1="{{ objectId }}">{{ title }}</a>
|
|
302
|
+
</aside>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
- Several values are allowed: `n1="abc,def"`.
|
|
306
|
+
- It runs over the whole document on every navigation, so layout and widget links stay correct without code.
|
|
307
|
+
- It only sets the class `active` — style `.active` yourself.
|
|
308
|
+
|
|
309
|
+
## Events and directives
|
|
310
|
+
|
|
311
|
+
`@event="handler"` binds a DOM event to a function defined in the file's `<script>`; `@init` is the sub-view
|
|
312
|
+
data hook (above), and `@before-render` / `@after-render` run around a render.
|
|
313
|
+
|
|
314
|
+
| Attribute | What it does |
|
|
315
|
+
|---|---|
|
|
316
|
+
| `t="css"` / `tcn="cls"` | click toggles class `active` (or `cls`) on the matching element(s) |
|
|
317
|
+
| `tgl="cls"` | click toggles `cls` (plus `toggled`) on the element itself |
|
|
318
|
+
| `actv="css"` | click: remove `active` from `css`, add it here — use for tab bars |
|
|
319
|
+
| `actvt="css"` | same, but this element toggles |
|
|
320
|
+
| `acl="css"` / `aclcn="cls"` | click adds a class (default `active`) |
|
|
321
|
+
| `rcl="css"` / `rclcn="cls"` | click removes it; with both, attribute order decides the winner |
|
|
322
|
+
| `h="css"` / `s="css"` | hide / show matching elements (order matters) |
|
|
323
|
+
| `stop` | stop the event from bubbling |
|
|
324
|
+
| `confirm="text"` / `econfirm="js"` | ask before acting / run JS before acting |
|
|
325
|
+
| `ctc="css"` | copy that element's text to the clipboard |
|
|
326
|
+
| `st="css"` | scroll to the element (smooth) |
|
|
327
|
+
| `:hover="css"` | inline style while hovered or touched |
|
|
328
|
+
| `alert="text"` (`alert-type`, `alert-icon`) | show a notice |
|
|
329
|
+
| `modal="id"` (`modal-title`, `modal-description`, `modal-icon`, `modal-align`, `modal-spacing`, `modal-ov`, `modal-class`) | open a modal; hooks `@modal-open`, `@modal-close`, `@modal-beforeclose` |
|
|
330
|
+
| `ci="css"` | collect the named fields of the closest form |
|
|
331
|
+
|
|
332
|
+
## Loaders and the update notice
|
|
333
|
+
|
|
334
|
+
`_loader.show()` / `_loader.hide()` for the full-screen wait state, `wait()` / `resume()` around long work,
|
|
335
|
+
`lmCheckForUpdate()` forces the built-in check. With `updateCheck` on, the runtime notices a new build and
|
|
336
|
+
offers a reload by itself — don't build your own.
|
|
337
|
+
|
|
338
|
+
## Built-in features (from `@lmjs/core` 2.8.6)
|
|
339
|
+
|
|
340
|
+
App lifecycle: `Reactor` (App, defaultView, authView, auth, init, tick, updateCheck, Base, subDirectory),
|
|
341
|
+
`globals`, `cookies`, `touch()`, `watch`.
|
|
342
|
+
|
|
343
|
+
Routing and navigation: `nodes[]`, `View.params`, `View.props`, `pushURL()`, in-app `<a href>`, automatic
|
|
344
|
+
scroll-to-top on a page change, `st()`, `#fragment` scrolling, `defaultView`, `init()` aliases.
|
|
345
|
+
|
|
346
|
+
Structure: layouts (`src/layouts`), views (`src/views`), sub-views (`view=`), widget regions
|
|
347
|
+
(`src/views/widgets`, `has<Region>`), slots, templates (`src/tpls`, `tpl=` on `:for`), the V1 fallback shell.
|
|
348
|
+
|
|
349
|
+
Rendering: `{{ }}` expressions, reactive top-level variables, `:if` / `:else-if` / `:else`, `:for` with
|
|
350
|
+
`as`, `:for-limit`, `:for-offset`, `:for-if`, HTML output from values, attribute-order priority.
|
|
351
|
+
|
|
352
|
+
Interaction: `@events`, `t` / `tcn`, `tgl`, `actv` / `actvt`, `acl` / `rcl` (+`cn`), `h` / `s`, `stop`,
|
|
353
|
+
`confirm` / `econfirm`, `ctc`, `st`, `:hover`, `alert*`, modals with their hooks, `ci`.
|
|
354
|
+
|
|
355
|
+
Data and platform: `API.get/post/put/patch/delete`, `LIVE`, `cl()`, `_loader.show/hide`, `wait()` / `resume()`,
|
|
356
|
+
`lmCheckForUpdate()`, `updateCheck`, the built-in update bar, `<meta name="generator">` with the release.
|
|
357
|
+
|
|
358
|
+
Auth: `requireAuth`, `authView`, `auth()`, `View.props.redirect`, no page reload.
|
|
359
|
+
|
|
360
|
+
## Gone in V2 — never use
|
|
361
|
+
|
|
362
|
+
- `bind=` — top-level variables are reactive by themselves.
|
|
363
|
+
- `comp=` — removed in 2.4.1; use `tpl=` (row templates) or `view=` (sub-views).
|
|
364
|
+
- `:data="name"` — sub-view data goes in through `@init` returning an object.
|
|
365
|
+
- `session` — does not exist; use `sessionStorage`.
|
|
366
|
+
- `data-into` — dead code, it does nothing.
|
|
367
|
+
|
|
368
|
+
## Rules that are easy to get wrong
|
|
369
|
+
|
|
370
|
+
- `nodes[0]` picks the view file and nothing else does: `/c/abc` is `c.view` with `nodes[1]`; there is no
|
|
371
|
+
nested route table.
|
|
372
|
+
- A widget keeps its state across navigation — never put "which chat is open" in a widget variable; read
|
|
373
|
+
`nodes[1]`.
|
|
374
|
+
- A sub-view is rebuilt on every host render and has its own variables: read `nodes` inside it instead of
|
|
375
|
+
passing the id down where you can.
|
|
376
|
+
- After sign-in, re-navigate to `location.pathname`, not to `View.props.redirect`.
|
|
377
|
+
- `{{ }}` output is HTML; escape user text.
|
|
378
|
+
- A `{{ }}` only listens to the variables named inside it.
|
|
379
|
+
- `tpl=` only on a `:for` element.
|
|
380
|
+
- Use `?query` for state that must survive a reload; `#fragments` only scroll.
|
|
381
|
+
- One `active` class is shared by `n0`-`n9` and the `t`/`actv`/`acl` directives — use `active` in your CSS.
|
|
382
|
+
- Never put API secrets in `config.json`; `lm login` + `lm api set <name>`.
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
Published for outside agents: this file ships into every project `lm create` makes (`lm update-core` adds it
|
|
387
|
+
to an existing one). Online, condensed: https://lumenjs.com/llms.txt. Online, long form with the source
|
|
388
|
+
references: https://lumenjs.com/llms/lumenjs.txt, **§14 "App shells"**.
|
|
389
|
+
Written against `@lmjs/core` 2.8.6 — check `lm --version` before relying on a version-specific detail.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmjs/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Command line interface for LumenJS — scaffold, develop, and build LumenJS applications. LumenJS is a tiny, fast reactive JavaScript framework for building web applications and interfaces with standard HTML, CSS, and JavaScript.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lm": "./dist/bin/commands.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"ora": "^6.1.2",
|
|
53
53
|
"semver": "^7.3.7",
|
|
54
54
|
"ws": "^8.8.1",
|
|
55
|
-
"@lmjs/core": "2.
|
|
55
|
+
"@lmjs/core": "2.9.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=18.0.0"
|