@loadbare/app 0.22.0 → 0.24.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 (45) hide show
  1. package/dist/build/assemble.d.ts.map +1 -1
  2. package/dist/build/assemble.js +28 -1
  3. package/dist/build/assemble.js.map +1 -1
  4. package/dist/build/build.d.ts +16 -0
  5. package/dist/build/build.d.ts.map +1 -1
  6. package/dist/build/build.js +77 -5
  7. package/dist/build/build.js.map +1 -1
  8. package/dist/core/lb-constants.d.ts +8 -5
  9. package/dist/core/lb-constants.d.ts.map +1 -1
  10. package/dist/core/lb-constants.js +20 -11
  11. package/dist/core/lb-constants.js.map +1 -1
  12. package/dist/core/lb-types.d.ts +19 -3
  13. package/dist/core/lb-types.d.ts.map +1 -1
  14. package/dist/core/lb-types.js +35 -5
  15. package/dist/core/lb-types.js.map +1 -1
  16. package/dist/hub/lb-apply.d.ts +18 -22
  17. package/dist/hub/lb-apply.d.ts.map +1 -1
  18. package/dist/hub/lb-apply.js +127 -57
  19. package/dist/hub/lb-apply.js.map +1 -1
  20. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  21. package/dist/hub/lb-hub.browser.js +15 -22
  22. package/dist/hub/lb-hub.browser.js.map +1 -1
  23. package/dist/server/lb-server.d.ts +2 -2
  24. package/dist/server/lb-server.d.ts.map +1 -1
  25. package/dist/server/lb-server.js +29 -9
  26. package/dist/server/lb-server.js.map +1 -1
  27. package/docs/comparison.md +11 -11
  28. package/docs/miswarts.md +7 -5
  29. package/docs/reference/chrome.md +42 -0
  30. package/docs/reference/custom-elements.md +9 -4
  31. package/docs/reference/data-binding.md +89 -67
  32. package/docs/reference/dev-server.md +10 -3
  33. package/docs/reference/names.md +10 -7
  34. package/docs/reference/page-files.md +8 -4
  35. package/docs/temp-proposals.md +251 -0
  36. package/docs/testing.md +3 -3
  37. package/package.json +1 -1
  38. package/skills/loadbare-app/SKILL.md +24 -12
  39. package/skills/loadbare-app/references/chrome.md +42 -0
  40. package/skills/loadbare-app/references/custom-elements.md +9 -4
  41. package/skills/loadbare-app/references/data-binding.md +89 -67
  42. package/skills/loadbare-app/references/dev-server.md +10 -3
  43. package/skills/loadbare-app/references/miswarts.md +7 -5
  44. package/skills/loadbare-app/references/names.md +10 -7
  45. package/skills/loadbare-app/references/page-files.md +8 -4
@@ -1 +1 @@
1
- {"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../build/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAyCH,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA6d/C,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,8EAA8E;IAC9E,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAgEtC"}
1
+ {"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../build/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4CH,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAigB/C,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,8EAA8E;IAC9E,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAgEtC"}
@@ -19,7 +19,7 @@
19
19
  import { readFile } from "node:fs/promises";
20
20
  import { addDefinitions, customElementTags, expandTree, } from "./expand.js";
21
21
  import { formatHtml } from "./format.js";
22
- import { AGGREGATES, ATTR_FILTER, ATTR_ORDER, ATTR_COLUMN, ATTR_COUNT, ATTR_GROUP, ATTR_PAGE, ATTR_PAGE_TITLE, ATTR_QUERY, ATTR_REQUEST, ATTR_SELECT, ATTR_SHOW, ATTR_URL_LINK, ATTR_URL_PUSH, ATTR_URL_PARM, ATTR_URL_UNKNOWN, CHOICES_QUERY, HUB_QUERY, DEVELOPER_ATTRIBUTES, HUB_TAG_NAME, LB_COMMAND_PREFIX, LB_COMMANDS, LB_RESERVED_PREFIX, REQUEST_ROW_DELETE, REQUEST_ROW_INSERT, REQUEST_ROW_UPDATE, SHOW_NOT, URL_QUERY, } from "../core/lb-constants.js";
22
+ import { AGGREGATES, ATTR_FILTER, ATTR_MANUAL, ATTR_ORDER, MANUAL_FILTER, MANUAL_ORDER, ATTR_COLUMN, ATTR_COUNT, ATTR_GROUP, ATTR_PAGE, ATTR_PAGE_TITLE, ATTR_QUERY, ATTR_REQUEST, ATTR_SELECT, ATTR_SHOW, ATTR_URL_LINK, ATTR_URL_PUSH, ATTR_URL_PARM, ATTR_URL_UNKNOWN, CHOICES_QUERY, HUB_QUERY, DEVELOPER_ATTRIBUTES, HUB_TAG_NAME, LB_COMMAND_PREFIX, LB_COMMANDS, LB_RESERVED_PREFIX, REQUEST_ROW_DELETE, REQUEST_ROW_INSERT, REQUEST_ROW_UPDATE, SHOW_NOT, URL_QUERY, } from "../core/lb-constants.js";
23
23
  import { isRowRequest } from "../core/lb-types.js";
