@redocly/framework 1.0.0-next.11 → 1.0.0-next.12

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 (225) hide show
  1. package/dist/bundler/build/dependency-pack.js +1 -1
  2. package/dist/bundler/build/output-metadata.js +1 -1
  3. package/dist/bundler/build/run.js +1 -1
  4. package/dist/bundler/build/theme-global-stylesheets.js +1 -1
  5. package/dist/bundler/build/vite-config.js +2 -2
  6. package/dist/bundler/dev/dev-content-build.js +1 -1
  7. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  8. package/dist/bundler/dev/routes/source-sync-route.js +1 -1
  9. package/dist/bundler/dev/run.js +1 -1
  10. package/dist/bundler/dev/runtime-app.js +1 -1
  11. package/dist/bundler/dev/vite-chunk-url.js +1 -1
  12. package/dist/bundler/dev/vite-config.js +1 -1
  13. package/dist/bundler/user-markdoc-schema.js +1 -1
  14. package/dist/bundler/vite-config.base.js +5 -5
  15. package/dist/cli/api-docs-build-event.js +1 -1
  16. package/dist/cli/args.js +1 -1
  17. package/dist/cli/commands/build.js +1 -1
  18. package/dist/cli/commands/dev.js +1 -1
  19. package/dist/cli/commands/ingest.js +1 -1
  20. package/dist/cli/commands/translate.js +1 -1
  21. package/dist/cli/problems-output.js +3 -3
  22. package/dist/cli/validate-react-pages.js +1 -1
  23. package/dist/client/ai-search/citations.js +3 -3
  24. package/dist/client/ai-search/use-ai-search.js +1 -1
  25. package/dist/client/analytics-page-view.js +1 -1
  26. package/dist/client/app.js +2 -2
  27. package/dist/client/classic-webview-sync.js +1 -0
  28. package/dist/client/client-entry.js +1 -1
  29. package/dist/client/contexts.js +1 -1
  30. package/dist/client/feedback.js +1 -1
  31. package/dist/client/l10n/ssr-l10n.js +1 -1
  32. package/dist/client/l10n/use-l10n-config.js +1 -1
  33. package/dist/client/page-sync.js +1 -0
  34. package/dist/client/products.js +1 -1
  35. package/dist/client/review/ReviewBar.js +3 -3
  36. package/dist/client/review/login-url.js +1 -1
  37. package/dist/client/review/use-review.js +1 -1
  38. package/dist/client/revisions-history.js +1 -1
  39. package/dist/client/sidebar/SidebarDataProvider.js +1 -1
  40. package/dist/client/sidebar/drilldown.js +1 -1
  41. package/dist/client/ssr.js +1 -1
  42. package/dist/client/telemetry/config.js +1 -1
  43. package/dist/client/theme-logo.js +1 -1
  44. package/dist/client/use-entity-revisions.js +1 -1
  45. package/dist/client/use-page-versions.js +1 -1
  46. package/dist/client/use-search.js +1 -1
  47. package/dist/client/webmcp/tools/shared.js +1 -1
  48. package/dist/client/webmcp/tools/site-tools.js +1 -1
  49. package/dist/client/webmcp/use-webmcp-tools.js +1 -1
  50. package/dist/content-layer/config.js +1 -1
  51. package/dist/content-layer/context-state.js +1 -1
  52. package/dist/content-layer/context.js +1 -1
  53. package/dist/content-layer/database/assets.js +1 -1
  54. package/dist/content-layer/database/blobs.js +1 -1
  55. package/dist/content-layer/database/entity-store.js +1 -1
  56. package/dist/content-layer/database/files.js +1 -1
  57. package/dist/content-layer/database/finalize.js +1 -1
  58. package/dist/content-layer/database/invalidation.js +26 -26
  59. package/dist/content-layer/database/link-refs.js +1 -1
  60. package/dist/content-layer/database/origins.js +1 -1
  61. package/dist/content-layer/database/problems.js +1 -1
  62. package/dist/content-layer/database/reset.js +1 -1
  63. package/dist/content-layer/database/route-query-deps.js +1 -1
  64. package/dist/content-layer/database/search-vocab.js +2 -2
  65. package/dist/content-layer/database/static-files.js +1 -1
  66. package/dist/content-layer/ingest/extract-all-phase.js +1 -1
  67. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  68. package/dist/content-layer/ingest/hash.js +1 -1
  69. package/dist/content-layer/ingest/hook-inputs.js +1 -1
  70. package/dist/content-layer/ingest/l10n-warnings.js +1 -1
  71. package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
  72. package/dist/content-layer/ingest/run.js +1 -1
  73. package/dist/content-layer/ingest/scan.js +1 -1
  74. package/dist/content-layer/ingest/search-sync.js +1 -1
  75. package/dist/content-layer/ingest/sync.js +1 -1
  76. package/dist/content-layer/link-checker/config-links.js +1 -1
  77. package/dist/content-layer/link-checker/delta.js +1 -1
  78. package/dist/content-layer/link-checker/fingerprint.js +1 -1
  79. package/dist/content-layer/link-checker/load-view.js +1 -1
  80. package/dist/content-layer/link-checker/node-ref.js +1 -1
  81. package/dist/content-layer/link-checker/run-build.js +1 -1
  82. package/dist/content-layer/link-checker/validate.js +1 -1
  83. package/dist/content-layer/loaders/context.js +1 -1
  84. package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
  85. package/dist/content-layer/markdown/client/markdown-text.js +1 -1
  86. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  87. package/dist/content-layer/markdown/nodes/fence.js +1 -1
  88. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  89. package/dist/content-layer/markdown/nodes/table.js +1 -1
  90. package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
  91. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  92. package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
  93. package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
  94. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  95. package/dist/content-layer/markdown/resolve/references.js +1 -1
  96. package/dist/content-layer/markdown/search/to-markdown.js +2 -2
  97. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  98. package/dist/content-layer/markdown/search/to-text.js +5 -5
  99. package/dist/content-layer/markdown/server/render.js +1 -1
  100. package/dist/content-layer/markdown/service.js +1 -1
  101. package/dist/content-layer/markdown/tags/variant.js +1 -1
  102. package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
  103. package/dist/content-layer/markdown/utils/first-heading.js +1 -1
  104. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  105. package/dist/content-layer/materialization/asset-reconcile.js +1 -1
  106. package/dist/content-layer/materialization/entity.js +1 -1
  107. package/dist/content-layer/materialization/materializer.js +1 -1
  108. package/dist/content-layer/materialization/static-files.js +1 -1
  109. package/dist/content-layer/plugins/execute.js +1 -1
  110. package/dist/content-layer/plugins/index.js +1 -1
  111. package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
  112. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  113. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
  114. package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +5 -5
  115. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  116. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
  117. package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
  118. package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
  119. package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
  120. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  121. package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
  122. package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
  123. package/dist/content-layer/plugins/internal/assets/index.js +1 -1
  124. package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
  125. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  126. package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
  127. package/dist/content-layer/plugins/internal/index.js +1 -1
  128. package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
  129. package/dist/content-layer/plugins/internal/l10n/translations-loader.js +1 -1
  130. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  131. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  132. package/dist/content-layer/plugins/internal/mcp/app-data.js +1 -1
  133. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  134. package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
  135. package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
  136. package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
  137. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  138. package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
  139. package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
  140. package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
  141. package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -2
  142. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
  143. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
  144. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
  145. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  146. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
  147. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  148. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  149. package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
  150. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  151. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  152. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  153. package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
  154. package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
  155. package/dist/content-layer/plugins/internal/mcp/server/oauth/error-reporting.js +1 -1
  156. package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
  157. package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
  158. package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
  159. package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
  160. package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
  161. package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
  162. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  163. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
  164. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
  165. package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
  166. package/dist/content-layer/plugins/internal/mcp/setup-page.js +1 -1
  167. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  168. package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
  169. package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
  170. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  171. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  172. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  173. package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
  174. package/dist/content-layer/plugins/internal/versions/index.js +1 -1
  175. package/dist/content-layer/plugins/io.js +1 -1
  176. package/dist/content-layer/plugins/project/load.js +2 -2
  177. package/dist/content-layer/plugins/source-file.js +1 -1
  178. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  179. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  180. package/dist/content-layer/revisions/delete.js +1 -1
  181. package/dist/content-layer/revisions/read.js +1 -1
  182. package/dist/content-layer/search/engine/core/search-engine.js +1 -1
  183. package/dist/content-layer/search/postings/postings-store.js +1 -1
  184. package/dist/content-layer/server/database.js +1 -1
  185. package/dist/content-layer/static/registry.js +1 -1
  186. package/dist/content-layer/templates/template-set.js +1 -1
  187. package/dist/content-layer/versions/group-info.d.ts +2 -1
  188. package/dist/content-layer/versions/group-info.js +1 -1
  189. package/dist/content-layer/versions/redirect.js +1 -1
  190. package/dist/content-layer/versions/resolve.js +1 -1
  191. package/dist/server/app.js +3 -3
  192. package/dist/server/ask-ai/route.js +1 -1
  193. package/dist/server/auth/middleware.js +1 -1
  194. package/dist/server/auth/request.js +1 -1
  195. package/dist/server/auth/routes.js +1 -1
  196. package/dist/server/auth/runtime.js +1 -1
  197. package/dist/server/content.js +12 -12
  198. package/dist/server/cors-proxy/handler.js +1 -1
  199. package/dist/server/feedback/route.js +1 -1
  200. package/dist/server/lambda-entry.js +1 -1
  201. package/dist/server/manifest-assets.js +4 -4
  202. package/dist/server/node-entry.js +1 -1
  203. package/dist/server/plugin-context.js +1 -1
  204. package/dist/server/rbac/content-asset-access.js +1 -1
  205. package/dist/server/runtime-config.js +1 -1
  206. package/dist/server/search/route.js +1 -1
  207. package/dist/server/seo-tags.js +2 -2
  208. package/dist/server/sitemap.js +1 -1
  209. package/dist/server/static-files/serve.js +1 -1
  210. package/dist/server/subprocess/child-entry.js +1 -1
  211. package/dist/server/telemetry/mock-server-events.js +1 -1
  212. package/dist/server/telemetry/sender.js +1 -1
  213. package/dist/server/template-ids.js +1 -1
  214. package/dist/server/wait-until.js +1 -0
  215. package/dist/shared/constants/review.d.ts +2 -0
  216. package/dist/shared/constants/review.js +1 -1
  217. package/dist/shared/constants/system-routes.d.ts +1 -1
  218. package/dist/shared/constants/system-routes.js +1 -1
  219. package/dist/shared/rbac/engine.js +0 -0
  220. package/dist/shared/rbac/l10n-rules.js +1 -1
  221. package/dist/shared/rbac/route-scope.js +1 -1
  222. package/dist/shared/rbac/team-templates.js +1 -1
  223. package/dist/shared/utils/l10n.js +1 -1
  224. package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
  225. package/package.json +4 -4
