@adaas/a-concept 0.3.4 → 0.3.5
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/browser/index.d.mts +19 -0
- package/dist/browser/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +58 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +19 -0
- package/dist/node/index.d.ts +19 -0
- package/dist/node/index.mjs +58 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Component/A-Component.meta.ts +1 -1
- package/src/lib/A-Context/A-Context.class.ts +11 -0
- package/src/lib/A-StepManager/A-StepManager.class.ts +59 -5
- package/tests/A-Feature.test.ts +76 -0
package/dist/node/index.cjs
CHANGED
|
@@ -3055,12 +3055,18 @@ A_StepManagerError.CircularDependencyError = "A-StepManager Circular Dependency
|
|
|
3055
3055
|
// src/lib/A-StepManager/A-StepManager.class.ts
|
|
3056
3056
|
var A_StepsManager = class {
|
|
3057
3057
|
constructor(entities) {
|
|
3058
|
+
/**
|
|
3059
|
+
* Maps each step instance to a unique ID.
|
|
3060
|
+
* Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
|
|
3061
|
+
*/
|
|
3062
|
+
this._uniqueIdMap = /* @__PURE__ */ new Map();
|
|
3058
3063
|
this._isBuilt = false;
|
|
3059
3064
|
this.entities = this.prepareSteps(entities);
|
|
3060
3065
|
this.graph = /* @__PURE__ */ new Map();
|
|
3061
3066
|
this.visited = /* @__PURE__ */ new Set();
|
|
3062
3067
|
this.tempMark = /* @__PURE__ */ new Set();
|
|
3063
3068
|
this.sortedEntities = [];
|
|
3069
|
+
this.assignUniqueIds();
|
|
3064
3070
|
}
|
|
3065
3071
|
prepareSteps(entities) {
|
|
3066
3072
|
return entities.map((step) => ({
|
|
@@ -3072,15 +3078,54 @@ var A_StepsManager = class {
|
|
|
3072
3078
|
throwOnError: false
|
|
3073
3079
|
}));
|
|
3074
3080
|
}
|
|
3075
|
-
|
|
3081
|
+
/**
|
|
3082
|
+
* Returns the base (non-unique) ID for a step: `dependency.name.handler`
|
|
3083
|
+
*/
|
|
3084
|
+
baseID(step) {
|
|
3076
3085
|
return `${step.dependency.name}.${step.handler}`;
|
|
3077
3086
|
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Returns the unique ID assigned to a specific step instance.
|
|
3089
|
+
* Falls back to baseID if not yet assigned.
|
|
3090
|
+
*/
|
|
3091
|
+
ID(step) {
|
|
3092
|
+
return this._uniqueIdMap.get(step) || this.baseID(step);
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* Assigns unique IDs to all steps.
|
|
3096
|
+
* Duplicate base IDs get an index suffix (#0, #1, ...).
|
|
3097
|
+
* Steps with unique base IDs keep their original ID (no suffix).
|
|
3098
|
+
*/
|
|
3099
|
+
assignUniqueIds() {
|
|
3100
|
+
const counts = /* @__PURE__ */ new Map();
|
|
3101
|
+
for (const step of this.entities) {
|
|
3102
|
+
const base = this.baseID(step);
|
|
3103
|
+
counts.set(base, (counts.get(base) || 0) + 1);
|
|
3104
|
+
}
|
|
3105
|
+
const indexTracker = /* @__PURE__ */ new Map();
|
|
3106
|
+
for (const step of this.entities) {
|
|
3107
|
+
const base = this.baseID(step);
|
|
3108
|
+
if (counts.get(base) > 1) {
|
|
3109
|
+
const idx = indexTracker.get(base) || 0;
|
|
3110
|
+
this._uniqueIdMap.set(step, `${base}#${idx}`);
|
|
3111
|
+
indexTracker.set(base, idx + 1);
|
|
3112
|
+
} else {
|
|
3113
|
+
this._uniqueIdMap.set(step, base);
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3078
3117
|
buildGraph() {
|
|
3079
3118
|
if (this._isBuilt) return;
|
|
3080
3119
|
this._isBuilt = true;
|
|
3081
3120
|
this.entities = this.entities.filter(
|
|
3082
|
-
(step, i, self) => !self.some((s) =>
|
|
3121
|
+
(step, i, self) => !self.some((s, j) => {
|
|
3122
|
+
if (i === j || !s.override) return false;
|
|
3123
|
+
const re = new RegExp(s.override);
|
|
3124
|
+
return re.test(this.baseID(step)) || re.test(step.handler);
|
|
3125
|
+
})
|
|
3083
3126
|
);
|
|
3127
|
+
this._uniqueIdMap.clear();
|
|
3128
|
+
this.assignUniqueIds();
|
|
3084
3129
|
this.entities.forEach((entity) => this.graph.set(this.ID(entity), /* @__PURE__ */ new Set()));
|
|
3085
3130
|
this.entities.forEach((entity) => {
|
|
3086
3131
|
const entityId = this.ID(entity);
|
|
@@ -3100,10 +3145,10 @@ var A_StepsManager = class {
|
|
|
3100
3145
|
}
|
|
3101
3146
|
});
|
|
3102
3147
|
}
|
|
3103
|
-
// Match entities by name or regex
|
|
3148
|
+
// Match entities by name or regex — matches against the base ID for pattern compatibility
|
|
3104
3149
|
matchEntities(entityId, pattern) {
|
|
3105
3150
|
const regex = new RegExp(pattern);
|
|
3106
|
-
return this.entities.filter((entity) => regex.test(this.
|
|
3151
|
+
return this.entities.filter((entity) => regex.test(this.baseID(entity)) && this.ID(entity) !== entityId).map((entity) => this.ID(entity));
|
|
3107
3152
|
}
|
|
3108
3153
|
// Topological sort with cycle detection
|
|
3109
3154
|
visit(node) {
|
|
@@ -3593,7 +3638,7 @@ var A_ComponentMeta = class extends A_Meta {
|
|
|
3593
3638
|
before: extension.before || "",
|
|
3594
3639
|
after: extension.after || "",
|
|
3595
3640
|
throwOnError: extension.throwOnError || true,
|
|
3596
|
-
override: ""
|
|
3641
|
+
override: extension.override || ""
|
|
3597
3642
|
});
|
|
3598
3643
|
});
|
|
3599
3644
|
});
|
|
@@ -5170,6 +5215,14 @@ var A_Context = class _A_Context {
|
|
|
5170
5215
|
if (inherited) {
|
|
5171
5216
|
steps.delete(`${A_CommonHelper.getComponentName(inherited)}.${declaration.handler}`);
|
|
5172
5217
|
}
|
|
5218
|
+
if (declaration.override) {
|
|
5219
|
+
const overrideRegexp = new RegExp(declaration.override);
|
|
5220
|
+
for (const [stepKey, step] of steps) {
|
|
5221
|
+
if (overrideRegexp.test(stepKey) || overrideRegexp.test(step.handler)) {
|
|
5222
|
+
steps.delete(stepKey);
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5173
5226
|
steps.set(`${A_CommonHelper.getComponentName(cmp)}.${declaration.handler}`, {
|
|
5174
5227
|
dependency: new A_Dependency(cmp),
|
|
5175
5228
|
...declaration
|