@loadbare/app 0.25.0 → 0.27.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 (56) hide show
  1. package/dist/build/assemble.d.ts +1 -2
  2. package/dist/build/assemble.d.ts.map +1 -1
  3. package/dist/build/assemble.js +31 -37
  4. package/dist/build/assemble.js.map +1 -1
  5. package/dist/build/cli.d.ts +4 -10
  6. package/dist/build/cli.d.ts.map +1 -1
  7. package/dist/build/cli.js +11 -33
  8. package/dist/build/cli.js.map +1 -1
  9. package/dist/build/declared.js +1 -1
  10. package/dist/build/declared.js.map +1 -1
  11. package/dist/core/lb-constants.d.ts +15 -13
  12. package/dist/core/lb-constants.d.ts.map +1 -1
  13. package/dist/core/lb-constants.js +47 -51
  14. package/dist/core/lb-constants.js.map +1 -1
  15. package/dist/core/lb-types.d.ts +12 -11
  16. package/dist/core/lb-types.d.ts.map +1 -1
  17. package/dist/core/lb-types.js +7 -0
  18. package/dist/core/lb-types.js.map +1 -1
  19. package/dist/hub/lb-apply.d.ts +10 -34
  20. package/dist/hub/lb-apply.d.ts.map +1 -1
  21. package/dist/hub/lb-apply.js +92 -151
  22. package/dist/hub/lb-apply.js.map +1 -1
  23. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  24. package/dist/hub/lb-hub.browser.js +115 -127
  25. package/dist/hub/lb-hub.browser.js.map +1 -1
  26. package/dist/hub/lb-lifecycle.d.ts.map +1 -1
  27. package/dist/hub/lb-lifecycle.js +4 -11
  28. package/dist/hub/lb-lifecycle.js.map +1 -1
  29. package/dist/server/lb-express.d.ts.map +1 -1
  30. package/dist/server/lb-express.js +3 -3
  31. package/dist/server/lb-express.js.map +1 -1
  32. package/dist/server/lb-server.d.ts +35 -19
  33. package/dist/server/lb-server.d.ts.map +1 -1
  34. package/dist/server/lb-server.js +141 -88
  35. package/dist/server/lb-server.js.map +1 -1
  36. package/docs/binding-cases.md +150 -0
  37. package/docs/comparison.md +34 -38
  38. package/docs/opinions.md +2 -2
  39. package/docs/reference/chrome.md +8 -10
  40. package/docs/reference/css.md +9 -10
  41. package/docs/reference/custom-elements.md +11 -8
  42. package/docs/reference/data-binding.md +93 -134
  43. package/docs/reference/names.md +21 -22
  44. package/docs/reference/page-files.md +24 -26
  45. package/docs/reference/server.md +3 -4
  46. package/docs/roadmap.md +2 -2
  47. package/docs/testing.md +5 -6
  48. package/package.json +1 -1
  49. package/skills/loadbare-app/SKILL.md +55 -48
  50. package/skills/loadbare-app/references/chrome.md +8 -10
  51. package/skills/loadbare-app/references/css.md +9 -10
  52. package/skills/loadbare-app/references/custom-elements.md +11 -8
  53. package/skills/loadbare-app/references/data-binding.md +93 -134
  54. package/skills/loadbare-app/references/names.md +21 -22
  55. package/skills/loadbare-app/references/page-files.md +24 -26
  56. package/skills/loadbare-app/references/server.md +3 -4
@@ -1,7 +1,6 @@
1
1
  // Every Loadbare attribute name lives here. Nothing writes one as a string
2
- // literal — not a widget, not a page host, not a test. See
3
- // docs/reference/data-binding.md.
4
- // --- Landing (docs/reference/data-binding.md) ----------------------------
2
+ // literal — not a widget, not a page host, not a test.
3
+ // --- Landing -------------------------------------------------------------
5
4
  // Everything is a query. The server answers every request with response
6
5
  // items, one per query, and each carries the query's kind and key. The
7
6
  // markup names a query and the columns it shows; it never repeats what the
@@ -56,7 +55,7 @@ export const ATTR_QUERY_UNPLACED_COUNT = "lb-query-unplaced-count";
56
55
  // placed by, the user's or else the server's, as an order's text, so a
57
56
  // widget or a stylesheet can show it. Absent when the rows have no order.
58
57
  export const ATTR_QUERY_ORDER = "lb-query-order";
59
- // --- Order and groups (docs/reference/data-binding.md) -------------------
58
+ // --- Order and groups ----------------------------------------------------
60
59
  // A `rows` query's order is a rule over its columns, and the hub places
61
60
  // live rows by it, except that an edit from inside a list leaves that list's
62
61
  // rows where they stand. A group is a run of rows sharing the order's leading term.
@@ -76,41 +75,41 @@ export const ATTR_GROUP_COLUMN = "lb-group-column";
76
75
  export const ATTR_GROUP_VALUE = "lb-group-value";
77
76
  // Selects a group's element, as LIVE_ROW selects a live row.
78
77
  export const LIVE_GROUP = `[${ATTR_GROUP_LIVE}]`;
79
- // Aggregates, written on any element in a group template or in the element
80
- // naming the query: the hub sets the element from the rows of the nearest
81
- // group around it, or of the whole list outside any group. `lb-count` takes
82
- // no value; the others name the column they aggregate.
83
- export const ATTR_COUNT = "lb-count";
84
- export const ATTR_SUM = "lb-sum";
85
- export const ATTR_AVG = "lb-avg";
86
- export const ATTR_MIN = "lb-min";
87
- export const ATTR_MAX = "lb-max";
78
+ // An aggregate, written on any element in a group template or in the
79
+ // element naming the query: set from the rows showing in the nearest group
80
+ // around it, or in the whole list outside any group. `lb-aggregate` names the
81
+ // function and `lb-column` the column; `count` with no column counts rows.
82
+ export const ATTR_AGGREGATE = "lb-aggregate";
83
+ export const AGGREGATE_COUNT = "count";
84
+ export const AGGREGATE_SUM = "sum";
85
+ export const AGGREGATE_AVG = "avg";
86
+ export const AGGREGATE_MIN = "min";
87
+ export const AGGREGATE_MAX = "max";
88
88
  export const AGGREGATES = [
89
- ATTR_COUNT,
90
- ATTR_SUM,
91
- ATTR_AVG,
92
- ATTR_MIN,
93
- ATTR_MAX,
89
+ AGGREGATE_COUNT,
90
+ AGGREGATE_SUM,
91
+ AGGREGATE_AVG,
92
+ AGGREGATE_MIN,
93
+ AGGREGATE_MAX,
94
94
  ];
95
95
  // Written before a column in an order, it sorts that column descending.
96
96
  export const ORDER_DESCENDING = "-";
97
97
  // The types a `rows` query may declare for its columns. Sorting, filtering,
98
- // `lb-min` and `lb-max` read a declared column as its type rather than by
98
+ // `min` and `max` read a declared column as its type rather than by
99
99
  // the JSON type its values arrive as.
100
100
  export const COLUMN_TYPES = ["number", "boolean", "text"];
101
- // --- Choices (docs/reference/data-binding.md) -----------------------------
102
- // What the user chose for how rows show: an order, a filter. The hub serves
103
- // them as its own query, one row keyed by the path, with a column per choice,
104
- // and any control inside `lb-query="lb-choices"` writes one with
105
- // `lb-row-update`. They hold until the page changes.
106
- export const CHOICES_QUERY = "lb-choices";
107
- // On an element naming a `rows` query: the column of `lb-choices` holding the
108
- // user's order for its rows, as an order's text. While that column is empty,
109
- // the order the server declared places them.
110
- export const ATTR_ORDER = "lb-order";
111
- // On an element naming a `rows` query: the columns of its rows that a choice
112
- // may filter, separated by commas. The column of `lb-choices` of the same
113
- // name holds the filter, and a row it does not pass is `hidden`.
101
+ // --- Sort and filter -----------------------------------------------------
102
+ // What the user chose for how rows show, in two hub-owned queries, one row
103
+ // per query keyed by the query's name. The server and the browser each may
104
+ // read and write them.
105
+ export const SORT_QUERY = "lb-sort";
106
+ export const SORT_COLUMN_QUERY = "query";
107
+ export const SORT_COLUMN_ORDER = "order";
108
+ export const FILTERS_QUERY = "lb-filters";
109
+ export const FILTERS_COLUMN_QUERY = "query";
110
+ // On an element naming a `rows` query: the columns of its rows the user may
111
+ // filter, separated by commas. The `lb-filters` row for the query holds each
112
+ // filter, and a row it does not pass is `hidden`.
114
113
  export const ATTR_FILTER = "lb-filter";
115
114
  // On an element naming a `rows` query: which placements wait for the user,
116
115
  // `order`, `filter` or both, separated by spaces. A side not named is placed
@@ -134,7 +133,7 @@ export const FILTER_OPERATORS = [
134
133
  "<",
135
134
  ">",
136
135
  ];
137
- // --- What happened to a row (docs/reference/data-binding.md) ------------
136
+ // --- What happened to a row ----------------------------------------------
138
137
  // Every change the hub makes to a list is one a stylesheet can see, so an
139
138
  // application animates with CSS alone. The first three are cleared when the
140
139
  // hub next touches the row, and a stamp applied again is removed and added
@@ -162,7 +161,7 @@ export const ATTR_ROW_UNPLACED = "lb-row-unplaced";
162
161
  // there are none.
163
162
  export const ATTR_ROW_LEAVING = "lb-row-leaving";
164
163
  export const ATTR_GROUP_LEAVING = "lb-group-leaving";
165
- // --- Requests (docs/reference/data-binding.md) --------------------------
164
+ // --- Requests ------------------------------------------------------------
166
165
  // Names the request an element issues when it commits: a form on submit, a
