@frontmcp/uipack 0.6.2 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CLAUDE.md +0 -14
  2. package/adapters/index.js +50 -47
  3. package/adapters/platform-meta.d.ts.map +1 -1
  4. package/adapters/response-builder.d.ts +16 -3
  5. package/adapters/response-builder.d.ts.map +1 -1
  6. package/bridge-runtime/iife-generator.d.ts.map +1 -1
  7. package/bridge-runtime/index.js +4 -0
  8. package/build/builders/base-builder.d.ts +2 -0
  9. package/build/builders/base-builder.d.ts.map +1 -1
  10. package/build/index.d.ts +1 -1
  11. package/build/index.d.ts.map +1 -1
  12. package/build/index.js +81 -75
  13. package/bundler/file-cache/component-builder.d.ts.map +1 -1
  14. package/bundler/index.js +40 -36
  15. package/dependency/import-map.d.ts.map +1 -1
  16. package/dependency/index.js +22 -29
  17. package/esm/adapters/index.mjs +52 -42
  18. package/esm/bridge-runtime/index.mjs +4 -0
  19. package/esm/build/index.mjs +50 -38
  20. package/esm/bundler/index.mjs +25 -14
  21. package/esm/dependency/index.mjs +18 -18
  22. package/esm/handlebars/index.mjs +9 -8
  23. package/esm/index.mjs +136 -136
  24. package/esm/package.json +16 -17
  25. package/esm/registry/index.mjs +57 -50
  26. package/esm/renderers/index.mjs +19 -22
  27. package/esm/runtime/index.mjs +16 -15
  28. package/esm/theme/index.mjs +8 -0
  29. package/esm/tool-template/index.mjs +23 -15
  30. package/esm/typings/index.mjs +4 -0
  31. package/esm/utils/index.mjs +9 -56
  32. package/esm/validation/index.mjs +9 -8
  33. package/handlebars/index.js +4 -10
  34. package/index.js +215 -221
  35. package/package.json +3 -2
  36. package/preview/generic-preview.d.ts +4 -5
  37. package/preview/generic-preview.d.ts.map +1 -1
  38. package/preview/types.d.ts +15 -1
  39. package/preview/types.d.ts.map +1 -1
  40. package/registry/index.js +65 -64
  41. package/registry/render-template.d.ts.map +1 -1
  42. package/renderers/index.js +20 -29
  43. package/renderers/utils/detect.d.ts.map +1 -1
  44. package/renderers/utils/transpiler.d.ts.map +1 -1
  45. package/runtime/index.js +20 -25
  46. package/runtime/sanitizer.d.ts.map +1 -1
  47. package/theme/css-to-theme.d.ts +0 -27
  48. package/theme/css-to-theme.d.ts.map +1 -1
  49. package/theme/index.js +8 -0
  50. package/tool-template/index.js +30 -28
  51. package/typings/dts-parser.d.ts.map +1 -1
  52. package/typings/index.js +4 -0
  53. package/utils/index.d.ts +2 -3
  54. package/utils/index.d.ts.map +1 -1
  55. package/utils/index.js +7 -63
  56. package/validation/index.js +6 -12
  57. package/utils/escape-html.d.ts +0 -102
  58. package/utils/escape-html.d.ts.map +0 -1
  59. package/utils/safe-stringify.d.ts +0 -30
  60. package/utils/safe-stringify.d.ts.map +0 -1
