@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.
Files changed (223) hide show
  1. package/compiler-assets/nextjs/defaults/group/layout.tsx +1 -5
  2. package/compiler-assets/nextjs/defaults/group/page.tsx +31 -22
  3. package/compiler-assets/nextjs/defaults/project/next.config.mjs +19 -10
  4. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
  5. package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
  6. package/compiler-assets/nextjs/shims/document.tsx +38 -0
  7. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +2 -0
  8. package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
  9. package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
  10. package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
  11. package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
  12. package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
  13. package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
  14. package/compiler-assets/nextjs/shims/proxy.ts +126 -60
  15. package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
  16. package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
  17. package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
  18. package/dist/{build-operation-2JAYBSKF.js → build-operation-5QMLXF7N.js} +29 -23
  19. package/dist/{button-c3WGnxIj.d.ts → button-BdCScEKi.d.ts} +3 -3
  20. package/dist/capture-local-source-WGGDIUU2.js +258 -0
  21. package/dist/chunk-22RSSUNV.js +13 -0
  22. package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
  23. package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
  24. package/dist/chunk-5KAD7W53.js +248 -0
  25. package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
  26. package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
  27. package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
  28. package/dist/chunk-EFO6AWXN.js +19 -0
  29. package/dist/{chunk-726GV2NF.js → chunk-F3AGNDF4.js} +100 -67
  30. package/dist/chunk-GBPLER5H.js +426 -0
  31. package/dist/chunk-IL4RJOKI.js +186 -0
  32. package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
  33. package/dist/{chunk-VO2I7MTM.js → chunk-ORIUWJBQ.js} +8 -6
  34. package/dist/{chunk-H6XILMZX.js → chunk-OXOFRXEI.js} +1806 -831
  35. package/dist/chunk-UYGCOWRF.js +1709 -0
  36. package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
  37. package/dist/compiler.d.ts +15 -2
  38. package/dist/compiler.js +90 -21
  39. package/dist/components/blocks/agent-actions.d.ts +81 -0
  40. package/dist/components/blocks/agent-actions.js +594 -0
  41. package/dist/components/blocks/toc.d.ts +43 -0
  42. package/dist/components/blocks/toc.js +136 -0
  43. package/dist/components/ui/button.d.ts +5 -0
  44. package/dist/components/ui/button.js +94 -0
  45. package/dist/compose-CVBJRAF6.js +16 -0
  46. package/dist/config/createNextConfig.js +17 -3
  47. package/dist/{dev-operation-TZDVJCN7.js → dev-operation-OSHHWRWK.js} +121 -81
  48. package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
  49. package/dist/ide-support-CU6Z5PVR.js +16 -0
  50. package/dist/index.d.ts +40 -1
  51. package/dist/jsx-dev-runtime.d.ts +6 -0
  52. package/dist/jsx-dev-runtime.js +100 -0
  53. package/dist/jsx-runtime.d.ts +7 -0
  54. package/dist/jsx-runtime.js +97 -0
  55. package/dist/kernel/components/blocks/AgentActions.d.ts +35 -6
  56. package/dist/kernel/components/blocks/AgentActions.js +383 -142
  57. package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
  58. package/dist/kernel/components/blocks/agent-actions.js +594 -0
  59. package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
  60. package/dist/kernel/components/blocks/color-palette.js +4 -4
  61. package/dist/kernel/components/blocks/logo-block.js +1 -1
  62. package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -2
  63. package/dist/kernel/components/blocks/navbar.js +17 -17
  64. package/dist/kernel/components/blocks/navigation-progress.js +2 -2
  65. package/dist/kernel/components/blocks/next-prev.js +1 -1
  66. package/dist/kernel/components/blocks/page-list.js +2 -2
  67. package/dist/kernel/components/blocks/search.d.ts +1 -1
  68. package/dist/kernel/components/blocks/search.js +16 -17
  69. package/dist/kernel/components/blocks/sidebar-node.js +1 -1
  70. package/dist/kernel/components/blocks/sidebar.js +7 -4
  71. package/dist/kernel/components/blocks/theme-toggle.d.ts +1 -1
  72. package/dist/kernel/components/blocks/theme-toggle.js +5 -5
  73. package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
  74. package/dist/kernel/components/blocks/toc-client.js +495 -0
  75. package/dist/kernel/components/blocks/toc.d.ts +19 -1
  76. package/dist/kernel/components/blocks/toc.js +121 -179
  77. package/dist/kernel/components/mdx/components/blockquote.js +1 -1
  78. package/dist/kernel/components/mdx/components/callout.js +1 -1
  79. package/dist/kernel/components/mdx/components/code-block.js +2 -2
  80. package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
  81. package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
  82. package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
  83. package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
  84. package/dist/kernel/components/mdx/components/figure.js +23 -13
  85. package/dist/kernel/components/mdx/components/footnotes.js +1 -1
  86. package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
  87. package/dist/kernel/components/mdx/components/heading.js +6 -3
  88. package/dist/kernel/components/mdx/components/hr.js +2 -2
  89. package/dist/kernel/components/mdx/components/image-zoom.js +1 -1
  90. package/dist/kernel/components/mdx/components/image.d.ts +1 -1
  91. package/dist/kernel/components/mdx/components/image.js +21 -16
  92. package/dist/kernel/components/mdx/components/inline-code.js +1 -1
  93. package/dist/kernel/components/mdx/components/kbd.js +2 -2
  94. package/dist/kernel/components/mdx/components/link.d.ts +3 -3
  95. package/dist/kernel/components/mdx/components/link.js +2 -2
  96. package/dist/kernel/components/mdx/components/paragraph.js +1 -1
  97. package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
  98. package/dist/kernel/components/mdx/components/table.js +2 -2
  99. package/dist/kernel/components/mdx/components/task-list.js +1 -1
  100. package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
  101. package/dist/kernel/components/mdx/components/video-player.js +6 -2
  102. package/dist/kernel/components/mdx/components/video.d.ts +5 -3
  103. package/dist/kernel/components/mdx/components/video.js +7 -5
  104. package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
  105. package/dist/kernel/components/mdx/error-boundary.js +2 -2
  106. package/dist/kernel/components/mdx/error-fallback.js +1 -1
  107. package/dist/kernel/components/mdx/mdx.d.ts +20 -10
  108. package/dist/kernel/components/mdx/mdx.js +231 -34
  109. package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
  110. package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
  111. package/dist/kernel/components/mdx/types.d.ts +1 -1
  112. package/dist/kernel/components/next-image.d.ts +12 -0
  113. package/dist/kernel/components/next-image.js +61 -0
  114. package/dist/kernel/components/ui/accordion.js +1 -1
  115. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +2 -2
  116. package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
  117. package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
  118. package/dist/kernel/components/ui/breadcrumb.js +4 -4
  119. package/dist/kernel/components/ui/button-group.d.ts +1 -1
  120. package/dist/kernel/components/ui/button-group.js +3 -3
  121. package/dist/kernel/components/ui/button.d.ts +56 -4
  122. package/dist/kernel/components/ui/button.js +43 -39
  123. package/dist/kernel/components/ui/card.js +1 -1
  124. package/dist/kernel/components/ui/dialog.js +1 -1
  125. package/dist/kernel/components/ui/drawer.js +1 -1
  126. package/dist/kernel/components/ui/input.d.ts +2 -2
  127. package/dist/kernel/components/ui/input.js +1 -1
  128. package/dist/kernel/components/ui/kbd.d.ts +1 -1
  129. package/dist/kernel/components/ui/kbd.js +1 -1
  130. package/dist/kernel/components/ui/link.d.ts +8 -2
  131. package/dist/kernel/components/ui/link.js +2 -2
  132. package/dist/kernel/components/ui/menu.js +1 -1
  133. package/dist/kernel/components/ui/mod-key.js +2 -2
  134. package/dist/kernel/components/ui/navigation-menu.js +1 -1
  135. package/dist/kernel/components/ui/popover.js +1 -1
  136. package/dist/kernel/components/ui/progress.js +1 -1
  137. package/dist/kernel/components/ui/scroll-area.d.ts +8 -8
  138. package/dist/kernel/components/ui/scroll-area.js +1 -1
  139. package/dist/kernel/components/ui/select.js +1 -1
  140. package/dist/kernel/components/ui/separator.js +1 -1
  141. package/dist/kernel/components/ui/table.js +1 -1
  142. package/dist/kernel/components/ui/tabs.js +1 -1
  143. package/dist/kernel/components/ui/tag.js +1 -1
  144. package/dist/kernel/components/ui/text.d.ts +1 -1
  145. package/dist/kernel/components/ui/text.js +1 -1
  146. package/dist/kernel/components/ui/toast.js +1 -1
  147. package/dist/kernel/components/ui/tooltip.js +1 -1
  148. package/dist/kernel/defaults.registry.d.ts +2 -15
  149. package/dist/kernel/defaults.registry.js +2 -17
  150. package/dist/kernel/routes/agent/markdown.d.ts +3 -0
  151. package/dist/kernel/routes/agent/markdown.js +219 -48
  152. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  153. package/dist/kernel/routes/layouts/group.js +5 -7
  154. package/dist/kernel/routes/metadata/feed.d.ts +1 -1
  155. package/dist/kernel/routes/metadata/feed.js +109 -83
  156. package/dist/kernel/routes/metadata/llms.d.ts +11 -3
  157. package/dist/kernel/routes/metadata/llms.js +154 -57
  158. package/dist/kernel/routes/metadata/og-image.js +1 -1
  159. package/dist/kernel/routes/metadata/robots.d.ts +1 -1
  160. package/dist/kernel/routes/metadata/sitemap.d.ts +22 -3
  161. package/dist/kernel/routes/metadata/sitemap.js +183 -43
  162. package/dist/kernel/routes/not-found.d.ts +34 -0
  163. package/dist/kernel/routes/not-found.js +213 -0
  164. package/dist/kernel/routes/pages/group.d.ts +2 -2
  165. package/dist/kernel/routes/pages/group.js +1 -1
  166. package/dist/kernel/routes/pages/leaf.d.ts +30 -3
  167. package/dist/kernel/routes/pages/leaf.js +5 -4
  168. package/dist/kernel/routes/pages/root.d.ts +2 -2
  169. package/dist/kernel/routes/pages/root.js +1 -1
  170. package/dist/keyboard-shortcuts.js +1 -1
  171. package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
  172. package/dist/search.js +7 -9
  173. package/dist/theme-scope.js +1 -1
  174. package/dist/{types-BzkZty3r.d.ts → types-J2w_puPF.d.ts} +1 -20
  175. package/dist/types-sM2g9nW0.d.ts +12 -0
  176. package/dist/types.d.ts +1 -0
  177. package/dist/utils/heading-ids.js +30 -11
  178. package/dist/utils/toc-selection.d.ts +7 -0
  179. package/dist/utils/toc-selection.js +14 -0
  180. package/dist/validate-local-source-SV44DBQT.js +16 -0
  181. package/dist/validate-publish-os-source-NZJF3TB2.js +14 -0
  182. package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
  183. package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
  184. package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
  185. package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
  186. package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
  187. package/init/seed/minimal/publish.os/blog/index.tsx +82 -0
  188. package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
  189. package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
  190. package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
  191. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
  192. package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
  193. package/init/seed/minimal/publish.os/publish.os.config.json +6 -2
  194. package/init/seed/minimal/publish.os/theme.css +3 -3
  195. package/init/seed/minimal/seed.json +11 -4
  196. package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
  197. package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
  198. package/package.json +45 -20
  199. package/release/app/phosphor/package.json +3 -3
  200. package/release/app/phosphor/pnpm-lock.yaml.template +88 -75
  201. package/release/compiler/package.json +5 -3
  202. package/release/compiler/pnpm-lock.yaml.template +118 -74
  203. package/release/release.json +6 -6
  204. package/dist/button-CtzUJB8u.d.ts +0 -11
  205. package/dist/chunk-535TM4A5.js +0 -1455
  206. package/dist/chunk-B2V22WRT.js +0 -297
  207. package/dist/chunk-NECL5IBJ.js +0 -318
  208. package/dist/chunk-SVYGXXYR.js +0 -36
  209. package/dist/chunk-UF6ATARM.js +0 -1100
  210. package/dist/compose-NN23UJGC.js +0 -13
  211. package/dist/ide-support-ZNW7ODFY.js +0 -15
  212. package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
  213. package/dist/kernel/components/blocks/design-system-preview.js +0 -667
  214. package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
  215. package/dist/kernel/components/blocks/link-playground.js +0 -744
  216. package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
  217. package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
  218. package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
  219. package/dist/kernel/components/ui/theme-toggle.js +0 -53
  220. package/dist/validate-local-source-XRL2Y7XE.js +0 -14
  221. package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
  222. package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
  223. package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
