@adaas/a-concept 0.3.4 → 0.3.6

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.
@@ -1783,10 +1783,29 @@ declare class A_StepsManager {
1783
1783
  visited: Set<string>;
1784
1784
  tempMark: Set<string>;
1785
1785
  sortedEntities: string[];
1786
+ /**
1787
+ * Maps each step instance to a unique ID.
1788
+ * Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
1789
+ */
1790
+ private _uniqueIdMap;
1786
1791
  private _isBuilt;
1787
1792
  constructor(entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>);
1788
1793
  private prepareSteps;
1794
+ /**
1795
+ * Returns the base (non-unique) ID for a step: `dependency.name.handler`
1796
+ */
1797
+ private baseID;
1798
+ /**
1799
+ * Returns the unique ID assigned to a specific step instance.
1800
+ * Falls back to baseID if not yet assigned.
1801
+ */
1789
1802
  private ID;
1803
+ /**
1804
+ * Assigns unique IDs to all steps.
1805
+ * Duplicate base IDs get an index suffix (#0, #1, ...).
1806
+ * Steps with unique base IDs keep their original ID (no suffix).
1807
+ */
1808
+ private assignUniqueIds;
1790
1809
  private buildGraph;
1791
1810
  private matchEntities;
1792
1811
  private visit;
@@ -1783,10 +1783,29 @@ declare class A_StepsManager {
1783
1783
  visited: Set<string>;
1784
1784
  tempMark: Set<string>;
1785
1785
  sortedEntities: string[];
1786
+ /**
1787
+ * Maps each step instance to a unique ID.
1788
+ * Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
1789
+ */
1790
+ private _uniqueIdMap;
1786
1791
  private _isBuilt;
1787
1792
  constructor(entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>);
1788
1793
  private prepareSteps;
1794
+ /**
1795
+ * Returns the base (non-unique) ID for a step: `dependency.name.handler`
1796
+ */
1797
+ private baseID;
1798
+ /**
1799
+ * Returns the unique ID assigned to a specific step instance.
1800
+ * Falls back to baseID if not yet assigned.
1801
+ */
1789
1802
  private ID;
1803
+ /**
1804
+ * Assigns unique IDs to all steps.
1805
+ * Duplicate base IDs get an index suffix (#0, #1, ...).
1806
+ * Steps with unique base IDs keep their original ID (no suffix).
1807
+ */
1808
+ private assignUniqueIds;
1790
1809
  private buildGraph;
1791
1810
  private matchEntities;
1792
1811
  private visit;
@@ -2812,14 +2812,20 @@ function A_Feature_Extend(param1) {
2812
2812
  const existedMetaValue = [
2813
2813
  ...existedMeta.get(targetRegexp.source) || []
2814
2814
  ];
2815
+ const currentFeatureName = param1 && typeof param1 === "object" && !A_TypeGuards.isRegExp(param1) && param1.name || propertyKey;
2815
2816
  for (const [key, handlers] of existedMeta.entries()) {
2816
2817
  const indexInAnother = handlers.findIndex((item) => item.handler === propertyKey);
2817
2818
  if (key !== targetRegexp.source && indexInAnother !== -1) {
2818
- handlers.splice(indexInAnother, 1);
2819
- if (handlers.length === 0) {
2820
- existedMeta.delete(key);
2821
- } else {
2822
- existedMeta.set(key, handlers);
2819
+ const keyStr = String(key);
2820
+ const featureNameMatch = keyStr.match(/\\\.\s*([^\\.$]+)\$$/);
2821
+ const otherFeatureName = featureNameMatch ? featureNameMatch[1] : null;
2822
+ if (otherFeatureName === currentFeatureName) {
2823
+ handlers.splice(indexInAnother, 1);
2824
+ if (handlers.length === 0) {
2825
+ existedMeta.delete(key);
2826
+ } else {
2827
+ existedMeta.set(key, handlers);
2828
+ }
2823
2829
  }
2824
2830
  }
2825
2831
  }
@@ -3053,12 +3059,18 @@ A_StepManagerError.CircularDependencyError = "A-StepManager Circular Dependency
3053
3059
  // src/lib/A-StepManager/A-StepManager.class.ts
3054
3060
  var A_StepsManager = class {
3055
3061
  constructor(entities) {
3062
+ /**
3063
+ * Maps each step instance to a unique ID.
3064
+ * Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
3065
+ */
3066
+ this._uniqueIdMap = /* @__PURE__ */ new Map();
3056
3067
  this._isBuilt = false;
3057
3068
  this.entities = this.prepareSteps(entities);
3058
3069
  this.graph = /* @__PURE__ */ new Map();
3059
3070
  this.visited = /* @__PURE__ */ new Set();
3060
3071
  this.tempMark = /* @__PURE__ */ new Set();
3061
3072
  this.sortedEntities = [];
3073
+ this.assignUniqueIds();
3062
3074
  }
3063
3075
  prepareSteps(entities) {
3064
3076
  return entities.map((step) => ({
@@ -3070,15 +3082,54 @@ var A_StepsManager = class {
3070
3082
  throwOnError: false
3071
3083
  }));
3072
3084
  }
3073
- ID(step) {
3085
+ /**
3086
+ * Returns the base (non-unique) ID for a step: `dependency.name.handler`
3087
+ */
3088
+ baseID(step) {
3074
3089
  return `${step.dependency.name}.${step.handler}`;
3075
3090
  }
3091
+ /**
3092
+ * Returns the unique ID assigned to a specific step instance.
3093
+ * Falls back to baseID if not yet assigned.
3094
+ */
3095
+ ID(step) {
3096
+ return this._uniqueIdMap.get(step) || this.baseID(step);
3097
+ }
3098
+ /**
3099
+ * Assigns unique IDs to all steps.
3100
+ * Duplicate base IDs get an index suffix (#0, #1, ...).
3101
+ * Steps with unique base IDs keep their original ID (no suffix).
3102
+ */
3103
+ assignUniqueIds() {
3104
+ const counts = /* @__PURE__ */ new Map();
3105
+ for (const step of this.entities) {
3106
+ const base = this.baseID(step);
3107
+ counts.set(base, (counts.get(base) || 0) + 1);
3108
+ }
3109
+ const indexTracker = /* @__PURE__ */ new Map();
3110
+ for (const step of this.entities) {
3111
+ const base = this.baseID(step);
3112
+ if (counts.get(base) > 1) {
3113
+ const idx = indexTracker.get(base) || 0;
3114
+ this._uniqueIdMap.set(step, `${base}#${idx}`);
3115
+ indexTracker.set(base, idx + 1);
3116
+ } else {
3117
+ this._uniqueIdMap.set(step, base);
3118
+ }
3119
+ }
3120
+ }
3076
3121
  buildGraph() {
3077
3122
  if (this._isBuilt) return;
3078
3123
  this._isBuilt = true;
3079
3124
  this.entities = this.entities.filter(
3080
- (step, i, self) => !self.some((s) => s.override ? new RegExp(s.override).test(this.ID(step)) : false)
3125
+ (step, i, self) => !self.some((s, j) => {
3126
+ if (i === j || !s.override) return false;
3127
+ const re = new RegExp(s.override);
3128
+ return re.test(this.baseID(step)) || re.test(step.handler);
3129
+ })
3081
3130
  );
3131
+ this._uniqueIdMap.clear();
3132
+ this.assignUniqueIds();
3082
3133
  this.entities.forEach((entity) => this.graph.set(this.ID(entity), /* @__PURE__ */ new Set()));
3083
3134
  this.entities.forEach((entity) => {
3084
3135
  const entityId = this.ID(entity);
@@ -3098,10 +3149,10 @@ var A_StepsManager = class {
3098
3149
  }
3099
3150
  });
3100
3151
  }
3101
- // Match entities by name or regex
3152
+ // Match entities by name or regex — matches against the base ID for pattern compatibility
3102
3153
  matchEntities(entityId, pattern) {
3103
3154
  const regex = new RegExp(pattern);
3104
- return this.entities.filter((entity) => regex.test(this.ID(entity)) && this.ID(entity) !== entityId).map((entity) => this.ID(entity));
3155
+ return this.entities.filter((entity) => regex.test(this.baseID(entity)) && this.ID(entity) !== entityId).map((entity) => this.ID(entity));
3105
3156
  }
3106
3157
  // Topological sort with cycle detection
3107
3158
  visit(node) {
@@ -3591,7 +3642,7 @@ var A_ComponentMeta = class extends A_Meta {
3591
3642
  before: extension.before || "",
3592
3643
  after: extension.after || "",
3593
3644
  throwOnError: extension.throwOnError || true,
3594
- override: ""
3645
+ override: extension.override || ""
3595
3646
  });
3596
3647
  });
3597
3648
  });
@@ -5168,6 +5219,14 @@ var A_Context = class _A_Context {
5168
5219
  if (inherited) {
5169
5220
  steps.delete(`${A_CommonHelper.getComponentName(inherited)}.${declaration.handler}`);
5170
5221
  }
5222
+ if (declaration.override) {
5223
+ const overrideRegexp = new RegExp(declaration.override);
5224
+ for (const [stepKey, step] of steps) {
5225
+ if (overrideRegexp.test(stepKey) || overrideRegexp.test(step.handler)) {
5226
+ steps.delete(stepKey);
5227
+ }
5228
+ }
5229
+ }
5171
5230
  steps.set(`${A_CommonHelper.getComponentName(cmp)}.${declaration.handler}`, {
5172
5231
  dependency: new A_Dependency(cmp),
5173
5232
  ...declaration