@supacloud/app 0.2.0 → 0.5.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/dist/context.d.ts +41 -0
- package/dist/decorators.d.ts +119 -5
- package/dist/forms.d.ts +122 -0
- package/dist/forward_ref.d.ts +16 -0
- package/dist/http_client.d.ts +53 -0
- package/dist/http_context.d.ts +16 -0
- package/dist/http_headers.d.ts +19 -0
- package/dist/http_params.d.ts +23 -0
- package/dist/index.d.ts +43 -5
- package/dist/index.js +2650 -15
- package/dist/inject.d.ts +81 -0
- package/dist/input_transform.d.ts +18 -0
- package/dist/interceptor.d.ts +33 -0
- package/dist/location.d.ts +15 -0
- package/dist/pipe.d.ts +45 -0
- package/dist/platform.d.ts +33 -0
- package/dist/provider.d.ts +32 -2
- package/dist/resource.d.ts +40 -0
- package/dist/route_match.d.ts +14 -0
- package/dist/route_pipeline.d.ts +74 -0
- package/dist/route_provider.d.ts +39 -0
- package/dist/signal.d.ts +48 -0
- package/dist/testing.d.ts +43 -0
- package/dist/title_strategy.d.ts +18 -0
- package/dist/token.d.ts +3 -0
- package/dist/transfer_state.d.ts +52 -0
- package/dist/url_tree.d.ts +31 -0
- package/package.json +1 -1
package/dist/inject.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { EnvironmentProviders, Provider, Token } from "./provider";
|
|
2
|
+
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
|
+
}
|
|
13
|
+
export interface InjectorLike {
|
|
14
|
+
get<T>(token: Token<T>, options?: InjectFlags): T | undefined;
|
|
15
|
+
readonly parent?: InjectorLike;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current active Injector context, or null if not inside an injection context.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getActiveInjector(): InjectorLike | null;
|
|
21
|
+
/**
|
|
22
|
+
* Built-in injection token for resolving the active injector instance.
|
|
23
|
+
* Modeled directly after Angular's INJECTOR token.
|
|
24
|
+
*/
|
|
25
|
+
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
|
+
export declare function runInInjectionContext<R>(injector: InjectorLike, fn: () => R): R;
|
|
31
|
+
/**
|
|
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`
|
|
42
|
+
*/
|
|
43
|
+
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
|
+
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
|
+
export declare function createChildInjector(parent: InjectorLike, localProviders?: Map<Token<unknown> | string, unknown> | Record<string, unknown>): InjectorLike & {
|
|
54
|
+
readonly parent: InjectorLike;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Asserts that execution is currently within an injection context.
|
|
58
|
+
* Modeled after Angular's `assertInInjectionContext`.
|
|
59
|
+
*/
|
|
60
|
+
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
|
+
export declare function injectDestroySignal(): AbortSignal;
|
|
67
|
+
export interface EnvironmentInjector extends InjectorLike {
|
|
68
|
+
get<T>(token: Token<T>, options?: InjectFlags): T;
|
|
69
|
+
get<T>(token: Token<T>, notFoundValue: T, options?: InjectFlags): T;
|
|
70
|
+
runInContext<R>(fn: () => R): R;
|
|
71
|
+
destroy(): void;
|
|
72
|
+
readonly destroyed: boolean;
|
|
73
|
+
readonly parent?: InjectorLike;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
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().
|
|
80
|
+
*/
|
|
81
|
+
export declare function createEnvironmentInjector(providers: Array<Provider | EnvironmentProviders>, parent?: InjectorLike): EnvironmentInjector;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular 16+ input transforms for parameter and attribute coercion.
|
|
3
|
+
* Directly modeled after Angular's booleanAttribute and numberAttribute.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Transforms an incoming value to a boolean following Angular booleanAttribute semantics:
|
|
7
|
+
* - boolean values are preserved
|
|
8
|
+
* - empty strings ('') and 'true' (or any truthy string except 'false') are coerced to true
|
|
9
|
+
* - 'false', false, null, and undefined are coerced to false
|
|
10
|
+
*/
|
|
11
|
+
export declare function booleanAttribute(value: unknown): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Transforms an incoming value to a number following Angular numberAttribute semantics:
|
|
14
|
+
* - number values are preserved (unless NaN)
|
|
15
|
+
* - valid numeric strings are parsed with parseFloat
|
|
16
|
+
* - invalid or non-numeric values fall back to fallbackValue (defaults to NaN)
|
|
17
|
+
*/
|
|
18
|
+
export declare function numberAttribute(value: unknown, fallbackValue?: number): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HttpContext } from "./http_context";
|
|
2
|
+
/**
|
|
3
|
+
* Angular-inspired functional HTTP interceptor pipeline.
|
|
4
|
+
* Modeled after Angular 15+ HttpInterceptorFn and withInterceptors API.
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpRequestPayload {
|
|
7
|
+
method: string;
|
|
8
|
+
url: string;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
context?: HttpContext;
|
|
12
|
+
}
|
|
13
|
+
export type HttpInterceptorFn = (req: HttpRequestPayload, next: (req: HttpRequestPayload) => Promise<Response>) => Promise<Response>;
|
|
14
|
+
/**
|
|
15
|
+
* Chains multiple functional interceptors into a single interceptor pipeline.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withInterceptors(...interceptors: HttpInterceptorFn[]): HttpInterceptorFn[];
|
|
18
|
+
/**
|
|
19
|
+
* Creates an interceptor that appends an Authorization: Bearer <token> header.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createBearerAuthInterceptor(tokenOrGetter: string | (() => string | Promise<string>)): HttpInterceptorFn;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an interceptor that merges static or dynamic headers.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createHeaderInterceptor(headers: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>)): HttpInterceptorFn;
|
|
26
|
+
/**
|
|
27
|
+
* Creates an interceptor that aborts the request after timeoutMs.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createTimeoutInterceptor(timeoutMs: number): HttpInterceptorFn;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an interceptor that retries on failed requests up to maxRetries.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createRetryInterceptor(maxRetries: number, delayMs?: number): HttpInterceptorFn;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a URL path by stripping duplicate slashes and ensuring single leading slash.
|
|
3
|
+
* Modeled directly after Angular's Location.normalize in @angular/common.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizePath(path: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Strips the trailing slash from a URL path, unless the path is root '/'.
|
|
8
|
+
* Modeled directly after Angular's Location.stripTrailingSlash.
|
|
9
|
+
*/
|
|
10
|
+
export declare function stripTrailingSlash(path: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Joins two path parts with a single slash.
|
|
13
|
+
* Modeled directly after Angular's Location.joinWithSlash.
|
|
14
|
+
*/
|
|
15
|
+
export declare function joinWithSlash(start: string, end: string): string;
|
package/dist/pipe.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular-style Pipes & Transformation Suite (@angular/core).
|
|
3
|
+
* Enables pure and declarative data transformations for route responses,
|
|
4
|
+
* payloads, and presentation layers.
|
|
5
|
+
*/
|
|
6
|
+
export interface PipeTransform<T = any, R = any> {
|
|
7
|
+
transform(value: T, ...args: any[]): R;
|
|
8
|
+
}
|
|
9
|
+
export interface PipeMetadata {
|
|
10
|
+
name: string;
|
|
11
|
+
pure?: boolean;
|
|
12
|
+
standalone?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function Pipe(options: PipeMetadata): ClassDecorator;
|
|
15
|
+
export declare function getPipeMetadata(target: any): PipeMetadata | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Transforms text to uppercase.
|
|
18
|
+
*/
|
|
19
|
+
export declare class UpperCasePipe implements PipeTransform<string | null | undefined, string> {
|
|
20
|
+
transform(value: string | null | undefined): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Transforms text to lowercase.
|
|
24
|
+
*/
|
|
25
|
+
export declare class LowerCasePipe implements PipeTransform<string | null | undefined, string> {
|
|
26
|
+
transform(value: string | null | undefined): string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Trims leading and trailing whitespace.
|
|
30
|
+
*/
|
|
31
|
+
export declare class TrimPipe implements PipeTransform<string | null | undefined, string> {
|
|
32
|
+
transform(value: string | null | undefined): string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Serializes value into a formatted JSON string.
|
|
36
|
+
*/
|
|
37
|
+
export declare class JsonPipe implements PipeTransform<unknown, string> {
|
|
38
|
+
transform(value: unknown, space?: number): string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Formats a Date or timestamp into an ISO string or localized string.
|
|
42
|
+
*/
|
|
43
|
+
export declare class DatePipe implements PipeTransform<Date | string | number | null | undefined, string> {
|
|
44
|
+
transform(value: Date | string | number | null | undefined, format?: "iso" | "locale"): string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InjectionToken } from "./token";
|
|
2
|
+
export declare const PLATFORM_SERVER_ID = "server";
|
|
3
|
+
export declare const PLATFORM_BROWSER_ID = "browser";
|
|
4
|
+
export declare const PLATFORM_EDGE_ID = "edge";
|
|
5
|
+
export type PlatformId = "server" | "browser" | "edge";
|
|
6
|
+
/**
|
|
7
|
+
* Detects the runtime execution platform.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectPlatform(): PlatformId;
|
|
10
|
+
/**
|
|
11
|
+
* A DI Token representing the main rendering context's Document.
|
|
12
|
+
* Modeled directly after Angular's DOCUMENT token in @angular/common.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DOCUMENT: InjectionToken<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Built-in injection token for platform identification.
|
|
17
|
+
* Modeled directly after Angular's PLATFORM_ID.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PLATFORM_ID: InjectionToken<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether a platform id represents a browser environment.
|
|
22
|
+
* Modeled directly after Angular's isPlatformBrowser.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isPlatformBrowser(platformId: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns whether a platform id represents a server-side environment (Node.js/Bun/Edge).
|
|
27
|
+
* Modeled directly after Angular's isPlatformServer.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isPlatformServer(platformId: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Returns whether a platform id represents an edge runtime environment.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isPlatformEdge(platformId: unknown): boolean;
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import type { InjectionToken } from "./token";
|
|
2
|
+
import type { ForwardRefFn } from "./forward_ref";
|
|
2
3
|
import type { Scope } from "./scope";
|
|
3
4
|
/** A class usable as a DI token / provider implementation. */
|
|
4
5
|
export interface Type<T> {
|
|
5
6
|
new (...args: any[]): T;
|
|
6
7
|
}
|
|
7
8
|
/** Anything that can identify a provider: an InjectionToken or a class. */
|
|
8
|
-
export type Token<T = any> = InjectionToken<T> | Type<T
|
|
9
|
+
export type Token<T = any> = InjectionToken<T> | Type<T> | ForwardRefFn<InjectionToken<T> | Type<T>>;
|
|
9
10
|
interface BaseProvider {
|
|
10
11
|
/** Overrides the scope derived from @Injectable / token defaults. */
|
|
11
12
|
scope?: Scope;
|
|
13
|
+
/**
|
|
14
|
+
* When true, multiple providers can contribute to this token as an array of instances (Angular multi-providers).
|
|
15
|
+
*/
|
|
16
|
+
multi?: boolean;
|
|
12
17
|
}
|
|
13
18
|
export interface ClassProvider<T = any> extends BaseProvider {
|
|
14
19
|
provide: Token<T>;
|
|
15
|
-
useClass: Type<T
|
|
20
|
+
useClass: Type<T> | ForwardRefFn<Type<T>>;
|
|
16
21
|
/** Explicit dependency tokens, positional (constructor order). */
|
|
17
22
|
deps?: Token[];
|
|
18
23
|
}
|
|
@@ -35,4 +40,29 @@ export declare function isClassProvider<T>(provider: Provider<T>): provider is C
|
|
|
35
40
|
export declare function isValueProvider<T>(provider: Provider<T>): provider is ValueProvider<T>;
|
|
36
41
|
export declare function isFactoryProvider<T>(provider: Provider<T>): provider is FactoryProvider<T>;
|
|
37
42
|
export declare function isExistingProvider<T>(provider: Provider<T>): provider is ExistingProvider<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Encapsulates a set of providers created by functional provideXxx APIs.
|
|
45
|
+
* Modeled directly after Angular's EnvironmentProviders.
|
|
46
|
+
*/
|
|
47
|
+
export interface EnvironmentProviders {
|
|
48
|
+
ɵproviders: Provider[];
|
|
49
|
+
}
|
|
50
|
+
export declare function makeEnvironmentProviders(providers: Provider[]): EnvironmentProviders;
|
|
51
|
+
export declare function isEnvironmentProviders(value: unknown): value is EnvironmentProviders;
|
|
52
|
+
export declare function flattenProviders(providers: Array<Provider | EnvironmentProviders>): Provider[];
|
|
53
|
+
/**
|
|
54
|
+
* Configures an application initializer function that executes during startup before accepting requests.
|
|
55
|
+
* Modeled after Angular's provideAppInitializer.
|
|
56
|
+
*/
|
|
57
|
+
export declare function provideAppInitializer(initializerFn: () => void | Promise<void>): EnvironmentProviders;
|
|
58
|
+
/**
|
|
59
|
+
* Configures an environment/application initializer that executes during startup before accepting requests.
|
|
60
|
+
* Modeled directly after Angular 15+ provideEnvironmentInitializer.
|
|
61
|
+
*/
|
|
62
|
+
export declare function provideEnvironmentInitializer(initializerFn: () => void | Promise<void>): EnvironmentProviders;
|
|
63
|
+
/**
|
|
64
|
+
* Functional provider helper to register an InjectionToken with a static value or factory.
|
|
65
|
+
* Modeled after Angular's provideToken pattern.
|
|
66
|
+
*/
|
|
67
|
+
export declare function provideToken<T>(token: Token<T>, value: T): EnvironmentProviders;
|
|
38
68
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Signal } from "./signal";
|
|
2
|
+
export type ResourceStatus = "idle" | "loading" | "resolved" | "error";
|
|
3
|
+
export interface ResourceLoaderParams<R> {
|
|
4
|
+
request: R;
|
|
5
|
+
abortSignal: AbortSignal;
|
|
6
|
+
previous?: {
|
|
7
|
+
status: ResourceStatus;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ResourceOptions<T, R = unknown> {
|
|
11
|
+
/** Reactive request getter. Re-executes loader whenever signals read inside change. */
|
|
12
|
+
request?: () => R;
|
|
13
|
+
/** Asynchronous loader that fetches data for the request. */
|
|
14
|
+
loader: (params: ResourceLoaderParams<R>) => Promise<T>;
|
|
15
|
+
/** Optional initial value before first load resolves. */
|
|
16
|
+
initialValue?: T;
|
|
17
|
+
}
|
|
18
|
+
export interface ResourceRef<T> {
|
|
19
|
+
/** The current loaded value, or undefined if not yet resolved. */
|
|
20
|
+
readonly value: Signal<T | undefined>;
|
|
21
|
+
/** The current lifecycle status: 'idle' | 'loading' | 'resolved' | 'error'. */
|
|
22
|
+
readonly status: Signal<ResourceStatus>;
|
|
23
|
+
/** The error encountered during the last load, if any. */
|
|
24
|
+
readonly error: Signal<unknown | undefined>;
|
|
25
|
+
/** Boolean indicating whether a load is currently in progress. */
|
|
26
|
+
readonly isLoading: Signal<boolean>;
|
|
27
|
+
/** Triggers a reload using the current request. */
|
|
28
|
+
reload(): void;
|
|
29
|
+
/** Sets the value directly, transitioning status to 'resolved'. */
|
|
30
|
+
set(value: T): void;
|
|
31
|
+
/** Updates the value directly using a transformation function. */
|
|
32
|
+
update(updateFn: (current: T | undefined) => T): void;
|
|
33
|
+
/** Destroys the resource, aborting any active requests and disposing internal effects. */
|
|
34
|
+
destroy(): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates an asynchronous resource driven by reactive signals.
|
|
38
|
+
* Modeled directly after Angular 19's resource() API.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resource<T, R = unknown>(options: ResourceOptions<T, R>): ResourceRef<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of matching a URL against a route pattern.
|
|
3
|
+
* Modeled after Angular Router's UrlMatcher / UrlSegment matching.
|
|
4
|
+
*/
|
|
5
|
+
export interface RouteMatchResult {
|
|
6
|
+
matched: boolean;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
remainingUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Matches a URL against a parameterized route pattern (e.g. `/users/:id/edit`).
|
|
12
|
+
* Supports Angular-style `pathMatch: "full" | "prefix"`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchRoute(pattern: string, url: string, strategy?: "full" | "prefix"): RouteMatchResult;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CanActivateFn, CanDeactivateFn, CanMatchFn, ResolveFn } from "./decorators";
|
|
2
|
+
import { type TitleStrategy } from "./title_strategy";
|
|
3
|
+
export interface NavigationExtras {
|
|
4
|
+
status?: number;
|
|
5
|
+
skipLocationChange?: boolean;
|
|
6
|
+
queryParams?: Record<string, unknown>;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Angular 18+ RedirectCommand for functional guards, resolvers, and handlers.
|
|
11
|
+
* Allows returning a redirect destination directly from route pipelines.
|
|
12
|
+
*/
|
|
13
|
+
export declare class RedirectCommand {
|
|
14
|
+
readonly redirectTo: string | {
|
|
15
|
+
toString(): string;
|
|
16
|
+
};
|
|
17
|
+
readonly navigationExtras?: NavigationExtras | undefined;
|
|
18
|
+
constructor(redirectTo: string | {
|
|
19
|
+
toString(): string;
|
|
20
|
+
}, navigationExtras?: NavigationExtras | undefined);
|
|
21
|
+
}
|
|
22
|
+
export declare function isRedirectCommand(val: unknown): val is RedirectCommand;
|
|
23
|
+
export interface RoutePipelineContext {
|
|
24
|
+
url: string;
|
|
25
|
+
method: string;
|
|
26
|
+
params?: Record<string, string>;
|
|
27
|
+
query?: Record<string, unknown>;
|
|
28
|
+
body?: unknown;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
resolved?: Record<string, unknown>;
|
|
31
|
+
data?: Record<string, unknown>;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface RoutePipelineDefinition {
|
|
35
|
+
path: string;
|
|
36
|
+
method: string;
|
|
37
|
+
handler: ((...args: any[]) => any) | string;
|
|
38
|
+
guards?: Array<CanActivateFn | string>;
|
|
39
|
+
canMatch?: Array<CanMatchFn | string>;
|
|
40
|
+
canDeactivate?: Array<CanDeactivateFn | string>;
|
|
41
|
+
resolvers?: Record<string, ResolveFn | string>;
|
|
42
|
+
title?: string;
|
|
43
|
+
data?: Record<string, unknown>;
|
|
44
|
+
invoker?: (controller: unknown, request: RoutePipelineContext) => Promise<unknown> | unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface RoutePipelineResult<T = unknown> {
|
|
47
|
+
matched: boolean;
|
|
48
|
+
status: number;
|
|
49
|
+
body?: T;
|
|
50
|
+
error?: string;
|
|
51
|
+
resolvedData?: Record<string, unknown>;
|
|
52
|
+
redirect?: string;
|
|
53
|
+
headers?: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
export type RouterEventType = "NavigationStart" | "RoutesRecognized" | "GuardsCheckStart" | "GuardsCheckEnd" | "ResolveStart" | "ResolveEnd" | "ExecutionStart" | "ExecutionEnd" | "NavigationEnd" | "NavigationCancel" | "NavigationError";
|
|
56
|
+
export interface RouterEvent {
|
|
57
|
+
type: RouterEventType;
|
|
58
|
+
url: string;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
data?: unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface RoutePipelineOptions {
|
|
63
|
+
onEvent?: (event: RouterEvent) => void;
|
|
64
|
+
titleStrategy?: TitleStrategy;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Executes a full route lifecycle pipeline matching Angular Router execution semantics:
|
|
68
|
+
* 1. canMatch guards check if route can match
|
|
69
|
+
* 2. canActivate guards check access permissions
|
|
70
|
+
* 3. resolvers prefetch data concurrently
|
|
71
|
+
* 4. handler executes
|
|
72
|
+
* 5. canDeactivate guards check teardown/exit safety
|
|
73
|
+
*/
|
|
74
|
+
export declare function executeRoutePipeline<T = unknown>(route: RoutePipelineDefinition, ctx: RoutePipelineContext, componentInstance?: any, options?: RoutePipelineOptions): Promise<RoutePipelineResult<T>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InjectionToken } from "./token";
|
|
2
|
+
import type { EnvironmentProviders, Provider, Type } from "./provider";
|
|
3
|
+
import type { RouteDefinition } from "./decorators";
|
|
4
|
+
import { type TitleStrategy } from "./title_strategy";
|
|
5
|
+
export declare const ROUTE_CONFIG: InjectionToken<RouteDefinition[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Built-in injection token for the application base href.
|
|
8
|
+
* Modeled directly after Angular's APP_BASE_HREF in @angular/common.
|
|
9
|
+
*/
|
|
10
|
+
export declare const APP_BASE_HREF: InjectionToken<string>;
|
|
11
|
+
export interface RouterFeature {
|
|
12
|
+
kind: string;
|
|
13
|
+
providers: Provider[];
|
|
14
|
+
}
|
|
15
|
+
export interface RouterConfigOptions {
|
|
16
|
+
onSameUrlNavigation?: "reload" | "ignore";
|
|
17
|
+
paramsInheritanceStrategy?: "emptyOnly" | "always";
|
|
18
|
+
}
|
|
19
|
+
export declare const ROUTER_CONFIGURATION: InjectionToken<RouterConfigOptions>;
|
|
20
|
+
/**
|
|
21
|
+
* Feature flag enabling automatic binding of route and query parameters to component/handler inputs.
|
|
22
|
+
* Modeled after Angular 16+ withComponentInputBinding().
|
|
23
|
+
*/
|
|
24
|
+
export declare function withComponentInputBinding(): RouterFeature;
|
|
25
|
+
/**
|
|
26
|
+
* Configures global router behavior options.
|
|
27
|
+
* Modeled after Angular 15+ withRouterConfig().
|
|
28
|
+
*/
|
|
29
|
+
export declare function withRouterConfig(options: RouterConfigOptions): RouterFeature;
|
|
30
|
+
/**
|
|
31
|
+
* Registers a custom TitleStrategy for page title updates upon navigation.
|
|
32
|
+
* Modeled after Angular 14+ withTitleStrategy().
|
|
33
|
+
*/
|
|
34
|
+
export declare function withTitleStrategy(strategy: TitleStrategy | Type<TitleStrategy>): RouterFeature;
|
|
35
|
+
/**
|
|
36
|
+
* Provides application-wide route configuration and router features.
|
|
37
|
+
* Modeled after Angular 15+ standalone provideRouter.
|
|
38
|
+
*/
|
|
39
|
+
export declare function provideRouter(routes: RouteDefinition[], ...features: RouterFeature[]): EnvironmentProviders;
|
package/dist/signal.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency, lightweight reactive signals modeled after Angular Signals and TC39 Signals.
|
|
3
|
+
* Provides fine-grained reactive state without RxJS or runtime reflection.
|
|
4
|
+
*/
|
|
5
|
+
export interface Signal<T> {
|
|
6
|
+
(): T;
|
|
7
|
+
}
|
|
8
|
+
export interface WritableSignal<T> extends Signal<T> {
|
|
9
|
+
set(value: T): void;
|
|
10
|
+
update(updateFn: (current: T) => T): void;
|
|
11
|
+
asReadonly(): Signal<T>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a writable signal with initial value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function signal<T>(initialValue: T): WritableSignal<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a computed, read-only signal derived from other signals.
|
|
19
|
+
* Evaluates lazily and caches the result until dependencies change.
|
|
20
|
+
*/
|
|
21
|
+
export declare function computed<T>(computation: () => T): Signal<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a reactive effect that runs computation immediately and re-runs whenever any read signal changes.
|
|
24
|
+
* Returns a teardown function.
|
|
25
|
+
*/
|
|
26
|
+
export declare function effect(effectFn: () => void | (() => void)): () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Runs a function without registering signal dependencies.
|
|
29
|
+
*/
|
|
30
|
+
export declare function untracked<T>(fn: () => T): T;
|
|
31
|
+
export interface LinkedSignalOptions<S, D> {
|
|
32
|
+
source: () => S;
|
|
33
|
+
computation: (source: S, previous?: {
|
|
34
|
+
source: S;
|
|
35
|
+
value: D;
|
|
36
|
+
}) => D;
|
|
37
|
+
equal?: (a: D, b: D) => boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a writable signal whose value is linked to a source reactive computation.
|
|
41
|
+
* When the source dependencies change, the linkedSignal automatically recomputes its value.
|
|
42
|
+
* Unlike a standard computed signal, a linkedSignal is writable and can be manually modified.
|
|
43
|
+
* Modeled directly after Angular 19's linkedSignal.
|
|
44
|
+
*/
|
|
45
|
+
export declare function linkedSignal<D>(computation: () => D, options?: {
|
|
46
|
+
equal?: (a: D, b: D) => boolean;
|
|
47
|
+
}): WritableSignal<D>;
|
|
48
|
+
export declare function linkedSignal<S, D = S>(options: LinkedSignalOptions<S, D>): WritableSignal<D>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EnvironmentProviders, Provider, Token } from "./provider";
|
|
2
|
+
import { type InjectFlags } from "./inject";
|
|
3
|
+
export interface TestModuleMetadata {
|
|
4
|
+
providers?: Array<Provider | EnvironmentProviders>;
|
|
5
|
+
imports?: Array<{
|
|
6
|
+
providers?: Array<Provider | EnvironmentProviders>;
|
|
7
|
+
} | any>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Unit testing environment for SupaCloud services and controllers.
|
|
11
|
+
* Modeled directly after Angular's TestBed.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TestBed {
|
|
14
|
+
private static declaredProviders;
|
|
15
|
+
private static overriddenProviders;
|
|
16
|
+
private static activeInjector;
|
|
17
|
+
private static instances;
|
|
18
|
+
/**
|
|
19
|
+
* Configures the testing module with providers and imports.
|
|
20
|
+
*/
|
|
21
|
+
static configureTestingModule(moduleDef: TestModuleMetadata): typeof TestBed;
|
|
22
|
+
/**
|
|
23
|
+
* Overrides a provider token with a test double or mock.
|
|
24
|
+
*/
|
|
25
|
+
static overrideProvider(token: Token<unknown>, provider: Provider): typeof TestBed;
|
|
26
|
+
/**
|
|
27
|
+
* Injects and resolves a dependency from the test environment.
|
|
28
|
+
*/
|
|
29
|
+
static inject<T>(token: Token<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
|
30
|
+
/**
|
|
31
|
+
* Injects all instances registered for a multi-provider token from the test environment.
|
|
32
|
+
*/
|
|
33
|
+
static injectAll<T>(token: Token<T>): T[];
|
|
34
|
+
/**
|
|
35
|
+
* Runs a function inside the TestBed injection context.
|
|
36
|
+
*/
|
|
37
|
+
static run<R>(fn: () => R): R;
|
|
38
|
+
/**
|
|
39
|
+
* Resets the testing environment, clearing providers, mocks, and instantiated singletons.
|
|
40
|
+
*/
|
|
41
|
+
static resetTestingModule(): typeof TestBed;
|
|
42
|
+
private static getOrCreateInjector;
|
|
43
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InjectionToken } from "./token";
|
|
2
|
+
import type { RoutePipelineContext } from "./route_pipeline";
|
|
3
|
+
/**
|
|
4
|
+
* Strategy interface for updating application document / page titles upon navigation.
|
|
5
|
+
* Modeled directly after Angular 14+ TitleStrategy.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class TitleStrategy {
|
|
8
|
+
abstract updateTitle(title: string | undefined, ctx?: RoutePipelineContext): void;
|
|
9
|
+
buildTitle(title: string | undefined, appPrefix?: string): string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Default implementation of TitleStrategy.
|
|
13
|
+
* Updates global document.title when available, and records the resolved title in route context data.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DefaultTitleStrategy extends TitleStrategy {
|
|
16
|
+
updateTitle(title: string | undefined, ctx?: RoutePipelineContext): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const TITLE_STRATEGY: InjectionToken<TitleStrategy>;
|
package/dist/token.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { Scope } from "./scope";
|
|
|
2
2
|
export interface InjectionTokenOptions<T> {
|
|
3
3
|
/** Optional default factory used when no explicit provider is registered. */
|
|
4
4
|
factory?: () => T;
|
|
5
|
+
/** Automatically provide in the root injector context without manual module declaration (Angular tree-shakable provider). */
|
|
6
|
+
providedIn?: "root";
|
|
5
7
|
/** Default scope when the token itself is used as a provider. */
|
|
6
8
|
scope?: Scope;
|
|
7
9
|
}
|
|
@@ -12,6 +14,7 @@ export interface InjectionTokenOptions<T> {
|
|
|
12
14
|
export declare class InjectionToken<T> {
|
|
13
15
|
readonly name: string;
|
|
14
16
|
readonly factory?: () => T;
|
|
17
|
+
readonly providedIn?: "root";
|
|
15
18
|
readonly scope?: Scope;
|
|
16
19
|
constructor(name: string, options?: InjectionTokenOptions<T>);
|
|
17
20
|
toString(): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { InjectionToken } from "./token";
|
|
2
|
+
export type StateKey<T> = string & {
|
|
3
|
+
readonly __type_brand?: T;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Creates a type-safe StateKey for TransferState.
|
|
7
|
+
* Modeled directly after Angular's makeStateKey.
|
|
8
|
+
*/
|
|
9
|
+
export declare function makeStateKey<T>(key: string): StateKey<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Key-value store used to transfer application state between server and client (SSR / Edge hydration).
|
|
12
|
+
* Modeled directly after Angular Universal TransferState.
|
|
13
|
+
*/
|
|
14
|
+
export declare class TransferState {
|
|
15
|
+
private store;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the value associated with the key, or defaultValue if not present.
|
|
18
|
+
*/
|
|
19
|
+
get<T>(key: StateKey<T> | string, defaultValue: T): T;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the value for the given key.
|
|
22
|
+
*/
|
|
23
|
+
set<T>(key: StateKey<T> | string, value: T): void;
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether the key exists in the store.
|
|
26
|
+
*/
|
|
27
|
+
hasKey<T>(key: StateKey<T> | string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Removes a key from the store.
|
|
30
|
+
*/
|
|
31
|
+
remove<T>(key: StateKey<T> | string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether the store is empty.
|
|
34
|
+
*/
|
|
35
|
+
isEmpty(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Serializes the current state store into a JSON string.
|
|
38
|
+
*/
|
|
39
|
+
toJson(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Deserializes a JSON string into a TransferState store.
|
|
42
|
+
*/
|
|
43
|
+
static fromJson(json: string): TransferState;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a TransferState initialized with a plain record object.
|
|
46
|
+
*/
|
|
47
|
+
static fromObject(record: Record<string, unknown>): TransferState;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Built-in injection token for TransferState.
|
|
51
|
+
*/
|
|
52
|
+
export declare const TRANSFER_STATE: InjectionToken<TransferState>;
|