@ecopages/core 0.2.0-alpha.39 → 0.2.0-alpha.40
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/package.json +2 -2
- package/src/adapters/bun/create-app.d.ts +8 -1
- package/src/adapters/bun/create-app.js +52 -65
- package/src/adapters/bun/hmr-manager.d.ts +19 -103
- package/src/adapters/bun/hmr-manager.js +26 -280
- package/src/adapters/bun/runtime-host.d.ts +52 -0
- package/src/adapters/bun/runtime-host.js +56 -0
- package/src/adapters/bun/server-adapter.d.ts +89 -28
- package/src/adapters/bun/server-adapter.js +113 -61
- package/src/adapters/bun/static-preview-host.d.ts +28 -0
- package/src/adapters/bun/static-preview-host.js +45 -0
- package/src/adapters/node/create-app.d.ts +9 -3
- package/src/adapters/node/create-app.js +24 -81
- package/src/adapters/node/http-request-bridge.d.ts +57 -0
- package/src/adapters/node/http-request-bridge.js +118 -0
- package/src/adapters/node/node-hmr-manager.d.ts +22 -91
- package/src/adapters/node/node-hmr-manager.js +26 -272
- package/src/adapters/node/runtime-host.d.ts +57 -0
- package/src/adapters/node/runtime-host.js +92 -0
- package/src/adapters/node/server-adapter-dependencies.d.ts +19 -0
- package/src/adapters/node/server-adapter-dependencies.js +18 -0
- package/src/adapters/node/server-adapter.d.ts +10 -37
- package/src/adapters/node/server-adapter.js +55 -125
- package/src/adapters/node/static-preview-host.d.ts +55 -0
- package/src/adapters/node/static-preview-host.js +68 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +26 -0
- package/src/adapters/shared/runtime-app-bootstrap.js +46 -0
- package/src/adapters/shared/runtime-host.d.ts +12 -0
- package/src/adapters/shared/runtime-host.js +0 -0
- package/src/adapters/shared/shared-hmr-manager.d.ts +59 -0
- package/src/adapters/shared/shared-hmr-manager.js +239 -0
- package/src/adapters/shared/static-preview-host.d.ts +10 -0
- package/src/adapters/shared/static-preview-host.js +0 -0
- package/src/build/build-adapter.js +12 -1
- package/src/build/esbuild-build-adapter.d.ts +1 -0
- package/src/build/esbuild-build-adapter.js +13 -0
- package/src/hmr/strategies/js-hmr-strategy.js +0 -4
- package/src/plugins/integration-plugin.d.ts +6 -1
- package/src/route-renderer/orchestration/integration-renderer.d.ts +32 -14
- package/src/route-renderer/orchestration/integration-renderer.js +80 -14
- package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +1 -0
- package/src/route-renderer/orchestration/processed-asset-dedupe.js +15 -11
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +22 -8
- package/src/route-renderer/orchestration/route-render-orchestrator.js +59 -10
- package/src/services/assets/asset-processing-service/page-package.d.ts +4 -1
- package/src/services/assets/asset-processing-service/page-package.js +11 -5
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +3 -1
- package/src/services/html/html-rewriter-provider.service.d.ts +3 -0
- package/src/services/html/html-transformer.service.d.ts +10 -1
- package/src/services/html/html-transformer.service.js +80 -9
- package/src/services/module-loading/page-module-import.service.js +2 -2
- package/src/types/public-types.d.ts +24 -7
- package/src/adapters/bun/server-lifecycle.d.ts +0 -63
- package/src/adapters/bun/server-lifecycle.js +0 -92
- package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
- package/src/adapters/shared/runtime-bootstrap.js +0 -43
|
@@ -106,7 +106,7 @@ class PageModuleImportService {
|
|
|
106
106
|
const fileBaseName = path.basename(filePath, path.extname(filePath));
|
|
107
107
|
const cacheScopeSuffix = cacheScope ? `-${sanitizeCacheScope(cacheScope)}` : "";
|
|
108
108
|
const invalidationSuffix = shouldVersionBuildOutputPath(invalidationVersion) ? `-v${invalidationVersion}` : "";
|
|
109
|
-
const outputFileName = `${fileBaseName}-${fileHash}${cacheScopeSuffix}${invalidationSuffix}.
|
|
109
|
+
const outputFileName = `${fileBaseName}-${fileHash}${cacheScopeSuffix}${invalidationSuffix}.mjs`;
|
|
110
110
|
const outputNamingTemplate = `${fileBaseName}-${fileHash}${cacheScopeSuffix}${invalidationSuffix}.[ext]`;
|
|
111
111
|
const buildResult = await this.dependencies.buildModule(
|
|
112
112
|
{
|
|
@@ -131,7 +131,7 @@ class PageModuleImportService {
|
|
|
131
131
|
throw new Error(transpileErrorMessage(details));
|
|
132
132
|
}
|
|
133
133
|
const preferredOutputPath = path.join(outdir, outputFileName);
|
|
134
|
-
const compiledOutput = buildResult.outputs.find((output) => output.path === preferredOutputPath)?.path ?? buildResult.outputs.find((output) => output.path
|
|
134
|
+
const compiledOutput = buildResult.outputs.find((output) => output.path === preferredOutputPath)?.path ?? buildResult.outputs.find((output) => /\.(?:[cm]?js)$/u.test(output.path))?.path;
|
|
135
135
|
if (!compiledOutput) {
|
|
136
136
|
throw new Error(noOutputMessage(filePath));
|
|
137
137
|
}
|
|
@@ -7,7 +7,7 @@ import type { EcoPageComponent } from '../eco/eco.types.js';
|
|
|
7
7
|
import type { EcoPagesAppConfig } from './internal-types.js';
|
|
8
8
|
import type { HmrStrategy } from '../hmr/hmr-strategy.js';
|
|
9
9
|
import type { BrowserBundleExecutor } from '../services/assets/browser-bundle.service.js';
|
|
10
|
-
import type { ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
10
|
+
import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
11
11
|
import type { CacheStats, CacheStrategy } from '../services/cache/cache.types.js';
|
|
12
12
|
import type { InteractionEventsString as ScriptsInjectorInteractionEventsString } from '@ecopages/scripts-injector/types';
|
|
13
13
|
export type { EcoPagesAppConfig } from './internal-types.js';
|
|
@@ -676,6 +676,10 @@ export interface PagePackageResult {
|
|
|
676
676
|
* Full processed asset list before any page-level partitioning.
|
|
677
677
|
*/
|
|
678
678
|
assets: ProcessedAsset[];
|
|
679
|
+
/**
|
|
680
|
+
* Optional structured Page Browser Graph carried through route preparation.
|
|
681
|
+
*/
|
|
682
|
+
pageBrowserGraph?: PageBrowserGraphResult;
|
|
679
683
|
/**
|
|
680
684
|
* Assets that should still be injected into the final HTML document.
|
|
681
685
|
*/
|
|
@@ -704,16 +708,29 @@ export interface PagePackageResult {
|
|
|
704
708
|
/**
|
|
705
709
|
* Page-scoped browser output planned before final HTML packaging.
|
|
706
710
|
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
* shared chunk
|
|
711
|
+
* This shape keeps page-browser ownership explicit without forcing downstream
|
|
712
|
+
* HTML packaging to understand how integrations discovered the graph. Entry
|
|
713
|
+
* assets represent the initial page bootstrap outputs, while chunk assets stay
|
|
714
|
+
* separate so callers can preserve lazy/shared chunk identity until the point
|
|
715
|
+
* they intentionally flatten for page packaging.
|
|
711
716
|
*/
|
|
712
717
|
export interface PageBrowserGraphResult {
|
|
713
718
|
/**
|
|
714
|
-
* Processed assets
|
|
719
|
+
* Processed assets needed for the initial page browser bootstrap.
|
|
715
720
|
*/
|
|
716
|
-
|
|
721
|
+
entryAssets: ProcessedAsset[];
|
|
722
|
+
/**
|
|
723
|
+
* Processed browser chunks referenced after the initial page bootstrap.
|
|
724
|
+
*/
|
|
725
|
+
chunkAssets: ProcessedAsset[];
|
|
726
|
+
}
|
|
727
|
+
export type PageBrowserGraphContributionContext = {
|
|
728
|
+
file: string;
|
|
729
|
+
pageModule: EcoPageFile;
|
|
730
|
+
};
|
|
731
|
+
export interface PageBrowserGraphContribution {
|
|
732
|
+
dependencies?: AssetDefinition[];
|
|
733
|
+
assets?: ProcessedAsset[];
|
|
717
734
|
}
|
|
718
735
|
export type OwnershipValidationErrorCode = 'UNKNOWN_INTEGRATION_OWNER' | 'MISSING_COMPONENT_METADATA';
|
|
719
736
|
export interface OwnershipValidationError {
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
-
import type { EcoBuildPlugin } from '../../build/build-types.js';
|
|
3
|
-
import { StaticSiteGenerator } from '../../static-site-generator/static-site-generator.js';
|
|
4
|
-
import type { ClientBridge } from './client-bridge.js';
|
|
5
|
-
import type { HmrManager } from './hmr-manager.js';
|
|
6
|
-
export interface WatcherCallbacks {
|
|
7
|
-
refreshRouterRoutesCallback: () => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export interface ServerLifecycleParams {
|
|
10
|
-
appConfig: EcoPagesAppConfig;
|
|
11
|
-
runtimeOrigin: string;
|
|
12
|
-
hmrManager: HmrManager;
|
|
13
|
-
bridge: ClientBridge;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Coordinates Bun-runtime server startup side effects for one app instance.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* This class keeps runtime-only concerns together: build-runtime bootstrapping,
|
|
20
|
-
* Bun loader registration, public asset preparation, plugin setup, and file
|
|
21
|
-
* watching. Core config/build state is expected to already be finalized before
|
|
22
|
-
* this lifecycle runs.
|
|
23
|
-
*/
|
|
24
|
-
export declare class ServerLifecycle {
|
|
25
|
-
private readonly appConfig;
|
|
26
|
-
private readonly hmrManager;
|
|
27
|
-
private readonly bridge;
|
|
28
|
-
private readonly runtimeOrigin;
|
|
29
|
-
private staticSiteGenerator;
|
|
30
|
-
constructor({ appConfig, runtimeOrigin, hmrManager, bridge }: ServerLifecycleParams);
|
|
31
|
-
/**
|
|
32
|
-
* Initializes the runtime services that Bun startup depends on.
|
|
33
|
-
*
|
|
34
|
-
* @returns The static-site generator instance reused by the adapter.
|
|
35
|
-
*/
|
|
36
|
-
initialize(): Promise<StaticSiteGenerator>;
|
|
37
|
-
/**
|
|
38
|
-
* Registers config-owned build loaders with Bun's runtime plugin API.
|
|
39
|
-
*
|
|
40
|
-
* @remarks
|
|
41
|
-
* Bun remains responsible only for transport-level plugin registration here.
|
|
42
|
-
* Loader ownership and composition were already finalized during config build.
|
|
43
|
-
*/
|
|
44
|
-
setupLoaders(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Runs runtime-only processor and integration setup for this Bun app session.
|
|
47
|
-
*
|
|
48
|
-
* @param options.watch Whether watch mode is enabled.
|
|
49
|
-
* @returns The browser build plugins visible to HMR after runtime setup.
|
|
50
|
-
*/
|
|
51
|
-
initializePlugins(options?: {
|
|
52
|
-
watch?: boolean;
|
|
53
|
-
}): Promise<EcoBuildPlugin[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Starts file watching and wires change events back into the adapter refresh
|
|
56
|
-
* callback.
|
|
57
|
-
*/
|
|
58
|
-
startWatching(callbacks: WatcherCallbacks): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Returns the static-site generator created during initialization.
|
|
61
|
-
*/
|
|
62
|
-
getStaticSiteGenerator(): StaticSiteGenerator;
|
|
63
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { getBunRuntime } from "../../utils/runtime.js";
|
|
2
|
-
import { appLogger } from "../../global/app-logger.js";
|
|
3
|
-
import { StaticSiteGenerator } from "../../static-site-generator/static-site-generator.js";
|
|
4
|
-
import {
|
|
5
|
-
bindSharedRuntimeHmrManager,
|
|
6
|
-
initializeSharedRuntimePlugins,
|
|
7
|
-
prepareSharedRuntimePublicDir,
|
|
8
|
-
startSharedProjectWatching
|
|
9
|
-
} from "../shared/runtime-bootstrap.js";
|
|
10
|
-
class ServerLifecycle {
|
|
11
|
-
appConfig;
|
|
12
|
-
hmrManager;
|
|
13
|
-
bridge;
|
|
14
|
-
runtimeOrigin;
|
|
15
|
-
staticSiteGenerator;
|
|
16
|
-
constructor({ appConfig, runtimeOrigin, hmrManager, bridge }) {
|
|
17
|
-
this.appConfig = appConfig;
|
|
18
|
-
this.runtimeOrigin = runtimeOrigin;
|
|
19
|
-
this.hmrManager = hmrManager;
|
|
20
|
-
this.bridge = bridge;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Initializes the runtime services that Bun startup depends on.
|
|
24
|
-
*
|
|
25
|
-
* @returns The static-site generator instance reused by the adapter.
|
|
26
|
-
*/
|
|
27
|
-
async initialize() {
|
|
28
|
-
this.staticSiteGenerator = new StaticSiteGenerator({ appConfig: this.appConfig });
|
|
29
|
-
await this.hmrManager.buildRuntime();
|
|
30
|
-
this.setupLoaders();
|
|
31
|
-
prepareSharedRuntimePublicDir(this.appConfig);
|
|
32
|
-
return this.staticSiteGenerator;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Registers config-owned build loaders with Bun's runtime plugin API.
|
|
36
|
-
*
|
|
37
|
-
* @remarks
|
|
38
|
-
* Bun remains responsible only for transport-level plugin registration here.
|
|
39
|
-
* Loader ownership and composition were already finalized during config build.
|
|
40
|
-
*/
|
|
41
|
-
setupLoaders() {
|
|
42
|
-
const loaders = this.appConfig.loaders;
|
|
43
|
-
for (const loader of loaders.values()) {
|
|
44
|
-
getBunRuntime()?.plugin(loader);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Runs runtime-only processor and integration setup for this Bun app session.
|
|
49
|
-
*
|
|
50
|
-
* @param options.watch Whether watch mode is enabled.
|
|
51
|
-
* @returns The browser build plugins visible to HMR after runtime setup.
|
|
52
|
-
*/
|
|
53
|
-
async initializePlugins(options) {
|
|
54
|
-
try {
|
|
55
|
-
const hmrEnabled = !!options?.watch;
|
|
56
|
-
this.hmrManager.setEnabled(hmrEnabled);
|
|
57
|
-
await initializeSharedRuntimePlugins({
|
|
58
|
-
appConfig: this.appConfig,
|
|
59
|
-
runtimeOrigin: this.runtimeOrigin,
|
|
60
|
-
hmrManager: this.hmrManager,
|
|
61
|
-
onRuntimePlugin: (plugin) => {
|
|
62
|
-
getBunRuntime()?.plugin(plugin);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return bindSharedRuntimeHmrManager(this.appConfig, this.hmrManager);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
appLogger.error(`Failed to initialize plugins: ${error instanceof Error ? error.message : String(error)}`);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Starts file watching and wires change events back into the adapter refresh
|
|
73
|
-
* callback.
|
|
74
|
-
*/
|
|
75
|
-
async startWatching(callbacks) {
|
|
76
|
-
await startSharedProjectWatching({
|
|
77
|
-
appConfig: this.appConfig,
|
|
78
|
-
refreshRouterRoutesCallback: callbacks.refreshRouterRoutesCallback,
|
|
79
|
-
hmrManager: this.hmrManager,
|
|
80
|
-
bridge: this.bridge
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns the static-site generator created during initialization.
|
|
85
|
-
*/
|
|
86
|
-
getStaticSiteGenerator() {
|
|
87
|
-
return this.staticSiteGenerator;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export {
|
|
91
|
-
ServerLifecycle
|
|
92
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type BuildExecutor } from '../../build/build-adapter.js';
|
|
2
|
-
import type { EcoBuildPlugin } from '../../build/build-types.js';
|
|
3
|
-
import type { EcoPagesAppConfig, IClientBridge, IHmrManager } from '../../types/internal-types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Installs and returns the app-owned runtime build executor used by adapter
|
|
6
|
-
* startup and follow-up runtime work.
|
|
7
|
-
*/
|
|
8
|
-
export declare function installSharedRuntimeBuildExecutor(appConfig: EcoPagesAppConfig, options: {
|
|
9
|
-
development: boolean;
|
|
10
|
-
}): BuildExecutor;
|
|
11
|
-
/**
|
|
12
|
-
* Copies app public assets into dist and ensures the resolved assets directory
|
|
13
|
-
* exists before request handling begins.
|
|
14
|
-
*/
|
|
15
|
-
export declare function prepareSharedRuntimePublicDir(appConfig: EcoPagesAppConfig): void;
|
|
16
|
-
/**
|
|
17
|
-
* Runs runtime plugin setup against app-owned config/runtime state and optional
|
|
18
|
-
* host plugin registration hooks.
|
|
19
|
-
*/
|
|
20
|
-
export declare function initializeSharedRuntimePlugins(options: {
|
|
21
|
-
appConfig: EcoPagesAppConfig;
|
|
22
|
-
runtimeOrigin: string;
|
|
23
|
-
hmrManager?: IHmrManager;
|
|
24
|
-
onRuntimePlugin?: (plugin: unknown) => void;
|
|
25
|
-
}): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Starts shared project watching for runtime adapters.
|
|
28
|
-
*/
|
|
29
|
-
export declare function startSharedProjectWatching(options: {
|
|
30
|
-
appConfig: EcoPagesAppConfig;
|
|
31
|
-
refreshRouterRoutesCallback: () => Promise<void>;
|
|
32
|
-
hmrManager: IHmrManager;
|
|
33
|
-
bridge: IClientBridge;
|
|
34
|
-
}): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Binds a runtime HMR manager to app-owned plugin and integration state.
|
|
37
|
-
*/
|
|
38
|
-
export declare function bindSharedRuntimeHmrManager(appConfig: EcoPagesAppConfig, hmrManager: IHmrManager): EcoBuildPlugin[];
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
-
import { getAppBrowserBuildPlugins, setupAppRuntimePlugins } from "../../build/build-adapter.js";
|
|
4
|
-
import { installAppRuntimeBuildExecutor } from "../../build/runtime-build-executor.js";
|
|
5
|
-
import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
|
|
6
|
-
import { ProjectWatcher } from "../../watchers/project-watcher.js";
|
|
7
|
-
function installSharedRuntimeBuildExecutor(appConfig, options) {
|
|
8
|
-
return installAppRuntimeBuildExecutor(appConfig, options);
|
|
9
|
-
}
|
|
10
|
-
function prepareSharedRuntimePublicDir(appConfig) {
|
|
11
|
-
const srcPublicDir = path.join(appConfig.rootDir, appConfig.srcDir, appConfig.publicDir);
|
|
12
|
-
if (fileSystem.exists(srcPublicDir)) {
|
|
13
|
-
fileSystem.copyDir(srcPublicDir, path.join(appConfig.rootDir, appConfig.distDir));
|
|
14
|
-
}
|
|
15
|
-
fileSystem.ensureDir(path.join(appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR));
|
|
16
|
-
}
|
|
17
|
-
async function initializeSharedRuntimePlugins(options) {
|
|
18
|
-
await setupAppRuntimePlugins(options);
|
|
19
|
-
}
|
|
20
|
-
async function startSharedProjectWatching(options) {
|
|
21
|
-
const watcher = new ProjectWatcher({
|
|
22
|
-
config: options.appConfig,
|
|
23
|
-
refreshRouterRoutesCallback: options.refreshRouterRoutesCallback,
|
|
24
|
-
hmrManager: options.hmrManager,
|
|
25
|
-
bridge: options.bridge
|
|
26
|
-
});
|
|
27
|
-
await watcher.createWatcherSubscription();
|
|
28
|
-
}
|
|
29
|
-
function bindSharedRuntimeHmrManager(appConfig, hmrManager) {
|
|
30
|
-
const browserBuildPlugins = getAppBrowserBuildPlugins(appConfig);
|
|
31
|
-
hmrManager.setPlugins(browserBuildPlugins);
|
|
32
|
-
for (const integration of appConfig.integrations) {
|
|
33
|
-
integration.setHmrManager(hmrManager);
|
|
34
|
-
}
|
|
35
|
-
return browserBuildPlugins;
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
bindSharedRuntimeHmrManager,
|
|
39
|
-
initializeSharedRuntimePlugins,
|
|
40
|
-
installSharedRuntimeBuildExecutor,
|
|
41
|
-
prepareSharedRuntimePublicDir,
|
|
42
|
-
startSharedProjectWatching
|
|
43
|
-
};
|