@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.92
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/compiler-assets/nextjs/defaults/group/index.tsx +16 -11
- package/compiler-assets/nextjs/defaults/group/layout.tsx +6 -6
- package/compiler-assets/nextjs/defaults/group/page.tsx +36 -26
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +21 -11
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
- package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
- package/compiler-assets/nextjs/defaults/root/index.tsx +16 -11
- package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -3
- package/compiler-assets/nextjs/shims/agent-user-agents.ts +65 -0
- package/compiler-assets/nextjs/shims/document.tsx +46 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +5 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
- package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
- package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
- package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
- package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
- package/compiler-assets/nextjs/shims/proxy.ts +254 -86
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
- package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
- package/dist/{build-operation-2JAYBSKF.js → build-operation-CJDUL4OW.js} +29 -23
- package/dist/{button-c3WGnxIj.d.ts → button-D6Xp2HBm.d.ts} +4 -4
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -0
- package/dist/chunk-3T4HVDSC.js +426 -0
- package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
- package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
- package/dist/chunk-5KAD7W53.js +248 -0
- package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
- package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
- package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
- package/dist/chunk-DX7PXFCM.js +2519 -0
- package/dist/{chunk-726GV2NF.js → chunk-DZ3VWEV5.js} +950 -632
- package/dist/chunk-EFO6AWXN.js +19 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/{chunk-H6XILMZX.js → chunk-NHSLTARU.js} +2588 -1493
- package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
- package/dist/{chunk-VO2I7MTM.js → chunk-SBMDONTV.js} +10 -7
- package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
- package/dist/compiler.d.ts +15 -2
- package/dist/compiler.js +111 -23
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +563 -0
- package/dist/components/blocks/toc.d.ts +43 -0
- package/dist/components/blocks/toc.js +136 -0
- package/dist/components/ui/button.d.ts +4 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-44GJSMXD.js +16 -0
- package/dist/config/createNextConfig.js +19 -3
- package/dist/{dev-operation-TZDVJCN7.js → dev-operation-WNECBHZ5.js} +134 -84
- package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
- package/dist/ide-support-TG74L4FF.js +16 -0
- package/dist/index.d.ts +151 -95
- package/dist/index.js +25 -0
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.js +100 -0
- package/dist/jsx-runtime.d.ts +7 -0
- package/dist/jsx-runtime.js +97 -0
- package/dist/kernel/components/blocks/AgentActions.d.ts +37 -8
- package/dist/kernel/components/blocks/AgentActions.js +384 -174
- package/dist/kernel/components/blocks/agent-actions.d.ts +4 -0
- package/dist/kernel/components/blocks/agent-actions.js +563 -0
- package/dist/kernel/components/blocks/animated-icon-swap.d.ts +2 -2
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.d.ts +2 -2
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.d.ts +2 -2
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +6 -5
- package/dist/kernel/components/blocks/nav-breadcrumb.js +21 -15
- package/dist/kernel/components/blocks/navbar.d.ts +5 -4
- package/dist/kernel/components/blocks/navbar.js +79 -59
- package/dist/kernel/components/blocks/navigation-progress.d.ts +2 -2
- package/dist/kernel/components/blocks/navigation-progress.js +2 -2
- package/dist/kernel/components/blocks/next-prev.d.ts +4 -4
- package/dist/kernel/components/blocks/next-prev.js +30 -7
- package/dist/kernel/components/blocks/page-list.d.ts +4 -4
- package/dist/kernel/components/blocks/page-list.js +32 -9
- package/dist/kernel/components/blocks/search.d.ts +9 -15
- package/dist/kernel/components/blocks/search.js +16 -17
- package/dist/kernel/components/blocks/sidebar-node.d.ts +3 -5
- package/dist/kernel/components/blocks/sidebar-node.js +13 -3
- package/dist/kernel/components/blocks/sidebar.d.ts +6 -7
- package/dist/kernel/components/blocks/sidebar.js +137 -28
- package/dist/kernel/components/blocks/theme-toggle.d.ts +3 -4
- package/dist/kernel/components/blocks/theme-toggle.js +5 -5
- package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
- package/dist/kernel/components/blocks/toc-client.js +495 -0
- package/dist/kernel/components/blocks/toc.d.ts +20 -2
- package/dist/kernel/components/blocks/toc.js +121 -179
- package/dist/kernel/components/mdx/components/blockquote.d.ts +2 -2
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.d.ts +3 -3
- package/dist/kernel/components/mdx/components/callout.js +1 -1
- package/dist/kernel/components/mdx/components/code-block.d.ts +2 -2
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.d.ts +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +3 -3
- package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
- package/dist/kernel/components/mdx/components/figure.d.ts +8 -4
- package/dist/kernel/components/mdx/components/figure.js +23 -13
- package/dist/kernel/components/mdx/components/footnotes.d.ts +2 -2
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.d.ts +2 -2
- package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
- package/dist/kernel/components/mdx/components/heading.d.ts +2 -2
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.d.ts +4 -4
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.d.ts +3 -3
- package/dist/kernel/components/mdx/components/image-zoom.js +4 -3
- package/dist/kernel/components/mdx/components/image.d.ts +2 -2
- package/dist/kernel/components/mdx/components/image.js +22 -17
- package/dist/kernel/components/mdx/components/inline-code.d.ts +2 -2
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.d.ts +3 -3
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +6 -6
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.d.ts +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +1 -1
- package/dist/kernel/components/mdx/components/strikethrough.d.ts +2 -2
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.d.ts +7 -7
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.d.ts +3 -3
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.d.ts +8 -4
- package/dist/kernel/components/mdx/components/video-player.js +6 -2
- package/dist/kernel/components/mdx/components/video.d.ts +5 -4
- package/dist/kernel/components/mdx/components/video.js +7 -5
- package/dist/kernel/components/mdx/error-boundary.d.ts +3 -4
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.d.ts +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +57 -16
- package/dist/kernel/components/mdx/mdx.js +232 -35
- package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
- package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/next-image.d.ts +12 -0
- package/dist/kernel/components/next-image.js +61 -0
- package/dist/kernel/components/ui/accordion.d.ts +7 -7
- package/dist/kernel/components/ui/accordion.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -4
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +14 -14
- package/dist/kernel/components/ui/breadcrumb.js +4 -4
- package/dist/kernel/components/ui/button-group.d.ts +6 -6
- package/dist/kernel/components/ui/button-group.js +3 -3
- package/dist/kernel/components/ui/button.d.ts +59 -7
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.d.ts +7 -7
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.d.ts +10 -10
- package/dist/kernel/components/ui/dialog.js +1 -1
- package/dist/kernel/components/ui/drawer.d.ts +12 -12
- package/dist/kernel/components/ui/drawer.js +1 -1
- package/dist/kernel/components/ui/input.d.ts +2 -2
- package/dist/kernel/components/ui/input.js +1 -1
- package/dist/kernel/components/ui/kbd.d.ts +4 -4
- package/dist/kernel/components/ui/kbd.js +1 -1
- package/dist/kernel/components/ui/link.d.ts +11 -5
- package/dist/kernel/components/ui/link.js +2 -2
- package/dist/kernel/components/ui/menu.d.ts +22 -22
- package/dist/kernel/components/ui/menu.js +1 -1
- package/dist/kernel/components/ui/mod-key.d.ts +2 -3
- package/dist/kernel/components/ui/mod-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.d.ts +15 -15
- package/dist/kernel/components/ui/navigation-menu.js +1 -1
- package/dist/kernel/components/ui/popover.d.ts +11 -11
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.d.ts +7 -7
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +9 -10
- package/dist/kernel/components/ui/scroll-area.js +1 -1
- package/dist/kernel/components/ui/select.d.ts +16 -16
- package/dist/kernel/components/ui/select.js +1 -1
- package/dist/kernel/components/ui/separator.d.ts +3 -3
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.d.ts +7 -7
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.d.ts +12 -12
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.d.ts +3 -3
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +4 -4
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.d.ts +11 -11
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.d.ts +9 -9
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +4 -17
- package/dist/kernel/defaults.registry.js +4 -19
- package/dist/kernel/routes/agent/markdown.d.ts +7 -0
- package/dist/kernel/routes/agent/markdown.js +229 -54
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +5 -7
- package/dist/kernel/routes/metadata/feed.d.ts +1 -2
- package/dist/kernel/routes/metadata/feed.js +119 -88
- package/dist/kernel/routes/metadata/llms.d.ts +3 -23
- package/dist/kernel/routes/metadata/llms.js +2 -103
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +5 -3
- package/dist/kernel/routes/metadata/robots.js +4 -25
- package/dist/kernel/routes/metadata/sitemap.d.ts +36 -3
- package/dist/kernel/routes/metadata/sitemap.js +277 -49
- package/dist/kernel/routes/not-found.d.ts +34 -0
- package/dist/kernel/routes/not-found.js +213 -0
- package/dist/kernel/routes/pages/group.d.ts +5 -5
- package/dist/kernel/routes/pages/group.js +11 -5
- package/dist/kernel/routes/pages/leaf.d.ts +38 -6
- package/dist/kernel/routes/pages/leaf.js +21 -12
- package/dist/kernel/routes/pages/root.d.ts +5 -5
- package/dist/kernel/routes/pages/root.js +21 -6
- package/dist/keyboard-shortcuts.d.ts +2 -2
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/manifest-types-CcVPH_jh.d.ts +83 -0
- package/dist/resolvers/manifest-resolver.d.ts +2 -2
- package/dist/resolvers/manifest-resolver.js +65 -35
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.d.ts +2 -9
- package/dist/search.js +9 -16
- package/dist/sidebar-types-CMrMM0Nj.d.ts +105 -0
- package/dist/theme-scope.d.ts +2 -2
- package/dist/theme-scope.js +1 -1
- package/dist/types-BbqmOzLC.d.ts +168 -0
- package/dist/types-TjH1ek0X.d.ts +22 -0
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +117 -91
- package/dist/utils/heading-ids.js +30 -11
- package/dist/utils/toc-selection.d.ts +7 -0
- package/dist/utils/toc-selection.js +14 -0
- package/dist/validate-local-source-EN2GW4FR.js +16 -0
- package/dist/validate-publish-os-source-OEWQDB7B.js +14 -0
- package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
- package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
- package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
- package/init/seed/minimal/publish.os/blog/index.tsx +85 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +91 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
- package/init/seed/minimal/publish.os/components/blog/frontmatter.ts +41 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
- package/init/seed/minimal/publish.os/publish.os.config.json +17 -2
- package/init/seed/minimal/publish.os/theme.css +3 -3
- package/init/seed/minimal/seed.json +12 -4
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
- package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
- package/package.json +48 -23
- package/release/app/phosphor/package.json +4 -4
- package/release/app/phosphor/pnpm-lock.yaml.template +123 -184
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +153 -183
- package/release/release.json +6 -6
- package/dist/button-CtzUJB8u.d.ts +0 -11
- package/dist/chunk-535TM4A5.js +0 -1455
- package/dist/chunk-B2V22WRT.js +0 -297
- package/dist/chunk-NECL5IBJ.js +0 -318
- package/dist/chunk-SVYGXXYR.js +0 -36
- package/dist/chunk-UF6ATARM.js +0 -1100
- package/dist/compose-NN23UJGC.js +0 -13
- package/dist/ide-support-ZNW7ODFY.js +0 -15
- package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
- package/dist/kernel/components/blocks/design-system-preview.js +0 -667
- package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/link-playground.js +0 -744
- package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
- package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
- package/dist/kernel/components/ui/theme-toggle.js +0 -53
- package/dist/sidebar-types-DKpR27II.d.ts +0 -25
- package/dist/types-BzkZty3r.d.ts +0 -147
- package/dist/types-CJWRG05y.d.ts +0 -76
- package/dist/types-CUtrppxt.d.ts +0 -69
- package/dist/validate-local-source-XRL2Y7XE.js +0 -14
- package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
- package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppError
|
|
3
|
+
} from "./chunk-22RSSUNV.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/compiler/source/assets/media-file-policy.ts
|
|
6
|
+
import { constants as fsConstants } from "fs";
|
|
7
|
+
import { open } from "fs/promises";
|
|
8
|
+
var DEFAULT_MAX_IMAGE_BYTES = 20 * 1024 * 1024, DEFAULT_MAX_VIDEO_BYTES = 20 * 1024 * 1024, DEFAULT_MAX_OTHER_BYTES = 5 * 1024 * 1024, MAX_THEME_FONT_BYTES = DEFAULT_MAX_OTHER_BYTES, MAX_MEDIA_SVG_BYTES = 256 * 1024, IGNORED_DOCUMENT_EXTENSIONS = /* @__PURE__ */ new Set(["pdf", "txt", "csv", "zip"]), THEME_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
9
|
+
"png",
|
|
10
|
+
"jpg",
|
|
11
|
+
"jpeg",
|
|
12
|
+
"gif",
|
|
13
|
+
"webp",
|
|
14
|
+
"avif",
|
|
15
|
+
"ico",
|
|
16
|
+
"svg"
|
|
17
|
+
]), THEME_FONT_EXTENSIONS = /* @__PURE__ */ new Set(["woff", "woff2", "ttf", "otf"]);
|
|
18
|
+
function ignoredMediaDocumentWarning(relativePath) {
|
|
19
|
+
let extension = relativePath.split(".").at(-1)?.toLowerCase() ?? "";
|
|
20
|
+
if (IGNORED_DOCUMENT_EXTENSIONS.has(extension))
|
|
21
|
+
return {
|
|
22
|
+
code: "FRAMEWORK_MEDIA_DOCUMENT_IGNORED",
|
|
23
|
+
message: `${relativePath} is ignored because this file type is not supported.`,
|
|
24
|
+
details: { file: relativePath, path: relativePath }
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function ignoredMediaPathWarning(sourcePath) {
|
|
28
|
+
return {
|
|
29
|
+
code: "FRAMEWORK_MEDIA_PATH_IGNORED",
|
|
30
|
+
message: "Hidden media file ignored.",
|
|
31
|
+
details: { file: sourcePath, path: sourcePath }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function isHiddenMediaPath(sourcePath) {
|
|
35
|
+
return sourcePath.split(/[\\/]/u).some((segment) => segment.startsWith("."));
|
|
36
|
+
}
|
|
37
|
+
function mediaFileTooLarge(options) {
|
|
38
|
+
return new AppError({
|
|
39
|
+
code: "FRAMEWORK_MEDIA_FILE_TOO_LARGE",
|
|
40
|
+
message: `${options.relativePath} is ${options.bytes} bytes. Media files must be less than ${Math.round(options.limit / 1024 / 1024)} MB.`,
|
|
41
|
+
details: {
|
|
42
|
+
path: options.relativePath,
|
|
43
|
+
bytes: options.bytes,
|
|
44
|
+
limit: options.limit
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function mediaFileByteLimit(relativePath) {
|
|
49
|
+
let extension = relativePath.split(".").at(-1)?.toLowerCase() ?? "", imageLimit = DEFAULT_MAX_IMAGE_BYTES;
|
|
50
|
+
return ["png", "jpg", "jpeg", "gif", "webp", "avif", "ico"].includes(extension) ? imageLimit : extension === "svg" ? Math.min(imageLimit, MAX_MEDIA_SVG_BYTES) : ["mp4", "webm"].includes(extension) ? DEFAULT_MAX_VIDEO_BYTES : DEFAULT_MAX_OTHER_BYTES;
|
|
51
|
+
}
|
|
52
|
+
function themeResourceByteLimit(relativePath) {
|
|
53
|
+
let extension = relativePath.split(".").at(-1)?.toLowerCase() ?? "";
|
|
54
|
+
if (THEME_FONT_EXTENSIONS.has(extension)) return MAX_THEME_FONT_BYTES;
|
|
55
|
+
if (THEME_IMAGE_EXTENSIONS.has(extension))
|
|
56
|
+
return mediaFileByteLimit(relativePath);
|
|
57
|
+
}
|
|
58
|
+
async function readBoundedMediaFile(options) {
|
|
59
|
+
let handle = await (options.openFile ?? open)(
|
|
60
|
+
options.path,
|
|
61
|
+
fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0)
|
|
62
|
+
);
|
|
63
|
+
try {
|
|
64
|
+
let opened = await handle.stat();
|
|
65
|
+
if (!opened.isFile() || options.expectedIdentity !== void 0 && (opened.dev !== options.expectedIdentity.dev || opened.ino !== options.expectedIdentity.ino))
|
|
66
|
+
throw new AppError({
|
|
67
|
+
code: "FRAMEWORK_MEDIA_FILE_CHANGED",
|
|
68
|
+
message: `${options.relativePath} changed while media was being read`,
|
|
69
|
+
details: { path: options.relativePath }
|
|
70
|
+
});
|
|
71
|
+
if (opened.size > options.limit)
|
|
72
|
+
throw mediaFileTooLarge({
|
|
73
|
+
relativePath: options.relativePath,
|
|
74
|
+
bytes: opened.size,
|
|
75
|
+
limit: options.limit
|
|
76
|
+
});
|
|
77
|
+
let chunkSize = Math.min(64 * 1024, options.limit + 1), chunk = Buffer.allocUnsafe(Math.max(1, chunkSize)), chunks = [], bytesRead = 0;
|
|
78
|
+
for (; ; ) {
|
|
79
|
+
options.signal?.throwIfAborted();
|
|
80
|
+
let remainingWithOverflowProbe = options.limit - bytesRead + 1, { bytesRead: count } = await handle.read(
|
|
81
|
+
chunk,
|
|
82
|
+
0,
|
|
83
|
+
Math.min(chunk.length, remainingWithOverflowProbe),
|
|
84
|
+
null
|
|
85
|
+
);
|
|
86
|
+
if (options.signal?.throwIfAborted(), count === 0) break;
|
|
87
|
+
if (bytesRead += count, bytesRead > options.limit)
|
|
88
|
+
throw mediaFileTooLarge({
|
|
89
|
+
relativePath: options.relativePath,
|
|
90
|
+
bytes: bytesRead,
|
|
91
|
+
limit: options.limit
|
|
92
|
+
});
|
|
93
|
+
chunks.push(Buffer.from(chunk.subarray(0, count)));
|
|
94
|
+
}
|
|
95
|
+
let completed = await handle.stat();
|
|
96
|
+
if (completed.size > options.limit)
|
|
97
|
+
throw mediaFileTooLarge({
|
|
98
|
+
relativePath: options.relativePath,
|
|
99
|
+
bytes: completed.size,
|
|
100
|
+
limit: options.limit
|
|
101
|
+
});
|
|
102
|
+
if (completed.size !== bytesRead)
|
|
103
|
+
throw new AppError({
|
|
104
|
+
code: "FRAMEWORK_MEDIA_FILE_CHANGED",
|
|
105
|
+
message: `${options.relativePath} changed while media was being read`,
|
|
106
|
+
details: { path: options.relativePath }
|
|
107
|
+
});
|
|
108
|
+
return Buffer.concat(chunks, bytesRead);
|
|
109
|
+
} finally {
|
|
110
|
+
await handle.close();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/lib/compiler/source/css-imports.ts
|
|
115
|
+
function skipString(css, start) {
|
|
116
|
+
let quote = css[start];
|
|
117
|
+
for (let index = start + 1; index < css.length; index += 1)
|
|
118
|
+
if (css[index] === "\\") index += 1;
|
|
119
|
+
else if (css[index] === quote) return index + 1;
|
|
120
|
+
return css.length;
|
|
121
|
+
}
|
|
122
|
+
function maskComments(css) {
|
|
123
|
+
let result = "";
|
|
124
|
+
for (let index = 0; index < css.length; )
|
|
125
|
+
if (css[index] === '"' || css[index] === "'") {
|
|
126
|
+
let end = skipString(css, index);
|
|
127
|
+
result += css.slice(index, end), index = end;
|
|
128
|
+
} else if (css.startsWith("/*", index)) {
|
|
129
|
+
let closing = css.indexOf("*/", index + 2), end = closing < 0 ? css.length : closing + 2;
|
|
130
|
+
result += css.slice(index, end).replace(/[^\r\n]/g, " "), index = end;
|
|
131
|
+
} else
|
|
132
|
+
result += css[index], index += 1;
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
function decodeCssPath(value) {
|
|
136
|
+
return value.replace(/\\(?:\r\n|[\r\n\f])/g, "").replace(
|
|
137
|
+
/\\([\da-f]{1,6})[\t\n\f\r ]?|\\(.)/gi,
|
|
138
|
+
(_match, hex, escaped) => {
|
|
139
|
+
if (!hex) return escaped ?? "";
|
|
140
|
+
let codePoint = Number.parseInt(hex, 16);
|
|
141
|
+
return codePoint > 0 && codePoint <= 1114111 && !(codePoint >= 55296 && codePoint <= 57343) ? String.fromCodePoint(codePoint) : "\uFFFD";
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
function statementEnd(scan, start) {
|
|
146
|
+
let depth = 0;
|
|
147
|
+
for (let index = start; index < scan.length; index += 1)
|
|
148
|
+
if (scan[index] === '"' || scan[index] === "'")
|
|
149
|
+
index = skipString(scan, index) - 1;
|
|
150
|
+
else if (scan[index] === "\\")
|
|
151
|
+
index += 1;
|
|
152
|
+
else if (scan[index] === "(")
|
|
153
|
+
depth += 1;
|
|
154
|
+
else if (scan[index] === ")")
|
|
155
|
+
depth -= 1;
|
|
156
|
+
else {
|
|
157
|
+
if (scan[index] === ";" && depth === 0)
|
|
158
|
+
return index + 1;
|
|
159
|
+
if ((scan[index] === "{" || scan[index] === "}") && depth === 0)
|
|
160
|
+
return index;
|
|
161
|
+
}
|
|
162
|
+
return scan.length;
|
|
163
|
+
}
|
|
164
|
+
function closingParenthesis(scan, start, end) {
|
|
165
|
+
let depth = 0;
|
|
166
|
+
for (let index = start; index < end; index += 1)
|
|
167
|
+
if (scan[index] === '"' || scan[index] === "'")
|
|
168
|
+
index = skipString(scan, index) - 1;
|
|
169
|
+
else if (scan[index] === "\\")
|
|
170
|
+
index += 1;
|
|
171
|
+
else if (scan[index] === "(")
|
|
172
|
+
depth += 1;
|
|
173
|
+
else if (scan[index] === ")" && --depth === 0)
|
|
174
|
+
return index;
|
|
175
|
+
return end;
|
|
176
|
+
}
|
|
177
|
+
function importConditions({
|
|
178
|
+
css,
|
|
179
|
+
scan,
|
|
180
|
+
start,
|
|
181
|
+
end
|
|
182
|
+
}) {
|
|
183
|
+
let result = {}, tailEnd = scan[end - 1] === ";" ? end - 1 : end, cursor = start, skipWhitespace = () => {
|
|
184
|
+
for (; cursor < tailEnd && /\s/.test(scan[cursor] ?? ""); ) cursor += 1;
|
|
185
|
+
};
|
|
186
|
+
skipWhitespace();
|
|
187
|
+
let layer = /^layer(?=\(|\s|$)/i.exec(scan.slice(cursor, tailEnd));
|
|
188
|
+
if (layer) {
|
|
189
|
+
if (cursor += layer[0].length, scan[cursor] === "(") {
|
|
190
|
+
let closing = closingParenthesis(scan, cursor, tailEnd);
|
|
191
|
+
result.layer = css.slice(cursor + 1, closing).trim(), cursor = closing + 1;
|
|
192
|
+
} else
|
|
193
|
+
result.layer = !0;
|
|
194
|
+
skipWhitespace();
|
|
195
|
+
}
|
|
196
|
+
let supports = /^supports\(/i.exec(scan.slice(cursor, tailEnd));
|
|
197
|
+
if (supports) {
|
|
198
|
+
let opening = cursor + supports[0].length - 1, closing = closingParenthesis(scan, opening, tailEnd);
|
|
199
|
+
result.supports = css.slice(opening + 1, closing).trim(), cursor = closing + 1, skipWhitespace();
|
|
200
|
+
}
|
|
201
|
+
return scan.slice(cursor, tailEnd).trim() && (result.media = css.slice(cursor, tailEnd).trim()), result;
|
|
202
|
+
}
|
|
203
|
+
function cssImports({ css }) {
|
|
204
|
+
let scan = maskComments(css), pattern = /@import\s+(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|url\(\s*(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|([^\s)]+))\s*\))/giy, imports = [];
|
|
205
|
+
for (let index = 0; index < scan.length; ) {
|
|
206
|
+
if (scan[index] === '"' || scan[index] === "'") {
|
|
207
|
+
index = skipString(scan, index);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (scan[index] === "\\") {
|
|
211
|
+
index += 2;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
pattern.lastIndex = index;
|
|
215
|
+
let match = scan[index] === "@" ? pattern.exec(scan) : null;
|
|
216
|
+
if (!match) {
|
|
217
|
+
index += 1;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
let path = decodeCssPath(
|
|
221
|
+
match.slice(1).find((value) => value !== void 0) ?? ""
|
|
222
|
+
), end = statementEnd(scan, pattern.lastIndex);
|
|
223
|
+
imports.push({
|
|
224
|
+
path,
|
|
225
|
+
start: index,
|
|
226
|
+
end,
|
|
227
|
+
...importConditions({ css, scan, start: pattern.lastIndex, end })
|
|
228
|
+
}), index = end;
|
|
229
|
+
}
|
|
230
|
+
return imports;
|
|
231
|
+
}
|
|
232
|
+
function localCssImports({ css }) {
|
|
233
|
+
return cssImports({ css }).filter(({ path }) => path.startsWith("."));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
MAX_MEDIA_SVG_BYTES,
|
|
238
|
+
ignoredMediaDocumentWarning,
|
|
239
|
+
ignoredMediaPathWarning,
|
|
240
|
+
isHiddenMediaPath,
|
|
241
|
+
mediaFileTooLarge,
|
|
242
|
+
mediaFileByteLimit,
|
|
243
|
+
themeResourceByteLimit,
|
|
244
|
+
readBoundedMediaFile,
|
|
245
|
+
decodeCssPath,
|
|
246
|
+
cssImports,
|
|
247
|
+
localCssImports
|
|
248
|
+
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
assertLocalDirectory,
|
|
4
4
|
assertOperationOutput,
|
|
5
5
|
markOperationOutput
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6D2E6UMD.js";
|
|
7
7
|
import {
|
|
8
8
|
AppError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-22RSSUNV.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/compiler/lifecycle/checkout-preparation.ts
|
|
12
12
|
import { lstat, mkdir, readdir, realpath } from "fs/promises";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
PUBLIC_SEARCH_DIRECTORY
|
|
3
|
+
} from "./chunk-EFO6AWXN.js";
|
|
4
4
|
import {
|
|
5
5
|
AppError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-22RSSUNV.js";
|
|
7
7
|
|
|
8
8
|
// src/lib/compiler/lifecycle/output-ownership.ts
|
|
9
9
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
link,
|
|
13
13
|
lstat,
|
|
14
14
|
mkdir,
|
|
15
|
+
mkdtemp,
|
|
15
16
|
open,
|
|
16
17
|
readdir,
|
|
17
18
|
realpath,
|
|
18
19
|
rename,
|
|
20
|
+
rmdir,
|
|
19
21
|
unlink,
|
|
20
22
|
writeFile
|
|
21
23
|
} from "fs/promises";
|
|
@@ -27,7 +29,7 @@ var MUTABLE_PREVIEW_ENTRIES = /* @__PURE__ */ new Set([
|
|
|
27
29
|
"tsconfig.tsbuildinfo",
|
|
28
30
|
".operation-owner.json",
|
|
29
31
|
".preview-cache.json",
|
|
30
|
-
|
|
32
|
+
PUBLIC_SEARCH_DIRECTORY
|
|
31
33
|
]);
|
|
32
34
|
async function generatedInventory(outputDir, stagingDir) {
|
|
33
35
|
if (stagingDir && (dirname(stagingDir) !== outputDir || !/^\.refresh-[a-zA-Z0-9]{6}$/u.test(basename(stagingDir))))
|
|
@@ -52,7 +54,7 @@ async function generatedInventory(outputDir, stagingDir) {
|
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
56
|
if (MUTABLE_PREVIEW_ENTRIES.has(path)) {
|
|
55
|
-
if (["node_modules", ".next",
|
|
57
|
+
if (["node_modules", ".next", PUBLIC_SEARCH_DIRECTORY].includes(path))
|
|
56
58
|
await assertLocalDirectory(absolute), path !== "node_modules" && await assertMutable(absolute);
|
|
57
59
|
else if (!entry.isFile()) throw redirectedOutput(absolute);
|
|
58
60
|
return;
|
|
@@ -210,7 +212,8 @@ async function markOperationOutput(options) {
|
|
|
210
212
|
function ownershipError() {
|
|
211
213
|
return new AppError({
|
|
212
214
|
code: "FRAMEWORK_LOCAL_OUTPUT_OWNERSHIP",
|
|
213
|
-
message: "The generated output
|
|
215
|
+
message: "The generated output could not be verified. Its files were preserved.",
|
|
216
|
+
fix: "Stop commands using this source, then run the command again to rebuild its generated output."
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
219
|
function redirectedOutput(path) {
|
|
@@ -224,7 +227,8 @@ async function assertLocalDirectory(path, expected) {
|
|
|
224
227
|
if (!entry.isDirectory() || entry.isSymbolicLink() || await realpath(path) !== path || expected && (entry.dev !== expected.dev || entry.ino !== expected.ino))
|
|
225
228
|
throw new AppError({
|
|
226
229
|
code: "FRAMEWORK_LOCAL_OUTPUT_REDIRECTED",
|
|
227
|
-
message: "The source-owned output directory was redirected or replaced. Restore it before continuing."
|
|
230
|
+
message: "The source-owned output directory was redirected or replaced. Restore it before continuing.",
|
|
231
|
+
details: { path }
|
|
228
232
|
});
|
|
229
233
|
return entry;
|
|
230
234
|
}
|
|
@@ -241,69 +245,41 @@ async function readOwnership(path, maximumSize = 16384) {
|
|
|
241
245
|
await file.close();
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
|
-
async function
|
|
245
|
-
sourceRoot
|
|
246
|
-
ownerSourceRoot = sourceRoot
|
|
248
|
+
async function ensureLocalOutputRoot({
|
|
249
|
+
sourceRoot
|
|
247
250
|
}) {
|
|
248
251
|
let sourceIdentity = await assertLocalDirectory(sourceRoot), outputRoot = join(sourceRoot, ".publish.os");
|
|
249
252
|
await mkdir(outputRoot).catch((error) => {
|
|
250
253
|
if (error.code !== "EEXIST") throw error;
|
|
251
254
|
});
|
|
252
|
-
let outputIdentity = await assertLocalDirectory(outputRoot),
|
|
255
|
+
let outputIdentity = await assertLocalDirectory(outputRoot), assertCurrent = async () => {
|
|
253
256
|
await assertLocalDirectory(sourceRoot, sourceIdentity), await assertLocalDirectory(outputRoot, outputIdentity);
|
|
254
|
-
for (let name of [
|
|
255
|
-
".locks",
|
|
256
|
-
".stages",
|
|
257
|
-
"build",
|
|
258
|
-
"dev",
|
|
259
|
-
"ide",
|
|
260
|
-
".ide-lock"
|
|
261
|
-
])
|
|
262
|
-
await assertLocalDirectory(join(outputRoot, name)).catch(
|
|
263
|
-
(error) => {
|
|
264
|
-
if (error.code !== "ENOENT") throw error;
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}, assertOwner = async () => {
|
|
268
|
-
try {
|
|
269
|
-
let current = await readOwnership(ownerPath);
|
|
270
|
-
if (!current || current.schemaVersion !== 1 || current.sourceRoot !== ownerSourceRoot)
|
|
271
|
-
throw ownershipError();
|
|
272
|
-
} catch {
|
|
273
|
-
throw ownershipError();
|
|
274
|
-
}
|
|
275
257
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
258
|
+
return await assertCurrent(), { outputRoot, assertCurrent };
|
|
259
|
+
}
|
|
260
|
+
async function recoverOperationOutput(options) {
|
|
261
|
+
try {
|
|
262
|
+
await assertOperationOutput(options), await assertGeneratedOutput(options);
|
|
263
|
+
return;
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (!(error instanceof AppError) || ![
|
|
266
|
+
"FRAMEWORK_LOCAL_OUTPUT_OWNERSHIP",
|
|
267
|
+
"FRAMEWORK_LOCAL_OUTPUT_MODIFIED",
|
|
268
|
+
"FRAMEWORK_LOCAL_OUTPUT_REDIRECTED"
|
|
269
|
+
].includes(error.code))
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
await options.assertCurrent();
|
|
273
|
+
let recoveryRoot = join(dirname(options.outputDir), "recovery");
|
|
274
|
+
await mkdir(recoveryRoot, { recursive: !0 }), await assertLocalDirectory(recoveryRoot);
|
|
275
|
+
let recovery = await mkdtemp(
|
|
276
|
+
join(recoveryRoot, `${localOperationName(options)}-`)
|
|
277
|
+
);
|
|
278
|
+
try {
|
|
279
|
+
await options.assertCurrent(), await rename(options.outputDir, join(recovery, "output"));
|
|
280
|
+
} catch (error) {
|
|
281
|
+
throw await rmdir(recovery), error;
|
|
300
282
|
}
|
|
301
|
-
return await assertOwner(), await assertDirectories(), {
|
|
302
|
-
outputRoot,
|
|
303
|
-
assertCurrent: async () => {
|
|
304
|
-
await assertDirectories(), await assertOwner();
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
283
|
}
|
|
308
284
|
|
|
309
285
|
// src/lib/compiler/lifecycle/operation-lock.ts
|
|
@@ -315,18 +291,23 @@ import {
|
|
|
315
291
|
open as open2,
|
|
316
292
|
readdir as readdir2,
|
|
317
293
|
realpath as realpath2,
|
|
318
|
-
rmdir,
|
|
294
|
+
rmdir as rmdir2,
|
|
319
295
|
unlink as unlink2,
|
|
320
296
|
writeFile as writeFile2
|
|
321
297
|
} from "fs/promises";
|
|
322
298
|
import { hostname } from "os";
|
|
323
|
-
import { join as join2, resolve } from "path";
|
|
299
|
+
import { isAbsolute, join as join2, resolve } from "path";
|
|
324
300
|
function lockError({
|
|
325
301
|
code,
|
|
326
302
|
message,
|
|
327
303
|
sourceRoot
|
|
328
304
|
}) {
|
|
329
|
-
return new AppError({
|
|
305
|
+
return new AppError({
|
|
306
|
+
code,
|
|
307
|
+
message,
|
|
308
|
+
details: { sourceRoot },
|
|
309
|
+
fix: code === "FRAMEWORK_LOCAL_OPERATION_ACTIVE" ? "Stop the running command for this source, then run the command again." : `Stop commands using this source, move only ${join2(sourceRoot, ".publish.os")} aside to preserve it, then run the command again.`
|
|
310
|
+
});
|
|
330
311
|
}
|
|
331
312
|
async function directoryIdentity({
|
|
332
313
|
path,
|
|
@@ -385,7 +366,7 @@ async function readOwner({
|
|
|
385
366
|
if (!owner || typeof owner != "object")
|
|
386
367
|
throw new Error("Invalid lock metadata.");
|
|
387
368
|
let value = owner;
|
|
388
|
-
if (value.sourceRoot
|
|
369
|
+
if (typeof value.sourceRoot != "string" || !isAbsolute(value.sourceRoot) || !["build", "dev", "ide", "dependencies"].includes(
|
|
389
370
|
value.operation ?? ""
|
|
390
371
|
) || value.scope !== void 0 && (value.operation !== "dev" || typeof value.scope != "string" || !/^[a-f0-9]{64}$/u.test(value.scope)) || !Number.isSafeInteger(value.pid) || (value.pid ?? 0) <= 0 || typeof value.hostname != "string" || !value.hostname || typeof value.token != "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u.test(
|
|
391
372
|
value.token
|
|
@@ -411,7 +392,7 @@ async function assertOwnedLock({
|
|
|
411
392
|
}) {
|
|
412
393
|
await verifyDirectory({ directory: parent, sourceRoot: owner.sourceRoot });
|
|
413
394
|
let current = await readOwner({ directory, sourceRoot: owner.sourceRoot });
|
|
414
|
-
if (current.token !== owner.token || current.operation !== owner.operation || current.scope !== owner.scope)
|
|
395
|
+
if (current.sourceRoot !== owner.sourceRoot || current.token !== owner.token || current.operation !== owner.operation || current.scope !== owner.scope)
|
|
415
396
|
throw lockError({
|
|
416
397
|
code: "FRAMEWORK_LOCAL_LOCK_UNVERIFIED",
|
|
417
398
|
message: "The operation lock now belongs to another owner. Leave it in place and inspect the active operation.",
|
|
@@ -460,7 +441,7 @@ async function removeOwnedLock({
|
|
|
460
441
|
owner,
|
|
461
442
|
beforeRemoval
|
|
462
443
|
}) {
|
|
463
|
-
await assertOwnedLock({ directory, parent, owner }), beforeRemoval?.(), await unlink2(join2(directory.path, "owner.json")), await
|
|
444
|
+
await assertOwnedLock({ directory, parent, owner }), beforeRemoval?.(), await unlink2(join2(directory.path, "owner.json")), await rmdir2(directory.path);
|
|
464
445
|
}
|
|
465
446
|
function assertDeadOwner({
|
|
466
447
|
owner,
|
|
@@ -609,6 +590,97 @@ async function acquireOperationLock({
|
|
|
609
590
|
};
|
|
610
591
|
}
|
|
611
592
|
|
|
593
|
+
// src/lib/compiler/lifecycle/owned-directory-publication.ts
|
|
594
|
+
import { lstat as lstat3, mkdir as mkdir3, mkdtemp as mkdtemp2, rename as rename2, rm } from "fs/promises";
|
|
595
|
+
import { basename as basename2, join as join3 } from "path";
|
|
596
|
+
async function assertMissing(path) {
|
|
597
|
+
try {
|
|
598
|
+
await lstat3(path);
|
|
599
|
+
} catch (error) {
|
|
600
|
+
if (error.code === "ENOENT") return;
|
|
601
|
+
throw error;
|
|
602
|
+
}
|
|
603
|
+
throw new AppError({
|
|
604
|
+
code: "FRAMEWORK_LOCAL_OUTPUT_REDIRECTED",
|
|
605
|
+
message: `Owned output appeared during publication: ${path}. The previous bytes were preserved.`
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
async function publishOwnedDirectory(options) {
|
|
609
|
+
options.signal?.throwIfAborted(), await options.assertOwner(), await mkdir3(options.stagingRoot, { recursive: !0 });
|
|
610
|
+
let stagingRootIdentity = await assertLocalDirectory(options.stagingRoot), stage = await mkdtemp2(
|
|
611
|
+
join3(options.stagingRoot, `${options.stagingPrefix}-`)
|
|
612
|
+
), stageIdentity = await assertLocalDirectory(stage), incoming = join3(stage, "incoming"), retainStage = !1, assertStage = async () => {
|
|
613
|
+
try {
|
|
614
|
+
await options.assertOwner(), await assertLocalDirectory(options.stagingRoot, stagingRootIdentity), await assertLocalDirectory(stage, stageIdentity);
|
|
615
|
+
} catch (error) {
|
|
616
|
+
throw options.onRecoveryRequired?.(), error;
|
|
617
|
+
}
|
|
618
|
+
}, previous, previousIdentity, recoveryEntry, recoveryRootIdentity, recoveryEntryIdentity, movedPrevious = !1, published = !1, failure;
|
|
619
|
+
try {
|
|
620
|
+
await mkdir3(incoming), await assertLocalDirectory(incoming), await options.prepareIncoming(incoming), options.signal?.throwIfAborted(), await assertStage();
|
|
621
|
+
let preparedIncomingIdentity = await assertLocalDirectory(incoming);
|
|
622
|
+
await options.validateIncoming?.(incoming), await assertStage(), await assertLocalDirectory(incoming, preparedIncomingIdentity);
|
|
623
|
+
try {
|
|
624
|
+
previousIdentity = await lstat3(options.targetDirectory), await assertLocalDirectory(options.targetDirectory, previousIdentity);
|
|
625
|
+
} catch (error) {
|
|
626
|
+
if (error.code !== "ENOENT") throw error;
|
|
627
|
+
previousIdentity = void 0;
|
|
628
|
+
}
|
|
629
|
+
if (previousIdentity) {
|
|
630
|
+
options.recoveryRoot ? (await mkdir3(options.recoveryRoot, { recursive: !0 }), recoveryRootIdentity = await assertLocalDirectory(options.recoveryRoot), recoveryEntry = await mkdtemp2(
|
|
631
|
+
join3(options.recoveryRoot, `${basename2(options.targetDirectory)}-`)
|
|
632
|
+
), recoveryEntryIdentity = await assertLocalDirectory(recoveryEntry), previous = join3(recoveryEntry, basename2(options.targetDirectory))) : previous = join3(stage, "previous"), await assertStage(), recoveryRootIdentity && options.recoveryRoot && await assertLocalDirectory(options.recoveryRoot, recoveryRootIdentity), recoveryEntryIdentity && recoveryEntry && await assertLocalDirectory(recoveryEntry, recoveryEntryIdentity), await assertLocalDirectory(options.targetDirectory, previousIdentity), await rename2(options.targetDirectory, previous), movedPrevious = !0;
|
|
633
|
+
try {
|
|
634
|
+
await assertLocalDirectory(previous, previousIdentity);
|
|
635
|
+
} catch (error) {
|
|
636
|
+
throw retainStage = !0, options.onRecoveryRequired?.(), new AggregateError(
|
|
637
|
+
[error],
|
|
638
|
+
`Owned output changed while being retained; preserve the previous output at ${previous}.`
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
try {
|
|
643
|
+
options.signal?.throwIfAborted(), await assertStage(), await assertLocalDirectory(incoming, preparedIncomingIdentity), await assertMissing(options.targetDirectory), await options.beforePublish?.(), await rename2(incoming, options.targetDirectory), published = !0;
|
|
644
|
+
} catch (publishError) {
|
|
645
|
+
if (movedPrevious && previous && previousIdentity)
|
|
646
|
+
try {
|
|
647
|
+
await assertStage(), recoveryRootIdentity && options.recoveryRoot && await assertLocalDirectory(
|
|
648
|
+
options.recoveryRoot,
|
|
649
|
+
recoveryRootIdentity
|
|
650
|
+
), recoveryEntryIdentity && recoveryEntry && await assertLocalDirectory(recoveryEntry, recoveryEntryIdentity), await assertMissing(options.targetDirectory), await rename2(previous, options.targetDirectory), await assertLocalDirectory(options.targetDirectory, previousIdentity), movedPrevious = !1;
|
|
651
|
+
} catch (rollbackError) {
|
|
652
|
+
throw retainStage = !0, options.onRecoveryRequired?.(), new AggregateError(
|
|
653
|
+
[publishError, rollbackError],
|
|
654
|
+
`Owned output publication failed; the previous output remains at ${previous}.`
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
throw publishError;
|
|
658
|
+
}
|
|
659
|
+
} catch (error) {
|
|
660
|
+
failure = error;
|
|
661
|
+
}
|
|
662
|
+
if (!retainStage && (!failure || options.cleanupFailedStaging !== !1))
|
|
663
|
+
try {
|
|
664
|
+
await assertStage(), await rm(stage, { recursive: !0, force: !0 });
|
|
665
|
+
} catch (cleanupError) {
|
|
666
|
+
failure = failure ? new AggregateError(
|
|
667
|
+
[failure, cleanupError],
|
|
668
|
+
`Owned output publication failed; staging cleanup also failed at ${stage}.`
|
|
669
|
+
) : cleanupError;
|
|
670
|
+
}
|
|
671
|
+
if (recoveryEntry && !movedPrevious)
|
|
672
|
+
try {
|
|
673
|
+
options.recoveryRoot && recoveryRootIdentity && await assertLocalDirectory(options.recoveryRoot, recoveryRootIdentity), recoveryEntryIdentity && await assertLocalDirectory(recoveryEntry, recoveryEntryIdentity), await rm(recoveryEntry, { recursive: !0, force: !0 });
|
|
674
|
+
} catch (cleanupError) {
|
|
675
|
+
failure = failure ? new AggregateError(
|
|
676
|
+
[failure, cleanupError],
|
|
677
|
+
`Owned output publication failed; recovery cleanup also failed at ${recoveryEntry}.`
|
|
678
|
+
) : cleanupError;
|
|
679
|
+
}
|
|
680
|
+
if (failure) throw failure;
|
|
681
|
+
if (!published) throw new Error("Owned output was not published.");
|
|
682
|
+
}
|
|
683
|
+
|
|
612
684
|
export {
|
|
613
685
|
assertGeneratedOutput,
|
|
614
686
|
prepareGeneratedOutputUpdate,
|
|
@@ -616,6 +688,8 @@ export {
|
|
|
616
688
|
assertOperationOutput,
|
|
617
689
|
markOperationOutput,
|
|
618
690
|
assertLocalDirectory,
|
|
619
|
-
|
|
620
|
-
|
|
691
|
+
ensureLocalOutputRoot,
|
|
692
|
+
recoverOperationOutput,
|
|
693
|
+
acquireOperationLock,
|
|
694
|
+
publishOwnedDirectory
|
|
621
695
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isOsMetadataPath,
|
|
2
3
|
isSameOrDescendant
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WL75GQ5M.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/compiler/source/assert-publish-os-source-boundary.ts
|
|
7
|
+
import { lstat, readdir, realpath } from "fs/promises";
|
|
8
|
+
import { basename, dirname, join, relative, resolve, sep } from "path";
|
|
4
9
|
|
|
5
10
|
// src/lib/compiler/source/diagnostics/errors/publish-os-source-error.ts
|
|
6
11
|
var ERROR_CODES = {
|
|
@@ -25,6 +30,7 @@ var ERROR_CODES = {
|
|
|
25
30
|
CONFIG_CONTENT_MISSING: "CONFIG_CONTENT_MISSING",
|
|
26
31
|
CONFIG_CONTENT_NOT_DIRECTORY: "CONFIG_CONTENT_NOT_DIRECTORY",
|
|
27
32
|
CONTENT_FRONTMATTER_INVALID_JSON: "CONTENT_FRONTMATTER_INVALID_JSON",
|
|
33
|
+
CONTENT_FRONTMATTER_LANGUAGE_UNSUPPORTED: "CONTENT_FRONTMATTER_LANGUAGE_UNSUPPORTED",
|
|
28
34
|
CONTENT_FRONTMATTER_REQUIRED: "CONTENT_FRONTMATTER_REQUIRED",
|
|
29
35
|
CONTENT_FRONTMATTER_ID_INVALID: "CONTENT_FRONTMATTER_ID_INVALID",
|
|
30
36
|
CONTENT_FILE_PARSE_FAILED: "CONTENT_FILE_PARSE_FAILED",
|
|
@@ -42,8 +48,6 @@ var ERROR_CODES = {
|
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
// src/lib/compiler/source/assert-publish-os-source-boundary.ts
|
|
45
|
-
import { lstat, readdir, realpath } from "fs/promises";
|
|
46
|
-
import { basename, dirname, join, relative, resolve, sep } from "path";
|
|
47
51
|
function displayPath(root, path) {
|
|
48
52
|
return relative(root, path).split(sep).join("/") || ".";
|
|
49
53
|
}
|
|
@@ -55,6 +59,7 @@ function sourceBoundaryError(options) {
|
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
async function assertEntry(options) {
|
|
62
|
+
if (isOsMetadataPath(relative(options.root, options.path))) return;
|
|
58
63
|
let entry = await lstat(options.path);
|
|
59
64
|
if (entry.isSymbolicLink())
|
|
60
65
|
throw sourceBoundaryError({
|