@supacloud/app 0.5.0 → 0.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/dist/inject.d.ts CHANGED
@@ -1,68 +1,29 @@
1
+ import { type InjectOptions } from "@angular/core";
1
2
  import type { EnvironmentProviders, Provider, Token } from "./provider";
2
3
  import { InjectionToken } from "./token";
3
- export interface InjectFlags {
4
- /** If true, returns undefined instead of throwing when token is not found. */
5
- optional?: boolean;
6
- /** If true, requires token to be resolved from current local injector. */
7
- self?: boolean;
8
- /** If true, skips current local injector and resolves from parent. */
9
- skipSelf?: boolean;
10
- /** If true, resolves from host injector. */
11
- host?: boolean;
12
- }
4
+ export type InjectFlags = InjectOptions;
13
5
  export interface InjectorLike {
14
6
  get<T>(token: Token<T>, options?: InjectFlags): T | undefined;
7
+ get<T>(token: Token<T>, notFoundValue: T, options?: InjectFlags): T;
15
8
  readonly parent?: InjectorLike;
16
9
  }
17
- /**
18
- * Returns the current active Injector context, or null if not inside an injection context.
19
- */
20
10
  export declare function getActiveInjector(): InjectorLike | null;
21
11
  /**
22
- * Built-in injection token for resolving the active injector instance.
23
- * Modeled directly after Angular's INJECTOR token.
12
+ * Compatibility token backed by Angular's public Injector token.
13
+ * The compiler does not use this token; it is provided for runtime/TestBed APIs.
24
14
  */
25
15
  export declare const INJECTOR: InjectionToken<InjectorLike>;
26
- /**
27
- * Executes a function within the scope of a specific injector.
28
- * Modeled directly after Angular's `runInInjectionContext(injector, fn)`.
29
- */
30
16
  export declare function runInInjectionContext<R>(injector: InjectorLike, fn: () => R): R;
31
17
  /**
32
- * Resolves a token from the currently active injection context.
33
- * Modeled directly after Angular's `inject(token)`.
34
- *
35
- * Can be used in:
36
- * 1. Property initializers of classes
37
- * 2. Constructors
38
- * 3. Functional route guards (CanActivateFn)
39
- * 4. Route resolvers (ResolveFn)
40
- * 5. Factory providers
41
- * 6. Code executed inside `runInInjectionContext`
18
+ * Angular is the source of truth for runtime injection semantics. This
19
+ * wrapper keeps the SupaCloud error contract for calls outside a context.
42
20
  */
43
21
  export declare function inject<T>(token: Token<T>, options?: InjectFlags): T;
44
- /**
45
- * Injects all instances registered for a multi-provider token.
46
- * Modeled after Angular's multi-provider injection.
47
- */
48
22
  export declare function injectAll<T>(token: Token<T>): T[];
49
- /**
50
- * Creates a hierarchical child injector that inherits providers from a parent injector.
51
- * Modeled directly after Angular's hierarchical injectors.
52
- */
53
23
  export declare function createChildInjector(parent: InjectorLike, localProviders?: Map<Token<unknown> | string, unknown> | Record<string, unknown>): InjectorLike & {
54
24
  readonly parent: InjectorLike;
55
25
  };
56
- /**
57
- * Asserts that execution is currently within an injection context.
58
- * Modeled after Angular's `assertInInjectionContext`.
59
- */
60
26
  export declare function assertInInjectionContext(fnName: string): void;
61
- /**
62
- * Injects the AbortSignal of the active DestroyRef.
63
- * Automatically aborted when the active context or service is destroyed.
64
- * Modeled after Angular's DestroyRef signal pattern.
65
- */
66
27
  export declare function injectDestroySignal(): AbortSignal;
