@teleporthq/teleport-shared 0.41.0 → 0.42.0

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.
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.extractExternalDependencies = exports.removeChildNodes = exports.findFirstElementNode = exports.transformAttributesAssignmentsToJson = exports.transformStylesAssignmentsToJson = exports.transformStringAssignmentToJson = exports.transformDynamicStyles = exports.cleanupDynamicStyles = exports.splitDynamicAndStaticStyles = exports.traverseRepeats = exports.traverseElements = exports.traverseResources = exports.traverseNodes = exports.cloneObject = exports.prefixAssetsPath = exports.getRepeatIteratorNameAndKey = exports.getComponentClassName = exports.getComponentFolderPath = exports.getTemplateFileName = exports.getStyleFileName = exports.getComponentFileName = exports.setFriendlyOutputOptions = exports.createWebComponentFriendlyName = exports.extractRoutes = void 0;
14
+ exports.extractExternalDependencies = exports.removeChildNodes = exports.findFirstElementNode = exports.transformAttributesAssignmentsToJson = exports.generateIdWithRefPath = exports.transformStylesAssignmentsToJson = exports.transformStringAssignmentToJson = exports.transformDynamicStyles = exports.cleanupDynamicStyles = exports.splitDynamicAndStaticStyles = exports.traverseRepeats = exports.traverseElements = exports.traverseResources = exports.traverseNodes = exports.cloneObject = exports.prefixAssetsPath = exports.getRepeatIteratorNameAndKey = exports.getComponentClassName = exports.getComponentFolderPath = exports.getTemplateFileName = exports.getStyleFileName = exports.getComponentFileName = exports.setFriendlyOutputOptions = exports.createWebComponentFriendlyName = exports.extractRoutes = void 0;
15
15
  var string_utils_1 = require("./string-utils");
16
16
  var path_1 = require("path");
17
17
  var __1 = require("..");
@@ -19,7 +19,11 @@ var extractRoutes = function (rootComponent) {
19
19
  // Assuming root element starts with a UIDLElementNode
20
20
  var rootElement = rootComponent.node.content;
21
21
  // Look for conditional nodes in the first level children of the root element
22
- return rootElement.children.filter(function (child) { return child.type === 'conditional' && child.content.reference.content.id === 'route'; });
22
+ return rootElement.children.filter(function (child) {
23
+ return child.type === 'conditional' &&
24
+ child.content.reference.type === 'dynamic' &&
25
+ child.content.reference.content.id === 'route';
26
+ });
23
27
  };
24
28
  exports.extractRoutes = extractRoutes;
