@adaas/a-concept 0.3.2 → 0.3.3

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.
@@ -1258,6 +1258,17 @@ var A_Meta = class _A_Meta {
1258
1258
  this.meta = new Map(meta.meta);
1259
1259
  return this;
1260
1260
  }
1261
+ /**
1262
+ * Allows to create a copy of the meta object with the same values, this is needed to ensure that when we inherit meta from the parent component, we create a copy of it, not a reference to the same object. This allows us to modify the meta of the child component without affecting the meta of the parent component.
1263
+ *
1264
+ * @returns
1265
+ */
1266
+ clone() {
1267
+ const ctor = this.constructor;
1268
+ const copy = new ctor();
1269
+ copy.meta = new Map(this.meta);
1270
+ return copy;
1271
+ }
1261
1272
  /**
1262
1273
  * Method to set values in the map
1263
1274
  *
@@ -1369,9 +1380,20 @@ var A_Meta = class _A_Meta {
1369
1380
  clear() {
1370
1381
  this.meta.clear();
1371
1382
  }
1383
+ /**
1384
+ * Method to convert the meta to an array of key-value pairs
1385
+ *
1386
+ * @returns
1387
+ */
1372
1388
  toArray() {
1373
1389
  return Array.from(this.meta.entries());
1374
1390
  }
1391
+ /**
1392
+ * Helper method to recursively convert the meta object to a JSON-compatible format. It handles nested A_Meta instances, Maps, Arrays, and plain objects.
1393
+ *
1394
+ * @param value
1395
+ * @returns
1396
+ */
1375
1397
  recursiveToJSON(value) {
1376
1398
  switch (true) {
1377
1399
  case value instanceof _A_Meta:
@@ -4124,6 +4146,21 @@ var A_Scope = class {
4124
4146
  return slice.length === 1 && count !== -1 ? slice[0] : slice.length ? slice : void 0;
4125
4147
  }
4126
4148
  resolveConstructor(name) {
4149
+ switch (true) {
4150
+ case A_TypeGuards.isComponentConstructor(name):
4151
+ return Array.from(this.allowedComponents).find((c) => A_CommonHelper.isInheritedFrom(c, name));
4152
+ case A_TypeGuards.isEntityConstructor(name):
4153
+ return Array.from(this.allowedEntities).find((e) => A_CommonHelper.isInheritedFrom(e, name));
4154
+ case A_TypeGuards.isFragmentConstructor(name):
4155
+ return Array.from(this.allowedFragments).find((f) => A_CommonHelper.isInheritedFrom(f, name));
4156
+ case A_TypeGuards.isErrorConstructor(name):
4157
+ return Array.from(this.allowedErrors).find((e) => A_CommonHelper.isInheritedFrom(e, name));
4158
+ }
4159
+ if (!A_TypeGuards.isString(name))
4160
+ throw new A_ScopeError(
4161
+ A_ScopeError.ResolutionError,
4162
+ `Invalid constructor name provided: ${name}`
4163
+ );
4127
4164
  const component = Array.from(this.allowedComponents).find(
4128
4165
  (c) => c.name === name || c.name === A_FormatterHelper.toPascalCase(name)
4129
4166
  );
@@ -5026,7 +5063,7 @@ var A_Context = class _A_Context {
5026
5063
  }
5027
5064
  if (!inheritedMeta)
5028
5065
  inheritedMeta = new metaType();
5029
- instance._metaStorage.set(property, new metaType().from(inheritedMeta));
5066
+ instance._metaStorage.set(property, inheritedMeta.clone());
5030
5067
  }
5031
5068
  return instance._metaStorage.get(property);
5032
5069
  }