@homepages/concrete 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/CHANGELOG.md +336 -0
  2. package/README.md +28 -17
  3. package/codemods/fill-is-a-source.mjs +533 -0
  4. package/codemods/manifest.json +12 -0
  5. package/codemods/reads-replace-reconcile.mjs +285 -0
  6. package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
  7. package/dist/artifact/playground/client/index.html +1 -1
  8. package/dist/artifact/playground/host.mjs +23 -23
  9. package/dist/base.css +3 -8
  10. package/dist/browser/site-config.js +1 -16
  11. package/dist/browser/submit-lead.js +0 -31
  12. package/dist/cli/build/artifact.js +16 -23
  13. package/dist/cli/build/captures.js +0 -6
  14. package/dist/cli/build/esbuild.js +0 -17
  15. package/dist/cli/build/fixtures.js +15 -30
  16. package/dist/cli/build/icons.js +0 -3
  17. package/dist/cli/build/index.js +1 -1
  18. package/dist/cli/build/playground.js +4 -8
  19. package/dist/cli/build/sections.js +9 -30
  20. package/dist/cli/build/source.js +52 -27
  21. package/dist/cli/build/static.js +4 -25
  22. package/dist/cli/capture/bundle.js +0 -9
  23. package/dist/cli/capture/capture-browser.js +0 -14
  24. package/dist/cli/capture/capture.js +1 -8
  25. package/dist/cli/check/analyze.js +2 -5
  26. package/dist/cli/check/index.js +1 -1
  27. package/dist/cli/check/line-endings.js +52 -0
  28. package/dist/cli/check/load-workspace.js +3 -8
  29. package/dist/cli/check/portable-names.js +48 -0
  30. package/dist/cli/check/render/class-conflicts.js +0 -5
  31. package/dist/cli/check/render/html.js +0 -1
  32. package/dist/cli/check/render/invariants.js +0 -5
  33. package/dist/cli/check/render/island-frames.js +0 -25
  34. package/dist/cli/check/render/marker-coverage.js +0 -20
  35. package/dist/cli/check/render/nav.js +0 -33
  36. package/dist/cli/check/report.js +0 -3
  37. package/dist/cli/check/stages/bundles.js +1 -9
  38. package/dist/cli/check/stages/composition.js +3 -2
  39. package/dist/cli/check/stages/dependencies.js +7 -38
  40. package/dist/cli/check/stages/fixtures.js +3 -31
  41. package/dist/cli/check/stages/lint.js +2 -2
  42. package/dist/cli/check/stages/logic.js +3 -34
  43. package/dist/cli/check/stages/relations.js +46 -0
  44. package/dist/cli/check/stages/render.js +0 -1
  45. package/dist/cli/check/stages/sections.js +3 -3
  46. package/dist/cli/check/stages/stylesheet.js +1 -1
  47. package/dist/cli/check/stages/typecheck.js +5 -11
  48. package/dist/cli/check/stages/workspace.js +36 -14
  49. package/dist/cli/commands.js +9 -56
  50. package/dist/cli/currency/cache.js +4 -17
  51. package/dist/cli/currency/decide.js +0 -14
  52. package/dist/cli/currency/opt-out.js +0 -7
  53. package/dist/cli/currency/preamble.js +3 -24
  54. package/dist/cli/currency/prompt.js +0 -1
  55. package/dist/cli/currency/refresh.js +5 -12
  56. package/dist/cli/currency/resolve-latest.js +3 -64
  57. package/dist/cli/currency/version-order.js +0 -12
  58. package/dist/cli/dev/crop.js +0 -2
  59. package/dist/cli/dev/http.js +0 -13
  60. package/dist/cli/dev/index.js +3 -4
  61. package/dist/cli/dev/islands.js +25 -70
  62. package/dist/cli/dev/listen.js +26 -0
  63. package/dist/cli/dev/load-template.js +0 -1
  64. package/dist/cli/dev/request-error.js +0 -4
  65. package/dist/cli/dev/server.js +46 -52
  66. package/dist/cli/dev/tsconfig-paths.js +0 -13
  67. package/dist/cli/dev/vite.js +9 -38
  68. package/dist/cli/dev/workspace-reader.js +4 -34
  69. package/dist/cli/media/cache.js +4 -51
  70. package/dist/cli/media/derive.js +2 -94
  71. package/dist/cli/media/deriver-plugin.js +0 -2
  72. package/dist/cli/media/frame-rung-floor.js +0 -6
  73. package/dist/cli/property/index.js +0 -4
  74. package/dist/cli/property/library.js +6 -24
  75. package/dist/cli/publish/client.js +0 -1
  76. package/dist/cli/publish/freshness.js +0 -2
  77. package/dist/cli/publish/git.js +2 -8
  78. package/dist/cli/publish/index.js +8 -15
  79. package/dist/cli/publish/pack.js +5 -6
  80. package/dist/cli/publish/report.js +0 -6
  81. package/dist/cli/publish/target.js +16 -13
  82. package/dist/cli/publish/wire.js +0 -6
  83. package/dist/cli/tar.js +2 -9
  84. package/dist/cli/upgrade/codemod.js +0 -8
  85. package/dist/cli/upgrade/index.js +0 -24
  86. package/dist/cli/upgrade/manifest.js +0 -12
  87. package/dist/cli/upgrade/plan.js +0 -17
  88. package/dist/cli/upgrade/stage.js +12 -15
  89. package/dist/cli/version.js +0 -8
  90. package/dist/cli/workspace.js +2 -34
  91. package/dist/cli.js +4 -21
  92. package/dist/css/compile.js +25 -28
  93. package/dist/css/graph.js +3 -10
  94. package/dist/css/inline.js +3 -13
  95. package/dist/css/rules.js +6 -43
  96. package/dist/design-system/format-variants.js +0 -22
  97. package/dist/eslint/authoring.js +0 -2
  98. package/dist/eslint/correctness.js +0 -7
  99. package/dist/eslint/rules/editor-reason.js +0 -11
  100. package/dist/eslint/rules/island-ids.js +0 -1
  101. package/dist/eslint/rules/jsx-visitor.js +0 -13
  102. package/dist/eslint/rules/no-editor-globals.js +0 -2
  103. package/dist/eslint/rules/no-raw-values.js +0 -1
  104. package/dist/fixtures/brand.js +0 -1
  105. package/dist/fixtures/bundle-rule.js +4 -9
  106. package/dist/fixtures/canonical.d.ts +20 -0
  107. package/dist/fixtures/image-dimensions.js +0 -1
  108. package/dist/fixtures/load.js +8 -17
  109. package/dist/fixtures/media-plugin.js +4 -31
  110. package/dist/fixtures/media.js +0 -21
  111. package/dist/fixtures/package-stylesheets.js +0 -6
  112. package/dist/fixtures/property.js +16 -15
  113. package/dist/fixtures/resolve.js +102 -29
  114. package/dist/fixtures/rows.js +12 -11
  115. package/dist/fixtures/synthesize-empties.js +0 -4
  116. package/dist/fixtures.d.ts +19 -4
  117. package/dist/fixtures.js +0 -18
  118. package/dist/index.d.ts +8 -9
  119. package/dist/index.js +2 -11
  120. package/dist/islands/client-module.js +0 -11
  121. package/dist/islands/marker.js +0 -33
  122. package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
  123. package/dist/packages/external/concrete/package.js +1 -1
  124. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +21 -35
  125. package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
  126. package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
  127. package/dist/packages/internal/fill-bake/dist/display.js +0 -1
  128. package/dist/packages/internal/fill-bake/dist/index.js +4 -4
  129. package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
  130. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
  131. package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
  132. package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
  133. package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
  134. package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
  135. package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
  136. package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
  137. package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
  138. package/dist/packages/internal/island-runtime/dist/index.js +0 -34
  139. package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
  140. package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
  141. package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
  142. package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
  143. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
  144. package/dist/packages/internal/property-facts/dist/index.js +1 -1
  145. package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
  146. package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
  147. package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
  148. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
  149. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
  150. package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
  151. package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
  152. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
  153. package/dist/packages/internal/section-contracts/dist/index.js +2 -1
  154. package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
  155. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
  156. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
  157. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
  158. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
  159. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
  160. package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
  161. package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
  162. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
  163. package/dist/packages/internal/source-resolution/dist/index.js +1 -9
  164. package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
  165. package/dist/packages/internal/template-artifact/dist/index.js +1 -1
  166. package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
  167. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
  168. package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
  169. package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
  170. package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
  171. package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
  172. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
  173. package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
  174. package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
  175. package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
  176. package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
  177. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
  178. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
  179. package/dist/platform/file-url.js +8 -0
  180. package/dist/platform/fs.js +73 -0
  181. package/dist/platform/names.js +63 -0
  182. package/dist/platform/order.js +7 -0
  183. package/dist/platform/paths.js +62 -0
  184. package/dist/platform/process.js +97 -0
  185. package/dist/playground/host/page-state.js +0 -2
  186. package/dist/playground/host/paths.js +0 -1
  187. package/dist/playground/layout.js +0 -7
  188. package/dist/playground/wire.js +0 -8
  189. package/dist/primitives/FrameShell.js +0 -18
  190. package/dist/primitives/Image.d.ts +5 -1
  191. package/dist/primitives/Image.js +2 -68
  192. package/dist/primitives/Section.js +0 -13
  193. package/dist/primitives/Tour.js +0 -26
  194. package/dist/primitives/Video.js +0 -32
  195. package/dist/primitives/embed-playback.js +0 -1
  196. package/dist/primitives/marker-attrs.js +0 -17
  197. package/dist/primitives/picture-sources.js +6 -1
  198. package/dist/primitives/probe-context.js +0 -7
  199. package/dist/primitives/slot-bindings.js +0 -46
  200. package/dist/primitives/slot-document.js +0 -11
  201. package/dist/primitives/slot-group.js +0 -9
  202. package/dist/primitives/slot-media.js +0 -27
  203. package/dist/primitives/slot-scalar.js +0 -4
  204. package/dist/primitives/slot.js +0 -6
  205. package/dist/rules/registry.js +42 -24
  206. package/dist/schema/compute.d.ts +46 -8
  207. package/dist/schema/compute.js +21 -15
  208. package/dist/schema/define-schema.d.ts +1 -1
  209. package/dist/schema/define-schema.js +37 -17
  210. package/dist/schema/extract-fill-spec.js +93 -180
  211. package/dist/schema/extract-used-facts.js +16 -158
  212. package/dist/schema/fact.d.ts +25 -12
  213. package/dist/schema/fact.js +7 -11
  214. package/dist/schema/fill-builders.d.ts +91 -366
  215. package/dist/schema/fill-builders.js +21 -259
  216. package/dist/schema/fill-declaration.d.ts +7 -69
  217. package/dist/schema/fill-declaration.js +5 -34
  218. package/dist/schema/fill-spec.js +59 -148
  219. package/dist/schema/format-presets.js +0 -12
  220. package/dist/schema/format.js +0 -7
  221. package/dist/schema/layout.js +0 -10
  222. package/dist/schema/manifest.js +0 -39
  223. package/dist/schema/property-facts.d.ts +20 -0
  224. package/dist/schema/section-nav.js +0 -15
  225. package/dist/schema/section-schema.d.ts +0 -1
  226. package/dist/schema/section-schema.js +4 -20
  227. package/dist/schema/slot-builders.d.ts +128 -117
  228. package/dist/schema/slot-builders.js +18 -201
  229. package/dist/schema/slot-ref.d.ts +63 -0
  230. package/dist/schema/slot-ref.js +33 -0
  231. package/dist/schema/slot-types.d.ts +3 -2
  232. package/dist/schema/slot-types.js +11 -20
  233. package/dist/section/declare.d.ts +14 -10
  234. package/dist/section/declare.js +13 -2
  235. package/dist/section/discovery.js +6 -21
  236. package/dist/section/groups.js +0 -6
  237. package/dist/section/materialize.js +0 -5
  238. package/dist/section/placements.js +0 -4
  239. package/dist/section/section.d.ts +8 -5
  240. package/dist/section/section.js +7 -29
  241. package/dist/styles.css +5 -0
  242. package/dist/template/define-template.d.ts +0 -4
  243. package/dist/template/define-template.js +1 -15
  244. package/dist/template/logic-build.js +8 -35
  245. package/dist/template/logic-shim.d.ts +4 -5
  246. package/dist/template/logic-shim.js +2 -6
  247. package/dist/template/logic-transform.js +0 -6
  248. package/dist/template/materialize.js +52 -43
  249. package/dist/template/mirror-types.js +43 -0
  250. package/dist/template/running-copy.js +5 -20
  251. package/dist/template/section-reads.js +83 -0
  252. package/guide/reference/cli/INDEX.md +12 -6
  253. package/guide/reference/cli/build.md +1 -1
  254. package/guide/reference/cli/check.md +1 -1
  255. package/guide/reference/cli/dev.md +3 -3
  256. package/guide/reference/cli/property-add.md +1 -1
  257. package/guide/reference/cli/property-list.md +1 -1
  258. package/guide/reference/cli/publish.md +4 -2
  259. package/guide/reference/cli/upgrade.md +1 -1
  260. package/guide/reference/rules/INDEX.md +26 -13
  261. package/package.json +4 -2
  262. package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
  263. package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
  264. package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
  265. package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
  266. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
  267. package/dist/schema/fill-spec.d.ts +0 -18
  268. package/dist/template/reconcile.d.ts +0 -67
  269. package/dist/template/reconcile.js +0 -25
