@absolutejs/absolute 0.19.0-beta.999 → 0.20.0-beta.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/LICENSE +21 -13
- package/README.md +48 -2
- package/dist/angular/browser.js +82 -77
- package/dist/angular/browser.js.map +11 -11
- package/dist/angular/components/constants.js +43 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/hmrPreserveCore.ts +132 -134
- package/dist/angular/index.js +1719 -844
- package/dist/angular/index.js.map +34 -26
- package/dist/angular/server.js +1620 -768
- package/dist/angular/server.js.map +28 -20
- package/dist/build.js +4935 -2593
- package/dist/build.js.map +72 -57
- package/dist/cli/config/client.js +578 -0
- package/dist/cli/config/server.js +39587 -0
- package/dist/cli/htmx/htmx.min.js +1 -0
- package/dist/cli/index.js +16828 -3511
- package/dist/client/index.js +49 -46
- package/dist/client/index.js.map +12 -12
- package/dist/core/streamingSlotRegistrar.js +1 -19
- package/dist/core/streamingSlotRegistrar.js.map +2 -2
- package/dist/core/streamingSlotRegistry.js +1 -19
- package/dist/core/streamingSlotRegistry.js.map +2 -2
- package/dist/dev/client/cssUtils.ts +98 -41
- package/dist/dev/client/domState.ts +2 -0
- package/dist/dev/client/errorOverlay.ts +14 -13
- package/dist/dev/client/handlers/angularHmrShim.ts +20 -20
- package/dist/dev/client/handlers/angularRemount.ts +74 -55
- package/dist/dev/client/handlers/angularRemountWiring.ts +1 -2
- package/dist/dev/client/handlers/html.ts +144 -41
- package/dist/dev/client/handlers/htmx.ts +43 -8
- package/dist/dev/client/handlers/react.ts +114 -32
- package/dist/dev/client/handlers/rebuild.ts +28 -8
- package/dist/dev/client/handlers/svelte.ts +92 -51
- package/dist/dev/client/handlers/vue.ts +36 -45
- package/dist/dev/client/hmrClient.ts +101 -26
- package/dist/dev/client/hmrTiming.ts +141 -0
- package/dist/dev/client/hmrToast.ts +22 -24
- package/dist/dev/client/reactRefreshSetup.ts +4 -0
- package/dist/dev/client/vendor/reactRefreshRuntime.d.ts +12 -0
- package/dist/dev/client/vendor/reactRefreshRuntime.js +313 -0
- package/dist/dev/serverBootstrap.js +45 -0
- package/dist/index.js +7153 -3224
- package/dist/index.js.map +118 -86
- package/dist/islands/browser.js +1 -19
- package/dist/islands/browser.js.map +3 -3
- package/dist/islands/index.js +709 -120
- package/dist/islands/index.js.map +18 -13
- package/dist/mobile/browser.js +428 -0
- package/dist/mobile/browser.js.map +12 -0
- package/dist/mobile/index.js +3058 -0
- package/dist/mobile/index.js.map +35 -0
- package/dist/react/browser.js +13 -62
- package/dist/react/browser.js.map +5 -6
- package/dist/react/components/browser/index.js +23 -13
- package/dist/react/components/index.js +30 -34
- package/dist/react/components/index.js.map +8 -7
- package/dist/react/hooks/index.js +1 -19
- package/dist/react/hooks/index.js.map +3 -3
- package/dist/react/index.js +1643 -679
- package/dist/react/index.js.map +29 -20
- package/dist/react/jsxDevRuntimeCompat.js +22 -20
- package/dist/react/jsxDevRuntimeCompat.js.map +5 -4
- package/dist/react/jsxRuntimeCompat.js +90 -0
- package/dist/react/jsxRuntimeCompat.js.map +10 -0
- package/dist/react/router/browser.js +77 -0
- package/dist/react/router/browser.js.map +10 -0
- package/dist/react/router/index.js +77 -0
- package/dist/react/router/index.js.map +10 -0
- package/dist/react/server.js +950 -565
- package/dist/react/server.js.map +16 -11
- package/dist/src/angular/components/constants.d.ts +21 -0
- package/dist/src/angular/hmrPreserveCore.d.ts +7 -20
- package/dist/src/angular/islands.d.ts +1 -1
- package/dist/src/angular/pageHandler.d.ts +2 -0
- package/dist/src/angular/ssrRender.d.ts +4 -1
- package/dist/src/build/bunStringRawUnicodePlugin.d.ts +12 -0
- package/dist/src/build/chainInlineSourcemaps.d.ts +1 -0
- package/dist/src/build/compileAngular.d.ts +5 -7
- package/dist/src/build/compileSvelte.d.ts +3 -0
- package/dist/src/build/compileVue.d.ts +3 -1
- package/dist/src/build/generateReactIndexes.d.ts +1 -0
- package/dist/src/build/islandRegistryTransform.d.ts +17 -0
- package/dist/src/build/maskLiterals.d.ts +28 -0
- package/dist/src/build/parseVueSpaRoutes.d.ts +5 -0
- package/dist/src/build/resolveBuildMode.d.ts +7 -0
- package/dist/src/build/serverExternals.d.ts +14 -0
- package/dist/src/build/spaSideManifests.d.ts +16 -0
- package/dist/src/build/tailwindCompiler.d.ts +0 -1
- package/dist/src/cli/add/dependencies.d.ts +13 -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 +19 -0
- package/dist/src/cli/config/auth/AuthPanel.d.ts +6 -0
- package/dist/src/cli/config/auth/authCatalog.d.ts +10 -0
- package/dist/src/cli/config/auth/authScaffolds.d.ts +16 -0
- package/dist/src/cli/config/auth/editAuthConfig.d.ts +5 -0
- package/dist/src/cli/config/auth/resolveAuthSettings.d.ts +14 -0
- package/dist/src/cli/config/auth/resolveAuthState.d.ts +2 -0
- package/dist/src/cli/config/auth/scaffoldAuthFeature.d.ts +6 -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/integrations/IntegrationsPanel.d.ts +6 -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 +8 -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 +1 -0
- package/dist/src/cli/config/schema/serialize.d.ts +1 -0
- package/dist/src/cli/config/server.d.ts +527 -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/elysiaOpenApiTypeboxPlugin.d.ts +8 -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/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/integrations/addPlugin.d.ts +8 -0
- package/dist/src/cli/integrations/catalog.d.ts +20 -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 -1
- package/dist/src/cli/scripts/db.d.ts +20 -0
- package/dist/src/cli/scripts/dev.d.ts +5 -1
- 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 +37 -2
- package/dist/src/cli/scripts/eslintChunked.d.ts +37 -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/inspect.d.ts +1 -0
- package/dist/src/cli/scripts/islands.d.ts +1 -0
- package/dist/src/cli/scripts/lintProof.d.ts +42 -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/mobile.d.ts +1 -0
- package/dist/src/cli/scripts/prettier.d.ts +2 -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 +6 -1
- package/dist/src/cli/scripts/tunnelRelay.d.ts +9 -0
- package/dist/src/cli/scripts/workspace.d.ts +3 -1
- package/dist/src/cli/serverBundleExternals.d.ts +2 -0
- package/dist/src/cli/tuiPrimitives.d.ts +14 -0
- package/dist/src/cli/typeGraphCoherence.d.ts +32 -0
- package/dist/src/cli/utils.d.ts +3 -1
- package/dist/src/cli/workspaceTui.d.ts +2 -1
- package/dist/src/client/hydrators/react.d.ts +1 -1
- package/dist/src/client/hydrators/svelte.d.ts +1 -1
- package/dist/src/client/hydrators/vue.d.ts +1 -1
- package/dist/src/client/islandStore.d.ts +3 -3
- package/dist/src/client/preserveIslandMarkup.d.ts +4 -1
- package/dist/src/constants.d.ts +21 -0
- package/dist/src/core/angularServerModule.d.ts +1 -0
- package/dist/src/core/build.d.ts +11 -3
- package/dist/src/core/devRouteRegistrationCallsite.d.ts +1 -5
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/pageResponseCache.d.ts +23 -0
- package/dist/src/core/prepare.d.ts +192 -154
- package/dist/src/core/requestContext.d.ts +18 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +5 -3
- package/dist/src/dev/angular/hmrCompiler.d.ts +1 -1
- package/dist/src/dev/angular/resolveOwningComponents.d.ts +1 -1
- package/dist/src/dev/clientManager.d.ts +10 -1
- package/dist/src/dev/configResolver.d.ts +2 -0
- package/dist/src/dev/moduleMapper.d.ts +1 -1
- package/dist/src/dev/moduleServer.d.ts +2 -1
- package/dist/src/dev/pathUtils.d.ts +1 -1
- package/dist/src/dev/reactComponentClassifier.d.ts +1 -1
- package/dist/src/dev/rebuildTrigger.d.ts +4 -0
- package/dist/src/dev/requestInspector.d.ts +31 -0
- package/dist/src/dev/serverBootstrap.d.ts +1 -0
- package/dist/src/dev/serverEntryWatcher.d.ts +3 -3
- 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 +1 -1
- package/dist/src/mobile/androidConformance.d.ts +42 -0
- package/dist/src/mobile/androidEmulatorController.d.ts +99 -0
- package/dist/src/mobile/androidNativeWatcher.d.ts +19 -0
- package/dist/src/mobile/androidRelease.d.ts +47 -0
- package/dist/src/mobile/androidWebView.d.ts +46 -0
- package/dist/src/mobile/artifactStore.d.ts +47 -0
- package/dist/src/mobile/associationFiles.d.ts +49 -0
- package/dist/src/mobile/browser.d.ts +2 -0
- package/dist/src/mobile/buildMetadata.d.ts +10 -0
- package/dist/src/mobile/buildPipeline.d.ts +8 -0
- package/dist/src/mobile/buildRelease.d.ts +24 -0
- package/dist/src/mobile/capacitorBundle.d.ts +28 -0
- package/dist/src/mobile/capacitorProject.d.ts +9 -0
- package/dist/src/mobile/client.d.ts +35 -0
- package/dist/src/mobile/compatibilityDispatcher.d.ts +26 -0
- package/dist/src/mobile/config.d.ts +16 -0
- package/dist/src/mobile/emulatorDoctor.d.ts +25 -0
- package/dist/src/mobile/emulatorInstaller.d.ts +41 -0
- package/dist/src/mobile/index.d.ts +19 -0
- package/dist/src/mobile/materializedBundle.d.ts +36 -0
- package/dist/src/mobile/nativeDeepLinks.d.ts +5 -0
- package/dist/src/mobile/pageProtocol.d.ts +89 -0
- package/dist/src/mobile/producerContext.d.ts +4 -0
- package/dist/src/mobile/producerContextState.d.ts +10 -0
- package/dist/src/mobile/releaseArtifact.d.ts +75 -0
- package/dist/src/mobile/releaseDoctor.d.ts +13 -0
- package/dist/src/mobile/routeMatcher.d.ts +3 -0
- package/dist/src/mobile/routeMetadataTransform.d.ts +13 -0
- package/dist/src/mobile/shellBootstrap.d.ts +1 -0
- package/dist/src/mobile/transport.d.ts +31 -0
- package/dist/src/plugins/devtoolsJson.d.ts +6 -47
- package/dist/src/plugins/hmr.d.ts +22 -96
- package/dist/src/plugins/imageOptimizer.d.ts +150 -62
- package/dist/src/plugins/networking.d.ts +2 -2
- package/dist/src/plugins/openApiPlugin.d.ts +4 -0
- package/dist/src/plugins/telemetryPlugin.d.ts +36 -0
- package/dist/src/react/browser.d.ts +0 -2
- package/dist/src/react/hooks/useMediaQuery.d.ts +1 -1
- package/dist/src/react/index.d.ts +0 -2
- package/dist/src/react/jsxDevRuntimeCompat.d.ts +1 -1
- package/dist/src/react/jsxRuntimeCompat.d.ts +7 -0
- package/dist/src/react/pageHandler.d.ts +8 -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/svelte/pageHandler.d.ts +5 -0
- package/dist/src/svelte/router/hashMode.d.ts +1 -6
- package/dist/src/svelte/router/matchPath.d.ts +4 -24
- package/dist/src/svelte/router/page.svelte.d.ts +1 -10
- package/dist/src/svelte/router/prefetchCache.d.ts +2 -6
- package/dist/src/utils/cleanup.d.ts +1 -0
- package/dist/src/utils/defineConvention.d.ts +2 -2
- package/dist/src/utils/defineEnv.d.ts +4 -4
- package/dist/src/utils/formatBytes.d.ts +2 -0
- package/dist/src/utils/generatedDir.d.ts +1 -1
- package/dist/src/utils/iconVersion.d.ts +5 -0
- package/dist/src/utils/imageProcessing.d.ts +1 -1
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/inlinePageCss.d.ts +9 -0
- package/dist/src/utils/instanceRegistry.d.ts +13 -0
- package/dist/src/utils/isTestSourcePath.d.ts +1 -0
- package/dist/src/utils/jsonLd.d.ts +1 -1
- package/dist/src/utils/loadConfig.d.ts +11 -3
- package/dist/src/utils/logger.d.ts +2 -0
- package/dist/src/utils/portScan.d.ts +22 -0
- package/dist/src/utils/projectRoot.d.ts +17 -0
- package/dist/src/utils/resolveConvention.d.ts +1 -1
- package/dist/src/utils/resolveDevPort.d.ts +4 -1
- package/dist/src/utils/runtimeMode.d.ts +1 -1
- package/dist/src/utils/spaRouteCss.d.ts +10 -0
- package/dist/src/utils/spaRouteManifest.d.ts +8 -0
- package/dist/src/utils/stripStringsAndComments.d.ts +18 -0
- package/dist/src/utils/userAgentFunctions.d.ts +1 -1
- package/dist/src/utils/vueCompiler.d.ts +1 -0
- package/dist/src/vue/components/Image.d.ts +2 -2
- package/dist/src/vue/defineVuePage.d.ts +1 -11
- package/dist/src/vue/index.d.ts +3 -0
- package/dist/src/vue/pageHandler.d.ts +5 -0
- package/dist/src/vue/resolveGeneratedVueModulePath.d.ts +1 -0
- package/dist/src/vue/teleports.d.ts +2 -0
- package/dist/src/vue/useResource.d.ts +65 -0
- package/dist/svelte/browser.js +1 -19
- package/dist/svelte/browser.js.map +3 -3
- package/dist/svelte/components/Head.svelte +7 -1
- package/dist/svelte/index.js +1281 -543
- package/dist/svelte/index.js.map +27 -19
- package/dist/svelte/router/Link.svelte.d.ts +3 -3
- package/dist/svelte/router/Route.svelte.d.ts +5 -5
- package/dist/svelte/router/Router.svelte.d.ts +3 -3
- package/dist/svelte/router/hashMode.ts +6 -12
- package/dist/svelte/router/matchPath.ts +44 -61
- package/dist/svelte/router/page.d.ts +1 -10
- package/dist/svelte/router/page.js +6 -6
- package/dist/svelte/router/prefetchCache.ts +21 -23
- package/dist/svelte/router/viewTransitions.ts +22 -12
- package/dist/svelte/server.js +697 -565
- package/dist/svelte/server.js.map +14 -11
- package/dist/types/absoluteConfig.d.ts +22 -0
- package/dist/types/angular.d.ts +4 -1
- package/dist/types/authPanel.d.ts +62 -0
- package/dist/types/build.d.ts +116 -0
- package/dist/types/cli.d.ts +57 -0
- package/dist/types/config.d.ts +52 -0
- package/dist/types/eslintConfig.d.ts +68 -0
- package/dist/types/globals.d.ts +31 -10
- package/dist/types/image.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/integrationsPanel.d.ts +29 -0
- package/dist/types/messages.d.ts +12 -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/tsconfig.d.ts +31 -0
- package/dist/types/vue.d.ts +13 -15
- package/dist/vue/browser.js +14 -36
- package/dist/vue/browser.js.map +5 -5
- package/dist/vue/components/Image.js +3 -20
- package/dist/vue/components/Image.js.map +3 -3
- package/dist/vue/components/index.js +3 -20
- package/dist/vue/components/index.js.map +3 -3
- package/dist/vue/index.js +1573 -620
- package/dist/vue/index.js.map +34 -22
- package/dist/vue/server.js +800 -520
- package/dist/vue/server.js.map +17 -11
- package/package.json +145 -68
- package/dist/src/react/UniversalRouter.d.ts +0 -12
package/dist/vue/index.js
CHANGED
|
@@ -3,7 +3,6 @@ var __create = Object.create;
|
|
|
3
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
7
|
function __accessProp(key) {
|
|
9
8
|
return this[key];
|
|
@@ -30,23 +29,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
30
29
|
cache.set(mod, to);
|
|
31
30
|
return to;
|
|
32
31
|
};
|
|
33
|
-
var __toCommonJS = (from) => {
|
|
34
|
-
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
35
|
-
if (entry)
|
|
36
|
-
return entry;
|
|
37
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
38
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
39
|
-
for (var key of __getOwnPropNames(from))
|
|
40
|
-
if (!__hasOwnProp.call(entry, key))
|
|
41
|
-
__defProp(entry, key, {
|
|
42
|
-
get: __accessProp.bind(from, key),
|
|
43
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
__moduleCache.set(from, entry);
|
|
47
|
-
return entry;
|
|
48
|
-
};
|
|
49
|
-
var __moduleCache;
|
|
50
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
51
33
|
var __returnValue = (v) => v;
|
|
52
34
|
function __exportSetter(name, newValue) {
|
|
@@ -79,8 +61,9 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
79
61
|
var __require = import.meta.require;
|
|
80
62
|
|
|
81
63
|
// src/constants.ts
|
|
82
|
-
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_CODE = 27, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, IMAGE_DEFAULT_DEVICE_SIZES, IMAGE_DEFAULT_IMAGE_SIZES, IMAGE_DEFAULT_QUALITY = 75, IMAGE_GLOB_SUFFIX_LENGTH = 2, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000, WORKSPACE_COMMAND_ARGS_OFFSET = 3, WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30, WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60, WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5000, WORKSPACE_READY_PROBE_INTERVAL_MS = 250, WORKSPACE_READY_TIMEOUT_MS = 30000, WORKSPACE_SHUTDOWN_TIMEOUT_MS = 1e4, WORKSPACE_TUI_DEFAULT_HEIGHT = 28, WORKSPACE_TUI_DEFAULT_WIDTH = 100, WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, WORKSPACE_TUI_FOOTER_LINE_COUNT = 3, WORKSPACE_TUI_MIN_LOG_HEIGHT = 3, WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7, WORKSPACE_TUI_MIN_TARGET_WIDTH = 8, WORKSPACE_TUI_MIN_WRAP_WIDTH = 12, WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3, WORKSPACE_TUI_RECENT_LOG_LIMIT = 40, WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16, WORKSPACE_TUI_STATUS_WIDTH = 10, WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6, WORKSPACE_TUI_VISIBILITY_WIDTH = 8;
|
|
64
|
+
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_CODE = 27, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", TAILWIND_BUN_CSS_WARNING_PATTERN, BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, ESLINT_STUDIO_DEFAULT_HOST = "eslint.absolute.localhost", ESLINT_STUDIO_DEFAULT_PORT = 4099, CONFIG_DEFAULT_HOST = "config.absolute.localhost", CONFIG_DEFAULT_PORT = 4099, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, IMAGE_DEFAULT_DEVICE_SIZES, IMAGE_DEFAULT_IMAGE_SIZES, IMAGE_DEFAULT_QUALITY = 75, IMAGE_GLOB_SUFFIX_LENGTH = 2, INSTANCE_PROBE_TIMEOUT_MS = 250, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, LIST_LOG_TAIL_MAX_BYTES = 65536, LIST_TUI_COLUMN_GAP = 2, LIST_TUI_DEFAULT_HEIGHT = 28, LIST_TUI_DEFAULT_WIDTH = 100, LIST_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, LIST_TUI_FOOTER_LINE_COUNT = 2, LIST_TUI_MARKER_WIDTH = 2, LIST_TUI_MIN_LOG_HEIGHT = 3, LIST_TUI_MIN_URL_WIDTH = 16, LIST_TUI_RENDER_DEBOUNCE_MS = 16, LIST_TUI_STATUS_MESSAGE_TIMEOUT_MS = 4000, LIST_WATCH_REFRESH_MS = 1000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000, DEFAULT_WEBSOCKET_IDLE_TIMEOUT_SECONDS = 240, DEFAULT_HTTP_IDLE_TIMEOUT_SECONDS = 240, MAX_HTTP_IDLE_TIMEOUT_SECONDS = 255, WORKSPACE_COMMAND_ARGS_OFFSET = 3, WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30, WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60, WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5000, WORKSPACE_READY_PROBE_INTERVAL_MS = 250, WORKSPACE_READY_TIMEOUT_MS = 30000, WORKSPACE_SHUTDOWN_TIMEOUT_MS = 1e4, WORKSPACE_TUI_DEFAULT_HEIGHT = 28, WORKSPACE_TUI_DEFAULT_WIDTH = 100, WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, WORKSPACE_TUI_FOOTER_LINE_COUNT = 3, WORKSPACE_TUI_MIN_LOG_HEIGHT = 3, WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7, WORKSPACE_TUI_MIN_TARGET_WIDTH = 8, WORKSPACE_TUI_MIN_WRAP_WIDTH = 12, WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3, WORKSPACE_TUI_RECENT_LOG_LIMIT = 40, WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16, WORKSPACE_TUI_STATUS_WIDTH = 10, WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6, WORKSPACE_TUI_VISIBILITY_WIDTH = 8;
|
|
83
65
|
var init_constants = __esm(() => {
|
|
66
|
+
TAILWIND_BUN_CSS_WARNING_PATTERN = /invalid @ rule encountered: '@(theme|tailwind|source|utility|variant|custom-variant|apply|reference|plugin|config)'/;
|
|
84
67
|
IMAGE_DEFAULT_DEVICE_SIZES = [
|
|
85
68
|
640,
|
|
86
69
|
750,
|
|
@@ -97,6 +80,467 @@ var init_constants = __esm(() => {
|
|
|
97
80
|
TWO_THIRDS = 2 / 3;
|
|
98
81
|
});
|
|
99
82
|
|
|
83
|
+
// src/utils/inlinePageCss.ts
|
|
84
|
+
var siblingCssCache, clearSiblingCssCache = () => {
|
|
85
|
+
siblingCssCache.clear();
|
|
86
|
+
}, injectInlineCss = (headTag, css) => {
|
|
87
|
+
if (!css)
|
|
88
|
+
return headTag;
|
|
89
|
+
const styleBlock = `<style data-absolute-page-css>${css}</style>`;
|
|
90
|
+
return headTag.replace("</head>", `${styleBlock}</head>`);
|
|
91
|
+
}, readSiblingCss = async (siblingJsPath) => {
|
|
92
|
+
if (!siblingJsPath)
|
|
93
|
+
return "";
|
|
94
|
+
const cssPath = siblingJsPath.replace(/\.js$/, ".css");
|
|
95
|
+
if (cssPath === siblingJsPath)
|
|
96
|
+
return "";
|
|
97
|
+
const cached = siblingCssCache.get(cssPath);
|
|
98
|
+
if (cached !== undefined)
|
|
99
|
+
return cached;
|
|
100
|
+
const { readFile } = await import("fs/promises");
|
|
101
|
+
try {
|
|
102
|
+
const css = await readFile(cssPath, "utf-8");
|
|
103
|
+
siblingCssCache.set(cssPath, css);
|
|
104
|
+
return css;
|
|
105
|
+
} catch {
|
|
106
|
+
siblingCssCache.set(cssPath, "");
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var init_inlinePageCss = __esm(() => {
|
|
111
|
+
siblingCssCache = new Map;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// src/utils/spaRouteCss.ts
|
|
115
|
+
import { readFile } from "fs/promises";
|
|
116
|
+
import { dirname, isAbsolute, resolve } from "path";
|
|
117
|
+
var sideManifestCache, readSideManifest = async (sideManifestPath) => {
|
|
118
|
+
const cached = sideManifestCache.get(sideManifestPath);
|
|
119
|
+
if (cached !== undefined)
|
|
120
|
+
return cached;
|
|
121
|
+
try {
|
|
122
|
+
const raw = await readFile(sideManifestPath, "utf-8");
|
|
123
|
+
const parsed = JSON.parse(raw);
|
|
124
|
+
const routes = Array.isArray(parsed) ? parsed : [];
|
|
125
|
+
sideManifestCache.set(sideManifestPath, routes);
|
|
126
|
+
return routes;
|
|
127
|
+
} catch {
|
|
128
|
+
sideManifestCache.set(sideManifestPath, []);
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
}, compilePathToRegExp = (pattern) => {
|
|
132
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
133
|
+
const withParams = escaped.replace(/:([a-zA-Z_$][a-zA-Z0-9_$]*)/g, "[^/]+").replace(/\\\*/g, ".*");
|
|
134
|
+
return new RegExp(`^${withParams}$`);
|
|
135
|
+
}, routeMatchers, matcherFor = (pattern) => {
|
|
136
|
+
const cached = routeMatchers.get(pattern);
|
|
137
|
+
if (cached !== undefined)
|
|
138
|
+
return cached;
|
|
139
|
+
const compiled = compilePathToRegExp(pattern);
|
|
140
|
+
routeMatchers.set(pattern, compiled);
|
|
141
|
+
return compiled;
|
|
142
|
+
}, findMatchingRoute = (routes, pathname) => {
|
|
143
|
+
for (const route of routes) {
|
|
144
|
+
if (matcherFor(route.path).test(pathname))
|
|
145
|
+
return route;
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}, childCssCache, clearSpaRouteCssCaches = () => {
|
|
149
|
+
sideManifestCache.clear();
|
|
150
|
+
childCssCache.clear();
|
|
151
|
+
}, readChildCss = async (cssPath, sideManifestPath) => {
|
|
152
|
+
if (!cssPath)
|
|
153
|
+
return "";
|
|
154
|
+
const resolvedCssPath = isAbsolute(cssPath) ? cssPath : resolve(dirname(sideManifestPath), cssPath);
|
|
155
|
+
const cached = childCssCache.get(resolvedCssPath);
|
|
156
|
+
if (cached !== undefined)
|
|
157
|
+
return cached;
|
|
158
|
+
try {
|
|
159
|
+
const css = await readFile(resolvedCssPath, "utf-8");
|
|
160
|
+
childCssCache.set(resolvedCssPath, css);
|
|
161
|
+
return css;
|
|
162
|
+
} catch {
|
|
163
|
+
childCssCache.set(resolvedCssPath, "");
|
|
164
|
+
return "";
|
|
165
|
+
}
|
|
166
|
+
}, resolveSpaChildCss = async (siblingJsPath, requestUrl) => {
|
|
167
|
+
if (!siblingJsPath || !requestUrl)
|
|
168
|
+
return "";
|
|
169
|
+
const sideManifestPath = siblingJsPath.replace(/\.js$/, ".spa.json");
|
|
170
|
+
if (sideManifestPath === siblingJsPath)
|
|
171
|
+
return "";
|
|
172
|
+
const routes = await readSideManifest(sideManifestPath);
|
|
173
|
+
if (routes.length === 0)
|
|
174
|
+
return "";
|
|
175
|
+
let pathname;
|
|
176
|
+
try {
|
|
177
|
+
({ pathname } = new URL(requestUrl));
|
|
178
|
+
} catch {
|
|
179
|
+
pathname = requestUrl.split("?")[0] ?? requestUrl;
|
|
180
|
+
}
|
|
181
|
+
const matched = findMatchingRoute(routes, pathname);
|
|
182
|
+
if (!matched)
|
|
183
|
+
return "";
|
|
184
|
+
const { cssPath: routeCssPath } = matched;
|
|
185
|
+
const cssPaths = [
|
|
186
|
+
routeCssPath,
|
|
187
|
+
...routes.map((route) => route.cssPath)
|
|
188
|
+
].filter((childCssPath, index, all) => childCssPath && all.indexOf(childCssPath) === index);
|
|
189
|
+
const chunks = await Promise.all(cssPaths.map((childCssPath) => readChildCss(childCssPath, sideManifestPath)));
|
|
190
|
+
return chunks.filter(Boolean).join(`
|
|
191
|
+
`);
|
|
192
|
+
};
|
|
193
|
+
var init_spaRouteCss = __esm(() => {
|
|
194
|
+
sideManifestCache = new Map;
|
|
195
|
+
routeMatchers = new Map;
|
|
196
|
+
childCssCache = new Map;
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/utils/stringModifiers.ts
|
|
200
|
+
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
201
|
+
if (!str.includes("-") && !str.includes("_")) {
|
|
202
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
203
|
+
}
|
|
204
|
+
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/utils/resolveConvention.ts
|
|
208
|
+
import { basename } from "path";
|
|
209
|
+
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
210
|
+
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
211
|
+
if (isConventionsMap(value))
|
|
212
|
+
return value;
|
|
213
|
+
const empty = {};
|
|
214
|
+
return empty;
|
|
215
|
+
}, derivePageName = (pagePath) => {
|
|
216
|
+
const base = basename(pagePath);
|
|
217
|
+
const dotIndex = base.indexOf(".");
|
|
218
|
+
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
219
|
+
return toPascal(name);
|
|
220
|
+
}, normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, ""), hasErrorConvention = (framework) => {
|
|
221
|
+
const conventions = getMap()[framework];
|
|
222
|
+
if (!conventions)
|
|
223
|
+
return false;
|
|
224
|
+
if (conventions.defaults?.error)
|
|
225
|
+
return true;
|
|
226
|
+
return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
|
|
227
|
+
}, resolveErrorConventionPath = (framework, pageName) => {
|
|
228
|
+
const conventions = getMap()[framework];
|
|
229
|
+
if (!conventions)
|
|
230
|
+
return;
|
|
231
|
+
const exact = conventions.pages?.[pageName]?.error;
|
|
232
|
+
if (exact)
|
|
233
|
+
return exact;
|
|
234
|
+
const normalizedPageName = normalizeConventionPageName(pageName);
|
|
235
|
+
for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
|
|
236
|
+
if (normalizeConventionPageName(candidate) === normalizedPageName) {
|
|
237
|
+
return page.error ?? conventions.defaults?.error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return conventions.defaults?.error;
|
|
241
|
+
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
242
|
+
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
243
|
+
}, isDev = () => true, buildErrorProps = (error) => {
|
|
244
|
+
if (error instanceof Error) {
|
|
245
|
+
return {
|
|
246
|
+
message: error.message,
|
|
247
|
+
name: error.name,
|
|
248
|
+
...isDev() && error.stack ? { stack: error.stack } : {}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return { message: String(error), name: "Error" };
|
|
252
|
+
}, renderReactError = async (conventionPath, errorProps) => {
|
|
253
|
+
const { createElement } = await import("react");
|
|
254
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
255
|
+
const mod = await import(conventionPath);
|
|
256
|
+
const ErrorComponent = mod.default;
|
|
257
|
+
if (typeof ErrorComponent !== "function")
|
|
258
|
+
return null;
|
|
259
|
+
const element = createElement(ErrorComponent, errorProps);
|
|
260
|
+
const stream = await renderToReadableStream(element);
|
|
261
|
+
return new Response(stream, {
|
|
262
|
+
headers: { "Content-Type": "text/html" },
|
|
263
|
+
status: 500
|
|
264
|
+
});
|
|
265
|
+
}, renderSvelteError = async (conventionPath, errorProps) => {
|
|
266
|
+
const { render } = await import("svelte/server");
|
|
267
|
+
const mod = await import(conventionPath);
|
|
268
|
+
const ErrorComponent = mod.default;
|
|
269
|
+
if (!ErrorComponent)
|
|
270
|
+
return null;
|
|
271
|
+
const { head, body } = render(ErrorComponent, {
|
|
272
|
+
props: errorProps
|
|
273
|
+
});
|
|
274
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
275
|
+
return new Response(html, {
|
|
276
|
+
headers: { "Content-Type": "text/html" },
|
|
277
|
+
status: 500
|
|
278
|
+
});
|
|
279
|
+
}, unescapeVueStyles = (ssrBody) => {
|
|
280
|
+
let styles = "";
|
|
281
|
+
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
282
|
+
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
283
|
+
return "";
|
|
284
|
+
});
|
|
285
|
+
return { body, styles };
|
|
286
|
+
}, renderVueError = async (conventionPath, errorProps) => {
|
|
287
|
+
const { createSSRApp, h: h4 } = await import("vue");
|
|
288
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
289
|
+
const mod = await import(conventionPath);
|
|
290
|
+
const ErrorComponent = mod.default;
|
|
291
|
+
if (!ErrorComponent)
|
|
292
|
+
return null;
|
|
293
|
+
const app = createSSRApp({
|
|
294
|
+
render: () => h4(ErrorComponent, errorProps)
|
|
295
|
+
});
|
|
296
|
+
const rawBody = await renderToString(app);
|
|
297
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
298
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
299
|
+
return new Response(html, {
|
|
300
|
+
headers: { "Content-Type": "text/html" },
|
|
301
|
+
status: 500
|
|
302
|
+
});
|
|
303
|
+
}, renderAngularError = async (conventionPath, errorProps) => {
|
|
304
|
+
const mod = await import(conventionPath);
|
|
305
|
+
const renderFn = mod.default;
|
|
306
|
+
if (typeof renderFn !== "function")
|
|
307
|
+
return null;
|
|
308
|
+
const html = renderFn(errorProps);
|
|
309
|
+
return new Response(html, {
|
|
310
|
+
headers: { "Content-Type": "text/html" },
|
|
311
|
+
status: 500
|
|
312
|
+
});
|
|
313
|
+
}, escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : ""), renderHtmlError = async (conventionPath, errorProps) => {
|
|
314
|
+
const template = await Bun.file(conventionPath).text();
|
|
315
|
+
const html = replaceErrorTokens(template, errorProps);
|
|
316
|
+
return new Response(html, {
|
|
317
|
+
headers: { "Content-Type": "text/html" },
|
|
318
|
+
status: 500
|
|
319
|
+
});
|
|
320
|
+
}, logConventionRenderError = (framework, label, renderError) => {
|
|
321
|
+
const message = renderError instanceof Error ? renderError.message : "";
|
|
322
|
+
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
323
|
+
console.error(`[SSR] Convention ${label} page for ${framework} failed: missing framework package. Ensure the ${framework} runtime is installed (e.g. bun add ${framework === "react" ? "react react-dom" : framework}).`);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
327
|
+
}, renderEmberError = async () => null, renderEmberNotFound = async () => null, ERROR_RENDERERS, tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
|
|
328
|
+
let conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
329
|
+
if (!conventionPath && error instanceof Error && error.stack) {
|
|
330
|
+
for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
|
|
331
|
+
const [, candidate] = match;
|
|
332
|
+
if (!candidate)
|
|
333
|
+
continue;
|
|
334
|
+
conventionPath = resolveErrorConventionPath(framework, candidate);
|
|
335
|
+
if (conventionPath)
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (!conventionPath)
|
|
340
|
+
return null;
|
|
341
|
+
const renderer = ERROR_RENDERERS[framework];
|
|
342
|
+
if (!renderer)
|
|
343
|
+
return null;
|
|
344
|
+
try {
|
|
345
|
+
return await renderer(conventionPath, errorProps);
|
|
346
|
+
} catch (renderError) {
|
|
347
|
+
logConventionRenderError(framework, "error", renderError);
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}, renderConventionError = async (framework, pageName, error) => {
|
|
351
|
+
const errorProps = buildErrorProps(error);
|
|
352
|
+
const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
|
|
353
|
+
if (frameworkResponse)
|
|
354
|
+
return frameworkResponse;
|
|
355
|
+
if (framework !== "html") {
|
|
356
|
+
const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
|
|
357
|
+
if (htmlResponse)
|
|
358
|
+
return htmlResponse;
|
|
359
|
+
}
|
|
360
|
+
return null;
|
|
361
|
+
}, renderReactNotFound = async (conventionPath) => {
|
|
362
|
+
const { createElement } = await import("react");
|
|
363
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
364
|
+
const mod = await import(conventionPath);
|
|
365
|
+
const NotFoundComponent = mod.default;
|
|
366
|
+
if (typeof NotFoundComponent !== "function")
|
|
367
|
+
return null;
|
|
368
|
+
const element = createElement(NotFoundComponent);
|
|
369
|
+
const stream = await renderToReadableStream(element);
|
|
370
|
+
return new Response(stream, {
|
|
371
|
+
headers: { "Content-Type": "text/html" },
|
|
372
|
+
status: 404
|
|
373
|
+
});
|
|
374
|
+
}, renderSvelteNotFound = async (conventionPath) => {
|
|
375
|
+
const { render } = await import("svelte/server");
|
|
376
|
+
const mod = await import(conventionPath);
|
|
377
|
+
const NotFoundComponent = mod.default;
|
|
378
|
+
if (!NotFoundComponent)
|
|
379
|
+
return null;
|
|
380
|
+
const { head, body } = render(NotFoundComponent);
|
|
381
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
382
|
+
return new Response(html, {
|
|
383
|
+
headers: { "Content-Type": "text/html" },
|
|
384
|
+
status: 404
|
|
385
|
+
});
|
|
386
|
+
}, renderVueNotFound = async (conventionPath) => {
|
|
387
|
+
const { createSSRApp, h: h4 } = await import("vue");
|
|
388
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
389
|
+
const mod = await import(conventionPath);
|
|
390
|
+
const NotFoundComponent = mod.default;
|
|
391
|
+
if (!NotFoundComponent)
|
|
392
|
+
return null;
|
|
393
|
+
const app = createSSRApp({
|
|
394
|
+
render: () => h4(NotFoundComponent)
|
|
395
|
+
});
|
|
396
|
+
const rawBody = await renderToString(app);
|
|
397
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
398
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
399
|
+
return new Response(html, {
|
|
400
|
+
headers: { "Content-Type": "text/html" },
|
|
401
|
+
status: 404
|
|
402
|
+
});
|
|
403
|
+
}, renderAngularNotFound = async (conventionPath) => {
|
|
404
|
+
const mod = await import(conventionPath);
|
|
405
|
+
const renderFn = mod.default;
|
|
406
|
+
if (typeof renderFn !== "function")
|
|
407
|
+
return null;
|
|
408
|
+
const html = renderFn();
|
|
409
|
+
return new Response(html, {
|
|
410
|
+
headers: { "Content-Type": "text/html" },
|
|
411
|
+
status: 404
|
|
412
|
+
});
|
|
413
|
+
}, renderHtmlNotFound = async (conventionPath) => {
|
|
414
|
+
const html = await Bun.file(conventionPath).text();
|
|
415
|
+
return new Response(html, {
|
|
416
|
+
headers: { "Content-Type": "text/html" },
|
|
417
|
+
status: 404
|
|
418
|
+
});
|
|
419
|
+
}, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
|
|
420
|
+
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
421
|
+
if (!conventionPath)
|
|
422
|
+
return null;
|
|
423
|
+
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
424
|
+
if (!renderer)
|
|
425
|
+
return null;
|
|
426
|
+
try {
|
|
427
|
+
return await renderer(conventionPath);
|
|
428
|
+
} catch (renderError) {
|
|
429
|
+
logConventionRenderError(framework, "not-found", renderError);
|
|
430
|
+
}
|
|
431
|
+
return null;
|
|
432
|
+
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
433
|
+
const renderNext = async (frameworks) => {
|
|
434
|
+
const [framework, ...remaining] = frameworks;
|
|
435
|
+
if (!framework) {
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
if (!getMap()[framework]?.defaults?.notFound) {
|
|
439
|
+
return renderNext(remaining);
|
|
440
|
+
}
|
|
441
|
+
const response = await renderConventionNotFound(framework);
|
|
442
|
+
if (response) {
|
|
443
|
+
return response;
|
|
444
|
+
}
|
|
445
|
+
return renderNext(remaining);
|
|
446
|
+
};
|
|
447
|
+
return renderNext(NOT_FOUND_PRIORITY);
|
|
448
|
+
};
|
|
449
|
+
var init_resolveConvention = __esm(() => {
|
|
450
|
+
ERROR_RENDERERS = {
|
|
451
|
+
angular: renderAngularError,
|
|
452
|
+
ember: renderEmberError,
|
|
453
|
+
html: renderHtmlError,
|
|
454
|
+
react: renderReactError,
|
|
455
|
+
svelte: renderSvelteError,
|
|
456
|
+
vue: renderVueError
|
|
457
|
+
};
|
|
458
|
+
NOT_FOUND_RENDERERS = {
|
|
459
|
+
angular: renderAngularNotFound,
|
|
460
|
+
ember: renderEmberNotFound,
|
|
461
|
+
html: renderHtmlNotFound,
|
|
462
|
+
react: renderReactNotFound,
|
|
463
|
+
svelte: renderSvelteNotFound,
|
|
464
|
+
vue: renderVueNotFound
|
|
465
|
+
};
|
|
466
|
+
NOT_FOUND_PRIORITY = [
|
|
467
|
+
"react",
|
|
468
|
+
"svelte",
|
|
469
|
+
"vue",
|
|
470
|
+
"angular",
|
|
471
|
+
"html"
|
|
472
|
+
];
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// src/utils/spaRouteManifest.ts
|
|
476
|
+
import { basename as basename2 } from "path";
|
|
477
|
+
var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
|
|
478
|
+
Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
|
|
479
|
+
}, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
|
|
480
|
+
const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
|
|
481
|
+
return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
|
|
482
|
+
}, normalizePath = (path) => {
|
|
483
|
+
const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
|
|
484
|
+
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
485
|
+
return trimmed || "/";
|
|
486
|
+
}, fullRoutePath = (baseHref, routePath) => {
|
|
487
|
+
const base = normalizePath(baseHref);
|
|
488
|
+
const route = normalizePath(routePath);
|
|
489
|
+
if (base !== "/" && (route === base || route.startsWith(`${base}/`))) {
|
|
490
|
+
return route;
|
|
491
|
+
}
|
|
492
|
+
if (base === "/")
|
|
493
|
+
return route;
|
|
494
|
+
return normalizePath(`${base}/${route.replace(/^\/+/, "")}`);
|
|
495
|
+
}, routePattern = (path) => {
|
|
496
|
+
const segments = normalizePath(path).split("/").filter(Boolean);
|
|
497
|
+
let expression = "^";
|
|
498
|
+
for (const segment of segments) {
|
|
499
|
+
if (segment === "*" || segment === "**") {
|
|
500
|
+
expression += "(?:/.*)?";
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
const parameter = /^:[A-Za-z_$][A-Za-z0-9_$]*(?:\((.*)\))?(\?)?$/.exec(segment);
|
|
504
|
+
if (parameter) {
|
|
505
|
+
const valuePattern = parameter[1] || "[^/]+";
|
|
506
|
+
expression += parameter[2] ? `(?:/${valuePattern})?` : `/${valuePattern}`;
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
expression += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&")}`;
|
|
510
|
+
}
|
|
511
|
+
return new RegExp(`${expression || "^/"}/?$`);
|
|
512
|
+
}, sourcePageName = (sourceFile) => basename2(sourceFile).replace(/\.[^.]+$/, "").toLowerCase(), isKnownSpaRoute = (framework, pageName, request) => {
|
|
513
|
+
if (!request)
|
|
514
|
+
return true;
|
|
515
|
+
let pathname;
|
|
516
|
+
try {
|
|
517
|
+
pathname = normalizePath(new URL(request.url).pathname);
|
|
518
|
+
} catch {
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
const hosts = getSpaRouteManifest().filter((host) => {
|
|
522
|
+
if (host.framework !== framework)
|
|
523
|
+
return false;
|
|
524
|
+
if (sourcePageName(host.sourceFile) !== pageName.toLowerCase())
|
|
525
|
+
return false;
|
|
526
|
+
const base = normalizePath(host.baseHref);
|
|
527
|
+
return base === "/" || pathname === base || pathname.startsWith(`${base}/`);
|
|
528
|
+
});
|
|
529
|
+
if (hosts.length === 0)
|
|
530
|
+
return true;
|
|
531
|
+
return hosts.some((host) => host.routes.some((route) => routePattern(fullRoutePath(host.baseHref, route.path)).test(pathname)));
|
|
532
|
+
}, renderSpaNotFound = async (framework, pageName, request) => {
|
|
533
|
+
if (isKnownSpaRoute(framework, pageName, request))
|
|
534
|
+
return null;
|
|
535
|
+
return await renderFirstNotFound() ?? new Response("Not found", {
|
|
536
|
+
headers: { "Content-Type": "text/plain" },
|
|
537
|
+
status: 404
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
var init_spaRouteManifest = __esm(() => {
|
|
541
|
+
init_resolveConvention();
|
|
542
|
+
});
|
|
543
|
+
|
|
100
544
|
// src/core/devRouteRegistrationCallsite.ts
|
|
101
545
|
var exports_devRouteRegistrationCallsite = {};
|
|
102
546
|
__export(exports_devRouteRegistrationCallsite, {
|
|
@@ -107,22 +551,20 @@ __export(exports_devRouteRegistrationCallsite, {
|
|
|
107
551
|
});
|
|
108
552
|
import { AsyncLocalStorage } from "async_hooks";
|
|
109
553
|
import { Elysia } from "elysia";
|
|
110
|
-
var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
|
|
554
|
+
var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, NODE_ENV_KEY = "NODE_ENV", ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, isPageHandlerFunction = (value) => typeof value === "function", handlerSourceMentionsPageHelper = (handler) => {
|
|
111
555
|
const source = handler.toString();
|
|
112
556
|
return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
|
|
557
|
+
}, getOriginalPageHandlerSource = (handler) => {
|
|
558
|
+
if (!isPageHandlerFunction(handler))
|
|
559
|
+
return;
|
|
560
|
+
const info = pageHandlerWrappers.get(handler);
|
|
561
|
+
return (info?.originalHandler ?? handler).toString();
|
|
113
562
|
}, isPageHandler = (handler) => {
|
|
114
|
-
if (
|
|
563
|
+
if (!isPageHandlerFunction(handler))
|
|
115
564
|
return false;
|
|
116
|
-
|
|
117
|
-
if (pageHandlerWrappers.has(fn))
|
|
565
|
+
if (pageHandlerWrappers.has(handler))
|
|
118
566
|
return true;
|
|
119
|
-
return handlerSourceMentionsPageHelper(
|
|
120
|
-
}, getOriginalPageHandlerSource = (handler) => {
|
|
121
|
-
if (typeof handler !== "function")
|
|
122
|
-
return;
|
|
123
|
-
const fn = handler;
|
|
124
|
-
const info = pageHandlerWrappers.get(fn);
|
|
125
|
-
return (info?.originalHandler ?? fn).toString();
|
|
567
|
+
return handlerSourceMentionsPageHelper(handler);
|
|
126
568
|
}, isObjectRecord4 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
|
|
127
569
|
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
128
570
|
if (value === null || typeof value === "undefined") {
|
|
@@ -156,17 +598,22 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
|
|
|
156
598
|
return function wrappedRouteHandler(...args) {
|
|
157
599
|
return storage.run({ callsite }, () => Reflect.apply(routeHandler, this, args));
|
|
158
600
|
};
|
|
159
|
-
}, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path,
|
|
601
|
+
}, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, ...routeArguments) {
|
|
602
|
+
const handlerIndex = routeArguments.length >= 2 ? 1 : 0;
|
|
603
|
+
const handler = routeArguments[handlerIndex];
|
|
160
604
|
const callsite = captureRouteRegistrationCallsite();
|
|
161
605
|
const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
|
|
162
|
-
if (methodName === "get" &&
|
|
606
|
+
if (methodName === "get" && isPageHandlerFunction(handler) && isPageHandlerFunction(wrapped) && handlerSourceMentionsPageHelper(handler)) {
|
|
163
607
|
pageHandlerWrappers.set(wrapped, {
|
|
164
608
|
originalHandler: handler
|
|
165
609
|
});
|
|
166
610
|
}
|
|
167
|
-
|
|
611
|
+
routeArguments[handlerIndex] = wrapped;
|
|
612
|
+
return Reflect.apply(originalMethod, this, [path, ...routeArguments]);
|
|
168
613
|
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
169
|
-
if (
|
|
614
|
+
if (process.env[NODE_ENV_KEY] === "production") {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
170
617
|
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
171
618
|
return;
|
|
172
619
|
}
|
|
@@ -203,6 +650,43 @@ var init_devRouteRegistrationCallsite = __esm(() => {
|
|
|
203
650
|
pageHandlerWrappers = new WeakMap;
|
|
204
651
|
});
|
|
205
652
|
|
|
653
|
+
// src/core/pageResponseCache.ts
|
|
654
|
+
import { createHash } from "crypto";
|
|
655
|
+
var STREAMING_PAGE_HEADER = "x-absolute-stream", HTML_CONTENT_TYPE = "text/html", streamingPageHeaders = (extra) => {
|
|
656
|
+
const headers = new Headers(extra);
|
|
657
|
+
headers.set("content-type", HTML_CONTENT_TYPE);
|
|
658
|
+
headers.set(STREAMING_PAGE_HEADER, "1");
|
|
659
|
+
return headers;
|
|
660
|
+
}, computeEtag = (html) => `W/"${createHash("sha1").update(html).digest("base64url")}"`, withPageCacheHeaders = async (response, request, options) => {
|
|
661
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
662
|
+
if (!contentType.includes(HTML_CONTENT_TYPE))
|
|
663
|
+
return response;
|
|
664
|
+
const isStreaming = response.headers.get(STREAMING_PAGE_HEADER) === "1";
|
|
665
|
+
if (isStreaming && !options?.bufferStreamForEtag || !response.body) {
|
|
666
|
+
response.headers.delete(STREAMING_PAGE_HEADER);
|
|
667
|
+
response.headers.set("cache-control", "no-cache");
|
|
668
|
+
return response;
|
|
669
|
+
}
|
|
670
|
+
const html = await response.text();
|
|
671
|
+
const etag = computeEtag(html);
|
|
672
|
+
if (request?.headers.get("if-none-match") === etag) {
|
|
673
|
+
return new Response(null, {
|
|
674
|
+
headers: { "cache-control": "no-cache", etag },
|
|
675
|
+
status: 304
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
const headers = new Headers(response.headers);
|
|
679
|
+
headers.delete(STREAMING_PAGE_HEADER);
|
|
680
|
+
headers.set("cache-control", "no-cache");
|
|
681
|
+
headers.set("etag", etag);
|
|
682
|
+
return new Response(html, {
|
|
683
|
+
headers,
|
|
684
|
+
status: response.status,
|
|
685
|
+
statusText: response.statusText
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
var init_pageResponseCache = () => {};
|
|
689
|
+
|
|
206
690
|
// src/client/streamSwap.ts
|
|
207
691
|
var streamSwapRuntime = () => {
|
|
208
692
|
const absoluteWindow = window;
|
|
@@ -988,6 +1472,19 @@ var colors2, frameworkColors, formatPath = (filePath) => {
|
|
|
988
1472
|
const errorMsg = error instanceof Error ? error.message : error;
|
|
989
1473
|
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
990
1474
|
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
1475
|
+
}, logHmrClientUpdate = (path, framework, duration, target, serverMs, clientMs, outcome = "applied", kind) => {
|
|
1476
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1477
|
+
const targetLabel = target.startsWith("capacitor-") ? target.slice("capacitor-".length) : target;
|
|
1478
|
+
const tag = `${colors2.cyan}[hmr:${targetLabel}]${colors2.reset}`;
|
|
1479
|
+
const pathColor = framework ? getFrameworkColor(framework) : colors2.white;
|
|
1480
|
+
const breakdown = serverMs === undefined || clientMs === undefined ? "" : `; server ${serverMs}ms, client ${clientMs}ms`;
|
|
1481
|
+
let action = "failed after";
|
|
1482
|
+
if (outcome === "applied")
|
|
1483
|
+
action = "applied in";
|
|
1484
|
+
else if (outcome === "reloaded")
|
|
1485
|
+
action = "falling back to reload after";
|
|
1486
|
+
const kindLabel = kind ? `${kind} ` : "";
|
|
1487
|
+
console.log(`${timestamp} ${tag} ${framework ?? "update"} ${kindLabel}${pathColor}${formatPath(path)}${colors2.reset} ${colors2.dim}${action} ${duration}ms${breakdown}${colors2.reset}`);
|
|
991
1488
|
}, logHmrUpdate = (path, framework, duration) => {
|
|
992
1489
|
log("hmr update", { duration, framework, path });
|
|
993
1490
|
}, logInfo = (message) => {
|
|
@@ -1083,14 +1580,6 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
1083
1580
|
</html>`;
|
|
1084
1581
|
};
|
|
1085
1582
|
|
|
1086
|
-
// src/utils/stringModifiers.ts
|
|
1087
|
-
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
1088
|
-
if (!str.includes("-") && !str.includes("_")) {
|
|
1089
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1090
|
-
}
|
|
1091
|
-
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
1583
|
// src/cli/scripts/telemetry.ts
|
|
1095
1584
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
1096
1585
|
import { homedir } from "os";
|
|
@@ -1114,7 +1603,7 @@ var init_telemetry = __esm(() => {
|
|
|
1114
1603
|
// src/cli/telemetryEvent.ts
|
|
1115
1604
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
1116
1605
|
import { arch, platform } from "os";
|
|
1117
|
-
import { dirname, join as join2, parse } from "path";
|
|
1606
|
+
import { dirname as dirname3, join as join2, parse } from "path";
|
|
1118
1607
|
var checkCandidate = (candidate) => {
|
|
1119
1608
|
if (!existsSync2(candidate)) {
|
|
1120
1609
|
return null;
|
|
@@ -1139,7 +1628,7 @@ var checkCandidate = (candidate) => {
|
|
|
1139
1628
|
if (version) {
|
|
1140
1629
|
return version;
|
|
1141
1630
|
}
|
|
1142
|
-
dir =
|
|
1631
|
+
dir = dirname3(dir);
|
|
1143
1632
|
}
|
|
1144
1633
|
return "unknown";
|
|
1145
1634
|
}, sendTelemetryEvent = (event, payload) => {
|
|
@@ -1178,18 +1667,18 @@ __export(exports_buildHMRClient, {
|
|
|
1178
1667
|
buildHMRClient: () => buildHMRClient
|
|
1179
1668
|
});
|
|
1180
1669
|
import { existsSync as existsSync3 } from "fs";
|
|
1181
|
-
import { resolve } from "path";
|
|
1670
|
+
import { resolve as resolve2 } from "path";
|
|
1182
1671
|
var {build: bunBuild } = globalThis.Bun;
|
|
1183
1672
|
var resolveHmrClientPath = () => {
|
|
1184
1673
|
const projectRoot = process.cwd();
|
|
1185
|
-
const fromSource =
|
|
1674
|
+
const fromSource = resolve2(import.meta.dir, "client/hmrClient.ts");
|
|
1186
1675
|
if (existsSync3(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
1187
1676
|
return fromSource;
|
|
1188
1677
|
}
|
|
1189
|
-
const fromNodeModules =
|
|
1678
|
+
const fromNodeModules = resolve2(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client/hmrClient.ts");
|
|
1190
1679
|
if (existsSync3(fromNodeModules))
|
|
1191
1680
|
return fromNodeModules;
|
|
1192
|
-
return
|
|
1681
|
+
return resolve2(import.meta.dir, "dev/client/hmrClient.ts");
|
|
1193
1682
|
}, hmrClientPath, buildHMRClient = async () => {
|
|
1194
1683
|
const entryPoint = hmrClientPath;
|
|
1195
1684
|
const result = await bunBuild({
|
|
@@ -1293,13 +1782,13 @@ var requireCurrentIslandRegistry = () => {
|
|
|
1293
1782
|
|
|
1294
1783
|
// src/angular/resolveAngularPackage.ts
|
|
1295
1784
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
1296
|
-
import { join as join3, resolve as
|
|
1785
|
+
import { join as join3, resolve as resolve3 } from "path";
|
|
1297
1786
|
var resolveAngularPackageDir = (specifier) => {
|
|
1298
|
-
const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ?
|
|
1787
|
+
const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve3(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
|
|
1299
1788
|
if (fromCompiledRuntime && existsSync4(fromCompiledRuntime)) {
|
|
1300
1789
|
return fromCompiledRuntime;
|
|
1301
1790
|
}
|
|
1302
|
-
const fromProject =
|
|
1791
|
+
const fromProject = resolve3(process.cwd(), "node_modules", specifier);
|
|
1303
1792
|
if (existsSync4(fromProject)) {
|
|
1304
1793
|
return fromProject;
|
|
1305
1794
|
}
|
|
@@ -1321,7 +1810,7 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
1321
1810
|
}, toSafeVendorName = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), resolveAngularRuntimePath = (specifier) => {
|
|
1322
1811
|
const buildDirs = [
|
|
1323
1812
|
process.env.ABSOLUTE_BUILD_DIR,
|
|
1324
|
-
|
|
1813
|
+
resolve3(process.cwd(), "build")
|
|
1325
1814
|
].filter((value) => Boolean(value));
|
|
1326
1815
|
for (const buildDir of buildDirs) {
|
|
1327
1816
|
const vendorPath = join3(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
|
|
@@ -1333,7 +1822,7 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
1333
1822
|
var init_resolveAngularPackage = () => {};
|
|
1334
1823
|
|
|
1335
1824
|
// src/utils/runtimeMode.ts
|
|
1336
|
-
var ENV_VAR = "NODE_ENV",
|
|
1825
|
+
var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
1337
1826
|
|
|
1338
1827
|
// src/angular/angularPatch.ts
|
|
1339
1828
|
var exports_angularPatch = {};
|
|
@@ -1425,7 +1914,14 @@ var ensureHead = (doc) => {
|
|
|
1425
1914
|
}
|
|
1426
1915
|
try {
|
|
1427
1916
|
const adapter = new \u{275}DominoAdapter;
|
|
1428
|
-
const
|
|
1917
|
+
const resolveSeedDoc = () => {
|
|
1918
|
+
if (typeof adapter.createHtmlDocument === "function")
|
|
1919
|
+
return adapter.createHtmlDocument();
|
|
1920
|
+
if (typeof adapter.getDefaultDocument === "function")
|
|
1921
|
+
return adapter.getDefaultDocument();
|
|
1922
|
+
return null;
|
|
1923
|
+
};
|
|
1924
|
+
const seedDoc = resolveSeedDoc();
|
|
1429
1925
|
if (seedDoc) {
|
|
1430
1926
|
patchElementLayout(seedDoc);
|
|
1431
1927
|
const probe = seedDoc.createElement("div");
|
|
@@ -1504,9 +2000,12 @@ var initDominoAdapter = (platformServer) => {
|
|
|
1504
2000
|
return {
|
|
1505
2001
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
1506
2002
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
2003
|
+
Component: core.Component,
|
|
1507
2004
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
1508
2005
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
1509
2006
|
inject: core.inject,
|
|
2007
|
+
InjectionToken: core.InjectionToken,
|
|
2008
|
+
NgComponentOutlet: common.NgComponentOutlet,
|
|
1510
2009
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
1511
2010
|
provideServerRendering: platformServer.provideServerRendering,
|
|
1512
2011
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
@@ -1708,7 +2207,7 @@ __export(exports_islands, {
|
|
|
1708
2207
|
isAngularComponent: () => isAngularComponent,
|
|
1709
2208
|
getAngularIslandSelector: () => getAngularIslandSelector
|
|
1710
2209
|
});
|
|
1711
|
-
var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) => typeof value === "function",
|
|
2210
|
+
var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, isAngularComponent = (value) => typeof value === "function", getSelectorFromRenderedIsland = (rootElement) => {
|
|
1712
2211
|
const firstChild = rootElement.firstElementChild;
|
|
1713
2212
|
if (!(firstChild instanceof HTMLElement)) {
|
|
1714
2213
|
return null;
|
|
@@ -1762,9 +2261,8 @@ var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) =
|
|
|
1762
2261
|
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
1763
2262
|
return `${componentName}:${JSON.stringify(props)}`;
|
|
1764
2263
|
}, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
|
|
1765
|
-
const { Component, InjectionToken, inject } = await import("@angular/core");
|
|
1766
|
-
const { NgComponentOutlet } = await import("@angular/common");
|
|
1767
2264
|
const deps = await getAngularDeps();
|
|
2265
|
+
const { Component, InjectionToken, NgComponentOutlet, inject } = deps;
|
|
1768
2266
|
const selector = getAngularIslandSelector(islandId);
|
|
1769
2267
|
const propsToken = new InjectionToken(`${wrapperKey}:props`);
|
|
1770
2268
|
|
|
@@ -1870,7 +2368,15 @@ var init_islands2 = __esm(() => {
|
|
|
1870
2368
|
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
1871
2369
|
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands2(), exports_islands));
|
|
1872
2370
|
return renderAngularIslandToHtml2(component, props, islandId);
|
|
1873
|
-
}, renderAngularIslandToHtml2,
|
|
2371
|
+
}, renderAngularIslandToHtml2, LEADING_HOISTED_RESOURCE_RE, stripLeadingHoistedResources = (html) => {
|
|
2372
|
+
let result = html;
|
|
2373
|
+
let match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
2374
|
+
while (match) {
|
|
2375
|
+
result = result.slice(match[0].length);
|
|
2376
|
+
match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
2377
|
+
}
|
|
2378
|
+
return result.trimStart();
|
|
2379
|
+
}, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToString }) => stripLeadingHoistedResources(renderToString(createElement(component, props))))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
|
|
1874
2380
|
const { body } = render(component, { props });
|
|
1875
2381
|
return body;
|
|
1876
2382
|
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
|
|
@@ -1879,12 +2385,578 @@ var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
|
1879
2385
|
});
|
|
1880
2386
|
return import("vue/server-renderer").then(({ renderToString }) => renderToString(app));
|
|
1881
2387
|
});
|
|
1882
|
-
var init_islandSsr = __esm(() => {
|
|
1883
|
-
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
2388
|
+
var init_islandSsr = __esm(() => {
|
|
2389
|
+
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
2390
|
+
LEADING_HOISTED_RESOURCE_RE = /^\s*(?:<link\b[^>]*\/?>|<meta\b[^>]*\/?>|<title\b[^>]*>[\s\S]*?<\/title>|<style\b[^>]*>[\s\S]*?<\/style>|<script\b[^>]*>[\s\S]*?<\/script>)/i;
|
|
2391
|
+
});
|
|
2392
|
+
|
|
2393
|
+
// src/build/maskLiterals.ts
|
|
2394
|
+
var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
|
|
2395
|
+
const n = src.length;
|
|
2396
|
+
const pieces = [];
|
|
2397
|
+
let out = "";
|
|
2398
|
+
let i = 0;
|
|
2399
|
+
let prevChar = "";
|
|
2400
|
+
let prevWord = "";
|
|
2401
|
+
let prevWasSpace = false;
|
|
2402
|
+
const mask = (text) => {
|
|
2403
|
+
out += SENTINEL + pieces.length + SENTINEL;
|
|
2404
|
+
pieces.push(text);
|
|
2405
|
+
prevChar = ")";
|
|
2406
|
+
prevWord = "";
|
|
2407
|
+
prevWasSpace = false;
|
|
2408
|
+
};
|
|
2409
|
+
const endOfString = (start) => {
|
|
2410
|
+
const q = src[start];
|
|
2411
|
+
let j = start + 1;
|
|
2412
|
+
while (j < n) {
|
|
2413
|
+
const c = src[j];
|
|
2414
|
+
if (c === "\\") {
|
|
2415
|
+
j += 2;
|
|
2416
|
+
continue;
|
|
2417
|
+
}
|
|
2418
|
+
if (c === q)
|
|
2419
|
+
return j + 1;
|
|
2420
|
+
if (c === `
|
|
2421
|
+
`)
|
|
2422
|
+
return j;
|
|
2423
|
+
j++;
|
|
2424
|
+
}
|
|
2425
|
+
return j;
|
|
2426
|
+
};
|
|
2427
|
+
const endOfInterp = (start) => {
|
|
2428
|
+
let j = start;
|
|
2429
|
+
let depth = 1;
|
|
2430
|
+
let ipChar = "";
|
|
2431
|
+
let ipWord = "";
|
|
2432
|
+
let ipSpace = false;
|
|
2433
|
+
while (j < n && depth > 0) {
|
|
2434
|
+
const c = src[j];
|
|
2435
|
+
if (c === "\\") {
|
|
2436
|
+
j += 2;
|
|
2437
|
+
continue;
|
|
2438
|
+
}
|
|
2439
|
+
if (c === "`") {
|
|
2440
|
+
j = endOfTemplate(j);
|
|
2441
|
+
ipChar = ")";
|
|
2442
|
+
ipWord = "";
|
|
2443
|
+
ipSpace = false;
|
|
2444
|
+
continue;
|
|
2445
|
+
}
|
|
2446
|
+
if (c === '"' || c === "'") {
|
|
2447
|
+
j = endOfString(j);
|
|
2448
|
+
ipChar = '"';
|
|
2449
|
+
ipWord = "";
|
|
2450
|
+
ipSpace = false;
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
if (c === "/" && src[j + 1] === "/") {
|
|
2454
|
+
const nl = src.indexOf(`
|
|
2455
|
+
`, j);
|
|
2456
|
+
j = nl < 0 ? n : nl;
|
|
2457
|
+
continue;
|
|
2458
|
+
}
|
|
2459
|
+
if (c === "/" && src[j + 1] === "*") {
|
|
2460
|
+
const e = src.indexOf("*/", j + 2);
|
|
2461
|
+
j = e < 0 ? n : e + 2;
|
|
2462
|
+
continue;
|
|
2463
|
+
}
|
|
2464
|
+
if (c === "/" && (ipChar === "" || REGEX_OK_AFTER_CHAR.has(ipChar) || REGEX_OK_AFTER_WORD.has(ipWord))) {
|
|
2465
|
+
const e = endOfRegex(j);
|
|
2466
|
+
if (e > 0) {
|
|
2467
|
+
j = e;
|
|
2468
|
+
ipChar = ")";
|
|
2469
|
+
ipWord = "";
|
|
2470
|
+
ipSpace = false;
|
|
2471
|
+
continue;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
if (c === "{")
|
|
2475
|
+
depth++;
|
|
2476
|
+
else if (c === "}")
|
|
2477
|
+
depth--;
|
|
2478
|
+
j++;
|
|
2479
|
+
if (c === " " || c === "\t" || c === "\r" || c === `
|
|
2480
|
+
`) {
|
|
2481
|
+
ipSpace = true;
|
|
2482
|
+
continue;
|
|
2483
|
+
}
|
|
2484
|
+
if (isIdentChar(c)) {
|
|
2485
|
+
ipWord = isIdentChar(ipChar) && !ipSpace ? ipWord + c : c;
|
|
2486
|
+
} else {
|
|
2487
|
+
ipWord = "";
|
|
2488
|
+
}
|
|
2489
|
+
ipChar = c;
|
|
2490
|
+
ipSpace = false;
|
|
2491
|
+
}
|
|
2492
|
+
return j;
|
|
2493
|
+
};
|
|
2494
|
+
function endOfTemplate(start) {
|
|
2495
|
+
let j = start + 1;
|
|
2496
|
+
while (j < n) {
|
|
2497
|
+
const c = src[j];
|
|
2498
|
+
if (c === "\\") {
|
|
2499
|
+
j += 2;
|
|
2500
|
+
continue;
|
|
2501
|
+
}
|
|
2502
|
+
if (c === "`")
|
|
2503
|
+
return j + 1;
|
|
2504
|
+
if (c === "$" && src[j + 1] === "{") {
|
|
2505
|
+
j = endOfInterp(j + 2);
|
|
2506
|
+
continue;
|
|
2507
|
+
}
|
|
2508
|
+
j++;
|
|
2509
|
+
}
|
|
2510
|
+
return j;
|
|
2511
|
+
}
|
|
2512
|
+
const endOfRegex = (start) => {
|
|
2513
|
+
let j = start + 1;
|
|
2514
|
+
let inClass = false;
|
|
2515
|
+
while (j < n) {
|
|
2516
|
+
const c = src[j];
|
|
2517
|
+
if (c === "\\") {
|
|
2518
|
+
j += 2;
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
if (c === `
|
|
2522
|
+
`)
|
|
2523
|
+
return -1;
|
|
2524
|
+
if (c === "[")
|
|
2525
|
+
inClass = true;
|
|
2526
|
+
else if (c === "]")
|
|
2527
|
+
inClass = false;
|
|
2528
|
+
else if (c === "/" && !inClass) {
|
|
2529
|
+
j++;
|
|
2530
|
+
break;
|
|
2531
|
+
}
|
|
2532
|
+
j++;
|
|
2533
|
+
}
|
|
2534
|
+
while (j < n && /[a-z]/i.test(src[j] ?? ""))
|
|
2535
|
+
j++;
|
|
2536
|
+
return j;
|
|
2537
|
+
};
|
|
2538
|
+
while (i < n) {
|
|
2539
|
+
const c = src[i];
|
|
2540
|
+
const c2 = src[i + 1];
|
|
2541
|
+
if (c === "/" && c2 === "/") {
|
|
2542
|
+
out += "//";
|
|
2543
|
+
i += 2;
|
|
2544
|
+
const s = i;
|
|
2545
|
+
while (i < n && src[i] !== `
|
|
2546
|
+
`)
|
|
2547
|
+
i++;
|
|
2548
|
+
mask(src.slice(s, i));
|
|
2549
|
+
continue;
|
|
2550
|
+
}
|
|
2551
|
+
if (c === "/" && c2 === "*") {
|
|
2552
|
+
out += "/*";
|
|
2553
|
+
i += 2;
|
|
2554
|
+
const e = src.indexOf("*/", i);
|
|
2555
|
+
const end = e < 0 ? n : e;
|
|
2556
|
+
mask(src.slice(i, end));
|
|
2557
|
+
i = end < n ? end + 2 : n;
|
|
2558
|
+
if (end < n)
|
|
2559
|
+
out += "*/";
|
|
2560
|
+
continue;
|
|
2561
|
+
}
|
|
2562
|
+
if (c === "`") {
|
|
2563
|
+
const end = endOfTemplate(i);
|
|
2564
|
+
mask(src.slice(i, end));
|
|
2565
|
+
i = end;
|
|
2566
|
+
continue;
|
|
2567
|
+
}
|
|
2568
|
+
if (c === '"' || c === "'") {
|
|
2569
|
+
const end = endOfString(i);
|
|
2570
|
+
const text = src.slice(i, end);
|
|
2571
|
+
if (RISKY_STRING_CONTENT.test(text)) {
|
|
2572
|
+
mask(text);
|
|
2573
|
+
} else {
|
|
2574
|
+
out += text;
|
|
2575
|
+
prevChar = '"';
|
|
2576
|
+
prevWord = "";
|
|
2577
|
+
prevWasSpace = false;
|
|
2578
|
+
}
|
|
2579
|
+
i = end;
|
|
2580
|
+
continue;
|
|
2581
|
+
}
|
|
2582
|
+
if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
|
|
2583
|
+
const end = endOfRegex(i);
|
|
2584
|
+
if (end > 0) {
|
|
2585
|
+
out += src.slice(i, end);
|
|
2586
|
+
i = end;
|
|
2587
|
+
prevChar = ")";
|
|
2588
|
+
prevWord = "";
|
|
2589
|
+
prevWasSpace = false;
|
|
2590
|
+
continue;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
out += c;
|
|
2594
|
+
i++;
|
|
2595
|
+
if (c === " " || c === "\t" || c === "\r" || c === `
|
|
2596
|
+
`) {
|
|
2597
|
+
prevWasSpace = true;
|
|
2598
|
+
continue;
|
|
2599
|
+
}
|
|
2600
|
+
if (isIdentChar(c)) {
|
|
2601
|
+
const contiguous = isIdentChar(prevChar) && !prevWasSpace;
|
|
2602
|
+
prevWord = contiguous ? prevWord + c : c;
|
|
2603
|
+
} else {
|
|
2604
|
+
prevWord = "";
|
|
2605
|
+
}
|
|
2606
|
+
prevChar = c;
|
|
2607
|
+
prevWasSpace = false;
|
|
2608
|
+
}
|
|
2609
|
+
const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
|
|
2610
|
+
const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
|
|
2611
|
+
return { masked: out, restore };
|
|
2612
|
+
};
|
|
2613
|
+
var init_maskLiterals = __esm(() => {
|
|
2614
|
+
SENTINEL = String.fromCharCode(57344);
|
|
2615
|
+
RISKY_STRING_CONTENT = /\b(?:from|import|require)\s*\(?\s*["'`]/;
|
|
2616
|
+
REGEX_OK_AFTER_CHAR = new Set([
|
|
2617
|
+
"(",
|
|
2618
|
+
",",
|
|
2619
|
+
"=",
|
|
2620
|
+
":",
|
|
2621
|
+
"[",
|
|
2622
|
+
"!",
|
|
2623
|
+
"&",
|
|
2624
|
+
"|",
|
|
2625
|
+
"?",
|
|
2626
|
+
"{",
|
|
2627
|
+
"}",
|
|
2628
|
+
";",
|
|
2629
|
+
"+",
|
|
2630
|
+
"-",
|
|
2631
|
+
"*",
|
|
2632
|
+
"/",
|
|
2633
|
+
"%",
|
|
2634
|
+
"^",
|
|
2635
|
+
"~",
|
|
2636
|
+
"<",
|
|
2637
|
+
">"
|
|
2638
|
+
]);
|
|
2639
|
+
REGEX_OK_AFTER_WORD = new Set([
|
|
2640
|
+
"return",
|
|
2641
|
+
"typeof",
|
|
2642
|
+
"instanceof",
|
|
2643
|
+
"in",
|
|
2644
|
+
"of",
|
|
2645
|
+
"new",
|
|
2646
|
+
"delete",
|
|
2647
|
+
"void",
|
|
2648
|
+
"do",
|
|
2649
|
+
"else",
|
|
2650
|
+
"yield",
|
|
2651
|
+
"await",
|
|
2652
|
+
"case"
|
|
2653
|
+
]);
|
|
2654
|
+
});
|
|
2655
|
+
|
|
2656
|
+
// src/build/nativeRewrite.ts
|
|
2657
|
+
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
2658
|
+
import { platform as platform2, arch as arch2 } from "os";
|
|
2659
|
+
import { resolve as resolve4 } from "path";
|
|
2660
|
+
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
2661
|
+
if (nativeLib !== null)
|
|
2662
|
+
return nativeLib;
|
|
2663
|
+
const osPlatform = platform2();
|
|
2664
|
+
const cpu = arch2();
|
|
2665
|
+
const platformMap = {
|
|
2666
|
+
"darwin-arm64": "darwin-arm64/fast_ops.dylib",
|
|
2667
|
+
"darwin-x64": "darwin-x64/fast_ops.dylib",
|
|
2668
|
+
"linux-arm64": "linux-arm64/fast_ops.so",
|
|
2669
|
+
"linux-x64": "linux-x64/fast_ops.so",
|
|
2670
|
+
"win32-arm64": "windows-arm64/fast_ops.dll",
|
|
2671
|
+
"win32-x64": "windows-x64/fast_ops.dll"
|
|
2672
|
+
};
|
|
2673
|
+
const libPath = platformMap[`${osPlatform}-${cpu}`];
|
|
2674
|
+
if (!libPath)
|
|
2675
|
+
return null;
|
|
2676
|
+
try {
|
|
2677
|
+
const fullPath = resolve4(import.meta.dir, "../../native/packages", libPath);
|
|
2678
|
+
const lib = dlopen(fullPath, ffiDefinition);
|
|
2679
|
+
nativeLib = lib.symbols;
|
|
2680
|
+
return nativeLib;
|
|
2681
|
+
} catch {
|
|
2682
|
+
return null;
|
|
2683
|
+
}
|
|
2684
|
+
}, nativeRewriteImports = (content, replacements) => {
|
|
2685
|
+
const lib = loadNative();
|
|
2686
|
+
if (!lib)
|
|
2687
|
+
return null;
|
|
2688
|
+
const jsonStr = JSON.stringify(replacements);
|
|
2689
|
+
const contentBuf = Buffer.from(content);
|
|
2690
|
+
const jsonBuf = Buffer.from(jsonStr);
|
|
2691
|
+
const outBuf = Buffer.alloc(content.length * 2);
|
|
2692
|
+
const outLenBuf = new BigUint64Array([BigInt(outBuf.length)]);
|
|
2693
|
+
const result = lib.rewrite_imports(ptr(contentBuf), contentBuf.length, ptr(jsonBuf), jsonBuf.length, ptr(outBuf), ptr(new Uint8Array(outLenBuf.buffer)));
|
|
2694
|
+
if (result < 0)
|
|
2695
|
+
return null;
|
|
2696
|
+
if (result === 0)
|
|
2697
|
+
return content;
|
|
2698
|
+
const outLen = Number(outLenBuf[0]);
|
|
2699
|
+
return outBuf.subarray(0, outLen).toString("utf-8");
|
|
2700
|
+
};
|
|
2701
|
+
var init_nativeRewrite = __esm(() => {
|
|
2702
|
+
ffiDefinition = {
|
|
2703
|
+
rewrite_imports: {
|
|
2704
|
+
args: [
|
|
2705
|
+
FFIType.ptr,
|
|
2706
|
+
FFIType.u64,
|
|
2707
|
+
FFIType.ptr,
|
|
2708
|
+
FFIType.u64,
|
|
2709
|
+
FFIType.ptr,
|
|
2710
|
+
FFIType.ptr
|
|
2711
|
+
],
|
|
2712
|
+
returns: FFIType.i32
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
});
|
|
2716
|
+
|
|
2717
|
+
// src/build/rewriteImportsPlugin.ts
|
|
2718
|
+
var exports_rewriteImportsPlugin = {};
|
|
2719
|
+
__export(exports_rewriteImportsPlugin, {
|
|
2720
|
+
rewriteVendorDirectories: () => rewriteVendorDirectories,
|
|
2721
|
+
rewriteImportsInContent: () => rewriteImportsInContent,
|
|
2722
|
+
rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
|
|
2723
|
+
rewriteBuildOutputs: () => rewriteBuildOutputs,
|
|
2724
|
+
jsRewriteImports: () => jsRewriteImports,
|
|
2725
|
+
fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
|
|
2726
|
+
buildWithImportRewrite: () => buildWithImportRewrite
|
|
2727
|
+
});
|
|
2728
|
+
import { readdir as readdir2 } from "fs/promises";
|
|
2729
|
+
import { join as join4 } from "path";
|
|
2730
|
+
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
2731
|
+
let result = content;
|
|
2732
|
+
for (const [specifier, webPath] of replacements) {
|
|
2733
|
+
const escaped = escapeRegex(specifier);
|
|
2734
|
+
const fromRegex = new RegExp(`(from\\s*["'])${escaped}(["'])`, "g");
|
|
2735
|
+
const sideEffectRegex = new RegExp(`(import\\s*["'])${escaped}(["'])`, "g");
|
|
2736
|
+
const dynamicRegex = new RegExp(`(import\\s*\\(\\s*["'])${escaped}(["']\\s*\\))`, "g");
|
|
2737
|
+
result = result.replace(fromRegex, `$1${webPath}$2`);
|
|
2738
|
+
result = result.replace(sideEffectRegex, `$1${webPath}$2`);
|
|
2739
|
+
result = result.replace(dynamicRegex, `$1${webPath}$2`);
|
|
2740
|
+
}
|
|
2741
|
+
return result;
|
|
2742
|
+
}, rewriteImportsInContent = (content, vendorPaths) => {
|
|
2743
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
2744
|
+
return content;
|
|
2745
|
+
const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
|
|
2746
|
+
const { masked, restore } = maskLiterals(content);
|
|
2747
|
+
const native = nativeRewriteImports(masked, replacements);
|
|
2748
|
+
return restore(native ?? jsRewriteImports(masked, replacements));
|
|
2749
|
+
}, fixMissingReExportNamespacesInContent = (content) => {
|
|
2750
|
+
const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
|
|
2751
|
+
REEXPORT_PATTERN.lastIndex = 0;
|
|
2752
|
+
const missing = [];
|
|
2753
|
+
let match;
|
|
2754
|
+
while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
|
|
2755
|
+
const ident = match[1];
|
|
2756
|
+
if (!ident)
|
|
2757
|
+
continue;
|
|
2758
|
+
const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
|
|
2759
|
+
if (nsImportRe.test(content))
|
|
2760
|
+
continue;
|
|
2761
|
+
const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
|
|
2762
|
+
if (declRe.test(content))
|
|
2763
|
+
continue;
|
|
2764
|
+
const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
|
|
2765
|
+
if (namedImportRe.test(content))
|
|
2766
|
+
continue;
|
|
2767
|
+
const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
|
|
2768
|
+
let pathMatch;
|
|
2769
|
+
let sourcePath;
|
|
2770
|
+
while ((pathMatch = importPathRe.exec(content)) !== null) {
|
|
2771
|
+
const p = pathMatch[1];
|
|
2772
|
+
if (!p)
|
|
2773
|
+
continue;
|
|
2774
|
+
const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
|
|
2775
|
+
if (!base)
|
|
2776
|
+
continue;
|
|
2777
|
+
const normalized = base.startsWith("_") ? base.slice(1) : base;
|
|
2778
|
+
if (normalized === ident || normalized.endsWith(`_${ident}`)) {
|
|
2779
|
+
sourcePath = p;
|
|
2780
|
+
break;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
if (sourcePath)
|
|
2784
|
+
missing.push({ ident, path: sourcePath });
|
|
2785
|
+
}
|
|
2786
|
+
if (missing.length === 0)
|
|
2787
|
+
return content;
|
|
2788
|
+
const seen = new Set;
|
|
2789
|
+
const unique = missing.filter((entry) => {
|
|
2790
|
+
if (seen.has(entry.ident))
|
|
2791
|
+
return false;
|
|
2792
|
+
seen.add(entry.ident);
|
|
2793
|
+
return true;
|
|
2794
|
+
});
|
|
2795
|
+
const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
|
|
2796
|
+
`);
|
|
2797
|
+
return `${inserts}
|
|
2798
|
+
${content}`;
|
|
2799
|
+
}, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
|
|
2800
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
2801
|
+
return;
|
|
2802
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
2803
|
+
let original;
|
|
2804
|
+
try {
|
|
2805
|
+
original = await artifact.text();
|
|
2806
|
+
} catch (err) {
|
|
2807
|
+
const code = err.code;
|
|
2808
|
+
if (code === "ENOENT")
|
|
2809
|
+
return;
|
|
2810
|
+
throw err;
|
|
2811
|
+
}
|
|
2812
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
2813
|
+
if (rewritten === original)
|
|
2814
|
+
return;
|
|
2815
|
+
try {
|
|
2816
|
+
await Bun.write(artifact.path, rewritten);
|
|
2817
|
+
} catch (err) {
|
|
2818
|
+
const code = err.code;
|
|
2819
|
+
if (code === "ENOENT")
|
|
2820
|
+
return;
|
|
2821
|
+
throw err;
|
|
2822
|
+
}
|
|
2823
|
+
}));
|
|
2824
|
+
}, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
|
|
2825
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
2826
|
+
const vendorPaths = resolveVendorPaths(artifact);
|
|
2827
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
2828
|
+
return;
|
|
2829
|
+
let original;
|
|
2830
|
+
try {
|
|
2831
|
+
original = await artifact.text();
|
|
2832
|
+
} catch (err) {
|
|
2833
|
+
const code = err.code;
|
|
2834
|
+
if (code === "ENOENT")
|
|
2835
|
+
return;
|
|
2836
|
+
throw err;
|
|
2837
|
+
}
|
|
2838
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
2839
|
+
if (rewritten === original)
|
|
2840
|
+
return;
|
|
2841
|
+
try {
|
|
2842
|
+
await Bun.write(artifact.path, rewritten);
|
|
2843
|
+
} catch (err) {
|
|
2844
|
+
const code = err.code;
|
|
2845
|
+
if (code === "ENOENT")
|
|
2846
|
+
return;
|
|
2847
|
+
throw err;
|
|
2848
|
+
}
|
|
2849
|
+
}));
|
|
2850
|
+
}, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
|
|
2851
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
2852
|
+
return;
|
|
2853
|
+
const allFiles = [];
|
|
2854
|
+
for (const dir of vendorDirs) {
|
|
2855
|
+
try {
|
|
2856
|
+
const entries = await readdir2(dir);
|
|
2857
|
+
for (const entry of entries) {
|
|
2858
|
+
if (entry.endsWith(".js"))
|
|
2859
|
+
allFiles.push(join4(dir, entry));
|
|
2860
|
+
}
|
|
2861
|
+
} catch {}
|
|
2862
|
+
}
|
|
2863
|
+
await Promise.all(allFiles.map(async (filePath) => {
|
|
2864
|
+
let original;
|
|
2865
|
+
try {
|
|
2866
|
+
original = await Bun.file(filePath).text();
|
|
2867
|
+
} catch (err) {
|
|
2868
|
+
const code = err.code;
|
|
2869
|
+
if (code === "ENOENT")
|
|
2870
|
+
return;
|
|
2871
|
+
throw err;
|
|
2872
|
+
}
|
|
2873
|
+
let next = rewriteImportsInContent(original, vendorPaths);
|
|
2874
|
+
next = fixMissingReExportNamespacesInContent(next);
|
|
2875
|
+
if (next === original)
|
|
2876
|
+
return;
|
|
2877
|
+
try {
|
|
2878
|
+
await Bun.write(filePath, next);
|
|
2879
|
+
} catch (err) {
|
|
2880
|
+
const code = err.code;
|
|
2881
|
+
if (code === "ENOENT")
|
|
2882
|
+
return;
|
|
2883
|
+
throw err;
|
|
2884
|
+
}
|
|
2885
|
+
}));
|
|
2886
|
+
}, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
|
|
2887
|
+
const result = await pendingBuild;
|
|
2888
|
+
if (result.outputs.length > 0) {
|
|
2889
|
+
await rewriteBuildOutputs(result.outputs, vendorPaths);
|
|
2890
|
+
}
|
|
2891
|
+
return result;
|
|
2892
|
+
};
|
|
2893
|
+
var init_rewriteImportsPlugin = __esm(() => {
|
|
2894
|
+
init_maskLiterals();
|
|
2895
|
+
init_nativeRewrite();
|
|
2896
|
+
});
|
|
2897
|
+
|
|
2898
|
+
// src/core/angularServerModule.ts
|
|
2899
|
+
import { mkdir } from "fs/promises";
|
|
2900
|
+
import { dirname as dirname4, join as join5, relative } from "path";
|
|
2901
|
+
var serverCacheRoot, compiledModuleCache, ANGULAR_SPECIFIER_RE, getCachedModulePath = (sourcePath) => {
|
|
2902
|
+
const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2903
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2904
|
+
return join5(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
2905
|
+
}, collectVendorPaths = (code) => {
|
|
2906
|
+
const vendorPaths = {};
|
|
2907
|
+
if (!isProductionRuntime()) {
|
|
2908
|
+
return vendorPaths;
|
|
2909
|
+
}
|
|
2910
|
+
const specifiers = new Set([...code.matchAll(ANGULAR_SPECIFIER_RE)].map((match) => match[1]));
|
|
2911
|
+
specifiers.forEach((specifier) => {
|
|
2912
|
+
if (!specifier)
|
|
2913
|
+
return;
|
|
2914
|
+
const resolved = resolveAngularRuntimePath(specifier);
|
|
2915
|
+
if (resolved === specifier)
|
|
2916
|
+
return;
|
|
2917
|
+
vendorPaths[specifier] = resolved;
|
|
2918
|
+
});
|
|
2919
|
+
return vendorPaths;
|
|
2920
|
+
}, buildAngularServerModule = async (sourcePath) => {
|
|
2921
|
+
const result = await Bun.build({
|
|
2922
|
+
entrypoints: [sourcePath],
|
|
2923
|
+
format: "esm",
|
|
2924
|
+
packages: "external",
|
|
2925
|
+
target: "bun",
|
|
2926
|
+
throw: false
|
|
2927
|
+
});
|
|
2928
|
+
const entry = result.outputs.find((output) => output.kind === "entry-point");
|
|
2929
|
+
if (!result.success || !entry) {
|
|
2930
|
+
const message = result.logs.map((log2) => String(log2)).join(`
|
|
2931
|
+
`);
|
|
2932
|
+
throw new Error(`Failed to compile Angular island server module for "${sourcePath}":
|
|
2933
|
+
${message}`);
|
|
2934
|
+
}
|
|
2935
|
+
const code = await entry.text();
|
|
2936
|
+
const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
|
|
2937
|
+
const modulePath = getCachedModulePath(sourcePath);
|
|
2938
|
+
await mkdir(dirname4(modulePath), { recursive: true });
|
|
2939
|
+
await Bun.write(modulePath, rewritten);
|
|
2940
|
+
return modulePath;
|
|
2941
|
+
}, compileAngularServerModule = (sourcePath) => {
|
|
2942
|
+
const cached = compiledModuleCache.get(sourcePath);
|
|
2943
|
+
if (cached) {
|
|
2944
|
+
return cached;
|
|
2945
|
+
}
|
|
2946
|
+
const compiledModulePromise = buildAngularServerModule(sourcePath);
|
|
2947
|
+
compiledModuleCache.set(sourcePath, compiledModulePromise);
|
|
2948
|
+
return compiledModulePromise;
|
|
2949
|
+
};
|
|
2950
|
+
var init_angularServerModule = __esm(() => {
|
|
2951
|
+
init_resolveAngularPackage();
|
|
2952
|
+
init_rewriteImportsPlugin();
|
|
2953
|
+
serverCacheRoot = join5(process.cwd(), ".absolutejs", "islands", "angular");
|
|
2954
|
+
compiledModuleCache = new Map;
|
|
2955
|
+
ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
|
|
1884
2956
|
});
|
|
1885
2957
|
|
|
1886
2958
|
// src/build/resolvePackageImport.ts
|
|
1887
|
-
import { resolve as
|
|
2959
|
+
import { resolve as resolve5, join as join6 } from "path";
|
|
1888
2960
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
1889
2961
|
var resolveExportPath = (entry, conditions) => {
|
|
1890
2962
|
if (typeof entry === "string")
|
|
@@ -1906,11 +2978,11 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
1906
2978
|
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
1907
2979
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
1908
2980
|
const exportKey = subpath ? `./${subpath}` : ".";
|
|
1909
|
-
const currentPackageJsonPath =
|
|
2981
|
+
const currentPackageJsonPath = resolve5(process.cwd(), "package.json");
|
|
1910
2982
|
const currentPackageJson = existsSync5(currentPackageJsonPath) ? JSON.parse(readFileSync4(currentPackageJsonPath, "utf-8")) : null;
|
|
1911
2983
|
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
1912
|
-
const packageDir = currentPackageDir ??
|
|
1913
|
-
const packageJsonPath =
|
|
2984
|
+
const packageDir = currentPackageDir ?? resolve5(process.cwd(), "node_modules", packageName ?? "");
|
|
2985
|
+
const packageJsonPath = join6(packageDir, "package.json");
|
|
1914
2986
|
if (!existsSync5(packageJsonPath))
|
|
1915
2987
|
return null;
|
|
1916
2988
|
try {
|
|
@@ -1925,12 +2997,12 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
1925
2997
|
if (!importPath)
|
|
1926
2998
|
return null;
|
|
1927
2999
|
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
1928
|
-
const sourceCandidate =
|
|
3000
|
+
const sourceCandidate = resolve5(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
1929
3001
|
if (existsSync5(sourceCandidate)) {
|
|
1930
3002
|
return sourceCandidate;
|
|
1931
3003
|
}
|
|
1932
3004
|
}
|
|
1933
|
-
const resolved =
|
|
3005
|
+
const resolved = resolve5(packageDir, importPath);
|
|
1934
3006
|
return existsSync5(resolved) ? resolved : null;
|
|
1935
3007
|
} catch {
|
|
1936
3008
|
return null;
|
|
@@ -2082,17 +3154,17 @@ __export(exports_stylePreprocessor, {
|
|
|
2082
3154
|
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded,
|
|
2083
3155
|
addStyleImporter: () => addStyleImporter
|
|
2084
3156
|
});
|
|
2085
|
-
import { createHash } from "crypto";
|
|
3157
|
+
import { createHash as createHash2 } from "crypto";
|
|
2086
3158
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
2087
|
-
import { readFile } from "fs/promises";
|
|
3159
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
2088
3160
|
import { createRequire } from "module";
|
|
2089
3161
|
import {
|
|
2090
|
-
dirname as
|
|
3162
|
+
dirname as dirname5,
|
|
2091
3163
|
extname,
|
|
2092
|
-
isAbsolute,
|
|
2093
|
-
join as
|
|
2094
|
-
relative,
|
|
2095
|
-
resolve as
|
|
3164
|
+
isAbsolute as isAbsolute2,
|
|
3165
|
+
join as join7,
|
|
3166
|
+
relative as relative2,
|
|
3167
|
+
resolve as resolve6
|
|
2096
3168
|
} from "path";
|
|
2097
3169
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
2098
3170
|
var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
@@ -2128,9 +3200,9 @@ ${message}`);
|
|
|
2128
3200
|
return requireOptionalPeer(specifier);
|
|
2129
3201
|
}
|
|
2130
3202
|
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
2131
|
-
|
|
3203
|
+
dirname5(filePath),
|
|
2132
3204
|
process.cwd(),
|
|
2133
|
-
...paths.map((path) =>
|
|
3205
|
+
...paths.map((path) => resolve6(process.cwd(), path))
|
|
2134
3206
|
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
2135
3207
|
pattern,
|
|
2136
3208
|
replacements: Array.isArray(value) ? value : [value]
|
|
@@ -2138,7 +3210,7 @@ ${message}`);
|
|
|
2138
3210
|
const cwd = process.cwd();
|
|
2139
3211
|
if (tsconfigAliasCache?.cwd === cwd)
|
|
2140
3212
|
return tsconfigAliasCache;
|
|
2141
|
-
const tsconfigPath =
|
|
3213
|
+
const tsconfigPath = resolve6(cwd, "tsconfig.json");
|
|
2142
3214
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
2143
3215
|
if (!existsSync6(tsconfigPath)) {
|
|
2144
3216
|
tsconfigAliasCache = empty;
|
|
@@ -2147,7 +3219,7 @@ ${message}`);
|
|
|
2147
3219
|
try {
|
|
2148
3220
|
const parsed = JSON.parse(stripJsonComments(readFileSync5(tsconfigPath, "utf-8")));
|
|
2149
3221
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
2150
|
-
const baseUrl =
|
|
3222
|
+
const baseUrl = resolve6(cwd, compilerOptions.baseUrl ?? ".");
|
|
2151
3223
|
tsconfigAliasCache = {
|
|
2152
3224
|
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
2153
3225
|
baseUrl,
|
|
@@ -2175,7 +3247,7 @@ ${message}`);
|
|
|
2175
3247
|
continue;
|
|
2176
3248
|
const wildcard = match[1] ?? "";
|
|
2177
3249
|
for (const replacement of alias.replacements) {
|
|
2178
|
-
targets.push(
|
|
3250
|
+
targets.push(resolve6(baseUrl, replacement.replace("*", wildcard)));
|
|
2179
3251
|
}
|
|
2180
3252
|
}
|
|
2181
3253
|
return targets;
|
|
@@ -2189,21 +3261,21 @@ ${message}`);
|
|
|
2189
3261
|
const ext = extname(basePath);
|
|
2190
3262
|
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
2191
3263
|
`${basePath}${extension}`,
|
|
2192
|
-
|
|
3264
|
+
join7(basePath, `index${extension}`)
|
|
2193
3265
|
]);
|
|
2194
3266
|
if (language === "scss" || language === "sass") {
|
|
2195
3267
|
return paths.flatMap((path) => {
|
|
2196
|
-
const dir =
|
|
3268
|
+
const dir = dirname5(path);
|
|
2197
3269
|
const base = path.slice(dir.length + 1);
|
|
2198
|
-
return [path,
|
|
3270
|
+
return [path, join7(dir, `_${base}`)];
|
|
2199
3271
|
});
|
|
2200
3272
|
}
|
|
2201
3273
|
return paths;
|
|
2202
3274
|
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
2203
3275
|
const rawCandidates = [
|
|
2204
3276
|
...resolveAliasTargets(specifier, config),
|
|
2205
|
-
|
|
2206
|
-
...loadPaths.map((path) =>
|
|
3277
|
+
isAbsolute2(specifier) ? specifier : resolve6(fromDirectory, specifier),
|
|
3278
|
+
...loadPaths.map((path) => resolve6(path, specifier))
|
|
2207
3279
|
];
|
|
2208
3280
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
2209
3281
|
if (existsSync6(candidate))
|
|
@@ -2219,8 +3291,8 @@ ${message}`);
|
|
|
2219
3291
|
path: url.slice(0, markerIndex)
|
|
2220
3292
|
};
|
|
2221
3293
|
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
2222
|
-
const sourceDir =
|
|
2223
|
-
const entryDir =
|
|
3294
|
+
const sourceDir = dirname5(sourceFile);
|
|
3295
|
+
const entryDir = dirname5(entryFile);
|
|
2224
3296
|
if (sourceDir === entryDir)
|
|
2225
3297
|
return contents;
|
|
2226
3298
|
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
@@ -2228,15 +3300,15 @@ ${message}`);
|
|
|
2228
3300
|
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
2229
3301
|
return match;
|
|
2230
3302
|
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
2231
|
-
const rebased =
|
|
3303
|
+
const rebased = relative2(entryDir, resolve6(sourceDir, path)).replace(/\\/g, "/");
|
|
2232
3304
|
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
2233
3305
|
const nextQuote = quote || '"';
|
|
2234
3306
|
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
2235
3307
|
});
|
|
2236
3308
|
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
2237
|
-
if (specifier.startsWith(".") ||
|
|
3309
|
+
if (specifier.startsWith(".") || isAbsolute2(specifier) || isExternalCssUrl(specifier))
|
|
2238
3310
|
return match;
|
|
2239
|
-
const resolved = resolveImportPath(specifier,
|
|
3311
|
+
const resolved = resolveImportPath(specifier, dirname5(sourceFile), loadPaths, language, config);
|
|
2240
3312
|
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
2241
3313
|
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
2242
3314
|
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
@@ -2266,7 +3338,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2266
3338
|
}
|
|
2267
3339
|
return mod;
|
|
2268
3340
|
}, loadPostcssConfigFile = async (configPath2) => {
|
|
2269
|
-
const resolved =
|
|
3341
|
+
const resolved = resolve6(process.cwd(), configPath2);
|
|
2270
3342
|
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
2271
3343
|
const config = normalizePostcssModule(loaded);
|
|
2272
3344
|
const value = typeof config === "function" ? await config({
|
|
@@ -2326,9 +3398,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2326
3398
|
return result.css;
|
|
2327
3399
|
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
2328
3400
|
canonicalize(specifier, options) {
|
|
2329
|
-
const fromDirectory = options.containingUrl ?
|
|
3401
|
+
const fromDirectory = options.containingUrl ? dirname5(fileURLToPath(options.containingUrl)) : dirname5(entryFile);
|
|
2330
3402
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
2331
|
-
return resolved ? new URL(pathToFileURL(
|
|
3403
|
+
return resolved ? new URL(pathToFileURL(resolve6(resolved)).href) : null;
|
|
2332
3404
|
},
|
|
2333
3405
|
load(canonicalUrl) {
|
|
2334
3406
|
const filePath = fileURLToPath(canonicalUrl);
|
|
@@ -2345,15 +3417,15 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2345
3417
|
install(less, pluginManager) {
|
|
2346
3418
|
const baseManager = new less.FileManager;
|
|
2347
3419
|
const manager = Object.create(baseManager);
|
|
2348
|
-
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename,
|
|
3420
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve6(currentDirectory), loadPaths, "less", config));
|
|
2349
3421
|
manager.loadFile = async (filename, currentDirectory) => {
|
|
2350
|
-
const resolved = resolveImportPath(filename,
|
|
3422
|
+
const resolved = resolveImportPath(filename, resolve6(currentDirectory), loadPaths, "less", config);
|
|
2351
3423
|
if (!resolved) {
|
|
2352
3424
|
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
2353
3425
|
}
|
|
2354
3426
|
deps?.add(resolved);
|
|
2355
3427
|
return {
|
|
2356
|
-
contents: preprocessLoadedStyle(await
|
|
3428
|
+
contents: preprocessLoadedStyle(await readFile2(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
2357
3429
|
filename: resolved
|
|
2358
3430
|
};
|
|
2359
3431
|
};
|
|
@@ -2384,29 +3456,29 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2384
3456
|
const stylusDeps = renderer.deps?.();
|
|
2385
3457
|
if (Array.isArray(stylusDeps)) {
|
|
2386
3458
|
for (const dep of stylusDeps)
|
|
2387
|
-
deps.add(
|
|
3459
|
+
deps.add(resolve6(dep));
|
|
2388
3460
|
}
|
|
2389
3461
|
}
|
|
2390
3462
|
resolveCss(css ?? "");
|
|
2391
3463
|
});
|
|
2392
3464
|
});
|
|
2393
3465
|
}, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
|
|
2394
|
-
const key =
|
|
3466
|
+
const key = resolve6(entry);
|
|
2395
3467
|
const stripped = new Set;
|
|
2396
3468
|
for (const dep of deps) {
|
|
2397
|
-
const resolved =
|
|
3469
|
+
const resolved = resolve6(dep);
|
|
2398
3470
|
if (resolved !== key)
|
|
2399
3471
|
stripped.add(resolved);
|
|
2400
3472
|
}
|
|
2401
3473
|
styleDependencyGraph.set(key, stripped);
|
|
2402
3474
|
}, addStyleImporter = (importerPath, stylePath) => {
|
|
2403
|
-
const key =
|
|
2404
|
-
const target =
|
|
3475
|
+
const key = resolve6(importerPath);
|
|
3476
|
+
const target = resolve6(stylePath);
|
|
2405
3477
|
const deps = styleDependencyGraph.get(key) ?? new Set;
|
|
2406
3478
|
deps.add(target);
|
|
2407
3479
|
styleDependencyGraph.set(key, deps);
|
|
2408
3480
|
}, findStyleEntriesImporting = (changedPath) => {
|
|
2409
|
-
const target =
|
|
3481
|
+
const target = resolve6(changedPath);
|
|
2410
3482
|
const importers = [];
|
|
2411
3483
|
for (const [entry, deps] of styleDependencyGraph) {
|
|
2412
3484
|
if (deps.has(target))
|
|
@@ -2414,18 +3486,18 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2414
3486
|
}
|
|
2415
3487
|
return importers;
|
|
2416
3488
|
}, recordStyleOutput = (entry, css) => {
|
|
2417
|
-
const key =
|
|
2418
|
-
const hash =
|
|
3489
|
+
const key = resolve6(entry);
|
|
3490
|
+
const hash = createHash2("sha1").update(css).digest("hex");
|
|
2419
3491
|
const previous = styleOutputHashes.get(key);
|
|
2420
3492
|
styleOutputHashes.set(key, hash);
|
|
2421
3493
|
return previous !== hash;
|
|
2422
3494
|
}, forgetStyleEntry = (entry) => {
|
|
2423
|
-
const key =
|
|
3495
|
+
const key = resolve6(entry);
|
|
2424
3496
|
styleDependencyGraph.delete(key);
|
|
2425
3497
|
styleOutputHashes.delete(key);
|
|
2426
3498
|
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
2427
3499
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2428
|
-
const rawContents = source ?? await
|
|
3500
|
+
const rawContents = source ?? await readFile2(filePath, "utf-8");
|
|
2429
3501
|
const deps = new Set;
|
|
2430
3502
|
if (language === "scss" || language === "sass") {
|
|
2431
3503
|
const options = getSassOptions(config, language);
|
|
@@ -2446,7 +3518,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2446
3518
|
loadPaths,
|
|
2447
3519
|
style: "expanded",
|
|
2448
3520
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2449
|
-
url: new URL(pathToFileURL(
|
|
3521
|
+
url: new URL(pathToFileURL(resolve6(filePath)).href)
|
|
2450
3522
|
});
|
|
2451
3523
|
const css = await runPostcss(result.css, filePath, config);
|
|
2452
3524
|
const loadedUrls = result.loadedUrls ?? [];
|
|
@@ -2454,7 +3526,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2454
3526
|
if (url.protocol !== "file:")
|
|
2455
3527
|
continue;
|
|
2456
3528
|
const dep = fileURLToPath(url);
|
|
2457
|
-
if (
|
|
3529
|
+
if (resolve6(dep) === resolve6(filePath))
|
|
2458
3530
|
continue;
|
|
2459
3531
|
deps.add(dep);
|
|
2460
3532
|
}
|
|
@@ -2575,7 +3647,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2575
3647
|
const start = match.index ?? 0;
|
|
2576
3648
|
const end = start + match[0].length;
|
|
2577
3649
|
parts.push(content.slice(cursor, start));
|
|
2578
|
-
const fullPath =
|
|
3650
|
+
const fullPath = isAbsolute2(importPath) ? importPath : resolve6(baseDir, importPath);
|
|
2579
3651
|
if (visited.has(fullPath) || !existsSync6(fullPath)) {
|
|
2580
3652
|
parts.push(visited.has(fullPath) ? "" : match[0]);
|
|
2581
3653
|
cursor = end;
|
|
@@ -2583,23 +3655,23 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2583
3655
|
}
|
|
2584
3656
|
const nextVisited = new Set(visited);
|
|
2585
3657
|
nextVisited.add(fullPath);
|
|
2586
|
-
const imported = await
|
|
2587
|
-
parts.push(await resolveCssImportsAsync(imported,
|
|
3658
|
+
const imported = await readFile2(fullPath, "utf-8");
|
|
3659
|
+
parts.push(await resolveCssImportsAsync(imported, dirname5(fullPath), nextVisited));
|
|
2588
3660
|
cursor = end;
|
|
2589
3661
|
}
|
|
2590
3662
|
parts.push(content.slice(cursor));
|
|
2591
3663
|
return parts.join("");
|
|
2592
3664
|
}, compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2593
3665
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2594
|
-
const raw = await
|
|
3666
|
+
const raw = await readFile2(filePath, "utf-8");
|
|
2595
3667
|
const processed = await runPostcss(raw, filePath, config);
|
|
2596
|
-
return resolveCssImportsAsync(processed,
|
|
3668
|
+
return resolveCssImportsAsync(processed, dirname5(filePath), new Set([filePath]));
|
|
2597
3669
|
}
|
|
2598
3670
|
const compiled = await compileStyleSource(filePath, undefined, undefined, config);
|
|
2599
|
-
return resolveCssImportsAsync(compiled,
|
|
3671
|
+
return resolveCssImportsAsync(compiled, dirname5(filePath), new Set([filePath]));
|
|
2600
3672
|
}, resolveCssImportsSync = (content, baseDir, visited) => {
|
|
2601
3673
|
return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
|
|
2602
|
-
const fullPath =
|
|
3674
|
+
const fullPath = isAbsolute2(importPath) ? importPath : resolve6(baseDir, importPath);
|
|
2603
3675
|
if (visited.has(fullPath))
|
|
2604
3676
|
return "";
|
|
2605
3677
|
if (!existsSync6(fullPath))
|
|
@@ -2607,7 +3679,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2607
3679
|
const nextVisited = new Set(visited);
|
|
2608
3680
|
nextVisited.add(fullPath);
|
|
2609
3681
|
const imported = readFileSync5(fullPath, "utf-8");
|
|
2610
|
-
return resolveCssImportsSync(imported,
|
|
3682
|
+
return resolveCssImportsSync(imported, dirname5(fullPath), nextVisited);
|
|
2611
3683
|
});
|
|
2612
3684
|
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
2613
3685
|
const rawContents = readFileSync5(filePath, "utf-8");
|
|
@@ -2633,18 +3705,18 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2633
3705
|
loadPaths,
|
|
2634
3706
|
style: "expanded",
|
|
2635
3707
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2636
|
-
url: new URL(pathToFileURL(
|
|
3708
|
+
url: new URL(pathToFileURL(resolve6(filePath)).href)
|
|
2637
3709
|
});
|
|
2638
3710
|
const loadedUrls = result.loadedUrls ?? [];
|
|
2639
3711
|
for (const url of loadedUrls) {
|
|
2640
3712
|
if (url.protocol !== "file:")
|
|
2641
3713
|
continue;
|
|
2642
3714
|
const dep = fileURLToPath(url);
|
|
2643
|
-
if (
|
|
3715
|
+
if (resolve6(dep) === resolve6(filePath))
|
|
2644
3716
|
continue;
|
|
2645
3717
|
addStyleImporter(filePath, dep);
|
|
2646
3718
|
}
|
|
2647
|
-
return resolveCssImportsSync(result.css,
|
|
3719
|
+
return resolveCssImportsSync(result.css, dirname5(filePath), new Set([filePath]));
|
|
2648
3720
|
}
|
|
2649
3721
|
if (language === "less") {
|
|
2650
3722
|
throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
@@ -2652,7 +3724,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
2652
3724
|
if (language === "stylus") {
|
|
2653
3725
|
throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
2654
3726
|
}
|
|
2655
|
-
return resolveCssImportsSync(rawContents,
|
|
3727
|
+
return resolveCssImportsSync(rawContents, dirname5(filePath), new Set([filePath]));
|
|
2656
3728
|
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
2657
3729
|
var init_stylePreprocessor = __esm(() => {
|
|
2658
3730
|
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
@@ -2661,7 +3733,7 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
2661
3733
|
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2662
3734
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2663
3735
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2664
|
-
requireFromCwd = createRequire(
|
|
3736
|
+
requireFromCwd = createRequire(join7(process.cwd(), "package.json"));
|
|
2665
3737
|
styleDependencyGraph = new Map;
|
|
2666
3738
|
styleOutputHashes = new Map;
|
|
2667
3739
|
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
@@ -2669,14 +3741,14 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
2669
3741
|
});
|
|
2670
3742
|
|
|
2671
3743
|
// src/core/svelteServerModule.ts
|
|
2672
|
-
import { mkdir, readdir as
|
|
2673
|
-
import { basename as
|
|
2674
|
-
var
|
|
2675
|
-
const importPath =
|
|
3744
|
+
import { mkdir as mkdir2, readdir as readdir3 } from "fs/promises";
|
|
3745
|
+
import { basename as basename4, dirname as dirname6, extname as extname2, join as join8, relative as relative3, resolve as resolve7 } from "path";
|
|
3746
|
+
var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
3747
|
+
const importPath = relative3(dirname6(from), target).replace(/\\/g, "/");
|
|
2676
3748
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2677
3749
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2678
3750
|
for (const entry of entries) {
|
|
2679
|
-
const entryPath =
|
|
3751
|
+
const entryPath = join8(dir, entry.name);
|
|
2680
3752
|
if (entry.isDirectory())
|
|
2681
3753
|
stack.push(entryPath);
|
|
2682
3754
|
if (entry.isFile() && entry.name === targetFileName) {
|
|
@@ -2690,7 +3762,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2690
3762
|
const nextStack = [];
|
|
2691
3763
|
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
2692
3764
|
dir,
|
|
2693
|
-
entries: await
|
|
3765
|
+
entries: await readdir3(dir, {
|
|
2694
3766
|
encoding: "utf-8",
|
|
2695
3767
|
withFileTypes: true
|
|
2696
3768
|
})
|
|
@@ -2701,16 +3773,16 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2701
3773
|
return found;
|
|
2702
3774
|
}
|
|
2703
3775
|
return searchDirectoryLevel(nextStack, targetFileName);
|
|
2704
|
-
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) =>
|
|
3776
|
+
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename4(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
2705
3777
|
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
2706
3778
|
if (cachedPath !== undefined) {
|
|
2707
3779
|
return cachedPath;
|
|
2708
3780
|
}
|
|
2709
|
-
if (!sourcePath.includes(`${
|
|
3781
|
+
if (!sourcePath.includes(`${join8(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
2710
3782
|
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
2711
3783
|
return sourcePath;
|
|
2712
3784
|
}
|
|
2713
|
-
const resolvedSourcePath = await findSourceFileByBasename(
|
|
3785
|
+
const resolvedSourcePath = await findSourceFileByBasename(join8(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
2714
3786
|
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
2715
3787
|
originalSourcePathCache.set(sourcePath, nextPath);
|
|
2716
3788
|
return nextPath;
|
|
@@ -2718,7 +3790,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2718
3790
|
if (!spec.startsWith(".")) {
|
|
2719
3791
|
return null;
|
|
2720
3792
|
}
|
|
2721
|
-
const basePath =
|
|
3793
|
+
const basePath = resolve7(dirname6(from), spec);
|
|
2722
3794
|
const candidates = [
|
|
2723
3795
|
basePath,
|
|
2724
3796
|
`${basePath}.ts`,
|
|
@@ -2726,19 +3798,19 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2726
3798
|
`${basePath}.mjs`,
|
|
2727
3799
|
`${basePath}.cjs`,
|
|
2728
3800
|
`${basePath}.json`,
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
3801
|
+
join8(basePath, "index.ts"),
|
|
3802
|
+
join8(basePath, "index.js"),
|
|
3803
|
+
join8(basePath, "index.mjs"),
|
|
3804
|
+
join8(basePath, "index.cjs"),
|
|
3805
|
+
join8(basePath, "index.json")
|
|
2734
3806
|
];
|
|
2735
3807
|
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
2736
3808
|
const foundIndex = existResults.indexOf(true);
|
|
2737
3809
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
2738
|
-
},
|
|
2739
|
-
const relativeSourcePath =
|
|
3810
|
+
}, getCachedModulePath2 = (sourcePath) => {
|
|
3811
|
+
const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2740
3812
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2741
|
-
return
|
|
3813
|
+
return join8(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
|
|
2742
3814
|
}, resolveSvelteImport = async (spec, from) => {
|
|
2743
3815
|
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
2744
3816
|
const resolved = resolvePackageImport(spec);
|
|
@@ -2750,7 +3822,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2750
3822
|
if (!spec.startsWith(".")) {
|
|
2751
3823
|
return null;
|
|
2752
3824
|
}
|
|
2753
|
-
const explicitPath =
|
|
3825
|
+
const explicitPath = resolve7(dirname6(from), spec);
|
|
2754
3826
|
if (extname2(explicitPath) === ".svelte") {
|
|
2755
3827
|
return explicitPath;
|
|
2756
3828
|
}
|
|
@@ -2770,7 +3842,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2770
3842
|
}
|
|
2771
3843
|
await Bun.write(path, content);
|
|
2772
3844
|
}, compileSvelteServerModule = async (sourcePath) => {
|
|
2773
|
-
const cachedModulePath =
|
|
3845
|
+
const cachedModulePath = compiledModuleCache2.get(sourcePath);
|
|
2774
3846
|
if (cachedModulePath) {
|
|
2775
3847
|
return cachedModulePath;
|
|
2776
3848
|
}
|
|
@@ -2809,7 +3881,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2809
3881
|
continue;
|
|
2810
3882
|
if (resolvedChildModules[index])
|
|
2811
3883
|
continue;
|
|
2812
|
-
rewrittenModulePaths.set(spec, ensureRelativeImportPath(
|
|
3884
|
+
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
|
|
2813
3885
|
}
|
|
2814
3886
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
2815
3887
|
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
@@ -2823,15 +3895,15 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2823
3895
|
generate: "server"
|
|
2824
3896
|
}).js.code;
|
|
2825
3897
|
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
2826
|
-
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(
|
|
3898
|
+
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
|
|
2827
3899
|
}
|
|
2828
3900
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
2829
3901
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
2830
3902
|
}
|
|
2831
|
-
const compiledModulePath =
|
|
2832
|
-
await
|
|
3903
|
+
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
3904
|
+
await mkdir2(dirname6(compiledModulePath), { recursive: true });
|
|
2833
3905
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
2834
|
-
|
|
3906
|
+
compiledModuleCache2.set(sourcePath, compiledModulePath);
|
|
2835
3907
|
return compiledModulePath;
|
|
2836
3908
|
};
|
|
2837
3909
|
var init_svelteServerModule = __esm(() => {
|
|
@@ -2839,8 +3911,8 @@ var init_svelteServerModule = __esm(() => {
|
|
|
2839
3911
|
init_lowerIslandSyntax();
|
|
2840
3912
|
init_lowerAwaitSlotSyntax();
|
|
2841
3913
|
init_stylePreprocessor();
|
|
2842
|
-
|
|
2843
|
-
|
|
3914
|
+
serverCacheRoot2 = join8(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
3915
|
+
compiledModuleCache2 = new Map;
|
|
2844
3916
|
originalSourcePathCache = new Map;
|
|
2845
3917
|
transpiler = new Bun.Transpiler({
|
|
2846
3918
|
loader: "ts",
|
|
@@ -2848,18 +3920,31 @@ var init_svelteServerModule = __esm(() => {
|
|
|
2848
3920
|
});
|
|
2849
3921
|
});
|
|
2850
3922
|
|
|
3923
|
+
// src/utils/vueCompiler.ts
|
|
3924
|
+
var createVueCompiler = async () => {
|
|
3925
|
+
const [compiler, typescript] = await Promise.all([
|
|
3926
|
+
import("@vue/compiler-sfc"),
|
|
3927
|
+
import("typescript")
|
|
3928
|
+
]);
|
|
3929
|
+
compiler.registerTS?.(() => typescript);
|
|
3930
|
+
return compiler;
|
|
3931
|
+
}, compilerPromise, loadVueCompiler = () => {
|
|
3932
|
+
compilerPromise ??= createVueCompiler();
|
|
3933
|
+
return compilerPromise;
|
|
3934
|
+
};
|
|
3935
|
+
|
|
2851
3936
|
// src/core/vueServerModule.ts
|
|
2852
3937
|
import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync } from "fs";
|
|
2853
|
-
import { mkdir as
|
|
2854
|
-
import { dirname as
|
|
3938
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
3939
|
+
import { dirname as dirname7, join as join9, relative as relative4, resolve as resolve8 } from "path";
|
|
2855
3940
|
var {Transpiler } = globalThis.Bun;
|
|
2856
|
-
var ISLAND_COMPONENT_ID_LENGTH = 8,
|
|
2857
|
-
const importPath =
|
|
3941
|
+
var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
|
|
3942
|
+
const importPath = relative4(dirname7(from), target).replace(/\\/g, "/");
|
|
2858
3943
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2859
|
-
},
|
|
2860
|
-
const relativeSourcePath =
|
|
3944
|
+
}, getCachedModulePath3 = (sourcePath) => {
|
|
3945
|
+
const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2861
3946
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2862
|
-
return
|
|
3947
|
+
return join9(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
|
|
2863
3948
|
}, writeIfChanged2 = async (path, content) => {
|
|
2864
3949
|
const targetFile = Bun.file(path);
|
|
2865
3950
|
if (await targetFile.exists()) {
|
|
@@ -2886,10 +3971,10 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
2886
3971
|
`) : nonVueLines.join(`
|
|
2887
3972
|
`);
|
|
2888
3973
|
}, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
|
|
2889
|
-
const cachedModulePath =
|
|
3974
|
+
const cachedModulePath = compiledModuleCache3.get(sourcePath);
|
|
2890
3975
|
if (cachedModulePath)
|
|
2891
3976
|
return cachedModulePath;
|
|
2892
|
-
const compiler = await
|
|
3977
|
+
const compiler = await loadVueCompiler();
|
|
2893
3978
|
const source = await Bun.file(sourcePath).text();
|
|
2894
3979
|
const { descriptor } = compiler.parse(source, { filename: sourcePath });
|
|
2895
3980
|
const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
|
|
@@ -2897,8 +3982,8 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
2897
3982
|
const compiledScript = hasScript ? compiler.compileScript(descriptor, {
|
|
2898
3983
|
fs: {
|
|
2899
3984
|
fileExists: existsSync7,
|
|
2900
|
-
|
|
2901
|
-
|
|
3985
|
+
realpath: realpathSync,
|
|
3986
|
+
readFile: (file) => existsSync7(file) ? readFileSync6(file, "utf-8") : undefined
|
|
2902
3987
|
},
|
|
2903
3988
|
id: componentId,
|
|
2904
3989
|
inlineTemplate: false
|
|
@@ -2919,7 +4004,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
2919
4004
|
}).code : "const ssrRender = () => {};";
|
|
2920
4005
|
const childImportPaths = extractRelativeVueImports(compiledScript.content);
|
|
2921
4006
|
const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
|
|
2922
|
-
compiledPath: await compileVueServerModule(
|
|
4007
|
+
compiledPath: await compileVueServerModule(resolve8(dirname7(sourcePath), relativeImport)),
|
|
2923
4008
|
spec: relativeImport
|
|
2924
4009
|
})));
|
|
2925
4010
|
const strippedScript = stripExports(compiledScript.content);
|
|
@@ -2931,20 +4016,20 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
2931
4016
|
"export default script;"
|
|
2932
4017
|
].join(`
|
|
2933
4018
|
`));
|
|
2934
|
-
const compiledModulePath =
|
|
4019
|
+
const compiledModulePath = getCachedModulePath3(sourcePath);
|
|
2935
4020
|
let rewritten = assembled;
|
|
2936
4021
|
for (const child of compiledChildren) {
|
|
2937
4022
|
rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
|
|
2938
4023
|
}
|
|
2939
|
-
await
|
|
4024
|
+
await mkdir3(dirname7(compiledModulePath), { recursive: true });
|
|
2940
4025
|
await writeIfChanged2(compiledModulePath, rewritten);
|
|
2941
|
-
|
|
4026
|
+
compiledModuleCache3.set(sourcePath, compiledModulePath);
|
|
2942
4027
|
return compiledModulePath;
|
|
2943
4028
|
};
|
|
2944
4029
|
var init_vueServerModule = __esm(() => {
|
|
2945
4030
|
init_constants();
|
|
2946
|
-
|
|
2947
|
-
|
|
4031
|
+
serverCacheRoot3 = join9(process.cwd(), ".absolutejs", "islands", "vue");
|
|
4032
|
+
compiledModuleCache3 = new Map;
|
|
2948
4033
|
transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
|
|
2949
4034
|
});
|
|
2950
4035
|
|
|
@@ -3026,8 +4111,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
3026
4111
|
throw new Error("Resolved Vue island is not a valid Vue component.");
|
|
3027
4112
|
}
|
|
3028
4113
|
return resolvedComponent;
|
|
4114
|
+
}, loadAngularServerBuildComponent = async (buildReferencePath, exportName) => {
|
|
4115
|
+
const serverModulePath = await compileAngularServerModule(buildReferencePath);
|
|
4116
|
+
const loadedModule = await import(serverModulePath);
|
|
4117
|
+
if (exportName && exportName !== "default" && exportName in loadedModule) {
|
|
4118
|
+
return loadedModule[exportName];
|
|
4119
|
+
}
|
|
4120
|
+
return "default" in loadedModule ? loadedModule.default : loadedModule;
|
|
3029
4121
|
}, resolveAngularServerIslandComponent = async (component) => {
|
|
3030
|
-
const
|
|
4122
|
+
const buildReference = getIslandBuildReference(component);
|
|
4123
|
+
const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
|
|
4124
|
+
const resolvedComponent = buildReferencePath ? await loadAngularServerBuildComponent(buildReferencePath, buildReference?.export) : await resolveServerIslandComponent(component);
|
|
3031
4125
|
if (!isAngularServerIslandComponent(resolvedComponent)) {
|
|
3032
4126
|
throw new Error("Resolved Angular island is not a valid Angular component.");
|
|
3033
4127
|
}
|
|
@@ -3083,6 +4177,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
3083
4177
|
};
|
|
3084
4178
|
var init_renderIslandMarkup = __esm(() => {
|
|
3085
4179
|
init_islandSsr();
|
|
4180
|
+
init_angularServerModule();
|
|
3086
4181
|
init_svelteServerModule();
|
|
3087
4182
|
init_vueServerModule();
|
|
3088
4183
|
init_islandMarkupAttributes();
|
|
@@ -3617,12 +4712,11 @@ var registerStreamSlotForSsr = (props) => {
|
|
|
3617
4712
|
});
|
|
3618
4713
|
};
|
|
3619
4714
|
// src/vue/pageHandler.ts
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
4715
|
+
init_inlinePageCss();
|
|
4716
|
+
init_spaRouteCss();
|
|
4717
|
+
init_spaRouteManifest();
|
|
3623
4718
|
|
|
3624
4719
|
// src/core/islandPageContext.ts
|
|
3625
|
-
init_constants();
|
|
3626
4720
|
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
|
|
3627
4721
|
var ISLAND_MARKER = 'data-island="true"';
|
|
3628
4722
|
var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
|
|
@@ -3743,61 +4837,69 @@ var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
|
3743
4837
|
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
3744
4838
|
const encoder = new TextEncoder;
|
|
3745
4839
|
const decoder = new TextDecoder;
|
|
3746
|
-
const
|
|
3747
|
-
const
|
|
3748
|
-
if (
|
|
3749
|
-
controller.enqueue(encoder.encode(
|
|
3750
|
-
return { injected, pending: "" };
|
|
4840
|
+
const headLookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
4841
|
+
const enqueue = (controller, text) => {
|
|
4842
|
+
if (text.length > 0) {
|
|
4843
|
+
controller.enqueue(encoder.encode(text));
|
|
3751
4844
|
}
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
3757
|
-
controller.enqueue(encoder.encode(next));
|
|
3758
|
-
return { injected: true, pending: "" };
|
|
4845
|
+
};
|
|
4846
|
+
const processHolding = (controller, held) => {
|
|
4847
|
+
if (!held.includes(ISLAND_MARKER)) {
|
|
4848
|
+
return { held, injected: false, pending: "", sawHead: true };
|
|
3759
4849
|
}
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
3763
|
-
};
|
|
4850
|
+
enqueue(controller, `${markup}${held}`);
|
|
4851
|
+
return { held: "", injected: true, pending: "", sawHead: true };
|
|
3764
4852
|
};
|
|
3765
|
-
const
|
|
3766
|
-
const
|
|
3767
|
-
if (
|
|
3768
|
-
|
|
4853
|
+
const processHead = (controller, pending) => {
|
|
4854
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
4855
|
+
if (headIndex < 0) {
|
|
4856
|
+
return {
|
|
4857
|
+
held: "",
|
|
4858
|
+
injected: false,
|
|
4859
|
+
pending: flushSafePendingText(controller, encoder, pending, headLookbehind),
|
|
4860
|
+
sawHead: false
|
|
4861
|
+
};
|
|
3769
4862
|
}
|
|
3770
|
-
controller.
|
|
4863
|
+
enqueue(controller, pending.slice(0, headIndex));
|
|
4864
|
+
return processHolding(controller, pending.slice(headIndex));
|
|
3771
4865
|
};
|
|
3772
|
-
const
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
return
|
|
4866
|
+
const processChunk = (controller, state, chunk) => {
|
|
4867
|
+
if (state.injected) {
|
|
4868
|
+
enqueue(controller, chunk);
|
|
4869
|
+
return state;
|
|
3776
4870
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
pending: processed.pending
|
|
3782
|
-
};
|
|
4871
|
+
if (!state.sawHead) {
|
|
4872
|
+
return processHead(controller, state.pending + chunk);
|
|
4873
|
+
}
|
|
4874
|
+
return processHolding(controller, state.held + chunk);
|
|
3783
4875
|
};
|
|
3784
|
-
const
|
|
3785
|
-
const
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4876
|
+
const finishMarkerStream = (controller, state) => {
|
|
4877
|
+
const tail = decoder.decode();
|
|
4878
|
+
const remainder = state.injected ? tail : (state.sawHead ? state.held : state.pending) + tail;
|
|
4879
|
+
enqueue(controller, remainder);
|
|
4880
|
+
controller.close();
|
|
4881
|
+
};
|
|
4882
|
+
const runMarkerLoop = (controller, reader) => {
|
|
4883
|
+
const consumeNext = async (state) => {
|
|
4884
|
+
const { done, value } = await readStreamChunk(reader);
|
|
4885
|
+
if (done || !value) {
|
|
4886
|
+
return state;
|
|
3790
4887
|
}
|
|
3791
|
-
return
|
|
4888
|
+
return consumeNext(processChunk(controller, state, streamChunkToString(value, decoder)));
|
|
3792
4889
|
};
|
|
3793
|
-
return
|
|
4890
|
+
return consumeNext({
|
|
4891
|
+
held: "",
|
|
4892
|
+
injected: false,
|
|
4893
|
+
pending: "",
|
|
4894
|
+
sawHead: false
|
|
4895
|
+
});
|
|
3794
4896
|
};
|
|
3795
4897
|
return new ReadableStream({
|
|
3796
4898
|
async start(controller) {
|
|
3797
4899
|
const reader = stream.getReader();
|
|
3798
4900
|
try {
|
|
3799
|
-
const
|
|
3800
|
-
|
|
4901
|
+
const finalState = await runMarkerLoop(controller, reader);
|
|
4902
|
+
finishMarkerStream(controller, finalState);
|
|
3801
4903
|
} catch (error) {
|
|
3802
4904
|
controller.error(error);
|
|
3803
4905
|
}
|
|
@@ -3835,9 +4937,11 @@ var setCurrentIslandManifest = (manifest) => {
|
|
|
3835
4937
|
|
|
3836
4938
|
// src/vue/pageHandler.ts
|
|
3837
4939
|
init_devRouteRegistrationCallsite();
|
|
4940
|
+
init_pageResponseCache();
|
|
3838
4941
|
|
|
3839
4942
|
// src/core/responseEnhancers.ts
|
|
3840
4943
|
init_streamingSlots();
|
|
4944
|
+
init_pageResponseCache();
|
|
3841
4945
|
var toResponse = async (responseLike) => responseLike;
|
|
3842
4946
|
var cloneHeaders = (response) => {
|
|
3843
4947
|
const headers = new Headers(response.headers);
|
|
@@ -3861,8 +4965,10 @@ var enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
|
3861
4965
|
runtimePlacement,
|
|
3862
4966
|
runtimePreludeScript
|
|
3863
4967
|
});
|
|
4968
|
+
const headers = cloneHeaders(response);
|
|
4969
|
+
headers.set(STREAMING_PAGE_HEADER, "1");
|
|
3864
4970
|
return new Response(body, {
|
|
3865
|
-
headers
|
|
4971
|
+
headers,
|
|
3866
4972
|
status: response.status,
|
|
3867
4973
|
statusText: response.statusText
|
|
3868
4974
|
});
|
|
@@ -3876,368 +4982,114 @@ var mergeStreamingSlots = (registered, explicit) => {
|
|
|
3876
4982
|
merged.set(slot.id, slot);
|
|
3877
4983
|
return [...merged.values()];
|
|
3878
4984
|
};
|
|
3879
|
-
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
3880
|
-
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
3881
|
-
const explicit = options.streamingSlots ?? [];
|
|
3882
|
-
return withStreamingSlots(result, {
|
|
3883
|
-
...options,
|
|
3884
|
-
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
3885
|
-
});
|
|
3886
|
-
};
|
|
3887
|
-
|
|
3888
|
-
// src/core/streamingSlotWarningScope.ts
|
|
3889
|
-
init_logger();
|
|
3890
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3891
|
-
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
3892
|
-
var isObjectRecord5 = (value) => Boolean(value) && typeof value === "object";
|
|
3893
|
-
var isAsyncLocalStorage3 = (value) => isObjectRecord5(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
3894
|
-
var getWarningStorage = () => {
|
|
3895
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
3896
|
-
if (value === null || typeof value === "undefined") {
|
|
3897
|
-
return;
|
|
3898
|
-
}
|
|
3899
|
-
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
3900
|
-
};
|
|
3901
|
-
var ensureWarningStorage = () => {
|
|
3902
|
-
const existing = getWarningStorage();
|
|
3903
|
-
if (existing) {
|
|
3904
|
-
return existing;
|
|
3905
|
-
}
|
|
3906
|
-
const storage = new AsyncLocalStorage2;
|
|
3907
|
-
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
3908
|
-
return storage;
|
|
3909
|
-
};
|
|
3910
|
-
var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
|
|
3911
|
-
var formatWarningCallsite = (callsite) => {
|
|
3912
|
-
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
3913
|
-
if (!match) {
|
|
3914
|
-
return `\x1B[36m${callsite}\x1B[0m`;
|
|
3915
|
-
}
|
|
3916
|
-
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
3917
|
-
};
|
|
3918
|
-
var shouldIgnoreWarningFrame = (frame) => frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/react/pageHandler.") || frame.includes("/src/vue/pageHandler.") || frame.includes("/src/svelte/pageHandler.") || frame.includes("/src/angular/pageHandler.") || frame.includes("/src/core/streamingSlotWarningScope.");
|
|
3919
|
-
var getWarningLocation = (frame) => frame.match(/\((\/[^)]+:\d+:\d+)\)$/)?.[1] ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/)?.[1];
|
|
3920
|
-
var extractCallsiteFromStack = (stack) => {
|
|
3921
|
-
const location = stack.split(`
|
|
3922
|
-
`).slice(1).map((line) => line.trim()).filter((frame) => !shouldIgnoreWarningFrame(frame)).map((frame) => getWarningLocation(frame)).find((frameLocation) => frameLocation !== undefined);
|
|
3923
|
-
return location ? normalizeCallsitePath2(location) : undefined;
|
|
3924
|
-
};
|
|
3925
|
-
var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
|
|
3926
|
-
setStreamingSlotWarningController({
|
|
3927
|
-
maybeWarn: (primitiveName) => {
|
|
3928
|
-
const store = getWarningStorage()?.getStore();
|
|
3929
|
-
if (!store || store.hasWarned) {
|
|
3930
|
-
return;
|
|
3931
|
-
}
|
|
3932
|
-
store.hasWarned = true;
|
|
3933
|
-
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
3934
|
-
}
|
|
3935
|
-
});
|
|
3936
|
-
var captureStreamingSlotWarningCallsite = () => {
|
|
3937
|
-
if (false) {}
|
|
3938
|
-
const { stack } = new Error;
|
|
3939
|
-
if (!stack) {
|
|
3940
|
-
return;
|
|
3941
|
-
}
|
|
3942
|
-
return extractCallsiteFromStack(stack);
|
|
3943
|
-
};
|
|
3944
|
-
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
3945
|
-
// src/utils/resolveConvention.ts
|
|
3946
|
-
import { basename } from "path";
|
|
3947
|
-
var CONVENTIONS_KEY = "__absoluteConventions";
|
|
3948
|
-
var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
|
|
3949
|
-
var getMap = () => {
|
|
3950
|
-
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
3951
|
-
if (isConventionsMap(value))
|
|
3952
|
-
return value;
|
|
3953
|
-
const empty = {};
|
|
3954
|
-
return empty;
|
|
3955
|
-
};
|
|
3956
|
-
var derivePageName = (pagePath) => {
|
|
3957
|
-
const base = basename(pagePath);
|
|
3958
|
-
const dotIndex = base.indexOf(".");
|
|
3959
|
-
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
3960
|
-
return toPascal(name);
|
|
3961
|
-
};
|
|
3962
|
-
var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
|
|
3963
|
-
var resolveErrorConventionPath = (framework, pageName) => {
|
|
3964
|
-
const conventions = getMap()[framework];
|
|
3965
|
-
if (!conventions)
|
|
3966
|
-
return;
|
|
3967
|
-
const exact = conventions.pages?.[pageName]?.error;
|
|
3968
|
-
if (exact)
|
|
3969
|
-
return exact;
|
|
3970
|
-
const normalizedPageName = normalizeConventionPageName(pageName);
|
|
3971
|
-
for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
|
|
3972
|
-
if (normalizeConventionPageName(candidate) === normalizedPageName) {
|
|
3973
|
-
return page.error ?? conventions.defaults?.error;
|
|
3974
|
-
}
|
|
3975
|
-
}
|
|
3976
|
-
return conventions.defaults?.error;
|
|
3977
|
-
};
|
|
3978
|
-
var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
|
|
3979
|
-
var hasErrorConvention = (framework) => {
|
|
3980
|
-
const conventions = getMap()[framework];
|
|
3981
|
-
if (!conventions)
|
|
3982
|
-
return false;
|
|
3983
|
-
if (conventions.defaults?.error)
|
|
3984
|
-
return true;
|
|
3985
|
-
return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
|
|
3986
|
-
};
|
|
3987
|
-
var setConventions = (map) => {
|
|
3988
|
-
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
3989
|
-
};
|
|
3990
|
-
var isDev = () => true;
|
|
3991
|
-
var buildErrorProps = (error) => {
|
|
3992
|
-
if (error instanceof Error) {
|
|
3993
|
-
return {
|
|
3994
|
-
name: error.name,
|
|
3995
|
-
message: error.message,
|
|
3996
|
-
...isDev() && error.stack ? { stack: error.stack } : {}
|
|
3997
|
-
};
|
|
3998
|
-
}
|
|
3999
|
-
return { name: "Error", message: String(error) };
|
|
4000
|
-
};
|
|
4001
|
-
var renderReactError = async (conventionPath, errorProps) => {
|
|
4002
|
-
const { createElement } = await import("react");
|
|
4003
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
4004
|
-
const mod = await import(conventionPath);
|
|
4005
|
-
const ErrorComponent = mod.default;
|
|
4006
|
-
if (typeof ErrorComponent !== "function")
|
|
4007
|
-
return null;
|
|
4008
|
-
const element = createElement(ErrorComponent, errorProps);
|
|
4009
|
-
const stream = await renderToReadableStream(element);
|
|
4010
|
-
return new Response(stream, {
|
|
4011
|
-
headers: { "Content-Type": "text/html" },
|
|
4012
|
-
status: 500
|
|
4013
|
-
});
|
|
4014
|
-
};
|
|
4015
|
-
var renderSvelteError = async (conventionPath, errorProps) => {
|
|
4016
|
-
const { render } = await import("svelte/server");
|
|
4017
|
-
const mod = await import(conventionPath);
|
|
4018
|
-
const ErrorComponent = mod.default;
|
|
4019
|
-
if (!ErrorComponent)
|
|
4020
|
-
return null;
|
|
4021
|
-
const { head, body } = render(ErrorComponent, {
|
|
4022
|
-
props: errorProps
|
|
4023
|
-
});
|
|
4024
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
4025
|
-
return new Response(html, {
|
|
4026
|
-
headers: { "Content-Type": "text/html" },
|
|
4027
|
-
status: 500
|
|
4028
|
-
});
|
|
4029
|
-
};
|
|
4030
|
-
var unescapeVueStyles = (ssrBody) => {
|
|
4031
|
-
let styles = "";
|
|
4032
|
-
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
4033
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
4034
|
-
return "";
|
|
4035
|
-
});
|
|
4036
|
-
return { body, styles };
|
|
4037
|
-
};
|
|
4038
|
-
var renderVueError = async (conventionPath, errorProps) => {
|
|
4039
|
-
const { createSSRApp, h: h4 } = await import("vue");
|
|
4040
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
4041
|
-
const mod = await import(conventionPath);
|
|
4042
|
-
const ErrorComponent = mod.default;
|
|
4043
|
-
if (!ErrorComponent)
|
|
4044
|
-
return null;
|
|
4045
|
-
const app = createSSRApp({
|
|
4046
|
-
render: () => h4(ErrorComponent, errorProps)
|
|
4047
|
-
});
|
|
4048
|
-
const rawBody = await renderToString(app);
|
|
4049
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
4050
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
4051
|
-
return new Response(html, {
|
|
4052
|
-
headers: { "Content-Type": "text/html" },
|
|
4053
|
-
status: 500
|
|
4054
|
-
});
|
|
4055
|
-
};
|
|
4056
|
-
var renderAngularError = async (conventionPath, errorProps) => {
|
|
4057
|
-
const mod = await import(conventionPath);
|
|
4058
|
-
const renderFn = mod.default;
|
|
4059
|
-
if (typeof renderFn !== "function")
|
|
4060
|
-
return null;
|
|
4061
|
-
const html = renderFn(errorProps);
|
|
4062
|
-
return new Response(html, {
|
|
4063
|
-
headers: { "Content-Type": "text/html" },
|
|
4064
|
-
status: 500
|
|
4065
|
-
});
|
|
4066
|
-
};
|
|
4067
|
-
var escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4068
|
-
var replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : "");
|
|
4069
|
-
var renderHtmlError = async (conventionPath, errorProps) => {
|
|
4070
|
-
const template = await Bun.file(conventionPath).text();
|
|
4071
|
-
const html = replaceErrorTokens(template, errorProps);
|
|
4072
|
-
return new Response(html, {
|
|
4073
|
-
headers: { "Content-Type": "text/html" },
|
|
4074
|
-
status: 500
|
|
4985
|
+
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
4986
|
+
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
4987
|
+
const explicit = options.streamingSlots ?? [];
|
|
4988
|
+
return withStreamingSlots(result, {
|
|
4989
|
+
...options,
|
|
4990
|
+
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
4075
4991
|
});
|
|
4076
4992
|
};
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4993
|
+
|
|
4994
|
+
// src/core/streamingSlotWarningScope.ts
|
|
4995
|
+
init_logger();
|
|
4996
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
4997
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
4998
|
+
var isObjectRecord5 = (value) => Boolean(value) && typeof value === "object";
|
|
4999
|
+
var isAsyncLocalStorage3 = (value) => isObjectRecord5(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
5000
|
+
var getWarningStorage = () => {
|
|
5001
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
5002
|
+
if (value === null || typeof value === "undefined") {
|
|
4081
5003
|
return;
|
|
4082
5004
|
}
|
|
4083
|
-
|
|
4084
|
-
};
|
|
4085
|
-
var renderEmberError = async () => null;
|
|
4086
|
-
var renderEmberNotFound = async () => null;
|
|
4087
|
-
var ERROR_RENDERERS = {
|
|
4088
|
-
angular: renderAngularError,
|
|
4089
|
-
ember: renderEmberError,
|
|
4090
|
-
html: renderHtmlError,
|
|
4091
|
-
react: renderReactError,
|
|
4092
|
-
svelte: renderSvelteError,
|
|
4093
|
-
vue: renderVueError
|
|
5005
|
+
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
4094
5006
|
};
|
|
4095
|
-
var
|
|
4096
|
-
|
|
4097
|
-
if (
|
|
4098
|
-
|
|
4099
|
-
const candidate = match[1];
|
|
4100
|
-
if (!candidate)
|
|
4101
|
-
continue;
|
|
4102
|
-
conventionPath = resolveErrorConventionPath(framework, candidate);
|
|
4103
|
-
if (conventionPath)
|
|
4104
|
-
break;
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4107
|
-
if (!conventionPath)
|
|
4108
|
-
return null;
|
|
4109
|
-
const renderer = ERROR_RENDERERS[framework];
|
|
4110
|
-
if (!renderer)
|
|
4111
|
-
return null;
|
|
4112
|
-
try {
|
|
4113
|
-
return await renderer(conventionPath, errorProps);
|
|
4114
|
-
} catch (renderError) {
|
|
4115
|
-
logConventionRenderError(framework, "error", renderError);
|
|
5007
|
+
var ensureWarningStorage = () => {
|
|
5008
|
+
const existing = getWarningStorage();
|
|
5009
|
+
if (existing) {
|
|
5010
|
+
return existing;
|
|
4116
5011
|
}
|
|
4117
|
-
|
|
5012
|
+
const storage = new AsyncLocalStorage2;
|
|
5013
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
5014
|
+
return storage;
|
|
4118
5015
|
};
|
|
4119
|
-
var
|
|
4120
|
-
|
|
4121
|
-
const
|
|
4122
|
-
if (
|
|
4123
|
-
return
|
|
4124
|
-
if (framework !== "html") {
|
|
4125
|
-
const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
|
|
4126
|
-
if (htmlResponse)
|
|
4127
|
-
return htmlResponse;
|
|
5016
|
+
var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
|
|
5017
|
+
var formatWarningCallsite = (callsite) => {
|
|
5018
|
+
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
5019
|
+
if (!match) {
|
|
5020
|
+
return `\x1B[36m${callsite}\x1B[0m`;
|
|
4128
5021
|
}
|
|
4129
|
-
return
|
|
4130
|
-
};
|
|
4131
|
-
var renderReactNotFound = async (conventionPath) => {
|
|
4132
|
-
const { createElement } = await import("react");
|
|
4133
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
4134
|
-
const mod = await import(conventionPath);
|
|
4135
|
-
const NotFoundComponent = mod.default;
|
|
4136
|
-
if (typeof NotFoundComponent !== "function")
|
|
4137
|
-
return null;
|
|
4138
|
-
const element = createElement(NotFoundComponent);
|
|
4139
|
-
const stream = await renderToReadableStream(element);
|
|
4140
|
-
return new Response(stream, {
|
|
4141
|
-
headers: { "Content-Type": "text/html" },
|
|
4142
|
-
status: 404
|
|
4143
|
-
});
|
|
4144
|
-
};
|
|
4145
|
-
var renderSvelteNotFound = async (conventionPath) => {
|
|
4146
|
-
const { render } = await import("svelte/server");
|
|
4147
|
-
const mod = await import(conventionPath);
|
|
4148
|
-
const NotFoundComponent = mod.default;
|
|
4149
|
-
if (!NotFoundComponent)
|
|
4150
|
-
return null;
|
|
4151
|
-
const { head, body } = render(NotFoundComponent);
|
|
4152
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
4153
|
-
return new Response(html, {
|
|
4154
|
-
headers: { "Content-Type": "text/html" },
|
|
4155
|
-
status: 404
|
|
4156
|
-
});
|
|
4157
|
-
};
|
|
4158
|
-
var renderVueNotFound = async (conventionPath) => {
|
|
4159
|
-
const { createSSRApp, h: h4 } = await import("vue");
|
|
4160
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
4161
|
-
const mod = await import(conventionPath);
|
|
4162
|
-
const NotFoundComponent = mod.default;
|
|
4163
|
-
if (!NotFoundComponent)
|
|
4164
|
-
return null;
|
|
4165
|
-
const app = createSSRApp({
|
|
4166
|
-
render: () => h4(NotFoundComponent)
|
|
4167
|
-
});
|
|
4168
|
-
const rawBody = await renderToString(app);
|
|
4169
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
4170
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
4171
|
-
return new Response(html, {
|
|
4172
|
-
headers: { "Content-Type": "text/html" },
|
|
4173
|
-
status: 404
|
|
4174
|
-
});
|
|
4175
|
-
};
|
|
4176
|
-
var renderAngularNotFound = async (conventionPath) => {
|
|
4177
|
-
const mod = await import(conventionPath);
|
|
4178
|
-
const renderFn = mod.default;
|
|
4179
|
-
if (typeof renderFn !== "function")
|
|
4180
|
-
return null;
|
|
4181
|
-
const html = renderFn();
|
|
4182
|
-
return new Response(html, {
|
|
4183
|
-
headers: { "Content-Type": "text/html" },
|
|
4184
|
-
status: 404
|
|
4185
|
-
});
|
|
5022
|
+
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
4186
5023
|
};
|
|
4187
|
-
var
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
5024
|
+
var shouldIgnoreWarningFrame = (frame) => frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/react/pageHandler.") || frame.includes("/src/vue/pageHandler.") || frame.includes("/src/svelte/pageHandler.") || frame.includes("/src/angular/pageHandler.") || frame.includes("/src/core/streamingSlotWarningScope.");
|
|
5025
|
+
var getWarningLocation = (frame) => frame.match(/\((\/[^)]+:\d+:\d+)\)$/)?.[1] ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/)?.[1];
|
|
5026
|
+
var extractCallsiteFromStack = (stack) => {
|
|
5027
|
+
const location = stack.split(`
|
|
5028
|
+
`).slice(1).map((line) => line.trim()).filter((frame) => !shouldIgnoreWarningFrame(frame)).map((frame) => getWarningLocation(frame)).find((frameLocation) => frameLocation !== undefined);
|
|
5029
|
+
return location ? normalizeCallsitePath2(location) : undefined;
|
|
4193
5030
|
};
|
|
4194
|
-
var
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
5031
|
+
var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
|
|
5032
|
+
setStreamingSlotWarningController({
|
|
5033
|
+
maybeWarn: (primitiveName) => {
|
|
5034
|
+
const store = getWarningStorage()?.getStore();
|
|
5035
|
+
if (!store || store.hasWarned) {
|
|
5036
|
+
return;
|
|
5037
|
+
}
|
|
5038
|
+
store.hasWarned = true;
|
|
5039
|
+
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
5040
|
+
}
|
|
5041
|
+
});
|
|
5042
|
+
var captureStreamingSlotWarningCallsite = () => {
|
|
5043
|
+
if (false) {}
|
|
5044
|
+
const { stack } = new Error;
|
|
5045
|
+
if (!stack) {
|
|
5046
|
+
return;
|
|
5047
|
+
}
|
|
5048
|
+
return extractCallsiteFromStack(stack);
|
|
4201
5049
|
};
|
|
4202
|
-
var
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
5050
|
+
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
5051
|
+
|
|
5052
|
+
// src/vue/pageHandler.ts
|
|
5053
|
+
init_resolveConvention();
|
|
5054
|
+
|
|
5055
|
+
// src/vue/resolveGeneratedVueModulePath.ts
|
|
5056
|
+
init_constants();
|
|
5057
|
+
import { access, readdir, stat } from "fs/promises";
|
|
5058
|
+
import { basename as basename3, dirname as dirname2 } from "path";
|
|
5059
|
+
var canAccess = async (path) => {
|
|
4209
5060
|
try {
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
5061
|
+
await access(path);
|
|
5062
|
+
return true;
|
|
5063
|
+
} catch {
|
|
5064
|
+
return false;
|
|
4213
5065
|
}
|
|
4214
|
-
return null;
|
|
4215
5066
|
};
|
|
4216
|
-
var
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
"
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
const
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
return renderNext(remaining);
|
|
4237
|
-
};
|
|
4238
|
-
return renderNext(NOT_FOUND_PRIORITY);
|
|
5067
|
+
var resolveGeneratedVueModulePath = async (pagePath) => {
|
|
5068
|
+
if (await canAccess(pagePath))
|
|
5069
|
+
return pagePath;
|
|
5070
|
+
const pageDirectory = dirname2(pagePath);
|
|
5071
|
+
const expectedPrefix = `${basename3(pagePath, ".js").split(".")[0]}.`;
|
|
5072
|
+
try {
|
|
5073
|
+
const pageEntries = await readdir(pageDirectory, {
|
|
5074
|
+
withFileTypes: true
|
|
5075
|
+
});
|
|
5076
|
+
const matchingEntries = pageEntries.filter((entry) => entry.isFile() && entry.name.endsWith(".js") && (entry.name === `${expectedPrefix.slice(0, EXCLUDE_LAST_OFFSET)}.js` || entry.name.startsWith(expectedPrefix)));
|
|
5077
|
+
const candidates = await Promise.all(matchingEntries.map(async (entry) => {
|
|
5078
|
+
const path = `${pageDirectory}/${entry.name}`;
|
|
5079
|
+
const metadata = await stat(path);
|
|
5080
|
+
return { modifiedAt: metadata.mtimeMs, path };
|
|
5081
|
+
}));
|
|
5082
|
+
candidates.sort((left, right) => right.modifiedAt - left.modifiedAt || left.path.localeCompare(right.path));
|
|
5083
|
+
return candidates[0]?.path ?? pagePath;
|
|
5084
|
+
} catch {
|
|
5085
|
+
return pagePath;
|
|
5086
|
+
}
|
|
4239
5087
|
};
|
|
4240
5088
|
|
|
5089
|
+
// src/vue/teleports.ts
|
|
5090
|
+
var ABSOLUTE_TELEPORT_TARGET_ID = "absolute-teleports";
|
|
5091
|
+
var ABSOLUTE_TELEPORT_TARGET = `#${ABSOLUTE_TELEPORT_TARGET_ID}`;
|
|
5092
|
+
|
|
4241
5093
|
// src/vue/pageHandler.ts
|
|
4242
5094
|
var isRecord2 = (value) => typeof value === "object" && value !== null;
|
|
4243
5095
|
var isGenericVueComponent = (value) => typeof value === "function" || isRecord2(value);
|
|
@@ -4247,29 +5099,15 @@ var readHasIslands = (value) => {
|
|
|
4247
5099
|
const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
|
|
4248
5100
|
return typeof hasIslands === "boolean" ? hasIslands : false;
|
|
4249
5101
|
};
|
|
5102
|
+
var isVueSetupApp = (value) => typeof value === "function";
|
|
4250
5103
|
var readSetupAppHook = (value) => {
|
|
4251
5104
|
if (!isRecord2(value))
|
|
4252
5105
|
return null;
|
|
4253
|
-
const setupApp = value
|
|
4254
|
-
return
|
|
5106
|
+
const { setupApp } = value;
|
|
5107
|
+
return isVueSetupApp(setupApp) ? setupApp : null;
|
|
4255
5108
|
};
|
|
5109
|
+
var readHasSpaRoutes = (value) => isRecord2(value) && Array.isArray(value["routes"]);
|
|
4256
5110
|
var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
|
|
4257
|
-
var resolveCurrentGeneratedVueModulePath = async (pagePath) => {
|
|
4258
|
-
const pageDirectory = dirname2(pagePath);
|
|
4259
|
-
const expectedPrefix = `${basename2(pagePath, ".js").split(".")[0]}.`;
|
|
4260
|
-
try {
|
|
4261
|
-
const pageEntries = await readdir(pageDirectory, {
|
|
4262
|
-
withFileTypes: true
|
|
4263
|
-
});
|
|
4264
|
-
const matchingEntry = pageEntries.find((entry) => entry.isFile() && entry.name.endsWith(".js") && (entry.name === `${expectedPrefix.slice(0, EXCLUDE_LAST_OFFSET)}.js` || entry.name.startsWith(expectedPrefix)));
|
|
4265
|
-
if (!matchingEntry) {
|
|
4266
|
-
return pagePath;
|
|
4267
|
-
}
|
|
4268
|
-
return `${pageDirectory}/${matchingEntry.name}`;
|
|
4269
|
-
} catch {
|
|
4270
|
-
return pagePath;
|
|
4271
|
-
}
|
|
4272
|
-
};
|
|
4273
5111
|
var resolveRequestRenderUrl = (request) => {
|
|
4274
5112
|
if (!request)
|
|
4275
5113
|
return "/";
|
|
@@ -4286,40 +5124,53 @@ var primeVueStream = async (stream) => {
|
|
|
4286
5124
|
return { firstChunk, reader };
|
|
4287
5125
|
};
|
|
4288
5126
|
var cachedSsrOnlyHmrShim = null;
|
|
5127
|
+
var buildSsrOnlyHmrShim = async () => {
|
|
5128
|
+
const { buildHMRClient: buildHMRClient2 } = await Promise.resolve().then(() => (init_buildHMRClient(), exports_buildHMRClient));
|
|
5129
|
+
const bundle = await buildHMRClient2();
|
|
5130
|
+
return `<script>window.__HMR_FRAMEWORK__="vue";</script><script data-hmr-client>${bundle}</script>`;
|
|
5131
|
+
};
|
|
4289
5132
|
var getSsrOnlyHmrShim = () => {
|
|
4290
5133
|
if (cachedSsrOnlyHmrShim)
|
|
4291
5134
|
return cachedSsrOnlyHmrShim;
|
|
4292
|
-
cachedSsrOnlyHmrShim = (
|
|
4293
|
-
const { buildHMRClient: buildHMRClient2 } = await Promise.resolve().then(() => (init_buildHMRClient(), exports_buildHMRClient));
|
|
4294
|
-
const bundle = await buildHMRClient2();
|
|
4295
|
-
return `<script>window.__HMR_FRAMEWORK__="vue";</script><script data-hmr-client>${bundle}</script>`;
|
|
4296
|
-
})();
|
|
5135
|
+
cachedSsrOnlyHmrShim = buildSsrOnlyHmrShim();
|
|
4297
5136
|
return cachedSsrOnlyHmrShim;
|
|
4298
5137
|
};
|
|
4299
5138
|
var handleVuePageRequest = async (input) => {
|
|
4300
5139
|
const passedPageComponent = input.Page;
|
|
4301
|
-
const
|
|
5140
|
+
const userHeadTag = input.headTag ?? "<head></head>";
|
|
4302
5141
|
const resolvedOptions = input;
|
|
4303
5142
|
const resolvedPagePath = input.pagePath;
|
|
5143
|
+
const [siblingCss, spaChildCss] = await Promise.all([
|
|
5144
|
+
readSiblingCss(resolvedPagePath),
|
|
5145
|
+
resolveSpaChildCss(resolvedPagePath, input.request?.url)
|
|
5146
|
+
]);
|
|
5147
|
+
const resolvedHeadTag = injectInlineCss(injectInlineCss(userHeadTag, siblingCss), spaChildCss);
|
|
4304
5148
|
const maybeProps = input.props;
|
|
4305
5149
|
const clientMode = input.client ?? "auto";
|
|
4306
5150
|
const resolvedIndexPath = input.indexPath;
|
|
5151
|
+
if (clientMode === "auto" && resolvedIndexPath === "") {
|
|
5152
|
+
throw new Error(`Asset "${derivePageName(resolvedPagePath)}Index" not found in manifest.`);
|
|
5153
|
+
}
|
|
4307
5154
|
if (clientMode === "auto" && !resolvedIndexPath) {
|
|
4308
5155
|
throw new Error('handleVuePageRequest: `indexPath` is required when `client` is `"auto"` (the default). Pass `client: "none"` to ship a SSR-only page with no client bundle.');
|
|
4309
5156
|
}
|
|
4310
5157
|
try {
|
|
5158
|
+
const spaNotFound = await renderSpaNotFound("vue", derivePageName(resolvedPagePath), input.request);
|
|
5159
|
+
if (spaNotFound)
|
|
5160
|
+
return withPageCacheHeaders(spaNotFound, input.request);
|
|
4311
5161
|
const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
4312
5162
|
const renderPageResponse = async () => {
|
|
4313
5163
|
const resolvePageComponent = async () => {
|
|
4314
5164
|
if (isGenericVueComponent(passedPageComponent)) {
|
|
5165
|
+
const setupApp = null;
|
|
4315
5166
|
return {
|
|
4316
5167
|
component: passedPageComponent,
|
|
4317
5168
|
hasIslands: readHasIslands(passedPageComponent),
|
|
4318
|
-
|
|
4319
|
-
setupApp
|
|
5169
|
+
hasSpaRoutes: false,
|
|
5170
|
+
setupApp
|
|
4320
5171
|
};
|
|
4321
5172
|
}
|
|
4322
|
-
const generatedPagePath = await
|
|
5173
|
+
const generatedPagePath = await resolveGeneratedVueModulePath(resolvedPagePath);
|
|
4323
5174
|
const importedPageModule = await import(generatedPagePath);
|
|
4324
5175
|
const importedPageComponent = readDefaultExport(importedPageModule) ?? importedPageModule;
|
|
4325
5176
|
if (!isGenericVueComponent(importedPageComponent)) {
|
|
@@ -4328,28 +5179,31 @@ var handleVuePageRequest = async (input) => {
|
|
|
4328
5179
|
return {
|
|
4329
5180
|
component: importedPageComponent,
|
|
4330
5181
|
hasIslands: readHasIslands(importedPageModule),
|
|
5182
|
+
hasSpaRoutes: readHasSpaRoutes(importedPageModule),
|
|
4331
5183
|
setupApp: readSetupAppHook(importedPageModule)
|
|
4332
5184
|
};
|
|
4333
5185
|
};
|
|
4334
5186
|
const resolvedPage = await resolvePageComponent();
|
|
4335
|
-
const { createSSRApp
|
|
4336
|
-
const { renderToWebStream } = await import("vue/server-renderer");
|
|
4337
|
-
const app = createSSRApp(
|
|
4338
|
-
render: () => h4(resolvedPage.component, maybeProps ?? null)
|
|
4339
|
-
});
|
|
5187
|
+
const { createSSRApp } = await import("vue");
|
|
5188
|
+
const { renderToString, renderToWebStream } = await import("vue/server-renderer");
|
|
5189
|
+
const app = createSSRApp(resolvedPage.component, maybeProps ?? null);
|
|
4340
5190
|
let pendingRedirect = null;
|
|
5191
|
+
let pendingNotFound = false;
|
|
4341
5192
|
if (resolvedPage.setupApp) {
|
|
4342
5193
|
const url = resolveRequestRenderUrl(input.request);
|
|
4343
5194
|
await resolvedPage.setupApp(app, {
|
|
4344
5195
|
isServer: true,
|
|
4345
5196
|
router: null,
|
|
5197
|
+
url,
|
|
5198
|
+
setNotFound: () => {
|
|
5199
|
+
pendingNotFound = true;
|
|
5200
|
+
},
|
|
4346
5201
|
setRedirect: (location, status) => {
|
|
4347
5202
|
pendingRedirect = {
|
|
4348
5203
|
location,
|
|
4349
5204
|
status: status ?? 302
|
|
4350
5205
|
};
|
|
4351
|
-
}
|
|
4352
|
-
url
|
|
5206
|
+
}
|
|
4353
5207
|
});
|
|
4354
5208
|
}
|
|
4355
5209
|
if (pendingRedirect !== null) {
|
|
@@ -4359,11 +5213,33 @@ var handleVuePageRequest = async (input) => {
|
|
|
4359
5213
|
status: redirect.status
|
|
4360
5214
|
});
|
|
4361
5215
|
}
|
|
4362
|
-
|
|
4363
|
-
|
|
5216
|
+
if (pendingNotFound) {
|
|
5217
|
+
return await renderFirstNotFound() ?? new Response("Not found", {
|
|
5218
|
+
headers: { "Content-Type": "text/plain" },
|
|
5219
|
+
status: 404
|
|
5220
|
+
});
|
|
5221
|
+
}
|
|
5222
|
+
const ssrContext = {};
|
|
4364
5223
|
const head = `<!DOCTYPE html><html>${resolvedHeadTag}<body><div id="root">`;
|
|
4365
5224
|
const ssrOnlyHmrShim = clientMode === "none" ? await getSsrOnlyHmrShim() : "";
|
|
4366
|
-
const
|
|
5225
|
+
const buildTail = () => {
|
|
5226
|
+
const teleports = ssrContext.teleports?.[ABSOLUTE_TELEPORT_TARGET] ?? "";
|
|
5227
|
+
const teleportHost = `<div id="${ABSOLUTE_TELEPORT_TARGET_ID}">${teleports}</div>`;
|
|
5228
|
+
return clientMode === "none" ? `</div>${teleportHost}${ssrOnlyHmrShim}</body></html>` : `</div>${teleportHost}<script>window.__INITIAL_PROPS__=${JSON.stringify(maybeProps ?? {})}</script><script type="module" src="${resolvedIndexPath}"></script></body></html>`;
|
|
5229
|
+
};
|
|
5230
|
+
if (resolvedPage.hasSpaRoutes && clientMode === "auto") {
|
|
5231
|
+
return new Response(`${head}${buildTail()}`, {
|
|
5232
|
+
headers: { "Content-Type": "text/html" }
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
if (resolvedOptions?.collectStreamingSlots !== true) {
|
|
5236
|
+
const body = await renderToString(app, ssrContext);
|
|
5237
|
+
return new Response(`${head}${body}${buildTail()}`, {
|
|
5238
|
+
headers: streamingPageHeaders()
|
|
5239
|
+
});
|
|
5240
|
+
}
|
|
5241
|
+
const bodyStream = renderToWebStream(app, ssrContext);
|
|
5242
|
+
const { firstChunk, reader } = await primeVueStream(bodyStream);
|
|
4367
5243
|
const stream = new ReadableStream({
|
|
4368
5244
|
start(controller) {
|
|
4369
5245
|
controller.enqueue(head);
|
|
@@ -4371,12 +5247,18 @@ var handleVuePageRequest = async (input) => {
|
|
|
4371
5247
|
controller.enqueue(firstChunk.value);
|
|
4372
5248
|
}
|
|
4373
5249
|
if (firstChunk.done) {
|
|
4374
|
-
controller.enqueue(
|
|
5250
|
+
controller.enqueue(buildTail());
|
|
4375
5251
|
controller.close();
|
|
4376
5252
|
return;
|
|
4377
5253
|
}
|
|
4378
5254
|
const pumpLoop = () => {
|
|
4379
|
-
reader.read().then(({ done, value }) => done ? (controller.enqueue(
|
|
5255
|
+
reader.read().then(({ done, value }) => done ? (controller.enqueue(buildTail()), controller.close()) : (controller.enqueue(value), pumpLoop())).catch((err) => {
|
|
5256
|
+
console.error("[SSR] Vue streaming render error:", err);
|
|
5257
|
+
reader.cancel(err).catch(() => {
|
|
5258
|
+
return;
|
|
5259
|
+
});
|
|
5260
|
+
controller.error(err);
|
|
5261
|
+
});
|
|
4380
5262
|
};
|
|
4381
5263
|
pumpLoop();
|
|
4382
5264
|
}
|
|
@@ -4385,20 +5267,24 @@ var handleVuePageRequest = async (input) => {
|
|
|
4385
5267
|
hasIslands: resolvedPage.hasIslands
|
|
4386
5268
|
});
|
|
4387
5269
|
return new Response(htmlStream, {
|
|
4388
|
-
headers:
|
|
5270
|
+
headers: streamingPageHeaders()
|
|
4389
5271
|
});
|
|
4390
5272
|
};
|
|
4391
|
-
|
|
5273
|
+
const pageResponse = await runWithStreamingSlotWarningScope(() => resolvedOptions?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, resolvedOptions) : renderPageResponse(), { handlerCallsite });
|
|
5274
|
+
return withPageCacheHeaders(pageResponse, input.request, {
|
|
5275
|
+
bufferStreamForEtag: input.bufferStreamForEtag
|
|
5276
|
+
});
|
|
4392
5277
|
} catch (error) {
|
|
4393
5278
|
console.error("[SSR] Vue render error:", error);
|
|
4394
5279
|
const pageName = derivePageName(resolvedPagePath);
|
|
4395
5280
|
const conventionResponse = await renderConventionError("vue", pageName, error);
|
|
4396
|
-
if (conventionResponse)
|
|
4397
|
-
return conventionResponse;
|
|
4398
|
-
|
|
5281
|
+
if (conventionResponse) {
|
|
5282
|
+
return withPageCacheHeaders(conventionResponse, input.request);
|
|
5283
|
+
}
|
|
5284
|
+
return withPageCacheHeaders(new Response(ssrErrorPage("vue", error), {
|
|
4399
5285
|
headers: { "Content-Type": "text/html" },
|
|
4400
5286
|
status: 500
|
|
4401
|
-
});
|
|
5287
|
+
}), input.request);
|
|
4402
5288
|
}
|
|
4403
5289
|
};
|
|
4404
5290
|
// src/vue/routerRedirectProviders.ts
|
|
@@ -4419,20 +5305,13 @@ var applyVueRouterRedirect = (router, requestedUrl, setRedirect, status = DEFAUL
|
|
|
4419
5305
|
setRedirect(finalPath, status);
|
|
4420
5306
|
};
|
|
4421
5307
|
// src/vue/defineVuePage.ts
|
|
4422
|
-
var defineVueSetupApp = (hook) => hook;
|
|
4423
5308
|
var defineRoutes = (routes) => routes;
|
|
5309
|
+
var defineVueSetupApp = (hook) => hook;
|
|
4424
5310
|
// src/vue/Island.ts
|
|
4425
5311
|
import { defineComponent as defineComponent4, h as h4, onServerPrefetch } from "vue";
|
|
4426
5312
|
|
|
4427
5313
|
// src/client/preserveIslandMarkup.ts
|
|
4428
5314
|
init_islandMarkupAttributes();
|
|
4429
|
-
var getClaimMap = () => {
|
|
4430
|
-
if (typeof window === "undefined") {
|
|
4431
|
-
return null;
|
|
4432
|
-
}
|
|
4433
|
-
window.__ABS_CLAIMED_ISLAND_MARKUP__ ??= new Map;
|
|
4434
|
-
return window.__ABS_CLAIMED_ISLAND_MARKUP__;
|
|
4435
|
-
};
|
|
4436
5315
|
var getSnapshotMap = () => {
|
|
4437
5316
|
if (typeof window === "undefined") {
|
|
4438
5317
|
return null;
|
|
@@ -4491,19 +5370,22 @@ var preserveIslandMarkup = (props) => {
|
|
|
4491
5370
|
innerHTML: ""
|
|
4492
5371
|
};
|
|
4493
5372
|
}
|
|
4494
|
-
const claimMap = getClaimMap();
|
|
4495
5373
|
const snapshotMap = getSnapshotMap();
|
|
4496
5374
|
const signature = getIslandSignature(props);
|
|
4497
|
-
const
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
5375
|
+
const snapshotCandidate = snapshotMap?.get(signature)?.[0];
|
|
5376
|
+
if (snapshotCandidate) {
|
|
5377
|
+
return snapshotCandidate;
|
|
5378
|
+
}
|
|
5379
|
+
const liveCandidate = Array.from(document.querySelectorAll('[data-island="true"]')).find((element) => isMatchingIslandElement(element, props));
|
|
5380
|
+
if (!liveCandidate) {
|
|
5381
|
+
return {
|
|
5382
|
+
attributes: getIslandMarkerAttributes(props),
|
|
5383
|
+
innerHTML: ""
|
|
5384
|
+
};
|
|
4503
5385
|
}
|
|
4504
5386
|
return {
|
|
4505
|
-
attributes:
|
|
4506
|
-
innerHTML:
|
|
5387
|
+
attributes: Object.fromEntries(liveCandidate.getAttributeNames().map((name) => [name, liveCandidate.getAttribute(name) ?? ""])),
|
|
5388
|
+
innerHTML: liveCandidate.innerHTML
|
|
4507
5389
|
};
|
|
4508
5390
|
};
|
|
4509
5391
|
|
|
@@ -4781,7 +5663,76 @@ var useIslandStore = (store, selector) => {
|
|
|
4781
5663
|
});
|
|
4782
5664
|
return state;
|
|
4783
5665
|
};
|
|
5666
|
+
// src/vue/useResource.ts
|
|
5667
|
+
import {
|
|
5668
|
+
getCurrentScope,
|
|
5669
|
+
onScopeDispose,
|
|
5670
|
+
ref as ref3,
|
|
5671
|
+
shallowRef
|
|
5672
|
+
} from "vue";
|
|
5673
|
+
var isMutatorFunction = (mutator) => typeof mutator === "function";
|
|
5674
|
+
var useResource = (fetcher, options = {}) => {
|
|
5675
|
+
const start = options.start ?? "immediate";
|
|
5676
|
+
const data = shallowRef(null);
|
|
5677
|
+
const error = shallowRef(null);
|
|
5678
|
+
const loading = ref3(start !== "idle");
|
|
5679
|
+
let controller = null;
|
|
5680
|
+
let destroyed = false;
|
|
5681
|
+
const cancel = () => {
|
|
5682
|
+
if (controller) {
|
|
5683
|
+
controller.abort();
|
|
5684
|
+
controller = null;
|
|
5685
|
+
}
|
|
5686
|
+
};
|
|
5687
|
+
const finishRefresh = (next) => {
|
|
5688
|
+
if (controller === next)
|
|
5689
|
+
controller = null;
|
|
5690
|
+
if (!next.signal.aborted)
|
|
5691
|
+
loading.value = false;
|
|
5692
|
+
};
|
|
5693
|
+
const refresh = async () => {
|
|
5694
|
+
if (destroyed)
|
|
5695
|
+
return;
|
|
5696
|
+
cancel();
|
|
5697
|
+
const next = new AbortController;
|
|
5698
|
+
controller = next;
|
|
5699
|
+
loading.value = true;
|
|
5700
|
+
error.value = null;
|
|
5701
|
+
try {
|
|
5702
|
+
const result = await fetcher(next.signal);
|
|
5703
|
+
if (next.signal.aborted)
|
|
5704
|
+
return;
|
|
5705
|
+
data.value = result;
|
|
5706
|
+
} catch (cause) {
|
|
5707
|
+
if (next.signal.aborted)
|
|
5708
|
+
return;
|
|
5709
|
+
error.value = cause;
|
|
5710
|
+
} finally {
|
|
5711
|
+
finishRefresh(next);
|
|
5712
|
+
}
|
|
5713
|
+
};
|
|
5714
|
+
const mutate = (next) => {
|
|
5715
|
+
if (destroyed)
|
|
5716
|
+
return;
|
|
5717
|
+
cancel();
|
|
5718
|
+
error.value = null;
|
|
5719
|
+
loading.value = false;
|
|
5720
|
+
const resolved = isMutatorFunction(next) ? next(data.value) : next;
|
|
5721
|
+
data.value = resolved;
|
|
5722
|
+
};
|
|
5723
|
+
if (getCurrentScope()) {
|
|
5724
|
+
onScopeDispose(() => {
|
|
5725
|
+
destroyed = true;
|
|
5726
|
+
cancel();
|
|
5727
|
+
});
|
|
5728
|
+
}
|
|
5729
|
+
if (start === "immediate") {
|
|
5730
|
+
refresh();
|
|
5731
|
+
}
|
|
5732
|
+
return { cancel, data, error, loading, mutate, refresh };
|
|
5733
|
+
};
|
|
4784
5734
|
export {
|
|
5735
|
+
useResource,
|
|
4785
5736
|
useIslandStore,
|
|
4786
5737
|
handleVuePageRequest,
|
|
4787
5738
|
defineVueSetupApp,
|
|
@@ -4791,8 +5742,10 @@ export {
|
|
|
4791
5742
|
SuspenseSlot,
|
|
4792
5743
|
StreamSlot,
|
|
4793
5744
|
Island,
|
|
4794
|
-
Image
|
|
5745
|
+
Image,
|
|
5746
|
+
ABSOLUTE_TELEPORT_TARGET_ID,
|
|
5747
|
+
ABSOLUTE_TELEPORT_TARGET
|
|
4795
5748
|
};
|
|
4796
5749
|
|
|
4797
|
-
//# debugId=
|
|
5750
|
+
//# debugId=80A3F4966DF7C3ED64756E2164756E21
|
|
4798
5751
|
//# sourceMappingURL=index.js.map
|