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,664 @@
|
|
|
1
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
4
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
5
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
8
|
+
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); }
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { styleText } from 'node:util';
|
|
13
|
+
import deepEqual from 'deep-eql';
|
|
14
|
+
import { warn } from '../output.js';
|
|
15
|
+
import { ContentNodeElementIsComponent, ContentNodeElementIsHtml, ContentNodeIsArray, ContentNodeIsElement, ContentNodeIsLiteral, IsContentNode } from '../ContentNode.js';
|
|
16
|
+
import { $props, $type } from '../contentNodeSymbols.js';
|
|
17
|
+
import { componentTypeIdentityKey } from '../hmr/componentIdentity.js';
|
|
18
|
+
import { display } from './display.js';
|
|
19
|
+
// with: the match's properties; its tag, and text and elements it holds, are for children
|
|
20
|
+
const propertyEnds = ['interruptedText', 'className', 'id', 'prop'];
|
|
21
|
+
// exported after
|
|
22
|
+
const _ensure = withMembers(ensure, quantifiers(fact => fact));
|
|
23
|
+
export { _ensure as ensure }; // naming
|
|
24
|
+
// read once: an ends object holds no run state, as each run starts its facts afresh
|
|
25
|
+
export const {
|
|
26
|
+
no,
|
|
27
|
+
none,
|
|
28
|
+
one,
|
|
29
|
+
two,
|
|
30
|
+
three,
|
|
31
|
+
a,
|
|
32
|
+
an,
|
|
33
|
+
some,
|
|
34
|
+
all,
|
|
35
|
+
count
|
|
36
|
+
} = _ensure;
|
|
37
|
+
// E: the ends as the caller offers them, which the built ends are typed loosely for.
|
|
38
|
+
// properties: only the ends a with list takes
|
|
39
|
+
function quantifiers(finish, properties = false) {
|
|
40
|
+
const made = (quantifier, requirement, spoken) => {
|
|
41
|
+
const all = ends(quantifier, requirement, finish, spoken);
|
|
42
|
+
const offered = properties ? Object.fromEntries(propertyEnds.map(name => [name, all[name]])) : all;
|
|
43
|
+
return offered; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
get no() {
|
|
47
|
+
return made('no', counting(count => count === 0, 0));
|
|
48
|
+
},
|
|
49
|
+
get none() {
|
|
50
|
+
return made('none', counting(count => count === 0, 0), 'no');
|
|
51
|
+
},
|
|
52
|
+
get one() {
|
|
53
|
+
return made('one', counting(count => count === 1, 1));
|
|
54
|
+
},
|
|
55
|
+
get two() {
|
|
56
|
+
return made('two', counting(count => count === 2, 2));
|
|
57
|
+
},
|
|
58
|
+
get three() {
|
|
59
|
+
return made('three', counting(count => count === 3, 3));
|
|
60
|
+
},
|
|
61
|
+
get a() {
|
|
62
|
+
return made('a', counting(count => count === 1, 1));
|
|
63
|
+
},
|
|
64
|
+
get an() {
|
|
65
|
+
return made('an', counting(count => count === 1, 1));
|
|
66
|
+
},
|
|
67
|
+
count: num => made(`count(${num})`, counting(count => count === num, num), String(num)),
|
|
68
|
+
get some() {
|
|
69
|
+
return made('some', () => {
|
|
70
|
+
let count = 0;
|
|
71
|
+
return [match => {
|
|
72
|
+
if (match) ++count;
|
|
73
|
+
return count > 0;
|
|
74
|
+
}, () => count > 0 ? undefined : {
|
|
75
|
+
actual: 0,
|
|
76
|
+
expected: '1 or more',
|
|
77
|
+
saw: 'saw 0',
|
|
78
|
+
showDiff: false
|
|
79
|
+
}];
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
// every sighting of its kind must match, and there must be one: all of none proves nothing
|
|
83
|
+
get all() {
|
|
84
|
+
return made('all', () => {
|
|
85
|
+
let count = 0;
|
|
86
|
+
return [match => {
|
|
87
|
+
if (match) ++count;
|
|
88
|
+
}, ofKind => ofKind > 0 && count === ofKind ? undefined : {
|
|
89
|
+
actual: count,
|
|
90
|
+
expected: ofKind,
|
|
91
|
+
saw: `saw ${count} of ${ofKind}`,
|
|
92
|
+
showDiff: ofKind > 0
|
|
93
|
+
}];
|
|
94
|
+
}, 'every');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// the facts of a list as prose, joined: (one <li> and no <b>)
|
|
99
|
+
const spokenList = facts => `(${facts.map(fact => fact[5]).join(' and ')})`;
|
|
100
|
+
// a value as JSX writes it in a prop: title="x", size={3}
|
|
101
|
+
const jsxValue = value => typeof value === 'string' ? `"${value}"` : `{${display(value)}}`;
|
|
102
|
+
// each end says only what a sighting must be, and how it reads in a failure;
|
|
103
|
+
// ensure() starts the requirement
|
|
104
|
+
// spoken: the quantifier as prose, where it differs - none as no, count(3) as 3.
|
|
105
|
+
// Typed loosely, every end making a plain Fact; quantifiers() gives them their offered types
|
|
106
|
+
function ends(quantifier, requirement, finish, spoken = quantifier) {
|
|
107
|
+
const fact = (kind, test, end, prose, explain) => finish([kind, test, requirement, quantifier, end, `${spoken} ${prose}`, explain]);
|
|
108
|
+
const many = !['one', 'a', 'an', 'every', '1'].includes(spoken);
|
|
109
|
+
const noun = word => !many ? word : word.endsWith('s') ? `${word}es` : `${word}s`;
|
|
110
|
+
// a scoped fact is the outer kind, passing where the inner facts pass on the sightings
|
|
111
|
+
// scopeOf gives for a sighting
|
|
112
|
+
const scoped = (kind, end, prose, scopeOf) => (inner, to, proseTo) => {
|
|
113
|
+
const facts = inner.map(each => forKind(each, kind));
|
|
114
|
+
return fact(kind, scopeTest(scopeOf, facts), `${end}.${to}`, `${prose} ${proseTo}`, scopeExplain(scopeOf, facts));
|
|
115
|
+
};
|
|
116
|
+
// alone: present. with: facts on the element itself, its children among them
|
|
117
|
+
const element = (kind, end, prose, own) => {
|
|
118
|
+
const within = scoped(kind, end, prose, own);
|
|
119
|
+
const below = scoped(kind, end, prose, childrenScope);
|
|
120
|
+
const children = withMembers(facts => below(facts, `with.children(${listed(facts)})`, `with ${spokenList(facts)} in its children`), quantifiers(inner => below([inner], `with.children.${chained(inner)}`, `with ${inner[5]} in its children`)));
|
|
121
|
+
return Object.assign(fact(kind, () => true, end, prose), {
|
|
122
|
+
// facts, or a fn given the props for what facts cannot say
|
|
123
|
+
with: withMembers(withMembers(facts => Array.isArray(facts) ? within(facts, `with(${listed(facts)})`, `with ${spokenList(facts)}`) : fact(kind, seen => facts(propsOf(seen)), `${end}.with(${fnName(facts)})`, `${prose} passing ${fnName(facts)}`), quantifiers(inner => within([inner], `with.${chained(inner)}`, `with ${inner[5]}`), true)), {
|
|
124
|
+
children
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
// the text ends differ only in the sighting they read and whether case matters
|
|
129
|
+
const stringEnd = (kind, name, what, ci = false) => {
|
|
130
|
+
const norm = text => ci ? lower(text) : text;
|
|
131
|
+
const read = (seen, met) => typeof seen === 'string' && met(norm(seen));
|
|
132
|
+
const said = (ci ? 'case-insensitive ' : '') + noun(what);
|
|
133
|
+
return Object.assign(text => fact(kind, seen => read(seen, found => found === norm(text)), `${name}('${text}')`, (ci ? 'case-insensitive ' : '') + `'${text}' ${noun(what)}`), {
|
|
134
|
+
contains: substring => fact(kind, seen => read(seen, found => found.includes(norm(substring))), `${name}.contains('${substring}')`, `${said} containing '${substring}'`),
|
|
135
|
+
matches: regex => fact(kind, matching(regex, ci ? 'i' : ''), `${name}.matches(${String(regex)})`, `${said} matching ${String(regex)}`)
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
text: stringEnd('text', 'text', 'text node'),
|
|
140
|
+
textCi: stringEnd('text', 'textCi', 'text node', true),
|
|
141
|
+
interruptedText: stringEnd('interruptedText', 'interruptedText', 'element text'),
|
|
142
|
+
html: tag => element(`html:${tag}`, `html('${tag}')`, `<${tag}>`, seen => htmlOwnSightings(tag, propsOf(seen))),
|
|
143
|
+
component: name => element(`component:${name}`, `component('${name}')`, `<${name}>`, seen => componentOwnSightings(name, propsOf(seen))),
|
|
144
|
+
select: query => {
|
|
145
|
+
selector(query); // an invalid selector throws here, as the fact is made
|
|
146
|
+
return element(`select:${query}`, `select('${query}')`, `'${query}' ${noun('element')}`, selectOwnSightings);
|
|
147
|
+
},
|
|
148
|
+
fragment: () => fact('fragment', () => true, 'fragment()', noun('fragment')),
|
|
149
|
+
className: className => fact('className', seen => className === undefined || seen === className, className === undefined ? 'className()' : `className('${className}')`, className === undefined ? noun('class') : `class="${className}"`),
|
|
150
|
+
id: id => fact('id', seen => id === undefined || seen === id, id === undefined ? 'id()' : `id('${id}')`, id === undefined ? noun('id') : `id="${id}"`),
|
|
151
|
+
// prop() alone: passed, whatever the value - undefined included, as the tree has the key.
|
|
152
|
+
// .is: the value raw, compared by ===, so a handler or ref is matched by reference
|
|
153
|
+
prop: prop => Object.assign(fact(`prop:${prop}`, () => true, `prop('${prop}')`, `${prop} ${noun('prop')}`), {
|
|
154
|
+
is: value => fact(`prop:${prop}`, seen => seen === value, `prop('${prop}').is(${display(value)})`, `${prop}=${jsxValue(value)}`),
|
|
155
|
+
contains: substring => fact(`prop:${prop}`, seen => typeof seen === 'string' && seen.includes(substring), `prop('${prop}').contains('${substring}')`, `${prop} containing '${substring}'`),
|
|
156
|
+
matches: regex => fact(`prop:${prop}`, matching(regex), `prop('${prop}').matches(${String(regex)})`, `${prop} matching ${String(regex)}`),
|
|
157
|
+
// chai's deep.equal, which is deep-eql
|
|
158
|
+
exact: value => fact(`prop:${prop}`, seen => deepEqual(seen, value), `prop('${prop}').exact(${display(value)})`, `${prop} deep-equal to ${display(value)}`),
|
|
159
|
+
subset: shape => fact(`prop:${prop}`, seen => contains(shape, seen, 'anywhere'), `prop('${prop}').subset(${display(shape)})`, `${prop} with subset ${display(shape)}`),
|
|
160
|
+
duck: shape => fact(`prop:${prop}`, seen => contains(shape, seen, 'inPlace'), `prop('${prop}').duck(${display(shape)})`, `${prop} shaped like ${display(shape)}`),
|
|
161
|
+
// opt-in: a content-like prop may not be rendered, so it is walked only on asking.
|
|
162
|
+
// Alone: the value is content; with: facts on its whole tree, root included
|
|
163
|
+
content: () => {
|
|
164
|
+
const end = `prop('${prop}').content()`;
|
|
165
|
+
const prose = `${prop} holding content`;
|
|
166
|
+
const within = scoped(`prop:${prop}`, end, prose, seen => IsContentNode(seen) ? contentSightings(seen) : undefined);
|
|
167
|
+
return Object.assign(fact(`prop:${prop}`, IsContentNode, end, prose), {
|
|
168
|
+
with: withMembers(facts => within(facts, `with(${listed(facts)})`, `with ${spokenList(facts)}`), quantifiers(inner => within([inner], `with.${chained(inner)}`, `with ${inner[5]}`)))
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// fields as sxy-assert's, for a runner to read; showDiff where actual and expected are counts
|
|
175
|
+
export class EnsureError extends Error {
|
|
176
|
+
constructor(message, actual, expected, operator, showDiff) {
|
|
177
|
+
super(message);
|
|
178
|
+
_defineProperty(this, "actual", void 0);
|
|
179
|
+
_defineProperty(this, "expected", void 0);
|
|
180
|
+
_defineProperty(this, "operator", void 0);
|
|
181
|
+
_defineProperty(this, "showDiff", void 0);
|
|
182
|
+
_defineProperty(this, "name", 'EnsureError');
|
|
183
|
+
this.actual = actual;
|
|
184
|
+
this.expected = expected;
|
|
185
|
+
this.operator = operator;
|
|
186
|
+
this.showDiff = showDiff;
|
|
187
|
+
Error.captureStackTrace(this, ensure); // the stack starts at the test's ensure() call
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function ensure(tree, facts, options = {}) {
|
|
191
|
+
const sightings = contentSightings(tree);
|
|
192
|
+
const miss = check(sightings, facts);
|
|
193
|
+
if (miss === undefined) return;
|
|
194
|
+
const [fact, failure] = miss;
|
|
195
|
+
const {
|
|
196
|
+
readable = true,
|
|
197
|
+
color = process.stdout.isTTY && process.stdout.hasColors()
|
|
198
|
+
} = options;
|
|
199
|
+
const style = {
|
|
200
|
+
readable,
|
|
201
|
+
paint: color ? (tint, text) => styleText(tint, text, {
|
|
202
|
+
validateStream: false
|
|
203
|
+
}) : (_, text) => text
|
|
204
|
+
};
|
|
205
|
+
const message = `expected ${readable ? fact.spoken : fact.chained}, ${failure.saw}`
|
|
206
|
+
// the · holds the gap until sxy-test-runner keeps blank lines
|
|
207
|
+
+ (readable ? `\n rule: ${fact.chained}\n ·` : '') + `\n ${seenLine(fact, sightings, style, true)}`;
|
|
208
|
+
const {
|
|
209
|
+
actual,
|
|
210
|
+
expected,
|
|
211
|
+
showDiff
|
|
212
|
+
} = failure;
|
|
213
|
+
throw new EnsureError(message, actual, expected, fact.operator, showDiff);
|
|
214
|
+
}
|
|
215
|
+
// each fact started and told of its sightings, ready to decide
|
|
216
|
+
function tracked(sightings, facts) {
|
|
217
|
+
const started = buildFacts(facts);
|
|
218
|
+
const byKind = new Map();
|
|
219
|
+
for (const fact of started) byKind.set(fact.kind, [...(byKind.get(fact.kind) ?? []), fact]);
|
|
220
|
+
for (const [kind, value] of sightings) {
|
|
221
|
+
for (const fact of byKind.get(kind) ?? []) fact.track(fact.test(value));
|
|
222
|
+
}
|
|
223
|
+
for (const [kind, kindFacts] of byKind) {
|
|
224
|
+
if (!isSelectKind(kind)) continue;
|
|
225
|
+
for (const [, value] of selectSightings(sightings, kind)) {
|
|
226
|
+
for (const fact of kindFacts) fact.track(fact.test(value));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return started;
|
|
230
|
+
}
|
|
231
|
+
const isSelectKind = kind => kind.startsWith('select:');
|
|
232
|
+
const sightingsOf = (sightings, kind) => isSelectKind(kind) ? selectSightings(sightings, kind) : sightings.filter(([seenKind]) => seenKind === kind);
|
|
233
|
+
const ofKind = (sightings, kind) => sightingsOf(sightings, kind).length;
|
|
234
|
+
// the first fact to fail, with what it saw.
|
|
235
|
+
// Every fact decides, including those of a kind the tree never showed
|
|
236
|
+
function check(sightings, facts) {
|
|
237
|
+
for (const fact of tracked(sightings, facts)) {
|
|
238
|
+
const failure = fact.decide(ofKind(sightings, fact.kind));
|
|
239
|
+
if (failure !== undefined) return [fact, failure];
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
// matching: whether a sighting meets a scope's inner facts, stopping at the first miss
|
|
244
|
+
const scopeTest = (scopeOf, inner) => seen => {
|
|
245
|
+
const sightings = scopeOf(seen);
|
|
246
|
+
return sightings !== undefined && check(sightings, inner) === undefined;
|
|
247
|
+
};
|
|
248
|
+
// reporting, once a fact has failed: every inner fact a sighting missed and met.
|
|
249
|
+
// Its score: 2 for each fact met, 1 for each missed whose kind it holds
|
|
250
|
+
const scopeExplain = (scopeOf, inner) => seen => {
|
|
251
|
+
const sightings = scopeOf(seen);
|
|
252
|
+
if (sightings === undefined) return 'not content';
|
|
253
|
+
const misses = [];
|
|
254
|
+
const met = [];
|
|
255
|
+
let score = 0;
|
|
256
|
+
for (const fact of tracked(sightings, inner)) {
|
|
257
|
+
const seenOfKind = ofKind(sightings, fact.kind);
|
|
258
|
+
const failure = fact.decide(seenOfKind);
|
|
259
|
+
if (failure === undefined) {
|
|
260
|
+
score += 2;
|
|
261
|
+
met.push(fact);
|
|
262
|
+
} else {
|
|
263
|
+
if (seenOfKind > 0) score += 1;
|
|
264
|
+
misses.push({
|
|
265
|
+
fact,
|
|
266
|
+
failure,
|
|
267
|
+
sightings
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return misses.length === 0 ? undefined : {
|
|
272
|
+
misses,
|
|
273
|
+
met,
|
|
274
|
+
score
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
// a scoped inner fact lists its own sightings with their reasons, down to the miss;
|
|
278
|
+
// its description would only repeat the rest of the outer one
|
|
279
|
+
function explained(outcome, style) {
|
|
280
|
+
const {
|
|
281
|
+
readable,
|
|
282
|
+
paint
|
|
283
|
+
} = style;
|
|
284
|
+
if (outcome === 'not content') return paint('red', outcome);
|
|
285
|
+
const label = fact => readable ? fact.spoken : fact.chained;
|
|
286
|
+
const missed = outcome.misses.map(({
|
|
287
|
+
fact,
|
|
288
|
+
failure,
|
|
289
|
+
sightings
|
|
290
|
+
}) => {
|
|
291
|
+
if (fact.explain === undefined) return paint('red', `${label(fact)}: ${failure.saw}`);
|
|
292
|
+
// a children fact's one sighting is its element, so listing it would repeat the element
|
|
293
|
+
const element = fact.operator === '' ? sightingsOf(sightings, fact.kind)[0] : undefined;
|
|
294
|
+
const inner = element === undefined ? undefined : fact.explain(element[1]);
|
|
295
|
+
if (inner !== undefined) {
|
|
296
|
+
return `${readable ? 'in its children,' : 'children:'} ${explained(inner, style)}`;
|
|
297
|
+
}
|
|
298
|
+
return `${paint('red', `${failure.saw};`)} ${seenLine(fact, sightings, style)}`;
|
|
299
|
+
});
|
|
300
|
+
const met = outcome.met.length === 0 ? [] : [paint('green', `met: ${outcome.met.map(label).join(', ')}`)];
|
|
301
|
+
return [...missed, ...met].join('; ');
|
|
302
|
+
}
|
|
303
|
+
// met: first; not content: last
|
|
304
|
+
const rank = outcome => outcome === undefined ? Infinity : outcome === 'not content' ? -1 : outcome.score;
|
|
305
|
+
const fnName = fn => fn.name === '' ? 'fn' : fn.name;
|
|
306
|
+
// a fact as it reads inside a scope: one.prop('href'); a children fact carries no quantifier
|
|
307
|
+
const chained = ([,,, quantifier, end]) => quantifier === '' ? end : `${quantifier}.${end}`;
|
|
308
|
+
const listed = facts => `[${facts.map(chained).join(', ')}]`;
|
|
309
|
+
const childrenKind = 'children';
|
|
310
|
+
const childrenScope = seen => contentSightings(propsOf(seen).children);
|
|
311
|
+
// an element sighting's value is its props, or for a selector's, the element it matched
|
|
312
|
+
const propsOf = seen =>
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
314
|
+
seen instanceof SelectElement ? seen.props : seen;
|
|
315
|
+
// a children fact takes the kind of the element whose with list holds it
|
|
316
|
+
const forKind = (fact, kind) => fact[0] === childrenKind ? [kind, fact[1], fact[2], fact[3], fact[4], fact[5], fact[6]] : fact;
|
|
317
|
+
// a with list holds one sighting of its element's kind - the element itself - so a children fact
|
|
318
|
+
// passes where the element's content meets its inner facts
|
|
319
|
+
function childrenFact(inner, end, spoken) {
|
|
320
|
+
const fact = [childrenKind, scopeTest(childrenScope, inner), counting(count => count === 1, 1), '', end, `${spoken} in its children`, scopeExplain(childrenScope, inner)];
|
|
321
|
+
return fact; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
322
|
+
}
|
|
323
|
+
// the element's children as a tree, for a with list, beside the element's own facts:
|
|
324
|
+
// with([one.className('x'), children.one.html('li')]), or with([children([…])]) for a list of them
|
|
325
|
+
export const children = withMembers(facts => childrenFact(facts, `children(${listed(facts)})`, spokenList(facts)), quantifiers(inner => childrenFact([inner], `children.${chained(inner)}`, inner[5])));
|
|
326
|
+
function withMembers(fn, members) {
|
|
327
|
+
Object.defineProperties(fn, Object.getOwnPropertyDescriptors(members));
|
|
328
|
+
return fn; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
329
|
+
}
|
|
330
|
+
// each fact's requirement started for this run, with its own state
|
|
331
|
+
function buildFacts(facts) {
|
|
332
|
+
return facts.map(fact => {
|
|
333
|
+
const [kind, test, requirement, quantifier,, spoken, explain] = fact;
|
|
334
|
+
const [track, decide] = requirement();
|
|
335
|
+
return {
|
|
336
|
+
kind,
|
|
337
|
+
test,
|
|
338
|
+
track,
|
|
339
|
+
decide,
|
|
340
|
+
explain,
|
|
341
|
+
spoken,
|
|
342
|
+
chained: chained(fact),
|
|
343
|
+
operator: quantifier
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const countFailure = (actual, expected) => ({
|
|
348
|
+
actual,
|
|
349
|
+
expected,
|
|
350
|
+
saw: `saw ${actual}`,
|
|
351
|
+
showDiff: true
|
|
352
|
+
});
|
|
353
|
+
// counts every match, so a failure reports the full count, not the one it stopped at
|
|
354
|
+
function counting(pass, expected) {
|
|
355
|
+
return () => {
|
|
356
|
+
let count = 0;
|
|
357
|
+
return [match => {
|
|
358
|
+
if (match) ++count;
|
|
359
|
+
}, () => pass(count) ? undefined : countFailure(count, expected)];
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
const seenListed = 10;
|
|
363
|
+
// only those listed are shown, as a nested reason is costly to build
|
|
364
|
+
function listing(items, show, separator = ', ') {
|
|
365
|
+
return items.slice(0, seenListed).map(show).join(separator) + (items.length > seenListed ? `${separator}… ${items.length - seenListed} more` : '');
|
|
366
|
+
}
|
|
367
|
+
// each sighting with why it missed, where the fact can say, the nearest first;
|
|
368
|
+
// none of an element kind seen: list the other tags or components, as a near miss.
|
|
369
|
+
// Top level elements a line each, as their props and reasons run long; nested ones stay inline
|
|
370
|
+
function seenLine({
|
|
371
|
+
kind,
|
|
372
|
+
explain
|
|
373
|
+
}, sightings, style, top = false) {
|
|
374
|
+
const {
|
|
375
|
+
readable,
|
|
376
|
+
paint
|
|
377
|
+
} = style;
|
|
378
|
+
const separator = top && /^(html|component|select):/.test(kind) ? '\n ' : ', ';
|
|
379
|
+
const named = readable ? spokenKind(kind) : kind;
|
|
380
|
+
const seen = sightingsOf(sightings, kind).map(sighting => ({
|
|
381
|
+
sighting,
|
|
382
|
+
outcome: explain?.(sighting[1])
|
|
383
|
+
}));
|
|
384
|
+
if (seen.length > 0) {
|
|
385
|
+
// stable, so sightings as near as each other stay in document order
|
|
386
|
+
if (explain !== undefined) seen.sort((a, b) => rank(b.outcome) - rank(a.outcome));
|
|
387
|
+
const opening = separator === ', ' ? ' ' : separator;
|
|
388
|
+
const shown = listing(seen, ({
|
|
389
|
+
sighting,
|
|
390
|
+
outcome
|
|
391
|
+
}) => paint('white', displaySighting(sighting)) + (outcome === undefined ? '' : ` (${explained(outcome, style)})`), separator);
|
|
392
|
+
const heading = readable && seen.length > 1 ? plural(named) : named;
|
|
393
|
+
return `${paint('white', `${heading} seen:`)}${opening}${shown}`;
|
|
394
|
+
}
|
|
395
|
+
const family = /^(html|component):/.exec(kind)?.[1];
|
|
396
|
+
if (family === undefined) return `no ${named} seen`;
|
|
397
|
+
const others = sightings.filter(([seenKind]) => seenKind.startsWith(`${family}:`)).map(([seenKind]) => seenKind.slice(family.length + 1));
|
|
398
|
+
return others.length === 0 ? `no ${named} seen` : `no ${named} seen; ${family} seen: ${listing(others, name => name)}`;
|
|
399
|
+
}
|
|
400
|
+
// <button>s, title props, classes
|
|
401
|
+
const plural = named => named.endsWith('s') ? `${named}es` : `${named}s`;
|
|
402
|
+
// a kind as prose: <button>, title prop, element text
|
|
403
|
+
function spokenKind(kind) {
|
|
404
|
+
const [family, name] = kind.split(/:(.*)/);
|
|
405
|
+
if (family === 'html' || family === 'component') return `<${name}>`;
|
|
406
|
+
if (family === 'select') return `'${name}' element`;
|
|
407
|
+
if (family === 'prop') return `${name} prop`;
|
|
408
|
+
const plain = {
|
|
409
|
+
text: 'text node',
|
|
410
|
+
interruptedText: 'element text',
|
|
411
|
+
className: 'class'
|
|
412
|
+
};
|
|
413
|
+
return plain[kind] ?? kind;
|
|
414
|
+
}
|
|
415
|
+
// an element as its tag or name and props, as written: <a href='/x'>
|
|
416
|
+
function displaySighting([kind, value]) {
|
|
417
|
+
if (kind === 'fragment') return '<>';
|
|
418
|
+
if (value instanceof SelectElement) return displayElement(value.name, value.props);
|
|
419
|
+
const element = /^(?:html|component):(.*)$/.exec(kind)?.[1];
|
|
420
|
+
return element === undefined ? display(value) : displayElement(element, value);
|
|
421
|
+
}
|
|
422
|
+
function displayElement(element, props) {
|
|
423
|
+
const shown = Object.entries(props).filter(([name]) => name !== 'children').map(([name, prop]) => ` ${name}=${display(prop)}`);
|
|
424
|
+
return `<${element}${shown.join('')}>`;
|
|
425
|
+
}
|
|
426
|
+
// an element's edge: text either side of one is not one run of text
|
|
427
|
+
const edge = Symbol('edge');
|
|
428
|
+
// in document order; the unrendered tree: a component is seen by name, its content not expanded.
|
|
429
|
+
// Adjacent text is one sighting, as the page shows it: JSX splits `Hi, {name}.` into three
|
|
430
|
+
function contentSightings(content) {
|
|
431
|
+
const sightings = [];
|
|
432
|
+
let run; // the text sighting still open to joining
|
|
433
|
+
for (const token of contentTokens(content)) {
|
|
434
|
+
if (token === edge) run = undefined;
|
|
435
|
+
// a fragment is seen but is no break, as it renders nothing of its own
|
|
436
|
+
else if (token[0] === 'fragment') sightings.push([...token]);else if (token[0] === 'text') {
|
|
437
|
+
if (run === undefined) {
|
|
438
|
+
run = ['text', token[1]];
|
|
439
|
+
sightings.push(run);
|
|
440
|
+
} else run[1] += token[1];
|
|
441
|
+
} else {
|
|
442
|
+
run = undefined;
|
|
443
|
+
sightings.push([...token]);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
sightings.push(['elements', {
|
|
447
|
+
roots: selectNodes(content, null),
|
|
448
|
+
descend: true
|
|
449
|
+
}]);
|
|
450
|
+
return sightings;
|
|
451
|
+
}
|
|
452
|
+
// fragments, arrays and non-rendered values add no edge: their text runs on into their neighbours'
|
|
453
|
+
function contentTokens(content) {
|
|
454
|
+
if (ContentNodeIsArray(content)) return content.flatMap(contentTokens);
|
|
455
|
+
if (ContentNodeIsLiteral(content)) return [['text', String(content)]];
|
|
456
|
+
if (!ContentNodeIsElement(content)) return []; // null, undefined, boolean
|
|
457
|
+
const props = content[$props];
|
|
458
|
+
if (ContentNodeElementIsHtml(content)) {
|
|
459
|
+
const descendants = contentTokens(props.children);
|
|
460
|
+
return [edge, ...htmlOwnSightings(content[$type], props), ...descendants, edge];
|
|
461
|
+
}
|
|
462
|
+
if (ContentNodeElementIsComponent(content)) {
|
|
463
|
+
// the name stylesheets match by
|
|
464
|
+
const name = componentTypeIdentityKey(content[$type]);
|
|
465
|
+
/// TODO children is a prop the component may render or not, so the walk arguably should
|
|
466
|
+
/// stop here and leave what it holds to children() - but too much breaks without it for now
|
|
467
|
+
return [edge, ...componentOwnSightings(name, props), ...contentTokens(props.children), edge];
|
|
468
|
+
/// TODO components can have classNames, ids too...
|
|
469
|
+
}
|
|
470
|
+
const fragment = ['fragment', props]; // seen, but unwrapped: its content is walked
|
|
471
|
+
return [fragment, ...contentTokens(props.children)];
|
|
472
|
+
}
|
|
473
|
+
// an element's sightings of itself, its content left out
|
|
474
|
+
function htmlOwnSightings(tag, props) {
|
|
475
|
+
// class and id only on html: a component's className is still a prop, not a class
|
|
476
|
+
const classes = props.className ?? props.class;
|
|
477
|
+
const classNames = typeof classes === 'string' ? classes.split(/\s+/).filter(c => c !== '') : [];
|
|
478
|
+
const id = typeof props.id === 'string' ? [['id', props.id]] : [];
|
|
479
|
+
const text = contentText(props.children);
|
|
480
|
+
const interrupted = text === '' ? [] : [['interruptedText', text]];
|
|
481
|
+
return [[`html:${tag}`, props], ...classNames.map(c => ['className', c]), ...id, ...interrupted, ...propSightings(props)];
|
|
482
|
+
}
|
|
483
|
+
// an element's whole text, the markup between the words ignored, as textContent reads it.
|
|
484
|
+
// A component's children count, as the walk takes them: the two say the same about a tree
|
|
485
|
+
function contentText(content) {
|
|
486
|
+
if (ContentNodeIsArray(content)) return content.map(contentText).join('');
|
|
487
|
+
if (ContentNodeIsLiteral(content)) return String(content);
|
|
488
|
+
if (!ContentNodeIsElement(content)) return ''; // null, undefined, boolean
|
|
489
|
+
return contentText(content[$props].children);
|
|
490
|
+
}
|
|
491
|
+
function componentOwnSightings(name, props) {
|
|
492
|
+
return [[`component:${name}`, props], ...propSightings(props)];
|
|
493
|
+
}
|
|
494
|
+
const lower = text => text.toLowerCase();
|
|
495
|
+
// g and y would carry lastIndex from one sighting's test to the next, so they are dropped
|
|
496
|
+
function matching(regex, addFlags = '') {
|
|
497
|
+
const flags = [...new Set(regex.flags.replace(/[gy]/g, '') + addFlags)].join('');
|
|
498
|
+
const plain = new RegExp(regex.source, flags);
|
|
499
|
+
return seen => typeof seen === 'string' && plain.test(seen);
|
|
500
|
+
}
|
|
501
|
+
// subset: chai-subset's containSubset, but a function in the shape is compared by reference, not
|
|
502
|
+
// called: extra keys and array elements pass, each shape element matching some element, any order.
|
|
503
|
+
// duck: as TS structural typing - extra keys pass, but an array is a tuple: same length, in place.
|
|
504
|
+
// Beyond chai-subset: Object.is, as deep-eql, so NaN matches; Map and Set shapes are subsets too.
|
|
505
|
+
// As chai-subset: a key undefined in the shape matches a missing one
|
|
506
|
+
function contains(shape, value, arrays) {
|
|
507
|
+
const within = (inner, seen) => contains(inner, seen, arrays);
|
|
508
|
+
if (Object.is(shape, value)) return true;
|
|
509
|
+
if (typeof shape !== 'object' || shape === null) return false;
|
|
510
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
511
|
+
const someOf = (values, each) => values.some(seen => within(each, seen));
|
|
512
|
+
if (Array.isArray(shape)) {
|
|
513
|
+
if (!('length' in value) || typeof value.length !== 'number') return false;
|
|
514
|
+
const values = Array.from(value);
|
|
515
|
+
return arrays === 'inPlace' ? shape.length === values.length && shape.every((each, i) => within(each, values[i])) : shape.every(each => someOf(values, each));
|
|
516
|
+
}
|
|
517
|
+
if (shape instanceof Date) {
|
|
518
|
+
return value instanceof Date && Object.is(shape.getTime(), value.getTime());
|
|
519
|
+
}
|
|
520
|
+
if (shape instanceof Set) {
|
|
521
|
+
return value instanceof Set && [...shape].every(each => someOf([...value], each));
|
|
522
|
+
}
|
|
523
|
+
if (shape instanceof Map) {
|
|
524
|
+
return value instanceof Map && [...shape].every(([key, each]) => value.has(key) && within(each, value.get(key)));
|
|
525
|
+
}
|
|
526
|
+
const record = value;
|
|
527
|
+
return Object.entries(shape).every(([key, each]) => within(each, record[key]));
|
|
528
|
+
}
|
|
529
|
+
// every prop but children, whose content is walked instead
|
|
530
|
+
function propSightings(props) {
|
|
531
|
+
return Object.entries(props).filter(([name]) => name !== 'children').map(([name, value]) => [`prop:${name}`, value]);
|
|
532
|
+
}
|
|
533
|
+
// an element as a selector reads it; a component, by name, is the parent of what it holds.
|
|
534
|
+
// Each scope is a tree of its own, so a selector sees no ancestor outside it
|
|
535
|
+
var _children = /*#__PURE__*/new WeakMap();
|
|
536
|
+
class SelectElement {
|
|
537
|
+
constructor(family, name, props, parent, siblings) {
|
|
538
|
+
_defineProperty(this, "family", void 0);
|
|
539
|
+
_defineProperty(this, "name", void 0);
|
|
540
|
+
_defineProperty(this, "props", void 0);
|
|
541
|
+
_defineProperty(this, "parent", void 0);
|
|
542
|
+
_defineProperty(this, "siblings", void 0);
|
|
543
|
+
_classPrivateFieldInitSpec(this, _children, void 0);
|
|
544
|
+
this.family = family;
|
|
545
|
+
this.name = name;
|
|
546
|
+
this.props = props;
|
|
547
|
+
this.parent = parent;
|
|
548
|
+
this.siblings = siblings;
|
|
549
|
+
}
|
|
550
|
+
get children() {
|
|
551
|
+
return _classPrivateFieldGet(_children, this) ?? _classPrivateFieldSet(_children, this, selectNodes(this.props.children, this));
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
// fragments and arrays unwrapped, as the page has no node for them
|
|
555
|
+
function selectNodes(content, parent) {
|
|
556
|
+
const nodes = [];
|
|
557
|
+
const add = each => {
|
|
558
|
+
if (ContentNodeIsArray(each)) each.forEach(add);else if (ContentNodeIsLiteral(each)) nodes.push(String(each));else if (!ContentNodeIsElement(each)) return; // null, undefined, boolean
|
|
559
|
+
else if (ContentNodeElementIsHtml(each)) {
|
|
560
|
+
nodes.push(new SelectElement('html', each[$type], each[$props], parent, nodes));
|
|
561
|
+
} else if (ContentNodeElementIsComponent(each)) {
|
|
562
|
+
const name = componentTypeIdentityKey(each[$type]);
|
|
563
|
+
nodes.push(new SelectElement('component', name, each[$props], parent, nodes));
|
|
564
|
+
} else add(each[$props].children);
|
|
565
|
+
};
|
|
566
|
+
add(content);
|
|
567
|
+
return nodes;
|
|
568
|
+
}
|
|
569
|
+
// its own sightings, and itself to match: a children fact in its with list is of its kind.
|
|
570
|
+
// It keeps its place in the tree, so an ancestor in the selector still holds
|
|
571
|
+
const selectOwnSightings = seen => {
|
|
572
|
+
const element = seen; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
573
|
+
const {
|
|
574
|
+
family,
|
|
575
|
+
name,
|
|
576
|
+
props
|
|
577
|
+
} = element;
|
|
578
|
+
const own = family === 'html' ? htmlOwnSightings(name, props) : componentOwnSightings(name, props);
|
|
579
|
+
return [...own, ['elements', {
|
|
580
|
+
roots: [element],
|
|
581
|
+
descend: false
|
|
582
|
+
}]];
|
|
583
|
+
};
|
|
584
|
+
function selectSightings(sightings, kind) {
|
|
585
|
+
const matches = selector(kind.slice('select:'.length));
|
|
586
|
+
const found = [];
|
|
587
|
+
const visit = (nodes, descend) => {
|
|
588
|
+
for (const node of nodes) {
|
|
589
|
+
if (typeof node === 'string') continue;
|
|
590
|
+
if (matches(node)) found.push([kind, node]);
|
|
591
|
+
if (descend) visit(node.children, true);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
for (const [seenKind, value] of sightings) {
|
|
595
|
+
if (seenKind !== 'elements') continue;
|
|
596
|
+
const {
|
|
597
|
+
roots,
|
|
598
|
+
descend
|
|
599
|
+
} = value; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
600
|
+
visit(roots, descend);
|
|
601
|
+
}
|
|
602
|
+
return found;
|
|
603
|
+
}
|
|
604
|
+
const selectors = new Map();
|
|
605
|
+
// on the first select(): ~100ms and 44 modules at import, which no other fact needs
|
|
606
|
+
let cssSelect;
|
|
607
|
+
// shipped in the package's vendor/, as dist is
|
|
608
|
+
export const cssSelectBundle = fileURLToPath(new URL('../../vendor/css-select.js', import.meta.url));
|
|
609
|
+
// the vendor bundle (one file, ~9ms), else the package (44 modules, ~100ms)
|
|
610
|
+
function loadCssSelect() {
|
|
611
|
+
const bundled = existsSync(cssSelectBundle);
|
|
612
|
+
if (!bundled) {
|
|
613
|
+
warn(`tungsten ensure: no css-select bundle at ${cssSelectBundle}; ` + 'loading the package instead, which is slower');
|
|
614
|
+
}
|
|
615
|
+
const load = createRequire(import.meta.url);
|
|
616
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
617
|
+
return load(bundled ? cssSelectBundle : 'css-select');
|
|
618
|
+
}
|
|
619
|
+
function selector(query) {
|
|
620
|
+
let compiled = selectors.get(query);
|
|
621
|
+
if (compiled === undefined) {
|
|
622
|
+
cssSelect ??= loadCssSelect();
|
|
623
|
+
// xmlMode: names as written, so Link is a component and link no tag
|
|
624
|
+
compiled = cssSelect.compile(query, {
|
|
625
|
+
adapter,
|
|
626
|
+
xmlMode: true,
|
|
627
|
+
cacheResults: false
|
|
628
|
+
});
|
|
629
|
+
selectors.set(query, compiled);
|
|
630
|
+
}
|
|
631
|
+
return compiled;
|
|
632
|
+
}
|
|
633
|
+
// as the page renders it: true present and empty; false, null and undefined absent.
|
|
634
|
+
// class and id only on html, as a component's className is still a prop
|
|
635
|
+
function attribute({
|
|
636
|
+
family,
|
|
637
|
+
props
|
|
638
|
+
}, name) {
|
|
639
|
+
const html = family === 'html';
|
|
640
|
+
if (name === 'children' || !html && (name === 'class' || name === 'id')) return undefined;
|
|
641
|
+
const value = !html ? props[name] : name === 'class' ? props.className ?? props.class : name === 'for' ? props.htmlFor ?? props.for : props[name];
|
|
642
|
+
if (value === undefined || value === null || value === false) return undefined;
|
|
643
|
+
if (value === true) return '';
|
|
644
|
+
if (typeof value === 'string') return value;
|
|
645
|
+
if (typeof value === 'number' || typeof value === 'bigint') return String(value);
|
|
646
|
+
return ''; // a handler or data: present, with no text to compare
|
|
647
|
+
}
|
|
648
|
+
function hasAncestorIn(node, nodes) {
|
|
649
|
+
for (let up = typeof node === 'string' ? null : node.parent; up !== null; up = up.parent) {
|
|
650
|
+
if (nodes.includes(up)) return true;
|
|
651
|
+
}
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
const adapter = {
|
|
655
|
+
isTag: node => typeof node !== 'string',
|
|
656
|
+
getName: element => element.name,
|
|
657
|
+
getParent: element => element.parent,
|
|
658
|
+
getChildren: node => typeof node === 'string' ? [] : node.children,
|
|
659
|
+
getSiblings: node => typeof node === 'string' ? [node] : node.siblings,
|
|
660
|
+
getText: node => typeof node === 'string' ? node : contentText(node.props.children),
|
|
661
|
+
getAttributeValue: attribute,
|
|
662
|
+
hasAttrib: (element, name) => attribute(element, name) !== undefined,
|
|
663
|
+
removeSubsets: nodes => nodes.filter((node, i) => nodes.indexOf(node) === i && !hasAncestorIn(node, nodes))
|
|
664
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure.trial.d.ts","sourceRoot":"","sources":["../../src/testing/ensure.trial.ts"],"names":[],"mappings":""}
|