67
28
  export interface EnvironmentInjector extends InjectorLike {
68
29
  get<T>(token: Token<T>, options?: InjectFlags): T;
@@ -73,9 +34,8 @@ export interface EnvironmentInjector extends InjectorLike {
73
34
  readonly parent?: InjectorLike;
74
35
  }
75
36
  /**
76
- * Creates an EnvironmentInjector with an isolated dependency scope and lifecycle.
77
- * Modeled directly after Angular 14+ createEnvironmentInjector.
78
- * Automatically executes all ENVIRONMENT_INITIALIZER / APP_INITIALIZER hooks upon creation,
79
- * and executes DestroyRef teardowns and OnDestroy hooks upon destroy().
37
+ * Runtime compatibility adapter over Angular's public EnvironmentInjector.
38
+ * SupaCloud EnvironmentProviders are flattened before crossing the boundary;
39
+ * no Angular private API is referenced.
80
40
  */
81
41
  export declare function createEnvironmentInjector(providers: Array<Provider | EnvironmentProviders>, parent?: InjectorLike): EnvironmentInjector;
@@ -7,6 +7,14 @@ export interface Type<T> {
7
7
  }
8
8
  /** Anything that can identify a provider: an InjectionToken or a class. */
9
9
  export type Token<T = any> = InjectionToken<T> | Type<T> | ForwardRefFn<InjectionToken<T> | Type<T>>;
10
+ export interface ProviderDependency {
11
+ token: Token;
12
+ optional?: boolean;
13
+ self?: boolean;
14
+ skipSelf?: boolean;
15
+ host?: boolean;
16
+ }
17
+ export type ProviderDep = Token | ProviderDependency;
10
18
  interface BaseProvider {
11
19
  /** Overrides the scope derived from @Injectable / token defaults. */
12
20
  scope?: Scope;
@@ -19,7 +27,7 @@ export interface ClassProvider<T = any> extends BaseProvider {
19
27
  provide: Token<T>;
20
28
  useClass: Type<T> | ForwardRefFn<Type<T>>;
21
29
  /** Explicit dependency tokens, positional (constructor order). */
22
- deps?: Token[];
30
+ deps?: ProviderDep[];
23
31
  }
24
32
  export interface ValueProvider<T = any> extends BaseProvider {
25
33
  provide: Token<T>;
@@ -28,7 +36,7 @@ export interface ValueProvider<T = any> extends BaseProvider {
28
36
  export interface FactoryProvider<T = any> extends BaseProvider {
29
37
  provide: Token<T>;
30
38
  useFactory: (...deps: any[]) => T;
31
- deps?: Token[];
39
+ deps?: ProviderDep[];
32
40
  }
33
41
  export interface ExistingProvider<T = any> extends BaseProvider {
34
42
  provide: Token<T>;
@@ -42,12 +50,15 @@ export declare function isFactoryProvider<T>(provider: Provider<T>): provider is
42
50
  export declare function isExistingProvider<T>(provider: Provider<T>): provider is ExistingProvider<T>;
43
51
  /**
44
52
  * Encapsulates a set of providers created by functional provideXxx APIs.
45
- * Modeled directly after Angular's EnvironmentProviders.
53
+ *
54
+ * This is intentionally a SupaCloud-owned representation. It is converted
55
+ * to Angular providers at the runtime boundary instead of exposing Angular's
56
+ * private provider-storage detail as a public contract.
46
57
  */
47
58
  export interface EnvironmentProviders {
48
- ɵproviders: Provider[];
59
+ readonly providers: Array<Provider | EnvironmentProviders>;
49
60
  }
50
- export declare function makeEnvironmentProviders(providers: Provider[]): EnvironmentProviders;
61
+ export declare function makeEnvironmentProviders(providers: Array<Provider | EnvironmentProviders>): EnvironmentProviders;
51
62
  export declare function isEnvironmentProviders(value: unknown): value is EnvironmentProviders;
52
63
  export declare function flattenProviders(providers: Array<Provider | EnvironmentProviders>): Provider[];
53
64
  /**
package/dist/testing.d.ts CHANGED
@@ -14,7 +14,6 @@ export declare class TestBed {
14
14
  private static declaredProviders;
15
15
  private static overriddenProviders;
16
16
  private static activeInjector;
17
- private static instances;
18
17
  /**
19
18
  * Configures the testing module with providers and imports.
20
19
  */
package/dist/token.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Scope } from "./scope";
2
+ import { InjectionToken as AngularInjectionToken } from "@angular/core";
2
3
  export interface InjectionTokenOptions<T> {
3
4
  /** Optional default factory used when no explicit provider is registered. */
4
5
  factory?: () => T;
@@ -11,7 +12,7 @@ export interface InjectionTokenOptions<T> {
11
12
  * Lightweight injection token, modeled after Angular's tree-shakable tokens.
12
13
  * Used as a DI key for interfaces and values that are not classes.
13
14
  */
14
- export declare class InjectionToken<T> {
15
+ export declare class InjectionToken<T> extends AngularInjectionToken<T> {
15
16
  readonly name: string;
16
17
  readonly factory?: () => T;
17
18
  readonly providedIn?: "root";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/app",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Angular-style application metadata for SupaCloud: modules, DI tokens, providers, scopes, controllers and commands",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,6 +40,9 @@
40
40
  "url": "https://github.com/vibeunion/supacloud.git",
41
41
  "directory": "packages/app"
42
42
  },
43
+ "dependencies": {
44
+ "@angular/core": "^22.1.5"
45
+ },
43
46
  "devDependencies": {
44
47
  "@types/bun": "^1.4.0",
45
48
  "typescript": "^7.0.2"