@homepages/concrete 12.0.0 → 13.0.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 (311) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/README.md +8 -10
  3. package/codemods/fixtures-are-data.mjs +7 -0
  4. package/codemods/fixtures-list-properties.mjs +6 -0
  5. package/codemods/manifest.json +15 -0
  6. package/codemods/steps/fixtures-list-properties.mjs +16 -0
  7. package/codemods/steps/fixtures-to-data.mjs +41 -0
  8. package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  9. package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  10. package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  11. package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
  12. package/dist/artifact/playground/client/assets/index-C01UCAWD.css +1 -0
  13. package/dist/artifact/playground/client/index.html +2 -2
  14. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  15. package/dist/artifact/playground/host.mjs +110 -59
  16. package/dist/base.css +2 -2
  17. package/dist/cli/build/icons.js +1 -1
  18. package/dist/cli/build/index.js +11 -10
  19. package/dist/cli/build/manifest.js +44 -0
  20. package/dist/cli/build/record.js +123 -0
  21. package/dist/cli/build/sections.js +28 -18
  22. package/dist/cli/build/source.js +1 -1
  23. package/dist/cli/build/static.js +8 -5
  24. package/dist/cli/build/template-build.js +614 -0
  25. package/dist/cli/check/analyze.js +18 -1
  26. package/dist/cli/check/load-workspace.js +2 -2
  27. package/dist/cli/check/portable-names.js +1 -1
  28. package/dist/cli/check/render/corpus.js +119 -0
  29. package/dist/cli/check/render/invariants.js +1 -0
  30. package/dist/cli/check/stages/bundles.js +15 -18
  31. package/dist/cli/check/stages/composition.js +8 -25
  32. package/dist/cli/check/stages/fixtures.js +14 -10
  33. package/dist/cli/check/stages/logic.js +7 -23
  34. package/dist/cli/check/stages/render.js +12 -14
  35. package/dist/cli/check/stages/sections.js +22 -66
  36. package/dist/cli/check/stages/stylesheet.js +4 -26
  37. package/dist/cli/check/stages/workspace.js +27 -22
  38. package/dist/cli/commands.js +51 -23
  39. package/dist/cli/currency/preamble.js +1 -1
  40. package/dist/cli/currency/resolve-latest.js +3 -2
  41. package/dist/cli/dev/capture-browser.js +26 -0
  42. package/dist/cli/dev/fixture-schema.js +441 -0
  43. package/dist/cli/dev/folder-files.js +244 -0
  44. package/dist/cli/dev/index.js +7 -3
  45. package/dist/cli/dev/playground-server.js +34 -0
  46. package/dist/cli/dev/section-ladders.js +76 -0
  47. package/dist/cli/dev/server.js +120 -304
  48. package/dist/cli/install/background.js +16 -0
  49. package/dist/cli/install/index.js +45 -0
  50. package/dist/cli/install/tools.js +27 -0
  51. package/dist/cli/media/derive.js +19 -13
  52. package/dist/cli/media/deriver-plugin.js +14 -3
  53. package/dist/cli/property/fixture-list.js +46 -0
  54. package/dist/cli/property/index.js +12 -9
  55. package/dist/cli/property/library.js +12 -10
  56. package/dist/cli/publish/artifact.js +90 -0
  57. package/dist/cli/publish/captures.js +61 -0
  58. package/dist/cli/publish/fixtures.js +17 -0
  59. package/dist/cli/publish/index.js +10 -18
  60. package/dist/cli/{build → publish}/playground.js +3 -3
  61. package/dist/cli/publish/report.js +15 -33
  62. package/dist/cli/upgrade/codemod.d.ts +14 -0
  63. package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
  64. package/dist/cli/upgrade/fixture-conversion.js +54 -0
  65. package/dist/cli/upgrade/fixture-modules.js +125 -0
  66. package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
  67. package/dist/cli/upgrade/fixtures-to-data.js +498 -0
  68. package/dist/cli/upgrade/index.js +18 -2
  69. package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
  70. package/dist/cli/upgrade/legacy-fixtures.js +22 -0
  71. package/dist/cli/upgrade/stage.js +1 -1
  72. package/dist/cli/workspace-fixtures.js +80 -0
  73. package/dist/cli.js +1 -0
  74. package/dist/css/compile.js +9 -3
  75. package/dist/fixtures/bundle-rule.js +16 -16
  76. package/dist/fixtures/media-plugin.js +12 -33
  77. package/dist/fixtures/synthesize-empties.js +3 -2
  78. package/dist/index.d.ts +7 -7
  79. package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
  80. package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
  81. package/dist/islands/client-module.js +1 -1
  82. package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
  83. package/dist/islands/wrap.js +40 -0
  84. package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
  85. package/dist/packages/external/concrete/package.js +1 -1
  86. package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
  87. package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
  88. package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
  89. package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
  90. package/dist/packages/internal/capture-settle/dist/index.js +2 -2
  91. package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
  92. package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
  93. package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
  94. package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
  95. package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
  96. package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
  97. package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
  98. package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
  99. package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
  100. package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
  101. package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
  102. package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
  103. package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
  104. package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
  105. package/dist/packages/internal/download-files/dist/capture.js +74 -0
  106. package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
  107. package/dist/packages/internal/download-files/dist/files.js +7 -0
  108. package/dist/packages/internal/download-files/dist/finish.js +35 -0
  109. package/dist/packages/internal/download-files/dist/fleet.js +94 -0
  110. package/dist/packages/internal/download-files/dist/format.js +40 -0
  111. package/dist/packages/internal/download-files/dist/make.js +105 -0
  112. package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
  113. package/dist/packages/internal/download-files/dist/names.js +24 -0
  114. package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
  115. package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
  116. package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
  117. package/dist/packages/internal/file-store/dist/files.js +8 -0
  118. package/dist/packages/internal/file-store/dist/lru.js +40 -0
  119. package/dist/packages/internal/file-store/dist/refusal.js +12 -0
  120. package/dist/packages/internal/file-store/dist/trees.js +151 -0
  121. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
  122. package/dist/packages/internal/fill-bake/dist/compute-reads.js +47 -21
  123. package/dist/packages/internal/fill-bake/dist/index.js +5 -1
  124. package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
  125. package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
  126. package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
  127. package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
  128. package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
  129. package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
  130. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
  131. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
  132. package/dist/packages/internal/island-runtime/dist/index.js +1 -10
  133. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
  134. package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
  135. package/dist/packages/internal/media-resolution/dist/video.js +6 -2
  136. package/dist/packages/internal/page-render/dist/addresses.js +57 -0
  137. package/dist/packages/internal/page-render/dist/index.js +6 -0
  138. package/dist/packages/internal/page-render/dist/kept.js +30 -0
  139. package/dist/packages/internal/page-render/dist/nav.js +42 -0
  140. package/dist/packages/internal/page-render/dist/render.js +152 -0
  141. package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
  142. package/dist/packages/internal/page-shell/dist/escape.js +10 -0
  143. package/dist/packages/internal/page-shell/dist/frame.js +23 -0
  144. package/dist/packages/internal/page-shell/dist/index.js +26 -0
  145. package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
  146. package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
  147. package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
  148. package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
  149. package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
  150. package/dist/packages/internal/playground/dist/host/built.js +202 -0
  151. package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
  152. package/dist/packages/internal/playground/dist/host/download.js +34 -0
  153. package/dist/packages/internal/playground/dist/host/env.js +11 -0
  154. package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
  155. package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
  156. package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
  157. package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
  158. package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
  159. package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
  160. package/dist/packages/internal/playground/dist/host/leads.js +41 -0
  161. package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
  162. package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
  163. package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
  164. package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
  165. package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
  166. package/dist/packages/internal/playground/dist/host/program.js +54 -0
  167. package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
  168. package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
  169. package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
  170. package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
  171. package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
  172. package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
  173. package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
  174. package/dist/packages/internal/playground/dist/host/save.js +429 -0
  175. package/dist/packages/internal/playground/dist/host/serve.js +952 -0
  176. package/dist/packages/internal/playground/dist/host/site.js +79 -0
  177. package/dist/packages/internal/playground/dist/host/slots.js +202 -0
  178. package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
  179. package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
  180. package/dist/packages/internal/playground/dist/host/violations.js +7 -0
  181. package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
  182. package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
  183. package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
  184. package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
  185. package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
  186. package/dist/packages/internal/playground/dist/layout.js +14 -0
  187. package/dist/packages/internal/playground/dist/platform.js +33 -0
  188. package/dist/packages/internal/playground/dist/server/changes.js +57 -0
  189. package/dist/packages/internal/playground/dist/server/crop.js +47 -0
  190. package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
  191. package/dist/packages/internal/playground/dist/server/download.js +158 -0
  192. package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
  193. package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
  194. package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
  195. package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
  196. package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
  197. package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
  198. package/dist/packages/internal/playground/dist/server/verification.js +75 -0
  199. package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
  200. package/dist/packages/internal/playground/dist/wire.js +78 -0
  201. package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
  202. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
  203. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
  204. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
  205. package/dist/packages/internal/site-files/dist/head.js +59 -0
  206. package/dist/packages/internal/site-files/dist/index.js +4 -0
  207. package/dist/packages/internal/site-files/dist/site.js +211 -0
  208. package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
  209. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
  210. package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
  211. package/dist/packages/internal/template-artifact/dist/build.js +148 -0
  212. package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
  213. package/dist/packages/internal/template-artifact/dist/index.js +2 -2
  214. package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
  215. package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
  216. package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
  217. package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
  218. package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
  219. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
  220. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
  221. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
  222. package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
  223. package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
  224. package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
  225. package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
  226. package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
  227. package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
  228. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
  229. package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
  230. package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
  231. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
  232. package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
  233. package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
  234. package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
  235. package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
  236. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
  237. package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
  238. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
  239. package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
  240. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
  241. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
  242. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
  243. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
  244. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
  245. package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
  246. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
  247. package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
  248. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
  249. package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
  250. package/dist/packages/internal/upload-formats/dist/index.js +80 -0
  251. package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
  252. package/dist/platform/paths.js +1 -0
  253. package/dist/platform/process.js +49 -1
  254. package/dist/rules/registry.js +27 -3
  255. package/dist/schema/fact.d.ts +2 -2
  256. package/dist/schema/facts-view.d.ts +1 -1
  257. package/dist/schema/section-props.d.ts +1 -1
  258. package/dist/schema/section-schema.d.ts +1 -1
  259. package/dist/schema/section-schema.js +1 -0
  260. package/dist/section/declare.d.ts +1 -1
  261. package/dist/section/discovery.js +6 -2
  262. package/dist/section/publish-shape.js +38 -0
  263. package/dist/section/section.d.ts +1 -1
  264. package/dist/template/define-template.d.ts +14 -4
  265. package/dist/template/define-template.js +2 -0
  266. package/dist/template/logic-shim.d.ts +1 -1
  267. package/dist/template/materialize.js +1 -1
  268. package/dist/template/running-copy.js +0 -1
  269. package/dist/template/section-reads.js +1 -1
  270. package/guide/reference/cli/INDEX.md +6 -5
  271. package/guide/reference/cli/build.md +10 -8
  272. package/guide/reference/cli/check.md +4 -2
  273. package/guide/reference/cli/dev.md +6 -2
  274. package/guide/reference/cli/install.md +41 -0
  275. package/guide/reference/cli/property-add.md +5 -4
  276. package/guide/reference/cli/property-list.md +2 -2
  277. package/guide/reference/cli/publish.md +5 -5
  278. package/guide/reference/cli/upgrade.md +1 -1
  279. package/guide/reference/rules/INDEX.md +8 -4
  280. package/package.json +14 -30
  281. package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
  282. package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
  283. package/dist/cli/build/artifact.js +0 -220
  284. package/dist/cli/build/captures.js +0 -48
  285. package/dist/cli/build/fixtures.js +0 -92
  286. package/dist/cli/capture/capture-browser.js +0 -37
  287. package/dist/cli/capture/capture.js +0 -115
  288. package/dist/cli/check/render/inputs.js +0 -60
  289. package/dist/cli/check/render/nav.js +0 -31
  290. package/dist/cli/dev/crop.js +0 -20
  291. package/dist/cli/dev/fixture-ladders.js +0 -96
  292. package/dist/cli/dev/hmr.js +0 -26
  293. package/dist/cli/dev/islands.js +0 -234
  294. package/dist/cli/dev/load-template.js +0 -52
  295. package/dist/cli/dev/vite.js +0 -114
  296. package/dist/cli/dev/workspace-reader.js +0 -249
  297. package/dist/cli/publish/freshness.js +0 -64
  298. package/dist/fixtures/brand.d.ts +0 -4
  299. package/dist/fixtures/brand.js +0 -8
  300. package/dist/fixtures/load.js +0 -159
  301. package/dist/fixtures/resolve.js +0 -392
  302. package/dist/fixtures.d.ts +0 -429
  303. package/dist/fixtures.js +0 -23
  304. package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
  305. package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
  306. package/dist/playground/canvas-island-host.d.ts +0 -11
  307. package/dist/playground/canvas-island-host.js +0 -29
  308. package/dist/playground/canvas-markers.js +0 -14
  309. package/dist/playground/host/paths.js +0 -8
  310. package/dist/playground/layout.js +0 -17
  311. package/dist/playground/wire.js +0 -28
