@apify/mcp-widgets 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/files_hash_at_build.txt +1 -0
- package/dist/host/types.d.ts +10 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/widget_host_provider.d.ts +10 -0
- package/dist/host/widget_host_provider.d.ts.map +1 -0
- package/dist/host/widget_host_provider.js +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `@apify/mcp-widgets`
|
|
2
|
+
|
|
3
|
+
React components that render the output of Apify MCP tools. One source for every host: Apify Console renders them in its own React tree, the [Apify MCP server](https://github.com/apify/apify-mcp-server) bundles them into the HTML it serves to MCP Apps hosts (Claude, ChatGPT).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @apify/mcp-widgets
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react`, `react-dom`, `styled-components`. The components build on `@apify/ui-library`, so the tree must also be wrapped in its `UiDependencyProvider`.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Components reach the environment through `WidgetHostProvider`:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { WidgetHostProvider } from '@apify/mcp-widgets';
|
|
19
|
+
|
|
20
|
+
<WidgetHostProvider host={{ openLink: (url) => window.open(url, '_blank', 'noopener') }}>{children}</WidgetHostProvider>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`WidgetHost` has one required member, `openLink`. `requestDisplayMode` and `maxHeight` are optional: hosts with a single display mode or no height limit leave them out.
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
Inside the apify-core monorepo:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm run storybook # shared Storybook, section "MCP-Widgets"
|
|
31
|
+
pnpm --filter @apify/mcp-widgets test # unit tests
|
|
32
|
+
pnpm --filter @apify/mcp-widgets build # dist/ (components + d.ts)
|
|
33
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c8087e74da2d5ea8c1ce1a3829915951762ffd3e
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type WidgetDisplayMode = 'inline' | 'fullscreen';
|
|
2
|
+
/** What a widget needs from its host (MCP Apps iframe, Console, Storybook). */
|
|
3
|
+
export type WidgetHost = {
|
|
4
|
+
openLink: (url: string) => void;
|
|
5
|
+
/** Absent when the host has a single display mode. */
|
|
6
|
+
requestDisplayMode?: (mode: WidgetDisplayMode) => Promise<void> | void;
|
|
7
|
+
/** In px; absent when unconstrained. */
|
|
8
|
+
maxHeight?: number;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAExD,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvE,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CAEtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { WidgetHost } from './types';
|
|
3
|
+
type WidgetHostProviderProps = {
|
|
4
|
+
host: WidgetHost;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function WidgetHostProvider({ host, children }: WidgetHostProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function useWidgetHost(): WidgetHost;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=widget_host_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget_host_provider.d.ts","sourceRoot":"","sources":["../../src/host/widget_host_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,KAAK,uBAAuB,GAAG;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CAE7E;AAED,wBAAgB,aAAa,IAAI,UAAU,CAI1C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/host/widget_host_provider.tsx
|
|
4
|
+
var WidgetHostContext = createContext(null);
|
|
5
|
+
function WidgetHostProvider({ host, children }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(WidgetHostContext.Provider, {
|
|
7
|
+
value: host,
|
|
8
|
+
children
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function useWidgetHost() {
|
|
12
|
+
const host = useContext(WidgetHostContext);
|
|
13
|
+
if (!host) throw new Error("Widgets must be wrapped by WidgetHostProvider");
|
|
14
|
+
return host;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { WidgetHostProvider, useWidgetHost };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apify/mcp-widgets",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React components that render the output of Apify MCP tools",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"apify",
|
|
7
|
+
"mcp",
|
|
8
|
+
"react",
|
|
9
|
+
"widgets"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"!dist/src",
|
|
26
|
+
"!dist/*.tsbuildinfo"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"registry": "https://registry.npmjs.org",
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest watch",
|
|
35
|
+
"lint": "oxlint --type-aware .",
|
|
36
|
+
"lint:fix": "oxlint --type-aware --fix .",
|
|
37
|
+
"build": "pnpm run clean && pnpm run compile && ./scripts/save_current_files_hash.sh",
|
|
38
|
+
"rebuild-if-needed": "./scripts/rebuild_if_needed.sh",
|
|
39
|
+
"clean": "rimraf ./dist",
|
|
40
|
+
"compile": "vite build",
|
|
41
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
42
|
+
"postpublish": "rimraf ./dist"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@apify/ui-icons": "^1.50.0",
|
|
46
|
+
"@apify/ui-library": "^1.165.4"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": "17.x || 18.x || 19.x",
|
|
50
|
+
"react-dom": "17.x || 18.x || 19.x",
|
|
51
|
+
"styled-components": "^6.1.19"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/react": "19.2.2",
|
|
55
|
+
"@types/react-dom": "19.2.2",
|
|
56
|
+
"@vitejs/plugin-react-swc": "^4.3.1",
|
|
57
|
+
"react": "19.2.0",
|
|
58
|
+
"react-dom": "19.2.0",
|
|
59
|
+
"styled-components": "^6.1.19",
|
|
60
|
+
"vite": "^8.0.14",
|
|
61
|
+
"vite-plugin-dts": "^5.0.1"
|
|
62
|
+
}
|
|
63
|
+
}
|