@absolutejs/absolute 0.19.0-beta.1043 → 0.19.0-beta.1045
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/angular/browser.js +10358 -0
- package/dist/angular/browser.js.map +260 -0
- package/dist/angular/components/constants.js +101 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +58 -0
- package/dist/angular/components/core/streamingSlotRegistry.js +114 -0
- package/dist/angular/components/defer-slot-payload.js +6 -0
- package/dist/angular/components/defer-slot-templates.directive.js +44 -0
- package/dist/angular/components/defer-slot.component.js +152 -0
- package/dist/angular/components/image.component.js +202 -0
- package/dist/angular/components/index.js +4 -0
- package/dist/angular/components/stream-slot.component.js +102 -0
- package/dist/angular/hmrPreserveCore.ts +188 -0
- package/dist/angular/index.js +15793 -0
- package/dist/angular/index.js.map +299 -0
- package/dist/angular/server.js +6357 -0
- package/dist/angular/server.js.map +61 -0
- package/dist/build.js +27484 -0
- package/dist/build.js.map +146 -0
- package/dist/cli/config/client.js +527 -0
- package/dist/cli/config/server.js +37130 -0
- package/dist/cli/htmx/htmx.min.js +1 -0
- package/dist/cli/index.js +180085 -0
- package/dist/client/index.js +1267 -0
- package/dist/client/index.js.map +31 -0
- package/dist/core/streamingSlotRegistrar.js +138 -0
- package/dist/core/streamingSlotRegistrar.js.map +10 -0
- package/dist/core/streamingSlotRegistry.js +194 -0
- package/dist/core/streamingSlotRegistry.js.map +11 -0
- package/dist/dev/client/constants.ts +26 -0
- package/dist/dev/client/cssUtils.ts +311 -0
- package/dist/dev/client/domDiff.ts +226 -0
- package/dist/dev/client/domState.ts +423 -0
- package/dist/dev/client/domTracker.ts +61 -0
- package/dist/dev/client/errorOverlay.ts +445 -0
- package/dist/dev/client/frameworkDetect.ts +63 -0
- package/dist/dev/client/handlers/angularHmrShim.ts +88 -0
- package/dist/dev/client/handlers/angularRemount.ts +362 -0
- package/dist/dev/client/handlers/angularRemountWiring.ts +52 -0
- package/dist/dev/client/handlers/html.ts +364 -0
- package/dist/dev/client/handlers/htmx.ts +278 -0
- package/dist/dev/client/handlers/react.ts +108 -0
- package/dist/dev/client/handlers/rebuild.ts +153 -0
- package/dist/dev/client/handlers/svelte.ts +334 -0
- package/dist/dev/client/handlers/vue.ts +292 -0
- package/dist/dev/client/headPatch.ts +233 -0
- package/dist/dev/client/hmrClient.ts +352 -0
- package/dist/dev/client/hmrState.ts +14 -0
- package/dist/dev/client/hmrToast.ts +150 -0
- package/dist/dev/client/moduleVersions.ts +62 -0
- package/dist/dev/client/reactRefreshSetup.ts +31 -0
- package/dist/dev/client/vendor/lview/lViewOps.ts +196 -0
- package/dist/dev/client/vendor/lview/slotConstants.ts +44 -0
- package/dist/dev/client/vendor/reactRefreshRuntime.d.ts +12 -0
- package/dist/dev/client/vendor/reactRefreshRuntime.js +313 -0
- package/dist/image-client/imageClient.js +69 -0
- package/dist/index.js +46260 -0
- package/dist/index.js.map +322 -0
- package/dist/islands/browser.js +259 -0
- package/dist/islands/browser.js.map +15 -0
- package/dist/islands/index.js +2415 -0
- package/dist/islands/index.js.map +37 -0
- package/dist/react/browser.js +374 -0
- package/dist/react/browser.js.map +19 -0
- package/dist/react/components/browser/index.js +467 -0
- package/dist/react/components/index.js +684 -0
- package/dist/react/components/index.js.map +18 -0
- package/dist/react/hooks/index.js +285 -0
- package/dist/react/hooks/index.js.map +14 -0
- package/dist/react/index.js +4258 -0
- package/dist/react/index.js.map +56 -0
- package/dist/react/jsxDevRuntimeCompat.js +90 -0
- package/dist/react/jsxDevRuntimeCompat.js.map +10 -0
- package/dist/react/router/browser.js +95 -0
- package/dist/react/router/browser.js.map +10 -0
- package/dist/react/router/index.js +95 -0
- package/dist/react/router/index.js.map +10 -0
- package/dist/react/server.js +1895 -0
- package/dist/react/server.js.map +26 -0
- package/dist/src/angular/Island.browser.d.ts +34 -0
- package/dist/src/angular/Island.d.ts +29 -0
- package/dist/src/angular/angularDeps.d.ts +2 -0
- package/dist/src/angular/angularPatch.d.ts +1 -0
- package/dist/src/angular/animationProviders.d.ts +2 -0
- package/dist/src/angular/browser.d.ts +14 -0
- package/dist/src/angular/components/constants.d.ts +96 -0
- package/dist/src/angular/components/defer-slot-payload.d.ts +7 -0
- package/dist/src/angular/components/defer-slot-templates.directive.d.ts +21 -0
- package/dist/src/angular/components/defer-slot.component.d.ts +29 -0
- package/dist/src/angular/components/image.component.d.ts +42 -0
- package/dist/src/angular/components/index.d.ts +4 -0
- package/dist/src/angular/components/stream-slot.component.d.ts +20 -0
- package/dist/src/angular/composables/index.d.ts +6 -0
- package/dist/src/angular/composables/usePageContext.d.ts +16 -0
- package/dist/src/angular/composables/useResource.d.ts +57 -0
- package/dist/src/angular/composables/useSubscription.d.ts +33 -0
- package/dist/src/angular/composables/useTimers.d.ts +18 -0
- package/dist/src/angular/createIsland.browser.d.ts +2 -0
- package/dist/src/angular/createIsland.d.ts +2 -0
- package/dist/src/angular/deterministicEnv.d.ts +26 -0
- package/dist/src/angular/hmrPreserveCore.d.ts +21 -0
- package/dist/src/angular/httpTransferCache.d.ts +12 -0
- package/dist/src/angular/index.d.ts +14 -0
- package/dist/src/angular/injectorPatch.d.ts +1 -0
- package/dist/src/angular/islandStore.d.ts +9 -0
- package/dist/src/angular/islands.d.ts +4 -0
- package/dist/src/angular/lowerDeferSyntax.d.ts +18 -0
- package/dist/src/angular/lowerServerIslands.d.ts +1 -0
- package/dist/src/angular/pageHandler.d.ts +48 -0
- package/dist/src/angular/pendingTask.d.ts +1 -0
- package/dist/src/angular/preserveAcrossHmr.d.ts +12 -0
- package/dist/src/angular/renderIsland.d.ts +2 -0
- package/dist/src/angular/requestProviders.d.ts +5 -0
- package/dist/src/angular/resolveAngularPackage.d.ts +19 -0
- package/dist/src/angular/routerRedirectProviders.d.ts +6 -0
- package/dist/src/angular/server.d.ts +4 -0
- package/dist/src/angular/ssrRender.d.ts +13 -0
- package/dist/src/angular/ssrSanitizer.d.ts +3 -0
- package/dist/src/angular/staticAnalyzeSpaRoutes.d.ts +7 -0
- package/dist/src/build/angularLinkerPlugin.d.ts +29 -0
- package/dist/src/build/buildAngularVendor.d.ts +40 -0
- package/dist/src/build/buildDepVendor.d.ts +2 -0
- package/dist/src/build/buildEmberVendor.d.ts +24 -0
- package/dist/src/build/buildReactVendor.d.ts +8 -0
- package/dist/src/build/buildSvelteVendor.d.ts +6 -0
- package/dist/src/build/buildVueVendor.d.ts +6 -0
- package/dist/src/build/chainInlineSourcemaps.d.ts +13 -0
- package/dist/src/build/compileAngular.d.ts +40 -0
- package/dist/src/build/compileEmber.d.ts +43 -0
- package/dist/src/build/compileSvelte.d.ts +14 -0
- package/dist/src/build/compileTailwind.d.ts +5 -0
- package/dist/src/build/compileVue.d.ts +22 -0
- package/dist/src/build/externalAssetPlugin.d.ts +2 -0
- package/dist/src/build/generateManifest.d.ts +2 -0
- package/dist/src/build/generateReactIndexes.d.ts +2 -0
- package/dist/src/build/htmlScriptHMRPlugin.d.ts +13 -0
- package/dist/src/build/index.d.ts +2 -0
- package/dist/src/build/islandEntries.d.ts +32 -0
- package/dist/src/build/islandRegistryTransform.d.ts +17 -0
- package/dist/src/build/nativeRewrite.d.ts +5 -0
- package/dist/src/build/optimizeHtmlImages.d.ts +2 -0
- package/dist/src/build/outputLogs.d.ts +1 -0
- package/dist/src/build/parseAngularConfigImports.d.ts +9 -0
- package/dist/src/build/parseVueSpaRoutes.d.ts +20 -0
- package/dist/src/build/resolvePackageImport.d.ts +9 -0
- package/dist/src/build/rewriteImports.d.ts +8 -0
- package/dist/src/build/rewriteImportsPlugin.d.ts +48 -0
- package/dist/src/build/rewriteReactImports.d.ts +7 -0
- package/dist/src/build/runAngularHandlerScan.d.ts +7 -0
- package/dist/src/build/scanAngularHandlerCalls.d.ts +13 -0
- package/dist/src/build/scanAngularPageRoutes.d.ts +10 -0
- package/dist/src/build/scanConventions.d.ts +5 -0
- package/dist/src/build/scanCssEntryPoints.d.ts +1 -0
- package/dist/src/build/scanEntryPoints.d.ts +1 -0
- package/dist/src/build/scanRouteRegistrations.d.ts +23 -0
- package/dist/src/build/scanVueSsrOnlyPages.d.ts +6 -0
- package/dist/src/build/staticIslandPages.d.ts +9 -0
- package/dist/src/build/stylePreprocessor.d.ts +26 -0
- package/dist/src/build/tailwindCompiler.d.ts +8 -0
- package/dist/src/build/updateAssetPaths.d.ts +1 -0
- package/dist/src/build/vendorEntrySource.d.ts +1 -0
- package/dist/src/build/verifyAngularCoreUniqueness.d.ts +2 -0
- package/dist/src/build/vueAutoRouterTransform.d.ts +1 -0
- package/dist/src/build/wrapHTMLScript.d.ts +17 -0
- package/dist/src/build.d.ts +2 -0
- package/dist/src/cli/add/dependencies.d.ts +12 -0
- package/dist/src/cli/cache.d.ts +15 -0
- package/dist/src/cli/config/absolute/AbsoluteConfigPanel.d.ts +6 -0
- package/dist/src/cli/config/absolute/editAbsoluteConfig.d.ts +5 -0
- package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +14 -0
- package/dist/src/cli/config/client.d.ts +1 -0
- package/dist/src/cli/config/configCert.d.ts +12 -0
- package/dist/src/cli/config/eslint/EslintPanel.d.ts +6 -0
- package/dist/src/cli/config/eslint/configAst.d.ts +18 -0
- package/dist/src/cli/config/eslint/editConfigRule.d.ts +6 -0
- package/dist/src/cli/config/eslint/eslintStyles.d.ts +1 -0
- package/dist/src/cli/config/eslint/resolveConfig.d.ts +3 -0
- package/dist/src/cli/config/eslint/serializeValue.d.ts +9 -0
- package/dist/src/cli/config/guards.d.ts +4 -0
- package/dist/src/cli/config/packageJson/PackageJsonPanel.d.ts +6 -0
- package/dist/src/cli/config/packageJson/editPackageJson.d.ts +9 -0
- package/dist/src/cli/config/packageJson/resolvePackageJson.d.ts +9 -0
- package/dist/src/cli/config/page/ConfigShell.d.ts +6 -0
- package/dist/src/cli/config/page/FieldEditor.d.ts +9 -0
- package/dist/src/cli/config/page/PanelHost.d.ts +6 -0
- package/dist/src/cli/config/page/configStyles.d.ts +1 -0
- package/dist/src/cli/config/panels.d.ts +7 -0
- package/dist/src/cli/config/prettier/PrettierPanel.d.ts +6 -0
- package/dist/src/cli/config/prettier/editPrettier.d.ts +5 -0
- package/dist/src/cli/config/prettier/resolvePrettier.d.ts +11 -0
- package/dist/src/cli/config/schema/fromJsonSchema.d.ts +3 -0
- package/dist/src/cli/config/schema/fromType.d.ts +2 -0
- package/dist/src/cli/config/schema/serialize.d.ts +1 -0
- package/dist/src/cli/config/server.d.ts +298 -0
- package/dist/src/cli/config/tsconfig/TsconfigPanel.d.ts +6 -0
- package/dist/src/cli/config/tsconfig/editTsconfig.d.ts +5 -0
- package/dist/src/cli/config/tsconfig/resolveTsconfig.d.ts +8 -0
- package/dist/src/cli/config/tsconfig/tsconfigStyles.d.ts +1 -0
- package/dist/src/cli/discoverInstances.d.ts +5 -0
- package/dist/src/cli/generate/componentTemplates.d.ts +7 -0
- package/dist/src/cli/generate/context.d.ts +30 -0
- package/dist/src/cli/generate/cssStrategy.d.ts +20 -0
- package/dist/src/cli/generate/frameworkKey.d.ts +3 -0
- package/dist/src/cli/generate/frameworks.d.ts +40 -0
- package/dist/src/cli/generate/generateApi.d.ts +3 -0
- package/dist/src/cli/generate/generateComponent.d.ts +4 -0
- package/dist/src/cli/generate/generatePage.d.ts +4 -0
- package/dist/src/cli/generate/naming.d.ts +5 -0
- package/dist/src/cli/generate/navData.d.ts +10 -0
- package/dist/src/cli/generate/outcome.d.ts +17 -0
- package/dist/src/cli/generate/pageTemplates.d.ts +11 -0
- package/dist/src/cli/generate/routeWiring.d.ts +40 -0
- package/dist/src/cli/generate/staticNav.d.ts +5 -0
- package/dist/src/cli/heapDiff.d.ts +1 -0
- package/dist/src/cli/htmx/install.d.ts +6 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/inspectData.d.ts +12 -0
- package/dist/src/cli/inspectTui.d.ts +1 -0
- package/dist/src/cli/instanceStatus.d.ts +22 -0
- package/dist/src/cli/interactive.d.ts +2 -0
- package/dist/src/cli/psTui.d.ts +1 -0
- package/dist/src/cli/scripts/add.d.ts +1 -0
- package/dist/src/cli/scripts/analyze.d.ts +1 -0
- package/dist/src/cli/scripts/api.d.ts +1 -0
- package/dist/src/cli/scripts/build.d.ts +1 -0
- package/dist/src/cli/scripts/compile.d.ts +2 -0
- package/dist/src/cli/scripts/dev.d.ts +1 -0
- package/dist/src/cli/scripts/doctor.d.ts +1 -0
- package/dist/src/cli/scripts/env.d.ts +7 -0
- package/dist/src/cli/scripts/eslint.d.ts +16 -0
- package/dist/src/cli/scripts/generate.d.ts +1 -0
- package/dist/src/cli/scripts/htmx.d.ts +1 -0
- package/dist/src/cli/scripts/info.d.ts +1 -0
- package/dist/src/cli/scripts/inspect.d.ts +1 -0
- package/dist/src/cli/scripts/islands.d.ts +1 -0
- package/dist/src/cli/scripts/logs.d.ts +1 -0
- package/dist/src/cli/scripts/ls.d.ts +1 -0
- package/dist/src/cli/scripts/mem.d.ts +1 -0
- package/dist/src/cli/scripts/prettier.d.ts +3 -0
- package/dist/src/cli/scripts/ps.d.ts +1 -0
- package/dist/src/cli/scripts/remove.d.ts +1 -0
- package/dist/src/cli/scripts/routes.d.ts +1 -0
- package/dist/src/cli/scripts/start.d.ts +1 -0
- package/dist/src/cli/scripts/telemetry.d.ts +5 -0
- package/dist/src/cli/scripts/tunnelRelay.d.ts +9 -0
- package/dist/src/cli/scripts/typecheck.d.ts +1 -0
- package/dist/src/cli/scripts/workspace.d.ts +11 -0
- package/dist/src/cli/telemetryEvent.d.ts +1 -0
- package/dist/src/cli/tuiPrimitives.d.ts +14 -0
- package/dist/src/cli/utils.d.ts +15 -0
- package/dist/src/cli/workspaceTui.d.ts +44 -0
- package/dist/src/client/hydrators/react.d.ts +3 -0
- package/dist/src/client/hydrators/svelte.d.ts +2 -0
- package/dist/src/client/hydrators/vue.d.ts +2 -0
- package/dist/src/client/index.d.ts +4 -0
- package/dist/src/client/islandResolver.d.ts +2 -0
- package/dist/src/client/islandRuntime.d.ts +9 -0
- package/dist/src/client/islandStore.d.ts +22 -0
- package/dist/src/client/preserveIslandMarkup.d.ts +16 -0
- package/dist/src/client/streamSwap.d.ts +1 -0
- package/dist/src/constants.d.ts +96 -0
- package/dist/src/core/angularServerModule.d.ts +1 -0
- package/dist/src/core/build.d.ts +14 -0
- package/dist/src/core/currentIslandRegistry.d.ts +7 -0
- package/dist/src/core/devBuild.d.ts +23 -0
- package/dist/src/core/devRouteRegistrationCallsite.d.ts +4 -0
- package/dist/src/core/devVendorPaths.d.ts +17 -0
- package/dist/src/core/index.d.ts +7 -0
- package/dist/src/core/islandManifest.d.ts +3 -0
- package/dist/src/core/islandMarkupAttributes.d.ts +12 -0
- package/dist/src/core/islandPageContext.d.ts +12 -0
- package/dist/src/core/islandSsr.d.ts +6 -0
- package/dist/src/core/islands.d.ts +16 -0
- package/dist/src/core/loadIslandRegistry.d.ts +1 -0
- package/dist/src/core/lookup.d.ts +1 -0
- package/dist/src/core/normalizeIslandProps.d.ts +15 -0
- package/dist/src/core/pageHandlers.d.ts +5 -0
- package/dist/src/core/prepare.d.ts +417 -0
- package/dist/src/core/prerender.d.ts +31 -0
- package/dist/src/core/renderIslandMarkup.d.ts +13 -0
- package/dist/src/core/responseEnhancers.d.ts +10 -0
- package/dist/src/core/staticStreaming.d.ts +25 -0
- package/dist/src/core/streamingSlotRegistrar.d.ts +16 -0
- package/dist/src/core/streamingSlotRegistry.d.ts +2 -0
- package/dist/src/core/streamingSlotWarningScope.d.ts +4 -0
- package/dist/src/core/svelteServerModule.d.ts +1 -0
- package/dist/src/core/vueServerModule.d.ts +1 -0
- package/dist/src/core/wrapPageHandlerWithStreamingSlots.d.ts +2 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +58 -0
- package/dist/src/dev/angular/hmrCompiler.d.ts +2 -0
- package/dist/src/dev/angular/hmrImportGenerator.d.ts +3 -0
- package/dist/src/dev/angular/hmrInjectionPlugin.d.ts +8 -0
- package/dist/src/dev/angular/resolveOwningComponents.d.ts +16 -0
- package/dist/src/dev/angular/vendor/translator/api/ast_factory.d.ts +363 -0
- package/dist/src/dev/angular/vendor/translator/api/import_generator.d.ts +49 -0
- package/dist/src/dev/angular/vendor/translator/context.d.ts +18 -0
- package/dist/src/dev/angular/vendor/translator/translator.d.ts +75 -0
- package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +12 -0
- package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +66 -0
- package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +13 -0
- package/dist/src/dev/assetStore.d.ts +8 -0
- package/dist/src/dev/buildHMRClient.d.ts +1 -0
- package/dist/src/dev/clientManager.d.ts +33 -0
- package/dist/src/dev/configResolver.d.ts +16 -0
- package/dist/src/dev/dependencyGraph.d.ts +10 -0
- package/dist/src/dev/devCert.d.ts +11 -0
- package/dist/src/dev/fileHashTracker.d.ts +2 -0
- package/dist/src/dev/fileWatcher.d.ts +4 -0
- package/dist/src/dev/moduleMapper.d.ts +27 -0
- package/dist/src/dev/moduleServer.d.ts +24 -0
- package/dist/src/dev/moduleVersionTracker.d.ts +7 -0
- package/dist/src/dev/pathUtils.d.ts +8 -0
- package/dist/src/dev/reactComponentClassifier.d.ts +2 -0
- package/dist/src/dev/rebuildTrigger.d.ts +11 -0
- package/dist/src/dev/requestInspector.d.ts +43 -0
- package/dist/src/dev/serverEntryWatcher.d.ts +5 -0
- package/dist/src/dev/simpleHTMLHMR.d.ts +4 -0
- package/dist/src/dev/simpleHTMXHMR.d.ts +4 -0
- package/dist/src/dev/transformCache.d.ts +22 -0
- package/dist/src/dev/tunnel/client.d.ts +20 -0
- package/dist/src/dev/tunnel/protocol.d.ts +85 -0
- package/dist/src/dev/tunnel/relay.d.ts +28 -0
- package/dist/src/dev/webSocket.d.ts +9 -0
- package/dist/src/ember/browser.d.ts +24 -0
- package/dist/src/ember/index.d.ts +2 -0
- package/dist/src/ember/pageHandler.d.ts +35 -0
- package/dist/src/ember/server.d.ts +2 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/islands/browser.d.ts +3 -0
- package/dist/src/islands/index.d.ts +3 -0
- package/dist/src/islands/pageMetadata.d.ts +13 -0
- package/dist/src/islands/sourceMetadata.d.ts +10 -0
- package/dist/src/plugins/devtoolsJson.d.ts +58 -0
- package/dist/src/plugins/hmr.d.ts +163 -0
- package/dist/src/plugins/imageOptimizer.d.ts +67 -0
- package/dist/src/plugins/index.d.ts +3 -0
- package/dist/src/plugins/networking.d.ts +2 -0
- package/dist/src/plugins/openApiPlugin.d.ts +11 -0
- package/dist/src/plugins/pageRouter.d.ts +1 -0
- package/dist/src/react/Island.browser.d.ts +2 -0
- package/dist/src/react/Island.d.ts +2 -0
- package/dist/src/react/bridgeInternals.d.ts +1 -0
- package/dist/src/react/browser.d.ts +3 -0
- package/dist/src/react/components/Head.d.ts +2 -0
- package/dist/src/react/components/Image.d.ts +2 -0
- package/dist/src/react/components/JsonLd.d.ts +4 -0
- package/dist/src/react/components/StreamSlot.browser.d.ts +10 -0
- package/dist/src/react/components/StreamSlot.d.ts +10 -0
- package/dist/src/react/components/SuspenseSlot.browser.d.ts +22 -0
- package/dist/src/react/components/SuspenseSlot.d.ts +37 -0
- package/dist/src/react/components/browser/index.d.ts +5 -0
- package/dist/src/react/components/index.d.ts +5 -0
- package/dist/src/react/createIsland.browser.d.ts +2 -0
- package/dist/src/react/createIsland.d.ts +2 -0
- package/dist/src/react/hooks/index.d.ts +3 -0
- package/dist/src/react/hooks/useIslandStore.d.ts +3 -0
- package/dist/src/react/hooks/useMediaQuery.d.ts +7 -0
- package/dist/src/react/index.d.ts +4 -0
- package/dist/src/react/jsxDevRuntimeCompat.d.ts +8 -0
- package/dist/src/react/pageHandler.d.ts +25 -0
- package/dist/src/react/router/UniversalRouter.d.ts +43 -0
- package/dist/src/react/router/browser.d.ts +2 -0
- package/dist/src/react/router/index.d.ts +2 -0
- package/dist/src/react/server.d.ts +1 -0
- package/dist/src/react/staticAnalyzeSpaRoutes.d.ts +7 -0
- package/dist/src/svelte/browser.d.ts +4 -0
- package/dist/src/svelte/createIsland.browser.d.ts +2 -0
- package/dist/src/svelte/createIsland.d.ts +2 -0
- package/dist/src/svelte/index.d.ts +6 -0
- package/dist/src/svelte/islandStore.d.ts +5 -0
- package/dist/src/svelte/lowerAwaitSlotSyntax.d.ts +4 -0
- package/dist/src/svelte/lowerIslandSyntax.d.ts +4 -0
- package/dist/src/svelte/pageHandler.d.ts +28 -0
- package/dist/src/svelte/renderIsland.d.ts +2 -0
- package/dist/src/svelte/renderToPipeableStream.d.ts +12 -0
- package/dist/src/svelte/renderToReadableStream.d.ts +14 -0
- package/dist/src/svelte/renderToString.d.ts +9 -0
- package/dist/src/svelte/resolveIslandHtml.browser.d.ts +2 -0
- package/dist/src/svelte/resolveIslandHtml.d.ts +2 -0
- package/dist/src/svelte/router/browser.d.ts +4 -0
- package/dist/src/svelte/router/goto.d.ts +15 -0
- package/dist/src/svelte/router/hashMode.d.ts +16 -0
- package/dist/src/svelte/router/index.d.ts +4 -0
- package/dist/src/svelte/router/matchPath.d.ts +30 -0
- package/dist/src/svelte/router/page.svelte.d.ts +15 -0
- package/dist/src/svelte/router/prefetchCache.d.ts +17 -0
- package/dist/src/svelte/router/pushState.d.ts +13 -0
- package/dist/src/svelte/router/viewTransitions.d.ts +6 -0
- package/dist/src/svelte/server.d.ts +1 -0
- package/dist/src/svelte/staticAnalyzeSpaRoutes.d.ts +7 -0
- package/dist/src/utils/buildDirectoryLock.d.ts +28 -0
- package/dist/src/utils/cleanStaleOutputs.d.ts +1 -0
- package/dist/src/utils/cleanup.d.ts +9 -0
- package/dist/src/utils/commonAncestor.d.ts +1 -0
- package/dist/src/utils/defineConfig.d.ts +39 -0
- package/dist/src/utils/defineConvention.d.ts +3 -0
- package/dist/src/utils/defineEnv.d.ts +10 -0
- package/dist/src/utils/escapeScriptContent.d.ts +1 -0
- package/dist/src/utils/formatBytes.d.ts +2 -0
- package/dist/src/utils/generateHeadElement.d.ts +4 -0
- package/dist/src/utils/generateSitemap.d.ts +21 -0
- package/dist/src/utils/generatedDir.d.ts +3 -0
- package/dist/src/utils/getDurationString.d.ts +1 -0
- package/dist/src/utils/getEnv.d.ts +1 -0
- package/dist/src/utils/imageClient.d.ts +13 -0
- package/dist/src/utils/imageProcessing.d.ts +33 -0
- package/dist/src/utils/index.d.ts +11 -0
- package/dist/src/utils/inlinePageCss.d.ts +2 -0
- package/dist/src/utils/instanceRegistry.d.ts +13 -0
- package/dist/src/utils/jsonLd.d.ts +3 -0
- package/dist/src/utils/loadConfig.d.ts +57 -0
- package/dist/src/utils/logger.d.ts +56 -0
- package/dist/src/utils/networking.d.ts +2 -0
- package/dist/src/utils/normalizePath.d.ts +9 -0
- package/dist/src/utils/portScan.d.ts +22 -0
- package/dist/src/utils/projectRoot.d.ts +17 -0
- package/dist/src/utils/registerClientScript.d.ts +36 -0
- package/dist/src/utils/resolveConvention.d.ts +10 -0
- package/dist/src/utils/resolveDevPort.d.ts +24 -0
- package/dist/src/utils/runtimeMode.d.ts +3 -0
- package/dist/src/utils/spaRouteCss.d.ts +4 -0
- package/dist/src/utils/spaRouteTypes.d.ts +25 -0
- package/dist/src/utils/ssrErrorPage.d.ts +1 -0
- package/dist/src/utils/startupBanner.d.ts +10 -0
- package/dist/src/utils/startupTimings.d.ts +7 -0
- package/dist/src/utils/streamingSlotMetricSink.d.ts +18 -0
- package/dist/src/utils/streamingSlots.d.ts +76 -0
- package/dist/src/utils/stringModifiers.d.ts +3 -0
- package/dist/src/utils/userAgentFunctions.d.ts +1 -0
- package/dist/src/utils/validateSafePath.d.ts +1 -0
- package/dist/src/vue/Island.browser.d.ts +37 -0
- package/dist/src/vue/Island.d.ts +36 -0
- package/dist/src/vue/browser.d.ts +6 -0
- package/dist/src/vue/components/Image.d.ts +74 -0
- package/dist/src/vue/components/StreamSlot.d.ts +22 -0
- package/dist/src/vue/components/SuspenseSlot.d.ts +26 -0
- package/dist/src/vue/components/index.d.ts +3 -0
- package/dist/src/vue/createIsland.browser.d.ts +13 -0
- package/dist/src/vue/createIsland.d.ts +13 -0
- package/dist/src/vue/defineVuePage.d.ts +6 -0
- package/dist/src/vue/index.d.ts +9 -0
- package/dist/src/vue/pageHandler.d.ts +45 -0
- package/dist/src/vue/routerRedirectProviders.d.ts +45 -0
- package/dist/src/vue/server.d.ts +2 -0
- package/dist/src/vue/staticAnalyzeSpaRoutes.d.ts +7 -0
- package/dist/src/vue/useIslandStore.d.ts +3 -0
- package/dist/svelte/browser.js +309 -0
- package/dist/svelte/browser.js.map +19 -0
- package/dist/svelte/components/AwaitSlot.svelte +39 -0
- package/dist/svelte/components/AwaitSlot.svelte.d.ts +2 -0
- package/dist/svelte/components/Head.svelte +144 -0
- package/dist/svelte/components/Head.svelte.d.ts +2 -0
- package/dist/svelte/components/Image.svelte +164 -0
- package/dist/svelte/components/Image.svelte.d.ts +5 -0
- package/dist/svelte/components/Island.svelte +71 -0
- package/dist/svelte/components/Island.svelte.d.ts +5 -0
- package/dist/svelte/components/JsonLd.svelte +21 -0
- package/dist/svelte/components/JsonLd.svelte.d.ts +2 -0
- package/dist/svelte/components/StreamSlot.svelte +41 -0
- package/dist/svelte/components/StreamSlot.svelte.d.ts +2 -0
- package/dist/svelte/index.js +4371 -0
- package/dist/svelte/index.js.map +60 -0
- package/dist/svelte/router/Link.svelte +124 -0
- package/dist/svelte/router/Link.svelte.d.ts +21 -0
- package/dist/svelte/router/Route.svelte +54 -0
- package/dist/svelte/router/Route.svelte.d.ts +13 -0
- package/dist/svelte/router/Router.svelte +189 -0
- package/dist/svelte/router/Router.svelte.d.ts +16 -0
- package/dist/svelte/router/browser.ts +14 -0
- package/dist/svelte/router/goto.ts +89 -0
- package/dist/svelte/router/hashMode.ts +31 -0
- package/dist/svelte/router/index.ts +23 -0
- package/dist/svelte/router/matchPath.ts +136 -0
- package/dist/svelte/router/page.d.ts +15 -0
- package/dist/svelte/router/page.js +27 -0
- package/dist/svelte/router/prefetchCache.ts +85 -0
- package/dist/svelte/router/pushState.ts +35 -0
- package/dist/svelte/router/viewTransitions.ts +35 -0
- package/dist/svelte/server.js +2996 -0
- package/dist/svelte/server.js.map +33 -0
- package/dist/types/absoluteConfig.d.ts +22 -0
- package/dist/types/angular.d.ts +43 -0
- package/dist/types/build.d.ts +259 -0
- package/dist/types/cli.d.ts +74 -0
- package/dist/types/client.d.ts +70 -0
- package/dist/types/config.d.ts +50 -0
- package/dist/types/conventions.d.ts +26 -0
- package/dist/types/ember.d.ts +39 -0
- package/dist/types/env.d.ts +2 -0
- package/dist/types/eslintConfig.d.ts +68 -0
- package/dist/types/globals.d.ts +163 -0
- package/dist/types/image.d.ts +77 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/island.d.ts +52 -0
- package/dist/types/jsonLd.d.ts +300 -0
- package/dist/types/mediaQuery.d.ts +9 -0
- package/dist/types/messages.d.ts +152 -0
- package/dist/types/metadata.d.ts +51 -0
- package/dist/types/packageJson.d.ts +74 -0
- package/dist/types/packageJsonPanel.d.ts +29 -0
- package/dist/types/prettier.d.ts +26 -0
- package/dist/types/react.d.ts +2 -0
- package/dist/types/sitemap.d.ts +24 -0
- package/dist/types/style-module-shim.d.ts +29 -0
- package/dist/types/svelte.d.ts +2 -0
- package/dist/types/svelteRouter.d.ts +65 -0
- package/dist/types/svelteRouter.ts +91 -0
- package/dist/types/telemetry.d.ts +15 -0
- package/dist/types/tool.d.ts +11 -0
- package/dist/types/tsconfig.d.ts +31 -0
- package/dist/types/typeGuards.d.ts +2 -0
- package/dist/types/userAgentTypes.d.ts +2 -0
- package/dist/types/vue.d.ts +56 -0
- package/dist/types/websocket.d.ts +6 -0
- package/dist/vue/browser.js +512 -0
- package/dist/vue/browser.js.map +22 -0
- package/dist/vue/components/Image.js +264 -0
- package/dist/vue/components/Image.js.map +12 -0
- package/dist/vue/components/index.js +571 -0
- package/dist/vue/components/index.js.map +15 -0
- package/dist/vue/index.js +5238 -0
- package/dist/vue/index.js.map +69 -0
- package/dist/vue/server.js +2251 -0
- package/dist/vue/server.js.map +32 -0
- package/package.json +2 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, onMount, type Snippet } from 'svelte';
|
|
3
|
+
import type { LinkPrefetchMode } from '../../types/svelteRouter';
|
|
4
|
+
import { goto } from './goto';
|
|
5
|
+
import { prefetch, scheduleHoverPrefetch } from './prefetchCache';
|
|
6
|
+
|
|
7
|
+
type LinkProps = {
|
|
8
|
+
/** Destination URL — relative or absolute. */
|
|
9
|
+
to: string;
|
|
10
|
+
/** `true` → use `history.replaceState` instead of `pushState`.
|
|
11
|
+
* Same name as SvelteKit's `goto` option. */
|
|
12
|
+
replaceState?: boolean;
|
|
13
|
+
/** `'hover'` (default) — prefetch on `pointerenter`.
|
|
14
|
+
* `'viewport'` — prefetch when the link enters the viewport.
|
|
15
|
+
* `'none'` — disable prefetch for this link. */
|
|
16
|
+
prefetch?: LinkPrefetchMode;
|
|
17
|
+
/** Don't reset focus to body on navigate. */
|
|
18
|
+
keepFocus?: boolean;
|
|
19
|
+
/** Don't scroll to top on navigate. */
|
|
20
|
+
noScroll?: boolean;
|
|
21
|
+
/** Forwarded to the underlying `<a>` element. */
|
|
22
|
+
class?: string;
|
|
23
|
+
/** Forwarded to the underlying `<a>` element. */
|
|
24
|
+
target?: string;
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
/** Allow arbitrary HTML attributes through. */
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
to,
|
|
32
|
+
replaceState = false,
|
|
33
|
+
prefetch: prefetchMode = 'hover',
|
|
34
|
+
keepFocus = false,
|
|
35
|
+
noScroll = false,
|
|
36
|
+
class: classProp,
|
|
37
|
+
target,
|
|
38
|
+
children,
|
|
39
|
+
...rest
|
|
40
|
+
}: LinkProps = $props();
|
|
41
|
+
|
|
42
|
+
let anchor: HTMLAnchorElement | null = null;
|
|
43
|
+
let hoverHandle: { cancel: () => void } | null = null;
|
|
44
|
+
let viewportObserver: IntersectionObserver | null = null;
|
|
45
|
+
|
|
46
|
+
const isModifierClick = (event: MouseEvent) =>
|
|
47
|
+
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
48
|
+
|
|
49
|
+
const isExternal = (href: string) => {
|
|
50
|
+
if (typeof window === 'undefined') return false;
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const url = new URL(href, window.location.href);
|
|
54
|
+
|
|
55
|
+
return url.origin !== window.location.origin;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleClick = (event: MouseEvent) => {
|
|
62
|
+
if (isModifierClick(event)) return;
|
|
63
|
+
if (event.button !== 0) return;
|
|
64
|
+
if (target && target !== '_self') return;
|
|
65
|
+
if (rest['download'] !== undefined) return;
|
|
66
|
+
if (isExternal(to)) return;
|
|
67
|
+
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
void goto(to, {
|
|
70
|
+
keepFocus,
|
|
71
|
+
noScroll,
|
|
72
|
+
replaceState
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handlePointerEnter = () => {
|
|
77
|
+
if (prefetchMode !== 'hover' || isExternal(to)) return;
|
|
78
|
+
hoverHandle?.cancel();
|
|
79
|
+
hoverHandle = scheduleHoverPrefetch(to);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handlePointerLeave = () => {
|
|
83
|
+
hoverHandle?.cancel();
|
|
84
|
+
hoverHandle = null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
onMount(() => {
|
|
88
|
+
if (prefetchMode !== 'viewport' || !anchor) return;
|
|
89
|
+
if (typeof IntersectionObserver === 'undefined') return;
|
|
90
|
+
if (isExternal(to)) return;
|
|
91
|
+
|
|
92
|
+
viewportObserver = new IntersectionObserver(
|
|
93
|
+
(entries) => {
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
if (entry.isIntersecting) {
|
|
96
|
+
prefetch(to);
|
|
97
|
+
viewportObserver?.disconnect();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{ rootMargin: '128px' }
|
|
103
|
+
);
|
|
104
|
+
viewportObserver.observe(anchor);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
onDestroy(() => {
|
|
108
|
+
hoverHandle?.cancel();
|
|
109
|
+
viewportObserver?.disconnect();
|
|
110
|
+
});
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<a
|
|
114
|
+
bind:this={anchor}
|
|
115
|
+
href={to}
|
|
116
|
+
class={classProp}
|
|
117
|
+
{target}
|
|
118
|
+
onclick={handleClick}
|
|
119
|
+
onpointerenter={handlePointerEnter}
|
|
120
|
+
onpointerleave={handlePointerLeave}
|
|
121
|
+
{...rest}
|
|
122
|
+
>
|
|
123
|
+
{@render children?.()}
|
|
124
|
+
</a>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { LinkPrefetchMode } from '../../types/svelteRouter';
|
|
3
|
+
|
|
4
|
+
type LinkProps = {
|
|
5
|
+
to: string;
|
|
6
|
+
replaceState?: boolean;
|
|
7
|
+
prefetch?: LinkPrefetchMode;
|
|
8
|
+
keepFocus?: boolean;
|
|
9
|
+
noScroll?: boolean;
|
|
10
|
+
class?: string;
|
|
11
|
+
target?: string;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const __propDef: { props: LinkProps };
|
|
17
|
+
type Props = typeof __propDef.props;
|
|
18
|
+
|
|
19
|
+
import { SvelteComponent } from 'svelte';
|
|
20
|
+
|
|
21
|
+
export default class Link extends SvelteComponent<Props> {}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts" generics="Path extends string">
|
|
2
|
+
import { getContext, onDestroy, type Snippet } from 'svelte';
|
|
3
|
+
import type { ExtractRouteParams } from '../../types/svelteRouter';
|
|
4
|
+
import type { RouterRegistry } from './Router.svelte';
|
|
5
|
+
import { compilePattern, joinBasepath } from './matchPath';
|
|
6
|
+
|
|
7
|
+
const ROUTER_CONTEXT_KEY = Symbol.for('absolutejs.svelte-router');
|
|
8
|
+
|
|
9
|
+
type RouteProps = {
|
|
10
|
+
path: Path;
|
|
11
|
+
content: Snippet<[ExtractRouteParams<Path>]>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let { path, content }: RouteProps = $props();
|
|
15
|
+
|
|
16
|
+
const registry = getContext<RouterRegistry | undefined>(ROUTER_CONTEXT_KEY);
|
|
17
|
+
if (!registry) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
'<Route> must be a descendant of <Router>. ' +
|
|
20
|
+
'Wrap your routes in `<Router url={...}>` (server) or `<Router>` (client).'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const id = registry.nextRouteId();
|
|
25
|
+
const registrationOrder = Number(id.slice(1));
|
|
26
|
+
|
|
27
|
+
// Register synchronously at script-body time so SSR (which doesn't
|
|
28
|
+
// run $effect) sees the registration before the template runs.
|
|
29
|
+
registry.register(id, {
|
|
30
|
+
pattern: compilePattern(joinBasepath(registry.basepath, path)),
|
|
31
|
+
registrationOrder
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
$effect(() => {
|
|
35
|
+
registry.register(id, {
|
|
36
|
+
pattern: compilePattern(joinBasepath(registry.basepath, path)),
|
|
37
|
+
registrationOrder
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
onDestroy(() => registry.deregister(id));
|
|
42
|
+
|
|
43
|
+
// The Router computes the active match across all registered Routes
|
|
44
|
+
// (specificity-ranked). Each Route checks if it's the winner and
|
|
45
|
+
// renders its own content at its own location in the markup. That
|
|
46
|
+
// way `<Route>` nested inside a layout `<section>` renders inside
|
|
47
|
+
// that section instead of getting hoisted to the Router's root.
|
|
48
|
+
const match = $derived(registry.getActiveMatch());
|
|
49
|
+
const isActive = $derived(match?.id === id);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
{#if isActive && match}
|
|
53
|
+
{@render content(match.params as ExtractRouteParams<Path>)}
|
|
54
|
+
{/if}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ExtractRouteParams } from '../../types/svelteRouter';
|
|
3
|
+
|
|
4
|
+
type RouteProps<Path extends string> = {
|
|
5
|
+
path: Path;
|
|
6
|
+
content: Snippet<[ExtractRouteParams<Path>]>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
import { SvelteComponent } from 'svelte';
|
|
10
|
+
|
|
11
|
+
export default class Route<
|
|
12
|
+
Path extends string = string
|
|
13
|
+
> extends SvelteComponent<RouteProps<Path>> {}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type RouteEntry = {
|
|
3
|
+
// reactive — read by the winner-resolver
|
|
4
|
+
pattern: ReturnType<typeof import('./matchPath').compilePattern>;
|
|
5
|
+
// stable — assigned at registration time, used as tiebreaker
|
|
6
|
+
registrationOrder: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ActiveMatch = {
|
|
10
|
+
id: string;
|
|
11
|
+
params: Record<string, string | undefined>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type RouterRegistry = {
|
|
15
|
+
basepath: string;
|
|
16
|
+
mode: import('../../types/svelteRouter').RouterMode;
|
|
17
|
+
register: (id: string, entry: RouteEntry) => void;
|
|
18
|
+
deregister: (id: string) => void;
|
|
19
|
+
nextRouteId: () => string;
|
|
20
|
+
// Returns the currently-winning Route's id and matched params, or null
|
|
21
|
+
// if no Route matches. Routes call this to decide whether to render.
|
|
22
|
+
// Reads $state internally, so callers using it inside $derived/$effect
|
|
23
|
+
// auto-subscribe to URL + registration changes.
|
|
24
|
+
getActiveMatch: () => ActiveMatch | null;
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import { getContext, onMount, setContext, type Snippet } from 'svelte';
|
|
30
|
+
import type { RouterMode } from '../../types/svelteRouter';
|
|
31
|
+
import { setRouterMode } from './goto';
|
|
32
|
+
import { hashPathnameOf } from './hashMode';
|
|
33
|
+
import { joinBasepath, matchPattern } from './matchPath';
|
|
34
|
+
import { page, seedPage, setPage } from './page.js';
|
|
35
|
+
|
|
36
|
+
const ROUTER_CONTEXT_KEY = Symbol.for('absolutejs.svelte-router');
|
|
37
|
+
|
|
38
|
+
type RouterProps = {
|
|
39
|
+
/** SSR URL passthrough. On the server, the page handler forwards
|
|
40
|
+
* `request.url` here. On the client, this prop is omitted and the
|
|
41
|
+
* router reads `window.location` instead. */
|
|
42
|
+
url?: string;
|
|
43
|
+
/** Optional URL prefix the router operates under. Stacks with
|
|
44
|
+
* parent `<Router basepath>` blocks for nested routers. */
|
|
45
|
+
basepath?: string;
|
|
46
|
+
/** `'history'` (default, clean URLs) or `'hash'` (`/#/path`,
|
|
47
|
+
* for static deploys). */
|
|
48
|
+
mode?: RouterMode;
|
|
49
|
+
children?: Snippet;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let {
|
|
53
|
+
url,
|
|
54
|
+
basepath = '',
|
|
55
|
+
mode = 'history',
|
|
56
|
+
children
|
|
57
|
+
}: RouterProps = $props();
|
|
58
|
+
|
|
59
|
+
const parent = getContext<RouterRegistry | undefined>(ROUTER_CONTEXT_KEY);
|
|
60
|
+
const stackedBasepath = parent
|
|
61
|
+
? joinBasepath(parent.basepath, basepath)
|
|
62
|
+
: basepath === ''
|
|
63
|
+
? ''
|
|
64
|
+
: basepath.startsWith('/')
|
|
65
|
+
? basepath
|
|
66
|
+
: `/${basepath}`;
|
|
67
|
+
const stackedMode: RouterMode = parent?.mode ?? mode;
|
|
68
|
+
const isOutermost = parent === undefined;
|
|
69
|
+
|
|
70
|
+
// Specificity ranking across siblings: each <Route> registers with
|
|
71
|
+
// its compiled pattern + a stable mount-order index. The winner is
|
|
72
|
+
// computed lazily from the current URL — highest score wins; ties
|
|
73
|
+
// break by earlier registration order. The winning Route then renders
|
|
74
|
+
// its own content at ITS location in the markup (so a Route nested
|
|
75
|
+
// inside a layout `<section>` renders inside that section, not at the
|
|
76
|
+
// Router's root).
|
|
77
|
+
const routes = $state(new Map<string, RouteEntry>());
|
|
78
|
+
let routeCounter = 0;
|
|
79
|
+
|
|
80
|
+
const computeWinner = (): ActiveMatch | null => {
|
|
81
|
+
let bestId: string | null = null;
|
|
82
|
+
let bestParams: Record<string, string | undefined> | null = null;
|
|
83
|
+
let bestScore = -Infinity;
|
|
84
|
+
let bestOrder = Infinity;
|
|
85
|
+
|
|
86
|
+
for (const [id, entry] of routes) {
|
|
87
|
+
const match = matchPattern(entry.pattern, page.url.pathname);
|
|
88
|
+
if (!match.matched) continue;
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
entry.pattern.score > bestScore ||
|
|
92
|
+
(entry.pattern.score === bestScore &&
|
|
93
|
+
entry.registrationOrder < bestOrder)
|
|
94
|
+
) {
|
|
95
|
+
bestScore = entry.pattern.score;
|
|
96
|
+
bestOrder = entry.registrationOrder;
|
|
97
|
+
bestId = id;
|
|
98
|
+
bestParams = match.params as Record<string, string | undefined>;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return bestId && bestParams ? { id: bestId, params: bestParams } : null;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Recompute on every call rather than caching via $derived. SSR
|
|
106
|
+
// renders Routes in declaration order; each Route's template invokes
|
|
107
|
+
// `getActiveMatch()` immediately after registering itself, before its
|
|
108
|
+
// siblings have registered. A cached value would freeze on whichever
|
|
109
|
+
// Route triggered the computation first, so later-registered (more
|
|
110
|
+
// specific) Routes would lose. Calling `computeWinner()` afresh on
|
|
111
|
+
// every read sees the full registry by the time all Routes have
|
|
112
|
+
// rendered. Each call is O(N) over N routes; for typical pages
|
|
113
|
+
// (N < 20) the recomputation is negligible. Reactivity still works:
|
|
114
|
+
// each Route wraps the call in its own `$derived`, which tracks the
|
|
115
|
+
// `$state(routes)` and `page.url` reads inside `computeWinner`.
|
|
116
|
+
const registry: RouterRegistry = {
|
|
117
|
+
basepath: stackedBasepath,
|
|
118
|
+
deregister: (id) => {
|
|
119
|
+
routes.delete(id);
|
|
120
|
+
},
|
|
121
|
+
getActiveMatch: () => computeWinner(),
|
|
122
|
+
mode: stackedMode,
|
|
123
|
+
nextRouteId: () => `r${routeCounter++}`,
|
|
124
|
+
register: (id, entry) => {
|
|
125
|
+
routes.set(id, entry);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
setContext<RouterRegistry>(ROUTER_CONTEXT_KEY, registry);
|
|
130
|
+
|
|
131
|
+
if (isOutermost) {
|
|
132
|
+
setRouterMode(stackedMode);
|
|
133
|
+
|
|
134
|
+
const baseUrl =
|
|
135
|
+
typeof window !== 'undefined' ? window.location.href : (url ?? '/');
|
|
136
|
+
const fullUrl =
|
|
137
|
+
typeof window !== 'undefined'
|
|
138
|
+
? new URL(baseUrl)
|
|
139
|
+
: new URL(baseUrl, 'http://localhost/');
|
|
140
|
+
|
|
141
|
+
const routablePathname =
|
|
142
|
+
stackedMode === 'hash' ? hashPathnameOf(fullUrl) : fullUrl.pathname;
|
|
143
|
+
const initial = new URL(fullUrl.href);
|
|
144
|
+
initial.pathname = routablePathname;
|
|
145
|
+
seedPage(initial);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onMount(() => {
|
|
149
|
+
if (!isOutermost) return;
|
|
150
|
+
|
|
151
|
+
const onPopState = (event: PopStateEvent) => {
|
|
152
|
+
const next = new URL(window.location.href);
|
|
153
|
+
const routable =
|
|
154
|
+
stackedMode === 'hash' ? hashPathnameOf(next) : next.pathname;
|
|
155
|
+
const synthetic = new URL(next.href);
|
|
156
|
+
synthetic.pathname = routable;
|
|
157
|
+
setPage({
|
|
158
|
+
params: {},
|
|
159
|
+
state: event.state ?? null,
|
|
160
|
+
url: synthetic
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const onHashChange = () => {
|
|
165
|
+
const next = new URL(window.location.href);
|
|
166
|
+
const synthetic = new URL(next.href);
|
|
167
|
+
synthetic.pathname = hashPathnameOf(next);
|
|
168
|
+
setPage({
|
|
169
|
+
params: {},
|
|
170
|
+
state: window.history.state ?? null,
|
|
171
|
+
url: synthetic
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
window.addEventListener('popstate', onPopState);
|
|
176
|
+
if (stackedMode === 'hash') {
|
|
177
|
+
window.addEventListener('hashchange', onHashChange);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return () => {
|
|
181
|
+
window.removeEventListener('popstate', onPopState);
|
|
182
|
+
if (stackedMode === 'hash') {
|
|
183
|
+
window.removeEventListener('hashchange', onHashChange);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
{@render children?.()}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { RouterMode } from '../../types/svelteRouter';
|
|
3
|
+
|
|
4
|
+
type RouterProps = {
|
|
5
|
+
url?: string;
|
|
6
|
+
basepath?: string;
|
|
7
|
+
mode?: RouterMode;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const __propDef: { props: RouterProps };
|
|
12
|
+
type Props = typeof __propDef.props;
|
|
13
|
+
|
|
14
|
+
import { SvelteComponent } from 'svelte';
|
|
15
|
+
|
|
16
|
+
export default class Router extends SvelteComponent<Props> {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Browser entry — same shape as ./index.ts. Components are imported by
|
|
2
|
+
// their .svelte path; this entry exposes only the runtime API.
|
|
3
|
+
|
|
4
|
+
export { goto } from './goto';
|
|
5
|
+
export { page } from './page.js';
|
|
6
|
+
export { pushState, replaceState } from './pushState';
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
ExtractRouteParams,
|
|
10
|
+
GotoOptions,
|
|
11
|
+
LinkPrefetchMode,
|
|
12
|
+
PageState,
|
|
13
|
+
RouterMode
|
|
14
|
+
} from '../../types/svelteRouter';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GotoOptions, RouterMode } from '../../types/svelteRouter';
|
|
2
|
+
import { buildHashHref } from './hashMode';
|
|
3
|
+
import { setPage } from './page.js';
|
|
4
|
+
import { consumePrefetch } from './prefetchCache';
|
|
5
|
+
import { withViewTransition } from './viewTransitions';
|
|
6
|
+
|
|
7
|
+
let activeMode: RouterMode = 'history';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal — called by Router.svelte on mount so navigation primitives
|
|
11
|
+
* know which URL strategy to use. Hash mode rewrites the URL bar to
|
|
12
|
+
* `#/path` instead of `/path`.
|
|
13
|
+
*/
|
|
14
|
+
export const setRouterMode = (mode: RouterMode) => {
|
|
15
|
+
activeMode = mode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const resolveAbsoluteUrl = (target: string) => {
|
|
19
|
+
if (typeof window === 'undefined') {
|
|
20
|
+
// Programmatic goto on the server is rare but we tolerate it as a
|
|
21
|
+
// way for tests to drive the router without a real DOM.
|
|
22
|
+
return new URL(target, 'http://localhost/');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return new URL(target, window.location.href);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const isExternal = (target: URL) => {
|
|
29
|
+
if (typeof window === 'undefined') return false;
|
|
30
|
+
|
|
31
|
+
return target.origin !== window.location.origin;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const writeHistory = (target: URL, options: GotoOptions) => {
|
|
35
|
+
if (typeof window === 'undefined') return;
|
|
36
|
+
|
|
37
|
+
const href =
|
|
38
|
+
activeMode === 'hash'
|
|
39
|
+
? `${window.location.pathname}${window.location.search}${buildHashHref(target.pathname + target.search)}`
|
|
40
|
+
: `${target.pathname}${target.search}${target.hash}`;
|
|
41
|
+
|
|
42
|
+
const method = options.replaceState
|
|
43
|
+
? window.history.replaceState
|
|
44
|
+
: window.history.pushState;
|
|
45
|
+
method.call(window.history, options.state ?? null, '', href);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const applyScrollAndFocus = (options: GotoOptions) => {
|
|
49
|
+
if (typeof window === 'undefined') return;
|
|
50
|
+
|
|
51
|
+
if (!options.noScroll) window.scrollTo({ left: 0, top: 0 });
|
|
52
|
+
if (!options.keepFocus && document.activeElement instanceof HTMLElement) {
|
|
53
|
+
document.activeElement.blur();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Programmatically navigate to a URL. Updates `page.url`, writes history,
|
|
59
|
+
* and (when supported) wraps the swap in `document.startViewTransition`.
|
|
60
|
+
*
|
|
61
|
+
* Mirrors SvelteKit's `goto` from `$app/navigation` — same name, same
|
|
62
|
+
* options shape, so a SvelteKit user finds the primitive familiar.
|
|
63
|
+
*/
|
|
64
|
+
export const goto = async (target: string, options: GotoOptions = {}) => {
|
|
65
|
+
const url = resolveAbsoluteUrl(target);
|
|
66
|
+
|
|
67
|
+
if (isExternal(url)) {
|
|
68
|
+
// External URLs go through the browser — we don't try to SPA them.
|
|
69
|
+
if (typeof window !== 'undefined') {
|
|
70
|
+
window.location.href = url.href;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
consumePrefetch(target);
|
|
77
|
+
|
|
78
|
+
const mutate = () => {
|
|
79
|
+
writeHistory(url, options);
|
|
80
|
+
setPage({
|
|
81
|
+
params: {},
|
|
82
|
+
state: options.state ?? null,
|
|
83
|
+
url
|
|
84
|
+
});
|
|
85
|
+
applyScrollAndFocus(options);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
await withViewTransition(mutate);
|
|
89
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash mode: routing happens against `window.location.hash` with the
|
|
3
|
+
* leading `#/` stripped. Useful for static deploys (GitHub Pages, S3)
|
|
4
|
+
* where the host can't be configured to wildcard-route to one HTML file.
|
|
5
|
+
*
|
|
6
|
+
* URLs look like `https://example.com/#/dashboard/settings`. The
|
|
7
|
+
* `pathname` part stays at `/` so the server always serves the same
|
|
8
|
+
* page; `<Route>` matching looks at the hash instead.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extract the routable pathname from a full URL when hash mode is on.
|
|
13
|
+
* Returns the part after `#/`, prefixed with `/` so it parses as a
|
|
14
|
+
* normal pathname.
|
|
15
|
+
*/
|
|
16
|
+
export const buildHashHref = (pathname: string) => {
|
|
17
|
+
const trimmed = pathname.replace(/^\/+/, '');
|
|
18
|
+
|
|
19
|
+
return trimmed === '' ? '#/' : `#/${trimmed}`;
|
|
20
|
+
};
|
|
21
|
+
export const hashPathnameOf = (url: URL) => {
|
|
22
|
+
const {hash} = url;
|
|
23
|
+
if (!hash || hash === '#') return '/';
|
|
24
|
+
|
|
25
|
+
// Tolerate both `#/foo` and `#foo`.
|
|
26
|
+
const trimmed = hash.startsWith('#/') ? hash.slice(2) : hash.slice(1);
|
|
27
|
+
|
|
28
|
+
if (trimmed === '') return '/';
|
|
29
|
+
|
|
30
|
+
return `/${trimmed.replace(/^\/+/, '')}`;
|
|
31
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Svelte components are imported by their .svelte path, not from this entry:
|
|
2
|
+
// import Router from '@absolutejs/absolute/svelte/router/Router.svelte';
|
|
3
|
+
// import Route from '@absolutejs/absolute/svelte/router/Route.svelte';
|
|
4
|
+
// import Link from '@absolutejs/absolute/svelte/router/Link.svelte';
|
|
5
|
+
//
|
|
6
|
+
// This entry only re-exports the non-component runtime API (programmatic
|
|
7
|
+
// navigation, reactive state, shallow routing). It mirrors the existing
|
|
8
|
+
// `@absolutejs/absolute/svelte/components/*.svelte` convention used by
|
|
9
|
+
// the framework's other Svelte components (Island, Image, StreamSlot,
|
|
10
|
+
// etc.) so user .svelte files can import the components directly via
|
|
11
|
+
// AbsoluteJS's Svelte compile pipeline.
|
|
12
|
+
|
|
13
|
+
export { goto } from './goto';
|
|
14
|
+
export { page } from './page.js';
|
|
15
|
+
export { pushState, replaceState } from './pushState';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
ExtractRouteParams,
|
|
19
|
+
GotoOptions,
|
|
20
|
+
LinkPrefetchMode,
|
|
21
|
+
PageState,
|
|
22
|
+
RouterMode
|
|
23
|
+
} from '../../types/svelteRouter';
|