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