24
24
  /**
25
25
  * The hub is one element, and it swaps each page into the one `<main>`
@@ -208,6 +208,19 @@ function walkMarkup(node, scope, names, problems) {
208
208
  problems.push(`<${tag}> carries ${ATTR_URL_PUSH} and no ${ATTR_REQUEST}; it goes ` +
209
209
  `on an element with ${ATTR_REQUEST}`);
210
210
  }
211
+ // A column holds one value, except a query parm, which a URL may repeat.
212
+ // The column belongs to the query around the element, even one that
213
+ // names a query of its own, as a picker does.
214
+ if (el.hasAttribute(ATTR_COLUMN) &&
215
+ (el.hasAttribute("multiple") ||
216
+ (tag === "input" &&
217
+ el.getAttribute("type") === "checkbox" &&
218
+ el.hasAttribute("value"))) &&
219
+ scope?.query !== URL_QUERY) {
220
+ problems.push(`<${tag}> carries ${ATTR_COLUMN} and holds several values; only a ` +
221
+ `column of ${URL_QUERY} holds several, so it goes inside ` +
222
+ `${ATTR_QUERY}="${URL_QUERY}"`);
223
+ }
211
224
  // A selector is a checkbox in a live row, and selects that row. It is no
212
225
  // column, and commits nothing of its own.
213
226
  if (el.hasAttribute(ATTR_SELECT)) {
@@ -276,6 +289,20 @@ function walkMarkup(node, scope, names, problems) {
276
289
  problems.push(`<${tag}> carries ${name} naming no column`);
277
290
  }
278
291
  }
292
+ const manual = el.getAttribute(ATTR_MANUAL);
293
+ if (manual !== null) {
294
+ const sides = manual.trim().split(/\s+/).filter((side) => side !== "");
295
+ const known = [MANUAL_ORDER, MANUAL_FILTER];
296
+ if (!el.hasAttribute(ATTR_QUERY)) {
297
+ problems.push(`<${tag}> carries ${ATTR_MANUAL}; it goes on the element carrying ` +
298
+ `${ATTR_QUERY}`);
299
+ }
300
+ else if (sides.length === 0 ||
301
+ sides.some((side) => !known.includes(side))) {
302
+ problems.push(`<${tag}> carries ${ATTR_MANUAL}="${manual}"; it names ` +
303
+ `${MANUAL_ORDER}, ${MANUAL_FILTER} or both, separated by a space`);
304
+ }
305
+ }
279
306
  // Judged by the scope around the element, not one the element carries:
280
307
  // its condition is a column of the row around it. With no lb-query
281
308
  // around it at all, nothing ever lands on it, and the element never
@@ -1 +1 @@
1
- {"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../build/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,GAEX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,UAAkB,EAAE,IAAgB;IACvD,MAAM,KAAK,GAAG,cAAc,UAAU,GAAG,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QAC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M,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;AACzD,CAAC","sourcesContent":["/**\n * Assembling one document out of a chrome file and a set of pages.\n *\n * Every `.html` file in play — the chrome and each page — goes through the\n * same `expand()` (see build/expand.ts) against the same definitions: the\n * built-in widgets and whatever definitions were found in the caller's own\n * source tree. `expand()` only ever sees a fragment, so the chrome's own is\n * the text between its `<body>` tags; a page's is the whole file. A page's\n * expanded host is wrapped in `<template lb-page=\"<name>\">` and, together\n * with the chrome's own expanded body content, spliced back into the\n * chrome's `<body>`. The result is the one document a server has to serve\n * for every route — see docs/tutorials/000-getting-started.md and\n * docs/reference/builder.md.\n *\n * Every path here is a parameter, resolved once by build/locations.ts — this\n * module never reconstructs one of its own, and never reads a directory\n * looking for pages or widgets; it is handed exactly which files those are.\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport {\n addDefinitions,\n customElementTags,\n expandTree,\n type Definitions,\n} from \"./expand.js\";\nimport { formatHtml } from \"./format.js\";\nimport {\n AGGREGATES,\n ATTR_FILTER,\n ATTR_ORDER,\n ATTR_COLUMN,\n ATTR_COUNT,\n ATTR_GROUP,\n ATTR_PAGE,\n ATTR_PAGE_TITLE,\n ATTR_QUERY,\n ATTR_REQUEST,\n ATTR_SELECT,\n ATTR_SHOW,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_PARM,\n ATTR_URL_UNKNOWN,\n CHOICES_QUERY,\n HUB_QUERY,\n DEVELOPER_ATTRIBUTES,\n HUB_TAG_NAME,\n LB_COMMAND_PREFIX,\n LB_COMMANDS,\n LB_RESERVED_PREFIX,\n REQUEST_ROW_DELETE,\n REQUEST_ROW_INSERT,\n REQUEST_ROW_UPDATE,\n SHOW_NOT,\n URL_QUERY,\n} from \"../core/lb-constants.js\";\nimport { isRowRequest } from \"../core/lb-types.js\";\nimport type { Declared, DeclaredPages } from \"./declared.js\";\nimport type { PageFile } from \"./locations.js\";\nimport type { OriginScan } from \"./origins.js\";\n\n/**\n * The hub is one element, and it swaps each page into the one `<main>`\n * inside it (hub/lb-hub.browser.ts), so the chrome holds exactly one of each,\n * the `<main>` inside the hub and empty, since whatever it held would be\n * replaced by the first page. A page is swapped into that `<main>`, so it\n * carries neither.\n */\nfunction checkChrome(chromeFile: string, body: ParentNode): void {\n const where = `assemble: '${chromeFile}'`;\n const hubs = body.querySelectorAll(HUB_TAG_NAME).length;\n if (hubs !== 1) {\n throw new Error(\n `${where} has ${hubs} <${HUB_TAG_NAME}>; it needs exactly one`,\n );\n }\n const mains = body.querySelectorAll(\"main\");\n if (mains.length !== 1) {\n throw new Error(\n `${where} has ${mains.length} <main>; it needs exactly one`,\n );\n }\n const main = mains[0]!;\n if (!main.closest(HUB_TAG_NAME)) {\n throw new Error(\n `${where} has its <main> outside <${HUB_TAG_NAME}>, where the hub cannot reach it`,\n );\n }\n if (main.children.length > 0 || main.textContent!.trim() !== \"\") {\n throw new Error(\n `${where} has content in its <main>, which the first page replaces; it goes empty`,\n );\n }\n}\n\n/** A page lands inside the chrome's `<main>`, so it brings no second one and no hub. */\nfunction checkPage(file: string, root: ParentNode): void {\n for (const tag of [HUB_TAG_NAME, \"main\"]) {\n if (root.querySelector(tag)) {\n throw new Error(\n `assemble: '${file}' carries a <${tag}>, which belongs to the chrome alone`,\n );\n }\n }\n}\n\n/**\n * The hub calls showModal() on the `<dialog>` carrying lb-url-unknown\n * (hub/lb-hub.browser.ts), and looks for it inside itself, as it does for\n * everything else it acts on. A dialog elsewhere in the body would never open\n * and would say nothing about why.\n */\nfunction checkUnknownPageDialog(chromeFile: string, body: ParentNode): void {\n const el = body.querySelector(`[${ATTR_URL_UNKNOWN}]`);\n if (!el) return;\n if (!el.closest(HUB_TAG_NAME)) {\n throw new Error(\n `assemble: '${chromeFile}' declares ${ATTR_URL_UNKNOWN} outside ` +\n `<${HUB_TAG_NAME}>, where the hub cannot reach it`,\n );\n }\n}\n\n/**\n * Where the markup stands while the check walks it: inside which `lb-query`,\n * and whether there is a row there to take a value from. Inside a row\n * template there always is. Inside an `lb-query` outside one, there is when\n * the query is of kind `row`, which only the server knows.\n */\ninterface Scope {\n query: string;\n row: boolean | \"unknown\";\n}\n\n/** The queries the hub serves, which every page and the chrome may name. */\nconst HUB_QUERIES: readonly string[] = [URL_QUERY, CHOICES_QUERY, HUB_QUERY];\n\n/** The `Crud` key each request Loadbare provides runs. */\nconst CRUD_KEYS: Record<string, string> = {\n [REQUEST_ROW_INSERT]: \"rowInsert\",\n [REQUEST_ROW_UPDATE]: \"rowUpdate\",\n [REQUEST_ROW_DELETE]: \"rowDelete\",\n};\n\n/**\n * What a file's names are checked against: a page's declarations, or `null`\n * for the chrome, which belongs to no page and so names only what the hub\n * serves.\n */\ntype Names = { declared: Declared | null };\n\n/**\n * An `lb-query` or `lb-request` naming nothing the page declares would be\n * found only on the first round trip, as a server warning and an empty\n * answer, so a typo would build cleanly.\n *\n * A request Loadbare provides is for the query of what it gathers: a form's\n * own when the form carries `lb-query`, otherwise the nearest around the\n * element, as the hub decides it (hub/lb-hub.browser.ts). With no query\n * around it, the hub reports it in the browser.\n */\nfunction checkNames(\n el: Element,\n scope: Scope | null,\n names: Names,\n problems: string[],\n): void {\n const tag = el.localName;\n const { declared } = names;\n\n const query = el.getAttribute(ATTR_QUERY);\n if (query !== null && !HUB_QUERIES.includes(query)) {\n if (declared === null) {\n problems.push(\n `<${tag}> carries ${ATTR_QUERY}=\"${query}\"; the chrome belongs to ` +\n `no page, and names only ${HUB_QUERIES.slice(0, -1).join(\", \")} and ${HUB_QUERIES.at(-1)}`,\n );\n } else if (!declared.queries.has(query)) {\n problems.push(\n `<${tag}> carries ${ATTR_QUERY}=\"${query}\", which the page's ` +\n `queries do not declare`,\n );\n }\n }\n\n const request = el.getAttribute(ATTR_REQUEST);\n if (!request) return;\n if (isRowRequest(request)) {\n const target =\n tag === \"form\" && query !== null ? query : (scope?.query ?? null);\n if (target === null) return;\n if (target === HUB_QUERY) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}'; ` +\n `the hub's own state is written by the hub alone`,\n );\n return;\n }\n if (HUB_QUERIES.includes(target)) {\n if (request !== REQUEST_ROW_UPDATE) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}'; ` +\n `the hub answers only ${REQUEST_ROW_UPDATE} for it`,\n );\n }\n return;\n }\n // A query the page does not declare is reported once, where it is named.\n if (declared === null || !declared.queries.has(target)) return;\n const key = CRUD_KEYS[request]!;\n if (!declared.crud.get(target)?.has(key)) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}', ` +\n `whose crud entry the page does not declare with ${key}`,\n );\n }\n } else if (request.startsWith(LB_RESERVED_PREFIX)) {\n // Reported by walkMarkup as naming no request Loadbare provides.\n } else if (declared === null) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\"; the chrome belongs ` +\n `to no page, and sends no declared request`,\n );\n } else if (!declared.handlers.has(request)) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\", which the page's ` +\n `handlers do not declare`,\n );\n }\n}\n\n/**\n * The markup, checked once against the finished document rather than\n * discovered one console error at a time in a browser.\n *\n * Every rule here is a fact the markup states about itself. The developer\n * writes `lb-*` attributes in markup, and script never assigns them, which is\n * what makes checking the markup sound. See docs/reference/data-binding.md.\n *\n * A `<template>`'s children are walked in the scope that encloses the\n * template, because a row template's clones land in the element around it.\n */\nfunction walkMarkup(\n node: ParentNode,\n scope: Scope | null,\n names: Names | null,\n problems: string[],\n): void {\n for (const el of node.children) {\n const tag = el.localName;\n let here = scope;\n const query = el.getAttribute(ATTR_QUERY);\n if (query !== null) here = { query, row: \"unknown\" };\n if (names) checkNames(el, scope, names, problems);\n\n for (const { name } of el.attributes) {\n if (\n name.startsWith(LB_RESERVED_PREFIX) &&\n !(DEVELOPER_ATTRIBUTES as readonly string[]).includes(name)\n ) {\n problems.push(\n `<${tag}> carries ${name}, which is not an attribute a developer ` +\n `writes`,\n );\n }\n }\n\n const request = el.getAttribute(ATTR_REQUEST);\n if (\n request !== null &&\n request.startsWith(LB_RESERVED_PREFIX) &&\n !isRowRequest(request)\n ) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\", which begins with ` +\n `'${LB_RESERVED_PREFIX}' but names no request Loadbare provides`,\n );\n }\n if (el.hasAttribute(ATTR_URL_LINK) && tag !== \"a\") {\n problems.push(`<${tag}> carries ${ATTR_URL_LINK}; it goes on an <a>`);\n }\n // A link's parms are columns of the row around it, and only a link the\n // hub handles takes them: the parms are the application's own URL.\n const parms = el.getAttribute(ATTR_URL_PARM);\n if (parms !== null) {\n const columns = parms.split(\",\").map((column) => column.trim());\n if (tag !== \"a\" || !el.hasAttribute(ATTR_URL_LINK)) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}; it goes on an <a> carrying ` +\n `${ATTR_URL_LINK}`,\n );\n } else if (columns.some((column) => column === \"\")) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\", which names no ` +\n `column between two commas or at either end`,\n );\n } else if (columns.some((column) => /\\s/.test(column))) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\"; columns are ` +\n `separated by commas`,\n );\n } else if (columns.some((c) => c.startsWith(LB_RESERVED_PREFIX))) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\"; a parm beginning ` +\n `'${LB_RESERVED_PREFIX}' is the hub's own`,\n );\n } else if (scope === null || scope.row === false) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\" with no row around ` +\n `it to take the values from`,\n );\n }\n }\n if (el.hasAttribute(ATTR_URL_PUSH) && request === null) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PUSH} and no ${ATTR_REQUEST}; it goes ` +\n `on an element with ${ATTR_REQUEST}`,\n );\n }\n // A selector is a checkbox in a live row, and selects that row. It is no\n // column, and commits nothing of its own.\n if (el.hasAttribute(ATTR_SELECT)) {\n if (tag !== \"input\" || el.getAttribute(\"type\") !== \"checkbox\") {\n problems.push(\n `<${tag}> carries ${ATTR_SELECT}; it goes on an ` +\n `<input type=\"checkbox\">`,\n );\n } else if (scope?.row !== true) {\n problems.push(\n `<input> carries ${ATTR_SELECT} outside a row template; it ` +\n `selects the row it sits in`,\n );\n }\n for (const name of [ATTR_COLUMN, ATTR_REQUEST]) {\n if (el.hasAttribute(name)) {\n problems.push(\n `<${tag}> carries ${ATTR_SELECT} and ${name}; a selector is no ` +\n `column and sends nothing`,\n );\n }\n }\n }\n // HTML's own command attribute, whose `--lb-` values are Loadbare's.\n const command = el.getAttribute(\"command\");\n if (command !== null && command.startsWith(LB_COMMAND_PREFIX)) {\n if (!(LB_COMMANDS as readonly string[]).includes(command)) {\n problems.push(\n `<${tag}> carries command=\"${command}\", which begins with ` +\n `'${LB_COMMAND_PREFIX}' but names no command Loadbare provides`,\n );\n } else if (!el.hasAttribute(\"commandfor\")) {\n problems.push(\n `<${tag}> carries command=\"${command}\" and no commandfor; it ` +\n `names the element the command is for`,\n );\n }\n }\n if (el.hasAttribute(ATTR_URL_UNKNOWN) && tag !== \"dialog\") {\n problems.push(\n `<${tag}> carries ${ATTR_URL_UNKNOWN}; it goes on a <dialog>`,\n );\n }\n\n // A group is a template holding a heading and the template its\n // contents go in; an aggregate is set on an element, from the column it\n // names.\n if (el.hasAttribute(ATTR_GROUP)) {\n if (tag !== \"template\") {\n problems.push(\n `<${tag}> carries ${ATTR_GROUP}; it goes on a <template>`,\n );\n } else if (\n !(el as HTMLTemplateElement).content.querySelector(\n `template:not([${ATTR_SHOW}])`,\n )\n ) {\n problems.push(\n `a <template ${ATTR_GROUP}> holds no <template> for its contents`,\n );\n }\n }\n for (const name of AGGREGATES) {\n if (!el.hasAttribute(name)) continue;\n if (tag === \"template\") {\n problems.push(`a <template> carries ${name}; it goes on an element`);\n } else if (name !== ATTR_COUNT && !el.getAttribute(name)) {\n problems.push(`<${tag}> carries ${name} naming no column`);\n }\n }\n\n // The user's order and filter for the rows an element holds, each read\n // from a column of lb-choices it names.\n for (const name of [ATTR_ORDER, ATTR_FILTER]) {\n const value = el.getAttribute(name);\n if (value === null) continue;\n if (!el.hasAttribute(ATTR_QUERY)) {\n problems.push(\n `<${tag}> carries ${name}; it goes on the element carrying ` +\n `${ATTR_QUERY}`,\n );\n } else if (value.trim() === \"\") {\n problems.push(`<${tag}> carries ${name} naming no column`);\n }\n }\n\n // Judged by the scope around the element, not one the element carries:\n // its condition is a column of the row around it. With no lb-query\n // around it at all, nothing ever lands on it, and the element never\n // shows.\n const show = el.getAttribute(ATTR_SHOW);\n if (show !== null) {\n if (tag === \"template\") {\n problems.push(\n `a <template> carries ${ATTR_SHOW}=\"${show}\"; write it on the ` +\n `element it shows, and Loadbare supplies the template`,\n );\n } else if (scope === null || scope.row === false) {\n problems.push(\n `<${tag}> carries ${ATTR_SHOW}=\"${show}\" with no row around it ` +\n `to take the value from`,\n );\n } else if (show === SHOW_NOT || show.startsWith(SHOW_NOT + SHOW_NOT)) {\n problems.push(\n `<${tag}> carries ${ATTR_SHOW}=\"${show}\"; write one ` +\n `${SHOW_NOT} and then the column it reverses`,\n );\n }\n }\n\n walkMarkup(el, here, names, problems);\n // By tag name rather than by instanceof: template content belongs to a\n // document with no window, so the constructor is not reachable from the\n // node.\n if (tag === \"template\") {\n const content = (el as HTMLTemplateElement).content;\n const isRowTemplate =\n scope !== null && !!el.parentElement?.closest(`[${ATTR_QUERY}]`);\n if (isRowTemplate) {\n for (const root of content.children) {\n if (root.hasAttribute(ATTR_SHOW)) {\n problems.push(\n `<${root.localName}> is a row template's root and carries ` +\n `${ATTR_SHOW}; a row that should not show is left out by ` +\n `the query`,\n );\n }\n }\n }\n walkMarkup(\n content,\n isRowTemplate ? { query: scope!.query, row: true } : here,\n names,\n problems,\n );\n }\n }\n}\n\n/**\n * Ship every `lb-show` element already inside the template the hub keeps an\n * absent branch in, so nothing conditional shows until its value says so.\n * A page is in the document before its data arrives, and a value that has not\n * arrived is no value.\n *\n * Elements are collected before any is moved, and a wrapped element is still\n * reached once its outer one has gone into a template, because the references\n * are held.\n */\nfunction wrapShown(holder: HTMLTemplateElement): void {\n const doc = holder.ownerDocument;\n const shown: Element[] = [];\n const collect = (root: ParentNode): void => {\n shown.push(...root.querySelectorAll(`[${ATTR_SHOW}]`));\n for (const t of root.querySelectorAll(\"template\")) {\n collect((t as HTMLTemplateElement).content);\n }\n };\n collect(holder.content);\n for (const el of shown) {\n const parked = doc.createElement(\"template\");\n parked.setAttribute(ATTR_SHOW, el.getAttribute(ATTR_SHOW)!);\n el.replaceWith(parked);\n parked.content.append(el);\n }\n}\n\n/**\n * Expand one file's markup, naming the file if expansion refuses it.\n *\n * What comes back is the tree the browser will build, so every pass after\n * this reads and changes it in place, and it is serialized once, when it\n * ships.\n */\nfunction expandFile(\n file: string,\n source: string,\n defs: Definitions,\n): HTMLTemplateElement {\n try {\n return expandTree(source, defs);\n } catch (e) {\n throw new Error(`assemble: '${file}': ${(e as Error).message}`);\n }\n}\n\n/** Check one expanded fragment, and name the file if anything is wrong. */\nfunction checkMarkup(\n file: string,\n root: ParentNode,\n names: Names | null,\n): void {\n const problems: string[] = [];\n walkMarkup(root, null, names, problems);\n if (problems.length > 0) {\n throw new Error(`assemble: '${file}' markup:\\n ` + problems.join(`\\n `));\n }\n}\n\n/**\n * A page file's `<title>` names the page. It is lifted out, since a page is\n * a fragment inside `<main>` and a `<title>` belongs in a document's head,\n * and its text content is stamped on the page as ATTR_PAGE_TITLE.\n */\nfunction liftTitle(holder: HTMLTemplateElement): string | null {\n const title = holder.content.querySelector(\"title\");\n if (!title) return null;\n const text = title.textContent?.trim() ?? \"\";\n title.remove();\n return text;\n}\n\n/** An attribute value, escaped for a double-quoted attribute. */\nfunction attributeValue(text: string): string {\n return text.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\");\n}\n\nexport interface AssembleOptions {\n chromeFile: string;\n pages: PageFile[];\n /** Every origin, already scanned, in cascade order — see build/origins.ts. */\n scans: OriginScan[];\n /**\n * What each page declares — see build/declared.ts. Without it, the names\n * `lb-query` and `lb-request` carry are not checked.\n */\n declared?: DeclaredPages;\n}\n\nexport interface Assembled {\n html: string;\n /** Every custom element tag left in the document once expansion is done. */\n usedTags: Set<string>;\n}\n\nexport async function assemble({\n chromeFile,\n pages,\n scans,\n declared,\n}: AssembleOptions): Promise<Assembled> {\n // One layer per origin, in order, so a later origin's definition overrides\n // an earlier one's for the same tag. Each layer is checked for cycles as it\n // lands, against everything merged so far.\n let defs: Definitions = {};\n for (const scan of scans) {\n defs = await addDefinitions(defs, scan.definitions);\n }\n\n // Tags are collected from each tree as it goes by. What ships is these\n // trees and the chrome around its body, which is collected on its own.\n const usedTags = new Set<string>();\n const templates: string[] = [];\n for (const { name, file } of pages) {\n const authored = await readFile(file, \"utf-8\");\n const host = expandFile(file, authored, defs);\n const title = liftTitle(host);\n checkPage(file, host.content);\n checkMarkup(\n file,\n host.content,\n declared ? { declared: declared.get(name)! } : null,\n );\n wrapShown(host);\n customElementTags(host.content, usedTags);\n const titled =\n title === null ? \"\" : ` ${ATTR_PAGE_TITLE}=\"${attributeValue(title)}\"`;\n templates.push(\n `<template ${ATTR_PAGE}=\"${name}\"${titled}>${host.innerHTML}</template>`,\n );\n }\n\n let chromeSource: string;\n try {\n chromeSource = await readFile(chromeFile, \"utf-8\");\n } catch {\n throw new Error(`assemble: no chrome file at '${chromeFile}'`);\n }\n\n const body = /<body([^>]*)>([\\s\\S]*)<\\/body>/i.exec(chromeSource);\n if (!body) {\n throw new Error(\n `assemble: '${chromeFile}' has no <body>...</body> to expand`,\n );\n }\n const [whole, bodyAttrs, bodyContent] = body;\n const chromeBody = expandFile(chromeFile, bodyContent!, defs);\n checkChrome(chromeFile, chromeBody.content);\n checkUnknownPageDialog(chromeFile, chromeBody.content);\n checkMarkup(\n chromeFile,\n chromeBody.content,\n declared ? { declared: null } : null,\n );\n wrapShown(chromeBody);\n customElementTags(chromeBody.content, usedTags);\n customElementTags(chromeSource.replace(whole!, \"\"), usedTags);\n const withPages = chromeSource.replace(\n whole!,\n () =>\n `<body${bodyAttrs}>${chromeBody.innerHTML}\\n${templates.join(\"\\n\")}\\n</body>`,\n );\n\n return { html: await formatHtml(withPages), usedTags };\n}\n"]}
1
+ {"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../build/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,GAEX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,UAAkB,EAAE,IAAgB;IACvD,MAAM,KAAK,GAAG,cAAc,UAAU,GAAG,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,QAAQ,IAAI,KAAK,YAAY,yBAAyB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M,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;AACzD,CAAC","sourcesContent":["/**\n * Assembling one document out of a chrome file and a set of pages.\n *\n * Every `.html` file in play — the chrome and each page — goes through the\n * same `expand()` (see build/expand.ts) against the same definitions: the\n * built-in widgets and whatever definitions were found in the caller's own\n * source tree. `expand()` only ever sees a fragment, so the chrome's own is\n * the text between its `<body>` tags; a page's is the whole file. A page's\n * expanded host is wrapped in `<template lb-page=\"<name>\">` and, together\n * with the chrome's own expanded body content, spliced back into the\n * chrome's `<body>`. The result is the one document a server has to serve\n * for every route — see docs/tutorials/000-getting-started.md and\n * docs/reference/builder.md.\n *\n * Every path here is a parameter, resolved once by build/locations.ts — this\n * module never reconstructs one of its own, and never reads a directory\n * looking for pages or widgets; it is handed exactly which files those are.\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport {\n addDefinitions,\n customElementTags,\n expandTree,\n type Definitions,\n} from \"./expand.js\";\nimport { formatHtml } from \"./format.js\";\nimport {\n AGGREGATES,\n ATTR_FILTER,\n ATTR_MANUAL,\n ATTR_ORDER,\n MANUAL_FILTER,\n MANUAL_ORDER,\n ATTR_COLUMN,\n ATTR_COUNT,\n ATTR_GROUP,\n ATTR_PAGE,\n ATTR_PAGE_TITLE,\n ATTR_QUERY,\n ATTR_REQUEST,\n ATTR_SELECT,\n ATTR_SHOW,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_PARM,\n ATTR_URL_UNKNOWN,\n CHOICES_QUERY,\n HUB_QUERY,\n DEVELOPER_ATTRIBUTES,\n HUB_TAG_NAME,\n LB_COMMAND_PREFIX,\n LB_COMMANDS,\n LB_RESERVED_PREFIX,\n REQUEST_ROW_DELETE,\n REQUEST_ROW_INSERT,\n REQUEST_ROW_UPDATE,\n SHOW_NOT,\n URL_QUERY,\n} from \"../core/lb-constants.js\";\nimport { isRowRequest } from \"../core/lb-types.js\";\nimport type { Declared, DeclaredPages } from \"./declared.js\";\nimport type { PageFile } from \"./locations.js\";\nimport type { OriginScan } from \"./origins.js\";\n\n/**\n * The hub is one element, and it swaps each page into the one `<main>`\n * inside it (hub/lb-hub.browser.ts), so the chrome holds exactly one of each,\n * the `<main>` inside the hub and empty, since whatever it held would be\n * replaced by the first page. A page is swapped into that `<main>`, so it\n * carries neither.\n */\nfunction checkChrome(chromeFile: string, body: ParentNode): void {\n const where = `assemble: '${chromeFile}'`;\n const hubs = body.querySelectorAll(HUB_TAG_NAME).length;\n if (hubs !== 1) {\n throw new Error(\n `${where} has ${hubs} <${HUB_TAG_NAME}>; it needs exactly one`,\n );\n }\n const mains = body.querySelectorAll(\"main\");\n if (mains.length !== 1) {\n throw new Error(\n `${where} has ${mains.length} <main>; it needs exactly one`,\n );\n }\n const main = mains[0]!;\n if (!main.closest(HUB_TAG_NAME)) {\n throw new Error(\n `${where} has its <main> outside <${HUB_TAG_NAME}>, where the hub cannot reach it`,\n );\n }\n if (main.children.length > 0 || main.textContent!.trim() !== \"\") {\n throw new Error(\n `${where} has content in its <main>, which the first page replaces; it goes empty`,\n );\n }\n}\n\n/** A page lands inside the chrome's `<main>`, so it brings no second one and no hub. */\nfunction checkPage(file: string, root: ParentNode): void {\n for (const tag of [HUB_TAG_NAME, \"main\"]) {\n if (root.querySelector(tag)) {\n throw new Error(\n `assemble: '${file}' carries a <${tag}>, which belongs to the chrome alone`,\n );\n }\n }\n}\n\n/**\n * The hub calls showModal() on the `<dialog>` carrying lb-url-unknown\n * (hub/lb-hub.browser.ts), and looks for it inside itself, as it does for\n * everything else it acts on. A dialog elsewhere in the body would never open\n * and would say nothing about why.\n */\nfunction checkUnknownPageDialog(chromeFile: string, body: ParentNode): void {\n const el = body.querySelector(`[${ATTR_URL_UNKNOWN}]`);\n if (!el) return;\n if (!el.closest(HUB_TAG_NAME)) {\n throw new Error(\n `assemble: '${chromeFile}' declares ${ATTR_URL_UNKNOWN} outside ` +\n `<${HUB_TAG_NAME}>, where the hub cannot reach it`,\n );\n }\n}\n\n/**\n * Where the markup stands while the check walks it: inside which `lb-query`,\n * and whether there is a row there to take a value from. Inside a row\n * template there always is. Inside an `lb-query` outside one, there is when\n * the query is of kind `row`, which only the server knows.\n */\ninterface Scope {\n query: string;\n row: boolean | \"unknown\";\n}\n\n/** The queries the hub serves, which every page and the chrome may name. */\nconst HUB_QUERIES: readonly string[] = [URL_QUERY, CHOICES_QUERY, HUB_QUERY];\n\n/** The `Crud` key each request Loadbare provides runs. */\nconst CRUD_KEYS: Record<string, string> = {\n [REQUEST_ROW_INSERT]: \"rowInsert\",\n [REQUEST_ROW_UPDATE]: \"rowUpdate\",\n [REQUEST_ROW_DELETE]: \"rowDelete\",\n};\n\n/**\n * What a file's names are checked against: a page's declarations, or `null`\n * for the chrome, which belongs to no page and so names only what the hub\n * serves.\n */\ntype Names = { declared: Declared | null };\n\n/**\n * An `lb-query` or `lb-request` naming nothing the page declares would be\n * found only on the first round trip, as a server warning and an empty\n * answer, so a typo would build cleanly.\n *\n * A request Loadbare provides is for the query of what it gathers: a form's\n * own when the form carries `lb-query`, otherwise the nearest around the\n * element, as the hub decides it (hub/lb-hub.browser.ts). With no query\n * around it, the hub reports it in the browser.\n */\nfunction checkNames(\n el: Element,\n scope: Scope | null,\n names: Names,\n problems: string[],\n): void {\n const tag = el.localName;\n const { declared } = names;\n\n const query = el.getAttribute(ATTR_QUERY);\n if (query !== null && !HUB_QUERIES.includes(query)) {\n if (declared === null) {\n problems.push(\n `<${tag}> carries ${ATTR_QUERY}=\"${query}\"; the chrome belongs to ` +\n `no page, and names only ${HUB_QUERIES.slice(0, -1).join(\", \")} and ${HUB_QUERIES.at(-1)}`,\n );\n } else if (!declared.queries.has(query)) {\n problems.push(\n `<${tag}> carries ${ATTR_QUERY}=\"${query}\", which the page's ` +\n `queries do not declare`,\n );\n }\n }\n\n const request = el.getAttribute(ATTR_REQUEST);\n if (!request) return;\n if (isRowRequest(request)) {\n const target =\n tag === \"form\" && query !== null ? query : (scope?.query ?? null);\n if (target === null) return;\n if (target === HUB_QUERY) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}'; ` +\n `the hub's own state is written by the hub alone`,\n );\n return;\n }\n if (HUB_QUERIES.includes(target)) {\n if (request !== REQUEST_ROW_UPDATE) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}'; ` +\n `the hub answers only ${REQUEST_ROW_UPDATE} for it`,\n );\n }\n return;\n }\n // A query the page does not declare is reported once, where it is named.\n if (declared === null || !declared.queries.has(target)) return;\n const key = CRUD_KEYS[request]!;\n if (!declared.crud.get(target)?.has(key)) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\" for '${target}', ` +\n `whose crud entry the page does not declare with ${key}`,\n );\n }\n } else if (request.startsWith(LB_RESERVED_PREFIX)) {\n // Reported by walkMarkup as naming no request Loadbare provides.\n } else if (declared === null) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\"; the chrome belongs ` +\n `to no page, and sends no declared request`,\n );\n } else if (!declared.handlers.has(request)) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\", which the page's ` +\n `handlers do not declare`,\n );\n }\n}\n\n/**\n * The markup, checked once against the finished document rather than\n * discovered one console error at a time in a browser.\n *\n * Every rule here is a fact the markup states about itself. The developer\n * writes `lb-*` attributes in markup, and script never assigns them, which is\n * what makes checking the markup sound. See docs/reference/data-binding.md.\n *\n * A `<template>`'s children are walked in the scope that encloses the\n * template, because a row template's clones land in the element around it.\n */\nfunction walkMarkup(\n node: ParentNode,\n scope: Scope | null,\n names: Names | null,\n problems: string[],\n): void {\n for (const el of node.children) {\n const tag = el.localName;\n let here = scope;\n const query = el.getAttribute(ATTR_QUERY);\n if (query !== null) here = { query, row: \"unknown\" };\n if (names) checkNames(el, scope, names, problems);\n\n for (const { name } of el.attributes) {\n if (\n name.startsWith(LB_RESERVED_PREFIX) &&\n !(DEVELOPER_ATTRIBUTES as readonly string[]).includes(name)\n ) {\n problems.push(\n `<${tag}> carries ${name}, which is not an attribute a developer ` +\n `writes`,\n );\n }\n }\n\n const request = el.getAttribute(ATTR_REQUEST);\n if (\n request !== null &&\n request.startsWith(LB_RESERVED_PREFIX) &&\n !isRowRequest(request)\n ) {\n problems.push(\n `<${tag}> carries ${ATTR_REQUEST}=\"${request}\", which begins with ` +\n `'${LB_RESERVED_PREFIX}' but names no request Loadbare provides`,\n );\n }\n if (el.hasAttribute(ATTR_URL_LINK) && tag !== \"a\") {\n problems.push(`<${tag}> carries ${ATTR_URL_LINK}; it goes on an <a>`);\n }\n // A link's parms are columns of the row around it, and only a link the\n // hub handles takes them: the parms are the application's own URL.\n const parms = el.getAttribute(ATTR_URL_PARM);\n if (parms !== null) {\n const columns = parms.split(\",\").map((column) => column.trim());\n if (tag !== \"a\" || !el.hasAttribute(ATTR_URL_LINK)) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}; it goes on an <a> carrying ` +\n `${ATTR_URL_LINK}`,\n );\n } else if (columns.some((column) => column === \"\")) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\", which names no ` +\n `column between two commas or at either end`,\n );\n } else if (columns.some((column) => /\\s/.test(column))) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\"; columns are ` +\n `separated by commas`,\n );\n } else if (columns.some((c) => c.startsWith(LB_RESERVED_PREFIX))) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\"; a parm beginning ` +\n `'${LB_RESERVED_PREFIX}' is the hub's own`,\n );\n } else if (scope === null || scope.row === false) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PARM}=\"${parms}\" with no row around ` +\n `it to take the values from`,\n );\n }\n }\n if (el.hasAttribute(ATTR_URL_PUSH) && request === null) {\n problems.push(\n `<${tag}> carries ${ATTR_URL_PUSH} and no ${ATTR_REQUEST}; it goes ` +\n `on an element with ${ATTR_REQUEST}`,\n );\n }\n // A column holds one value, except a query parm, which a URL may repeat.\n // The column belongs to the query around the element, even one that\n // names a query of its own, as a picker does.\n if (\n el.hasAttribute(ATTR_COLUMN) &&\n (el.hasAttribute(\"multiple\") ||\n (tag === \"input\" &&\n el.getAttribute(\"type\") === \"checkbox\" &&\n el.hasAttribute(\"value\"))) &&\n scope?.query !== URL_QUERY\n ) {\n problems.push(\n `<${tag}> carries ${ATTR_COLUMN} and holds several values; only a ` +\n `column of ${URL_QUERY} holds several, so it goes inside ` +\n `${ATTR_QUERY}=\"${URL_QUERY}\"`,\n );\n }\n // A selector is a checkbox in a live row, and selects that row. It is no\n // column, and commits nothing of its own.\n if (el.hasAttribute(ATTR_SELECT)) {\n if (tag !== \"input\" || el.getAttribute(\"type\") !== \"checkbox\") {\n problems.push(\n `<${tag}> carries ${ATTR_SELECT}; it goes on an ` +\n `<input type=\"checkbox\">`,\n );\n } else if (scope?.row !== true) {\n problems.push(\n `<input> carries ${ATTR_SELECT} outside a row template; it ` +\n `selects the row it sits in`,\n );\n }\n for (const name of [ATTR_COLUMN, ATTR_REQUEST]) {\n if (el.hasAttribute(name)) {\n problems.push(\n `<${tag}> carries ${ATTR_SELECT} and ${name}; a selector is no ` +\n `column and sends nothing`,\n );\n }\n }\n }\n // HTML's own command attribute, whose `--lb-` values are Loadbare's.\n const command = el.getAttribute(\"command\");\n if (command !== null && command.startsWith(LB_COMMAND_PREFIX)) {\n if (!(LB_COMMANDS as readonly string[]).includes(command)) {\n problems.push(\n `<${tag}> carries command=\"${command}\", which begins with ` +\n `'${LB_COMMAND_PREFIX}' but names no command Loadbare provides`,\n );\n } else if (!el.hasAttribute(\"commandfor\")) {\n problems.push(\n `<${tag}> carries command=\"${command}\" and no commandfor; it ` +\n `names the element the command is for`,\n );\n }\n }\n if (el.hasAttribute(ATTR_URL_UNKNOWN) && tag !== \"dialog\") {\n problems.push(\n `<${tag}> carries ${ATTR_URL_UNKNOWN}; it goes on a <dialog>`,\n );\n }\n\n // A group is a template holding a heading and the template its\n // contents go in; an aggregate is set on an element, from the column it\n // names.\n if (el.hasAttribute(ATTR_GROUP)) {\n if (tag !== \"template\") {\n problems.push(\n `<${tag}> carries ${ATTR_GROUP}; it goes on a <template>`,\n );\n } else if (\n !(el as HTMLTemplateElement).content.querySelector(\n `template:not([${ATTR_SHOW}])`,\n )\n ) {\n problems.push(\n `a <template ${ATTR_GROUP}> holds no <template> for its contents`,\n );\n }\n }\n for (const name of AGGREGATES) {\n if (!el.hasAttribute(name)) continue;\n if (tag === \"template\") {\n problems.push(`a <template> carries ${name}; it goes on an element`);\n } else if (name !== ATTR_COUNT && !el.getAttribute(name)) {\n problems.push(`<${tag}> carries ${name} naming no column`);\n }\n }\n\n // The user's order and filter for the rows an element holds, each read\n // from a column of lb-choices it names.\n for (const name of [ATTR_ORDER, ATTR_FILTER]) {\n const value = el.getAttribute(name);\n if (value === null) continue;\n if (!el.hasAttribute(ATTR_QUERY)) {\n problems.push(\n `<${tag}> carries ${name}; it goes on the element carrying ` +\n `${ATTR_QUERY}`,\n );\n } else if (value.trim() === \"\") {\n problems.push(`<${tag}> carries ${name} naming no column`);\n }\n }\n const manual = el.getAttribute(ATTR_MANUAL);\n if (manual !== null) {\n const sides = manual.trim().split(/\\s+/).filter((side) => side !== \"\");\n const known = [MANUAL_ORDER, MANUAL_FILTER];\n if (!el.hasAttribute(ATTR_QUERY)) {\n problems.push(\n `<${tag}> carries ${ATTR_MANUAL}; it goes on the element carrying ` +\n `${ATTR_QUERY}`,\n );\n } else if (\n sides.length === 0 ||\n sides.some((side) => !known.includes(side))\n ) {\n problems.push(\n `<${tag}> carries ${ATTR_MANUAL}=\"${manual}\"; it names ` +\n `${MANUAL_ORDER}, ${MANUAL_FILTER} or both, separated by a space`,\n );\n }\n }\n\n // Judged by the scope around the element, not one the element carries:\n // its condition is a column of the row around it. With no lb-query\n // around it at all, nothing ever lands on it, and the element never\n // shows.\n const show = el.getAttribute(ATTR_SHOW);\n if (show !== null) {\n if (tag === \"template\") {\n problems.push(\n `a <template> carries ${ATTR_SHOW}=\"${show}\"; write it on the ` +\n `element it shows, and Loadbare supplies the template`,\n );\n } else if (scope === null || scope.row === false) {\n problems.push(\n `<${tag}> carries ${ATTR_SHOW}=\"${show}\" with no row around it ` +\n `to take the value from`,\n );\n } else if (show === SHOW_NOT || show.startsWith(SHOW_NOT + SHOW_NOT)) {\n problems.push(\n `<${tag}> carries ${ATTR_SHOW}=\"${show}\"; write one ` +\n `${SHOW_NOT} and then the column it reverses`,\n );\n }\n }\n\n walkMarkup(el, here, names, problems);\n // By tag name rather than by instanceof: template content belongs to a\n // document with no window, so the constructor is not reachable from the\n // node.\n if (tag === \"template\") {\n const content = (el as HTMLTemplateElement).content;\n const isRowTemplate =\n scope !== null && !!el.parentElement?.closest(`[${ATTR_QUERY}]`);\n if (isRowTemplate) {\n for (const root of content.children) {\n if (root.hasAttribute(ATTR_SHOW)) {\n problems.push(\n `<${root.localName}> is a row template's root and carries ` +\n `${ATTR_SHOW}; a row that should not show is left out by ` +\n `the query`,\n );\n }\n }\n }\n walkMarkup(\n content,\n isRowTemplate ? { query: scope!.query, row: true } : here,\n names,\n problems,\n );\n }\n }\n}\n\n/**\n * Ship every `lb-show` element already inside the template the hub keeps an\n * absent branch in, so nothing conditional shows until its value says so.\n * A page is in the document before its data arrives, and a value that has not\n * arrived is no value.\n *\n * Elements are collected before any is moved, and a wrapped element is still\n * reached once its outer one has gone into a template, because the references\n * are held.\n */\nfunction wrapShown(holder: HTMLTemplateElement): void {\n const doc = holder.ownerDocument;\n const shown: Element[] = [];\n const collect = (root: ParentNode): void => {\n shown.push(...root.querySelectorAll(`[${ATTR_SHOW}]`));\n for (const t of root.querySelectorAll(\"template\")) {\n collect((t as HTMLTemplateElement).content);\n }\n };\n collect(holder.content);\n for (const el of shown) {\n const parked = doc.createElement(\"template\");\n parked.setAttribute(ATTR_SHOW, el.getAttribute(ATTR_SHOW)!);\n el.replaceWith(parked);\n parked.content.append(el);\n }\n}\n\n/**\n * Expand one file's markup, naming the file if expansion refuses it.\n *\n * What comes back is the tree the browser will build, so every pass after\n * this reads and changes it in place, and it is serialized once, when it\n * ships.\n */\nfunction expandFile(\n file: string,\n source: string,\n defs: Definitions,\n): HTMLTemplateElement {\n try {\n return expandTree(source, defs);\n } catch (e) {\n throw new Error(`assemble: '${file}': ${(e as Error).message}`);\n }\n}\n\n/** Check one expanded fragment, and name the file if anything is wrong. */\nfunction checkMarkup(\n file: string,\n root: ParentNode,\n names: Names | null,\n): void {\n const problems: string[] = [];\n walkMarkup(root, null, names, problems);\n if (problems.length > 0) {\n throw new Error(`assemble: '${file}' markup:\\n ` + problems.join(`\\n `));\n }\n}\n\n/**\n * A page file's `<title>` names the page. It is lifted out, since a page is\n * a fragment inside `<main>` and a `<title>` belongs in a document's head,\n * and its text content is stamped on the page as ATTR_PAGE_TITLE.\n */\nfunction liftTitle(holder: HTMLTemplateElement): string | null {\n const title = holder.content.querySelector(\"title\");\n if (!title) return null;\n const text = title.textContent?.trim() ?? \"\";\n title.remove();\n return text;\n}\n\n/** An attribute value, escaped for a double-quoted attribute. */\nfunction attributeValue(text: string): string {\n return text.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\");\n}\n\nexport interface AssembleOptions {\n chromeFile: string;\n pages: PageFile[];\n /** Every origin, already scanned, in cascade order — see build/origins.ts. */\n scans: OriginScan[];\n /**\n * What each page declares — see build/declared.ts. Without it, the names\n * `lb-query` and `lb-request` carry are not checked.\n */\n declared?: DeclaredPages;\n}\n\nexport interface Assembled {\n html: string;\n /** Every custom element tag left in the document once expansion is done. */\n usedTags: Set<string>;\n}\n\nexport async function assemble({\n chromeFile,\n pages,\n scans,\n declared,\n}: AssembleOptions): Promise<Assembled> {\n // One layer per origin, in order, so a later origin's definition overrides\n // an earlier one's for the same tag. Each layer is checked for cycles as it\n // lands, against everything merged so far.\n let defs: Definitions = {};\n for (const scan of scans) {\n defs = await addDefinitions(defs, scan.definitions);\n }\n\n // Tags are collected from each tree as it goes by. What ships is these\n // trees and the chrome around its body, which is collected on its own.\n const usedTags = new Set<string>();\n const templates: string[] = [];\n for (const { name, file } of pages) {\n const authored = await readFile(file, \"utf-8\");\n const host = expandFile(file, authored, defs);\n const title = liftTitle(host);\n checkPage(file, host.content);\n checkMarkup(\n file,\n host.content,\n declared ? { declared: declared.get(name)! } : null,\n );\n wrapShown(host);\n customElementTags(host.content, usedTags);\n const titled =\n title === null ? \"\" : ` ${ATTR_PAGE_TITLE}=\"${attributeValue(title)}\"`;\n templates.push(\n `<template ${ATTR_PAGE}=\"${name}\"${titled}>${host.innerHTML}</template>`,\n );\n }\n\n let chromeSource: string;\n try {\n chromeSource = await readFile(chromeFile, \"utf-8\");\n } catch {\n throw new Error(`assemble: no chrome file at '${chromeFile}'`);\n }\n\n const body = /<body([^>]*)>([\\s\\S]*)<\\/body>/i.exec(chromeSource);\n if (!body) {\n throw new Error(\n `assemble: '${chromeFile}' has no <body>...</body> to expand`,\n );\n }\n const [whole, bodyAttrs, bodyContent] = body;\n const chromeBody = expandFile(chromeFile, bodyContent!, defs);\n checkChrome(chromeFile, chromeBody.content);\n checkUnknownPageDialog(chromeFile, chromeBody.content);\n checkMarkup(\n chromeFile,\n chromeBody.content,\n declared ? { declared: null } : null,\n );\n wrapShown(chromeBody);\n customElementTags(chromeBody.content, usedTags);\n customElementTags(chromeSource.replace(whole!, \"\"), usedTags);\n const withPages = chromeSource.replace(\n whole!,\n () =>\n `<body${bodyAttrs}>${chromeBody.innerHTML}\\n${templates.join(\"\\n\")}\\n</body>`,\n );\n\n return { html: await formatHtml(withPages), usedTags };\n}\n"]}
@@ -59,4 +59,20 @@ export interface AppWatcher {
59
59
  * never overlap and never fall behind.
60
60
  */
61
61
  export declare function watchApp(options?: WatchOptions): AppWatcher;
62
+ /**
63
+ * Watch every directory under `root`, and each one made later, and report
64
+ * each file an event names, relative to `root`. A directory `skip` answers
65
+ * true for, relative to `root`, is not watched, nor is anything under it.
66
+ *
67
+ * Directories rather than `recursive: true`: on Linux, Node's recursive
68
+ * watch follows each file, so a file saved by replacing it, as `sed -i` and
69
+ * many editors save, is never heard from again. A directory's watch outlives
70
+ * every file in it.
71
+ *
72
+ * A directory made after the watch began may hold files before its own
73
+ * watch starts, so each file found in it is reported.
74
+ */
75
+ export declare function watchTree(root: string, onFile: (file: string) => void, skip?: (dir: string) => boolean): {
76
+ close(): void;
77
+ };
62
78
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../build/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkBH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,KAAK;IACpB,kCAAkC;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wEAAwE;AACxE,wBAAsB,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,CAgEzE;AAED,sCAAsC;AACtC,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC7C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEnD,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtC,gFAAgF;IAChF,OAAO,CAAC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C,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7B,uDAAuD;IACvD,KAAK,IAAI,IAAI,CAAC;CACf;AAYD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,UAAU,CA6D/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC9B,IAAI,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAqB,GAC3C;IAAE,KAAK,IAAI,IAAI,CAAA;CAAE,CAqDnB"}
@@ -10,7 +10,7 @@
10
10
  * leaves the last good build in place, so a server reading `dist/` keeps
11
11
  * serving something coherent while the developer fixes the mistake.
12
12
  */
13
- import { watch as watchFiles } from "node:fs";
13
+ import { readdirSync, statSync, watch as watchDir } from "node:fs";
14
14
  import { mkdir, writeFile } from "node:fs/promises";
15
15
  import path from "node:path";
16
16
  import * as esbuild from "esbuild";
@@ -121,8 +121,8 @@ export function watchApp(options = {}) {
121
121
  void drain();
122
122
  return outcome;
123
123
  });