@@ -1 +1 @@
1
- import{toPosixPath as e}from"../../shared/utils/to-posix-path.js";import{RUNTIME_DEPENDENCY_PACK_DIRNAME as t}from"../../shared/constants/runtime-layout.js";import{layoutFromGraph as n}from"../../browser-engine/dedicated-worker/deps/layout.js";import{parseDependencies as r}from"../../browser-engine/dedicated-worker/deps/manifest.js";import{createTar as i}from"../../browser-engine/dedicated-worker/tar-archive.js";import{DEPENDENCY_PACK_FILENAME as a,DEPENDENCY_PACK_MANIFEST_PATH as o,ENGINE_PROVIDED_PACKAGES as s,SKIPPED_DEPENDENCY_FILE_RE as c,dependencyManifestFingerprint as l}from"../../shared/constants/dependency-pack.js";import{createHash as u}from"node:crypto";import{existsSync as d,readFileSync as f,readdirSync as p,realpathSync as m,statSync as h}from"node:fs";import{dirname as g,isAbsolute as _,join as v,relative as y}from"node:path";import{mkdir as b,writeFile as x}from"node:fs/promises";import{gzipSync as S}from"node:zlib";function C(){let t=/* @__PURE__ */ new Set;return{files:t,plugin:{name:`realm-dependency-recorder`,enforce:`pre`,load(n){if(n.startsWith(`\0`))return null;let r=Math.min(...[`?`,`#`].map(e=>n.indexOf(e)).filter(e=>e!==-1)),i=Number.isFinite(r)?n.slice(0,r):n;return _(i)&&e(i).includes(`/node_modules/`)&&t.add(i),null}}}}async function w(e){let r=v(e.contentDir,`package.json`);if(!d(r))return null;let s=f(r,`utf8`),c=v(e.contentDir,`package-lock.json`),u=d(c)?f(c,`utf8`):null,p=e.engineOwned??T(),m=D(e.contentDir,s),h=n(m.graph,p);if(h.size===0)return null;let _={},y=[],C=new Set([...e.recorded].map(j)),w=/* @__PURE__ */ new Set;for(let[e,{name:t,version:n}]of h){let r=m.dirs.get(`${t}@${n}`);if(!r)continue;let i=!w.has(`${t}@${n}`);w.add(`${t}@${n}`);let a={};for(let[t,n]of A(r)){a[t]=n;let o=v(r,t);i&&(t.endsWith(`package.json`)||C.has(o))&&y.push({path:`${e}/${t}`,data:new Uint8Array(f(o))})}_[e]={name:t,version:n,files:a}}let E={version:2,manifestHash:M(l(s)),lockfileHash:u===null?null:M(u),fileUrl:e.fileUrl,packages:_};y.unshift({path:o,data:new TextEncoder().encode(JSON.stringify(E))});let O=S(i(y)),k=v(e.outputDir,t,a);return await b(g(k),{recursive:!0}),await x(k,O),{path:k,packages:Object.keys(_).length,packedFiles:y.length-1,bytes:O.byteLength}}function T(){return new Set(s)}function E(e){return[.../* @__PURE__ */ new Set([...Object.keys(e.dependencies??{}),...Object.keys(e.optionalDependencies??{}),...Object.keys(e.peerDependencies??{})])]}function D(e,t){let n={root:{},packages:{}},i=/* @__PURE__ */ new Map,a=[];for(let{name:i}of r(t))a.push({from:e,name:i,onResolved:e=>void(n.root[i]=e)});for(let{from:e,name:t,onResolved:r}of a){let o=O(e,t),s=o?k(o):null;if(!o||typeof s?.version!=`string`)continue;let c=`${t}@${s.version}`;if(r(s.version),n.packages[c])continue;let l={};n.packages[c]={name:t,version:s.version,dependencies:l},i.set(c,o);for(let e of E(s))a.push({from:o,name:e,onResolved:t=>void(l[e]=t)})}return{graph:n,dirs:i}}function O(e,t){let n=e;for(;;){let e=v(n,`node_modules`,...t.split(`/`));if(d(v(e,`package.json`)))return j(e);let r=g(n);if(r===n)return null;n=r}}function k(e){try{return JSON.parse(f(v(e,`package.json`),`utf8`))}catch{return null}}function A(t){let n=[],r=i=>{for(let a of p(i,{withFileTypes:!0})){if(a.name===`node_modules`)continue;let o=v(i,a.name);if(a.isDirectory())r(o);else if(a.isFile()||a.isSymbolicLink()){let r=e(y(t,o));if(c.test(r))continue;try{n.push([r,h(o).size])}catch{}}}};return r(t),n}function j(e){try{return m(e)}catch{return e}}function M(e){return u(`sha256`).update(e).digest(`hex`)}export{C as createDependencyRecorder,T as engineOwnedPackageNames,w as writeDependencyPack};
1
+ import{RUNTIME_DEPENDENCY_PACK_DIRNAME as e}from"../../shared/constants/runtime-layout.js";import{toPosixPath as t}from"../../shared/utils/to-posix-path.js";import{layoutFromGraph as n}from"../../browser-engine/dedicated-worker/deps/layout.js";import{parseDependencies as r}from"../../browser-engine/dedicated-worker/deps/manifest.js";import{createTar as i}from"../../browser-engine/dedicated-worker/tar-archive.js";import{DEPENDENCY_PACK_FILENAME as a,DEPENDENCY_PACK_MANIFEST_PATH as o,ENGINE_PROVIDED_PACKAGES as s,SKIPPED_DEPENDENCY_FILE_RE as c,dependencyManifestFingerprint as l}from"../../shared/constants/dependency-pack.js";import{createHash as u}from"node:crypto";import{existsSync as d,readFileSync as f,readdirSync as p,realpathSync as m,statSync as h}from"node:fs";import{dirname as g,isAbsolute as _,join as v,relative as y}from"node:path";import{mkdir as b,writeFile as x}from"node:fs/promises";import{gzipSync as S}from"node:zlib";function C(){let e=/* @__PURE__ */ new Set;return{files:e,plugin:{name:`realm-dependency-recorder`,enforce:`pre`,load(n){if(n.startsWith(`\0`))return null;let r=Math.min(...[`?`,`#`].map(e=>n.indexOf(e)).filter(e=>e!==-1)),i=Number.isFinite(r)?n.slice(0,r):n;return _(i)&&t(i).includes(`/node_modules/`)&&e.add(i),null}}}}async function w(t){let r=v(t.contentDir,`package.json`);if(!d(r))return null;let s=f(r,`utf8`),c=v(t.contentDir,`package-lock.json`),u=d(c)?f(c,`utf8`):null,p=t.engineOwned??T(),m=D(t.contentDir,s),h=n(m.graph,p);if(h.size===0)return null;let _={},y=[],C=new Set([...t.recorded].map(j)),w=/* @__PURE__ */ new Set;for(let[e,{name:t,version:n}]of h){let r=m.dirs.get(`${t}@${n}`);if(!r)continue;let i=!w.has(`${t}@${n}`);w.add(`${t}@${n}`);let a={};for(let[t,n]of A(r)){a[t]=n;let o=v(r,t);i&&(t.endsWith(`package.json`)||C.has(o))&&y.push({path:`${e}/${t}`,data:new Uint8Array(f(o))})}_[e]={name:t,version:n,files:a}}let E={version:2,manifestHash:M(l(s)),lockfileHash:u===null?null:M(u),fileUrl:t.fileUrl,packages:_};y.unshift({path:o,data:new TextEncoder().encode(JSON.stringify(E))});let O=S(i(y)),k=v(t.outputDir,e,a);return await b(g(k),{recursive:!0}),await x(k,O),{path:k,packages:Object.keys(_).length,packedFiles:y.length-1,bytes:O.byteLength}}function T(){return new Set(s)}function E(e){return[.../* @__PURE__ */ new Set([...Object.keys(e.dependencies??{}),...Object.keys(e.optionalDependencies??{}),...Object.keys(e.peerDependencies??{})])]}function D(e,t){let n={root:{},packages:{}},i=/* @__PURE__ */ new Map,a=[];for(let{name:i}of r(t))a.push({from:e,name:i,onResolved:e=>void(n.root[i]=e)});for(let{from:e,name:t,onResolved:r}of a){let o=O(e,t),s=o?k(o):null;if(!o||typeof s?.version!=`string`)continue;let c=`${t}@${s.version}`;if(r(s.version),n.packages[c])continue;let l={};n.packages[c]={name:t,version:s.version,dependencies:l},i.set(c,o);for(let e of E(s))a.push({from:o,name:e,onResolved:t=>void(l[e]=t)})}return{graph:n,dirs:i}}function O(e,t){let n=e;for(;;){let e=v(n,`node_modules`,...t.split(`/`));if(d(v(e,`package.json`)))return j(e);let r=g(n);if(r===n)return null;n=r}}function k(e){try{return JSON.parse(f(v(e,`package.json`),`utf8`))}catch{return null}}function A(e){let n=[],r=i=>{for(let a of p(i,{withFileTypes:!0})){if(a.name===`node_modules`)continue;let o=v(i,a.name);if(a.isDirectory())r(o);else if(a.isFile()||a.isSymbolicLink()){let r=t(y(e,o));if(c.test(r))continue;try{n.push([r,h(o).size])}catch{}}}};return r(e),n}function j(e){try{return m(e)}catch{return e}}function M(e){return u(`sha256`).update(e).digest(`hex`)}export{C as createDependencyRecorder,T as engineOwnedPackageNames,w as writeDependencyPack};
@@ -1 +1 @@
1
- import{ROUTE_SLUGS_FILENAME as e,RUNTIME_ROUTE_SLUGS_DIRNAME as t,RUNTIME_SSR_DIRNAME as n,serverModuleChunkPath as r}from"../../shared/constants/runtime-layout.js";import{loadContentLayerConfig as i}from"../../content-layer/config.js";import{resolveContentLayerContext as a}from"../../content-layer/context.js";import{openContentLayerDatabase as o}from"../../content-layer/database/connection.js";import{createEntityStore as s}from"../../content-layer/database/entity-store.js";import{createRouteIndex as c}from"../../content-layer/plugins/utils/route-index.js";import{createContentPlugins as l}from"../../content-layer/plugins/create-content-plugins.js";import"../../content-layer/plugins/index.js";import{listAssetSourcePaths as u}from"../../content-layer/database/assets.js";import{listProblems as d,summarizeStoredProblems as f}from"../../content-layer/database/problems.js";import{listRoutePagesByFile as p}from"../../content-layer/database/files.js";import"../../content-layer/server/database.js";import{assertValidMcpToolFiles as m}from"../../content-layer/plugins/internal/mcp/build-check.js";import{compileAssetAudienceTable as h}from"../../content-layer/markdown/resolve/audience-tag.js";import{loadContentLayerState as g}from"../../content-layer/context-state.js";import{pathToFileURL as _}from"node:url";import{dirname as v,join as y}from"node:path";import{mkdir as b,writeFile as x}from"node:fs/promises";const S=`build-metadata.json`;async function C(e){let t={},{access:n}=e.context.config;t.access={requiresLogin:n?.requiresLogin===!0,rbacConfigured:n?.rbac!==void 0};let r=await h(n?.rbac,await u(e.database));return r&&(t.contentAssetAudiences={schemaVersion:1,tags:r}),t.problems=await T(e.database),Object.assign(t,await E(e)),t}function w(e){let t=e.filePath===null?void 0:{filePath:e.filePath,...e.range===null?{}:{range:e.range},...e.snippet===null?{}:{snippet:e.snippet}};return{code:e.code,category:e.category,severity:e.severity,message:e.message,...t===void 0?{}:{location:t},data:e.data}}async function T(e,{limit:t=1e4}={}){let n=await f(e),r=await d(e,{limit:t});return{schemaVersion:1,summary:{...n,truncated:n.errors+n.warnings>t},problems:r.map(w)}}async function E(e){let{context:t,database:n}=e,r=await g({context:t,database:n}),i=c(r,t.config),a=s({database:n,state:r}),o={};for(let e of t.pluginRegistry.listBuildMetadataPlugins()){let n=await e.buildMetadata?.({config:t.config,routes:i,entities:a,logger:t.logger.child(`content-layer:build-metadata:${e.id}`)});n!==void 0&&(o[e.id]=n)}return o}async function D(e){let{context:t,database:i,outputDir:a}=e,o=await g({context:t,database:i}),c=s({database:i,state:o}),l=y(a,n);await m({entities:c,loadContentModule:async e=>{let t=y(l,r(e));return await import(_(t).href)},pluginToolNames:t.pluginRegistry.listMcpTools().map(e=>e.declaration.name),...e.logger?{logger:e.logger}:{}})}async function O(n,r){let i=y(r,t,e);await b(v(i),{recursive:!0});let a=await p(n);await x(i,JSON.stringify(Object.fromEntries(a)),`utf8`)}async function k(e){let t=a({contentDir:e.contentDir,context:e.context,logger:e.logger,plugins:l(e.contentDir)});await i({context:t});let n=e.database??await o({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,runMigrations:!1});try{await D({database:n,context:t,outputDir:e.outputDir,...e.logger?{logger:e.logger}:{}});let r={formatVersion:1,sections:await C({database:n,context:t,logger:e.logger})},i=y(e.outputDir,S);return await x(i,`${JSON.stringify(r,null,2)}\n`,`utf8`),await O(n,e.outputDir),i}finally{e.database||await n.close()}}export{S as BUILD_OUTPUT_METADATA_FILENAME,C as collectBuildOutputMetadataSections,T as collectProblemsSection,k as writeBuildOutputMetadata};
1
+ import{ROUTE_SLUGS_FILENAME as e,RUNTIME_ROUTE_SLUGS_DIRNAME as t,RUNTIME_SSR_DIRNAME as n,serverModuleChunkPath as r}from"../../shared/constants/runtime-layout.js";import{openContentLayerDatabase as i}from"../../content-layer/database/connection.js";import{listAssetSourcePaths as a}from"../../content-layer/database/assets.js";import{createEntityStore as o}from"../../content-layer/database/entity-store.js";import{createRouteIndex as s}from"../../content-layer/plugins/utils/route-index.js";import{listProblems as c,summarizeStoredProblems as l}from"../../content-layer/database/problems.js";import{listRoutePagesByFile as u}from"../../content-layer/database/files.js";import"../../content-layer/server/database.js";import{loadContentLayerConfig as d}from"../../content-layer/config.js";import{resolveContentLayerContext as f}from"../../content-layer/context.js";import{createContentPlugins as p}from"../../content-layer/plugins/create-content-plugins.js";import"../../content-layer/plugins/index.js";import{loadContentLayerState as m}from"../../content-layer/context-state.js";import{compileAssetAudienceTable as h}from"../../content-layer/markdown/resolve/audience-tag.js";import{assertValidMcpToolFiles as g}from"../../content-layer/plugins/internal/mcp/build-check.js";import{pathToFileURL as _}from"node:url";import{dirname as v,join as y}from"node:path";import{mkdir as b,writeFile as x}from"node:fs/promises";const S=`build-metadata.json`;async function C(e){let t={},{access:n}=e.context.config;t.access={requiresLogin:n?.requiresLogin===!0,rbacConfigured:n?.rbac!==void 0};let r=await h(n?.rbac,await a(e.database));return r&&(t.contentAssetAudiences={schemaVersion:1,tags:r}),t.problems=await T(e.database),Object.assign(t,await E(e)),t}function w(e){let t=e.filePath===null?void 0:{filePath:e.filePath,...e.range===null?{}:{range:e.range},...e.snippet===null?{}:{snippet:e.snippet}};return{code:e.code,category:e.category,severity:e.severity,message:e.message,...t===void 0?{}:{location:t},data:e.data}}async function T(e,{limit:t=1e4}={}){let n=await l(e),r=await c(e,{limit:t});return{schemaVersion:1,summary:{...n,truncated:n.errors+n.warnings>t},problems:r.map(w)}}async function E(e){let{context:t,database:n}=e,r=await m({context:t,database:n}),i=s(r,t.config),a=o({database:n,state:r}),c={};for(let e of t.pluginRegistry.listBuildMetadataPlugins()){let n=await e.buildMetadata?.({config:t.config,routes:i,entities:a,logger:t.logger.child(`content-layer:build-metadata:${e.id}`)});n!==void 0&&(c[e.id]=n)}return c}async function D(e){let{context:t,database:i,outputDir:a}=e,s=await m({context:t,database:i}),c=o({database:i,state:s}),l=y(a,n);await g({entities:c,loadContentModule:async e=>{let t=y(l,r(e));return await import(_(t).href)},pluginToolNames:t.pluginRegistry.listMcpTools().map(e=>e.declaration.name),...e.logger?{logger:e.logger}:{}})}async function O(n,r){let i=y(r,t,e);await b(v(i),{recursive:!0});let a=await u(n);await x(i,JSON.stringify(Object.fromEntries(a)),`utf8`)}async function k(e){let t=f({contentDir:e.contentDir,context:e.context,logger:e.logger,plugins:p(e.contentDir)});await d({context:t});let n=e.database??await i({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,runMigrations:!1});try{await D({database:n,context:t,outputDir:e.outputDir,...e.logger?{logger:e.logger}:{}});let r={formatVersion:1,sections:await C({database:n,context:t,logger:e.logger})},i=y(e.outputDir,S);return await x(i,`${JSON.stringify(r,null,2)}\n`,`utf8`),await O(n,e.outputDir),i}finally{e.database||await n.close()}}export{S as BUILD_OUTPUT_METADATA_FILENAME,C as collectBuildOutputMetadataSections,T as collectProblemsSection,k as writeBuildOutputMetadata};
@@ -1 +1 @@
1
- import{formatCount as e}from"../../shared/log-format.js";import{createLogger as t}from"../../shared/logger.js";import{loadContentLayerConfig as n}from"../../content-layer/config.js";import{resolveContentLayerContext as r}from"../../content-layer/context.js";import{MaterializationError as i}from"../../content-layer/problems/problem-error.js";import{openContentLayerDatabase as a}from"../../content-layer/database/connection.js";import{createRouteIndex as o}from"../../content-layer/plugins/utils/route-index.js";import{createContentPlugins as s}from"../../content-layer/plugins/create-content-plugins.js";import"../../content-layer/plugins/index.js";import{silentReporter as c}from"../../shared/reporter.js";import{promiseMapLimit as l}from"../../shared/utils/promise-map-limit.js";import{loadStaleEntityRecords as u}from"../../content-layer/database/entities.js";import{listStaticFileRecords as d}from"../../content-layer/database/static-files.js";import{garbageCollectOrphanAssetFiles as f}from"../../content-layer/materialization/asset-reconcile.js";import{collectStaticProducerKeys as p,materializeStaticProducers as m}from"../../content-layer/materialization/static-files.js";import{loadEntityMaterializer as h}from"../../content-layer/materialization/materializer.js";import{runSearchSync as g}from"../../content-layer/ingest/search-sync.js";import{createStaticAudienceResolver as _}from"../../content-layer/static/audience.js";var v=class extends Error{name=`BuildOptionsError`};function y(e,t){if(t===`aws-lambda`&&e===`local`)throw new v(`--platform aws-lambda is incompatible with --target local. Lambda has a read-only, ephemeral filesystem; use --target cloud (a Realm DB database).`)}async function b(e){let n=e.platform??`nodejs`;y(e.target,n);let r=(e.logger??t()).child(`runtime:build`),{buildRuntime:i}=await import(`./vite-config.js`),a=await i({contentDir:e.contentDir,target:e.target,platform:n,logger:r,reporter:e.reporter??c,templateSet:e.templateSet,serverModuleSet:e.serverModuleSet,devLogin:e.devLogin??!1});return r.debug(`Built runtime`,{outputDir:a.outputDir,target:e.target,platform:n}),a}async function x(t){let v=r({contentDir:t.contentDir,context:t.context,logger:t.logger,plugins:s(t.contentDir)}),y=v.logger.child(`content-layer:entity`);await n({context:v});let b=t.database===void 0,x=t.database??await a({contentDir:v.contentDir,databaseUrl:t.databaseUrl,logger:y,migrationsDir:t.migrationsDir,runMigrations:t.runMigrations,platform:v.platform});try{let n=await h({context:v,database:x,captureRevisions:!0}),{state:r}=n,a=await u(x),s=await d(x),b=p(s),S=a.filter(e=>e.kind!==`inline`&&e.loaderId!==null&&v.pluginRegistry.getEntityLoaderById(e.loaderId)!==void 0),C=S.filter(e=>!b.has(e.key)),w=S.filter(e=>b.has(e.key)),T=async e=>{await n.materialize(e.key)},E=t.reporter??c,D=C.length;await E.run(`Building content items`,async e=>{let t=0,n=0;await l(C,8,async r=>{let a=Date.now();try{await T(r),y.debug(`materialized ${r.key} (+${Date.now()-a}ms)`)}catch(e){if(!(e instanceof i))throw e;n+=1,y.debug(`Could not materialize ${r.key}; recorded the problem`)}t+=1,e.progress(t,D)});let r=await f(v.pluginIO,{contentDir:v.contentDir,database:x,logger:y});return r.removedRows>0&&y.debug(`post-materialize asset GC removed orphan assets`,{count:r.removedRows,swept:r.sweptFilenames.length}),n},t=>{if(D===0)return`All content items are built`;let n=`Built ${e(D-t)} content ${D-t===1?`item`:`items`}`;return t>0?`${n} (${e(t)} failed)`:n});let O=await E.run(`Indexing search`,e=>g({context:v,database:x,inlineSearchables:t.inlineSearchables,materializer:n,onProgress:(t,n)=>e.progress(t,n)}),t=>`Indexed ${e(t.synced)} content ${t.synced===1?`item`:`items`} for search`);return await E.run(`Writing static files`,()=>m({io:v.pluginIO,contentDir:v.contentDir,database:x,rows:s,staleProducers:w,materializeEntity:T,resolveAudience:_({config:v.config,routes:o(r,v.config)}),logger:y}),t=>`Wrote ${e(t.files.length)} static ${t.files.length===1?`file`:`files`}`),{entityCount:D+w.length,problems:O.problems}}finally{b&&await x.close()}}export{v as BuildOptionsError,y as assertRuntimeBuildOptions,b as runBuild,x as runContentEntityBuild};
1
+ import{formatCount as e}from"../../shared/log-format.js";import{createLogger as t}from"../../shared/logger.js";import{promiseMapLimit as n}from"../../shared/utils/promise-map-limit.js";import{MaterializationError as r}from"../../content-layer/problems/problem-error.js";import{openContentLayerDatabase as i}from"../../content-layer/database/connection.js";import{loadStaleEntityRecords as a}from"../../content-layer/database/entities.js";import{createRouteIndex as o}from"../../content-layer/plugins/utils/route-index.js";import{listStaticFileRecords as s}from"../../content-layer/database/static-files.js";import{loadContentLayerConfig as c}from"../../content-layer/config.js";import{resolveContentLayerContext as l}from"../../content-layer/context.js";import{createContentPlugins as u}from"../../content-layer/plugins/create-content-plugins.js";import"../../content-layer/plugins/index.js";import{silentReporter as d}from"../../shared/reporter.js";import{garbageCollectOrphanAssetFiles as f}from"../../content-layer/materialization/asset-reconcile.js";import{loadEntityMaterializer as p}from"../../content-layer/materialization/materializer.js";import{runSearchSync as m}from"../../content-layer/ingest/search-sync.js";import{collectStaticProducerKeys as h,materializeStaticProducers as g}from"../../content-layer/materialization/static-files.js";import{createStaticAudienceResolver as _}from"../../content-layer/static/audience.js";var v=class extends Error{name=`BuildOptionsError`};function y(e,t){if(t===`aws-lambda`&&e===`local`)throw new v(`--platform aws-lambda is incompatible with --target local. Lambda has a read-only, ephemeral filesystem; use --target cloud (a Realm DB database).`)}async function b(e){let n=e.platform??`nodejs`;y(e.target,n);let r=(e.logger??t()).child(`runtime:build`),{buildRuntime:i}=await import(`./vite-config.js`),a=await i({contentDir:e.contentDir,target:e.target,platform:n,logger:r,reporter:e.reporter??d,templateSet:e.templateSet,serverModuleSet:e.serverModuleSet,devLogin:e.devLogin??!1});return r.debug(`Built runtime`,{outputDir:a.outputDir,target:e.target,platform:n}),a}async function x(t){let v=l({contentDir:t.contentDir,context:t.context,logger:t.logger,plugins:u(t.contentDir)}),y=v.logger.child(`content-layer:entity`);await c({context:v});let b=t.database===void 0,x=t.database??await i({contentDir:v.contentDir,databaseUrl:t.databaseUrl,logger:y,migrationsDir:t.migrationsDir,runMigrations:t.runMigrations,platform:v.platform});try{let i=await p({context:v,database:x,captureRevisions:!0}),{state:c}=i,l=await a(x),u=await s(x),b=h(u),S=l.filter(e=>e.kind!==`inline`&&e.loaderId!==null&&v.pluginRegistry.getEntityLoaderById(e.loaderId)!==void 0),C=S.filter(e=>!b.has(e.key)),w=S.filter(e=>b.has(e.key)),T=async e=>{await i.materialize(e.key)},E=t.reporter??d,D=C.length;await E.run(`Building content items`,async e=>{let t=0,i=0;await n(C,8,async n=>{let a=Date.now();try{await T(n),y.debug(`materialized ${n.key} (+${Date.now()-a}ms)`)}catch(e){if(!(e instanceof r))throw e;i+=1,y.debug(`Could not materialize ${n.key}; recorded the problem`)}t+=1,e.progress(t,D)});let a=await f(v.pluginIO,{contentDir:v.contentDir,database:x,logger:y});return a.removedRows>0&&y.debug(`post-materialize asset GC removed orphan assets`,{count:a.removedRows,swept:a.sweptFilenames.length}),i},t=>{if(D===0)return`All content items are built`;let n=`Built ${e(D-t)} content ${D-t===1?`item`:`items`}`;return t>0?`${n} (${e(t)} failed)`:n});let O=await E.run(`Indexing search`,e=>m({context:v,database:x,inlineSearchables:t.inlineSearchables,materializer:i,onProgress:(t,n)=>e.progress(t,n)}),t=>`Indexed ${e(t.synced)} content ${t.synced===1?`item`:`items`} for search`);return await E.run(`Writing static files`,()=>g({io:v.pluginIO,contentDir:v.contentDir,database:x,rows:u,staleProducers:w,materializeEntity:T,resolveAudience:_({config:v.config,routes:o(c,v.config)}),logger:y}),t=>`Wrote ${e(t.files.length)} static ${t.files.length===1?`file`:`files`}`),{entityCount:D+w.length,problems:O.problems}}finally{b&&await x.close()}}export{v as BuildOptionsError,y as assertRuntimeBuildOptions,b as runBuild,x as runContentEntityBuild};
@@ -1 +1 @@
1
- import{toPosixPath as e}from"../../shared/utils/to-posix-path.js";import{BUILD_ASSETS_DIRNAME as t}from"../../shared/constants/runtime-layout.js";import{createNodePlatformFs as n}from"../../platform/node/fs.js";import{loadRedoclyConfig as r}from"../../content-layer/config.js";import{listConfiguredProducts as i}from"../../content-layer/products.js";import{productConfigPath as a,readProductConfig as o}from"../../content-layer/plugins/internal/app-data/products.js";import{bundleForNode as s}from"../node-bundle.js";import{createHash as c}from"node:crypto";import{fileURLToPath as l}from"node:url";import{extname as u,resolve as d}from"node:path";const f=l(new URL(`./theme-global-style-compiler${u(import.meta.url)}`,import.meta.url)),p=e(l(new URL(`../../client/theme-global-css${u(import.meta.url)}`,import.meta.url)));async function m(n){let{module:r}=await s({...n,input:f}),i=[...await h(n.contentDir)].map(e=>{let n=r.compileThemeGlobalStyle(e),i=c(`sha256`).update(n).digest(`hex`).slice(0,10);return{palette:e??``,href:`/${t}/theme-global-${e??`default`}-${i}.css`,source:n}}),a=!1;return{name:`realm-theme-global-stylesheets`,config:()=>({define:{__REALM_THEME_GLOBAL_STYLESHEETS__:JSON.stringify({"":i[0]?.href,...Object.fromEntries(i.map(({palette:e,href:t})=>[e,t]))})}}),configResolved(e){a=!e.build.ssr},load(t){if(a||e(t)!==p)return null;let n=Object.fromEntries(i.map(({href:e,source:t})=>[e,t]));return`export const themeGlobalCss = ${JSON.stringify(n)};`},generateBundle(){if(a)for(let{href:e,source:t}of i)this.emitFile({type:`asset`,fileName:e.slice(1),source:t})}}}async function h(e){let t=n(),{config:s}=await r(e,t),c=/* @__PURE__ */ new Set([s.palette]);for(let{folder:n}of i(s)){let r=a(n),i=d(e,r);if(!await t.exists(i))continue;let{palette:s}=o(await t.readFile(i),r);s&&c.add(s)}return c}export{m as createThemeGlobalStylesheetsPlugin};
1
+ import{BUILD_ASSETS_DIRNAME as e}from"../../shared/constants/runtime-layout.js";import{createNodePlatformFs as t}from"../../platform/node/fs.js";import{toPosixPath as n}from"../../shared/utils/to-posix-path.js";import{loadRedoclyConfig as r}from"../../content-layer/config.js";import{listConfiguredProducts as i}from"../../content-layer/products.js";import{productConfigPath as a,readProductConfig as o}from"../../content-layer/plugins/internal/app-data/products.js";import{bundleForNode as s}from"../node-bundle.js";import{createHash as c}from"node:crypto";import{fileURLToPath as l}from"node:url";import{extname as u,resolve as d}from"node:path";const f=l(new URL(`./theme-global-style-compiler${u(import.meta.url)}`,import.meta.url)),p=n(l(new URL(`../../client/theme-global-css${u(import.meta.url)}`,import.meta.url)));async function m(t){let{module:r}=await s({...t,input:f}),i=[...await h(t.contentDir)].map(t=>{let n=r.compileThemeGlobalStyle(t),i=c(`sha256`).update(n).digest(`hex`).slice(0,10);return{palette:t??``,href:`/${e}/theme-global-${t??`default`}-${i}.css`,source:n}}),a=!1;return{name:`realm-theme-global-stylesheets`,config:()=>({define:{__REALM_THEME_GLOBAL_STYLESHEETS__:JSON.stringify({"":i[0]?.href,...Object.fromEntries(i.map(({palette:e,href:t})=>[e,t]))})}}),configResolved(e){a=!e.build.ssr},load(e){if(a||n(e)!==p)return null;let t=Object.fromEntries(i.map(({href:e,source:t})=>[e,t]));return`export const themeGlobalCss = ${JSON.stringify(t)};`},generateBundle(){if(a)for(let{href:e,source:t}of i)this.emitFile({type:`asset`,fileName:e.slice(1),source:t})}}}async function h(e){let n=t(),{config:s}=await r(e,n),c=/* @__PURE__ */ new Set([s.palette]);for(let{folder:t}of i(s)){let r=a(t),i=d(e,r);if(!await n.exists(i))continue;let{palette:s}=o(await n.readFile(i),r);s&&c.add(s)}return c}export{m as createThemeGlobalStylesheetsPlugin};
@@ -1,2 +1,2 @@
1
- import{toPosixPath as e}from"../../shared/utils/to-posix-path.js";import{discoverContentDependencyPolicy as t}from"../content-dependency-policy.js";import{createResolvedTemplateSetProvider as n}from"../../content-layer/templates/template-set.js";import{getEnvFileDefaults as r}from"../../shared/public-env.js";import{BUILD_ASSETS_DIRNAME as i,CLIENT_TEMPLATE_KEYS_FILENAME as a,RUNTIME_CLIENT_DIRNAME as o,RUNTIME_HOST_CHUNKS_DIRNAME as s,RUNTIME_MANIFEST_FILENAME as c,RUNTIME_SSR_DIRNAME as l,RUNTIME_SSR_ENTRY_FILENAME as u,RUNTIME_SUBPROCESS_CHILD_FILENAME as d,getRuntimeOutputDir as f,serverModuleChunkPath as p}from"../../shared/constants/runtime-layout.js";import{createEmptyServerModuleSet as m}from"../../content-layer/server-modules/module-set.js";import{formatBytes as h,formatCount as g}from"../../shared/log-format.js";import{getPathPrefix as _}from"../../shared/path-prefix.js";import{resolveRuntimeEntryFiles as v,resolveRuntimeServerModuleFiles as y,resolveRuntimeTemplateFiles as b}from"../runtime-files.js";import{VITE_LOG_STREAM as ee}from"../../shared/constants/log-streams.js";import{DEV_LOGIN_DEFINE as te,ENV_FILE_DEFAULTS_DEFINE as x,PATH_PREFIX_DEFINE as S,REDOCLY_SSR_NO_EXTERNAL as C,TEMPLATE_IDS_DEFINE as ne,createBaseViteConfig as re,createDefineValues as w,createThemeSourcePlugin as T,createViteCustomLogger as E}from"../vite-config.base.js";import{PLATFORM_CONFIG as D}from"./constants/platform.js";import{createDependencyRecorder as O,writeDependencyPack as k}from"./dependency-pack.js";import{createThemeGlobalStylesheetsPlugin as ie}from"./theme-global-stylesheets.js";import{createRequire as ae}from"node:module";import{fileURLToPath as oe}from"node:url";import{existsSync as A}from"node:fs";import{dirname as j,join as M,relative as N,resolve as P}from"node:path";import{mkdir as F,rm as I,writeFile as L}from"node:fs/promises";import{build as R}from"vite";async function z(e){let t=f(e.contentDir),r=M(t,o),i=M(t,l),a=M(i,u),s=M(r,`.vite`,`manifest.json`),d=M(t,c),p=v(e.contentDir),m=n(e.templateSet),h=b(e.templateSet,e.contentDir);await F(t,{recursive:!0});let g=O(),_=await e.reporter.run(`Compiling the theme styles`,()=>ie(e),()=>`Compiled the theme styles`);return await e.reporter.run(`Building client bundle`,()=>R(Y({contentDir:e.contentDir,logger:e.logger,entryFiles:p,templateSetProvider:m,variant:`client`,plugins:[g.plugin,_]})),e=>`Built client bundle ${$(e)}`),await e.reporter.run(`Building SSR bundle`,()=>R(Y({contentDir:e.contentDir,logger:e.logger,entryFiles:p,templateSetProvider:m,serverModuleSet:e.serverModuleSet,variant:`ssr`,plugins:[g.plugin,_]})),e=>`Built SSR bundle ${$(e)}`),await e.reporter.run(`Writing the dependency pack`,()=>se(e.contentDir,t,g.files,e.logger),e=>e?`Wrote the dependency pack: ${e.packages} packages, ${e.packedFiles} files, ${(e.bytes/1048576).toFixed(1)} MB`:`No dependency pack: the project declares no dependencies`),await B(t),await e.reporter.run(`Building server entry`,()=>R(Q({contentDir:e.contentDir,logger:e.logger,target:e.target,platform:e.platform,templateFiles:h,devLogin:e.devLogin})),e=>`Built server entry ${$(e)}`),await V(t),await L(d,JSON.stringify({target:e.target,platform:e.platform,clientDir:r,serverEntryPath:a,viteManifestPath:s},null,2)),{outputDir:t,clientDir:r,serverEntryPath:a,manifestPath:d,target:e.target,platform:e.platform,viteManifestPath:s}}async function B(e){await I(M(e,s),{recursive:!0,force:!0})}async function V(e){await L(M(e,`package.json`),`${JSON.stringify({type:`module`})}\n`)}const H=`\0realm-server-replay-stub`;function U(){return{name:`realm-server-replay-stub`,enforce:`pre`,resolveId(e){return e===`@redocly/replay`||e.startsWith(`@redocly/replay/`)?H:null},load(e){return e===H?[`const stub = (name) => () => {`,` throw new Error(`,` '@redocly/replay is excluded from server bundles (client-only); <' + name + '> cannot render on the server.',`,` );`,`};`,`export const EmbeddedReplay = stub('EmbeddedReplay');`,`export const ReplayOverlay = stub('ReplayOverlay');`].join(`
2
- `):null}}}function W(t,n){let r=``;return{name:`realm-template-manifest-keys`,configResolved(e){r=e.root},async generateBundle(){let i={};for(let a of b(await t.current(),n)){let t=await this.resolve(a.filePath);t&&(i[a.templateId]=e(N(r,t.id)))}this.emitFile({type:`asset`,fileName:`.vite/${a}`,source:JSON.stringify(i)})}}}const G=ae(import.meta.url),K=e(M(j(G.resolve(`@redocly/theme/package.json`)),`src/`));function q(t){return e(t).startsWith(K)}async function se(e,t,n,r){try{return await k({contentDir:e,outputDir:t,recorded:n})}catch(e){return r.warn(`Dependency pack not written: ${e instanceof Error?e.message:String(e)}`),null}}const J=(t,n)=>{t.code===`EVAL`&&t.id&&e(t.id).includes(`/node_modules/`)||n(t)};function Y(n){let r=f(n.contentDir),a=n.variant===`client`,s=t(n.contentDir,{viteManagedDependencies:C}),c=re({contentDir:n.contentDir,logger:n.logger,templateSetProvider:n.templateSetProvider,serverModuleSet:n.serverModuleSet,enableLazyStaticData:a,styledComponentsDependencies:[...s.noExternal,...s.external],styledComponentsRoots:s.packageRoots}),d=new Map(y(n.serverModuleSet??m(),n.contentDir).map(t=>[e(t.filePath),p(t.key)]));return{configFile:!1,envDir:!1,...c,define:w({enableLazyStaticData:a,production:!0,themePathPrefixFromGlobal:!0}),plugins:[...c.plugins??[],...n.plugins??[],W(n.templateSetProvider,n.contentDir),...a?[]:[U()]],ssr:a?void 0:{noExternal:!0},experimental:{...c.experimental,renderBuiltUrl:(e,{hostType:t})=>t===`js`?{runtime:`(globalThis.__REALM_PATH_PREFIX__ ?? "") + ${JSON.stringify(`/${e}`)}`}:{relative:!0}},build:{copyPublicDir:!1,emptyOutDir:!0,...a?{assetsDir:i,chunkSizeWarningLimit:5e3,manifest:!0,outDir:M(r,o),rollupOptions:{input:n.entryFiles.clientEntryPath,onwarn:J,output:{assetFileNames:`${i}/[name]-[hash][extname]`,codeSplitting:{groups:[{name:`app`,tags:[`$initial`],priority:2},{name:`theme`,test:e=>q(e)&&!e.includes(`/markdoc/tags/`),minShareCount:2,priority:1}]}},treeshake:{moduleSideEffects:e=>!q(e)&&void 0}}}:{minify:!0,manifest:!0,outDir:M(r,l),rollupOptions:{external:[/^node:/],onwarn:J,output:{entryFileNames:u,chunkFileNames:e=>e.facadeModuleId&&d.get(e.facadeModuleId)||`assets/[name]-[hash].mjs`}},ssr:n.entryFiles.serverEntryPath}}}}const X=`subprocess-child`;function Z(e,t){let n=P(e,`${t}.ts`),r=P(e,`${t}.js`);if(A(n))return n;if(A(r))return r;throw Error(`Host entry source not found for "${t}". Expected one of: ${n}, ${r}.`)}function Q(e){let t=P(j(oe(import.meta.url)),`../../server`),{entryBasename:n,outputFilename:i}=D[e.platform],a=Z(t,n),o=Z(t,`subprocess/child-entry`);return{configFile:!1,envDir:!1,appType:`custom`,clearScreen:!1,logLevel:e.logger.isDebugEnabled(`runtime:vite`)?`info`:`warn`,customLogger:E(e.logger.child(ee)),define:{...w({enableLazyStaticData:!1,production:!0}),[ne]:JSON.stringify(e.templateFiles.map(e=>e.templateId)),..._()?{[S]:JSON.stringify(_())}:{},[te]:JSON.stringify(e.devLogin===!0),[x]:JSON.stringify(r())},plugins:[U(),T()],publicDir:!1,root:e.contentDir,ssr:{noExternal:!0},build:{copyPublicDir:!1,emptyOutDir:!1,minify:!0,outDir:f(e.contentDir),rollupOptions:{input:{[n]:a,[X]:o},external:[/^node:/],treeshake:{moduleSideEffects:e=>!q(e)&&void 0},output:{entryFileNames:e=>e.name===X?d:i,chunkFileNames:`assets/[name]-[hash].mjs`}},ssr:!0,target:`node22`}}}function $(e){let t=Array.isArray(e)?e:`output`in e?[e]:[],n=0,r=0;for(let e of t.flatMap(e=>e.output)){n+=1;let t=e.type===`chunk`?e.code:e.source;r+=typeof t==`string`?Buffer.byteLength(t):t.byteLength}return`(${g(n)} ${n===1?`file`:`files`}, ${h(r)})`}export{z as buildRuntime,B as cleanStaleHostOutputs,Y as createBundleBuildConfig,Q as createHttpServerBuildConfig,U as createServerReplayStubPlugin,V as writeRuntimePackageManifest};
1
+ import{getPathPrefix as e}from"../../shared/path-prefix.js";import{formatBytes as t,formatCount as n}from"../../shared/log-format.js";import{BUILD_ASSETS_DIRNAME as r,CLIENT_TEMPLATE_KEYS_FILENAME as i,RUNTIME_CLIENT_DIRNAME as a,RUNTIME_HOST_CHUNKS_DIRNAME as o,RUNTIME_MANIFEST_FILENAME as s,RUNTIME_SSR_DIRNAME as c,RUNTIME_SSR_ENTRY_FILENAME as l,RUNTIME_SUBPROCESS_CHILD_FILENAME as u,getRuntimeOutputDir as d,serverModuleChunkPath as f}from"../../shared/constants/runtime-layout.js";import{toPosixPath as p}from"../../shared/utils/to-posix-path.js";import{getEnvFileDefaults as m}from"../../shared/public-env.js";import{createResolvedTemplateSetProvider as h}from"../../content-layer/templates/template-set.js";import{discoverContentDependencyPolicy as g}from"../content-dependency-policy.js";import{createEmptyServerModuleSet as _}from"../../content-layer/server-modules/module-set.js";import{resolveRuntimeEntryFiles as ee,resolveRuntimeServerModuleFiles as te,resolveRuntimeTemplateFiles as v}from"../runtime-files.js";import{VITE_LOG_STREAM as y}from"../../shared/constants/log-streams.js";import{DEV_LOGIN_DEFINE as b,ENV_FILE_DEFAULTS_DEFINE as x,PATH_PREFIX_DEFINE as S,REDOCLY_SSR_NO_EXTERNAL as C,TEMPLATE_IDS_DEFINE as w,createBaseViteConfig as T,createDefineValues as E,createThemeSourcePlugin as D,createViteCustomLogger as O}from"../vite-config.base.js";import{PLATFORM_CONFIG as k}from"./constants/platform.js";import{createDependencyRecorder as ne,writeDependencyPack as re}from"./dependency-pack.js";import{createThemeGlobalStylesheetsPlugin as ie}from"./theme-global-stylesheets.js";import{createRequire as ae}from"node:module";import{fileURLToPath as oe}from"node:url";import{existsSync as A}from"node:fs";import{dirname as j,join as M,relative as N,resolve as P}from"node:path";import{mkdir as F,rm as I,writeFile as L}from"node:fs/promises";import{build as R}from"vite";async function z(e){let t=d(e.contentDir),n=M(t,a),r=M(t,c),i=M(r,l),o=M(n,`.vite`,`manifest.json`),u=M(t,s),f=ee(e.contentDir),p=h(e.templateSet),m=v(e.templateSet,e.contentDir);await F(t,{recursive:!0});let g=ne(),_=await e.reporter.run(`Compiling the theme styles`,()=>ie(e),()=>`Compiled the theme styles`);return await e.reporter.run(`Building client bundle`,()=>R(Y({contentDir:e.contentDir,logger:e.logger,entryFiles:f,templateSetProvider:p,variant:`client`,plugins:[g.plugin,_]})),e=>`Built client bundle ${$(e)}`),await e.reporter.run(`Building SSR bundle`,()=>R(Y({contentDir:e.contentDir,logger:e.logger,entryFiles:f,templateSetProvider:p,serverModuleSet:e.serverModuleSet,variant:`ssr`,plugins:[g.plugin,_]})),e=>`Built SSR bundle ${$(e)}`),await e.reporter.run(`Writing the dependency pack`,()=>se(e.contentDir,t,g.files,e.logger),e=>e?`Wrote the dependency pack: ${e.packages} packages, ${e.packedFiles} files, ${(e.bytes/1048576).toFixed(1)} MB`:`No dependency pack: the project declares no dependencies`),await B(t),await e.reporter.run(`Building server entry`,()=>R(Q({contentDir:e.contentDir,logger:e.logger,target:e.target,platform:e.platform,templateFiles:m,devLogin:e.devLogin})),e=>`Built server entry ${$(e)}`),await V(t),await L(u,JSON.stringify({target:e.target,platform:e.platform,clientDir:n,serverEntryPath:i,viteManifestPath:o},null,2)),{outputDir:t,clientDir:n,serverEntryPath:i,manifestPath:u,target:e.target,platform:e.platform,viteManifestPath:o}}async function B(e){await I(M(e,o),{recursive:!0,force:!0})}async function V(e){await L(M(e,`package.json`),`${JSON.stringify({type:`module`})}\n`)}const H=`\0realm-server-replay-stub`;function U(){return{name:`realm-server-replay-stub`,enforce:`pre`,resolveId(e){return e===`@redocly/replay`||e.startsWith(`@redocly/replay/`)?H:null},load(e){return e===H?[`const stub = (name) => () => {`,` throw new Error(`,` '@redocly/replay is excluded from server bundles (client-only); <' + name + '> cannot render on the server.',`,` );`,`};`,`export const EmbeddedReplay = stub('EmbeddedReplay');`,`export const ReplayOverlay = stub('ReplayOverlay');`].join(`
2
+ `):null}}}function W(e,t){let n=``;return{name:`realm-template-manifest-keys`,configResolved(e){n=e.root},async generateBundle(){let r={};for(let i of v(await e.current(),t)){let e=await this.resolve(i.filePath);e&&(r[i.templateId]=p(N(n,e.id)))}this.emitFile({type:`asset`,fileName:`.vite/${i}`,source:JSON.stringify(r)})}}}const G=ae(import.meta.url),K=p(M(j(G.resolve(`@redocly/theme/package.json`)),`src/`));function q(e){return p(e).startsWith(K)}async function se(e,t,n,r){try{return await re({contentDir:e,outputDir:t,recorded:n})}catch(e){return r.warn(`Dependency pack not written: ${e instanceof Error?e.message:String(e)}`),null}}const J=(e,t)=>{e.code===`EVAL`&&e.id&&p(e.id).includes(`/node_modules/`)||t(e)};function Y(e){let t=d(e.contentDir),n=e.variant===`client`,i=g(e.contentDir,{viteManagedDependencies:C}),o=T({contentDir:e.contentDir,logger:e.logger,templateSetProvider:e.templateSetProvider,serverModuleSet:e.serverModuleSet,enableLazyStaticData:n,styledComponentsDependencies:[...i.noExternal,...i.external],styledComponentsRoots:i.packageRoots}),s=new Map(te(e.serverModuleSet??_(),e.contentDir).map(e=>[p(e.filePath),f(e.key)]));return{configFile:!1,envDir:!1,...o,define:E({enableLazyStaticData:n,production:!0,themePathPrefixFromGlobal:!0}),plugins:[...o.plugins??[],...e.plugins??[],W(e.templateSetProvider,e.contentDir),...n?[]:[U()]],ssr:n?void 0:{noExternal:!0},experimental:{...o.experimental,renderBuiltUrl:(e,{hostType:t})=>t===`js`?{runtime:`(globalThis.__REALM_PATH_PREFIX__ ?? "") + ${JSON.stringify(`/${e}`)}`}:{relative:!0}},build:{copyPublicDir:!1,emptyOutDir:!0,...n?{assetsDir:r,chunkSizeWarningLimit:5e3,manifest:!0,outDir:M(t,a),rollupOptions:{input:e.entryFiles.clientEntryPath,onwarn:J,output:{assetFileNames:`${r}/[name]-[hash][extname]`,codeSplitting:{groups:[{name:`app`,tags:[`$initial`],priority:2},{name:`theme`,test:e=>q(e)&&!e.includes(`/markdoc/tags/`),minShareCount:2,priority:1}]}},treeshake:{moduleSideEffects:e=>!q(e)&&void 0}}}:{minify:!0,manifest:!0,outDir:M(t,c),rollupOptions:{external:[/^node:/],onwarn:J,output:{entryFileNames:l,chunkFileNames:e=>e.facadeModuleId&&s.get(e.facadeModuleId)||`assets/[name]-[hash].mjs`}},ssr:e.entryFiles.serverEntryPath}}}}const X=`subprocess-child`;function Z(e,t){let n=P(e,`${t}.ts`),r=P(e,`${t}.js`);if(A(n))return n;if(A(r))return r;throw Error(`Host entry source not found for "${t}". Expected one of: ${n}, ${r}.`)}function Q(t){let n=P(j(oe(import.meta.url)),`../../server`),{entryBasename:r,outputFilename:i}=k[t.platform],a=Z(n,r),o=Z(n,`subprocess/child-entry`);return{configFile:!1,envDir:!1,appType:`custom`,clearScreen:!1,logLevel:t.logger.isDebugEnabled(`runtime:vite`)?`info`:`warn`,customLogger:O(t.logger.child(y)),define:{...E({enableLazyStaticData:!1,production:!0}),[w]:JSON.stringify(t.templateFiles.map(e=>e.templateId)),...e()?{[S]:JSON.stringify(e())}:{},[b]:JSON.stringify(t.devLogin===!0),[x]:JSON.stringify(m())},plugins:[U(),D()],publicDir:!1,root:t.contentDir,ssr:{noExternal:!0},build:{copyPublicDir:!1,emptyOutDir:!1,minify:!0,outDir:d(t.contentDir),rollupOptions:{input:{[r]:a,[X]:o},external:[/^node:/],treeshake:{moduleSideEffects:e=>!q(e)&&void 0},output:{entryFileNames:e=>e.name===X?u:i,chunkFileNames:`assets/[name]-[hash].mjs`}},ssr:!0,target:`node22`}}}function $(e){let r=Array.isArray(e)?e:`output`in e?[e]:[],i=0,a=0;for(let e of r.flatMap(e=>e.output)){i+=1;let t=e.type===`chunk`?e.code:e.source;a+=typeof t==`string`?Buffer.byteLength(t):t.byteLength}return`(${n(i)} ${i===1?`file`:`files`}, ${t(a)})`}export{z as buildRuntime,B as cleanStaleHostOutputs,Y as createBundleBuildConfig,Q as createHttpServerBuildConfig,U as createServerReplayStubPlugin,V as writeRuntimePackageManifest};
@@ -1 +1 @@
1
- import{compareStrings as e}from"../../shared/utils/compare-strings.js";import{createLogger as t}from"../../shared/logger.js";import{entities as n,staticFiles as r}from"../../content-layer/database/schema.js";import{MaterializationError as i}from"../../content-layer/problems/problem-error.js";import{loadAttachedRouteSlugs as a}from"../../content-layer/database/route-deps.js";import{and as o,count as s,eq as c,inArray as l,ne as u,notInArray as d,sql as f}from"drizzle-orm";function p(e){let n=(e.logger??t()).child(`runtime:content-build`),r=`idle`,a=[],o=!1,s=!1,c=null,l=/* @__PURE__ */ new Set,u=()=>{c!==null||r!==`running`||s||(c=d().finally(()=>{c=null,u()}))},d=async()=>{try{for(;r===`running`&&!s;){if(!o){a=(await e.loadQueue()).filter(e=>!l.has(e)),o=!0;continue}let t=a.shift();if(t===void 0){r=`idle`,o=!1,e.onProgress?.({kind:`state`,state:r});break}try{await e.materialize(t)}catch(e){if(!(e instanceof i))throw e;l.add(t),n.debug(`Could not materialize "${t}"; recorded the problem and moved on`)}e.onProgress?.({kind:`entity`}),await new Promise(e=>setImmediate(e))}}catch(t){let i=t instanceof Error?t.message:String(t);n.error(`Stopped the content build: ${i}`),a=[],o=!1,r===`running`&&(r=`idle`,e.onProgress?.({kind:`state`,state:r}))}};return{start(){r!==`running`&&(r=`running`,e.onProgress?.({kind:`state`,state:r}),u())},pause(){r===`running`&&(r=`paused`,e.onProgress?.({kind:`state`,state:r}))},async status(){let t=await e.loadProgress([...l]);return{state:r,done:t.done,total:t.total,failed:t.failed}},onIngestCycleStart(){s=!0},onIngestCycleEnd(){s=!1,l.clear(),o=!1,u()}}}function m(e){let t=f`(select ${r.entityKey} from ${r} where ${r.kind} = 'producer' and ${r.entityKey} is not null)`;return o(u(n.kind,`inline`),c(n.isCurrent,1),l(n.loaderId,[...e]),d(n.key,t))}async function h(t){let r=t.entityLoaderIds();if(r.length===0)return[];let i=await t.database.db.select({key:n.key}).from(n).where(o(c(n.status,`stale`),m(r))).orderBy(n.key),s=await a(t.database,i.map(e=>e.key));return i.map(e=>({key:e.key,slug:s.get(e.key)})).sort((t,n)=>{if(t.slug===void 0||n.slug===void 0)return t.slug===n.slug?e(t.key,n.key):t.slug===void 0?1:-1;let r=e(t.slug,n.slug);return r===0?e(t.key,n.key):r}).map(e=>e.key)}async function g(e,t){let r=e.entityLoaderIds();if(r.length===0)return{done:0,total:0,failed:0};let i=m(r),a=await e.database.db.select({status:n.status,count:s()}).from(n).where(i).groupBy(n.status),c=0,d=0;for(let e of a)d+=e.count,e.status===`ready`&&(c+=e.count);let f=0;if(t.length>0){let r=new Set(t);f=(await e.database.db.select({key:n.key}).from(n).where(t.length>50?o(u(n.status,`ready`),i):o(l(n.key,[...r]),u(n.status,`ready`),i))).filter(e=>r.has(e.key)).length}return{done:c,total:d,failed:f}}export{p as createDevContentBuild,g as loadContentBuildProgress,h as loadContentBuildQueue};
1
+ import{compareStrings as e}from"../../shared/utils/compare-strings.js";import{createLogger as t}from"../../shared/logger.js";import{MaterializationError as n}from"../../content-layer/problems/problem-error.js";import{entities as r,staticFiles as i}from"../../content-layer/database/schema.js";import{loadAttachedRouteSlugs as a}from"../../content-layer/database/route-deps.js";import{and as o,count as s,eq as c,inArray as l,ne as u,notInArray as d,sql as f}from"drizzle-orm";function p(e){let r=(e.logger??t()).child(`runtime:content-build`),i=`idle`,a=[],o=!1,s=!1,c=null,l=/* @__PURE__ */ new Set,u=()=>{c!==null||i!==`running`||s||(c=d().finally(()=>{c=null,u()}))},d=async()=>{try{for(;i===`running`&&!s;){if(!o){a=(await e.loadQueue()).filter(e=>!l.has(e)),o=!0;continue}let t=a.shift();if(t===void 0){i=`idle`,o=!1,e.onProgress?.({kind:`state`,state:i});break}try{await e.materialize(t)}catch(e){if(!(e instanceof n))throw e;l.add(t),r.debug(`Could not materialize "${t}"; recorded the problem and moved on`)}e.onProgress?.({kind:`entity`}),await new Promise(e=>setImmediate(e))}}catch(t){let n=t instanceof Error?t.message:String(t);r.error(`Stopped the content build: ${n}`),a=[],o=!1,i===`running`&&(i=`idle`,e.onProgress?.({kind:`state`,state:i}))}};return{start(){i!==`running`&&(i=`running`,e.onProgress?.({kind:`state`,state:i}),u())},pause(){i===`running`&&(i=`paused`,e.onProgress?.({kind:`state`,state:i}))},async status(){let t=await e.loadProgress([...l]);return{state:i,done:t.done,total:t.total,failed:t.failed}},onIngestCycleStart(){s=!0},onIngestCycleEnd(){s=!1,l.clear(),o=!1,u()}}}function m(e){let t=f`(select ${i.entityKey} from ${i} where ${i.kind} = 'producer' and ${i.entityKey} is not null)`;return o(u(r.kind,`inline`),c(r.isCurrent,1),l(r.loaderId,[...e]),d(r.key,t))}async function h(t){let n=t.entityLoaderIds();if(n.length===0)return[];let i=await t.database.db.select({key:r.key}).from(r).where(o(c(r.status,`stale`),m(n))).orderBy(r.key),s=await a(t.database,i.map(e=>e.key));return i.map(e=>({key:e.key,slug:s.get(e.key)})).sort((t,n)=>{if(t.slug===void 0||n.slug===void 0)return t.slug===n.slug?e(t.key,n.key):t.slug===void 0?1:-1;let r=e(t.slug,n.slug);return r===0?e(t.key,n.key):r}).map(e=>e.key)}async function g(e,t){let n=e.entityLoaderIds();if(n.length===0)return{done:0,total:0,failed:0};let i=m(n),a=await e.database.db.select({status:r.status,count:s()}).from(r).where(i).groupBy(r.status),c=0,d=0;for(let e of a)d+=e.count,e.status===`ready`&&(c+=e.count);let f=0;if(t.length>0){let n=new Set(t);f=(await e.database.db.select({key:r.key}).from(r).where(t.length>50?o(u(r.status,`ready`),i):o(l(r.key,[...n]),u(r.status,`ready`),i))).filter(e=>n.has(e.key)).length}return{done:c,total:d,failed:f}}export{p as createDevContentBuild,g as loadContentBuildProgress,h as loadContentBuildQueue};
@@ -1 +1 @@
1
- import{captureSnippet as e,splitSourceLines as t}from"../../../shared/utils/capture-snippet.js";import{listProblems as n,summarizeStoredProblems as r}from"../../../content-layer/database/problems.js";import{contentUpdateState as i}from"./content-update-state-route.js";import{narrowRangeToTarget as a}from"../../../shared/utils/narrow-range-to-target.js";import{DEV_PROBLEMS_PATH as o}from"../../../shared/constants/dev-problems.js";const s=500;function c(s,c){let l={generation:-1,byPath:/* @__PURE__ */ new Map},u=e=>(l.generation!==e&&(l={generation:e,byPath:/* @__PURE__ */ new Map}),l.byPath);s.get(o,async o=>{let{errors:s,warnings:l}=await r(c.database),d={errors:s,warnings:l,generation:i.generation};if(o.req.query(`list`)!==`1`)return o.json(d);let f=await n(c.database,{limit:500}),p=u(i.generation),m=async n=>{let r={range:n.range,snippet:n.snippet};if(n.snippet!==null||c.readSourceFile===void 0||n.filePath===null||n.range===null)return r;let i=p.get(n.filePath);if(i===void 0){let e=await c.readSourceFile(n.filePath);i=e===null?null:t(e),p.set(n.filePath,i)}if(i===null)return r;let o=n.data?.raw,s=typeof o==`string`?a(i,n.range,o):n.range;return{range:s,snippet:e(i,s)}},h=[];for(let e of f)h.push({code:e.code,category:e.category,severity:e.severity,message:e.message,filePath:e.filePath,...await m(e)});let g={...d,truncated:s+l>f.length,problems:h};return o.json(g)})}export{s as MAX_DEV_LIST_PROBLEMS,c as registerDevProblemsRoute};
1
+ import{listProblems as e,summarizeStoredProblems as t}from"../../../content-layer/database/problems.js";import{captureSnippet as n,splitSourceLines as r}from"../../../shared/utils/capture-snippet.js";import{DEV_PROBLEMS_PATH as i}from"../../../shared/constants/dev-problems.js";import{contentUpdateState as a}from"./content-update-state-route.js";import{narrowRangeToTarget as o}from"../../../shared/utils/narrow-range-to-target.js";const s=500;function c(s,c){let l={generation:-1,byPath:/* @__PURE__ */ new Map},u=e=>(l.generation!==e&&(l={generation:e,byPath:/* @__PURE__ */ new Map}),l.byPath);s.get(i,async i=>{let{errors:s,warnings:l}=await t(c.database),d={errors:s,warnings:l,generation:a.generation};if(i.req.query(`list`)!==`1`)return i.json(d);let f=await e(c.database,{limit:500}),p=u(a.generation),m=async e=>{let t={range:e.range,snippet:e.snippet};if(e.snippet!==null||c.readSourceFile===void 0||e.filePath===null||e.range===null)return t;let i=p.get(e.filePath);if(i===void 0){let t=await c.readSourceFile(e.filePath);i=t===null?null:r(t),p.set(e.filePath,i)}if(i===null)return t;let a=e.data?.raw,s=typeof a==`string`?o(i,e.range,a):e.range;return{range:s,snippet:n(i,s)}},h=[];for(let e of f)h.push({code:e.code,category:e.category,severity:e.severity,message:e.message,filePath:e.filePath,...await m(e)});let g={...d,truncated:s+l>f.length,problems:h};return i.json(g)})}export{s as MAX_DEV_LIST_PROBLEMS,c as registerDevProblemsRoute};
@@ -1,4 +1,4 @@
1
- import{isObject as e}from"../../../shared/utils/is-object.js";import{normalizeRoutePath as t}from"../../../shared/utils/routes/normalize-route-path.js";import{stripPathPrefix as n,withPathPrefix as r}from"../../../shared/path-prefix.js";import"../../../content-layer/plugins/internal/api-docs/server/shared.js";import{resolveDefaultVersionAlias as i,resolveVersionlessRedirect as a,toVersionlessSlug as o}from"../../../content-layer/versions/redirect.js";import{createRuntimeEntityStore as s,loadStoredRouteWithDeps as c}from"../../../server/content.js";import{DEV_PAGE_FOR_SOURCE_PATH as l,DEV_SOURCE_FOR_PAGE_PATH as u}from"../../../shared/constants/dev-source-sync.js";import{createApiSourceMap as d}from"../../../content-layer/plugins/internal/api-docs/server/source-map.js";import{sql as f}from"drizzle-orm";function p(i,o){let f=s(o),p=/* @__PURE__ */ new Map,v=async(t,n)=>{let r=await o.readSourceFile(n);if(r===null)return;let i=await f.get(t),a=p.get(t);if(a&&i?.status===`ready`&&i.dataHash===a.dataHash&&a.text===r)return a.page;let s=await f.load(t);if(!e(s)||!Array.isArray(s.items)||typeof s.basePath!=`string`)return;let c={basePath:s.basePath,map:await d(s.items,n,r)},l=(await f.get(t))?.dataHash;return l&&p.set(t,{dataHash:l,text:r,page:c}),c},y=async e=>{let{route:t,dependencies:n}=e;if(t.pluginId!==`internal.api-docs`||t.sourcePath===null)return;let r=n.find(e=>e.key===`apiDocs:render`&&e.dependencyType===`entity`);if(r)try{return await v(r.target,t.sourcePath)}catch(e){o.logger.warn(`Source sync could not map ${t.sourcePath}`,{err:e});return}};i.get(l,async e=>{e.header(`Cache-Control`,`no-store`);let t=e.req.query(`path`);if(!t)return e.json({error:`Missing the "path" query parameter.`},400);let n=await h(o.database,t),i=n===null?null:await c(o.database,n);if(!i)return e.json({url:null});let s=await a(o.database.db,i.route)??i.route.slug,l=Number(e.req.query(`line`)),u=Number.isInteger(l)&&l>0?await y(i):void 0,d=u?.map.linkAtLine(l),f=u&&d&&_(s,u.basePath,d)||s;return e.json({url:r(f)})}),i.get(u,async e=>{e.header(`Cache-Control`,`no-store`);let r=e.req.query(`url`);if(!r)return e.json({error:`Missing the "url" query parameter.`},400);let{pathname:i}=new URL(r,`http://realm.invalid`),a=t(n(i)??i),s=await m(o.database,a),c=s?.loaded.route.sourcePath??null;if(!s||c===null)return e.json({path:null});let l=await y(s.loaded),u=l?.map.positionOfLink(g(s.publicSlug,l.basePath,a));return e.json({path:c,position:u})})}async function m(e,t){let n=await c(e,t);if(n)return{loaded:n,publicSlug:n.route.slug};let r=await i(e.db,t,t=>c(e,t));if(r?.kind!==`serve`)return null;let{route:a}=r.loaded;return{loaded:r.loaded,publicSlug:o(a.slug,r.versionGroup,r.version,r.locale)}}async function h(e,t){let[n]=await e.db.all(f`
1
+ import{stripPathPrefix as e,withPathPrefix as t}from"../../../shared/path-prefix.js";import{isObject as n}from"../../../shared/utils/is-object.js";import"../../../content-layer/plugins/internal/api-docs/server/shared.js";import{DEV_PAGE_FOR_SOURCE_PATH as r,DEV_SOURCE_FOR_PAGE_PATH as i}from"../../../shared/constants/dev-source-sync.js";import{normalizeRoutePath as a}from"../../../shared/utils/routes/normalize-route-path.js";import{resolveDefaultVersionAlias as o,resolveVersionlessRedirect as s,toVersionlessSlug as c}from"../../../content-layer/versions/redirect.js";import{createRuntimeEntityStore as l,loadStoredRouteWithDeps as u}from"../../../server/content.js";import{createApiSourceMap as d}from"../../../content-layer/plugins/internal/api-docs/server/source-map.js";import{sql as f}from"drizzle-orm";function p(o,c){let f=l(c),p=/* @__PURE__ */ new Map,v=async(e,t)=>{let r=await c.readSourceFile(t);if(r===null)return;let i=await f.get(e),a=p.get(e);if(a&&i?.status===`ready`&&i.dataHash===a.dataHash&&a.text===r)return a.page;let o=await f.load(e);if(!n(o)||!Array.isArray(o.items)||typeof o.basePath!=`string`)return;let s={basePath:o.basePath,map:await d(o.items,t,r)},l=(await f.get(e))?.dataHash;return l&&p.set(e,{dataHash:l,text:r,page:s}),s},y=async e=>{let{route:t,dependencies:n}=e;if(t.pluginId!==`internal.api-docs`||t.sourcePath===null)return;let r=n.find(e=>e.key===`apiDocs:render`&&e.dependencyType===`entity`);if(r)try{return await v(r.target,t.sourcePath)}catch(e){c.logger.warn(`Source sync could not map ${t.sourcePath}`,{err:e});return}};o.get(r,async e=>{e.header(`Cache-Control`,`no-store`);let n=e.req.query(`path`);if(!n)return e.json({error:`Missing the "path" query parameter.`},400);let r=await h(c.database,n),i=r===null?null:await u(c.database,r);if(!i)return e.json({url:null});let a=await s(c.database.db,i.route)??i.route.slug,o=Number(e.req.query(`line`)),l=Number.isInteger(o)&&o>0?await y(i):void 0,d=l?.map.linkAtLine(o),f=l&&d&&_(a,l.basePath,d)||a;return e.json({url:t(f)})}),o.get(i,async t=>{t.header(`Cache-Control`,`no-store`);let n=t.req.query(`url`);if(!n)return t.json({error:`Missing the "url" query parameter.`},400);let{pathname:r}=new URL(n,`http://realm.invalid`),i=a(e(r)??r),o=await m(c.database,i),s=o?.loaded.route.sourcePath??null;if(!o||s===null)return t.json({path:null});let l=await y(o.loaded),u=l?.map.positionOfLink(g(o.publicSlug,l.basePath,i));return t.json({path:s,position:u})})}async function m(e,t){let n=await u(e,t);if(n)return{loaded:n,publicSlug:n.route.slug};let r=await o(e.db,t,t=>u(e,t));if(r?.kind!==`serve`)return null;let{route:i}=r.loaded;return{loaded:r.loaded,publicSlug:c(i.slug,r.versionGroup,r.version,r.locale)}}async function h(e,t){let[n]=await e.db.all(f`
2
2
  SELECT routes.slug AS slug
3
3
  FROM routes
4
4
  INNER JOIN files ON files.id = routes.source_id
@@ -1 +1 @@
1
- import{discoverContentDependencyPolicy as e}from"../content-dependency-policy.js";import{createTemplateSetProvider as t}from"../../content-layer/templates/template-set.js";import{createLogger as n}from"../../shared/logger.js";import{openContentLayerDatabase as r}from"../../content-layer/database/connection.js";import{getPathPrefix as i}from"../../shared/path-prefix.js";import{resolveRuntimeEntryFiles as a}from"../runtime-files.js";import{BUNDLED_DEV_CLIENT_SCRIPT_TAG as o,REACT_REFRESH_PREAMBLE_PATH as s,REDOCLY_SSR_NO_EXTERNAL as c}from"../vite-config.base.js";import{silentReporter as l}from"../../shared/reporter.js";import{loadUserMarkdocSchema as u}from"../user-markdoc-schema.js";import{resolveAccessConfig as d}from"../../server/auth/access-config.js";import{resolveAuthKeySeed as f}from"../../server/auth/keys.js";import{createAuthRuntime as p}from"../../server/auth/runtime.js";import{invalidateLinkCheckViewCache as m,materializeRuntimeEntityDataByKey as h}from"../../server/content.js";import{createCorsProxyHandler as g}from"../../server/cors-proxy/handler.js";import{createDevSubprocessHost as _}from"../../server/subprocess/host.js";import{createSsrModuleInvoke as ee,createViteDevServer as te,ensureBundledClientOutput as ne}from"./vite-config.js";import{createCodeAssetSources as re}from"./code-asset-sources.js";import{startContentDevSession as v}from"./content-session.js";import{createDevContentBuild as ie,loadContentBuildProgress as ae,loadContentBuildQueue as y}from"./dev-content-build.js";import{countPages as b,listDevProblems as x,loadDevProblems as S,watchBuiltProblems as oe}from"./dev-problems.js";import{silentDevReporter as C}from"./dev-reporter.js";import{serveReactRefreshPreamble as w}from"./react-refresh-preamble.js";import{CONTENT_BUILD_PROGRESS_HMR_EVENT as T}from"../../shared/constants/dev-content-build.js";import{createRealmOnIngestComplete as E,createRealmRuntimeApp as se}from"./runtime-app.js";import{toViteChunkUrl as ce}from"./vite-chunk-url.js";import{readFile as le}from"node:fs/promises";import D from"node:process";import{createServer as ue}from"node:http";import{getRequestListener as O}from"@hono/node-server";import{createServer as k}from"node:net";const A=[`@redocly/redoc-opentelemetry`,`@redocly/realm-asyncapi-sdk`,`@redocly/mock-server`],j=[...c,`react`,`react-dom`,`styled-components`];async function M(c){let k=c.logger??n(),M=c.reporter??l,F=c.devReporter??C,I=k.child(`runtime:dev`),R=i(),V=null,H=!1,U=null,W=null,G=new Promise((e,t)=>{U=e,W=t}),K=async e=>{if(!H){if(H=!0,B(),X?.pause(),Z(),await Promise.allSettled([q?.close(),J?.close(),Y?.close(),N(V)]),e){W?.(e);return}U?.()}},q=null,J=null,Y=null,X=null,Z=()=>{};try{let n=await M.run(`Starting dev server`,async()=>{let n=a(c.contentDir),i=t(),l=(e,t)=>{t.statusCode=503,t.end(`Dev server is starting.`)};V=ue((e,t)=>{l(e,t)});let x=e(c.contentDir,{viteManagedDependencies:j});I.debug(`Content dependency SSR policy`,x);let C=re();Y=await te({contentDir:c.contentDir,externalizeReactForSsr:!0,registerCodeAssetSource:C.register,hmrServer:V,lazyDevCompilation:!1,logger:k,templateSetProvider:i,styledComponentsDependencies:x.noExternal,styledComponentsRoots:x.packageRoots,configOverrides:{ssr:{external:[...A,...x.external],noExternal:x.noExternal}}});let M=Y;await u({contentDir:c.contentDir,logger:k});let N=async()=>{};q=await v({contentDir:c.contentDir,databaseUrl:c.databaseUrl,debounceMs:c.debounceMs,ignoredDirectories:c.ignoredDirectories,logger:k,onError:e=>{K(e)},onCycleStart:()=>{J&&m(J),X?.onIngestCycleStart(),F.changeStart()},onCycleEnd:async e=>{X?.onIngestCycleEnd(),J&&F.changeEnd({...e,pages:await b(J),problems:await S(J)})},onIngestComplete:e=>N(e),templateSetProvider:i});let z=q.context;J=await r({contentDir:c.contentDir,databaseUrl:c.databaseUrl,logger:k.child(`runtime:content`),runMigrations:!1});let B=J;Z=oe({database:B,report:e=>F.problems(e),logger:I});let H={database:B,entityLoaderIds:()=>z.pluginRegistry.listEntityLoaders().map(e=>e.definition.id)},U=1,W=0,G=()=>{try{M.environments.client.hot.send({type:`custom`,event:T,data:{}})}catch(e){let t=e instanceof Error?e.message:String(e);I.warn(`Could not send the content build HMR nudge: ${t}`)}},Q=0,de=e=>{let t=performance.now();!e&&t-Q<250||(Q=t,X?.status().then(e=>F.contentBuild(e)).catch(e=>I.warn(`Could not read the content build status`,{err:e})))};X=ie({loadQueue:()=>y(H),loadProgress:e=>ae(H,e),materialize:e=>h({contentDir:c.contentDir,context:z,database:B,logger:k,key:e}),logger:k,onProgress:e=>{if(de(e.kind===`state`),e.kind===`state`){W=0,X?.status().then(e=>{U=Math.max(1,Math.floor(e.total/50))}).catch(e=>{let t=e instanceof Error?e.message:String(e);I.warn(`Could not refresh the content build HMR nudge threshold: ${t}`)}).finally(G);return}W+=1,!(W<U)&&(W=0,G())}});let fe=X;N=E({contentDir:c.contentDir,database:B,viteServer:M,logger:I,refreshClientOutput:async()=>{await ne(M.environments.client)}});let pe=await p({env:D.env,getAccessConfig:()=>d(z.config),devLogin:!0,allowDevFallbackSeed:!0,allowInsecureCookies:!0,logger:k}),me=se({contentDir:c.contentDir,context:z,database:B,logger:k,viteServer:M,entryFiles:n,headTags:`<script src="${s}"><\/script>${o}`,auth:pe,gatewaySecretSeed:f(D.env,{allowDevFallback:!0}),corsProxy:g({getConfig:()=>z.config,allowPrivateNetwork:!0}),subprocess:_({contentDir:c.contentDir,databaseUrl:B.url,viteInvoke:ee(M)}),contentBuild:X??void 0,readCodeAssetSource:async e=>{let t=C.pathOf(e);if(!t)return null;try{return new Uint8Array(await le(t))}catch{return null}}}),he=O(me.fetch);l=(e,t)=>{if(w(e,t))return;let n=e.url,r=ce(n);r!==null&&(e.url=r),M.middlewares(e,t,()=>{e.url=n,he(e,t)})};let $=await P(V,c.host,c.port);return V.on(`error`,e=>{K(e)}),$!==c.port&&k.warn(`Port ${c.port} is already in use. Using port ${$} instead.`),{url:`http://${L(c.host)}:${$}${R}`,database:B,contentBuild:fe}},e=>`Dev server ready at ${e.url}`);z(()=>{K()}),F.ready({url:n.url,pages:await b(n.database),problems:await S(n.database),contentBuild:await n.contentBuild.status(),controls:{listProblems:()=>x(n.database),startBuild:()=>n.contentBuild.start(),pauseBuild:()=>n.contentBuild.pause()}}),await G}catch(e){let t=e instanceof Error?e:Error(String(e));throw await K(t),t}}function N(e){return e?new Promise((t,n)=>{e.close(e=>{if(e){n(e);return}t()})}):Promise.resolve()}async function P(e,t,n){let r=L(t),i=Math.max(n,Math.min(n+20,65535));for(let a=n;a<=i;a++)if(r===t||await I(r,a))try{return await F(e,t,a),a}catch(e){if(e.code!==`EADDRINUSE`)throw e}throw Object.assign(/* @__PURE__ */ Error(`Ports ${n}-${i} are already in use.`),{code:`EADDRINUSE`})}function F(e,t,n){return new Promise((r,i)=>{let a=t=>{e.off(`listening`,o),i(t)},o=()=>{e.off(`error`,a),r()};e.once(`error`,a),e.once(`listening`,o),e.listen(n,t)})}function I(e,t){return new Promise(n=>{let r=k();r.once(`error`,e=>n(e.code!==`EADDRINUSE`)),r.listen(t,e,()=>r.close(()=>n(!0)))})}function L(e){return e===void 0||e===`0.0.0.0`||e===`::`?`127.0.0.1`:e}let R=[];function z(e){R=[[`SIGINT`,e],[`SIGTERM`,e]];for(let[e,t]of R)D.once(e,t)}function B(){for(let[e,t]of R)D.off(e,t);R=[]}export{A as NODE_DEV_SSR_EXTERNAL,M as runDev};
1
+ import{getPathPrefix as e}from"../../shared/path-prefix.js";import{createLogger as t}from"../../shared/logger.js";import{openContentLayerDatabase as n}from"../../content-layer/database/connection.js";import{resolveAccessConfig as r}from"../../server/auth/access-config.js";import{resolveAuthKeySeed as i}from"../../server/auth/keys.js";import{createAuthRuntime as a}from"../../server/auth/runtime.js";import{invalidateLinkCheckViewCache as o,materializeRuntimeEntityDataByKey as s}from"../../server/content.js";import{createCorsProxyHandler as ee}from"../../server/cors-proxy/handler.js";import{createDevSubprocessHost as c}from"../../server/subprocess/host.js";import{createTemplateSetProvider as l}from"../../content-layer/templates/template-set.js";import{discoverContentDependencyPolicy as u}from"../content-dependency-policy.js";import{resolveRuntimeEntryFiles as d}from"../runtime-files.js";import{BUNDLED_DEV_CLIENT_SCRIPT_TAG as f,REACT_REFRESH_PREAMBLE_PATH as p,REDOCLY_SSR_NO_EXTERNAL as m}from"../vite-config.base.js";import{silentReporter as h}from"../../shared/reporter.js";import{loadUserMarkdocSchema as g}from"../user-markdoc-schema.js";import{CONTENT_BUILD_PROGRESS_HMR_EVENT as te}from"../../shared/constants/dev-content-build.js";import{createSsrModuleInvoke as ne,createViteDevServer as re,ensureBundledClientOutput as ie}from"./vite-config.js";import{createCodeAssetSources as _}from"./code-asset-sources.js";import{startContentDevSession as ae}from"./content-session.js";import{createDevContentBuild as oe,loadContentBuildProgress as v,loadContentBuildQueue as y}from"./dev-content-build.js";import{countPages as b,listDevProblems as x,loadDevProblems as S,watchBuiltProblems as C}from"./dev-problems.js";import{silentDevReporter as w}from"./dev-reporter.js";import{serveReactRefreshPreamble as T}from"./react-refresh-preamble.js";import{createRealmOnIngestComplete as E,createRealmRuntimeApp as se}from"./runtime-app.js";import{toViteChunkUrl as ce}from"./vite-chunk-url.js";import{readFile as le}from"node:fs/promises";import{createServer as ue}from"node:http";import D from"node:process";import{getRequestListener as O}from"@hono/node-server";import{createServer as k}from"node:net";const A=[`@redocly/redoc-opentelemetry`,`@redocly/realm-asyncapi-sdk`,`@redocly/mock-server`],j=[...m,`react`,`react-dom`,`styled-components`];async function M(m){let k=m.logger??t(),M=m.reporter??h,F=m.devReporter??w,I=k.child(`runtime:dev`),R=e(),V=null,H=!1,U=null,W=null,G=new Promise((e,t)=>{U=e,W=t}),K=async e=>{if(!H){if(H=!0,B(),X?.pause(),Z(),await Promise.allSettled([q?.close(),J?.close(),Y?.close(),N(V)]),e){W?.(e);return}U?.()}},q=null,J=null,Y=null,X=null,Z=()=>{};try{let e=await M.run(`Starting dev server`,async()=>{let e=d(m.contentDir),t=l(),h=(e,t)=>{t.statusCode=503,t.end(`Dev server is starting.`)};V=ue((e,t)=>{h(e,t)});let x=u(m.contentDir,{viteManagedDependencies:j});I.debug(`Content dependency SSR policy`,x);let w=_();Y=await re({contentDir:m.contentDir,externalizeReactForSsr:!0,registerCodeAssetSource:w.register,hmrServer:V,lazyDevCompilation:!1,logger:k,templateSetProvider:t,styledComponentsDependencies:x.noExternal,styledComponentsRoots:x.packageRoots,configOverrides:{ssr:{external:[...A,...x.external],noExternal:x.noExternal}}});let M=Y;await g({contentDir:m.contentDir,logger:k});let N=async()=>{};q=await ae({contentDir:m.contentDir,databaseUrl:m.databaseUrl,debounceMs:m.debounceMs,ignoredDirectories:m.ignoredDirectories,logger:k,onError:e=>{K(e)},onCycleStart:()=>{J&&o(J),X?.onIngestCycleStart(),F.changeStart()},onCycleEnd:async e=>{X?.onIngestCycleEnd(),J&&F.changeEnd({...e,pages:await b(J),problems:await S(J)})},onIngestComplete:e=>N(e),templateSetProvider:t});let z=q.context;J=await n({contentDir:m.contentDir,databaseUrl:m.databaseUrl,logger:k.child(`runtime:content`),runMigrations:!1});let B=J;Z=C({database:B,report:e=>F.problems(e),logger:I});let H={database:B,entityLoaderIds:()=>z.pluginRegistry.listEntityLoaders().map(e=>e.definition.id)},U=1,W=0,G=()=>{try{M.environments.client.hot.send({type:`custom`,event:te,data:{}})}catch(e){let t=e instanceof Error?e.message:String(e);I.warn(`Could not send the content build HMR nudge: ${t}`)}},Q=0,de=e=>{let t=performance.now();!e&&t-Q<250||(Q=t,X?.status().then(e=>F.contentBuild(e)).catch(e=>I.warn(`Could not read the content build status`,{err:e})))};X=oe({loadQueue:()=>y(H),loadProgress:e=>v(H,e),materialize:e=>s({contentDir:m.contentDir,context:z,database:B,logger:k,key:e}),logger:k,onProgress:e=>{if(de(e.kind===`state`),e.kind===`state`){W=0,X?.status().then(e=>{U=Math.max(1,Math.floor(e.total/50))}).catch(e=>{let t=e instanceof Error?e.message:String(e);I.warn(`Could not refresh the content build HMR nudge threshold: ${t}`)}).finally(G);return}W+=1,!(W<U)&&(W=0,G())}});let fe=X;N=E({contentDir:m.contentDir,database:B,viteServer:M,logger:I,refreshClientOutput:async()=>{await ie(M.environments.client)}});let pe=await a({env:D.env,getAccessConfig:()=>r(z.config),devLogin:!0,allowDevFallbackSeed:!0,allowInsecureCookies:!0,logger:k}),me=se({contentDir:m.contentDir,context:z,database:B,logger:k,viteServer:M,entryFiles:e,headTags:`<script src="${p}"><\/script>${f}`,auth:pe,gatewaySecretSeed:i(D.env,{allowDevFallback:!0}),corsProxy:ee({getConfig:()=>z.config,allowPrivateNetwork:!0}),subprocess:c({contentDir:m.contentDir,databaseUrl:B.url,viteInvoke:ne(M)}),contentBuild:X??void 0,readCodeAssetSource:async e=>{let t=w.pathOf(e);if(!t)return null;try{return new Uint8Array(await le(t))}catch{return null}}}),he=O(me.fetch);h=(e,t)=>{if(T(e,t))return;let n=e.url,r=ce(n);r!==null&&(e.url=r),M.middlewares(e,t,()=>{e.url=n,he(e,t)})};let $=await P(V,m.host,m.port);return V.on(`error`,e=>{K(e)}),$!==m.port&&k.warn(`Port ${m.port} is already in use. Using port ${$} instead.`),{url:`http://${L(m.host)}:${$}${R}`,database:B,contentBuild:fe}},e=>`Dev server ready at ${e.url}`);z(()=>{K()}),F.ready({url:e.url,pages:await b(e.database),problems:await S(e.database),contentBuild:await e.contentBuild.status(),controls:{listProblems:()=>x(e.database),startBuild:()=>e.contentBuild.start(),pauseBuild:()=>e.contentBuild.pause()}}),await G}catch(e){let t=e instanceof Error?e:Error(String(e));throw await K(t),t}}function N(e){return e?new Promise((t,n)=>{e.close(e=>{if(e){n(e);return}t()})}):Promise.resolve()}async function P(e,t,n){let r=L(t),i=Math.max(n,Math.min(n+20,65535));for(let a=n;a<=i;a++)if(r===t||await I(r,a))try{return await F(e,t,a),a}catch(e){if(e.code!==`EADDRINUSE`)throw e}throw Object.assign(/* @__PURE__ */ Error(`Ports ${n}-${i} are already in use.`),{code:`EADDRINUSE`})}function F(e,t,n){return new Promise((r,i)=>{let a=t=>{e.off(`listening`,o),i(t)},o=()=>{e.off(`error`,a),r()};e.once(`error`,a),e.once(`listening`,o),e.listen(n,t)})}function I(e,t){return new Promise(n=>{let r=k();r.once(`error`,e=>n(e.code!==`EADDRINUSE`)),r.listen(t,e,()=>r.close(()=>n(!0)))})}function L(e){return e===void 0||e===`0.0.0.0`||e===`::`?`127.0.0.1`:e}let R=[];function z(e){R=[[`SIGINT`,e],[`SIGTERM`,e]];for(let[e,t]of R)D.once(e,t)}function B(){for(let[e,t]of R)D.off(e,t);R=[]}export{A as NODE_DEV_SSR_EXTERNAL,M as runDev};
@@ -1 +1 @@
1
- import{BUILD_ASSETS_URL_PREFIX as e,getContentAssetsOutputDir as t}from"../../shared/constants/runtime-layout.js";import{setUserMarkdocSchemaFailure as n,userMarkdocSchemaFailure as r,userMarkdocSchemaFiles as i}from"../../content-layer/markdown/constants/tag-sets.js";import{toViteFsModuleId as a}from"../runtime-files.js";import{DATA_UPDATE_HMR_EVENT as o}from"../../shared/constants/content-update.js";import{MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as s}from"../constants/virtual-modules.js";import{invalidateThemeOverrideIndex as c}from"../vite-config.base.js";import{invalidateAppDataCache as l}from"../../server/content.js";import{registerDevAuthRoutes as u,registerMockDevAuthRoutes as d}from"../../server/auth/routes.js";import{collectManualAuthPaths as f}from"../../server/plugin-routes.js";import{createApp as p}from"../../server/app.js";import{createPageHandlers as m}from"../../server/page-handlers.js";import{registerLocalContentAssetRoute as h}from"../../server/content-assets/serve-local.js";import{registerEntityRevisionsAdminRoute as g}from"../../server/revisions-admin.js";import{invalidateBundledSsrRunnerCache as _,invalidateMarkdocSchemaModule as v,triggerFullClientRebuild as y}from"./vite-config.js";import{renderClientStylesheetTags as b}from"./client-stylesheets.js";import{syncUserMarkdocSchemaProblem as x}from"../../content-layer/ingest/markdoc-schema-problem.js";import{loadContentBuildProgress as S}from"./dev-content-build.js";import{DEV_PAGE_FOR_SOURCE_PATH as C}from"../../shared/constants/dev-source-sync.js";import{getSsrGraphGate as w}from"./ssr-graph-gate.js";import{contentUpdateState as T,registerContentUpdateStateRoute as E}from"./routes/content-update-state-route.js";import{registerDevContentBuildRoute as D}from"./routes/dev-content-build-route.js";import{registerDevProblemsRoute as O}from"./routes/dev-problems-route.js";import{registerSourceSyncRoutes as k}from"./routes/source-sync-route.js";import{join as A,resolve as j,sep as M}from"node:path";import{isRunnableDevEnvironment as N}from"vite";const P=/\.([cm]?[jt]sx?|css)$/,F=/(^|\/)@theme\//,I=/(^|\/)@theme\/markdoc\//,L=/(^|\/)@theme\/styles\.css$/,R=/\.md$/i;function z(e){let t=e.environments.ssr;if(!N(t))throw Error(`Runtime requires the Vite SSR environment to be runnable.`);return t}async function B(e){let t=z(e.viteServer);try{await t.runner.import(s)}catch(r){let i=r instanceof Error?r.message:String(r);n(i),e.logger.warn(`The project Markdoc schema did not load; pages render without its tags: ${i}`),await x(e.database),v(t),y(e.viteServer.environments.client),await t.runner.import(s)}}function V(n){let{contentDir:r,context:i,database:o,logger:s,viteServer:c,entryFiles:l,headTags:_}=n,v=t(i.contentDir),y=l.serverRouteFiles.map(e=>({method:e.method,path:e.path,plugin:e.plugin,...e.auth?{auth:e.auth}:{},loadHandler:async()=>(await z(c).runner.import(a(e.handler.filePath)))[e.handler.exportName]})),x=async e=>{let t=A(r,e),n=j(r),i=j(t);if(i!==n&&!i.startsWith(n+M))throw Error(`Refusing to load a content module outside the content directory: ${e}`);return z(c).runner.import(a(t))},T=m({contentDir:r,context:i,database:o,logger:s,authInfo:n.auth?.pageAuthInfo,development:!0,headTags:_,loadHeadTags:()=>b(c),beforeLoad:()=>B({viteServer:c,database:o,logger:s}),loadSsr:()=>(n.onBootPhase?.(`site-code-compile`),z(c).runner.import(a(l.serverEntryPath)))}),N=w(c,e=>s.warn(e)),P=async e=>{try{return await i.platform.fs.readFile(A(i.contentDir,e))}catch{return null}};return p({getConfig:()=>i.config,responseHeaders:n.responseHeaders,registerRoutes:e=>{E(e),g(e,{database:o,logger:s}),O(e,{database:o,readSourceFile:P}),D(e,{contentBuild:n.contentBuild}),k(e,{contentDir:r,context:i,database:o,logger:s,readSourceFile:P}),h(e,{contentAssetsDir:v,fs:i.pluginIO,readSource:n.readCodeAssetSource,logger:s}),n.auth&&n.auth.devLogin&&(n.auth.keys?u(e,n.auth):n.auth.setViewer&&d(e,n.auth))},clientBootstrap:{type:`script-src`,src:`${e}/client-entry.js`},auth:n.auth,corsProxy:n.corsProxy,database:o,contentDir:r,context:i,development:!0,logger:s,pluginRoutes:{contentDir:r,context:i,subprocess:n.subprocess,gatewaySecretSeed:n.gatewaySecretSeed,routes:y,mcpToolEntries:l.mcpToolFiles,loadContentModule:x},manualAuthPaths:[...f(y),C],search:{loadIndexCoverage:async()=>{let e=i.pluginRegistry.listEntityLoaders().filter(e=>e.definition.searchable!==void 0).map(e=>e.definition.id),{done:t,total:n}=await S({database:o,entityLoaderIds:()=>e},[]);return{indexed:t,total:n}}},staticFiles:{contentDir:r,context:i},...T,renderPage:(e,t)=>N.render(()=>(n.onBootPhase?.(`page-data-load`),T.renderPage(e,t)))})}function H(e){return async({changes:t,templateSetChanged:a})=>{l(e.database);let s=e.viteServer.environments.ssr;N(s)&&(a||!t.every(({path:e})=>R.test(e))||[...s.moduleGraph.fileToModulesMap.keys()].some(e=>R.test(e)))&&await w(e.viteServer,t=>e.logger.warn(t)).invalidate(()=>_(s)),t.some(({path:e})=>F.test(e))&&c(e.contentDir);let u=r()!==void 0&&!t.every(({path:e})=>R.test(e));u&&(n(void 0),await B(e),await x(e.database));let d=new Set(i()),f=u||t.some(({event:e,path:t})=>I.test(t)||d.has(t)||L.test(t)&&e!==`change`);if(a||f||t.some(({path:e})=>P.test(e))){(a||f)&&(y(e.viteServer.environments.client)||e.logger.warn(`template-set rebuild trigger found no dev engine — client bundle may be stale`));try{await e.refreshClientOutput()}catch(t){let n=t instanceof Error?t.message:String(t);e.logger.warn(`Failed to refresh bundled client output: ${n}`)}}T.generation+=1,T.updatedAt=Date.now(),e.viteServer.environments.client.hot.send({type:`custom`,event:o,data:{changes:t,generation:T.generation}})}}export{H as createRealmOnIngestComplete,V as createRealmRuntimeApp};
1
+ import{setUserMarkdocSchemaFailure as e,userMarkdocSchemaFailure as t,userMarkdocSchemaFiles as n}from"../../content-layer/markdown/constants/tag-sets.js";import{DEV_PAGE_FOR_SOURCE_PATH as r}from"../../shared/constants/dev-source-sync.js";import{DATA_UPDATE_HMR_EVENT as i}from"../../shared/constants/content-update.js";import{BUILD_ASSETS_URL_PREFIX as a,getContentAssetsOutputDir as o}from"../../shared/constants/runtime-layout.js";import{invalidateAppDataCache as s}from"../../server/content.js";import{registerDevAuthRoutes as c,registerMockDevAuthRoutes as l}from"../../server/auth/routes.js";import{collectManualAuthPaths as u}from"../../server/plugin-routes.js";import{createApp as d}from"../../server/app.js";import{createPageHandlers as f}from"../../server/page-handlers.js";import{registerLocalContentAssetRoute as p}from"../../server/content-assets/serve-local.js";import{registerEntityRevisionsAdminRoute as m}from"../../server/revisions-admin.js";import{toViteFsModuleId as h}from"../runtime-files.js";import{MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as g}from"../constants/virtual-modules.js";import{invalidateThemeOverrideIndex as _}from"../vite-config.base.js";import{invalidateBundledSsrRunnerCache as v,invalidateMarkdocSchemaModule as y,triggerFullClientRebuild as b}from"./vite-config.js";import{renderClientStylesheetTags as x}from"./client-stylesheets.js";import{syncUserMarkdocSchemaProblem as S}from"../../content-layer/ingest/markdoc-schema-problem.js";import{loadContentBuildProgress as C}from"./dev-content-build.js";import{getSsrGraphGate as w}from"./ssr-graph-gate.js";import{contentUpdateState as T,registerContentUpdateStateRoute as E}from"./routes/content-update-state-route.js";import{registerDevContentBuildRoute as D}from"./routes/dev-content-build-route.js";import{registerDevProblemsRoute as O}from"./routes/dev-problems-route.js";import{registerSourceSyncRoutes as k}from"./routes/source-sync-route.js";import{join as A,resolve as j,sep as M}from"node:path";import{isRunnableDevEnvironment as N}from"vite";const P=/\.([cm]?[jt]sx?|css)$/,F=/(^|\/)@theme\//,I=/(^|\/)@theme\/markdoc\//,L=/(^|\/)@theme\/styles\.css$/,R=/\.md$/i;function z(e){let t=e.environments.ssr;if(!N(t))throw Error(`Runtime requires the Vite SSR environment to be runnable.`);return t}async function B(t){let n=z(t.viteServer);try{await n.runner.import(g)}catch(r){let i=r instanceof Error?r.message:String(r);e(i),t.logger.warn(`The project Markdoc schema did not load; pages render without its tags: ${i}`),await S(t.database),y(n),b(t.viteServer.environments.client),await n.runner.import(g)}}function V(e){let{contentDir:t,context:n,database:i,logger:s,viteServer:g,entryFiles:_,headTags:v}=e,y=o(n.contentDir),b=_.serverRouteFiles.map(e=>({method:e.method,path:e.path,plugin:e.plugin,...e.auth?{auth:e.auth}:{},loadHandler:async()=>(await z(g).runner.import(h(e.handler.filePath)))[e.handler.exportName]})),S=async e=>{let n=A(t,e),r=j(t),i=j(n);if(i!==r&&!i.startsWith(r+M))throw Error(`Refusing to load a content module outside the content directory: ${e}`);return z(g).runner.import(h(n))},T=f({contentDir:t,context:n,database:i,logger:s,authInfo:e.auth?.pageAuthInfo,development:!0,headTags:v,loadHeadTags:()=>x(g),beforeLoad:()=>B({viteServer:g,database:i,logger:s}),loadSsr:()=>(e.onBootPhase?.(`site-code-compile`),z(g).runner.import(h(_.serverEntryPath)))}),N=w(g,e=>s.warn(e)),P=async e=>{try{return await n.platform.fs.readFile(A(n.contentDir,e))}catch{return null}};return d({getConfig:()=>n.config,responseHeaders:e.responseHeaders,registerRoutes:r=>{E(r),m(r,{database:i,logger:s}),O(r,{database:i,readSourceFile:P}),D(r,{contentBuild:e.contentBuild}),k(r,{contentDir:t,context:n,database:i,logger:s,readSourceFile:P}),p(r,{contentAssetsDir:y,fs:n.pluginIO,readSource:e.readCodeAssetSource,logger:s}),e.auth&&e.auth.devLogin&&(e.auth.keys?c(r,e.auth):e.auth.setViewer&&l(r,e.auth))},clientBootstrap:{type:`script-src`,src:`${a}/client-entry.js`},auth:e.auth,corsProxy:e.corsProxy,database:i,contentDir:t,context:n,development:!0,logger:s,pluginRoutes:{contentDir:t,context:n,subprocess:e.subprocess,gatewaySecretSeed:e.gatewaySecretSeed,routes:b,mcpToolEntries:_.mcpToolFiles,loadContentModule:S},manualAuthPaths:[...u(b),r],search:{loadIndexCoverage:async()=>{let e=n.pluginRegistry.listEntityLoaders().filter(e=>e.definition.searchable!==void 0).map(e=>e.definition.id),{done:t,total:r}=await C({database:i,entityLoaderIds:()=>e},[]);return{indexed:t,total:r}}},staticFiles:{contentDir:t,context:n},...T,renderPage:(t,n)=>N.render(()=>(e.onBootPhase?.(`page-data-load`),T.renderPage(t,n)))})}function H(r){return async({changes:a,templateSetChanged:o})=>{s(r.database);let c=r.viteServer.environments.ssr;N(c)&&(o||!a.every(({path:e})=>R.test(e))||[...c.moduleGraph.fileToModulesMap.keys()].some(e=>R.test(e)))&&await w(r.viteServer,e=>r.logger.warn(e)).invalidate(()=>v(c)),a.some(({path:e})=>F.test(e))&&_(r.contentDir);let l=t()!==void 0&&!a.every(({path:e})=>R.test(e));l&&(e(void 0),await B(r),await S(r.database));let u=new Set(n()),d=l||a.some(({event:e,path:t})=>I.test(t)||u.has(t)||L.test(t)&&e!==`change`);if(o||d||a.some(({path:e})=>P.test(e))){(o||d)&&(b(r.viteServer.environments.client)||r.logger.warn(`template-set rebuild trigger found no dev engine — client bundle may be stale`));try{await r.refreshClientOutput()}catch(e){let t=e instanceof Error?e.message:String(e);r.logger.warn(`Failed to refresh bundled client output: ${t}`)}}T.generation+=1,T.updatedAt=Date.now(),r.viteServer.environments.client.hot.send({type:`custom`,event:i,data:{changes:a,generation:T.generation}})}}export{H as createRealmOnIngestComplete,V as createRealmRuntimeApp};
@@ -1 +1 @@
1
- import{BUILD_ASSETS_URL_PREFIX as e}from"../../shared/constants/runtime-layout.js";import{getPathPrefix as t}from"../../shared/path-prefix.js";function n(n){let r=`${t()}${e}/`;return!n||!n.startsWith(r)?null:`/assets/${n.slice(r.length)}`}export{n as toViteChunkUrl};
1
+ import{getPathPrefix as e}from"../../shared/path-prefix.js";import{BUILD_ASSETS_URL_PREFIX as t}from"../../shared/constants/runtime-layout.js";function n(n){let r=`${e()}${t}/`;return!n||!n.startsWith(r)?null:`/assets/${n.slice(r.length)}`}export{n as toViteChunkUrl};
@@ -1 +1 @@
1
- import{REDOCLY_SSR_NO_EXTERNAL as e,RESOLVED_MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as t,createBaseViteConfig as n}from"../vite-config.base.js";import{createBrowserExternalPlugin as r}from"./browser-external.js";import{createClientStylesheetsPlugin as i}from"./client-stylesheets.js";import{createServer as a,defaultAllowedOrigins as o,mergeConfig as s}from"vite";async function c(t){let c=n({contentDir:t.contentDir,enableLazyStaticData:!0,externalizeReactForSsr:t.externalizeReactForSsr,lazyDevCompilation:t.lazyDevCompilation,logger:t.logger,templateSetProvider:t.templateSetProvider,styledComponentsDependencies:t.styledComponentsDependencies,styledComponentsRoots:t.styledComponentsRoots,registerCodeAssetSource:t.registerCodeAssetSource}),l={configFile:!1,envDir:!1,...c,plugins:[...c.plugins??[],i(),r()],server:{hmr:t.hmrServer?{overlay:!0,server:t.hmrServer}:!1,middlewareMode:!0,cors:{origin:o,preflightContinue:!0},watch:t.watchFiles===!1?null:void 0},ssr:{noExternal:[...e]}};return a(t.configOverrides?s(l,t.configOverrides):l)}function l(e){return t=>e.environments.ssr.hot.handleInvoke(t)}function u(e){if(!e||typeof e!=`object`)return;let t=e,n;try{n=t.bundledDev?.devEngine??t.devEngine}catch{n=void 0}return typeof n?.ensureLatestBuildOutput==`function`?n:void 0}function d(e){return e?(e.moduleGraph.invalidateAll(),e.runner.evaluatedModules.clear(),!0):!1}function f(e){let n=e.moduleGraph.getModuleById(t);n&&e.moduleGraph.invalidateModule(n);let{evaluatedModules:r}=e.runner,i=r.getModuleById(t);i&&r.invalidateModule(i)}async function p(e){let t=u(e);return t?(await t.ensureLatestBuildOutput(),!0):!1}function m(e){let t=u(e);return!t||typeof t.triggerFullBuild!=`function`?!1:(t.triggerFullBuild(),!0)}export{l as createSsrModuleInvoke,c as createViteDevServer,p as ensureBundledClientOutput,d as invalidateBundledSsrRunnerCache,f as invalidateMarkdocSchemaModule,m as triggerFullClientRebuild};
1
+ import{REDOCLY_SSR_NO_EXTERNAL as e,RESOLVED_MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as t,createBaseViteConfig as n}from"../vite-config.base.js";import{createBrowserExternalPlugin as r}from"./browser-external.js";import{createClientStylesheetsPlugin as i}from"./client-stylesheets.js";import{createServer as a,defaultAllowedOrigins as o,mergeConfig as s}from"vite";async function c(t){let c=n({contentDir:t.contentDir,enableLazyStaticData:!0,externalizeReactForSsr:t.externalizeReactForSsr,lazyDevCompilation:t.lazyDevCompilation,logger:t.logger,templateSetProvider:t.templateSetProvider,styledComponentsDependencies:t.styledComponentsDependencies,styledComponentsRoots:t.styledComponentsRoots,registerCodeAssetSource:t.registerCodeAssetSource}),l={configFile:!1,envDir:!1,...c,plugins:[...c.plugins??[],i(),r()],server:{hmr:t.hmrServer?{overlay:!0,server:t.hmrServer}:!1,middlewareMode:!0,cors:{origin:o,preflightContinue:!0},watch:t.watchFiles===!1?null:void 0},ssr:{noExternal:[...e]}};return a(t.configOverrides?s(l,t.configOverrides):l)}function l(e){return t=>e.environments.ssr.hot.handleInvoke(t)}function u(e){if(!e||typeof e!=`object`)return;let t=e,n;try{n=t.bundledDev?.devEngine??t.devEngine}catch{return}if(typeof n?.ensureLatestBuildOutput==`function`)return{devEngine:n,clients:t.bundledDev?.clients??t.clients}}function d(e){return e?(e.moduleGraph.invalidateAll(),e.runner.evaluatedModules.clear(),!0):!1}function f(e){let n=e.moduleGraph.getModuleById(t);n&&e.moduleGraph.invalidateModule(n);let{evaluatedModules:r}=e.runner,i=r.getModuleById(t);i&&r.invalidateModule(i)}async function p(e){let t=u(e)?.devEngine;return t?(await t.ensureLatestBuildOutput(),!0):!1}function m(e){let t=u(e)?.devEngine;return!t||typeof t.triggerFullBuild!=`function`?!1:(t.triggerFullBuild(),!0)}export{l as createSsrModuleInvoke,c as createViteDevServer,p as ensureBundledClientOutput,d as invalidateBundledSsrRunnerCache,f as invalidateMarkdocSchemaModule,u as resolveBundledClientDev,m as triggerFullClientRebuild};
@@ -1 +1 @@
1
- import{toPosixPath as e}from"../shared/utils/to-posix-path.js";import{hashContentBytes as t}from"../shared/utils/content-hash.js";import{USER_MARKDOC_SCHEMA_FILE as n,registerUserMarkdocSchema as r,registerUserMarkdocSchemaFailure as i}from"../content-layer/markdown/constants/tag-sets.js";import{MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as a}from"./constants/virtual-modules.js";import{userMarkdocSchemaFile as o}from"./vite-config.base.js";import{bundleForNode as s}from"./node-bundle.js";import{silentReporter as c}from"../shared/reporter.js";import{createServerReplayStubPlugin as l}from"./build/vite-config.js";import{isAbsolute as u,join as d,relative as f}from"node:path";import{readFile as p,readdir as m,realpath as h}from"node:fs/promises";const g=`@theme/markdoc/`;let _;async function v(e){let{contentDir:t,logger:i}=e;if(o(t)===null){r(void 0,void 0,[n]),_=/* @__PURE__ */ new Set;return}await(e.reporter??c).run(`Loading the Markdoc schema`,()=>y(t,i),e=>e===void 0?`Markdoc schema did not load (see the warning)`:`Loaded the Markdoc schema (${e} ${e===1?`tag`:`tags`})`)}async function y(e,t){let o=await h(e);try{let{module:n,moduleIds:i}=await s({contentDir:e,logger:t,input:a,plugins:[l()]}),c=S(i),u=c.map(e=>T(o,e));r({tags:n.userMarkdocTags,nodes:n.userMarkdocNodes,functions:n.userMarkdocFunctions},await x(o,c),u),_=new Set(u);let d=Object.keys(n.userMarkdocTags).length;return t.debug(`Loaded the project Markdoc schema: ${d} tag(s) from ${c.length} file(s)`),d}catch(e){_=/* @__PURE__ */ new Set([..._??[],n,...await C(o)]);let r=e instanceof Error?e.message:String(e);i([..._],r),t.warn(`The project Markdoc schema did not load; pages are not validated and its tags show their title in page Markdown: ${r}`);return}}async function b(e){let t=_;return t===void 0||!e.changes.some(e=>t.has(e.path)||e.path.startsWith(g))?!1:(await v(e),!0)}async function x(e,n){let r=n.map(t=>({file:t,path:T(e,t)})).sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),i=await Promise.all(r.map(async({file:e,path:n})=>[n,await t(await p(e))]));return t(new TextEncoder().encode(JSON.stringify(i)))}function S(t){return[...new Set(t.map(t=>w(e(t))).filter(e=>u(e)&&!e.includes(`/node_modules/`)))]}async function C(e){return(await m(d(e,g),{recursive:!0,withFileTypes:!0})).filter(e=>e.isFile()).map(t=>T(e,d(t.parentPath,t.name)))}function w(e){let t=[e.indexOf(`?`),e.indexOf(`#`)].filter(e=>e!==-1);return t.length===0?e:e.slice(0,Math.min(...t))}function T(t,n){return e(f(t,n))}export{v as loadUserMarkdocSchema,b as reloadUserMarkdocSchemaIfChanged};
1
+ import{USER_MARKDOC_SCHEMA_FILE as e,registerUserMarkdocSchema as t,registerUserMarkdocSchemaFailure as n}from"../content-layer/markdown/constants/tag-sets.js";import{toPosixPath as r}from"../shared/utils/to-posix-path.js";import{hashContentBytes as i}from"../shared/utils/content-hash.js";import{MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as a}from"./constants/virtual-modules.js";import{userMarkdocSchemaFile as o}from"./vite-config.base.js";import{bundleForNode as s}from"./node-bundle.js";import{silentReporter as c}from"../shared/reporter.js";import{createServerReplayStubPlugin as l}from"./build/vite-config.js";import{isAbsolute as u,join as d,relative as f}from"node:path";import{readFile as p,readdir as m,realpath as h}from"node:fs/promises";const g=`@theme/markdoc/`;let _;async function v(n){let{contentDir:r,logger:i}=n;if(o(r)===null){t(void 0,void 0,[e]),_=/* @__PURE__ */ new Set;return}await(n.reporter??c).run(`Loading the Markdoc schema`,()=>y(r,i),e=>e===void 0?`Markdoc schema did not load (see the warning)`:`Loaded the Markdoc schema (${e} ${e===1?`tag`:`tags`})`)}async function y(r,i){let o=await h(r);try{let{module:e,moduleIds:n}=await s({contentDir:r,logger:i,input:a,plugins:[l()]}),c=S(n),u=c.map(e=>T(o,e));t({tags:e.userMarkdocTags,nodes:e.userMarkdocNodes,functions:e.userMarkdocFunctions},await x(o,c),u),_=new Set(u);let d=Object.keys(e.userMarkdocTags).length;return i.debug(`Loaded the project Markdoc schema: ${d} tag(s) from ${c.length} file(s)`),d}catch(t){_=/* @__PURE__ */ new Set([..._??[],e,...await C(o)]);let r=t instanceof Error?t.message:String(t);n([..._],r),i.warn(`The project Markdoc schema did not load; pages are not validated and its tags show their title in page Markdown: ${r}`);return}}async function b(e){let t=_;return t===void 0||!e.changes.some(e=>t.has(e.path)||e.path.startsWith(g))?!1:(await v(e),!0)}async function x(e,t){let n=t.map(t=>({file:t,path:T(e,t)})).sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),r=await Promise.all(n.map(async({file:e,path:t})=>[t,await i(await p(e))]));return i(new TextEncoder().encode(JSON.stringify(r)))}function S(e){return[...new Set(e.map(e=>w(r(e))).filter(e=>u(e)&&!e.includes(`/node_modules/`)))]}async function C(e){return(await m(d(e,g),{recursive:!0,withFileTypes:!0})).filter(e=>e.isFile()).map(t=>T(e,d(t.parentPath,t.name)))}function w(e){let t=[e.indexOf(`?`),e.indexOf(`#`)].filter(e=>e!==-1);return t.length===0?e:e.slice(0,Math.min(...t))}function T(e,t){return r(f(e,t))}export{v as loadUserMarkdocSchema,b as reloadUserMarkdocSchemaIfChanged};
@@ -1,8 +1,8 @@
1
- import{toPosixPath as e}from"../shared/utils/to-posix-path.js";import{createCodeAssetsPlugin as t}from"./code-assets.js";import{getProcessEnv as n,getPublicEnv as r}from"../shared/public-env.js";import{getContentAssetsOutputDir as i,getRuntimeOutputDir as a}from"../shared/constants/runtime-layout.js";import{createEmptyServerModuleSet as o}from"../content-layer/server-modules/module-set.js";import{userMarkdocSchemaFailure as s}from"../content-layer/markdown/constants/tag-sets.js";import{resolveRuntimeEntryFiles as c,resolveRuntimeServerModuleFiles as ee,resolveRuntimeTemplateFiles as l,toViteFsModuleId as u}from"./runtime-files.js";import{MARKDOC_COMPONENTS_VIRTUAL_MODULE_ID as te,MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as ne,MCP_TOOLS_VIRTUAL_MODULE_ID as re,RUNTIME_HOOKS_VIRTUAL_MODULE_ID as ie,SERVER_FNS_VIRTUAL_MODULE_ID as ae,SERVER_MODULES_VIRTUAL_MODULE_ID as oe,SERVER_ROUTES_VIRTUAL_MODULE_ID as se,TEMPLATES_VIRTUAL_MODULE_ID as ce,THEME_STYLES_VIRTUAL_MODULE_ID as le}from"./constants/virtual-modules.js";import{VITE_LOG_STREAM as ue}from"../shared/constants/log-streams.js";import{createRequire as de}from"node:module";import{fileURLToPath as d,pathToFileURL as fe}from"node:url";import{existsSync as f,readdirSync as pe}from"node:fs";import{dirname as p,join as m,resolve as me}from"node:path";import{createLogger as he,transformWithOxc as h}from"vite";import ge from"@redocly/markdoc";import{init as _e,parse as ve}from"es-module-lexer";import ye from"js-yaml";import be from"@vitejs/plugin-react";const g=`__REALM_ENABLE_LAZY_STATIC_DATA__`,xe=`__REALM_TEMPLATE_IDS__`,Se=`__REALM_BUILD_PATH_PREFIX__`,Ce=`__REALM_BUILD_DEV_LOGIN__`,we=`__REALM_BUILD_ENV_FILE_DEFAULTS__`,_=`__REALM_VERSION__`,v=`\0${ce}`,y=`\0${ie}`,b=`\0${ae}`,x=`\0${se}`,S=`\0${oe}`,C=`\0${re}`,w=`\0${ne}`,T=`\0${te}`,E=`\0${le}`,D=`@redocly/theme`,Te=RegExp(`^${D}(?:/|$)`),O=de(import.meta.url),Ee=`window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;window.__getReactRefreshIgnoredExports = ({ id }) => /\\.page\\.[jt]sx?$/.test(id) ? ['frontmatter'] : [];`,De=`/__realm_react_refresh__.js`,Oe=`<script type="module" src="/bundledDevClient.mjs"><\/script>`,ke=[`@redocly/api-docs`,`@redocly/replay`,`@redocly/theme`];function Ae(e){let n=c(e.contentDir);return{appType:`custom`,build:{rollupOptions:{input:n.clientEntryPath,...e.lazyDevCompilation===void 0?{}:{experimental:{devMode:{lazy:e.lazyDevCompilation}}}}},clearScreen:!1,logLevel:e.logger.isDebugEnabled(`runtime:vite`)?`info`:`warn`,customLogger:j(e.logger.child(ue)),define:A({enableLazyStaticData:e.enableLazyStaticData,themePathPrefixFromGlobal:!0}),experimental:{bundledDev:!0},oxc:{plugins:{styledComponents:{ssr:!0}}},resolve:{tsconfigPaths:!0},plugins:[P({externalizeForSsr:e.externalizeReactForSsr===!0}),Fe(),...be(),qe(n.clientEntryPath),He(e.templateSetProvider,e.contentDir),Le(),I(e.styledComponentsDependencies,e.styledComponentsRoots),Z(e.contentDir),L(),Ue(),t({contentDir:e.contentDir,outputDir:i(e.contentDir),registerSource:e.registerCodeAssetSource,logger:e.logger}),We(),q(),R(n,e.templateSetProvider,e.contentDir,e.serverModuleSet)],publicDir:!1,root:e.contentDir}}function je(){try{return O("../../package.json").version}catch{return`dev`}}function k(e,t){return e?t===`off`?`off`:`on`:t===`on`?`on`:`off`}function A(e){let t={[g]:JSON.stringify(e.enableLazyStaticData),[_]:JSON.stringify(je()),"process.env.REDOCLY_FIRST_PARTY":JSON.stringify(`true`),"process.env.REDOCLY_TELEMETRY":JSON.stringify(k(!!e.production,process.env.REDOCLY_TELEMETRY)),"process.env.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED":JSON.stringify(n().REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED===`true`?`true`:`false`),"process.env.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED":JSON.stringify(n().REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED===`true`?`true`:`false`)};for(let[e,n]of Object.entries(r()))t[`process.env.${e}`]=JSON.stringify(n);return e.production&&(t[`process.env.NODE_ENV`]=JSON.stringify(`production`)),e.themePathPrefixFromGlobal&&(t[`process.env.REDOCLY_PREFIX_PATHS`]=`globalThis.__REALM_PATH_PREFIX__`),t}function j(e){let t=/* @__PURE__ */ new Set;return he(`info`,{allowClearScreen:!1,customLogger:{hasWarned:!1,clearScreen(){},hasErrorLogged(e){return t.has(e.message)},info(t){if(t.includes(`│ gzip:`)){e.debug(`\n${t}`);return}let n=t.trim();n!==``&&e.info(n)},warn(t){M(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},warnOnce(t){M(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},error(n,r){r?.error&&t.add(r.error.message),e.error(n)}}})}function M(e){return e.includes(`Failed to load source map`)||e.includes(`points to missing source files`)&&/[\\/]node_modules[\\/]/.test(e)}const N=/^(?:react|react-dom|react-router|react-router-dom)(?:\/|$)/,Me=/^react-router(?:-dom)?(?:\/|$)/;function Ne(e){return N.test(e)}function Pe(e){let t=fe(e).href,n=`export * from ${JSON.stringify(t)}; export { default } from ${JSON.stringify(t)};`;return`data:text/javascript,${encodeURIComponent(n)}`}function P(e){let t=d(import.meta.url);return{enforce:`pre`,name:`react-singleton-alias`,resolveId:{filter:{id:N},handler(n){if(Me.test(n)){let r=n.replace(/^react-router-dom/,`react-router`);return e.externalizeForSsr&&this.environment?.name===`ssr`?{external:!0,id:import.meta.resolve(r)}:this.resolve(r,t,{skipSelf:!0})}let r;try{r=O.resolve(n)}catch{return null}return e.externalizeForSsr&&this.environment?.name===`ssr`?{external:!0,id:Pe(r)}:r}}}}const F=/^@markdoc\/markdoc(?=\/|$)/;function Fe(){let e=import.meta.url.startsWith(`file:`)?d(import.meta.url):void 0;return{enforce:`pre`,name:`markdoc-fork-alias`,async resolveId(t,n,r){if(!F.test(t))return null;let i=t.replace(F,`@redocly/markdoc`),a={...r,skipSelf:!0};return(e?await this.resolve(i,e,a):null)??this.resolve(i,n,a)}}}const Ie=/\.(m?ts|[jt]sx|js)$/;function Le(){let e=null;return{name:`ssr-transform`,apply:`serve`,buildStart(){e=_e},async transform(t,n){if(this.environment?.name!==`ssr`||!Ie.test(n))return null;let r=await h(t,n,{sourcemap:!0,plugins:{styledComponents:{ssr:!0}}});await e;let[i]=ve(r.code);if(i.length===0)return{code:r.code,map:r.map};let a=r.code;for(let e=i.length-1;e>=0;e--){let t=i[e],r=t.n;if(!r||!(r.startsWith(`.`)||r.startsWith(`virtual:`)||r.startsWith(`@redocly/theme`)||Ne(r)||r===`styled-components`||r===`file-saver`))continue;let o=await this.resolve(r,n);if(!o||o.external&&!Ne(r))continue;let s=et(o.id);if(s===r)continue;let c=t.d===-1?s:JSON.stringify(s);a=a.slice(0,t.s)+c+a.slice(t.e)}return{code:a,map:r.map}}}}const Re=/\/node_modules\/@redocly\/(?:api-docs|replay)\/.*\.m?js$/,ze=(()=>{let t=[],n;try{n=p(O.resolve(`@redocly/api-docs/package.json`)),t.push(n)}catch{}if(n)try{let e=p(O.resolve(`@redocly/replay`,{paths:[n]}));for(;e!==p(e)&&!f(m(e,`package.json`));)e=p(e);f(m(e,`package.json`))&&t.push(e)}catch{}return t.map(e).filter(e=>!e.includes(`/node_modules/`))})();function Be(t,n,r){if(Re.test(t))return!0;if(!/\.m?js$/.test(t))return!1;let i=e(t);return ze.some(e=>i.startsWith(`${e}/`))||r.some(t=>i.startsWith(`${e(t)}/`))?!0:n.some(e=>i.includes(`/node_modules/${e}/`))}function I(e=[],t=[]){let n=!1;return{name:`redocly-dep-styled-components`,configResolved(e){n=e.command===`serve`},async transform(r,i){if(n&&this.environment?.name===`ssr`)return null;let a=(i.split(`?`,1)[0]??i).replace(/^\/@fs/,``);if(!Be(a,e,t)||!r.includes(`styled`))return null;let{code:o,map:s}=await h(r,a,{sourcemap:n,plugins:{styledComponents:{ssr:!0}}});return{code:o,map:s}}}}function L(){return{name:`realm-api-docs-global-style-stub`,load(t){return e(t.split(`?`,1)[0]??t).endsWith(`/api-docs/lib/components/GlobalStyle.js`)?`export function GlobalStyle() { return null; }`:null}}}function R(e,t,n,r=o()){return{name:`templates-virtual-module`,resolveId(e){return e===`virtual:realm-templates`?v:e===`virtual:realm-runtime`?y:e===`virtual:realm-server-fns`?b:e===`virtual:realm-server-routes`?x:e===`virtual:realm-server-modules`?S:e===`virtual:realm-mcp-tools`?C:e===`virtual:realm-markdoc-schema`?w:e===`virtual:realm-markdoc-components`?T:e===`virtual:realm-theme-styles`?E:null},async load(i){if(i===y){let t=u(e.appModulePath);return`export { useLoaderData, usePageData, usePageProps, usePageSharedData, useSharedData, prefetchPage, useL10nHref } from ${JSON.stringify(t)};`}if(i===b){let t=e.serverFnFiles.map(e=>` ${JSON.stringify(e.id)}: async () => (await import(${JSON.stringify(u(e.filePath))}))[${JSON.stringify(e.exportName)}],`),n=e.serverFnFiles.map(e=>` ${JSON.stringify(e.id)}: ${JSON.stringify({plugin:e.plugin,cacheable:e.cacheable,markdoc:e.markdoc})},`);return[`const serverFnLoaders = {`,...t,`};`,`const serverFnMetadata = {`,...n,`};`,`globalThis.__REALM_SERVER_FN_LOADERS__ = {`,` ...(globalThis.__REALM_SERVER_FN_LOADERS__ ?? {}),`,` ...serverFnLoaders,`,`};`,`globalThis.__REALM_SERVER_FN_METADATA__ = {`,` ...(globalThis.__REALM_SERVER_FN_METADATA__ ?? {}),`,` ...serverFnMetadata,`,`};`,`export { serverFnLoaders };`].join(`
2
- `)}if(i===x)return z(e.serverRouteFiles);if(i===S)return V(ee(r,n));if(i===C)return B(e.mcpToolFiles);if(i===w)return G(s()!==void 0&&this.environment?.mode===`dev`?null:H(n));if(i===T)return K(U(n,`components.tsx`));if(i===E)return W(Ve(n,`styles.css`));if(i!==v)return null;let a=await t.current();return[`export const templateLoaders = {`,...l(a,n).map(e=>` ${JSON.stringify(e.templateId)}: () => import(${JSON.stringify(e.filePath)}),`),`};`].join(`
1
+ import{userMarkdocSchemaFailure as e}from"../content-layer/markdown/constants/tag-sets.js";import{getContentAssetsOutputDir as t,getRuntimeOutputDir as n}from"../shared/constants/runtime-layout.js";import{toPosixPath as r}from"../shared/utils/to-posix-path.js";import{getProcessEnv as i,getPublicEnv as a}from"../shared/public-env.js";import{createCodeAssetsPlugin as o}from"./code-assets.js";import{createEmptyServerModuleSet as s}from"../content-layer/server-modules/module-set.js";import{resolveRuntimeEntryFiles as c,resolveRuntimeServerModuleFiles as ee,resolveRuntimeTemplateFiles as l,toViteFsModuleId as u}from"./runtime-files.js";import{MARKDOC_COMPONENTS_VIRTUAL_MODULE_ID as te,MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as ne,MCP_TOOLS_VIRTUAL_MODULE_ID as re,RUNTIME_HOOKS_VIRTUAL_MODULE_ID as ie,SERVER_FNS_VIRTUAL_MODULE_ID as ae,SERVER_MODULES_VIRTUAL_MODULE_ID as oe,SERVER_ROUTES_VIRTUAL_MODULE_ID as se,TEMPLATES_VIRTUAL_MODULE_ID as ce,THEME_STYLES_VIRTUAL_MODULE_ID as le}from"./constants/virtual-modules.js";import{VITE_LOG_STREAM as ue}from"../shared/constants/log-streams.js";import{createRequire as de}from"node:module";import{fileURLToPath as d,pathToFileURL as fe}from"node:url";import{existsSync as f,readdirSync as pe}from"node:fs";import{dirname as p,join as m,resolve as me}from"node:path";import he from"@redocly/markdoc";import ge from"js-yaml";import{createLogger as _e,transformWithOxc as h}from"vite";import{init as ve,parse as ye}from"es-module-lexer";import be from"@vitejs/plugin-react";const g=`__REALM_ENABLE_LAZY_STATIC_DATA__`,xe=`__REALM_TEMPLATE_IDS__`,Se=`__REALM_BUILD_PATH_PREFIX__`,Ce=`__REALM_BUILD_DEV_LOGIN__`,we=`__REALM_BUILD_ENV_FILE_DEFAULTS__`,_=`__REALM_VERSION__`,v=`\0${ce}`,y=`\0${ie}`,b=`\0${ae}`,x=`\0${se}`,S=`\0${oe}`,C=`\0${re}`,w=`\0${ne}`,T=`\0${te}`,E=`\0${le}`,D=`@redocly/theme`,Te=RegExp(`^${D}(?:/|$)`),O=de(import.meta.url),Ee=`window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;window.__getReactRefreshIgnoredExports = ({ id }) => /\\.page\\.[jt]sx?$/.test(id) ? ['frontmatter'] : [];`,De=`/__realm_react_refresh__.js`,Oe=`<script type="module" src="/bundledDevClient.mjs"><\/script>`,ke=[`@redocly/api-docs`,`@redocly/replay`,`@redocly/theme`];function Ae(e){let n=c(e.contentDir);return{appType:`custom`,build:{rollupOptions:{input:n.clientEntryPath,...e.lazyDevCompilation===void 0?{}:{experimental:{devMode:{lazy:e.lazyDevCompilation}}}}},clearScreen:!1,logLevel:e.logger.isDebugEnabled(`runtime:vite`)?`info`:`warn`,customLogger:j(e.logger.child(ue)),define:A({enableLazyStaticData:e.enableLazyStaticData,themePathPrefixFromGlobal:!0}),experimental:{bundledDev:!0},oxc:{plugins:{styledComponents:{ssr:!0}}},resolve:{tsconfigPaths:!0},plugins:[P({externalizeForSsr:e.externalizeReactForSsr===!0}),Fe(),...be(),qe(n.clientEntryPath),He(e.templateSetProvider,e.contentDir),Le(),I(e.styledComponentsDependencies,e.styledComponentsRoots),Z(e.contentDir),L(),Ue(),o({contentDir:e.contentDir,outputDir:t(e.contentDir),registerSource:e.registerCodeAssetSource,logger:e.logger}),We(),q(),R(n,e.templateSetProvider,e.contentDir,e.serverModuleSet)],publicDir:!1,root:e.contentDir}}function je(){try{return O("../../package.json").version}catch{return`dev`}}function k(e,t){return e?t===`off`?`off`:`on`:t===`on`?`on`:`off`}function A(e){let t={[g]:JSON.stringify(e.enableLazyStaticData),[_]:JSON.stringify(je()),"process.env.REDOCLY_FIRST_PARTY":JSON.stringify(`true`),"process.env.REDOCLY_TELEMETRY":JSON.stringify(k(!!e.production,process.env.REDOCLY_TELEMETRY)),"process.env.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED":JSON.stringify(i().REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED===`true`?`true`:`false`),"process.env.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED":JSON.stringify(i().REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED===`true`?`true`:`false`)};for(let[e,n]of Object.entries(a()))t[`process.env.${e}`]=JSON.stringify(n);return e.production&&(t[`process.env.NODE_ENV`]=JSON.stringify(`production`)),e.themePathPrefixFromGlobal&&(t[`process.env.REDOCLY_PREFIX_PATHS`]=`globalThis.__REALM_PATH_PREFIX__`),t}function j(e){let t=/* @__PURE__ */ new Set;return _e(`info`,{allowClearScreen:!1,customLogger:{hasWarned:!1,clearScreen(){},hasErrorLogged(e){return t.has(e.message)},info(t){if(t.includes(`│ gzip:`)){e.debug(`\n${t}`);return}let n=t.trim();n!==``&&e.info(n)},warn(t){M(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},warnOnce(t){M(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},error(n,r){r?.error&&t.add(r.error.message),e.error(n)}}})}function M(e){return e.includes(`Failed to load source map`)||e.includes(`points to missing source files`)&&/[\\/]node_modules[\\/]/.test(e)}const N=/^(?:react|react-dom|react-router|react-router-dom)(?:\/|$)/,Me=/^react-router(?:-dom)?(?:\/|$)/;function Ne(e){return N.test(e)}function Pe(e){let t=fe(e).href,n=`export * from ${JSON.stringify(t)}; export { default } from ${JSON.stringify(t)};`;return`data:text/javascript,${encodeURIComponent(n)}`}function P(e){let t=d(import.meta.url);return{enforce:`pre`,name:`react-singleton-alias`,resolveId:{filter:{id:N},handler(n){if(Me.test(n)){let r=n.replace(/^react-router-dom/,`react-router`);return e.externalizeForSsr&&this.environment?.name===`ssr`?{external:!0,id:import.meta.resolve(r)}:this.resolve(r,t,{skipSelf:!0})}let r;try{r=O.resolve(n)}catch{return null}return e.externalizeForSsr&&this.environment?.name===`ssr`?{external:!0,id:Pe(r)}:r}}}}const F=/^@markdoc\/markdoc(?=\/|$)/;function Fe(){let e=import.meta.url.startsWith(`file:`)?d(import.meta.url):void 0;return{enforce:`pre`,name:`markdoc-fork-alias`,async resolveId(t,n,r){if(!F.test(t))return null;let i=t.replace(F,`@redocly/markdoc`),a={...r,skipSelf:!0};return(e?await this.resolve(i,e,a):null)??this.resolve(i,n,a)}}}const Ie=/\.(m?ts|[jt]sx|js)$/;function Le(){let e=null;return{name:`ssr-transform`,apply:`serve`,buildStart(){e=ve},async transform(t,n){if(this.environment?.name!==`ssr`||!Ie.test(n))return null;let r=await h(t,n,{sourcemap:!0,plugins:{styledComponents:{ssr:!0}}});await e;let[i]=ye(r.code);if(i.length===0)return{code:r.code,map:r.map};let a=r.code;for(let e=i.length-1;e>=0;e--){let t=i[e],r=t.n;if(!r||!(r.startsWith(`.`)||r.startsWith(`virtual:`)||r.startsWith(`@redocly/theme`)||Ne(r)||r===`styled-components`||r===`file-saver`))continue;let o=await this.resolve(r,n);if(!o||o.external&&!Ne(r))continue;let s=et(o.id);if(s===r)continue;let c=t.d===-1?s:JSON.stringify(s);a=a.slice(0,t.s)+c+a.slice(t.e)}return{code:a,map:r.map}}}}const Re=/\/node_modules\/@redocly\/(?:api-docs|replay)\/.*\.m?js$/,ze=(()=>{let e=[],t;try{t=p(O.resolve(`@redocly/api-docs/package.json`)),e.push(t)}catch{}if(t)try{let n=p(O.resolve(`@redocly/replay`,{paths:[t]}));for(;n!==p(n)&&!f(m(n,`package.json`));)n=p(n);f(m(n,`package.json`))&&e.push(n)}catch{}return e.map(r).filter(e=>!e.includes(`/node_modules/`))})();function Be(e,t,n){if(Re.test(e))return!0;if(!/\.m?js$/.test(e))return!1;let i=r(e);return ze.some(e=>i.startsWith(`${e}/`))||n.some(e=>i.startsWith(`${r(e)}/`))?!0:t.some(e=>i.includes(`/node_modules/${e}/`))}function I(e=[],t=[]){let n=!1;return{name:`redocly-dep-styled-components`,configResolved(e){n=e.command===`serve`},async transform(r,i){if(n&&this.environment?.name===`ssr`)return null;let a=(i.split(`?`,1)[0]??i).replace(/^\/@fs/,``);if(!Be(a,e,t)||!r.includes(`styled`))return null;let{code:o,map:s}=await h(r,a,{sourcemap:n,plugins:{styledComponents:{ssr:!0}}});return{code:o,map:s}}}}function L(){return{name:`realm-api-docs-global-style-stub`,load(e){return r(e.split(`?`,1)[0]??e).endsWith(`/api-docs/lib/components/GlobalStyle.js`)?`export function GlobalStyle() { return null; }`:null}}}function R(t,n,r,i=s()){return{name:`templates-virtual-module`,resolveId(e){return e===`virtual:realm-templates`?v:e===`virtual:realm-runtime`?y:e===`virtual:realm-server-fns`?b:e===`virtual:realm-server-routes`?x:e===`virtual:realm-server-modules`?S:e===`virtual:realm-mcp-tools`?C:e===`virtual:realm-markdoc-schema`?w:e===`virtual:realm-markdoc-components`?T:e===`virtual:realm-theme-styles`?E:null},async load(a){if(a===y){let e=u(t.appModulePath);return`export { useLoaderData, usePageData, usePageProps, usePageSharedData, useSharedData, prefetchPage, useL10nHref } from ${JSON.stringify(e)};`}if(a===b){let e=t.serverFnFiles.map(e=>` ${JSON.stringify(e.id)}: async () => (await import(${JSON.stringify(u(e.filePath))}))[${JSON.stringify(e.exportName)}],`),n=t.serverFnFiles.map(e=>` ${JSON.stringify(e.id)}: ${JSON.stringify({plugin:e.plugin,cacheable:e.cacheable,markdoc:e.markdoc})},`);return[`const serverFnLoaders = {`,...e,`};`,`const serverFnMetadata = {`,...n,`};`,`globalThis.__REALM_SERVER_FN_LOADERS__ = {`,` ...(globalThis.__REALM_SERVER_FN_LOADERS__ ?? {}),`,` ...serverFnLoaders,`,`};`,`globalThis.__REALM_SERVER_FN_METADATA__ = {`,` ...(globalThis.__REALM_SERVER_FN_METADATA__ ?? {}),`,` ...serverFnMetadata,`,`};`,`export { serverFnLoaders };`].join(`
2
+ `)}if(a===x)return z(t.serverRouteFiles);if(a===S)return V(ee(i,r));if(a===C)return B(t.mcpToolFiles);if(a===w)return G(e()!==void 0&&this.environment?.mode===`dev`?null:H(r));if(a===T)return K(U(r,`components.tsx`));if(a===E)return W(Ve(r,`styles.css`));if(a!==v)return null;let o=await n.current();return[`export const templateLoaders = {`,...l(o,r).map(e=>` ${JSON.stringify(e.templateId)}: () => import(${JSON.stringify(e.filePath)}),`),`};`].join(`
3
3
  `)}}}function z(e){return[`export const serverRoutes = [`,...e.map(e=>` { ${[`plugin: ${JSON.stringify(e.plugin)}`,...e.method===void 0?[]:[`method: ${JSON.stringify(e.method)}`],`path: ${JSON.stringify(e.path)}`,...e.auth===void 0?[]:[`auth: ${JSON.stringify(e.auth)}`],`loadHandler: async () => (await import(${JSON.stringify(u(e.handler.filePath))}))[${JSON.stringify(e.handler.exportName)}]`].join(`, `)} },`),`];`].join(`
4
4
  `)}function B(e){return`export const mcpTools = ${JSON.stringify(e,null,2)};`}function V(e){return[`export const serverModules = {`,...e.map(e=>` ${JSON.stringify(e.key)}: () => import(${JSON.stringify(u(e.filePath))}),`),`};`].join(`
5
- `)}function H(e){return U(e,`schema.ts`)}function U(e,t){let n=m(e,`@theme`,`markdoc`,t);return f(n)?n:null}function Ve(e,t){let n=m(e,`@theme`,t);return f(n)?n:null}function W(e){return e?`import ${JSON.stringify(e)};`:`export {};`}function G(e){return[...e?[`import * as userSchema from ${JSON.stringify(e)};`,`const { tags = {}, nodes = {}, functions = {}, default: _default, ...topLevelTags } = userSchema;`,`const tagNameOf = ([key, schema]) => [schema && typeof schema.tagName === 'string' ? schema.tagName : key, schema];`,`const markdocNodeNames = new Set(${JSON.stringify(Object.keys(ge.nodes))});`,`const namedEntries = Object.entries({ ...topLevelTags, ...tags }).map(tagNameOf);`,`export const userMarkdocTags = Object.fromEntries(namedEntries.filter(([name]) => !markdocNodeNames.has(name)));`,`export const userMarkdocNodes = { ...Object.fromEntries(namedEntries.filter(([name]) => markdocNodeNames.has(name))), ...nodes };`,`export const userMarkdocFunctions = { ...functions };`]:[`export const userMarkdocTags = {};`,`export const userMarkdocNodes = {};`,`export const userMarkdocFunctions = {};`],`globalThis.__REALM_MARKDOC_USER_SCHEMA__ = { tags: userMarkdocTags, nodes: userMarkdocNodes, functions: userMarkdocFunctions };`].join(`
5
+ `)}function H(e){return U(e,`schema.ts`)}function U(e,t){let n=m(e,`@theme`,`markdoc`,t);return f(n)?n:null}function Ve(e,t){let n=m(e,`@theme`,t);return f(n)?n:null}function W(e){return e?`import ${JSON.stringify(e)};`:`export {};`}function G(e){return[...e?[`import * as userSchema from ${JSON.stringify(e)};`,`const { tags = {}, nodes = {}, functions = {}, default: _default, ...topLevelTags } = userSchema;`,`const tagNameOf = ([key, schema]) => [schema && typeof schema.tagName === 'string' ? schema.tagName : key, schema];`,`const markdocNodeNames = new Set(${JSON.stringify(Object.keys(he.nodes))});`,`const namedEntries = Object.entries({ ...topLevelTags, ...tags }).map(tagNameOf);`,`export const userMarkdocTags = Object.fromEntries(namedEntries.filter(([name]) => !markdocNodeNames.has(name)));`,`export const userMarkdocNodes = { ...Object.fromEntries(namedEntries.filter(([name]) => markdocNodeNames.has(name))), ...nodes };`,`export const userMarkdocFunctions = { ...functions };`]:[`export const userMarkdocTags = {};`,`export const userMarkdocNodes = {};`,`export const userMarkdocFunctions = {};`],`globalThis.__REALM_MARKDOC_USER_SCHEMA__ = { tags: userMarkdocTags, nodes: userMarkdocNodes, functions: userMarkdocFunctions };`].join(`
6
6
  `)}function K(e){return e?[`import * as userComponents from ${JSON.stringify(e)};`,`export const userMarkdocComponents = { ...userComponents };`].join(`
7
7
  `):`export const userMarkdocComponents = {};`}function He(e,t){let n=null,r=null,i=(e,t,n)=>{let r=e.get(n);return r===void 0?null:{code:`${t}
8
8
 
@@ -23,6 +23,6 @@ export default { saveAs };
23
23
  `:`import _m from ${JSON.stringify(u(n))};\nexport const saveAs = _m.saveAs ?? _m;\nexport default _m;\n`:null},transform(e,t){return t!==r||this.environment?.name!==`ssr`?null:{code:`import { createRequire as __scCreateRequire } from "node:module";
24
24
  const require = __scCreateRequire(import.meta.url);
25
25
  `+e,map:null}}}}function We(){let e=`\0browser-stream-shim:stream`;return{enforce:`pre`,name:`browser-stream-shim`,resolveId(t){return t===`stream`&&this.environment?.name===`client`?e:null},load(t){return t===e?[`export class Transform {`,` constructor() {`,` throw new Error("Node.js streams are not available in the browser.");`,` }`,`}`,`export default { Transform };`].join(`
26
- `):null}}}const Ge=/\.ya?ml(?:$|\?)/,Ke=/[?&](?:worker|sharedworker|raw|url)\b/;function q(){return{name:`realm-yaml`,transform(e,t){if(!Ge.test(t)||Ke.test(t))return null;try{return{code:`export default ${JSON.stringify(ye.load(e))};`,map:null}}catch(e){let n=t.split(`?`,1)[0]??t;return this.error(`Failed to parse YAML ${n}: ${e.message}`)}}}}const J=`virtual:realm-react-refresh-inject`,Y=`\0${J}`;function qe(e){return{name:`dev-entry`,apply:`serve`,resolveId(e){return e===J?Y:null},load(e){return e===Y?`import { injectIntoGlobalHook } from "/@react-refresh";
26
+ `):null}}}const Ge=/\.ya?ml(?:$|\?)/,Ke=/[?&](?:worker|sharedworker|raw|url)\b/;function q(){return{name:`realm-yaml`,transform(e,t){if(!Ge.test(t)||Ke.test(t))return null;try{return{code:`export default ${JSON.stringify(ge.load(e))};`,map:null}}catch(e){let n=t.split(`?`,1)[0]??t;return this.error(`Failed to parse YAML ${n}: ${e.message}`)}}}}const J=`virtual:realm-react-refresh-inject`,Y=`\0${J}`;function qe(e){return{name:`dev-entry`,apply:`serve`,resolveId(e){return e===J?Y:null},load(e){return e===Y?`import { injectIntoGlobalHook } from "/@react-refresh";
27
27
  injectIntoGlobalHook(window);
28
- `:null},transform(t,n){return this.environment?.name!==`client`||n!==e?null:{code:`import ${JSON.stringify(J)};\n`+t,map:null}}}}const X=/* @__PURE__ */ new Map;function Je(e){let t=X.get(e);if(t)return t;let n=/* @__PURE__ */ new Set,r=e=>{let t;try{t=pe(e,{withFileTypes:!0})}catch{return}for(let i of t){if(i.name.startsWith(`.`))continue;let t=m(e,i.name);i.isDirectory()?r(t):n.add(t)}};return r(e),X.set(e,n),n}function Ye(e){if(e===void 0){X.clear();return}X.delete(m(e,`@theme`))}function Z(t){let n=t&&`${e(me(t))}/`;return{enforce:`pre`,name:`redocly-theme-source`,resolveId:{filter:{id:Te},handler(e,r){let i=Ze(e,{contentDir:t,importer:r}),a=$(r);return i&&n&&e===D&&this.environment?.mode===`dev`&&this.environment.name===`ssr`&&a?.startsWith(n)?`${i}?content-importer=${encodeURIComponent(a)}`:i}}}}function Q(e){return e===D?`index`:e.startsWith(`${D}/`)?e.slice(`${D}/`.length).replace(/^src\//,``):null}function Xe(e,t){let n=Q(e);if(n===null||!t.contentDir)return null;let r=m(t.contentDir,`@theme`),i=Je(r),a=$(t.importer);for(let e of $e(r,n))if(e!==a&&i.has(e))return e;return null}function Ze(e,t={}){let n=Q(e);if(n===null)return null;let r=Xe(e,t);if(r)return r;let i=p(O.resolve(`${D}/package.json`)),a=m(i,`src`);for(let e of $e(a,n))if(f(e))return e;return null}const Qe=/\.(?:tsx?|jsx?)$/;function $e(e,t){return Qe.test(t)?[m(e,t)]:[m(e,`${t}.ts`),m(e,`${t}.tsx`),m(e,`${t}.js`),m(e,`${t}.jsx`),m(e,t,`index.ts`),m(e,t,`index.tsx`),m(e,t,`index.js`),m(e,t,`index.jsx`)]}function $(e){return e?(e.split(`?`,1)[0]??e).replace(/^\/@fs/,``):null}function et(e){return e.startsWith(`\0`)?`/@id/${e.replace(`\0`,`__x00__`)}`:e.startsWith(`/`)?u(e):e}export{Oe as BUNDLED_DEV_CLIENT_SCRIPT_TAG,Ce as DEV_LOGIN_DEFINE,g as ENABLE_LAZY_STATIC_DATA_DEFINE,we as ENV_FILE_DEFAULTS_DEFINE,Se as PATH_PREFIX_DEFINE,Ee as REACT_REFRESH_PREAMBLE,De as REACT_REFRESH_PREAMBLE_PATH,ke as REDOCLY_SSR_NO_EXTERNAL,w as RESOLVED_MARKDOC_SCHEMA_VIRTUAL_MODULE_ID,xe as TEMPLATE_IDS_DEFINE,_ as VERSION_DEFINE,L as createApiDocsGlobalStyleStubPlugin,Ae as createBaseViteConfig,A as createDefineValues,I as createDepStyledComponentsTransformPlugin,P as createReactSingletonAliasPlugin,R as createTemplatesVirtualModulePlugin,Z as createThemeSourcePlugin,j as createViteCustomLogger,q as createYamlPlugin,Xe as findThemeOverride,a as getRuntimeOutputDir,Ye as invalidateThemeOverrideIndex,K as renderMarkdocComponentsModule,G as renderMarkdocSchemaModule,B as renderMcpToolsModule,V as renderServerModulesModule,z as renderServerRoutesModule,W as renderThemeStylesModule,k as resolveClientTelemetryFlag,Ze as resolveThemeSourceImport,H as userMarkdocSchemaFile};
28
+ `:null},transform(t,n){return this.environment?.name!==`client`||n!==e?null:{code:`import ${JSON.stringify(J)};\n`+t,map:null}}}}const X=/* @__PURE__ */ new Map;function Je(e){let t=X.get(e);if(t)return t;let n=/* @__PURE__ */ new Set,r=e=>{let t;try{t=pe(e,{withFileTypes:!0})}catch{return}for(let i of t){if(i.name.startsWith(`.`))continue;let t=m(e,i.name);i.isDirectory()?r(t):n.add(t)}};return r(e),X.set(e,n),n}function Ye(e){if(e===void 0){X.clear();return}X.delete(m(e,`@theme`))}function Z(e){let t=e&&`${r(me(e))}/`;return{enforce:`pre`,name:`redocly-theme-source`,resolveId:{filter:{id:Te},handler(n,r){let i=Ze(n,{contentDir:e,importer:r}),a=$(r);return i&&t&&n===D&&this.environment?.mode===`dev`&&this.environment.name===`ssr`&&a?.startsWith(t)?`${i}?content-importer=${encodeURIComponent(a)}`:i}}}}function Q(e){return e===D?`index`:e.startsWith(`${D}/`)?e.slice(`${D}/`.length).replace(/^src\//,``):null}function Xe(e,t){let n=Q(e);if(n===null||!t.contentDir)return null;let r=m(t.contentDir,`@theme`),i=Je(r),a=$(t.importer);for(let e of $e(r,n))if(e!==a&&i.has(e))return e;return null}function Ze(e,t={}){let n=Q(e);if(n===null)return null;let r=Xe(e,t);if(r)return r;let i=p(O.resolve(`${D}/package.json`)),a=m(i,`src`);for(let e of $e(a,n))if(f(e))return e;return null}const Qe=/\.(?:tsx?|jsx?)$/;function $e(e,t){return Qe.test(t)?[m(e,t)]:[m(e,`${t}.ts`),m(e,`${t}.tsx`),m(e,`${t}.js`),m(e,`${t}.jsx`),m(e,t,`index.ts`),m(e,t,`index.tsx`),m(e,t,`index.js`),m(e,t,`index.jsx`)]}function $(e){return e?(e.split(`?`,1)[0]??e).replace(/^\/@fs/,``):null}function et(e){return e.startsWith(`\0`)?`/@id/${e.replace(`\0`,`__x00__`)}`:e.startsWith(`/`)?u(e):e}export{Oe as BUNDLED_DEV_CLIENT_SCRIPT_TAG,Ce as DEV_LOGIN_DEFINE,g as ENABLE_LAZY_STATIC_DATA_DEFINE,we as ENV_FILE_DEFAULTS_DEFINE,Se as PATH_PREFIX_DEFINE,Ee as REACT_REFRESH_PREAMBLE,De as REACT_REFRESH_PREAMBLE_PATH,ke as REDOCLY_SSR_NO_EXTERNAL,w as RESOLVED_MARKDOC_SCHEMA_VIRTUAL_MODULE_ID,xe as TEMPLATE_IDS_DEFINE,_ as VERSION_DEFINE,L as createApiDocsGlobalStyleStubPlugin,Ae as createBaseViteConfig,A as createDefineValues,I as createDepStyledComponentsTransformPlugin,P as createReactSingletonAliasPlugin,R as createTemplatesVirtualModulePlugin,Z as createThemeSourcePlugin,j as createViteCustomLogger,q as createYamlPlugin,Xe as findThemeOverride,n as getRuntimeOutputDir,Ye as invalidateThemeOverrideIndex,K as renderMarkdocComponentsModule,G as renderMarkdocSchemaModule,B as renderMcpToolsModule,V as renderServerModulesModule,z as renderServerRoutesModule,W as renderThemeStylesModule,k as resolveClientTelemetryFlag,Ze as resolveThemeSourceImport,H as userMarkdocSchemaFile};
@@ -1 +1 @@
1
- import{takePluginWorkTime as e}from"../content-layer/plugins/work-time.js";import{API_DOCS_PLUGIN_ID as t}from"../content-layer/plugins/internal/api-docs/server/shared.js";import{sendServerEvent as n}from"../server/telemetry/sender.js";import{ulid as r}from"ulid";function i(i){let{startedAt:a,cold:o,state:s,...c}=i,l=e(t),u=0;for(let e of s.entitiesByKey.values())e.pluginId===`internal.api-docs`&&e.type===`api`&&(u+=1);return n({type:`com.redocly.build.plugin.apiDocs`,signal:`trace`,time:a,endTime:new Date(a.getTime()+l.ms),data:{apis:u,entities:l.loaderCalls,cold:o},actor:{id:`ann_${r()}`,object:`user`,uri:``}},{timeoutMs:5e3,...c,service:`realm-cli`})}export{i as sendApiDocsBuildEvent};
1
+ import{API_DOCS_PLUGIN_ID as e}from"../content-layer/plugins/internal/api-docs/server/shared.js";import{sendServerEvent as t}from"../server/telemetry/sender.js";import{takePluginWorkTime as n}from"../content-layer/plugins/work-time.js";import{ulid as r}from"ulid";function i(i){let{startedAt:a,cold:o,state:s,...c}=i,l=n(e),u=0;for(let e of s.entitiesByKey.values())e.pluginId===`internal.api-docs`&&e.type===`api`&&(u+=1);return t({type:`com.redocly.build.plugin.apiDocs`,signal:`trace`,time:a,endTime:new Date(a.getTime()+l.ms),data:{apis:u,entities:l.loaderCalls,cold:o},actor:{id:`ann_${r()}`,object:`user`,uri:``}},{timeoutMs:5e3,...c,service:`realm-cli`})}export{i as sendApiDocsBuildEvent};
package/dist/cli/args.js CHANGED
@@ -1 +1 @@
1
- import{createLogger as e,isLogLevel as t}from"../shared/logger.js";import{isRemoteDatabaseUrl as n}from"../content-layer/database/utils/is-remote-database-url.js";import{createReporter as r}from"../shared/reporter.js";import{loadProjectEnv as i}from"../shared/load-dot-env.js";import{BuildOptionsError as a}from"../bundler/build/run.js";import{CliUsageError as o,parseArgs as s}from"./parse-args.js";import{resolve as c}from"node:path";const l={alias:{h:`help`,D:`debug`,d:`project-dir`},boolean:[`help`,`h`],string:[`project-dir`,`db`,`log-level`]};function u(e){let t=c(y(e[`project-dir`],`--project-dir`)??process.env.REDOCLY_CONTENT_DIR??`.`),n=h(e.db),r=x(e.debug),a=g(e[`log-level`]);i(t);let o=a??_(process.env.REDOCLY_LOG_LEVEL);return{contentDir:t,databaseUrl:n,level:o,debug:r,stacks:r!==!1||o===`debug`,expandPhases:r===!0||o===`debug`}}function d(t,n){let i=e({level:t.level===`debug`?`debug`:`http`,debug:t.debug,output:n});return p(i),{...t,logger:i,reporter:r(n)}}let f;function p(e){if(f===void 0){let e=process.listeners(`warning`).find(e=>e.name===`onWarning`);if(e===void 0||Reflect.get(process,`traceProcessWarnings`)===!0)return;process.off(`warning`,e),process.on(`warning`,e=>{m.has(e.code??``)||f?.warn(e.message,{code:e.code})})}f=e}const m=/* @__PURE__ */ new Set([`MODULE_TYPELESS_PACKAGE_JSON`]);function h(e){let t=y(e,`--db`);if(t!==void 0&&n(t))throw new o(`Invalid value for --db. Expected a local path or file: URL.`);return t}function g(e){if(e!==void 0){if(t(e))return e;throw new o(`Invalid value for --log-level. Expected "debug", "http", "info", "warn" or "error".`)}}function _(e){let n=e?.toLowerCase();return t(n)?n:void 0}function v(e){if(e!==void 0){if(typeof e==`number`&&Number.isInteger(e)&&e>0)return e;if(typeof e==`string`&&/^[1-9]\d*$/.test(e))return Number(e);throw new o(`Invalid value for --port. Expected a positive integer.`)}}function y(e,t){if(e!==void 0){if(typeof e!=`string`||e.trim()===``)throw new o(`Invalid value for ${t}. Expected a non-empty string.`);return e}}function b(e){return typeof e==`string`&&e.length>0?e.split(`,`):void 0}function x(e){if(e===void 0||e===!1)return!1;if(e===!0)return!0;if(typeof e==`string`){let t=S([e]);if(t.length===0)throw T();return t}if(Array.isArray(e)&&e.every(e=>typeof e==`string`)){let t=S(e);if(t.length===0)throw T();return t}throw T()}function S(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.split(`,`)){let n=e.trim();n!==``&&t.add(n)}return[...t]}function C(e){if(e===void 0)return`local`;if(e===`local`||e===`cloud`)return e;throw new o(`Invalid value for --target. Expected "local" or "cloud".`)}function w(e){if(e===void 0)return`nodejs`;if(e===`nodejs`||e===`aws-lambda`)return e;throw new o(`Invalid value for --platform. Expected "nodejs" or "aws-lambda".`)}function T(){return new o(`Invalid value for --debug. Expected a stream name or a comma-separated list.`)}function E(e,t){if(e instanceof o||e instanceof a)return t.stderr(e.message),1;throw e}export{l as COMMON_FLAGS,o as CliUsageError,s as parseArgs,C as parseBuildTarget,x as parseDebugFlag,b as parseHintsFlag,w as parseHostPlatform,y as parseOptionalStringFlag,v as parsePort,E as reportUsageError,u as resolveCommonArgs,d as setUpLogging};
1
+ import{createLogger as e,isLogLevel as t}from"../shared/logger.js";import{isRemoteDatabaseUrl as n}from"../content-layer/database/utils/is-remote-database-url.js";import{loadProjectEnv as r}from"../shared/load-dot-env.js";import{createReporter as i}from"../shared/reporter.js";import{BuildOptionsError as a}from"../bundler/build/run.js";import{CliUsageError as o,parseArgs as s}from"./parse-args.js";import{resolve as c}from"node:path";const l={alias:{h:`help`,D:`debug`,d:`project-dir`},boolean:[`help`,`h`],string:[`project-dir`,`db`,`log-level`]};function u(e){let t=c(y(e[`project-dir`],`--project-dir`)??process.env.REDOCLY_CONTENT_DIR??`.`),n=h(e.db),i=x(e.debug),a=g(e[`log-level`]);r(t);let o=a??_(process.env.REDOCLY_LOG_LEVEL);return{contentDir:t,databaseUrl:n,level:o,debug:i,stacks:i!==!1||o===`debug`,expandPhases:i===!0||o===`debug`}}function d(t,n){let r=e({level:t.level===`debug`?`debug`:`http`,debug:t.debug,output:n});return p(r),{...t,logger:r,reporter:i(n)}}let f;function p(e){if(f===void 0){let e=process.listeners(`warning`).find(e=>e.name===`onWarning`);if(e===void 0||Reflect.get(process,`traceProcessWarnings`)===!0)return;process.off(`warning`,e),process.on(`warning`,e=>{m.has(e.code??``)||f?.warn(e.message,{code:e.code})})}f=e}const m=/* @__PURE__ */ new Set([`MODULE_TYPELESS_PACKAGE_JSON`]);function h(e){let t=y(e,`--db`);if(t!==void 0&&n(t))throw new o(`Invalid value for --db. Expected a local path or file: URL.`);return t}function g(e){if(e!==void 0){if(t(e))return e;throw new o(`Invalid value for --log-level. Expected "debug", "http", "info", "warn" or "error".`)}}function _(e){let n=e?.toLowerCase();return t(n)?n:void 0}function v(e){if(e!==void 0){if(typeof e==`number`&&Number.isInteger(e)&&e>0)return e;if(typeof e==`string`&&/^[1-9]\d*$/.test(e))return Number(e);throw new o(`Invalid value for --port. Expected a positive integer.`)}}function y(e,t){if(e!==void 0){if(typeof e!=`string`||e.trim()===``)throw new o(`Invalid value for ${t}. Expected a non-empty string.`);return e}}function b(e){return typeof e==`string`&&e.length>0?e.split(`,`):void 0}function x(e){if(e===void 0||e===!1)return!1;if(e===!0)return!0;if(typeof e==`string`){let t=S([e]);if(t.length===0)throw T();return t}if(Array.isArray(e)&&e.every(e=>typeof e==`string`)){let t=S(e);if(t.length===0)throw T();return t}throw T()}function S(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.split(`,`)){let n=e.trim();n!==``&&t.add(n)}return[...t]}function C(e){if(e===void 0)return`local`;if(e===`local`||e===`cloud`)return e;throw new o(`Invalid value for --target. Expected "local" or "cloud".`)}function w(e){if(e===void 0)return`nodejs`;if(e===`nodejs`||e===`aws-lambda`)return e;throw new o(`Invalid value for --platform. Expected "nodejs" or "aws-lambda".`)}function T(){return new o(`Invalid value for --debug. Expected a stream name or a comma-separated list.`)}function E(e,t){if(e instanceof o||e instanceof a)return t.stderr(e.message),1;throw e}export{l as COMMON_FLAGS,o as CliUsageError,s as parseArgs,C as parseBuildTarget,x as parseDebugFlag,b as parseHintsFlag,w as parseHostPlatform,y as parseOptionalStringFlag,v as parsePort,E as reportUsageError,u as resolveCommonArgs,d as setUpLogging};
@@ -1 +1 @@
1
- import{stopwatch as e}from"../../shared/logger.js";import{getPathPrefix as t,setGlobalPathPrefix as n}from"../../shared/path-prefix.js";import{formatCommandRows as r,formatCompletion as i,formatContentRow as a,formatFailure as o,formatFileChanges as s,pluralize as c,printBuildHelp as l,shouldUseColors as u}from"../output.js";import{writeBuildOutputMetadata as d}from"../../bundler/build/output-metadata.js";import{assertRuntimeBuildOptions as f,runBuild as p}from"../../bundler/build/run.js";import{validateReactPages as m}from"../validate-react-pages.js";import{sendApiDocsBuildEvent as h}from"../api-docs-build-event.js";import{parseArgs as g}from"../parse-args.js";import{COMMON_FLAGS as _,parseBuildTarget as v,parseHintsFlag as y,parseHostPlatform as b,parseOptionalStringFlag as x,reportUsageError as S,resolveCommonArgs as C,setUpLogging as w}from"../args.js";import{createCliOutput as T,shouldWriteLogGroups as E}from"../log-output/index.js";import{formatProblemCounts as D,reportProblems as O}from"../problems-output.js";import{hasInjectedContentSteps as k,openContentSession as A,recordRunFailure as j,runContentIngestWithStaticDataBuild as M}from"./ingest.js";import N from"node:process";async function P(P,F,I){let L=g(P,{alias:_.alias,boolean:[..._.boolean,`dev-login`],string:[..._.string,`hints`,`target`,`platform`,`path-prefix`]});if(L.help)return l(F.stdout),0;let R,z,B,V;try{let e=C(L);R=w(e,T(F,e)),z=v(L.target),B=b(L.platform),V=x(L[`path-prefix`],`--path-prefix`),f(z,B)}catch(e){return S(e,F)}n(V??N.env.REDOCLY_PREFIX_PATHS??``);let{logger:H,reporter:U}=R,W=u();F.stdout(r([a(R.contentDir),[`Prefix`,t()||void 0]],W)),H.debug(`Process startup took ${N.uptime().toFixed(2)}s`);let G=e(),K,q;try{K=k(I)?void 0:await A(R);let e=/* @__PURE__ */ new Date,{ingestResult:t,problems:n,staticDataResult:r,ignoreMarkdocErrors:a}=await M(R,I,{hints:y(L.hints),session:K}),l=K?.context.state;l&&(q=h({startedAt:e,cold:t.diff.summary.totalPrevious===0,state:l,logger:H}));let u=O(F,n,{ignoreMarkdocErrors:a,groups:E(F)}),f=await(I.runRuntimeBuild??p)({contentDir:R.contentDir,target:z,platform:B,logger:H,reporter:U,templateSet:t.templateSet,serverModuleSet:t.serverModuleSet,devLogin:L[`dev-login`]===!0}),g=await U.run(`Validating React pages`,()=>m({contentDir:R.contentDir,outputDir:f.outputDir,sourceTemplates:t.templateSet.sourceTemplates,databaseUrl:R.databaseUrl,database:K?.database,context:K?.context,logger:H}),({pageCount:e,renderedCount:t,problems:n})=>{if(e===0)return`No React pages`;if(t===0)return`${c(e,`React page`)} unchanged`;let r=t===e?`Checked ${c(e,`React page`)}`:`Checked ${t} of ${c(e,`React page`)}`;return n.length>0?`${r}, ${n.length} failed to render`:r}),_=O(F,g.problems,{ignoreMarkdocErrors:a,groups:E(F)});return await(I.writeBuildOutputMetadata??d)({contentDir:R.contentDir,outputDir:f.outputDir,databaseUrl:R.databaseUrl,database:K?.database,context:K?.context,logger:H}),F.stdout(``),u+_>0?(F.stdout(o(`Build failed`,G(),`${c(u+_,`content error`)} (see Problems above)`,{colors:W,stacks:R.stacks})),1):(F.stdout(i(`Build complete`,G(),[[`Files`,s(t.diff.summary)],[`Built`,c(r.staticDataCount,`content item`)],[`Problems`,D(n,{ignoreMarkdocErrors:a})]],W)),0)}catch(e){F.stdout(o(`Build failed`,G(),e,{colors:W,stacks:R.stacks}));let t=K?.database.close();return K=void 0,await t?.catch(()=>void 0),await j(R,I,e),1}finally{await K?.database.close(),await q}}export{P as runBuild};
1
+ import{getPathPrefix as e,setGlobalPathPrefix as t}from"../../shared/path-prefix.js";import{stopwatch as n}from"../../shared/logger.js";import{formatCommandRows as r,formatCompletion as i,formatContentRow as a,formatFailure as o,formatFileChanges as s,pluralize as c,printBuildHelp as l,shouldUseColors as u}from"../output.js";import{writeBuildOutputMetadata as d}from"../../bundler/build/output-metadata.js";import{assertRuntimeBuildOptions as f,runBuild as p}from"../../bundler/build/run.js";import{validateReactPages as m}from"../validate-react-pages.js";import{sendApiDocsBuildEvent as h}from"../api-docs-build-event.js";import{parseArgs as g}from"../parse-args.js";import{COMMON_FLAGS as _,parseBuildTarget as v,parseHintsFlag as y,parseHostPlatform as b,parseOptionalStringFlag as x,reportUsageError as S,resolveCommonArgs as C,setUpLogging as w}from"../args.js";import{createCliOutput as T,shouldWriteLogGroups as E}from"../log-output/index.js";import{formatProblemCounts as D,reportProblems as O}from"../problems-output.js";import{hasInjectedContentSteps as k,openContentSession as A,recordRunFailure as j,runContentIngestWithStaticDataBuild as M}from"./ingest.js";import N from"node:process";async function P(P,F,I){let L=g(P,{alias:_.alias,boolean:[..._.boolean,`dev-login`],string:[..._.string,`hints`,`target`,`platform`,`path-prefix`]});if(L.help)return l(F.stdout),0;let R,z,B,V;try{let e=C(L);R=w(e,T(F,e)),z=v(L.target),B=b(L.platform),V=x(L[`path-prefix`],`--path-prefix`),f(z,B)}catch(e){return S(e,F)}t(V??N.env.REDOCLY_PREFIX_PATHS??``);let{logger:H,reporter:U}=R,W=u();F.stdout(r([a(R.contentDir),[`Prefix`,e()||void 0]],W)),H.debug(`Process startup took ${N.uptime().toFixed(2)}s`);let G=n(),K,q;try{K=k(I)?void 0:await A(R);let e=/* @__PURE__ */ new Date,{ingestResult:t,problems:n,staticDataResult:r,ignoreMarkdocErrors:a}=await M(R,I,{hints:y(L.hints),session:K}),l=K?.context.state;l&&(q=h({startedAt:e,cold:t.diff.summary.totalPrevious===0,state:l,logger:H}));let u=O(F,n,{ignoreMarkdocErrors:a,groups:E(F)}),f=await(I.runRuntimeBuild??p)({contentDir:R.contentDir,target:z,platform:B,logger:H,reporter:U,templateSet:t.templateSet,serverModuleSet:t.serverModuleSet,devLogin:L[`dev-login`]===!0}),g=await U.run(`Validating React pages`,()=>m({contentDir:R.contentDir,outputDir:f.outputDir,sourceTemplates:t.templateSet.sourceTemplates,databaseUrl:R.databaseUrl,database:K?.database,context:K?.context,logger:H}),({pageCount:e,renderedCount:t,problems:n})=>{if(e===0)return`No React pages`;if(t===0)return`${c(e,`React page`)} unchanged`;let r=t===e?`Checked ${c(e,`React page`)}`:`Checked ${t} of ${c(e,`React page`)}`;return n.length>0?`${r}, ${n.length} failed to render`:r}),_=O(F,g.problems,{ignoreMarkdocErrors:a,groups:E(F)});return await(I.writeBuildOutputMetadata??d)({contentDir:R.contentDir,outputDir:f.outputDir,databaseUrl:R.databaseUrl,database:K?.database,context:K?.context,logger:H}),F.stdout(``),u+_>0?(F.stdout(o(`Build failed`,G(),`${c(u+_,`content error`)} (see Problems above)`,{colors:W,stacks:R.stacks})),1):(F.stdout(i(`Build complete`,G(),[[`Files`,s(t.diff.summary)],[`Built`,c(r.staticDataCount,`content item`)],[`Problems`,D(n,{ignoreMarkdocErrors:a})]],W)),0)}catch(e){F.stdout(o(`Build failed`,G(),e,{colors:W,stacks:R.stacks}));let t=K?.database.close();return K=void 0,await t?.catch(()=>void 0),await j(R,I,e),1}finally{await K?.database.close(),await q}}export{P as runBuild};
@@ -1 +1 @@
1
- import{setGlobalPathPrefix as e}from"../../shared/path-prefix.js";import{formatProjectPluginDiagnostics as t,loadAndRegisterProjectPlugins as n}from"../../content-layer/plugins/project/load.js";import"../../content-layer/plugins/index.js";import{printDevHelp as r}from"../output.js";import{runDev as i}from"../../bundler/dev/run.js";import{parseArgs as a}from"../parse-args.js";import{COMMON_FLAGS as o,parseOptionalStringFlag as s,parsePort as c,reportUsageError as l,resolveCommonArgs as u,setUpLogging as d}from"../args.js";import{resolveDevRealmDir as f}from"../dev-realm-dir.js";import{createDevConsole as p}from"../dev-console/index.js";import{join as m,resolve as h}from"node:path";import g from"node:process";async function _(_,v,y){let b=a(_,{alias:{...o.alias,p:`port`},boolean:o.boolean,string:[...o.string,`host`,`path-prefix`,`log-file`,`plan`]});if(b.help)return r(v.stdout),0;let x,S,C,w,T;try{C=s(b.host,`--host`),w=c(b.port)??4e3,T=s(b[`path-prefix`],`--path-prefix`);let e=s(b[`log-file`],`--log-file`),t=u(b);g.env.REALM_DIR??=f(t.contentDir),S=p(v,{...t,logFile:h(e??m(g.env.REALM_DIR,`logs`,`dev.log`))}),x=d(t,S)}catch(e){return S?.close(),l(e,v)}let{logger:E}=x;e(T??g.env.REDOCLY_PREFIX_PATHS??``),E.debug(`Development data: ${g.env.REALM_DIR}`);let D=await n(x.contentDir,{logger:E});D.diagnostics.length>0&&E.warn(`Some project plugins did not load:\n${t(D.diagnostics)}`);try{return await(y.runRuntimeDev??i)({contentDir:x.contentDir,databaseUrl:x.databaseUrl,host:C,port:w,logger:E,reporter:x.reporter,devReporter:S}),0}catch(e){return E.error(`Dev failed`,{err:e}),1}finally{S?.close()}}export{_ as runDev};
1
+ import{setGlobalPathPrefix as e}from"../../shared/path-prefix.js";import{printDevHelp as t}from"../output.js";import{formatProjectPluginDiagnostics as n,loadAndRegisterProjectPlugins as r}from"../../content-layer/plugins/project/load.js";import"../../content-layer/plugins/index.js";import{runDev as i}from"../../bundler/dev/run.js";import{parseArgs as a}from"../parse-args.js";import{COMMON_FLAGS as o,parseOptionalStringFlag as s,parsePort as c,reportUsageError as l,resolveCommonArgs as u,setUpLogging as d}from"../args.js";import{resolveDevRealmDir as f}from"../dev-realm-dir.js";import{createDevConsole as p}from"../dev-console/index.js";import{join as m,resolve as h}from"node:path";import g from"node:process";async function _(_,v,y){let b=a(_,{alias:{...o.alias,p:`port`},boolean:o.boolean,string:[...o.string,`host`,`path-prefix`,`log-file`,`plan`]});if(b.help)return t(v.stdout),0;let x,S,C,w,T;try{C=s(b.host,`--host`),w=c(b.port)??4e3,T=s(b[`path-prefix`],`--path-prefix`);let e=s(b[`log-file`],`--log-file`),t=u(b);g.env.REALM_DIR??=f(t.contentDir),S=p(v,{...t,logFile:h(e??m(g.env.REALM_DIR,`logs`,`dev.log`))}),x=d(t,S)}catch(e){return S?.close(),l(e,v)}let{logger:E}=x;e(T??g.env.REDOCLY_PREFIX_PATHS??``),E.debug(`Development data: ${g.env.REALM_DIR}`);let D=await r(x.contentDir,{logger:E});D.diagnostics.length>0&&E.warn(`Some project plugins did not load:\n${n(D.diagnostics)}`);try{return await(y.runRuntimeDev??i)({contentDir:x.contentDir,databaseUrl:x.databaseUrl,host:C,port:w,logger:E,reporter:x.reporter,devReporter:S}),0}catch(e){return E.error(`Dev failed`,{err:e}),1}finally{S?.close()}}export{_ as runDev};
@@ -1 +1 @@
1
- import{createNodePlatform as e}from"../../platform/node/create.js";import{formatCount as t}from"../../shared/log-format.js";import{stopwatch as n}from"../../shared/logger.js";import{createContentLayerContext as r}from"../../content-layer/context.js";import{openContentLayerDatabase as i}from"../../content-layer/database/connection.js";import{createContentPlugins as a}from"../../content-layer/plugins/create-content-plugins.js";import{createProjectPluginLoadError as o,loadAndRegisterProjectPlugins as s}from"../../content-layer/plugins/project/load.js";import"../../content-layer/plugins/index.js";import{loadUserMarkdocSchema as c}from"../../bundler/user-markdoc-schema.js";import{describeFileChanges as l,formatCommandHeader as u,formatCompletion as d,formatContentRow as f,formatFailure as p,formatFileChanges as m,pluralize as h,printIngestHelp as g,shouldUseColors as _}from"../output.js";import{listProblems as v,problemRow as y,replaceGlobalProblemsForSourceTx as b}from"../../content-layer/database/problems.js";import{ingestFailedProblem as x}from"../../content-layer/problems/producers.js";import{runContentEntityBuild as S}from"../../bundler/build/run.js";import{runContentIngest as C}from"../../content-layer/ingest/run.js";import{parseArgs as w}from"../parse-args.js";import{COMMON_FLAGS as T,parseHintsFlag as E,reportUsageError as D,resolveCommonArgs as O,setUpLogging as k}from"../args.js";import{createCliOutput as A,shouldWriteLogGroups as j}from"../log-output/index.js";import{formatProblemCounts as M,reportProblems as N}from"../problems-output.js";import{runBuildLinkCheck as P}from"../../content-layer/link-checker/run-build.js";import{resolve as F}from"node:path";async function I(e,t,r){let i=w(e,{alias:T.alias,boolean:T.boolean,string:[...T.string,`hints`]});if(i.help)return g(t.stdout),0;let a;try{let e=O(i);a=k(e,A(t,e))}catch(e){return D(e,t)}let o=E(i.hints),s=_();t.stdout(u(`ingest`,[f(a.contentDir)],s));let c=n();try{let{ingestResult:e,problems:n,staticDataResult:i,ignoreMarkdocErrors:l}=await z(a,r,{hints:o}),u=N(t,n,{ignoreMarkdocErrors:l,groups:j(t)});return t.stdout(``),u>0?(t.stdout(p(`Ingest failed`,c(),`${h(u,`content error`)} (see Problems above)`,{colors:s,stacks:a.stacks})),1):(t.stdout(d(`Ingest complete`,c(),[[`Files`,m(e.diff.summary)],[`Built`,h(i.staticDataCount,`content item`)],[`Problems`,M(n,{ignoreMarkdocErrors:l})]],s)),0)}catch(e){return t.stdout(p(`Ingest failed`,c(),e,{colors:s,stacks:a.stacks})),await B(a,r,e),1}}function L(e){return e.runContentIngest!==void 0||e.runContentEntityBuild!==void 0}async function R(e){let t=await s(e.contentDir,{logger:e.logger});if(t.diagnostics.length>0)throw o(t.diagnostics);await c({contentDir:e.contentDir,logger:e.logger,reporter:e.reporter});let n=r({contentDir:e.contentDir,logger:e.logger,plugins:a(e.contentDir)});return{context:n,database:await V(e,n.platform)}}async function z(e,n,r){if(L(n)){let t=await(n.runContentIngest??C)({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,hints:r?.hints}),i=await(n.runContentEntityBuild??S)({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger});return{ingestResult:t,problems:[...t.problems,...i.problems??[]],staticDataResult:{staticDataCount:i.entityCount},ignoreMarkdocErrors:!1}}let i=r?.session===void 0,{context:a,database:o}=r?.session??await R(e);try{let n=await e.reporter.run(`Ingesting content`,t=>C({contentDir:e.contentDir,context:a,database:o,databaseUrl:e.databaseUrl,logger:e.logger,hints:r?.hints,searchSync:!1,collectProblems:!1,captureRevisions:!0,onProgress:e=>{e.stage===`sync`&&t.progress(e.done,e.total)}}),e=>`Ingested ${h(e.diff.summary.totalCurrent,`file`)} (${l(e.diff.summary)})`),i=await S({contentDir:e.contentDir,context:a,database:o,databaseUrl:e.databaseUrl,logger:e.logger,reporter:e.reporter,inlineSearchables:n.inlineSearchables});return await e.reporter.run(`Checking links`,()=>P({database:o,config:a.config,readSourceFile:async t=>{try{return await a.platform.fs.readFile(F(e.contentDir,t))}catch{return null}},logger:e.logger}),e=>e.ok?e.judged===e.checked?`Checked ${h(e.checked,`link`)} (${t(e.broken)} broken)`:`Re-checked ${t(e.judged)} of ${h(e.checked,`link`)} (${t(e.broken)} broken)`:`Link check failed; stored link problems were left unchanged`),{ingestResult:n,problems:await v(o),staticDataResult:{staticDataCount:i.entityCount},ignoreMarkdocErrors:a.config.platform?.ignoreMarkdocErrors===!0}}finally{i&&await o.close()}}async function B(t,n,r){if(!L(n))try{let n=x(r instanceof Error?r.message:String(r)),i=await V(t,e());try{await i.db.transaction(e=>b(e,`system`,[y(n,{scope:`global`,source:`system`})]))}finally{await i.close()}}catch{}}function V(e,t){return i({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,platform:t})}export{L as hasInjectedContentSteps,R as openContentSession,B as recordRunFailure,z as runContentIngestWithStaticDataBuild,I as runIngest};
1
+ import{formatCount as e}from"../../shared/log-format.js";import{stopwatch as t}from"../../shared/logger.js";import{openContentLayerDatabase as n}from"../../content-layer/database/connection.js";import{listProblems as r,problemRow as i,replaceGlobalProblemsForSourceTx as a}from"../../content-layer/database/problems.js";import{createNodePlatform as o}from"../../platform/node/create.js";import{createContentLayerContext as s}from"../../content-layer/context.js";import{createContentPlugins as c}from"../../content-layer/plugins/create-content-plugins.js";import{describeFileChanges as l,formatCommandHeader as u,formatCompletion as d,formatContentRow as f,formatFailure as p,formatFileChanges as m,pluralize as h,printIngestHelp as g,shouldUseColors as _}from"../output.js";import{createProjectPluginLoadError as v,loadAndRegisterProjectPlugins as y}from"../../content-layer/plugins/project/load.js";import"../../content-layer/plugins/index.js";import{loadUserMarkdocSchema as b}from"../../bundler/user-markdoc-schema.js";import{ingestFailedProblem as x}from"../../content-layer/problems/producers.js";import{runContentIngest as S}from"../../content-layer/ingest/run.js";import{runContentEntityBuild as C}from"../../bundler/build/run.js";import{parseArgs as w}from"../parse-args.js";import{COMMON_FLAGS as T,parseHintsFlag as E,reportUsageError as D,resolveCommonArgs as O,setUpLogging as k}from"../args.js";import{createCliOutput as A,shouldWriteLogGroups as j}from"../log-output/index.js";import{formatProblemCounts as M,reportProblems as N}from"../problems-output.js";import{runBuildLinkCheck as P}from"../../content-layer/link-checker/run-build.js";import{resolve as F}from"node:path";async function I(e,n,r){let i=w(e,{alias:T.alias,boolean:T.boolean,string:[...T.string,`hints`]});if(i.help)return g(n.stdout),0;let a;try{let e=O(i);a=k(e,A(n,e))}catch(e){return D(e,n)}let o=E(i.hints),s=_();n.stdout(u(`ingest`,[f(a.contentDir)],s));let c=t();try{let{ingestResult:e,problems:t,staticDataResult:i,ignoreMarkdocErrors:l}=await z(a,r,{hints:o}),u=N(n,t,{ignoreMarkdocErrors:l,groups:j(n)});return n.stdout(``),u>0?(n.stdout(p(`Ingest failed`,c(),`${h(u,`content error`)} (see Problems above)`,{colors:s,stacks:a.stacks})),1):(n.stdout(d(`Ingest complete`,c(),[[`Files`,m(e.diff.summary)],[`Built`,h(i.staticDataCount,`content item`)],[`Problems`,M(t,{ignoreMarkdocErrors:l})]],s)),0)}catch(e){return n.stdout(p(`Ingest failed`,c(),e,{colors:s,stacks:a.stacks})),await B(a,r,e),1}}function L(e){return e.runContentIngest!==void 0||e.runContentEntityBuild!==void 0}async function R(e){let t=await y(e.contentDir,{logger:e.logger});if(t.diagnostics.length>0)throw v(t.diagnostics);await b({contentDir:e.contentDir,logger:e.logger,reporter:e.reporter});let n=s({contentDir:e.contentDir,logger:e.logger,plugins:c(e.contentDir)});return{context:n,database:await V(e,n.platform)}}async function z(t,n,i){if(L(n)){let e=await(n.runContentIngest??S)({contentDir:t.contentDir,databaseUrl:t.databaseUrl,logger:t.logger,hints:i?.hints}),r=await(n.runContentEntityBuild??C)({contentDir:t.contentDir,databaseUrl:t.databaseUrl,logger:t.logger});return{ingestResult:e,problems:[...e.problems,...r.problems??[]],staticDataResult:{staticDataCount:r.entityCount},ignoreMarkdocErrors:!1}}let a=i?.session===void 0,{context:o,database:s}=i?.session??await R(t);try{let n=await t.reporter.run(`Ingesting content`,e=>S({contentDir:t.contentDir,context:o,database:s,databaseUrl:t.databaseUrl,logger:t.logger,hints:i?.hints,searchSync:!1,collectProblems:!1,captureRevisions:!0,onProgress:t=>{t.stage===`sync`&&e.progress(t.done,t.total)}}),e=>`Ingested ${h(e.diff.summary.totalCurrent,`file`)} (${l(e.diff.summary)})`),a=await C({contentDir:t.contentDir,context:o,database:s,databaseUrl:t.databaseUrl,logger:t.logger,reporter:t.reporter,inlineSearchables:n.inlineSearchables});return await t.reporter.run(`Checking links`,()=>P({database:s,config:o.config,readSourceFile:async e=>{try{return await o.platform.fs.readFile(F(t.contentDir,e))}catch{return null}},logger:t.logger}),t=>t.ok?t.judged===t.checked?`Checked ${h(t.checked,`link`)} (${e(t.broken)} broken)`:`Re-checked ${e(t.judged)} of ${h(t.checked,`link`)} (${e(t.broken)} broken)`:`Link check failed; stored link problems were left unchanged`),{ingestResult:n,problems:await r(s),staticDataResult:{staticDataCount:a.entityCount},ignoreMarkdocErrors:o.config.platform?.ignoreMarkdocErrors===!0}}finally{a&&await s.close()}}async function B(e,t,n){if(!L(t))try{let t=x(n instanceof Error?n.message:String(n)),r=await V(e,o());try{await r.db.transaction(e=>a(e,`system`,[i(t,{scope:`global`,source:`system`})]))}finally{await r.close()}}catch{}}function V(e,t){return n({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,platform:t})}export{L as hasInjectedContentSteps,R as openContentSession,B as recordRunFailure,z as runContentIngestWithStaticDataBuild,I as runIngest};
@@ -1,2 +1,2 @@
1
- import{compareStrings as e}from"../../shared/utils/compare-strings.js";import{isObject as t}from"../../shared/utils/is-object.js";import{createNodePlatformFs as n}from"../../platform/node/fs.js";import{ANSI as r,paint as i}from"../../shared/log-format.js";import{stopwatch as a}from"../../shared/logger.js";import{DEFAULT_LOCALE_PLACEHOLDER as o,L10N_DIR as s,TRANSLATIONS_FILE_NAMES as c}from"../../shared/constants/l10n/defaults.js";import{l10nDirOf as l,listL10nDirs as u,normalizeL10nConfig as d}from"../../shared/utils/l10n.js";import{loadRedoclyConfig as f}from"../../content-layer/config.js";import{contentIgnoreMatcherOf as p,scanContentFiles as m}from"../../content-layer/ingest/scan.js";import{SIDEBAR_FILENAME_REGEX as h}from"../../content-layer/plugins/internal/sidebar/index.js";import{formatFailure as g,printTranslateHelp as _,shouldUseColors as v}from"../output.js";import{defaultTranslationImports as y}from"../../shared/constants/l10n/default-translations.js";import{CliUsageError as b,parseArgs as x}from"../parse-args.js";import{COMMON_FLAGS as S,reportUsageError as C,resolveCommonArgs as w}from"../args.js";import{join as T,posix as E}from"node:path";import D from"js-yaml";import O from"node:process";import{createInterface as k}from"node:readline/promises";const A=`default`,j=/^[\w-]+$/,M=/^translations\.ya?ml$/i,N=D.FAILSAFE_SCHEMA.extend({implicit:[new D.Type(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:e=>[`~`,`null`,`Null`,`NULL`].includes(e),construct:()=>null})]});async function P(e,t,o){let s=x(e,{alias:{h:`help`,d:`project-dir`,D:`debug`},boolean:[...S.boolean,`debug`],string:[`project-dir`]});if(s.help)return _(t.stdout),0;let c,l,u=s._.map(String);try{if({contentDir:c,stacks:l}=w(s),u.length===0)throw new b(`Locale is required but was not provided.`);let e=u.find(e=>!j.test(e));if(e!==void 0)throw new b(`Invalid locale "${e}". Use letters, digits, "-" and "_" only.`)}catch(e){return C(e,t)}let d=v(),p=a();try{let e=n(),{config:a}=await f(c,e),s=await F(c,e,a,u),l=await(o.confirm??(e=>W(e,t)))(U(s,d));if(l===void 0)return t.stderr(`The confirmation prompt got no answer. No files changed.`),1;if(!l)return t.stdout(`No files changed.`),0;for(let t of s)await e.writeFile(T(c,t.path),D.dump(t.translations),{recursive:!0});return t.stdout(i(`✓ Translations updated`,r.bold+r.green,d)),0}catch(e){return t.stdout(g(`Translate failed`,p(),e,{colors:d,stacks:l})),1}}async function F(t,n,r,i){let{defaultLocale:a}=d(r.l10n),o=await u(t,n),l=i[0]===`all`?[A,...o]:i,f=await I(t,n,r),p=/* @__PURE__ */ new Map;for(let r of l){let i=r===A||r.toLowerCase()===a.toLowerCase(),l=i?``:E.join(s,o.find(e=>H(e,r))??r),u=await B(t,n,l),d=u??E.join(l,c[0]);if(p.has(d))continue;let m=u?V(await n.readFile(T(t,u)),u):{},h={...await R(i?a:r),...f,...m};p.set(d,{path:d,exists:u!==void 0,translations:Object.fromEntries(Object.entries(h).sort(([t],[n])=>e(t,n)))})}return[...p.values()]}async function I(e,t,n){let r=p(n),i=(await m({fs:t,rootDir:e})).filter(e=>h.test(e.path)&&l(e.path)===void 0&&!r(e.path));return{...L(await Promise.all(i.map(async e=>D.load(await t.readFile(e.absolutePath),{filename:e.path})))),...L(n)}}function L(e){let n={};if(Array.isArray(e)){for(let t of e)Object.assign(n,L(t));return n}if(!t(e))return n;for(let[t,r]of Object.entries(e)){if(!t.endsWith(`TranslationKey`)||typeof r!=`string`){Object.assign(n,L(r));continue}let i=t.slice(0,-14),a=e[i];i.trim()===``||r.trim()===``||a!=null&&typeof a!=`string`||(n[r]=a??``)}return n}async function R(e){let t=e.split(`-`)[0];return{...await y[o](),...await z(t),...H(t,e)?{}:await z(e)}}async function z(e){let t=Object.keys(y).find(t=>H(t,e));return t===void 0?{}:y[t]()}async function B(e,t,n){for(let r of await t.readdir(T(e,n))){if(!M.test(r.name))continue;let i=E.join(n,r.name);if(r.type===`file`||r.type===`symlink`&&(await t.stat(T(e,i)))?.type===`file`)return i}}function V(e,n){let r=D.load(e,{filename:n,schema:N})??{};if(!t(r))throw Error(`${n} must map translation keys to texts. No files changed.`);return r}function H(e,t){return e.toLowerCase()===t.toLowerCase()}function U(e,t){let n=e=>e.map(e=>` - ${i(e.path,r.cyan,t)}`),a=e.filter(e=>!e.exists),o=e.filter(e=>e.exists),s=[`Confirm the following actions:`,``];return a.length>0&&s.push(`Create new files with translations stubs:`,...n(a),``),o.length>0&&s.push(`Update translations files with missing phrases (this doesn't rewrite existing data values):`,...n(o),``),s.push(`Continue? (Y/n) `),s.join(`
1
+ import{DEFAULT_LOCALE_PLACEHOLDER as e,L10N_DIR as t,TRANSLATIONS_FILE_NAMES as n}from"../../shared/constants/l10n/defaults.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{isObject as i}from"../../shared/utils/is-object.js";import{l10nDirOf as a,listL10nDirs as o,normalizeL10nConfig as s}from"../../shared/utils/l10n.js";import{defaultTranslationImports as c}from"../../shared/constants/l10n/default-translations.js";import{ANSI as l,paint as u}from"../../shared/log-format.js";import{stopwatch as d}from"../../shared/logger.js";import{createNodePlatformFs as f}from"../../platform/node/fs.js";import{SIDEBAR_FILENAME_REGEX as p}from"../../content-layer/plugins/internal/sidebar/index.js";import{loadRedoclyConfig as m}from"../../content-layer/config.js";import{contentIgnoreMatcherOf as h,scanContentFiles as g}from"../../content-layer/ingest/scan.js";import{formatFailure as _,printTranslateHelp as v,shouldUseColors as y}from"../output.js";import{CliUsageError as b,parseArgs as x}from"../parse-args.js";import{COMMON_FLAGS as S,reportUsageError as C,resolveCommonArgs as w}from"../args.js";import{join as T,posix as E}from"node:path";import D from"js-yaml";import O from"node:process";import{createInterface as k}from"node:readline/promises";const A=`default`,j=/^[\w-]+$/,M=/^translations\.ya?ml$/i,N=D.FAILSAFE_SCHEMA.extend({implicit:[new D.Type(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:e=>[`~`,`null`,`Null`,`NULL`].includes(e),construct:()=>null})]});async function P(e,t,n){let r=x(e,{alias:{h:`help`,d:`project-dir`,D:`debug`},boolean:[...S.boolean,`debug`],string:[`project-dir`]});if(r.help)return v(t.stdout),0;let i,a,o=r._.map(String);try{if({contentDir:i,stacks:a}=w(r),o.length===0)throw new b(`Locale is required but was not provided.`);let e=o.find(e=>!j.test(e));if(e!==void 0)throw new b(`Invalid locale "${e}". Use letters, digits, "-" and "_" only.`)}catch(e){return C(e,t)}let s=y(),c=d();try{let e=f(),{config:r}=await m(i,e),a=await F(i,e,r,o),c=await(n.confirm??(e=>W(e,t)))(U(a,s));if(c===void 0)return t.stderr(`The confirmation prompt got no answer. No files changed.`),1;if(!c)return t.stdout(`No files changed.`),0;for(let t of a)await e.writeFile(T(i,t.path),D.dump(t.translations),{recursive:!0});return t.stdout(u(`✓ Translations updated`,l.bold+l.green,s)),0}catch(e){return t.stdout(_(`Translate failed`,c(),e,{colors:s,stacks:a})),1}}async function F(e,i,a,c){let{defaultLocale:l}=s(a.l10n),u=await o(e,i),d=c[0]===`all`?[A,...u]:c,f=await I(e,i,a),p=/* @__PURE__ */ new Map;for(let a of d){let o=a===A||a.toLowerCase()===l.toLowerCase(),s=o?``:E.join(t,u.find(e=>H(e,a))??a),c=await B(e,i,s),d=c??E.join(s,n[0]);if(p.has(d))continue;let m=c?V(await i.readFile(T(e,c)),c):{},h={...await R(o?l:a),...f,...m};p.set(d,{path:d,exists:c!==void 0,translations:Object.fromEntries(Object.entries(h).sort(([e],[t])=>r(e,t)))})}return[...p.values()]}async function I(e,t,n){let r=h(n),i=(await g({fs:t,rootDir:e})).filter(e=>p.test(e.path)&&a(e.path)===void 0&&!r(e.path));return{...L(await Promise.all(i.map(async e=>D.load(await t.readFile(e.absolutePath),{filename:e.path})))),...L(n)}}function L(e){let t={};if(Array.isArray(e)){for(let n of e)Object.assign(t,L(n));return t}if(!i(e))return t;for(let[n,r]of Object.entries(e)){if(!n.endsWith(`TranslationKey`)||typeof r!=`string`){Object.assign(t,L(r));continue}let i=n.slice(0,-14),a=e[i];i.trim()===``||r.trim()===``||a!=null&&typeof a!=`string`||(t[r]=a??``)}return t}async function R(t){let n=t.split(`-`)[0];return{...await c[e](),...await z(n),...H(n,t)?{}:await z(t)}}async function z(e){let t=Object.keys(c).find(t=>H(t,e));return t===void 0?{}:c[t]()}async function B(e,t,n){for(let r of await t.readdir(T(e,n))){if(!M.test(r.name))continue;let i=E.join(n,r.name);if(r.type===`file`||r.type===`symlink`&&(await t.stat(T(e,i)))?.type===`file`)return i}}function V(e,t){let n=D.load(e,{filename:t,schema:N})??{};if(!i(n))throw Error(`${t} must map translation keys to texts. No files changed.`);return n}function H(e,t){return e.toLowerCase()===t.toLowerCase()}function U(e,t){let n=e=>e.map(e=>` - ${u(e.path,l.cyan,t)}`),r=e.filter(e=>!e.exists),i=e.filter(e=>e.exists),a=[`Confirm the following actions:`,``];return r.length>0&&a.push(`Create new files with translations stubs:`,...n(r),``),i.length>0&&a.push(`Update translations files with missing phrases (this doesn't rewrite existing data values):`,...n(i),``),a.push(`Continue? (Y/n) `),a.join(`
2
2
  `)}async function W(e,t){let n=k({input:t.terminal?.stdin??O.stdin,output:t.terminal?.stdout??O.stdout});n.once(`SIGINT`,()=>n.close());let r=new Promise(e=>n.once(`close`,()=>e(void 0)));try{let t=await Promise.race([n.question(e),r]);if(t===void 0)return;let i=t.trim().toLowerCase();return i===``||i===`y`||i===`yes`}finally{n.close()}}export{P as runTranslate};