@teleporthq/teleport-plugin-common 0.45.3-alpha.0 → 0.45.13

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 (200) hide show
  1. package/__tests__/builders/html-builders.ts +9 -2
  2. package/__tests__/builders/style-builders.ts +135 -1
  3. package/__tests__/node-handlers/node-to-html/index.ts +2 -0
  4. package/__tests__/node-handlers/node-to-jsx/attribute-value-mapper.ts +77 -0
  5. package/__tests__/node-handlers/node-to-jsx/calendar-events-reviver.ts +176 -0
  6. package/__tests__/node-handlers/node-to-jsx/chart-data-guard.ts +101 -0
  7. package/__tests__/node-handlers/node-to-jsx/cms-list-repeater-ecommerce-source.ts +79 -0
  8. package/__tests__/node-handlers/node-to-jsx/cms-list-repeater-loading.ts +122 -0
  9. package/__tests__/node-handlers/node-to-jsx/index.ts +719 -3
  10. package/__tests__/node-handlers/node-to-jsx/url-search-params-expression.ts +59 -0
  11. package/__tests__/node-handlers/node-to-jsx/utils.ts +635 -3
  12. package/__tests__/utils/ast-utils.ts +188 -0
  13. package/__tests__/utils/content-property-sanitiser.ts +156 -0
  14. package/__tests__/utils/page-seeds-state-from-data-source.ts +70 -0
  15. package/__tests__/utils/parse-string-with-template-expressions.ts +82 -0
  16. package/__tests__/utils/resource-auth-scheme.ts +55 -0
  17. package/__tests__/utils/route-utils.ts +118 -0
  18. package/__tests__/utils/style-utils.ts +59 -0
  19. package/__tests__/utils/template-expression-balance.ts +83 -0
  20. package/__tests__/utils/url-query-writer.ts +239 -0
  21. package/__tests__/utils/url-search-param-sync.ts +138 -0
  22. package/__tests__/utils/url-search-params.ts +48 -0
  23. package/dist/cjs/builders/ast-builders.d.ts +2 -0
  24. package/dist/cjs/builders/ast-builders.d.ts.map +1 -1
  25. package/dist/cjs/builders/ast-builders.js +41 -3
  26. package/dist/cjs/builders/ast-builders.js.map +1 -1
  27. package/dist/cjs/builders/hast-builders.d.ts +1 -0
  28. package/dist/cjs/builders/hast-builders.d.ts.map +1 -1
  29. package/dist/cjs/builders/hast-builders.js +11 -1
  30. package/dist/cjs/builders/hast-builders.js.map +1 -1
  31. package/dist/cjs/builders/style-builders.d.ts +8 -2
  32. package/dist/cjs/builders/style-builders.d.ts.map +1 -1
  33. package/dist/cjs/builders/style-builders.js +80 -33
  34. package/dist/cjs/builders/style-builders.js.map +1 -1
  35. package/dist/cjs/index.d.ts +5 -1
  36. package/dist/cjs/index.d.ts.map +1 -1
  37. package/dist/cjs/index.js +10 -1
  38. package/dist/cjs/index.js.map +1 -1
  39. package/dist/cjs/node-handlers/node-to-html/constants.d.ts.map +1 -1
  40. package/dist/cjs/node-handlers/node-to-html/constants.js +2 -0
  41. package/dist/cjs/node-handlers/node-to-html/constants.js.map +1 -1
  42. package/dist/cjs/node-handlers/node-to-html/index.d.ts.map +1 -1
  43. package/dist/cjs/node-handlers/node-to-html/index.js +69 -1
  44. package/dist/cjs/node-handlers/node-to-html/index.js.map +1 -1
  45. package/dist/cjs/node-handlers/node-to-html/types.d.ts +5 -1
  46. package/dist/cjs/node-handlers/node-to-html/types.d.ts.map +1 -1
  47. package/dist/cjs/node-handlers/node-to-html/utils.d.ts +2 -1
  48. package/dist/cjs/node-handlers/node-to-html/utils.d.ts.map +1 -1
  49. package/dist/cjs/node-handlers/node-to-html/utils.js +174 -13
  50. package/dist/cjs/node-handlers/node-to-html/utils.js.map +1 -1
  51. package/dist/cjs/node-handlers/node-to-jsx/index.d.ts.map +1 -1
  52. package/dist/cjs/node-handlers/node-to-jsx/index.js +1443 -45
  53. package/dist/cjs/node-handlers/node-to-jsx/index.js.map +1 -1
  54. package/dist/cjs/node-handlers/node-to-jsx/types.d.ts +60 -6
  55. package/dist/cjs/node-handlers/node-to-jsx/types.d.ts.map +1 -1
  56. package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts +80 -7
  57. package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  58. package/dist/cjs/node-handlers/node-to-jsx/utils.js +883 -72
  59. package/dist/cjs/node-handlers/node-to-jsx/utils.js.map +1 -1
  60. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  61. package/dist/cjs/utils/ast-utils.d.ts +163 -11
  62. package/dist/cjs/utils/ast-utils.d.ts.map +1 -1
  63. package/dist/cjs/utils/ast-utils.js +1013 -75
  64. package/dist/cjs/utils/ast-utils.js.map +1 -1
  65. package/dist/cjs/utils/hast-utils.d.ts +8 -6
  66. package/dist/cjs/utils/hast-utils.d.ts.map +1 -1
  67. package/dist/cjs/utils/hast-utils.js +28 -4
  68. package/dist/cjs/utils/hast-utils.js.map +1 -1
  69. package/dist/cjs/utils/nested-selector-commas.d.ts +2 -0
  70. package/dist/cjs/utils/nested-selector-commas.d.ts.map +1 -0
  71. package/dist/cjs/utils/nested-selector-commas.js +81 -0
  72. package/dist/cjs/utils/nested-selector-commas.js.map +1 -0
  73. package/dist/cjs/utils/route-utils.d.ts +117 -0
  74. package/dist/cjs/utils/route-utils.d.ts.map +1 -0
  75. package/dist/cjs/utils/route-utils.js +212 -0
  76. package/dist/cjs/utils/route-utils.js.map +1 -0
  77. package/dist/cjs/utils/style-utils.d.ts +1 -0
  78. package/dist/cjs/utils/style-utils.d.ts.map +1 -1
  79. package/dist/cjs/utils/style-utils.js +181 -2
  80. package/dist/cjs/utils/style-utils.js.map +1 -1
  81. package/dist/cjs/utils/template-expression-balance.d.ts +58 -0
  82. package/dist/cjs/utils/template-expression-balance.d.ts.map +1 -0
  83. package/dist/cjs/utils/template-expression-balance.js +181 -0
  84. package/dist/cjs/utils/template-expression-balance.js.map +1 -0
  85. package/dist/cjs/utils/types.d.ts +3 -0
  86. package/dist/cjs/utils/types.d.ts.map +1 -0
  87. package/dist/cjs/utils/types.js +3 -0
  88. package/dist/cjs/utils/types.js.map +1 -0
  89. package/dist/cjs/utils/url-query-writer.d.ts +123 -0
  90. package/dist/cjs/utils/url-query-writer.d.ts.map +1 -0
  91. package/dist/cjs/utils/url-query-writer.js +260 -0
  92. package/dist/cjs/utils/url-query-writer.js.map +1 -0
  93. package/dist/cjs/utils/url-search-param-sync.d.ts +4 -0
  94. package/dist/cjs/utils/url-search-param-sync.d.ts.map +1 -0
  95. package/dist/cjs/utils/url-search-param-sync.js +241 -0
  96. package/dist/cjs/utils/url-search-param-sync.js.map +1 -0
  97. package/dist/cjs/utils/url-search-params.d.ts +48 -0
  98. package/dist/cjs/utils/url-search-params.d.ts.map +1 -0
  99. package/dist/cjs/utils/url-search-params.js +109 -0
  100. package/dist/cjs/utils/url-search-params.js.map +1 -0
  101. package/dist/esm/builders/ast-builders.d.ts +2 -0
  102. package/dist/esm/builders/ast-builders.d.ts.map +1 -1
  103. package/dist/esm/builders/ast-builders.js +40 -4
  104. package/dist/esm/builders/ast-builders.js.map +1 -1
  105. package/dist/esm/builders/hast-builders.d.ts +1 -0
  106. package/dist/esm/builders/hast-builders.d.ts.map +1 -1
  107. package/dist/esm/builders/hast-builders.js +9 -0
  108. package/dist/esm/builders/hast-builders.js.map +1 -1
  109. package/dist/esm/builders/style-builders.d.ts +8 -2
  110. package/dist/esm/builders/style-builders.d.ts.map +1 -1
  111. package/dist/esm/builders/style-builders.js +78 -32
  112. package/dist/esm/builders/style-builders.js.map +1 -1
  113. package/dist/esm/index.d.ts +5 -1
  114. package/dist/esm/index.d.ts.map +1 -1
  115. package/dist/esm/index.js +5 -1
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/node-handlers/node-to-html/constants.d.ts.map +1 -1
  118. package/dist/esm/node-handlers/node-to-html/constants.js +2 -0
  119. package/dist/esm/node-handlers/node-to-html/constants.js.map +1 -1
  120. package/dist/esm/node-handlers/node-to-html/index.d.ts.map +1 -1
  121. package/dist/esm/node-handlers/node-to-html/index.js +71 -3
  122. package/dist/esm/node-handlers/node-to-html/index.js.map +1 -1
  123. package/dist/esm/node-handlers/node-to-html/types.d.ts +5 -1
  124. package/dist/esm/node-handlers/node-to-html/types.d.ts.map +1 -1
  125. package/dist/esm/node-handlers/node-to-html/utils.d.ts +2 -1
  126. package/dist/esm/node-handlers/node-to-html/utils.d.ts.map +1 -1
  127. package/dist/esm/node-handlers/node-to-html/utils.js +170 -13
  128. package/dist/esm/node-handlers/node-to-html/utils.js.map +1 -1
  129. package/dist/esm/node-handlers/node-to-jsx/index.d.ts.map +1 -1
  130. package/dist/esm/node-handlers/node-to-jsx/index.js +1442 -47
  131. package/dist/esm/node-handlers/node-to-jsx/index.js.map +1 -1
  132. package/dist/esm/node-handlers/node-to-jsx/types.d.ts +60 -6
  133. package/dist/esm/node-handlers/node-to-jsx/types.d.ts.map +1 -1
  134. package/dist/esm/node-handlers/node-to-jsx/utils.d.ts +80 -7
  135. package/dist/esm/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  136. package/dist/esm/node-handlers/node-to-jsx/utils.js +875 -70
  137. package/dist/esm/node-handlers/node-to-jsx/utils.js.map +1 -1
  138. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  139. package/dist/esm/utils/ast-utils.d.ts +163 -11
  140. package/dist/esm/utils/ast-utils.d.ts.map +1 -1
  141. package/dist/esm/utils/ast-utils.js +989 -75
  142. package/dist/esm/utils/ast-utils.js.map +1 -1
  143. package/dist/esm/utils/hast-utils.d.ts +8 -6
  144. package/dist/esm/utils/hast-utils.d.ts.map +1 -1
  145. package/dist/esm/utils/hast-utils.js +26 -3
  146. package/dist/esm/utils/hast-utils.js.map +1 -1
  147. package/dist/esm/utils/nested-selector-commas.d.ts +2 -0
  148. package/dist/esm/utils/nested-selector-commas.d.ts.map +1 -0
  149. package/dist/esm/utils/nested-selector-commas.js +77 -0
  150. package/dist/esm/utils/nested-selector-commas.js.map +1 -0
  151. package/dist/esm/utils/route-utils.d.ts +117 -0
  152. package/dist/esm/utils/route-utils.d.ts.map +1 -0
  153. package/dist/esm/utils/route-utils.js +179 -0
  154. package/dist/esm/utils/route-utils.js.map +1 -0
  155. package/dist/esm/utils/style-utils.d.ts +1 -0
  156. package/dist/esm/utils/style-utils.d.ts.map +1 -1
  157. package/dist/esm/utils/style-utils.js +179 -1
  158. package/dist/esm/utils/style-utils.js.map +1 -1
  159. package/dist/esm/utils/template-expression-balance.d.ts +58 -0
  160. package/dist/esm/utils/template-expression-balance.d.ts.map +1 -0
  161. package/dist/esm/utils/template-expression-balance.js +174 -0
  162. package/dist/esm/utils/template-expression-balance.js.map +1 -0
  163. package/dist/esm/utils/types.d.ts +3 -0
  164. package/dist/esm/utils/types.d.ts.map +1 -0
  165. package/dist/esm/utils/types.js +2 -0
  166. package/dist/esm/utils/types.js.map +1 -0
  167. package/dist/esm/utils/url-query-writer.d.ts +123 -0
  168. package/dist/esm/utils/url-query-writer.d.ts.map +1 -0
  169. package/dist/esm/utils/url-query-writer.js +229 -0
  170. package/dist/esm/utils/url-query-writer.js.map +1 -0
  171. package/dist/esm/utils/url-search-param-sync.d.ts +4 -0
  172. package/dist/esm/utils/url-search-param-sync.d.ts.map +1 -0
  173. package/dist/esm/utils/url-search-param-sync.js +213 -0
  174. package/dist/esm/utils/url-search-param-sync.js.map +1 -0
  175. package/dist/esm/utils/url-search-params.d.ts +48 -0
  176. package/dist/esm/utils/url-search-params.d.ts.map +1 -0
  177. package/dist/esm/utils/url-search-params.js +81 -0
  178. package/dist/esm/utils/url-search-params.js.map +1 -0
  179. package/package.json +4 -4
  180. package/src/builders/ast-builders.ts +80 -3
  181. package/src/builders/hast-builders.ts +11 -0
  182. package/src/builders/style-builders.ts +121 -43
  183. package/src/index.ts +22 -1
  184. package/src/node-handlers/node-to-html/constants.ts +2 -0
  185. package/src/node-handlers/node-to-html/index.ts +126 -6
  186. package/src/node-handlers/node-to-html/types.ts +6 -0
  187. package/src/node-handlers/node-to-html/utils.ts +228 -14
  188. package/src/node-handlers/node-to-jsx/index.ts +2135 -62
  189. package/src/node-handlers/node-to-jsx/types.ts +75 -32
  190. package/src/node-handlers/node-to-jsx/utils.ts +1173 -84
  191. package/src/utils/ast-utils.ts +1316 -127
  192. package/src/utils/hast-utils.ts +37 -9
  193. package/src/utils/nested-selector-commas.ts +88 -0
  194. package/src/utils/route-utils.ts +214 -0
  195. package/src/utils/style-utils.ts +183 -1
  196. package/src/utils/template-expression-balance.ts +196 -0
  197. package/src/utils/types.ts +25 -0
  198. package/src/utils/url-query-writer.ts +318 -0
  199. package/src/utils/url-search-param-sync.ts +303 -0
  200. package/src/utils/url-search-params.ts +122 -0
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
14
  if (ar || !(i in from)) {
@@ -8,10 +19,136 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
19
  return to.concat(ar || Array.prototype.slice.call(from));
9
20
  };
