@frontmcp/uipack 0.6.1 → 0.6.2
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 +88 -105
- package/README.md +1 -0
- package/adapters/index.d.ts +1 -1
- package/adapters/index.d.ts.map +1 -1
- package/adapters/index.js +35 -2
- package/adapters/platform-meta.d.ts +29 -0
- package/adapters/platform-meta.d.ts.map +1 -1
- package/base-template/default-base-template.d.ts +0 -1
- package/base-template/default-base-template.d.ts.map +1 -1
- package/base-template/index.js +32 -37
- package/build/builders/base-builder.d.ts +122 -0
- package/build/builders/base-builder.d.ts.map +1 -0
- package/build/builders/esbuild-config.d.ts +94 -0
- package/build/builders/esbuild-config.d.ts.map +1 -0
- package/build/builders/hybrid-builder.d.ts +93 -0
- package/build/builders/hybrid-builder.d.ts.map +1 -0
- package/build/builders/index.d.ts +17 -0
- package/build/builders/index.d.ts.map +1 -0
- package/build/builders/inline-builder.d.ts +83 -0
- package/build/builders/inline-builder.d.ts.map +1 -0
- package/build/builders/static-builder.d.ts +78 -0
- package/build/builders/static-builder.d.ts.map +1 -0
- package/build/builders/types.d.ts +341 -0
- package/build/builders/types.d.ts.map +1 -0
- package/build/cdn-resources.d.ts +3 -2
- package/build/cdn-resources.d.ts.map +1 -1
- package/build/hybrid-data.d.ts +127 -0
- package/build/hybrid-data.d.ts.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1885 -171
- package/build/ui-components-browser.d.ts +64 -0
- package/build/ui-components-browser.d.ts.map +1 -0
- package/build/widget-manifest.d.ts.map +1 -1
- package/bundler/file-cache/component-builder.d.ts.map +1 -1
- package/bundler/file-cache/storage/redis.d.ts.map +1 -1
- package/bundler/index.js +6 -4
- package/dependency/cdn-registry.d.ts +1 -1
- package/dependency/cdn-registry.d.ts.map +1 -1
- package/dependency/import-map.d.ts.map +1 -1
- package/dependency/index.js +93 -121
- package/dependency/resolver.d.ts.map +1 -1
- package/esm/adapters/{index.js → index.mjs} +34 -2
- package/esm/base-template/{index.js → index.mjs} +32 -37
- package/esm/build/{index.js → index.mjs} +1855 -170
- package/esm/bundler/{index.js → index.mjs} +6 -4
- package/esm/dependency/{index.js → index.mjs} +93 -121
- package/esm/handlebars/{index.js → index.mjs} +0 -1
- package/esm/{index.js → index.mjs} +2516 -830
- package/esm/package.json +7 -6
- package/esm/registry/{index.js → index.mjs} +196 -264
- package/esm/renderers/{index.js → index.mjs} +106 -200
- package/esm/runtime/{index.js → index.mjs} +44 -35
- package/esm/styles/{index.js → index.mjs} +6 -6
- package/esm/theme/{index.js → index.mjs} +90 -42
- package/esm/tool-template/{index.js → index.mjs} +35 -28
- package/esm/typings/{index.js → index.mjs} +157 -1
- package/esm/utils/{index.js → index.mjs} +24 -0
- package/esm/validation/{index.js → index.mjs} +0 -1
- package/handlebars/expression-extractor.d.ts.map +1 -1
- package/handlebars/index.d.ts.map +1 -1
- package/handlebars/index.js +0 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +2545 -835
- package/package.json +7 -6
- package/preview/claude-preview.d.ts +67 -0
- package/preview/claude-preview.d.ts.map +1 -0
- package/preview/generic-preview.d.ts +67 -0
- package/preview/generic-preview.d.ts.map +1 -0
- package/preview/index.d.ts +36 -0
- package/preview/index.d.ts.map +1 -0
- package/preview/openai-preview.d.ts +70 -0
- package/preview/openai-preview.d.ts.map +1 -0
- package/preview/types.d.ts +185 -0
- package/preview/types.d.ts.map +1 -0
- package/registry/index.js +196 -264
- package/registry/render-template.d.ts.map +1 -1
- package/renderers/index.d.ts +2 -2
- package/renderers/index.d.ts.map +1 -1
- package/renderers/index.js +110 -204
- package/renderers/mdx-client.renderer.d.ts +124 -0
- package/renderers/mdx-client.renderer.d.ts.map +1 -0
- package/renderers/registry.d.ts +2 -2
- package/renderers/registry.d.ts.map +1 -1
- package/renderers/types.d.ts +3 -2
- package/renderers/types.d.ts.map +1 -1
- package/renderers/utils/transpiler.d.ts +8 -27
- package/renderers/utils/transpiler.d.ts.map +1 -1
- package/runtime/index.js +44 -35
- package/runtime/mcp-bridge.d.ts.map +1 -1
- package/runtime/renderer-runtime.d.ts.map +1 -1
- package/runtime/wrapper.d.ts.map +1 -1
- package/styles/index.js +6 -6
- package/styles/variants.d.ts +1 -1
- package/styles/variants.d.ts.map +1 -1
- package/theme/cdn.d.ts.map +1 -1
- package/theme/css-to-theme.d.ts +91 -0
- package/theme/css-to-theme.d.ts.map +1 -0
- package/theme/index.d.ts +2 -1
- package/theme/index.d.ts.map +1 -1
- package/theme/index.js +92 -43
- package/theme/platforms.d.ts +1 -6
- package/theme/platforms.d.ts.map +1 -1
- package/theme/theme.d.ts.map +1 -1
- package/tool-template/builder.d.ts.map +1 -1
- package/tool-template/index.js +35 -28
- package/typings/index.d.ts +4 -4
- package/typings/index.d.ts.map +1 -1
- package/typings/index.js +162 -1
- package/typings/schemas.d.ts +30 -0
- package/typings/schemas.d.ts.map +1 -1
- package/typings/type-fetcher.d.ts +74 -1
- package/typings/type-fetcher.d.ts.map +1 -1
- package/typings/types.d.ts +72 -1
- package/typings/types.d.ts.map +1 -1
- package/utils/escape-html.d.ts +44 -0
- package/utils/escape-html.d.ts.map +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +26 -0
- package/validation/index.js +0 -1
- package/validation/template-validator.d.ts.map +1 -1
- package/esm/adapters/index.d.ts +0 -13
- package/esm/adapters/index.d.ts.map +0 -1
- package/esm/adapters/platform-meta.d.ts +0 -166
- package/esm/adapters/platform-meta.d.ts.map +0 -1
- package/esm/adapters/response-builder.d.ts +0 -108
- package/esm/adapters/response-builder.d.ts.map +0 -1
- package/esm/adapters/serving-mode.d.ts +0 -107
- package/esm/adapters/serving-mode.d.ts.map +0 -1
- package/esm/base-template/bridge.d.ts +0 -90
- package/esm/base-template/bridge.d.ts.map +0 -1
- package/esm/base-template/default-base-template.d.ts +0 -92
- package/esm/base-template/default-base-template.d.ts.map +0 -1
- package/esm/base-template/index.d.ts +0 -15
- package/esm/base-template/index.d.ts.map +0 -1
- package/esm/base-template/polyfills.d.ts +0 -31
- package/esm/base-template/polyfills.d.ts.map +0 -1
- package/esm/base-template/theme-styles.d.ts +0 -74
- package/esm/base-template/theme-styles.d.ts.map +0 -1
- package/esm/bridge-runtime/iife-generator.d.ts +0 -62
- package/esm/bridge-runtime/iife-generator.d.ts.map +0 -1
- package/esm/bridge-runtime/index.d.ts +0 -10
- package/esm/bridge-runtime/index.d.ts.map +0 -1
- package/esm/build/cdn-resources.d.ts +0 -243
- package/esm/build/cdn-resources.d.ts.map +0 -1
- package/esm/build/index.d.ts +0 -295
- package/esm/build/index.d.ts.map +0 -1
- package/esm/build/widget-manifest.d.ts +0 -362
- package/esm/build/widget-manifest.d.ts.map +0 -1
- package/esm/bundler/cache.d.ts +0 -173
- package/esm/bundler/cache.d.ts.map +0 -1
- package/esm/bundler/file-cache/component-builder.d.ts +0 -167
- package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/esm/bundler/file-cache/index.d.ts +0 -12
- package/esm/bundler/file-cache/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/index.d.ts +0 -11
- package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
- package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
- package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/esm/bundler/index.d.ts +0 -35
- package/esm/bundler/index.d.ts.map +0 -1
- package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/esm/bundler/sandbox/executor.d.ts +0 -14
- package/esm/bundler/sandbox/executor.d.ts.map +0 -1
- package/esm/bundler/sandbox/policy.d.ts +0 -62
- package/esm/bundler/sandbox/policy.d.ts.map +0 -1
- package/esm/bundler/types.d.ts +0 -702
- package/esm/bundler/types.d.ts.map +0 -1
- package/esm/dependency/cdn-registry.d.ts +0 -98
- package/esm/dependency/cdn-registry.d.ts.map +0 -1
- package/esm/dependency/import-map.d.ts +0 -186
- package/esm/dependency/import-map.d.ts.map +0 -1
- package/esm/dependency/import-parser.d.ts +0 -82
- package/esm/dependency/import-parser.d.ts.map +0 -1
- package/esm/dependency/index.d.ts +0 -17
- package/esm/dependency/index.d.ts.map +0 -1
- package/esm/dependency/resolver.d.ts +0 -164
- package/esm/dependency/resolver.d.ts.map +0 -1
- package/esm/dependency/schemas.d.ts +0 -486
- package/esm/dependency/schemas.d.ts.map +0 -1
- package/esm/dependency/template-loader.d.ts +0 -204
- package/esm/dependency/template-loader.d.ts.map +0 -1
- package/esm/dependency/template-processor.d.ts +0 -118
- package/esm/dependency/template-processor.d.ts.map +0 -1
- package/esm/dependency/types.d.ts +0 -739
- package/esm/dependency/types.d.ts.map +0 -1
- package/esm/handlebars/expression-extractor.d.ts +0 -147
- package/esm/handlebars/expression-extractor.d.ts.map +0 -1
- package/esm/handlebars/helpers.d.ts +0 -339
- package/esm/handlebars/helpers.d.ts.map +0 -1
- package/esm/handlebars/index.d.ts +0 -195
- package/esm/handlebars/index.d.ts.map +0 -1
- package/esm/index.d.ts +0 -50
- package/esm/index.d.ts.map +0 -1
- package/esm/registry/index.d.ts +0 -46
- package/esm/registry/index.d.ts.map +0 -1
- package/esm/registry/render-template.d.ts +0 -91
- package/esm/registry/render-template.d.ts.map +0 -1
- package/esm/registry/tool-ui.registry.d.ts +0 -294
- package/esm/registry/tool-ui.registry.d.ts.map +0 -1
- package/esm/registry/uri-utils.d.ts +0 -56
- package/esm/registry/uri-utils.d.ts.map +0 -1
- package/esm/renderers/cache.d.ts +0 -145
- package/esm/renderers/cache.d.ts.map +0 -1
- package/esm/renderers/html.renderer.d.ts +0 -123
- package/esm/renderers/html.renderer.d.ts.map +0 -1
- package/esm/renderers/index.d.ts +0 -36
- package/esm/renderers/index.d.ts.map +0 -1
- package/esm/renderers/mdx.renderer.d.ts +0 -120
- package/esm/renderers/mdx.renderer.d.ts.map +0 -1
- package/esm/renderers/registry.d.ts +0 -133
- package/esm/renderers/registry.d.ts.map +0 -1
- package/esm/renderers/types.d.ts +0 -342
- package/esm/renderers/types.d.ts.map +0 -1
- package/esm/renderers/utils/detect.d.ts +0 -107
- package/esm/renderers/utils/detect.d.ts.map +0 -1
- package/esm/renderers/utils/hash.d.ts +0 -40
- package/esm/renderers/utils/hash.d.ts.map +0 -1
- package/esm/renderers/utils/index.d.ts +0 -9
- package/esm/renderers/utils/index.d.ts.map +0 -1
- package/esm/renderers/utils/transpiler.d.ts +0 -89
- package/esm/renderers/utils/transpiler.d.ts.map +0 -1
- package/esm/runtime/adapters/html.adapter.d.ts +0 -59
- package/esm/runtime/adapters/html.adapter.d.ts.map +0 -1
- package/esm/runtime/adapters/index.d.ts +0 -26
- package/esm/runtime/adapters/index.d.ts.map +0 -1
- package/esm/runtime/adapters/mdx.adapter.d.ts +0 -73
- package/esm/runtime/adapters/mdx.adapter.d.ts.map +0 -1
- package/esm/runtime/adapters/types.d.ts +0 -95
- package/esm/runtime/adapters/types.d.ts.map +0 -1
- package/esm/runtime/csp.d.ts +0 -48
- package/esm/runtime/csp.d.ts.map +0 -1
- package/esm/runtime/index.d.ts +0 -17
- package/esm/runtime/index.d.ts.map +0 -1
- package/esm/runtime/mcp-bridge.d.ts +0 -101
- package/esm/runtime/mcp-bridge.d.ts.map +0 -1
- package/esm/runtime/renderer-runtime.d.ts +0 -133
- package/esm/runtime/renderer-runtime.d.ts.map +0 -1
- package/esm/runtime/sanitizer.d.ts +0 -172
- package/esm/runtime/sanitizer.d.ts.map +0 -1
- package/esm/runtime/types.d.ts +0 -415
- package/esm/runtime/types.d.ts.map +0 -1
- package/esm/runtime/wrapper.d.ts +0 -421
- package/esm/runtime/wrapper.d.ts.map +0 -1
- package/esm/styles/index.d.ts +0 -8
- package/esm/styles/index.d.ts.map +0 -1
- package/esm/styles/variants.d.ts +0 -51
- package/esm/styles/variants.d.ts.map +0 -1
- package/esm/theme/cdn.d.ts +0 -195
- package/esm/theme/cdn.d.ts.map +0 -1
- package/esm/theme/index.d.ts +0 -18
- package/esm/theme/index.d.ts.map +0 -1
- package/esm/theme/platforms.d.ts +0 -107
- package/esm/theme/platforms.d.ts.map +0 -1
- package/esm/theme/presets/github-openai.d.ts +0 -50
- package/esm/theme/presets/github-openai.d.ts.map +0 -1
- package/esm/theme/presets/index.d.ts +0 -11
- package/esm/theme/presets/index.d.ts.map +0 -1
- package/esm/theme/theme.d.ts +0 -396
- package/esm/theme/theme.d.ts.map +0 -1
- package/esm/tool-template/builder.d.ts +0 -213
- package/esm/tool-template/builder.d.ts.map +0 -1
- package/esm/tool-template/index.d.ts +0 -16
- package/esm/tool-template/index.d.ts.map +0 -1
- package/esm/types/index.d.ts +0 -14
- package/esm/types/index.d.ts.map +0 -1
- package/esm/types/ui-config.d.ts +0 -641
- package/esm/types/ui-config.d.ts.map +0 -1
- package/esm/types/ui-runtime.d.ts +0 -1008
- package/esm/types/ui-runtime.d.ts.map +0 -1
- package/esm/typings/cache/cache-adapter.d.ts +0 -125
- package/esm/typings/cache/cache-adapter.d.ts.map +0 -1
- package/esm/typings/cache/index.d.ts +0 -10
- package/esm/typings/cache/index.d.ts.map +0 -1
- package/esm/typings/cache/memory-cache.d.ts +0 -92
- package/esm/typings/cache/memory-cache.d.ts.map +0 -1
- package/esm/typings/dts-parser.d.ts +0 -90
- package/esm/typings/dts-parser.d.ts.map +0 -1
- package/esm/typings/index.d.ts +0 -48
- package/esm/typings/index.d.ts.map +0 -1
- package/esm/typings/schemas.d.ts +0 -232
- package/esm/typings/schemas.d.ts.map +0 -1
- package/esm/typings/type-fetcher.d.ts +0 -89
- package/esm/typings/type-fetcher.d.ts.map +0 -1
- package/esm/typings/types.d.ts +0 -320
- package/esm/typings/types.d.ts.map +0 -1
- package/esm/utils/escape-html.d.ts +0 -58
- package/esm/utils/escape-html.d.ts.map +0 -1
- package/esm/utils/index.d.ts +0 -10
- package/esm/utils/index.d.ts.map +0 -1
- package/esm/utils/safe-stringify.d.ts +0 -30
- package/esm/utils/safe-stringify.d.ts.map +0 -1
- package/esm/validation/error-box.d.ts +0 -56
- package/esm/validation/error-box.d.ts.map +0 -1
- package/esm/validation/index.d.ts +0 -13
- package/esm/validation/index.d.ts.map +0 -1
- package/esm/validation/schema-paths.d.ts +0 -118
- package/esm/validation/schema-paths.d.ts.map +0 -1
- package/esm/validation/template-validator.d.ts +0 -143
- package/esm/validation/template-validator.d.ts.map +0 -1
- package/esm/validation/wrapper.d.ts +0 -97
- package/esm/validation/wrapper.d.ts.map +0 -1
- package/renderers/mdx.renderer.d.ts +0 -120
- package/renderers/mdx.renderer.d.ts.map +0 -1
- /package/esm/bridge-runtime/{index.js → index.mjs} +0 -0
- /package/esm/types/{index.js → index.mjs} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Builder
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class for Static, Hybrid, and Inline builders.
|
|
5
|
+
* Provides common functionality for template detection, transpilation,
|
|
6
|
+
* and HTML generation.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { BuilderOptions, CdnMode, TemplateDetection, TranspileOptions, TranspileResult } from './types';
|
|
11
|
+
import type { UITemplateConfig, TemplateContext, TemplateBuilderFn } from '../../types';
|
|
12
|
+
import type { ThemeConfig } from '../../theme';
|
|
13
|
+
/**
|
|
14
|
+
* Abstract base builder class.
|
|
15
|
+
*
|
|
16
|
+
* Provides common functionality:
|
|
17
|
+
* - Template type detection
|
|
18
|
+
* - Component transpilation via esbuild
|
|
19
|
+
* - Theme CSS generation
|
|
20
|
+
* - HTML document scaffolding
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class BaseBuilder {
|
|
23
|
+
/**
|
|
24
|
+
* CDN loading mode.
|
|
25
|
+
*/
|
|
26
|
+
protected readonly cdnMode: CdnMode;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to minify output.
|
|
29
|
+
*/
|
|
30
|
+
protected readonly minify: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Theme configuration.
|
|
33
|
+
*/
|
|
34
|
+
protected readonly theme: ThemeConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to include source maps.
|
|
37
|
+
*/
|
|
38
|
+
protected readonly sourceMaps: boolean;
|
|
39
|
+
constructor(options?: BuilderOptions);
|
|
40
|
+
/**
|
|
41
|
+
* Detect the type of a template.
|
|
42
|
+
*
|
|
43
|
+
* @param template - Template to detect
|
|
44
|
+
* @returns Detection result with type and renderer info
|
|
45
|
+
*/
|
|
46
|
+
protected detectTemplate<In = unknown, Out = unknown>(template: UITemplateConfig<In, Out>['template']): TemplateDetection;
|
|
47
|
+
/**
|
|
48
|
+
* Transpile a component using esbuild.
|
|
49
|
+
*
|
|
50
|
+
* @param source - Source code to transpile
|
|
51
|
+
* @param options - Transpile options
|
|
52
|
+
* @returns Transpile result
|
|
53
|
+
*/
|
|
54
|
+
protected transpile(source: string, options?: TranspileOptions): Promise<TranspileResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Render an HTML template.
|
|
57
|
+
*
|
|
58
|
+
* @param template - HTML template (string or function)
|
|
59
|
+
* @param context - Template context with input/output
|
|
60
|
+
* @returns Rendered HTML string
|
|
61
|
+
*/
|
|
62
|
+
protected renderHtmlTemplate<In = unknown, Out = unknown>(template: string | TemplateBuilderFn<In, Out>, context: TemplateContext<In, Out>): string;
|
|
63
|
+
/**
|
|
64
|
+
* Build the <head> section of the HTML document.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Head options
|
|
67
|
+
* @returns HTML head content
|
|
68
|
+
*/
|
|
69
|
+
protected buildHead(options: {
|
|
70
|
+
title: string;
|
|
71
|
+
includeBridge?: boolean;
|
|
72
|
+
includeCdn?: boolean;
|
|
73
|
+
includeTheme?: boolean;
|
|
74
|
+
customStyles?: string;
|
|
75
|
+
}): string;
|
|
76
|
+
/**
|
|
77
|
+
* Build data injection script.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Injection options
|
|
80
|
+
* @returns Script tag with data injection
|
|
81
|
+
*/
|
|
82
|
+
protected buildDataInjectionScript(options: {
|
|
83
|
+
toolName: string;
|
|
84
|
+
input?: unknown;
|
|
85
|
+
output?: unknown;
|
|
86
|
+
usePlaceholders?: boolean;
|
|
87
|
+
}): string;
|
|
88
|
+
/**
|
|
89
|
+
* Wrap content in a complete HTML document.
|
|
90
|
+
*
|
|
91
|
+
* @param options - Wrap options
|
|
92
|
+
* @returns Complete HTML document
|
|
93
|
+
*/
|
|
94
|
+
protected wrapInHtmlDocument(options: {
|
|
95
|
+
head: string;
|
|
96
|
+
body: string;
|
|
97
|
+
bodyClass?: string;
|
|
98
|
+
}): string;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate content hash.
|
|
101
|
+
*
|
|
102
|
+
* @param content - Content to hash
|
|
103
|
+
* @returns Hash string
|
|
104
|
+
*/
|
|
105
|
+
protected calculateHash(content: string): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Estimate gzipped size.
|
|
108
|
+
*
|
|
109
|
+
* @param content - Content to estimate
|
|
110
|
+
* @returns Estimated gzipped size in bytes
|
|
111
|
+
*/
|
|
112
|
+
protected estimateGzipSize(content: string): number;
|
|
113
|
+
/**
|
|
114
|
+
* Create template context.
|
|
115
|
+
*
|
|
116
|
+
* @param input - Tool input
|
|
117
|
+
* @param output - Tool output
|
|
118
|
+
* @returns Template context
|
|
119
|
+
*/
|
|
120
|
+
protected createContext<In = unknown, Out = unknown>(input: In, output: Out): TemplateContext<In, Out>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=base-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-builder.d.ts","sourceRoot":"","sources":["../../../src/build/builders/base-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAW/C;;;;;;;;GAQG;AACH,8BAAsB,WAAW;IAC/B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAEpC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAEtC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;gBAE3B,OAAO,GAAE,cAAmB;IAWxC;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EAClD,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAC9C,iBAAiB;IA4DpB;;;;;;OAMG;cACa,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC;IAgB3B;;;;;;OAMG;IACH,SAAS,CAAC,kBAAkB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACtD,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,GAAG,CAAC,EAC7C,OAAO,EAAE,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,GAChC,MAAM;IAYT;;;;;OAKG;IACH,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE;QAC3B,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,MAAM;IAsDV;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAAC,OAAO,EAAE;QAC1C,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,GAAG,MAAM;IAwBV;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACpC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,MAAM;IAgBV;;;;;OAKG;cACa,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/D;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAKnD;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACjD,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,GAAG,GACV,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC;CAgC5B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild Configuration for Builders
|
|
3
|
+
*
|
|
4
|
+
* Shared esbuild configuration for component transpilation.
|
|
5
|
+
* Supports externalization for hybrid mode and inline bundling.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { TransformOptions } from 'esbuild';
|
|
10
|
+
import type { TranspileOptions } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Default packages to externalize in hybrid mode.
|
|
13
|
+
* These packages are loaded from the vendor shell's CDN scripts.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_EXTERNALS: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Global variable mappings for externalized packages.
|
|
18
|
+
* Used to create namespace polyfills in the component chunk.
|
|
19
|
+
*/
|
|
20
|
+
export declare const EXTERNAL_GLOBALS: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Create esbuild transform options for component transpilation.
|
|
23
|
+
*
|
|
24
|
+
* @param options - Transpile options
|
|
25
|
+
* @returns esbuild transform options
|
|
26
|
+
*/
|
|
27
|
+
export declare function createTransformConfig(options?: TranspileOptions): TransformOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Create esbuild transform options for externalized component chunks.
|
|
30
|
+
*
|
|
31
|
+
* This configuration produces code that:
|
|
32
|
+
* 1. Imports React/deps from external globals
|
|
33
|
+
* 2. Uses ESM format for dynamic import
|
|
34
|
+
* 3. Has all FrontMCP UI components externalized
|
|
35
|
+
*
|
|
36
|
+
* @param options - Transpile options
|
|
37
|
+
* @returns esbuild transform options with externalization
|
|
38
|
+
*/
|
|
39
|
+
export declare function createExternalizedConfig(options?: TranspileOptions): TransformOptions;
|
|
40
|
+
/**
|
|
41
|
+
* Create JavaScript banner that defines external namespace objects.
|
|
42
|
+
*
|
|
43
|
+
* This banner is prepended to the transpiled code and provides
|
|
44
|
+
* the global variables that the externalized imports reference.
|
|
45
|
+
*
|
|
46
|
+
* @param externals - List of external package names
|
|
47
|
+
* @returns JavaScript banner code
|
|
48
|
+
*/
|
|
49
|
+
export declare function createExternalsBanner(externals: string[]): string;
|
|
50
|
+
/**
|
|
51
|
+
* Create inline bundle configuration.
|
|
52
|
+
*
|
|
53
|
+
* This configuration bundles everything together for inline mode,
|
|
54
|
+
* including React and all dependencies.
|
|
55
|
+
*
|
|
56
|
+
* @param options - Transpile options
|
|
57
|
+
* @returns esbuild transform options for inline bundling
|
|
58
|
+
*/
|
|
59
|
+
export declare function createInlineConfig(options?: TranspileOptions): TransformOptions;
|
|
60
|
+
/**
|
|
61
|
+
* CDN URLs for external dependencies.
|
|
62
|
+
*/
|
|
63
|
+
export declare const CDN_URLS: {
|
|
64
|
+
readonly react: "https://esm.sh/react@19";
|
|
65
|
+
readonly reactDom: "https://esm.sh/react-dom@19";
|
|
66
|
+
readonly reactJsxRuntime: "https://esm.sh/react@19/jsx-runtime";
|
|
67
|
+
readonly frontmcpUI: "https://esm.sh/@frontmcp/ui";
|
|
68
|
+
readonly tailwind: "https://cdn.tailwindcss.com";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Cloudflare CDN URLs (for Claude compatibility).
|
|
72
|
+
*/
|
|
73
|
+
export declare const CLOUDFLARE_CDN_URLS: {
|
|
74
|
+
readonly react: "https://cdnjs.cloudflare.com/ajax/libs/react/19.0.0/umd/react.production.min.js";
|
|
75
|
+
readonly reactDom: "https://cdnjs.cloudflare.com/ajax/libs/react-dom/19.0.0/umd/react-dom.production.min.js";
|
|
76
|
+
readonly tailwind: "https://cdn.tailwindcss.com";
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Generate CDN script tags for the vendor shell.
|
|
80
|
+
*
|
|
81
|
+
* @param useCloudflare - Use Cloudflare CDN (for Claude)
|
|
82
|
+
* @returns HTML script tags
|
|
83
|
+
*/
|
|
84
|
+
export declare function generateCdnScriptTags(useCloudflare?: boolean): string;
|
|
85
|
+
/**
|
|
86
|
+
* Generate global namespace setup script.
|
|
87
|
+
*
|
|
88
|
+
* This script exposes React and other modules as globals
|
|
89
|
+
* for the externalized component chunks to use.
|
|
90
|
+
*
|
|
91
|
+
* @returns JavaScript code to set up globals
|
|
92
|
+
*/
|
|
93
|
+
export declare function generateGlobalsSetupScript(): string;
|
|
94
|
+
//# sourceMappingURL=esbuild-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-config.d.ts","sourceRoot":"","sources":["../../../src/build/builders/esbuild-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAMhD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAO7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnD,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAkBtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAWzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAejE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAMnF;AAMD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;CAMX,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,UAAQ,GAAG,MAAM,CA0BnE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAiBnD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds vendor shell (cached, shared) + component chunks (per-tool).
|
|
5
|
+
* Optimal for OpenAI where shell is fetched once via resource URI and cached.
|
|
6
|
+
*
|
|
7
|
+
* Build Phase:
|
|
8
|
+
* - Vendor shell: React, Bridge, UI components from CDN
|
|
9
|
+
* - Component chunks: Transpiled with externalized dependencies
|
|
10
|
+
*
|
|
11
|
+
* Preview Phase:
|
|
12
|
+
* - OpenAI: Shell via resource://, component in tool response
|
|
13
|
+
* - Claude: Combine shell + component (inline delivery)
|
|
14
|
+
* - Generic: Same as OpenAI with frontmcp namespace
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
import { BaseBuilder } from './base-builder';
|
|
19
|
+
import type { BuilderOptions, BuildToolOptions, HybridBuildResult, IHybridBuilder } from './types';
|
|
20
|
+
import type { UITemplateConfig } from '../../types';
|
|
21
|
+
/**
|
|
22
|
+
* Hybrid builder for creating vendor shells and component chunks.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const builder = new HybridBuilder({ cdnMode: 'cdn' });
|
|
27
|
+
*
|
|
28
|
+
* // Build vendor shell (cached, shared across all tools)
|
|
29
|
+
* const vendorShell = await builder.buildVendorShell();
|
|
30
|
+
*
|
|
31
|
+
* // Build component chunk per tool
|
|
32
|
+
* const componentChunk = await builder.buildComponentChunk(WeatherWidget);
|
|
33
|
+
*
|
|
34
|
+
* // For Claude, combine into inline HTML
|
|
35
|
+
* const html = builder.combineForInline(vendorShell, componentChunk, input, output);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class HybridBuilder extends BaseBuilder implements IHybridBuilder {
|
|
39
|
+
readonly mode: "hybrid";
|
|
40
|
+
/**
|
|
41
|
+
* Cached vendor shell.
|
|
42
|
+
*/
|
|
43
|
+
private vendorShellCache;
|
|
44
|
+
constructor(options?: BuilderOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Build a hybrid result with vendor shell and component chunk.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Build options
|
|
49
|
+
* @returns Hybrid build result
|
|
50
|
+
*/
|
|
51
|
+
build<In = unknown, Out = unknown>(options: BuildToolOptions<In, Out>): Promise<HybridBuildResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Build the vendor shell (shared across all tools).
|
|
54
|
+
*
|
|
55
|
+
* The vendor shell contains:
|
|
56
|
+
* - React/ReactDOM from CDN
|
|
57
|
+
* - FrontMCP Bridge runtime
|
|
58
|
+
* - Theme CSS and fonts
|
|
59
|
+
* - Component injection point
|
|
60
|
+
*
|
|
61
|
+
* @returns Vendor shell HTML
|
|
62
|
+
*/
|
|
63
|
+
buildVendorShell(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Build a component chunk for a specific template.
|
|
66
|
+
*
|
|
67
|
+
* The component chunk is transpiled with externalized dependencies
|
|
68
|
+
* (React, etc.) that are provided by the vendor shell.
|
|
69
|
+
*
|
|
70
|
+
* @param template - Component template
|
|
71
|
+
* @returns Transpiled component code
|
|
72
|
+
*/
|
|
73
|
+
buildComponentChunk<In = unknown, Out = unknown>(template: UITemplateConfig<In, Out>['template']): Promise<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Combine shell and component for Claude/inline delivery.
|
|
76
|
+
*
|
|
77
|
+
* @param shell - Vendor shell HTML
|
|
78
|
+
* @param component - Component chunk code
|
|
79
|
+
* @param input - Tool input data
|
|
80
|
+
* @param output - Tool output data
|
|
81
|
+
* @returns Complete HTML with embedded component and data
|
|
82
|
+
*/
|
|
83
|
+
combineForInline(shell: string, component: string, input: unknown, output: unknown): string;
|
|
84
|
+
/**
|
|
85
|
+
* Wrap HTML template as a React component.
|
|
86
|
+
*/
|
|
87
|
+
private wrapHtmlAsComponent;
|
|
88
|
+
/**
|
|
89
|
+
* Transpile a React component function.
|
|
90
|
+
*/
|
|
91
|
+
private transpileReactComponent;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=hybrid-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hybrid-builder.d.ts","sourceRoot":"","sources":["../../../src/build/builders/hybrid-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,aAAa,CAAC;AAWvE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,WAAY,YAAW,cAAc;IACtE,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAAuB;gBAEnC,OAAO,GAAE,cAAmB;IAIxC;;;;;OAKG;IACG,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACrC,OAAO,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,GACjC,OAAO,CAAC,iBAAiB,CAAC;IAkC7B;;;;;;;;;;OAUG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAqHzC;;;;;;;;OAQG;IACG,mBAAmB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACnD,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAC9C,OAAO,CAAC,MAAM,CAAC;IA2BlB;;;;;;;;OAQG;IACH,gBAAgB,CACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,GACd,MAAM;IA+CT;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA8B3B;;OAEG;YACW,uBAAuB;CA8BtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Builders
|
|
3
|
+
*
|
|
4
|
+
* Three build modes for creating universal HTML documents:
|
|
5
|
+
* - Static: Full HTML with placeholders, inject data at preview time
|
|
6
|
+
* - Hybrid: Vendor shell + component chunks, optimal for OpenAI
|
|
7
|
+
* - Inline: Minimal loader + full HTML per request, best for development
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export type { BuildMode, CdnMode, BuilderOptions, BuildToolOptions, StaticBuildResult, HybridBuildResult, InlineBuildResult, BuilderResult, Builder, IStaticBuilder, IHybridBuilder, IInlineBuilder, TemplateType, TemplateDetection, TranspileOptions, TranspileResult, } from './types';
|
|
12
|
+
export { BaseBuilder } from './base-builder';
|
|
13
|
+
export { StaticBuilder } from './static-builder';
|
|
14
|
+
export { HybridBuilder } from './hybrid-builder';
|
|
15
|
+
export { InlineBuilder } from './inline-builder';
|
|
16
|
+
export { DEFAULT_EXTERNALS, EXTERNAL_GLOBALS, CDN_URLS, CLOUDFLARE_CDN_URLS, createTransformConfig, createExternalizedConfig, createInlineConfig, createExternalsBanner, generateCdnScriptTags, generateGlobalsSetupScript, } from './esbuild-config';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/build/builders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds minimal loader shell (for discovery) + full HTML per request.
|
|
5
|
+
* Best for development/review where each request gets complete widget.
|
|
6
|
+
*
|
|
7
|
+
* Build Phase:
|
|
8
|
+
* - Minimal loader with bridge and loading indicator
|
|
9
|
+
* - Injector script that waits for full HTML in tool response
|
|
10
|
+
*
|
|
11
|
+
* Preview Phase:
|
|
12
|
+
* - OpenAI: Loader at discovery, full HTML replaces document on tool call
|
|
13
|
+
* - Claude: Full HTML returned directly (no loader needed)
|
|
14
|
+
* - Generic: Same as OpenAI with frontmcp namespace
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
import { BaseBuilder } from './base-builder';
|
|
19
|
+
import type { BuilderOptions, BuildToolOptions, InlineBuildResult, IInlineBuilder } from './types';
|
|
20
|
+
import type { UITemplateConfig } from '../../types';
|
|
21
|
+
/**
|
|
22
|
+
* Inline builder for development and review scenarios.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const builder = new InlineBuilder({ cdnMode: 'cdn' });
|
|
27
|
+
*
|
|
28
|
+
* // Get loader for tools/list
|
|
29
|
+
* const loader = builder.buildLoader('get_weather');
|
|
30
|
+
*
|
|
31
|
+
* // Build full widget for each tool call
|
|
32
|
+
* const fullHtml = await builder.buildFullWidget(
|
|
33
|
+
* WeatherWidget,
|
|
34
|
+
* { location: 'NYC' },
|
|
35
|
+
* { temperature: 72 }
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class InlineBuilder extends BaseBuilder implements IInlineBuilder {
|
|
40
|
+
readonly mode: "inline";
|
|
41
|
+
constructor(options?: BuilderOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Build an inline result with loader and full widget generator.
|
|
44
|
+
*
|
|
45
|
+
* @param options - Build options
|
|
46
|
+
* @returns Inline build result
|
|
47
|
+
*/
|
|
48
|
+
build<In = unknown, Out = unknown>(options: BuildToolOptions<In, Out>): Promise<InlineBuildResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Build the minimal loader shell.
|
|
51
|
+
*
|
|
52
|
+
* The loader contains:
|
|
53
|
+
* - FrontMCP Bridge runtime
|
|
54
|
+
* - Loading indicator
|
|
55
|
+
* - Injector script that replaces document on tool response
|
|
56
|
+
*
|
|
57
|
+
* @param toolName - Name of the tool
|
|
58
|
+
* @returns Loader HTML
|
|
59
|
+
*/
|
|
60
|
+
buildLoader(toolName: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Build full widget HTML with embedded data.
|
|
63
|
+
*
|
|
64
|
+
* @param template - Component template
|
|
65
|
+
* @param input - Tool input data
|
|
66
|
+
* @param output - Tool output data
|
|
67
|
+
* @returns Complete HTML with all dependencies and data
|
|
68
|
+
*/
|
|
69
|
+
buildFullWidget<In = unknown, Out = unknown>(template: UITemplateConfig<In, Out>['template'], input: In, output: Out): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Build React scripts for client-side rendering.
|
|
72
|
+
*/
|
|
73
|
+
private buildReactScripts;
|
|
74
|
+
/**
|
|
75
|
+
* Build React content with client-side rendering.
|
|
76
|
+
*/
|
|
77
|
+
private buildReactContent;
|
|
78
|
+
/**
|
|
79
|
+
* Simple HTML minification.
|
|
80
|
+
*/
|
|
81
|
+
private minifyHtml;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=inline-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-builder.d.ts","sourceRoot":"","sources":["../../../src/build/builders/inline-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,aAAa,CAAC;AAOvE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,WAAY,YAAW,cAAc;IACtE,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;gBAEtB,OAAO,GAAE,cAAmB;IAIxC;;;;;OAKG;IACG,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACrC,OAAO,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,GACjC,OAAO,CAAC,iBAAiB,CAAC;IAgC7B;;;;;;;;;;OAUG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAuHrC;;;;;;;OAOG;IACG,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EAC/C,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,EAC/C,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,GAAG,GACV,OAAO,CAAC,MAAM,CAAC;IA8DlB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsDzB;;OAEG;IACH,OAAO,CAAC,UAAU;CAMnB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds complete HTML documents with placeholders for data injection.
|
|
5
|
+
* The shell is cached and reused; only data changes per request.
|
|
6
|
+
*
|
|
7
|
+
* Build Phase:
|
|
8
|
+
* - Full HTML with theme, CDN scripts, bridge runtime
|
|
9
|
+
* - Component code (transpiled if React/MDX)
|
|
10
|
+
* - Placeholders for input/output data
|
|
11
|
+
*
|
|
12
|
+
* Preview Phase:
|
|
13
|
+
* - Replace placeholders with actual data
|
|
14
|
+
* - Platform-specific handling (OpenAI, Claude, Generic)
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
import { BaseBuilder } from './base-builder';
|
|
19
|
+
import type { BuilderOptions, BuildToolOptions, StaticBuildResult, IStaticBuilder } from './types';
|
|
20
|
+
/**
|
|
21
|
+
* Static builder for creating cached HTML shells with placeholders.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const builder = new StaticBuilder({ cdnMode: 'cdn' });
|
|
26
|
+
*
|
|
27
|
+
* // Build once (cached)
|
|
28
|
+
* const result = await builder.build({
|
|
29
|
+
* template: WeatherWidget,
|
|
30
|
+
* toolName: 'get_weather',
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Inject data per request (fast)
|
|
34
|
+
* const html = builder.injectData(result.html, input, output);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class StaticBuilder extends BaseBuilder implements IStaticBuilder {
|
|
38
|
+
readonly mode: "static";
|
|
39
|
+
constructor(options?: BuilderOptions);
|
|
40
|
+
/**
|
|
41
|
+
* Build a static HTML shell with placeholders.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Build options
|
|
44
|
+
* @returns Static build result
|
|
45
|
+
*/
|
|
46
|
+
build<In = unknown, Out = unknown>(options: BuildToolOptions<In, Out>): Promise<StaticBuildResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Inject data into a pre-built shell.
|
|
49
|
+
*
|
|
50
|
+
* @param shell - HTML shell with placeholders
|
|
51
|
+
* @param input - Tool input data
|
|
52
|
+
* @param output - Tool output data
|
|
53
|
+
* @returns HTML with data injected
|
|
54
|
+
*/
|
|
55
|
+
injectData(shell: string, input: unknown, output: unknown): string;
|
|
56
|
+
/**
|
|
57
|
+
* Build React rendering shell.
|
|
58
|
+
*
|
|
59
|
+
* Creates a client-side React rendering setup that:
|
|
60
|
+
* 1. Waits for runtime to be ready
|
|
61
|
+
* 2. Loads component code
|
|
62
|
+
* 3. Renders into #root with data from window.__mcpToolOutput
|
|
63
|
+
*/
|
|
64
|
+
private buildReactShell;
|
|
65
|
+
/**
|
|
66
|
+
* Build inline React runtime (for offline mode).
|
|
67
|
+
*/
|
|
68
|
+
private buildInlineReactRuntime;
|
|
69
|
+
/**
|
|
70
|
+
* Get component name from template.
|
|
71
|
+
*/
|
|
72
|
+
private getComponentName;
|
|
73
|
+
/**
|
|
74
|
+
* Simple HTML minification.
|
|
75
|
+
*/
|
|
76
|
+
private minifyHtml;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=static-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-builder.d.ts","sourceRoot":"","sources":["../../../src/build/builders/static-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAC;AASjB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,WAAY,YAAW,cAAc;IACtE,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;gBAEtB,OAAO,GAAE,cAAmB;IAIxC;;;;;OAKG;IACG,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACrC,OAAO,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,GACjC,OAAO,CAAC,iBAAiB,CAAC;IA6F7B;;;;;;;OAOG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM;IAQlE;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IA8EvB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,UAAU;CAMnB"}
|