@revealui/core 0.0.1-pre.0
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/LICENSE +202 -0
- package/LICENSE_SUMMARY.md +55 -0
- package/README.md +201 -0
- package/dist/core/__internal/index.ts +63 -0
- package/dist/core/__tests__/assertNoInfiniteHttpRedirect.spec.ts +76 -0
- package/dist/core/__tests__/deduceRouteStringFromFilesystemPath.spec.ts +88 -0
- package/dist/core/__tests__/freezePartial.spec.ts +40 -0
- package/dist/core/__tests__/getValuePrintable.spec.ts +15 -0
- package/dist/core/__tests__/injectHtmlTags.spec.ts +101 -0
- package/dist/core/__tests__/isHtml.spec.ts +23 -0
- package/dist/core/__tests__/isNpmPackage.spec.ts +93 -0
- package/dist/core/__tests__/normalizeHeaders.spec.ts +142 -0
- package/dist/core/__tests__/parseUrl-extras.spec.ts +60 -0
- package/dist/core/__tests__/parseUrl.spec.ts +1339 -0
- package/dist/core/__tests__/resolvePrecedence/resolvePrecedence_overall.spec.ts +106 -0
- package/dist/core/__tests__/resolvePrecedence/resolvePrecedence_route-strings.spec.ts +99 -0
- package/dist/core/__tests__/resolveRedirects.spec.ts +132 -0
- package/dist/core/__tests__/resolveRouteString.spec.ts +211 -0
- package/dist/core/__tests__/resolveUrlPathname.spec.ts +22 -0
- package/dist/core/__tests__/trimWithAnsi.spec.ts +40 -0
- package/dist/core/api/ssr.ts +63 -0
- package/dist/core/assets/extractAssetsQuery.ts +29 -0
- package/dist/core/assets/index.ts +173 -0
- package/dist/core/assets/inferHtmlTags.ts +61 -0
- package/dist/core/assets/injectHtmlTags.ts +236 -0
- package/dist/core/assets/mergeScriptTags.ts +77 -0
- package/dist/core/assets/sanitizeJson.ts +8 -0
- package/dist/core/cli/bin.ts +161 -0
- package/dist/core/cli/commands/add.ts +158 -0
- package/dist/core/cli/commands/check.ts +47 -0
- package/dist/core/cli/commands/doctor/checks/build.ts +83 -0
- package/dist/core/cli/commands/doctor/checks/config.ts +130 -0
- package/dist/core/cli/commands/doctor/checks/dependencies.ts +144 -0
- package/dist/core/cli/commands/doctor/checks/practices.ts +156 -0
- package/dist/core/cli/commands/doctor/checks/structure.ts +127 -0
- package/dist/core/cli/commands/doctor/fixes/index.ts +136 -0
- package/dist/core/cli/commands/doctor/index.ts +47 -0
- package/dist/core/cli/commands/doctor/print.ts +44 -0
- package/dist/core/cli/commands/doctor/types.ts +16 -0
- package/dist/core/cli/commands/fix.ts +161 -0
- package/dist/core/cli/commands/init.ts +145 -0
- package/dist/core/cli/commands/upgrade.ts +115 -0
- package/dist/core/cli/onLoad.ts +7 -0
- package/dist/core/cli/utils.ts +6 -0
- package/dist/core/components/Config/Config-client.ts +14 -0
- package/dist/core/components/Config/Config-server.ts +16 -0
- package/dist/core/components/Head/Head-client.ts +4 -0
- package/dist/core/components/Head/Head-server.ts +16 -0
- package/dist/core/components/Loading.tsx +23 -0
- package/dist/core/config/findPageConfig.ts +14 -0
- package/dist/core/config/loadConfigValues.ts +28 -0
- package/dist/core/constants/UnifiedConstants.ts +348 -0
- package/dist/core/dom/applyHeadSettings.tsx +13 -0
- package/dist/core/dom/onPageVisibilityChange.ts +17 -0
- package/dist/core/dom/updateDocumentHead.ts +15 -0
- package/dist/core/errors/ErrorHandler.ts +480 -0
- package/dist/core/files/file-system/filesystemPath.ts +27 -0
- package/dist/core/files/file-system/findFile.ts +35 -0
- package/dist/core/files/file-system/findPackageJson.ts +19 -0
- package/dist/core/files/file-system/findPageFiles.ts +40 -0
- package/dist/core/files/file-system/pathShim.ts +16 -0
- package/dist/core/files/file-system/prependEntriesDir.ts +13 -0
- package/dist/core/files/file-system/removeFileExtention.ts +3 -0
- package/dist/core/files/file-system/requireResolve.ts +59 -0
- package/dist/core/files/file-system/scanCodebase.ts +64 -0
- package/dist/core/files/virtual-files/index.ts +31 -0
- package/dist/core/files/virtual-files/virtualFileImportUserCode.ts +34 -0
- package/dist/core/files/virtual-files/virtualFilePageConfigValuesAll.ts +49 -0
- package/dist/core/gaurds/assertions/assert/base.ts +6 -0
- package/dist/core/gaurds/assertions/assert/index.ts +2 -0
- package/dist/core/gaurds/assertions/assert/log.ts +42 -0
- package/dist/core/gaurds/assertions/assertArguments.ts +83 -0
- package/dist/core/gaurds/assertions/assertCast.ts +9 -0
- package/dist/core/gaurds/assertions/assertCommonJS/base.ts +9 -0
- package/dist/core/gaurds/assertions/assertCommonJS/common.ts +30 -0
- package/dist/core/gaurds/assertions/assertCommonJS/index.ts +2 -0
- package/dist/core/gaurds/assertions/assertExtensions/base.ts +187 -0
- package/dist/core/gaurds/assertions/assertExtensions/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertHookReturnedObject.ts +30 -0
- package/dist/core/gaurds/assertions/assertInfo/base.ts +14 -0
- package/dist/core/gaurds/assertions/assertInfo/index.ts +2 -0
- package/dist/core/gaurds/assertions/assertInfo/log.ts +28 -0
- package/dist/core/gaurds/assertions/assertIs404.ts +12 -0
- package/dist/core/gaurds/assertions/assertIsBrowser/base.ts +8 -0
- package/dist/core/gaurds/assertions/assertIsBrowser/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertIsNotBrowser/base.ts +9 -0
- package/dist/core/gaurds/assertions/assertIsNotBrowser/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertIsNotProductionRuntime/base.ts +71 -0
- package/dist/core/gaurds/assertions/assertIsNotProductionRuntime/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertKeys/base.ts +31 -0
- package/dist/core/gaurds/assertions/assertKeys/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertNoInfiniteHttpRedirect.ts +55 -0
- package/dist/core/gaurds/assertions/assertNodeEnv/base.ts +120 -0
- package/dist/core/gaurds/assertions/assertNodeEnv/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertNodeVersion/base.ts +11 -0
- package/dist/core/gaurds/assertions/assertNodeVersion/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertOnBeforeRenderHookReturn.ts +37 -0
- package/dist/core/gaurds/assertions/assertPageContextProvidedByUser.ts +60 -0
- package/dist/core/gaurds/assertions/assertPluginManifest.ts +41 -0
- package/dist/core/gaurds/assertions/assertPlusFileExport.ts +66 -0
- package/dist/core/gaurds/assertions/assertRoutingType/base.ts +41 -0
- package/dist/core/gaurds/assertions/assertRoutingType/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertRuntimeManifest.ts +34 -0
- package/dist/core/gaurds/assertions/assertSingleInstance/index.ts +142 -0
- package/dist/core/gaurds/assertions/assertSingleInstance/onAssertModuleLoad.ts +0 -0
- package/dist/core/gaurds/assertions/assertSingleInstance/onClientEntryClientRouting.ts +0 -0
- package/dist/core/gaurds/assertions/assertSingleInstance/onClientEntryServerRouting.ts +0 -0
- package/dist/core/gaurds/assertions/assertType.ts +12 -0
- package/dist/core/gaurds/assertions/assertUsage/base.ts +43 -0
- package/dist/core/gaurds/assertions/assertUsage/index.ts +3 -0
- package/dist/core/gaurds/assertions/assertUsage/log.ts +29 -0
- package/dist/core/gaurds/assertions/assertUsage/node.ts +16 -0
- package/dist/core/gaurds/assertions/assertV1Design.ts +29 -0
- package/dist/core/gaurds/assertions/assertVersion/base.ts +55 -0
- package/dist/core/gaurds/assertions/assertVersion/index.ts +1 -0
- package/dist/core/gaurds/assertions/assertWarning/base.ts +43 -0
- package/dist/core/gaurds/assertions/assertWarning/index.ts +2 -0
- package/dist/core/gaurds/assertions/assertWarning/log.ts +43 -0
- package/dist/core/gaurds/assertions/checkType.ts +2 -0
- package/dist/core/gaurds/debugger/createDebugger.ts +196 -0
- package/dist/core/gaurds/debugger/debugPageFiles.ts +121 -0
- package/dist/core/gaurds/debugger/index.ts +2 -0
- package/dist/core/gaurds/errors/createErrorWithCleanStackTrace.ts +56 -0
- package/dist/core/gaurds/errors/removeErrMsg.ts +8 -0
- package/dist/core/gaurds/logger/addOnBeforeLogHook/index.ts +7 -0
- package/dist/core/gaurds/logger/formatHintLog.ts +17 -0
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-1 +8 -0
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-2 +9 -0
- package/dist/core/gaurds/logger/log404/index.spec.ts +78 -0
- package/dist/core/gaurds/logger/log404/index.ts +208 -0
- package/dist/core/gaurds/logger/logErrorHint/errors.ts +17 -0
- package/dist/core/gaurds/logger/logErrorHint/getErrorHint.spec.ts +1057 -0
- package/dist/core/gaurds/logger/logErrorHint.ts +196 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.ts +16 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.ts +16 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.ts +39 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.ts +24 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.ts +83 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.ts +33 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.ts +20 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.ts +19 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.ts +36 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.ts +17 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.ts +16 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/getPrettyErrMessage.spec.ts +101 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet/getPrettyErrorWithCodeSnippet.spec.ts +232 -0
- package/dist/core/gaurds/logger/loggerNotProd/errorWithCodeSnippet.ts +212 -0
- package/dist/core/gaurds/logger/loggerNotProd/log.ts +124 -0
- package/dist/core/gaurds/logger/loggerNotProd.ts +271 -0
- package/dist/core/gaurds/logger/loggerProd.ts +37 -0
- package/dist/core/gaurds/logger/loggerRuntime.ts +46 -0
- package/dist/core/gaurds/logger/loggerVite/removeSuperfluousViteLog.ts +30 -0
- package/dist/core/gaurds/logger/loggerVite.ts +65 -0
- package/dist/core/gaurds/logger/overwriteAssertProductionLogger/index.ts +9 -0
- package/dist/core/gaurds/logger/trackLogs.ts +35 -0
- package/dist/core/gaurds/logger/warnIfErrorIsNotObject.ts +31 -0
- package/dist/core/gaurds/normalization/freezePartial.ts +39 -0
- package/dist/core/gaurds/normalization/normalizeHeaders.ts +20 -0
- package/dist/core/gaurds/normalization/normalizeLink.tsx +14 -0
- package/dist/core/gaurds/normalization/normalizeUrlArgument.ts +22 -0
- package/dist/core/gaurds/validators/hasProp.ts +116 -0
- package/dist/core/gaurds/validators/isArray.ts +4 -0
- package/dist/core/gaurds/validators/isArrayOfStrings.ts +7 -0
- package/dist/core/gaurds/validators/isAsset.ts +43 -0
- package/dist/core/gaurds/validators/isBrowser.ts +5 -0
- package/dist/core/gaurds/validators/isBug.ts +5 -0
- package/dist/core/gaurds/validators/isCallable.ts +11 -0
- package/dist/core/gaurds/validators/isClientSideRoutable.ts +19 -0
- package/dist/core/gaurds/validators/isConfigInvalid.ts +10 -0
- package/dist/core/gaurds/validators/isDev.ts +56 -0
- package/dist/core/gaurds/validators/isErrorDebug.ts +7 -0
- package/dist/core/gaurds/validators/isErrorPage.ts +16 -0
- package/dist/core/gaurds/validators/isFilePathAbsoluteFilesystem.ts +55 -0
- package/dist/core/gaurds/validators/isHtml.ts +9 -0
- package/dist/core/gaurds/validators/isNewError.ts +29 -0
- package/dist/core/gaurds/validators/isNodeJS.ts +10 -0
- package/dist/core/gaurds/validators/isNotFalse.ts +3 -0
- package/dist/core/gaurds/validators/isNotNullish.ts +2 -0
- package/dist/core/gaurds/validators/isNpmPackage.ts +127 -0
- package/dist/core/gaurds/validators/isObject.ts +3 -0
- package/dist/core/gaurds/validators/isObjectOfStrings.ts +9 -0
- package/dist/core/gaurds/validators/isObjectWithKeys.ts +18 -0
- package/dist/core/gaurds/validators/isPlainObject.ts +21 -0
- package/dist/core/gaurds/validators/isPromise.ts +9 -0
- package/dist/core/gaurds/validators/isPropertyGetter.ts +4 -0
- package/dist/core/gaurds/validators/isReact.ts +24 -0
- package/dist/core/gaurds/validators/isReactElement.ts +21 -0
- package/dist/core/gaurds/validators/isRevealApp.ts +4 -0
- package/dist/core/gaurds/validators/isSameErrorMessage.ts +8 -0
- package/dist/core/gaurds/validators/isScriptFile.ts +75 -0
- package/dist/core/gaurds/validators/isServerSideError.ts +1 -0
- package/dist/core/gaurds/validators/isViteCliCall.ts +93 -0
- package/dist/core/gaurds/validators/isVitest.ts +7 -0
- package/dist/core/gaurds/validators/rollupIsEsm.ts +14 -0
- package/dist/core/gaurds/validators/viteIsSSR.ts +23 -0
- package/dist/core/globals/contexts/globalContext/getPageFilesExports.ts +28 -0
- package/dist/core/globals/contexts/globalContext/index.ts +374 -0
- package/dist/core/globals/contexts/globalContext/loadImportBuild.ts +44 -0
- package/dist/core/globals/contexts/globalContext/setup.ts +4 -0
- package/dist/core/globals/contexts/index.ts +1 -0
- package/dist/core/globals/logger/index.ts +1 -0
- package/dist/core/globals/logger/numberOfStackTraceLinesToRemove.ts +3 -0
- package/dist/core/globals/objects/index.ts +1 -0
- package/dist/core/globals/objects/log.ts +24 -0
- package/dist/core/globals/patterns/styleFileRE.ts +3 -0
- package/dist/core/globals/tags/addPrefixAssertType.ts +11 -0
- package/dist/core/globals/tags/addPrefixProjectName.ts +9 -0
- package/dist/core/globals/tags/projectTag.ts +3 -0
- package/dist/core/globals/tags/projectTagWithVersion.ts +5 -0
- package/dist/core/globals/versions/PROJECT_VERSION.ts +2 -0
- package/dist/core/globals/versions/projectInfo.ts +5 -0
- package/dist/core/handlers/handleErrorWithoutErrorPage.ts +70 -0
- package/dist/core/handlers/handlePageContext.ts +15 -0
- package/dist/core/handlers/handlePageContextRequestUrl.ts +56 -0
- package/dist/core/handlers/openFacebook.ts +20 -0
- package/dist/core/hocs/clientOnly.tsx +130 -0
- package/dist/core/hooks/callCumulativeHooks.ts +22 -0
- package/dist/core/hooks/executeHook.ts +118 -0
- package/dist/core/hooks/useConfig/configsCumulative.ts +6 -0
- package/dist/core/hooks/useConfig/useConfig-client.ts +82 -0
- package/dist/core/hooks/useConfig/useConfig-server.ts +152 -0
- package/dist/core/hydration/progressive.ts +252 -0
- package/dist/core/index.ts +60 -0
- package/dist/core/islands/index.tsx +198 -0
- package/dist/core/logging/UnifiedLoggerV2.ts +555 -0
- package/dist/core/logging/index.ts +80 -0
- package/dist/core/logging/plugins/FilePlugin.ts +132 -0
- package/dist/core/logging/plugins/PayloadCMSPlugin.ts +71 -0
- package/dist/core/logging/plugins/RemotePlugin.ts +110 -0
- package/dist/core/logging/plugins/index.ts +11 -0
- package/dist/core/naming/UnifiedNaming.ts +424 -0
- package/dist/core/observability/logger.ts +195 -0
- package/dist/core/observability/metrics.ts +156 -0
- package/dist/core/processing/getters/getAssertErrMsg.ts +49 -0
- package/dist/core/processing/getters/getAssetsDir.ts +11 -0
- package/dist/core/processing/getters/getBaseServer.ts +16 -0
- package/dist/core/processing/getters/getCacheControl.ts +26 -0
- package/dist/core/processing/getters/getConfigDefinedAt.ts +73 -0
- package/dist/core/processing/getters/getConfigReveal.ts +14 -0
- package/dist/core/processing/getters/getConfigValue.ts +68 -0
- package/dist/core/processing/getters/getConfigValueBuildTime.ts +92 -0
- package/dist/core/processing/getters/getConfigValueFilePathToShowToUser.ts +17 -0
- package/dist/core/processing/getters/getCurrentUrl.ts +42 -0
- package/dist/core/processing/getters/getEarlyHints.ts +58 -0
- package/dist/core/processing/getters/getEnv.ts +33 -0
- package/dist/core/processing/getters/getErrorPageId.ts +23 -0
- package/dist/core/processing/getters/getExportPath.spec.ts +34 -0
- package/dist/core/processing/getters/getExportPath.ts +33 -0
- package/dist/core/processing/getters/getFileExtension.ts +19 -0
- package/dist/core/processing/getters/getFilePath.ts +269 -0
- package/dist/core/processing/getters/getGlobalObject.ts +53 -0
- package/dist/core/processing/getters/getHeadSetting.tsx +36 -0
- package/dist/core/processing/getters/getHook.ts +222 -0
- package/dist/core/processing/getters/getHookFilePathToShowToUser.ts +12 -0
- package/dist/core/processing/getters/getHtmlTags.ts +341 -0
- package/dist/core/processing/getters/getHttpRequestAsyncStore.ts +122 -0
- package/dist/core/processing/getters/getHttpResponseBody.ts +177 -0
- package/dist/core/processing/getters/getMostSimilar.ts +72 -0
- package/dist/core/processing/getters/getOutDirs.ts +160 -0
- package/dist/core/processing/getters/getPageAssets/getManifestEntry.ts +164 -0
- package/dist/core/processing/getters/getPageAssets/retrieveAssetsDev.ts +96 -0
- package/dist/core/processing/getters/getPageAssets/retrieveAssetsProd.ts +86 -0
- package/dist/core/processing/getters/getPageAssets/sortPageAssetsForEarlyHintsHeader.ts +40 -0
- package/dist/core/processing/getters/getPageAssets.ts +140 -0
- package/dist/core/processing/getters/getPageConfig.ts +14 -0
- package/dist/core/processing/getters/getPageContext.ts +64 -0
- package/dist/core/processing/getters/getPageContextCurrent.ts +19 -0
- package/dist/core/processing/getters/getPageContextFromHooks.ts +335 -0
- package/dist/core/processing/getters/getPageContextProxyForUser.ts +97 -0
- package/dist/core/processing/getters/getPageContextRequestUrl.ts +22 -0
- package/dist/core/processing/getters/getPageContextSerializedInHtml.ts +32 -0
- package/dist/core/processing/getters/getPageContextUrlComputed.ts +410 -0
- package/dist/core/processing/getters/getPageElement.tsx +148 -0
- package/dist/core/processing/getters/getPageFiles/analyzeClientSide.ts +50 -0
- package/dist/core/processing/getters/getPageFiles/analyzePageServerSide.ts +32 -0
- package/dist/core/processing/getters/getPageFiles/getExportNames.ts +16 -0
- package/dist/core/processing/getters/getPageFiles/getExports.ts +193 -0
- package/dist/core/processing/getters/getPageFiles/index.ts +9 -0
- package/dist/core/processing/getters/getPageFiles/parseGlobResults.ts +167 -0
- package/dist/core/processing/getters/getPageFiles/setPageFiles.ts +76 -0
- package/dist/core/processing/getters/getPrefetchSettingResolved.ts.ts +87 -0
- package/dist/core/processing/getters/getProjectError.ts +18 -0
- package/dist/core/processing/getters/getPropAccessNotation.ts +10 -0
- package/dist/core/processing/getters/getRandomId.ts +15 -0
- package/dist/core/processing/getters/getRevalidationKey.ts +5 -0
- package/dist/core/processing/getters/getRevealClientEntry.ts +7 -0
- package/dist/core/processing/getters/getRevealConfig/configDefinitionsBuiltIn.ts +711 -0
- package/dist/core/processing/getters/getRevealConfig/crawlPlusFiles.ts +409 -0
- package/dist/core/processing/getters/getRevealConfig/filesystemRouting.spec.ts +40 -0
- package/dist/core/processing/getters/getRevealConfig/filesystemRouting.ts +286 -0
- package/dist/core/processing/getters/getRevealConfig/index.ts +1641 -0
- package/dist/core/processing/getters/getRevealConfig/loadFileAtConfigTime.ts +181 -0
- package/dist/core/processing/getters/getRevealConfig/resolvePointerImport.ts +240 -0
- package/dist/core/processing/getters/getRevealConfig/transformPointerImports.spec.ts +30 -0
- package/dist/core/processing/getters/getRevealConfig/transformPointerImports.ts +244 -0
- package/dist/core/processing/getters/getRevealConfig/transpileAndExecuteFile.ts +490 -0
- package/dist/core/processing/getters/getTagAttributesString.ts +27 -0
- package/dist/core/processing/getters/getTerminWidth.ts +9 -0
- package/dist/core/processing/getters/getValuePrintable.ts +6 -0
- package/dist/core/processing/getters/getViteDevScript.ts +47 -0
- package/dist/core/processing/iterators/analyzePage.ts +65 -0
- package/dist/core/processing/iterators/includes.ts +10 -0
- package/dist/core/processing/iterators/index.ts +2 -0
- package/dist/core/processing/iterators/objectKeys.ts +6 -0
- package/dist/core/processing/parsers/parseEsModule.ts +43 -0
- package/dist/core/processing/parsers/parseTransform.ts +36 -0
- package/dist/core/processing/serializers/notSerializable.ts +2 -0
- package/dist/core/processing/serializers/replaceWithParserPath.ts +30 -0
- package/dist/core/processing/serializers/serializePage/PageConfigSerialized.ts +45 -0
- package/dist/core/processing/serializers/serializePage/parsePageConfigs.ts +223 -0
- package/dist/core/processing/serializers/serializePage/serializeConfigValues.ts +336 -0
- package/dist/core/processing/serializers/serializePageContextClientSide.ts +179 -0
- package/dist/core/processing/serializers/stringify.ts +188 -0
- package/dist/core/processing/serializers/stringifyTypes.ts +103 -0
- package/dist/core/processing/setters/addIs404ToPageProps.ts +27 -0
- package/dist/core/processing/setters/setAlwaysShowStackTrace.ts +7 -0
- package/dist/core/processing/transformers/augmentType.ts +10 -0
- package/dist/core/processing/transformers/rollupSourceMap.ts +23 -0
- package/dist/core/processing/transformers/slice.ts +52 -0
- package/dist/core/renderer/page/executeOnBeforeRenderAndDataHooks.ts +53 -0
- package/dist/core/renderer/page/executeOnRenderHtmlHook.ts +261 -0
- package/dist/core/renderer/page/index.ts +804 -0
- package/dist/core/renderer/page/inferMediaType.ts +128 -0
- package/dist/core/renderer/page/loadUserFilesServerSide.ts +154 -0
- package/dist/core/renderer/page/preparePageContextForUserConsumption.ts +55 -0
- package/dist/core/renderer/page/preparePageContextForUserConsumptionServerSide.ts +38 -0
- package/dist/core/renderer/page/renderPageAlreadyRouted.ts +373 -0
- package/dist/core/renderer/page/resolveRedirects.ts +75 -0
- package/dist/core/renderer/prerender/index.ts +1 -0
- package/dist/core/renderer/prerender/runPrerender.ts +1141 -0
- package/dist/core/renderer/prerender/utils.ts +22 -0
- package/dist/core/renderer/stream/html.ts +408 -0
- package/dist/core/renderer/stream/index.ts +1001 -0
- package/dist/core/renderer/stream/onLoad.ts +14 -0
- package/dist/core/renderer/stream/react-streaming.ts +69 -0
- package/dist/core/renderer/stream/utils.ts +66 -0
- package/dist/core/resilience/circuit-breaker.ts +212 -0
- package/dist/core/resilience/retry.ts +172 -0
- package/dist/core/result/adapters.ts +254 -0
- package/dist/core/result.ts +332 -0
- package/dist/core/router/abort.ts +339 -0
- package/dist/core/router/apiRoutes.ts +94 -0
- package/dist/core/router/debug.ts +19 -0
- package/dist/core/router/deduceRouteStringFromFilesystemPath.ts +75 -0
- package/dist/core/router/dynamicApiRoutes.ts +18 -0
- package/dist/core/router/dynamicPageRoutes.ts +18 -0
- package/dist/core/router/executeGuardHook.ts +45 -0
- package/dist/core/router/executeOnBeforeRouteHook.ts +161 -0
- package/dist/core/router/index.ts +230 -0
- package/dist/core/router/loadPageRoutes.ts +155 -0
- package/dist/core/router/noRouteMatch.ts +1 -0
- package/dist/core/router/pageRoutes.ts +159 -0
- package/dist/core/router/resolvePrecedence.ts +128 -0
- package/dist/core/router/resolveRoute.ts +29 -0
- package/dist/core/router/resolveRouteFunction.ts +193 -0
- package/dist/core/router/resolveRouteString.ts +204 -0
- package/dist/core/router/resolveRouteUtils.ts +77 -0
- package/dist/core/router/resolveUrlPathname.ts +67 -0
- package/dist/core/router/routeInternal.ts +97 -0
- package/dist/core/router/utils.ts +30 -0
- package/dist/core/services/BaseService.ts +403 -0
- package/dist/core/targets/client/abort.ts +11 -0
- package/dist/core/targets/client/createPageContext.ts +48 -0
- package/dist/core/targets/client/entry.ts +15 -0
- package/dist/core/targets/client/executeOnRenderClientHook.ts +94 -0
- package/dist/core/targets/client/history.ts +142 -0
- package/dist/core/targets/client/index.ts +9 -0
- package/dist/core/targets/client/initClientRouter.ts +48 -0
- package/dist/core/targets/client/initOnLinkClick.ts +54 -0
- package/dist/core/targets/client/loadUserFilesClientSide.ts +92 -0
- package/dist/core/targets/client/navigate.ts +45 -0
- package/dist/core/targets/client/onBrowserHistoryNavigation.ts +85 -0
- package/dist/core/targets/client/onLoad.ts +10 -0
- package/dist/core/targets/client/pageContextInitIsPassedToClient.ts +2 -0
- package/dist/core/targets/client/pageFiles.ts +4 -0
- package/dist/core/targets/client/prefetch.ts +399 -0
- package/dist/core/targets/client/preparePageContextForUserConsumptionClientSide.ts +48 -0
- package/dist/core/targets/client/removeBuiltInOverrides.ts +37 -0
- package/dist/core/targets/client/removeFoucBuster.ts +70 -0
- package/dist/core/targets/client/renderPageClientSide.ts +1817 -0
- package/dist/core/targets/client/router.ts +15 -0
- package/dist/core/targets/client/scrollRestoration.ts +37 -0
- package/dist/core/targets/client/setScrollPosition.ts +87 -0
- package/dist/core/targets/client/skipLink.ts +63 -0
- package/dist/core/targets/client/utils.ts +34 -0
- package/dist/core/targets/http/createHttpResponse.ts +254 -0
- package/dist/core/targets/http/fetchBanner.ts +25 -0
- package/dist/core/targets/http/fetchCard.ts +25 -0
- package/dist/core/targets/http/fetchEvents.ts +25 -0
- package/dist/core/targets/http/fetchHero.ts +25 -0
- package/dist/core/targets/http/fetchMainInfos.ts +25 -0
- package/dist/core/targets/http/fetchPage.ts +78 -0
- package/dist/core/targets/http/fetchPages.ts +70 -0
- package/dist/core/targets/http/fetchVideos.ts +26 -0
- package/dist/core/targets/http/fetchYouTube.ts +90 -0
- package/dist/core/targets/server/entry.ts +43 -0
- package/dist/core/targets/server/middleware/addSsrMiddleware.ts +52 -0
- package/dist/core/targets/server/onLoad.ts +7 -0
- package/dist/core/targets/server/pageFiles.ts +4 -0
- package/dist/core/targets/server/root.ts +10 -0
- package/dist/core/targets/server/utils.ts +20 -0
- package/dist/core/targets/url/index.ts +439 -0
- package/dist/core/targets/url/modifyUrl.ts +45 -0
- package/dist/core/targets/url/parseUrl.ts +440 -0
- package/dist/core/targets/url/parseUrlExtras.ts +193 -0
- package/dist/core/targets/url/redirectHard.ts +3 -0
- package/dist/core/targets/url/updateCurrentPath.ts +52 -0
- package/dist/core/targets/url/urlToFile.ts +47 -0
- package/dist/core/types/UnifiedTypes.ts +493 -0
- package/dist/core/types/contracts.ts +61 -0
- package/dist/core/types/generator.ts +316 -0
- package/dist/core/utils/array/includes.ts +10 -0
- package/dist/core/utils/array/slice.ts +52 -0
- package/dist/core/utils/array/sorter.ts +130 -0
- package/dist/core/utils/array/stringifyStringArray.ts +7 -0
- package/dist/core/utils/array/unique.ts +5 -0
- package/dist/core/utils/async/genPromise.ts +8 -0
- package/dist/core/utils/async/pLimit.ts +157 -0
- package/dist/core/utils/async/sleep.ts +3 -0
- package/dist/core/utils/async/throttle.ts +14 -0
- package/dist/core/utils/index.ts +31 -0
- package/dist/core/utils/object/changeEnumerable.ts +9 -0
- package/dist/core/utils/object/deepEqual.ts +10 -0
- package/dist/core/utils/object/objectAssign.ts +16 -0
- package/dist/core/utils/object/objectDefineProperty.ts +15 -0
- package/dist/core/utils/object/objectEntries.ts +7 -0
- package/dist/core/utils/object/objectEntriesForEach.ts +7 -0
- package/dist/core/utils/object/objectFromEntries.ts +6 -0
- package/dist/core/utils/string/addWhitespace.ts +9 -0
- package/dist/core/utils/string/capitalizeFirstLetter.ts +8 -0
- package/dist/core/utils/string/compareString.ts +7 -0
- package/dist/core/utils/string/escapeHtml.ts +10 -0
- package/dist/core/utils/string/escapeRegex.ts +4 -0
- package/dist/core/utils/string/joinEnglish.ts +18 -0
- package/dist/core/utils/string/removeEmptyLines.ts +6 -0
- package/dist/core/utils/string/stripAnsi.ts +24 -0
- package/dist/core/utils/string/trimWithAnsi.ts +40 -0
- package/dist/core/utils/string/truncateString.ts +19 -0
- package/dist/core/utils/time/humanizeTime.ts +24 -0
- package/dist/exports/RenderErrorPage.js +3 -0
- package/dist/exports/__internal.js +3 -0
- package/dist/exports/abort.js +3 -0
- package/dist/exports/bin-entry.js +3 -0
- package/dist/exports/cli.js +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/exports/config.js +1 -0
- package/dist/exports/helpers.js +1 -0
- package/dist/exports/index.js +33 -0
- package/dist/exports/plugin.js +3 -0
- package/dist/exports/prerender.js +3 -0
- package/dist/exports/router.js +3 -0
- package/dist/exports/routing.js +3 -0
- package/dist/exports/server.js +3 -0
- package/dist/exports/setup.js +3 -0
- package/dist/exports/types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -0
- package/dist/integration/hydration.ts +52 -0
- package/dist/integration/onRenderClient.tsx +377 -0
- package/dist/integration/onRenderHtml.tsx +761 -0
- package/dist/integration/ssrEffect.ts +31 -0
- package/dist/integration/styles.css +141 -0
- package/dist/plugins/baseUrls.ts +54 -0
- package/dist/plugins/buildConfig/index.ts +701 -0
- package/dist/plugins/buildConfig/injectRollupInputs.ts +36 -0
- package/dist/plugins/commonConfig.ts +112 -0
- package/dist/plugins/config/assertResolveAlias.ts +99 -0
- package/dist/plugins/config/assertRevealConfig.ts +116 -0
- package/dist/plugins/config/fixServerAssets.ts +213 -0
- package/dist/plugins/config/index.ts +227 -0
- package/dist/plugins/config/pickFirst.ts +3 -0
- package/dist/plugins/config/resolveBase.ts +78 -0
- package/dist/plugins/devConfig/determineFsAllowList.ts +34 -0
- package/dist/plugins/devConfig/determineOptimizeDeps.ts +129 -0
- package/dist/plugins/devConfig/index.ts +222 -0
- package/dist/plugins/distFileNames.ts +341 -0
- package/dist/plugins/envVars.ts +150 -0
- package/dist/plugins/extractAssetsPlugin.ts +318 -0
- package/dist/plugins/extractExportNamesPlugin.ts +154 -0
- package/dist/plugins/fileEnv.ts +374 -0
- package/dist/plugins/importBuild/getRevealManifest.ts +20 -0
- package/dist/plugins/importBuild/index.ts +120 -0
- package/dist/plugins/importUserCode/addImportStatement.ts +32 -0
- package/dist/plugins/importUserCode/debug.ts +2 -0
- package/dist/plugins/importUserCode/getConfigFileExport.ts +24 -0
- package/dist/plugins/importUserCode/getVirtualFilePageConfigValuesAll.ts +95 -0
- package/dist/plugins/importUserCode/getVirtualFilePageConfigs.ts +150 -0
- package/dist/plugins/importUserCode/index.ts +375 -0
- package/dist/plugins/importUserCode/isRuntimeEnvMatch.ts +31 -0
- package/dist/plugins/index.ts +233 -0
- package/dist/plugins/onLoad.ts +12 -0
- package/dist/plugins/packageJsonFile.ts +62 -0
- package/dist/plugins/payload/index.ts +62 -0
- package/dist/plugins/previewConfig.ts +95 -0
- package/dist/plugins/react/index.ts +72 -0
- package/dist/plugins/removeRequireHookPlugin.ts +27 -0
- package/dist/plugins/resolveClientEntriesDev.ts +87 -0
- package/dist/plugins/reveal/index.ts +39 -0
- package/dist/plugins/reveal/remove-use-client-server.ts +52 -0
- package/dist/plugins/setGlobalContext.ts +53 -0
- package/dist/plugins/suppressRollupWarning.ts +94 -0
- package/dist/plugins/utils.ts +33 -0
- package/dist/plugins/vercel/+config.ts +18 -0
- package/dist/plugins/vercel/functions/assert.ts +13 -0
- package/dist/plugins/vercel/functions/build.ts +484 -0
- package/dist/plugins/vercel/functions/config.ts +147 -0
- package/dist/plugins/vercel/functions/helpers.ts +70 -0
- package/dist/plugins/vercel/functions/prerender.ts +140 -0
- package/dist/plugins/vercel/functions/route-regex.ts +37 -0
- package/dist/plugins/vercel/functions/utils.ts +33 -0
- package/dist/plugins/vercel/functions/vike.ts +754 -0
- package/dist/plugins/vercel/index.ts +186 -0
- package/dist/plugins/vercel/plugin.ts +45 -0
- package/dist/plugins/vercel/schemas/config/prerender-config.ts +20 -0
- package/dist/plugins/vercel/schemas/config/vc-config.ts +45 -0
- package/dist/plugins/vercel/schemas/config/vercel.ts +130 -0
- package/dist/plugins/vercel/schemas/exports.ts +12 -0
- package/dist/plugins/vercel/templates/edge-helpers.ts +72 -0
- package/dist/plugins/vercel/templates/node-helpers.ts +60 -0
- package/dist/plugins/vercel/templates/ssr_.template.ts +25 -0
- package/dist/plugins/vercel/templates/ssr_edge_.template.ts +20 -0
- package/dist/plugins/vercel/templates/utils.ts +31 -0
- package/dist/plugins/workaroundCssModuleHmr.ts +23 -0
- package/dist/types/index.ts +50 -0
- package/dist/types/interfaces/app.ts +700 -0
- package/dist/types/interfaces/client.ts +10 -0
- package/dist/types/interfaces/config.ts +481 -0
- package/dist/types/interfaces/context.ts +677 -0
- package/dist/types/interfaces/error.ts +6 -0
- package/dist/types/interfaces/file.ts +98 -0
- package/dist/types/interfaces/host.ts +209 -0
- package/dist/types/interfaces/log.ts +3 -0
- package/dist/types/interfaces/logic.ts +46 -0
- package/dist/types/interfaces/manifest.ts +15 -0
- package/dist/types/interfaces/node.ts +8 -0
- package/dist/types/interfaces/page.ts +154 -0
- package/dist/types/interfaces/reveal.ts +118 -0
- package/dist/types/interfaces/tag.ts +3 -0
- package/dist/types/modules/assets.d.ts +57 -0
- package/dist/types/modules/env.d.ts +34 -0
- package/dist/types/modules/global.d.ts +10 -0
- package/dist/types/modules/index.d.ts +1 -0
- package/dist/types/modules/node.d.ts +2 -0
- package/dist/types/modules/payload.d.ts +2 -0
- package/dist/types/modules/reveal-vercel.d.ts +19 -0
- package/dist/types/modules/reveal.d.ts +1 -0
- package/dist/types/modules/stripe.d.ts +41 -0
- package/dist/types/modules/supabase.d.ts +19 -0
- package/dist/types/modules/tailwindcss.d.ts +49 -0
- package/dist/types/modules/vite.d.ts +7 -0
- package/dist/types/namespaces/Config.ts +291 -0
- package/dist/types/namespaces/PageContext.ts +23 -0
- package/dist/types/namespaces/RevealNamespace.ts +51 -0
- package/dist/types/namespaces/index.ts +3 -0
- package/dist/ui/accents/DiagonalGrid.tsx +36 -0
- package/dist/ui/accents/Glass.tsx +33 -0
- package/dist/ui/accents/Parallax.tsx +78 -0
- package/dist/ui/accents/Shadow.tsx +28 -0
- package/dist/ui/accents/index.tsx +4 -0
- package/dist/ui/accessibility/index.ts +168 -0
- package/dist/ui/ai/ChatGPTAssistant.tsx +113 -0
- package/dist/ui/ai/index.ts +3 -0
- package/dist/ui/animations/container.ts +7 -0
- package/dist/ui/animations/content.ts +16 -0
- package/dist/ui/animations/fade.ts +16 -0
- package/dist/ui/animations/index.ts +6 -0
- package/dist/ui/animations/slide.ts +23 -0
- package/dist/ui/animations/text.ts +14 -0
- package/dist/ui/animations/transition.ts +1 -0
- package/dist/ui/audio/AudioTrack.tsx +26 -0
- package/dist/ui/audio/index.tsx +1 -0
- package/dist/ui/backgrounds/Diagonal.tsx +46 -0
- package/dist/ui/backgrounds/GradientConic.tsx +21 -0
- package/dist/ui/backgrounds/GradientConicRev.tsx +50 -0
- package/dist/ui/backgrounds/GradientGlass.tsx +28 -0
- package/dist/ui/backgrounds/GradientRadial.tsx +37 -0
- package/dist/ui/backgrounds/GradientRadialLeft.tsx +33 -0
- package/dist/ui/backgrounds/GradientToBottom.tsx +59 -0
- package/dist/ui/backgrounds/GradientToTop.tsx +60 -0
- package/dist/ui/backgrounds/Solid.tsx +50 -0
- package/dist/ui/backgrounds/Straight.tsx +55 -0
- package/dist/ui/backgrounds/TopRight.tsx +15 -0
- package/dist/ui/backgrounds/Wrapper.tsx +33 -0
- package/dist/ui/backgrounds/index.tsx +12 -0
- package/dist/ui/buttons/Button.tsx +54 -0
- package/dist/ui/buttons/DisclosureButton.tsx +35 -0
- package/dist/ui/buttons/GradientButton.tsx +51 -0
- package/dist/ui/buttons/IconButton.tsx +24 -0
- package/dist/ui/buttons/LikeButton.tsx +221 -0
- package/dist/ui/buttons/MobileMenuButton.tsx +63 -0
- package/dist/ui/buttons/MusicButton.tsx +53 -0
- package/dist/ui/buttons/SignUpButton.tsx +18 -0
- package/dist/ui/buttons/index.tsx +8 -0
- package/dist/ui/cards/Card.tsx +255 -0
- package/dist/ui/cards/ProductCard.tsx +291 -0
- package/dist/ui/cards/VideoCard.tsx +201 -0
- package/dist/ui/cards/index.tsx +3 -0
- package/dist/ui/contexts/DisclosureContext.tsx +44 -0
- package/dist/ui/contexts/GlobalContext.tsx +67 -0
- package/dist/ui/contexts/MenuContext.tsx +8 -0
- package/dist/ui/contexts/PageContext.tsx +28 -0
- package/dist/ui/contexts/ThemeContext.tsx +195 -0
- package/dist/ui/controls/MusicHeader.tsx +484 -0
- package/dist/ui/controls/MusicPlayer.tsx +76 -0
- package/dist/ui/controls/MusicSidebar.tsx +118 -0
- package/dist/ui/controls/MusicSlider.tsx +25 -0
- package/dist/ui/controls/MusicUpload.tsx +296 -0
- package/dist/ui/controls/PlayPause.tsx +64 -0
- package/dist/ui/controls/PlayerContent.tsx +205 -0
- package/dist/ui/controls/SearchContent.tsx +58 -0
- package/dist/ui/controls/SearchInput.tsx +118 -0
- package/dist/ui/controls/Searchbar.tsx +53 -0
- package/dist/ui/controls/SidebarItem.tsx +57 -0
- package/dist/ui/controls/SongItem.tsx +45 -0
- package/dist/ui/controls/VideoPlayer.tsx +36 -0
- package/dist/ui/controls/index.tsx +13 -0
- package/dist/ui/dividers/Horizontal.tsx +18 -0
- package/dist/ui/dividers/Transparent.tsx +7 -0
- package/dist/ui/dividers/index.tsx +2 -0
- package/dist/ui/error/ErrorBoundary.tsx +150 -0
- package/dist/ui/error/index.tsx +1 -0
- package/dist/ui/forms/Input.tsx +38 -0
- package/dist/ui/forms/MediaItem.tsx +105 -0
- package/dist/ui/forms/index.tsx +2 -0
- package/dist/ui/game/Enemy.tsx +52 -0
- package/dist/ui/game/Fighters.tsx +38 -0
- package/dist/ui/game/GameControls.tsx +37 -0
- package/dist/ui/game/HealthBar.tsx +18 -0
- package/dist/ui/game/Player.tsx +70 -0
- package/dist/ui/game/index.tsx +5 -0
- package/dist/ui/hooks/useApiData.ts +57 -0
- package/dist/ui/hooks/useAuthModal.ts +18 -0
- package/dist/ui/hooks/useCart.ts +21 -0
- package/dist/ui/hooks/useChatGPT.ts +94 -0
- package/dist/ui/hooks/useCustomProps.ts +31 -0
- package/dist/ui/hooks/useData.ts +10 -0
- package/dist/ui/hooks/useDebounce.ts +52 -0
- package/dist/ui/hooks/useDisclosure.ts +8 -0
- package/dist/ui/hooks/useGame.ts +1147 -0
- package/dist/ui/hooks/useLayoutClasses.ts +70 -0
- package/dist/ui/hooks/useLazyLoad.ts +78 -0
- package/dist/ui/hooks/useLikeSong.ts +22 -0
- package/dist/ui/hooks/useLivePreview.ts +60 -0
- package/dist/ui/hooks/useMenu.ts +6 -0
- package/dist/ui/hooks/useOnPlay.ts +23 -0
- package/dist/ui/hooks/usePageContext.ts +174 -0
- package/dist/ui/hooks/useParallax.ts +161 -0
- package/dist/ui/hooks/usePreviewModal.ts +25 -0
- package/dist/ui/hooks/useScreenSize.ts +56 -0
- package/dist/ui/hooks/useTheme.ts +6 -0
- package/dist/ui/images/Carousel.tsx +326 -0
- package/dist/ui/images/Circle.tsx +9 -0
- package/dist/ui/images/Defs.tsx +7 -0
- package/dist/ui/images/Image.tsx +127 -0
- package/dist/ui/images/ImageGrid.tsx +73 -0
- package/dist/ui/images/Logo.tsx +22 -0
- package/dist/ui/images/Path.tsx +27 -0
- package/dist/ui/images/Pattern.tsx +70 -0
- package/dist/ui/images/PromoBanner.tsx +25 -0
- package/dist/ui/images/Rect.tsx +10 -0
- package/dist/ui/images/SVG.tsx +58 -0
- package/dist/ui/images/Stop.tsx +15 -0
- package/dist/ui/images/index.tsx +12 -0
- package/dist/ui/layouts/classNames.ts +8 -0
- package/dist/ui/layouts/container.ts +20 -0
- package/dist/ui/layouts/flex.ts +13 -0
- package/dist/ui/layouts/grid.ts +11 -0
- package/dist/ui/layouts/main.ts +31 -0
- package/dist/ui/layouts/responsive.ts +28 -0
- package/dist/ui/layouts/stack.ts +24 -0
- package/dist/ui/lists/DescriptionList.tsx +41 -0
- package/dist/ui/lists/DisclosurePanel.tsx +20 -0
- package/dist/ui/lists/JobOpeningsList.tsx +54 -0
- package/dist/ui/lists/List.tsx +18 -0
- package/dist/ui/lists/ListElements.tsx +43 -0
- package/dist/ui/lists/ListItem.tsx +63 -0
- package/dist/ui/lists/ProductList.tsx +37 -0
- package/dist/ui/lists/StatsList.tsx +64 -0
- package/dist/ui/lists/UList.tsx +54 -0
- package/dist/ui/lists/index.ts +9 -0
- package/dist/ui/navigation/DesktopMenu.tsx +14 -0
- package/dist/ui/navigation/Footer.tsx +128 -0
- package/dist/ui/navigation/Link.tsx +225 -0
- package/dist/ui/navigation/MobileMenu.tsx +26 -0
- package/dist/ui/navigation/NavigationLinks.tsx +244 -0
- package/dist/ui/navigation/NotFound.tsx +12 -0
- package/dist/ui/navigation/Route.tsx +120 -0
- package/dist/ui/navigation/Transition.tsx +40 -0
- package/dist/ui/navigation/index.tsx +8 -0
- package/dist/ui/notifications/Banner.tsx +69 -0
- package/dist/ui/notifications/Error.tsx +12 -0
- package/dist/ui/notifications/Loader.tsx +14 -0
- package/dist/ui/notifications/NoResults.tsx +11 -0
- package/dist/ui/notifications/index.tsx +4 -0
- package/dist/ui/providers/AppProvider.tsx +115 -0
- package/dist/ui/providers/DisclosureProvider.tsx +21 -0
- package/dist/ui/providers/MenuProvider.tsx +40 -0
- package/dist/ui/providers/PageContextProvider.tsx +176 -0
- package/dist/ui/providers/ThemeProvider.tsx +196 -0
- package/dist/ui/shells/App.tsx +57 -0
- package/dist/ui/shells/Container.tsx +74 -0
- package/dist/ui/shells/Disclosure.tsx +72 -0
- package/dist/ui/shells/Field.tsx +21 -0
- package/dist/ui/shells/Flex.tsx +193 -0
- package/dist/ui/shells/Grid.tsx +118 -0
- package/dist/ui/shells/Header.tsx +123 -0
- package/dist/ui/shells/Main.tsx +96 -0
- package/dist/ui/shells/Nav.tsx +138 -0
- package/dist/ui/shells/Section.tsx +94 -0
- package/dist/ui/shells/Skeleton.tsx +24 -0
- package/dist/ui/shells/index.ts +11 -0
- package/dist/ui/text/Article.tsx +141 -0
- package/dist/ui/text/Currency.tsx +29 -0
- package/dist/ui/text/Heading.tsx +29 -0
- package/dist/ui/text/Label.tsx +24 -0
- package/dist/ui/text/Motto.tsx +40 -0
- package/dist/ui/text/Paragraph.tsx +20 -0
- package/dist/ui/text/Span.tsx +20 -0
- package/dist/ui/text/TagLine.tsx +20 -0
- package/dist/ui/text/Time.tsx +36 -0
- package/dist/ui/text/WelcomeHeading.tsx +40 -0
- package/dist/ui/text/index.ts +10 -0
- package/dist/ui/video/VideoComponent.tsx +23 -0
- package/dist/ui/video/VideoDetail.tsx +33 -0
- package/dist/ui/video/VideoItem.tsx +51 -0
- package/dist/ui/video/VideoList.tsx +155 -0
- package/dist/ui/video/index.ts +4 -0
- package/package.json +721 -0
|
@@ -0,0 +1,1641 @@
|
|
|
1
|
+
export {
|
|
2
|
+
getConfigValueInterfaceFile,
|
|
3
|
+
getRevealConfig,
|
|
4
|
+
isRevealConfigFile,
|
|
5
|
+
isV1Design,
|
|
6
|
+
reloadRevealConfig,
|
|
7
|
+
revealConfigDependencies,
|
|
8
|
+
}
|
|
9
|
+
export type { InterfaceFile, InterfaceValueFile, RevealConfigObject }
|
|
10
|
+
|
|
11
|
+
import pc from "@brillout/picocolors"
|
|
12
|
+
import path from "path"
|
|
13
|
+
import type { ResolvedConfig } from "vite"
|
|
14
|
+
|
|
15
|
+
import { getConfigFileExport } from "../../../../plugins/importUserCode/getConfigFileExport.js"
|
|
16
|
+
import {
|
|
17
|
+
assert,
|
|
18
|
+
assertIsNotProductionRuntime,
|
|
19
|
+
assertKeys,
|
|
20
|
+
assertLog,
|
|
21
|
+
assertPosixPath,
|
|
22
|
+
assertUsage,
|
|
23
|
+
assertWarning,
|
|
24
|
+
getMostSimilar,
|
|
25
|
+
getOutDirs,
|
|
26
|
+
hasProp,
|
|
27
|
+
includes,
|
|
28
|
+
isNpmPackageImport,
|
|
29
|
+
isObject,
|
|
30
|
+
joinEnglish,
|
|
31
|
+
lowerFirst,
|
|
32
|
+
makeFirst,
|
|
33
|
+
objectEntries,
|
|
34
|
+
objectFromEntries,
|
|
35
|
+
objectKeys,
|
|
36
|
+
reverse,
|
|
37
|
+
} from "../../../../plugins/utils.js"
|
|
38
|
+
import type { Config } from "../../../../types/interfaces/config.js"
|
|
39
|
+
import type { FilePathResolved } from "../../../../types/interfaces/file.js"
|
|
40
|
+
import type {
|
|
41
|
+
ConfigEnvInternal,
|
|
42
|
+
ConfigValueSource,
|
|
43
|
+
ConfigValueSources,
|
|
44
|
+
ConfigValuesComputed,
|
|
45
|
+
DefinedAtFilePath,
|
|
46
|
+
PageConfigBuildTime,
|
|
47
|
+
PageConfigGlobalBuildTime,
|
|
48
|
+
} from "../../../../types/interfaces/page.js"
|
|
49
|
+
import {
|
|
50
|
+
assertExtensionsConventions,
|
|
51
|
+
assertExtensionsPeerDependencies,
|
|
52
|
+
} from "../../../gaurds/assertions/assertExtensions/base.js"
|
|
53
|
+
import {
|
|
54
|
+
logConfigError,
|
|
55
|
+
logConfigErrorRecover,
|
|
56
|
+
} from "../../../gaurds/logger/loggerNotProd.js"
|
|
57
|
+
import {
|
|
58
|
+
removeSuperfluousViteLog_disable,
|
|
59
|
+
removeSuperfluousViteLog_enable,
|
|
60
|
+
} from "../../../gaurds/logger/loggerVite/removeSuperfluousViteLog.js"
|
|
61
|
+
import {
|
|
62
|
+
isConfigInvalid,
|
|
63
|
+
isConfigInvalid_set,
|
|
64
|
+
} from "../../../gaurds/validators/isConfigInvalid.js"
|
|
65
|
+
import { getViteDevServer } from "../../../globals/contexts/globalContext/index.js"
|
|
66
|
+
import { getConfigDefinedAt } from "../getConfigDefinedAt.js"
|
|
67
|
+
import { getConfigReveal } from "../getConfigReveal.js"
|
|
68
|
+
import { getConfigValueBuildTime } from "../getConfigValueBuildTime.js"
|
|
69
|
+
import { getFilePathResolved } from "../getFilePath.js"
|
|
70
|
+
import {
|
|
71
|
+
type ConfigDefinitionInternal,
|
|
72
|
+
type ConfigDefinitions,
|
|
73
|
+
type ConfigNameGlobal,
|
|
74
|
+
configDefinitionsBuiltIn,
|
|
75
|
+
configDefinitionsBuiltInGlobal,
|
|
76
|
+
} from "./configDefinitionsBuiltIn.js"
|
|
77
|
+
import { crawlPlusFiles } from "./crawlPlusFiles.js"
|
|
78
|
+
import {
|
|
79
|
+
type LocationId,
|
|
80
|
+
applyFilesystemRoutingRootEffect,
|
|
81
|
+
getFilesystemRouteDefinedBy,
|
|
82
|
+
getFilesystemRouteString,
|
|
83
|
+
getLocationId,
|
|
84
|
+
isGlobalLocation,
|
|
85
|
+
isInherited,
|
|
86
|
+
sortAfterInheritanceOrder,
|
|
87
|
+
} from "./filesystemRouting.js"
|
|
88
|
+
import {
|
|
89
|
+
type ConfigFile,
|
|
90
|
+
ImportedFilesLoaded,
|
|
91
|
+
loadConfigFile,
|
|
92
|
+
loadImportedFile,
|
|
93
|
+
loadValueFile,
|
|
94
|
+
} from "./loadFileAtConfigTime.js"
|
|
95
|
+
import {
|
|
96
|
+
clearFilesEnvMap,
|
|
97
|
+
resolvePointerImportOfConfig,
|
|
98
|
+
} from "./resolvePointerImport.js"
|
|
99
|
+
import { isTemporaryBuildFile } from "./transpileAndExecuteFile.js"
|
|
100
|
+
|
|
101
|
+
assertIsNotProductionRuntime()
|
|
102
|
+
|
|
103
|
+
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile
|
|
104
|
+
type InterfaceFileCommons = {
|
|
105
|
+
locationId: LocationId
|
|
106
|
+
filePath: FilePathResolved
|
|
107
|
+
fileExportsByConfigName: Record<ConfigName, { configValue?: unknown }>
|
|
108
|
+
}
|
|
109
|
+
// +config.js
|
|
110
|
+
type InterfaceConfigFile = InterfaceFileCommons & {
|
|
111
|
+
isConfigFile: true
|
|
112
|
+
isValueFile: false
|
|
113
|
+
extendsFilePaths: string[]
|
|
114
|
+
isConfigExtend: boolean
|
|
115
|
+
}
|
|
116
|
+
// +{configName}.js
|
|
117
|
+
type InterfaceValueFile = InterfaceFileCommons & {
|
|
118
|
+
isConfigFile: false
|
|
119
|
+
isValueFile: true
|
|
120
|
+
configName: string
|
|
121
|
+
}
|
|
122
|
+
type ConfigName = string
|
|
123
|
+
type InterfaceFilesByLocationId = Record<LocationId, InterfaceFile[]>
|
|
124
|
+
|
|
125
|
+
type RevealConfigObject = {
|
|
126
|
+
pageConfigs: PageConfigBuildTime[]
|
|
127
|
+
pageConfigGlobal: PageConfigGlobalBuildTime
|
|
128
|
+
globalRevealConfig: Record<string, unknown>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let devServerIsCorrupt = false
|
|
132
|
+
let wasConfigInvalid: boolean | null = null
|
|
133
|
+
let revealConfigPromise: Promise<RevealConfigObject> | null = null
|
|
134
|
+
|
|
135
|
+
const revealConfigDependencies: Set<string> = new Set()
|
|
136
|
+
|
|
137
|
+
function reloadRevealConfig(userRootDir: string, outDirRoot: string) {
|
|
138
|
+
revealConfigDependencies.clear()
|
|
139
|
+
clearFilesEnvMap()
|
|
140
|
+
revealConfigPromise = loadRevealConfig_withErrorHandling(
|
|
141
|
+
userRootDir,
|
|
142
|
+
outDirRoot,
|
|
143
|
+
true,
|
|
144
|
+
true
|
|
145
|
+
)
|
|
146
|
+
handleReloadSideEffects()
|
|
147
|
+
}
|
|
148
|
+
async function handleReloadSideEffects() {
|
|
149
|
+
wasConfigInvalid = !!isConfigInvalid
|
|
150
|
+
const revealConfigPromisePrevious = revealConfigPromise
|
|
151
|
+
try {
|
|
152
|
+
await revealConfigPromise
|
|
153
|
+
} catch (err) {
|
|
154
|
+
// handleReloadSideEffects() is only called in dev.
|
|
155
|
+
// In dev, if loadRevealConfig_withErrorHandling() throws an error, then it's a reveal bug.
|
|
156
|
+
console.error(err)
|
|
157
|
+
assert(false)
|
|
158
|
+
}
|
|
159
|
+
if (revealConfigPromise !== revealConfigPromisePrevious) {
|
|
160
|
+
// Let the next handleReloadSideEffects() call handle side effects
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
if (!isConfigInvalid) {
|
|
164
|
+
if (wasConfigInvalid) {
|
|
165
|
+
wasConfigInvalid = false
|
|
166
|
+
logConfigErrorRecover()
|
|
167
|
+
}
|
|
168
|
+
if (devServerIsCorrupt) {
|
|
169
|
+
devServerIsCorrupt = false
|
|
170
|
+
const viteDevServer = getViteDevServer()
|
|
171
|
+
assert(viteDevServer)
|
|
172
|
+
removeSuperfluousViteLog_enable()
|
|
173
|
+
await viteDevServer.restart(true)
|
|
174
|
+
removeSuperfluousViteLog_disable()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function getRevealConfig(
|
|
179
|
+
config: ResolvedConfig,
|
|
180
|
+
isDev: boolean,
|
|
181
|
+
{
|
|
182
|
+
crawlWithGit,
|
|
183
|
+
tolerateInvalidConfig,
|
|
184
|
+
}: {
|
|
185
|
+
crawlWithGit?: null | boolean
|
|
186
|
+
tolerateInvalidConfig?: true
|
|
187
|
+
} = {}
|
|
188
|
+
): Promise<RevealConfigObject> {
|
|
189
|
+
const { outDirRoot } = getOutDirs(config)
|
|
190
|
+
const userRootDir = config.root
|
|
191
|
+
if (!revealConfigPromise) {
|
|
192
|
+
const crawlWithGit_ =
|
|
193
|
+
crawlWithGit !== undefined
|
|
194
|
+
? crawlWithGit
|
|
195
|
+
: (await getConfigReveal(config)).crawl.git
|
|
196
|
+
revealConfigPromise = loadRevealConfig_withErrorHandling(
|
|
197
|
+
userRootDir,
|
|
198
|
+
outDirRoot,
|
|
199
|
+
isDev,
|
|
200
|
+
crawlWithGit_,
|
|
201
|
+
tolerateInvalidConfig
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
return await revealConfigPromise
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function isV1Design(
|
|
208
|
+
config: ResolvedConfig,
|
|
209
|
+
isDev: boolean
|
|
210
|
+
): Promise<boolean> {
|
|
211
|
+
const revealConfig = await getRevealConfig(config, isDev)
|
|
212
|
+
const { pageConfigs } = revealConfig
|
|
213
|
+
const isV1Design = pageConfigs.length > 0
|
|
214
|
+
return isV1Design
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function loadInterfaceFiles(
|
|
218
|
+
userRootDir: string,
|
|
219
|
+
outDirRoot: string,
|
|
220
|
+
isDev: boolean,
|
|
221
|
+
crawlWithGit: null | boolean
|
|
222
|
+
): Promise<InterfaceFilesByLocationId> {
|
|
223
|
+
const plusFiles = await findPlusFiles(
|
|
224
|
+
userRootDir,
|
|
225
|
+
outDirRoot,
|
|
226
|
+
isDev,
|
|
227
|
+
crawlWithGit
|
|
228
|
+
)
|
|
229
|
+
const configFiles: FilePathResolved[] = []
|
|
230
|
+
const valueFiles: FilePathResolved[] = []
|
|
231
|
+
plusFiles.forEach((f) => {
|
|
232
|
+
if (getConfigName(f.filePathAbsoluteFilesystem) === "config") {
|
|
233
|
+
configFiles.push(f)
|
|
234
|
+
} else {
|
|
235
|
+
valueFiles.push(f)
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
let interfaceFilesByLocationId: InterfaceFilesByLocationId = {}
|
|
240
|
+
|
|
241
|
+
await Promise.allSettled([
|
|
242
|
+
// Config files
|
|
243
|
+
...configFiles.map(async (filePath) => {
|
|
244
|
+
const { filePathAbsoluteUserRootDir } = filePath
|
|
245
|
+
assert(filePathAbsoluteUserRootDir)
|
|
246
|
+
const { configFile, extendsConfigs } = await loadConfigFile(
|
|
247
|
+
filePath,
|
|
248
|
+
userRootDir,
|
|
249
|
+
[],
|
|
250
|
+
false
|
|
251
|
+
)
|
|
252
|
+
assert(filePath.filePathAbsoluteUserRootDir)
|
|
253
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir)
|
|
254
|
+
const interfaceFile = getInterfaceFileFromConfigFile(
|
|
255
|
+
configFile,
|
|
256
|
+
false,
|
|
257
|
+
locationId
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
interfaceFilesByLocationId[locationId] =
|
|
261
|
+
interfaceFilesByLocationId[locationId] ?? []
|
|
262
|
+
interfaceFilesByLocationId[locationId]!.push(interfaceFile)
|
|
263
|
+
extendsConfigs.forEach((extendsConfig) => {
|
|
264
|
+
/* We purposely use the same locationId because the Reveal extension's config should only apply to where it's being extended from, for example:
|
|
265
|
+
```js
|
|
266
|
+
// /pages/admin/+config.js (Reveal extension)
|
|
267
|
+
import revealReact from 'reveal/config'
|
|
268
|
+
// Should only apply to /pages/marketing/** (Reveal extension)
|
|
269
|
+
export default { extends: [revealReact] } // Reveal extension
|
|
270
|
+
|
|
271
|
+
*/
|
|
272
|
+
const interfaceFile = getInterfaceFileFromConfigFile(
|
|
273
|
+
extendsConfig,
|
|
274
|
+
true,
|
|
275
|
+
locationId
|
|
276
|
+
)
|
|
277
|
+
assertExtensionsConventions(interfaceFile)
|
|
278
|
+
interfaceFilesByLocationId[locationId]!.push(interfaceFile)
|
|
279
|
+
})
|
|
280
|
+
}),
|
|
281
|
+
// Value files
|
|
282
|
+
...valueFiles.map(async (filePath) => {
|
|
283
|
+
const { filePathAbsoluteUserRootDir } = filePath
|
|
284
|
+
assert(filePathAbsoluteUserRootDir)
|
|
285
|
+
|
|
286
|
+
const configName = getConfigName(filePathAbsoluteUserRootDir)
|
|
287
|
+
assert(configName)
|
|
288
|
+
|
|
289
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir)
|
|
290
|
+
|
|
291
|
+
const interfaceFile: InterfaceValueFile = {
|
|
292
|
+
locationId,
|
|
293
|
+
filePath,
|
|
294
|
+
fileExportsByConfigName: {
|
|
295
|
+
[configName]: {},
|
|
296
|
+
},
|
|
297
|
+
isConfigFile: false,
|
|
298
|
+
isValueFile: true,
|
|
299
|
+
configName,
|
|
300
|
+
}
|
|
301
|
+
{
|
|
302
|
+
// We don't have access to the custom config definitions defined by the user yet.
|
|
303
|
+
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
304
|
+
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
305
|
+
const configDef = getConfigDefinitionOptional(
|
|
306
|
+
configDefinitionsBuiltIn,
|
|
307
|
+
configName
|
|
308
|
+
)
|
|
309
|
+
if (configDef && isLoadableAtBuildTime(configDef)) {
|
|
310
|
+
await loadValueFile(interfaceFile, configName, userRootDir)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
{
|
|
314
|
+
interfaceFilesByLocationId[locationId] =
|
|
315
|
+
interfaceFilesByLocationId[locationId] ?? []
|
|
316
|
+
interfaceFilesByLocationId[locationId]!.push(interfaceFile)
|
|
317
|
+
}
|
|
318
|
+
}),
|
|
319
|
+
])
|
|
320
|
+
|
|
321
|
+
assertAllConfigsAreKnown(interfaceFilesByLocationId)
|
|
322
|
+
|
|
323
|
+
return interfaceFilesByLocationId
|
|
324
|
+
}
|
|
325
|
+
function getInterfaceFileFromConfigFile(
|
|
326
|
+
configFile: ConfigFile,
|
|
327
|
+
isConfigExtend: boolean,
|
|
328
|
+
locationId: LocationId
|
|
329
|
+
): InterfaceFile {
|
|
330
|
+
const { fileExports, filePath, extendsFilePaths } = configFile
|
|
331
|
+
const interfaceFile: InterfaceConfigFile = {
|
|
332
|
+
locationId,
|
|
333
|
+
filePath,
|
|
334
|
+
fileExportsByConfigName: {},
|
|
335
|
+
isConfigFile: true,
|
|
336
|
+
isValueFile: false,
|
|
337
|
+
isConfigExtend,
|
|
338
|
+
extendsFilePaths,
|
|
339
|
+
}
|
|
340
|
+
const fileExport = getConfigFileExport(
|
|
341
|
+
fileExports,
|
|
342
|
+
filePath.filePathToShowToUser
|
|
343
|
+
)
|
|
344
|
+
Object.entries(fileExport).forEach(([configName, configValue]) => {
|
|
345
|
+
interfaceFile.fileExportsByConfigName[configName] = { configValue }
|
|
346
|
+
})
|
|
347
|
+
return interfaceFile
|
|
348
|
+
}
|
|
349
|
+
/** Show error message upon unknown config */
|
|
350
|
+
function assertAllConfigsAreKnown(
|
|
351
|
+
interfaceFilesByLocationId: InterfaceFilesByLocationId
|
|
352
|
+
) {
|
|
353
|
+
objectEntries(interfaceFilesByLocationId).forEach(
|
|
354
|
+
([locationId, interfaceFiles]) => {
|
|
355
|
+
const interfaceFilesRelevant = getInterfaceFilesRelevant(
|
|
356
|
+
interfaceFilesByLocationId,
|
|
357
|
+
locationId
|
|
358
|
+
)
|
|
359
|
+
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant)
|
|
360
|
+
interfaceFiles.forEach((interfaceFile) => {
|
|
361
|
+
Object.keys(interfaceFile.fileExportsByConfigName).forEach(
|
|
362
|
+
(configName) => {
|
|
363
|
+
assertConfigExists(
|
|
364
|
+
configName,
|
|
365
|
+
Object.keys(configDefinitions),
|
|
366
|
+
interfaceFile.filePath.filePathToShowToUser
|
|
367
|
+
)
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async function loadRevealConfig_withErrorHandling(
|
|
376
|
+
userRootDir: string,
|
|
377
|
+
outDirRoot: string,
|
|
378
|
+
isDev: boolean,
|
|
379
|
+
crawlWithGit: null | boolean,
|
|
380
|
+
tolerateInvalidConfig?: boolean
|
|
381
|
+
): Promise<RevealConfigObject> {
|
|
382
|
+
let hasError = false
|
|
383
|
+
let ret: RevealConfigObject | undefined
|
|
384
|
+
let err: unknown
|
|
385
|
+
try {
|
|
386
|
+
ret = await loadRevealConfig(userRootDir, outDirRoot, isDev, crawlWithGit)
|
|
387
|
+
} catch (err_) {
|
|
388
|
+
hasError = true
|
|
389
|
+
err = err_
|
|
390
|
+
}
|
|
391
|
+
if (!hasError) {
|
|
392
|
+
assert(ret)
|
|
393
|
+
assert(err === undefined)
|
|
394
|
+
isConfigInvalid_set(false)
|
|
395
|
+
return ret
|
|
396
|
+
} else {
|
|
397
|
+
assert(ret === undefined)
|
|
398
|
+
assert(err)
|
|
399
|
+
isConfigInvalid_set({ err })
|
|
400
|
+
if (!isDev) {
|
|
401
|
+
assert(getViteDevServer() === null)
|
|
402
|
+
throw err
|
|
403
|
+
} else {
|
|
404
|
+
logConfigError(err)
|
|
405
|
+
if (!tolerateInvalidConfig) {
|
|
406
|
+
devServerIsCorrupt = true
|
|
407
|
+
}
|
|
408
|
+
const dummyData: RevealConfigObject = {
|
|
409
|
+
pageConfigs: [],
|
|
410
|
+
pageConfigGlobal: {
|
|
411
|
+
configDefinitions: {},
|
|
412
|
+
configValueSources: {},
|
|
413
|
+
},
|
|
414
|
+
globalRevealConfig: {},
|
|
415
|
+
}
|
|
416
|
+
return dummyData
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async function loadRevealConfig(
|
|
421
|
+
userRootDir: string,
|
|
422
|
+
outDirRoot: string,
|
|
423
|
+
isDev: boolean,
|
|
424
|
+
crawlWithGit: null | boolean
|
|
425
|
+
): Promise<RevealConfigObject> {
|
|
426
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(
|
|
427
|
+
userRootDir,
|
|
428
|
+
outDirRoot,
|
|
429
|
+
isDev,
|
|
430
|
+
crawlWithGit
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
const importedFilesLoaded: ImportedFilesLoaded = {}
|
|
434
|
+
|
|
435
|
+
const { globalRevealConfig, pageConfigGlobal } = await getGlobalConfigs(
|
|
436
|
+
interfaceFilesByLocationId,
|
|
437
|
+
userRootDir,
|
|
438
|
+
importedFilesLoaded
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
const pageConfigs: PageConfigBuildTime[] = (
|
|
442
|
+
await Promise.allSettled(
|
|
443
|
+
objectEntries(interfaceFilesByLocationId)
|
|
444
|
+
.filter(([pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
445
|
+
.map(async ([locationId]) => {
|
|
446
|
+
const interfaceFilesRelevant = getInterfaceFilesRelevant(
|
|
447
|
+
interfaceFilesByLocationId,
|
|
448
|
+
locationId
|
|
449
|
+
)
|
|
450
|
+
const interfaceFilesRelevantList: InterfaceFile[] = Object.values(
|
|
451
|
+
interfaceFilesRelevant
|
|
452
|
+
).flat(1)
|
|
453
|
+
|
|
454
|
+
assertExtensionsPeerDependencies(interfaceFilesRelevantList)
|
|
455
|
+
|
|
456
|
+
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant)
|
|
457
|
+
|
|
458
|
+
// Load value files of custom config-only configs
|
|
459
|
+
await Promise.allSettled(
|
|
460
|
+
interfaceFilesRelevantList.map(async (interfaceFile) => {
|
|
461
|
+
if (!interfaceFile.isValueFile) return
|
|
462
|
+
const { configName } = interfaceFile
|
|
463
|
+
if (isGlobalConfig(configName)) return
|
|
464
|
+
const configDef = getConfigDefinition(
|
|
465
|
+
configDefinitions,
|
|
466
|
+
configName,
|
|
467
|
+
interfaceFile.filePath.filePathToShowToUser
|
|
468
|
+
)
|
|
469
|
+
if (!isLoadableAtBuildTime(configDef)) return
|
|
470
|
+
const isAlreadyLoaded =
|
|
471
|
+
interfacefileIsAlreaydLoaded(interfaceFile)
|
|
472
|
+
if (isAlreadyLoaded) return
|
|
473
|
+
// Value files of built-in configs should have already been loaded at loadInterfaceFiles()
|
|
474
|
+
assert(!(configName in configDefinitionsBuiltIn))
|
|
475
|
+
await loadValueFile(interfaceFile, configName, userRootDir)
|
|
476
|
+
})
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
let configValueSources: ConfigValueSources = {}
|
|
480
|
+
await Promise.allSettled(
|
|
481
|
+
objectEntries(configDefinitions)
|
|
482
|
+
.filter(([configName]) => !isGlobalConfig(configName))
|
|
483
|
+
.map(async ([configName, configDef]) => {
|
|
484
|
+
const sources = await resolveConfigValueSources(
|
|
485
|
+
configName,
|
|
486
|
+
configDef,
|
|
487
|
+
interfaceFilesRelevant,
|
|
488
|
+
userRootDir,
|
|
489
|
+
importedFilesLoaded
|
|
490
|
+
)
|
|
491
|
+
if (sources.length === 0) return
|
|
492
|
+
configValueSources[configName] = sources
|
|
493
|
+
})
|
|
494
|
+
)
|
|
495
|
+
configValueSources = sortConfigValueSources(
|
|
496
|
+
configValueSources,
|
|
497
|
+
locationId
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(
|
|
501
|
+
locationId,
|
|
502
|
+
configValueSources
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
applyEffectsAll(configValueSources, configDefinitions)
|
|
506
|
+
const configValuesComputed = getComputed(
|
|
507
|
+
configValueSources,
|
|
508
|
+
configDefinitions
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
assertUsageGlobalConfigs(
|
|
512
|
+
interfaceFilesRelevantList,
|
|
513
|
+
configDefinitions,
|
|
514
|
+
interfaceFilesByLocationId
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
const pageConfig: PageConfigBuildTime = {
|
|
518
|
+
pageId: locationId,
|
|
519
|
+
isErrorPage,
|
|
520
|
+
routeFilesystem,
|
|
521
|
+
configDefinitions,
|
|
522
|
+
configValueSources,
|
|
523
|
+
configValuesComputed,
|
|
524
|
+
}
|
|
525
|
+
return pageConfig
|
|
526
|
+
})
|
|
527
|
+
)
|
|
528
|
+
)
|
|
529
|
+
.filter(
|
|
530
|
+
(result): result is PromiseFulfilledResult<PageConfigBuildTime> =>
|
|
531
|
+
result.status === "fulfilled"
|
|
532
|
+
)
|
|
533
|
+
.map((result) => result.value)
|
|
534
|
+
|
|
535
|
+
assertPageConfigs(pageConfigs)
|
|
536
|
+
|
|
537
|
+
return { pageConfigs, pageConfigGlobal, globalRevealConfig }
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// TODO/soon: refactor
|
|
541
|
+
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
542
|
+
// - This assertUsage() message is slightly better: use this one for getGlobalConfigs()
|
|
543
|
+
// Global configs should be defined at global locations
|
|
544
|
+
function assertUsageGlobalConfigs(
|
|
545
|
+
interfaceFilesRelevantList: InterfaceFile[],
|
|
546
|
+
configDefinitions: ConfigDefinitions,
|
|
547
|
+
interfaceFilesByLocationId: InterfaceFilesByLocationId
|
|
548
|
+
) {
|
|
549
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
550
|
+
const configNames: string[] = []
|
|
551
|
+
if (interfaceFile.isValueFile) {
|
|
552
|
+
configNames.push(interfaceFile.configName)
|
|
553
|
+
} else {
|
|
554
|
+
configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName))
|
|
555
|
+
}
|
|
556
|
+
configNames.forEach((configName) => {
|
|
557
|
+
if (isGlobalConfig(configName)) return
|
|
558
|
+
const configDef = getConfigDefinition(
|
|
559
|
+
configDefinitions,
|
|
560
|
+
configName,
|
|
561
|
+
interfaceFile.filePath.filePathToShowToUser
|
|
562
|
+
)
|
|
563
|
+
if (configDef.global) {
|
|
564
|
+
const locationIds = objectKeys(interfaceFilesByLocationId)
|
|
565
|
+
if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
|
|
566
|
+
const interfaceFilesGlobal = objectFromEntries(
|
|
567
|
+
objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
568
|
+
return isGlobalLocation(locationId, locationIds)
|
|
569
|
+
})
|
|
570
|
+
)
|
|
571
|
+
const configFilesGlobal: string[] = []
|
|
572
|
+
objectEntries(interfaceFilesGlobal).forEach(
|
|
573
|
+
([locationId, interfaceFiles]) => {
|
|
574
|
+
assert(isGlobalLocation(locationId, locationIds))
|
|
575
|
+
interfaceFiles.forEach((interfaceFile) => {
|
|
576
|
+
if (!interfaceFile.isConfigFile) return
|
|
577
|
+
const {
|
|
578
|
+
filePath: { filePathAbsoluteUserRootDir },
|
|
579
|
+
} = interfaceFile
|
|
580
|
+
if (filePathAbsoluteUserRootDir) {
|
|
581
|
+
configFilesGlobal.push(filePathAbsoluteUserRootDir)
|
|
582
|
+
}
|
|
583
|
+
})
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
assertUsage(
|
|
587
|
+
false,
|
|
588
|
+
[
|
|
589
|
+
`${interfaceFile.filePath.filePathToShowToUser} sets the config ${pc.cyan(
|
|
590
|
+
configName
|
|
591
|
+
)} but it's a global config:`,
|
|
592
|
+
configFilesGlobal.length > 0
|
|
593
|
+
? `define ${pc.cyan(configName)} at ${joinEnglish(configFilesGlobal, "or")} instead.`
|
|
594
|
+
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead.`,
|
|
595
|
+
].join(" ")
|
|
596
|
+
)
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
})
|
|
600
|
+
})
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function deriveConfigEnvFromFileName(env: ConfigEnvInternal, fileName: string) {
|
|
604
|
+
env = { ...env }
|
|
605
|
+
if (fileName.includes(".server.")) {
|
|
606
|
+
env.server = true
|
|
607
|
+
env.client = false
|
|
608
|
+
} else if (fileName.includes(".client.")) {
|
|
609
|
+
env.client = true
|
|
610
|
+
env.server = false
|
|
611
|
+
} else if (fileName.includes(".shared.")) {
|
|
612
|
+
env.server = true
|
|
613
|
+
env.client = true
|
|
614
|
+
}
|
|
615
|
+
return env
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function assertPageConfigs(pageConfigs: PageConfigBuildTime[]) {
|
|
619
|
+
pageConfigs.forEach((pageConfig) => {
|
|
620
|
+
assertOnBeforeRenderEnv(pageConfig)
|
|
621
|
+
})
|
|
622
|
+
}
|
|
623
|
+
function assertOnBeforeRenderEnv(pageConfig: PageConfigBuildTime) {
|
|
624
|
+
const onBeforeRenderConfig = pageConfig.configValueSources.onBeforeRender?.[0]
|
|
625
|
+
if (!onBeforeRenderConfig) return
|
|
626
|
+
const onBeforeRenderEnv = onBeforeRenderConfig.configEnv
|
|
627
|
+
const isClientRouting = getConfigValueBuildTime(
|
|
628
|
+
pageConfig,
|
|
629
|
+
"clientRouting",
|
|
630
|
+
"boolean"
|
|
631
|
+
)
|
|
632
|
+
// When using Server Routing, loading a onBeforeRender() hook on the client-side hasn't any effect (the Server Routing's client runtime never calls it); it unnecessarily bloats client bundle sizes
|
|
633
|
+
assertUsage(
|
|
634
|
+
!(onBeforeRenderEnv.client && !isClientRouting),
|
|
635
|
+
`Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${pc.cyan(
|
|
636
|
+
JSON.stringify(onBeforeRenderEnv)
|
|
637
|
+
)} which doesn't make sense because the page is using Server Routing: onBeforeRender() can be run in the client only when using Client Routing.`
|
|
638
|
+
)
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function interfacefileIsAlreaydLoaded(interfaceFile: InterfaceFile): boolean {
|
|
642
|
+
const configMapValues = Object.values(interfaceFile.fileExportsByConfigName)
|
|
643
|
+
const isAlreadyLoaded = configMapValues.some((conf) => "configValue" in conf)
|
|
644
|
+
if (isAlreadyLoaded) {
|
|
645
|
+
assert(configMapValues.every((conf) => "configValue" in conf))
|
|
646
|
+
}
|
|
647
|
+
return isAlreadyLoaded
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function getInterfaceFilesRelevant(
|
|
651
|
+
interfaceFilesByLocationId: InterfaceFilesByLocationId,
|
|
652
|
+
locationIdPage: LocationId
|
|
653
|
+
): InterfaceFilesByLocationId {
|
|
654
|
+
const interfaceFilesRelevant = Object.fromEntries(
|
|
655
|
+
objectEntries(interfaceFilesByLocationId)
|
|
656
|
+
.filter(([locationId]) => {
|
|
657
|
+
return isInherited(locationId, locationIdPage)
|
|
658
|
+
})
|
|
659
|
+
.sort(([locationId1], [locationId2]) =>
|
|
660
|
+
sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage)
|
|
661
|
+
)
|
|
662
|
+
)
|
|
663
|
+
return interfaceFilesRelevant
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
async function getGlobalConfigs(
|
|
667
|
+
interfaceFilesByLocationId: InterfaceFilesByLocationId,
|
|
668
|
+
userRootDir: string,
|
|
669
|
+
importedFilesLoaded: ImportedFilesLoaded
|
|
670
|
+
) {
|
|
671
|
+
const locationIds = objectKeys(interfaceFilesByLocationId)
|
|
672
|
+
const interfaceFilesGlobal = objectFromEntries(
|
|
673
|
+
objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
674
|
+
return isGlobalLocation(locationId, locationIds)
|
|
675
|
+
})
|
|
676
|
+
)
|
|
677
|
+
|
|
678
|
+
// Validate that global configs live in global interface files
|
|
679
|
+
{
|
|
680
|
+
const interfaceFilesGlobalPaths: string[] = []
|
|
681
|
+
objectEntries(interfaceFilesGlobal).forEach(
|
|
682
|
+
([locationId, interfaceFiles]) => {
|
|
683
|
+
assert(isGlobalLocation(locationId, locationIds))
|
|
684
|
+
interfaceFiles.forEach(
|
|
685
|
+
({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
686
|
+
if (filePathAbsoluteUserRootDir) {
|
|
687
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir)
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
)
|
|
691
|
+
}
|
|
692
|
+
)
|
|
693
|
+
const globalPaths = Array.from(
|
|
694
|
+
new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p)))
|
|
695
|
+
)
|
|
696
|
+
objectEntries(interfaceFilesByLocationId).forEach(
|
|
697
|
+
([locationId, interfaceFiles]) => {
|
|
698
|
+
interfaceFiles.forEach((interfaceFile) => {
|
|
699
|
+
Object.keys(interfaceFile.fileExportsByConfigName).forEach(
|
|
700
|
+
(configName) => {
|
|
701
|
+
if (
|
|
702
|
+
!isGlobalLocation(locationId, locationIds) &&
|
|
703
|
+
isGlobalConfig(configName)
|
|
704
|
+
) {
|
|
705
|
+
assertUsage(
|
|
706
|
+
false,
|
|
707
|
+
[
|
|
708
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(
|
|
709
|
+
configName
|
|
710
|
+
)} which is global:`,
|
|
711
|
+
globalPaths.length
|
|
712
|
+
? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, "or")} instead`
|
|
713
|
+
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`,
|
|
714
|
+
].join(" ")
|
|
715
|
+
)
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
})
|
|
720
|
+
}
|
|
721
|
+
)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const globalRevealConfig: Record<string, unknown> = {}
|
|
725
|
+
const pageConfigGlobal: PageConfigGlobalBuildTime = {
|
|
726
|
+
configDefinitions: configDefinitionsBuiltInGlobal,
|
|
727
|
+
configValueSources: {},
|
|
728
|
+
}
|
|
729
|
+
await Promise.allSettled(
|
|
730
|
+
objectEntries(configDefinitionsBuiltInGlobal).map(
|
|
731
|
+
async ([configName, configDef]) => {
|
|
732
|
+
const sources = await resolveConfigValueSources(
|
|
733
|
+
configName,
|
|
734
|
+
configDef,
|
|
735
|
+
interfaceFilesGlobal,
|
|
736
|
+
userRootDir,
|
|
737
|
+
importedFilesLoaded
|
|
738
|
+
)
|
|
739
|
+
const configValueSource = sources[0]
|
|
740
|
+
if (!configValueSource) return
|
|
741
|
+
if (
|
|
742
|
+
configName === "onBeforeRoute" ||
|
|
743
|
+
configName === "onPrerenderStart"
|
|
744
|
+
) {
|
|
745
|
+
assert(!("value" in configValueSource))
|
|
746
|
+
pageConfigGlobal.configValueSources[configName] = [configValueSource]
|
|
747
|
+
} else {
|
|
748
|
+
assert("value" in configValueSource)
|
|
749
|
+
if (
|
|
750
|
+
configName === "prerender" &&
|
|
751
|
+
typeof configValueSource.value === "boolean"
|
|
752
|
+
)
|
|
753
|
+
return
|
|
754
|
+
const { filePathToShowToUser } = configValueSource.definedAtFilePath
|
|
755
|
+
assertWarning(
|
|
756
|
+
false,
|
|
757
|
+
`Being able to define config ${pc.cyan(
|
|
758
|
+
configName
|
|
759
|
+
)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${pc.cyan(
|
|
760
|
+
configName
|
|
761
|
+
)} in reveal's Vite plugin options instead.`,
|
|
762
|
+
{ onlyOnce: true }
|
|
763
|
+
)
|
|
764
|
+
globalRevealConfig[configName] = configValueSource.value
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
)
|
|
768
|
+
)
|
|
769
|
+
|
|
770
|
+
return { pageConfigGlobal, globalRevealConfig }
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
async function resolveConfigValueSources(
|
|
774
|
+
configName: string,
|
|
775
|
+
configDef: ConfigDefinitionInternal,
|
|
776
|
+
interfaceFilesRelevant: InterfaceFilesByLocationId,
|
|
777
|
+
userRootDir: string,
|
|
778
|
+
importedFilesLoaded: ImportedFilesLoaded
|
|
779
|
+
): Promise<ConfigValueSource[]> {
|
|
780
|
+
const sourcesInfo: Parameters<typeof getConfigValueSource>[] = []
|
|
781
|
+
|
|
782
|
+
// interfaceFilesRelevant is sorted by sortAfterInheritanceOrder()
|
|
783
|
+
for (const interfaceFiles of Object.values(interfaceFilesRelevant)) {
|
|
784
|
+
const interfaceFilesDefiningConfig = interfaceFiles.filter(
|
|
785
|
+
(interfaceFile) => interfaceFile.fileExportsByConfigName[configName]
|
|
786
|
+
)
|
|
787
|
+
if (interfaceFilesDefiningConfig.length === 0) continue
|
|
788
|
+
const visited = new WeakSet<InterfaceFile>()
|
|
789
|
+
const add = (interfaceFile: InterfaceFile) => {
|
|
790
|
+
assert(!visited.has(interfaceFile))
|
|
791
|
+
visited.add(interfaceFile)
|
|
792
|
+
const isHighestInheritancePrecedence = sourcesInfo.length === 0
|
|
793
|
+
sourcesInfo.push([
|
|
794
|
+
configName,
|
|
795
|
+
interfaceFile,
|
|
796
|
+
configDef,
|
|
797
|
+
userRootDir,
|
|
798
|
+
importedFilesLoaded,
|
|
799
|
+
isHighestInheritancePrecedence,
|
|
800
|
+
])
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// Main resolution logic
|
|
804
|
+
{
|
|
805
|
+
const interfaceValueFiles = interfaceFilesDefiningConfig
|
|
806
|
+
.filter(
|
|
807
|
+
(interfaceFile) =>
|
|
808
|
+
interfaceFile.isValueFile &&
|
|
809
|
+
// We consider side-effect configs (e.g. `export { frontmatter }` of .mdx files) later (i.e. with less priority)
|
|
810
|
+
interfaceFile.configName === configName
|
|
811
|
+
)
|
|
812
|
+
.sort(makeOrderDeterministic)
|
|
813
|
+
const interfaceConfigFiles = interfaceFilesDefiningConfig
|
|
814
|
+
.filter(
|
|
815
|
+
(interfaceFile) =>
|
|
816
|
+
interfaceFile.isConfigFile &&
|
|
817
|
+
// We consider value from extended configs (e.g. reveal-react) later (i.e. with less priority)
|
|
818
|
+
!interfaceFile.isConfigExtend
|
|
819
|
+
)
|
|
820
|
+
.sort(makeOrderDeterministic)
|
|
821
|
+
const interfaceValueFile = interfaceValueFiles[0]
|
|
822
|
+
const interfaceConfigFile = interfaceConfigFiles[0]
|
|
823
|
+
// Make this value:
|
|
824
|
+
// /pages/some-page/+{configName}.js > `export default`
|
|
825
|
+
// override that value:
|
|
826
|
+
// /pages/some-page/+config.js > `export default { someConfig }`
|
|
827
|
+
const interfaceFileWinner = interfaceValueFile ?? interfaceConfigFile
|
|
828
|
+
if (interfaceFileWinner) {
|
|
829
|
+
const interfaceFilesOverriden = [
|
|
830
|
+
...interfaceValueFiles,
|
|
831
|
+
...interfaceConfigFiles,
|
|
832
|
+
].filter((f) => f !== interfaceFileWinner)
|
|
833
|
+
// A user-land conflict of interfaceFiles with the same locationId means that the user has superfluously defined the config twice; the user should remove such redundancy making things unnecessarily ambiguous
|
|
834
|
+
warnOverridenConfigValues(
|
|
835
|
+
interfaceFileWinner,
|
|
836
|
+
interfaceFilesOverriden,
|
|
837
|
+
configName
|
|
838
|
+
)
|
|
839
|
+
;[interfaceFileWinner, ...interfaceFilesOverriden].forEach(
|
|
840
|
+
(interfaceFile) => {
|
|
841
|
+
add(interfaceFile)
|
|
842
|
+
}
|
|
843
|
+
)
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// Side-effect configs such as `export { frontmatter }` in .mdx files
|
|
848
|
+
interfaceFilesDefiningConfig
|
|
849
|
+
.filter(
|
|
850
|
+
(interfaceFile) =>
|
|
851
|
+
interfaceFile.isValueFile &&
|
|
852
|
+
// Is side-effect config
|
|
853
|
+
interfaceFile.configName !== configName
|
|
854
|
+
)
|
|
855
|
+
.forEach((interfaceValueFileSideEffect) => {
|
|
856
|
+
add(interfaceValueFileSideEffect)
|
|
857
|
+
})
|
|
858
|
+
|
|
859
|
+
// extends
|
|
860
|
+
interfaceFilesDefiningConfig
|
|
861
|
+
.filter(
|
|
862
|
+
(interfaceFile) =>
|
|
863
|
+
interfaceFile.isConfigFile && interfaceFile.isConfigExtend
|
|
864
|
+
)
|
|
865
|
+
// extended config files are already sorted by inheritance order
|
|
866
|
+
.forEach((interfaceFile) => {
|
|
867
|
+
add(interfaceFile)
|
|
868
|
+
})
|
|
869
|
+
|
|
870
|
+
interfaceFilesDefiningConfig.forEach((interfaceFile) => {
|
|
871
|
+
assert(visited.has(interfaceFile))
|
|
872
|
+
})
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
const sourcesSettled = await Promise.allSettled(
|
|
876
|
+
sourcesInfo.map(async (args) => await getConfigValueSource(...args))
|
|
877
|
+
)
|
|
878
|
+
const sources: ConfigValueSource[] = sourcesSettled
|
|
879
|
+
.filter(
|
|
880
|
+
(result): result is PromiseFulfilledResult<ConfigValueSource> =>
|
|
881
|
+
result.status === "fulfilled"
|
|
882
|
+
)
|
|
883
|
+
.map((result) => result.value)
|
|
884
|
+
return sources
|
|
885
|
+
}
|
|
886
|
+
function makeOrderDeterministic(
|
|
887
|
+
interfaceFile1: InterfaceFile,
|
|
888
|
+
interfaceFile2: InterfaceFile
|
|
889
|
+
): 0 | -1 | 1 {
|
|
890
|
+
return lowerFirst<InterfaceFile>((interfaceFile) => {
|
|
891
|
+
const { filePathAbsoluteUserRootDir } = interfaceFile.filePath
|
|
892
|
+
assert(isInterfaceFileUserLand(interfaceFile))
|
|
893
|
+
assert(filePathAbsoluteUserRootDir)
|
|
894
|
+
return filePathAbsoluteUserRootDir.length
|
|
895
|
+
})(interfaceFile1, interfaceFile2)
|
|
896
|
+
}
|
|
897
|
+
function warnOverridenConfigValues(
|
|
898
|
+
interfaceFileWinner: InterfaceFile,
|
|
899
|
+
interfaceFilesOverriden: InterfaceFile[],
|
|
900
|
+
configName: string
|
|
901
|
+
) {
|
|
902
|
+
interfaceFilesOverriden.forEach((interfaceFileLoser) => {
|
|
903
|
+
const loserFilePath = interfaceFileLoser.filePath.filePathToShowToUser
|
|
904
|
+
const winnerFilePath = interfaceFileWinner.filePath.filePathToShowToUser
|
|
905
|
+
const confName = pc.cyan(configName)
|
|
906
|
+
assertWarning(
|
|
907
|
+
false,
|
|
908
|
+
`The value of the config ${confName} defined at ${loserFilePath} is always overwritten by the value defined at ${winnerFilePath}, remove the superfluous value defined at ${loserFilePath}`,
|
|
909
|
+
{ onlyOnce: true }
|
|
910
|
+
)
|
|
911
|
+
})
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function isInterfaceFileUserLand(interfaceFile: InterfaceFile) {
|
|
915
|
+
return (
|
|
916
|
+
(interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) ||
|
|
917
|
+
interfaceFile.isValueFile
|
|
918
|
+
)
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
async function getConfigValueSource(
|
|
922
|
+
configName: string,
|
|
923
|
+
interfaceFile: InterfaceFile,
|
|
924
|
+
configDef: ConfigDefinitionInternal,
|
|
925
|
+
userRootDir: string,
|
|
926
|
+
importedFilesLoaded: ImportedFilesLoaded,
|
|
927
|
+
isHighestInheritancePrecedence: boolean
|
|
928
|
+
): Promise<ConfigValueSource> {
|
|
929
|
+
const conf = interfaceFile.fileExportsByConfigName[configName]
|
|
930
|
+
assert(conf)
|
|
931
|
+
const configEnv = deriveConfigEnvFromFileName(
|
|
932
|
+
configDef.env,
|
|
933
|
+
interfaceFile.filePath.fileName
|
|
934
|
+
)
|
|
935
|
+
const { locationId } = interfaceFile
|
|
936
|
+
|
|
937
|
+
const definedAtFilePath_: DefinedAtFilePath = {
|
|
938
|
+
...interfaceFile.filePath,
|
|
939
|
+
fileExportPathToShowToUser: ["default", configName],
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
const isOverriden = configDef.cumulative
|
|
943
|
+
? false
|
|
944
|
+
: !isHighestInheritancePrecedence
|
|
945
|
+
|
|
946
|
+
// +client.js
|
|
947
|
+
if (configDef._valueIsFilePath) {
|
|
948
|
+
let definedAtFilePath: DefinedAtFilePath
|
|
949
|
+
let valueFilePath: string
|
|
950
|
+
if (interfaceFile.isConfigFile) {
|
|
951
|
+
const { configValue } = conf
|
|
952
|
+
const pointerImport = resolvePointerImportOfConfig(
|
|
953
|
+
configValue,
|
|
954
|
+
interfaceFile.filePath,
|
|
955
|
+
userRootDir,
|
|
956
|
+
configEnv,
|
|
957
|
+
configName
|
|
958
|
+
)
|
|
959
|
+
const configDefinedAt = getConfigDefinedAt(
|
|
960
|
+
"Config",
|
|
961
|
+
configName,
|
|
962
|
+
definedAtFilePath_
|
|
963
|
+
)
|
|
964
|
+
assertUsage(pointerImport, `${configDefinedAt} should be an import`)
|
|
965
|
+
valueFilePath = pointerImport.filePathAbsoluteVite
|
|
966
|
+
definedAtFilePath = pointerImport
|
|
967
|
+
} else {
|
|
968
|
+
assert(interfaceFile.isValueFile)
|
|
969
|
+
valueFilePath = interfaceFile.filePath.filePathAbsoluteVite
|
|
970
|
+
definedAtFilePath = {
|
|
971
|
+
...interfaceFile.filePath,
|
|
972
|
+
fileExportPathToShowToUser: [],
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
const configValueSource: ConfigValueSource = {
|
|
976
|
+
locationId,
|
|
977
|
+
value: valueFilePath,
|
|
978
|
+
valueIsFilePath: true,
|
|
979
|
+
configEnv,
|
|
980
|
+
valueIsImportedAtRuntime: true,
|
|
981
|
+
valueIsDefinedByPlusFile: false,
|
|
982
|
+
isOverriden,
|
|
983
|
+
definedAtFilePath,
|
|
984
|
+
}
|
|
985
|
+
return configValueSource
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// +config.js
|
|
989
|
+
if (interfaceFile.isConfigFile) {
|
|
990
|
+
assert("configValue" in conf)
|
|
991
|
+
const { configValue } = conf
|
|
992
|
+
|
|
993
|
+
// Pointer import
|
|
994
|
+
const pointerImport = resolvePointerImportOfConfig(
|
|
995
|
+
configValue,
|
|
996
|
+
interfaceFile.filePath,
|
|
997
|
+
userRootDir,
|
|
998
|
+
configEnv,
|
|
999
|
+
configName
|
|
1000
|
+
)
|
|
1001
|
+
if (pointerImport) {
|
|
1002
|
+
const configValueSource: ConfigValueSource = {
|
|
1003
|
+
locationId,
|
|
1004
|
+
configEnv,
|
|
1005
|
+
valueIsImportedAtRuntime: true,
|
|
1006
|
+
valueIsDefinedByPlusFile: false,
|
|
1007
|
+
isOverriden,
|
|
1008
|
+
definedAtFilePath: pointerImport,
|
|
1009
|
+
}
|
|
1010
|
+
// Load pointer import
|
|
1011
|
+
if (
|
|
1012
|
+
isLoadableAtBuildTime(configDef) &&
|
|
1013
|
+
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
1014
|
+
configName !== "extends"
|
|
1015
|
+
) {
|
|
1016
|
+
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
1017
|
+
const fileExport = await loadImportedFile(
|
|
1018
|
+
pointerImport,
|
|
1019
|
+
userRootDir,
|
|
1020
|
+
importedFilesLoaded
|
|
1021
|
+
)
|
|
1022
|
+
configValueSource.value = fileExport
|
|
1023
|
+
} else {
|
|
1024
|
+
const configDefinedAt = getConfigDefinedAt(
|
|
1025
|
+
"Config",
|
|
1026
|
+
configName,
|
|
1027
|
+
configValueSource.definedAtFilePath
|
|
1028
|
+
)
|
|
1029
|
+
assertUsage(
|
|
1030
|
+
!configDef.cumulative,
|
|
1031
|
+
`${configDefinedAt} cannot be defined over an aliased import`
|
|
1032
|
+
)
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
return configValueSource
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Defined by config file, i.e. +config.js file
|
|
1040
|
+
const configValueSource: ConfigValueSource = {
|
|
1041
|
+
locationId,
|
|
1042
|
+
value: configValue,
|
|
1043
|
+
configEnv,
|
|
1044
|
+
valueIsImportedAtRuntime: false,
|
|
1045
|
+
valueIsDefinedByPlusFile: false,
|
|
1046
|
+
isOverriden,
|
|
1047
|
+
definedAtFilePath: definedAtFilePath_,
|
|
1048
|
+
}
|
|
1049
|
+
return configValueSource
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// Defined by value file, i.e. +{configName}.js
|
|
1053
|
+
if (interfaceFile.isValueFile) {
|
|
1054
|
+
const valueAlreadyLoaded = "configValue" in conf
|
|
1055
|
+
assert(valueAlreadyLoaded === !!configEnv.config)
|
|
1056
|
+
const configValueSource: ConfigValueSource = {
|
|
1057
|
+
locationId,
|
|
1058
|
+
configEnv,
|
|
1059
|
+
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
1060
|
+
valueIsDefinedByPlusFile: true,
|
|
1061
|
+
isOverriden,
|
|
1062
|
+
definedAtFilePath: {
|
|
1063
|
+
...interfaceFile.filePath,
|
|
1064
|
+
fileExportPathToShowToUser:
|
|
1065
|
+
configName === interfaceFile.configName
|
|
1066
|
+
? []
|
|
1067
|
+
: // Side-effect config (e.g. `export { frontmatter }` of .md files)
|
|
1068
|
+
[configName],
|
|
1069
|
+
},
|
|
1070
|
+
}
|
|
1071
|
+
if (valueAlreadyLoaded) {
|
|
1072
|
+
configValueSource.value = conf.configValue
|
|
1073
|
+
}
|
|
1074
|
+
return configValueSource
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
assert(false)
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function isDefiningPage(interfaceFiles: InterfaceFile[]): boolean {
|
|
1081
|
+
for (const interfaceFile of interfaceFiles) {
|
|
1082
|
+
const configNames = Object.keys(interfaceFile.fileExportsByConfigName)
|
|
1083
|
+
if (configNames.some((configName) => isDefiningPageConfig(configName))) {
|
|
1084
|
+
return true
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return false
|
|
1088
|
+
}
|
|
1089
|
+
function isDefiningPageConfig(configName: string): boolean {
|
|
1090
|
+
return ["Page", "route"].includes(configName)
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
function getConfigDefinitions(
|
|
1094
|
+
interfaceFilesRelevant: InterfaceFilesByLocationId
|
|
1095
|
+
): ConfigDefinitions {
|
|
1096
|
+
const configDefinitionsMerged: ConfigDefinitions = {
|
|
1097
|
+
...configDefinitionsBuiltIn,
|
|
1098
|
+
}
|
|
1099
|
+
Object.entries(interfaceFilesRelevant)
|
|
1100
|
+
.reverse()
|
|
1101
|
+
.forEach(([_locationId, interfaceFiles]) => {
|
|
1102
|
+
interfaceFiles.forEach((interfaceFile) => {
|
|
1103
|
+
const configMeta = interfaceFile.fileExportsByConfigName["meta"]
|
|
1104
|
+
if (!configMeta) return
|
|
1105
|
+
const meta = configMeta.configValue
|
|
1106
|
+
assertMetaUsage(
|
|
1107
|
+
meta,
|
|
1108
|
+
`Config ${pc.cyan("meta")} defined at ${interfaceFile.filePath.filePathToShowToUser}`
|
|
1109
|
+
)
|
|
1110
|
+
|
|
1111
|
+
// Set configDef._userEffectDefinedAtFilePath
|
|
1112
|
+
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
1113
|
+
if (!configDef.effect) return
|
|
1114
|
+
assert(interfaceFile.isConfigFile)
|
|
1115
|
+
configDef._userEffectDefinedAtFilePath = {
|
|
1116
|
+
...interfaceFile.filePath,
|
|
1117
|
+
fileExportPathToShowToUser: [
|
|
1118
|
+
"default",
|
|
1119
|
+
"meta",
|
|
1120
|
+
configName,
|
|
1121
|
+
"effect",
|
|
1122
|
+
],
|
|
1123
|
+
}
|
|
1124
|
+
})
|
|
1125
|
+
|
|
1126
|
+
objectEntries(meta).forEach(([configName, configDefinition]) => {
|
|
1127
|
+
// User can override an existing config definition
|
|
1128
|
+
configDefinitionsMerged[configName] = {
|
|
1129
|
+
...configDefinitionsMerged[configName],
|
|
1130
|
+
...configDefinition,
|
|
1131
|
+
}
|
|
1132
|
+
})
|
|
1133
|
+
})
|
|
1134
|
+
})
|
|
1135
|
+
|
|
1136
|
+
const configDefinitions = configDefinitionsMerged
|
|
1137
|
+
return configDefinitions
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
function assertMetaUsage(
|
|
1141
|
+
metaVal: unknown,
|
|
1142
|
+
metaConfigDefinedAt: `Config meta defined at ${string}` | null
|
|
1143
|
+
): asserts metaVal is ConfigDefinitions {
|
|
1144
|
+
if (!isObject(metaVal)) {
|
|
1145
|
+
assert(metaConfigDefinedAt) // We expect internal effects to return a valid meta value
|
|
1146
|
+
assertUsage(
|
|
1147
|
+
false,
|
|
1148
|
+
`${metaConfigDefinedAt} has an invalid type ${pc.cyan(typeof metaVal)}: it should be an object instead.`
|
|
1149
|
+
)
|
|
1150
|
+
}
|
|
1151
|
+
objectEntries(metaVal).forEach(([configName, def]) => {
|
|
1152
|
+
if (!isObject(def)) {
|
|
1153
|
+
assert(metaConfigDefinedAt) // We expect internal effects to return a valid meta value
|
|
1154
|
+
assertUsage(
|
|
1155
|
+
false,
|
|
1156
|
+
`${metaConfigDefinedAt} sets ${pc.cyan(`meta.${configName}`)} to a value with an invalid type ${pc.cyan(
|
|
1157
|
+
typeof def
|
|
1158
|
+
)}: it should be an object instead.`
|
|
1159
|
+
)
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// env
|
|
1163
|
+
let configEnv: ConfigEnvInternal
|
|
1164
|
+
{
|
|
1165
|
+
assert(metaConfigDefinedAt) // We expect internal effects to return a valid meta value
|
|
1166
|
+
if (!("env" in def)) {
|
|
1167
|
+
assertUsage(
|
|
1168
|
+
false,
|
|
1169
|
+
`${metaConfigDefinedAt} doesn't set ${pc.cyan(`meta.${configName}.env`)} but it's required.`
|
|
1170
|
+
)
|
|
1171
|
+
}
|
|
1172
|
+
configEnv = getConfigEnvValue(
|
|
1173
|
+
def.env,
|
|
1174
|
+
`${metaConfigDefinedAt} sets ${pc.cyan(`meta.${configName}.env`)} to`
|
|
1175
|
+
)
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// effect
|
|
1179
|
+
if ("effect" in def) {
|
|
1180
|
+
if (!hasProp(def, "effect", "function")) {
|
|
1181
|
+
assert(metaConfigDefinedAt) // We expect internal effects to return a valid meta value
|
|
1182
|
+
assertUsage(
|
|
1183
|
+
false,
|
|
1184
|
+
`${metaConfigDefinedAt} sets ${pc.cyan(`meta.${configName}.effect`)} to an invalid type ${pc.cyan(
|
|
1185
|
+
typeof def.effect
|
|
1186
|
+
)}: it should be a function instead`
|
|
1187
|
+
)
|
|
1188
|
+
}
|
|
1189
|
+
if (!configEnv.config) {
|
|
1190
|
+
assert(metaConfigDefinedAt) // We expect internal effects to return a valid meta value
|
|
1191
|
+
assertUsage(
|
|
1192
|
+
false,
|
|
1193
|
+
`${metaConfigDefinedAt} sets ${pc.cyan(
|
|
1194
|
+
`meta.${configName}.effect`
|
|
1195
|
+
)} but it's only supported if meta.${configName}.env has ${pc.cyan("{ config: true }")} (but it's ${pc.cyan(
|
|
1196
|
+
JSON.stringify(configEnv)
|
|
1197
|
+
)} instead)`
|
|
1198
|
+
)
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
})
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function applyEffectsAll(
|
|
1205
|
+
configValueSources: ConfigValueSources,
|
|
1206
|
+
configDefinitions: ConfigDefinitions
|
|
1207
|
+
) {
|
|
1208
|
+
objectEntries(configDefinitions).forEach(([configName, configDef]) => {
|
|
1209
|
+
if (!configDef.effect) return
|
|
1210
|
+
// The value needs to be loaded at config time, that's why we only support effect for configs that are config-only for now.
|
|
1211
|
+
// (We could support effect for non config-only by always loading its value at config time, regardless of the config's `env` value.)
|
|
1212
|
+
assertUsage(
|
|
1213
|
+
configDef.env.config,
|
|
1214
|
+
[
|
|
1215
|
+
`Cannot add effect to ${pc.cyan(configName)} because its ${pc.cyan("env")} is ${pc.cyan(
|
|
1216
|
+
JSON.stringify(configDef.env)
|
|
1217
|
+
)}: effects can only be added to configs with an ${pc.cyan("env")} with ${pc.cyan("{ config: true }")}.`,
|
|
1218
|
+
].join(" ")
|
|
1219
|
+
)
|
|
1220
|
+
const source = configValueSources[configName]?.[0]
|
|
1221
|
+
if (!source) return
|
|
1222
|
+
// The config value is eagerly loaded since `configDef.env === 'config-only``
|
|
1223
|
+
assert("value" in source)
|
|
1224
|
+
// Call effect
|
|
1225
|
+
const configModFromEffect = configDef.effect({
|
|
1226
|
+
configValue: source.value,
|
|
1227
|
+
configDefinedAt: getConfigDefinedAt(
|
|
1228
|
+
"Config",
|
|
1229
|
+
configName,
|
|
1230
|
+
source.definedAtFilePath
|
|
1231
|
+
),
|
|
1232
|
+
})
|
|
1233
|
+
if (!configModFromEffect) return
|
|
1234
|
+
assert(hasProp(source, "value")) // We need to assume that the config value is loaded at build-time
|
|
1235
|
+
applyEffect(configModFromEffect, configValueSources, configDef)
|
|
1236
|
+
})
|
|
1237
|
+
}
|
|
1238
|
+
function applyEffect(
|
|
1239
|
+
configModFromEffect: Config,
|
|
1240
|
+
configValueSources: ConfigValueSources,
|
|
1241
|
+
configDefEffect: ConfigDefinitionInternal
|
|
1242
|
+
) {
|
|
1243
|
+
const notSupported =
|
|
1244
|
+
`Effects currently only supports modifying the the ${pc.cyan("env")} of a config.` as const
|
|
1245
|
+
objectEntries(configModFromEffect).forEach(([configName, configValue]) => {
|
|
1246
|
+
if (configName === "meta") {
|
|
1247
|
+
let configDefinedAt: Parameters<typeof assertMetaUsage>[1]
|
|
1248
|
+
if (configDefEffect._userEffectDefinedAtFilePath) {
|
|
1249
|
+
configDefinedAt = getConfigDefinedAt(
|
|
1250
|
+
"Config",
|
|
1251
|
+
configName,
|
|
1252
|
+
configDefEffect._userEffectDefinedAtFilePath
|
|
1253
|
+
)
|
|
1254
|
+
} else {
|
|
1255
|
+
configDefinedAt = null
|
|
1256
|
+
}
|
|
1257
|
+
assertMetaUsage(configValue, configDefinedAt)
|
|
1258
|
+
objectEntries(configValue).forEach(
|
|
1259
|
+
([configTargetName, configTargetDef]) => {
|
|
1260
|
+
{
|
|
1261
|
+
const keys = Object.keys(configTargetDef)
|
|
1262
|
+
assertUsage(keys.includes("env"), notSupported)
|
|
1263
|
+
assertUsage(keys.length === 1, notSupported)
|
|
1264
|
+
}
|
|
1265
|
+
const envOverriden = configTargetDef.env
|
|
1266
|
+
const sources = configValueSources[configTargetName]
|
|
1267
|
+
sources?.forEach((configValueSource) => {
|
|
1268
|
+
// Apply effect
|
|
1269
|
+
configValueSource.configEnv = envOverriden
|
|
1270
|
+
})
|
|
1271
|
+
}
|
|
1272
|
+
)
|
|
1273
|
+
} else {
|
|
1274
|
+
assertUsage(false, notSupported)
|
|
1275
|
+
/* To implement being able to set a config value in an effect:
|
|
1276
|
+
* - Copy and append definedAtFile.fileExportPathToShowToUser with ['meta', configName, 'effect']
|
|
1277
|
+
* - Copying the definedAtFile of the config that defines the effect
|
|
1278
|
+
* - Same precedence as the config that sets the value triggering the effect (not the config defining the effect)
|
|
1279
|
+
* - Apply sortConfigValueSources() again?
|
|
1280
|
+
configValueSources.push()
|
|
1281
|
+
*/
|
|
1282
|
+
}
|
|
1283
|
+
})
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function getComputed(
|
|
1287
|
+
configValueSources: ConfigValueSources,
|
|
1288
|
+
configDefinitions: ConfigDefinitions
|
|
1289
|
+
) {
|
|
1290
|
+
const configValuesComputed: ConfigValuesComputed = {}
|
|
1291
|
+
objectEntries(configDefinitions).forEach(([configName, configDef]) => {
|
|
1292
|
+
if (!configDef._computed) return
|
|
1293
|
+
const value = configDef._computed(configValueSources)
|
|
1294
|
+
if (value === undefined) return
|
|
1295
|
+
configValuesComputed[configName] = {
|
|
1296
|
+
value,
|
|
1297
|
+
configEnv: configDef.env,
|
|
1298
|
+
}
|
|
1299
|
+
})
|
|
1300
|
+
return configValuesComputed
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
async function findPlusFiles(
|
|
1304
|
+
userRootDir: string,
|
|
1305
|
+
outDirRoot: string,
|
|
1306
|
+
isDev: boolean,
|
|
1307
|
+
crawlWithGit: null | boolean
|
|
1308
|
+
): Promise<FilePathResolved[]> {
|
|
1309
|
+
const files = await crawlPlusFiles(
|
|
1310
|
+
userRootDir,
|
|
1311
|
+
outDirRoot,
|
|
1312
|
+
isDev,
|
|
1313
|
+
crawlWithGit
|
|
1314
|
+
)
|
|
1315
|
+
|
|
1316
|
+
const plusFiles: FilePathResolved[] = files.map(
|
|
1317
|
+
({ filePathAbsoluteUserRootDir }) =>
|
|
1318
|
+
getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir })
|
|
1319
|
+
)
|
|
1320
|
+
|
|
1321
|
+
return plusFiles
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function getConfigName(filePath: string): string | null {
|
|
1325
|
+
assertPosixPath(filePath)
|
|
1326
|
+
if (isTemporaryBuildFile(filePath)) return null
|
|
1327
|
+
const fileName = path.posix.basename(filePath)
|
|
1328
|
+
assertNoUnexpectedPlusSign(filePath, fileName)
|
|
1329
|
+
const basename = fileName.split(".")[0]!
|
|
1330
|
+
if (!basename.startsWith("+")) {
|
|
1331
|
+
return null
|
|
1332
|
+
} else {
|
|
1333
|
+
const configName = basename.slice(1)
|
|
1334
|
+
assertUsage(configName !== "", `${filePath} Invalid filename ${fileName}`)
|
|
1335
|
+
return configName
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
/* https://github.com/revealjs/reveal/issues/1407 */
|
|
1339
|
+
function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
1340
|
+
const dirs = path.posix.dirname(filePath).split("/")
|
|
1341
|
+
dirs.forEach((dir, i) => {
|
|
1342
|
+
const dirPath = dirs.slice(0, i + 1).join("/")
|
|
1343
|
+
assertUsage(
|
|
1344
|
+
!dir.includes("+"),
|
|
1345
|
+
`Character '+' is a reserved character: remove '+' from the directory name ${dirPath}/`
|
|
1346
|
+
)
|
|
1347
|
+
})
|
|
1348
|
+
assertUsage(
|
|
1349
|
+
!fileName.slice(1).includes("+"),
|
|
1350
|
+
`Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`
|
|
1351
|
+
)
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function handleUnknownConfig(
|
|
1355
|
+
configName: string,
|
|
1356
|
+
configNames: string[],
|
|
1357
|
+
filePathToShowToUser: string
|
|
1358
|
+
) {
|
|
1359
|
+
const configNameColored = pc.cyan(configName)
|
|
1360
|
+
let errMsg =
|
|
1361
|
+
`${filePathToShowToUser} sets an unknown config ${configNameColored}.` as const
|
|
1362
|
+
|
|
1363
|
+
// reveal-{react,vue,solid} hint
|
|
1364
|
+
{
|
|
1365
|
+
const ui = ["reveal"] as const
|
|
1366
|
+
const knownRevealExntensionConfigs = {
|
|
1367
|
+
description: ui,
|
|
1368
|
+
favicon: ui,
|
|
1369
|
+
Head: ui,
|
|
1370
|
+
Layout: ui,
|
|
1371
|
+
onCreateApp: ["reveal"],
|
|
1372
|
+
title: ui,
|
|
1373
|
+
ssr: ui,
|
|
1374
|
+
stream: ui,
|
|
1375
|
+
Wrapper: ui,
|
|
1376
|
+
} as const
|
|
1377
|
+
if (configName in knownRevealExntensionConfigs) {
|
|
1378
|
+
const requiredRevealExtension =
|
|
1379
|
+
knownRevealExntensionConfigs[
|
|
1380
|
+
configName as keyof typeof knownRevealExntensionConfigs
|
|
1381
|
+
]
|
|
1382
|
+
assertUsage(
|
|
1383
|
+
false,
|
|
1384
|
+
[
|
|
1385
|
+
errMsg,
|
|
1386
|
+
`If you want to use the configuration documented at https://reveal.dev/${configName} then make sure to install the reveal extension ${requiredRevealExtension
|
|
1387
|
+
.map((e) => pc.bold(e))
|
|
1388
|
+
.join("/")}.`,
|
|
1389
|
+
`Also make sure it applies to ${filePathToShowToUser} (see https://reveal.dev/extends#inheritance).`,
|
|
1390
|
+
`Alternatively, if you don't want to use the aforementioned reveal extension, define it yourself by using ${pc.cyan(
|
|
1391
|
+
"meta"
|
|
1392
|
+
)} (https://reveal.dev/meta).`,
|
|
1393
|
+
].join(" ")
|
|
1394
|
+
)
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// Similarity hint
|
|
1399
|
+
let configNameSimilar: string | null = null
|
|
1400
|
+
if (configName === "page") {
|
|
1401
|
+
configNameSimilar = "Page"
|
|
1402
|
+
} else {
|
|
1403
|
+
configNameSimilar = getMostSimilar(configName, configNames)
|
|
1404
|
+
}
|
|
1405
|
+
if (configNameSimilar) {
|
|
1406
|
+
assert(configNameSimilar !== configName)
|
|
1407
|
+
errMsg += ` Did you mean to set ${pc.cyan(configNameSimilar)} instead?`
|
|
1408
|
+
if (configName === "page") {
|
|
1409
|
+
errMsg += ` (The name of the config ${pc.cyan("Page")} starts with a capital letter ${pc.cyan(
|
|
1410
|
+
"P"
|
|
1411
|
+
)} because it defines a UI component: a ubiquitous JavaScript convention is that the name of UI components start with a capital letter.)`
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// `meta` hint
|
|
1416
|
+
if (!configNameSimilar) {
|
|
1417
|
+
errMsg += ` Make sure to define ${configNameColored} by using ${pc.cyan(
|
|
1418
|
+
"meta"
|
|
1419
|
+
)} (https://reveal.dev/meta), and also make sure the meta configuration applies to ${filePathToShowToUser} (see https://reveal.dev/config#inheritance).`
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
assertUsage(false, errMsg)
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function determineRouteFilesystem(
|
|
1426
|
+
locationId: LocationId,
|
|
1427
|
+
configValueSources: ConfigValueSources
|
|
1428
|
+
) {
|
|
1429
|
+
const configName = "filesystemRoutingRoot"
|
|
1430
|
+
const configFilesystemRoutingRoot = configValueSources[configName]?.[0]
|
|
1431
|
+
let filesystemRouteString = getFilesystemRouteString(locationId)
|
|
1432
|
+
if (determineIsErrorPage(filesystemRouteString)) {
|
|
1433
|
+
return { isErrorPage: true as const, routeFilesystem: undefined }
|
|
1434
|
+
}
|
|
1435
|
+
let filesystemRouteDefinedBy = getFilesystemRouteDefinedBy(locationId) // for log404()
|
|
1436
|
+
if (configFilesystemRoutingRoot) {
|
|
1437
|
+
const routingRoot = getFilesystemRoutingRootEffect(
|
|
1438
|
+
configFilesystemRoutingRoot,
|
|
1439
|
+
configName
|
|
1440
|
+
)
|
|
1441
|
+
if (routingRoot) {
|
|
1442
|
+
const {
|
|
1443
|
+
filesystemRoutingRootEffect,
|
|
1444
|
+
filesystemRoutingRootConfigDefinedAt,
|
|
1445
|
+
} = routingRoot
|
|
1446
|
+
const debugInfo = {
|
|
1447
|
+
locationId,
|
|
1448
|
+
routeFilesystem: filesystemRouteString,
|
|
1449
|
+
configFilesystemRoutingRoot,
|
|
1450
|
+
}
|
|
1451
|
+
assertLog(
|
|
1452
|
+
filesystemRouteString.startsWith(filesystemRoutingRootEffect.before),
|
|
1453
|
+
debugInfo
|
|
1454
|
+
)
|
|
1455
|
+
filesystemRouteString = applyFilesystemRoutingRootEffect(
|
|
1456
|
+
filesystemRouteString,
|
|
1457
|
+
filesystemRoutingRootEffect
|
|
1458
|
+
)
|
|
1459
|
+
filesystemRouteDefinedBy = `${filesystemRouteDefinedBy} (with ${filesystemRoutingRootConfigDefinedAt})`
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
assert(filesystemRouteString.startsWith("/"))
|
|
1463
|
+
const routeFilesystem = {
|
|
1464
|
+
routeString: filesystemRouteString,
|
|
1465
|
+
definedBy: filesystemRouteDefinedBy,
|
|
1466
|
+
}
|
|
1467
|
+
return { routeFilesystem, isErrorPage: undefined }
|
|
1468
|
+
}
|
|
1469
|
+
function getFilesystemRoutingRootEffect(
|
|
1470
|
+
configFilesystemRoutingRoot: ConfigValueSource,
|
|
1471
|
+
configName: "filesystemRoutingRoot"
|
|
1472
|
+
) {
|
|
1473
|
+
assert(configFilesystemRoutingRoot.configEnv.config)
|
|
1474
|
+
// Eagerly loaded since it's config-only
|
|
1475
|
+
assert("value" in configFilesystemRoutingRoot)
|
|
1476
|
+
const { value } = configFilesystemRoutingRoot
|
|
1477
|
+
const configDefinedAt = getConfigDefinedAt(
|
|
1478
|
+
"Config",
|
|
1479
|
+
configName,
|
|
1480
|
+
configFilesystemRoutingRoot.definedAtFilePath
|
|
1481
|
+
)
|
|
1482
|
+
assertUsage(
|
|
1483
|
+
typeof value === "string",
|
|
1484
|
+
`${configDefinedAt} should be a string`
|
|
1485
|
+
)
|
|
1486
|
+
assertUsage(
|
|
1487
|
+
value.startsWith("/"),
|
|
1488
|
+
`${configDefinedAt} is ${pc.cyan(value)} but it should start with a leading slash ${pc.cyan("/")}`
|
|
1489
|
+
)
|
|
1490
|
+
const { filePathAbsoluteUserRootDir } =
|
|
1491
|
+
configFilesystemRoutingRoot.definedAtFilePath
|
|
1492
|
+
assert(filePathAbsoluteUserRootDir)
|
|
1493
|
+
const before = getFilesystemRouteString(
|
|
1494
|
+
getLocationId(filePathAbsoluteUserRootDir)
|
|
1495
|
+
)
|
|
1496
|
+
const after = value
|
|
1497
|
+
const filesystemRoutingRootEffect = { before, after }
|
|
1498
|
+
return {
|
|
1499
|
+
filesystemRoutingRootEffect,
|
|
1500
|
+
filesystemRoutingRootConfigDefinedAt: configDefinedAt,
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
function determineIsErrorPage(routeFilesystem: string) {
|
|
1504
|
+
assertPosixPath(routeFilesystem)
|
|
1505
|
+
return routeFilesystem.split("/").includes("_error")
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
function isRevealConfigFile(filePath: string): boolean {
|
|
1509
|
+
return !!getConfigName(filePath)
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
function getConfigEnvValue(
|
|
1513
|
+
val: unknown,
|
|
1514
|
+
errMsgIntro: `Config meta defined at ${string} sets meta.${
|
|
1515
|
+
string // configName
|
|
1516
|
+
}.env to`
|
|
1517
|
+
): ConfigEnvInternal {
|
|
1518
|
+
const errInvalidValue = `${errMsgIntro} an invalid value ${pc.cyan(JSON.stringify(val))}`
|
|
1519
|
+
|
|
1520
|
+
assertUsage(
|
|
1521
|
+
isObject(val),
|
|
1522
|
+
`${errMsgIntro} an invalid type ${pc.cyan(typeof val)}`
|
|
1523
|
+
)
|
|
1524
|
+
|
|
1525
|
+
assertKeys(
|
|
1526
|
+
val,
|
|
1527
|
+
["config", "server", "client"] as const,
|
|
1528
|
+
`${errInvalidValue}:`
|
|
1529
|
+
)
|
|
1530
|
+
assertUsage(
|
|
1531
|
+
hasProp(val, "config", "undefined") || hasProp(val, "config", "boolean"),
|
|
1532
|
+
errInvalidValue
|
|
1533
|
+
)
|
|
1534
|
+
assertUsage(
|
|
1535
|
+
hasProp(val, "server", "undefined") || hasProp(val, "server", "boolean"),
|
|
1536
|
+
errInvalidValue
|
|
1537
|
+
)
|
|
1538
|
+
assertUsage(
|
|
1539
|
+
hasProp(val, "client", "undefined") || hasProp(val, "client", "boolean"),
|
|
1540
|
+
errInvalidValue
|
|
1541
|
+
)
|
|
1542
|
+
/* To allow users to set an eager config:
|
|
1543
|
+
* - Uncomment line below.
|
|
1544
|
+
* - Add 'eager' to assertKeys() call above.
|
|
1545
|
+
* - Add `eager: boolean` to ConfigEnv type.
|
|
1546
|
+
* */
|
|
1547
|
+
assertUsage(
|
|
1548
|
+
hasProp(val, "eager", "undefined") || hasProp(val, "eager", "boolean"),
|
|
1549
|
+
errInvalidValue
|
|
1550
|
+
)
|
|
1551
|
+
|
|
1552
|
+
return val
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
function getConfigDefinition(
|
|
1556
|
+
configDefinitions: ConfigDefinitions,
|
|
1557
|
+
configName: string,
|
|
1558
|
+
filePathToShowToUser: string
|
|
1559
|
+
) {
|
|
1560
|
+
const configDef = configDefinitions[configName]
|
|
1561
|
+
assertConfigExists(
|
|
1562
|
+
configName,
|
|
1563
|
+
Object.keys(configDefinitions),
|
|
1564
|
+
filePathToShowToUser
|
|
1565
|
+
)
|
|
1566
|
+
assert(configDef)
|
|
1567
|
+
return configDef
|
|
1568
|
+
}
|
|
1569
|
+
function getConfigDefinitionOptional(
|
|
1570
|
+
configDefinitions: ConfigDefinitions,
|
|
1571
|
+
configName: string
|
|
1572
|
+
) {
|
|
1573
|
+
return configDefinitions[configName] ?? null
|
|
1574
|
+
}
|
|
1575
|
+
function isLoadableAtBuildTime(configDef: ConfigDefinitionInternal): boolean {
|
|
1576
|
+
return !!configDef.env.config && !configDef._valueIsFilePath
|
|
1577
|
+
}
|
|
1578
|
+
function isGlobalConfig(configName: string): configName is ConfigNameGlobal {
|
|
1579
|
+
if (configName === "prerender") return false
|
|
1580
|
+
const configNamesGlobal = getConfigNamesGlobal()
|
|
1581
|
+
return includes(configNamesGlobal, configName)
|
|
1582
|
+
}
|
|
1583
|
+
function getConfigNamesGlobal() {
|
|
1584
|
+
return Object.keys(configDefinitionsBuiltInGlobal)
|
|
1585
|
+
}
|
|
1586
|
+
function assertConfigExists(
|
|
1587
|
+
configName: string,
|
|
1588
|
+
configNamesRelevant: string[],
|
|
1589
|
+
filePathToShowToUser: string
|
|
1590
|
+
) {
|
|
1591
|
+
const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()]
|
|
1592
|
+
if (configNames.includes(configName)) return
|
|
1593
|
+
handleUnknownConfig(configName, configNames, filePathToShowToUser)
|
|
1594
|
+
assert(false)
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
function sortConfigValueSources(
|
|
1598
|
+
configValueSources: ConfigValueSources,
|
|
1599
|
+
locationIdPage: LocationId
|
|
1600
|
+
): ConfigValueSources {
|
|
1601
|
+
return Object.fromEntries(
|
|
1602
|
+
Object.entries(configValueSources)
|
|
1603
|
+
// Make order deterministic (no other purpose)
|
|
1604
|
+
.sort(([, [source1]], [, [source2]]) =>
|
|
1605
|
+
source1!.definedAtFilePath.filePathAbsoluteVite <
|
|
1606
|
+
source2!.definedAtFilePath.filePathAbsoluteVite
|
|
1607
|
+
? -1
|
|
1608
|
+
: 1
|
|
1609
|
+
)
|
|
1610
|
+
// Sort after whether the config value was defined by an npm package
|
|
1611
|
+
.sort(
|
|
1612
|
+
makeFirst(([, [source]]) => {
|
|
1613
|
+
const { importPathAbsolute } = source!.definedAtFilePath
|
|
1614
|
+
return (
|
|
1615
|
+
!!importPathAbsolute &&
|
|
1616
|
+
isNpmPackageImport(importPathAbsolute, {
|
|
1617
|
+
// Reveal config files don't support path aliases. (If they do one day, then Reveal will/should be able to resolve path aliases.)
|
|
1618
|
+
cannotBePathAlias: true,
|
|
1619
|
+
})
|
|
1620
|
+
)
|
|
1621
|
+
})
|
|
1622
|
+
)
|
|
1623
|
+
// Sort after the filesystem inheritance of the config value
|
|
1624
|
+
.sort(([, [source1]], [, [source2]]) =>
|
|
1625
|
+
reverse(
|
|
1626
|
+
sortAfterInheritanceOrder(
|
|
1627
|
+
source1!.locationId,
|
|
1628
|
+
source2!.locationId,
|
|
1629
|
+
locationIdPage
|
|
1630
|
+
)
|
|
1631
|
+
)
|
|
1632
|
+
)
|
|
1633
|
+
)
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
function getConfigValueInterfaceFile(
|
|
1637
|
+
interfaceFile: InterfaceFile,
|
|
1638
|
+
configName: string
|
|
1639
|
+
): unknown {
|
|
1640
|
+
return interfaceFile.fileExportsByConfigName[configName]?.configValue
|
|
1641
|
+
}
|