@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,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handlebars Built-in Helpers
|
|
3
|
+
*
|
|
4
|
+
* Provides a collection of helper functions for Handlebars templates.
|
|
5
|
+
* Includes formatting, escaping, conditionals, and iteration helpers.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { escapeHtml } from '../utils';
|
|
10
|
+
/**
|
|
11
|
+
* Helper function type for Handlebars.
|
|
12
|
+
* Allows any function signature since Handlebars helpers vary widely.
|
|
13
|
+
*/
|
|
14
|
+
export type HelperFunction = (...args: any[]) => string | boolean | unknown;
|
|
15
|
+
export { escapeHtml };
|
|
16
|
+
/**
|
|
17
|
+
* Format a date for display.
|
|
18
|
+
*
|
|
19
|
+
* @param date - Date object, ISO string, or timestamp
|
|
20
|
+
* @param format - Optional format string (default: localized date)
|
|
21
|
+
* @returns Formatted date string
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```handlebars
|
|
25
|
+
* {{formatDate output.createdAt}}
|
|
26
|
+
* {{formatDate output.createdAt "short"}}
|
|
27
|
+
* {{formatDate output.createdAt "long"}}
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatDate(date: unknown, format?: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format a number as currency.
|
|
33
|
+
*
|
|
34
|
+
* @param amount - Numeric amount
|
|
35
|
+
* @param currency - ISO 4217 currency code (default: 'USD')
|
|
36
|
+
* @returns Formatted currency string
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```handlebars
|
|
40
|
+
* {{formatCurrency output.price}}
|
|
41
|
+
* {{formatCurrency output.price "EUR"}}
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatCurrency(amount: unknown, currency?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Format a number with locale-aware separators.
|
|
47
|
+
*
|
|
48
|
+
* @param value - Number to format
|
|
49
|
+
* @param decimals - Number of decimal places (optional)
|
|
50
|
+
* @returns Formatted number string
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```handlebars
|
|
54
|
+
* {{formatNumber output.count}}
|
|
55
|
+
* {{formatNumber output.percentage 2}}
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatNumber(value: unknown, decimals?: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Safely embed JSON data in HTML.
|
|
61
|
+
* Escapes script-breaking characters.
|
|
62
|
+
*
|
|
63
|
+
* @param data - Data to serialize
|
|
64
|
+
* @returns JSON string safe for embedding
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```handlebars
|
|
68
|
+
* <script type="application/json" id="data">
|
|
69
|
+
* {{{jsonEmbed output}}}
|
|
70
|
+
* </script>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function jsonEmbed(data: unknown): string;
|
|
74
|
+
/**
|
|
75
|
+
* Convert data to JSON string.
|
|
76
|
+
*
|
|
77
|
+
* @param data - Data to serialize
|
|
78
|
+
* @param pretty - Whether to pretty-print (optional)
|
|
79
|
+
* @returns JSON string
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```handlebars
|
|
83
|
+
* <pre>{{json output true}}</pre>
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function json(data: unknown, pretty?: boolean): string;
|
|
87
|
+
/**
|
|
88
|
+
* Equality comparison.
|
|
89
|
+
*
|
|
90
|
+
* @param a - First value
|
|
91
|
+
* @param b - Second value
|
|
92
|
+
* @returns true if values are equal
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```handlebars
|
|
96
|
+
* {{#if (eq output.status "active")}}Active{{/if}}
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function eq(a: unknown, b: unknown): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Inequality comparison.
|
|
102
|
+
*
|
|
103
|
+
* @param a - First value
|
|
104
|
+
* @param b - Second value
|
|
105
|
+
* @returns true if values are not equal
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```handlebars
|
|
109
|
+
* {{#if (ne output.status "deleted")}}Visible{{/if}}
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function ne(a: unknown, b: unknown): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Greater than comparison.
|
|
115
|
+
*
|
|
116
|
+
* @param a - First value
|
|
117
|
+
* @param b - Second value
|
|
118
|
+
* @returns true if a > b
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```handlebars
|
|
122
|
+
* {{#if (gt output.count 10)}}Many items{{/if}}
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function gt(a: unknown, b: unknown): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Greater than or equal comparison.
|
|
128
|
+
*
|
|
129
|
+
* @param a - First value
|
|
130
|
+
* @param b - Second value
|
|
131
|
+
* @returns true if a >= b
|
|
132
|
+
*/
|
|
133
|
+
export declare function gte(a: unknown, b: unknown): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Less than comparison.
|
|
136
|
+
*
|
|
137
|
+
* @param a - First value
|
|
138
|
+
* @param b - Second value
|
|
139
|
+
* @returns true if a < b
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```handlebars
|
|
143
|
+
* {{#if (lt output.remaining 5)}}Running low{{/if}}
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function lt(a: unknown, b: unknown): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Less than or equal comparison.
|
|
149
|
+
*
|
|
150
|
+
* @param a - First value
|
|
151
|
+
* @param b - Second value
|
|
152
|
+
* @returns true if a <= b
|
|
153
|
+
*/
|
|
154
|
+
export declare function lte(a: unknown, b: unknown): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Logical AND.
|
|
157
|
+
*
|
|
158
|
+
* @param a - First value
|
|
159
|
+
* @param b - Second value
|
|
160
|
+
* @returns true if both values are truthy
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```handlebars
|
|
164
|
+
* {{#if (and output.enabled output.visible)}}Show content{{/if}}
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare function and(a: unknown, b: unknown): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Logical OR.
|
|
170
|
+
*
|
|
171
|
+
* @param a - First value
|
|
172
|
+
* @param b - Second value
|
|
173
|
+
* @returns true if either value is truthy
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```handlebars
|
|
177
|
+
* {{#if (or output.featured output.promoted)}}Highlight{{/if}}
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare function or(a: unknown, b: unknown): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Logical NOT.
|
|
183
|
+
*
|
|
184
|
+
* @param value - Value to negate
|
|
185
|
+
* @returns Negated boolean
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```handlebars
|
|
189
|
+
* {{#if (not output.hidden)}}Visible{{/if}}
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export declare function not(value: unknown): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Get the first element of an array.
|
|
195
|
+
*
|
|
196
|
+
* @param arr - Array
|
|
197
|
+
* @returns First element
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```handlebars
|
|
201
|
+
* {{first output.items}}
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function first<T>(arr: T[]): T | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Get the last element of an array.
|
|
207
|
+
*
|
|
208
|
+
* @param arr - Array
|
|
209
|
+
* @returns Last element
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```handlebars
|
|
213
|
+
* {{last output.items}}
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare function last<T>(arr: T[]): T | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Get the length of an array or string.
|
|
219
|
+
*
|
|
220
|
+
* @param value - Array or string
|
|
221
|
+
* @returns Length
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```handlebars
|
|
225
|
+
* {{length output.items}} items
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function length(value: unknown): number;
|
|
229
|
+
/**
|
|
230
|
+
* Check if a value is in an array.
|
|
231
|
+
*
|
|
232
|
+
* @param arr - Array to search
|
|
233
|
+
* @param value - Value to find
|
|
234
|
+
* @returns true if value is in array
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```handlebars
|
|
238
|
+
* {{#if (includes output.tags "featured")}}Featured{{/if}}
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export declare function includes(arr: unknown, value: unknown): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Join array elements with a separator.
|
|
244
|
+
*
|
|
245
|
+
* @param arr - Array to join
|
|
246
|
+
* @param separator - Separator string (default: ', ')
|
|
247
|
+
* @returns Joined string
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```handlebars
|
|
251
|
+
* {{join output.tags ", "}}
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export declare function join(arr: unknown, separator?: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* Convert to uppercase.
|
|
257
|
+
*
|
|
258
|
+
* @param str - String to convert
|
|
259
|
+
* @returns Uppercase string
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```handlebars
|
|
263
|
+
* {{uppercase output.status}}
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export declare function uppercase(str: unknown): string;
|
|
267
|
+
/**
|
|
268
|
+
* Convert to lowercase.
|
|
269
|
+
*
|
|
270
|
+
* @param str - String to convert
|
|
271
|
+
* @returns Lowercase string
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```handlebars
|
|
275
|
+
* {{lowercase output.name}}
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare function lowercase(str: unknown): string;
|
|
279
|
+
/**
|
|
280
|
+
* Capitalize the first letter.
|
|
281
|
+
*
|
|
282
|
+
* @param str - String to capitalize
|
|
283
|
+
* @returns Capitalized string
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```handlebars
|
|
287
|
+
* {{capitalize output.name}}
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export declare function capitalize(str: unknown): string;
|
|
291
|
+
/**
|
|
292
|
+
* Truncate a string to a maximum length.
|
|
293
|
+
*
|
|
294
|
+
* @param str - String to truncate
|
|
295
|
+
* @param maxLength - Maximum length
|
|
296
|
+
* @param suffix - Suffix to add if truncated (default: '...')
|
|
297
|
+
* @returns Truncated string
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```handlebars
|
|
301
|
+
* {{truncate output.description 100}}
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export declare function truncate(str: unknown, maxLength?: number, suffix?: string): string;
|
|
305
|
+
/**
|
|
306
|
+
* Provide a default value if the input is falsy.
|
|
307
|
+
*
|
|
308
|
+
* @param value - Value to check
|
|
309
|
+
* @param defaultValue - Default value if falsy
|
|
310
|
+
* @returns Value or default
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```handlebars
|
|
314
|
+
* {{default output.name "Unknown"}}
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export declare function defaultValue(value: unknown, defaultValue: unknown): unknown;
|
|
318
|
+
export declare function uniqueId(prefix?: string): string;
|
|
319
|
+
/**
|
|
320
|
+
* Reset the unique ID counter (for testing).
|
|
321
|
+
*/
|
|
322
|
+
export declare function resetUniqueIdCounter(): void;
|
|
323
|
+
/**
|
|
324
|
+
* Conditionally join class names.
|
|
325
|
+
*
|
|
326
|
+
* @param classes - Class names (falsy values are filtered)
|
|
327
|
+
* @returns Space-separated class string
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```handlebars
|
|
331
|
+
* <div class="{{classNames 'base' (if active 'active') (if disabled 'disabled')}}">
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
export declare function classNames(...classes: unknown[]): string;
|
|
335
|
+
/**
|
|
336
|
+
* Collection of all built-in helpers.
|
|
337
|
+
*/
|
|
338
|
+
export declare const builtinHelpers: Record<string, HelperFunction>;
|
|
339
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/handlebars/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAG5E,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkDjE;AA0BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAezE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAS/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,C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GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAG/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOlF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAE3E;AAcD,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAyCzD,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handlebars Renderer Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Handlebars template rendering for HTML templates.
|
|
5
|
+
* Enhances plain HTML with {{variable}} syntax support.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { HandlebarsRenderer, createHandlebarsRenderer } from '@frontmcp/ui/handlebars';
|
|
10
|
+
*
|
|
11
|
+
* const renderer = createHandlebarsRenderer();
|
|
12
|
+
*
|
|
13
|
+
* const template = `
|
|
14
|
+
* <div class="card">
|
|
15
|
+
* <h2>{{escapeHtml output.title}}</h2>
|
|
16
|
+
* <p>Created: {{formatDate output.createdAt}}</p>
|
|
17
|
+
* {{#if output.items.length}}
|
|
18
|
+
* <ul>
|
|
19
|
+
* {{#each output.items}}
|
|
20
|
+
* <li>{{this.name}} - {{formatCurrency this.price}}</li>
|
|
21
|
+
* {{/each}}
|
|
22
|
+
* </ul>
|
|
23
|
+
* {{/if}}
|
|
24
|
+
* </div>
|
|
25
|
+
* `;
|
|
26
|
+
*
|
|
27
|
+
* const html = renderer.render(template, {
|
|
28
|
+
* input: { query: 'test' },
|
|
29
|
+
* output: {
|
|
30
|
+
* title: 'Results',
|
|
31
|
+
* createdAt: new Date(),
|
|
32
|
+
* items: [{ name: 'Item 1', price: 9.99 }]
|
|
33
|
+
* }
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @packageDocumentation
|
|
38
|
+
*/
|
|
39
|
+
import type { TemplateHelpers } from '../types';
|
|
40
|
+
import { type HelperFunction } from './helpers';
|
|
41
|
+
/**
|
|
42
|
+
* Check if Handlebars is available.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isHandlebarsAvailable(): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Options for the Handlebars renderer.
|
|
47
|
+
*/
|
|
48
|
+
export interface HandlebarsRendererOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Additional custom helpers to register.
|
|
51
|
+
*/
|
|
52
|
+
helpers?: Record<string, HelperFunction>;
|
|
53
|
+
/**
|
|
54
|
+
* Partial templates to register.
|
|
55
|
+
*/
|
|
56
|
+
partials?: Record<string, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Strict mode - error on missing variables.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
strict?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to auto-escape output.
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
autoEscape?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Render context for templates.
|
|
70
|
+
*/
|
|
71
|
+
export interface RenderContext {
|
|
72
|
+
/**
|
|
73
|
+
* Tool input arguments.
|
|
74
|
+
*/
|
|
75
|
+
input: Record<string, unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* Tool output/result.
|
|
78
|
+
*/
|
|
79
|
+
output: unknown;
|
|
80
|
+
/**
|
|
81
|
+
* Structured content (if schema provided).
|
|
82
|
+
*/
|
|
83
|
+
structuredContent?: unknown;
|
|
84
|
+
/**
|
|
85
|
+
* Template helper functions.
|
|
86
|
+
*/
|
|
87
|
+
helpers?: TemplateHelpers;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handlebars template renderer.
|
|
91
|
+
*
|
|
92
|
+
* Provides safe, cacheable Handlebars rendering with built-in helpers
|
|
93
|
+
* for formatting, escaping, and logic.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const renderer = new HandlebarsRenderer();
|
|
98
|
+
*
|
|
99
|
+
* // Simple render
|
|
100
|
+
* const html = await renderer.render('<div>{{output.name}}</div>', { output: { name: 'Test' } });
|
|
101
|
+
*
|
|
102
|
+
* // With custom helpers
|
|
103
|
+
* renderer.registerHelper('shout', (str) => String(str).toUpperCase() + '!');
|
|
104
|
+
* const html2 = await renderer.render('<div>{{shout output.name}}</div>', { output: { name: 'hello' } });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare class HandlebarsRenderer {
|
|
108
|
+
private readonly options;
|
|
109
|
+
private compiledTemplates;
|
|
110
|
+
private initialized;
|
|
111
|
+
private hbs;
|
|
112
|
+
constructor(options?: HandlebarsRendererOptions);
|
|
113
|
+
/**
|
|
114
|
+
* Initialize the renderer with Handlebars.
|
|
115
|
+
*/
|
|
116
|
+
private init;
|
|
117
|
+
/**
|
|
118
|
+
* Render a Handlebars template.
|
|
119
|
+
*
|
|
120
|
+
* @param template - Template string
|
|
121
|
+
* @param context - Render context with input/output
|
|
122
|
+
* @returns Rendered HTML string
|
|
123
|
+
*/
|
|
124
|
+
render(template: string, context: RenderContext): Promise<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Render a template synchronously.
|
|
127
|
+
*
|
|
128
|
+
* Note: Requires Handlebars to be pre-loaded. Use `render()` for async loading.
|
|
129
|
+
*
|
|
130
|
+
* @param template - Template string
|
|
131
|
+
* @param context - Render context
|
|
132
|
+
* @returns Rendered HTML string
|
|
133
|
+
*/
|
|
134
|
+
renderSync(template: string, context: RenderContext): string;
|
|
135
|
+
/**
|
|
136
|
+
* Initialize synchronously (for environments where Handlebars is already loaded).
|
|
137
|
+
*/
|
|
138
|
+
initSync(handlebars: typeof import('handlebars')): void;
|
|
139
|
+
/**
|
|
140
|
+
* Register a custom helper.
|
|
141
|
+
*
|
|
142
|
+
* @param name - Helper name
|
|
143
|
+
* @param fn - Helper function
|
|
144
|
+
*/
|
|
145
|
+
registerHelper(name: string, fn: HelperFunction): void;
|
|
146
|
+
/**
|
|
147
|
+
* Register a partial template.
|
|
148
|
+
*
|
|
149
|
+
* @param name - Partial name
|
|
150
|
+
* @param template - Partial template string
|
|
151
|
+
*/
|
|
152
|
+
registerPartial(name: string, template: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* Clear compiled template cache.
|
|
155
|
+
*/
|
|
156
|
+
clearCache(): void;
|
|
157
|
+
/**
|
|
158
|
+
* Check if a template string contains Handlebars syntax.
|
|
159
|
+
*
|
|
160
|
+
* @param template - Template string to check
|
|
161
|
+
* @returns true if contains {{...}} syntax
|
|
162
|
+
*/
|
|
163
|
+
static containsHandlebars(template: string): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Check if the renderer is initialized.
|
|
166
|
+
*/
|
|
167
|
+
get isInitialized(): boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a new Handlebars renderer.
|
|
171
|
+
*
|
|
172
|
+
* @param options - Renderer options
|
|
173
|
+
* @returns New HandlebarsRenderer instance
|
|
174
|
+
*/
|
|
175
|
+
export declare function createHandlebarsRenderer(options?: HandlebarsRendererOptions): HandlebarsRenderer;
|
|
176
|
+
/**
|
|
177
|
+
* Render a template with default settings.
|
|
178
|
+
*
|
|
179
|
+
* Convenience function for one-off rendering.
|
|
180
|
+
*
|
|
181
|
+
* @param template - Template string
|
|
182
|
+
* @param context - Render context
|
|
183
|
+
* @returns Rendered HTML
|
|
184
|
+
*/
|
|
185
|
+
export declare function renderTemplate(template: string, context: RenderContext): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Check if a template contains Handlebars syntax.
|
|
188
|
+
*
|
|
189
|
+
* @param template - Template string
|
|
190
|
+
* @returns true if contains {{...}}
|
|
191
|
+
*/
|
|
192
|
+
export declare function containsHandlebars(template: string): boolean;
|
|
193
|
+
export { builtinHelpers, escapeHtml, formatDate, formatCurrency, formatNumber, json, jsonEmbed, eq, ne, gt, gte, lt, lte, and, or, not, first, last, length, includes, join, uppercase, lowercase, capitalize, truncate, defaultValue, uniqueId, classNames, resetUniqueIdCounter, type HelperFunction, } from './helpers';
|
|
194
|
+
export { extractExpressions, extractVariablePaths, extractOutputPaths, extractInputPaths, extractStructuredContentPaths, extractAll, hasVariablePaths, getExpressionAt, normalizePath, type ExtractedExpression, type ExtractionResult, type ExpressionType, } from './expression-extractor';
|
|
195
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlebars/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAuBhE;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,O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