124
- const watcher = watchFiles(src, { recursive: true }, (_event, file) => {
125
- if (closed || !file || !BUILT_FROM.test(file) || inOut(file))
124
+ const tree = watchTree(src, (file) => {
125
+ if (closed || !BUILT_FROM.test(file) || inOut(file))
126
126
  return;
127
127
  pending.add(file.split(path.sep).join("/"));
128
128
  if (running || timer)
@@ -135,14 +135,86 @@ export function watchApp(options = {}) {
135
135
  void drain();
136
136
  });
137
137
  }, SETTLE_MS);
138
- });
138
+ }, inOut);
139
139
  return {
140
140
  ready,
141
141
  close() {
142
142
  closed = true;
143
143
  clearTimeout(timer);
144
- watcher.close();
144
+ tree.close();
145
145
  },
146
146
  };
147
147
  }
148
+ /**
149
+ * Watch every directory under `root`, and each one made later, and report
150
+ * each file an event names, relative to `root`. A directory `skip` answers
151
+ * true for, relative to `root`, is not watched, nor is anything under it.
152
+ *
153
+ * Directories rather than `recursive: true`: on Linux, Node's recursive
154
+ * watch follows each file, so a file saved by replacing it, as `sed -i` and
155
+ * many editors save, is never heard from again. A directory's watch outlives
156
+ * every file in it.
157
+ *
158
+ * A directory made after the watch began may hold files before its own
159
+ * watch starts, so each file found in it is reported.
160
+ */
161
+ export function watchTree(root, onFile, skip = () => false) {
162
+ const watchers = new Map();
163
+ const drop = (dir) => {
164
+ for (const [watched, watcher] of watchers) {
165
+ if (dir === "" || watched === dir || watched.startsWith(dir + path.sep)) {
166
+ watcher.close();
167
+ watchers.delete(watched);
168
+ }
169
+ }
170
+ };
171
+ const changed = (file) => {
172
+ let isDir = false;
173
+ try {
174
+ isDir = statSync(path.join(root, file)).isDirectory();
175
+ }
176
+ catch {
177
+ // Gone: a deleted file is a change, and a deleted directory's watch ends.
178
+ }
179
+ if (isDir) {
180
+ if (!watchers.has(file))
181
+ add(file, true);
182
+ }
183
+ else {
184
+ drop(file);
185
+ onFile(file);
186
+ }
187
+ };
188
+ const add = (dir, report) => {
189
+ if (skip(dir))
190
+ return;
191
+ const full = path.join(root, dir);
192
+ let watcher;
193
+ let entries;
194
+ try {
195
+ watcher = watchDir(full, (_event, name) => {
196
+ if (name)
197
+ changed(path.join(dir, name.toString()));
198
+ });
199
+ entries = readdirSync(full, { withFileTypes: true });
200
+ }
201
+ catch (err) {
202
+ // The root must exist; a directory below it may be gone already.
203
+ if (dir === "")
204
+ throw err;
205
+ return;
206
+ }
207
+ watcher.on("error", () => drop(dir));
208
+ watchers.set(dir, watcher);
209
+ for (const entry of entries) {
210
+ const child = path.join(dir, entry.name);
211
+ if (entry.isDirectory())
212
+ add(child, report);
213
+ else if (report)
214
+ onFile(child);
215
+ }
216
+ };
217
+ add("", false);
218
+ return { close: () => drop("") };
219
+ }
148
220
  //# sourceMappingURL=build.js.map
