@loadbare/app 0.9.0 → 0.11.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.
Files changed (82) hide show
  1. package/README.md +3 -3
  2. package/dist/build/assemble.d.ts.map +1 -1
  3. package/dist/build/assemble.js +107 -90
  4. package/dist/build/assemble.js.map +1 -1
  5. package/dist/build/expand.d.ts +6 -1
  6. package/dist/build/expand.d.ts.map +1 -1
  7. package/dist/build/expand.js +112 -26
  8. package/dist/build/expand.js.map +1 -1
  9. package/dist/build/locations.d.ts +2 -3
  10. package/dist/build/locations.d.ts.map +1 -1
  11. package/dist/build/locations.js +2 -3
  12. package/dist/build/locations.js.map +1 -1
  13. package/dist/build/pages.d.ts +3 -4
  14. package/dist/build/pages.d.ts.map +1 -1
  15. package/dist/build/pages.js +3 -4
  16. package/dist/build/pages.js.map +1 -1
  17. package/dist/core/lb-constants.d.ts +27 -24
  18. package/dist/core/lb-constants.d.ts.map +1 -1
  19. package/dist/core/lb-constants.js +103 -168
  20. package/dist/core/lb-constants.js.map +1 -1
  21. package/dist/core/lb-types.d.ts +64 -77
  22. package/dist/core/lb-types.d.ts.map +1 -1
  23. package/dist/core/lb-types.js +40 -7
  24. package/dist/core/lb-types.js.map +1 -1
  25. package/dist/hub/lb-apply.d.ts +47 -37
  26. package/dist/hub/lb-apply.d.ts.map +1 -1
  27. package/dist/hub/lb-apply.js +195 -199
  28. package/dist/hub/lb-apply.js.map +1 -1
  29. package/dist/hub/lb-hub.browser.d.ts +1 -1
  30. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  31. package/dist/hub/lb-hub.browser.js +410 -449
  32. package/dist/hub/lb-hub.browser.js.map +1 -1
  33. package/dist/server/lb-express.d.ts +5 -5
  34. package/dist/server/lb-express.d.ts.map +1 -1
  35. package/dist/server/lb-express.js +35 -66
  36. package/dist/server/lb-express.js.map +1 -1
  37. package/dist/server/lb-server.d.ts +77 -135
  38. package/dist/server/lb-server.d.ts.map +1 -1
  39. package/dist/server/lb-server.js +132 -79
  40. package/dist/server/lb-server.js.map +1 -1
  41. package/docs/TECHREF-1.0.md +908 -585
  42. package/docs/comparison.md +243 -185
  43. package/docs/prior-art.md +15 -14
  44. package/docs/reference/builder.md +9 -3
  45. package/docs/reference/chrome.md +107 -56
  46. package/docs/reference/custom-elements.md +291 -173
  47. package/docs/reference/data-binding.md +381 -374
  48. package/docs/reference/overview.md +12 -10
  49. package/docs/reference/page-files.md +164 -99
  50. package/docs/reference/server.md +2 -2
  51. package/docs/reference/widgets.md +104 -110
  52. package/docs/roadmap.md +32 -39
  53. package/docs/terms-of-art.md +57 -0
  54. package/docs/testing.md +97 -68
  55. package/docs/theory.md +92 -58
  56. package/docs/tutorials/010-pages-and-navigation.md +20 -12
  57. package/docs/tutorials/020-css.md +6 -3
  58. package/docs/tutorials/030-html-decomposition.md +9 -7
  59. package/docs/tutorials/040-displaying-data.md +30 -13
  60. package/docs/tutorials/{050-actions.md → 050-requests.md} +25 -15
  61. package/docs/tutorials/060-custom-element-code.md +17 -16
  62. package/docs/tutorials/065-conditional-rendering.md +34 -23
  63. package/docs/tutorials/070-displaying-a-list.md +29 -21
  64. package/docs/tutorials/072-inserting-into-a-list.md +24 -16
  65. package/docs/tutorials/074-deleting-from-a-list.md +9 -7
  66. package/docs/tutorials/076-updating-a-list-item.md +11 -10
  67. package/docs/tutorials/080-widget-requests.md +71 -43
  68. package/docs/tutorials/090-using-widget-libraries.md +22 -22
  69. package/docs/what-does-loadbare-extend.md +124 -0
  70. package/package.json +1 -1
  71. package/skills/loadbare-app/SKILL.md +201 -123
  72. package/skills/loadbare-app/references/TECHREF-1.0.md +908 -585
  73. package/skills/loadbare-app/references/builder.md +9 -3
  74. package/skills/loadbare-app/references/chrome.md +107 -56
  75. package/skills/loadbare-app/references/custom-elements.md +291 -173
  76. package/skills/loadbare-app/references/data-binding.md +381 -374
  77. package/skills/loadbare-app/references/overview.md +12 -10
  78. package/skills/loadbare-app/references/page-files.md +164 -99
  79. package/skills/loadbare-app/references/server.md +2 -2
  80. package/skills/loadbare-app/references/widgets.md +104 -110
  81. package/docs/analysis-accidental-complexity.md +0 -149
  82. package/docs/analysis-closed-set.md +0 -210
@@ -1,39 +1,21 @@
1
- // Every hub attribute name lives here. Nothing writes one as a string
1
+ // Every Loadbare attribute name lives here. Nothing writes one as a string
2
2
  // literal — not a widget, not a page host, not a test. See
3
3
  // docs/reference/data-binding.md.
4
- // --- Binding (docs/reference/data-binding.md) ---------------------------
5
- // One containment ladder: a list holds rows, a row holds cells. Both scope
6
- // attributes take a name the server declares, and a nested one of either
7
- // kind begins a new scope.
8
- // Scopes DOM children to a named set of rows.
9
- export const ATTR_LIST = "lb-list";
10
- // Scopes DOM children to one named row.
11
- //
12
- // A single-row scope is read-only. Every write operation needs a key, and a
13
- // key exists only on a live row the hub stamped inside a list, so a declared
14
- // action is the only thing such a scope can send. An application that wants
15
- // a writable single row declares a list that answers with one row.
16
- export const ATTR_ROW = "lb-row";
17
- // Named on a row template by the developer: the column that identifies a row
18
- // of the list. A property of the list rather than of the template — a list
19
- // without a fixed key column is meaningless — but written where the rows
20
- // land, because that is the only place the page says anything about them.
21
- export const ATTR_KEY = "lb-key";
22
- // Stamped on a live row by the row machinery: that row's value of the column
23
- // ATTR_KEY names. Written by the hub, never by a developer, and read back by
24
- // whatever needs to know which row it is inside — a delete button, an update
25
- // form, a widget building its own request, or a stylesheet.
26
- export const ATTR_KEY_VALUE = "lb-key-value";
27
- // The column an element displays.
28
- //
29
- // Its value is a column name and never a cell name. A cell has no name of
30
- // its own: it is identified by its row and its column, and the row arrives
31
- // from scope, so the column is all that is left to say. ATTR_KEY holds a
32
- // column name for the same reason.
33
- export const ATTR_CELL = "lb-cell";
4
+ // --- Landing (docs/reference/data-binding.md) ----------------------------
5
+ // Everything is a query. The server answers every request with response
6
+ // items, one per query, and each carries the query's kind and key. The
7
+ // markup names a query and the columns it shows; it never repeats what the
8
+ // server already declared.
9
+ // Names the query whose rows land in an element's content. A nested one
10
+ // begins a new query: what is inside it is that query's.
11
+ export const ATTR_QUERY = "lb-query";
12
+ // The column an element shows, read from the nearest ancestor row. On a
13
+ // control the hub sets its value, and gathers it back under this name when
14
+ // the control's request is issued.
15
+ export const ATTR_COLUMN = "lb-column";
34
16
  // The column that decides whether an element is present: `null` and `false`
