@loadbare/app 0.6.0 → 0.7.1

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 (122) hide show
  1. package/dist/build/assemble.js +1 -0
  2. package/dist/build/assemble.js.map +1 -0
  3. package/dist/build/cli.js +1 -0
  4. package/dist/build/cli.js.map +1 -0
  5. package/dist/build/elements.js +1 -0
  6. package/dist/build/elements.js.map +1 -0
  7. package/dist/build/expand.js +1 -0
  8. package/dist/build/expand.js.map +1 -0
  9. package/dist/build/format.js +1 -0
  10. package/dist/build/format.js.map +1 -0
  11. package/dist/build/locations.d.ts +2 -2
  12. package/dist/build/locations.d.ts.map +1 -1
  13. package/dist/build/locations.js +3 -4
  14. package/dist/build/locations.js.map +1 -0
  15. package/dist/build/origins.js +1 -0
  16. package/dist/build/origins.js.map +1 -0
  17. package/dist/build/package-root.js +1 -0
  18. package/dist/build/package-root.js.map +1 -0
  19. package/dist/build/pages.d.ts +4 -0
  20. package/dist/build/pages.d.ts.map +1 -1
  21. package/dist/build/pages.js +5 -0
  22. package/dist/build/pages.js.map +1 -0
  23. package/dist/build/styles.js +1 -0
  24. package/dist/build/styles.js.map +1 -0
  25. package/dist/core/lb-constants.js +1 -0
  26. package/dist/core/lb-constants.js.map +1 -0
  27. package/dist/core/lb-types.d.ts +1 -1
  28. package/dist/core/lb-types.d.ts.map +1 -1
  29. package/dist/core/lb-types.js +2 -1
  30. package/dist/core/lb-types.js.map +1 -0
  31. package/dist/hub/lb-apply.d.ts +11 -1
  32. package/dist/hub/lb-apply.d.ts.map +1 -1
  33. package/dist/hub/lb-apply.js +50 -13
  34. package/dist/hub/lb-apply.js.map +1 -0
  35. package/dist/hub/lb-hub.browser.d.ts +1 -1
  36. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  37. package/dist/hub/lb-hub.browser.js +143 -112
  38. package/dist/hub/lb-hub.browser.js.map +1 -0
  39. package/dist/server/lb-express.d.ts +1 -1
  40. package/dist/server/lb-express.d.ts.map +1 -1
  41. package/dist/server/lb-express.js +1 -0
  42. package/dist/server/lb-express.js.map +1 -0
  43. package/dist/server/lb-server.d.ts +1 -1
  44. package/dist/server/lb-server.d.ts.map +1 -1
  45. package/dist/server/lb-server.js +2 -1
  46. package/dist/server/lb-server.js.map +1 -0
  47. package/docs/TECHREF-1.0.md +158 -43
  48. package/docs/analysis-accidental-complexity.md +149 -0
  49. package/docs/reference/custom-elements.md +27 -17
  50. package/docs/reference/data-binding.md +88 -29
  51. package/docs/reference/server.md +18 -0
  52. package/docs/reference/widgets.md +3 -3
  53. package/docs/theory.md +114 -1
  54. package/docs/tutorials/072-inserting-into-a-list.md +14 -11
  55. package/docs/tutorials/080-widget-requests.md +9 -26
  56. package/package.json +2 -2
  57. package/dist/tests/assemble.test.d.ts +0 -8
  58. package/dist/tests/assemble.test.d.ts.map +0 -1
  59. package/dist/tests/assemble.test.js +0 -210
  60. package/dist/tests/elements.test.d.ts +0 -8
  61. package/dist/tests/elements.test.d.ts.map +0 -1
  62. package/dist/tests/elements.test.js +0 -118
  63. package/dist/tests/expand.test.d.ts +0 -10
  64. package/dist/tests/expand.test.d.ts.map +0 -1
  65. package/dist/tests/expand.test.js +0 -253
  66. package/dist/tests/fixtures/elements/collision/imports.d.ts +0 -3
  67. package/dist/tests/fixtures/elements/collision/imports.d.ts.map +0 -1
  68. package/dist/tests/fixtures/elements/collision/imports.js +0 -1
  69. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.browser.d.ts +0 -2
  70. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.browser.d.ts.map +0 -1
  71. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.browser.js +0 -1
  72. package/dist/tests/fixtures/elements/local/widgets/app-box.browser.d.ts +0 -2
  73. package/dist/tests/fixtures/elements/local/widgets/app-box.browser.d.ts.map +0 -1
  74. package/dist/tests/fixtures/elements/local/widgets/app-box.browser.js +0 -1
  75. package/dist/tests/fixtures/elements/manifest/imports.d.ts +0 -3
  76. package/dist/tests/fixtures/elements/manifest/imports.d.ts.map +0 -1
  77. package/dist/tests/fixtures/elements/manifest/imports.js +0 -1
  78. package/dist/tests/fixtures/elements/manifest-bad-entry/imports.d.ts +0 -3
  79. package/dist/tests/fixtures/elements/manifest-bad-entry/imports.d.ts.map +0 -1
  80. package/dist/tests/fixtures/elements/manifest-bad-entry/imports.js +0 -1
  81. package/dist/tests/fixtures/elements/manifest-not-array/imports.d.ts +0 -5
  82. package/dist/tests/fixtures/elements/manifest-not-array/imports.d.ts.map +0 -1
  83. package/dist/tests/fixtures/elements/manifest-not-array/imports.js +0 -1
  84. package/dist/tests/fixtures/elements/pkg/acme-widget.browser.d.ts +0 -2
  85. package/dist/tests/fixtures/elements/pkg/acme-widget.browser.d.ts.map +0 -1
  86. package/dist/tests/fixtures/elements/pkg/acme-widget.browser.js +0 -1
  87. package/dist/tests/fixtures/elements/unmarked/widgets/app-box.d.ts +0 -6
  88. package/dist/tests/fixtures/elements/unmarked/widgets/app-box.d.ts.map +0 -1
  89. package/dist/tests/fixtures/elements/unmarked/widgets/app-box.js +0 -1
  90. package/dist/tests/helpers/console.d.ts +0 -20
  91. package/dist/tests/helpers/console.d.ts.map +0 -1
  92. package/dist/tests/helpers/console.js +0 -28
  93. package/dist/tests/helpers/dom.d.ts +0 -18
  94. package/dist/tests/helpers/dom.d.ts.map +0 -1
  95. package/dist/tests/helpers/dom.js +0 -22
  96. package/dist/tests/helpers/hub.d.ts +0 -73
  97. package/dist/tests/helpers/hub.d.ts.map +0 -1
  98. package/dist/tests/helpers/hub.js +0 -151
  99. package/dist/tests/lb-apply.test.d.ts +0 -8
  100. package/dist/tests/lb-apply.test.d.ts.map +0 -1
  101. package/dist/tests/lb-apply.test.js +0 -177
  102. package/dist/tests/lb-express.test.d.ts +0 -14
  103. package/dist/tests/lb-express.test.d.ts.map +0 -1
  104. package/dist/tests/lb-express.test.js +0 -243
  105. package/dist/tests/lb-hub.test.d.ts +0 -14
  106. package/dist/tests/lb-hub.test.d.ts.map +0 -1
  107. package/dist/tests/lb-hub.test.js +0 -319
  108. package/dist/tests/lb-list.test.d.ts +0 -12
  109. package/dist/tests/lb-list.test.d.ts.map +0 -1
  110. package/dist/tests/lb-list.test.js +0 -339
  111. package/dist/tests/lb-server.test.d.ts +0 -9
  112. package/dist/tests/lb-server.test.d.ts.map +0 -1
  113. package/dist/tests/lb-server.test.js +0 -546
  114. package/dist/tests/origins.test.d.ts +0 -10
  115. package/dist/tests/origins.test.d.ts.map +0 -1
  116. package/dist/tests/origins.test.js +0 -387
  117. package/dist/tests/pages.test.d.ts +0 -6
  118. package/dist/tests/pages.test.d.ts.map +0 -1
  119. package/dist/tests/pages.test.js +0 -148
  120. package/dist/tests/styles.test.d.ts +0 -7
  121. package/dist/tests/styles.test.d.ts.map +0 -1
  122. package/dist/tests/styles.test.js +0 -76
@@ -144,3 +144,4 @@ export async function assemble({ chromeFile, pages, scans, }) {
144
144
  usedTags: customElementTags(withPages),
145
145
  };
146
146
  }
147
+ //# sourceMappingURL=assemble.js.map
@@ -0,0 +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,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,MAAM,GAEP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,YAAY,GACb,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;GAUG;AACH,SAAS,sBAAsB,CAC7B,UAAkB,EAClB,YAAoB;IAEpB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,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C,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,WAAY,EAAE,IAAI,CAAC,CAAC;IAChD,sBAAsB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CACpC,KAAM,EACN,GAAG,EAAE,CAAC,QAAQ,SAAS,IAAI,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAC5E,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,UAAU,CAAC,SAAS,CAAC;QACjC,QAAQ,EAAE,iBAAiB,CAAC,SAAS,CAAC;KACvC,CAAC;AACJ,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 { JSDOM } from \"jsdom\";\nimport {\n addDefinitions,\n customElementTags,\n expand,\n type Definitions,\n} from \"./expand.js\";\nimport { formatHtml } from \"./format.js\";\nimport {\n ATTR_CELL,\n ATTR_KEY,\n ATTR_LIST,\n ATTR_PAGE,\n ATTR_ROW,\n ATTR_UNKNOWN_PAGE,\n HUB_TAG_NAME,\n} from \"../core/lb-constants.js\";\nimport type { PageFile } from \"./locations.js\";\nimport type { OriginScan } from \"./origins.js\";\n\n/**\n * The hub calls showModal() on whatever carries lb-unknown-page\n * (hub/lb-hub.browser.ts), so a chrome that puts the attribute on anything\n * else would fail at runtime, on whichever page happens to 404 first, rather\n * than at build time. The attribute is optional; a wrong element on it, or a\n * right one out of the hub's reach, is an error.\n *\n * Out of reach because the hub looks for the dialog inside itself, as it\n * does for everything else it acts on. A dialog elsewhere in the body would\n * never open and would say nothing about why.\n */\nfunction checkUnknownPageDialog(\n chromeFile: string,\n expandedBody: string,\n): void {\n const fragment = JSDOM.fragment(expandedBody);\n const el = fragment.querySelector(`[${ATTR_UNKNOWN_PAGE}]`);\n if (!el) return;\n if (el.tagName !== \"DIALOG\") {\n throw new Error(\n `assemble: '${chromeFile}' declares ${ATTR_UNKNOWN_PAGE} on ` +\n `<${el.tagName.toLowerCase()}>, must be a <dialog>`,\n );\n }\n if (!el.closest(HUB_TAG_NAME)) {\n throw new Error(\n `assemble: '${chromeFile}' declares ${ATTR_UNKNOWN_PAGE} outside ` +\n `<${HUB_TAG_NAME}>, where the hub cannot reach it`,\n );\n }\n}\n\n/**\n * One scope while the binding check walks a document: which rung it is, the\n * name it carries, and whether a list has found its row template yet.\n */\ninterface Scope {\n kind: \"list\" | \"row\";\n name: string;\n}\n\n/**\n * The binding vocabulary, checked once against the finished document rather\n * than discovered one console error at a time in a browser.\n *\n * Everything here is a fact the markup states about itself, so none of it\n * needs the server: a key is named on a row template, a row template belongs\n * to a list, and a cell belongs to a scope. What the markup and the server\n * say about cardinality cannot be compared here, because they are separate\n * artifacts — createHub holds that check. See docs/reference/data-binding.md.\n *\n * A list scope with no row template is not an error. It is bound to the list\n * without displaying it, which is what an insert form naming the list it adds\n * to already is.\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 list around it.\n */\nfunction walkBinding(\n node: ParentNode,\n scope: Scope | null,\n problems: string[],\n): void {\n for (const el of node.children) {\n const listName = el.getAttribute(ATTR_LIST);\n const rowName = el.getAttribute(ATTR_ROW);\n const tag = el.localName;\n let here = scope;\n\n if (listName !== null && rowName !== null) {\n problems.push(\n `<${tag}> carries both ${ATTR_LIST} and ${ATTR_ROW}; a scope is ` +\n `one or the other, and a name answers with one shape`,\n );\n }\n if (listName !== null) here = { kind: \"list\", name: listName };\n else if (rowName !== null) here = { kind: \"row\", name: rowName };\n\n if (el.hasAttribute(ATTR_CELL) && here === null) {\n problems.push(\n `<${tag}> carries ${ATTR_CELL}=\"${el.getAttribute(ATTR_CELL)}\" with ` +\n `no ${ATTR_LIST} or ${ATTR_ROW} scope around it`,\n );\n }\n\n if (el.hasAttribute(ATTR_KEY)) {\n if (tag !== \"template\") {\n problems.push(\n `<${tag}> carries ${ATTR_KEY}; it names the column that identifies ` +\n `a row and belongs on the row <template>`,\n );\n } else if (here === null || here.kind !== \"list\") {\n problems.push(\n `a <template> carries ${ATTR_KEY} outside any ${ATTR_LIST} scope; ` +\n `only a list has rows to identify`,\n );\n }\n }\n\n walkBinding(el, here, problems);\n // By tag name rather than by instanceof: JSDOM.fragment() parses into a\n // document with no window, so the constructor is not reachable from the\n // node.\n if (tag === \"template\") {\n walkBinding((el as HTMLTemplateElement).content, here, problems);\n }\n }\n}\n\n/** Check one expanded fragment, and name the file if anything is wrong. */\nfunction checkBinding(file: string, html: string): void {\n const problems: string[] = [];\n walkBinding(JSDOM.fragment(html), null, problems);\n if (problems.length > 0) {\n throw new Error(`assemble: '${file}' binding:\\n ` + problems.join(`\\n `));\n }\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\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}: 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 const templates: string[] = [];\n for (const { name, file } of pages) {\n const authored = await readFile(file, \"utf-8\");\n const host = expand(authored, defs);\n checkBinding(file, host);\n templates.push(`<template ${ATTR_PAGE}=\"${name}\">${host}</template>`);\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 expandedBody = expand(bodyContent!, defs);\n checkUnknownPageDialog(chromeFile, expandedBody);\n checkBinding(chromeFile, expandedBody);\n const withPages = chromeSource.replace(\n whole!,\n () => `<body${bodyAttrs}>${expandedBody}\\n${templates.join(\"\\n\")}\\n</body>`,\n );\n\n return {\n html: await formatHtml(withPages),\n usedTags: customElementTags(withPages),\n };\n}\n"]}
package/dist/build/cli.js CHANGED
@@ -123,3 +123,4 @@ async function main() {
123
123
  }
