@loadbare/app 0.18.2 → 0.19.1
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 +17 -17
- package/dist/build/assemble.d.ts +7 -1
- package/dist/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +81 -11
- package/dist/build/assemble.js.map +1 -1
- package/dist/build/cli.d.ts +3 -0
- package/dist/build/cli.d.ts.map +1 -1
- package/dist/build/cli.js +6 -1
- package/dist/build/cli.js.map +1 -1
- package/dist/build/declared.d.ts +25 -0
- package/dist/build/declared.d.ts.map +1 -0
- package/dist/build/declared.js +62 -0
- package/dist/build/declared.js.map +1 -0
- package/dist/build/pages.d.ts +6 -0
- package/dist/build/pages.d.ts.map +1 -1
- package/dist/build/pages.js +32 -12
- package/dist/build/pages.js.map +1 -1
- package/docs/comparison.md +697 -484
- package/docs/departures.md +63 -0
- package/docs/miswarts.md +140 -0
- package/docs/opinions.md +155 -0
- package/docs/reference/builder.md +20 -4
- package/docs/reference/chrome.md +45 -10
- package/docs/reference/css.md +0 -1
- package/docs/reference/custom-elements.md +3 -25
- package/docs/reference/data-binding.md +265 -48
- package/docs/reference/names.md +250 -0
- package/docs/reference/overview.md +6 -0
- package/docs/reference/page-files.md +77 -9
- package/docs/reference/server.md +54 -1
- package/docs/roadmap.md +55 -43
- package/docs/testing.md +62 -28
- package/docs/theory.md +348 -108
- package/docs/tutorials/040-displaying-data.md +1 -1
- package/package.json +1 -1
- package/skills/loadbare-app/SKILL.md +19 -13
- package/skills/loadbare-app/references/builder.md +20 -4
- package/skills/loadbare-app/references/chrome.md +45 -10
- package/skills/loadbare-app/references/css.md +0 -1
- package/skills/loadbare-app/references/custom-elements.md +3 -25
- package/skills/loadbare-app/references/data-binding.md +265 -48
- package/skills/loadbare-app/references/miswarts.md +140 -0
- package/skills/loadbare-app/references/names.md +250 -0
- package/skills/loadbare-app/references/overview.md +6 -0
- package/skills/loadbare-app/references/page-files.md +77 -9
- package/skills/loadbare-app/references/server.md +54 -1
- package/docs/TECHREF-1.0.md +0 -2312
- package/docs/possible-ideas.md +0 -314
- package/docs/theory-old.md +0 -839
- package/docs/what-does-loadbare-extend.md +0 -124
- package/skills/loadbare-app/references/TECHREF-1.0.md +0 -2312
package/package.json
CHANGED
|
@@ -42,8 +42,10 @@ tsc --noEmit
|
|
|
42
42
|
`dist/pages.ts` imports page files with their `.ts` extensions, so the
|
|
43
43
|
application's `tsconfig.json` needs `allowImportingTsExtensions`.
|
|
44
44
|
|
|
45
|
-
Write, build, fix, and repeat until the build is clean.
|
|
46
|
-
|
|
45
|
+
Write, build, fix, and repeat until the build is clean. The build loads
|
|
46
|
+
each page's `.queries.ts` and `.requests.ts` to check the names the markup
|
|
47
|
+
carries, so their import-time code runs then; open a database in
|
|
48
|
+
`contextFor`, not at import. Then start the server: `createHub` refuses a page that declares a reserved name at startup,
|
|
47
49
|
and the server console reports a query that answers with the wrong kind.
|
|
48
50
|
Restart the server after adding or changing a `.queries.ts` or
|
|
49
51
|
`.requests.ts` file.
|
|
@@ -70,7 +72,8 @@ server.ts
|
|
|
70
72
|
|
|
71
73
|
The chrome carries `<lb-hub>` inside `<body>`, an empty `<main>` inside the
|
|
72
74
|
hub, and `<script src="/client.js" defer>`. Everything a user touches sits
|
|
73
|
-
inside `<lb-hub>`.
|
|
75
|
+
inside `<lb-hub>`. The chrome belongs to no page, so it names only the
|
|
76
|
+
hub's queries, `lb-url` and `lb-choices`, and sends no declared request.
|
|
74
77
|
|
|
75
78
|
A page is an HTML fragment that lands in `<main>`:
|
|
76
79
|
|
|
@@ -274,7 +277,9 @@ fetched to be edited is another page, with that row as its master.
|
|
|
274
277
|
`crud`, keyed by query name, as `rowInsert`, `rowUpdate` and `rowDelete`.
|
|
275
278
|
Each works on a `row` query as well as a `rows` query, since the element a
|
|
276
279
|
`row` lands on carries its key. Every other request name is a declared
|
|
277
|
-
request, under `handlers`.
|
|
280
|
+
request, under `handlers`. The build refuses markup naming a query or
|
|
281
|
+
request the page does not declare. One that arrives anyway, from a script,
|
|
282
|
+
is warned about on the server console and answered with nothing.
|
|
278
283
|
|
|
279
284
|
**An empty key is a row not yet entered.** A `row` query answering with an
|
|
280
285
|
empty key, or a form `--lb-new` pointed, carries `lb-key-value=""`. The hub
|
|
@@ -387,10 +392,13 @@ lb-query="lb-url">` in the chrome for it.
|
|
|
387
392
|
whole data channel.
|
|
388
393
|
|
|
389
394
|
**The developer writes `lb-*` attributes in markup, and script never
|
|
390
|
-
assigns them.** The builder refuses any `lb-` attribute other than
|
|
391
|
-
|
|
392
|
-
`lb-
|
|
393
|
-
|
|
395
|
+
assigns them.** The builder refuses any `lb-` attribute other than the
|
|
396
|
+
sixteen in [Attributes](references/names.md#attributes): `lb-query`,
|
|
397
|
+
`lb-column`, `lb-show`, `lb-order`, `lb-filter`, `lb-group`, `lb-count`,
|
|
398
|
+
`lb-sum`, `lb-avg`, `lb-min`, `lb-max`, `lb-select`, `lb-request`,
|
|
399
|
+
`lb-url-link`, `lb-url-push` and `lb-url-unknown`. `lb-exp-slot` and
|
|
400
|
+
`lb-exp-template` are expansion's, and never reach the page. Everything
|
|
401
|
+
else with the prefix is a stamp the hub or the builder writes.
|
|
394
402
|
|
|
395
403
|
**`lb-` belongs to Loadbare.** The application should never name anything
|
|
396
404
|
with the `lb-` prefix anywhere: no attribute, query, column, request, custom
|
|
@@ -495,8 +503,6 @@ with the package, so no network is needed.
|
|
|
495
503
|
- [`references/css.md`](references/css.md) — how stylesheets are ordered.
|
|
496
504
|
- [`references/widgets.md`](references/widgets.md) — the basic widget
|
|
497
505
|
library.
|
|
498
|
-
- [`references/
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
that block 1.0. Read it before designing around something the other
|
|
502
|
-
references do not mention.
|
|
506
|
+
- [`references/names.md`](references/names.md) — every name Loadbare
|
|
507
|
+
owns, the constants, and the section defining each. Check a name here
|
|
508
|
+
before designing around something the other references do not mention.
|
|
@@ -44,11 +44,16 @@ The builder classifies by name, not location.
|
|
|
44
44
|
| `*.queries.ts` | A page's queries, matched by base name |
|
|
45
45
|
| `imports.ts` | The packages this app takes widgets from |
|
|
46
46
|
| `*.css` | A stylesheet — see [CSS](./css.md) |
|
|
47
|
-
|
|
|
47
|
+
| `<tag-name>.html` | A widget definition, named for the tag it defines |
|
|
48
48
|
| `<tag>.browser.ts` | A widget script, named for the tag it registers |
|
|
49
49
|
|
|
50
50
|
Give the application exactly one `chrome.html` and at most one `imports.ts`.
|
|
51
|
-
Give every `.requests.ts` and `.queries.ts` a `.page.html` of the same base name
|
|
51
|
+
Give every `.requests.ts` and `.queries.ts` a `.page.html` of the same base name;
|
|
52
|
+
one with no page is a build error.
|
|
53
|
+
|
|
54
|
+
A widget definition is exactly `<kebab-case-name>.html`. Any other `.html`
|
|
55
|
+
file is an error when it looks like a definition with capitals in its name,
|
|
56
|
+
and is skipped otherwise.
|
|
52
57
|
|
|
53
58
|
Name a widget script `<tag>.browser.ts`, not `<tag>.ts`. Only a file whose
|
|
54
59
|
name carries `.browser` is bundled for the browser; every other module under
|
|
@@ -128,11 +133,22 @@ substitution rules — wraps each expanded page in
|
|
|
128
133
|
`<template lb-page="<stub>">`, and splices them into the chrome's `<body>`.
|
|
129
134
|
It removes a page file's `<title>` and stamps its text on the page's
|
|
130
135
|
template as `lb-page-title`; see [The page title](./page-files.md#the-page-title).
|
|
131
|
-
It formats the result with Prettier
|
|
136
|
+
It formats the result with Prettier, which ships with `@loadbare/app`, and
|
|
137
|
+
keeps the unformatted result if Prettier fails.
|
|
132
138
|
|
|
133
139
|
The builder checks the `lb-` attributes of the chrome and every page after
|
|
134
140
|
expansion, and stops on the first file with a problem; see
|
|
135
|
-
[The markup checks](./data-binding.md#the-markup-checks).
|
|
141
|
+
[The markup checks](./data-binding.md#the-markup-checks). The names
|
|
142
|
+
`lb-query` and `lb-request` carry are checked against what each page
|
|
143
|
+
declares, which the builder reads by loading the page's `.queries.ts` and
|
|
144
|
+
`.requests.ts` modules. Their import-time code runs during the build, as it
|
|
145
|
+
does when the server starts, so a module that connects to a database at
|
|
146
|
+
import connects during the build too; open connections in `contextFor`
|
|
147
|
+
instead.
|
|
148
|
+
|
|
149
|
+
It also writes `client-entry.ts`, the generated entry `client.js` is bundled
|
|
150
|
+
from, and leaves it there. Nothing reads it after the bundle, and an
|
|
151
|
+
application neither writes nor imports it.
|
|
136
152
|
|
|
137
153
|
The builder writes `app.css` only when it finds a stylesheet, and `pages.ts`
|
|
138
154
|
only when some page has a `.requests.ts` or a `.queries.ts` file. Import `hub`
|
|
@@ -103,6 +103,12 @@ server's row lands, so a chrome shows where the page is with no code:
|
|
|
103
103
|
| `lb-page-unknown` | `true` when no page's stub matches the path |
|
|
104
104
|
| Any other name | The query parm of that name, or empty when it is absent |
|
|
105
105
|
|
|
106
|
+
The path names a page, never a resource: `/accounts/42` is not a way to
|
|
107
|
+
reach account 42, and an application designs no endpoints. The query string
|
|
108
|
+
describes what that page has on screen, `/accounts?acct=23`, and never
|
|
109
|
+
commands. The server remembers nothing about the view, so a URL reloads,
|
|
110
|
+
bookmarks and mails as the same view.
|
|
111
|
+
|
|
106
112
|
A path names a page by its stub: `/members` shows `members.page.html`, and
|
|
107
113
|
`/` shows `index.page.html`. A page's title is the text of the `<title>` its
|
|
108
114
|
page file carries; see [page files](./page-files.md#the-page-title). The hub
|
|
@@ -139,11 +145,17 @@ Write `lb-url-link` on an `<a>` to move between pages:
|
|
|
139
145
|
</nav>
|
|
140
146
|
```
|
|
141
147
|
|
|
142
|
-
On a plain primary click, the
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
the browser has them behave
|
|
146
|
-
|
|
148
|
+
On a plain primary click, the first button with no modifier key and not
|
|
149
|
+
already handled, the hub pushes a history entry for the `href`, path and
|
|
150
|
+
query string both, and shows the page it names. Any other click, and a link
|
|
151
|
+
without `lb-url-link`, behave as the browser has them behave, so leaving the
|
|
152
|
+
application is the default and staying in it is the opt-in. The attribute
|
|
153
|
+
takes no value. Back and Forward show the page at the URL they arrive at.
|
|
154
|
+
|
|
155
|
+
Path space is flat: `/members` shows `members.page.html` wherever under
|
|
156
|
+
`--src` it sits. The query string is kept, so
|
|
157
|
+
`/transactions?date_begin=2026-09-01` opens the page narrowed to those
|
|
158
|
+
dates.
|
|
147
159
|
|
|
148
160
|
### Query parms
|
|
149
161
|
|
|
@@ -170,11 +182,28 @@ pushes one instead when the element carrying `lb-request` also carries
|
|
|
170
182
|
|
|
171
183
|
The hub answers the request itself, with no round trip, then reloads the
|
|
172
184
|
page's queries at the new URL. The page stays in place, and rows that come
|
|
173
|
-
back keep their place.
|
|
185
|
+
back keep their place. A request that leaves the URL as it was does
|
|
186
|
+
nothing. `lb-page-label` and `lb-page-unknown` are the hub's, and a request
|
|
187
|
+
never sets them.
|
|
188
|
+
|
|
189
|
+
A request that gives `lb-path` a new value enters that page, pushes a
|
|
190
|
+
history entry, and the new URL carries only the query parms the request
|
|
191
|
+
names.
|
|
174
192
|
|
|
175
193
|
A control whose column the URL does not carry lands empty, so every control
|
|
176
194
|
inside `lb-query="lb-url"` shows what the address bar says, after a reload
|
|
177
|
-
and after Back alike
|
|
195
|
+
and after Back alike
|
|
196
|
+
([miswart](./miswarts.md#lb-url-lands-every-parm-it-names)).
|
|
197
|
+
|
|
198
|
+
Loadbare assigns no parm a meaning, and a column of `lb-url` whose name
|
|
199
|
+
begins with `lb-` is never a query parm.
|
|
200
|
+
|
|
201
|
+
A query parm is user input. A query still takes no argument from the
|
|
202
|
+
browser, and a parm arrives the way the session cookie does, as part of the
|
|
203
|
+
request the context is built from, but a user who types `?acct=99999`
|
|
204
|
+
influences what a query returns. Validate it where the application reads
|
|
205
|
+
it; a per-session database role means an id outside the caller's reach
|
|
206
|
+
finds nothing.
|
|
178
207
|
|
|
179
208
|
An order or a filter the hub applies to rows the page already holds is not
|
|
180
209
|
a query parm. It is a [choice](./data-binding.md#choices), which holds until
|
|
@@ -198,8 +227,13 @@ show the path:
|
|
|
198
227
|
```
|
|
199
228
|
|
|
200
229
|
When no page's stub matches the path, `lb-page-unknown` is `true`,
|
|
201
|
-
`lb-page-label` is null, `<main>` keeps the page it had,
|
|
202
|
-
`showModal()` on the dialog.
|
|
230
|
+
`lb-page-label` is null, `<main>` keeps the page it had, the hub calls
|
|
231
|
+
`showModal()` on the dialog, and reports the path to the console. A chrome
|
|
232
|
+
with no dialog shows nothing. `lb-url` lands before the page is looked up,
|
|
233
|
+
so the dialog shows the path by naming it like any other element.
|
|
234
|
+
|
|
235
|
+
Every route gets the same document, so an unknown path is found out in the
|
|
236
|
+
browser after a successful 200, and there is no server-delivered 404.
|
|
203
237
|
|
|
204
238
|
`@loadbare/widgets` ships this dialog as `<lb-unknown-page>`, for a chrome
|
|
205
239
|
that would rather write one tag; see
|
|
@@ -224,7 +258,8 @@ being visibly empty — so it's the whole document that needs to wait, not
|
|
|
224
258
|
just the piece that was empty.
|
|
225
259
|
|
|
226
260
|
The `<noscript>` block is the escape hatch for a visitor with JavaScript
|
|
227
|
-
disabled. `<lb-hub>` is what removes `hidden` from `<body
|
|
261
|
+
disabled. `<lb-hub>` is what removes `hidden` from `<body>`
|
|
262
|
+
([miswart](./miswarts.md#the-hub-unhides-the-body)), so a browser
|
|
228
263
|
that never runs `client.js` would otherwise be stuck looking at a
|
|
229
264
|
permanently blank page. `<noscript>` content is only rendered when scripting
|
|
230
265
|
is off, so the fallback rule only ever applies in exactly that case — it
|
|
@@ -41,7 +41,6 @@ Serve it at `/app.css` and link it from the chrome:
|
|
|
41
41
|
See [`chrome.html`](./chrome.md) for the link, [The Express
|
|
42
42
|
server](./server.md) for the route, and
|
|
43
43
|
[`loadbare-app-build`](./builder.md#running-the-builder) for `--minify`.
|
|
44
|
-
</content>
|
|
45
44
|
|
|
46
45
|
## Selecting what the hub stamps
|
|
47
46
|
|
|
@@ -250,30 +250,8 @@ takes part in data binding in one of four ways: it is a control, it renders
|
|
|
250
250
|
a value, it sends a request, or it holds rows.
|
|
251
251
|
|
|
252
252
|
Import every Loadbare name from `@loadbare/app/constants`, and never write
|
|
253
|
-
one as a string literal:
|
|
254
|
-
|
|
255
|
-
| Constant | Value |
|
|
256
|
-
|------------------------|----------------------|
|
|
257
|
-
| `ATTR_QUERY` | `lb-query` |
|
|
258
|
-
| `ATTR_COLUMN` | `lb-column` |
|
|
259
|
-
| `ATTR_SHOW` | `lb-show` |
|
|
260
|
-
| `ATTR_REQUEST` | `lb-request` |
|
|
261
|
-
| `ATTR_COLUMN_VALUE` | `lb-column-value` |
|
|
262
|
-
| `ATTR_KEY_VALUE` | `lb-key-value` |
|
|
263
|
-
| `ATTR_ROW_LIVE` | `lb-row-live` |
|
|
264
|
-
| `LIVE_ROW` | `[lb-row-live]` |
|
|
265
|
-
| `ATTR_QUERY_ROW_COUNT` | `lb-query-row-count` |
|
|
266
|
-
| `ATTR_REQUEST_PENDING` | `lb-request-pending` |
|
|
267
|
-
| `ATTR_REQUEST_ERROR` | `lb-request-error` |
|
|
268
|
-
| `REQUEST_ROW_INSERT`, `REQUEST_ROW_UPDATE`, `REQUEST_ROW_DELETE` | The requests Loadbare provides |
|
|
269
|
-
| `LB_ROW_REQUESTS` | All three, in one array |
|
|
270
|
-
| `LB_EVENT_NAME` | `lb-request`, the event every request travels as |
|
|
271
|
-
| `LB_DONE_EVENT_NAME` | `lb-request-done`, the event that says how it turned out |
|
|
272
|
-
| `SHOW_NOT` | `!`, written before a column in `lb-show` |
|
|
273
|
-
| `URL_QUERY` | `lb-url` |
|
|
274
|
-
| `CHOICES_QUERY` | `lb-choices` |
|
|
275
|
-
| `URL_COLUMN_PATH`, `URL_COLUMN_PAGE_LABEL`, `URL_COLUMN_PAGE_UNKNOWN` | `lb-path`, `lb-page-label`, `lb-page-unknown` |
|
|
276
|
-
| `LB_RESERVED_PREFIX` | `lb-` |
|
|
253
|
+
one as a string literal: `ATTR_COLUMN_VALUE` rather than `"lb-column-value"`.
|
|
254
|
+
[Constants](./names.md#constants) lists them all.
|
|
277
255
|
|
|
278
256
|
A custom element reads `lb-` attributes and never assigns one. The developer
|
|
279
257
|
writes them in markup, and the hub and the builder write their stamps.
|
|
@@ -290,7 +268,7 @@ Each direction has one mechanism for each kind of message:
|
|
|
290
268
|
|
|
291
269
|
| Direction | What | How | Today |
|
|
292
270
|
|----------------|--------------------------------------------|-----------------------------|-------|
|
|
293
|
-
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-group-*`, `lb-row-*`, `lb-request-pending`, `lb-request-error` |
|
|
271
|
+
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-group-*`, `lb-row-*`, `lb-request-pending`, `lb-request-error`, `lb-request-refused` |
|
|
294
272
|
| Hub to element | State the platform already names | A property | A control's `value` |
|
|
295
273
|
| Hub to element | What the hub did | An optional `lb` method | `lbAttached`, `lbRowsLanded`, `lbRequestDone`, `lbDetached` |
|
|
296
274
|
| Hub to element | A moment an element started | A bubbling event | `lb-request-done` |
|