@ecopages/core 0.2.0-alpha.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/CHANGELOG.md +89 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/package.json +279 -0
- package/src/adapters/abstract/application-adapter.d.ts +168 -0
- package/src/adapters/abstract/application-adapter.js +109 -0
- package/src/adapters/abstract/application-adapter.ts +337 -0
- package/src/adapters/abstract/router-adapter.d.ts +26 -0
- package/src/adapters/abstract/router-adapter.js +5 -0
- package/src/adapters/abstract/router-adapter.ts +30 -0
- package/src/adapters/abstract/server-adapter.d.ts +69 -0
- package/src/adapters/abstract/server-adapter.js +15 -0
- package/src/adapters/abstract/server-adapter.ts +79 -0
- package/src/adapters/bun/client-bridge.d.ts +34 -0
- package/src/adapters/bun/client-bridge.js +48 -0
- package/src/adapters/bun/client-bridge.ts +62 -0
- package/src/adapters/bun/create-app.d.ts +60 -0
- package/src/adapters/bun/create-app.js +117 -0
- package/src/adapters/bun/create-app.ts +189 -0
- package/src/adapters/bun/define-api-handler.d.ts +61 -0
- package/src/adapters/bun/define-api-handler.js +15 -0
- package/src/adapters/bun/define-api-handler.ts +114 -0
- package/src/adapters/bun/hmr-manager.d.ts +84 -0
- package/src/adapters/bun/hmr-manager.js +227 -0
- package/src/adapters/bun/hmr-manager.ts +281 -0
- package/src/adapters/bun/index.d.ts +3 -0
- package/src/adapters/bun/index.js +8 -0
- package/src/adapters/bun/index.ts +3 -0
- package/src/adapters/bun/server-adapter.d.ts +155 -0
- package/src/adapters/bun/server-adapter.js +368 -0
- package/src/adapters/bun/server-adapter.ts +492 -0
- package/src/adapters/bun/server-lifecycle.d.ts +52 -0
- package/src/adapters/bun/server-lifecycle.js +120 -0
- package/src/adapters/bun/server-lifecycle.ts +154 -0
- package/src/adapters/index.d.ts +6 -0
- package/src/adapters/index.js +14 -0
- package/src/adapters/index.ts +6 -0
- package/src/adapters/node/create-app.d.ts +21 -0
- package/src/adapters/node/create-app.js +143 -0
- package/src/adapters/node/create-app.ts +179 -0
- package/src/adapters/node/index.d.ts +4 -0
- package/src/adapters/node/index.js +8 -0
- package/src/adapters/node/index.ts +9 -0
- package/src/adapters/node/node-client-bridge.d.ts +26 -0
- package/src/adapters/node/node-client-bridge.js +66 -0
- package/src/adapters/node/node-client-bridge.ts +79 -0
- package/src/adapters/node/node-hmr-manager.d.ts +62 -0
- package/src/adapters/node/node-hmr-manager.js +221 -0
- package/src/adapters/node/node-hmr-manager.ts +271 -0
- package/src/adapters/node/server-adapter.d.ts +190 -0
- package/src/adapters/node/server-adapter.js +420 -0
- package/src/adapters/node/server-adapter.ts +561 -0
- package/src/adapters/node/static-content-server.d.ts +24 -0
- package/src/adapters/node/static-content-server.js +166 -0
- package/src/adapters/node/static-content-server.ts +203 -0
- package/src/adapters/shared/api-response.d.ts +52 -0
- package/src/adapters/shared/api-response.js +96 -0
- package/src/adapters/shared/api-response.ts +104 -0
- package/src/adapters/shared/application-adapter.d.ts +18 -0
- package/src/adapters/shared/application-adapter.js +90 -0
- package/src/adapters/shared/application-adapter.ts +199 -0
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
- package/src/adapters/shared/explicit-static-route-matcher.js +100 -0
- package/src/adapters/shared/explicit-static-route-matcher.ts +134 -0
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
- package/src/adapters/shared/file-route-middleware-pipeline.js +98 -0
- package/src/adapters/shared/file-route-middleware-pipeline.ts +123 -0
- package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
- package/src/adapters/shared/fs-server-response-factory.js +97 -0
- package/src/adapters/shared/fs-server-response-factory.ts +118 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +71 -0
- package/src/adapters/shared/fs-server-response-matcher.js +155 -0
- package/src/adapters/shared/fs-server-response-matcher.ts +198 -0
- package/src/adapters/shared/render-context.d.ts +14 -0
- package/src/adapters/shared/render-context.js +69 -0
- package/src/adapters/shared/render-context.ts +105 -0
- package/src/adapters/shared/server-adapter.d.ts +87 -0
- package/src/adapters/shared/server-adapter.js +353 -0
- package/src/adapters/shared/server-adapter.ts +442 -0
- package/src/adapters/shared/server-route-handler.d.ts +89 -0
- package/src/adapters/shared/server-route-handler.js +120 -0
- package/src/adapters/shared/server-route-handler.ts +166 -0
- package/src/adapters/shared/server-static-builder.d.ts +38 -0
- package/src/adapters/shared/server-static-builder.js +46 -0
- package/src/adapters/shared/server-static-builder.ts +82 -0
- package/src/build/build-adapter.d.ts +74 -0
- package/src/build/build-adapter.js +54 -0
- package/src/build/build-adapter.ts +132 -0
- package/src/build/build-types.d.ts +57 -0
- package/src/build/build-types.js +0 -0
- package/src/build/build-types.ts +83 -0
- package/src/build/esbuild-build-adapter.d.ts +69 -0
- package/src/build/esbuild-build-adapter.js +390 -0
- package/src/build/esbuild-build-adapter.ts +510 -0
- package/src/config/config-builder.d.ts +227 -0
- package/src/config/config-builder.js +392 -0
- package/src/config/config-builder.ts +474 -0
- package/src/constants.d.ts +32 -0
- package/src/constants.js +21 -0
- package/src/constants.ts +39 -0
- package/src/create-app.d.ts +17 -0
- package/src/create-app.js +66 -0
- package/src/create-app.ts +87 -0
- package/src/declarations.d.ts +26 -0
- package/src/define-api-handler.d.ts +25 -0
- package/src/define-api-handler.js +15 -0
- package/src/define-api-handler.ts +66 -0
- package/src/dev/sc-server.d.ts +30 -0
- package/src/dev/sc-server.js +111 -0
- package/src/dev/sc-server.ts +143 -0
- package/src/eco/README.md +636 -0
- package/src/eco/component-render-context.d.ts +105 -0
- package/src/eco/component-render-context.js +77 -0
- package/src/eco/component-render-context.ts +202 -0
- package/src/eco/eco.d.ts +9 -0
- package/src/eco/eco.js +110 -0
- package/src/eco/eco.ts +221 -0
- package/src/eco/eco.types.d.ts +170 -0
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.types.ts +202 -0
- package/src/eco/eco.utils.d.ts +40 -0
- package/src/eco/eco.utils.js +40 -0
- package/src/eco/eco.utils.ts +89 -0
- package/src/eco/global-injector-map.d.ts +16 -0
- package/src/eco/global-injector-map.js +80 -0
- package/src/eco/global-injector-map.ts +112 -0
- package/src/eco/lazy-injector-map.d.ts +8 -0
- package/src/eco/lazy-injector-map.js +70 -0
- package/src/eco/lazy-injector-map.ts +120 -0
- package/src/eco/module-dependencies.d.ts +18 -0
- package/src/eco/module-dependencies.js +49 -0
- package/src/eco/module-dependencies.ts +75 -0
- package/src/env.d.ts +20 -0
- package/src/errors/http-error.d.ts +31 -0
- package/src/errors/http-error.js +50 -0
- package/src/errors/http-error.ts +72 -0
- package/src/errors/index.d.ts +2 -0
- package/src/errors/index.js +4 -0
- package/src/errors/index.ts +2 -0
- package/src/errors/locals-access-error.d.ts +4 -0
- package/src/errors/locals-access-error.js +9 -0
- package/src/errors/locals-access-error.ts +7 -0
- package/src/global/app-logger.d.ts +2 -0
- package/src/global/app-logger.js +6 -0
- package/src/global/app-logger.ts +4 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
- package/src/hmr/client/hmr-runtime.d.ts +10 -0
- package/src/hmr/client/hmr-runtime.js +86 -0
- package/src/hmr/client/hmr-runtime.ts +121 -0
- package/src/hmr/hmr-strategy.d.ts +159 -0
- package/src/hmr/hmr-strategy.js +29 -0
- package/src/hmr/hmr-strategy.ts +172 -0
- package/src/hmr/hmr.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.test.e2e.js +50 -0
- package/src/hmr/hmr.test.e2e.ts +75 -0
- package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
- package/src/hmr/strategies/default-hmr-strategy.js +34 -0
- package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +136 -0
- package/src/hmr/strategies/js-hmr-strategy.js +179 -0
- package/src/hmr/strategies/js-hmr-strategy.ts +308 -0
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +4 -0
- package/src/index.browser.ts +3 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +10 -0
- package/src/index.ts +5 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
- package/src/integrations/ghtml/ghtml-renderer.js +60 -0
- package/src/integrations/ghtml/ghtml-renderer.ts +93 -0
- package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
- package/src/integrations/ghtml/ghtml.plugin.js +21 -0
- package/src/integrations/ghtml/ghtml.plugin.ts +32 -0
- package/src/internal-types.d.ts +200 -0
- package/src/internal-types.js +0 -0
- package/src/internal-types.ts +212 -0
- package/src/plugins/alias-resolver-plugin.d.ts +2 -0
- package/src/plugins/alias-resolver-plugin.js +39 -0
- package/src/plugins/alias-resolver-plugin.ts +45 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +95 -0
- package/src/plugins/eco-component-meta-plugin.js +157 -0
- package/src/plugins/eco-component-meta-plugin.ts +474 -0
- package/src/plugins/integration-plugin.d.ts +102 -0
- package/src/plugins/integration-plugin.js +100 -0
- package/src/plugins/integration-plugin.ts +184 -0
- package/src/plugins/processor.d.ts +82 -0
- package/src/plugins/processor.js +122 -0
- package/src/plugins/processor.ts +220 -0
- package/src/public-types.d.ts +1094 -0
- package/src/public-types.js +0 -0
- package/src/public-types.ts +1255 -0
- package/src/route-renderer/GRAPH.md +387 -0
- package/src/route-renderer/README.md +135 -0
- package/src/route-renderer/component-graph-executor.d.ts +32 -0
- package/src/route-renderer/component-graph-executor.js +31 -0
- package/src/route-renderer/component-graph-executor.ts +84 -0
- package/src/route-renderer/component-graph.d.ts +42 -0
- package/src/route-renderer/component-graph.js +72 -0
- package/src/route-renderer/component-graph.ts +159 -0
- package/src/route-renderer/component-marker.d.ts +52 -0
- package/src/route-renderer/component-marker.js +46 -0
- package/src/route-renderer/component-marker.ts +117 -0
- package/src/route-renderer/dependency-resolver.d.ts +24 -0
- package/src/route-renderer/dependency-resolver.js +428 -0
- package/src/route-renderer/dependency-resolver.ts +596 -0
- package/src/route-renderer/html-post-processing.service.d.ts +40 -0
- package/src/route-renderer/html-post-processing.service.js +86 -0
- package/src/route-renderer/html-post-processing.service.ts +103 -0
- package/src/route-renderer/integration-renderer.d.ts +339 -0
- package/src/route-renderer/integration-renderer.js +526 -0
- package/src/route-renderer/integration-renderer.ts +696 -0
- package/src/route-renderer/marker-graph-resolver.d.ts +76 -0
- package/src/route-renderer/marker-graph-resolver.js +93 -0
- package/src/route-renderer/marker-graph-resolver.ts +153 -0
- package/src/route-renderer/page-module-loader.d.ts +61 -0
- package/src/route-renderer/page-module-loader.js +102 -0
- package/src/route-renderer/page-module-loader.ts +153 -0
- package/src/route-renderer/render-execution.service.d.ts +69 -0
- package/src/route-renderer/render-execution.service.js +91 -0
- package/src/route-renderer/render-execution.service.ts +158 -0
- package/src/route-renderer/render-preparation.service.d.ts +112 -0
- package/src/route-renderer/render-preparation.service.js +243 -0
- package/src/route-renderer/render-preparation.service.ts +358 -0
- package/src/route-renderer/route-renderer.d.ts +26 -0
- package/src/route-renderer/route-renderer.js +68 -0
- package/src/route-renderer/route-renderer.ts +80 -0
- package/src/router/fs-router-scanner.d.ts +41 -0
- package/src/router/fs-router-scanner.js +155 -0
- package/src/router/fs-router-scanner.ts +217 -0
- package/src/router/fs-router.d.ts +26 -0
- package/src/router/fs-router.js +100 -0
- package/src/router/fs-router.ts +122 -0
- package/src/services/asset-processing-service/asset-processing.service.d.ts +41 -0
- package/src/services/asset-processing-service/asset-processing.service.js +250 -0
- package/src/services/asset-processing-service/asset-processing.service.ts +306 -0
- package/src/services/asset-processing-service/asset.factory.d.ts +17 -0
- package/src/services/asset-processing-service/asset.factory.js +82 -0
- package/src/services/asset-processing-service/asset.factory.ts +105 -0
- package/src/services/asset-processing-service/assets.types.d.ts +88 -0
- package/src/services/asset-processing-service/assets.types.js +0 -0
- package/src/services/asset-processing-service/assets.types.ts +112 -0
- package/src/services/asset-processing-service/index.d.ts +3 -0
- package/src/services/asset-processing-service/index.js +3 -0
- package/src/services/asset-processing-service/index.ts +3 -0
- package/src/services/asset-processing-service/processor.interface.d.ts +22 -0
- package/src/services/asset-processing-service/processor.interface.js +6 -0
- package/src/services/asset-processing-service/processor.interface.ts +27 -0
- package/src/services/asset-processing-service/processor.registry.d.ts +8 -0
- package/src/services/asset-processing-service/processor.registry.js +15 -0
- package/src/services/asset-processing-service/processor.registry.ts +18 -0
- package/src/services/asset-processing-service/processors/base/base-processor.d.ts +24 -0
- package/src/services/asset-processing-service/processors/base/base-processor.js +59 -0
- package/src/services/asset-processing-service/processors/base/base-processor.ts +76 -0
- package/src/services/asset-processing-service/processors/base/base-script-processor.d.ts +16 -0
- package/src/services/asset-processing-service/processors/base/base-script-processor.js +80 -0
- package/src/services/asset-processing-service/processors/base/base-script-processor.ts +105 -0
- package/src/services/asset-processing-service/processors/index.d.ts +5 -0
- package/src/services/asset-processing-service/processors/index.js +5 -0
- package/src/services/asset-processing-service/processors/index.ts +5 -0
- package/src/services/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
- package/src/services/asset-processing-service/processors/script/content-script.processor.js +57 -0
- package/src/services/asset-processing-service/processors/script/content-script.processor.ts +66 -0
- package/src/services/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
- package/src/services/asset-processing-service/processors/script/file-script.processor.js +76 -0
- package/src/services/asset-processing-service/processors/script/file-script.processor.ts +88 -0
- package/src/services/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
- package/src/services/asset-processing-service/processors/script/node-module-script.processor.js +74 -0
- package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +84 -0
- package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
- package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
- package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +27 -0
- package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
- package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +63 -0
- package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +77 -0
- package/src/services/cache/cache.types.d.ts +107 -0
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/cache.types.ts +126 -0
- package/src/services/cache/index.d.ts +7 -0
- package/src/services/cache/index.js +7 -0
- package/src/services/cache/index.ts +18 -0
- package/src/services/cache/memory-cache-store.d.ts +42 -0
- package/src/services/cache/memory-cache-store.js +98 -0
- package/src/services/cache/memory-cache-store.ts +130 -0
- package/src/services/cache/page-cache-service.d.ts +70 -0
- package/src/services/cache/page-cache-service.js +152 -0
- package/src/services/cache/page-cache-service.ts +202 -0
- package/src/services/html-transformer.service.d.ts +50 -0
- package/src/services/html-transformer.service.js +163 -0
- package/src/services/html-transformer.service.ts +217 -0
- package/src/services/page-module-import.service.d.ts +37 -0
- package/src/services/page-module-import.service.js +88 -0
- package/src/services/page-module-import.service.ts +129 -0
- package/src/services/page-request-cache-coordinator.service.d.ts +75 -0
- package/src/services/page-request-cache-coordinator.service.js +107 -0
- package/src/services/page-request-cache-coordinator.service.ts +128 -0
- package/src/services/schema-validation-service.d.ts +122 -0
- package/src/services/schema-validation-service.js +101 -0
- package/src/services/schema-validation-service.ts +204 -0
- package/src/services/validation/standard-schema.types.d.ts +65 -0
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/services/validation/standard-schema.types.ts +68 -0
- package/src/static-site-generator/static-site-generator.d.ts +57 -0
- package/src/static-site-generator/static-site-generator.js +272 -0
- package/src/static-site-generator/static-site-generator.ts +359 -0
- package/src/utils/css.d.ts +1 -0
- package/src/utils/css.js +7 -0
- package/src/utils/css.ts +5 -0
- package/src/utils/deep-merge.d.ts +14 -0
- package/src/utils/deep-merge.js +32 -0
- package/src/utils/deep-merge.ts +47 -0
- package/src/utils/hash.d.ts +1 -0
- package/src/utils/hash.js +7 -0
- package/src/utils/hash.ts +5 -0
- package/src/utils/html.d.ts +1 -0
- package/src/utils/html.js +4 -0
- package/src/utils/html.ts +1 -0
- package/src/utils/invariant.d.ts +5 -0
- package/src/utils/invariant.js +11 -0
- package/src/utils/invariant.ts +15 -0
- package/src/utils/locals-utils.d.ts +15 -0
- package/src/utils/locals-utils.js +24 -0
- package/src/utils/locals-utils.ts +37 -0
- package/src/utils/parse-cli-args.d.ts +24 -0
- package/src/utils/parse-cli-args.js +47 -0
- package/src/utils/parse-cli-args.ts +83 -0
- package/src/utils/path-utils.module.d.ts +5 -0
- package/src/utils/path-utils.module.js +14 -0
- package/src/utils/path-utils.module.ts +14 -0
- package/src/utils/runtime.d.ts +11 -0
- package/src/utils/runtime.js +40 -0
- package/src/utils/runtime.ts +44 -0
- package/src/utils/server-utils.module.d.ts +19 -0
- package/src/utils/server-utils.module.js +56 -0
- package/src/utils/server-utils.module.ts +67 -0
- package/src/watchers/project-watcher.d.ts +120 -0
- package/src/watchers/project-watcher.js +238 -0
- package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
- package/src/watchers/project-watcher.test-helpers.js +51 -0
- package/src/watchers/project-watcher.test-helpers.ts +40 -0
- package/src/watchers/project-watcher.ts +306 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IntegrationPlugin, type IntegrationPluginConfig } from '../../plugins/integration-plugin';
|
|
2
|
+
import { GhtmlRenderer } from './ghtml-renderer';
|
|
3
|
+
/**
|
|
4
|
+
* The name of the ghtml plugin
|
|
5
|
+
*/
|
|
6
|
+
export declare const GHTML_PLUGIN_NAME = "ghtml";
|
|
7
|
+
/**
|
|
8
|
+
* The Ghtml plugin class
|
|
9
|
+
* This plugin provides support for ghtml components in Ecopages
|
|
10
|
+
*/
|
|
11
|
+
export declare class GhtmlPlugin extends IntegrationPlugin {
|
|
12
|
+
renderer: typeof GhtmlRenderer;
|
|
13
|
+
constructor(options?: Omit<IntegrationPluginConfig, 'name'>);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Factory function to create a Ghtml plugin instance
|
|
17
|
+
* @param options Configuration options for the Ghtml plugin
|
|
18
|
+
* @returns A new GhtmlPlugin instance
|
|
19
|
+
*/
|
|
20
|
+
export declare function ghtmlPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): GhtmlPlugin;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IntegrationPlugin } from "../../plugins/integration-plugin";
|
|
2
|
+
import { GhtmlRenderer } from "./ghtml-renderer";
|
|
3
|
+
const GHTML_PLUGIN_NAME = "ghtml";
|
|
4
|
+
class GhtmlPlugin extends IntegrationPlugin {
|
|
5
|
+
renderer = GhtmlRenderer;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super({
|
|
8
|
+
name: GHTML_PLUGIN_NAME,
|
|
9
|
+
extensions: [".ghtml.ts", ".ghtml.tsx", ".ghtml"],
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function ghtmlPlugin(options) {
|
|
15
|
+
return new GhtmlPlugin(options);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
GHTML_PLUGIN_NAME,
|
|
19
|
+
GhtmlPlugin,
|
|
20
|
+
ghtmlPlugin
|
|
21
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IntegrationPlugin, type IntegrationPluginConfig } from '../../plugins/integration-plugin';
|
|
2
|
+
import { GhtmlRenderer } from './ghtml-renderer';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The name of the ghtml plugin
|
|
6
|
+
*/
|
|
7
|
+
export const GHTML_PLUGIN_NAME = 'ghtml';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Ghtml plugin class
|
|
11
|
+
* This plugin provides support for ghtml components in Ecopages
|
|
12
|
+
*/
|
|
13
|
+
export class GhtmlPlugin extends IntegrationPlugin {
|
|
14
|
+
renderer = GhtmlRenderer;
|
|
15
|
+
|
|
16
|
+
constructor(options?: Omit<IntegrationPluginConfig, 'name'>) {
|
|
17
|
+
super({
|
|
18
|
+
name: GHTML_PLUGIN_NAME,
|
|
19
|
+
extensions: ['.ghtml.ts', '.ghtml.tsx', '.ghtml'],
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Factory function to create a Ghtml plugin instance
|
|
27
|
+
* @param options Configuration options for the Ghtml plugin
|
|
28
|
+
* @returns A new GhtmlPlugin instance
|
|
29
|
+
*/
|
|
30
|
+
export function ghtmlPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): GhtmlPlugin {
|
|
31
|
+
return new GhtmlPlugin(options);
|
|
32
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from './build/build-types.js';
|
|
2
|
+
import type { IntegrationPlugin } from './plugins/integration-plugin.js';
|
|
3
|
+
import type { Processor } from './plugins/processor.js';
|
|
4
|
+
import type { PageMetadataProps } from './public-types.js';
|
|
5
|
+
import type { FSRouter } from './router/fs-router.js';
|
|
6
|
+
import type { CacheConfig } from './services/cache/cache.types.js';
|
|
7
|
+
/**
|
|
8
|
+
* The templates used to build the pages and loaded via the includes directory.
|
|
9
|
+
*/
|
|
10
|
+
export type IncludesTemplates = {
|
|
11
|
+
head: string;
|
|
12
|
+
html: string;
|
|
13
|
+
seo: string;
|
|
14
|
+
};
|
|
15
|
+
export interface RobotsPreference {
|
|
16
|
+
/**
|
|
17
|
+
* The user agent
|
|
18
|
+
* If an empty array is provided, it will enable all paths for the user agent
|
|
19
|
+
* If a path is provided, it will disallow the path for the user agent
|
|
20
|
+
*/
|
|
21
|
+
[key: string]: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents the complete configuration object for EcoPages.
|
|
25
|
+
*/
|
|
26
|
+
export type EcoPagesAppConfig = {
|
|
27
|
+
/**
|
|
28
|
+
* The base URL of the website, localhost or the domain
|
|
29
|
+
*/
|
|
30
|
+
baseUrl: string;
|
|
31
|
+
/**
|
|
32
|
+
* The root directory of the project
|
|
33
|
+
* @default "."
|
|
34
|
+
*/
|
|
35
|
+
rootDir: string;
|
|
36
|
+
/**
|
|
37
|
+
* The root directory of the project
|
|
38
|
+
* @default "src"
|
|
39
|
+
*/
|
|
40
|
+
srcDir: string;
|
|
41
|
+
/**
|
|
42
|
+
* The directory where the public files are located
|
|
43
|
+
* @default "public"
|
|
44
|
+
*/
|
|
45
|
+
publicDir: string;
|
|
46
|
+
/**
|
|
47
|
+
* The directory where the pages are located
|
|
48
|
+
* @default "pages"
|
|
49
|
+
*/
|
|
50
|
+
pagesDir: string;
|
|
51
|
+
/**
|
|
52
|
+
* The directory where the includes templates are located
|
|
53
|
+
* @default "includes"
|
|
54
|
+
*/
|
|
55
|
+
includesDir: string;
|
|
56
|
+
/**
|
|
57
|
+
* The directory where the layouts are located
|
|
58
|
+
* @default "layouts"
|
|
59
|
+
*/
|
|
60
|
+
layoutsDir: string;
|
|
61
|
+
/**
|
|
62
|
+
* The templates used for the pages
|
|
63
|
+
* @default "{head: 'head.kita.tsx', html: 'html.kita.tsx', seo: 'seo.kita.tsx'}"
|
|
64
|
+
*/
|
|
65
|
+
includesTemplates: IncludesTemplates;
|
|
66
|
+
/** Error 404 page
|
|
67
|
+
* @default "404.kita.tsx"
|
|
68
|
+
*/
|
|
69
|
+
error404Template: string;
|
|
70
|
+
/**
|
|
71
|
+
* The directory where the output will be located
|
|
72
|
+
* @default "dist"
|
|
73
|
+
*/
|
|
74
|
+
distDir: string;
|
|
75
|
+
/**
|
|
76
|
+
* The templates extensions based on the integrations
|
|
77
|
+
*/
|
|
78
|
+
templatesExt: string[];
|
|
79
|
+
/**
|
|
80
|
+
* The directory where the components are located
|
|
81
|
+
* @default "components"
|
|
82
|
+
*/
|
|
83
|
+
componentsDir: string;
|
|
84
|
+
/**
|
|
85
|
+
* The robots.txt configuration
|
|
86
|
+
*/
|
|
87
|
+
robotsTxt: {
|
|
88
|
+
/**
|
|
89
|
+
* The robots preferences. The key is the user agent and the value is the disallowed paths.
|
|
90
|
+
* @default { "*": [] }
|
|
91
|
+
*/
|
|
92
|
+
preferences: RobotsPreference;
|
|
93
|
+
};
|
|
94
|
+
/** Additional paths to watch. Use this to monitor extra files. It is relative to the rootDir */
|
|
95
|
+
additionalWatchPaths: string[];
|
|
96
|
+
/**
|
|
97
|
+
* @default { title: 'Ecopages', description: 'Ecopages' }
|
|
98
|
+
*/
|
|
99
|
+
defaultMetadata: PageMetadataProps;
|
|
100
|
+
/** Integrations plugins */
|
|
101
|
+
integrations: IntegrationPlugin[];
|
|
102
|
+
/** Integrations dependencies */
|
|
103
|
+
integrationsDependencies: IntegrationDependencyConfig[];
|
|
104
|
+
/** Derived Paths */
|
|
105
|
+
absolutePaths: {
|
|
106
|
+
config: string;
|
|
107
|
+
componentsDir: string;
|
|
108
|
+
distDir: string;
|
|
109
|
+
includesDir: string;
|
|
110
|
+
layoutsDir: string;
|
|
111
|
+
pagesDir: string;
|
|
112
|
+
projectDir: string;
|
|
113
|
+
publicDir: string;
|
|
114
|
+
srcDir: string;
|
|
115
|
+
htmlTemplatePath: string;
|
|
116
|
+
error404TemplatePath: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The processors to be used in the app
|
|
120
|
+
*/
|
|
121
|
+
processors: Map<string, Processor>;
|
|
122
|
+
/**
|
|
123
|
+
* Loaders to be used in the app, these are used to process the files when importing them
|
|
124
|
+
*/
|
|
125
|
+
loaders: Map<string, EcoBuildPlugin>;
|
|
126
|
+
/**
|
|
127
|
+
* Cache configuration for ISR and page caching.
|
|
128
|
+
* @default { store: 'memory', defaultStrategy: 'static', enabled: true }
|
|
129
|
+
*/
|
|
130
|
+
cache?: CacheConfig;
|
|
131
|
+
/**
|
|
132
|
+
* Experimental features.
|
|
133
|
+
*/
|
|
134
|
+
experimental?: {
|
|
135
|
+
/** Escape hatch for short-lived private toggles. No validation or IntelliSense. */
|
|
136
|
+
unsafe?: Record<string, unknown>;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export type IntegrationDependencyConfig = {
|
|
140
|
+
integration: string;
|
|
141
|
+
kind: 'script' | 'stylesheet';
|
|
142
|
+
position?: 'head' | 'body';
|
|
143
|
+
srcUrl: string;
|
|
144
|
+
filePath: string;
|
|
145
|
+
/** @todo inline dependencies not implemented yet */
|
|
146
|
+
inline?: boolean;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The possible kinds of a route.
|
|
150
|
+
*/
|
|
151
|
+
export type RouteKind = 'exact' | 'catch-all' | 'dynamic';
|
|
152
|
+
/**
|
|
153
|
+
* Represents the result of a route match.
|
|
154
|
+
*/
|
|
155
|
+
export type MatchResult = {
|
|
156
|
+
filePath: string;
|
|
157
|
+
kind: RouteKind;
|
|
158
|
+
pathname: string;
|
|
159
|
+
query?: Record<string, string>;
|
|
160
|
+
params?: Record<string, string | string[]>;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Represents a route in EcoPages.
|
|
164
|
+
*/
|
|
165
|
+
export type Route = {
|
|
166
|
+
kind: RouteKind;
|
|
167
|
+
filePath: string;
|
|
168
|
+
pathname: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Represents the routes in EcoPages.
|
|
172
|
+
*/
|
|
173
|
+
export type Routes = Record<string, Route>;
|
|
174
|
+
/**
|
|
175
|
+
* Represents the options for the file system server.
|
|
176
|
+
*/
|
|
177
|
+
export type FileSystemServerOptions = {
|
|
178
|
+
watchMode: boolean;
|
|
179
|
+
port?: number | string;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Represents the file system server adapter.
|
|
183
|
+
*/
|
|
184
|
+
export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
|
|
185
|
+
startServer(serverOptions: ServerInstanceOptions): {
|
|
186
|
+
router: FSRouter;
|
|
187
|
+
server: unknown;
|
|
188
|
+
} | Promise<{
|
|
189
|
+
router: FSRouter;
|
|
190
|
+
server: unknown;
|
|
191
|
+
}>;
|
|
192
|
+
}
|
|
193
|
+
export interface ProcessorPlugin {
|
|
194
|
+
name: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
setup(): Promise<void>;
|
|
197
|
+
process<T = unknown>(input: T): Promise<T>;
|
|
198
|
+
teardown?(): Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
export type { ClientBridgeEvent, DefaultHmrContext, IHmrManager, IClientBridge } from './public-types.js';
|
|
File without changes
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from './build/build-types.ts';
|
|
2
|
+
import type { IntegrationPlugin } from './plugins/integration-plugin.ts';
|
|
3
|
+
import type { Processor } from './plugins/processor.ts';
|
|
4
|
+
import type { PageMetadataProps } from './public-types.ts';
|
|
5
|
+
import type { FSRouter } from './router/fs-router.ts';
|
|
6
|
+
import type { CacheConfig } from './services/cache/cache.types.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The templates used to build the pages and loaded via the includes directory.
|
|
10
|
+
*/
|
|
11
|
+
export type IncludesTemplates = {
|
|
12
|
+
head: string;
|
|
13
|
+
html: string;
|
|
14
|
+
seo: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export interface RobotsPreference {
|
|
18
|
+
/**
|
|
19
|
+
* The user agent
|
|
20
|
+
* If an empty array is provided, it will enable all paths for the user agent
|
|
21
|
+
* If a path is provided, it will disallow the path for the user agent
|
|
22
|
+
*/
|
|
23
|
+
[key: string]: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Represents the complete configuration object for EcoPages.
|
|
28
|
+
*/
|
|
29
|
+
export type EcoPagesAppConfig = {
|
|
30
|
+
/**
|
|
31
|
+
* The base URL of the website, localhost or the domain
|
|
32
|
+
*/
|
|
33
|
+
baseUrl: string;
|
|
34
|
+
/**
|
|
35
|
+
* The root directory of the project
|
|
36
|
+
* @default "."
|
|
37
|
+
*/
|
|
38
|
+
rootDir: string;
|
|
39
|
+
/**
|
|
40
|
+
* The root directory of the project
|
|
41
|
+
* @default "src"
|
|
42
|
+
*/
|
|
43
|
+
srcDir: string;
|
|
44
|
+
/**
|
|
45
|
+
* The directory where the public files are located
|
|
46
|
+
* @default "public"
|
|
47
|
+
*/
|
|
48
|
+
publicDir: string;
|
|
49
|
+
/**
|
|
50
|
+
* The directory where the pages are located
|
|
51
|
+
* @default "pages"
|
|
52
|
+
*/
|
|
53
|
+
pagesDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* The directory where the includes templates are located
|
|
56
|
+
* @default "includes"
|
|
57
|
+
*/
|
|
58
|
+
includesDir: string;
|
|
59
|
+
/**
|
|
60
|
+
* The directory where the layouts are located
|
|
61
|
+
* @default "layouts"
|
|
62
|
+
*/
|
|
63
|
+
layoutsDir: string;
|
|
64
|
+
/**
|
|
65
|
+
* The templates used for the pages
|
|
66
|
+
* @default "{head: 'head.kita.tsx', html: 'html.kita.tsx', seo: 'seo.kita.tsx'}"
|
|
67
|
+
*/
|
|
68
|
+
includesTemplates: IncludesTemplates;
|
|
69
|
+
/** Error 404 page
|
|
70
|
+
* @default "404.kita.tsx"
|
|
71
|
+
*/
|
|
72
|
+
error404Template: string;
|
|
73
|
+
/**
|
|
74
|
+
* The directory where the output will be located
|
|
75
|
+
* @default "dist"
|
|
76
|
+
*/
|
|
77
|
+
distDir: string;
|
|
78
|
+
/**
|
|
79
|
+
* The templates extensions based on the integrations
|
|
80
|
+
*/
|
|
81
|
+
templatesExt: string[];
|
|
82
|
+
/**
|
|
83
|
+
* The directory where the components are located
|
|
84
|
+
* @default "components"
|
|
85
|
+
*/
|
|
86
|
+
componentsDir: string;
|
|
87
|
+
/**
|
|
88
|
+
* The robots.txt configuration
|
|
89
|
+
*/
|
|
90
|
+
robotsTxt: {
|
|
91
|
+
/**
|
|
92
|
+
* The robots preferences. The key is the user agent and the value is the disallowed paths.
|
|
93
|
+
* @default { "*": [] }
|
|
94
|
+
*/
|
|
95
|
+
preferences: RobotsPreference;
|
|
96
|
+
};
|
|
97
|
+
/** Additional paths to watch. Use this to monitor extra files. It is relative to the rootDir */
|
|
98
|
+
additionalWatchPaths: string[];
|
|
99
|
+
/**
|
|
100
|
+
* @default { title: 'Ecopages', description: 'Ecopages' }
|
|
101
|
+
*/
|
|
102
|
+
defaultMetadata: PageMetadataProps;
|
|
103
|
+
/** Integrations plugins */
|
|
104
|
+
integrations: IntegrationPlugin[];
|
|
105
|
+
/** Integrations dependencies */
|
|
106
|
+
integrationsDependencies: IntegrationDependencyConfig[];
|
|
107
|
+
/** Derived Paths */
|
|
108
|
+
absolutePaths: {
|
|
109
|
+
config: string;
|
|
110
|
+
componentsDir: string;
|
|
111
|
+
distDir: string;
|
|
112
|
+
includesDir: string;
|
|
113
|
+
layoutsDir: string;
|
|
114
|
+
pagesDir: string;
|
|
115
|
+
projectDir: string;
|
|
116
|
+
publicDir: string;
|
|
117
|
+
srcDir: string;
|
|
118
|
+
htmlTemplatePath: string;
|
|
119
|
+
error404TemplatePath: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* The processors to be used in the app
|
|
123
|
+
*/
|
|
124
|
+
processors: Map<string, Processor>;
|
|
125
|
+
/**
|
|
126
|
+
* Loaders to be used in the app, these are used to process the files when importing them
|
|
127
|
+
*/
|
|
128
|
+
loaders: Map<string, EcoBuildPlugin>;
|
|
129
|
+
/**
|
|
130
|
+
* Cache configuration for ISR and page caching.
|
|
131
|
+
* @default { store: 'memory', defaultStrategy: 'static', enabled: true }
|
|
132
|
+
*/
|
|
133
|
+
cache?: CacheConfig;
|
|
134
|
+
/**
|
|
135
|
+
* Experimental features.
|
|
136
|
+
*/
|
|
137
|
+
experimental?: {
|
|
138
|
+
/** Escape hatch for short-lived private toggles. No validation or IntelliSense. */
|
|
139
|
+
unsafe?: Record<string, unknown>;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export type IntegrationDependencyConfig = {
|
|
144
|
+
integration: string;
|
|
145
|
+
kind: 'script' | 'stylesheet';
|
|
146
|
+
position?: 'head' | 'body';
|
|
147
|
+
srcUrl: string;
|
|
148
|
+
filePath: string;
|
|
149
|
+
/** @todo inline dependencies not implemented yet */
|
|
150
|
+
inline?: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The possible kinds of a route.
|
|
155
|
+
*/
|
|
156
|
+
export type RouteKind = 'exact' | 'catch-all' | 'dynamic';
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Represents the result of a route match.
|
|
160
|
+
*/
|
|
161
|
+
export type MatchResult = {
|
|
162
|
+
filePath: string;
|
|
163
|
+
kind: RouteKind;
|
|
164
|
+
pathname: string;
|
|
165
|
+
query?: Record<string, string>;
|
|
166
|
+
params?: Record<string, string | string[]>;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Represents a route in EcoPages.
|
|
171
|
+
*/
|
|
172
|
+
export type Route = {
|
|
173
|
+
kind: RouteKind;
|
|
174
|
+
filePath: string;
|
|
175
|
+
pathname: string;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Represents the routes in EcoPages.
|
|
180
|
+
*/
|
|
181
|
+
export type Routes = Record<string, Route>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Represents the options for the file system server.
|
|
185
|
+
*/
|
|
186
|
+
export type FileSystemServerOptions = {
|
|
187
|
+
watchMode: boolean;
|
|
188
|
+
port?: number | string;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Represents the file system server adapter.
|
|
193
|
+
*/
|
|
194
|
+
export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
|
|
195
|
+
startServer(serverOptions: ServerInstanceOptions):
|
|
196
|
+
| {
|
|
197
|
+
router: FSRouter;
|
|
198
|
+
server: unknown;
|
|
199
|
+
}
|
|
200
|
+
| Promise<{ router: FSRouter; server: unknown }>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface ProcessorPlugin {
|
|
204
|
+
name: string;
|
|
205
|
+
description?: string;
|
|
206
|
+
setup(): Promise<void>;
|
|
207
|
+
process<T = unknown>(input: T): Promise<T>;
|
|
208
|
+
teardown?(): Promise<void>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Re-export HMR types from public-types for internal use
|
|
212
|
+
export type { ClientBridgeEvent, DefaultHmrContext, IHmrManager, IClientBridge } from './public-types.ts';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const RESOLVABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mdx", ".css", ".scss", ".sass", ".less"];
|
|
4
|
+
function findResolvablePath(candidate) {
|
|
5
|
+
if (path.extname(candidate)) {
|
|
6
|
+
return existsSync(candidate) ? candidate : void 0;
|
|
7
|
+
}
|
|
8
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
9
|
+
const fileCandidate = `${candidate}${extension}`;
|
|
10
|
+
if (existsSync(fileCandidate)) {
|
|
11
|
+
return fileCandidate;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
15
|
+
const indexCandidate = path.join(candidate, `index${extension}`);
|
|
16
|
+
if (existsSync(indexCandidate)) {
|
|
17
|
+
return indexCandidate;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function createAliasResolverPlugin(srcDir) {
|
|
23
|
+
return {
|
|
24
|
+
name: "ecopages-alias-resolver",
|
|
25
|
+
setup(build) {
|
|
26
|
+
build.onResolve({ filter: /^@\// }, (args) => {
|
|
27
|
+
const candidate = path.join(srcDir, args.path.slice(2));
|
|
28
|
+
const resolved = findResolvablePath(candidate);
|
|
29
|
+
if (resolved) {
|
|
30
|
+
return { path: resolved };
|
|
31
|
+
}
|
|
32
|
+
return {};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
createAliasResolverPlugin
|
|
39
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { EcoBuildPlugin } from '../build/build-types.ts';
|
|
4
|
+
|
|
5
|
+
const RESOLVABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mdx', '.css', '.scss', '.sass', '.less'];
|
|
6
|
+
|
|
7
|
+
function findResolvablePath(candidate: string): string | undefined {
|
|
8
|
+
if (path.extname(candidate)) {
|
|
9
|
+
return existsSync(candidate) ? candidate : undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
13
|
+
const fileCandidate = `${candidate}${extension}`;
|
|
14
|
+
if (existsSync(fileCandidate)) {
|
|
15
|
+
return fileCandidate;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
20
|
+
const indexCandidate = path.join(candidate, `index${extension}`);
|
|
21
|
+
if (existsSync(indexCandidate)) {
|
|
22
|
+
return indexCandidate;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createAliasResolverPlugin(srcDir: string): EcoBuildPlugin {
|
|
30
|
+
return {
|
|
31
|
+
name: 'ecopages-alias-resolver',
|
|
32
|
+
setup(build) {
|
|
33
|
+
build.onResolve({ filter: /^@\// }, (args) => {
|
|
34
|
+
const candidate = path.join(srcDir, args.path.slice(2));
|
|
35
|
+
const resolved = findResolvablePath(candidate);
|
|
36
|
+
|
|
37
|
+
if (resolved) {
|
|
38
|
+
return { path: resolved };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {};
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun plugin that auto-injects `__eco` metadata into EcoComponent config objects.
|
|
3
|
+
*
|
|
4
|
+
* This plugin uses AST parsing (via oxc-parser) to reliably inject the `__eco` property
|
|
5
|
+
* into EcoComponent config objects at import time. The injected metadata contains:
|
|
6
|
+
* - `dir`: The directory path of the component file (used for dependency resolution)
|
|
7
|
+
* - `integration`: The integration type (e.g., 'react', 'kitajs', 'ghtml', 'lit')
|
|
8
|
+
*
|
|
9
|
+
* The plugin intercepts file loading for all configured integration extensions and
|
|
10
|
+
* transforms component configs before they are executed.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Before transformation:
|
|
15
|
+
* export default eco.page({
|
|
16
|
+
* render: () => '<div>Hello</div>',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // After transformation:
|
|
20
|
+
* export default eco.page({
|
|
21
|
+
* __eco: { id: "<hash>", file: "/path/to/pages/index.tsx", integration: "react" },
|
|
22
|
+
* render: () => '<div>Hello</div>',
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @module eco-component-meta-plugin
|
|
27
|
+
*/
|
|
28
|
+
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
29
|
+
import type { EcoPagesAppConfig } from '../internal-types.js';
|
|
30
|
+
/**
|
|
31
|
+
* Options for creating the eco-component-meta-plugin.
|
|
32
|
+
*/
|
|
33
|
+
export interface EcoComponentDirPluginOptions {
|
|
34
|
+
/** The EcoPages application configuration containing integration settings */
|
|
35
|
+
config: EcoPagesAppConfig;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a build plugin that auto-injects `__eco` metadata into EcoComponent config objects.
|
|
39
|
+
*
|
|
40
|
+
* This plugin intercepts file loading for all integration-compatible files and:
|
|
41
|
+
* 1. Strips any query string from the file path (for dev mode cache-busting)
|
|
42
|
+
* 2. Reads the file contents
|
|
43
|
+
* 3. Parses the AST using oxc-parser to find injection points
|
|
44
|
+
* 4. Injects `__eco: { id: "...", file: "...", integration: "..." }` into config objects
|
|
45
|
+
* 5. Returns the transformed content with the appropriate loader
|
|
46
|
+
*
|
|
47
|
+
* Supported patterns:
|
|
48
|
+
* - `eco.page({ ... })` - Page component declarations
|
|
49
|
+
* - `eco.component({ ... })` - Reusable component declarations
|
|
50
|
+
* - `Component.config = { ... }` - Config assignment pattern
|
|
51
|
+
* - `config: { ... }` - Config property in object literals
|
|
52
|
+
* - `export const config = { ... }` - Exported config declarations
|
|
53
|
+
*
|
|
54
|
+
* @param options - Plugin options containing the EcoPages config
|
|
55
|
+
* @returns A build plugin instance ready for registration
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { createEcoComponentMetaPlugin } from '@ecopages/core';
|
|
60
|
+
*
|
|
61
|
+
* const plugin = createEcoComponentMetaPlugin({ config: appConfig });
|
|
62
|
+
* appConfig.loaders.set(plugin.name, plugin);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
|
|
66
|
+
/**
|
|
67
|
+
* Injects `__eco` metadata into EcoComponent config objects in file content.
|
|
68
|
+
*
|
|
69
|
+
* Uses oxc-parser for robust AST-based code analysis, which handles edge cases
|
|
70
|
+
* that regex-based approaches would miss (e.g., complex generics, nested objects,
|
|
71
|
+
* comments, string literals containing similar patterns).
|
|
72
|
+
*
|
|
73
|
+
* The injection is performed by:
|
|
74
|
+
* 1. Parsing the source code into an AST
|
|
75
|
+
* 2. Walking the AST to find all config object patterns
|
|
76
|
+
* 3. Collecting insertion points (sorted in reverse order to preserve positions)
|
|
77
|
+
* 4. Inserting the `__eco` property at each point
|
|
78
|
+
*
|
|
79
|
+
* @param contents - The source code content to transform
|
|
80
|
+
* @param filePath - Absolute path to the file (used to derive the directory)
|
|
81
|
+
* @param integration - The integration identifier for this file type
|
|
82
|
+
* @returns Transformed source code with `__eco` injected, or original if no patterns found
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const result = injectEcoMeta(
|
|
87
|
+
* 'export default eco.page({ render: () => "<div>Hi</div>" });',
|
|
88
|
+
* '/app/src/pages/index.tsx',
|
|
89
|
+
* 'react'
|
|
90
|
+
* );
|
|
91
|
+
* // Result: 'export default eco.page({ __eco: { id: "<hash>", file: "/app/src/pages/index.tsx", integration: "react" }, render: () => "<div>Hi</div>" });'
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function injectEcoMeta(contents: string, filePath: string, integration: string): string;
|
|
95
|
+
export default createEcoComponentMetaPlugin;
|