124
124
  }
125
125
  void main();
126
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../build/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAA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AQ,CAAC,OAAO,CAAC;YAClC,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;YAChC,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;YAEjC,SAAS;QACX,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,uBAAwB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * loadbare-app-build — assemble a chrome file and its pages into one HTML\n * document, and bundle the client script for exactly the custom elements\n * that document uses. See docs/tutorials/000-getting-started.md.\n *\n * loadbare-app-build [--src src] [--out dist] [--watch] [--minify]\n *\n * `--src` names the application's own tree: the one `chrome.html` file,\n * every `*.page.html` page, its `*.requests.ts`/`*.queries.ts` pairs, and\n * `imports.ts` if there is one — see build/locations.ts. It is also the last\n * origin in the cascade that supplies widget definitions, widget scripts and\n * stylesheets; this package's own widgets come first and each package named\n * in `imports.ts` in between, all scanned the same way — see\n * build/origins.ts.\n *\n * The assembled document is written to `<out>/app.html`; the client bundle\n * to `<out>/client.js`, by way of a generated `<out>/client-entry.ts` — see\n * build/elements.ts for how a tag is resolved to the script that registers\n * it. When any page has a requests or queries file, the hub registry that used\n * to be hand-maintained is written to `<out>/pages.ts` — see build/pages.ts.\n * Every origin's stylesheets are concatenated in that same cascade order and\n * written to `<out>/app.css` — see build/styles.ts.\n *\n * `--minify` minifies both output files: esbuild's own minifier for\n * `client.js`, as part of the same bundling pass, and esbuild's CSS\n * transform for `app.css`, as a pass over the concatenation above. `app.html`\n * is never minified — it is markup an application may still want to read.\n *\n * Without `--watch`, this runs once and exits. With it, every `.html`,\n * `.ts` and `.css` file under `<src>` is watched — a page, a widget's\n * markup, a widget's class, a stylesheet, and `imports.ts` all feed the\n * same build — and a rebuild that throws is reported without stopping the\n * watch. There is no dev server and no browser reload here, only the files\n * on disk staying current for the next manual refresh.\n */\n\nimport { parseArgs } from \"node:util\";\nimport { mkdir, watch, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport * as esbuild from \"esbuild\";\nimport { assemble } from \"./assemble.js\";\nimport { clientEntrySource, resolveElements } 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\nconst { values } = parseArgs({\n options: {\n src: { type: \"string\", default: \"src\" },\n out: { type: \"string\", default: \"dist\" },\n watch: { type: \"boolean\", default: false },\n minify: { type: \"boolean\", default: false },\n },\n});\n\nconst srcDir = values.src!;\n\nasync function build(): Promise<void> {\n const locations = await resolveLocations({ src: srcDir, out: values.out! });\n const outFile = path.join(locations.outDir, \"app.html\");\n const entryFile = path.join(locations.outDir, \"client-entry.ts\");\n const clientFile = path.join(locations.outDir, \"client.js\");\n\n const scans = await scanAll(locations, srcDir, locations.importsFile);\n\n const { html, usedTags } = await assemble({ ...locations, scans });\n await mkdir(locations.outDir, { recursive: true });\n await writeFile(outFile, html, \"utf-8\");\n\n const { resolved } = resolveElements({ used: usedTags, scans });\n await writeFile(\n entryFile,\n clientEntrySource(resolved, locations.outDir),\n \"utf-8\",\n );\n await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n format: \"iife\",\n outfile: clientFile,\n minify: values.minify,\n });\n\n const generatedPages = pagesSource(\n locations.pages,\n locations.pageSources,\n locations.outDir,\n locations.packageName,\n );\n let pagesMessage = \"\";\n if (generatedPages) {\n const pagesFile = path.join(locations.outDir, \"pages.ts\");\n await writeFile(pagesFile, generatedPages, \"utf-8\");\n pagesMessage = ` and ${pagesFile}`;\n }\n\n const concatenatedCss = await stylesSource(cssFrom(scans));\n let cssMessage = \"\";\n if (concatenatedCss) {\n const cssFile = path.join(locations.outDir, \"app.css\");\n const generatedCss = values.minify\n ? (\n await esbuild.transform(concatenatedCss, {\n loader: \"css\",\n minify: true,\n })\n ).code\n : concatenatedCss;\n await writeFile(cssFile, generatedCss, \"utf-8\");\n cssMessage = ` and ${cssFile}`;\n }\n\n console.log(\n `loadbare-app-build: wrote ${outFile} and ${clientFile}${pagesMessage}${cssMessage} ` +\n `(${resolved.size} custom element${resolved.size === 1 ? \"\" : \"s\"})`,\n );\n}\n\nasync function main(): Promise<void> {\n try {\n await build();\n } catch (err) {\n console.error(`loadbare-app-build: ${(err as Error).message}`);\n if (!values.watch) {\n process.exitCode = 1;\n return;\n }\n }\n\n if (!values.watch) return;\n\n console.log(`loadbare-app-build: watching ${srcDir}`);\n const watcher = watch(srcDir, { recursive: true });\n for await (const event of watcher) {\n if (\n !event.filename?.endsWith(\".html\") &&\n !event.filename?.endsWith(\".ts\") &&\n !event.filename?.endsWith(\".css\")\n )\n continue;\n try {\n await build();\n } catch (err) {\n console.error(`loadbare-app-build: ${(err as Error).message}`);\n }\n }\n}\n\nvoid main();\n"]}
@@ -86,3 +86,4 @@ export function clientEntrySource(resolved, outDir) {
86
86
  }
87
87
  return lines.join("\n") + "\n";
88
88
  }
89
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../build/elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,mBAAmB,EAAwB,MAAM,cAAc,CAAC;AAgBzE,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,KAAK,GACU;IACf,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,MAA4B,CAAC;QACjC,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,sEAAsE;QACtE,KAAK,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AK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAA+B,EAC/B,MAAc;IAEd,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;QACjC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzE,KAAK,CAAC,IAAI,CACR,UAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC","sourcesContent":["/**\n * Validating that a custom element a build actually uses can do something —\n * and finding the script to import for it when it can.\n *\n * A used tag is valid if it has a script, a definition, or both:\n * - a script registers the class that upgrades it.\n * - a definition (an `.html` file) expands the tag's content at build\n * time. A widget with only a definition and no script is markup only:\n * expansion already gave it everything it will ever have, and the tag\n * survives as an inert wrapper (see expand.ts).\n *\n * A tag with neither — no script anywhere and no definition — would do\n * nothing were it ever to reach the browser, so that is an error. When a\n * module named after the tag exists but never said `.browser`, the error\n * names that file: forgetting the word is the ordinary way to arrive here,\n * and it is the one an author can fix in a rename.\n *\n * Both halves are looked for in the same ordered origins, and the later\n * origin wins: an application's own script overrides one from a package it\n * imported, which overrides a built-in. Two files claiming one tag *within*\n * one origin is the error case, and build/origins.ts raises it while\n * scanning. Nothing is scanned here.\n */\n\nimport path from \"node:path\";\nimport type { OriginScan } from \"./origins.js\";\n\nexport { loadElementManifest, type ElementManifest } from \"./origins.js\";\n\n/** A resolved tag: a bare specifier to import, or a local file to import by relative path. */\nexport type Resolved =\n { kind: \"specifier\"; value: string } | { kind: \"file\"; value: string };\n\nexport interface ResolveOptions {\n used: Set<string>;\n /** Every origin, already scanned, in cascade order — see build/origins.ts. */\n scans: OriginScan[];\n}\n\nexport interface ResolveResult {\n resolved: Map<string, Resolved>;\n}\n\nexport function resolveElements({\n used,\n scans,\n}: ResolveOptions): ResolveResult {\n const resolved = new Map<string, Resolved>();\n\n for (const tag of used) {\n let script: Resolved | undefined;\n let hasDefinition = false;\n\n // In order, so the last origin holding a script is the one that wins.\n for (const scan of scans) {\n if (scan.definitions.has(tag)) hasDefinition = true;\n const found = scan.scripts.get(tag);\n if (found === undefined) continue;\n script = scan.specifier\n ? { kind: \"specifier\", value: scan.specifier(tag) }\n : { kind: \"file\", value: found };\n }\n\n if (script) {\n resolved.set(tag, script);\n continue;\n }\n // No script anywhere. Valid only if a definition gave the tag its\n // content — otherwise nothing, ever, would upgrade or fill it, and the\n // tag would do nothing were it to reach the browser.\n if (!hasDefinition) {\n // The likeliest reason, checked first: a module named after the tag is\n // sitting right there without the word that would ship it. Say which\n // file, because \"there is no script\" reads as a lie to someone looking\n // straight at one.\n for (const scan of scans) {\n const near = scan.unmarked.get(tag);\n if (near === undefined) continue;\n throw new Error(\n `build: <${tag}> has no script, but '${near}' is named after it. ` +\n `A script reaches the browser only when its name says so — ` +\n `rename it '${path.basename(near, path.extname(near))}.browser` +\n `${path.extname(near)}' if that is what it is.`,\n );\n }\n throw new Error(\n `build: <${tag}> has neither a script nor a definition, so it would ` +\n `do nothing (checked ${scans.map((s) => `'${s.name}'`).join(\", \")})`,\n );\n }\n }\n\n return { resolved };\n}\n\n/**\n * The generated client entry point — every custom element the assembled\n * document actually uses, and nothing else. Written to `outDir` so a\n * relative import to a local widget resolves the ordinary way; a specifier\n * (built-in or third-party) is written as the bare string it is.\n */\nexport function clientEntrySource(\n resolved: Map<string, Resolved>,\n outDir: string,\n): string {\n const lines: string[] = [];\n for (const tag of [...resolved.keys()].sort()) {\n const entry = resolved.get(tag)!;\n if (entry.kind === \"specifier\") {\n lines.push(`import ${JSON.stringify(entry.value)};`);\n } else {\n const rel = path.relative(outDir, entry.value).split(path.sep).join(\"/\");\n lines.push(\n `import ${JSON.stringify(rel.startsWith(\".\") ? rel : `./${rel}`)};`,\n );\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n"]}
@@ -380,3 +380,4 @@ export function expand(source, defs) {
380
380
  walk(tree, defs);
381
381
  return tree.innerHTML;
382
382
  }