10
21
  import * as types from '@babel/types';
11
- import { convertValueToLiteral } from '../../utils/ast-utils';
12
- import { StringUtils } from '@teleporthq/teleport-shared';
22
+ import { coerceToDeclaredType, convertToBinaryOperator, convertToUnaryOperator, convertValueToLiteral, getExpressionFromUIDLExpressionNode, } from '../../utils/ast-utils';
23
+ import { JSIdentifiers, StringUtils, UIDLUtils } from '@teleporthq/teleport-shared';
24
+ import { generateIdWithRefPath } from '@teleporthq/teleport-shared/dist/cjs/utils/uidl-utils';
13
25
  // Adds all the event handlers and all the instructions for each event handler
14
26
  // in case there is more than one specified in the UIDL
27
+ /** HTML form controls that React treats as "controlled" when given a value/checked prop. */
28
+ var CONTROLLED_FORM_CONTROL_TAGS = new Set(['input', 'textarea', 'select']);
29
+ /**
30
+ * `<input type=...>` values the browser accepts ONLY in a narrow string format,
31
+ * mapped to the number of leading ISO-8601 characters that format requires:
32
+ * datetime-local → `YYYY-MM-DDTHH:mm` (16) date → `YYYY-MM-DD` (10)
33
+ * month → `YYYY-MM` (7)
34
+ * A stored timestamp such as `2026-07-21T20:00:00.000Z` (with seconds/ms and a
35
+ * `Z`) does NOT conform, so the input renders EMPTY — and when it is `required`
36
+ * the whole form fails HTML5 validation and can never submit (edit pages could
37
+ * not be saved). `time` is handled separately because its digits are not a
38
+ * simple prefix. Slicing the ISO STRING (not `new Date(...)`) keeps the nominal
39
+ * wall-clock value and avoids server/browser timezone shifts.
40
+ */
41
+ var DATE_TIME_INPUT_PREFIX_LENGTH = {
42
+ 'datetime-local': 16,
43
+ date: 10,
44
+ month: 7,
45
+ };
46
+ /** Reads a static `type="..."` off a JSX opening tag, lowercased; null if absent/dynamic. */
47
+ var getStaticInputType = function (tag) {
48
+ var typeAttr = tag.openingElement.attributes.find(function (attr) {
49
+ return attr.type === 'JSXAttribute' &&
50
+ attr.name.type === 'JSXIdentifier' &&
51
+ attr.name.name === 'type';
52
+ });
53
+ if (!typeAttr || !typeAttr.value || typeAttr.value.type !== 'StringLiteral') {
54
+ return null;
55
+ }
56
+ return typeAttr.value.value.toLowerCase();
57
+ };
58
+ /**
59
+ * Wrap a bound `<input>` value expression so it renders in the format the input
60
+ * `type` requires. Returns the original expression untouched for non date/time
61
+ * types. `E` → `String(E || '').slice(0, N)` (date/datetime-local/month) or, for
62
+ * `time`, strip an optional leading `YYYY-MM-DD[T| ]` date then take `HH:mm`.
63
+ */
64
+ var buildDateTimeInputValueExpression = function (expression, inputType, t) {
65
+ if (t === void 0) { t = types; }
66
+ var stringified = t.callExpression(t.identifier('String'), [
67
+ t.logicalExpression('||', expression, t.stringLiteral('')),
68
+ ]);
69
+ if (inputType === 'time') {
70
+ var dateStripped = t.callExpression(t.memberExpression(stringified, t.identifier('replace')), [t.regExpLiteral('^\\d{4}-\\d{2}-\\d{2}[T ]', ''), t.stringLiteral('')]);
71
+ return t.callExpression(t.memberExpression(dateStripped, t.identifier('slice')), [
72
+ t.numericLiteral(0),
73
+ t.numericLiteral(5),
74
+ ]);
75
+ }
76
+ var prefixLength = DATE_TIME_INPUT_PREFIX_LENGTH[inputType];
77
+ return t.callExpression(t.memberExpression(stringified, t.identifier('slice')), [
78
+ t.numericLiteral(0),
79
+ t.numericLiteral(prefixLength),
80
+ ]);
81
+ };
82
+ /**
83
+ * React FREEZES a controlled form control (`value`/`checked` set) that has no
84
+ * `onChange` — the user cannot type and a console warning is logged. This is the
85
+ * classic edit-form failure: entity-bound fields rendered `value={props.item?.x}`
86
+ * with no state mirror (the worker intentionally does not mirror entity columns
87
+ * into state). When an `<input>`/`<textarea>`/`<select>` has a `value` (or a
88
+ * checkbox/radio `checked`) attribute but NO `onChange` handler was attached, and
89
+ * it is not `readOnly`/`disabled`, convert it to UNCONTROLLED — `value`→
90
+ * `defaultValue`, `checked`→`defaultChecked`. The control then pre-fills, stays
91
+ * editable, and its live DOM value is what form-submit workflows read via
92
+ * `document.getElementById(id).value`. Controls that ARE controlled (an onChange
93
+ * was already attached — via UIDL events, the form-store binding, or a workflow
94
+ * trigger) and read-only/disabled display fields are left untouched.
95
+ *
96
+ * Must run AFTER all attributes and event handlers have been added to the tag.
97
+ * Mutates the tag in place; idempotent.
98
+ */
99
+ export var makeControlUncontrolledWhenNoChangeHandler = function (tag, elementName, t) {
100
+ if (t === void 0) { t = types; }
101
+ if (!CONTROLLED_FORM_CONTROL_TAGS.has(elementName.toLowerCase())) {
102
+ return;
103
+ }
104
+ var attributes = tag.openingElement.attributes;
105
+ var hasNamedAttribute = function (name) {
106
+ return attributes.some(function (attr) {
107
+ return attr.type === 'JSXAttribute' &&
108
+ attr.name.type === 'JSXIdentifier' &&
109
+ attr.name.name === name;
110
+ });
111
+ };
112
+ // An onChange means it is legitimately controlled; readOnly/disabled inputs are
113
+ // intentionally non-editable display fields (React does not warn on those).
114
+ if (hasNamedAttribute('onChange') ||
115
+ hasNamedAttribute('readOnly') ||
116
+ hasNamedAttribute('disabled')) {
117
+ return;
118
+ }
119
+ // A date/time `<input>` whose value is a dynamic binding (an entity-prefilled
120
+ // edit field) must have its ISO value reformatted to the input's required
121
+ // string shape, or the browser drops it and a `required` field blocks submit.
122
+ var inputType = elementName.toLowerCase() === 'input' ? getStaticInputType(tag) : null;
123
+ var needsDateTimeFormat = inputType !== null && (inputType === 'time' || inputType in DATE_TIME_INPUT_PREFIX_LENGTH);
124
+ var controlledToUncontrolled = [
125
+ ['value', 'defaultValue'],
126
+ ['checked', 'defaultChecked'],
127
+ ];
128
+ var _loop_1 = function (controlled, uncontrolled) {
129
+ var index = attributes.findIndex(function (attr) {
130
+ return attr.type === 'JSXAttribute' &&
131
+ attr.name.type === 'JSXIdentifier' &&
132
+ attr.name.name === controlled;
133
+ });
134
+ if (index !== -1) {
135
+ var attr = attributes[index];
136
+ var attrValue = attr.value;
137
+ if (controlled === 'value' &&
138
+ needsDateTimeFormat &&
139
+ attrValue &&
140
+ attrValue.type === 'JSXExpressionContainer' &&
141
+ attrValue.expression.type !== 'JSXEmptyExpression') {
142
+ attrValue = t.jsxExpressionContainer(buildDateTimeInputValueExpression(attrValue.expression, inputType, t));
143
+ }
144
+ attributes.splice(index, 1, t.jsxAttribute(t.jsxIdentifier(uncontrolled), attrValue));
145
+ }
146
+ };
147
+ for (var _i = 0, controlledToUncontrolled_1 = controlledToUncontrolled; _i < controlledToUncontrolled_1.length; _i++) {
148
+ var _a = controlledToUncontrolled_1[_i], controlled = _a[0], uncontrolled = _a[1];
149
+ _loop_1(controlled, uncontrolled);
150
+ }
151
+ };
15
152
  export var addEventHandlerToTag = function (tag, eventKey, eventHandlerStatements, params, options, t) {
16
153
  if (t === void 0) { t = types; }
17
154
  var eventHandlerASTStatements = [];
@@ -31,15 +168,18 @@ export var addEventHandlerToTag = function (tag, eventKey, eventHandlerStatement
31
168
  }
32
169
  });
