@loadbare/app 0.16.0 → 0.17.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 (46) hide show
  1. package/README.md +10 -14
  2. package/dist/build/assemble.d.ts.map +1 -1
  3. package/dist/build/assemble.js +15 -1
  4. package/dist/build/assemble.js.map +1 -1
  5. package/dist/core/lb-constants.d.ts +6 -2
  6. package/dist/core/lb-constants.d.ts.map +1 -1
  7. package/dist/core/lb-constants.js +38 -8
  8. package/dist/core/lb-constants.js.map +1 -1
  9. package/dist/core/lb-types.d.ts +57 -20
  10. package/dist/core/lb-types.d.ts.map +1 -1
  11. package/dist/core/lb-types.js +122 -11
  12. package/dist/core/lb-types.js.map +1 -1
  13. package/dist/hub/lb-apply.d.ts +38 -26
  14. package/dist/hub/lb-apply.d.ts.map +1 -1
  15. package/dist/hub/lb-apply.js +655 -471
  16. package/dist/hub/lb-apply.js.map +1 -1
  17. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  18. package/dist/hub/lb-hub.browser.js +77 -59
  19. package/dist/hub/lb-hub.browser.js.map +1 -1
  20. package/dist/hub/lb-lifecycle.d.ts +1 -2
  21. package/dist/hub/lb-lifecycle.d.ts.map +1 -1
  22. package/dist/hub/lb-lifecycle.js +9 -3
  23. package/dist/hub/lb-lifecycle.js.map +1 -1
  24. package/dist/server/lb-server.d.ts +29 -12
  25. package/dist/server/lb-server.d.ts.map +1 -1
  26. package/dist/server/lb-server.js +72 -11
  27. package/dist/server/lb-server.js.map +1 -1
  28. package/docs/TECHREF-1.0.md +162 -48
  29. package/docs/comparison.md +9 -8
  30. package/docs/reference/chrome.md +8 -5
  31. package/docs/reference/custom-elements.md +25 -7
  32. package/docs/reference/data-binding.md +125 -22
  33. package/docs/reference/page-files.md +51 -7
  34. package/docs/reference/widgets.md +5 -1
  35. package/docs/roadmap.md +8 -0
  36. package/docs/testing.md +6 -2
  37. package/docs/theory-old.md +839 -0
  38. package/docs/theory.md +113 -839
  39. package/package.json +1 -1
  40. package/skills/loadbare-app/SKILL.md +28 -15
  41. package/skills/loadbare-app/references/TECHREF-1.0.md +162 -48
  42. package/skills/loadbare-app/references/chrome.md +8 -5
  43. package/skills/loadbare-app/references/custom-elements.md +25 -7
  44. package/skills/loadbare-app/references/data-binding.md +125 -22
  45. package/skills/loadbare-app/references/page-files.md +51 -7
  46. package/skills/loadbare-app/references/widgets.md +5 -1
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="dom" />
2
2
  // The wire vocabulary. Shared by browser and server.
3
- import { LB_RESERVED_PREFIX, LB_ROW_REQUESTS, ORDER_DESCENDING, ORDER_PARM_PREFIX, URL_COLUMN_PATH, } from "./lb-constants.js";
3
+ import { FILTER_OPERATORS, LB_RESERVED_PREFIX, LB_ROW_REQUESTS, ORDER_DESCENDING, URL_COLUMN_PATH, } from "./lb-constants.js";
4
4
  export function isPatch(result) {
5
5
  return !Array.isArray(result);
6
6
  }
@@ -54,10 +54,6 @@ export function parseOrder(text) {
54
54
  return { column, descending };
55
55
  });
56
56
  }
57
- /** The query parm carrying the user's order for a query. */
58
- export function orderParm(query) {
59
- return ORDER_PARM_PREFIX + query;
60
- }
61
57
  /** Strings compare as the user's language orders them. */
62
58
  const collator = new Intl.Collator();
