@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
package/typings/index.js
ADDED
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// libs/uipack/src/typings/index.ts
|
|
21
|
+
var typings_exports = {};
|
|
22
|
+
__export(typings_exports, {
|
|
23
|
+
DEFAULT_CACHE_OPTIONS: () => DEFAULT_CACHE_OPTIONS,
|
|
24
|
+
DEFAULT_TYPE_CACHE_TTL: () => DEFAULT_TYPE_CACHE_TTL,
|
|
25
|
+
DEFAULT_TYPE_FETCHER_OPTIONS: () => DEFAULT_TYPE_FETCHER_OPTIONS,
|
|
26
|
+
MemoryTypeCache: () => MemoryTypeCache,
|
|
27
|
+
TYPE_CACHE_PREFIX: () => TYPE_CACHE_PREFIX,
|
|
28
|
+
TypeFetcher: () => TypeFetcher,
|
|
29
|
+
combineDtsContents: () => combineDtsContents,
|
|
30
|
+
createTypeFetcher: () => createTypeFetcher,
|
|
31
|
+
dtsImportSchema: () => dtsImportSchema,
|
|
32
|
+
dtsImportTypeSchema: () => dtsImportTypeSchema,
|
|
33
|
+
dtsParseResultSchema: () => dtsParseResultSchema,
|
|
34
|
+
getPackageFromSpecifier: () => getPackageFromSpecifier,
|
|
35
|
+
getSubpathFromSpecifier: () => getSubpathFromSpecifier,
|
|
36
|
+
globalTypeCache: () => globalTypeCache,
|
|
37
|
+
isRelativeImport: () => isRelativeImport,
|
|
38
|
+
packageResolutionSchema: () => packageResolutionSchema,
|
|
39
|
+
parseDtsImports: () => parseDtsImports,
|
|
40
|
+
parseImportStatement: () => parseImportStatement,
|
|
41
|
+
safeParseBatchRequest: () => safeParseBatchRequest,
|
|
42
|
+
safeParseTypeFetcherOptions: () => safeParseTypeFetcherOptions,
|
|
43
|
+
typeCacheEntrySchema: () => typeCacheEntrySchema,
|
|
44
|
+
typeCacheStatsSchema: () => typeCacheStatsSchema,
|
|
45
|
+
typeFetchBatchRequestSchema: () => typeFetchBatchRequestSchema,
|
|
46
|
+
typeFetchBatchResultSchema: () => typeFetchBatchResultSchema,
|
|
47
|
+
typeFetchErrorCodeSchema: () => typeFetchErrorCodeSchema,
|
|
48
|
+
typeFetchErrorSchema: () => typeFetchErrorSchema,
|
|
49
|
+
typeFetchResultSchema: () => typeFetchResultSchema,
|
|
50
|
+
typeFetcherOptionsSchema: () => typeFetcherOptionsSchema,
|
|
51
|
+
validateBatchRequest: () => validateBatchRequest,
|
|
52
|
+
validateTypeFetcherOptions: () => validateTypeFetcherOptions
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(typings_exports);
|
|
55
|
+
|
|
56
|
+
// libs/uipack/src/typings/types.ts
|
|
57
|
+
var DEFAULT_TYPE_FETCHER_OPTIONS = {
|
|
58
|
+
maxDepth: 2,
|
|
59
|
+
timeout: 1e4,
|
|
60
|
+
maxConcurrency: 5,
|
|
61
|
+
cdnBaseUrl: "https://esm.sh"
|
|
62
|
+
};
|
|
63
|
+
var TYPE_CACHE_PREFIX = "types:";
|
|
64
|
+
var DEFAULT_TYPE_CACHE_TTL = 60 * 60 * 1e3;
|
|
65
|
+
|
|
66
|
+
// libs/uipack/src/typings/schemas.ts
|
|
67
|
+
var import_zod = require("zod");
|
|
68
|
+
var typeFetchErrorCodeSchema = import_zod.z.enum([
|
|
69
|
+
"NETWORK_ERROR",
|
|
70
|
+
"TIMEOUT",
|
|
71
|
+
"NO_TYPES_HEADER",
|
|
72
|
+
"INVALID_SPECIFIER",
|
|
73
|
+
"PACKAGE_NOT_FOUND",
|
|
74
|
+
"PARSE_ERROR"
|
|
75
|
+
]);
|
|
76
|
+
var typeFetchResultSchema = import_zod.z.object({
|
|
77
|
+
specifier: import_zod.z.string().min(1),
|
|
78
|
+
resolvedPackage: import_zod.z.string().min(1),
|
|
79
|
+
version: import_zod.z.string().min(1),
|
|
80
|
+
content: import_zod.z.string(),
|
|
81
|
+
fetchedUrls: import_zod.z.array(import_zod.z.string().url()),
|
|
82
|
+
fetchedAt: import_zod.z.string().datetime()
|
|
83
|
+
}).strict();
|
|
84
|
+
var typeFetchErrorSchema = import_zod.z.object({
|
|
85
|
+
specifier: import_zod.z.string().min(1),
|
|
86
|
+
code: typeFetchErrorCodeSchema,
|
|
87
|
+
message: import_zod.z.string().min(1),
|
|
88
|
+
url: import_zod.z.string().url().optional()
|
|
89
|
+
}).strict();
|
|
90
|
+
var typeFetchBatchRequestSchema = import_zod.z.object({
|
|
91
|
+
imports: import_zod.z.array(import_zod.z.string().min(1)).min(1),
|
|
92
|
+
maxDepth: import_zod.z.number().int().min(0).max(10).optional(),
|
|
93
|
+
timeout: import_zod.z.number().int().min(1e3).max(6e4).optional(),
|
|
94
|
+
maxConcurrency: import_zod.z.number().int().min(1).max(20).optional(),
|
|
95
|
+
skipCache: import_zod.z.boolean().optional(),
|
|
96
|
+
versionOverrides: import_zod.z.record(import_zod.z.string().min(1), import_zod.z.string().min(1)).optional()
|
|
97
|
+
}).strict();
|
|
98
|
+
var typeFetchBatchResultSchema = import_zod.z.object({
|
|
99
|
+
results: import_zod.z.array(typeFetchResultSchema),
|
|
100
|
+
errors: import_zod.z.array(typeFetchErrorSchema),
|
|
101
|
+
totalTimeMs: import_zod.z.number().nonnegative(),
|
|
102
|
+
cacheHits: import_zod.z.number().int().nonnegative(),
|
|
103
|
+
networkRequests: import_zod.z.number().int().nonnegative()
|
|
104
|
+
}).strict();
|
|
105
|
+
var typeCacheEntrySchema = import_zod.z.object({
|
|
106
|
+
result: typeFetchResultSchema,
|
|
107
|
+
cachedAt: import_zod.z.number().int().positive(),
|
|
108
|
+
size: import_zod.z.number().int().nonnegative(),
|
|
109
|
+
accessCount: import_zod.z.number().int().nonnegative()
|
|
110
|
+
}).strict();
|
|
111
|
+
var typeCacheStatsSchema = import_zod.z.object({
|
|
112
|
+
entries: import_zod.z.number().int().nonnegative(),
|
|
113
|
+
totalSize: import_zod.z.number().nonnegative(),
|
|
114
|
+
hits: import_zod.z.number().int().nonnegative(),
|
|
115
|
+
misses: import_zod.z.number().int().nonnegative(),
|
|
116
|
+
hitRate: import_zod.z.number().min(0).max(1)
|
|
117
|
+
}).strict();
|
|
118
|
+
var dtsImportTypeSchema = import_zod.z.enum(["import", "export", "reference", "declare-module"]);
|
|
119
|
+
var dtsImportSchema = import_zod.z.object({
|
|
120
|
+
type: dtsImportTypeSchema,
|
|
121
|
+
specifier: import_zod.z.string().min(1),
|
|
122
|
+
statement: import_zod.z.string(),
|
|
123
|
+
line: import_zod.z.number().int().positive()
|
|
124
|
+
}).strict();
|
|
125
|
+
var dtsParseResultSchema = import_zod.z.object({
|
|
126
|
+
imports: import_zod.z.array(dtsImportSchema),
|
|
127
|
+
externalPackages: import_zod.z.array(import_zod.z.string().min(1)),
|
|
128
|
+
relativeImports: import_zod.z.array(import_zod.z.string())
|
|
129
|
+
}).strict();
|
|
130
|
+
var typeFetcherOptionsSchema = import_zod.z.object({
|
|
131
|
+
maxDepth: import_zod.z.number().int().min(0).max(10).optional(),
|
|
132
|
+
timeout: import_zod.z.number().int().min(1e3).max(6e4).optional(),
|
|
133
|
+
maxConcurrency: import_zod.z.number().int().min(1).max(20).optional(),
|
|
134
|
+
cdnBaseUrl: import_zod.z.string().url().optional()
|
|
135
|
+
}).strict();
|
|
136
|
+
var packageResolutionSchema = import_zod.z.object({
|
|
137
|
+
packageName: import_zod.z.string().min(1),
|
|
138
|
+
subpath: import_zod.z.string().optional(),
|
|
139
|
+
version: import_zod.z.string().min(1),
|
|
140
|
+
typesUrl: import_zod.z.string().url()
|
|
141
|
+
}).strict();
|
|
142
|
+
function validateBatchRequest(data) {
|
|
143
|
+
return typeFetchBatchRequestSchema.parse(data);
|
|
144
|
+
}
|
|
145
|
+
function safeParseBatchRequest(data) {
|
|
146
|
+
return typeFetchBatchRequestSchema.safeParse(data);
|
|
147
|
+
}
|
|
148
|
+
function validateTypeFetcherOptions(data) {
|
|
149
|
+
return typeFetcherOptionsSchema.parse(data);
|
|
150
|
+
}
|
|
151
|
+
function safeParseTypeFetcherOptions(data) {
|
|
152
|
+
return typeFetcherOptionsSchema.safeParse(data);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// libs/uipack/src/typings/cache/cache-adapter.ts
|
|
156
|
+
var DEFAULT_CACHE_OPTIONS = {
|
|
157
|
+
maxSize: 500,
|
|
158
|
+
defaultTtl: 60 * 60 * 1e3,
|
|
159
|
+
// 1 hour
|
|
160
|
+
trackStats: true
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// libs/uipack/src/typings/cache/memory-cache.ts
|
|
164
|
+
var MemoryTypeCache = class {
|
|
165
|
+
cache = /* @__PURE__ */ new Map();
|
|
166
|
+
maxSize;
|
|
167
|
+
defaultTtl;
|
|
168
|
+
trackStats;
|
|
169
|
+
/** Cache statistics */
|
|
170
|
+
stats = {
|
|
171
|
+
hits: 0,
|
|
172
|
+
misses: 0,
|
|
173
|
+
evictions: 0
|
|
174
|
+
};
|
|
175
|
+
constructor(options = {}) {
|
|
176
|
+
const opts = { ...DEFAULT_CACHE_OPTIONS, ...options };
|
|
177
|
+
this.maxSize = opts.maxSize;
|
|
178
|
+
this.defaultTtl = opts.defaultTtl;
|
|
179
|
+
this.trackStats = opts.trackStats;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get a cached entry by key.
|
|
183
|
+
*/
|
|
184
|
+
async get(key) {
|
|
185
|
+
const internal = this.cache.get(key);
|
|
186
|
+
if (!internal) {
|
|
187
|
+
if (this.trackStats) this.stats.misses++;
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
if (internal.expiresAt > 0 && Date.now() > internal.expiresAt) {
|
|
191
|
+
this.cache.delete(key);
|
|
192
|
+
if (this.trackStats) this.stats.misses++;
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
this.cache.delete(key);
|
|
196
|
+
internal.entry.accessCount++;
|
|
197
|
+
this.cache.set(key, internal);
|
|
198
|
+
if (this.trackStats) this.stats.hits++;
|
|
199
|
+
return internal.entry;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Store an entry in the cache.
|
|
203
|
+
*/
|
|
204
|
+
async set(key, entry, ttl) {
|
|
205
|
+
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
206
|
+
const oldestKey = this.cache.keys().next().value;
|
|
207
|
+
if (oldestKey) {
|
|
208
|
+
this.cache.delete(oldestKey);
|
|
209
|
+
if (this.trackStats) this.stats.evictions++;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const effectiveTtl = ttl ?? this.defaultTtl;
|
|
213
|
+
const expiresAt = effectiveTtl > 0 ? Date.now() + effectiveTtl : 0;
|
|
214
|
+
this.cache.set(key, { entry, expiresAt });
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Check if a key exists in the cache.
|
|
218
|
+
*/
|
|
219
|
+
async has(key) {
|
|
220
|
+
const internal = this.cache.get(key);
|
|
221
|
+
if (!internal) return false;
|
|
222
|
+
if (internal.expiresAt > 0 && Date.now() > internal.expiresAt) {
|
|
223
|
+
this.cache.delete(key);
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Delete a cached entry.
|
|
230
|
+
*/
|
|
231
|
+
async delete(key) {
|
|
232
|
+
return this.cache.delete(key);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Clear all cached entries.
|
|
236
|
+
*/
|
|
237
|
+
async clear() {
|
|
238
|
+
this.cache.clear();
|
|
239
|
+
this.stats = { hits: 0, misses: 0, evictions: 0 };
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get cache statistics.
|
|
243
|
+
*/
|
|
244
|
+
async getStats() {
|
|
245
|
+
let totalSize = 0;
|
|
246
|
+
for (const { entry } of this.cache.values()) {
|
|
247
|
+
totalSize += entry.size;
|
|
248
|
+
}
|
|
249
|
+
const total = this.stats.hits + this.stats.misses;
|
|
250
|
+
return {
|
|
251
|
+
entries: this.cache.size,
|
|
252
|
+
totalSize,
|
|
253
|
+
hits: this.stats.hits,
|
|
254
|
+
misses: this.stats.misses,
|
|
255
|
+
hitRate: total > 0 ? this.stats.hits / total : 0
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get current cache size.
|
|
260
|
+
*/
|
|
261
|
+
get size() {
|
|
262
|
+
return this.cache.size;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get number of evictions.
|
|
266
|
+
*/
|
|
267
|
+
get evictions() {
|
|
268
|
+
return this.stats.evictions;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Clean up expired entries.
|
|
272
|
+
* Call periodically to free memory from expired entries.
|
|
273
|
+
*
|
|
274
|
+
* @returns Number of entries cleaned up
|
|
275
|
+
*/
|
|
276
|
+
cleanup() {
|
|
277
|
+
const now = Date.now();
|
|
278
|
+
let cleaned = 0;
|
|
279
|
+
for (const [key, internal] of this.cache.entries()) {
|
|
280
|
+
if (internal.expiresAt > 0 && now > internal.expiresAt) {
|
|
281
|
+
this.cache.delete(key);
|
|
282
|
+
cleaned++;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return cleaned;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var globalTypeCache = new MemoryTypeCache({
|
|
289
|
+
maxSize: 500,
|
|
290
|
+
defaultTtl: 60 * 60 * 1e3
|
|
291
|
+
// 1 hour
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// libs/uipack/src/typings/dts-parser.ts
|
|
295
|
+
var IMPORT_PATTERN = /^import\s+(?:type\s+)?(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"]([^'"]+)['"]/gm;
|
|
296
|
+
var EXPORT_FROM_PATTERN = /^export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/gm;
|
|
297
|
+
var REFERENCE_TYPES_PATTERN = /^\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/gm;
|
|
298
|
+
var REFERENCE_PATH_PATTERN = /^\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/gm;
|
|
299
|
+
var DECLARE_MODULE_PATTERN = /^declare\s+module\s+['"]([^'"]+)['"]/gm;
|
|
300
|
+
function parseDtsImports(content) {
|
|
301
|
+
const imports = [];
|
|
302
|
+
const externalPackages = /* @__PURE__ */ new Set();
|
|
303
|
+
const relativeImports = /* @__PURE__ */ new Set();
|
|
304
|
+
const lines = content.split("\n");
|
|
305
|
+
for (let i = 0; i < lines.length; i++) {
|
|
306
|
+
const line = lines[i];
|
|
307
|
+
const lineNum = i + 1;
|
|
308
|
+
IMPORT_PATTERN.lastIndex = 0;
|
|
309
|
+
let match = IMPORT_PATTERN.exec(line);
|
|
310
|
+
if (match) {
|
|
311
|
+
const specifier = match[1];
|
|
312
|
+
imports.push({
|
|
313
|
+
type: "import",
|
|
314
|
+
specifier,
|
|
315
|
+
statement: line.trim(),
|
|
316
|
+
line: lineNum
|
|
317
|
+
});
|
|
318
|
+
categorizeSpecifier(specifier, externalPackages, relativeImports);
|
|
319
|
+
}
|
|
320
|
+
EXPORT_FROM_PATTERN.lastIndex = 0;
|
|
321
|
+
match = EXPORT_FROM_PATTERN.exec(line);
|
|
322
|
+
if (match) {
|
|
323
|
+
const specifier = match[1];
|
|
324
|
+
imports.push({
|
|
325
|
+
type: "export",
|
|
326
|
+
specifier,
|
|
327
|
+
statement: line.trim(),
|
|
328
|
+
line: lineNum
|
|
329
|
+
});
|
|
330
|
+
categorizeSpecifier(specifier, externalPackages, relativeImports);
|
|
331
|
+
}
|
|
332
|
+
REFERENCE_TYPES_PATTERN.lastIndex = 0;
|
|
333
|
+
match = REFERENCE_TYPES_PATTERN.exec(line);
|
|
334
|
+
if (match) {
|
|
335
|
+
const specifier = match[1];
|
|
336
|
+
imports.push({
|
|
337
|
+
type: "reference",
|
|
338
|
+
specifier,
|
|
339
|
+
statement: line.trim(),
|
|
340
|
+
line: lineNum
|
|
341
|
+
});
|
|
342
|
+
externalPackages.add(getPackageFromSpecifier(specifier));
|
|
343
|
+
}
|
|
344
|
+
REFERENCE_PATH_PATTERN.lastIndex = 0;
|
|
345
|
+
match = REFERENCE_PATH_PATTERN.exec(line);
|
|
346
|
+
if (match) {
|
|
347
|
+
const specifier = match[1];
|
|
348
|
+
imports.push({
|
|
349
|
+
type: "reference",
|
|
350
|
+
specifier,
|
|
351
|
+
statement: line.trim(),
|
|
352
|
+
line: lineNum
|
|
353
|
+
});
|
|
354
|
+
relativeImports.add(specifier);
|
|
355
|
+
}
|
|
356
|
+
DECLARE_MODULE_PATTERN.lastIndex = 0;
|
|
357
|
+
match = DECLARE_MODULE_PATTERN.exec(line);
|
|
358
|
+
if (match) {
|
|
359
|
+
const specifier = match[1];
|
|
360
|
+
imports.push({
|
|
361
|
+
type: "declare-module",
|
|
362
|
+
specifier,
|
|
363
|
+
statement: line.trim(),
|
|
364
|
+
line: lineNum
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
imports,
|
|
370
|
+
externalPackages: Array.from(externalPackages),
|
|
371
|
+
relativeImports: Array.from(relativeImports)
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function categorizeSpecifier(specifier, externalPackages, relativeImports) {
|
|
375
|
+
if (isRelativeImport(specifier)) {
|
|
376
|
+
relativeImports.add(specifier);
|
|
377
|
+
} else {
|
|
378
|
+
externalPackages.add(getPackageFromSpecifier(specifier));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function isRelativeImport(specifier) {
|
|
382
|
+
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || // Check for Windows-style paths
|
|
383
|
+
/^[A-Za-z]:/.test(specifier);
|
|
384
|
+
}
|
|
385
|
+
function getPackageFromSpecifier(specifier) {
|
|
386
|
+
if (specifier.startsWith("@")) {
|
|
387
|
+
const parts = specifier.split("/");
|
|
388
|
+
if (parts.length >= 2) {
|
|
389
|
+
return `${parts[0]}/${parts[1]}`;
|
|
390
|
+
}
|
|
391
|
+
return specifier;
|
|
392
|
+
}
|
|
393
|
+
const slashIndex = specifier.indexOf("/");
|
|
394
|
+
if (slashIndex > 0) {
|
|
395
|
+
return specifier.substring(0, slashIndex);
|
|
396
|
+
}
|
|
397
|
+
return specifier;
|
|
398
|
+
}
|
|
399
|
+
function getSubpathFromSpecifier(specifier) {
|
|
400
|
+
const packageName = getPackageFromSpecifier(specifier);
|
|
401
|
+
if (specifier.length > packageName.length + 1) {
|
|
402
|
+
return specifier.substring(packageName.length + 1);
|
|
403
|
+
}
|
|
404
|
+
return void 0;
|
|
405
|
+
}
|
|
406
|
+
function parseImportStatement(statement) {
|
|
407
|
+
const namedMatch = /import\s+(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+['"]([^'"]+)['"]/.exec(statement);
|
|
408
|
+
if (namedMatch) {
|
|
409
|
+
return namedMatch[1];
|
|
410
|
+
}
|
|
411
|
+
const sideEffectMatch = /import\s+['"]([^'"]+)['"]/.exec(statement);
|
|
412
|
+
if (sideEffectMatch) {
|
|
413
|
+
return sideEffectMatch[1];
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
function combineDtsContents(contents) {
|
|
418
|
+
const seenReferences = /* @__PURE__ */ new Set();
|
|
419
|
+
const references = [];
|
|
420
|
+
const declarations = [];
|
|
421
|
+
for (const [url, content] of contents.entries()) {
|
|
422
|
+
const lines = content.split("\n");
|
|
423
|
+
let inReferences = true;
|
|
424
|
+
for (const line of lines) {
|
|
425
|
+
const trimmed = line.trim();
|
|
426
|
+
if (trimmed.startsWith("///")) {
|
|
427
|
+
if (!seenReferences.has(trimmed)) {
|
|
428
|
+
seenReferences.add(trimmed);
|
|
429
|
+
references.push(trimmed);
|
|
430
|
+
}
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (inReferences && trimmed === "") {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
inReferences = false;
|
|
437
|
+
if (declarations.length === 0 || declarations[declarations.length - 1] !== "") {
|
|
438
|
+
if (trimmed !== "") {
|
|
439
|
+
if (!declarations.some((d) => d.includes(`// Source: ${url}`))) {
|
|
440
|
+
declarations.push(`
|
|
441
|
+
// Source: ${url}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
declarations.push(line);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const parts = [];
|
|
449
|
+
if (references.length > 0) {
|
|
450
|
+
parts.push(references.join("\n"));
|
|
451
|
+
parts.push("");
|
|
452
|
+
}
|
|
453
|
+
parts.push(declarations.join("\n").trim());
|
|
454
|
+
return parts.join("\n");
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// libs/uipack/src/typings/type-fetcher.ts
|
|
458
|
+
var Semaphore = class {
|
|
459
|
+
permits;
|
|
460
|
+
waiting = [];
|
|
461
|
+
constructor(permits) {
|
|
462
|
+
this.permits = permits;
|
|
463
|
+
}
|
|
464
|
+
async acquire() {
|
|
465
|
+
if (this.permits > 0) {
|
|
466
|
+
this.permits--;
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
return new Promise((resolve) => {
|
|
470
|
+
this.waiting.push(resolve);
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
release() {
|
|
474
|
+
if (this.waiting.length > 0) {
|
|
475
|
+
const next = this.waiting.shift();
|
|
476
|
+
next?.();
|
|
477
|
+
} else {
|
|
478
|
+
this.permits++;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
var TypeFetcher = class {
|
|
483
|
+
maxDepth;
|
|
484
|
+
timeout;
|
|
485
|
+
maxConcurrency;
|
|
486
|
+
cdnBaseUrl;
|
|
487
|
+
fetchFn;
|
|
488
|
+
cache;
|
|
489
|
+
constructor(options = {}, cache) {
|
|
490
|
+
this.maxDepth = options.maxDepth ?? 2;
|
|
491
|
+
this.timeout = options.timeout ?? 1e4;
|
|
492
|
+
this.maxConcurrency = options.maxConcurrency ?? 5;
|
|
493
|
+
this.cdnBaseUrl = options.cdnBaseUrl ?? "https://esm.sh";
|
|
494
|
+
this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
495
|
+
this.cache = cache ?? globalTypeCache;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Fetch types for a batch of import statements.
|
|
499
|
+
*
|
|
500
|
+
* @param request - Batch request configuration
|
|
501
|
+
* @returns Batch result with results and errors
|
|
502
|
+
*/
|
|
503
|
+
async fetchBatch(request) {
|
|
504
|
+
const startTime = Date.now();
|
|
505
|
+
const results = [];
|
|
506
|
+
const errors = [];
|
|
507
|
+
let cacheHits = 0;
|
|
508
|
+
let networkRequests = 0;
|
|
509
|
+
const maxDepth = request.maxDepth ?? this.maxDepth;
|
|
510
|
+
const timeout = request.timeout ?? this.timeout;
|
|
511
|
+
const maxConcurrency = request.maxConcurrency ?? this.maxConcurrency;
|
|
512
|
+
const skipCache = request.skipCache ?? false;
|
|
513
|
+
const versionOverrides = request.versionOverrides ?? {};
|
|
514
|
+
const semaphore = new Semaphore(maxConcurrency);
|
|
515
|
+
const promises = request.imports.map(async (importStatement) => {
|
|
516
|
+
await semaphore.acquire();
|
|
517
|
+
try {
|
|
518
|
+
const specifier = parseImportStatement(importStatement);
|
|
519
|
+
if (!specifier) {
|
|
520
|
+
errors.push({
|
|
521
|
+
specifier: importStatement,
|
|
522
|
+
code: "INVALID_SPECIFIER",
|
|
523
|
+
message: `Could not parse import statement: ${importStatement}`
|
|
524
|
+
});
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const packageName = getPackageFromSpecifier(specifier);
|
|
528
|
+
const version = versionOverrides[packageName] ?? "latest";
|
|
529
|
+
const cacheKey = `${TYPE_CACHE_PREFIX}${packageName}@${version}`;
|
|
530
|
+
if (!skipCache) {
|
|
531
|
+
const cached = await this.cache.get(cacheKey);
|
|
532
|
+
if (cached) {
|
|
533
|
+
cacheHits++;
|
|
534
|
+
results.push(cached.result);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const result = await this.fetchTypesForSpecifier(specifier, {
|
|
539
|
+
maxDepth,
|
|
540
|
+
timeout,
|
|
541
|
+
version
|
|
542
|
+
});
|
|
543
|
+
if (result.success) {
|
|
544
|
+
results.push(result.data);
|
|
545
|
+
networkRequests += result.fetchCount;
|
|
546
|
+
const entry = {
|
|
547
|
+
result: result.data,
|
|
548
|
+
cachedAt: Date.now(),
|
|
549
|
+
size: result.data.content.length,
|
|
550
|
+
accessCount: 1
|
|
551
|
+
};
|
|
552
|
+
await this.cache.set(cacheKey, entry);
|
|
553
|
+
} else {
|
|
554
|
+
errors.push(result.error);
|
|
555
|
+
networkRequests += result.fetchCount;
|
|
556
|
+
}
|
|
557
|
+
} finally {
|
|
558
|
+
semaphore.release();
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
await Promise.all(promises);
|
|
562
|
+
return {
|
|
563
|
+
results,
|
|
564
|
+
errors,
|
|
565
|
+
totalTimeMs: Date.now() - startTime,
|
|
566
|
+
cacheHits,
|
|
567
|
+
networkRequests
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Fetch types for a single import specifier.
|
|
572
|
+
*/
|
|
573
|
+
async fetchTypesForSpecifier(specifier, options) {
|
|
574
|
+
let fetchCount = 0;
|
|
575
|
+
const fetchedUrls = [];
|
|
576
|
+
const visitedUrls = /* @__PURE__ */ new Set();
|
|
577
|
+
const contents = /* @__PURE__ */ new Map();
|
|
578
|
+
try {
|
|
579
|
+
const resolution = await this.resolvePackage(specifier, options.version, options.timeout);
|
|
580
|
+
if (!resolution) {
|
|
581
|
+
return {
|
|
582
|
+
success: false,
|
|
583
|
+
error: {
|
|
584
|
+
specifier,
|
|
585
|
+
code: "PACKAGE_NOT_FOUND",
|
|
586
|
+
message: `Could not resolve package: ${specifier}`
|
|
587
|
+
},
|
|
588
|
+
fetchCount
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
fetchCount++;
|
|
592
|
+
const fetchResult = await this.fetchRecursive(
|
|
593
|
+
resolution.typesUrl,
|
|
594
|
+
options.maxDepth,
|
|
595
|
+
options.timeout,
|
|
596
|
+
visitedUrls,
|
|
597
|
+
contents
|
|
598
|
+
);
|
|
599
|
+
fetchCount += fetchResult.fetchCount;
|
|
600
|
+
fetchedUrls.push(...fetchResult.fetchedUrls);
|
|
601
|
+
if (!fetchResult.success) {
|
|
602
|
+
return {
|
|
603
|
+
success: false,
|
|
604
|
+
error: {
|
|
605
|
+
specifier,
|
|
606
|
+
code: fetchResult.errorCode,
|
|
607
|
+
message: fetchResult.errorMessage ?? "Unknown error",
|
|
608
|
+
url: fetchResult.errorUrl
|
|
609
|
+
},
|
|
610
|
+
fetchCount
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
const combinedContent = combineDtsContents(contents);
|
|
614
|
+
const result = {
|
|
615
|
+
specifier,
|
|
616
|
+
resolvedPackage: resolution.packageName,
|
|
617
|
+
version: resolution.version,
|
|
618
|
+
content: combinedContent,
|
|
619
|
+
fetchedUrls,
|
|
620
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
621
|
+
};
|
|
622
|
+
return { success: true, data: result, fetchCount };
|
|
623
|
+
} catch (error) {
|
|
624
|
+
return {
|
|
625
|
+
success: false,
|
|
626
|
+
error: {
|
|
627
|
+
specifier,
|
|
628
|
+
code: "NETWORK_ERROR",
|
|
629
|
+
message: error instanceof Error ? error.message : String(error)
|
|
630
|
+
},
|
|
631
|
+
fetchCount
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Resolve a package specifier to a types URL.
|
|
637
|
+
* Uses path fallback: try full path, then remove last segment until found.
|
|
638
|
+
*/
|
|
639
|
+
async resolvePackage(specifier, version, timeout) {
|
|
640
|
+
const packageName = getPackageFromSpecifier(specifier);
|
|
641
|
+
const subpath = getSubpathFromSpecifier(specifier);
|
|
642
|
+
const versionSuffix = version === "latest" ? "" : `@${version}`;
|
|
643
|
+
const baseUrl = `${this.cdnBaseUrl}/${packageName}${versionSuffix}`;
|
|
644
|
+
const urlsToTry = subpath ? [`${baseUrl}/${subpath}`, baseUrl] : [baseUrl];
|
|
645
|
+
for (const url of urlsToTry) {
|
|
646
|
+
try {
|
|
647
|
+
const response = await this.fetchWithTimeout(url, timeout, "HEAD");
|
|
648
|
+
if (response.ok) {
|
|
649
|
+
const typesHeader = response.headers.get("X-TypeScript-Types");
|
|
650
|
+
if (typesHeader) {
|
|
651
|
+
const typesUrl = typesHeader.startsWith("/") ? `${this.cdnBaseUrl}${typesHeader}` : typesHeader;
|
|
652
|
+
const versionMatch = /@(\d+\.\d+\.\d+[^/]*)/.exec(typesUrl);
|
|
653
|
+
const resolvedVersion = versionMatch ? versionMatch[1] : version;
|
|
654
|
+
return {
|
|
655
|
+
packageName,
|
|
656
|
+
subpath,
|
|
657
|
+
version: resolvedVersion,
|
|
658
|
+
typesUrl
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
} catch {
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Recursively fetch .d.ts files.
|
|
670
|
+
*/
|
|
671
|
+
async fetchRecursive(url, depth, timeout, visited, contents) {
|
|
672
|
+
if (visited.has(url)) {
|
|
673
|
+
return { success: true, fetchCount: 0, fetchedUrls: [] };
|
|
674
|
+
}
|
|
675
|
+
visited.add(url);
|
|
676
|
+
let fetchCount = 1;
|
|
677
|
+
const fetchedUrls = [url];
|
|
678
|
+
try {
|
|
679
|
+
const response = await this.fetchWithTimeout(url, timeout, "GET");
|
|
680
|
+
if (!response.ok) {
|
|
681
|
+
return {
|
|
682
|
+
success: false,
|
|
683
|
+
fetchCount,
|
|
684
|
+
fetchedUrls,
|
|
685
|
+
errorCode: "NETWORK_ERROR",
|
|
686
|
+
errorMessage: `HTTP ${response.status}: ${response.statusText}`,
|
|
687
|
+
errorUrl: url
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
const content = await response.text();
|
|
691
|
+
contents.set(url, content);
|
|
692
|
+
if (depth <= 0) {
|
|
693
|
+
return { success: true, fetchCount, fetchedUrls };
|
|
694
|
+
}
|
|
695
|
+
const parsed = parseDtsImports(content);
|
|
696
|
+
for (const pkg of parsed.externalPackages) {
|
|
697
|
+
if (pkg.startsWith("@types/") || isBuiltinModule(pkg)) {
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const resolution = await this.resolvePackage(pkg, "latest", timeout);
|
|
701
|
+
fetchCount++;
|
|
702
|
+
if (resolution && !visited.has(resolution.typesUrl)) {
|
|
703
|
+
const result = await this.fetchRecursive(resolution.typesUrl, depth - 1, timeout, visited, contents);
|
|
704
|
+
fetchCount += result.fetchCount;
|
|
705
|
+
fetchedUrls.push(...result.fetchedUrls);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
for (const relativePath of parsed.relativeImports) {
|
|
709
|
+
const resolvedUrl = resolveRelativeUrl(url, relativePath);
|
|
710
|
+
if (resolvedUrl && !visited.has(resolvedUrl)) {
|
|
711
|
+
const result = await this.fetchRecursive(resolvedUrl, depth - 1, timeout, visited, contents);
|
|
712
|
+
fetchCount += result.fetchCount;
|
|
713
|
+
fetchedUrls.push(...result.fetchedUrls);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return { success: true, fetchCount, fetchedUrls };
|
|
717
|
+
} catch (error) {
|
|
718
|
+
const isTimeout = error instanceof Error && error.message.includes("timeout");
|
|
719
|
+
return {
|
|
720
|
+
success: false,
|
|
721
|
+
fetchCount,
|
|
722
|
+
fetchedUrls,
|
|
723
|
+
errorCode: isTimeout ? "TIMEOUT" : "NETWORK_ERROR",
|
|
724
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
725
|
+
errorUrl: url
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Fetch with timeout support.
|
|
731
|
+
*/
|
|
732
|
+
async fetchWithTimeout(url, timeout, method) {
|
|
733
|
+
const controller = new AbortController();
|
|
734
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
735
|
+
try {
|
|
736
|
+
const response = await this.fetchFn(url, {
|
|
737
|
+
method,
|
|
738
|
+
signal: controller.signal,
|
|
739
|
+
headers: {
|
|
740
|
+
Accept: "application/typescript, text/plain, */*"
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
return response;
|
|
744
|
+
} finally {
|
|
745
|
+
clearTimeout(timeoutId);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
function isBuiltinModule(name) {
|
|
750
|
+
const builtins = /* @__PURE__ */ new Set([
|
|
751
|
+
"assert",
|
|
752
|
+
"buffer",
|
|
753
|
+
"child_process",
|
|
754
|
+
"cluster",
|
|
755
|
+
"console",
|
|
756
|
+
"constants",
|
|
757
|
+
"crypto",
|
|
758
|
+
"dgram",
|
|
759
|
+
"dns",
|
|
760
|
+
"domain",
|
|
761
|
+
"events",
|
|
762
|
+
"fs",
|
|
763
|
+
"http",
|
|
764
|
+
"https",
|
|
765
|
+
"module",
|
|
766
|
+
"net",
|
|
767
|
+
"os",
|
|
768
|
+
"path",
|
|
769
|
+
"punycode",
|
|
770
|
+
"querystring",
|
|
771
|
+
"readline",
|
|
772
|
+
"repl",
|
|
773
|
+
"stream",
|
|
774
|
+
"string_decoder",
|
|
775
|
+
"sys",
|
|
776
|
+
"timers",
|
|
777
|
+
"tls",
|
|
778
|
+
"tty",
|
|
779
|
+
"url",
|
|
780
|
+
"util",
|
|
781
|
+
"v8",
|
|
782
|
+
"vm",
|
|
783
|
+
"zlib",
|
|
784
|
+
// Node.js prefixed modules
|
|
785
|
+
"node:assert",
|
|
786
|
+
"node:buffer",
|
|
787
|
+
"node:child_process",
|
|
788
|
+
"node:cluster",
|
|
789
|
+
"node:console",
|
|
790
|
+
"node:constants",
|
|
791
|
+
"node:crypto",
|
|
792
|
+
"node:dgram",
|
|
793
|
+
"node:dns",
|
|
794
|
+
"node:domain",
|
|
795
|
+
"node:events",
|
|
796
|
+
"node:fs",
|
|
797
|
+
"node:http",
|
|
798
|
+
"node:https",
|
|
799
|
+
"node:module",
|
|
800
|
+
"node:net",
|
|
801
|
+
"node:os",
|
|
802
|
+
"node:path",
|
|
803
|
+
"node:punycode",
|
|
804
|
+
"node:querystring",
|
|
805
|
+
"node:readline",
|
|
806
|
+
"node:repl",
|
|
807
|
+
"node:stream",
|
|
808
|
+
"node:string_decoder",
|
|
809
|
+
"node:sys",
|
|
810
|
+
"node:timers",
|
|
811
|
+
"node:tls",
|
|
812
|
+
"node:tty",
|
|
813
|
+
"node:url",
|
|
814
|
+
"node:util",
|
|
815
|
+
"node:v8",
|
|
816
|
+
"node:vm",
|
|
817
|
+
"node:zlib"
|
|
818
|
+
]);
|
|
819
|
+
return builtins.has(name);
|
|
820
|
+
}
|
|
821
|
+
function resolveRelativeUrl(base, relative) {
|
|
822
|
+
try {
|
|
823
|
+
let path = relative;
|
|
824
|
+
if (!path.endsWith(".d.ts") && !path.endsWith(".ts")) {
|
|
825
|
+
path = `${path}.d.ts`;
|
|
826
|
+
}
|
|
827
|
+
const resolved = new URL(path, base);
|
|
828
|
+
return resolved.toString();
|
|
829
|
+
} catch {
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function createTypeFetcher(options, cache) {
|
|
834
|
+
return new TypeFetcher(options, cache);
|
|
835
|
+
}
|
|
836
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
837
|
+
0 && (module.exports = {
|
|
838
|
+
DEFAULT_CACHE_OPTIONS,
|
|
839
|
+
DEFAULT_TYPE_CACHE_TTL,
|
|
840
|
+
DEFAULT_TYPE_FETCHER_OPTIONS,
|
|
841
|
+
MemoryTypeCache,
|
|
842
|
+
TYPE_CACHE_PREFIX,
|
|
843
|
+
TypeFetcher,
|
|
844
|
+
combineDtsContents,
|
|
845
|
+
createTypeFetcher,
|
|
846
|
+
dtsImportSchema,
|
|
847
|
+
dtsImportTypeSchema,
|
|
848
|
+
dtsParseResultSchema,
|
|
849
|
+
getPackageFromSpecifier,
|
|
850
|
+
getSubpathFromSpecifier,
|
|
851
|
+
globalTypeCache,
|
|
852
|
+
isRelativeImport,
|
|
853
|
+
packageResolutionSchema,
|
|
854
|
+
parseDtsImports,
|
|
855
|
+
parseImportStatement,
|
|
856
|
+
safeParseBatchRequest,
|
|
857
|
+
safeParseTypeFetcherOptions,
|
|
858
|
+
typeCacheEntrySchema,
|
|
859
|
+
typeCacheStatsSchema,
|
|
860
|
+
typeFetchBatchRequestSchema,
|
|
861
|
+
typeFetchBatchResultSchema,
|
|
862
|
+
typeFetchErrorCodeSchema,
|
|
863
|
+
typeFetchErrorSchema,
|
|
864
|
+
typeFetchResultSchema,
|
|
865
|
+
typeFetcherOptionsSchema,
|
|
866
|
+
validateBatchRequest,
|
|
867
|
+
validateTypeFetcherOptions
|
|
868
|
+
});
|