@@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B,qEAAqE;YACrE,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnB,IAAI,CAAC,OAAO;oBAAE,KAAK,KAAK,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,KAAK;YACH,MAAM,GAAG,IAAI,CAAC;YACd,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The build, as a library: one build, or a watch that rebuilds and says when\n * each build has ended. `loadbare-app-build` (build/cli.ts) is a thin\n * command over these, and `@loadbare/app/dev` runs the watch in process.\n *\n * Paths resolve against the working directory, as the command's do, so a\n * caller runs from the application's root.\n *\n * A build writes nothing until every output is in hand. One that fails\n * leaves the last good build in place, so a server reading `dist/` keeps\n * serving something coherent while the developer fixes the mistake.\n */\n\nimport { watch as watchFiles } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport * as esbuild from \"esbuild\";\nimport { assemble } from \"./assemble.js\";\nimport { loadDeclared } from \"./declared.js\";\nimport {\n checkReservedMethods,\n clientEntrySource,\n resolveElements,\n} from \"./elements.js\";\nimport { resolveLocations } from \"./locations.js\";\nimport { cssFrom, scanAll } from \"./origins.js\";\nimport { pagesSource } from \"./pages.js\";\nimport { stylesSource } from \"./styles.js\";\n\nexport interface BuildOptions {\n /** The application's source tree, `src` when absent. */\n src?: string;\n /** Where the output lands, `dist` when absent. */\n out?: string;\n /** Minify `client.js` and `app.css`. */\n minify?: boolean;\n}\n\nexport interface Built {\n /** Every file the build wrote. */\n files: string[];\n /** How many custom elements `client.js` registers. */\n elements: number;\n /** One line saying what was written, as the command prints it. */\n summary: string;\n}\n\n/** Build once. Throws, having written nothing, when the build fails. */\nexport async function buildApp(options: BuildOptions = {}): Promise<Built> {\n const src = options.src ?? \"src\";\n const minify = options.minify ?? false;\n const locations = await resolveLocations({ src, out: options.out ?? \"dist\" });\n const { outDir } = locations;\n const entryFile = path.join(outDir, \"client-entry.ts\");\n\n const scans = await scanAll(locations, src, locations.importsFile);\n await mkdir(outDir, { recursive: true });\n const declared = await loadDeclared(\n locations.pages,\n locations.pageSources,\n outDir,\n );\n const { html, usedTags } = await assemble({ ...locations, scans, declared });\n\n const { resolved } = resolveElements({ used: usedTags, scans });\n await checkReservedMethods(resolved);\n // The entry is read by the bundler and never served, so it is written now.\n await writeFile(entryFile, clientEntrySource(resolved, outDir), \"utf-8\");\n const bundle = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n format: \"iife\",\n outfile: path.join(outDir, \"client.js\"),\n minify,\n write: false,\n // esbuild keeps the directory it started in; the paths are the caller's.\n absWorkingDir: process.cwd(),\n });\n\n const outputs = new Map<string, string | Uint8Array>();\n outputs.set(path.join(outDir, \"app.html\"), html);\n for (const file of bundle.outputFiles) outputs.set(file.path, file.contents);\n\n const pages = pagesSource(\n locations.pages,\n locations.pageSources,\n outDir,\n locations.packageName,\n );\n if (pages) outputs.set(path.join(outDir, \"pages.ts\"), pages);\n\n const css = await stylesSource(cssFrom(scans));\n if (css) {\n const code = minify\n ? (await esbuild.transform(css, { loader: \"css\", minify: true })).code\n : css;\n outputs.set(path.join(outDir, \"app.css\"), code);\n }\n\n for (const [file, content] of outputs) await writeFile(file, content);\n\n const files = [...outputs.keys()].map((file) =>\n path.relative(process.cwd(), file),\n );\n const elements = resolved.size;\n return {\n files,\n elements,\n summary:\n `wrote ${files.join(\" and \")} ` +\n `(${elements} custom element${elements === 1 ? \"\" : \"s\"})`,\n };\n}\n\n/** How one build of a watch ended. */\nexport type BuildOutcome =\n | { ok: true; changed: string[]; built: Built }\n | { ok: false; changed: string[]; error: Error };\n\nexport interface WatchOptions extends BuildOptions {\n /**\n * A build is starting, for these changed files under `src`, relative to\n * it. Empty for the first build.\n */\n onStart?: (changed: string[]) => void;\n /** A build has ended, well or badly. A failed build does not stop the watch. */\n onBuilt?: (outcome: BuildOutcome) => void;\n}\n\nexport interface AppWatcher {\n /** How the first build ended. */\n ready: Promise<BuildOutcome>;\n /** Stop watching. A build already running finishes. */\n close(): void;\n}\n\n/** The files a build reads. A change to any other file starts no build. */\nconst BUILT_FROM = /\\.(html|ts|css)$/;\n\n/**\n * Edits arrive in bursts: an editor's save is often several events, and a\n * branch switch is hundreds. Waiting this long after the first lets the\n * burst finish, so it starts one build.\n */\nconst SETTLE_MS = 20;\n\n/**\n * Build, then build again whenever a file under `src` changes. Changes that\n * arrive while a build runs are gathered into one build after it, so builds\n * never overlap and never fall behind.\n */\nexport function watchApp(options: WatchOptions = {}): AppWatcher {\n const src = options.src ?? \"src\";\n // An output directory inside the source tree is written by every build,\n // and a change there must not start the next one.\n const out = path.relative(path.resolve(src), path.resolve(options.out ?? \"dist\"));\n const inOut = (file: string) =>\n out !== \"\" && !out.startsWith(\"..\") && (file === out || file.startsWith(out + path.sep));\n let pending = new Set<string>();\n let running = false;\n let timer: NodeJS.Timeout | undefined;\n let closed = false;\n\n const once = async (changed: string[]): Promise<BuildOutcome> => {\n options.onStart?.(changed);\n let outcome: BuildOutcome;\n try {\n outcome = { ok: true, changed, built: await buildApp(options) };\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n outcome = { ok: false, changed, error };\n }\n options.onBuilt?.(outcome);\n return outcome;\n };\n\n const drain = async (): Promise<void> => {\n running = true;\n while (pending.size > 0 && !closed) {\n const changed = [...pending].sort();\n pending = new Set();\n await once(changed);\n }\n running = false;\n };\n\n const ready = once([]).then((outcome) => {\n if (pending.size > 0) void drain();\n return outcome;\n });\n\n const watcher = watchFiles(src, { recursive: true }, (_event, file) => {\n if (closed || !file || !BUILT_FROM.test(file) || inOut(file)) return;\n pending.add(file.split(path.sep).join(\"/\"));\n if (running || timer) return;\n timer = setTimeout(() => {\n timer = undefined;\n // The first build is still running: it starts the next when it ends.\n void ready.then(() => {\n if (!running) void drain();\n });\n }, SETTLE_MS);\n });\n\n return {\n ready,\n close() {\n closed = true;\n clearTimeout(timer);\n watcher.close();\n },\n };\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../build/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,IAAI,QAAQ,EAAkB,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,UAAwB,EAAE;IACvD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC;IACvC,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC;IAC9E,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,M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,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBACvC,IAAI,MAAM;gBAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;IAEF,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACf,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * The build, as a library: one build, or a watch that rebuilds and says when\n * each build has ended. `loadbare-app-build` (build/cli.ts) is a thin\n * command over these, and `@loadbare/app/dev` runs the watch in process.\n *\n * Paths resolve against the working directory, as the command's do, so a\n * caller runs from the application's root.\n *\n * A build writes nothing until every output is in hand. One that fails\n * leaves the last good build in place, so a server reading `dist/` keeps\n * serving something coherent while the developer fixes the mistake.\n */\n\nimport { readdirSync, statSync, watch as watchDir, type FSWatcher } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport * as esbuild from \"esbuild\";\nimport { assemble } from \"./assemble.js\";\nimport { loadDeclared } from \"./declared.js\";\nimport {\n checkReservedMethods,\n clientEntrySource,\n resolveElements,\n} from \"./elements.js\";\nimport { resolveLocations } from \"./locations.js\";\nimport { cssFrom, scanAll } from \"./origins.js\";\nimport { pagesSource } from \"./pages.js\";\nimport { stylesSource } from \"./styles.js\";\n\nexport interface BuildOptions {\n /** The application's source tree, `src` when absent. */\n src?: string;\n /** Where the output lands, `dist` when absent. */\n out?: string;\n /** Minify `client.js` and `app.css`. */\n minify?: boolean;\n}\n\nexport interface Built {\n /** Every file the build wrote. */\n files: string[];\n /** How many custom elements `client.js` registers. */\n elements: number;\n /** One line saying what was written, as the command prints it. */\n summary: string;\n}\n\n/** Build once. Throws, having written nothing, when the build fails. */\nexport async function buildApp(options: BuildOptions = {}): Promise<Built> {\n const src = options.src ?? \"src\";\n const minify = options.minify ?? false;\n const locations = await resolveLocations({ src, out: options.out ?? \"dist\" });\n const { outDir } = locations;\n const entryFile = path.join(outDir, \"client-entry.ts\");\n\n const scans = await scanAll(locations, src, locations.importsFile);\n await mkdir(outDir, { recursive: true });\n const declared = await loadDeclared(\n locations.pages,\n locations.pageSources,\n outDir,\n );\n const { html, usedTags } = await assemble({ ...locations, scans, declared });\n\n const { resolved } = resolveElements({ used: usedTags, scans });\n await checkReservedMethods(resolved);\n // The entry is read by the bundler and never served, so it is written now.\n await writeFile(entryFile, clientEntrySource(resolved, outDir), \"utf-8\");\n const bundle = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n format: \"iife\",\n outfile: path.join(outDir, \"client.js\"),\n minify,\n write: false,\n // esbuild keeps the directory it started in; the paths are the caller's.\n absWorkingDir: process.cwd(),\n });\n\n const outputs = new Map<string, string | Uint8Array>();\n outputs.set(path.join(outDir, \"app.html\"), html);\n for (const file of bundle.outputFiles) outputs.set(file.path, file.contents);\n\n const pages = pagesSource(\n locations.pages,\n locations.pageSources,\n outDir,\n locations.packageName,\n );\n if (pages) outputs.set(path.join(outDir, \"pages.ts\"), pages);\n\n const css = await stylesSource(cssFrom(scans));\n if (css) {\n const code = minify\n ? (await esbuild.transform(css, { loader: \"css\", minify: true })).code\n : css;\n outputs.set(path.join(outDir, \"app.css\"), code);\n }\n\n for (const [file, content] of outputs) await writeFile(file, content);\n\n const files = [...outputs.keys()].map((file) =>\n path.relative(process.cwd(), file),\n );\n const elements = resolved.size;\n return {\n files,\n elements,\n summary:\n `wrote ${files.join(\" and \")} ` +\n `(${elements} custom element${elements === 1 ? \"\" : \"s\"})`,\n };\n}\n\n/** How one build of a watch ended. */\nexport type BuildOutcome =\n | { ok: true; changed: string[]; built: Built }\n | { ok: false; changed: string[]; error: Error };\n\nexport interface WatchOptions extends BuildOptions {\n /**\n * A build is starting, for these changed files under `src`, relative to\n * it. Empty for the first build.\n */\n onStart?: (changed: string[]) => void;\n /** A build has ended, well or badly. A failed build does not stop the watch. */\n onBuilt?: (outcome: BuildOutcome) => void;\n}\n\nexport interface AppWatcher {\n /** How the first build ended. */\n ready: Promise<BuildOutcome>;\n /** Stop watching. A build already running finishes. */\n close(): void;\n}\n\n/** The files a build reads. A change to any other file starts no build. */\nconst BUILT_FROM = /\\.(html|ts|css)$/;\n\n/**\n * Edits arrive in bursts: an editor's save is often several events, and a\n * branch switch is hundreds. Waiting this long after the first lets the\n * burst finish, so it starts one build.\n */\nconst SETTLE_MS = 20;\n\n/**\n * Build, then build again whenever a file under `src` changes. Changes that\n * arrive while a build runs are gathered into one build after it, so builds\n * never overlap and never fall behind.\n */\nexport function watchApp(options: WatchOptions = {}): AppWatcher {\n const src = options.src ?? \"src\";\n // An output directory inside the source tree is written by every build,\n // and a change there must not start the next one.\n const out = path.relative(path.resolve(src), path.resolve(options.out ?? \"dist\"));\n const inOut = (file: string) =>\n out !== \"\" && !out.startsWith(\"..\") && (file === out || file.startsWith(out + path.sep));\n let pending = new Set<string>();\n let running = false;\n let timer: NodeJS.Timeout | undefined;\n let closed = false;\n\n const once = async (changed: string[]): Promise<BuildOutcome> => {\n options.onStart?.(changed);\n let outcome: BuildOutcome;\n try {\n outcome = { ok: true, changed, built: await buildApp(options) };\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n outcome = { ok: false, changed, error };\n }\n options.onBuilt?.(outcome);\n return outcome;\n };\n\n const drain = async (): Promise<void> => {\n running = true;\n while (pending.size > 0 && !closed) {\n const changed = [...pending].sort();\n pending = new Set();\n await once(changed);\n }\n running = false;\n };\n\n const ready = once([]).then((outcome) => {\n if (pending.size > 0) void drain();\n return outcome;\n });\n\n const tree = watchTree(src, (file) => {\n if (closed || !BUILT_FROM.test(file) || inOut(file)) return;\n pending.add(file.split(path.sep).join(\"/\"));\n if (running || timer) return;\n timer = setTimeout(() => {\n timer = undefined;\n // The first build is still running: it starts the next when it ends.\n void ready.then(() => {\n if (!running) void drain();\n });\n }, SETTLE_MS);\n }, inOut);\n\n return {\n ready,\n close() {\n closed = true;\n clearTimeout(timer);\n tree.close();\n },\n };\n}\n\n/**\n * Watch every directory under `root`, and each one made later, and report\n * each file an event names, relative to `root`. A directory `skip` answers\n * true for, relative to `root`, is not watched, nor is anything under it.\n *\n * Directories rather than `recursive: true`: on Linux, Node's recursive\n * watch follows each file, so a file saved by replacing it, as `sed -i` and\n * many editors save, is never heard from again. A directory's watch outlives\n * every file in it.\n *\n * A directory made after the watch began may hold files before its own\n * watch starts, so each file found in it is reported.\n */\nexport function watchTree(\n root: string,\n onFile: (file: string) => void,\n skip: (dir: string) => boolean = () => false,\n): { close(): void } {\n const watchers = new Map<string, FSWatcher>();\n\n const drop = (dir: string) => {\n for (const [watched, watcher] of watchers) {\n if (dir === \"\" || watched === dir || watched.startsWith(dir + path.sep)) {\n watcher.close();\n watchers.delete(watched);\n }\n }\n };\n\n const changed = (file: string) => {\n let isDir = false;\n try {\n isDir = statSync(path.join(root, file)).isDirectory();\n } catch {\n // Gone: a deleted file is a change, and a deleted directory's watch ends.\n }\n if (isDir) {\n if (!watchers.has(file)) add(file, true);\n } else {\n drop(file);\n onFile(file);\n }\n };\n\n const add = (dir: string, report: boolean) => {\n if (skip(dir)) return;\n const full = path.join(root, dir);\n let watcher: FSWatcher;\n let entries;\n try {\n watcher = watchDir(full, (_event, name) => {\n if (name) changed(path.join(dir, name.toString()));\n });\n entries = readdirSync(full, { withFileTypes: true });\n } catch (err) {\n // The root must exist; a directory below it may be gone already.\n if (dir === \"\") throw err;\n return;\n }\n watcher.on(\"error\", () => drop(dir));\n watchers.set(dir, watcher);\n for (const entry of entries) {\n const child = path.join(dir, entry.name);\n if (entry.isDirectory()) add(child, report);\n else if (report) onFile(child);\n }\n };\n\n add(\"\", false);\n return { close: () => drop(\"\") };\n}\n"]}
@@ -7,7 +7,7 @@ export declare const ATTR_KEY_VALUE = "lb-key-value";
7
7
  export declare const ATTR_ROW_LIVE = "lb-row-live";