33
170
  var expressionContent;
171
+ var functionParams = eventHandlerStatements.some(function (eventHandler) { return eventHandler.includeEventObject; })
172
+ ? [t.identifier('event')]
173
+ : [];
34
174
  if (eventHandlerASTStatements.length === 1) {
35
175
  var expression = eventHandlerASTStatements[0].expression;
36
176
  expressionContent =
37
177
  expression.type === 'CallExpression' && expression.arguments.length === 0
38
178
  ? expression.callee
39
- : t.arrowFunctionExpression([], expression);
179
+ : t.arrowFunctionExpression(functionParams, expression);
40
180
  }
41
181
  else {
42
- expressionContent = t.arrowFunctionExpression([], t.blockStatement(eventHandlerASTStatements));
182
+ expressionContent = t.arrowFunctionExpression(functionParams, t.blockStatement(eventHandlerASTStatements));
43
183
  }
44
184
  tag.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier(eventKey), t.jsxExpressionContainer(expressionContent)));
45
185
  };
@@ -58,9 +198,35 @@ var createPropCallStatement = function (eventHandlerStatement, propDefinitions,
58
198
  var prefix = options.dynamicReferencePrefixMap.prop
59
199
  ? options.dynamicReferencePrefixMap.prop + '.'
60
200
  : '';
61
- return t.expressionStatement(t.callExpression(t.identifier(prefix + propFunctionKey), __spreadArray([], args.map(function (arg) { return convertValueToLiteral(arg); }), true)));
201
+ // Un-prefixed the prop name is called as a bare binding, so it must be
202
+ // identifier-safe; prefixed it is `props.<name>`, where the UIDL spelling is
203
+ // both legal and load-bearing.
204
+ var calleeName = prefix
205
+ ? prefix + propFunctionKey
206
+ : JSIdentifiers.createSafeJSIdentifier(propFunctionKey);
207
+ return t.expressionStatement(t.callExpression(t.identifier(calleeName), __spreadArray([], args.map(function (arg) { return convertValueToLiteral(arg); }), true)));
62
208
  };
