@nativescript/compiler-angular 0.0.0-stage → 9.2.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-libraries.js +173 -0
- package/dist/angular.js +2895 -0
- package/dist/component-bases.js +746 -0
- package/dist/core-api.js +8 -0
- package/dist/entry.js +118 -0
- package/dist/index.js +157 -0
- package/dist/kotlin.js +280 -0
- package/dist/modules.js +698 -0
- package/dist/ng-modules.js +66 -0
- package/dist/package.js +15 -0
- package/dist/refusals.js +5 -0
- package/dist/semantics.js +213 -0
- package/dist/swift.js +340 -0
- package/kit-android/fromcore/AngularAPI.kt +172 -0
- package/kit-android/fromcore/AngularRouter.kt +587 -0
- package/kit-android/handport/Router.kt +151 -0
- package/kit-android/main/AngularChangeDetection.kt +250 -0
- package/kit-android/main/AngularCore.kt +685 -0
- package/kit-android/main/AngularHttp.kt +431 -0
- package/kit-android/main/AngularRouterValues.kt +154 -0
- package/kit-android/main/AngularRx.kt +224 -0
- package/kit-apple/AngularAPI.swift +224 -0
- package/kit-apple/AngularChangeDetection.swift +248 -0
- package/kit-apple/AngularCore.swift +764 -0
- package/kit-apple/AngularHttp.swift +467 -0
- package/kit-apple/AngularRouter.swift +626 -0
- package/kit-apple/AngularRouterValues.swift +285 -0
- package/kit-apple/AngularRx.swift +246 -0
- package/kit-apple/kit-index.json +739 -0
- package/package.json +53 -4
- package/runtime/angular-forms.ts +3099 -0
- package/runtime/angular-rx.ts +550 -0
- package/runtime/angular.ts +826 -0
- package/README.md +0 -3
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
// The Angular APIs a compiled app imports from @angular/common/http and @angular/router, over the kit's Observable and
|
|
2
|
+
// router. Their declarations (HttpClient, the router's classes, Route, the guard types) follow Angular's:
|
|
3
|
+
//
|
|
4
|
+
// @license
|
|
5
|
+
// Copyright Google LLC All Rights Reserved.
|
|
6
|
+
// Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
// found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
|
|
9
|
+
import { firstValueFrom, isObservable, Observable, type OperatorFunction, ReplaySubject, type Subscription } from 'rxjs';
|
|
10
|
+
import { DestroyRef, effect, inject, InjectionToken, type Signal, signal } from '@angular/core';
|
|
11
|
+
import {
|
|
12
|
+
ActivatedRouteSnapshot,
|
|
13
|
+
bootstrapApplication,
|
|
14
|
+
convertToParamMap,
|
|
15
|
+
createRouterStateSnapshot,
|
|
16
|
+
DefaultUrlSerializer,
|
|
17
|
+
HTTP_INTERCEPTORS,
|
|
18
|
+
HttpClientModule,
|
|
19
|
+
HttpContext,
|
|
20
|
+
HttpContextToken,
|
|
21
|
+
HttpErrorResponse,
|
|
22
|
+
HttpHeaders,
|
|
23
|
+
HttpParams,
|
|
24
|
+
HttpRequest,
|
|
25
|
+
HttpResponse,
|
|
26
|
+
HttpStatusCode,
|
|
27
|
+
KitActivatedRoute,
|
|
28
|
+
KitHttpClient,
|
|
29
|
+
KitNativeDialogRef,
|
|
30
|
+
KitNativeDialogService,
|
|
31
|
+
KitRouter,
|
|
32
|
+
NavigationCancel,
|
|
33
|
+
NavigationEnd,
|
|
34
|
+
NavigationError,
|
|
35
|
+
NavigationStart,
|
|
36
|
+
ParamMap,
|
|
37
|
+
provideHttpClient,
|
|
38
|
+
provideNativeScriptHttpClient,
|
|
39
|
+
provideNativeScriptNgZone,
|
|
40
|
+
provideNativeScriptRouter,
|
|
41
|
+
provideRouter,
|
|
42
|
+
ResolveEnd,
|
|
43
|
+
ResolveStart,
|
|
44
|
+
RoutesRecognized,
|
|
45
|
+
RouterStateSnapshot,
|
|
46
|
+
runNativeScriptAngularApp,
|
|
47
|
+
type RxObservable,
|
|
48
|
+
UrlSegment,
|
|
49
|
+
UrlTree,
|
|
50
|
+
withFetch,
|
|
51
|
+
withInterceptors,
|
|
52
|
+
withInterceptorsFromDi,
|
|
53
|
+
} from '@angular#kit';
|
|
54
|
+
|
|
55
|
+
export function fromKit<T>(kit: RxObservable<T>): Observable<T> {
|
|
56
|
+
return new Observable<T>((subscriber) => {
|
|
57
|
+
const sub = kit.subscribe(
|
|
58
|
+
(value) => subscriber.next(value),
|
|
59
|
+
(err) => subscriber.error(err),
|
|
60
|
+
() => subscriber.complete(),
|
|
61
|
+
);
|
|
62
|
+
return () => sub.unsubscribe();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
ActivatedRouteSnapshot,
|
|
68
|
+
bootstrapApplication,
|
|
69
|
+
convertToParamMap,
|
|
70
|
+
createRouterStateSnapshot,
|
|
71
|
+
DefaultUrlSerializer,
|
|
72
|
+
HTTP_INTERCEPTORS,
|
|
73
|
+
HttpClientModule,
|
|
74
|
+
HttpContext,
|
|
75
|
+
HttpContextToken,
|
|
76
|
+
HttpErrorResponse,
|
|
77
|
+
HttpHeaders,
|
|
78
|
+
HttpParams,
|
|
79
|
+
HttpRequest,
|
|
80
|
+
HttpResponse,
|
|
81
|
+
HttpStatusCode,
|
|
82
|
+
NavigationCancel,
|
|
83
|
+
NavigationEnd,
|
|
84
|
+
NavigationError,
|
|
85
|
+
NavigationStart,
|
|
86
|
+
ParamMap,
|
|
87
|
+
provideHttpClient,
|
|
88
|
+
provideNativeScriptHttpClient,
|
|
89
|
+
provideNativeScriptNgZone,
|
|
90
|
+
provideNativeScriptRouter,
|
|
91
|
+
provideRouter,
|
|
92
|
+
ResolveEnd,
|
|
93
|
+
ResolveStart,
|
|
94
|
+
RoutesRecognized,
|
|
95
|
+
RouterStateSnapshot,
|
|
96
|
+
runNativeScriptAngularApp,
|
|
97
|
+
UrlSegment,
|
|
98
|
+
UrlTree,
|
|
99
|
+
withFetch,
|
|
100
|
+
withInterceptors,
|
|
101
|
+
withInterceptorsFromDi,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export interface HttpHandler {
|
|
105
|
+
handle(req: HttpRequest<any>): Observable<any>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface HttpInterceptor {
|
|
109
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<any>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type HttpInterceptorFn = (req: HttpRequest<any>, next: (req: HttpRequest<any>) => Observable<any>) => Observable<any>;
|
|
113
|
+
export type HttpEvent<T = any> = HttpResponse<T>;
|
|
114
|
+
|
|
115
|
+
export class HttpClient {
|
|
116
|
+
static readonly shared = new HttpClient();
|
|
117
|
+
|
|
118
|
+
request<T = any>(first: string | HttpRequest<any>, url?: string, options?: any): Observable<T> {
|
|
119
|
+
if (first instanceof HttpRequest) {
|
|
120
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
121
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
122
|
+
let handler: HttpHandler = {
|
|
123
|
+
handle: (r: HttpRequest<any>) => fromKit(KitHttpClient.shared.request(r)),
|
|
124
|
+
};
|
|
125
|
+
for (let i = interceptors.length - 1; i >= 0; i--) {
|
|
126
|
+
const interceptor = interceptors[i];
|
|
127
|
+
if (interceptor && typeof interceptor.intercept === 'function') {
|
|
128
|
+
const next = handler;
|
|
129
|
+
handler = { handle: (r: HttpRequest<any>) => interceptor.intercept(r, next) };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return handler.handle(first);
|
|
133
|
+
}
|
|
134
|
+
return fromKit(KitHttpClient.shared.request(first));
|
|
135
|
+
}
|
|
136
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
137
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
138
|
+
const observe = options?.observe || 'body';
|
|
139
|
+
const req = new HttpRequest(first, url || '', options?.body ?? null, options);
|
|
140
|
+
let handler: HttpHandler = {
|
|
141
|
+
handle: (r: HttpRequest<any>) => fromKit(KitHttpClient.shared.request(r)),
|
|
142
|
+
};
|
|
143
|
+
for (let i = interceptors.length - 1; i >= 0; i--) {
|
|
144
|
+
const interceptor = interceptors[i];
|
|
145
|
+
if (interceptor && typeof interceptor.intercept === 'function') {
|
|
146
|
+
const next = handler;
|
|
147
|
+
handler = { handle: (r: HttpRequest<any>) => interceptor.intercept(r, next) };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return new Observable<T>((subscriber) => {
|
|
151
|
+
const sub = handler.handle(req).subscribe({
|
|
152
|
+
next: (event: any) => {
|
|
153
|
+
if (observe === 'response' || observe === 'events') {
|
|
154
|
+
subscriber.next(event);
|
|
155
|
+
} else if (event instanceof HttpResponse) {
|
|
156
|
+
subscriber.next(event.body);
|
|
157
|
+
} else {
|
|
158
|
+
subscriber.next(event);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
error: (err: any) => subscriber.error(err),
|
|
162
|
+
complete: () => subscriber.complete(),
|
|
163
|
+
});
|
|
164
|
+
return () => sub.unsubscribe();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return fromKit(KitHttpClient.shared.request(first, url, options));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get(url: string, options: { headers?: Record<string, string> | HttpHeaders; responseType: 'text'; params?: any; observe?: any; context?: HttpContext }): Observable<string>;
|
|
171
|
+
get<T = any>(url: string, options?: any): Observable<T>;
|
|
172
|
+
get(url: string, options?: any): Observable<any> {
|
|
173
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
174
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
175
|
+
return this.request('GET', url, options);
|
|
176
|
+
}
|
|
177
|
+
return fromKit(KitHttpClient.shared.get(url, options));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
delete<T = any>(url: string, options?: any): Observable<T> {
|
|
181
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
182
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
183
|
+
return this.request('DELETE', url, options);
|
|
184
|
+
}
|
|
185
|
+
return fromKit(KitHttpClient.shared.delete(url, options));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
head<T = any>(url: string, options?: any): Observable<T> {
|
|
189
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
190
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
191
|
+
return this.request('HEAD', url, options);
|
|
192
|
+
}
|
|
193
|
+
return fromKit(KitHttpClient.shared.head(url, options));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
options<T = any>(url: string, options?: any): Observable<T> {
|
|
197
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
198
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
199
|
+
return this.request('OPTIONS', url, options);
|
|
200
|
+
}
|
|
201
|
+
return fromKit(KitHttpClient.shared.options(url, options));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
post<T = any>(url: string, body: any, options?: any): Observable<T> {
|
|
205
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
206
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
207
|
+
return this.request('POST', url, { ...(options || {}), body });
|
|
208
|
+
}
|
|
209
|
+
return fromKit(KitHttpClient.shared.post(url, body, options));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
put<T = any>(url: string, body: any, options?: any): Observable<T> {
|
|
213
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
214
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
215
|
+
return this.request('PUT', url, { ...(options || {}), body });
|
|
216
|
+
}
|
|
217
|
+
return fromKit(KitHttpClient.shared.put(url, body, options));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
patch<T = any>(url: string, body: any, options?: any): Observable<T> {
|
|
221
|
+
const interceptors = inject<HttpInterceptor[]>(HTTP_INTERCEPTORS as any, { optional: true } as any);
|
|
222
|
+
if (Array.isArray(interceptors) && interceptors.length > 0) {
|
|
223
|
+
return this.request('PATCH', url, { ...(options || {}), body });
|
|
224
|
+
}
|
|
225
|
+
return fromKit(KitHttpClient.shared.patch(url, body, options));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
jsonp<T = any>(url: string, callbackParam: string): Observable<T> {
|
|
229
|
+
return fromKit(KitHttpClient.shared.jsonp(url, callbackParam));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export class ActivatedRoute {
|
|
234
|
+
readonly _kit: KitActivatedRoute;
|
|
235
|
+
readonly snapshot: ActivatedRouteSnapshot;
|
|
236
|
+
readonly params: Observable<Record<string, string>>;
|
|
237
|
+
readonly queryParams: Observable<Record<string, string>>;
|
|
238
|
+
readonly data: Observable<Record<string, any>>;
|
|
239
|
+
readonly paramMap: Observable<ParamMap>;
|
|
240
|
+
readonly queryParamMap: Observable<ParamMap>;
|
|
241
|
+
readonly fragment: Observable<string | null>;
|
|
242
|
+
readonly title: Observable<string | undefined>;
|
|
243
|
+
readonly outlet: string;
|
|
244
|
+
readonly routeConfig: any;
|
|
245
|
+
|
|
246
|
+
constructor(kit: KitActivatedRoute = KitActivatedRoute.current) {
|
|
247
|
+
this._kit = kit;
|
|
248
|
+
this.snapshot = kit.snapshot;
|
|
249
|
+
this.params = fromKit(kit.params);
|
|
250
|
+
this.queryParams = fromKit(kit.queryParams);
|
|
251
|
+
this.data = fromKit(kit.data);
|
|
252
|
+
this.paramMap = fromKit(kit.paramMap);
|
|
253
|
+
this.queryParamMap = fromKit(kit.queryParamMap);
|
|
254
|
+
this.fragment = fromKit(kit.fragment);
|
|
255
|
+
this.title = fromKit(kit.title);
|
|
256
|
+
this.outlet = kit.outlet;
|
|
257
|
+
this.routeConfig = kit.routeConfig;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
get root(): ActivatedRoute {
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
get parent(): ActivatedRoute | null {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
get firstChild(): ActivatedRoute | null {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
get children(): ActivatedRoute[] {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
get pathFromRoot(): ActivatedRoute[] {
|
|
277
|
+
return [this];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
static get shared(): ActivatedRoute {
|
|
281
|
+
return new ActivatedRoute(KitActivatedRoute.current);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export type Event = NavigationEnd | NavigationStart | NavigationCancel | NavigationError | RoutesRecognized | ResolveStart | ResolveEnd;
|
|
286
|
+
|
|
287
|
+
export class Router {
|
|
288
|
+
static readonly shared = new Router();
|
|
289
|
+
readonly events: Observable<Event> = fromKit(KitRouter.shared.events);
|
|
290
|
+
|
|
291
|
+
get url(): string {
|
|
292
|
+
return KitRouter.shared.url;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
get router(): Router {
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
get routerState(): any {
|
|
300
|
+
return KitRouter.shared.routerState;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
createUrlTree(commands: any[], extras?: any): UrlTree {
|
|
304
|
+
return KitRouter.shared.createUrlTree(commands, extras);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
serializeUrl(url: UrlTree): string {
|
|
308
|
+
return KitRouter.shared.serializeUrl(url);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
parseUrl(url: string): UrlTree {
|
|
312
|
+
return KitRouter.shared.parseUrl(url);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
isActive(url: string | UrlTree, exact: any = false): boolean {
|
|
316
|
+
return KitRouter.shared.isActive(url, exact);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
navigate(commands: any[], extras?: any): Promise<boolean> {
|
|
320
|
+
return KitRouter.shared.navigate(commands, extras);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
navigateByUrl(url: string | UrlTree, extras?: any): Promise<boolean> {
|
|
324
|
+
return KitRouter.shared.navigateByUrl(url, extras);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
back(options?: { relativeTo?: any; outlets?: string[] }): void {
|
|
328
|
+
KitRouter.shared.back(options);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
backToPreviousPage(): void {
|
|
332
|
+
KitRouter.shared.backToPreviousPage();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
canGoBack(options?: any): boolean {
|
|
336
|
+
return KitRouter.shared.canGoBack(options);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
canGoBackToPreviousPage(): boolean {
|
|
340
|
+
return KitRouter.shared.canGoBackToPreviousPage();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface Route {
|
|
345
|
+
path?: string;
|
|
346
|
+
component?: any;
|
|
347
|
+
redirectTo?: string;
|
|
348
|
+
pathMatch?: string;
|
|
349
|
+
outlet?: string;
|
|
350
|
+
data?: Record<string, any>;
|
|
351
|
+
canActivate?: any[];
|
|
352
|
+
canActivateChild?: any[];
|
|
353
|
+
canDeactivate?: any[];
|
|
354
|
+
canMatch?: any[];
|
|
355
|
+
resolve?: Record<string, any>;
|
|
356
|
+
providers?: any[];
|
|
357
|
+
children?: Route[];
|
|
358
|
+
loadChildren?: () => any;
|
|
359
|
+
loadComponent?: () => any;
|
|
360
|
+
title?: any;
|
|
361
|
+
}
|
|
362
|
+
export type Routes = Route[];
|
|
363
|
+
|
|
364
|
+
export type NavigationExtras = any;
|
|
365
|
+
export type Params = { [key: string]: any };
|
|
366
|
+
export interface IsActiveMatchOptions {
|
|
367
|
+
matrixParams: 'exact' | 'subset' | 'ignored';
|
|
368
|
+
queryParams: 'exact' | 'subset' | 'ignored';
|
|
369
|
+
paths: 'exact' | 'subset';
|
|
370
|
+
fragment: 'exact' | 'ignored';
|
|
371
|
+
}
|
|
372
|
+
export type GuardResult = boolean | UrlTree;
|
|
373
|
+
export type MaybeAsync<T> = T | Observable<T> | Promise<T>;
|
|
374
|
+
export type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
375
|
+
export type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
376
|
+
export type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
377
|
+
export type CanMatchFn = (route: Route, segments: UrlSegment[]) => MaybeAsync<GuardResult>;
|
|
378
|
+
export interface CanActivate {
|
|
379
|
+
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): MaybeAsync<GuardResult>;
|
|
380
|
+
}
|
|
381
|
+
export interface CanActivateChild {
|
|
382
|
+
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): MaybeAsync<GuardResult>;
|
|
383
|
+
}
|
|
384
|
+
export interface CanDeactivate<T> {
|
|
385
|
+
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): MaybeAsync<GuardResult>;
|
|
386
|
+
}
|
|
387
|
+
export interface CanMatch {
|
|
388
|
+
canMatch(route: Route, segments: UrlSegment[]): MaybeAsync<GuardResult>;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** A guard's result as the kit's router takes it: an Observable's first value as a promise (Angular's `first()`), else the result. */
|
|
392
|
+
export function ɵguardResult(result: any): any {
|
|
393
|
+
return isObservable(result) ? firstValueFrom(result) : result;
|
|
394
|
+
}
|
|
395
|
+
export type ParamMapType = ParamMap;
|
|
396
|
+
export { Router as RouterExtensions };
|
|
397
|
+
|
|
398
|
+
export type NativeDialogConfig<D = any> = {
|
|
399
|
+
data?: D;
|
|
400
|
+
nativeOptions?: any;
|
|
401
|
+
[key: string]: any;
|
|
402
|
+
};
|
|
403
|
+
export const NATIVE_DIALOG_DATA = new InjectionToken<any>('NativeDialogData');
|
|
404
|
+
|
|
405
|
+
export class NativeDialogRef<T = any, R = any> {
|
|
406
|
+
readonly _kit: KitNativeDialogRef;
|
|
407
|
+
readonly componentInstance: T = undefined as any;
|
|
408
|
+
constructor(kit: KitNativeDialogRef = KitNativeDialogRef.current) {
|
|
409
|
+
this._kit = kit;
|
|
410
|
+
}
|
|
411
|
+
static get shared(): NativeDialogRef<any, any> {
|
|
412
|
+
return new NativeDialogRef(KitNativeDialogRef.current);
|
|
413
|
+
}
|
|
414
|
+
close(result?: R): void {
|
|
415
|
+
this._kit.close(result);
|
|
416
|
+
}
|
|
417
|
+
afterClosed(): Observable<R | undefined> {
|
|
418
|
+
return fromKit(this._kit.afterClosed());
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export class NativeDialogService {
|
|
423
|
+
static readonly shared = new NativeDialogService();
|
|
424
|
+
open<T = any, D = any, R = any>(component: any, config?: NativeDialogConfig<D>): NativeDialogRef<T, R> {
|
|
425
|
+
return new NativeDialogRef(KitNativeDialogService.shared.open(component, config));
|
|
426
|
+
}
|
|
427
|
+
closeAll(): void {}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export { NativeDialogService as NativeDialog };
|
|
431
|
+
|
|
432
|
+
export const NativeDialogModule: any = undefined;
|
|
433
|
+
export function registerElement(_name: string, _resolver: () => any, _meta?: any): void {}
|
|
434
|
+
/** A release build never restores routes for hot module replacement. */
|
|
435
|
+
export function isAngularHmrRestoringRoute(): boolean {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
export const ActionBarComponent: any = undefined;
|
|
439
|
+
export const ActionItemDirective: any = undefined;
|
|
440
|
+
export const NavigationButtonDirective: any = undefined;
|
|
441
|
+
export const TabViewDirective: any = undefined;
|
|
442
|
+
export const TabViewItemDirective: any = undefined;
|
|
443
|
+
export const NSEmptyOutletComponent: any = undefined;
|
|
444
|
+
export const NativeScriptCommonModule: any = undefined;
|
|
445
|
+
export const NativeScriptFormsModule: any = undefined;
|
|
446
|
+
export const NativeScriptHttpClientModule: any = undefined;
|
|
447
|
+
export const NativeScriptModule: any = undefined;
|
|
448
|
+
export const NativeScriptRouterModule = {
|
|
449
|
+
forRoot(_routes: any, _config?: any): any {
|
|
450
|
+
return undefined;
|
|
451
|
+
},
|
|
452
|
+
forChild(_routes: any): any {
|
|
453
|
+
return undefined;
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
export function platformNativeScript(): { bootstrapModule(module: any, options?: any): Promise<any> } {
|
|
457
|
+
return {
|
|
458
|
+
bootstrapModule(_module: any, _options?: any): Promise<any> {
|
|
459
|
+
return Promise.resolve();
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
export const PageRouterOutlet: any = undefined;
|
|
464
|
+
export const RouterOutlet: any = undefined;
|
|
465
|
+
export const RouterLink: any = undefined;
|
|
466
|
+
export const RouterLinkActive: any = undefined;
|
|
467
|
+
export const NSRouterLink: any = undefined;
|
|
468
|
+
export const NSRouterLinkActive: any = undefined;
|
|
469
|
+
|
|
470
|
+
export function toSignal<T>(source: Observable<T>, options: { initialValue: T; injector?: any; requireSync?: boolean; manualCleanup?: boolean; equal?: any }): Signal<T>;
|
|
471
|
+
export function toSignal<T>(source: Observable<T>, options: { requireSync: true; injector?: any; manualCleanup?: boolean; equal?: any }): Signal<T>;
|
|
472
|
+
export function toSignal<T>(source: Observable<T>, options?: { initialValue?: T; injector?: any; requireSync?: boolean; manualCleanup?: boolean; equal?: any }): Signal<T | undefined>;
|
|
473
|
+
export function toSignal<T>(source: Observable<T>, options?: { initialValue?: T; injector?: any; requireSync?: boolean; manualCleanup?: boolean; equal?: any }): Signal<any> {
|
|
474
|
+
const sig = signal<any>(options?.initialValue);
|
|
475
|
+
const sub = source.subscribe((value) => {
|
|
476
|
+
sig.set(value);
|
|
477
|
+
});
|
|
478
|
+
if (!options?.manualCleanup) {
|
|
479
|
+
inject(DestroyRef).onDestroy(() => {
|
|
480
|
+
sub.unsubscribe();
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
return sig.asReadonly();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export function toObservable<T>(source: Signal<T>, _options?: { injector?: any }): Observable<T> {
|
|
487
|
+
const subject = new ReplaySubject<T>(1);
|
|
488
|
+
const ref = effect(() => {
|
|
489
|
+
subject.next(source());
|
|
490
|
+
});
|
|
491
|
+
inject(DestroyRef).onDestroy(() => {
|
|
492
|
+
ref.destroy();
|
|
493
|
+
subject.complete();
|
|
494
|
+
});
|
|
495
|
+
return subject.asObservable();
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export function takeUntilDestroyed<T>(destroyRef?: DestroyRef): OperatorFunction<T, T> {
|
|
499
|
+
const ref = destroyRef ?? inject(DestroyRef);
|
|
500
|
+
return (source: Observable<T>) =>
|
|
501
|
+
new Observable<T>((subscriber) => {
|
|
502
|
+
const sub = source.subscribe({
|
|
503
|
+
next: (value) => subscriber.next(value),
|
|
504
|
+
error: (err) => subscriber.error(err),
|
|
505
|
+
complete: () => subscriber.complete(),
|
|
506
|
+
});
|
|
507
|
+
const stop = ref.onDestroy(() => {
|
|
508
|
+
sub.unsubscribe();
|
|
509
|
+
subscriber.complete();
|
|
510
|
+
});
|
|
511
|
+
return () => {
|
|
512
|
+
stop();
|
|
513
|
+
sub.unsubscribe();
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export class AsyncPipe {
|
|
519
|
+
private source: Observable<any> | null | undefined = null;
|
|
520
|
+
private sub: Subscription | null = null;
|
|
521
|
+
private latest = signal<any>(null);
|
|
522
|
+
|
|
523
|
+
constructor() {
|
|
524
|
+
inject(DestroyRef).onDestroy(() => {
|
|
525
|
+
this.dispose();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
transform<T>(observable: Observable<T> | null | undefined): T | null {
|
|
530
|
+
if (observable !== this.source) {
|
|
531
|
+
this.dispose();
|
|
532
|
+
this.source = observable;
|
|
533
|
+
if (observable) {
|
|
534
|
+
this.sub = observable.subscribe((value) => {
|
|
535
|
+
this.latest.set(value);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return this.latest();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private dispose(): void {
|
|
543
|
+
if (this.sub) {
|
|
544
|
+
this.sub.unsubscribe();
|
|
545
|
+
this.sub = null;
|
|
546
|
+
}
|
|
547
|
+
this.source = null;
|
|
548
|
+
this.latest.set(null);
|
|
549
|
+
}
|
|
550
|
+
}
|