@lovable.dev/mcp-js 3.3.1 → 3.5.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/README.internal.md +38 -12
- package/README.md +140 -12
- package/dist/THIRD_PARTY_NOTICES +75 -0
- package/dist/apps-CWG3rGhB.js +132 -0
- package/dist/apps-DyoDrwfi.cjs +185 -0
- package/dist/{authorize-CoaAw6wg.d.cts → authorize--W1XtwdB.d.cts} +1 -1
- package/dist/{authorize-BV62MDan.d.ts → authorize-DpNYioXM.d.ts} +1 -1
- package/dist/{base-Cx0spfMk.d.ts → base-Ce9JYirF.d.ts} +1 -1
- package/dist/{base-CzWe8AD1.d.cts → base-qEX8YVcD.d.cts} +1 -1
- package/dist/cli/check-server.cjs +1 -1
- package/dist/cli/check-server.js +1 -1
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-3HjrsmEW.cjs → cors-B_Oui5La.cjs} +1 -1
- package/dist/{cors-CNNmKKIg.js → cors-D83r8WUF.js} +1 -1
- package/dist/dist-CIu-UFye.js +6738 -0
- package/dist/dist-CqY2qXpc.cjs +6738 -0
- package/dist/{errors-CIpFAb6i.js → errors-CfaxXr2T.js} +15 -2
- package/dist/{errors-C97I7VOC.cjs → errors-xJ_7Su1K.cjs} +20 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -2
- package/dist/{io-D7cpdBJO.d.ts → io-BEpyfk4G.d.ts} +1 -1
- package/dist/{io-CaBSlPwS.cjs → io-CUnV4kTL.cjs} +12 -2
- package/dist/{io-DC-Y6R61.d.cts → io-Di5ljvZY.d.cts} +1 -1
- package/dist/{io-CahnhUhA.js → io-STpVLkbi.js} +13 -3
- package/dist/{mcp-DC8AoD18.js → mcp-BgIFUoo1.js} +110 -49
- package/dist/{mcp-DlWLIwX9.cjs → mcp-DpI0wwnW.cjs} +110 -49
- package/dist/mcp-app.d.ts +4 -0
- package/dist/{package-B488glmj.cjs → package-CuCho6-k.cjs} +1 -1
- package/dist/{package-CukfP_vq.js → package-Cz6Z5F_X.js} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/src-D7RtXSV0.cjs +311 -0
- package/dist/src-sWQwyLwS.js +310 -0
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +10 -1
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +21 -12
- package/dist/stacks/tanstack/index.cjs +33 -2
- package/dist/stacks/tanstack/index.d.cts +7 -4
- package/dist/stacks/tanstack/index.d.ts +7 -4
- package/dist/stacks/tanstack/index.js +33 -2
- package/dist/stacks/tanstack/vite.cjs +995 -15
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/stacks/tanstack/vite.js +1001 -21
- package/dist/testing/browser/LICENSE.ext-apps +218 -0
- package/dist/testing/browser/host.ts +151 -0
- package/dist/testing/browser/sandbox.ts +137 -0
- package/dist/testing/browser.cjs +382 -0
- package/dist/testing/browser.d.cts +46 -0
- package/dist/testing/browser.d.ts +46 -0
- package/dist/testing/browser.js +381 -0
- package/dist/testing/index.cjs +2 -1
- package/dist/testing/index.d.cts +2 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/server.cjs +36 -0
- package/dist/testing/server.d.cts +6 -2
- package/dist/testing/server.d.ts +6 -2
- package/dist/testing/server.js +36 -1
- package/dist/{tool-result-DcNioyiI.js → tool-result-BG-HsSQu.js} +8 -1
- package/dist/{tool-result-rU-PpNNi.cjs → tool-result-BQcr7VV-.cjs} +8 -1
- package/dist/{types-z7T5bBIU.d.cts → types-B_dVw-zM.d.cts} +55 -1
- package/dist/{types-z7T5bBIU.d.ts → types-B_dVw-zM.d.ts} +55 -1
- package/package.json +66 -25
|
@@ -2,11 +2,927 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
+
const require_apps = require("../../apps-DyoDrwfi.cjs");
|
|
5
6
|
require("../../metadata-path-zd7NSNoa.cjs");
|
|
6
7
|
const require_hooks = require("../../hooks-xQl3EkDa.cjs");
|
|
7
8
|
let node_fs = require("node:fs");
|
|
8
9
|
let node_path = require("node:path");
|
|
9
10
|
let vite = require("vite");
|
|
11
|
+
let node_module = require("node:module");
|
|
12
|
+
let esbuild = require("esbuild");
|
|
13
|
+
let node_url = require("node:url");
|
|
14
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/mrmime/2.0.1/707d6e2722072f911c175089bde1d600521e397943efa72f5248de1f4bdfd47d/node_modules/mrmime/index.mjs
|
|
15
|
+
const mimes = {
|
|
16
|
+
"3g2": "video/3gpp2",
|
|
17
|
+
"3gp": "video/3gpp",
|
|
18
|
+
"3gpp": "video/3gpp",
|
|
19
|
+
"3mf": "model/3mf",
|
|
20
|
+
"aac": "audio/aac",
|
|
21
|
+
"ac": "application/pkix-attr-cert",
|
|
22
|
+
"adp": "audio/adpcm",
|
|
23
|
+
"adts": "audio/aac",
|
|
24
|
+
"ai": "application/postscript",
|
|
25
|
+
"aml": "application/automationml-aml+xml",
|
|
26
|
+
"amlx": "application/automationml-amlx+zip",
|
|
27
|
+
"amr": "audio/amr",
|
|
28
|
+
"apng": "image/apng",
|
|
29
|
+
"appcache": "text/cache-manifest",
|
|
30
|
+
"appinstaller": "application/appinstaller",
|
|
31
|
+
"appx": "application/appx",
|
|
32
|
+
"appxbundle": "application/appxbundle",
|
|
33
|
+
"asc": "application/pgp-keys",
|
|
34
|
+
"atom": "application/atom+xml",
|
|
35
|
+
"atomcat": "application/atomcat+xml",
|
|
36
|
+
"atomdeleted": "application/atomdeleted+xml",
|
|
37
|
+
"atomsvc": "application/atomsvc+xml",
|
|
38
|
+
"au": "audio/basic",
|
|
39
|
+
"avci": "image/avci",
|
|
40
|
+
"avcs": "image/avcs",
|
|
41
|
+
"avif": "image/avif",
|
|
42
|
+
"aw": "application/applixware",
|
|
43
|
+
"bdoc": "application/bdoc",
|
|
44
|
+
"bin": "application/octet-stream",
|
|
45
|
+
"bmp": "image/bmp",
|
|
46
|
+
"bpk": "application/octet-stream",
|
|
47
|
+
"btf": "image/prs.btif",
|
|
48
|
+
"btif": "image/prs.btif",
|
|
49
|
+
"buffer": "application/octet-stream",
|
|
50
|
+
"ccxml": "application/ccxml+xml",
|
|
51
|
+
"cdfx": "application/cdfx+xml",
|
|
52
|
+
"cdmia": "application/cdmi-capability",
|
|
53
|
+
"cdmic": "application/cdmi-container",
|
|
54
|
+
"cdmid": "application/cdmi-domain",
|
|
55
|
+
"cdmio": "application/cdmi-object",
|
|
56
|
+
"cdmiq": "application/cdmi-queue",
|
|
57
|
+
"cer": "application/pkix-cert",
|
|
58
|
+
"cgm": "image/cgm",
|
|
59
|
+
"cjs": "application/node",
|
|
60
|
+
"class": "application/java-vm",
|
|
61
|
+
"coffee": "text/coffeescript",
|
|
62
|
+
"conf": "text/plain",
|
|
63
|
+
"cpl": "application/cpl+xml",
|
|
64
|
+
"cpt": "application/mac-compactpro",
|
|
65
|
+
"crl": "application/pkix-crl",
|
|
66
|
+
"css": "text/css",
|
|
67
|
+
"csv": "text/csv",
|
|
68
|
+
"cu": "application/cu-seeme",
|
|
69
|
+
"cwl": "application/cwl",
|
|
70
|
+
"cww": "application/prs.cww",
|
|
71
|
+
"davmount": "application/davmount+xml",
|
|
72
|
+
"dbk": "application/docbook+xml",
|
|
73
|
+
"deb": "application/octet-stream",
|
|
74
|
+
"def": "text/plain",
|
|
75
|
+
"deploy": "application/octet-stream",
|
|
76
|
+
"dib": "image/bmp",
|
|
77
|
+
"disposition-notification": "message/disposition-notification",
|
|
78
|
+
"dist": "application/octet-stream",
|
|
79
|
+
"distz": "application/octet-stream",
|
|
80
|
+
"dll": "application/octet-stream",
|
|
81
|
+
"dmg": "application/octet-stream",
|
|
82
|
+
"dms": "application/octet-stream",
|
|
83
|
+
"doc": "application/msword",
|
|
84
|
+
"dot": "application/msword",
|
|
85
|
+
"dpx": "image/dpx",
|
|
86
|
+
"drle": "image/dicom-rle",
|
|
87
|
+
"dsc": "text/prs.lines.tag",
|
|
88
|
+
"dssc": "application/dssc+der",
|
|
89
|
+
"dtd": "application/xml-dtd",
|
|
90
|
+
"dump": "application/octet-stream",
|
|
91
|
+
"dwd": "application/atsc-dwd+xml",
|
|
92
|
+
"ear": "application/java-archive",
|
|
93
|
+
"ecma": "application/ecmascript",
|
|
94
|
+
"elc": "application/octet-stream",
|
|
95
|
+
"emf": "image/emf",
|
|
96
|
+
"eml": "message/rfc822",
|
|
97
|
+
"emma": "application/emma+xml",
|
|
98
|
+
"emotionml": "application/emotionml+xml",
|
|
99
|
+
"eps": "application/postscript",
|
|
100
|
+
"epub": "application/epub+zip",
|
|
101
|
+
"exe": "application/octet-stream",
|
|
102
|
+
"exi": "application/exi",
|
|
103
|
+
"exp": "application/express",
|
|
104
|
+
"exr": "image/aces",
|
|
105
|
+
"ez": "application/andrew-inset",
|
|
106
|
+
"fdf": "application/fdf",
|
|
107
|
+
"fdt": "application/fdt+xml",
|
|
108
|
+
"fits": "image/fits",
|
|
109
|
+
"g3": "image/g3fax",
|
|
110
|
+
"gbr": "application/rpki-ghostbusters",
|
|
111
|
+
"geojson": "application/geo+json",
|
|
112
|
+
"gif": "image/gif",
|
|
113
|
+
"glb": "model/gltf-binary",
|
|
114
|
+
"gltf": "model/gltf+json",
|
|
115
|
+
"gml": "application/gml+xml",
|
|
116
|
+
"gpx": "application/gpx+xml",
|
|
117
|
+
"gram": "application/srgs",
|
|
118
|
+
"grxml": "application/srgs+xml",
|
|
119
|
+
"gxf": "application/gxf",
|
|
120
|
+
"gz": "application/gzip",
|
|
121
|
+
"h261": "video/h261",
|
|
122
|
+
"h263": "video/h263",
|
|
123
|
+
"h264": "video/h264",
|
|
124
|
+
"heic": "image/heic",
|
|
125
|
+
"heics": "image/heic-sequence",
|
|
126
|
+
"heif": "image/heif",
|
|
127
|
+
"heifs": "image/heif-sequence",
|
|
128
|
+
"hej2": "image/hej2k",
|
|
129
|
+
"held": "application/atsc-held+xml",
|
|
130
|
+
"hjson": "application/hjson",
|
|
131
|
+
"hlp": "application/winhlp",
|
|
132
|
+
"hqx": "application/mac-binhex40",
|
|
133
|
+
"hsj2": "image/hsj2",
|
|
134
|
+
"htm": "text/html",
|
|
135
|
+
"html": "text/html",
|
|
136
|
+
"ics": "text/calendar",
|
|
137
|
+
"ief": "image/ief",
|
|
138
|
+
"ifb": "text/calendar",
|
|
139
|
+
"iges": "model/iges",
|
|
140
|
+
"igs": "model/iges",
|
|
141
|
+
"img": "application/octet-stream",
|
|
142
|
+
"in": "text/plain",
|
|
143
|
+
"ini": "text/plain",
|
|
144
|
+
"ink": "application/inkml+xml",
|
|
145
|
+
"inkml": "application/inkml+xml",
|
|
146
|
+
"ipfix": "application/ipfix",
|
|
147
|
+
"iso": "application/octet-stream",
|
|
148
|
+
"its": "application/its+xml",
|
|
149
|
+
"jade": "text/jade",
|
|
150
|
+
"jar": "application/java-archive",
|
|
151
|
+
"jhc": "image/jphc",
|
|
152
|
+
"jls": "image/jls",
|
|
153
|
+
"jp2": "image/jp2",
|
|
154
|
+
"jpe": "image/jpeg",
|
|
155
|
+
"jpeg": "image/jpeg",
|
|
156
|
+
"jpf": "image/jpx",
|
|
157
|
+
"jpg": "image/jpeg",
|
|
158
|
+
"jpg2": "image/jp2",
|
|
159
|
+
"jpgm": "image/jpm",
|
|
160
|
+
"jpgv": "video/jpeg",
|
|
161
|
+
"jph": "image/jph",
|
|
162
|
+
"jpm": "image/jpm",
|
|
163
|
+
"jpx": "image/jpx",
|
|
164
|
+
"js": "text/javascript",
|
|
165
|
+
"json": "application/json",
|
|
166
|
+
"json5": "application/json5",
|
|
167
|
+
"jsonld": "application/ld+json",
|
|
168
|
+
"jsonml": "application/jsonml+json",
|
|
169
|
+
"jsx": "text/jsx",
|
|
170
|
+
"jt": "model/jt",
|
|
171
|
+
"jxl": "image/jxl",
|
|
172
|
+
"jxr": "image/jxr",
|
|
173
|
+
"jxra": "image/jxra",
|
|
174
|
+
"jxrs": "image/jxrs",
|
|
175
|
+
"jxs": "image/jxs",
|
|
176
|
+
"jxsc": "image/jxsc",
|
|
177
|
+
"jxsi": "image/jxsi",
|
|
178
|
+
"jxss": "image/jxss",
|
|
179
|
+
"kar": "audio/midi",
|
|
180
|
+
"ktx": "image/ktx",
|
|
181
|
+
"ktx2": "image/ktx2",
|
|
182
|
+
"less": "text/less",
|
|
183
|
+
"lgr": "application/lgr+xml",
|
|
184
|
+
"list": "text/plain",
|
|
185
|
+
"litcoffee": "text/coffeescript",
|
|
186
|
+
"log": "text/plain",
|
|
187
|
+
"lostxml": "application/lost+xml",
|
|
188
|
+
"lrf": "application/octet-stream",
|
|
189
|
+
"m1v": "video/mpeg",
|
|
190
|
+
"m21": "application/mp21",
|
|
191
|
+
"m2a": "audio/mpeg",
|
|
192
|
+
"m2t": "video/mp2t",
|
|
193
|
+
"m2ts": "video/mp2t",
|
|
194
|
+
"m2v": "video/mpeg",
|
|
195
|
+
"m3a": "audio/mpeg",
|
|
196
|
+
"m4a": "audio/mp4",
|
|
197
|
+
"m4p": "application/mp4",
|
|
198
|
+
"m4s": "video/iso.segment",
|
|
199
|
+
"ma": "application/mathematica",
|
|
200
|
+
"mads": "application/mads+xml",
|
|
201
|
+
"maei": "application/mmt-aei+xml",
|
|
202
|
+
"man": "text/troff",
|
|
203
|
+
"manifest": "text/cache-manifest",
|
|
204
|
+
"map": "application/json",
|
|
205
|
+
"mar": "application/octet-stream",
|
|
206
|
+
"markdown": "text/markdown",
|
|
207
|
+
"mathml": "application/mathml+xml",
|
|
208
|
+
"mb": "application/mathematica",
|
|
209
|
+
"mbox": "application/mbox",
|
|
210
|
+
"md": "text/markdown",
|
|
211
|
+
"mdx": "text/mdx",
|
|
212
|
+
"me": "text/troff",
|
|
213
|
+
"mesh": "model/mesh",
|
|
214
|
+
"meta4": "application/metalink4+xml",
|
|
215
|
+
"metalink": "application/metalink+xml",
|
|
216
|
+
"mets": "application/mets+xml",
|
|
217
|
+
"mft": "application/rpki-manifest",
|
|
218
|
+
"mid": "audio/midi",
|
|
219
|
+
"midi": "audio/midi",
|
|
220
|
+
"mime": "message/rfc822",
|
|
221
|
+
"mj2": "video/mj2",
|
|
222
|
+
"mjp2": "video/mj2",
|
|
223
|
+
"mjs": "text/javascript",
|
|
224
|
+
"mml": "text/mathml",
|
|
225
|
+
"mods": "application/mods+xml",
|
|
226
|
+
"mov": "video/quicktime",
|
|
227
|
+
"mp2": "audio/mpeg",
|
|
228
|
+
"mp21": "application/mp21",
|
|
229
|
+
"mp2a": "audio/mpeg",
|
|
230
|
+
"mp3": "audio/mpeg",
|
|
231
|
+
"mp4": "video/mp4",
|
|
232
|
+
"mp4a": "audio/mp4",
|
|
233
|
+
"mp4s": "application/mp4",
|
|
234
|
+
"mp4v": "video/mp4",
|
|
235
|
+
"mpd": "application/dash+xml",
|
|
236
|
+
"mpe": "video/mpeg",
|
|
237
|
+
"mpeg": "video/mpeg",
|
|
238
|
+
"mpf": "application/media-policy-dataset+xml",
|
|
239
|
+
"mpg": "video/mpeg",
|
|
240
|
+
"mpg4": "video/mp4",
|
|
241
|
+
"mpga": "audio/mpeg",
|
|
242
|
+
"mpp": "application/dash-patch+xml",
|
|
243
|
+
"mrc": "application/marc",
|
|
244
|
+
"mrcx": "application/marcxml+xml",
|
|
245
|
+
"ms": "text/troff",
|
|
246
|
+
"mscml": "application/mediaservercontrol+xml",
|
|
247
|
+
"msh": "model/mesh",
|
|
248
|
+
"msi": "application/octet-stream",
|
|
249
|
+
"msix": "application/msix",
|
|
250
|
+
"msixbundle": "application/msixbundle",
|
|
251
|
+
"msm": "application/octet-stream",
|
|
252
|
+
"msp": "application/octet-stream",
|
|
253
|
+
"mtl": "model/mtl",
|
|
254
|
+
"mts": "video/mp2t",
|
|
255
|
+
"musd": "application/mmt-usd+xml",
|
|
256
|
+
"mxf": "application/mxf",
|
|
257
|
+
"mxmf": "audio/mobile-xmf",
|
|
258
|
+
"mxml": "application/xv+xml",
|
|
259
|
+
"n3": "text/n3",
|
|
260
|
+
"nb": "application/mathematica",
|
|
261
|
+
"nq": "application/n-quads",
|
|
262
|
+
"nt": "application/n-triples",
|
|
263
|
+
"obj": "model/obj",
|
|
264
|
+
"oda": "application/oda",
|
|
265
|
+
"oga": "audio/ogg",
|
|
266
|
+
"ogg": "audio/ogg",
|
|
267
|
+
"ogv": "video/ogg",
|
|
268
|
+
"ogx": "application/ogg",
|
|
269
|
+
"omdoc": "application/omdoc+xml",
|
|
270
|
+
"onepkg": "application/onenote",
|
|
271
|
+
"onetmp": "application/onenote",
|
|
272
|
+
"onetoc": "application/onenote",
|
|
273
|
+
"onetoc2": "application/onenote",
|
|
274
|
+
"opf": "application/oebps-package+xml",
|
|
275
|
+
"opus": "audio/ogg",
|
|
276
|
+
"otf": "font/otf",
|
|
277
|
+
"owl": "application/rdf+xml",
|
|
278
|
+
"oxps": "application/oxps",
|
|
279
|
+
"p10": "application/pkcs10",
|
|
280
|
+
"p7c": "application/pkcs7-mime",
|
|
281
|
+
"p7m": "application/pkcs7-mime",
|
|
282
|
+
"p7s": "application/pkcs7-signature",
|
|
283
|
+
"p8": "application/pkcs8",
|
|
284
|
+
"pdf": "application/pdf",
|
|
285
|
+
"pfr": "application/font-tdpfr",
|
|
286
|
+
"pgp": "application/pgp-encrypted",
|
|
287
|
+
"pkg": "application/octet-stream",
|
|
288
|
+
"pki": "application/pkixcmp",
|
|
289
|
+
"pkipath": "application/pkix-pkipath",
|
|
290
|
+
"pls": "application/pls+xml",
|
|
291
|
+
"png": "image/png",
|
|
292
|
+
"prc": "model/prc",
|
|
293
|
+
"prf": "application/pics-rules",
|
|
294
|
+
"provx": "application/provenance+xml",
|
|
295
|
+
"ps": "application/postscript",
|
|
296
|
+
"pskcxml": "application/pskc+xml",
|
|
297
|
+
"pti": "image/prs.pti",
|
|
298
|
+
"qt": "video/quicktime",
|
|
299
|
+
"raml": "application/raml+yaml",
|
|
300
|
+
"rapd": "application/route-apd+xml",
|
|
301
|
+
"rdf": "application/rdf+xml",
|
|
302
|
+
"relo": "application/p2p-overlay+xml",
|
|
303
|
+
"rif": "application/reginfo+xml",
|
|
304
|
+
"rl": "application/resource-lists+xml",
|
|
305
|
+
"rld": "application/resource-lists-diff+xml",
|
|
306
|
+
"rmi": "audio/midi",
|
|
307
|
+
"rnc": "application/relax-ng-compact-syntax",
|
|
308
|
+
"rng": "application/xml",
|
|
309
|
+
"roa": "application/rpki-roa",
|
|
310
|
+
"roff": "text/troff",
|
|
311
|
+
"rq": "application/sparql-query",
|
|
312
|
+
"rs": "application/rls-services+xml",
|
|
313
|
+
"rsat": "application/atsc-rsat+xml",
|
|
314
|
+
"rsd": "application/rsd+xml",
|
|
315
|
+
"rsheet": "application/urc-ressheet+xml",
|
|
316
|
+
"rss": "application/rss+xml",
|
|
317
|
+
"rtf": "text/rtf",
|
|
318
|
+
"rtx": "text/richtext",
|
|
319
|
+
"rusd": "application/route-usd+xml",
|
|
320
|
+
"s3m": "audio/s3m",
|
|
321
|
+
"sbml": "application/sbml+xml",
|
|
322
|
+
"scq": "application/scvp-cv-request",
|
|
323
|
+
"scs": "application/scvp-cv-response",
|
|
324
|
+
"sdp": "application/sdp",
|
|
325
|
+
"senmlx": "application/senml+xml",
|
|
326
|
+
"sensmlx": "application/sensml+xml",
|
|
327
|
+
"ser": "application/java-serialized-object",
|
|
328
|
+
"setpay": "application/set-payment-initiation",
|
|
329
|
+
"setreg": "application/set-registration-initiation",
|
|
330
|
+
"sgi": "image/sgi",
|
|
331
|
+
"sgm": "text/sgml",
|
|
332
|
+
"sgml": "text/sgml",
|
|
333
|
+
"shex": "text/shex",
|
|
334
|
+
"shf": "application/shf+xml",
|
|
335
|
+
"shtml": "text/html",
|
|
336
|
+
"sieve": "application/sieve",
|
|
337
|
+
"sig": "application/pgp-signature",
|
|
338
|
+
"sil": "audio/silk",
|
|
339
|
+
"silo": "model/mesh",
|
|
340
|
+
"siv": "application/sieve",
|
|
341
|
+
"slim": "text/slim",
|
|
342
|
+
"slm": "text/slim",
|
|
343
|
+
"sls": "application/route-s-tsid+xml",
|
|
344
|
+
"smi": "application/smil+xml",
|
|
345
|
+
"smil": "application/smil+xml",
|
|
346
|
+
"snd": "audio/basic",
|
|
347
|
+
"so": "application/octet-stream",
|
|
348
|
+
"spdx": "text/spdx",
|
|
349
|
+
"spp": "application/scvp-vp-response",
|
|
350
|
+
"spq": "application/scvp-vp-request",
|
|
351
|
+
"spx": "audio/ogg",
|
|
352
|
+
"sql": "application/sql",
|
|
353
|
+
"sru": "application/sru+xml",
|
|
354
|
+
"srx": "application/sparql-results+xml",
|
|
355
|
+
"ssdl": "application/ssdl+xml",
|
|
356
|
+
"ssml": "application/ssml+xml",
|
|
357
|
+
"stk": "application/hyperstudio",
|
|
358
|
+
"stl": "model/stl",
|
|
359
|
+
"stpx": "model/step+xml",
|
|
360
|
+
"stpxz": "model/step-xml+zip",
|
|
361
|
+
"stpz": "model/step+zip",
|
|
362
|
+
"styl": "text/stylus",
|
|
363
|
+
"stylus": "text/stylus",
|
|
364
|
+
"svg": "image/svg+xml",
|
|
365
|
+
"svgz": "image/svg+xml",
|
|
366
|
+
"swidtag": "application/swid+xml",
|
|
367
|
+
"t": "text/troff",
|
|
368
|
+
"t38": "image/t38",
|
|
369
|
+
"td": "application/urc-targetdesc+xml",
|
|
370
|
+
"tei": "application/tei+xml",
|
|
371
|
+
"teicorpus": "application/tei+xml",
|
|
372
|
+
"text": "text/plain",
|
|
373
|
+
"tfi": "application/thraud+xml",
|
|
374
|
+
"tfx": "image/tiff-fx",
|
|
375
|
+
"tif": "image/tiff",
|
|
376
|
+
"tiff": "image/tiff",
|
|
377
|
+
"toml": "application/toml",
|
|
378
|
+
"tr": "text/troff",
|
|
379
|
+
"trig": "application/trig",
|
|
380
|
+
"ts": "video/mp2t",
|
|
381
|
+
"tsd": "application/timestamped-data",
|
|
382
|
+
"tsv": "text/tab-separated-values",
|
|
383
|
+
"ttc": "font/collection",
|
|
384
|
+
"ttf": "font/ttf",
|
|
385
|
+
"ttl": "text/turtle",
|
|
386
|
+
"ttml": "application/ttml+xml",
|
|
387
|
+
"txt": "text/plain",
|
|
388
|
+
"u3d": "model/u3d",
|
|
389
|
+
"u8dsn": "message/global-delivery-status",
|
|
390
|
+
"u8hdr": "message/global-headers",
|
|
391
|
+
"u8mdn": "message/global-disposition-notification",
|
|
392
|
+
"u8msg": "message/global",
|
|
393
|
+
"ubj": "application/ubjson",
|
|
394
|
+
"uri": "text/uri-list",
|
|
395
|
+
"uris": "text/uri-list",
|
|
396
|
+
"urls": "text/uri-list",
|
|
397
|
+
"vcard": "text/vcard",
|
|
398
|
+
"vrml": "model/vrml",
|
|
399
|
+
"vtt": "text/vtt",
|
|
400
|
+
"vxml": "application/voicexml+xml",
|
|
401
|
+
"war": "application/java-archive",
|
|
402
|
+
"wasm": "application/wasm",
|
|
403
|
+
"wav": "audio/wav",
|
|
404
|
+
"weba": "audio/webm",
|
|
405
|
+
"webm": "video/webm",
|
|
406
|
+
"webmanifest": "application/manifest+json",
|
|
407
|
+
"webp": "image/webp",
|
|
408
|
+
"wgsl": "text/wgsl",
|
|
409
|
+
"wgt": "application/widget",
|
|
410
|
+
"wif": "application/watcherinfo+xml",
|
|
411
|
+
"wmf": "image/wmf",
|
|
412
|
+
"woff": "font/woff",
|
|
413
|
+
"woff2": "font/woff2",
|
|
414
|
+
"wrl": "model/vrml",
|
|
415
|
+
"wsdl": "application/wsdl+xml",
|
|
416
|
+
"wspolicy": "application/wspolicy+xml",
|
|
417
|
+
"x3d": "model/x3d+xml",
|
|
418
|
+
"x3db": "model/x3d+fastinfoset",
|
|
419
|
+
"x3dbz": "model/x3d+binary",
|
|
420
|
+
"x3dv": "model/x3d-vrml",
|
|
421
|
+
"x3dvz": "model/x3d+vrml",
|
|
422
|
+
"x3dz": "model/x3d+xml",
|
|
423
|
+
"xaml": "application/xaml+xml",
|
|
424
|
+
"xav": "application/xcap-att+xml",
|
|
425
|
+
"xca": "application/xcap-caps+xml",
|
|
426
|
+
"xcs": "application/calendar+xml",
|
|
427
|
+
"xdf": "application/xcap-diff+xml",
|
|
428
|
+
"xdssc": "application/dssc+xml",
|
|
429
|
+
"xel": "application/xcap-el+xml",
|
|
430
|
+
"xenc": "application/xenc+xml",
|
|
431
|
+
"xer": "application/patch-ops-error+xml",
|
|
432
|
+
"xfdf": "application/xfdf",
|
|
433
|
+
"xht": "application/xhtml+xml",
|
|
434
|
+
"xhtml": "application/xhtml+xml",
|
|
435
|
+
"xhvml": "application/xv+xml",
|
|
436
|
+
"xlf": "application/xliff+xml",
|
|
437
|
+
"xm": "audio/xm",
|
|
438
|
+
"xml": "text/xml",
|
|
439
|
+
"xns": "application/xcap-ns+xml",
|
|
440
|
+
"xop": "application/xop+xml",
|
|
441
|
+
"xpl": "application/xproc+xml",
|
|
442
|
+
"xsd": "application/xml",
|
|
443
|
+
"xsf": "application/prs.xsf+xml",
|
|
444
|
+
"xsl": "application/xml",
|
|
445
|
+
"xslt": "application/xml",
|
|
446
|
+
"xspf": "application/xspf+xml",
|
|
447
|
+
"xvm": "application/xv+xml",
|
|
448
|
+
"xvml": "application/xv+xml",
|
|
449
|
+
"yaml": "text/yaml",
|
|
450
|
+
"yang": "application/yang",
|
|
451
|
+
"yin": "application/yin+xml",
|
|
452
|
+
"yml": "text/yaml",
|
|
453
|
+
"zip": "application/zip"
|
|
454
|
+
};
|
|
455
|
+
function lookup(extn) {
|
|
456
|
+
let tmp = ("" + extn).trim().toLowerCase();
|
|
457
|
+
let idx = tmp.lastIndexOf(".");
|
|
458
|
+
return mimes[!~idx ? tmp : tmp.substring(++idx)];
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/stacks/tanstack/mcp-app-sources.ts
|
|
462
|
+
function withoutQuery(id) {
|
|
463
|
+
return id.split(/[?#]/, 1)[0];
|
|
464
|
+
}
|
|
465
|
+
function isUnder(parent, child) {
|
|
466
|
+
return child === parent || child.startsWith(parent + "/");
|
|
467
|
+
}
|
|
468
|
+
var AppSources = class {
|
|
469
|
+
dependencies;
|
|
470
|
+
root;
|
|
471
|
+
input;
|
|
472
|
+
roots;
|
|
473
|
+
label;
|
|
474
|
+
constructor(root, input, dependencies) {
|
|
475
|
+
this.dependencies = dependencies;
|
|
476
|
+
this.root = (0, vite.normalizePath)(node_fs.realpathSync.native(root));
|
|
477
|
+
this.input = (0, vite.normalizePath)(node_fs.realpathSync.native(input));
|
|
478
|
+
this.label = (0, vite.normalizePath)((0, node_path.relative)(this.root, input));
|
|
479
|
+
const view = (0, vite.normalizePath)((0, node_path.relative)(node_path.posix.join(this.root, "src/lib/mcp/apps"), this.input)).split("/");
|
|
480
|
+
if (view.length < 2 || view[0] === ".." || node_path.posix.isAbsolute(view[0])) throw this.error("The HTML entry must be inside src/lib/mcp/apps/<name>/; move the view into that folder.");
|
|
481
|
+
this.roots = [node_path.posix.join(this.root, "src/lib/mcp/apps", view[0]), node_path.posix.join(this.root, "src/browser")];
|
|
482
|
+
this.file(this.input);
|
|
483
|
+
}
|
|
484
|
+
error(message) {
|
|
485
|
+
return /* @__PURE__ */ new Error(`@lovable.dev/mcp-js: MCP App ${this.label}: ${message}`);
|
|
486
|
+
}
|
|
487
|
+
isDependency(file) {
|
|
488
|
+
const packagePath = file.slice(file.lastIndexOf("/node_modules/") + 14);
|
|
489
|
+
return file.includes("/node_modules/") && !packagePath.startsWith(".") && (!isUnder(this.root, file) || isUnder(node_path.posix.join(this.root, "node_modules"), file));
|
|
490
|
+
}
|
|
491
|
+
file(path, importer = this.input) {
|
|
492
|
+
const file = (0, vite.normalizePath)(node_fs.realpathSync.native(withoutQuery(path)));
|
|
493
|
+
if (isUnder(this.root, file) && !this.isDependency(file)) this.dependencies.add(file);
|
|
494
|
+
if (this.isDependency(file)) return file;
|
|
495
|
+
const reason = /\.server\.[^.]+$/.test(file) ? "is a *.server.* module" : this.roots.some((root) => isUnder(root, file)) ? void 0 : "is outside the permitted browser sources";
|
|
496
|
+
if (reason) throw this.error(`${(0, vite.normalizePath)((0, node_path.relative)(this.root, withoutQuery(importer)))} imports ${(0, vite.normalizePath)((0, node_path.relative)(this.root, file))}, which ${reason}. Move shared browser code, styles and assets into src/browser/, or keep them inside this view's folder. Server-side code must stay outside both.`);
|
|
497
|
+
return file;
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/stacks/tanstack/mcp-app-assets.ts
|
|
502
|
+
function isExternal(url) {
|
|
503
|
+
return /^([a-z]+:)?\/\//.test(url) || /^\s*data:/i.test(url) || url.startsWith("#");
|
|
504
|
+
}
|
|
505
|
+
const META_ASSETS = /* @__PURE__ */ new Set([
|
|
506
|
+
"msapplication-tileimage",
|
|
507
|
+
"msapplication-square70x70logo",
|
|
508
|
+
"msapplication-square150x150logo",
|
|
509
|
+
"msapplication-wide310x150logo",
|
|
510
|
+
"msapplication-square310x310logo",
|
|
511
|
+
"msapplication-config",
|
|
512
|
+
"twitter:image",
|
|
513
|
+
"og:image",
|
|
514
|
+
"og:image:url",
|
|
515
|
+
"og:image:secure_url",
|
|
516
|
+
"og:audio",
|
|
517
|
+
"og:audio:secure_url",
|
|
518
|
+
"og:video",
|
|
519
|
+
"og:video:secure_url"
|
|
520
|
+
]);
|
|
521
|
+
function assetDataUrl(sources, id, importer) {
|
|
522
|
+
const file = sources.file(id, importer);
|
|
523
|
+
const fragment = id.includes("#") ? id.slice(id.indexOf("#")) : "";
|
|
524
|
+
return `data:${lookup(file) ?? "application/octet-stream"};base64,${(0, node_fs.readFileSync)(file).toString("base64")}${fragment}`;
|
|
525
|
+
}
|
|
526
|
+
function appAssets(sources) {
|
|
527
|
+
let resolve;
|
|
528
|
+
return {
|
|
529
|
+
name: "@lovable.dev/mcp-js:mcp-app-assets",
|
|
530
|
+
enforce: "pre",
|
|
531
|
+
configResolved(config) {
|
|
532
|
+
resolve = config.createResolver();
|
|
533
|
+
},
|
|
534
|
+
transformIndexHtml: {
|
|
535
|
+
order: "pre",
|
|
536
|
+
async handler(html) {
|
|
537
|
+
const { parse } = await Promise.resolve().then(() => require("../../dist-CqY2qXpc.cjs"));
|
|
538
|
+
const visit = async (node) => {
|
|
539
|
+
if ("tagName" in node) {
|
|
540
|
+
const attrs = Object.fromEntries(node.attrs.map((attr) => [attr.name, attr.value]));
|
|
541
|
+
if (node.tagName === "base" || node.tagName === "style" || "style" in attrs) throw sources.error("HTML base URLs and inline CSS are unsupported. Put CSS in an imported stylesheet and assets in browser sources.");
|
|
542
|
+
if (node.tagName === "script" && attrs.type !== "module") throw sources.error("Use a type=module script entry for the MCP App; classic scripts are not bundled.");
|
|
543
|
+
for (const attr of node.attrs) {
|
|
544
|
+
if (attr.name === "srcset" || attr.name === "imagesrcset") throw sources.error("HTML srcset is unsupported. Import images in JavaScript and pass their bundled URLs to the component.");
|
|
545
|
+
if (node.tagName === "a" && attr.name === "href") continue;
|
|
546
|
+
if (!([
|
|
547
|
+
"src",
|
|
548
|
+
"href",
|
|
549
|
+
"poster",
|
|
550
|
+
"data",
|
|
551
|
+
"background"
|
|
552
|
+
].includes(attr.name) || node.tagName === "meta" && attr.name === "content" && [attrs.name, attrs.property].some((value) => META_ASSETS.has(value?.trim().toLowerCase()))) || isExternal(attr.value)) continue;
|
|
553
|
+
if (!(node.tagName === "script" && attr.name === "src" || node.tagName === "link" && attrs.rel === "stylesheet" && attr.name === "href")) throw sources.error(`HTML ${node.tagName}[${attr.name}] references local asset ${attr.value}. Import assets in JavaScript or CSS instead.`);
|
|
554
|
+
const file = await resolve(attr.value, sources.input);
|
|
555
|
+
if (!file) throw sources.error(`Cannot resolve HTML entry ${attr.value}.`);
|
|
556
|
+
sources.file(file);
|
|
557
|
+
}
|
|
558
|
+
if (node.tagName === "template" && "content" in node) await visit(node.content);
|
|
559
|
+
}
|
|
560
|
+
if ("childNodes" in node) for (const child of node.childNodes) await visit(child);
|
|
561
|
+
};
|
|
562
|
+
await visit(parse(html, { scriptingEnabled: false }));
|
|
563
|
+
return html;
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
async transform(code, id) {
|
|
567
|
+
if (id === "\0vite/preload-helper.js") return null;
|
|
568
|
+
const path = withoutQuery(id);
|
|
569
|
+
if (!/\.[cm]?[jt]sx?$/.test(path) && !id.includes("html-proxy")) return null;
|
|
570
|
+
const compiled = await (0, esbuild.transform)(code, {
|
|
571
|
+
loader: path.endsWith(".tsx") ? "tsx" : /\.[cm]?ts$/.test(path) ? "ts" : path.endsWith(".jsx") ? "jsx" : "js",
|
|
572
|
+
sourcefile: path,
|
|
573
|
+
jsx: "automatic",
|
|
574
|
+
target: "esnext",
|
|
575
|
+
tsconfigRaw: {}
|
|
576
|
+
});
|
|
577
|
+
const edits = [];
|
|
578
|
+
const { asyncWalk } = await Promise.resolve().then(() => require("../../src-D7RtXSV0.cjs"));
|
|
579
|
+
await asyncWalk(this.parse(compiled.code), { enter: async (node) => {
|
|
580
|
+
if (node.type !== "NewExpression" || node.callee.type !== "Identifier" || node.callee.name !== "URL") return;
|
|
581
|
+
const base = node.arguments[1];
|
|
582
|
+
if (base?.type !== "MemberExpression" || base.object.type !== "MetaProperty" || base.object.meta.name !== "import" || base.object.property.name !== "meta" || base.property.type !== "Identifier" || base.property.name !== "url") return;
|
|
583
|
+
const argument = node.arguments[0];
|
|
584
|
+
const url = argument?.type === "Literal" && typeof argument.value === "string" ? argument.value : argument?.type === "TemplateLiteral" && argument.expressions.length === 0 ? argument.quasis[0].value.cooked : void 0;
|
|
585
|
+
if (url === void 0 || url === null) throw sources.error(`${path}: new URL assets must use a literal path. Import the asset explicitly instead.`);
|
|
586
|
+
if (isExternal(url)) return;
|
|
587
|
+
const resolved = await this.resolve(url, id);
|
|
588
|
+
if (!resolved || resolved.external) throw sources.error(`${path}: cannot bundle asset ${url}.`);
|
|
589
|
+
const file = sources.file(resolved.id, path);
|
|
590
|
+
if (/\.[cm]?[jt]sx?$/.test(file)) throw sources.error(`${path}: worker/script asset URLs are unsupported. Import browser modules directly.`);
|
|
591
|
+
const data = assetDataUrl(sources, resolved.id, path);
|
|
592
|
+
const { start, end } = node;
|
|
593
|
+
edits.push({
|
|
594
|
+
start,
|
|
595
|
+
end,
|
|
596
|
+
text: `new URL(${JSON.stringify(data)})`
|
|
597
|
+
});
|
|
598
|
+
} });
|
|
599
|
+
let output = compiled.code;
|
|
600
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
|
|
601
|
+
return {
|
|
602
|
+
code: output,
|
|
603
|
+
map: null
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/stacks/tanstack/mcp-app-inline.ts
|
|
610
|
+
const JS_FILE = /\.[mc]?js$/;
|
|
611
|
+
const CSS_FILE = /\.css$/;
|
|
612
|
+
const HTML_FILE = /\.html?$/;
|
|
613
|
+
function escapeForRegExp(value) {
|
|
614
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
615
|
+
}
|
|
616
|
+
function replaceScript(html, scriptFileName, code) {
|
|
617
|
+
const file = escapeForRegExp(scriptFileName);
|
|
618
|
+
const script = new RegExp(`<script([^>]*?) src="(?:[^"]*?/)?${file}"([^>]*)><\/script>`);
|
|
619
|
+
const inlineCode = code.replace(/"?__VITE_PRELOAD__"?/g, "void 0").replace(/<(\/script(?=[\t\n\f\r />])|!--)/gi, "\\x3C$1");
|
|
620
|
+
return html.replace(script, (_, before, after) => `<script${before}${after}>${inlineCode.trim()}<\/script>`);
|
|
621
|
+
}
|
|
622
|
+
function replaceCss(html, cssFileName, css) {
|
|
623
|
+
const file = escapeForRegExp(cssFileName);
|
|
624
|
+
const link = new RegExp(`<link([^>]*?) href="(?:[^"]*?/)?${file}"([^>]*)>`);
|
|
625
|
+
const inlineCss = css.replace("@charset \"UTF-8\";", "").replace(/<(?=\/style[\t\n\f\r />])/gi, "\\3c ");
|
|
626
|
+
return html.replace(link, (_, before, after) => `<style${before}${after}>${inlineCss.trim()}</style>`);
|
|
627
|
+
}
|
|
628
|
+
function isAsset(item) {
|
|
629
|
+
return item.type === "asset";
|
|
630
|
+
}
|
|
631
|
+
function inlineIntoSingleHtml(appLabel) {
|
|
632
|
+
return {
|
|
633
|
+
name: "@lovable.dev/mcp-js:mcp-app-inline",
|
|
634
|
+
enforce: "post",
|
|
635
|
+
async generateBundle(_options, bundle) {
|
|
636
|
+
const { walk } = await Promise.resolve().then(() => require("../../src-D7RtXSV0.cjs"));
|
|
637
|
+
const names = Object.keys(bundle);
|
|
638
|
+
const htmlNames = names.filter((name) => HTML_FILE.test(name));
|
|
639
|
+
if (htmlNames.length !== 1) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel} produced ${htmlNames.length} HTML documents; expected exactly one`);
|
|
640
|
+
const htmlAsset = bundle[htmlNames[0]];
|
|
641
|
+
if (!isAsset(htmlAsset) || typeof htmlAsset.source !== "string") throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel} HTML output is not a text asset`);
|
|
642
|
+
let html = htmlAsset.source;
|
|
643
|
+
const leftovers = [];
|
|
644
|
+
for (const name of names) {
|
|
645
|
+
if (name === htmlAsset.fileName) continue;
|
|
646
|
+
const item = bundle[name];
|
|
647
|
+
const before = html;
|
|
648
|
+
if (JS_FILE.test(name) && !isAsset(item)) {
|
|
649
|
+
walk(this.parse(item.code), { enter(node) {
|
|
650
|
+
if (node.type === "ImportDeclaration" || node.type === "ImportExpression" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel}: import or dynamic import cannot be resolved statically into the view. Use a literal local import so the module is bundled.`);
|
|
651
|
+
} });
|
|
652
|
+
html = replaceScript(html, item.fileName, item.code);
|
|
653
|
+
} else if (CSS_FILE.test(name) && isAsset(item) && typeof item.source === "string") html = replaceCss(html, item.fileName, item.source);
|
|
654
|
+
if (html === before) leftovers.push(name);
|
|
655
|
+
else delete bundle[name];
|
|
656
|
+
}
|
|
657
|
+
if (leftovers.length > 0) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel} emitted files that cannot be inlined into its HTML: ${leftovers.join(", ")}. Import assets from JS/CSS so they are inlined as data URLs, and reference exactly one script from index.html.`);
|
|
658
|
+
htmlAsset.source = html;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
//#endregion
|
|
663
|
+
//#region src/stacks/tanstack/mcp-app-styles.ts
|
|
664
|
+
async function projectTailwind(root) {
|
|
665
|
+
const require = (0, node_module.createRequire)((0, node_url.pathToFileURL)(node_path.posix.join(root, "package.json")));
|
|
666
|
+
let entry;
|
|
667
|
+
try {
|
|
668
|
+
entry = require.resolve("@tailwindcss/vite");
|
|
669
|
+
} catch (error) {
|
|
670
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const tooling = (0, node_module.createRequire)(entry);
|
|
674
|
+
const compiler = await import((0, node_url.pathToFileURL)(tooling.resolve("@tailwindcss/node")).href);
|
|
675
|
+
const oxide = await import((0, node_url.pathToFileURL)(tooling.resolve("@tailwindcss/oxide")).href);
|
|
676
|
+
return {
|
|
677
|
+
compile: compiler.compile,
|
|
678
|
+
Scanner: oxide.Scanner
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
function scanInputs(sources) {
|
|
682
|
+
const inputs = [];
|
|
683
|
+
const visit = (directory) => {
|
|
684
|
+
let entries;
|
|
685
|
+
try {
|
|
686
|
+
entries = (0, node_fs.readdirSync)(sources.file(directory), { withFileTypes: true });
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (error.code === "ENOENT") return;
|
|
689
|
+
throw error;
|
|
690
|
+
}
|
|
691
|
+
for (const entry of entries) {
|
|
692
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
693
|
+
const file = node_path.posix.join(directory, entry.name);
|
|
694
|
+
if (entry.isSymbolicLink()) throw sources.error(`Symlink ${file} is not supported; use real browser source files.`);
|
|
695
|
+
if (entry.isDirectory()) visit(file);
|
|
696
|
+
else if (/\.(?:[cm]?[jt]sx?|html?|css)$/.test(entry.name)) inputs.push({
|
|
697
|
+
content: (0, node_fs.readFileSync)(sources.file(file), "utf8"),
|
|
698
|
+
extension: node_path.posix.extname(file).slice(1)
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
for (const root of sources.roots) visit(root);
|
|
703
|
+
return inputs;
|
|
704
|
+
}
|
|
705
|
+
async function appStyles(sources) {
|
|
706
|
+
const { bundleAsync } = await import("lightningcss").catch((error) => {
|
|
707
|
+
if (!["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"].includes(error.code ?? "") || !/^Cannot find (?:package|module) ['"]lightningcss['"]/.test(error.message)) throw error;
|
|
708
|
+
throw sources.error("MCP Apps compilation requires Lightning CSS. Install it with: bun add -D lightningcss@^1.33.0");
|
|
709
|
+
});
|
|
710
|
+
const tailwind = await projectTailwind(sources.root);
|
|
711
|
+
let candidates;
|
|
712
|
+
let resolve;
|
|
713
|
+
const resolveFile = async (id, importer) => {
|
|
714
|
+
const file = await resolve(id, importer);
|
|
715
|
+
if (!file) throw sources.error(`Cannot resolve CSS input ${id} from ${importer}.`);
|
|
716
|
+
sources.file(file, importer);
|
|
717
|
+
return file;
|
|
718
|
+
};
|
|
719
|
+
return {
|
|
720
|
+
name: "@lovable.dev/mcp-js:mcp-app-styles",
|
|
721
|
+
enforce: "pre",
|
|
722
|
+
configResolved(config) {
|
|
723
|
+
resolve = config.createResolver({
|
|
724
|
+
extensions: [".css"],
|
|
725
|
+
mainFields: ["style"],
|
|
726
|
+
conditions: ["style"],
|
|
727
|
+
preferRelative: true
|
|
728
|
+
});
|
|
729
|
+
},
|
|
730
|
+
async transform(code, id) {
|
|
731
|
+
const path = withoutQuery(id);
|
|
732
|
+
if (/\.(?:scss|sass|less|styl|stylus|pcss|postcss)$/.test(path) || path.endsWith(".module.css")) throw sources.error(`${path}: use plain CSS or CSS-first Tailwind v4, not CSS modules or preprocessors.`);
|
|
733
|
+
if (!path.endsWith(".css")) return null;
|
|
734
|
+
if (id !== path && id !== `${path}?inline`) throw sources.error(`${id}: import the stylesheet directly, or use ?inline for compiled CSS.`);
|
|
735
|
+
const input = sources.file(path);
|
|
736
|
+
const result = await bundleAsync({
|
|
737
|
+
filename: input,
|
|
738
|
+
analyzeDependencies: { preserveImports: true },
|
|
739
|
+
visitor: { Function(fn) {
|
|
740
|
+
if (!/^(?:-webkit-)?image-set$/i.test(fn.name)) return;
|
|
741
|
+
if (fn.arguments.some((argument) => argument.type === "token" && argument.value.type === "string" && !isExternal(argument.value.value))) throw sources.error("Use local image-set() assets in a regular CSS declaration, not a custom property. Custom-property image-set() strings must use external or data URLs.");
|
|
742
|
+
} },
|
|
743
|
+
resolver: {
|
|
744
|
+
resolve: resolveFile,
|
|
745
|
+
async read(path) {
|
|
746
|
+
const file = sources.file(path, input);
|
|
747
|
+
const css = file === input ? code : (0, node_fs.readFileSync)(file, "utf8");
|
|
748
|
+
if (!tailwind) return css;
|
|
749
|
+
const compiled = await tailwind.compile(css, {
|
|
750
|
+
base: node_path.posix.dirname(file),
|
|
751
|
+
from: file,
|
|
752
|
+
shouldRewriteUrls: true,
|
|
753
|
+
onDependency: (dependency) => {
|
|
754
|
+
sources.file(dependency, file);
|
|
755
|
+
},
|
|
756
|
+
customCssResolver: (id, base) => resolveFile(id, node_path.posix.join(base, "index.css")),
|
|
757
|
+
customJsResolver: async (id, base) => {
|
|
758
|
+
const resolved = (0, node_module.createRequire)((0, node_url.pathToFileURL)(node_path.posix.join(base, "package.json"))).resolve(id);
|
|
759
|
+
const module = (0, vite.normalizePath)(node_fs.realpathSync.native(resolved));
|
|
760
|
+
if (!sources.isDependency(module)) throw sources.error(`${file}: project-local Tailwind @config/@plugin is unsupported. Move theme values and utilities into shared CSS; installed npm plugins are trusted.`);
|
|
761
|
+
return module;
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
if (compiled.sources.length > 0 || compiled.root !== null && compiled.root !== "none") throw sources.error(`${file}: filesystem @source and source(path) are unsupported in MCP App CSS. The compiler scans this view and src/browser/; share theme CSS, not the normal app's scanning entrypoint.`);
|
|
765
|
+
candidates ??= new tailwind.Scanner({}).scanFiles(scanInputs(sources));
|
|
766
|
+
return compiled.build(candidates);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
let css = Buffer.from(result.code).toString();
|
|
771
|
+
for (const dependency of result.dependencies ?? []) {
|
|
772
|
+
if (dependency.type !== "url" && dependency.type !== "import") continue;
|
|
773
|
+
const escaped = (!dependency.url || isExternal(dependency.url) ? dependency.url : assetDataUrl(sources, await resolveFile(dependency.url, dependency.loc.filePath), dependency.loc.filePath)).replace(/[\x00-\x1f\x7f"\\]/g, (char) => `\\${char.charCodeAt(0).toString(16)} `);
|
|
774
|
+
css = css.replaceAll(dependency.placeholder, escaped);
|
|
775
|
+
}
|
|
776
|
+
return {
|
|
777
|
+
code: css,
|
|
778
|
+
map: null
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/stacks/tanstack/mcp-app-build.ts
|
|
785
|
+
/** Import suffix that turns an `index.html` into its bundled single-file string. */
|
|
786
|
+
const MCP_APP_QUERY = "?mcp-app";
|
|
787
|
+
function inNodeModules(file) {
|
|
788
|
+
return file.split("/").includes("node_modules");
|
|
789
|
+
}
|
|
790
|
+
const NODE_BUILTINS = new Set(node_module.builtinModules);
|
|
791
|
+
const SERVER_ONLY_SPECIFIER = /^(?:@tanstack\/react-start|server-only)(?:\/|$)/;
|
|
792
|
+
const EMPTY_BROWSER_MODULE = "\0mcp-app-browser-empty";
|
|
793
|
+
const VITE_MAJOR = Number.parseInt(vite.version, 10);
|
|
794
|
+
function explicitlyDisabledForBrowser(source, importer) {
|
|
795
|
+
for (let dir = node_path.posix.dirname(withoutQuery(importer)); dir !== node_path.posix.dirname(dir); dir = node_path.posix.dirname(dir)) try {
|
|
796
|
+
const { browser } = JSON.parse((0, node_fs.readFileSync)(node_path.posix.join(dir, "package.json"), "utf8"));
|
|
797
|
+
if (!browser || typeof browser !== "object") return false;
|
|
798
|
+
return Object.entries(browser).some(([key, value]) => {
|
|
799
|
+
const normalized = node_path.posix.normalize(key);
|
|
800
|
+
return value === false && [normalized, normalized.replace(/(?:\.js|\/index\.js)$/, "")].includes(source);
|
|
801
|
+
});
|
|
802
|
+
} catch (error) {
|
|
803
|
+
if (error.code !== "ENOENT") throw error;
|
|
804
|
+
}
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
function importBoundary(sources) {
|
|
808
|
+
const { root: projectRoot, label: appLabel } = sources;
|
|
809
|
+
const rel = (p) => (0, vite.normalizePath)((0, node_path.relative)(projectRoot, p));
|
|
810
|
+
return {
|
|
811
|
+
name: "@lovable.dev/mcp-js:mcp-app-import-boundary",
|
|
812
|
+
enforce: "pre",
|
|
813
|
+
async resolveId(source, importer, options) {
|
|
814
|
+
if (!importer) return null;
|
|
815
|
+
const from = rel(withoutQuery(importer));
|
|
816
|
+
if (/[?&](?:sharedworker|worker)(?:[=&]|$)/.test(source)) throw sources.error(`${from}: worker imports are unsupported; keep the view in one browser bundle.`);
|
|
817
|
+
if ((source.startsWith("node:") || NODE_BUILTINS.has(source)) && !sources.isDependency(withoutQuery(importer))) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel}: ${from} imports the Node builtin "${source}", which does not exist in a browser view.`);
|
|
818
|
+
if (SERVER_ONLY_SPECIFIER.test(source)) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel}: ${from} imports "${source}", which is server-only and cannot run in a browser view.`);
|
|
819
|
+
const resolved = await this.resolve(source, importer, {
|
|
820
|
+
...options,
|
|
821
|
+
skipSelf: true
|
|
822
|
+
});
|
|
823
|
+
if (resolved?.external) throw sources.error(`${from}: import "${source}" cannot be resolved statically into the view.`);
|
|
824
|
+
if (!resolved || resolved.id.startsWith("\0")) return resolved;
|
|
825
|
+
if (resolved.id === "__vite-browser-external") {
|
|
826
|
+
if ((source.startsWith("node:") || NODE_BUILTINS.has(source)) && !explicitlyDisabledForBrowser(source, importer)) throw sources.error(`${from} imports unavailable Node builtin "${source}"`);
|
|
827
|
+
return {
|
|
828
|
+
...resolved,
|
|
829
|
+
id: EMPTY_BROWSER_MODULE
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
if (resolved.id.startsWith("__vite-browser-external:")) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel}: ${from} imports unavailable Node builtin "${source}"`);
|
|
833
|
+
sources.file(resolved.id, importer);
|
|
834
|
+
return resolved;
|
|
835
|
+
},
|
|
836
|
+
load(id) {
|
|
837
|
+
if (id === EMPTY_BROWSER_MODULE) return "export default {}";
|
|
838
|
+
if ((0, node_path.isAbsolute)(withoutQuery(id))) sources.file(id);
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function moduleTracker(projectRoot, sink) {
|
|
844
|
+
const track = (id) => {
|
|
845
|
+
if (id.startsWith("\0")) return;
|
|
846
|
+
const file = (0, vite.normalizePath)(withoutQuery(id));
|
|
847
|
+
if (isUnder(projectRoot, file) && !inNodeModules(file)) sink.add(file);
|
|
848
|
+
};
|
|
849
|
+
return {
|
|
850
|
+
name: "@lovable.dev/mcp-js:mcp-app-module-tracker",
|
|
851
|
+
moduleParsed(info) {
|
|
852
|
+
track(info.id);
|
|
853
|
+
},
|
|
854
|
+
buildEnd() {
|
|
855
|
+
for (const file of this.getWatchFiles?.() ?? []) track(file);
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
function singleChunkOutput() {
|
|
860
|
+
return VITE_MAJOR >= 8 ? { codeSplitting: false } : { inlineDynamicImports: true };
|
|
861
|
+
}
|
|
862
|
+
function flattenOutput(result) {
|
|
863
|
+
return (Array.isArray(result) ? result : "output" in result ? [result] : []).flatMap((o) => o.output).filter((item) => item.type === "asset");
|
|
864
|
+
}
|
|
865
|
+
async function buildMcpApp(projectRootPath, inputPath, dependencies) {
|
|
866
|
+
if (!/^[5-8]\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.test(vite.version)) throw new Error(`@lovable.dev/mcp-js: MCP App compilation requires Vite >=5.0.0 <9.0.0 (stable releases); resolved ${vite.version}. Preserve existing project pins; use a compatible build environment or explicitly agree a Vite change before compiling Apps.`);
|
|
867
|
+
const sources = new AppSources(projectRootPath, inputPath, dependencies);
|
|
868
|
+
const { root: projectRoot, input, label: appLabel } = sources;
|
|
869
|
+
const styles = await appStyles(sources);
|
|
870
|
+
const logger = (0, vite.createLogger)("silent");
|
|
871
|
+
const warnOnce = logger.warnOnce.bind(logger);
|
|
872
|
+
logger.warnOnce = (message, options) => {
|
|
873
|
+
if (message.includes("didn't resolve at build time")) throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel}: ${message}`);
|
|
874
|
+
warnOnce(message, options);
|
|
875
|
+
};
|
|
876
|
+
const assets = flattenOutput(await (0, vite.build)({
|
|
877
|
+
configFile: false,
|
|
878
|
+
root: projectRoot,
|
|
879
|
+
mode: "production",
|
|
880
|
+
logLevel: "silent",
|
|
881
|
+
customLogger: logger,
|
|
882
|
+
envPrefix: [],
|
|
883
|
+
envFile: false,
|
|
884
|
+
publicDir: false,
|
|
885
|
+
css: { transformer: "lightningcss" },
|
|
886
|
+
esbuild: VITE_MAJOR >= 8 ? false : { tsconfigRaw: "{\"compilerOptions\":{\"jsx\":\"react-jsx\"}}" },
|
|
887
|
+
...VITE_MAJOR >= 8 ? { oxc: false } : {},
|
|
888
|
+
resolve: {
|
|
889
|
+
alias: { "@": node_path.posix.join(projectRoot, "src") },
|
|
890
|
+
dedupe: [
|
|
891
|
+
"react",
|
|
892
|
+
"react-dom",
|
|
893
|
+
"react/jsx-runtime",
|
|
894
|
+
"react/jsx-dev-runtime"
|
|
895
|
+
]
|
|
896
|
+
},
|
|
897
|
+
build: {
|
|
898
|
+
write: false,
|
|
899
|
+
modulePreload: false,
|
|
900
|
+
cssCodeSplit: false,
|
|
901
|
+
assetsInlineLimit: Number.MAX_SAFE_INTEGER,
|
|
902
|
+
chunkSizeWarningLimit: Number.MAX_SAFE_INTEGER,
|
|
903
|
+
rollupOptions: {
|
|
904
|
+
input,
|
|
905
|
+
...VITE_MAJOR >= 8 ? { tsconfig: false } : {},
|
|
906
|
+
output: singleChunkOutput()
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
plugins: [
|
|
910
|
+
importBoundary(sources),
|
|
911
|
+
moduleTracker(projectRoot, dependencies),
|
|
912
|
+
appAssets(sources),
|
|
913
|
+
styles,
|
|
914
|
+
inlineIntoSingleHtml(appLabel)
|
|
915
|
+
]
|
|
916
|
+
}));
|
|
917
|
+
const html = assets.find((asset) => /\.html?$/.test(asset.fileName));
|
|
918
|
+
if (assets.length !== 1 || !html || typeof html.source !== "string") throw new Error(`@lovable.dev/mcp-js: MCP App ${appLabel} build did not produce a single HTML document`);
|
|
919
|
+
require_apps.assertAppServable({
|
|
920
|
+
name: appLabel,
|
|
921
|
+
html: html.source
|
|
922
|
+
});
|
|
923
|
+
return html.source;
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
10
926
|
//#region src/stacks/tanstack/vite.ts
|
|
11
927
|
const SUPABASE_PROJECT_REF_ENV = "VITE_SUPABASE_PROJECT_ID";
|
|
12
928
|
const GENERATED_BANNER = "// AUTO-GENERATED by @lovable.dev/mcp-js — do not edit. Regenerated by the Vite plugin.\n// To take ownership, delete this banner line; the plugin then leaves the file alone.";
|
|
@@ -84,12 +1000,12 @@ import { createFileRoute } from "@tanstack/react-router";
|
|
|
84
1000
|
|
|
85
1001
|
import { ${route.handlerFactory} } from "@lovable.dev/mcp-js/stacks/tanstack";
|
|
86
1002
|
|
|
87
|
-
|
|
1003
|
+
const loadMcp = () => import("${mcpImport}");
|
|
88
1004
|
|
|
89
1005
|
${routeOpen}
|
|
90
1006
|
${hasSitemapInventory ? " staticData: { sitemap: false },\n" : ""} server: {
|
|
91
1007
|
handlers: {
|
|
92
|
-
ANY: ${route.handlerFactory}(
|
|
1008
|
+
ANY: ${route.handlerFactory}(loadMcp, ${optionsObject}),
|
|
93
1009
|
},
|
|
94
1010
|
},
|
|
95
1011
|
});
|
|
@@ -182,6 +1098,8 @@ function mcpPlugin(options = {}) {
|
|
|
182
1098
|
let projectRoot = process.cwd();
|
|
183
1099
|
let mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
184
1100
|
let sitemapFile = (0, node_path.resolve)(projectRoot, "src/lib/sitemap.ts");
|
|
1101
|
+
const appBuilds = /* @__PURE__ */ new Map();
|
|
1102
|
+
let viteConfig;
|
|
185
1103
|
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
186
1104
|
const regenerate = () => {
|
|
187
1105
|
let mcpEntryExists = true;
|
|
@@ -222,20 +1140,34 @@ function mcpPlugin(options = {}) {
|
|
|
222
1140
|
if (!require_hooks.isFileMissing(err)) throw err;
|
|
223
1141
|
}
|
|
224
1142
|
};
|
|
1143
|
+
const skillPlugin = require_hooks.skillImportVitePlugin({ onServer(server) {
|
|
1144
|
+
const onChange = (file) => {
|
|
1145
|
+
if (normalizePath(file) === normalizePath(mcpEntry) || normalizePath(file) === normalizePath(sitemapFile)) regenerate();
|
|
1146
|
+
};
|
|
1147
|
+
const onViewChange = (file) => {
|
|
1148
|
+
if (!normalizePath(file).startsWith(`${normalizePath(projectRoot)}/src/`)) return;
|
|
1149
|
+
appBuilds.clear();
|
|
1150
|
+
if (server.environments) {
|
|
1151
|
+
for (const { moduleGraph } of Object.values(server.environments)) for (const module of moduleGraph.idToModuleMap.values()) if (module.id?.endsWith("?mcp-app")) moduleGraph.invalidateModule(module);
|
|
1152
|
+
} else for (const module of server.moduleGraph.idToModuleMap.values()) if (module.id?.endsWith("?mcp-app")) server.moduleGraph.invalidateModule(module);
|
|
1153
|
+
};
|
|
1154
|
+
server.watcher.on("add", onChange);
|
|
1155
|
+
server.watcher.on("change", onChange);
|
|
1156
|
+
server.watcher.on("unlink", onChange);
|
|
1157
|
+
server.watcher.on("add", onViewChange);
|
|
1158
|
+
server.watcher.on("change", onViewChange);
|
|
1159
|
+
server.watcher.on("unlink", onViewChange);
|
|
1160
|
+
server.watcher.once("close", () => {
|
|
1161
|
+
server.watcher.off("add", onChange);
|
|
1162
|
+
server.watcher.off("change", onChange);
|
|
1163
|
+
server.watcher.off("unlink", onChange);
|
|
1164
|
+
server.watcher.off("add", onViewChange);
|
|
1165
|
+
server.watcher.off("change", onViewChange);
|
|
1166
|
+
server.watcher.off("unlink", onViewChange);
|
|
1167
|
+
});
|
|
1168
|
+
} });
|
|
225
1169
|
return {
|
|
226
|
-
...
|
|
227
|
-
const onChange = (file) => {
|
|
228
|
-
if (normalizePath(file) === normalizePath(mcpEntry) || normalizePath(file) === normalizePath(sitemapFile)) regenerate();
|
|
229
|
-
};
|
|
230
|
-
server.watcher.on("add", onChange);
|
|
231
|
-
server.watcher.on("change", onChange);
|
|
232
|
-
server.watcher.on("unlink", onChange);
|
|
233
|
-
server.watcher.once("close", () => {
|
|
234
|
-
server.watcher.off("add", onChange);
|
|
235
|
-
server.watcher.off("change", onChange);
|
|
236
|
-
server.watcher.off("unlink", onChange);
|
|
237
|
-
});
|
|
238
|
-
} }),
|
|
1170
|
+
...skillPlugin,
|
|
239
1171
|
name: "@lovable.dev/mcp-js",
|
|
240
1172
|
api: {
|
|
241
1173
|
get mcpEntry() {
|
|
@@ -253,6 +1185,7 @@ function mcpPlugin(options = {}) {
|
|
|
253
1185
|
return { define: { [`import.meta.env.${SUPABASE_PROJECT_REF_ENV}`]: JSON.stringify(ref) } };
|
|
254
1186
|
},
|
|
255
1187
|
configResolved(config) {
|
|
1188
|
+
viteConfig = config;
|
|
256
1189
|
projectRoot = config.root;
|
|
257
1190
|
mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
258
1191
|
sitemapFile = (0, node_path.resolve)(projectRoot, "src/lib/sitemap.ts");
|
|
@@ -261,6 +1194,53 @@ function mcpPlugin(options = {}) {
|
|
|
261
1194
|
},
|
|
262
1195
|
buildStart() {
|
|
263
1196
|
regenerate();
|
|
1197
|
+
appBuilds.clear();
|
|
1198
|
+
},
|
|
1199
|
+
resolveId: {
|
|
1200
|
+
order: "pre",
|
|
1201
|
+
async handler(source, importer) {
|
|
1202
|
+
const skillId = skillPlugin.resolveId.handler.call(this, source, importer);
|
|
1203
|
+
if (skillId !== null) return skillId;
|
|
1204
|
+
if (!source.endsWith("?mcp-app")) return null;
|
|
1205
|
+
const htmlPath = source.slice(0, -8);
|
|
1206
|
+
if (!/\.html?$/.test(htmlPath)) throw new Error(`@lovable.dev/mcp-js: "${source}" — the ${MCP_APP_QUERY} import must point at an .html file`);
|
|
1207
|
+
const resolved = await this.resolve(htmlPath, importer, { skipSelf: true });
|
|
1208
|
+
if (!resolved) return null;
|
|
1209
|
+
return resolved.id + MCP_APP_QUERY;
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
async load(id, options) {
|
|
1213
|
+
const skillSource = skillPlugin.load.handler.call(this, id);
|
|
1214
|
+
if (skillSource !== null) return skillSource;
|
|
1215
|
+
if (!id.endsWith("?mcp-app")) return null;
|
|
1216
|
+
if (!(this.environment ? this.environment.config.consumer === "server" : options?.ssr === true)) throw new Error(`@lovable.dev/mcp-js: ${normalizePath((0, node_path.relative)(projectRoot, id))} is bundled into the server-side MCP entry only. Client code must not value-import the MCP entry or its views; use \`import type\` or move the import.`);
|
|
1217
|
+
const input = id.slice(0, -8);
|
|
1218
|
+
let pending = appBuilds.get(input);
|
|
1219
|
+
if (!pending) {
|
|
1220
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
1221
|
+
pending = {
|
|
1222
|
+
dependencies,
|
|
1223
|
+
html: buildMcpApp(projectRoot, input, dependencies)
|
|
1224
|
+
};
|
|
1225
|
+
appBuilds.set(input, pending);
|
|
1226
|
+
pending.html.catch(() => {
|
|
1227
|
+
if (appBuilds.get(input) === pending) appBuilds.delete(input);
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
let html;
|
|
1231
|
+
try {
|
|
1232
|
+
html = await pending.html;
|
|
1233
|
+
} finally {
|
|
1234
|
+
for (const file of pending.dependencies) this.addWatchFile(file);
|
|
1235
|
+
}
|
|
1236
|
+
if (viteConfig?.command === "build") {
|
|
1237
|
+
const kb = (Buffer.byteLength(html, "utf8") / 1024).toFixed(1);
|
|
1238
|
+
viteConfig.logger.info(`MCP App ${normalizePath((0, node_path.relative)(projectRoot, input))} → ${kb} kB inlined into the server bundle`);
|
|
1239
|
+
}
|
|
1240
|
+
return `export default ${JSON.stringify(html)};\n`;
|
|
1241
|
+
},
|
|
1242
|
+
watchChange() {
|
|
1243
|
+
appBuilds.clear();
|
|
264
1244
|
}
|
|
265
1245
|
};
|
|
266
1246
|
}
|