@redocly/framework 1.0.0-next.6 → 1.0.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/dev-content-build.js +1 -0
- package/dist/bundler/dev/dev-problems.js +1 -1
- package/dist/bundler/dev/dev-reporter.js +1 -1
- package/dist/bundler/dev/routes/dev-content-build-route.js +1 -0
- package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +2 -2
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +2 -2
- package/dist/cli/dev-console/{sweep.js → content-build.js} +1 -1
- package/dist/cli/dev-console/index.js +1 -1
- package/dist/cli/dev-console/lines.js +2 -2
- package/dist/cli/dev-console/plain.js +1 -1
- package/dist/cli/dev-console/tui.js +2 -2
- package/dist/cli/log-output/index.js +1 -1
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +3 -3
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/dev-problems/ProblemsBar.js +61 -11
- package/dist/client/dev-problems/build-segment.js +1 -0
- package/dist/client/dev-problems/index.js +1 -1
- package/dist/client/dev-problems/use-dev-problems.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/l10n/ssr-l10n.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +50 -50
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/theme-logo.js +1 -1
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/config.d.ts +2 -1
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/git-last-modified.js +3 -3
- package/dist/content-layer/ingest/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
- package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
- package/dist/content-layer/markdown/nodes/fence.js +1 -1
- package/dist/content-layer/markdown/nodes/heading.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +2 -2
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/tags/variant.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +13 -13
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/templates/template-set.js +1 -1
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/content.js +12 -12
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/node-entry.js +1 -1
- package/dist/server/page-handlers.js +1 -1
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/redirects.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/sitemap.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/telemetry/mock-server-events.js +1 -0
- package/dist/server/telemetry/redirect-event.js +1 -0
- package/dist/server/telemetry/sender.js +1 -1
- package/dist/shared/constants/content-update.js +1 -1
- package/dist/shared/constants/dev-content-build.js +1 -0
- package/dist/shared/constants/dev-problems.js +1 -1
- package/dist/shared/constants/dev-source-sync.js +1 -1
- package/dist/shared/constants/system-routes.js +1 -1
- package/dist/shared/rbac/l10n-rules.js +1 -1
- package/dist/shared/rbac/team-templates.js +1 -1
- package/dist/shared/types/search.d.ts +7 -2
- package/dist/shared/utils/l10n.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/package.json +22 -2
- package/dist/bundler/dev/__tests__/reset-content-update-state.js +0 -1
- package/dist/bundler/dev/materialization-sweeper.js +0 -1
- package/dist/client/dev-problems/sweep-segment.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/fake-kv.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/secret-store-fixture.js +0 -1
- package/dist/server/__tests__/rbac-fixture.js +0 -1
- package/dist/server/__tests__/test-session.js +0 -1
|
@@ -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{openContentLayerDatabase as i}from"../../content-layer/database/connection.js";import{createRouteIndex as a}from"../../content-layer/plugins/utils/route-index.js";import{MaterializationError as o}from"../../content-layer/problems/problem-error.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 i({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,i=await u(x),s=await d(x),b=p(s),S=i.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(`
|
|
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{openContentLayerDatabase as i}from"../../content-layer/database/connection.js";import{createRouteIndex as a}from"../../content-layer/plugins/utils/route-index.js";import{MaterializationError as o}from"../../content-layer/problems/problem-error.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 i({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,i=await u(x),s=await d(x),b=p(s),S=i.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 i=Date.now();try{await T(r),y.debug(`materialized ${r.key} (+${Date.now()-i}ms)`)}catch(e){if(!(e instanceof o))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:a(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,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`):null}}}function W(t
|
|
1
|
+
import{formatBytes as e,formatCount as t}from"../../shared/log-format.js";import{getPathPrefix as n}from"../../shared/path-prefix.js";import{toPosixPath as r}from"../../shared/utils/to-posix-path.js";import{discoverContentDependencyPolicy as i}from"../content-dependency-policy.js";import{createResolvedTemplateSetProvider as a}from"../../content-layer/templates/template-set.js";import{getEnvFileDefaults as o}from"../../shared/public-env.js";import{BUILD_ASSETS_DIRNAME as s,CLIENT_TEMPLATE_KEYS_FILENAME as c,RUNTIME_CLIENT_DIRNAME as l,RUNTIME_HOST_CHUNKS_DIRNAME as u,RUNTIME_MANIFEST_FILENAME as d,RUNTIME_SSR_DIRNAME as f,RUNTIME_SSR_ENTRY_FILENAME as p,RUNTIME_SUBPROCESS_CHILD_FILENAME as m,getRuntimeOutputDir as h,serverModuleChunkPath as g}from"../../shared/constants/runtime-layout.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=h(e.contentDir),n=M(t,l),r=M(t,f),i=M(r,p),o=M(n,`.vite`,`manifest.json`),s=M(t,d),c=ee(e.contentDir),u=a(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:c,templateSetProvider:u,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:c,templateSetProvider:u,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(s,JSON.stringify({target:e.target,platform:e.platform,clientDir:n,serverEntryPath:i,viteManifestPath:o},null,2)),{outputDir:t,clientDir:n,serverEntryPath:i,manifestPath:s,target:e.target,platform:e.platform,viteManifestPath:o}}async function B(e){await I(M(e,u),{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 i={};for(let a of v(await e.current(),t)){let e=await this.resolve(a.filePath);e&&(i[a.templateId]=r(N(n,e.id)))}this.emitFile({type:`asset`,fileName:`.vite/${c}`,source:JSON.stringify(i)})}}}const G=ae(import.meta.url),K=r(M(j(G.resolve(`@redocly/theme/package.json`)),`src/`));function q(e){return r(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&&r(e.id).includes(`/node_modules/`)||t(e)};function Y(e){let t=h(e.contentDir),n=e.variant===`client`,a=i(e.contentDir,{viteManagedDependencies:C}),o=T({contentDir:e.contentDir,logger:e.logger,templateSetProvider:e.templateSetProvider,serverModuleSet:e.serverModuleSet,enableLazyStaticData:n,styledComponentsDependencies:[...a.noExternal,...a.external],styledComponentsRoots:a.packageRoots}),c=new Map(te(e.serverModuleSet??_(),e.contentDir).map(e=>[r(e.filePath),g(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:s,chunkSizeWarningLimit:5e3,manifest:!0,outDir:M(t,l),rollupOptions:{input:e.entryFiles.clientEntryPath,onwarn:J,output:{assetFileNames:`${s}/[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,f),rollupOptions:{external:[/^node:/],onwarn:J,output:{entryFileNames:p,chunkFileNames:e=>e.facadeModuleId&&c.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(e){let t=P(j(oe(import.meta.url)),`../../server`),{entryBasename:r,outputFilename:i}=k[e.platform],a=Z(t,r),s=Z(t,`subprocess/child-entry`);return{configFile:!1,envDir:!1,appType:`custom`,clearScreen:!1,logLevel:e.logger.isDebugEnabled(`runtime:vite`)?`info`:`warn`,customLogger:O(e.logger.child(y)),define:{...E({enableLazyStaticData:!1,production:!0}),[w]:JSON.stringify(e.templateFiles.map(e=>e.templateId)),...n()?{[S]:JSON.stringify(n())}:{},[b]:JSON.stringify(e.devLogin===!0),[x]:JSON.stringify(o())},plugins:[U(),D()],publicDir:!1,root:e.contentDir,ssr:{noExternal:!0},build:{copyPublicDir:!1,emptyOutDir:!1,minify:!0,outDir:h(e.contentDir),rollupOptions:{input:{[r]:a,[X]:s},external:[/^node:/],treeshake:{moduleSideEffects:e=>!q(e)&&void 0},output:{entryFileNames:e=>e.name===X?m:i,chunkFileNames:`assets/[name]-[hash].mjs`}},ssr:!0,target:`node22`}}}function $(n){let r=Array.isArray(n)?n:`output`in n?[n]:[],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`(${t(i)} ${i===1?`file`:`files`}, ${e(a)})`}export{z as buildRuntime,B as cleanStaleHostOutputs,Y as createBundleBuildConfig,Q as createHttpServerBuildConfig,U as createServerReplayStubPlugin,V as writeRuntimePackageManifest};
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
import{routes as e}from"../../content-layer/database/schema.js";import{listProblems as t,summarizeStoredProblems as n}from"../../content-layer/database/problems.js";import{onLazyMaterializeEnd as r}from"../../server/content.js";import{count as i,eq as a}from"drizzle-orm";const o=1e3;async function s(e){let{errors:r,warnings:i}=await n(e);return{errors:r,warnings:i,rows:await t(e,{limit:o})}}async function c(t){let[n]=await t.db.select({pages:i()}).from(e).where(a(e.isFallback,!1));return n?.pages??0}function l(e){return t(e,{limit:o})}function u(e){let t,n=Promise.resolve(),i=r(e.database,()=>{t||(t=setTimeout(()=>{t=void 0,n=n.then(async()=>e.report(await s(e.database))).catch(t=>e.logger.warn(`Could not read the problems`,{err:t}))},250),t.unref?.())});return()=>{i(),clearTimeout(t)}}export{c as countPages,l as listDevProblems,s as loadDevProblems,u as
|
|
1
|
+
import{routes as e}from"../../content-layer/database/schema.js";import{listProblems as t,summarizeStoredProblems as n}from"../../content-layer/database/problems.js";import{onLazyMaterializeEnd as r}from"../../server/content.js";import{count as i,eq as a}from"drizzle-orm";const o=1e3;async function s(e){let{errors:r,warnings:i}=await n(e);return{errors:r,warnings:i,rows:await t(e,{limit:o})}}async function c(t){let[n]=await t.db.select({pages:i()}).from(e).where(a(e.isFallback,!1));return n?.pages??0}function l(e){return t(e,{limit:o})}function u(e){let t,n=Promise.resolve(),i=r(e.database,()=>{t||(t=setTimeout(()=>{t=void 0,n=n.then(async()=>e.report(await s(e.database))).catch(t=>e.logger.warn(`Could not read the problems`,{err:t}))},250),t.unref?.())});return()=>{i(),clearTimeout(t)}}export{c as countPages,l as listDevProblems,s as loadDevProblems,u as watchBuiltProblems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={ready:()=>{},changeStart:()=>{},changeEnd:()=>{},
|
|
1
|
+
const e={ready:()=>{},changeStart:()=>{},changeEnd:()=>{},contentBuild:()=>{},problems:()=>{}};export{e as silentDevReporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEV_CONTENT_BUILD_PATH as e}from"../../../shared/constants/dev-content-build.js";async function t(e){let t=await e.status();return{state:t.state,done:t.done,total:t.total,failed:t.failed,pending:Math.max(0,t.total-t.done-t.failed)}}function n(n,r){n.get(e,async e=>e.json(r.contentBuild?await t(r.contentBuild):null)),n.patch(e,async e=>{let n=r.contentBuild;if(!n)return e.json({error:`This dev host runs no content build.`},404);let i;try{i=await e.req.json()}catch{return e.json({error:`Content build update body must be JSON.`},400)}let a=i?.state;return a!==`running`&&a!==`paused`?e.json({error:`Content build update body must be { state: "running" | "paused" }.`},400):(a===`running`?n.start():n.pause(),e.json(await t(n)))})}export{n as registerDevContentBuildRoute};
|
|
@@ -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{
|
|
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{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 r(c.database),d={errors:s,warnings:l,generation:a.generation};if(i.req.query(`list`)!==`1`)return i.json(d);let f=await n(c.database,{limit:500}),p=u(a.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 a=n.data?.raw,s=typeof a==`string`?o(i,n.range,a):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 i.json(g)})}export{s as MAX_DEV_LIST_PROBLEMS,c as registerDevProblemsRoute};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
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{normalizeRoutePath as r}from"../../../shared/utils/routes/normalize-route-path.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(e,t)=>{let r=await o.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 s=await f.load(e);if(!n(s)||!Array.isArray(s.items)||typeof s.basePath!=`string`)return;let c={basePath:s.basePath,map:await d(s.items,t,r)},l=(await f.get(e))?.dataHash;return l&&p.set(e,{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 n=e.req.query(`path`);if(!n)return e.json({error:`Missing the "path" query parameter.`},400);let r=await h(o.database,n),i=r===null?null:await c(o.database,r);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:t(f)})}),i.get(u,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:i}=new URL(n,`http://realm.invalid`),a=r(e(i)??i),s=await m(o.database,a),c=s?.loaded.route.sourcePath??null;if(!s||c===null)return t.json({path:null});let l=await y(s.loaded),u=l?.map.positionOfLink(g(s.publicSlug,l.basePath,a));return t.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`
|
|
2
2
|
SELECT routes.slug AS slug
|
|
3
3
|
FROM routes
|
|
4
4
|
INNER JOIN files ON files.id = routes.source_id
|
package/dist/bundler/dev/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getPathPrefix as e}from"../../shared/path-prefix.js";import{discoverContentDependencyPolicy as t}from"../content-dependency-policy.js";import{createTemplateSetProvider as n}from"../../content-layer/templates/template-set.js";import{createLogger as r}from"../../shared/logger.js";import{openContentLayerDatabase as i}from"../../content-layer/database/connection.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{CONTENT_BUILD_PROGRESS_HMR_EVENT as ee}from"../../shared/constants/dev-content-build.js";import{createSsrModuleInvoke as te,createViteDevServer as ne,ensureBundledClientOutput as re}from"./vite-config.js";import{createCodeAssetSources as v}from"./code-asset-sources.js";import{startContentDevSession as ie}from"./content-session.js";import{createDevContentBuild as ae,loadContentBuildProgress as y,loadContentBuildQueue as oe}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 D from"node:process";import{readFile as le}from"node:fs/promises";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??r(),M=c.reporter??l,F=c.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=a(c.contentDir),r=n(),l=(e,t)=>{t.statusCode=503,t.end(`Dev server is starting.`)};V=ue((e,t)=>{l(e,t)});let x=t(c.contentDir,{viteManagedDependencies:j});I.debug(`Content dependency SSR policy`,x);let w=v();Y=await ne({contentDir:c.contentDir,externalizeReactForSsr:!0,registerCodeAssetSource:w.register,hmrServer:V,lazyDevCompilation:!1,logger:k,templateSetProvider:r,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 ie({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:r});let z=q.context;J=await i({contentDir:c.contentDir,databaseUrl:c.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:ee,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=ae({loadQueue:()=>oe(H),loadProgress:e=>y(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 re(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:e,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:te(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);l=(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,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: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{
|
|
1
|
+
import{DATA_UPDATE_HMR_EVENT as e}from"../../shared/constants/content-update.js";import{BUILD_ASSETS_URL_PREFIX as t,getContentAssetsOutputDir as n}from"../../shared/constants/runtime-layout.js";import{toViteFsModuleId as r}from"../runtime-files.js";import{MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as i}from"../constants/virtual-modules.js";import{invalidateThemeOverrideIndex as a}from"../vite-config.base.js";import{invalidateAppDataCache as o}from"../../server/content.js";import{registerDevAuthRoutes as s,registerMockDevAuthRoutes as c}from"../../server/auth/routes.js";import{collectManualAuthPaths as l}from"../../server/plugin-routes.js";import{createApp as u}from"../../server/app.js";import{createPageHandlers as d}from"../../server/page-handlers.js";import{registerLocalContentAssetRoute as f}from"../../server/content-assets/serve-local.js";import{registerEntityRevisionsAdminRoute as p}from"../../server/revisions-admin.js";import{invalidateBundledSsrRunnerCache as m,triggerFullClientRebuild as h}from"./vite-config.js";import{renderClientStylesheetTags as g}from"./client-stylesheets.js";import{loadContentBuildProgress as _}from"./dev-content-build.js";import{DEV_PAGE_FOR_SOURCE_PATH as v}from"../../shared/constants/dev-source-sync.js";import{getSsrGraphGate as y}from"./ssr-graph-gate.js";import{contentUpdateState as b,registerContentUpdateStateRoute as x}from"./routes/content-update-state-route.js";import{registerDevContentBuildRoute as S}from"./routes/dev-content-build-route.js";import{registerDevProblemsRoute as C}from"./routes/dev-problems-route.js";import{registerSourceSyncRoutes as w}from"./routes/source-sync-route.js";import{join as T,resolve as E,sep as D}from"node:path";import{isRunnableDevEnvironment as O}from"vite";const k=/\.([cm]?[jt]sx?|css)$/,A=/(^|\/)@theme\//,j=/(^|\/)@theme\/markdoc\//,M=/(^|\/)@theme\/styles\.css$/,N=/\.md$/i;function P(e){let t=e.environments.ssr;if(!O(t))throw Error(`Runtime requires the Vite SSR environment to be runnable.`);return t}async function F(e){await P(e).runner.import(i)}function I(e){let{contentDir:i,context:a,database:o,logger:m,viteServer:h,entryFiles:b,headTags:O}=e,k=n(a.contentDir),A=b.serverRouteFiles.map(e=>({method:e.method,path:e.path,plugin:e.plugin,...e.auth?{auth:e.auth}:{},loadHandler:async()=>(await P(h).runner.import(r(e.handler.filePath)))[e.handler.exportName]})),j=async e=>{let t=T(i,e),n=E(i),a=E(t);if(a!==n&&!a.startsWith(n+D))throw Error(`Refusing to load a content module outside the content directory: ${e}`);return P(h).runner.import(r(t))},M=d({contentDir:i,context:a,database:o,logger:m,authInfo:e.auth?.pageAuthInfo,development:!0,headTags:O,loadHeadTags:()=>g(h),beforeLoad:()=>F(h),loadSsr:()=>(e.onBootPhase?.(`site-code-compile`),P(h).runner.import(r(b.serverEntryPath)))}),N=y(h,e=>m.warn(e)),I=async e=>{try{return await a.platform.fs.readFile(T(a.contentDir,e))}catch{return null}};return u({getConfig:()=>a.config,responseHeaders:e.responseHeaders,registerRoutes:t=>{x(t),p(t,{database:o,logger:m}),C(t,{database:o,readSourceFile:I}),S(t,{contentBuild:e.contentBuild}),w(t,{contentDir:i,context:a,database:o,logger:m,readSourceFile:I}),f(t,{contentAssetsDir:k,fs:a.pluginIO,readSource:e.readCodeAssetSource,logger:m}),e.auth&&e.auth.devLogin&&(e.auth.keys?s(t,e.auth):e.auth.setViewer&&c(t,e.auth))},clientBootstrap:{type:`script-src`,src:`${t}/client-entry.js`},auth:e.auth,corsProxy:e.corsProxy,database:o,contentDir:i,context:a,development:!0,logger:m,pluginRoutes:{contentDir:i,context:a,subprocess:e.subprocess,gatewaySecretSeed:e.gatewaySecretSeed,routes:A,mcpToolEntries:b.mcpToolFiles,loadContentModule:j},manualAuthPaths:[...l(A),v],search:{loadIndexCoverage:async()=>{let e=a.pluginRegistry.listEntityLoaders().filter(e=>e.definition.searchable!==void 0).map(e=>e.definition.id),{done:t,total:n}=await _({database:o,entityLoaderIds:()=>e},[]);return{indexed:t,total:n}}},staticFiles:{contentDir:i,context:a},...M,renderPage:(t,n)=>N.render(()=>(e.onBootPhase?.(`page-data-load`),M.renderPage(t,n)))})}function L(t){return async({changes:n,templateSetChanged:r})=>{o(t.database);let i=t.viteServer.environments.ssr;O(i)&&(r||!n.every(({path:e})=>N.test(e))||[...i.moduleGraph.fileToModulesMap.keys()].some(e=>N.test(e)))&&await y(t.viteServer,e=>t.logger.warn(e)).invalidate(()=>m(i)),n.some(({path:e})=>A.test(e))&&a(t.contentDir);let s=n.some(({event:e,path:t})=>j.test(t)||M.test(t)&&e!==`change`);if(r||s||n.some(({path:e})=>k.test(e))){(r||s)&&(h(t.viteServer.environments.client)||t.logger.warn(`template-set rebuild trigger found no dev engine — client bundle may be stale`));try{await t.refreshClientOutput()}catch(e){let n=e instanceof Error?e.message:String(e);t.logger.warn(`Failed to refresh bundled client output: ${n}`)}}b.generation+=1,b.updatedAt=Date.now(),t.viteServer.environments.client.hot.send({type:`custom`,event:e,data:{changes:n,generation:b.generation}})}}export{L as createRealmOnIngestComplete,I as createRealmRuntimeApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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{
|
|
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)]),n([..._]),i.warn(`The project Markdoc schema did not load; pages are not validated and its tags show their title in page Markdown: ${t instanceof Error?t.message:String(t)}`);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{resolveRuntimeEntryFiles as s,resolveRuntimeServerModuleFiles as c,resolveRuntimeTemplateFiles as l,toViteFsModuleId as u}from"./runtime-files.js";import{MARKDOC_COMPONENTS_VIRTUAL_MODULE_ID as ee,MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as te,MCP_TOOLS_VIRTUAL_MODULE_ID as ne,RUNTIME_HOOKS_VIRTUAL_MODULE_ID as re,SERVER_FNS_VIRTUAL_MODULE_ID as ie,SERVER_MODULES_VIRTUAL_MODULE_ID as ae,SERVER_ROUTES_VIRTUAL_MODULE_ID as oe,TEMPLATES_VIRTUAL_MODULE_ID as se,THEME_STYLES_VIRTUAL_MODULE_ID as ce}from"./constants/virtual-modules.js";import{VITE_LOG_STREAM as le}from"../shared/constants/log-streams.js";import{createRequire as ue}from"node:module";import{fileURLToPath as d,pathToFileURL as de}from"node:url";import{existsSync as f,readdirSync as fe}from"node:fs";import{dirname as p,join as m}from"node:path";import{createLogger as
|
|
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{resolveRuntimeEntryFiles as s,resolveRuntimeServerModuleFiles as c,resolveRuntimeTemplateFiles as l,toViteFsModuleId as u}from"./runtime-files.js";import{MARKDOC_COMPONENTS_VIRTUAL_MODULE_ID as ee,MARKDOC_SCHEMA_VIRTUAL_MODULE_ID as te,MCP_TOOLS_VIRTUAL_MODULE_ID as ne,RUNTIME_HOOKS_VIRTUAL_MODULE_ID as re,SERVER_FNS_VIRTUAL_MODULE_ID as ie,SERVER_MODULES_VIRTUAL_MODULE_ID as ae,SERVER_ROUTES_VIRTUAL_MODULE_ID as oe,TEMPLATES_VIRTUAL_MODULE_ID as se,THEME_STYLES_VIRTUAL_MODULE_ID as ce}from"./constants/virtual-modules.js";import{VITE_LOG_STREAM as le}from"../shared/constants/log-streams.js";import{createRequire as ue}from"node:module";import{fileURLToPath as d,pathToFileURL as de}from"node:url";import{existsSync as f,readdirSync as fe}from"node:fs";import{dirname as p,join as m}from"node:path";import pe from"@redocly/markdoc";import{createLogger as me,transformWithOxc as h}from"vite";import{init as he,parse as ge}from"es-module-lexer";import _e from"js-yaml";import ve from"@vitejs/plugin-react";const g=`__REALM_ENABLE_LAZY_STATIC_DATA__`,ye=`__REALM_TEMPLATE_IDS__`,be=`__REALM_BUILD_PATH_PREFIX__`,xe=`__REALM_BUILD_DEV_LOGIN__`,Se=`__REALM_BUILD_ENV_FILE_DEFAULTS__`,_=`__REALM_VERSION__`,v=`\0${se}`,y=`\0${re}`,b=`\0${ie}`,x=`\0${oe}`,S=`\0${ae}`,C=`\0${ne}`,w=`\0${te}`,T=`\0${ee}`,E=`\0${ce}`,D=`@redocly/theme`,Ce=RegExp(`^${D}(?:/|$)`),O=ue(import.meta.url),we=`window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;window.__getReactRefreshIgnoredExports = ({ id }) => /\\.page\\.[jt]sx?$/.test(id) ? ['frontmatter'] : [];`,Te=`/__realm_react_refresh__.js`,Ee=`<script type="module" src="/bundledDevClient.mjs"><\/script>`,De=[`@redocly/api-docs`,`@redocly/replay`,`@redocly/theme`];function Oe(e){let n=s(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:Ae(e.logger.child(le)),define:A({enableLazyStaticData:e.enableLazyStaticData,themePathPrefixFromGlobal:!0}),experimental:{bundledDev:!0},oxc:{plugins:{styledComponents:{ssr:!0}}},resolve:{tsconfigPaths:!0},plugins:[P({externalizeForSsr:e.externalizeReactForSsr===!0}),Ne(),...ve(),Ge(n.clientEntryPath),Be(e.templateSetProvider,e.contentDir),Fe(),I(e.styledComponentsDependencies,e.styledComponentsRoots),Z(e.contentDir),L(),Ve(),t({contentDir:e.contentDir,outputDir:i(e.contentDir),registerSource:e.registerCodeAssetSource,logger:e.logger}),He(),q(),R(n,e.templateSetProvider,e.contentDir,e.serverModuleSet)],publicDir:!1,root:e.contentDir}}function ke(){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(ke()),"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 Ae(e){let t=/* @__PURE__ */ new Set;return me(`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){j(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},warnOnce(t){j(t)||(this.hasWarned=!0,e.warn(t.trimEnd()))},error(n,r){r?.error&&t.add(r.error.message),e.error(n)}}})}function j(e){return e.includes(`Failed to load source map`)||e.includes(`points to missing source files`)&&/[\\/]node_modules[\\/]/.test(e)}const M=/^(?:react|react-dom|react-router|react-router-dom)(?:\/|$)/,je=/^react-router(?:-dom)?(?:\/|$)/;function N(e){return M.test(e)}function Me(e){let t=de(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:M},handler(n){if(je.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:Me(r)}:r}}}}const F=/^@markdoc\/markdoc(?=\/|$)/;function Ne(){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 Pe=/\.(m?ts|[jt]sx|js)$/;function Fe(){let e=null;return{name:`ssr-transform`,apply:`serve`,buildStart(){e=he},async transform(t,n){if(this.environment?.name!==`ssr`||!Pe.test(n))return null;let r=await h(t,n,{sourcemap:!0,plugins:{styledComponents:{ssr:!0}}});await e;let[i]=ge(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`)||N(r)||r===`styled-components`||r===`file-saver`))continue;let o=await this.resolve(r,n);if(!o||o.external&&!N(r))continue;let s=Qe(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 Ie=/\/node_modules\/@redocly\/(?:api-docs|replay)\/.*\.m?js$/,Le=(()=>{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 Re(t,n,r){if(Ie.test(t))return!0;if(!/\.m?js$/.test(t))return!1;let i=e(t);return Le.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(!Re(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
2
|
`)}if(i===x)return z(e.serverRouteFiles);if(i===S)return V(c(r,n));if(i===C)return B(e.mcpToolFiles);if(i===w)return G(H(n));if(i===T)return K(U(n,`components.tsx`));if(i===E)return W(ze(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(`
|
|
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 ze(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(
|
|
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 ze(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(pe.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 Be(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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{formatCommandRows as e,formatCompletion as t,formatContentRow as n,formatFailure as r,formatFileChanges as i,pluralize as a,printBuildHelp as o,shouldUseColors as s}from"../output.js";import{getPathPrefix as c,setGlobalPathPrefix as l}from"../../shared/path-prefix.js";import{stopwatch as u}from"../../shared/logger.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{parseArgs as h}from"../parse-args.js";import{COMMON_FLAGS as g,parseBuildTarget as _,parseHintsFlag as v,parseHostPlatform as y,parseOptionalStringFlag as b,reportUsageError as x,resolveCommonArgs as S,setUpLogging as C}from"../args.js";import{createCliOutput as w,shouldWriteLogGroups as T}from"../log-output/index.js";import{formatProblemCounts as E,reportProblems as D}from"../problems-output.js";import{hasInjectedContentSteps as O,openContentSession as k,recordRunFailure as A,runContentIngestWithStaticDataBuild as j}from"./ingest.js";import M from"node:process";async function N(N,P,F){let I=h(N,{alias:g.alias,boolean:[...g.boolean,`dev-login`],string:[...g.string,`hints`,`target`,`platform`,`path-prefix`]});if(I.help)return o(P.stdout),0;let L,R,z,B;try{let e=S(I);L=C(e,w(P,e)),R=_(I.target),z=y(I.platform),B=b(I[`path-prefix`],`--path-prefix`),f(R,z)}catch(e){return x(e,P)}l(B??M.env.REDOCLY_PREFIX_PATHS??``);let{logger:V,reporter:H}=L,U=s();P.stdout(e([n(L.contentDir),[`Prefix`,c()||void 0]],U)),V.debug(`Process startup took ${M.uptime().toFixed(2)}s`);let W=u(),G;try{G=O(F)?void 0:await k(L);let{ingestResult:e,problems:n,staticDataResult:o,ignoreMarkdocErrors:s}=await j(L,F,{hints:v(I.hints),session:G}),c=D(P,n,{ignoreMarkdocErrors:s,groups:T(P)}),l=await(F.runRuntimeBuild??p)({contentDir:L.contentDir,target:R,platform:z,logger:V,reporter:H,templateSet:e.templateSet,serverModuleSet:e.serverModuleSet,devLogin:I[`dev-login`]===!0}),u=await H.run(`Validating React pages`,()=>m({contentDir:L.contentDir,outputDir:l.outputDir,sourceTemplates:e.templateSet.sourceTemplates,databaseUrl:L.databaseUrl,database:G?.database,context:G?.context,logger:V}),({pageCount:e,renderedCount:t,problems:n})=>{if(e===0)return`No React pages`;if(t===0)return`${a(e,`React page`)} unchanged`;let r=t===e?`Checked ${a(e,`React page`)}`:`Checked ${t} of ${a(e,`React page`)}`;return n.length>0?`${r}, ${n.length} failed to render`:r}),f=D(P,u.problems,{ignoreMarkdocErrors:s,groups:T(P)});return await(F.writeBuildOutputMetadata??d)({contentDir:L.contentDir,outputDir:l.outputDir,databaseUrl:L.databaseUrl,database:G?.database,context:G?.context,logger:V}),P.stdout(``),c+f>0?(P.stdout(r(`Build failed`,W(),`${a(c+f,`content error`)} (see Problems above)`,{colors:U,stacks:L.stacks})),1):(P.stdout(t(`Build complete`,W(),[[`Files`,i(e.diff.summary)],[`Built`,a(o.staticDataCount,`content item`)],[`Problems`,E(n,{ignoreMarkdocErrors:s})]],U)),0)}catch(e){P.stdout(r(`Build failed`,W(),e,{colors:U,stacks:L.stacks}));let t=G?.database.close();return G=void 0,await t?.catch(()=>void 0),await A(L,F,e),1}finally{await G?.database.close()}}export{N as runBuild};
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{printDevHelp as e}from"../output.js";import{setGlobalPathPrefix as t}from"../../shared/path-prefix.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 e(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;t(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{
|
|
1
|
+
import{formatCount as e}from"../../shared/log-format.js";import{describeFileChanges as t,formatCommandHeader as n,formatCompletion as r,formatContentRow as i,formatFailure as a,formatFileChanges as o,pluralize as s,printIngestHelp as c,shouldUseColors as l}from"../output.js";import{createNodePlatform as u}from"../../platform/node/create.js";import{stopwatch as d}from"../../shared/logger.js";import{createContentLayerContext as f}from"../../content-layer/context.js";import{openContentLayerDatabase as p}from"../../content-layer/database/connection.js";import{createContentPlugins as m}from"../../content-layer/plugins/create-content-plugins.js";import{createProjectPluginLoadError as h,loadAndRegisterProjectPlugins as g}from"../../content-layer/plugins/project/load.js";import"../../content-layer/plugins/index.js";import{loadUserMarkdocSchema as _}from"../../bundler/user-markdoc-schema.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,u){let f=w(e,{alias:T.alias,boolean:T.boolean,string:[...T.string,`hints`]});if(f.help)return c(t.stdout),0;let p;try{let e=O(f);p=k(e,A(t,e))}catch(e){return D(e,t)}let m=E(f.hints),h=l();t.stdout(n(`ingest`,[i(p.contentDir)],h));let g=d();try{let{ingestResult:e,problems:n,staticDataResult:i,ignoreMarkdocErrors:c}=await z(p,u,{hints:m}),l=N(t,n,{ignoreMarkdocErrors:c,groups:j(t)});return t.stdout(``),l>0?(t.stdout(a(`Ingest failed`,g(),`${s(l,`content error`)} (see Problems above)`,{colors:h,stacks:p.stacks})),1):(t.stdout(r(`Ingest complete`,g(),[[`Files`,o(e.diff.summary)],[`Built`,s(i.staticDataCount,`content item`)],[`Problems`,M(n,{ignoreMarkdocErrors:c})]],h)),0)}catch(e){return t.stdout(a(`Ingest failed`,g(),e,{colors:h,stacks:p.stacks})),await B(p,u,e),1}}function L(e){return e.runContentIngest!==void 0||e.runContentEntityBuild!==void 0}async function R(e){let t=await g(e.contentDir,{logger:e.logger});if(t.diagnostics.length>0)throw h(t.diagnostics);await _({contentDir:e.contentDir,logger:e.logger,reporter:e.reporter});let n=f({contentDir:e.contentDir,logger:e.logger,plugins:m(e.contentDir)});return{context:n,database:await V(e,n.platform)}}async function z(n,r,i){if(L(r)){let e=await(r.runContentIngest??C)({contentDir:n.contentDir,databaseUrl:n.databaseUrl,logger:n.logger,hints:i?.hints}),t=await(r.runContentEntityBuild??S)({contentDir:n.contentDir,databaseUrl:n.databaseUrl,logger:n.logger});return{ingestResult:e,problems:[...e.problems,...t.problems??[]],staticDataResult:{staticDataCount:t.entityCount},ignoreMarkdocErrors:!1}}let a=i?.session===void 0,{context:o,database:c}=i?.session??await R(n);try{let r=await n.reporter.run(`Ingesting content`,e=>C({contentDir:n.contentDir,context:o,database:c,databaseUrl:n.databaseUrl,logger:n.logger,hints:i?.hints,searchSync:!1,collectProblems:!1,captureRevisions:!0,onProgress:t=>{t.stage===`sync`&&e.progress(t.done,t.total)}}),e=>`Ingested ${s(e.diff.summary.totalCurrent,`file`)} (${t(e.diff.summary)})`),a=await S({contentDir:n.contentDir,context:o,database:c,databaseUrl:n.databaseUrl,logger:n.logger,reporter:n.reporter,inlineSearchables:r.inlineSearchables});return await n.reporter.run(`Checking links`,()=>P({database:c,config:o.config,readSourceFile:async e=>{try{return await o.platform.fs.readFile(F(n.contentDir,e))}catch{return null}},logger:n.logger}),t=>t.ok?t.judged===t.checked?`Checked ${s(t.checked,`link`)} (${e(t.broken)} broken)`:`Re-checked ${e(t.judged)} of ${s(t.checked,`link`)} (${e(t.broken)} broken)`:`Link check failed; stored link problems were left unchanged`),{ingestResult:r,problems:await v(c),staticDataResult:{staticDataCount:a.entityCount},ignoreMarkdocErrors:o.config.platform?.ignoreMarkdocErrors===!0}}finally{a&&await c.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,u());try{await r.db.transaction(e=>b(e,`system`,[y(t,{scope:`global`,source:`system`})]))}finally{await r.close()}}catch{}}function V(e,t){return p({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{
|
|
2
|
-
`)}async function W(e,t){let n=k({input:t.terminal?.stdin??
|
|
1
|
+
import{ANSI as e,paint as t}from"../../shared/log-format.js";import{formatFailure as n,printTranslateHelp as r,shouldUseColors as i}from"../output.js";import{DEFAULT_LOCALE_PLACEHOLDER as a,L10N_DIR as o,TRANSLATIONS_FILE_NAMES as s}from"../../shared/constants/l10n/defaults.js";import{compareStrings as c}from"../../shared/utils/compare-strings.js";import{isObject as l}from"../../shared/utils/is-object.js";import{l10nDirOf as u,listL10nDirs as d,normalizeL10nConfig as f}from"../../shared/utils/l10n.js";import{defaultTranslationImports as p}from"../../shared/constants/l10n/default-translations.js";import{createNodePlatformFs as m}from"../../platform/node/fs.js";import{stopwatch as h}from"../../shared/logger.js";import{loadRedoclyConfig as g}from"../../content-layer/config.js";import{contentIgnoreMatcherOf as _,scanContentFiles as v}from"../../content-layer/ingest/scan.js";import{SIDEBAR_FILENAME_REGEX as y}from"../../content-layer/plugins/internal/sidebar/index.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"node:process";import O from"js-yaml";import{createInterface as k}from"node:readline/promises";const A=`default`,j=/^[\w-]+$/,M=/^translations\.ya?ml$/i,N=O.FAILSAFE_SCHEMA.extend({implicit:[new O.Type(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:e=>[`~`,`null`,`Null`,`NULL`].includes(e),construct:()=>null})]});async function P(a,o,s){let c=x(a,{alias:{h:`help`,d:`project-dir`,D:`debug`},boolean:[...S.boolean,`debug`],string:[`project-dir`]});if(c.help)return r(o.stdout),0;let l,u,d=c._.map(String);try{if({contentDir:l,stacks:u}=w(c),d.length===0)throw new b(`Locale is required but was not provided.`);let e=d.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,o)}let f=i(),p=h();try{let n=m(),{config:r}=await g(l,n),i=await F(l,n,r,d),a=await(s.confirm??(e=>W(e,o)))(U(i,f));if(a===void 0)return o.stderr(`The confirmation prompt got no answer. No files changed.`),1;if(!a)return o.stdout(`No files changed.`),0;for(let e of i)await n.writeFile(T(l,e.path),O.dump(e.translations),{recursive:!0});return o.stdout(t(`✓ Translations updated`,e.bold+e.green,f)),0}catch(e){return o.stdout(n(`Translate failed`,p(),e,{colors:f,stacks:u})),1}}async function F(e,t,n,r){let{defaultLocale:i}=f(n.l10n),a=await d(e,t),l=r[0]===`all`?[A,...a]:r,u=await I(e,t,n),p=/* @__PURE__ */ new Map;for(let n of l){let r=n===A||n.toLowerCase()===i.toLowerCase(),l=r?``:E.join(o,a.find(e=>H(e,n))??n),d=await B(e,t,l),f=d??E.join(l,s[0]);if(p.has(f))continue;let m=d?V(await t.readFile(T(e,d)),d):{},h={...await R(r?i:n),...u,...m};p.set(f,{path:f,exists:d!==void 0,translations:Object.fromEntries(Object.entries(h).sort(([e],[t])=>c(e,t)))})}return[...p.values()]}async function I(e,t,n){let r=_(n),i=(await v({fs:t,rootDir:e})).filter(e=>y.test(e.path)&&u(e.path)===void 0&&!r(e.path));return{...L(await Promise.all(i.map(async e=>O.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(!l(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(e){let t=e.split(`-`)[0];return{...await p[a](),...await z(t),...H(t,e)?{}:await z(e)}}async function z(e){let t=Object.keys(p).find(t=>H(t,e));return t===void 0?{}:p[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=O.load(e,{filename:t,schema:N})??{};if(!l(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(n,r){let i=n=>n.map(n=>` - ${t(n.path,e.cyan,r)}`),a=n.filter(e=>!e.exists),o=n.filter(e=>e.exists),s=[`Confirm the following actions:`,``];return a.length>0&&s.push(`Create new files with translations stubs:`,...i(a),``),o.length>0&&s.push(`Update translations files with missing phrases (this doesn't rewrite existing data values):`,...i(o),``),s.push(`Continue? (Y/n) `),s.join(`
|
|
2
|
+
`)}async function W(e,t){let n=k({input:t.terminal?.stdin??D.stdin,output:t.terminal?.stdout??D.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatCount as e}from"../../shared/log-format.js";import{pluralize as t}from"../output.js";import{createQuarterMarks as n,formatPhaseEnd as r}from"../log-output/phase-lines.js";function i(){let e=`idle`,t=0,r=n();return i=>{let a=e;e=i.state;let{done:o,total:s}=i;if(i.state===`running`){let e=[];return a!==`running`&&(t=performance.now(),r=n(),e.push({kind:`start`,pending:s-o})),r(o,s)&&e.push({kind:`progress`,done:o,total:s}),e}return a===`running`?i.state===`paused`?[{kind:`pause`,done:o,total:s}]:[{kind:`end`,done:o,failed:i.failed,durationMs:performance.now()-t}]:[]}}function a(n,i){switch(n.kind){case`start`:return`
|
|
1
|
+
import{formatCount as e}from"../../shared/log-format.js";import{pluralize as t}from"../output.js";import{createQuarterMarks as n,formatPhaseEnd as r}from"../log-output/phase-lines.js";function i(){let e=`idle`,t=0,r=n();return i=>{let a=e;e=i.state;let{done:o,total:s}=i;if(i.state===`running`){let e=[];return a!==`running`&&(t=performance.now(),r=n(),e.push({kind:`start`,pending:s-o})),r(o,s)&&e.push({kind:`progress`,done:o,total:s}),e}return a===`running`?i.state===`paused`?[{kind:`pause`,done:o,total:s}]:[{kind:`end`,done:o,failed:i.failed,durationMs:performance.now()-t}]:[]}}function a(n,i){switch(n.kind){case`start`:return` Building ${t(n.pending,`content item`)}`;case`progress`:return` ${e(n.done)}/${e(n.total)} (${Math.floor(n.done/n.total*100)}%)`;case`pause`:return` Paused building at ${e(n.done)}/${e(n.total)}`;case`end`:{let a=n.failed>0?` (${e(n.failed)} failed)`:``;return r(`Building content items`,{ok:!0,summary:`Built all ${t(n.done,`content item`)}${a}`},n.durationMs,i)}}}export{i as createContentBuildTracker,a as formatContentBuildEvent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{formatCommandHeader as e,formatContentRow as t,formatDisplayPath as n,shouldUseColors as r}from"../output.js";import{withMinLevel as i}from"../../shared/logger.js";import{isInteractiveTerminal as a}from"../log-output/index.js";import{createLogFile as o}from"./log-file.js";import{createPlainDevOutput as s}from"./plain.js";import{createTuiDevOutput as c}from"./tui.js";import l from"node:process";function u(u,d){let f=r(),p=o(d.logFile),m=s({stdout:p.write,stacks:!0}),h=u.terminal,g=h&&a(h.stdout)&&h.stdin.isTTY?c({stdout:h.stdout,stdin:h.stdin,colors:f,stacks:d.stacks,expandPhases:d.expandPhases,logFile:n(d.logFile),onQuit:()=>l.kill(l.pid,`SIGINT`)}):s({stdout:u.stdout,colors:f,stacks:d.stacks,time:`clock`}),_=i(g,d.level??`warn`),v=[_,m],y=[t(d.contentDir),[`Log`,n(d.logFile)]];return u.stdout(e(`preview`,y,f)),p.write(e(`preview`,y,!1)),{write(e){_.write(e),e.level!==`debug`&&m.write(e)},phaseStart:e=>v.forEach(t=>t.phaseStart(e)),phaseProgress:(e,t)=>v.forEach(n=>n.phaseProgress(e,t)),phaseEnd:(e,t,n)=>v.forEach(r=>r.phaseEnd(e,t,n)),ready:e=>v.forEach(t=>t.ready(e)),changeStart:()=>v.forEach(e=>e.changeStart()),changeEnd:e=>v.forEach(t=>t.changeEnd(e)),contentBuild:e=>v.forEach(t=>t.contentBuild(e)),problems:e=>v.forEach(t=>t.problems(e)),close(){_.close(),p.close()}}}export{u as createDevConsole};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ANSI as e,formatCount as t,formatDuration as n,paint as r,prefixTime as i}from"../../shared/log-format.js";import{pluralize as a}from"../output.js";import{
|
|
2
|
-
`)[0]??``;return[c(e),e.severity,e.code,t].join(` `)}function h(e){let t=e.range?.start;return[e.severity,e.code,e.filePath??``,t?.line??``,t?.character??``,e.message].join(`\0`)}function g(e){let n=Math.max(0,e.total-e.done-e.failed),r=e.failed>0?` · ${t(e.failed)} failed`:``;return e.state===`running`?`${t(e.done)}/${t(e.total)}
|
|
1
|
+
import{ANSI as e,formatCount as t,formatDuration as n,paint as r,prefixTime as i}from"../../shared/log-format.js";import{pluralize as a}from"../output.js";import{DEV_CONTENT_BUILD_PATH as o}from"../../shared/constants/dev-content-build.js";import{DEV_PROBLEMS_PATH as s}from"../../shared/constants/dev-problems.js";import{formatProblemPosition as c}from"../problems-output.js";function l(t,n,i){if(t.errors===0&&t.warnings===0)return r(`no problems`,e.green,n);let o=(e,t,n)=>{let r=t===void 0||t===e?``:` (${e>t?`+`:``}${e-t})`;return`${a(e,n)}${r}`};return[t.errors>0||(i?.errors??0)>0?r(o(t.errors,i?.errors,`error`),e.red,n&&t.errors>0):null,t.warnings>0||(i?.warnings??0)>0?r(o(t.warnings,i?.warnings,`warning`),e.yellow,n&&t.warnings>0):null].filter(e=>e!==null).join(`, `)}function u(e){return e.length===1?e[0]??``:a(e.length,`file`)}function d(t,a,o,s){let c=s.colors??!1,d=[`↻ Last change processed in ${n(t.durationMs)}`,u(t.paths),l(a,c,o)].join(r(` · `,e.dim,c));return i(d,t.time,s)}function f(t,n,a,o){let s=o.colors??!1,c=p(t.rows,n.rows,s);if(c.length===0&&t.errors===n.errors&&t.warnings===n.warnings)return[];let u=[`↻ Built content items`,l(n,s,t)].join(r(` · `,e.dim,s));return[i(u,a,o),...c]}function p(n,i,a){let o=new Set(n.map(h)),s=new Set(i.map(h)),c=[...i.filter(e=>!o.has(h(e))).map(e=>({problem:e,sign:`+`})),...n.filter(e=>!s.has(h(e))).map(e=>({problem:e,sign:`-`}))],l=c.slice(0,20).map(({problem:t,sign:n})=>r(` ${n} ${m(t)}`,n===`+`?e.red:e.green,a));return c.length>20&&l.push(` …and ${t(c.length-20)} more`),l}function m(e){let t=e.message.split(`
|
|
2
|
+
`)[0]??``;return[c(e),e.severity,e.code,t].join(` `)}function h(e){let t=e.range?.start;return[e.severity,e.code,e.filePath??``,t?.line??``,t?.character??``,e.message].join(`\0`)}function g(e){let n=Math.max(0,e.total-e.done-e.failed),r=e.failed>0?` · ${t(e.failed)} failed`:``;return e.state===`running`?`${t(e.done)}/${t(e.total)} built${r}`:e.state===`paused`?`paused at ${t(e.done)}/${t(e.total)}${r}`:n>0?`${a(n,`item`)} not built${r}`:`all built${r}`}function _(e){return[` Problems as JSON: GET ${e}${s}?list=1`,` Build all content items: PATCH ${e}${o} {"state":"running"}`]}export{f as formatBuiltProblems,d as formatChangeLine,u as formatChangedPaths,g as formatContentBuildStatus,_ as formatEndpointHints,p as formatProblemDiff,l as formatProblemSummary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pluralize as e}from"../output.js";import{createPlainOutput as t}from"../log-output/plain.js";import{
|
|
1
|
+
import{pluralize as e}from"../output.js";import{createPlainOutput as t}from"../log-output/plain.js";import{formatBuiltProblems as n,formatChangeLine as r,formatContentBuildStatus as i,formatEndpointHints as a,formatProblemDiff as o,formatProblemSummary as s}from"./lines.js";import{createContentBuildTracker as c,formatContentBuildEvent as l}from"./content-build.js";function u(u){let d=u.colors??!1,f=null,p=c();return{...t(u),ready(t){f=t.problems;let n=[e(t.pages,`page`),s(t.problems,d)];t.contentBuild&&n.push(i(t.contentBuild)),u.stdout(` ${n.join(` · `)}`);for(let e of a(t.url))u.stdout(e)},changeStart(){},changeEnd(e){let t=f??e.problems;if(f=e.problems,!e.failed){u.stdout(r({...e,time:Date.now()},e.problems,t,u));for(let n of o(t.rows,e.problems.rows,d))u.stdout(n)}},contentBuild(e){for(let t of p(e))u.stdout(l(t,d))},problems(e){let t=f??e;f=e;for(let r of n(t,e,Date.now(),u))u.stdout(r)},close(){}}}export{u as createPlainDevOutput};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ANSI as e,formatClockTime as t,formatDuration as n,paint as r,stripAnsi as i}from"../../shared/log-format.js";import{formatProductTitle as a,pluralize as o}from"../output.js";import{HIDE_CURSOR as s,SHOW_CURSOR as c,SPINNER as l,createTtyOutput as u}from"../log-output/tty.js";import{formatProblems as d}from"../problems-output.js";import{
|
|
2
|
-
`.repeat(8)+`\x1B[8A`+s),k(),O())},j=()=>{b&&(b=!1,n.write(`7[r\x1b[${D()};1H\x1b[J8`+c))},M=()=>{if(!E()){j();return}if(!b){A();return}k(),O()},N=()=>{let e=o.updating||o.
|
|
1
|
+
import{ANSI as e,formatClockTime as t,formatDuration as n,paint as r,stripAnsi as i}from"../../shared/log-format.js";import{formatProductTitle as a,pluralize as o}from"../output.js";import{HIDE_CURSOR as s,SHOW_CURSOR as c,SPINNER as l,createTtyOutput as u}from"../log-output/tty.js";import{formatProblems as d}from"../problems-output.js";import{formatBuiltProblems as f,formatChangeLine as p,formatChangedPaths as m,formatContentBuildStatus as h,formatProblemDiff as g,formatProblemSummary as _}from"./lines.js";import{createContentBuildTracker as v,formatContentBuildEvent as y}from"./content-build.js";import{spawn as b}from"node:child_process";function x(i,s){let{colors:c}=s,u=l[s.frame%l.length],d=(t,n)=>` ${r(t.padEnd(10),e.dim,c)}${n}`,f=i.updating?`${u} updating…`:i.failed?r(`update failed; serving the last good state`,e.red,c):r(`ready`,e.green,c),p=i.contentBuild?.state===`running`;return[r(`─`.repeat(s.width-1),e.dim,c),` ${r(a(`preview`),e.bold,c)}`,d(`Local`,r(i.url,e.cyan,c)),d(`Status`,[f,o(i.pages,`page`),i.problems?_(i.problems,c):``].join(` · `)),d(`Last`,i.lastChange?[m(i.lastChange.paths),n(i.lastChange.durationMs),t(i.lastChange.time).slice(0,8)].join(` · `):r(`no changes yet`,e.dim,c)),d(`Content`,i.contentBuild?`${p?`${u} `:``}${h(i.contentBuild)}`:``),d(`Log`,i.logFile),r(` p problems · o open · m ${p?`pause`:`build all`} · c clear · q quit`,e.dim,c)].map(e=>C(e,s.width))}function S(t){let{stdout:n,stdin:i}=t,a=t.colors??!1,o={url:``,pages:0,problems:null,updating:!1,failed:!1,lastChange:null,contentBuild:null,logFile:t.logFile},l=u(t),m=l.print,h=v(),_=null,b=!1,S=0,C,T=()=>n.rows||24,E=()=>T()>=13,D=()=>T()-8+1,O=()=>{if(!b)return;let e=x(o,{width:n.columns||80,colors:a,frame:S}).map((e,t)=>`\x1b[${D()+t};1H\x1b[2K${e}`);n.write(`\x1B7`+e.join(``)+`\x1B8`)},k=()=>{n.write(`7\x1b[1;${T()-8}r8`)},A=()=>{!b&&E()&&(b=!0,n.write(`
|
|
2
|
+
`.repeat(8)+`\x1B[8A`+s),k(),O())},j=()=>{b&&(b=!1,n.write(`7[r\x1b[${D()};1H\x1b[J8`+c))},M=()=>{if(!E()){j();return}if(!b){A();return}k(),O()},N=()=>{let e=o.updating||o.contentBuild?.state===`running`;e&&!C?(C=setInterval(()=>{S+=1,O()},100),C.unref()):!e&&C&&(clearInterval(C),C=void 0)},P=async()=>{let e=await _?.listProblems()??[];m(e.length>0?`\n${d(e,{colors:a})}\n`:` No problems`)},F=i=>{switch(i){case`p`:P().catch(t=>m(r(`✗ Could not read the problems: ${String(t)}`,e.red,a)));break;case`o`:w(o.url,()=>m(r(`⚠ Could not open a browser`,e.yellow,a)));break;case`m`:o.contentBuild?.state===`running`?_?.pauseBuild():_?.startBuild();break;case`c`:n.write(`\x1B[2J\x1B[3J\x1B[H`),O();break;case`q`:case``:I(),t.onQuit()}},I=()=>{clearInterval(C),C=void 0,n.off(`resize`,M),i.off(`data`,F),i.isTTY&&i.setRawMode(!1),i.pause(),j(),process.off(`exit`,I)};return{...l,ready(e){_=e.controls,Object.assign(o,{url:e.url,pages:e.pages,problems:e.problems,contentBuild:e.contentBuild}),process.once(`exit`,I),n.on(`resize`,M),i.setRawMode(!0),i.setEncoding(`utf8`),i.on(`data`,F),i.resume(),A()},changeStart(){o.updating=!0,N(),O()},changeEnd(e){let t=o.problems??e.problems,n={paths:e.paths,durationMs:e.durationMs,time:Date.now()};if(Object.assign(o,{updating:!1,failed:e.failed,pages:e.pages,problems:e.problems,lastChange:n}),N(),!e.failed){m(p(n,e.problems,t,{colors:a,time:`clock`}));for(let n of g(t.rows,e.problems.rows,a))m(n)}O()},contentBuild(e){o.contentBuild=e;for(let t of h(e))(t.kind===`pause`||t.kind===`end`)&&m(y(t,a));N(),O()},problems(e){let t=o.problems??e;o.problems=e;for(let n of f(t,e,Date.now(),{colors:a,time:`clock`}))m(n);O()},close:I}}function C(e,t){let n=i(e);return n.length<t?e:`${n.slice(0,t-2)}…`}function w(e,t){let[n,r]=process.platform===`darwin`?[`open`,[e]]:process.platform===`win32`?[`cmd`,[`/c`,`start`,``,e]]:[`xdg-open`,[e]];b(n,r,{stdio:`ignore`,detached:!0}).on(`error`,t).unref()}export{S as createTuiDevOutput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{shouldUseColors as e}from"../output.js";import{withMinLevel as t}from"../../shared/logger.js";import{createPlainOutput as n}from"./plain.js";import{createTtyOutput as r}from"./tty.js";function i(i,s){let c=e(),l=o(i)?r({stdout:i.terminal.stdout,colors:c,stacks:s.stacks,expandPhases:s.expandPhases}):n({stdout:i.stdout,colors:c,stacks:s.stacks,groups:a(i)});return t(l,s.level??`info`)}function a(e,t=process.env){return!o(e)&&t.REDOCLY_REUNITE_BUILD===`1`}function o(e){return e.terminal!==void 0&&s(e.terminal.stdout)}function s(e,t=process.env){let n=t.CI?.toLowerCase(),r=n!==void 0&&n!==``&&n!==`0`&&n!==`false`;return e.isTTY===!0&&t.TERM!==`dumb`&&!r}export{i as createCliOutput,s as isInteractiveTerminal,a as shouldWriteLogGroups};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e,hashString as t}from"../content-layer/database/utils/json.js";import{
|
|
1
|
+
import{hashJsonValue as e,hashString as t}from"../content-layer/database/utils/json.js";import{readPackageVersion as n}from"./output.js";import{APP_DATA_ENTITY_KEY as r}from"../shared/constants/app-data.js";import{isObject as i}from"../shared/utils/is-object.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as a,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as o,SIDEBAR_ROUTE_DEP_KEY as s,isLocalizedSidebarDepKey as c}from"../shared/constants/route-deps.js";import{hashContentBytes as l}from"../shared/utils/content-hash.js";import{SOURCE_TEMPLATE_PREFIX as u}from"../shared/constants/template-ids.js";import{getProcessEnv as d}from"../shared/public-env.js";import{RUNTIME_SSR_DIRNAME as f,RUNTIME_SSR_ENTRY_FILENAME as p}from"../shared/constants/runtime-layout.js";import{RBAC_TEAM_ANONYMOUS as m,RBAC_TEAM_AUTHENTICATED as h}from"../shared/rbac/types.js";import{entities as g,pageMarkdown as _,reactPageChecks as v,routeDeps as y,routes as b}from"../content-layer/database/schema.js";import{loadContentLayerConfig as x}from"../content-layer/config.js";import{resolveContentLayerContext as ee}from"../content-layer/context.js";import{openContentLayerDatabase as S}from"../content-layer/database/connection.js";import{createRouteQueryEvaluator as C}from"../content-layer/plugins/utils/route-index.js";import{createContentPlugins as w}from"../content-layer/plugins/create-content-plugins.js";import"../content-layer/plugins/index.js";import{createMarkdownCopyRule as T}from"../content-layer/markdown-copy-rule.js";import{createProblem as te}from"../content-layer/problems/codes.js";import"../content-layer/server/database.js";import{extractRbacTeamNames as E}from"../server/auth/dev-login-teams.js";import{resolvePageOwnTitle as D,resolveRuntimePage as O}from"../server/content.js";import{collectChunks as k,loadTemplateManifestKeys as A,loadViteManifest as j}from"../server/manifest-assets.js";import{loadRuntimeConfig as M}from"../server/runtime-config.js";import{loadContentLayerState as N}from"../content-layer/context-state.js";import{toRbacTeams as P}from"../content-layer/ingest/rbac-teams.js";import{htmlToMarkdownDoc as ne}from"../content-layer/markdown/search/html-to-markdown.js";import{pathToFileURL as re}from"node:url";import{join as F}from"node:path";import{readFile as ie}from"node:fs/promises";import{and as I,asc as L,eq as R,gte as z,inArray as B,lt as V}from"drizzle-orm";const H=/\.page\.tsx?$/i,U=/-[\w-]{8}\.mjs\b/g,W=`http://localhost`,G=`react-page:markdown:`,K=[s,a,o];async function q(e){let t=[...e.sourceTemplates].filter(e=>H.test(e));if(t.length===0)return await e.database?.db.transaction(async e=>{await e.delete(v),await e.delete(_).where(ae())}),{pageCount:0,renderedCount:0,problems:[]};let n=e.database===void 0,r=e.database??await S({contentDir:e.contentDir,databaseUrl:e.databaseUrl,logger:e.logger,runMigrations:!1});try{let n=ee({contentDir:e.contentDir,context:e.context,logger:e.logger,plugins:e.context?[]:w(e.contentDir)}),{config:i}=await x({context:n}),a=await N({context:n,database:r}),{config:o}=await M(r,d()),s=F(e.outputDir,f),c,l=await oe(r,t),u=await se({config:o,database:r,pages:l,ssrDir:s}),g=await ue(r),y=C(a,i).index(),b=T(i),S={...o,access:{...o.access,rbac:void 0}},D=[m,h,...E(o)],O=[],k=/* @__PURE__ */ new Map,A=[];for(let t of l){let{path:i,slug:a}=t,l=u.get(J(t));if(l!==void 0&&g.get(J(t))===l)continue;c??=await import(re(F(s,p)).href);let d={context:n,database:r,ssr:c,slug:a,logger:e.logger},f=(await Q({...d,config:S,teams:D}))?.error;if(f!==void 0){k.set(J(t),void 0),O.push(te({code:`react-page/render-failed`,message:`Runtime error${t.locale?` in locale ${t.locale}`:``}: ${f.message}`,location:{filePath:i}}));continue}k.set(J(t),l);for(let n of t.slugs){let r=y.get(n),a=r&&b.allows(r)?de(r.access):void 0;if(r===void 0||a===void 0)continue;let s=await Q({...d,slug:n,config:o,teams:a});if(s?.error!==void 0)e.logger?.warn(`No Markdown for the React page ${i} at ${n}: ${s.error.message}`);else if(s!==null){let e=J(t);A.push(...await fe({key:e,html:s.html,route:r,fingerprint:l}))}}}let j=[...g.keys()].filter(e=>!u.has(e));if(k.size>0||j.length>0){let e=new Map([...g].filter(([e])=>u.has(e)));for(let[t,n]of k)n===void 0?e.delete(t):e.set(t,n);let t=[...e].map(([e,t])=>Object.assign(Y(e),{fingerprint:t})),n=[...j,...k.keys()].map(X);await r.db.transaction(async e=>{await e.delete(v);for(let n=0;n<t.length;n+=500)await e.insert(v).values(t.slice(n,n+500));for(let t of Z(n))await e.delete(_).where(B(_.entityKey,t));for(let t=0;t<A.length;t+=500)await e.insert(_).values(A.slice(t,t+500))})}return{pageCount:l.length,renderedCount:k.size,problems:O}}finally{n&&await r.close()}}function J(e){return`${e.path}\u0000${e.locale}`}function Y(e){let t=e.lastIndexOf(`\0`);return{path:e.slice(0,t),locale:e.slice(t+1)}}function X(e){let{path:t,locale:n}=Y(e);return`${G}${n}/${t}`}function ae(){return I(z(_.entityKey,G),V(_.entityKey,`${G.slice(0,-1)};`))}async function oe(e,t){let n=[];for(let r of Z(t.map(e=>`${u}${e}`)))n.push(...await e.db.select({slug:b.slug,locale:b.locale,isFallback:b.isFallback,canonicalSlug:b.canonicalSlug,template:b.template,metadata:b.metadata}).from(b).where(B(b.template,r)).orderBy(L(b.id)));let r=/* @__PURE__ */ new Map;for(let{isFallback:e,canonicalSlug:t,...i}of n){let n={path:i.template.slice(u.length),slugs:[i.slug],depsSlug:e&&t?t:i.slug,...i},a=r.get(J(n));a?a.slugs.push(i.slug):r.set(J(n),n)}return[...r.values()]}async function se(t){let[i,a]=await Promise.all([j(t.ssrDir),A(t.ssrDir)]),o=await ce(t.database,t.pages.map(e=>e.depsSlug)),s=le(t.ssrDir),c=async(e,t)=>(await Promise.all([...k(i,e,t)].map(s))).sort(),l=Object.values(i).find(e=>e.isEntry),[u]=await t.database.db.select({dataHash:g.dataHash}).from(g).where(I(R(g.isCurrent,1),R(g.key,r))),d={version:n(),config:e(t.config),appData:u?.dataHash??null,entry:await s(p),entryChunks:l?await c(l):[]},f=/* @__PURE__ */ new Map;for(let n of t.pages){let t=i[a[n.template]??``];f.set(J(n),t===void 0?void 0:e({...d,chunks:await c(t,{dynamicImports:!0}),route:{slug:n.slug,template:n.template,metadata:n.metadata},deps:o.get(n.depsSlug)??[]}))}return f}async function ce(e,t){let n=[];for(let r of Z(t))n.push(...await e.db.select().from(y).where(B(y.routeSlug,r)));let r=n.filter(e=>!K.includes(e.key)&&!c(e.key)),i=[...new Set(r.filter(e=>e.dependencyType===`entity`).map(e=>e.target))],a=/* @__PURE__ */ new Map;for(let t of Z(i)){let n=await e.db.select({key:g.key,dataHash:g.dataHash}).from(g).where(I(R(g.isCurrent,1),B(g.key,t)));for(let e of n)a.set(e.key,e.dataHash)}let o=/* @__PURE__ */ new Map;for(let e of r.sort((e,t)=>e.key<t.key?-1:+(e.key>t.key))){let t=o.get(e.routeSlug)??[];t.push({key:e.key,type:e.dependencyType,target:e.target,args:e.args,dataHash:a.get(e.target)??null}),o.set(e.routeSlug,t)}return o}function*Z(e){for(let t=0;t<e.length;t+=50)yield e.slice(t,t+50)}function le(e){let n=/* @__PURE__ */ new Map;return r=>{let i=n.get(r);return i===void 0&&(i=ie(F(e,r),`utf8`).then(e=>t(e.replace(U,`.mjs`))),n.set(r,i)),i}}async function ue(e){let t=await e.db.select().from(v);return new Map(t.map(e=>[J(e),e.fingerprint]))}function de(e){let t=P(e);if(t.includes(`anonymous`))return[m];if(t.includes(`authenticated`))return[h]}async function fe(e){let{chunks:t,headings:r}=ne(e.html),{metadata:a}=e.route,o=i(a.seo)?a.seo:{},s=i(a.search)?a.search:{},c=[o.description,a.description].find(e=>typeof e==`string`&&e.trim()!==``),u=D(a,typeof s.title==`string`?s.title.trim():void 0)??r.find(e=>e!==null)?.heading??null,d=n();return Promise.all(t.map(async(t,n)=>({entityKey:X(e.key),chunkIndex:n,routeSlug:e.route.slug,text:t,heading:r[n]?.heading??null,anchor:r[n]?.anchor??null,title:u,description:c??null,rbacTeams:P(e.route.access),hash:await l(new TextEncoder().encode(t)),sourceHash:e.fingerprint??``,pluginVersion:d})))}async function Q(e){try{let t=await $(e,e.slug);if(t.page.status===302&&t.redirectTo!==void 0&&(t=await $(e,t.redirectTo)),t.page.status!==200)return null;let n=await e.ssr.render(t.page,t.resolvedLoaderData,t.url,W),r=await new Response(n.stream).text();return n.renderError?{error:n.renderError}:{html:r}}catch(e){return{error:e instanceof Error?e:Error(String(e))}}}async function $(e,t){let n=`${W}${t}`,r={headers:{},ip:null,method:`GET`,teams:e.teams,url:n,userAgent:null};return{...await O({config:e.config,contentDir:e.context.contentDir,context:e.context,database:e.database,logger:e.logger,request:r,url:n}),url:n}}export{q as validateReactPages};
|