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