@webiny/website-builder-sdk 6.3.0 → 6.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/BindingsApi.js +29 -36
  2. package/BindingsApi.js.map +1 -1
  3. package/BindingsProcessor.js +34 -43
  4. package/BindingsProcessor.js.map +1 -1
  5. package/BindingsProcessor.test.js +82 -78
  6. package/BindingsProcessor.test.js.map +1 -1
  7. package/BindingsResolver.js +92 -119
  8. package/BindingsResolver.js.map +1 -1
  9. package/BindingsResolver.test.js +399 -363
  10. package/BindingsResolver.test.js.map +1 -1
  11. package/ComponentInputTraverser.js +28 -49
  12. package/ComponentInputTraverser.js.map +1 -1
  13. package/ComponentManifestToAstConverter.js +20 -21
  14. package/ComponentManifestToAstConverter.js.map +1 -1
  15. package/ComponentRegistry.js +26 -45
  16. package/ComponentRegistry.js.map +1 -1
  17. package/ComponentResolver.js +25 -29
  18. package/ComponentResolver.js.map +1 -1
  19. package/ConstraintEvaluator.js +246 -353
  20. package/ConstraintEvaluator.js.map +1 -1
  21. package/ConstraintEvaluator.test.js +1616 -1438
  22. package/ConstraintEvaluator.test.js.map +1 -1
  23. package/ContentSdk.js +83 -90
  24. package/ContentSdk.js.map +1 -1
  25. package/DocumentStore.js +47 -59
  26. package/DocumentStore.js.map +1 -1
  27. package/DocumentStoreManager.js +17 -16
  28. package/DocumentStoreManager.js.map +1 -1
  29. package/EditingSdk.js +87 -121
  30. package/EditingSdk.js.map +1 -1
  31. package/ElementFactory.js +126 -174
  32. package/ElementFactory.js.map +1 -1
  33. package/ElementFactory.test.js +234 -263
  34. package/ElementFactory.test.js.map +1 -1
  35. package/Environment.js +18 -19
  36. package/Environment.js.map +1 -1
  37. package/FunctionConverter.js +8 -7
  38. package/FunctionConverter.js.map +1 -1
  39. package/HashObject.js +11 -26
  40. package/HashObject.js.map +1 -1
  41. package/HotkeyManager.js +40 -47
  42. package/HotkeyManager.js.map +1 -1
  43. package/IBindingsUpdater.js +0 -3
  44. package/IRedirects.js +0 -3
  45. package/InheritanceProcessor.js +99 -139
  46. package/InheritanceProcessor.js.map +1 -1
  47. package/InheritanceProcessor.test.js +178 -179
  48. package/InheritanceProcessor.test.js.map +1 -1
  49. package/InheritedValueResolver.js +15 -20
  50. package/InheritedValueResolver.js.map +1 -1
  51. package/InputBindingsProcessor.js +187 -307
  52. package/InputBindingsProcessor.js.map +1 -1
  53. package/InputsBindingsProcessor.test.js +334 -315
  54. package/InputsBindingsProcessor.test.js.map +1 -1
  55. package/InputsUpdater.js +23 -26
  56. package/InputsUpdater.js.map +1 -1
  57. package/LiveSdk.js +12 -13
  58. package/LiveSdk.js.map +1 -1
  59. package/Logger.js +9 -8
  60. package/Logger.js.map +1 -1
  61. package/MouseTracker.js +77 -83
  62. package/MouseTracker.js.map +1 -1
  63. package/NullSdk.js +22 -21
  64. package/NullSdk.js.map +1 -1
  65. package/PreviewDocument.js +27 -30
  66. package/PreviewDocument.js.map +1 -1
  67. package/PreviewSdk.js +16 -17
  68. package/PreviewSdk.js.map +1 -1
  69. package/PreviewViewport.js +51 -63
  70. package/PreviewViewport.js.map +1 -1
  71. package/ResizeObserver.js +24 -31
  72. package/ResizeObserver.js.map +1 -1
  73. package/StylesBindingsProcessor.js +40 -79
  74. package/StylesBindingsProcessor.js.map +1 -1
  75. package/StylesUpdater.js +20 -25
  76. package/StylesUpdater.js.map +1 -1
  77. package/Theme.js +28 -25
  78. package/Theme.js.map +1 -1
  79. package/ViewportManager.js +89 -101
  80. package/ViewportManager.js.map +1 -1
  81. package/constants.js +7 -6
  82. package/constants.js.map +1 -1
  83. package/createElement.js +5 -6
  84. package/createElement.js.map +1 -1
  85. package/createInput.js +85 -143
  86. package/createInput.js.map +1 -1
  87. package/createTheme.js +2 -3
  88. package/createTheme.js.map +1 -1
  89. package/dataProviders/ApiClient.js +40 -49
  90. package/dataProviders/ApiClient.js.map +1 -1
  91. package/dataProviders/DefaultDataProvider.js +56 -58
  92. package/dataProviders/DefaultDataProvider.js.map +1 -1
  93. package/dataProviders/GET_PAGE_BY_ID.js +2 -1
  94. package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
  95. package/dataProviders/GET_PAGE_BY_PATH.js +2 -1
  96. package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
  97. package/dataProviders/LIST_PUBLISHED_PAGES.js +2 -1
  98. package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
  99. package/dataProviders/NullDataProvider.js +21 -20
  100. package/dataProviders/NullDataProvider.js.map +1 -1
  101. package/dataProviders/RedirectsProvider.js +24 -27
  102. package/dataProviders/RedirectsProvider.js.map +1 -1
  103. package/defaultBreakpoints.js +23 -22
  104. package/defaultBreakpoints.js.map +1 -1
  105. package/documentOperations/$addElementReferenceToParent.js +29 -32
  106. package/documentOperations/$addElementReferenceToParent.js.map +1 -1
  107. package/documentOperations/AddElement.js +8 -7
  108. package/documentOperations/AddElement.js.map +1 -1
  109. package/documentOperations/AddToParent.js +14 -13
  110. package/documentOperations/AddToParent.js.map +1 -1
  111. package/documentOperations/IDocumentOperation.js +0 -3
  112. package/documentOperations/RemoveElement.js +9 -15
  113. package/documentOperations/RemoveElement.js.map +1 -1
  114. package/documentOperations/SetGlobalInputBinding.js +23 -22
  115. package/documentOperations/SetGlobalInputBinding.js.map +1 -1
  116. package/documentOperations/SetGlobalStyleBinding.js +23 -23
  117. package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
  118. package/documentOperations/SetInputBindingOverride.js +30 -29
  119. package/documentOperations/SetInputBindingOverride.js.map +1 -1
  120. package/documentOperations/SetStyleBindingOverride.js +30 -31
  121. package/documentOperations/SetStyleBindingOverride.js.map +1 -1
  122. package/documentOperations/index.js +9 -8
  123. package/documentOperations/index.js.map +1 -1
  124. package/findMatchingAstNode.js +11 -13
  125. package/findMatchingAstNode.js.map +1 -1
  126. package/generateElementId.js +2 -1
  127. package/generateElementId.js.map +1 -1
  128. package/headersProvider.js +4 -3
  129. package/headersProvider.js.map +1 -1
  130. package/index.js +0 -2
  131. package/jsonPatch.js +5 -9
  132. package/jsonPatch.js.map +1 -1
  133. package/messages.js +12 -11
  134. package/messages.js.map +1 -1
  135. package/messenger/MessageOrigin.js +12 -11
  136. package/messenger/MessageOrigin.js.map +1 -1
  137. package/messenger/Messenger.js +58 -69
  138. package/messenger/Messenger.js.map +1 -1
  139. package/messenger/index.js +0 -2
  140. package/package.json +5 -5
  141. package/registerComponentGroup.js +5 -6
  142. package/registerComponentGroup.js.map +1 -1
  143. package/types/ShorthandCssProperties.js +0 -3
  144. package/types/WebsiteBuilderTheme.js +0 -3
  145. package/types.d.ts +3 -0
  146. package/types.js +0 -3
  147. package/IBindingsUpdater.js.map +0 -1
  148. package/IRedirects.js.map +0 -1
  149. package/documentOperations/IDocumentOperation.js.map +0 -1
  150. package/index.js.map +0 -1
  151. package/messenger/index.js.map +0 -1
  152. package/types/ShorthandCssProperties.js.map +0 -1
  153. package/types/WebsiteBuilderTheme.js.map +0 -1
  154. package/types.js.map +0 -1
