@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.91
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/layout.tsx +1 -5
- package/compiler-assets/nextjs/defaults/group/page.tsx +31 -22
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +19 -10
- 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/shims/document.tsx +38 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +2 -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 +126 -60
- 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-5QMLXF7N.js} +29 -23
- package/dist/{button-c3WGnxIj.d.ts → button-BdCScEKi.d.ts} +3 -3
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -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-EFO6AWXN.js +19 -0
- package/dist/{chunk-726GV2NF.js → chunk-F3AGNDF4.js} +100 -67
- package/dist/chunk-GBPLER5H.js +426 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
- package/dist/{chunk-VO2I7MTM.js → chunk-ORIUWJBQ.js} +8 -6
- package/dist/{chunk-H6XILMZX.js → chunk-OXOFRXEI.js} +1806 -831
- package/dist/chunk-UYGCOWRF.js +1709 -0
- package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
- package/dist/compiler.d.ts +15 -2
- package/dist/compiler.js +90 -21
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +594 -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 +5 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-CVBJRAF6.js +16 -0
- package/dist/config/createNextConfig.js +17 -3
- package/dist/{dev-operation-TZDVJCN7.js → dev-operation-OSHHWRWK.js} +121 -81
- package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
- package/dist/ide-support-CU6Z5PVR.js +16 -0
- package/dist/index.d.ts +40 -1
- 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 +35 -6
- package/dist/kernel/components/blocks/AgentActions.js +383 -142
- package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
- package/dist/kernel/components/blocks/agent-actions.js +594 -0
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -2
- package/dist/kernel/components/blocks/navbar.js +17 -17
- package/dist/kernel/components/blocks/navigation-progress.js +2 -2
- package/dist/kernel/components/blocks/next-prev.js +1 -1
- package/dist/kernel/components/blocks/page-list.js +2 -2
- package/dist/kernel/components/blocks/search.d.ts +1 -1
- package/dist/kernel/components/blocks/search.js +16 -17
- package/dist/kernel/components/blocks/sidebar-node.js +1 -1
- package/dist/kernel/components/blocks/sidebar.js +7 -4
- package/dist/kernel/components/blocks/theme-toggle.d.ts +1 -1
- 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 +19 -1
- package/dist/kernel/components/blocks/toc.js +121 -179
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.js +1 -1
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
- package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
- package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
- package/dist/kernel/components/mdx/components/figure.js +23 -13
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +1 -1
- package/dist/kernel/components/mdx/components/image.d.ts +1 -1
- package/dist/kernel/components/mdx/components/image.js +21 -16
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +3 -3
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +1 -1
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
- package/dist/kernel/components/mdx/components/video-player.js +6 -2
- package/dist/kernel/components/mdx/components/video.d.ts +5 -3
- package/dist/kernel/components/mdx/components/video.js +7 -5
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +20 -10
- package/dist/kernel/components/mdx/mdx.js +231 -34
- 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.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +2 -2
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +4 -4
- package/dist/kernel/components/ui/button-group.d.ts +1 -1
- package/dist/kernel/components/ui/button-group.js +3 -3
- package/dist/kernel/components/ui/button.d.ts +56 -4
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.js +1 -1
- 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 +1 -1
- package/dist/kernel/components/ui/kbd.js +1 -1
- package/dist/kernel/components/ui/link.d.ts +8 -2
- package/dist/kernel/components/ui/link.js +2 -2
- package/dist/kernel/components/ui/menu.js +1 -1
- package/dist/kernel/components/ui/mod-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.js +1 -1
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +8 -8
- package/dist/kernel/components/ui/scroll-area.js +1 -1
- package/dist/kernel/components/ui/select.js +1 -1
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +1 -1
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +2 -15
- package/dist/kernel/defaults.registry.js +2 -17
- package/dist/kernel/routes/agent/markdown.d.ts +3 -0
- package/dist/kernel/routes/agent/markdown.js +219 -48
- 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 -1
- package/dist/kernel/routes/metadata/feed.js +109 -83
- package/dist/kernel/routes/metadata/llms.d.ts +11 -3
- package/dist/kernel/routes/metadata/llms.js +154 -57
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +1 -1
- package/dist/kernel/routes/metadata/sitemap.d.ts +22 -3
- package/dist/kernel/routes/metadata/sitemap.js +183 -43
- 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 +2 -2
- package/dist/kernel/routes/pages/group.js +1 -1
- package/dist/kernel/routes/pages/leaf.d.ts +30 -3
- package/dist/kernel/routes/pages/leaf.js +5 -4
- package/dist/kernel/routes/pages/root.d.ts +2 -2
- package/dist/kernel/routes/pages/root.js +1 -1
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.js +7 -9
- package/dist/theme-scope.js +1 -1
- package/dist/{types-BzkZty3r.d.ts → types-J2w_puPF.d.ts} +1 -20
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +1 -0
- 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-SV44DBQT.js +16 -0
- package/dist/validate-publish-os-source-NZJF3TB2.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 +82 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -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 +6 -2
- package/init/seed/minimal/publish.os/theme.css +3 -3
- package/init/seed/minimal/seed.json +11 -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 +45 -20
- package/release/app/phosphor/package.json +3 -3
- package/release/app/phosphor/pnpm-lock.yaml.template +88 -75
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +118 -74
- 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/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,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertPublishOsSourceBoundary
|
|
3
|
+
} from "./chunk-7NY22B5U.js";
|
|
4
|
+
import {
|
|
5
|
+
decodeCssPath,
|
|
6
|
+
ignoredMediaDocumentWarning,
|
|
7
|
+
mediaFileByteLimit,
|
|
8
|
+
readBoundedMediaFile,
|
|
9
|
+
themeResourceByteLimit
|
|
10
|
+
} from "./chunk-5KAD7W53.js";
|
|
11
|
+
import {
|
|
12
|
+
isExcludedSourcePath
|
|
13
|
+
} from "./chunk-WL75GQ5M.js";
|
|
14
|
+
import {
|
|
15
|
+
AppError
|
|
16
|
+
} from "./chunk-22RSSUNV.js";
|
|
17
|
+
|
|
18
|
+
// src/lib/compiler/lifecycle/capture-local-source.ts
|
|
19
|
+
import { createHash } from "crypto";
|
|
20
|
+
import { constants } from "fs";
|
|
21
|
+
import {
|
|
22
|
+
lstat,
|
|
23
|
+
mkdir,
|
|
24
|
+
open,
|
|
25
|
+
readdir,
|
|
26
|
+
readFile,
|
|
27
|
+
realpath,
|
|
28
|
+
writeFile
|
|
29
|
+
} from "fs/promises";
|
|
30
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
31
|
+
import valueParser from "postcss-value-parser";
|
|
32
|
+
function isInside({ root, path }) {
|
|
33
|
+
let value = relative(root, path);
|
|
34
|
+
return value !== "" && value !== ".." && !value.startsWith(`..${sep}`) && !isAbsolute(value);
|
|
35
|
+
}
|
|
36
|
+
function cssResourcePaths(css) {
|
|
37
|
+
let paths = /* @__PURE__ */ new Set();
|
|
38
|
+
return valueParser(css).walk((node) => {
|
|
39
|
+
if (node.type !== "function") return;
|
|
40
|
+
let name = node.value.toLowerCase(), candidates = name === "url" ? node.nodes.filter(
|
|
41
|
+
(child) => child.type === "string" || child.type === "word"
|
|
42
|
+
) : ["image-set", "-webkit-image-set"].includes(name) ? node.nodes.filter((child) => child.type === "string") : [];
|
|
43
|
+
for (let candidate of candidates) {
|
|
44
|
+
let decoded = decodeCssPath(candidate.value.trim());
|
|
45
|
+
if (!decoded || decoded.startsWith("#") || decoded.startsWith("/") || decoded.startsWith("//") || /^[a-z][a-z0-9+.-]*:/iu.test(decoded))
|
|
46
|
+
continue;
|
|
47
|
+
let path = decoded.split(/[?#]/u, 1)[0] ?? "";
|
|
48
|
+
path && paths.add(path);
|
|
49
|
+
}
|
|
50
|
+
if (name === "url") return !1;
|
|
51
|
+
}), [...paths];
|
|
52
|
+
}
|
|
53
|
+
async function collectCssReferencedResources({
|
|
54
|
+
captureDir,
|
|
55
|
+
capturedFiles
|
|
56
|
+
}) {
|
|
57
|
+
let referenced = /* @__PURE__ */ new Set();
|
|
58
|
+
for (let cssFile of capturedFiles.filter(
|
|
59
|
+
(path) => path.toLowerCase().endsWith(".css")
|
|
60
|
+
)) {
|
|
61
|
+
let css = await readFile(join(captureDir, cssFile), "utf8");
|
|
62
|
+
for (let urlPath of cssResourcePaths(css)) {
|
|
63
|
+
let absolutePath = resolve(captureDir, dirname(cssFile), urlPath);
|
|
64
|
+
isInside({ root: captureDir, path: absolutePath }) && referenced.add(relative(captureDir, absolutePath).split(sep).join("/"));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return referenced;
|
|
68
|
+
}
|
|
69
|
+
function localFontPaths(config) {
|
|
70
|
+
if (!config || typeof config != "object" || Array.isArray(config)) return [];
|
|
71
|
+
let fonts = config.fonts;
|
|
72
|
+
if (!fonts || typeof fonts != "object" || Array.isArray(fonts)) return [];
|
|
73
|
+
let paths = /* @__PURE__ */ new Set();
|
|
74
|
+
for (let role of Object.values(fonts)) {
|
|
75
|
+
if (!role || typeof role != "object" || Array.isArray(role)) continue;
|
|
76
|
+
let src = role.src, addPath = (value) => {
|
|
77
|
+
if (typeof value != "string" || /^[a-z][a-z0-9+.-]*:/iu.test(value) || value.startsWith("//") || value.includes("\0"))
|
|
78
|
+
return;
|
|
79
|
+
let normalized = value.replace(/^\/+/, "").replace(/^\.\//, "");
|
|
80
|
+
normalized && paths.add(normalized);
|
|
81
|
+
};
|
|
82
|
+
if (addPath(src), Array.isArray(src))
|
|
83
|
+
for (let file of src)
|
|
84
|
+
file && typeof file == "object" && !Array.isArray(file) && addPath(file.path);
|
|
85
|
+
}
|
|
86
|
+
return [...paths];
|
|
87
|
+
}
|
|
88
|
+
async function collectConfiguredFontResources({
|
|
89
|
+
captureDir,
|
|
90
|
+
capturedFiles
|
|
91
|
+
}) {
|
|
92
|
+
let referenced = /* @__PURE__ */ new Set();
|
|
93
|
+
for (let configPath of capturedFiles.filter(
|
|
94
|
+
(path) => path.endsWith(".config.json")
|
|
95
|
+
)) {
|
|
96
|
+
let config;
|
|
97
|
+
try {
|
|
98
|
+
config = JSON.parse(await readFile(join(captureDir, configPath), "utf8"));
|
|
99
|
+
} catch {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
for (let fontPath of localFontPaths(config)) {
|
|
103
|
+
let absolutePath = resolve(captureDir, fontPath);
|
|
104
|
+
isInside({ root: captureDir, path: absolutePath }) && referenced.add(relative(captureDir, absolutePath).split(sep).join("/"));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return referenced;
|
|
108
|
+
}
|
|
109
|
+
async function readUnboundedSourceFile({
|
|
110
|
+
path,
|
|
111
|
+
entry,
|
|
112
|
+
signal
|
|
113
|
+
}) {
|
|
114
|
+
let file = await open(
|
|
115
|
+
path,
|
|
116
|
+
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
117
|
+
);
|
|
118
|
+
try {
|
|
119
|
+
let opened = await file.stat();
|
|
120
|
+
if (!opened.isFile() || opened.dev !== entry.dev || opened.ino !== entry.ino)
|
|
121
|
+
throw new AppError({
|
|
122
|
+
code: "FRAMEWORK_CAPTURE_SOURCE_CHANGED",
|
|
123
|
+
message: "A source entry changed before capture could read it."
|
|
124
|
+
});
|
|
125
|
+
signal?.throwIfAborted();
|
|
126
|
+
let contents = await file.readFile({ signal });
|
|
127
|
+
return signal?.throwIfAborted(), contents;
|
|
128
|
+
} finally {
|
|
129
|
+
await file.close();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function captureLocalSource({
|
|
133
|
+
sourceRoot,
|
|
134
|
+
captureDir,
|
|
135
|
+
signal
|
|
136
|
+
}) {
|
|
137
|
+
signal?.throwIfAborted(), await assertPublishOsSourceBoundary(sourceRoot), signal?.throwIfAborted();
|
|
138
|
+
let root = await realpath(sourceRoot), destination = resolve(captureDir), outputRoot = join(root, ".publish.os");
|
|
139
|
+
if (!isInside({ root: outputRoot, path: destination }) || await realpath(dirname(destination)) !== dirname(destination))
|
|
140
|
+
throw new AppError({
|
|
141
|
+
code: "FRAMEWORK_CAPTURE_OUTPUT_INVALID",
|
|
142
|
+
message: "Source capture requires an owned path inside source output."
|
|
143
|
+
});
|
|
144
|
+
await mkdir(destination).catch((error) => {
|
|
145
|
+
if (error.code !== "EEXIST") throw error;
|
|
146
|
+
});
|
|
147
|
+
let destinationEntry = await lstat(destination);
|
|
148
|
+
if (!destinationEntry.isDirectory() || destinationEntry.isSymbolicLink() || await realpath(destination) !== destination || (await readdir(destination)).length > 0)
|
|
149
|
+
throw new AppError({
|
|
150
|
+
code: "FRAMEWORK_CAPTURE_OUTPUT_INVALID",
|
|
151
|
+
message: "Source capture requires an empty owned directory."
|
|
152
|
+
});
|
|
153
|
+
let capturedFiles = [], deferredResources = [], copyDirectory = async (relativeDirectory) => {
|
|
154
|
+
signal?.throwIfAborted();
|
|
155
|
+
let directory = join(root, relativeDirectory), names = (await readdir(directory)).sort();
|
|
156
|
+
if (!relativeDirectory) {
|
|
157
|
+
let configIndex = names.indexOf("publish.os.config.json");
|
|
158
|
+
if (configIndex > 0) {
|
|
159
|
+
let [configName] = names.splice(configIndex, 1);
|
|
160
|
+
configName && names.unshift(configName);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
for (let name of names) {
|
|
164
|
+
signal?.throwIfAborted();
|
|
165
|
+
let path = relativeDirectory ? `${relativeDirectory}/${name}` : name;
|
|
166
|
+
if (isExcludedSourcePath(path) || relativeDirectory === "" && name.startsWith(".env"))
|
|
167
|
+
continue;
|
|
168
|
+
let sourcePath = join(root, path), outputPath = join(destination, path), entry = await lstat(sourcePath);
|
|
169
|
+
if (entry.isSymbolicLink())
|
|
170
|
+
throw new AppError({
|
|
171
|
+
code: "FRAMEWORK_SOURCE_SYMLINK",
|
|
172
|
+
message: "Symbolic links are not allowed inside publish.os."
|
|
173
|
+
});
|
|
174
|
+
if (!isInside({ root, path: await realpath(sourcePath) }))
|
|
175
|
+
throw new AppError({
|
|
176
|
+
code: "FRAMEWORK_SOURCE_PATH_ESCAPE",
|
|
177
|
+
message: "A source entry resolves outside the selected source."
|
|
178
|
+
});
|
|
179
|
+
if (entry.isDirectory()) {
|
|
180
|
+
await mkdir(outputPath), await copyDirectory(path);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (!entry.isFile())
|
|
184
|
+
throw new AppError({
|
|
185
|
+
code: "FRAMEWORK_SOURCE_ENTRY_NOT_REGULAR",
|
|
186
|
+
message: "Source capture accepts only directories and regular files."
|
|
187
|
+
});
|
|
188
|
+
let contents;
|
|
189
|
+
if (ignoredMediaDocumentWarning(path))
|
|
190
|
+
contents = Buffer.alloc(0);
|
|
191
|
+
else if (path.startsWith("assets/")) {
|
|
192
|
+
let relativeAssetPath = path.slice(7);
|
|
193
|
+
contents = await readBoundedMediaFile({
|
|
194
|
+
path: sourcePath,
|
|
195
|
+
relativePath: `assets/${relativeAssetPath}`,
|
|
196
|
+
limit: mediaFileByteLimit(relativeAssetPath),
|
|
197
|
+
expectedIdentity: { dev: entry.dev, ino: entry.ino },
|
|
198
|
+
signal
|
|
199
|
+
});
|
|
200
|
+
} else if (themeResourceByteLimit(path) !== void 0) {
|
|
201
|
+
deferredResources.push({
|
|
202
|
+
path: sourcePath,
|
|
203
|
+
outputPath,
|
|
204
|
+
relativePath: path,
|
|
205
|
+
entry
|
|
206
|
+
});
|
|
207
|
+
continue;
|
|
208
|
+
} else
|
|
209
|
+
contents = await readUnboundedSourceFile({
|
|
210
|
+
path: sourcePath,
|
|
211
|
+
entry,
|
|
212
|
+
signal
|
|
213
|
+
});
|
|
214
|
+
await writeFile(outputPath, contents, { flag: "wx", signal }), capturedFiles.push(path);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
await copyDirectory("");
|
|
218
|
+
let cssResources = await collectCssReferencedResources({
|
|
219
|
+
captureDir: destination,
|
|
220
|
+
capturedFiles
|
|
221
|
+
});
|
|
222
|
+
for (let path of await collectConfiguredFontResources({
|
|
223
|
+
captureDir: destination,
|
|
224
|
+
capturedFiles
|
|
225
|
+
}))
|
|
226
|
+
cssResources.add(path);
|
|
227
|
+
for (let resource of deferredResources) {
|
|
228
|
+
signal?.throwIfAborted();
|
|
229
|
+
let contents = cssResources.has(resource.relativePath) ? await readBoundedMediaFile({
|
|
230
|
+
path: resource.path,
|
|
231
|
+
relativePath: resource.relativePath,
|
|
232
|
+
limit: themeResourceByteLimit(resource.relativePath) ?? 0,
|
|
233
|
+
expectedIdentity: {
|
|
234
|
+
dev: resource.entry.dev,
|
|
235
|
+
ino: resource.entry.ino
|
|
236
|
+
},
|
|
237
|
+
signal
|
|
238
|
+
}) : await readUnboundedSourceFile({
|
|
239
|
+
path: resource.path,
|
|
240
|
+
entry: resource.entry,
|
|
241
|
+
signal
|
|
242
|
+
});
|
|
243
|
+
await writeFile(resource.outputPath, contents, { flag: "wx", signal }), capturedFiles.push(resource.relativePath);
|
|
244
|
+
}
|
|
245
|
+
let hash = createHash("sha256");
|
|
246
|
+
for (let path of capturedFiles.sort()) {
|
|
247
|
+
signal?.throwIfAborted();
|
|
248
|
+
let contents = await readFile(join(destination, path), { signal });
|
|
249
|
+
hash.update(JSON.stringify([path, contents.byteLength])), hash.update("\0"), hash.update(contents);
|
|
250
|
+
}
|
|
251
|
+
return signal?.throwIfAborted(), {
|
|
252
|
+
sourceDir: captureDir,
|
|
253
|
+
sourceRevision: `sha256:${hash.digest("hex")}`
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
captureLocalSource
|
|
258
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/compiler/internal/errors.ts
|
|
2
|
+
var AppError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
details;
|
|
5
|
+
fix;
|
|
6
|
+
constructor({ code, message, details, fix }) {
|
|
7
|
+
super(message), this.name = "FrameworkError", this.code = code, this.details = details, this.fix = fix;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
AppError
|
|
13
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-22RSSUNV.js";
|
|
4
4
|
|
|
5
5
|
// src/lib/compiler/lifecycle/local-process.ts
|
|
6
6
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -336,6 +336,9 @@ var LocalProcessError = class extends AppError {
|
|
|
336
336
|
}), this.output = output;
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
|
+
async function processGroupAbsentAfterReapTurn(groupExists) {
|
|
340
|
+
return await new Promise((resolve) => setImmediate(resolve)), !groupExists();
|
|
341
|
+
}
|
|
339
342
|
function startLocalProcess(options) {
|
|
340
343
|
options.signal.throwIfAborted();
|
|
341
344
|
let grouped = process.platform !== "win32", environment = options.environment ?? localProcessEnvironment({ mode: "production" }), windows = grouped ? void 0 : startWindowsProcess({
|
|
@@ -399,7 +402,10 @@ function startLocalProcess(options) {
|
|
|
399
402
|
killGroup("SIGTERM");
|
|
400
403
|
let forced = !1;
|
|
401
404
|
for (; groupExists(); ) {
|
|
402
|
-
if (!forced && Date.now() >= deadline - 750 && (killGroup("SIGKILL"), forced = !0), Date.now() >= deadline)
|
|
405
|
+
if (!forced && Date.now() >= deadline - 750 && (killGroup("SIGKILL"), forced = !0), Date.now() >= deadline) {
|
|
406
|
+
if (await processGroupAbsentAfterReapTurn(groupExists)) break;
|
|
407
|
+
throw shutdownFailure();
|
|
408
|
+
}
|
|
403
409
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
404
410
|
}
|
|
405
411
|
}
|
|
@@ -470,9 +476,7 @@ async function installLocalApp({
|
|
|
470
476
|
outputDir,
|
|
471
477
|
framework,
|
|
472
478
|
options,
|
|
473
|
-
lifetime
|
|
474
|
-
purpose,
|
|
475
|
-
assertInstallGraph
|
|
479
|
+
lifetime
|
|
476
480
|
}) {
|
|
477
481
|
let publicCommand = options.request.operation === "validate" ? "init" : options.request.operation, command = options.request.context?.pnpmExecutable;
|
|
478
482
|
if (typeof command != "string" || !isAbsolute(command))
|
|
@@ -525,7 +529,7 @@ async function installLocalApp({
|
|
|
525
529
|
let lockPath = join2(outputDir, "pnpm-lock.yaml"), lock = await readFile(lockPath);
|
|
526
530
|
options.onEvent?.({
|
|
527
531
|
type: "progress",
|
|
528
|
-
message:
|
|
532
|
+
message: "Preparing app dependencies"
|
|
529
533
|
});
|
|
530
534
|
try {
|
|
531
535
|
await run({
|
|
@@ -542,13 +546,13 @@ async function installLocalApp({
|
|
|
542
546
|
throw error instanceof LocalProcessError && error.output.trim() && process.stderr.write(error.output), error;
|
|
543
547
|
options.onEvent?.({
|
|
544
548
|
type: "progress",
|
|
545
|
-
message:
|
|
546
|
-
})
|
|
549
|
+
message: "Downloading missing app dependencies"
|
|
550
|
+
});
|
|
547
551
|
try {
|
|
548
552
|
await run({
|
|
549
|
-
args: ["install", "--frozen-lockfile"
|
|
553
|
+
args: ["install", "--frozen-lockfile"],
|
|
550
554
|
quiet: options.request.operation !== "build",
|
|
551
|
-
timeoutMs:
|
|
555
|
+
timeoutMs: 3e5
|
|
552
556
|
});
|
|
553
557
|
} catch (downloadError) {
|
|
554
558
|
throw downloadError instanceof AppError && downloadError.code === "FRAMEWORK_PROCESS_SHUTDOWN_FAILED" || (lifetime.signal.throwIfAborted(), !(downloadError instanceof LocalProcessError) && !(downloadError instanceof AppError && downloadError.code === "FRAMEWORK_DEPENDENCY_DOWNLOAD_FAILED")) ? downloadError : new AppError({
|
|
@@ -557,7 +561,7 @@ async function installLocalApp({
|
|
|
557
561
|
});
|
|
558
562
|
}
|
|
559
563
|
}
|
|
560
|
-
if (
|
|
564
|
+
if (!(await readFile(lockPath)).equals(lock))
|
|
561
565
|
throw new AppError({
|
|
562
566
|
code: "FRAMEWORK_RELEASE_INVALID",
|
|
563
567
|
message: "App installation changed the released lock. The output was not published."
|
|
@@ -578,9 +582,39 @@ async function installLocalApp({
|
|
|
578
582
|
return { run: (args) => run({ args }) };
|
|
579
583
|
}
|
|
580
584
|
|
|
585
|
+
// src/lib/compiler/lifecycle/local-gates.ts
|
|
586
|
+
async function requestLocalGate({
|
|
587
|
+
options,
|
|
588
|
+
gate
|
|
589
|
+
}) {
|
|
590
|
+
options.signal?.throwIfAborted();
|
|
591
|
+
let approved = await new Promise((resolve, reject) => {
|
|
592
|
+
let abort = () => reject(options.signal?.reason);
|
|
593
|
+
options.signal?.addEventListener("abort", abort, { once: !0 }), options.signal?.aborted && abort(), Promise.resolve().then(() => options.onGate?.(gate)).then((value) => resolve(value === !0), reject).finally(() => options.signal?.removeEventListener("abort", abort));
|
|
594
|
+
});
|
|
595
|
+
if (options.signal?.throwIfAborted(), !approved)
|
|
596
|
+
throw new AppError({
|
|
597
|
+
code: "FRAMEWORK_GATE_DENIED",
|
|
598
|
+
message: "The caller did not authorize the operation."
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
async function approveLocalComposition({
|
|
602
|
+
options
|
|
603
|
+
}) {
|
|
604
|
+
options.onGate && await requestLocalGate({
|
|
605
|
+
options,
|
|
606
|
+
gate: {
|
|
607
|
+
id: "compose",
|
|
608
|
+
kind: "compose",
|
|
609
|
+
summary: "Compose the validated source."
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
|
|
581
614
|
export {
|
|
582
615
|
localProcessEnvironment,
|
|
583
616
|
LocalProcessError,
|
|
584
617
|
startLocalProcess,
|
|
585
|
-
installLocalApp
|
|
618
|
+
installLocalApp,
|
|
619
|
+
approveLocalComposition
|
|
586
620
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
details;
|
|
5
|
-
fix;
|
|
6
|
-
constructor({ code, message, details, fix }) {
|
|
7
|
-
super(message), this.name = "FrameworkError", this.code = code, this.details = details, this.fix = fix;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
AppError
|
|
3
|
+
} from "./chunk-22RSSUNV.js";
|
|
10
4
|
|
|
11
5
|
// src/lib/compiler/release/installed-framework.ts
|
|
12
6
|
import { readFileSync } from "fs";
|
|
@@ -122,7 +116,6 @@ async function readInstalledFramework() {
|
|
|
122
116
|
}
|
|
123
117
|
|
|
124
118
|
export {
|
|
125
|
-
AppError,
|
|
126
119
|
readInstalledFrameworkLocation,
|
|
127
120
|
readInstalledFramework
|
|
128
121
|
};
|
|
@@ -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";
|