static-injector 6.0.3 → 6.1.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.
Files changed (42) hide show
  1. package/import/change_detection/scheduling/zoneless_scheduling.d.ts +1 -1
  2. package/import/core_reactivity_export_internal.d.ts +3 -4
  3. package/import/di/forward_ref.d.ts +9 -7
  4. package/import/di/inject_switch.d.ts +4 -4
  5. package/import/di/injector.d.ts +12 -17
  6. package/import/di/injector_compatibility.d.ts +24 -18
  7. package/import/di/interface/injector.d.ts +13 -17
  8. package/import/di/metadata.d.ts +7 -0
  9. package/import/di/provider_collection.d.ts +2 -42
  10. package/import/di/r3_injector.d.ts +10 -11
  11. package/import/error_handler.d.ts +5 -0
  12. package/import/errors.d.ts +11 -1
  13. package/import/index.d.ts +3 -0
  14. package/import/linker/destroy_ref.d.ts +2 -0
  15. package/import/pending_tasks.d.ts +15 -16
  16. package/import/render3/errors_di.d.ts +2 -0
  17. package/import/render3/reactivity/api.d.ts +5 -1
  18. package/import/render3/reactivity/asserts.d.ts +1 -1
  19. package/import/render3/reactivity/effect.d.ts +10 -22
  20. package/import/render3/reactivity/linked_signal.d.ts +3 -3
  21. package/import/render3/reactivity/root_effect_scheduler.d.ts +4 -1
  22. package/import/render3/reactivity/signal.d.ts +3 -1
  23. package/import/resource/api.d.ts +35 -50
  24. package/import/resource/resource.d.ts +9 -7
  25. package/index.js +464 -623
  26. package/index.js.map +4 -4
  27. package/index.mjs +458 -619
  28. package/index.mjs.map +4 -4
  29. package/package.json +2 -2
  30. package/primitives/di/index.d.ts +12 -0
  31. package/primitives/di/src/injection_token.d.ts +63 -0
  32. package/primitives/di/src/injector.d.ts +14 -0
  33. package/primitives/di/src/not_found.d.ts +28 -0
  34. package/primitives/di/src/type.d.ts +61 -0
  35. package/primitives/signals/index.d.ts +5 -4
  36. package/primitives/signals/src/computed.d.ts +1 -1
  37. package/primitives/signals/src/graph.d.ts +3 -0
  38. package/primitives/signals/src/linked_signal.d.ts +2 -29
  39. package/primitives/signals/src/signal.d.ts +8 -6
  40. package/{import/render3/reactivity/patch.d.ts → primitives/signals/src/untracked.d.ts} +3 -2
  41. package/readme.md +1 -1
  42. package/import/render3/reactivity/microtask_effect.d.ts +0 -21
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "static-injector",
3
- "version": "6.0.3",
3
+ "version": "6.1.0",
4
4
  "description": "Angular 依赖注入独立版本;Angular dependency injection standalone version",
