@hamur/adapter-angular 0.0.0-stage → 0.0.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/LICENSE +22 -0
- package/README.md +42 -2
- package/dist/chunks/browser-index-7h7x2xz2.js +131 -0
- package/dist/chunks/browser-index-nann848q.js +205 -0
- package/dist/chunks/browser-index-qn8q5fa2.js +580 -0
- package/dist/src/adapter.js +1073 -0
- package/dist/src/error-page.js +34 -0
- package/dist/src/index.js +1729 -0
- package/dist/src/keepalive.js +0 -0
- package/dist/src/runtime/client.js +21 -0
- package/dist/src/runtime/island.js +92 -0
- package/dist/src/runtime/server.js +175 -0
- package/dist/types/src/activation.d.ts +20 -0
- package/dist/types/src/adapter.d.ts +7 -0
- package/dist/types/src/app.d.ts +3 -0
- package/dist/types/src/async-data.d.ts +21 -0
- package/dist/types/src/client-parts.d.ts +32 -0
- package/dist/types/src/compile.d.ts +97 -0
- package/dist/types/src/context.d.ts +74 -0
- package/dist/types/src/data.d.ts +65 -0
- package/dist/types/src/definition.d.ts +13 -0
- package/dist/types/src/error-page.d.ts +5 -0
- package/dist/types/src/error.d.ts +4 -0
- package/dist/types/src/form.d.ts +65 -0
- package/dist/types/src/head.d.ts +12 -0
- package/dist/types/src/hmr.d.ts +14 -0
- package/dist/types/src/hydration.d.ts +16 -0
- package/dist/types/src/index.d.ts +24 -0
- package/dist/types/src/indicators.d.ts +69 -0
- package/dist/types/src/island.d.ts +39 -0
- package/dist/types/src/keepalive.d.ts +1 -0
- package/dist/types/src/link.d.ts +65 -0
- package/dist/types/src/markdown-page.d.ts +10 -0
- package/dist/types/src/markdown.d.ts +37 -0
- package/dist/types/src/mask.d.ts +12 -0
- package/dist/types/src/navigate.d.ts +14 -0
- package/dist/types/src/outlet.d.ts +71 -0
- package/dist/types/src/request.d.ts +31 -0
- package/dist/types/src/routing.d.ts +47 -0
- package/dist/types/src/runtime/client.d.ts +29 -0
- package/dist/types/src/runtime/hydration-dev.d.ts +1 -0
- package/dist/types/src/runtime/hydration.d.ts +8 -0
- package/dist/types/src/runtime/island.d.ts +8 -0
- package/dist/types/src/runtime/server.d.ts +15 -0
- package/dist/types/src/server-island.d.ts +21 -0
- package/dist/types/src/state.d.ts +14 -0
- package/dist/types/src/svg.d.ts +15 -0
- package/dist/types/src/time.d.ts +37 -0
- package/dist/types/src/wrapper.d.ts +21 -0
- package/package.json +56 -4
- package/src/activation.ts +83 -0
- package/src/adapter.ts +107 -0
- package/src/app.ts +6 -0
- package/src/async-data.ts +105 -0
- package/src/client-parts.ts +127 -0
- package/src/compile.ts +959 -0
- package/src/context.ts +189 -0
- package/src/data.ts +389 -0
- package/src/definition.ts +144 -0
- package/src/error-page.ts +17 -0
- package/src/error.ts +15 -0
- package/src/form.ts +253 -0
- package/src/head.ts +63 -0
- package/src/hmr.ts +61 -0
- package/src/hydration.ts +120 -0
- package/src/index.ts +98 -0
- package/src/indicators.ts +251 -0
- package/src/island.ts +95 -0
- package/src/keepalive.ts +1 -0
- package/src/link.ts +251 -0
- package/src/markdown-page.ts +31 -0
- package/src/markdown.ts +170 -0
- package/src/mask.ts +36 -0
- package/src/navigate.ts +19 -0
- package/src/outlet.ts +344 -0
- package/src/request.ts +170 -0
- package/src/routing.ts +218 -0
- package/src/runtime/client.ts +140 -0
- package/src/runtime/contract.d.ts +4 -0
- package/src/runtime/hydration-dev.ts +18 -0
- package/src/runtime/hydration.ts +7 -0
- package/src/runtime/island.ts +109 -0
- package/src/runtime/server.ts +228 -0
- package/src/server-island.ts +54 -0
- package/src/state.ts +70 -0
- package/src/svg.ts +65 -0
- package/src/time.ts +108 -0
- package/src/wrapper.ts +187 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Signal } from "@angular/core";
|
|
2
|
+
import type { ActionOptions, ActionRunner, FormStatus, Handler } from "hamur/adapter";
|
|
3
|
+
import type { ActionFailure, FieldsOf, HamurError, PendingRun, RouteLocation } from "hamur/app";
|
|
4
|
+
type FormHandler = Handler<any, any>;
|
|
5
|
+
type FormAction = string | RouteLocation | FormHandler;
|
|
6
|
+
/**
|
|
7
|
+
* `<form hamurForm>`. The host bindings write what the other adapters' `Form` writes on its
|
|
8
|
+
* `<form>`; with a handler it posts to the page with `_fn=<id>` without JavaScript and calls the handler's stub with it.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Form {
|
|
11
|
+
readonly action: import("@angular/core/types/core.js").InputSignalWithTransform<FormAction | undefined, FormAction | undefined>;
|
|
12
|
+
readonly method: import("@angular/core/types/core.js").InputSignal<"get" | "post" | undefined>;
|
|
13
|
+
readonly encType: import("@angular/core/types/core.js").InputSignal<"application/x-www-form-urlencoded" | "multipart/form-data" | undefined>;
|
|
14
|
+
readonly replace: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
15
|
+
readonly reset: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
16
|
+
readonly reloadDocument: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
17
|
+
readonly refresh: import("@angular/core/types/core.js").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
18
|
+
readonly restore: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
19
|
+
readonly instance: import("@angular/core/types/core.js").InputSignal<string | number | undefined>;
|
|
20
|
+
private readonly app;
|
|
21
|
+
private readonly route;
|
|
22
|
+
private readonly router;
|
|
23
|
+
private readonly resolve;
|
|
24
|
+
private readonly status;
|
|
25
|
+
private readonly element;
|
|
26
|
+
protected readonly methodAttribute: Signal<"get" | "post">;
|
|
27
|
+
protected readonly target: Signal<string | undefined>;
|
|
28
|
+
private readonly posts;
|
|
29
|
+
constructor();
|
|
30
|
+
private enhanceOptions;
|
|
31
|
+
/** The handler, `refresh` and `instance` of the moment of the submission, as `action` and `_fn` show them. */
|
|
32
|
+
private post;
|
|
33
|
+
protected flag(value: boolean): "" | null;
|
|
34
|
+
}
|
|
35
|
+
/** The run of the `Form` the component is created in; idle outside one. */
|
|
36
|
+
export declare function injectFormStatus(): Signal<FormStatus>;
|
|
37
|
+
/** What `injectForm(fn)` and its `for(key)` return: the field helpers, and the store's values as signals. */
|
|
38
|
+
export interface InjectFormInstance<I, O> {
|
|
39
|
+
readonly fields: FieldsOf<I>;
|
|
40
|
+
/** True while a run of this handler and instance is in `pendingRuns`. */
|
|
41
|
+
readonly pending: Signal<boolean>;
|
|
42
|
+
/** What the last run returned, a `fail()` included. */
|
|
43
|
+
readonly result: Signal<O | undefined>;
|
|
44
|
+
}
|
|
45
|
+
export interface InjectFormResult<I, O> extends InjectFormInstance<I, O> {
|
|
46
|
+
/** The store of `injectAction(fn, { instance: key })`. */
|
|
47
|
+
for(key: string | number): InjectFormInstance<I, O>;
|
|
48
|
+
}
|
|
49
|
+
/** The field helpers of `fn`'s input and the store of its runs; a field's reads follow the store too. */
|
|
50
|
+
export declare function injectForm<I, O>(fn: Handler<I, O>): InjectFormResult<I, O>;
|
|
51
|
+
export interface InjectActionResult<I, O> {
|
|
52
|
+
readonly run: ActionRunner<I, O>["run"];
|
|
53
|
+
readonly state: Signal<O | undefined>;
|
|
54
|
+
readonly pending: Signal<boolean>;
|
|
55
|
+
readonly error: Signal<HamurError | undefined>;
|
|
56
|
+
readonly failure: Signal<ActionFailure | undefined>;
|
|
57
|
+
reset(): void;
|
|
58
|
+
}
|
|
59
|
+
/** Runs `fn` one call after another; below a `Form` of `fn` it shows that form's posts. */
|
|
60
|
+
export declare function injectAction<I, O>(fn: Handler<I, O>, options?: ActionOptions<O> & {
|
|
61
|
+
instance?: string | number;
|
|
62
|
+
}): InjectActionResult<I, O>;
|
|
63
|
+
/** `value` while no handler call runs, else `reduce(value, the running calls)`. */
|
|
64
|
+
export declare function injectOptimistic<T, A = PendingRun>(value: T | (() => T), reduce: (current: T, pending: A[]) => T): Signal<T>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HeadInput, HeadSafeInput, SeoMetaInput } from "hamur/app";
|
|
2
|
+
type ServerHeadInput = Omit<HeadInput, "title" | "titleTemplate">;
|
|
3
|
+
type ServerSeoMetaInput = Omit<SeoMetaInput, "title" | "titleTemplate">;
|
|
4
|
+
type Input<T> = T | (() => T);
|
|
5
|
+
/** An entry of the request's head, patched when the signals its function reads change and removed with the component; the server's head is the request's, so nothing is removed there. */
|
|
6
|
+
export declare function injectHead(input: Input<HeadInput>): void;
|
|
7
|
+
export declare function injectSeoMeta(input: Input<SeoMetaInput>): void;
|
|
8
|
+
export declare function injectHeadSafe(input: Input<HeadSafeInput>): void;
|
|
9
|
+
/** Tags written for the server render only; the browser does nothing. */
|
|
10
|
+
export declare function injectServerHead(input: Input<ServerHeadInput>): void;
|
|
11
|
+
export declare function injectServerSeoMeta(input: Input<ServerSeoMetaInput>): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Adapter } from "hamur/adapter";
|
|
2
|
+
declare module "hamur" {
|
|
3
|
+
interface HamurDevEvents {
|
|
4
|
+
"angular:component-update": {
|
|
5
|
+
id: string;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `modules:done` serves `/@ng/component`; `dev:change` sends the update, or lists the components
|
|
12
|
+
* that read the file as dependents with `hmr` off, and with it on those a template error is shown in; `close` drops the program.
|
|
13
|
+
*/
|
|
14
|
+
export declare const angularHooks: NonNullable<Adapter["hooks"]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HydrationMismatch } from "hamur/adapter/dev";
|
|
2
|
+
/** The parts of an element `angularMismatch` reads, so a test can pass a plain object tree. */
|
|
3
|
+
export interface MismatchElement {
|
|
4
|
+
readonly localName: string;
|
|
5
|
+
readonly id?: string;
|
|
6
|
+
readonly parentElement: MismatchElement | null;
|
|
7
|
+
readonly children: ArrayLike<MismatchElement>;
|
|
8
|
+
getAttribute(name: string): string | null;
|
|
9
|
+
querySelectorAll(selector: string): ArrayLike<MismatchElement>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The report of a hydration mismatch Angular detected (NG0500, NG0501, NG0502 and NG0509 of the hydration, read from
|
|
13
|
+
* the message alone); any other error, a serialization error included, is `undefined`. `root` holds `<hamur-app>`; without it
|
|
14
|
+
* the report has Angular's outlines and the path of the app host.
|
|
15
|
+
*/
|
|
16
|
+
export declare function angularMismatch(error: unknown, route: string, root?: MismatchElement | undefined): HydrationMismatch | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { default as DefaultErrorPage } from "./error-page.ts";
|
|
2
|
+
export { Outlet } from "./outlet.ts";
|
|
3
|
+
export { Link, injectLink, injectLinkStatus } from "./link.ts";
|
|
4
|
+
export { Navigate } from "./navigate.ts";
|
|
5
|
+
export { injectError } from "./error.ts";
|
|
6
|
+
export { clearError, forbidden, navigateTo, notFound, permanentRedirect, showError, unauthorized } from "hamur/app";
|
|
7
|
+
export { callOnce, clearState, injectAsyncData, injectData, injectFetch, injectLazyAsyncData, injectLazyFetch, injectNuxtData, } from "./data.ts";
|
|
8
|
+
export type { AsyncDataResource, InjectAsyncDataOptions, InjectFetchOptions } from "./data.ts";
|
|
9
|
+
export { injectHead, injectHeadSafe, injectSeoMeta, injectServerHead, injectServerSeoMeta } from "./head.ts";
|
|
10
|
+
export { injectCookie, injectState, injectSyncedState } from "./state.ts";
|
|
11
|
+
export { DevOnly, injectDeferred, injectHydrated, injectId, onPrehydrate, transitionName } from "./client-parts.ts";
|
|
12
|
+
export { onPageActivated, onPageDeactivated } from "./activation.ts";
|
|
13
|
+
export { Time } from "./time.ts";
|
|
14
|
+
export { Announcer, LoadingIndicator, RouteAnnouncer, injectAnnouncer, injectLoadingIndicator, injectRouteAnnouncer, } from "./indicators.ts";
|
|
15
|
+
export { MarkdownRenderer } from "./markdown.ts";
|
|
16
|
+
export type { MarkdownRendererProps } from "./markdown.ts";
|
|
17
|
+
export { Island } from "./island.ts";
|
|
18
|
+
export { ServerIsland } from "./server-island.ts";
|
|
19
|
+
export { Form, injectAction, injectForm, injectFormStatus, injectOptimistic } from "./form.ts";
|
|
20
|
+
export type { InjectActionResult, InjectFormInstance, InjectFormResult } from "./form.ts";
|
|
21
|
+
export { injectApp, injectAppUpdate, injectOnline, injectPoll, injectPreviewMode, injectReportWebVitals, injectRequestEvent, injectRequestFetch, injectRequestHeader, injectRequestHeaders, injectRequestURL, injectResponseHeader, injectRuntimeConfig, injectRuntimeHook, injectSiteConfig, onAppReady, setResponseStatus, } from "./request.ts";
|
|
22
|
+
export { injectBlocker, injectLayout, injectLayoutSegment, injectLayoutSegments, injectMatches, injectNavigation, injectOutletContext, injectPreventNavigate, injectResolvedPath, injectRoute, injectRouteData, injectRouter, injectSearch, injectSnapshot, onAfterNavigate, onBeforeNavigate, onBeforeRouteLeave, onBeforeRouteUpdate, onNavigate, } from "./routing.ts";
|
|
23
|
+
export type { AngularSetup } from "./context.ts";
|
|
24
|
+
export type { AnnouncerPoliteness, Blocker, BlockerArgs, LinkDefaults, LinkSlot, LoadingIndicatorOptions, LoadingIndicatorProps, MatchedRoute, NavigateOptions, Navigation, NavigationState, RouteDataName, RouteAnnouncerPoliteness, RouteDataOf, RouteValue, RouterApi, SnapshotOptions, UseBlockerOptions, UseLinkOptions, } from "hamur/adapter";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type OnInit, type Signal } from "@angular/core";
|
|
2
|
+
import type { AnnouncerActions, AnnouncerPoliteness, LoadingIndicatorActions, LoadingIndicatorOptions, RouteAnnouncerActions, RouteAnnouncerPoliteness } from "hamur/adapter";
|
|
3
|
+
/** The bar's state as signals, and its `start`, `finish`, `set` and `clear`; it follows the navigation while a component that called it is alive. */
|
|
4
|
+
export declare function injectLoadingIndicator(options?: LoadingIndicatorOptions): {
|
|
5
|
+
progress: Signal<number>;
|
|
6
|
+
isLoading: Signal<boolean>;
|
|
7
|
+
error: Signal<boolean>;
|
|
8
|
+
} & LoadingIndicatorActions;
|
|
9
|
+
/**
|
|
10
|
+
* `<hamur-loading-indicator />`, the bar at the top of the page that follows `injectNavigation().state`. Its look is
|
|
11
|
+
* written through `element.style` after the first render, so the server's element has no `style` attribute.
|
|
12
|
+
*/
|
|
13
|
+
export declare class LoadingIndicator implements OnInit {
|
|
14
|
+
readonly color: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
15
|
+
readonly errorColor: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
16
|
+
readonly height: import("@angular/core/types/core.js").InputSignal<number | undefined>;
|
|
17
|
+
readonly duration: import("@angular/core/types/core.js").InputSignal<number | undefined>;
|
|
18
|
+
readonly throttle: import("@angular/core/types/core.js").InputSignal<number | undefined>;
|
|
19
|
+
readonly estimatedProgress: import("@angular/core/types/core.js").InputSignal<((duration: number, elapsed: number) => number) | undefined>;
|
|
20
|
+
private readonly injector;
|
|
21
|
+
private readonly element;
|
|
22
|
+
ngOnInit(): void;
|
|
23
|
+
}
|
|
24
|
+
/** The page's route announcer as signals, and `set`, `polite` and `assertive`. */
|
|
25
|
+
export declare function injectRouteAnnouncer(): {
|
|
26
|
+
message: Signal<string>;
|
|
27
|
+
politeness: Signal<RouteAnnouncerPoliteness>;
|
|
28
|
+
} & RouteAnnouncerActions;
|
|
29
|
+
/**
|
|
30
|
+
* `<hamur-route-announcer />` is the region that speaks each navigation; the first one mounted holds `#__hamur_announcer`
|
|
31
|
+
* and the navigator's own region goes away while it is. A `politeness` pins `aria-live` and `role`; a `class` or `style` on the
|
|
32
|
+
* element keeps it visible.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RouteAnnouncer {
|
|
35
|
+
readonly politeness: import("@angular/core/types/core.js").InputSignal<RouteAnnouncerPoliteness | undefined>;
|
|
36
|
+
protected readonly id: string;
|
|
37
|
+
private readonly store;
|
|
38
|
+
private readonly state;
|
|
39
|
+
private readonly element;
|
|
40
|
+
private readonly styled;
|
|
41
|
+
private readonly key;
|
|
42
|
+
private readonly tick;
|
|
43
|
+
protected readonly message: Signal<string>;
|
|
44
|
+
protected readonly live: Signal<RouteAnnouncerPoliteness>;
|
|
45
|
+
protected readonly role: Signal<"alert" | "status" | undefined>;
|
|
46
|
+
protected readonly owner: Signal<boolean>;
|
|
47
|
+
constructor();
|
|
48
|
+
}
|
|
49
|
+
/** The page's announcer as signals, and `set`, `polite` and `assertive` (`polite` unless `politeness` says otherwise). */
|
|
50
|
+
export declare function injectAnnouncer({ politeness }?: {
|
|
51
|
+
politeness?: AnnouncerPoliteness;
|
|
52
|
+
}): {
|
|
53
|
+
message: Signal<string>;
|
|
54
|
+
politeness: Signal<AnnouncerPoliteness>;
|
|
55
|
+
} & AnnouncerActions;
|
|
56
|
+
/** `<hamur-announcer />` holds the two regions `injectAnnouncer()` writes to: `#__hamur_announcer_polite` and `#__hamur_announcer_assertive`. */
|
|
57
|
+
export declare class Announcer {
|
|
58
|
+
protected readonly politeId: string;
|
|
59
|
+
protected readonly assertiveId: string;
|
|
60
|
+
private readonly store;
|
|
61
|
+
private readonly state;
|
|
62
|
+
protected readonly regions: Signal<{
|
|
63
|
+
polite: string;
|
|
64
|
+
assertive: string;
|
|
65
|
+
}>;
|
|
66
|
+
private readonly polite;
|
|
67
|
+
private readonly assertive;
|
|
68
|
+
constructor();
|
|
69
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InjectionToken, Renderer2, type OnInit, type TemplateRef, type Type } from "@angular/core";
|
|
2
|
+
import type { IslandOn } from "hamur/adapter";
|
|
3
|
+
/** A component that writes its own nodes below its host: a template it renders there is a view the application checks. */
|
|
4
|
+
export declare abstract class HostWriter {
|
|
5
|
+
protected readonly host: HTMLElement;
|
|
6
|
+
protected readonly renderer: Renderer2;
|
|
7
|
+
private readonly appRef;
|
|
8
|
+
private readonly injector;
|
|
9
|
+
private readonly destroyRef;
|
|
10
|
+
protected append(template: TemplateRef<unknown>, into?: Element): void;
|
|
11
|
+
}
|
|
12
|
+
/** The element the core's islands runtime reads, `<appId>-island` of the build; a token, so a test gives it another app id. */
|
|
13
|
+
export declare const HAMUR_ISLAND_ELEMENT: InjectionToken<string>;
|
|
14
|
+
/**
|
|
15
|
+
* On an island page, `component` rendered on the server as an application of its own inside `<hamur-island>`,
|
|
16
|
+
* hydrated on its own in the browser; `fallback` is what the server renders under `on="only"`. Its template is empty: the island's
|
|
17
|
+
* HTML is written below its host on the server and left as it is in the browser. The host is the core's element when the app id is
|
|
18
|
+
* `hamur`; under another app id the host holds `<appId>-island`, which the runtime reads.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Island extends HostWriter implements OnInit {
|
|
21
|
+
/** The default export of a file under `app/islands/`. */
|
|
22
|
+
readonly component: import("@angular/core/types/core.js").InputSignal<Type<unknown>>;
|
|
23
|
+
readonly props: import("@angular/core/types/core.js").InputSignal<Record<string, unknown> | undefined>;
|
|
24
|
+
/** The island directive: when the island hydrates, `"only"` to mount it in the browser alone, or a directive a module adds; default `"load"`. */
|
|
25
|
+
readonly on: import("@angular/core/types/core.js").InputSignal<IslandOn | undefined>;
|
|
26
|
+
readonly fallback: import("@angular/core/types/core.js").InputSignal<TemplateRef<unknown> | undefined>;
|
|
27
|
+
/** The island's id across swaps; a swap to a page with the same id keeps its element and state. */
|
|
28
|
+
readonly persist: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
29
|
+
/** With `persist`, a swap keeps the island's old props. */
|
|
30
|
+
readonly persistProps: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
31
|
+
private readonly app;
|
|
32
|
+
private readonly id;
|
|
33
|
+
private readonly tasks;
|
|
34
|
+
private readonly fail;
|
|
35
|
+
private readonly server;
|
|
36
|
+
private readonly element;
|
|
37
|
+
constructor();
|
|
38
|
+
ngOnInit(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Signal } from "@angular/core";
|
|
2
|
+
import type { RouteLocation, ViewTransitionCall } from "hamur/app";
|
|
3
|
+
import type { CheckedTarget, LinkSlot, Navigation, PrefetchOn, UseLinkOptions } from "hamur/adapter";
|
|
4
|
+
type AriaCurrent = "page" | "step" | "location" | "date" | "time" | "true";
|
|
5
|
+
type Query = (prev: never) => Record<string, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* `<a hamurLink="/path">`. The host bindings write what the other adapters' `Link` writes on its anchor; the
|
|
8
|
+
* core navigator takes the click. A `target`, `rel` or `aria-current` written on the element stays.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Link<T extends string = string> {
|
|
11
|
+
readonly to: import("@angular/core/types/core.js").InputSignal<T | ({
|
|
12
|
+
name: string;
|
|
13
|
+
query?: Record<string, string | string[]>;
|
|
14
|
+
hash?: string;
|
|
15
|
+
} & {
|
|
16
|
+
params?: Record<string, string | string[]> | undefined;
|
|
17
|
+
})>;
|
|
18
|
+
readonly replace: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
19
|
+
readonly prefetch: import("@angular/core/types/core.js").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
20
|
+
readonly prefetchOn: import("@angular/core/types/core.js").InputSignal<PrefetchOn | undefined>;
|
|
21
|
+
readonly prefetchDelay: import("@angular/core/types/core.js").InputSignalWithTransform<number | undefined, unknown>;
|
|
22
|
+
readonly viewTransition: import("@angular/core/types/core.js").InputSignal<ViewTransitionCall | undefined>;
|
|
23
|
+
readonly query: import("@angular/core/types/core.js").InputSignal<Query | undefined>;
|
|
24
|
+
readonly state: import("@angular/core/types/core.js").InputSignal<Record<string, unknown> | undefined>;
|
|
25
|
+
readonly relative: import("@angular/core/types/core.js").InputSignal<"route" | undefined>;
|
|
26
|
+
readonly mask: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
27
|
+
readonly unmaskOnReload: import("@angular/core/types/core.js").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
28
|
+
readonly activeClass: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
29
|
+
readonly exactActiveClass: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
30
|
+
readonly pendingClass: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
31
|
+
readonly prefetchedClass: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
32
|
+
readonly ariaCurrentValue: import("@angular/core/types/core.js").InputSignal<AriaCurrent>;
|
|
33
|
+
readonly external: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
34
|
+
readonly noRel: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
35
|
+
readonly scroll: import("@angular/core/types/core.js").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
36
|
+
readonly keepFocus: import("@angular/core/types/core.js").InputSignalWithTransform<boolean, unknown>;
|
|
37
|
+
readonly beforeNavigate: import("@angular/core/types/_api-chunk.js").OutputEmitterRef<Navigation>;
|
|
38
|
+
private readonly app;
|
|
39
|
+
private readonly route;
|
|
40
|
+
private readonly resolve;
|
|
41
|
+
private readonly baseURL;
|
|
42
|
+
private readonly element;
|
|
43
|
+
private readonly rel;
|
|
44
|
+
private readonly target;
|
|
45
|
+
private readonly given;
|
|
46
|
+
private readonly defaults;
|
|
47
|
+
private readonly classNames;
|
|
48
|
+
private readonly linked;
|
|
49
|
+
private readonly matched;
|
|
50
|
+
/** The based `href` of the link. */
|
|
51
|
+
readonly href: Signal<string>;
|
|
52
|
+
protected readonly ariaCurrent: Signal<string | undefined>;
|
|
53
|
+
protected readonly keepFocusValue: Signal<"" | undefined>;
|
|
54
|
+
protected readonly classes: Signal<string>;
|
|
55
|
+
private readonly attrs;
|
|
56
|
+
constructor();
|
|
57
|
+
protected attr(name: string): string | undefined;
|
|
58
|
+
}
|
|
59
|
+
/** The `LinkSlot` of a link to `to`, for an element that renders its own `<a>`; `app.link` sets its defaults. */
|
|
60
|
+
export declare function injectLink<T extends string = string>(to: CheckedTarget<T> | RouteLocation | (() => CheckedTarget<T> | RouteLocation), options?: UseLinkOptions | (() => UseLinkOptions)): Signal<LinkSlot>;
|
|
61
|
+
/** Inside a `Link`'s content, whether a navigation to that link is in flight; `false` anywhere else. */
|
|
62
|
+
export declare function injectLinkStatus(): {
|
|
63
|
+
pending: Signal<boolean>;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MarkdownSource } from "hamur/adapter";
|
|
2
|
+
/** The module of a Markdown page, a component rendering `source.document.ast` with `MarkdownRenderer`; it is compiled with the app. */
|
|
3
|
+
declare function module(source: MarkdownSource): {
|
|
4
|
+
contents: string;
|
|
5
|
+
extension: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const markdownComponent: {
|
|
8
|
+
module: typeof module;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Type } from "@angular/core";
|
|
2
|
+
import type { MarkdownDocument, MdNode } from "hamur/markdown";
|
|
3
|
+
export interface MarkdownRendererProps {
|
|
4
|
+
/** A Markdown AST node, a list of nodes, or a document, which renders its `ast`. */
|
|
5
|
+
value: MdNode | MdNode[] | MarkdownDocument;
|
|
6
|
+
/** Components by Markdown component name (kebab case); each gets the node's props, its default slot and a slot per named slot. */
|
|
7
|
+
components?: Record<string, Type<unknown>>;
|
|
8
|
+
/** Renders `html` nodes, writing what it returns as their inner HTML; without it they are left out. A Markdown page under config `markdown.html` passes the core's Trusted Types writer. */
|
|
9
|
+
raw?: (html: string) => string | {
|
|
10
|
+
readonly __brand: "TrustedHTML";
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type Components = Record<string, Type<unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* Renders the Markdown AST as elements: an internal link as the anchor `Link` writes, a component node as its component
|
|
16
|
+
* in `components` (its props as inputs, the others as attributes; its default slot and each named slot projected into the `ng-content`
|
|
17
|
+
* whose selector is the slot's name, as `[name]` or `[slot=name]`). The elements are made with the renderer, so Angular skips
|
|
18
|
+
* the host in hydration and the browser builds them again from the same AST.
|
|
19
|
+
*/
|
|
20
|
+
export declare class MarkdownRenderer {
|
|
21
|
+
readonly value: import("@angular/core/types/core.js").InputSignal<MdNode[] | MarkdownDocument | MdNode>;
|
|
22
|
+
readonly components: import("@angular/core/types/core.js").InputSignal<Components | undefined>;
|
|
23
|
+
readonly raw: import("@angular/core/types/core.js").InputSignal<((html: string) => string | {
|
|
24
|
+
readonly __brand: "TrustedHTML";
|
|
25
|
+
}) | undefined>;
|
|
26
|
+
private readonly host;
|
|
27
|
+
private readonly renderer;
|
|
28
|
+
private readonly app;
|
|
29
|
+
private readonly resolve;
|
|
30
|
+
private readonly injector;
|
|
31
|
+
private readonly environment;
|
|
32
|
+
private readonly appRef;
|
|
33
|
+
constructor();
|
|
34
|
+
private append;
|
|
35
|
+
private appendComponent;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HamurError } from "hamur/app";
|
|
2
|
+
/**
|
|
3
|
+
* Angular binds the object it hands to `onViewError` to `$error` (`boundary.error`, set before the call), so a render overwrites it with what `publicError` made of it: its own properties go, its message, status, statusText and data are the masked ones.
|
|
4
|
+
*/
|
|
5
|
+
export declare function maskInPlace(error: object, shown: HamurError): void;
|
|
6
|
+
/**
|
|
7
|
+
* The `@error` blocks the server rendered, in the order they caught, under `$boundary:<n>` in the app state (as vue's
|
|
8
|
+
* `$boundary:<useId()>`): the browser creates each block again while it hydrates (A6) and shows the same text.
|
|
9
|
+
*/
|
|
10
|
+
export declare const boundaryKey: (index: number) => string;
|
|
11
|
+
/** What the server's `@error` block showed, as plain data for the payload. */
|
|
12
|
+
export declare function shownError(error: Error): HamurError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OnInit } from "@angular/core";
|
|
2
|
+
/** Navigates to `to` once after mount; during SSR it throws the redirect `navigateTo` throws there. */
|
|
3
|
+
export declare class Navigate<T extends string = string> implements OnInit {
|
|
4
|
+
readonly to: import("@angular/core/types/core").InputSignal<T | ({
|
|
5
|
+
name: string;
|
|
6
|
+
query?: Record<string, string | string[]>;
|
|
7
|
+
hash?: string;
|
|
8
|
+
} & {
|
|
9
|
+
params?: Record<string, string | string[]> | undefined;
|
|
10
|
+
})>;
|
|
11
|
+
readonly replace: import("@angular/core/types/core").InputSignalWithTransform<boolean, unknown>;
|
|
12
|
+
constructor();
|
|
13
|
+
ngOnInit(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type OnInit, type Signal } from "@angular/core";
|
|
2
|
+
import type { KeptUnit, RenderContext, RenderTree, RouteValue } from "hamur/adapter";
|
|
3
|
+
/**
|
|
4
|
+
* Places the next level of the tree as its next sibling; the `hamur-outlet` element stays empty. With `name` it places
|
|
5
|
+
* the chain of that slot of the entry it sits in; `context` reaches the entries below through `injectOutletContext()`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Outlet implements OnInit {
|
|
8
|
+
readonly name: import("@angular/core/types/core.js").InputSignal<string | undefined>;
|
|
9
|
+
readonly context: import("@angular/core/types/core.js").InputSignal<unknown>;
|
|
10
|
+
private readonly tree;
|
|
11
|
+
private readonly fail;
|
|
12
|
+
private readonly app;
|
|
13
|
+
private readonly payload;
|
|
14
|
+
private readonly route;
|
|
15
|
+
private readonly above;
|
|
16
|
+
private readonly owner;
|
|
17
|
+
private readonly injector;
|
|
18
|
+
private readonly container;
|
|
19
|
+
private readonly pageContext;
|
|
20
|
+
private readonly tasks;
|
|
21
|
+
private readonly warned;
|
|
22
|
+
private shown;
|
|
23
|
+
/** The keep-alive wrappers this outlet holds, by keep-alive key. */
|
|
24
|
+
private readonly pages;
|
|
25
|
+
private started;
|
|
26
|
+
/** Counts what the level shows, so an answer that waits for a microtask finds out the level moved on. */
|
|
27
|
+
private shownCount;
|
|
28
|
+
/** The tree this outlet reads and the index of its entry in it. */
|
|
29
|
+
private readonly view;
|
|
30
|
+
private readonly value;
|
|
31
|
+
private readonly slotTree;
|
|
32
|
+
private readonly slotRoute;
|
|
33
|
+
constructor();
|
|
34
|
+
ngOnInit(): void;
|
|
35
|
+
/** The kept units of this outlet; `undefined` while the app has keep-alive off, so the outlet keeps one shape. */
|
|
36
|
+
private units;
|
|
37
|
+
/** Each kept unit hidden in its wrapper, then the current child, in the wrapper of its key when its route keeps its pages. */
|
|
38
|
+
private apply;
|
|
39
|
+
private page;
|
|
40
|
+
private dropPages;
|
|
41
|
+
private dropShown;
|
|
42
|
+
private entry;
|
|
43
|
+
private show;
|
|
44
|
+
private place;
|
|
45
|
+
/**
|
|
46
|
+
* A throw of the entry this level creates, in its constructor or its checks. The route boundary covering the entry
|
|
47
|
+
* answers in its place; with none the error goes up to the next `@boundary` or level, and from the first level to the app's error page.
|
|
48
|
+
* A route boundary's own throw skips every boundary above it.
|
|
49
|
+
*/
|
|
50
|
+
private failed;
|
|
51
|
+
/** The boundary component takes the entry's place once the check that threw is over: Angular is still walking the view. */
|
|
52
|
+
private answer;
|
|
53
|
+
private clear;
|
|
54
|
+
private setInputs;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The `<div data-hamur-keepalive="<key>">` of a page whose route keeps its pages, `display:contents` while it is shown
|
|
58
|
+
* and `hidden` while kept. A kept unit reads its own tree, route and payload; a shown one reads the page's, from its own level down.
|
|
59
|
+
*/
|
|
60
|
+
export declare class KeptPage {
|
|
61
|
+
readonly name: import("@angular/core/types/core.js").InputSignal<string>;
|
|
62
|
+
readonly unit: import("@angular/core/types/core.js").InputSignal<KeptUnit | undefined>;
|
|
63
|
+
readonly hidden: import("@angular/core/types/core.js").InputSignal<boolean>;
|
|
64
|
+
private readonly source;
|
|
65
|
+
private readonly app;
|
|
66
|
+
readonly activation: import("./activation.ts").Activation;
|
|
67
|
+
readonly tree: Signal<RenderTree>;
|
|
68
|
+
readonly route: Signal<RouteValue>;
|
|
69
|
+
readonly payload: Signal<RenderContext["payload"]>;
|
|
70
|
+
constructor();
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Signal, type WritableSignal } from "@angular/core";
|
|
2
|
+
import type { AppUpdateActions, AppUpdateState } from "hamur/adapter";
|
|
3
|
+
import type { $Fetch, AppContext, AppHooks, ClientRuntimeConfig, PreviewMode, SiteConfig, WebVitalMetric } from "hamur/app";
|
|
4
|
+
import type { HamurEvent } from "hamur/server";
|
|
5
|
+
export declare function injectApp(): AppContext;
|
|
6
|
+
export declare function injectRuntimeConfig(): ClientRuntimeConfig;
|
|
7
|
+
export declare function injectSiteConfig(): SiteConfig;
|
|
8
|
+
/** A hook of the app, removed when the component is destroyed. */
|
|
9
|
+
export declare function injectRuntimeHook<K extends keyof AppHooks>(name: K, fn: AppHooks[K]): void;
|
|
10
|
+
export declare function injectReportWebVitals(fn: (metric: WebVitalMetric) => void | Promise<void>): void;
|
|
11
|
+
export declare function onAppReady(fn: () => void | Promise<void>): void;
|
|
12
|
+
/** Preview mode: enabled by the payload's `draft` or by `?preview=true` on the first URL. */
|
|
13
|
+
export declare function injectPreviewMode(): PreviewMode;
|
|
14
|
+
export declare function injectRequestEvent(): HamurEvent | undefined;
|
|
15
|
+
export declare function injectRequestHeaders(names?: readonly string[]): Record<string, string>;
|
|
16
|
+
export declare function injectRequestHeader(name: string): string | undefined;
|
|
17
|
+
export declare function injectRequestURL(): URL;
|
|
18
|
+
export declare function injectRequestFetch(): $Fetch;
|
|
19
|
+
/** Sets the status of the page's answer; does nothing in the browser. */
|
|
20
|
+
export declare function setResponseStatus(status: number, statusText?: string): void;
|
|
21
|
+
/** A header of the page's answer; a write sets it, `undefined` removes it. */
|
|
22
|
+
export declare function injectResponseHeader(name: string): WritableSignal<string | undefined>;
|
|
23
|
+
/** `true` until the browser reports otherwise; set after the first render, so the server's HTML and the hydration agree. */
|
|
24
|
+
export declare function injectOnline(): Signal<boolean>;
|
|
25
|
+
/** `refresh({ keys })` every `ms` while the document is visible, from the first render until the component is destroyed. */
|
|
26
|
+
export declare function injectPoll(ms: number, options?: {
|
|
27
|
+
keys?: string[];
|
|
28
|
+
}): void;
|
|
29
|
+
export declare function injectAppUpdate(): {
|
|
30
|
+
[K in keyof AppUpdateState]: Signal<AppUpdateState[K]>;
|
|
31
|
+
} & AppUpdateActions;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Signal } from "@angular/core";
|
|
2
|
+
import { layoutOf } from "hamur/adapter";
|
|
3
|
+
import type { AfterNavigateHook, BeforeNavigateHook, Blocker, MatchedRoute, NavigateHook, NavigationBlocker, NavigationGuard, NavigationState, RouteDataName, RouteDataOf, RouteFor, RouteName, RouteValue, RouterApi, SetSearch, ShouldBlock, SnapshotOptions, UseBlockerOptions } from "hamur/adapter";
|
|
4
|
+
/** The route on screen; one signal per component, a new value on every navigation. */
|
|
5
|
+
export declare function injectRoute<N extends RouteName>(name: N): Signal<RouteFor<N>>;
|
|
6
|
+
export declare function injectRoute<N extends RouteName = never>(): Signal<RouteFor<N>>;
|
|
7
|
+
export declare function injectRoute(): Signal<RouteValue>;
|
|
8
|
+
export declare function injectRouter(): RouterApi;
|
|
9
|
+
export declare function injectNavigation(): Signal<NavigationState>;
|
|
10
|
+
/** The app path a relative `to` leads to from the route on screen. */
|
|
11
|
+
export declare function injectResolvedPath(to: string | (() => string), { relative }?: {
|
|
12
|
+
relative?: "route";
|
|
13
|
+
}): Signal<string>;
|
|
14
|
+
/** The `context` of the nearest `Outlet` above that has one. */
|
|
15
|
+
export declare function injectOutletContext<T = unknown>(): Signal<T>;
|
|
16
|
+
/** The path segments of the route below the calling level, outermost first. */
|
|
17
|
+
export declare function injectLayoutSegments(_slot?: string): Signal<string[]>;
|
|
18
|
+
export declare function injectLayoutSegment(slot?: string): Signal<string | null>;
|
|
19
|
+
/** The layout the page renders in and its props; `{ name: false, props: {} }` when it renders none. */
|
|
20
|
+
export declare function injectLayout(): Signal<ReturnType<typeof layoutOf>>;
|
|
21
|
+
/** The matched routes, outermost first, each with its params and loader data. */
|
|
22
|
+
export declare function injectMatches(): Signal<MatchedRoute[]>;
|
|
23
|
+
/** The loader data of route `name` while it is in the matched chain, else `undefined`. */
|
|
24
|
+
export declare function injectRouteData<N extends RouteDataName>(name: N): Signal<RouteDataOf<N>>;
|
|
25
|
+
/** The validated search params of the route and a setter that replaces the entry, or pushes one with `{ replace: false }`. */
|
|
26
|
+
export declare function injectSearch(): {
|
|
27
|
+
value: Signal<RouteValue["search"]>;
|
|
28
|
+
set: SetSearch;
|
|
29
|
+
};
|
|
30
|
+
export declare function injectSearch<S>(select: (search: RouteValue["search"]) => S): {
|
|
31
|
+
value: Signal<S>;
|
|
32
|
+
set: SetSearch;
|
|
33
|
+
};
|
|
34
|
+
/** Runs `fn` before a navigation; removed when the component is destroyed. */
|
|
35
|
+
export declare function onBeforeNavigate(fn: BeforeNavigateHook): void;
|
|
36
|
+
export declare function onNavigate(fn: NavigateHook): void;
|
|
37
|
+
export declare function onAfterNavigate(fn: AfterNavigateHook): void;
|
|
38
|
+
/** Runs `fn` when the navigation leaves this page; removed when the component is destroyed. */
|
|
39
|
+
export declare function onBeforeRouteLeave(fn: NavigationGuard): void;
|
|
40
|
+
/** Runs `fn` when the navigation keeps this page and changes its params or query. */
|
|
41
|
+
export declare function onBeforeRouteUpdate(fn: NavigationGuard): void;
|
|
42
|
+
/** `fn` answers whether a navigation is stopped; removed when the component is destroyed. */
|
|
43
|
+
export declare function injectPreventNavigate(fn: NavigationBlocker): void;
|
|
44
|
+
/** A blocker held while the component lives; its state is a signal. */
|
|
45
|
+
export declare function injectBlocker(options: ShouldBlock | UseBlockerOptions): Signal<Blocker>;
|
|
46
|
+
/** Keeps `capture()` per history entry and calls `restore` when back or a reload returns to it, from the first render until the component is destroyed. */
|
|
47
|
+
export declare function injectSnapshot<T>(key: string, options: SnapshotOptions<T>): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ErrorHandler } from "@angular/core";
|
|
2
|
+
import type { ClientContext } from "hamur/adapter";
|
|
3
|
+
import type { AppContext } from "hamur/app";
|
|
4
|
+
import { type HydrationWatch } from "./hydration.ts";
|
|
5
|
+
/** A throw outside a level (a listener, an effect) is reported and the page stays; in dev it reaches the overlay. */
|
|
6
|
+
export declare class ClientErrors extends ErrorHandler {
|
|
7
|
+
private readonly app;
|
|
8
|
+
hydrating: boolean;
|
|
9
|
+
private readonly watch?;
|
|
10
|
+
private readonly viewErrors;
|
|
11
|
+
private caught;
|
|
12
|
+
/** `hydrating`: until the hydrated app is stable, a caught error stands for the `@error` block the server rendered. */
|
|
13
|
+
constructor(app: AppContext, hydrating?: boolean, watch?: HydrationWatch | undefined);
|
|
14
|
+
handleError(error: unknown): void;
|
|
15
|
+
/**
|
|
16
|
+
* An `@boundary` caught it and shows its `@error` block: `app:error` hears it once, the page stays. While hydrating the block
|
|
17
|
+
* shows the masked error, the text the server rendered there, since Angular creates that block again (A6).
|
|
18
|
+
*/
|
|
19
|
+
onViewError(error: Error): void;
|
|
20
|
+
}
|
|
21
|
+
/** The nonce a browser keeps as the DOM property of a script the server wrote. */
|
|
22
|
+
export declare const documentNonce: () => string | null;
|
|
23
|
+
/** Hydrates the server's `<hamur-app>`; event replay replays the clicks made before. */
|
|
24
|
+
export declare function hydrate(ctx: ClientContext): Promise<void>;
|
|
25
|
+
/** `ssr: false`: a new `<hamur-app>` appended to the root, without hydration. */
|
|
26
|
+
export declare function mount(ctx: ClientContext): Promise<void>;
|
|
27
|
+
/** Resolves once the new tree is in the DOM and the page's pending tasks settled. */
|
|
28
|
+
export declare function update(ctx: ClientContext): Promise<void>;
|
|
29
|
+
export { clientComponentOnClient as clientComponent, serverComponentOnClient as serverComponent } from "../wrapper.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** What `hydration-dev.ts` hands the client runtime in `hamur dev`; a production client never sets it. */
|
|
2
|
+
export interface HydrationWatch {
|
|
3
|
+
/** An error of the hydration; `true` when it is a mismatch and was reported, so it goes no further. */
|
|
4
|
+
failed(error: unknown): boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const devHydration: {
|
|
7
|
+
watch?: (root: Element, route: () => string) => HydrationWatch;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IslandContext } from "hamur/adapter";
|
|
2
|
+
/** Hydrates the island's server HTML in `el`; event replay, scoped to `el`, replays the clicks made inside it before. */
|
|
3
|
+
export declare function hydrateIsland(el: Element, component: unknown, props: Record<string, unknown>, ctx: IslandContext): Promise<void>;
|
|
4
|
+
/** Mounts the island into `el` in place of the fallback it holds. */
|
|
5
|
+
export declare function mountIsland(el: Element, component: unknown, props: Record<string, unknown>, ctx: IslandContext): Promise<void>;
|
|
6
|
+
export declare function unmountIsland(el: Element): void;
|
|
7
|
+
/** Gives the island's application new props, which keeps its state. */
|
|
8
|
+
export declare function updateIsland(el: Element, props: Record<string, unknown>): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentRenderContext, RenderContext, RenderResult } from "hamur/adapter";
|
|
2
|
+
/** Angular renders `@defer (hydrate …)` content only with hydration on, so a script-free page is rendered with it and stripped of what only a client reads. */
|
|
3
|
+
export declare function withoutHydration(document: string): string;
|
|
4
|
+
/** A throw no boundary caught fails the render, so the handler answers the error page with its status. */
|
|
5
|
+
export declare function render(ctx: RenderContext): Promise<RenderResult>;
|
|
6
|
+
/**
|
|
7
|
+
* `Island` (A8): `component` as an application of its own with `ctx.idPrefix` as its `APP_ID`. Its replay script
|
|
8
|
+
* is scoped to the island's element. The event-dispatch contract goes to the page's head once, with the first island that keeps it,
|
|
9
|
+
* so it runs before every island's replay script whatever order the islands render in.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderComponent(component: unknown, props: Record<string, unknown>, ctx: ComponentRenderContext): Promise<{
|
|
12
|
+
html: string;
|
|
13
|
+
head?: string;
|
|
14
|
+
}>;
|
|
15
|
+
export { clientComponentOnServer as clientComponent, serverComponentOnServer as serverComponent } from "../wrapper.ts";
|