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