35
- // are off, and every other value is on. It binds by the same ancestor rule as
36
- // ATTR_CELL, and names a column for the same reason.
17
+ // are off, and every other value is on. It reads from the nearest ancestor
18
+ // row, as ATTR_COLUMN does.
37
19
  //
38
20
  // An element that is off is moved into a `<template>` carrying this attribute
39
21
  // and the same column, standing where the element stood, and moved back out
@@ -43,132 +25,99 @@ export const ATTR_CELL = "lb-cell";
43
25
  // branch in the document so the hub holds nothing. Landing reaches inside it,
44
26
  // so a branch that returns is already current; nothing else does.
45
27
  export const ATTR_SHOW = "lb-show";
46
- export const ATTR_VALUE = "lb-value";
47
- // Stamped on a list scope by the shared row machinery: how many rows it is
48
- // showing. Written by the hub and never bound to — it is derived from rows
49
- // the hub already knows, exactly as the section heading in lb-table is. A
50
- // list widget watches it, and it exists so that "no members yet" is a
51
- // stylesheet rule rather than a conditional in every list widget.
52
- export const ATTR_ROW_COUNT = "lb-row-count";
28
+ // Stamped by the hub on every element it sets from a column: the value it
29
+ // set, so a stylesheet can select on it and a custom element that is not a
30
+ // control can render it.
31
+ export const ATTR_COLUMN_VALUE = "lb-column-value";
32
+ // Stamped by the hub on each live row, and on an element a `row` lands on
33
+ // itself: the row's key. The key column is the query's, declared by the
34
+ // server and carried by every response item.
35
+ export const ATTR_KEY_VALUE = "lb-key-value";
36
+ // Stamped by the hub on each live row, and on nothing else: the element it
37
+ // cloned from a row template. A key alone does not say so, because an
38
+ // element a `row` lands on carries one too, and a live row may name a query
39
+ // of its own, so neither the key nor `lb-query` tells the two apart.
40
+ export const ATTR_ROW_LIVE = "lb-row-live";
41
+ // Selects a live row. Anything that walks rows — reconciliation, gathering,
42
+ // a custom element's own placement — finds them with this and nothing else.
43
+ export const LIVE_ROW = `[${ATTR_ROW_LIVE}]`;
44
+ // Stamped by the hub on an element with a row template: how many live rows
45
+ // it holds, so "no members yet" is a stylesheet rule rather than a
46
+ // conditional in every widget.
47
+ export const ATTR_QUERY_ROW_COUNT = "lb-query-row-count";
53
48
  // --- Requests (docs/reference/data-binding.md) --------------------------
54
- // One event name, used by a widget reaching the server and by a widget
55
- // reaching an ancestor widget.
49
+ // Names the request an element issues when it commits: a form on submit, a
50
+ // control on change, anything else on click.
51
+ export const ATTR_REQUEST = "lb-request";
52
+ // Every request travels as one bubbling event of this name, whoever issued
53
+ // it, so an ancestor may stop it.
56
54
  export const LB_EVENT_NAME = "lb-request";
57
- // Names what an interaction asks for.
58
- //
59
- // One attribute name, one wire field, one set of values: the request field
60
- // `action` carries this attribute's value verbatim, and nothing is
61
- // translated in between. On a native element the hub turns the element's own
62
- // event into the request — a form submits, anything else clicks; on a
63
- // widget, the widget builds it from whatever interaction it owns.
64
- export const ATTR_ACTION = "lb-action";
55
+ // Stamped on the element that issued a request while its round trip is in
56
+ // flight, alongside aria-busy. A commit on an element carrying it is ignored.
57
+ export const ATTR_REQUEST_PENDING = "lb-request-pending";
58
+ // Stamped on the element that issued a request when its round trip failed —
59
+ // a non-2xx response, a thrown application error, or a timeout, all alike.
60
+ // Cleared at the start of that element's next request.
61
+ export const ATTR_REQUEST_ERROR = "lb-request-error";
65
62
  // --- Reserved names ----------------------------------------------------
66
- // Loadbare owns every value beginning with this prefix, in every lb-*
67
- // attribute: a name so prefixed is the hub's own (NAV_ROW), and an
68
- // lb-action so prefixed is an operation (below). The server refuses a page
69
- // that declares a query or an action beginning with it, so a new reserved
70
- // name can never collide with one an application already uses.
71
- //
72
- // It is also the whole of the wire discriminant. A request whose `action`
73
- // begins with it is one of the three operations; anything else is a name the
74
- // page declared under its requests. Nothing else tells them apart.
63
+ // Loadbare owns every name beginning with this prefix: attribute names, the
64
+ // values of its attributes, query names, request names, the column names of
65
+ // its own queries, custom element names and event names. The server refuses
66
+ // a page that declares a query or a request so named.
75
67
  export const LB_RESERVED_PREFIX = "lb-";