383
+ //# sourceMappingURL=expand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expand.js","sourceRoot":"","sources":["../../build/expand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEnE,sEAAsE;AACtE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,yEAAyE;AACzE;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,uDAAuD,CAAC;A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AAE,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAClE,EAAE,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,IAAI,CAAC,IAAgB,EAAE,IAAiB;IAC/C,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACjD,mEAAmE;QACnE,kEAAkE;QAClE,sEAAsE;QACtE,IAAI,MAAM,KAAK,SAAS;YAAE,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7D,qEAAqE;QACrE,iDAAiD;QACjD,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClB,wEAAwE;QACxE,4CAA4C;QAC5C,IAAI,KAAK,YAAY,mBAAmB;YAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAc,EAAE,IAAiB;IACtD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC,SAAS,CAAC;AACxB,CAAC","sourcesContent":["/**\n * Expansion — see docs/reference/custom-elements.md, \"HTML\".\n *\n * A page author writes one tag and gets the tree it stands for. Expansion\n * runs at build time, before any request exists, so it has no data. That is\n * why there is no control flow here: nothing to branch on.\n *\n * Substitution is applied to a parsed tree with setAttribute and node values,\n * never to a string. A value applied through the DOM API cannot be reparsed\n * as markup, so injection is impossible by construction.\n */\n\nimport { readdir, readFile } from \"node:fs/promises\";\nimport { JSDOM } from \"jsdom\";\nimport { ATTR_SLOT, ATTR_TEMPLATE } from \"../core/lb-constants.js\";\n\n/** Lowercase, hyphenated — the one shape a custom element tag has. */\nconst CUSTOM_ELEMENT = /-/;\n\n/** A placeholder is an entire attribute value or an entire text node. */\n/**\n * `{{name}}` or `{{name|default}}`. The default is a literal that stands in\n * when the tag supplies nothing; it is not evaluated and nothing branches on\n * it. Whitespace around the name and the default is not part of either, so\n * `{{button-text | OK}}` is the same placeholder as `{{button-text|OK}}` —\n * a spaced form that shipped as literal braces would be a silent failure\n * an author would find in the browser.\n */\nconst PLACEHOLDER = /^\\{\\{\\s*([A-Za-z][\\w-]*)\\s*(?:\\|\\s*([^}]*?)\\s*)?\\}\\}$/;\n\n/**\n * Marks an attribute as input to expansion. Three namespaces share the tag:\n * `lb-` holds the names Loadbare defines, `exp-` the names a widget author\n * defines, and everything unprefixed is HTML's and means what HTML says it\n * means. The split is by owner rather than by phase — `lb-slot` and\n * `lb-template` are expansion's own and never reach the browser, while\n * `lb-list` and `lb-cell` are read at both times. So an author is free to write\n * `class`, `title` or `hidden` on any widget, whatever its parameters happen\n * to be named. The prefix marks the slot on the tag, where the ambiguity was;\n * inside a definition `{{ }}` already says the same thing, so `exp-label`\n * fills `{{label}}`.\n */\nconst EXP_PREFIX = \"exp-\";\n\nexport type Definitions = Record<string, string>;\n\nconst dom = new JSDOM(\"\");\nconst doc = dom.window.document;\nconst { Element, HTMLTemplateElement, Node } = dom.window;\n\nfunction parse(source: string): HTMLElement {\n const holder = doc.createElement(\"div\");\n holder.innerHTML = source;\n return holder as unknown as HTMLElement;\n}\n\n/**\n * A tree and the content of every template in it, however deep.\n *\n * A template's children are parsed into a fragment rather than into the tree,\n * so `querySelectorAll` does not reach them. Everything expansion does has to\n * reach them anyway: a definition may supply its own row template, and\n * `lb-picker` does, so `{{key}}` written inside one has to be a\n * placeholder rather than literal text that ships. `walk` already descends\n * into template content to expand widget tags; this is the same rule stated\n * once for every pass that reads a tree.\n */\nfunction* scopes(root: ParentNode): Generator<ParentNode> {\n yield root;\n for (const el of root.querySelectorAll(\"template\")) {\n yield* scopes((el as HTMLTemplateElement).content);\n }\n}\n\n/**\n * Load one definition per file, named by the tag it defines.\n *\n * Later directories win, so an application can override a built-in widget.\n */\nexport async function loadDefinitions(dirs: string[]): Promise<Definitions> {\n const defs: Definitions = {};\n for (const dir of dirs) {\n let names: string[];\n try {\n names = await readdir(dir);\n } catch {\n continue;\n }\n for (const name of names) {\n if (!name.endsWith(\".html\")) continue;\n const file = `${dir}/${name}`;\n const source = await readFile(file, \"utf-8\");\n checkNames(file, source);\n defs[name.slice(0, -\".html\".length).toUpperCase()] = source;\n }\n }\n checkAcyclic(defs);\n return defs;\n}\n\n/**\n * Overlay definitions read from explicit files, each already keyed by the\n * tag it defines — for a source, like an application's own `src` tree, that\n * is discovered file by file rather than listed by directory. A tag here\n * overrides the same tag in `defs`, the same override `loadDefinitions`\n * gives a later directory over an earlier one.\n */\nexport async function addDefinitions(\n defs: Definitions,\n files: Map<string, string>,\n): Promise<Definitions> {\n const merged = { ...defs };\n for (const [tag, file] of files) {\n const source = await readFile(file, \"utf-8\");\n checkNames(file, source);\n merged[tag.toUpperCase()] = source;\n }\n checkAcyclic(merged);\n return merged;\n}\n\n/** Every placeholder a definition declares. */\nfunction placeholdersOf(source: string): string[] {\n const names: string[] = [];\n for (const scope of scopes(parse(source))) {\n for (const el of scope.querySelectorAll(\"*\")) {\n for (const attr of el.attributes) {\n const match = PLACEHOLDER.exec(attr.value.trim());\n if (match) names.push(match[1]!);\n }\n }\n const walker = doc.createTreeWalker(scope as globalThis.Node, 4 /* TEXT */);\n while (walker.nextNode()) {\n const match = PLACEHOLDER.exec((walker.currentNode as Text).data.trim());\n if (match) names.push(match[1]!);\n }\n }\n return names;\n}\n\n/**\n * A placeholder must be spelled the way a tag can supply it.\n *\n * HTML lowercases attribute names, so `exp-inputClass` reaches expansion as\n * `exp-inputclass` and could never fill `{{inputClass}}`. A definition is the\n * only file that can hold such a name and the only one that can fix it, so it\n * is rejected here, once, rather than at every page that uses the widget.\n *\n * Recognition stays broad on purpose. Narrowing PLACEHOLDER to lowercase would\n * make `{{inputClass}}` not a placeholder at all, and ship it to the browser as\n * literal text — the same silent failure somewhere new.\n */\nfunction checkNames(file: string, source: string): void {\n for (const name of placeholdersOf(source)) {\n if (!/[A-Z]/.test(name)) continue;\n const kebab = name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n throw new Error(\n `expand: ${file} declares {{${name}}}, but HTML lowercases attribute ` +\n `names, so no tag can supply it. Write {{${kebab}}}.`,\n );\n }\n}\n\n/**\n * Every hyphenated tag name left in a document, template content included.\n *\n * Meant to run on already-expanded output: an `LB-*` tag with a definition\n * is gone by then, replaced by the tree it stands for, so what remains is\n * whatever is left for the browser to upgrade itself — a built-in widget\n * class, an application's own custom element, or one from a package. A\n * hyphen in the tag name is the one thing a custom element is guaranteed to\n * have, per the Custom Elements spec, and nothing native has one.\n */\nexport function customElementTags(html: string): Set<string> {\n const tags = new Set<string>();\n for (const scope of scopes(parse(html))) {\n for (const el of scope.querySelectorAll(\"*\")) {\n const tag = el.tagName.toLowerCase();\n if (tag.includes(\"-\")) tags.add(tag);\n }\n }\n return tags;\n}\n\n/** Which definitions a definition uses. A tag with no definition expands to nothing and cannot cycle. */\nfunction referencesOf(source: string, defs: Definitions): string[] {\n const refs = new Set<string>();\n for (const scope of scopes(parse(source))) {\n for (const el of scope.querySelectorAll(\"*\")) {\n const tag = el.tagName.toUpperCase();\n if (CUSTOM_ELEMENT.test(tag) && tag in defs) refs.add(tag);\n }\n }\n return [...refs];\n}\n\n/**\n * Expansion is a fixpoint, so it terminates only on an acyclic graph. A depth\n * cap would hide the bug behind a limit instead of reporting it.\n */\nfunction checkAcyclic(defs: Definitions): void {\n const refs = new Map<string, string[]>();\n for (const [tag, source] of Object.entries(defs)) {\n refs.set(tag, referencesOf(source, defs));\n }\n const done = new Set<string>();\n const path: string[] = [];\n\n const visit = (tag: string): void => {\n if (done.has(tag)) return;\n const cycle = path.indexOf(tag);\n if (cycle !== -1) {\n throw new Error(\n `expand: cycle in the definition graph: ` +\n [...path.slice(cycle), tag].map((t) => t.toLowerCase()).join(\" → \"),\n );\n }\n path.push(tag);\n for (const ref of refs.get(tag) ?? []) visit(ref);\n path.pop();\n done.add(tag);\n };\n\n for (const tag of refs.keys()) visit(tag);\n}\n\n/**\n * Resolve a placeholder against what the author wrote: the supplied value,\n * else the definition's default, else absent.\n *\n * Every name the definition asks for is recorded, whether or not it was\n * supplied, so expansion can report a parameter the definition never declared.\n */\nfunction resolve(\n text: string,\n attrs: Map<string, string>,\n asked: Set<string>,\n): string | null {\n const match = PLACEHOLDER.exec(text.trim());\n if (!match) return text;\n const name = match[1]!;\n asked.add(name);\n return attrs.get(name) ?? match[2] ?? null;\n}\n\nfunction substitute(\n root: ParentNode,\n attrs: Map<string, string>,\n asked: Set<string>,\n): void {\n for (const scope of scopes(root)) {\n for (const el of scope.querySelectorAll(\"*\")) {\n for (const attr of [...el.attributes]) {\n const value = resolve(attr.value, attrs, asked);\n // Presence propagates: a placeholder with nothing behind it drops the\n // attribute rather than emitting it empty, which is what HTML's own\n // boolean-attribute semantics require.\n if (value === null) el.removeAttribute(attr.name);\n else if (value !== attr.value) el.setAttribute(attr.name, value);\n }\n }\n\n const walker = doc.createTreeWalker(scope as globalThis.Node, 4 /* TEXT */);\n const texts: Text[] = [];\n while (walker.nextNode()) texts.push(walker.currentNode as Text);\n for (const text of texts) {\n const raw = text.data;\n if (!PLACEHOLDER.test(raw.trim())) continue;\n const value = resolve(raw, attrs, asked) ?? \"\";\n // Keep the author's surrounding whitespace: \"{{label}} <input>\" should\n // still separate the label from the control.\n const lead = raw.slice(0, raw.length - raw.trimStart().length);\n const tail = raw.slice(raw.trimEnd().length);\n text.data = lead + value + tail;\n }\n }\n}\n\n/**\n * Fill the definition's named destinations from the authored templates that\n * name them, and hand back the content that is left for the slot.\n *\n * A destination is filled with the template's contents, not with the\n * template, so what ships is ordinary markup in an ordinary place — a real\n * `<tr>` inside a real `<thead>`, visible in view-source like everything\n * else. The wrapper existed only to survive the parser and is gone.\n *\n * Unlike the slot, there may be several, because the reason for wrapping is\n * per-destination: a table has a head and a body, and each needs its own\n * markup past the same obstacle. They are matched by name, and an empty name\n * is a name, so a widget with one destination costs the author nothing.\n */\nfunction fillTemplates(\n tag: string,\n root: ParentNode,\n content: globalThis.Node[],\n): globalThis.Node[] {\n const destinations = new Map<string, Element>();\n for (const el of root.querySelectorAll(`[${ATTR_TEMPLATE}]`)) {\n const name = el.getAttribute(ATTR_TEMPLATE)!;\n if (destinations.has(name)) {\n throw new Error(\n `expand: <${tag.toLowerCase()}> declares two ${ATTR_TEMPLATE}=\"${name}\" destinations`,\n );\n }\n destinations.set(name, el);\n el.removeAttribute(ATTR_TEMPLATE);\n }\n\n const rest: globalThis.Node[] = [];\n const filled = new Set<string>();\n for (const node of content) {\n const named =\n node instanceof HTMLTemplateElement && node.hasAttribute(ATTR_TEMPLATE);\n if (!named) {\n rest.push(node);\n continue;\n }\n const template = node as HTMLTemplateElement;\n const name = template.getAttribute(ATTR_TEMPLATE)!;\n const destination = destinations.get(name);\n if (!destination) {\n throw new Error(\n `expand: a <template ${ATTR_TEMPLATE}=\"${name}\"> was written inside ` +\n `<${tag.toLowerCase()}>, whose definition has no destination by that name.`,\n );\n }\n if (filled.has(name)) {\n throw new Error(\n `expand: <${tag.toLowerCase()}> was given two templates for '${name}'`,\n );\n }\n filled.add(name);\n destination.append(template.content);\n }\n return rest;\n}\n\n/** Place authored inner content in the single slot, if the definition has one. */\nfunction fillSlot(\n tag: string,\n root: ParentNode,\n content: globalThis.Node[],\n): void {\n const slots = root.querySelectorAll(`[${ATTR_SLOT}]`);\n if (slots.length > 1) {\n throw new Error(\n `expand: <${tag.toLowerCase()}> declares more than one ${ATTR_SLOT}`,\n );\n }\n if (slots.length === 0) {\n // Whitespace is not content. An author who writes only named templates\n // still leaves the newlines between them, and those are the file's\n // formatting rather than something anybody meant to place.\n const wrote = content.some(\n (node) => node.nodeType !== Node.TEXT_NODE || (node as Text).data.trim(),\n );\n if (wrote) {\n throw new Error(\n `expand: content was written inside <${tag.toLowerCase()}>, whose definition has no ${ATTR_SLOT}`,\n );\n }\n return;\n }\n const slot = slots[0]!;\n // The authored nodes move rather than copy. The caller replaces the tag's\n // children with the expanded tree immediately after, so there is nothing\n // left behind for a clone to protect.\n slot.append(...content);\n slot.removeAttribute(ATTR_SLOT);\n}\n\nfunction expandElement(el: Element, defs: Definitions, source: string): void {\n const tag = el.tagName.toUpperCase();\n\n // The tag survives expansion carrying every attribute the author wrote,\n // `exp-` ones included. They cost nothing where they are, and what ships\n // shows what was asked for beside what it produced.\n const attrs = new Map<string, string>();\n for (const attr of el.attributes) {\n if (!attr.name.startsWith(EXP_PREFIX)) continue;\n attrs.set(attr.name.slice(EXP_PREFIX.length), attr.value);\n }\n\n const tree = parse(source);\n const asked = new Set<string>();\n substitute(tree, attrs, asked);\n\n // A parameter the definition never declared is a name that resolves to\n // nothing. Unprefixed attributes could not support this check, because a\n // stray one is indistinguishable from a deliberate HTML attribute.\n for (const name of attrs.keys()) {\n if (asked.has(name)) continue;\n throw new Error(\n `expand: <${tag.toLowerCase()}> was given ${EXP_PREFIX}${name}, ` +\n `but its definition has no {{${name}}}.`,\n );\n }\n // Named destinations first: what they take is addressed to them, and only\n // what is left is the slot's.\n fillSlot(tag, tree, fillTemplates(tag, tree, [...el.childNodes]));\n el.replaceChildren(...tree.childNodes);\n}\n\nfunction walk(root: ParentNode, defs: Definitions): void {\n for (const child of [...root.children]) {\n const source = defs[child.tagName.toUpperCase()];\n // A tag with no definition is left alone. It is a custom element a\n // script registers, and build/elements.ts is where a tag that has\n // neither a definition nor a script is refused — one rule, one place.\n if (source !== undefined) expandElement(child, defs, source);\n // Definitions may use other widgets, so descend after expanding. The\n // acyclicity check is what makes this terminate.\n walk(child, defs);\n // Template content is markup in a file like any other, and it is inert,\n // so a row template ships already expanded.\n if (child instanceof HTMLTemplateElement) walk(child.content, defs);\n }\n}\n\n/**\n * Expand every widget tag in an authored page. Throws rather than shipping.\n *\n * Definitions must come from `loadDefinitions`, which is where the graph is\n * checked for cycles. Handed a cyclic map directly, this recurses forever.\n */\nexport function expand(source: string, defs: Definitions): string {\n const tree = parse(source);\n walk(tree, defs);\n return tree.innerHTML;\n}\n"]}
@@ -43,3 +43,4 @@ export async function formatHtml(source) {
43
43
  return source;
44
44
  }
45
45
  }
46
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../build/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,yEAAyE;YACzE,sEAAsE;YACtE,uEAAuE;YACvE,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,6DAA6D,GAAG,EAAE,CACnE,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Pretty-printing the assembled document — cosmetic, and deliberately so.\n *\n * Loadbare App ships the DOM the browser holds, so view-source is a real view of the\n * application. That only pays if it is legible. Expansion produces correct\n * markup but inherits its whitespace from the definition files, so the\n * assembled document reads like a concatenation, which is what it is.\n *\n * So prettier is a dependency rather than something an application author has\n * to know to add: legible output is the default install's job, not an\n * easter egg for whoever reads a warning closely enough to act on it. It runs\n * on the whole document once, after everything is assembled, and the one way\n * it can fail — throwing on a document — leaves the unformatted string in\n * place.\n *\n * Ignoring the throw is the point rather than an oversight. The correct output\n * is what `expand` already returned; formatting only makes it pleasant. If a\n * failure could fail the build, we would end up writing checks upstream whose\n * only purpose was to keep the formatter happy, and an error message about\n * markup the author never wrote is worse than an ugly line. So: nothing in this\n * codebase exists to keep prettier from throwing. It either helps or it doesn't.\n *\n * The one failure that would retire this outright is whitespace. Whitespace is\n * semantic in inline contexts — `<label>Name <input></label>` needs that space —\n * and prettier has no display information for `lb-*` elements. If formatting\n * is ever observed to change what renders, delete this file. A prettier page\n * that shows the wrong thing is not a trade worth making.\n */\n\n/** Format if we can, and return the input unchanged if we cannot. */\nexport async function formatHtml(source: string): Promise<string> {\n try {\n const prettier = await import(\"prettier\");\n return await prettier.format(source, {\n parser: \"html\",\n // The default. Prettier respects each element's CSS display default when\n // deciding where whitespace may move, and treats elements it does not\n // know — every hub widget — as inline, which is the conservative side.\n htmlWhitespaceSensitivity: \"css\",\n });\n } catch (err) {\n console.warn(\n `loadbare: shipping unformatted markup, prettier declined: ${err}`,\n );\n return source;\n }\n}\n"]}
@@ -32,9 +32,9 @@ export interface PageFile {
32
32
  file: string;
33
33
  }
34
34
  export interface PageSource {
35
- /** Absolute path, without extension, to the `.requests.ts` module, if this page has one. */
35
+ /** Absolute path to the `.requests.ts` module, if this page has one. */
36
36
  requests?: string;
37
- /** Absolute path, without extension, to the `.queries.ts` module, if this page has one. */
37
+ /** Absolute path to the `.queries.ts` module, if this page has one. */
38
38
  queries?: string;
39
39
  }
40
40
  interface Discovered {
@@ -1 +1 @@
1
- {"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../build/locations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQlD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAA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QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,UAAU;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,gHAAgH;AAChH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAyClE;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC;AAEtC,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAmBxD;AAED,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CA2D7E"}
@@ -70,12 +70,10 @@ export async function discoverSrc(src) {
70
70
  pages.push({ name: entry.name.slice(0, -PAGE_SUFFIX.length), file });
71
71
  }
72
72
  else if (entry.name.endsWith(HOOKS_SUFFIX)) {
73
- pageSource(entry.name.slice(0, -HOOKS_SUFFIX.length)).requests =
74
- file.slice(0, -".ts".length);
73
+ pageSource(entry.name.slice(0, -HOOKS_SUFFIX.length)).requests = file;
75
74
  }
76
75
  else if (entry.name.endsWith(QUERIES_SUFFIX)) {
77
- pageSource(entry.name.slice(0, -QUERIES_SUFFIX.length)).queries =
78
- file.slice(0, -".ts".length);
76
+ pageSource(entry.name.slice(0, -QUERIES_SUFFIX.length)).queries = file;
79
77
  }
80
78
  }
81
79
  pages.sort((a, b) => a.name.localeCompare(b.name));
@@ -145,3 +143,4 @@ export async function resolveLocations(args) {
145
143
  outDir: args.out,
146
144
  };
147
145
  }
146
+ //# sourceMappingURL=locations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locations.js","sourceRoot":"","sources":["../../build/locations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAqBtC,gHAAgH;AAChH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QAC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,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,CAAC,IAAI,GAAG,WAAW,gBAAgB;gBAClE,IAAI,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,0BAA0B;gBACnE,gCAAgC,CACnC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,GAAG,YAAY,SAAS,IAAI,GAAG,cAAc,gBAAgB;gBAC9E,IAAI,IAAI,CAAC,GAAG,sBAAsB,IAAI,GAAG,WAAW,GAAG,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,IAAI,CAAC,GAAG;QAChB,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAE;QAChC,KAAK;QACL,WAAW;QACX,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,MAAM,EAAE,IAAI,CAAC,GAAG;KACjB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Finding the application's own files by what they're named, not by which\n * directory they happen to sit in.\n *\n * A page and a widget definition can be byte-for-byte identical markup —\n * the only thing that says which one a file is, is extrinsic to its\n * content. `pages/` vs. `widgets/` used to carry that meaning; here a\n * filename suffix does instead: `chrome.html` is the one chrome file, and\n * `*.page.html` is a page.\n *\n * A page's server half is named the same way: `*.requests.ts` and\n * `*.queries.ts` pair with a `*.page.html` by sharing its basename, and are\n * free to sit anywhere too. Either may be absent — a page with no data needs\n * neither — but one with no matching `*.page.html` is a naming mistake and\n * is rejected below.\n *\n * Widget definitions, widget scripts and stylesheets are not found here.\n * They arrive from more than one origin — this package's own widgets, an\n * imported package, or `src` — and all three are scanned the same way by\n * build/origins.ts. `src` is simply the last origin in that cascade.\n *\n * `--src` names the one tree scanned this way; `--out` names where the\n * build lands. Those, plus this package's own root (for its built-in\n * widgets and hub/), are the only locations this module resolves — every\n * other module takes the result as a plain parameter and never\n * reconstructs one of its own.\n */\n\nimport { readdir, readFile } from \"node:fs/promises\";\nimport type { Dirent } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { findPackageRoot } from \"./package-root.js\";\nimport type { BuiltinDirs } from \"./origins.js\";\n\nexport { CUSTOM_ELEMENT_TAG } from \"./origins.js\";\n\nconst CHROME_FILENAME = \"chrome.html\";\nconst PAGE_SUFFIX = \".page.html\";\nconst HOOKS_SUFFIX = \".requests.ts\";\nconst QUERIES_SUFFIX = \".queries.ts\";\nconst IMPORTS_FILENAME = \"imports.ts\";\n\nexport interface PageFile {\n name: string;\n file: string;\n}\n\nexport interface PageSource {\n /** Absolute path to the `.requests.ts` module, if this page has one. */\n requests?: string;\n /** Absolute path to the `.queries.ts` module, if this page has one. */\n queries?: string;\n}\n\ninterface Discovered {\n chromeCandidates: string[];\n pages: PageFile[];\n pageSources: Map<string, PageSource>;\n importsCandidates: string[];\n}\n\n/** The raw walk, with no uniqueness checks — usable on its own by anything that does not need a chrome file. */\nexport async function discoverSrc(src: string): Promise<Discovered> {\n const chromeCandidates: string[] = [];\n const pages: PageFile[] = [];\n const pageSources = new Map<string, PageSource>();\n const importsCandidates: string[] = [];\n\n let entries: Dirent[];\n try {\n entries = await readdir(src, { withFileTypes: true, recursive: true });\n } catch {\n entries = [];\n }\n\n const pageSource = (name: string): PageSource => {\n let p = pageSources.get(name);\n if (!p) {\n p = {};\n pageSources.set(name, p);\n }\n return p;\n };\n\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n const file = path.join(entry.parentPath, entry.name);\n\n if (entry.name === IMPORTS_FILENAME) {\n importsCandidates.push(file);\n } else if (entry.name === CHROME_FILENAME) {\n chromeCandidates.push(file);\n } else if (entry.name.endsWith(PAGE_SUFFIX)) {\n pages.push({ name: entry.name.slice(0, -PAGE_SUFFIX.length), file });\n } else if (entry.name.endsWith(HOOKS_SUFFIX)) {\n pageSource(entry.name.slice(0, -HOOKS_SUFFIX.length)).requests = file;\n } else if (entry.name.endsWith(QUERIES_SUFFIX)) {\n pageSource(entry.name.slice(0, -QUERIES_SUFFIX.length)).queries = file;\n }\n }\n\n pages.sort((a, b) => a.name.localeCompare(b.name));\n return { chromeCandidates, pages, pageSources, importsCandidates };\n}\n\nexport type PackageInfo = BuiltinDirs;\n\nexport async function packageInfo(): Promise<PackageInfo> {\n const here = path.dirname(fileURLToPath(import.meta.url));\n const root = await findPackageRoot(here);\n let pkg: { name: string };\n try {\n pkg = JSON.parse(await readFile(path.join(root, \"package.json\"), \"utf-8\"));\n } catch (err) {\n throw new Error(\n `locations: could not read '${root}/package.json': ${(err as Error).message}`,\n );\n }\n return {\n // `hub/` beside this module, not beside package.json: running from source\n // that is the package's own hub/, and running compiled it is dist/hub —\n // the one an installed package ships, since `files` carries dist and not\n // the source tree.\n builtinHubDir: path.join(path.dirname(here), \"hub\"),\n packageName: pkg.name,\n };\n}\n\nexport interface LocationArgs {\n /** The application's source tree, e.g. \"src\". Scanned as a whole — see this file's header. */\n src: string;\n out: string;\n}\n\nexport interface Locations extends PackageInfo {\n srcDir: string;\n chromeFile: string;\n pages: PageFile[];\n pageSources: Map<string, PageSource>;\n importsFile?: string;\n outDir: string;\n}\n\nexport async function resolveLocations(args: LocationArgs): Promise<Locations> {\n const [info, discovered] = await Promise.all([\n packageInfo(),\n discoverSrc(args.src),\n ]);\n const { chromeCandidates, importsCandidates, pages, pageSources } =\n discovered;\n\n if (chromeCandidates.length === 0) {\n throw new Error(\n `locations: no ${CHROME_FILENAME} file found under '${args.src}'`,\n );\n }\n if (chromeCandidates.length > 1) {\n throw new Error(\n `locations: more than one ${CHROME_FILENAME} file found under '${args.src}': ` +\n chromeCandidates.join(\", \"),\n );\n }\n if (importsCandidates.length > 1) {\n throw new Error(\n `locations: more than one ${IMPORTS_FILENAME} found under '${args.src}': ` +\n importsCandidates.join(\", \"),\n );\n }\n\n // Sorted by name above, so duplicates are adjacent. A stub is the page's\n // whole identity — its route, its template and its server half all key on\n // it — so two files claiming one stub is a naming mistake, not a merge.\n for (let i = 1; i < pages.length; i++) {\n const [prev, here] = [pages[i - 1]!, pages[i]!];\n if (prev.name === here.name) {\n throw new Error(\n `locations: more than one '${here.name}${PAGE_SUFFIX}' found under ` +\n `'${args.src}': ${prev.file}, ${here.file}; the page namespace is ` +\n `flat, so a stub names one page`,\n );\n }\n }\n\n const pageNames = new Set(pages.map((p) => p.name));\n for (const name of pageSources.keys()) {\n if (!pageNames.has(name)) {\n throw new Error(\n `locations: '${name}${HOOKS_SUFFIX}' or '${name}${QUERIES_SUFFIX}' found under ` +\n `'${args.src}' but there is no '${name}${PAGE_SUFFIX}'`,\n );\n }\n }\n\n return {\n ...info,\n srcDir: args.src,\n chromeFile: chromeCandidates[0]!,\n pages,\n pageSources,\n ...(importsCandidates[0] ? { importsFile: importsCandidates[0] } : {}),\n outDir: args.out,\n };\n}\n"]}
@@ -324,3 +324,4 @@ export async function scanAll(builtin, src, importsFile) {
324
324
  export function cssFrom(scans) {
325
325
  return scans.flatMap((scan) => scan.css);
326
326
  }
327
+ //# sourceMappingURL=origins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origins.js","sourceRoot":"","sources":["../../build/origins.ts"],"names":[],"mappings":"AAAA;;;;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EACX,WAAoB;IAEpB,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * Where a build's files come from — see docs/reference/builder.md.\n *\n * Three kinds of file reach the assembled application: a `.html` definition\n * that expands a tag, a `.browser.ts` script that registers its class, and a\n * `.css` stylesheet. All three arrive from the same places, so all three are\n * found the same way: one ordered list of origins, scanned once each, read by\n * whoever needs them.\n *\n * A script says `.browser` because shipping is the thing worth being sure\n * about. Under a plain `lb-thing.ts` rule a filename alone decides what\n * crosses to the browser, so a module named after a tag someone else writes\n * later is bundled without anyone having chosen that — and the author who\n * would most like to know is the one who never considered it. Requiring the\n * word puts the decision where a reader can see it, and leaves every\n * unmarked module in a source tree exactly what it looks like: not browser\n * code. It costs a widget author one word, once.\n *\n * The order is the cascade, and it is the same for every file kind:\n *\n * 1. this package's own `hub/`\n * 2. each package declared in `imports.ts`, in first-mention order\n * 3. the application's own `--src` tree\n *\n * A package contributes one directory of its own choosing — `loadbare.widgets`\n * in its package.json, or the whole package when it says nothing. See\n * `widgetDir` below for why a package gets to answer that.\n *\n * The one built-in origin holds one tag, `lb-hub`, and it is there because\n * every application has a hub whether or not it says so. A widget is not in\n * that position: `@loadbare/widgets` is a declared package like any other,\n * and the builder cannot tell it from someone else's.\n *\n * Two rules fall out of that list, and there is no third:\n *\n * - Within one origin, two files claiming the same tag are an error. That\n * is a typo, and the origin's own author is the one who can fix it.\n * - Across origins, the later one wins. An application always has the\n * final say over a package it imported, and a package over a built-in,\n * without anyone having to out-name a dependency they do not control.\n */\n\nimport { readdir, readFile, stat } from \"node:fs/promises\";\nimport type { Dirent } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/** Lowercase, hyphenated — the one shape every custom element tag has, and the one native elements never do. */\nexport const CUSTOM_ELEMENT_TAG = /^[a-z][a-z0-9]*(-[a-z0-9]+)+$/;\n\nconst HTML_SUFFIX = \".html\";\n/** A widget script says so in its name: `lb-thing.browser.ts` and nothing else. */\nconst BROWSER_SUFFIXES = [\".browser.ts\", \".browser.js\"];\n/** What an unmarked module ends in — enough to recognise a near miss and say so. */\nconst MODULE_SUFFIXES = [\".ts\", \".js\"];\nconst CSS_SUFFIX = \".css\";\n\nexport interface Origin {\n /** How this origin is named in an error message: a package name, or \"src\". */\n name: string;\n /** The roots to scan. */\n dirs: string[];\n /**\n * How a script from here is imported, when a bare specifier is wanted\n * instead of the scanned file's own path. Only this package's `hub/` uses\n * it: `lb-hub` is the package's main entry point rather than a file an\n * application should reach into.\n */\n specifier?: (tag: string) => string;\n}\n\nexport interface OriginScan {\n name: string;\n specifier?: (tag: string) => string;\n /** Tag to its `.html` definition. */\n definitions: Map<string, string>;\n /** Tag to its `.browser.ts` script, the trailing `.ts` stripped. */\n scripts: Map<string, string>;\n /**\n * Tag to the unmarked module that would have claimed it — `lb-thing.ts`\n * where `lb-thing.browser.ts` was meant. Nothing is built from this. It is\n * here so build/elements.ts can name the file when the tag turns out to\n * have nothing to register it.\n */\n unmarked: Map<string, string>;\n /** Every `.css` file here, sorted by filename with the full path breaking a tie. */\n css: string[];\n}\n\n/**\n * Every file under `dir`, its own nested `node_modules` excluded — those\n * belong to the packages that declare them, not to this one.\n */\nasync function filesUnder(dir: string): Promise<string[]> {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true, recursive: true });\n } catch {\n return [];\n }\n return entries\n .filter((entry) => {\n if (!entry.isFile()) return false;\n const relative = path.relative(dir, entry.parentPath);\n return !relative.split(path.sep).includes(\"node_modules\");\n })\n .map((entry) => path.join(entry.parentPath, entry.name));\n}\n\n/**\n * One origin's contribution, classified by filename alone.\n *\n * A `.html` file is a widget's only when its basename is a tag, and a module\n * only when it is `<tag>.browser.ts` — which is what excludes `chrome.html`,\n * `about.page.html`, `about.requests.ts` and `imports.ts` here without naming\n * any of them. Those are the application's own files, and\n * build/locations.ts picks them out of `src` separately.\n *\n * A module named after a tag without the `.browser` goes in `unmarked`, so\n * an author who forgot the word gets told which file to rename rather than\n * being told their tag does not exist.\n */\n/**\n * The tag a filename claims, or null when it claims none.\n *\n * A filename is the tag verbatim, never folded. HTML matches an element name\n * case-insensitively, so folding would let `My-Widget.html` and\n * `my-widget.html` be two files for one tag — a collision on a\n * case-sensitive filesystem and one file on a case-insensitive one, which is\n * a difference between machines rather than a rule anyone can read.\n *\n * A name that is a tag only once folded is refused rather than ignored: the\n * author meant a widget, and silence would leave them with a tag that never\n * expands.\n */\nfunction tagIn(stem: string, file: string): string | null {\n if (CUSTOM_ELEMENT_TAG.test(stem)) return stem;\n const folded = stem.toLowerCase();\n if (!CUSTOM_ELEMENT_TAG.test(folded)) return null;\n const suffix = path.basename(file).slice(stem.length);\n throw new Error(\n `origins: '${file}' carries capitals; a tag is lowercase, so this ` +\n `file must be named '${folded}${suffix}'`,\n );\n}\n\nexport async function scanOrigin(origin: Origin): Promise<OriginScan> {\n const definitions = new Map<string, string>();\n const scripts = new Map<string, string>();\n const unmarked = new Map<string, string>();\n const css: string[] = [];\n\n const claim = (\n into: Map<string, string>,\n what: string,\n tag: string,\n file: string,\n ): void => {\n const already = into.get(tag);\n if (already) {\n throw new Error(\n `origins: '${origin.name}' has two ${what} files for <${tag}>: ` +\n `'${already}' and '${file}'`,\n );\n }\n into.set(tag, file);\n };\n\n for (const dir of origin.dirs) {\n for (const file of await filesUnder(dir)) {\n const name = path.basename(file);\n if (name.endsWith(CSS_SUFFIX)) {\n css.push(file);\n } else if (name.endsWith(HTML_SUFFIX)) {\n const tag = tagIn(name.slice(0, -HTML_SUFFIX.length), file);\n if (tag) claim(definitions, \"definition\", tag, file);\n } else {\n const browser = BROWSER_SUFFIXES.find((s) => name.endsWith(s));\n if (browser) {\n const tag = tagIn(name.slice(0, -browser.length), file);\n // Only the trailing \".ts\" comes off, never the \".browser\": what is\n // left becomes an import specifier, and esbuild resolves\n // \"lb-thing.browser\" to \"lb-thing.browser.ts\" the same way as to\n // \".js\".\n if (tag) {\n const ext = MODULE_SUFFIXES.find((e) => name.endsWith(e))!;\n claim(scripts, \"script\", tag, file.slice(0, -ext.length));\n }\n continue;\n }\n const ext = MODULE_SUFFIXES.find((e) => name.endsWith(e));\n if (!ext) continue;\n // A module whose name is a tag but which never said it was browser\n // code. It contributes nothing. Remembering it costs a map entry and\n // buys an error message that names the file instead of describing an\n // absence. A `.d.ts` never reaches here — stripping \".ts\" leaves a\n // dot, which is not a tag. Tested rather than tagIn()'d: an unmarked\n // module was never claimed to be a widget, so a capital in its name\n // is not a mistake anyone here can see.\n const tag = name.slice(0, -ext.length);\n if (CUSTOM_ELEMENT_TAG.test(tag) && !unmarked.has(tag)) {\n unmarked.set(tag, file);\n }\n }\n }\n }\n\n // By filename first, the full path only to break a tie. A directory a file\n // happens to sit in never affects the order.\n css.sort(\n (a, b) =>\n path.basename(a).localeCompare(path.basename(b)) || a.localeCompare(b),\n );\n\n return {\n name: origin.name,\n ...(origin.specifier ? { specifier: origin.specifier } : {}),\n definitions,\n scripts,\n unmarked,\n css,\n };\n}\n\n/** The shape of an `imports.ts` module's default export: the packages an application pulls widgets from. */\nexport type ElementManifest = string[];\n\n/**\n * `imports.ts`, executed rather than parsed — it runs through the same\n * loader as the rest of the build, so it is ordinary TypeScript, not a data\n * format with its own rules. It lists the packages an application pulls\n * widgets from, and each one becomes an origin, scanned exactly as `src` is.\n */\nexport async function loadElementManifest(\n file: string,\n): Promise<ElementManifest> {\n let mod: { default?: unknown };\n try {\n // pathToFileURL requires an absolute path; the caller's may not be one.\n mod = (await import(pathToFileURL(path.resolve(file)).href)) as {\n default?: unknown;\n };\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ERR_MODULE_NOT_FOUND\")\n return [];\n throw new Error(\n `elements: '${file}' failed to load: ${(err as Error).message}`,\n );\n }\n const declared = mod.default ?? [];\n if (!Array.isArray(declared)) {\n throw new Error(\n `imports.ts: must default-export an array of package names, got ${typeof declared}`,\n );\n }\n for (const name of declared) {\n if (typeof name !== \"string\" || name === \"\") {\n throw new Error(\n `imports.ts: every entry must be a package name, got ${JSON.stringify(name)}`,\n );\n }\n }\n return declared as ElementManifest;\n}\n\n/**\n * The ordinary node_modules walk, stopping at the first directory that has\n * the package installed — not a full resolution of an entry file, on\n * purpose: this only needs the package's root directory, and stopping short\n * avoids caring whether the package exposes an \"exports\" map at all. Which\n * part of that root holds the widgets is the package's own answer to give —\n * `widgetDir` asks it.\n */\nexport async function findInstalledPackage(\n packageName: string,\n fromDir: string,\n): Promise<string> {\n let dir = path.resolve(fromDir);\n for (;;) {\n const candidate = path.join(dir, \"node_modules\", packageName);\n try {\n await stat(path.join(candidate, \"package.json\"));\n return candidate;\n } catch {\n // not here — keep walking up\n }\n const parent = path.dirname(dir);\n if (parent === dir) {\n throw new Error(\n `origins: could not find installed package '${packageName}' above '${fromDir}'`,\n );\n }\n dir = parent;\n }\n}\n\n/**\n * Where in an installed package its widgets are, from the package's own\n * manifest:\n *\n * \"loadbare\": { \"widgets\": \"./dist\" }\n *\n * A package that says nothing has its whole directory scanned, which is what\n * every package got before this field existed.\n *\n * The field is here because a published package is not a source tree. It is a\n * distribution artifact with a shape npm defines — compiled output in `dist/`,\n * the source excluded, plus a README, a licence, docs and whatever else its\n * author ships — and scanning all of it makes every one of those files a\n * possible widget. A package that compiles then carries the same tag twice,\n * once as `.ts` and once as `.js`, and the duplicate-tag error fires on a\n * package the application does not control and cannot fix.\n *\n * So the package says where to look, and the rest of it is none of the\n * builder's business. This costs an application author nothing: they still\n * list the package in `imports.ts` and write no import statement. It costs the\n * package author one line, in the file npm already expects to carry exactly\n * this kind of declaration.\n */\nasync function widgetDir(root: string, packageName: string): Promise<string> {\n let manifest: { loadbare?: { widgets?: unknown } };\n try {\n manifest = JSON.parse(\n await readFile(path.join(root, \"package.json\"), \"utf-8\"),\n );\n } catch (err) {\n throw new Error(\n `origins: could not read the package.json of '${packageName}': ${(err as Error).message}`,\n );\n }\n\n const declared = manifest.loadbare?.widgets;\n if (declared === undefined) return root;\n\n if (typeof declared !== \"string\" || declared === \"\") {\n throw new Error(\n `origins: '${packageName}' has a \"loadbare.widgets\" that is not a path: ` +\n `${JSON.stringify(declared)}`,\n );\n }\n\n // A path out of the package would put a package's declaration in charge of\n // directories it does not own — including the application's own.\n const dir = path.resolve(root, declared);\n const inside = path.relative(root, dir);\n if (path.isAbsolute(declared) || inside.startsWith(\"..\")) {\n throw new Error(\n `origins: '${packageName}' declares widgets at '${declared}', which is outside the package`,\n );\n }\n\n // A declared directory that is not there means the package shipped without\n // its widgets — its build did not run, or `files` left the directory out.\n // Scanning the package root instead would find some of them and look like it\n // worked, so this stops.\n try {\n await stat(dir);\n } catch {\n throw new Error(\n `origins: '${packageName}' declares widgets at '${declared}', which is not in the installed package`,\n );\n }\n\n return dir;\n}\n\nexport interface BuiltinDirs {\n /** This package's own hub/ — where lb-hub's script lives, found the same way as any widget. */\n builtinHubDir: string;\n /** This package's own name, e.g. \"@loadbare/app\" — for naming the built-in's import specifier. */\n packageName: string;\n}\n\n/**\n * The cascade, in order. A declared package is an origin like any other: the\n * directory it points `loadbare.widgets` at is scanned the way `src` is — its\n * whole installed directory, when it points at nothing — and a widget there is\n * found by its filename, not by being named in a manifest.\n *\n * `hub/` is the only origin naming a specifier, because `lb-hub` is the\n * package's main entry point rather than a file to reach into.\n */\nexport async function buildOrigins(\n builtin: BuiltinDirs,\n declared: ElementManifest,\n src: string,\n): Promise<Origin[]> {\n const { builtinHubDir, packageName } = builtin;\n\n const packages: Origin[] = [];\n for (const name of declared) {\n const root = await findInstalledPackage(name, src);\n packages.push({ name, dirs: [await widgetDir(root, name)] });\n }\n\n return [\n {\n name: packageName,\n dirs: [builtinHubDir],\n specifier: () => packageName,\n },\n ...packages,\n { name: src, dirs: [src] },\n ];\n}\n\n/**\n * The whole cascade, scanned. Everything a build reads from disk that is not\n * a page, the chrome, or a page's server half comes back from here.\n */\nexport async function scanAll(\n builtin: BuiltinDirs,\n src: string,\n importsFile?: string,\n): Promise<OriginScan[]> {\n const declared = importsFile ? await loadElementManifest(importsFile) : [];\n const origins = await buildOrigins(builtin, declared, src);\n return Promise.all(origins.map(scanOrigin));\n}\n\n/** Every origin's stylesheets, concatenated in cascade order. */\nexport function cssFrom(scans: OriginScan[]): string[] {\n return scans.flatMap((scan) => scan.css);\n}\n"]}
@@ -22,3 +22,4 @@ export async function findPackageRoot(dir) {
22
22
  }
23
23
  }
