@lets-ship/site 0.0.0-stage → 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 (337) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/bin/ship-site.js +5 -0
  4. package/dist/badge/badge.d.ts +14 -0
  5. package/dist/badge/badge.d.ts.map +1 -0
  6. package/dist/badge/badge.js +16 -0
  7. package/dist/badge/badge.js.map +1 -0
  8. package/dist/blog/arrow.d.ts +6 -0
  9. package/dist/blog/arrow.d.ts.map +1 -0
  10. package/dist/blog/arrow.js +6 -0
  11. package/dist/blog/arrow.js.map +1 -0
  12. package/dist/blog/article-view.d.ts +20 -0
  13. package/dist/blog/article-view.d.ts.map +1 -0
  14. package/dist/blog/article-view.js +71 -0
  15. package/dist/blog/article-view.js.map +1 -0
  16. package/dist/blog/article.d.ts +72 -0
  17. package/dist/blog/article.d.ts.map +1 -0
  18. package/dist/blog/article.js +90 -0
  19. package/dist/blog/article.js.map +1 -0
  20. package/dist/blog/featured.d.ts +18 -0
  21. package/dist/blog/featured.d.ts.map +1 -0
  22. package/dist/blog/featured.js +19 -0
  23. package/dist/blog/featured.js.map +1 -0
  24. package/dist/blog/frontmatter.d.ts +155 -0
  25. package/dist/blog/frontmatter.d.ts.map +1 -0
  26. package/dist/blog/frontmatter.js +96 -0
  27. package/dist/blog/frontmatter.js.map +1 -0
  28. package/dist/blog/index-view.d.ts +21 -0
  29. package/dist/blog/index-view.d.ts.map +1 -0
  30. package/dist/blog/index-view.js +70 -0
  31. package/dist/blog/index-view.js.map +1 -0
  32. package/dist/blog/inline-markdown.d.ts +15 -0
  33. package/dist/blog/inline-markdown.d.ts.map +1 -0
  34. package/dist/blog/inline-markdown.js +44 -0
  35. package/dist/blog/inline-markdown.js.map +1 -0
  36. package/dist/blog/post-card.d.ts +37 -0
  37. package/dist/blog/post-card.d.ts.map +1 -0
  38. package/dist/blog/post-card.js +68 -0
  39. package/dist/blog/post-card.js.map +1 -0
  40. package/dist/blog/site.d.ts +57 -0
  41. package/dist/blog/site.d.ts.map +1 -0
  42. package/dist/blog/site.js +76 -0
  43. package/dist/blog/site.js.map +1 -0
  44. package/dist/blog/toc.d.ts +32 -0
  45. package/dist/blog/toc.d.ts.map +1 -0
  46. package/dist/blog/toc.js +46 -0
  47. package/dist/blog/toc.js.map +1 -0
  48. package/dist/config/context.d.ts +16 -0
  49. package/dist/config/context.d.ts.map +1 -0
  50. package/dist/config/context.js +11 -0
  51. package/dist/config/context.js.map +1 -0
  52. package/dist/config/identity.d.ts +41 -0
  53. package/dist/config/identity.d.ts.map +1 -0
  54. package/dist/config/identity.js +28 -0
  55. package/dist/config/identity.js.map +1 -0
  56. package/dist/config/json-schema.d.ts +11 -0
  57. package/dist/config/json-schema.d.ts.map +1 -0
  58. package/dist/config/json-schema.js +14 -0
  59. package/dist/config/json-schema.js.map +1 -0
  60. package/dist/config/site-config.d.ts +145 -0
  61. package/dist/config/site-config.d.ts.map +1 -0
  62. package/dist/config/site-config.js +130 -0
  63. package/dist/config/site-config.js.map +1 -0
  64. package/dist/docs/page-view.d.ts +21 -0
  65. package/dist/docs/page-view.d.ts.map +1 -0
  66. package/dist/docs/page-view.js +27 -0
  67. package/dist/docs/page-view.js.map +1 -0
  68. package/dist/feeds/feeds.d.ts +33 -0
  69. package/dist/feeds/feeds.d.ts.map +1 -0
  70. package/dist/feeds/feeds.js +122 -0
  71. package/dist/feeds/feeds.js.map +1 -0
  72. package/dist/format/dates.d.ts +5 -0
  73. package/dist/format/dates.d.ts.map +1 -0
  74. package/dist/format/dates.js +17 -0
  75. package/dist/format/dates.js.map +1 -0
  76. package/dist/format/node-text.d.ts +7 -0
  77. package/dist/format/node-text.d.ts.map +1 -0
  78. package/dist/format/node-text.js +15 -0
  79. package/dist/format/node-text.js.map +1 -0
  80. package/dist/format/toc-depth.d.ts +11 -0
  81. package/dist/format/toc-depth.d.ts.map +1 -0
  82. package/dist/format/toc-depth.js +14 -0
  83. package/dist/format/toc-depth.js.map +1 -0
  84. package/dist/i18n/fumadocs-keys.d.ts +13 -0
  85. package/dist/i18n/fumadocs-keys.d.ts.map +1 -0
  86. package/dist/i18n/fumadocs-keys.js +136 -0
  87. package/dist/i18n/fumadocs-keys.js.map +1 -0
  88. package/dist/i18n/strings.d.ts +19 -0
  89. package/dist/i18n/strings.d.ts.map +1 -0
  90. package/dist/i18n/strings.js +59 -0
  91. package/dist/i18n/strings.js.map +1 -0
  92. package/dist/i18n/tables/de.d.ts +3 -0
  93. package/dist/i18n/tables/de.d.ts.map +1 -0
  94. package/dist/i18n/tables/de.js +82 -0
  95. package/dist/i18n/tables/de.js.map +1 -0
  96. package/dist/i18n/tables/en.d.ts +3 -0
  97. package/dist/i18n/tables/en.d.ts.map +1 -0
  98. package/dist/i18n/tables/en.js +25 -0
  99. package/dist/i18n/tables/en.js.map +1 -0
  100. package/dist/i18n/tables/es.d.ts +3 -0
  101. package/dist/i18n/tables/es.d.ts.map +1 -0
  102. package/dist/i18n/tables/es.js +82 -0
  103. package/dist/i18n/tables/es.js.map +1 -0
  104. package/dist/i18n/tables/fr.d.ts +3 -0
  105. package/dist/i18n/tables/fr.d.ts.map +1 -0
  106. package/dist/i18n/tables/fr.js +82 -0
  107. package/dist/i18n/tables/fr.js.map +1 -0
  108. package/dist/i18n/tables/nl.d.ts +3 -0
  109. package/dist/i18n/tables/nl.d.ts.map +1 -0
  110. package/dist/i18n/tables/nl.js +82 -0
  111. package/dist/i18n/tables/nl.js.map +1 -0
  112. package/dist/i18n/tables/pt.d.ts +3 -0
  113. package/dist/i18n/tables/pt.d.ts.map +1 -0
  114. package/dist/i18n/tables/pt.js +82 -0
  115. package/dist/i18n/tables/pt.js.map +1 -0
  116. package/dist/i18n/tables/tr.d.ts +3 -0
  117. package/dist/i18n/tables/tr.d.ts.map +1 -0
  118. package/dist/i18n/tables/tr.js +82 -0
  119. package/dist/i18n/tables/tr.js.map +1 -0
  120. package/dist/i18n/types.d.ts +39 -0
  121. package/dist/i18n/types.d.ts.map +1 -0
  122. package/dist/i18n/types.js +2 -0
  123. package/dist/i18n/types.js.map +1 -0
  124. package/dist/layout/analytics.d.ts +9 -0
  125. package/dist/layout/analytics.d.ts.map +1 -0
  126. package/dist/layout/analytics.js +18 -0
  127. package/dist/layout/analytics.js.map +1 -0
  128. package/dist/layout/brand-files.d.ts +15 -0
  129. package/dist/layout/brand-files.d.ts.map +1 -0
  130. package/dist/layout/brand-files.js +15 -0
  131. package/dist/layout/brand-files.js.map +1 -0
  132. package/dist/layout/footer.d.ts +10 -0
  133. package/dist/layout/footer.d.ts.map +1 -0
  134. package/dist/layout/footer.js +21 -0
  135. package/dist/layout/footer.js.map +1 -0
  136. package/dist/layout/not-found.d.ts +7 -0
  137. package/dist/layout/not-found.d.ts.map +1 -0
  138. package/dist/layout/not-found.js +8 -0
  139. package/dist/layout/not-found.js.map +1 -0
  140. package/dist/layout/provider.d.ts +17 -0
  141. package/dist/layout/provider.d.ts.map +1 -0
  142. package/dist/layout/provider.js +14 -0
  143. package/dist/layout/provider.js.map +1 -0
  144. package/dist/layout/root.d.ts +17 -0
  145. package/dist/layout/root.d.ts.map +1 -0
  146. package/dist/layout/root.js +47 -0
  147. package/dist/layout/root.js.map +1 -0
  148. package/dist/lint/source.d.ts +19 -0
  149. package/dist/lint/source.d.ts.map +1 -0
  150. package/dist/lint/source.js +43 -0
  151. package/dist/lint/source.js.map +1 -0
  152. package/dist/llms/llms.d.ts +22 -0
  153. package/dist/llms/llms.d.ts.map +1 -0
  154. package/dist/llms/llms.js +24 -0
  155. package/dist/llms/llms.js.map +1 -0
  156. package/dist/markdown/article.d.ts +44 -0
  157. package/dist/markdown/article.d.ts.map +1 -0
  158. package/dist/markdown/article.js +108 -0
  159. package/dist/markdown/article.js.map +1 -0
  160. package/dist/markdown/inline.d.ts +40 -0
  161. package/dist/markdown/inline.d.ts.map +1 -0
  162. package/dist/markdown/inline.js +74 -0
  163. package/dist/markdown/inline.js.map +1 -0
  164. package/dist/markdown/page.d.ts +13 -0
  165. package/dist/markdown/page.d.ts.map +1 -0
  166. package/dist/markdown/page.js +21 -0
  167. package/dist/markdown/page.js.map +1 -0
  168. package/dist/marker.d.ts +37 -0
  169. package/dist/marker.d.ts.map +1 -0
  170. package/dist/marker.js +36 -0
  171. package/dist/marker.js.map +1 -0
  172. package/dist/mdx/allow-list.d.ts +23 -0
  173. package/dist/mdx/allow-list.d.ts.map +1 -0
  174. package/dist/mdx/allow-list.js +79 -0
  175. package/dist/mdx/allow-list.js.map +1 -0
  176. package/dist/mdx/components.d.ts +8 -0
  177. package/dist/mdx/components.d.ts.map +1 -0
  178. package/dist/mdx/components.js +68 -0
  179. package/dist/mdx/components.js.map +1 -0
  180. package/dist/mdx/remark-alerts.d.ts +4 -0
  181. package/dist/mdx/remark-alerts.d.ts.map +1 -0
  182. package/dist/mdx/remark-alerts.js +39 -0
  183. package/dist/mdx/remark-alerts.js.map +1 -0
  184. package/dist/next.d.ts +24 -0
  185. package/dist/next.d.ts.map +1 -0
  186. package/dist/next.js +55 -0
  187. package/dist/next.js.map +1 -0
  188. package/dist/node/bin.d.ts +3 -0
  189. package/dist/node/bin.d.ts.map +1 -0
  190. package/dist/node/bin.js +13 -0
  191. package/dist/node/bin.js.map +1 -0
  192. package/dist/node/brand.d.ts +13 -0
  193. package/dist/node/brand.d.ts.map +1 -0
  194. package/dist/node/brand.js +48 -0
  195. package/dist/node/brand.js.map +1 -0
  196. package/dist/node/build.d.ts +31 -0
  197. package/dist/node/build.d.ts.map +1 -0
  198. package/dist/node/build.js +151 -0
  199. package/dist/node/build.js.map +1 -0
  200. package/dist/node/cli.d.ts +11 -0
  201. package/dist/node/cli.d.ts.map +1 -0
  202. package/dist/node/cli.js +80 -0
  203. package/dist/node/cli.js.map +1 -0
  204. package/dist/node/config-file.d.ts +5 -0
  205. package/dist/node/config-file.d.ts.map +1 -0
  206. package/dist/node/config-file.js +31 -0
  207. package/dist/node/config-file.js.map +1 -0
  208. package/dist/node/content.d.ts +6 -0
  209. package/dist/node/content.d.ts.map +1 -0
  210. package/dist/node/content.js +36 -0
  211. package/dist/node/content.js.map +1 -0
  212. package/dist/node/errors.d.ts +26 -0
  213. package/dist/node/errors.d.ts.map +1 -0
  214. package/dist/node/errors.js +34 -0
  215. package/dist/node/errors.js.map +1 -0
  216. package/dist/node/files.d.ts +12 -0
  217. package/dist/node/files.d.ts.map +1 -0
  218. package/dist/node/files.js +43 -0
  219. package/dist/node/files.js.map +1 -0
  220. package/dist/node/og.d.ts +17 -0
  221. package/dist/node/og.d.ts.map +1 -0
  222. package/dist/node/og.js +43 -0
  223. package/dist/node/og.js.map +1 -0
  224. package/dist/node/project-root.d.ts +12 -0
  225. package/dist/node/project-root.d.ts.map +1 -0
  226. package/dist/node/project-root.js +27 -0
  227. package/dist/node/project-root.js.map +1 -0
  228. package/dist/node/serve.d.ts +32 -0
  229. package/dist/node/serve.d.ts.map +1 -0
  230. package/dist/node/serve.js +133 -0
  231. package/dist/node/serve.js.map +1 -0
  232. package/dist/node/theme.d.ts +15 -0
  233. package/dist/node/theme.d.ts.map +1 -0
  234. package/dist/node/theme.js +46 -0
  235. package/dist/node/theme.js.map +1 -0
  236. package/dist/search/dialog.d.ts +14 -0
  237. package/dist/search/dialog.d.ts.map +1 -0
  238. package/dist/search/dialog.js +17 -0
  239. package/dist/search/dialog.js.map +1 -0
  240. package/dist/search/language.d.ts +8 -0
  241. package/dist/search/language.d.ts.map +1 -0
  242. package/dist/search/language.js +30 -0
  243. package/dist/search/language.js.map +1 -0
  244. package/dist/search/route.d.ts +9 -0
  245. package/dist/search/route.d.ts.map +1 -0
  246. package/dist/search/route.js +11 -0
  247. package/dist/search/route.js.map +1 -0
  248. package/dist/seo/article.d.ts +84 -0
  249. package/dist/seo/article.d.ts.map +1 -0
  250. package/dist/seo/article.js +117 -0
  251. package/dist/seo/article.js.map +1 -0
  252. package/dist/seo/collection.d.ts +19 -0
  253. package/dist/seo/collection.d.ts.map +1 -0
  254. package/dist/seo/collection.js +30 -0
  255. package/dist/seo/collection.js.map +1 -0
  256. package/dist/seo/dataset.d.ts +31 -0
  257. package/dist/seo/dataset.d.ts.map +1 -0
  258. package/dist/seo/dataset.js +33 -0
  259. package/dist/seo/dataset.js.map +1 -0
  260. package/dist/seo/json-ld.d.ts +6 -0
  261. package/dist/seo/json-ld.d.ts.map +1 -0
  262. package/dist/seo/json-ld.js +8 -0
  263. package/dist/seo/json-ld.js.map +1 -0
  264. package/dist/seo/script-json.d.ts +8 -0
  265. package/dist/seo/script-json.d.ts.map +1 -0
  266. package/dist/seo/script-json.js +12 -0
  267. package/dist/seo/script-json.js.map +1 -0
  268. package/dist/seo/title.d.ts +11 -0
  269. package/dist/seo/title.d.ts.map +1 -0
  270. package/dist/seo/title.js +11 -0
  271. package/dist/seo/title.js.map +1 -0
  272. package/dist/seo/x-handle.d.ts +9 -0
  273. package/dist/seo/x-handle.d.ts.map +1 -0
  274. package/dist/seo/x-handle.js +21 -0
  275. package/dist/seo/x-handle.js.map +1 -0
  276. package/dist/site/app.d.ts +56 -0
  277. package/dist/site/app.d.ts.map +1 -0
  278. package/dist/site/app.js +79 -0
  279. package/dist/site/app.js.map +1 -0
  280. package/dist/site/features.d.ts +26 -0
  281. package/dist/site/features.d.ts.map +1 -0
  282. package/dist/site/features.js +46 -0
  283. package/dist/site/features.js.map +1 -0
  284. package/dist/site/metadata.d.ts +6 -0
  285. package/dist/site/metadata.d.ts.map +1 -0
  286. package/dist/site/metadata.js +78 -0
  287. package/dist/site/metadata.js.map +1 -0
  288. package/dist/site/outputs.d.ts +24 -0
  289. package/dist/site/outputs.d.ts.map +1 -0
  290. package/dist/site/outputs.js +113 -0
  291. package/dist/site/outputs.js.map +1 -0
  292. package/dist/site/posts.d.ts +6 -0
  293. package/dist/site/posts.d.ts.map +1 -0
  294. package/dist/site/posts.js +9 -0
  295. package/dist/site/posts.js.map +1 -0
  296. package/dist/site/routes.d.ts +43 -0
  297. package/dist/site/routes.d.ts.map +1 -0
  298. package/dist/site/routes.js +94 -0
  299. package/dist/site/routes.js.map +1 -0
  300. package/dist/site/site-page.d.ts +11 -0
  301. package/dist/site/site-page.d.ts.map +1 -0
  302. package/dist/site/site-page.js +70 -0
  303. package/dist/site/site-page.js.map +1 -0
  304. package/dist/site/sources.d.ts +58 -0
  305. package/dist/site/sources.d.ts.map +1 -0
  306. package/dist/site/sources.js +2 -0
  307. package/dist/site/sources.js.map +1 -0
  308. package/dist/site/url-style.d.ts +21 -0
  309. package/dist/site/url-style.d.ts.map +1 -0
  310. package/dist/site/url-style.js +18 -0
  311. package/dist/site/url-style.js.map +1 -0
  312. package/dist/website/blocks/commerce.d.ts +41 -0
  313. package/dist/website/blocks/commerce.d.ts.map +1 -0
  314. package/dist/website/blocks/commerce.js +26 -0
  315. package/dist/website/blocks/commerce.js.map +1 -0
  316. package/dist/website/blocks/content.d.ts +41 -0
  317. package/dist/website/blocks/content.d.ts.map +1 -0
  318. package/dist/website/blocks/content.js +25 -0
  319. package/dist/website/blocks/content.js.map +1 -0
  320. package/dist/website/blocks/marketing.d.ts +32 -0
  321. package/dist/website/blocks/marketing.d.ts.map +1 -0
  322. package/dist/website/blocks/marketing.js +23 -0
  323. package/dist/website/blocks/marketing.js.map +1 -0
  324. package/dist/website/blocks/parts.d.ts +26 -0
  325. package/dist/website/blocks/parts.d.ts.map +1 -0
  326. package/dist/website/blocks/parts.js +13 -0
  327. package/dist/website/blocks/parts.js.map +1 -0
  328. package/dist/website/page-view.d.ts +12 -0
  329. package/dist/website/page-view.d.ts.map +1 -0
  330. package/dist/website/page-view.js +10 -0
  331. package/dist/website/page-view.js.map +1 -0
  332. package/dist/zod.d.ts +8 -0
  333. package/dist/zod.d.ts.map +1 -0
  334. package/dist/zod.js +8 -0
  335. package/dist/zod.js.map +1 -0
  336. package/package.json +187 -3
  337. package/styles.css +326 -0