@@ -1,24 +1,46 @@
1
1
  import { DuplicateSectionKeyError, discoverSections } from "../../../section/discovery.js";
2
- import { loadWorkspace } from "../load-workspace.js";
2
+ import { TEMPLATE_FILE, loadWorkspace } from "../load-workspace.js";
3
+ import { loadFixtures } from "../../../fixtures/load.js";
4
+ import { listSourcePaths } from "../../build/source.js";
5
+ import { crlfTextViolations } from "../line-endings.js";
6
+ import { unportableNameViolations } from "../portable-names.js";
3
7
 
4
8
  //#region src/cli/check/stages/workspace.ts
5
9
  async function workspaceStage(ctx) {
6
10
  const workspace = await loadWorkspace(ctx.root);
7
11
  ctx.workspace = workspace;
8
- const violations = [...workspace.violations];
9
- if (workspace.template !== null) try {
10
- ctx.discovered = await discoverSections({
11
- root: ctx.root,
12
- importModule: (file) => Promise.resolve(workspace.modules.get(file) ?? {})
13
- });
14
- } catch (cause) {
15
- if (!(cause instanceof DuplicateSectionKeyError)) throw cause;
16
- violations.push({
17
- rule: "workspace/duplicate-section-key",
18
- file: cause.second.module,
19
- message: cause.message
20
- });
12
+ const violations = [...workspace.violations, ...await crlfTextViolations(ctx.root)];
13
+ if (workspace.template !== null) {
14
+ try {
15
+ ctx.discovered = await discoverSections({
16
+ root: ctx.root,
17
+ importModule: (file) => Promise.resolve(workspace.modules.get(file) ?? {})
18
+ });
19
+ } catch (cause) {
20
+ if (!(cause instanceof DuplicateSectionKeyError)) throw cause;
21
+ violations.push({
22
+ rule: "workspace/duplicate-section-key",
23
+ file: cause.second.module,
24
+ message: cause.message
25
+ });
26
+ }
27
+ ctx.fixtures = await loadFixtures({ root: ctx.root });
21
28
  }
29
+ violations.push(...unportableNameViolations({
30
+ sourcePaths: await listSourcePaths(ctx.root, []),
31
+ ...workspace.template === null ? {} : { template: {
32
+ name: workspace.template.key,
33
+ module: TEMPLATE_FILE
34
+ } },
35
+ sections: (ctx.discovered ?? []).map((site) => ({
36
+ name: site.section.key,
37
+ module: site.module
38
+ })),
39
+ fixtures: (ctx.fixtures?.fixtures ?? []).map((fixture) => ({
40
+ name: fixture.id,
41
+ module: fixture.module
42
+ }))
43
+ }));
22
44
  return { violations };
23
45
  }
24
46
 
@@ -1,18 +1,10 @@
1
1
  //#region src/cli/commands.ts
2
- /**
3
- * The escape hatch for the package-currency preamble, which runs in front of every
4
- * author command. Declared once and attached to all of them below rather than repeated
5
- * per command: the same predicate decides who runs the preamble and who documents the
6
- * flag that turns it off, so the two cannot drift into a command that refreshes
7
- * without saying it can be told not to.
8
- */
9
2
  const NO_AUTO_UPDATE = {
10
3
  name: "no-auto-update",
11
4
  type: "boolean",
12
5
  default: false,
13
6
  summary: "Skip the package refresh this command runs first when the workspace is behind the published release"
14
7
  };
15
- /** Where `build` writes when `--out` is absent. Gitignored by the scaffold. */
16
8
  const DEFAULT_BUILD_DIR = ".concrete/build";
17
9
  const DECLARED_COMMANDS = [
18
10
  {
@@ -23,11 +15,11 @@ const DECLARED_COMMANDS = [
23
15
  type: "string",
24
16
  valueLabel: "<n>",
25
17
  default: 5180,
26
- summary: "Port to serve on. A non-integer or non-positive value falls back to the default"
18
+ summary: "Port to serve on. A non-integer or non-positive value falls back to the default. The editor also opens its module-reload socket at this port + 100, so at most 65435"
27
19
  }],
28
20
  exits: [{
29
21
  code: 0,
30
- when: "the server is interrupted (Ctrl-C, SIGTERM) and shuts down cleanly"
22
+ when: "the server is interrupted (Ctrl-C, Ctrl+Break, closing its terminal, SIGTERM) and shuts down cleanly"
31
23
  }, {
32
24
  code: 1,
33
25
  when: "the server cannot start"
@@ -177,6 +169,12 @@ const DECLARED_COMMANDS = [
177
169
  type: "boolean",
178
170
  default: false,
179
171
  summary: "Print the settled publication record on stdout instead of the summary"
172
+ },
173
+ {
174
+ name: "env-file",
175
+ type: "string",
176
+ valueLabel: "<path>",
177
+ summary: "Read `CONCRETE_TOKEN` and `CONCRETE_API_URL` from this dotenv file instead of the workspace's `.env`"
180
178
  }
181
179
  ],
182
180
  exits: [
@@ -196,6 +194,7 @@ const DECLARED_COMMANDS = [
196
194
  constraints: [
197
195
  "The key is the environment: `CONCRETE_TOKEN` names production, staging or dev in its prefix (`cpt_prod_…`), and publish goes where it points. There is no environment flag.",
198
196
  "Reads `CONCRETE_TOKEN` from the environment, then from the workspace's `.env`. `CONCRETE_API_URL` replaces the endpoint the key's prefix names.",
197
+ "`--env-file <path>` names the key file instead, relative to the current directory: its values win over the environment and the workspace's `.env` is not read. It is how a library holding one key file per environment picks one, in any shell.",
199
198
  `Builds first when it matters: the artifact in \`${DEFAULT_BUILD_DIR}/\` is reused while the workspace's files match the ones it was built from, and rebuilt — check included — when they do not.`,
200
199
  "Prints one line per stage on stderr as it settles: target, build, upload, verify, write, adopt.",
201
200
  "Publishing a tree the environment already holds as current changes nothing, says so, and exits 0. Rolling back is publishing the older tree.",
@@ -204,34 +203,17 @@ const DECLARED_COMMANDS = [
204
203
  ]
205
204
  }
206
205
  ];
207
- /** One predicate, applied to a definition rather than a name — see the exported form. */
208
206
  const precededByPreamble = (command) => command.ownsPackageVersion !== true && command.reserved === void 0;
209
207
  const COMMANDS = DECLARED_COMMANDS.map((command) => precededByPreamble(command) ? {
210
208
  ...command,
211
209
  flags: [...command.flags, NO_AUTO_UPDATE]
212
210
  } : command);
213
- /**
214
- * Whether the currency preamble runs in front of `name`.
215
- *
216
- * An author's command against their own workspace, except the one that moves the
217
- * package's version itself and a reserved name with no body to run. The two global
218
- * flags, which are not commands at all, are outside it deliberately: they must keep
219
- * working when everything else about the workspace is broken.
220
- */
221
211
  function runsCurrencyPreamble(name) {
222
212
  return COMMANDS.some((command) => command.name === name && precededByPreamble(command));
223
213
  }
224
- /** Whether this invocation asked for the currency preamble to stay out of the way. */
225
214
  function hasNoAutoUpdateFlag(argv) {
226
215
  return argv.includes(`--${NO_AUTO_UPDATE.name}`);
227
216
  }
228
- /**
229
- * `argv` without the currency escape hatch.
230
- *
231
- * The dispatcher consumes that flag and no command parses it: it is read before the
232
- * command's module is even imported, and stripping it there is what keeps every
233
- * command's own parse a parse of the flags it declared.
234
- */
235
217
  function withoutNoAutoUpdateFlag(argv) {
236
218
  return argv.filter((arg) => arg !== `--${NO_AUTO_UPDATE.name}`);
237
219
  }
@@ -248,13 +230,11 @@ const GLOBAL_FLAGS = [{
248
230
  spellings: ["--help", "-h"],
249
231
  summary: "Print this message"
250
232
  }];
251
- /** Every spelling of a global flag, so the dispatcher spells none of them. */
252
233
  function globalFlagSpellings(name) {
253
234
  const flag = GLOBAL_FLAGS.find((f) => f.name === name);
254
235
  if (flag === void 0) throw new Error(`no global flag '${name}'`);
255
236
  return flag.spellings;
256
237
  }
257
- /** The members of the group `word` names, in table order; empty when it names no group. */
258
238
  function groupMembers(word) {
259
239
  return COMMANDS.filter((command) => command.name.startsWith(`${word} `));
260
240
  }
@@ -263,7 +243,6 @@ function findCommand(name) {
263
243
  if (found === void 0) throw new Error(`no command definition for '${name}'`);
264
244
  return found;
265
245
  }
266
- /** `--<name>`, so no entry point spells a flag as a string literal of its own. */
267
246
  function flagName(command, flag) {
268
247
  const found = command.flags.find((f) => f.name === flag);
269
248
  if (found === void 0) throw new Error(`'${command.name}' declares no flag '${flag}'`);
@@ -274,18 +253,6 @@ function flagDefault(command, flag) {
274
253
  if (found === void 0) throw new Error(`'${command.name}' declares no flag '${flag}'`);
275
254
  return found.default;
276
255
  }
277
- /**
278
- * The `options` object a command hands `node:util`'s `parseArgs`.
279
- *
280
- * Deriving it rather than writing it beside the definition is what makes the
281
- * definition load-bearing: an undeclared flag is not merely undocumented, it is
282
- * unparsed, so the two cannot drift apart in the direction that matters.
283
- *
284
- * A numeric default (only `dev --port`) is omitted rather than stringified — that
285
- * command validates and coerces its own value, and handing `parseArgs` a coerced
286
- * copy would make the definition's number and the parser's string two spellings of
287
- * one default.
288
- */
289
256
  function parseSpec(name) {
290
257
  const options = {};
291
258
  for (const flag of findCommand(name).flags) options[flag.name] = typeof flag.default === "boolean" || typeof flag.default === "string" ? {
@@ -294,14 +261,6 @@ function parseSpec(name) {
294
261
  } : { type: flag.type };
295
262
  return { options };
296
263
  }
297
- /**
298
- * Read one parsed flag back off `parseArgs`'s `values`.
299
- *
300
- * Deriving the options object from data costs its literal type, so `values` comes
301
- * back loosely typed. These two narrow it at the point of use — legible, and honest
302
- * about the runtime shape — rather than reaching for a generic that reconstructs the
303
- * literal type from `COMMANDS`.
304
- */
305
264
  function booleanFlag(values, name) {
306
265
  return values[name] === true;
307
266
  }
@@ -309,15 +268,9 @@ function stringFlag(values, name) {
309
268
  const value = values[name];
310
269
  return typeof value === "string" ? value : null;
311
270
  }
312
- /** `property add <slug>`: the name and its positionals, as help's command column prints it. */
313
271
  function commandLabel(command) {
314
272
  return [command.name, ...(command.args ?? []).map((arg) => `<${arg.name}>`)].join(" ");
315
273
  }
316
- /**
317
- * The `--help` message, built from the same definitions the pages are.
318
- *
319
- * `header` is passed in rather than read here so this module stays import-free.
320
- */
321
274
  function renderUsage(header) {
322
275
  const spelling = (f) => [...f.spellings].reverse().join(", ");
323
276
  const commandColumn = Math.max(...COMMANDS.map((c) => commandLabel(c).length)) + 2;
@@ -1,10 +1,9 @@
1
+ import { writeFileReplacing } from "../../platform/fs.js";
1
2
  import { dirname, join } from "node:path";
2
- import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
+ import { mkdir, readFile } from "node:fs/promises";
3
4
  import { z } from "zod";
4
- import { homedir } from "node:os";
5
5
 
6
6
  //#region src/cli/currency/cache.ts
7
- /** Below the injected root, so `XDG_CACHE_HOME` and a test fixture behave identically. */
8
7
  const CACHE_FILE_RELATIVE = join("homepages", "concrete-currency.json");
9
8
  const HIT_TTL_MS = 3600 * 1e3;
10
9
  const MISS_TTL_MS = 600 * 1e3;
@@ -13,20 +12,9 @@ const CACHE_SCHEMA = z.object({
13
12
  value: z.string().nullable(),
14
13
  checkedAt: z.number()
15
14
  }).optional(),
16
- /** version -> when it was declined. Bounded by the number of majors ever published. */
17
15
  declined: z.record(z.string(), z.number()).default({})
18
16
  });
19
17
  const EMPTY = { declined: {} };
20
- /**
21
- * The default root: `XDG_CACHE_HOME`, else `~/.cache`.
22
- *
23
- * The environment arrives as an argument even here, so the one place that reads an
24
- * ambient value is a caller's explicit choice to pass `process.env`.
25
- */
26
- function defaultCacheRoot(env) {
27
- const xdg = env.XDG_CACHE_HOME;
28
- return xdg !== void 0 && xdg !== "" ? xdg : join(homedir(), ".cache");
29
- }
30
18
  function openCurrencyCache(options) {
31
19
  const file = join(options.root, CACHE_FILE_RELATIVE);
32
20
  const read = async () => {
@@ -46,8 +34,7 @@ function openCurrencyCache(options) {
46
34
  const temporary = `${file}.${String(process.pid)}.tmp`;
47
35
  try {
48
36
  await mkdir(dirname(file), { recursive: true });
49
- await writeFile(temporary, `${JSON.stringify(next, null, 2)}\n`, "utf8");
50
- await rename(temporary, file);
37
+ await writeFileReplacing(temporary, file, `${JSON.stringify(next, null, 2)}\n`);
51
38
  } catch {}
52
39
  };
53
40
  return {
@@ -86,4 +73,4 @@ function openCurrencyCache(options) {
86
73
  }
87
74
 
88
75
  //#endregion
89
- export { CACHE_FILE_RELATIVE, HIT_TTL_MS, MISS_TTL_MS, defaultCacheRoot, openCurrencyCache };
76
+ export { CACHE_FILE_RELATIVE, HIT_TTL_MS, MISS_TTL_MS, openCurrencyCache };
@@ -1,12 +1,6 @@
1
1
  import { compareVersions, parseVersion } from "./version-order.js";
2
2
 
3
3
  //#region src/cli/currency/decide.ts
4
- /**
5
- * The rules that need no registry, cheapest first, each short-circuiting.
6
- *
7
- * The order is the point: opting out has to be the first rule or it is not an opt-out,
8
- * and neither rule needs anything the workspace does not already hold.
9
- */
10
4
  function decideLocally(signals) {
11
5
  if (signals.optedOut) return {
12
6
  state: "inert",
@@ -17,13 +11,6 @@ function decideLocally(signals) {
17
11
  reason: "not-a-registry-range"
18
12
  };
19
13
  }
20
- /**
21
- * Whether the registry has to be read at all.
22
- *
23
- * Defined by the same chain `decideCurrency` short-circuits on, rather than restated,
24
- * so the two can never drift into a caller that reads the network for a workspace
25
- * already decided without it.
26
- */
27
14
  function registryNeeded(signals) {
28
15
  return decideLocally(signals) === void 0;
29
16
  }
@@ -33,7 +20,6 @@ function blockedReason(signals, latest, crossesMajor) {
33
20
  if (crossesMajor && signals.declinedVersions.includes(latest)) return "declined";
34
21
  return null;
35
22
  }
36
- /** Total: every signals object maps to exactly one decision, and nothing throws. */
37
23
  function decideCurrency(signals) {
38
24
  const local = decideLocally(signals);
39
25
  if (local !== void 0) return local;
@@ -1,12 +1,5 @@
1
1
  //#region src/cli/currency/opt-out.ts
2
2
  const NO_AUTO_UPDATE_ENV = "HOMEPAGES_NO_AUTO_UPDATE";
3
- /**
4
- * Whether the author turned the whole feature off.
5
- *
6
- * Documented as `=1`, but any value other than `0` counts: an author who exports it as
7
- * `true` in a shell profile means the same thing, and silently ignoring that spelling
8
- * would install over them.
9
- */
10
3
  function optedOut(env) {
11
4
  const value = env[NO_AUTO_UPDATE_ENV];
12
5
  return value !== void 0 && value !== "" && value !== "0";
@@ -1,6 +1,7 @@
1
1
  import { findCommand, flagName, hasNoAutoUpdateFlag } from "../commands.js";
2
2
  import { findWorkspaceRoot, isRegistryRange, readDeclaredRange, resolveInstalledVersion } from "../workspace.js";
3
- import { defaultCacheRoot, openCurrencyCache } from "./cache.js";
3
+ import { cacheRoot } from "../../platform/fs.js";
4
+ import { openCurrencyCache } from "./cache.js";
4
5
  import { decideCurrency, registryNeeded } from "./decide.js";
5
6
  import { optedOut } from "./opt-out.js";
6
7
  import { askYesNo } from "./prompt.js";
@@ -30,7 +31,6 @@ async function gatherLocalSignals(root, options, env) {
30
31
  lockfile: await isFile(join(root, "package-lock.json"))
31
32
  };
32
33
  }
33
- /** The registry's answer for this workspace, through the user-scoped time cache. */
34
34
  async function latestVersion(cache, root, options, env) {
35
35
  const declinedVersions = await cache.declinedVersions();
36
36
  const cached = await cache.readLatest();
@@ -52,11 +52,6 @@ function say(sink, lines) {
52
52
  sink.write(`${lines.join("\n")}\n`);
53
53
  }
54
54
  const gap = (installed, latest) => `concrete: ${latest} is published; this workspace is on ${installed}.`;
55
- /**
56
- * Reports a real gap the preamble may not act on. Each reason is a different thing for
57
- * the author to do, so none of them share a line — a message that only said "not
58
- * refreshing" would leave the author with nothing to fix.
59
- */
60
55
  function reportBlocked(sink, installed, latest, reason) {
61
56
  say(sink, [reason === "not-a-tty" ? `${gap(installed, latest)} Not refreshing outside a terminal — run \`npm update\` at the workspace root to catch up.` : `${gap(installed, latest)} There is no package-lock.json to refresh — run \`npm install\` at the workspace root first.`]);
62
57
  }
@@ -73,7 +68,6 @@ async function refreshWorkspace(root, installed, latest, options, env, sink) {
73
68
  say(sink, [`concrete: now on ${await resolveInstalledVersion(root) ?? latest}.`]);
74
69
  return "succeeded";
75
70
  }
76
- /** `upgrade`'s own routine, imported only when an author has actually said yes. */
77
71
  const runUpgradeCommand = async ({ root, target, env, sink }) => {
78
72
  const { runUpgrade } = await import("../upgrade/index.js");
79
73
  return runUpgrade([flagName(findCommand("upgrade"), "to"), target], {
@@ -84,14 +78,6 @@ const runUpgradeCommand = async ({ root, target, env, sink }) => {
84
78
  tty: true
85
79
  });
86
80
  };
87
- /**
88
- * The one branch that asks a question.
89
- *
90
- * Crossing a major is a manifest rewrite plus its codemods, so it is never automatic —
91
- * but a notice the author can only act on later leaves the gap open indefinitely, which
92
- * is what the question closes. Whichever way it is answered, the command the author
93
- * actually typed runs afterwards; nothing here returns a code, and nothing here throws.
94
- */
95
81
  async function crossMajor(root, decision, cache, options, env, sink) {
96
82
  if (decision.blocked !== null) {
97
83
  say(sink, [`${gap(decision.installed, decision.latest)} That crosses a major, which is never automatic — continuing on ${decision.installed}.`, ` Run \`concrete upgrade\` when you are ready to move.`]);
@@ -125,13 +111,6 @@ async function crossMajor(root, decision, cache, options, env, sink) {
125
111
  say(sink, [`concrete: this command is still running ${decision.installed} — the next one you run will be ${decision.latest}.`]);
126
112
  return "succeeded";
127
113
  }
128
- /**
129
- * Bring the workspace up to the published release before the command runs, or say why
130
- * that did not happen.
131
- *
132
- * Never throws and never writes to stdout. Returns what it decided so a caller — in
133
- * practice a test — can see the whole behaviour table without reading bytes.
134
- */
135
114
  async function enforceCurrency(options) {
136
115
  const env = options.env ?? process.env;
137
116
  const sink = options.sink ?? process.stderr;
@@ -143,7 +122,7 @@ async function enforceCurrency(options) {
143
122
  }
144
123
  const local = await gatherLocalSignals(root, options, env);
145
124
  const cache = openCurrencyCache({
146
- root: options.cacheRoot ?? defaultCacheRoot(env),
125
+ root: options.cacheRoot ?? cacheRoot(env),
147
126
  now: options.now ?? Date.now
148
127
  });
149
128
  const registry = registryNeeded(local) ? await latestVersion(cache, root, options, env) : {
@@ -1,7 +1,6 @@
1
1
  import { createInterface } from "node:readline";
2
2
 
3
3
  //#region src/cli/currency/prompt.ts
4
- /** Only a whole word: a path or a sentence typed at the prompt is not a decline. */
5
4
  const NO = /^n(o)?$/i;
6
5
  const askYesNo = async ({ question, sink, input = process.stdin }) => {
7
6
  const reader = createInterface({
@@ -1,34 +1,27 @@
1
+ import { spawnNpm } from "../../platform/process.js";
1
2
  import { CONCRETE_PACKAGE } from "../workspace.js";
2
- import { spawn } from "node:child_process";
3
3
 
4
4
  //#region src/cli/currency/refresh.ts
5
- /** The exact invocation, so the notice that names it and the run that makes it agree. */
6
5
  const REFRESH_COMMAND = ["update", CONCRETE_PACKAGE];
7
- /**
8
- * One npm subcommand at the workspace root, streamed. `null` on success, the failure
9
- * text otherwise. Never throws. Shared with `upgrade`'s install, so the two surfaces that
10
- * run npm on an author's behalf stream it, and fail, the same way.
11
- */
12
6
  function runNpm(args, { root, env, sink }) {
13
7
  return new Promise((resolve) => {
14
8
  let child;
15
9
  try {
16
- child = spawn("npm", [...args], {
10
+ child = spawnNpm(args, {
17
11
  cwd: root,
18
12
  env: { ...env },
19
13
  stdio: [
20
14
  "ignore",
21
15
  "pipe",
22
16
  "pipe"
23
- ],
24
- shell: process.platform === "win32"
17
+ ]
25
18
  });
26
19
  } catch (cause) {
27
20
  resolve(cause instanceof Error ? cause.message : String(cause));
28
21
  return;
29
22
  }
30
- child.stdout.pipe(sink, { end: false });
31
- child.stderr.pipe(sink, { end: false });
23
+ child.stdout?.pipe(sink, { end: false });
24
+ child.stderr?.pipe(sink, { end: false });
32
25
  child.once("error", (cause) => {
33
26
  resolve(cause.message);
34
27
  });
@@ -1,23 +1,11 @@
1
+ import { execNpm } from "../../platform/process.js";
1
2
  import { CONCRETE_PACKAGE } from "../workspace.js";
2
3
  import { z } from "zod";
3
- import { execFile } from "node:child_process";
4
- import { promisify } from "node:util";
5
4
 
6
5
  //#region src/cli/currency/resolve-latest.ts
7
- const execFileAsync = promisify(execFile);
8
- /** The package whose `latest` decides currency. */
9
6
  const CURRENCY_PACKAGE = CONCRETE_PACKAGE;
10
- /**
11
- * The whole budget, config read included.
12
- *
13
- * Not incidental: without a deadline a hung registry connection turns every author
14
- * command into a hang, which is the one failure that would make an author reach for the
15
- * kill switch permanently. Two seconds is what the read may cost a command that runs
16
- * in front of every other one.
17
- */
18
7
  const DEFAULT_TIMEOUT_MS = 2e3;
19
8
  const PUBLIC_REGISTRY = "https://registry.npmjs.org/";
20
- /** npm prints this, literally, for a key that is not set. */
21
9
  const NPM_UNSET = "undefined";
22
10
  const VERSION_DIST_SCHEMA = z.object({ dist: z.object({
23
11
  tarball: z.string(),
@@ -25,25 +13,16 @@ const VERSION_DIST_SCHEMA = z.object({ dist: z.object({
25
13
  shasum: z.string().optional()
26
14
  }) });
27
15
  const DIST_TAGS_SCHEMA = z.object({ latest: z.string().optional() });
28
- /**
29
- * `npm config get <keys…>`, as npm resolves them — every `.npmrc` layer, env vars and
30
- * builtin defaults included. Hand-parsing those files would honour a different subset
31
- * than the install this feature's recommendation is about.
32
- *
33
- * Reading config touches no network and no package cache.
34
- */
35
16
  function npmConfigReader(cwd, env, timeoutMs) {
36
17
  return async (keys) => {
37
- const { stdout } = await execFileAsync("npm", [
18
+ const { stdout } = await execNpm([
38
19
  "config",
39
20
  "get",
40
21
  ...keys
41
22
  ], {
42
23
  cwd,
43
24
  env: { ...env },
44
- encoding: "utf8",
45
- timeout: timeoutMs,
46
- shell: process.platform === "win32"
25
+ timeout: timeoutMs
47
26
  });
48
27
  const only = keys.length === 1 ? keys[0] : void 0;
49
28
  if (only !== void 0) return { [only]: stdout.trim() };
@@ -59,7 +38,6 @@ function npmConfigReader(cwd, env, timeoutMs) {
59
38
  function usable(value) {
60
39
  return value === void 0 || value === "" || value === NPM_UNSET ? void 0 : value;
61
40
  }
62
- /** The scope's own registry wins over the default one, exactly as an install resolves it. */
63
41
  async function registryBase(packageName, read) {
64
42
  const slash = packageName.indexOf("/");
65
43
  const scope = packageName.startsWith("@") && slash > 0 ? packageName.slice(0, slash) : void 0;
@@ -73,21 +51,9 @@ async function registryBase(packageName, read) {
73
51
  const base = usable(scope === void 0 ? void 0 : values[`${scope}:registry`]) ?? usable(values.registry) ?? PUBLIC_REGISTRY;
74
52
  return base.endsWith("/") ? base : `${base}/`;
75
53
  }
76
- /** The escaping npm's own registry clients use: the scope separator, and only it. */
77
54
  function packagePath(packageName) {
78
55
  return packageName.replace("/", "%2f");
79
56
  }
80
- /**
81
- * Everything a request needs, or `null` when the budget is already gone.
82
- *
83
- * By default ONE deadline across both steps, so a wedged `npm config get` cannot spend
84
- * the budget and then let the request spend it again. With `configTimeoutMs` the config
85
- * read is bounded by that instead and the request gets all of `timeoutMs`.
86
- *
87
- * Either way a config read that outlasts its deadline is unknown, never the public
88
- * registry: npm killed mid-read is not npm answering "unset", and asking the public
89
- * registry about a version only a mirror carries would answer `absent`.
90
- */
91
57
  async function prepare(options) {
92
58
  const packageName = options.packageName ?? CURRENCY_PACKAGE;
93
59
  const timeoutMs = options.timeoutMs ?? 2e3;
@@ -107,14 +73,6 @@ async function prepare(options) {
107
73
  packageName
108
74
  };
109
75
  }
110
- /**
111
- * One GET inside what is left of the deadline. `null` is unreachable, aborted, or a
112
- * transport that threw — never a status, which the caller reads for itself.
113
- *
114
- * A private mirror demanding credentials answers 401 rather than `null`: reading a
115
- * token out of npm's config is a larger question than this feature answers, and every
116
- * caller here treats a status it did not expect as unknown anyway.
117
- */
118
76
  async function get(call, url) {
119
77
  try {
120
78
  return await call.doFetch(url, {
@@ -125,12 +83,6 @@ async function get(call, url) {
125
83
  return null;
126
84
  }
127
85
  }
128
- /**
129
- * The `latest` dist-tag for the package, or `null` when it cannot be read.
130
- *
131
- * Never throws — a preamble that runs before every author command may not be able to
132
- * fail one.
133
- */
134
86
  async function resolveLatest(options = {}) {
135
87
  const call = await prepare(options);
136
88
  if (call === null) return null;
@@ -143,14 +95,6 @@ async function resolveLatest(options = {}) {
143
95
  return null;
144
96
  }
145
97
  }
146
- /**
147
- * Whether the registry carries an exact version.
148
- *
149
- * Three answers, not two, and the third is the point: `unknown` covers an unreachable
150
- * registry, a timeout and any status that is neither the version document nor a plain
151
- * 404. A caller must not read it as `absent` — refusing a version because the network
152
- * was down would turn an offline moment into "that release does not exist".
153
- */
154
98
  async function versionExists(version, options = {}) {
155
99
  const call = await prepare(options);
156
100
  if (call === null) return "unknown";
@@ -159,11 +103,6 @@ async function versionExists(version, options = {}) {
159
103
  if (response.ok) return "present";
160
104
  return response.status === 404 ? "absent" : "unknown";
161
105
  }
162
- /**
163
- * The `dist` block of one exact version's document, or `null` when it cannot be read.
164
- * Never throws. A 404 is `null` too: the caller asks only about a version `resolveLatest`
165
- * has just named, so there is no absent-versus-unknown decision to make here.
166
- */
167
106
  async function readPublishedDist(version, options = {}) {
168
107
  const call = await prepare(options);
169
108
  if (call === null) return null;
@@ -1,6 +1,5 @@
1
1
  //#region src/cli/currency/version-order.ts
2
2
  const VERSION_PATTERN = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
3
- /** `null` for anything this cannot read — the caller must treat that as unknown. */
4
3
  function parseVersion(raw) {
5
4
  const matched = VERSION_PATTERN.exec(raw.trim());
6
5
  if (matched === null) return null;
@@ -11,17 +10,6 @@ function parseVersion(raw) {
11
10
  prerelease: matched[4] ?? ""
12
11
  };
13
12
  }
14
- /**
15
- * `-1`, `0` or `1`, ordering `a` against `b`.
16
- *
17
- * Prereleases are ordered exactly one step past the release triple: at equal triples a
18
- * prerelease sorts BELOW the release, so `4.1.0-rc.1` is behind `4.1.0`. Two
19
- * prereleases at the same triple compare EQUAL rather than being ranked against each
20
- * other — the identifier precedence rules that would rank them are the fiddliest part
21
- * of the spec, and the only input that could reach them is an author's own local build
22
- * against a registry `latest`, which is never a prerelease. Ranking them by string
23
- * comparison would order `rc.10` below `rc.9`, which is worse than declining to answer.
24
- */
25
13
  function compareVersions(a, b) {
26
14
  for (const part of [
27
15
  "major",
@@ -1,7 +1,6 @@
1
1
  import { CROP_PARAM, croppedUrl, cutRegion as cutRegion$1, parseCropParam } from "../../packages/internal/image-ladder/dist/crop.js";
2
2
 
3
3
  //#region src/cli/dev/crop.ts
4
- /** A fixture media URL serving only `rect` of the image. */
5
4
  function croppedMediaUrl(url, rect) {
6
5
  return croppedUrl(url, rect);
7
6
  }
@@ -12,7 +11,6 @@ async function defaultLoadSharp() {
12
11
  return null;
13
12
  }
14
13
  }
15
- /** `rect` of an image's bytes, in its own format. Null when sharp is unavailable. */
16
14
  async function cutRegion(master, rect, loadSharp = defaultLoadSharp) {
17
15
  const sharp = await loadSharp();
18
16
  return sharp === null ? null : cutRegion$1(sharp, master, rect);
@@ -30,7 +30,6 @@ const MIME = {
30
30
  ".otf": "font/otf",
31
31
  ".eot": "application/vnd.ms-fontobject"
32
32
  };
33
- /** The content type a file is served under, by extension. */
34
33
  function contentTypeFor(path) {
35
34
  return MIME[extname(path).toLowerCase()] ?? "application/octet-stream";
36
35
  }
@@ -48,7 +47,6 @@ function sendBytes(res, contentType, bytes, disposition) {
48
47
  if (disposition !== void 0) res.setHeader("content-disposition", disposition);
49
48
  res.end(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength));
50
49
  }
51
- /** Read a request body, bounded. */
52
50
  async function readBody(req, maxBytes) {
53
51
  const chunks = [];
54
52
  let size = 0;
@@ -60,7 +58,6 @@ async function readBody(req, maxBytes) {
60
58
  }
61
59
  return Buffer.concat(chunks);
62
60
  }
63
- /** A request the server refuses with a status of its own choosing and a sentence. */
64
61
  var RequestError = class extends Error {
65
62
  status;
66
63
  constructor(status, message) {
@@ -68,11 +65,6 @@ var RequestError = class extends Error {
68
65
  this.status = status;
69
66
  }
70
67
  };
71
- /**
72
- * One `bytes=` range (the only form a media element sends) against a body of `size`
73
- * bytes: the inclusive slice to serve, `null` for no or an unparsable header (serve the
74
- * whole body), `"unsatisfiable"` when it starts past the end.
75
- */
76
68
  function parseByteRange(header, size) {
77
69
  const match = header ? /^bytes=(\d*)-(\d*)$/.exec(header.trim()) : null;
78
70
  if (!match || match[1] === "" && match[2] === "") return null;
@@ -92,11 +84,6 @@ function parseByteRange(header, size) {
92
84
  end
93
85
  };
94
86
  }
95
- /**
96
- * Serve a file from disk, honouring a byte range. A `<video>` seeks by ranges: a player
97
- * that asked for `bytes=N-` and got the whole file back reports `seekable` as empty and
98
- * snaps every seek to zero. A missing file 404s.
99
- */
100
87
  async function sendFile(req, res, path) {
101
88
  let buf;
102
89
  try {