5
5
  "keywords": [
6
6
  "angular",
7
- "angular 19.2.0",
7
+ "angular 20.0.2",
8
8
  "injector",
9
9
  "typescript",
10
10
  "injectable",
@@ -0,0 +1,12 @@
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
+ export { setCurrentInjector, getCurrentInjector } from './src/injector';
9
+ export type { Injector } from './src/injector';
10
+ export { NOT_FOUND, NotFoundError, isNotFound } from './src/not_found';
11
+ export type { NotFound } from './src/not_found';
12
+ export type { InjectionToken, ɵɵInjectableDeclaration } from './src/injection_token';
@@ -0,0 +1,63 @@
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 { Type } from './type';
9
+ /**
10
+ * Information about how a type or `InjectionToken` interfaces with the DI
11
+ * system. This describes:
12
+ *
13
+ * 1. *How* the type is provided
14
+ * The declaration must specify only one of the following:
15
+ * - A `value` which is a predefined instance of the type.
16
+ * - A `factory` which defines how to create the given type `T`, possibly
17
+ * requesting injection of other types if necessary.
18
+ * - Neither, in which case the type is expected to already be present in the
19
+ * injector hierarchy. This is used for internal use cases.
20
+ *
21
+ * 2. *Where* the type is stored (if it is stored)
22
+ * - The `providedIn` parameter specifies which injector the type belongs to.
23
+ * - The `token` is used as the key to store the type in the injector.
24
+ */
25
+ export interface ɵɵInjectableDeclaration<T> {
26
+ /**
27
+ * Specifies that the given type belongs to a particular `Injector`,
28
+ * `NgModule`, or a special scope (e.g. `'root'`).
29
+ *
30
+ * `any` is deprecated and will be removed soon.
31
+ *
32
+ * A value of `null` indicates that the injectable does not belong to any
33
+ * scope, and won't be stored in any injector. For declarations with a
34
+ * factory, this will create a new instance of the type each time it is
35
+ * requested.
36
+ */
37
+ providedIn: Type<any> | 'root' | 'platform' | 'any' | null;
38
+ /**
39
+ * The token to which this definition belongs.
40
+ *
41
+ * Note that this may not be the same as the type that the `factory` will create.
42
+ */
43
+ token: unknown;
44
+ /**
45
+ * Factory method to execute to create an instance of the injectable.
46
+ */
47
+ factory?: (t?: Type<any>) => T;
48
+ /**
49
+ * In a case of no explicit injector, a location where the instance of the injectable is stored.
50
+ */
51
+ value?: T;
52
+ }
53
+ /**
54
+ * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
55
+ *
56
+ * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
57
+ * `InjectorDef`-based `StaticInjector`.
58
+ *
59
+ * @publicApi
60
+ */
61
+ export interface InjectionToken<T> {
62
+ ɵprov: ɵɵInjectableDeclaration<T>;
63
+ }
@@ -0,0 +1,14 @@
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 { InjectionToken } from './injection_token';
9
+ import { NotFound } from './not_found';
10
+ export interface Injector {
11
+ retrieve<T>(token: InjectionToken<T>, options?: unknown): T | NotFound;
12
+ }
13
+ export declare function getCurrentInjector(): Injector | undefined | null;
14
+ export declare function setCurrentInjector(injector: Injector | null | undefined): Injector | undefined | null;
@@ -0,0 +1,28 @@
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
+ /**
9
+ * Value returned if the key-value pair couldn't be found in the context
10
+ * hierarchy.
11
+ */
12
+ export declare const NOT_FOUND: unique symbol;
13
+ /**
14
+ * Error thrown when the key-value pair couldn't be found in the context
15
+ * hierarchy. Context can be attached below.
16
+ */
17
+ export declare class NotFoundError extends Error {
18
+ readonly name: string;
19
+ constructor(message: string);
20
+ }
21
+ /**
22
+ * Type guard for checking if an unknown value is a NotFound.
23
+ */
24
+ export declare function isNotFound(e: unknown): e is NotFound;
25
+ /**
26
+ * Type union of NotFound and NotFoundError.
27
+ */
28
+ export type NotFound = typeof NOT_FOUND | NotFoundError;
@@ -0,0 +1,61 @@
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
+ /**
9
+ * @description
10
+ *
11
+ * Represents a type that a Component or other object is instances of.
12
+ *
13
+ * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is represented by
14
+ * the `MyCustomComponent` constructor function.
15
+ *
16
+ * @publicApi
17
+ */
18
+ export declare const Type: FunctionConstructor;
19
+ export declare function isType(v: any): v is Type<any>;
20
+ /**
21
+ * @description
22
+ *
23
+ * Represents an abstract class `T`, if applied to a concrete class it would stop being
24
+ * instantiable.
25
+ *
26
+ * @publicApi
27
+ */
28
+ export interface AbstractType<T> extends Function {
29
+ prototype: T;
30
+ }
31
+ export interface Type<T> extends Function {
32
+ new (...args: any[]): T;
33
+ }
34
+ /**
35
+ * Returns a writable type version of type.
36
+ *
37
+ * USAGE:
38
+ * Given:
39
+ * ```ts
40
+ * interface Person {readonly name: string}
41
+ * ```
42
+ *
43
+ * We would like to get a read/write version of `Person`.
44
+ * ```ts
45
+ * const WritablePerson = Writable<Person>;
46
+ * ```
47
+ *
48
+ * The result is that you can do:
49
+ *
50
+ * ```ts
51
+ * const readonlyPerson: Person = {name: 'Marry'};
52
+ * readonlyPerson.name = 'John'; // TypeError
53
+ * (readonlyPerson as WritablePerson).name = 'John'; // OK
54
+ *
55
+ * // Error: Correctly detects that `Person` did not have `age` property.
56
+ * (readonlyPerson as WritablePerson).age = 30;
57
+ * ```
58
+ */
59
+ export type Writable<T> = {
60
+ -readonly [K in keyof T]: T[K];
61
+ };
@@ -6,10 +6,11 @@
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, 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, ReactiveNode, SIGNAL, consumerAfterComputation, consumerBeforeComputation, consumerDestroy, consumerMarkDirty, consumerPollProducersForChange, getActiveConsumer, isInNotificationPhase, isReactive, producerAccessed, producerIncrementEpoch, producerMarkClean, producerNotifyConsumers, producerUpdateValueVersion, producerUpdatesAllowed, setActiveConsumer, } from './src/graph';
13
- export { SIGNAL_NODE, SignalGetter, SignalNode, createSignal, runPostSignalSetFn, setPostSignalSetFn, signalSetFn, signalUpdateFn, } from './src/signal';
14
- export { Watch, WatchCleanupFn, WatchCleanupRegisterFn, createWatch, } from './src/watch';
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';
13
+ export { SIGNAL_NODE, SignalGetter, SignalNode, createSignal, runPostSignalSetFn, setPostSignalSetFn, signalGetFn, signalSetFn, signalUpdateFn } from './src/signal';
14
+ export { Watch, WatchCleanupFn, WatchCleanupRegisterFn, createWatch } from './src/watch';
15
15
  export { setAlternateWeakRefImpl } from './src/weak_ref';
