@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/compiler-assets/nextjs/defaults/group/index.tsx +16 -11
  2. package/compiler-assets/nextjs/defaults/group/layout.tsx +6 -6
  3. package/compiler-assets/nextjs/defaults/group/page.tsx +36 -26
  4. package/compiler-assets/nextjs/defaults/project/next.config.mjs +21 -11
  5. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
  6. package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
  7. package/compiler-assets/nextjs/defaults/root/index.tsx +16 -11
  8. package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -3
  9. package/compiler-assets/nextjs/shims/agent-user-agents.ts +65 -0
  10. package/compiler-assets/nextjs/shims/document.tsx +46 -0
  11. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +5 -0
  12. package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
  13. package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
  14. package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
  15. package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
  16. package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
  17. package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
  18. package/compiler-assets/nextjs/shims/proxy.ts +254 -86
  19. package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
  20. package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
  21. package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
  22. package/dist/{build-operation-2JAYBSKF.js → build-operation-CJDUL4OW.js} +29 -23
  23. package/dist/{button-c3WGnxIj.d.ts → button-D6Xp2HBm.d.ts} +4 -4
  24. package/dist/capture-local-source-WGGDIUU2.js +258 -0
  25. package/dist/chunk-22RSSUNV.js +13 -0
  26. package/dist/chunk-3T4HVDSC.js +426 -0
  27. package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
  28. package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
  29. package/dist/chunk-5KAD7W53.js +248 -0
  30. package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
  31. package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
  32. package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
  33. package/dist/chunk-DX7PXFCM.js +2519 -0
  34. package/dist/{chunk-726GV2NF.js → chunk-DZ3VWEV5.js} +950 -632
  35. package/dist/chunk-EFO6AWXN.js +19 -0
  36. package/dist/chunk-IL4RJOKI.js +186 -0
  37. package/dist/{chunk-H6XILMZX.js → chunk-NHSLTARU.js} +2588 -1493
  38. package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
  39. package/dist/{chunk-VO2I7MTM.js → chunk-SBMDONTV.js} +10 -7
  40. package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
  41. package/dist/compiler.d.ts +15 -2
  42. package/dist/compiler.js +111 -23
  43. package/dist/components/blocks/agent-actions.d.ts +81 -0
  44. package/dist/components/blocks/agent-actions.js +563 -0
  45. package/dist/components/blocks/toc.d.ts +43 -0
  46. package/dist/components/blocks/toc.js +136 -0
  47. package/dist/components/ui/button.d.ts +4 -0
  48. package/dist/components/ui/button.js +94 -0
  49. package/dist/compose-44GJSMXD.js +16 -0
  50. package/dist/config/createNextConfig.js +19 -3
  51. package/dist/{dev-operation-TZDVJCN7.js → dev-operation-WNECBHZ5.js} +134 -84
  52. package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
  53. package/dist/ide-support-TG74L4FF.js +16 -0
  54. package/dist/index.d.ts +151 -95
  55. package/dist/index.js +25 -0
  56. package/dist/jsx-dev-runtime.d.ts +6 -0
  57. package/dist/jsx-dev-runtime.js +100 -0
  58. package/dist/jsx-runtime.d.ts +7 -0
  59. package/dist/jsx-runtime.js +97 -0
  60. package/dist/kernel/components/blocks/AgentActions.d.ts +37 -8
  61. package/dist/kernel/components/blocks/AgentActions.js +384 -174
  62. package/dist/kernel/components/blocks/agent-actions.d.ts +4 -0
  63. package/dist/kernel/components/blocks/agent-actions.js +563 -0
  64. package/dist/kernel/components/blocks/animated-icon-swap.d.ts +2 -2
  65. package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
  66. package/dist/kernel/components/blocks/color-palette.d.ts +2 -2
  67. package/dist/kernel/components/blocks/color-palette.js +4 -4
  68. package/dist/kernel/components/blocks/logo-block.d.ts +2 -2
  69. package/dist/kernel/components/blocks/logo-block.js +1 -1
  70. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +6 -5
  71. package/dist/kernel/components/blocks/nav-breadcrumb.js +21 -15
  72. package/dist/kernel/components/blocks/navbar.d.ts +5 -4
  73. package/dist/kernel/components/blocks/navbar.js +79 -59
  74. package/dist/kernel/components/blocks/navigation-progress.d.ts +2 -2
  75. package/dist/kernel/components/blocks/navigation-progress.js +2 -2
  76. package/dist/kernel/components/blocks/next-prev.d.ts +4 -4
  77. package/dist/kernel/components/blocks/next-prev.js +30 -7
  78. package/dist/kernel/components/blocks/page-list.d.ts +4 -4
  79. package/dist/kernel/components/blocks/page-list.js +32 -9
  80. package/dist/kernel/components/blocks/search.d.ts +9 -15
  81. package/dist/kernel/components/blocks/search.js +16 -17
  82. package/dist/kernel/components/blocks/sidebar-node.d.ts +3 -5
  83. package/dist/kernel/components/blocks/sidebar-node.js +13 -3
  84. package/dist/kernel/components/blocks/sidebar.d.ts +6 -7
  85. package/dist/kernel/components/blocks/sidebar.js +137 -28
  86. package/dist/kernel/components/blocks/theme-toggle.d.ts +3 -4
  87. package/dist/kernel/components/blocks/theme-toggle.js +5 -5
  88. package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
  89. package/dist/kernel/components/blocks/toc-client.js +495 -0
  90. package/dist/kernel/components/blocks/toc.d.ts +20 -2
  91. package/dist/kernel/components/blocks/toc.js +121 -179
  92. package/dist/kernel/components/mdx/components/blockquote.d.ts +2 -2
  93. package/dist/kernel/components/mdx/components/blockquote.js +1 -1
  94. package/dist/kernel/components/mdx/components/callout.d.ts +3 -3
  95. package/dist/kernel/components/mdx/components/callout.js +1 -1
  96. package/dist/kernel/components/mdx/components/code-block.d.ts +2 -2
  97. package/dist/kernel/components/mdx/components/code-block.js +2 -2
  98. package/dist/kernel/components/mdx/components/copy-code-button.d.ts +2 -2
  99. package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
  100. package/dist/kernel/components/mdx/components/figure-caption.d.ts +3 -3
  101. package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
  102. package/dist/kernel/components/mdx/components/figure.d.ts +8 -4
  103. package/dist/kernel/components/mdx/components/figure.js +23 -13
  104. package/dist/kernel/components/mdx/components/footnotes.d.ts +2 -2
  105. package/dist/kernel/components/mdx/components/footnotes.js +1 -1
  106. package/dist/kernel/components/mdx/components/heading-copy-link.d.ts +2 -2
  107. package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
  108. package/dist/kernel/components/mdx/components/heading.d.ts +2 -2
  109. package/dist/kernel/components/mdx/components/heading.js +6 -3
  110. package/dist/kernel/components/mdx/components/hr.d.ts +4 -4
  111. package/dist/kernel/components/mdx/components/hr.js +2 -2
  112. package/dist/kernel/components/mdx/components/image-zoom.d.ts +3 -3
  113. package/dist/kernel/components/mdx/components/image-zoom.js +4 -3
  114. package/dist/kernel/components/mdx/components/image.d.ts +2 -2
  115. package/dist/kernel/components/mdx/components/image.js +22 -17
  116. package/dist/kernel/components/mdx/components/inline-code.d.ts +2 -2
  117. package/dist/kernel/components/mdx/components/inline-code.js +1 -1
  118. package/dist/kernel/components/mdx/components/kbd.d.ts +3 -3
  119. package/dist/kernel/components/mdx/components/kbd.js +2 -2
  120. package/dist/kernel/components/mdx/components/link.d.ts +6 -6
  121. package/dist/kernel/components/mdx/components/link.js +2 -2
  122. package/dist/kernel/components/mdx/components/paragraph.d.ts +2 -2
  123. package/dist/kernel/components/mdx/components/paragraph.js +1 -1
  124. package/dist/kernel/components/mdx/components/strikethrough.d.ts +2 -2
  125. package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
  126. package/dist/kernel/components/mdx/components/table.d.ts +7 -7
  127. package/dist/kernel/components/mdx/components/table.js +2 -2
  128. package/dist/kernel/components/mdx/components/task-list.d.ts +3 -3
  129. package/dist/kernel/components/mdx/components/task-list.js +1 -1
  130. package/dist/kernel/components/mdx/components/video-player.d.ts +8 -4
  131. package/dist/kernel/components/mdx/components/video-player.js +6 -2
  132. package/dist/kernel/components/mdx/components/video.d.ts +5 -4
  133. package/dist/kernel/components/mdx/components/video.js +7 -5
  134. package/dist/kernel/components/mdx/error-boundary.d.ts +3 -4
  135. package/dist/kernel/components/mdx/error-boundary.js +2 -2
  136. package/dist/kernel/components/mdx/error-fallback.d.ts +2 -2
  137. package/dist/kernel/components/mdx/error-fallback.js +1 -1
  138. package/dist/kernel/components/mdx/mdx.d.ts +57 -16
  139. package/dist/kernel/components/mdx/mdx.js +232 -35
  140. package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
  141. package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
  142. package/dist/kernel/components/mdx/types.d.ts +1 -1
  143. package/dist/kernel/components/next-image.d.ts +12 -0
  144. package/dist/kernel/components/next-image.js +61 -0
  145. package/dist/kernel/components/ui/accordion.d.ts +7 -7
  146. package/dist/kernel/components/ui/accordion.js +1 -1
  147. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -4
  148. package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
  149. package/dist/kernel/components/ui/breadcrumb.d.ts +14 -14
  150. package/dist/kernel/components/ui/breadcrumb.js +4 -4
  151. package/dist/kernel/components/ui/button-group.d.ts +6 -6
  152. package/dist/kernel/components/ui/button-group.js +3 -3
  153. package/dist/kernel/components/ui/button.d.ts +59 -7
  154. package/dist/kernel/components/ui/button.js +43 -39
  155. package/dist/kernel/components/ui/card.d.ts +7 -7
  156. package/dist/kernel/components/ui/card.js +1 -1
  157. package/dist/kernel/components/ui/dialog.d.ts +10 -10
  158. package/dist/kernel/components/ui/dialog.js +1 -1
  159. package/dist/kernel/components/ui/drawer.d.ts +12 -12
  160. package/dist/kernel/components/ui/drawer.js +1 -1
  161. package/dist/kernel/components/ui/input.d.ts +2 -2
  162. package/dist/kernel/components/ui/input.js +1 -1
  163. package/dist/kernel/components/ui/kbd.d.ts +4 -4
  164. package/dist/kernel/components/ui/kbd.js +1 -1
  165. package/dist/kernel/components/ui/link.d.ts +11 -5
  166. package/dist/kernel/components/ui/link.js +2 -2
  167. package/dist/kernel/components/ui/menu.d.ts +22 -22
  168. package/dist/kernel/components/ui/menu.js +1 -1
  169. package/dist/kernel/components/ui/mod-key.d.ts +2 -3
  170. package/dist/kernel/components/ui/mod-key.js +2 -2
  171. package/dist/kernel/components/ui/navigation-menu.d.ts +15 -15
  172. package/dist/kernel/components/ui/navigation-menu.js +1 -1
  173. package/dist/kernel/components/ui/popover.d.ts +11 -11
  174. package/dist/kernel/components/ui/popover.js +1 -1
  175. package/dist/kernel/components/ui/progress.d.ts +7 -7
  176. package/dist/kernel/components/ui/progress.js +1 -1
  177. package/dist/kernel/components/ui/scroll-area.d.ts +9 -10
  178. package/dist/kernel/components/ui/scroll-area.js +1 -1
  179. package/dist/kernel/components/ui/select.d.ts +16 -16
  180. package/dist/kernel/components/ui/select.js +1 -1
  181. package/dist/kernel/components/ui/separator.d.ts +3 -3
  182. package/dist/kernel/components/ui/separator.js +1 -1
  183. package/dist/kernel/components/ui/table.d.ts +7 -7
  184. package/dist/kernel/components/ui/table.js +1 -1
  185. package/dist/kernel/components/ui/tabs.d.ts +12 -12
  186. package/dist/kernel/components/ui/tabs.js +1 -1
  187. package/dist/kernel/components/ui/tag.d.ts +3 -3
  188. package/dist/kernel/components/ui/tag.js +1 -1
  189. package/dist/kernel/components/ui/text.d.ts +4 -4
  190. package/dist/kernel/components/ui/text.js +1 -1
  191. package/dist/kernel/components/ui/toast.d.ts +11 -11
  192. package/dist/kernel/components/ui/toast.js +1 -1
  193. package/dist/kernel/components/ui/tooltip.d.ts +9 -9
  194. package/dist/kernel/components/ui/tooltip.js +1 -1
  195. package/dist/kernel/defaults.registry.d.ts +4 -17
  196. package/dist/kernel/defaults.registry.js +4 -19
  197. package/dist/kernel/routes/agent/markdown.d.ts +7 -0
  198. package/dist/kernel/routes/agent/markdown.js +229 -54
  199. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  200. package/dist/kernel/routes/layouts/group.js +5 -7
  201. package/dist/kernel/routes/metadata/feed.d.ts +1 -2
  202. package/dist/kernel/routes/metadata/feed.js +119 -88
  203. package/dist/kernel/routes/metadata/llms.d.ts +3 -23
  204. package/dist/kernel/routes/metadata/llms.js +2 -103
  205. package/dist/kernel/routes/metadata/og-image.js +1 -1
  206. package/dist/kernel/routes/metadata/robots.d.ts +5 -3
  207. package/dist/kernel/routes/metadata/robots.js +4 -25
  208. package/dist/kernel/routes/metadata/sitemap.d.ts +36 -3
  209. package/dist/kernel/routes/metadata/sitemap.js +277 -49
  210. package/dist/kernel/routes/not-found.d.ts +34 -0
  211. package/dist/kernel/routes/not-found.js +213 -0
  212. package/dist/kernel/routes/pages/group.d.ts +5 -5
  213. package/dist/kernel/routes/pages/group.js +11 -5
  214. package/dist/kernel/routes/pages/leaf.d.ts +38 -6
  215. package/dist/kernel/routes/pages/leaf.js +21 -12
  216. package/dist/kernel/routes/pages/root.d.ts +5 -5
  217. package/dist/kernel/routes/pages/root.js +21 -6
  218. package/dist/keyboard-shortcuts.d.ts +2 -2
  219. package/dist/keyboard-shortcuts.js +1 -1
  220. package/dist/manifest-types-CcVPH_jh.d.ts +83 -0
  221. package/dist/resolvers/manifest-resolver.d.ts +2 -2
  222. package/dist/resolvers/manifest-resolver.js +65 -35
  223. package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
  224. package/dist/search.d.ts +2 -9
  225. package/dist/search.js +9 -16
  226. package/dist/sidebar-types-CMrMM0Nj.d.ts +105 -0
  227. package/dist/theme-scope.d.ts +2 -2
  228. package/dist/theme-scope.js +1 -1
  229. package/dist/types-BbqmOzLC.d.ts +168 -0
  230. package/dist/types-TjH1ek0X.d.ts +22 -0
  231. package/dist/types-sM2g9nW0.d.ts +12 -0
  232. package/dist/types.d.ts +117 -91
  233. package/dist/utils/heading-ids.js +30 -11
  234. package/dist/utils/toc-selection.d.ts +7 -0
  235. package/dist/utils/toc-selection.js +14 -0
  236. package/dist/validate-local-source-EN2GW4FR.js +16 -0
  237. package/dist/validate-publish-os-source-OEWQDB7B.js +14 -0
  238. package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
  239. package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
  240. package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
  241. package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
  242. package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
  243. package/init/seed/minimal/publish.os/blog/index.tsx +85 -0
  244. package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
  245. package/init/seed/minimal/publish.os/blog/page.tsx +91 -0
  246. package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
  247. package/init/seed/minimal/publish.os/components/blog/frontmatter.ts +41 -0
  248. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
  249. package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
  250. package/init/seed/minimal/publish.os/publish.os.config.json +17 -2
  251. package/init/seed/minimal/publish.os/theme.css +3 -3
  252. package/init/seed/minimal/seed.json +12 -4
  253. package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
  254. package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
  255. package/package.json +48 -23
  256. package/release/app/phosphor/package.json +4 -4
  257. package/release/app/phosphor/pnpm-lock.yaml.template +123 -184
  258. package/release/compiler/package.json +5 -3
  259. package/release/compiler/pnpm-lock.yaml.template +153 -183
  260. package/release/release.json +6 -6
  261. package/dist/button-CtzUJB8u.d.ts +0 -11
  262. package/dist/chunk-535TM4A5.js +0 -1455
  263. package/dist/chunk-B2V22WRT.js +0 -297
  264. package/dist/chunk-NECL5IBJ.js +0 -318
  265. package/dist/chunk-SVYGXXYR.js +0 -36
  266. package/dist/chunk-UF6ATARM.js +0 -1100
  267. package/dist/compose-NN23UJGC.js +0 -13
  268. package/dist/ide-support-ZNW7ODFY.js +0 -15
  269. package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
  270. package/dist/kernel/components/blocks/design-system-preview.js +0 -667
  271. package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
  272. package/dist/kernel/components/blocks/link-playground.js +0 -744
  273. package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
  274. package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
  275. package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
  276. package/dist/kernel/components/ui/theme-toggle.js +0 -53
  277. package/dist/sidebar-types-DKpR27II.d.ts +0 -25
  278. package/dist/types-BzkZty3r.d.ts +0 -147
  279. package/dist/types-CJWRG05y.d.ts +0 -76
  280. package/dist/types-CUtrppxt.d.ts +0 -69
  281. package/dist/validate-local-source-XRL2Y7XE.js +0 -14
  282. package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
  283. package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
  284. 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-NHSLTARU.js";
9
+ import {
10
+ assertFrameworkSelection,
11
+ readCheckoutTypeScriptConfig
12
+ } from "./chunk-NNBJZPFM.js";
13
+ import {
14
+ supportedNextjsSourceImports
15
+ } from "./chunk-DX7PXFCM.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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AppError
3
- } from "./chunk-WDY4IK6Z.js";
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) throw shutdownFailure();
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: purpose === "ide" ? "Preparing IDE dependencies" : "Preparing app dependencies"
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: `Downloading missing ${purpose === "ide" ? "IDE" : "app"} dependencies`
546
- }), await assertInstallGraph?.();
549
+ message: "Downloading missing app dependencies"
550
+ });
547
551
  try {
548
552
  await run({
549
- args: ["install", "--frozen-lockfile", "--fetch-timeout=10000"],
553
+ args: ["install", "--frozen-lockfile"],
550
554
  quiet: options.request.operation !== "build",
551
- timeoutMs: 12e4
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 (await assertInstallGraph?.(), !(await readFile(lockPath)).equals(lock))
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
- // 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
- };
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
  };