@codefast/di 0.3.16-canary.1 → 0.3.16-canary.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.
- package/CHANGELOG.md +18 -0
- package/README.md +4 -4
- package/dist/binding-select.d.mts +1 -1
- package/dist/binding-select.mjs +5 -5
- package/dist/binding.d.mts +28 -28
- package/dist/binding.mjs +8 -8
- package/dist/constraints.d.mts +3 -3
- package/dist/constraints.mjs +2 -2
- package/dist/container.mjs +146 -214
- package/dist/decorators/inject.d.mts +4 -3
- package/dist/decorators/inject.mjs +21 -48
- package/dist/decorators/injectable.mjs +4 -12
- package/dist/decorators/lifecycle-decorators.mjs +11 -72
- package/dist/dependency-graph.mjs +17 -15
- package/dist/environment.d.mts +15 -15
- package/dist/environment.mjs +21 -21
- package/dist/graph-adapters/cytoscape.d.mts +12 -12
- package/dist/graph-adapters/cytoscape.mjs +7 -7
- package/dist/graph-adapters/reactflow.d.mts +15 -15
- package/dist/graph-adapters/reactflow.mjs +6 -9
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/inspector.d.mts +3 -2
- package/dist/inspector.mjs +19 -22
- package/dist/lifecycle.mjs +2 -12
- package/dist/metadata/metadata-keys.d.mts +8 -33
- package/dist/metadata/metadata-keys.mjs +8 -21
- package/dist/metadata/metadata-types.d.mts +5 -0
- package/dist/metadata/symbol-metadata-reader.d.mts +1 -0
- package/dist/metadata/symbol-metadata-reader.mjs +11 -33
- package/dist/module.d.mts +1 -1
- package/dist/module.mjs +2 -2
- package/dist/registry.d.mts +4 -4
- package/dist/registry.mjs +26 -45
- package/dist/resolve-options.d.mts +7 -7
- package/dist/resolve-options.mjs +14 -12
- package/dist/resolver.d.mts +15 -10
- package/dist/resolver.mjs +167 -173
- package/dist/token.d.mts +1 -1
- package/dist/token.mjs +4 -4
- package/dist/types.d.mts +14 -8
- package/package.json +40 -13
- package/src/binding-scope.ts +26 -0
- package/src/binding-select.ts +167 -0
- package/src/binding.ts +281 -0
- package/src/constraints.ts +149 -0
- package/src/constructor-type.ts +19 -0
- package/src/container.ts +1213 -0
- package/src/decorators/inject.ts +233 -0
- package/src/decorators/injectable.ts +85 -0
- package/src/decorators/lifecycle-decorators.ts +55 -0
- package/src/dependency-graph.ts +116 -0
- package/src/environment.ts +232 -0
- package/src/errors.ts +262 -0
- package/src/graph-adapters/cytoscape.ts +64 -0
- package/src/graph-adapters/dot.ts +22 -0
- package/src/graph-adapters/reactflow.ts +58 -0
- package/src/index.ts +101 -0
- package/src/inspector.ts +133 -0
- package/src/lifecycle.ts +238 -0
- package/src/metadata/metadata-keys.ts +25 -0
- package/src/metadata/metadata-reader-token.ts +8 -0
- package/src/metadata/metadata-types.ts +53 -0
- package/src/metadata/symbol-metadata-reader.ts +57 -0
- package/src/module.ts +93 -0
- package/src/registry.ts +241 -0
- package/src/resolve-options.ts +42 -0
- package/src/resolver.ts +1837 -0
- package/src/scope.ts +77 -0
- package/src/token.ts +40 -0
- package/src/types.ts +145 -0
- package/dist/graph-adapters/types.d.mts +0 -2
- package/dist/graph-adapters/types.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @codefast/di
|
|
2
2
|
|
|
3
|
+
## 0.3.16-canary.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2a82188`](https://github.com/codefastlabs/codefast/commit/2a82188264c204b0b519b3324402ae962594d29b) Thanks [@thevuong](https://github.com/thevuong)! - feat(dev): enable source condition for zero-rebuild HMR in apps/docs
|
|
8
|
+
|
|
9
|
+
- [`bed2f30`](https://github.com/codefastlabs/codefast/commit/bed2f30df74128fe3b1a98dd9d03f6bb96099164) Thanks [@thevuong](https://github.com/thevuong)! - feat(web): refactor theme management to color scheme system
|
|
10
|
+
|
|
11
|
+
## 0.3.16-canary.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1ad2cb7`](https://github.com/codefastlabs/codefast/commit/1ad2cb73a3f6f8bff2b001e9df2f2492efd89aa2) Thanks [@thevuong](https://github.com/thevuong)! - chore: align package config globs
|
|
16
|
+
|
|
17
|
+
- [`4fda78b`](https://github.com/codefastlabs/codefast/commit/4fda78b20f98646d114cfddb09e66af609a625a2) Thanks [@thevuong](https://github.com/thevuong)! - fix: support Node 26 mirror export verification
|
|
18
|
+
|
|
19
|
+
- [`1b0df2e`](https://github.com/codefastlabs/codefast/commit/1b0df2e55140c927b7f3ba39ccdcb4cba87ec7ff) Thanks [@thevuong](https://github.com/thevuong)! - refactor(di): clarify contextual names
|
|
20
|
+
|
|
3
21
|
## 0.3.16-canary.1
|
|
4
22
|
|
|
5
23
|
## 0.3.16-canary.0
|
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ Start with `container.bind(key)` and chain a strategy, then optional constraints
|
|
|
181
181
|
| `.toDynamicAsync(factory)` | Async factory `(ctx: ResolutionContext) => Promise<Value>`. |
|
|
182
182
|
| `.toResolved(factory, deps)` | Factory with a typed dependency tuple; dependencies are resolved in order. |
|
|
183
183
|
| `.toResolvedAsync(factory, deps)` | Like `toResolved`, but the factory returns a `Promise`. |
|
|
184
|
-
| `.toAlias(targetToken)` | Redirect resolution to another token; the alias follows the target’s
|
|
184
|
+
| `.toAlias(targetToken)` | Redirect resolution to another token; the alias follows the target’s resolution. |
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
187
|
container.bind(AppConfigToken).toConstantValue({ port: 3000 });
|
|
@@ -271,7 +271,7 @@ Built-in predicates (all from `@codefast/di/constraints`):
|
|
|
271
271
|
| ----------------------------------- | -------------------------------------------------------------------------- |
|
|
272
272
|
| `whenParentIs(key)` | The direct parent binding was registered for `key`. |
|
|
273
273
|
| `whenNoParentIs(key)` | There is no parent, or the parent is not registered for `key`. |
|
|
274
|
-
| `whenAnyAncestorIs(key)` | Any ancestor on the
|
|
274
|
+
| `whenAnyAncestorIs(key)` | Any ancestor on the resolution stack was registered for `key`. |
|
|
275
275
|
| `whenNoAncestorIs(key)` | No ancestor was registered for `key`. |
|
|
276
276
|
| `whenParentNamed(name)` | The immediate parent binding’s slot name is `name`. |
|
|
277
277
|
| `whenAnyAncestorNamed(name)` | Some ancestor’s slot name is `name`. |
|
|
@@ -645,7 +645,7 @@ The root entry re-exports the full façade (`package.json` → `"."`). Subpaths
|
|
|
645
645
|
| `@codefast/di/decorators/injectable` | `injectable`, `createAutoRegisterRegistry`, `AutoRegisterRegistry` |
|
|
646
646
|
| `@codefast/di/decorators/lifecycle-decorators` | `postConstruct`, `preDestroy` |
|
|
647
647
|
| `@codefast/di/dependency-graph` | `buildDependencyGraph`, `ContainerGraphJson`, `GraphOptions`, … |
|
|
648
|
-
| `@codefast/di/environment` | `runWithContainer`, `getActiveContainer`, `DefaultResolutionContext`, `ResolverCallbacks`, `
|
|
648
|
+
| `@codefast/di/environment` | `runWithContainer`, `getActiveContainer`, `DefaultResolutionContext`, `ResolverCallbacks`, `buildResolutionFrame` |
|
|
649
649
|
| `@codefast/di/errors` | Full `DiError` hierarchy |
|
|
650
650
|
| `@codefast/di/graph-adapters/cytoscape` | `toCytoscapeGraph` |
|
|
651
651
|
| `@codefast/di/graph-adapters/dot` | `toDotGraph` |
|
|
@@ -659,7 +659,7 @@ The root entry re-exports the full façade (`package.json` → `"."`). Subpaths
|
|
|
659
659
|
| `@codefast/di/metadata/symbol-metadata-reader` | `SymbolMetadataReader`, `defaultMetadataReader` |
|
|
660
660
|
| `@codefast/di/module` | `Module`, `AsyncModule`, `SyncModule`, `isSyncModule`, builders |
|
|
661
661
|
| `@codefast/di/registry` | `BindingRegistry` |
|
|
662
|
-
| `@codefast/di/resolve-options` | `
|
|
662
|
+
| `@codefast/di/resolve-options` | `injectionSlotToResolveOptions`, `bindingSlotToResolveOptions` |
|
|
663
663
|
| `@codefast/di/resolver` | `DependencyResolver` |
|
|
664
664
|
| `@codefast/di/scope` | `ScopeManager` |
|
|
665
665
|
| `@codefast/di/token` | `token`, `Token`, `tokenName`, … |
|
|
@@ -8,7 +8,7 @@ import { Binding } from "./binding.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @since 0.3.16-canary.0
|
|
10
10
|
*/
|
|
11
|
-
declare function selectBinding(bindings: ReadonlyArray<Binding>, hint: ResolveOptions | undefined, ctx: ConstraintContext,
|
|
11
|
+
declare function selectBinding(bindings: ReadonlyArray<Binding>, hint: ResolveOptions | undefined, ctx: ConstraintContext, tokenDisplayName: string): Binding | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Select all candidates matching hint + predicates.
|
|
14
14
|
*
|
package/dist/binding-select.mjs
CHANGED
|
@@ -6,11 +6,11 @@ import { AmbiguousBindingError } from "./errors.mjs";
|
|
|
6
6
|
*
|
|
7
7
|
* @since 0.3.16-canary.0
|
|
8
8
|
*/
|
|
9
|
-
function selectBinding(bindings, hint, ctx,
|
|
9
|
+
function selectBinding(bindings, hint, ctx, tokenDisplayName) {
|
|
10
10
|
const candidates = filterBindings(bindings, hint, ctx);
|
|
11
11
|
if (candidates.length === 0) return;
|
|
12
12
|
if (candidates.length === 1) return candidates[0];
|
|
13
|
-
throw new AmbiguousBindingError(
|
|
13
|
+
throw new AmbiguousBindingError(tokenDisplayName, candidates.map((c) => c.id));
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Select all candidates matching hint + predicates.
|
|
@@ -20,10 +20,10 @@ function selectBinding(bindings, hint, ctx, tName) {
|
|
|
20
20
|
function selectAllBindings(bindings, hint, ctx) {
|
|
21
21
|
return filterBindings(bindings, hint, ctx, "all");
|
|
22
22
|
}
|
|
23
|
-
function filterBindings(bindings, hint, ctx,
|
|
23
|
+
function filterBindings(bindings, hint, ctx, selectionMode = "single") {
|
|
24
24
|
if (hint === void 0) {
|
|
25
25
|
const resultWithoutHint = [];
|
|
26
|
-
if (
|
|
26
|
+
if (selectionMode === "all") {
|
|
27
27
|
for (const binding of bindings) if (matchesPredicate(binding, ctx)) resultWithoutHint.push(binding);
|
|
28
28
|
} else for (const binding of bindings) {
|
|
29
29
|
const slot = binding.slot;
|
|
@@ -32,7 +32,7 @@ function filterBindings(bindings, hint, ctx, mode = "single") {
|
|
|
32
32
|
return resultWithoutHint;
|
|
33
33
|
}
|
|
34
34
|
const result = [];
|
|
35
|
-
for (const binding of bindings) if ((
|
|
35
|
+
for (const binding of bindings) if ((selectionMode === "all" ? matchesSlotForResolveAll(binding, hint) : matchesSlot(binding, hint)) && matchesPredicate(binding, ctx)) result.push(binding);
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
38
38
|
function matchesSlotForResolveAll(binding, hint) {
|
package/dist/binding.d.mts
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import { Constructor } from "./constructor-type.mjs";
|
|
2
2
|
import { Token } from "./token.mjs";
|
|
3
|
-
import { ActivationHandler, BindingIdentifier, BindingScope, ConstraintContext, DeactivationHandler, DependencyKey, ResolutionContext, TokenValue } from "./types.mjs";
|
|
3
|
+
import { ActivationHandler, BindingIdentifier, BindingScope, BindingTag, ConstraintContext, DeactivationHandler, DependencyKey, ResolutionContext, TokenValue } from "./types.mjs";
|
|
4
4
|
import { InjectionDescriptor } from "./decorators/inject.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/binding.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* @since 0.3.16-canary.0
|
|
9
9
|
*/
|
|
10
|
-
interface
|
|
10
|
+
interface BindingSlot {
|
|
11
11
|
readonly name: string | undefined;
|
|
12
|
-
readonly tags: ReadonlyArray<
|
|
12
|
+
readonly tags: ReadonlyArray<BindingTag>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* @since 0.3.16-canary.0
|
|
16
16
|
*/
|
|
17
|
-
declare function
|
|
17
|
+
declare function bindingSlotEquals(left: BindingSlot, right: BindingSlot): boolean;
|
|
18
18
|
/**
|
|
19
19
|
* @since 0.3.16-canary.0
|
|
20
20
|
*/
|
|
21
|
-
declare const
|
|
21
|
+
declare const DEFAULT_BINDING_SLOT: {
|
|
22
|
+
name: undefined;
|
|
23
|
+
tags: never[];
|
|
24
|
+
};
|
|
22
25
|
/**
|
|
23
26
|
* @since 0.3.16-canary.0
|
|
24
27
|
*/
|
|
25
|
-
declare function
|
|
28
|
+
declare function bindingSlotToString(slot: BindingSlot): string;
|
|
26
29
|
interface BindingBase<Value> {
|
|
27
30
|
readonly id: BindingIdentifier;
|
|
28
31
|
readonly token: Token<Value> | Constructor<Value>;
|
|
29
|
-
readonly slot:
|
|
32
|
+
readonly slot: BindingSlot;
|
|
30
33
|
readonly predicate?: (ctx: ConstraintContext) => boolean;
|
|
31
34
|
}
|
|
35
|
+
type BindingBaseKeys = keyof BindingBase<unknown>;
|
|
32
36
|
/**
|
|
33
37
|
* @since 0.3.16-canary.0
|
|
34
38
|
*/
|
|
@@ -107,11 +111,23 @@ type Binding<Value = unknown> = ClassBinding<Value> | DynamicBinding<Value> | Dy
|
|
|
107
111
|
*
|
|
108
112
|
* @since 0.3.16-canary.0
|
|
109
113
|
*/
|
|
110
|
-
type PartialBinding<Value> = Omit<ClassBinding<Value>,
|
|
114
|
+
type PartialBinding<Value> = Omit<ClassBinding<Value>, BindingBaseKeys> | Omit<DynamicBinding<Value>, BindingBaseKeys> | Omit<DynamicAsyncBinding<Value>, BindingBaseKeys> | Omit<ResolvedBinding<Value>, BindingBaseKeys> | Omit<ResolvedAsyncBinding<Value>, BindingBaseKeys> | Omit<ConstantBinding<Value>, BindingBaseKeys> | Omit<AliasBinding<Value>, BindingBaseKeys>;
|
|
111
115
|
/**
|
|
112
116
|
* @since 0.3.16-canary.0
|
|
113
117
|
*/
|
|
114
118
|
declare function generateBindingId(): BindingIdentifier;
|
|
119
|
+
/**
|
|
120
|
+
* Common slot-constraint + id methods shared by all concrete binding builders.
|
|
121
|
+
*
|
|
122
|
+
* @since 0.3.16-canary.0
|
|
123
|
+
*/
|
|
124
|
+
interface SlotConstrainedBuilder {
|
|
125
|
+
when(predicate: (ctx: ConstraintContext) => boolean): this;
|
|
126
|
+
whenNamed(name: string): this;
|
|
127
|
+
whenTagged(tag: string, value: unknown): this;
|
|
128
|
+
whenDefault(): this;
|
|
129
|
+
id(): BindingIdentifier;
|
|
130
|
+
}
|
|
115
131
|
/**
|
|
116
132
|
* @since 0.3.16-canary.0
|
|
117
133
|
*/
|
|
@@ -128,38 +144,22 @@ interface BindToBuilder<Value> {
|
|
|
128
144
|
/**
|
|
129
145
|
* @since 0.3.16-canary.0
|
|
130
146
|
*/
|
|
131
|
-
interface BindingBuilder<Value> {
|
|
132
|
-
when(predicate: (ctx: ConstraintContext) => boolean): this;
|
|
133
|
-
whenNamed(name: string): this;
|
|
134
|
-
whenTagged(tag: string, value: unknown): this;
|
|
135
|
-
whenDefault(): this;
|
|
147
|
+
interface BindingBuilder<Value> extends SlotConstrainedBuilder {
|
|
136
148
|
singleton(): SingletonBindingBuilder<Value>;
|
|
137
149
|
transient(): TransientBindingBuilder<Value>;
|
|
138
150
|
scoped(): ScopedBindingBuilder<Value>;
|
|
139
|
-
id(): BindingIdentifier;
|
|
140
151
|
}
|
|
141
152
|
/**
|
|
142
153
|
* @since 0.3.16-canary.0
|
|
143
154
|
*/
|
|
144
|
-
interface ConstantBindingBuilder<Value> {
|
|
145
|
-
when(predicate: (ctx: ConstraintContext) => boolean): this;
|
|
146
|
-
whenNamed(name: string): this;
|
|
147
|
-
whenTagged(tag: string, value: unknown): this;
|
|
148
|
-
whenDefault(): this;
|
|
155
|
+
interface ConstantBindingBuilder<Value> extends SlotConstrainedBuilder {
|
|
149
156
|
onActivation(fn: ActivationHandler<Value>): SingletonLifecycleBuilder<Value>;
|
|
150
157
|
onDeactivation(fn: DeactivationHandler<Value>): SingletonLifecycleBuilder<Value>;
|
|
151
|
-
id(): BindingIdentifier;
|
|
152
158
|
}
|
|
153
159
|
/**
|
|
154
160
|
* @since 0.3.16-canary.0
|
|
155
161
|
*/
|
|
156
|
-
interface AliasBindingBuilder {
|
|
157
|
-
when(predicate: (ctx: ConstraintContext) => boolean): this;
|
|
158
|
-
whenNamed(name: string): this;
|
|
159
|
-
whenTagged(tag: string, value: unknown): this;
|
|
160
|
-
whenDefault(): this;
|
|
161
|
-
id(): BindingIdentifier;
|
|
162
|
-
}
|
|
162
|
+
interface AliasBindingBuilder extends SlotConstrainedBuilder {}
|
|
163
163
|
/**
|
|
164
164
|
* @since 0.3.16-canary.0
|
|
165
165
|
*/
|
|
@@ -188,4 +188,4 @@ interface SingletonLifecycleBuilder<Value> {
|
|
|
188
188
|
id(): BindingIdentifier;
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|
|
191
|
-
export { AliasBinding, AliasBindingBuilder, BindToBuilder, Binding, BindingBuilder, ClassBinding, ConstantBinding, ConstantBindingBuilder,
|
|
191
|
+
export { AliasBinding, AliasBindingBuilder, BindToBuilder, Binding, BindingBuilder, BindingSlot, ClassBinding, ConstantBinding, ConstantBindingBuilder, DEFAULT_BINDING_SLOT, DynamicAsyncBinding, DynamicBinding, PartialBinding, ResolvedAsyncBinding, ResolvedBinding, ScopedBindingBuilder, SingletonBindingBuilder, SingletonLifecycleBuilder, SlotConstrainedBuilder, TransientBindingBuilder, bindingSlotEquals, bindingSlotToString, generateBindingId };
|
package/dist/binding.mjs
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @since 0.3.16-canary.0
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
if (
|
|
8
|
-
for (const [tagKey, tagValue] of
|
|
5
|
+
function bindingSlotEquals(left, right) {
|
|
6
|
+
if (left.name !== right.name) return false;
|
|
7
|
+
if (left.tags.length !== right.tags.length) return false;
|
|
8
|
+
for (const [tagKey, tagValue] of left.tags) if (!right.tags.some(([otherKey, otherValue]) => otherKey === tagKey && Object.is(otherValue, tagValue))) return false;
|
|
9
9
|
return true;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* @since 0.3.16-canary.0
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
14
|
+
const DEFAULT_BINDING_SLOT = {
|
|
15
15
|
name: void 0,
|
|
16
16
|
tags: []
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* @since 0.3.16-canary.0
|
|
20
20
|
*/
|
|
21
|
-
function
|
|
21
|
+
function bindingSlotToString(slot) {
|
|
22
22
|
if (slot.name === void 0 && slot.tags.length === 0) return "default";
|
|
23
23
|
const parts = [];
|
|
24
24
|
if (slot.name !== void 0) parts.push(`name:${slot.name}`);
|
|
25
|
-
for (const [
|
|
25
|
+
for (const [tagKey, tagValue] of slot.tags) parts.push(`tag:${tagKey}=${String(tagValue)}`);
|
|
26
26
|
return parts.join(",");
|
|
27
27
|
}
|
|
28
28
|
let _idCounter = 0;
|
|
@@ -33,4 +33,4 @@ function generateBindingId() {
|
|
|
33
33
|
return String(++_idCounter);
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
|
-
export {
|
|
36
|
+
export { DEFAULT_BINDING_SLOT, bindingSlotEquals, bindingSlotToString, generateBindingId };
|
package/dist/constraints.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Constructor } from "./constructor-type.mjs";
|
|
2
2
|
import { Token } from "./token.mjs";
|
|
3
|
-
import { ConstraintContext } from "./types.mjs";
|
|
3
|
+
import { BindingTag, ConstraintContext } from "./types.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/constraints.d.ts
|
|
6
6
|
/**
|
|
@@ -42,7 +42,7 @@ declare function whenAnyAncestorTagged(tag: string, value: unknown): (constraint
|
|
|
42
42
|
*
|
|
43
43
|
* @since 0.3.16-canary.1
|
|
44
44
|
*/
|
|
45
|
-
declare function whenParentTaggedAll(tags: ReadonlyArray<
|
|
45
|
+
declare function whenParentTaggedAll(tags: ReadonlyArray<BindingTag>): (constraintContext: ConstraintContext) => boolean;
|
|
46
46
|
/**
|
|
47
47
|
* Matches when at least one ancestor slot carries **all** of the given tag pairs.
|
|
48
48
|
* Equivalent to AND-composing multiple `whenAnyAncestorTagged` calls but evaluates
|
|
@@ -50,6 +50,6 @@ declare function whenParentTaggedAll(tags: ReadonlyArray<readonly [tag: string,
|
|
|
50
50
|
*
|
|
51
51
|
* @since 0.3.16-canary.1
|
|
52
52
|
*/
|
|
53
|
-
declare function whenAnyAncestorTaggedAll(tags: ReadonlyArray<
|
|
53
|
+
declare function whenAnyAncestorTaggedAll(tags: ReadonlyArray<BindingTag>): (constraintContext: ConstraintContext) => boolean;
|
|
54
54
|
//#endregion
|
|
55
55
|
export { whenAnyAncestorIs, whenAnyAncestorNamed, whenAnyAncestorTagged, whenAnyAncestorTaggedAll, whenNoAncestorIs, whenNoParentIs, whenParentIs, whenParentNamed, whenParentTagged, whenParentTaggedAll };
|
package/dist/constraints.mjs
CHANGED
|
@@ -67,7 +67,7 @@ function whenParentTaggedAll(tags) {
|
|
|
67
67
|
const { parent } = constraintContext;
|
|
68
68
|
if (parent === void 0) return false;
|
|
69
69
|
const { tags: parentTags } = parent.slot;
|
|
70
|
-
return tags.every(([tagKey, tagValue]) => parentTags.some(([
|
|
70
|
+
return tags.every(([tagKey, tagValue]) => parentTags.some(([otherKey, otherValue]) => otherKey === tagKey && Object.is(otherValue, tagValue)));
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
@@ -80,7 +80,7 @@ function whenParentTaggedAll(tags) {
|
|
|
80
80
|
function whenAnyAncestorTaggedAll(tags) {
|
|
81
81
|
return (constraintContext) => constraintContext.ancestors.some((frame) => {
|
|
82
82
|
const { tags: frameTags } = frame.slot;
|
|
83
|
-
return tags.every(([tagKey, tagValue]) => frameTags.some(([
|
|
83
|
+
return tags.every(([tagKey, tagValue]) => frameTags.some(([otherKey, otherValue]) => otherKey === tagKey && Object.is(otherValue, tagValue)));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|