167
166
  // control on change, anything else on click.
168
167
  export const ATTR_REQUEST = "lb-request";
@@ -189,7 +188,7 @@ export const LB_REFUSAL_STATUS = 422;
189
188
  // a non-2xx response, a thrown application error, or a timeout, all alike.
190
189
  // Cleared at the start of that element's next request.
191
190
  export const ATTR_REQUEST_ERROR = "lb-request-error";
192
- // --- A form pointed at a row (docs/reference/data-binding.md) -----------
191
+ // --- A form pointed at a row ---------------------------------------------
193
192
  // One form edits any row of its query, or enters a new one. A button points
194
193
  // it with HTML's own `commandfor="<form id>"` and one of these commands,
195
194
  // which HTML requires to begin with `--`. The hub hears the `command` event
@@ -215,13 +214,6 @@ export const LB_COMMAND_PREFIX = "--lb-";
215
214
  // Stamped by the hub on the live row a form is pointed at, until the form
216
215
  // lets go of it.
217
216
  export const ATTR_ROW_EDITING = "lb-row-editing";
218
- // --- Selecting rows (docs/reference/data-binding.md) ---------------------
219
- // On a checkbox in a row template: ticking it selects the live row it sits
220
- // in. It is not a column and is not gathered as one. A request for the
221
- // row's query that names no one row carries the keys of every row selected.
222
- export const ATTR_SELECT = "lb-select";
223
- // Stamped by the hub on a live row while its `lb-select` checkbox is ticked.
224
- export const ATTR_ROW_SELECTED = "lb-row-selected";
225
217
  // --- Reserved names ----------------------------------------------------
226
218
  // Loadbare owns every name beginning with this prefix: attribute names, the
227
219
  // values of its attributes, query names, request names, the column names of
@@ -238,6 +230,12 @@ export const LB_ROW_REQUESTS = [
238
230
  REQUEST_ROW_UPDATE,
239
231
  REQUEST_ROW_DELETE,
240
232
  ];
233
+ // The hub's own read: the queries it names, run again at the URL the request
234
+ // is sent from. The hub sends it when Edit or New binds a form, for the lists
235
+ // nested in the form, with the bound row's key as a parm named for the form's
236
+ // key column, so a list inside a row follows the row it is bound to. Markup
237
+ // never writes it.
238
+ export const REQUEST_READ = "lb-read";
241
239
  // Loadbare also owns every method name on a custom element that begins with
242
240
  // `lb` and a capital. These are the ones it calls (the HubLifecycle interface
243
241
  // in core/lb-types.ts); the builder refuses a script that declares any other.
