@hamur/adapter-angular 0.0.0-stage → 0.0.2
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 +1075 -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 +6 -0
- package/dist/types/src/async-data.d.ts +21 -0
- package/dist/types/src/client-parts.d.ts +35 -0
- package/dist/types/src/compile.d.ts +99 -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 +8 -0
- package/dist/types/src/error.d.ts +4 -0
- package/dist/types/src/form.d.ts +68 -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 +76 -0
- package/dist/types/src/island.d.ts +42 -0
- package/dist/types/src/keepalive.d.ts +1 -0
- package/dist/types/src/link.d.ts +68 -0
- package/dist/types/src/markdown-page.d.ts +10 -0
- package/dist/types/src/markdown.d.ts +40 -0
- package/dist/types/src/mask.d.ts +12 -0
- package/dist/types/src/navigate.d.ts +17 -0
- package/dist/types/src/outlet.d.ts +76 -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 +24 -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 +40 -0
- package/dist/types/src/wrapper.d.ts +21 -0
- package/package.json +77 -4
- package/src/activation.ts +83 -0
- package/src/adapter.ts +107 -0
- package/src/app.ts +12 -0
- package/src/async-data.ts +105 -0
- package/src/client-parts.ts +107 -0
- package/src/compile.ts +963 -0
- package/src/context.ts +189 -0
- package/src/data.ts +389 -0
- package/src/definition.ts +144 -0
- package/src/error-page.ts +30 -0
- package/src/error.ts +15 -0
- package/src/form.ts +182 -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 +220 -0
- package/src/island.ts +89 -0
- package/src/keepalive.ts +1 -0
- package/src/link.ts +214 -0
- package/src/markdown-page.ts +31 -0
- package/src/markdown.ts +140 -0
- package/src/mask.ts +36 -0
- package/src/navigate.ts +22 -0
- package/src/outlet.ts +316 -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 +67 -0
- package/src/state.ts +70 -0
- package/src/svg.ts +65 -0
- package/src/time.ts +115 -0
- package/src/wrapper.ts +187 -0
|
@@ -0,0 +1,1729 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HAMUR_APP,
|
|
3
|
+
HAMUR_ROOT_TREE,
|
|
4
|
+
HAMUR_ROUTER,
|
|
5
|
+
HAMUR_NAVIGATION,
|
|
6
|
+
HAMUR_BASE_URL,
|
|
7
|
+
HAMUR_HREF,
|
|
8
|
+
HAMUR_OUTLET_CONTEXT,
|
|
9
|
+
HAMUR_ROUTE,
|
|
10
|
+
HAMUR_PAYLOAD,
|
|
11
|
+
HAMUR_FAIL,
|
|
12
|
+
HAMUR_CAUGHT,
|
|
13
|
+
HAMUR_LEVEL_DISPOSE,
|
|
14
|
+
onServer,
|
|
15
|
+
required,
|
|
16
|
+
entryOf,
|
|
17
|
+
dataOf,
|
|
18
|
+
detachedHref,
|
|
19
|
+
onPageActivated2,
|
|
20
|
+
onPageDeactivated2,
|
|
21
|
+
Outlet2,
|
|
22
|
+
DevOnly2,
|
|
23
|
+
injectDeferred2,
|
|
24
|
+
injectHydrated2,
|
|
25
|
+
injectId2,
|
|
26
|
+
onPrehydrate2,
|
|
27
|
+
transitionName2
|
|
28
|
+
} from "../chunks/browser-index-qn8q5fa2.js";
|
|
29
|
+
|
|
30
|
+
// packages/adapter-angular/src/error-page.ts
|
|
31
|
+
import { Component, input } from "@angular/core";
|
|
32
|
+
import * as i0 from "@angular/core";
|
|
33
|
+
|
|
34
|
+
class DefaultErrorPage {
|
|
35
|
+
error = input.required(...ngDevMode ? [{ debugName: "error" }] : []);
|
|
36
|
+
clearError = input(...ngDevMode ? [undefined, { debugName: "clearError" }] : []);
|
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: DefaultErrorPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.2", type: DefaultErrorPage, isStandalone: true, selector: "ng-component", inputs: { error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: true, transformFunction: null }, clearError: { classPropertyName: "clearError", publicName: "clearError", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<main style="font-family: system-ui, sans-serif; text-align: center; padding: 4rem 1rem">
|
|
39
|
+
<h1 style="font-size: 4rem; margin: 0">{{ error().status }}</h1>
|
|
40
|
+
<p>{{ error().message }}</p>
|
|
41
|
+
@if (error().stack) {
|
|
42
|
+
<pre>{{ error().stack }}</pre>
|
|
43
|
+
}
|
|
44
|
+
<a href="/">Back home</a>
|
|
45
|
+
</main>`, isInline: true });
|
|
46
|
+
}
|
|
47
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: DefaultErrorPage, decorators: [{
|
|
48
|
+
type: Component,
|
|
49
|
+
args: [{
|
|
50
|
+
template: `<main style="font-family: system-ui, sans-serif; text-align: center; padding: 4rem 1rem">
|
|
51
|
+
<h1 style="font-size: 4rem; margin: 0">{{ error().status }}</h1>
|
|
52
|
+
<p>{{ error().message }}</p>
|
|
53
|
+
@if (error().stack) {
|
|
54
|
+
<pre>{{ error().stack }}</pre>
|
|
55
|
+
}
|
|
56
|
+
<a href="/">Back home</a>
|
|
57
|
+
</main>`
|
|
58
|
+
}]
|
|
59
|
+
}], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: true }] }], clearError: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearError", required: false }] }] } });
|
|
60
|
+
// packages/adapter-angular/src/link.ts
|
|
61
|
+
import { DestroyRef, Directive, ElementRef, HostAttributeToken, InjectionToken, assertInInjectionContext, booleanAttribute, computed, effect, forwardRef, inject, input as input2, numberAttribute, output } from "@angular/core";
|
|
62
|
+
import { withoutBase } from "hamur/app";
|
|
63
|
+
import { createLinkSlot, linkAttributes, linkDefaultsOf, linkPending, linkPrefetchProps, linkState, relativeTarget, resolveLinkTarget, searchTarget, setLinkState } from "hamur/adapter";
|
|
64
|
+
import * as i02 from "@angular/core";
|
|
65
|
+
var LINK_HREF = new InjectionToken("hamur link href");
|
|
66
|
+
var optionalBoolean = (value) => value === undefined ? undefined : booleanAttribute(value);
|
|
67
|
+
|
|
68
|
+
class Link {
|
|
69
|
+
to = input2.required({ ...ngDevMode ? { debugName: "to" } : {}, alias: "hamurLink" });
|
|
70
|
+
replace = input2(false, { ...ngDevMode ? { debugName: "replace" } : {}, transform: booleanAttribute });
|
|
71
|
+
prefetch = input2(undefined, { ...ngDevMode ? { debugName: "prefetch" } : {}, transform: optionalBoolean });
|
|
72
|
+
prefetchOn = input2(...ngDevMode ? [undefined, { debugName: "prefetchOn" }] : []);
|
|
73
|
+
prefetchDelay = input2(undefined, { ...ngDevMode ? { debugName: "prefetchDelay" } : {}, transform: (value) => value === undefined ? undefined : numberAttribute(value) });
|
|
74
|
+
viewTransition = input2(...ngDevMode ? [undefined, { debugName: "viewTransition" }] : []);
|
|
75
|
+
query = input2(...ngDevMode ? [undefined, { debugName: "query" }] : []);
|
|
76
|
+
state = input2(...ngDevMode ? [undefined, { debugName: "state" }] : []);
|
|
77
|
+
relative = input2(...ngDevMode ? [undefined, { debugName: "relative" }] : []);
|
|
78
|
+
mask = input2(...ngDevMode ? [undefined, { debugName: "mask" }] : []);
|
|
79
|
+
unmaskOnReload = input2(undefined, { ...ngDevMode ? { debugName: "unmaskOnReload" } : {}, transform: optionalBoolean });
|
|
80
|
+
activeClass = input2(...ngDevMode ? [undefined, { debugName: "activeClass" }] : []);
|
|
81
|
+
exactActiveClass = input2(...ngDevMode ? [undefined, { debugName: "exactActiveClass" }] : []);
|
|
82
|
+
pendingClass = input2(...ngDevMode ? [undefined, { debugName: "pendingClass" }] : []);
|
|
83
|
+
prefetchedClass = input2(...ngDevMode ? [undefined, { debugName: "prefetchedClass" }] : []);
|
|
84
|
+
ariaCurrentValue = input2("page", ...ngDevMode ? [{ debugName: "ariaCurrentValue" }] : []);
|
|
85
|
+
external = input2(false, { ...ngDevMode ? { debugName: "external" } : {}, transform: booleanAttribute });
|
|
86
|
+
noRel = input2(false, { ...ngDevMode ? { debugName: "noRel" } : {}, transform: booleanAttribute });
|
|
87
|
+
scroll = input2(undefined, { ...ngDevMode ? { debugName: "scroll" } : {}, transform: optionalBoolean });
|
|
88
|
+
keepFocus = input2(false, { ...ngDevMode ? { debugName: "keepFocus" } : {}, transform: booleanAttribute });
|
|
89
|
+
beforeNavigate = output();
|
|
90
|
+
app = inject(HAMUR_APP, { optional: true });
|
|
91
|
+
route = inject(HAMUR_ROUTE, { optional: true });
|
|
92
|
+
resolve = inject(HAMUR_HREF, { optional: true }) ?? detachedHref;
|
|
93
|
+
baseURL = inject(HAMUR_BASE_URL, { optional: true }) ?? "/";
|
|
94
|
+
element = inject(ElementRef).nativeElement;
|
|
95
|
+
rel = inject(new HostAttributeToken("rel"), { optional: true });
|
|
96
|
+
target = inject(new HostAttributeToken("target"), { optional: true });
|
|
97
|
+
given = inject(new HostAttributeToken("aria-current"), { optional: true });
|
|
98
|
+
defaults = computed(() => linkDefaultsOf(this.app), ...ngDevMode ? [{ debugName: "defaults" }] : []);
|
|
99
|
+
classNames = computed(() => ({
|
|
100
|
+
active: this.activeClass() ?? this.defaults().activeClass,
|
|
101
|
+
exact: this.exactActiveClass() ?? this.defaults().exactActiveClass,
|
|
102
|
+
pending: this.pendingClass() ?? this.defaults().pendingClass,
|
|
103
|
+
prefetched: this.prefetchedClass() ?? this.defaults().prefetchedClass
|
|
104
|
+
}), ...ngDevMode ? [{ debugName: "classNames" }] : []);
|
|
105
|
+
linked = computed(() => {
|
|
106
|
+
const route = this.route?.();
|
|
107
|
+
const to = this.to();
|
|
108
|
+
return resolveLinkTarget(this.app, route ? searchTarget(relativeTarget(to, route, this.relative()), route, this.query()) : to, {
|
|
109
|
+
replace: this.replace(),
|
|
110
|
+
prefetch: this.prefetch(),
|
|
111
|
+
prefetchOn: this.prefetchOn(),
|
|
112
|
+
external: this.external(),
|
|
113
|
+
scroll: this.scroll(),
|
|
114
|
+
mask: this.mask(),
|
|
115
|
+
...this.target === null ? {} : { target: this.target }
|
|
116
|
+
}, this.resolve, this.external());
|
|
117
|
+
}, ...ngDevMode ? [{ debugName: "linked" }] : []);
|
|
118
|
+
matched = computed(() => {
|
|
119
|
+
const route = this.route?.();
|
|
120
|
+
const target = this.linked().to;
|
|
121
|
+
if (!route)
|
|
122
|
+
return { active: false, exact: false };
|
|
123
|
+
return linkState(typeof target === "string" ? target : withoutBase(this.href(), this.baseURL), route);
|
|
124
|
+
}, ...ngDevMode ? [{ debugName: "matched" }] : []);
|
|
125
|
+
href = computed(() => this.resolve(this.linked().to), ...ngDevMode ? [{ debugName: "href" }] : []);
|
|
126
|
+
ariaCurrent = computed(() => this.given ?? (this.matched().exact ? this.ariaCurrentValue() : undefined), ...ngDevMode ? [{ debugName: "ariaCurrent" }] : []);
|
|
127
|
+
keepFocusValue = computed(() => this.keepFocus() ? "" : undefined, ...ngDevMode ? [{ debugName: "keepFocusValue" }] : []);
|
|
128
|
+
classes = computed(() => {
|
|
129
|
+
const { active, exact } = this.matched();
|
|
130
|
+
return [active && this.classNames().active, exact && this.classNames().exact].filter(Boolean).join(" ");
|
|
131
|
+
}, ...ngDevMode ? [{ debugName: "classes" }] : []);
|
|
132
|
+
attrs = computed(() => {
|
|
133
|
+
const defaults = this.defaults();
|
|
134
|
+
return linkAttributes({
|
|
135
|
+
href: this.href(),
|
|
136
|
+
external: this.external(),
|
|
137
|
+
...linkPrefetchProps({ prefetch: this.prefetch(), prefetchOn: this.prefetchOn() }, defaults),
|
|
138
|
+
replace: this.replace(),
|
|
139
|
+
viewTransition: this.viewTransition(),
|
|
140
|
+
pendingClass: this.classNames().pending,
|
|
141
|
+
trim: !!this.query(),
|
|
142
|
+
mask: this.mask() === undefined ? undefined : this.resolve(this.mask()),
|
|
143
|
+
unmaskOnReload: this.unmaskOnReload(),
|
|
144
|
+
rel: this.rel ?? undefined,
|
|
145
|
+
target: this.target ?? undefined,
|
|
146
|
+
noRel: this.noRel(),
|
|
147
|
+
prefetchedClass: this.classNames().prefetched,
|
|
148
|
+
scroll: this.scroll(),
|
|
149
|
+
prefetchDelay: this.prefetchDelay() ?? defaults.prefetchDelay,
|
|
150
|
+
externalRelAttribute: defaults.externalRelAttribute
|
|
151
|
+
});
|
|
152
|
+
}, ...ngDevMode ? [{ debugName: "attrs" }] : []);
|
|
153
|
+
constructor() {
|
|
154
|
+
effect(() => {
|
|
155
|
+
const state = this.state();
|
|
156
|
+
setLinkState(this.element, state, (navigation) => this.beforeNavigate.emit(navigation));
|
|
157
|
+
});
|
|
158
|
+
inject(DestroyRef).onDestroy(() => setLinkState(this.element, undefined));
|
|
159
|
+
}
|
|
160
|
+
attr(name) {
|
|
161
|
+
return this.attrs()[name] ?? (name === "rel" ? this.rel ?? undefined : undefined);
|
|
162
|
+
}
|
|
163
|
+
static ɵfac = i02.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i02, type: Link, deps: [], target: i02.ɵɵFactoryTarget.Directive });
|
|
164
|
+
static ɵdir = i02.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.2", type: Link, isStandalone: true, selector: "a[hamurLink]", inputs: { to: { classPropertyName: "to", publicName: "hamurLink", isSignal: true, isRequired: true, transformFunction: null }, replace: { classPropertyName: "replace", publicName: "replace", isSignal: true, isRequired: false, transformFunction: null }, prefetch: { classPropertyName: "prefetch", publicName: "prefetch", isSignal: true, isRequired: false, transformFunction: null }, prefetchOn: { classPropertyName: "prefetchOn", publicName: "prefetchOn", isSignal: true, isRequired: false, transformFunction: null }, prefetchDelay: { classPropertyName: "prefetchDelay", publicName: "prefetchDelay", isSignal: true, isRequired: false, transformFunction: null }, viewTransition: { classPropertyName: "viewTransition", publicName: "viewTransition", isSignal: true, isRequired: false, transformFunction: null }, query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, relative: { classPropertyName: "relative", publicName: "relative", isSignal: true, isRequired: false, transformFunction: null }, mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, unmaskOnReload: { classPropertyName: "unmaskOnReload", publicName: "unmaskOnReload", isSignal: true, isRequired: false, transformFunction: null }, activeClass: { classPropertyName: "activeClass", publicName: "activeClass", isSignal: true, isRequired: false, transformFunction: null }, exactActiveClass: { classPropertyName: "exactActiveClass", publicName: "exactActiveClass", isSignal: true, isRequired: false, transformFunction: null }, pendingClass: { classPropertyName: "pendingClass", publicName: "pendingClass", isSignal: true, isRequired: false, transformFunction: null }, prefetchedClass: { classPropertyName: "prefetchedClass", publicName: "prefetchedClass", isSignal: true, isRequired: false, transformFunction: null }, ariaCurrentValue: { classPropertyName: "ariaCurrentValue", publicName: "ariaCurrentValue", isSignal: true, isRequired: false, transformFunction: null }, external: { classPropertyName: "external", publicName: "external", isSignal: true, isRequired: false, transformFunction: null }, noRel: { classPropertyName: "noRel", publicName: "noRel", isSignal: true, isRequired: false, transformFunction: null }, scroll: { classPropertyName: "scroll", publicName: "scroll", isSignal: true, isRequired: false, transformFunction: null }, keepFocus: { classPropertyName: "keepFocus", publicName: "keepFocus", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { beforeNavigate: "beforeNavigate" }, host: { properties: { "attr.href": "href()", "attr.aria-current": "ariaCurrent()", "attr.rel": "attr('rel')", "attr.data-hamur-prefetch": "attr('data-hamur-prefetch')", "attr.data-hamur-replace": "attr('data-hamur-replace')", "attr.data-hamur-view-transition": "attr('data-hamur-view-transition')", "attr.data-hamur-pending-class": "attr('data-hamur-pending-class')", "attr.data-hamur-trim": "attr('data-hamur-trim')", "attr.data-hamur-mask": "attr('data-hamur-mask')", "attr.data-hamur-unmask": "attr('data-hamur-unmask')", "attr.data-hamur-prefetched-class": "attr('data-hamur-prefetched-class')", "attr.data-hamur-scroll": "attr('data-hamur-scroll')", "attr.data-hamur-prefetch-delay": "attr('data-hamur-prefetch-delay')", "attr.data-hamur-keepfocus": "keepFocusValue()", class: "classes()" } }, providers: [{ provide: LINK_HREF, useExisting: forwardRef(() => Link) }], ngImport: i02 });
|
|
165
|
+
}
|
|
166
|
+
i02.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i02, type: Link, decorators: [{
|
|
167
|
+
type: Directive,
|
|
168
|
+
args: [{
|
|
169
|
+
selector: "a[hamurLink]",
|
|
170
|
+
providers: [{ provide: LINK_HREF, useExisting: forwardRef(() => Link) }],
|
|
171
|
+
host: {
|
|
172
|
+
"[attr.href]": "href()",
|
|
173
|
+
"[attr.aria-current]": "ariaCurrent()",
|
|
174
|
+
"[attr.rel]": "attr('rel')",
|
|
175
|
+
"[attr.data-hamur-prefetch]": "attr('data-hamur-prefetch')",
|
|
176
|
+
"[attr.data-hamur-replace]": "attr('data-hamur-replace')",
|
|
177
|
+
"[attr.data-hamur-view-transition]": "attr('data-hamur-view-transition')",
|
|
178
|
+
"[attr.data-hamur-pending-class]": "attr('data-hamur-pending-class')",
|
|
179
|
+
"[attr.data-hamur-trim]": "attr('data-hamur-trim')",
|
|
180
|
+
"[attr.data-hamur-mask]": "attr('data-hamur-mask')",
|
|
181
|
+
"[attr.data-hamur-unmask]": "attr('data-hamur-unmask')",
|
|
182
|
+
"[attr.data-hamur-prefetched-class]": "attr('data-hamur-prefetched-class')",
|
|
183
|
+
"[attr.data-hamur-scroll]": "attr('data-hamur-scroll')",
|
|
184
|
+
"[attr.data-hamur-prefetch-delay]": "attr('data-hamur-prefetch-delay')",
|
|
185
|
+
"[attr.data-hamur-keepfocus]": "keepFocusValue()",
|
|
186
|
+
"[class]": "classes()"
|
|
187
|
+
}
|
|
188
|
+
}]
|
|
189
|
+
}], ctorParameters: () => [], propDecorators: { to: [{ type: i02.Input, args: [{ isSignal: true, alias: "hamurLink", required: true }] }], replace: [{ type: i02.Input, args: [{ isSignal: true, alias: "replace", required: false }] }], prefetch: [{ type: i02.Input, args: [{ isSignal: true, alias: "prefetch", required: false }] }], prefetchOn: [{ type: i02.Input, args: [{ isSignal: true, alias: "prefetchOn", required: false }] }], prefetchDelay: [{ type: i02.Input, args: [{ isSignal: true, alias: "prefetchDelay", required: false }] }], viewTransition: [{ type: i02.Input, args: [{ isSignal: true, alias: "viewTransition", required: false }] }], query: [{ type: i02.Input, args: [{ isSignal: true, alias: "query", required: false }] }], state: [{ type: i02.Input, args: [{ isSignal: true, alias: "state", required: false }] }], relative: [{ type: i02.Input, args: [{ isSignal: true, alias: "relative", required: false }] }], mask: [{ type: i02.Input, args: [{ isSignal: true, alias: "mask", required: false }] }], unmaskOnReload: [{ type: i02.Input, args: [{ isSignal: true, alias: "unmaskOnReload", required: false }] }], activeClass: [{ type: i02.Input, args: [{ isSignal: true, alias: "activeClass", required: false }] }], exactActiveClass: [{ type: i02.Input, args: [{ isSignal: true, alias: "exactActiveClass", required: false }] }], pendingClass: [{ type: i02.Input, args: [{ isSignal: true, alias: "pendingClass", required: false }] }], prefetchedClass: [{ type: i02.Input, args: [{ isSignal: true, alias: "prefetchedClass", required: false }] }], ariaCurrentValue: [{ type: i02.Input, args: [{ isSignal: true, alias: "ariaCurrentValue", required: false }] }], external: [{ type: i02.Input, args: [{ isSignal: true, alias: "external", required: false }] }], noRel: [{ type: i02.Input, args: [{ isSignal: true, alias: "noRel", required: false }] }], scroll: [{ type: i02.Input, args: [{ isSignal: true, alias: "scroll", required: false }] }], keepFocus: [{ type: i02.Input, args: [{ isSignal: true, alias: "keepFocus", required: false }] }], beforeNavigate: [{ type: i02.Output, args: ["beforeNavigate"] }] } });
|
|
190
|
+
function injectLink(to, options) {
|
|
191
|
+
assertInInjectionContext(injectLink);
|
|
192
|
+
const app = inject(HAMUR_APP, { optional: true });
|
|
193
|
+
const route = inject(HAMUR_ROUTE, { optional: true });
|
|
194
|
+
const router = inject(HAMUR_ROUTER, { optional: true });
|
|
195
|
+
const navigation = inject(HAMUR_NAVIGATION, { optional: true });
|
|
196
|
+
const resolve = inject(HAMUR_HREF, { optional: true }) ?? detachedHref;
|
|
197
|
+
const baseURL = inject(HAMUR_BASE_URL, { optional: true }) ?? "/";
|
|
198
|
+
return computed(() => {
|
|
199
|
+
const given = (typeof options === "function" ? options() : options) ?? {};
|
|
200
|
+
const defaults = linkDefaultsOf(app);
|
|
201
|
+
const base = typeof to === "function" ? to() : to;
|
|
202
|
+
const current = route?.();
|
|
203
|
+
const searched = current ? searchTarget(relativeTarget(base, current, given.relative), current, given.query) : base;
|
|
204
|
+
const { to: target } = resolveLinkTarget(app, searched, given, resolve, given.external);
|
|
205
|
+
const href = resolve(target);
|
|
206
|
+
const state = current ? linkState(typeof target === "string" ? target : withoutBase(href, baseURL), current) : { active: false, exact: false };
|
|
207
|
+
return createLinkSlot({
|
|
208
|
+
href,
|
|
209
|
+
to: target,
|
|
210
|
+
attrs: linkAttributes({
|
|
211
|
+
href,
|
|
212
|
+
external: given.external,
|
|
213
|
+
...linkPrefetchProps({}, defaults),
|
|
214
|
+
replace: given.replace,
|
|
215
|
+
viewTransition: given.viewTransition,
|
|
216
|
+
pendingClass: defaults.pendingClass,
|
|
217
|
+
trim: !!given.query,
|
|
218
|
+
ariaCurrent: state.exact ? "page" : undefined,
|
|
219
|
+
prefetchedClass: defaults.prefetchedClass,
|
|
220
|
+
scroll: given.scroll,
|
|
221
|
+
prefetchDelay: defaults.prefetchDelay,
|
|
222
|
+
externalRelAttribute: defaults.externalRelAttribute
|
|
223
|
+
}),
|
|
224
|
+
active: state.active,
|
|
225
|
+
exact: state.exact,
|
|
226
|
+
pending: navigation ? linkPending(href, navigation(), baseURL) : false,
|
|
227
|
+
external: given.external,
|
|
228
|
+
options: {
|
|
229
|
+
replace: given.replace,
|
|
230
|
+
state: given.state,
|
|
231
|
+
viewTransition: given.viewTransition,
|
|
232
|
+
scroll: given.scroll === false ? false : undefined
|
|
233
|
+
},
|
|
234
|
+
router
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function injectLinkStatus() {
|
|
239
|
+
assertInInjectionContext(injectLinkStatus);
|
|
240
|
+
const link = inject(LINK_HREF, { optional: true });
|
|
241
|
+
const navigation = inject(HAMUR_NAVIGATION, { optional: true });
|
|
242
|
+
const baseURL = inject(HAMUR_BASE_URL, { optional: true }) ?? "/";
|
|
243
|
+
return { pending: computed(() => !!link && !!navigation && linkPending(link.href(), navigation(), baseURL)) };
|
|
244
|
+
}
|
|
245
|
+
// packages/adapter-angular/src/navigate.ts
|
|
246
|
+
import { Component as Component2, afterNextRender, booleanAttribute as booleanAttribute2, input as input3 } from "@angular/core";
|
|
247
|
+
import { navigateTo, redirect } from "hamur/app";
|
|
248
|
+
import * as i03 from "@angular/core";
|
|
249
|
+
|
|
250
|
+
class Navigate {
|
|
251
|
+
to = input3.required(...ngDevMode ? [{ debugName: "to" }] : []);
|
|
252
|
+
replace = input3(false, { ...ngDevMode ? { debugName: "replace" } : {}, transform: booleanAttribute2 });
|
|
253
|
+
constructor() {
|
|
254
|
+
afterNextRender(() => void navigateTo(this.to(), { replace: this.replace() }));
|
|
255
|
+
}
|
|
256
|
+
ngOnInit() {
|
|
257
|
+
if (typeof window === "undefined")
|
|
258
|
+
throw redirect(this.to());
|
|
259
|
+
}
|
|
260
|
+
static ɵfac = i03.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i03, type: Navigate, deps: [], target: i03.ɵɵFactoryTarget.Component });
|
|
261
|
+
static ɵcmp = i03.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: Navigate, isStandalone: true, selector: "hamur-navigate", inputs: { to: { classPropertyName: "to", publicName: "to", isSignal: true, isRequired: true, transformFunction: null }, replace: { classPropertyName: "replace", publicName: "replace", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i03, template: "", isInline: true });
|
|
262
|
+
}
|
|
263
|
+
i03.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i03, type: Navigate, decorators: [{
|
|
264
|
+
type: Component2,
|
|
265
|
+
args: [{ selector: "hamur-navigate", template: "" }]
|
|
266
|
+
}], ctorParameters: () => [], propDecorators: { to: [{ type: i03.Input, args: [{ isSignal: true, alias: "to", required: true }] }], replace: [{ type: i03.Input, args: [{ isSignal: true, alias: "replace", required: false }] }] } });
|
|
267
|
+
// packages/adapter-angular/src/error.ts
|
|
268
|
+
import { DestroyRef as DestroyRef2, assertInInjectionContext as assertInInjectionContext2, computed as computed2, inject as inject2, signal, untracked } from "@angular/core";
|
|
269
|
+
function injectError() {
|
|
270
|
+
assertInInjectionContext2(injectError);
|
|
271
|
+
const caught = inject2(HAMUR_CAUGHT, { optional: true });
|
|
272
|
+
if (caught)
|
|
273
|
+
return signal(caught).asReadonly();
|
|
274
|
+
const store = required(HAMUR_APP, "injectError").error;
|
|
275
|
+
const route = required(HAMUR_ROUTE, "injectError");
|
|
276
|
+
const error = signal(store ? store.get() : untracked(route).error);
|
|
277
|
+
if (store)
|
|
278
|
+
inject2(DestroyRef2).onDestroy(store.subscribe(() => error.set(store.get())));
|
|
279
|
+
return computed2(() => error() ?? null);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// packages/adapter-angular/src/index.ts
|
|
283
|
+
import { clearError, forbidden, navigateTo as navigateTo2, notFound, permanentRedirect, showError, unauthorized } from "hamur/app";
|
|
284
|
+
|
|
285
|
+
// packages/adapter-angular/src/data.ts
|
|
286
|
+
import {
|
|
287
|
+
DestroyRef as DestroyRef3,
|
|
288
|
+
PendingTasks,
|
|
289
|
+
assertInInjectionContext as assertInInjectionContext3,
|
|
290
|
+
computed as computed3,
|
|
291
|
+
effect as effect2,
|
|
292
|
+
inject as inject3,
|
|
293
|
+
signal as signal2,
|
|
294
|
+
untracked as untracked2
|
|
295
|
+
} from "@angular/core";
|
|
296
|
+
import { asyncDataArguments, asyncDataKey as asyncDataKey2, isHandlerReference, isPending } from "hamur/adapter";
|
|
297
|
+
import { callOnce as callOnceOf, clearAsyncData, clearState as clearStateOf } from "hamur/app";
|
|
298
|
+
|
|
299
|
+
// packages/adapter-angular/src/async-data.ts
|
|
300
|
+
import { asyncDataKey, fetchKey, isPreviewMode } from "hamur/adapter";
|
|
301
|
+
import { $fetch } from "hamur/app";
|
|
302
|
+
var valueOf = (value) => typeof value === "function" ? value() : value;
|
|
303
|
+
function requestOf({ query, body, ...rest }) {
|
|
304
|
+
const request = rest;
|
|
305
|
+
const resolvedQuery = valueOf(query);
|
|
306
|
+
const resolvedBody = valueOf(body);
|
|
307
|
+
if (resolvedQuery !== undefined)
|
|
308
|
+
request.query = resolvedQuery;
|
|
309
|
+
if (resolvedBody !== undefined)
|
|
310
|
+
request.body = resolvedBody;
|
|
311
|
+
return request;
|
|
312
|
+
}
|
|
313
|
+
function fetchSlots(url, options, fetcher = $fetch, fixedKey) {
|
|
314
|
+
const requests = new Map;
|
|
315
|
+
return {
|
|
316
|
+
keyOf() {
|
|
317
|
+
const target = valueOf(url);
|
|
318
|
+
const request = requestOf(options);
|
|
319
|
+
const key = fixedKey ?? fetchKey(target, request);
|
|
320
|
+
requests.set(key, { url: target, request });
|
|
321
|
+
return key;
|
|
322
|
+
},
|
|
323
|
+
handlerFor(key) {
|
|
324
|
+
const { url: target, request } = requests.get(key);
|
|
325
|
+
return ({ signal }) => fetcher(target, { ...request, signal: signalOf(request.signal, signal) });
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function handlerSlots(app, fn, input) {
|
|
330
|
+
const inputs = new Map;
|
|
331
|
+
return {
|
|
332
|
+
keyOf() {
|
|
333
|
+
const value = valueOf(input);
|
|
334
|
+
const key = asyncDataKey(fn, value);
|
|
335
|
+
inputs.set(key, value);
|
|
336
|
+
return key;
|
|
337
|
+
},
|
|
338
|
+
handlerFor(key) {
|
|
339
|
+
const value = inputs.get(key);
|
|
340
|
+
return ({ signal }) => fn(value, {
|
|
341
|
+
signal,
|
|
342
|
+
event: app.event
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function defaultGetCachedData(key, app) {
|
|
348
|
+
if (!app.asyncData.hydrating || isPreviewMode(app))
|
|
349
|
+
return;
|
|
350
|
+
const entry = app.asyncData.get(key);
|
|
351
|
+
return entry?.status === "success" ? entry.data : undefined;
|
|
352
|
+
}
|
|
353
|
+
function refreshCached(app, key, handler, options, getCachedData, cause) {
|
|
354
|
+
const cached = getCachedData(key, app, { cause });
|
|
355
|
+
if (cached !== undefined) {
|
|
356
|
+
app.asyncData.fetch(key, handler, { ...options, cached });
|
|
357
|
+
return Promise.resolve();
|
|
358
|
+
}
|
|
359
|
+
if (!app.asyncData.has(key))
|
|
360
|
+
app.asyncData.fetch(key, handler, { ...options, immediate: false });
|
|
361
|
+
return app.asyncData.refresh(key, handler);
|
|
362
|
+
}
|
|
363
|
+
var kept = new WeakMap;
|
|
364
|
+
function keepCached(app, key, getCachedData) {
|
|
365
|
+
if (getCachedData === defaultGetCachedData)
|
|
366
|
+
return;
|
|
367
|
+
let keys = kept.get(app.asyncData);
|
|
368
|
+
if (!keys)
|
|
369
|
+
kept.set(app.asyncData, keys = new Set);
|
|
370
|
+
if (keys.has(key))
|
|
371
|
+
return;
|
|
372
|
+
keys.add(key);
|
|
373
|
+
app.asyncData.subscribe(key, () => {});
|
|
374
|
+
}
|
|
375
|
+
var signalOf = (own, run) => own ? AbortSignal.any([own, run]) : run;
|
|
376
|
+
|
|
377
|
+
// packages/adapter-angular/src/data.ts
|
|
378
|
+
function resourceOf(app, current, refresh, clear) {
|
|
379
|
+
const snapshot = computed3(() => {
|
|
380
|
+
const entry = current();
|
|
381
|
+
if (entry?.status === "error")
|
|
382
|
+
return { status: "error", error: entry.error };
|
|
383
|
+
const value = entry?.data;
|
|
384
|
+
const status = entry?.status ?? "idle";
|
|
385
|
+
if (status === "pending")
|
|
386
|
+
return { status: value === undefined ? "loading" : "reloading", value };
|
|
387
|
+
return { status: status === "success" ? "resolved" : "idle", value };
|
|
388
|
+
});
|
|
389
|
+
const value = computed3(() => {
|
|
390
|
+
const read = snapshot();
|
|
391
|
+
if (read.status === "error")
|
|
392
|
+
throw read.error;
|
|
393
|
+
return read.value;
|
|
394
|
+
});
|
|
395
|
+
return {
|
|
396
|
+
value,
|
|
397
|
+
status: computed3(() => snapshot().status),
|
|
398
|
+
error: computed3(() => {
|
|
399
|
+
const read = snapshot();
|
|
400
|
+
return read.status === "error" ? read.error : undefined;
|
|
401
|
+
}),
|
|
402
|
+
isLoading: computed3(() => {
|
|
403
|
+
const entry = current();
|
|
404
|
+
return entry !== undefined && isPending(app, entry);
|
|
405
|
+
}),
|
|
406
|
+
snapshot,
|
|
407
|
+
hasValue: () => {
|
|
408
|
+
const read = snapshot();
|
|
409
|
+
return read.status !== "error" && read.value !== undefined;
|
|
410
|
+
},
|
|
411
|
+
refresh,
|
|
412
|
+
clear
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function keyedAsyncData(key, handlerFor, options, name) {
|
|
416
|
+
const app = required(HAMUR_APP, name);
|
|
417
|
+
const store = app.asyncData;
|
|
418
|
+
const tasks = inject3(PendingTasks);
|
|
419
|
+
const destroy = inject3(DestroyRef3);
|
|
420
|
+
const server = onServer();
|
|
421
|
+
const {
|
|
422
|
+
server: runsOnServer,
|
|
423
|
+
lazy,
|
|
424
|
+
default: init,
|
|
425
|
+
transform,
|
|
426
|
+
immediate,
|
|
427
|
+
dedupe,
|
|
428
|
+
pick,
|
|
429
|
+
watch,
|
|
430
|
+
getCachedData = defaultGetCachedData
|
|
431
|
+
} = options;
|
|
432
|
+
const settings = {
|
|
433
|
+
server: runsOnServer,
|
|
434
|
+
lazy,
|
|
435
|
+
default: init,
|
|
436
|
+
transform,
|
|
437
|
+
immediate,
|
|
438
|
+
dedupe,
|
|
439
|
+
pick
|
|
440
|
+
};
|
|
441
|
+
const hold = (entry) => {
|
|
442
|
+
if (entry.status !== "pending" || !entry.promise || lazy === true && !server)
|
|
443
|
+
return;
|
|
444
|
+
const release = tasks.add();
|
|
445
|
+
entry.promise.then(() => void setTimeout(release));
|
|
446
|
+
};
|
|
447
|
+
const first = (active) => {
|
|
448
|
+
keepCached(app, active, getCachedData);
|
|
449
|
+
const entry = store.fetch(active, handlerFor(active), {
|
|
450
|
+
...settings,
|
|
451
|
+
cached: getCachedData(active, app, { cause: "initial" })
|
|
452
|
+
});
|
|
453
|
+
hold(entry);
|
|
454
|
+
return entry;
|
|
455
|
+
};
|
|
456
|
+
const keyNow = computed3(() => valueOf(key));
|
|
457
|
+
const initial = untracked2(keyNow);
|
|
458
|
+
let entry = first(initial);
|
|
459
|
+
const active = signal2(initial);
|
|
460
|
+
const version = signal2(0);
|
|
461
|
+
const bump = () => version.update((count) => count + 1);
|
|
462
|
+
let unsubscribe = store.subscribe(initial, bump);
|
|
463
|
+
let unhook = store.onRefresh(initial, () => again("refresh:hook"));
|
|
464
|
+
destroy.onDestroy(() => (unsubscribe(), unhook()));
|
|
465
|
+
const again = (cause) => {
|
|
466
|
+
const current = untracked2(active);
|
|
467
|
+
return refreshCached(app, current, handlerFor(current), settings, getCachedData, cause);
|
|
468
|
+
};
|
|
469
|
+
if (typeof key === "function")
|
|
470
|
+
effect2(() => {
|
|
471
|
+
const next = keyNow();
|
|
472
|
+
untracked2(() => {
|
|
473
|
+
if (next === active())
|
|
474
|
+
return;
|
|
475
|
+
unsubscribe();
|
|
476
|
+
unhook();
|
|
477
|
+
entry = first(next);
|
|
478
|
+
unsubscribe = store.subscribe(next, bump);
|
|
479
|
+
unhook = store.onRefresh(next, () => again("refresh:hook"));
|
|
480
|
+
active.set(next);
|
|
481
|
+
bump();
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
if (Array.isArray(watch) && watch.length) {
|
|
485
|
+
let started = false;
|
|
486
|
+
effect2(() => {
|
|
487
|
+
for (const source of watch)
|
|
488
|
+
source();
|
|
489
|
+
if (!started) {
|
|
490
|
+
started = true;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
untracked2(() => void again("watch"));
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
const current = () => {
|
|
497
|
+
version();
|
|
498
|
+
return store.get(active()) ?? entry;
|
|
499
|
+
};
|
|
500
|
+
return resourceOf(app, current, () => again("refresh:manual"), () => clearAsyncData(app, untracked2(active)));
|
|
501
|
+
}
|
|
502
|
+
function injectAsyncData(...args) {
|
|
503
|
+
assertInInjectionContext3(injectAsyncData);
|
|
504
|
+
return asyncData("injectAsyncData", args);
|
|
505
|
+
}
|
|
506
|
+
function asyncData(name, args) {
|
|
507
|
+
const [first, second, given] = asyncDataArguments(name, args);
|
|
508
|
+
const options = given ?? {};
|
|
509
|
+
if (!isHandlerReference(first))
|
|
510
|
+
return keyedAsyncData(first, () => second, options, name);
|
|
511
|
+
const { keyOf, handlerFor } = handlerSlots(required(HAMUR_APP, name), first, second);
|
|
512
|
+
return keyedAsyncData(keyOf, handlerFor, options, name);
|
|
513
|
+
}
|
|
514
|
+
function injectFetch(url, options = {}) {
|
|
515
|
+
assertInInjectionContext3(injectFetch);
|
|
516
|
+
return fetchWith(url, options, "injectFetch");
|
|
517
|
+
}
|
|
518
|
+
function fetchWith(url, options, name) {
|
|
519
|
+
const {
|
|
520
|
+
key,
|
|
521
|
+
server,
|
|
522
|
+
lazy,
|
|
523
|
+
default: init,
|
|
524
|
+
transform,
|
|
525
|
+
immediate,
|
|
526
|
+
dedupe,
|
|
527
|
+
pick,
|
|
528
|
+
watch,
|
|
529
|
+
getCachedData,
|
|
530
|
+
...rest
|
|
531
|
+
} = options;
|
|
532
|
+
const app = required(HAMUR_APP, name);
|
|
533
|
+
const { keyOf, handlerFor } = fetchSlots(url, rest, app.fetch, key);
|
|
534
|
+
return keyedAsyncData(keyOf, handlerFor, { server, lazy, default: init, transform, immediate, dedupe, pick, watch, getCachedData }, name);
|
|
535
|
+
}
|
|
536
|
+
var injectLazyFetch = (url, options) => {
|
|
537
|
+
assertInInjectionContext3(injectLazyFetch);
|
|
538
|
+
return fetchWith(url, { ...options, lazy: true }, "injectLazyFetch");
|
|
539
|
+
};
|
|
540
|
+
var injectLazyAsyncData = (...args) => {
|
|
541
|
+
assertInInjectionContext3(injectLazyAsyncData);
|
|
542
|
+
const [first, second, options] = asyncDataArguments("injectLazyAsyncData", args);
|
|
543
|
+
return asyncData("injectLazyAsyncData", [
|
|
544
|
+
first,
|
|
545
|
+
second,
|
|
546
|
+
{ ...options, lazy: true }
|
|
547
|
+
]);
|
|
548
|
+
};
|
|
549
|
+
function injectNuxtData(target, input) {
|
|
550
|
+
assertInInjectionContext3(injectNuxtData);
|
|
551
|
+
const app = required(HAMUR_APP, "injectNuxtData");
|
|
552
|
+
const store = app.asyncData;
|
|
553
|
+
const key = typeof target === "string" ? target : asyncDataKey2(target, valueOf(input));
|
|
554
|
+
const version = signal2(0);
|
|
555
|
+
const off = store.subscribe(key, () => version.update((count) => count + 1));
|
|
556
|
+
inject3(DestroyRef3).onDestroy(off);
|
|
557
|
+
return resourceOf(app, () => {
|
|
558
|
+
version();
|
|
559
|
+
return store.get(key);
|
|
560
|
+
}, () => store.has(key) ? store.refresh(key) : Promise.resolve(), () => clearAsyncData(app, key));
|
|
561
|
+
}
|
|
562
|
+
function injectData(..._route) {
|
|
563
|
+
assertInInjectionContext3(injectData);
|
|
564
|
+
const payload = required(HAMUR_PAYLOAD, "injectData");
|
|
565
|
+
const entry = entryOf("injectData");
|
|
566
|
+
return computed3(() => dataOf(payload)[entry()] ?? null);
|
|
567
|
+
}
|
|
568
|
+
function clearState(keys, options) {
|
|
569
|
+
assertInInjectionContext3(clearState);
|
|
570
|
+
clearStateOf(required(HAMUR_APP, "clearState"), keys, options);
|
|
571
|
+
}
|
|
572
|
+
function callOnce(key, fn, options) {
|
|
573
|
+
assertInInjectionContext3(callOnce);
|
|
574
|
+
return callOnceOf(required(HAMUR_APP, "callOnce"), key, fn, options);
|
|
575
|
+
}
|
|
576
|
+
// packages/adapter-angular/src/head.ts
|
|
577
|
+
import { DestroyRef as DestroyRef4, assertInInjectionContext as assertInInjectionContext4, effect as effect3, inject as inject4, untracked as untracked3 } from "@angular/core";
|
|
578
|
+
import { sanitizeHead, seoMetaToHead } from "hamur/adapter";
|
|
579
|
+
var resolve = (input) => typeof input === "function" ? input() : input;
|
|
580
|
+
function injectHead(input) {
|
|
581
|
+
assertInInjectionContext4(injectHead);
|
|
582
|
+
const head = required(HAMUR_APP, "injectHead").head;
|
|
583
|
+
const server = onServer();
|
|
584
|
+
const entry = head.push(untracked3(() => resolve(input)));
|
|
585
|
+
if (!server) {
|
|
586
|
+
let disposed = false;
|
|
587
|
+
const dispose = () => {
|
|
588
|
+
if (disposed)
|
|
589
|
+
return;
|
|
590
|
+
disposed = true;
|
|
591
|
+
entry.dispose();
|
|
592
|
+
head.apply();
|
|
593
|
+
};
|
|
594
|
+
inject4(DestroyRef4).onDestroy(dispose);
|
|
595
|
+
inject4(HAMUR_LEVEL_DISPOSE, { optional: true })?.(dispose);
|
|
596
|
+
}
|
|
597
|
+
effect3(() => {
|
|
598
|
+
const next = resolve(input);
|
|
599
|
+
untracked3(() => {
|
|
600
|
+
entry.patch(next);
|
|
601
|
+
if (!server)
|
|
602
|
+
head.apply();
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function injectSeoMeta(input) {
|
|
607
|
+
assertInInjectionContext4(injectSeoMeta);
|
|
608
|
+
injectHead(() => seoMetaToHead(resolve(input)));
|
|
609
|
+
}
|
|
610
|
+
function injectHeadSafe(input) {
|
|
611
|
+
assertInInjectionContext4(injectHeadSafe);
|
|
612
|
+
injectHead(() => sanitizeHead(resolve(input)));
|
|
613
|
+
}
|
|
614
|
+
function injectServerHead(input) {
|
|
615
|
+
assertInInjectionContext4(injectServerHead);
|
|
616
|
+
const head = required(HAMUR_APP, "injectServerHead").head;
|
|
617
|
+
if (!onServer())
|
|
618
|
+
return;
|
|
619
|
+
const entry = head.push(untracked3(() => resolve(input)), { server: true });
|
|
620
|
+
if (typeof input === "function")
|
|
621
|
+
effect3(() => entry.patch(resolve(input)));
|
|
622
|
+
}
|
|
623
|
+
function injectServerSeoMeta(input) {
|
|
624
|
+
assertInInjectionContext4(injectServerSeoMeta);
|
|
625
|
+
injectServerHead(() => seoMetaToHead(resolve(input)));
|
|
626
|
+
}
|
|
627
|
+
// packages/adapter-angular/src/state.ts
|
|
628
|
+
import {
|
|
629
|
+
DestroyRef as DestroyRef5,
|
|
630
|
+
afterNextRender as afterNextRender2,
|
|
631
|
+
assertInInjectionContext as assertInInjectionContext5,
|
|
632
|
+
computed as computed4,
|
|
633
|
+
inject as inject5,
|
|
634
|
+
signal as signal3,
|
|
635
|
+
untracked as untracked4
|
|
636
|
+
} from "@angular/core";
|
|
637
|
+
import { stateArguments } from "hamur/adapter";
|
|
638
|
+
import { syncedState, useCookie as cookieOf } from "hamur/app";
|
|
639
|
+
function writableOf(source, write) {
|
|
640
|
+
const read = computed4(source);
|
|
641
|
+
return Object.assign(read, {
|
|
642
|
+
set: write,
|
|
643
|
+
update: (change) => write(change(untracked4(source))),
|
|
644
|
+
asReadonly: () => read
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
function injectState(...args) {
|
|
648
|
+
assertInInjectionContext5(injectState);
|
|
649
|
+
const { key, init } = stateArguments(args);
|
|
650
|
+
const store = required(HAMUR_APP, "injectState").state;
|
|
651
|
+
const value = signal3(store.use(key, init));
|
|
652
|
+
inject5(DestroyRef5).onDestroy(store.subscribe(key, (next) => value.set(next)));
|
|
653
|
+
return writableOf(value, (next) => store.set(key, next));
|
|
654
|
+
}
|
|
655
|
+
function injectCookie(name, options = {}) {
|
|
656
|
+
assertInInjectionContext5(injectCookie);
|
|
657
|
+
const cookie = cookieOf(name, { ...options, app: required(HAMUR_APP, "injectCookie") });
|
|
658
|
+
const value = signal3(cookie.get());
|
|
659
|
+
inject5(DestroyRef5).onDestroy(cookie.subscribe((next) => value.set(next)));
|
|
660
|
+
return writableOf(value, (next) => cookie.set(next));
|
|
661
|
+
}
|
|
662
|
+
function injectSyncedState(key, initial, options = {}) {
|
|
663
|
+
assertInInjectionContext5(injectSyncedState);
|
|
664
|
+
const state = syncedState(key, initial, options);
|
|
665
|
+
const value = signal3(initial);
|
|
666
|
+
const destroy = inject5(DestroyRef5);
|
|
667
|
+
afterNextRender2(() => {
|
|
668
|
+
value.set(state.get());
|
|
669
|
+
destroy.onDestroy(state.subscribe((next) => value.set(next)));
|
|
670
|
+
});
|
|
671
|
+
return writableOf(value, (next) => state.set(next));
|
|
672
|
+
}
|
|
673
|
+
// packages/adapter-angular/src/time.ts
|
|
674
|
+
import { Directive as Directive2, afterRenderEffect, booleanAttribute as booleanAttribute3, computed as computed5, inject as inject6, input as input4, numberAttribute as numberAttribute2, signal as signal4 } from "@angular/core";
|
|
675
|
+
import { timeView, watchTime } from "hamur/adapter";
|
|
676
|
+
import * as i04 from "@angular/core";
|
|
677
|
+
var optionalBoolean2 = (value) => value === undefined ? undefined : booleanAttribute3(value);
|
|
678
|
+
var optionalNumber = (value) => value === undefined ? undefined : numberAttribute2(value);
|
|
679
|
+
|
|
680
|
+
class Time {
|
|
681
|
+
datetime = input4.required({ ...ngDevMode ? { debugName: "datetime" } : {}, alias: "hamurTime" });
|
|
682
|
+
locale = input4(...ngDevMode ? [undefined, { debugName: "locale" }] : []);
|
|
683
|
+
timeZone = input4(...ngDevMode ? [undefined, { debugName: "timeZone" }] : []);
|
|
684
|
+
relative = input4(false, { ...ngDevMode ? { debugName: "relative" } : {}, transform: booleanAttribute3 });
|
|
685
|
+
relativeInterval = input4(undefined, { ...ngDevMode ? { debugName: "relativeInterval" } : {}, transform: optionalNumber });
|
|
686
|
+
calendar = input4(...ngDevMode ? [undefined, { debugName: "calendar" }] : []);
|
|
687
|
+
dayPeriod = input4(...ngDevMode ? [undefined, { debugName: "dayPeriod" }] : []);
|
|
688
|
+
numberingSystem = input4(...ngDevMode ? [undefined, { debugName: "numberingSystem" }] : []);
|
|
689
|
+
dateStyle = input4(...ngDevMode ? [undefined, { debugName: "dateStyle" }] : []);
|
|
690
|
+
timeStyle = input4(...ngDevMode ? [undefined, { debugName: "timeStyle" }] : []);
|
|
691
|
+
hourCycle = input4(...ngDevMode ? [undefined, { debugName: "hourCycle" }] : []);
|
|
692
|
+
hour12 = input4(undefined, { ...ngDevMode ? { debugName: "hour12" } : {}, transform: optionalBoolean2 });
|
|
693
|
+
localeMatcher = input4(...ngDevMode ? [undefined, { debugName: "localeMatcher" }] : []);
|
|
694
|
+
formatMatcher = input4(...ngDevMode ? [undefined, { debugName: "formatMatcher" }] : []);
|
|
695
|
+
weekday = input4(...ngDevMode ? [undefined, { debugName: "weekday" }] : []);
|
|
696
|
+
era = input4(...ngDevMode ? [undefined, { debugName: "era" }] : []);
|
|
697
|
+
year = input4(...ngDevMode ? [undefined, { debugName: "year" }] : []);
|
|
698
|
+
month = input4(...ngDevMode ? [undefined, { debugName: "month" }] : []);
|
|
699
|
+
day = input4(...ngDevMode ? [undefined, { debugName: "day" }] : []);
|
|
700
|
+
hour = input4(...ngDevMode ? [undefined, { debugName: "hour" }] : []);
|
|
701
|
+
minute = input4(...ngDevMode ? [undefined, { debugName: "minute" }] : []);
|
|
702
|
+
second = input4(...ngDevMode ? [undefined, { debugName: "second" }] : []);
|
|
703
|
+
fractionalSecondDigits = input4(undefined, { ...ngDevMode ? { debugName: "fractionalSecondDigits" } : {}, transform: optionalNumber });
|
|
704
|
+
timeZoneName = input4(...ngDevMode ? [undefined, { debugName: "timeZoneName" }] : []);
|
|
705
|
+
app = required(HAMUR_APP, "Time");
|
|
706
|
+
route = inject6(HAMUR_ROUTE, { optional: true });
|
|
707
|
+
now = signal4(undefined, ...ngDevMode ? [{ debugName: "now" }] : []);
|
|
708
|
+
props = computed5(() => {
|
|
709
|
+
const given = {
|
|
710
|
+
datetime: this.datetime(),
|
|
711
|
+
locale: this.locale(),
|
|
712
|
+
timeZone: this.timeZone(),
|
|
713
|
+
relative: this.relative(),
|
|
714
|
+
relativeInterval: this.relativeInterval(),
|
|
715
|
+
calendar: this.calendar(),
|
|
716
|
+
dayPeriod: this.dayPeriod(),
|
|
717
|
+
numberingSystem: this.numberingSystem(),
|
|
718
|
+
dateStyle: this.dateStyle(),
|
|
719
|
+
timeStyle: this.timeStyle(),
|
|
720
|
+
hourCycle: this.hourCycle(),
|
|
721
|
+
hour12: this.hour12(),
|
|
722
|
+
localeMatcher: this.localeMatcher(),
|
|
723
|
+
formatMatcher: this.formatMatcher(),
|
|
724
|
+
weekday: this.weekday(),
|
|
725
|
+
era: this.era(),
|
|
726
|
+
year: this.year(),
|
|
727
|
+
month: this.month(),
|
|
728
|
+
day: this.day(),
|
|
729
|
+
hour: this.hour(),
|
|
730
|
+
minute: this.minute(),
|
|
731
|
+
second: this.second(),
|
|
732
|
+
fractionalSecondDigits: this.fractionalSecondDigits(),
|
|
733
|
+
timeZoneName: this.timeZoneName()
|
|
734
|
+
};
|
|
735
|
+
return Object.fromEntries(Object.entries(given).filter(([, value]) => value !== undefined));
|
|
736
|
+
}, ...ngDevMode ? [{ debugName: "props" }] : []);
|
|
737
|
+
view = computed5(() => timeView(this.app, this.route?.().path ?? "/", this.props(), this.now()), ...ngDevMode ? [{ debugName: "view" }] : []);
|
|
738
|
+
interval = computed5(() => this.view().interval, ...ngDevMode ? [{ debugName: "interval" }] : []);
|
|
739
|
+
constructor() {
|
|
740
|
+
afterRenderEffect((onCleanup) => {
|
|
741
|
+
const interval = this.interval();
|
|
742
|
+
if (interval === undefined)
|
|
743
|
+
return;
|
|
744
|
+
onCleanup(watchTime(interval, (next) => this.now.set(next)));
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
static ɵfac = i04.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i04, type: Time, deps: [], target: i04.ɵɵFactoryTarget.Directive });
|
|
748
|
+
static ɵdir = i04.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.2", type: Time, isStandalone: true, selector: "time[hamurTime]", inputs: { datetime: { classPropertyName: "datetime", publicName: "hamurTime", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, timeZone: { classPropertyName: "timeZone", publicName: "timeZone", isSignal: true, isRequired: false, transformFunction: null }, relative: { classPropertyName: "relative", publicName: "relative", isSignal: true, isRequired: false, transformFunction: null }, relativeInterval: { classPropertyName: "relativeInterval", publicName: "relativeInterval", isSignal: true, isRequired: false, transformFunction: null }, calendar: { classPropertyName: "calendar", publicName: "calendar", isSignal: true, isRequired: false, transformFunction: null }, dayPeriod: { classPropertyName: "dayPeriod", publicName: "dayPeriod", isSignal: true, isRequired: false, transformFunction: null }, numberingSystem: { classPropertyName: "numberingSystem", publicName: "numberingSystem", isSignal: true, isRequired: false, transformFunction: null }, dateStyle: { classPropertyName: "dateStyle", publicName: "dateStyle", isSignal: true, isRequired: false, transformFunction: null }, timeStyle: { classPropertyName: "timeStyle", publicName: "timeStyle", isSignal: true, isRequired: false, transformFunction: null }, hourCycle: { classPropertyName: "hourCycle", publicName: "hourCycle", isSignal: true, isRequired: false, transformFunction: null }, hour12: { classPropertyName: "hour12", publicName: "hour12", isSignal: true, isRequired: false, transformFunction: null }, localeMatcher: { classPropertyName: "localeMatcher", publicName: "localeMatcher", isSignal: true, isRequired: false, transformFunction: null }, formatMatcher: { classPropertyName: "formatMatcher", publicName: "formatMatcher", isSignal: true, isRequired: false, transformFunction: null }, weekday: { classPropertyName: "weekday", publicName: "weekday", isSignal: true, isRequired: false, transformFunction: null }, era: { classPropertyName: "era", publicName: "era", isSignal: true, isRequired: false, transformFunction: null }, year: { classPropertyName: "year", publicName: "year", isSignal: true, isRequired: false, transformFunction: null }, month: { classPropertyName: "month", publicName: "month", isSignal: true, isRequired: false, transformFunction: null }, day: { classPropertyName: "day", publicName: "day", isSignal: true, isRequired: false, transformFunction: null }, hour: { classPropertyName: "hour", publicName: "hour", isSignal: true, isRequired: false, transformFunction: null }, minute: { classPropertyName: "minute", publicName: "minute", isSignal: true, isRequired: false, transformFunction: null }, second: { classPropertyName: "second", publicName: "second", isSignal: true, isRequired: false, transformFunction: null }, fractionalSecondDigits: { classPropertyName: "fractionalSecondDigits", publicName: "fractionalSecondDigits", isSignal: true, isRequired: false, transformFunction: null }, timeZoneName: { classPropertyName: "timeZoneName", publicName: "timeZoneName", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.datetime": "view().iso", "attr.data-locale": "view().locale", "attr.data-time-zone": "view().timeZone", textContent: "view().text" } }, ngImport: i04 });
|
|
749
|
+
}
|
|
750
|
+
i04.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i04, type: Time, decorators: [{
|
|
751
|
+
type: Directive2,
|
|
752
|
+
args: [{
|
|
753
|
+
selector: "time[hamurTime]",
|
|
754
|
+
host: {
|
|
755
|
+
"[attr.datetime]": "view().iso",
|
|
756
|
+
"[attr.data-locale]": "view().locale",
|
|
757
|
+
"[attr.data-time-zone]": "view().timeZone",
|
|
758
|
+
"[textContent]": "view().text"
|
|
759
|
+
}
|
|
760
|
+
}]
|
|
761
|
+
}], ctorParameters: () => [], propDecorators: { datetime: [{ type: i04.Input, args: [{ isSignal: true, alias: "hamurTime", required: true }] }], locale: [{ type: i04.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], timeZone: [{ type: i04.Input, args: [{ isSignal: true, alias: "timeZone", required: false }] }], relative: [{ type: i04.Input, args: [{ isSignal: true, alias: "relative", required: false }] }], relativeInterval: [{ type: i04.Input, args: [{ isSignal: true, alias: "relativeInterval", required: false }] }], calendar: [{ type: i04.Input, args: [{ isSignal: true, alias: "calendar", required: false }] }], dayPeriod: [{ type: i04.Input, args: [{ isSignal: true, alias: "dayPeriod", required: false }] }], numberingSystem: [{ type: i04.Input, args: [{ isSignal: true, alias: "numberingSystem", required: false }] }], dateStyle: [{ type: i04.Input, args: [{ isSignal: true, alias: "dateStyle", required: false }] }], timeStyle: [{ type: i04.Input, args: [{ isSignal: true, alias: "timeStyle", required: false }] }], hourCycle: [{ type: i04.Input, args: [{ isSignal: true, alias: "hourCycle", required: false }] }], hour12: [{ type: i04.Input, args: [{ isSignal: true, alias: "hour12", required: false }] }], localeMatcher: [{ type: i04.Input, args: [{ isSignal: true, alias: "localeMatcher", required: false }] }], formatMatcher: [{ type: i04.Input, args: [{ isSignal: true, alias: "formatMatcher", required: false }] }], weekday: [{ type: i04.Input, args: [{ isSignal: true, alias: "weekday", required: false }] }], era: [{ type: i04.Input, args: [{ isSignal: true, alias: "era", required: false }] }], year: [{ type: i04.Input, args: [{ isSignal: true, alias: "year", required: false }] }], month: [{ type: i04.Input, args: [{ isSignal: true, alias: "month", required: false }] }], day: [{ type: i04.Input, args: [{ isSignal: true, alias: "day", required: false }] }], hour: [{ type: i04.Input, args: [{ isSignal: true, alias: "hour", required: false }] }], minute: [{ type: i04.Input, args: [{ isSignal: true, alias: "minute", required: false }] }], second: [{ type: i04.Input, args: [{ isSignal: true, alias: "second", required: false }] }], fractionalSecondDigits: [{ type: i04.Input, args: [{ isSignal: true, alias: "fractionalSecondDigits", required: false }] }], timeZoneName: [{ type: i04.Input, args: [{ isSignal: true, alias: "timeZoneName", required: false }] }] } });
|
|
762
|
+
// packages/adapter-angular/src/indicators.ts
|
|
763
|
+
import { Component as Component3, DestroyRef as DestroyRef6, ElementRef as ElementRef2, HostAttributeToken as HostAttributeToken2, Injector, afterNextRender as afterNextRender3, afterRenderEffect as afterRenderEffect2, assertInInjectionContext as assertInInjectionContext6, computed as computed6, effect as effect4, inject as inject7, input as input5, runInInjectionContext, signal as signal5, untracked as untracked5, viewChild } from "@angular/core";
|
|
764
|
+
import { ANNOUNCER_ASSERTIVE_ID, ANNOUNCER_POLITE_ID, ROUTE_ANNOUNCER_ID, announcerActions, announcerRole, createAnnouncer, createLoadingIndicator, createRouteAnnouncer, hideAnnouncer, loadingIndicatorOptions, paintLoadingIndicator } from "hamur/adapter";
|
|
765
|
+
import * as i05 from "@angular/core";
|
|
766
|
+
function injectLoadingIndicator(options) {
|
|
767
|
+
assertInInjectionContext6(injectLoadingIndicator);
|
|
768
|
+
const store = createLoadingIndicator(required(HAMUR_APP, "injectLoadingIndicator"), options);
|
|
769
|
+
const navigation = required(HAMUR_NAVIGATION, "injectLoadingIndicator");
|
|
770
|
+
const state = signal5(store.get(), ...ngDevMode ? [{ debugName: "state" }] : []);
|
|
771
|
+
const injector = inject7(Injector);
|
|
772
|
+
const destroy = inject7(DestroyRef6);
|
|
773
|
+
afterNextRender3(() => {
|
|
774
|
+
state.set(store.get());
|
|
775
|
+
const stopState = store.subscribe(() => state.set(store.get()));
|
|
776
|
+
const listeners = new Set;
|
|
777
|
+
const watcher = effect4(() => {
|
|
778
|
+
navigation();
|
|
779
|
+
untracked5(() => {
|
|
780
|
+
for (const listener of [...listeners])
|
|
781
|
+
listener();
|
|
782
|
+
});
|
|
783
|
+
}, { ...ngDevMode ? { debugName: "watcher" } : {}, injector });
|
|
784
|
+
const stopFollow = store.follow({
|
|
785
|
+
get: () => untracked5(navigation),
|
|
786
|
+
subscribe(listener) {
|
|
787
|
+
listeners.add(listener);
|
|
788
|
+
return () => void listeners.delete(listener);
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
destroy.onDestroy(() => {
|
|
792
|
+
stopState();
|
|
793
|
+
stopFollow();
|
|
794
|
+
watcher.destroy();
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
return {
|
|
798
|
+
progress: computed6(() => state().progress),
|
|
799
|
+
isLoading: computed6(() => state().isLoading),
|
|
800
|
+
error: computed6(() => state().error),
|
|
801
|
+
start: store.start,
|
|
802
|
+
finish: store.finish,
|
|
803
|
+
set: store.set,
|
|
804
|
+
clear: store.clear
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
class LoadingIndicator {
|
|
809
|
+
color = input5(...ngDevMode ? [undefined, { debugName: "color" }] : []);
|
|
810
|
+
errorColor = input5(...ngDevMode ? [undefined, { debugName: "errorColor" }] : []);
|
|
811
|
+
height = input5(...ngDevMode ? [undefined, { debugName: "height" }] : []);
|
|
812
|
+
duration = input5(...ngDevMode ? [undefined, { debugName: "duration" }] : []);
|
|
813
|
+
throttle = input5(...ngDevMode ? [undefined, { debugName: "throttle" }] : []);
|
|
814
|
+
estimatedProgress = input5(...ngDevMode ? [undefined, { debugName: "estimatedProgress" }] : []);
|
|
815
|
+
injector = inject7(Injector);
|
|
816
|
+
element = inject7(ElementRef2).nativeElement;
|
|
817
|
+
ngOnInit() {
|
|
818
|
+
runInInjectionContext(this.injector, () => {
|
|
819
|
+
const { progress, isLoading, error } = injectLoadingIndicator(loadingIndicatorOptions({
|
|
820
|
+
duration: this.duration(),
|
|
821
|
+
throttle: this.throttle(),
|
|
822
|
+
estimatedProgress: this.estimatedProgress()
|
|
823
|
+
}));
|
|
824
|
+
afterRenderEffect2(() => paintLoadingIndicator(this.element, { progress: progress(), isLoading: isLoading(), error: error() }, { color: this.color(), errorColor: this.errorColor(), height: this.height() }));
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
static ɵfac = i05.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: LoadingIndicator, deps: [], target: i05.ɵɵFactoryTarget.Component });
|
|
828
|
+
static ɵcmp = i05.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: LoadingIndicator, isStandalone: true, selector: "hamur-loading-indicator", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, errorColor: { classPropertyName: "errorColor", publicName: "errorColor", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, duration: { classPropertyName: "duration", publicName: "duration", isSignal: true, isRequired: false, transformFunction: null }, throttle: { classPropertyName: "throttle", publicName: "throttle", isSignal: true, isRequired: false, transformFunction: null }, estimatedProgress: { classPropertyName: "estimatedProgress", publicName: "estimatedProgress", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "data-hamur-loading-indicator": "", "aria-hidden": "true" } }, ngImport: i05, template: "", isInline: true });
|
|
829
|
+
}
|
|
830
|
+
i05.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: LoadingIndicator, decorators: [{
|
|
831
|
+
type: Component3,
|
|
832
|
+
args: [{
|
|
833
|
+
selector: "hamur-loading-indicator",
|
|
834
|
+
template: "",
|
|
835
|
+
host: { "data-hamur-loading-indicator": "", "aria-hidden": "true" }
|
|
836
|
+
}]
|
|
837
|
+
}], propDecorators: { color: [{ type: i05.Input, args: [{ isSignal: true, alias: "color", required: false }] }], errorColor: [{ type: i05.Input, args: [{ isSignal: true, alias: "errorColor", required: false }] }], height: [{ type: i05.Input, args: [{ isSignal: true, alias: "height", required: false }] }], duration: [{ type: i05.Input, args: [{ isSignal: true, alias: "duration", required: false }] }], throttle: [{ type: i05.Input, args: [{ isSignal: true, alias: "throttle", required: false }] }], estimatedProgress: [{ type: i05.Input, args: [{ isSignal: true, alias: "estimatedProgress", required: false }] }] } });
|
|
838
|
+
function injectRouteAnnouncer() {
|
|
839
|
+
assertInInjectionContext6(injectRouteAnnouncer);
|
|
840
|
+
const store = createRouteAnnouncer(required(HAMUR_APP, "injectRouteAnnouncer"));
|
|
841
|
+
const state = signal5(store.get(), ...ngDevMode ? [{ debugName: "state" }] : []);
|
|
842
|
+
const destroy = inject7(DestroyRef6);
|
|
843
|
+
afterNextRender3(() => {
|
|
844
|
+
state.set(store.get());
|
|
845
|
+
destroy.onDestroy(store.subscribe(() => state.set(store.get())));
|
|
846
|
+
});
|
|
847
|
+
return {
|
|
848
|
+
message: computed6(() => state().message),
|
|
849
|
+
politeness: computed6(() => state().politeness),
|
|
850
|
+
set: store.set,
|
|
851
|
+
polite: store.polite,
|
|
852
|
+
assertive: store.assertive
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
class RouteAnnouncer {
|
|
857
|
+
politeness = input5(...ngDevMode ? [undefined, { debugName: "politeness" }] : []);
|
|
858
|
+
id = ROUTE_ANNOUNCER_ID;
|
|
859
|
+
store = createRouteAnnouncer(required(HAMUR_APP, "RouteAnnouncer"));
|
|
860
|
+
state = injectRouteAnnouncer();
|
|
861
|
+
element = inject7(ElementRef2).nativeElement;
|
|
862
|
+
styled = inject7(new HostAttributeToken2("class"), { optional: true }) !== null || inject7(new HostAttributeToken2("style"), { optional: true }) !== null;
|
|
863
|
+
key = {};
|
|
864
|
+
tick = signal5(0, ...ngDevMode ? [{ debugName: "tick" }] : []);
|
|
865
|
+
message = this.state.message;
|
|
866
|
+
live = computed6(() => this.politeness() ?? this.state.politeness(), ...ngDevMode ? [{ debugName: "live" }] : []);
|
|
867
|
+
role = computed6(() => announcerRole(this.live()), ...ngDevMode ? [{ debugName: "role" }] : []);
|
|
868
|
+
owner = computed6(() => {
|
|
869
|
+
this.tick();
|
|
870
|
+
return this.store.claim(this.key, () => this.tick.update((count) => count + 1));
|
|
871
|
+
}, ...ngDevMode ? [{ debugName: "owner" }] : []);
|
|
872
|
+
constructor() {
|
|
873
|
+
afterRenderEffect2((onCleanup) => {
|
|
874
|
+
if (!this.owner())
|
|
875
|
+
return;
|
|
876
|
+
onCleanup(this.store.mount());
|
|
877
|
+
if (!this.styled)
|
|
878
|
+
hideAnnouncer(this.element);
|
|
879
|
+
});
|
|
880
|
+
inject7(DestroyRef6).onDestroy(() => this.store.release(this.key));
|
|
881
|
+
}
|
|
882
|
+
static ɵfac = i05.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: RouteAnnouncer, deps: [], target: i05.ɵɵFactoryTarget.Component });
|
|
883
|
+
static ɵcmp = i05.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: RouteAnnouncer, isStandalone: true, selector: "hamur-route-announcer", inputs: { politeness: { classPropertyName: "politeness", publicName: "politeness", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-atomic": "true" }, properties: { "attr.id": "owner() ? id : null", "attr.aria-live": "owner() ? live() : 'off'", "attr.role": "owner() ? role() : null", textContent: "owner() ? message() : ''" } }, ngImport: i05, template: "", isInline: true });
|
|
884
|
+
}
|
|
885
|
+
i05.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: RouteAnnouncer, decorators: [{
|
|
886
|
+
type: Component3,
|
|
887
|
+
args: [{
|
|
888
|
+
selector: "hamur-route-announcer",
|
|
889
|
+
template: "",
|
|
890
|
+
host: {
|
|
891
|
+
"[attr.id]": "owner() ? id : null",
|
|
892
|
+
"[attr.aria-live]": "owner() ? live() : 'off'",
|
|
893
|
+
"aria-atomic": "true",
|
|
894
|
+
"[attr.role]": "owner() ? role() : null",
|
|
895
|
+
"[textContent]": "owner() ? message() : ''"
|
|
896
|
+
}
|
|
897
|
+
}]
|
|
898
|
+
}], ctorParameters: () => [], propDecorators: { politeness: [{ type: i05.Input, args: [{ isSignal: true, alias: "politeness", required: false }] }] } });
|
|
899
|
+
function injectAnnouncer({ politeness = "polite" } = {}) {
|
|
900
|
+
assertInInjectionContext6(injectAnnouncer);
|
|
901
|
+
const store = createAnnouncer(required(HAMUR_APP, "injectAnnouncer"));
|
|
902
|
+
const state = signal5(store.get(), ...ngDevMode ? [{ debugName: "state" }] : []);
|
|
903
|
+
const destroy = inject7(DestroyRef6);
|
|
904
|
+
afterNextRender3(() => {
|
|
905
|
+
state.set(store.get());
|
|
906
|
+
destroy.onDestroy(store.subscribe(() => state.set(store.get())));
|
|
907
|
+
});
|
|
908
|
+
return {
|
|
909
|
+
message: computed6(() => state().message),
|
|
910
|
+
politeness: computed6(() => state().politeness),
|
|
911
|
+
...announcerActions(store, politeness)
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
class Announcer {
|
|
916
|
+
politeId = ANNOUNCER_POLITE_ID;
|
|
917
|
+
assertiveId = ANNOUNCER_ASSERTIVE_ID;
|
|
918
|
+
store = createAnnouncer(required(HAMUR_APP, "Announcer"));
|
|
919
|
+
state = signal5(this.store.get(), ...ngDevMode ? [{ debugName: "state" }] : []);
|
|
920
|
+
regions = computed6(() => this.state().regions, ...ngDevMode ? [{ debugName: "regions" }] : []);
|
|
921
|
+
polite = viewChild.required("polite", ...ngDevMode ? [{ debugName: "polite" }] : []);
|
|
922
|
+
assertive = viewChild.required("assertive", ...ngDevMode ? [{ debugName: "assertive" }] : []);
|
|
923
|
+
constructor() {
|
|
924
|
+
const destroy = inject7(DestroyRef6);
|
|
925
|
+
afterNextRender3(() => {
|
|
926
|
+
this.state.set(this.store.get());
|
|
927
|
+
hideAnnouncer(this.polite().nativeElement);
|
|
928
|
+
hideAnnouncer(this.assertive().nativeElement);
|
|
929
|
+
const stop = this.store.subscribe(() => this.state.set(this.store.get()));
|
|
930
|
+
const unmount = this.store.mount();
|
|
931
|
+
destroy.onDestroy(() => {
|
|
932
|
+
stop();
|
|
933
|
+
unmount();
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
static ɵfac = i05.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: Announcer, deps: [], target: i05.ɵɵFactoryTarget.Component });
|
|
938
|
+
static ɵcmp = i05.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.3.2", type: Announcer, isStandalone: true, selector: "hamur-announcer", viewQueries: [{ propertyName: "polite", first: true, predicate: ["polite"], descendants: true, isSignal: true }, { propertyName: "assertive", first: true, predicate: ["assertive"], descendants: true, isSignal: true }], ngImport: i05, template: `<div #polite [attr.id]="politeId" aria-live="polite" aria-atomic="true" role="status">{{ regions().polite }}</div
|
|
939
|
+
><div #assertive [attr.id]="assertiveId" aria-live="assertive" aria-atomic="true" role="alert">{{
|
|
940
|
+
regions().assertive
|
|
941
|
+
}}</div>`, isInline: true });
|
|
942
|
+
}
|
|
943
|
+
i05.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i05, type: Announcer, decorators: [{
|
|
944
|
+
type: Component3,
|
|
945
|
+
args: [{
|
|
946
|
+
selector: "hamur-announcer",
|
|
947
|
+
template: `<div #polite [attr.id]="politeId" aria-live="polite" aria-atomic="true" role="status">{{ regions().polite }}</div
|
|
948
|
+
><div #assertive [attr.id]="assertiveId" aria-live="assertive" aria-atomic="true" role="alert">{{
|
|
949
|
+
regions().assertive
|
|
950
|
+
}}</div>`
|
|
951
|
+
}]
|
|
952
|
+
}], ctorParameters: () => [], propDecorators: { polite: [{ type: i05.ViewChild, args: ["polite", { isSignal: true }] }], assertive: [{ type: i05.ViewChild, args: ["assertive", { isSignal: true }] }] } });
|
|
953
|
+
// packages/adapter-angular/src/markdown.ts
|
|
954
|
+
import { ApplicationRef, Component as Component4, ElementRef as ElementRef3, EnvironmentInjector, Injector as Injector2, Renderer2, createComponent, effect as effect5, inject as inject8, input as input6, reflectComponentType, untracked as untracked6 } from "@angular/core";
|
|
955
|
+
import { linkAttributes as linkAttributes2, linkDefaultsOf as linkDefaultsOf2, linkPrefetchProps as linkPrefetchProps2, markdownLink, markdownProse, markdownView } from "hamur/adapter";
|
|
956
|
+
import * as i06 from "@angular/core";
|
|
957
|
+
var camelize = (name) => name.replace(/-(\w)/g, (_, char) => char.toUpperCase());
|
|
958
|
+
var SLOT = /^\[(?:slot=)?["']?([\w-]+)["']?\]$|^([\w-]+)$/;
|
|
959
|
+
|
|
960
|
+
class MarkdownRenderer {
|
|
961
|
+
value = input6.required(...ngDevMode ? [{ debugName: "value" }] : []);
|
|
962
|
+
components = input6(...ngDevMode ? [undefined, { debugName: "components" }] : []);
|
|
963
|
+
raw = input6(...ngDevMode ? [undefined, { debugName: "raw" }] : []);
|
|
964
|
+
host = inject8(ElementRef3).nativeElement;
|
|
965
|
+
renderer = inject8(Renderer2);
|
|
966
|
+
app = inject8(HAMUR_APP);
|
|
967
|
+
resolve = inject8(HAMUR_HREF, { optional: true }) ?? detachedHref;
|
|
968
|
+
injector = inject8(Injector2);
|
|
969
|
+
environment = inject8(EnvironmentInjector);
|
|
970
|
+
appRef = inject8(ApplicationRef);
|
|
971
|
+
constructor() {
|
|
972
|
+
effect5((onCleanup) => {
|
|
973
|
+
const raw = this.raw();
|
|
974
|
+
const prose = markdownProse(this.value(), this.components() ?? {});
|
|
975
|
+
const views = markdownView(prose.value, { html: raw !== undefined, components: prose.components });
|
|
976
|
+
const refs = [];
|
|
977
|
+
untracked6(() => {
|
|
978
|
+
for (const view of views)
|
|
979
|
+
this.append(this.host, view, raw, prose.components, refs);
|
|
980
|
+
});
|
|
981
|
+
onCleanup(() => {
|
|
982
|
+
for (const ref of refs)
|
|
983
|
+
ref.destroy();
|
|
984
|
+
while (this.host.firstChild)
|
|
985
|
+
this.renderer.removeChild(this.host, this.host.firstChild);
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
append(parent, view, raw, components, refs) {
|
|
990
|
+
const renderer = this.renderer;
|
|
991
|
+
if (typeof view === "string")
|
|
992
|
+
return renderer.appendChild(parent, renderer.createText(view));
|
|
993
|
+
if ("html" in view) {
|
|
994
|
+
const element = renderer.createElement("hamur-html");
|
|
995
|
+
renderer.setStyle(element, "display", "contents");
|
|
996
|
+
renderer.setProperty(element, "innerHTML", raw(view.html));
|
|
997
|
+
return renderer.appendChild(parent, element);
|
|
998
|
+
}
|
|
999
|
+
if ("component" in view)
|
|
1000
|
+
return this.appendComponent(parent, view, raw, components, refs);
|
|
1001
|
+
const link = markdownLink(view);
|
|
1002
|
+
const element = renderer.createElement(view.tag);
|
|
1003
|
+
if (link) {
|
|
1004
|
+
const defaults = linkDefaultsOf2(this.app);
|
|
1005
|
+
const attributes = linkAttributes2({
|
|
1006
|
+
href: this.resolve(link.to),
|
|
1007
|
+
external: false,
|
|
1008
|
+
...linkPrefetchProps2({}, defaults),
|
|
1009
|
+
replace: false,
|
|
1010
|
+
pendingClass: defaults.pendingClass,
|
|
1011
|
+
trim: false,
|
|
1012
|
+
prefetchedClass: defaults.prefetchedClass,
|
|
1013
|
+
prefetchDelay: defaults.prefetchDelay,
|
|
1014
|
+
externalRelAttribute: defaults.externalRelAttribute
|
|
1015
|
+
});
|
|
1016
|
+
for (const [name, value] of Object.entries({ ...link.attrs, ...attributes }))
|
|
1017
|
+
renderer.setAttribute(element, name, value === true ? "" : value);
|
|
1018
|
+
} else
|
|
1019
|
+
for (const [name, value] of Object.entries(view.attrs))
|
|
1020
|
+
renderer.setAttribute(element, name, value === true ? "" : value);
|
|
1021
|
+
for (const child of view.children)
|
|
1022
|
+
this.append(element, child, raw, components, refs);
|
|
1023
|
+
renderer.appendChild(parent, element);
|
|
1024
|
+
}
|
|
1025
|
+
appendComponent(parent, view, raw, components, refs) {
|
|
1026
|
+
const renderer = this.renderer;
|
|
1027
|
+
const component = Object.hasOwn(components, view.component) ? components[view.component] : undefined;
|
|
1028
|
+
const nodes = (views) => {
|
|
1029
|
+
const holder = renderer.createElement("div");
|
|
1030
|
+
for (const child of views)
|
|
1031
|
+
this.append(holder, child, raw, components, refs);
|
|
1032
|
+
return Array.from(holder.childNodes);
|
|
1033
|
+
};
|
|
1034
|
+
if (!component) {
|
|
1035
|
+
if (!view.attrs) {
|
|
1036
|
+
for (const child of view.children)
|
|
1037
|
+
this.append(parent, child, raw, components, refs);
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
const element = renderer.createElement(view.component);
|
|
1041
|
+
for (const [name, value] of Object.entries(view.attrs))
|
|
1042
|
+
renderer.setAttribute(element, name, value === true ? "" : value);
|
|
1043
|
+
for (const child of view.children)
|
|
1044
|
+
this.append(element, child, raw, components, refs);
|
|
1045
|
+
return renderer.appendChild(parent, element);
|
|
1046
|
+
}
|
|
1047
|
+
const mirror = reflectComponentType(component);
|
|
1048
|
+
const declared = new Set(mirror?.inputs.map((input) => input.templateName));
|
|
1049
|
+
const entries = Object.entries(view.props);
|
|
1050
|
+
const [element] = markdownView([
|
|
1051
|
+
"span",
|
|
1052
|
+
Object.fromEntries(entries.filter(([name]) => !declared.has(camelize(name))))
|
|
1053
|
+
]);
|
|
1054
|
+
const slots = new Map;
|
|
1055
|
+
for (const [name, views] of Object.entries(view.slots))
|
|
1056
|
+
slots.set(name, nodes(views));
|
|
1057
|
+
const content = nodes(view.children);
|
|
1058
|
+
const ref = createComponent(component, {
|
|
1059
|
+
environmentInjector: this.environment,
|
|
1060
|
+
elementInjector: this.injector,
|
|
1061
|
+
projectableNodes: (mirror?.ngContentSelectors ?? []).map((selector) => {
|
|
1062
|
+
const named = SLOT.exec(selector);
|
|
1063
|
+
const name = named?.[1] ?? named?.[2];
|
|
1064
|
+
return selector === "*" ? content : name !== undefined ? slots.get(name) ?? [] : [];
|
|
1065
|
+
})
|
|
1066
|
+
});
|
|
1067
|
+
for (const [name, value] of entries)
|
|
1068
|
+
if (declared.has(camelize(name)))
|
|
1069
|
+
ref.setInput(camelize(name), value);
|
|
1070
|
+
const host = ref.location.nativeElement;
|
|
1071
|
+
for (const [name, value] of Object.entries(element?.attrs ?? {}))
|
|
1072
|
+
renderer.setAttribute(host, name, value === true ? "" : value);
|
|
1073
|
+
this.appRef.attachView(ref.hostView);
|
|
1074
|
+
refs.push(ref);
|
|
1075
|
+
renderer.appendChild(parent, host);
|
|
1076
|
+
}
|
|
1077
|
+
static ɵfac = i06.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i06, type: MarkdownRenderer, deps: [], target: i06.ɵɵFactoryTarget.Component });
|
|
1078
|
+
static ɵcmp = i06.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: MarkdownRenderer, isStandalone: true, selector: "hamur-markdown", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, components: { classPropertyName: "components", publicName: "components", isSignal: true, isRequired: false, transformFunction: null }, raw: { classPropertyName: "raw", publicName: "raw", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { ngSkipHydration: "true" } }, ngImport: i06, template: "", isInline: true });
|
|
1079
|
+
}
|
|
1080
|
+
i06.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i06, type: MarkdownRenderer, decorators: [{
|
|
1081
|
+
type: Component4,
|
|
1082
|
+
args: [{ selector: "hamur-markdown", template: "", host: { ngSkipHydration: "true" } }]
|
|
1083
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i06.Input, args: [{ isSignal: true, alias: "value", required: true }] }], components: [{ type: i06.Input, args: [{ isSignal: true, alias: "components", required: false }] }], raw: [{ type: i06.Input, args: [{ isSignal: true, alias: "raw", required: false }] }] } });
|
|
1084
|
+
// packages/adapter-angular/src/island.ts
|
|
1085
|
+
import { ApplicationRef as ApplicationRef2, Component as Component5, DestroyRef as DestroyRef7, ElementRef as ElementRef4, InjectionToken as InjectionToken2, Injector as Injector3, PendingTasks as PendingTasks2, Renderer2 as Renderer22, booleanAttribute as booleanAttribute4, inject as inject9, input as input7 } from "@angular/core";
|
|
1086
|
+
import { ISLAND_ELEMENT, renderIsland } from "hamur/adapter";
|
|
1087
|
+
import * as i07 from "@angular/core";
|
|
1088
|
+
|
|
1089
|
+
class HostWriter {
|
|
1090
|
+
host = inject9(ElementRef4).nativeElement;
|
|
1091
|
+
renderer = inject9(Renderer22);
|
|
1092
|
+
appRef = inject9(ApplicationRef2);
|
|
1093
|
+
injector = inject9(Injector3);
|
|
1094
|
+
destroyRef = inject9(DestroyRef7);
|
|
1095
|
+
append(template, into = this.host) {
|
|
1096
|
+
const view = template.createEmbeddedView({}, this.injector);
|
|
1097
|
+
this.appRef.attachView(view);
|
|
1098
|
+
for (const node of view.rootNodes)
|
|
1099
|
+
this.renderer.appendChild(into, node);
|
|
1100
|
+
this.destroyRef.onDestroy(() => view.destroy());
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
var HAMUR_ISLAND_ELEMENT = new InjectionToken2("hamur island element", {
|
|
1104
|
+
providedIn: "root",
|
|
1105
|
+
factory: () => ISLAND_ELEMENT
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
class Island extends HostWriter {
|
|
1109
|
+
component = input7.required(...ngDevMode ? [{ debugName: "component" }] : []);
|
|
1110
|
+
props = input7(...ngDevMode ? [undefined, { debugName: "props" }] : []);
|
|
1111
|
+
on = input7(...ngDevMode ? [undefined, { debugName: "on" }] : []);
|
|
1112
|
+
fallback = input7(...ngDevMode ? [undefined, { debugName: "fallback" }] : []);
|
|
1113
|
+
persist = input7(...ngDevMode ? [undefined, { debugName: "persist" }] : []);
|
|
1114
|
+
persistProps = input7(false, { ...ngDevMode ? { debugName: "persistProps" } : {}, transform: booleanAttribute4 });
|
|
1115
|
+
app = inject9(HAMUR_APP, { optional: true });
|
|
1116
|
+
id = injectId2();
|
|
1117
|
+
tasks = inject9(PendingTasks2);
|
|
1118
|
+
fail = inject9(HAMUR_FAIL, { optional: true });
|
|
1119
|
+
server = onServer();
|
|
1120
|
+
element = inject9(HAMUR_ISLAND_ELEMENT);
|
|
1121
|
+
constructor() {
|
|
1122
|
+
super();
|
|
1123
|
+
if (!this.app)
|
|
1124
|
+
throw new Error("Island must be rendered inside a Hamur app");
|
|
1125
|
+
}
|
|
1126
|
+
ngOnInit() {
|
|
1127
|
+
if (!this.server)
|
|
1128
|
+
return;
|
|
1129
|
+
const island = renderIsland(this.app, this.id, this.component(), this.props() ?? {}, this.on(), undefined, {
|
|
1130
|
+
persist: this.persist(),
|
|
1131
|
+
persistProps: this.persistProps()
|
|
1132
|
+
});
|
|
1133
|
+
const element = this.host.localName === this.element ? this.host : this.renderer.createElement(this.element);
|
|
1134
|
+
if (element !== this.host)
|
|
1135
|
+
this.renderer.appendChild(this.host, element);
|
|
1136
|
+
for (const [name, value] of Object.entries(island.attributes))
|
|
1137
|
+
this.renderer.setAttribute(element, name, value);
|
|
1138
|
+
if (!island.html) {
|
|
1139
|
+
const fallback = this.fallback();
|
|
1140
|
+
if (fallback)
|
|
1141
|
+
this.append(fallback, element);
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
const done = this.tasks.add();
|
|
1145
|
+
island.html.then((html) => this.renderer.setProperty(element, "innerHTML", html)).catch((error) => this.fail?.(error)).finally(done);
|
|
1146
|
+
}
|
|
1147
|
+
static ɵfac = i07.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i07, type: Island, deps: [], target: i07.ɵɵFactoryTarget.Component });
|
|
1148
|
+
static ɵcmp = i07.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: Island, isStandalone: true, selector: "hamur-island", inputs: { component: { classPropertyName: "component", publicName: "component", isSignal: true, isRequired: true, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, on: { classPropertyName: "on", publicName: "on", isSignal: true, isRequired: false, transformFunction: null }, fallback: { classPropertyName: "fallback", publicName: "fallback", isSignal: true, isRequired: false, transformFunction: null }, persist: { classPropertyName: "persist", publicName: "persist", isSignal: true, isRequired: false, transformFunction: null }, persistProps: { classPropertyName: "persistProps", publicName: "persistProps", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i07, template: "", isInline: true });
|
|
1149
|
+
}
|
|
1150
|
+
i07.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i07, type: Island, decorators: [{
|
|
1151
|
+
type: Component5,
|
|
1152
|
+
args: [{ selector: "hamur-island", template: "" }]
|
|
1153
|
+
}], ctorParameters: () => [], propDecorators: { component: [{ type: i07.Input, args: [{ isSignal: true, alias: "component", required: true }] }], props: [{ type: i07.Input, args: [{ isSignal: true, alias: "props", required: false }] }], on: [{ type: i07.Input, args: [{ isSignal: true, alias: "on", required: false }] }], fallback: [{ type: i07.Input, args: [{ isSignal: true, alias: "fallback", required: false }] }], persist: [{ type: i07.Input, args: [{ isSignal: true, alias: "persist", required: false }] }], persistProps: [{ type: i07.Input, args: [{ isSignal: true, alias: "persistProps", required: false }] }] } });
|
|
1154
|
+
// packages/adapter-angular/src/server-island.ts
|
|
1155
|
+
import { Component as Component6, PendingTasks as PendingTasks3, effect as effect6, inject as inject10, input as input8 } from "@angular/core";
|
|
1156
|
+
import { renderServerIsland, serverIslandProps } from "hamur/adapter";
|
|
1157
|
+
import * as i08 from "@angular/core";
|
|
1158
|
+
|
|
1159
|
+
class ServerIsland extends HostWriter {
|
|
1160
|
+
name = input8.required(...ngDevMode ? [{ debugName: "name" }] : []);
|
|
1161
|
+
props = input8(...ngDevMode ? [undefined, { debugName: "props" }] : []);
|
|
1162
|
+
fallback = input8(...ngDevMode ? [undefined, { debugName: "fallback" }] : []);
|
|
1163
|
+
app = inject10(HAMUR_APP, { optional: true });
|
|
1164
|
+
id = injectId2();
|
|
1165
|
+
tasks = inject10(PendingTasks3);
|
|
1166
|
+
fail = inject10(HAMUR_FAIL, { optional: true });
|
|
1167
|
+
server = onServer();
|
|
1168
|
+
kept;
|
|
1169
|
+
constructor() {
|
|
1170
|
+
super();
|
|
1171
|
+
if (!this.app)
|
|
1172
|
+
throw new Error("ServerIsland must be rendered inside a Hamur app");
|
|
1173
|
+
this.kept = !this.server && this.app.asyncData.hydrating;
|
|
1174
|
+
if (this.server || this.kept)
|
|
1175
|
+
return;
|
|
1176
|
+
effect6(() => {
|
|
1177
|
+
const name = this.name();
|
|
1178
|
+
const props = this.props();
|
|
1179
|
+
this.renderer.setAttribute(this.host, "name", name);
|
|
1180
|
+
if (props && Object.keys(props).length)
|
|
1181
|
+
this.renderer.setAttribute(this.host, "props", serverIslandProps(name, props));
|
|
1182
|
+
else
|
|
1183
|
+
this.renderer.removeAttribute(this.host, "props");
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
ngOnInit() {
|
|
1187
|
+
if (this.kept)
|
|
1188
|
+
return;
|
|
1189
|
+
const fallback = this.fallback();
|
|
1190
|
+
if (fallback)
|
|
1191
|
+
this.append(fallback);
|
|
1192
|
+
if (!this.server)
|
|
1193
|
+
return;
|
|
1194
|
+
const { attributes } = renderServerIsland(this.app, this.id, this.name(), this.props());
|
|
1195
|
+
const done = this.tasks.add();
|
|
1196
|
+
attributes.then((written) => {
|
|
1197
|
+
for (const [name, value] of Object.entries(written))
|
|
1198
|
+
this.renderer.setAttribute(this.host, name, value);
|
|
1199
|
+
}).catch((error) => this.fail?.(error)).finally(done);
|
|
1200
|
+
}
|
|
1201
|
+
static ɵfac = i08.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i08, type: ServerIsland, deps: [], target: i08.ɵɵFactoryTarget.Component });
|
|
1202
|
+
static ɵcmp = i08.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.3.2", type: ServerIsland, isStandalone: true, selector: "hamur-server-island", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, fallback: { classPropertyName: "fallback", publicName: "fallback", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i08, template: "", isInline: true });
|
|
1203
|
+
}
|
|
1204
|
+
i08.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i08, type: ServerIsland, decorators: [{
|
|
1205
|
+
type: Component6,
|
|
1206
|
+
args: [{ selector: "hamur-server-island", template: "" }]
|
|
1207
|
+
}], ctorParameters: () => [], propDecorators: { name: [{ type: i08.Input, args: [{ isSignal: true, alias: "name", required: true }] }], props: [{ type: i08.Input, args: [{ isSignal: true, alias: "props", required: false }] }], fallback: [{ type: i08.Input, args: [{ isSignal: true, alias: "fallback", required: false }] }] } });
|
|
1208
|
+
// packages/adapter-angular/src/form.ts
|
|
1209
|
+
import { DestroyRef as DestroyRef8, Directive as Directive3, ElementRef as ElementRef5, InjectionToken as InjectionToken3, assertInInjectionContext as assertInInjectionContext7, booleanAttribute as booleanAttribute5, computed as computed7, effect as effect7, inject as inject11, input as input9, signal as signal6, untracked as untracked7 } from "@angular/core";
|
|
1210
|
+
import { IDLE_FORM_STATUS, assertFormMethod, createActionRunner, createFormStatus, functionFormAction, linkActionRunner, optimisticSource, restoredResult, runFunctionForm } from "hamur/adapter";
|
|
1211
|
+
import { createForm, enhance } from "hamur/app";
|
|
1212
|
+
import * as i09 from "@angular/core";
|
|
1213
|
+
var FORM_STATUS = new InjectionToken3("hamur form status");
|
|
1214
|
+
var handlerStateOf = (payload) => payload?.()?.handlerState;
|
|
1215
|
+
|
|
1216
|
+
class Form {
|
|
1217
|
+
action = input9(undefined, {
|
|
1218
|
+
...ngDevMode ? { debugName: "action" } : {},
|
|
1219
|
+
alias: "hamurForm",
|
|
1220
|
+
transform: (value) => value === "" ? undefined : value
|
|
1221
|
+
});
|
|
1222
|
+
method = input9(...ngDevMode ? [undefined, { debugName: "method" }] : []);
|
|
1223
|
+
encType = input9(...ngDevMode ? [undefined, { debugName: "encType" }] : []);
|
|
1224
|
+
replace = input9(false, { ...ngDevMode ? { debugName: "replace" } : {}, transform: booleanAttribute5 });
|
|
1225
|
+
reset = input9(false, { ...ngDevMode ? { debugName: "reset" } : {}, transform: booleanAttribute5 });
|
|
1226
|
+
reloadDocument = input9(false, { ...ngDevMode ? { debugName: "reloadDocument" } : {}, transform: booleanAttribute5 });
|
|
1227
|
+
refresh = input9(undefined, { ...ngDevMode ? { debugName: "refresh" } : {}, transform: (value) => value === undefined ? undefined : booleanAttribute5(value) });
|
|
1228
|
+
restore = input9(true, { ...ngDevMode ? { debugName: "restore" } : {}, transform: booleanAttribute5 });
|
|
1229
|
+
instance = input9(...ngDevMode ? [undefined, { debugName: "instance" }] : []);
|
|
1230
|
+
app = inject11(HAMUR_APP, { optional: true });
|
|
1231
|
+
route = inject11(HAMUR_ROUTE, { optional: true });
|
|
1232
|
+
router = inject11(HAMUR_ROUTER, { optional: true });
|
|
1233
|
+
resolve = inject11(HAMUR_HREF, { optional: true }) ?? detachedHref;
|
|
1234
|
+
status = inject11(FORM_STATUS);
|
|
1235
|
+
element = inject11(ElementRef5).nativeElement;
|
|
1236
|
+
methodAttribute = computed7(() => typeof this.action() === "function" ? "post" : "get", ...ngDevMode ? [{ debugName: "methodAttribute" }] : []);
|
|
1237
|
+
target = computed7(() => {
|
|
1238
|
+
const action = this.action();
|
|
1239
|
+
assertFormMethod(action, this.method());
|
|
1240
|
+
const page = this.route ? this.route().fullPath.replace(/#.*$/, "") : undefined;
|
|
1241
|
+
if (typeof action === "function")
|
|
1242
|
+
return functionFormAction(action, this.resolve(page ?? "/"), this.instance());
|
|
1243
|
+
return action !== undefined ? this.resolve(action) : page !== undefined ? this.resolve(page) : undefined;
|
|
1244
|
+
}, ...ngDevMode ? [{ debugName: "target" }] : []);
|
|
1245
|
+
posts = computed7(() => typeof this.action() === "function", ...ngDevMode ? [{ debugName: "posts" }] : []);
|
|
1246
|
+
constructor() {
|
|
1247
|
+
const browser = !onServer();
|
|
1248
|
+
effect7((onCleanup) => {
|
|
1249
|
+
if (!browser)
|
|
1250
|
+
return;
|
|
1251
|
+
const posts = this.posts();
|
|
1252
|
+
onCleanup(untracked7(() => enhance(this.element, this.enhanceOptions(posts))));
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
enhanceOptions(posts) {
|
|
1256
|
+
const { status } = this;
|
|
1257
|
+
return {
|
|
1258
|
+
onSubmit: (args) => status.submitted(args.formData),
|
|
1259
|
+
...posts && this.app ? { call: (input, formData) => this.post(input, formData) } : {}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
post(input, formData) {
|
|
1263
|
+
const action = this.action();
|
|
1264
|
+
const { app, router, status } = this;
|
|
1265
|
+
if (typeof action !== "function" || !app)
|
|
1266
|
+
return Promise.resolve(false);
|
|
1267
|
+
return runFunctionForm(app, action, input, formData, () => router?.refresh() ?? Promise.resolve(), status, {
|
|
1268
|
+
refresh: this.refresh(),
|
|
1269
|
+
instance: this.instance()
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
flag(value) {
|
|
1273
|
+
return value ? "" : null;
|
|
1274
|
+
}
|
|
1275
|
+
static ɵfac = i09.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i09, type: Form, deps: [], target: i09.ɵɵFactoryTarget.Directive });
|
|
1276
|
+
static ɵdir = i09.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.2", type: Form, isStandalone: true, selector: "form[hamurForm]", inputs: { action: { classPropertyName: "action", publicName: "hamurForm", isSignal: true, isRequired: false, transformFunction: null }, method: { classPropertyName: "method", publicName: "method", isSignal: true, isRequired: false, transformFunction: null }, encType: { classPropertyName: "encType", publicName: "encType", isSignal: true, isRequired: false, transformFunction: null }, replace: { classPropertyName: "replace", publicName: "replace", isSignal: true, isRequired: false, transformFunction: null }, reset: { classPropertyName: "reset", publicName: "reset", isSignal: true, isRequired: false, transformFunction: null }, reloadDocument: { classPropertyName: "reloadDocument", publicName: "reloadDocument", isSignal: true, isRequired: false, transformFunction: null }, refresh: { classPropertyName: "refresh", publicName: "refresh", isSignal: true, isRequired: false, transformFunction: null }, restore: { classPropertyName: "restore", publicName: "restore", isSignal: true, isRequired: false, transformFunction: null }, instance: { classPropertyName: "instance", publicName: "instance", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "data-hamur-form": "" }, properties: { "attr.method": "methodAttribute()", "attr.action": "target()", "attr.enctype": "encType()", "attr.data-hamur-replace": "flag(replace())", "attr.data-hamur-reset": "flag(reset())", "attr.data-hamur-reload": "flag(reloadDocument())", "attr.data-hamur-refresh": "refresh() === false ? 'false' : null", "attr.data-hamur-restore": "restore() ? null : 'false'" } }, providers: [{ provide: FORM_STATUS, useFactory: createFormStatus }], ngImport: i09 });
|
|
1277
|
+
}
|
|
1278
|
+
i09.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i09, type: Form, decorators: [{
|
|
1279
|
+
type: Directive3,
|
|
1280
|
+
args: [{
|
|
1281
|
+
selector: "form[hamurForm]",
|
|
1282
|
+
providers: [{ provide: FORM_STATUS, useFactory: createFormStatus }],
|
|
1283
|
+
host: {
|
|
1284
|
+
"data-hamur-form": "",
|
|
1285
|
+
"[attr.method]": "methodAttribute()",
|
|
1286
|
+
"[attr.action]": "target()",
|
|
1287
|
+
"[attr.enctype]": "encType()",
|
|
1288
|
+
"[attr.data-hamur-replace]": "flag(replace())",
|
|
1289
|
+
"[attr.data-hamur-reset]": "flag(reset())",
|
|
1290
|
+
"[attr.data-hamur-reload]": "flag(reloadDocument())",
|
|
1291
|
+
"[attr.data-hamur-refresh]": "refresh() === false ? 'false' : null",
|
|
1292
|
+
"[attr.data-hamur-restore]": "restore() ? null : 'false'"
|
|
1293
|
+
}
|
|
1294
|
+
}]
|
|
1295
|
+
}], ctorParameters: () => [], propDecorators: { action: [{ type: i09.Input, args: [{ isSignal: true, alias: "hamurForm", required: false }] }], method: [{ type: i09.Input, args: [{ isSignal: true, alias: "method", required: false }] }], encType: [{ type: i09.Input, args: [{ isSignal: true, alias: "encType", required: false }] }], replace: [{ type: i09.Input, args: [{ isSignal: true, alias: "replace", required: false }] }], reset: [{ type: i09.Input, args: [{ isSignal: true, alias: "reset", required: false }] }], reloadDocument: [{ type: i09.Input, args: [{ isSignal: true, alias: "reloadDocument", required: false }] }], refresh: [{ type: i09.Input, args: [{ isSignal: true, alias: "refresh", required: false }] }], restore: [{ type: i09.Input, args: [{ isSignal: true, alias: "restore", required: false }] }], instance: [{ type: i09.Input, args: [{ isSignal: true, alias: "instance", required: false }] }] } });
|
|
1296
|
+
function injectFormStatus() {
|
|
1297
|
+
assertInInjectionContext7(injectFormStatus);
|
|
1298
|
+
const store = inject11(FORM_STATUS, { optional: true });
|
|
1299
|
+
if (!store)
|
|
1300
|
+
return signal6(IDLE_FORM_STATUS).asReadonly();
|
|
1301
|
+
const status = signal6(store.get(), ...ngDevMode ? [{ debugName: "status" }] : []);
|
|
1302
|
+
inject11(DestroyRef8).onDestroy(store.subscribe(() => status.set(store.get())));
|
|
1303
|
+
return status.asReadonly();
|
|
1304
|
+
}
|
|
1305
|
+
function injectForm(fn) {
|
|
1306
|
+
assertInInjectionContext7(injectForm);
|
|
1307
|
+
const payload = inject11(HAMUR_PAYLOAD, { optional: true });
|
|
1308
|
+
const version = signal6(0, ...ngDevMode ? [{ debugName: "version" }] : []);
|
|
1309
|
+
const form = createForm(fn, {
|
|
1310
|
+
app: inject11(HAMUR_APP, { optional: true }),
|
|
1311
|
+
submitted: () => ({ handlerState: handlerStateOf(payload) }),
|
|
1312
|
+
track: () => void version()
|
|
1313
|
+
});
|
|
1314
|
+
inject11(DestroyRef8).onDestroy(form.subscribe(() => version.set(form.version())));
|
|
1315
|
+
const signals = (instance) => ({
|
|
1316
|
+
fields: instance.fields,
|
|
1317
|
+
pending: computed7(() => instance.pending),
|
|
1318
|
+
result: computed7(() => instance.result)
|
|
1319
|
+
});
|
|
1320
|
+
const instances = new Map;
|
|
1321
|
+
return {
|
|
1322
|
+
...signals(form),
|
|
1323
|
+
for(key) {
|
|
1324
|
+
let instance = instances.get(key);
|
|
1325
|
+
if (!instance)
|
|
1326
|
+
instances.set(key, instance = signals(form.for(key)));
|
|
1327
|
+
return instance;
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
function injectAction(fn, options = {}) {
|
|
1332
|
+
assertInInjectionContext7(injectAction);
|
|
1333
|
+
const router = required(HAMUR_ROUTER, "injectAction");
|
|
1334
|
+
const app = inject11(HAMUR_APP, { optional: true });
|
|
1335
|
+
const { instance } = options;
|
|
1336
|
+
const runner = createActionRunner(fn, {
|
|
1337
|
+
app,
|
|
1338
|
+
instance,
|
|
1339
|
+
options: () => options,
|
|
1340
|
+
refresh: () => router.refresh(),
|
|
1341
|
+
restored: restoredResult(handlerStateOf(inject11(HAMUR_PAYLOAD, { optional: true })), fn.id, instance)
|
|
1342
|
+
});
|
|
1343
|
+
const snapshot = signal6(runner.get(), ...ngDevMode ? [{ debugName: "snapshot" }] : []);
|
|
1344
|
+
const destroy = inject11(DestroyRef8);
|
|
1345
|
+
destroy.onDestroy(runner.subscribe(() => snapshot.set(runner.get())));
|
|
1346
|
+
const below = inject11(FORM_STATUS, { optional: true });
|
|
1347
|
+
if (below)
|
|
1348
|
+
destroy.onDestroy(below.owner.link(fn.id, runner, instance));
|
|
1349
|
+
else if (app)
|
|
1350
|
+
destroy.onDestroy(linkActionRunner(app, fn.id, runner, instance));
|
|
1351
|
+
return {
|
|
1352
|
+
run: runner.run,
|
|
1353
|
+
reset: runner.reset,
|
|
1354
|
+
state: computed7(() => snapshot().state),
|
|
1355
|
+
pending: computed7(() => snapshot().pending),
|
|
1356
|
+
error: computed7(() => snapshot().error),
|
|
1357
|
+
failure: computed7(() => snapshot().failure)
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
function injectOptimistic(value, reduce) {
|
|
1361
|
+
assertInInjectionContext7(injectOptimistic);
|
|
1362
|
+
const source = optimisticSource(inject11(HAMUR_APP, { optional: true }));
|
|
1363
|
+
const pending = signal6(source.get(), ...ngDevMode ? [{ debugName: "pending" }] : []);
|
|
1364
|
+
inject11(DestroyRef8).onDestroy(source.subscribe(() => pending.set(source.get())));
|
|
1365
|
+
const read = typeof value === "function" ? value : () => value;
|
|
1366
|
+
return computed7(() => {
|
|
1367
|
+
const runs = pending();
|
|
1368
|
+
const current = read();
|
|
1369
|
+
return runs.length ? reduce(current, runs) : current;
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
// packages/adapter-angular/src/request.ts
|
|
1373
|
+
import {
|
|
1374
|
+
DestroyRef as DestroyRef9,
|
|
1375
|
+
afterNextRender as afterNextRender4,
|
|
1376
|
+
assertInInjectionContext as assertInInjectionContext8,
|
|
1377
|
+
computed as computed8,
|
|
1378
|
+
inject as inject12,
|
|
1379
|
+
signal as signal7
|
|
1380
|
+
} from "@angular/core";
|
|
1381
|
+
import {
|
|
1382
|
+
APP_UPDATE_OFF,
|
|
1383
|
+
createAppUpdate,
|
|
1384
|
+
isOnline,
|
|
1385
|
+
pollInterval,
|
|
1386
|
+
runtimeConfigOf,
|
|
1387
|
+
siteConfigOf,
|
|
1388
|
+
startPoll,
|
|
1389
|
+
subscribeOnline,
|
|
1390
|
+
whenAppReady
|
|
1391
|
+
} from "hamur/adapter";
|
|
1392
|
+
import {
|
|
1393
|
+
reportWebVitals,
|
|
1394
|
+
setResponseStatus as setResponseStatusOf,
|
|
1395
|
+
usePreviewMode as previewModeOf,
|
|
1396
|
+
useRequestEvent as requestEventOf,
|
|
1397
|
+
useRequestFetch as requestFetchOf,
|
|
1398
|
+
useRequestHeader as requestHeaderOf,
|
|
1399
|
+
useRequestHeaders as requestHeadersOf,
|
|
1400
|
+
useRequestURL as requestURLOf,
|
|
1401
|
+
useResponseHeader as responseHeaderOf
|
|
1402
|
+
} from "hamur/app";
|
|
1403
|
+
var appOf = (name) => required(HAMUR_APP, name);
|
|
1404
|
+
function injectApp() {
|
|
1405
|
+
assertInInjectionContext8(injectApp);
|
|
1406
|
+
return appOf("injectApp");
|
|
1407
|
+
}
|
|
1408
|
+
function injectRuntimeConfig() {
|
|
1409
|
+
assertInInjectionContext8(injectRuntimeConfig);
|
|
1410
|
+
return runtimeConfigOf(appOf("injectRuntimeConfig"));
|
|
1411
|
+
}
|
|
1412
|
+
function injectSiteConfig() {
|
|
1413
|
+
assertInInjectionContext8(injectSiteConfig);
|
|
1414
|
+
return siteConfigOf(appOf("injectSiteConfig"));
|
|
1415
|
+
}
|
|
1416
|
+
function injectRuntimeHook(name, fn) {
|
|
1417
|
+
assertInInjectionContext8(injectRuntimeHook);
|
|
1418
|
+
inject12(DestroyRef9).onDestroy(appOf("injectRuntimeHook").hooks.hook(name, fn));
|
|
1419
|
+
}
|
|
1420
|
+
function injectReportWebVitals(fn) {
|
|
1421
|
+
assertInInjectionContext8(injectReportWebVitals);
|
|
1422
|
+
inject12(DestroyRef9).onDestroy(reportWebVitals(appOf("injectReportWebVitals"), fn));
|
|
1423
|
+
}
|
|
1424
|
+
function onAppReady(fn) {
|
|
1425
|
+
assertInInjectionContext8(onAppReady);
|
|
1426
|
+
whenAppReady(appOf("onAppReady"), fn);
|
|
1427
|
+
}
|
|
1428
|
+
function injectPreviewMode() {
|
|
1429
|
+
assertInInjectionContext8(injectPreviewMode);
|
|
1430
|
+
return previewModeOf(appOf("injectPreviewMode"));
|
|
1431
|
+
}
|
|
1432
|
+
function injectRequestEvent() {
|
|
1433
|
+
assertInInjectionContext8(injectRequestEvent);
|
|
1434
|
+
return requestEventOf(appOf("injectRequestEvent"));
|
|
1435
|
+
}
|
|
1436
|
+
function injectRequestHeaders(names) {
|
|
1437
|
+
assertInInjectionContext8(injectRequestHeaders);
|
|
1438
|
+
return requestHeadersOf(appOf("injectRequestHeaders"), names);
|
|
1439
|
+
}
|
|
1440
|
+
function injectRequestHeader(name) {
|
|
1441
|
+
assertInInjectionContext8(injectRequestHeader);
|
|
1442
|
+
return requestHeaderOf(appOf("injectRequestHeader"), name);
|
|
1443
|
+
}
|
|
1444
|
+
function injectRequestURL() {
|
|
1445
|
+
assertInInjectionContext8(injectRequestURL);
|
|
1446
|
+
return requestURLOf(appOf("injectRequestURL"));
|
|
1447
|
+
}
|
|
1448
|
+
function injectRequestFetch() {
|
|
1449
|
+
assertInInjectionContext8(injectRequestFetch);
|
|
1450
|
+
return requestFetchOf(appOf("injectRequestFetch"));
|
|
1451
|
+
}
|
|
1452
|
+
function setResponseStatus(status, statusText) {
|
|
1453
|
+
assertInInjectionContext8(setResponseStatus);
|
|
1454
|
+
setResponseStatusOf(appOf("setResponseStatus"), status, statusText);
|
|
1455
|
+
}
|
|
1456
|
+
function injectResponseHeader(name) {
|
|
1457
|
+
assertInInjectionContext8(injectResponseHeader);
|
|
1458
|
+
const header = responseHeaderOf(appOf("injectResponseHeader"), name);
|
|
1459
|
+
const read = signal7(header.get());
|
|
1460
|
+
return writableOf(read, (value) => {
|
|
1461
|
+
header.set(value);
|
|
1462
|
+
read.set(header.get());
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
function injectOnline() {
|
|
1466
|
+
assertInInjectionContext8(injectOnline);
|
|
1467
|
+
const online = signal7(true);
|
|
1468
|
+
const destroy = inject12(DestroyRef9);
|
|
1469
|
+
afterNextRender4(() => {
|
|
1470
|
+
online.set(isOnline());
|
|
1471
|
+
destroy.onDestroy(subscribeOnline((value) => online.set(value)));
|
|
1472
|
+
});
|
|
1473
|
+
return online.asReadonly();
|
|
1474
|
+
}
|
|
1475
|
+
function injectPoll(ms, options = {}) {
|
|
1476
|
+
assertInInjectionContext8(injectPoll);
|
|
1477
|
+
pollInterval(ms);
|
|
1478
|
+
const router = required(HAMUR_ROUTER, "injectPoll");
|
|
1479
|
+
const destroy = inject12(DestroyRef9);
|
|
1480
|
+
afterNextRender4(() => destroy.onDestroy(startPoll(ms, () => options.keys ? router.refresh(options.keys) : router.refresh())));
|
|
1481
|
+
}
|
|
1482
|
+
function injectAppUpdate() {
|
|
1483
|
+
assertInInjectionContext8(injectAppUpdate);
|
|
1484
|
+
const store = createAppUpdate(appOf("injectAppUpdate"));
|
|
1485
|
+
const state = signal7(APP_UPDATE_OFF);
|
|
1486
|
+
const destroy = inject12(DestroyRef9);
|
|
1487
|
+
afterNextRender4(() => {
|
|
1488
|
+
state.set(store.get());
|
|
1489
|
+
destroy.onDestroy(store.subscribe(() => state.set(store.get())));
|
|
1490
|
+
});
|
|
1491
|
+
return {
|
|
1492
|
+
available: computedOf(state, "available"),
|
|
1493
|
+
buildId: computedOf(state, "buildId"),
|
|
1494
|
+
time: computedOf(state, "time"),
|
|
1495
|
+
check: store.check
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
function computedOf(state, key) {
|
|
1499
|
+
return computed8(() => state()[key]);
|
|
1500
|
+
}
|
|
1501
|
+
// packages/adapter-angular/src/routing.ts
|
|
1502
|
+
import {
|
|
1503
|
+
DestroyRef as DestroyRef10,
|
|
1504
|
+
afterNextRender as afterNextRender5,
|
|
1505
|
+
assertInInjectionContext as assertInInjectionContext9,
|
|
1506
|
+
computed as computed9,
|
|
1507
|
+
effect as effect8,
|
|
1508
|
+
inject as inject13,
|
|
1509
|
+
signal as signal8
|
|
1510
|
+
} from "@angular/core";
|
|
1511
|
+
import {
|
|
1512
|
+
createBlocker,
|
|
1513
|
+
layoutOf,
|
|
1514
|
+
layoutSegments,
|
|
1515
|
+
matchesOf,
|
|
1516
|
+
navigationBlocker,
|
|
1517
|
+
navigationHook,
|
|
1518
|
+
registerSnapshot,
|
|
1519
|
+
resolveRelative,
|
|
1520
|
+
routeDataOf,
|
|
1521
|
+
routeGuard,
|
|
1522
|
+
equalSearch
|
|
1523
|
+
} from "hamur/adapter";
|
|
1524
|
+
function injectRoute(_name) {
|
|
1525
|
+
assertInInjectionContext9(injectRoute);
|
|
1526
|
+
return required(HAMUR_ROUTE, "injectRoute");
|
|
1527
|
+
}
|
|
1528
|
+
function injectRouter() {
|
|
1529
|
+
assertInInjectionContext9(injectRouter);
|
|
1530
|
+
return required(HAMUR_ROUTER, "injectRouter");
|
|
1531
|
+
}
|
|
1532
|
+
function injectNavigation() {
|
|
1533
|
+
assertInInjectionContext9(injectNavigation);
|
|
1534
|
+
return required(HAMUR_NAVIGATION, "injectNavigation");
|
|
1535
|
+
}
|
|
1536
|
+
function injectResolvedPath(to, { relative } = {}) {
|
|
1537
|
+
assertInInjectionContext9(injectResolvedPath);
|
|
1538
|
+
const route = required(HAMUR_ROUTE, "injectResolvedPath");
|
|
1539
|
+
return computed9(() => resolveRelative(typeof to === "function" ? to() : to, route(), relative));
|
|
1540
|
+
}
|
|
1541
|
+
function injectOutletContext() {
|
|
1542
|
+
assertInInjectionContext9(injectOutletContext);
|
|
1543
|
+
const value = inject13(HAMUR_OUTLET_CONTEXT, { optional: true });
|
|
1544
|
+
return computed9(() => value?.());
|
|
1545
|
+
}
|
|
1546
|
+
function injectLayoutSegments(_slot) {
|
|
1547
|
+
assertInInjectionContext9(injectLayoutSegments);
|
|
1548
|
+
const route = required(HAMUR_ROUTE, "injectLayoutSegments");
|
|
1549
|
+
const entry = entryOf("injectLayoutSegments");
|
|
1550
|
+
return computed9(() => layoutSegments(route(), entry()));
|
|
1551
|
+
}
|
|
1552
|
+
function injectLayoutSegment(slot) {
|
|
1553
|
+
assertInInjectionContext9(injectLayoutSegment);
|
|
1554
|
+
const segments = injectLayoutSegments(slot);
|
|
1555
|
+
return computed9(() => segments()[0] ?? null);
|
|
1556
|
+
}
|
|
1557
|
+
function injectLayout() {
|
|
1558
|
+
assertInInjectionContext9(injectLayout);
|
|
1559
|
+
const tree = required(HAMUR_ROOT_TREE, "injectLayout");
|
|
1560
|
+
return computed9(() => layoutOf(tree()));
|
|
1561
|
+
}
|
|
1562
|
+
function injectMatches() {
|
|
1563
|
+
assertInInjectionContext9(injectMatches);
|
|
1564
|
+
const route = required(HAMUR_ROUTE, "injectMatches");
|
|
1565
|
+
const payload = required(HAMUR_PAYLOAD, "injectMatches");
|
|
1566
|
+
return computed9(() => matchesOf(route(), dataOf(payload)));
|
|
1567
|
+
}
|
|
1568
|
+
function injectRouteData(name) {
|
|
1569
|
+
assertInInjectionContext9(injectRouteData);
|
|
1570
|
+
const route = required(HAMUR_ROUTE, "injectRouteData");
|
|
1571
|
+
const payload = required(HAMUR_PAYLOAD, "injectRouteData");
|
|
1572
|
+
return computed9(() => routeDataOf(route(), dataOf(payload), name));
|
|
1573
|
+
}
|
|
1574
|
+
function injectSearch(select) {
|
|
1575
|
+
assertInInjectionContext9(injectSearch);
|
|
1576
|
+
const route = required(HAMUR_ROUTE, "injectSearch");
|
|
1577
|
+
const router = required(HAMUR_ROUTER, "injectSearch");
|
|
1578
|
+
const value = computed9(() => select ? select(route().search) : route().search, {
|
|
1579
|
+
equal: equalSearch
|
|
1580
|
+
});
|
|
1581
|
+
const set = (change, { replace = true } = {}) => {
|
|
1582
|
+
const update = { query: (prev) => typeof change === "function" ? change(prev) : change };
|
|
1583
|
+
return replace ? router.replace(update) : router.navigate(update);
|
|
1584
|
+
};
|
|
1585
|
+
return { value, set };
|
|
1586
|
+
}
|
|
1587
|
+
function whileAlive(register) {
|
|
1588
|
+
inject13(DestroyRef10).onDestroy(register());
|
|
1589
|
+
}
|
|
1590
|
+
function hook(kind, fn) {
|
|
1591
|
+
whileAlive(() => navigationHook(kind, fn));
|
|
1592
|
+
}
|
|
1593
|
+
function onBeforeNavigate(fn) {
|
|
1594
|
+
assertInInjectionContext9(onBeforeNavigate);
|
|
1595
|
+
hook("before", fn);
|
|
1596
|
+
}
|
|
1597
|
+
function onNavigate(fn) {
|
|
1598
|
+
assertInInjectionContext9(onNavigate);
|
|
1599
|
+
hook("navigate", fn);
|
|
1600
|
+
}
|
|
1601
|
+
function onAfterNavigate(fn) {
|
|
1602
|
+
assertInInjectionContext9(onAfterNavigate);
|
|
1603
|
+
hook("after", fn);
|
|
1604
|
+
}
|
|
1605
|
+
function guard(kind, fn, name) {
|
|
1606
|
+
const entry = entryOf(name);
|
|
1607
|
+
whileAlive(() => routeGuard(kind, entry(), fn));
|
|
1608
|
+
}
|
|
1609
|
+
function onBeforeRouteLeave(fn) {
|
|
1610
|
+
assertInInjectionContext9(onBeforeRouteLeave);
|
|
1611
|
+
guard("leave", fn, "onBeforeRouteLeave");
|
|
1612
|
+
}
|
|
1613
|
+
function onBeforeRouteUpdate(fn) {
|
|
1614
|
+
assertInInjectionContext9(onBeforeRouteUpdate);
|
|
1615
|
+
guard("update", fn, "onBeforeRouteUpdate");
|
|
1616
|
+
}
|
|
1617
|
+
function injectPreventNavigate(fn) {
|
|
1618
|
+
assertInInjectionContext9(injectPreventNavigate);
|
|
1619
|
+
whileAlive(() => navigationBlocker(fn));
|
|
1620
|
+
}
|
|
1621
|
+
function injectBlocker(options) {
|
|
1622
|
+
assertInInjectionContext9(injectBlocker);
|
|
1623
|
+
const store = createBlocker(options);
|
|
1624
|
+
const value = signal8(store.get());
|
|
1625
|
+
const unsubscribe = store.subscribe(() => value.set(store.get()));
|
|
1626
|
+
const stop = store.start();
|
|
1627
|
+
effect8(() => store.sync());
|
|
1628
|
+
inject13(DestroyRef10).onDestroy(() => {
|
|
1629
|
+
stop();
|
|
1630
|
+
unsubscribe();
|
|
1631
|
+
});
|
|
1632
|
+
return value.asReadonly();
|
|
1633
|
+
}
|
|
1634
|
+
function injectSnapshot(key, options) {
|
|
1635
|
+
assertInInjectionContext9(injectSnapshot);
|
|
1636
|
+
const destroy = inject13(DestroyRef10);
|
|
1637
|
+
afterNextRender5(() => destroy.onDestroy(registerSnapshot(key, options)));
|
|
1638
|
+
}
|
|
1639
|
+
export {
|
|
1640
|
+
Announcer,
|
|
1641
|
+
DefaultErrorPage,
|
|
1642
|
+
DevOnly2 as DevOnly,
|
|
1643
|
+
Form,
|
|
1644
|
+
Island,
|
|
1645
|
+
Link,
|
|
1646
|
+
LoadingIndicator,
|
|
1647
|
+
MarkdownRenderer,
|
|
1648
|
+
Navigate,
|
|
1649
|
+
Outlet2 as Outlet,
|
|
1650
|
+
RouteAnnouncer,
|
|
1651
|
+
ServerIsland,
|
|
1652
|
+
Time,
|
|
1653
|
+
callOnce,
|
|
1654
|
+
clearError,
|
|
1655
|
+
clearState,
|
|
1656
|
+
forbidden,
|
|
1657
|
+
injectAction,
|
|
1658
|
+
injectAnnouncer,
|
|
1659
|
+
injectApp,
|
|
1660
|
+
injectAppUpdate,
|
|
1661
|
+
injectAsyncData,
|
|
1662
|
+
injectBlocker,
|
|
1663
|
+
injectCookie,
|
|
1664
|
+
injectData,
|
|
1665
|
+
injectDeferred2 as injectDeferred,
|
|
1666
|
+
injectError,
|
|
1667
|
+
injectFetch,
|
|
1668
|
+
injectForm,
|
|
1669
|
+
injectFormStatus,
|
|
1670
|
+
injectHead,
|
|
1671
|
+
injectHeadSafe,
|
|
1672
|
+
injectHydrated2 as injectHydrated,
|
|
1673
|
+
injectId2 as injectId,
|
|
1674
|
+
injectLayout,
|
|
1675
|
+
injectLayoutSegment,
|
|
1676
|
+
injectLayoutSegments,
|
|
1677
|
+
injectLazyAsyncData,
|
|
1678
|
+
injectLazyFetch,
|
|
1679
|
+
injectLink,
|
|
1680
|
+
injectLinkStatus,
|
|
1681
|
+
injectLoadingIndicator,
|
|
1682
|
+
injectMatches,
|
|
1683
|
+
injectNavigation,
|
|
1684
|
+
injectNuxtData,
|
|
1685
|
+
injectOnline,
|
|
1686
|
+
injectOptimistic,
|
|
1687
|
+
injectOutletContext,
|
|
1688
|
+
injectPoll,
|
|
1689
|
+
injectPreventNavigate,
|
|
1690
|
+
injectPreviewMode,
|
|
1691
|
+
injectReportWebVitals,
|
|
1692
|
+
injectRequestEvent,
|
|
1693
|
+
injectRequestFetch,
|
|
1694
|
+
injectRequestHeader,
|
|
1695
|
+
injectRequestHeaders,
|
|
1696
|
+
injectRequestURL,
|
|
1697
|
+
injectResolvedPath,
|
|
1698
|
+
injectResponseHeader,
|
|
1699
|
+
injectRoute,
|
|
1700
|
+
injectRouteAnnouncer,
|
|
1701
|
+
injectRouteData,
|
|
1702
|
+
injectRouter,
|
|
1703
|
+
injectRuntimeConfig,
|
|
1704
|
+
injectRuntimeHook,
|
|
1705
|
+
injectSearch,
|
|
1706
|
+
injectSeoMeta,
|
|
1707
|
+
injectServerHead,
|
|
1708
|
+
injectServerSeoMeta,
|
|
1709
|
+
injectSiteConfig,
|
|
1710
|
+
injectSnapshot,
|
|
1711
|
+
injectState,
|
|
1712
|
+
injectSyncedState,
|
|
1713
|
+
navigateTo2 as navigateTo,
|
|
1714
|
+
notFound,
|
|
1715
|
+
onAfterNavigate,
|
|
1716
|
+
onAppReady,
|
|
1717
|
+
onBeforeNavigate,
|
|
1718
|
+
onBeforeRouteLeave,
|
|
1719
|
+
onBeforeRouteUpdate,
|
|
1720
|
+
onNavigate,
|
|
1721
|
+
onPageActivated2 as onPageActivated,
|
|
1722
|
+
onPageDeactivated2 as onPageDeactivated,
|
|
1723
|
+
onPrehydrate2 as onPrehydrate,
|
|
1724
|
+
permanentRedirect,
|
|
1725
|
+
setResponseStatus,
|
|
1726
|
+
showError,
|
|
1727
|
+
transitionName2 as transitionName,
|
|
1728
|
+
unauthorized
|
|
1729
|
+
};
|