@@ -0,0 +1,81 @@
1
+ import { defaultDisplayCase, variantSelectFor } from "./display.js";
2
+ import { bootstrapPageIds, instancesOf, isPageEnabled } from "./pages.js";
3
+
4
+ //#region ../../internal/deliverable-reads/dist/bootstrap.js
5
+ const SETTLED_FILL_HOLDERS = {
6
+ pending: [],
7
+ processing: {},
8
+ failed: [],
9
+ failed_crops: [],
10
+ waiting: {},
11
+ evaluating: false
12
+ };
13
+ async function assembleBootstrap(input) {
14
+ const { composition, contentDoc } = input;
15
+ const stored = new Map(contentDoc.instances.map((i) => [i.instance_id, i]));
16
+ const paintedPageOf = /* @__PURE__ */ new Map();
17
+ const painted = new Set(bootstrapPageIds(composition));
18
+ for (const page of composition.pages) {
19
+ if (!painted.has(page.id)) continue;
20
+ for (const entry of page.sections) if (!paintedPageOf.has(entry.instance_id)) paintedPageOf.set(entry.instance_id, page.id);
21
+ }
22
+ const sections = await Promise.all(instancesOf(composition).map(async (entry) => {
23
+ const section = input.sectionOf(entry.section);
24
+ const declared = section.schema.display;
25
+ const variant = stored.get(entry.instance_id)?.variant ?? defaultDisplayCase(declared);
26
+ const pageId = paintedPageOf.get(entry.instance_id);
27
+ const [computed, rendered] = await Promise.all([input.computedOf(entry, section), pageId === void 0 ? Promise.resolve({
28
+ html: null,
29
+ render_error: null
30
+ }) : input.render(entry, section, {
31
+ pageId,
32
+ variant
33
+ })]);
34
+ return {
35
+ instance_id: entry.instance_id,
36
+ section_key: section.section_key,
37
+ section_display_name: section.section_display_name,
38
+ render_key: section.render_key,
39
+ schema: section.schema,
40
+ fill_spec: section.fill_spec,
41
+ required: entry.required ?? false,
42
+ html: rendered.html,
43
+ render_error: rendered.render_error === null ? null : {
44
+ code: rendered.render_error.code,
45
+ message: rendered.render_error.message
46
+ },
47
+ fill_failure: input.fillFailureOf?.(entry.instance_id) ?? null,
48
+ computed,
49
+ ...input.resolveFaultsOf === void 0 ? {} : { resolve_faults: input.resolveFaultsOf(entry.instance_id) },
50
+ variant,
51
+ variant_select: variantSelectFor(declared)
52
+ };
53
+ }));
54
+ const website = composition.output === "website";
55
+ return {
56
+ deliverable: input.deliverable,
57
+ format: input.format,
58
+ pages: composition.pages.map((page) => ({
59
+ id: page.id,
60
+ label: page.label,
61
+ path: website ? page.path ?? null : null,
62
+ ...website ? {} : { direction: page.direction ?? "column" },
63
+ optional: page.optional ?? false,
64
+ enabled: isPageEnabled(contentDoc.page_state, page.id),
65
+ instance_ids: page.sections.map((s) => s.instance_id)
66
+ })),
67
+ canvases: composition.canvases.map((canvas) => ({
68
+ id: canvas.id,
69
+ label: canvas.label,
70
+ page_ids: [...canvas.pages]
71
+ })),
72
+ sections,
73
+ facts: input.facts,
74
+ by: input.by,
75
+ fill_holders: input.fillHolders,
76
+ content_fingerprint: input.contentFingerprint
77
+ };
78
+ }
79
+
80
+ //#endregion
81
+ export { SETTLED_FILL_HOLDERS, assembleBootstrap };
@@ -0,0 +1,21 @@
1
+ //#region ../../internal/deliverable-reads/dist/display.js
2
+ function defaultDisplayCase(display) {
3
+ return display?.variant?.cases[0];
4
+ }
5
+ function caseLabel(value) {
6
+ return value.split("-").map((part) => part ? part[0].toUpperCase() + part.slice(1) : part).join(" ");
7
+ }
8
+ function variantSelectFor(display) {
9
+ const variant = display?.variant;
10
+ if (!variant) return void 0;
11
+ return {
12
+ cases: variant.cases.map((value) => ({
13
+ value,
14
+ label: caseLabel(value)
15
+ })),
16
+ locked: variant.locked === true
17
+ };
18
+ }
19
+
20
+ //#endregion
21
+ export { caseLabel, defaultDisplayCase, variantSelectFor };
@@ -0,0 +1,15 @@
1
+ //#region ../../internal/deliverable-reads/dist/format.js
2
+ function templateFormatOf(format) {
3
+ return {
4
+ id: format.id,
5
+ label: format.label,
6
+ category: format.category,
7
+ ...format.width !== void 0 ? { width: format.width } : {},
8
+ ...format.height !== void 0 ? { height: format.height } : {},
9
+ ...format.dpi !== void 0 ? { dpi: format.dpi } : {},
10
+ ...format.bleed !== void 0 ? { bleed: format.bleed } : {}
11
+ };
12
+ }
13
+
14
+ //#endregion
15
+ export { templateFormatOf };
@@ -0,0 +1,7 @@
1
+ import { caseLabel, defaultDisplayCase, variantSelectFor } from "./display.js";
2
+ import { bootstrapPageIds, homePageOf, instancesOf, isPageEnabled } from "./pages.js";
3
+ import { SETTLED_FILL_HOLDERS, assembleBootstrap } from "./bootstrap.js";
4
+ import { templateFormatOf } from "./format.js";
5
+ import { answerRequirements, deliverableRequirements, deliverableSubjectOf, requirementsResponseOf, subjectContentOf, templateSubjectOf } from "./requirements.js";
6
+
7
+ export { SETTLED_FILL_HOLDERS, answerRequirements, assembleBootstrap, defaultDisplayCase, deliverableRequirements, deliverableSubjectOf, requirementsResponseOf, templateFormatOf, templateSubjectOf };
@@ -0,0 +1,29 @@
1
+ //#region ../../internal/deliverable-reads/dist/pages.js
2
+ const ROOT_PAGE_PATH = "/";
3
+ function isPageEnabled(pageState, pageId) {
4
+ return pageState?.find((p) => p.page_id === pageId)?.enabled ?? true;
5
+ }
6
+ function homePageOf(pages) {
7
+ const home = pages.find((p) => p.path === "/") ?? pages[0];
8
+ if (home === void 0) throw new Error("a composition holds at least one page");
9
+ return home;
10
+ }
11
+ function bootstrapPageIds(composition) {
12
+ if (composition.output === "website") return [homePageOf(composition.pages).id];
13
+ const first = composition.canvases[0];
14
+ if (first === void 0) throw new Error("a composition holds at least one canvas");
15
+ return [...first.pages];
16
+ }
17
+ function instancesOf(composition) {
18
+ const seen = /* @__PURE__ */ new Set();
19
+ const out = [];
20
+ for (const page of composition.pages) for (const entry of page.sections) {
21
+ if (seen.has(entry.instance_id)) continue;
22
+ seen.add(entry.instance_id);
23
+ out.push(entry);
24
+ }
25
+ return out;
26
+ }
27
+
28
+ //#endregion
29
+ export { bootstrapPageIds, homePageOf, instancesOf, isPageEnabled };
@@ -0,0 +1,72 @@
1
+ import { evaluateRequirements } from "../../template-contracts/dist/require-graph.js";
2
+
3
+ //#region ../../internal/deliverable-reads/dist/requirements.js
4
+ function variantCasesOf(schema) {
5
+ const cases = schema["display"]?.variant?.cases;
6
+ return Array.isArray(cases) ? cases.filter((value) => typeof value === "string") : void 0;
7
+ }
8
+ function templateSubjectOf(id, build) {
9
+ const variantCases = /* @__PURE__ */ new Map();
10
+ for (const [key, section] of build.sections) {
11
+ const cases = variantCasesOf(section.schema);
12
+ if (cases !== void 0) variantCases.set(key, cases);
13
+ }
14
+ return {
15
+ id,
16
+ graph: build.readGraph,
17
+ optionalPages: new Set(build.composition.pages.filter((page) => page.optional === true).map((page) => page.id)),
18
+ variantCases
19
+ };
20
+ }
21
+ function subjectContentOf(raw) {
22
+ const doc = raw;
23
+ return {
24
+ instances: Array.isArray(doc?.instances) ? doc.instances : [],
25
+ page_state: Array.isArray(doc?.page_state) ? doc.page_state : void 0
26
+ };
27
+ }
28
+ function deliverableSubjectOf(id, build, contentDoc) {
29
+ return {
30
+ ...templateSubjectOf(id, build),
31
+ content: subjectContentOf(contentDoc)
32
+ };
33
+ }
34
+ function answerRequirements(subjects, facts) {
35
+ return evaluateRequirements({
36
+ subjects,
37
+ facts: { property: facts }
38
+ });
39
+ }
40
+ function requirementsResponseOf(mode, subjects, answer) {
41
+ return {
42
+ mode,
43
+ subjects: subjects.map((subject) => subject.id),
44
+ pages: answer.pages.map((page) => ({
45
+ home: page.home,
46
+ key: page.key,
47
+ paged: page.paged,
48
+ used: [...page.used],
49
+ required: [...page.required],
50
+ unanswered: [...page.unanswered],
51
+ preconditions: page.preconditions.map((p) => ({
52
+ subject: p.subject,
53
+ instance_id: p.instanceId,
54
+ slot: p.slot,
55
+ requires: [...p.requires],
56
+ unanswered: [...p.unanswered]
57
+ }))
58
+ })),
59
+ empty_content: answer.emptyContent.map((c) => ({
60
+ subject: c.subject,
61
+ page_id: c.pageId,
62
+ instance_id: c.instanceId,
63
+ slot: c.slot
64
+ }))
65
+ };
66
+ }
67
+ function deliverableRequirements(subject, facts) {
68
+ return requirementsResponseOf("deliverable", [subject], answerRequirements([subject], facts));
69
+ }
70
+
71
+ //#endregion
72
+ export { answerRequirements, deliverableRequirements, deliverableSubjectOf, requirementsResponseOf, subjectContentOf, templateSubjectOf };
@@ -1,6 +1,7 @@
1
- import { zipSync } from "../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js";
1
+ import { zipSync } from "../../../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js";
2
2
 
