@frontmcp/uipack 0.12.1 → 1.0.0-beta.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 (298) hide show
  1. package/CLAUDE.md +56 -154
  2. package/README.md +367 -62
  3. package/adapters/base-template.d.ts +30 -0
  4. package/adapters/base-template.d.ts.map +1 -0
  5. package/adapters/cdn-info.d.ts +34 -0
  6. package/adapters/cdn-info.d.ts.map +1 -0
  7. package/adapters/constants.d.ts +18 -0
  8. package/adapters/constants.d.ts.map +1 -0
  9. package/adapters/content-detector.d.ts +19 -0
  10. package/adapters/content-detector.d.ts.map +1 -0
  11. package/adapters/content-renderers.d.ts +27 -0
  12. package/adapters/content-renderers.d.ts.map +1 -0
  13. package/adapters/index.d.ts +14 -7
  14. package/adapters/index.d.ts.map +1 -1
  15. package/adapters/index.js +2343 -426
  16. package/adapters/render-failure.d.ts +18 -0
  17. package/adapters/render-failure.d.ts.map +1 -0
  18. package/adapters/response-builder.d.ts +34 -104
  19. package/adapters/response-builder.d.ts.map +1 -1
  20. package/adapters/serving-mode.d.ts +28 -91
  21. package/adapters/serving-mode.d.ts.map +1 -1
  22. package/adapters/template-renderer.d.ts +50 -0
  23. package/adapters/template-renderer.d.ts.map +1 -0
  24. package/adapters/type-detector.d.ts +18 -0
  25. package/adapters/type-detector.d.ts.map +1 -0
  26. package/bridge-runtime/index.js +1 -1
  27. package/component/index.d.ts +14 -0
  28. package/component/index.d.ts.map +1 -0
  29. package/component/index.js +2043 -0
  30. package/component/loader.d.ts +36 -0
  31. package/component/loader.d.ts.map +1 -0
  32. package/component/renderer.d.ts +30 -0
  33. package/component/renderer.d.ts.map +1 -0
  34. package/component/transpiler.d.ts +49 -0
  35. package/component/transpiler.d.ts.map +1 -0
  36. package/component/types.d.ts +82 -0
  37. package/component/types.d.ts.map +1 -0
  38. package/esm/adapters/index.mjs +2337 -422
  39. package/esm/bridge-runtime/index.mjs +1 -1
  40. package/esm/component/index.mjs +2013 -0
  41. package/esm/index.mjs +3446 -13935
  42. package/esm/package.json +3 -12
  43. package/esm/resolver/index.mjs +661 -0
  44. package/esm/shell/index.mjs +1406 -0
  45. package/esm/types/index.mjs +11 -11
  46. package/esm/utils/index.mjs +53 -8
  47. package/index.d.ts +12 -40
  48. package/index.d.ts.map +1 -1
  49. package/index.js +3579 -14218
  50. package/package.json +3 -12
  51. package/resolver/cdn-registry.d.ts +39 -0
  52. package/resolver/cdn-registry.d.ts.map +1 -0
  53. package/resolver/esm-sh.resolver.d.ts +54 -0
  54. package/resolver/esm-sh.resolver.d.ts.map +1 -0
  55. package/resolver/import-map.d.ts +47 -0
  56. package/resolver/import-map.d.ts.map +1 -0
  57. package/resolver/import-parser.d.ts +28 -0
  58. package/resolver/import-parser.d.ts.map +1 -0
  59. package/resolver/import-rewriter.d.ts +29 -0
  60. package/resolver/import-rewriter.d.ts.map +1 -0
  61. package/resolver/index.d.ts +15 -0
  62. package/resolver/index.d.ts.map +1 -0
  63. package/resolver/index.js +708 -0
  64. package/resolver/types.d.ts +191 -0
  65. package/resolver/types.d.ts.map +1 -0
  66. package/shell/builder.d.ts +31 -0
  67. package/shell/builder.d.ts.map +1 -0
  68. package/shell/csp.d.ts +37 -0
  69. package/shell/csp.d.ts.map +1 -0
  70. package/shell/custom-shell-applier.d.ts +33 -0
  71. package/shell/custom-shell-applier.d.ts.map +1 -0
  72. package/shell/custom-shell-resolver.d.ts +47 -0
  73. package/shell/custom-shell-resolver.d.ts.map +1 -0
  74. package/shell/custom-shell-types.d.ts +75 -0
  75. package/shell/custom-shell-types.d.ts.map +1 -0
  76. package/shell/custom-shell-validator.d.ts +26 -0
  77. package/shell/custom-shell-validator.d.ts.map +1 -0
  78. package/shell/data-injector.d.ts +40 -0
  79. package/shell/data-injector.d.ts.map +1 -0
  80. package/shell/index.d.ts +19 -0
  81. package/shell/index.d.ts.map +1 -0
  82. package/shell/index.js +1453 -0
  83. package/shell/types.d.ts +54 -0
  84. package/shell/types.d.ts.map +1 -0
  85. package/types/index.d.ts +1 -3
  86. package/types/index.d.ts.map +1 -1
  87. package/types/index.js +11 -11
  88. package/types/ui-config.d.ts +50 -11
  89. package/types/ui-config.d.ts.map +1 -1
  90. package/types/ui-runtime.d.ts +8 -82
  91. package/types/ui-runtime.d.ts.map +1 -1
  92. package/utils/index.d.ts +9 -3
  93. package/utils/index.d.ts.map +1 -1
  94. package/utils/index.js +59 -7
  95. package/adapters/platform-meta.constants.d.ts +0 -26
  96. package/adapters/platform-meta.constants.d.ts.map +0 -1
  97. package/adapters/platform-meta.d.ts +0 -234
  98. package/adapters/platform-meta.d.ts.map +0 -1
  99. package/base-template/bridge.d.ts +0 -90
  100. package/base-template/bridge.d.ts.map +0 -1
  101. package/base-template/default-base-template.d.ts +0 -91
  102. package/base-template/default-base-template.d.ts.map +0 -1
  103. package/base-template/index.d.ts +0 -15
  104. package/base-template/index.d.ts.map +0 -1
  105. package/base-template/index.js +0 -1393
  106. package/base-template/polyfills.d.ts +0 -31
  107. package/base-template/polyfills.d.ts.map +0 -1
  108. package/base-template/theme-styles.d.ts +0 -74
  109. package/base-template/theme-styles.d.ts.map +0 -1
  110. package/build/builders/base-builder.d.ts +0 -124
  111. package/build/builders/base-builder.d.ts.map +0 -1
  112. package/build/builders/esbuild-config.d.ts +0 -94
  113. package/build/builders/esbuild-config.d.ts.map +0 -1
  114. package/build/builders/hybrid-builder.d.ts +0 -93
  115. package/build/builders/hybrid-builder.d.ts.map +0 -1
  116. package/build/builders/index.d.ts +0 -17
  117. package/build/builders/index.d.ts.map +0 -1
  118. package/build/builders/inline-builder.d.ts +0 -83
  119. package/build/builders/inline-builder.d.ts.map +0 -1
  120. package/build/builders/static-builder.d.ts +0 -78
  121. package/build/builders/static-builder.d.ts.map +0 -1
  122. package/build/builders/types.d.ts +0 -341
  123. package/build/builders/types.d.ts.map +0 -1
  124. package/build/cdn-resources.d.ts +0 -244
  125. package/build/cdn-resources.d.ts.map +0 -1
  126. package/build/hybrid-data.d.ts +0 -127
  127. package/build/hybrid-data.d.ts.map +0 -1
  128. package/build/index.d.ts +0 -299
  129. package/build/index.d.ts.map +0 -1
  130. package/build/index.js +0 -8699
  131. package/build/ui-components-browser.d.ts +0 -64
  132. package/build/ui-components-browser.d.ts.map +0 -1
  133. package/build/widget-manifest.d.ts +0 -362
  134. package/build/widget-manifest.d.ts.map +0 -1
  135. package/bundler/cache.d.ts +0 -173
  136. package/bundler/cache.d.ts.map +0 -1
  137. package/bundler/file-cache/component-builder.d.ts +0 -167
  138. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  139. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  140. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  141. package/bundler/file-cache/index.d.ts +0 -12
  142. package/bundler/file-cache/index.d.ts.map +0 -1
  143. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  144. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  145. package/bundler/file-cache/storage/index.d.ts +0 -11
  146. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  147. package/bundler/file-cache/storage/interface.d.ts +0 -152
  148. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  149. package/bundler/file-cache/storage/redis.d.ts +0 -139
  150. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  151. package/bundler/index.d.ts +0 -35
  152. package/bundler/index.d.ts.map +0 -1
  153. package/bundler/index.js +0 -2953
  154. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  155. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  156. package/bundler/sandbox/executor.d.ts +0 -14
  157. package/bundler/sandbox/executor.d.ts.map +0 -1
  158. package/bundler/sandbox/policy.d.ts +0 -62
  159. package/bundler/sandbox/policy.d.ts.map +0 -1
  160. package/bundler/types.d.ts +0 -702
  161. package/bundler/types.d.ts.map +0 -1
  162. package/dependency/cdn-registry.d.ts +0 -98
  163. package/dependency/cdn-registry.d.ts.map +0 -1
  164. package/dependency/import-map.d.ts +0 -186
  165. package/dependency/import-map.d.ts.map +0 -1
  166. package/dependency/import-parser.d.ts +0 -82
  167. package/dependency/import-parser.d.ts.map +0 -1
  168. package/dependency/index.d.ts +0 -17
  169. package/dependency/index.d.ts.map +0 -1
  170. package/dependency/index.js +0 -3180
  171. package/dependency/resolver.d.ts +0 -164
  172. package/dependency/resolver.d.ts.map +0 -1
  173. package/dependency/schemas.d.ts +0 -486
  174. package/dependency/schemas.d.ts.map +0 -1
  175. package/dependency/template-loader.d.ts +0 -204
  176. package/dependency/template-loader.d.ts.map +0 -1
  177. package/dependency/template-processor.d.ts +0 -118
  178. package/dependency/template-processor.d.ts.map +0 -1
  179. package/dependency/types.d.ts +0 -739
  180. package/dependency/types.d.ts.map +0 -1
  181. package/esm/base-template/index.mjs +0 -1359
  182. package/esm/build/index.mjs +0 -8601
  183. package/esm/bundler/index.mjs +0 -2895
  184. package/esm/dependency/index.mjs +0 -3068
  185. package/esm/handlebars/index.mjs +0 -587
  186. package/esm/registry/index.mjs +0 -6305
  187. package/esm/renderers/index.mjs +0 -1557
  188. package/esm/runtime/index.mjs +0 -5361
  189. package/esm/styles/index.mjs +0 -171
  190. package/esm/theme/index.mjs +0 -756
  191. package/esm/tool-template/index.mjs +0 -3652
  192. package/esm/validation/index.mjs +0 -542
  193. package/handlebars/expression-extractor.d.ts +0 -147
  194. package/handlebars/expression-extractor.d.ts.map +0 -1
  195. package/handlebars/helpers.d.ts +0 -339
  196. package/handlebars/helpers.d.ts.map +0 -1
  197. package/handlebars/index.d.ts +0 -195
  198. package/handlebars/index.d.ts.map +0 -1
  199. package/handlebars/index.js +0 -659
  200. package/preview/claude-preview.d.ts +0 -67
  201. package/preview/claude-preview.d.ts.map +0 -1
  202. package/preview/generic-preview.d.ts +0 -66
  203. package/preview/generic-preview.d.ts.map +0 -1
  204. package/preview/index.d.ts +0 -36
  205. package/preview/index.d.ts.map +0 -1
  206. package/preview/openai-preview.d.ts +0 -70
  207. package/preview/openai-preview.d.ts.map +0 -1
  208. package/preview/types.d.ts +0 -199
  209. package/preview/types.d.ts.map +0 -1
  210. package/registry/index.d.ts +0 -46
  211. package/registry/index.d.ts.map +0 -1
  212. package/registry/index.js +0 -6342
  213. package/registry/render-template.d.ts +0 -91
  214. package/registry/render-template.d.ts.map +0 -1
  215. package/registry/tool-ui.registry.d.ts +0 -294
  216. package/registry/tool-ui.registry.d.ts.map +0 -1
  217. package/registry/uri-utils.d.ts +0 -56
  218. package/registry/uri-utils.d.ts.map +0 -1
  219. package/renderers/cache.d.ts +0 -145
  220. package/renderers/cache.d.ts.map +0 -1
  221. package/renderers/html.renderer.d.ts +0 -123
  222. package/renderers/html.renderer.d.ts.map +0 -1
  223. package/renderers/index.d.ts +0 -36
  224. package/renderers/index.d.ts.map +0 -1
  225. package/renderers/index.js +0 -1603
  226. package/renderers/mdx-client.renderer.d.ts +0 -124
  227. package/renderers/mdx-client.renderer.d.ts.map +0 -1
  228. package/renderers/registry.d.ts +0 -133
  229. package/renderers/registry.d.ts.map +0 -1
  230. package/renderers/types.d.ts +0 -343
  231. package/renderers/types.d.ts.map +0 -1
  232. package/renderers/utils/detect.d.ts +0 -107
  233. package/renderers/utils/detect.d.ts.map +0 -1
  234. package/renderers/utils/hash.d.ts +0 -40
  235. package/renderers/utils/hash.d.ts.map +0 -1
  236. package/renderers/utils/index.d.ts +0 -9
  237. package/renderers/utils/index.d.ts.map +0 -1
  238. package/renderers/utils/transpiler.d.ts +0 -70
  239. package/renderers/utils/transpiler.d.ts.map +0 -1
  240. package/runtime/adapters/html.adapter.d.ts +0 -59
  241. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  242. package/runtime/adapters/index.d.ts +0 -26
  243. package/runtime/adapters/index.d.ts.map +0 -1
  244. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  245. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  246. package/runtime/adapters/types.d.ts +0 -95
  247. package/runtime/adapters/types.d.ts.map +0 -1
  248. package/runtime/csp.d.ts +0 -48
  249. package/runtime/csp.d.ts.map +0 -1
  250. package/runtime/index.d.ts +0 -17
  251. package/runtime/index.d.ts.map +0 -1
  252. package/runtime/index.js +0 -5432
  253. package/runtime/mcp-bridge.d.ts +0 -101
  254. package/runtime/mcp-bridge.d.ts.map +0 -1
  255. package/runtime/renderer-runtime.d.ts +0 -133
  256. package/runtime/renderer-runtime.d.ts.map +0 -1
  257. package/runtime/sanitizer.d.ts +0 -180
  258. package/runtime/sanitizer.d.ts.map +0 -1
  259. package/runtime/types.d.ts +0 -415
  260. package/runtime/types.d.ts.map +0 -1
  261. package/runtime/wrapper.d.ts +0 -421
  262. package/runtime/wrapper.d.ts.map +0 -1
  263. package/styles/index.d.ts +0 -8
  264. package/styles/index.d.ts.map +0 -1
  265. package/styles/index.js +0 -222
  266. package/styles/variants.d.ts +0 -51
  267. package/styles/variants.d.ts.map +0 -1
  268. package/theme/cdn.d.ts +0 -195
  269. package/theme/cdn.d.ts.map +0 -1
  270. package/theme/css-to-theme.d.ts +0 -64
  271. package/theme/css-to-theme.d.ts.map +0 -1
  272. package/theme/index.d.ts +0 -19
  273. package/theme/index.d.ts.map +0 -1
  274. package/theme/index.js +0 -814
  275. package/theme/platforms.d.ts +0 -102
  276. package/theme/platforms.d.ts.map +0 -1
  277. package/theme/presets/github-openai.d.ts +0 -50
  278. package/theme/presets/github-openai.d.ts.map +0 -1
  279. package/theme/presets/index.d.ts +0 -11
  280. package/theme/presets/index.d.ts.map +0 -1
  281. package/theme/theme.d.ts +0 -396
  282. package/theme/theme.d.ts.map +0 -1
  283. package/tool-template/builder.d.ts +0 -213
  284. package/tool-template/builder.d.ts.map +0 -1
  285. package/tool-template/index.d.ts +0 -16
  286. package/tool-template/index.d.ts.map +0 -1
  287. package/tool-template/index.js +0 -3690
  288. package/validation/error-box.d.ts +0 -56
  289. package/validation/error-box.d.ts.map +0 -1
  290. package/validation/index.d.ts +0 -13
  291. package/validation/index.d.ts.map +0 -1
  292. package/validation/index.js +0 -576
  293. package/validation/schema-paths.d.ts +0 -118
  294. package/validation/schema-paths.d.ts.map +0 -1
  295. package/validation/template-validator.d.ts +0 -143
  296. package/validation/template-validator.d.ts.map +0 -1
  297. package/validation/wrapper.d.ts +0 -97
  298. package/validation/wrapper.d.ts.map +0 -1
