@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/angular/server.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) {
|
|
@@ -94,8 +76,9 @@ var ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER = "x-skip-transfer-cache", buildAbs
|
|
|
94
76
|
};
|
|
95
77
|
|
|
96
78
|
// src/constants.ts
|
|
97
|
-
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;
|
|
79
|
+
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;
|
|
98
80
|
var init_constants = __esm(() => {
|
|
81
|
+
TAILWIND_BUN_CSS_WARNING_PATTERN = /invalid @ rule encountered: '@(theme|tailwind|source|utility|variant|custom-variant|apply|reference|plugin|config)'/;
|
|
99
82
|
IMAGE_DEFAULT_DEVICE_SIZES = [
|
|
100
83
|
640,
|
|
101
84
|
750,
|
|
@@ -112,6 +95,37 @@ var init_constants = __esm(() => {
|
|
|
112
95
|
TWO_THIRDS = 2 / 3;
|
|
113
96
|
});
|
|
114
97
|
|
|
98
|
+
// src/utils/inlinePageCss.ts
|
|
99
|
+
var siblingCssCache, clearSiblingCssCache = () => {
|
|
100
|
+
siblingCssCache.clear();
|
|
101
|
+
}, injectInlineCss = (headTag, css) => {
|
|
102
|
+
if (!css)
|
|
103
|
+
return headTag;
|
|
104
|
+
const styleBlock = `<style data-absolute-page-css>${css}</style>`;
|
|
105
|
+
return headTag.replace("</head>", `${styleBlock}</head>`);
|
|
106
|
+
}, readSiblingCss = async (siblingJsPath) => {
|
|
107
|
+
if (!siblingJsPath)
|
|
108
|
+
return "";
|
|
109
|
+
const cssPath = siblingJsPath.replace(/\.js$/, ".css");
|
|
110
|
+
if (cssPath === siblingJsPath)
|
|
111
|
+
return "";
|
|
112
|
+
const cached = siblingCssCache.get(cssPath);
|
|
113
|
+
if (cached !== undefined)
|
|
114
|
+
return cached;
|
|
115
|
+
const { readFile } = await import("fs/promises");
|
|
116
|
+
try {
|
|
117
|
+
const css = await readFile(cssPath, "utf-8");
|
|
118
|
+
siblingCssCache.set(cssPath, css);
|
|
119
|
+
return css;
|
|
120
|
+
} catch {
|
|
121
|
+
siblingCssCache.set(cssPath, "");
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var init_inlinePageCss = __esm(() => {
|
|
126
|
+
siblingCssCache = new Map;
|
|
127
|
+
});
|
|
128
|
+
|
|
115
129
|
// src/utils/ssrErrorPage.ts
|
|
116
130
|
var exports_ssrErrorPage = {};
|
|
117
131
|
__export(exports_ssrErrorPage, {
|
|
@@ -176,6 +190,274 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
176
190
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
177
191
|
};
|
|
178
192
|
|
|
193
|
+
// src/utils/resolveConvention.ts
|
|
194
|
+
import { basename } from "path";
|
|
195
|
+
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
196
|
+
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
197
|
+
if (isConventionsMap(value))
|
|
198
|
+
return value;
|
|
199
|
+
const empty = {};
|
|
200
|
+
return empty;
|
|
201
|
+
}, derivePageName = (pagePath) => {
|
|
202
|
+
const base = basename(pagePath);
|
|
203
|
+
const dotIndex = base.indexOf(".");
|
|
204
|
+
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
205
|
+
return toPascal(name);
|
|
206
|
+
}, normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, ""), hasErrorConvention = (framework) => {
|
|
207
|
+
const conventions = getMap()[framework];
|
|
208
|
+
if (!conventions)
|
|
209
|
+
return false;
|
|
210
|
+
if (conventions.defaults?.error)
|
|
211
|
+
return true;
|
|
212
|
+
return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
|
|
213
|
+
}, resolveErrorConventionPath = (framework, pageName) => {
|
|
214
|
+
const conventions = getMap()[framework];
|
|
215
|
+
if (!conventions)
|
|
216
|
+
return;
|
|
217
|
+
const exact = conventions.pages?.[pageName]?.error;
|
|
218
|
+
if (exact)
|
|
219
|
+
return exact;
|
|
220
|
+
const normalizedPageName = normalizeConventionPageName(pageName);
|
|
221
|
+
for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
|
|
222
|
+
if (normalizeConventionPageName(candidate) === normalizedPageName) {
|
|
223
|
+
return page.error ?? conventions.defaults?.error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return conventions.defaults?.error;
|
|
227
|
+
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
228
|
+
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
229
|
+
}, isDev = () => true, buildErrorProps = (error) => {
|
|
230
|
+
if (error instanceof Error) {
|
|
231
|
+
return {
|
|
232
|
+
message: error.message,
|
|
233
|
+
name: error.name,
|
|
234
|
+
...isDev() && error.stack ? { stack: error.stack } : {}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return { message: String(error), name: "Error" };
|
|
238
|
+
}, renderReactError = async (conventionPath, errorProps) => {
|
|
239
|
+
const { createElement } = await import("react");
|
|
240
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
241
|
+
const mod = await import(conventionPath);
|
|
242
|
+
const ErrorComponent = mod.default;
|
|
243
|
+
if (typeof ErrorComponent !== "function")
|
|
244
|
+
return null;
|
|
245
|
+
const element = createElement(ErrorComponent, errorProps);
|
|
246
|
+
const stream = await renderToReadableStream(element);
|
|
247
|
+
return new Response(stream, {
|
|
248
|
+
headers: { "Content-Type": "text/html" },
|
|
249
|
+
status: 500
|
|
250
|
+
});
|
|
251
|
+
}, renderSvelteError = async (conventionPath, errorProps) => {
|
|
252
|
+
const { render } = await import("svelte/server");
|
|
253
|
+
const mod = await import(conventionPath);
|
|
254
|
+
const ErrorComponent = mod.default;
|
|
255
|
+
if (!ErrorComponent)
|
|
256
|
+
return null;
|
|
257
|
+
const { head, body } = render(ErrorComponent, {
|
|
258
|
+
props: errorProps
|
|
259
|
+
});
|
|
260
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
261
|
+
return new Response(html, {
|
|
262
|
+
headers: { "Content-Type": "text/html" },
|
|
263
|
+
status: 500
|
|
264
|
+
});
|
|
265
|
+
}, unescapeVueStyles = (ssrBody) => {
|
|
266
|
+
let styles = "";
|
|
267
|
+
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
268
|
+
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
269
|
+
return "";
|
|
270
|
+
});
|
|
271
|
+
return { body, styles };
|
|
272
|
+
}, renderVueError = async (conventionPath, errorProps) => {
|
|
273
|
+
const { createSSRApp, h } = await import("vue");
|
|
274
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
275
|
+
const mod = await import(conventionPath);
|
|
276
|
+
const ErrorComponent = mod.default;
|
|
277
|
+
if (!ErrorComponent)
|
|
278
|
+
return null;
|
|
279
|
+
const app = createSSRApp({
|
|
280
|
+
render: () => h(ErrorComponent, errorProps)
|
|
281
|
+
});
|
|
282
|
+
const rawBody = await renderToString(app);
|
|
283
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
284
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
285
|
+
return new Response(html, {
|
|
286
|
+
headers: { "Content-Type": "text/html" },
|
|
287
|
+
status: 500
|
|
288
|
+
});
|
|
289
|
+
}, renderAngularError = async (conventionPath, errorProps) => {
|
|
290
|
+
const mod = await import(conventionPath);
|
|
291
|
+
const renderFn = mod.default;
|
|
292
|
+
if (typeof renderFn !== "function")
|
|
293
|
+
return null;
|
|
294
|
+
const html = renderFn(errorProps);
|
|
295
|
+
return new Response(html, {
|
|
296
|
+
headers: { "Content-Type": "text/html" },
|
|
297
|
+
status: 500
|
|
298
|
+
});
|
|
299
|
+
}, 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) => {
|
|
300
|
+
const template = await Bun.file(conventionPath).text();
|
|
301
|
+
const html = replaceErrorTokens(template, errorProps);
|
|
302
|
+
return new Response(html, {
|
|
303
|
+
headers: { "Content-Type": "text/html" },
|
|
304
|
+
status: 500
|
|
305
|
+
});
|
|
306
|
+
}, logConventionRenderError = (framework, label, renderError) => {
|
|
307
|
+
const message = renderError instanceof Error ? renderError.message : "";
|
|
308
|
+
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
309
|
+
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}).`);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
313
|
+
}, renderEmberError = async () => null, renderEmberNotFound = async () => null, ERROR_RENDERERS, tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
|
|
314
|
+
let conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
315
|
+
if (!conventionPath && error instanceof Error && error.stack) {
|
|
316
|
+
for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
|
|
317
|
+
const [, candidate] = match;
|
|
318
|
+
if (!candidate)
|
|
319
|
+
continue;
|
|
320
|
+
conventionPath = resolveErrorConventionPath(framework, candidate);
|
|
321
|
+
if (conventionPath)
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (!conventionPath)
|
|
326
|
+
return null;
|
|
327
|
+
const renderer = ERROR_RENDERERS[framework];
|
|
328
|
+
if (!renderer)
|
|
329
|
+
return null;
|
|
330
|
+
try {
|
|
331
|
+
return await renderer(conventionPath, errorProps);
|
|
332
|
+
} catch (renderError) {
|
|
333
|
+
logConventionRenderError(framework, "error", renderError);
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}, renderConventionError = async (framework, pageName, error) => {
|
|
337
|
+
const errorProps = buildErrorProps(error);
|
|
338
|
+
const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
|
|
339
|
+
if (frameworkResponse)
|
|
340
|
+
return frameworkResponse;
|
|
341
|
+
if (framework !== "html") {
|
|
342
|
+
const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
|
|
343
|
+
if (htmlResponse)
|
|
344
|
+
return htmlResponse;
|
|
345
|
+
}
|
|
346
|
+
return null;
|
|
347
|
+
}, renderReactNotFound = async (conventionPath) => {
|
|
348
|
+
const { createElement } = await import("react");
|
|
349
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
350
|
+
const mod = await import(conventionPath);
|
|
351
|
+
const NotFoundComponent = mod.default;
|
|
352
|
+
if (typeof NotFoundComponent !== "function")
|
|
353
|
+
return null;
|
|
354
|
+
const element = createElement(NotFoundComponent);
|
|
355
|
+
const stream = await renderToReadableStream(element);
|
|
356
|
+
return new Response(stream, {
|
|
357
|
+
headers: { "Content-Type": "text/html" },
|
|
358
|
+
status: 404
|
|
359
|
+
});
|
|
360
|
+
}, renderSvelteNotFound = async (conventionPath) => {
|
|
361
|
+
const { render } = await import("svelte/server");
|
|
362
|
+
const mod = await import(conventionPath);
|
|
363
|
+
const NotFoundComponent = mod.default;
|
|
364
|
+
if (!NotFoundComponent)
|
|
365
|
+
return null;
|
|
366
|
+
const { head, body } = render(NotFoundComponent);
|
|
367
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
368
|
+
return new Response(html, {
|
|
369
|
+
headers: { "Content-Type": "text/html" },
|
|
370
|
+
status: 404
|
|
371
|
+
});
|
|
372
|
+
}, renderVueNotFound = async (conventionPath) => {
|
|
373
|
+
const { createSSRApp, h } = await import("vue");
|
|
374
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
375
|
+
const mod = await import(conventionPath);
|
|
376
|
+
const NotFoundComponent = mod.default;
|
|
377
|
+
if (!NotFoundComponent)
|
|
378
|
+
return null;
|
|
379
|
+
const app = createSSRApp({
|
|
380
|
+
render: () => h(NotFoundComponent)
|
|
381
|
+
});
|
|
382
|
+
const rawBody = await renderToString(app);
|
|
383
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
384
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
385
|
+
return new Response(html, {
|
|
386
|
+
headers: { "Content-Type": "text/html" },
|
|
387
|
+
status: 404
|
|
388
|
+
});
|
|
389
|
+
}, renderAngularNotFound = async (conventionPath) => {
|
|
390
|
+
const mod = await import(conventionPath);
|
|
391
|
+
const renderFn = mod.default;
|
|
392
|
+
if (typeof renderFn !== "function")
|
|
393
|
+
return null;
|
|
394
|
+
const html = renderFn();
|
|
395
|
+
return new Response(html, {
|
|
396
|
+
headers: { "Content-Type": "text/html" },
|
|
397
|
+
status: 404
|
|
398
|
+
});
|
|
399
|
+
}, renderHtmlNotFound = async (conventionPath) => {
|
|
400
|
+
const html = await Bun.file(conventionPath).text();
|
|
401
|
+
return new Response(html, {
|
|
402
|
+
headers: { "Content-Type": "text/html" },
|
|
403
|
+
status: 404
|
|
404
|
+
});
|
|
405
|
+
}, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
|
|
406
|
+
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
407
|
+
if (!conventionPath)
|
|
408
|
+
return null;
|
|
409
|
+
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
410
|
+
if (!renderer)
|
|
411
|
+
return null;
|
|
412
|
+
try {
|
|
413
|
+
return await renderer(conventionPath);
|
|
414
|
+
} catch (renderError) {
|
|
415
|
+
logConventionRenderError(framework, "not-found", renderError);
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
419
|
+
const renderNext = async (frameworks) => {
|
|
420
|
+
const [framework, ...remaining] = frameworks;
|
|
421
|
+
if (!framework) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
if (!getMap()[framework]?.defaults?.notFound) {
|
|
425
|
+
return renderNext(remaining);
|
|
426
|
+
}
|
|
427
|
+
const response = await renderConventionNotFound(framework);
|
|
428
|
+
if (response) {
|
|
429
|
+
return response;
|
|
430
|
+
}
|
|
431
|
+
return renderNext(remaining);
|
|
432
|
+
};
|
|
433
|
+
return renderNext(NOT_FOUND_PRIORITY);
|
|
434
|
+
};
|
|
435
|
+
var init_resolveConvention = __esm(() => {
|
|
436
|
+
ERROR_RENDERERS = {
|
|
437
|
+
angular: renderAngularError,
|
|
438
|
+
ember: renderEmberError,
|
|
439
|
+
html: renderHtmlError,
|
|
440
|
+
react: renderReactError,
|
|
441
|
+
svelte: renderSvelteError,
|
|
442
|
+
vue: renderVueError
|
|
443
|
+
};
|
|
444
|
+
NOT_FOUND_RENDERERS = {
|
|
445
|
+
angular: renderAngularNotFound,
|
|
446
|
+
ember: renderEmberNotFound,
|
|
447
|
+
html: renderHtmlNotFound,
|
|
448
|
+
react: renderReactNotFound,
|
|
449
|
+
svelte: renderSvelteNotFound,
|
|
450
|
+
vue: renderVueNotFound
|
|
451
|
+
};
|
|
452
|
+
NOT_FOUND_PRIORITY = [
|
|
453
|
+
"react",
|
|
454
|
+
"svelte",
|
|
455
|
+
"vue",
|
|
456
|
+
"angular",
|
|
457
|
+
"html"
|
|
458
|
+
];
|
|
459
|
+
});
|
|
460
|
+
|
|
179
461
|
// src/utils/registerClientScript.ts
|
|
180
462
|
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
181
463
|
const id = requestId || getSsrContextId() || getRequestId();
|
|
@@ -297,7 +579,7 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
297
579
|
var init_resolveAngularPackage = () => {};
|
|
298
580
|
|
|
299
581
|
// src/utils/runtimeMode.ts
|
|
300
|
-
var ENV_VAR = "NODE_ENV",
|
|
582
|
+
var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
301
583
|
|
|
302
584
|
// src/angular/angularPatch.ts
|
|
303
585
|
var exports_angularPatch = {};
|
|
@@ -389,7 +671,14 @@ var ensureHead = (doc) => {
|
|
|
389
671
|
}
|
|
390
672
|
try {
|
|
391
673
|
const adapter = new \u{275}DominoAdapter;
|
|
392
|
-
const
|
|
674
|
+
const resolveSeedDoc = () => {
|
|
675
|
+
if (typeof adapter.createHtmlDocument === "function")
|
|
676
|
+
return adapter.createHtmlDocument();
|
|
677
|
+
if (typeof adapter.getDefaultDocument === "function")
|
|
678
|
+
return adapter.getDefaultDocument();
|
|
679
|
+
return null;
|
|
680
|
+
};
|
|
681
|
+
const seedDoc = resolveSeedDoc();
|
|
393
682
|
if (seedDoc) {
|
|
394
683
|
patchElementLayout(seedDoc);
|
|
395
684
|
const probe = seedDoc.createElement("div");
|
|
@@ -468,9 +757,12 @@ var initDominoAdapter = (platformServer) => {
|
|
|
468
757
|
return {
|
|
469
758
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
470
759
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
760
|
+
Component: core.Component,
|
|
471
761
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
472
762
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
473
763
|
inject: core.inject,
|
|
764
|
+
InjectionToken: core.InjectionToken,
|
|
765
|
+
NgComponentOutlet: common.NgComponentOutlet,
|
|
474
766
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
475
767
|
provideServerRendering: platformServer.provideServerRendering,
|
|
476
768
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
@@ -493,16 +785,85 @@ var init_angularDeps = __esm(() => {
|
|
|
493
785
|
init_resolveAngularPackage();
|
|
494
786
|
});
|
|
495
787
|
|
|
496
|
-
// src/
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
788
|
+
// src/utils/spaRouteManifest.ts
|
|
789
|
+
import { basename as basename2 } from "path";
|
|
790
|
+
var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
|
|
791
|
+
Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
|
|
792
|
+
}, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
|
|
793
|
+
const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
|
|
794
|
+
return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
|
|
795
|
+
}, normalizePath = (path) => {
|
|
796
|
+
const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
|
|
797
|
+
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
798
|
+
return trimmed || "/";
|
|
799
|
+
}, fullRoutePath = (baseHref, routePath) => {
|
|
800
|
+
const base = normalizePath(baseHref);
|
|
801
|
+
const route = normalizePath(routePath);
|
|
802
|
+
if (base !== "/" && (route === base || route.startsWith(`${base}/`))) {
|
|
803
|
+
return route;
|
|
804
|
+
}
|
|
805
|
+
if (base === "/")
|
|
806
|
+
return route;
|
|
807
|
+
return normalizePath(`${base}/${route.replace(/^\/+/, "")}`);
|
|
808
|
+
}, routePattern = (path) => {
|
|
809
|
+
const segments = normalizePath(path).split("/").filter(Boolean);
|
|
810
|
+
let expression = "^";
|
|
811
|
+
for (const segment of segments) {
|
|
812
|
+
if (segment === "*" || segment === "**") {
|
|
813
|
+
expression += "(?:/.*)?";
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
const parameter = /^:[A-Za-z_$][A-Za-z0-9_$]*(?:\((.*)\))?(\?)?$/.exec(segment);
|
|
817
|
+
if (parameter) {
|
|
818
|
+
const valuePattern = parameter[1] || "[^/]+";
|
|
819
|
+
expression += parameter[2] ? `(?:/${valuePattern})?` : `/${valuePattern}`;
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
expression += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&")}`;
|
|
501
823
|
}
|
|
502
|
-
return
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
|
|
824
|
+
return new RegExp(`${expression || "^/"}/?$`);
|
|
825
|
+
}, sourcePageName = (sourceFile) => basename2(sourceFile).replace(/\.[^.]+$/, "").toLowerCase(), isKnownSpaRoute = (framework, pageName, request) => {
|
|
826
|
+
if (!request)
|
|
827
|
+
return true;
|
|
828
|
+
let pathname;
|
|
829
|
+
try {
|
|
830
|
+
pathname = normalizePath(new URL(request.url).pathname);
|
|
831
|
+
} catch {
|
|
832
|
+
return true;
|
|
833
|
+
}
|
|
834
|
+
const hosts = getSpaRouteManifest().filter((host) => {
|
|
835
|
+
if (host.framework !== framework)
|
|
836
|
+
return false;
|
|
837
|
+
if (sourcePageName(host.sourceFile) !== pageName.toLowerCase())
|
|
838
|
+
return false;
|
|
839
|
+
const base = normalizePath(host.baseHref);
|
|
840
|
+
return base === "/" || pathname === base || pathname.startsWith(`${base}/`);
|
|
841
|
+
});
|
|
842
|
+
if (hosts.length === 0)
|
|
843
|
+
return true;
|
|
844
|
+
return hosts.some((host) => host.routes.some((route) => routePattern(fullRoutePath(host.baseHref, route.path)).test(pathname)));
|
|
845
|
+
}, renderSpaNotFound = async (framework, pageName, request) => {
|
|
846
|
+
if (isKnownSpaRoute(framework, pageName, request))
|
|
847
|
+
return null;
|
|
848
|
+
return await renderFirstNotFound() ?? new Response("Not found", {
|
|
849
|
+
headers: { "Content-Type": "text/plain" },
|
|
850
|
+
status: 404
|
|
851
|
+
});
|
|
852
|
+
};
|
|
853
|
+
var init_spaRouteManifest = __esm(() => {
|
|
854
|
+
init_resolveConvention();
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
// src/core/currentIslandRegistry.ts
|
|
858
|
+
var requireCurrentIslandRegistry = () => {
|
|
859
|
+
const registry = globalThis.__absoluteIslandRegistry;
|
|
860
|
+
if (!registry) {
|
|
861
|
+
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
862
|
+
}
|
|
863
|
+
return registry;
|
|
864
|
+
}, setCurrentIslandRegistry = (registry) => {
|
|
865
|
+
globalThis.__absoluteIslandRegistry = registry;
|
|
866
|
+
};
|
|
506
867
|
|
|
507
868
|
// src/angular/requestProviders.ts
|
|
508
869
|
var buildRequestProviders = (deps, request, requestContext, responseInit) => [
|
|
@@ -589,7 +950,7 @@ __export(exports_islands, {
|
|
|
589
950
|
isAngularComponent: () => isAngularComponent,
|
|
590
951
|
getAngularIslandSelector: () => getAngularIslandSelector
|
|
591
952
|
});
|
|
592
|
-
var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) => typeof value === "function",
|
|
953
|
+
var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, isAngularComponent = (value) => typeof value === "function", getSelectorFromRenderedIsland = (rootElement) => {
|
|
593
954
|
const firstChild = rootElement.firstElementChild;
|
|
594
955
|
if (!(firstChild instanceof HTMLElement)) {
|
|
595
956
|
return null;
|
|
@@ -643,9 +1004,8 @@ var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) =
|
|
|
643
1004
|
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
644
1005
|
return `${componentName}:${JSON.stringify(props)}`;
|
|
645
1006
|
}, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
|
|
646
|
-
const { Component, InjectionToken: InjectionToken2, inject } = await import("@angular/core");
|
|
647
|
-
const { NgComponentOutlet } = await import("@angular/common");
|
|
648
1007
|
const deps = await getAngularDeps();
|
|
1008
|
+
const { Component, InjectionToken: InjectionToken2, NgComponentOutlet, inject } = deps;
|
|
649
1009
|
const selector = getAngularIslandSelector(islandId);
|
|
650
1010
|
const propsToken = new InjectionToken2(`${wrapperKey}:props`);
|
|
651
1011
|
|
|
@@ -751,7 +1111,15 @@ var init_islands = __esm(() => {
|
|
|
751
1111
|
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
752
1112
|
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands(), exports_islands));
|
|
753
1113
|
return renderAngularIslandToHtml2(component, props, islandId);
|
|
754
|
-
}, renderAngularIslandToHtml2,
|
|
1114
|
+
}, renderAngularIslandToHtml2, LEADING_HOISTED_RESOURCE_RE, stripLeadingHoistedResources = (html) => {
|
|
1115
|
+
let result = html;
|
|
1116
|
+
let match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
1117
|
+
while (match) {
|
|
1118
|
+
result = result.slice(match[0].length);
|
|
1119
|
+
match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
1120
|
+
}
|
|
1121
|
+
return result.trimStart();
|
|
1122
|
+
}, 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 }) => {
|
|
755
1123
|
const { body } = render(component, { props });
|
|
756
1124
|
return body;
|
|
757
1125
|
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
|
|
@@ -762,10 +1130,576 @@ var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
|
762
1130
|
});
|
|
763
1131
|
var init_islandSsr = __esm(() => {
|
|
764
1132
|
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
1133
|
+
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;
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
// src/build/maskLiterals.ts
|
|
1137
|
+
var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
|
|
1138
|
+
const n = src.length;
|
|
1139
|
+
const pieces = [];
|
|
1140
|
+
let out = "";
|
|
1141
|
+
let i = 0;
|
|
1142
|
+
let prevChar = "";
|
|
1143
|
+
let prevWord = "";
|
|
1144
|
+
let prevWasSpace = false;
|
|
1145
|
+
const mask = (text) => {
|
|
1146
|
+
out += SENTINEL + pieces.length + SENTINEL;
|
|
1147
|
+
pieces.push(text);
|
|
1148
|
+
prevChar = ")";
|
|
1149
|
+
prevWord = "";
|
|
1150
|
+
prevWasSpace = false;
|
|
1151
|
+
};
|
|
1152
|
+
const endOfString = (start) => {
|
|
1153
|
+
const q = src[start];
|
|
1154
|
+
let j = start + 1;
|
|
1155
|
+
while (j < n) {
|
|
1156
|
+
const c = src[j];
|
|
1157
|
+
if (c === "\\") {
|
|
1158
|
+
j += 2;
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
if (c === q)
|
|
1162
|
+
return j + 1;
|
|
1163
|
+
if (c === `
|
|
1164
|
+
`)
|
|
1165
|
+
return j;
|
|
1166
|
+
j++;
|
|
1167
|
+
}
|
|
1168
|
+
return j;
|
|
1169
|
+
};
|
|
1170
|
+
const endOfInterp = (start) => {
|
|
1171
|
+
let j = start;
|
|
1172
|
+
let depth = 1;
|
|
1173
|
+
let ipChar = "";
|
|
1174
|
+
let ipWord = "";
|
|
1175
|
+
let ipSpace = false;
|
|
1176
|
+
while (j < n && depth > 0) {
|
|
1177
|
+
const c = src[j];
|
|
1178
|
+
if (c === "\\") {
|
|
1179
|
+
j += 2;
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (c === "`") {
|
|
1183
|
+
j = endOfTemplate(j);
|
|
1184
|
+
ipChar = ")";
|
|
1185
|
+
ipWord = "";
|
|
1186
|
+
ipSpace = false;
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (c === '"' || c === "'") {
|
|
1190
|
+
j = endOfString(j);
|
|
1191
|
+
ipChar = '"';
|
|
1192
|
+
ipWord = "";
|
|
1193
|
+
ipSpace = false;
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
if (c === "/" && src[j + 1] === "/") {
|
|
1197
|
+
const nl = src.indexOf(`
|
|
1198
|
+
`, j);
|
|
1199
|
+
j = nl < 0 ? n : nl;
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
if (c === "/" && src[j + 1] === "*") {
|
|
1203
|
+
const e = src.indexOf("*/", j + 2);
|
|
1204
|
+
j = e < 0 ? n : e + 2;
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (c === "/" && (ipChar === "" || REGEX_OK_AFTER_CHAR.has(ipChar) || REGEX_OK_AFTER_WORD.has(ipWord))) {
|
|
1208
|
+
const e = endOfRegex(j);
|
|
1209
|
+
if (e > 0) {
|
|
1210
|
+
j = e;
|
|
1211
|
+
ipChar = ")";
|
|
1212
|
+
ipWord = "";
|
|
1213
|
+
ipSpace = false;
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (c === "{")
|
|
1218
|
+
depth++;
|
|
1219
|
+
else if (c === "}")
|
|
1220
|
+
depth--;
|
|
1221
|
+
j++;
|
|
1222
|
+
if (c === " " || c === "\t" || c === "\r" || c === `
|
|
1223
|
+
`) {
|
|
1224
|
+
ipSpace = true;
|
|
1225
|
+
continue;
|
|
1226
|
+
}
|
|
1227
|
+
if (isIdentChar(c)) {
|
|
1228
|
+
ipWord = isIdentChar(ipChar) && !ipSpace ? ipWord + c : c;
|
|
1229
|
+
} else {
|
|
1230
|
+
ipWord = "";
|
|
1231
|
+
}
|
|
1232
|
+
ipChar = c;
|
|
1233
|
+
ipSpace = false;
|
|
1234
|
+
}
|
|
1235
|
+
return j;
|
|
1236
|
+
};
|
|
1237
|
+
function endOfTemplate(start) {
|
|
1238
|
+
let j = start + 1;
|
|
1239
|
+
while (j < n) {
|
|
1240
|
+
const c = src[j];
|
|
1241
|
+
if (c === "\\") {
|
|
1242
|
+
j += 2;
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
if (c === "`")
|
|
1246
|
+
return j + 1;
|
|
1247
|
+
if (c === "$" && src[j + 1] === "{") {
|
|
1248
|
+
j = endOfInterp(j + 2);
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
j++;
|
|
1252
|
+
}
|
|
1253
|
+
return j;
|
|
1254
|
+
}
|
|
1255
|
+
const endOfRegex = (start) => {
|
|
1256
|
+
let j = start + 1;
|
|
1257
|
+
let inClass = false;
|
|
1258
|
+
while (j < n) {
|
|
1259
|
+
const c = src[j];
|
|
1260
|
+
if (c === "\\") {
|
|
1261
|
+
j += 2;
|
|
1262
|
+
continue;
|
|
1263
|
+
}
|
|
1264
|
+
if (c === `
|
|
1265
|
+
`)
|
|
1266
|
+
return -1;
|
|
1267
|
+
if (c === "[")
|
|
1268
|
+
inClass = true;
|
|
1269
|
+
else if (c === "]")
|
|
1270
|
+
inClass = false;
|
|
1271
|
+
else if (c === "/" && !inClass) {
|
|
1272
|
+
j++;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
j++;
|
|
1276
|
+
}
|
|
1277
|
+
while (j < n && /[a-z]/i.test(src[j] ?? ""))
|
|
1278
|
+
j++;
|
|
1279
|
+
return j;
|
|
1280
|
+
};
|
|
1281
|
+
while (i < n) {
|
|
1282
|
+
const c = src[i];
|
|
1283
|
+
const c2 = src[i + 1];
|
|
1284
|
+
if (c === "/" && c2 === "/") {
|
|
1285
|
+
out += "//";
|
|
1286
|
+
i += 2;
|
|
1287
|
+
const s = i;
|
|
1288
|
+
while (i < n && src[i] !== `
|
|
1289
|
+
`)
|
|
1290
|
+
i++;
|
|
1291
|
+
mask(src.slice(s, i));
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
if (c === "/" && c2 === "*") {
|
|
1295
|
+
out += "/*";
|
|
1296
|
+
i += 2;
|
|
1297
|
+
const e = src.indexOf("*/", i);
|
|
1298
|
+
const end = e < 0 ? n : e;
|
|
1299
|
+
mask(src.slice(i, end));
|
|
1300
|
+
i = end < n ? end + 2 : n;
|
|
1301
|
+
if (end < n)
|
|
1302
|
+
out += "*/";
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
if (c === "`") {
|
|
1306
|
+
const end = endOfTemplate(i);
|
|
1307
|
+
mask(src.slice(i, end));
|
|
1308
|
+
i = end;
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
if (c === '"' || c === "'") {
|
|
1312
|
+
const end = endOfString(i);
|
|
1313
|
+
const text = src.slice(i, end);
|
|
1314
|
+
if (RISKY_STRING_CONTENT.test(text)) {
|
|
1315
|
+
mask(text);
|
|
1316
|
+
} else {
|
|
1317
|
+
out += text;
|
|
1318
|
+
prevChar = '"';
|
|
1319
|
+
prevWord = "";
|
|
1320
|
+
prevWasSpace = false;
|
|
1321
|
+
}
|
|
1322
|
+
i = end;
|
|
1323
|
+
continue;
|
|
1324
|
+
}
|
|
1325
|
+
if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
|
|
1326
|
+
const end = endOfRegex(i);
|
|
1327
|
+
if (end > 0) {
|
|
1328
|
+
out += src.slice(i, end);
|
|
1329
|
+
i = end;
|
|
1330
|
+
prevChar = ")";
|
|
1331
|
+
prevWord = "";
|
|
1332
|
+
prevWasSpace = false;
|
|
1333
|
+
continue;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
out += c;
|
|
1337
|
+
i++;
|
|
1338
|
+
if (c === " " || c === "\t" || c === "\r" || c === `
|
|
1339
|
+
`) {
|
|
1340
|
+
prevWasSpace = true;
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
if (isIdentChar(c)) {
|
|
1344
|
+
const contiguous = isIdentChar(prevChar) && !prevWasSpace;
|
|
1345
|
+
prevWord = contiguous ? prevWord + c : c;
|
|
1346
|
+
} else {
|
|
1347
|
+
prevWord = "";
|
|
1348
|
+
}
|
|
1349
|
+
prevChar = c;
|
|
1350
|
+
prevWasSpace = false;
|
|
1351
|
+
}
|
|
1352
|
+
const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
|
|
1353
|
+
const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
|
|
1354
|
+
return { masked: out, restore };
|
|
1355
|
+
};
|
|
1356
|
+
var init_maskLiterals = __esm(() => {
|
|
1357
|
+
SENTINEL = String.fromCharCode(57344);
|
|
1358
|
+
RISKY_STRING_CONTENT = /\b(?:from|import|require)\s*\(?\s*["'`]/;
|
|
1359
|
+
REGEX_OK_AFTER_CHAR = new Set([
|
|
1360
|
+
"(",
|
|
1361
|
+
",",
|
|
1362
|
+
"=",
|
|
1363
|
+
":",
|
|
1364
|
+
"[",
|
|
1365
|
+
"!",
|
|
1366
|
+
"&",
|
|
1367
|
+
"|",
|
|
1368
|
+
"?",
|
|
1369
|
+
"{",
|
|
1370
|
+
"}",
|
|
1371
|
+
";",
|
|
1372
|
+
"+",
|
|
1373
|
+
"-",
|
|
1374
|
+
"*",
|
|
1375
|
+
"/",
|
|
1376
|
+
"%",
|
|
1377
|
+
"^",
|
|
1378
|
+
"~",
|
|
1379
|
+
"<",
|
|
1380
|
+
">"
|
|
1381
|
+
]);
|
|
1382
|
+
REGEX_OK_AFTER_WORD = new Set([
|
|
1383
|
+
"return",
|
|
1384
|
+
"typeof",
|
|
1385
|
+
"instanceof",
|
|
1386
|
+
"in",
|
|
1387
|
+
"of",
|
|
1388
|
+
"new",
|
|
1389
|
+
"delete",
|
|
1390
|
+
"void",
|
|
1391
|
+
"do",
|
|
1392
|
+
"else",
|
|
1393
|
+
"yield",
|
|
1394
|
+
"await",
|
|
1395
|
+
"case"
|
|
1396
|
+
]);
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1399
|
+
// src/build/nativeRewrite.ts
|
|
1400
|
+
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
1401
|
+
import { platform, arch } from "os";
|
|
1402
|
+
import { resolve as resolve2 } from "path";
|
|
1403
|
+
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
1404
|
+
if (nativeLib !== null)
|
|
1405
|
+
return nativeLib;
|
|
1406
|
+
const osPlatform = platform();
|
|
1407
|
+
const cpu = arch();
|
|
1408
|
+
const platformMap = {
|
|
1409
|
+
"darwin-arm64": "darwin-arm64/fast_ops.dylib",
|
|
1410
|
+
"darwin-x64": "darwin-x64/fast_ops.dylib",
|
|
1411
|
+
"linux-arm64": "linux-arm64/fast_ops.so",
|
|
1412
|
+
"linux-x64": "linux-x64/fast_ops.so",
|
|
1413
|
+
"win32-arm64": "windows-arm64/fast_ops.dll",
|
|
1414
|
+
"win32-x64": "windows-x64/fast_ops.dll"
|
|
1415
|
+
};
|
|
1416
|
+
const libPath = platformMap[`${osPlatform}-${cpu}`];
|
|
1417
|
+
if (!libPath)
|
|
1418
|
+
return null;
|
|
1419
|
+
try {
|
|
1420
|
+
const fullPath = resolve2(import.meta.dir, "../../native/packages", libPath);
|
|
1421
|
+
const lib = dlopen(fullPath, ffiDefinition);
|
|
1422
|
+
nativeLib = lib.symbols;
|
|
1423
|
+
return nativeLib;
|
|
1424
|
+
} catch {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1427
|
+
}, nativeRewriteImports = (content, replacements) => {
|
|
1428
|
+
const lib = loadNative();
|
|
1429
|
+
if (!lib)
|
|
1430
|
+
return null;
|
|
1431
|
+
const jsonStr = JSON.stringify(replacements);
|
|
1432
|
+
const contentBuf = Buffer.from(content);
|
|
1433
|
+
const jsonBuf = Buffer.from(jsonStr);
|
|
1434
|
+
const outBuf = Buffer.alloc(content.length * 2);
|
|
1435
|
+
const outLenBuf = new BigUint64Array([BigInt(outBuf.length)]);
|
|
1436
|
+
const result = lib.rewrite_imports(ptr(contentBuf), contentBuf.length, ptr(jsonBuf), jsonBuf.length, ptr(outBuf), ptr(new Uint8Array(outLenBuf.buffer)));
|
|
1437
|
+
if (result < 0)
|
|
1438
|
+
return null;
|
|
1439
|
+
if (result === 0)
|
|
1440
|
+
return content;
|
|
1441
|
+
const outLen = Number(outLenBuf[0]);
|
|
1442
|
+
return outBuf.subarray(0, outLen).toString("utf-8");
|
|
1443
|
+
};
|
|
1444
|
+
var init_nativeRewrite = __esm(() => {
|
|
1445
|
+
ffiDefinition = {
|
|
1446
|
+
rewrite_imports: {
|
|
1447
|
+
args: [
|
|
1448
|
+
FFIType.ptr,
|
|
1449
|
+
FFIType.u64,
|
|
1450
|
+
FFIType.ptr,
|
|
1451
|
+
FFIType.u64,
|
|
1452
|
+
FFIType.ptr,
|
|
1453
|
+
FFIType.ptr
|
|
1454
|
+
],
|
|
1455
|
+
returns: FFIType.i32
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
// src/build/rewriteImportsPlugin.ts
|
|
1461
|
+
var exports_rewriteImportsPlugin = {};
|
|
1462
|
+
__export(exports_rewriteImportsPlugin, {
|
|
1463
|
+
rewriteVendorDirectories: () => rewriteVendorDirectories,
|
|
1464
|
+
rewriteImportsInContent: () => rewriteImportsInContent,
|
|
1465
|
+
rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
|
|
1466
|
+
rewriteBuildOutputs: () => rewriteBuildOutputs,
|
|
1467
|
+
jsRewriteImports: () => jsRewriteImports,
|
|
1468
|
+
fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
|
|
1469
|
+
buildWithImportRewrite: () => buildWithImportRewrite
|
|
1470
|
+
});
|
|
1471
|
+
import { readdir } from "fs/promises";
|
|
1472
|
+
import { join as join2 } from "path";
|
|
1473
|
+
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
1474
|
+
let result = content;
|
|
1475
|
+
for (const [specifier, webPath] of replacements) {
|
|
1476
|
+
const escaped = escapeRegex(specifier);
|
|
1477
|
+
const fromRegex = new RegExp(`(from\\s*["'])${escaped}(["'])`, "g");
|
|
1478
|
+
const sideEffectRegex = new RegExp(`(import\\s*["'])${escaped}(["'])`, "g");
|
|
1479
|
+
const dynamicRegex = new RegExp(`(import\\s*\\(\\s*["'])${escaped}(["']\\s*\\))`, "g");
|
|
1480
|
+
result = result.replace(fromRegex, `$1${webPath}$2`);
|
|
1481
|
+
result = result.replace(sideEffectRegex, `$1${webPath}$2`);
|
|
1482
|
+
result = result.replace(dynamicRegex, `$1${webPath}$2`);
|
|
1483
|
+
}
|
|
1484
|
+
return result;
|
|
1485
|
+
}, rewriteImportsInContent = (content, vendorPaths) => {
|
|
1486
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
1487
|
+
return content;
|
|
1488
|
+
const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
|
|
1489
|
+
const { masked, restore } = maskLiterals(content);
|
|
1490
|
+
const native = nativeRewriteImports(masked, replacements);
|
|
1491
|
+
return restore(native ?? jsRewriteImports(masked, replacements));
|
|
1492
|
+
}, fixMissingReExportNamespacesInContent = (content) => {
|
|
1493
|
+
const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
|
|
1494
|
+
REEXPORT_PATTERN.lastIndex = 0;
|
|
1495
|
+
const missing = [];
|
|
1496
|
+
let match;
|
|
1497
|
+
while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
|
|
1498
|
+
const ident = match[1];
|
|
1499
|
+
if (!ident)
|
|
1500
|
+
continue;
|
|
1501
|
+
const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
|
|
1502
|
+
if (nsImportRe.test(content))
|
|
1503
|
+
continue;
|
|
1504
|
+
const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
|
|
1505
|
+
if (declRe.test(content))
|
|
1506
|
+
continue;
|
|
1507
|
+
const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
|
|
1508
|
+
if (namedImportRe.test(content))
|
|
1509
|
+
continue;
|
|
1510
|
+
const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
|
|
1511
|
+
let pathMatch;
|
|
1512
|
+
let sourcePath;
|
|
1513
|
+
while ((pathMatch = importPathRe.exec(content)) !== null) {
|
|
1514
|
+
const p = pathMatch[1];
|
|
1515
|
+
if (!p)
|
|
1516
|
+
continue;
|
|
1517
|
+
const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
|
|
1518
|
+
if (!base)
|
|
1519
|
+
continue;
|
|
1520
|
+
const normalized = base.startsWith("_") ? base.slice(1) : base;
|
|
1521
|
+
if (normalized === ident || normalized.endsWith(`_${ident}`)) {
|
|
1522
|
+
sourcePath = p;
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
if (sourcePath)
|
|
1527
|
+
missing.push({ ident, path: sourcePath });
|
|
1528
|
+
}
|
|
1529
|
+
if (missing.length === 0)
|
|
1530
|
+
return content;
|
|
1531
|
+
const seen = new Set;
|
|
1532
|
+
const unique = missing.filter((entry) => {
|
|
1533
|
+
if (seen.has(entry.ident))
|
|
1534
|
+
return false;
|
|
1535
|
+
seen.add(entry.ident);
|
|
1536
|
+
return true;
|
|
1537
|
+
});
|
|
1538
|
+
const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
|
|
1539
|
+
`);
|
|
1540
|
+
return `${inserts}
|
|
1541
|
+
${content}`;
|
|
1542
|
+
}, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
|
|
1543
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
1544
|
+
return;
|
|
1545
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
1546
|
+
let original;
|
|
1547
|
+
try {
|
|
1548
|
+
original = await artifact.text();
|
|
1549
|
+
} catch (err) {
|
|
1550
|
+
const code = err.code;
|
|
1551
|
+
if (code === "ENOENT")
|
|
1552
|
+
return;
|
|
1553
|
+
throw err;
|
|
1554
|
+
}
|
|
1555
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
1556
|
+
if (rewritten === original)
|
|
1557
|
+
return;
|
|
1558
|
+
try {
|
|
1559
|
+
await Bun.write(artifact.path, rewritten);
|
|
1560
|
+
} catch (err) {
|
|
1561
|
+
const code = err.code;
|
|
1562
|
+
if (code === "ENOENT")
|
|
1563
|
+
return;
|
|
1564
|
+
throw err;
|
|
1565
|
+
}
|
|
1566
|
+
}));
|
|
1567
|
+
}, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
|
|
1568
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
1569
|
+
const vendorPaths = resolveVendorPaths(artifact);
|
|
1570
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
1571
|
+
return;
|
|
1572
|
+
let original;
|
|
1573
|
+
try {
|
|
1574
|
+
original = await artifact.text();
|
|
1575
|
+
} catch (err) {
|
|
1576
|
+
const code = err.code;
|
|
1577
|
+
if (code === "ENOENT")
|
|
1578
|
+
return;
|
|
1579
|
+
throw err;
|
|
1580
|
+
}
|
|
1581
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
1582
|
+
if (rewritten === original)
|
|
1583
|
+
return;
|
|
1584
|
+
try {
|
|
1585
|
+
await Bun.write(artifact.path, rewritten);
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
const code = err.code;
|
|
1588
|
+
if (code === "ENOENT")
|
|
1589
|
+
return;
|
|
1590
|
+
throw err;
|
|
1591
|
+
}
|
|
1592
|
+
}));
|
|
1593
|
+
}, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
|
|
1594
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
1595
|
+
return;
|
|
1596
|
+
const allFiles = [];
|
|
1597
|
+
for (const dir of vendorDirs) {
|
|
1598
|
+
try {
|
|
1599
|
+
const entries = await readdir(dir);
|
|
1600
|
+
for (const entry of entries) {
|
|
1601
|
+
if (entry.endsWith(".js"))
|
|
1602
|
+
allFiles.push(join2(dir, entry));
|
|
1603
|
+
}
|
|
1604
|
+
} catch {}
|
|
1605
|
+
}
|
|
1606
|
+
await Promise.all(allFiles.map(async (filePath) => {
|
|
1607
|
+
let original;
|
|
1608
|
+
try {
|
|
1609
|
+
original = await Bun.file(filePath).text();
|
|
1610
|
+
} catch (err) {
|
|
1611
|
+
const code = err.code;
|
|
1612
|
+
if (code === "ENOENT")
|
|
1613
|
+
return;
|
|
1614
|
+
throw err;
|
|
1615
|
+
}
|
|
1616
|
+
let next = rewriteImportsInContent(original, vendorPaths);
|
|
1617
|
+
next = fixMissingReExportNamespacesInContent(next);
|
|
1618
|
+
if (next === original)
|
|
1619
|
+
return;
|
|
1620
|
+
try {
|
|
1621
|
+
await Bun.write(filePath, next);
|
|
1622
|
+
} catch (err) {
|
|
1623
|
+
const code = err.code;
|
|
1624
|
+
if (code === "ENOENT")
|
|
1625
|
+
return;
|
|
1626
|
+
throw err;
|
|
1627
|
+
}
|
|
1628
|
+
}));
|
|
1629
|
+
}, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
|
|
1630
|
+
const result = await pendingBuild;
|
|
1631
|
+
if (result.outputs.length > 0) {
|
|
1632
|
+
await rewriteBuildOutputs(result.outputs, vendorPaths);
|
|
1633
|
+
}
|
|
1634
|
+
return result;
|
|
1635
|
+
};
|
|
1636
|
+
var init_rewriteImportsPlugin = __esm(() => {
|
|
1637
|
+
init_maskLiterals();
|
|
1638
|
+
init_nativeRewrite();
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
// src/core/angularServerModule.ts
|
|
1642
|
+
import { mkdir } from "fs/promises";
|
|
1643
|
+
import { dirname, join as join3, relative } from "path";
|
|
1644
|
+
var serverCacheRoot, compiledModuleCache, ANGULAR_SPECIFIER_RE, getCachedModulePath = (sourcePath) => {
|
|
1645
|
+
const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1646
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1647
|
+
return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1648
|
+
}, collectVendorPaths = (code) => {
|
|
1649
|
+
const vendorPaths = {};
|
|
1650
|
+
if (!isProductionRuntime()) {
|
|
1651
|
+
return vendorPaths;
|
|
1652
|
+
}
|
|
1653
|
+
const specifiers = new Set([...code.matchAll(ANGULAR_SPECIFIER_RE)].map((match) => match[1]));
|
|
1654
|
+
specifiers.forEach((specifier) => {
|
|
1655
|
+
if (!specifier)
|
|
1656
|
+
return;
|
|
1657
|
+
const resolved = resolveAngularRuntimePath(specifier);
|
|
1658
|
+
if (resolved === specifier)
|
|
1659
|
+
return;
|
|
1660
|
+
vendorPaths[specifier] = resolved;
|
|
1661
|
+
});
|
|
1662
|
+
return vendorPaths;
|
|
1663
|
+
}, buildAngularServerModule = async (sourcePath) => {
|
|
1664
|
+
const result = await Bun.build({
|
|
1665
|
+
entrypoints: [sourcePath],
|
|
1666
|
+
format: "esm",
|
|
1667
|
+
packages: "external",
|
|
1668
|
+
target: "bun",
|
|
1669
|
+
throw: false
|
|
1670
|
+
});
|
|
1671
|
+
const entry = result.outputs.find((output) => output.kind === "entry-point");
|
|
1672
|
+
if (!result.success || !entry) {
|
|
1673
|
+
const message = result.logs.map((log) => String(log)).join(`
|
|
1674
|
+
`);
|
|
1675
|
+
throw new Error(`Failed to compile Angular island server module for "${sourcePath}":
|
|
1676
|
+
${message}`);
|
|
1677
|
+
}
|
|
1678
|
+
const code = await entry.text();
|
|
1679
|
+
const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
|
|
1680
|
+
const modulePath = getCachedModulePath(sourcePath);
|
|
1681
|
+
await mkdir(dirname(modulePath), { recursive: true });
|
|
1682
|
+
await Bun.write(modulePath, rewritten);
|
|
1683
|
+
return modulePath;
|
|
1684
|
+
}, compileAngularServerModule = (sourcePath) => {
|
|
1685
|
+
const cached = compiledModuleCache.get(sourcePath);
|
|
1686
|
+
if (cached) {
|
|
1687
|
+
return cached;
|
|
1688
|
+
}
|
|
1689
|
+
const compiledModulePromise = buildAngularServerModule(sourcePath);
|
|
1690
|
+
compiledModuleCache.set(sourcePath, compiledModulePromise);
|
|
1691
|
+
return compiledModulePromise;
|
|
1692
|
+
};
|
|
1693
|
+
var init_angularServerModule = __esm(() => {
|
|
1694
|
+
init_resolveAngularPackage();
|
|
1695
|
+
init_rewriteImportsPlugin();
|
|
1696
|
+
serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "angular");
|
|
1697
|
+
compiledModuleCache = new Map;
|
|
1698
|
+
ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
|
|
765
1699
|
});
|
|
766
1700
|
|
|
767
1701
|
// src/build/resolvePackageImport.ts
|
|
768
|
-
import { resolve as
|
|
1702
|
+
import { resolve as resolve3, join as join4 } from "path";
|
|
769
1703
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
770
1704
|
var resolveExportPath = (entry, conditions) => {
|
|
771
1705
|
if (typeof entry === "string")
|
|
@@ -787,11 +1721,11 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
787
1721
|
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
788
1722
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
789
1723
|
const exportKey = subpath ? `./${subpath}` : ".";
|
|
790
|
-
const currentPackageJsonPath =
|
|
1724
|
+
const currentPackageJsonPath = resolve3(process.cwd(), "package.json");
|
|
791
1725
|
const currentPackageJson = existsSync2(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
|
|
792
1726
|
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
793
|
-
const packageDir = currentPackageDir ??
|
|
794
|
-
const packageJsonPath =
|
|
1727
|
+
const packageDir = currentPackageDir ?? resolve3(process.cwd(), "node_modules", packageName ?? "");
|
|
1728
|
+
const packageJsonPath = join4(packageDir, "package.json");
|
|
795
1729
|
if (!existsSync2(packageJsonPath))
|
|
796
1730
|
return null;
|
|
797
1731
|
try {
|
|
@@ -806,12 +1740,12 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
806
1740
|
if (!importPath)
|
|
807
1741
|
return null;
|
|
808
1742
|
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
809
|
-
const sourceCandidate =
|
|
1743
|
+
const sourceCandidate = resolve3(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
810
1744
|
if (existsSync2(sourceCandidate)) {
|
|
811
1745
|
return sourceCandidate;
|
|
812
1746
|
}
|
|
813
1747
|
}
|
|
814
|
-
const resolved =
|
|
1748
|
+
const resolved = resolve3(packageDir, importPath);
|
|
815
1749
|
return existsSync2(resolved) ? resolved : null;
|
|
816
1750
|
} catch {
|
|
817
1751
|
return null;
|
|
@@ -968,12 +1902,12 @@ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
|
968
1902
|
import { readFile } from "fs/promises";
|
|
969
1903
|
import { createRequire } from "module";
|
|
970
1904
|
import {
|
|
971
|
-
dirname,
|
|
1905
|
+
dirname as dirname2,
|
|
972
1906
|
extname,
|
|
973
1907
|
isAbsolute,
|
|
974
|
-
join as
|
|
975
|
-
relative,
|
|
976
|
-
resolve as
|
|
1908
|
+
join as join5,
|
|
1909
|
+
relative as relative2,
|
|
1910
|
+
resolve as resolve4
|
|
977
1911
|
} from "path";
|
|
978
1912
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
979
1913
|
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) => {
|
|
@@ -1009,9 +1943,9 @@ ${message}`);
|
|
|
1009
1943
|
return requireOptionalPeer(specifier);
|
|
1010
1944
|
}
|
|
1011
1945
|
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
1012
|
-
|
|
1946
|
+
dirname2(filePath),
|
|
1013
1947
|
process.cwd(),
|
|
1014
|
-
...paths.map((path) =>
|
|
1948
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
1015
1949
|
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
1016
1950
|
pattern,
|
|
1017
1951
|
replacements: Array.isArray(value) ? value : [value]
|
|
@@ -1019,7 +1953,7 @@ ${message}`);
|
|
|
1019
1953
|
const cwd = process.cwd();
|
|
1020
1954
|
if (tsconfigAliasCache?.cwd === cwd)
|
|
1021
1955
|
return tsconfigAliasCache;
|
|
1022
|
-
const tsconfigPath =
|
|
1956
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
1023
1957
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1024
1958
|
if (!existsSync3(tsconfigPath)) {
|
|
1025
1959
|
tsconfigAliasCache = empty;
|
|
@@ -1028,7 +1962,7 @@ ${message}`);
|
|
|
1028
1962
|
try {
|
|
1029
1963
|
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
1030
1964
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
1031
|
-
const baseUrl =
|
|
1965
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
1032
1966
|
tsconfigAliasCache = {
|
|
1033
1967
|
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1034
1968
|
baseUrl,
|
|
@@ -1056,7 +1990,7 @@ ${message}`);
|
|
|
1056
1990
|
continue;
|
|
1057
1991
|
const wildcard = match[1] ?? "";
|
|
1058
1992
|
for (const replacement of alias.replacements) {
|
|
1059
|
-
targets.push(
|
|
1993
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
1060
1994
|
}
|
|
1061
1995
|
}
|
|
1062
1996
|
return targets;
|
|
@@ -1070,21 +2004,21 @@ ${message}`);
|
|
|
1070
2004
|
const ext = extname(basePath);
|
|
1071
2005
|
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1072
2006
|
`${basePath}${extension}`,
|
|
1073
|
-
|
|
2007
|
+
join5(basePath, `index${extension}`)
|
|
1074
2008
|
]);
|
|
1075
2009
|
if (language === "scss" || language === "sass") {
|
|
1076
2010
|
return paths.flatMap((path) => {
|
|
1077
|
-
const dir =
|
|
2011
|
+
const dir = dirname2(path);
|
|
1078
2012
|
const base = path.slice(dir.length + 1);
|
|
1079
|
-
return [path,
|
|
2013
|
+
return [path, join5(dir, `_${base}`)];
|
|
1080
2014
|
});
|
|
1081
2015
|
}
|
|
1082
2016
|
return paths;
|
|
1083
2017
|
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
1084
2018
|
const rawCandidates = [
|
|
1085
2019
|
...resolveAliasTargets(specifier, config),
|
|
1086
|
-
isAbsolute(specifier) ? specifier :
|
|
1087
|
-
...loadPaths.map((path) =>
|
|
2020
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
2021
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
1088
2022
|
];
|
|
1089
2023
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
1090
2024
|
if (existsSync3(candidate))
|
|
@@ -1100,8 +2034,8 @@ ${message}`);
|
|
|
1100
2034
|
path: url.slice(0, markerIndex)
|
|
1101
2035
|
};
|
|
1102
2036
|
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1103
|
-
const sourceDir =
|
|
1104
|
-
const entryDir =
|
|
2037
|
+
const sourceDir = dirname2(sourceFile);
|
|
2038
|
+
const entryDir = dirname2(entryFile);
|
|
1105
2039
|
if (sourceDir === entryDir)
|
|
1106
2040
|
return contents;
|
|
1107
2041
|
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
@@ -1109,7 +2043,7 @@ ${message}`);
|
|
|
1109
2043
|
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1110
2044
|
return match;
|
|
1111
2045
|
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1112
|
-
const rebased =
|
|
2046
|
+
const rebased = relative2(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
1113
2047
|
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1114
2048
|
const nextQuote = quote || '"';
|
|
1115
2049
|
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
@@ -1117,7 +2051,7 @@ ${message}`);
|
|
|
1117
2051
|
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1118
2052
|
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
1119
2053
|
return match;
|
|
1120
|
-
const resolved = resolveImportPath(specifier,
|
|
2054
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
1121
2055
|
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1122
2056
|
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1123
2057
|
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
@@ -1147,7 +2081,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1147
2081
|
}
|
|
1148
2082
|
return mod;
|
|
1149
2083
|
}, loadPostcssConfigFile = async (configPath) => {
|
|
1150
|
-
const resolved =
|
|
2084
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
1151
2085
|
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1152
2086
|
const config = normalizePostcssModule(loaded);
|
|
1153
2087
|
const value = typeof config === "function" ? await config({
|
|
@@ -1207,9 +2141,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1207
2141
|
return result.css;
|
|
1208
2142
|
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
1209
2143
|
canonicalize(specifier, options) {
|
|
1210
|
-
const fromDirectory = options.containingUrl ?
|
|
2144
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
1211
2145
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1212
|
-
return resolved ? new URL(pathToFileURL(
|
|
2146
|
+
return resolved ? new URL(pathToFileURL(resolve4(resolved)).href) : null;
|
|
1213
2147
|
},
|
|
1214
2148
|
load(canonicalUrl) {
|
|
1215
2149
|
const filePath = fileURLToPath(canonicalUrl);
|
|
@@ -1226,9 +2160,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1226
2160
|
install(less, pluginManager) {
|
|
1227
2161
|
const baseManager = new less.FileManager;
|
|
1228
2162
|
const manager = Object.create(baseManager);
|
|
1229
|
-
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename,
|
|
2163
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1230
2164
|
manager.loadFile = async (filename, currentDirectory) => {
|
|
1231
|
-
const resolved = resolveImportPath(filename,
|
|
2165
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1232
2166
|
if (!resolved) {
|
|
1233
2167
|
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1234
2168
|
}
|
|
@@ -1265,29 +2199,29 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1265
2199
|
const stylusDeps = renderer.deps?.();
|
|
1266
2200
|
if (Array.isArray(stylusDeps)) {
|
|
1267
2201
|
for (const dep of stylusDeps)
|
|
1268
|
-
deps.add(
|
|
2202
|
+
deps.add(resolve4(dep));
|
|
1269
2203
|
}
|
|
1270
2204
|
}
|
|
1271
2205
|
resolveCss(css ?? "");
|
|
1272
2206
|
});
|
|
1273
2207
|
});
|
|
1274
2208
|
}, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
|
|
1275
|
-
const key =
|
|
2209
|
+
const key = resolve4(entry);
|
|
1276
2210
|
const stripped = new Set;
|
|
1277
2211
|
for (const dep of deps) {
|
|
1278
|
-
const resolved =
|
|
2212
|
+
const resolved = resolve4(dep);
|
|
1279
2213
|
if (resolved !== key)
|
|
1280
2214
|
stripped.add(resolved);
|
|
1281
2215
|
}
|
|
1282
2216
|
styleDependencyGraph.set(key, stripped);
|
|
1283
2217
|
}, addStyleImporter = (importerPath, stylePath) => {
|
|
1284
|
-
const key =
|
|
1285
|
-
const target =
|
|
2218
|
+
const key = resolve4(importerPath);
|
|
2219
|
+
const target = resolve4(stylePath);
|
|
1286
2220
|
const deps = styleDependencyGraph.get(key) ?? new Set;
|
|
1287
2221
|
deps.add(target);
|
|
1288
2222
|
styleDependencyGraph.set(key, deps);
|
|
1289
2223
|
}, findStyleEntriesImporting = (changedPath) => {
|
|
1290
|
-
const target =
|
|
2224
|
+
const target = resolve4(changedPath);
|
|
1291
2225
|
const importers = [];
|
|
1292
2226
|
for (const [entry, deps] of styleDependencyGraph) {
|
|
1293
2227
|
if (deps.has(target))
|
|
@@ -1295,13 +2229,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1295
2229
|
}
|
|
1296
2230
|
return importers;
|
|
1297
2231
|
}, recordStyleOutput = (entry, css) => {
|
|
1298
|
-
const key =
|
|
2232
|
+
const key = resolve4(entry);
|
|
1299
2233
|
const hash = createHash("sha1").update(css).digest("hex");
|
|
1300
2234
|
const previous = styleOutputHashes.get(key);
|
|
1301
2235
|
styleOutputHashes.set(key, hash);
|
|
1302
2236
|
return previous !== hash;
|
|
1303
2237
|
}, forgetStyleEntry = (entry) => {
|
|
1304
|
-
const key =
|
|
2238
|
+
const key = resolve4(entry);
|
|
1305
2239
|
styleDependencyGraph.delete(key);
|
|
1306
2240
|
styleOutputHashes.delete(key);
|
|
1307
2241
|
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
@@ -1327,7 +2261,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1327
2261
|
loadPaths,
|
|
1328
2262
|
style: "expanded",
|
|
1329
2263
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1330
|
-
url: new URL(pathToFileURL(
|
|
2264
|
+
url: new URL(pathToFileURL(resolve4(filePath)).href)
|
|
1331
2265
|
});
|
|
1332
2266
|
const css = await runPostcss(result.css, filePath, config);
|
|
1333
2267
|
const loadedUrls = result.loadedUrls ?? [];
|
|
@@ -1335,7 +2269,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1335
2269
|
if (url.protocol !== "file:")
|
|
1336
2270
|
continue;
|
|
1337
2271
|
const dep = fileURLToPath(url);
|
|
1338
|
-
if (
|
|
2272
|
+
if (resolve4(dep) === resolve4(filePath))
|
|
1339
2273
|
continue;
|
|
1340
2274
|
deps.add(dep);
|
|
1341
2275
|
}
|
|
@@ -1456,7 +2390,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1456
2390
|
const start = match.index ?? 0;
|
|
1457
2391
|
const end = start + match[0].length;
|
|
1458
2392
|
parts.push(content.slice(cursor, start));
|
|
1459
|
-
const fullPath = isAbsolute(importPath) ? importPath :
|
|
2393
|
+
const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
|
|
1460
2394
|
if (visited.has(fullPath) || !existsSync3(fullPath)) {
|
|
1461
2395
|
parts.push(visited.has(fullPath) ? "" : match[0]);
|
|
1462
2396
|
cursor = end;
|
|
@@ -1465,7 +2399,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1465
2399
|
const nextVisited = new Set(visited);
|
|
1466
2400
|
nextVisited.add(fullPath);
|
|
1467
2401
|
const imported = await readFile(fullPath, "utf-8");
|
|
1468
|
-
parts.push(await resolveCssImportsAsync(imported,
|
|
2402
|
+
parts.push(await resolveCssImportsAsync(imported, dirname2(fullPath), nextVisited));
|
|
1469
2403
|
cursor = end;
|
|
1470
2404
|
}
|
|
1471
2405
|
parts.push(content.slice(cursor));
|
|
@@ -1474,13 +2408,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1474
2408
|
if (!isPreprocessableStylePath(filePath)) {
|
|
1475
2409
|
const raw = await readFile(filePath, "utf-8");
|
|
1476
2410
|
const processed = await runPostcss(raw, filePath, config);
|
|
1477
|
-
return resolveCssImportsAsync(processed,
|
|
2411
|
+
return resolveCssImportsAsync(processed, dirname2(filePath), new Set([filePath]));
|
|
1478
2412
|
}
|
|
1479
2413
|
const compiled = await compileStyleSource(filePath, undefined, undefined, config);
|
|
1480
|
-
return resolveCssImportsAsync(compiled,
|
|
2414
|
+
return resolveCssImportsAsync(compiled, dirname2(filePath), new Set([filePath]));
|
|
1481
2415
|
}, resolveCssImportsSync = (content, baseDir, visited) => {
|
|
1482
2416
|
return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
|
|
1483
|
-
const fullPath = isAbsolute(importPath) ? importPath :
|
|
2417
|
+
const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
|
|
1484
2418
|
if (visited.has(fullPath))
|
|
1485
2419
|
return "";
|
|
1486
2420
|
if (!existsSync3(fullPath))
|
|
@@ -1488,7 +2422,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1488
2422
|
const nextVisited = new Set(visited);
|
|
1489
2423
|
nextVisited.add(fullPath);
|
|
1490
2424
|
const imported = readFileSync3(fullPath, "utf-8");
|
|
1491
|
-
return resolveCssImportsSync(imported,
|
|
2425
|
+
return resolveCssImportsSync(imported, dirname2(fullPath), nextVisited);
|
|
1492
2426
|
});
|
|
1493
2427
|
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
1494
2428
|
const rawContents = readFileSync3(filePath, "utf-8");
|
|
@@ -1514,18 +2448,18 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1514
2448
|
loadPaths,
|
|
1515
2449
|
style: "expanded",
|
|
1516
2450
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1517
|
-
url: new URL(pathToFileURL(
|
|
2451
|
+
url: new URL(pathToFileURL(resolve4(filePath)).href)
|
|
1518
2452
|
});
|
|
1519
2453
|
const loadedUrls = result.loadedUrls ?? [];
|
|
1520
2454
|
for (const url of loadedUrls) {
|
|
1521
2455
|
if (url.protocol !== "file:")
|
|
1522
2456
|
continue;
|
|
1523
2457
|
const dep = fileURLToPath(url);
|
|
1524
|
-
if (
|
|
2458
|
+
if (resolve4(dep) === resolve4(filePath))
|
|
1525
2459
|
continue;
|
|
1526
2460
|
addStyleImporter(filePath, dep);
|
|
1527
2461
|
}
|
|
1528
|
-
return resolveCssImportsSync(result.css,
|
|
2462
|
+
return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
|
|
1529
2463
|
}
|
|
1530
2464
|
if (language === "less") {
|
|
1531
2465
|
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.`);
|
|
@@ -1533,7 +2467,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1533
2467
|
if (language === "stylus") {
|
|
1534
2468
|
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.`);
|
|
1535
2469
|
}
|
|
1536
|
-
return resolveCssImportsSync(rawContents,
|
|
2470
|
+
return resolveCssImportsSync(rawContents, dirname2(filePath), new Set([filePath]));
|
|
1537
2471
|
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
1538
2472
|
var init_stylePreprocessor = __esm(() => {
|
|
1539
2473
|
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
@@ -1542,7 +2476,7 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1542
2476
|
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1543
2477
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1544
2478
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1545
|
-
requireFromCwd = createRequire(
|
|
2479
|
+
requireFromCwd = createRequire(join5(process.cwd(), "package.json"));
|
|
1546
2480
|
styleDependencyGraph = new Map;
|
|
1547
2481
|
styleOutputHashes = new Map;
|
|
1548
2482
|
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
@@ -1550,14 +2484,14 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1550
2484
|
});
|
|
1551
2485
|
|
|
1552
2486
|
// src/core/svelteServerModule.ts
|
|
1553
|
-
import { mkdir, readdir } from "fs/promises";
|
|
1554
|
-
import { basename as
|
|
1555
|
-
var
|
|
1556
|
-
const importPath =
|
|
2487
|
+
import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
|
|
2488
|
+
import { basename as basename3, dirname as dirname3, extname as extname2, join as join6, relative as relative3, resolve as resolve5 } from "path";
|
|
2489
|
+
var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2490
|
+
const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
|
|
1557
2491
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1558
2492
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1559
2493
|
for (const entry of entries) {
|
|
1560
|
-
const entryPath =
|
|
2494
|
+
const entryPath = join6(dir, entry.name);
|
|
1561
2495
|
if (entry.isDirectory())
|
|
1562
2496
|
stack.push(entryPath);
|
|
1563
2497
|
if (entry.isFile() && entry.name === targetFileName) {
|
|
@@ -1571,7 +2505,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1571
2505
|
const nextStack = [];
|
|
1572
2506
|
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
1573
2507
|
dir,
|
|
1574
|
-
entries: await
|
|
2508
|
+
entries: await readdir2(dir, {
|
|
1575
2509
|
encoding: "utf-8",
|
|
1576
2510
|
withFileTypes: true
|
|
1577
2511
|
})
|
|
@@ -1582,16 +2516,16 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1582
2516
|
return found;
|
|
1583
2517
|
}
|
|
1584
2518
|
return searchDirectoryLevel(nextStack, targetFileName);
|
|
1585
|
-
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) =>
|
|
2519
|
+
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename3(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
1586
2520
|
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
1587
2521
|
if (cachedPath !== undefined) {
|
|
1588
2522
|
return cachedPath;
|
|
1589
2523
|
}
|
|
1590
|
-
if (!sourcePath.includes(`${
|
|
2524
|
+
if (!sourcePath.includes(`${join6(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
1591
2525
|
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
1592
2526
|
return sourcePath;
|
|
1593
2527
|
}
|
|
1594
|
-
const resolvedSourcePath = await findSourceFileByBasename(
|
|
2528
|
+
const resolvedSourcePath = await findSourceFileByBasename(join6(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
1595
2529
|
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
1596
2530
|
originalSourcePathCache.set(sourcePath, nextPath);
|
|
1597
2531
|
return nextPath;
|
|
@@ -1599,7 +2533,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1599
2533
|
if (!spec.startsWith(".")) {
|
|
1600
2534
|
return null;
|
|
1601
2535
|
}
|
|
1602
|
-
const basePath =
|
|
2536
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
1603
2537
|
const candidates = [
|
|
1604
2538
|
basePath,
|
|
1605
2539
|
`${basePath}.ts`,
|
|
@@ -1607,19 +2541,19 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1607
2541
|
`${basePath}.mjs`,
|
|
1608
2542
|
`${basePath}.cjs`,
|
|
1609
2543
|
`${basePath}.json`,
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
2544
|
+
join6(basePath, "index.ts"),
|
|
2545
|
+
join6(basePath, "index.js"),
|
|
2546
|
+
join6(basePath, "index.mjs"),
|
|
2547
|
+
join6(basePath, "index.cjs"),
|
|
2548
|
+
join6(basePath, "index.json")
|
|
1615
2549
|
];
|
|
1616
2550
|
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
1617
2551
|
const foundIndex = existResults.indexOf(true);
|
|
1618
2552
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1619
|
-
},
|
|
1620
|
-
const relativeSourcePath =
|
|
2553
|
+
}, getCachedModulePath2 = (sourcePath) => {
|
|
2554
|
+
const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1621
2555
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1622
|
-
return
|
|
2556
|
+
return join6(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
|
|
1623
2557
|
}, resolveSvelteImport = async (spec, from) => {
|
|
1624
2558
|
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
1625
2559
|
const resolved = resolvePackageImport(spec);
|
|
@@ -1631,7 +2565,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1631
2565
|
if (!spec.startsWith(".")) {
|
|
1632
2566
|
return null;
|
|
1633
2567
|
}
|
|
1634
|
-
const explicitPath =
|
|
2568
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
1635
2569
|
if (extname2(explicitPath) === ".svelte") {
|
|
1636
2570
|
return explicitPath;
|
|
1637
2571
|
}
|
|
@@ -1651,7 +2585,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1651
2585
|
}
|
|
1652
2586
|
await Bun.write(path, content);
|
|
1653
2587
|
}, compileSvelteServerModule = async (sourcePath) => {
|
|
1654
|
-
const cachedModulePath =
|
|
2588
|
+
const cachedModulePath = compiledModuleCache2.get(sourcePath);
|
|
1655
2589
|
if (cachedModulePath) {
|
|
1656
2590
|
return cachedModulePath;
|
|
1657
2591
|
}
|
|
@@ -1690,7 +2624,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1690
2624
|
continue;
|
|
1691
2625
|
if (resolvedChildModules[index])
|
|
1692
2626
|
continue;
|
|
1693
|
-
rewrittenModulePaths.set(spec, ensureRelativeImportPath(
|
|
2627
|
+
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
|
|
1694
2628
|
}
|
|
1695
2629
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1696
2630
|
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
@@ -1704,15 +2638,15 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1704
2638
|
generate: "server"
|
|
1705
2639
|
}).js.code;
|
|
1706
2640
|
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
1707
|
-
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(
|
|
2641
|
+
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
|
|
1708
2642
|
}
|
|
1709
2643
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1710
2644
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
1711
2645
|
}
|
|
1712
|
-
const compiledModulePath =
|
|
1713
|
-
await
|
|
2646
|
+
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
2647
|
+
await mkdir2(dirname3(compiledModulePath), { recursive: true });
|
|
1714
2648
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
1715
|
-
|
|
2649
|
+
compiledModuleCache2.set(sourcePath, compiledModulePath);
|
|
1716
2650
|
return compiledModulePath;
|
|
1717
2651
|
};
|
|
1718
2652
|
var init_svelteServerModule = __esm(() => {
|
|
@@ -1720,8 +2654,8 @@ var init_svelteServerModule = __esm(() => {
|
|
|
1720
2654
|
init_lowerIslandSyntax();
|
|
1721
2655
|
init_lowerAwaitSlotSyntax();
|
|
1722
2656
|
init_stylePreprocessor();
|
|
1723
|
-
|
|
1724
|
-
|
|
2657
|
+
serverCacheRoot2 = join6(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
2658
|
+
compiledModuleCache2 = new Map;
|
|
1725
2659
|
originalSourcePathCache = new Map;
|
|
1726
2660
|
transpiler = new Bun.Transpiler({
|
|
1727
2661
|
loader: "ts",
|
|
@@ -1729,18 +2663,31 @@ var init_svelteServerModule = __esm(() => {
|
|
|
1729
2663
|
});
|
|
1730
2664
|
});
|
|
1731
2665
|
|
|
2666
|
+
// src/utils/vueCompiler.ts
|
|
2667
|
+
var createVueCompiler = async () => {
|
|
2668
|
+
const [compiler, typescript] = await Promise.all([
|
|
2669
|
+
import("@vue/compiler-sfc"),
|
|
2670
|
+
import("typescript")
|
|
2671
|
+
]);
|
|
2672
|
+
compiler.registerTS?.(() => typescript);
|
|
2673
|
+
return compiler;
|
|
2674
|
+
}, compilerPromise, loadVueCompiler = () => {
|
|
2675
|
+
compilerPromise ??= createVueCompiler();
|
|
2676
|
+
return compilerPromise;
|
|
2677
|
+
};
|
|
2678
|
+
|
|
1732
2679
|
// src/core/vueServerModule.ts
|
|
1733
2680
|
import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync } from "fs";
|
|
1734
|
-
import { mkdir as
|
|
1735
|
-
import { dirname as
|
|
2681
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
2682
|
+
import { dirname as dirname4, join as join7, relative as relative4, resolve as resolve6 } from "path";
|
|
1736
2683
|
var {Transpiler } = globalThis.Bun;
|
|
1737
|
-
var ISLAND_COMPONENT_ID_LENGTH = 8,
|
|
1738
|
-
const importPath =
|
|
2684
|
+
var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
|
|
2685
|
+
const importPath = relative4(dirname4(from), target).replace(/\\/g, "/");
|
|
1739
2686
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1740
|
-
},
|
|
1741
|
-
const relativeSourcePath =
|
|
2687
|
+
}, getCachedModulePath3 = (sourcePath) => {
|
|
2688
|
+
const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1742
2689
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1743
|
-
return
|
|
2690
|
+
return join7(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
|
|
1744
2691
|
}, writeIfChanged2 = async (path, content) => {
|
|
1745
2692
|
const targetFile = Bun.file(path);
|
|
1746
2693
|
if (await targetFile.exists()) {
|
|
@@ -1767,10 +2714,10 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1767
2714
|
`) : nonVueLines.join(`
|
|
1768
2715
|
`);
|
|
1769
2716
|
}, 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) => {
|
|
1770
|
-
const cachedModulePath =
|
|
2717
|
+
const cachedModulePath = compiledModuleCache3.get(sourcePath);
|
|
1771
2718
|
if (cachedModulePath)
|
|
1772
2719
|
return cachedModulePath;
|
|
1773
|
-
const compiler = await
|
|
2720
|
+
const compiler = await loadVueCompiler();
|
|
1774
2721
|
const source = await Bun.file(sourcePath).text();
|
|
1775
2722
|
const { descriptor } = compiler.parse(source, { filename: sourcePath });
|
|
1776
2723
|
const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
|
|
@@ -1778,8 +2725,8 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1778
2725
|
const compiledScript = hasScript ? compiler.compileScript(descriptor, {
|
|
1779
2726
|
fs: {
|
|
1780
2727
|
fileExists: existsSync4,
|
|
1781
|
-
|
|
1782
|
-
|
|
2728
|
+
realpath: realpathSync,
|
|
2729
|
+
readFile: (file) => existsSync4(file) ? readFileSync4(file, "utf-8") : undefined
|
|
1783
2730
|
},
|
|
1784
2731
|
id: componentId,
|
|
1785
2732
|
inlineTemplate: false
|
|
@@ -1800,7 +2747,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1800
2747
|
}).code : "const ssrRender = () => {};";
|
|
1801
2748
|
const childImportPaths = extractRelativeVueImports(compiledScript.content);
|
|
1802
2749
|
const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
|
|
1803
|
-
compiledPath: await compileVueServerModule(
|
|
2750
|
+
compiledPath: await compileVueServerModule(resolve6(dirname4(sourcePath), relativeImport)),
|
|
1804
2751
|
spec: relativeImport
|
|
1805
2752
|
})));
|
|
1806
2753
|
const strippedScript = stripExports(compiledScript.content);
|
|
@@ -1812,20 +2759,20 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1812
2759
|
"export default script;"
|
|
1813
2760
|
].join(`
|
|
1814
2761
|
`));
|
|
1815
|
-
const compiledModulePath =
|
|
2762
|
+
const compiledModulePath = getCachedModulePath3(sourcePath);
|
|
1816
2763
|
let rewritten = assembled;
|
|
1817
2764
|
for (const child of compiledChildren) {
|
|
1818
2765
|
rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
|
|
1819
2766
|
}
|
|
1820
|
-
await
|
|
2767
|
+
await mkdir3(dirname4(compiledModulePath), { recursive: true });
|
|
1821
2768
|
await writeIfChanged2(compiledModulePath, rewritten);
|
|
1822
|
-
|
|
2769
|
+
compiledModuleCache3.set(sourcePath, compiledModulePath);
|
|
1823
2770
|
return compiledModulePath;
|
|
1824
2771
|
};
|
|
1825
2772
|
var init_vueServerModule = __esm(() => {
|
|
1826
2773
|
init_constants();
|
|
1827
|
-
|
|
1828
|
-
|
|
2774
|
+
serverCacheRoot3 = join7(process.cwd(), ".absolutejs", "islands", "vue");
|
|
2775
|
+
compiledModuleCache3 = new Map;
|
|
1829
2776
|
transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
|
|
1830
2777
|
});
|
|
1831
2778
|
|
|
@@ -1971,8 +2918,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
1971
2918
|
throw new Error("Resolved Vue island is not a valid Vue component.");
|
|
1972
2919
|
}
|
|
1973
2920
|
return resolvedComponent;
|
|
2921
|
+
}, loadAngularServerBuildComponent = async (buildReferencePath, exportName) => {
|
|
2922
|
+
const serverModulePath = await compileAngularServerModule(buildReferencePath);
|
|
2923
|
+
const loadedModule = await import(serverModulePath);
|
|
2924
|
+
if (exportName && exportName !== "default" && exportName in loadedModule) {
|
|
2925
|
+
return loadedModule[exportName];
|
|
2926
|
+
}
|
|
2927
|
+
return "default" in loadedModule ? loadedModule.default : loadedModule;
|
|
1974
2928
|
}, resolveAngularServerIslandComponent = async (component) => {
|
|
1975
|
-
const
|
|
2929
|
+
const buildReference = getIslandBuildReference(component);
|
|
2930
|
+
const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
|
|
2931
|
+
const resolvedComponent = buildReferencePath ? await loadAngularServerBuildComponent(buildReferencePath, buildReference?.export) : await resolveServerIslandComponent(component);
|
|
1976
2932
|
if (!isAngularServerIslandComponent(resolvedComponent)) {
|
|
1977
2933
|
throw new Error("Resolved Angular island is not a valid Angular component.");
|
|
1978
2934
|
}
|
|
@@ -2028,6 +2984,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
2028
2984
|
};
|
|
2029
2985
|
var init_renderIslandMarkup = __esm(() => {
|
|
2030
2986
|
init_islandSsr();
|
|
2987
|
+
init_angularServerModule();
|
|
2031
2988
|
init_svelteServerModule();
|
|
2032
2989
|
init_vueServerModule();
|
|
2033
2990
|
init_islandMarkupAttributes();
|
|
@@ -2046,22 +3003,20 @@ __export(exports_devRouteRegistrationCallsite, {
|
|
|
2046
3003
|
});
|
|
2047
3004
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2048
3005
|
import { Elysia } from "elysia";
|
|
2049
|
-
var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
|
|
3006
|
+
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) => {
|
|
2050
3007
|
const source = handler.toString();
|
|
2051
3008
|
return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
|
|
3009
|
+
}, getOriginalPageHandlerSource = (handler) => {
|
|
3010
|
+
if (!isPageHandlerFunction(handler))
|
|
3011
|
+
return;
|
|
3012
|
+
const info = pageHandlerWrappers.get(handler);
|
|
3013
|
+
return (info?.originalHandler ?? handler).toString();
|
|
2052
3014
|
}, isPageHandler = (handler) => {
|
|
2053
|
-
if (
|
|
3015
|
+
if (!isPageHandlerFunction(handler))
|
|
2054
3016
|
return false;
|
|
2055
|
-
|
|
2056
|
-
if (pageHandlerWrappers.has(fn))
|
|
3017
|
+
if (pageHandlerWrappers.has(handler))
|
|
2057
3018
|
return true;
|
|
2058
|
-
return handlerSourceMentionsPageHelper(
|
|
2059
|
-
}, getOriginalPageHandlerSource = (handler) => {
|
|
2060
|
-
if (typeof handler !== "function")
|
|
2061
|
-
return;
|
|
2062
|
-
const fn = handler;
|
|
2063
|
-
const info = pageHandlerWrappers.get(fn);
|
|
2064
|
-
return (info?.originalHandler ?? fn).toString();
|
|
3019
|
+
return handlerSourceMentionsPageHelper(handler);
|
|
2065
3020
|
}, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
|
|
2066
3021
|
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
2067
3022
|
if (value === null || typeof value === "undefined") {
|
|
@@ -2095,17 +3050,22 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
|
|
|
2095
3050
|
return function wrappedRouteHandler(...args) {
|
|
2096
3051
|
return storage.run({ callsite }, () => Reflect.apply(routeHandler, this, args));
|
|
2097
3052
|
};
|
|
2098
|
-
}, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path,
|
|
3053
|
+
}, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, ...routeArguments) {
|
|
3054
|
+
const handlerIndex = routeArguments.length >= 2 ? 1 : 0;
|
|
3055
|
+
const handler = routeArguments[handlerIndex];
|
|
2099
3056
|
const callsite = captureRouteRegistrationCallsite();
|
|
2100
3057
|
const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
|
|
2101
|
-
if (methodName === "get" &&
|
|
3058
|
+
if (methodName === "get" && isPageHandlerFunction(handler) && isPageHandlerFunction(wrapped) && handlerSourceMentionsPageHelper(handler)) {
|
|
2102
3059
|
pageHandlerWrappers.set(wrapped, {
|
|
2103
3060
|
originalHandler: handler
|
|
2104
3061
|
});
|
|
2105
3062
|
}
|
|
2106
|
-
|
|
3063
|
+
routeArguments[handlerIndex] = wrapped;
|
|
3064
|
+
return Reflect.apply(originalMethod, this, [path, ...routeArguments]);
|
|
2107
3065
|
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
2108
|
-
if (
|
|
3066
|
+
if (process.env[NODE_ENV_KEY] === "production") {
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
2109
3069
|
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
2110
3070
|
return;
|
|
2111
3071
|
}
|
|
@@ -2142,6 +3102,43 @@ var init_devRouteRegistrationCallsite = __esm(() => {
|
|
|
2142
3102
|
pageHandlerWrappers = new WeakMap;
|
|
2143
3103
|
});
|
|
2144
3104
|
|
|
3105
|
+
// src/core/pageResponseCache.ts
|
|
3106
|
+
import { createHash as createHash2 } from "crypto";
|
|
3107
|
+
var STREAMING_PAGE_HEADER = "x-absolute-stream", HTML_CONTENT_TYPE = "text/html", streamingPageHeaders = (extra) => {
|
|
3108
|
+
const headers = new Headers(extra);
|
|
3109
|
+
headers.set("content-type", HTML_CONTENT_TYPE);
|
|
3110
|
+
headers.set(STREAMING_PAGE_HEADER, "1");
|
|
3111
|
+
return headers;
|
|
3112
|
+
}, computeEtag = (html) => `W/"${createHash2("sha1").update(html).digest("base64url")}"`, withPageCacheHeaders = async (response, request, options) => {
|
|
3113
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3114
|
+
if (!contentType.includes(HTML_CONTENT_TYPE))
|
|
3115
|
+
return response;
|
|
3116
|
+
const isStreaming = response.headers.get(STREAMING_PAGE_HEADER) === "1";
|
|
3117
|
+
if (isStreaming && !options?.bufferStreamForEtag || !response.body) {
|
|
3118
|
+
response.headers.delete(STREAMING_PAGE_HEADER);
|
|
3119
|
+
response.headers.set("cache-control", "no-cache");
|
|
3120
|
+
return response;
|
|
3121
|
+
}
|
|
3122
|
+
const html = await response.text();
|
|
3123
|
+
const etag = computeEtag(html);
|
|
3124
|
+
if (request?.headers.get("if-none-match") === etag) {
|
|
3125
|
+
return new Response(null, {
|
|
3126
|
+
headers: { "cache-control": "no-cache", etag },
|
|
3127
|
+
status: 304
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
const headers = new Headers(response.headers);
|
|
3131
|
+
headers.delete(STREAMING_PAGE_HEADER);
|
|
3132
|
+
headers.set("cache-control", "no-cache");
|
|
3133
|
+
headers.set("etag", etag);
|
|
3134
|
+
return new Response(html, {
|
|
3135
|
+
headers,
|
|
3136
|
+
status: response.status,
|
|
3137
|
+
statusText: response.statusText
|
|
3138
|
+
});
|
|
3139
|
+
};
|
|
3140
|
+
var init_pageResponseCache = () => {};
|
|
3141
|
+
|
|
2145
3142
|
// src/client/streamSwap.ts
|
|
2146
3143
|
var streamSwapRuntime = () => {
|
|
2147
3144
|
const absoluteWindow = window;
|
|
@@ -2901,12 +3898,12 @@ var init_startupBanner = __esm(() => {
|
|
|
2901
3898
|
// src/utils/logger.ts
|
|
2902
3899
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
2903
3900
|
const cwd = process.cwd();
|
|
2904
|
-
let
|
|
2905
|
-
|
|
2906
|
-
if (!
|
|
2907
|
-
|
|
3901
|
+
let relative5 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
3902
|
+
relative5 = relative5.replace(/\\/g, "/");
|
|
3903
|
+
if (!relative5.startsWith("/")) {
|
|
3904
|
+
relative5 = `/${relative5}`;
|
|
2908
3905
|
}
|
|
2909
|
-
return
|
|
3906
|
+
return relative5;
|
|
2910
3907
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
2911
3908
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2912
3909
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -2927,6 +3924,19 @@ var colors2, frameworkColors, formatPath = (filePath) => {
|
|
|
2927
3924
|
const errorMsg = error instanceof Error ? error.message : error;
|
|
2928
3925
|
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
2929
3926
|
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
3927
|
+
}, logHmrClientUpdate = (path, framework, duration, target, serverMs, clientMs, outcome = "applied", kind) => {
|
|
3928
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
3929
|
+
const targetLabel = target.startsWith("capacitor-") ? target.slice("capacitor-".length) : target;
|
|
3930
|
+
const tag = `${colors2.cyan}[hmr:${targetLabel}]${colors2.reset}`;
|
|
3931
|
+
const pathColor = framework ? getFrameworkColor(framework) : colors2.white;
|
|
3932
|
+
const breakdown = serverMs === undefined || clientMs === undefined ? "" : `; server ${serverMs}ms, client ${clientMs}ms`;
|
|
3933
|
+
let action = "failed after";
|
|
3934
|
+
if (outcome === "applied")
|
|
3935
|
+
action = "applied in";
|
|
3936
|
+
else if (outcome === "reloaded")
|
|
3937
|
+
action = "falling back to reload after";
|
|
3938
|
+
const kindLabel = kind ? `${kind} ` : "";
|
|
3939
|
+
console.log(`${timestamp} ${tag} ${framework ?? "update"} ${kindLabel}${pathColor}${formatPath(path)}${colors2.reset} ${colors2.dim}${action} ${duration}ms${breakdown}${colors2.reset}`);
|
|
2930
3940
|
}, logHmrUpdate = (path, framework, duration) => {
|
|
2931
3941
|
log("hmr update", { duration, framework, path });
|
|
2932
3942
|
}, logInfo = (message) => {
|
|
@@ -3510,8 +4520,8 @@ __export(exports_generatedDir, {
|
|
|
3510
4520
|
getGeneratedRoot: () => getGeneratedRoot,
|
|
3511
4521
|
getFrameworkGeneratedDir: () => getFrameworkGeneratedDir
|
|
3512
4522
|
});
|
|
3513
|
-
import { join as
|
|
3514
|
-
var GENERATED_DIR_NAME = "generated", ABSOLUTE_CACHE_DIR_NAME = ".absolutejs",
|
|
4523
|
+
import { join as join8 } from "path";
|
|
4524
|
+
var GENERATED_DIR_NAME = "generated", ABSOLUTE_CACHE_DIR_NAME = ".absolutejs", getFrameworkGeneratedDir = (framework, projectRoot = process.cwd()) => join8(getGeneratedRoot(projectRoot), framework), getGeneratedRoot = (projectRoot = process.cwd()) => join8(projectRoot, ABSOLUTE_CACHE_DIR_NAME, GENERATED_DIR_NAME);
|
|
3515
4525
|
var init_generatedDir = () => {};
|
|
3516
4526
|
|
|
3517
4527
|
// src/build/compileAngular.ts
|
|
@@ -3524,7 +4534,7 @@ __export(exports_compileAngular, {
|
|
|
3524
4534
|
compileAngular: () => compileAngular
|
|
3525
4535
|
});
|
|
3526
4536
|
import { existsSync as existsSync5, readFileSync as readFileSync5, promises as fs } from "fs";
|
|
3527
|
-
import { join as
|
|
4537
|
+
import { join as join9, basename as basename4, sep, dirname as dirname5, resolve as resolve7, relative as relative5 } from "path";
|
|
3528
4538
|
var {Glob } = globalThis.Bun;
|
|
3529
4539
|
import ts from "typescript";
|
|
3530
4540
|
var traceAngularPhase = async (name, fn, metadata) => {
|
|
@@ -3532,10 +4542,10 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3532
4542
|
return tracePhase ? tracePhase(`compile/angular/${name}`, fn, metadata) : await fn();
|
|
3533
4543
|
}, readTsconfigPathAliases = () => {
|
|
3534
4544
|
try {
|
|
3535
|
-
const configPath =
|
|
4545
|
+
const configPath = resolve7(process.cwd(), "tsconfig.json");
|
|
3536
4546
|
const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
|
|
3537
4547
|
const compilerOptions = config?.compilerOptions ?? {};
|
|
3538
|
-
const baseUrl =
|
|
4548
|
+
const baseUrl = resolve7(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
3539
4549
|
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
3540
4550
|
return { aliases, baseUrl };
|
|
3541
4551
|
} catch {
|
|
@@ -3555,7 +4565,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3555
4565
|
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
3556
4566
|
for (const replacement of alias.replacements) {
|
|
3557
4567
|
const candidate = replacement.replace("*", wildcardValue);
|
|
3558
|
-
const resolved = resolveSourceFile(
|
|
4568
|
+
const resolved = resolveSourceFile(resolve7(baseUrl, candidate));
|
|
3559
4569
|
if (resolved)
|
|
3560
4570
|
return resolved;
|
|
3561
4571
|
}
|
|
@@ -3567,20 +4577,20 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3567
4577
|
`${candidate}.tsx`,
|
|
3568
4578
|
`${candidate}.js`,
|
|
3569
4579
|
`${candidate}.jsx`,
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
4580
|
+
join9(candidate, "index.ts"),
|
|
4581
|
+
join9(candidate, "index.tsx"),
|
|
4582
|
+
join9(candidate, "index.js"),
|
|
4583
|
+
join9(candidate, "index.jsx")
|
|
3574
4584
|
];
|
|
3575
4585
|
return candidates.find((file) => existsSync5(file));
|
|
3576
4586
|
}, createLegacyAngularAnimationUsageResolver = (rootDir) => {
|
|
3577
|
-
const baseDir =
|
|
4587
|
+
const baseDir = resolve7(rootDir);
|
|
3578
4588
|
const tsconfigAliases = readTsconfigPathAliases();
|
|
3579
4589
|
const transpiler3 = new Bun.Transpiler({ loader: "tsx" });
|
|
3580
4590
|
const scanCache = new Map;
|
|
3581
4591
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
3582
4592
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3583
|
-
return resolveSourceFile(
|
|
4593
|
+
return resolveSourceFile(resolve7(fromDir, specifier));
|
|
3584
4594
|
}
|
|
3585
4595
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
3586
4596
|
if (aliased)
|
|
@@ -3589,7 +4599,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3589
4599
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
3590
4600
|
if (resolved.includes("/node_modules/"))
|
|
3591
4601
|
return;
|
|
3592
|
-
const absolute =
|
|
4602
|
+
const absolute = resolve7(resolved);
|
|
3593
4603
|
if (!absolute.startsWith(baseDir))
|
|
3594
4604
|
return;
|
|
3595
4605
|
return resolveSourceFile(absolute);
|
|
@@ -3605,7 +4615,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3605
4615
|
usesLegacyAnimations: false
|
|
3606
4616
|
});
|
|
3607
4617
|
}
|
|
3608
|
-
const resolved =
|
|
4618
|
+
const resolved = resolve7(actualPath);
|
|
3609
4619
|
const cached = scanCache.get(resolved);
|
|
3610
4620
|
if (cached)
|
|
3611
4621
|
return cached;
|
|
@@ -3634,7 +4644,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3634
4644
|
const actualPath = resolveSourceFile(filePath);
|
|
3635
4645
|
if (!actualPath)
|
|
3636
4646
|
return false;
|
|
3637
|
-
const resolved =
|
|
4647
|
+
const resolved = resolve7(actualPath);
|
|
3638
4648
|
if (visited.has(resolved))
|
|
3639
4649
|
return false;
|
|
3640
4650
|
visited.add(resolved);
|
|
@@ -3642,7 +4652,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3642
4652
|
if (scan.usesLegacyAnimations)
|
|
3643
4653
|
return true;
|
|
3644
4654
|
for (const specifier of scan.imports) {
|
|
3645
|
-
const importedPath = resolveLocalImport(specifier,
|
|
4655
|
+
const importedPath = resolveLocalImport(specifier, dirname5(resolved));
|
|
3646
4656
|
if (importedPath && await visit(importedPath, visited)) {
|
|
3647
4657
|
return true;
|
|
3648
4658
|
}
|
|
@@ -3652,14 +4662,14 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3652
4662
|
return (entryPath) => visit(entryPath);
|
|
3653
4663
|
}, resolveDevClientDir = () => {
|
|
3654
4664
|
const projectRoot = process.cwd();
|
|
3655
|
-
const fromSource =
|
|
4665
|
+
const fromSource = resolve7(import.meta.dir, "../dev/client");
|
|
3656
4666
|
if (existsSync5(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
3657
4667
|
return fromSource;
|
|
3658
4668
|
}
|
|
3659
|
-
const fromNodeModules =
|
|
4669
|
+
const fromNodeModules = resolve7(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
3660
4670
|
if (existsSync5(fromNodeModules))
|
|
3661
4671
|
return fromNodeModules;
|
|
3662
|
-
return
|
|
4672
|
+
return resolve7(import.meta.dir, "./dev/client");
|
|
3663
4673
|
}, devClientDir, hmrClientPath, formatDiagnosticMessage = (diagnostic) => {
|
|
3664
4674
|
try {
|
|
3665
4675
|
return ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
@@ -3701,12 +4711,12 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3701
4711
|
return `${path.replace(/\.ts$/, ".js")}${query}`;
|
|
3702
4712
|
if (hasJsLikeExtension(path))
|
|
3703
4713
|
return `${path}${query}`;
|
|
3704
|
-
const importerDir =
|
|
3705
|
-
const fileCandidate =
|
|
4714
|
+
const importerDir = dirname5(importerOutputPath);
|
|
4715
|
+
const fileCandidate = resolve7(importerDir, `${path}.js`);
|
|
3706
4716
|
if (outputFiles?.has(fileCandidate) || existsSync5(fileCandidate)) {
|
|
3707
4717
|
return `${path}.js${query}`;
|
|
3708
4718
|
}
|
|
3709
|
-
const indexCandidate =
|
|
4719
|
+
const indexCandidate = resolve7(importerDir, path, "index.js");
|
|
3710
4720
|
if (outputFiles?.has(indexCandidate) || existsSync5(indexCandidate)) {
|
|
3711
4721
|
return `${path}/index.js${query}`;
|
|
3712
4722
|
}
|
|
@@ -3734,18 +4744,18 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3734
4744
|
}, resolveLocalTsImport = (fromFile, specifier) => {
|
|
3735
4745
|
if (!isRelativeModuleSpecifier(specifier))
|
|
3736
4746
|
return null;
|
|
3737
|
-
const basePath =
|
|
4747
|
+
const basePath = resolve7(dirname5(fromFile), specifier);
|
|
3738
4748
|
const candidates = /\.[cm]?[tj]sx?$/.test(basePath) ? [basePath] : [
|
|
3739
4749
|
`${basePath}.ts`,
|
|
3740
4750
|
`${basePath}.tsx`,
|
|
3741
4751
|
`${basePath}.mts`,
|
|
3742
4752
|
`${basePath}.cts`,
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
4753
|
+
join9(basePath, "index.ts"),
|
|
4754
|
+
join9(basePath, "index.tsx"),
|
|
4755
|
+
join9(basePath, "index.mts"),
|
|
4756
|
+
join9(basePath, "index.cts")
|
|
3747
4757
|
];
|
|
3748
|
-
return candidates.map((candidate) =>
|
|
4758
|
+
return candidates.map((candidate) => resolve7(candidate)).find((candidate) => existsSync5(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
3749
4759
|
}, readFileForAotTransform = async (fileName, readFile2) => {
|
|
3750
4760
|
const hostSource = readFile2?.(fileName);
|
|
3751
4761
|
if (typeof hostSource === "string")
|
|
@@ -3769,18 +4779,18 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3769
4779
|
const paths = [];
|
|
3770
4780
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3771
4781
|
if (templateUrlMatch?.[1])
|
|
3772
|
-
paths.push(
|
|
4782
|
+
paths.push(join9(fileDir, templateUrlMatch[1]));
|
|
3773
4783
|
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3774
4784
|
if (styleUrlMatch?.[1])
|
|
3775
|
-
paths.push(
|
|
4785
|
+
paths.push(join9(fileDir, styleUrlMatch[1]));
|
|
3776
4786
|
const styleUrlsMatch = findUncommentedMatch(source, /styleUrls\s*:\s*\[([^\]]+)\]/);
|
|
3777
4787
|
const urlMatches = styleUrlsMatch?.[1]?.match(/['"]([^'"]+)['"]/g);
|
|
3778
4788
|
if (urlMatches) {
|
|
3779
4789
|
for (const urlMatch of urlMatches) {
|
|
3780
|
-
paths.push(
|
|
4790
|
+
paths.push(join9(fileDir, urlMatch.replace(/['"]/g, "")));
|
|
3781
4791
|
}
|
|
3782
4792
|
}
|
|
3783
|
-
return paths.map((path) =>
|
|
4793
|
+
return paths.map((path) => resolve7(path));
|
|
3784
4794
|
}, readResourceCacheFile = async (cachePath) => {
|
|
3785
4795
|
try {
|
|
3786
4796
|
const entry = JSON.parse(await fs.readFile(cachePath, "utf-8"));
|
|
@@ -3792,13 +4802,13 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3792
4802
|
return null;
|
|
3793
4803
|
}
|
|
3794
4804
|
}, writeResourceCacheFile = async (cachePath, source) => {
|
|
3795
|
-
await fs.mkdir(
|
|
4805
|
+
await fs.mkdir(dirname5(cachePath), { recursive: true });
|
|
3796
4806
|
await fs.writeFile(cachePath, JSON.stringify({
|
|
3797
4807
|
source,
|
|
3798
4808
|
version: 1
|
|
3799
4809
|
}), "utf-8");
|
|
3800
4810
|
}, resolveResourceTransformCachePath = async (filePath, source, stylePreprocessors) => {
|
|
3801
|
-
const resourcePaths = collectAngularResourcePaths(source,
|
|
4811
|
+
const resourcePaths = collectAngularResourcePaths(source, dirname5(filePath));
|
|
3802
4812
|
const resourceContents = await Promise.all(resourcePaths.map(async (resourcePath) => {
|
|
3803
4813
|
const content = await fs.readFile(resourcePath, "utf-8");
|
|
3804
4814
|
return `${resourcePath}\x00${content}`;
|
|
@@ -3811,7 +4821,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3811
4821
|
safeStableStringify(stylePreprocessors ?? null)
|
|
3812
4822
|
].join("\x00");
|
|
3813
4823
|
const cacheKey = Bun.hash(cacheInput).toString(BASE_36_RADIX);
|
|
3814
|
-
return
|
|
4824
|
+
return join9(process.cwd(), ".absolutejs", "cache", "angular-resources", `${cacheKey}.json`);
|
|
3815
4825
|
}, precomputeAotResourceTransforms = async (inputPaths, readFile2, stylePreprocessors) => {
|
|
3816
4826
|
const transformedSources = new Map;
|
|
3817
4827
|
const visited = new Set;
|
|
@@ -3822,7 +4832,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3822
4832
|
transformedFiles: 0
|
|
3823
4833
|
};
|
|
3824
4834
|
const transformFile = async (filePath) => {
|
|
3825
|
-
const resolvedPath =
|
|
4835
|
+
const resolvedPath = resolve7(filePath);
|
|
3826
4836
|
if (visited.has(resolvedPath))
|
|
3827
4837
|
return;
|
|
3828
4838
|
visited.add(resolvedPath);
|
|
@@ -3838,7 +4848,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3838
4848
|
transformedSource = cached.source;
|
|
3839
4849
|
} else {
|
|
3840
4850
|
stats.cacheMisses += 1;
|
|
3841
|
-
const transformed = await inlineResources(source,
|
|
4851
|
+
const transformed = await inlineResources(source, dirname5(resolvedPath), stylePreprocessors);
|
|
3842
4852
|
transformedSource = transformed.source;
|
|
3843
4853
|
await writeResourceCacheFile(cachePath, transformedSource);
|
|
3844
4854
|
}
|
|
@@ -3857,7 +4867,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3857
4867
|
return { stats, transformedSources };
|
|
3858
4868
|
}, compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
|
|
3859
4869
|
const islandMetadataByOutputPath = await traceAngularPhase("aot/island-metadata", () => new Map(inputPaths.map((inputPath) => {
|
|
3860
|
-
const outputPath =
|
|
4870
|
+
const outputPath = resolve7(join9(outDir, relative5(process.cwd(), resolve7(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
|
|
3861
4871
|
return [
|
|
3862
4872
|
outputPath,
|
|
3863
4873
|
buildIslandMetadataExports(readFileSync5(inputPath, "utf-8"))
|
|
@@ -3867,8 +4877,8 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3867
4877
|
const { readConfiguration, performCompilation, EmitFlags } = await traceAngularPhase("aot/import-compiler-cli", () => import("@angular/compiler-cli"));
|
|
3868
4878
|
const tsLibDir = await traceAngularPhase("aot/resolve-typescript-lib", () => {
|
|
3869
4879
|
const tsPath = __require.resolve("typescript");
|
|
3870
|
-
const tsRootDir =
|
|
3871
|
-
return tsRootDir.endsWith("lib") ? tsRootDir :
|
|
4880
|
+
const tsRootDir = dirname5(tsPath);
|
|
4881
|
+
return tsRootDir.endsWith("lib") ? tsRootDir : resolve7(tsRootDir, "lib");
|
|
3872
4882
|
});
|
|
3873
4883
|
const config = await traceAngularPhase("aot/read-configuration", () => readConfiguration("./tsconfig.json"));
|
|
3874
4884
|
const options = {
|
|
@@ -3899,18 +4909,18 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3899
4909
|
const originalGetDefaultLibFileName = host.getDefaultLibFileName;
|
|
3900
4910
|
host.getDefaultLibFileName = (opts) => {
|
|
3901
4911
|
const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
|
|
3902
|
-
return
|
|
4912
|
+
return basename4(fileName);
|
|
3903
4913
|
};
|
|
3904
4914
|
const originalGetSourceFile = host.getSourceFile;
|
|
3905
4915
|
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
3906
4916
|
if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
|
|
3907
|
-
const resolvedPath =
|
|
4917
|
+
const resolvedPath = join9(tsLibDir, fileName);
|
|
3908
4918
|
return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
|
|
3909
4919
|
}
|
|
3910
4920
|
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
3911
4921
|
};
|
|
3912
4922
|
const emitted = {};
|
|
3913
|
-
const resolvedOutDir =
|
|
4923
|
+
const resolvedOutDir = resolve7(outDir);
|
|
3914
4924
|
host.writeFile = (fileName, text) => {
|
|
3915
4925
|
const relativePath = resolveRelativePath(fileName, resolvedOutDir, outDir);
|
|
3916
4926
|
emitted[relativePath] = text;
|
|
@@ -3932,12 +4942,12 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3932
4942
|
if (!fileName.endsWith(".ts") || fileName.endsWith(".d.ts")) {
|
|
3933
4943
|
return source;
|
|
3934
4944
|
}
|
|
3935
|
-
const resolvedPath =
|
|
4945
|
+
const resolvedPath = resolve7(fileName);
|
|
3936
4946
|
return transformedSources.get(resolvedPath) ?? source;
|
|
3937
4947
|
};
|
|
3938
4948
|
const originalGetSourceFileForCompile = host.getSourceFile;
|
|
3939
4949
|
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
3940
|
-
const source = transformedSources.get(
|
|
4950
|
+
const source = transformedSources.get(resolve7(fileName));
|
|
3941
4951
|
if (source) {
|
|
3942
4952
|
return ts.createSourceFile(fileName, source, languageVersion, true);
|
|
3943
4953
|
}
|
|
@@ -3959,9 +4969,9 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3959
4969
|
const entries = await traceAngularPhase("aot/postprocess-emitted-js", () => {
|
|
3960
4970
|
const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
|
|
3961
4971
|
content,
|
|
3962
|
-
target:
|
|
4972
|
+
target: join9(outDir, fileName)
|
|
3963
4973
|
}));
|
|
3964
|
-
const outputFiles = new Set(rawEntries.map(({ target }) =>
|
|
4974
|
+
const outputFiles = new Set(rawEntries.map(({ target }) => resolve7(target)));
|
|
3965
4975
|
return rawEntries.map(({ content, target }) => {
|
|
3966
4976
|
let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
3967
4977
|
const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
|
|
@@ -3976,17 +4986,17 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3976
4986
|
return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
|
|
3977
4987
|
});
|
|
3978
4988
|
processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
|
|
3979
|
-
processedContent += islandMetadataByOutputPath.get(
|
|
4989
|
+
processedContent += islandMetadataByOutputPath.get(resolve7(target)) ?? "";
|
|
3980
4990
|
return { content: processedContent, target };
|
|
3981
4991
|
});
|
|
3982
4992
|
});
|
|
3983
4993
|
await traceAngularPhase("aot/write-output", () => Promise.all(entries.map(async ({ target, content }) => {
|
|
3984
|
-
await fs.mkdir(
|
|
4994
|
+
await fs.mkdir(dirname5(target), { recursive: true });
|
|
3985
4995
|
await fs.writeFile(target, content, "utf-8");
|
|
3986
4996
|
})), { outputs: entries.length });
|
|
3987
4997
|
return await traceAngularPhase("aot/collect-output-paths", () => entries.map(({ target }) => target), { outputs: entries.length });
|
|
3988
4998
|
}, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => compileAngularFiles([inputPath], outDir, stylePreprocessors), jitContentCache, invalidateAngularJitCache = (filePath) => {
|
|
3989
|
-
jitContentCache.delete(
|
|
4999
|
+
jitContentCache.delete(resolve7(filePath));
|
|
3990
5000
|
}, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), findUncommentedMatch = (source, pattern) => {
|
|
3991
5001
|
const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
|
|
3992
5002
|
let match;
|
|
@@ -3999,7 +5009,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3999
5009
|
}
|
|
4000
5010
|
return null;
|
|
4001
5011
|
}, resolveAngularDeferImportSpecifier = () => {
|
|
4002
|
-
const sourceEntry =
|
|
5012
|
+
const sourceEntry = resolve7(import.meta.dir, "../angular/components/index.ts");
|
|
4003
5013
|
if (existsSync5(sourceEntry)) {
|
|
4004
5014
|
return sourceEntry.replace(/\\/g, "/");
|
|
4005
5015
|
}
|
|
@@ -4136,7 +5146,7 @@ ${fields}
|
|
|
4136
5146
|
}, inlineTemplateAndLowerDefer = async (source, fileDir) => {
|
|
4137
5147
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4138
5148
|
if (templateUrlMatch?.[1]) {
|
|
4139
|
-
const templatePath =
|
|
5149
|
+
const templatePath = join9(fileDir, templateUrlMatch[1]);
|
|
4140
5150
|
if (!existsSync5(templatePath)) {
|
|
4141
5151
|
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
4142
5152
|
}
|
|
@@ -4167,7 +5177,7 @@ ${fields}
|
|
|
4167
5177
|
}, inlineTemplateAndLowerDeferSync = (source, fileDir) => {
|
|
4168
5178
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4169
5179
|
if (templateUrlMatch?.[1]) {
|
|
4170
|
-
const templatePath =
|
|
5180
|
+
const templatePath = join9(fileDir, templateUrlMatch[1]);
|
|
4171
5181
|
if (!existsSync5(templatePath)) {
|
|
4172
5182
|
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
4173
5183
|
}
|
|
@@ -4204,7 +5214,7 @@ ${fields}
|
|
|
4204
5214
|
return source;
|
|
4205
5215
|
const stylePromises = urlMatches.map((urlMatch) => {
|
|
4206
5216
|
const styleUrl = urlMatch.replace(/['"]/g, "");
|
|
4207
|
-
return readAndEscapeFile(
|
|
5217
|
+
return readAndEscapeFile(join9(fileDir, styleUrl), stylePreprocessors);
|
|
4208
5218
|
});
|
|
4209
5219
|
const results = await Promise.all(stylePromises);
|
|
4210
5220
|
const inlinedStyles = results.filter(Boolean).map((escaped) => `\`${escaped}\``);
|
|
@@ -4215,7 +5225,7 @@ ${fields}
|
|
|
4215
5225
|
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4216
5226
|
if (!styleUrlMatch?.[1])
|
|
4217
5227
|
return source;
|
|
4218
|
-
const escaped = await readAndEscapeFile(
|
|
5228
|
+
const escaped = await readAndEscapeFile(join9(fileDir, styleUrlMatch[1]), stylePreprocessors);
|
|
4219
5229
|
if (!escaped)
|
|
4220
5230
|
return source;
|
|
4221
5231
|
return source.slice(0, styleUrlMatch.index) + `styles: [\`${escaped}\`]` + source.slice(styleUrlMatch.index + styleUrlMatch[0].length);
|
|
@@ -4228,11 +5238,71 @@ ${fields}
|
|
|
4228
5238
|
deferSlots: inlinedTemplate.deferSlots,
|
|
4229
5239
|
source: result
|
|
4230
5240
|
};
|
|
5241
|
+
}, CLASS_KEYWORD = "class", isIdentifierChar = (char) => char !== undefined && /[A-Za-z0-9_$]/.test(char), skipStringLiteral = (source, start) => {
|
|
5242
|
+
const quote = source[start];
|
|
5243
|
+
let index = start + 1;
|
|
5244
|
+
while (index < source.length) {
|
|
5245
|
+
if (source[index] === "\\") {
|
|
5246
|
+
index += 2;
|
|
5247
|
+
continue;
|
|
5248
|
+
}
|
|
5249
|
+
if (source[index] === quote)
|
|
5250
|
+
return index + 1;
|
|
5251
|
+
index += 1;
|
|
5252
|
+
}
|
|
5253
|
+
return index;
|
|
5254
|
+
}, findDecoratedClassKeyword = (source, start) => {
|
|
5255
|
+
let index = start;
|
|
5256
|
+
let depth = 0;
|
|
5257
|
+
while (index < source.length) {
|
|
5258
|
+
const char = source[index];
|
|
5259
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
5260
|
+
index = skipStringLiteral(source, index);
|
|
5261
|
+
continue;
|
|
5262
|
+
}
|
|
5263
|
+
const isOpen = char === "(" || char === "[" || char === "{";
|
|
5264
|
+
const isClose = char === ")" || char === "]" || char === "}";
|
|
5265
|
+
const atClass = depth === 0 && source.startsWith(CLASS_KEYWORD, index) && !isIdentifierChar(source[index - 1]) && !isIdentifierChar(source[index + CLASS_KEYWORD.length]);
|
|
5266
|
+
if (atClass)
|
|
5267
|
+
return index;
|
|
5268
|
+
if (isOpen)
|
|
5269
|
+
depth += 1;
|
|
5270
|
+
else if (isClose)
|
|
5271
|
+
depth -= 1;
|
|
5272
|
+
index += 1;
|
|
5273
|
+
}
|
|
5274
|
+
return -1;
|
|
5275
|
+
}, hoistExportPastDecorators = (source) => {
|
|
5276
|
+
const exportBeforeDecorator = /\bexport\s+(?=@)/g;
|
|
5277
|
+
let result = "";
|
|
5278
|
+
let lastIndex = 0;
|
|
5279
|
+
let match = exportBeforeDecorator.exec(source);
|
|
5280
|
+
while (match !== null) {
|
|
5281
|
+
const decoratorStart = match.index + match[0].length;
|
|
5282
|
+
const classIndex = findDecoratedClassKeyword(source, decoratorStart);
|
|
5283
|
+
if (classIndex !== -1) {
|
|
5284
|
+
result += source.slice(lastIndex, match.index);
|
|
5285
|
+
result += source.slice(decoratorStart, classIndex);
|
|
5286
|
+
result += `export ${CLASS_KEYWORD}`;
|
|
5287
|
+
lastIndex = classIndex + CLASS_KEYWORD.length;
|
|
5288
|
+
exportBeforeDecorator.lastIndex = lastIndex;
|
|
5289
|
+
}
|
|
5290
|
+
match = exportBeforeDecorator.exec(source);
|
|
5291
|
+
}
|
|
5292
|
+
result += source.slice(lastIndex);
|
|
5293
|
+
return result;
|
|
5294
|
+
}, PROVIDERS_INJECTION_BLOCK_RE, readPreservedInjection = async (targetPath) => {
|
|
5295
|
+
try {
|
|
5296
|
+
const existing = await fs.readFile(targetPath, "utf-8");
|
|
5297
|
+
return PROVIDERS_INJECTION_BLOCK_RE.exec(existing)?.[0] ?? "";
|
|
5298
|
+
} catch {
|
|
5299
|
+
return "";
|
|
5300
|
+
}
|
|
4231
5301
|
}, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
|
|
4232
|
-
const entryPath =
|
|
5302
|
+
const entryPath = resolve7(inputPath);
|
|
4233
5303
|
const allOutputs = [];
|
|
4234
5304
|
const visited = new Set;
|
|
4235
|
-
const baseDir =
|
|
5305
|
+
const baseDir = resolve7(rootDir ?? process.cwd());
|
|
4236
5306
|
let usesLegacyAnimations = false;
|
|
4237
5307
|
const angularTranspiler = new Bun.Transpiler({
|
|
4238
5308
|
loader: "ts",
|
|
@@ -4251,16 +5321,16 @@ ${fields}
|
|
|
4251
5321
|
`${candidate}.js`,
|
|
4252
5322
|
`${candidate}.jsx`,
|
|
4253
5323
|
`${candidate}.json`,
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
5324
|
+
join9(candidate, "index.ts"),
|
|
5325
|
+
join9(candidate, "index.tsx"),
|
|
5326
|
+
join9(candidate, "index.js"),
|
|
5327
|
+
join9(candidate, "index.jsx")
|
|
4258
5328
|
];
|
|
4259
5329
|
return candidates.find((file) => existsSync5(file));
|
|
4260
5330
|
};
|
|
4261
5331
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
4262
5332
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
4263
|
-
return resolveSourceFile2(
|
|
5333
|
+
return resolveSourceFile2(resolve7(fromDir, specifier));
|
|
4264
5334
|
}
|
|
4265
5335
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile2);
|
|
4266
5336
|
if (aliased)
|
|
@@ -4269,7 +5339,7 @@ ${fields}
|
|
|
4269
5339
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
4270
5340
|
if (resolved.includes("/node_modules/"))
|
|
4271
5341
|
return;
|
|
4272
|
-
const absolute =
|
|
5342
|
+
const absolute = resolve7(resolved);
|
|
4273
5343
|
if (!absolute.startsWith(baseDir))
|
|
4274
5344
|
return;
|
|
4275
5345
|
return resolveSourceFile2(absolute);
|
|
@@ -4278,13 +5348,13 @@ ${fields}
|
|
|
4278
5348
|
}
|
|
4279
5349
|
};
|
|
4280
5350
|
const toOutputPath = (sourcePath) => {
|
|
4281
|
-
const inputDir =
|
|
4282
|
-
const fileBase =
|
|
5351
|
+
const inputDir = dirname5(sourcePath);
|
|
5352
|
+
const fileBase = basename4(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
4283
5353
|
if (inputDir === outDir || inputDir.startsWith(`${outDir}${sep}`)) {
|
|
4284
|
-
return
|
|
5354
|
+
return join9(inputDir, fileBase);
|
|
4285
5355
|
}
|
|
4286
5356
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
4287
|
-
return
|
|
5357
|
+
return join9(outDir, relativeDir, fileBase);
|
|
4288
5358
|
};
|
|
4289
5359
|
const withCacheBuster = (specifier) => {
|
|
4290
5360
|
if (!cacheBuster)
|
|
@@ -4292,7 +5362,7 @@ ${fields}
|
|
|
4292
5362
|
return specifier.includes("?") ? `${specifier}&t=${cacheBuster}` : `${specifier}?t=${cacheBuster}`;
|
|
4293
5363
|
};
|
|
4294
5364
|
const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
|
|
4295
|
-
let processedContent = angularTranspiler.transformSync(sourceCode);
|
|
5365
|
+
let processedContent = angularTranspiler.transformSync(hoistExportPastDecorators(sourceCode));
|
|
4296
5366
|
const outputPath = toOutputPath(actualPath);
|
|
4297
5367
|
const rewriteBareImport = (prefix, specifier, suffix) => {
|
|
4298
5368
|
const rewritten = importRewrites.get(specifier);
|
|
@@ -4321,21 +5391,21 @@ ${fields}
|
|
|
4321
5391
|
return `${prefix}${dots}`;
|
|
4322
5392
|
return `${prefix}../${dots}`;
|
|
4323
5393
|
});
|
|
4324
|
-
if (
|
|
5394
|
+
if (resolve7(actualPath) === entryPath) {
|
|
4325
5395
|
processedContent += buildIslandMetadataExports(sourceCode);
|
|
4326
5396
|
}
|
|
4327
5397
|
return processedContent;
|
|
4328
5398
|
};
|
|
4329
5399
|
const transpileFile = async (filePath) => {
|
|
4330
|
-
const resolved =
|
|
5400
|
+
const resolved = resolve7(filePath);
|
|
4331
5401
|
if (visited.has(resolved))
|
|
4332
5402
|
return;
|
|
4333
5403
|
visited.add(resolved);
|
|
4334
5404
|
if (resolved.endsWith(".json") && existsSync5(resolved)) {
|
|
4335
|
-
const inputDir2 =
|
|
5405
|
+
const inputDir2 = dirname5(resolved);
|
|
4336
5406
|
const relativeDir2 = inputDir2.startsWith(baseDir) ? inputDir2.substring(baseDir.length + 1) : inputDir2;
|
|
4337
|
-
const targetDir2 =
|
|
4338
|
-
const targetPath2 =
|
|
5407
|
+
const targetDir2 = join9(outDir, relativeDir2);
|
|
5408
|
+
const targetPath2 = join9(targetDir2, basename4(resolved));
|
|
4339
5409
|
await fs.mkdir(targetDir2, { recursive: true });
|
|
4340
5410
|
await fs.copyFile(resolved, targetPath2);
|
|
4341
5411
|
allOutputs.push(targetPath2);
|
|
@@ -4347,13 +5417,13 @@ ${fields}
|
|
|
4347
5417
|
if (!existsSync5(actualPath))
|
|
4348
5418
|
return;
|
|
4349
5419
|
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
4350
|
-
const inlined = await inlineResources(sourceCode,
|
|
4351
|
-
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source,
|
|
4352
|
-
const inputDir =
|
|
4353
|
-
const fileBase =
|
|
5420
|
+
const inlined = await inlineResources(sourceCode, dirname5(actualPath), stylePreprocessors);
|
|
5421
|
+
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname5(actualPath)).source;
|
|
5422
|
+
const inputDir = dirname5(actualPath);
|
|
5423
|
+
const fileBase = basename4(actualPath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
4354
5424
|
const targetPath = toOutputPath(actualPath);
|
|
4355
|
-
const targetDir =
|
|
4356
|
-
const relativeDir =
|
|
5425
|
+
const targetDir = dirname5(targetPath);
|
|
5426
|
+
const relativeDir = relative5(outDir, targetDir).replace(/\\/g, "/");
|
|
4357
5427
|
const localImports = [];
|
|
4358
5428
|
const importRewrites = new Map;
|
|
4359
5429
|
const fromRegex = /(?:from|import)\s+['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]/g;
|
|
@@ -4374,19 +5444,20 @@ ${fields}
|
|
|
4374
5444
|
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
4375
5445
|
if (!resolved2)
|
|
4376
5446
|
return null;
|
|
4377
|
-
const relativeImport =
|
|
5447
|
+
const relativeImport = relative5(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
4378
5448
|
const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
|
|
4379
5449
|
importRewrites.set(specifier, relativeRewrite);
|
|
4380
5450
|
return resolved2;
|
|
4381
5451
|
}).filter((path) => Boolean(path));
|
|
4382
|
-
const isEntry =
|
|
5452
|
+
const isEntry = resolve7(actualPath) === resolve7(entryPath);
|
|
4383
5453
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
4384
5454
|
const cacheKey = actualPath;
|
|
4385
5455
|
const shouldWriteFile = cacheBuster && isEntry ? true : jitContentCache.get(cacheKey) !== contentHash || !existsSync5(targetPath);
|
|
4386
5456
|
if (shouldWriteFile) {
|
|
4387
5457
|
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
|
|
5458
|
+
const preservedInjection = await readPreservedInjection(targetPath);
|
|
4388
5459
|
await fs.mkdir(targetDir, { recursive: true });
|
|
4389
|
-
await fs.writeFile(targetPath, processedContent, "utf-8");
|
|
5460
|
+
await fs.writeFile(targetPath, processedContent + preservedInjection, "utf-8");
|
|
4390
5461
|
jitContentCache.set(cacheKey, contentHash);
|
|
4391
5462
|
}
|
|
4392
5463
|
allOutputs.push(targetPath);
|
|
@@ -4413,13 +5484,13 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4413
5484
|
return { clientPaths: [...emptyPaths], serverPaths: [...emptyPaths] };
|
|
4414
5485
|
}
|
|
4415
5486
|
const compiledRoot = compiledParent;
|
|
4416
|
-
const indexesDir =
|
|
5487
|
+
const indexesDir = join9(compiledParent, "indexes");
|
|
4417
5488
|
await traceAngularPhase("setup/create-indexes-dir", () => fs.mkdir(indexesDir, { recursive: true }));
|
|
4418
|
-
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) =>
|
|
5489
|
+
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) => resolve7(entry)), compiledRoot, stylePreprocessors), { entries: entryPoints.length });
|
|
4419
5490
|
if (!hmr) {
|
|
4420
5491
|
await traceAngularPhase("aot/copy-json-resources", async () => {
|
|
4421
5492
|
const cwd = process.cwd();
|
|
4422
|
-
const angularSrcDir =
|
|
5493
|
+
const angularSrcDir = resolve7(outRoot);
|
|
4423
5494
|
if (!existsSync5(angularSrcDir))
|
|
4424
5495
|
return;
|
|
4425
5496
|
const jsonGlob = new Glob("**/*.json");
|
|
@@ -4427,32 +5498,32 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4427
5498
|
absolute: false,
|
|
4428
5499
|
cwd: angularSrcDir
|
|
4429
5500
|
})) {
|
|
4430
|
-
const sourcePath =
|
|
4431
|
-
const cwdRel =
|
|
4432
|
-
const targetPath =
|
|
4433
|
-
await fs.mkdir(
|
|
5501
|
+
const sourcePath = join9(angularSrcDir, rel);
|
|
5502
|
+
const cwdRel = relative5(cwd, sourcePath);
|
|
5503
|
+
const targetPath = join9(compiledRoot, cwdRel);
|
|
5504
|
+
await fs.mkdir(dirname5(targetPath), { recursive: true });
|
|
4434
5505
|
await fs.copyFile(sourcePath, targetPath);
|
|
4435
5506
|
}
|
|
4436
5507
|
});
|
|
4437
5508
|
}
|
|
4438
5509
|
const usesLegacyAngularAnimations = await traceAngularPhase("setup/legacy-animation-resolver", () => createLegacyAngularAnimationUsageResolver(outRoot));
|
|
4439
5510
|
const compileTasks = entryPoints.map(async (entry) => {
|
|
4440
|
-
const resolvedEntry =
|
|
4441
|
-
const relativeEntry =
|
|
5511
|
+
const resolvedEntry = resolve7(entry);
|
|
5512
|
+
const relativeEntry = relative5(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
4442
5513
|
const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
|
|
4443
5514
|
let outputs = hmr ? await traceAngularPhase("jit/compile-entry", compileEntry, {
|
|
4444
5515
|
entry: resolvedEntry
|
|
4445
5516
|
}) : aotOutputs;
|
|
4446
|
-
const fileBase =
|
|
5517
|
+
const fileBase = basename4(resolvedEntry).replace(/\.[tj]s$/, "");
|
|
4447
5518
|
const jsName = `${fileBase}.js`;
|
|
4448
5519
|
const compiledFallbackPaths = [
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
].map((file) =>
|
|
5520
|
+
join9(compiledRoot, relativeEntry),
|
|
5521
|
+
join9(compiledRoot, "pages", jsName),
|
|
5522
|
+
join9(compiledRoot, jsName)
|
|
5523
|
+
].map((file) => resolve7(file));
|
|
4453
5524
|
const resolveRawServerFile = (candidatePaths) => {
|
|
4454
5525
|
const normalizedCandidates = [
|
|
4455
|
-
...candidatePaths.map((file) =>
|
|
5526
|
+
...candidatePaths.map((file) => resolve7(file)),
|
|
4456
5527
|
...compiledFallbackPaths
|
|
4457
5528
|
];
|
|
4458
5529
|
let candidate = normalizedCandidates.find((file) => existsSync5(file) && file.endsWith(`${sep}${relativeEntry}`));
|
|
@@ -4497,9 +5568,11 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4497
5568
|
const pageInjectionForHash = providersInjection?.pagesByFile.get(resolvedEntry);
|
|
4498
5569
|
const providersHashInput = providersInjection ? (() => {
|
|
4499
5570
|
let providersSourceContent = "";
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
5571
|
+
if (providersInjection.appProvidersSource) {
|
|
5572
|
+
try {
|
|
5573
|
+
providersSourceContent = readFileSync5(providersInjection.appProvidersSource, "utf-8");
|
|
5574
|
+
} catch {}
|
|
5575
|
+
}
|
|
4503
5576
|
return JSON.stringify({
|
|
4504
5577
|
basePath: pageInjectionForHash?.basePath ?? null,
|
|
4505
5578
|
hasRoutes: pageInjectionForHash?.hasRoutes ?? false,
|
|
@@ -4508,7 +5581,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4508
5581
|
})() : "no-providers";
|
|
4509
5582
|
const serverContentHash = `${Bun.hash(original).toString(BASE_36_RADIX)}.${Bun.hash(providersHashInput).toString(BASE_36_RADIX)}`;
|
|
4510
5583
|
const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
|
|
4511
|
-
const clientFile =
|
|
5584
|
+
const clientFile = join9(indexesDir, jsName);
|
|
4512
5585
|
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync5(clientFile) && (usesLegacyAnimations || !original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__")) && (!usesLegacyAnimations || original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__"))) {
|
|
4513
5586
|
return {
|
|
4514
5587
|
clientPath: clientFile,
|
|
@@ -4536,20 +5609,22 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4536
5609
|
const pageInjection = providersInjection?.pagesByFile.get(resolvedEntry);
|
|
4537
5610
|
rewritten = rewritten.replace(/\n\/\* __ABS_PROVIDERS_INJECTION_START \*\/[\s\S]*?\/\* __ABS_PROVIDERS_INJECTION_END \*\/\n?/g, "");
|
|
4538
5611
|
if (providersInjection && pageInjection) {
|
|
4539
|
-
const
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
const
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
5612
|
+
const importLines = [];
|
|
5613
|
+
const fragments = [];
|
|
5614
|
+
if (providersInjection.appProvidersSource) {
|
|
5615
|
+
const compiledAppProvidersPath = (() => {
|
|
5616
|
+
const angularDirAbs = resolve7(outRoot);
|
|
5617
|
+
const appSourceAbs = resolve7(providersInjection.appProvidersSource);
|
|
5618
|
+
const rel = relative5(angularDirAbs, appSourceAbs).replace(/\\/g, "/");
|
|
5619
|
+
return join9(compiledParent, rel).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
5620
|
+
})();
|
|
5621
|
+
const appProvidersSpec = (() => {
|
|
5622
|
+
const rel = relative5(dirname5(rawServerFile), compiledAppProvidersPath).replace(/\\/g, "/");
|
|
5623
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
5624
|
+
})();
|
|
5625
|
+
importLines.push(`import { appProviders as __abs_globalProviders } from "${appProvidersSpec}";`);
|
|
5626
|
+
fragments.push("...__abs_globalProviders");
|
|
5627
|
+
}
|
|
4553
5628
|
if (pageInjection.hasRoutes) {
|
|
4554
5629
|
importLines.push(`import { provideRouter as __abs_provideRouter, withComponentInputBinding as __abs_withComponentInputBinding, withViewTransitions as __abs_withViewTransitions } from "@angular/router";`);
|
|
4555
5630
|
fragments.push("__abs_provideRouter(routes, __abs_withComponentInputBinding(), __abs_withViewTransitions())");
|
|
@@ -4558,16 +5633,18 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4558
5633
|
importLines.push(`import { APP_BASE_HREF as __abs_APP_BASE_HREF } from "@angular/common";`);
|
|
4559
5634
|
fragments.push(`{ provide: __abs_APP_BASE_HREF, useValue: ${JSON.stringify(pageInjection.basePath)} }`);
|
|
4560
5635
|
}
|
|
4561
|
-
|
|
5636
|
+
if (fragments.length > 0) {
|
|
5637
|
+
rewritten += `
|
|
4562
5638
|
/* __ABS_PROVIDERS_INJECTION_START */
|
|
4563
5639
|
${importLines.join(`
|
|
4564
5640
|
`)}
|
|
4565
5641
|
export const providers = [${fragments.join(", ")}];
|
|
4566
5642
|
/* __ABS_PROVIDERS_INJECTION_END */
|
|
4567
5643
|
`;
|
|
5644
|
+
}
|
|
4568
5645
|
}
|
|
4569
5646
|
await traceAngularPhase("wrapper/write-server-output", () => fs.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
|
|
4570
|
-
const relativePath =
|
|
5647
|
+
const relativePath = relative5(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
4571
5648
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
4572
5649
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
4573
5650
|
import "${hmrClientPath}";
|
|
@@ -4763,9 +5840,10 @@ var init_compileAngular = __esm(() => {
|
|
|
4763
5840
|
init_stylePreprocessor();
|
|
4764
5841
|
init_generatedDir();
|
|
4765
5842
|
devClientDir = resolveDevClientDir();
|
|
4766
|
-
hmrClientPath =
|
|
5843
|
+
hmrClientPath = join9(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
4767
5844
|
jitContentCache = new Map;
|
|
4768
5845
|
wrapperOutputCache = new Map;
|
|
5846
|
+
PROVIDERS_INJECTION_BLOCK_RE = /\n\/\* __ABS_PROVIDERS_INJECTION_START \*\/[\s\S]*?\/\* __ABS_PROVIDERS_INJECTION_END \*\/\n?/;
|
|
4769
5847
|
});
|
|
4770
5848
|
|
|
4771
5849
|
// src/core/streamingSlotRegistrar.ts
|
|
@@ -4931,13 +6009,11 @@ var provideDeterministicEnv = (options = {}) => {
|
|
|
4931
6009
|
// src/angular/pageHandler.ts
|
|
4932
6010
|
init_constants();
|
|
4933
6011
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
4934
|
-
import { mkdir as
|
|
4935
|
-
import {
|
|
4936
|
-
import { basename as basename4, dirname as dirname5, join as join8, resolve as resolve7 } from "path";
|
|
6012
|
+
import { lstat, mkdir as mkdir4, readlink, symlink } from "fs/promises";
|
|
6013
|
+
import { basename as basename5, dirname as dirname6, join as join10, resolve as resolve8 } from "path";
|
|
4937
6014
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
4938
6015
|
|
|
4939
6016
|
// src/core/islandPageContext.ts
|
|
4940
|
-
init_constants();
|
|
4941
6017
|
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
|
|
4942
6018
|
var ISLAND_MARKER = 'data-island="true"';
|
|
4943
6019
|
var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
|
|
@@ -4962,488 +6038,203 @@ var injectHeadMarkup = (html, markup) => {
|
|
|
4962
6038
|
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
4963
6039
|
}
|
|
4964
6040
|
}
|
|
4965
|
-
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
4966
|
-
};
|
|
4967
|
-
var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
|
|
4968
|
-
var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
4969
|
-
if (pending.length <= lookbehind) {
|
|
4970
|
-
return pending;
|
|
4971
|
-
}
|
|
4972
|
-
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
4973
|
-
controller.enqueue(encoder.encode(safeText));
|
|
4974
|
-
return pending.slice(-lookbehind);
|
|
4975
|
-
};
|
|
4976
|
-
var updateInjectedState = (consumed, injected, pending) => {
|
|
4977
|
-
if (consumed.done) {
|
|
4978
|
-
return { done: true, injected, pending };
|
|
4979
|
-
}
|
|
4980
|
-
return {
|
|
4981
|
-
done: false,
|
|
4982
|
-
injected: consumed.injected,
|
|
4983
|
-
pending: consumed.pending
|
|
4984
|
-
};
|
|
4985
|
-
};
|
|
4986
|
-
var readStreamChunk = async (reader) => {
|
|
4987
|
-
const { done, value } = await reader.read();
|
|
4988
|
-
if (done || !value) {
|
|
4989
|
-
return { done, value: undefined };
|
|
4990
|
-
}
|
|
4991
|
-
return { done, value };
|
|
4992
|
-
};
|
|
4993
|
-
var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
4994
|
-
const encoder = new TextEncoder;
|
|
4995
|
-
const decoder = new TextDecoder;
|
|
4996
|
-
const lookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
4997
|
-
const processPending = (controller, pending, injected) => {
|
|
4998
|
-
if (injected) {
|
|
4999
|
-
controller.enqueue(encoder.encode(pending));
|
|
5000
|
-
return { injected, pending: "" };
|
|
5001
|
-
}
|
|
5002
|
-
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
5003
|
-
if (headIndex >= 0) {
|
|
5004
|
-
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
5005
|
-
controller.enqueue(encoder.encode(next));
|
|
5006
|
-
return { injected: true, pending: "" };
|
|
5007
|
-
}
|
|
5008
|
-
return {
|
|
5009
|
-
injected,
|
|
5010
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
5011
|
-
};
|
|
5012
|
-
};
|
|
5013
|
-
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
5014
|
-
let finalPending = pending + decoder.decode();
|
|
5015
|
-
if (!injected) {
|
|
5016
|
-
finalPending = injectHeadMarkup(finalPending, markup);
|
|
5017
|
-
}
|
|
5018
|
-
if (finalPending.length > 0) {
|
|
5019
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
5020
|
-
}
|
|
5021
|
-
controller.close();
|
|
5022
|
-
};
|
|
5023
|
-
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
5024
|
-
const { done, value } = await readStreamChunk(reader);
|
|
5025
|
-
if (done || !value) {
|
|
5026
|
-
return { done, injected, pending };
|
|
5027
|
-
}
|
|
5028
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
5029
|
-
return {
|
|
5030
|
-
done,
|
|
5031
|
-
injected: processed.injected,
|
|
5032
|
-
pending: processed.pending
|
|
5033
|
-
};
|
|
5034
|
-
};
|
|
5035
|
-
const runHeadInjectionLoop = async (controller, reader) => {
|
|
5036
|
-
const consumeNextHeadChunk = async (injected, pending) => {
|
|
5037
|
-
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
5038
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
5039
|
-
if (nextState.done) {
|
|
5040
|
-
return { injected, pending };
|
|
5041
|
-
}
|
|
5042
|
-
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
5043
|
-
};
|
|
5044
|
-
return consumeNextHeadChunk(false, "");
|
|
5045
|
-
};
|
|
5046
|
-
return new ReadableStream({
|
|
5047
|
-
async start(controller) {
|
|
5048
|
-
const reader = stream.getReader();
|
|
5049
|
-
try {
|
|
5050
|
-
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
5051
|
-
finishHeadInjectionStream(controller, pending, injected);
|
|
5052
|
-
} catch (error) {
|
|
5053
|
-
controller.error(error);
|
|
5054
|
-
}
|
|
5055
|
-
}
|
|
5056
|
-
});
|
|
5057
|
-
};
|
|
5058
|
-
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
5059
|
-
const encoder = new TextEncoder;
|
|
5060
|
-
const decoder = new TextDecoder;
|
|
5061
|
-
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
5062
|
-
const processPending = (controller, pending, injected) => {
|
|
5063
|
-
if (injected) {
|
|
5064
|
-
controller.enqueue(encoder.encode(pending));
|
|
5065
|
-
return { injected, pending: "" };
|
|
5066
|
-
}
|
|
5067
|
-
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
5068
|
-
if (markerIndex >= 0) {
|
|
5069
|
-
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
5070
|
-
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
5071
|
-
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
5072
|
-
controller.enqueue(encoder.encode(next));
|
|
5073
|
-
return { injected: true, pending: "" };
|
|
5074
|
-
}
|
|
5075
|
-
return {
|
|
5076
|
-
injected,
|
|
5077
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
5078
|
-
};
|
|
5079
|
-
};
|
|
5080
|
-
const finishIslandMarkerStream = (controller, pending) => {
|
|
5081
|
-
const finalPending = pending + decoder.decode();
|
|
5082
|
-
if (finalPending.length > 0) {
|
|
5083
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
5084
|
-
}
|
|
5085
|
-
controller.close();
|
|
5086
|
-
};
|
|
5087
|
-
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
5088
|
-
const { done, value } = await readStreamChunk(reader);
|
|
5089
|
-
if (done || !value) {
|
|
5090
|
-
return { done, injected, pending };
|
|
5091
|
-
}
|
|
5092
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
5093
|
-
return {
|
|
5094
|
-
done,
|
|
5095
|
-
injected: processed.injected,
|
|
5096
|
-
pending: processed.pending
|
|
5097
|
-
};
|
|
5098
|
-
};
|
|
5099
|
-
const runIslandMarkerLoop = async (controller, reader) => {
|
|
5100
|
-
const consumeNextIslandChunk = async (injected, pending) => {
|
|
5101
|
-
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
5102
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
5103
|
-
if (nextState.done) {
|
|
5104
|
-
return { injected, pending };
|
|
5105
|
-
}
|
|
5106
|
-
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
5107
|
-
};
|
|
5108
|
-
return consumeNextIslandChunk(false, "");
|
|
5109
|
-
};
|
|
5110
|
-
return new ReadableStream({
|
|
5111
|
-
async start(controller) {
|
|
5112
|
-
const reader = stream.getReader();
|
|
5113
|
-
try {
|
|
5114
|
-
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
5115
|
-
finishIslandMarkerStream(controller, pending);
|
|
5116
|
-
} catch (error) {
|
|
5117
|
-
controller.error(error);
|
|
5118
|
-
}
|
|
5119
|
-
}
|
|
5120
|
-
});
|
|
5121
|
-
};
|
|
5122
|
-
var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
|
|
5123
|
-
var injectIslandPageContext = (html, options) => {
|
|
5124
|
-
const manifest = globalThis.__absoluteManifest;
|
|
5125
|
-
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
5126
|
-
if (!manifest || !hasIslands) {
|
|
5127
|
-
return html;
|
|
5128
|
-
}
|
|
5129
|
-
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
5130
|
-
return html;
|
|
5131
|
-
}
|
|
5132
|
-
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
5133
|
-
};
|
|
5134
|
-
var injectIslandPageContextStream = (stream, options) => {
|
|
5135
|
-
const manifest = globalThis.__absoluteManifest;
|
|
5136
|
-
if (!manifest)
|
|
5137
|
-
return stream;
|
|
5138
|
-
const markup = buildIslandsHeadMarkup(manifest);
|
|
5139
|
-
if (options?.hasIslands === true) {
|
|
5140
|
-
return pipeStreamWithHeadInjection(stream, markup);
|
|
5141
|
-
}
|
|
5142
|
-
if (options?.hasIslands === false) {
|
|
5143
|
-
return stream;
|
|
5144
|
-
}
|
|
5145
|
-
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
5146
|
-
};
|
|
5147
|
-
var setCurrentIslandManifest = (manifest) => {
|
|
5148
|
-
globalThis.__absoluteManifest = manifest;
|
|
5149
|
-
};
|
|
5150
|
-
// src/utils/resolveConvention.ts
|
|
5151
|
-
import { basename } from "path";
|
|
5152
|
-
var CONVENTIONS_KEY = "__absoluteConventions";
|
|
5153
|
-
var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
|
|
5154
|
-
var getMap = () => {
|
|
5155
|
-
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
5156
|
-
if (isConventionsMap(value))
|
|
5157
|
-
return value;
|
|
5158
|
-
const empty = {};
|
|
5159
|
-
return empty;
|
|
5160
|
-
};
|
|
5161
|
-
var derivePageName = (pagePath) => {
|
|
5162
|
-
const base = basename(pagePath);
|
|
5163
|
-
const dotIndex = base.indexOf(".");
|
|
5164
|
-
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
5165
|
-
return toPascal(name);
|
|
5166
|
-
};
|
|
5167
|
-
var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
|
|
5168
|
-
var resolveErrorConventionPath = (framework, pageName) => {
|
|
5169
|
-
const conventions = getMap()[framework];
|
|
5170
|
-
if (!conventions)
|
|
5171
|
-
return;
|
|
5172
|
-
const exact = conventions.pages?.[pageName]?.error;
|
|
5173
|
-
if (exact)
|
|
5174
|
-
return exact;
|
|
5175
|
-
const normalizedPageName = normalizeConventionPageName(pageName);
|
|
5176
|
-
for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
|
|
5177
|
-
if (normalizeConventionPageName(candidate) === normalizedPageName) {
|
|
5178
|
-
return page.error ?? conventions.defaults?.error;
|
|
5179
|
-
}
|
|
5180
|
-
}
|
|
5181
|
-
return conventions.defaults?.error;
|
|
5182
|
-
};
|
|
5183
|
-
var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
|
|
5184
|
-
var hasErrorConvention = (framework) => {
|
|
5185
|
-
const conventions = getMap()[framework];
|
|
5186
|
-
if (!conventions)
|
|
5187
|
-
return false;
|
|
5188
|
-
if (conventions.defaults?.error)
|
|
5189
|
-
return true;
|
|
5190
|
-
return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
|
|
5191
|
-
};
|
|
5192
|
-
var setConventions = (map) => {
|
|
5193
|
-
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
5194
|
-
};
|
|
5195
|
-
var isDev = () => true;
|
|
5196
|
-
var buildErrorProps = (error) => {
|
|
5197
|
-
if (error instanceof Error) {
|
|
5198
|
-
return {
|
|
5199
|
-
name: error.name,
|
|
5200
|
-
message: error.message,
|
|
5201
|
-
...isDev() && error.stack ? { stack: error.stack } : {}
|
|
5202
|
-
};
|
|
5203
|
-
}
|
|
5204
|
-
return { name: "Error", message: String(error) };
|
|
5205
|
-
};
|
|
5206
|
-
var renderReactError = async (conventionPath, errorProps) => {
|
|
5207
|
-
const { createElement } = await import("react");
|
|
5208
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
5209
|
-
const mod = await import(conventionPath);
|
|
5210
|
-
const ErrorComponent = mod.default;
|
|
5211
|
-
if (typeof ErrorComponent !== "function")
|
|
5212
|
-
return null;
|
|
5213
|
-
const element = createElement(ErrorComponent, errorProps);
|
|
5214
|
-
const stream = await renderToReadableStream(element);
|
|
5215
|
-
return new Response(stream, {
|
|
5216
|
-
headers: { "Content-Type": "text/html" },
|
|
5217
|
-
status: 500
|
|
5218
|
-
});
|
|
5219
|
-
};
|
|
5220
|
-
var renderSvelteError = async (conventionPath, errorProps) => {
|
|
5221
|
-
const { render } = await import("svelte/server");
|
|
5222
|
-
const mod = await import(conventionPath);
|
|
5223
|
-
const ErrorComponent = mod.default;
|
|
5224
|
-
if (!ErrorComponent)
|
|
5225
|
-
return null;
|
|
5226
|
-
const { head, body } = render(ErrorComponent, {
|
|
5227
|
-
props: errorProps
|
|
5228
|
-
});
|
|
5229
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
5230
|
-
return new Response(html, {
|
|
5231
|
-
headers: { "Content-Type": "text/html" },
|
|
5232
|
-
status: 500
|
|
5233
|
-
});
|
|
5234
|
-
};
|
|
5235
|
-
var unescapeVueStyles = (ssrBody) => {
|
|
5236
|
-
let styles = "";
|
|
5237
|
-
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
5238
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
5239
|
-
return "";
|
|
5240
|
-
});
|
|
5241
|
-
return { body, styles };
|
|
5242
|
-
};
|
|
5243
|
-
var renderVueError = async (conventionPath, errorProps) => {
|
|
5244
|
-
const { createSSRApp, h } = await import("vue");
|
|
5245
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
5246
|
-
const mod = await import(conventionPath);
|
|
5247
|
-
const ErrorComponent = mod.default;
|
|
5248
|
-
if (!ErrorComponent)
|
|
5249
|
-
return null;
|
|
5250
|
-
const app = createSSRApp({
|
|
5251
|
-
render: () => h(ErrorComponent, errorProps)
|
|
5252
|
-
});
|
|
5253
|
-
const rawBody = await renderToString(app);
|
|
5254
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
5255
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
5256
|
-
return new Response(html, {
|
|
5257
|
-
headers: { "Content-Type": "text/html" },
|
|
5258
|
-
status: 500
|
|
5259
|
-
});
|
|
5260
|
-
};
|
|
5261
|
-
var renderAngularError = async (conventionPath, errorProps) => {
|
|
5262
|
-
const mod = await import(conventionPath);
|
|
5263
|
-
const renderFn = mod.default;
|
|
5264
|
-
if (typeof renderFn !== "function")
|
|
5265
|
-
return null;
|
|
5266
|
-
const html = renderFn(errorProps);
|
|
5267
|
-
return new Response(html, {
|
|
5268
|
-
headers: { "Content-Type": "text/html" },
|
|
5269
|
-
status: 500
|
|
5270
|
-
});
|
|
5271
|
-
};
|
|
5272
|
-
var escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5273
|
-
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) : "");
|
|
5274
|
-
var renderHtmlError = async (conventionPath, errorProps) => {
|
|
5275
|
-
const template = await Bun.file(conventionPath).text();
|
|
5276
|
-
const html = replaceErrorTokens(template, errorProps);
|
|
5277
|
-
return new Response(html, {
|
|
5278
|
-
headers: { "Content-Type": "text/html" },
|
|
5279
|
-
status: 500
|
|
5280
|
-
});
|
|
5281
|
-
};
|
|
5282
|
-
var logConventionRenderError = (framework, label, renderError) => {
|
|
5283
|
-
const message = renderError instanceof Error ? renderError.message : "";
|
|
5284
|
-
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
5285
|
-
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}).`);
|
|
5286
|
-
return;
|
|
5287
|
-
}
|
|
5288
|
-
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
5289
|
-
};
|
|
5290
|
-
var renderEmberError = async () => null;
|
|
5291
|
-
var renderEmberNotFound = async () => null;
|
|
5292
|
-
var ERROR_RENDERERS = {
|
|
5293
|
-
angular: renderAngularError,
|
|
5294
|
-
ember: renderEmberError,
|
|
5295
|
-
html: renderHtmlError,
|
|
5296
|
-
react: renderReactError,
|
|
5297
|
-
svelte: renderSvelteError,
|
|
5298
|
-
vue: renderVueError
|
|
5299
|
-
};
|
|
5300
|
-
var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
|
|
5301
|
-
let conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
5302
|
-
if (!conventionPath && error instanceof Error && error.stack) {
|
|
5303
|
-
for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
|
|
5304
|
-
const candidate = match[1];
|
|
5305
|
-
if (!candidate)
|
|
5306
|
-
continue;
|
|
5307
|
-
conventionPath = resolveErrorConventionPath(framework, candidate);
|
|
5308
|
-
if (conventionPath)
|
|
5309
|
-
break;
|
|
5310
|
-
}
|
|
5311
|
-
}
|
|
5312
|
-
if (!conventionPath)
|
|
5313
|
-
return null;
|
|
5314
|
-
const renderer = ERROR_RENDERERS[framework];
|
|
5315
|
-
if (!renderer)
|
|
5316
|
-
return null;
|
|
5317
|
-
try {
|
|
5318
|
-
return await renderer(conventionPath, errorProps);
|
|
5319
|
-
} catch (renderError) {
|
|
5320
|
-
logConventionRenderError(framework, "error", renderError);
|
|
5321
|
-
}
|
|
5322
|
-
return null;
|
|
6041
|
+
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
5323
6042
|
};
|
|
5324
|
-
var
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
return frameworkResponse;
|
|
5329
|
-
if (framework !== "html") {
|
|
5330
|
-
const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
|
|
5331
|
-
if (htmlResponse)
|
|
5332
|
-
return htmlResponse;
|
|
6043
|
+
var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
|
|
6044
|
+
var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
6045
|
+
if (pending.length <= lookbehind) {
|
|
6046
|
+
return pending;
|
|
5333
6047
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
const { createElement } = await import("react");
|
|
5338
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
5339
|
-
const mod = await import(conventionPath);
|
|
5340
|
-
const NotFoundComponent = mod.default;
|
|
5341
|
-
if (typeof NotFoundComponent !== "function")
|
|
5342
|
-
return null;
|
|
5343
|
-
const element = createElement(NotFoundComponent);
|
|
5344
|
-
const stream = await renderToReadableStream(element);
|
|
5345
|
-
return new Response(stream, {
|
|
5346
|
-
headers: { "Content-Type": "text/html" },
|
|
5347
|
-
status: 404
|
|
5348
|
-
});
|
|
6048
|
+
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
6049
|
+
controller.enqueue(encoder.encode(safeText));
|
|
6050
|
+
return pending.slice(-lookbehind);
|
|
5349
6051
|
};
|
|
5350
|
-
var
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
headers: { "Content-Type": "text/html" },
|
|
5360
|
-
status: 404
|
|
5361
|
-
});
|
|
6052
|
+
var updateInjectedState = (consumed, injected, pending) => {
|
|
6053
|
+
if (consumed.done) {
|
|
6054
|
+
return { done: true, injected, pending };
|
|
6055
|
+
}
|
|
6056
|
+
return {
|
|
6057
|
+
done: false,
|
|
6058
|
+
injected: consumed.injected,
|
|
6059
|
+
pending: consumed.pending
|
|
6060
|
+
};
|
|
5362
6061
|
};
|
|
5363
|
-
var
|
|
5364
|
-
const {
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
return null;
|
|
5370
|
-
const app = createSSRApp({
|
|
5371
|
-
render: () => h(NotFoundComponent)
|
|
5372
|
-
});
|
|
5373
|
-
const rawBody = await renderToString(app);
|
|
5374
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
5375
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
5376
|
-
return new Response(html, {
|
|
5377
|
-
headers: { "Content-Type": "text/html" },
|
|
5378
|
-
status: 404
|
|
5379
|
-
});
|
|
6062
|
+
var readStreamChunk = async (reader) => {
|
|
6063
|
+
const { done, value } = await reader.read();
|
|
6064
|
+
if (done || !value) {
|
|
6065
|
+
return { done, value: undefined };
|
|
6066
|
+
}
|
|
6067
|
+
return { done, value };
|
|
5380
6068
|
};
|
|
5381
|
-
var
|
|
5382
|
-
const
|
|
5383
|
-
const
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
6069
|
+
var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
6070
|
+
const encoder = new TextEncoder;
|
|
6071
|
+
const decoder = new TextDecoder;
|
|
6072
|
+
const lookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
6073
|
+
const processPending = (controller, pending, injected) => {
|
|
6074
|
+
if (injected) {
|
|
6075
|
+
controller.enqueue(encoder.encode(pending));
|
|
6076
|
+
return { injected, pending: "" };
|
|
6077
|
+
}
|
|
6078
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
6079
|
+
if (headIndex >= 0) {
|
|
6080
|
+
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
6081
|
+
controller.enqueue(encoder.encode(next));
|
|
6082
|
+
return { injected: true, pending: "" };
|
|
6083
|
+
}
|
|
6084
|
+
return {
|
|
6085
|
+
injected,
|
|
6086
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
6087
|
+
};
|
|
6088
|
+
};
|
|
6089
|
+
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
6090
|
+
let finalPending = pending + decoder.decode();
|
|
6091
|
+
if (!injected) {
|
|
6092
|
+
finalPending = injectHeadMarkup(finalPending, markup);
|
|
6093
|
+
}
|
|
6094
|
+
if (finalPending.length > 0) {
|
|
6095
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
6096
|
+
}
|
|
6097
|
+
controller.close();
|
|
6098
|
+
};
|
|
6099
|
+
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
6100
|
+
const { done, value } = await readStreamChunk(reader);
|
|
6101
|
+
if (done || !value) {
|
|
6102
|
+
return { done, injected, pending };
|
|
6103
|
+
}
|
|
6104
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
6105
|
+
return {
|
|
6106
|
+
done,
|
|
6107
|
+
injected: processed.injected,
|
|
6108
|
+
pending: processed.pending
|
|
6109
|
+
};
|
|
6110
|
+
};
|
|
6111
|
+
const runHeadInjectionLoop = async (controller, reader) => {
|
|
6112
|
+
const consumeNextHeadChunk = async (injected, pending) => {
|
|
6113
|
+
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
6114
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
6115
|
+
if (nextState.done) {
|
|
6116
|
+
return { injected, pending };
|
|
6117
|
+
}
|
|
6118
|
+
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
6119
|
+
};
|
|
6120
|
+
return consumeNextHeadChunk(false, "");
|
|
6121
|
+
};
|
|
6122
|
+
return new ReadableStream({
|
|
6123
|
+
async start(controller) {
|
|
6124
|
+
const reader = stream.getReader();
|
|
6125
|
+
try {
|
|
6126
|
+
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
6127
|
+
finishHeadInjectionStream(controller, pending, injected);
|
|
6128
|
+
} catch (error) {
|
|
6129
|
+
controller.error(error);
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
5390
6132
|
});
|
|
5391
6133
|
};
|
|
5392
|
-
var
|
|
5393
|
-
const
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
6134
|
+
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
6135
|
+
const encoder = new TextEncoder;
|
|
6136
|
+
const decoder = new TextDecoder;
|
|
6137
|
+
const headLookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
6138
|
+
const enqueue = (controller, text) => {
|
|
6139
|
+
if (text.length > 0) {
|
|
6140
|
+
controller.enqueue(encoder.encode(text));
|
|
6141
|
+
}
|
|
6142
|
+
};
|
|
6143
|
+
const processHolding = (controller, held) => {
|
|
6144
|
+
if (!held.includes(ISLAND_MARKER)) {
|
|
6145
|
+
return { held, injected: false, pending: "", sawHead: true };
|
|
6146
|
+
}
|
|
6147
|
+
enqueue(controller, `${markup}${held}`);
|
|
6148
|
+
return { held: "", injected: true, pending: "", sawHead: true };
|
|
6149
|
+
};
|
|
6150
|
+
const processHead = (controller, pending) => {
|
|
6151
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
6152
|
+
if (headIndex < 0) {
|
|
6153
|
+
return {
|
|
6154
|
+
held: "",
|
|
6155
|
+
injected: false,
|
|
6156
|
+
pending: flushSafePendingText(controller, encoder, pending, headLookbehind),
|
|
6157
|
+
sawHead: false
|
|
6158
|
+
};
|
|
6159
|
+
}
|
|
6160
|
+
enqueue(controller, pending.slice(0, headIndex));
|
|
6161
|
+
return processHolding(controller, pending.slice(headIndex));
|
|
6162
|
+
};
|
|
6163
|
+
const processChunk = (controller, state, chunk) => {
|
|
6164
|
+
if (state.injected) {
|
|
6165
|
+
enqueue(controller, chunk);
|
|
6166
|
+
return state;
|
|
6167
|
+
}
|
|
6168
|
+
if (!state.sawHead) {
|
|
6169
|
+
return processHead(controller, state.pending + chunk);
|
|
6170
|
+
}
|
|
6171
|
+
return processHolding(controller, state.held + chunk);
|
|
6172
|
+
};
|
|
6173
|
+
const finishMarkerStream = (controller, state) => {
|
|
6174
|
+
const tail = decoder.decode();
|
|
6175
|
+
const remainder = state.injected ? tail : (state.sawHead ? state.held : state.pending) + tail;
|
|
6176
|
+
enqueue(controller, remainder);
|
|
6177
|
+
controller.close();
|
|
6178
|
+
};
|
|
6179
|
+
const runMarkerLoop = (controller, reader) => {
|
|
6180
|
+
const consumeNext = async (state) => {
|
|
6181
|
+
const { done, value } = await readStreamChunk(reader);
|
|
6182
|
+
if (done || !value) {
|
|
6183
|
+
return state;
|
|
6184
|
+
}
|
|
6185
|
+
return consumeNext(processChunk(controller, state, streamChunkToString(value, decoder)));
|
|
6186
|
+
};
|
|
6187
|
+
return consumeNext({
|
|
6188
|
+
held: "",
|
|
6189
|
+
injected: false,
|
|
6190
|
+
pending: "",
|
|
6191
|
+
sawHead: false
|
|
6192
|
+
});
|
|
6193
|
+
};
|
|
6194
|
+
return new ReadableStream({
|
|
6195
|
+
async start(controller) {
|
|
6196
|
+
const reader = stream.getReader();
|
|
6197
|
+
try {
|
|
6198
|
+
const finalState = await runMarkerLoop(controller, reader);
|
|
6199
|
+
finishMarkerStream(controller, finalState);
|
|
6200
|
+
} catch (error) {
|
|
6201
|
+
controller.error(error);
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
5397
6204
|
});
|
|
5398
6205
|
};
|
|
5399
|
-
var
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
html
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
6206
|
+
var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
|
|
6207
|
+
var injectIslandPageContext = (html, options) => {
|
|
6208
|
+
const manifest = globalThis.__absoluteManifest;
|
|
6209
|
+
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
6210
|
+
if (!manifest || !hasIslands) {
|
|
6211
|
+
return html;
|
|
6212
|
+
}
|
|
6213
|
+
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
6214
|
+
return html;
|
|
6215
|
+
}
|
|
6216
|
+
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
5406
6217
|
};
|
|
5407
|
-
var
|
|
5408
|
-
const
|
|
5409
|
-
if (!
|
|
5410
|
-
return
|
|
5411
|
-
const
|
|
5412
|
-
if (
|
|
5413
|
-
return
|
|
5414
|
-
try {
|
|
5415
|
-
return await renderer(conventionPath);
|
|
5416
|
-
} catch (renderError) {
|
|
5417
|
-
logConventionRenderError(framework, "not-found", renderError);
|
|
6218
|
+
var injectIslandPageContextStream = (stream, options) => {
|
|
6219
|
+
const manifest = globalThis.__absoluteManifest;
|
|
6220
|
+
if (!manifest)
|
|
6221
|
+
return stream;
|
|
6222
|
+
const markup = buildIslandsHeadMarkup(manifest);
|
|
6223
|
+
if (options?.hasIslands === true) {
|
|
6224
|
+
return pipeStreamWithHeadInjection(stream, markup);
|
|
5418
6225
|
}
|
|
5419
|
-
|
|
6226
|
+
if (options?.hasIslands === false) {
|
|
6227
|
+
return stream;
|
|
6228
|
+
}
|
|
6229
|
+
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
5420
6230
|
};
|
|
5421
|
-
var
|
|
5422
|
-
|
|
5423
|
-
"svelte",
|
|
5424
|
-
"vue",
|
|
5425
|
-
"angular",
|
|
5426
|
-
"html"
|
|
5427
|
-
];
|
|
5428
|
-
var renderFirstNotFound = async () => {
|
|
5429
|
-
const renderNext = async (frameworks) => {
|
|
5430
|
-
const [framework, ...remaining] = frameworks;
|
|
5431
|
-
if (!framework) {
|
|
5432
|
-
return null;
|
|
5433
|
-
}
|
|
5434
|
-
if (!getMap()[framework]?.defaults?.notFound) {
|
|
5435
|
-
return renderNext(remaining);
|
|
5436
|
-
}
|
|
5437
|
-
const response = await renderConventionNotFound(framework);
|
|
5438
|
-
if (response) {
|
|
5439
|
-
return response;
|
|
5440
|
-
}
|
|
5441
|
-
return renderNext(remaining);
|
|
5442
|
-
};
|
|
5443
|
-
return renderNext(NOT_FOUND_PRIORITY);
|
|
6231
|
+
var setCurrentIslandManifest = (manifest) => {
|
|
6232
|
+
globalThis.__absoluteManifest = manifest;
|
|
5444
6233
|
};
|
|
5445
6234
|
|
|
5446
6235
|
// src/angular/pageHandler.ts
|
|
6236
|
+
init_inlinePageCss();
|
|
6237
|
+
init_resolveConvention();
|
|
5447
6238
|
init_registerClientScript();
|
|
5448
6239
|
init_angularDeps();
|
|
5449
6240
|
|
|
@@ -5522,6 +6313,9 @@ var buildRouterRedirectProviders = async (deps, responseInit) => {
|
|
|
5522
6313
|
];
|
|
5523
6314
|
};
|
|
5524
6315
|
|
|
6316
|
+
// src/angular/pageHandler.ts
|
|
6317
|
+
init_spaRouteManifest();
|
|
6318
|
+
|
|
5525
6319
|
// src/angular/lowerServerIslands.ts
|
|
5526
6320
|
init_renderIslandMarkup();
|
|
5527
6321
|
var ANGULAR_ISLAND_TAG_RE = /<absolute-island\b([^>]*)>[\s\S]*?<\/absolute-island>/gi;
|
|
@@ -5661,8 +6455,12 @@ var resetSsrSanitizer = () => {
|
|
|
5661
6455
|
ssrSanitizer = null;
|
|
5662
6456
|
};
|
|
5663
6457
|
|
|
6458
|
+
// src/angular/pageHandler.ts
|
|
6459
|
+
init_pageResponseCache();
|
|
6460
|
+
|
|
5664
6461
|
// src/core/responseEnhancers.ts
|
|
5665
6462
|
init_streamingSlots();
|
|
6463
|
+
init_pageResponseCache();
|
|
5666
6464
|
var toResponse = async (responseLike) => responseLike;
|
|
5667
6465
|
var cloneHeaders = (response) => {
|
|
5668
6466
|
const headers = new Headers(response.headers);
|
|
@@ -5686,8 +6484,10 @@ var enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
|
5686
6484
|
runtimePlacement,
|
|
5687
6485
|
runtimePreludeScript
|
|
5688
6486
|
});
|
|
6487
|
+
const headers = cloneHeaders(response);
|
|
6488
|
+
headers.set(STREAMING_PAGE_HEADER, "1");
|
|
5689
6489
|
return new Response(body, {
|
|
5690
|
-
headers
|
|
6490
|
+
headers,
|
|
5691
6491
|
status: response.status,
|
|
5692
6492
|
statusText: response.statusText
|
|
5693
6493
|
});
|
|
@@ -5770,15 +6570,40 @@ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage(
|
|
|
5770
6570
|
|
|
5771
6571
|
// src/angular/pageHandler.ts
|
|
5772
6572
|
init_ssrRender();
|
|
5773
|
-
var lastSelector = "angular-page";
|
|
5774
6573
|
var isRecord5 = (value) => typeof value === "object" && value !== null;
|
|
5775
6574
|
var isAngularComponent2 = (value) => typeof value === "function";
|
|
6575
|
+
var componentHostsRouterOutlet = (component) => {
|
|
6576
|
+
const componentDef = Reflect.get(component, "\u0275cmp");
|
|
6577
|
+
if (!isRecord5(componentDef))
|
|
6578
|
+
return false;
|
|
6579
|
+
const rawDependencies = componentDef.dependencies;
|
|
6580
|
+
const dependencies = typeof rawDependencies === "function" ? Reflect.apply(rawDependencies, undefined, []) : rawDependencies;
|
|
6581
|
+
if (!Array.isArray(dependencies))
|
|
6582
|
+
return false;
|
|
6583
|
+
return dependencies.some((dependency) => {
|
|
6584
|
+
if (dependency === null || typeof dependency !== "object" && typeof dependency !== "function")
|
|
6585
|
+
return false;
|
|
6586
|
+
const directiveDef = Reflect.get(dependency, "\u0275dir") ?? dependency;
|
|
6587
|
+
if (!isRecord5(directiveDef))
|
|
6588
|
+
return false;
|
|
6589
|
+
const { selectors } = directiveDef;
|
|
6590
|
+
return Array.isArray(selectors) && JSON.stringify(selectors).includes("router-outlet");
|
|
6591
|
+
});
|
|
6592
|
+
};
|
|
5776
6593
|
var resolvePageComponent = (pageModule) => {
|
|
5777
6594
|
const defaultExport = pageModule.default;
|
|
5778
6595
|
if (isAngularComponent2(defaultExport)) {
|
|
5779
6596
|
return defaultExport;
|
|
5780
6597
|
}
|
|
5781
|
-
|
|
6598
|
+
const components = Object.values(pageModule).filter(isAngularComponent2);
|
|
6599
|
+
if (components.length <= 1) {
|
|
6600
|
+
return components[0];
|
|
6601
|
+
}
|
|
6602
|
+
const outletHosts = components.filter(componentHostsRouterOutlet);
|
|
6603
|
+
if (outletHosts.length === 1) {
|
|
6604
|
+
return outletHosts[0];
|
|
6605
|
+
}
|
|
6606
|
+
return components.at(-1);
|
|
5782
6607
|
};
|
|
5783
6608
|
var compilerImportPromise = null;
|
|
5784
6609
|
var ensureAngularCompiler = () => {
|
|
@@ -5790,27 +6615,48 @@ var ensureAngularCompiler = () => {
|
|
|
5790
6615
|
return compilerImportPromise;
|
|
5791
6616
|
};
|
|
5792
6617
|
var readAngularPageModule = (value) => isRecord5(value) ? value : null;
|
|
5793
|
-
var resolveAngularSsrOutDir = ()
|
|
6618
|
+
var resolveAngularSsrOutDir = (projectRoot = process.cwd(), configuredOutDir = process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) => configuredOutDir ?? join10(projectRoot, ".absolutejs", "runtime", "angular-ssr");
|
|
5794
6619
|
var createAngularRuntimeCacheBuster = () => `${Date.now().toString(BASE_36_RADIX)}.${Math.random().toString(BASE_36_RADIX).substring(2, RANDOM_ID_END_INDEX)}`;
|
|
5795
|
-
var
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
6620
|
+
var existingNodeModulesLinkMatches = async (nodeModulesLink, expectedTarget) => {
|
|
6621
|
+
try {
|
|
6622
|
+
const stats = await lstat(nodeModulesLink);
|
|
6623
|
+
if (!stats.isSymbolicLink()) {
|
|
6624
|
+
throw new Error(`Refusing non-symlink Angular SSR dependency path: ${nodeModulesLink}`);
|
|
6625
|
+
}
|
|
6626
|
+
const target = resolve8(dirname6(nodeModulesLink), await readlink(nodeModulesLink));
|
|
6627
|
+
if (target !== expectedTarget) {
|
|
6628
|
+
throw new Error(`Refusing Angular SSR dependency link outside this project: ${target}`);
|
|
6629
|
+
}
|
|
6630
|
+
return true;
|
|
6631
|
+
} catch (error) {
|
|
6632
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
6633
|
+
return false;
|
|
6634
|
+
}
|
|
6635
|
+
throw error;
|
|
6636
|
+
}
|
|
6637
|
+
};
|
|
6638
|
+
var ensureAngularSsrNodeModules = async (outDir, projectRoot = process.cwd(), hasConfiguredOutDir = Boolean(process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR)) => {
|
|
6639
|
+
const outRoot = resolve8(dirname6(dirname6(outDir)));
|
|
6640
|
+
const nodeModulesLink = join10(outRoot, "node_modules");
|
|
6641
|
+
if (hasConfiguredOutDir) {
|
|
5799
6642
|
return;
|
|
5800
6643
|
}
|
|
5801
|
-
|
|
6644
|
+
const expectedTarget = resolve8(projectRoot, "node_modules");
|
|
6645
|
+
if (nodeModulesLink === expectedTarget) {
|
|
5802
6646
|
return;
|
|
5803
6647
|
}
|
|
5804
|
-
if (await
|
|
6648
|
+
if (await existingNodeModulesLinkMatches(nodeModulesLink, expectedTarget)) {
|
|
5805
6649
|
return;
|
|
5806
6650
|
}
|
|
5807
|
-
await
|
|
6651
|
+
await mkdir4(outRoot, { recursive: true });
|
|
5808
6652
|
try {
|
|
5809
|
-
await symlink(
|
|
6653
|
+
await symlink(expectedTarget, nodeModulesLink, "dir");
|
|
5810
6654
|
} catch (error) {
|
|
5811
|
-
if (!(error instanceof Error) || !("code" in error)
|
|
6655
|
+
if (!(error instanceof Error) || !("code" in error))
|
|
5812
6656
|
throw error;
|
|
5813
|
-
|
|
6657
|
+
if (error.code !== "EEXIST")
|
|
6658
|
+
throw error;
|
|
6659
|
+
await existingNodeModulesLinkMatches(nodeModulesLink, expectedTarget);
|
|
5814
6660
|
}
|
|
5815
6661
|
};
|
|
5816
6662
|
var resolveRuntimeAngularModulePath = async (pagePath) => {
|
|
@@ -5820,16 +6666,16 @@ var resolveRuntimeAngularModulePath = async (pagePath) => {
|
|
|
5820
6666
|
const { stat } = await import("fs/promises");
|
|
5821
6667
|
const stats = await stat(pagePath);
|
|
5822
6668
|
return {
|
|
5823
|
-
|
|
5824
|
-
|
|
6669
|
+
cacheBuster: stats.mtimeMs.toString(BASE_36_RADIX),
|
|
6670
|
+
path: pagePath
|
|
5825
6671
|
};
|
|
5826
6672
|
} catch {
|
|
5827
|
-
return {
|
|
6673
|
+
return { cacheBuster: undefined, path: pagePath };
|
|
5828
6674
|
}
|
|
5829
6675
|
}
|
|
5830
6676
|
return {
|
|
5831
|
-
|
|
5832
|
-
|
|
6677
|
+
cacheBuster: undefined,
|
|
6678
|
+
path: pagePath
|
|
5833
6679
|
};
|
|
5834
6680
|
}
|
|
5835
6681
|
const outDir = resolveAngularSsrOutDir();
|
|
@@ -5837,11 +6683,11 @@ var resolveRuntimeAngularModulePath = async (pagePath) => {
|
|
|
5837
6683
|
const { compileAngularFileJIT: compileAngularFileJIT2 } = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
|
|
5838
6684
|
const cacheBuster = createAngularRuntimeCacheBuster();
|
|
5839
6685
|
const outputs = await compileAngularFileJIT2(pagePath, outDir, process.cwd(), undefined, cacheBuster);
|
|
5840
|
-
const expectedFileName =
|
|
6686
|
+
const expectedFileName = basename5(pagePath).replace(/\.ts$/, ".js");
|
|
5841
6687
|
const runtimePagePath = outputs.find((output) => output.endsWith(`/${expectedFileName}`)) ?? outputs.find((output) => output.endsWith(`\\${expectedFileName}`)) ?? outputs[0] ?? pagePath;
|
|
5842
6688
|
return {
|
|
5843
|
-
|
|
5844
|
-
|
|
6689
|
+
cacheBuster,
|
|
6690
|
+
path: runtimePagePath
|
|
5845
6691
|
};
|
|
5846
6692
|
};
|
|
5847
6693
|
var buildRuntimeModuleSpecifier = (modulePath, cacheBuster) => {
|
|
@@ -5874,14 +6720,19 @@ setSsrContextGetter(() => angularSsrContext.getStore());
|
|
|
5874
6720
|
var handleAngularPageRequest = async (input) => {
|
|
5875
6721
|
const requestId = `angular_${Date.now()}_${Math.random().toString(BASE_36_RADIX).substring(2, RANDOM_ID_END_INDEX)}`;
|
|
5876
6722
|
return angularSsrContext.run(requestId, async () => {
|
|
6723
|
+
const spaNotFound = await renderSpaNotFound("angular", derivePageName(input.pagePath), input.request);
|
|
6724
|
+
if (spaNotFound)
|
|
6725
|
+
return withPageCacheHeaders(spaNotFound, input.request);
|
|
5877
6726
|
await ensureAngularCompiler();
|
|
5878
|
-
const
|
|
6727
|
+
const userHeadTag = input.headTag ?? "<head></head>";
|
|
5879
6728
|
const resolvedIndexPath = input.indexPath;
|
|
5880
6729
|
const options = input;
|
|
5881
6730
|
const resolvedPagePath = input.pagePath;
|
|
5882
6731
|
const maybeRequestContext = input.requestContext;
|
|
5883
6732
|
const responseInit = input.responseInit ?? {};
|
|
5884
6733
|
const resolvedUrl = resolveRequestRenderUrl(input.request);
|
|
6734
|
+
const siblingCss = await readSiblingCss(resolvedPagePath);
|
|
6735
|
+
const resolvedHeadTag = injectInlineCss(userHeadTag, siblingCss);
|
|
5885
6736
|
cacheRouteData(resolvedPagePath, {
|
|
5886
6737
|
headTag: resolvedHeadTag,
|
|
5887
6738
|
requestContext: maybeRequestContext
|
|
@@ -5904,7 +6755,6 @@ var handleAngularPageRequest = async (input) => {
|
|
|
5904
6755
|
const usesLegacyAnimations = pageModule.__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ === true;
|
|
5905
6756
|
const deps = baseDeps;
|
|
5906
6757
|
const selector = resolveSelector(deps, resolvedPagePath, PageComponent);
|
|
5907
|
-
lastSelector = selector;
|
|
5908
6758
|
const htmlString = `<!DOCTYPE html><html>${resolvedHeadTag}<body><${selector}></${selector}></body></html>`;
|
|
5909
6759
|
resetSsrSanitizer();
|
|
5910
6760
|
const sanitizer = getSsrSanitizer(deps);
|
|
@@ -5924,17 +6774,19 @@ var handleAngularPageRequest = async (input) => {
|
|
|
5924
6774
|
const html = injectIslandPageContext(injectSsrScripts(htmlWithLoweredIslands, requestId, resolvedIndexPath, maybeRequestContext), { hasIslands: shouldProcessIslands });
|
|
5925
6775
|
return new Response(html, withHtmlContentType(responseInit));
|
|
5926
6776
|
};
|
|
5927
|
-
|
|
6777
|
+
const pageResponse = await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
6778
|
+
return withPageCacheHeaders(pageResponse, input.request);
|
|
5928
6779
|
} catch (error) {
|
|
5929
6780
|
console.error("[SSR] Angular render error:", error);
|
|
5930
6781
|
const pageName = derivePageName(resolvedPagePath);
|
|
5931
6782
|
const conventionResponse = await renderConventionError("angular", pageName, error);
|
|
5932
|
-
if (conventionResponse)
|
|
5933
|
-
return conventionResponse;
|
|
5934
|
-
|
|
6783
|
+
if (conventionResponse) {
|
|
6784
|
+
return withPageCacheHeaders(conventionResponse, input.request);
|
|
6785
|
+
}
|
|
6786
|
+
return withPageCacheHeaders(new Response(ssrErrorPage("angular", error), {
|
|
5935
6787
|
headers: { "Content-Type": "text/html" },
|
|
5936
6788
|
status: 500
|
|
5937
|
-
});
|
|
6789
|
+
}), input.request);
|
|
5938
6790
|
}
|
|
5939
6791
|
});
|
|
5940
6792
|
};
|
|
@@ -5960,5 +6812,5 @@ export {
|
|
|
5960
6812
|
ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
|
|
5961
6813
|
};
|
|
5962
6814
|
|
|
5963
|
-
//# debugId=
|
|
6815
|
+
//# debugId=61E1DD96B8611B8364756E2164756E21
|
|
5964
6816
|
//# sourceMappingURL=server.js.map
|