@@ -258,18 +256,17 @@ export const BROWSER_LIFECYCLE = [
258
256
  // --- Kinds --------------------------------------------------------------
259
257
  export const KIND_ROW = "row";
260
258
  export const KIND_ROWS = "rows";
261
- // --- The URL (docs/reference/chrome.md) ---------------------------------
259
+ // --- The URL -------------------------------------------------------------
262
260
  // The query the hub serves: one row, keyed by the path, whose other columns
263
261
  // are the query parms.
264
262
  export const URL_QUERY = "lb-url";
265
263
  export const URL_COLUMN_PATH = "lb-path";
266
264
  export const URL_COLUMN_PAGE_LABEL = "lb-page-label";
267
- export const URL_COLUMN_PAGE_UNKNOWN = "lb-page-unknown";
268
- // --- Round trips (docs/reference/chrome.md) ------------------------------
265
+ // --- Round trips ---------------------------------------------------------
269
266
  // The query the hub serves with its own state: one row, keyed by the path,
270
267
  // telling whether the page's data arrived and whether the server answers.
271
268
  // The hub stamps the same columns on `<lb-hub>` itself, for a stylesheet.
272
- export const HUB_QUERY = "lb-hub";
269
+ export const HUB_QUERY = "lb-hub-status";
273
270
  // `loading`, `loaded` or `failed`: the page load for the URL showing.
274
271
  export const HUB_COLUMN_LOAD_STATE = "lb-load-state";
275
272
  // `reachable`, `failing` or `unreachable`: how the latest round trip of any
@@ -299,9 +296,10 @@ export const ATTR_URL_PUSH = "lb-url-push";
299
296
  // by commas, each added to the `href`'s query string as the parm of the same
300
297
  // name.
301
298
  export const ATTR_URL_PARM = "lb-url-parm";
302
- // On a `<dialog>`: the hub calls showModal() when `lb-page-unknown` is true.
299
+ // On a `<dialog>`: the hub calls showModal() when the path names a page that
300
+ // does not exist.
303
301
  export const ATTR_URL_UNKNOWN = "lb-url-unknown";
304
- // --- Build time (docs/reference/custom-elements.md) ---------------------
302
+ // --- Build time ----------------------------------------------------------
305
303
  // Marks the element in an element file whose children receive the rest of
306
304
  // the custom element's content. An attribute rather than an element because
307
305
  // HTML content models discard foreign elements inside <select> and <table>.
@@ -323,12 +321,10 @@ export const DEVELOPER_ATTRIBUTES = [
323
321
  ATTR_COLUMN,
324
322
  ATTR_SHOW,
325
323
  ATTR_GROUP,
326
- ...AGGREGATES,
327
- ATTR_ORDER,
324
+ ATTR_AGGREGATE,
328
325
  ATTR_FILTER,
329
326
  ATTR_MANUAL,
330
327
  ATTR_REQUEST,
331
- ATTR_SELECT,
332
328
  ATTR_URL_LINK,
333
329
  ATTR_URL_PUSH,
334
330
  ATTR_URL_PARM,
@@ -1 +1 @@
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,qEAAqE;AACrE,kEAAkE;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE5B,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,G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AAG,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// Written before the column in ATTR_SHOW, it reverses the condition:\n// `lb-show=\"!chosen\"` is present while `chosen` is null or false.\nexport const SHOW_NOT = \"!\";\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 shows, so \"no members yet\" is a stylesheet rule rather than a\n// conditional in every widget. A row a filter hides is not counted.\nexport const ATTR_QUERY_ROW_COUNT = \"lb-query-row-count\";\n\n// Stamped by the hub beside ATTR_QUERY_ROW_COUNT: how many live rows stand\n// where the order or the filter would not leave them, so a stylesheet shows\n// a control that places them only while one would do something.\nexport const ATTR_QUERY_UNPLACED_COUNT = \"lb-query-unplaced-count\";\n\n// Stamped by the hub beside ATTR_QUERY_ROW_COUNT: the order its rows are\n// placed by, the user's or else the server's, as an order's text, so a\n// widget or a stylesheet can show it. Absent when the rows have no order.\nexport const ATTR_QUERY_ORDER = \"lb-query-order\";\n\n// --- Order and groups (docs/reference/data-binding.md) -------------------\n// A `rows` query's order is a rule over its columns, and the hub places\n// live rows by it, except that an edit from inside a list leaves that list's\n// rows where they stand. A group is a run of rows sharing the order's leading term.\n\n// On a `<template>` inside an element naming a query: a group template. Its\n// content holds the group's heading and exactly one nested `<template>`,\n// which is where the group's contents go: the next group template, or, at\n// the innermost level, the row template. The nth group template breaks on\n// the order's nth term. The markup's nesting decides whether the contents\n// land inside the heading's element or beside it.\nexport const ATTR_GROUP = \"lb-group\";\n\n// Stamped by the hub on each top-level element of a group it built, and on\n// nothing else, as ATTR_ROW_LIVE is on a live row.\nexport const ATTR_GROUP_LIVE = \"lb-group-live\";\n\n// Stamped beside ATTR_GROUP_LIVE: the column the group breaks on, and its\n// value there.\nexport const ATTR_GROUP_COLUMN = \"lb-group-column\";\nexport const ATTR_GROUP_VALUE = \"lb-group-value\";\n\n// Selects a group's element, as LIVE_ROW selects a live row.\nexport const LIVE_GROUP = `[${ATTR_GROUP_LIVE}]`;\n\n// Aggregates, written on any element in a group template or in the element\n// naming the query: the hub sets the element from the rows of the nearest\n// group around it, or of the whole list outside any group. `lb-count` takes\n// no value; the others name the column they aggregate.\nexport const ATTR_COUNT = \"lb-count\";\nexport const ATTR_SUM = \"lb-sum\";\nexport const ATTR_AVG = \"lb-avg\";\nexport const ATTR_MIN = \"lb-min\";\nexport const ATTR_MAX = \"lb-max\";\n\nexport const AGGREGATES = [\n ATTR_COUNT,\n ATTR_SUM,\n ATTR_AVG,\n ATTR_MIN,\n ATTR_MAX,\n] as const;\n\n// Written before a column in an order, it sorts that column descending.\nexport const ORDER_DESCENDING = \"-\";\n\n// The types a `rows` query may declare for its columns. Sorting, filtering,\n// `lb-min` and `lb-max` read a declared column as its type rather than by\n// the JSON type its values arrive as.\nexport const COLUMN_TYPES = [\"number\", \"boolean\", \"text\"] as const;\n\n// --- Choices (docs/reference/data-binding.md) -----------------------------\n// What the user chose for how rows show: an order, a filter. The hub serves\n// them as its own query, one row keyed by the path, with a column per choice,\n// and any control inside `lb-query=\"lb-choices\"` writes one with\n// `lb-row-update`. They hold until the page changes.\nexport const CHOICES_QUERY = \"lb-choices\";\n\n// On an element naming a `rows` query: the column of `lb-choices` holding the\n// user's order for its rows, as an order's text. While that column is empty,\n// the order the server declared places them.\nexport const ATTR_ORDER = \"lb-order\";\n\n// On an element naming a `rows` query: the columns of its rows that a choice\n// may filter, separated by commas. The column of `lb-choices` of the same\n// name holds the filter, and a row it does not pass is `hidden`.\nexport const ATTR_FILTER = \"lb-filter\";\n\n// On an element naming a `rows` query: which placements wait for the user,\n// `order`, `filter` or both, separated by spaces. A side not named is placed\n// on every landing. A side named is placed when the page loads, when the\n// user's order or filter changes, and on COMMAND_PLACE; an answer to a\n// request leaves the rows on that side where they stand.\nexport const ATTR_MANUAL = \"lb-manual\";\nexport const MANUAL_ORDER = \"order\";\nexport const MANUAL_FILTER = \"filter\";\n\n// A filter's operators, written before each value: `^=Amazon`, or\n// `>=2026-01-01 <=2026-03-31` for a range. A value with none is `*=`. The\n// longer are listed first, which is the order they are read in.\nexport const FILTER_OPERATORS = [\n \"!=\",\n \"^=\",\n \"$=\",\n \"*=\",\n \"<=\",\n \">=\",\n \"=\",\n \"<\",\n \">\",\n] as const;\n\n// --- What happened to a row (docs/reference/data-binding.md) ------------\n// Every change the hub makes to a list is one a stylesheet can see, so an\n// application animates with CSS alone. The first three are cleared when the\n// hub next touches the row, and a stamp applied again is removed and added\n// as two changes, so an animation keyed to it plays again.\n\n// The row was created when the hub last touched it.\nexport const ATTR_ROW_CREATED = \"lb-row-created\";\n\n// The row's values changed when the hub last touched it.\nexport const ATTR_ROW_CHANGED = \"lb-row-changed\";\n\n// The row moved when the hub last touched it: its values changed, and the\n// order put it somewhere else among the rows whose values did not.\nexport const ATTR_ROW_MOVED = \"lb-row-moved\";\n\n// What a request from this page did to the row: one of the three values\n// below. Cleared at every landing of the row's query, so a script reading it\n// after a landing reads only what that landing did.\nexport const ATTR_ROW_REQUESTED = \"lb-row-requested\";\nexport const REQUESTED_CREATED = \"created\";\nexport const REQUESTED_CHANGED = \"changed\";\nexport const REQUESTED_MOVED = \"moved\";\n\n// The row stands where the order or the filter would not leave it: an answer\n// changed or created it in a list that places that side by hand, and the hub\n// left it where it stood. Cleared when the rows are next placed.\nexport const ATTR_ROW_UNPLACED = \"lb-row-unplaced\";\n\n// A row or a group on its way out. It is no longer live, takes no input, and\n// is removed once the animations running on it have finished, at once when\n// there are none.\nexport const ATTR_ROW_LEAVING = \"lb-row-leaving\";\nexport const ATTR_GROUP_LEAVING = \"lb-group-leaving\";\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// The counterpart of LB_EVENT_NAME: raised on the element that committed,\n// once what the request brought back has landed or the round trip has\n// failed. It bubbles, so the element that cares about the outcome need not\n// be the one that committed.\nexport const LB_DONE_EVENT_NAME = \"lb-request-done\";\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 handler refused it:\n// the refusal's message for the request as a whole, empty when it has none.\n// Cleared at the start of that element's next request. A refusal is not a\n// failure, and does not stamp ATTR_REQUEST_ERROR.\nexport const ATTR_REQUEST_REFUSED = \"lb-request-refused\";\n\n// The status a refusal travels with. Every other failure is a 500 with no\n// body, so nothing but a refusal's own words reaches the browser.\nexport const LB_REFUSAL_STATUS = 422;\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// --- A form pointed at a row (docs/reference/data-binding.md) -----------\n// One form edits any row of its query, or enters a new one. A button points\n// it with HTML's own `commandfor=\"<form id>\"` and one of these commands,\n// which HTML requires to begin with `--`. The hub hears the `command` event\n// on the form. COMMAND_PLACE, the last of them, is for a list, not a form.\n\n// From a button in a live row of the form's query: fill the form from that\n// row, as the hub holds it, and key it by that row.\nexport const COMMAND_EDIT = \"--lb-edit\";\n\n// From any button: start the form empty, for an insert.\nexport const COMMAND_NEW = \"--lb-new\";\n\n// From any button: let the form go without saving.\nexport const COMMAND_RELEASE = \"--lb-release\";\n\n// From any button, for an element carrying `lb-query` rather than a form:\n// place its rows by the order and the filter, from the rows the hub holds.\nexport const COMMAND_PLACE = \"--lb-place\";\n\nexport const LB_COMMANDS = [\n COMMAND_EDIT,\n COMMAND_NEW,\n COMMAND_RELEASE,\n COMMAND_PLACE,\n] as const;\n\n// Loadbare owns every command beginning with this prefix.\nexport const LB_COMMAND_PREFIX = \"--lb-\";\n\n// Stamped by the hub on the live row a form is pointed at, until the form\n// lets go of it.\nexport const ATTR_ROW_EDITING = \"lb-row-editing\";\n\n// --- Selecting rows (docs/reference/data-binding.md) ---------------------\n// On a checkbox in a row template: ticking it selects the live row it sits\n// in. It is not a column and is not gathered as one. A request for the\n// row's query that names no one row carries the keys of every row selected.\nexport const ATTR_SELECT = \"lb-select\";\n\n// Stamped by the hub on a live row while its `lb-select` checkbox is ticked.\nexport const ATTR_ROW_SELECTED = \"lb-row-selected\";\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// Loadbare also owns every method name on a custom element that begins with\n// `lb` and a capital. These are the ones it calls (the HubLifecycle interface\n// in core/lb-types.ts); the builder refuses a script that declares any other.\nexport const LB_METHODS = [\n \"lbAttached\",\n \"lbRowsLanded\",\n \"lbRequestDone\",\n \"lbDetached\",\n] as const;\n\n// The browser's lifecycle callbacks, which the hub's methods replace. The\n// builder refuses a script that declares any of them.\nexport const BROWSER_LIFECYCLE = [\n \"connectedCallback\",\n \"disconnectedCallback\",\n \"adoptedCallback\",\n \"connectedMoveCallback\",\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// --- Round trips (docs/reference/chrome.md) ------------------------------\n// The query the hub serves with its own state: one row, keyed by the path,\n// telling whether the page's data arrived and whether the server answers.\n// The hub stamps the same columns on `<lb-hub>` itself, for a stylesheet.\nexport const HUB_QUERY = \"lb-hub\";\n\n// `loading`, `loaded` or `failed`: the page load for the URL showing.\nexport const HUB_COLUMN_LOAD_STATE = \"lb-load-state\";\n\n// `reachable`, `failing` or `unreachable`: how the latest round trip of any\n// kind went. Empty until the first one returns.\nexport const HUB_COLUMN_SERVER_STATE = \"lb-server-state\";\n\n// Empty, or why the latest round trip failed: HUB_ERROR_NETWORK,\n// HUB_ERROR_TIMEOUT, or the HTTP status the server answered with.\nexport const HUB_COLUMN_ERROR = \"lb-error\";\n\n// How many round trips are in flight.\nexport const HUB_COLUMN_PENDING = \"lb-pending\";\n\n// When rows last came from the server, as an ISO timestamp.\nexport const HUB_COLUMN_AS_OF = \"lb-as-of\";\n\nexport const HUB_LOAD_LOADING = \"loading\";\nexport const HUB_LOAD_LOADED = \"loaded\";\nexport const HUB_LOAD_FAILED = \"failed\";\n\nexport const HUB_SERVER_REACHABLE = \"reachable\";\nexport const HUB_SERVER_FAILING = \"failing\";\nexport const HUB_SERVER_UNREACHABLE = \"unreachable\";\n\nexport const HUB_ERROR_NETWORK = \"network\";\nexport const HUB_ERROR_TIMEOUT = \"timeout\";\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 an `<a>` carrying ATTR_URL_LINK: columns of the row around it, separated\n// by commas, each added to the `href`'s query string as the parm of the same\n// name.\nexport const ATTR_URL_PARM = \"lb-url-parm\";\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_GROUP,\n ...AGGREGATES,\n ATTR_ORDER,\n ATTR_FILTER,\n ATTR_MANUAL,\n ATTR_REQUEST,\n ATTR_SELECT,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_PARM,\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
+ {"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,uDAAuD;AAEvD,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,qEAAqE;AACrE,kEAAkE;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE5B,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,IAAI,aAAa,GAAG,CAAC;AAE7C,2EAA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1E,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.\n\n// --- Landing -------------------------------------------------------------\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// Written before the column in ATTR_SHOW, it reverses the condition:\n// `lb-show=\"!chosen\"` is present while `chosen` is null or false.\nexport const SHOW_NOT = \"!\";\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 shows, so \"no members yet\" is a stylesheet rule rather than a\n// conditional in every widget. A row a filter hides is not counted.\nexport const ATTR_QUERY_ROW_COUNT = \"lb-query-row-count\";\n\n// Stamped by the hub beside ATTR_QUERY_ROW_COUNT: how many live rows stand\n// where the order or the filter would not leave them, so a stylesheet shows\n// a control that places them only while one would do something.\nexport const ATTR_QUERY_UNPLACED_COUNT = \"lb-query-unplaced-count\";\n\n// Stamped by the hub beside ATTR_QUERY_ROW_COUNT: the order its rows are\n// placed by, the user's or else the server's, as an order's text, so a\n// widget or a stylesheet can show it. Absent when the rows have no order.\nexport const ATTR_QUERY_ORDER = \"lb-query-order\";\n\n// --- Order and groups ----------------------------------------------------\n// A `rows` query's order is a rule over its columns, and the hub places\n// live rows by it, except that an edit from inside a list leaves that list's\n// rows where they stand. A group is a run of rows sharing the order's leading term.\n\n// On a `<template>` inside an element naming a query: a group template. Its\n// content holds the group's heading and exactly one nested `<template>`,\n// which is where the group's contents go: the next group template, or, at\n// the innermost level, the row template. The nth group template breaks on\n// the order's nth term. The markup's nesting decides whether the contents\n// land inside the heading's element or beside it.\nexport const ATTR_GROUP = \"lb-group\";\n\n// Stamped by the hub on each top-level element of a group it built, and on\n// nothing else, as ATTR_ROW_LIVE is on a live row.\nexport const ATTR_GROUP_LIVE = \"lb-group-live\";\n\n// Stamped beside ATTR_GROUP_LIVE: the column the group breaks on, and its\n// value there.\nexport const ATTR_GROUP_COLUMN = \"lb-group-column\";\nexport const ATTR_GROUP_VALUE = \"lb-group-value\";\n\n// Selects a group's element, as LIVE_ROW selects a live row.\nexport const LIVE_GROUP = `[${ATTR_GROUP_LIVE}]`;\n\n// An aggregate, written on any element in a group template or in the\n// element naming the query: set from the rows showing in the nearest group\n// around it, or in the whole list outside any group. `lb-aggregate` names the\n// function and `lb-column` the column; `count` with no column counts rows.\nexport const ATTR_AGGREGATE = \"lb-aggregate\";\n\nexport const AGGREGATE_COUNT = \"count\";\nexport const AGGREGATE_SUM = \"sum\";\nexport const AGGREGATE_AVG = \"avg\";\nexport const AGGREGATE_MIN = \"min\";\nexport const AGGREGATE_MAX = \"max\";\n\nexport const AGGREGATES = [\n AGGREGATE_COUNT,\n AGGREGATE_SUM,\n AGGREGATE_AVG,\n AGGREGATE_MIN,\n AGGREGATE_MAX,\n] as const;\n\n// Written before a column in an order, it sorts that column descending.\nexport const ORDER_DESCENDING = \"-\";\n\n// The types a `rows` query may declare for its columns. Sorting, filtering,\n// `min` and `max` read a declared column as its type rather than by\n// the JSON type its values arrive as.\nexport const COLUMN_TYPES = [\"number\", \"boolean\", \"text\"] as const;\n\n// --- Sort and filter -----------------------------------------------------\n// What the user chose for how rows show, in two hub-owned queries, one row\n// per query keyed by the query's name. The server and the browser each may\n// read and write them.\nexport const SORT_QUERY = \"lb-sort\";\nexport const SORT_COLUMN_QUERY = \"query\";\nexport const SORT_COLUMN_ORDER = \"order\";\n\nexport const FILTERS_QUERY = \"lb-filters\";\nexport const FILTERS_COLUMN_QUERY = \"query\";\n\n// On an element naming a `rows` query: the columns of its rows the user may\n// filter, separated by commas. The `lb-filters` row for the query holds each\n// filter, and a row it does not pass is `hidden`.\nexport const ATTR_FILTER = \"lb-filter\";\n\n// On an element naming a `rows` query: which placements wait for the user,\n// `order`, `filter` or both, separated by spaces. A side not named is placed\n// on every landing. A side named is placed when the page loads, when the\n// user's order or filter changes, and on COMMAND_PLACE; an answer to a\n// request leaves the rows on that side where they stand.\nexport const ATTR_MANUAL = \"lb-manual\";\nexport const MANUAL_ORDER = \"order\";\nexport const MANUAL_FILTER = \"filter\";\n\n// A filter's operators, written before each value: `^=Amazon`, or\n// `>=2026-01-01 <=2026-03-31` for a range. A value with none is `*=`. The\n// longer are listed first, which is the order they are read in.\nexport const FILTER_OPERATORS = [\n \"!=\",\n \"^=\",\n \"$=\",\n \"*=\",\n \"<=\",\n \">=\",\n \"=\",\n \"<\",\n \">\",\n] as const;\n\n// --- What happened to a row ----------------------------------------------\n// Every change the hub makes to a list is one a stylesheet can see, so an\n// application animates with CSS alone. The first three are cleared when the\n// hub next touches the row, and a stamp applied again is removed and added\n// as two changes, so an animation keyed to it plays again.\n\n// The row was created when the hub last touched it.\nexport const ATTR_ROW_CREATED = \"lb-row-created\";\n\n// The row's values changed when the hub last touched it.\nexport const ATTR_ROW_CHANGED = \"lb-row-changed\";\n\n// The row moved when the hub last touched it: its values changed, and the\n// order put it somewhere else among the rows whose values did not.\nexport const ATTR_ROW_MOVED = \"lb-row-moved\";\n\n// What a request from this page did to the row: one of the three values\n// below. Cleared at every landing of the row's query, so a script reading it\n// after a landing reads only what that landing did.\nexport const ATTR_ROW_REQUESTED = \"lb-row-requested\";\nexport const REQUESTED_CREATED = \"created\";\nexport const REQUESTED_CHANGED = \"changed\";\nexport const REQUESTED_MOVED = \"moved\";\n\n// The row stands where the order or the filter would not leave it: an answer\n// changed or created it in a list that places that side by hand, and the hub\n// left it where it stood. Cleared when the rows are next placed.\nexport const ATTR_ROW_UNPLACED = \"lb-row-unplaced\";\n\n// A row or a group on its way out. It is no longer live, takes no input, and\n// is removed once the animations running on it have finished, at once when\n// there are none.\nexport const ATTR_ROW_LEAVING = \"lb-row-leaving\";\nexport const ATTR_GROUP_LEAVING = \"lb-group-leaving\";\n\n// --- Requests ------------------------------------------------------------\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// The counterpart of LB_EVENT_NAME: raised on the element that committed,\n// once what the request brought back has landed or the round trip has\n// failed. It bubbles, so the element that cares about the outcome need not\n// be the one that committed.\nexport const LB_DONE_EVENT_NAME = \"lb-request-done\";\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 handler refused it:\n// the refusal's message for the request as a whole, empty when it has none.\n// Cleared at the start of that element's next request. A refusal is not a\n// failure, and does not stamp ATTR_REQUEST_ERROR.\nexport const ATTR_REQUEST_REFUSED = \"lb-request-refused\";\n\n// The status a refusal travels with. Every other failure is a 500 with no\n// body, so nothing but a refusal's own words reaches the browser.\nexport const LB_REFUSAL_STATUS = 422;\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// --- A form pointed at a row ---------------------------------------------\n// One form edits any row of its query, or enters a new one. A button points\n// it with HTML's own `commandfor=\"<form id>\"` and one of these commands,\n// which HTML requires to begin with `--`. The hub hears the `command` event\n// on the form. COMMAND_PLACE, the last of them, is for a list, not a form.\n\n// From a button in a live row of the form's query: fill the form from that\n// row, as the hub holds it, and key it by that row.\nexport const COMMAND_EDIT = \"--lb-edit\";\n\n// From any button: start the form empty, for an insert.\nexport const COMMAND_NEW = \"--lb-new\";\n\n// From any button: let the form go without saving.\nexport const COMMAND_RELEASE = \"--lb-release\";\n\n// From any button, for an element carrying `lb-query` rather than a form:\n// place its rows by the order and the filter, from the rows the hub holds.\nexport const COMMAND_PLACE = \"--lb-place\";\n\nexport const LB_COMMANDS = [\n COMMAND_EDIT,\n COMMAND_NEW,\n COMMAND_RELEASE,\n COMMAND_PLACE,\n] as const;\n\n// Loadbare owns every command beginning with this prefix.\nexport const LB_COMMAND_PREFIX = \"--lb-\";\n\n// Stamped by the hub on the live row a form is pointed at, until the form\n// lets go of it.\nexport const ATTR_ROW_EDITING = \"lb-row-editing\";\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// The hub's own read: the queries it names, run again at the URL the request\n// is sent from. The hub sends it when Edit or New binds a form, for the lists\n// nested in the form, with the bound row's key as a parm named for the form's\n// key column, so a list inside a row follows the row it is bound to. Markup\n// never writes it.\nexport const REQUEST_READ = \"lb-read\";\n\n// Loadbare also owns every method name on a custom element that begins with\n// `lb` and a capital. These are the ones it calls (the HubLifecycle interface\n// in core/lb-types.ts); the builder refuses a script that declares any other.\nexport const LB_METHODS = [\n \"lbAttached\",\n \"lbRowsLanded\",\n \"lbRequestDone\",\n \"lbDetached\",\n] as const;\n\n// The browser's lifecycle callbacks, which the hub's methods replace. The\n// builder refuses a script that declares any of them.\nexport const BROWSER_LIFECYCLE = [\n \"connectedCallback\",\n \"disconnectedCallback\",\n \"adoptedCallback\",\n \"connectedMoveCallback\",\n] as const;\n\n// --- Kinds --------------------------------------------------------------\nexport const KIND_ROW = \"row\";\nexport const KIND_ROWS = \"rows\";\n\n// --- The URL -------------------------------------------------------------\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\";\n\n// --- Round trips ---------------------------------------------------------\n// The query the hub serves with its own state: one row, keyed by the path,\n// telling whether the page's data arrived and whether the server answers.\n// The hub stamps the same columns on `<lb-hub>` itself, for a stylesheet.\nexport const HUB_QUERY = \"lb-hub-status\";\n\n// `loading`, `loaded` or `failed`: the page load for the URL showing.\nexport const HUB_COLUMN_LOAD_STATE = \"lb-load-state\";\n\n// `reachable`, `failing` or `unreachable`: how the latest round trip of any\n// kind went. Empty until the first one returns.\nexport const HUB_COLUMN_SERVER_STATE = \"lb-server-state\";\n\n// Empty, or why the latest round trip failed: HUB_ERROR_NETWORK,\n// HUB_ERROR_TIMEOUT, or the HTTP status the server answered with.\nexport const HUB_COLUMN_ERROR = \"lb-error\";\n\n// How many round trips are in flight.\nexport const HUB_COLUMN_PENDING = \"lb-pending\";\n\n// When rows last came from the server, as an ISO timestamp.\nexport const HUB_COLUMN_AS_OF = \"lb-as-of\";\n\nexport const HUB_LOAD_LOADING = \"loading\";\nexport const HUB_LOAD_LOADED = \"loaded\";\nexport const HUB_LOAD_FAILED = \"failed\";\n\nexport const HUB_SERVER_REACHABLE = \"reachable\";\nexport const HUB_SERVER_FAILING = \"failing\";\nexport const HUB_SERVER_UNREACHABLE = \"unreachable\";\n\nexport const HUB_ERROR_NETWORK = \"network\";\nexport const HUB_ERROR_TIMEOUT = \"timeout\";\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 an `<a>` carrying ATTR_URL_LINK: columns of the row around it, separated\n// by commas, each added to the `href`'s query string as the parm of the same\n// name.\nexport const ATTR_URL_PARM = \"lb-url-parm\";\n\n// On a `<dialog>`: the hub calls showModal() when the path names a page that\n// does not exist.\nexport const ATTR_URL_UNKNOWN = \"lb-url-unknown\";\n\n// --- Build time ----------------------------------------------------------\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_GROUP,\n ATTR_AGGREGATE,\n ATTR_FILTER,\n ATTR_MANUAL,\n ATTR_REQUEST,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_PARM,\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"]}
@@ -9,7 +9,7 @@ import { COLUMN_TYPES, KIND_ROW, FILTER_OPERATORS, KIND_ROWS } from "./lb-consta
9
9
  */
10
10
  export type Row = Record<string, unknown>;
11
11
  /**
12
- * Part of a `rows` query's answer — see docs/reference/server.md, "Queries".
12
+ * Part of a `rows` query's answer.
13
13
  *
14
14
  * Rows named here are added or updated, keys in `drop` are removed, and
15
15
  * anything unnamed is left alone. The hub places what it names by the
@@ -48,8 +48,9 @@ export type HubResult = Row | RowsResult | null;
48
48
  export type HubData = Record<string, HubResult>;
49
49
  /**
50
50
  * One query's answer on the wire: its name, its kind, its key's column name,
51
- * and exactly one of a row, all rows, or a patch. A patch answers a `rows`
52
- * query only.
51
+ * and exactly one of all its rows or a patch. Every answer is rows: a query
52
+ * declared `row` answers with at most one, and a patch answers a `rows` query
53
+ * only.
53
54
  *
54
55
  * A `rows` query also carries the order and column types it declared, once,
55
56
  * on the answer that loads the page. The hub keeps them with the answer for
@@ -59,12 +60,16 @@ export interface ResponseItem {
59
60
  query: string;
60
61
  kind: Kind;
61
62
  key: string;
62
- row?: Row | null;
63
63
  rows?: Row[];
64
64
  patch?: Patch;
65
65
  order?: string;
66
66
  types?: ColumnTypes;
67
67
  }
68
+ /**
69
+ * The one row of an answer to a query declared `row`, or null when it found
70
+ * none.
71
+ */
72
+ export declare function oneRow(item: ResponseItem | undefined): Row | null;
68
73
  /** Every response the server sends: a page load and a request alike. */
69
74
  export type HubResponse = ResponseItem[];
70
75
  /**
@@ -75,11 +80,6 @@ export interface HubRequest {
75
80
  name: string;
76
81
  query?: string;
77
82
  key?: string;
78
- /**
79
- * The rows a request acts on together, by key: those the user selected,
80
- * for a request that names no one row. Never sent beside `key`.
81
- */
82
- keys?: string[];
83
83
  /**
84
84
  * The gathered controls' values, by column. A column of `lb-url` may hold
85
85
  * several, as a URL repeats a parm; every other column holds one.
@@ -91,6 +91,8 @@ export interface HubRequest {
91
91
  * own values.
92
92
  */
93
93
  rows?: Record<string, GatheredRow[]>;
94
+ /** The queries an `lb-read` runs again. */
95
+ queries?: string[];
94
96
  }
95
97
  /** One nested row a form gathered: its key, and its controls' values. */
96
98
  export interface GatheredRow {
@@ -232,8 +234,7 @@ export declare function nextLocation(page: string, parms: URLSearchParams, row:
232
234
  * `connectedCallback` and its kin, which the builder refuses.
233
235
  *
234
236
  * Each is a method on an element the hub does not own, so it carries the
235
- * `lb` prefix Loadbare reserves for exactly that — see
236
- * docs/reference/custom-elements.md.
237
+ * `lb` prefix Loadbare reserves for exactly that.
237
238
  */
238
239
  export interface HubLifecycle {
239
240
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"lb-types.d.ts","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,SAAS,EAKV,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,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,oEAAoE;AACpE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAErD,0EAA0E;AAC1E,MAAM,MAAM,IAAI,GAAG,OAAO,QAAQ,GAAG,OAAO,SAAS,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;AAEvC,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,KAAK,CAE3D;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,UAAU,GAAG,IAAI,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,S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,IAAI,EAAE,EAAE,UAAU,EACrC,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CA2BT;AAED,8DAA8D;AAC9D,wBAAgB,MAAM,CACpB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,UAAU,EAAE,EACnB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,GAAG,GACP;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAgB1D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,IAAI,IAAI,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9D,0DAA0D;IAC1D,UAAU,CAAC,IAAI,IAAI,CAAC;CACrB"}
@@ -4,6 +4,13 @@ import { FILTER_OPERATORS, LB_RESERVED_PREFIX, LB_ROW_REQUESTS, ORDER_DESCENDING
4
4
  export function isPatch(result) {
5
5
  return !Array.isArray(result);
6
6
  }
7
+ /**
8
+ * The one row of an answer to a query declared `row`, or null when it found
9
+ * none.
10
+ */
11
+ export function oneRow(item) {
12
+ return item?.rows?.[0] ?? null;
13
+ }
7
14
  /**
8
15
  * The query parms of a URL as a row of `lb-url`: a parm the URL carries
9
16
  * once is a string, and one it repeats is every value it carries, in order.
@@ -1 +1 @@
1
- {"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAGL,gBAAgB,EAEhB,kBAAkB,EAClB,eAAe,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,\n KIND_ROW,\n FILTER_OPERATORS,\n KIND_ROWS,\n LB_RESERVED_PREFIX,\n LB_ROW_REQUESTS,\n ORDER_DESCENDING,\n URL_COLUMN_PATH,\n} from \"./lb-constants.js\";\n\n/**\n * One row: its columns, by name.\n *\n * A value is whatever the server serialized. The hub knows nothing about its\n * type and enforces nothing: it hands each value to the browser untouched,\n * and the browser renders it as it sees fit. What a number, a date or a null\n * should look like is the application's decision, made in the query.\n */\nexport type Row = Record<string, unknown>;\n\n/**\n * Part of a `rows` query's answer — see docs/reference/server.md, \"Queries\".\n *\n * Rows named here are added or updated, keys in `drop` are removed, and\n * anything unnamed is left alone. The hub places what it names by the\n * query's order. Add and remove are one result rather than two because the\n * interesting cases are both at once — a row whose sort key changed has to\n * move, a swap is one out and one in — and two messages would paint the\n * intermediate state.\n */\nexport interface Patch {\n rows?: Row[];\n drop?: unknown[];\n}\n\n/** A type a `rows` query may declare for a column — see COLUMN_TYPES. */\nexport type ColumnType = (typeof COLUMN_TYPES)[number];\n\n/** The types a `rows` query declares for its columns, by column. */\nexport type ColumnTypes = Record<string, ColumnType>;\n\n/** A query's kind, declared by the server and carried by every answer. */\nexport type Kind = typeof KIND_ROW | typeof KIND_ROWS;\n\n/**\n * What a `rows` query answers with: all rows, or a patch. `Array.isArray`\n * tells the two apart. All rows arrive in the order the server chose, which\n * is the order they show in when the query declares none.\n */\nexport type RowsResult = Row[] | Patch;\n\nexport function isPatch(result: RowsResult): result is Patch {\n return !Array.isArray(result);\n}\n\n/**\n * What any one query answers with, as the application writes it. A `row`\n * query that finds no row answers `null`.\n */\nexport type HubResult = Row | RowsResult | null;\n\n/**\n * What application code hands the engine: answers by query name. The engine\n * turns each into a response item, adding the kind and key the query\n * declared.\n */\nexport type HubData = Record<string, HubResult>;\n\n/**\n * One query's answer on the wire: its name, its kind, its key's column name,\n * and exactly one of a row, all rows, or a patch. A patch answers a `rows`\n * query only.\n *\n * A `rows` query also carries the order and column types it declared, once,\n * on the answer that loads the page. The hub keeps them with the answer for\n * every answer after it.\n */\nexport interface ResponseItem {\n query: string;\n kind: Kind;\n key: string;\n row?: Row | null;\n rows?: Row[];\n patch?: Patch;\n order?: string;\n types?: ColumnTypes;\n}\n\n/** Every response the server sends: a page load and a request alike. */\nexport type HubResponse = ResponseItem[];\n\n/**\n * Every request has one shape. The name picks the handler; the rest is\n * present when the hub found it.\n */\nexport interface HubRequest {\n name: string;\n query?: string;\n key?: string;\n /**\n * The rows a request acts on together, by key: those the user selected,\n * for a request that names no one row. Never sent beside `key`.\n */\n keys?: string[];\n /**\n * The gathered controls' values, by column. A column of `lb-url` may hold\n * several, as a URL repeats a parm; every other column holds one.\n */\n values?: Record<string, ParmValue>;\n /**\n * The rows of the queries nested in a form, by query name, each with the\n * values of its own controls: a set of rows gathered beside the form's\n * own values.\n */\n rows?: Record<string, GatheredRow[]>;\n}\n\n/** One nested row a form gathered: its key, and its controls' values. */\nexport interface GatheredRow {\n key: string;\n values: Record<string, string>;\n}\n\n/**\n * What a control gathers: one value, or several from a control that holds\n * several, which only a column of `lb-url` takes.\n */\nexport type ParmValue = string | string[];\n\n/**\n * The query parms of a URL as a row of `lb-url`: a parm the URL carries\n * once is a string, and one it repeats is every value it carries, in order.\n */\nexport function parmsRow(parms: URLSearchParams): Row {\n const row: Row = {};\n for (const name of new Set(parms.keys())) {\n const all = parms.getAll(name);\n row[name] = all.length === 1 ? all[0] : all;\n }\n return row;\n}\n\n/**\n * The detail of the `lb-request-done` event: the request as the hub\n * completed and sent it, and what came of it. `items` is every response\n * item that landed because of it, in the order it landed. `error` is set\n * when the request's own round trip failed, and then nothing landed.\n */\nexport interface HubRequestDone {\n request: HubRequest;\n items: ResponseItem[];\n error?: Error;\n /** Set beside `error` when the handler refused the request. */\n refusal?: HubRefusal;\n}\n\n/**\n * Why a handler refused a request, in words written for the user: a\n * message for the request as a whole, a message per column the request\n * gathered, or both. Sent with status 422; any other failure sends nothing.\n */\nexport interface HubRefusal {\n message?: string;\n columns?: Record<string, string>;\n}\n\n/** The fields a handler receives: the request, less its name. */\nexport type RequestFields = Omit<HubRequest, \"name\" | \"values\"> & {\n values?: Record<string, string>;\n};\n\n/** Whether a name is one of the requests Loadbare provides. */\nexport function isRowRequest(name: string): boolean {\n return (LB_ROW_REQUESTS as readonly string[]).includes(name);\n}\n\n/**\n * A query string with some parms set, and the rest as they were. An empty\n * value takes its parm out, since empty is every parm's default and a\n * default is left out of the URL.\n *\n * One rule on both sides of the wire: the hub applies it to the address bar,\n * and the server to the query string it loads the page at after a request\n * returned `lb-url`. The two must agree, or what the page shows would differ\n * from what the address bar says.\n */\nexport function withQueryParms(\n search: URLSearchParams,\n parms: Record<string, ParmValue>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (!Array.isArray(value)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\n continue;\n }\n // Several values repeat the parm, as an HTML form sends them. Values\n // already there are left where they stand, so the URL is unchanged.\n const kept = value.filter((v) => v !== \"\");\n const had = next.getAll(name);\n if (kept.length === had.length && kept.every((v, i) => v === had[i])) {\n continue;\n }\n if (kept.length === 1) {\n next.set(name, kept[0]!);\n continue;\n }\n next.delete(name);\n for (const v of kept) next.append(name, v);\n }\n return next;\n}\n\n/**\n * A path names a page by its stub, and nothing finer. The bare path resolves\n * to `index`, the same convention a static file server follows.\n */\nexport function pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/** One term of an order: a column, and whether it sorts descending. */\nexport interface OrderTerm {\n column: string;\n descending: boolean;\n}\n\n/**\n * An order's terms, from its text: columns separated by commas, each\n * descending when it begins with `-`. Throws on a term that names no column.\n * An empty text is no order.\n */\nexport function parseOrder(text: string): OrderTerm[] {\n if (text.trim() === \"\") return [];\n return text.split(\",\").map((raw) => {\n const term = raw.trim();\n const descending = term.startsWith(ORDER_DESCENDING);\n const column = descending ? term.slice(ORDER_DESCENDING.length) : term;\n if (column === \"\" || column.startsWith(ORDER_DESCENDING)) {\n throw new Error(`the order '${text}' has a term naming no column`);\n }\n return { column, descending };\n });\n}\n\n/** Strings compare as the user's language orders them. */\nconst collator = new Intl.Collator();\n\n/** How a value sorts among values of other types: by its JSON type. */\nfunction rank(value: unknown): number {\n switch (typeof value) {\n case \"boolean\":\n return 0;\n case \"number\":\n return 1;\n case \"string\":\n return 2;\n default:\n return 3;\n }\n}\n\n/**\n * Compare two column values, ascending.\n *\n * A value compares by its JSON type, and nothing is guessed: numbers\n * numerically, booleans false before true, strings as the user's language\n * orders them. A number that arrives as a string sorts as a string, so a\n * numeric sort column is sent as a JSON number. Null and a missing value\n * sort after everything, as Postgres sorts them ascending, and so first\n * descending.\n */\nexport function compareValues(a: unknown, b: unknown): number {\n const missingA = a === null || a === undefined;\n const missingB = b === null || b === undefined;\n if (missingA || missingB) return missingA === missingB ? 0 : missingA ? 1 : -1;\n const ra = rank(a);\n const rb = rank(b);\n if (ra !== rb) return ra - rb;\n if (typeof a === \"number\") return a - (b as number);\n if (typeof a === \"boolean\") return Number(a) - Number(b);\n if (typeof a === \"string\") return collator.compare(a, b as string);\n return collator.compare(JSON.stringify(a), JSON.stringify(b));\n}\n\n/**\n * A value read as a declared column type: a number for `number`, a boolean\n * for `boolean`, text for `text`. A value that is no value of its type reads\n * as missing, and compares as a null does. A column with no declared type\n * reads as it arrived.\n */\nexport function readAs(value: unknown, type: ColumnType | undefined): unknown {\n if (type === undefined || value === null || value === undefined) return value;\n switch (type) {\n case \"number\": {\n if (typeof value === \"number\") return value;\n if (typeof value !== \"string\" || value.trim() === \"\") return undefined;\n const n = Number(value);\n return Number.isNaN(n) ? undefined : n;\n }\n case \"boolean\":\n if (typeof value === \"boolean\") return value;\n return value === \"true\" ? true : value === \"false\" ? false : undefined;\n default:\n return typeof value === \"object\" ? JSON.stringify(value) : String(value);\n }\n}\n\n/** Compare two rows by an order's terms, each column read as its type. */\nexport function compareRows(\n a: Row,\n b: Row,\n terms: OrderTerm[],\n types: ColumnTypes = {},\n): number {\n for (const { column, descending } of terms) {\n const c = compareValues(\n readAs(a[column], types[column]),\n readAs(b[column], types[column]),\n );\n if (c !== 0) return descending ? -c : c;\n }\n return 0;\n}\n\n/** A filter's operator — see FILTER_OPERATORS. */\nexport type FilterOperator = (typeof FILTER_OPERATORS)[number];\n\n/** One term of a filter: an operator, and the value it compares with. */\nexport interface FilterTerm {\n operator: FilterOperator;\n value: string;\n}\n\n/** Where a filter's next term begins: whitespace before an operator. */\nconst NEXT_TERM = new RegExp(\n `\\\\s+(?=${FILTER_OPERATORS.map((op) => op.replace(/[$^*]/g, \"\\\\$&\")).join(\"|\")})`,\n);\n\n/**\n * A filter's terms, from its text: each an operator and the value after it,\n * a new term beginning wherever whitespace comes before an operator, so a\n * value may hold spaces. Text with no operator before it is `*=`. A term\n * with no value is not yet a term, and is left out, so a filter being typed\n * filters nothing until it says something. Nothing is evaluated.\n */\nexport function parseFilter(text: string): FilterTerm[] {\n const terms: FilterTerm[] = [];\n for (const raw of text.trim().split(NEXT_TERM)) {\n const operator =\n FILTER_OPERATORS.find((op) => raw.startsWith(op)) ?? \"*=\";\n const value = raw.slice(raw.startsWith(operator) ? operator.length : 0);\n if (value.trim() !== \"\") terms.push({ operator, value: value.trim() });\n }\n return terms;\n}\n\n/**\n * The filter's value as the column's own type, so a comparison is the one\n * the order makes: a number for a number, a boolean for a boolean, text for\n * anything else. Undefined when the text is no value of that type.\n */\nfunction asTypeOf(text: string, like: unknown): unknown {\n if (typeof like === \"number\") {\n const n = Number(text);\n return text.trim() === \"\" || Number.isNaN(n) ? undefined : n;\n }\n if (typeof like === \"boolean\") {\n return text === \"true\" ? true : text === \"false\" ? false : undefined;\n }\n return text;\n}\n\n/**\n * Whether a column's value passes one term.\n *\n * `^=`, `$=` and `*=` read the value as text, ignoring case: it begins with,\n * ends with or contains the term's value. The rest compare as the order\n * compares, with the column read as its declared type, if it has one, and\n * the term's value read as the column's type. A missing value, and one that\n * is no value of its declared type, passes only `!=`.\n */\nexport function passesTerm(\n value: unknown,\n { operator, value: text }: FilterTerm,\n type?: ColumnType,\n): boolean {\n if (value === null || value === undefined) return operator === \"!=\";\n if (operator === \"^=\" || operator === \"$=\" || operator === \"*=\") {\n const have = String(value).toLocaleLowerCase();\n const want = text.toLocaleLowerCase();\n if (operator === \"^=\") return have.startsWith(want);\n if (operator === \"$=\") return have.endsWith(want);\n return have.includes(want);\n }\n const read = readAs(value, type);\n const typed = read === undefined ? undefined : asTypeOf(text, read);\n if (typed === undefined) return operator === \"!=\";\n const c = compareValues(read, typed);\n switch (operator) {\n case \"=\":\n return c === 0;\n case \"!=\":\n return c !== 0;\n case \"<\":\n return c < 0;\n case \"<=\":\n return c <= 0;\n case \">\":\n return c > 0;\n default:\n return c >= 0;\n }\n}\n\n/** Whether a column's value passes every term of a filter. */\nexport function passes(\n value: unknown,\n terms: FilterTerm[],\n type?: ColumnType,\n): boolean {\n return terms.every((term) => passesTerm(value, term, type));\n}\n\n/**\n * Where a row for `lb-url` leads, from a page and its query parms.\n *\n * A column whose name begins with `lb-` is Loadbare's, and never a query\n * parm; every other column is one. An `lb-path` naming another page enters\n * it with only the parms the row names. Otherwise the named parms are set,\n * or taken out when empty, and the rest are kept.\n *\n * One rule on both sides of the wire: the server loads the page it names,\n * and the hub writes the URL it names. The two must agree, or what the page\n * shows would differ from what the address bar says.\n */\nexport function nextLocation(\n page: string,\n parms: URLSearchParams,\n row: Row,\n): { page: string; parms: URLSearchParams; moved: boolean } {\n const named: Record<string, ParmValue> = {};\n const text = (value: unknown): string =>\n value === null || value === undefined ? \"\" : String(value);\n for (const [name, value] of Object.entries(row)) {\n if (name.startsWith(LB_RESERVED_PREFIX)) continue;\n named[name] = Array.isArray(value) ? value.map(text) : text(value);\n }\n const path = row[URL_COLUMN_PATH];\n const next = typeof path === \"string\" ? pageNameFor(path) : page;\n const moved = next !== page;\n return {\n page: next,\n parms: withQueryParms(moved ? new URLSearchParams() : parms, named),\n moved,\n };\n}\n\n/**\n * What the hub tells a custom element it did, in its own terms rather than\n * the browser's: a custom element implements any of these in place of\n * `connectedCallback` and its kin, which the builder refuses.\n *\n * Each is a method on an element the hub does not own, so it carries the\n * `lb` prefix Loadbare reserves for exactly that — see\n * docs/reference/custom-elements.md.\n */\nexport interface HubLifecycle {\n /**\n * Called once, after the hub has placed the element and every column has\n * landed on it. An element under an `lb-show` that is off is placed inside\n * its template, so it may not be rendered.\n */\n lbAttached?(): void;\n /**\n * Called once after a result has landed on an element holding rows, with\n * every row in place and every stamp set. The hub reconciles and places\n * every row itself, by the query's order, so a custom element reacts to\n * rows and never places them.\n */\n lbRowsLanded?(): void;\n /**\n * Called once a request committed by this element, or by one inside it,\n * has finished, innermost first and before `lb-request-done` is\n * dispatched. `origin` is the element that committed.\n */\n lbRequestDone?(detail: HubRequestDone, origin: Element): void;\n /** Called once, after the hub has removed the element. */\n lbDetached?(): void;\n}\n"]}
1
+ {"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAGL,gBAAgB,EAEhB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AA2C3B,MAAM,UAAU,OAAO,CAAC,MAAkB;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAmCD;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAA8B;IACnD,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACjC,CAAC;AAwCD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAsB;IAC7C,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,G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MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC;YAAE,SAAS;QAClD,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,MAAM,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5B,OAAO;QACL,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC;QACnE,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\n// The wire vocabulary. Shared by browser and server.\n\nimport {\n COLUMN_TYPES,\n KIND_ROW,\n FILTER_OPERATORS,\n KIND_ROWS,\n LB_RESERVED_PREFIX,\n LB_ROW_REQUESTS,\n ORDER_DESCENDING,\n URL_COLUMN_PATH,\n} from \"./lb-constants.js\";\n\n/**\n * One row: its columns, by name.\n *\n * A value is whatever the server serialized. The hub knows nothing about its\n * type and enforces nothing: it hands each value to the browser untouched,\n * and the browser renders it as it sees fit. What a number, a date or a null\n * should look like is the application's decision, made in the query.\n */\nexport type Row = Record<string, unknown>;\n\n/**\n * Part of a `rows` query's answer.\n *\n * Rows named here are added or updated, keys in `drop` are removed, and\n * anything unnamed is left alone. The hub places what it names by the\n * query's order. Add and remove are one result rather than two because the\n * interesting cases are both at once — a row whose sort key changed has to\n * move, a swap is one out and one in — and two messages would paint the\n * intermediate state.\n */\nexport interface Patch {\n rows?: Row[];\n drop?: unknown[];\n}\n\n/** A type a `rows` query may declare for a column — see COLUMN_TYPES. */\nexport type ColumnType = (typeof COLUMN_TYPES)[number];\n\n/** The types a `rows` query declares for its columns, by column. */\nexport type ColumnTypes = Record<string, ColumnType>;\n\n/** A query's kind, declared by the server and carried by every answer. */\nexport type Kind = typeof KIND_ROW | typeof KIND_ROWS;\n\n/**\n * What a `rows` query answers with: all rows, or a patch. `Array.isArray`\n * tells the two apart. All rows arrive in the order the server chose, which\n * is the order they show in when the query declares none.\n */\nexport type RowsResult = Row[] | Patch;\n\nexport function isPatch(result: RowsResult): result is Patch {\n return !Array.isArray(result);\n}\n\n/**\n * What any one query answers with, as the application writes it. A `row`\n * query that finds no row answers `null`.\n */\nexport type HubResult = Row | RowsResult | null;\n\n/**\n * What application code hands the engine: answers by query name. The engine\n * turns each into a response item, adding the kind and key the query\n * declared.\n */\nexport type HubData = Record<string, HubResult>;\n\n/**\n * One query's answer on the wire: its name, its kind, its key's column name,\n * and exactly one of all its rows or a patch. Every answer is rows: a query\n * declared `row` answers with at most one, and a patch answers a `rows` query\n * only.\n *\n * A `rows` query also carries the order and column types it declared, once,\n * on the answer that loads the page. The hub keeps them with the answer for\n * every answer after it.\n */\nexport interface ResponseItem {\n query: string;\n kind: Kind;\n key: string;\n rows?: Row[];\n patch?: Patch;\n order?: string;\n types?: ColumnTypes;\n}\n\n/**\n * The one row of an answer to a query declared `row`, or null when it found\n * none.\n */\nexport function oneRow(item: ResponseItem | undefined): Row | null {\n return item?.rows?.[0] ?? null;\n}\n\n/** Every response the server sends: a page load and a request alike. */\nexport type HubResponse = ResponseItem[];\n\n/**\n * Every request has one shape. The name picks the handler; the rest is\n * present when the hub found it.\n */\nexport interface HubRequest {\n name: string;\n query?: string;\n key?: string;\n /**\n * The gathered controls' values, by column. A column of `lb-url` may hold\n * several, as a URL repeats a parm; every other column holds one.\n */\n values?: Record<string, ParmValue>;\n /**\n * The rows of the queries nested in a form, by query name, each with the\n * values of its own controls: a set of rows gathered beside the form's\n * own values.\n */\n rows?: Record<string, GatheredRow[]>;\n /** The queries an `lb-read` runs again. */\n queries?: string[];\n}\n\n/** One nested row a form gathered: its key, and its controls' values. */\nexport interface GatheredRow {\n key: string;\n values: Record<string, string>;\n}\n\n/**\n * What a control gathers: one value, or several from a control that holds\n * several, which only a column of `lb-url` takes.\n */\nexport type ParmValue = string | string[];\n\n/**\n * The query parms of a URL as a row of `lb-url`: a parm the URL carries\n * once is a string, and one it repeats is every value it carries, in order.\n */\nexport function parmsRow(parms: URLSearchParams): Row {\n const row: Row = {};\n for (const name of new Set(parms.keys())) {\n const all = parms.getAll(name);\n row[name] = all.length === 1 ? all[0] : all;\n }\n return row;\n}\n\n/**\n * The detail of the `lb-request-done` event: the request as the hub\n * completed and sent it, and what came of it. `items` is every response\n * item that landed because of it, in the order it landed. `error` is set\n * when the request's own round trip failed, and then nothing landed.\n */\nexport interface HubRequestDone {\n request: HubRequest;\n items: ResponseItem[];\n error?: Error;\n /** Set beside `error` when the handler refused the request. */\n refusal?: HubRefusal;\n}\n\n/**\n * Why a handler refused a request, in words written for the user: a\n * message for the request as a whole, a message per column the request\n * gathered, or both. Sent with status 422; any other failure sends nothing.\n */\nexport interface HubRefusal {\n message?: string;\n columns?: Record<string, string>;\n}\n\n/** The fields a handler receives: the request, less its name. */\nexport type RequestFields = Omit<HubRequest, \"name\" | \"values\"> & {\n values?: Record<string, string>;\n};\n\n/** Whether a name is one of the requests Loadbare provides. */\nexport function isRowRequest(name: string): boolean {\n return (LB_ROW_REQUESTS as readonly string[]).includes(name);\n}\n\n/**\n * A query string with some parms set, and the rest as they were. An empty\n * value takes its parm out, since empty is every parm's default and a\n * default is left out of the URL.\n *\n * One rule on both sides of the wire: the hub applies it to the address bar,\n * and the server to the query string it loads the page at after a request\n * returned `lb-url`. The two must agree, or what the page shows would differ\n * from what the address bar says.\n */\nexport function withQueryParms(\n search: URLSearchParams,\n parms: Record<string, ParmValue>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (!Array.isArray(value)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\n continue;\n }\n // Several values repeat the parm, as an HTML form sends them. Values\n // already there are left where they stand, so the URL is unchanged.\n const kept = value.filter((v) => v !== \"\");\n const had = next.getAll(name);\n if (kept.length === had.length && kept.every((v, i) => v === had[i])) {\n continue;\n }\n if (kept.length === 1) {\n next.set(name, kept[0]!);\n continue;\n }\n next.delete(name);\n for (const v of kept) next.append(name, v);\n }\n return next;\n}\n\n/**\n * A path names a page by its stub, and nothing finer. The bare path resolves\n * to `index`, the same convention a static file server follows.\n */\nexport function pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/** One term of an order: a column, and whether it sorts descending. */\nexport interface OrderTerm {\n column: string;\n descending: boolean;\n}\n\n/**\n * An order's terms, from its text: columns separated by commas, each\n * descending when it begins with `-`. Throws on a term that names no column.\n * An empty text is no order.\n */\nexport function parseOrder(text: string): OrderTerm[] {\n if (text.trim() === \"\") return [];\n return text.split(\",\").map((raw) => {\n const term = raw.trim();\n const descending = term.startsWith(ORDER_DESCENDING);\n const column = descending ? term.slice(ORDER_DESCENDING.length) : term;\n if (column === \"\" || column.startsWith(ORDER_DESCENDING)) {\n throw new Error(`the order '${text}' has a term naming no column`);\n }\n return { column, descending };\n });\n}\n\n/** Strings compare as the user's language orders them. */\nconst collator = new Intl.Collator();\n\n/** How a value sorts among values of other types: by its JSON type. */\nfunction rank(value: unknown): number {\n switch (typeof value) {\n case \"boolean\":\n return 0;\n case \"number\":\n return 1;\n case \"string\":\n return 2;\n default:\n return 3;\n }\n}\n\n/**\n * Compare two column values, ascending.\n *\n * A value compares by its JSON type, and nothing is guessed: numbers\n * numerically, booleans false before true, strings as the user's language\n * orders them. A number that arrives as a string sorts as a string, so a\n * numeric sort column is sent as a JSON number. Null and a missing value\n * sort after everything, as Postgres sorts them ascending, and so first\n * descending.\n */\nexport function compareValues(a: unknown, b: unknown): number {\n const missingA = a === null || a === undefined;\n const missingB = b === null || b === undefined;\n if (missingA || missingB) return missingA === missingB ? 0 : missingA ? 1 : -1;\n const ra = rank(a);\n const rb = rank(b);\n if (ra !== rb) return ra - rb;\n if (typeof a === \"number\") return a - (b as number);\n if (typeof a === \"boolean\") return Number(a) - Number(b);\n if (typeof a === \"string\") return collator.compare(a, b as string);\n return collator.compare(JSON.stringify(a), JSON.stringify(b));\n}\n\n/**\n * A value read as a declared column type: a number for `number`, a boolean\n * for `boolean`, text for `text`. A value that is no value of its type reads\n * as missing, and compares as a null does. A column with no declared type\n * reads as it arrived.\n */\nexport function readAs(value: unknown, type: ColumnType | undefined): unknown {\n if (type === undefined || value === null || value === undefined) return value;\n switch (type) {\n case \"number\": {\n if (typeof value === \"number\") return value;\n if (typeof value !== \"string\" || value.trim() === \"\") return undefined;\n const n = Number(value);\n return Number.isNaN(n) ? undefined : n;\n }\n case \"boolean\":\n if (typeof value === \"boolean\") return value;\n return value === \"true\" ? true : value === \"false\" ? false : undefined;\n default:\n return typeof value === \"object\" ? JSON.stringify(value) : String(value);\n }\n}\n\n/** Compare two rows by an order's terms, each column read as its type. */\nexport function compareRows(\n a: Row,\n b: Row,\n terms: OrderTerm[],\n types: ColumnTypes = {},\n): number {\n for (const { column, descending } of terms) {\n const c = compareValues(\n readAs(a[column], types[column]),\n readAs(b[column], types[column]),\n );\n if (c !== 0) return descending ? -c : c;\n }\n return 0;\n}\n\n/** A filter's operator — see FILTER_OPERATORS. */\nexport type FilterOperator = (typeof FILTER_OPERATORS)[number];\n\n/** One term of a filter: an operator, and the value it compares with. */\nexport interface FilterTerm {\n operator: FilterOperator;\n value: string;\n}\n\n/** Where a filter's next term begins: whitespace before an operator. */\nconst NEXT_TERM = new RegExp(\n `\\\\s+(?=${FILTER_OPERATORS.map((op) => op.replace(/[$^*]/g, \"\\\\$&\")).join(\"|\")})`,\n);\n\n/**\n * A filter's terms, from its text: each an operator and the value after it,\n * a new term beginning wherever whitespace comes before an operator, so a\n * value may hold spaces. Text with no operator before it is `*=`. A term\n * with no value is not yet a term, and is left out, so a filter being typed\n * filters nothing until it says something. Nothing is evaluated.\n */\nexport function parseFilter(text: string): FilterTerm[] {\n const terms: FilterTerm[] = [];\n for (const raw of text.trim().split(NEXT_TERM)) {\n const operator =\n FILTER_OPERATORS.find((op) => raw.startsWith(op)) ?? \"*=\";\n const value = raw.slice(raw.startsWith(operator) ? operator.length : 0);\n if (value.trim() !== \"\") terms.push({ operator, value: value.trim() });\n }\n return terms;\n}\n\n/**\n * The filter's value as the column's own type, so a comparison is the one\n * the order makes: a number for a number, a boolean for a boolean, text for\n * anything else. Undefined when the text is no value of that type.\n */\nfunction asTypeOf(text: string, like: unknown): unknown {\n if (typeof like === \"number\") {\n const n = Number(text);\n return text.trim() === \"\" || Number.isNaN(n) ? undefined : n;\n }\n if (typeof like === \"boolean\") {\n return text === \"true\" ? true : text === \"false\" ? false : undefined;\n }\n return text;\n}\n\n/**\n * Whether a column's value passes one term.\n *\n * `^=`, `$=` and `*=` read the value as text, ignoring case: it begins with,\n * ends with or contains the term's value. The rest compare as the order\n * compares, with the column read as its declared type, if it has one, and\n * the term's value read as the column's type. A missing value, and one that\n * is no value of its declared type, passes only `!=`.\n */\nexport function passesTerm(\n value: unknown,\n { operator, value: text }: FilterTerm,\n type?: ColumnType,\n): boolean {\n if (value === null || value === undefined) return operator === \"!=\";\n if (operator === \"^=\" || operator === \"$=\" || operator === \"*=\") {\n const have = String(value).toLocaleLowerCase();\n const want = text.toLocaleLowerCase();\n if (operator === \"^=\") return have.startsWith(want);\n if (operator === \"$=\") return have.endsWith(want);\n return have.includes(want);\n }\n const read = readAs(value, type);\n const typed = read === undefined ? undefined : asTypeOf(text, read);\n if (typed === undefined) return operator === \"!=\";\n const c = compareValues(read, typed);\n switch (operator) {\n case \"=\":\n return c === 0;\n case \"!=\":\n return c !== 0;\n case \"<\":\n return c < 0;\n case \"<=\":\n return c <= 0;\n case \">\":\n return c > 0;\n default:\n return c >= 0;\n }\n}\n\n/** Whether a column's value passes every term of a filter. */\nexport function passes(\n value: unknown,\n terms: FilterTerm[],\n type?: ColumnType,\n): boolean {\n return terms.every((term) => passesTerm(value, term, type));\n}\n\n/**\n * Where a row for `lb-url` leads, from a page and its query parms.\n *\n * A column whose name begins with `lb-` is Loadbare's, and never a query\n * parm; every other column is one. An `lb-path` naming another page enters\n * it with only the parms the row names. Otherwise the named parms are set,\n * or taken out when empty, and the rest are kept.\n *\n * One rule on both sides of the wire: the server loads the page it names,\n * and the hub writes the URL it names. The two must agree, or what the page\n * shows would differ from what the address bar says.\n */\nexport function nextLocation(\n page: string,\n parms: URLSearchParams,\n row: Row,\n): { page: string; parms: URLSearchParams; moved: boolean } {\n const named: Record<string, ParmValue> = {};\n const text = (value: unknown): string =>\n value === null || value === undefined ? \"\" : String(value);\n for (const [name, value] of Object.entries(row)) {\n if (name.startsWith(LB_RESERVED_PREFIX)) continue;\n named[name] = Array.isArray(value) ? value.map(text) : text(value);\n }\n const path = row[URL_COLUMN_PATH];\n const next = typeof path === \"string\" ? pageNameFor(path) : page;\n const moved = next !== page;\n return {\n page: next,\n parms: withQueryParms(moved ? new URLSearchParams() : parms, named),\n moved,\n };\n}\n\n/**\n * What the hub tells a custom element it did, in its own terms rather than\n * the browser's: a custom element implements any of these in place of\n * `connectedCallback` and its kin, which the builder refuses.\n *\n * Each is a method on an element the hub does not own, so it carries the\n * `lb` prefix Loadbare reserves for exactly that.\n */\nexport interface HubLifecycle {\n /**\n * Called once, after the hub has placed the element and every column has\n * landed on it. An element under an `lb-show` that is off is placed inside\n * its template, so it may not be rendered.\n */\n lbAttached?(): void;\n /**\n * Called once after a result has landed on an element holding rows, with\n * every row in place and every stamp set. The hub reconciles and places\n * every row itself, by the query's order, so a custom element reacts to\n * rows and never places them.\n */\n lbRowsLanded?(): void;\n /**\n * Called once a request committed by this element, or by one inside it,\n * has finished, innermost first and before `lb-request-done` is\n * dispatched. `origin` is the element that committed.\n */\n lbRequestDone?(detail: HubRequestDone, origin: Element): void;\n /** Called once, after the hub has removed the element. */\n lbDetached?(): void;\n}\n"]}