@@ -0,0 +1,426 @@
1
+ import {
2
+ acquireOperationLock,
3
+ ensureLocalOutputRoot,
4
+ publishOwnedDirectory
5
+ } from "./chunk-6D2E6UMD.js";
6
+ import {
7
+ createIdeSourceArtifacts
8
+ } from "./chunk-OXOFRXEI.js";
9
+ import {
10
+ assertFrameworkSelection,
11
+ readCheckoutTypeScriptConfig
12
+ } from "./chunk-NNBJZPFM.js";
13
+ import {
14
+ supportedNextjsSourceImports
15
+ } from "./chunk-UYGCOWRF.js";
16
+ import {
17
+ runtimePackageVersion
18
+ } from "./chunk-AI2UULNX.js";
19
+ import {
20
+ AppError
21
+ } from "./chunk-22RSSUNV.js";
22
+
23
+ // src/lib/compiler/ide/ide-support.ts
24
+ import { constants, existsSync } from "fs";
25
+ import {
26
+ lstat,
27
+ mkdir,
28
+ open,
29
+ readdir,
30
+ readFile,
31
+ realpath,
32
+ writeFile
33
+ } from "fs/promises";
34
+ import { createRequire } from "module";
35
+ import { dirname, join, resolve } from "path";
36
+ function errorCauses(error) {
37
+ return [
38
+ ...error instanceof AggregateError ? error.errors : [],
39
+ ...error.cause === void 0 ? [] : [error.cause]
40
+ ];
41
+ }
42
+ function errorMessage(error, seen = /* @__PURE__ */ new Set()) {
43
+ if (seen.has(error)) return "";
44
+ if (seen.add(error), !(error instanceof Error)) return String(error);
45
+ let causes = errorCauses(error).map((cause) => errorMessage(cause, seen)).filter(Boolean);
46
+ return causes.length ? `${error.message}: ${causes.join("; ")}` : error.message;
47
+ }
48
+ function findRequiredFailure(error, seen = /* @__PURE__ */ new Set()) {
49
+ if (!(!(error instanceof Error) || seen.has(error))) {
50
+ if (seen.add(error), error instanceof AppError && ["FRAMEWORK_SOURCE_PIN_MISMATCH", "IDE_FRAMEWORK_PIN_MISMATCH"].includes(
51
+ error.code
52
+ ) || error.name === "AbortError")
53
+ return error;
54
+ for (let cause of errorCauses(error)) {
55
+ let required = findRequiredFailure(cause, seen);
56
+ if (required) return required;
57
+ }
58
+ }
59
+ }
60
+ function emitWarning(options, message) {
61
+ options.onEvent?.({
62
+ type: "diagnostics",
63
+ diagnostics: {
64
+ diagnostics: [
65
+ {
66
+ code: "IDE_INTEGRATION_REQUIRED",
67
+ severity: "warning",
68
+ message
69
+ }
70
+ ]
71
+ }
72
+ });
73
+ }
74
+ function sourceRootConfigPath(publishOsDir) {
75
+ return join(publishOsDir, "tsconfig.json");
76
+ }
77
+ function editorIntegrationIssue(source, typescript) {
78
+ if (!source) return "no authored tsconfig.json exists";
79
+ let parsed = typescript.parseConfigFileTextToJson(
80
+ "publish.os/tsconfig.json",
81
+ source
82
+ );
83
+ if (parsed.error || !parsed.config)
84
+ return "the authored tsconfig.json is invalid";
85
+ let config = parsed.config;
86
+ if (!(Array.isArray(config.extends) ? config.extends : [config.extends]).some(
87
+ (base) => typeof base == "string" && [
88
+ "./.publish.os/ide/tsconfig",
89
+ "./.publish.os/ide/tsconfig.json"
90
+ ].includes(base)
91
+ ))
92
+ return "the authored tsconfig.json does not extend the generated IDE config";
93
+ let overridden = [
94
+ ...["baseUrl", "paths"].filter(
95
+ (key) => Object.hasOwn(config.compilerOptions ?? {}, key)
96
+ ),
97
+ ...["files", "include", "exclude"].filter(
98
+ (key) => Object.hasOwn(config, key)
99
+ )
100
+ ];
101
+ return overridden.length ? `the authored tsconfig.json overrides generated ${overridden.join(", ")}` : void 0;
102
+ }
103
+ function typescriptApi(framework) {
104
+ try {
105
+ return createRequire(
106
+ join(framework.packageRoot, "package.json")
107
+ )("typescript");
108
+ } catch (cause) {
109
+ throw new AppError({
110
+ code: "IDE_TYPESCRIPT_UNAVAILABLE",
111
+ message: "The selected framework installation does not include TypeScript.",
112
+ fix: "Install or repair the selected framework, then run the command again. The site operation will continue without IDE support.",
113
+ details: { cause }
114
+ });
115
+ }
116
+ }
117
+ function packageTypePath(options) {
118
+ let resolved = options.typescript.resolveModuleName(
119
+ options.specifier,
120
+ join(options.framework.packageRoot, "__publishos_ide_check__.tsx"),
121
+ {
122
+ module: options.typescript.ModuleKind.ESNext,
123
+ moduleResolution: options.typescript.ModuleResolutionKind.Bundler,
124
+ preserveSymlinks: !0
125
+ },
126
+ options.typescript.sys
127
+ ).resolvedModule?.resolvedFileName, declared = resolved?.replace(/\.mjs$/u, ".d.mts").replace(/\.cjs$/u, ".d.cts").replace(/\.js$/u, ".d.ts"), path = resolved && /\.d\.[cm]?ts$/u.test(resolved) ? resolved : declared && existsSync(declared) ? declared : void 0;
128
+ if (!path)
129
+ throw new AppError({
130
+ code: "IDE_DECLARATION_UNAVAILABLE",
131
+ message: `The selected framework installation does not provide declarations for ${options.specifier}${resolved ? ` (resolved to ${resolved})` : ""}.`,
132
+ fix: "Repair or update the selected framework installation. The site operation will continue without IDE support."
133
+ });
134
+ return path;
135
+ }
136
+ async function editorPaths(options) {
137
+ let typescript = typescriptApi(options.framework), checkout = options.checkoutRoot ? await readCheckoutTypeScriptConfig({
138
+ packageRoot: options.checkoutRoot
139
+ }) : void 0, paths = {};
140
+ for (let specifier of [
141
+ ...supportedNextjsSourceImports(),
142
+ "react/jsx-runtime"
143
+ ]) {
144
+ let checkoutPath = checkout?.paths[specifier]?.[0];
145
+ paths[specifier] = [
146
+ checkoutPath ? resolve(
147
+ options.checkoutRoot ?? options.framework.packageRoot,
148
+ checkoutPath
149
+ ) : packageTypePath({
150
+ framework: options.framework,
151
+ typescript,
152
+ specifier
153
+ })
154
+ ];
155
+ }
156
+ if (checkout && options.checkoutRoot) {
157
+ let checkoutRoot = options.checkoutRoot;
158
+ paths["@/*"] = [join(checkoutRoot, "src", "*")];
159
+ for (let [specifier, sources] of Object.entries(checkout.paths))
160
+ specifier.startsWith("@components/") && (paths[specifier] = [
161
+ join(options.publishOsDir, "components", specifier.slice(12)),
162
+ ...sources.map((source) => join(checkoutRoot, source))
163
+ ]);
164
+ }
165
+ return paths["@components/*"] = [
166
+ join(options.publishOsDir, "components", "*"),
167
+ join(options.framework.packageRoot, "dist/kernel/components", "*")
168
+ ], paths["@source/*"] = [
169
+ join(options.publishOsDir, "*"),
170
+ join(options.publishOsDir, ".publish.os/ide/source", "*")
171
+ ], paths;
172
+ }
173
+ async function ideTsconfig(options) {
174
+ let { framework, finalPublishOsDir } = options, resolveFromFramework = createRequire(
175
+ join(framework.packageRoot, "package.json")
176
+ ), types = ["node", "react", "react-dom"], typeRoots = [
177
+ ...new Set(
178
+ types.map((name) => {
179
+ let manifest = resolveFromFramework.resolve(
180
+ `@types/${name}/package.json`
181
+ );
182
+ return dirname(dirname(manifest));
183
+ })
184
+ )
185
+ ], config = {
186
+ compilerOptions: {
187
+ allowJs: !0,
188
+ baseUrl: finalPublishOsDir,
189
+ esModuleInterop: !0,
190
+ isolatedModules: !0,
191
+ jsx: "react-jsx",
192
+ jsxImportSource: "@publish.os/nextjs",
193
+ lib: ["dom", "dom.iterable", "esnext"],
194
+ module: "esnext",
195
+ moduleResolution: "bundler",
196
+ noEmit: !0,
197
+ paths: await editorPaths({
198
+ framework,
199
+ publishOsDir: finalPublishOsDir,
200
+ checkoutRoot: options.checkoutRoot
201
+ }),
202
+ resolveJsonModule: !0,
203
+ strict: !0,
204
+ target: "ES2022",
205
+ typeRoots,
206
+ types
207
+ },
208
+ exclude: [join(finalPublishOsDir, ".publish.os", "**/*")],
209
+ include: [join(finalPublishOsDir, "**/*")],
210
+ // The config lives inside generated state, but TypeScript resolves bare
211
+ // packages from the exact selected framework installation.
212
+ typeAcquisition: { enable: !1 }
213
+ };
214
+ return `${JSON.stringify(config, null, 2)}
215
+ `;
216
+ }
217
+ function assertExactRuntime(source, framework) {
218
+ if (runtimePackageVersion(source.config.runtime) !== framework.version)
219
+ throw new AppError({
220
+ code: "IDE_FRAMEWORK_PIN_MISMATCH",
221
+ message: "IDE support does not match the source's selected framework pin.",
222
+ fix: "Use the framework selected by publish.os.config.json, then run the command again."
223
+ });
224
+ }
225
+ async function assertLiveRuntimePin(options) {
226
+ try {
227
+ let config = JSON.parse(
228
+ await readFile(
229
+ join(options.publishOsDir, "publish.os.config.json"),
230
+ "utf8"
231
+ )
232
+ );
233
+ if (runtimePackageVersion(config.runtime) === options.expectedRuntimeVersion)
234
+ return;
235
+ } catch {
236
+ }
237
+ throw new AppError({
238
+ code: "FRAMEWORK_SOURCE_PIN_MISMATCH",
239
+ message: "The source framework pin changed during IDE preparation.",
240
+ fix: "Finish editing publish.os.config.json, then run the command again with the framework selected by the source."
241
+ });
242
+ }
243
+ async function ideOutputMatches(options) {
244
+ let root = await lstat(options.ideRoot).catch(
245
+ (error) => {
246
+ if (error.code !== "ENOENT")
247
+ throw error;
248
+ }
249
+ );
250
+ if (root?.isDirectory() !== !0 || root.isSymbolicLink()) return !1;
251
+ let actual = /* @__PURE__ */ new Map();
252
+ async function readRegularFile(path) {
253
+ try {
254
+ let file = await open(
255
+ path,
256
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
257
+ );
258
+ try {
259
+ return (await file.stat()).isFile() ? await file.readFile("utf8") : void 0;
260
+ } finally {
261
+ await file.close();
262
+ }
263
+ } catch {
264
+ return;
265
+ }
266
+ }
267
+ async function visit(directory, prefix = "") {
268
+ let entries;
269
+ try {
270
+ entries = await readdir(directory, { withFileTypes: !0 });
271
+ } catch {
272
+ return !1;
273
+ }
274
+ for (let entry of entries) {
275
+ let path = prefix ? `${prefix}/${entry.name}` : entry.name, absolute = join(directory, entry.name);
276
+ if (entry.isDirectory() && !entry.isSymbolicLink()) {
277
+ if (!await visit(absolute, path)) return !1;
278
+ } else if (entry.isFile() && !entry.isSymbolicLink()) {
279
+ let contents = await readRegularFile(absolute);
280
+ if (contents === void 0) return !1;
281
+ actual.set(path, contents);
282
+ } else return !1;
283
+ }
284
+ return !0;
285
+ }
286
+ return await visit(options.ideRoot) ? actual.size === Object.keys(options.files).length && Object.entries(options.files).every(
287
+ ([path, contents]) => actual.get(path) === contents
288
+ ) : !1;
289
+ }
290
+ async function acquireIdeOutputLock(options) {
291
+ let deadline = Date.now() + 1e4;
292
+ for (; ; ) {
293
+ options.signal?.throwIfAborted();
294
+ try {
295
+ return await acquireOperationLock({ ...options, operation: "ide" });
296
+ } catch (error) {
297
+ if (!(error instanceof AppError) || error.code !== "FRAMEWORK_LOCAL_OPERATION_ACTIVE" || Date.now() >= deadline)
298
+ throw error;
299
+ await new Promise((resolvePromise) => setTimeout(resolvePromise, 20));
300
+ }
301
+ }
302
+ }
303
+ async function publishIdeOutput(options) {
304
+ let ownership = await ensureLocalOutputRoot({
305
+ sourceRoot: options.publishOsDir
306
+ }), { outputRoot: generatedRoot } = ownership, releaseLock = await acquireIdeOutputLock({
307
+ sourceRoot: options.publishOsDir,
308
+ outputRoot: generatedRoot,
309
+ signal: options.signal
310
+ }), ideRoot = join(generatedRoot, "ide"), stageRoot = join(generatedRoot, ".stages"), recoveryRoot = join(generatedRoot, "recovery"), primaryFailure;
311
+ try {
312
+ await options.assertSourcePin(), await ownership.assertCurrent(), await ideOutputMatches({ ideRoot, files: options.files }) || await publishOwnedDirectory({
313
+ targetDirectory: ideRoot,
314
+ stagingRoot: stageRoot,
315
+ stagingPrefix: "ide",
316
+ recoveryRoot,
317
+ signal: options.signal,
318
+ assertOwner: ownership.assertCurrent,
319
+ beforePublish: options.assertSourcePin,
320
+ prepareIncoming: async (incoming) => {
321
+ for (let [path, contents] of Object.entries(options.files)) {
322
+ let target = join(incoming, path);
323
+ await mkdir(dirname(target), { recursive: !0 }), await writeFile(target, contents, { flag: "wx" });
324
+ }
325
+ }
326
+ });
327
+ } catch (error) {
328
+ primaryFailure = new Error("IDE output publication failed", {
329
+ cause: error
330
+ });
331
+ }
332
+ try {
333
+ await releaseLock();
334
+ } catch (releaseError) {
335
+ throw primaryFailure ? new AggregateError(
336
+ [primaryFailure, releaseError],
337
+ "IDE output publication failed; lock release also failed"
338
+ ) : releaseError;
339
+ }
340
+ if (primaryFailure) throw primaryFailure;
341
+ return ideRoot;
342
+ }
343
+ async function generateIdeSupport(input) {
344
+ input.frameworkOptions.signal?.throwIfAborted();
345
+ let publishOsDir = await realpath(input.publishOsDir), runtime = `@publish.os/nextjs@${input.framework.version}`;
346
+ await assertFrameworkSelection({
347
+ context: input.frameworkOptions.request.context,
348
+ framework: input.framework,
349
+ runtime
350
+ });
351
+ let source = input.source, expectedRuntimeVersion = runtimePackageVersion(source.config.runtime);
352
+ if (expectedRuntimeVersion === void 0)
353
+ throw new AppError({
354
+ code: "FRAMEWORK_SOURCE_PIN_MISMATCH",
355
+ message: "The validated source no longer has a valid framework pin.",
356
+ fix: "Restore a valid runtime value in publish.os.config.json, then run the command again."
357
+ });
358
+ input.frameworkOptions.request.context?.framework || assertExactRuntime(source, input.framework);
359
+ let assertSourcePin = async () => {
360
+ input.frameworkOptions.request.context?.framework || await assertLiveRuntimePin({ publishOsDir, expectedRuntimeVersion });
361
+ };
362
+ await assertSourcePin();
363
+ let finalPublishOsDir = input.finalPublishOsDir ?? publishOsDir, artifacts = await createIdeSourceArtifacts({
364
+ mediaManifest: source.assets.media.manifest
365
+ }), [config, authoredConfig] = await Promise.all([
366
+ ideTsconfig({
367
+ framework: input.framework,
368
+ finalPublishOsDir,
369
+ checkoutRoot: input.frameworkOptions.request.context?.framework?.kind === "checkout" ? input.framework.packageRoot : void 0
370
+ }),
371
+ readFile(sourceRootConfigPath(publishOsDir), "utf8").catch(
372
+ (error) => {
373
+ if (error.code !== "ENOENT")
374
+ throw error;
375
+ }
376
+ )
377
+ ]);
378
+ input.frameworkOptions.signal?.throwIfAborted();
379
+ let ideRoot = await publishIdeOutput({
380
+ publishOsDir,
381
+ signal: input.frameworkOptions.signal,
382
+ assertSourcePin,
383
+ files: {
384
+ "tsconfig.json": config,
385
+ "source/.publishos/media-manifest.generated.ts": artifacts.mediaModule
386
+ }
387
+ }), integrationIssue = editorIntegrationIssue(
388
+ authoredConfig,
389
+ typescriptApi(input.framework)
390
+ );
391
+ integrationIssue && emitWarning(
392
+ input.frameworkOptions,
393
+ `TypeScript support was generated at ${join(ideRoot, "tsconfig.json")}, but ${integrationIssue}. Add extends: "./.publish.os/ide/tsconfig.json" and merge custom TypeScript settings without overriding generated paths. PublishOS left your file unchanged.`
394
+ );
395
+ }
396
+ async function prepareIdeSupport(input) {
397
+ try {
398
+ input.frameworkOptions.signal?.throwIfAborted(), await generateIdeSupport(input);
399
+ } catch (error) {
400
+ let required = findRequiredFailure(error);
401
+ if (required) {
402
+ if (required === error) throw error;
403
+ let failure = required instanceof AppError ? new AppError(required) : new Error(required.message);
404
+ throw failure.name = required.name, failure.cause = error, failure;
405
+ }
406
+ input.frameworkOptions.signal?.throwIfAborted();
407
+ let cause = errorMessage(error);
408
+ input.frameworkOptions.onEvent?.({
409
+ type: "diagnostics",
410
+ diagnostics: {
411
+ diagnostics: [
412
+ {
413
+ code: "IDE_SUPPORT_UNAVAILABLE",
414
+ severity: "warning",
415
+ message: `IDE support is unavailable: ${cause}`,
416
+ correction: "The site operation will continue. IDE support will be retried the next time you run this command."
417
+ }
418
+ ]
419
+ }
420
+ });
421
+ }
422
+ }
423
+
424
+ export {
425
+ prepareIdeSupport
426
+ };
@@ -0,0 +1,186 @@
1
+ import {
2
+ acquireOperationLock,
3
+ assertGeneratedOutput,
4
+ assertLocalDirectory,
5
+ assertOperationOutput,
6
+ ensureLocalOutputRoot,
7
+ localOperationName,
8
+ markOperationOutput,
9
+ publishOwnedDirectory,
10
+ recoverOperationOutput
11
+ } from "./chunk-6D2E6UMD.js";
12
+ import {
13
+ assertPublishOsSourceBoundary
14
+ } from "./chunk-7NY22B5U.js";
15
+ import {
16
+ AppError
17
+ } from "./chunk-22RSSUNV.js";
18
+
19
+ // src/lib/compiler/lifecycle/local-operation.ts
20
+ import { mkdir, mkdtemp, realpath, rm } from "fs/promises";
21
+ import { isAbsolute, join, resolve } from "path";
22
+ async function withLocalOperation(options) {
23
+ let operation = await openLocalOperation(options);
24
+ try {
25
+ operation.context.signal.throwIfAborted();
26
+ let result = await options.run(operation.context);
27
+ return options.signal?.throwIfAborted(), result;
28
+ } finally {
29
+ await operation.close();
30
+ }
31
+ }
32
+ async function openLocalOperation(options) {
33
+ if (options.signal?.throwIfAborted(), options.operation !== "build" && options.operation !== "dev")
34
+ throw new AppError({
35
+ code: "FRAMEWORK_LOCAL_OPERATION_INVALID",
36
+ message: "Select a build or development operation."
37
+ });
38
+ if (!isAbsolute(options.sourceRoot))
39
+ throw new AppError({
40
+ code: "FRAMEWORK_LOCAL_SOURCE_INVALID",
41
+ message: "Supply an absolute publish.os source path."
42
+ });
43
+ await assertPublishOsSourceBoundary(options.sourceRoot);
44
+ let operationName = localOperationName(options), sourceRoot = await realpath(options.sourceRoot), outputRoot = join(sourceRoot, ".publish.os"), outputDir = join(outputRoot, operationName);
45
+ if (options.outputDir && resolve(options.outputDir) !== outputDir)
46
+ throw new AppError({
47
+ code: "FRAMEWORK_LOCAL_OUTPUT_INVALID",
48
+ message: "Local output must use the selected source and operation directory."
49
+ });
50
+ let ownership = await ensureLocalOutputRoot({ sourceRoot }), output = {
51
+ sourceRoot,
52
+ outputDir,
53
+ operation: options.operation,
54
+ scope: options.scope
55
+ }, releaseLock = await acquireOperationLock({
56
+ sourceRoot,
57
+ outputRoot,
58
+ operation: options.operation,
59
+ scope: options.scope,
60
+ signal: options.signal
61
+ }), stagingRoot;
62
+ try {
63
+ await recoverOperationOutput({
64
+ ...output,
65
+ assertCurrent: ownership.assertCurrent
66
+ }), options.signal?.throwIfAborted(), await ownership.assertCurrent(), await mkdir(join(outputRoot, ".stages"), { recursive: !0 }), await assertLocalDirectory(join(outputRoot, ".stages")), stagingRoot = await mkdtemp(
67
+ join(outputRoot, ".stages", `${operationName}-`)
68
+ );
69
+ } catch (error) {
70
+ throw await releaseLock(), error;
71
+ }
72
+ let stagingIdentity = await assertLocalDirectory(stagingRoot), retainStaging = !1, assertStaging = async () => {
73
+ try {
74
+ await ownership.assertCurrent(), await assertLocalDirectory(stagingRoot, stagingIdentity);
75
+ } catch (error) {
76
+ throw retainStaging = !0, error;
77
+ }
78
+ }, controller = new AbortController(), signal = options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal, sourceDir = sourceRoot, sourceRevision;
79
+ try {
80
+ if (options.operation === "build") {
81
+ let { captureLocalSource } = await import("./capture-local-source-WGGDIUU2.js"), capture = await captureLocalSource({
82
+ sourceRoot,
83
+ captureDir: join(stagingRoot, "source"),
84
+ signal
85
+ });
86
+ sourceDir = capture.sourceDir, sourceRevision = capture.sourceRevision;
87
+ }
88
+ } catch (error) {
89
+ throw await assertStaging(), await rm(stagingRoot, { recursive: !0, force: !0 }), await releaseLock(), error;
90
+ }
91
+ let shutdown = [], shutdownFailures = [], acceptsShutdownRegistrations = !0, stopping, stopCallbacks = async (callbacks) => {
92
+ let results = await Promise.allSettled(
93
+ callbacks.map((callback) => Promise.resolve().then(callback))
94
+ );
95
+ shutdownFailures.push(
96
+ ...results.filter((result) => result.status === "rejected").map((result) => result.reason)
97
+ );
98
+ }, stop = async () => {
99
+ stopping ??= stopCallbacks(shutdown);
100
+ let active = stopping;
101
+ for (; await active, active !== stopping; )
102
+ active = stopping;
103
+ if (shutdownFailures.length)
104
+ throw new AppError({
105
+ code: "FRAMEWORK_PROCESS_SHUTDOWN_FAILED",
106
+ message: "Owned resources did not stop. Output and locks remain in place. Confirm that all operation processes have stopped before recovery.",
107
+ details: { failures: shutdownFailures }
108
+ });
109
+ }, abort = () => {
110
+ stop().catch(() => {
111
+ });
112
+ };
113
+ signal.addEventListener("abort", abort, { once: !0 });
114
+ let replacementWork, replaceOutput = async (run) => {
115
+ signal.throwIfAborted(), await assertStaging(), await publishOwnedDirectory({
116
+ targetDirectory: outputDir,
117
+ stagingRoot,
118
+ stagingPrefix: "output",
119
+ signal,
120
+ cleanupFailedStaging: !1,
121
+ assertOwner: async () => {
122
+ try {
123
+ await assertStaging();
124
+ } catch (error) {
125
+ throw retainStaging = !0, error;
126
+ }
127
+ },
128
+ onRecoveryRequired: () => {
129
+ retainStaging = !0;
130
+ },
131
+ prepareIncoming: run,
132
+ validateIncoming: async (incoming) => {
133
+ await assertLocalDirectory(incoming), await assertOperationOutput(output), await assertGeneratedOutput(output), await markOperationOutput({ ...output, outputDir: incoming });
134
+ }
135
+ });
136
+ };
137
+ return {
138
+ context: {
139
+ sourceRoot,
140
+ sourceDir,
141
+ sourceRevision,
142
+ outputDir,
143
+ signal,
144
+ onShutdown: (callback) => acceptsShutdownRegistrations ? stopping ? (stopping = stopping.then(() => stopCallbacks([callback])), () => {
145
+ }) : (shutdown.push(callback), () => {
146
+ let index = shutdown.indexOf(callback);
147
+ index !== -1 && shutdown.splice(index, 1);
148
+ }) : (signal.throwIfAborted(), () => {
149
+ }),
150
+ replaceOutput: (run) => {
151
+ if (replacementWork)
152
+ return Promise.reject(
153
+ new AppError({
154
+ code: "FRAMEWORK_LOCAL_REPLACEMENT_ACTIVE",
155
+ message: "Wait for the current output replacement to finish."
156
+ })
157
+ );
158
+ let work = replaceOutput(run);
159
+ return replacementWork = work, work.finally(() => {
160
+ replacementWork === work && (replacementWork = void 0);
161
+ }).catch(() => {
162
+ }), work;
163
+ }
164
+ },
165
+ close: async () => {
166
+ if (controller.abort(), acceptsShutdownRegistrations = !1, await stop().catch(async (error) => {
167
+ try {
168
+ await releaseLock({ shutdownUnverified: !0 });
169
+ } catch (retentionFailure) {
170
+ error instanceof AppError && error.details && (error.details.lockRetentionFailure = retentionFailure);
171
+ }
172
+ throw error;
173
+ }), await replacementWork?.catch(() => {
174
+ }), signal.removeEventListener("abort", abort), await assertStaging(), retainStaging)
175
+ throw new AppError({
176
+ code: "FRAMEWORK_LOCAL_OUTPUT_REDIRECTED",
177
+ message: `Output cleanup stopped to preserve unverified data. Inspect ${stagingRoot} before recovery.`
178
+ });
179
+ await rm(stagingRoot, { recursive: !0, force: !0 }), await releaseLock();
180
+ }
181
+ };
182
+ }
183
+
184
+ export {
185
+ withLocalOperation
186
+ };
@@ -2,9 +2,11 @@ import {
2
2
  runtimePackageVersion
3
3
  } from "./chunk-AI2UULNX.js";
