@frontmcp/ui 0.12.2 → 1.0.0-beta.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/README.md +279 -72
- package/bridge/adapters/claude.adapter.d.ts.map +1 -1
- package/bridge/adapters/gemini.adapter.d.ts.map +1 -1
- package/bridge/index.js +2 -36
- package/components/Alert/Alert.d.ts +11 -0
- package/components/Alert/Alert.d.ts.map +1 -0
- package/components/Alert/index.d.ts +4 -0
- package/components/Alert/index.d.ts.map +1 -0
- package/components/Alert/index.js +61 -0
- package/components/Avatar/Avatar.d.ts +10 -0
- package/components/Avatar/Avatar.d.ts.map +1 -0
- package/components/Avatar/index.d.ts +4 -0
- package/components/Avatar/index.d.ts.map +1 -0
- package/components/Avatar/index.js +43 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.d.ts.map +1 -0
- package/components/Badge/index.d.ts +4 -0
- package/components/Badge/index.d.ts.map +1 -0
- package/{render → components/Badge}/index.js +54 -42
- package/components/Button/Button.d.ts +16 -0
- package/components/Button/Button.d.ts.map +1 -0
- package/components/Button/index.d.ts +4 -0
- package/components/Button/index.d.ts.map +1 -0
- package/components/Button/index.js +91 -0
- package/components/Card/Card.d.ts +25 -0
- package/components/Card/Card.d.ts.map +1 -0
- package/components/Card/index.d.ts +4 -0
- package/components/Card/index.d.ts.map +1 -0
- package/components/Card/index.js +110 -0
- package/components/List/List.d.ts +15 -0
- package/components/List/List.d.ts.map +1 -0
- package/components/List/index.d.ts +4 -0
- package/components/List/index.d.ts.map +1 -0
- package/components/List/index.js +58 -0
- package/components/Loader/Loader.d.ts +28 -0
- package/components/Loader/Loader.d.ts.map +1 -0
- package/components/Loader/LoaderContext.d.ts +20 -0
- package/components/Loader/LoaderContext.d.ts.map +1 -0
- package/components/Loader/index.d.ts +6 -0
- package/components/Loader/index.d.ts.map +1 -0
- package/components/Loader/index.js +174 -0
- package/components/Modal/Modal.d.ts +22 -0
- package/components/Modal/Modal.d.ts.map +1 -0
- package/components/Modal/index.d.ts +4 -0
- package/components/Modal/index.d.ts.map +1 -0
- package/components/Modal/index.js +80 -0
- package/components/Select/Select.d.ts +21 -0
- package/components/Select/Select.d.ts.map +1 -0
- package/components/Select/index.d.ts +4 -0
- package/components/Select/index.d.ts.map +1 -0
- package/components/Select/index.js +78 -0
- package/components/Table/Table.d.ts +15 -0
- package/components/Table/Table.d.ts.map +1 -0
- package/components/Table/index.d.ts +4 -0
- package/components/Table/index.d.ts.map +1 -0
- package/components/Table/index.js +70 -0
- package/components/TextField/TextField.d.ts +19 -0
- package/components/TextField/TextField.d.ts.map +1 -0
- package/components/TextField/index.d.ts +4 -0
- package/components/TextField/index.d.ts.map +1 -0
- package/components/TextField/index.js +77 -0
- package/components/index.d.ts +22 -28
- package/components/index.d.ts.map +1 -1
- package/components/index.js +523 -2521
- package/esm/bridge/index.mjs +2 -6
- package/esm/components/Alert/index.mjs +28 -0
- package/esm/components/Avatar/index.mjs +10 -0
- package/esm/components/Badge/index.mjs +56 -0
- package/esm/components/Button/index.mjs +58 -0
- package/esm/components/Card/index.mjs +77 -0
- package/esm/components/List/index.mjs +25 -0
- package/esm/components/Loader/index.mjs +141 -0
- package/esm/components/Modal/index.mjs +47 -0
- package/esm/components/Select/index.mjs +45 -0
- package/esm/components/Table/index.mjs +37 -0
- package/esm/components/TextField/index.mjs +44 -0
- package/esm/components/index.mjs +513 -2415
- package/esm/index.mjs +62 -4652
- package/esm/package.json +372 -16
- package/esm/react/index.mjs +2 -285
- package/esm/renderer/charts/index.mjs +336 -0
- package/esm/renderer/common/index.mjs +135 -0
- package/esm/renderer/csv/index.mjs +193 -0
- package/esm/renderer/flow/index.mjs +259 -0
- package/esm/renderer/html/index.mjs +99 -0
- package/esm/renderer/image/index.mjs +125 -0
- package/esm/renderer/index.mjs +2173 -0
- package/esm/renderer/maps/index.mjs +217 -0
- package/esm/renderer/math/index.mjs +229 -0
- package/esm/renderer/mdx/index.mjs +261 -0
- package/esm/renderer/media/index.mjs +235 -0
- package/esm/renderer/mermaid/index.mjs +220 -0
- package/esm/renderer/pdf/index.mjs +229 -0
- package/esm/renderer/react/index.mjs +230 -0
- package/esm/runtime/index.mjs +194 -0
- package/esm/theme/index.mjs +93 -0
- package/index.d.ts +10 -18
- package/index.d.ts.map +1 -1
- package/index.js +63 -4806
- package/package.json +372 -16
- package/react/index.d.ts +8 -54
- package/react/index.d.ts.map +1 -1
- package/react/index.js +2 -295
- package/renderer/auto-detect.d.ts +39 -0
- package/renderer/auto-detect.d.ts.map +1 -0
- package/renderer/charts/index.d.ts +22 -0
- package/renderer/charts/index.d.ts.map +1 -0
- package/renderer/charts/index.js +367 -0
- package/renderer/common/index.d.ts +5 -0
- package/renderer/common/index.d.ts.map +1 -0
- package/renderer/common/index.js +158 -0
- package/renderer/common/inject-stylesheet.d.ts +9 -0
- package/renderer/common/inject-stylesheet.d.ts.map +1 -0
- package/renderer/common/lazy-import.d.ts +85 -0
- package/renderer/common/lazy-import.d.ts.map +1 -0
- package/renderer/common/use-lazy-module.d.ts +13 -0
- package/renderer/common/use-lazy-module.d.ts.map +1 -0
- package/renderer/common/use-renderer-theme.d.ts +35 -0
- package/renderer/common/use-renderer-theme.d.ts.map +1 -0
- package/renderer/csv/index.d.ts +12 -0
- package/renderer/csv/index.d.ts.map +1 -0
- package/renderer/csv/index.js +224 -0
- package/renderer/flow/index.d.ts +40 -0
- package/renderer/flow/index.d.ts.map +1 -0
- package/renderer/flow/index.js +290 -0
- package/renderer/html/index.d.ts +12 -0
- package/renderer/html/index.d.ts.map +1 -0
- package/renderer/html/index.js +130 -0
- package/renderer/image/index.d.ts +11 -0
- package/renderer/image/index.d.ts.map +1 -0
- package/renderer/image/index.js +156 -0
- package/renderer/index.d.ts +32 -0
- package/renderer/index.d.ts.map +1 -0
- package/renderer/index.js +2206 -0
- package/renderer/maps/index.d.ts +27 -0
- package/renderer/maps/index.d.ts.map +1 -0
- package/renderer/maps/index.js +248 -0
- package/renderer/math/index.d.ts +11 -0
- package/renderer/math/index.d.ts.map +1 -0
- package/renderer/math/index.js +260 -0
- package/renderer/mdx/index.d.ts +10 -0
- package/renderer/mdx/index.d.ts.map +1 -0
- package/renderer/mdx/index.js +292 -0
- package/renderer/media/index.d.ts +20 -0
- package/renderer/media/index.d.ts.map +1 -0
- package/renderer/media/index.js +266 -0
- package/renderer/mermaid/index.d.ts +11 -0
- package/renderer/mermaid/index.d.ts.map +1 -0
- package/renderer/mermaid/index.js +251 -0
- package/renderer/pdf/index.d.ts +10 -0
- package/renderer/pdf/index.d.ts.map +1 -0
- package/renderer/pdf/index.js +260 -0
- package/renderer/react/index.d.ts +45 -0
- package/renderer/react/index.d.ts.map +1 -0
- package/renderer/react/index.js +261 -0
- package/renderer/types.d.ts +24 -0
- package/renderer/types.d.ts.map +1 -0
- package/runtime/babel-runtime.d.ts +70 -0
- package/runtime/babel-runtime.d.ts.map +1 -0
- package/runtime/content-detector.d.ts +43 -0
- package/runtime/content-detector.d.ts.map +1 -0
- package/runtime/index.d.ts +10 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +217 -0
- package/theme/FrontMcpThemeProvider.d.ts +4 -0
- package/theme/FrontMcpThemeProvider.d.ts.map +1 -0
- package/theme/create-theme.d.ts +9 -0
- package/theme/create-theme.d.ts.map +1 -0
- package/theme/index.d.ts +5 -0
- package/theme/index.d.ts.map +1 -0
- package/theme/index.js +126 -0
- package/theme/types.d.ts +28 -0
- package/theme/types.d.ts.map +1 -0
- package/theme/use-theme.d.ts +3 -0
- package/theme/use-theme.d.ts.map +1 -0
- package/bundler/browser-components.d.ts +0 -42
- package/bundler/browser-components.d.ts.map +0 -1
- package/bundler/bundler.d.ts +0 -282
- package/bundler/bundler.d.ts.map +0 -1
- package/bundler/index.d.ts +0 -43
- package/bundler/index.d.ts.map +0 -1
- package/bundler/index.js +0 -3168
- package/bundler/types.d.ts +0 -883
- package/bundler/types.d.ts.map +0 -1
- package/components/alert.d.ts +0 -83
- package/components/alert.d.ts.map +0 -1
- package/components/alert.schema.d.ts +0 -98
- package/components/alert.schema.d.ts.map +0 -1
- package/components/avatar.d.ts +0 -77
- package/components/avatar.d.ts.map +0 -1
- package/components/avatar.schema.d.ts +0 -170
- package/components/avatar.schema.d.ts.map +0 -1
- package/components/badge.d.ts +0 -78
- package/components/badge.d.ts.map +0 -1
- package/components/badge.schema.d.ts +0 -91
- package/components/badge.schema.d.ts.map +0 -1
- package/components/button.d.ts +0 -100
- package/components/button.d.ts.map +0 -1
- package/components/button.schema.d.ts +0 -120
- package/components/button.schema.d.ts.map +0 -1
- package/components/card.d.ts +0 -76
- package/components/card.d.ts.map +0 -1
- package/components/card.schema.d.ts +0 -93
- package/components/card.schema.d.ts.map +0 -1
- package/components/form.d.ts +0 -227
- package/components/form.d.ts.map +0 -1
- package/components/form.schema.d.ts +0 -365
- package/components/form.schema.d.ts.map +0 -1
- package/components/list.d.ts +0 -121
- package/components/list.d.ts.map +0 -1
- package/components/list.schema.d.ts +0 -129
- package/components/list.schema.d.ts.map +0 -1
- package/components/modal.d.ts +0 -100
- package/components/modal.d.ts.map +0 -1
- package/components/modal.schema.d.ts +0 -151
- package/components/modal.schema.d.ts.map +0 -1
- package/components/table.d.ts +0 -91
- package/components/table.d.ts.map +0 -1
- package/components/table.schema.d.ts +0 -123
- package/components/table.schema.d.ts.map +0 -1
- package/esm/bundler/index.mjs +0 -3136
- package/esm/layouts/index.mjs +0 -409
- package/esm/render/index.mjs +0 -45
- package/esm/renderers/index.mjs +0 -621
- package/esm/universal/index.mjs +0 -1946
- package/esm/web-components/index.mjs +0 -2023
- package/layouts/base.d.ts +0 -86
- package/layouts/base.d.ts.map +0 -1
- package/layouts/index.d.ts +0 -8
- package/layouts/index.d.ts.map +0 -1
- package/layouts/index.js +0 -437
- package/layouts/presets.d.ts +0 -134
- package/layouts/presets.d.ts.map +0 -1
- package/react/Alert.d.ts +0 -101
- package/react/Alert.d.ts.map +0 -1
- package/react/Badge.d.ts +0 -100
- package/react/Badge.d.ts.map +0 -1
- package/react/Button.d.ts +0 -108
- package/react/Button.d.ts.map +0 -1
- package/react/Card.d.ts +0 -103
- package/react/Card.d.ts.map +0 -1
- package/react/types.d.ts +0 -105
- package/react/types.d.ts.map +0 -1
- package/render/index.d.ts +0 -8
- package/render/index.d.ts.map +0 -1
- package/render/prerender.d.ts +0 -57
- package/render/prerender.d.ts.map +0 -1
- package/renderers/index.d.ts +0 -26
- package/renderers/index.d.ts.map +0 -1
- package/renderers/index.js +0 -666
- package/renderers/mdx.renderer.d.ts +0 -99
- package/renderers/mdx.renderer.d.ts.map +0 -1
- package/renderers/react.adapter.d.ts +0 -70
- package/renderers/react.adapter.d.ts.map +0 -1
- package/renderers/react.renderer.d.ts +0 -105
- package/renderers/react.renderer.d.ts.map +0 -1
- package/renderers/transpiler.d.ts +0 -49
- package/renderers/transpiler.d.ts.map +0 -1
- package/universal/UniversalApp.d.ts +0 -108
- package/universal/UniversalApp.d.ts.map +0 -1
- package/universal/cached-runtime.d.ts +0 -139
- package/universal/cached-runtime.d.ts.map +0 -1
- package/universal/context.d.ts +0 -122
- package/universal/context.d.ts.map +0 -1
- package/universal/index.d.ts +0 -57
- package/universal/index.d.ts.map +0 -1
- package/universal/index.js +0 -2032
- package/universal/renderers/html.renderer.d.ts +0 -36
- package/universal/renderers/html.renderer.d.ts.map +0 -1
- package/universal/renderers/index.d.ts +0 -112
- package/universal/renderers/index.d.ts.map +0 -1
- package/universal/renderers/markdown.renderer.d.ts +0 -33
- package/universal/renderers/markdown.renderer.d.ts.map +0 -1
- package/universal/renderers/mdx.renderer.d.ts +0 -38
- package/universal/renderers/mdx.renderer.d.ts.map +0 -1
- package/universal/renderers/react.renderer.d.ts +0 -46
- package/universal/renderers/react.renderer.d.ts.map +0 -1
- package/universal/runtime-builder.d.ts +0 -33
- package/universal/runtime-builder.d.ts.map +0 -1
- package/universal/store.d.ts +0 -135
- package/universal/store.d.ts.map +0 -1
- package/universal/types.d.ts +0 -199
- package/universal/types.d.ts.map +0 -1
- package/web-components/core/attribute-parser.d.ts +0 -82
- package/web-components/core/attribute-parser.d.ts.map +0 -1
- package/web-components/core/base-element.d.ts +0 -197
- package/web-components/core/base-element.d.ts.map +0 -1
- package/web-components/core/index.d.ts +0 -9
- package/web-components/core/index.d.ts.map +0 -1
- package/web-components/elements/fmcp-alert.d.ts +0 -46
- package/web-components/elements/fmcp-alert.d.ts.map +0 -1
- package/web-components/elements/fmcp-badge.d.ts +0 -47
- package/web-components/elements/fmcp-badge.d.ts.map +0 -1
- package/web-components/elements/fmcp-button.d.ts +0 -117
- package/web-components/elements/fmcp-button.d.ts.map +0 -1
- package/web-components/elements/fmcp-card.d.ts +0 -53
- package/web-components/elements/fmcp-card.d.ts.map +0 -1
- package/web-components/elements/fmcp-input.d.ts +0 -96
- package/web-components/elements/fmcp-input.d.ts.map +0 -1
- package/web-components/elements/fmcp-select.d.ts +0 -100
- package/web-components/elements/fmcp-select.d.ts.map +0 -1
- package/web-components/elements/index.d.ts +0 -13
- package/web-components/elements/index.d.ts.map +0 -1
- package/web-components/index.d.ts +0 -49
- package/web-components/index.d.ts.map +0 -1
- package/web-components/index.js +0 -2058
- package/web-components/register.d.ts +0 -57
- package/web-components/register.d.ts.map +0 -1
- package/web-components/types.d.ts +0 -122
- package/web-components/types.d.ts.map +0 -1
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MDX Server Renderer
|
|
3
|
-
*
|
|
4
|
-
* Handles MDX templates - Markdown with embedded JSX components.
|
|
5
|
-
* Uses @mdx-js/mdx for compilation and react-dom/server for SSR.
|
|
6
|
-
*
|
|
7
|
-
* This renderer requires React as a peer dependency.
|
|
8
|
-
* For React-free client-side MDX rendering, use MdxClientRenderer from @frontmcp/uipack.
|
|
9
|
-
*
|
|
10
|
-
* MDX allows mixing Markdown with React components:
|
|
11
|
-
* - Markdown headings, lists, code blocks
|
|
12
|
-
* - JSX component tags: `<Card />`
|
|
13
|
-
* - JS expressions: `{output.items.map(...)}`
|
|
14
|
-
* - Frontmatter for metadata
|
|
15
|
-
*
|
|
16
|
-
* @module @frontmcp/ui/renderers
|
|
17
|
-
*/
|
|
18
|
-
import type { TemplateContext } from '@frontmcp/uipack/runtime';
|
|
19
|
-
import type { PlatformCapabilities } from '@frontmcp/uipack/theme';
|
|
20
|
-
import type { UIRenderer, TranspileResult, TranspileOptions, RenderOptions, RuntimeScripts } from '@frontmcp/uipack/renderers';
|
|
21
|
-
/**
|
|
22
|
-
* Types this renderer can handle - MDX strings.
|
|
23
|
-
*/
|
|
24
|
-
type MdxTemplate = string;
|
|
25
|
-
/**
|
|
26
|
-
* MDX Server Renderer Implementation.
|
|
27
|
-
*
|
|
28
|
-
* Compiles MDX (Markdown + JSX) to React components using @mdx-js/mdx,
|
|
29
|
-
* then renders to HTML using react-dom/server.
|
|
30
|
-
*
|
|
31
|
-
* @example Basic MDX template
|
|
32
|
-
* ```typescript
|
|
33
|
-
* @Tool({
|
|
34
|
-
* ui: {
|
|
35
|
-
* template: `
|
|
36
|
-
* # User Profile
|
|
37
|
-
*
|
|
38
|
-
* <UserCard name={output.name} email={output.email} />
|
|
39
|
-
*
|
|
40
|
-
* ## Recent Activity
|
|
41
|
-
* {output.items.map(item => <ActivityItem key={item.id} {...item} />)}
|
|
42
|
-
* `,
|
|
43
|
-
* mdxComponents: { UserCard, ActivityItem }
|
|
44
|
-
* }
|
|
45
|
-
* })
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class MdxRenderer implements UIRenderer<MdxTemplate> {
|
|
49
|
-
readonly type: "mdx";
|
|
50
|
-
readonly priority = 10;
|
|
51
|
-
/**
|
|
52
|
-
* Lazy-loaded modules.
|
|
53
|
-
*/
|
|
54
|
-
private React;
|
|
55
|
-
private ReactDOMServer;
|
|
56
|
-
private jsxRuntime;
|
|
57
|
-
private mdxEvaluate;
|
|
58
|
-
/**
|
|
59
|
-
* Check if this renderer can handle the given template.
|
|
60
|
-
*
|
|
61
|
-
* Accepts strings containing MDX syntax (Markdown + JSX).
|
|
62
|
-
*/
|
|
63
|
-
canHandle(template: unknown): template is MdxTemplate;
|
|
64
|
-
/**
|
|
65
|
-
* Prepare MDX template for rendering.
|
|
66
|
-
* Caches the template hash for deduplication. Actual MDX compilation
|
|
67
|
-
* happens during render() via @mdx-js/mdx evaluate().
|
|
68
|
-
*/
|
|
69
|
-
transpile(template: MdxTemplate, _options?: TranspileOptions): Promise<TranspileResult>;
|
|
70
|
-
/**
|
|
71
|
-
* Render MDX template to HTML string.
|
|
72
|
-
*
|
|
73
|
-
* Uses @mdx-js/mdx's evaluate() for clean compilation + execution,
|
|
74
|
-
* then renders the resulting React component to HTML via SSR.
|
|
75
|
-
*/
|
|
76
|
-
render<In, Out>(template: MdxTemplate, context: TemplateContext<In, Out>, options?: RenderOptions): Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* Get runtime scripts for client-side functionality.
|
|
79
|
-
*/
|
|
80
|
-
getRuntimeScripts(platform: PlatformCapabilities): RuntimeScripts;
|
|
81
|
-
/**
|
|
82
|
-
* Load React and ReactDOMServer modules.
|
|
83
|
-
*/
|
|
84
|
-
private loadReact;
|
|
85
|
-
/**
|
|
86
|
-
* Load @mdx-js/mdx evaluate function.
|
|
87
|
-
*/
|
|
88
|
-
private loadMdx;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Singleton instance of the MDX renderer.
|
|
92
|
-
*/
|
|
93
|
-
export declare const mdxRenderer: MdxRenderer;
|
|
94
|
-
/**
|
|
95
|
-
* Build MDX hydration script for client-side interactivity.
|
|
96
|
-
*/
|
|
97
|
-
export declare function buildMdxHydrationScript(): string;
|
|
98
|
-
export {};
|
|
99
|
-
//# sourceMappingURL=mdx.renderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.renderer.d.ts","sourceRoot":"","sources":["../../src/renderers/mdx.renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Renderer Adapter
|
|
3
|
-
*
|
|
4
|
-
* Client-side adapter for rendering React components.
|
|
5
|
-
* Handles hydration, client-side rendering, and updates.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
import type { RendererAdapter, RenderContext, RenderOptions, RenderResult } from '@frontmcp/uipack/runtime';
|
|
10
|
-
import type { UIType } from '@frontmcp/uipack/types';
|
|
11
|
-
/**
|
|
12
|
-
* React Renderer Adapter.
|
|
13
|
-
*
|
|
14
|
-
* Renders React components to the DOM with support for:
|
|
15
|
-
* - Server-side rendering (SSR)
|
|
16
|
-
* - Client-side hydration
|
|
17
|
-
* - Dynamic updates when data changes
|
|
18
|
-
*/
|
|
19
|
-
export declare class ReactRendererAdapter implements RendererAdapter {
|
|
20
|
-
readonly type: UIType;
|
|
21
|
-
private react;
|
|
22
|
-
private reactDOM;
|
|
23
|
-
private loadPromise;
|
|
24
|
-
/**
|
|
25
|
-
* Check if this adapter can handle the given content.
|
|
26
|
-
*/
|
|
27
|
-
canHandle(content: string | unknown): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Render React component to a string.
|
|
30
|
-
* This is a client-side fallback - SSR should be done at build time.
|
|
31
|
-
*/
|
|
32
|
-
render(content: string, context: RenderContext, _options?: RenderOptions): Promise<string>;
|
|
33
|
-
/**
|
|
34
|
-
* Render React component directly to the DOM.
|
|
35
|
-
*/
|
|
36
|
-
renderToDOM(content: string, target: HTMLElement, context: RenderContext, options?: RenderOptions): Promise<RenderResult>;
|
|
37
|
-
/**
|
|
38
|
-
* Hydrate existing SSR content with React.
|
|
39
|
-
*/
|
|
40
|
-
hydrate(target: HTMLElement, context: RenderContext, options?: RenderOptions): Promise<RenderResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Update rendered React component with new data.
|
|
43
|
-
*/
|
|
44
|
-
update(target: HTMLElement, context: RenderContext): Promise<RenderResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Clean up React root.
|
|
47
|
-
*/
|
|
48
|
-
destroy(target: HTMLElement): void;
|
|
49
|
-
/**
|
|
50
|
-
* Ensure React is loaded.
|
|
51
|
-
*/
|
|
52
|
-
private ensureReactLoaded;
|
|
53
|
-
/**
|
|
54
|
-
* Load React runtime.
|
|
55
|
-
*/
|
|
56
|
-
private loadReact;
|
|
57
|
-
/**
|
|
58
|
-
* Get a React component by name or from content.
|
|
59
|
-
*/
|
|
60
|
-
private getComponent;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create a new React renderer adapter.
|
|
64
|
-
*/
|
|
65
|
-
export declare function createReactAdapter(): ReactRendererAdapter;
|
|
66
|
-
/**
|
|
67
|
-
* Adapter loader for lazy loading.
|
|
68
|
-
*/
|
|
69
|
-
export declare function loadReactAdapter(): Promise<RendererAdapter>;
|
|
70
|
-
//# sourceMappingURL=react.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.adapter.d.ts","sourceRoot":"","sources":["../../src/renderers/react.adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAsDrD;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAW;IAGhC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,WAAW,CAA8B;IAEjD;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO;IAiC7C;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhG;;OAEG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC;IA4DxB;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAI1G;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAsChF;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAQlC;;OAEG;YACW,iBAAiB;IAa/B;;OAEG;YACW,SAAS;IAmCvB;;OAEG;IACH,OAAO,CAAC,YAAY;CAsBrB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,oBAAoB,CAEzD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,eAAe,CAAC,CAEjE"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Renderer
|
|
3
|
-
*
|
|
4
|
-
* Handles React component templates:
|
|
5
|
-
* - Imported React components (already transpiled)
|
|
6
|
-
* - JSX string templates (transpiled at runtime with SWC)
|
|
7
|
-
*
|
|
8
|
-
* Generates HTML for CLIENT-SIDE rendering (no SSR).
|
|
9
|
-
* React components are rendered in the browser, not on the server.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // The generated HTML includes React CDN scripts and a render script
|
|
14
|
-
* // The component is rendered client-side when the page loads
|
|
15
|
-
* const html = await reactRenderer.render(MyWidget, context);
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
import type { TemplateContext } from '@frontmcp/uipack/runtime';
|
|
19
|
-
import type { PlatformCapabilities } from '@frontmcp/uipack/theme';
|
|
20
|
-
import type { UIRenderer, TranspileResult, TranspileOptions, RenderOptions, RuntimeScripts, ToolUIProps } from '@frontmcp/uipack/renderers';
|
|
21
|
-
/**
|
|
22
|
-
* Types this renderer can handle.
|
|
23
|
-
*/
|
|
24
|
-
type ReactTemplate<In = unknown, Out = unknown> = ((props: ToolUIProps<In, Out>) => unknown) | string;
|
|
25
|
-
/**
|
|
26
|
-
* React Renderer Implementation.
|
|
27
|
-
*
|
|
28
|
-
* Handles:
|
|
29
|
-
* - Imported React components (FC or class)
|
|
30
|
-
* - JSX string templates (transpiled with SWC at runtime)
|
|
31
|
-
*
|
|
32
|
-
* Generates HTML for CLIENT-SIDE rendering. The component is rendered
|
|
33
|
-
* in the browser using React from CDN, not server-side rendered.
|
|
34
|
-
*
|
|
35
|
-
* @example Imported component
|
|
36
|
-
* ```typescript
|
|
37
|
-
* import { MyWidget } from './my-widget.tsx';
|
|
38
|
-
*
|
|
39
|
-
* @Tool({
|
|
40
|
-
* ui: { template: MyWidget }
|
|
41
|
-
* })
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @example JSX string (runtime transpilation)
|
|
45
|
-
* ```typescript
|
|
46
|
-
* @Tool({
|
|
47
|
-
* ui: {
|
|
48
|
-
* template: `
|
|
49
|
-
* function Widget({ output }) {
|
|
50
|
-
* return <div>{output.name}</div>;
|
|
51
|
-
* }
|
|
52
|
-
* `
|
|
53
|
-
* }
|
|
54
|
-
* })
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare class ReactRenderer implements UIRenderer<ReactTemplate> {
|
|
58
|
-
readonly type: "react";
|
|
59
|
-
readonly priority = 20;
|
|
60
|
-
/**
|
|
61
|
-
* Check if this renderer can handle the given template.
|
|
62
|
-
*
|
|
63
|
-
* Accepts:
|
|
64
|
-
* - React component functions (imported, already transpiled)
|
|
65
|
-
* - Strings containing JSX syntax
|
|
66
|
-
*/
|
|
67
|
-
canHandle(template: unknown): template is ReactTemplate;
|
|
68
|
-
/**
|
|
69
|
-
* Transpile the template if needed.
|
|
70
|
-
*
|
|
71
|
-
* For imported React components, no transpilation is needed.
|
|
72
|
-
* For JSX strings, SWC transpilation is performed.
|
|
73
|
-
*/
|
|
74
|
-
transpile(template: ReactTemplate, options?: TranspileOptions): Promise<TranspileResult>;
|
|
75
|
-
/**
|
|
76
|
-
* Render the template to HTML for client-side rendering.
|
|
77
|
-
*
|
|
78
|
-
* Unlike SSR, this method generates HTML that will be rendered
|
|
79
|
-
* client-side by React in the browser. No server-side React required.
|
|
80
|
-
*
|
|
81
|
-
* The generated HTML includes:
|
|
82
|
-
* - A container div for the React root
|
|
83
|
-
* - The component code (transpiled if needed)
|
|
84
|
-
* - Props embedded as a data attribute
|
|
85
|
-
* - A render script that initializes the component
|
|
86
|
-
*/
|
|
87
|
-
render<In, Out>(template: ReactTemplate<In, Out>, context: TemplateContext<In, Out>, _options?: RenderOptions): Promise<string>;
|
|
88
|
-
/**
|
|
89
|
-
* Get runtime scripts for client-side functionality.
|
|
90
|
-
*/
|
|
91
|
-
getRuntimeScripts(platform: PlatformCapabilities): RuntimeScripts;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Singleton instance of the React renderer.
|
|
95
|
-
*/
|
|
96
|
-
export declare const reactRenderer: ReactRenderer;
|
|
97
|
-
/**
|
|
98
|
-
* Build React hydration script for client-side interactivity.
|
|
99
|
-
*
|
|
100
|
-
* This script finds elements with data-hydrate attributes and
|
|
101
|
-
* hydrates them with the corresponding React component.
|
|
102
|
-
*/
|
|
103
|
-
export declare function buildHydrationScript(): string;
|
|
104
|
-
export {};
|
|
105
|
-
//# sourceMappingURL=react.renderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.renderer.d.ts","sourceRoot":"","sources":["../../src/renderers/react.renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,K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/**
|
|
2
|
-
* JSX Execution Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides React-dependent code execution for transpiled JSX.
|
|
5
|
-
* Uses React runtime for component evaluation.
|
|
6
|
-
*
|
|
7
|
-
* For transpilation without React, use transpileJsx from @frontmcp/uipack.
|
|
8
|
-
*
|
|
9
|
-
* @module @frontmcp/ui/renderers
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Execute transpiled JavaScript code and extract the component.
|
|
13
|
-
*
|
|
14
|
-
* Creates a sandboxed environment with React available,
|
|
15
|
-
* executes the code, and returns the exported component.
|
|
16
|
-
*
|
|
17
|
-
* @param code - Transpiled JavaScript code
|
|
18
|
-
* @param context - Additional context to inject
|
|
19
|
-
* @returns The exported component or default export
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const code = `
|
|
24
|
-
* "use strict";
|
|
25
|
-
* Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
* const jsx_runtime = require("react/jsx-runtime");
|
|
27
|
-
* function Widget(props) {
|
|
28
|
-
* return jsx_runtime.jsx("div", { children: props.output.name });
|
|
29
|
-
* }
|
|
30
|
-
* exports.default = Widget;
|
|
31
|
-
* `;
|
|
32
|
-
*
|
|
33
|
-
* const Component = await executeTranspiledCode(code);
|
|
34
|
-
* // Component is now a usable React component function
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function executeTranspiledCode(code: string, context?: Record<string, any>): Promise<any>;
|
|
38
|
-
/**
|
|
39
|
-
* Transpile and execute a JSX string, returning the component.
|
|
40
|
-
*
|
|
41
|
-
* Convenience function that combines transpileJsx and executeTranspiledCode.
|
|
42
|
-
* Requires React to be installed.
|
|
43
|
-
*
|
|
44
|
-
* @param source - JSX/TSX source code
|
|
45
|
-
* @param context - Additional context for execution
|
|
46
|
-
* @returns The component function
|
|
47
|
-
*/
|
|
48
|
-
export declare function transpileAndExecute(source: string, context?: Record<string, any>): Promise<any>;
|
|
49
|
-
//# sourceMappingURL=transpiler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../src/renderers/transpiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EAEZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAEhC,OAAO,CAAC,GAAG,CAAC,CAmDd;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EAEd,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAEhC,OAAO,CAAC,GAAG,CAAC,CAGd"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal App Component
|
|
3
|
-
*
|
|
4
|
-
* Main entry point for the universal renderer.
|
|
5
|
-
* Handles loading states, error boundaries, and auto-detection.
|
|
6
|
-
*/
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import type { UniversalAppProps, FrontMCPState } from './types';
|
|
9
|
-
/**
|
|
10
|
-
* Default loading spinner component.
|
|
11
|
-
*/
|
|
12
|
-
declare function LoadingSpinner(): React.ReactElement;
|
|
13
|
-
/**
|
|
14
|
-
* Default error display component.
|
|
15
|
-
*/
|
|
16
|
-
declare function ErrorDisplay({ error }: {
|
|
17
|
-
error: string;
|
|
18
|
-
}): React.ReactElement;
|
|
19
|
-
/**
|
|
20
|
-
* Default empty state component.
|
|
21
|
-
*/
|
|
22
|
-
declare function EmptyState(): React.ReactElement;
|
|
23
|
-
/**
|
|
24
|
-
* Universal App component.
|
|
25
|
-
*
|
|
26
|
-
* Main entry point for the universal renderer. Handles:
|
|
27
|
-
* - Loading states
|
|
28
|
-
* - Error display
|
|
29
|
-
* - Content auto-detection
|
|
30
|
-
* - Custom component injection
|
|
31
|
-
*
|
|
32
|
-
* @example Basic usage
|
|
33
|
-
* ```tsx
|
|
34
|
-
* function App() {
|
|
35
|
-
* return (
|
|
36
|
-
* <FrontMCPProvider>
|
|
37
|
-
* <UniversalApp />
|
|
38
|
-
* </FrontMCPProvider>
|
|
39
|
-
* );
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @example With custom content
|
|
44
|
-
* ```tsx
|
|
45
|
-
* const content: UniversalContent = {
|
|
46
|
-
* type: 'markdown',
|
|
47
|
-
* source: '# Hello World',
|
|
48
|
-
* };
|
|
49
|
-
*
|
|
50
|
-
* function App() {
|
|
51
|
-
* return (
|
|
52
|
-
* <FrontMCPProvider>
|
|
53
|
-
* <UniversalApp content={content} />
|
|
54
|
-
* </FrontMCPProvider>
|
|
55
|
-
* );
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example With custom components
|
|
60
|
-
* ```tsx
|
|
61
|
-
* const components = {
|
|
62
|
-
* WeatherCard: ({ temp }) => <div>{temp}°F</div>,
|
|
63
|
-
* };
|
|
64
|
-
*
|
|
65
|
-
* function App() {
|
|
66
|
-
* return (
|
|
67
|
-
* <FrontMCPProvider>
|
|
68
|
-
* <UniversalApp components={components} />
|
|
69
|
-
* </FrontMCPProvider>
|
|
70
|
-
* );
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function UniversalApp({ content: contentOverride, components, fallback, errorFallback: ErrorFallback, }: UniversalAppProps): React.ReactElement;
|
|
75
|
-
/**
|
|
76
|
-
* Props for the standalone UniversalAppWithProvider.
|
|
77
|
-
*/
|
|
78
|
-
interface StandaloneAppProps extends UniversalAppProps {
|
|
79
|
-
/** Initial store state */
|
|
80
|
-
initialState?: Partial<FrontMCPState>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Standalone Universal App with built-in provider.
|
|
84
|
-
*
|
|
85
|
-
* Use this when you need a self-contained universal renderer
|
|
86
|
-
* without manually setting up the provider.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```tsx
|
|
90
|
-
* function App() {
|
|
91
|
-
* return (
|
|
92
|
-
* <UniversalAppWithProvider
|
|
93
|
-
* initialState={{
|
|
94
|
-
* toolName: 'get_weather',
|
|
95
|
-
* output: { temperature: 72 },
|
|
96
|
-
* }}
|
|
97
|
-
* content={{
|
|
98
|
-
* type: 'markdown',
|
|
99
|
-
* source: '# Weather: {output.temperature}°F',
|
|
100
|
-
* }}
|
|
101
|
-
* />
|
|
102
|
-
* );
|
|
103
|
-
* }
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
export declare function UniversalAppWithProvider({ initialState, components, ...appProps }: StandaloneAppProps): React.ReactElement;
|
|
107
|
-
export { LoadingSpinner, ErrorDisplay, EmptyState };
|
|
108
|
-
//# sourceMappingURL=UniversalApp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalApp.d.ts","sourceRoot":"","sources":["../../src/universal/UniversalApp.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAmC,aAAa,EAAE,MAAM,SAAS,CAAC;AAUjG;;GAEG;AACH,iBAAS,cAAc,IAAI,KAAK,CAAC,YAAY,CAQ5C;AAMD;;GAEG;AACH,iBAAS,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAWtE;AAMD;;GAEG;AACH,iBAAS,UAAU,IAAI,KAAK,CAAC,YAAY,CAQxC;AAuCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EAAE,eAAe,EACxB,UAAU,EACV,QAAQ,EACR,aAAa,EAAE,aAA4B,GAC5C,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CA+BxC;AAMD;;GAEG;AACH,UAAU,kBAAmB,SAAQ,iBAAiB;IACpD,0BAA0B;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,YAAY,EACZ,UAAU,EACV,GAAG,QAAQ,EACZ,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAQzC;AAMD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cached Runtime Builder
|
|
3
|
-
*
|
|
4
|
-
* Optimizes bundling by pre-building and caching the static runtime code.
|
|
5
|
-
* Separates "vendor" (static runtime) from "app" (user component) chunks.
|
|
6
|
-
*
|
|
7
|
-
* Benefits:
|
|
8
|
-
* - Runtime is built once and cached globally
|
|
9
|
-
* - Only user components need transpilation per request
|
|
10
|
-
* - Significantly reduces build time for repeated builds
|
|
11
|
-
*/
|
|
12
|
-
import type { CDNType, ContentSecurityOptions } from './types';
|
|
13
|
-
/**
|
|
14
|
-
* Runtime cache configuration.
|
|
15
|
-
*/
|
|
16
|
-
interface RuntimeCacheConfig {
|
|
17
|
-
/** Maximum cache entries */
|
|
18
|
-
maxEntries?: number;
|
|
19
|
-
/** TTL in milliseconds (0 = forever) */
|
|
20
|
-
ttl?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Placeholders for dynamic content injection.
|
|
24
|
-
* These are replaced at build time with actual content.
|
|
25
|
-
*/
|
|
26
|
-
export declare const RUNTIME_PLACEHOLDERS: {
|
|
27
|
-
/** Placeholder for transpiled component code */
|
|
28
|
-
readonly COMPONENT_CODE: "/*__FRONTMCP_COMPONENT_CODE__*/";
|
|
29
|
-
/** Placeholder for data injection */
|
|
30
|
-
readonly DATA_INJECTION: "/*__FRONTMCP_DATA_INJECTION__*/";
|
|
31
|
-
/** Placeholder for custom components */
|
|
32
|
-
readonly CUSTOM_COMPONENTS: "/*__FRONTMCP_CUSTOM_COMPONENTS__*/";
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Options for cached runtime.
|
|
36
|
-
*/
|
|
37
|
-
export interface CachedRuntimeOptions {
|
|
38
|
-
/** CDN type (esm or umd) */
|
|
39
|
-
cdnType: CDNType;
|
|
40
|
-
/** Include markdown renderer */
|
|
41
|
-
includeMarkdown?: boolean;
|
|
42
|
-
/** Include MDX renderer */
|
|
43
|
-
includeMdx?: boolean;
|
|
44
|
-
/** Minify output */
|
|
45
|
-
minify?: boolean;
|
|
46
|
-
/** Content security / XSS protection options */
|
|
47
|
-
contentSecurity?: ContentSecurityOptions;
|
|
48
|
-
/**
|
|
49
|
-
* Include MCP Bridge runtime for platform data detection.
|
|
50
|
-
* When true, includes the MCP Bridge which:
|
|
51
|
-
* - Detects data from window.openai.toolOutput (OpenAI Apps SDK)
|
|
52
|
-
* - Creates window.mcpBridge with unified API
|
|
53
|
-
* - Provides window.openai polyfill for non-OpenAI platforms
|
|
54
|
-
* Defaults to true for dynamic/hybrid modes, false for static.
|
|
55
|
-
*/
|
|
56
|
-
includeBridge?: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Result from getting cached runtime.
|
|
60
|
-
*/
|
|
61
|
-
export interface CachedRuntimeResult {
|
|
62
|
-
/** Pre-built vendor script (static runtime) */
|
|
63
|
-
vendorScript: string;
|
|
64
|
-
/** Template for app script (with placeholders) */
|
|
65
|
-
appTemplate: string;
|
|
66
|
-
/** CDN imports for head */
|
|
67
|
-
cdnImports: string;
|
|
68
|
-
/** Total size of vendor script */
|
|
69
|
-
vendorSize: number;
|
|
70
|
-
/** Whether this was from cache */
|
|
71
|
-
cached: boolean;
|
|
72
|
-
/** Cache key used */
|
|
73
|
-
cacheKey: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get or build cached runtime.
|
|
77
|
-
*
|
|
78
|
-
* @param options - Runtime options
|
|
79
|
-
* @param config - Cache configuration
|
|
80
|
-
* @returns Cached runtime result
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* const runtime = getCachedRuntime({ cdnType: 'umd', includeMarkdown: true });
|
|
85
|
-
*
|
|
86
|
-
* // Replace placeholders with actual content
|
|
87
|
-
* const appScript = runtime.appTemplate
|
|
88
|
-
* .replace(RUNTIME_PLACEHOLDERS.COMPONENT_CODE, transpiledCode)
|
|
89
|
-
* .replace(RUNTIME_PLACEHOLDERS.DATA_INJECTION, dataScript);
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare function getCachedRuntime(options: CachedRuntimeOptions, config?: RuntimeCacheConfig): CachedRuntimeResult;
|
|
93
|
-
/**
|
|
94
|
-
* Clear the runtime cache.
|
|
95
|
-
*/
|
|
96
|
-
export declare function clearRuntimeCache(): void;
|
|
97
|
-
/**
|
|
98
|
-
* Get cache statistics.
|
|
99
|
-
*/
|
|
100
|
-
export declare function getRuntimeCacheStats(): {
|
|
101
|
-
entries: number;
|
|
102
|
-
totalSize: number;
|
|
103
|
-
keys: string[];
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Build the complete app script by replacing placeholders.
|
|
107
|
-
*
|
|
108
|
-
* @param appTemplate - Template with placeholders
|
|
109
|
-
* @param componentCode - Transpiled component code (or empty string)
|
|
110
|
-
* @param dataInjection - Data injection script
|
|
111
|
-
* @param customComponents - Custom components script (or empty string)
|
|
112
|
-
* @returns Complete app script
|
|
113
|
-
*/
|
|
114
|
-
export declare function buildAppScript(appTemplate: string, componentCode: string, dataInjection: string, customComponents?: string): string;
|
|
115
|
-
export type BuildMode = 'static' | 'dynamic' | 'hybrid';
|
|
116
|
-
export interface DataInjectionOptions {
|
|
117
|
-
buildMode?: BuildMode;
|
|
118
|
-
/** CDN type - needed for platform-aware dynamic mode */
|
|
119
|
-
cdnType?: 'esm' | 'umd';
|
|
120
|
-
dynamicOptions?: {
|
|
121
|
-
includeInitialData?: boolean;
|
|
122
|
-
subscribeToUpdates?: boolean;
|
|
123
|
-
};
|
|
124
|
-
hybridOptions?: {
|
|
125
|
-
placeholder?: string;
|
|
126
|
-
inputPlaceholder?: string;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Build data injection code for the app script.
|
|
131
|
-
* Supports static, dynamic, and hybrid build modes.
|
|
132
|
-
*/
|
|
133
|
-
export declare function buildDataInjectionCode(toolName: string, input: unknown, output: unknown, structuredContent: unknown, contentType: string, source: string | null, hasComponent: boolean, options?: DataInjectionOptions): string;
|
|
134
|
-
/**
|
|
135
|
-
* Build component wrapper code.
|
|
136
|
-
*/
|
|
137
|
-
export declare function buildComponentCode(transpiledCode: string): string;
|
|
138
|
-
export {};
|
|
139
|
-
//# sourceMappingURL=cached-runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached-runtime.d.ts","sourceRoot":"","sources":["../../src/universal/cached-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAyB/D;;GAEG;AACH,UAAU,kBAAkB;IAC1B,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAC/B,gDAAgD;;IAEhD,qCAAqC;;IAErC,wCAAwC;;CAEhC,CAAC;AAkDX;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IA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