@mcp-web/types 0.1.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/LICENSE +201 -0
- package/dist/apps.d.ts +125 -0
- package/dist/apps.d.ts.map +1 -0
- package/dist/apps.js +50 -0
- package/dist/apps.js.map +1 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +48 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +54 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +60 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +21 -0
- package/dist/mcp.js.map +1 -0
- package/dist/query.d.ts +127 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +71 -0
- package/dist/query.js.map +1 -0
- package/dist/resources.d.ts +108 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +47 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools.d.ts +114 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +55 -0
- package/dist/tools.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Fritz Lekschas
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/apps.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* MIME type for MCP App resources, per the ext-apps specification (SEP-1865).
|
|
5
|
+
* @see https://github.com/modelcontextprotocol/ext-apps
|
|
6
|
+
*/
|
|
7
|
+
export declare const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
8
|
+
/**
|
|
9
|
+
* Handler function for an MCP App tool.
|
|
10
|
+
* Returns props that will be passed to the app component.
|
|
11
|
+
*/
|
|
12
|
+
export type AppToolHandler = (input?: any) => any | Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Zod schema for app definition validation.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AppDefinitionSchema: z.ZodObject<{
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
description: z.ZodString;
|
|
19
|
+
component: z.ZodCustom<ComponentType<any>, ComponentType<any>>;
|
|
20
|
+
inputSchema: z.ZodOptional<z.ZodCustom<z.ZodObject<Readonly<{
|
|
21
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
22
|
+
}>, z.core.$strip> | Record<string, unknown>, z.ZodObject<Readonly<{
|
|
23
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
24
|
+
}>, z.core.$strip> | Record<string, unknown>>>;
|
|
25
|
+
propsSchema: z.ZodOptional<z.ZodCustom<Record<string, unknown> | z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, Record<string, unknown> | z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
26
|
+
handler: z.ZodCustom<AppToolHandler, AppToolHandler>;
|
|
27
|
+
url: z.ZodOptional<z.ZodString>;
|
|
28
|
+
resourceUri: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/**
|
|
31
|
+
* App definition for registering MCP Apps with MCPWeb.
|
|
32
|
+
*
|
|
33
|
+
* An MCP App is a combination of:
|
|
34
|
+
* 1. A tool that AI can call (returns props)
|
|
35
|
+
* 2. A resource that provides the UI (HTML)
|
|
36
|
+
*
|
|
37
|
+
* When AI calls the tool, the handler returns props which are included
|
|
38
|
+
* in the tool response with `_meta.ui.resourceUri`. The host then fetches
|
|
39
|
+
* the resource HTML and renders it in an iframe, communicating via the
|
|
40
|
+
* ext-apps JSON-RPC protocol (`@modelcontextprotocol/ext-apps`).
|
|
41
|
+
*
|
|
42
|
+
* @example Basic App
|
|
43
|
+
* ```typescript
|
|
44
|
+
* mcp.addApp({
|
|
45
|
+
* name: 'show_statistics',
|
|
46
|
+
* description: 'Display statistics visualization',
|
|
47
|
+
* handler: () => ({
|
|
48
|
+
* completionRate: 0.75,
|
|
49
|
+
* totalTasks: 100,
|
|
50
|
+
* completedTasks: 75,
|
|
51
|
+
* }),
|
|
52
|
+
* url: '/mcp-web-apps/statistics.html',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example With Input Schema
|
|
57
|
+
* ```typescript
|
|
58
|
+
* mcp.addApp({
|
|
59
|
+
* name: 'show_chart',
|
|
60
|
+
* description: 'Display a chart with the given data',
|
|
61
|
+
* inputSchema: z.object({
|
|
62
|
+
* chartType: z.enum(['bar', 'line', 'pie']).describe('Type of chart'),
|
|
63
|
+
* title: z.string().describe('Chart title'),
|
|
64
|
+
* }),
|
|
65
|
+
* handler: ({ chartType, title }) => ({
|
|
66
|
+
* chartType,
|
|
67
|
+
* title,
|
|
68
|
+
* data: getChartData(),
|
|
69
|
+
* }),
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export interface AppDefinition {
|
|
74
|
+
/** Unique name for the app (also used as tool name) */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Description of what the app does (shown to AI) */
|
|
77
|
+
description: string;
|
|
78
|
+
/** React component to render in the app */
|
|
79
|
+
component: ComponentType<any>;
|
|
80
|
+
/** Input schema for the tool (Zod or JSON Schema) */
|
|
81
|
+
inputSchema?: z.ZodObject | Record<string, unknown>;
|
|
82
|
+
/** Props schema for validating handler output */
|
|
83
|
+
propsSchema?: z.ZodType | Record<string, unknown>;
|
|
84
|
+
/** Handler function that returns props for the app */
|
|
85
|
+
handler: AppToolHandler;
|
|
86
|
+
/** URL to fetch the app HTML from (defaults to /mcp-web-apps/{name}.html) */
|
|
87
|
+
url?: string;
|
|
88
|
+
/** Resource URI for the app (defaults to ui://{name}/app.html) */
|
|
89
|
+
resourceUri?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Internal processed app definition with resolved defaults.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export interface ProcessedAppDefinition extends AppDefinition {
|
|
96
|
+
/** Resolved URL (with default applied) */
|
|
97
|
+
resolvedUrl: string;
|
|
98
|
+
/** Resolved resource URI (with default applied) */
|
|
99
|
+
resolvedResourceUri: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get default URL for an app.
|
|
103
|
+
*/
|
|
104
|
+
export declare function getDefaultAppUrl(name: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Get default resource URI for an app.
|
|
107
|
+
*/
|
|
108
|
+
export declare function getDefaultAppResourceUri(name: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* A created app that can be registered with MCPWeb.
|
|
111
|
+
*
|
|
112
|
+
* Created apps are validated at creation time but not yet registered.
|
|
113
|
+
* Use `mcpWeb.addApp(createdApp)` to register.
|
|
114
|
+
*/
|
|
115
|
+
export interface CreatedApp {
|
|
116
|
+
/** Marker to identify this as a created app */
|
|
117
|
+
readonly __brand: 'CreatedApp';
|
|
118
|
+
/** The app definition for registration */
|
|
119
|
+
readonly definition: AppDefinition;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Type guard to check if a value is a CreatedApp.
|
|
123
|
+
*/
|
|
124
|
+
export declare function isCreatedApp(value: unknown): value is CreatedApp;
|
|
125
|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AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAOhE"}
|
package/dist/apps.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* MIME type for MCP App resources, per the ext-apps specification (SEP-1865).
|
|
4
|
+
* @see https://github.com/modelcontextprotocol/ext-apps
|
|
5
|
+
*/
|
|
6
|
+
export const RESOURCE_MIME_TYPE = 'text/html;profile=mcp-app';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for app definition validation.
|
|
9
|
+
*/
|
|
10
|
+
export const AppDefinitionSchema = z.object({
|
|
11
|
+
/** Unique name for the app (also used as tool name) */
|
|
12
|
+
name: z.string().min(1, 'App name is required'),
|
|
13
|
+
/** Description of what the app does (shown to AI) */
|
|
14
|
+
description: z.string().min(1, 'App description is required'),
|
|
15
|
+
/** React component to render in the app */
|
|
16
|
+
// biome-ignore lint/suspicious/noExplicitAny: Component can have any props type
|
|
17
|
+
component: z.custom((val) => typeof val === 'function', { message: 'Component must be a React component' }),
|
|
18
|
+
/** Input schema for the tool (Zod or JSON Schema) */
|
|
19
|
+
inputSchema: z.custom((val) => val === undefined || (val && typeof val === 'object'), { message: 'Must be a Zod schema or JSON Schema object' }).optional(),
|
|
20
|
+
/** Props schema for validating handler output */
|
|
21
|
+
propsSchema: z.custom((val) => val === undefined || (val && typeof val === 'object'), { message: 'Must be a Zod schema or JSON Schema object' }).optional(),
|
|
22
|
+
/** Handler function that returns props for the app */
|
|
23
|
+
handler: z.custom((val) => typeof val === 'function', { message: 'Handler must be a function' }),
|
|
24
|
+
/** URL to fetch the app HTML from (defaults to /mcp-web-apps/{kebab-case-name}.html) */
|
|
25
|
+
url: z.string().optional(),
|
|
26
|
+
/** Resource URI for the app (defaults to ui://{name}/app.html) */
|
|
27
|
+
resourceUri: z.string().optional(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Get default URL for an app.
|
|
31
|
+
*/
|
|
32
|
+
export function getDefaultAppUrl(name) {
|
|
33
|
+
return `/mcp-web-apps/${name}.html`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get default resource URI for an app.
|
|
37
|
+
*/
|
|
38
|
+
export function getDefaultAppResourceUri(name) {
|
|
39
|
+
return `ui://${name}/app.html`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Type guard to check if a value is a CreatedApp.
|
|
43
|
+
*/
|
|
44
|
+
export function isCreatedApp(value) {
|
|
45
|
+
return (typeof value === 'object' &&
|
|
46
|
+
value !== null &&
|
|
47
|
+
'__brand' in value &&
|
|
48
|
+
value.__brand === 'CreatedApp');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=apps.js.map
|
package/dist/apps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../src/apps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAS9D;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,uDAAuD;IACvD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;IAC/C,q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AACjC,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QACjB,KAAoB,CAAC,OAAO,KAAK,YAAY,CAC/C,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for MCPWeb configuration.
|
|
4
|
+
*
|
|
5
|
+
* Validates and transforms configuration options for MCPWeb instances.
|
|
6
|
+
* All URL fields are stripped of protocols as the protocol is determined
|
|
7
|
+
* automatically based on the page context (http/https).
|
|
8
|
+
*/
|
|
9
|
+
export declare const McpWebConfigSchema: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
description: z.ZodString;
|
|
12
|
+
bridgeUrl: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodString>>, z.ZodTransform<string, string>>;
|
|
13
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
14
|
+
agentUrl: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
|
|
15
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
16
|
+
persistAuthToken: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
17
|
+
autoConnect: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
18
|
+
maxSessionsPerToken: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
onSessionLimitExceeded: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
reject: "reject";
|
|
21
|
+
close_oldest: "close_oldest";
|
|
22
|
+
}>>>;
|
|
23
|
+
maxInFlightQueriesPerToken: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
sessionMaxDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
sessionName: z.ZodOptional<z.ZodString>;
|
|
26
|
+
debug: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/**
|
|
29
|
+
* Input type for MCPWeb configuration.
|
|
30
|
+
*
|
|
31
|
+
* Use this type when creating new MCPWeb instances. All fields except
|
|
32
|
+
* `name` and `description` have sensible defaults.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const config: MCPWebConfig = {
|
|
37
|
+
* name: 'My App',
|
|
38
|
+
* description: 'An AI-controllable web application',
|
|
39
|
+
* bridgeUrl: 'localhost:3001',
|
|
40
|
+
* };
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export type MCPWebConfig = z.input<typeof McpWebConfigSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* Output type for parsed MCPWeb configuration.
|
|
46
|
+
*
|
|
47
|
+
* This type represents the configuration after validation and transformation,
|
|
48
|
+
* with all defaults applied. Used internally by MCPWeb instances.
|
|
49
|
+
*/
|
|
50
|
+
export type MCPWebConfigOutput = z.infer<typeof McpWebConfigSchema>;
|
|
51
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;iBAsC7B,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for MCPWeb configuration.
|
|
4
|
+
*
|
|
5
|
+
* Validates and transforms configuration options for MCPWeb instances.
|
|
6
|
+
* All URL fields are stripped of protocols as the protocol is determined
|
|
7
|
+
* automatically based on the page context (http/https).
|
|
8
|
+
*/
|
|
9
|
+
export const McpWebConfigSchema = z.object({
|
|
10
|
+
/** The name of the server. This is used to identify the server and is displayed in your AI App (e.g., Claude Desktop) */
|
|
11
|
+
name: z.string().min(1).describe('The name of the server. This is used to identify the server and is displayed in your AI App (e.g., Claude Desktop)'),
|
|
12
|
+
/** The description of the server. This should describe the web app you want the AI App to control. */
|
|
13
|
+
description: z.string().min(1).describe('The description of the server. This should describe the web app you want the AI App to control.'),
|
|
14
|
+
/** The bridge server address as host:port (e.g., 'localhost:3001' or 'bridge.example.com'). Protocol is determined automatically based on page context. */
|
|
15
|
+
bridgeUrl: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.default('localhost:3001')
|
|
19
|
+
.transform((url) => url.replace(/^(wss?|https?):\/\//, ''))
|
|
20
|
+
.describe('The bridge server address as host:port (e.g., \'localhost:3001\' or \'bridge.example.com\'). Protocol is determined automatically.'),
|
|
21
|
+
/** Either a URL or a data URI like "data:image/png;base64,...". This is shown in the AI App. */
|
|
22
|
+
icon: z.string().optional().describe('Either a URL or a data URI like "data:image/png;base64,...". This is shown in the AI App.'),
|
|
23
|
+
/** The agent server address with optional path (e.g., 'localhost:3000' or 'localhost:3000/api/v1/query'). Protocol is determined automatically. Required for query support. */
|
|
24
|
+
agentUrl: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.transform((url) => url?.replace(/^(wss?|https?):\/\//, ''))
|
|
28
|
+
.describe('The agent server address with optional path (e.g., \'localhost:3000\' or \'localhost:3000/api/v1/query\'). Protocol is determined automatically.'),
|
|
29
|
+
/** Authentication token for the agent. If not provided, will use auto-generated token. */
|
|
30
|
+
authToken: z.string().optional().describe('Authentication token for the agent. If not provided, will use auto-generated token.'),
|
|
31
|
+
/** Whether to persist the auth token in localStorage. */
|
|
32
|
+
persistAuthToken: z.boolean().optional().default(true).describe('Whether to persist the auth token in localStorage.'),
|
|
33
|
+
/** Whether to automatically connect to the MCP bridge on initialization. */
|
|
34
|
+
autoConnect: z.boolean().optional().default(true).describe('Whether to automatically connect to the MCP bridge on initialization.'),
|
|
35
|
+
/** Maximum sessions allowed per auth token. When exceeded, behavior is determined by `onSessionLimitExceeded`. */
|
|
36
|
+
maxSessionsPerToken: z.number().int().positive().optional().describe('Maximum sessions allowed per auth token.'),
|
|
37
|
+
/** Behavior when session limit is exceeded. "reject" rejects new connections, "close_oldest" closes the oldest session. */
|
|
38
|
+
onSessionLimitExceeded: z.enum(['reject', 'close_oldest']).optional().default('reject').describe('Behavior when session limit is exceeded.'),
|
|
39
|
+
/** Maximum concurrent in-flight queries across all sessions for a token. Prevents resource exhaustion. */
|
|
40
|
+
maxInFlightQueriesPerToken: z.number().int().positive().optional().describe('Maximum concurrent in-flight queries per token.'),
|
|
41
|
+
/** Maximum session duration in milliseconds. Sessions older than this are automatically closed. */
|
|
42
|
+
sessionMaxDurationMs: z.number().int().positive().optional().describe('Maximum session duration in milliseconds.'),
|
|
43
|
+
/** Optional human-readable name for the session. Must be unique per auth token. Used to identify specific sessions when multiple are connected. */
|
|
44
|
+
sessionName: z.string().min(1).optional().describe('Optional human-readable name for the session. Must be unique per auth token. Used to identify specific sessions when multiple are connected.'),
|
|
45
|
+
/** Enable debug logging for MCP requests and responses. */
|
|
46
|
+
debug: z.boolean().optional().default(false).describe('Enable debug logging for MCP requests and responses.'),
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAM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,CAAC,CAAC,QAAQ,CAAC,uEAAuE,CAAC;IACnI,kHAAkH;IAClH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IAChH,2HAA2H;IAC3H,sBAAsB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IAC5I,0GAA0G;IAC1G,0BAA0B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC9H,mGAAmG;IACnG,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAClH,mJAAmJ;IACnJ,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8IAA8I,CAAC;IAClM,2DAA2D;IAC3D,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,sDAAsD,CAAC;CAC9G,CAAC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const MissingAuthenticationErrorCode = "MissingAuthentication";
|
|
2
|
+
export declare const InvalidAuthenticationErrorCode = "InvalidAuthentication";
|
|
3
|
+
export declare const InvalidSessionErrorCode = "InvalidSession";
|
|
4
|
+
export declare const NoSessionsFoundErrorCode = "NoSessionsFound";
|
|
5
|
+
export declare const SessionNotFoundErrorCode = "SessionNotFound";
|
|
6
|
+
export declare const QueryNotFoundErrorCode = "QueryNotFound";
|
|
7
|
+
export declare const QueryNotActiveErrorCode = "QueryNotActive";
|
|
8
|
+
export declare const QueryDoneErrorCode = "QueryCompleted";
|
|
9
|
+
export declare const UnknownMethodErrorCode = "UnknownMethod";
|
|
10
|
+
export declare const InternalErrorCode = "InternalError";
|
|
11
|
+
export declare const ClientNotConextualizedErrorCode = "ClientNotConextualized";
|
|
12
|
+
export declare const ToolNotFoundErrorCode = "ToolNotFound";
|
|
13
|
+
export declare const SessionNotSpecifiedErrorCode = "SessionNotSpecified";
|
|
14
|
+
export declare const ToolNameRequiredErrorCode = "ToolNameRequired";
|
|
15
|
+
export declare const ToolNotAllowedErrorCode = "ToolNotAllowed";
|
|
16
|
+
export declare const SessionLimitExceededErrorCode = "SessionLimitExceeded";
|
|
17
|
+
export declare const QueryLimitExceededErrorCode = "QueryLimitExceeded";
|
|
18
|
+
export declare const SessionExpiredErrorCode = "SessionExpired";
|
|
19
|
+
export declare const SessionNameAlreadyInUseErrorCode = "SessionNameAlreadyInUse";
|
|
20
|
+
export declare const ToolSchemaConflictErrorCode = "ToolSchemaConflict";
|
|
21
|
+
/**
|
|
22
|
+
* Error details passed to the `onRegistrationError` callback when the bridge
|
|
23
|
+
* rejects a tool registration (e.g., due to a schema conflict with a sibling session).
|
|
24
|
+
*/
|
|
25
|
+
export interface ToolRegistrationError {
|
|
26
|
+
/** The name of the tool that was rejected. */
|
|
27
|
+
toolName: string;
|
|
28
|
+
/** Error code identifying the type of registration failure. */
|
|
29
|
+
code: string;
|
|
30
|
+
/** Human-readable description of why the registration was rejected. */
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Session information returned in errors
|
|
35
|
+
*/
|
|
36
|
+
export interface SessionInfo {
|
|
37
|
+
session_id: string;
|
|
38
|
+
session_name: string | undefined;
|
|
39
|
+
origin: string;
|
|
40
|
+
page_title: string;
|
|
41
|
+
connected_at: string;
|
|
42
|
+
last_activity: string;
|
|
43
|
+
available_tools: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Error thrown when a session must be specified but wasn't provided.
|
|
47
|
+
* Contains structured information about available sessions.
|
|
48
|
+
*/
|
|
49
|
+
export declare class SessionNotSpecifiedError extends Error {
|
|
50
|
+
readonly availableSessions: SessionInfo[];
|
|
51
|
+
readonly code = "SessionNotSpecified";
|
|
52
|
+
constructor(message: string, availableSessions: SessionInfo[]);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AACtE,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AACtE,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AACxD,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AACxD,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AACjD,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MAAM,4BAA4B,wBAAwB,CAAC;AAClE,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAC5D,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AACxD,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AACpE,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,eAAO,MAAM,gCAAgC,4BAA4B,CAAC;AAC1E,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;aAK/B,iBAAiB,EAAE,WAAW,EAAE;IAJlD,SAAgB,IAAI,yBAAgC;gBAGlD,OAAO,EAAE,MAAM,EACC,iBAAiB,EAAE,WAAW,EAAE;CAQnD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const MissingAuthenticationErrorCode = 'MissingAuthentication';
|
|
2
|
+
export const InvalidAuthenticationErrorCode = 'InvalidAuthentication';
|
|
3
|
+
export const InvalidSessionErrorCode = 'InvalidSession';
|
|
4
|
+
export const NoSessionsFoundErrorCode = 'NoSessionsFound';
|
|
5
|
+
export const SessionNotFoundErrorCode = 'SessionNotFound';
|
|
6
|
+
export const QueryNotFoundErrorCode = 'QueryNotFound';
|
|
7
|
+
export const QueryNotActiveErrorCode = 'QueryNotActive';
|
|
8
|
+
export const QueryDoneErrorCode = 'QueryCompleted';
|
|
9
|
+
export const UnknownMethodErrorCode = 'UnknownMethod';
|
|
10
|
+
export const InternalErrorCode = 'InternalError';
|
|
11
|
+
export const ClientNotConextualizedErrorCode = 'ClientNotConextualized';
|
|
12
|
+
export const ToolNotFoundErrorCode = 'ToolNotFound';
|
|
13
|
+
export const SessionNotSpecifiedErrorCode = 'SessionNotSpecified';
|
|
14
|
+
export const ToolNameRequiredErrorCode = 'ToolNameRequired';
|
|
15
|
+
export const ToolNotAllowedErrorCode = 'ToolNotAllowed';
|
|
16
|
+
export const SessionLimitExceededErrorCode = 'SessionLimitExceeded';
|
|
17
|
+
export const QueryLimitExceededErrorCode = 'QueryLimitExceeded';
|
|
18
|
+
export const SessionExpiredErrorCode = 'SessionExpired';
|
|
19
|
+
export const SessionNameAlreadyInUseErrorCode = 'SessionNameAlreadyInUse';
|
|
20
|
+
export const ToolSchemaConflictErrorCode = 'ToolSchemaConflict';
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when a session must be specified but wasn't provided.
|
|
23
|
+
* Contains structured information about available sessions.
|
|
24
|
+
*/
|
|
25
|
+
export class SessionNotSpecifiedError extends Error {
|
|
26
|
+
constructor(message, availableSessions) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.availableSessions = availableSessions;
|
|
29
|
+
this.code = SessionNotSpecifiedErrorCode;
|
|
30
|
+
this.name = 'SessionNotSpecifiedError';
|
|
31
|
+
// Ensure proper prototype chain for instanceof checks
|
|
32
|
+
Object.setPrototypeOf(this, SessionNotSpecifiedError.prototype);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AACtE,MAAM,CAAC,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CA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["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|