63
- var createStateChangeStatement = function (eventHandlerStatement, stateDefinitions, options, t) {
209
+ /**
210
+ * Plan v14 — Type-aware state setter emitter.
211
+ *
212
+ * The old emitter unconditionally produced `setX(!x)` for `$toggle` and
213
+ * `setX(<literal>)` for primitives, regardless of the declared state
214
+ * type. That broke every multi-step form: `$toggle` on a numeric step
215
+ * state turned `1` into `false`, hiding every `state === N` panel; a
216
+ * primitive written to an object state replaced the whole object.
217
+ *
218
+ * The codegen here is now the safety net for what server-side Layers 1-3
219
+ * could not catch (legacy projects, AI bypass). When a combination is
220
+ * incoherent (e.g. `$toggle` on a number, or a bare string targeting an
221
+ * object), we skip the statement and warn — the workflow runtime handler
222
+ * remains the source of truth. Coherent combinations emit the same code
223
+ * as before, plus four new modifier shapes (`$increment` / `$decrement` /
224
+ * `$patch` / `$append`) that produce React functional setters.
225
+ *
226
+ * Returns `null` when the emitter declines (caller already handles null).
227
+ */
228
+ export var createStateChangeStatement = function (eventHandlerStatement, stateDefinitions, options, t) {
229
+ var _a;
64
230
  if (t === void 0) { t = types; }
65
231
  if (!eventHandlerStatement.modifies) {
66
232
  console.warn("No state identifier referenced under the \"modifies\" field");
@@ -68,67 +234,524 @@ var createStateChangeStatement = function (eventHandlerStatement, stateDefinitio
68
234
  }
69
235
  var stateKey = eventHandlerStatement.modifies;
70
236
  var stateDefinition = stateDefinitions[stateKey];
237
+ if (!stateDefinition) {
238
+ console.warn("State change references an undeclared state \"".concat(stateKey, "\" \u2014 skipping setter emission."));
239
+ return null;
240
+ }
71
241
  var statePrefix = options.dynamicReferencePrefixMap.state
72
242
  ? options.dynamicReferencePrefixMap.state + '.'
73
243
  : '';
74
- var newStateValue = eventHandlerStatement.newState === '$toggle'
75
- ? t.unaryExpression('!', t.identifier(statePrefix + stateKey))
76
- : convertValueToLiteral(eventHandlerStatement.newState, stateDefinition.type);
244
+ // Reading/writing the state through a prefix (`this.class`) is a member
245
+ // access and keeps the UIDL spelling; without one the name IS the binding
246
+ // and has to match what `createStateHookAST` declared.
247
+ var stateReadName = statePrefix
248
+ ? statePrefix + stateKey
249
+ : JSIdentifiers.createSafeJSIdentifier(stateKey);
250
+ var declaredType = stateDefinition.type;
251
+ var newState = eventHandlerStatement.newState;
252
+ var newStateValue;
253
+ var useFunctionalSetter = false;
254
+ var functionalSetterBuilder;
255
+ if (newState === '$toggle') {
256
+ // Boolean-only. Reject for number / object / array — emitting `!x`
257
+ // on those types is the v13/v14 regression we are fixing.
258
+ if (declaredType !== 'boolean') {
259
+ console.warn("[createStateChangeStatement] '$toggle' is only valid for boolean state; state \"".concat(stateKey, "\" is declared as ").concat(declaredType, ". Skipping setter to avoid corrupting state."));
260
+ return null;
261
+ }
262
+ newStateValue = t.unaryExpression('!', t.identifier(stateReadName));
263
+ }
264
+ else if (typeof newState === 'object' && newState !== null) {
265
+ var obj = newState;
266
+ var objType = obj.type;
267
+ if (objType === 'expr') {
268
+ newStateValue = getExpressionFromUIDLExpressionNode(newState);
269
+ }
270
+ else if (objType === 'dynamic') {
271
+ newStateValue = createDynamicValueExpression(newState, options);
272
+ }
273
+ else if (objType === '$increment' || objType === '$decrement') {
274
+ if (declaredType !== 'number') {
275
+ console.warn("[createStateChangeStatement] '".concat(objType, "' requires a numeric state; \"").concat(stateKey, "\" is declared as ").concat(declaredType, ". Skipping setter."));
276
+ return null;
277
+ }
278
+ // Honor the sign of `delta`: an $increment with delta -2 is a
279
+ // deliberate decrement by 2 (the type doc documents this). The
280
+ // builder emits `prev + delta` for $increment and `prev - delta`
281
+ // for $decrement, then the absolute value of |delta| is the
282
+ // numeric literal we feed in. Math.abs prevents the rare double-
283
+ // negative case where someone writes `{ type: '$decrement', delta: -1 }`
284
+ // (intended +1) from emitting `prev - -1` (which would be `+1`
285
+ // via JS coercion but is unreadable).
286
+ var rawDelta = (_a = obj.delta) !== null && _a !== void 0 ? _a : 1;
287
+ var operator_1 = objType === '$increment' ? (rawDelta < 0 ? '-' : '+') : rawDelta < 0 ? '+' : '-';
288
+ var magnitude_1 = Math.abs(rawDelta);
289
+ useFunctionalSetter = true;
290
+ functionalSetterBuilder = function (prevId) {
291
+ return t.binaryExpression(operator_1, prevId, t.numericLiteral(magnitude_1));
292
+ };
293
+ }
294
+ else if (objType === '$patch') {
295
+ if (declaredType !== 'object') {
296
+ console.warn("[createStateChangeStatement] '$patch' requires an object state; \"".concat(stateKey, "\" is declared as ").concat(declaredType, ". Skipping setter."));
297
+ return null;
298
+ }
299
+ var patch_1 = obj;
300
+ if (!patch_1.path || typeof patch_1.path !== 'string') {
301
+ console.warn("[createStateChangeStatement] '$patch' requires a string \"path\"; received \"".concat(String(patch_1.path), "\" for state \"").concat(stateKey, "\". Skipping setter."));
302
+ return null;
303
+ }
304
+ var patchValueAst_1 = convertValueToLiteral(patch_1.value, 'string');
305
+ useFunctionalSetter = true;
306
+ functionalSetterBuilder = function (prevId) {
307
+ return t.objectExpression([
308
+ t.spreadElement(prevId),
309
+ t.objectProperty(t.identifier(patch_1.path), patchValueAst_1, false, false),
310
+ ]);
311
+ };
312
+ }
313
+ else if (objType === '$append') {
314
+ if (declaredType !== 'array') {
315
+ console.warn("[createStateChangeStatement] '$append' requires an array state; \"".concat(stateKey, "\" is declared as ").concat(declaredType, ". Skipping setter."));
316
+ return null;
317
+ }
318
+ var appended = obj;
319
+ var appendedValueAst_1 = convertValueToLiteral(appended.value, 'string');
320
+ useFunctionalSetter = true;
321
+ functionalSetterBuilder = function (prevId) {
322
+ return t.arrayExpression([t.spreadElement(prevId), appendedValueAst_1]);
323
+ };
324
+ }
325
+ else {
326
+ // Unknown object shape — fall back to literal conversion only when
327
+ // the declared type accepts a primitive write.
328
+ if (declaredType === 'object' || declaredType === 'array') {
329
+ console.warn("[createStateChangeStatement] Unrecognised modifier shape on a ".concat(declaredType, " state \"").concat(stateKey, "\"; skipping setter to avoid corrupting state."));
330
+ return null;
331
+ }
332
+ newStateValue = convertValueToLiteral(newState, declaredType);
333
+ }
334
+ }
335
+ else {
336
+ // Bare primitive (`'oily'`, `2`, `true`). Coerce against the declared type.
337
+ // For object/array state, writing a primitive REPLACES the structure.
338
+ // That is the bug — fail safe.
339
+ if (declaredType === 'object' || declaredType === 'array') {
340
+ console.warn("[createStateChangeStatement] Refusing to overwrite ".concat(declaredType, " state \"").concat(stateKey, "\" with a primitive value (").concat(JSON.stringify(newState), "). Use '$patch' / '$append' modifiers instead. Skipping setter."));
341
+ return null;
342
+ }
343
+ newStateValue = convertValueToLiteral(newState, declaredType);
344
+ }
77
345
  switch (options.stateHandling) {
78
- case 'hooks':
79
- return t.expressionStatement(t.callExpression(t.identifier(StringUtils.createStateStoringFunction(stateKey)), [
80
- newStateValue,
81
- ]));
82
- case 'function':
346
+ case 'hooks': {
347
+ var setterId = t.identifier(StringUtils.createStateStoringFunction(stateKey));
348
+ if (useFunctionalSetter && functionalSetterBuilder) {
349
+ var prevId = t.identifier('prev');
350
+ var arrow = t.arrowFunctionExpression([prevId], functionalSetterBuilder(prevId));
351
+ return t.expressionStatement(t.callExpression(setterId, [arrow]));
352
+ }
353
+ if (!newStateValue) {
354
+ return null;
355
+ }
356
+ return t.expressionStatement(t.callExpression(setterId, [newStateValue]));
357
+ }
358
+ case 'function': {
359
+ // Class-component setState path is legacy; functional setters aren't
360
+ // supported via `this.setState(prev => …)` here, so for the new
361
+ // modifiers we fall back to skipping. The hooks path is the path the
362
+ // multi-step form actually exercises.
363
+ if (useFunctionalSetter) {
364
+ console.warn("[createStateChangeStatement] Functional-setter modifiers are only supported under stateHandling=\"hooks\". Skipping setter for \"".concat(stateKey, "\"."));
365
+ return null;
366
+ }
367
+ if (!newStateValue) {
368
+ return null;
369
+ }
83
370
  return t.expressionStatement(t.callExpression(t.identifier('this.setState'), [
84
371
  t.objectExpression([t.objectProperty(t.identifier(stateKey), newStateValue)]),
85
372
  ]));
373
+ }
86
374
  case 'mutation':
87
- default:
88
- return t.expressionStatement(t.assignmentExpression('=', t.identifier(statePrefix + stateKey), newStateValue));
375
+ default: {
376
+ if (useFunctionalSetter) {
377
+ console.warn("[createStateChangeStatement] Functional-setter modifiers are only supported under stateHandling=\"hooks\". Skipping setter for \"".concat(stateKey, "\"."));
378
+ return null;
379
+ }
380
+ if (!newStateValue) {
381
+ return null;
382
+ }
383
+ return t.expressionStatement(t.assignmentExpression('=', t.identifier(stateReadName), newStateValue));
384
+ }
89
385
  }
90
386
  };
387
+ export var resolveGlobalStateName = function (id, definitions) {
388
+ if (!definitions) {
389
+ return id;
390
+ }
391
+ for (var _i = 0, _a = Object.values(definitions); _i < _a.length; _i++) {
392
+ var def = _a[_i];
393
+ if (def.id === id) {
394
+ return def.name;
395
+ }
396
+ }
397
+ return id;
398
+ };
399
+ // Matches the leading JS identifier of an expression, e.g. `foo` from
400
+ // `foo?.['bar'] || []`. Used to recognise when a string-encoded UIDL source
401
+ // (cms-list-repeater `source`) is rooted at a global-state name so the
402
+ // generator can register the reference for `useGlobalState()` destructuring.
403
+ var LEADING_IDENTIFIER_RE = /^([A-Za-z_$][A-Za-z0-9_$]*)/;
404
+ // Older versions of the UIDL emitter encoded a global-state reference as the
405
+ // magic literal `globalState_<defId>` instead of the declared variable name.
406
+ // Detect that prefix so we can rewrite it to the proper identifier and fix
407
+ // already-published UIDL documents without forcing them to be regenerated.
408
+ var LEGACY_GLOBAL_STATE_RE = /^globalState_([A-Za-z0-9_-]+)/;
409
+ /**
410
+ * Given a string-encoded UIDL `source` expression, resolve any global-state
411
+ * reference into the proper JS identifier for the generator and ensure the
412
+ * reference is registered for `useGlobalState()` destructuring.
413
+ *
414
+ * Two upstream encodings are accepted:
415
+ * 1. Modern shape — leading identifier is the declared state name
416
+ * (e.g. `countriesWithDescriptions || []`). We just register it.
417
+ * 2. Legacy shape — leading identifier is the magic placeholder
418
+ * `globalState_<defId>` (e.g. `globalState_TQ_96vaRH5pdf['key']`). We
419
+ * rewrite the placeholder to the declared name AND register it.
420
+ *
421
+ * Returns the (possibly rewritten) source string. The caller should embed
422
+ * the returned string instead of the input.
423
+ */
424
+ export var resolveAndRegisterGlobalStateSource = function (source, params) {
425
+ var original = source !== null && source !== void 0 ? source : '';
426
+ if (!original) {
427
+ return original;
428
+ }
429
+ var definitions = params.globalStateDefinitions;
430
+ if (!definitions || Object.keys(definitions).length === 0) {
431
+ return original;
432
+ }
433
+ var legacyMatch = original.match(LEGACY_GLOBAL_STATE_RE);
434
+ if (legacyMatch) {
435
+ var id = legacyMatch[1];
436
+ for (var _i = 0, _a = Object.values(definitions); _i < _a.length; _i++) {
437
+ var def = _a[_i];
438
+ if (def.id === id) {
439
+ params.globalStateReferences.push({ id: def.id, name: def.name });
440
+ // The rewritten source is embedded as code, so the placeholder becomes
441
+ // the LOCAL binding — the sanitised name the destructuring declares.
442
+ return original.replace(LEGACY_GLOBAL_STATE_RE, JSIdentifiers.createSafeJSIdentifier(def.name));
443
+ }
444
+ }
445
+ // Legacy prefix found but no matching definition (orphaned reference).
446
+ // Leave the source untouched; the downstream identifier creation will
447
+ // still emit something, and a separate sanity pass can flag it.
448
+ return original;
449
+ }
450
+ var leadingMatch = original.match(LEADING_IDENTIFIER_RE);
451
+ if (leadingMatch) {
452
+ var leadingName = leadingMatch[1];
453
+ for (var _b = 0, _c = Object.values(definitions); _b < _c.length; _b++) {
454
+ var def = _c[_b];
455
+ if (def.name === leadingName) {
456
+ params.globalStateReferences.push({ id: def.id, name: def.name });
457
+ return original;
458
+ }
459
+ }
460
+ }
461
+ return original;
462
+ };
463
+ export var createGlobalStateExpression = function (ref, definitions, t) {
464
+ if (t === void 0) { t = types; }
465
+ // The global-state name is destructured out of `useGlobalState()` as a local
466
+ // binding, so it goes through the same sanitiser the destructuring site uses.
467
+ var name = JSIdentifiers.createSafeJSIdentifier(resolveGlobalStateName(ref.content.id, definitions));
468
+ var refPath = ref.content.refPath || [];
469
+ if (refPath.length === 0) {
470
+ return t.identifier(name);
471
+ }
472
+ var expr = t.identifier(name);
473
+ for (var _i = 0, refPath_1 = refPath; _i < refPath_1.length; _i++) {
474
+ var segment = refPath_1[_i];
475
+ expr = t.optionalMemberExpression(expr, t.identifier(segment), false, true);
476
+ }
477
+ return expr;
478
+ };
91
479
  export var createDynamicValueExpression = function (identifier, options, t) {
480
+ var _a;
481
+ if (t === void 0) { t = types; }
482
+ var inner = createDynamicValueExpressionRaw(identifier, options, t);
483
+ // When the UIDL content carries a `valueMapper`, wrap the resolved
484
+ // expression in a sandboxed IIFE that runs the user's `mapValue(value)`
485
+ // and falls back to the raw value on error. This mirrors the state
486
+ // definition `wrapWithMappingFunction` pattern and lets any framework
487
+ // that re-uses `createDynamicValueExpression` inherit the behaviour.
488
+ var valueMapper = ((_a = identifier.content.valueMapper) === null || _a === void 0 ? void 0 : _a.trim()) || '';
489
+ if (!valueMapper) {
490
+ return inner;
491
+ }
492
+ return wrapExpressionWithValueMapperAst(inner, valueMapper, t);
493
+ };
494
+ var wrapExpressionWithValueMapperAst = function (innerExpression, valueMapper, t) {
495
+ if (t === void 0) { t = types; }
496
+ // Build: ((v) => { try { return (new Function('value', '"use strict"; <mapper>; return mapValue(value);')).call(null, v) } catch (_e) { return v } })(<inner>)
497
+ //
498
+ // We deliberately use `new Function(...)` at runtime rather than parsing
499
+ // the mapper body into AST statements here. That keeps this plugin free
500
+ // of a parser dependency, matches the sandboxing used by state-definition
501
+ // `wrapWithMappingFunction`, and ensures the generated code is framework
502
+ // agnostic — only stringify semantics + `toString()` on primitives are
503
+ // required for the output to render correctly.
504
+ var tryBlock = t.tryStatement(t.blockStatement([
505
+ t.returnStatement(t.callExpression(t.memberExpression(t.newExpression(t.identifier('Function'), [
506
+ t.stringLiteral('value'),
507
+ t.stringLiteral("\"use strict\"; ".concat(valueMapper, "; return mapValue(value);")),
508
+ ]), t.identifier('call')), [t.nullLiteral(), t.identifier('v')])),
509
+ ]), t.catchClause(t.identifier('_e'), t.blockStatement([t.returnStatement(t.identifier('v'))])));
510
+ var arrow = t.arrowFunctionExpression([t.identifier('v')], t.blockStatement([tryBlock]));
511
+ return t.callExpression(arrow, [innerExpression]);
512
+ };
513
+ var createDynamicValueExpressionRaw = function (identifier, options, t) {
514
+ var _a;
92
515
  if (t === void 0) { t = types; }
93
516
  var identifierContent = identifier.content;
517
+ var refPath = identifier.content.refPath || [];
94
518
  var referenceType = identifierContent.referenceType, id = identifierContent.id;
95
519
  if (referenceType === 'attr' || referenceType === 'children' || referenceType === 'token') {
96
520
  throw new Error("Dynamic reference type \"".concat(referenceType, "\" is not supported yet"));
97
521
  }
522
+ // 'ctx' references resolve to the data source context render prop identifier
523
+ // using only the refPath to build property access
524
+ if (referenceType === 'ctx') {
525
+ var ctxPrefix = options.dynamicReferencePrefixMap.ctx || '';
526
+ if (ctxPrefix && refPath.length > 0) {
527
+ var expr = t.identifier(ctxPrefix);
528
+ for (var _i = 0, refPath_2 = refPath; _i < refPath_2.length; _i++) {
529
+ var path = refPath_2[_i];
530
+ expr = t.optionalMemberExpression(expr, t.identifier(path), false, true);
531
+ }
532
+ return expr;
533
+ }
534
+ // Details-page fallback: an unresolvable `ctx` reference on a details page
535
+ // (its ctxId points at no known render-prop context — e.g. a synthetic
536
+ // `details-page-generic-*` id produced for a widget's `target`) is still a
537
+ // column on the fetched row exposed as a prop. Resolve it exactly like the
538
+ // `local` branch below → `props.<exposeAs>.<refPath>` (e.g.
539
+ // `props.webinar?.scheduled_at`), so the widget binds the real value.
540
+ if (options.detailsPageExposeAsName && refPath.length > 0) {
541
+ var propPrefix = options.dynamicReferencePrefixMap.prop || 'props';
542
+ var expr = t.memberExpression(t.identifier(propPrefix), t.identifier(options.detailsPageExposeAsName));
543
+ for (var _b = 0, refPath_3 = refPath; _b < refPath_3.length; _b++) {
544
+ var path = refPath_3[_b];
545
+ expr = t.optionalMemberExpression(expr, t.identifier(path), false, true);
546
+ }
547
+ return expr;
548
+ }
549
+ // Last resort: NEVER emit a bare identifier for an unresolved ctx reference —
550
+ // `generateIdWithRefPath(id, …)` yields an UNDECLARED variable (e.g.
551
+ // `tQQGFGA6h4I`), which throws `ReferenceError` during SSR and crashes the
552
+ // Vercel `next build` export (run 1b6eb5ba: `/webinar-detail/[id]`). Emit the
553
+ // reference's declared `fallbackValue` literal, or `undefined`.
554
+ var ctxFallbackValue = identifierContent.fallbackValue;
555
+ if (typeof ctxFallbackValue === 'string' ||
556
+ typeof ctxFallbackValue === 'number' ||
557
+ typeof ctxFallbackValue === 'boolean') {
558
+ return convertValueToLiteral(ctxFallbackValue);
559
+ }
560
+ return t.identifier('undefined');
561
+ }
562
+ // `urlSearchParams` references read a declared key from the URL query string.
563
+ // Next.js generators typically set `dynamicReferencePrefixMap.urlSearchParams`
564
+ // to `'router.query'` so we emit `router.query.<key>`. Static / HTML
565
+ // generators set it to `'__urlSearchParams'` and inject a `const
566
+ // __urlSearchParams = new URLSearchParams(location.search)` prelude.
567
+ //
568
+ // `options.urlSearchParamsRegistry` (set by the plugin based on the page
569
+ // UIDL's `searchParams` definition) supplies per-key defaults so we emit
570
+ // `(router.query.category ?? 'food')` with the declared fallback.
571
+ if (referenceType === 'urlSearchParams') {
572
+ var paramKey = refPath[0] || id;
573
+ var urlParamsPrefix = options.dynamicReferencePrefixMap.urlSearchParams ||
574
+ 'router.query';
575
+ var _c = urlParamsPrefix.split('.'), rootPrefix = _c[0], restPath = _c.slice(1);
576
+ var expr = t.identifier(rootPrefix);
577
+ for (var _d = 0, restPath_1 = restPath; _d < restPath_1.length; _d++) {
578
+ var segment = restPath_1[_d];
579
+ expr = t.memberExpression(expr, t.identifier(segment));
580
+ }
581
+ expr = t.optionalMemberExpression(expr, t.identifier(paramKey), false, true);
582
+ var registry = options.urlSearchParamsRegistry;
583
+ var declaredDefault = (_a = registry === null || registry === void 0 ? void 0 : registry[paramKey]) === null || _a === void 0 ? void 0 : _a.defaultValue;
584
+ if (declaredDefault !== undefined && declaredDefault !== '') {
585
+ expr = t.logicalExpression('??', expr, t.stringLiteral(declaredDefault));
586
+ }
587
+ return expr;
588
+ }
589
+ // 'local' references resolve to the iteration variable of the enclosing repeater.
590
+ // The reference id in UIDL is a node id (e.g. "TQ_xxxxxx") and carries no meaning
591
+ // at runtime — the only load-bearing pieces are the refPath and the current
592
+ // localIdentifier (set when walking into a repeater/data-provider's children).
593
+ if (referenceType === 'local') {
594
+ var localPrefix = options.localIdentifier ||
595
+ options.dynamicReferencePrefixMap.local ||
596
+ '';
597
+ if (localPrefix) {
598
+ if (refPath.length === 0) {
599
+ return t.identifier(localPrefix);
600
+ }
601
+ var expr = t.identifier(localPrefix);
602
+ for (var _e = 0, refPath_4 = refPath; _e < refPath_4.length; _e++) {
603
+ var path = refPath_4[_e];
604
+ expr = t.optionalMemberExpression(expr, t.identifier(path), false, true);
605
+ }
606
+ return expr;
607
+ }
608
+ // Details-page fallback: a page-root `local` reference (no enclosing
609
+ // repeater) means "a column on the fetched row" exposed as a prop under
610
+ // `initialPropsData.exposeAs.name`. Resolve to `props.<name>.<refPath>`.
611
+ if (options.detailsPageExposeAsName && refPath.length > 0) {
612
+ var propPrefix = options.dynamicReferencePrefixMap.prop || 'props';
613
+ var expr = t.memberExpression(t.identifier(propPrefix), t.identifier(options.detailsPageExposeAsName));
614
+ for (var _f = 0, refPath_5 = refPath; _f < refPath_5.length; _f++) {
615
+ var path = refPath_5[_f];
616
+ expr = t.optionalMemberExpression(expr, t.identifier(path), false, true);
617
+ }
618
+ return expr;
619
+ }
620
+ }
621
+ var idWithPath = generateIdWithRefPath(id, refPath);
98
622
  var prefix = options.dynamicReferencePrefixMap[referenceType] || '';
623
+ // With no prefix the id IS the binding (React hooks: `class`), so it has to
624
+ // be sanitised exactly the way the declaration was. With a prefix it is a
625
+ // MEMBER (`props.class`, `this.class`), where a reserved word is perfectly
626
+ // legal and renaming it would point at a property that does not exist.
99
627
  return prefix === ''
100
- ? t.identifier(id)
101
- : t.memberExpression(t.identifier(prefix), t.identifier(id));
628
+ ? t.identifier(JSIdentifiers.createSafeJSIdentifierPath(idWithPath))
629
+ : t.memberExpression(t.identifier(prefix), t.identifier(idWithPath));
102
630
  };
103
631
  // Prepares an identifier (from props or state or an expr) to be used as a conditional rendering identifier
104
632
  // Assumes the type from the corresponding props/state definitions if not expr. Expressions are expected to have a boolean return here
105
633
  export var createConditionIdentifier = function (dynamicReference, params, options) {
106
- var _a = dynamicReference.content, id = _a.id, referenceType = _a.referenceType;
634
+ var _a, _b, _c, _d;
635
+ if (dynamicReference.type === 'expr') {
636
+ return {
637
+ key: dynamicReference.content,
638
+ type: 'boolean',
639
+ isExpression: true,
640
+ };
641
+ }
642
+ var _e = dynamicReference.content, id = _e.id, referenceType = _e.referenceType, refPath = _e.refPath;
643
+ // Handle local references (from repeaters/loops) - they don't have an id
644
+ if (referenceType === 'local') {
645
+ // For local references, the identifier comes from the refPath
646
+ var refPathKey = refPath && refPath.length > 0 ? refPath.join('.') : '';
647
+ var prefix = options.localIdentifier || '';
648
+ // Details-page fallback: at the page root there is no enclosing repeater,
649
+ // so a `local` reference means "a column on the fetched row" exposed as a
650
+ // prop under `initialPropsData.exposeAs.name`.
651
+ if (!prefix && options.detailsPageExposeAsName && refPathKey) {
652
+ var propPrefix = ((_a = options.dynamicReferencePrefixMap) === null || _a === void 0 ? void 0 : _a.prop) || 'props';
653
+ return {
654
+ key: "".concat(options.detailsPageExposeAsName, ".").concat(refPathKey),
655
+ type: 'string',
656
+ prefix: propPrefix,
657
+ };
658
+ }
659
+ return {
660
+ key: refPathKey,
661
+ type: 'string',
662
+ prefix: prefix,
663
+ };
664
+ }
665
+ if (referenceType === 'global') {
666
+ return {
667
+ key: UIDLUtils.generateIdWithRefPath(id, refPath),
668
+ type: 'string',
669
+ prefix: '',
670
+ referenceType: 'global',
671
+ };
672
+ }
673
+ if (referenceType === 'globalState') {
674
+ var resolvedName = resolveGlobalStateName(id, params.globalStateDefinitions);
675
+ var refPathSegments = refPath || [];
676
+ var key = refPathSegments.length > 0
677
+ ? refPathSegments.reduce(function (acc, seg) { return "".concat(acc, "?.").concat(seg); }, resolvedName)
678
+ : resolvedName;
679
+ return {
680
+ key: key,
681
+ type: 'string',
682
+ prefix: '',
683
+ referenceType: 'globalState',
684
+ };
685
+ }
686
+ // A value of the page address's query string, read the way the value path
687
+ // above reads it (`router.query.<key>` in Next, the prelude's object in a
688
+ // static generator) — e.g. a categories overview that steps aside while a
689
+ // search narrows the list.
690
+ if (referenceType === 'urlSearchParams') {
691
+ return {
692
+ key: (refPath === null || refPath === void 0 ? void 0 : refPath[0]) || id,
693
+ type: 'string',
694
+ prefix: options.dynamicReferencePrefixMap.urlSearchParams ||
695
+ 'router.query',
696
+ };
697
+ }
107
698
  // in case the id is a member expression: eg: fields.name
108
699
  var referenceRoot = id.split('.')[0];
700
+ var currentType = referenceType === 'prop'
701
+ ? (_b = params.propDefinitions[referenceRoot]) === null || _b === void 0 ? void 0 : _b.type
702
+ : (_c = params.stateDefinitions[referenceRoot]) === null || _c === void 0 ? void 0 : _c.type;
703
+ var type = currentType;
704
+ if (refPath === null || refPath === void 0 ? void 0 : refPath.length) {
705
+ if (referenceType === 'prop' && ((_d = params.propDefinitions[referenceRoot]) === null || _d === void 0 ? void 0 : _d.defaultValue)) {
706
+ var currentValue = params.propDefinitions[referenceRoot].defaultValue;
707
+ for (var _i = 0, refPath_6 = refPath; _i < refPath_6.length; _i++) {
708
+ var path = refPath_6[_i];
709
+ currentValue = currentValue === null || currentValue === void 0 ? void 0 : currentValue[path];
710
+ type = currentValue ? typeof currentValue : currentType;
711
+ }
712
+ }
713
+ else if (referenceType === 'state' && currentType === 'object') {
714
+ var stateDef = params.stateDefinitions[referenceRoot];
715
+ if (stateDef &&
716
+ typeof stateDef.defaultValue === 'object' &&
717
+ stateDef.defaultValue !== null &&
718
+ !Array.isArray(stateDef.defaultValue)) {
719
+ var objectDefault = stateDef.defaultValue;
720
+ var entry = objectDefault[refPath[0]];
721
+ if ((entry === null || entry === void 0 ? void 0 : entry.type) === 'static' && entry.content !== undefined) {
722
+ type = typeof entry.content;
723
+ }
724
+ else {
725
+ type = 'string';
726
+ }
727
+ }
728
+ }
729
+ }
109
730
  switch (referenceType) {
110
731
  case 'prop':
111
732
  return {
112
- key: id,
113
- type: params.propDefinitions[referenceRoot].type,
733
+ key: UIDLUtils.generateIdWithRefPath(id, refPath),
734
+ type: type,
114
735
  prefix: options.dynamicReferencePrefixMap.prop,
115
736
  };
116
737
  case 'state':
117
738
  return {
118
- key: id,
119
- type: params.stateDefinitions[referenceRoot].type,
739
+ key: UIDLUtils.generateIdWithRefPath(id, refPath),
740
+ type: type,
120
741
  prefix: options.dynamicReferencePrefixMap.state,
121
742
  };
122
743
  case 'expr':
123
744
  return {
124
745
  key: id,
125
746
  type: 'boolean',
747
+ isExpression: true,
126
748
  };
127
749
  default:
128
750
  throw new Error("createConditionIdentifier encountered an invalid reference type: ".concat(JSON.stringify(dynamicReference, null, 2)));
129
751
  }
130
752
  };
131
- export var createConditionalJSXExpression = function (content, conditionalExpression, conditionalIdentifier, t) {
753
+ export var createConditionalJSXExpression = function (content, conditionalExpression, conditionalIdentifier, options, t) {
754
+ if (options === void 0) { options = {}; }
132
755
  if (t === void 0) { t = types; }
133
756
  var contentNode;
134
757
  if (typeof content === 'string') {
@@ -140,34 +763,217 @@ export var createConditionalJSXExpression = function (content, conditionalExpres
140
763
  else {
141
764
  contentNode = content;
142
765
  }
143
- var binaryExpression;
144
- // When the stateValue is an object we will compute a logical/binary expression on the left side
145
- var conditions = conditionalExpression.conditions, matchingCriteria = conditionalExpression.matchingCriteria;
146
- var binaryExpressions = conditions.map(function (condition) {
147
- return createBinaryExpression(condition, conditionalIdentifier);
766
+ var binaryExpression = createConditionChainExpression(conditionalExpression, conditionalIdentifier, options, t);
767
+ return t.logicalExpression('&&', binaryExpression, contentNode);
768
+ };
769
+ // Folds a (possibly nested) conditions chain into one expression. Group
770
+ // entries recurse with their own matchingCriteria — the AST nesting is what
771
+ // the printer emits as parentheses.
772
+ var createConditionChainExpression = function (chain, conditionalIdentifier, options, t) {
773
+ if (t === void 0) { t = types; }
774
+ var conditions = chain.conditions, matchingCriteria = chain.matchingCriteria;
775
+ var entryExpressions = conditions.map(function (entry) {
776
+ var _a, _b;
777
+ return UIDLUtils.isUIDLConditionGroup(entry)
778
+ ? createConditionChainExpression(entry, conditionalIdentifier, options, t)
779
+ : createBinaryExpression(entry, (_b = (_a = options.resolveEntryIdentifier) === null || _a === void 0 ? void 0 : _a.call(options, entry)) !== null && _b !== void 0 ? _b : conditionalIdentifier, options);
148
780
  });
149
- if (binaryExpressions.length === 1) {
150
- binaryExpression = binaryExpressions[0];
781
+ if (entryExpressions.length === 0) {
782
+ // An empty group cannot gate anything; degrade to a pass-through.
783
+ return t.booleanLiteral(true);
151
784
  }
152
- else {
153
- // the first two binary expressions are put together as a logical expression
154
- var firstExp = binaryExpressions[0], secondExp = binaryExpressions[1];
155
- var operation = matchingCriteria === 'all' ? '&&' : '||';
156
- var expression = t.logicalExpression(operation, firstExp, secondExp);
157
- // accumulate the rest of the expressions to the logical expression
158
- for (var index = 2; index < binaryExpressions.length; index++) {
159
- expression = t.logicalExpression(operation, expression, binaryExpressions[index]);
785
+ if (entryExpressions.length === 1) {
786
+ return entryExpressions[0];
787
+ }
788
+ // the first two expressions are put together as a logical expression
789
+ var operation = matchingCriteria === 'all' ? '&&' : '||';
790
+ var expression = t.logicalExpression(operation, entryExpressions[0], entryExpressions[1]);
791
+ // accumulate the rest of the expressions to the logical expression
792
+ for (var index = 2; index < entryExpressions.length; index++) {
793
+ expression = t.logicalExpression(operation, expression, entryExpressions[index]);
794
+ }
795
+ return expression;
796
+ };
797
+ /**
798
+ * The test a conditionally-bound class applies under: every rule of its chain,
799
+ * joined by the chain's matchingCriteria, or the single `value` it equals. A
800
+ * condition with neither can never hold, so there is no test and the caller
801
+ * leaves the class off.
802
+ */
803
+ export var createClassConditionExpression = function (condition, conditionalIdentifier) {
804
+ var _a, _b;
805
+ if ((_b = (_a = condition.expression) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.length) {
806
+ return createConditionChainExpression(condition.expression, conditionalIdentifier, {});
807
+ }
808
+ if (condition.value !== undefined) {
809
+ return createBinaryExpression({ operation: '===', operand: condition.value }, conditionalIdentifier);
810
+ }
811
+ return null;
812
+ };
813
+ /**
814
+ * Resolves an operand value to an AST expression, handling dynamic refs, expressions, and static values.
815
+ */
816
+ var resolveOperandExpression = function (operand, conditionalIdentifier, options) {
817
+ if (typeof operand === 'object' && 'type' in operand && operand.type === 'expr') {
818
+ return getExpressionFromUIDLExpressionNode(operand);
819
+ }
820
+ if (typeof operand === 'object' && 'type' in operand && operand.type === 'dynamic') {
821
+ return createDynamicValueExpression(operand, {
822
+ dynamicReferencePrefixMap: {
823
+ prop: 'props',
824
+ state: '',
825
+ local: '',
826
+ },
827
+ localIdentifier: options.localIdentifier,
828
+ detailsPageExposeAsName: options.detailsPageExposeAsName,
829
+ });
830
+ }
831
+ return convertValueToLiteral(operand, conditionalIdentifier.type);
832
+ };
833
+ /**
834
+ * `resolveOperandExpression` for an operand that is ONE ELEMENT of the bound
835
+ * collection (`contains` / `notContains`), not a value of the collection's own
836
+ * type.
837
+ *
838
+ * The typed resolver parses a static operand as the identifier's type, which
839
+ * for an array-typed state means `JSON.parse`: the string `"5"` came out as the
840
+ * number `5`, `"true"` as `true`. The rows an array state actually holds are
841
+ * whatever a workflow pushed — strings, read off `data-*` attributes — so
842
+ * `selectedRatings.includes(5)` never matched `["5"]` and a ticked rating
843
+ * checkbox stayed empty. The literal keeps the type it was authored with, which
844
+ * is also how the editor's canvas evaluates the same condition.
845
+ */
846
+ var resolveElementOperandExpression = function (operand, conditionalIdentifier, options) {
847
+ return resolveOperandExpression(operand, __assign(__assign({}, conditionalIdentifier), { type: '' }), options);
848
+ };
849
+ /**
850
+ * Coerce a conditional identifier to an empty collection when it is null or
851
+ * undefined, so the collection operators below can dereference it safely.
852
+ *
853
+ * The bound value is absent far more often than it looks: an optional CMS
854
+ * column, a category without an image, a state that has not hydrated yet. A
855
+ * bare `x.length` / `x.includes(...)` then throws `Cannot read properties of
856
+ * null` during render and takes the whole page down with an unhandled runtime
857
+ * error — a condition whose entire job is to HIDE a node must never be able to
858
+ * do that. `x || []` keeps string semantics intact (a non-empty string is
859
+ * truthy and carries both `.length` and `.includes`) while turning nullish
860
+ * values into a harmless empty collection; objects get `{}` for `Object.keys`
861
+ * / `hasOwnProperty`, which reject `null` outright.
862
+ */
863
+ var createNullSafeCollection = function (identifier, conditionalIdentifier, t) {
864
+ if (t === void 0) { t = types; }
865
+ return t.logicalExpression('||', identifier, conditionalIdentifier.type === 'object' ? t.objectExpression([]) : t.arrayExpression([]));
866
+ };
867
+ /** `x.length` — via `Object.keys(x).length` for objects — on a nullish-safe target. */
868
+ var createLengthExpression = function (identifier, conditionalIdentifier, t) {
869
+ if (t === void 0) { t = types; }
870
+ var target = createNullSafeCollection(identifier, conditionalIdentifier, t);
871
+ return conditionalIdentifier.type === 'object'
872
+ ? t.memberExpression(t.callExpression(t.memberExpression(t.identifier('Object'), t.identifier('keys')), [
873
+ target,
874
+ ]), t.identifier('length'))
875
+ : t.memberExpression(target, t.identifier('length'));
876
+ };
877
+ /**
878
+ * A UIDL `expr` reference whose whole body is a JavaScript LITERAL.
879
+ *
880
+ * `expr` content is source, not a name, so it must never reach the reserved
881
+ * word sanitiser: the domain-to-UIDL mapper emits the literal `false` as its
882
+ * "this condition could not be resolved" fallback (an orphaned state/prop
883
+ * reference), and `t.identifier(createSafeJSIdentifierPath('false'))` prints
884
+ * `false_` — an undefined binding that throws
885
+ * `ReferenceError: false_ is not defined` while the page is rendering, taking
886
+ * the whole page down instead of quietly rendering nothing.
887
+ *
888
+ * Only complete literals are matched. Anything else (`chatMessage?.sender`,
889
+ * `props.product?.slug`) keeps the historical verbatim-identifier printing,
890
+ * including the sanitiser pass that a state genuinely named `class` relies on.
891
+ */
892
+ var NUMERIC_LITERAL_RE = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/;
893
+ var createJSLiteralExpression = function (source, t) {
894
+ if (t === void 0) { t = types; }
895
+ switch (source) {
896
+ case 'true':
897
+ return t.booleanLiteral(true);
898
+ case 'false':
899
+ return t.booleanLiteral(false);
900
+ case 'null':
901
+ return t.nullLiteral();
902
+ case 'undefined':
903
+ return t.identifier('undefined');
904
+ default:
905
+ return NUMERIC_LITERAL_RE.test(source) ? t.numericLiteral(Number(source)) : null;
906
+ }
907
+ };
908
+ /** The left-hand side of one condition, as an AST node. */
909
+ var createConditionalIdentifierExpression = function (conditionalIdentifier, t) {
910
+ if (t === void 0) { t = types; }
911
+ // Same rule as `createDynamicValueExpression`: an un-prefixed key is the
912
+ // binding itself and must be identifier-safe; a prefixed one is a member
913
+ // access that has to keep the UIDL's original spelling.
914
+ if (conditionalIdentifier.prefix) {
915
+ return t.memberExpression(t.identifier(conditionalIdentifier.prefix), t.identifier(conditionalIdentifier.key));
916
+ }
917
+ if (conditionalIdentifier.isExpression) {
918
+ var literal = createJSLiteralExpression(conditionalIdentifier.key, t);
919
+ if (literal) {
920
+ return literal;
160
921
  }
161
- binaryExpression = expression;
162
922
  }
163
- return t.logicalExpression('&&', binaryExpression, contentNode);
923
+ return t.identifier(JSIdentifiers.createSafeJSIdentifierPath(conditionalIdentifier.key));
164
924
  };
165
- export var createBinaryExpression = function (condition, conditionalIdentifier, t) {
925
+ export var createBinaryExpression = function (condition, conditionalIdentifier, options, t) {
926
+ if (options === void 0) { options = {}; }
166
927
  if (t === void 0) { t = types; }
167
- var operand = condition.operand, operation = condition.operation;
168
- var identifier = conditionalIdentifier.prefix
169
- ? t.memberExpression(t.identifier(conditionalIdentifier.prefix), t.identifier(conditionalIdentifier.key))
170
- : t.identifier(conditionalIdentifier.key);
928
+ var operand = condition.operand, operation = condition.operation, containsField = condition.containsField;
929
+ var identifier = createConditionalIdentifierExpression(conditionalIdentifier, t);
930
+ // Array/Object operators
931
+ if (operation === 'isEmpty') {
932
+ return t.binaryExpression('===', createLengthExpression(identifier, conditionalIdentifier, t), t.numericLiteral(0));
933
+ }
934
+ if (operation === 'isNotEmpty') {
935
+ return t.binaryExpression('>', createLengthExpression(identifier, conditionalIdentifier, t), t.numericLiteral(0));
936
+ }
937
+ if (operation === 'lengthEquals' && operand !== undefined) {
938
+ return t.binaryExpression('===', createLengthExpression(identifier, conditionalIdentifier, t), resolveOperandExpression(operand, conditionalIdentifier, options));
939
+ }
940
+ if (operation === 'lengthGreaterThan' && operand !== undefined) {
941
+ return t.binaryExpression('>', createLengthExpression(identifier, conditionalIdentifier, t), resolveOperandExpression(operand, conditionalIdentifier, options));
942
+ }
943
+ if (operation === 'lengthLessThan' && operand !== undefined) {
944
+ return t.binaryExpression('<', createLengthExpression(identifier, conditionalIdentifier, t), resolveOperandExpression(operand, conditionalIdentifier, options));
945
+ }
946
+ if (operation === 'contains' && operand !== undefined) {
947
+ var operandExpr = resolveElementOperandExpression(operand, conditionalIdentifier, options);
948
+ var target = createNullSafeCollection(identifier, conditionalIdentifier, t);
949
+ if (containsField) {
950
+ var itemParam = t.identifier('__item');
951
+ return t.callExpression(t.memberExpression(target, t.identifier('some')), [
952
+ t.arrowFunctionExpression([itemParam], t.binaryExpression('===', t.memberExpression(itemParam, t.identifier(containsField)), operandExpr)),
953
+ ]);
954
+ }
955
+ return t.callExpression(t.memberExpression(target, t.identifier('includes')), [operandExpr]);
956
+ }
957
+ if (operation === 'notContains' && operand !== undefined) {
958
+ var operandExpr = resolveElementOperandExpression(operand, conditionalIdentifier, options);
959
+ var target = createNullSafeCollection(identifier, conditionalIdentifier, t);
960
+ if (containsField) {
961
+ var itemParam = t.identifier('__item');
962
+ return t.unaryExpression('!', t.callExpression(t.memberExpression(target, t.identifier('some')), [
963
+ t.arrowFunctionExpression([itemParam], t.binaryExpression('===', t.memberExpression(itemParam, t.identifier(containsField)), operandExpr)),
964
+ ]));
965
+ }
966
+ return t.unaryExpression('!', t.callExpression(t.memberExpression(target, t.identifier('includes')), [operandExpr]));
967
+ }
968
+ if (operation === 'hasKey' && operand !== undefined) {
969
+ var operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options);
970
+ return t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier('Object'), t.identifier('prototype')), t.identifier('hasOwnProperty')), t.identifier('call')), [createNullSafeCollection(identifier, conditionalIdentifier, t), operandExpr]);
971
+ }
972
+ if (operation === 'notHasKey' && operand !== undefined) {
973
+ var operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options);
974
+ return t.unaryExpression('!', t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier('Object'), t.identifier('prototype')), t.identifier('hasOwnProperty')), t.identifier('call')), [createNullSafeCollection(identifier, conditionalIdentifier, t), operandExpr]));
975
+ }
976
+ // Standard binary operators
171
977
  if (operation === '===') {
172
978
  if (operand === true) {
173
979
  return identifier;
@@ -177,35 +983,34 @@ export var createBinaryExpression = function (condition, conditionalIdentifier,
177
983
  }
178
984
  }
179
985
  if (operand !== undefined) {
180
- var stateValueIdentifier = convertValueToLiteral(operand, conditionalIdentifier.type);
181
- return t.binaryExpression(convertToBinaryOperator(operation), identifier, stateValueIdentifier);
986
+ if (typeof operand === 'object' && 'type' in operand && operand.type === 'expr') {
987
+ var exprIdentifier = getExpressionFromUIDLExpressionNode(operand);
988
+ return t.binaryExpression(convertToBinaryOperator(operation), identifier, exprIdentifier);
989
+ }
990
+ if (typeof operand === 'object' && 'type' in operand && operand.type === 'dynamic') {
991
+ var dynamicValueIdentifier = createDynamicValueExpression(operand, {
992
+ dynamicReferencePrefixMap: {
993
+ prop: 'props',
994
+ state: '',
995
+ local: '',
996
+ },
997
+ localIdentifier: options.localIdentifier,
998
+ });
999
+ return t.binaryExpression(convertToBinaryOperator(operation), identifier, dynamicValueIdentifier);
1000
+ }
1001
+ // An expression's type is a placeholder, not the type of its value.
1002
+ var stateValueIdentifier = convertValueToLiteral(coerceToDeclaredType(operand, conditionalIdentifier.isExpression ? undefined : conditionalIdentifier.type), conditionalIdentifier.type);
1003
+ var lhs = (conditionalIdentifier.referenceType === 'global' ||
1004
+ conditionalIdentifier.referenceType === 'globalState') &&
1005
+ typeof operand === 'string'
1006
+ ? t.optionalCallExpression(t.optionalMemberExpression(identifier, t.identifier('toString'), false, true), [], false)
1007
+ : identifier;
1008
+ return t.binaryExpression(convertToBinaryOperator(operation), lhs, stateValueIdentifier);
182
1009
  }
183
1010
  else {
184
1011
  return operation ? t.unaryExpression(convertToUnaryOperator(operation), identifier) : identifier;
185
1012
  }
186
1013
  };
187
- /**
188
- * Because of the restrictions of the AST Types we need to have a clear subset of binary operators we can use
189
- * @param operation - the operation defined in the UIDL for the current state branch
190
- */
191
- var convertToBinaryOperator = function (operation) {
192
- var allowedOperations = ['===', '!==', '>=', '<=', '>', '<'];
193
- if (allowedOperations.includes(operation)) {
194
- return operation;
195
- }
196
- else {
197
- return '===';
198
- }
199
- };
200
- var convertToUnaryOperator = function (operation) {
201
- var allowedOperations = ['!'];
202
- if (allowedOperations.includes(operation)) {
203
- return operation;
204
- }
205
- else {
206
- return '!';
207
- }
208
- };
209
1014
  export var getRepeatSourceIdentifier = function (dataSource, options) {
210
1015
  switch (dataSource.type) {
211
1016
  case 'static':