@wavemaker-ai/react-runtime 1.0.0-rc.647469 → 1.0.0-rc.647502

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 (315) hide show
  1. package/actions/base-action.d.ts +7 -0
  2. package/actions/login-action.d.ts +11 -0
  3. package/actions/logout-action.d.ts +10 -0
  4. package/actions/navigation-action.d.ts +35 -0
  5. package/actions/navigation-action.js +23 -5
  6. package/actions/notification-action.d.ts +20 -0
  7. package/actions/timer-action.d.ts +27 -0
  8. package/components/advanced/carousel/index.d.ts +1 -0
  9. package/components/advanced/carousel/index.js +2 -1
  10. package/components/advanced/carousel/template.d.ts +1 -0
  11. package/components/advanced/carousel/template.js +2 -1
  12. package/components/advanced/login/index.d.ts +1 -0
  13. package/components/advanced/marquee/index.d.ts +1 -0
  14. package/components/advanced/marquee/index.js +2 -1
  15. package/components/basic/anchor/index.d.ts +1 -0
  16. package/components/basic/anchor/index.js +4 -3
  17. package/components/basic/audio/index.d.ts +1 -0
  18. package/components/basic/audio/index.js +3 -2
  19. package/components/basic/html/index.d.ts +1 -0
  20. package/components/basic/icon/index.d.ts +1 -0
  21. package/components/basic/icon/index.js +4 -7
  22. package/components/basic/iframe/iframe.utils.d.ts +1 -1
  23. package/components/basic/iframe/iframe.utils.js +8 -4
  24. package/components/basic/iframe/index.d.ts +1 -0
  25. package/components/basic/label/index.d.ts +1 -0
  26. package/components/basic/label/index.js +3 -2
  27. package/components/basic/message/index.js +1 -1
  28. package/components/basic/picture/index.d.ts +1 -0
  29. package/components/basic/picture/index.js +3 -4
  30. package/components/basic/progress-bar/index.d.ts +1 -0
  31. package/components/basic/progress-bar/index.js +2 -1
  32. package/components/basic/progress-circle/index.d.ts +1 -0
  33. package/components/basic/richtexteditor/index.d.ts +2 -0
  34. package/components/basic/search/index.d.ts +3 -0
  35. package/components/basic/search/index.js +7 -4
  36. package/components/basic/search/props.d.ts +2 -0
  37. package/components/basic/spinner/index.d.ts +1 -0
  38. package/components/basic/tile/index.d.ts +1 -0
  39. package/components/basic/tile/index.js +2 -1
  40. package/components/basic/tree/Components/TreeNodeComponent.js +9 -5
  41. package/components/basic/tree/index.d.ts +1 -0
  42. package/components/basic/tree/index.js +14 -3
  43. package/components/basic/tree/utils.d.ts +2 -0
  44. package/components/basic/tree/utils.js +11 -1
  45. package/components/basic/video/index.d.ts +1 -0
  46. package/components/basic/video/index.js +40 -23
  47. package/components/chart/index.d.ts +1 -0
  48. package/components/common/AppSpinner.js +2 -5
  49. package/components/container/accordion/accordion-pane/index.d.ts +1 -0
  50. package/components/container/accordion/accordion-pane/index.js +1 -4
  51. package/components/container/accordion/index.d.ts +1 -0
  52. package/components/container/index.d.ts +3 -0
  53. package/components/container/index.js +6 -1
  54. package/components/container/layout-grid/grid-column/index.d.ts +1 -0
  55. package/components/container/layout-grid/grid-row/index.d.ts +1 -0
  56. package/components/container/layout-grid/index.d.ts +1 -0
  57. package/components/container/layout-grid/index.js +4 -8
  58. package/components/container/linear-layout/index.d.ts +1 -0
  59. package/components/container/linear-layout/linear-layout-item/index.d.ts +1 -0
  60. package/components/container/panel/components/panel-header/index.js +11 -6
  61. package/components/container/panel/components/panel-header/props.d.ts +5 -0
  62. package/components/container/panel/index.d.ts +1 -0
  63. package/components/container/panel/index.js +2 -1
  64. package/components/container/props.d.ts +2 -0
  65. package/components/container/repeat-template/index.d.ts +22 -1
  66. package/components/container/repeat-template/index.js +2 -1
  67. package/components/container/tabs/index.d.ts +3 -1
  68. package/components/container/tabs/index.js +102 -51
  69. package/components/container/tabs/props.d.ts +12 -0
  70. package/components/container/tabs/tab-pane/index.d.ts +1 -0
  71. package/components/container/tabs/tab-pane/index.js +28 -11
  72. package/components/container/wizard/index.d.ts +2 -0
  73. package/components/container/wizard/wizard-step/index.d.ts +1 -0
  74. package/components/container/wizard/wizard-step/index.js +2 -2
  75. package/components/data/card/card-actions/index.d.ts +1 -0
  76. package/components/data/card/card-actions/index.js +3 -5
  77. package/components/data/card/card-content/index.d.ts +1 -0
  78. package/components/data/card/card-content/index.js +3 -13
  79. package/components/data/card/card-footer/index.d.ts +1 -0
  80. package/components/data/card/card-footer/index.js +3 -5
  81. package/components/data/card/index.d.ts +1 -0
  82. package/components/data/card/index.js +3 -14
  83. package/components/data/form/dynamic-fields/index.js +7 -1
  84. package/components/data/form/dynamic-fields/props.d.ts +1 -0
  85. package/components/data/form/form-action/index.d.ts +2 -0
  86. package/components/data/form/form-body/index.js +2 -1
  87. package/components/data/form/form-field/base-field.js +4 -3
  88. package/components/data/form/form-footer/index.js +2 -1
  89. package/components/data/list/components/ListItemWithTemplate.js +4 -2
  90. package/components/data/list/hooks/props.d.ts +2 -2
  91. package/components/data/list/hooks/useListEventHandlers.js +6 -6
  92. package/components/data/list/index.d.ts +2 -0
  93. package/components/data/list/index.js +3 -4
  94. package/components/data/list/props.d.ts +2 -1
  95. package/components/data/list/utils/list-widget-methods.d.ts +2 -1
  96. package/components/data/table/components/RowCells.d.ts +16 -2
  97. package/components/data/table/components/RowCells.js +38 -24
  98. package/components/data/table/components/TableBody.js +11 -3
  99. package/components/data/table/components/TableDataRow.d.ts +3 -0
  100. package/components/data/table/components/TableDataRow.js +11 -3
  101. package/components/data/table/components/TableHeader.js +1 -4
  102. package/components/data/table/hooks/index.d.ts +1 -0
  103. package/components/data/table/hooks/index.js +12 -0
  104. package/components/data/table/hooks/useCustomExpressionColumns.d.ts +16 -0
  105. package/components/data/table/hooks/useCustomExpressionColumns.js +88 -0
  106. package/components/data/table/hooks/useDynamicColumns.js +1 -1
  107. package/components/data/table/hooks/useResponsiveColumns.d.ts +1 -0
  108. package/components/data/table/hooks/useRowSelection.d.ts +1 -1
  109. package/components/data/table/hooks/useRowSelection.js +26 -5
  110. package/components/data/table/hooks/useTableInitialization.js +2 -1
  111. package/components/data/table/index.d.ts +4 -0
  112. package/components/data/table/index.js +77 -12
  113. package/components/data/table/live-table/index.d.ts +1 -0
  114. package/components/data/table/props.d.ts +7 -0
  115. package/components/data/table/table-action/index.d.ts +1 -0
  116. package/components/data/table/table-column/index.d.ts +1 -0
  117. package/components/data/table/table-row/index.d.ts +1 -0
  118. package/components/data/table/table-row-action/index.d.ts +1 -0
  119. package/components/data/table/utils/buildSelectionColumns.js +7 -1
  120. package/components/data/table/utils/columnBuilder.js +1 -1
  121. package/components/data/table/utils/index.js +2 -2
  122. package/components/data/table/utils/renderDisplayCell.js +1 -1
  123. package/components/dialogs/alert-dialog/index.d.ts +2 -0
  124. package/components/dialogs/confirm-dialog/index.d.ts +2 -0
  125. package/components/dialogs/dialog/index.d.ts +2 -0
  126. package/components/dialogs/dialog/index.js +2 -4
  127. package/components/dialogs/dialog-actions/index.d.ts +1 -0
  128. package/components/dialogs/dialog-body/index.d.ts +1 -0
  129. package/components/dialogs/dialog-content/index.d.ts +1 -0
  130. package/components/dialogs/dialog-header/index.d.ts +1 -0
  131. package/components/dialogs/iframe-dialog/index.d.ts +2 -0
  132. package/components/dialogs/login-dialog/index.d.ts +2 -0
  133. package/components/dialogs/page-dialog/index.d.ts +2 -0
  134. package/components/form/button/index.d.ts +1 -0
  135. package/components/form/button/index.js +4 -3
  136. package/components/form/button-group/index.d.ts +1 -0
  137. package/components/form/button-group/index.js +2 -1
  138. package/components/input/calendar/index.d.ts +2 -0
  139. package/components/input/chips/index.d.ts +2 -0
  140. package/components/input/color-picker/index.d.ts +2 -0
  141. package/components/input/composite/index.d.ts +1 -0
  142. package/components/input/currency/index.d.ts +2 -0
  143. package/components/input/default/checkbox/index.d.ts +2 -0
  144. package/components/input/default/checkboxset/index.d.ts +2 -0
  145. package/components/input/default/radioset/index.d.ts +2 -0
  146. package/components/input/default/switch/index.d.ts +2 -0
  147. package/components/input/epoch/date/components/DatePickerPopover.js +11 -29
  148. package/components/input/epoch/date/index.d.ts +1 -0
  149. package/components/input/epoch/datetime/index.d.ts +1 -0
  150. package/components/input/epoch/datetime/index.js +10 -25
  151. package/components/input/epoch/time/index.d.ts +1 -0
  152. package/components/input/epoch/time/index.js +1 -1
  153. package/components/input/epoch/time/utils.d.ts +0 -17
  154. package/components/input/epoch/time/utils.js +1 -18
  155. package/components/input/fileupload/index.d.ts +1 -0
  156. package/components/input/number/index.d.ts +2 -0
  157. package/components/input/rating/index.d.ts +2 -0
  158. package/components/input/rating/index.js +14 -17
  159. package/components/input/select/index.d.ts +2 -0
  160. package/components/input/select/index.js +1 -4
  161. package/components/input/slider/index.d.ts +2 -0
  162. package/components/input/slider/index.js +13 -12
  163. package/components/input/text/index.d.ts +2 -0
  164. package/components/input/text/index.js +3 -14
  165. package/components/input/textarea/index.d.ts +2 -0
  166. package/components/input/textarea/index.js +7 -10
  167. package/components/input/upload/index.d.ts +2 -0
  168. package/components/input/upload/index.js +3 -5
  169. package/components/layout/footer/index.js +2 -1
  170. package/components/layout/footer/props.d.ts +1 -0
  171. package/components/layout/header/index.js +2 -1
  172. package/components/layout/header/props.d.ts +1 -0
  173. package/components/layout/leftnav/index.js +2 -1
  174. package/components/layout/leftnav/props.d.ts +1 -0
  175. package/components/layout/rightnav/index.js +2 -1
  176. package/components/layout/rightnav/props.d.ts +1 -0
  177. package/components/layout/topnav/index.js +2 -1
  178. package/components/layout/topnav/props.d.ts +1 -0
  179. package/components/navbar/index.d.ts +1 -0
  180. package/components/navbar/index.js +2 -1
  181. package/components/navbar/nav/index.d.ts +1 -0
  182. package/components/navbar/nav-item/index.d.ts +1 -0
  183. package/components/navbar/nav-item/index.js +2 -1
  184. package/components/navigation/breadcrumb/index.d.ts +1 -0
  185. package/components/navigation/menu/index.d.ts +1 -0
  186. package/components/navigation/menu/index.js +5 -4
  187. package/components/navigation/popover/index.d.ts +2 -1
  188. package/components/navigation/popover/index.js +1 -1
  189. package/components/page/error-boundary/index.js +5 -5
  190. package/components/page/index.js +13 -9
  191. package/components/page/partial/index.d.ts +1 -0
  192. package/components/prefab/container/index.js +2 -1
  193. package/context/WidgetProvider.js +2 -2
  194. package/core/app.service.js +40 -35
  195. package/core/constants/events.js +6 -0
  196. package/core/constants/index.d.ts +9 -1
  197. package/core/constants/index.js +32 -5
  198. package/core/formatter/date-formatters.d.ts +1 -1
  199. package/core/formatter/date-formatters.js +38 -13
  200. package/core/formatter/types.d.ts +1 -1
  201. package/core/proxy-service.js +15 -5
  202. package/core/security.service.d.ts +12 -0
  203. package/core/util/index.js +3 -2
  204. package/higherOrder/BaseApp.js +2 -2
  205. package/higherOrder/BasePage.d.ts +0 -17
  206. package/higherOrder/BasePage.js +53 -104
  207. package/higherOrder/BasePrefab.js +69 -59
  208. package/higherOrder/props.d.ts +1 -0
  209. package/higherOrder/withBaseWrapper.js +3 -4
  210. package/hooks/useAccess.js +13 -0
  211. package/mui-config/theme-provider.d.ts +3 -0
  212. package/mui-config/theme.d.ts +2 -0
  213. package/mui-config/theme.js +1 -4
  214. package/package-lock.json +2640 -615
  215. package/package.json +23 -4
  216. package/runtime-dynamic/App.d.ts +7 -0
  217. package/runtime-dynamic/App.js +144 -0
  218. package/runtime-dynamic/app-initializer.d.ts +15 -0
  219. package/runtime-dynamic/app-initializer.js +447 -0
  220. package/runtime-dynamic/components/ErrorBoundary.d.ts +18 -0
  221. package/runtime-dynamic/components/ErrorBoundary.js +93 -0
  222. package/runtime-dynamic/components/PageWrapper.d.ts +1 -0
  223. package/runtime-dynamic/components/PageWrapper.js +43 -0
  224. package/runtime-dynamic/components/PrefabPreview.d.ts +1 -0
  225. package/runtime-dynamic/components/PrefabPreview.js +84 -0
  226. package/runtime-dynamic/components/partial-content.d.ts +15 -0
  227. package/runtime-dynamic/components/partial-content.js +50 -0
  228. package/runtime-dynamic/components/prefab-content.d.ts +10 -0
  229. package/runtime-dynamic/components/prefab-content.js +31 -0
  230. package/runtime-dynamic/components/use-dynamic-component.d.ts +10 -0
  231. package/runtime-dynamic/components/use-dynamic-component.js +165 -0
  232. package/runtime-dynamic/factories/build-base-page-like-component.d.ts +8 -0
  233. package/runtime-dynamic/factories/build-base-page-like-component.js +59 -0
  234. package/runtime-dynamic/factories/prefab-factory.d.ts +3 -0
  235. package/runtime-dynamic/factories/prefab-factory.js +82 -0
  236. package/runtime-dynamic/factories/startup-info.d.ts +6 -0
  237. package/runtime-dynamic/factories/startup-info.js +28 -0
  238. package/runtime-dynamic/factories/utils.d.ts +23 -0
  239. package/runtime-dynamic/factories/utils.js +131 -0
  240. package/runtime-dynamic/index.d.ts +14 -0
  241. package/runtime-dynamic/index.js +191 -0
  242. package/runtime-dynamic/main.d.ts +2 -0
  243. package/runtime-dynamic/main.js +84 -0
  244. package/runtime-dynamic/preview-mode.d.ts +15 -0
  245. package/runtime-dynamic/preview-mode.js +31 -0
  246. package/runtime-dynamic/preview-navigation.d.ts +6 -0
  247. package/runtime-dynamic/preview-navigation.js +38 -0
  248. package/runtime-dynamic/preview-resource-base.d.ts +12 -0
  249. package/runtime-dynamic/preview-resource-base.js +65 -0
  250. package/runtime-dynamic/registry/component-registry.d.ts +3 -0
  251. package/runtime-dynamic/registry/component-registry.js +353 -0
  252. package/runtime-dynamic/registry/custom-widget-registry.d.ts +7 -0
  253. package/runtime-dynamic/registry/custom-widget-registry.js +18 -0
  254. package/runtime-dynamic/registry/index.d.ts +2 -0
  255. package/runtime-dynamic/registry/index.js +63 -0
  256. package/runtime-dynamic/registry/store.d.ts +9 -0
  257. package/runtime-dynamic/registry/store.js +26 -0
  258. package/runtime-dynamic/routes.d.ts +2 -0
  259. package/runtime-dynamic/routes.js +107 -0
  260. package/runtime-dynamic/services/app-extension-provider.d.ts +1 -0
  261. package/runtime-dynamic/services/app-extension-provider.js +45 -0
  262. package/runtime-dynamic/services/cache.d.ts +29 -0
  263. package/runtime-dynamic/services/cache.js +57 -0
  264. package/runtime-dynamic/services/component-ref-provider.d.ts +12 -0
  265. package/runtime-dynamic/services/component-ref-provider.js +149 -0
  266. package/runtime-dynamic/services/css-scoping.d.ts +2 -0
  267. package/runtime-dynamic/services/css-scoping.js +53 -0
  268. package/runtime-dynamic/services/fragment-url.d.ts +16 -0
  269. package/runtime-dynamic/services/fragment-url.js +74 -0
  270. package/runtime-dynamic/services/index.d.ts +10 -0
  271. package/runtime-dynamic/services/index.js +152 -0
  272. package/runtime-dynamic/services/markup-transpiler.d.ts +12 -0
  273. package/runtime-dynamic/services/markup-transpiler.js +250 -0
  274. package/runtime-dynamic/services/prefab-resources.d.ts +18 -0
  275. package/runtime-dynamic/services/prefab-resources.js +159 -0
  276. package/runtime-dynamic/services/resource-manager.d.ts +2 -0
  277. package/runtime-dynamic/services/resource-manager.js +66 -0
  278. package/runtime-dynamic/services/script-executor.d.ts +8 -0
  279. package/runtime-dynamic/services/script-executor.js +90 -0
  280. package/runtime-dynamic/services/variable-factory.d.ts +2 -0
  281. package/runtime-dynamic/services/variable-factory.js +260 -0
  282. package/runtime-dynamic/services/variable-registry.d.ts +12 -0
  283. package/runtime-dynamic/services/variable-registry.js +118 -0
  284. package/runtime-dynamic/services/variable-transpiler.d.ts +5 -0
  285. package/runtime-dynamic/services/variable-transpiler.js +159 -0
  286. package/runtime-dynamic/shims/next-image.d.ts +35 -0
  287. package/runtime-dynamic/shims/next-image.js +60 -0
  288. package/runtime-dynamic/shims/next-link.d.ts +25 -0
  289. package/runtime-dynamic/shims/next-link.js +33 -0
  290. package/runtime-dynamic/shims/next-navigation.d.ts +16 -0
  291. package/runtime-dynamic/shims/next-navigation.js +52 -0
  292. package/runtime-dynamic/utils/index.d.ts +9 -0
  293. package/runtime-dynamic/utils/index.js +40 -0
  294. package/store/middleware/navigationMiddleware.js +1 -1
  295. package/store/slices/appConfigSlice.js +10 -8
  296. package/store/slices/authSlice.js +46 -32
  297. package/tsconfig.declaration.tsbuildinfo +1 -1
  298. package/types/index.d.ts +1 -0
  299. package/utils/attr.js +71 -14
  300. package/utils/custom-expression/index.d.ts +43 -0
  301. package/utils/custom-expression/index.js +161 -0
  302. package/utils/custom-expression/parser.d.ts +15 -0
  303. package/utils/custom-expression/parser.js +208 -0
  304. package/utils/layoutsize-util.d.ts +1 -0
  305. package/utils/layoutsize-util.js +57 -0
  306. package/utils/lib-error-skipper.d.ts +4 -26
  307. package/utils/lib-error-skipper.js +41 -165
  308. package/utils/style-utils.d.ts +6 -0
  309. package/utils/style-utils.js +10 -1
  310. package/variables/metadata.service.js +2 -3
  311. package/variables/model-variable.js +10 -7
  312. package/variables/service-variable.d.ts +1 -0
  313. package/variables/service-variable.js +26 -6
  314. package/components/input/epoch/datetime/styled.d.ts +0 -78
  315. package/components/input/epoch/datetime/styled.js +0 -90
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.clearTranspileCache = clearTranspileCache;
8
+ exports.renderTranspiledMarkup = renderTranspiledMarkup;
9
+ exports.transpileAndRender = transpileAndRender;
10
+ exports.transpileFragment = transpileFragment;
11
+ var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _transpiler = require("@wavemaker-ai/react-codegen/transpiler");
16
+ var _sucrase = require("sucrase");
17
+ var _componentRegistry = require("../registry/component-registry");
18
+ var _util = require("@wavemaker-ai/react-runtime/core/util");
19
+ var _appInitializer = require("../app-initializer");
20
+ var _variableRegistry = require("./variable-registry");
21
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
22
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
23
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
+ var compiledCache = new Map();
25
+ var transpiledCache = new Map();
26
+ var componentNameCache = new Map();
27
+ var AUTOLAYOUT_SCOPE = "autolayout-dynamic";
28
+ var injectedAutoLayoutRules = new Set();
29
+ function injectAutolayoutCss(rules) {
30
+ var newRules = rules.filter(function (r) {
31
+ return !injectedAutoLayoutRules.has(r);
32
+ });
33
+ if (newRules.length === 0) return;
34
+ newRules.forEach(function (r) {
35
+ return injectedAutoLayoutRules.add(r);
36
+ });
37
+ var styleEl = document.querySelector("style[data-wm-scope=\"".concat(AUTOLAYOUT_SCOPE, "\"]"));
38
+ if (!styleEl) {
39
+ styleEl = document.createElement("style");
40
+ styleEl.setAttribute("data-wm-scope", AUTOLAYOUT_SCOPE);
41
+ document.head.appendChild(styleEl);
42
+ }
43
+ styleEl.textContent += "\n" + newRules.join("\n\n") + "\n";
44
+ }
45
+ var UTIL_SCOPE = {
46
+ formatMessage: _util.formatMessage,
47
+ _get: _util._get,
48
+ toNumber: _util.toNumber
49
+ };
50
+ var lazyPartialCache = new Map();
51
+ function markupErrorNode(className, message) {
52
+ return /*#__PURE__*/_react["default"].createElement("div", {
53
+ className: className
54
+ }, message);
55
+ }
56
+ function extractMarkupComponents(markup) {
57
+ var cached = componentNameCache.get(markup);
58
+ if (cached) return cached;
59
+ var matches = markup.match(/\bWm[A-Z]\w*/g);
60
+ var result = matches ? (0, _toConsumableArray2["default"])(new Set(matches)) : [];
61
+ componentNameCache.set(markup, result);
62
+ return result;
63
+ }
64
+ function resolveScope(imports, appState, markup) {
65
+ var fragment = appState;
66
+ var names = ["React", "fragment", "Widgets", "Variables"];
67
+ var values = [_react["default"], appState, fragment === null || fragment === void 0 ? void 0 : fragment.Widgets, fragment === null || fragment === void 0 ? void 0 : fragment.Variables];
68
+ var seen = new Set(["React", "fragment", "Widgets", "Variables"]);
69
+ var knownPartials = new Set((0, _appInitializer.getPartialNames)());
70
+ var _iterator = _createForOfIteratorHelper(imports),
71
+ _step;
72
+ try {
73
+ var _loop = function _loop() {
74
+ var importDef = _step.value;
75
+ var name = importDef.as || importDef.name;
76
+ if (seen.has(name)) return 0; // continue
77
+ var component = (0, _componentRegistry.getComponent)(name);
78
+ if (component) {
79
+ seen.add(name);
80
+ names.push(name);
81
+ values.push(component);
82
+ return 0; // continue
83
+ }
84
+ var partialName = (0, _toConsumableArray2["default"])(knownPartials).find(function (p) {
85
+ return p.toLowerCase() === name.toLowerCase();
86
+ });
87
+ if (partialName) {
88
+ if (!lazyPartialCache.has(partialName)) {
89
+ lazyPartialCache.set(partialName, (0, _variableRegistry.createLazyPartial)(partialName));
90
+ }
91
+ seen.add(name);
92
+ names.push(name);
93
+ values.push(lazyPartialCache.get(partialName));
94
+ }
95
+ },
96
+ _ret;
97
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
98
+ _ret = _loop();
99
+ if (_ret === 0) continue;
100
+ }
101
+ } catch (err) {
102
+ _iterator.e(err);
103
+ } finally {
104
+ _iterator.f();
105
+ }
106
+ if (markup) {
107
+ var _iterator2 = _createForOfIteratorHelper(extractMarkupComponents(markup)),
108
+ _step2;
109
+ try {
110
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
111
+ var name = _step2.value;
112
+ if (seen.has(name)) continue;
113
+ var component = (0, _componentRegistry.getComponent)(name);
114
+ if (component) {
115
+ seen.add(name);
116
+ names.push(name);
117
+ values.push(component);
118
+ }
119
+ }
120
+ } catch (err) {
121
+ _iterator2.e(err);
122
+ } finally {
123
+ _iterator2.f();
124
+ }
125
+ }
126
+ for (var _i = 0, _Object$entries = Object.entries(UTIL_SCOPE); _i < _Object$entries.length; _i++) {
127
+ var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
128
+ _name = _Object$entries$_i[0],
129
+ value = _Object$entries$_i[1];
130
+ if (!seen.has(_name)) {
131
+ seen.add(_name);
132
+ names.push(_name);
133
+ values.push(value);
134
+ }
135
+ }
136
+ return {
137
+ names: names,
138
+ values: values
139
+ };
140
+ }
141
+ function compileJsx(jsxCode) {
142
+ var result = (0, _sucrase.transform)(jsxCode, {
143
+ transforms: ["typescript", "jsx"],
144
+ jsxRuntime: "classic",
145
+ production: true
146
+ });
147
+ return result.code;
148
+ }
149
+ function transpileFragment(markup, variablesOrOptions) {
150
+ var _transpiled$autolayou;
151
+ if (!(markup !== null && markup !== void 0 && markup.trim())) return null;
152
+ var variables;
153
+ var isPartOfPrefab = false;
154
+ var prefabName;
155
+ if (variablesOrOptions && ("isPartOfPrefab" in variablesOrOptions || "prefabName" in variablesOrOptions)) {
156
+ var _opts$isPartOfPrefab;
157
+ var opts = variablesOrOptions;
158
+ variables = opts.variables;
159
+ isPartOfPrefab = (_opts$isPartOfPrefab = opts.isPartOfPrefab) !== null && _opts$isPartOfPrefab !== void 0 ? _opts$isPartOfPrefab : false;
160
+ prefabName = opts.prefabName;
161
+ } else {
162
+ variables = variablesOrOptions;
163
+ }
164
+ var cacheKey = prefabName ? "prefab:".concat(prefabName, ":").concat(markup) : markup;
165
+ var cached = transpiledCache.get(cacheKey);
166
+ if (cached) return cached;
167
+ var config = (0, _appInitializer.getProjectConfig)();
168
+ var appUrl = config.deployUrl || "./";
169
+ var transpiled = (0, _transpiler.transformMarkup)(markup, {
170
+ variables: variables,
171
+ appUrl: appUrl,
172
+ isPartOfPrefab: isPartOfPrefab,
173
+ prefabName: prefabName
174
+ });
175
+ if ((_transpiled$autolayou = transpiled.autolayoutCss) !== null && _transpiled$autolayou !== void 0 && _transpiled$autolayou.length) {
176
+ injectAutolayoutCss(transpiled.autolayoutCss);
177
+ }
178
+ transpiledCache.set(cacheKey, transpiled);
179
+ return transpiled;
180
+ }
181
+ function renderTranspiledMarkup(transpiled, appState) {
182
+ var cacheKey = transpiled.markup;
183
+ var cached = compiledCache.get(cacheKey);
184
+ if (!cached) {
185
+ var jsxString = transpiled.markup;
186
+ var jsxWrapped = "function __render__() { return (<React.Fragment>".concat(jsxString.trim() || "null", "</React.Fragment>); }");
187
+ var compiledCode;
188
+ try {
189
+ var compiled = compileJsx(jsxWrapped);
190
+ compiledCode = "".concat(compiled, "\nreturn __render__();");
191
+ } catch (compileError) {
192
+ console.error("[markup-transpiler] Compilation failed:", compileError);
193
+ console.error("[markup-transpiler] JSX input:", jsxWrapped);
194
+ return markupErrorNode("wm-transpile-error", "Transpilation error");
195
+ }
196
+ var _resolveScope = resolveScope(transpiled.imports, appState, jsxWrapped),
197
+ names = _resolveScope.names,
198
+ values = _resolveScope.values;
199
+ var renderFn;
200
+ try {
201
+ renderFn = (0, _construct2["default"])(Function, (0, _toConsumableArray2["default"])(names).concat([compiledCode]));
202
+ } catch (constructionError) {
203
+ console.error("[markup-transpiler] Function compilation failed:", constructionError);
204
+ console.error("[markup-transpiler] Compiled code:", compiledCode);
205
+ return markupErrorNode("wm-transpile-error", "Compilation error");
206
+ }
207
+ var reactIdx = names.indexOf("React");
208
+ var fragmentIdx = names.indexOf("fragment");
209
+ var widgetsIdx = names.indexOf("Widgets");
210
+ var variablesIdx = names.indexOf("Variables");
211
+ cached = {
212
+ renderFn: renderFn,
213
+ scopeNames: names,
214
+ runtimeValues: values,
215
+ reactIdx: reactIdx,
216
+ fragmentIdx: fragmentIdx,
217
+ widgetsIdx: widgetsIdx,
218
+ variablesIdx: variablesIdx
219
+ };
220
+ compiledCache.set(cacheKey, cached);
221
+ }
222
+
223
+ // Mutate the 4 dynamic slots in-place — avoids a per-render array allocation.
224
+ var runtimeFragment = appState;
225
+ cached.runtimeValues[cached.reactIdx] = _react["default"];
226
+ cached.runtimeValues[cached.fragmentIdx] = appState;
227
+ cached.runtimeValues[cached.widgetsIdx] = runtimeFragment === null || runtimeFragment === void 0 ? void 0 : runtimeFragment.Widgets;
228
+ cached.runtimeValues[cached.variablesIdx] = runtimeFragment === null || runtimeFragment === void 0 ? void 0 : runtimeFragment.Variables;
229
+ try {
230
+ var _cached;
231
+ return (_cached = cached).renderFn.apply(_cached, (0, _toConsumableArray2["default"])(cached.runtimeValues));
232
+ } catch (renderError) {
233
+ console.error("[markup-transpiler] Render failed:", renderError);
234
+ return markupErrorNode("wm-render-error", "Render error");
235
+ }
236
+ }
237
+ function transpileAndRender(markup, appState, variables) {
238
+ var transpiled = transpileFragment(markup, variables);
239
+ if (!transpiled) return null;
240
+ return renderTranspiledMarkup(transpiled, appState);
241
+ }
242
+ function clearTranspileCache() {
243
+ compiledCache.clear();
244
+ transpiledCache.clear();
245
+ componentNameCache.clear();
246
+ lazyPartialCache.clear();
247
+ injectedAutoLayoutRules.clear();
248
+ var styleEl = document.querySelector("style[data-wm-scope=\"".concat(AUTOLAYOUT_SCOPE, "\"]"));
249
+ if (styleEl) styleEl.remove();
250
+ }
@@ -0,0 +1,18 @@
1
+ /** Cleared with `clearComponentRefCache` so a new preview session can reload scripts/styles. */
2
+ export declare function clearPrefabResourcesLoaded(): void;
3
+ /**
4
+ * Mirrors Angular `getPrefabResourceUrl` in `runtime-base` `prefab-manager.service.ts`.
5
+ */
6
+ export declare function getPrefabResourceUrl(resourcePath: string, resourceBasePath: string): string;
7
+ export type PrefabConfigResources = {
8
+ resources?: {
9
+ styles?: string[];
10
+ scripts?: string[];
11
+ };
12
+ };
13
+ /**
14
+ * Loads `resources.styles` / `resources.scripts` from prefab `config.json` like Angular
15
+ * `PrefabManagerService.loadDependencies` (`loadStyleSheets` / `loadScripts` from `@wm/core`).
16
+ * Runs at most once per `prefabName` per page session.
17
+ */
18
+ export declare function loadPrefabResourcesFromConfig(prefabName: string, config: PrefabConfigResources): Promise<void>;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.clearPrefabResourcesLoaded = clearPrefabResourcesLoaded;
8
+ exports.getPrefabResourceUrl = getPrefabResourceUrl;
9
+ exports.loadPrefabResourcesFromConfig = loadPrefabResourcesFromConfig;
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _endsWith = _interopRequireDefault(require("lodash-es/endsWith"));
13
+ var _previewResourceBase = require("../preview-resource-base");
14
+ var _fragmentUrl = require("./fragment-url");
15
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
16
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
17
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
+ /** Do not inject Main page CSS from prefab config — same as Angular `PrefabManagerService.loadStyles`. */
19
+ var PREFAB_MAIN_PAGE_CSS_SUFFIX = "/pages/Main/Main.css";
20
+ var prefabResourcesLoaded = new Set();
21
+
22
+ /** Cleared with `clearComponentRefCache` so a new preview session can reload scripts/styles. */
23
+ function clearPrefabResourcesLoaded() {
24
+ prefabResourcesLoaded.clear();
25
+ }
26
+ function isAbsoluteResourcePath(path) {
27
+ return /^https?:\/\//i.test(path) || path.startsWith("//");
28
+ }
29
+
30
+ /**
31
+ * Mirrors Angular `getPrefabResourceUrl` in `runtime-base` `prefab-manager.service.ts`.
32
+ */
33
+ function getPrefabResourceUrl(resourcePath, resourceBasePath) {
34
+ if (isAbsoluteResourcePath(resourcePath)) {
35
+ return resourcePath;
36
+ }
37
+ return "".concat(resourceBasePath).concat(resourcePath);
38
+ }
39
+ function isStylesheetLoaded(href) {
40
+ var links = document.getElementsByTagName("link");
41
+ for (var i = 0; i < links.length; i++) {
42
+ var el = links[i];
43
+ if (el.rel === "stylesheet" && el.getAttribute("href") === href) return true;
44
+ }
45
+ return false;
46
+ }
47
+ function loadStyleSheetOnce(href) {
48
+ var resolved = (0, _previewResourceBase.resolvePreviewFetchUrl)(href);
49
+ if (!resolved || isStylesheetLoaded(resolved)) return;
50
+ var link = document.createElement("link");
51
+ link.rel = "stylesheet";
52
+ link.type = "text/css";
53
+ link.href = resolved;
54
+ document.head.appendChild(link);
55
+ }
56
+ function isScriptLoaded(src) {
57
+ var scripts = document.getElementsByTagName("script");
58
+ for (var i = 0; i < scripts.length; i++) {
59
+ if (scripts[i].getAttribute("src") === src) return true;
60
+ }
61
+ return false;
62
+ }
63
+ function loadScriptOnce(src) {
64
+ var trimmed = (0, _previewResourceBase.resolvePreviewFetchUrl)(src.trim());
65
+ if (!trimmed || isScriptLoaded(trimmed)) {
66
+ return Promise.resolve();
67
+ }
68
+ return new Promise(function (resolve, reject) {
69
+ var script = document.createElement("script");
70
+ script.type = "text/javascript";
71
+ script.async = false;
72
+ script.src = trimmed;
73
+ script.onload = function () {
74
+ return resolve();
75
+ };
76
+ script.onerror = function () {
77
+ return reject(new Error("Failed to load script: ".concat(trimmed)));
78
+ };
79
+ document.head.appendChild(script);
80
+ });
81
+ }
82
+ /**
83
+ * Loads `resources.styles` / `resources.scripts` from prefab `config.json` like Angular
84
+ * `PrefabManagerService.loadDependencies` (`loadStyleSheets` / `loadScripts` from `@wm/core`).
85
+ * Runs at most once per `prefabName` per page session.
86
+ */
87
+ function loadPrefabResourcesFromConfig(_x, _x2) {
88
+ return _loadPrefabResourcesFromConfig.apply(this, arguments);
89
+ }
90
+ function _loadPrefabResourcesFromConfig() {
91
+ _loadPrefabResourcesFromConfig = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(prefabName, config) {
92
+ var _config$resources$sty, _config$resources, _config$resources$scr, _config$resources2;
93
+ var styles, scripts, basePath, styleUrls, scriptUrls, _iterator, _step, src;
94
+ return _regenerator["default"].wrap(function _callee$(_context) {
95
+ while (1) switch (_context.prev = _context.next) {
96
+ case 0:
97
+ if (!prefabResourcesLoaded.has(prefabName)) {
98
+ _context.next = 2;
99
+ break;
100
+ }
101
+ return _context.abrupt("return");
102
+ case 2:
103
+ styles = (_config$resources$sty = (_config$resources = config.resources) === null || _config$resources === void 0 ? void 0 : _config$resources.styles) !== null && _config$resources$sty !== void 0 ? _config$resources$sty : [];
104
+ scripts = ((_config$resources$scr = (_config$resources2 = config.resources) === null || _config$resources2 === void 0 ? void 0 : _config$resources2.scripts) !== null && _config$resources$scr !== void 0 ? _config$resources$scr : []).filter(function (s) {
105
+ return !s.startsWith("npm://");
106
+ });
107
+ basePath = (0, _fragmentUrl.getPrefabBaseUrl)(prefabName);
108
+ styleUrls = styles.map(function (url) {
109
+ return getPrefabResourceUrl(url, basePath);
110
+ }).filter(function (url) {
111
+ return !!url && !(0, _endsWith["default"])(url, PREFAB_MAIN_PAGE_CSS_SUFFIX);
112
+ });
113
+ scriptUrls = scripts.map(function (url) {
114
+ return getPrefabResourceUrl(url, basePath);
115
+ });
116
+ styleUrls.forEach(loadStyleSheetOnce);
117
+ _iterator = _createForOfIteratorHelper(scriptUrls);
118
+ _context.prev = 9;
119
+ _iterator.s();
120
+ case 11:
121
+ if ((_step = _iterator.n()).done) {
122
+ _context.next = 23;
123
+ break;
124
+ }
125
+ src = _step.value;
126
+ _context.prev = 13;
127
+ _context.next = 16;
128
+ return loadScriptOnce(src);
129
+ case 16:
130
+ _context.next = 21;
131
+ break;
132
+ case 18:
133
+ _context.prev = 18;
134
+ _context.t0 = _context["catch"](13);
135
+ console.warn("[prefab-resources] Optional script failed:", src, _context.t0);
136
+ case 21:
137
+ _context.next = 11;
138
+ break;
139
+ case 23:
140
+ _context.next = 28;
141
+ break;
142
+ case 25:
143
+ _context.prev = 25;
144
+ _context.t1 = _context["catch"](9);
145
+ _iterator.e(_context.t1);
146
+ case 28:
147
+ _context.prev = 28;
148
+ _iterator.f();
149
+ return _context.finish(28);
150
+ case 31:
151
+ prefabResourcesLoaded.add(prefabName);
152
+ case 32:
153
+ case "end":
154
+ return _context.stop();
155
+ }
156
+ }, _callee, null, [[9, 25, 28, 31], [13, 18]]);
157
+ }));
158
+ return _loadPrefabResourcesFromConfig.apply(this, arguments);
159
+ }
@@ -0,0 +1,2 @@
1
+ export declare function fetchResource<T = unknown>(url: string, useCache?: boolean): Promise<T>;
2
+ export declare function clearResourceCache(): void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.clearResourceCache = clearResourceCache;
8
+ exports.fetchResource = fetchResource;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _axios = _interopRequireDefault(require("axios"));
12
+ var _previewResourceBase = require("../preview-resource-base");
13
+ var _app = require("@wavemaker-ai/react-runtime/core/app.service");
14
+ var cache = new Map();
15
+ function fetchResource(_x) {
16
+ return _fetchResource.apply(this, arguments);
17
+ }
18
+ function _fetchResource() {
19
+ _fetchResource = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(url) {
20
+ var useCache,
21
+ resolvedUrl,
22
+ response,
23
+ data,
24
+ _error$response,
25
+ status,
26
+ _args = arguments;
27
+ return _regenerator["default"].wrap(function _callee$(_context) {
28
+ while (1) switch (_context.prev = _context.next) {
29
+ case 0:
30
+ useCache = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;
31
+ resolvedUrl = (0, _previewResourceBase.resolvePreviewFetchUrl)(url);
32
+ if (!(useCache && cache.has(resolvedUrl))) {
33
+ _context.next = 4;
34
+ break;
35
+ }
36
+ return _context.abrupt("return", cache.get(resolvedUrl));
37
+ case 4:
38
+ _context.prev = 4;
39
+ _context.next = 7;
40
+ return _axios["default"].get(resolvedUrl);
41
+ case 7:
42
+ response = _context.sent;
43
+ data = response.data;
44
+ if (useCache) {
45
+ cache.set(resolvedUrl, data);
46
+ }
47
+ return _context.abrupt("return", data);
48
+ case 13:
49
+ _context.prev = 13;
50
+ _context.t0 = _context["catch"](4);
51
+ status = _context.t0 === null || _context.t0 === void 0 || (_error$response = _context.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status;
52
+ if (status === 401 || status === 403) {
53
+ (0, _app.handle401)();
54
+ }
55
+ throw _context.t0;
56
+ case 18:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }, _callee, null, [[4, 13]]);
61
+ }));
62
+ return _fetchResource.apply(this, arguments);
63
+ }
64
+ function clearResourceCache() {
65
+ cache.clear();
66
+ }
@@ -0,0 +1,8 @@
1
+ type ScriptFn = (app: unknown, page: unknown) => void;
2
+ export declare enum ScriptScope {
3
+ PAGE = "Page",
4
+ PARTIAL = "Partial",
5
+ PREFAB = "Prefab"
6
+ }
7
+ export declare function buildAddPageScript(script: string, scopeKind: ScriptScope, componentName: string): ScriptFn;
8
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ScriptScope = void 0;
9
+ exports.buildAddPageScript = buildAddPageScript;
10
+ var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var lodash = _interopRequireWildcard(require("lodash-es"));
13
+ var _moment = _interopRequireDefault(require("moment"));
14
+ var _utils = require("@wavemaker-ai/react-runtime/core/util/utils");
15
+ var _cache = require("./cache");
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
17
+ var ScriptScope = exports.ScriptScope = /*#__PURE__*/function (ScriptScope) {
18
+ ScriptScope["PAGE"] = "Page";
19
+ ScriptScope["PARTIAL"] = "Partial";
20
+ ScriptScope["PREFAB"] = "Prefab";
21
+ return ScriptScope;
22
+ }({});
23
+ var IMPORT_LINE_RE = /^\s*import\s+.*?["'];?\s*$/gm;
24
+ var EXPORTED_FN_HEADER_RE = /^\s*export\s+default\s+function\s+\w+\s*\([^)]*\)\s*\{/m;
25
+
26
+ // Proxy-safe structuredClone: the reactive proxy system wraps variable dataSets
27
+ // in Proxy objects, which native structuredClone cannot handle. This shim
28
+ // unwraps proxies via JSON round-trip before cloning.
29
+ function safeStructuredClone(value) {
30
+ try {
31
+ return structuredClone(value);
32
+ } catch (_unused) {
33
+ try {
34
+ return JSON.parse(JSON.stringify(value));
35
+ } catch (_unused2) {
36
+ return value;
37
+ }
38
+ }
39
+ }
40
+ var SCRIPT_GLOBALS = {
41
+ _: lodash,
42
+ moment: _moment["default"],
43
+ Utils: _utils.Utils,
44
+ structuredClone: safeStructuredClone
45
+ };
46
+
47
+ // Globals loaded asynchronously (e.g. via dynamic import in app-initializer).
48
+ // Resolved from window at script execution time, not at compile time.
49
+ var DEFERRED_GLOBALS = ["QRCode"];
50
+ function prepareScript(raw) {
51
+ var code = raw.replace(IMPORT_LINE_RE, "");
52
+ var headerMatch = code.match(EXPORTED_FN_HEADER_RE);
53
+ if (headerMatch) {
54
+ var headerEnd = code.indexOf(headerMatch[0]) + headerMatch[0].length;
55
+ var body = code.slice(headerEnd);
56
+ var lastBrace = body.lastIndexOf("}");
57
+ return lastBrace >= 0 ? body.slice(0, lastBrace) : body;
58
+ }
59
+ code = code.replace(/^\s*export\s+default\s+/m, "");
60
+ return code;
61
+ }
62
+ function buildAddPageScript(script, scopeKind, componentName) {
63
+ if (!script) return function () {};
64
+ var cacheKey = "".concat(scopeKind, ":").concat(componentName);
65
+ var cached = (0, _cache.getScriptFromCache)(cacheKey);
66
+ if (cached) return cached;
67
+ try {
68
+ var cleanScript = prepareScript(script);
69
+ var allNames = [].concat((0, _toConsumableArray2["default"])(Object.keys(SCRIPT_GLOBALS)), DEFERRED_GLOBALS);
70
+ var compiledFn = (0, _construct2["default"])(Function, ["App", scopeKind].concat((0, _toConsumableArray2["default"])(allNames), [cleanScript]));
71
+ var staticValues = Object.keys(SCRIPT_GLOBALS).map(function (k) {
72
+ return SCRIPT_GLOBALS[k];
73
+ });
74
+ var boundFn = function boundFn(app, page) {
75
+ try {
76
+ var deferredValues = DEFERRED_GLOBALS.map(function (k) {
77
+ return window[k];
78
+ });
79
+ compiledFn.apply(void 0, [app, page].concat((0, _toConsumableArray2["default"])(staticValues), (0, _toConsumableArray2["default"])(deferredValues)));
80
+ } catch (runtimeError) {
81
+ console.error("[script-executor] Runtime error in ".concat(scopeKind, " script \"").concat(componentName, "\":"), runtimeError);
82
+ }
83
+ };
84
+ (0, _cache.setScriptInCache)(cacheKey, boundFn);
85
+ return boundFn;
86
+ } catch (compileError) {
87
+ console.error("[script-executor] Compilation error in ".concat(scopeKind, " script \"").concat(componentName, "\":"), compileError);
88
+ return function () {};
89
+ }
90
+ }
@@ -0,0 +1,2 @@
1
+ import { type VariablesResult } from "./variable-registry";
2
+ export declare function createVariablesFromJson(rawVariables: Record<string, unknown>, scopeProxy: any): VariablesResult;