76
- // On a <form> in a list scope: builds a new row on submit. The hub gathers
77
- // every lb-cell inside the form into a values map — no key, because there is
78
- // no row yet — and the form's own lb-list says which list it is inserting
79
- // into.
80
- export const ACTION_ROW_INSERT = "lb-row-insert";
81
- // Deletes the row the element is inside. Needs no declared name: it takes
82
- // only the row's own lb-list/lb-key-value binding, which is all the server
83
- // needs to know which row and whether the operation is permitted on it.
84
- export const ACTION_ROW_DELETE = "lb-row-delete";
85
- // Commits cells of the row the element is inside. From a <form> or a button,
86
- // on submit or click, the hub gathers the same values map as an insert, plus
87
- // the row's own lb-key-value: a form that is a list's row template root, or
88
- // sits inside one, has both from its ancestors exactly as a delete button
89
- // does.
90
- //
91
- // From an element carrying lb-cell — a widget wrapping one control — the
92
- // values map holds that one cell and nothing else, the way a control has a
93
- // value and a form has values. The widget decides when a change is made and
94
- // sends the action with its value; without one, the hub reads the control
95
- // the widget wraps. SQL has one UPDATE whether it sets one column or many,
96
- // and so there is one operation here.
97
- export const ACTION_ROW_UPDATE = "lb-row-update";
98
- // Every reserved lb-action, in one place, so the builder can refuse an
99
- // unknown one and the hub can refuse to send one it does not implement.
100
- export const LB_ACTIONS = [
101
- ACTION_ROW_INSERT,
102
- ACTION_ROW_DELETE,
103
- ACTION_ROW_UPDATE,
68
+ // The requests Loadbare provides. Each runs the page's crud declaration for
69
+ // the request's query.
70
+ export const REQUEST_ROW_INSERT = "lb-row-insert";
71
+ export const REQUEST_ROW_UPDATE = "lb-row-update";
72
+ export const REQUEST_ROW_DELETE = "lb-row-delete";
73
+ export const LB_ROW_REQUESTS = [
74
+ REQUEST_ROW_INSERT,
75
+ REQUEST_ROW_UPDATE,
76
+ REQUEST_ROW_DELETE,
104
77
  ];
105
- // --- Expansion (docs/reference/custom-elements.md) ---------------------
106
- // Marks the element in a definition whose children receive the authored
107
- // inner content. An attribute rather than an element because HTML content
108
- // models discard foreign elements inside <select> and <table>.
109
- export const ATTR_SLOT = "lb-slot";
110
- // One name in two positions. In a definition it marks a destination; on an
111
- // authored <template> it names the destination that template is for, and the
112
- // template is unwrapped into it.
113
- //
114
- // It exists because the parser, not the content model, is the obstacle. A
115
- // <thead> written inside <lb-table> on a page is not in a table, so the
116
- // tokenizer drops the tag and keeps the text. A <template> survives anywhere
117
- // and its contents parse as if they were in a table, so wrapping the markup
118
- // is what gets it to expansion intact — and unwrapping it is what puts real
119
- // elements in the shipped document.
120
- export const ATTR_TEMPLATE = "lb-template";
121
- // --- Host channel (docs/reference/chrome.md) ---------------------------
122
- // Only anchors carrying this are intercepted, so external links are never
123
- // hijacked.
124
- export const ATTR_NAV_LINK = "lb-nav-link";
125
- // Names the query parm a control writes. The query string describes what is
126
- // on screen and never commands, so a control that narrows the page writes its
127
- // value into the address bar rather than sending it: the hub sets the one
128
- // parm, or deletes it when the value is empty, and loads the page at the new
129
- // URL. Every other parm is left as it is. Landed back onto the control from
130
- // the URL on every load, so a reload, a mailed link and Back all show it.
131
- export const ATTR_QUERY_PARM = "lb-query-parm";
132
- // Changing what the current page shows is not going anywhere, so a query parm
133
- // write replaces the history entry. A control carrying this pushes one
134
- // instead, for the rare parm a user would expect Back to undo.
135
- export const ATTR_QUERY_PARM_PUSH = "lb-query-parm-push";
136
- // A page host ships as <template lb-page="<name>">. An attribute rather than
137
- // an id: an id lives in the application's own namespace, where a page named
138
- // for something the chrome also ids would collide, and getElementById()
139
- // answers a collision by silently picking one.
78
+ // --- Kinds --------------------------------------------------------------
79
+ export const KIND_ROW = "row";
80
+ export const KIND_ROWS = "rows";
81
+ // --- The URL (docs/reference/chrome.md) ---------------------------------
82
+ // The query the hub serves: one row, keyed by the path, whose other columns
83
+ // are the query parms.
84
+ export const URL_QUERY = "lb-url";
85
+ export const URL_COLUMN_PATH = "lb-path";
86
+ export const URL_COLUMN_PAGE_LABEL = "lb-page-label";
87
+ export const URL_COLUMN_PAGE_UNKNOWN = "lb-page-unknown";
88
+ // On an `<a>`: a plain primary click sets `lb-path` from the `href`.
89
+ export const ATTR_URL_LINK = "lb-url-link";
90
+ // On an element with `lb-request`: its update of `lb-url` pushes a history
91
+ // entry instead of replacing one.
92
+ export const ATTR_URL_PUSH = "lb-url-push";
93
+ // On a `<dialog>`: the hub calls showModal() when `lb-page-unknown` is true.
94
+ export const ATTR_URL_UNKNOWN = "lb-url-unknown";
95
+ // --- Build time (docs/reference/custom-elements.md) ---------------------
96
+ // Marks the element in an element file whose children receive the rest of
97
+ // the custom element's content. An attribute rather than an element because
98
+ // HTML content models discard foreign elements inside <select> and <table>.
99
+ export const ATTR_EXP_SLOT = "lb-exp-slot";
100
+ // One name in two positions. In an element file it marks a destination; on a
101
+ // `<template>` in the custom element's content it names the destination
102
+ // that template is for, and the template's content moves into it.
103
+ export const ATTR_EXP_TEMPLATE = "lb-exp-template";
104
+ // A page ships as <template lb-page="<stub>">.
140
105
  export const ATTR_PAGE = "lb-page";
141
- // The hub's own row. Landed on every navigation, on any subtree inside the
142
- // hub that names it, through the same applyData() a server answer goes
143
- // through — so a chrome displays where the page is the way it displays
144
- // anything else. One row rather than a list, so a subtree binds it with
145
- // lb-row. A reserved name (LB_RESERVED_PREFIX): the server refuses to
146
- // declare a query so named.
147
- export const NAV_ROW = "lb-navigation";
148
- // Its two columns. The label is the nav's: the text of the lb-nav-link
149
- // anchor whose href names the current page, and empty when no anchor does.
150
- // The URI is the path and query string as the browser has them.
151
- export const NAV_CELL_LABEL = "page-label";
152
- export const NAV_CELL_URI = "page-uri";
153
- // A server response that changes the query parms, in one row whose columns
154
- // are the parms. Returned from a request's run (write it with queryParms() in
155
- // server/lb-server.ts), because some values exist only once the write has
156
- // run: the key of a row just inserted, or the absence of one just deleted.
157
- // The server then loads the page at the query string with these parms set,
158
- // in the same round trip, and the hub writes them into the URL before
159
- // landing that load. An empty value takes the parm out. Only parms: the
160
- // path is never the server's to change, so this cannot redirect. A reserved
161
- // name (LB_RESERVED_PREFIX), so it never collides with a declared query.
162
- export const QUERY_PARMS_ROW = "lb-query-parms";
163
- // Marks the chrome's own <dialog> for a page name that resolves to no
164
- // template — a routing miss discovered client-side, not an HTTP 404 (every
165
- // route gets the same 200 response; see docs/tutorials/010-pages-and-navigation.md).
166
- // The hub only opens it; what it says comes from NAV_ROW, which the dialog
167
- // consumes like any other subtree, by naming it in lb-row. Optional: an
168
- // application that declares none gets today's console.error and nothing
169
- // more. The builder requires the element it's on to be a <dialog>
170
- // (build/assemble.ts), since the hub calls showModal() on it.
171
- export const ATTR_UNKNOWN_PAGE = "lb-unknown-page";
106
+ // Stamped by the builder beside ATTR_PAGE: the text content of the page
107
+ // file's `<title>`, which the builder removes.
108
+ export const ATTR_PAGE_TITLE = "lb-page-title";
109
+ // The attributes a developer writes. The builder refuses any other `lb-`
110
+ // attribute in markup: the rest are stamps, written by the hub or the
111
+ // builder and never by hand or by script.
112
+ export const DEVELOPER_ATTRIBUTES = [
113
+ ATTR_QUERY,
114
+ ATTR_COLUMN,
115
+ ATTR_SHOW,
116
+ ATTR_REQUEST,
117
+ ATTR_URL_LINK,
118
+ ATTR_URL_PUSH,
119
+ ATTR_URL_UNKNOWN,
120
+ ];
172
121
  // The hub's own tag. It is exempt from the rule every other LB-* tag
173
122
  // follows: expansion does not require it to have a definition (build/expand.ts),
174
123
  // and the client build does not require it to have a script of its own
@@ -176,23 +125,9 @@ export const ATTR_UNKNOWN_PAGE = "lb-unknown-page";
176
125
  // registered once by the package's main entry point, not a widget an
177
126
  // application discovers or declares.
178
127
  export const HUB_TAG_NAME = "lb-hub";
179
- // --- Request lifecycle --------------------------------------------------
180
- // Stamped on the element that dispatched a request — the button, form, or
181
- // widget itself — for the duration of its round trip. It carries no
182
- // meaning beyond "in flight": a stylesheet dims the element, or a custom
183
- // button widget watches it to disable itself. The hub sets and clears it,
184
- // alongside aria-busy, and reads it in one place: a native action (a button
185
- // or form, not a widget) still pending ignores being performed again.
186
- export const ATTR_PENDING = "lb-pending";
187
- // Stamped on the same element if that round trip failed — a non-2xx
188
- // response, a thrown application error, or a timeout, all alike. Cleared at
189
- // the start of that element's next request. What (if anything) an
190
- // application shows for it is undecided; this is only the fact that it
191
- // happened.
192
- export const ATTR_ERROR = "lb-error";
193
128
  // --- Wire --------------------------------------------------------------
194
129
  // One path, one method: everything the hub asks of the server is a POST
195
- // below this path. The page name follows it, and the query string the
130
+ // below this path. The page's stub follows it, and the query string the
196
131
  // browser is showing rides after that verbatim, so `/accounts?acct=23` asks
197
132
  // as `POST /lb/accounts?acct=23` and the server always knows what URL the
198
133
  // browser is showing. Navigation is therefore the only GET an application
@@ -1 +1 @@
1
- {"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2DAA2D;AAC3D,kCAAkC;AAElC,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,2BAA2B;AAE3B,8CAA8C;AAC9C,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,mEAAmE;AACnE,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEjC,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEjC,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C,kCAAkC;AAClC,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,mCAAmC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,4EAA4E;AAC5E,8EAA8E;AAC9E,qDAAqD;AACrD,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACz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CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEhD,sEAAsE;AACtE,2EAA2E;AAC3E,qFAAqF;AACrF,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;AAClE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,qEAAqE;AACrE,iFAAiF;AACjF,uEAAuE;AACvE,4EAA4E;AAC5E,qEAAqE;AACrE,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,sEAAsE;AACtE,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC,oEAAoE;AACpE,4EAA4E;AAC5E,kEAAkE;AAClE,uEAAuE;AACvE,YAAY;AACZ,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC","sourcesContent":["// Every hub attribute name lives here. Nothing writes one as a string\n// literal — not a widget, not a page host, not a test. See\n// docs/reference/data-binding.md.\n\n// --- Binding (docs/reference/data-binding.md) ---------------------------\n// One containment ladder: a list holds rows, a row holds cells. Both scope\n// attributes take a name the server declares, and a nested one of either\n// kind begins a new scope.\n\n// Scopes DOM children to a named set of rows.\nexport const ATTR_LIST = \"lb-list\";\n\n// Scopes DOM children to one named row.\n//\n// A single-row scope is read-only. Every write operation needs a key, and a\n// key exists only on a live row the hub stamped inside a list, so a declared\n// action is the only thing such a scope can send. An application that wants\n// a writable single row declares a list that answers with one row.\nexport const ATTR_ROW = \"lb-row\";\n\n// Named on a row template by the developer: the column that identifies a row\n// of the list. A property of the list rather than of the template — a list\n// without a fixed key column is meaningless — but written where the rows\n// land, because that is the only place the page says anything about them.\nexport const ATTR_KEY = \"lb-key\";\n\n// Stamped on a live row by the row machinery: that row's value of the column\n// ATTR_KEY names. Written by the hub, never by a developer, and read back by\n// whatever needs to know which row it is inside — a delete button, an update\n// form, a widget building its own request, or a stylesheet.\nexport const ATTR_KEY_VALUE = \"lb-key-value\";\n\n// The column an element displays.\n//\n// Its value is a column name and never a cell name. A cell has no name of\n// its own: it is identified by its row and its column, and the row arrives\n// from scope, so the column is all that is left to say. ATTR_KEY holds a\n// column name for the same reason.\nexport const ATTR_CELL = \"lb-cell\";\n\n// The column that decides whether an element is present: `null` and `false`\n// are off, and every other value is on. It binds by the same ancestor rule as\n// ATTR_CELL, and names a column for the same reason.\n//\n// An element that is off is moved into a `<template>` carrying this attribute\n// and the same column, standing where the element stood, and moved back out\n// when the column turns on. The builder ships every such element already\n// inside its template. A developer writes this attribute on an element and\n// never on a template: the template form is Loadbare's, and holds the absent\n// branch in the document so the hub holds nothing. Landing reaches inside it,\n// so a branch that returns is already current; nothing else does.\nexport const ATTR_SHOW = \"lb-show\";\n\nexport const ATTR_VALUE = \"lb-value\";\n\n// Stamped on a list scope by the shared row machinery: how many rows it is\n// showing. Written by the hub and never bound to — it is derived from rows\n// the hub already knows, exactly as the section heading in lb-table is. A\n// list widget watches it, and it exists so that \"no members yet\" is a\n// stylesheet rule rather than a conditional in every list widget.\nexport const ATTR_ROW_COUNT = \"lb-row-count\";\n\n// --- Requests (docs/reference/data-binding.md) --------------------------\n// One event name, used by a widget reaching the server and by a widget\n// reaching an ancestor widget.\nexport const LB_EVENT_NAME = \"lb-request\";\n\n// Names what an interaction asks for.\n//\n// One attribute name, one wire field, one set of values: the request field\n// `action` carries this attribute's value verbatim, and nothing is\n// translated in between. On a native element the hub turns the element's own\n// event into the request — a form submits, anything else clicks; on a\n// widget, the widget builds it from whatever interaction it owns.\nexport const ATTR_ACTION = \"lb-action\";\n\n// --- Reserved names ----------------------------------------------------\n// Loadbare owns every value beginning with this prefix, in every lb-*\n// attribute: a name so prefixed is the hub's own (NAV_ROW), and an\n// lb-action so prefixed is an operation (below). The server refuses a page\n// that declares a query or an action beginning with it, so a new reserved\n// name can never collide with one an application already uses.\n//\n// It is also the whole of the wire discriminant. A request whose `action`\n// begins with it is one of the three operations; anything else is a name the\n// page declared under its requests. Nothing else tells them apart.\nexport const LB_RESERVED_PREFIX = \"lb-\";\n\n// On a <form> in a list scope: builds a new row on submit. The hub gathers\n// every lb-cell inside the form into a values map — no key, because there is\n// no row yet — and the form's own lb-list says which list it is inserting\n// into.\nexport const ACTION_ROW_INSERT = \"lb-row-insert\";\n\n// Deletes the row the element is inside. Needs no declared name: it takes\n// only the row's own lb-list/lb-key-value binding, which is all the server\n// needs to know which row and whether the operation is permitted on it.\nexport const ACTION_ROW_DELETE = \"lb-row-delete\";\n\n// Commits cells of the row the element is inside. From a <form> or a button,\n// on submit or click, the hub gathers the same values map as an insert, plus\n// the row's own lb-key-value: a form that is a list's row template root, or\n// sits inside one, has both from its ancestors exactly as a delete button\n// does.\n//\n// From an element carrying lb-cell — a widget wrapping one control — the\n// values map holds that one cell and nothing else, the way a control has a\n// value and a form has values. The widget decides when a change is made and\n// sends the action with its value; without one, the hub reads the control\n// the widget wraps. SQL has one UPDATE whether it sets one column or many,\n// and so there is one operation here.\nexport const ACTION_ROW_UPDATE = \"lb-row-update\";\n\n// Every reserved lb-action, in one place, so the builder can refuse an\n// unknown one and the hub can refuse to send one it does not implement.\nexport const LB_ACTIONS = [\n ACTION_ROW_INSERT,\n ACTION_ROW_DELETE,\n ACTION_ROW_UPDATE,\n] as const;\n\n// --- Expansion (docs/reference/custom-elements.md) ---------------------\n// Marks the element in a definition whose children receive the authored\n// inner content. An attribute rather than an element because HTML content\n// models discard foreign elements inside <select> and <table>.\nexport const ATTR_SLOT = \"lb-slot\";\n\n// One name in two positions. In a definition it marks a destination; on an\n// authored <template> it names the destination that template is for, and the\n// template is unwrapped into it.\n//\n// It exists because the parser, not the content model, is the obstacle. A\n// <thead> written inside <lb-table> on a page is not in a table, so the\n// tokenizer drops the tag and keeps the text. A <template> survives anywhere\n// and its contents parse as if they were in a table, so wrapping the markup\n// is what gets it to expansion intact — and unwrapping it is what puts real\n// elements in the shipped document.\nexport const ATTR_TEMPLATE = \"lb-template\";\n\n// --- Host channel (docs/reference/chrome.md) ---------------------------\n// Only anchors carrying this are intercepted, so external links are never\n// hijacked.\nexport const ATTR_NAV_LINK = \"lb-nav-link\";\n\n// Names the query parm a control writes. The query string describes what is\n// on screen and never commands, so a control that narrows the page writes its\n// value into the address bar rather than sending it: the hub sets the one\n// parm, or deletes it when the value is empty, and loads the page at the new\n// URL. Every other parm is left as it is. Landed back onto the control from\n// the URL on every load, so a reload, a mailed link and Back all show it.\nexport const ATTR_QUERY_PARM = \"lb-query-parm\";\n\n// Changing what the current page shows is not going anywhere, so a query parm\n// write replaces the history entry. A control carrying this pushes one\n// instead, for the rare parm a user would expect Back to undo.\nexport const ATTR_QUERY_PARM_PUSH = \"lb-query-parm-push\";\n\n// A page host ships as <template lb-page=\"<name>\">. An attribute rather than\n// an id: an id lives in the application's own namespace, where a page named\n// for something the chrome also ids would collide, and getElementById()\n// answers a collision by silently picking one.\nexport const ATTR_PAGE = \"lb-page\";\n\n// The hub's own row. Landed on every navigation, on any subtree inside the\n// hub that names it, through the same applyData() a server answer goes\n// through — so a chrome displays where the page is the way it displays\n// anything else. One row rather than a list, so a subtree binds it with\n// lb-row. A reserved name (LB_RESERVED_PREFIX): the server refuses to\n// declare a query so named.\nexport const NAV_ROW = \"lb-navigation\";\n\n// Its two columns. The label is the nav's: the text of the lb-nav-link\n// anchor whose href names the current page, and empty when no anchor does.\n// The URI is the path and query string as the browser has them.\nexport const NAV_CELL_LABEL = \"page-label\";\nexport const NAV_CELL_URI = \"page-uri\";\n\n// A server response that changes the query parms, in one row whose columns\n// are the parms. Returned from a request's run (write it with queryParms() in\n// server/lb-server.ts), because some values exist only once the write has\n// run: the key of a row just inserted, or the absence of one just deleted.\n// The server then loads the page at the query string with these parms set,\n// in the same round trip, and the hub writes them into the URL before\n// landing that load. An empty value takes the parm out. Only parms: the\n// path is never the server's to change, so this cannot redirect. A reserved\n// name (LB_RESERVED_PREFIX), so it never collides with a declared query.\nexport const QUERY_PARMS_ROW = \"lb-query-parms\";\n\n// Marks the chrome's own <dialog> for a page name that resolves to no\n// template — a routing miss discovered client-side, not an HTTP 404 (every\n// route gets the same 200 response; see docs/tutorials/010-pages-and-navigation.md).\n// The hub only opens it; what it says comes from NAV_ROW, which the dialog\n// consumes like any other subtree, by naming it in lb-row. Optional: an\n// application that declares none gets today's console.error and nothing\n// more. The builder requires the element it's on to be a <dialog>\n// (build/assemble.ts), since the hub calls showModal() on it.\nexport const ATTR_UNKNOWN_PAGE = \"lb-unknown-page\";\n\n// The hub's own tag. It is exempt from the rule every other LB-* tag\n// follows: expansion does not require it to have a definition (build/expand.ts),\n// and the client build does not require it to have a script of its own\n// (build/elements.ts) — it is the framework's live element, always present,\n// registered once by the package's main entry point, not a widget an\n// application discovers or declares.\nexport const HUB_TAG_NAME = \"lb-hub\";\n\n// --- Request lifecycle --------------------------------------------------\n// Stamped on the element that dispatched a request — the button, form, or\n// widget itself — for the duration of its round trip. It carries no\n// meaning beyond \"in flight\": a stylesheet dims the element, or a custom\n// button widget watches it to disable itself. The hub sets and clears it,\n// alongside aria-busy, and reads it in one place: a native action (a button\n// or form, not a widget) still pending ignores being performed again.\nexport const ATTR_PENDING = \"lb-pending\";\n\n// Stamped on the same element if that round trip failed — a non-2xx\n// response, a thrown application error, or a timeout, all alike. Cleared at\n// the start of that element's next request. What (if anything) an\n// application shows for it is undecided; this is only the fact that it\n// happened.\nexport const ATTR_ERROR = \"lb-error\";\n\n// --- Wire --------------------------------------------------------------\n// One path, one method: everything the hub asks of the server is a POST\n// below this path. The page name follows it, and the query string the\n// browser is showing rides after that verbatim, so `/accounts?acct=23` asks\n// as `POST /lb/accounts?acct=23` and the server always knows what URL the\n// browser is showing. Navigation is therefore the only GET an application\n// serves, which is what leaves the page name space unrestricted.\nexport const LB_ENDPOINT = \"/lb\";\n\n// A client-side deadline for one round trip. fetch() has no deadline of its\n// own; past this the request is aborted and treated as a failure.\nexport const LB_REQUEST_TIMEOUT_MS = 10_000;\n"]}
1
+ {"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2DAA2D;AAC3D,kCAAkC;AAElC,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,2EAA2E;AAC3E,2BAA2B;AAE3B,wEAAwE;AACxE,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,wEAAwE;AACxE,2EAA2E;AAC3E,mCAAmC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEvC,4EAA4E;AAC5E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,0EAA0E;AAC1E,2EAA2E;AAC3E,yBAAyB;AACzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,0EAA0E;AAC1E,wEAAwE;AACxE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C,2EAA2E;AAC3E,sEAAsE;AACtE,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,I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iBAAiB,CAAC;AAEzD,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,2EAA2E;AAC3E,kCAAkC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,6EAA6E;AAC7E,wEAAwE;AACxE,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,wEAAwE;AACxE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAE/C,yEAAyE;AACzE,sEAAsE;AACtE,0CAA0C;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,WAAW;IACX,SAAS;IACT,YAAY;IACZ,aAAa;IACb,aAAa;IACb,gBAAgB;CACR,CAAC;AAEX,qEAAqE;AACrE,iFAAiF;AACjF,uEAAuE;AACvE,4EAA4E;AAC5E,qEAAqE;AACrE,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC","sourcesContent":["// Every Loadbare attribute name lives here. Nothing writes one as a string\n// literal — not a widget, not a page host, not a test. See\n// docs/reference/data-binding.md.\n\n// --- Landing (docs/reference/data-binding.md) ----------------------------\n// Everything is a query. The server answers every request with response\n// items, one per query, and each carries the query's kind and key. The\n// markup names a query and the columns it shows; it never repeats what the\n// server already declared.\n\n// Names the query whose rows land in an element's content. A nested one\n// begins a new query: what is inside it is that query's.\nexport const ATTR_QUERY = \"lb-query\";\n\n// The column an element shows, read from the nearest ancestor row. On a\n// control the hub sets its value, and gathers it back under this name when\n// the control's request is issued.\nexport const ATTR_COLUMN = \"lb-column\";\n\n// The column that decides whether an element is present: `null` and `false`\n// are off, and every other value is on. It reads from the nearest ancestor\n// row, as ATTR_COLUMN does.\n//\n// An element that is off is moved into a `<template>` carrying this attribute\n// and the same column, standing where the element stood, and moved back out\n// when the column turns on. The builder ships every such element already\n// inside its template. A developer writes this attribute on an element and\n// never on a template: the template form is Loadbare's, and holds the absent\n// branch in the document so the hub holds nothing. Landing reaches inside it,\n// so a branch that returns is already current; nothing else does.\nexport const ATTR_SHOW = \"lb-show\";\n\n// Stamped by the hub on every element it sets from a column: the value it\n// set, so a stylesheet can select on it and a custom element that is not a\n// control can render it.\nexport const ATTR_COLUMN_VALUE = \"lb-column-value\";\n\n// Stamped by the hub on each live row, and on an element a `row` lands on\n// itself: the row's key. The key column is the query's, declared by the\n// server and carried by every response item.\nexport const ATTR_KEY_VALUE = \"lb-key-value\";\n\n// Stamped by the hub on each live row, and on nothing else: the element it\n// cloned from a row template. A key alone does not say so, because an\n// element a `row` lands on carries one too, and a live row may name a query\n// of its own, so neither the key nor `lb-query` tells the two apart.\nexport const ATTR_ROW_LIVE = \"lb-row-live\";\n\n// Selects a live row. Anything that walks rows — reconciliation, gathering,\n// a custom element's own placement — finds them with this and nothing else.\nexport const LIVE_ROW = `[${ATTR_ROW_LIVE}]`;\n\n// Stamped by the hub on an element with a row template: how many live rows\n// it holds, so \"no members yet\" is a stylesheet rule rather than a\n// conditional in every widget.\nexport const ATTR_QUERY_ROW_COUNT = \"lb-query-row-count\";\n\n// --- Requests (docs/reference/data-binding.md) --------------------------\n// Names the request an element issues when it commits: a form on submit, a\n// control on change, anything else on click.\nexport const ATTR_REQUEST = \"lb-request\";\n\n// Every request travels as one bubbling event of this name, whoever issued\n// it, so an ancestor may stop it.\nexport const LB_EVENT_NAME = \"lb-request\";\n\n// Stamped on the element that issued a request while its round trip is in\n// flight, alongside aria-busy. A commit on an element carrying it is ignored.\nexport const ATTR_REQUEST_PENDING = \"lb-request-pending\";\n\n// Stamped on the element that issued a request when its round trip failed —\n// a non-2xx response, a thrown application error, or a timeout, all alike.\n// Cleared at the start of that element's next request.\nexport const ATTR_REQUEST_ERROR = \"lb-request-error\";\n\n// --- Reserved names ----------------------------------------------------\n// Loadbare owns every name beginning with this prefix: attribute names, the\n// values of its attributes, query names, request names, the column names of\n// its own queries, custom element names and event names. The server refuses\n// a page that declares a query or a request so named.\nexport const LB_RESERVED_PREFIX = \"lb-\";\n\n// The requests Loadbare provides. Each runs the page's crud declaration for\n// the request's query.\nexport const REQUEST_ROW_INSERT = \"lb-row-insert\";\nexport const REQUEST_ROW_UPDATE = \"lb-row-update\";\nexport const REQUEST_ROW_DELETE = \"lb-row-delete\";\n\nexport const LB_ROW_REQUESTS = [\n REQUEST_ROW_INSERT,\n REQUEST_ROW_UPDATE,\n REQUEST_ROW_DELETE,\n] as const;\n\n// --- Kinds --------------------------------------------------------------\nexport const KIND_ROW = \"row\";\nexport const KIND_ROWS = \"rows\";\n\n// --- The URL (docs/reference/chrome.md) ---------------------------------\n// The query the hub serves: one row, keyed by the path, whose other columns\n// are the query parms.\nexport const URL_QUERY = \"lb-url\";\nexport const URL_COLUMN_PATH = \"lb-path\";\nexport const URL_COLUMN_PAGE_LABEL = \"lb-page-label\";\nexport const URL_COLUMN_PAGE_UNKNOWN = \"lb-page-unknown\";\n\n// On an `<a>`: a plain primary click sets `lb-path` from the `href`.\nexport const ATTR_URL_LINK = \"lb-url-link\";\n\n// On an element with `lb-request`: its update of `lb-url` pushes a history\n// entry instead of replacing one.\nexport const ATTR_URL_PUSH = \"lb-url-push\";\n\n// On a `<dialog>`: the hub calls showModal() when `lb-page-unknown` is true.\nexport const ATTR_URL_UNKNOWN = \"lb-url-unknown\";\n\n// --- Build time (docs/reference/custom-elements.md) ---------------------\n// Marks the element in an element file whose children receive the rest of\n// the custom element's content. An attribute rather than an element because\n// HTML content models discard foreign elements inside <select> and <table>.\nexport const ATTR_EXP_SLOT = \"lb-exp-slot\";\n\n// One name in two positions. In an element file it marks a destination; on a\n// `<template>` in the custom element's content it names the destination\n// that template is for, and the template's content moves into it.\nexport const ATTR_EXP_TEMPLATE = \"lb-exp-template\";\n\n// A page ships as <template lb-page=\"<stub>\">.\nexport const ATTR_PAGE = \"lb-page\";\n\n// Stamped by the builder beside ATTR_PAGE: the text content of the page\n// file's `<title>`, which the builder removes.\nexport const ATTR_PAGE_TITLE = \"lb-page-title\";\n\n// The attributes a developer writes. The builder refuses any other `lb-`\n// attribute in markup: the rest are stamps, written by the hub or the\n// builder and never by hand or by script.\nexport const DEVELOPER_ATTRIBUTES = [\n ATTR_QUERY,\n ATTR_COLUMN,\n ATTR_SHOW,\n ATTR_REQUEST,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_UNKNOWN,\n] as const;\n\n// The hub's own tag. It is exempt from the rule every other LB-* tag\n// follows: expansion does not require it to have a definition (build/expand.ts),\n// and the client build does not require it to have a script of its own\n// (build/elements.ts) — it is the framework's live element, always present,\n// registered once by the package's main entry point, not a widget an\n// application discovers or declares.\nexport const HUB_TAG_NAME = \"lb-hub\";\n\n// --- Wire --------------------------------------------------------------\n// One path, one method: everything the hub asks of the server is a POST\n// below this path. The page's stub follows it, and the query string the\n// browser is showing rides after that verbatim, so `/accounts?acct=23` asks\n// as `POST /lb/accounts?acct=23` and the server always knows what URL the\n// browser is showing. Navigation is therefore the only GET an application\n// serves, which is what leaves the page name space unrestricted.\nexport const LB_ENDPOINT = \"/lb\";\n\n// A client-side deadline for one round trip. fetch() has no deadline of its\n// own; past this the request is aborted and treated as a failure.\nexport const LB_REQUEST_TIMEOUT_MS = 10_000;\n"]}
@@ -1,4 +1,4 @@
1
- import { ACTION_ROW_DELETE, ACTION_ROW_INSERT, ACTION_ROW_UPDATE } from "./lb-constants.js";
1
+ import { KIND_ROW, KIND_ROWS } from "./lb-constants.js";
2
2
  /**
3
3
  * One row: its columns, by name.
4
4
  *
@@ -9,9 +9,9 @@ import { ACTION_ROW_DELETE, ACTION_ROW_INSERT, ACTION_ROW_UPDATE } from "./lb-co
9
9
  */
10
10
  export type Row = Record<string, unknown>;
11
11
  /**
12
- * Part of a list — see docs/reference/server.md, "Queries".
12
+ * Part of a `rows` query's answer — see docs/reference/server.md, "Queries".
13
13
  *
14
- * Rows named here arrive or are updated, keys in `drop` are gone, and
14
+ * Rows named here are added or updated, keys in `drop` are removed, and
15
15
  * anything unnamed is left alone: its contents, and its place in whatever
16
16
  * order the widget is keeping. Add and remove are one result rather than two
17
17
  * because the interesting cases are both at once — a row whose sort key
@@ -22,77 +22,51 @@ export interface Patch {
22
22
  rows?: Row[];
23
23
  drop?: unknown[];
24
24
  }
25
+ /** A query's kind, declared by the server and carried by every answer. */
26
+ export type Kind = typeof KIND_ROW | typeof KIND_ROWS;
25
27
  /**
26
- * What a list answers with.
27
- *
28
- * An array is the entire set and therefore also the order: a row whose key
29
- * is not in it is gone. A Patch disturbs only what it names.
30
- *
31
- * `Array.isArray` tells the two apart, which is why no column name has to be
32
- * reserved to carry a discriminant. A list answering with an object is a
33
- * patch, because the declaration already said this name answers with rows.
34
- */
35
- export type ListResult = Row[] | Patch;
36
- export declare function isPatch(result: ListResult): result is Patch;
37
- /**
38
- * What any one name answers with. Which of the two it is comes from the
39
- * query's own declaration, never from inspecting the value.
28
+ * What a `rows` query answers with: all rows, which is also their order, or
29
+ * a patch. `Array.isArray` tells the two apart.
40
30
  */
41
- export type HubResult = Row | ListResult;
31
+ export type RowsResult = Row[] | Patch;
32
+ export declare function isPatch(result: RowsResult): result is Patch;
33
+ /** What any one query answers with, as the application writes it. */
34
+ export type HubResult = Row | RowsResult;
42
35
  /**
43
- * Every response on the data channel is the same shape, whether it is a cold
44
- * start or the narrowest refresh. The hub does not know which case it is in.
45
- *
46
- * A name rides as an object key and is labelled by nothing, which is why the
47
- * response direction never needed a noun for the addressable thing.
36
+ * What application code hands the engine: answers by query name. The engine
37
+ * turns each into a response item, adding the kind and key the query
38
+ * declared.
48
39
  */
49
40
  export type HubData = Record<string, HubResult>;
50
41
  /**
51
- * The three operations — docs/reference/data-binding.md. The set is closed.
52
- *
53
- * `action` carries the value of `lb-action` verbatim, so the attribute, the
54
- * wire field and the CRUD key are one vocabulary with no translation step.
55
- * The scope field is `list` here because all three are list operations: each
56
- * needs a key, and a key exists only on a live row inside a list.
42
+ * One query's answer on the wire: its name, its kind, its key's column name,
43
+ * and exactly one of a row, all rows, or a patch. A patch answers a `rows`
44
+ * query only.
57
45
  */
58
- export type LbOperation = {
59
- action: typeof ACTION_ROW_INSERT;
60
- list: string;
61
- values: Record<string, string>;
62
- } | {
63
- action: typeof ACTION_ROW_DELETE;
64
- list: string;
46
+ export interface ResponseItem {
47
+ query: string;
48
+ kind: Kind;
65
49
  key: string;
66
- } | {
67
- action: typeof ACTION_ROW_UPDATE;
68
- list: string;
69
- key: string;
70
- values: Record<string, string>;
71
- };
50
+ row?: Row;
51
+ rows?: Row[];
52
+ patch?: Patch;
53
+ }
54
+ /** Every response the server sends: a page load and a request alike. */
55
+ export type HubResponse = ResponseItem[];
72
56
  /**
73
- * Everything that is not one of the three.
74
- *
75
- * The name is the application's and is looked up in the page's declared
76
- * actions. What keeps this from being an RPC endpoint is that the name must
77
- * already appear in the page's requests: the browser cannot reach anything the
78
- * page has not published, and there is no argument list — only where the
79
- * interaction happened and, where a control has one, its value.
80
- *
81
- * The scope field is `list` or `row`, whichever attribute scoped the element
82
- * the interaction came from, so an action fired from a single-row scope says
83
- * so. A button carries no value, so the server computes the whole of the new
84
- * state and the browser never displays a number it has not confirmed. A
85
- * `<select>` carries one, because the choice is the interaction.
57
+ * Every request has one shape. The name picks the handler; the rest is
58
+ * present when the hub found it.
86
59
  */
87
- export interface DeclaredAction {
88
- action: string;
89
- list?: string;
90
- row?: string;
60
+ export interface HubRequest {
61
+ name: string;
62
+ query?: string;
91
63
  key?: string;
92
- cell?: string;
93
- value?: string;
64
+ values?: Record<string, string>;
94
65
  }
95
- export type HubRequest = LbOperation | DeclaredAction;
66
+ /** The fields a handler receives: the request, less its name. */
67
+ export type RequestFields = Omit<HubRequest, "name">;
68
+ /** Whether a name is one of the requests Loadbare provides. */
69
+ export declare function isRowRequest(name: string): boolean;
96
70
  /**
97
71
  * A query string with some parms set, and the rest as they were. An empty
98
72
  * value takes its parm out, since empty is every parm's default and a
@@ -100,30 +74,43 @@ export type HubRequest = LbOperation | DeclaredAction;
100
74
  *
101
75
  * One rule on both sides of the wire: the hub applies it to the address bar,
102
76
  * and the server to the query string it loads the page at after a request
103
- * returned `QUERY_PARMS_ROW`. The two must agree, or what the page shows
104
- * would differ from what the address bar says.
77
+ * returned `lb-url`. The two must agree, or what the page shows would differ
78
+ * from what the address bar says.
105
79
  */
106
80
  export declare function withQueryParms(search: URLSearchParams, parms: Record<string, string>): URLSearchParams;
107
81
  /**
108
- * The reserved prefix is the whole of the discriminant. Nothing else tells
109
- * an operation from a declared action, on the wire or anywhere else.
82
+ * A path names a page by its stub, and nothing finer. The bare path resolves
83
+ * to `index`, the same convention a static file server follows.
110
84
  */
111
- export declare function isOperation(request: HubRequest): request is LbOperation;
85
+ export declare function pageNameFor(path: string): string;
112
86
  /**
113
- * The two hooks a list widget may implement, both optional.
87
+ * Where a row for `lb-url` leads, from a page and its query parms.
114
88
  *
115
- * The hub reconciles every list scope itself, so a widget supplies placement
116
- * and scaffolding and nothing else. A scope that implements neither is a
117
- * plain element with a row template inside it, which is why there is no
118
- * repeater widget.
89
+ * A column whose name begins with `lb-` is Loadbare's, and never a query
90
+ * parm; every other column is one. An `lb-path` naming another page enters
91
+ * it with only the parms the row names. Otherwise the named parms are set,
92
+ * or taken out when empty, and the rest are kept.
93
+ *
94
+ * One rule on both sides of the wire: the server loads the page it names,
95
+ * and the hub writes the URL it names. The two must agree, or what the page
96
+ * shows would differ from what the address bar says.
97
+ */
98
+ export declare function nextLocation(page: string, parms: URLSearchParams, row: Row): {
99
+ page: string;
100
+ parms: URLSearchParams;
101
+ moved: boolean;
102
+ };
103
+ /**
104
+ * The two hooks a custom element holding rows may implement, both optional.
119
105
  *
120
- * They are methods on an element the hub does not own, so they carry the
121
- * `lb` prefix that Loadbare reserves for exactly that — see
122
- * docs/reference/custom-elements.md.
106
+ * The hub reconciles every row template itself, so a custom element supplies
107
+ * placement and scaffolding and nothing else. They are methods on an element
108
+ * the hub does not own, so they carry the `lb` prefix Loadbare reserves for
109
+ * exactly that — see docs/reference/custom-elements.md.
123
110
  */
124
- export interface ListHost {
111
+ export interface RowsHost {
125
112
  /**
126
- * Where a row belongs, called with the row detached on its first
113
+ * Where a live row belongs, called with the row detached on its first
127
114
  * appearance. Without it a row lands immediately before the template, so
128
115
  * rows accumulate in the order they arrive.
129
116
  */
@@ -1 +1 @@
1
- {"version":3,"file":"lb-types.d.ts","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;AAEvC,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,KAAK,CAE3D;AAED;;;G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