@@ -1,659 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // libs/uipack/src/handlebars/index.ts
31
- var handlebars_exports = {};
32
- __export(handlebars_exports, {
33
- HandlebarsRenderer: () => HandlebarsRenderer,
34
- and: () => and,
35
- builtinHelpers: () => builtinHelpers,
36
- capitalize: () => capitalize,
37
- classNames: () => classNames,
38
- containsHandlebars: () => containsHandlebars,
39
- createHandlebarsRenderer: () => createHandlebarsRenderer,
40
- defaultValue: () => defaultValue,
41
- eq: () => eq,
42
- escapeHtml: () => import_utils.escapeHtml,
43
- extractAll: () => extractAll,
44
- extractExpressions: () => extractExpressions,
45
- extractInputPaths: () => extractInputPaths,
46
- extractOutputPaths: () => extractOutputPaths,
47
- extractStructuredContentPaths: () => extractStructuredContentPaths,
48
- extractVariablePaths: () => extractVariablePaths,
49
- first: () => first,
50
- formatCurrency: () => formatCurrency,
51
- formatDate: () => formatDate,
52
- formatNumber: () => formatNumber,
53
- getExpressionAt: () => getExpressionAt,
54
- gt: () => gt,
55
- gte: () => gte,
56
- hasVariablePaths: () => hasVariablePaths,
57
- includes: () => includes,
58
- isHandlebarsAvailable: () => isHandlebarsAvailable,
59
- join: () => join,
60
- json: () => json,
61
- jsonEmbed: () => jsonEmbed,
62
- last: () => last,
63
- length: () => length,
64
- lowercase: () => lowercase,
65
- lt: () => lt,
66
- lte: () => lte,
67
- ne: () => ne,
68
- normalizePath: () => normalizePath,
69
- not: () => not,
70
- or: () => or,
71
- renderTemplate: () => renderTemplate,
72
- resetUniqueIdCounter: () => resetUniqueIdCounter,
73
- truncate: () => truncate,
74
- uniqueId: () => uniqueId,
75
- uppercase: () => uppercase
76
- });
77
- module.exports = __toCommonJS(handlebars_exports);
78
-
79
- // libs/uipack/src/utils/index.ts
80
- var import_utils = require("@frontmcp/utils");
81
-
82
- // libs/uipack/src/handlebars/helpers.ts
83
- function formatDate(date, format) {
84
- if (date === null || date === void 0) {
85
- return "";
86
- }
87
- let dateObj;
88
- if (date instanceof Date) {
89
- dateObj = date;
90
- } else if (typeof date === "string" || typeof date === "number") {
91
- dateObj = new Date(date);
92
- } else {
93
- return String(date);
94
- }
95
- if (isNaN(dateObj.getTime())) {
96
- return String(date);
97
- }
98
- const options = {};
99
- switch (format) {
100
- case "short":
101
- options.dateStyle = "short";
102
- break;
103
- case "medium":
104
- options.dateStyle = "medium";
105
- break;
106
- case "long":
107
- options.dateStyle = "long";
108
- break;
109
- case "full":
110
- options.dateStyle = "full";
111
- break;
112
- case "time":
113
- options.timeStyle = "short";
114
- break;
115
- case "datetime":
116
- options.dateStyle = "medium";
117
- options.timeStyle = "short";
118
- break;
119
- case "iso":
120
- return dateObj.toISOString();
121
- case "relative":
122
- return formatRelativeDate(dateObj);
123
- default:
124
- options.dateStyle = "medium";
125
- }
126
- return new Intl.DateTimeFormat("en-US", options).format(dateObj);
127
- }
128
- function formatRelativeDate(date) {
129
- const now = /* @__PURE__ */ new Date();
130
- const diffMs = now.getTime() - date.getTime();
131
- const diffSecs = Math.floor(diffMs / 1e3);
132
- const diffMins = Math.floor(diffSecs / 60);
133
- const diffHours = Math.floor(diffMins / 60);
134
- const diffDays = Math.floor(diffHours / 24);
135
- if (diffSecs < 60) {
136
- return "just now";
137
- } else if (diffMins < 60) {
138
- return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
139
- } else if (diffHours < 24) {
140
- return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
141
- } else if (diffDays < 7) {
142
- return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
143
- } else {
144
- return formatDate(date, "medium");
145
- }
146
- }
147
- function formatCurrency(amount, currency) {
148
- if (amount === null || amount === void 0) {
149
- return "";
150
- }
151
- const num = typeof amount === "number" ? amount : parseFloat(String(amount));
152
- if (isNaN(num)) {
153
- return String(amount);
154
- }
155
- return new Intl.NumberFormat("en-US", {
156
- style: "currency",
157
- currency: typeof currency === "string" ? currency : "USD"
158
- }).format(num);
159
- }
160
- function formatNumber(value, decimals) {
161
- if (value === null || value === void 0) {
162
- return "";
163
- }
164
- const num = typeof value === "number" ? value : parseFloat(String(value));
165
- if (isNaN(num)) {
166
- return String(value);
167
- }
168
- const options = {};
169
- if (typeof decimals === "number") {
170
- options.minimumFractionDigits = decimals;
171
- options.maximumFractionDigits = decimals;
172
- }
173
- return new Intl.NumberFormat("en-US", options).format(num);
174
- }
175
- function jsonEmbed(data) {
176
- const json2 = JSON.stringify(data ?? null);
177
- return json2.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
178
- }
179
- function json(data, pretty) {
180
- return JSON.stringify(data ?? null, null, pretty ? 2 : void 0);
181
- }
182
- function eq(a, b) {
183
- return a === b;
184
- }
185
- function ne(a, b) {
186
- return a !== b;
187
- }
188
- function gt(a, b) {
189
- return Number(a) > Number(b);
190
- }
191
- function gte(a, b) {
192
- return Number(a) >= Number(b);
193
- }
194
- function lt(a, b) {
195
- return Number(a) < Number(b);
196
- }
197
- function lte(a, b) {
198
- return Number(a) <= Number(b);
199
- }
200
- function and(a, b) {
201
- return Boolean(a) && Boolean(b);
202
- }
203
- function or(a, b) {
204
- return Boolean(a) || Boolean(b);
205
- }
206
- function not(value) {
207
- return !value;
208
- }
209
- function first(arr) {
210
- if (!Array.isArray(arr)) return void 0;
211
- return arr[0];
212
- }
213
- function last(arr) {
214
- if (!Array.isArray(arr)) return void 0;
215
- return arr[arr.length - 1];
216
- }
217
- function length(value) {
218
- if (Array.isArray(value)) return value.length;
219
- if (typeof value === "string") return value.length;
220
- return 0;
221
- }
222
- function includes(arr, value) {
223
- if (!Array.isArray(arr)) return false;
224
- return arr.includes(value);
225
- }
226
- function join(arr, separator) {
227
- if (!Array.isArray(arr)) return "";
228
- return arr.join(typeof separator === "string" ? separator : ", ");
229
- }
230
- function uppercase(str) {
231
- return String(str ?? "").toUpperCase();
232
- }
233
- function lowercase(str) {
234
- return String(str ?? "").toLowerCase();
235
- }
236
- function capitalize(str) {
237
- const s = String(str ?? "");
238
- return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
239
- }
240
- function truncate(str, maxLength, suffix) {
241
- const s = String(str ?? "");
242
- const len = typeof maxLength === "number" ? maxLength : 50;
243
- const suf = typeof suffix === "string" ? suffix : "...";
244
- if (s.length <= len) return s;
245
- return s.slice(0, len - suf.length) + suf;
246
- }
247
- function defaultValue(value, defaultValue2) {
248
- return value || defaultValue2;
249
- }
250
- var idCounter = 0;
251
- function uniqueId(prefix) {
252
- const id = ++idCounter;
253
- return prefix ? `${prefix}-${id}` : `id-${id}`;
254
- }
255
- function resetUniqueIdCounter() {
256
- idCounter = 0;
257
- }
258
- function classNames(...classes) {
259
- return classes.filter(Boolean).map(String).join(" ");
260
- }
261
- var builtinHelpers = {
262
- // Escaping
263
- escapeHtml: import_utils.escapeHtml,
264
- // Formatting
265
- formatDate,
266
- formatCurrency,
267
- formatNumber,
268
- json,
269
- jsonEmbed,
270
- // Comparison
271
- eq,
272
- ne,
273
- gt,
274
- gte,
275
- lt,
276
- lte,
277
- // Logical
278
- and,
279
- or,
280
- not,
281
- // Array
282
- first,
283
- last,
284
- length,
285
- includes,
286
- join,
287
- // String
288
- uppercase,
289
- lowercase,
290
- capitalize,
291
- truncate,
292
- // Utility
293
- default: defaultValue,
294
- uniqueId,
295
- classNames
296
- };
297
-
298
- // libs/uipack/src/handlebars/expression-extractor.ts
299
- var EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
300
- var PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
301
- var KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
302
- function extractExpressions(template) {
303
- const expressions = [];
304
- const positionMap = buildPositionMap(template);
305
- let match;
306
- EXPRESSION_REGEX.lastIndex = 0;
307
- while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
308
- const fullExpression = match[0];
309
- const prefix = match[1];
310
- const content = match[2].trim();
311
- const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
312
- let type = "variable";
313
- let helperName;
314
- if (prefix === "/") {
315
- type = "block-close";
316
- helperName = content;
317
- } else if (prefix === "#") {
318
- type = "block";
319
- const parts = content.split(/\s+/);
320
- helperName = parts[0];
321
- } else {
322
- const parts = content.split(/\s+/);
323
- if (parts.length > 1 && !content.startsWith("(")) {
324
- const firstToken = parts[0];
325
- if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
326
- type = "helper";
327
- helperName = firstToken;
328
- }
329
- }
330
- }
331
- const paths = extractPathsFromContent(content);
332
- for (const path of paths) {
333
- expressions.push({
334
- path,
335
- fullExpression,
336
- line: position.line,
337
- column: position.column,
338
- type,
339
- helperName
340
- });
341
- }
342
- if (paths.length === 0 && type === "variable") {
343
- const cleanContent = content.trim();
344
- if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
345
- }
346
- }
347
- }
348
- return expressions;
349
- }
350
- function extractPathsFromContent(content) {
351
- const paths = [];
352
- let match;
353
- const regex = new RegExp(PATH_REGEX.source, "g");
354
- while ((match = regex.exec(content)) !== null) {
355
- paths.push(match[0]);
356
- }
357
- return paths;
358
- }
359
- function buildPositionMap(template) {
360
- const map = /* @__PURE__ */ new Map();
361
- let line = 1;
362
- let column = 1;
363
- for (let i = 0; i < template.length; i++) {
364
- map.set(i, { line, column });
365
- if (template[i] === "\n") {
366
- line++;
367
- column = 1;
368
- } else {
369
- column++;
370
- }
371
- }
372
- return map;
373
- }
374
- function extractVariablePaths(template) {
375
- const expressions = extractExpressions(template);
376
- const paths = new Set(expressions.map((e) => e.path));
377
- return Array.from(paths);
378
- }
379
- function extractOutputPaths(template) {
380
- return extractVariablePaths(template).filter((p) => p.startsWith("output."));
381
- }
382
- function extractInputPaths(template) {
383
- return extractVariablePaths(template).filter((p) => p.startsWith("input."));
384
- }
385
- function extractStructuredContentPaths(template) {
386
- return extractVariablePaths(template).filter((p) => p.startsWith("structuredContent."));
387
- }
388
- function extractAll(template) {
389
- const expressions = extractExpressions(template);
390
- const paths = [...new Set(expressions.map((e) => e.path))];
391
- return {
392
- expressions,
393
- paths,
394
- outputPaths: paths.filter((p) => p.startsWith("output.")),
395
- inputPaths: paths.filter((p) => p.startsWith("input.")),
396
- structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
397
- };
398
- }
399
- function hasVariablePaths(template) {
400
- return extractVariablePaths(template).length > 0;
401
- }
402
- function getExpressionAt(template, line, column) {
403
- const expressions = extractExpressions(template);
404
- return expressions.find((expr) => {
405
- if (expr.line !== line) return false;
406
- const exprEnd = expr.column + expr.fullExpression.length;
407
- return column >= expr.column && column <= exprEnd;
408
- });
409
- }
410
- function normalizePath(path) {
411
- return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
412
- }
413
-
414
- // libs/uipack/src/handlebars/index.ts
415
- var Handlebars = null;
416
- async function loadHandlebars() {
417
- if (Handlebars !== null) {
418
- return Handlebars;
419
- }
420
- try {
421
- Handlebars = await import("handlebars");
422
- return Handlebars;
423
- } catch {
424
- throw new Error("Handlebars is required for template rendering. Install it: npm install handlebars");
425
- }
426
- }
427
- async function isHandlebarsAvailable() {
428
- try {
429
- await loadHandlebars();
430
- return true;
431
- } catch {
432
- return false;
433
- }
434
- }
435
- var HandlebarsRenderer = class {
436
- options;
437
- compiledTemplates = /* @__PURE__ */ new Map();
438
- initialized = false;
439
- hbs = null;
440
- constructor(options = {}) {
441
- this.options = {
442
- strict: false,
443
- autoEscape: true,
444
- ...options
445
- };
446
- }
447
- /**
448
- * Initialize the renderer with Handlebars.
449
- */
450
- async init() {
451
- if (this.initialized) return;
452
- this.hbs = await loadHandlebars();
453
- for (const [name, helper] of Object.entries(builtinHelpers)) {
454
- this.hbs.registerHelper(name, helper);
455
- }
456
- if (this.options.helpers) {
457
- for (const [name, helper] of Object.entries(this.options.helpers)) {
458
- this.hbs.registerHelper(name, helper);
459
- }
460
- }
461
- if (this.options.partials) {
462
- for (const [name, template] of Object.entries(this.options.partials)) {
463
- this.hbs.registerPartial(name, template);
464
- }
465
- }
466
- this.initialized = true;
467
- }
468
- /**
469
- * Render a Handlebars template.
470
- *
471
- * @param template - Template string
472
- * @param context - Render context with input/output
473
- * @returns Rendered HTML string
474
- */
475
- async render(template, context) {
476
- await this.init();
477
- if (!this.hbs) {
478
- throw new Error("Handlebars not initialized");
479
- }
480
- let compiled = this.compiledTemplates.get(template);
481
- if (!compiled) {
482
- compiled = this.hbs.compile(template, {
483
- strict: this.options.strict,
484
- noEscape: !this.options.autoEscape
485
- });
486
- this.compiledTemplates.set(template, compiled);
487
- }
488
- const data = {
489
- input: context.input ?? {},
490
- output: context.output ?? {},
491
- structuredContent: context.structuredContent,
492
- // Also expose at root level for convenience
493
- ...context.input,
494
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
495
- };
496
- try {
497
- return compiled(data);
498
- } catch (error) {
499
- throw new Error(`Template rendering failed: ${error instanceof Error ? error.message : String(error)}`);
500
- }
501
- }
502
- /**
503
- * Render a template synchronously.
504
- *
505
- * Note: Requires Handlebars to be pre-loaded. Use `render()` for async loading.
506
- *
507
- * @param template - Template string
508
- * @param context - Render context
509
- * @returns Rendered HTML string
510
- */
511
- renderSync(template, context) {
512
- if (!this.initialized || !this.hbs) {
513
- throw new Error("HandlebarsRenderer not initialized. Call render() first or use initSync().");
514
- }
515
- let compiled = this.compiledTemplates.get(template);
516
- if (!compiled) {
517
- compiled = this.hbs.compile(template, {
518
- strict: this.options.strict,
519
- noEscape: !this.options.autoEscape
520
- });
521
- this.compiledTemplates.set(template, compiled);
522
- }
523
- const data = {
524
- input: context.input ?? {},
525
- output: context.output ?? {},
526
- structuredContent: context.structuredContent,
527
- ...context.input,
528
- ...typeof context.output === "object" && context.output !== null ? context.output : {}
529
- };
530
- return compiled(data);
531
- }
532
- /**
533
- * Initialize synchronously (for environments where Handlebars is already loaded).
534
- */
535
- initSync(handlebars) {
536
- this.hbs = handlebars;
537
- for (const [name, helper] of Object.entries(builtinHelpers)) {
538
- this.hbs.registerHelper(name, helper);
539
- }
540
- if (this.options.helpers) {
541
- for (const [name, helper] of Object.entries(this.options.helpers)) {
542
- this.hbs.registerHelper(name, helper);
543
- }
544
- }
545
- if (this.options.partials) {
546
- for (const [name, template] of Object.entries(this.options.partials)) {
547
- this.hbs.registerPartial(name, template);
548
- }
549
- }
550
- this.initialized = true;
551
- }
552
- /**
553
- * Register a custom helper.
554
- *
555
- * @param name - Helper name
556
- * @param fn - Helper function
557
- */
558
- registerHelper(name, fn) {
559
- if (this.hbs) {
560
- this.hbs.registerHelper(name, fn);
561
- }
562
- if (!this.options.helpers) {
563
- this.options.helpers = {};
564
- }
565
- this.options.helpers[name] = fn;
566
- }
567
- /**
568
- * Register a partial template.
569
- *
570
- * @param name - Partial name
571
- * @param template - Partial template string
572
- */
573
- registerPartial(name, template) {
574
- if (this.hbs) {
575
- this.hbs.registerPartial(name, template);
576
- }
577
- if (!this.options.partials) {
578
- this.options.partials = {};
579
- }
580
- this.options.partials[name] = template;
581
- }
582
- /**
583
- * Clear compiled template cache.
584
- */
585
- clearCache() {
586
- this.compiledTemplates.clear();
587
- }
588
- /**
589
- * Check if a template string contains Handlebars syntax.
590
- *
591
- * @param template - Template string to check
592
- * @returns true if contains {{...}} syntax
593
- */
594
- static containsHandlebars(template) {
595
- return /\{\{(?!!)[\s\S]*?\}\}/.test(template);
596
- }
597
- /**
598
- * Check if the renderer is initialized.
599
- */
600
- get isInitialized() {
601
- return this.initialized;
602
- }
603
- };
604
- function createHandlebarsRenderer(options) {
605
- return new HandlebarsRenderer(options);
606
- }
607
- async function renderTemplate(template, context) {
608
- const renderer = createHandlebarsRenderer();
609
- return renderer.render(template, context);
610
- }
611
- function containsHandlebars(template) {
612
- return HandlebarsRenderer.containsHandlebars(template);
613
- }
614
- // Annotate the CommonJS export names for ESM import in node:
615
- 0 && (module.exports = {
616
- HandlebarsRenderer,
617
- and,
618
- builtinHelpers,
619
- capitalize,
620
- classNames,
621
- containsHandlebars,
622
- createHandlebarsRenderer,
623
- defaultValue,
624
- eq,
625
- escapeHtml,
626
- extractAll,
627
- extractExpressions,
628
- extractInputPaths,
629
- extractOutputPaths,
630
- extractStructuredContentPaths,
631
- extractVariablePaths,
632
- first,
633
- formatCurrency,
634
- formatDate,
635
- formatNumber,
636
- getExpressionAt,
637
- gt,
638
- gte,
639
- hasVariablePaths,
640
- includes,
641
- isHandlebarsAvailable,
642
- join,
643
- json,
644
- jsonEmbed,
645
- last,
646
- length,
647
- lowercase,
648
- lt,
649
- lte,
650
- ne,
651
- normalizePath,
652
- not,
653
- or,
654
- renderTemplate,
655
- resetUniqueIdCounter,
656
- truncate,
657
- uniqueId,
658
- uppercase
659
- });