24
24
  }
25
+ //# sourceMappingURL=package-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-root.js","sourceRoot":"","sources":["../../build/package-root.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,SAAS,CAAC;QACR,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;YACxD,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAC;YAClE,CAAC;YACD,GAAG,GAAG,MAAM,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Walk up from `dir` to the nearest ancestor holding a package.json.\n *\n * Needed because a caller may run from source (build/*.ts) or compiled\n * (dist/build/*.js) — both are the same distance from the package root, but\n * nothing here should assume that stays true.\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function findPackageRoot(dir: string): Promise<string> {\n for (;;) {\n try {\n await readFile(path.join(dir, \"package.json\"), \"utf-8\");\n return dir;\n } catch {\n const parent = path.dirname(dir);\n if (parent === dir) {\n throw new Error(`could not find a package.json above '${dir}'`);\n }\n dir = parent;\n }\n }\n}\n"]}
@@ -11,6 +11,10 @@
11
11
  * code, so it never needs a bundler step the way the browser-bound client
12
12
  * entry does.
13
13
  *
14
+ * Each import keeps its `.ts` extension. Node's loader, including its own
15
+ * type stripping, looks for exactly the path it is given and never tries an
16
+ * extension, so a path without one runs under tsx and nowhere else.
17
+ *
14
18
  * Nothing here is emitted for a page with neither a requests nor a queries
