@uniformdev/transformer 1.1.6 → 1.1.8
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.
- package/dist/cli/index.js +26 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -352,6 +352,16 @@ var ComponentService = class {
|
|
|
352
352
|
component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));
|
|
353
353
|
return component;
|
|
354
354
|
}
|
|
355
|
+
generateGroupId(name) {
|
|
356
|
+
const words = name.replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).filter((w) => w.length > 0);
|
|
357
|
+
if (words.length === 0) {
|
|
358
|
+
return "group_";
|
|
359
|
+
}
|
|
360
|
+
const camel = words.map(
|
|
361
|
+
(w, i) => i === 0 ? w.toLowerCase() : w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()
|
|
362
|
+
).join("");
|
|
363
|
+
return `group_${camel}`;
|
|
364
|
+
}
|
|
355
365
|
};
|
|
356
366
|
|
|
357
367
|
// src/core/services/composition.service.ts
|
|
@@ -590,17 +600,18 @@ var PropertyPropagatorService = class {
|
|
|
590
600
|
}
|
|
591
601
|
let modifiedComponent = { ...targetComponent };
|
|
592
602
|
let componentModified = false;
|
|
603
|
+
const groupId = this.componentService.generateGroupId(targetGroup);
|
|
593
604
|
const existingGroup = this.componentService.findParameter(
|
|
594
605
|
modifiedComponent,
|
|
595
|
-
|
|
606
|
+
groupId,
|
|
596
607
|
findOptions
|
|
597
608
|
);
|
|
598
609
|
if (!existingGroup) {
|
|
599
610
|
this.logger.action(whatIf, "CREATE", `Group "${targetGroup}" on ${targetComponentType}`);
|
|
600
611
|
modifiedComponent = this.componentService.ensureGroupExists(
|
|
601
612
|
modifiedComponent,
|
|
613
|
+
groupId,
|
|
602
614
|
targetGroup,
|
|
603
|
-
void 0,
|
|
604
615
|
findOptions
|
|
605
616
|
);
|
|
606
617
|
componentModified = true;
|
|
@@ -624,7 +635,7 @@ var PropertyPropagatorService = class {
|
|
|
624
635
|
);
|
|
625
636
|
modifiedComponent = this.componentService.addParameterToGroup(
|
|
626
637
|
modifiedComponent,
|
|
627
|
-
|
|
638
|
+
groupId,
|
|
628
639
|
param.id,
|
|
629
640
|
findOptions
|
|
630
641
|
);
|
|
@@ -633,7 +644,7 @@ var PropertyPropagatorService = class {
|
|
|
633
644
|
this.logger.info(`Parameter "${param.id}" already exists on ${targetComponentType}`);
|
|
634
645
|
const group = this.componentService.findParameter(
|
|
635
646
|
modifiedComponent,
|
|
636
|
-
|
|
647
|
+
groupId,
|
|
637
648
|
findOptions
|
|
638
649
|
);
|
|
639
650
|
if (group && this.componentService.isGroupParameter(group)) {
|
|
@@ -643,7 +654,7 @@ var PropertyPropagatorService = class {
|
|
|
643
654
|
if (!isInGroup) {
|
|
644
655
|
modifiedComponent = this.componentService.addParameterToGroup(
|
|
645
656
|
modifiedComponent,
|
|
646
|
-
|
|
657
|
+
groupId,
|
|
647
658
|
param.id,
|
|
648
659
|
findOptions
|
|
649
660
|
);
|
|
@@ -1087,8 +1098,7 @@ var PatternAnalyzerService = class {
|
|
|
1087
1098
|
const sortedSlotNames = Object.keys(slots).sort();
|
|
1088
1099
|
for (const slotName of sortedSlotNames) {
|
|
1089
1100
|
const instances = slots[slotName];
|
|
1090
|
-
if (!Array.isArray(instances)) {
|
|
1091
|
-
node.slots.set(slotName, []);
|
|
1101
|
+
if (!Array.isArray(instances) || instances.length === 0) {
|
|
1092
1102
|
continue;
|
|
1093
1103
|
}
|
|
1094
1104
|
const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;
|
|
@@ -1244,17 +1254,21 @@ var PatternAnalyzerService = class {
|
|
|
1244
1254
|
return type;
|
|
1245
1255
|
}
|
|
1246
1256
|
const sortedSlotNames = Object.keys(slots).sort();
|
|
1247
|
-
const slotFingerprints =
|
|
1257
|
+
const slotFingerprints = [];
|
|
1258
|
+
for (const slotName of sortedSlotNames) {
|
|
1248
1259
|
const instances = slots[slotName];
|
|
1249
1260
|
if (!Array.isArray(instances) || instances.length === 0) {
|
|
1250
|
-
|
|
1261
|
+
continue;
|
|
1251
1262
|
}
|
|
1252
1263
|
const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;
|
|
1253
1264
|
const instanceFingerprints = instances.map(
|
|
1254
1265
|
(instance) => this.generateNodeFingerprint(instance.type, instance.slots, nextDepth)
|
|
1255
1266
|
);
|
|
1256
|
-
|
|
1257
|
-
}
|
|
1267
|
+
slotFingerprints.push(`${slotName}:[${instanceFingerprints.join(",")}]`);
|
|
1268
|
+
}
|
|
1269
|
+
if (slotFingerprints.length === 0) {
|
|
1270
|
+
return type;
|
|
1271
|
+
}
|
|
1258
1272
|
return `${type}{${slotFingerprints.join(";")}}`;
|
|
1259
1273
|
}
|
|
1260
1274
|
/**
|
|
@@ -3364,7 +3378,7 @@ function createPropagateRootComponentSlotCommand() {
|
|
|
3364
3378
|
// package.json
|
|
3365
3379
|
var package_default = {
|
|
3366
3380
|
name: "@uniformdev/transformer",
|
|
3367
|
-
version: "1.1.
|
|
3381
|
+
version: "1.1.8",
|
|
3368
3382
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
3369
3383
|
type: "module",
|
|
3370
3384
|
bin: {
|