@frontmcp/uipack 1.2.1 → 1.4.0
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/adapters/index.js +1046 -698
- package/adapters/template-renderer.d.ts +14 -0
- package/adapters/template-renderer.d.ts.map +1 -1
- package/bridge-runtime/iife-generator.d.ts.map +1 -1
- package/bridge-runtime/index.js +149 -0
- package/component/index.d.ts +1 -0
- package/component/index.d.ts.map +1 -1
- package/component/index.js +468 -145
- package/component/loader.d.ts +21 -2
- package/component/loader.d.ts.map +1 -1
- package/component/renderer.d.ts +2 -2
- package/component/renderer.d.ts.map +1 -1
- package/component/transpiler.d.ts +16 -1
- package/component/transpiler.d.ts.map +1 -1
- package/component/types.d.ts +19 -0
- package/component/types.d.ts.map +1 -1
- package/component/ui-availability.d.ts +27 -0
- package/component/ui-availability.d.ts.map +1 -0
- package/esm/adapters/index.mjs +1046 -698
- package/esm/bridge-runtime/index.mjs +149 -0
- package/esm/component/index.mjs +468 -145
- package/esm/index.mjs +444 -109
- package/esm/package.json +2 -2
- package/esm/shell/index.mjs +420 -171
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +445 -109
- package/package.json +2 -2
- package/shell/builder.d.ts.map +1 -1
- package/shell/data-injector.d.ts +27 -1
- package/shell/data-injector.d.ts.map +1 -1
- package/shell/index.d.ts +3 -2
- package/shell/index.d.ts.map +1 -1
- package/shell/index.js +423 -171
- package/shell/sizing-css.d.ts +27 -0
- package/shell/sizing-css.d.ts.map +1 -0
- package/shell/types.d.ts +102 -0
- package/shell/types.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/ui-config.d.ts +105 -11
- package/types/ui-config.d.ts.map +1 -1
- package/types/ui-runtime.d.ts +23 -2
- package/types/ui-runtime.d.ts.map +1 -1
package/component/loader.d.ts
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import type { ImportResolver } from '../resolver/types';
|
|
10
|
-
import
|
|
11
|
-
import { FRONTMCP_META_KEY } from './types';
|
|
10
|
+
import { FRONTMCP_META_KEY, type ResolvedComponent, type UISource } from './types';
|
|
12
11
|
/**
|
|
13
12
|
* Resolve a UISource to a loadable component.
|
|
14
13
|
*
|
|
@@ -21,6 +20,26 @@ export declare function resolveUISource(source: UISource, options?: {
|
|
|
21
20
|
resolver?: ImportResolver;
|
|
22
21
|
input?: unknown;
|
|
23
22
|
output?: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* When true, FileSource `.tsx`/`.jsx` widgets are bundled with React
|
|
25
|
+
* inlined (no esm.sh import map). Required for hosts that block external
|
|
26
|
+
* script execution (Claude — see #454). Passes through to
|
|
27
|
+
* `bundleFileSource({ bundleReact })`.
|
|
28
|
+
*/
|
|
29
|
+
inlineReact?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When true, FileSource `.tsx`/`.jsx` widgets are TRANSFORM-ONLY: the source
|
|
32
|
+
* is transpiled with esbuild `transformSync` (single file, JSX → createElement)
|
|
33
|
+
* and ALL imports — including `react`/`react-dom` — stay external bare
|
|
34
|
+
* specifiers resolved by the import map. NO bundling, NO auto-injected mount
|
|
35
|
+
* (the caller supplies a {@link ShellMountDescriptor} on the render side).
|
|
36
|
+
*
|
|
37
|
+
* This is the generic primitive a non-widget caller (e.g. an auth page) uses
|
|
38
|
+
* to route a `.tsx` through `renderComponent`'s inline-module path without
|
|
39
|
+
* pulling in the widget bundle + `McpBridgeProvider` mount. Mutually
|
|
40
|
+
* exclusive with {@link inlineReact} (bundling). Default `false`.
|
|
41
|
+
*/
|
|
42
|
+
transformOnly?: boolean;
|
|
24
43
|
}): ResolvedComponent;
|
|
25
44
|
/**
|
|
26
45
|
* Generate a mount script for module-based components.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/component/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/component/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EACL,iBAAiB,EAUjB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAOjB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,QAAQ,EAChB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,iBAAiB,CA2BnB;AA6ID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CA6B9G;AAmBD;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/component/renderer.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
import type
|
|
10
|
-
import type
|
|
9
|
+
import { type ShellConfig, type ShellResult } from '../shell/types';
|
|
10
|
+
import { type UIConfig } from './types';
|
|
11
11
|
/**
|
|
12
12
|
* Render a complete HTML shell for a UI component.
|
|
13
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/component/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/component/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,EAAE,KAAK,WAAW,EAA6B,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/F,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAehE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CA6BvF"}
|
|
@@ -31,7 +31,22 @@ export declare function transpileReactSource(source: string, filename?: string):
|
|
|
31
31
|
* @param componentName - Name of the component to mount (extracted from source)
|
|
32
32
|
* @returns Bundled JavaScript source code
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Options for `bundleFileSource`.
|
|
36
|
+
*/
|
|
37
|
+
export interface BundleFileSourceOptions {
|
|
38
|
+
/**
|
|
39
|
+
* When true, `react` / `react-dom` / `react-dom/client` and the JSX runtime
|
|
40
|
+
* subpaths are bundled into the output instead of being declared external.
|
|
41
|
+
*
|
|
42
|
+
* Used by `resourceMode: 'inline'` to produce a truly self-contained widget
|
|
43
|
+
* that runs in hosts that block external script execution (e.g. Claude
|
|
44
|
+
* Desktop / claude.ai — see issue #454). Default `false` keeps the original
|
|
45
|
+
* behavior where React is loaded from the CDN via an import map.
|
|
46
|
+
*/
|
|
47
|
+
bundleReact?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function bundleFileSource(source: string, filename: string, resolveDir: string, componentName: string, options?: BundleFileSourceOptions): {
|
|
35
50
|
code: string;
|
|
36
51
|
};
|
|
37
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../src/component/transpiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../src/component/transpiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB9E;AAED;;;;;;;;;;;;GAYG;AACH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,uBAA4B,GACpC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CA6HlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpE"}
|
package/component/types.d.ts
CHANGED
|
@@ -46,6 +46,25 @@ export interface UIConfig<In = unknown, Out = unknown> {
|
|
|
46
46
|
includeBridge?: boolean;
|
|
47
47
|
/** Custom shell template (pre-resolved object or inline string). */
|
|
48
48
|
customShell?: import('../shell/custom-shell-types').ResolvedShellTemplate | string;
|
|
49
|
+
/**
|
|
50
|
+
* When true, FileSource `.tsx`/`.jsx` widgets are bundled with React
|
|
51
|
+
* inlined (no esm.sh import map / no external `<script type="module">`).
|
|
52
|
+
* This is what `UITemplateConfig.resourceMode: 'inline'` is supposed to do
|
|
53
|
+
* end-to-end; setting it makes the widget self-contained and renders
|
|
54
|
+
* correctly in hosts that block external script execution (Claude
|
|
55
|
+
* Desktop / claude.ai — see issue #454).
|
|
56
|
+
*/
|
|
57
|
+
inlineReact?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* When true, a FileSource `.tsx`/`.jsx` is TRANSFORM-ONLY: transpiled as a
|
|
60
|
+
* single file with ALL imports (incl. react/react-dom) left external for the
|
|
61
|
+
* import map, and NO auto-injected widget mount. Pair with a
|
|
62
|
+
* {@link import('../shell/types').ShellMountDescriptor} on the shell config to
|
|
63
|
+
* supply the mount tail. The generic primitive for routing a non-widget page
|
|
64
|
+
* (e.g. an auth page) through `renderComponent`'s inline-module path. Mutually
|
|
65
|
+
* exclusive with {@link inlineReact}. Default `false`.
|
|
66
|
+
*/
|
|
67
|
+
transformOnly?: boolean;
|
|
49
68
|
}
|
|
50
69
|
/** Auto-detected or declared metadata on a component module */
|
|
51
70
|
export interface ComponentMeta {
|
package/component/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/component/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,wDAAwD;AACxD,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,uCAAuC;AACvC,MAAM,MAAM,cAAc,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC;AAE7F,mCAAmC;AACnC,MAAM,MAAM,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,CAAC,EAAE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SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,6BAA6B,EAAE,qBAAqB,GAAG,MAAM,CAAC;IACnF;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,+CAA+C;IAC/C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@frontmcp/ui` availability check for FileSource bundling.
|
|
3
|
+
*
|
|
4
|
+
* `bundleFileSource` injects an auto-generated mount that imports from
|
|
5
|
+
* `@frontmcp/ui/react`. If `@frontmcp/ui` isn't installed in the consuming
|
|
6
|
+
* project, esbuild fails with a cryptic `Could not resolve` error. This
|
|
7
|
+
* preflight detects the missing package up-front so consumers see actionable
|
|
8
|
+
* guidance instead (issue #443).
|
|
9
|
+
*
|
|
10
|
+
* Implementation note: we deliberately probe the filesystem directly with
|
|
11
|
+
* `fs.existsSync(<dir>/node_modules/@frontmcp/ui/package.json)` rather than
|
|
12
|
+
* `require.resolve('@frontmcp/ui/...')`. The latter would surface as a
|
|
13
|
+
* module-specifier reference to the `@frontmcp/ui` workspace package and
|
|
14
|
+
* trip the Nx `@nx/enforce-module-boundaries` rule (uipack must not depend
|
|
15
|
+
* on ui), even though it's a runtime resolution check rather than a real
|
|
16
|
+
* import. Using a filesystem probe keeps the dependency graph one-way.
|
|
17
|
+
*
|
|
18
|
+
* Browser-safe: `require('fs')` is Node-only. In a browser build we return
|
|
19
|
+
* `false` rather than throwing — uipack is on track to be importable from
|
|
20
|
+
* browser bundles, and the bundling code-path that gates on this check
|
|
21
|
+
* shouldn't run in a browser anyway.
|
|
22
|
+
*
|
|
23
|
+
* Extracted to its own module so tests can mock it without touching the
|
|
24
|
+
* global Node module resolver.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isFrontmcpUiResolvable(...candidatePaths: string[]): boolean;
|
|
27
|
+
//# sourceMappingURL=ui-availability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-availability.d.ts","sourceRoot":"","sources":["../../src/component/ui-availability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CA2B3E"}
|