@@ -0,0 +1,43 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readdir, readFile } from "node:fs/promises";
3
+ import { join, relative, sep } from "node:path";
4
+ import { outputHashInput } from "../marker.js";
5
+ /** Every file under a folder, as sorted POSIX paths relative to it, skipping the named folders and files. */
6
+ export async function listTree(root, skip = new Set()) {
7
+ const entries = await readdir(root, { withFileTypes: true, recursive: true });
8
+ return entries
9
+ .filter((entry) => entry.isFile())
10
+ .map((entry) => relative(root, join(entry.parentPath, entry.name)).split(sep).join("/"))
11
+ .filter((path) => !path.split("/").some((part) => skip.has(part)))
12
+ .sort();
13
+ }
14
+ const sha256 = (data) => createHash("sha256").update(data).digest("hex");
15
+ /** How many files a step reads at once: well under the default open-file limit (256 on macOS). */
16
+ export const FILE_CONCURRENCY = 32;
17
+ /** `items.map(fn)` with at most `limit` calls in flight, results in input order. */
18
+ export async function mapLimit(items, limit, fn) {
19
+ const results = new Array(items.length);
20
+ let next = 0;
21
+ // Each worker takes the next index until none is left; the counter is shared on purpose.
22
+ const worker = async () => {
23
+ while (next < items.length) {
24
+ const index = next++;
25
+ results[index] = await fn(items[index]);
26
+ }
27
+ };
28
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
29
+ return results;
30
+ }
31
+ /**
32
+ * One hash for a folder: each file's path and the hash of its bytes, in path order. The same
33
+ * files give the same hash on any machine, whatever order the file system lists them in.
34
+ */
35
+ export async function hashTree(root, skip = new Set()) {
36
+ const paths = await listTree(root, skip);
37
+ const digests = await mapLimit(paths, FILE_CONCURRENCY, async (path) => ({
38
+ path,
39
+ sha256: sha256(await readFile(join(root, path))),
40
+ }));
41
+ return `sha256:${sha256(outputHashInput(digests))}`;
42
+ }
43
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/node/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE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AAG,CAAC,CAAC;IACb,yFAAyF;IACzF,MAAM,MAAM,GAAG,KAAK,IAAmB,EAAE;QACxC,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,OAA4B,IAAI,GAAG,EAAE;IACjF,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACxE,IAAI;QACJ,MAAM,EAAE,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;KAChD,CAAC,CAAC,CAAC;IACJ,OAAO,UAAU,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Dna } from "@lets-ship/brand-dna/schema/dna";
2
+ export declare const OG_WIDTH = 1200;
3
+ export declare const OG_HEIGHT = 630;
4
+ /**
5
+ * The social card of a page, in the brand's light colours and display face: the mark, the
6
+ * title and one line under it, on the brand's surface with a bar in its primary colour.
7
+ */
8
+ export declare function ogCardHtml(dna: Dna, text: {
9
+ readonly title: string;
10
+ readonly subtitle: string;
11
+ }): string;
12
+ /** Renders a social card to PNG with the catalog fonts, so no system font ever reaches it. */
13
+ export declare function renderOgCard(dna: Dna, mark: Uint8Array, text: {
14
+ readonly title: string;
15
+ readonly subtitle: string;
16
+ }): Promise<Uint8Array>;
17
+ //# sourceMappingURL=og.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"og.d.ts","sourceRoot":"","sources":["../../src/node/og.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAG3D,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,SAAS,MAAM,CAAC;AAW7B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAaxG;AAED,8FAA8F;AAC9F,wBAAsB,YAAY,CACjC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD,OAAO,CAAC,UAAU,CAAC,CASrB"}
@@ -0,0 +1,43 @@
1
+ import { resolvedFamilies, roleHex } from "@lets-ship/brand-dna/core/compile/shared";
2
+ import { indexTokens } from "@lets-ship/brand-dna/core/tokens/resolve";
3
+ import { catalogRenderer } from "@lets-ship/brand-dna/node/pack";
4
+ import { buildStepError } from "./errors.js";
5
+ export const OG_WIDTH = 1200;
6
+ export const OG_HEIGHT = 630;
7
+ const escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
8
+ function role(dna, name) {
9
+ const hex = roleHex(indexTokens(dna.tokens), dna, name, "light");
10
+ if (!hex)
11
+ throw buildStepError("og", `the brand DNA has no ${name} colour for the light mode`);
12
+ return hex;
13
+ }
14
+ /**
15
+ * The social card of a page, in the brand's light colours and display face: the mark, the
16
+ * title and one line under it, on the brand's surface with a bar in its primary colour.
17
+ */
18
+ export function ogCardHtml(dna, text) {
19
+ const index = indexTokens(dna.tokens);
20
+ const display = resolvedFamilies(index, dna.tokens.font.display.$value)[0];
21
+ const body = resolvedFamilies(index, dna.tokens.font.body.$value)[0];
22
+ return [
23
+ `<div style="display:flex;flex-direction:column;justify-content:space-between;width:${OG_WIDTH}px;height:${OG_HEIGHT}px;padding:72px;background:${role(dna, "surface")};border-top:16px solid ${role(dna, "primary")}">`,
24
+ '<img src="mark.svg" width="96" height="96" />',
25
+ '<div style="display:flex;flex-direction:column;gap:24px">',
26
+ `<div style="font-family:'${display}';font-weight:700;font-size:64px;line-height:1.1;color:${role(dna, "on-surface")}">${escapeHtml(text.title)}</div>`,
27
+ `<div style="font-family:'${body}';font-size:32px;line-height:1.4;color:${role(dna, "muted")}">${escapeHtml(text.subtitle)}</div>`,
28
+ "</div>",
29
+ "</div>",
30
+ ].join("");
31
+ }
32
+ /** Renders a social card to PNG with the catalog fonts, so no system font ever reaches it. */
33
+ export async function renderOgCard(dna, mark, text) {
34
+ const renderer = await catalogRenderer();
35
+ return renderer.render({
36
+ html: ogCardHtml(dna, text),
37
+ width: OG_WIDTH,
38
+ height: OG_HEIGHT,
39
+ format: "png",
40
+ images: [{ src: "mark.svg", data: mark }],
41
+ });
42
+ }
43
+ //# sourceMappingURL=og.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"og.js","sourceRoot":"","sources":["../../src/node/og.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AA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CAA+C;QAC/C,2DAA2D;QAC3D,4BAA4B,OAAO,0DAA0D,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QACvJ,4BAA4B,IAAI,0CAA0C,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ;QAClI,QAAQ;QACR,QAAQ;KACR,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,GAAQ,EACR,IAAgB,EAChB,IAA2D;IAE3D,MAAM,QAAQ,GAAG,MAAM,eAAe,EAAE,CAAC;IACzC,OAAO,QAAQ,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC;QAC3B,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACzC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { SiteInputError } from "./errors.js";
2
+ /** The lockfiles a package manager writes at the root of the project it installs. */
3
+ export declare const LOCKFILES: readonly string[];
4
+ export declare const projectRootError: (dir: string) => SiteInputError;
5
+ /**
6
+ * The root of the project a site is installed in: the nearest folder at or above the site that
7
+ * holds a lockfile, as the package manager that installed it decides. Next makes module paths in
8
+ * the output relative to this root, so a root Next guesses (it takes the outermost lockfile it
9
+ * finds) gives a site in a nested checkout other bytes than the same site anywhere else.
10
+ */
11
+ export declare function projectRoot(dir: string, at?: string): string;
12
+ //# sourceMappingURL=project-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-root.d.ts","sourceRoot":"","sources":["../../src/node/project-root.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qFAAqF;AACrF,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAMtC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,cAK7C,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,GAAG,MAAM,CAKjE"}
@@ -0,0 +1,27 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { SiteInputError } from "./errors.js";
4
+ /** The lockfiles a package manager writes at the root of the project it installs. */
5
+ export const LOCKFILES = [
6
+ "pnpm-lock.yaml",
7
+ "package-lock.json",
8
+ "yarn.lock",
9
+ "bun.lock",
10
+ "bun.lockb",
11
+ ];
12
+ export const projectRootError = (dir) => new SiteInputError("ProjectRootError", `no lockfile in ${dir} or in a folder above it. Install the site's dependencies first, for example with npm install.`, []);
13
+ /**
14
+ * The root of the project a site is installed in: the nearest folder at or above the site that
15
+ * holds a lockfile, as the package manager that installed it decides. Next makes module paths in
16
+ * the output relative to this root, so a root Next guesses (it takes the outermost lockfile it
17
+ * finds) gives a site in a nested checkout other bytes than the same site anywhere else.
18
+ */
19
+ export function projectRoot(dir, at = dir) {
20
+ if (LOCKFILES.some((file) => existsSync(join(at, file))))
21
+ return at;
22
+ const parent = dirname(at);
23
+ if (parent === at)
24
+ throw projectRootError(dir);
25
+ return projectRoot(dir, parent);
26
+ }
27
+ //# sourceMappingURL=project-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-root.js","sourceRoot":"","sources":["../../src/node/project-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC3C,gBAAgB;IAChB,mBAAmB;IACnB,WAAW;IACX,UAAU;IACV,WAAW;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAkB,EAAE,CAC/D,IAAI,cAAc,CACjB,kBAAkB,EAClB,kBAAkB,GAAG,gGAAgG,EACrH,EAAE,CACF,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,KAAa,GAAG;IACxD,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3B,IAAI,MAAM,KAAK,EAAE;QAAE,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type Server } from "node:http";
2
+ /**
3
+ * `ship-site serve`: a static export served as SHIP Sites hosting serves it (architecture 7.5),
4
+ * with the asset store's `auto-trailing-slash` and `404-page` rules and the site's `_headers`, so
5
+ * a template's QA run sees what its visitors will.
6
+ */
7
+ export type Resolution = {
8
+ readonly kind: "file";
9
+ readonly path: string;
10
+ readonly status: 200 | 404;
11
+ } | {
12
+ readonly kind: "redirect";
13
+ readonly location: string;
14
+ } | {
15
+ readonly kind: "bad-request";
16
+ } | {
17
+ readonly kind: "missing";
18
+ };
19
+ /** Maps a request path to a file, a redirect or the 404 page, as `auto-trailing-slash` does. */
20
+ export declare function resolvePath(files: ReadonlySet<string>, pathname: string): Resolution;
21
+ /**
22
+ * The `_headers` rules (`/path` or `/prefix/*`, then indented `Name: value` lines) that match a
23
+ * path. Two rules that set one header combine, as the asset store combines them.
24
+ */
25
+ export declare function headersFor(rules: string, pathname: string): Record<string, string>;
26
+ /**
27
+ * Starts the server; resolves once it listens. Port 0 picks a free port. The folder is read on
28
+ * each request, so a build that finishes while the server is up is served as it now stands, and a
29
+ * request during that build gets a 503 rather than stopping the server.
30
+ */
31
+ export declare function serveStatic(root: string, port: number): Promise<Server>;
32
+ //# sourceMappingURL=serve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/node/serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAC;AAKjG;;;;GAIG;AACH,MAAM,MAAM,UAAU,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAwBhC,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAiBpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBlF;AA0CD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB7E"}
@@ -0,0 +1,133 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { createServer } from "node:http";
3
+ import { extname, join } from "node:path";
4
+ import { SiteInputError } from "./errors.js";
5
+ import { listTree } from "./files.js";
6
+ /** Hosting reads these as configuration and never serves them. */
7
+ const CONFIG_FILES = new Set(["_headers"]);
8
+ /** The nearest 404.html at or above a path, as the asset store's `404-page` handling picks it. */
9
+ function notFoundPage(files, path) {
10
+ const parts = path.split("/").filter(Boolean);
11
+ const candidates = [...parts.map((_, i) => parts.slice(0, parts.length - i).join("/")), ""].map((folder) => folder ? `${folder}/404.html` : "404.html");
12
+ const page = candidates.find((candidate) => files.has(candidate));
13
+ return page ? { kind: "file", path: page, status: 404 } : { kind: "missing" };
14
+ }
15
+ function decoded(pathname) {
16
+ try {
17
+ return decodeURIComponent(pathname).replace(/^\/+/, "");
18
+ }
19
+ catch {
20
+ // A malformed percent-encoding (`/%`) is the client's error, answered with a 400.
21
+ return undefined;
22
+ }
23
+ }
24
+ /** Maps a request path to a file, a redirect or the 404 page, as `auto-trailing-slash` does. */
25
+ export function resolvePath(files, pathname) {
26
+ const path = decoded(pathname);
27
+ if (path === undefined)
28
+ return { kind: "bad-request" };
29
+ if (path.split("/").includes("..") || CONFIG_FILES.has(path))
30
+ return notFoundPage(files, "");
31
+ if (path === "" || path.endsWith("/")) {
32
+ const index = `${path}index.html`;
33
+ if (files.has(index))
34
+ return { kind: "file", path: index, status: 200 };
35
+ if (files.has(`${path.slice(0, -1)}.html`))
36
+ return { kind: "redirect", location: `/${path.slice(0, -1)}` };
37
+ return notFoundPage(files, path);
38
+ }
39
+ if (files.has(path))
40
+ return path.endsWith(".html") && !path.endsWith("404.html")
41
+ ? { kind: "redirect", location: `/${path.slice(0, -5).replace(/(^|\/)index$/, "$1")}` }
42
+ : { kind: "file", path, status: 200 };
43
+ if (files.has(`${path}/index.html`))
44
+ return { kind: "redirect", location: `/${path}/` };
45
+ if (files.has(`${path}.html`))
46
+ return { kind: "file", path: `${path}.html`, status: 200 };
47
+ return notFoundPage(files, path);
48
+ }
49
+ /**
50
+ * The `_headers` rules (`/path` or `/prefix/*`, then indented `Name: value` lines) that match a
51
+ * path. Two rules that set one header combine, as the asset store combines them.
52
+ */
53
+ export function headersFor(rules, pathname) {
54
+ const blocks = rules.split(/\n(?=\S)/).map((block) => block.split("\n"));
55
+ const pairs = blocks.flatMap(([pattern = "", ...lines]) => {
56
+ const target = pattern.trim();
57
+ const matches = target.endsWith("*") ? pathname.startsWith(target.slice(0, -1)) : pathname === target;
58
+ if (!matches)
59
+ return [];
60
+ return lines
61
+ .map((line) => /^\s+([^:]+):\s*(.*)$/.exec(line))
62
+ .flatMap((m) => (m?.[1] && m[2] !== undefined ? [[m[1].trim().toLowerCase(), m[2].trim()]] : []));
63
+ });
64
+ const names = [...new Set(pairs.map(([name]) => name))];
65
+ return Object.fromEntries(names.map((name) => [
66
+ name,
67
+ pairs
68
+ .filter(([other]) => other === name)
69
+ .map(([, value]) => value)
70
+ .join(", "),
71
+ ]));
72
+ }
73
+ const TYPES = {
74
+ ".html": "text/html; charset=utf-8",
75
+ ".css": "text/css; charset=utf-8",
76
+ ".js": "text/javascript; charset=utf-8",
77
+ ".json": "application/json",
78
+ ".txt": "text/plain; charset=utf-8",
79
+ ".md": "text/markdown; charset=utf-8",
80
+ ".csv": "text/csv; charset=utf-8",
81
+ ".xml": "application/xml",
82
+ ".map": "application/json",
83
+ ".svg": "image/svg+xml",
84
+ ".png": "image/png",
85
+ ".jpg": "image/jpeg",
86
+ ".jpeg": "image/jpeg",
87
+ ".gif": "image/gif",
88
+ ".webp": "image/webp",
89
+ ".avif": "image/avif",
90
+ ".ico": "image/x-icon",
91
+ ".mp4": "video/mp4",
92
+ ".webm": "video/webm",
93
+ ".woff": "font/woff",
94
+ ".woff2": "font/woff2",
95
+ };
96
+ async function answer(root, request, response) {
97
+ const { pathname } = new URL(request.url ?? "/", "http://localhost");
98
+ const files = new Set(await listTree(root));
99
+ const rules = files.has("_headers") ? await readFile(join(root, "_headers"), "utf8") : "";
100
+ const hit = resolvePath(files, pathname);
101
+ if (hit.kind === "redirect")
102
+ return void response.writeHead(307, { location: hit.location }).end();
103
+ if (hit.kind === "bad-request")
104
+ return void response.writeHead(400).end("Bad request: malformed URL encoding");
105
+ if (hit.kind === "missing")
106
+ return void response.writeHead(404).end("Not found");
107
+ const type = TYPES[extname(hit.path)] ?? "application/octet-stream";
108
+ const body = await readFile(join(root, hit.path));
109
+ response.writeHead(hit.status, { "content-type": type, ...headersFor(rules, pathname) }).end(body);
110
+ }
111
+ /** A request while a build has the folder half written: the folder or a file is gone for a moment. */
112
+ const isMidBuild = (error) => error.code === "ENOENT";
113
+ /**
114
+ * Starts the server; resolves once it listens. Port 0 picks a free port. The folder is read on
115
+ * each request, so a build that finishes while the server is up is served as it now stands, and a
116
+ * request during that build gets a 503 rather than stopping the server.
117
+ */
118
+ export async function serveStatic(root, port) {
119
+ const folder = await stat(root).catch(() => undefined);
120
+ if (!folder?.isDirectory())
121
+ throw new SiteInputError("ServeError", `${root} is not a folder. Build the site first, then serve its out folder.`, []);
122
+ const server = createServer((request, response) => {
123
+ answer(root, request, response).catch((error) => {
124
+ if (isMidBuild(error))
125
+ return void response.writeHead(503).end("The site is being built. Try again.");
126
+ console.error("ship-site serve:", error);
127
+ response.writeHead(500).end("Internal error");
128
+ });
129
+ });
130
+ await new Promise((resolve) => server.listen(port, "127.0.0.1", resolve));
131
+ return server;
132
+ }
133
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/node/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY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C,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { SiteIdentity } from "../config/identity.js";
2
+ import type { LoadedBrand } from "./brand.js";
3
+ /** Where the compiled brand goes. Git ignores it; every build writes it again from the DNA. */
4
+ export declare const THEME_DIR = ".ship-site/theme";
5
+ /** The brand files the site serves (icons, logos, the social card), generated and git-ignored too. */
6
+ export declare const BRAND_PUBLIC_DIR = "public/_brand";
7
+ /** The contract major of a compiled site theme, from its first line (`theme-contract@1.0 ...`). */
8
+ export declare function themeContractMajor(css: string): number | undefined;
9
+ /**
10
+ * Compiles the brand: site-theme.css, the fonts and the Shiki themes into the theme folder, and
11
+ * the icons, logos and default social card into the served folder. The engine reads only these
12
+ * for its look (D27), so a theme of another contract major stops the build here.
13
+ */
14
+ export declare function compileTheme(dir: string, brand: LoadedBrand, identity: SiteIdentity): Promise<void>;
15
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/node/theme.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,+FAA+F;AAC/F,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAC5C,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,kBAA+B,CAAC;AAK7D,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGlE;AAeD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAczG"}
@@ -0,0 +1,46 @@
1
+ import { readFile, rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { buildDna } from "@lets-ship/brand-dna/core/compile/build";
4
+ import { SITE_THEME_PATH, THEME_CONTRACT_MAJOR } from "@lets-ship/brand-dna/core/compile/site-theme-rules";
5
+ import { shikiThemes } from "@lets-ship/brand-dna/core/site/shiki";
6
+ import { writeFiles } from "@lets-ship/brand-dna/node/io";
7
+ import { renderPack } from "@lets-ship/brand-dna/node/pack";
8
+ import { BRAND_PUBLIC_PATH, OG_DEFAULT } from "../layout/brand-files.js";
9
+ import { buildStepError } from "./errors.js";
10
+ import { renderOgCard } from "./og.js";
11
+ /** Where the compiled brand goes. Git ignores it; every build writes it again from the DNA. */
12
+ export const THEME_DIR = ".ship-site/theme";
13
+ /** The brand files the site serves (icons, logos, the social card), generated and git-ignored too. */
14
+ export const BRAND_PUBLIC_DIR = `public${BRAND_PUBLIC_PATH}`;
15
+ /** The pack files a browser fetches by URL; the rest (CSS, fonts) reach the page through the CSS. */
16
+ const SERVED = /^(favicon\.(ico|svg)|apple-touch-icon\.png|icon-\d+\.png|logo\/)/;
17
+ /** The contract major of a compiled site theme, from its first line (`theme-contract@1.0 ...`). */
18
+ export function themeContractMajor(css) {
19
+ const match = /theme-contract@(\d+)\./.exec(css.slice(0, 200));
20
+ return match ? Number(match[1]) : undefined;
21
+ }
22
+ async function servedFiles(files, brand, identity) {
23
+ const mark = files.find((f) => f.path === "favicon.svg");
24
+ if (!mark || typeof mark.content === "string")
25
+ throw buildStepError("theme", "the brand build wrote no favicon.svg");
26
+ const og = await renderOgCard(brand.dna, mark.content, { title: identity.name, subtitle: identity.description });
27
+ return [...files.filter((f) => SERVED.test(f.path)), { path: OG_DEFAULT, content: og }];
28
+ }
29
+ /**
30
+ * Compiles the brand: site-theme.css, the fonts and the Shiki themes into the theme folder, and
31
+ * the icons, logos and default social card into the served folder. The engine reads only these
32
+ * for its look (D27), so a theme of another contract major stops the build here.
33
+ */
34
+ export async function compileTheme(dir, brand, identity) {
35
+ const theme = join(dir, THEME_DIR);
36
+ const served = join(dir, BRAND_PUBLIC_DIR);
37
+ await Promise.all([rm(theme, { recursive: true, force: true }), rm(served, { recursive: true, force: true })]);
38
+ const pack = await renderPack(brand.dna, { logos: brand.assets, fonts: brand.assets });
39
+ const { files } = await buildDna(brand.dna, pack);
40
+ await writeFiles(theme, [...files, { path: "shiki.json", content: shikiThemes(brand.dna) }]);
41
+ await writeFiles(served, await servedFiles(files, brand, identity));
42
+ const major = themeContractMajor(await readFile(join(theme, SITE_THEME_PATH), "utf8"));
43
+ if (major !== THEME_CONTRACT_MAJOR)
44
+ throw buildStepError("theme", `site-theme.css has contract major ${major}; this engine reads ${THEME_CONTRACT_MAJOR}`);
45
+ }
46
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/node/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAC5C,sGAAsG;AACtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,iBAAiB,EAAE,C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G,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC3C,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/G,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7F,MAAM,UAAU,CAAC,MAAM,EAAE,MAAM,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACvF,IAAI,KAAK,KAAK,oBAAoB;QACjC,MAAM,cAAc,CACnB,OAAO,EACP,qCAAqC,KAAK,uBAAuB,oBAAoB,EAAE,CACvF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type SharedProps } from "fumadocs-ui/components/dialog/search";
2
+ import { type ReactElement } from "react";
3
+ export type SiteSearchProps = SharedProps & {
4
+ /** The tokeniser language the index was built with (searchLanguage). */
5
+ readonly language: string;
6
+ /** Where the build put the index. */
7
+ readonly from: string;
8
+ };
9
+ /**
10
+ * Static search: the index is a file of the export, downloaded on the first search and queried
11
+ * in the browser, so search needs no server and costs nothing per keystroke.
12
+ */
13
+ export declare function SiteSearchDialog({ language, from, ...props }: SiteSearchProps): ReactElement;
14
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/search/dialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EASN,KAAK,WAAW,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,KAAK,YAAY,EAAW,MAAM,OAAO,CAAC;AAGnD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC3C,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,GAAG,YAAY,CAmB5F"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useDocsSearch } from "fumadocs-core/search/client";
4
+ import { staticClient } from "fumadocs-core/search/client/orama-static";
5
+ import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, } from "fumadocs-ui/components/dialog/search";
6
+ import { useMemo } from "react";
7
+ import { create } from "zbsearch";
8
+ /**
9
+ * Static search: the index is a file of the export, downloaded on the first search and queried
10
+ * in the browser, so search needs no server and costs nothing per keystroke.
11
+ */
12
+ export function SiteSearchDialog({ language, from, ...props }) {
13
+ const client = useMemo(() => staticClient({ from, initDB: () => create({ schema: { _: "string" }, language }) }), [from, language]);
14
+ const { search, setSearch, query } = useDocsSearch({ client });
15
+ return (_jsxs(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, ...props, children: [_jsx(SearchDialogOverlay, {}), _jsxs(SearchDialogContent, { children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : null })] })] }));
16
+ }
17
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/search/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EACN,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GAEnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAqB,OAAO,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAmB;IAC7E,MAAM,MAAM,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,EACzF,CAAC,IAAI,EAAE,QAAQ,CAAC,CAChB,CAAC;IACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,OAAO,CACN,MAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,KAAM,KAAK,aAC7F,KAAC,mBAAmB,KAAG,EACvB,MAAC,mBAAmB,eACnB,MAAC,kBAAkB,eAClB,KAAC,gBAAgB,KAAG,EACpB,KAAC,iBAAiB,KAAG,EACrB,KAAC,iBAAiB,KAAG,IACD,EACrB,KAAC,gBAAgB,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,IAClD,IACR,CACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Where a site's search index lives; the dialog downloads it from the same path. */
2
+ export declare const SEARCH_INDEX_PATH = "/api/search";
3
+ /** A locale whose language the search index cannot tokenise. */
4
+ export declare class SearchLanguageError extends Error {
5
+ constructor(locale: string);
6
+ }
7
+ export declare function searchLanguage(locale: string): string;
8
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/search/language.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAiB/C,gEAAgE;AAChE,qBAAa,mBAAoB,SAAQ,KAAK;gBACjC,MAAM,EAAE,MAAM;CAI1B;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIrD"}
@@ -0,0 +1,30 @@
1
+ /** Where a site's search index lives; the dialog downloads it from the same path. */
2
+ export const SEARCH_INDEX_PATH = "/api/search";
3
+ /**
4
+ * The search index tokenises words in the site's language, and the browser must tokenise a query
5
+ * the same way, so both take the language from here. Each language with an interface table has
6
+ * a tokeniser.
7
+ */
8
+ const SEARCH_LANGUAGES = {
9
+ en: "english",
10
+ de: "german",
11
+ fr: "french",
12
+ es: "spanish",
13
+ nl: "dutch",
14
+ pt: "portuguese",
15
+ tr: "turkish",
16
+ };
17
+ /** A locale whose language the search index cannot tokenise. */
18
+ export class SearchLanguageError extends Error {
19
+ constructor(locale) {
20
+ super(`search: no tokeniser for locale "${locale}". Supported: ${Object.keys(SEARCH_LANGUAGES).join(", ")}.`);
21
+ this.name = "SearchLanguageError";
22
+ }
23
+ }
24
+ export function searchLanguage(locale) {
25
+ const language = SEARCH_LANGUAGES[locale.toLowerCase().split("-")[0] ?? ""];
26
+ if (!language)
27
+ throw new SearchLanguageError(locale);
28
+ return language;
29
+ }
30
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/search/language.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C;;;;GAIG;AACH,MAAM,gBAAgB,GAAqC;IAC1D,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,SAAS;CACb,CAAC;AAEF,gEAAgE;AAChE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,MAAc;QACzB,KAAK,CAAC,oCAAoC,MAAM,iBAAiB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9G,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD;AAED,MAAM,UAAU,cAAc,CAAC,MAAc;IAC5C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type AdvancedIndex } from "fumadocs-core/search/server";
2
+ export type { AdvancedIndex as SearchEntry };
3
+ /**
4
+ * The GET handler of `app/api/search/route.ts`: the static index of the pages given, each with
5
+ * its structured content, tokenised in the site's language. Export it with
6
+ * `export const revalidate = false`.
7
+ */
8
+ export declare function searchIndexRoute(entries: AdvancedIndex[], locale: string): () => Promise<Response>;
9
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/search/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,6BAA6B,CAAC;AAGlF,YAAY,EAAE,aAAa,IAAI,WAAW,EAAE,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAElG"}
@@ -0,0 +1,11 @@
1
+ import { createSearchAPI } from "fumadocs-core/search/server";
2
+ import { searchLanguage } from "./language.js";
3
+ /**
4
+ * The GET handler of `app/api/search/route.ts`: the static index of the pages given, each with
5
+ * its structured content, tokenised in the site's language. Export it with
6
+ * `export const revalidate = false`.
7
+ */
8
+ export function searchIndexRoute(entries, locale) {
9
+ return createSearchAPI("advanced", { language: searchLanguage(locale), indexes: entries }).staticGET;
10
+ }
11
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/search/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAwB,EAAE,MAAc;IACxE,OAAO,eAAe,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;AACtG,CAAC"}