3
- //#region src/cli/capture/bundle.ts
3
+ //#region ../../internal/download-files/dist/bundle.js
4
+ const FIXED_MTIME_MS = Date.UTC(1985, 0, 1, 12);
4
5
  function uniqueName(taken, name) {
5
6
  if (!taken.has(name)) {
6
7
  taken.add(name);
@@ -20,8 +21,11 @@ function uniqueName(taken, name) {
20
21
  function bundlePages(entries) {
21
22
  const taken = /* @__PURE__ */ new Set();
22
23
  const members = {};
23
- for (const entry of entries) members[uniqueName(taken, entry.name)] = entry.bytes;
24
- return Buffer.from(zipSync(members, { level: 0 }));
24
+ for (const entry of entries) members[uniqueName(taken, entry.name)] = new Uint8Array(entry.bytes.buffer, entry.bytes.byteOffset, entry.bytes.byteLength);
25
+ return Buffer.from(zipSync(members, {
26
+ level: 0,
27
+ mtime: FIXED_MTIME_MS
28
+ }));
25
29
  }
26
30
 
27
31
  //#endregion
@@ -0,0 +1,126 @@
1
+ import { fillBuildFile } from "../../static-assets-binding/dist/section-asset-url.js";
2
+ import { isFilledText } from "./capture-routes.js";
3
+ import { createServer } from "node:http";
4
+ import { pipeline } from "node:stream/promises";
5
+
6
+ //#region ../../internal/download-files/dist/capture-origin.js
7
+ const HOST = "127.0.0.1";
8
+ const DEFAULT_CONTENT_TYPE = "application/octet-stream";
9
+ async function startCaptureOrigin(input) {
10
+ const documents = new Map(input.documents.map((doc) => [doc.path, doc.html]));
11
+ const server = createServer((req, res) => {
12
+ serveRequest(input, documents, req, res);
13
+ });
14
+ await new Promise((resolve, reject) => {
15
+ server.once("error", reject);
16
+ server.listen(0, HOST, () => {
17
+ server.removeListener("error", reject);
18
+ resolve();
19
+ });
20
+ });
21
+ const { port } = server.address();
22
+ const origin = `http://${HOST}:${port}`;
23
+ return {
24
+ origin,
25
+ urlFor: (document) => `${origin}${document.path}`,
26
+ close: () => closeServer(server)
27
+ };
28
+ }
29
+ function routeName(route) {
30
+ return route.from === "build" ? route.path : route.key;
31
+ }
32
+ async function openRoute(input, route) {
33
+ return route.from === "build" ? input.reads.buildFile(route.path) : input.reads.mediaFile(route.key);
34
+ }
35
+ async function serveRequest(input, documents, req, res) {
36
+ if (req.method !== "GET" && req.method !== "HEAD") {
37
+ res.writeHead(405, { allow: "GET, HEAD" }).end();
38
+ return;
39
+ }
40
+ const pathname = new URL(req.url ?? "/", `http://${HOST}`).pathname;
41
+ const html = documents.get(pathname);
42
+ if (html !== void 0) {
43
+ const body = Buffer.from(html, "utf8");
44
+ res.writeHead(200, {
45
+ "content-type": "text/html; charset=utf-8",
46
+ "content-length": body.byteLength
47
+ });
48
+ res.end(req.method === "HEAD" ? void 0 : body);
49
+ return;
50
+ }
51
+ const route = input.routes.routeOf(pathname);
52
+ if (route === null) {
53
+ res.writeHead(404).end();
54
+ return;
55
+ }
56
+ let stored;
57
+ try {
58
+ stored = await openRoute(input, route);
59
+ } catch (err) {
60
+ input.onError?.(`capture origin could not open ${route.from} file ${routeName(route)}`, err);
61
+ res.writeHead(404).end();
62
+ return;
63
+ }
64
+ if (stored === null) {
65
+ if (route.from === "build") input.onAbsentBuildFile?.(route.path);
66
+ res.writeHead(404).end();
67
+ return;
68
+ }
69
+ if (route.served !== void 0) input.onImageServed?.({
70
+ ...route.served,
71
+ pathname,
72
+ servedKey: routeName(route)
73
+ });
74
+ const contentType = route.contentType ?? stored.contentType ?? DEFAULT_CONTENT_TYPE;
75
+ const disposition = route.from === "media" && route.contentDisposition !== void 0 ? { "content-disposition": route.contentDisposition } : {};
76
+ if (isFilledText(route) && route.from === "build") {
77
+ let text;
78
+ try {
79
+ text = await readText(stored.body);
80
+ } catch (err) {
81
+ input.onError?.(`capture origin could not read ${route.path}`, err);
82
+ res.writeHead(404).end();
83
+ return;
84
+ }
85
+ const body = Buffer.from(fillBuildFile(route.filename, text, input.bases.build), "utf8");
86
+ res.writeHead(200, {
87
+ "content-type": contentType,
88
+ "content-length": body.byteLength
89
+ });
90
+ res.end(req.method === "HEAD" ? void 0 : body);
91
+ return;
92
+ }
93
+ res.writeHead(200, {
94
+ "content-type": contentType,
95
+ ...stored.contentLength === void 0 ? {} : { "content-length": stored.contentLength },
96
+ ...disposition
97
+ });
98
+ if (req.method === "HEAD") {
99
+ stored.body.destroy();
100
+ res.end();
101
+ return;
102
+ }
103
+ try {
104
+ await pipeline(stored.body, res);
105
+ } catch (err) {
106
+ input.onError?.(`capture origin stream failed for ${route.from} file ${routeName(route)}`, err);
107
+ res.destroy();
108
+ }
109
+ }
110
+ async function readText(body) {
111
+ const chunks = [];
112
+ for await (const chunk of body) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
113
+ return Buffer.concat(chunks).toString("utf8");
114
+ }
115
+ function closeServer(server) {
116
+ return new Promise((resolve, reject) => {
117
+ server.closeAllConnections();
118
+ server.close((err) => {
119
+ if (err) reject(err);
120
+ else resolve();
121
+ });
122
+ });
123
+ }
124
+
125
+ //#endregion
126
+ export { startCaptureOrigin };
@@ -0,0 +1,139 @@
1
+ import { assetContentType } from "../../template-artifact/dist/asset-mime.js";
2
+ import { assetPath, browserFiles } from "../../template-artifact/dist/layout.js";
3
+ import { carriesFixedAddresses } from "../../static-assets-binding/dist/section-asset-url.js";
4
+ import { imageDocumentHtml, printDocumentHtml } from "./capture-shell.js";
5
+
6
+ //#region ../../internal/download-files/dist/capture-routes.js
7
+ const SCRIPT_TYPE = "application/javascript; charset=utf-8";
8
+ const STYLESHEET_TYPE = "text/css; charset=utf-8";
9
+ function buildFileType(filename) {
10
+ if (/\.css$/i.test(filename)) return STYLESHEET_TYPE;
11
+ if (/\.(mjs|js)$/i.test(filename)) return SCRIPT_TYPE;
12
+ return assetContentType(filename);
13
+ }
14
+ function checkBase(name, base) {
15
+ if (!base.startsWith("/") || !base.endsWith("/")) throw new Error(`A capture's ${name} base starts and ends with "/", not "${base}".`);
16
+ return base;
17
+ }
18
+ function pageDocumentPath(contentBase, pageId) {
19
+ return `${contentBase}pages/${encodeURIComponent(pageId)}/`;
20
+ }
21
+ function printDocumentPath(contentBase) {
22
+ return `${contentBase}print/`;
23
+ }
24
+ function shellIslands(binding, buildBase) {
25
+ const islandKeys = Object.keys(binding.islands);
26
+ if (islandKeys.length === 0) return { kind: "none" };
27
+ if (binding.island_runtime === null || binding.react_vendor_core === null) throw new Error("capture: the binding has islands but no island runtime or React vendor core");
28
+ const at = (filename) => `${buildBase}${filename}`;
29
+ return {
30
+ kind: "bundles",
31
+ runtime: { url: at(binding.island_runtime.filename) },
32
+ islandMap: Object.fromEntries(islandKeys.map((key) => [key, at(binding.islands[key].filename)])),
33
+ reactVendorMap: Object.fromEntries(Object.entries(binding.react_vendor ?? {}).map(([spec, ref]) => [spec, at(ref.filename)])),
34
+ reactVendorCore: { url: at(binding.react_vendor_core.filename) }
35
+ };
36
+ }
37
+ function captureDocuments(input) {
38
+ if (input.pages.length === 0) throw new Error("a download has no enabled page to capture");
39
+ const content = checkBase("content", input.bases.content);
40
+ const build = checkBase("build", input.bases.build);
41
+ const stylesheets = {
42
+ baseCss: `${build}${input.binding.base_css.filename}`,
43
+ templateCss: `${build}${input.binding.template_css.filename}`
44
+ };
45
+ const islands = shellIslands(input.binding, build);
46
+ if (input.output === "image") return input.pages.map((page) => ({
47
+ pageId: page.id,
48
+ path: pageDocumentPath(content, page.id),
49
+ html: imageDocumentHtml({
50
+ format: input.format,
51
+ sectionHtml: page.sectionHtml,
52
+ ...page.direction === void 0 ? {} : { direction: page.direction },
53
+ stylesheets,
54
+ islands
55
+ })
56
+ }));
57
+ return [{
58
+ pageId: null,
59
+ path: printDocumentPath(content),
60
+ html: printDocumentHtml({
61
+ format: input.format,
62
+ pages: input.pages.map((page) => ({
63
+ sectionHtml: page.sectionHtml,
64
+ ...page.direction === void 0 ? {} : { direction: page.direction }
65
+ })),
66
+ stylesheets,
67
+ islands
68
+ })
69
+ }];
70
+ }
71
+ function masterIndexKey(filename) {
72
+ const dot = filename.lastIndexOf(".");
73
+ if (dot <= 0) return null;
74
+ const rung = /^(.+)-w\d+$/.exec(filename.slice(0, dot));
75
+ return rung === null ? null : rung[1];
76
+ }
77
+ function captureRoutes(input) {
78
+ const content = checkBase("content", input.bases.content);
79
+ const build = checkBase("build", input.bases.build);
80
+ const files = browserFiles(input.binding);
81
+ const media = /* @__PURE__ */ new Map();
82
+ for (const copy of input.media) {
83
+ const path = `${content}${copy.r2_path}`;
84
+ const route = {
85
+ from: "media",
86
+ key: copy.master_key ?? copy.source_key,
87
+ contentType: copy.content_type,
88
+ ...copy.master_key === void 0 ? {} : { served: {
89
+ kind: "master",
90
+ askedFor: copy.source_key
91
+ } },
92
+ ...copy.content_disposition === void 0 ? {} : { contentDisposition: copy.content_disposition }
93
+ };
94
+ const existing = media.get(path);
95
+ if (existing !== void 0 && existing.from === "media" && existing.key !== route.key) throw new Error(`capture path collision at ${path}: ${existing.key} vs ${route.key}`);
96
+ media.set(path, route);
97
+ }
98
+ const buildFile = (filename) => {
99
+ const path = files.pathOf(filename);
100
+ if (path === null) return null;
101
+ const indexKey = path === assetPath(filename) ? masterIndexKey(filename) : null;
102
+ if (indexKey === null) return {
103
+ from: "build",
104
+ path,
105
+ filename,
106
+ contentType: buildFileType(filename)
107
+ };
108
+ const master = input.binding.masters[indexKey];
109
+ if (master === void 0) return {
110
+ from: "build",
111
+ path,
112
+ filename,
113
+ contentType: buildFileType(filename),
114
+ served: { kind: "rung-miss" }
115
+ };
116
+ return {
117
+ from: "build",
118
+ path: assetPath(master),
119
+ filename: master,
120
+ contentType: buildFileType(master),
121
+ served: {
122
+ kind: "master",
123
+ askedFor: path
124
+ }
125
+ };
126
+ };
127
+ return { routeOf(pathname) {
128
+ const fromMedia = media.get(pathname);
129
+ if (fromMedia !== void 0) return fromMedia;
130
+ if (!pathname.startsWith(build)) return null;
131
+ return buildFile(pathname.slice(build.length));
132
+ } };
133
+ }
134
+ function isFilledText(route) {
135
+ return route.from === "build" && carriesFixedAddresses(route.filename);
136
+ }
137
+
138
+ //#endregion
139
+ export { captureDocuments, captureRoutes, isFilledText, pageDocumentPath, printDocumentPath };
@@ -0,0 +1,38 @@
1
+ import { assembleDocument } from "../../page-shell/dist/assemble.js";
2
+ import "../../page-shell/dist/index.js";
3
+
4
+ //#region ../../internal/download-files/dist/capture-shell.js
5
+ function linkedStylesheets(stylesheets) {
6
+ return {
7
+ kind: "links",
8
+ hrefs: [stylesheets.baseCss, stylesheets.templateCss]
9
+ };
10
+ }
11
+ function imageDocumentHtml(args) {
12
+ return assembleDocument({
13
+ destination: "capture",
14
+ root: {
15
+ kind: "frame",
16
+ format: args.format,
17
+ sectionHtml: args.sectionHtml,
18
+ ...args.direction === void 0 ? {} : { direction: args.direction }
19
+ },
20
+ islands: args.islands,
21
+ stylesheets: linkedStylesheets(args.stylesheets)
22
+ });
23
+ }
24
+ function printDocumentHtml(args) {
25
+ return assembleDocument({
26
+ destination: "capture",
27
+ root: {
28
+ kind: "frameStack",
29
+ format: args.format,
30
+ pages: args.pages
31
+ },
32
+ islands: args.islands,
33
+ stylesheets: linkedStylesheets(args.stylesheets)
34
+ });
35
+ }
36
+
37
+ //#endregion
38
+ export { imageDocumentHtml, printDocumentHtml };
@@ -0,0 +1,74 @@
1
+ import { captureViewport, printPageSize } from "../../format-geometry/dist/capture.js";
2
+ import { CAPTURE_WAIT_UNTIL, settleCapture } from "../../capture-settle/dist/settle.js";
3
+ import "../../capture-settle/dist/index.js";
4
+ import { watchPageEgress } from "./egress-watch.js";
5
+
6
+ //#region ../../internal/download-files/dist/capture.js
7
+ function captureSettleHost(page) {
8
+ return {
9
+ evaluate: (expression) => page.evaluate(expression),
10
+ onNetworkActivity: (listener) => {
11
+ page.on("request", listener);
12
+ page.on("requestfinished", listener);
13
+ page.on("requestfailed", listener);
14
+ return () => {
15
+ page.off("request", listener);
16
+ page.off("requestfinished", listener);
17
+ page.off("requestfailed", listener);
18
+ };
19
+ }
20
+ };
21
+ }
22
+ async function withCapturedPage(context, target, prepare, shoot) {
23
+ const page = await context.newPage();
24
+ try {
25
+ const watch = watchPageEgress(page, target.origin);
26
+ await prepare(page);
27
+ await page.goto(target.url, { waitUntil: CAPTURE_WAIT_UNTIL });
28
+ try {
29
+ await settleCapture(captureSettleHost(page));
30
+ } catch (err) {
31
+ target.masters.assertBuildFilesServed();
32
+ throw err;
33
+ }
34
+ watch.assertEgressClean();
35
+ target.masters.assertBuildFilesServed();
36
+ target.masters.assertMastersServed();
37
+ return await shoot(page);
38
+ } finally {
39
+ await page.close();
40
+ }
41
+ }
42
+ function captureImagePage(context, target) {
43
+ return withCapturedPage(context, target, () => Promise.resolve(), (page) => page.screenshot({
44
+ fullPage: false,
45
+ type: "png"
46
+ }));
47
+ }
48
+ function capturePrintDocument(context, target) {
49
+ const paper = printPageSize(target.format);
50
+ return withCapturedPage(context, target, (page) => page.emulateMedia({ media: "screen" }), (page) => page.pdf({
51
+ width: paper.width,
52
+ height: paper.height,
53
+ margin: {
54
+ top: "0",
55
+ right: "0",
56
+ bottom: "0",
57
+ left: "0"
58
+ },
59
+ printBackground: true
60
+ }));
61
+ }
62
+ function newCaptureContextOptions(format) {
63
+ const viewport = captureViewport(format);
64
+ return {
65
+ viewport: {
66
+ width: viewport.width,
67
+ height: viewport.height
68
+ },
69
+ deviceScaleFactor: viewport.deviceScaleFactor
70
+ };
71
+ }
72
+
73
+ //#endregion
74
+ export { captureImagePage, capturePrintDocument, newCaptureContextOptions };
@@ -0,0 +1,38 @@
1
+ //#region ../../internal/download-files/dist/egress-watch.js
2
+ function watchPageEgress(page, loopbackOrigin) {
3
+ const failures = [];
4
+ page.on("response", (response) => {
5
+ const url = response.url();
6
+ if (isLoopback(url, loopbackOrigin)) return;
7
+ const status = response.status();
8
+ if (status >= 400) failures.push(`${url} — HTTP ${status}`);
9
+ });
10
+ page.on("requestfailed", (request) => {
11
+ const url = request.url();
12
+ if (isLoopback(url, loopbackOrigin)) return;
13
+ const reason = request.failure()?.errorText ?? "network error";
14
+ if (reason === "net::ERR_ABORTED") return;
15
+ failures.push(`${url} — ${reason}`);
16
+ });
17
+ return {
18
+ failures,
19
+ assertEgressClean() {
20
+ const [first] = failures;
21
+ if (first === void 0) return;
22
+ throw new Error(`render blocked: an external request failed — ${first}. A rendered page may reach beyond its own origin, so a FAILED request is the defect: whatever that response would have painted is missing from the download` + (failures.length > 1 ? ` (${failures.length} failed external requests in total)` : ""));
23
+ }
24
+ };
25
+ }
26
+ function isLoopback(url, loopbackOrigin) {
27
+ let parsed;
28
+ try {
29
+ parsed = new URL(url);
30
+ } catch {
31
+ return false;
32
+ }
33
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return true;
34
+ return parsed.origin === loopbackOrigin;
35
+ }
36
+
37
+ //#endregion
38
+ export { watchPageEgress };
@@ -0,0 +1,7 @@
1
+ import { newCaptureContextOptions } from "./capture.js";
2
+ import { captureDocuments, captureRoutes, pageDocumentPath, printDocumentPath } from "./capture-routes.js";
3
+ import { startCaptureOrigin } from "./capture-origin.js";
4
+ import { finishDownload } from "./finish.js";
5
+ import { makeDownloadFiles } from "./make.js";
6
+
7
+ export { makeDownloadFiles };