@homepages/concrete 1.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 (327) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +174 -0
  3. package/codemods/manifest.json +9 -0
  4. package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
  5. package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
  6. package/dist/artifact/playground/client/index.html +13 -0
  7. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
  8. package/dist/artifact/playground/host.mjs +127 -0
  9. package/dist/asset-modules.d.ts +99 -0
  10. package/dist/base.css +220 -0
  11. package/dist/browser/site-config.d.ts +18 -0
  12. package/dist/browser/site-config.js +56 -0
  13. package/dist/browser/submit-lead.d.ts +98 -0
  14. package/dist/browser/submit-lead.js +188 -0
  15. package/dist/browser.d.ts +3 -0
  16. package/dist/browser.js +4 -0
  17. package/dist/cli/build/artifact.js +225 -0
  18. package/dist/cli/build/captures.js +67 -0
  19. package/dist/cli/build/esbuild.js +127 -0
  20. package/dist/cli/build/fixtures.js +96 -0
  21. package/dist/cli/build/icons.js +76 -0
  22. package/dist/cli/build/index.js +38 -0
  23. package/dist/cli/build/playground.js +31 -0
  24. package/dist/cli/build/sections.js +236 -0
  25. package/dist/cli/build/source.js +62 -0
  26. package/dist/cli/build/static.js +156 -0
  27. package/dist/cli/capture/bundle.js +37 -0
  28. package/dist/cli/capture/capture-browser.js +51 -0
  29. package/dist/cli/capture/capture.js +121 -0
  30. package/dist/cli/check/analyze.js +95 -0
  31. package/dist/cli/check/index.js +19 -0
  32. package/dist/cli/check/load-workspace.js +119 -0
  33. package/dist/cli/check/messages.js +16 -0
  34. package/dist/cli/check/render/class-conflicts.js +39 -0
  35. package/dist/cli/check/render/html.js +86 -0
  36. package/dist/cli/check/render/inputs.js +53 -0
  37. package/dist/cli/check/render/invariants.js +58 -0
  38. package/dist/cli/check/render/island-frames.js +72 -0
  39. package/dist/cli/check/render/marker-coverage.js +102 -0
  40. package/dist/cli/check/render/nav.js +64 -0
  41. package/dist/cli/check/report.js +73 -0
  42. package/dist/cli/check/stages/bundles.js +129 -0
  43. package/dist/cli/check/stages/composition.js +67 -0
  44. package/dist/cli/check/stages/contracts.js +22 -0
  45. package/dist/cli/check/stages/dependencies.js +261 -0
  46. package/dist/cli/check/stages/fixtures.js +74 -0
  47. package/dist/cli/check/stages/lint.js +41 -0
  48. package/dist/cli/check/stages/logic.js +63 -0
  49. package/dist/cli/check/stages/render.js +144 -0
  50. package/dist/cli/check/stages/sections.js +83 -0
  51. package/dist/cli/check/stages/stylesheet.js +31 -0
  52. package/dist/cli/check/stages/typecheck.js +68 -0
  53. package/dist/cli/check/stages/workspace.js +26 -0
  54. package/dist/cli/commands.js +342 -0
  55. package/dist/cli/currency/cache.js +89 -0
  56. package/dist/cli/currency/decide.js +65 -0
  57. package/dist/cli/currency/opt-out.js +16 -0
  58. package/dist/cli/currency/preamble.js +183 -0
  59. package/dist/cli/currency/prompt.js +28 -0
  60. package/dist/cli/currency/refresh.js +44 -0
  61. package/dist/cli/currency/resolve-latest.js +185 -0
  62. package/dist/cli/currency/version-order.js +38 -0
  63. package/dist/cli/dev/crop.js +22 -0
  64. package/dist/cli/dev/hmr.js +26 -0
  65. package/dist/cli/dev/http.js +129 -0
  66. package/dist/cli/dev/index.js +70 -0
  67. package/dist/cli/dev/islands.js +390 -0
  68. package/dist/cli/dev/load-template.js +46 -0
  69. package/dist/cli/dev/request-error.js +22 -0
  70. package/dist/cli/dev/server.js +307 -0
  71. package/dist/cli/dev/tsconfig-paths.js +95 -0
  72. package/dist/cli/dev/vite.js +85 -0
  73. package/dist/cli/dev/workspace-reader.js +274 -0
  74. package/dist/cli/io.d.ts +14 -0
  75. package/dist/cli/media/cache.js +125 -0
  76. package/dist/cli/media/derive.js +252 -0
  77. package/dist/cli/media/deriver-plugin.js +71 -0
  78. package/dist/cli/property/index.js +180 -0
  79. package/dist/cli/property/library.js +137 -0
  80. package/dist/cli/publish/client.js +119 -0
  81. package/dist/cli/publish/freshness.js +66 -0
  82. package/dist/cli/publish/git.js +43 -0
  83. package/dist/cli/publish/index.js +207 -0
  84. package/dist/cli/publish/pack.js +78 -0
  85. package/dist/cli/publish/report.js +98 -0
  86. package/dist/cli/publish/target.js +87 -0
  87. package/dist/cli/publish/wire.js +29 -0
  88. package/dist/cli/tar.js +87 -0
  89. package/dist/cli/upgrade/codemod.js +56 -0
  90. package/dist/cli/upgrade/index.js +263 -0
  91. package/dist/cli/upgrade/manifest.js +72 -0
  92. package/dist/cli/upgrade/plan.js +68 -0
  93. package/dist/cli/upgrade/stage.js +71 -0
  94. package/dist/cli/version.d.ts +12 -0
  95. package/dist/cli/version.js +15 -0
  96. package/dist/cli/workspace.js +108 -0
  97. package/dist/cli.d.ts +6 -0
  98. package/dist/cli.js +94 -0
  99. package/dist/css/compile.js +77 -0
  100. package/dist/css/graph.js +109 -0
  101. package/dist/css/inline.js +132 -0
  102. package/dist/css/rules.js +65 -0
  103. package/dist/design-system/format-variants.js +127 -0
  104. package/dist/eslint/authoring.js +46 -0
  105. package/dist/eslint/correctness.js +42 -0
  106. package/dist/eslint/rules/editor-declaration.js +103 -0
  107. package/dist/eslint/rules/editor-reason.js +135 -0
  108. package/dist/eslint/rules/island-imports.js +20 -0
  109. package/dist/eslint/rules/jsx-visitor.js +20 -0
  110. package/dist/eslint/rules/no-client-runtime.js +88 -0
  111. package/dist/eslint/rules/no-editor-globals.js +60 -0
  112. package/dist/eslint/rules/no-hard-coded-color.js +183 -0
  113. package/dist/eslint/rules/no-inline-style.js +24 -0
  114. package/dist/eslint/rules/no-marker-literal.js +37 -0
  115. package/dist/eslint/rules/no-nondeterminism.js +44 -0
  116. package/dist/eslint/rules/no-px-breakpoint.js +44 -0
  117. package/dist/eslint/rules/no-raw-values.js +45 -0
  118. package/dist/eslint/rules/serializable-props.js +95 -0
  119. package/dist/eslint.d.ts +6 -0
  120. package/dist/eslint.js +26 -0
  121. package/dist/fixtures/brand.d.ts +4 -0
  122. package/dist/fixtures/brand.js +9 -0
  123. package/dist/fixtures/bundle-rule.js +67 -0
  124. package/dist/fixtures/canonical.d.ts +149 -0
  125. package/dist/fixtures/image-dimensions.js +59 -0
  126. package/dist/fixtures/load.js +154 -0
  127. package/dist/fixtures/media-plugin.js +141 -0
  128. package/dist/fixtures/media.js +165 -0
  129. package/dist/fixtures/property.js +210 -0
  130. package/dist/fixtures/resolve.js +202 -0
  131. package/dist/fixtures/rows.js +108 -0
  132. package/dist/fixtures/synthesize-empties.js +42 -0
  133. package/dist/fixtures.d.ts +213 -0
  134. package/dist/fixtures.js +37 -0
  135. package/dist/index.d.ts +53 -0
  136. package/dist/index.js +37 -0
  137. package/dist/islands/client-module.js +97 -0
  138. package/dist/islands/marker.d.ts +43 -0
  139. package/dist/islands/marker.js +44 -0
  140. package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
  141. package/dist/packages/external/concrete/package.js +5 -0
  142. package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
  143. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
  144. package/dist/packages/internal/fill-bake/dist/display.js +9 -0
  145. package/dist/packages/internal/fill-bake/dist/index.js +6 -0
  146. package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
  147. package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
  148. package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
  149. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
  150. package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
  151. package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
  152. package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
  153. package/dist/packages/internal/format-geometry/dist/index.js +4 -0
  154. package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
  155. package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
  156. package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
  157. package/dist/packages/internal/image-ladder/dist/index.js +4 -0
  158. package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
  159. package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
  160. package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
  161. package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
  162. package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
  163. package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
  164. package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
  165. package/dist/packages/internal/island-runtime/dist/index.js +163 -0
  166. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
  167. package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
  168. package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
  169. package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
  170. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
  171. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
  172. package/dist/packages/internal/property-facts/dist/index.js +3 -0
  173. package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
  174. package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
  175. package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
  176. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
  177. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
  178. package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
  179. package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
  180. package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
  181. package/dist/packages/internal/section-contracts/dist/index.js +26 -0
  182. package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
  183. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
  184. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
  185. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
  186. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
  187. package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
  188. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
  189. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
  190. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
  191. package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
  192. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
  193. package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
  194. package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
  195. package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
  196. package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
  197. package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
  198. package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
  199. package/dist/packages/internal/source-resolution/dist/index.js +222 -0
  200. package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
  201. package/dist/packages/internal/template-artifact/dist/index.js +7 -0
  202. package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
  203. package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
  204. package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
  205. package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
  206. package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
  207. package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
  208. package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
  209. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
  210. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
  211. package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
  212. package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
  213. package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
  214. package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
  215. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
  216. package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
  217. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
  218. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
  219. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
  220. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
  221. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
  222. package/dist/playground/host/page-state.js +12 -0
  223. package/dist/playground/host/paths.js +9 -0
  224. package/dist/playground/layout.js +24 -0
  225. package/dist/playground/wire.js +36 -0
  226. package/dist/playground-island-runtime.d.ts +3 -0
  227. package/dist/playground-island-runtime.js +4 -0
  228. package/dist/primitives/FrameShell.d.ts +29 -0
  229. package/dist/primitives/FrameShell.js +34 -0
  230. package/dist/primitives/Image.d.ts +119 -0
  231. package/dist/primitives/Image.js +173 -0
  232. package/dist/primitives/Section.d.ts +22 -0
  233. package/dist/primitives/Section.js +26 -0
  234. package/dist/primitives/Tour.d.ts +43 -0
  235. package/dist/primitives/Tour.js +72 -0
  236. package/dist/primitives/Video.d.ts +57 -0
  237. package/dist/primitives/Video.js +116 -0
  238. package/dist/primitives/embed-playback.js +50 -0
  239. package/dist/primitives/index.d.ts +11 -0
  240. package/dist/primitives/marker-attrs.js +44 -0
  241. package/dist/primitives/object-fit.js +11 -0
  242. package/dist/primitives/picture-sources.d.ts +24 -0
  243. package/dist/primitives/picture-sources.js +52 -0
  244. package/dist/primitives/probe-context.js +24 -0
  245. package/dist/primitives/slot-bindings.d.ts +96 -0
  246. package/dist/primitives/slot-bindings.js +226 -0
  247. package/dist/primitives/slot-document.d.ts +35 -0
  248. package/dist/primitives/slot-document.js +37 -0
  249. package/dist/primitives/slot-group.d.ts +40 -0
  250. package/dist/primitives/slot-group.js +45 -0
  251. package/dist/primitives/slot-list.d.ts +21 -0
  252. package/dist/primitives/slot-list.js +23 -0
  253. package/dist/primitives/slot-media.d.ts +71 -0
  254. package/dist/primitives/slot-media.js +98 -0
  255. package/dist/primitives/slot-scalar.d.ts +53 -0
  256. package/dist/primitives/slot-scalar.js +98 -0
  257. package/dist/primitives/slot.d.ts +26 -0
  258. package/dist/primitives/slot.js +28 -0
  259. package/dist/rules/registry.js +479 -0
  260. package/dist/schema/compute.d.ts +22 -0
  261. package/dist/schema/compute.js +30 -0
  262. package/dist/schema/define-schema.d.ts +27 -0
  263. package/dist/schema/define-schema.js +73 -0
  264. package/dist/schema/extract-fill-spec.js +246 -0
  265. package/dist/schema/extract-used-facts.js +176 -0
  266. package/dist/schema/fact.d.ts +65 -0
  267. package/dist/schema/fact.js +33 -0
  268. package/dist/schema/fill-builders.d.ts +387 -0
  269. package/dist/schema/fill-builders.js +263 -0
  270. package/dist/schema/fill-declaration.d.ts +76 -0
  271. package/dist/schema/fill-declaration.js +43 -0
  272. package/dist/schema/fill-spec.d.ts +18 -0
  273. package/dist/schema/fill-spec.js +170 -0
  274. package/dist/schema/format-presets.d.ts +27 -0
  275. package/dist/schema/format-presets.js +76 -0
  276. package/dist/schema/format.d.ts +22 -0
  277. package/dist/schema/format.js +40 -0
  278. package/dist/schema/formats.d.ts +6 -0
  279. package/dist/schema/formats.js +7 -0
  280. package/dist/schema/layout.d.ts +32 -0
  281. package/dist/schema/layout.js +30 -0
  282. package/dist/schema/manifest.js +300 -0
  283. package/dist/schema/property-facts.d.ts +83 -0
  284. package/dist/schema/runtime-values.d.ts +88 -0
  285. package/dist/schema/section-nav.d.ts +38 -0
  286. package/dist/schema/section-nav.js +29 -0
  287. package/dist/schema/section-props.d.ts +98 -0
  288. package/dist/schema/section-schema.d.ts +53 -0
  289. package/dist/schema/section-schema.js +54 -0
  290. package/dist/schema/slot-builders.d.ts +497 -0
  291. package/dist/schema/slot-builders.js +331 -0
  292. package/dist/schema/slot-types.d.ts +110 -0
  293. package/dist/schema/slot-types.js +187 -0
  294. package/dist/section/declare.d.ts +44 -0
  295. package/dist/section/declare.js +27 -0
  296. package/dist/section/discovery.js +76 -0
  297. package/dist/section/groups.js +74 -0
  298. package/dist/section/materialize.js +28 -0
  299. package/dist/section/placements.js +28 -0
  300. package/dist/section/section.d.ts +69 -0
  301. package/dist/section/section.js +101 -0
  302. package/dist/site-analytics.d.ts +1 -0
  303. package/dist/site-analytics.js +15 -0
  304. package/dist/site-runtime/analytics.js +97 -0
  305. package/dist/site-runtime/site-integrations.js +97 -0
  306. package/dist/styles.css +60 -0
  307. package/dist/template/define-template.d.ts +139 -0
  308. package/dist/template/define-template.js +98 -0
  309. package/dist/template/logic-build.js +191 -0
  310. package/dist/template/logic-shim.d.ts +43 -0
  311. package/dist/template/logic-shim.js +52 -0
  312. package/dist/template/logic-transform.js +92 -0
  313. package/dist/template/materialize.js +107 -0
  314. package/dist/template/reconcile.d.ts +67 -0
  315. package/dist/template/reconcile.js +25 -0
  316. package/dist/template/running-copy.js +58 -0
  317. package/guide/reference/cli/INDEX.md +79 -0
  318. package/guide/reference/cli/build.md +48 -0
  319. package/guide/reference/cli/check.md +49 -0
  320. package/guide/reference/cli/dev.md +46 -0
  321. package/guide/reference/cli/property-add.md +53 -0
  322. package/guide/reference/cli/property-list.md +46 -0
  323. package/guide/reference/cli/publish.md +54 -0
  324. package/guide/reference/cli/upgrade.md +48 -0
  325. package/guide/reference/rules/INDEX.md +190 -0
  326. package/package.json +137 -0
  327. package/tsconfig.base.json +16 -0