15
19
  * file — a purely static page needs no hub entry, and createHub is only
16
20
  * called at all when there is at least one.
@@ -1 +1 @@
1
- {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../build/pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAY3D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,EAAE,EACjB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAsCpB"}
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../build/pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAY3D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,EAAE,EACjB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAsCpB"}
@@ -11,6 +11,10 @@
11
11
  * code, so it never needs a bundler step the way the browser-bound client
12
12
  * entry does.
13
13
  *
14
+ * Each import keeps its `.ts` extension. Node's loader, including its own
15
+ * type stripping, looks for exactly the path it is given and never tries an
16
+ * extension, so a path without one runs under tsx and nowhere else.
17
+ *
14
18
  * Nothing here is emitted for a page with neither a requests nor a queries
15
19
  * file — a purely static page needs no hub entry, and createHub is only
16
20
  * called at all when there is at least one.
@@ -54,3 +58,4 @@ export function pagesSource(pages, pageSources, outDir, packageName) {
54
58
  }
55
59
  return ([...imports, "", "export const hub = createHub({", ...entries, "});"].join("\n") + "\n");
56
60
  }
61
+ //# sourceMappingURL=pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.js","sourceRoot":"","sources":["../../build/pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,qFAAqF;AACrF,SAAS,UAAU,CAAC,IAAY,EAAE,MAA8B;IAC9D,OAAO,QAAQ,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,IAAI,MAAM,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,MAAc,EAAE,IAAY;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,OAAO,GAAG,CA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O,CAAC,IAAI,CACV,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,UAAU,IAAI,IAAI,cAAc,SAAS,IAAI,IAAI,KAAK,CACjG,CAAC;IACJ,CAAC;IAED,OAAO,CACL,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,gCAAgC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,CACxE,IAAI,CACL,GAAG,IAAI,CACT,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Generating the hub's page registry — the server-side counterpart to\n * build/elements.ts's client entry point.\n *\n * `*.requests.ts` and `*.queries.ts` are ordinary TypeScript, found by\n * build/locations.ts and handed here already paired by page name. What this\n * module writes is the file an application used to hand-maintain: an import\n * of each pair, a `Pages` object naming them by page, and the one\n * `createHub()` call. It is written to `<out>/pages.ts` rather than compiled\n * — the application runs it directly, exactly as it does its own server\n * code, so it never needs a bundler step the way the browser-bound client\n * entry does.\n *\n * Each import keeps its `.ts` extension. Node's loader, including its own\n * type stripping, looks for exactly the path it is given and never tries an\n * extension, so a path without one runs under tsx and nowhere else.\n *\n * Nothing here is emitted for a page with neither a requests nor a queries\n * file — a purely static page needs no hub entry, and createHub is only\n * called at all when there is at least one.\n */\n\nimport path from \"node:path\";\nimport type { PageFile, PageSource } from \"./locations.js\";\n\n/** A page name may contain anything a filename can; an import identifier may not. */\nfunction identifier(name: string, suffix: \"Requests\" | \"Queries\"): string {\n return `page_${name.replace(/[^a-zA-Z0-9]/g, \"_\")}_${suffix}`;\n}\n\nfunction relativeImport(outDir: string, file: string): string {\n const rel = path.relative(outDir, file).split(path.sep).join(\"/\");\n return rel.startsWith(\".\") ? rel : `./${rel}`;\n}\n\n/**\n * `undefined` when no page has a requests or queries file — the caller writes\n * nothing in that case, the same way an app with no custom elements gets no\n * client entry beyond the built-ins.\n */\nexport function pagesSource(\n pages: PageFile[],\n pageSources: Map<string, PageSource>,\n outDir: string,\n packageName: string,\n): string | undefined {\n if (pageSources.size === 0) return undefined;\n\n const imports: string[] = [\n `import { createHub } from ${JSON.stringify(`${packageName}/server`)};`,\n ];\n const entries: string[] = [];\n\n for (const { name } of pages) {\n const source = pageSources.get(name);\n if (!source) continue;\n\n const requestsId = source.requests\n ? identifier(name, \"Requests\")\n : undefined;\n const queriesId = source.queries ? identifier(name, \"Queries\") : undefined;\n\n if (source.requests) {\n imports.push(\n `import { requests as ${requestsId} } from ${JSON.stringify(relativeImport(outDir, source.requests))};`,\n );\n }\n if (source.queries) {\n imports.push(\n `import { queries as ${queriesId} } from ${JSON.stringify(relativeImport(outDir, source.queries))};`,\n );\n }\n\n entries.push(\n ` ${JSON.stringify(name)}: { requests: ${requestsId ?? \"{}\"}, queries: ${queriesId ?? \"{}\"} },`,\n );\n }\n\n return (\n [...imports, \"\", \"export const hub = createHub({\", ...entries, \"});\"].join(\n \"\\n\",\n ) + \"\\n\"\n );\n}\n"]}
@@ -16,3 +16,4 @@ export async function stylesSource(cssFiles) {
16
16
  const parts = await Promise.all(cssFiles.map((file) => readFile(file, "utf-8")));
17
17
  return parts.join("\n");
18
18
  }
19
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../build/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAkB;IAElB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAChD,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Concatenating an application's CSS.\n *\n * There is no widget, page, or chrome concept here — every `.css` file\n * anywhere under `src` is joined, in the order build/locations.ts already\n * sorted them into, with nothing added, removed, or scoped. What ships is\n * exactly the concatenation of what was authored, the same \"view source is\n * what ships\" rule build/assemble.ts holds for markup. Ordering is the\n * author's own, by filename — see build/locations.ts for the convention.\n */\n\nimport { readFile } from \"node:fs/promises\";\n\n/** `undefined` when there is no CSS at all — the caller writes nothing in that case. */\nexport async function stylesSource(\n cssFiles: string[],\n): Promise<string | undefined> {\n if (cssFiles.length === 0) return undefined;\n const parts = await Promise.all(\n cssFiles.map((file) => readFile(file, \"utf-8\")),\n );\n return parts.join(\"\\n\");\n}\n"]}
@@ -163,3 +163,4 @@ export const LB_ENDPOINT = "/lb";
163
163
  // A client-side deadline for one round trip. fetch() has no deadline of its
164
164
  // own; past this the request is aborted and treated as a failure.
165
165
  export const LB_REQUEST_TIMEOUT_MS = 10_000;
