@ecopages/core 0.2.0-alpha.9 → 0.2.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 +18 -11
- package/README.md +23 -26
- package/package.json +76 -58
- package/src/adapters/README.md +2 -2
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +4 -4
- package/src/adapters/bun/hmr-manager.js +8 -8
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +6 -5
- package/src/adapters/bun/server-lifecycle.d.ts +4 -4
- package/src/adapters/bun/server-lifecycle.js +2 -2
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +1 -5
- package/src/adapters/index.js +1 -7
- package/src/adapters/node/create-app.d.ts +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +2 -2
- package/src/adapters/node/node-hmr-manager.js +3 -3
- package/src/adapters/node/server-adapter.d.ts +4 -4
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/adapters/shared/define-api-handler.d.ts +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
- package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +3 -1
- package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
- package/src/adapters/shared/runtime-bootstrap.js +1 -1
- package/src/adapters/shared/server-adapter.d.ts +1 -1
- package/src/adapters/shared/server-adapter.js +5 -1
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +3 -3
- package/src/adapters/shared/server-static-builder.d.ts +5 -5
- package/src/adapters/shared/server-static-builder.js +5 -4
- package/src/build/README.md +19 -13
- package/src/build/build-adapter.d.ts +67 -20
- package/src/build/build-adapter.js +420 -19
- package/src/build/dev-build-coordinator.d.ts +10 -12
- package/src/build/dev-build-coordinator.js +8 -15
- package/src/build/esbuild-build-adapter.d.ts +6 -0
- package/src/build/esbuild-build-adapter.js +94 -11
- package/src/build/runtime-build-executor.d.ts +5 -4
- package/src/build/runtime-build-executor.js +5 -3
- package/src/build/runtime-specifier-alias-plugin.js +19 -15
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +25 -2
- package/src/config/config-builder.js +44 -7
- package/src/declarations.d.ts +1 -1
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.js +19 -48
- package/src/eco/eco.types.d.ts +1 -1
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -1
- package/src/hmr/hmr-strategy.d.ts +16 -13
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/js-hmr-strategy.js +2 -2
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +15 -4
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +1 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +26 -20
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +99 -33
- package/src/plugins/integration-plugin.js +68 -21
- package/src/plugins/processor.d.ts +2 -2
- package/src/plugins/processor.js +2 -2
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +14 -20
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
- package/src/route-renderer/orchestration/integration-renderer.js +500 -143
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
- package/src/route-renderer/orchestration/render-execution.service.js +65 -80
- package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
- package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
- package/src/route-renderer/page-loading/page-module-loader.js +7 -5
- package/src/route-renderer/route-renderer.d.ts +5 -3
- package/src/route-renderer/route-renderer.js +13 -3
- package/src/router/README.md +79 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.d.ts +1 -1
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/router/server/fs-router.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
- package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
- package/src/services/assets/asset-processing-service/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/index.js +5 -5
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/processors/index.js +5 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +15 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -1
- package/src/services/assets/browser-bundle.service.js +2 -2
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +2 -2
- package/src/services/html/html-transformer.service.js +4 -10
- package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
- package/src/services/invalidation/development-invalidation.service.js +1 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +77 -2
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
- package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
- package/src/services/module-loading/page-module-import.service.d.ts +4 -0
- package/src/services/module-loading/page-module-import.service.js +38 -9
- package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
- package/src/services/module-loading/server-module-transpiler.service.js +4 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +1 -1
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
- package/src/static-site-generator/static-site-generator.d.ts +2 -2
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
- package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
- package/src/types/public-types.js +0 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.js +1 -1
- package/src/watchers/project-watcher.d.ts +4 -4
- package/src/watchers/project-watcher.js +4 -10
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- package/src/adapters/abstract/application-adapter.ts +0 -337
- package/src/adapters/abstract/router-adapter.ts +0 -30
- package/src/adapters/abstract/server-adapter.ts +0 -79
- package/src/adapters/bun/client-bridge.ts +0 -62
- package/src/adapters/bun/create-app.ts +0 -189
- package/src/adapters/bun/hmr-manager.ts +0 -409
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -499
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -6
- package/src/adapters/node/index.js +0 -11
- package/src/adapters/node/index.ts +0 -16
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -381
- package/src/adapters/node/runtime-adapter.d.ts +0 -46
- package/src/adapters/node/runtime-adapter.js +0 -306
- package/src/adapters/node/runtime-adapter.ts +0 -439
- package/src/adapters/node/server-adapter.ts +0 -488
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
- package/src/adapters/node/write-runtime-manifest.js +0 -12
- package/src/adapters/node/write-runtime-manifest.ts +0 -38
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/define-api-handler.ts +0 -66
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/render-context.ts +0 -120
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.ts +0 -489
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.ts +0 -166
- package/src/build/build-adapter.ts +0 -361
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.ts +0 -221
- package/src/build/esbuild-build-adapter.ts +0 -559
- package/src/build/runtime-build-executor.ts +0 -34
- package/src/build/runtime-specifier-alias-plugin.ts +0 -58
- package/src/config/config-builder.ts +0 -706
- package/src/constants.ts +0 -54
- package/src/create-app.ts +0 -87
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -87
- package/src/eco/component-render-context.ts +0 -224
- package/src/eco/eco.ts +0 -242
- package/src/eco/eco.types.ts +0 -221
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -2
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/hmr/client/hmr-runtime.ts +0 -152
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
- package/src/hmr/hmr.test.e2e.ts +0 -66
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -232
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.ts +0 -481
- package/src/plugins/integration-plugin.ts +0 -226
- package/src/plugins/processor.ts +0 -240
- package/src/plugins/runtime-capability.ts +0 -14
- package/src/public-types.ts +0 -1317
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
- package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
- package/src/route-renderer/component-graph/component-graph.js +0 -72
- package/src/route-renderer/component-graph/component-graph.ts +0 -159
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-marker.ts +0 -117
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -19
- package/src/route-renderer/component-graph/component-reference.ts +0 -29
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
- package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
- package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
- package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
- package/src/route-renderer/route-renderer.ts +0 -115
- package/src/router/client/link-intent.test.browser.ts +0 -51
- package/src/router/client/link-intent.ts +0 -92
- package/src/router/client/navigation-coordinator.ts +0 -433
- package/src/router/server/fs-router-scanner.ts +0 -219
- package/src/router/server/fs-router.ts +0 -122
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
- package/src/services/assets/browser-bundle.service.ts +0 -53
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.ts +0 -103
- package/src/services/html/html-transformer.service.ts +0 -279
- package/src/services/invalidation/development-invalidation.service.ts +0 -261
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
- package/src/services/module-loading/page-module-import.service.ts +0 -200
- package/src/services/module-loading/server-loader.service.d.ts +0 -96
- package/src/services/module-loading/server-loader.service.js +0 -32
- package/src/services/module-loading/server-loader.service.ts +0 -130
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
- package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
- package/src/services/runtime-state/dev-graph.service.ts +0 -217
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
- package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/schema-validation-service.ts +0 -204
- package/src/services/validation/standard-schema.types.ts +0 -68
- package/src/static-site-generator/static-site-generator.ts +0 -462
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/resolve-work-dir.ts +0 -45
- package/src/utils/runtime.ts +0 -44
- package/src/utils/server-utils.module.ts +0 -67
- package/src/watchers/project-watcher.test-helpers.ts +0 -41
- package/src/watchers/project-watcher.ts +0 -363
- /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
- /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/{public-types.js → types/internal-types.js} +0 -0
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import { getAppBuildAdapter } from '../../../../../build/build-adapter.ts';
|
|
4
|
-
import type { NodeModuleScriptAsset } from '../../assets.types';
|
|
5
|
-
import { BaseScriptProcessor } from '../base/base-script-processor';
|
|
6
|
-
|
|
7
|
-
export class NodeModuleScriptProcessor extends BaseScriptProcessor<NodeModuleScriptAsset> {
|
|
8
|
-
async process(dep: NodeModuleScriptAsset) {
|
|
9
|
-
const modulePath = this.resolveModulePath(dep.importPath, this.appConfig.rootDir);
|
|
10
|
-
const moduleName = path.basename(modulePath);
|
|
11
|
-
const filename = dep.name ?? `nm-${moduleName}`;
|
|
12
|
-
const configHash = this.generateHash(
|
|
13
|
-
JSON.stringify({ inline: dep.inline, minify: !dep.inline && this.isProduction, opts: dep.bundleOptions }),
|
|
14
|
-
);
|
|
15
|
-
const cachekey = `${this.buildCacheKey(filename, this.generateHash(modulePath), dep)}:${configHash}`;
|
|
16
|
-
|
|
17
|
-
return this.getOrProcess(cachekey, async () => {
|
|
18
|
-
if (dep.inline) {
|
|
19
|
-
const content = fileSystem.readFileAsBuffer(modulePath).toString();
|
|
20
|
-
return {
|
|
21
|
-
content,
|
|
22
|
-
kind: dep.kind,
|
|
23
|
-
position: dep.position,
|
|
24
|
-
attributes: dep.attributes,
|
|
25
|
-
inline: true,
|
|
26
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const outdir = path.join(this.getAssetsDir(), 'vendors');
|
|
31
|
-
const bundlerOptions = this.getBundlerOptions(dep);
|
|
32
|
-
|
|
33
|
-
const filePath = await this.bundleScript({
|
|
34
|
-
entrypoint: modulePath,
|
|
35
|
-
outdir: outdir,
|
|
36
|
-
minify: this.isProduction,
|
|
37
|
-
naming: bundlerOptions.naming ?? (dep.name ? `${dep.name}-[hash].[ext]` : '[name]-[hash].[ext]'),
|
|
38
|
-
...bundlerOptions,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
filepath: filePath,
|
|
43
|
-
kind: dep.kind,
|
|
44
|
-
position: dep.position,
|
|
45
|
-
attributes: dep.attributes,
|
|
46
|
-
inline: dep.inline,
|
|
47
|
-
excludeFromHtml: dep.excludeFromHtml,
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private resolveModulePath(importPath: string, rootDir: string): string {
|
|
53
|
-
if (path.isAbsolute(importPath) && fileSystem.exists(importPath)) {
|
|
54
|
-
return importPath;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
return getAppBuildAdapter(this.appConfig).resolve(importPath, rootDir);
|
|
59
|
-
} catch {
|
|
60
|
-
return this.resolveModulePathFallback(importPath, rootDir);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private resolveModulePathFallback(importPath: string, rootDir: string, maxDepth = 5): string {
|
|
65
|
-
let currentDir = rootDir;
|
|
66
|
-
let remainingDepth = maxDepth;
|
|
67
|
-
|
|
68
|
-
while (remainingDepth >= 0) {
|
|
69
|
-
const modulePath = path.join(currentDir, 'node_modules', importPath);
|
|
70
|
-
if (fileSystem.exists(modulePath)) {
|
|
71
|
-
return modulePath;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const parentDir = path.dirname(currentDir);
|
|
75
|
-
if (parentDir === currentDir) {
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
currentDir = parentDir;
|
|
80
|
-
remainingDepth -= 1;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
throw new Error(`Could not resolve module '${importPath}' from '${rootDir}'`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import type { ContentStylesheetAsset, ProcessedAsset } from '../../assets.types';
|
|
4
|
-
import { BaseProcessor } from '../base/base-processor';
|
|
5
|
-
|
|
6
|
-
export class ContentStylesheetProcessor extends BaseProcessor<ContentStylesheetAsset> {
|
|
7
|
-
async process(dep: ContentStylesheetAsset): Promise<ProcessedAsset> {
|
|
8
|
-
const hash = this.generateHash(dep.content);
|
|
9
|
-
const filename = `style-${hash}.css`;
|
|
10
|
-
const cachekey = this.buildCacheKey(filename, hash, dep);
|
|
11
|
-
|
|
12
|
-
return this.getOrProcess(cachekey, () => {
|
|
13
|
-
const filepath = path.join(this.getAssetsDir(), 'styles', filename);
|
|
14
|
-
|
|
15
|
-
if (!dep.inline) fileSystem.write(filepath, dep.content);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
filepath: dep.inline ? undefined : filepath,
|
|
19
|
-
content: dep.inline ? dep.content : undefined,
|
|
20
|
-
kind: 'stylesheet',
|
|
21
|
-
position: dep.position,
|
|
22
|
-
attributes: dep.attributes,
|
|
23
|
-
inline: dep.inline,
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import type { FileStylesheetAsset, ProcessedAsset } from '../../assets.types';
|
|
4
|
-
import { BaseProcessor } from '../base/base-processor';
|
|
5
|
-
|
|
6
|
-
export class FileStylesheetProcessor extends BaseProcessor<FileStylesheetAsset> {
|
|
7
|
-
private static readonly PROCESSABLE_STYLESHEET_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
|
|
8
|
-
|
|
9
|
-
getStyleContent = (srcUrl: string): Buffer => {
|
|
10
|
-
return fileSystem.readFileAsBuffer(srcUrl);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
private isProcessableStylesheet(filepath: string): boolean {
|
|
14
|
-
return FileStylesheetProcessor.PROCESSABLE_STYLESHEET_EXTENSIONS.has(path.extname(filepath));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private async applyStylesheetProcessors(content: string, filepath: string): Promise<string> {
|
|
18
|
-
if (!this.isProcessableStylesheet(filepath)) {
|
|
19
|
-
return content;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let transformedContent = content;
|
|
23
|
-
|
|
24
|
-
for (const processor of this.appConfig.processors.values()) {
|
|
25
|
-
const hasCapabilities = processor.getAssetCapabilities().length > 0;
|
|
26
|
-
const canProcessStylesheet = processor.canProcessAsset('stylesheet', filepath);
|
|
27
|
-
|
|
28
|
-
if (!canProcessStylesheet && (hasCapabilities || !processor.getName().includes('postcss'))) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!processor.matchesFileFilter(filepath)) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const result = await processor.process(transformedContent, filepath);
|
|
37
|
-
|
|
38
|
-
if (typeof result === 'string') {
|
|
39
|
-
transformedContent = result;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (result instanceof Buffer) {
|
|
44
|
-
transformedContent = result.toString();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return transformedContent;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async process(dep: FileStylesheetAsset): Promise<ProcessedAsset> {
|
|
52
|
-
const buffer = this.getStyleContent(dep.filepath);
|
|
53
|
-
const rawContent = buffer.toString();
|
|
54
|
-
const processedContent = await this.applyStylesheetProcessors(rawContent, dep.filepath);
|
|
55
|
-
const hash = this.generateHash(processedContent);
|
|
56
|
-
const cachekey = this.buildCacheKey(dep.filepath, hash, dep);
|
|
57
|
-
|
|
58
|
-
return this.getOrProcess(cachekey, () => {
|
|
59
|
-
const filepath = path.join(
|
|
60
|
-
this.getAssetsDir(),
|
|
61
|
-
path.relative(this.appConfig.absolutePaths.srcDir, dep.filepath),
|
|
62
|
-
);
|
|
63
|
-
const outputBuffer = Buffer.from(processedContent);
|
|
64
|
-
|
|
65
|
-
if (!dep.inline) {
|
|
66
|
-
fileSystem.ensureDir(path.dirname(filepath));
|
|
67
|
-
fileSystem.write(filepath, outputBuffer);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
filepath: filepath,
|
|
72
|
-
content: dep.inline ? processedContent : undefined,
|
|
73
|
-
kind: 'stylesheet',
|
|
74
|
-
position: dep.position,
|
|
75
|
-
attributes: dep.attributes,
|
|
76
|
-
inline: dep.inline,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { BuildOptions, BuildResult, BuildTranspileProfile } from '../../build/build-adapter.ts';
|
|
2
|
-
import type { EcoBuildPlugin } from '../../build/build-types.ts';
|
|
3
|
-
import { getAppBrowserBuildPlugins, getAppBuildExecutor, getTranspileOptions } from '../../build/build-adapter.ts';
|
|
4
|
-
import { mergeEcoBuildPlugins } from '../../build/build-manifest.ts';
|
|
5
|
-
import type { EcoPagesAppConfig } from '../../internal-types.ts';
|
|
6
|
-
|
|
7
|
-
export type BrowserBundleOptions = Omit<BuildOptions, 'target' | 'format' | 'sourcemap'> & {
|
|
8
|
-
profile: BuildTranspileProfile;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export interface BrowserBundleExecutor {
|
|
12
|
-
bundle(options: BrowserBundleOptions): Promise<BuildResult>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* App-owned boundary for browser-oriented bundle work.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* This service owns the shared browser transpile defaults and ensures browser
|
|
20
|
-
* builds always run through the app-owned executor rather than direct backend
|
|
21
|
-
* calls scattered across HMR and asset processing paths.
|
|
22
|
-
*/
|
|
23
|
-
export class BrowserBundleService implements BrowserBundleExecutor {
|
|
24
|
-
private readonly appConfig: EcoPagesAppConfig;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Creates the browser bundle boundary for one finalized app instance.
|
|
28
|
-
*/
|
|
29
|
-
constructor(appConfig: EcoPagesAppConfig) {
|
|
30
|
-
this.appConfig = appConfig;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Runs one browser-targeted build through the app-owned executor.
|
|
35
|
-
*
|
|
36
|
-
* @remarks
|
|
37
|
-
* Browser defaults and app-owned browser build plugins are applied here so HMR
|
|
38
|
-
* and runtime asset generation do not have to recreate that policy at each call
|
|
39
|
-
* site.
|
|
40
|
-
*/
|
|
41
|
-
async bundle(options: BrowserBundleOptions): Promise<BuildResult> {
|
|
42
|
-
const { profile, ...rawBuildOptions } = options;
|
|
43
|
-
const buildOptions = rawBuildOptions as Omit<BuildOptions, 'target' | 'format' | 'sourcemap'>;
|
|
44
|
-
const plugins = buildOptions.plugins as EcoBuildPlugin[] | undefined;
|
|
45
|
-
const request = {
|
|
46
|
-
...buildOptions,
|
|
47
|
-
...getTranspileOptions(profile),
|
|
48
|
-
plugins: mergeEcoBuildPlugins(plugins, getAppBrowserBuildPlugins(this.appConfig)),
|
|
49
|
-
} as BuildOptions;
|
|
50
|
-
|
|
51
|
-
return await getAppBuildExecutor(this.appConfig).build(request);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache types and interfaces for page caching and ISR
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Result from rendering a page, including HTML and cache strategy.
|
|
8
|
-
*/
|
|
9
|
-
export interface RenderResult {
|
|
10
|
-
html: string;
|
|
11
|
-
strategy: CacheStrategy;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Render strategy configuration for pages.
|
|
16
|
-
* - `'static'`: Render once, cache indefinitely
|
|
17
|
-
* - `'dynamic'`: No caching, render on every request
|
|
18
|
-
* - `{ revalidate, tags }`: Cache with time-based revalidation and optional tags
|
|
19
|
-
*/
|
|
20
|
-
export type CacheStrategy =
|
|
21
|
-
| 'static'
|
|
22
|
-
| 'dynamic'
|
|
23
|
-
| {
|
|
24
|
-
/** Seconds until cache is considered stale */
|
|
25
|
-
revalidate: number;
|
|
26
|
-
/** Tags for on-demand invalidation */
|
|
27
|
-
tags?: string[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Cache entry stored in the cache store.
|
|
32
|
-
*/
|
|
33
|
-
export interface CacheEntry {
|
|
34
|
-
/** The rendered HTML content */
|
|
35
|
-
html: string;
|
|
36
|
-
/** Timestamp when the entry was created */
|
|
37
|
-
createdAt: number;
|
|
38
|
-
/** Timestamp when the entry should be revalidated (null = never stale) */
|
|
39
|
-
revalidateAfter: number | null;
|
|
40
|
-
/** Tags associated with this entry for invalidation */
|
|
41
|
-
tags: string[];
|
|
42
|
-
/** The cache strategy used (for generating headers on HIT) */
|
|
43
|
-
strategy: CacheStrategy;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Cache statistics for debugging and monitoring.
|
|
48
|
-
*/
|
|
49
|
-
export interface CacheStats {
|
|
50
|
-
/** Number of entries in the cache */
|
|
51
|
-
entries: number;
|
|
52
|
-
/** Memory usage in bytes (if available) */
|
|
53
|
-
memoryUsage?: number;
|
|
54
|
-
/** Cache hit rate (if tracked) */
|
|
55
|
-
hitRate?: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Abstract interface for cache storage backends.
|
|
60
|
-
* Implementations must handle serialization/deserialization internally.
|
|
61
|
-
*/
|
|
62
|
-
export interface CacheStore {
|
|
63
|
-
/** Retrieve an entry by key */
|
|
64
|
-
get(key: string): Promise<CacheEntry | null>;
|
|
65
|
-
|
|
66
|
-
/** Store an entry */
|
|
67
|
-
set(key: string, entry: CacheEntry): Promise<void>;
|
|
68
|
-
|
|
69
|
-
/** Delete a specific entry */
|
|
70
|
-
delete(key: string): Promise<boolean>;
|
|
71
|
-
|
|
72
|
-
/** Delete all entries matching any of the provided tags */
|
|
73
|
-
invalidateByTags(tags: string[]): Promise<number>;
|
|
74
|
-
|
|
75
|
-
/** Delete entries by exact path */
|
|
76
|
-
invalidateByPaths(paths: string[]): Promise<number>;
|
|
77
|
-
|
|
78
|
-
/** Clear all entries */
|
|
79
|
-
clear(): Promise<void>;
|
|
80
|
-
|
|
81
|
-
/** Get cache statistics (optional, for debugging) */
|
|
82
|
-
stats?(): Promise<CacheStats>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Configuration for the cache system.
|
|
87
|
-
*/
|
|
88
|
-
export interface CacheConfig {
|
|
89
|
-
/**
|
|
90
|
-
* Cache store implementation.
|
|
91
|
-
* @default 'memory'
|
|
92
|
-
*/
|
|
93
|
-
store?: 'memory' | CacheStore;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Default cache strategy for pages that don't specify one.
|
|
97
|
-
* @default 'static'
|
|
98
|
-
*/
|
|
99
|
-
defaultStrategy?: CacheStrategy;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Whether caching is enabled.
|
|
103
|
-
* Automatically disabled in dev mode unless explicitly set.
|
|
104
|
-
* @default true (production), false (development)
|
|
105
|
-
*/
|
|
106
|
-
enabled?: boolean;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Maximum number of entries in the memory cache before LRU eviction.
|
|
110
|
-
* Only applies when using the built-in memory store.
|
|
111
|
-
* @default 1000
|
|
112
|
-
*/
|
|
113
|
-
maxEntries?: number;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Result of a cache lookup operation.
|
|
118
|
-
*/
|
|
119
|
-
export interface CacheResult {
|
|
120
|
-
/** The cached HTML content */
|
|
121
|
-
html: string;
|
|
122
|
-
/** Cache status for X-Cache header */
|
|
123
|
-
status: 'hit' | 'miss' | 'stale';
|
|
124
|
-
/** The cache strategy (for generating Cache-Control headers) */
|
|
125
|
-
strategy: CacheStrategy;
|
|
126
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache services exports
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type {
|
|
7
|
-
CacheConfig,
|
|
8
|
-
CacheEntry,
|
|
9
|
-
CacheResult,
|
|
10
|
-
CacheStats,
|
|
11
|
-
CacheStore,
|
|
12
|
-
CacheStrategy,
|
|
13
|
-
RenderResult,
|
|
14
|
-
} from './cache.types.js';
|
|
15
|
-
|
|
16
|
-
export { MemoryCacheStore, type MemoryCacheStoreOptions } from './memory-cache-store.js';
|
|
17
|
-
|
|
18
|
-
export { getCacheControlHeader, PageCacheService, type PageCacheServiceOptions } from './page-cache-service.js';
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory cache store with LRU eviction.
|
|
3
|
-
* Suitable for single-instance deployments and development.
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { CacheEntry, CacheStats, CacheStore } from './cache.types.js';
|
|
8
|
-
|
|
9
|
-
export interface MemoryCacheStoreOptions {
|
|
10
|
-
/** Maximum number of entries before LRU eviction. @default 1000 */
|
|
11
|
-
maxEntries?: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Simple in-memory cache store with LRU eviction.
|
|
16
|
-
* Uses Map insertion order for LRU tracking.
|
|
17
|
-
*/
|
|
18
|
-
export class MemoryCacheStore implements CacheStore {
|
|
19
|
-
private cache = new Map<string, CacheEntry>();
|
|
20
|
-
private tagIndex = new Map<string, Set<string>>();
|
|
21
|
-
private readonly maxEntries: number;
|
|
22
|
-
|
|
23
|
-
constructor(options: MemoryCacheStoreOptions = {}) {
|
|
24
|
-
this.maxEntries = options.maxEntries ?? 1000;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Retrieve an entry by key.
|
|
29
|
-
* Uses Map's insertion order for LRU tracking - accessed entries are
|
|
30
|
-
* deleted and re-inserted to move them to the "most recently used" position.
|
|
31
|
-
*/
|
|
32
|
-
async get(key: string): Promise<CacheEntry | null> {
|
|
33
|
-
const entry = this.cache.get(key);
|
|
34
|
-
if (!entry) return null;
|
|
35
|
-
|
|
36
|
-
this.cache.delete(key);
|
|
37
|
-
this.cache.set(key, entry);
|
|
38
|
-
|
|
39
|
-
return entry;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Store an entry, evicting the oldest if at capacity.
|
|
44
|
-
* When maxEntries is reached and a new key is added, the first key in
|
|
45
|
-
* the Map (oldest/least-recently-used) is evicted to make room.
|
|
46
|
-
* Updating an existing key refreshes its LRU position.
|
|
47
|
-
*/
|
|
48
|
-
async set(key: string, entry: CacheEntry): Promise<void> {
|
|
49
|
-
const existingEntry = this.cache.get(key);
|
|
50
|
-
|
|
51
|
-
if (existingEntry) {
|
|
52
|
-
for (const tag of existingEntry.tags) {
|
|
53
|
-
this.tagIndex.get(tag)?.delete(key);
|
|
54
|
-
if (this.tagIndex.get(tag)?.size === 0) {
|
|
55
|
-
this.tagIndex.delete(tag);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
this.cache.delete(key);
|
|
59
|
-
} else if (this.cache.size >= this.maxEntries) {
|
|
60
|
-
const oldestKey = this.cache.keys().next().value;
|
|
61
|
-
if (oldestKey) await this.delete(oldestKey);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.cache.set(key, entry);
|
|
65
|
-
|
|
66
|
-
for (const tag of entry.tags) {
|
|
67
|
-
if (!this.tagIndex.has(tag)) {
|
|
68
|
-
this.tagIndex.set(tag, new Set());
|
|
69
|
-
}
|
|
70
|
-
this.tagIndex.get(tag)!.add(key);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Delete an entry and clean up its tag index references.
|
|
76
|
-
* Removes empty tag sets to prevent memory leaks from accumulated tags.
|
|
77
|
-
*/
|
|
78
|
-
async delete(key: string): Promise<boolean> {
|
|
79
|
-
const entry = this.cache.get(key);
|
|
80
|
-
if (!entry) return false;
|
|
81
|
-
|
|
82
|
-
for (const tag of entry.tags) {
|
|
83
|
-
this.tagIndex.get(tag)?.delete(key);
|
|
84
|
-
if (this.tagIndex.get(tag)?.size === 0) {
|
|
85
|
-
this.tagIndex.delete(tag);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return this.cache.delete(key);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async invalidateByTags(tags: string[]): Promise<number> {
|
|
93
|
-
let count = 0;
|
|
94
|
-
const keysToDelete = new Set<string>();
|
|
95
|
-
|
|
96
|
-
for (const tag of tags) {
|
|
97
|
-
const keys = this.tagIndex.get(tag);
|
|
98
|
-
if (keys) {
|
|
99
|
-
for (const key of keys) {
|
|
100
|
-
keysToDelete.add(key);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
for (const key of keysToDelete) {
|
|
106
|
-
if (await this.delete(key)) count++;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return count;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async invalidateByPaths(paths: string[]): Promise<number> {
|
|
113
|
-
let count = 0;
|
|
114
|
-
for (const path of paths) {
|
|
115
|
-
if (await this.delete(path)) count++;
|
|
116
|
-
}
|
|
117
|
-
return count;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async clear(): Promise<void> {
|
|
121
|
-
this.cache.clear();
|
|
122
|
-
this.tagIndex.clear();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async stats(): Promise<CacheStats> {
|
|
126
|
-
return {
|
|
127
|
-
entries: this.cache.size,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|