@teqfw/di 2.5.1 → 2.6.1
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 +14 -0
- package/README.md +430 -119
- package/ai/AGENTS.md +42 -74
- package/ai/concepts.md +11 -54
- package/ai/container.md +56 -47
- package/ai/dependency-id.md +77 -59
- package/ai/extensions.md +68 -38
- package/ai/package-api.ts +13 -11
- package/ai/usage.md +67 -207
- package/dist/esm.js +1 -1
- package/dist/umd.js +1 -1
- package/package.json +1 -1
- package/src/Config/NamespaceRegistry.mjs +19 -15
- package/src/Container/Lifecycle/Registry.mjs +2 -12
- package/src/Container/Resolve/GraphResolver.mjs +8 -40
- package/src/Container/Runtime.mjs +244 -0
- package/src/Container.mjs +14 -402
- package/src/Internal/DependencyKey.mjs +29 -0
- package/src/Internal/DepsDecl.mjs +42 -0
- package/src/Internal/PromiseSafe.mjs +39 -0
- package/src/{Def/Parser.mjs → Parser.mjs} +82 -35
- package/types.d.ts +1 -2
- package/src/Container/Instantiate/ExportSelector.mjs +0 -44
package/ai/AGENTS.md
CHANGED
|
@@ -1,94 +1,62 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
2
|
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20260606
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Purpose
|
|
6
6
|
|
|
7
|
-
This
|
|
7
|
+
This file defines the `ai/` level for agent-facing package documentation included in the distributable package.
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
The `ai/` directory provides a compact machine-oriented interface for agents that need to understand and use the package correctly.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Level Boundary
|
|
12
12
|
|
|
13
|
-
This
|
|
13
|
+
This level defines:
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- modules that remain environment-agnostic across Node.js and browser runtimes
|
|
20
|
-
- explicit machine-readable dependency structure for agent-assisted maintenance
|
|
15
|
+
- what documents exist in `ai/`;
|
|
16
|
+
- what each document is for;
|
|
17
|
+
- how an agent should navigate this directory;
|
|
18
|
+
- which documents describe supported usage.
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
This level does not define:
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
- repository organization;
|
|
23
|
+
- development workflow;
|
|
24
|
+
- testing strategy;
|
|
25
|
+
- internal implementation details that are not part of the supported surface;
|
|
26
|
+
- behavior not described by the documents in `ai/`.
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
- isomorphic JavaScript systems with shared browser/server code
|
|
28
|
-
- pure JavaScript + JSDoc codebases
|
|
28
|
+
## Level Map
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
- `AGENTS.md` — entry point for this level; defines scope, navigation, and authority.
|
|
31
|
+
- `concepts.md` — core concepts behind runtime linking and dependency contracts.
|
|
32
|
+
- `container.md` — container lifecycle, state model, and resolution pipeline.
|
|
33
|
+
- `dependency-id.md` — normative CDC grammar and interpretation rules.
|
|
34
|
+
- `extensions.md` — preprocess hooks, postprocess hooks, and wrapper exports.
|
|
35
|
+
- `package-api.ts` — machine-readable contract of the supported programmatic surface.
|
|
36
|
+
- `usage.md` — canonical usage patterns and short integration recipes.
|
|
31
37
|
|
|
32
|
-
##
|
|
38
|
+
## Reading Guide
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
Read documents by task:
|
|
35
41
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
42
|
+
- for supported imports and public surface, start with `package-api.ts`;
|
|
43
|
+
- for CDC syntax and meaning, read `dependency-id.md`;
|
|
44
|
+
- for runtime behavior of the container, read `container.md`;
|
|
45
|
+
- for extension behavior, read `extensions.md`;
|
|
46
|
+
- for practical integration examples, read `usage.md`;
|
|
47
|
+
- for conceptual orientation, read `concepts.md`.
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
If the task is broad or unclear, read in this order:
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
1. `AGENTS.md`
|
|
52
|
+
2. `package-api.ts`
|
|
53
|
+
3. `usage.md`
|
|
54
|
+
4. `dependency-id.md`
|
|
55
|
+
5. `container.md`
|
|
56
|
+
6. remaining documents as needed
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
## Authority
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
The documents in `ai/` define the supported agent-facing usage semantics of the package.
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- ES modules provide implementations.
|
|
52
|
-
- CDC identifiers define dependency contracts.
|
|
53
|
-
- the container performs deterministic runtime linking.
|
|
54
|
-
- linked values are frozen before they are returned.
|
|
55
|
-
|
|
56
|
-
This mechanism separates module implementation from dependency binding and allows systems to assemble component graphs dynamically while preserving deterministic behavior.
|
|
57
|
-
|
|
58
|
-
## Reading Order
|
|
59
|
-
|
|
60
|
-
Agents should read the documents in this directory in the following order:
|
|
61
|
-
|
|
62
|
-
1. **AGENTS.md** — overview of the package and navigation of the Agent Interface.
|
|
63
|
-
2. **package-api.ts** — machine-readable contract of the supported programmatic API, public entrypoints, structural contracts, and internal exclusions.
|
|
64
|
-
3. **concepts.md** — architectural concepts and design principles.
|
|
65
|
-
4. **container.md** — container responsibilities and dependency resolution pipeline.
|
|
66
|
-
5. **dependency-id.md** — syntax and semantics of dependency identifiers.
|
|
67
|
-
6. **extensions.md** — extension mechanisms such as preprocessors and wrappers.
|
|
68
|
-
7. **usage.md** — minimal usage scenarios and examples.
|
|
69
|
-
|
|
70
|
-
This sequence reflects the intended agent workflow: contract surface first, then architectural model, operational mechanism, dependency addressing, extension points, and practical usage.
|
|
71
|
-
|
|
72
|
-
Agents that need a working integration should prefer:
|
|
73
|
-
|
|
74
|
-
1. `package-api.ts` for the programmatic surface,
|
|
75
|
-
2. `usage.md` for examples,
|
|
76
|
-
3. `dependency-id.md` for CDC details,
|
|
77
|
-
4. `container.md` for behavioral guarantees.
|
|
78
|
-
|
|
79
|
-
## Interface Scope
|
|
80
|
-
|
|
81
|
-
The documents in this directory define the supported usage semantics of the package. Behaviors not described here should be treated as undefined and should not be inferred. The interface intentionally contains only the information required to correctly apply the package in external code.
|
|
82
|
-
|
|
83
|
-
## Relation to TeqFW
|
|
84
|
-
|
|
85
|
-
The package follows architectural principles used in the **Tequila Framework (TeqFW)** platform, including:
|
|
86
|
-
|
|
87
|
-
- late binding between components
|
|
88
|
-
- separation of data structures and logic handlers
|
|
89
|
-
- namespace-based module organization
|
|
90
|
-
- development in modern JavaScript without compilation
|
|
91
|
-
|
|
92
|
-
Understanding the broader TeqFW ecosystem is not required to use the package, but the container follows the same architectural philosophy.
|
|
93
|
-
|
|
94
|
-
For agent usage, this directory is the package's machine-oriented interface. Prefer these documents over inferring behavior from repository-level prose.
|
|
62
|
+
Agents should rely on these documents for package use and should treat behavior not described here as undefined.
|
package/ai/concepts.md
CHANGED
|
@@ -1,68 +1,25 @@
|
|
|
1
1
|
# concepts.md
|
|
2
2
|
|
|
3
|
-
Version:
|
|
4
|
-
|
|
5
|
-
## Purpose of the Container
|
|
6
|
-
|
|
7
|
-
The container provides a deterministic mechanism for linking ES modules at runtime. Instead of static imports between modules, dependencies are resolved through a central container that loads modules, instantiates exported factories, and returns linked objects. This approach separates module implementation from dependency resolution and allows systems to assemble components dynamically.
|
|
3
|
+
Version: 20260606
|
|
8
4
|
|
|
9
5
|
## Late Binding
|
|
10
6
|
|
|
11
|
-
Dependencies
|
|
12
|
-
|
|
13
|
-
Late binding enables the following properties:
|
|
14
|
-
|
|
15
|
-
- reduced coupling between modules
|
|
16
|
-
- runtime replacement of implementations
|
|
17
|
-
- simplified testing through dependency substitution
|
|
18
|
-
- compatibility with different runtime environments
|
|
19
|
-
|
|
20
|
-
## Dependency Container
|
|
21
|
-
|
|
22
|
-
The container acts as the composition root of the application. It receives dependency requests expressed as identifiers, resolves them into module locations, loads the corresponding ES modules, and produces linked objects.
|
|
23
|
-
|
|
24
|
-
The container is responsible for:
|
|
25
|
-
|
|
26
|
-
- translating dependency identifiers into module references
|
|
27
|
-
- loading ES modules dynamically
|
|
28
|
-
- instantiating exported factories
|
|
29
|
-
- applying preprocessing and postprocessing steps
|
|
30
|
-
- returning fully linked objects to the caller
|
|
31
|
-
|
|
32
|
-
Application modules do not construct their dependencies directly and do not perform dependency resolution.
|
|
33
|
-
|
|
34
|
-
## Dependency Identifiers
|
|
35
|
-
|
|
36
|
-
Dependencies are addressed using structured identifiers interpreted by the container. An identifier describes how the dependency should be resolved and how the resulting object should be instantiated.
|
|
37
|
-
|
|
38
|
-
Dependency identifiers define:
|
|
39
|
-
|
|
40
|
-
- which module provides the dependency
|
|
41
|
-
- which export must be used
|
|
42
|
-
- whether the dependency represents a singleton or a new instance
|
|
43
|
-
|
|
44
|
-
Module dependency descriptors complement CDCs by declaring export-scoped dependency maps. The canonical form is hierarchical and keyed by export name; a flat descriptor is shorthand for limited single-export cases; omission means there are no dependencies.
|
|
45
|
-
|
|
46
|
-
The identifier syntax and resolution rules are described in **dependency-id.md**.
|
|
7
|
+
Dependencies are resolved at runtime rather than through direct static imports between application modules. This keeps modules independent of concrete implementations and moves dependency binding into the container.
|
|
47
8
|
|
|
48
|
-
##
|
|
9
|
+
## Runtime Linker
|
|
49
10
|
|
|
50
|
-
|
|
11
|
+
The container acts as a runtime linker for ES modules. It interprets CDC identifiers, resolves modules, selects exports, and produces linked values for callers.
|
|
51
12
|
|
|
52
|
-
|
|
13
|
+
## Dependency Contracts
|
|
53
14
|
|
|
54
|
-
|
|
15
|
+
Dependencies are declared through CDC strings and module-level `__deps__` descriptors. Together they form the contract between module code and runtime composition.
|
|
55
16
|
|
|
56
|
-
|
|
57
|
-
- isolation between packages
|
|
58
|
-
- consistent mapping between identifiers and modules
|
|
17
|
+
The canonical `__deps__` form is hierarchical and keyed by export name.
|
|
59
18
|
|
|
60
|
-
##
|
|
19
|
+
## Namespace Mapping
|
|
61
20
|
|
|
62
|
-
|
|
21
|
+
Logical module identifiers are translated into module-specifier bases through namespace roots. This keeps dependency addressing independent from concrete filesystem paths or URL locations.
|
|
63
22
|
|
|
64
|
-
|
|
23
|
+
## Immutable Linked Values
|
|
65
24
|
|
|
66
|
-
|
|
67
|
-
- shared instances cannot be altered by consumers
|
|
68
|
-
- the container remains the single authority responsible for object construction
|
|
25
|
+
Values returned by the container are frozen after linking. Consumers should treat them as stable resolved values rather than mutable construction targets.
|
package/ai/container.md
CHANGED
|
@@ -1,75 +1,84 @@
|
|
|
1
1
|
# container.md
|
|
2
2
|
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20260606
|
|
4
4
|
|
|
5
|
-
## Role
|
|
5
|
+
## Role
|
|
6
6
|
|
|
7
|
-
The container
|
|
7
|
+
The container is the runtime composition root of the package. It interprets CDC identifiers, resolves them into modules, produces linked values, and returns frozen results.
|
|
8
8
|
|
|
9
|
-
Application modules do not resolve dependencies themselves
|
|
9
|
+
Application modules do not resolve dependencies themselves. They declare dependency contracts and rely on the container to perform linking.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Configuration Stage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Before the first `get()`, the container is in builder stage.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
- resolve identifiers into module locations
|
|
17
|
-
- load ES modules dynamically
|
|
18
|
-
- instantiate exported factories
|
|
19
|
-
- apply preprocess and postprocess handlers
|
|
20
|
-
- manage object lifecycle semantics
|
|
21
|
-
- freeze linked objects before returning them
|
|
15
|
+
During this stage external code may:
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
- register namespace roots with `addNamespaceRoot()`;
|
|
18
|
+
- replace the CDC parser with `setParser()`;
|
|
19
|
+
- add preprocess hooks with `addPreprocess()`;
|
|
20
|
+
- add postprocess hooks with `addPostprocess()`;
|
|
21
|
+
- enable diagnostics with `enableLogging()`;
|
|
22
|
+
- enable test-only mock registration with `enableTestMode()` and `register()`.
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
On the first `get()`:
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
- configuration is locked;
|
|
27
|
+
- namespace rules are snapshotted;
|
|
28
|
+
- internal resolution infrastructure is created.
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
2. **Preprocess** — allow registered preprocess handlers to transform the identifier.
|
|
31
|
-
3. **Resolve** — translate the identifier into a module reference.
|
|
32
|
-
4. **Instantiate** — load the module and create the object using the selected export.
|
|
33
|
-
5. **Postprocess** — apply wrapper handlers to the created object.
|
|
34
|
-
6. **Lifecycle** — apply lifecycle semantics such as singleton caching or instance creation.
|
|
35
|
-
7. **Freeze** — freeze the resulting object before returning it.
|
|
30
|
+
After the first `get()`, builder-stage methods are no longer supported.
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
## Resolution Pipeline
|
|
38
33
|
|
|
39
|
-
|
|
34
|
+
For each `get(cdc)` request the container applies this pipeline:
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
1. `Parse` — convert the CDC string into a DepId DTO.
|
|
37
|
+
2. `Preprocess hooks` — transform the DepId DTO through ordered `addPreprocess()` hooks.
|
|
38
|
+
3. `Resolve` — map the identifier to a concrete module location.
|
|
39
|
+
4. `Instantiate` — load the module and either return the selected export as-is or instantiate it according to lifecycle composition rules.
|
|
40
|
+
5. `Postprocess hooks` — apply ordered `addPostprocess()` value transforms.
|
|
41
|
+
6. `Wrapper exports` — apply ordered wrapper exports selected by CDC suffixes.
|
|
42
|
+
7. `Lifecycle` — apply singleton caching or transient behavior.
|
|
43
|
+
8. `Freeze` — freeze the resolved value before returning it.
|
|
42
44
|
|
|
43
|
-
The
|
|
45
|
+
The pipeline is deterministic for a fixed configuration and input CDC.
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
- **register(identifier, value)** — register a predefined dependency or instance in the container.
|
|
47
|
-
- **get(identifier)** — resolve a dependency identifier and return the linked object.
|
|
48
|
-
- **addPreprocess(handler)** — register a handler that can transform dependency identifiers before resolution.
|
|
49
|
-
- **addPostprocess(handler)** — register a handler that can modify created objects after instantiation.
|
|
47
|
+
## State Model
|
|
50
48
|
|
|
51
|
-
The
|
|
49
|
+
The container operates in three states:
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
- `builder` — configuration is still mutable.
|
|
52
|
+
- `operational` — dependency resolution is active.
|
|
53
|
+
- `failed` — a fatal pipeline error has occurred.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
State transitions:
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
- construction starts in `builder`;
|
|
58
|
+
- the first successful or failed `get()` transitions the container out of mutable builder configuration;
|
|
59
|
+
- a fatal resolution error moves the container to `failed`.
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
- **operational** — the container resolves dependencies and produces linked objects.
|
|
61
|
-
- **failed** — the container has encountered an unrecoverable error.
|
|
61
|
+
## Freeze Semantics
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Values returned by the container are frozen before they are returned to callers.
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
Freeze happens after:
|
|
66
|
+
|
|
67
|
+
- instantiation;
|
|
68
|
+
- postprocess hooks;
|
|
69
|
+
- wrapper exports;
|
|
70
|
+
- lifecycle application.
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
This means consumers receive stable linked values and should not mutate them.
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
## Failure Semantics
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
If any fatal error occurs during parsing, preprocessing, resolution, instantiation, postprocessing, wrapping, or lifecycle handling, the container enters `failed` state.
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- the
|
|
78
|
+
Once in `failed` state:
|
|
79
|
+
|
|
80
|
+
- the current `get()` request rejects;
|
|
81
|
+
- all subsequent `get()` calls reject;
|
|
82
|
+
- the container does not attempt partial recovery.
|
|
83
|
+
|
|
84
|
+
This fail-fast behavior prevents partially linked systems from continuing execution.
|
package/ai/dependency-id.md
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
# dependency-id.md
|
|
2
2
|
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20260606
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
Dependencies in the container are addressed using **Canonical Dependency Codes (CDC)**. A CDC is a structured identifier interpreted by the container to determine which module must be loaded, which export must be
|
|
7
|
+
Dependencies in the container are addressed using **Canonical Dependency Codes (CDC)**. A CDC is a structured identifier interpreted by the container to determine which module must be loaded, which export must be selected, and whether the resolved value is returned as-is or instantiated with lifecycle semantics.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Canonical Form
|
|
12
|
-
|
|
13
|
-
A CDC follows the canonical structure:
|
|
9
|
+
## Grammar
|
|
14
10
|
|
|
15
11
|
```txt
|
|
16
|
-
[PlatformPrefix]ModuleName[__ExportName][Lifecycle][WrapperSuffixes]
|
|
12
|
+
CDC := [PlatformPrefix]ModuleName[__ExportName][Lifecycle][WrapperSuffixes]
|
|
17
13
|
```
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
Component order is fixed.
|
|
16
|
+
|
|
17
|
+
- `PlatformPrefix` is optional.
|
|
18
|
+
- `__ExportName` is optional.
|
|
19
|
+
- `Lifecycle` is optional.
|
|
20
|
+
- `WrapperSuffixes` are optional and require a lifecycle marker.
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
- **ModuleName** — logical module identifier within a namespace.
|
|
23
|
-
- **ExportName** — optional named export selector.
|
|
24
|
-
- **Lifecycle** — marker defining instantiation semantics.
|
|
25
|
-
- **WrapperSuffixes** — optional sequence of wrapper identifiers.
|
|
22
|
+
## Components
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
- `PlatformPrefix` — optional source selector such as `node:` or `npm:`.
|
|
25
|
+
- `ModuleName` — logical module identifier inside a namespace.
|
|
26
|
+
- `__ExportName` — optional named export selector. Omission means the default export for composition, or whole-module namespace for as-is resolution.
|
|
27
|
+
- `Lifecycle` — optional instantiation marker.
|
|
28
|
+
- `WrapperSuffixes` — optional ordered wrapper export names appended after the lifecycle marker.
|
|
28
29
|
|
|
29
|
-
## Platform
|
|
30
|
+
## Platform Prefixes
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
Supported prefixes:
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
- `node:` — reference a built-in Node.js module.
|
|
35
|
+
- `npm:` — reference an npm package.
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
- **`npm:`** — reference a module from the npm ecosystem.
|
|
37
|
+
If no platform prefix is present, the identifier refers to an application module resolved through namespace roots.
|
|
37
38
|
|
|
38
39
|
Examples:
|
|
39
40
|
|
|
40
41
|
```txt
|
|
41
|
-
node:fs
|
|
42
|
-
npm:@humanfs/core
|
|
43
|
-
|
|
44
|
-
npm:lodash$
|
|
42
|
+
node:fs
|
|
43
|
+
npm:@humanfs/core
|
|
44
|
+
App_Service_User$
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
If no platform prefix is present, the identifier refers to an application module resolved through namespace mapping.
|
|
48
|
-
|
|
49
47
|
## Module Identification
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Identifier segments separated by underscores correspond to directory boundaries in the module path.
|
|
49
|
+
`ModuleName` identifies the provider module. Identifier segments separated by underscores correspond to path segments inside the configured namespace root.
|
|
54
50
|
|
|
55
51
|
Example:
|
|
56
52
|
|
|
@@ -58,19 +54,17 @@ Example:
|
|
|
58
54
|
App_Service_User
|
|
59
55
|
```
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
may map to a module-specifier base such as:
|
|
62
58
|
|
|
63
59
|
```txt
|
|
64
|
-
AppRoot/Service/User.
|
|
60
|
+
AppRoot/Service/User.mjs
|
|
65
61
|
```
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
The base may be filesystem-backed or URL-backed depending on runtime configuration.
|
|
68
64
|
|
|
69
65
|
## Export Selection
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Named exports are selected using a double underscore separator.
|
|
67
|
+
Named exports are selected with a double underscore separator.
|
|
74
68
|
|
|
75
69
|
Examples:
|
|
76
70
|
|
|
@@ -79,49 +73,73 @@ App_Service_User$
|
|
|
79
73
|
App_Service_User__Factory$
|
|
80
74
|
```
|
|
81
75
|
|
|
82
|
-
|
|
76
|
+
- `App_Service_User$` selects the default export for lifecycle-based composition.
|
|
77
|
+
- `App_Service_User__Factory$` selects the named export `Factory` for lifecycle-based composition.
|
|
83
78
|
|
|
84
79
|
## Lifecycle Markers
|
|
85
80
|
|
|
86
|
-
|
|
81
|
+
Supported lifecycle markers:
|
|
87
82
|
|
|
88
|
-
|
|
83
|
+
- `$` — singleton lifecycle; create once and reuse the same instance.
|
|
84
|
+
- `$$` — transient lifecycle; create a new instance each time.
|
|
85
|
+
- `$$$` — transient alias; behaves the same as `$$` in the current implementation.
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
If the lifecycle marker is omitted, the selected module export is resolved **as-is** and is not instantiated by lifecycle rules.
|
|
88
|
+
|
|
89
|
+
Examples:
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
```txt
|
|
92
|
+
App_Math
|
|
93
|
+
App_Service$
|
|
94
|
+
App_Task$$
|
|
95
|
+
```
|
|
95
96
|
|
|
96
97
|
## Wrapper Suffixes
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
Wrapper suffixes are appended after the lifecycle marker and separated by underscores.
|
|
99
100
|
|
|
100
101
|
Example:
|
|
101
102
|
|
|
102
103
|
```txt
|
|
103
|
-
|
|
104
|
+
App_Service$$_wrapLog_wrapTrace
|
|
104
105
|
```
|
|
105
106
|
|
|
106
|
-
In this example the container creates a
|
|
107
|
+
In this example the container creates a transient instance, then applies wrapper exports `wrapLog` and `wrapTrace` in the declared order.
|
|
107
108
|
|
|
108
|
-
Wrapper
|
|
109
|
+
Wrapper exports are described in `extensions.md`.
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
## Interpretation Rules
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
When the container receives a CDC it interprets it in this order:
|
|
114
|
+
|
|
115
|
+
1. determine the platform prefix and module namespace;
|
|
116
|
+
2. resolve the module identifier into a module location;
|
|
117
|
+
3. select the default export, a named export, or the whole module namespace for as-is resolution;
|
|
118
|
+
4. apply lifecycle semantics if a lifecycle marker is present;
|
|
119
|
+
5. apply wrapper exports if wrapper suffixes are present.
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
Important rules:
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
- no lifecycle marker means as-is resolution of the selected export;
|
|
124
|
+
- wrapper suffixes are meaningful only for lifecycle-based composition;
|
|
125
|
+
- named export selection does not by itself imply singleton or transient behavior;
|
|
126
|
+
- lifecycle and wrappers are interpreted after export selection.
|
|
127
|
+
|
|
128
|
+
## Canonical Examples
|
|
129
|
+
|
|
130
|
+
```txt
|
|
131
|
+
App_Math
|
|
132
|
+
App_Service$
|
|
133
|
+
App_Service__Factory$
|
|
134
|
+
App_Task$$_wrapLog
|
|
135
|
+
node:fs
|
|
136
|
+
npm:@humanfs/core
|
|
137
|
+
```
|
|
120
138
|
|
|
121
|
-
|
|
122
|
-
2. resolve the module identifier into a module location
|
|
123
|
-
3. select the requested export
|
|
124
|
-
4. apply lifecycle semantics
|
|
125
|
-
5. apply wrapper suffixes if present
|
|
139
|
+
These examples cover:
|
|
126
140
|
|
|
127
|
-
|
|
141
|
+
- as-is module or export resolution;
|
|
142
|
+
- singleton composition;
|
|
143
|
+
- named export composition;
|
|
144
|
+
- transient composition with wrapper exports;
|
|
145
|
+
- platform module access.
|