@mcp-native/webview 0.0.1 → 0.0.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 +1 -3
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -8
- package/index.js +0 -1
package/README.md
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { McpResource } from "@mcp-native/core";
|
|
2
|
+
export interface WebViewPolicy {
|
|
3
|
+
readonly allowRemoteDocuments?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type WebViewDocument = {
|
|
6
|
+
readonly kind: "inline";
|
|
7
|
+
readonly html: string;
|
|
8
|
+
readonly baseUrl: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: "remote";
|
|
11
|
+
readonly uri: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class WebViewPolicyError extends Error {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare function isHtmlResource(resource: McpResource): boolean;
|
|
17
|
+
export declare function createWebViewDocument(resource: McpResource, policy?: WebViewPolicy): WebViewDocument;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACzC;AAED,MAAM,MAAM,eAAe,GACvB;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAE7D;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EACrB,MAAM,GAAE,aAAkB,GACzB,eAAe,CAgBjB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const HTML_MIME_TYPES = new Set(["text/html", "text/html+skybridge"]);
|
|
2
|
+
export class WebViewPolicyError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "WebViewPolicyError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function isHtmlResource(resource) {
|
|
9
|
+
return resource.mimeType !== undefined && HTML_MIME_TYPES.has(resource.mimeType);
|
|
10
|
+
}
|
|
11
|
+
export function createWebViewDocument(resource, policy = {}) {
|
|
12
|
+
if (!isHtmlResource(resource)) {
|
|
13
|
+
throw new WebViewPolicyError(`Unsupported WebView MIME type: ${resource.mimeType ?? "unknown"}`);
|
|
14
|
+
}
|
|
15
|
+
if (resource.text !== undefined) {
|
|
16
|
+
return { kind: "inline", html: resource.text, baseUrl: resource.uri };
|
|
17
|
+
}
|
|
18
|
+
if (policy.allowRemoteDocuments !== true) {
|
|
19
|
+
throw new WebViewPolicyError("Remote WebView documents are disabled by policy");
|
|
20
|
+
}
|
|
21
|
+
return { kind: "remote", uri: resource.uri };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAiBtE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAC,QAAqB;IAClD,OAAO,QAAQ,CAAC,QAAQ,KAAK,SAAS,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAAqB,EACrB,MAAM,GAAkB,EAAE;IAE1B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,kBAAkB,CAC1B,kCAAkC,QAAQ,CAAC,QAAQ,IAAI,SAAS,EAAE,CACnE,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACxE,CAAC;IAED,IAAI,MAAM,CAAC,oBAAoB,KAAK,IAAI,EAAE,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAAC,iDAAiD,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-native/webview",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
8
|
-
"keywords": [],
|
|
9
|
-
"author": "",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Policy-gated WebView fallback primitives for MCP Native.",
|
|
10
5
|
"license": "MIT",
|
|
11
|
-
"
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/pablospaniard/mcp-native.git",
|
|
9
|
+
"directory": "packages/webview"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@mcp-native/core": "^0.0.2"
|
|
30
|
+
}
|
|
12
31
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|