8
8
  export declare const LIVE_ROW = "[lb-row-live]";
9
9
  export declare const ATTR_QUERY_ROW_COUNT = "lb-query-row-count";
10
- export declare const ATTR_QUERY_UNSORTED_COUNT = "lb-query-unsorted-count";
10
+ export declare const ATTR_QUERY_UNPLACED_COUNT = "lb-query-unplaced-count";
11
11
  export declare const ATTR_QUERY_ORDER = "lb-query-order";
12
12
  export declare const ATTR_GROUP = "lb-group";
13
13
  export declare const ATTR_GROUP_LIVE = "lb-group-live";
@@ -25,6 +25,9 @@ export declare const COLUMN_TYPES: readonly ["number", "boolean", "text"];
25
25
  export declare const CHOICES_QUERY = "lb-choices";
26
26
  export declare const ATTR_ORDER = "lb-order";
27
27
  export declare const ATTR_FILTER = "lb-filter";
28
+ export declare const ATTR_MANUAL = "lb-manual";
29
+ export declare const MANUAL_ORDER = "order";
30
+ export declare const MANUAL_FILTER = "filter";
28
31
  export declare const FILTER_OPERATORS: readonly ["!=", "^=", "$=", "*=", "<=", ">=", "=", "<", ">"];
29
32
  export declare const ATTR_ROW_CREATED = "lb-row-created";