25
29
  var createWebComponentFriendlyName = function (componentName) {
@@ -116,6 +120,9 @@ var prefixAssetsPath = function (originalString, assets) {
116
120
  var prefix = assets.prefix, _a = assets.mappings, mappings = _a === void 0 ? {} : _a, identifier = assets.identifier;
117
121
  var assetName = (0, path_1.basename)(originalString);
118
122
  var decodedAssetName = decodeURIComponent(assetName);
123
+ // Extract the full path from the original string (normalize to remove leading slash)
124
+ var fullPath = originalString.startsWith('/') ? originalString.slice(1) : originalString;
125
+ var decodedFullPath = decodeURIComponent(fullPath);
119
126
  /*
120
127
  If the value is missing from the mapping, it means
121
128
  - asset is missing in the project packer
@@ -123,15 +130,27 @@ var prefixAssetsPath = function (originalString, assets) {
123
130
 
124
131
  Note: We need to check for decoded asset name as well as for some special characters such as katakana / kanjis / hiraganas
125
132
  the src / url leading to the asset can be encoded and we need to check the decoded version against the asset mapping
133
+
134
+ Try full-path lookup first (to handle duplicate filenames in different folders),
135
+ then fall back to basename-only (for backward compatibility)
126
136
  */
127
- if (!(typeof mappings[assetName] === 'string') &&
137
+ if (!(typeof mappings[fullPath] === 'string') &&
138
+ !(typeof mappings[decodedFullPath] === 'string') &&
139
+ !(typeof mappings[assetName] === 'string') &&
128
140
  !(typeof mappings[decodedAssetName] === 'string')) {
129
141
  return originalString;
130
142
  }
131
143
  /*
132
144
  need to use either the original or decoded assetName to retrieve its mapping if there is one
145
+ Priority: fullPath > decodedFullPath > assetName > decodedAssetName
133
146
  */
134
- var assetNameUsedForMapping = typeof mappings[assetName] === 'string' ? assetName : decodedAssetName;
147
+ var assetNameUsedForMapping = typeof mappings[fullPath] === 'string'
148
+ ? fullPath
149
+ : typeof mappings[decodedFullPath] === 'string'
150
+ ? decodedFullPath
151
+ : typeof mappings[assetName] === 'string'
152
+ ? assetName
153
+ : decodedAssetName;
135
154
  /*
136
155
  If the value from the mapping is an empty string
137
156
  we need to not join it in the return path as it would append
@@ -155,15 +174,32 @@ exports.cloneObject = cloneObject;
155
174
  // This function parses all the UIDLNodes in a tree structure
156
175
  // enabling a function to be applied to each individual node
157
176
  var traverseNodes = function (node, fn, parent) {
158
- var _a, _b, _c;
177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
159
178
  if (parent === void 0) { parent = null; }
179
+ if (!node.type) {
180
+ return;
181
+ }
160
182
  fn(node, parent);
161
183
  switch (node.type) {
162
184
  case 'element':
163
- var _d = node.content, attrs_1 = _d.attrs, children = _d.children, style = _d.style, abilities = _d.abilities, referencedStyles = _d.referencedStyles;
185
+ // Check if this element node is wrapping a data-source node
186
+ // This happens when node.content has a 'type' property that is a data-source type
187
+ if (node.content &&
188
+ typeof node.content === 'object' &&
189
+ 'type' in node.content &&
190
+ (node.content.type === 'data-source-item' || node.content.type === 'data-source-list')) {
191
+ // Treat the entire node.content as a data-source node
192
+ (0, exports.traverseNodes)(node.content, fn, node);
193
+ break;
194
+ }
195
+ var _o = node.content, attrs_1 = _o.attrs, children = _o.children, style = _o.style, abilities = _o.abilities, referencedStyles = _o.referencedStyles;
164
196
  if (attrs_1) {
165
197
  Object.keys(attrs_1).forEach(function (attrKey) {
166
- (0, exports.traverseNodes)(attrs_1[attrKey], fn, node);
198
+ var attr = attrs_1[attrKey];
199
+ if (attr.type === 'object') {
200
+ return;
201
+ }
202
+ (0, exports.traverseNodes)(attr, fn, node);
167
203
  });
168
204
  }
169
205
  if (referencedStyles && Object.keys(referencedStyles).length > 0) {
@@ -199,6 +235,9 @@ var traverseNodes = function (node, fn, parent) {
199
235
  if (node.content.nodes.empty) {
200
236
  (0, exports.traverseNodes)(node.content.nodes.empty, fn);
201
237
  }
238
+ if (node.content.nodes.loading) {
239
+ (0, exports.traverseNodes)(node.content.nodes.loading, fn);
240
+ }
202
241
  break;
203
242
  case 'cms-item':
204
243
  (0, exports.traverseNodes)(node.content.nodes.success, fn);
@@ -209,6 +248,49 @@ var traverseNodes = function (node, fn, parent) {
209
248
  (0, exports.traverseNodes)(node.content.nodes.loading, fn);
210
249
  }
211
250
  break;
251
+ case 'cms-mixed-type':
252
+ if ((_d = node.content.nodes) === null || _d === void 0 ? void 0 : _d.fallback) {
253
+ (0, exports.traverseNodes)(node.content.nodes.fallback, fn);
254
+ }
255
+ if ((_e = node.content.nodes) === null || _e === void 0 ? void 0 : _e.error) {
256
+ (0, exports.traverseNodes)(node.content.nodes.error, fn);
257
+ }
258
+ Object.keys(((_f = node.content) === null || _f === void 0 ? void 0 : _f.mappings) || {}).forEach(function (key) {
259
+ (0, exports.traverseNodes)(node.content.mappings[key], fn);
260
+ });
261
+ break;
262
+ case 'data-source-item':
263
+ if ((_g = node.content.nodes) === null || _g === void 0 ? void 0 : _g.success) {
264
+ (0, exports.traverseNodes)(node.content.nodes.success, fn);
265
+ }
266
+ if ((_h = node.content.nodes) === null || _h === void 0 ? void 0 : _h.error) {
267
+ (0, exports.traverseNodes)(node.content.nodes.error, fn);
268
+ }
269
+ if ((_j = node.content.nodes) === null || _j === void 0 ? void 0 : _j.loading) {
270
+ (0, exports.traverseNodes)(node.content.nodes.loading, fn);
271
+ }
272
+ if (node.content.children) {
273
+ node.content.children.forEach(function (child) {
274
+ (0, exports.traverseNodes)(child, fn, node);
275
+ });
276
+ }
277
+ break;
278
+ case 'data-source-list':
279
+ if ((_k = node.content.nodes) === null || _k === void 0 ? void 0 : _k.success) {
280
+ (0, exports.traverseNodes)(node.content.nodes.success, fn);
281
+ }
282
+ if ((_l = node.content.nodes) === null || _l === void 0 ? void 0 : _l.error) {
283
+ (0, exports.traverseNodes)(node.content.nodes.error, fn);
284
+ }
285
+ if ((_m = node.content.nodes) === null || _m === void 0 ? void 0 : _m.loading) {
286
+ (0, exports.traverseNodes)(node.content.nodes.loading, fn);
287
+ }
288
+ if (node.content.children) {
289
+ node.content.children.forEach(function (child) {
290
+ (0, exports.traverseNodes)(child, fn, node);
291
+ });
292
+ }
293
+ break;
212
294
  case 'repeat':
213
295
  (0, exports.traverseNodes)(node.content.node, fn, node);
214
296
  (0, exports.traverseNodes)(node.content.dataSource, fn, node);
@@ -236,8 +318,18 @@ var traverseNodes = function (node, fn, parent) {
236
318
  };
237
319
  exports.traverseNodes = traverseNodes;
238
320
  var traverseResources = function (node, fn) {
321
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
239
322
  switch (node.type) {
240
323
  case 'element':
324
+ // Check if this element node is wrapping a data-source node
325
+ if (node.content &&
326
+ typeof node.content === 'object' &&
327
+ 'type' in node.content &&
328
+ (node.content.type === 'data-source-item' || node.content.type === 'data-source-list')) {
329
+ // Treat the entire node.content as a data-source node
330
+ (0, exports.traverseResources)(node.content, fn);
331
+ break;
332
+ }
241
333
  var children = node.content.children;
242
334
  if (children) {
243
335
  children.forEach(function (child) {
@@ -259,6 +351,9 @@ var traverseResources = function (node, fn) {
259
351
  if (node.content.nodes.empty) {
260
352
  (0, exports.traverseResources)(node.content.nodes.empty, fn);
261
353
  }
354
+ if (node.content.nodes.loading) {
355
+ (0, exports.traverseResources)(node.content.nodes.loading, fn);
356
+ }
262
357
  break;
263
358
  case 'cms-item':
264
359
  (0, exports.traverseResources)(node.content.nodes.success, fn);
@@ -269,6 +364,39 @@ var traverseResources = function (node, fn) {
269
364
  (0, exports.traverseResources)(node.content.nodes.loading, fn);
270
365
  }
271
366
  break;
367
+ case 'cms-mixed-type':
368
+ if ((_a = node.content.nodes) === null || _a === void 0 ? void 0 : _a.fallback) {
369
+ (0, exports.traverseResources)(node.content.nodes.fallback, fn);
370
+ }
371
+ if ((_b = node.content.nodes) === null || _b === void 0 ? void 0 : _b.error) {
372
+ (0, exports.traverseResources)(node.content.nodes.error, fn);
373
+ }
374
+ Object.keys(((_c = node.content) === null || _c === void 0 ? void 0 : _c.mappings) || {}).forEach(function (key) {
375
+ (0, exports.traverseResources)(node.content.mappings[key], fn);
376
+ });
377
+ break;
378
+ case 'data-source-item':
379
+ if ((_d = node.content.nodes) === null || _d === void 0 ? void 0 : _d.success) {
380
+ (0, exports.traverseResources)(node.content.nodes.success, fn);
381
+ }
382
+ if ((_e = node.content.nodes) === null || _e === void 0 ? void 0 : _e.error) {
383
+ (0, exports.traverseResources)(node.content.nodes.error, fn);
384
+ }
385
+ if ((_f = node.content.nodes) === null || _f === void 0 ? void 0 : _f.loading) {
386
+ (0, exports.traverseResources)(node.content.nodes.loading, fn);
387
+ }
388
+ break;
389
+ case 'data-source-list':
390
+ if ((_g = node.content.nodes) === null || _g === void 0 ? void 0 : _g.success) {
391
+ (0, exports.traverseResources)(node.content.nodes.success, fn);
392
+ }
393
+ if ((_h = node.content.nodes) === null || _h === void 0 ? void 0 : _h.error) {
394
+ (0, exports.traverseResources)(node.content.nodes.error, fn);
395
+ }
396
+ if ((_j = node.content.nodes) === null || _j === void 0 ? void 0 : _j.loading) {
397
+ (0, exports.traverseResources)(node.content.nodes.loading, fn);
398
+ }
399
+ break;
272
400
  case 'repeat':
273
401
  (0, exports.traverseResources)(node.content.node, fn);
274
402
  break;
@@ -293,17 +421,38 @@ exports.traverseResources = traverseResources;
293
421
  var traverseStyleObject = function (style) {
294
422
  Object.keys(style).forEach(function (styleKey) {
295
423
  var styleValue = style[styleKey];
296
- // TODO: cross-check the support for the strings as content for styles
297
424
  if (styleValue.type !== 'static' && styleValue.type !== 'dynamic') {
298
- throw new Error("We support only 'static' and 'dynamic' content for styles");
425
+ throw new Error("We support only 'static' and 'dynamic' content for styles \n\n Received \n\n ".concat(JSON.stringify(styleValue, null, 2)));
299
426
  }
300
427
  });
301
428
  };
302
429
  // Parses a node structure recursively and applies a function to each UIDLElement instance
303
430
  var traverseElements = function (node, fn) {
431
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
432
+ if (!node || !node.type) {
433
+ return;
434
+ }
304
435
  switch (node.type) {
305
436
  case 'element':
437
+ // Check if this element node is wrapping a data-source node
438
+ if (node.content &&
439
+ typeof node.content === 'object' &&
440
+ 'type' in node.content &&
441
+ (node.content.type === 'data-source-item' || node.content.type === 'data-source-list')) {
442
+ // Treat the entire node.content as a data-source node
443
+ (0, exports.traverseElements)(node.content, fn);
444
+ break;
445
+ }
306
446
  fn(node.content);
447
+ if (node.content.attrs) {
448
+ for (var _i = 0, _k = Object.keys(node.content.attrs); _i < _k.length; _i++) {
449
+ var attrKey = _k[_i];
450
+ var attrValue = node.content.attrs[attrKey];
451
+ if (attrValue.type === 'element') {
452
+ (0, exports.traverseElements)(attrValue, fn);
453
+ }
454
+ }
455
+ }
307
456
  if (node.content.children) {
308
457
  node.content.children.forEach(function (child) {
309
458
  (0, exports.traverseElements)(child, fn);
@@ -318,12 +467,24 @@ var traverseElements = function (node, fn) {
318
467
  if (node.content.nodes.loading) {
319
468
  (0, exports.traverseElements)(node.content.nodes.loading, fn);
320
469
  }
470
+ if (node.content.attrs) {
471
+ for (var _l = 0, _m = Object.keys(node.content.attrs); _l < _m.length; _l++) {
472
+ var attrKey = _m[_l];
473
+ var attrValue = node.content.attrs[attrKey];
474
+ if (attrValue.type === 'element') {
475
+ (0, exports.traverseElements)(attrValue, fn);
476
+ }
477
+ }
478
+ }
321
479
  break;
322
480
  case 'cms-list-repeater':
323
481
  (0, exports.traverseElements)(node.content.nodes.list, fn);
324
482
  if (node.content.nodes.empty) {
325
483
  (0, exports.traverseElements)(node.content.nodes.empty, fn);
326
484
  }
485
+ if (node.content.nodes.loading) {
486
+ (0, exports.traverseElements)(node.content.nodes.loading, fn);
487
+ }
327
488
  break;
328
489
  case 'cms-item':
329
490
  (0, exports.traverseElements)(node.content.nodes.success, fn);
@@ -333,6 +494,75 @@ var traverseElements = function (node, fn) {
333
494
  if (node.content.nodes.loading) {
334
495
  (0, exports.traverseElements)(node.content.nodes.loading, fn);
335
496
  }
497
+ if (node.content.attrs) {
498
+ for (var _o = 0, _p = Object.keys(node.content.attrs); _o < _p.length; _o++) {
499
+ var attrKey = _p[_o];
500
+ var attrValue = node.content.attrs[attrKey];
501
+ if (attrValue.type === 'element') {
502
+ (0, exports.traverseElements)(attrValue, fn);
503
+ }
504
+ }
505
+ }
506
+ break;
507
+ case 'cms-mixed-type':
508
+ if ((_a = node.content.nodes) === null || _a === void 0 ? void 0 : _a.fallback) {
509
+ (0, exports.traverseElements)(node.content.nodes.fallback, fn);
510
+ }
511
+ if ((_b = node.content.nodes) === null || _b === void 0 ? void 0 : _b.error) {
512
+ (0, exports.traverseElements)(node.content.nodes.error, fn);
513
+ }
514
+ Object.keys(((_c = node.content) === null || _c === void 0 ? void 0 : _c.mappings) || {}).forEach(function (key) {
515
+ (0, exports.traverseElements)(node.content.mappings[key], fn);
516
+ });
517
+ if (node.content.attrs) {
518
+ for (var _q = 0, _r = Object.keys(node.content.attrs); _q < _r.length; _q++) {
519
+ var attrKey = _r[_q];
520
+ var attrValue = node.content.attrs[attrKey];
521
+ if (attrValue.type === 'element') {
522
+ (0, exports.traverseElements)(attrValue, fn);
523
+ }
524
+ }
525
+ }
526
+ break;
527
+ case 'data-source-item':
528
+ if ((_d = node.content.nodes) === null || _d === void 0 ? void 0 : _d.success) {
529
+ (0, exports.traverseElements)(node.content.nodes.success, fn);
530
+ }
531
+ if ((_e = node.content.nodes) === null || _e === void 0 ? void 0 : _e.error) {
532
+ (0, exports.traverseElements)(node.content.nodes.error, fn);
533
+ }
534
+ if ((_f = node.content.nodes) === null || _f === void 0 ? void 0 : _f.loading) {
535
+ (0, exports.traverseElements)(node.content.nodes.loading, fn);
536
+ }
537
+ if (node.content.attrs) {
538
+ for (var _s = 0, _t = Object.keys(node.content.attrs); _s < _t.length; _s++) {
539
+ var attrKey = _t[_s];
540
+ var attrValue = node.content.attrs[attrKey];
541
+ if (attrValue.type === 'element') {
542
+ (0, exports.traverseElements)(attrValue, fn);
543
+ }
544
+ }
545
+ }
546
+ break;
547
+ case 'data-source-list':
548
+ if ((_g = node.content.nodes) === null || _g === void 0 ? void 0 : _g.success) {
549
+ (0, exports.traverseElements)(node.content.nodes.success, fn);
550
+ }
551
+ if ((_h = node.content.nodes) === null || _h === void 0 ? void 0 : _h.error) {
552
+ (0, exports.traverseElements)(node.content.nodes.error, fn);
553
+ }
554
+ if ((_j = node.content.nodes) === null || _j === void 0 ? void 0 : _j.loading) {
555
+ (0, exports.traverseElements)(node.content.nodes.loading, fn);
556
+ }
557
+ if (node.content.attrs) {
558
+ for (var _u = 0, _v = Object.keys(node.content.attrs); _u < _v.length; _u++) {
559
+ var attrKey = _v[_u];
560
+ var attrValue = node.content.attrs[attrKey];
561
+ if (attrValue.type === 'element') {
562
+ (0, exports.traverseElements)(attrValue, fn);
563
+ }
564
+ }
565
+ }
336
566
  break;
337
567
  case 'repeat':
338
568
  (0, exports.traverseElements)(node.content.node, fn);
@@ -352,13 +582,35 @@ var traverseElements = function (node, fn) {
352
582
  case 'expr':
353
583
  break;
354
584
  default:
355
- throw new Error("traverseElements was given an unsupported node type : ".concat(node.type, ", ").concat(JSON.stringify(node, null, 2)));
585
+ throw new Error("traverseElements was given an unsupported node type : \n ".concat(JSON.stringify(node, null, 2)));
356
586
  }
357
587
  };
358
588
  exports.traverseElements = traverseElements;
359
589
  var traverseRepeats = function (node, fn) {
590
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
591
+ if (!node || !node.type) {
592
+ return;
593
+ }
360
594
  switch (node.type) {
361
595
  case 'element':
596
+ // Check if this element node is wrapping a data-source node
597
+ if (node.content &&
598
+ typeof node.content === 'object' &&
599
+ 'type' in node.content &&
600
+ (node.content.type === 'data-source-item' || node.content.type === 'data-source-list')) {
601
+ // Treat the entire node.content as a data-source node
602
+ (0, exports.traverseRepeats)(node.content, fn);
603
+ break;
604
+ }
605
+ if (node.content.attrs) {
606
+ for (var _i = 0, _k = Object.keys(node.content.attrs); _i < _k.length; _i++) {
607
+ var attrKey = _k[_i];
608
+ var attrValue = node.content.attrs[attrKey];
609
+ if (attrValue.type === 'element') {
610
+ (0, exports.traverseRepeats)(attrValue, fn);
611
+ }
612
+ }
613
+ }
362
614
  if (node.content.children) {
363
615
  node.content.children.forEach(function (child) {
364
616
  (0, exports.traverseRepeats)(child, fn);
@@ -373,12 +625,24 @@ var traverseRepeats = function (node, fn) {
373
625
  if (node.content.nodes.loading) {
374
626
  (0, exports.traverseRepeats)(node.content.nodes.loading, fn);
375
627
  }
628
+ if (node.content.attrs) {
629
+ for (var _l = 0, _m = Object.keys(node.content.attrs); _l < _m.length; _l++) {
630
+ var attrKey = _m[_l];
631
+ var attrValue = node.content.attrs[attrKey];
632
+ if (attrValue.type === 'element') {
633
+ (0, exports.traverseRepeats)(attrValue, fn);
634
+ }
635
+ }
636
+ }
376
637
  break;
377
638
  case 'cms-list-repeater':
378
639
  (0, exports.traverseRepeats)(node.content.nodes.list, fn);
379
640
  if (node.content.nodes.empty) {
380
641
  (0, exports.traverseRepeats)(node.content.nodes.empty, fn);
381
642
  }
643
+ if (node.content.nodes.loading) {
644
+ (0, exports.traverseRepeats)(node.content.nodes.loading, fn);
645
+ }
382
646
  break;
383
647
  case 'cms-item':
384
648
  (0, exports.traverseRepeats)(node.content.nodes.success, fn);
@@ -388,6 +652,35 @@ var traverseRepeats = function (node, fn) {
388
652
  if (node.content.nodes.loading) {
389
653
  (0, exports.traverseRepeats)(node.content.nodes.loading, fn);
390
654
  }
655
+ if (node.content.attrs) {
656
+ for (var _o = 0, _p = Object.keys(node.content.attrs); _o < _p.length; _o++) {
657
+ var attrKey = _p[_o];
658
+ var attrValue = node.content.attrs[attrKey];
659
+ if (attrValue.type === 'element') {
660
+ (0, exports.traverseRepeats)(attrValue, fn);
661
+ }
662
+ }
663
+ }
664
+ break;
665
+ case 'cms-mixed-type':
666
+ if ((_a = node.content.nodes) === null || _a === void 0 ? void 0 : _a.fallback) {
667
+ (0, exports.traverseRepeats)(node.content.nodes.fallback, fn);
668
+ }
669
+ if ((_b = node.content.nodes) === null || _b === void 0 ? void 0 : _b.error) {
670
+ (0, exports.traverseRepeats)(node.content.nodes.error, fn);
671
+ }
672
+ Object.keys(((_c = node.content) === null || _c === void 0 ? void 0 : _c.mappings) || {}).forEach(function (key) {
673
+ (0, exports.traverseRepeats)(node.content.mappings[key], fn);
674
+ });
675
+ if (node.content.attrs) {
676
+ for (var _q = 0, _r = Object.keys(node.content.attrs); _q < _r.length; _q++) {
677
+ var attrKey = _r[_q];
678
+ var attrValue = node.content.attrs[attrKey];
679
+ if (attrValue.type === 'element') {
680
+ (0, exports.traverseRepeats)(attrValue, fn);
681
+ }
682
+ }
683
+ }
391
684
  break;
392
685
  case 'repeat':
393
686
  fn(node.content);
@@ -401,6 +694,28 @@ var traverseRepeats = function (node, fn) {
401
694
  (0, exports.traverseRepeats)(node.content.fallback, fn);
402
695
  }
403
696
  break;
697
+ case 'data-source-item':
698
+ if ((_d = node.content.nodes) === null || _d === void 0 ? void 0 : _d.success) {
699
+ (0, exports.traverseRepeats)(node.content.nodes.success, fn);
700
+ }
701
+ if ((_e = node.content.nodes) === null || _e === void 0 ? void 0 : _e.error) {
702
+ (0, exports.traverseRepeats)(node.content.nodes.error, fn);
703
+ }
704
+ if ((_f = node.content.nodes) === null || _f === void 0 ? void 0 : _f.loading) {
705
+ (0, exports.traverseRepeats)(node.content.nodes.loading, fn);
706
+ }
707
+ break;
708
+ case 'data-source-list':
709
+ if ((_g = node.content.nodes) === null || _g === void 0 ? void 0 : _g.success) {
710
+ (0, exports.traverseRepeats)(node.content.nodes.success, fn);
711
+ }
712
+ if ((_h = node.content.nodes) === null || _h === void 0 ? void 0 : _h.error) {
713
+ (0, exports.traverseRepeats)(node.content.nodes.error, fn);
714
+ }
715
+ if ((_j = node.content.nodes) === null || _j === void 0 ? void 0 : _j.loading) {
716
+ (0, exports.traverseRepeats)(node.content.nodes.loading, fn);
717
+ }
718
+ break;
404
719
  case 'static':
405
720
  case 'dynamic':
406
721
  case 'raw':
@@ -526,11 +841,11 @@ var transformStylesAssignmentsToJson = function (styleObject) {
526
841
  acc[key] = styleContentAtKey;
527
842
  return acc;
528
843
  }
529
- if (type === 'dynamic') {
844
+ if (type === 'dynamic' && content.referenceType !== 'global') {
530
845
  if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) {
531
846
  acc[key] = {
532
847
  type: type,
533
- content: __assign(__assign({}, content), { id: __1.StringUtils.createStateOrPropStoringValue(content.id) }),
848
+ content: __assign(__assign({}, content), { id: (0, exports.generateIdWithRefPath)(content.id, content.refPath) }),
534
849
  };
535
850
  }
536
851
  else {
@@ -544,6 +859,21 @@ var transformStylesAssignmentsToJson = function (styleObject) {
544
859
  return newStyleObject;
545
860
  };
546
861
  exports.transformStylesAssignmentsToJson = transformStylesAssignmentsToJson;
862
+ var generateIdWithRefPath = function (contentId, refPath) {
863
+ var processedId = contentId;
864
+ if (refPath) {
865
+ var processedRefPath = refPath.reduce(function (acc, path) {
866
+ return "".concat(acc, "?.['").concat(path, "']");
867
+ }, '');
868
+ // This is a bit ugly, but in some cases props are parsed twice or already generated.
869
+ // To avoid possible bugs, this should be a good safety measure
870
+ if (!processedId.includes(processedRefPath)) {
871
+ processedId = "".concat(processedId).concat(processedRefPath);
872
+ }
873
+ }
874
+ return __1.StringUtils.createStateOrPropStoringValue(processedId);
875
+ };
876
+ exports.generateIdWithRefPath = generateIdWithRefPath;
547
877
  /*
548
878
  All the props passed to the components are transformed to a unique case
549
879
  to minimize the collision of using cameCalse in one place and dashCase in
@@ -562,34 +892,47 @@ var transformAttributesAssignmentsToJson = function (attributesObject, isLocalCo
562
892
  return acc;
563
893
  }
564
894
  if (!Array.isArray(attributeContent) && entityType === 'object') {
565
- // if this value is already properly declared, make sure it is not
566
895
  var type = attributeContent.type;
567
- if (['static', 'import', 'raw', 'expr'].indexOf(type) !== -1) {
568
- var propKey = isLocalComponent ? __1.StringUtils.createStateOrPropStoringValue(key) : key;
569
- acc[propKey] = attributeContent;
570
- return acc;
571
- }
572
- if (type === 'comp-style') {
573
- acc[key] = {
574
- type: 'comp-style',
575
- content: __1.StringUtils.createStateOrPropStoringValue(attributeContent.content),
576
- };
577
- return acc;
578
- }
579
- var content = attributeContent.content;
580
- if (type === 'dynamic') {
581
- if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) {
896
+ switch (type) {
897
+ case 'import':
898
+ case 'static':
899
+ case 'raw':
900
+ case 'expr': {
901
+ var propKey = isLocalComponent ? __1.StringUtils.createStateOrPropStoringValue(key) : key;
902
+ acc[propKey] = attributeContent;
903
+ return acc;
904
+ }
905
+ case 'comp-style': {
582
906
  acc[key] = {
583
- type: type,
584
- content: __assign(__assign({}, content), { id: __1.StringUtils.createStateOrPropStoringValue(content.id) }),
907
+ type: 'comp-style',
908
+ content: __1.StringUtils.createStateOrPropStoringValue(attributeContent.content),
585
909
  };
910
+ return acc;
586
911
  }
587
- else {
912
+ case 'dynamic': {
913
+ var content = attributeContent.content;
914
+ // global id's dont need to be transformed. As they are constants and each one is handled by the generator
915
+ // depending on the context and the framework.
916
+ if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType) &&
917
+ content.referenceType !== 'global') {
918
+ acc[key] = {
919
+ type: type,
920
+ content: __assign(__assign({}, content), { id: (0, exports.generateIdWithRefPath)(content.id, content.refPath) }),
921
+ };
922
+ }
923
+ else {
924
+ acc[key] = attributeContent;
925
+ }
926
+ return acc;
927
+ }
928
+ case 'object':
929
+ case 'element':
588
930
  acc[key] = attributeContent;
931
+ return acc;
932
+ default: {
933
+ throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2)));
589
934
  }
590
- return acc;
591
935
  }
592
- throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2)));
593
936
  }
594
937
  }, newAttrObject);
595
938
  return newAttrObject;
@@ -613,6 +956,7 @@ var findFirstElementNode = function (node) {
613
956
  };
614
957
  exports.findFirstElementNode = findFirstElementNode;
615
958
  var removeChildNodes = function (node, criteria) {
959
+ var _a, _b, _c;
616
960
  switch (node.type) {
617
961
  case 'element':
618
962
  if (node.content.children) {
@@ -639,6 +983,9 @@ var removeChildNodes = function (node, criteria) {
639
983
  if (node.content.nodes.empty) {
640
984
  (0, exports.removeChildNodes)(node.content.nodes.empty, criteria);
641
985
  }
986
+ if (node.content.nodes.loading) {
987
+ (0, exports.removeChildNodes)(node.content.nodes.loading, criteria);
988
+ }
642
989
  break;
643
990
  case 'cms-item':
644
991
  (0, exports.removeChildNodes)(node.content.nodes.success, criteria);
@@ -649,6 +996,17 @@ var removeChildNodes = function (node, criteria) {
649
996
  (0, exports.removeChildNodes)(node.content.nodes.loading, criteria);
650
997
  }
651
998
  break;
999
+ case 'cms-mixed-type':
1000
+ if ((_a = node.content.nodes) === null || _a === void 0 ? void 0 : _a.fallback) {
1001
+ (0, exports.removeChildNodes)(node.content.nodes.fallback, criteria);
1002
+ }
1003
+ if ((_b = node.content.nodes) === null || _b === void 0 ? void 0 : _b.error) {
1004
+ (0, exports.removeChildNodes)(node.content.nodes.error, criteria);
1005
+ }
1006
+ Object.keys(((_c = node.content) === null || _c === void 0 ? void 0 : _c.mappings) || {}).forEach(function (key) {
1007
+ (0, exports.removeChildNodes)(node.content.mappings[key], criteria);
1008
+ });
1009
+ break;
652
1010
  case 'conditional':
653
1011
  (0, exports.removeChildNodes)(node.content.node, criteria);
654
1012
  break;