16
+ export { untracked } from './src/untracked';
@@ -35,7 +35,7 @@ export type ComputedGetter<T> = (() => T) & {
35
35
  /**
36
36
  * Create a computed signal which derives a reactive value from an expression.
37
37
  */
38
- export declare function createComputed<T>(computation: () => T): ComputedGetter<T>;
38
+ export declare function createComputed<T>(computation: () => T, equal?: ValueEqualityFn<T>): ComputedGetter<T>;
39
39
  /**
40
40
  * A dedicated symbol used before a computed value has been calculated for the first time.
41
41
  * Explicitly typed as `any` so we can use it as signal's value.
@@ -8,6 +8,7 @@
8
8
  type Version = number & {
9
9
  __brand: 'Version';
10
10
  };
11
+ export type ReactiveHookFn = (node: ReactiveNode) => void;
11
12
  /**
12
13
  * Symbol used to tell `Signal`s apart from other functions.
13
14
  *
@@ -179,4 +180,6 @@ export declare function consumerPollProducersForChange(node: ReactiveNode): bool
179
180
  * Disconnect this consumer from the graph.
180
181
  */
181
182
  export declare function consumerDestroy(node: ReactiveNode): void;
183
+ export declare function runPostProducerCreatedFn(node: ReactiveNode): void;
184
+ export declare function setPostProducerCreatedFn(fn: ReactiveHookFn | null): ReactiveHookFn | null;
182
185
  export {};
@@ -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
- import { defaultEquals, ValueEqualityFn } from './equality';
8
+ import { ValueEqualityFn } from './equality';
9
9
  import { ReactiveNode, SIGNAL } from './graph';
10
10
  export type ComputationFn<S, D> = (source: S, previous?: {
11
11
  source: S;
@@ -42,31 +42,4 @@ export type LinkedSignalGetter<S, D> = (() => D) & {
42
42
  export declare function createLinkedSignal<S, D>(sourceFn: () => S, computationFn: ComputationFn<S, D>, equalityFn?: ValueEqualityFn<D>): LinkedSignalGetter<S, D>;
43
43
  export declare function linkedSignalSetFn<S, D>(node: LinkedSignalNode<S, D>, newValue: D): void;
44
44
  export declare function linkedSignalUpdateFn<S, D>(node: LinkedSignalNode<S, D>, updater: (value: D) => D): void;
45
- export declare const LINKED_SIGNAL_NODE: {
46
- value: any;
47
- dirty: boolean;
48
- error: null;
49
- equal: typeof defaultEquals;
50
- producerMustRecompute(node: LinkedSignalNode<unknown, unknown>): boolean;
51
- producerRecomputeValue(node: LinkedSignalNode<unknown, unknown>): void;
52
- version: number & {
53
- __brand: "Version";
54
- };
55
- lastCleanEpoch: number & {
56
- __brand: "Version";
57
- };
58
- producerNode: ReactiveNode[] | undefined;
59
- producerLastReadVersion: (number & {
60
- __brand: "Version";
61
- })[] | undefined;
62
- producerIndexOfThis: number[] | undefined;
63
- nextProducerIndex: number;
64
- liveConsumerNode: ReactiveNode[] | undefined;
65
- liveConsumerIndexOfThis: number[] | undefined;
66
- consumerAllowSignalWrites: boolean;
67
- consumerIsAlwaysLive: boolean;
68
- consumerMarkedDirty(node: unknown): void;
69
- consumerOnSignalRead(node: unknown): void;
70
- debugName?: string;
71
- kind: string;
72
- };
45
+ export declare const LINKED_SIGNAL_NODE: object;
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { ValueEqualityFn } from './equality';
9
- import { ReactiveNode, SIGNAL } from './graph';
9
+ import { ReactiveNode, ReactiveHookFn, SIGNAL } from './graph';
10
10
  export interface SignalNode<T> extends ReactiveNode {
11
11
  value: T;
12
12
  equal: ValueEqualityFn<T>;
@@ -14,16 +14,18 @@ export interface SignalNode<T> extends ReactiveNode {
14
14
  export type SignalBaseGetter<T> = (() => T) & {
15
15
  readonly [SIGNAL]: unknown;
16
16
  };
17
+ export type SignalSetter<T> = (newValue: T) => void;
18
+ export type SignalUpdater<T> = (updateFn: (value: T) => T) => void;
17
19
  export interface SignalGetter<T> extends SignalBaseGetter<T> {
18
20
  readonly [SIGNAL]: SignalNode<T>;
19
21
  }
20
22
  /**
21
- * Create a `Signal` that can be set or updated directly.
23
+ * Creates a `Signal` getter, setter, and updater function.
22
24
  */
23
- export declare function createSignal<T>(initialValue: T): SignalGetter<T>;
24
- export declare function setPostSignalSetFn(fn: (() => void) | null): (() => void) | null;
25
- export declare function signalGetFn<T>(this: SignalNode<T>): T;
25
+ export declare function createSignal<T>(initialValue: T, equal?: ValueEqualityFn<T>): [SignalGetter<T>, SignalSetter<T>, SignalUpdater<T>];
26
+ export declare function setPostSignalSetFn(fn: ReactiveHookFn | null): ReactiveHookFn | null;
27
+ export declare function signalGetFn<T>(node: SignalNode<T>): T;
26
28
  export declare function signalSetFn<T>(node: SignalNode<T>, newValue: T): void;
27
29
  export declare function signalUpdateFn<T>(node: SignalNode<T>, updater: (value: T) => T): void;
28
- export declare function runPostSignalSetFn(): void;
30
+ export declare function runPostSignalSetFn<T>(node: SignalNode<T>): void;
29
31
  export declare const SIGNAL_NODE: SignalNode<unknown>;
@@ -6,6 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  /**
9
- * Controls whether effects use the legacy `microtaskEffect` by default.
9
+ * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function
10
+ * can, optionally, return a value.
10
11
  */
11
- export declare const USE_MICROTASK_EFFECT_BY_DEFAULT = false;
12
+ export declare function untracked<T>(nonReactiveReadsFn: () => T): T;
package/readme.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  # Source
15
15
 
16
- - Angular 19.2.0
16
+ - Angular 20.0.2
17
17
 
18
18
  # Usage
19
19
 
@@ -1,21 +0,0 @@
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 type { CreateEffectOptions, EffectCleanupRegisterFn, EffectRef } from './effect';
9
- import { type SchedulableEffect, ZoneAwareEffectScheduler } from './root_effect_scheduler';
10
- export declare class MicrotaskEffectScheduler extends ZoneAwareEffectScheduler {
11
- private readonly pendingTasks;
12
- private taskId;
13
- schedule(effect: SchedulableEffect): void;
14
- flush(): void;
15
- /** @nocollapse */
16
- static ɵprov: unknown;
17
- }
18
- /**
19
- * Create a global `Effect` for the given reactive function.
20
- */
21
- export declare function microtaskEffect(effectFn: (onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef;