@frontmcp/uipack 0.6.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/CLAUDE.md +246 -0
- package/LICENSE +201 -0
- package/README.md +150 -0
- package/adapters/index.d.ts +13 -0
- package/adapters/index.d.ts.map +1 -0
- package/adapters/index.js +462 -0
- package/adapters/platform-meta.d.ts +166 -0
- package/adapters/platform-meta.d.ts.map +1 -0
- package/adapters/response-builder.d.ts +108 -0
- package/adapters/response-builder.d.ts.map +1 -0
- package/adapters/serving-mode.d.ts +107 -0
- package/adapters/serving-mode.d.ts.map +1 -0
- package/base-template/bridge.d.ts +90 -0
- package/base-template/bridge.d.ts.map +1 -0
- package/base-template/default-base-template.d.ts +92 -0
- package/base-template/default-base-template.d.ts.map +1 -0
- package/base-template/index.d.ts +15 -0
- package/base-template/index.d.ts.map +1 -0
- package/base-template/index.js +1398 -0
- package/base-template/polyfills.d.ts +31 -0
- package/base-template/polyfills.d.ts.map +1 -0
- package/base-template/theme-styles.d.ts +74 -0
- package/base-template/theme-styles.d.ts.map +1 -0
- package/bridge-runtime/iife-generator.d.ts +62 -0
- package/bridge-runtime/iife-generator.d.ts.map +1 -0
- package/bridge-runtime/index.d.ts +10 -0
- package/bridge-runtime/index.d.ts.map +1 -0
- package/bridge-runtime/index.js +883 -0
- package/build/cdn-resources.d.ts +243 -0
- package/build/cdn-resources.d.ts.map +1 -0
- package/build/index.d.ts +295 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +6861 -0
- package/build/widget-manifest.d.ts +362 -0
- package/build/widget-manifest.d.ts.map +1 -0
- package/bundler/cache.d.ts +173 -0
- package/bundler/cache.d.ts.map +1 -0
- package/bundler/file-cache/component-builder.d.ts +167 -0
- package/bundler/file-cache/component-builder.d.ts.map +1 -0
- package/bundler/file-cache/hash-calculator.d.ts +155 -0
- package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
- package/bundler/file-cache/index.d.ts +12 -0
- package/bundler/file-cache/index.d.ts.map +1 -0
- package/bundler/file-cache/storage/filesystem.d.ts +149 -0
- package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
- package/bundler/file-cache/storage/index.d.ts +11 -0
- package/bundler/file-cache/storage/index.d.ts.map +1 -0
- package/bundler/file-cache/storage/interface.d.ts +152 -0
- package/bundler/file-cache/storage/interface.d.ts.map +1 -0
- package/bundler/file-cache/storage/redis.d.ts +139 -0
- package/bundler/file-cache/storage/redis.d.ts.map +1 -0
- package/bundler/index.d.ts +35 -0
- package/bundler/index.d.ts.map +1 -0
- package/bundler/index.js +2947 -0
- package/bundler/sandbox/enclave-adapter.d.ts +121 -0
- package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
- package/bundler/sandbox/executor.d.ts +14 -0
- package/bundler/sandbox/executor.d.ts.map +1 -0
- package/bundler/sandbox/policy.d.ts +62 -0
- package/bundler/sandbox/policy.d.ts.map +1 -0
- package/bundler/types.d.ts +702 -0
- package/bundler/types.d.ts.map +1 -0
- package/dependency/cdn-registry.d.ts +98 -0
- package/dependency/cdn-registry.d.ts.map +1 -0
- package/dependency/import-map.d.ts +186 -0
- package/dependency/import-map.d.ts.map +1 -0
- package/dependency/import-parser.d.ts +82 -0
- package/dependency/import-parser.d.ts.map +1 -0
- package/dependency/index.d.ts +17 -0
- package/dependency/index.d.ts.map +1 -0
- package/dependency/index.js +3215 -0
- package/dependency/resolver.d.ts +164 -0
- package/dependency/resolver.d.ts.map +1 -0
- package/dependency/schemas.d.ts +486 -0
- package/dependency/schemas.d.ts.map +1 -0
- package/dependency/template-loader.d.ts +204 -0
- package/dependency/template-loader.d.ts.map +1 -0
- package/dependency/template-processor.d.ts +118 -0
- package/dependency/template-processor.d.ts.map +1 -0
- package/dependency/types.d.ts +739 -0
- package/dependency/types.d.ts.map +1 -0
- package/esm/adapters/index.d.ts +13 -0
- package/esm/adapters/index.d.ts.map +1 -0
- package/esm/adapters/index.js +427 -0
- package/esm/adapters/platform-meta.d.ts +166 -0
- package/esm/adapters/platform-meta.d.ts.map +1 -0
- package/esm/adapters/response-builder.d.ts +108 -0
- package/esm/adapters/response-builder.d.ts.map +1 -0
- package/esm/adapters/serving-mode.d.ts +107 -0
- package/esm/adapters/serving-mode.d.ts.map +1 -0
- package/esm/base-template/bridge.d.ts +90 -0
- package/esm/base-template/bridge.d.ts.map +1 -0
- package/esm/base-template/default-base-template.d.ts +92 -0
- package/esm/base-template/default-base-template.d.ts.map +1 -0
- package/esm/base-template/index.d.ts +15 -0
- package/esm/base-template/index.d.ts.map +1 -0
- package/esm/base-template/index.js +1364 -0
- package/esm/base-template/polyfills.d.ts +31 -0
- package/esm/base-template/polyfills.d.ts.map +1 -0
- package/esm/base-template/theme-styles.d.ts +74 -0
- package/esm/base-template/theme-styles.d.ts.map +1 -0
- package/esm/bridge-runtime/iife-generator.d.ts +62 -0
- package/esm/bridge-runtime/iife-generator.d.ts.map +1 -0
- package/esm/bridge-runtime/index.d.ts +10 -0
- package/esm/bridge-runtime/index.d.ts.map +1 -0
- package/esm/bridge-runtime/index.js +853 -0
- package/esm/build/cdn-resources.d.ts +243 -0
- package/esm/build/cdn-resources.d.ts.map +1 -0
- package/esm/build/index.d.ts +295 -0
- package/esm/build/index.d.ts.map +1 -0
- package/esm/build/index.js +6786 -0
- package/esm/build/widget-manifest.d.ts +362 -0
- package/esm/build/widget-manifest.d.ts.map +1 -0
- package/esm/bundler/cache.d.ts +173 -0
- package/esm/bundler/cache.d.ts.map +1 -0
- package/esm/bundler/file-cache/component-builder.d.ts +167 -0
- package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
- package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
- package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
- package/esm/bundler/file-cache/index.d.ts +12 -0
- package/esm/bundler/file-cache/index.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
- package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/index.d.ts +11 -0
- package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
- package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
- package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
- package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
- package/esm/bundler/index.d.ts +35 -0
- package/esm/bundler/index.d.ts.map +1 -0
- package/esm/bundler/index.js +2882 -0
- package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
- package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
- package/esm/bundler/sandbox/executor.d.ts +14 -0
- package/esm/bundler/sandbox/executor.d.ts.map +1 -0
- package/esm/bundler/sandbox/policy.d.ts +62 -0
- package/esm/bundler/sandbox/policy.d.ts.map +1 -0
- package/esm/bundler/types.d.ts +702 -0
- package/esm/bundler/types.d.ts.map +1 -0
- package/esm/dependency/cdn-registry.d.ts +98 -0
- package/esm/dependency/cdn-registry.d.ts.map +1 -0
- package/esm/dependency/import-map.d.ts +186 -0
- package/esm/dependency/import-map.d.ts.map +1 -0
- package/esm/dependency/import-parser.d.ts +82 -0
- package/esm/dependency/import-parser.d.ts.map +1 -0
- package/esm/dependency/index.d.ts +17 -0
- package/esm/dependency/index.d.ts.map +1 -0
- package/esm/dependency/index.js +3096 -0
- package/esm/dependency/resolver.d.ts +164 -0
- package/esm/dependency/resolver.d.ts.map +1 -0
- package/esm/dependency/schemas.d.ts +486 -0
- package/esm/dependency/schemas.d.ts.map +1 -0
- package/esm/dependency/template-loader.d.ts +204 -0
- package/esm/dependency/template-loader.d.ts.map +1 -0
- package/esm/dependency/template-processor.d.ts +118 -0
- package/esm/dependency/template-processor.d.ts.map +1 -0
- package/esm/dependency/types.d.ts +739 -0
- package/esm/dependency/types.d.ts.map +1 -0
- package/esm/handlebars/expression-extractor.d.ts +147 -0
- package/esm/handlebars/expression-extractor.d.ts.map +1 -0
- package/esm/handlebars/helpers.d.ts +339 -0
- package/esm/handlebars/helpers.d.ts.map +1 -0
- package/esm/handlebars/index.d.ts +195 -0
- package/esm/handlebars/index.d.ts.map +1 -0
- package/esm/handlebars/index.js +587 -0
- package/esm/index.d.ts +50 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +12434 -0
- package/esm/package.json +68 -0
- package/esm/registry/index.d.ts +46 -0
- package/esm/registry/index.d.ts.map +1 -0
- package/esm/registry/index.js +6237 -0
- package/esm/registry/render-template.d.ts +91 -0
- package/esm/registry/render-template.d.ts.map +1 -0
- package/esm/registry/tool-ui.registry.d.ts +294 -0
- package/esm/registry/tool-ui.registry.d.ts.map +1 -0
- package/esm/registry/uri-utils.d.ts +56 -0
- package/esm/registry/uri-utils.d.ts.map +1 -0
- package/esm/renderers/cache.d.ts +145 -0
- package/esm/renderers/cache.d.ts.map +1 -0
- package/esm/renderers/html.renderer.d.ts +123 -0
- package/esm/renderers/html.renderer.d.ts.map +1 -0
- package/esm/renderers/index.d.ts +36 -0
- package/esm/renderers/index.d.ts.map +1 -0
- package/esm/renderers/index.js +1654 -0
- package/esm/renderers/mdx.renderer.d.ts +120 -0
- package/esm/renderers/mdx.renderer.d.ts.map +1 -0
- package/esm/renderers/registry.d.ts +133 -0
- package/esm/renderers/registry.d.ts.map +1 -0
- package/esm/renderers/types.d.ts +342 -0
- package/esm/renderers/types.d.ts.map +1 -0
- package/esm/renderers/utils/detect.d.ts +107 -0
- package/esm/renderers/utils/detect.d.ts.map +1 -0
- package/esm/renderers/utils/hash.d.ts +40 -0
- package/esm/renderers/utils/hash.d.ts.map +1 -0
- package/esm/renderers/utils/index.d.ts +9 -0
- package/esm/renderers/utils/index.d.ts.map +1 -0
- package/esm/renderers/utils/transpiler.d.ts +89 -0
- package/esm/renderers/utils/transpiler.d.ts.map +1 -0
- package/esm/runtime/adapters/html.adapter.d.ts +59 -0
- package/esm/runtime/adapters/html.adapter.d.ts.map +1 -0
- package/esm/runtime/adapters/index.d.ts +26 -0
- package/esm/runtime/adapters/index.d.ts.map +1 -0
- package/esm/runtime/adapters/mdx.adapter.d.ts +73 -0
- package/esm/runtime/adapters/mdx.adapter.d.ts.map +1 -0
- package/esm/runtime/adapters/types.d.ts +95 -0
- package/esm/runtime/adapters/types.d.ts.map +1 -0
- package/esm/runtime/csp.d.ts +48 -0
- package/esm/runtime/csp.d.ts.map +1 -0
- package/esm/runtime/index.d.ts +17 -0
- package/esm/runtime/index.d.ts.map +1 -0
- package/esm/runtime/index.js +4976 -0
- package/esm/runtime/mcp-bridge.d.ts +101 -0
- package/esm/runtime/mcp-bridge.d.ts.map +1 -0
- package/esm/runtime/renderer-runtime.d.ts +133 -0
- package/esm/runtime/renderer-runtime.d.ts.map +1 -0
- package/esm/runtime/sanitizer.d.ts +172 -0
- package/esm/runtime/sanitizer.d.ts.map +1 -0
- package/esm/runtime/types.d.ts +415 -0
- package/esm/runtime/types.d.ts.map +1 -0
- package/esm/runtime/wrapper.d.ts +421 -0
- package/esm/runtime/wrapper.d.ts.map +1 -0
- package/esm/styles/index.d.ts +8 -0
- package/esm/styles/index.d.ts.map +1 -0
- package/esm/styles/index.js +171 -0
- package/esm/styles/variants.d.ts +51 -0
- package/esm/styles/variants.d.ts.map +1 -0
- package/esm/theme/cdn.d.ts +195 -0
- package/esm/theme/cdn.d.ts.map +1 -0
- package/esm/theme/index.d.ts +18 -0
- package/esm/theme/index.d.ts.map +1 -0
- package/esm/theme/index.js +700 -0
- package/esm/theme/platforms.d.ts +107 -0
- package/esm/theme/platforms.d.ts.map +1 -0
- package/esm/theme/presets/github-openai.d.ts +50 -0
- package/esm/theme/presets/github-openai.d.ts.map +1 -0
- package/esm/theme/presets/index.d.ts +11 -0
- package/esm/theme/presets/index.d.ts.map +1 -0
- package/esm/theme/theme.d.ts +396 -0
- package/esm/theme/theme.d.ts.map +1 -0
- package/esm/tool-template/builder.d.ts +213 -0
- package/esm/tool-template/builder.d.ts.map +1 -0
- package/esm/tool-template/index.d.ts +16 -0
- package/esm/tool-template/index.d.ts.map +1 -0
- package/esm/tool-template/index.js +3518 -0
- package/esm/types/index.d.ts +14 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +75 -0
- package/esm/types/ui-config.d.ts +641 -0
- package/esm/types/ui-config.d.ts.map +1 -0
- package/esm/types/ui-runtime.d.ts +1008 -0
- package/esm/types/ui-runtime.d.ts.map +1 -0
- package/esm/typings/cache/cache-adapter.d.ts +125 -0
- package/esm/typings/cache/cache-adapter.d.ts.map +1 -0
- package/esm/typings/cache/index.d.ts +10 -0
- package/esm/typings/cache/index.d.ts.map +1 -0
- package/esm/typings/cache/memory-cache.d.ts +92 -0
- package/esm/typings/cache/memory-cache.d.ts.map +1 -0
- package/esm/typings/dts-parser.d.ts +90 -0
- package/esm/typings/dts-parser.d.ts.map +1 -0
- package/esm/typings/index.d.ts +48 -0
- package/esm/typings/index.d.ts.map +1 -0
- package/esm/typings/index.js +812 -0
- package/esm/typings/schemas.d.ts +232 -0
- package/esm/typings/schemas.d.ts.map +1 -0
- package/esm/typings/type-fetcher.d.ts +89 -0
- package/esm/typings/type-fetcher.d.ts.map +1 -0
- package/esm/typings/types.d.ts +320 -0
- package/esm/typings/types.d.ts.map +1 -0
- package/esm/utils/escape-html.d.ts +58 -0
- package/esm/utils/escape-html.d.ts.map +1 -0
- package/esm/utils/index.d.ts +10 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +40 -0
- package/esm/utils/safe-stringify.d.ts +30 -0
- package/esm/utils/safe-stringify.d.ts.map +1 -0
- package/esm/validation/error-box.d.ts +56 -0
- package/esm/validation/error-box.d.ts.map +1 -0
- package/esm/validation/index.d.ts +13 -0
- package/esm/validation/index.d.ts.map +1 -0
- package/esm/validation/index.js +542 -0
- package/esm/validation/schema-paths.d.ts +118 -0
- package/esm/validation/schema-paths.d.ts.map +1 -0
- package/esm/validation/template-validator.d.ts +143 -0
- package/esm/validation/template-validator.d.ts.map +1 -0
- package/esm/validation/wrapper.d.ts +97 -0
- package/esm/validation/wrapper.d.ts.map +1 -0
- package/handlebars/expression-extractor.d.ts +147 -0
- package/handlebars/expression-extractor.d.ts.map +1 -0
- package/handlebars/helpers.d.ts +339 -0
- package/handlebars/helpers.d.ts.map +1 -0
- package/handlebars/index.d.ts +195 -0
- package/handlebars/index.d.ts.map +1 -0
- package/handlebars/index.js +666 -0
- package/index.d.ts +50 -0
- package/index.d.ts.map +1 -0
- package/index.js +12683 -0
- package/package.json +66 -0
- package/registry/index.d.ts +46 -0
- package/registry/index.d.ts.map +1 -0
- package/registry/index.js +6280 -0
- package/registry/render-template.d.ts +91 -0
- package/registry/render-template.d.ts.map +1 -0
- package/registry/tool-ui.registry.d.ts +294 -0
- package/registry/tool-ui.registry.d.ts.map +1 -0
- package/registry/uri-utils.d.ts +56 -0
- package/registry/uri-utils.d.ts.map +1 -0
- package/renderers/cache.d.ts +145 -0
- package/renderers/cache.d.ts.map +1 -0
- package/renderers/html.renderer.d.ts +123 -0
- package/renderers/html.renderer.d.ts.map +1 -0
- package/renderers/index.d.ts +36 -0
- package/renderers/index.d.ts.map +1 -0
- package/renderers/index.js +1706 -0
- package/renderers/mdx.renderer.d.ts +120 -0
- package/renderers/mdx.renderer.d.ts.map +1 -0
- package/renderers/registry.d.ts +133 -0
- package/renderers/registry.d.ts.map +1 -0
- package/renderers/types.d.ts +342 -0
- package/renderers/types.d.ts.map +1 -0
- package/renderers/utils/detect.d.ts +107 -0
- package/renderers/utils/detect.d.ts.map +1 -0
- package/renderers/utils/hash.d.ts +40 -0
- package/renderers/utils/hash.d.ts.map +1 -0
- package/renderers/utils/index.d.ts +9 -0
- package/renderers/utils/index.d.ts.map +1 -0
- package/renderers/utils/transpiler.d.ts +89 -0
- package/renderers/utils/transpiler.d.ts.map +1 -0
- package/runtime/adapters/html.adapter.d.ts +59 -0
- package/runtime/adapters/html.adapter.d.ts.map +1 -0
- package/runtime/adapters/index.d.ts +26 -0
- package/runtime/adapters/index.d.ts.map +1 -0
- package/runtime/adapters/mdx.adapter.d.ts +73 -0
- package/runtime/adapters/mdx.adapter.d.ts.map +1 -0
- package/runtime/adapters/types.d.ts +95 -0
- package/runtime/adapters/types.d.ts.map +1 -0
- package/runtime/csp.d.ts +48 -0
- package/runtime/csp.d.ts.map +1 -0
- package/runtime/index.d.ts +17 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +5052 -0
- package/runtime/mcp-bridge.d.ts +101 -0
- package/runtime/mcp-bridge.d.ts.map +1 -0
- package/runtime/renderer-runtime.d.ts +133 -0
- package/runtime/renderer-runtime.d.ts.map +1 -0
- package/runtime/sanitizer.d.ts +172 -0
- package/runtime/sanitizer.d.ts.map +1 -0
- package/runtime/types.d.ts +415 -0
- package/runtime/types.d.ts.map +1 -0
- package/runtime/wrapper.d.ts +421 -0
- package/runtime/wrapper.d.ts.map +1 -0
- package/styles/index.d.ts +8 -0
- package/styles/index.d.ts.map +1 -0
- package/styles/index.js +222 -0
- package/styles/variants.d.ts +51 -0
- package/styles/variants.d.ts.map +1 -0
- package/theme/cdn.d.ts +195 -0
- package/theme/cdn.d.ts.map +1 -0
- package/theme/index.d.ts +18 -0
- package/theme/index.d.ts.map +1 -0
- package/theme/index.js +757 -0
- package/theme/platforms.d.ts +107 -0
- package/theme/platforms.d.ts.map +1 -0
- package/theme/presets/github-openai.d.ts +50 -0
- package/theme/presets/github-openai.d.ts.map +1 -0
- package/theme/presets/index.d.ts +11 -0
- package/theme/presets/index.d.ts.map +1 -0
- package/theme/theme.d.ts +396 -0
- package/theme/theme.d.ts.map +1 -0
- package/tool-template/builder.d.ts +213 -0
- package/tool-template/builder.d.ts.map +1 -0
- package/tool-template/index.d.ts +16 -0
- package/tool-template/index.d.ts.map +1 -0
- package/tool-template/index.js +3562 -0
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -0
- package/types/index.js +108 -0
- package/types/ui-config.d.ts +641 -0
- package/types/ui-config.d.ts.map +1 -0
- package/types/ui-runtime.d.ts +1008 -0
- package/types/ui-runtime.d.ts.map +1 -0
- package/typings/cache/cache-adapter.d.ts +125 -0
- package/typings/cache/cache-adapter.d.ts.map +1 -0
- package/typings/cache/index.d.ts +10 -0
- package/typings/cache/index.d.ts.map +1 -0
- package/typings/cache/memory-cache.d.ts +92 -0
- package/typings/cache/memory-cache.d.ts.map +1 -0
- package/typings/dts-parser.d.ts +90 -0
- package/typings/dts-parser.d.ts.map +1 -0
- package/typings/index.d.ts +48 -0
- package/typings/index.d.ts.map +1 -0
- package/typings/index.js +868 -0
- package/typings/schemas.d.ts +232 -0
- package/typings/schemas.d.ts.map +1 -0
- package/typings/type-fetcher.d.ts +89 -0
- package/typings/type-fetcher.d.ts.map +1 -0
- package/typings/types.d.ts +320 -0
- package/typings/types.d.ts.map +1 -0
- package/utils/escape-html.d.ts +58 -0
- package/utils/escape-html.d.ts.map +1 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.d.ts.map +1 -0
- package/utils/index.js +70 -0
- package/utils/safe-stringify.d.ts +30 -0
- package/utils/safe-stringify.d.ts.map +1 -0
- package/validation/error-box.d.ts +56 -0
- package/validation/error-box.d.ts.map +1 -0
- package/validation/index.d.ts +13 -0
- package/validation/index.d.ts.map +1 -0
- package/validation/index.js +583 -0
- package/validation/schema-paths.d.ts +118 -0
- package/validation/schema-paths.d.ts.map +1 -0
- package/validation/template-validator.d.ts +143 -0
- package/validation/template-validator.d.ts.map +1 -0
- package/validation/wrapper.d.ts +97 -0
- package/validation/wrapper.d.ts.map +1 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget Manifest Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds static widget wrappers with embedded manifests for tool UIs.
|
|
5
|
+
* Produces complete HTML documents with FrontMCP Bridge runtime.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { UIType, ResourceMode, OutputMode, CSPDirectives, RendererAssets, WidgetConfig, BuildManifestResult, BuildManifestOptions, ToolResponseMeta } from '../types/ui-runtime';
|
|
10
|
+
import type { ThemeConfig } from '../theme';
|
|
11
|
+
import type { CDNPlatformType, ComponentBuildManifest } from '../dependency/types';
|
|
12
|
+
/**
|
|
13
|
+
* Check if a template is a file path.
|
|
14
|
+
*
|
|
15
|
+
* @param template - Widget template
|
|
16
|
+
* @returns true if the template is a file path
|
|
17
|
+
*/
|
|
18
|
+
export declare function isFilePathTemplate(template: unknown): template is string;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a template is a URL.
|
|
21
|
+
*
|
|
22
|
+
* @param template - Widget template
|
|
23
|
+
* @returns true if the template is a URL
|
|
24
|
+
*/
|
|
25
|
+
export declare function isUrlTemplate(template: unknown): template is string;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a template is file-based (either file path or URL).
|
|
28
|
+
*
|
|
29
|
+
* @param template - Widget template
|
|
30
|
+
* @returns true if the template is file-based
|
|
31
|
+
*/
|
|
32
|
+
export declare function isFileBasedTemplate(template: unknown): template is string;
|
|
33
|
+
/**
|
|
34
|
+
* Detect the UI type from a template.
|
|
35
|
+
*
|
|
36
|
+
* @param template - Widget template
|
|
37
|
+
* @returns Detected UI type
|
|
38
|
+
*/
|
|
39
|
+
export declare function detectUIType(template: WidgetConfig['template']): UIType;
|
|
40
|
+
/**
|
|
41
|
+
* Build CSP directives for a UI type.
|
|
42
|
+
*
|
|
43
|
+
* @param uiType - UI renderer type
|
|
44
|
+
* @param userCsp - User-provided CSP overrides
|
|
45
|
+
* @returns Complete CSP directives
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildCSPForType(uiType: UIType, userCsp?: Partial<CSPDirectives>): CSPDirectives;
|
|
48
|
+
/**
|
|
49
|
+
* Build CSP meta tag content.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildCSPMetaContent(csp: CSPDirectives): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get renderer assets for a UI type.
|
|
54
|
+
*
|
|
55
|
+
* @param uiType - UI renderer type
|
|
56
|
+
* @param resourceMode - Resource loading mode (cdn or inline)
|
|
57
|
+
* @returns Required renderer assets with CDN URLs or inline placeholders
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Get CDN-based assets for React
|
|
62
|
+
* const assets = getRendererAssets('react', 'cdn');
|
|
63
|
+
* console.log(assets.react?.url);
|
|
64
|
+
* // "https://unpkg.com/react@18/umd/react.production.min.js"
|
|
65
|
+
*
|
|
66
|
+
* // Get inline-mode assets
|
|
67
|
+
* const inlineAssets = getRendererAssets('react', 'inline');
|
|
68
|
+
* // inlineAssets.mode === 'inline'
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function getRendererAssets(uiType: UIType, resourceMode?: ResourceMode): RendererAssets;
|
|
72
|
+
/**
|
|
73
|
+
* Build a widget manifest for a tool.
|
|
74
|
+
*
|
|
75
|
+
* Creates a static widget wrapper with embedded manifest.
|
|
76
|
+
* The widget can be cached and reused across tool invocations.
|
|
77
|
+
*
|
|
78
|
+
* @param options - Build options
|
|
79
|
+
* @returns Build result with HTML, manifest, and metadata
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { buildToolWidgetManifest } from '@frontmcp/ui/build';
|
|
84
|
+
*
|
|
85
|
+
* const result = await buildToolWidgetManifest({
|
|
86
|
+
* toolName: 'weather.get',
|
|
87
|
+
* uiConfig: {
|
|
88
|
+
* template: WeatherWidget,
|
|
89
|
+
* uiType: 'react',
|
|
90
|
+
* displayMode: 'inline',
|
|
91
|
+
* widgetAccessible: true,
|
|
92
|
+
* },
|
|
93
|
+
* schema: { type: 'object', properties: { ... } },
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Cache the HTML
|
|
97
|
+
* cache.set(`ui://widget/${result.manifest.tool}.html`, result.html);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildToolWidgetManifest<Input = Record<string, unknown>, Output = unknown>(options: BuildManifestOptions<Input, Output>): Promise<BuildManifestResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Options for batch building multiple widgets.
|
|
103
|
+
*/
|
|
104
|
+
export interface BatchBuildOptions {
|
|
105
|
+
/**
|
|
106
|
+
* Array of tool configurations to build.
|
|
107
|
+
*/
|
|
108
|
+
tools: Array<{
|
|
109
|
+
toolName: string;
|
|
110
|
+
uiConfig: WidgetConfig;
|
|
111
|
+
schema?: object;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Theme configuration to apply to all widgets.
|
|
115
|
+
*/
|
|
116
|
+
theme?: ThemeConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Enable parallel building.
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
parallel?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Result of batch building.
|
|
125
|
+
*/
|
|
126
|
+
export interface BatchBuildResult {
|
|
127
|
+
/**
|
|
128
|
+
* Individual build results keyed by tool name.
|
|
129
|
+
*/
|
|
130
|
+
results: Map<string, BuildManifestResult>;
|
|
131
|
+
/**
|
|
132
|
+
* Total build time in ms.
|
|
133
|
+
*/
|
|
134
|
+
totalTime: number;
|
|
135
|
+
/**
|
|
136
|
+
* Number of successful builds.
|
|
137
|
+
*/
|
|
138
|
+
successCount: number;
|
|
139
|
+
/**
|
|
140
|
+
* Errors encountered (keyed by tool name).
|
|
141
|
+
*/
|
|
142
|
+
errors: Map<string, Error>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build multiple widget manifests in batch.
|
|
146
|
+
*
|
|
147
|
+
* @param options - Batch build options
|
|
148
|
+
* @returns Batch build results
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const { results, errors } = await batchBuildWidgets({
|
|
153
|
+
* tools: [
|
|
154
|
+
* { toolName: 'weather.get', uiConfig: weatherConfig },
|
|
155
|
+
* { toolName: 'stock.quote', uiConfig: stockConfig },
|
|
156
|
+
* ],
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* for (const [name, result] of results) {
|
|
160
|
+
* cache.set(result.manifest.uri, result.html);
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function batchBuildWidgets(options: BatchBuildOptions): Promise<BatchBuildResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Options for building tool response _meta fields.
|
|
167
|
+
*/
|
|
168
|
+
export interface BuildMetaOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Build result from buildToolWidgetManifest.
|
|
171
|
+
*/
|
|
172
|
+
buildResult: BuildManifestResult;
|
|
173
|
+
/**
|
|
174
|
+
* Output mode - determines which content to include.
|
|
175
|
+
* - 'code-only': Include ui/content (transpiled code only)
|
|
176
|
+
* - 'full-ssr': Include ui/html (complete HTML document)
|
|
177
|
+
*
|
|
178
|
+
* @default 'code-only'
|
|
179
|
+
*/
|
|
180
|
+
outputMode?: OutputMode;
|
|
181
|
+
/**
|
|
182
|
+
* Include OpenAI-specific meta fields.
|
|
183
|
+
* @default true
|
|
184
|
+
*/
|
|
185
|
+
includeOpenAI?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Build _meta fields for a tool response.
|
|
189
|
+
*
|
|
190
|
+
* This function generates the proper _meta structure for UI widgets.
|
|
191
|
+
* All UI-related data goes in _meta, NOT in the content array.
|
|
192
|
+
*
|
|
193
|
+
* @param options - Build options
|
|
194
|
+
* @returns _meta fields object to spread into tool response
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const buildResult = await buildToolWidgetManifest({...});
|
|
199
|
+
*
|
|
200
|
+
* // For OpenAI (code-only mode)
|
|
201
|
+
* const meta = buildToolResponseMeta({
|
|
202
|
+
* buildResult,
|
|
203
|
+
* outputMode: 'code-only',
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* return {
|
|
207
|
+
* content: [{ type: 'text', text: 'Weather retrieved' }],
|
|
208
|
+
* _meta: meta,
|
|
209
|
+
* };
|
|
210
|
+
*
|
|
211
|
+
* // For unknown clients (full-ssr mode)
|
|
212
|
+
* const meta = buildToolResponseMeta({
|
|
213
|
+
* buildResult,
|
|
214
|
+
* outputMode: 'full-ssr',
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function buildToolResponseMeta(options: BuildMetaOptions): ToolResponseMeta;
|
|
219
|
+
/**
|
|
220
|
+
* Determine the appropriate output mode based on client info.
|
|
221
|
+
*
|
|
222
|
+
* Platform capabilities:
|
|
223
|
+
* - OpenAI/ChatGPT/Cursor: Can load CDN scripts, use 'code-only' (smaller payload)
|
|
224
|
+
* - Claude: Sandboxed artifacts block ALL external requests, MUST use 'full-ssr' (embedded HTML)
|
|
225
|
+
* - Unknown: Default to 'full-ssr' for maximum compatibility
|
|
226
|
+
*
|
|
227
|
+
* @param clientInfo - MCP client information
|
|
228
|
+
* @returns Recommended output mode
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const outputMode = getOutputModeForClient(request.clientInfo);
|
|
233
|
+
* const meta = buildToolResponseMeta({ buildResult, outputMode });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export declare function getOutputModeForClient(clientInfo?: {
|
|
237
|
+
name?: string;
|
|
238
|
+
version?: string;
|
|
239
|
+
}): OutputMode;
|
|
240
|
+
/**
|
|
241
|
+
* Options for building a file-based UI component.
|
|
242
|
+
*/
|
|
243
|
+
export interface FileComponentBuildOptions {
|
|
244
|
+
/**
|
|
245
|
+
* File path to the component entry point.
|
|
246
|
+
* @example './widgets/chart.tsx'
|
|
247
|
+
*/
|
|
248
|
+
entryPath: string;
|
|
249
|
+
/**
|
|
250
|
+
* Tool name for this component.
|
|
251
|
+
*/
|
|
252
|
+
toolName: string;
|
|
253
|
+
/**
|
|
254
|
+
* Packages to load from CDN.
|
|
255
|
+
*/
|
|
256
|
+
externals?: string[];
|
|
257
|
+
/**
|
|
258
|
+
* Explicit CDN dependency overrides.
|
|
259
|
+
*/
|
|
260
|
+
dependencies?: Record<string, import('../dependency/types').CDNDependency>;
|
|
261
|
+
/**
|
|
262
|
+
* Bundle options.
|
|
263
|
+
*/
|
|
264
|
+
bundleOptions?: import('../dependency/types').FileBundleOptions;
|
|
265
|
+
/**
|
|
266
|
+
* Target platform for CDN selection.
|
|
267
|
+
* @default 'unknown'
|
|
268
|
+
*/
|
|
269
|
+
platform?: CDNPlatformType;
|
|
270
|
+
/**
|
|
271
|
+
* Whether to skip cache lookup.
|
|
272
|
+
* @default false
|
|
273
|
+
*/
|
|
274
|
+
skipCache?: boolean;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Result of a file-based component build.
|
|
278
|
+
*/
|
|
279
|
+
export interface FileComponentBuildResult {
|
|
280
|
+
/**
|
|
281
|
+
* The build manifest.
|
|
282
|
+
*/
|
|
283
|
+
manifest: ComponentBuildManifest;
|
|
284
|
+
/**
|
|
285
|
+
* Complete HTML with dependencies and component code.
|
|
286
|
+
*/
|
|
287
|
+
html: string;
|
|
288
|
+
/**
|
|
289
|
+
* Whether the result came from cache.
|
|
290
|
+
*/
|
|
291
|
+
cached: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Build time in milliseconds.
|
|
294
|
+
*/
|
|
295
|
+
buildTimeMs: number;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Build a file-based UI component.
|
|
299
|
+
*
|
|
300
|
+
* This function handles the complete build pipeline for file-based templates:
|
|
301
|
+
* 1. Check cache for existing build
|
|
302
|
+
* 2. Parse entry file for imports
|
|
303
|
+
* 3. Resolve external dependencies to CDN URLs
|
|
304
|
+
* 4. Bundle the component with esbuild
|
|
305
|
+
* 5. Generate import map for CDN dependencies
|
|
306
|
+
* 6. Store result in cache
|
|
307
|
+
*
|
|
308
|
+
* @param options - Build options
|
|
309
|
+
* @returns Build result with manifest and HTML
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* const result = await buildFileComponent({
|
|
314
|
+
* entryPath: './widgets/chart.tsx',
|
|
315
|
+
* toolName: 'chart_display',
|
|
316
|
+
* externals: ['chart.js', 'react-chartjs-2'],
|
|
317
|
+
* platform: 'claude',
|
|
318
|
+
* });
|
|
319
|
+
*
|
|
320
|
+
* // Use the HTML in tool response
|
|
321
|
+
* return {
|
|
322
|
+
* content: [{ type: 'text', text: 'Chart rendered' }],
|
|
323
|
+
* _meta: {
|
|
324
|
+
* 'ui/html': result.html,
|
|
325
|
+
* 'ui/hash': result.manifest.contentHash,
|
|
326
|
+
* },
|
|
327
|
+
* };
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
export declare function buildFileComponent(options: FileComponentBuildOptions): Promise<FileComponentBuildResult>;
|
|
331
|
+
/**
|
|
332
|
+
* Build multiple file-based components.
|
|
333
|
+
*
|
|
334
|
+
* @param options - Array of build options
|
|
335
|
+
* @returns Array of build results
|
|
336
|
+
*/
|
|
337
|
+
export declare function buildFileComponents(options: FileComponentBuildOptions[]): Promise<FileComponentBuildResult[]>;
|
|
338
|
+
/**
|
|
339
|
+
* Check if a file-based component needs rebuilding.
|
|
340
|
+
*
|
|
341
|
+
* @param options - Build options (without skipCache)
|
|
342
|
+
* @returns true if the component needs rebuilding
|
|
343
|
+
*/
|
|
344
|
+
export declare function needsFileComponentRebuild(options: Omit<FileComponentBuildOptions, 'skipCache'>): Promise<boolean>;
|
|
345
|
+
/**
|
|
346
|
+
* Get a cached file-based component build.
|
|
347
|
+
*
|
|
348
|
+
* @param options - Build options
|
|
349
|
+
* @returns Cached manifest or undefined
|
|
350
|
+
*/
|
|
351
|
+
export declare function getCachedFileComponent(options: Omit<FileComponentBuildOptions, 'skipCache' | 'toolName'>): Promise<ComponentBuildManifest | undefined>;
|
|
352
|
+
/**
|
|
353
|
+
* Map MCP client info to platform type.
|
|
354
|
+
*
|
|
355
|
+
* @param clientInfo - MCP client information
|
|
356
|
+
* @returns Platform type for CDN selection
|
|
357
|
+
*/
|
|
358
|
+
export declare function getPlatformFromClientInfo(clientInfo?: {
|
|
359
|
+
name?: string;
|
|
360
|
+
version?: string;
|
|
361
|
+
}): CDNPlatformType;
|
|
362
|
+
//# sourceMappingURL=widget-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-manifest.d.ts","sourceRoot":"","sources":["../../../src/build/widget-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,MAAM,EAGN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAU5C,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EAGvB,MAAM,qBAAqB,CAAC;AAS7B;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAGzE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,MAAM,CAuBvE;AA0BD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,aAAa,CAkBf;AAWD;;GAEG;AACH,wBAAgB,mBAAmB,CAA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AO,EAAE,yBAAyB,EAAE,GACnC,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAErC;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GACpD,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,GAAG,UAAU,CAAC,GACjE,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAQ7C;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,CAAC,EAAE;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,eAAe,CAelB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundler Cache
|
|
3
|
+
*
|
|
4
|
+
* LRU cache implementation for bundled results.
|
|
5
|
+
* Provides content-addressable caching with TTL expiration.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { BundleResult } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Cache configuration options.
|
|
12
|
+
*/
|
|
13
|
+
export interface CacheOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of entries in the cache.
|
|
16
|
+
* @default 100
|
|
17
|
+
*/
|
|
18
|
+
maxSize: number;
|
|
19
|
+
/**
|
|
20
|
+
* Time-to-live for cache entries in milliseconds.
|
|
21
|
+
* @default 300000 (5 minutes)
|
|
22
|
+
*/
|
|
23
|
+
ttl: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cache statistics.
|
|
27
|
+
*/
|
|
28
|
+
export interface CacheStats {
|
|
29
|
+
/**
|
|
30
|
+
* Number of entries in the cache.
|
|
31
|
+
*/
|
|
32
|
+
size: number;
|
|
33
|
+
/**
|
|
34
|
+
* Number of cache hits.
|
|
35
|
+
*/
|
|
36
|
+
hits: number;
|
|
37
|
+
/**
|
|
38
|
+
* Number of cache misses.
|
|
39
|
+
*/
|
|
40
|
+
misses: number;
|
|
41
|
+
/**
|
|
42
|
+
* Hit rate (0-1).
|
|
43
|
+
*/
|
|
44
|
+
hitRate: number;
|
|
45
|
+
/**
|
|
46
|
+
* Number of expired entries removed.
|
|
47
|
+
*/
|
|
48
|
+
evictions: number;
|
|
49
|
+
/**
|
|
50
|
+
* Total memory used by cache (approximate).
|
|
51
|
+
*/
|
|
52
|
+
memoryUsage: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* LRU cache for bundled results.
|
|
56
|
+
*
|
|
57
|
+
* Features:
|
|
58
|
+
* - Content-addressable by hash
|
|
59
|
+
* - TTL-based expiration
|
|
60
|
+
* - LRU eviction when at capacity
|
|
61
|
+
* - Statistics tracking
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const cache = new BundlerCache({ maxSize: 100, ttl: 300000 });
|
|
66
|
+
*
|
|
67
|
+
* // Store a result
|
|
68
|
+
* cache.set('abc123', bundleResult);
|
|
69
|
+
*
|
|
70
|
+
* // Retrieve a result
|
|
71
|
+
* const cached = cache.get('abc123');
|
|
72
|
+
* if (cached) {
|
|
73
|
+
* console.log('Cache hit!', cached);
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // Get statistics
|
|
77
|
+
* console.log(cache.getStats());
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare class BundlerCache {
|
|
81
|
+
private readonly cache;
|
|
82
|
+
private readonly options;
|
|
83
|
+
private stats;
|
|
84
|
+
constructor(options?: Partial<CacheOptions>);
|
|
85
|
+
/**
|
|
86
|
+
* Get a cached bundle result.
|
|
87
|
+
*
|
|
88
|
+
* @param key - Cache key (typically content hash)
|
|
89
|
+
* @returns Cached result or undefined if not found/expired
|
|
90
|
+
*/
|
|
91
|
+
get(key: string): BundleResult | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Store a bundle result in the cache.
|
|
94
|
+
*
|
|
95
|
+
* @param key - Cache key (typically content hash)
|
|
96
|
+
* @param result - Bundle result to cache
|
|
97
|
+
*/
|
|
98
|
+
set(key: string, result: BundleResult): void;
|
|
99
|
+
/**
|
|
100
|
+
* Check if a key exists in the cache (and is not expired).
|
|
101
|
+
*
|
|
102
|
+
* @param key - Cache key to check
|
|
103
|
+
* @returns true if key exists and is not expired
|
|
104
|
+
*/
|
|
105
|
+
has(key: string): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Delete a specific entry from the cache.
|
|
108
|
+
*
|
|
109
|
+
* @param key - Cache key to delete
|
|
110
|
+
* @returns true if the key was found and deleted
|
|
111
|
+
*/
|
|
112
|
+
delete(key: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Clear all entries from the cache.
|
|
115
|
+
*/
|
|
116
|
+
clear(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get cache statistics.
|
|
119
|
+
*
|
|
120
|
+
* @returns Current cache statistics
|
|
121
|
+
*/
|
|
122
|
+
getStats(): CacheStats;
|
|
123
|
+
/**
|
|
124
|
+
* Remove expired entries from the cache.
|
|
125
|
+
*
|
|
126
|
+
* @returns Number of entries removed
|
|
127
|
+
*/
|
|
128
|
+
cleanup(): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get all cache keys.
|
|
131
|
+
*
|
|
132
|
+
* @returns Array of cache keys
|
|
133
|
+
*/
|
|
134
|
+
keys(): string[];
|
|
135
|
+
/**
|
|
136
|
+
* Get the number of entries in the cache.
|
|
137
|
+
*/
|
|
138
|
+
get size(): number;
|
|
139
|
+
/**
|
|
140
|
+
* Check if an entry is expired.
|
|
141
|
+
*/
|
|
142
|
+
private isExpired;
|
|
143
|
+
/**
|
|
144
|
+
* Evict the oldest (least recently used) entry.
|
|
145
|
+
*/
|
|
146
|
+
private evictOldest;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a hash from source content.
|
|
150
|
+
*
|
|
151
|
+
* Uses a simple but fast hashing algorithm suitable for cache keys.
|
|
152
|
+
*
|
|
153
|
+
* @param content - Content to hash
|
|
154
|
+
* @returns Hash string
|
|
155
|
+
*/
|
|
156
|
+
export declare function hashContent(content: string): string;
|
|
157
|
+
/**
|
|
158
|
+
* Create a hash from bundle options.
|
|
159
|
+
*
|
|
160
|
+
* Used to differentiate bundles of the same source with different options.
|
|
161
|
+
*
|
|
162
|
+
* @param source - Source content
|
|
163
|
+
* @param options - Bundle options that affect output
|
|
164
|
+
* @returns Combined hash string
|
|
165
|
+
*/
|
|
166
|
+
export declare function createCacheKey(source: string, options: {
|
|
167
|
+
sourceType?: string;
|
|
168
|
+
format?: string;
|
|
169
|
+
minify?: boolean;
|
|
170
|
+
externals?: string[];
|
|
171
|
+
target?: string;
|
|
172
|
+
}): string;
|
|
173
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/bundler/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;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