166
+ //# sourceMappingURL=lb-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2DAA2D;AAC3D,kCAAkC;AAElC,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,2BAA2B;AAE3B,8CAA8C;AAC9C,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,mEAAmE;AACnE,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEjC,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEjC,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc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;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,yEAAyE;AACzE,2EAA2E;AAC3E,iBAAiB;AACjB,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC,oEAAoE;AACpE,4EAA4E;AAC5E,kEAAkE;AAClE,uEAAuE;AACvE,YAAY;AACZ,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC","sourcesContent":["// Every hub attribute name lives here. Nothing writes one as a string\n// literal — not a widget, not a page host, not a test. See\n// docs/reference/data-binding.md.\n\n// --- Binding (docs/reference/data-binding.md) ---------------------------\n// One containment ladder: a list holds rows, a row holds cells. Both scope\n// attributes take a name the server declares, and a nested one of either\n// kind begins a new scope.\n\n// Scopes DOM children to a named set of rows.\nexport const ATTR_LIST = \"lb-list\";\n\n// Scopes DOM children to one named row.\n//\n// A single-row scope is read-only. Every write operation needs a key, and a\n// key exists only on a live row the hub stamped inside a list, so a declared\n// action is the only thing such a scope can send. An application that wants\n// a writable single row declares a list that answers with one row.\nexport const ATTR_ROW = \"lb-row\";\n\n// Named on a row template by the developer: the column that identifies a row\n// of the list. A property of the list rather than of the template — a list\n// without a fixed key column is meaningless — but written where the rows\n// land, because that is the only place the page says anything about them.\nexport const ATTR_KEY = \"lb-key\";\n\n// Stamped on a live row by the row machinery: that row's value of the column\n// ATTR_KEY names. Written by the hub, never by a developer, and read back by\n// whatever needs to know which row it is inside — a delete button, an update\n// form, a widget building its own request, or a stylesheet.\nexport const ATTR_KEY_VALUE = \"lb-key-value\";\n\n// The column an element displays.\n//\n// Its value is a column name and never a cell name. A cell has no name of\n// its own: it is identified by its row and its column, and the row arrives\n// from scope, so the column is all that is left to say. ATTR_KEY holds a\n// column name for the same reason.\nexport const ATTR_CELL = \"lb-cell\";\n\nexport const ATTR_VALUE = \"lb-value\";\n\n// Stamped on a list scope by the shared row machinery: how many rows it is\n// showing. Written by the hub and never bound to — it is derived from rows\n// the hub already knows, exactly as the section heading in lb-table is. A\n// list widget watches it, and it exists so that \"no members yet\" is a\n// stylesheet rule rather than a conditional in every list widget.\nexport const ATTR_ROW_COUNT = \"lb-row-count\";\n\n// --- Requests (docs/reference/data-binding.md) --------------------------\n// One event name, used by a widget reaching the server and by a widget\n// reaching an ancestor widget.\nexport const LB_EVENT_NAME = \"lb-request\";\n\n// Names what an interaction asks for.\n//\n// One attribute name, one wire field, one set of values: the request field\n// `action` carries this attribute's value verbatim, and nothing is\n// translated in between. On a native element the hub turns the element's own\n// event into the request — a form submits, anything else clicks; on a\n// widget, the widget builds it from whatever interaction it owns.\nexport const ATTR_ACTION = \"lb-action\";\n\n// --- Reserved names ----------------------------------------------------\n// Loadbare owns every value beginning with this prefix, in every lb-*\n// attribute: a name so prefixed is the hub's own (NAV_ROW), and an\n// lb-action so prefixed is an operation (below). The server refuses a page\n// that declares a query or an action beginning with it, so a new reserved\n// name can never collide with one an application already uses.\n//\n// It is also the whole of the wire discriminant. A request whose `action`\n// begins with it is one of the four operations; anything else is a name the\n// page declared under its requests. Nothing else tells them apart.\nexport const LB_RESERVED_PREFIX = \"lb-\";\n\n// On a <form> in a list scope: builds a new row on submit. The hub gathers\n// every lb-cell inside the form into a values map — no key, because there is\n// no row yet — and the form's own lb-list says which list it is inserting\n// into.\nexport const ACTION_ROW_INSERT = \"lb-row-insert\";\n\n// Deletes the row the element is inside. Needs no declared name: it takes\n// only the row's own lb-list/lb-key-value binding, which is all the server\n// needs to know which row and whether the operation is permitted on it.\nexport const ACTION_ROW_DELETE = \"lb-row-delete\";\n\n// On a <form> inside a live row: commits several cells of that row at once\n// on submit — the batch counterpart to a cell change. The hub gathers the\n// same values map, plus the row's own lb-key-value: a form that is a list's\n// row template root, or sits inside one, has both from its ancestors exactly\n// as a delete button does.\nexport const ACTION_ROW_UPDATE = \"lb-row-update\";\n\n// On a widget wrapping one control: commits that one cell when the control\n// changes. The hub never sends this itself — a native element has no widget\n// to decide what a change is — so a widget that carries it builds the\n// operation from its own lb-list/lb-key-value/lb-cell binding.\nexport const ACTION_CELL_CHANGE = \"lb-cell-change\";\n\n// Every reserved lb-action, in one place, so the builder can refuse an\n// unknown one and the hub can refuse to send one it does not implement.\nexport const LB_ACTIONS = [\n ACTION_ROW_INSERT,\n ACTION_ROW_DELETE,\n ACTION_ROW_UPDATE,\n ACTION_CELL_CHANGE,\n] as const;\n\n// --- Expansion (docs/reference/custom-elements.md) ---------------------\n// Marks the element in a definition whose children receive the authored\n// inner content. An attribute rather than an element because HTML content\n// models discard foreign elements inside <select> and <table>.\nexport const ATTR_SLOT = \"lb-slot\";\n\n// One name in two positions. In a definition it marks a destination; on an\n// authored <template> it names the destination that template is for, and the\n// template is unwrapped into it.\n//\n// It exists because the parser, not the content model, is the obstacle. A\n// <thead> written inside <lb-table> on a page is not in a table, so the\n// tokenizer drops the tag and keeps the text. A <template> survives anywhere\n// and its contents parse as if they were in a table, so wrapping the markup\n// is what gets it to expansion intact — and unwrapping it is what puts real\n// elements in the shipped document.\nexport const ATTR_TEMPLATE = \"lb-template\";\n\n// --- Host channel (docs/reference/chrome.md) ---------------------------\n// Only anchors carrying this are intercepted, so external links are never\n// hijacked.\nexport const ATTR_NAV_LINK = \"lb-nav-link\";\n\n// A page host ships as <template lb-page=\"<name>\">. An attribute rather than\n// an id: an id lives in the application's own namespace, where a page named\n// for something the chrome also ids would collide, and getElementById()\n// answers a collision by silently picking one.\nexport const ATTR_PAGE = \"lb-page\";\n\n// The hub's own row. Landed on every navigation, on any subtree inside the\n// hub that names it, through the same applyData() a server answer goes\n// through — so a chrome displays where the page is the way it displays\n// anything else. One row rather than a list, so a subtree binds it with\n// lb-row. A reserved name (LB_RESERVED_PREFIX): the server refuses to\n// declare a query so named.\nexport const NAV_ROW = \"lb-navigation\";\n\n// Its two columns. The label is the nav's: the text of the lb-nav-link\n// anchor whose href names the current page, and empty when no anchor does.\n// The URI is the path as the browser has it.\nexport const NAV_CELL_LABEL = \"page-label\";\nexport const NAV_CELL_URI = \"page-uri\";\n\n// Marks the chrome's own <dialog> for a page name that resolves to no\n// template — a routing miss discovered client-side, not an HTTP 404 (every\n// route gets the same 200 response; see docs/tutorials/010-pages-and-navigation.md).\n// The hub only opens it; what it says comes from NAV_ROW, which the dialog\n// consumes like any other subtree, by naming it in lb-row. Optional: an\n// application that declares none gets today's console.error and nothing\n// more. The builder requires the element it's on to be a <dialog>\n// (build/assemble.ts), since the hub calls showModal() on it.\nexport const ATTR_UNKNOWN_PAGE = \"lb-unknown-page\";\n\n// The hub's own tag. It is exempt from the rule every other LB-* tag\n// follows: expansion does not require it to have a definition (build/expand.ts),\n// and the client build does not require it to have a script of its own\n// (build/elements.ts) — it is the framework's live element, always present,\n// registered once by the package's main entry point, not a widget an\n// application discovers or declares.\nexport const HUB_TAG_NAME = \"lb-hub\";\n\n// --- Request lifecycle --------------------------------------------------\n// Stamped on the element that dispatched a request — the button, form, or\n// widget itself — for the duration of its round trip. It carries no\n// meaning beyond \"in flight\": a stylesheet dims the element, or a custom\n// button widget watches it to disable itself, but the hub itself only sets\n// and clears it.\nexport const ATTR_PENDING = \"lb-pending\";\n\n// Stamped on the same element if that round trip failed — a non-2xx\n// response, a thrown application error, or a timeout, all alike. Cleared at\n// the start of that element's next request. What (if anything) an\n// application shows for it is undecided; this is only the fact that it\n// happened.\nexport const ATTR_ERROR = \"lb-error\";\n\n// --- Wire --------------------------------------------------------------\n// One path, one method: everything the hub asks of the server is a POST to\n// this path. Navigation is therefore the only GET an application serves,\n// which is what leaves the page name space unrestricted.\nexport const LB_ENDPOINT = \"/lb\";\n\n// A client-side deadline for one round trip. fetch() has no deadline of its\n// own; past this the request is aborted and treated as a failure.\nexport const LB_REQUEST_TIMEOUT_MS = 10_000;\n"]}
@@ -1,4 +1,4 @@
1
- import { ACTION_CELL_CHANGE, ACTION_ROW_DELETE, ACTION_ROW_INSERT, ACTION_ROW_UPDATE } from "./lb-constants";
1
+ import { ACTION_CELL_CHANGE, ACTION_ROW_DELETE, ACTION_ROW_INSERT, ACTION_ROW_UPDATE } from "./lb-constants.js";
2
2
  /**
3
3
  * One row: its columns, by name.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lb-types.d.ts","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;AAEvC,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,KAAK,CAE3D;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,UAAU,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACnB;IACE,MAAM,EAAE,OAAO,iBAAiB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,GACD;IAAE,MAAM,EAAE,OAAO,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CA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,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,IAAI,WAAW,CAEvE;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAExE,4EAA4E;IAC5E,YAAY,CAAC,IAAI,IAAI,CAAC;CACvB"}
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="dom" />
2
2
  // The wire vocabulary. Shared by browser and server.
3
- import { LB_RESERVED_PREFIX, } from "./lb-constants";
3
+ import { LB_RESERVED_PREFIX, } from "./lb-constants.js";
4
4
  export function isPatch(result) {
5
5
  return !Array.isArray(result);
6
6
  }
@@ -11,3 +11,4 @@ export function isPatch(result) {
11
11
  export function isOperation(request) {
12
12
  return request.action.startsWith(LB_RESERVED_PREFIX);
13
13
  }
14
+ //# sourceMappingURL=lb-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAKL,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAuC3B,MAAM,UAAU,OAAO,CAAC,MAAkB;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAwED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAmB;IAC7C,OAAO,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\n// The wire vocabulary. Shared by browser and server.\n\nimport {\n ACTION_CELL_CHANGE,\n ACTION_ROW_DELETE,\n ACTION_ROW_INSERT,\n ACTION_ROW_UPDATE,\n LB_RESERVED_PREFIX,\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 list — see docs/reference/server.md, \"Queries\".\n *\n * Rows named here arrive or are updated, keys in `drop` are gone, and\n * anything unnamed is left alone: its contents, and its place in whatever\n * order the widget is keeping. Add and remove are one result rather than two\n * because the interesting cases are both at once — a row whose sort key\n * changed has to move, a swap is one out and one in — and two messages would\n * paint the intermediate state.\n */\nexport interface Patch {\n rows?: Row[];\n drop?: unknown[];\n}\n\n/**\n * What a list answers with.\n *\n * An array is the entire set and therefore also the order: a row whose key\n * is not in it is gone. A Patch disturbs only what it names.\n *\n * `Array.isArray` tells the two apart, which is why no column name has to be\n * reserved to carry a discriminant. A list answering with an object is a\n * patch, because the declaration already said this name answers with rows.\n */\nexport type ListResult = Row[] | Patch;\n\nexport function isPatch(result: ListResult): result is Patch {\n return !Array.isArray(result);\n}\n\n/**\n * What any one name answers with. Which of the two it is comes from the\n * query's own declaration, never from inspecting the value.\n */\nexport type HubResult = Row | ListResult;\n\n/**\n * Every response on the data channel is the same shape, whether it is a cold\n * start or the narrowest refresh. The hub does not know which case it is in.\n *\n * A name rides as an object key and is labelled by nothing, which is why the\n * response direction never needed a noun for the addressable thing.\n */\nexport type HubData = Record<string, HubResult>;\n\n/**\n * The four operations — docs/reference/data-binding.md. The set is closed.\n *\n * `action` carries the value of `lb-action` verbatim, so the attribute, the\n * wire field and the CRUD key are one vocabulary with no translation step.\n * The scope field is `list` here because all four are list operations: each\n * needs a key, and a key exists only on a live row inside a list.\n */\nexport type LbOperation =\n | {\n action: typeof ACTION_ROW_INSERT;\n list: string;\n values: Record<string, string>;\n }\n | { action: typeof ACTION_ROW_DELETE; list: string; key: string }\n | {\n action: typeof ACTION_ROW_UPDATE;\n list: string;\n key: string;\n values: Record<string, string>;\n }\n | {\n action: typeof ACTION_CELL_CHANGE;\n list: string;\n key: string;\n cell: string;\n value: string;\n };\n\n/**\n * Everything that is not one of the four.\n *\n * The name is the application's and is looked up in the page's declared\n * actions. What keeps this from being an RPC endpoint is that the name must\n * already appear in the page's requests: the browser cannot reach anything the\n * page has not published, and there is no argument list — only where the\n * interaction happened and, where a control has one, its value.\n *\n * The scope field is `list` or `row`, whichever attribute scoped the element\n * the interaction came from, so an action fired from a single-row scope says\n * so. A button carries no value, so the server computes the whole of the new\n * state and the browser never displays a number it has not confirmed. A\n * `<select>` carries one, because the choice is the interaction.\n */\nexport interface DeclaredAction {\n action: string;\n list?: string;\n row?: string;\n key?: string;\n cell?: string;\n value?: string;\n}\n\nexport type HubRequest = LbOperation | DeclaredAction;\n\n/**\n * The reserved prefix is the whole of the discriminant. Nothing else tells\n * an operation from a declared action, on the wire or anywhere else.\n */\nexport function isOperation(request: HubRequest): request is LbOperation {\n return request.action.startsWith(LB_RESERVED_PREFIX);\n}\n\n/**\n * The two hooks a list widget may implement, both optional.\n *\n * The hub reconciles every list scope itself, so a widget supplies placement\n * and scaffolding and nothing else. A scope that implements neither is a\n * plain element with a row template inside it, which is why there is no\n * repeater widget.\n *\n * They are methods on an element the hub does not own, so they carry the\n * `lb` prefix that Loadbare reserves for exactly that — see\n * docs/reference/custom-elements.md.\n */\nexport interface ListHost {\n /**\n * Where a row belongs, called with the row detached on its first\n * appearance. Without it a row lands immediately before the template, so\n * rows accumulate in the order they arrive.\n */\n lbPlaceRow?(el: Element, row: Row, template: HTMLTemplateElement): void;\n\n /** Called once after a whole result has landed, for derived scaffolding. */\n lbRowsLanded?(): void;\n}\n"]}
@@ -1,4 +1,14 @@
1
- import { type HubData, type ListResult, type Row } from "../core/lb-types";
1
+ import { type HubData, type ListResult, type Row } from "../core/lb-types.js";
2
+ /**
3
+ * A form control whose state is its `value`: a `<select>`, a `<textarea>`,
4
+ * or an `<input>` of any type but checkbox, radio and file. Landing and
5
+ * gathering draw the same line, so a value read back from a form is the one
6
+ * that landed there.
7
+ *
8
+ * Told apart by tag name and type rather than by class, so it holds for an
9
+ * element from any document.
10
+ */
11
+ export declare function isValueControl(el: Element): el is HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
2
12
  /**
3
13
  * Fill one scope from one row.
4
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lb-apply.d.ts","sourceRoot":"","sources":["../../hub/lb-apply.ts"],"names":[],"mappings":"AA4BA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,KAAK,GAAG,EACT,MAAM,kBAAkB,CAAC;AAiD1B;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAMtD;AAoCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAgElE;AAED,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAkC/D"}
1
+ {"version":3,"file":"lb-apply.d.ts","sourceRoot":"","sources":["../../hub/lb-apply.ts"],"names":[],"mappings":"AA4BA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,KAAK,GAAG,EACT,MAAM,qBAAqB,CAAC;AAK7B;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,OAAO,GACV,EAAE,IAAI,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,CAMlE;AAgED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAMtD;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAgElE;AAED,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAkC/D"}