static-injector 6.1.2 → 6.2.0
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/import/di/contextual.d.ts +4 -0
- package/import/di/forward_ref.d.ts +1 -1
- package/import/di/injectable.d.ts +4 -3
- package/import/di/injection_token.d.ts +3 -0
- package/import/di/injector.d.ts +2 -0
- package/import/di/injector_compatibility.d.ts +0 -1
- package/import/di/interface/provider.d.ts +11 -11
- package/import/di/metadata.d.ts +2 -2
- package/import/di/r3_injector.d.ts +8 -1
- package/import/error_handler.d.ts +3 -0
- package/import/errors.d.ts +7 -1
- package/import/index.d.ts +1 -0
- package/import/linker/destroy_ref.d.ts +12 -0
- package/import/pending_tasks.d.ts +3 -0
- package/import/render3/errors_di.d.ts +12 -2
- package/import/render3/reactivity/api.d.ts +2 -0
- package/import/render3/reactivity/asserts.d.ts +1 -1
- package/import/render3/reactivity/computed.d.ts +1 -0
- package/import/render3/reactivity/effect.d.ts +9 -8
- package/import/render3/reactivity/linked_signal.d.ts +3 -0
- package/import/render3/reactivity/signal.d.ts +1 -0
- package/import/render3/reactivity/untracked.d.ts +1 -0
- package/import/resource/api.d.ts +7 -4
- package/import/resource/resource.d.ts +6 -3
- package/index.js +259 -185
- package/index.js.map +4 -4
- package/index.mjs +259 -184
- package/index.mjs.map +4 -4
- package/package.json +2 -2
- package/primitives/di/index.d.ts +2 -1
- package/primitives/di/src/injection_token.d.ts +9 -0
- package/primitives/di/src/injector.d.ts +2 -1
- package/primitives/signals/index.d.ts +4 -2
- package/primitives/signals/src/effect.d.ts +26 -0
- package/primitives/signals/src/formatter.d.ts +18 -0
- package/primitives/signals/src/graph.d.ts +42 -35
- package/primitives/signals/src/linked_signal.d.ts +3 -2
- package/primitives/signals/src/watch.d.ts +0 -1
- package/readme.md +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "static-injector",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Angular 依赖注入独立版本;Angular dependency injection standalone version",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
7
|
-
"angular 20.
|
|
7
|
+
"angular 20.3.15",
|
|
8
8
|
"injector",
|
|
9
9
|
"typescript",
|
|
10
10
|
"injectable",
|
package/primitives/di/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
export { setCurrentInjector, getCurrentInjector } from './src/injector';
|
|
8
|
+
export { setCurrentInjector, getCurrentInjector, inject } from './src/injector';
|
|
9
9
|
export type { Injector } from './src/injector';
|
|
10
10
|
export { NOT_FOUND, NotFoundError, isNotFound } from './src/not_found';
|
|
11
11
|
export type { NotFound } from './src/not_found';
|
|
12
12
|
export type { InjectionToken, ɵɵInjectableDeclaration } from './src/injection_token';
|
|
13
|
+
export { defineInjectable, registerInjectable } from './src/injection_token';
|
|
@@ -61,3 +61,12 @@ export interface ɵɵInjectableDeclaration<T> {
|
|
|
61
61
|
export interface InjectionToken<T> {
|
|
62
62
|
ɵprov: ɵɵInjectableDeclaration<T>;
|
|
63
63
|
}
|
|
64
|
+
export declare function defineInjectable<T>(opts: {
|
|
65
|
+
token: unknown;
|
|
66
|
+
providedIn?: Type<any> | 'root' | 'platform' | 'any' | 'environment' | null;
|
|
67
|
+
factory: () => T;
|
|
68
|
+
}): ɵɵInjectableDeclaration<T>;
|
|
69
|
+
export type Constructor<T> = Function & {
|
|
70
|
+
prototype: T;
|
|
71
|
+
};
|
|
72
|
+
export declare function registerInjectable<T>(ctor: unknown, declaration: ɵɵInjectableDeclaration<T>): InjectionToken<T>;
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
import { InjectionToken } from './injection_token';
|
|
8
|
+
import { Constructor, InjectionToken } from './injection_token';
|
|
9
9
|
import { NotFound } from './not_found';
|
|
10
10
|
export interface Injector {
|
|
11
11
|
retrieve<T>(token: InjectionToken<T>, options?: unknown): T | NotFound;
|
|
12
12
|
}
|
|
13
13
|
export declare function getCurrentInjector(): Injector | undefined | null;
|
|
14
14
|
export declare function setCurrentInjector(injector: Injector | null | undefined): Injector | undefined | null;
|
|
15
|
+
export declare function inject<T>(token: InjectionToken<T> | Constructor<T>): T;
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
export { ComputedNode, createComputed } from './src/computed';
|
|
9
|
-
export { ComputationFn, LinkedSignalNode, LinkedSignalGetter, createLinkedSignal, linkedSignalSetFn, linkedSignalUpdateFn } from './src/linked_signal';
|
|
9
|
+
export { ComputationFn, LinkedSignalNode, LinkedSignalGetter, PreviousValue, createLinkedSignal, linkedSignalSetFn, linkedSignalUpdateFn } from './src/linked_signal';
|
|
10
10
|
export { ValueEqualityFn, defaultEquals } from './src/equality';
|
|
11
11
|
export { setThrowInvalidWriteToSignalError } from './src/errors';
|
|
12
|
-
export { REACTIVE_NODE, Reactive, ReactiveHookFn, ReactiveNode, SIGNAL, consumerAfterComputation, consumerBeforeComputation, consumerDestroy, consumerMarkDirty, consumerPollProducersForChange, getActiveConsumer, isInNotificationPhase, isReactive, producerAccessed, producerIncrementEpoch, producerMarkClean, producerNotifyConsumers, producerUpdateValueVersion, producerUpdatesAllowed, runPostProducerCreatedFn, setActiveConsumer, setPostProducerCreatedFn, } from './src/graph';
|
|
12
|
+
export { REACTIVE_NODE, Reactive, ReactiveHookFn, ReactiveNode, SIGNAL, consumerAfterComputation, consumerBeforeComputation, consumerDestroy, consumerMarkDirty, consumerPollProducersForChange, finalizeConsumerAfterComputation, getActiveConsumer, isInNotificationPhase, isReactive, producerAccessed, producerIncrementEpoch, producerMarkClean, producerNotifyConsumers, producerUpdateValueVersion, producerUpdatesAllowed, resetConsumerBeforeComputation, runPostProducerCreatedFn, setActiveConsumer, setPostProducerCreatedFn, Version, } from './src/graph';
|
|
13
13
|
export { SIGNAL_NODE, SignalGetter, SignalNode, createSignal, runPostSignalSetFn, setPostSignalSetFn, signalGetFn, signalSetFn, signalUpdateFn } from './src/signal';
|
|
14
14
|
export { Watch, WatchCleanupFn, WatchCleanupRegisterFn, createWatch } from './src/watch';
|
|
15
15
|
export { setAlternateWeakRefImpl } from './src/weak_ref';
|
|
16
16
|
export { untracked } from './src/untracked';
|
|
17
|
+
export { runEffect, BASE_EFFECT_NODE, BaseEffectNode } from './src/effect';
|
|
18
|
+
export { installDevToolsSignalFormatter } from './src/formatter';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { ReactiveNode } from './graph';
|
|
9
|
+
/**
|
|
10
|
+
* An effect can, optionally, register a cleanup function. If registered, the cleanup is executed
|
|
11
|
+
* before the next effect run. The cleanup function makes it possible to "cancel" any work that the
|
|
12
|
+
* previous effect run might have started.
|
|
13
|
+
*/
|
|
14
|
+
export type EffectCleanupFn = () => void;
|
|
15
|
+
/**
|
|
16
|
+
* A callback passed to the effect function that makes it possible to register cleanup logic.
|
|
17
|
+
*/
|
|
18
|
+
export type EffectCleanupRegisterFn = (cleanupFn: EffectCleanupFn) => void;
|
|
19
|
+
export interface BaseEffectNode extends ReactiveNode {
|
|
20
|
+
fn: () => void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
cleanup(): void;
|
|
23
|
+
run(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const BASE_EFFECT_NODE: Omit<BaseEffectNode, 'fn' | 'destroy' | 'cleanup' | 'run'>;
|
|
26
|
+
export declare function runEffect(node: BaseEffectNode): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
declare global {
|
|
9
|
+
var devtoolsFormatters: any[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Installs the custom formatter into custom formatting on Signals in the devtools.
|
|
13
|
+
*
|
|
14
|
+
* Supported by both Chrome and Firefox.
|
|
15
|
+
*
|
|
16
|
+
* @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
|
|
17
|
+
*/
|
|
18
|
+
export declare function installDevToolsSignalFormatter(): void;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
type Version = number & {
|
|
8
|
+
export type Version = number & {
|
|
9
9
|
__brand: 'Version';
|
|
10
10
|
};
|
|
11
11
|
export type ReactiveHookFn = (node: ReactiveNode) => void;
|
|
@@ -23,6 +23,14 @@ export interface Reactive {
|
|
|
23
23
|
}
|
|
24
24
|
export declare function isReactive(value: unknown): value is Reactive;
|
|
25
25
|
export declare const REACTIVE_NODE: ReactiveNode;
|
|
26
|
+
interface ReactiveLink {
|
|
27
|
+
producer: ReactiveNode;
|
|
28
|
+
consumer: ReactiveNode;
|
|
29
|
+
lastReadVersion: number;
|
|
30
|
+
prevConsumer: ReactiveLink | undefined;
|
|
31
|
+
nextConsumer: ReactiveLink | undefined;
|
|
32
|
+
nextProducer: ReactiveLink | undefined;
|
|
33
|
+
}
|
|
26
34
|
/**
|
|
27
35
|
* A producer and/or consumer which participates in the reactive graph.
|
|
28
36
|
*
|
|
@@ -58,47 +66,26 @@ export interface ReactiveNode {
|
|
|
58
66
|
*/
|
|
59
67
|
dirty: boolean;
|
|
60
68
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* Uses the same indices as the `producerLastReadVersion` and `producerIndexOfThis` arrays.
|
|
64
|
-
*/
|
|
65
|
-
producerNode: ReactiveNode[] | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* `Version` of the value last read by a given producer.
|
|
68
|
-
*
|
|
69
|
-
* Uses the same indices as the `producerNode` and `producerIndexOfThis` arrays.
|
|
69
|
+
* Whether this node is currently rebuilding its producer list.
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
recomputing: boolean;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* This value is only meaningful if this node is live (`liveConsumers.length > 0`). Otherwise
|
|
76
|
-
* these indices are stale.
|
|
77
|
-
*
|
|
78
|
-
* Uses the same indices as the `producerNode` and `producerLastReadVersion` arrays.
|
|
79
|
-
*/
|
|
80
|
-
producerIndexOfThis: number[] | undefined;
|
|
81
|
-
/**
|
|
82
|
-
* Index into the producer arrays that the next dependency of this node as a consumer will use.
|
|
83
|
-
*
|
|
84
|
-
* This index is zeroed before this node as a consumer begins executing. When a producer is read,
|
|
85
|
-
* it gets inserted into the producers arrays at this index. There may be an existing dependency
|
|
86
|
-
* in this location which may or may not match the incoming producer, depending on whether the
|
|
87
|
-
* same producers were read in the same order as the last computation.
|
|
73
|
+
* Producers which are dependencies of this consumer.
|
|
88
74
|
*/
|
|
89
|
-
|
|
75
|
+
producers: ReactiveLink | undefined;
|
|
90
76
|
/**
|
|
91
|
-
*
|
|
77
|
+
* Points to the last linked list node in the `producers` linked list.
|
|
92
78
|
*
|
|
93
|
-
*
|
|
79
|
+
* When this node is recomputing, this is used to track the producers that we have accessed so far.
|
|
94
80
|
*/
|
|
95
|
-
|
|
81
|
+
producersTail: ReactiveLink | undefined;
|
|
96
82
|
/**
|
|
97
|
-
*
|
|
83
|
+
* Linked list of consumers of this producer that are "live" (they require push notifications).
|
|
98
84
|
*
|
|
99
|
-
*
|
|
85
|
+
* The length of this list is effectively our reference count for this node.
|
|
100
86
|
*/
|
|
101
|
-
|
|
87
|
+
consumers: ReactiveLink | undefined;
|
|
88
|
+
consumersTail: ReactiveLink | undefined;
|
|
102
89
|
/**
|
|
103
90
|
* Whether writes to signals are allowed when this consumer is the `activeConsumer`.
|
|
104
91
|
*
|
|
@@ -158,19 +145,39 @@ export declare function producerUpdatesAllowed(): boolean;
|
|
|
158
145
|
export declare function consumerMarkDirty(node: ReactiveNode): void;
|
|
159
146
|
export declare function producerMarkClean(node: ReactiveNode): void;
|
|
160
147
|
/**
|
|
161
|
-
* Prepare this consumer to run a computation in its reactive context
|
|
148
|
+
* Prepare this consumer to run a computation in its reactive context and set
|
|
149
|
+
* it as the active consumer.
|
|
162
150
|
*
|
|
163
151
|
* Must be called by subclasses which represent reactive computations, before those computations
|
|
164
152
|
* begin.
|
|
165
153
|
*/
|
|
166
154
|
export declare function consumerBeforeComputation(node: ReactiveNode | null): ReactiveNode | null;
|
|
167
155
|
/**
|
|
168
|
-
*
|
|
156
|
+
* Prepare this consumer to run a computation in its reactive context.
|
|
157
|
+
*
|
|
158
|
+
* We expose this mainly for code where we manually batch effects into a single
|
|
159
|
+
* consumer. In those cases we may wish to "reopen" a consumer multiple times
|
|
160
|
+
* in initial render before finalizing it. Most code should just call
|
|
161
|
+
* `consumerBeforeComputation` instead of calling this directly.
|
|
162
|
+
*/
|
|
163
|
+
export declare function resetConsumerBeforeComputation(node: ReactiveNode): void;
|
|
164
|
+
/**
|
|
165
|
+
* Finalize this consumer's state and set previous consumer as the active consumer after a
|
|
166
|
+
* reactive computation has run.
|
|
169
167
|
*
|
|
170
168
|
* Must be called by subclasses which represent reactive computations, after those computations
|
|
171
169
|
* have finished.
|
|
172
170
|
*/
|
|
173
171
|
export declare function consumerAfterComputation(node: ReactiveNode | null, prevConsumer: ReactiveNode | null): void;
|
|
172
|
+
/**
|
|
173
|
+
* Finalize this consumer's state after a reactive computation has run.
|
|
174
|
+
*
|
|
175
|
+
* We expose this mainly for code where we manually batch effects into a single
|
|
176
|
+
* consumer. In those cases we may wish to "reopen" a consumer multiple times
|
|
177
|
+
* in initial render before finalizing it. Most code should just call
|
|
178
|
+
* `consumerAfterComputation` instead of calling this directly.
|
|
179
|
+
*/
|
|
180
|
+
export declare function finalizeConsumerAfterComputation(node: ReactiveNode): void;
|
|
174
181
|
/**
|
|
175
182
|
* Determine whether this consumer has any dependencies which have changed since the last time
|
|
176
183
|
* they were read.
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { ValueEqualityFn } from './equality';
|
|
9
9
|
import { ReactiveNode, SIGNAL } from './graph';
|
|
10
|
-
export type ComputationFn<S, D> = (source: S, previous?:
|
|
10
|
+
export type ComputationFn<S, D> = (source: S, previous?: PreviousValue<S, D>) => D;
|
|
11
|
+
export type PreviousValue<S, D> = {
|
|
11
12
|
source: S;
|
|
12
13
|
value: D;
|
|
13
|
-
}
|
|
14
|
+
};
|
|
14
15
|
export interface LinkedSignalNode<S, D> extends ReactiveNode {
|
|
15
16
|
/**
|
|
16
17
|
* Value of the source signal that was used to derive the computed value.
|
|
@@ -34,7 +34,6 @@ export interface Watch {
|
|
|
34
34
|
[SIGNAL]: WatchNode;
|
|
35
35
|
}
|
|
36
36
|
export interface WatchNode extends ReactiveNode {
|
|
37
|
-
hasRun: boolean;
|
|
38
37
|
fn: ((onCleanup: WatchCleanupRegisterFn) => void) | null;
|
|
39
38
|
schedule: ((watch: Watch) => void) | null;
|
|
40
39
|
cleanupFn: WatchCleanupFn;
|