30
33
  export declare const ATTR_ROW_CHANGED = "lb-row-changed";
@@ -33,7 +36,7 @@ export declare const ATTR_ROW_REQUESTED = "lb-row-requested";
33
36
  export declare const REQUESTED_CREATED = "created";
34
37
  export declare const REQUESTED_CHANGED = "changed";
35
38
  export declare const REQUESTED_MOVED = "moved";
36
- export declare const ATTR_ROW_UNSORTED = "lb-row-unsorted";
39
+ export declare const ATTR_ROW_UNPLACED = "lb-row-unplaced";
37
40
  export declare const ATTR_ROW_LEAVING = "lb-row-leaving";
38
41
  export declare const ATTR_GROUP_LEAVING = "lb-group-leaving";
39
42
  export declare const ATTR_REQUEST = "lb-request";
@@ -46,8 +49,8 @@ export declare const ATTR_REQUEST_ERROR = "lb-request-error";
46
49
  export declare const COMMAND_EDIT = "--lb-edit";
47
50
  export declare const COMMAND_NEW = "--lb-new";
48
51
  export declare const COMMAND_RELEASE = "--lb-release";
49
- export declare const COMMAND_SORT = "--lb-sort";
50
- export declare const LB_COMMANDS: readonly ["--lb-edit", "--lb-new", "--lb-release", "--lb-sort"];
52
+ export declare const COMMAND_PLACE = "--lb-place";
53
+ export declare const LB_COMMANDS: readonly ["--lb-edit", "--lb-new", "--lb-release", "--lb-place"];
51
54
  export declare const LB_COMMAND_PREFIX = "--lb-";
