@redocly/revel 0.141.0-next.6 → 0.141.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/CHANGELOG.md +30 -0
- package/dist/cli/develop.js +1 -1
- package/dist/cli/utils/react-pages-check.d.ts +11 -0
- package/dist/cli/utils/react-pages-check.js +1 -0
- package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
- package/dist/client/runtime/errors/page-async-component-error.d.ts +4 -0
- package/dist/client/runtime/errors/page-async-component-error.js +1 -0
- package/dist/client/runtime/loader.js +1 -1
- package/dist/server/plugins/api-docs/options.js +1 -1
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/pages/validators/validate-react-pages.d.ts +8 -1
- package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @redocly/revel
|
|
2
2
|
|
|
3
|
+
## 0.141.0-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b99335804a3: Fixed an issue where the copy button of a code block and of a code walkthrough file copied the `[!code highlight]`, `[!code warning]` and other highlight notation comments along with the code.
|
|
8
|
+
- 5ab244099d2: Fixed an issue where the page could not be scrolled after the browser window was resized from a mobile or tablet width to a desktop width while the navigation menu was open.
|
|
9
|
+
- e8d0e1e092b: Fixed an issue where a React page that exports an async component displayed a blank page in preview.
|
|
10
|
+
- e8d0e1e092b: Added React page runtime errors to the preview status bar and terminal summary.
|
|
11
|
+
- Updated dependencies [2be77ebbf13]
|
|
12
|
+
- Updated dependencies [73daff36df4]
|
|
13
|
+
- Updated dependencies [3b0144f79a9]
|
|
14
|
+
- Updated dependencies [2be77ebbf13]
|
|
15
|
+
- Updated dependencies [5ebf95c0652]
|
|
16
|
+
- Updated dependencies [3b0144f79a9]
|
|
17
|
+
- Updated dependencies [930a9104e7e]
|
|
18
|
+
- Updated dependencies [784206189dd]
|
|
19
|
+
- Updated dependencies [2be77ebbf13]
|
|
20
|
+
- Updated dependencies [d21d3af6b99]
|
|
21
|
+
- Updated dependencies [3e29b8a269e]
|
|
22
|
+
- Updated dependencies [b9f395893a4]
|
|
23
|
+
- Updated dependencies [b99335804a3]
|
|
24
|
+
- Updated dependencies [3bfc48009ff]
|
|
25
|
+
- Updated dependencies [5ab244099d2]
|
|
26
|
+
- Updated dependencies [0eb19a57733]
|
|
27
|
+
- Updated dependencies [d58e22e0695]
|
|
28
|
+
- Updated dependencies [ee2291668f4]
|
|
29
|
+
- Updated dependencies [ee2291668f4]
|
|
30
|
+
- @redocly/api-docs@0.6.0-next.7
|
|
31
|
+
- @redocly/theme@0.73.0-next.3
|
|
32
|
+
|
|
3
33
|
## 0.141.0-next.6
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/cli/develop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as t}from"../server/tools/notifiers/logger.js";import{reporter as c}from"../server/tools/notifiers/reporter.js";import{green as
|
|
1
|
+
import{logger as t}from"../server/tools/notifiers/logger.js";import{reporter as c}from"../server/tools/notifiers/reporter.js";import{green as w}from"../server/tools/notifiers/helpers/colors.js";import{envConfig as m}from"../server/config/env-config.js";import{resolveCache as R}from"../server/esbuild/plugins/themes-resolver.js";import{getBilledPagesCount as p}from"../server/utils/index.js";import{createClientCompiler as C,createServerCompiler as S}from"../server/esbuild/esbuild.js";import{initPlugins as h,runPlugins as f,writeClientEntries as E}from"../server/plugins/lifecycle.js";import{startDevServer as P}from"../server/web-server/dev-server.js";import{validateAllMarkdowns as g}from"../server/plugins/markdown/compiler.js";import{reportAllErrors as v}from"../server/utils/report-all-errors.js";import{validateAllowedPackages as y}from"../server/utils/validate-allowed-packages.js";import{copyMigrationsFolder as L}from"../server/providers/database/copy-migrations.js";import{listenStdin as T}from"./utils/listen-stdin.js";import{createReactPagesCheck as k}from"./utils/react-pages-check.js";const D=20;async function Y(i,e){t.info("Starting project preview mode."),e.devLogin=i["dev-login"]!==!1,E(e),t.startTiming("initial-js"),await A(e),t.infoTime("initial-js","JavaScript compiled");const{pluginInstances:o,lifecycleContext:n}=await h({contentDir:e.contentDir,outdir:e.outdir,serverOutDir:void 0,devLogin:e.devLogin,setGlobalConfig:e.setGlobalConfig});e.lifecycleContext=n,L(e),await f(o,e,n,{failFast:!0});const d=k(e,n),u=async a=>{const s=performance.now();c.clearErrors(),await y(),d.invalidate(),await f(o,e,n),m.REDOCLY_EXP_DISABLE_MD_VALIDATION?t.info("Skipping markdown validation step"):await g(e,n),a.some(({event:l})=>l==="code-updated")&&d.run(),O().then(async()=>{await v(n);const l=p(e.getAllRoutes()),b=c.summary(` \u{1F440} Last change processed in ${w(Math.round(performance.now()-s)+"ms")}`,l);e.runListeners("errors-updated",void 0,b),e.runListeners("pages-updated",void 0,l),e.runListeners("routes-updated")})};m.REDOCLY_EXP_DISABLE_MD_VALIDATION?t.info("Skipping markdown validation step"):await g(e,n),await v(n);const r=p(e.getAllRoutes());c.summary(" \u{1F440} Watching for changes...",r),e.runListeners("pages-updated",void 0,r),n.fs.watch(async a=>{R.clear(),await u(a)}),t.verbose("Starting development server."),await P(e,n,{port:Number(i.port||4e3),maxPortRetries:m.isReunite?0:D}),d.run(),T()}async function A(i){let e=!0,o=!0;const n=async r=>{r==="client"?e=!0:o=!0,i.runListeners("build-started");const a=e!=o;a&&i.startEsbuildRun(),i.buildRevision>0&&await i.waitForPluginsRun(),r!=="client"&&i.noteRequestHandlersEntryBuildStart(),a&&t.startTiming("rebuild")},d=async r=>{r==="client"?e=!1:(o=!1,i.markRequestHandlersEntryUpdated()),!(e||o)&&(i.finishEsbuildRun(),i.buildRevision++,t.infoTime("rebuild","JavaScript re-compiled"),await i.reloadMarkdocOptions(),i.markUserCodeReady(),i.runListeners("build-updated"),i.lifecycleContext&&i.buildRevision>1&&i.lifecycleContext.fs.emitCodeUpdated())},u=[new Promise((r,a)=>{const s={label:"client",buildStart(){t.verbose("Start compiling client code."),t.startTiming(this.label)},buildEnd(){t.verboseTime(this.label,"Client compiled"),r(!0)},rebuildStart:()=>n("client"),rebuildEnd:()=>d("client")};C(i,i.outdir,"development",s).then(l=>l.watch()).catch(a)}),new Promise((r,a)=>{const s={label:"server",buildStart(){t.verbose("Start compiling server code."),t.startTiming(this.label)},buildEnd(){t.verboseTime(this.label,"Server compiled"),r(!0)},rebuildStart:()=>n("server"),rebuildEnd:()=>d("server")};S(i,i.serverOutDir,"development",s).then(l=>l.watch()).catch(a)})];await Promise.all(u),await i.reloadMarkdocOptions()}function O(){return new Promise(i=>{setTimeout(i,0)})}export{Y as develop};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Store } from '../../server/store.js';
|
|
2
|
+
import type { LifecycleContext } from '../../server/types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The preview check of React pages. It runs in the background, so the dev server and file
|
|
5
|
+
* changes do not wait for it, and it publishes the errors when its result changes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createReactPagesCheck(store: Store, lifecycleContext: LifecycleContext): {
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
invalidate(): void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=react-pages-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{reporter as a}from"../../server/tools/notifiers/reporter.js";import{green as f}from"../../server/tools/notifiers/helpers/colors.js";import{getBilledPagesCount as m}from"../../server/utils/index.js";import{validateReactPages as l}from"../../server/plugins/pages/validators/validate-react-pages.js";import{renderPage as u}from"../../server/ssr/index.js";function R(r,n){let t=!1,e=!1;return{async run(){if(t){e=!0;return}t=!0;const o=performance.now(),i=JSON.stringify(a.getPageRenderProblems());do e=!1,await r.waitForPluginsRun(),await l(r,n,u,()=>e);while(e);if(t=!1,JSON.stringify(a.getPageRenderProblems())===i)return;const s=a.summary(` \u{1F440} React pages checked in ${f(Math.round(performance.now()-o)+"ms")}`,m(r.getAllRoutes()));r.runListeners("errors-updated",void 0,s)},invalidate(){e=t}}}export{R as createReactPagesCheck};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLocation as A}from"react-router";import{useEffect as w,useMemo as c,useRef as _,useState as
|
|
1
|
+
import{useLocation as A}from"react-router";import{useEffect as w,useMemo as c,useRef as _,useState as D}from"react";import{useApiDocsActiveSectionId as k}from"@redocly/theme/core/hooks";import{getMenuItemType as C}from"@redocly/theme/core/utils";import{MenuItemType as v}from"@redocly/theme/core/constants";import{CATALOG_BASE_SLUG as T,CATALOG_SLUGS as h}from"../../../constants/catalog-entities";import{usePageSharedData as y,useSidebarItemsData as G,useSidebarConnectedCatalogConfig as E,useSidebarConnectedCatalogEntity as O}from"../../providers/page-data/hooks";import{mapItemsPropsToState as b}from"./utils";import{injectCatalogItems as K}from"../../utils/catalog/inject-catalog-items";import{filterOutVersionedItems as R}from"../../utils/filter-out-versioned-items";const B="catalog.backToAllLabel",M=`${T}/${h.ALL}`;function U(i){const e=G();return c(()=>R(e,i),[e,i])}function J(i){const e=A(),t=k(e),a=O(),g=E(),s=U(i),u=a?K(s,a.key,g?.slug,e.search):s,m=_(null),r=c(()=>b(u,e,t),[t,e,u]),l=y("current-catalog-info"),p=c(()=>S(r),[u]),[n,d]=D(p),o=n.length>0?n[n.length-1]:void 0,I=c(()=>o&&b([...o.item.link?[{...o.item,items:[],menuStyle:void 0,separatorLine:!1}]:[],...o.item.items],e,t),[o,e,t]);w(()=>{if(!m.current||m.current!==t){const f=S(r);d(f),m.current=t}},[s,e,t]);const L=o?{slug:o.previousLink,event:"sidebar_drilldown_back_button.clicked"}:a?{label:"Back to Catalog",labelTranslationKey:B,slug:M,event:"back_to_catalog_button.clicked"}:l?{label:l.catalog.label,labelTranslationKey:l.catalog.labelTranslationKey,slug:l.catalog.link,event:"back_to_catalog_button.clicked"}:void 0;return{currentItems:I||r,allSidebarItems:r,popDrilldownState:()=>{n.length>0&&d(n.slice(0,n.length-1))},pushDrilldownState:f=>{d([...n,f])},backLink:L,versionLabel:a?.version??null}}function S(i,e=[]){for(const t of i){if(!t.active&&!t.hasActiveSubItem)continue;if(C(t)===v.DrillDown&&e.push({item:t}),t.active)return e;if(t.hasActiveSubItem)return S(t.items,e)}return e}export{U as useRawSidebarItems,J as useSidebarItems};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class r extends Error{constructor(o){super(`${o} exports an async component. React pages do not support async components: export a synchronous component.`),this.name="PageAsyncComponentError"}}export{r as PageAsyncComponentError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as y from"react";import{withPathPrefix as L}from"@redocly/theme/core/utils";import{appendSearchParams as N}from"../utils";import{mapObject as x}from"../../utils/object/map-object.js";import{mapObjectAsync as $}from"../../utils/object/map-object-async.js";import{isFunction as z}from"../../utils/guards/is-function.js";import{isBrowser as I}from"../../utils/env/is-browser.js";import{GLOBAL_DATA_URL as G}from"../../constants/common.js";import{getClientPageDataUrl as V}from"../../utils/url/get-client-page-data-url.js";import{getSharedDataFetchUrl as F}from"../../utils/url/get-shared-data-fetch-url.js";import{normalizeRouteSlug as c}from"../../utils/path/normalize-route-slug.js";import{templates as R}from"./generated/templates.js";import{AsyncCache as E}from"./cache.js";import{fetch as D}from"./fetch.js";import{updateTranslations as B}from"../app/l10n";import{PageMissingDefaultExportError as b}from"./errors/page-missing-default-export-error.js";import{PageAsyncComponentError as K}from"./errors/page-async-component-error.js";import{ErrorDetails as q}from"../app/Error/ErrorDetails";const l=new E,m=new E;let g=null,d,W;const u=new Set;async function H(){const o=await(await D(L(G))).json();return d=o,o}async function v(o){const t=F(o,process.env.NODE_ENV==="development");return await(await D(t)).json()}async function J(o){return m.has(o)||m.set(o,v(o)),m.get(o)}function ht(){const[,o]=y.useReducer(t=>t+1,0);y.useEffect(()=>{process.env.NODE_ENV!=="production"&&(window.__redoclyRefresh=o)},[o])}function C(o,t){const e=t?new URLSearchParams(t).get("revision"):null,a=t?new URLSearchParams(t).get("version"):null;return e||a?`${o}?${e?`revision=${encodeURIComponent(e)}`:""}${a?`&version=${encodeURIComponent(a)}`:""}`.trim():o}class p{static markdocComponents={};static async updateTemplate(t,e,a){const n=c(t);R[a]=()=>e;const r=c(window.location.pathname);n===r&&(await this.load(t,!0),window.__redoclyRefresh())}static async update(t){const e=c(t),a=c(window.location.pathname);if(e!==a){l.delete(e);return}await this.load(t,!0),window.__redoclyRefresh()}static async updateSharedData(t){await m.set(t,v(t)),window.__redoclyRefresh()}static addGlobalDataListener(t){u.add(t)}static removeGlobalDataListener(t){u.delete(t)}static updateGlobalData(t){u.forEach(e=>e(t)),d=t,B(d.l10n)}static async tryLoad(t,e,a){try{return await this.load(t,e,a)}catch{return null}}static async loadDynamicMarkdocComponents(t){const e=this.markdocComponents?.[t];e&&z(e)&&Object.assign(this.markdocComponents,await e())}static async load(t,e,a){const n=c(t),r=C(n,a);if(!d&&!g&&(g=H()),!e&&l.has(r)){const f=await l.get(r);if(f)return f}const[i]=await Promise.all([l.set(r,s(a)),g]);return i;async function s(f){const _=V(n),T=N(_,f),O=await D(T),{templateId:P,sharedDataIds:w,props:S,userData:A,versions:j,redirectTo:k,isPublic:M}=await O.json(),[U]=await Promise.all([(async()=>p.loadTemplate(P))(),Promise.all((S.dynamicMarkdocComponents||[]).map(h=>p.loadDynamicMarkdocComponents(h))),w?$(w,h=>J(h)):Promise.resolve({})]);return{templateId:P,slug:n,sharedDataIds:w,redirectTo:k,props:S,Template:U,userData:A,versions:j,isPublic:M}}}static loadSync(t){const e=c(t),a=C(e,typeof window<"u"?window.location.search:void 0),n=l.tryGetSync(a);if(!n)return;const r=x(n.sharedDataIds,i=>m.getSync(i,"Data dependency not cached ahead of time: "+i));return{...n,sharedData:r}}static async prepare(t,e,a,n){const r=t.templateId;if(await Promise.all((t.props.dynamicMarkdocComponents||[]).map(s=>this.loadDynamicMarkdocComponents(s))),e)for(const s of Object.keys(e))m.setSync(s,e[s]);const i=await p.loadTemplate(r);if(i){const s=c(t.slug);l.setSync(s,{templateId:r,slug:s,props:t.props,sharedDataIds:t.sharedDataIds||{},Template:i,userData:t.userInfo,versions:t.versions,isPublic:t.isPublic})}d=a,W=n}static async loadTemplate(t){try{const e=await R[t](),a=/page\.tsx?$/.test(t);if(a&&!e.default)throw new b(t);const n=e.default,r=Y(n)?n:n?.default;return a&&X(r)?Q(t):r}catch(e){if(!(process.env.NODE_ENV==="development")||!I())throw e;return e instanceof b?()=>(window.location.reload(),null):(window.location.reload(),null)}}static clear(){u.clear(),m.clear(),l.clear()}}(typeof window<"u"?window:global).__LOADER=p;function Q(o){const t=new K(o),{name:e,message:a}=t;return function(){const r=!!globalThis.SSR_OMIT_SUSPENSE;if(process.env.NODE_ENV!=="development"||r)throw t;return y.createElement(q,{error:{name:e,message:a}})}}function X(o){return Object.prototype.toString.call(o)==="[object AsyncFunction]"}function Y(o){return typeof o=="function"||typeof o=="object"&&o!==null&&"$$typeof"in o}export{p as Loader,J as getSharedData,d as globalData,W as initLocale,ht as useRefresh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as L from"node:path";import{
|
|
1
|
+
import*as L from"node:path";import{descriptionOptions as x,markdocParser as A}from"@redocly/api-docs";import{combineUrls as i}from"@redocly/theme/core/openapi";import{withPathPrefix as E}from"@redocly/theme/core/utils";import{GRAPHQL_SPEC_SLUG as D}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as f,PUBLIC_STATIC_FOLDER as F}from"../../constants/common.js";import{envConfig as S}from"../../config/env-config.js";import{deepMerge as w}from"../../../utils/object/deep-merge.js";import{normalizeFeedbackOptions as R}from"./utils/normalize-feedback-options.js";import{replaceFileExtension as p}from"./utils/replace-file-extension.js";import{relativePathToBaseSlug as B}from"./utils/relative-path-to-base-slug.js";const I={tags:{},nodes:{},components:{}};function U(o,r){if(!(o?.off!==!0))return o;const e=B(r);return{url:E(`/_mock${e}`),position:"first",description:"Mock server",...o}}function M(o,r){return(r==="graphql"?[i(D,`${p(o,L.posix.extname(o))}?download`)]:[i(f,`${p(o,".json")}?download`),i(f,`${p(o,".yaml")}?download`)]).map(e=>({url:E(e)}))}function j(o,r,l){const{rootConfig:e,config:s,apiConfig:c,mergedConfig:t,relativePath:a}=l,n=w(e?.[o]||{},s[o]||{},c[o]||c.theme?.[o]||{}),_=r["x-feedback"]||n.feedback||s.feedback,b=!!t[o]?.excludeFromSearch||!!t.theme?.[o]?.excludeFromSearch||!!e?.[o]?.excludeFromSearch||!!e?.theme?.[o]?.excludeFromSearch,C=t.rbac||c.rbac,g=R(_),h=s.metadata,u=M(a,o),O={...g&&{feedback:g},mockServer:U(t?.mockServer||e?.mockServer,a),disableRouter:!0,downloadUrls:n.downloadUrls||u,replayDefinitionUrl:o!=="graphql"&&a.startsWith(`${F}/`)?void 0:u[0]?.url,excludeFromSearch:b,rbac:C,markdownParser:A,replayFeatures:{graphql:S.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED??!1,asyncapi:S.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED??!1}},k=x(o,r,h);let m;if(o==="graphql"){const d=n;m={title:d.info?.title,...h,...d.metadata??{}}}else m={description:r.info?.description,...k.metadata};o==="openapi"&&n.showSchemaCatalogLinks&&(r["x-schema-catalog-link"]=i(f,a));const P=n.markdocOptions??I;return{...n,...O,...k,markdocOptions:P,metadata:m}}export{M as buildDownloadUrls,j as createOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import A from"@redocly/markdoc";import{htmlTags as Y}from"@redocly/markdoc/html";import*as P from"path";import{convertGithubAlertToAdmonition as H}from"@redocly/theme/markdoc/tags/admonition";import{logger as M}from"../../tools/notifiers/logger.js";import{reporter as F}from"../../tools/notifiers/reporter.js";import{sha1 as B}from"../../utils/crypto/sha1.js";import{formatMarkdocError as $}from"./errors.js";import{extractFirstHeading as V,SKIP as G,visit as j}from"./markdoc/plugins/utils.js";import{isPromptNode as K}from"../../../markdoc/helpers/guards/is-prompt-node.js";import{attributeResolvers as L}from"./attribute-resolvers/index.js";import{MdResolveError as q}from"./attribute-resolvers/md-resolve-error.js";import{normalizeHtmlHeadings as C}from"./html/normalize-html-headings.js";import{resolveRawPartials as J}from"./markdoc/resolve-raw-partials.js";import{exampleContentTrees as Q,reparseExampleFences as X}from"./markdoc/reparse-example-fences.js";import{MARKDOC_PARTIALS_DEPS_KEY as Z}from"../../constants/common.js";import{getLinkOriginalAttrName as tt}from"./attribute-resolvers/utils.js";import{createSourceLinesReader as rt}from"./create-source-lines-reader.js";const et="EMPTY";async function at(r,e,o){const{actions:n}=o,{relativePath:s,resolveErrors:k}=r,h={...o,readSourceLines:rt(r.rawContent)},E=new Set,d=new Set,y=new Set,c=new Set,g={},f=new Set,D={},_={};function S(t,a){const u=a||et;t[u]=(t[u]||0)+1}const T=[];r.resolveErrors.length=0;const I=Q(r.ast),x=t=>{H(t);const a=u();T.push(a.then(p=>{p?.sharedDataIds&&p.sharedDataIds.forEach(m=>E.add(m))}).catch(W(t)));async function u(){const p=[];switch(t.type){case"fence":S(D,t.attributes.language);break;case"link":case"image":await L.nativeMdLink(t,t.type==="link"?"href":"src",s,h);break;case"tag":{if(!t.tag)break;const m=e?.tags?.[t.tag];if(!m){const i=e?.planDeniedTags?.[t.tag];i&&(t.addError({level:"error",id:"invalid-tag",message:i}),t.tag="",t.type="error",t.attributes={});break}const w=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:c).add(w),g[w]=(g[w]||0)+1,w==="code-snippet"&&S(D,t.attributes.language),m.attributes?.__idx&&(t.attributes.__idx=g[t.tag]),m.dynamicComponentLib&&d.add(m.dynamicComponentLib),!m.attributes)break;if(w==="partial"&&t.attributes?.file){const i=tt("file"),l=t[i]||t.attributes.file,b=l.startsWith("/")?l.slice(1):P.posix.normalize(P.posix.join(P.posix.dirname(s),l));y.add(b);const v=(n.getGlobalConfig(Z)||{})[b];if(v?.dynamicComponents)for(const R of v.dynamicComponents)d.add(R);if(v?.sharedDataDeps)for(const R of v.sharedDataDeps)E.add(R)}for(const[i,l]of Object.entries(m.attributes)){const b=l.type;if(b&&(b.resolver||l.resolver)){const N=L[b.resolver||l.resolver],v=await N?.(t,i,s,h);v?.sharedDataId&&p.push(v.sharedDataId)}}if(w==="code-walkthrough")for(const i of t.attributes.resolvedFilesets||[])for(const l of i.files||[])S(_,l.language);const O=t.attributes?.attrs;if(O&&t.tag==="html")for(const i of Object.keys(O))i==="src"||i==="srcSet"?await L.htmlSourceAttribute(t,i,s,h):i==="href"&&await L.htmlHref(t,i,s,h);break}}return{sharedDataIds:p}}};function W(t){return async a=>{if(!(a instanceof q)){await F.panicOnBuild(a.message);return}k.push($({type:"resolve_link",meta:{...a.meta,link:a.meta.link??a.meta.rawLink},lines:t.location?[t.location.start.line,t.location.end.line]:[],location:t.location,error:{id:"",level:"error",message:a.message,location:t.location}},r.relativePath,r.rawContent))}}j(r.ast,t=>(x(t),K(t)?G:void 0));for(const t of I)j(t,a=>(H(a),a.type==="tag"&&x(a),K(a)?G:void 0));if(await Promise.all(T),r.sharedDataDeps=E,r.dynamicMarkdocComponents=d,r.validatedAtRevision<n.buildRevision){r.markdocErrors=[];for(const t of[r.ast,...I])for(const a of A.validate(t,e)){if(a.error.level!=="error"&&a.error.level!=="critical"){const u=a.location?.start.line,p=u===void 0?"":`:${u+1}`;M.warn(`${a.error.message} at ./${s}${p}`);continue}r.markdocErrors.push($(a,s,r.rawContent))}r.validatedAtRevision=n.buildRevision}return{sharedDataDeps:r.sharedDataDeps,dynamicMarkdocComponents:Array.from(r.dynamicMarkdocComponents?.values()??[]),partials:Array.from(y),tagList:Array.from(c),htmlTagsList:Array.from(f),tagOccurrence:g,codeSnippetLanguages:D,codeWalkthroughLanguages:_}}const U="unclosed-html",ot={html:Y({errorTag:U}),allowIndentation:!0,allowComments:!0};function z(r,e){const o=A.parse(r,{...ot,...e});return it(o),C(o),o}function it(r){for(const e of r.walk())e.type!=="tag"||e.tag!==U||(e.type="error",e.errors.push({id:"parse-error",level:"critical",message:String(e.attributes.message),location:e.location}))}function st(r,e){const o=z(e,{file:r,slots:!0});return X(o,s=>z(s,{file:r})),{ast:o,rawContent:e,resolveErrors:[],markdocErrors:[],relativePath:r,sharedDataDeps:void 0,validatedAtRevision:-1}}async function St(r,e){const{data:o}=await e.cache.load(r,"markdown-ast");return V(o.ast)}async function Rt(r,e){F.clearMarkdocProblems();const o=r.getAllRoutes();let n=0;const s=M.isInteractive();for(const k of o)await r.resolveRouteStaticData(k,e,!0),n++,s&&n%100===0&&M.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${n}/${o.length})`)}async function Pt(r,e,o,n){const s=r.content?B(r.content):"";return await o.context.cache.load(n||r.relativePath,{loader:h,name:"markdown-inline-parser"},[s,String(o.actions.buildRevision)]);async function h(E,d,y){let c;if(r.content){const f=await d.getConfig(),D=await J(r.content,r.relativePath,f.markdown?.partialsFolders,d);c=st(r.relativePath,D)}else c=(await d.cache.load(r.relativePath,"markdown-ast")).data;let g={};if(o.actions.buildRevision!==0&&(g=await at(c,e,o)),!r.isVirtual){for(const f of c.markdocErrors)y(f);for(const f of c.resolveErrors)y(f)}return{ast:c.ast,info:g}}}export{St as extractMdFirstHeading,st as getAst,Pt as parseAndResolveMarkdoc,at as resolveAndValidateMarkdoc,Rt as validateAllMarkdowns};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Store } from '../../../store.js';
|
|
2
2
|
import type { LifecycleContext } from '../../../types';
|
|
3
|
-
|
|
3
|
+
import type { renderPage as renderPageFn } from '../../../ssr/index.js';
|
|
4
|
+
type RenderPage = typeof renderPageFn;
|
|
5
|
+
/**
|
|
6
|
+
* `renderPage` defaults to the one from the built server bundle, which preview does not have.
|
|
7
|
+
* When `isOutdated` returns true the store has changed under the run: it stops and reports nothing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateReactPages(store: Store, lifecycleContext: LifecycleContext, renderPage?: RenderPage, isOutdated?: () => boolean): Promise<void>;
|
|
10
|
+
export {};
|
|
4
11
|
//# sourceMappingURL=validate-react-pages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pathToFileURL as
|
|
1
|
+
import{pathToFileURL as d}from"node:url";import{slash as P}from"../../../../utils/path/slash.js";import{logger as s}from"../../../tools/notifiers/logger.js";import{reporter as n}from"../../../tools/notifiers/reporter.js";import{getServerProps as h}from"../../../ssr/server-side-props/get-server-props.js";import{isVirtualFile as R}from"../../../fs/utils/isVirtualFile.js";import{telemetry as E}from"../../../../cli/telemetry/index.js";const w=["PageMissingDefaultExportError","PageAsyncComponentError"];async function A(r,i,o,l){try{const a=r.getAllRoutes().filter(e=>e.fsPath.match(/\.page\.tsx?$/)&&!R(e.fsPath,i.fs));if(!a.length){n.clearPageRenderProblems();return}const m=s.startTiming();s.info("Validating react pages");const u=o??await b(r.serverOutDir),c=[];for(const e of a){const f=await r.resolveRouteStaticData(e,i),p=await h(e,null,f,r);let t;try{t=(await u(e,p,null,r,E,!0)).error}catch(g){t=g}if(l?.())return;t&&c.push({message:w.includes(t.name)?t.message:`Runtime error: ${t.message}`,sourceFileRelativePath:e.fsPath})}n.clearPageRenderProblems(),c.forEach(e=>n.reportPageRenderError(e)),s.infoTime(m,`Validated ${a.length} React pages`)}catch(a){if(l?.())return;await n.panicOnBuild(`Failed to validate react pages: ${a.message}`)}}async function b(r){const o=await import(d(`${P(r)}/index.mjs`)+"?only-exports=true");if(!o.renderPage)throw new Error("renderPage function not found in bundle");return o.renderPage}export{A as validateReactPages};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/revel",
|
|
3
|
-
"version": "0.141.0-next.
|
|
3
|
+
"version": "0.141.0-next.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"@opentelemetry/sdk-trace-web": "2.8.0",
|
|
34
34
|
"@opentelemetry/semantic-conventions": "1.40.0",
|
|
35
35
|
"@redocly/ajv": "8.18.0",
|
|
36
|
-
"@redocly/api-docs": "0.6.0-next.
|
|
36
|
+
"@redocly/api-docs": "0.6.0-next.7",
|
|
37
37
|
"@redocly/config": "0.74.0",
|
|
38
38
|
"@redocly/markdoc": "0.7.0-beta.2",
|
|
39
39
|
"@redocly/openapi-core": "2.77.0",
|
|
40
40
|
"@redocly/portal-legacy-ui": "0.19.0",
|
|
41
41
|
"@redocly/portal-plugin-mock-server": "0.26.0-next.1",
|
|
42
42
|
"@redocly/realm-asyncapi-sdk": "0.18.0-next.0",
|
|
43
|
-
"@redocly/theme": "0.73.0-next.
|
|
43
|
+
"@redocly/theme": "0.73.0-next.3",
|
|
44
44
|
"@shikijs/transformers": "3.21.0",
|
|
45
45
|
"@tanstack/react-query": "5.62.3",
|
|
46
46
|
"@tanstack/react-table": "8.21.3",
|