@@ -0,0 +1,71 @@
1
+ import { DERIVABLE_EXTENSIONS, deriveAuthorImage } from "./derive.js";
2
+ import { extname } from "node:path";
3
+ import { readFile } from "node:fs/promises";
4
+
5
+ //#region src/cli/media/deriver-plugin.ts
6
+ const NAMESPACE = "media-deriver";
7
+ const RESOLVING = Symbol("media-deriver:resolving");
8
+ const RASTER_FILTER = /\.(?:[jJ][pP][eE]?[gG]|[pP][nN][gG]|[wW][eE][bB][pP]|[aA][vV][iI][fF])$/;
9
+ /** A fresh deriver per esbuild pass; `cacheDir` opts it into the on-disk ladder cache. */
10
+ function createMediaDeriver(opts = {}) {
11
+ const derived = /* @__PURE__ */ new Map();
12
+ const masters = /* @__PURE__ */ new Map();
13
+ const passthrough = /* @__PURE__ */ new Set();
14
+ const sources = /* @__PURE__ */ new Map();
15
+ return {
16
+ plugin: {
17
+ name: NAMESPACE,
18
+ setup(build) {
19
+ build.onResolve({ filter: RASTER_FILTER }, async (args) => {
20
+ if (args.pluginData === RESOLVING) return null;
21
+ if (args.kind !== "import-statement") return null;
22
+ if (!DERIVABLE_EXTENSIONS.has(extname(args.path).toLowerCase())) return null;
23
+ const resolved = await build.resolve(args.path, {
24
+ importer: args.importer,
25
+ namespace: args.namespace,
26
+ resolveDir: args.resolveDir,
27
+ kind: args.kind,
28
+ pluginData: RESOLVING
29
+ });
30
+ if (resolved.errors.length > 0 || resolved.path === "") return null;
31
+ return {
32
+ path: resolved.path,
33
+ namespace: NAMESPACE
34
+ };
35
+ });
36
+ build.onLoad({
37
+ filter: /.*/,
38
+ namespace: NAMESPACE
39
+ }, async (args) => {
40
+ const bytes = await readFile(args.path);
41
+ const derivation = await deriveAuthorImage(args.path, bytes, { cacheDir: opts.cacheDir });
42
+ for (const asset of derivation.derivatives) derived.set(asset.filename, asset);
43
+ const { key, filename, bytes: masterBytes, contentType } = derivation.master;
44
+ derived.set(filename, {
45
+ filename,
46
+ bytes: masterBytes,
47
+ contentType
48
+ });
49
+ masters.set(key, filename);
50
+ if (derivation.passthrough) passthrough.add(args.path);
51
+ sources.set(args.path, {
52
+ masterBytes: masterBytes.byteLength,
53
+ derivatives: derivation.derivatives
54
+ });
55
+ return {
56
+ contents: `export default ${JSON.stringify(derivation.image)};`,
57
+ loader: "js",
58
+ watchFiles: [args.path]
59
+ };
60
+ });
61
+ }
62
+ },
63
+ derived,
64
+ masters,
65
+ passthrough,
66
+ sources
67
+ };
68
+ }
69
+
70
+ //#endregion
71
+ export { createMediaDeriver };
@@ -0,0 +1,180 @@
1
+ import { parseSpec } from "../commands.js";
2
+ import { findWorkspaceRoot } from "../workspace.js";
3
+ import { LIBRARY_PACKAGE, openLibrary } from "./library.js";
4
+ import { dirname, join } from "node:path";
5
+ import { cp, lstat, mkdir, readFile, stat } from "node:fs/promises";
6
+ import { z } from "zod";
7
+ import { parseArgs } from "node:util";
8
+
9
+ //#region src/cli/property/index.ts
10
+ const COUNTS_SCHEMA = z.object({
11
+ units: z.number(),
12
+ photos: z.number(),
13
+ floor_plans: z.number(),
14
+ videos: z.number(),
15
+ tours: z.number(),
16
+ documents: z.number()
17
+ });
18
+ const INDEX_SCHEMA = z.object({ properties: z.array(z.object({
19
+ slug: z.string(),
20
+ description: z.string(),
21
+ type: z.string(),
22
+ intent: z.string(),
23
+ counts: COUNTS_SCHEMA
24
+ })) });
25
+ const SLUG = /^[a-z0-9][a-z0-9-]*$/;
26
+ const COUNT_NOUNS = [
27
+ [
28
+ "units",
29
+ "unit",
30
+ "units"
31
+ ],
32
+ [
33
+ "photos",
34
+ "photo",
35
+ "photos"
36
+ ],
37
+ [
38
+ "floor_plans",
39
+ "floor plan",
40
+ "floor plans"
41
+ ],
42
+ [
43
+ "videos",
44
+ "video",
45
+ "videos"
46
+ ],
47
+ [
48
+ "tours",
49
+ "tour",
50
+ "tours"
51
+ ],
52
+ [
53
+ "documents",
54
+ "document",
55
+ "documents"
56
+ ]
57
+ ];
58
+ /** `pearl-street` → `pearlStreet`: the name a library property module exports its property under. */
59
+ function exportNameFor(slug) {
60
+ return slug.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
61
+ }
62
+ /** One line per property: its slug, its description, then its type, intent and non-zero counts. */
63
+ function listingLines(index) {
64
+ const width = Math.max(0, ...index.properties.map((p) => p.slug.length));
65
+ return index.properties.map((property) => {
66
+ const counts = COUNT_NOUNS.filter(([key]) => property.counts[key] > 0).map(([key, one, many]) => `${String(property.counts[key])} ${property.counts[key] === 1 ? one : many}`);
67
+ return `${property.slug.padEnd(width)} ${property.description} (${[
68
+ property.type,
69
+ property.intent,
70
+ ...counts
71
+ ].join(", ")})`;
72
+ });
73
+ }
74
+ function say(stream, text) {
75
+ stream.write(text.endsWith("\n") ? text : `${text}\n`);
76
+ }
77
+ /** Says, on stderr, when an earlier copy stood in for a registry that could not be read. */
78
+ function reportSource(io, prefix, library) {
79
+ if (library.source === "cache") say(io.stderr, `${prefix}: the registry could not be read, so this is ${LIBRARY_PACKAGE} ${library.version}, cached earlier.`);
80
+ }
81
+ async function readIndex(library) {
82
+ try {
83
+ return INDEX_SCHEMA.parse(JSON.parse(await readFile(join(library.dir, "index.json"), "utf8")));
84
+ } catch {
85
+ throw new Error(`${LIBRARY_PACKAGE} ${library.version} carries an index.json this version of concrete cannot read`);
86
+ }
87
+ }
88
+ async function exists(path) {
89
+ try {
90
+ await lstat(path);
91
+ return true;
92
+ } catch {
93
+ return false;
94
+ }
95
+ }
96
+ async function isDirectory(path) {
97
+ try {
98
+ return (await stat(path)).isDirectory();
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
103
+ async function runList(argv, io, environment) {
104
+ const prefix = "concrete property list";
105
+ parseArgs({
106
+ args: [...argv],
107
+ ...parseSpec("property list"),
108
+ allowPositionals: false
109
+ });
110
+ const library = await openLibrary({
111
+ cwd: io.cwd,
112
+ env: io.env,
113
+ ...environment
114
+ });
115
+ reportSource(io, prefix, library);
116
+ for (const line of listingLines(await readIndex(library))) say(io.stdout, line);
117
+ return 0;
118
+ }
119
+ async function runAdd(argv, io, environment) {
120
+ const prefix = "concrete property add";
121
+ const { positionals } = parseArgs({
122
+ args: [...argv],
123
+ ...parseSpec("property add"),
124
+ allowPositionals: true
125
+ });
126
+ const [slug, ...extra] = positionals;
127
+ if (slug === void 0 || extra.length > 0) {
128
+ say(io.stderr, `${prefix}: name one property to copy, e.g. \`concrete property add starter\`. \`concrete property list\` shows every one.`);
129
+ return 1;
130
+ }
131
+ if (!SLUG.test(slug)) {
132
+ say(io.stderr, `${prefix}: a property slug is lowercase letters, digits and hyphens. Got: ${slug}`);
133
+ return 1;
134
+ }
135
+ const root = await findWorkspaceRoot(io.cwd);
136
+ const shown = `fixtures/properties/${slug}/`;
137
+ const destination = join(root, "fixtures", "properties", slug);
138
+ if (await exists(destination)) {
139
+ say(io.stderr, `${prefix}: ${shown} already exists. Nothing was copied — move or delete that folder to take the library's copy.`);
140
+ return 1;
141
+ }
142
+ const library = await openLibrary({
143
+ cwd: root,
144
+ env: io.env,
145
+ ...environment
146
+ });
147
+ reportSource(io, prefix, library);
148
+ const source = join(library.dir, "properties", slug);
149
+ if (!await isDirectory(source)) {
150
+ say(io.stderr, `${prefix}: ${LIBRARY_PACKAGE} ${library.version} has no property '${slug}'. \`concrete property list\` shows every one.`);
151
+ return 1;
152
+ }
153
+ await mkdir(dirname(destination), { recursive: true });
154
+ await cp(source, destination, {
155
+ recursive: true,
156
+ errorOnExist: true,
157
+ force: false
158
+ });
159
+ const name = exportNameFor(slug);
160
+ say(io.stdout, [
161
+ `Copied ${shown} from ${LIBRARY_PACKAGE} ${library.version}. It is yours now: edit it freely.`,
162
+ `Build a fixture on it in any module under fixtures/:`,
163
+ "",
164
+ ` import { ${name} } from "./properties/${slug}/property";`
165
+ ].join("\n"));
166
+ return 0;
167
+ }
168
+ /** The group's entry point, with its environment injected. */
169
+ function createPropertyCommand(environment = {}) {
170
+ return async (argv, io) => {
171
+ const [subcommand, ...rest] = argv;
172
+ if (subcommand === "list") return runList(rest, io, environment);
173
+ if (subcommand === "add") return runAdd(rest, io, environment);
174
+ throw new Error(`no subcommand '${String(subcommand)}'`);
175
+ };
176
+ }
177
+ const runProperty = createPropertyCommand();
178
+
179
+ //#endregion
180
+ export { createPropertyCommand, exportNameFor, listingLines, runProperty };
@@ -0,0 +1,137 @@
1
+ import { defaultCacheRoot } from "../currency/cache.js";
2
+ import { compareVersions, parseVersion } from "../currency/version-order.js";
3
+ import { readPublishedDist, resolveLatest } from "../currency/resolve-latest.js";
4
+ import { readTarball } from "../tar.js";
5
+ import { dirname, join } from "node:path";
6
+ import { mkdir, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
7
+ import { createHash } from "node:crypto";
8
+
9
+ //#region src/cli/property/library.ts
10
+ const LIBRARY_PACKAGE = "@homepages/sample-properties";
11
+ /** Below the cache root, beside the currency cache's file. */
12
+ const LIBRARY_CACHE_RELATIVE = join("homepages", "sample-properties");
13
+ /** Each registry read. Longer than the preamble's two seconds: a person asked for this one. */
14
+ const REGISTRY_TIMEOUT_MS = 1e4;
15
+ /** The tarball download, which carries every property's media. */
16
+ const DOWNLOAD_TIMEOUT_MS = 6e4;
17
+ async function isDirectory(path) {
18
+ try {
19
+ return (await stat(path)).isDirectory();
20
+ } catch {
21
+ return false;
22
+ }
23
+ }
24
+ /** The newest version already unpacked under `root`, or `null`. A half-written staging directory is not a version. */
25
+ async function newestCached(root) {
26
+ let names;
27
+ try {
28
+ names = await readdir(root);
29
+ } catch {
30
+ return null;
31
+ }
32
+ const versions = [];
33
+ for (const name of names) {
34
+ const parsed = parseVersion(name);
35
+ if (parsed !== null && await isDirectory(join(root, name))) versions.push({
36
+ name,
37
+ parsed
38
+ });
39
+ }
40
+ versions.sort((a, b) => compareVersions(b.parsed, a.parsed));
41
+ return versions[0]?.name ?? null;
42
+ }
43
+ async function download(url, doFetch) {
44
+ try {
45
+ const response = await doFetch(url, {
46
+ signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),
47
+ headers: { accept: "application/octet-stream" }
48
+ });
49
+ if (!response.ok) return null;
50
+ return new Uint8Array(await response.arrayBuffer());
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
55
+ /**
56
+ * Whether the bytes are the ones the registry published. The sha512 integrity string when
57
+ * there is one — it may list several digests, and one sha512 decides — else the sha1
58
+ * every registry still carries. A version with neither cannot be checked, so it fails.
59
+ */
60
+ function matchesDigest(bytes, dist) {
61
+ for (const token of (dist.integrity ?? "").split(/\s+/)) if (token.startsWith("sha512-")) return createHash("sha512").update(bytes).digest("base64") === token.slice(7);
62
+ if (dist.shasum !== null) return createHash("sha1").update(bytes).digest("hex") === dist.shasum.toLowerCase();
63
+ return false;
64
+ }
65
+ /** Unpacks into a staging directory and renames it into place, so a version directory is always whole. */
66
+ async function unpack(bytes, dir, version) {
67
+ const files = readTarball(bytes);
68
+ if (!files.some((file) => file.path === "index.json")) throw new Error(`${LIBRARY_PACKAGE}@${version} carries no index.json, so it is not a library this command can read`);
69
+ const staging = `${dir}.${String(process.pid)}.tmp`;
70
+ await rm(staging, {
71
+ recursive: true,
72
+ force: true
73
+ });
74
+ try {
75
+ for (const file of files) {
76
+ const target = join(staging, ...file.path.split("/"));
77
+ await mkdir(dirname(target), { recursive: true });
78
+ await writeFile(target, file.body);
79
+ }
80
+ try {
81
+ await rename(staging, dir);
82
+ } catch (cause) {
83
+ if (!await isDirectory(dir)) throw cause;
84
+ }
85
+ } finally {
86
+ await rm(staging, {
87
+ recursive: true,
88
+ force: true
89
+ });
90
+ }
91
+ }
92
+ /** The published version unpacked, or `null` when the registry could not be read at some step. */
93
+ async function fromRegistry(root, registry, doFetch) {
94
+ const latest = await resolveLatest(registry);
95
+ if (latest === null || parseVersion(latest) === null) return null;
96
+ const dir = join(root, latest);
97
+ if (await isDirectory(dir)) return {
98
+ version: latest,
99
+ dir,
100
+ source: "registry"
101
+ };
102
+ const dist = await readPublishedDist(latest, registry);
103
+ if (dist === null) return null;
104
+ const bytes = await download(dist.tarball, doFetch);
105
+ if (bytes === null) return null;
106
+ if (!matchesDigest(bytes, dist)) throw new Error(`the tarball of ${LIBRARY_PACKAGE}@${latest} does not match the digest the registry published for it. Nothing was unpacked.`);
107
+ await unpack(bytes, dir, latest);
108
+ return {
109
+ version: latest,
110
+ dir,
111
+ source: "registry"
112
+ };
113
+ }
114
+ /** The library to read: the published latest, else the newest cached copy. Throws when there is neither. */
115
+ async function openLibrary(options) {
116
+ const root = join(defaultCacheRoot(options.env), LIBRARY_CACHE_RELATIVE);
117
+ const doFetch = options.fetchImpl ?? fetch;
118
+ const published = await fromRegistry(root, {
119
+ packageName: LIBRARY_PACKAGE,
120
+ cwd: options.cwd,
121
+ env: options.env,
122
+ timeoutMs: REGISTRY_TIMEOUT_MS,
123
+ fetchImpl: doFetch,
124
+ ...options.readNpmConfig === void 0 ? {} : { readNpmConfig: options.readNpmConfig }
125
+ }, doFetch);
126
+ if (published !== null) return published;
127
+ const cached = await newestCached(root);
128
+ if (cached === null) throw new Error(`could not read ${LIBRARY_PACKAGE} from the registry, and no earlier copy is cached. Check the connection and the registry this workspace installs from, then run it again.`);
129
+ return {
130
+ version: cached,
131
+ dir: join(root, cached),
132
+ source: "cache"
133
+ };
134
+ }
135
+
136
+ //#endregion
137
+ export { DOWNLOAD_TIMEOUT_MS, LIBRARY_CACHE_RELATIVE, LIBRARY_PACKAGE, REGISTRY_TIMEOUT_MS, matchesDigest, openLibrary };
@@ -0,0 +1,119 @@
1
+ import { asProblem, isCreateResponse, isPublicationRecord, isSubmitResponse } from "./wire.js";
2
+ import { createReadStream } from "node:fs";
3
+ import { request } from "node:http";
4
+ import { request as request$1 } from "node:https";
5
+
6
+ //#region src/cli/publish/client.ts
7
+ /** A socket that goes quiet this long is a dead endpoint, not a slow one. */
8
+ const IDLE_TIMEOUT_MS = 6e4;
9
+ function send(url, method, headers, body) {
10
+ const request$2 = url.protocol === "https:" ? request$1 : request;
11
+ return new Promise((resolve, reject) => {
12
+ const payload = body !== null && "json" in body ? Buffer.from(JSON.stringify(body.json), "utf8") : null;
13
+ const req = request$2(url, {
14
+ method,
15
+ headers: payload === null ? headers : {
16
+ ...headers,
17
+ "content-type": "application/json",
18
+ "content-length": String(payload.length)
19
+ },
20
+ timeout: IDLE_TIMEOUT_MS
21
+ }, (res) => {
22
+ const chunks = [];
23
+ res.on("data", (chunk) => chunks.push(chunk));
24
+ res.on("end", () => resolve({
25
+ status: res.statusCode ?? 0,
26
+ body: Buffer.concat(chunks).toString("utf8")
27
+ }));
28
+ res.on("error", reject);
29
+ });
30
+ req.on("timeout", () => req.destroy(/* @__PURE__ */ new Error(`no response in ${String(IDLE_TIMEOUT_MS / 1e3)}s`)));
31
+ req.on("error", reject);
32
+ if (payload !== null) req.end(payload);
33
+ else if (body !== null && "file" in body) {
34
+ const stream = createReadStream(body.file);
35
+ stream.on("error", (cause) => req.destroy(cause));
36
+ stream.pipe(req);
37
+ } else req.end();
38
+ });
39
+ }
40
+ function reasonOf(cause) {
41
+ if (cause instanceof Error) {
42
+ const code = cause.code;
43
+ return code === void 0 ? cause.message : `${code}: ${cause.message}`;
44
+ }
45
+ return String(cause);
46
+ }
47
+ function parseJson(text) {
48
+ try {
49
+ return JSON.parse(text);
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ async function exchange(url, method, headers, body, expected, accept) {
55
+ let raw;
56
+ try {
57
+ raw = await send(url, method, headers, body);
58
+ } catch (cause) {
59
+ return {
60
+ kind: "unreachable",
61
+ reason: reasonOf(cause)
62
+ };
63
+ }
64
+ const parsed = parseJson(raw.body);
65
+ if (expected.includes(raw.status)) return accept(parsed) ? {
66
+ kind: "ok",
67
+ value: parsed
68
+ } : {
69
+ kind: "unexpected",
70
+ status: raw.status,
71
+ reason: "the body is not the shape this route answers with"
72
+ };
73
+ if (raw.status >= 400 && raw.status < 600) return {
74
+ kind: "refused",
75
+ status: raw.status,
76
+ problem: asProblem(parsed)
77
+ };
78
+ return {
79
+ kind: "unexpected",
80
+ status: raw.status,
81
+ reason: `HTTP ${String(raw.status)}`
82
+ };
83
+ }
84
+ function publicationClient(endpoint, token) {
85
+ const auth = {
86
+ authorization: `Bearer ${token}`,
87
+ accept: "application/json"
88
+ };
89
+ const route = (path) => new URL(`${endpoint}${path}`);
90
+ return {
91
+ create: (body) => exchange(route("/catalog/publications"), "POST", auth, { json: body }, [201], isCreateResponse),
92
+ upload: async (upload, file) => {
93
+ let raw;
94
+ try {
95
+ raw = await send(new URL(upload.url), upload.method, upload.headers, { file });
96
+ } catch (cause) {
97
+ return {
98
+ kind: "unreachable",
99
+ reason: reasonOf(cause)
100
+ };
101
+ }
102
+ if (raw.status >= 200 && raw.status < 300) return {
103
+ kind: "ok",
104
+ value: null
105
+ };
106
+ const message = /<Message>([^<]*)<\/Message>/.exec(raw.body)?.[1];
107
+ return {
108
+ kind: "refused",
109
+ status: raw.status,
110
+ problem: { detail: message ?? `HTTP ${String(raw.status)}` }
111
+ };
112
+ },
113
+ submit: (id, body) => exchange(route(`/catalog/publications/${encodeURIComponent(id)}/submit`), "POST", auth, body === null ? null : { json: body }, [202], isSubmitResponse),
114
+ read: (id) => exchange(route(`/catalog/publications/${encodeURIComponent(id)}`), "GET", auth, null, [200], isPublicationRecord)
115
+ };
116
+ }
117
+
118
+ //#endregion
119
+ export { publicationClient };
@@ -0,0 +1,66 @@
1
+ import { CONCRETE_CLI_VERSION } from "../version.js";
2
+ import { MANIFEST_FILE } from "../../packages/internal/template-artifact/dist/layout.js";
3
+ import { sourceDigest } from "../../packages/internal/template-artifact/dist/hash.js";
4
+ import { ArtifactManifest } from "../../packages/internal/template-artifact/dist/manifest.js";
5
+ import "../../packages/internal/template-artifact/dist/index.js";
6
+ import { collectSourceFiles } from "../build/source.js";
7
+ import { join } from "node:path";
8
+ import { readFile, stat } from "node:fs/promises";
9
+
10
+ //#region src/cli/publish/freshness.ts
11
+ /** The artifact's manifest and when it was written; `missing` without one, `unreadable` when it does not parse. */
12
+ async function readManifest(out) {
13
+ let text;
14
+ let builtAt;
15
+ try {
16
+ const path = join(out, MANIFEST_FILE);
17
+ text = await readFile(path, "utf8");
18
+ builtAt = (await stat(path)).mtime;
19
+ } catch (cause) {
20
+ if (cause.code === "ENOENT") return "missing";
21
+ throw cause;
22
+ }
23
+ let value;
24
+ try {
25
+ value = JSON.parse(text);
26
+ } catch {
27
+ return "unreadable";
28
+ }
29
+ const parsed = ArtifactManifest.safeParse(value);
30
+ return parsed.success ? {
31
+ manifest: parsed.data,
32
+ builtAt
33
+ } : "unreadable";
34
+ }
35
+ /** Decide whether the artifact at `out` can be published as it is. */
36
+ async function assessFreshness(options) {
37
+ const read = await readManifest(options.out);
38
+ const previous = typeof read === "string" ? null : read.manifest;
39
+ if (options.rebuild) return {
40
+ kind: "rebuild",
41
+ reason: "forced",
42
+ previous
43
+ };
44
+ if (typeof read === "string") return {
45
+ kind: "rebuild",
46
+ reason: read,
47
+ previous: null
48
+ };
49
+ if (read.manifest.framework_version !== CONCRETE_CLI_VERSION) return {
50
+ kind: "rebuild",
51
+ reason: "framework",
52
+ previous
53
+ };
54
+ return sourceDigest(await collectSourceFiles(options.root, [options.out])) === read.manifest.source_digest ? {
55
+ kind: "reuse",
56
+ manifest: read.manifest,
57
+ builtAt: read.builtAt
58
+ } : {
59
+ kind: "rebuild",
60
+ reason: "changed",
61
+ previous
62
+ };
63
+ }
64
+
65
+ //#endregion
66
+ export { assessFreshness, readManifest };
@@ -0,0 +1,43 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+
4
+ //#region src/cli/publish/git.ts
5
+ const run = promisify(execFile);
6
+ async function git(root, args) {
7
+ try {
8
+ const { stdout } = await run("git", [...args], { cwd: root });
9
+ const value = stdout.trim();
10
+ return value === "" ? null : value;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ /**
16
+ * A remote URL with any credentials removed: an https remote can carry a token in its
17
+ * userinfo, and the record is read by people other than the one who published.
18
+ */
19
+ function withoutCredentials(remote) {
20
+ try {
21
+ const url = new URL(remote);
22
+ if (url.username === "" && url.password === "") return remote;
23
+ url.username = "";
24
+ url.password = "";
25
+ return url.toString();
26
+ } catch {
27
+ return remote;
28
+ }
29
+ }
30
+ async function readSourceFacts(root) {
31
+ const [commit, remote] = await Promise.all([git(root, ["rev-parse", "HEAD"]), git(root, [
32
+ "remote",
33
+ "get-url",
34
+ "origin"
35
+ ])]);
36
+ return {
37
+ commit: commit !== null && /^[0-9a-f]{40,64}$/.test(commit) ? commit : null,
38
+ remote: remote === null ? null : withoutCredentials(remote).slice(0, 2048)
39
+ };
40
+ }
41
+
42
+ //#endregion
43
+ export { readSourceFacts, withoutCredentials };