@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
|
@@ -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({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/lib/hosting/framework-paths.ts
|
|
2
|
+
var FRAMEWORK_PREFIX = "/publishos", SOURCE_ASSET_PREFIX = `${FRAMEWORK_PREFIX}/assets`, INTERNAL_PREFIX = `${FRAMEWORK_PREFIX}/internal`, SITE_API_PREFIX = `${FRAMEWORK_PREFIX}/api`, SEARCH_PREFIX = `${INTERNAL_PREFIX}/search`, PAGEFIND_MODULE_URL = `${SEARCH_PREFIX}/pagefind.js`, PAGEFIND_ENTRY_URL = `${SEARCH_PREFIX}/pagefind-entry.json`, IMAGE_OPTIMIZER_PATH = `${SITE_API_PREFIX}/image`, NEXT_IMAGE_OPTIMIZER_PATH = "/_next/image", OG_SERVICE_PREFIX = `${SITE_API_PREFIX}/og`, PUBLIC_INTERNAL_DIRECTORY = INTERNAL_PREFIX.slice(1), PUBLIC_FONT_DIRECTORY = `${PUBLIC_INTERNAL_DIRECTORY}/fonts`, PUBLIC_SEARCH_DIRECTORY = `public/${PUBLIC_INTERNAL_DIRECTORY}/search`, FRAMEWORK_PROXY_MATCHER = `/((?!${FRAMEWORK_PREFIX.slice(1)}(?:/|$)|_next/static|_next/image|_next/webpack-hmr).*)`;
|
|
3
|
+
function isFrameworkNamespacePath(pathname) {
|
|
4
|
+
return pathname === FRAMEWORK_PREFIX || pathname.startsWith(`${FRAMEWORK_PREFIX}/`);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
FRAMEWORK_PREFIX,
|
|
9
|
+
SOURCE_ASSET_PREFIX,
|
|
10
|
+
INTERNAL_PREFIX,
|
|
11
|
+
IMAGE_OPTIMIZER_PATH,
|
|
12
|
+
NEXT_IMAGE_OPTIMIZER_PATH,
|
|
13
|
+
OG_SERVICE_PREFIX,
|
|
14
|
+
PUBLIC_INTERNAL_DIRECTORY,
|
|
15
|
+
PUBLIC_FONT_DIRECTORY,
|
|
16
|
+
PUBLIC_SEARCH_DIRECTORY,
|
|
17
|
+
FRAMEWORK_PROXY_MATCHER,
|
|
18
|
+
isFrameworkNamespacePath
|
|
19
|
+
};
|
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
AppError as AppError2,
|
|
3
|
+
ERROR_CODES,
|
|
4
|
+
assertPublishOsSourceBoundary
|
|
5
|
+
} from "./chunk-7NY22B5U.js";
|
|
4
6
|
import {
|
|
7
|
+
MdxIconImportError,
|
|
5
8
|
ROOT_CONTENT_GROUP_KEY,
|
|
6
9
|
ROOT_CONTENT_GROUP_TITLE,
|
|
10
|
+
UnsupportedFrontmatterLanguageError,
|
|
7
11
|
assertSourceDependency,
|
|
8
12
|
buildFaviconsAndLogos,
|
|
9
13
|
buildMediaAssets,
|
|
10
14
|
collectBindingNames,
|
|
11
15
|
groupedMdxExports,
|
|
12
16
|
joinUrlPath,
|
|
13
|
-
localCssImports,
|
|
14
17
|
mdxComponentExportName,
|
|
15
18
|
namedValueExports,
|
|
16
19
|
normalizeSlugPath,
|
|
17
20
|
normalizeUrlPath,
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
originalDefaultComponentSourcePath,
|
|
22
|
+
parseSourceFrontmatter,
|
|
23
|
+
replacedMdxSourceFiles,
|
|
24
|
+
supportedNextjsSourceImports,
|
|
25
|
+
validateMdxIconImports
|
|
26
|
+
} from "./chunk-UYGCOWRF.js";
|
|
20
27
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
isFrameworkNamespacePath
|
|
29
|
+
} from "./chunk-EFO6AWXN.js";
|
|
30
|
+
import {
|
|
31
|
+
localCssImports
|
|
32
|
+
} from "./chunk-5KAD7W53.js";
|
|
25
33
|
import {
|
|
26
34
|
isApprovedPublishOsPath,
|
|
27
35
|
isExcludedSourcePath,
|
|
28
|
-
isFrameworkNamespacePath,
|
|
29
36
|
isReservedFrameworkPath,
|
|
30
37
|
isSameOrDescendant
|
|
31
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-WL75GQ5M.js";
|
|
32
39
|
import {
|
|
33
40
|
runtimePackageVersion
|
|
34
41
|
} from "./chunk-AI2UULNX.js";
|
|
35
42
|
import {
|
|
36
|
-
AppError,
|
|
37
43
|
readInstalledFrameworkLocation
|
|
38
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-5J3YUNRY.js";
|
|
45
|
+
import {
|
|
46
|
+
AppError
|
|
47
|
+
} from "./chunk-22RSSUNV.js";
|
|
39
48
|
|
|
40
49
|
// src/lib/compiler/validation/validate-publish-os-source.ts
|
|
41
50
|
import { readdir as readdir3, readFile as readFile5, stat as stat3 } from "fs/promises";
|
|
@@ -88,9 +97,15 @@ import { resolve } from "path";
|
|
|
88
97
|
function issueMessages(issue) {
|
|
89
98
|
return issue.code === "invalid_union" ? issue.unionErrors.flatMap(
|
|
90
99
|
(error) => error.issues.flatMap(issueMessages)
|
|
91
|
-
) : issue.code === "unrecognized_keys" ? issue.keys.map(
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
) : issue.code === "unrecognized_keys" ? issue.keys.map((key) => {
|
|
101
|
+
let path = [...issue.path, key].join(".");
|
|
102
|
+
return issue.path.join(".") === "media.assets" && [
|
|
103
|
+
"maxImageBytes",
|
|
104
|
+
"maxVideoBytes",
|
|
105
|
+
"maxTotalBytes",
|
|
106
|
+
"maxFileCount"
|
|
107
|
+
].includes(key) ? `${path}: Media limits are fixed by PublishOS. Remove this field.` : `${path}: Unknown field.`;
|
|
108
|
+
}) : [`${issue.path.join(".") || "(root)"}: ${issue.message}`];
|
|
94
109
|
}
|
|
95
110
|
function formatConfigIssues(error) {
|
|
96
111
|
return [...new Set(error.issues.flatMap(issueMessages))].join(`
|
|
@@ -158,7 +173,10 @@ var treeNodeSchema = z3.lazy(
|
|
|
158
173
|
scope: outputScopeSchema.optional(),
|
|
159
174
|
description: z3.string().optional(),
|
|
160
175
|
limit: z3.number().int().positive().optional()
|
|
161
|
-
}).strict(),
|
|
176
|
+
}).strict(), sitemapOutputSchema = outputDeclarationSchema.extend({
|
|
177
|
+
path: z3.string().min(1).optional(),
|
|
178
|
+
mode: z3.enum(["index", "urls"]).optional()
|
|
179
|
+
}), outputDefaultsDeclarationSchema = z3.object({
|
|
162
180
|
scope: outputScopeSchema.optional(),
|
|
163
181
|
limit: z3.number().int().positive().optional(),
|
|
164
182
|
status: z3.array(outputStatusSchema).optional(),
|
|
@@ -172,10 +190,12 @@ var treeNodeSchema = z3.lazy(
|
|
|
172
190
|
atom: outputDefaultsDeclarationSchema.optional(),
|
|
173
191
|
json: outputDefaultsDeclarationSchema.optional()
|
|
174
192
|
}).strict(), outputsSchema = z3.object({
|
|
175
|
-
llms: outputDeclarationSchema.optional(),
|
|
193
|
+
llms: outputDeclarationSchema.or(z3.literal(!1)).optional(),
|
|
194
|
+
llmsFull: outputDeclarationSchema.or(z3.literal(!1)).optional(),
|
|
176
195
|
feeds: feedsOutputSchema.optional(),
|
|
177
|
-
robots: outputDeclarationSchema.optional(),
|
|
178
|
-
sitemap:
|
|
196
|
+
robots: outputDeclarationSchema.or(z3.literal(!1)).optional(),
|
|
197
|
+
sitemap: sitemapOutputSchema.or(z3.literal(!1)).optional(),
|
|
198
|
+
sitemapMarkdown: outputDeclarationSchema.or(z3.literal(!1)).optional()
|
|
179
199
|
}).strict(), outputDefaultsSchema = z3.object({
|
|
180
200
|
llms: outputDefaultsDeclarationSchema.optional(),
|
|
181
201
|
feeds: feedsOutputDefaultsSchema.optional()
|
|
@@ -267,31 +287,8 @@ var siteSchema = z4.object({
|
|
|
267
287
|
}), rootThemeSchema = z4.object({
|
|
268
288
|
defaultMode: z4.enum(["system", "light", "dark"]).optional(),
|
|
269
289
|
forcedMode: z4.enum(["light", "dark"]).optional()
|
|
270
|
-
}).strict(), remoteMediaSourceSchema = z4.object({
|
|
271
|
-
protocol: z4.literal("https"),
|
|
272
|
-
hostname: z4.string().min(1),
|
|
273
|
-
pathname: z4.string().optional()
|
|
274
|
-
}).strict(), remoteEmbedSourceSchema = z4.object({
|
|
275
|
-
provider: z4.enum([
|
|
276
|
-
"youtube",
|
|
277
|
-
"vimeo",
|
|
278
|
-
"loom",
|
|
279
|
-
"wistia",
|
|
280
|
-
"cloudflare-stream"
|
|
281
|
-
]),
|
|
282
|
-
hostname: z4.string().min(1)
|
|
283
290
|
}).strict(), mediaConfigSchema = z4.object({
|
|
284
|
-
assets: z4.object({
|
|
285
|
-
maxImageBytes: z4.number().int().positive().optional(),
|
|
286
|
-
maxVideoBytes: z4.number().int().positive().optional(),
|
|
287
|
-
maxTotalBytes: z4.number().int().positive().optional(),
|
|
288
|
-
maxFileCount: z4.number().int().positive().optional()
|
|
289
|
-
}).strict().optional(),
|
|
290
|
-
remote: z4.object({
|
|
291
|
-
images: z4.array(remoteMediaSourceSchema).optional(),
|
|
292
|
-
videos: z4.array(remoteMediaSourceSchema).optional(),
|
|
293
|
-
embeds: z4.array(remoteEmbedSourceSchema).optional()
|
|
294
|
-
}).strict().optional()
|
|
291
|
+
assets: z4.object({}).strict().optional()
|
|
295
292
|
}).strict(), agentConfigSchema = z4.object({
|
|
296
293
|
enabled: z4.boolean().optional(),
|
|
297
294
|
markdownRoutes: z4.boolean().optional(),
|
|
@@ -802,7 +799,6 @@ async function resolvePublishOsConfig(baseDir) {
|
|
|
802
799
|
// src/lib/compiler/source/content/scan-publish-os-content.ts
|
|
803
800
|
import { readdir as readdir2, readFile as readFile3, stat as stat2 } from "fs/promises";
|
|
804
801
|
import { extname, join as join2, relative as relative2 } from "path";
|
|
805
|
-
import matter from "gray-matter";
|
|
806
802
|
var RESERVED_FIELDS = /* @__PURE__ */ new Set([
|
|
807
803
|
"title",
|
|
808
804
|
"slug",
|
|
@@ -1008,7 +1004,7 @@ function customMeta(frontmatter, absolutePath) {
|
|
|
1008
1004
|
async function readContentFile(group, absolutePath, configSlugs) {
|
|
1009
1005
|
let raw = await readFile3(absolutePath, "utf-8");
|
|
1010
1006
|
try {
|
|
1011
|
-
let parsed =
|
|
1007
|
+
let parsed = parseSourceFrontmatter(raw), frontmatter = parsed.data, relativePath = relative2(group.contentPath, absolutePath), fileID = normalizeContentSlug(fileSlug(relativePath), absolutePath), title = asString(frontmatter.title);
|
|
1012
1008
|
if (frontmatter.id !== void 0)
|
|
1013
1009
|
throw new AppError2({
|
|
1014
1010
|
code: ERROR_CODES.CONTENT_FRONTMATTER_ID_INVALID,
|
|
@@ -1102,7 +1098,11 @@ async function readContentFile(group, absolutePath, configSlugs) {
|
|
|
1102
1098
|
warnings
|
|
1103
1099
|
};
|
|
1104
1100
|
} catch (error) {
|
|
1105
|
-
throw error instanceof AppError2 ? error : new AppError2({
|
|
1101
|
+
throw error instanceof AppError2 ? error : error instanceof UnsupportedFrontmatterLanguageError ? new AppError2({
|
|
1102
|
+
code: ERROR_CODES.CONTENT_FRONTMATTER_LANGUAGE_UNSUPPORTED,
|
|
1103
|
+
message: `Unsupported frontmatter language "${error.language}" for ${absolutePath}. Use YAML or JSON.`,
|
|
1104
|
+
details: { path: absolutePath, language: error.language }
|
|
1105
|
+
}) : new AppError2({
|
|
1106
1106
|
code: ERROR_CODES.CONTENT_FILE_PARSE_FAILED,
|
|
1107
1107
|
message: `Failed to parse frontmatter for ${absolutePath}`,
|
|
1108
1108
|
details: { error }
|
|
@@ -1475,7 +1475,9 @@ async function preparePublishOsSource({
|
|
|
1475
1475
|
), config = await resolvePublishOsConfig(sourceRoot), content = await scanContent(config), media = await buildMediaAssets({
|
|
1476
1476
|
config,
|
|
1477
1477
|
publishOsDir
|
|
1478
|
-
}), faviconsAndLogos =
|
|
1478
|
+
}), faviconsAndLogos = buildFaviconsAndLogos({
|
|
1479
|
+
media
|
|
1480
|
+
}), missingPages = await missingPageReferences({
|
|
1479
1481
|
sourceRoot,
|
|
1480
1482
|
config,
|
|
1481
1483
|
content
|
|
@@ -1490,13 +1492,10 @@ async function preparePublishOsSource({
|
|
|
1490
1492
|
})),
|
|
1491
1493
|
...content.warnings,
|
|
1492
1494
|
...missingPages,
|
|
1495
|
+
...faviconsAndLogos.warnings,
|
|
1493
1496
|
...media.warnings.map((warning2) => ({
|
|
1494
1497
|
...warning2,
|
|
1495
1498
|
level: "warning"
|
|
1496
|
-
})),
|
|
1497
|
-
...faviconsAndLogos.warnings.map((warning2) => ({
|
|
1498
|
-
...warning2,
|
|
1499
|
-
level: "warning"
|
|
1500
1499
|
}))
|
|
1501
1500
|
],
|
|
1502
1501
|
source: {
|
|
@@ -1704,6 +1703,10 @@ function isAllowedBareImport(specifier) {
|
|
|
1704
1703
|
}
|
|
1705
1704
|
return ALLOWED_BARE_IMPORTS.has(specifier);
|
|
1706
1705
|
}
|
|
1706
|
+
function isOriginalDefaultComponentBridge(options) {
|
|
1707
|
+
let sourcePath = originalDefaultComponentSourcePath(options.specifier);
|
|
1708
|
+
return sourcePath ? options.relativeFile.replace(/\.[^.]+$/, "") === sourcePath : !1;
|
|
1709
|
+
}
|
|
1707
1710
|
function addFileError(store, code, message, file, details = {}) {
|
|
1708
1711
|
store.error(code, message, { ...details, file });
|
|
1709
1712
|
}
|
|
@@ -2075,7 +2078,7 @@ function validateLegacyIconReferences(source, file, store) {
|
|
|
2075
2078
|
match && addFileError(
|
|
2076
2079
|
store,
|
|
2077
2080
|
"FRAMEWORK_ICON_RESOLVER_REJECTED",
|
|
2078
|
-
'The Icon resolver is removed. Import an exact component from "@phosphor-icons/react/ssr" in
|
|
2081
|
+
'The Icon resolver is removed. Import an exact named component from "@phosphor-icons/react/ssr" in MDX or TSX instead.',
|
|
2079
2082
|
file,
|
|
2080
2083
|
sourceDetails(source, match.index, match[0] ?? "")
|
|
2081
2084
|
);
|
|
@@ -2115,7 +2118,23 @@ async function validateSourceFileContents({
|
|
|
2115
2118
|
filePath: absolutePath,
|
|
2116
2119
|
css: source,
|
|
2117
2120
|
checked: checkedCss
|
|
2118
|
-
}))
|
|
2121
|
+
}));
|
|
2122
|
+
let importsIconBinding = !1;
|
|
2123
|
+
if (extension === ".mdx" && !file.startsWith("assets/"))
|
|
2124
|
+
try {
|
|
2125
|
+
importsIconBinding = (await validateMdxIconImports(source)).some(({ local }) => local === "Icon");
|
|
2126
|
+
} catch (error) {
|
|
2127
|
+
let line = error instanceof MdxIconImportError ? error.line : 1, column = error instanceof MdxIconImportError ? error.column : 1;
|
|
2128
|
+
addFileError(
|
|
2129
|
+
store,
|
|
2130
|
+
error instanceof MdxIconImportError ? error.code : "FRAMEWORK_MDX_IMPORT_INVALID",
|
|
2131
|
+
error instanceof Error ? error.message : String(error),
|
|
2132
|
+
file,
|
|
2133
|
+
{ line, column, sourceLine: source.split(`
|
|
2134
|
+
`)[line - 1] ?? "" }
|
|
2135
|
+
);
|
|
2136
|
+
}
|
|
2137
|
+
scansLegacyIcons && !importsIconBinding && validateLegacyIconReferences(source, file, store), sourceModule && (validateSourceModuleSafety(source, file, store), await validateSourceModule({
|
|
2119
2138
|
absolutePath,
|
|
2120
2139
|
groupFolders,
|
|
2121
2140
|
publishOsDir,
|
|
@@ -2140,18 +2159,32 @@ async function validateSourceBoundary(publishOsDir, config, store) {
|
|
|
2140
2159
|
"package.json"
|
|
2141
2160
|
);
|
|
2142
2161
|
for (let file of await walkAllFiles(publishOsDir))
|
|
2143
|
-
validateSourceFilePath({ file, groupFolders, store }) &&
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2162
|
+
if (validateSourceFilePath({ file, groupFolders, store }) && !validateSourceFontFile({ file, configuredFontSourcePaths, store })) {
|
|
2163
|
+
if (!isApprovedPublishOsPath(file, groupFolders))
|
|
2164
|
+
if (file.startsWith("public/")) {
|
|
2165
|
+
let assetPath = file.slice(7);
|
|
2166
|
+
addFileWarning(
|
|
2167
|
+
store,
|
|
2168
|
+
"FRAMEWORK_SOURCE_PUBLIC_UNSUPPORTED",
|
|
2169
|
+
`Files in publish.os/public are not included. Move this file to publish.os/assets/${assetPath} and reference it as /assets/${assetPath}.`,
|
|
2170
|
+
file,
|
|
2171
|
+
{ correction: `assets/${assetPath}` }
|
|
2172
|
+
);
|
|
2173
|
+
} else
|
|
2174
|
+
addFileWarning(
|
|
2175
|
+
store,
|
|
2176
|
+
"FRAMEWORK_SOURCE_PATH_IGNORED",
|
|
2177
|
+
"This file is outside the supported publish.os structure and will not be included in the site.",
|
|
2178
|
+
file
|
|
2179
|
+
);
|
|
2180
|
+
await validateSourceFileContents({
|
|
2181
|
+
publishOsDir,
|
|
2182
|
+
file,
|
|
2183
|
+
groupFolders,
|
|
2184
|
+
checkedCss,
|
|
2185
|
+
store
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2155
2188
|
}
|
|
2156
2189
|
async function validateCssDependencies({
|
|
2157
2190
|
publishOsDir,
|
|
@@ -2296,7 +2329,7 @@ async function validateImportSpecifier(options) {
|
|
|
2296
2329
|
);
|
|
2297
2330
|
return;
|
|
2298
2331
|
}
|
|
2299
|
-
isAllowedBareImport(options.specifier)
|
|
2332
|
+
!isAllowedBareImport(options.specifier) && !isOriginalDefaultComponentBridge(options) && addFileError(
|
|
2300
2333
|
options.store,
|
|
2301
2334
|
"FRAMEWORK_IMPORT_NOT_ALLOWED",
|
|
2302
2335
|
`Can't import from "${options.specifier}". Source modules can only import approved runtime packages.`,
|