@absolutejs/absolute 0.19.0-beta.963 → 0.19.0-beta.965
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/angular/browser.js +4 -6
- package/dist/angular/browser.js.map +5 -6
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +4 -14
- package/dist/angular/index.js.map +6 -7
- package/dist/angular/server.js +1 -12
- package/dist/angular/server.js.map +4 -5
- package/dist/src/angular/browser.d.ts +2 -3
- package/dist/src/angular/composables/index.d.ts +1 -1
- package/dist/src/angular/composables/useResource.d.ts +19 -4
- package/dist/src/angular/index.d.ts +2 -3
- package/dist/src/angular/pageHandler.d.ts +9 -15
- package/dist/src/angular/server.d.ts +1 -2
- package/dist/types/angular.d.ts +48 -18
- package/package.json +1 -1
- package/dist/src/angular/page.d.ts +0 -5
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { AngularPagePropsOf } from '../../types/angular';
|
|
2
2
|
export { ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER, buildAbsoluteHttpTransferCacheOptions } from './httpTransferCache';
|
|
3
3
|
export { createDeterministicRandom, DETERMINISTIC_NOW, DETERMINISTIC_RANDOM, DETERMINISTIC_SEED, provideDeterministicEnv } from './deterministicEnv';
|
|
4
|
-
export { defineAngularPage } from './page';
|
|
5
4
|
export { useResource, useSubscription, useTimers } from './composables';
|
|
6
|
-
export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './composables';
|
|
5
|
+
export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './composables';
|
|
7
6
|
export { preserveAcrossHmr } from './preserveAcrossHmr';
|
|
8
7
|
export { Island } from './Island.browser';
|
|
9
8
|
export { withPendingTask } from './pendingTask';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useResource } from './useResource';
|
|
2
|
-
export type { Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './useResource';
|
|
2
|
+
export type { Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './useResource';
|
|
3
3
|
export { useSubscription } from './useSubscription';
|
|
4
4
|
export type { Observer } from './useSubscription';
|
|
5
5
|
export { useTimers } from './useTimers';
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { type Signal } from '@angular/core';
|
|
2
2
|
export type ResourceFetcher<T> = (signal: AbortSignal) => Promise<T>;
|
|
3
|
+
/** Controls the resource's startup behavior.
|
|
4
|
+
*
|
|
5
|
+
* - `'immediate'` (default) — fire the fetcher synchronously at creation;
|
|
6
|
+
* `loading()` starts `true`.
|
|
7
|
+
* - `'pending'` — don't fire the fetcher yet, but render as if a fetch is
|
|
8
|
+
* coming: `loading()` starts `true`. Pair with a manual `refresh()` call
|
|
9
|
+
* from `ngOnInit` (or wherever the dependencies become available). Use
|
|
10
|
+
* this when the fetcher depends on state set after construction (e.g. a
|
|
11
|
+
* route param assigned by the page factory) — it avoids the blank-frame
|
|
12
|
+
* flash you'd get from `'idle'`.
|
|
13
|
+
* - `'idle'` — don't fire the fetcher and don't pretend you will:
|
|
14
|
+
* `loading()` starts `false`. The resource is dormant until `refresh()`
|
|
15
|
+
* or `mutate()` is called.
|
|
16
|
+
*/
|
|
17
|
+
export type ResourceStart = 'immediate' | 'pending' | 'idle';
|
|
3
18
|
export type ResourceOptions = {
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
immediate?: boolean;
|
|
19
|
+
/** When and how the fetcher fires on creation. Default: `'immediate'`. */
|
|
20
|
+
start?: ResourceStart;
|
|
7
21
|
};
|
|
8
22
|
export type ResourceMutator<T> = T | null | ((prev: T | null) => T | null);
|
|
9
23
|
export type Resource<T> = {
|
|
@@ -11,7 +25,8 @@ export type Resource<T> = {
|
|
|
11
25
|
data: Signal<T | null>;
|
|
12
26
|
/** Latest rejection reason, or `null` when the resource is healthy. */
|
|
13
27
|
error: Signal<unknown>;
|
|
14
|
-
/** True while a fetch is in flight
|
|
28
|
+
/** True while a fetch is in flight, or when `start: 'pending'` was set
|
|
29
|
+
* and `refresh()` hasn't been called yet. */
|
|
15
30
|
loading: Signal<boolean>;
|
|
16
31
|
/** Re-runs the fetcher. Any in-flight request is aborted first. */
|
|
17
32
|
refresh: () => Promise<void>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import '@angular/compiler';
|
|
2
|
-
export type {
|
|
2
|
+
export type { AngularPagePropsOf } from '../../types/angular';
|
|
3
3
|
export { ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER, buildAbsoluteHttpTransferCacheOptions } from './httpTransferCache';
|
|
4
4
|
export { createDeterministicRandom, DETERMINISTIC_NOW, DETERMINISTIC_RANDOM, DETERMINISTIC_SEED, provideDeterministicEnv } from './deterministicEnv';
|
|
5
5
|
export { handleAngularPageRequest } from './pageHandler';
|
|
6
|
-
export { defineAngularPage } from './page';
|
|
7
6
|
export { useResource, useSubscription, useTimers } from './composables';
|
|
8
|
-
export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions } from './composables';
|
|
7
|
+
export type { Observer, Resource, ResourceFetcher, ResourceMutator, ResourceOptions, ResourceStart } from './composables';
|
|
9
8
|
export { preserveAcrossHmr } from './preserveAcrossHmr';
|
|
10
9
|
export { withPendingTask } from './pendingTask';
|
|
11
10
|
export { createTypedIsland } from './createIsland';
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AngularPagePropsOf } from '../../types/angular';
|
|
2
2
|
import { type StreamingSlotEnhancerOptions } from '../core/responseEnhancers';
|
|
3
3
|
type AngularPageRenderOptions = StreamingSlotEnhancerOptions & {
|
|
4
4
|
collectStreamingSlots?: boolean;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} ? HasNoRequiredAngularProps<Props> : HasNoRequiredAngularProps<AngularPagePropsOf<Page>>;
|
|
13
|
-
export type AngularPageRequestInput<Page = {
|
|
14
|
-
page: AngularPageDefinition<Record<never, never>>;
|
|
15
|
-
}> = AngularPageRenderOptions & {
|
|
6
|
+
/** True when the derived Props record has no required keys — used to
|
|
7
|
+
* flip the `props` argument between required and optional in the
|
|
8
|
+
* request-input shape. Pages with no SSR-injected tokens skip
|
|
9
|
+
* `props` entirely. */
|
|
10
|
+
type HasNoRequiredAngularProps<Props> = keyof Props extends never ? true : Partial<Props> extends Props ? true : false;
|
|
11
|
+
export type AngularPageRequestInput<Page = unknown> = AngularPageRenderOptions & {
|
|
16
12
|
headTag?: `<head>${string}</head>`;
|
|
17
13
|
indexPath: string;
|
|
18
14
|
pagePath: string;
|
|
@@ -30,12 +26,10 @@ export type AngularPageRequestInput<Page = {
|
|
|
30
26
|
* honoured. For finer control use `Route.data.sitemap` in the
|
|
31
27
|
* page's `Routes` config, or `sitemap.overrides` in `absolute.config.ts`. */
|
|
32
28
|
sitemap?: import('../../types/sitemap').PageHandlerSitemapMetadata;
|
|
33
|
-
} & (
|
|
29
|
+
} & (HasNoRequiredAngularProps<AngularPagePropsOf<Page>> extends true ? {
|
|
34
30
|
props?: NoInfer<AngularPagePropsOf<Page>>;
|
|
35
31
|
} : {
|
|
36
32
|
props: NoInfer<AngularPagePropsOf<Page>>;
|
|
37
33
|
});
|
|
38
|
-
export declare const handleAngularPageRequest: <Page =
|
|
39
|
-
page: AngularPageDefinition<Record<never, never>>;
|
|
40
|
-
}>(input: AngularPageRequestInput<Page>) => Promise<Response>;
|
|
34
|
+
export declare const handleAngularPageRequest: <Page = unknown>(input: AngularPageRequestInput<Page>) => Promise<Response>;
|
|
41
35
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { AngularPagePropsOf } from '../../types/angular';
|
|
2
2
|
export { ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER, buildAbsoluteHttpTransferCacheOptions } from './httpTransferCache';
|
|
3
3
|
export { createDeterministicRandom, DETERMINISTIC_NOW, DETERMINISTIC_RANDOM, DETERMINISTIC_SEED, provideDeterministicEnv } from './deterministicEnv';
|
|
4
4
|
export { handleAngularPageRequest } from './pageHandler';
|
|
5
|
-
export { defineAngularPage } from './page';
|
|
6
5
|
export { withPendingTask } from './pendingTask';
|
package/dist/types/angular.d.ts
CHANGED
|
@@ -16,26 +16,56 @@ export type AngularDeps = {
|
|
|
16
16
|
SecurityContext: typeof import('@angular/core').SecurityContext;
|
|
17
17
|
withHttpTransferCacheOptions: typeof import('@angular/platform-browser').withHttpTransferCacheOptions;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
/**
|
|
20
|
+
* SCREAMING_SNAKE_CASE → camelCase at the type level. Mirrors the
|
|
21
|
+
* runtime mapping in `ssrRender.ts` that turns a page module's
|
|
22
|
+
* exported `INITIAL_ACCOUNT` token into the `initialAccount` prop
|
|
23
|
+
* the backend pages plugin passes.
|
|
24
|
+
*/
|
|
25
|
+
type SnakeToCamel<S extends string> = S extends `${infer First}_${infer Rest}` ? `${Lowercase<First>}${Capitalize<SnakeToCamel<Rest>>}` : Lowercase<S>;
|
|
26
|
+
/** Pull the value type out of `InjectionToken<T>` (loosened to any
|
|
27
|
+
* shape that carries the same `T` generic parameter). */
|
|
28
|
+
type ExtractTokenValue<T> = T extends {
|
|
29
|
+
__NG_ELEMENT_ID__?: unknown;
|
|
30
|
+
ngMetadataName?: 'InjectionToken';
|
|
31
|
+
prototype: infer P;
|
|
32
|
+
} ? P : T extends import('@angular/core').InjectionToken<infer U> ? U : never;
|
|
33
|
+
/** Type guard: is `T` an `InjectionToken<unknown>`? Written
|
|
34
|
+
* structurally so it picks up both Angular's official type and any
|
|
35
|
+
* user-defined token via duck-typing on `prototype`. */
|
|
36
|
+
type IsInjectionToken<T> = T extends import('@angular/core').InjectionToken<unknown> ? true : false;
|
|
37
|
+
/** A token whose value type explicitly includes `undefined` becomes
|
|
38
|
+
* an optional prop — call sites can omit it. `null` does not flip
|
|
39
|
+
* to optional: callers must still pass the value explicitly, even
|
|
40
|
+
* if the value happens to be `null`. */
|
|
41
|
+
type RequiredTokenKey<M, K extends keyof M> = IsInjectionToken<M[K]> extends true ? undefined extends ExtractTokenValue<M[K]> ? never : K & string : never;
|
|
42
|
+
type OptionalTokenKey<M, K extends keyof M> = IsInjectionToken<M[K]> extends true ? undefined extends ExtractTokenValue<M[K]> ? K & string : never : never;
|
|
43
|
+
/**
|
|
44
|
+
* Derives the props shape a page accepts from its module's exported
|
|
45
|
+
* `InjectionToken<T>` declarations. The runtime in `ssrRender.ts`
|
|
46
|
+
* already enforces "each prop must match a token re-exported from
|
|
47
|
+
* the page module"; this type mirrors that. A token whose `T`
|
|
48
|
+
* includes `null`/`undefined` becomes an optional prop, otherwise
|
|
49
|
+
* required.
|
|
50
|
+
*/
|
|
51
|
+
export type ExtractPageProps<M> = {
|
|
52
|
+
[K in keyof M as SnakeToCamel<RequiredTokenKey<M, K>>]: ExtractTokenValue<M[K]>;
|
|
53
|
+
} & {
|
|
54
|
+
[K in keyof M as SnakeToCamel<OptionalTokenKey<M, K>>]?: ExtractTokenValue<M[K]>;
|
|
32
55
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Props the framework will resolve for a given page module. Pages
|
|
58
|
+
* declare their prop surface by exporting `InjectionToken<T>`s — no
|
|
59
|
+
* wrapper function, no separate props type to maintain.
|
|
60
|
+
*/
|
|
61
|
+
export type AngularPagePropsOf<Page> = ExtractPageProps<Page>;
|
|
62
|
+
/**
|
|
63
|
+
* Cached render data per route. The `headTag` is captured once when
|
|
64
|
+
* the page module is registered so subsequent renders skip the
|
|
65
|
+
* filesystem read.
|
|
66
|
+
*/
|
|
38
67
|
export type CachedRouteData = {
|
|
39
68
|
props: Record<string, unknown> | undefined;
|
|
40
69
|
headTag: `<head>${string}</head>`;
|
|
41
70
|
};
|
|
71
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Type } from '@angular/core';
|
|
2
|
-
import type { AngularPageDefinition } from '../../types/angular';
|
|
3
|
-
export declare const defineAngularPage: <Props extends Record<string, unknown> = Record<never, never>>(definition: {
|
|
4
|
-
component: Type<unknown>;
|
|
5
|
-
}) => AngularPageDefinition<Props>;
|