4
4
  import {
5
- AppError,
6
5
  readInstalledFrameworkLocation
7
- } from "./chunk-WDY4IK6Z.js";
6
+ } from "./chunk-5J3YUNRY.js";
7
+ import {
8
+ AppError
9
+ } from "./chunk-22RSSUNV.js";
8
10
 
9
11
  // src/lib/compiler/release/framework-selection.ts
10
12
  import { createHash } from "crypto";
@@ -1,13 +1,15 @@
1
- import {
2
- validatePublishOsSource
3
- } from "./chunk-726GV2NF.js";
4
1
  import {
5
2
  assertFrameworkSelection
6
- } from "./chunk-DLDFHU7Y.js";
3
+ } from "./chunk-NNBJZPFM.js";
4
+ import {
5
+ validatePublishOsSource
6
+ } from "./chunk-F3AGNDF4.js";
7
7
  import {
8
- AppError,
9
8
  readInstalledFramework
10
- } from "./chunk-WDY4IK6Z.js";
9
+ } from "./chunk-5J3YUNRY.js";
10
+ import {
11
+ AppError
12
+ } from "./chunk-22RSSUNV.js";
11
13
 
12
14
  // src/lib/compiler/lifecycle/validate-local-source.ts
13
15
  async function validateLocalSource({