fulldev-ui 0.27.2 → 0.28.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/public/r/styles/base-luma/images.json +18 -0
- package/public/r/styles/base-luma/og.json +47 -0
- package/public/r/styles/base-luma/registry.json +57 -0
- package/public/r/styles/base-lyra/images.json +18 -0
- package/public/r/styles/base-lyra/og.json +47 -0
- package/public/r/styles/base-lyra/registry.json +57 -0
- package/public/r/styles/base-maia/images.json +18 -0
- package/public/r/styles/base-maia/og.json +47 -0
- package/public/r/styles/base-maia/registry.json +57 -0
- package/public/r/styles/base-mira/images.json +18 -0
- package/public/r/styles/base-mira/og.json +47 -0
- package/public/r/styles/base-mira/registry.json +57 -0
- package/public/r/styles/base-nova/images.json +18 -0
- package/public/r/styles/base-nova/og.json +47 -0
- package/public/r/styles/base-nova/registry.json +57 -0
- package/public/r/styles/base-rhea/images.json +18 -0
- package/public/r/styles/base-rhea/og.json +47 -0
- package/public/r/styles/base-rhea/registry.json +57 -0
- package/public/r/styles/base-sera/images.json +18 -0
- package/public/r/styles/base-sera/og.json +47 -0
- package/public/r/styles/base-sera/registry.json +57 -0
- package/public/r/styles/base-vega/images.json +18 -0
- package/public/r/styles/base-vega/og.json +47 -0
- package/public/r/styles/base-vega/registry.json +57 -0
|
@@ -4682,6 +4682,63 @@
|
|
|
4682
4682
|
}
|
|
4683
4683
|
}
|
|
4684
4684
|
},
|
|
4685
|
+
{
|
|
4686
|
+
"name": "images",
|
|
4687
|
+
"type": "registry:file",
|
|
4688
|
+
"title": "Images",
|
|
4689
|
+
"description": "Converts a site's source photos to WebP within 3840 pixels and updates their references; `--check` checks them.",
|
|
4690
|
+
"dependencies": [
|
|
4691
|
+
"sharp"
|
|
4692
|
+
],
|
|
4693
|
+
"files": [
|
|
4694
|
+
{
|
|
4695
|
+
"path": "scripts/images.ts",
|
|
4696
|
+
"type": "registry:file",
|
|
4697
|
+
"target": "~/scripts/images.ts"
|
|
4698
|
+
}
|
|
4699
|
+
]
|
|
4700
|
+
},
|
|
4701
|
+
{
|
|
4702
|
+
"name": "og",
|
|
4703
|
+
"type": "registry:file",
|
|
4704
|
+
"title": "Open Graph images",
|
|
4705
|
+
"description": "Draws each page's Open Graph image from the built site, checks them, and keeps them in Netlify's build cache.",
|
|
4706
|
+
"dependencies": [
|
|
4707
|
+
"sharp"
|
|
4708
|
+
],
|
|
4709
|
+
"devDependencies": [
|
|
4710
|
+
"parse5",
|
|
4711
|
+
"playwright-core",
|
|
4712
|
+
"sirv"
|
|
4713
|
+
],
|
|
4714
|
+
"files": [
|
|
4715
|
+
{
|
|
4716
|
+
"path": "registry/site/scripts/og.ts",
|
|
4717
|
+
"type": "registry:file",
|
|
4718
|
+
"target": "~/scripts/og.ts"
|
|
4719
|
+
},
|
|
4720
|
+
{
|
|
4721
|
+
"path": "registry/site/scripts/open-graph.test.ts",
|
|
4722
|
+
"type": "registry:file",
|
|
4723
|
+
"target": "~/scripts/open-graph.test.ts"
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
"path": "registry/site/scripts/netlify-cache/index.js",
|
|
4727
|
+
"type": "registry:file",
|
|
4728
|
+
"target": "~/scripts/netlify-cache/index.js"
|
|
4729
|
+
},
|
|
4730
|
+
{
|
|
4731
|
+
"path": "registry/site/scripts/netlify-cache/manifest.yml",
|
|
4732
|
+
"type": "registry:file",
|
|
4733
|
+
"target": "~/scripts/netlify-cache/manifest.yml"
|
|
4734
|
+
},
|
|
4735
|
+
{
|
|
4736
|
+
"path": "registry/site/src/lib/og.ts",
|
|
4737
|
+
"type": "registry:file",
|
|
4738
|
+
"target": "~/src/lib/og.ts"
|
|
4739
|
+
}
|
|
4740
|
+
]
|
|
4741
|
+
},
|
|
4685
4742
|
{
|
|
4686
4743
|
"name": "base",
|
|
4687
4744
|
"type": "registry:base",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "images",
|
|
4
|
+
"title": "Images",
|
|
5
|
+
"description": "Converts a site's source photos to WebP within 3840 pixels and updates their references; `--check` checks them.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"sharp"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "scripts/images.ts",
|
|
12
|
+
"content": "// Keeps source photographs in src as WebP, quality 90, at most 3840 pixels on\n// the longest edge. It reads the real format of each file, not its extension.\n//\n// vp run images fix everything under src\n// vp run images <file> also convert this file, such as a PNG photo\n// node scripts/images.ts --check check src, part of check\n//\n// Fix mode converts JPEG content and PNG content saved as .jpg, .jpeg or .webp\n// to WebP, renames WebP content saved as .jpg without encoding it again,\n// resizes photos over the limit, and updates references in src. Real WebP\n// files within the limit stay as they are, so they are never compressed\n// twice. PNG, SVG and GIF files are graphics and keep their format.\n//\n// --check fails only on what a CloudCannon upload with the image options in\n// AGENTS.md cannot produce: JPEG content in a .jpg or .jpeg file, and photos\n// over the limit. Any other mismatch, such as a PNG saved as .webp by Safari\n// on an iPhone, which cannot encode WebP, is a warning, so an editor's upload\n// never fails a publish pull request.\nimport {\n existsSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\"\nimport { dirname, extname, join, relative, sep } from \"node:path\"\nimport sharp from \"sharp\"\n\nconst maxSize = 3840\nconst photoExtensions = [\".jpg\", \".jpeg\", \".webp\"]\nconst check = process.argv.includes(\"--check\")\n// Paths use forward slashes on every system, as references in src do.\nconst slash = (path: string) => path.split(sep).join(\"/\")\nconst extra = process.argv\n .slice(2)\n .filter((arg) => !arg.startsWith(\"--\"))\n .map((arg) => slash(relative(\".\", arg)))\nfor (const path of extra)\n if (!path.startsWith(\"src/\")) throw new Error(`${path} is not in src`)\n\nconst files = (dir: string): string[] =>\n readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {\n const path = slash(join(dir, entry.name))\n return entry.isDirectory() ? files(path) : [path]\n })\nconst sources = files(\"src\")\n\ntype Task = {\n path: string\n target: string\n problem: string\n fail: boolean\n encode: boolean\n}\n\nasync function inspect(path: string): Promise<Task | undefined> {\n const ext = extname(path).toLowerCase()\n if (!extra.includes(path) && !photoExtensions.includes(ext)) return\n const {\n format,\n width = 0,\n height = 0,\n pages = 1,\n } = await sharp(path)\n .metadata()\n .catch((error: unknown) => {\n throw new Error(`${path}: ${error}`, { cause: error })\n })\n if (pages > 1) return\n const oversized = Math.max(width, height) > maxSize\n const jpeg = format === \"jpeg\"\n const target = (ext ? path.slice(0, -ext.length) : path) + \".webp\"\n if (format === \"webp\" && !oversized)\n return ext === \".webp\"\n ? undefined\n : { path, target, problem: \"is WebP\", fail: false, encode: false }\n if (format !== \"webp\" && !jpeg && format !== \"png\") return\n const problem = oversized\n ? `is larger than ${maxSize} pixels`\n : `is ${jpeg ? \"JPEG\" : \"PNG\"}`\n const fail = oversized || (jpeg && [\".jpg\", \".jpeg\"].includes(ext))\n return { path, target, problem, fail, encode: true }\n}\n\nconst tasks: Task[] = []\nfor (const path of new Set([...sources, ...extra])) {\n const task = await inspect(path)\n if (task) tasks.push(task)\n}\n\nif (check) {\n for (const { path, problem, fail } of tasks)\n if (!fail) console.warn(`Warning: ${path} ${problem}; run pnpm images.`)\n const failures = tasks.filter((task) => task.fail)\n if (failures.length) {\n console.error(\n `Run pnpm images to convert:\\n${failures.map((task) => `${task.path} ${task.problem}`).join(\"\\n\")}`\n )\n process.exit(1)\n }\n process.exit(0)\n}\n\nconst targets = tasks.map((task) => task.target)\nfor (const { path, target } of tasks) {\n if (target === path) continue\n // /assets/<name> can mean src/assets or public/assets, so a WebP name that\n // public/assets already has would make a rewritten reference ambiguous.\n const taken = [\n target,\n path.startsWith(\"src/assets/\") ? `public/${target.slice(4)}` : \"\",\n ].find((file) => file && existsSync(file))\n if (taken || targets.indexOf(target) !== targets.lastIndexOf(target))\n throw new Error(`${path}: ${taken ?? target} already exists`)\n}\n\nconst escape = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n// Matches text in which any character but / may be URL-encoded, in either\n// case, as Markdown writes my photo.jpg as my%20photo.jpg.\nconst encodable = (text: string) =>\n [...text]\n .map((char) => {\n if (char === \"/\") return char\n const bytes = [...new TextEncoder().encode(char)]\n const hex = bytes.map((byte) => `%${byte.toString(16).padStart(2, \"0\")}`)\n return `(?:${escape(char)}|(?i:${hex.join(\"\")}))`\n })\n .join(\"\")\n// Write to a temporary file first, so a failed run never leaves half a file.\nconst write = (path: string, data: string | Buffer) => {\n const temp = `${path}.${process.pid}.tmp`\n try {\n writeFileSync(temp, data)\n renameSync(temp, path)\n } catch (error) {\n rmSync(temp, { force: true })\n throw error\n }\n}\nconst textFiles = sources.filter((file) =>\n /\\.(mdx?|ya?ml|json|astro|[jt]sx?|css)$/.test(file)\n)\nlet before = 0\nlet after = 0\nfor (const { path, target, encode } of tasks) {\n const size = readFileSync(path).length\n if (encode) {\n // rotate() applies the EXIF orientation; metadata is not copied.\n const image = await sharp(path)\n .rotate()\n .resize(maxSize, maxSize, { fit: \"inside\", withoutEnlargement: true })\n .webp({ quality: 90 })\n .toBuffer()\n write(target, image)\n } else write(target, readFileSync(path))\n const newSize = readFileSync(target).length\n before += size\n after += newSize\n console.log(`${path} -> ${target} (${size} -> ${newSize} bytes)`)\n if (target === path) continue\n\n // Point references such as ../../assets/photo.jpg, ./photo.jpg,\n // @/assets/photo.jpg, /src/assets/photo.jpg and, for uploads in src/assets,\n // /assets/photo.jpg at the WebP file, URL-encoded or not. A reference must\n // be a whole path, so photo.jpg does not match my-photo.jpg,\n // ../other/photo.jpg or photo.jpg.webp. Only the extension changes, so a\n // reference keeps its encoding.\n const ext = path.slice(target.length - \".webp\".length)\n const paths = [`@/${path.slice(4)}`, `/${path}`]\n if (path.startsWith(\"src/assets/\") && !existsSync(`public/${path.slice(4)}`))\n paths.push(`/${path.slice(4)}`)\n for (const file of textFiles) {\n const text = readFileSync(file, \"utf8\")\n const local = slash(relative(dirname(file), path))\n const updated = [local, ...paths].reduce((text, from) => {\n const stem = encodable(from.slice(0, from.length - ext.length))\n return text.replace(\n new RegExp(\n `(?<![\\\\w@~./-])(\\\\./)?${stem}${escape(ext)}(?![\\\\w%-]|\\\\.\\\\w)`,\n \"g\"\n ),\n (match) => match.slice(0, match.length - ext.length) + \".webp\"\n )\n }, text)\n if (updated !== text) write(file, updated)\n }\n // Delete the original last, so a failed update leaves it in place.\n rmSync(path)\n}\nif (tasks.length) console.log(`Total: ${before} -> ${after} bytes`)\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/scripts/images.ts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:file"
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "og",
|
|
4
|
+
"title": "Open Graph images",
|
|
5
|
+
"description": "Draws each page's Open Graph image from the built site, checks them, and keeps them in Netlify's build cache.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"sharp"
|
|
8
|
+
],
|
|
9
|
+
"devDependencies": [
|
|
10
|
+
"parse5",
|
|
11
|
+
"playwright-core",
|
|
12
|
+
"sirv"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "registry/site/scripts/og.ts",
|
|
17
|
+
"content": "// Draws the Open Graph images of a built site into its dist/og/ (1200 by\n// 630, JPEG): the hero of a page, without the site header, in a raised\n// browser window on the site's stone background that runs off the bottom.\n//\n// node scripts/og.ts [dist]\n//\n// It reads only the built HTML, after `astro build`. An og:image with\n// data-og-source names the page whose hero it shows, such as \"/contact/\" on\n// /meeting/. Each such page is drawn once and saved under a content hash\n// (/og/contact.<hash>.jpg); the og:image and twitter:image that carried the\n// old URL on each page that refers to it get the new one. Images without the\n// marker stay as they are. A second run over the same dist/ changes nothing\n// while the pixels stay the same.\n// The site's node_modules/.cache/fulldev-og holds the images and their\n// input fingerprints between builds. Netlify restores and saves that folder.\n//\n// The hero is the page's [data-og] element, or else the section around its\n// main h1. The folder is served on a free localhost port; only its own files\n// load. It draws with Playwright's Chromium headless shell, installed when\n// missing, or with the browser binary in CHROME.\nimport { execFileSync } from \"node:child_process\"\nimport { createHash } from \"node:crypto\"\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\"\nimport { createServer } from \"node:http\"\nimport type { AddressInfo } from \"node:net\"\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { parse, type DefaultTreeAdapterTypes } from \"parse5\"\nimport { chromium, type Browser } from \"playwright-core\"\nimport sirv from \"sirv\"\n\nimport { ogImage } from \"../src/lib/og.ts\"\n\n// The page is drawn 1680 pixels wide, so it shows at about 70% of its size.\nconst shot = { width: 1680, height: 882 }\nconst card = { width: 1200, height: 630 }\n\ntype Meta = { content: string; source?: string; start: number; end: number }\ntype Page = { file: string; html: string; metas: Meta[] }\nexport type Plan = {\n // The image each owner page draws, such as /contact/ to /og/contact.jpg.\n owners: Map<string, string>\n // The pages with a data-og-source and their og:image and twitter:image.\n pages: Page[]\n}\n\n// The file of a URL path in dir; a path that leaves dir fails.\nconst inside = (dir: string, path: string) => {\n const file = join(dir, decodeURIComponent(path))\n const rest = relative(dir, file)\n if (!rest || rest.split(sep)[0] === \"..\" || isAbsolute(rest))\n throw new Error(`${path} is outside ${dir}`)\n return file\n}\n\nconst hashed = (image: string, jpeg: Buffer) =>\n image.replace(\n /\\.jpg$/,\n `.${createHash(\"sha256\").update(jpeg).digest(\"hex\").slice(0, 12)}.jpg`\n )\n\n// Whether path is a hashed copy of image, from an earlier run.\nconst isHashed = (image: string, path: string) => {\n const stem = image.slice(0, -\".jpg\".length)\n return (\n path.startsWith(stem) &&\n /^\\.[0-9a-f]{12}\\.jpg$/.test(path.slice(stem.length))\n )\n}\n\n// The og:image and twitter:image tags, with their content attribute's place\n// in the source, so a rewrite touches only those characters.\nconst metasOf = (html: string) => {\n const metas: Meta[] = []\n const walk = (node: DefaultTreeAdapterTypes.ParentNode, source?: string) => {\n for (const child of node.childNodes) {\n if (!(\"tagName\" in child)) continue\n const attr = (name: string) =>\n child.attrs.find((each) => each.name === name)?.value\n const content = attr(\"content\")\n const owner = attr(\"data-og-source\") ?? source\n const place = child.sourceCodeLocation?.attrs?.content\n const name = attr(\"property\") ?? attr(\"name\")\n if (\n child.tagName === \"meta\" &&\n [\n \"og:image\",\n \"og:image:url\",\n \"og:image:secure_url\",\n \"twitter:image\",\n \"twitter:image:src\",\n ].includes(name ?? \"\") &&\n content !== undefined &&\n place\n )\n metas.push({\n content,\n source: owner,\n start: place.startOffset,\n end: place.endOffset,\n })\n walk(child, owner)\n }\n }\n walk(parse(html, { sourceCodeLocationInfo: true }))\n return metas\n}\n\n// Finds every generated image in dist and the page it is drawn from. It\n// fails on a source that is not a page of dist, or a marked og:image whose\n// URL is not that page's image.\nexport const plan = (dist: string): Plan => {\n const owners = new Map<string, string>()\n const pages: Page[] = []\n const names = readdirSync(dist, { recursive: true, encoding: \"utf8\" })\n for (const name of names.sort()) {\n if (!name.endsWith(\".html\")) continue\n const file = join(dist, name)\n const html = readFileSync(file, \"utf8\")\n if (!html.includes(\"data-og-source\")) continue\n const metas = metasOf(html)\n for (const { content, source } of metas) {\n if (source === undefined) continue\n if (\n !source.startsWith(\"/\") ||\n new URL(source, \"http://localhost\").pathname !== source\n )\n throw new Error(`${name}: data-og-source \"${source}\" is not a path`)\n const image = ogImage(source)\n const path = URL.canParse(content) ? new URL(content).pathname : \"\"\n if (path !== image && !isHashed(image, path))\n throw new Error(`${name}: ${content} is not the image of ${source}`)\n if (owners.has(source)) continue\n const files = source.endsWith(\"/\")\n ? [`${source}index.html`]\n : [`${source}.html`, `${source}/index.html`]\n if (!files.some((page) => existsSync(inside(dist, page))))\n throw new Error(`${name}: data-og-source ${source} is not in ${dist}`)\n owners.set(source, image)\n }\n pages.push({ file, html, metas })\n }\n return { owners, pages }\n}\n\n// Saves each owner's JPEG under its hash and points the pages at it. A file\n// that already holds the same bytes stays; another file with that name\n// fails.\nexport const apply = (\n dist: string,\n { owners, pages }: Plan,\n jpegs: Map<string, Buffer>\n) => {\n const images = new Map<string, string>()\n for (const [source, image] of owners) {\n const jpeg = jpegs.get(source)\n if (!jpeg) throw new Error(`No image drawn for ${source}`)\n const path = hashed(image, jpeg)\n const file = inside(dist, path)\n if (!existsSync(file)) {\n mkdirSync(dirname(file), { recursive: true })\n writeFileSync(file, jpeg)\n console.log(relative(process.cwd(), file))\n } else if (!readFileSync(file).equals(jpeg))\n throw new Error(`${file} already exists with other content`)\n images.set(source, path)\n }\n for (const { file, html, metas } of pages) {\n const urls = new Map<string, string>()\n for (const { content, source } of metas) {\n const path = source === undefined ? undefined : images.get(source)\n if (path) urls.set(content, new URL(path, content).href)\n }\n let next = html\n for (const { content, start, end } of metas.toReversed()) {\n const url = urls.get(content)\n if (!url || url === content) continue\n next = `${next.slice(0, start)}content=\"${url}\"${next.slice(end)}`\n }\n if (next !== html) writeFileSync(file, next)\n }\n}\n\n// Runs in the page: leaves only the hero, the [data-og] element or else the\n// section around the main h1, by hiding the site header and every other\n// branch of the page, then waits for its fonts and visible images.\nconst isolate = async () => {\n const hero =\n document.querySelector<HTMLElement>(\"[data-og]\") ??\n document.querySelector(\"main h1\")?.closest(\"section\")\n if (!hero) return false\n const style = document.createElement(\"style\")\n style.textContent =\n \"[data-slot=header] { display: none !important } html, body { overflow: hidden !important }\"\n document.head.append(style)\n let node: Element = hero\n while (node !== document.body && node.parentElement) {\n const parent: HTMLElement = node.parentElement\n for (const sibling of parent.children)\n if (sibling !== node)\n (sibling as HTMLElement).style.setProperty(\n \"display\",\n \"none\",\n \"important\"\n )\n node = parent\n }\n hero.style.setProperty(\"padding-top\", \"80px\", \"important\")\n hero.style.setProperty(\"min-height\", \"0\", \"important\")\n scrollTo(0, 0)\n // Measuring lays the page out, so the fonts it needs start loading.\n const images = [...hero.querySelectorAll(\"img\")].filter((img) => {\n img.loading = \"eager\"\n const box = img.getBoundingClientRect()\n return box.width > 0 && box.height > 0 && box.top < innerHeight\n })\n await document.fonts.ready\n // Hiding the scrollbar can change vw-based srcset selection on the next paint.\n await new Promise((done) =>\n requestAnimationFrame(() => requestAnimationFrame(done))\n )\n await Promise.all(\n images.map((img) =>\n img.decode().catch(() => {\n throw new Error(`${img.currentSrc || img.src} did not load`)\n })\n )\n )\n await new Promise((done) =>\n requestAnimationFrame(() => requestAnimationFrame(done))\n )\n const styleOf = getComputedStyle(document.documentElement)\n return {\n background: styleOf.getPropertyValue(\"--background\").trim() || \"white\",\n card: styleOf.getPropertyValue(\"--card\").trim() || \"white\",\n border: styleOf.getPropertyValue(\"--border\").trim() || \"currentColor\",\n shadow:\n styleOf.getPropertyValue(\"--fd-block-shadow\").trim() ||\n \"color-mix(in oklab, currentColor 20%, transparent)\",\n }\n}\n\n// The card: the screenshot in a browser window with three dots, 80px from\n// the sides and 64px from the top, on stone, with the floor shadow in the\n// block shadow's brown.\nconst frame = (src: string) => `<!doctype html><html><head><style>\n* { margin: 0; box-sizing: border-box; }\nhtml, body { width: ${card.width}px; height: ${card.height}px; overflow: hidden; background: var(--og-background); }\n.frame { position: absolute; left: 80px; right: 80px; top: 64px; height: 620px; overflow: hidden; border-radius: 18px;\n background: var(--og-background);\n box-shadow: 0 0 0 1px color-mix(in oklab, var(--og-shadow) 40%, transparent), 0 2px 4px -2px var(--og-shadow), 0 36px 70px -24px var(--og-shadow); }\n.bar { height: 30px; display: flex; gap: 7px; align-items: center; padding: 0 15px; background: var(--og-card); border-bottom: 1px solid var(--og-border); }\n.bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--og-border); }\niframe { display: block; border: 0; width: ${shot.width}px; height: ${shot.height}px; transform: scale(${1040 / shot.width}); transform-origin: top left; }\n</style></head><body><div class=\"frame\"><div class=\"bar\"><i></i><i></i><i></i></div><iframe title=\"Open Graph source\" src=\"${src}\"></iframe></div></body></html>`\n\ntype Drawing = { jpeg: Buffer; resources: string[] }\n\n// Draws each owner page of dist into its card.\nconst draw = async (dist: string, sources: string[]) => {\n if (!process.env.CHROME) {\n const cli = new URL(\n \"cli.js\",\n import.meta.resolve(\"playwright-core/package.json\")\n )\n execFileSync(\n process.execPath,\n [fileURLToPath(cli), \"install\", \"chromium\", \"--only-shell\"],\n { stdio: \"inherit\" }\n )\n }\n const files = sirv(dist)\n const server = createServer((req, res) =>\n files(req, res, () => {\n res.statusCode = 404\n res.end(\"Not found\")\n })\n )\n let browser: Browser | undefined\n try {\n await new Promise<void>((done, fail) =>\n server.once(\"error\", fail).listen(0, \"127.0.0.1\", done)\n )\n const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`\n browser = await chromium.launch({ executablePath: process.env.CHROME })\n const activeBrowser = browser\n const drawings = new Map<string, Drawing>()\n let next = 0\n // Reuse one browser with bounded concurrency. The iframe keeps the\n // hero's 1680px layout while the final 1200px card needs only one shot.\n await Promise.all(\n Array.from({ length: Math.min(4, sources.length) }, async () => {\n while (next < sources.length) {\n const source = sources[next++]!\n // A fresh context records every request, even when another page\n // already loaded the same stylesheet, font or public image.\n const context = await activeBrowser.newContext({\n viewport: card,\n reducedMotion: \"reduce\",\n serviceWorkers: \"block\",\n })\n try {\n // Analytics and APIs never see the run or hold it up.\n await context.route(\n (url) => url.origin !== origin,\n (route) => route.abort()\n )\n const page = await context.newPage()\n const resources = new Set([source])\n page.on(\"request\", (request) => {\n const url = new URL(request.url())\n if (url.origin === origin) resources.add(url.pathname)\n })\n const url = new URL(source, origin).href\n await page.setContent(frame(url.replaceAll(\"&\", \"&\")), {\n waitUntil: \"load\",\n })\n const inner = page.frames().find((frame) => frame.url() === url)\n const theme = await inner?.evaluate(isolate)\n if (!theme)\n throw new Error(\n `${source} has no [data-og] or section around its h1`\n )\n await page.evaluate((theme) => {\n for (const [name, color] of Object.entries(theme))\n document.documentElement.style.setProperty(\n `--og-${name}`,\n color\n )\n }, theme)\n drawings.set(source, {\n jpeg: await page.screenshot({\n type: \"jpeg\",\n quality: 85,\n animations: \"disabled\",\n }),\n resources: [...resources].sort(),\n })\n } finally {\n await context.close()\n }\n }\n })\n )\n return drawings\n } finally {\n await browser?.close().catch(() => {})\n server.closeAllConnections()\n await new Promise((done) => server.close(done))\n }\n}\n\nconst digest = (input: string | Buffer) =>\n createHash(\"sha256\").update(input).digest(\"hex\")\n\n// Metadata is rewritten after drawing. Normalize those URLs so a direct\n// rerun and a fresh Astro build have the same input fingerprint.\nconst normalize = (html: string) => {\n const metas = metasOf(html)\n const urls = new Map(\n metas\n .filter((meta) => meta.source !== undefined)\n .map((meta) => [\n meta.content,\n new URL(ogImage(meta.source!), meta.content).href,\n ])\n )\n for (const { content, start, end } of metas.toReversed()) {\n const url = urls.get(content)\n if (url) html = `${html.slice(0, start)}content=\"${url}\"${html.slice(end)}`\n }\n return html\n}\n\n// Cache entries describe the files Chromium actually requested, including\n// imported CSS, scripts, fonts and responsive images. Hash each file once\n// per run; a changed dependency invalidates only the pages that loaded it.\nexport const generate = async (\n dist: string,\n {\n cacheDir = join(dirname(dist), \"node_modules/.cache/fulldev-og\"),\n render = draw,\n }: { cacheDir?: string; render?: typeof draw } = {}\n) => {\n const work = plan(dist)\n const customBrowser = process.env.CHROME && statSync(process.env.CHROME)\n const fingerprint = digest(\n [\n readFileSync(fileURLToPath(import.meta.url), \"utf8\"),\n readFileSync(\n fileURLToPath(import.meta.resolve(\"playwright-core/package.json\")),\n \"utf8\"\n ),\n process.platform,\n process.arch,\n customBrowser\n ? `${process.env.CHROME}:${customBrowser.size}:${customBrowser.mtimeMs}`\n : \"managed-chromium\",\n ].join(\"\\n\")\n )\n const inputs = new Map<string, string>()\n const inputHash = (path: string) => {\n let hash = inputs.get(path)\n if (hash !== undefined) return hash\n // Match sirv's file and directory-index resolution, including routes\n // without a trailing slash.\n const stem = path.replace(/\\/$/, \"\")\n const file = [\"\", \".html\", \".htm\"]\n .flatMap((extension) => [\n ...(stem ? [`${stem}${extension}`] : []),\n `${stem}/index${extension}`,\n ])\n .map((name) => inside(dist, name))\n .find((name) => existsSync(name) && statSync(name).isFile())\n if (!file) hash = \"missing\"\n else\n hash = digest(\n file.endsWith(\".html\")\n ? normalize(readFileSync(file, \"utf8\"))\n : readFileSync(file)\n )\n inputs.set(path, hash)\n return hash\n }\n const jpegs = new Map<string, Buffer>()\n const missing: string[] = []\n mkdirSync(cacheDir, { recursive: true })\n for (const source of work.owners.keys()) {\n const entry = join(cacheDir, digest(source))\n try {\n const cached = JSON.parse(readFileSync(`${entry}.json`, \"utf8\")) as {\n renderer: string\n image: string\n resources: [string, string][]\n }\n if (\n cached.renderer !== fingerprint ||\n !cached.resources.some(([path]) => path === source) ||\n !cached.resources.every(([path, hash]) => inputHash(path) === hash)\n )\n throw new Error(\"Changed input\")\n const jpeg = readFileSync(`${entry}.jpg`)\n if (digest(jpeg) !== cached.image) throw new Error(\"Changed cache image\")\n jpegs.set(source, jpeg)\n } catch {\n missing.push(source)\n }\n }\n if (missing.length) {\n const drawings = await render(dist, missing)\n for (const source of missing) {\n const drawing = drawings.get(source)\n if (!drawing) throw new Error(`No image drawn for ${source}`)\n const entry = join(cacheDir, digest(source))\n writeFileSync(`${entry}.jpg`, drawing.jpeg)\n writeFileSync(\n `${entry}.json`,\n JSON.stringify({\n renderer: fingerprint,\n image: digest(drawing.jpeg),\n resources: [...new Set([source, ...drawing.resources])].map(\n (path) => [path, inputHash(path)]\n ),\n })\n )\n jpegs.set(source, drawing.jpeg)\n }\n }\n apply(dist, work, jpegs)\n const active = new Set([...work.owners.keys()].map(digest))\n for (const name of readdirSync(cacheDir))\n if (\n /^[a-f0-9]{64}\\.(json|jpg)$/.test(name) &&\n !active.has(name.slice(0, 64))\n )\n rmSync(join(cacheDir, name))\n const result = {\n rendered: missing.length,\n reused: work.owners.size - missing.length,\n }\n console.log(\n `Open Graph: ${result.rendered} rendered, ${result.reused} reused`\n )\n return result\n}\n\nif (import.meta.main) await generate(resolve(process.argv[2] ?? \"dist\"))\n",
|
|
18
|
+
"type": "registry:file",
|
|
19
|
+
"target": "~/scripts/og.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "registry/site/scripts/open-graph.test.ts",
|
|
23
|
+
"content": "// Verify the published routes, after Astro has normalized content filenames\n// and applied custom slugs. Reuse the build.\nimport assert from \"node:assert/strict\"\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { test } from \"node:test\"\nimport sharp from \"sharp\"\n\ntest(\"indexed pages advertise usable share images without generating unindexed images\", async () => {\n const files = readdirSync(\"dist\", { recursive: true, encoding: \"utf8\" })\n const advertised = new Set<string>()\n for (const file of files.filter((file) => file.endsWith(\"index.html\"))) {\n const html = readFileSync(join(\"dist\", file), \"utf8\")\n const path = file.slice(0, -\"index.html\".length)\n const stem = `/og/${path ? path.slice(0, -1) : \"index\"}.`\n if (/<meta name=\"robots\" content=\"[^\"]*noindex/.test(html)) {\n assert.ok(\n !files.some((name) => `/${name}`.startsWith(stem)),\n `${file} has no fallback`\n )\n continue\n }\n const url = html.match(/property=\"og:image\" content=\"([^\"]+)\"/)?.[1]\n assert.ok(url, `${file} has an og:image`)\n const imagePath = decodeURI(new URL(url).pathname)\n // A custom image is published by Astro's image service. Only generated\n // fallback images belong in /og and must match the page's actual route.\n if (!html.includes(\"data-og-source=\")) continue\n assert.ok(imagePath.startsWith(stem), `${file} uses its fallback`)\n assert.match(imagePath.slice(stem.length), /^[a-f0-9]{12}\\.jpg$/, file)\n assert.ok(existsSync(join(\"dist\", imagePath)), file)\n advertised.add(imagePath)\n const metadata = await sharp(join(\"dist\", imagePath)).metadata()\n assert.equal(metadata.format, \"jpeg\", file)\n assert.equal(metadata.width, 1200, file)\n assert.equal(metadata.height, 630, file)\n }\n const generated = files\n .filter(\n (file) => file.startsWith(\"og/\") && /\\.[a-f0-9]{12}\\.jpg$/.test(file)\n )\n .map((file) => `/${file}`)\n assert.deepEqual(new Set(generated), advertised)\n})\n",
|
|
24
|
+
"type": "registry:file",
|
|
25
|
+
"target": "~/scripts/open-graph.test.ts"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "registry/site/scripts/netlify-cache/index.js",
|
|
29
|
+
"content": "import { join } from \"node:path\"\n\nconst directory = (inputs) =>\n join(inputs.directory, \"node_modules/.cache/fulldev-og\")\n\nexport async function onPreBuild({ inputs, utils }) {\n const restored = await utils.cache.restore(directory(inputs))\n console.log(`Open Graph cache: ${restored ? \"restored\" : \"empty\"}`)\n}\n\nexport async function onBuild({ inputs, utils }) {\n await utils.cache.save(directory(inputs))\n}\n",
|
|
30
|
+
"type": "registry:file",
|
|
31
|
+
"target": "~/scripts/netlify-cache/index.js"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "registry/site/scripts/netlify-cache/manifest.yml",
|
|
35
|
+
"content": "name: fulldev-og-cache\ninputs:\n - name: directory\n description: Site directory relative to the Netlify base directory.\n default: .\n",
|
|
36
|
+
"type": "registry:file",
|
|
37
|
+
"target": "~/scripts/netlify-cache/manifest.yml"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "registry/site/src/lib/og.ts",
|
|
41
|
+
"content": "// The Open Graph image of a page path, generated from dist during the build (scripts/og.ts):\n// /og/index.jpg for the homepage, /og/<path>.jpg for the others.\nexport const ogImage = (path: string) =>\n path === \"/\" ? \"/og/index.jpg\" : `/og${path.replace(/\\/$/, \"\")}.jpg`\n",
|
|
42
|
+
"type": "registry:file",
|
|
43
|
+
"target": "~/src/lib/og.ts"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"type": "registry:file"
|
|
47
|
+
}
|
|
@@ -4682,6 +4682,63 @@
|
|
|
4682
4682
|
}
|
|
4683
4683
|
}
|
|
4684
4684
|
},
|
|
4685
|
+
{
|
|
4686
|
+
"name": "images",
|
|
4687
|
+
"type": "registry:file",
|
|
4688
|
+
"title": "Images",
|
|
4689
|
+
"description": "Converts a site's source photos to WebP within 3840 pixels and updates their references; `--check` checks them.",
|
|
4690
|
+
"dependencies": [
|
|
4691
|
+
"sharp"
|
|
4692
|
+
],
|
|
4693
|
+
"files": [
|
|
4694
|
+
{
|
|
4695
|
+
"path": "scripts/images.ts",
|
|
4696
|
+
"type": "registry:file",
|
|
4697
|
+
"target": "~/scripts/images.ts"
|
|
4698
|
+
}
|
|
4699
|
+
]
|
|
4700
|
+
},
|
|
4701
|
+
{
|
|
4702
|
+
"name": "og",
|
|
4703
|
+
"type": "registry:file",
|
|
4704
|
+
"title": "Open Graph images",
|
|
4705
|
+
"description": "Draws each page's Open Graph image from the built site, checks them, and keeps them in Netlify's build cache.",
|
|
4706
|
+
"dependencies": [
|
|
4707
|
+
"sharp"
|
|
4708
|
+
],
|
|
4709
|
+
"devDependencies": [
|
|
4710
|
+
"parse5",
|
|
4711
|
+
"playwright-core",
|
|
4712
|
+
"sirv"
|
|
4713
|
+
],
|
|
4714
|
+
"files": [
|
|
4715
|
+
{
|
|
4716
|
+
"path": "registry/site/scripts/og.ts",
|
|
4717
|
+
"type": "registry:file",
|
|
4718
|
+
"target": "~/scripts/og.ts"
|
|
4719
|
+
},
|
|
4720
|
+
{
|
|
4721
|
+
"path": "registry/site/scripts/open-graph.test.ts",
|
|
4722
|
+
"type": "registry:file",
|
|
4723
|
+
"target": "~/scripts/open-graph.test.ts"
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
"path": "registry/site/scripts/netlify-cache/index.js",
|
|
4727
|
+
"type": "registry:file",
|
|
4728
|
+
"target": "~/scripts/netlify-cache/index.js"
|
|
4729
|
+
},
|
|
4730
|
+
{
|
|
4731
|
+
"path": "registry/site/scripts/netlify-cache/manifest.yml",
|
|
4732
|
+
"type": "registry:file",
|
|
4733
|
+
"target": "~/scripts/netlify-cache/manifest.yml"
|
|
4734
|
+
},
|
|
4735
|
+
{
|
|
4736
|
+
"path": "registry/site/src/lib/og.ts",
|
|
4737
|
+
"type": "registry:file",
|
|
4738
|
+
"target": "~/src/lib/og.ts"
|
|
4739
|
+
}
|
|
4740
|
+
]
|
|
4741
|
+
},
|
|
4685
4742
|
{
|
|
4686
4743
|
"name": "base",
|
|
4687
4744
|
"type": "registry:base",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "images",
|
|
4
|
+
"title": "Images",
|
|
5
|
+
"description": "Converts a site's source photos to WebP within 3840 pixels and updates their references; `--check` checks them.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"sharp"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "scripts/images.ts",
|
|
12
|
+
"content": "// Keeps source photographs in src as WebP, quality 90, at most 3840 pixels on\n// the longest edge. It reads the real format of each file, not its extension.\n//\n// vp run images fix everything under src\n// vp run images <file> also convert this file, such as a PNG photo\n// node scripts/images.ts --check check src, part of check\n//\n// Fix mode converts JPEG content and PNG content saved as .jpg, .jpeg or .webp\n// to WebP, renames WebP content saved as .jpg without encoding it again,\n// resizes photos over the limit, and updates references in src. Real WebP\n// files within the limit stay as they are, so they are never compressed\n// twice. PNG, SVG and GIF files are graphics and keep their format.\n//\n// --check fails only on what a CloudCannon upload with the image options in\n// AGENTS.md cannot produce: JPEG content in a .jpg or .jpeg file, and photos\n// over the limit. Any other mismatch, such as a PNG saved as .webp by Safari\n// on an iPhone, which cannot encode WebP, is a warning, so an editor's upload\n// never fails a publish pull request.\nimport {\n existsSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\"\nimport { dirname, extname, join, relative, sep } from \"node:path\"\nimport sharp from \"sharp\"\n\nconst maxSize = 3840\nconst photoExtensions = [\".jpg\", \".jpeg\", \".webp\"]\nconst check = process.argv.includes(\"--check\")\n// Paths use forward slashes on every system, as references in src do.\nconst slash = (path: string) => path.split(sep).join(\"/\")\nconst extra = process.argv\n .slice(2)\n .filter((arg) => !arg.startsWith(\"--\"))\n .map((arg) => slash(relative(\".\", arg)))\nfor (const path of extra)\n if (!path.startsWith(\"src/\")) throw new Error(`${path} is not in src`)\n\nconst files = (dir: string): string[] =>\n readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {\n const path = slash(join(dir, entry.name))\n return entry.isDirectory() ? files(path) : [path]\n })\nconst sources = files(\"src\")\n\ntype Task = {\n path: string\n target: string\n problem: string\n fail: boolean\n encode: boolean\n}\n\nasync function inspect(path: string): Promise<Task | undefined> {\n const ext = extname(path).toLowerCase()\n if (!extra.includes(path) && !photoExtensions.includes(ext)) return\n const {\n format,\n width = 0,\n height = 0,\n pages = 1,\n } = await sharp(path)\n .metadata()\n .catch((error: unknown) => {\n throw new Error(`${path}: ${error}`, { cause: error })\n })\n if (pages > 1) return\n const oversized = Math.max(width, height) > maxSize\n const jpeg = format === \"jpeg\"\n const target = (ext ? path.slice(0, -ext.length) : path) + \".webp\"\n if (format === \"webp\" && !oversized)\n return ext === \".webp\"\n ? undefined\n : { path, target, problem: \"is WebP\", fail: false, encode: false }\n if (format !== \"webp\" && !jpeg && format !== \"png\") return\n const problem = oversized\n ? `is larger than ${maxSize} pixels`\n : `is ${jpeg ? \"JPEG\" : \"PNG\"}`\n const fail = oversized || (jpeg && [\".jpg\", \".jpeg\"].includes(ext))\n return { path, target, problem, fail, encode: true }\n}\n\nconst tasks: Task[] = []\nfor (const path of new Set([...sources, ...extra])) {\n const task = await inspect(path)\n if (task) tasks.push(task)\n}\n\nif (check) {\n for (const { path, problem, fail } of tasks)\n if (!fail) console.warn(`Warning: ${path} ${problem}; run pnpm images.`)\n const failures = tasks.filter((task) => task.fail)\n if (failures.length) {\n console.error(\n `Run pnpm images to convert:\\n${failures.map((task) => `${task.path} ${task.problem}`).join(\"\\n\")}`\n )\n process.exit(1)\n }\n process.exit(0)\n}\n\nconst targets = tasks.map((task) => task.target)\nfor (const { path, target } of tasks) {\n if (target === path) continue\n // /assets/<name> can mean src/assets or public/assets, so a WebP name that\n // public/assets already has would make a rewritten reference ambiguous.\n const taken = [\n target,\n path.startsWith(\"src/assets/\") ? `public/${target.slice(4)}` : \"\",\n ].find((file) => file && existsSync(file))\n if (taken || targets.indexOf(target) !== targets.lastIndexOf(target))\n throw new Error(`${path}: ${taken ?? target} already exists`)\n}\n\nconst escape = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n// Matches text in which any character but / may be URL-encoded, in either\n// case, as Markdown writes my photo.jpg as my%20photo.jpg.\nconst encodable = (text: string) =>\n [...text]\n .map((char) => {\n if (char === \"/\") return char\n const bytes = [...new TextEncoder().encode(char)]\n const hex = bytes.map((byte) => `%${byte.toString(16).padStart(2, \"0\")}`)\n return `(?:${escape(char)}|(?i:${hex.join(\"\")}))`\n })\n .join(\"\")\n// Write to a temporary file first, so a failed run never leaves half a file.\nconst write = (path: string, data: string | Buffer) => {\n const temp = `${path}.${process.pid}.tmp`\n try {\n writeFileSync(temp, data)\n renameSync(temp, path)\n } catch (error) {\n rmSync(temp, { force: true })\n throw error\n }\n}\nconst textFiles = sources.filter((file) =>\n /\\.(mdx?|ya?ml|json|astro|[jt]sx?|css)$/.test(file)\n)\nlet before = 0\nlet after = 0\nfor (const { path, target, encode } of tasks) {\n const size = readFileSync(path).length\n if (encode) {\n // rotate() applies the EXIF orientation; metadata is not copied.\n const image = await sharp(path)\n .rotate()\n .resize(maxSize, maxSize, { fit: \"inside\", withoutEnlargement: true })\n .webp({ quality: 90 })\n .toBuffer()\n write(target, image)\n } else write(target, readFileSync(path))\n const newSize = readFileSync(target).length\n before += size\n after += newSize\n console.log(`${path} -> ${target} (${size} -> ${newSize} bytes)`)\n if (target === path) continue\n\n // Point references such as ../../assets/photo.jpg, ./photo.jpg,\n // @/assets/photo.jpg, /src/assets/photo.jpg and, for uploads in src/assets,\n // /assets/photo.jpg at the WebP file, URL-encoded or not. A reference must\n // be a whole path, so photo.jpg does not match my-photo.jpg,\n // ../other/photo.jpg or photo.jpg.webp. Only the extension changes, so a\n // reference keeps its encoding.\n const ext = path.slice(target.length - \".webp\".length)\n const paths = [`@/${path.slice(4)}`, `/${path}`]\n if (path.startsWith(\"src/assets/\") && !existsSync(`public/${path.slice(4)}`))\n paths.push(`/${path.slice(4)}`)\n for (const file of textFiles) {\n const text = readFileSync(file, \"utf8\")\n const local = slash(relative(dirname(file), path))\n const updated = [local, ...paths].reduce((text, from) => {\n const stem = encodable(from.slice(0, from.length - ext.length))\n return text.replace(\n new RegExp(\n `(?<![\\\\w@~./-])(\\\\./)?${stem}${escape(ext)}(?![\\\\w%-]|\\\\.\\\\w)`,\n \"g\"\n ),\n (match) => match.slice(0, match.length - ext.length) + \".webp\"\n )\n }, text)\n if (updated !== text) write(file, updated)\n }\n // Delete the original last, so a failed update leaves it in place.\n rmSync(path)\n}\nif (tasks.length) console.log(`Total: ${before} -> ${after} bytes`)\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/scripts/images.ts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:file"
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "og",
|
|
4
|
+
"title": "Open Graph images",
|
|
5
|
+
"description": "Draws each page's Open Graph image from the built site, checks them, and keeps them in Netlify's build cache.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"sharp"
|
|
8
|
+
],
|
|
9
|
+
"devDependencies": [
|
|
10
|
+
"parse5",
|
|
11
|
+
"playwright-core",
|
|
12
|
+
"sirv"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "registry/site/scripts/og.ts",
|
|
17
|
+
"content": "// Draws the Open Graph images of a built site into its dist/og/ (1200 by\n// 630, JPEG): the hero of a page, without the site header, in a raised\n// browser window on the site's stone background that runs off the bottom.\n//\n// node scripts/og.ts [dist]\n//\n// It reads only the built HTML, after `astro build`. An og:image with\n// data-og-source names the page whose hero it shows, such as \"/contact/\" on\n// /meeting/. Each such page is drawn once and saved under a content hash\n// (/og/contact.<hash>.jpg); the og:image and twitter:image that carried the\n// old URL on each page that refers to it get the new one. Images without the\n// marker stay as they are. A second run over the same dist/ changes nothing\n// while the pixels stay the same.\n// The site's node_modules/.cache/fulldev-og holds the images and their\n// input fingerprints between builds. Netlify restores and saves that folder.\n//\n// The hero is the page's [data-og] element, or else the section around its\n// main h1. The folder is served on a free localhost port; only its own files\n// load. It draws with Playwright's Chromium headless shell, installed when\n// missing, or with the browser binary in CHROME.\nimport { execFileSync } from \"node:child_process\"\nimport { createHash } from \"node:crypto\"\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\"\nimport { createServer } from \"node:http\"\nimport type { AddressInfo } from \"node:net\"\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { parse, type DefaultTreeAdapterTypes } from \"parse5\"\nimport { chromium, type Browser } from \"playwright-core\"\nimport sirv from \"sirv\"\n\nimport { ogImage } from \"../src/lib/og.ts\"\n\n// The page is drawn 1680 pixels wide, so it shows at about 70% of its size.\nconst shot = { width: 1680, height: 882 }\nconst card = { width: 1200, height: 630 }\n\ntype Meta = { content: string; source?: string; start: number; end: number }\ntype Page = { file: string; html: string; metas: Meta[] }\nexport type Plan = {\n // The image each owner page draws, such as /contact/ to /og/contact.jpg.\n owners: Map<string, string>\n // The pages with a data-og-source and their og:image and twitter:image.\n pages: Page[]\n}\n\n// The file of a URL path in dir; a path that leaves dir fails.\nconst inside = (dir: string, path: string) => {\n const file = join(dir, decodeURIComponent(path))\n const rest = relative(dir, file)\n if (!rest || rest.split(sep)[0] === \"..\" || isAbsolute(rest))\n throw new Error(`${path} is outside ${dir}`)\n return file\n}\n\nconst hashed = (image: string, jpeg: Buffer) =>\n image.replace(\n /\\.jpg$/,\n `.${createHash(\"sha256\").update(jpeg).digest(\"hex\").slice(0, 12)}.jpg`\n )\n\n// Whether path is a hashed copy of image, from an earlier run.\nconst isHashed = (image: string, path: string) => {\n const stem = image.slice(0, -\".jpg\".length)\n return (\n path.startsWith(stem) &&\n /^\\.[0-9a-f]{12}\\.jpg$/.test(path.slice(stem.length))\n )\n}\n\n// The og:image and twitter:image tags, with their content attribute's place\n// in the source, so a rewrite touches only those characters.\nconst metasOf = (html: string) => {\n const metas: Meta[] = []\n const walk = (node: DefaultTreeAdapterTypes.ParentNode, source?: string) => {\n for (const child of node.childNodes) {\n if (!(\"tagName\" in child)) continue\n const attr = (name: string) =>\n child.attrs.find((each) => each.name === name)?.value\n const content = attr(\"content\")\n const owner = attr(\"data-og-source\") ?? source\n const place = child.sourceCodeLocation?.attrs?.content\n const name = attr(\"property\") ?? attr(\"name\")\n if (\n child.tagName === \"meta\" &&\n [\n \"og:image\",\n \"og:image:url\",\n \"og:image:secure_url\",\n \"twitter:image\",\n \"twitter:image:src\",\n ].includes(name ?? \"\") &&\n content !== undefined &&\n place\n )\n metas.push({\n content,\n source: owner,\n start: place.startOffset,\n end: place.endOffset,\n })\n walk(child, owner)\n }\n }\n walk(parse(html, { sourceCodeLocationInfo: true }))\n return metas\n}\n\n// Finds every generated image in dist and the page it is drawn from. It\n// fails on a source that is not a page of dist, or a marked og:image whose\n// URL is not that page's image.\nexport const plan = (dist: string): Plan => {\n const owners = new Map<string, string>()\n const pages: Page[] = []\n const names = readdirSync(dist, { recursive: true, encoding: \"utf8\" })\n for (const name of names.sort()) {\n if (!name.endsWith(\".html\")) continue\n const file = join(dist, name)\n const html = readFileSync(file, \"utf8\")\n if (!html.includes(\"data-og-source\")) continue\n const metas = metasOf(html)\n for (const { content, source } of metas) {\n if (source === undefined) continue\n if (\n !source.startsWith(\"/\") ||\n new URL(source, \"http://localhost\").pathname !== source\n )\n throw new Error(`${name}: data-og-source \"${source}\" is not a path`)\n const image = ogImage(source)\n const path = URL.canParse(content) ? new URL(content).pathname : \"\"\n if (path !== image && !isHashed(image, path))\n throw new Error(`${name}: ${content} is not the image of ${source}`)\n if (owners.has(source)) continue\n const files = source.endsWith(\"/\")\n ? [`${source}index.html`]\n : [`${source}.html`, `${source}/index.html`]\n if (!files.some((page) => existsSync(inside(dist, page))))\n throw new Error(`${name}: data-og-source ${source} is not in ${dist}`)\n owners.set(source, image)\n }\n pages.push({ file, html, metas })\n }\n return { owners, pages }\n}\n\n// Saves each owner's JPEG under its hash and points the pages at it. A file\n// that already holds the same bytes stays; another file with that name\n// fails.\nexport const apply = (\n dist: string,\n { owners, pages }: Plan,\n jpegs: Map<string, Buffer>\n) => {\n const images = new Map<string, string>()\n for (const [source, image] of owners) {\n const jpeg = jpegs.get(source)\n if (!jpeg) throw new Error(`No image drawn for ${source}`)\n const path = hashed(image, jpeg)\n const file = inside(dist, path)\n if (!existsSync(file)) {\n mkdirSync(dirname(file), { recursive: true })\n writeFileSync(file, jpeg)\n console.log(relative(process.cwd(), file))\n } else if (!readFileSync(file).equals(jpeg))\n throw new Error(`${file} already exists with other content`)\n images.set(source, path)\n }\n for (const { file, html, metas } of pages) {\n const urls = new Map<string, string>()\n for (const { content, source } of metas) {\n const path = source === undefined ? undefined : images.get(source)\n if (path) urls.set(content, new URL(path, content).href)\n }\n let next = html\n for (const { content, start, end } of metas.toReversed()) {\n const url = urls.get(content)\n if (!url || url === content) continue\n next = `${next.slice(0, start)}content=\"${url}\"${next.slice(end)}`\n }\n if (next !== html) writeFileSync(file, next)\n }\n}\n\n// Runs in the page: leaves only the hero, the [data-og] element or else the\n// section around the main h1, by hiding the site header and every other\n// branch of the page, then waits for its fonts and visible images.\nconst isolate = async () => {\n const hero =\n document.querySelector<HTMLElement>(\"[data-og]\") ??\n document.querySelector(\"main h1\")?.closest(\"section\")\n if (!hero) return false\n const style = document.createElement(\"style\")\n style.textContent =\n \"[data-slot=header] { display: none !important } html, body { overflow: hidden !important }\"\n document.head.append(style)\n let node: Element = hero\n while (node !== document.body && node.parentElement) {\n const parent: HTMLElement = node.parentElement\n for (const sibling of parent.children)\n if (sibling !== node)\n (sibling as HTMLElement).style.setProperty(\n \"display\",\n \"none\",\n \"important\"\n )\n node = parent\n }\n hero.style.setProperty(\"padding-top\", \"80px\", \"important\")\n hero.style.setProperty(\"min-height\", \"0\", \"important\")\n scrollTo(0, 0)\n // Measuring lays the page out, so the fonts it needs start loading.\n const images = [...hero.querySelectorAll(\"img\")].filter((img) => {\n img.loading = \"eager\"\n const box = img.getBoundingClientRect()\n return box.width > 0 && box.height > 0 && box.top < innerHeight\n })\n await document.fonts.ready\n // Hiding the scrollbar can change vw-based srcset selection on the next paint.\n await new Promise((done) =>\n requestAnimationFrame(() => requestAnimationFrame(done))\n )\n await Promise.all(\n images.map((img) =>\n img.decode().catch(() => {\n throw new Error(`${img.currentSrc || img.src} did not load`)\n })\n )\n )\n await new Promise((done) =>\n requestAnimationFrame(() => requestAnimationFrame(done))\n )\n const styleOf = getComputedStyle(document.documentElement)\n return {\n background: styleOf.getPropertyValue(\"--background\").trim() || \"white\",\n card: styleOf.getPropertyValue(\"--card\").trim() || \"white\",\n border: styleOf.getPropertyValue(\"--border\").trim() || \"currentColor\",\n shadow:\n styleOf.getPropertyValue(\"--fd-block-shadow\").trim() ||\n \"color-mix(in oklab, currentColor 20%, transparent)\",\n }\n}\n\n// The card: the screenshot in a browser window with three dots, 80px from\n// the sides and 64px from the top, on stone, with the floor shadow in the\n// block shadow's brown.\nconst frame = (src: string) => `<!doctype html><html><head><style>\n* { margin: 0; box-sizing: border-box; }\nhtml, body { width: ${card.width}px; height: ${card.height}px; overflow: hidden; background: var(--og-background); }\n.frame { position: absolute; left: 80px; right: 80px; top: 64px; height: 620px; overflow: hidden; border-radius: 18px;\n background: var(--og-background);\n box-shadow: 0 0 0 1px color-mix(in oklab, var(--og-shadow) 40%, transparent), 0 2px 4px -2px var(--og-shadow), 0 36px 70px -24px var(--og-shadow); }\n.bar { height: 30px; display: flex; gap: 7px; align-items: center; padding: 0 15px; background: var(--og-card); border-bottom: 1px solid var(--og-border); }\n.bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--og-border); }\niframe { display: block; border: 0; width: ${shot.width}px; height: ${shot.height}px; transform: scale(${1040 / shot.width}); transform-origin: top left; }\n</style></head><body><div class=\"frame\"><div class=\"bar\"><i></i><i></i><i></i></div><iframe title=\"Open Graph source\" src=\"${src}\"></iframe></div></body></html>`\n\ntype Drawing = { jpeg: Buffer; resources: string[] }\n\n// Draws each owner page of dist into its card.\nconst draw = async (dist: string, sources: string[]) => {\n if (!process.env.CHROME) {\n const cli = new URL(\n \"cli.js\",\n import.meta.resolve(\"playwright-core/package.json\")\n )\n execFileSync(\n process.execPath,\n [fileURLToPath(cli), \"install\", \"chromium\", \"--only-shell\"],\n { stdio: \"inherit\" }\n )\n }\n const files = sirv(dist)\n const server = createServer((req, res) =>\n files(req, res, () => {\n res.statusCode = 404\n res.end(\"Not found\")\n })\n )\n let browser: Browser | undefined\n try {\n await new Promise<void>((done, fail) =>\n server.once(\"error\", fail).listen(0, \"127.0.0.1\", done)\n )\n const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`\n browser = await chromium.launch({ executablePath: process.env.CHROME })\n const activeBrowser = browser\n const drawings = new Map<string, Drawing>()\n let next = 0\n // Reuse one browser with bounded concurrency. The iframe keeps the\n // hero's 1680px layout while the final 1200px card needs only one shot.\n await Promise.all(\n Array.from({ length: Math.min(4, sources.length) }, async () => {\n while (next < sources.length) {\n const source = sources[next++]!\n // A fresh context records every request, even when another page\n // already loaded the same stylesheet, font or public image.\n const context = await activeBrowser.newContext({\n viewport: card,\n reducedMotion: \"reduce\",\n serviceWorkers: \"block\",\n })\n try {\n // Analytics and APIs never see the run or hold it up.\n await context.route(\n (url) => url.origin !== origin,\n (route) => route.abort()\n )\n const page = await context.newPage()\n const resources = new Set([source])\n page.on(\"request\", (request) => {\n const url = new URL(request.url())\n if (url.origin === origin) resources.add(url.pathname)\n })\n const url = new URL(source, origin).href\n await page.setContent(frame(url.replaceAll(\"&\", \"&\")), {\n waitUntil: \"load\",\n })\n const inner = page.frames().find((frame) => frame.url() === url)\n const theme = await inner?.evaluate(isolate)\n if (!theme)\n throw new Error(\n `${source} has no [data-og] or section around its h1`\n )\n await page.evaluate((theme) => {\n for (const [name, color] of Object.entries(theme))\n document.documentElement.style.setProperty(\n `--og-${name}`,\n color\n )\n }, theme)\n drawings.set(source, {\n jpeg: await page.screenshot({\n type: \"jpeg\",\n quality: 85,\n animations: \"disabled\",\n }),\n resources: [...resources].sort(),\n })\n } finally {\n await context.close()\n }\n }\n })\n )\n return drawings\n } finally {\n await browser?.close().catch(() => {})\n server.closeAllConnections()\n await new Promise((done) => server.close(done))\n }\n}\n\nconst digest = (input: string | Buffer) =>\n createHash(\"sha256\").update(input).digest(\"hex\")\n\n// Metadata is rewritten after drawing. Normalize those URLs so a direct\n// rerun and a fresh Astro build have the same input fingerprint.\nconst normalize = (html: string) => {\n const metas = metasOf(html)\n const urls = new Map(\n metas\n .filter((meta) => meta.source !== undefined)\n .map((meta) => [\n meta.content,\n new URL(ogImage(meta.source!), meta.content).href,\n ])\n )\n for (const { content, start, end } of metas.toReversed()) {\n const url = urls.get(content)\n if (url) html = `${html.slice(0, start)}content=\"${url}\"${html.slice(end)}`\n }\n return html\n}\n\n// Cache entries describe the files Chromium actually requested, including\n// imported CSS, scripts, fonts and responsive images. Hash each file once\n// per run; a changed dependency invalidates only the pages that loaded it.\nexport const generate = async (\n dist: string,\n {\n cacheDir = join(dirname(dist), \"node_modules/.cache/fulldev-og\"),\n render = draw,\n }: { cacheDir?: string; render?: typeof draw } = {}\n) => {\n const work = plan(dist)\n const customBrowser = process.env.CHROME && statSync(process.env.CHROME)\n const fingerprint = digest(\n [\n readFileSync(fileURLToPath(import.meta.url), \"utf8\"),\n readFileSync(\n fileURLToPath(import.meta.resolve(\"playwright-core/package.json\")),\n \"utf8\"\n ),\n process.platform,\n process.arch,\n customBrowser\n ? `${process.env.CHROME}:${customBrowser.size}:${customBrowser.mtimeMs}`\n : \"managed-chromium\",\n ].join(\"\\n\")\n )\n const inputs = new Map<string, string>()\n const inputHash = (path: string) => {\n let hash = inputs.get(path)\n if (hash !== undefined) return hash\n // Match sirv's file and directory-index resolution, including routes\n // without a trailing slash.\n const stem = path.replace(/\\/$/, \"\")\n const file = [\"\", \".html\", \".htm\"]\n .flatMap((extension) => [\n ...(stem ? [`${stem}${extension}`] : []),\n `${stem}/index${extension}`,\n ])\n .map((name) => inside(dist, name))\n .find((name) => existsSync(name) && statSync(name).isFile())\n if (!file) hash = \"missing\"\n else\n hash = digest(\n file.endsWith(\".html\")\n ? normalize(readFileSync(file, \"utf8\"))\n : readFileSync(file)\n )\n inputs.set(path, hash)\n return hash\n }\n const jpegs = new Map<string, Buffer>()\n const missing: string[] = []\n mkdirSync(cacheDir, { recursive: true })\n for (const source of work.owners.keys()) {\n const entry = join(cacheDir, digest(source))\n try {\n const cached = JSON.parse(readFileSync(`${entry}.json`, \"utf8\")) as {\n renderer: string\n image: string\n resources: [string, string][]\n }\n if (\n cached.renderer !== fingerprint ||\n !cached.resources.some(([path]) => path === source) ||\n !cached.resources.every(([path, hash]) => inputHash(path) === hash)\n )\n throw new Error(\"Changed input\")\n const jpeg = readFileSync(`${entry}.jpg`)\n if (digest(jpeg) !== cached.image) throw new Error(\"Changed cache image\")\n jpegs.set(source, jpeg)\n } catch {\n missing.push(source)\n }\n }\n if (missing.length) {\n const drawings = await render(dist, missing)\n for (const source of missing) {\n const drawing = drawings.get(source)\n if (!drawing) throw new Error(`No image drawn for ${source}`)\n const entry = join(cacheDir, digest(source))\n writeFileSync(`${entry}.jpg`, drawing.jpeg)\n writeFileSync(\n `${entry}.json`,\n JSON.stringify({\n renderer: fingerprint,\n image: digest(drawing.jpeg),\n resources: [...new Set([source, ...drawing.resources])].map(\n (path) => [path, inputHash(path)]\n ),\n })\n )\n jpegs.set(source, drawing.jpeg)\n }\n }\n apply(dist, work, jpegs)\n const active = new Set([...work.owners.keys()].map(digest))\n for (const name of readdirSync(cacheDir))\n if (\n /^[a-f0-9]{64}\\.(json|jpg)$/.test(name) &&\n !active.has(name.slice(0, 64))\n )\n rmSync(join(cacheDir, name))\n const result = {\n rendered: missing.length,\n reused: work.owners.size - missing.length,\n }\n console.log(\n `Open Graph: ${result.rendered} rendered, ${result.reused} reused`\n )\n return result\n}\n\nif (import.meta.main) await generate(resolve(process.argv[2] ?? \"dist\"))\n",
|
|
18
|
+
"type": "registry:file",
|
|
19
|
+
"target": "~/scripts/og.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "registry/site/scripts/open-graph.test.ts",
|
|
23
|
+
"content": "// Verify the published routes, after Astro has normalized content filenames\n// and applied custom slugs. Reuse the build.\nimport assert from \"node:assert/strict\"\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { test } from \"node:test\"\nimport sharp from \"sharp\"\n\ntest(\"indexed pages advertise usable share images without generating unindexed images\", async () => {\n const files = readdirSync(\"dist\", { recursive: true, encoding: \"utf8\" })\n const advertised = new Set<string>()\n for (const file of files.filter((file) => file.endsWith(\"index.html\"))) {\n const html = readFileSync(join(\"dist\", file), \"utf8\")\n const path = file.slice(0, -\"index.html\".length)\n const stem = `/og/${path ? path.slice(0, -1) : \"index\"}.`\n if (/<meta name=\"robots\" content=\"[^\"]*noindex/.test(html)) {\n assert.ok(\n !files.some((name) => `/${name}`.startsWith(stem)),\n `${file} has no fallback`\n )\n continue\n }\n const url = html.match(/property=\"og:image\" content=\"([^\"]+)\"/)?.[1]\n assert.ok(url, `${file} has an og:image`)\n const imagePath = decodeURI(new URL(url).pathname)\n // A custom image is published by Astro's image service. Only generated\n // fallback images belong in /og and must match the page's actual route.\n if (!html.includes(\"data-og-source=\")) continue\n assert.ok(imagePath.startsWith(stem), `${file} uses its fallback`)\n assert.match(imagePath.slice(stem.length), /^[a-f0-9]{12}\\.jpg$/, file)\n assert.ok(existsSync(join(\"dist\", imagePath)), file)\n advertised.add(imagePath)\n const metadata = await sharp(join(\"dist\", imagePath)).metadata()\n assert.equal(metadata.format, \"jpeg\", file)\n assert.equal(metadata.width, 1200, file)\n assert.equal(metadata.height, 630, file)\n }\n const generated = files\n .filter(\n (file) => file.startsWith(\"og/\") && /\\.[a-f0-9]{12}\\.jpg$/.test(file)\n )\n .map((file) => `/${file}`)\n assert.deepEqual(new Set(generated), advertised)\n})\n",
|
|
24
|
+
"type": "registry:file",
|
|
25
|
+
"target": "~/scripts/open-graph.test.ts"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "registry/site/scripts/netlify-cache/index.js",
|
|
29
|
+
"content": "import { join } from \"node:path\"\n\nconst directory = (inputs) =>\n join(inputs.directory, \"node_modules/.cache/fulldev-og\")\n\nexport async function onPreBuild({ inputs, utils }) {\n const restored = await utils.cache.restore(directory(inputs))\n console.log(`Open Graph cache: ${restored ? \"restored\" : \"empty\"}`)\n}\n\nexport async function onBuild({ inputs, utils }) {\n await utils.cache.save(directory(inputs))\n}\n",
|
|
30
|
+
"type": "registry:file",
|
|
31
|
+
"target": "~/scripts/netlify-cache/index.js"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "registry/site/scripts/netlify-cache/manifest.yml",
|
|
35
|
+
"content": "name: fulldev-og-cache\ninputs:\n - name: directory\n description: Site directory relative to the Netlify base directory.\n default: .\n",
|
|
36
|
+
"type": "registry:file",
|
|
37
|
+
"target": "~/scripts/netlify-cache/manifest.yml"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "registry/site/src/lib/og.ts",
|
|
41
|
+
"content": "// The Open Graph image of a page path, generated from dist during the build (scripts/og.ts):\n// /og/index.jpg for the homepage, /og/<path>.jpg for the others.\nexport const ogImage = (path: string) =>\n path === \"/\" ? \"/og/index.jpg\" : `/og${path.replace(/\\/$/, \"\")}.jpg`\n",
|
|
42
|
+
"type": "registry:file",
|
|
43
|
+
"target": "~/src/lib/og.ts"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"type": "registry:file"
|
|
47
|
+
}
|
|
@@ -4682,6 +4682,63 @@
|
|
|
4682
4682
|
}
|
|
4683
4683
|
}
|
|
4684
4684
|
},
|
|
4685
|
+
{
|
|
4686
|
+
"name": "images",
|
|
4687
|
+
"type": "registry:file",
|
|
4688
|
+
"title": "Images",
|
|
4689
|
+
"description": "Converts a site's source photos to WebP within 3840 pixels and updates their references; `--check` checks them.",
|
|
4690
|
+
"dependencies": [
|
|
4691
|
+
"sharp"
|
|
4692
|
+
],
|
|
4693
|
+
"files": [
|
|
4694
|
+
{
|
|
4695
|
+
"path": "scripts/images.ts",
|
|
4696
|
+
"type": "registry:file",
|
|
4697
|
+
"target": "~/scripts/images.ts"
|
|
4698
|
+
}
|
|
4699
|
+
]
|
|
4700
|
+
},
|
|
4701
|
+
{
|
|
4702
|
+
"name": "og",
|
|
4703
|
+
"type": "registry:file",
|
|
4704
|
+
"title": "Open Graph images",
|
|
4705
|
+
"description": "Draws each page's Open Graph image from the built site, checks them, and keeps them in Netlify's build cache.",
|
|
4706
|
+
"dependencies": [
|
|
4707
|
+
"sharp"
|
|
4708
|
+
],
|
|
4709
|
+
"devDependencies": [
|
|
4710
|
+
"parse5",
|
|
4711
|
+
"playwright-core",
|
|
4712
|
+
"sirv"
|
|
4713
|
+
],
|
|
4714
|
+
"files": [
|
|
4715
|
+
{
|
|
4716
|
+
"path": "registry/site/scripts/og.ts",
|
|
4717
|
+
"type": "registry:file",
|
|
4718
|
+
"target": "~/scripts/og.ts"
|
|
4719
|
+
},
|
|
4720
|
+
{
|
|
4721
|
+
"path": "registry/site/scripts/open-graph.test.ts",
|
|
4722
|
+
"type": "registry:file",
|
|
4723
|
+
"target": "~/scripts/open-graph.test.ts"
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
"path": "registry/site/scripts/netlify-cache/index.js",
|
|
4727
|
+
"type": "registry:file",
|
|
4728
|
+
"target": "~/scripts/netlify-cache/index.js"
|
|
4729
|
+
},
|
|
4730
|
+
{
|
|
4731
|
+
"path": "registry/site/scripts/netlify-cache/manifest.yml",
|
|
4732
|
+
"type": "registry:file",
|
|
4733
|
+
"target": "~/scripts/netlify-cache/manifest.yml"
|
|
4734
|
+
},
|
|
4735
|
+
{
|
|
4736
|
+
"path": "registry/site/src/lib/og.ts",
|
|
4737
|
+
"type": "registry:file",
|
|
4738
|
+
"target": "~/src/lib/og.ts"
|
|
4739
|
+
}
|
|
4740
|
+
]
|
|
4741
|
+
},
|
|
4685
4742
|
{
|
|
4686
4743
|
"name": "base",
|
|
4687
4744
|
"type": "registry:base",
|