tungsten 0.6.3 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-complete +1 -1
- package/dist/Brands.d.ts +16 -0
- package/dist/Brands.d.ts.map +1 -0
- package/dist/Brands.js +22 -0
- package/dist/Components.d.ts +4 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +24 -6
- package/dist/ContentNode.d.ts +3 -2
- package/dist/ContentNode.d.ts.map +1 -1
- package/dist/ContentNode.js +11 -0
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +23 -4
- package/dist/FrameworkConfig.d.ts +9 -1
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FrameworkConfig.types.test.d.ts +2 -0
- package/dist/FrameworkConfig.types.test.d.ts.map +1 -0
- package/dist/FrameworkConfig.types.test.js +6 -0
- package/dist/FunctionComponent.d.ts +1 -0
- package/dist/FunctionComponent.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/Instance/Instance.d.ts +21 -9
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +42 -38
- package/dist/Instance/InstanceConfig.d.ts +3 -1
- package/dist/Instance/InstanceConfig.d.ts.map +1 -1
- package/dist/RenderedContentNode.d.ts.map +1 -1
- package/dist/RenderingNode.d.ts.map +1 -1
- package/dist/Servers/DevServer.d.ts +4 -2
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +72 -21
- package/dist/Servers/ProdServer.d.ts +5 -2
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +95 -19
- package/dist/Servers/StaticSiteServer.d.ts +1 -1
- package/dist/Servers/StaticSiteServer.d.ts.map +1 -1
- package/dist/Servers/TungstenServer.d.ts +2 -1
- package/dist/Servers/TungstenServer.d.ts.map +1 -1
- package/dist/Servers/TungstenServer.js +7 -0
- package/dist/Servers/cacheVersioned.d.ts +3 -0
- package/dist/Servers/cacheVersioned.d.ts.map +1 -0
- package/dist/Servers/cacheVersioned.js +23 -0
- package/dist/Servers/devErrorPageAutoRetry.d.ts.map +1 -1
- package/dist/Servers/devErrorPageAutoRetry.js +1 -0
- package/dist/Servers/initStores.d.ts +4 -4
- package/dist/Servers/initStores.d.ts.map +1 -1
- package/dist/Servers/initStores.js +2 -2
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +7 -6
- package/dist/Servers/resetRegistrations.d.ts +2 -0
- package/dist/Servers/resetRegistrations.d.ts.map +1 -0
- package/dist/Servers/resetRegistrations.js +13 -0
- package/dist/Servers/routing.d.ts +3 -2
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +12 -7
- package/dist/Servers/stubInstance.d.ts +8 -0
- package/dist/Servers/stubInstance.d.ts.map +1 -0
- package/dist/Servers/stubInstance.js +40 -0
- package/dist/Store/InternalStoreSchema.d.ts +1 -1
- package/dist/Store/Store.js +2 -1
- package/dist/Store/StoreSchemaClass.d.ts +6 -3
- package/dist/Store/StoreSchemaClass.d.ts.map +1 -1
- package/dist/Store/StoreSchemaClass.js +8 -1
- package/dist/Store/TypeSafeStore.js +2 -1
- package/dist/Store/createStores.d.ts +3 -3
- package/dist/Store/createStores.d.ts.map +1 -1
- package/dist/Store/createStores.js +7 -2
- package/dist/Store/getInternalStore.d.ts.map +1 -1
- package/dist/Store/registerStore.d.ts.map +1 -1
- package/dist/Store/registerStore.js +2 -2
- package/dist/Store/storeCreators.d.ts +2 -2
- package/dist/Store/storeCreators.d.ts.map +1 -1
- package/dist/TungstenApp.d.ts +3 -3
- package/dist/TungstenApp.d.ts.map +1 -1
- package/dist/_client/cjsHelpers.d.ts.map +1 -1
- package/dist/_client/cjsHelpers.js +5 -3
- package/dist/_client/client.d.ts +2 -0
- package/dist/_client/client.d.ts.map +1 -1
- package/dist/_client/client.js +10 -3
- package/dist/api/getApiRoutes.d.ts.map +1 -1
- package/dist/api/getExport.d.ts +1 -1
- package/dist/api/getExport.d.ts.map +1 -1
- package/dist/api/getExport.js +2 -1
- package/dist/api/getExportDev.d.ts +1 -1
- package/dist/api/getExportDev.d.ts.map +1 -1
- package/dist/appBuilder.d.ts +69 -0
- package/dist/appBuilder.d.ts.map +1 -0
- package/dist/appBuilder.js +98 -0
- package/dist/appBuilder.types.test.d.ts +110 -0
- package/dist/appBuilder.types.test.d.ts.map +1 -0
- package/dist/appBuilder.types.test.js +240 -0
- package/dist/babelPlugins/BabelTransformBindDirect.js +7 -7
- package/dist/babelPlugins/BabelTransformBindVar.js +7 -7
- package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.js +5 -5
- package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformCssImports.js +2 -2
- package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +11 -6
- package/dist/babelPlugins/BabelTransformRemoveDevBlocks.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformRemoveServerBlocks.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +2 -2
- package/dist/bin/commands/compile.d.ts.map +1 -1
- package/dist/bin/commands/compile.js +2 -1
- package/dist/build/CompilationInfo.d.ts +3 -0
- package/dist/build/CompilationInfo.d.ts.map +1 -1
- package/dist/build/assetVersions.d.ts +9 -0
- package/dist/build/assetVersions.d.ts.map +1 -0
- package/dist/build/assetVersions.js +39 -0
- package/dist/build/babel.user.common.config.d.ts.map +1 -1
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +2 -1
- package/dist/build/bundleBabelOptions.d.ts.map +1 -1
- package/dist/build/clientRoutesFile.d.ts +2 -0
- package/dist/build/clientRoutesFile.d.ts.map +1 -0
- package/dist/build/clientRoutesFile.js +13 -0
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +4 -3
- package/dist/build/compileStyles.d.ts +2 -1
- package/dist/build/compileStyles.d.ts.map +1 -1
- package/dist/build/compileStyles.js +38 -83
- package/dist/build/compileUserApp.d.ts.map +1 -1
- package/dist/build/componentStylesCache.d.ts.map +1 -1
- package/dist/build/componentStylesCache.js +3 -2
- package/dist/build/copyAssets.d.ts.map +1 -1
- package/dist/build/copyAssets.js +2 -1
- package/dist/build/copyPackageModulesToPackagesFolder.d.ts.map +1 -1
- package/dist/build/copyPackageModulesToPackagesFolder.js +1 -1
- package/dist/build/copyPublicFiles.d.ts.map +1 -1
- package/dist/build/copyPublicFiles.js +2 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +9 -5
- package/dist/build/createInstanceConfigFile.d.ts +1 -1
- package/dist/build/createInstanceConfigFile.d.ts.map +1 -1
- package/dist/build/createInstanceConfigFile.js +9 -3
- package/dist/build/frameworkDestLocation.d.ts.map +1 -1
- package/dist/build/frameworkDestLocation.js +5 -6
- package/dist/build/frameworkStylesheets.d.ts.map +1 -1
- package/dist/build/frameworkStylesheets.js +1 -1
- package/dist/build/makeBabelRawConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts +2 -2
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
- package/dist/build/rollup.user.prod.config.d.ts.map +1 -1
- package/dist/build/rollup.user.prod.config.js +5 -3
- package/dist/build/rollupProdConstants.d.ts +5 -0
- package/dist/build/rollupProdConstants.d.ts.map +1 -0
- package/dist/build/rollupProdConstants.js +21 -0
- package/dist/cacheControl.d.ts +13 -0
- package/dist/cacheControl.d.ts.map +1 -0
- package/dist/cacheControl.js +22 -0
- package/dist/compat/types.d.ts +1 -1
- package/dist/compat/types.d.ts.map +1 -1
- package/dist/componentHelpers.d.ts +19 -0
- package/dist/componentHelpers.d.ts.map +1 -0
- package/dist/componentHelpers.js +31 -0
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/components/Fragment.d.ts +8 -0
- package/dist/components/Fragment.d.ts.map +1 -0
- package/dist/components/Fragment.js +10 -0
- package/dist/components/Link.d.ts +4 -3
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +1 -0
- package/dist/components/NoEscape.d.ts +8 -0
- package/dist/components/NoEscape.d.ts.map +1 -0
- package/dist/components/NoEscape.js +6 -0
- package/dist/components/RouteRedirectComponent.d.ts.map +1 -1
- package/dist/components/RouteRedirectComponent.js +1 -1
- package/dist/components/WebRedirectComponent.d.ts.map +1 -1
- package/dist/components/WebRedirectComponent.js +1 -1
- package/dist/components/bindable/BindVariable.d.ts +1 -0
- package/dist/components/bindable/BindVariable.d.ts.map +1 -1
- package/dist/components/bindable/BindableCheckbox.d.ts +7 -7
- package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
- package/dist/components/bindable/BindableInput.d.ts +7 -7
- package/dist/components/bindable/BindableInput.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputNonString.d.ts +2 -2
- package/dist/components/bindable/BindableInputNonString.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputString.d.ts +2 -2
- package/dist/components/bindable/BindableInputString.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTyped.d.ts +3 -3
- package/dist/components/bindable/BindableInputTyped.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts +3 -3
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
- package/dist/components/bindable/BindableRadio.js +2 -2
- package/dist/components/bindable/BindableSelect.d.ts +13 -10
- package/dist/components/bindable/BindableSelect.d.ts.map +1 -1
- package/dist/components/bindable/BindableSelectNaive.js +3 -3
- package/dist/components/bindable/BindableTextarea.d.ts +7 -7
- package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
- package/dist/components/bindable/bindableCandidates.comparison.d.ts +136 -0
- package/dist/components/bindable/bindableCandidates.comparison.d.ts.map +1 -0
- package/dist/components/bindable/bindableCandidates.comparison.js +268 -0
- package/dist/components/bindable/bindableProps.types.test.d.ts +50 -0
- package/dist/components/bindable/bindableProps.types.test.d.ts.map +1 -0
- package/dist/components/bindable/bindableProps.types.test.js +252 -0
- package/dist/components/library/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/contentTree.d.ts.map +1 -1
- package/dist/components/makeTypedLink.d.ts +9 -0
- package/dist/components/makeTypedLink.d.ts.map +1 -0
- package/dist/components/makeTypedLink.js +15 -0
- package/dist/context/registerContext.d.ts +22 -0
- package/dist/context/registerContext.d.ts.map +1 -0
- package/dist/context/registerContext.js +18 -0
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +2 -1
- package/dist/fileVersions.d.ts +9 -0
- package/dist/fileVersions.d.ts.map +1 -0
- package/dist/fileVersions.js +28 -0
- package/dist/findUserConfig.d.ts +1 -1
- package/dist/findUserConfig.d.ts.map +1 -1
- package/dist/findUserConfig.js +2 -1
- package/dist/frameworkConfigSchema.d.ts +16 -2
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +15 -3
- package/dist/getComponent.d.ts.map +1 -1
- package/dist/getComponent.js +4 -3
- package/dist/getRoutes.d.ts.map +1 -1
- package/dist/getRoutes.js +9 -8
- package/dist/getUserConfig.d.ts.map +1 -1
- package/dist/hmr/applyHmrModule.d.ts.map +1 -1
- package/dist/hmr/componentIdentity.js +1 -1
- package/dist/hooks/getCurrentComponent.d.ts +1 -1
- package/dist/hooks/getCurrentComponent.d.ts.map +1 -1
- package/dist/hydrate/hydrate.d.ts +5 -1
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +86 -52
- package/dist/hydrate/hydrateGlobalData.d.ts +4 -3
- package/dist/hydrate/hydrateGlobalData.d.ts.map +1 -1
- package/dist/hydrate/reconcileHydratedAttributes.d.ts +2 -1
- package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
- package/dist/hydrate/reconcileHydratedAttributes.js +4 -3
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -1
- package/dist/hydrate/renderHydrationMismatchBanner.js +2 -1
- package/dist/hydrate/stubRouting.d.ts +8 -0
- package/dist/hydrate/stubRouting.d.ts.map +1 -0
- package/dist/hydrate/stubRouting.js +25 -0
- package/dist/importDevModuleWithRetry.d.ts +2 -1
- package/dist/importDevModuleWithRetry.d.ts.map +1 -1
- package/dist/importDevModuleWithRetry.js +2 -1
- package/dist/importModule.d.ts +3 -0
- package/dist/importModule.d.ts.map +1 -0
- package/dist/importModule.js +4 -0
- package/dist/index.js +2 -1
- package/dist/indexInner.d.ts +30 -7
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +37 -2
- package/dist/json.d.ts +12 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +8 -0
- package/dist/jsxHelpers.d.ts +3 -0
- package/dist/jsxHelpers.d.ts.map +1 -0
- package/dist/jsxHelpers.js +6 -0
- package/dist/jsxRuntime.d.ts +1 -0
- package/dist/jsxRuntime.d.ts.map +1 -1
- package/dist/jsxRuntime.js +3 -1
- package/dist/jsxRuntimeSignals.d.ts.map +1 -1
- package/dist/jsxRuntimeSignals.js +1 -0
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +2 -0
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -0
- package/dist/mergeConfigs.d.ts.map +1 -1
- package/dist/mergeConfigs.js +2 -6
- package/dist/nbsp.d.ts +1 -2
- package/dist/nbsp.d.ts.map +1 -1
- package/dist/nbsp.js +3 -7
- package/dist/objectMap.d.ts +1 -1
- package/dist/objectMap.d.ts.map +1 -1
- package/dist/pipeline/PipelineRequestHandler.d.ts +25 -0
- package/dist/pipeline/PipelineRequestHandler.d.ts.map +1 -0
- package/dist/pipeline/PipelineRequestHandler.js +104 -0
- package/dist/pipeline/contextStore.d.ts +12 -0
- package/dist/pipeline/contextStore.d.ts.map +1 -0
- package/dist/pipeline/contextStore.js +13 -0
- package/dist/pipeline/hydratePipeline.d.ts +4 -0
- package/dist/pipeline/hydratePipeline.d.ts.map +1 -0
- package/dist/pipeline/hydratePipeline.js +83 -0
- package/dist/pipeline/importRoutesModule.d.ts +6 -0
- package/dist/pipeline/importRoutesModule.d.ts.map +1 -0
- package/dist/pipeline/importRoutesModule.js +33 -0
- package/dist/pipeline/networkedTransport.d.ts +11 -0
- package/dist/pipeline/networkedTransport.d.ts.map +1 -0
- package/dist/pipeline/networkedTransport.js +54 -0
- package/dist/pipeline/pipeline.d.ts +107 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +113 -0
- package/dist/pipeline/pipeline.types.test.d.ts +760 -0
- package/dist/pipeline/pipeline.types.test.d.ts.map +1 -0
- package/dist/pipeline/pipeline.types.test.js +344 -0
- package/dist/pipeline/pipelineDefinition.d.ts +78 -0
- package/dist/pipeline/pipelineDefinition.d.ts.map +1 -0
- package/dist/pipeline/pipelineDefinition.js +11 -0
- package/dist/pipeline/pipelineSplit.types.test.d.ts +2445 -0
- package/dist/pipeline/pipelineSplit.types.test.d.ts.map +1 -0
- package/dist/pipeline/pipelineSplit.types.test.js +440 -0
- package/dist/pipeline/runPipeline.d.ts +29 -0
- package/dist/pipeline/runPipeline.d.ts.map +1 -0
- package/dist/pipeline/runPipeline.js +71 -0
- package/dist/pipeline/runSplitPipeline.d.ts +10 -0
- package/dist/pipeline/runSplitPipeline.d.ts.map +1 -0
- package/dist/pipeline/runSplitPipeline.js +52 -0
- package/dist/pipeline/splitPipeline.d.ts +62 -0
- package/dist/pipeline/splitPipeline.d.ts.map +1 -0
- package/dist/pipeline/splitPipeline.js +76 -0
- package/dist/pop.js +1 -1
- package/dist/rawHtml/filterContentNode.d.ts.map +1 -1
- package/dist/render/HeadData.d.ts +3 -1
- package/dist/render/HeadData.d.ts.map +1 -1
- package/dist/render/classComponentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/contentToHtml.d.ts +2 -2
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +2 -1
- package/dist/render/contentToHtmlDev.d.ts +1 -1
- package/dist/render/contentToHtmlDev.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.js +6 -2
- package/dist/render/functionComponentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/functionComponentNodeToRenderingTree.js +2 -2
- package/dist/render/instantiateComponent.d.ts.map +1 -1
- package/dist/render/processHead.d.ts.map +1 -1
- package/dist/render/processHead.js +12 -18
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/renderingTreeToHtml.js +6 -3
- package/dist/render/rootToHtml.d.ts +2 -2
- package/dist/render/rootToHtml.d.ts.map +1 -1
- package/dist/requests/fetch/delete.d.ts.map +1 -1
- package/dist/requests/fetch/delete.js +5 -2
- package/dist/requests/fetch/get.js +1 -1
- package/dist/requests/fetch/patch.d.ts.map +1 -1
- package/dist/requests/fetch/patch.js +5 -2
- package/dist/requests/fetch/post.d.ts.map +1 -1
- package/dist/requests/fetch/post.js +5 -2
- package/dist/requests/fetch/put.d.ts.map +1 -1
- package/dist/requests/fetch/put.js +5 -2
- package/dist/routesLocationParts.d.ts +6 -0
- package/dist/routesLocationParts.d.ts.map +1 -0
- package/dist/routesLocationParts.js +10 -0
- package/dist/routing/AppRoutes.d.ts +5 -3
- package/dist/routing/AppRoutes.d.ts.map +1 -1
- package/dist/routing/MatchedRouteInfo.d.ts +13 -0
- package/dist/routing/MatchedRouteInfo.d.ts.map +1 -0
- package/dist/routing/MatchedRouteInfo.js +1 -0
- package/dist/routing/RouteContentFunction.d.ts +1 -2
- package/dist/routing/RouteContentFunction.d.ts.map +1 -1
- package/dist/routing/RouteDataFunction.type.d.ts +4 -2
- package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
- package/dist/routing/RoutePaths.d.ts +12 -0
- package/dist/routing/RoutePaths.d.ts.map +1 -0
- package/dist/routing/RouteTypes.d.ts +6 -4
- package/dist/routing/RouteTypes.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +20 -11
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/RoutesFunction.d.ts +11 -2
- package/dist/routing/RoutesFunction.d.ts.map +1 -1
- package/dist/routing/Serializable.d.ts +5 -0
- package/dist/routing/Serializable.d.ts.map +1 -0
- package/dist/routing/Serializable.js +1 -0
- package/dist/routing/builder.d.ts +100 -0
- package/dist/routing/builder.d.ts.map +1 -0
- package/dist/routing/builder.js +219 -0
- package/dist/routing/builder.trial.d.ts +2 -0
- package/dist/routing/builder.trial.d.ts.map +1 -0
- package/dist/routing/builder.trial.js +85 -0
- package/dist/routing/defineRoutes.d.ts +8 -0
- package/dist/routing/defineRoutes.d.ts.map +1 -0
- package/dist/routing/defineRoutes.js +3 -0
- package/dist/routing/pyramidRouting.d.ts +2 -0
- package/dist/routing/pyramidRouting.d.ts.map +1 -0
- package/dist/routing/pyramidRouting.js +13 -0
- package/dist/routing/redirectOf.d.ts +11 -0
- package/dist/routing/redirectOf.d.ts.map +1 -0
- package/dist/routing/redirectOf.js +32 -0
- package/dist/routing/registerGlobalData.d.ts +11 -3
- package/dist/routing/registerGlobalData.d.ts.map +1 -1
- package/dist/routing/registerGlobalData.js +6 -0
- package/dist/routing/registerParts.types.test.d.ts +2 -0
- package/dist/routing/registerParts.types.test.d.ts.map +1 -0
- package/dist/routing/registerParts.types.test.js +139 -0
- package/dist/routing/registerRoutes.d.ts +10 -0
- package/dist/routing/registerRoutes.d.ts.map +1 -0
- package/dist/routing/registerRoutes.js +9 -0
- package/dist/routing/registerRouting.d.ts +36 -0
- package/dist/routing/registerRouting.d.ts.map +1 -0
- package/dist/routing/registerRouting.js +34 -0
- package/dist/routing/registerRouting.types.test.d.ts +80 -0
- package/dist/routing/registerRouting.types.test.d.ts.map +1 -0
- package/dist/routing/registerRouting.types.test.js +120 -0
- package/dist/routing/registrationTypes.d.ts +11 -0
- package/dist/routing/registrationTypes.d.ts.map +1 -0
- package/dist/routing/registrationTypes.js +1 -0
- package/dist/routing/resolveAppRoutes.d.ts +5 -0
- package/dist/routing/resolveAppRoutes.d.ts.map +1 -0
- package/dist/routing/resolveAppRoutes.js +25 -0
- package/dist/routing/routesArray.d.ts +23 -0
- package/dist/routing/routesArray.d.ts.map +1 -0
- package/dist/routing/routesArray.js +20 -0
- package/dist/routing/routesArray.types.test.d.ts +2 -0
- package/dist/routing/routesArray.types.test.d.ts.map +1 -0
- package/dist/routing/routesArray.types.test.js +132 -0
- package/dist/routing/routingBuilder.d.ts +34 -0
- package/dist/routing/routingBuilder.d.ts.map +1 -0
- package/dist/routing/routingBuilder.js +32 -0
- package/dist/routing/routingBuilder.types.test.d.ts +2 -0
- package/dist/routing/routingBuilder.types.test.d.ts.map +1 -0
- package/dist/routing/routingBuilder.types.test.js +171 -0
- package/dist/routing/routingRegistry.d.ts +19 -0
- package/dist/routing/routingRegistry.d.ts.map +1 -0
- package/dist/routing/routingRegistry.js +29 -0
- package/dist/staticGen/getAppRoutes.d.ts +2 -2
- package/dist/staticGen/getAppRoutes.d.ts.map +1 -1
- package/dist/staticGen/getAppRoutes.js +9 -6
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +8 -2
- package/dist/style/styleContentSxy.d.ts.map +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -0
- package/dist/syncServer/index.cjs +1 -2
- package/dist/syncServer/preload.js +2 -0
- package/dist/testing/contentToString.d.ts +13 -0
- package/dist/testing/contentToString.d.ts.map +1 -0
- package/dist/testing/contentToString.js +105 -0
- package/dist/testing/createTestApp.d.ts +25 -1
- package/dist/testing/createTestApp.d.ts.map +1 -1
- package/dist/testing/createTestApp.js +12 -3
- package/dist/testing/display.d.ts +2 -0
- package/dist/testing/display.d.ts.map +1 -0
- package/dist/testing/display.js +37 -0
- package/dist/testing/ensure.d.ts +119 -0
- package/dist/testing/ensure.d.ts.map +1 -0
- package/dist/testing/ensure.js +664 -0
- package/dist/testing/ensure.trial.d.ts +2 -0
- package/dist/testing/ensure.trial.d.ts.map +1 -0
- package/dist/testing/ensure.trial.js +9 -0
- package/dist/testing/ensure.types.test.d.ts +2 -0
- package/dist/testing/ensure.types.test.d.ts.map +1 -0
- package/dist/testing/ensure.types.test.js +34 -0
- package/dist/testing/helpers/contentHtmlElements.d.ts.map +1 -1
- package/dist/testing/host.d.ts +86 -15
- package/dist/testing/host.d.ts.map +1 -1
- package/dist/testing/host.js +82 -23
- package/dist/testing/host.types.test.d.ts +2 -0
- package/dist/testing/host.types.test.d.ts.map +1 -0
- package/dist/testing/host.types.test.js +81 -0
- package/dist/testing/hydrateTestApp.d.ts +17 -0
- package/dist/testing/hydrateTestApp.d.ts.map +1 -1
- package/dist/testing/hydrateTestApp.js +27 -6
- package/dist/testing/index.d.ts +5 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3 -1
- package/dist/testing/pipeline/createTestPacketApp.d.ts +30 -0
- package/dist/testing/pipeline/createTestPacketApp.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPacketApp.js +45 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts +3 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.js +101 -0
- package/dist/testing/pipeline/createTestPipelineApp.d.ts +70 -0
- package/dist/testing/pipeline/createTestPipelineApp.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPipelineApp.js +90 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts +6 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.js +146 -0
- package/dist/testing/pipeline/hostPipeline.d.ts +25 -0
- package/dist/testing/pipeline/hostPipeline.d.ts.map +1 -0
- package/dist/testing/pipeline/hostPipeline.js +18 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.d.ts +30 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.d.ts.map +1 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.js +193 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts +2 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.js +27 -0
- package/dist/testing/pipeline/index.d.ts +5 -0
- package/dist/testing/pipeline/index.d.ts.map +1 -0
- package/dist/testing/pipeline/index.js +4 -0
- package/dist/testing/pipeline/pipelineTestApp.d.ts +34 -0
- package/dist/testing/pipeline/pipelineTestApp.d.ts.map +1 -0
- package/dist/testing/pipeline/pipelineTestApp.js +100 -0
- package/dist/testing/pipeline/testPipelineRoute.d.ts +2 -0
- package/dist/testing/pipeline/testPipelineRoute.d.ts.map +1 -0
- package/dist/testing/pipeline/testPipelineRoute.js +1 -0
- package/dist/testing/resolveContent.d.ts +18 -0
- package/dist/testing/resolveContent.d.ts.map +1 -0
- package/dist/testing/resolveContent.js +73 -0
- package/dist/testing/testingComponentPackage.d.ts +3 -1
- package/dist/testing/testingComponentPackage.d.ts.map +1 -1
- package/dist/testing/testingComponentPackage.js +16 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +35 -31
- package/dist/update/integrateUpdateVdomPrebuild.js +20 -20
- package/dist/validChildren.d.ts.map +1 -1
- package/dist/zones/react.d.ts.map +1 -1
- package/package.json +23 -19
- package/types/helpers.d.ts +11 -2
- package/types/jsx/html.d.ts +29 -25
- package/types/jsx/jsx.d.ts +8 -8
- package/types/modules.d.ts +14 -3
- package/types/testing.d.ts +0 -0
- package/vendor/babel-core.js +5 -5
- package/vendor/babel-parser.js +1 -1
- package/vendor/babel-preset-react.js +32 -34
- package/vendor/babel-preset-typescript.js +5 -5
- package/vendor/chalk-extensions.js +3 -146
- package/vendor/chokidar.js +311 -5
- package/vendor/chunk-B34JUlnS.js +169 -0
- package/vendor/{chunk-Bu8ZRE-c.js → chunk-B9ttgKqg.js} +28 -25
- package/vendor/{chunk-D2EnpcLg.js → chunk-BGvapINa.js} +3 -164
- package/vendor/{chunk-Cqrj-Zqr.js → chunk-BmAiqUzD.js} +22 -8
- package/vendor/{chunk-BiUcnLhT.js → chunk-But4T5N_.js} +8 -3
- package/vendor/{chunk-OUnVY4Wm.js → chunk-DuR6SGzI.js} +162 -35
- package/vendor/css-select.js +3383 -0
- package/vendor/dotenv.js +2 -2
- package/vendor/express.js +61 -10
- package/vendor/manifest.json +4 -3
- package/vendor/postcss.js +1 -1
- package/vendor/precinct.js +5914 -3591
- package/vendor/valibot.js +418 -504
- package/dist/Servers/MatchedRouteInfo.d.ts +0 -11
- package/dist/Servers/MatchedRouteInfo.d.ts.map +0 -1
- package/dist/routing/__fluentRouteBuilder.d.ts +0 -80
- package/dist/routing/__fluentRouteBuilder.d.ts.map +0 -1
- package/dist/routing/__fluentRouteBuilder.js +0 -183
- package/dist/routing/__fluentRoutes.d.ts +0 -2
- package/dist/routing/__fluentRoutes.d.ts.map +0 -1
- package/dist/routing/__fluentRoutes.js +0 -59
- package/vendor/chunk-Hy-cCmu-.js +0 -23
- /package/dist/{Servers/MatchedRouteInfo.js → routing/RoutePaths.js} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import { registerRouting } from './registerRouting.js';
|
|
5
|
+
/*
|
|
6
|
+
* Type tests for registerRouting()'s inference. tsc is the assertion - nothing here runs.
|
|
7
|
+
*
|
|
8
|
+
* The case that needs pinning: globalDataFunction now takes the context and the networked store,
|
|
9
|
+
* so ContextSchema and NetworkedStoreSchema are inferred from TWO argument positions each (their
|
|
10
|
+
* own, and this callback's parameters). A parameter is a contravariant inference site, so getting
|
|
11
|
+
* this wrong collapses them to never - the same way BindableSelect's Value did before NoInfer.
|
|
12
|
+
*/
|
|
13
|
+
const routes = {
|
|
14
|
+
default: {
|
|
15
|
+
content: null
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class AppContext {
|
|
19
|
+
constructor(reqRes) {
|
|
20
|
+
_defineProperty(this, "reqRes", void 0);
|
|
21
|
+
_defineProperty(this, "user", {
|
|
22
|
+
id: 1
|
|
23
|
+
});
|
|
24
|
+
this.reqRes = reqRes;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// the networked store is serialized to the page, so every member must be JsonValue - holding the
|
|
28
|
+
// reqRes on it makes it fail `NS extends Serializable<NS>` and fall back to its constraint
|
|
29
|
+
class AppStore {
|
|
30
|
+
constructor(reqRes) {
|
|
31
|
+
_defineProperty(this, "token", 'abc');
|
|
32
|
+
void reqRes;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// ---- both registered: the callback sees the real classes, not never ----------
|
|
36
|
+
export const both = registerRouting(() => routes, async (reqRes, context, store) => {
|
|
37
|
+
const id = context.user.id;
|
|
38
|
+
const token = store.token;
|
|
39
|
+
return await Promise.resolve({
|
|
40
|
+
id,
|
|
41
|
+
token
|
|
42
|
+
});
|
|
43
|
+
}, AppContext, AppStore);
|
|
44
|
+
// G still infers from the callback's return, uncontaminated by the two new parameters
|
|
45
|
+
const bothData = {
|
|
46
|
+
id: 1,
|
|
47
|
+
token: 'a'
|
|
48
|
+
};
|
|
49
|
+
// @ts-expect-error -- and is not widened: `id` is a number
|
|
50
|
+
const bothWrong = {
|
|
51
|
+
id: 'not a number',
|
|
52
|
+
token: 'a'
|
|
53
|
+
};
|
|
54
|
+
// ---- context only: the store parameter is undefined, not any -----------------
|
|
55
|
+
export const contextOnly = registerRouting(() => routes, async (reqRes, context) => Promise.resolve({
|
|
56
|
+
id: context.user.id
|
|
57
|
+
}), AppContext);
|
|
58
|
+
// ---- nothing registered: a one-argument callback still satisfies the type -----
|
|
59
|
+
// the parameters are additive, so an app that ignores them is unaffected
|
|
60
|
+
export const neither = registerRouting(() => routes, async () => Promise.resolve({
|
|
61
|
+
count: 1
|
|
62
|
+
}));
|
|
63
|
+
// ---- the parameters are checked, not any ------------------------------------
|
|
64
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment -- suppressing the type error below
|
|
65
|
+
leaves the property error-typed, which is the point of the case */
|
|
66
|
+
export const wrongContextUse = registerRouting(() => routes,
|
|
67
|
+
// @ts-expect-error -- `nope` is not on AppContext
|
|
68
|
+
async (reqRes, context) => Promise.resolve({
|
|
69
|
+
id: context.nope
|
|
70
|
+
}), AppContext);
|
|
71
|
+
export const wrongStoreUse = registerRouting(() => routes,
|
|
72
|
+
// @ts-expect-error -- the store is AppStore, which has no `missing`
|
|
73
|
+
async (reqRes, context, store) => Promise.resolve({
|
|
74
|
+
t: store.missing
|
|
75
|
+
}), AppContext, AppStore);
|
|
76
|
+
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
|
77
|
+
// ---- an annotated callback parameter must not redefine the context ----------
|
|
78
|
+
// the context is whatever class was registered. If the callback's own annotation is allowed to
|
|
79
|
+
// compete as an inference site, a wider annotation silently wins and the registered class is lost
|
|
80
|
+
class Base {
|
|
81
|
+
constructor() {
|
|
82
|
+
_defineProperty(this, "a", 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class Derived extends Base {
|
|
86
|
+
constructor(...args) {
|
|
87
|
+
super(...args);
|
|
88
|
+
_defineProperty(this, "b", 2);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export const annotatedWider = registerRouting(() => routes, async (reqRes, context) => Promise.resolve({
|
|
92
|
+
n: context.a
|
|
93
|
+
}), Derived);
|
|
94
|
+
const stillDerived = annotatedContext;
|
|
95
|
+
void stillDerived;
|
|
96
|
+
// ---- what cannot cross the network -----------------------------------------
|
|
97
|
+
// the store and the global data are both serialized into the page. Checked at the ARGUMENT, so
|
|
98
|
+
// the failure names the offending class or property instead of cascading - see registerRouting.ts
|
|
99
|
+
class StoreHoldingReqRes {
|
|
100
|
+
constructor(reqRes) {
|
|
101
|
+
_defineProperty(this, "reqRes", void 0);
|
|
102
|
+
_defineProperty(this, "token", 'abc');
|
|
103
|
+
this.reqRes = reqRes;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export const storeNotSerializable = registerRouting(() => routes, async () => Promise.resolve({
|
|
107
|
+
n: 1
|
|
108
|
+
}), AppContext,
|
|
109
|
+
// @ts-expect-error -- on THIS argument, naming the class: "'typeof StoreHoldingReqRes' is not
|
|
110
|
+
// assignable to ... SerializableStore<...>" ... "The types of 'reqRes' are incompatible" ...
|
|
111
|
+
// "Type 'Request' is not assignable to type 'JsonValue'"
|
|
112
|
+
StoreHoldingReqRes);
|
|
113
|
+
export const dataNotSerializable = registerRouting(() => routes,
|
|
114
|
+
// @ts-expect-error -- on the callback, naming the property: "Types of property 'leaked' are
|
|
115
|
+
// incompatible" ... "Type 'Request' is not assignable to type 'JsonValue'"
|
|
116
|
+
async reqRes => Promise.resolve({
|
|
117
|
+
leaked: reqRes
|
|
118
|
+
}), AppContext, AppStore);
|
|
119
|
+
void bothData;
|
|
120
|
+
void bothWrong;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReqRes } from '../ReqRes.js';
|
|
2
|
+
import type { RoutesWithSettings } from './Routes.js';
|
|
3
|
+
import type { RoutesArray } from './routesArray.js';
|
|
4
|
+
export declare const $routing: unique symbol;
|
|
5
|
+
export type Fixed<T> = {
|
|
6
|
+
[$routing]: T;
|
|
7
|
+
};
|
|
8
|
+
export type RoutesFunctionGeneric<G extends object, C, NS, Rs extends RoutesWithSettings<G> | RoutesArray<G>> = (reqRes: ReqRes | null, context: C, networkedData: NS) => Rs;
|
|
9
|
+
export type ContextInitializer<ContextSchema> = new (reqRes: ReqRes | null) => ContextSchema;
|
|
10
|
+
export type NetworkedStoreInitializer<StoreSchema> = new (reqRes: ReqRes | null, context?: unknown) => StoreSchema;
|
|
11
|
+
//# sourceMappingURL=registrationTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrationTypes.d.ts","sourceRoot":"","sources":["../../src/routing/registrationTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAoBnD,MAAM,CAAC,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,MAAM,CAAA;AAI5C,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;CAAE,CAAA;AAExC,MAAM,MAAM,qBAAqB,CAC7B,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,IAC1E,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,CAAA;AAEhE,MAAM,MAAM,kBAAkB,CAAC,aAAa,IAAI,KAC5C,MAAM,EAAE,MAAM,GAAG,IAAI,KACpB,aAAa,CAAA;AAIlB,MAAM,MAAM,yBAAyB,CAAC,WAAW,IAAI,KACjD,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,CAAC,EAAE,OAAO,KAChB,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Mode } from '../Mode.js';
|
|
2
|
+
import type { RoutesLocation } from '../FrameworkConfig.js';
|
|
3
|
+
import type { AppRoutes } from './AppRoutes.js';
|
|
4
|
+
export declare function resolveAppRoutes(module: Record<string, unknown>, routesLocation: RoutesLocation, mode: Mode): AppRoutes<any>;
|
|
5
|
+
//# sourceMappingURL=resolveAppRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveAppRoutes.d.ts","sourceRoot":"","sources":["../../src/routing/resolveAppRoutes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAQ/C,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,IAAI,GACX,SAAS,CAAC,GAAG,CAAC,CAgChB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TungstenError } from '../TungstenError.js';
|
|
2
|
+
import { routesLocationParts } from '../routesLocationParts.js';
|
|
3
|
+
import { registeredRouting } from './routingRegistry.js';
|
|
4
|
+
// routes come from registerRouting() or from routesLocation's named export. The module has already
|
|
5
|
+
// been imported by the caller, which is what runs the registerRouting() call
|
|
6
|
+
export function resolveAppRoutes(module, routesLocation, mode) {
|
|
7
|
+
const {
|
|
8
|
+
routesFile,
|
|
9
|
+
routeExport
|
|
10
|
+
} = routesLocationParts(routesLocation);
|
|
11
|
+
const registered = registeredRouting.value;
|
|
12
|
+
const isExported = routeExport !== undefined && routeExport in module;
|
|
13
|
+
// both systems in one app is almost always a mistake, so say so while it is cheap to fix
|
|
14
|
+
if (registered !== undefined && isExported && mode === 'dev') {
|
|
15
|
+
throw new TungstenError(`Routes are set twice: registerRouting() was called, and routes file ${routesFile}` + ` exports ${routeExport} (config.routesLocation). Use one or the other - drop the` + ` export name from routesLocation to keep registerRouting().`);
|
|
16
|
+
}
|
|
17
|
+
if (registered !== undefined) return registered;
|
|
18
|
+
if (isExported) {
|
|
19
|
+
return module[routeExport]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
20
|
+
}
|
|
21
|
+
if (routeExport === undefined) {
|
|
22
|
+
throw new TungstenError(`No routes. config.routesLocation names the file ${routesFile} without an export name,` + ` so routes must come from registerRouting(), but ${routesFile} did not call it.`);
|
|
23
|
+
}
|
|
24
|
+
throw new TungstenError(`Could not find an export named ${routeExport} in routes file ${routesFile},` + ` and registerRouting() was not called.` + ` These settings are set in config.routesLocation.`);
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ErrorRouteType } from './ErrorRouteType.js';
|
|
2
|
+
import type { Routes, RoutesWithSettings } from './Routes.js';
|
|
3
|
+
import type { Endpoint, Path } from './RouteTypes.js';
|
|
4
|
+
export type RouteEntry<G extends object | undefined = object> = (Endpoint<any, any, G> & {
|
|
5
|
+
path: Path | 'default' | '404';
|
|
6
|
+
}) | (ErrorRouteType & {
|
|
7
|
+
path: 'error';
|
|
8
|
+
});
|
|
9
|
+
export type RoutesArray<G extends object | undefined = object> = readonly RouteEntry<G>[];
|
|
10
|
+
export declare function routesFromArray(entries: RoutesArray<any>, dev: boolean): Routes<any>;
|
|
11
|
+
export declare const toRoutes: <Rs extends object>(routes: Rs | RoutesArray<any>, dev: boolean) => Rs | RoutesWithSettings<any>;
|
|
12
|
+
export type KeyedRoutes<Rs> = Rs extends RoutesArray<any> ? {
|
|
13
|
+
[Entry in Rs[number] as Entry['path']]: Omit<Entry, 'path'>;
|
|
14
|
+
} : Rs;
|
|
15
|
+
type IsOnePath<P extends PropertyKey> = Record<never, never> extends Record<P, 1> ? false : true;
|
|
16
|
+
type DuplicatePath<T, Seen = never> = T extends readonly [infer H, ...infer Rest] ? H extends {
|
|
17
|
+
path: infer P extends PropertyKey;
|
|
18
|
+
} ? IsOnePath<P> extends false ? DuplicatePath<Rest, Seen> : P extends Seen ? P : DuplicatePath<Rest, Seen | P> : DuplicatePath<Rest, Seen> : never;
|
|
19
|
+
type ReturnedRoutes<R> = R extends (...args: never[]) => infer Rs ? Rs : R;
|
|
20
|
+
type GivenTwice<P extends string> = `The routes give the path '${P}' twice. Each path can have one route.`;
|
|
21
|
+
export type NoDuplicatePaths<R> = [DuplicatePath<ReturnedRoutes<R>>] extends [never] ? unknown : GivenTwice<DuplicatePath<ReturnedRoutes<R>> & string>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=routesArray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesArray.d.ts","sourceRoot":"","sources":["../../src/routing/routesArray.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE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AK,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,GAC3E,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,SAAS,WAAW,CAAA;CAAE,GAC3C,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GACtB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,GACzB,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,GACtD,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,GAC7B,KAAK,CAAA;AACX,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAE1E,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,IAC1B,6BAA6B,CAAC,wCAAwC,CAAA;AAG5E,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC9E,OAAO,GACP,UAAU,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TungstenError } from '../TungstenError.js';
|
|
2
|
+
// the array form as the object form. A path given twice is an error in dev; otherwise the last
|
|
3
|
+
// one wins, as a repeated key does in an object
|
|
4
|
+
export function routesFromArray(entries, dev) {
|
|
5
|
+
const routes = {};
|
|
6
|
+
for (const {
|
|
7
|
+
path,
|
|
8
|
+
...endpoint
|
|
9
|
+
} of entries) {
|
|
10
|
+
if (dev && Object.hasOwn(routes, path)) {
|
|
11
|
+
throw new TungstenError(`The routes give the path '${path}' twice. Each path can have one route.`);
|
|
12
|
+
}
|
|
13
|
+
routes[path] = endpoint;
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- keyed by entry path
|
|
16
|
+
return routes;
|
|
17
|
+
}
|
|
18
|
+
// the array form carries no RoutesSettings, so they read as unset
|
|
19
|
+
export const toRoutes = (routes, dev) => isRoutesArray(routes) ? routesFromArray(routes, dev) : routes;
|
|
20
|
+
const isRoutesArray = routes => Array.isArray(routes);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesArray.types.test.d.ts","sourceRoot":"","sources":["../../src/routing/routesArray.types.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { appBuilder } from '../appBuilder.js';
|
|
2
|
+
import { pipeline } from '../pipeline/pipeline.js';
|
|
3
|
+
import { route } from './builder.js';
|
|
4
|
+
/*
|
|
5
|
+
* Type tests for the array routes form. tsc is the assertion - nothing here runs.
|
|
6
|
+
*/
|
|
7
|
+
const _routes = () => [route({
|
|
8
|
+
path: '/leads/:id<1+>',
|
|
9
|
+
content: null
|
|
10
|
+
}), route({
|
|
11
|
+
path: '/about',
|
|
12
|
+
content: null
|
|
13
|
+
}), route({
|
|
14
|
+
path: '404',
|
|
15
|
+
content: null
|
|
16
|
+
})];
|
|
17
|
+
// the route and path types read the array form as they read the object form
|
|
18
|
+
const leadPath = '/leads/5';
|
|
19
|
+
const aboutPath = '/about';
|
|
20
|
+
// @ts-expect-error -- not a route
|
|
21
|
+
const nopePath = '/nope';
|
|
22
|
+
const routeKeys = ['/leads/:id<1+>', '/about', '404'];
|
|
23
|
+
// @ts-expect-error -- not a route key
|
|
24
|
+
const nopeKey = '/nope';
|
|
25
|
+
void leadPath;
|
|
26
|
+
void aboutPath;
|
|
27
|
+
void nopePath;
|
|
28
|
+
void routeKeys;
|
|
29
|
+
void nopeKey;
|
|
30
|
+
// a plain array works too
|
|
31
|
+
const _array = [route({
|
|
32
|
+
path: '/a',
|
|
33
|
+
content: null
|
|
34
|
+
})];
|
|
35
|
+
const arrayPath = '/a';
|
|
36
|
+
void arrayPath;
|
|
37
|
+
// a path starts with / or names a special route
|
|
38
|
+
// @ts-expect-error -- neither
|
|
39
|
+
route({
|
|
40
|
+
path: 'foo',
|
|
41
|
+
content: null
|
|
42
|
+
});
|
|
43
|
+
// the error route's content is a function without data, which route() does not take: a plain entry
|
|
44
|
+
appBuilder.routes(() => [route({
|
|
45
|
+
path: '/e',
|
|
46
|
+
content: null
|
|
47
|
+
}), {
|
|
48
|
+
path: 'error',
|
|
49
|
+
content: () => null
|
|
50
|
+
}]);
|
|
51
|
+
// @ts-expect-error -- and it is typed as the error route
|
|
52
|
+
appBuilder.routes(() => [{
|
|
53
|
+
path: 'error',
|
|
54
|
+
content: info => info.nope
|
|
55
|
+
}]);
|
|
56
|
+
// the app builder takes the array form
|
|
57
|
+
appBuilder.routes(() => [route({
|
|
58
|
+
path: '/b',
|
|
59
|
+
content: null
|
|
60
|
+
})]);
|
|
61
|
+
appBuilder.routes([route({
|
|
62
|
+
path: '/c',
|
|
63
|
+
content: null
|
|
64
|
+
})]);
|
|
65
|
+
// ---- a path given twice, at registration ------------------------------------
|
|
66
|
+
appBuilder.routes(() => [route({
|
|
67
|
+
path: '/a',
|
|
68
|
+
content: null
|
|
69
|
+
}), route({
|
|
70
|
+
path: '/b',
|
|
71
|
+
content: null
|
|
72
|
+
}), route({
|
|
73
|
+
path: '404',
|
|
74
|
+
content: null
|
|
75
|
+
})]);
|
|
76
|
+
// @ts-expect-error -- '/a' twice
|
|
77
|
+
appBuilder.routes(() => [route({
|
|
78
|
+
path: '/a',
|
|
79
|
+
content: null
|
|
80
|
+
}), route({
|
|
81
|
+
path: '/a',
|
|
82
|
+
content: 'x'
|
|
83
|
+
})]);
|
|
84
|
+
// @ts-expect-error -- given directly, too
|
|
85
|
+
appBuilder.routes([route({
|
|
86
|
+
path: '/a',
|
|
87
|
+
content: null
|
|
88
|
+
}), route({
|
|
89
|
+
path: '/a',
|
|
90
|
+
content: null
|
|
91
|
+
})]);
|
|
92
|
+
// @ts-expect-error -- and without route()
|
|
93
|
+
appBuilder.routes(() => [{
|
|
94
|
+
path: '/a',
|
|
95
|
+
content: null
|
|
96
|
+
}, {
|
|
97
|
+
path: '/a',
|
|
98
|
+
content: null
|
|
99
|
+
}]);
|
|
100
|
+
// @ts-expect-error -- and in the pipeline
|
|
101
|
+
pipeline.server('express').routes(() => [route({
|
|
102
|
+
path: '/a',
|
|
103
|
+
content: null
|
|
104
|
+
}), route({
|
|
105
|
+
path: '/a',
|
|
106
|
+
content: null
|
|
107
|
+
})]);
|
|
108
|
+
appBuilder.routes(() => [route({
|
|
109
|
+
path: somePath,
|
|
110
|
+
content: null
|
|
111
|
+
}), route({
|
|
112
|
+
path: '/a',
|
|
113
|
+
content: null
|
|
114
|
+
})]);
|
|
115
|
+
// a computed array is not a tuple, so it is left to the check when the routes are read
|
|
116
|
+
const computed = [route({
|
|
117
|
+
path: '/a',
|
|
118
|
+
content: null
|
|
119
|
+
}), route({
|
|
120
|
+
path: '/a',
|
|
121
|
+
content: null
|
|
122
|
+
})];
|
|
123
|
+
appBuilder.routes(() => computed);
|
|
124
|
+
// the object form is untouched
|
|
125
|
+
appBuilder.routes(() => ({
|
|
126
|
+
'/a': {
|
|
127
|
+
content: null
|
|
128
|
+
},
|
|
129
|
+
'404': {
|
|
130
|
+
content: null
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReqRes, ReqResOrNull } from '../ReqRes.js';
|
|
2
|
+
import type { RoutesWithSettings } from './Routes.js';
|
|
3
|
+
import type { ContextClasses } from '../context/registerContext.js';
|
|
4
|
+
import type { Routing, RoutesFunctionGeneric, Serializable } from './registerRouting.js';
|
|
5
|
+
import type { Fixed } from './registrationTypes.js';
|
|
6
|
+
type NetworkedStoreClass<C, ND> = (new (reqRes: ReqResOrNull, context: C) => ND) & (new (reqRes: ReqResOrNull, context: C) => Serializable<NoInfer<ND>>);
|
|
7
|
+
type GetGlobalData<C, ND, G extends object> = ((reqRes: ReqRes | null, context: C, networkedData: ND) => Promise<G>) & ((reqRes: ReqRes | null, context: C, networkedData: ND) => Promise<Serializable<NoInfer<G>>>);
|
|
8
|
+
type RoutesMethod<C, ND, G extends object> = {
|
|
9
|
+
routes: <Rs extends RoutesWithSettings<G>>(getRoutes: RoutesFunctionGeneric<G, C, ND, Rs>) => Routing<Rs, G, C, ND>;
|
|
10
|
+
};
|
|
11
|
+
type GlobalDataMethod<C, ND> = {
|
|
12
|
+
globalData: <G extends object>(getGlobalData: GetGlobalData<C, ND, G>) => RoutesStage<C, ND, G>;
|
|
13
|
+
};
|
|
14
|
+
type NetworkedDataMethod<C> = {
|
|
15
|
+
networkedData: <ND extends object>(networkedDataInitializer: NetworkedStoreClass<C, ND>) => GlobalDataStage<C, ND>;
|
|
16
|
+
};
|
|
17
|
+
type RoutesStage<C, ND, G extends object> = RoutesMethod<C, ND, G> & Fixed<{
|
|
18
|
+
context: C;
|
|
19
|
+
networkedStore: ND;
|
|
20
|
+
globalData: G;
|
|
21
|
+
}>;
|
|
22
|
+
type GlobalDataStage<C, ND> = RoutesMethod<C, ND, object> & GlobalDataMethod<C, ND> & Fixed<{
|
|
23
|
+
context: C;
|
|
24
|
+
networkedStore: ND;
|
|
25
|
+
}>;
|
|
26
|
+
type NetworkedDataStage<C> = RoutesMethod<C, undefined, object> & GlobalDataMethod<C, undefined> & NetworkedDataMethod<C> & Fixed<{
|
|
27
|
+
context: C;
|
|
28
|
+
}>;
|
|
29
|
+
type ContextStage = RoutesMethod<undefined, undefined, object> & GlobalDataMethod<undefined, undefined> & NetworkedDataMethod<undefined> & {
|
|
30
|
+
context: <C extends object>(contextInitializer: (new (reqRes: ReqResOrNull) => C) | ContextClasses) => NetworkedDataStage<C>;
|
|
31
|
+
};
|
|
32
|
+
export declare const register: ContextStage;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=routingBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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A;CAAE,CAAC,CAAA;AAG3B,KAAK,YAAY,GAAG,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,GACxD,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,GAAG;IACxE,OAAO,EAAE,CAAC,CAAC,SAAS,MAAM,EACtB,kBAAkB,EAAE,CAAC,KAAK,MAAM,EAAE,YAAY,KAAK,CAAC,CAAC,GAAG,cAAc,KACrE,kBAAkB,CAAC,CAAC,CAAC,CAAA;CAC7B,CAAA;AAgCL,eAAO,MAAM,QAAQ,EAAE,YAA6B,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { registeredRouting, registeredNetworkedStore } from './routingRegistry.js';
|
|
2
|
+
import { contextRegistration } from '../context/registerContext.js';
|
|
3
|
+
import { globalDataFunc } from './registerGlobalData.js';
|
|
4
|
+
function makeStages(pending) {
|
|
5
|
+
return {
|
|
6
|
+
context: contextInitializer => makeStages({
|
|
7
|
+
...pending,
|
|
8
|
+
context: contextInitializer
|
|
9
|
+
}),
|
|
10
|
+
networkedData: networkedDataInitializer => makeStages({
|
|
11
|
+
...pending,
|
|
12
|
+
networkedStore: networkedDataInitializer
|
|
13
|
+
}),
|
|
14
|
+
globalData: getGlobalData => makeStages({
|
|
15
|
+
...pending,
|
|
16
|
+
globalData: getGlobalData
|
|
17
|
+
}),
|
|
18
|
+
routes: getRoutes => {
|
|
19
|
+
registeredRouting.value = getRoutes;
|
|
20
|
+
if (pending.globalData !== undefined) globalDataFunc.value = pending.globalData;
|
|
21
|
+
if (pending.context !== undefined) contextRegistration.value = pending.context;
|
|
22
|
+
if (pending.networkedStore !== undefined) {
|
|
23
|
+
registeredNetworkedStore.value = pending.networkedStore;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
// unchecked: every method hands back this one untyped shape, not the stage it promises, and the
|
|
28
|
+
// Fixed records exist only in the types
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// the entry point. Every stage is optional except .routes(), which commits the chain
|
|
32
|
+
export const register = makeStages({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routingBuilder.types.test.d.ts","sourceRoot":"","sources":["../../src/routing/routingBuilder.types.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import { register } from './routingBuilder.js';
|
|
5
|
+
/*
|
|
6
|
+
* Type tests for the staged builder. tsc is the assertion - nothing here runs.
|
|
7
|
+
*
|
|
8
|
+
* What is being pinned: each stage fixes ONE type parameter from ONE argument, so every later
|
|
9
|
+
* stage sees a concrete type. The cases below check that the later callbacks really do see the
|
|
10
|
+
* earlier types, that skipping a stage leaves `undefined` rather than collapsing, and that the
|
|
11
|
+
* serializable checks land on the argument at fault.
|
|
12
|
+
*/
|
|
13
|
+
const routes = {
|
|
14
|
+
default: {
|
|
15
|
+
content: null
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class AppContext {
|
|
19
|
+
constructor(reqRes) {
|
|
20
|
+
_defineProperty(this, "user", {
|
|
21
|
+
id: 1
|
|
22
|
+
});
|
|
23
|
+
void reqRes;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class AppStore {
|
|
27
|
+
// the store is built after the context, so it may read it
|
|
28
|
+
constructor(reqRes, context) {
|
|
29
|
+
_defineProperty(this, "userId", void 0);
|
|
30
|
+
_defineProperty(this, "token", 'abc');
|
|
31
|
+
void reqRes;
|
|
32
|
+
this.userId = context.user.id;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// ---- the full chain ---------------------------------------------------------
|
|
36
|
+
const _full = register.context(AppContext).networkedData(AppStore).globalData(async (reqRes, context, networkedData) => {
|
|
37
|
+
// both earlier stages are concrete here, with no annotation and no cast
|
|
38
|
+
const id = context.user.id;
|
|
39
|
+
const token = networkedData.token;
|
|
40
|
+
return await Promise.resolve({
|
|
41
|
+
id,
|
|
42
|
+
token
|
|
43
|
+
});
|
|
44
|
+
}).routes((reqRes, context, networkedData) => {
|
|
45
|
+
// and so are they here, alongside the global data's own type
|
|
46
|
+
const id = context.user.id;
|
|
47
|
+
const token = networkedData.token;
|
|
48
|
+
void id;
|
|
49
|
+
void token;
|
|
50
|
+
return routes;
|
|
51
|
+
});
|
|
52
|
+
const fullContext = fullC;
|
|
53
|
+
const fullStore = fullNd;
|
|
54
|
+
const fullData = fullG;
|
|
55
|
+
const fullRoutes = fullRs;
|
|
56
|
+
void fullContext;
|
|
57
|
+
void fullStore;
|
|
58
|
+
void fullData;
|
|
59
|
+
void fullRoutes;
|
|
60
|
+
// the cases above would pass just as well if the parameters were silently `any`, so each one is
|
|
61
|
+
// probed for a member that does not exist. Without these, "the later stages see the types" can
|
|
62
|
+
// mean only that we have stopped checking
|
|
63
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment -- suppressing the type error leaves the
|
|
64
|
+
property error-typed, which is exactly what these cases are for */
|
|
65
|
+
register.context(AppContext).networkedData(AppStore)
|
|
66
|
+
// @ts-expect-error -- `nope` is not on AppContext, so the context is not any
|
|
67
|
+
.globalData(async (reqRes, context) => Promise.resolve({
|
|
68
|
+
x: context.nope
|
|
69
|
+
})).routes(() => routes);
|
|
70
|
+
register.context(AppContext).networkedData(AppStore)
|
|
71
|
+
// @ts-expect-error -- `nope` is not on AppStore, so the store is not any
|
|
72
|
+
.globalData(async (reqRes, context, networkedData) => Promise.resolve({
|
|
73
|
+
x: networkedData.nope
|
|
74
|
+
})).routes(() => routes);
|
|
75
|
+
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
|
76
|
+
register.context(AppContext).routes((reqRes, context) => {
|
|
77
|
+
// @ts-expect-error -- and the same inside the routes callback
|
|
78
|
+
void context.nope;
|
|
79
|
+
return routes;
|
|
80
|
+
});
|
|
81
|
+
// ---- reading a type off an unfinished chain ---------------------------------
|
|
82
|
+
// an app augments Context from the stage after .context(): read off the finished routing, a
|
|
83
|
+
// callback in the chain that names the augmented type would be part of its own definition
|
|
84
|
+
const withContext = register.context(AppContext);
|
|
85
|
+
const stageContext = stageC;
|
|
86
|
+
const withStore = withContext.networkedData(AppStore);
|
|
87
|
+
const stageStore = stageNd;
|
|
88
|
+
const stageStoreContext = stageStoreC;
|
|
89
|
+
void stageContext;
|
|
90
|
+
void stageStore;
|
|
91
|
+
void stageStoreContext;
|
|
92
|
+
const _staged = withStore.globalData(async (reqRes, context, networkedData) => Promise.resolve({
|
|
93
|
+
id: context.user.id,
|
|
94
|
+
token: networkedData.token
|
|
95
|
+
})).routes(() => routes);
|
|
96
|
+
const stagedData = stagedG;
|
|
97
|
+
void stagedData;
|
|
98
|
+
// ---- skipping stages --------------------------------------------------------
|
|
99
|
+
const _noneAtAll = register.routes(() => routes);
|
|
100
|
+
const skippedContext = noneC;
|
|
101
|
+
void skippedContext;
|
|
102
|
+
const _contextOnly = register.context(AppContext).routes((reqRes, context) => {
|
|
103
|
+
const id = context.user.id;
|
|
104
|
+
void id;
|
|
105
|
+
return routes;
|
|
106
|
+
});
|
|
107
|
+
const keptContext = contextOnlyC;
|
|
108
|
+
void keptContext;
|
|
109
|
+
const _dataOnly = register.globalData(async () => Promise.resolve({
|
|
110
|
+
n: 1
|
|
111
|
+
})).routes(() => routes);
|
|
112
|
+
const keptData = dataOnlyG;
|
|
113
|
+
void keptData;
|
|
114
|
+
// ---- a stage cannot be taken twice, or out of order -------------------------
|
|
115
|
+
// @ts-expect-error -- .context is gone once taken
|
|
116
|
+
register.context(AppContext).context(AppContext);
|
|
117
|
+
// @ts-expect-error -- .context cannot follow .globalData
|
|
118
|
+
register.globalData(async () => Promise.resolve({})).context(AppContext);
|
|
119
|
+
// @ts-expect-error -- .networkedData cannot follow .globalData
|
|
120
|
+
register.globalData(async () => Promise.resolve({})).networkedData(AppStore);
|
|
121
|
+
// ---- what cannot cross the network ------------------------------------------
|
|
122
|
+
class StoreHoldingReqRes {
|
|
123
|
+
constructor(reqRes) {
|
|
124
|
+
_defineProperty(this, "reqRes", void 0);
|
|
125
|
+
_defineProperty(this, "token", 'abc');
|
|
126
|
+
this.reqRes = reqRes;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
register.context(AppContext)
|
|
130
|
+
// @ts-expect-error -- on THIS argument: "Type 'Request' is not assignable to type 'JsonValue'"
|
|
131
|
+
.networkedData(StoreHoldingReqRes).routes(() => routes);
|
|
132
|
+
register
|
|
133
|
+
// @ts-expect-error -- on THIS callback: "Types of property 'leaked' are incompatible"
|
|
134
|
+
.globalData(async reqRes => Promise.resolve({
|
|
135
|
+
leaked: reqRes
|
|
136
|
+
})).routes(() => routes);
|
|
137
|
+
// ---- the routes are checked against the global data -------------------------
|
|
138
|
+
// Rs is constrained by RoutesWithSettings<G>, with G already concrete by this point
|
|
139
|
+
register.globalData(async () => Promise.resolve({
|
|
140
|
+
n: 1
|
|
141
|
+
}))
|
|
142
|
+
// @ts-expect-error -- routes must have a `default` or a `404`
|
|
143
|
+
.routes(() => ({
|
|
144
|
+
'/somewhere': {
|
|
145
|
+
content: null
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
// G reaches a route's content function, which is the point of fixing it first: by the time
|
|
149
|
+
// .routes() is called G is a concrete type, not a parameter still being inferred elsewhere
|
|
150
|
+
register.globalData(async () => Promise.resolve({
|
|
151
|
+
n: 1
|
|
152
|
+
})).routes(() => ({
|
|
153
|
+
default: {
|
|
154
|
+
content: (routeData, routeParams, props, globalData) => {
|
|
155
|
+
const n = globalData.n;
|
|
156
|
+
void n;
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
register.globalData(async () => Promise.resolve({
|
|
162
|
+
n: 1
|
|
163
|
+
})).routes(() => ({
|
|
164
|
+
default: {
|
|
165
|
+
content: (routeData, routeParams, props, globalData) => {
|
|
166
|
+
// @ts-expect-error -- and it is checked: `nope` is not on the global data
|
|
167
|
+
void globalData.nope;
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppRoutes } from './AppRoutes.js';
|
|
2
|
+
import type { ReqRes } from '../ReqRes.js';
|
|
3
|
+
import type { BrandedContext, BrandedNetworkedData } from '../Brands.js';
|
|
4
|
+
import type { Context } from '../context/registerContext.js';
|
|
5
|
+
import type { Serializable } from './Serializable.js';
|
|
6
|
+
import type { Fixed } from './registrationTypes.js';
|
|
7
|
+
export interface NetworkedData {
|
|
8
|
+
}
|
|
9
|
+
export declare const registeredRouting: {
|
|
10
|
+
value: AppRoutes<any> | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const registeredNetworkedStore: {
|
|
13
|
+
value: (new (reqRes: ReqRes | null, context: BrandedContext) => object) | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare function registerNetworkedData<ND extends object>(store: (new (reqRes: ReqRes | null, context: Context) => ND) & (new (reqRes: ReqRes | null, context: Context) => Serializable<NoInfer<ND>>)): Fixed<{
|
|
16
|
+
networkedStore: ND;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function createNetworkedData(reqRes: ReqRes | null, context: BrandedContext): BrandedNetworkedData;
|
|
19
|
+
//# sourceMappingURL=routingRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routingRegistry.d.ts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