@loadbare/app 0.19.0 → 0.20.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/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +28 -2
- package/dist/build/assemble.js.map +1 -1
- package/dist/core/lb-constants.d.ts +7 -2
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +30 -4
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/hub/lb-apply.d.ts +21 -0
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +221 -30
- package/dist/hub/lb-apply.js.map +1 -1
- package/dist/hub/lb-hub.browser.d.ts.map +1 -1
- package/dist/hub/lb-hub.browser.js +26 -6
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/docs/comparison.md +23 -13
- package/docs/opinions.md +2 -2
- package/docs/reference/builder.md +11 -2
- package/docs/reference/chrome.md +83 -9
- package/docs/reference/css.md +0 -1
- package/docs/reference/custom-elements.md +7 -28
- package/docs/reference/data-binding.md +320 -50
- package/docs/reference/names.md +258 -0
- package/docs/reference/overview.md +6 -0
- package/docs/reference/page-files.md +47 -10
- package/docs/reference/server.md +54 -1
- package/docs/reference/widgets.md +10 -1
- package/docs/testing.md +5 -1
- package/docs/tutorials/040-displaying-data.md +1 -1
- package/package.json +1 -1
- package/skills/loadbare-app/SKILL.md +26 -14
- package/skills/loadbare-app/references/builder.md +11 -2
- package/skills/loadbare-app/references/chrome.md +83 -9
- package/skills/loadbare-app/references/css.md +0 -1
- package/skills/loadbare-app/references/custom-elements.md +7 -28
- package/skills/loadbare-app/references/data-binding.md +320 -50
- package/skills/loadbare-app/references/names.md +258 -0
- package/skills/loadbare-app/references/overview.md +6 -0
- package/skills/loadbare-app/references/page-files.md +47 -10
- package/skills/loadbare-app/references/server.md +54 -1
- package/skills/loadbare-app/references/widgets.md +10 -1
- package/docs/TECHREF-1.0.md +0 -2267
- package/skills/loadbare-app/references/TECHREF-1.0.md +0 -2267
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Names
|
|
2
|
+
|
|
3
|
+
Every name Loadbare/app owns, in one place. Each row links to the section
|
|
4
|
+
that defines it, and the definition lives there and only there.
|
|
5
|
+
|
|
6
|
+
An application names nothing with the `lb-` prefix: no attribute, query,
|
|
7
|
+
column, request, command, custom element or event. A name Loadbare has not
|
|
8
|
+
defined today it may define tomorrow. `createHub` refuses at startup a page
|
|
9
|
+
that declares a query, a handler or a `crud` entry whose name begins with
|
|
10
|
+
`lb-`, and the builder refuses the rest; see
|
|
11
|
+
[The markup checks](./data-binding.md#the-markup-checks).
|
|
12
|
+
|
|
13
|
+
## Builder flags
|
|
14
|
+
|
|
15
|
+
| Flag | Default | Names | Defined in |
|
|
16
|
+
| ---------- | ------- | ----------------------------------------- | --------------------------------------------------- |
|
|
17
|
+
| `--src` | `src` | The application's own tree, scanned whole | [Running the builder](./builder.md#running-the-builder) |
|
|
18
|
+
| `--out` | `dist` | Where the builder writes | [Running the builder](./builder.md#running-the-builder) |
|
|
19
|
+
| `--watch` | off | Rebuild on change under `--src` | [Running the builder](./builder.md#running-the-builder) |
|
|
20
|
+
| `--minify` | off | Minify `client.js` and `app.css` | [Running the builder](./builder.md#running-the-builder) |
|
|
21
|
+
|
|
22
|
+
## Reserved file names
|
|
23
|
+
|
|
24
|
+
A file so named carries its meaning wherever it sits in the `--src` tree,
|
|
25
|
+
so an application uses none of these names for anything else.
|
|
26
|
+
|
|
27
|
+
| File | How many | Holds | Defined in |
|
|
28
|
+
| ----------------------- | ------------------------------ | -------------------------------------------------------- | --------------------------------------------------- |
|
|
29
|
+
| `chrome.html` | Exactly one | The application's one HTML document | [chrome.html](./chrome.md) |
|
|
30
|
+
| `imports.ts` | Zero or one | Default-exports an array of widget package names | [Widgets from packages](./builder.md#widgets-from-packages) |
|
|
31
|
+
| `<stub>.page.html` | One per page | One page's markup, as a fragment | [HTML](./page-files.md#html) |
|
|
32
|
+
| `<stub>.queries.ts` | Zero or one per page | That page's queries | [Queries](./page-files.md#queries) |
|
|
33
|
+
| `<stub>.requests.ts` | Zero or one per page | That page's requests | [Requests](./page-files.md#requests) |
|
|
34
|
+
| `<tag-name>.html` | Zero or one per custom element | One element file, as a fragment | [HTML](./custom-elements.md#html) |
|
|
35
|
+
| `<tag-name>.browser.ts` | Zero or one per custom element | One custom element's script, `.js` also accepted | [Code](./custom-elements.md#code) |
|
|
36
|
+
| `*.css` | Any number | A stylesheet, concatenated into `app.css` | [CSS](./css.md) |
|
|
37
|
+
|
|
38
|
+
## Build outputs
|
|
39
|
+
|
|
40
|
+
The builder writes these into `--out`.
|
|
41
|
+
|
|
42
|
+
| File | Written | Holds | Defined in |
|
|
43
|
+
| ----------------- | ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------- |
|
|
44
|
+
| `app.html` | Always | The chrome, with every page inside a `<template>` | [What the builder writes](./builder.md#what-the-builder-writes) |
|
|
45
|
+
| `client.js` | Always | `<lb-hub>` and every custom element the application uses | [What the builder writes](./builder.md#what-the-builder-writes) |
|
|
46
|
+
| `client-entry.ts` | Always | The generated entry `client.js` is bundled from | [What the builder writes](./builder.md#what-the-builder-writes) |
|
|
47
|
+
| `app.css` | With a stylesheet | Every stylesheet in the cascade, concatenated | [CSS](./css.md) |
|
|
48
|
+
| `pages.ts` | With page data | The one `createHub()` call, over every page's queries and requests | [Running the server](./server.md#running-the-server) |
|
|
49
|
+
|
|
50
|
+
## Reserved package.json keys
|
|
51
|
+
|
|
52
|
+
A widget package declares these. An application never does.
|
|
53
|
+
|
|
54
|
+
| Key | Value | Means | Defined in |
|
|
55
|
+
| ------------------ | ------------------------- | ------------------------------------------------------------------ | --------------------------------------------------- |
|
|
56
|
+
| `loadbare.widgets` | A path inside the package | Where its custom elements are; absent means the whole installed directory | [Widgets from packages](./builder.md#widgets-from-packages) |
|
|
57
|
+
|
|
58
|
+
## Reserved namespaces
|
|
59
|
+
|
|
60
|
+
| Namespace | Applies to | Loadbare owns | Defined in |
|
|
61
|
+
| --------- | ----------------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------ |
|
|
62
|
+
| `lb-*` | Attributes, their values, queries, columns of `lb-` queries, requests, custom elements, events | The names and their behavior | [Attributes](#attributes) |
|
|
63
|
+
| `--lb-*` | Values of HTML's `command` attribute | The names and their behavior | [Reserved commands](#reserved-commands) |
|
|
64
|
+
| `exp-*` | Attributes on a custom element | The behavior; element file authors pick the names | [Parameters](./custom-elements.md#parameters) |
|
|
65
|
+
| `lb*` | Methods on custom elements: `lb` and a capital | The names and their behavior | [Reserved methods](#reserved-methods) |
|
|
66
|
+
|
|
67
|
+
## Attributes
|
|
68
|
+
|
|
69
|
+
The developer writes seventeen attributes in pages and the chrome, and the
|
|
70
|
+
builder refuses any other `lb-` attribute there. `lb-exp-slot` and
|
|
71
|
+
`lb-exp-template` are written for expansion, which removes them before the
|
|
72
|
+
check. The hub and the builder write the rest, as stamps, and script never
|
|
73
|
+
assigns one.
|
|
74
|
+
|
|
75
|
+
| Attribute | Written by | Defined in |
|
|
76
|
+
| -------------------- | --------------- | ---------------------------------------------------------------- |
|
|
77
|
+
| `lb-query` | Developer | [Landing](./data-binding.md#landing) |
|
|
78
|
+
| `lb-column` | Developer | [Landing](./data-binding.md#landing) |
|
|
79
|
+
| `lb-show` | Developer | [Conditional rendering](./data-binding.md#conditional-rendering) |
|
|
80
|
+
| `lb-order` | Developer | [Order](./data-binding.md#order) |
|
|
81
|
+
| `lb-filter` | Developer | [Filters](./data-binding.md#filters) |
|
|
82
|
+
| `lb-group` | Developer | [Groups](./data-binding.md#groups) |
|
|
83
|
+
| `lb-count`, `lb-sum`, `lb-avg`, `lb-min`, `lb-max` | Developer | [Aggregates](./data-binding.md#aggregates) |
|
|
84
|
+
| `lb-select` | Developer | [Selecting rows](./data-binding.md#selecting-rows) |
|
|
85
|
+
| `lb-request` | Developer | [Requests](./data-binding.md#requests) |
|
|
86
|
+
| `lb-url-link` | Developer | [Links](./chrome.md#links) |
|
|
87
|
+
| `lb-url-parm` | Developer | [A link from a row](./chrome.md#a-link-from-a-row) |
|
|
88
|
+
| `lb-url-push` | Developer | [Query parms](./chrome.md#query-parms) |
|
|
89
|
+
| `lb-url-unknown` | Developer | [An unknown page](./chrome.md#an-unknown-page) |
|
|
90
|
+
| `lb-exp-slot` | Developer, consumed by expansion | [The slot](./custom-elements.md#the-slot) |
|
|
91
|
+
| `lb-exp-template` | Developer, consumed by expansion | [Destinations](./custom-elements.md#destinations) |
|
|
92
|
+
| `lb-column-value` | Hub | [Where a column lands](./data-binding.md#where-a-column-lands) |
|
|
93
|
+
| `lb-key-value` | Hub | [Landing](./data-binding.md#landing), [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
|
|
94
|
+
| `lb-row-live` | Hub | [Landing](./data-binding.md#landing) |
|
|
95
|
+
| `lb-query-row-count` | Hub | [Counting rows](./data-binding.md#counting-rows) |
|
|
96
|
+
| `lb-query-unsorted-count`, `lb-row-unsorted` | Hub | [Rows the user is working in](./data-binding.md#rows-the-user-is-working-in) |
|
|
97
|
+
| `lb-query-order` | Hub | [Order](./data-binding.md#order) |
|
|
98
|
+
| `lb-group-live`, `lb-group-column`, `lb-group-value` | Hub | [Groups](./data-binding.md#groups) |
|
|
99
|
+
| `lb-row-created`, `lb-row-changed`, `lb-row-moved`, `lb-row-requested` | Hub | [What happened to a row](./data-binding.md#what-happened-to-a-row) |
|
|
100
|
+
| `lb-row-leaving`, `lb-group-leaving` | Hub | [What happened to a row](./data-binding.md#what-happened-to-a-row) |
|
|
101
|
+
| `lb-row-editing` | Hub | [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
|
|
102
|
+
| `lb-row-selected` | Hub | [Selecting rows](./data-binding.md#selecting-rows) |
|
|
103
|
+
| `lb-request-pending` | Hub | [Request state](./data-binding.md#request-state) |
|
|
104
|
+
| `lb-request-error` | Hub | [Request state](./data-binding.md#request-state) |
|
|
105
|
+
| `lb-request-refused` | Hub | [Refusals](./data-binding.md#refusals) |
|
|
106
|
+
| `lb-show` on a `<template>` | Hub and builder | [Where an absent element is](./data-binding.md#where-an-absent-element-is) |
|
|
107
|
+
| `lb-page` | Builder | [What the builder writes](./builder.md#what-the-builder-writes) |
|
|
108
|
+
| `lb-page-title` | Builder | [The page title](./page-files.md#the-page-title) |
|
|
109
|
+
|
|
110
|
+
## Reserved queries
|
|
111
|
+
|
|
112
|
+
The hub serves these in the browser. Every page and the chrome may name
|
|
113
|
+
them, and a page declares neither.
|
|
114
|
+
|
|
115
|
+
| Query | Kind | Key | Columns | Defined in |
|
|
116
|
+
| ------------ | ----- | --------- | --------------------------------------------------------------- | ------------------------------------- |
|
|
117
|
+
| `lb-url` | `row` | `lb-path` | `lb-path`, `lb-page-label`, `lb-page-unknown`, every query parm | [The URL](./chrome.md#the-url) |
|
|
118
|
+
| `lb-choices` | `row` | `lb-path` | `lb-path`, every choice | [Choices](./data-binding.md#choices) |
|
|
119
|
+
|
|
120
|
+
No query parm is reserved: a column of `lb-url` whose name begins with
|
|
121
|
+
`lb-` is never a query parm.
|
|
122
|
+
|
|
123
|
+
## Reserved request names
|
|
124
|
+
|
|
125
|
+
| Request name | Runs under `crud` | Defined in |
|
|
126
|
+
| --------------- | ----------------- | --------------------------------------------------------------------------- |
|
|
127
|
+
| `lb-row-insert` | `rowInsert` | [Inserting, updating and deleting rows](./data-binding.md#inserting-updating-and-deleting-rows) |
|
|
128
|
+
| `lb-row-update` | `rowUpdate` | [Inserting, updating and deleting rows](./data-binding.md#inserting-updating-and-deleting-rows) |
|
|
129
|
+
| `lb-row-delete` | `rowDelete` | [Inserting, updating and deleting rows](./data-binding.md#inserting-updating-and-deleting-rows) |
|
|
130
|
+
|
|
131
|
+
## Reserved commands
|
|
132
|
+
|
|
133
|
+
Loadbare/app owns every value of HTML's `command` attribute beginning with
|
|
134
|
+
`--lb-`.
|
|
135
|
+
|
|
136
|
+
| Command | Defined in |
|
|
137
|
+
| -------------- | ------------------------------------------------------------------------ |
|
|
138
|
+
| `--lb-edit` | [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
|
|
139
|
+
| `--lb-new` | [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
|
|
140
|
+
| `--lb-release` | [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
|
|
141
|
+
| `--lb-sort` | [Rows the user is working in](./data-binding.md#rows-the-user-is-working-in) |
|
|
142
|
+
|
|
143
|
+
## Reserved tags
|
|
144
|
+
|
|
145
|
+
An application writes these and never defines them.
|
|
146
|
+
|
|
147
|
+
| Tag | Written in | Means | Defined in |
|
|
148
|
+
| ---------- | ---------- | ------------------------------ | -------------------------------------------------- |
|
|
149
|
+
| `<lb-hub>` | The chrome | The application's live element | [The parts of a chrome](./chrome.md#the-parts-of-a-chrome) |
|
|
150
|
+
|
|
151
|
+
## Reserved events
|
|
152
|
+
|
|
153
|
+
Loadbare/app owns each event's name and what its `detail` carries.
|
|
154
|
+
|
|
155
|
+
| Event | Dispatched from | Bubbles | Cancelable | Defined in |
|
|
156
|
+
| ----------------- | -------------------------- | ------- | ---------- | ----------------------------------------------------------- |
|
|
157
|
+
| `lb-request` | The element that committed | Yes | No | [The request event](./data-binding.md#the-request-event) |
|
|
158
|
+
| `lb-request-done` | The element that committed | Yes | No | [Hearing how it turned out](./custom-elements.md#hearing-how-it-turned-out) |
|
|
159
|
+
|
|
160
|
+
## Reserved methods
|
|
161
|
+
|
|
162
|
+
The build refuses a custom element script declaring any other method,
|
|
163
|
+
accessor or field named `lb` and a capital.
|
|
164
|
+
|
|
165
|
+
| Method | On | Defined in |
|
|
166
|
+
| --------------- | ------------------------------------------------------ | ----------------------------------------------------------- |
|
|
167
|
+
| `lbAttached` | Any custom element the hub places | [When its code runs](./custom-elements.md#when-its-code-runs) |
|
|
168
|
+
| `lbRowsLanded` | A custom element with `lb-query` and a row template | [Holding rows](./custom-elements.md#holding-rows) |
|
|
169
|
+
| `lbRequestDone` | A custom element that committed, or holds one that did | [Hearing how it turned out](./custom-elements.md#hearing-how-it-turned-out) |
|
|
170
|
+
| `lbDetached` | Any custom element the hub removes | [When its code runs](./custom-elements.md#when-its-code-runs) |
|
|
171
|
+
|
|
172
|
+
## Exports
|
|
173
|
+
|
|
174
|
+
| Entry point | Exports | Defined in |
|
|
175
|
+
| -------------------------- | ---------------------------------------------------------------- | ---------------------------------------------- |
|
|
176
|
+
| `@loadbare/app/server` | `row`, `rows`, `patch`, `url`, `choices`, `refusal`, `createHub`, and the types `Queries`, `Requests`, `HubContext`, `Hub` | [Page Files](./page-files.md), [The data channel](./server.md#the-data-channel) |
|
|
177
|
+
| `@loadbare/app/express` | `hubRoutes` | [The Express Server](./server.md) |
|
|
178
|
+
| `@loadbare/app/types` | `HubRequest`, `ResponseItem`, `HubRequestDone`, `HubLifecycle`, and the rules the hub applies: `readAs`, `parseFilter`, `passes`, `passesTerm` | [The data channel](./server.md#the-data-channel), [Order](./data-binding.md#order), [Filters](./data-binding.md#filters) |
|
|
179
|
+
| `@loadbare/app` | `applyRow` | [Filling a subtree by hand](./custom-elements.md#filling-a-subtree-by-hand) |
|
|
180
|
+
| `@loadbare/app/constants` | Every name on this page; see [Constants](#constants) | [Code](./custom-elements.md#code) |
|
|
181
|
+
|
|
182
|
+
## Constants
|
|
183
|
+
|
|
184
|
+
`@loadbare/app/constants` exports every name above. Custom element code
|
|
185
|
+
imports them rather than writing a string.
|
|
186
|
+
|
|
187
|
+
| Constant | Value |
|
|
188
|
+
| ------------------------- | --------------------------------------- |
|
|
189
|
+
| `ATTR_QUERY` | `lb-query` |
|
|
190
|
+
| `ATTR_COLUMN` | `lb-column` |
|
|
191
|
+
| `ATTR_SHOW` | `lb-show` |
|
|
192
|
+
| `SHOW_NOT` | `!`, written before a column in `lb-show` |
|
|
193
|
+
| `ATTR_COLUMN_VALUE` | `lb-column-value` |
|
|
194
|
+
| `ATTR_KEY_VALUE` | `lb-key-value` |
|
|
195
|
+
| `ATTR_ROW_LIVE` | `lb-row-live` |
|
|
196
|
+
| `LIVE_ROW` | `[lb-row-live]`, the selector for a live row |
|
|
197
|
+
| `ATTR_QUERY_ROW_COUNT` | `lb-query-row-count` |
|
|
198
|
+
| `ATTR_QUERY_UNSORTED_COUNT` | `lb-query-unsorted-count` |
|
|
199
|
+
| `ATTR_QUERY_ORDER` | `lb-query-order` |
|
|
200
|
+
| `ATTR_GROUP` | `lb-group` |
|
|
201
|
+
| `ATTR_GROUP_LIVE` | `lb-group-live` |
|
|
202
|
+
| `ATTR_GROUP_COLUMN` | `lb-group-column` |
|
|
203
|
+
| `ATTR_GROUP_VALUE` | `lb-group-value` |
|
|
204
|
+
| `LIVE_GROUP` | `[lb-group-live]`, the selector for a group's element |
|
|
205
|
+
| `ATTR_COUNT`, `ATTR_SUM`, `ATTR_AVG`, `ATTR_MIN`, `ATTR_MAX` | `lb-count`, `lb-sum`, `lb-avg`, `lb-min`, `lb-max` |
|
|
206
|
+
| `AGGREGATES` | All five aggregate attributes |
|
|
207
|
+
| `ORDER_DESCENDING` | `-`, written before a column in an order |
|
|
208
|
+
| `COLUMN_TYPES` | `number`, `boolean`, `text` |
|
|
209
|
+
| `CHOICES_QUERY` | `lb-choices` |
|
|
210
|
+
| `ATTR_ORDER` | `lb-order` |
|
|
211
|
+
| `ATTR_FILTER` | `lb-filter` |
|
|
212
|
+
| `FILTER_OPERATORS` | Every filter operator, the longer first |
|
|
213
|
+
| `ATTR_ROW_CREATED` | `lb-row-created` |
|
|
214
|
+
| `ATTR_ROW_CHANGED` | `lb-row-changed` |
|
|
215
|
+
| `ATTR_ROW_MOVED` | `lb-row-moved` |
|
|
216
|
+
| `ATTR_ROW_REQUESTED` | `lb-row-requested` |
|
|
217
|
+
| `REQUESTED_CREATED`, `REQUESTED_CHANGED`, `REQUESTED_MOVED` | `created`, `changed`, `moved` |
|
|
218
|
+
| `ATTR_ROW_UNSORTED` | `lb-row-unsorted` |
|
|
219
|
+
| `ATTR_ROW_LEAVING` | `lb-row-leaving` |
|
|
220
|
+
| `ATTR_GROUP_LEAVING` | `lb-group-leaving` |
|
|
221
|
+
| `ATTR_REQUEST` | `lb-request` |
|
|
222
|
+
| `LB_EVENT_NAME` | `lb-request`, the event every request travels as |
|
|
223
|
+
| `LB_DONE_EVENT_NAME` | `lb-request-done` |
|
|
224
|
+
| `ATTR_REQUEST_PENDING` | `lb-request-pending` |
|
|
225
|
+
| `ATTR_REQUEST_ERROR` | `lb-request-error` |
|
|
226
|
+
| `ATTR_REQUEST_REFUSED` | `lb-request-refused` |
|
|
227
|
+
| `LB_REFUSAL_STATUS` | `422` |
|
|
228
|
+
| `COMMAND_EDIT`, `COMMAND_NEW`, `COMMAND_RELEASE`, `COMMAND_SORT` | `--lb-edit`, `--lb-new`, `--lb-release`, `--lb-sort` |
|
|
229
|
+
| `LB_COMMANDS` | All four commands |
|
|
230
|
+
| `LB_COMMAND_PREFIX` | `--lb-` |
|
|
231
|
+
| `ATTR_ROW_EDITING` | `lb-row-editing` |
|
|
232
|
+
| `ATTR_SELECT` | `lb-select` |
|
|
233
|
+
| `ATTR_ROW_SELECTED` | `lb-row-selected` |
|
|
234
|
+
| `LB_RESERVED_PREFIX` | `lb-` |
|
|
235
|
+
| `REQUEST_ROW_INSERT` | `lb-row-insert` |
|
|
236
|
+
| `REQUEST_ROW_UPDATE` | `lb-row-update` |
|
|
237
|
+
| `REQUEST_ROW_DELETE` | `lb-row-delete` |
|
|
238
|
+
| `LB_ROW_REQUESTS` | All three request names |
|
|
239
|
+
| `LB_METHODS` | The four reserved methods |
|
|
240
|
+
| `BROWSER_LIFECYCLE` | The browser callbacks the build refuses |
|
|
241
|
+
| `KIND_ROW` | `row` |
|
|
242
|
+
| `KIND_ROWS` | `rows` |
|
|
243
|
+
| `URL_QUERY` | `lb-url` |
|
|
244
|
+
| `URL_COLUMN_PATH` | `lb-path` |
|
|
245
|
+
| `URL_COLUMN_PAGE_LABEL` | `lb-page-label` |
|
|
246
|
+
| `URL_COLUMN_PAGE_UNKNOWN` | `lb-page-unknown` |
|
|
247
|
+
| `ATTR_URL_LINK` | `lb-url-link` |
|
|
248
|
+
| `ATTR_URL_PARM` | `lb-url-parm` |
|
|
249
|
+
| `ATTR_URL_PUSH` | `lb-url-push` |
|
|
250
|
+
| `ATTR_URL_UNKNOWN` | `lb-url-unknown` |
|
|
251
|
+
| `ATTR_EXP_SLOT` | `lb-exp-slot` |
|
|
252
|
+
| `ATTR_EXP_TEMPLATE` | `lb-exp-template` |
|
|
253
|
+
| `ATTR_PAGE` | `lb-page` |
|
|
254
|
+
| `ATTR_PAGE_TITLE` | `lb-page-title` |
|
|
255
|
+
| `DEVELOPER_ATTRIBUTES` | The seventeen attributes a developer writes |
|
|
256
|
+
| `HUB_TAG_NAME` | `lb-hub` |
|
|
257
|
+
| `LB_ENDPOINT` | `/lb` |
|
|
258
|
+
| `LB_REQUEST_TIMEOUT_MS` | `10000` |
|
|
@@ -38,3 +38,9 @@ serves, and the custom elements those pages are made of.
|
|
|
38
38
|
| [`<tag-name>.html`](./custom-elements.md#html) | The markup the tag expands into |
|
|
39
39
|
| [`<tag-name>.browser.ts`](./custom-elements.md#code) | The class the tag registers |
|
|
40
40
|
| [The Basic Widget Library](./widgets.md) | `@loadbare/widgets` |
|
|
41
|
+
|
|
42
|
+
## Names
|
|
43
|
+
|
|
44
|
+
| Topic | Description |
|
|
45
|
+
|--------------------------|--------------------------------------------------------------|
|
|
46
|
+
| [Names](./names.md) | Every name Loadbare owns, the constants, and where each is defined |
|
|
@@ -14,7 +14,9 @@ Name the landing page `index.page.html`. A bare `/` resolves to `index`, and
|
|
|
14
14
|
every other path names the page whose stub it is.
|
|
15
15
|
|
|
16
16
|
Put the files anywhere under `src/`. The builder pairs them by stub, not by
|
|
17
|
-
directory; `src/pages/` is the convention.
|
|
17
|
+
directory; `src/pages/` is the convention. The page namespace is flat, so
|
|
18
|
+
`src/deep/path/mypage.page.html` is the page for `/mypage`, and a stub is
|
|
19
|
+
unique across the application.
|
|
18
20
|
|
|
19
21
|
## What the page files are
|
|
20
22
|
|
|
@@ -122,8 +124,19 @@ including a `row` query's: an aggregate row answers with a constant key. The
|
|
|
122
124
|
hub matches rows to live rows by key, and a request names a row by key.
|
|
123
125
|
|
|
124
126
|
Kind and key belong to the name, so one name answers with one shape, always,
|
|
125
|
-
and `createHub` leaves out an answer that disagrees with its declaration
|
|
126
|
-
page that needs the same data as one row
|
|
127
|
+
and `createHub` leaves out an answer that disagrees with its declaration,
|
|
128
|
+
with a warning naming the query. A page that needs the same data as one row
|
|
129
|
+
and as a set declares two queries.
|
|
130
|
+
|
|
131
|
+
`createHub` refuses at startup a page that declares a query, a handler or a
|
|
132
|
+
`crud` entry whose name begins with `lb-`, a query whose order has a term
|
|
133
|
+
naming no column, and a type it does not know.
|
|
134
|
+
|
|
135
|
+
Every query and every handler receives `ctx`, the application's own request
|
|
136
|
+
context, built by `contextFor`; see
|
|
137
|
+
[the Express server](./server.md#database-layer). Loadbare declares it
|
|
138
|
+
empty and never reads it, so a query finds exactly what the application put
|
|
139
|
+
there.
|
|
127
140
|
|
|
128
141
|
The hub hands each value to the browser untouched, so what a number, a date
|
|
129
142
|
or a null looks like is decided here, in the query.
|
|
@@ -230,13 +243,20 @@ export const requests: Requests = {
|
|
|
230
243
|
```
|
|
231
244
|
|
|
232
245
|
Declare every request the page allows. The builder refuses markup naming a
|
|
233
|
-
request the page does not declare
|
|
234
|
-
|
|
246
|
+
request the page does not declare; see
|
|
247
|
+
[The markup checks](./data-binding.md#the-markup-checks). One can still
|
|
248
|
+
arrive, from a widget's script or from outside the page. The server then
|
|
249
|
+
warns on its console, naming the page and the missing entry, and answers
|
|
250
|
+
200 with no response items, so nothing lands and `lb-request-pending`
|
|
251
|
+
clears. A request carrying no name answers 400, and a `run` that throws
|
|
252
|
+
anything but a [refusal](#refusing-a-request) answers 500.
|
|
235
253
|
|
|
236
254
|
### crud
|
|
237
255
|
|
|
238
256
|
Declare what the three requests Loadbare provides do under `crud`, keyed by
|
|
239
|
-
the query they operate on
|
|
257
|
+
the query they operate on. Each key is the request name with its `lb-`
|
|
258
|
+
stripped and the rest camel-cased, so the attribute, the wire and the key
|
|
259
|
+
are one vocabulary:
|
|
240
260
|
|
|
241
261
|
| Request name | Runs | `run` receives |
|
|
242
262
|
|-----------------|-------------|------------------|
|
|
@@ -295,8 +315,9 @@ export const requests: Requests = {
|
|
|
295
315
|
```
|
|
296
316
|
|
|
297
317
|
Declare every request the query permits. The builder refuses markup sending
|
|
298
|
-
a request a query does not declare, and the server
|
|
299
|
-
anyway
|
|
318
|
+
a request a query does not declare, and the server answers one that arrives
|
|
319
|
+
anyway as it does an undeclared handler, with a console warning and nothing
|
|
320
|
+
to land. A query with no `crud` entry permits none.
|
|
300
321
|
|
|
301
322
|
Write `rowUpdate` to set the columns `values` names and leave every other
|
|
302
323
|
column as it is. A form or a live row sends every control it gathers, and a
|
|
@@ -361,7 +382,8 @@ one row dropped, one row edited — and leave `refresh` empty. A refreshed
|
|
|
361
382
|
A change that seems to need a refresh usually has a patch:
|
|
362
383
|
|
|
363
384
|
- A row whose position changes: the hub places it by the query's
|
|
364
|
-
[order](./data-binding.md#order)
|
|
385
|
+
[order](./data-binding.md#order), or leaves it where the user is working
|
|
386
|
+
when the request came from inside its list; a refresh would do the same.
|
|
365
387
|
- A group that appears or goes: the hub makes a group with its first row
|
|
366
388
|
and removes it with its last, so no row stands in for an empty one.
|
|
367
389
|
- A row whose other columns change with the edit: re-read the row and patch
|
|
@@ -374,7 +396,7 @@ removing a row never reorders the rest. So does an insert, which has the new
|
|
|
374
396
|
row's key once it has written it, and the hub places the new row by the
|
|
375
397
|
query's order. `createHub` refuses at startup a `crud` `rowInsert`,
|
|
376
398
|
`rowUpdate` or `rowDelete` on a `rows` query whose `refresh` names that same
|
|
377
|
-
query.
|
|
399
|
+
query. A `row` query sends one row and may refresh itself.
|
|
378
400
|
|
|
379
401
|
Each request's `refresh` is its own, and every query in it needs its own
|
|
380
402
|
reason. A list shared by several requests is a warning sign.
|
|
@@ -440,6 +462,21 @@ nothing else `run` returned is sent, since both answered for the URL the page
|
|
|
440
462
|
left. The loaded page reads the new parms through `contextFor`; see
|
|
441
463
|
[the Express server](./server.md#database-layer).
|
|
442
464
|
|
|
465
|
+
- A `url()` naming no column, or holding a value that is not a string, is
|
|
466
|
+
warned about on the server console and ignored, and the refresh set runs
|
|
467
|
+
as usual.
|
|
468
|
+
- If loading the page fails, the write has still happened. The response
|
|
469
|
+
carries the `lb-url` item alone, and the hub loads the page itself. A
|
|
470
|
+
failure there is a page load's, and is not stamped on the element that
|
|
471
|
+
sent the request.
|
|
472
|
+
- A user who has moved by the time the response arrives, to another page or
|
|
473
|
+
to other query parms, keeps the URL they are on.
|
|
474
|
+
|
|
475
|
+
Saving what the user has on screen, for `onPageEnter` to restore, is a
|
|
476
|
+
declared request with `refresh: []`, whose handler each page passes to a
|
|
477
|
+
routine the application's pages share. A custom element naming `lb-url`
|
|
478
|
+
sees every change of the URL and sends it.
|
|
479
|
+
|
|
443
480
|
### Refusing a request
|
|
444
481
|
|
|
445
482
|
A handler refuses a request by throwing `refusal()`, with words written for
|
package/docs/reference/server.md
CHANGED
|
@@ -17,7 +17,7 @@ import { readFileSync } from "node:fs";
|
|
|
17
17
|
import express, { type Request } from "express";
|
|
18
18
|
import { hubRoutes } from "@loadbare/app/express";
|
|
19
19
|
import type { HubContext } from "@loadbare/app/server";
|
|
20
|
-
import { hub } from "./dist/pages";
|
|
20
|
+
import { hub } from "./dist/pages.ts";
|
|
21
21
|
import { openDb } from "./src/database";
|
|
22
22
|
|
|
23
23
|
const DIST = path.resolve("dist");
|
|
@@ -181,3 +181,56 @@ open across the two, is both.
|
|
|
181
181
|
Add a field for anything else a request needs — the authenticated user, a
|
|
182
182
|
request id, a feature flag set. Queries and requests read them from `ctx`; see
|
|
183
183
|
[page files](./page-files.md).
|
|
184
|
+
|
|
185
|
+
## The data channel
|
|
186
|
+
|
|
187
|
+
One path, one method. The hub sends every round trip as
|
|
188
|
+
`POST /lb/<stub>?<query string>`, with the query string the browser is
|
|
189
|
+
showing, verbatim. An empty body, or `{}`, asks for the page load. Any other
|
|
190
|
+
body is a request:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
interface HubRequest {
|
|
194
|
+
name: string;
|
|
195
|
+
query?: string;
|
|
196
|
+
key?: string;
|
|
197
|
+
keys?: string[];
|
|
198
|
+
values?: Record<string, string>;
|
|
199
|
+
rows?: Record<string, { key: string; values: Record<string, string> }[]>;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
A refused request is answered with status 422 and
|
|
204
|
+
`{ refusal: { message?, columns? } }`, a request with no name with 400 and
|
|
205
|
+
`[]`, and
|
|
206
|
+
any other failure with 500 and no body; see
|
|
207
|
+
[Refusing a request](./page-files.md#refusing-a-request). Every other
|
|
208
|
+
response is an array of response items:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
interface ResponseItem {
|
|
212
|
+
query: string;
|
|
213
|
+
kind: "row" | "rows";
|
|
214
|
+
key: string;
|
|
215
|
+
row?: Row;
|
|
216
|
+
rows?: Row[];
|
|
217
|
+
patch?: { rows?: Row[]; drop?: unknown[] };
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
A response item carries exactly one of `row`, `rows` or `patch`. A patch
|
|
222
|
+
answers a `rows` query only: rows named in `rows` are added or updated, keys
|
|
223
|
+
in `drop` are removed, and every other row is left alone. A `rows` item on
|
|
224
|
+
the answer that loads the page also carries the query's declared `order`
|
|
225
|
+
and `types`, which the hub keeps for every answer after it.
|
|
226
|
+
|
|
227
|
+
A choice is sent as `lb-row-update` for `lb-choices`, keyed by the path,
|
|
228
|
+
with every choice made on the page as `values`; see
|
|
229
|
+
[Choices](./data-binding.md#choices).
|
|
230
|
+
|
|
231
|
+
`createHub(pages)` builds the `Hub`, which has two calls, both answering
|
|
232
|
+
with response items: `dataForPage(page, ctx, options)` for a page load, and
|
|
233
|
+
`runRequest(page, request, ctx)` for a request. `options.parms` are the
|
|
234
|
+
parms the page is loaded at, and `options.follow` false ignores a `url()`
|
|
235
|
+
from `onPageEnter`. `hubRoutes` passes both, and an application calls
|
|
236
|
+
neither.
|
|
@@ -155,7 +155,9 @@ row, the row template, and optionally a footer, each as a `<template>`:
|
|
|
155
155
|
| `<template lb-exp-template="foot">` | The `<tfoot>` |
|
|
156
156
|
| Any other `<template>` | The row or group template, in the `<tbody>` |
|
|
157
157
|
|
|
158
|
-
- The hub places the rows by the query's order and builds its groups
|
|
158
|
+
- The hub places the rows by the query's order and builds its groups, and
|
|
159
|
+
leaves them where they stand for an edit from inside the table; see
|
|
160
|
+
[Rows the user is working in](./data-binding.md#rows-the-user-is-working-in). The
|
|
159
161
|
rows land in the one `<tbody>`, so a group here is a heading row with its
|
|
160
162
|
rows after it.
|
|
161
163
|
- `lb-order` and `lb-filter` go on the `lb-table` itself, beside
|
|
@@ -174,6 +176,13 @@ row, the row template, and optionally a footer, each as a `<template>`:
|
|
|
174
176
|
- Text selected in a cell whose `lb-column` the table's `lb-filter` names
|
|
175
177
|
becomes that column's filter in `lb-choices`: `=` for the whole text,
|
|
176
178
|
`^=` from its start, `$=` up to its end, `*=` otherwise.
|
|
179
|
+
- The heading of the order's leading column carries a triangle for the
|
|
180
|
+
direction, read from [`lb-query-order`](./data-binding.md#order). A
|
|
181
|
+
heading's column is the `lb-column` in the cell at its position in the row
|
|
182
|
+
template. While rows stand out of order the triangle carries
|
|
183
|
+
`data-unsorted` and a click on its heading re-sorts. With `lb-order`, a
|
|
184
|
+
click on the sorted heading reverses the order and a click on another
|
|
185
|
+
sorts by its column. Not on a grouped table.
|
|
177
186
|
|
|
178
187
|
## `lb-confirm`
|
|
179
188
|
|
package/docs/testing.md
CHANGED
|
@@ -208,7 +208,9 @@ evidence here.
|
|
|
208
208
|
- `lb-query-row-count` counts the rows showing, so all rows and a patch
|
|
209
209
|
ending in the same state report the same number, and a row a filter hides
|
|
210
210
|
is not counted
|
|
211
|
-
- the order places all rows and a patch alike,
|
|
211
|
+
- the order places all rows and a patch alike, except where an edit came
|
|
212
|
+
from inside the list, which leaves its rows standing and stamped until
|
|
213
|
+
the user asks for the order; groups come and go with
|
|
212
214
|
their rows to any depth, aggregates follow every landing, and every change
|
|
213
215
|
leaves a stamp a stylesheet can see (`lb-order.test.ts`)
|
|
214
216
|
- a filter's text reads and passes values as documented, and a choice of
|
|
@@ -279,6 +281,8 @@ What the hub is tested for here:
|
|
|
279
281
|
`lb-page-label`, and a column per query parm, and sets the document title
|
|
280
282
|
- `lb-url-link` pushes state and swaps the page on a plain primary click,
|
|
281
283
|
`popstate` reverses it, and an ordinary anchor is left alone
|
|
284
|
+
- `lb-url-parm` writes a link's `href` from its row as held, starting from
|
|
285
|
+
the `href` as written every time (`lb-apply.test.ts`)
|
|
282
286
|
- a control inside `lb-query="lb-url"` writes its parm, replacing the history
|
|
283
287
|
entry or pushing one with `lb-url-push`, and the page's queries reload
|
|
284
288
|
- an `lb-url` item in a server answer writes the URL and lands the page
|
|
@@ -130,7 +130,7 @@ requests to the correct page code.
|
|
|
130
130
|
import express from "express";
|
|
131
131
|
import { readFileSync } from "node:fs";
|
|
132
132
|
import { hubRoutes } from "@loadbare/app/express";
|
|
133
|
-
import { hub } from "./dist/pages";
|
|
133
|
+
import { hub } from "./dist/pages.ts";
|
|
134
134
|
import { openDb } from "./src/database";
|
|
135
135
|
|
|
136
136
|
const app = express();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: loadbare-app
|
|
3
|
-
description: Build server-bound web applications with Loadbare/app. Covers the file conventions the builder finds by name (`chrome.html`, `*.page.html`, `*.queries.ts`, `*.requests.ts`, `imports.ts`, `<tag>.html`, `<tag>.browser.ts`); the `lb-*` attribute vocabulary that lands query rows on HTML and issues requests (`lb-query`, `lb-column`, `lb-show`, `lb-request`); queries declared with `row(key, run)` and `rows(key, run)`; the URL as the hub's own query `lb-url`, with `lb-url-link`, `lb-url-push` and `lb-url-unknown`; the user's order and filters as the hub's query `lb-choices`, read by `lb-order` and `lb-filter`; one form pointed at a row by the `--lb-edit`, `--lb-new` and `--lb-release` commands; build-time expansion with `exp-*` parameters, `lb-exp-slot` and `lb-exp-template`; custom elements as form-associated controls and row hosts; the Express wiring with `hubRoutes`; and the `@loadbare/widgets` library. Use whenever a task involves `@loadbare/app`, `@loadbare/widgets`, `loadbare-app-build`, an `lb-` attribute, or a page, query, request or custom element file in a Loadbare application. The model is not React, htmx or REST, and cannot be inferred from them.
|
|
3
|
+
description: Build server-bound web applications with Loadbare/app. Covers the file conventions the builder finds by name (`chrome.html`, `*.page.html`, `*.queries.ts`, `*.requests.ts`, `imports.ts`, `<tag>.html`, `<tag>.browser.ts`); the `lb-*` attribute vocabulary that lands query rows on HTML and issues requests (`lb-query`, `lb-column`, `lb-show`, `lb-request`); queries declared with `row(key, run)` and `rows(key, run)`; the URL as the hub's own query `lb-url`, with `lb-url-link`, `lb-url-parm`, `lb-url-push` and `lb-url-unknown`; the user's order and filters as the hub's query `lb-choices`, read by `lb-order` and `lb-filter`; one form pointed at a row by the `--lb-edit`, `--lb-new` and `--lb-release` commands; re-sorting a list with `--lb-sort`; build-time expansion with `exp-*` parameters, `lb-exp-slot` and `lb-exp-template`; custom elements as form-associated controls and row hosts; the Express wiring with `hubRoutes`; and the `@loadbare/widgets` library. Use whenever a task involves `@loadbare/app`, `@loadbare/widgets`, `loadbare-app-build`, an `lb-` attribute, or a page, query, request or custom element file in a Loadbare application. The model is not React, htmx or REST, and cannot be inferred from them.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
6
|
package: "@loadbare/app"
|
|
@@ -191,6 +191,12 @@ row is filled from the nested query's last answer, whatever order they land
|
|
|
191
191
|
in.
|
|
192
192
|
|
|
193
193
|
**A `rows` query declares its order, and the hub places every row by it.**
|
|
194
|
+
An edit sent from inside a list leaves that list's rows where they stand,
|
|
195
|
+
stamped `lb-row-unsorted` where out of order, until the page loads, the
|
|
196
|
+
user's order or filter changes, or a button with `commandfor` naming the
|
|
197
|
+
list sends `command="--lb-sort"`, which places them with no round trip;
|
|
198
|
+
show it by `[lb-query-unsorted-count]`. Never refresh to make rows hold
|
|
199
|
+
still, and never to put them back in order.
|
|
194
200
|
`rows("id", run, { order: "category_order,name" })`; a column after `-` sorts
|
|
195
201
|
descending, and values compare by JSON type, so a numeric sort column is a
|
|
196
202
|
JSON number or is declared one: `types: { amount: "number" }` beside
|
|
@@ -265,7 +271,8 @@ in every row. Write one form naming the set's query, outside every row,
|
|
|
265
271
|
often in a `<dialog>`, and give it an `id`. A `type="button"` with
|
|
266
272
|
`commandfor="<id>"` and `command="--lb-edit"` in a live row fills it from
|
|
267
273
|
that row with no round trip; `--lb-new` starts it empty for an insert;
|
|
268
|
-
`--lb-release` lets it go.
|
|
274
|
+
`--lb-release` lets it go. (`--lb-sort` is the fourth command, for a list,
|
|
275
|
+
not a form.) The form's `lb-key-value` is the row's key, empty
|
|
269
276
|
for a new row, absent when not in use, and a stylesheet shows Save or Save
|
|
270
277
|
new by it. A successful request from the form, or its dialog closing, lets
|
|
271
278
|
it go. Which row is being edited is never a query parm. A row that must be
|
|
@@ -278,8 +285,8 @@ fetched to be edited is another page, with that row as its master.
|
|
|
278
285
|
Each works on a `row` query as well as a `rows` query, since the element a
|
|
279
286
|
`row` lands on carries its key. Every other request name is a declared
|
|
280
287
|
request, under `handlers`. The build refuses markup naming a query or
|
|
281
|
-
request the page does not declare
|
|
282
|
-
|
|
288
|
+
request the page does not declare. One that arrives anyway, from a script,
|
|
289
|
+
is warned about on the server console and answered with nothing.
|
|
283
290
|
|
|
284
291
|
**An empty key is a row not yet entered.** A `row` query answering with an
|
|
285
292
|
empty key, or a form `--lb-new` pointed, carries `lb-key-value=""`. The hub
|
|
@@ -321,7 +328,8 @@ picker in a row the request adds: its answer did not change, and the hub
|
|
|
321
328
|
fills a new row from the last one.
|
|
322
329
|
|
|
323
330
|
**The usual reasons for a refresh each have a patch.**
|
|
324
|
-
- A row whose position changes: the hub places it by the query's order
|
|
331
|
+
- A row whose position changes: the hub places it by the query's order, or
|
|
332
|
+
holds it where the user is working; a refresh changes neither.
|
|
325
333
|
- A group that appears or goes: the hub makes it with its first row and
|
|
326
334
|
removes it with its last.
|
|
327
335
|
- A row whose other columns change with the edit: re-read the row and patch
|
|
@@ -359,7 +367,9 @@ per query parm. A control inside `lb-query="lb-url"` carrying
|
|
|
359
367
|
`lb-request="lb-row-update"` writes its parm; the hub replaces the history
|
|
360
368
|
entry, or pushes one when the control carries `lb-url-push`, and reloads the
|
|
361
369
|
page's queries with no request to the server. An `<a lb-url-link>` moves
|
|
362
|
-
to its `href
|
|
370
|
+
to its `href`; inside a row, `lb-url-parm="topic_id"` adds that column of
|
|
371
|
+
the row to the `href` as the parm of the same name, so a link to another
|
|
372
|
+
page narrowed by the row is a link, never a request or script. Queries still take no arguments: `contextFor(req, parms)`
|
|
363
373
|
puts parms onto `ctx`, and a query reads them there. Read them from
|
|
364
374
|
`parms`, never `req.query`, because `contextFor` may be called twice for one
|
|
365
375
|
request. A parm is user input, so validate it where it is read. Do not
|
|
@@ -392,10 +402,13 @@ lb-query="lb-url">` in the chrome for it.
|
|
|
392
402
|
whole data channel.
|
|
393
403
|
|
|
394
404
|
**The developer writes `lb-*` attributes in markup, and script never
|
|
395
|
-
assigns them.** The builder refuses any `lb-` attribute other than
|
|
396
|
-
|
|
397
|
-
`lb-
|
|
398
|
-
|
|
405
|
+
assigns them.** The builder refuses any `lb-` attribute other than the
|
|
406
|
+
seventeen in [Attributes](references/names.md#attributes): `lb-query`,
|
|
407
|
+
`lb-column`, `lb-show`, `lb-order`, `lb-filter`, `lb-group`, `lb-count`,
|
|
408
|
+
`lb-sum`, `lb-avg`, `lb-min`, `lb-max`, `lb-select`, `lb-request`,
|
|
409
|
+
`lb-url-link`, `lb-url-parm`, `lb-url-push` and `lb-url-unknown`. `lb-exp-slot` and
|
|
410
|
+
`lb-exp-template` are expansion's, and never reach the page. Everything
|
|
411
|
+
else with the prefix is a stamp the hub or the builder writes.
|
|
399
412
|
|
|
400
413
|
**`lb-` belongs to Loadbare.** The application should never name anything
|
|
401
414
|
with the `lb-` prefix anywhere: no attribute, query, column, request, custom
|
|
@@ -500,7 +513,6 @@ with the package, so no network is needed.
|
|
|
500
513
|
- [`references/css.md`](references/css.md) — how stylesheets are ordered.
|
|
501
514
|
- [`references/widgets.md`](references/widgets.md) — the basic widget
|
|
502
515
|
library.
|
|
503
|
-
- [`references/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
references do not mention.
|
|
516
|
+
- [`references/names.md`](references/names.md) — every name Loadbare
|
|
517
|
+
owns, the constants, and the section defining each. Check a name here
|
|
518
|
+
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
|
|
@@ -141,6 +146,10 @@ does when the server starts, so a module that connects to a database at
|
|
|
141
146
|
import connects during the build too; open connections in `contextFor`
|
|
142
147
|
instead.
|
|
143
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.
|
|
152
|
+
|
|
144
153
|
The builder writes `app.css` only when it finds a stylesheet, and `pages.ts`
|
|
145
154
|
only when some page has a `.requests.ts` or a `.queries.ts` file. Import `hub`
|
|
146
155
|
from `pages.ts` — see [The Express Server](./server.md) for the rest of the
|