52
55
  export declare const ATTR_ROW_EDITING = "lb-row-editing";
53
56
  export declare const ATTR_SELECT = "lb-select";
@@ -87,7 +90,7 @@ export declare const ATTR_EXP_SLOT = "lb-exp-slot";
87
90
  export declare const ATTR_EXP_TEMPLATE = "lb-exp-template";
88
91
  export declare const ATTR_PAGE = "lb-page";
89
92
  export declare const ATTR_PAGE_TITLE = "lb-page-title";
90
- export declare const DEVELOPER_ATTRIBUTES: readonly ["lb-query", "lb-column", "lb-show", "lb-group", "lb-count", "lb-sum", "lb-avg", "lb-min", "lb-max", "lb-order", "lb-filter", "lb-request", "lb-select", "lb-url-link", "lb-url-push", "lb-url-parm", "lb-url-unknown"];
93
+ export declare const DEVELOPER_ATTRIBUTES: readonly ["lb-query", "lb-column", "lb-show", "lb-group", "lb-count", "lb-sum", "lb-avg", "lb-min", "lb-max", "lb-order", "lb-filter", "lb-manual", "lb-request", "lb-select", "lb-url-link", "lb-url-push", "lb-url-parm", "lb-url-unknown"];
91
94
  export declare const HUB_TAG_NAME = "lb-hub";
