@uniformdev/transformer 1.0.0 → 1.1.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.
package/dist/index.d.ts CHANGED
@@ -109,6 +109,25 @@ interface RenameSlotOptions extends GlobalOptions {
109
109
  newSlotId: string;
110
110
  newSlotName?: string;
111
111
  }
112
+ interface AddComponentOptions extends GlobalOptions {
113
+ parentComponentType: string;
114
+ slot: string;
115
+ newComponentType: string;
116
+ parameters?: string;
117
+ }
118
+ interface AddComponentPatternOptions extends GlobalOptions {
119
+ parentComponentType: string;
120
+ slot: string;
121
+ componentPatternId: string;
122
+ parameters?: string;
123
+ }
124
+ interface PropagateRootComponentSlotOptions extends GlobalOptions {
125
+ compositionType: string;
126
+ slot: string;
127
+ targetComponentType: string;
128
+ targetSlot: string;
129
+ deleteSourceSlot?: boolean;
130
+ }
112
131
 
113
132
  declare class TransformError extends Error {
114
133
  constructor(message: string);
@@ -179,6 +198,10 @@ declare class ComponentService {
179
198
  addParameterToGroup(component: ComponentDefinition, groupId: string, parameterId: string, options?: FindOptions$1): ComponentDefinition;
180
199
  removeParameter(component: ComponentDefinition, parameterId: string, options?: FindOptions$1): ComponentDefinition;
181
200
  removeEmptyGroups(component: ComponentDefinition): ComponentDefinition;
201
+ findSlot(component: ComponentDefinition, slotId: string, options?: FindOptions$1): SlotDefinition | undefined;
202
+ addSlot(component: ComponentDefinition, slot: SlotDefinition): ComponentDefinition;
203
+ updateSlotAllowedComponents(component: ComponentDefinition, slotId: string, allowedComponents: string[], options?: FindOptions$1): ComponentDefinition;
204
+ removeSlot(component: ComponentDefinition, slotId: string, options?: FindOptions$1): ComponentDefinition;
182
205
  }
183
206
 
184
207
  interface FindOptions {
@@ -317,4 +340,44 @@ declare class ComponentRenamerService {
317
340
  private renameTypeInTree;
318
341
  }
319
342
 
320
- export { ComponentAlreadyExistsError, type ComponentDefinition, type ComponentInstance, ComponentNotFoundError, ComponentRenamerService, ComponentService, type Composition, type CompositionOverrides, type CompositionPatternCandidatesOptions, type CompositionRoot, CompositionService, DuplicateIdError, FileNotFoundError, FileSystemService, type GlobalOptions, InvalidYamlError, Logger, type PackSerializationOptions, type Parameter, type ParameterValue, type PropagateRootComponentPropertyOptions, PropertyNotFoundError, PropertyPropagatorService, type RenameComponentOptions, type RenameSlotOptions, SlotAlreadyExistsError, type SlotDefinition, SlotNotFoundError, SlotRenamerService, TransformError, type UnpackSerializationOptions };
343
+ interface AddComponentInternalOptions {
344
+ rootDir: string;
345
+ componentsDir: string;
346
+ compositionsDir: string;
347
+ compositionPatternsDir: string;
348
+ componentPatternsDir: string;
349
+ parentComponentType: string;
350
+ slot: string;
351
+ newComponentType?: string;
352
+ componentPatternId?: string;
353
+ parameters?: string;
354
+ whatIf: boolean;
355
+ strict: boolean;
356
+ }
357
+ interface AddComponentResult {
358
+ allowedComponentsUpdated: boolean;
359
+ compositionsModified: number;
360
+ compositionPatternsModified: number;
361
+ componentPatternsModified: number;
362
+ instancesAdded: number;
363
+ }
364
+ declare class ComponentAdderService {
365
+ private fileSystem;
366
+ private componentService;
367
+ private logger;
368
+ constructor(fileSystem: FileSystemService, componentService: ComponentService, logger: Logger);
369
+ private compareIds;
370
+ private parseParameters;
371
+ private generateId;
372
+ private cloneComponentInstance;
373
+ private regenerateInstanceIds;
374
+ private createComponentInstance;
375
+ private addComponentToSlot;
376
+ addComponent(options: AddComponentInternalOptions): Promise<AddComponentResult>;
377
+ addComponentPattern(options: AddComponentInternalOptions): Promise<AddComponentResult>;
378
+ private loadComponentPattern;
379
+ private addComponentToDirectory;
380
+ private addComponentToNestedSlots;
381
+ }
382
+
383
+ export { type AddComponentOptions, type AddComponentPatternOptions, ComponentAdderService, ComponentAlreadyExistsError, type ComponentDefinition, type ComponentInstance, ComponentNotFoundError, ComponentRenamerService, ComponentService, type Composition, type CompositionOverrides, type CompositionPatternCandidatesOptions, type CompositionRoot, CompositionService, DuplicateIdError, FileNotFoundError, FileSystemService, type GlobalOptions, InvalidYamlError, Logger, type PackSerializationOptions, type Parameter, type ParameterValue, type PropagateRootComponentPropertyOptions, type PropagateRootComponentSlotOptions, PropertyNotFoundError, PropertyPropagatorService, type RenameComponentOptions, type RenameSlotOptions, SlotAlreadyExistsError, type SlotDefinition, SlotNotFoundError, SlotRenamerService, TransformError, type UnpackSerializationOptions };
package/dist/index.js CHANGED
@@ -314,6 +314,34 @@ var ComponentService = class {
314
314
  });
315
315
  return component;
316
316
  }
317
+ // Slot methods
318
+ findSlot(component, slotId, options = {}) {
319
+ const { strict = false } = options;
320
+ return component.slots?.find((s) => this.compareIds(s.id, slotId, strict));
321
+ }
322
+ addSlot(component, slot) {
323
+ if (!component.slots) {
324
+ component.slots = [];
325
+ }
326
+ component.slots.push({ ...slot });
327
+ return component;
328
+ }
329
+ updateSlotAllowedComponents(component, slotId, allowedComponents, options = {}) {
330
+ const { strict = false } = options;
331
+ const slot = component.slots?.find((s) => this.compareIds(s.id, slotId, strict));
332
+ if (slot) {
333
+ slot.allowedComponents = allowedComponents;
334
+ }
335
+ return component;
336
+ }
337
+ removeSlot(component, slotId, options = {}) {
338
+ const { strict = false } = options;
339
+ if (!component.slots) {
340
+ return component;
341
+ }
342
+ component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));
343
+ return component;
344
+ }
317
345
  };
318
346
 
319
347
  // src/core/services/composition.service.ts
@@ -1072,6 +1100,439 @@ var ComponentRenamerService = class {
1072
1100
  }
1073
1101
  };
1074
1102
 
1103
+ // src/core/services/component-adder.service.ts
1104
+ import { randomUUID } from "crypto";
1105
+ var ComponentAdderService = class {
1106
+ constructor(fileSystem, componentService, logger) {
1107
+ this.fileSystem = fileSystem;
1108
+ this.componentService = componentService;
1109
+ this.logger = logger;
1110
+ }
1111
+ compareIds(id1, id2, strict) {
1112
+ if (strict) {
1113
+ return id1 === id2;
1114
+ }
1115
+ return id1.toLowerCase() === id2.toLowerCase();
1116
+ }
1117
+ parseParameters(parameterString) {
1118
+ const result = {};
1119
+ if (!parameterString) return result;
1120
+ const pairs = parameterString.split("|");
1121
+ for (const pair of pairs) {
1122
+ const [key, ...valueParts] = pair.split(":");
1123
+ if (key && valueParts.length > 0) {
1124
+ result[key.trim()] = valueParts.join(":").trim();
1125
+ }
1126
+ }
1127
+ return result;
1128
+ }
1129
+ generateId(baseName) {
1130
+ return `${baseName}-${randomUUID().slice(0, 8)}`;
1131
+ }
1132
+ cloneComponentInstance(instance) {
1133
+ const clone = JSON.parse(JSON.stringify(instance));
1134
+ if (clone._id) {
1135
+ clone._id = this.generateId(clone.type);
1136
+ }
1137
+ if (clone.slots) {
1138
+ for (const slotInstances of Object.values(clone.slots)) {
1139
+ if (Array.isArray(slotInstances)) {
1140
+ for (const nestedInstance of slotInstances) {
1141
+ this.regenerateInstanceIds(nestedInstance);
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ return clone;
1147
+ }
1148
+ regenerateInstanceIds(instance) {
1149
+ if (instance._id) {
1150
+ instance._id = this.generateId(instance.type);
1151
+ }
1152
+ if (instance.slots) {
1153
+ for (const slotInstances of Object.values(instance.slots)) {
1154
+ if (Array.isArray(slotInstances)) {
1155
+ for (const nestedInstance of slotInstances) {
1156
+ this.regenerateInstanceIds(nestedInstance);
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ }
1162
+ createComponentInstance(componentType, parameters) {
1163
+ const instance = {
1164
+ type: componentType,
1165
+ _id: this.generateId(componentType)
1166
+ };
1167
+ if (Object.keys(parameters).length > 0) {
1168
+ instance.parameters = {};
1169
+ for (const [key, value] of Object.entries(parameters)) {
1170
+ instance.parameters[key] = {
1171
+ type: "text",
1172
+ value
1173
+ };
1174
+ }
1175
+ }
1176
+ return instance;
1177
+ }
1178
+ addComponentToSlot(slots, slotId, instance) {
1179
+ if (!slots[slotId]) {
1180
+ slots[slotId] = [];
1181
+ }
1182
+ slots[slotId].push(instance);
1183
+ }
1184
+ async addComponent(options) {
1185
+ const {
1186
+ rootDir,
1187
+ componentsDir,
1188
+ compositionsDir,
1189
+ compositionPatternsDir,
1190
+ componentPatternsDir,
1191
+ parentComponentType,
1192
+ slot,
1193
+ newComponentType,
1194
+ parameters: paramString,
1195
+ whatIf,
1196
+ strict
1197
+ } = options;
1198
+ if (!newComponentType) {
1199
+ throw new TransformError("newComponentType is required for add-component");
1200
+ }
1201
+ const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);
1202
+ const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);
1203
+ const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);
1204
+ const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);
1205
+ const findOptions = { strict };
1206
+ this.logger.info(`Loading parent component: ${parentComponentType}`);
1207
+ const { component: parentComponent, filePath: parentComponentFilePath } = await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);
1208
+ const slotDef = parentComponent.slots?.find(
1209
+ (s) => this.compareIds(s.id, slot, strict)
1210
+ );
1211
+ if (!slotDef) {
1212
+ throw new SlotNotFoundError(slot, parentComponentType);
1213
+ }
1214
+ this.logger.info(`Validating new component: ${newComponentType}`);
1215
+ try {
1216
+ await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);
1217
+ } catch (error) {
1218
+ if (error instanceof ComponentNotFoundError) {
1219
+ throw new TransformError(
1220
+ `Component type "${newComponentType}" not found in ${fullComponentsDir}`
1221
+ );
1222
+ }
1223
+ throw error;
1224
+ }
1225
+ let allowedComponentsUpdated = false;
1226
+ const slotIndex = parentComponent.slots?.findIndex(
1227
+ (s) => this.compareIds(s.id, slotDef.id, strict)
1228
+ );
1229
+ if (slotIndex !== void 0 && slotIndex >= 0) {
1230
+ const actualSlot = parentComponent.slots[slotIndex];
1231
+ if (!actualSlot.allowedComponents) {
1232
+ actualSlot.allowedComponents = [];
1233
+ }
1234
+ const isAlreadyAllowed = actualSlot.allowedComponents.some(
1235
+ (c) => this.compareIds(c, newComponentType, strict)
1236
+ );
1237
+ if (!isAlreadyAllowed) {
1238
+ this.logger.action(
1239
+ whatIf,
1240
+ "UPDATE",
1241
+ `Adding "${newComponentType}" to allowedComponents for slot "${slot}" on component "${parentComponentType}"`
1242
+ );
1243
+ actualSlot.allowedComponents.push(newComponentType);
1244
+ if (!whatIf) {
1245
+ await this.componentService.saveComponent(parentComponentFilePath, parentComponent);
1246
+ }
1247
+ allowedComponentsUpdated = true;
1248
+ }
1249
+ }
1250
+ const parsedParams = this.parseParameters(paramString);
1251
+ const newInstance = this.createComponentInstance(newComponentType, parsedParams);
1252
+ const compositionsResult = await this.addComponentToDirectory(
1253
+ fullCompositionsDir,
1254
+ parentComponentType,
1255
+ slot,
1256
+ newInstance,
1257
+ whatIf,
1258
+ strict,
1259
+ "composition"
1260
+ );
1261
+ const compositionPatternsResult = await this.addComponentToDirectory(
1262
+ fullCompositionPatternsDir,
1263
+ parentComponentType,
1264
+ slot,
1265
+ newInstance,
1266
+ whatIf,
1267
+ strict,
1268
+ "compositionPattern"
1269
+ );
1270
+ const componentPatternsResult = await this.addComponentToDirectory(
1271
+ fullComponentPatternsDir,
1272
+ parentComponentType,
1273
+ slot,
1274
+ newInstance,
1275
+ whatIf,
1276
+ strict,
1277
+ "componentPattern"
1278
+ );
1279
+ this.logger.info("");
1280
+ this.logger.info(
1281
+ `Summary: ${allowedComponentsUpdated ? "1 component definition updated, " : ""}${compositionsResult} composition(s), ${compositionPatternsResult} composition pattern(s), ${componentPatternsResult} component pattern(s) updated. ${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`
1282
+ );
1283
+ return {
1284
+ allowedComponentsUpdated,
1285
+ compositionsModified: compositionsResult,
1286
+ compositionPatternsModified: compositionPatternsResult,
1287
+ componentPatternsModified: componentPatternsResult,
1288
+ instancesAdded: compositionsResult + compositionPatternsResult + componentPatternsResult
1289
+ };
1290
+ }
1291
+ async addComponentPattern(options) {
1292
+ const {
1293
+ rootDir,
1294
+ componentsDir,
1295
+ compositionsDir,
1296
+ compositionPatternsDir,
1297
+ componentPatternsDir,
1298
+ parentComponentType,
1299
+ slot,
1300
+ componentPatternId,
1301
+ whatIf,
1302
+ strict
1303
+ } = options;
1304
+ if (!componentPatternId) {
1305
+ throw new TransformError("componentPatternId is required for add-component-pattern");
1306
+ }
1307
+ const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);
1308
+ const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);
1309
+ const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);
1310
+ const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);
1311
+ const findOptions = { strict };
1312
+ this.logger.info(`Loading parent component: ${parentComponentType}`);
1313
+ const { component: parentComponent } = await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);
1314
+ const slotDef = parentComponent.slots?.find(
1315
+ (s) => this.compareIds(s.id, slot, strict)
1316
+ );
1317
+ if (!slotDef) {
1318
+ throw new SlotNotFoundError(slot, parentComponentType);
1319
+ }
1320
+ this.logger.info(`Loading component pattern: ${componentPatternId}`);
1321
+ const pattern = await this.loadComponentPattern(
1322
+ fullComponentPatternsDir,
1323
+ componentPatternId,
1324
+ strict
1325
+ );
1326
+ const patternDefinition = pattern.definition;
1327
+ if (!patternDefinition || !patternDefinition.type) {
1328
+ throw new TransformError(
1329
+ `Component pattern "${componentPatternId}" has no valid definition or missing type`
1330
+ );
1331
+ }
1332
+ let allowedComponentsUpdated = false;
1333
+ const componentTypeInPattern = patternDefinition.type;
1334
+ const slotIndex = parentComponent.slots?.findIndex(
1335
+ (s) => this.compareIds(s.id, slotDef.id, strict)
1336
+ );
1337
+ if (slotIndex !== void 0 && slotIndex >= 0) {
1338
+ const actualSlot = parentComponent.slots[slotIndex];
1339
+ if (!actualSlot.allowedComponents) {
1340
+ actualSlot.allowedComponents = [];
1341
+ }
1342
+ const isAlreadyAllowed = actualSlot.allowedComponents.some(
1343
+ (c) => this.compareIds(c, componentTypeInPattern, strict)
1344
+ );
1345
+ if (!isAlreadyAllowed) {
1346
+ this.logger.action(
1347
+ whatIf,
1348
+ "UPDATE",
1349
+ `Adding "${componentTypeInPattern}" to allowedComponents for slot "${slot}" on component "${parentComponentType}"`
1350
+ );
1351
+ actualSlot.allowedComponents.push(componentTypeInPattern);
1352
+ if (!whatIf) {
1353
+ await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions).then(
1354
+ ({ filePath }) => this.componentService.saveComponent(filePath, parentComponent)
1355
+ );
1356
+ }
1357
+ allowedComponentsUpdated = true;
1358
+ }
1359
+ }
1360
+ const newInstance = this.cloneComponentInstance(patternDefinition);
1361
+ const compositionsResult = await this.addComponentToDirectory(
1362
+ fullCompositionsDir,
1363
+ parentComponentType,
1364
+ slot,
1365
+ newInstance,
1366
+ whatIf,
1367
+ strict,
1368
+ "composition"
1369
+ );
1370
+ const compositionPatternsResult = await this.addComponentToDirectory(
1371
+ fullCompositionPatternsDir,
1372
+ parentComponentType,
1373
+ slot,
1374
+ newInstance,
1375
+ whatIf,
1376
+ strict,
1377
+ "compositionPattern"
1378
+ );
1379
+ const componentPatternsResult = await this.addComponentToDirectory(
1380
+ fullComponentPatternsDir,
1381
+ parentComponentType,
1382
+ slot,
1383
+ newInstance,
1384
+ whatIf,
1385
+ strict,
1386
+ "componentPattern"
1387
+ );
1388
+ this.logger.info("");
1389
+ this.logger.info(
1390
+ `Summary: ${allowedComponentsUpdated ? "1 component definition updated, " : ""}${compositionsResult} composition(s), ${compositionPatternsResult} composition pattern(s), ${componentPatternsResult} component pattern(s) updated. ${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`
1391
+ );
1392
+ return {
1393
+ allowedComponentsUpdated,
1394
+ compositionsModified: compositionsResult,
1395
+ compositionPatternsModified: compositionPatternsResult,
1396
+ componentPatternsModified: componentPatternsResult,
1397
+ instancesAdded: compositionsResult + compositionPatternsResult + componentPatternsResult
1398
+ };
1399
+ }
1400
+ async loadComponentPattern(componentPatternsDir, patternId, strict) {
1401
+ const jsonPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.json`);
1402
+ const yamlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yaml`);
1403
+ const ymlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yml`);
1404
+ if (await this.fileSystem.fileExists(jsonPath)) {
1405
+ return this.fileSystem.readFile(jsonPath);
1406
+ }
1407
+ if (await this.fileSystem.fileExists(yamlPath)) {
1408
+ return this.fileSystem.readFile(yamlPath);
1409
+ }
1410
+ if (await this.fileSystem.fileExists(ymlPath)) {
1411
+ return this.fileSystem.readFile(ymlPath);
1412
+ }
1413
+ if (!strict) {
1414
+ const files = await this.fileSystem.findFiles(componentPatternsDir, "*.{json,yaml,yml}");
1415
+ for (const filePath of files) {
1416
+ const basename2 = this.fileSystem.getBasename(filePath);
1417
+ const nameWithoutExt = basename2.replace(/\.(json|yaml|yml)$/i, "");
1418
+ if (nameWithoutExt.toLowerCase() === patternId.toLowerCase()) {
1419
+ return this.fileSystem.readFile(filePath);
1420
+ }
1421
+ }
1422
+ }
1423
+ throw new TransformError(`Component pattern "${patternId}" not found in ${componentPatternsDir}`);
1424
+ }
1425
+ async addComponentToDirectory(directory, parentComponentType, slot, newInstance, whatIf, strict, dirType) {
1426
+ const exists = await this.fileSystem.fileExists(directory);
1427
+ if (!exists) {
1428
+ this.logger.detail(`${dirType} directory does not exist, skipping`);
1429
+ return 0;
1430
+ }
1431
+ const files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
1432
+ let filesModified = 0;
1433
+ for (const filePath of files) {
1434
+ try {
1435
+ const content = await this.fileSystem.readFile(filePath);
1436
+ let composition = null;
1437
+ let isComponentPattern = false;
1438
+ if (dirType === "componentPattern" && content && typeof content === "object" && "definition" in content) {
1439
+ isComponentPattern = true;
1440
+ const pattern = content;
1441
+ if (pattern.definition && pattern.definition.slots) {
1442
+ composition = {
1443
+ composition: {
1444
+ _id: "pattern-root",
1445
+ type: pattern.definition.type,
1446
+ slots: pattern.definition.slots
1447
+ }
1448
+ };
1449
+ }
1450
+ } else {
1451
+ composition = content;
1452
+ }
1453
+ if (!composition?.composition) {
1454
+ continue;
1455
+ }
1456
+ const rootInstance = composition.composition;
1457
+ let modified = false;
1458
+ if (this.compareIds(rootInstance.type, parentComponentType, strict)) {
1459
+ if (!rootInstance.slots) {
1460
+ rootInstance.slots = {};
1461
+ }
1462
+ const instanceCopy = JSON.parse(JSON.stringify(newInstance));
1463
+ this.regenerateInstanceIds(instanceCopy);
1464
+ this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);
1465
+ modified = true;
1466
+ }
1467
+ if (rootInstance.slots) {
1468
+ const nestedModified = this.addComponentToNestedSlots(
1469
+ rootInstance.slots,
1470
+ parentComponentType,
1471
+ slot,
1472
+ newInstance,
1473
+ strict
1474
+ );
1475
+ if (nestedModified) {
1476
+ modified = true;
1477
+ }
1478
+ }
1479
+ if (modified) {
1480
+ this.logger.action(
1481
+ whatIf,
1482
+ "UPDATE",
1483
+ `Adding "${newInstance.type}" to slot "${slot}" in ${dirType}/${this.fileSystem.getBasename(filePath)}`
1484
+ );
1485
+ if (!whatIf) {
1486
+ if (isComponentPattern && content && typeof content === "object" && "definition" in content) {
1487
+ const pattern = content;
1488
+ if (rootInstance.slots) {
1489
+ pattern.definition.slots = rootInstance.slots;
1490
+ }
1491
+ }
1492
+ await this.fileSystem.writeFile(filePath, content);
1493
+ }
1494
+ filesModified++;
1495
+ }
1496
+ } catch (error) {
1497
+ if (error instanceof Error && !error.message.includes("skipping")) {
1498
+ this.logger.detail(`Skipping ${filePath}: ${error.message}`);
1499
+ }
1500
+ }
1501
+ }
1502
+ return filesModified;
1503
+ }
1504
+ addComponentToNestedSlots(slots, parentComponentType, slot, newInstance, strict) {
1505
+ let modified = false;
1506
+ for (const slotInstances of Object.values(slots)) {
1507
+ if (!Array.isArray(slotInstances)) continue;
1508
+ for (const instance of slotInstances) {
1509
+ if (this.compareIds(instance.type, parentComponentType, strict)) {
1510
+ if (!instance.slots) {
1511
+ instance.slots = {};
1512
+ }
1513
+ const instanceCopy = JSON.parse(JSON.stringify(newInstance));
1514
+ this.regenerateInstanceIds(instanceCopy);
1515
+ this.addComponentToSlot(instance.slots, slot, instanceCopy);
1516
+ modified = true;
1517
+ }
1518
+ if (instance.slots) {
1519
+ const nestedModified = this.addComponentToNestedSlots(
1520
+ instance.slots,
1521
+ parentComponentType,
1522
+ slot,
1523
+ newInstance,
1524
+ strict
1525
+ );
1526
+ if (nestedModified) {
1527
+ modified = true;
1528
+ }
1529
+ }
1530
+ }
1531
+ }
1532
+ return modified;
1533
+ }
1534
+ };
1535
+
1075
1536
  // src/cli/logger.ts
1076
1537
  import chalk from "chalk";
1077
1538
  var Logger = class {
@@ -1096,6 +1557,7 @@ var Logger = class {
1096
1557
  }
1097
1558
  };
1098
1559
  export {
1560
+ ComponentAdderService,
1099
1561
  ComponentAlreadyExistsError,
1100
1562
  ComponentNotFoundError,
1101
1563
  ComponentRenamerService,