63
59
  /** How a value sorts among values of other types: by its JSON type. */
@@ -100,22 +96,137 @@ export function compareValues(a, b) {
100
96
  return collator.compare(a, b);
101
97
  return collator.compare(JSON.stringify(a), JSON.stringify(b));
102
98
  }
103
- /** Compare two rows by an order's terms. */
104
- export function compareRows(a, b, terms) {
99
+ /**
100
+ * A value read as a declared column type: a number for `number`, a boolean
101
+ * for `boolean`, text for `text`. A value that is no value of its type reads
102
+ * as missing, and compares as a null does. A column with no declared type
103
+ * reads as it arrived.
104
+ */
105
+ export function readAs(value, type) {
106
+ if (type === undefined || value === null || value === undefined)
107
+ return value;
108
+ switch (type) {
109
+ case "number": {
110
+ if (typeof value === "number")
111
+ return value;
112
+ if (typeof value !== "string" || value.trim() === "")
113
+ return undefined;
114
+ const n = Number(value);
115
+ return Number.isNaN(n) ? undefined : n;
116
+ }
117
+ case "boolean":
118
+ if (typeof value === "boolean")
119
+ return value;
120
+ return value === "true" ? true : value === "false" ? false : undefined;
121
+ default:
122
+ return typeof value === "object" ? JSON.stringify(value) : String(value);
123
+ }
124
+ }
125
+ /** Compare two rows by an order's terms, each column read as its type. */
126
+ export function compareRows(a, b, terms, types = {}) {
105
127
  for (const { column, descending } of terms) {
106
- const c = compareValues(a[column], b[column]);
128
+ const c = compareValues(readAs(a[column], types[column]), readAs(b[column], types[column]));
107
129
  if (c !== 0)
108
130
  return descending ? -c : c;
109
131
  }
110
132
  return 0;
111
133
  }
134
+ /** Where a filter's next term begins: whitespace before an operator. */
135
+ const NEXT_TERM = new RegExp(`\\s+(?=${FILTER_OPERATORS.map((op) => op.replace(/[$^*]/g, "\\$&")).join("|")})`);
136
+ /**
137
+ * A filter's terms, from its text: each an operator and the value after it,
138
+ * a new term beginning wherever whitespace comes before an operator, so a
139
+ * value may hold spaces. Text with no operator before it is `*=`. A term
140
+ * with no value is not yet a term, and is left out, so a filter being typed
141
+ * filters nothing until it says something. Nothing is evaluated.
142
+ */
143
+ export function parseFilter(text) {
144
+ const terms = [];
145
+ for (const raw of text.trim().split(NEXT_TERM)) {
146
+ const operator = FILTER_OPERATORS.find((op) => raw.startsWith(op)) ?? "*=";
147
+ const value = raw.slice(raw.startsWith(operator) ? operator.length : 0);
148
+ if (value.trim() !== "")
149
+ terms.push({ operator, value: value.trim() });
150
+ }
151
+ return terms;
152
+ }
153
+ /**
154
+ * The filter's value as the column's own type, so a comparison is the one
155
+ * the order makes: a number for a number, a boolean for a boolean, text for
156
+ * anything else. Undefined when the text is no value of that type.
157
+ */
158
+ function asTypeOf(text, like) {
159
+ if (typeof like === "number") {
160
+ const n = Number(text);
161
+ return text.trim() === "" || Number.isNaN(n) ? undefined : n;
162
+ }
163
+ if (typeof like === "boolean") {
164
+ return text === "true" ? true : text === "false" ? false : undefined;
165
+ }
166
+ return text;
167
+ }
168
+ /**
169
+ * Whether a column's value passes one term.
170
+ *
171
+ * `^=`, `$=` and `*=` read the value as text, ignoring case: it begins with,
172
+ * ends with or contains the term's value. The rest compare as the order
173
+ * compares, with the column read as its declared type, if it has one, and
174
+ * the term's value read as the column's type. A missing value, and one that
175
+ * is no value of its declared type, passes only `!=`.
176
+ */
177
+ export function passesTerm(value, { operator, value: text }, type) {
178
+ if (value === null || value === undefined)
179
+ return operator === "!=";
180
+ if (operator === "^=" || operator === "$=" || operator === "*=") {
181
+ const have = String(value).toLocaleLowerCase();
182
+ const want = text.toLocaleLowerCase();
183
+ if (operator === "^=")
184
+ return have.startsWith(want);
185
+ if (operator === "$=")
186
+ return have.endsWith(want);
187
+ return have.includes(want);
188
+ }
189
+ const read = readAs(value, type);
190
+ const typed = read === undefined ? undefined : asTypeOf(text, read);
191
+ if (typed === undefined)
192
+ return operator === "!=";
193
+ const c = compareValues(read, typed);
194
+ switch (operator) {
195
+ case "=":
196
+ return c === 0;
197
+ case "!=":
198
+ return c !== 0;
199
+ case "<":
200
+ return c < 0;
201
+ case "<=":
202
+ return c <= 0;
203
+ case ">":
204
+ return c > 0;
205
+ default:
206
+ return c >= 0;
207
+ }
208
+ }
209
+ /** Whether a column's value passes every term of a filter. */
210
+ export function passes(value, terms, type) {
211
+ return terms.every((term) => passesTerm(value, term, type));
212
+ }
213
+ /**
214
+ * Where a row for `lb-url` leads, from a page and its query parms.
215
+ *
216
+ * A column whose name begins with `lb-` is Loadbare's, and never a query
217
+ * parm; every other column is one. An `lb-path` naming another page enters
218
+ * it with only the parms the row names. Otherwise the named parms are set,
219
+ * or taken out when empty, and the rest are kept.
220
+ *
221
+ * One rule on both sides of the wire: the server loads the page it names,
222
+ * and the hub writes the URL it names. The two must agree, or what the page
223
+ * shows would differ from what the address bar says.
224
+ */
112
225
  export function nextLocation(page, parms, row) {
113
226
  const named = {};
114
227
  for (const [name, value] of Object.entries(row)) {
115
- if (name.startsWith(LB_RESERVED_PREFIX) &&
116
- !name.startsWith(ORDER_PARM_PREFIX)) {
228
+ if (name.startsWith(LB_RESERVED_PREFIX))
117
229
  continue;
118
- }
119
230
  named[name] = value === null || value === undefined ? "" : String(value);
120
231
  }
121
232
  const path = row[URL_COLUMN_PATH];
@@ -1 +1 @@
1
- {"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAGL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAqC3B,MAAM,UAAU,OAAO,CAAC,MAAkB;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAyFD,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAQ,eAAqC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAuB,EACvB,KAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;YAC/B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC5C,OAAO,IAAI,KAAK,EAAE,CAAC,CAA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KAAK,CAAC;YAAE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,KAAsB,EACtB,GAAQ;IAER,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,IACE,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACnC,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EACnC,CAAC;YACD,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3E,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 KIND_ROW,\n KIND_ROWS,\n LB_RESERVED_PREFIX,\n LB_ROW_REQUESTS,\n ORDER_DESCENDING,\n ORDER_PARM_PREFIX,\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 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/** What any one query answers with, as the application writes it. */\nexport type HubResult = Row | RowsResult;\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 what it declared about order: the order the\n * server gives it, and whether the query reads the order parm itself.\n */\nexport interface ResponseItem {\n query: string;\n kind: Kind;\n key: string;\n row?: Row;\n rows?: Row[];\n patch?: Patch;\n order?: string;\n serverSortedByUrl?: boolean;\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 values?: Record<string, string>;\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 * 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\">;\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, string>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\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/**\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, except an order parm, which is one; 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 */\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/** The query parm carrying the user's order for a query. */\nexport function orderParm(query: string): string {\n return ORDER_PARM_PREFIX + query;\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/** Compare two rows by an order's terms. */\nexport function compareRows(a: Row, b: Row, terms: OrderTerm[]): number {\n for (const { column, descending } of terms) {\n const c = compareValues(a[column], b[column]);\n if (c !== 0) return descending ? -c : c;\n }\n return 0;\n}\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, string> = {};\n for (const [name, value] of Object.entries(row)) {\n if (\n name.startsWith(LB_RESERVED_PREFIX) &&\n !name.startsWith(ORDER_PARM_PREFIX)\n ) {\n continue;\n }\n named[name] = value === null || value === undefined ? \"\" : String(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"]}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WS,\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/** What any one query answers with, as the application writes it. */\nexport type HubResult = Row | RowsResult;\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;\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 values?: Record<string, string>;\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 * 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\">;\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, string>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\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, string> = {};\n for (const [name, value] of Object.entries(row)) {\n if (name.startsWith(LB_RESERVED_PREFIX)) continue;\n named[name] = value === null || value === undefined ? \"\" : String(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,4 +1,4 @@
1
- import { type ResponseItem, type Row, type RowsResult } from "../core/lb-types.js";
1
+ import { type ColumnTypes, type ResponseItem, type Row, type RowsResult } from "../core/lb-types.js";
2
2
  /** A control's value, whether it is native or a custom element. */
3
3
  export interface Control extends Element {
4
4
  value: string;
@@ -35,15 +35,15 @@ export declare function select(box: Element, on: boolean): void;
35
35
  /**
36
36
  * Fill from one row: every `lb-column` and `lb-show` in root's query.
37
37
  *
38
- * A live row is its own row, so its root counts when it carries
39
- * `lb-column`: `<option>`'s content model is text, so an option row has to
40
- * be the column it displays. An element a `row` lands on is not its own
41
- * ancestor, so its own `lb-column` reads from the row around it and is left
42
- * alone here.
38
+ * With `self`, root's own `lb-column` counts, as a live row's does:
39
+ * `<option>`'s content model is text, so an option row has to be the column
40
+ * it displays. An element a `row` lands on is not its own ancestor, so its
41
+ * own `lb-column` reads from the row around it and is left alone here. Root's
42
+ * own `lb-show` never counts.
43
43
  *
44
- * A live row is searched once, the first time it is filled; see places().
44
+ * `stop` passes over everything matching it and inside it.
45
45
  */
46
- export declare function applyRow(root: Element, row: Row, liveRow?: boolean, stop?: string): void;
46
+ export declare function applyRow(root: Element, row: Row, self?: boolean, stop?: string): void;
47
47
  /**
48
48
  * A row naming every column root's query shows, each null: what landing it
49
49
  * leaves is root as it stands with no row. Absent branches are counted, so a
@@ -57,10 +57,21 @@ export declare function blankRow(root: Element): Row;
57
57
  * live row comes first in document order.
58
58
  */
59
59
  export declare function templateIn(el: Element): HTMLTemplateElement | null;
60
+ /**
61
+ * Focus the first element in `root` the user can operate: not disabled, not
62
+ * in a closed dialog, not inert, not hidden, and one that took the focus
63
+ * when asked. Nothing in a `<template>` is a candidate, so an absent
64
+ * `lb-show` branch is passed over.
65
+ */
66
+ export declare function focusIn(root: Element): void;
60
67
  /** How a list of rows lands: in what order, and whether a request asked. */
61
68
  export interface RowsOptions {
62
- /** The order to place rows by, as an order's text. */
69
+ /** The order the server declared, as an order's text. */
63
70
  order?: string;
71
+ /** The column types the server declared. */
72
+ types?: ColumnTypes;
73
+ /** The user's choices: the row of `lb-choices`. */
74
+ choices?: Row;
64
75
  /** The landing answers a request from this page. */
65
76
  requested?: boolean;
66
77
  /**
@@ -72,46 +83,47 @@ export interface RowsOptions {
72
83
  /**
73
84
  * Land rows through a row template.
74
85
  *
86
+ * Two loops do the work, on rows in no document. The creation loop makes a
87
+ * live row for each key not yet shown, with its key and no values. The
88
+ * landing loop lands each arriving row's values on its live row, as a `row`
89
+ * lands, passing over a column that already shows its value. Then every live
90
+ * row is placed by the order in one fragment, and the browser styles once.
91
+ *
75
92
  * All rows decide membership: a row whose key did not arrive leaves. A patch
76
93
  * disturbs only what it names — a row it did not mention keeps its contents,
77
94
  * and keeps its place unless a row the patch named now sorts around it.
78
95
  *
79
- * Every live row is placed by the order. With none, all rows show in the
80
- * order they arrived, and a patch's new rows go last. A row moves only when
81
- * the order put it somewhere else, so landing the same rows again moves
82
- * nothing.
96
+ * With no order, all rows show in the order they arrived, and a patch's new
97
+ * rows go last. A row that stands where it stood is not touched, so landing
98
+ * the same rows again moves nothing. A row a filter the user chose does not
99
+ * pass is `hidden`.
83
100
  */
84
101
  export declare function applyRows(el: Element, template: HTMLTemplateElement, keyColumn: string, result: RowsResult, options?: RowsOptions): void;
85
102
  /** The answer kept for a query, as all of its rows. */
86
103
  export declare function keptAnswer(root: ParentNode, query: string): ResponseItem | undefined;
87
104
  /**
88
105
  * Drop what landing kept for a root. The hub calls it when it replaces the
89
- * page, since another page's query of the same name is another query.
106
+ * page, since another page's query of the same name is another query, and
107
+ * the user's choices were for the page they were made on.
90
108
  */
91
109
  export declare function forget(root: ParentNode): void;
92
110
  /** How response items land. */
93
111
  export interface LandOptions {
94
112
  /**
95
- * Queries that may have nowhere to land without a warning: the hub's own
96
- * `lb-url` lands wherever a chrome or page names it, and nowhere otherwise.
113
+ * Queries that may have nowhere to land without a warning. A query the hub
114
+ * serves, such as `lb-url`, is always one: it lands wherever a chrome or
115
+ * page names it, and nowhere otherwise.
97
116
  */
98
117
  quiet?: readonly string[];
99
- /** The user's order for a query, which replaces the server's. */
100
- orderFor?: (query: string) => string | undefined;
101
118
  /** The items answer a request from this page. */
102
119
  requested?: boolean;
103
120
  }
104
121
  /**
105
122
  * Land response items. Every answer arrives through here, and is kept for
106
123
  * `root`, so that what arrives after it is filled from it — see forget().
107
- * Once everything has landed, each custom element placed since the last
108
- * landing is attached.
124
+ * An answer to `lb-choices` places again the rows its choices change. Once
125
+ * everything has landed, each custom element placed since the last landing
126
+ * is attached.
109
127
  */
110
128
  export declare function applyResponse(root: ParentNode, items: ResponseItem[], options?: LandOptions): void;
111
- /**
112
- * Land a query's kept answer again, as all of its rows: what the hub does
113
- * when the user's order for it changes and the rows themselves have not.
114
- * False when no answer is kept.
115
- */
116
- export declare function reland(root: ParentNode, query: string): boolean;
117
129
  //# sourceMappingURL=lb-apply.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lb-apply.d.ts","sourceRoot":"","sources":["../../hub/lb-apply.ts"],"names":[],"mappings":"AAyEA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAkC7B,mEAAmE;AACnE,MAAM,WAAW,OAAQ,SAAQ,OAAO;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AA4BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAEhD;AAsFD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAMjE;AA0CD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAGtD;AA4FD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,GAAG,EACR,OAAO,UAAQ,EACf,IAAI,C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