92
95
  export declare const LB_ENDPOINT = "/lb";
93
96
  export declare const LB_REQUEST_TIMEOUT_MS = 10000;
@@ -1 +1 @@
1
- {"version":3,"file":"lb-constants.d.ts","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,UAAU,aAAa,CAAC;AAKrC,eAAO,MAAM,WAAW,cAAc,CAAC;AAavC,eAAO,MAAM,SAAS,YAAY,CAAC;AAInC,eAAO,MAAM,QAAQ,MAAM,CAAC;AAK5B,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAKnD,eAAO,MAAM,cAAc,iBAAiB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
50
  export const ATTR_QUERY_ROW_COUNT = "lb-query-row-count";
51
51
  // Stamped by the hub beside ATTR_QUERY_ROW_COUNT: how many live rows stand
52
- // where the order would not put them, so a stylesheet shows a re-sort
53
- // control only while one would do something.
54
- export const ATTR_QUERY_UNSORTED_COUNT = "lb-query-unsorted-count";
52
+ // where the order or the filter would not leave them, so a stylesheet shows
53
+ // a control that places them only while one would do something.
54
+ export const ATTR_QUERY_UNPLACED_COUNT = "lb-query-unplaced-count";
55
55
  // Stamped by the hub beside ATTR_QUERY_ROW_COUNT: the order its rows are
56
56
  // placed by, the user's or else the server's, as an order's text, so a
57
57
  // widget or a stylesheet can show it. Absent when the rows have no order.
@@ -112,6 +112,14 @@ export const ATTR_ORDER = "lb-order";
112
112
  // may filter, separated by commas. The column of `lb-choices` of the same
113
113
  // name holds the filter, and a row it does not pass is `hidden`.
114
114
  export const ATTR_FILTER = "lb-filter";
115
+ // On an element naming a `rows` query: which placements wait for the user,
116
+ // `order`, `filter` or both, separated by spaces. A side not named is placed
117
+ // on every landing. A side named is placed when the page loads, when the
118
+ // user's order or filter changes, and on COMMAND_PLACE; an answer to a
119
+ // request leaves the rows on that side where they stand.
120
+ export const ATTR_MANUAL = "lb-manual";
121
+ export const MANUAL_ORDER = "order";
122
+ export const MANUAL_FILTER = "filter";
115
123
  // A filter's operators, written before each value: `^=Amazon`, or
116
124
  // `>=2026-01-01 <=2026-03-31` for a range. A value with none is `*=`. The
117
125
  // longer are listed first, which is the order they are read in.
@@ -145,10 +153,10 @@ export const ATTR_ROW_REQUESTED = "lb-row-requested";
145
153
  export const REQUESTED_CREATED = "created";
146
154
  export const REQUESTED_CHANGED = "changed";
147
155
  export const REQUESTED_MOVED = "moved";
148
- // The row stands where the order would not put it: an edit from inside its
149
- // list changed or created it, and the hub left it where the user was
150
- // working. Cleared when the rows are next placed by the order.
151
- export const ATTR_ROW_UNSORTED = "lb-row-unsorted";
156
+ // The row stands where the order or the filter would not leave it: an answer
157
+ // changed or created it in a list that places that side by hand, and the hub
158
+ // left it where it stood. Cleared when the rows are next placed.
159
+ export const ATTR_ROW_UNPLACED = "lb-row-unplaced";
152
160
  // A row or a group on its way out. It is no longer live, takes no input, and
153
161
  // is removed once the animations running on it have finished, at once when
154
162
  // there are none.
@@ -185,7 +193,7 @@ export const ATTR_REQUEST_ERROR = "lb-request-error";
185
193
  // One form edits any row of its query, or enters a new one. A button points
186
194
  // it with HTML's own `commandfor="<form id>"` and one of these commands,
187
195
  // which HTML requires to begin with `--`. The hub hears the `command` event
188
- // on the form. COMMAND_SORT, the last of them, is for a list, not a form.
196
+ // on the form. COMMAND_PLACE, the last of them, is for a list, not a form.
189
197
  // From a button in a live row of the form's query: fill the form from that
190
198
  // row, as the hub holds it, and key it by that row.
191
199
  export const COMMAND_EDIT = "--lb-edit";
@@ -194,13 +202,13 @@ export const COMMAND_NEW = "--lb-new";
194
202
  // From any button: let the form go without saving.
195
203
  export const COMMAND_RELEASE = "--lb-release";
196
204
  // From any button, for an element carrying `lb-query` rather than a form:
197
- // place its rows by the order, from the rows the hub holds.
198
- export const COMMAND_SORT = "--lb-sort";
205
+ // place its rows by the order and the filter, from the rows the hub holds.
206
+ export const COMMAND_PLACE = "--lb-place";
199
207
  export const LB_COMMANDS = [
200
208
  COMMAND_EDIT,
201
209
  COMMAND_NEW,
202
210
  COMMAND_RELEASE,
203
- COMMAND_SORT,
211
+ COMMAND_PLACE,
204
212
  ];
205
213
  // Loadbare owns every command beginning with this prefix.
206
214
  export const LB_COMMAND_PREFIX = "--lb-";
@@ -318,6 +326,7 @@ export const DEVELOPER_ATTRIBUTES = [
318
326
  ...AGGREGATES,
319
327
  ATTR_ORDER,
320
328
  ATTR_FILTER,
329
+ ATTR_MANUAL,
321
330
  ATTR_REQUEST,
322
331
  ATTR_SELECT,
323
332
  ATTR_URL_LINK,