package/bundler/index.js CHANGED
@@ -65,14 +65,14 @@ __export(filesystem_exports, {
65
65
  function createFilesystemStorage(options) {
66
66
  return new FilesystemStorage(options);
67
67
  }
68
- var import_promises, import_path, import_fs, import_crypto, CacheInitializationError, CacheOperationError, StorageNotInitializedError, DEFAULT_FS_OPTIONS, FilesystemStorage;
68
+ var import_path, import_fs, import_crypto, import_utils, CacheInitializationError, CacheOperationError, StorageNotInitializedError, DEFAULT_FS_OPTIONS, FilesystemStorage;
69
69
  var init_filesystem = __esm({
70
70
  "libs/uipack/src/bundler/file-cache/storage/filesystem.ts"() {
71
71
  "use strict";
72
- import_promises = require("fs/promises");
73
72
  import_path = require("path");
74
73
  import_fs = require("fs");
75
74
  import_crypto = require("crypto");
75
+ import_utils = require("@frontmcp/utils");
76
76
  init_interface();
77
77
  CacheInitializationError = class extends Error {
78
78
  cause;
@@ -124,7 +124,7 @@ var init_filesystem = __esm({
124
124
  async initialize() {
125
125
  if (this.initialized) return;
126
126
  try {
127
- await (0, import_promises.mkdir)(this.options.cacheDir, { recursive: true });
127
+ await (0, import_utils.mkdir)(this.options.cacheDir, { recursive: true });
128
128
  await this.loadStats();
129
129
  this.initialized = true;
130
130
  } catch (error) {
@@ -143,7 +143,7 @@ var init_filesystem = __esm({
143
143
  this.updateHitRate();
144
144
  return void 0;
145
145
  }
146
- const content = await (0, import_promises.readFile)(filePath, "utf8");
146
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
147
147
  const entry = JSON.parse(content);
148
148
  if (Date.now() > entry.metadata.expiresAt) {
149
149
  await this.delete(key);
@@ -199,7 +199,7 @@ var init_filesystem = __esm({
199
199
  const filePath = this.getFilePath(key);
200
200
  try {
201
201
  if (!(0, import_fs.existsSync)(filePath)) return false;
202
- const content = await (0, import_promises.readFile)(filePath, "utf8");
202
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
203
203
  const entry = JSON.parse(content);
204
204
  if (Date.now() > entry.metadata.expiresAt) {
205
205
  await this.delete(key);
@@ -218,9 +218,9 @@ var init_filesystem = __esm({
218
218
  const filePath = this.getFilePath(key);
219
219
  try {
220
220
  if (!(0, import_fs.existsSync)(filePath)) return false;
221
- const content = await (0, import_promises.readFile)(filePath, "utf8");
221
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
222
222
  const entry = JSON.parse(content);
223
- await (0, import_promises.unlink)(filePath);
223
+ await (0, import_utils.unlink)(filePath);
224
224
  this.stats.entries = Math.max(0, this.stats.entries - 1);
225
225
  this.stats.totalSize = Math.max(0, this.stats.totalSize - entry.metadata.size);
226
226
  return true;
@@ -234,8 +234,8 @@ var init_filesystem = __esm({
234
234
  async clear() {
235
235
  this.ensureInitialized();
236
236
  try {
237
- await (0, import_promises.rm)(this.options.cacheDir, { recursive: true, force: true });
238
- await (0, import_promises.mkdir)(this.options.cacheDir, { recursive: true });
237
+ await (0, import_utils.rm)(this.options.cacheDir, { recursive: true, force: true });
238
+ await (0, import_utils.mkdir)(this.options.cacheDir, { recursive: true });
239
239
  this.stats = {
240
240
  entries: 0,
241
241
  totalSize: 0,
@@ -260,21 +260,21 @@ var init_filesystem = __esm({
260
260
  this.ensureInitialized();
261
261
  let removed = 0;
262
262
  try {
263
- const files = await (0, import_promises.readdir)(this.options.cacheDir);
263
+ const files = await (0, import_utils.readdir)(this.options.cacheDir);
264
264
  for (const file of files) {
265
265
  if (!file.endsWith(this.options.extension)) continue;
266
266
  const filePath = (0, import_path.join)(this.options.cacheDir, file);
267
267
  try {
268
- const content = await (0, import_promises.readFile)(filePath, "utf8");
268
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
269
269
  const entry = JSON.parse(content);
270
270
  if (Date.now() > entry.metadata.expiresAt) {
271
- await (0, import_promises.unlink)(filePath);
271
+ await (0, import_utils.unlink)(filePath);
272
272
  this.stats.entries = Math.max(0, this.stats.entries - 1);
273
273
  this.stats.totalSize = Math.max(0, this.stats.totalSize - entry.metadata.size);
274
274
  removed++;
275
275
  }
276
276
  } catch {
277
- await (0, import_promises.unlink)(filePath).catch(() => {
277
+ await (0, import_utils.unlink)(filePath).catch(() => {
278
278
  });
279
279
  removed++;
280
280
  }
@@ -300,8 +300,8 @@ var init_filesystem = __esm({
300
300
  * Write a cache entry to disk.
301
301
  */
302
302
  async writeEntry(filePath, entry) {
303
- await (0, import_promises.mkdir)((0, import_path.dirname)(filePath), { recursive: true });
304
- await (0, import_promises.writeFile)(filePath, JSON.stringify(entry, null, 2), "utf8");
303
+ await (0, import_utils.mkdir)((0, import_path.dirname)(filePath), { recursive: true });
304
+ await (0, import_utils.writeFile)(filePath, JSON.stringify(entry, null, 2));
305
305
  }
306
306
  /**
307
307
  * Ensure the storage is initialized.
@@ -317,14 +317,14 @@ var init_filesystem = __esm({
317
317
  */
318
318
  async loadStats() {
319
319
  try {
320
- const files = await (0, import_promises.readdir)(this.options.cacheDir);
320
+ const files = await (0, import_utils.readdir)(this.options.cacheDir);
321
321
  let entries = 0;
322
322
  let totalSize = 0;
323
323
  for (const file of files) {
324
324
  if (!file.endsWith(this.options.extension)) continue;
325
325
  const filePath = (0, import_path.join)(this.options.cacheDir, file);
326
326
  try {
327
- const content = await (0, import_promises.readFile)(filePath, "utf8");
327
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
328
328
  const entry = JSON.parse(content);
329
329
  entries++;
330
330
  totalSize += entry.metadata.size;
@@ -353,7 +353,7 @@ var init_filesystem = __esm({
353
353
  */
354
354
  async evictLRU() {
355
355
  try {
356
- const files = await (0, import_promises.readdir)(this.options.cacheDir);
356
+ const files = await (0, import_utils.readdir)(this.options.cacheDir);
357
357
  let oldestKey = null;
358
358
  let oldestTime = Infinity;
359
359
  let corruptedFile = null;
@@ -361,7 +361,7 @@ var init_filesystem = __esm({
361
361
  if (!file.endsWith(this.options.extension)) continue;
362
362
  const filePath = (0, import_path.join)(this.options.cacheDir, file);
363
363
  try {
364
- const content = await (0, import_promises.readFile)(filePath, "utf8");
364
+ const content = await (0, import_utils.readFile)(filePath, "utf8");
365
365
  const entry = JSON.parse(content);
366
366
  if (entry.metadata.lastAccessedAt < oldestTime) {
367
367
  oldestTime = entry.metadata.lastAccessedAt;
@@ -373,7 +373,7 @@ var init_filesystem = __esm({
373
373
  }
374
374
  if (corruptedFile) {
375
375
  try {
376
- await (0, import_promises.unlink)(corruptedFile);
376
+ await (0, import_utils.unlink)(corruptedFile);
377
377
  this.stats.entries = Math.max(0, this.stats.entries - 1);
378
378
  return true;
379
379
  } catch {
@@ -1462,9 +1462,9 @@ init_redis();
1462
1462
 
1463
1463
  // libs/uipack/src/bundler/file-cache/hash-calculator.ts
1464
1464
  var import_crypto2 = require("crypto");
1465
- var import_promises2 = require("fs/promises");
1466
1465
  var import_fs2 = require("fs");
1467
1466
  var import_path2 = require("path");
1467
+ var import_utils2 = require("@frontmcp/utils");
1468
1468
  function sha256(content) {
1469
1469
  return (0, import_crypto2.createHash)("sha256").update(content, "utf8").digest("hex");
1470
1470
  }
@@ -1473,7 +1473,7 @@ function sha256Buffer(buffer) {
1473
1473
  }
1474
1474
  async function hashFile(filePath) {
1475
1475
  try {
1476
- const content = await (0, import_promises2.readFile)(filePath);
1476
+ const content = await (0, import_utils2.readFileBuffer)(filePath);
1477
1477
  return sha256Buffer(content);
1478
1478
  } catch {
1479
1479
  return void 0;
@@ -1534,7 +1534,7 @@ async function collectLocalDependencies(filePath, baseDir, collected, maxDepth,
1534
1534
  if (!(0, import_fs2.existsSync)(filePath)) return;
1535
1535
  collected.add(filePath);
1536
1536
  try {
1537
- const content = await (0, import_promises2.readFile)(filePath, "utf8");
1537
+ const content = await (0, import_utils2.readFile)(filePath);
1538
1538
  const imports = extractImportPaths(content);
1539
1539
  for (const importPath of imports) {
1540
1540
  if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
@@ -1608,10 +1608,10 @@ function buildIdFromHash(hash) {
1608
1608
  }
1609
1609
 
1610
1610
  // libs/uipack/src/bundler/file-cache/component-builder.ts
1611
- var import_promises3 = require("fs/promises");
1612
1611
  var import_fs3 = require("fs");
1613
1612
  var import_path3 = require("path");
1614
1613
  var import_crypto3 = require("crypto");
1614
+ var import_utils5 = require("@frontmcp/utils");
1615
1615
 
1616
1616
  // libs/uipack/src/dependency/cdn-registry.ts
1617
1617
  var DEFAULT_CDN_REGISTRY = {
@@ -2374,10 +2374,8 @@ function parseImports(source) {
2374
2374
  };
2375
2375
  }
2376
2376
 
2377
- // libs/uipack/src/utils/escape-html.ts
2378
- function escapeHtmlAttr(str) {
2379
- return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
2380
- }
2377
+ // libs/uipack/src/utils/index.ts
2378
+ var import_utils3 = require("@frontmcp/utils");
2381
2379
 
2382
2380
  // libs/uipack/src/dependency/import-map.ts
2383
2381
  function createImportMap(dependencies) {
@@ -2424,13 +2422,16 @@ function generateUMDShim(dependencies, options = {}) {
2424
2422
  console.warn('UMD shim failed:', e);
2425
2423
  }
2426
2424
  })();` : `window.__esm_shim = ${shimObject};`;
2427
- return minify ? code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1") : code;
2425
+ if (minify && code.length <= 1e5) {
2426
+ return code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1");
2427
+ }
2428
+ return code;
2428
2429
  }
2429
2430
  function generateCDNScriptTags(dependencies) {
2430
2431
  return dependencies.filter((dep) => !dep.esm).map((dep) => {
2431
- const attrs = [`src="${escapeHtmlAttr(dep.cdnUrl)}"`];
2432
+ const attrs = [`src="${(0, import_utils3.escapeHtmlAttr)(dep.cdnUrl)}"`];
2432
2433
  if (dep.integrity) {
2433
- attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
2434
+ attrs.push(`integrity="${(0, import_utils3.escapeHtmlAttr)(dep.integrity)}"`);
2434
2435
  }
2435
2436
  attrs.push('crossorigin="anonymous"');
2436
2437
  return `<script ${attrs.join(" ")}></script>`;
@@ -2438,9 +2439,9 @@ function generateCDNScriptTags(dependencies) {
2438
2439
  }
2439
2440
  function generateESMScriptTags(dependencies) {
2440
2441
  return dependencies.filter((dep) => dep.esm).map((dep) => {
2441
- const attrs = ['type="module"', `src="${escapeHtmlAttr(dep.cdnUrl)}"`];
2442
+ const attrs = ['type="module"', `src="${(0, import_utils3.escapeHtmlAttr)(dep.cdnUrl)}"`];
2442
2443
  if (dep.integrity) {
2443
- attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
2444
+ attrs.push(`integrity="${(0, import_utils3.escapeHtmlAttr)(dep.integrity)}"`);
2444
2445
  }
2445
2446
  attrs.push('crossorigin="anonymous"');
2446
2447
  return `<script ${attrs.join(" ")}></script>`;
@@ -2681,7 +2682,7 @@ var ComponentBuilder = class {
2681
2682
  } = options;
2682
2683
  const absoluteEntryPath = (0, import_path3.resolve)(entryPath);
2683
2684
  if (!(0, import_fs3.existsSync)(absoluteEntryPath)) {
2684
- throw new Error(`Entry file not found: ${absoluteEntryPath}`);
2685
+ throw new Error(`Entry file not found: ${(0, import_path3.basename)(absoluteEntryPath)}`);
2685
2686
  }
2686
2687
  const hashResult = await calculateComponentHash({
2687
2688
  entryPath: absoluteEntryPath,
@@ -2699,7 +2700,7 @@ var ComponentBuilder = class {
2699
2700
  };
2700
2701
  }
2701
2702
  }
2702
- const source = await (0, import_promises3.readFile)(absoluteEntryPath, "utf8");
2703
+ const source = await (0, import_utils5.readFile)(absoluteEntryPath, "utf8");
2703
2704
  const resolver = new DependencyResolver({ platform });
2704
2705
  const resolvedDeps = [];
2705
2706
  for (const pkg of externals) {
@@ -2855,7 +2856,10 @@ var ComponentBuilder = class {
2855
2856
  bundlerVersion: this.esbuild.version
2856
2857
  };
2857
2858
  } catch (error) {
2858
- throw new Error(`Bundle failed for ${entryPath}: ${error}`);
2859
+ const fileName = (0, import_path3.basename)(entryPath);
2860
+ const rawMessage = error instanceof Error ? error.message : String(error);
2861
+ const sanitizedMessage = rawMessage.replace(/(?:\/[\w./-]+|[A-Z]:\\[\w.\\-]+)/g, (match) => (0, import_path3.basename)(match));
2862
+ throw new Error(`Bundle failed for ${fileName}: ${sanitizedMessage}`);
2859
2863
  }
2860
2864
  }
2861
2865
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"import-map.d.ts","sourceRoot":"","sources":["../../src/dependency/import-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAgB7E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAgBnG;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAwB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAQtG;AAMD;;;;;;;;;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OAAO,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,GAAE,qBAA0B,GAClC,MAAM,CA2BR;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAiDpF"}
@@ -1192,23 +1192,8 @@ function getImportStats(source) {
1192
1192
  };
1193
1193
  }
1194
1194
 
1195
- // libs/uipack/src/utils/escape-html.ts
1196
- function escapeHtml(str) {
1197
- if (str === null || str === void 0) {
1198
- return "";
1199
- }
1200
- const s = String(str);
1201
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
1202
- }
1203
- function escapeHtmlAttr(str) {
1204
- return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
1205
- }
1206
- function escapeJsString(str) {
1207
- return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
1208
- }
1209
- function escapeScriptClose(jsonString) {
1210
- return jsonString.replace(/<\//g, "<\\/");
1211
- }
1195
+ // libs/uipack/src/utils/index.ts
1196
+ var import_utils = require("@frontmcp/utils");
1212
1197
 
1213
1198
  // libs/uipack/src/dependency/import-map.ts
1214
1199
  function createImportMap(dependencies) {
@@ -1299,13 +1284,16 @@ function generateUMDShim(dependencies, options = {}) {
1299
1284
  console.warn('UMD shim failed:', e);
1300
1285
  }
1301
1286
  })();` : `window.__esm_shim = ${shimObject};`;
1302
- return minify ? code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1") : code;
1287
+ if (minify && code.length <= 1e5) {
1288
+ return code.replace(/\s+/g, " ").replace(/\s*([{},:])\s*/g, "$1");
1289
+ }
1290
+ return code;
1303
1291
  }
1304
1292
  function generateCDNScriptTags(dependencies) {
1305
1293
  return dependencies.filter((dep) => !dep.esm).map((dep) => {
1306
- const attrs = [`src="${escapeHtmlAttr(dep.cdnUrl)}"`];
1294
+ const attrs = [`src="${(0, import_utils.escapeHtmlAttr)(dep.cdnUrl)}"`];
1307
1295
  if (dep.integrity) {
1308
- attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
1296
+ attrs.push(`integrity="${(0, import_utils.escapeHtmlAttr)(dep.integrity)}"`);
1309
1297
  }
1310
1298
  attrs.push('crossorigin="anonymous"');
1311
1299
  return `<script ${attrs.join(" ")}></script>`;
@@ -1313,9 +1301,9 @@ function generateCDNScriptTags(dependencies) {
1313
1301
  }
1314
1302
  function generateESMScriptTags(dependencies) {
1315
1303
  return dependencies.filter((dep) => dep.esm).map((dep) => {
1316
- const attrs = ['type="module"', `src="${escapeHtmlAttr(dep.cdnUrl)}"`];
1304
+ const attrs = ['type="module"', `src="${(0, import_utils.escapeHtmlAttr)(dep.cdnUrl)}"`];
1317
1305
  if (dep.integrity) {
1318
- attrs.push(`integrity="${escapeHtmlAttr(dep.integrity)}"`);
1306
+ attrs.push(`integrity="${(0, import_utils.escapeHtmlAttr)(dep.integrity)}"`);
1319
1307
  }
1320
1308
  attrs.push('crossorigin="anonymous"');
1321
1309
  return `<script ${attrs.join(" ")}></script>`;
@@ -1598,6 +1586,7 @@ var import_path = require("path");
1598
1586
 
1599
1587
  // libs/uipack/src/bundler/file-cache/hash-calculator.ts
1600
1588
  var import_crypto = require("crypto");
1589
+ var import_utils3 = require("@frontmcp/utils");
1601
1590
  function sha256(content) {
1602
1591
  return (0, import_crypto.createHash)("sha256").update(content, "utf8").digest("hex");
1603
1592
  }
@@ -1966,7 +1955,7 @@ function classNames(...classes) {
1966
1955
  }
1967
1956
  var builtinHelpers = {
1968
1957
  // Escaping
1969
- escapeHtml,
1958
+ escapeHtml: import_utils.escapeHtml,
1970
1959
  // Formatting
1971
1960
  formatDate,
1972
1961
  formatCurrency,
@@ -2279,7 +2268,11 @@ function containsHandlebars(template) {
2279
2268
  }
2280
2269
 
2281
2270
  // libs/uipack/src/renderers/utils/detect.ts
2271
+ var MAX_TEMPLATE_LENGTH = 5e4;
2282
2272
  function containsMdxSyntax(source) {
2273
+ if (source.length > MAX_TEMPLATE_LENGTH) {
2274
+ return false;
2275
+ }
2283
2276
  if (/<[A-Z][a-zA-Z0-9]*/.test(source)) {
2284
2277
  return true;
2285
2278
  }
@@ -2566,12 +2559,12 @@ var MdxClientRenderer = class {
2566
2559
  ...outputProps,
2567
2560
  ...props
2568
2561
  };
2569
- const escapedMdx = escapeScriptClose(JSON.stringify(template));
2570
- const escapedProps = escapeScriptClose(JSON.stringify(spreadProps));
2571
- const safeContainerId = escapeJsString(containerId);
2572
- const loadingHtml = showLoading ? `<div class="mdx-loading">${escapeHtml(loadingMessage)}</div>` : "";
2562
+ const escapedMdx = (0, import_utils.escapeScriptClose)(JSON.stringify(template));
2563
+ const escapedProps = (0, import_utils.escapeScriptClose)(JSON.stringify(spreadProps));
2564
+ const safeContainerId = (0, import_utils.escapeJsString)(containerId);
2565
+ const loadingHtml = showLoading ? `<div class="mdx-loading">${(0, import_utils.escapeHtml)(loadingMessage)}</div>` : "";
2573
2566
  return `
2574
- <div id="${escapeHtml(containerId)}">${loadingHtml}</div>
2567
+ <div id="${(0, import_utils.escapeHtml)(containerId)}">${loadingHtml}</div>
2575
2568
  <script type="module">
2576
2569
  (async function() {
2577
2570
  try {
@@ -2912,7 +2905,7 @@ function safeInputToRecord(input) {
2912
2905
  return {};
2913
2906
  }
2914
2907
  var defaultHelpers = {
2915
- escapeHtml,
2908
+ escapeHtml: import_utils.escapeHtml,
2916
2909
  formatDate: (date, format) => {
2917
2910
  const d = date instanceof Date ? date : new Date(date);
2918
2911
  if (format === "iso") return d.toISOString();
@@ -28,16 +28,13 @@ function buildUIMeta(options) {
28
28
  case "generic-mcp":
29
29
  case "gemini":
30
30
  default:
31
- meta["frontmcp/html"] = html;
32
- meta["frontmcp/mimeType"] = "text/html+mcp";
33
- if (rendererType) meta["frontmcp/type"] = rendererType;
34
- if (contentHash) meta["frontmcp/contentHash"] = contentHash;
35
- if (manifestUri) meta["frontmcp/manifestUri"] = manifestUri;
36
- if (token) meta["frontmcp/widgetToken"] = token;
37
- if (directUrl) meta["frontmcp/directUrl"] = directUrl;
38
31
  meta["ui/html"] = html;
39
32
  meta["ui/mimeType"] = "text/html+mcp";
40
33
  if (rendererType) meta["ui/type"] = rendererType;
34
+ if (contentHash) meta["ui/contentHash"] = contentHash;
35
+ if (manifestUri) meta["ui/manifestUri"] = manifestUri;
36
+ if (token) meta["ui/widgetToken"] = token;
37
+ if (directUrl) meta["ui/directUrl"] = directUrl;
41
38
  if (platformType === "claude") {
42
39
  return buildClaudeMeta(meta, uiConfig);
43
40
  } else if (platformType === "gemini") {
@@ -107,23 +104,36 @@ function buildFrontMCPCSP(csp) {
107
104
  return result;
108
105
  }
109
106
  function buildGenericMeta(meta, uiConfig) {
110
- if (uiConfig.widgetAccessible) {
111
- meta["frontmcp/widgetAccessible"] = true;
112
- }
113
107
  if (uiConfig.csp) {
114
- meta["frontmcp/widgetCSP"] = buildFrontMCPCSP(uiConfig.csp);
108
+ const csp = {};
109
+ if (uiConfig.csp.connectDomains?.length) {
110
+ csp.connectDomains = uiConfig.csp.connectDomains;
111
+ }
112
+ if (uiConfig.csp.resourceDomains?.length) {
113
+ csp.resourceDomains = uiConfig.csp.resourceDomains;
114
+ }
115
+ if (Object.keys(csp).length > 0) {
116
+ meta["ui/csp"] = csp;
117
+ }
115
118
  }
116
119
  if (uiConfig.displayMode) {
117
- meta["frontmcp/displayMode"] = uiConfig.displayMode;
118
- }
119
- if (uiConfig.widgetDescription) {
120
- meta["frontmcp/widgetDescription"] = uiConfig.widgetDescription;
120
+ const displayModeMap = {
121
+ inline: "inline",
122
+ fullscreen: "fullscreen",
123
+ pip: "pip",
124
+ widget: "inline",
125
+ panel: "fullscreen"
126
+ };
127
+ const mappedMode = displayModeMap[uiConfig.displayMode];
128
+ if (mappedMode) {
129
+ meta["ui/displayMode"] = mappedMode;
130
+ }
121
131
  }
122
132
  if (uiConfig.prefersBorder !== void 0) {
123
- meta["frontmcp/prefersBorder"] = uiConfig.prefersBorder;
133
+ meta["ui/prefersBorder"] = uiConfig.prefersBorder;
124
134
  }
125
135
  if (uiConfig.sandboxDomain) {
126
- meta["frontmcp/domain"] = uiConfig.sandboxDomain;
136
+ meta["ui/domain"] = uiConfig.sandboxDomain;
127
137
  }
128
138
  return meta;
129
139
  }
@@ -353,25 +363,15 @@ function platformSupportsWidgets(platformType) {
353
363
  return capabilities.supportsWidgets;
354
364
  }
355
365
 
356
- // libs/uipack/src/utils/safe-stringify.ts
357
- function safeStringify(value, space) {
358
- const seen = /* @__PURE__ */ new WeakSet();
359
- try {
360
- return JSON.stringify(
361
- value,
362
- (_key, val) => {
363
- if (typeof val === "object" && val !== null) {
364
- if (seen.has(val)) return "[Circular]";
365
- seen.add(val);
366
- }
367
- return val;
368
- },
369
- space
370
- );
371
- } catch {
372
- return JSON.stringify({ error: "Output could not be serialized" });
373
- }
374
- }
366
+ // libs/uipack/src/utils/index.ts
367
+ import {
368
+ safeStringify,
369
+ escapeHtml,
370
+ escapeHtmlAttr,
371
+ escapeJsString,
372
+ escapeScriptClose,
373
+ safeJsonForScript
374
+ } from "@frontmcp/utils";
375
375
 
376
376
  // libs/uipack/src/adapters/response-builder.ts
377
377
  function buildToolResponseContent(options) {
@@ -394,12 +394,22 @@ function buildToolResponseContent(options) {
394
394
  }
395
395
  if (useStructuredContent) {
396
396
  if (htmlContent) {
397
- return {
398
- content: [{ type: "text", text: htmlContent }],
399
- structuredContent: rawOutput,
400
- contentCleared: false,
401
- format: "structured-content"
402
- };
397
+ const htmlInContent = platformType === "openai" || platformType === "ext-apps";
398
+ if (htmlInContent) {
399
+ return {
400
+ content: [{ type: "text", text: htmlContent }],
401
+ structuredContent: rawOutput,
402
+ contentCleared: false,
403
+ format: "structured-content"
404
+ };
405
+ } else {
406
+ return {
407
+ content: [{ type: "text", text: safeStringify(rawOutput) }],
408
+ structuredContent: rawOutput,
409
+ contentCleared: false,
410
+ format: "structured-content"
411
+ };
412
+ }
403
413
  }
404
414
  return {
405
415
  content: [{ type: "text", text: safeStringify(rawOutput) }],
@@ -823,7 +823,11 @@ FrontMcpBridge.prototype._setupDataToolCallHandler = function() {
823
823
  };
824
824
  `.trim();
825
825
  }
826
+ var MAX_MINIFY_CODE_LENGTH = 5e5;
826
827
  function minifyJS(code) {
828
+ if (code.length > MAX_MINIFY_CODE_LENGTH) {
829
+ return code;
830
+ }
827
831
  return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/\s+/g, " ").replace(/\s*([{};,:()[\]])\s*/g, "$1").replace(/;\}/g, "}").trim();
828
832
  }
829
833
  function generatePlatformBundle(platform, options = {}) {