@@ -1,324 +1,204 @@
1
- import deepEqual from "deep-equal";
1
+ import deep_equal from "deep-equal";
2
2
  import set from "lodash/set.js";
3
3
  import { InheritedValueResolver } from "./InheritedValueResolver.js";
4
4
  import { DocumentOperations } from "./documentOperations/index.js";
5
5
  import { InputsUpdater } from "./InputsUpdater.js";
6
6
  import { generateElementId } from "./generateElementId.js";
7
- /**
8
- * Handles deep-to-flat and flat-to-deep conversion of input bindings,
9
- * with breakpoint inheritance awareness.
10
- */
11
- export class InputsBindingsProcessor {
12
- constructor(elementId, inputsAst, breakpoints, rawBindings, elementFactory) {
13
- this.elementId = elementId;
14
- this.inputsAst = inputsAst;
15
- this.breakpoints = breakpoints;
16
- this.rawBindings = rawBindings;
17
- this.elementFactory = elementFactory;
18
- this.elementReferences = this.getElementReferences(rawBindings.inputs);
19
- }
20
-
21
- /**
22
- * Converts flat input bindings into deep inputs object (removes `.static` wrappers).
23
- */
24
- toDeepInputs(flat) {
25
- const result = {};
26
-
27
- // Assigns a value to a nested path within the result object, creating arrays/objects as needed.
28
- const assignValue = (path, value) => {
29
- let current = result;
30
- for (let i = 0; i < path.length - 1; i++) {
31
- const key = path[i];
32
- const nextKey = path[i + 1];
33
- const isNextIndex = typeof nextKey === "number";
34
- if (typeof key === "number") {
35
- if (!Array.isArray(current)) {
36
- throw new Error("Expected array in path assignment.");
37
- }
38
- while (current.length <= key) {
39
- current.push(isNextIndex ? [] : {});
40
- }
41
- if (typeof current[key] !== "object") {
42
- current[key] = isNextIndex ? [] : {};
43
- }
44
- current = current[key];
45
- } else {
46
- if (!(key in current) || typeof current[key] !== "object") {
47
- current[key] = isNextIndex ? [] : {};
48
- }
49
- current = current[key];
50
- }
51
- }
52
- current[path[path.length - 1]] = value;
53
- };
54
-
55
- // Recursively walks the AST and assigns values from flat bindings to the nested result.
56
- const walk = (nodes, prefix) => {
57
- for (const node of nodes) {
58
- const pathParts = [...prefix, node.name];
59
- const flatKey = pathParts.join("/");
60
- const entry = flat[flatKey];
61
- const staticValue = entry?.static;
62
- if (node.children.length > 0) {
63
- if (node.list) {
64
- const pattern = new RegExp(`^${flatKey}\\/(\\d+)\\/`);
65
- const indexes = Object.keys(flat).reduce((acc, key) => {
66
- const match = key.match(pattern);
67
- if (match) {
68
- acc.push(parseInt(match[1], 10));
69
- }
70
- return acc;
71
- }, []);
72
- const uniqueIndexes = Array.from(new Set(indexes)).sort((a, b) => a - b);
73
- for (const i of uniqueIndexes) {
74
- walk(node.children, [...prefix, `${node.name}/${i}`]);
75
- }
76
- } else {
77
- walk(node.children, pathParts);
78
- }
79
- } else if (staticValue !== undefined) {
80
- const path = pathParts.reduce((acc, part) => {
81
- const match = part.match(/(.*?)\/(\d+)/);
82
- if (match) {
83
- acc.push(match[1], Number(match[2]));
84
- } else {
85
- acc.push(part);
86
- }
87
- return acc;
88
- }, []);
89
- assignValue(path, staticValue);
90
- }
91
- }
92
- };
93
- walk(this.inputsAst, []);
94
- return result;
95
- }
96
-
97
- /**
98
- * Flattens deep inputs object into flat bindings with `.static` wrappers,
99
- * skipping overrides that match inherited parent breakpoint values.
100
- */
101
- createUpdate(inputs, breakpoint) {
102
- const operations = [];
103
- const originalInputs = this.rawBindings.inputs ?? {};
104
- const rebuilt = {
105
- inputs: {},
106
- overrides: {}
107
- };
108
-
109
- // Clone existing overrides if present, to avoid losing breakpoint overrides
110
- if (this.rawBindings.overrides) {
111
- for (const [bp, overrides] of Object.entries(this.rawBindings.overrides)) {
112
- if (overrides.inputs) {
113
- set(rebuilt, `overrides.${bp}.inputs`, structuredClone(this.rawBindings.overrides[bp].inputs));
114
- }
115
- }
7
+ class InputsBindingsProcessor {
8
+ constructor(elementId, inputsAst, breakpoints, rawBindings, elementFactory){
9
+ this.elementId = elementId;
10
+ this.inputsAst = inputsAst;
11
+ this.breakpoints = breakpoints;
12
+ this.rawBindings = rawBindings;
13
+ this.elementFactory = elementFactory;
14
+ this.elementReferences = this.getElementReferences(rawBindings.inputs);
116
15
  }
117
-
118
- // Set to track which flat binding paths we've processed during traversal
119
- const seenPaths = new Set();
120
- const valueResolver = new InheritedValueResolver(this.breakpoints, bp => {
121
- if (this.isBaseBreakpoint(bp)) {
122
- return this.rawBindings.inputs;
123
- }
124
- return this.rawBindings.overrides?.[bp]?.inputs;
125
- });
126
-
127
- // Extracts a nested value from an object based on a flat string path.
128
- // Supports array indexes like 'rows/0/columns/1/children'.
129
- const getValue = (obj, path) => {
130
- const segments = path.split("/");
131
- const keys = segments.flatMap(segment => {
132
- return segment.split(".").map(part => {
133
- return /^\d+$/.test(part) ? parseInt(part, 10) : part;
134
- });
135
- });
136
- return keys.reduce((acc, key) => acc ? acc[key] : undefined, obj);
137
- };
138
-
139
- // Recursively traverses the AST nodes, comparing new input values with original bindings.
140
- // Collects changed values into 'rebuilt' and generates operations for new elements.
141
- const compareAndCollect = (nodes, prefix) => {
142
- for (const node of nodes) {
143
- const pathParts = [...prefix, node.name];
144
- const flatKey = pathParts.join("/");
145
-
146
- // Mark this path as seen
147
- seenPaths.add(flatKey);
148
- if (node.children.length) {
149
- if (node.list) {
150
- // For list nodes, process each indexed item separately
151
- const list = getValue(inputs, flatKey);
152
- if (Array.isArray(list)) {
153
- for (let i = 0; i < list.length; i++) {
154
- // Recurse with indexed path like 'rows[0]', 'rows[1]'
155
- compareAndCollect(node.children, [...pathParts.slice(0, -1), `${node.name}/${i}`]);
156
- }
157
- }
158
- } else {
159
- // For single object nodes, recurse normally
160
- compareAndCollect(node.children, pathParts);
161
- }
162
- } else {
163
- // Leaf node (primitive or slot) processing
164
-
165
- // Get current new value from deep inputs
166
- let newValue = getValue(inputs, flatKey);
167
-
168
- // Get original binding entry for this path
169
- const originalEntry = originalInputs[flatKey];
170
-
171
- // Skip if newValue is undefined and no original entry
172
- if (newValue === undefined && !originalEntry) {
173
- continue;
174
- }
175
-
176
- // For list slots, process CreateElement items within the array.
177
- if (node.list && Array.isArray(newValue)) {
178
- newValue = newValue.map(item => {
179
- if (typeof item === "object" && item !== null && item.action === "CreateElement") {
180
- const newElement = this.elementFactory.createElementFromComponent({
181
- componentName: item.params.component,
182
- parentId: this.elementId,
183
- slot: flatKey,
184
- bindings: item.params
185
- });
186
- // Skip AddToParent — this processor manages the binding array.
187
- operations.push(...newElement.operations.filter(op => !(op instanceof DocumentOperations.AddToParent)));
188
- return newElement.element.id;
189
- }
190
- return item;
191
- });
192
- }
193
- if (!Array.isArray(newValue) && typeof newValue === "object" && newValue?.action === "CreateElement") {
194
- // Handle single (non-list) CreateElement action
195
- const newElement = this.elementFactory.createElementFromComponent({
196
- componentName: newValue.params.component,
197
- parentId: this.elementId,
198
- slot: flatKey,
199
- index: -1,
200
- bindings: newValue.params
201
- });
202
- const createdId = newElement.element.id;
203
-
204
- // Assign or generate a stable unique id for the binding
205
- const existingId = originalEntry?.id;
206
- const idToUse = existingId ?? generateElementId();
207
-
208
- // Build binding for the new element id(s)
209
- const binding = {
210
- static: createdId,
211
- type: node.type,
212
- list: node.list,
213
- id: idToUse
214
- };
215
- if (node.input?.responsive && !this.isBaseBreakpoint(breakpoint)) {
216
- const inheritedValue = valueResolver.getInheritedValue(flatKey, breakpoint);
217
- if (binding.static === undefined) {
218
- // Unset override
219
- if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) {
220
- delete rebuilt.overrides[breakpoint].inputs[flatKey];
221
- }
222
- } else if (inheritedValue === undefined || !deepEqual(inheritedValue, binding.static)) {
223
- if (!rebuilt.overrides[breakpoint]) {
224
- rebuilt.overrides[breakpoint] = {
225
- inputs: {}
226
- };
227
- }
228
- rebuilt.overrides[breakpoint].inputs[flatKey] = binding;
229
- } else {
230
- if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) {
231
- delete rebuilt.overrides[breakpoint].inputs[flatKey];
16
+ toDeepInputs(flat) {
17
+ const result = {};
18
+ const assignValue = (path, value)=>{
19
+ let current = result;
20
+ for(let i = 0; i < path.length - 1; i++){
21
+ const key = path[i];
22
+ const nextKey = path[i + 1];
23
+ const isNextIndex = "number" == typeof nextKey;
24
+ if ("number" == typeof key) {
25
+ if (!Array.isArray(current)) throw new Error("Expected array in path assignment.");
26
+ while(current.length <= key)current.push(isNextIndex ? [] : {});
27
+ if ("object" != typeof current[key]) current[key] = isNextIndex ? [] : {};
28
+ current = current[key];
29
+ } else {
30
+ if (!(key in current) || "object" != typeof current[key]) current[key] = isNextIndex ? [] : {};
31
+ current = current[key];
232
32
  }
233
- }
234
- if (originalEntry) {
235
- rebuilt.inputs[flatKey] = originalEntry;
236
- }
237
- } else {
238
- // Normal case: update base inputs
239
- rebuilt.inputs[flatKey] = binding;
240
33
  }
241
-
242
- // Skip AddToParent — this processor manages the binding directly.
243
- operations.push(...newElement.operations.filter(op => !(op instanceof DocumentOperations.AddToParent)));
244
- } else {
245
- // Normal value update
246
- const isResponsive = node.input?.responsive && !this.isBaseBreakpoint(breakpoint);
247
-
248
- // Assign or generate a stable unique id for the binding
249
- const existingId = originalEntry?.id;
250
- const idToUse = existingId ?? generateElementId();
251
-
252
- // Merge existing original entry data with updated static value
253
- const binding = {
254
- ...(originalEntry ?? {}),
255
- static: newValue,
256
- type: node.type,
257
- list: node.list,
258
- id: idToUse
259
- };
260
- if (isResponsive) {
261
- const inheritedValue = valueResolver.getInheritedValue(flatKey, breakpoint);
262
- if (binding.static === undefined) {
263
- // Unset override
264
- if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) {
265
- delete rebuilt.overrides[breakpoint].inputs[flatKey];
266
- }
267
- } else if (inheritedValue === undefined || !deepEqual(inheritedValue, binding.static)) {
268
- if (!rebuilt.overrides[breakpoint]) {
269
- rebuilt.overrides[breakpoint] = {
270
- inputs: {}
271
- };
34
+ current[path[path.length - 1]] = value;
35
+ };
36
+ const walk = (nodes, prefix)=>{
37
+ for (const node of nodes){
38
+ const pathParts = [
39
+ ...prefix,
40
+ node.name
41
+ ];
42
+ const flatKey = pathParts.join("/");
43
+ const entry = flat[flatKey];
44
+ const staticValue = entry?.static;
45
+ if (node.children.length > 0) if (node.list) {
46
+ const pattern = new RegExp(`^${flatKey}\\/(\\d+)\\/`);
47
+ const indexes = Object.keys(flat).reduce((acc, key)=>{
48
+ const match = key.match(pattern);
49
+ if (match) acc.push(parseInt(match[1], 10));
50
+ return acc;
51
+ }, []);
52
+ const uniqueIndexes = Array.from(new Set(indexes)).sort((a, b)=>a - b);
53
+ for (const i of uniqueIndexes)walk(node.children, [
54
+ ...prefix,
55
+ `${node.name}/${i}`
56
+ ]);
57
+ } else walk(node.children, pathParts);
58
+ else if (void 0 !== staticValue) {
59
+ const path = pathParts.reduce((acc, part)=>{
60
+ const match = part.match(/(.*?)\/(\d+)/);
61
+ if (match) acc.push(match[1], Number(match[2]));
62
+ else acc.push(part);
63
+ return acc;
64
+ }, []);
65
+ assignValue(path, staticValue);
272
66
  }
273
- rebuilt.overrides[breakpoint].inputs[flatKey] = binding;
274
- } else {
275
- if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) {
276
- delete rebuilt.overrides[breakpoint].inputs[flatKey];
277
- }
278
- }
279
- if (originalEntry) {
280
- rebuilt.inputs[flatKey] = originalEntry;
281
- }
282
- } else {
283
- // Base binding update
284
- rebuilt.inputs[flatKey] = binding;
285
67
  }
286
- }
68
+ };
69
+ walk(this.inputsAst, []);
70
+ return result;
71
+ }
72
+ createUpdate(inputs, breakpoint) {
73
+ const operations = [];
74
+ const originalInputs = this.rawBindings.inputs ?? {};
75
+ const rebuilt = {
76
+ inputs: {},
77
+ overrides: {}
78
+ };
79
+ if (this.rawBindings.overrides) {
80
+ for (const [bp, overrides] of Object.entries(this.rawBindings.overrides))if (overrides.inputs) set(rebuilt, `overrides.${bp}.inputs`, structuredClone(this.rawBindings.overrides[bp].inputs));
287
81
  }
288
- }
289
- };
290
-
291
- // Start the AST traversal and collection.
292
- compareAndCollect(this.inputsAst, []);
293
-
294
- // Identify elements referenced in slots that were removed since last state,
295
- // and queue their removal.
296
- const usedSlotIds = this.getElementReferences(rebuilt.inputs);
297
- for (const id of this.elementReferences) {
298
- if (!usedSlotIds.has(id)) {
299
- operations.push(new DocumentOperations.RemoveElement(id));
300
- }
82
+ const seenPaths = new Set();
83
+ const valueResolver = new InheritedValueResolver(this.breakpoints, (bp)=>{
84
+ if (this.isBaseBreakpoint(bp)) return this.rawBindings.inputs;
85
+ return this.rawBindings.overrides?.[bp]?.inputs;
86
+ });
87
+ const getValue = (obj, path)=>{
88
+ const segments = path.split("/");
89
+ const keys = segments.flatMap((segment)=>segment.split(".").map((part)=>/^\d+$/.test(part) ? parseInt(part, 10) : part));
90
+ return keys.reduce((acc, key)=>acc ? acc[key] : void 0, obj);
91
+ };
92
+ const compareAndCollect = (nodes, prefix)=>{
93
+ for (const node of nodes){
94
+ const pathParts = [
95
+ ...prefix,
96
+ node.name
97
+ ];
98
+ const flatKey = pathParts.join("/");
99
+ seenPaths.add(flatKey);
100
+ if (node.children.length) if (node.list) {
101
+ const list = getValue(inputs, flatKey);
102
+ if (Array.isArray(list)) for(let i = 0; i < list.length; i++)compareAndCollect(node.children, [
103
+ ...pathParts.slice(0, -1),
104
+ `${node.name}/${i}`
105
+ ]);
106
+ } else compareAndCollect(node.children, pathParts);
107
+ else {
108
+ let newValue = getValue(inputs, flatKey);
109
+ const originalEntry = originalInputs[flatKey];
110
+ if (void 0 === newValue && !originalEntry) continue;
111
+ if (node.list && Array.isArray(newValue)) newValue = newValue.map((item)=>{
112
+ if ("object" == typeof item && null !== item && "CreateElement" === item.action) {
113
+ const newElement = this.elementFactory.createElementFromComponent({
114
+ componentName: item.params.component,
115
+ parentId: this.elementId,
116
+ slot: flatKey,
117
+ bindings: item.params
118
+ });
119
+ operations.push(...newElement.operations.filter((op)=>!(op instanceof DocumentOperations.AddToParent)));
120
+ return newElement.element.id;
121
+ }
122
+ return item;
123
+ });
124
+ if (Array.isArray(newValue) || "object" != typeof newValue || newValue?.action !== "CreateElement") {
125
+ const isResponsive = node.input?.responsive && !this.isBaseBreakpoint(breakpoint);
126
+ const existingId = originalEntry?.id;
127
+ const idToUse = existingId ?? generateElementId();
128
+ const binding = {
129
+ ...originalEntry ?? {},
130
+ static: newValue,
131
+ type: node.type,
132
+ list: node.list,
133
+ id: idToUse
134
+ };
135
+ if (isResponsive) {
136
+ const inheritedValue = valueResolver.getInheritedValue(flatKey, breakpoint);
137
+ if (void 0 === binding.static) {
138
+ if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) delete rebuilt.overrides[breakpoint].inputs[flatKey];
139
+ } else if (void 0 !== inheritedValue && deep_equal(inheritedValue, binding.static)) {
140
+ if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) delete rebuilt.overrides[breakpoint].inputs[flatKey];
141
+ } else {
142
+ if (!rebuilt.overrides[breakpoint]) rebuilt.overrides[breakpoint] = {
143
+ inputs: {}
144
+ };
145
+ rebuilt.overrides[breakpoint].inputs[flatKey] = binding;
146
+ }
147
+ if (originalEntry) rebuilt.inputs[flatKey] = originalEntry;
148
+ } else rebuilt.inputs[flatKey] = binding;
149
+ } else {
150
+ const newElement = this.elementFactory.createElementFromComponent({
151
+ componentName: newValue.params.component,
152
+ parentId: this.elementId,
153
+ slot: flatKey,
154
+ index: -1,
155
+ bindings: newValue.params
156
+ });
157
+ const createdId = newElement.element.id;
158
+ const existingId = originalEntry?.id;
159
+ const idToUse = existingId ?? generateElementId();
160
+ const binding = {
161
+ static: createdId,
162
+ type: node.type,
163
+ list: node.list,
164
+ id: idToUse
165
+ };
166
+ if (node.input?.responsive && !this.isBaseBreakpoint(breakpoint)) {
167
+ const inheritedValue = valueResolver.getInheritedValue(flatKey, breakpoint);
168
+ if (void 0 === binding.static) {
169
+ if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) delete rebuilt.overrides[breakpoint].inputs[flatKey];
170
+ } else if (void 0 !== inheritedValue && deep_equal(inheritedValue, binding.static)) {
171
+ if (rebuilt.overrides[breakpoint]?.inputs?.[flatKey]) delete rebuilt.overrides[breakpoint].inputs[flatKey];
172
+ } else {
173
+ if (!rebuilt.overrides[breakpoint]) rebuilt.overrides[breakpoint] = {
174
+ inputs: {}
175
+ };
176
+ rebuilt.overrides[breakpoint].inputs[flatKey] = binding;
177
+ }
178
+ if (originalEntry) rebuilt.inputs[flatKey] = originalEntry;
179
+ } else rebuilt.inputs[flatKey] = binding;
180
+ operations.push(...newElement.operations.filter((op)=>!(op instanceof DocumentOperations.AddToParent)));
181
+ }
182
+ }
183
+ }
184
+ };
185
+ compareAndCollect(this.inputsAst, []);
186
+ const usedSlotIds = this.getElementReferences(rebuilt.inputs);
187
+ for (const id of this.elementReferences)if (!usedSlotIds.has(id)) operations.push(new DocumentOperations.RemoveElement(id));
188
+ return new InputsUpdater(this.elementId, rebuilt, operations);
301
189
  }
302
- return new InputsUpdater(this.elementId, rebuilt, operations);
303
- }
304
-
305
- // Returns a set of element IDs referenced in slot bindings within the provided inputs.
306
- getElementReferences(inputs = {}) {
307
- const references = new Set();
308
- for (const [, binding] of Object.entries(inputs)) {
309
- if (binding.type === "slot") {
310
- if (Array.isArray(binding.static)) {
311
- (binding.static ?? []).forEach(id => references.add(id));
312
- } else if (typeof binding.static === "string") {
313
- references.add(binding.static);
190
+ getElementReferences(inputs = {}) {
191
+ const references = new Set();
192
+ for (const [, binding] of Object.entries(inputs))if ("slot" === binding.type) {
193
+ if (Array.isArray(binding.static)) (binding.static ?? []).forEach((id)=>references.add(id));
194
+ else if ("string" == typeof binding.static) references.add(binding.static);
314
195
  }
315
- }
196
+ return references;
197
+ }
198
+ isBaseBreakpoint(name) {
199
+ return 0 === this.breakpoints.indexOf(name);
316
200
  }
317
- return references;
318
- }
319
- isBaseBreakpoint(name) {
320
- return this.breakpoints.indexOf(name) === 0;
321
- }
322
201
  }
202
+ export { InputsBindingsProcessor };
323
203
 
324
204
  //# sourceMappingURL=InputBindingsProcessor.js.map