@hybridly/core 0.10.0-beta.2 → 0.10.0-beta.20

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.
@@ -1,20 +1,13 @@
1
- import "node:module";
2
-
3
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
4
2
  var __defProp = Object.defineProperty;
5
- var __exportAll = (all, symbols) => {
3
+ var __exportAll = (all, no_symbols) => {
6
4
  let target = {};
7
- for (var name in all) {
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- }
13
- if (symbols) {
14
- __defProp(target, Symbol.toStringTag, { value: "Module" });
15
- }
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
10
  return target;
17
11
  };
18
-
19
12
  //#endregion
20
- export { __exportAll as t };
13
+ export { __exportAll as t };
package/dist/index.d.mts CHANGED
@@ -1,60 +1,122 @@
1
+ import * as _hybridly_utils0 from "@hybridly/utils";
1
2
  import { RequestData } from "@hybridly/utils";
2
- import { Axios, AxiosProgressEvent, AxiosResponse } from "axios";
3
3
 
4
+ //#region src/http/client.d.ts
5
+ interface HttpUploadProgressEvent {
6
+ loaded: number;
7
+ total?: number;
8
+ lengthComputable: boolean;
9
+ percentage: number;
10
+ }
11
+ interface HttpHeaders {
12
+ all: Readonly<Record<string, string>>;
13
+ get: (name: string) => string | undefined;
14
+ has: (name: string) => boolean;
15
+ isContentType: (matcher: string | RegExp) => boolean;
16
+ }
17
+ interface HttpRequest {
18
+ url: string;
19
+ method?: string;
20
+ headers?: Record<string, string>;
21
+ params?: RequestData;
22
+ data?: unknown;
23
+ signal?: AbortSignal;
24
+ onUploadProgress?: (event: HttpUploadProgressEvent) => void | Promise<void>;
25
+ }
26
+ interface HttpResponse<T = unknown> {
27
+ data: T;
28
+ rawData: ArrayBuffer;
29
+ status: number;
30
+ statusText: string;
31
+ headers: HttpHeaders;
32
+ request: XMLHttpRequest;
33
+ config: HttpRequest;
34
+ toBlob: (type?: string) => Blob;
35
+ }
36
+ interface HttpClient {
37
+ request: <T = unknown>(config: HttpRequest) => Promise<HttpResponse<T>>;
38
+ }
39
+ type HttpErrorCode = 'ERR_ABORTED' | 'ERR_NETWORK' | 'ECONNABORTED';
40
+ type HttpErrorKind = 'abort' | 'network' | 'timeout';
41
+ declare class HttpError extends Error {
42
+ readonly config: HttpRequest;
43
+ readonly request: XMLHttpRequest;
44
+ readonly response?: HttpResponse;
45
+ readonly code: HttpErrorCode;
46
+ readonly kind: HttpErrorKind;
47
+ readonly reason?: unknown;
48
+ readonly isHttpError = true;
49
+ constructor(message: string, options: HttpErrorOptions);
50
+ }
51
+ declare class HttpAbortError extends HttpError {
52
+ constructor(options: HttpErrorOptions);
53
+ }
54
+ declare function isHttpError(error: unknown): error is HttpError;
55
+ declare function isHttpAbortError(error: unknown): error is HttpAbortError;
56
+ declare function createXhrHttpClient(): HttpClient;
57
+ interface HttpErrorOptions {
58
+ config: HttpRequest;
59
+ request: XMLHttpRequest;
60
+ response?: HttpResponse;
61
+ code?: HttpErrorCode;
62
+ kind?: HttpErrorKind;
63
+ reason?: unknown;
64
+ }
65
+ //#endregion
4
66
  //#region src/types.d.ts
5
67
  type MaybePromise<T> = T | Promise<T>;
6
68
  //#endregion
7
69
  //#region src/plugins/hooks.d.ts
8
70
  interface RequestHooks {
9
71
  /**
10
- * Called before a navigation request is going to happen.
11
- */
12
- before: (options: HybridRequestOptions, context: InternalRouterContext) => MaybePromise<any | boolean>;
72
+ * Called before a navigation request is going to happen.
73
+ */
74
+ before: (request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any | boolean>;
13
75
  /**
14
76
  * Called before the request of a navigation is going to happen.
15
77
  */
16
- start: (context: InternalRouterContext) => MaybePromise<any>;
78
+ start: (request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
17
79
  /**
18
80
  * Called when progress on the request is being made.
19
81
  */
20
- progress: (progress: Progress, context: InternalRouterContext) => MaybePromise<any>;
82
+ progress: (progress: HttpUploadProgressEvent, request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
21
83
  /**
22
84
  * Called when data is received after a request for a navigation.
23
85
  */
24
- data: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
86
+ data: (request: PendingHybridRequest, response: HttpResponse, context: InternalRouterContext) => MaybePromise<any>;
25
87
  /**
26
88
  * Called when a request is successful and there is no error.
27
89
  */
28
- success: (payload: HybridPayload, context: InternalRouterContext) => MaybePromise<any>;
90
+ success: (payload: HybridPayload, request: PendingHybridRequest, response: HttpResponse, context: InternalRouterContext) => MaybePromise<any>;
29
91
  /**
30
- * Called when a request is successful but there were errors.
92
+ * Called when a request is successful but there were validation errors.
31
93
  */
32
- error: (errors: Errors, context: InternalRouterContext) => MaybePromise<any>;
94
+ 'validation-error': (errors: Errors, request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
33
95
  /**
34
96
  * Called when a request has been aborted.
35
97
  */
36
- abort: (context: InternalRouterContext) => MaybePromise<any>;
98
+ abort: (request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
37
99
  /**
38
100
  * Called when a response to a request is not a valid hybrid response.
39
101
  */
40
- invalid: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
102
+ invalid: (request: PendingHybridRequest, response: HttpResponse, context: InternalRouterContext) => MaybePromise<any>;
41
103
  /**
42
- * Called when an unknowne exception was triggered.
104
+ * Called when an unknown exception was triggered.
43
105
  */
44
- exception: (error: Error, context: InternalRouterContext) => MaybePromise<any>;
106
+ exception: (error: Error, request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
45
107
  /**
46
108
  * Called whenever the request failed, for any reason, in addition to other hooks.
47
109
  */
48
- fail: (context: InternalRouterContext) => MaybePromise<any>;
110
+ fail: (error: Error, request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
49
111
  /**
50
- * Called after a request has been made, even if it didn't succeed.
112
+ * Called after a response has been received, even if it didn't succeed in a navigation.
51
113
  */
52
- after: (context: InternalRouterContext) => MaybePromise<any>;
114
+ after: (request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
53
115
  }
54
116
  interface Hooks extends RequestHooks {
55
117
  /**
56
- * Called when Hybridly's context is initialized.
57
- */
118
+ * Called when Hybridly's context is initialized.
119
+ */
58
120
  initialized: (context: InternalRouterContext) => MaybePromise<any>;
59
121
  /**
60
122
  * Called after Hybridly's initial load.
@@ -92,14 +154,12 @@ interface HookOptions {
92
154
  */
93
155
  declare function registerHook<T extends keyof Hooks>(hook: T, fn: Hooks[T], options?: HookOptions): () => void;
94
156
  //#endregion
95
- //#region src/dialog/index.d.ts
96
- interface CloseDialogOptions extends HybridRequestOptions {
97
- /**
98
- * Close the dialog without a round-trip to the server.
99
- * @default false
100
- */
101
- local?: boolean;
157
+ //#region src/plugins/plugin.d.ts
158
+ interface Plugin extends Partial<Hooks> {
159
+ /** Identifier of the plugin. */
160
+ name: string;
102
161
  }
162
+ declare function definePlugin(plugin: Plugin): Plugin;
103
163
  //#endregion
104
164
  //#region src/routing/types.d.ts
105
165
  interface RoutingConfiguration {
@@ -121,15 +181,116 @@ interface GlobalRouteCollection extends RoutingConfiguration {}
121
181
  type RouteName = keyof GlobalRouteCollection['routes'];
122
182
  type RouteParameters<T extends RouteName> = Record<keyof GlobalRouteCollection['routes'][T]['bindings'], any> & Record<string, any>;
123
183
  //#endregion
184
+ //#region src/context/types.d.ts
185
+ /** Options for creating a router context. */
186
+ interface RouterContextOptions {
187
+ /** The initial payload served by the browser. */
188
+ payload: HybridPayload;
189
+ /** Adapter-specific functions. */
190
+ adapter: Adapter;
191
+ /** History state serializer. */
192
+ serializer?: Serializer;
193
+ /** List of plugins. */
194
+ plugins?: Plugin[];
195
+ /** The HTTP client instance. */
196
+ http?: HttpClient;
197
+ /** Initial routing configuration. */
198
+ routing?: RoutingConfiguration;
199
+ /** Whether to display response error modals. */
200
+ responseErrorModals?: boolean;
201
+ }
202
+ /** Router context. */
203
+ interface InternalRouterContext {
204
+ /** The current, normalized URL. */
205
+ url: string;
206
+ /** Validation errors grouped by error bag. */
207
+ validation: Record<string, Errors>;
208
+ /** The current view. */
209
+ view: View;
210
+ /** The current, optional dialog. */
211
+ dialog?: Dialog;
212
+ /** The current local asset version. */
213
+ version: string;
214
+ /** The current adapter's functions. */
215
+ adapter: ResolvedAdapter;
216
+ /** Scroll positions of the current page's DOM elements. */
217
+ scrollRegions: ScrollRegion[];
218
+ /** Arbitrary state. */
219
+ memo: Record<string, any>;
220
+ /** History state serializer. */
221
+ serializer: Serializer;
222
+ /** List of plugins. */
223
+ plugins: Plugin[];
224
+ /** Global hooks. */
225
+ hooks: Partial<Record<keyof Hooks, Array<Function>>>;
226
+ /** The HTTP client instance. */
227
+ http: HttpClient;
228
+ /** Routing configuration. */
229
+ routing?: RoutingConfiguration;
230
+ /** Whether to display response error modals. */
231
+ responseErrorModals?: boolean;
232
+ }
233
+ /** Router context. */
234
+ type RouterContext = Readonly<InternalRouterContext>;
235
+ /** Adapter-specific functions. */
236
+ interface Adapter {
237
+ /** Resolves a component from the given name. */
238
+ resolveComponent: ResolveComponent;
239
+ /** Called when the view is swapped. */
240
+ onViewSwap: SwapView;
241
+ /** Called when the context is updated. */
242
+ onContextUpdate?: (context: InternalRouterContext) => void;
243
+ /** Called when a dialog is closed. */
244
+ onDialogClose?: (context: InternalRouterContext) => void;
245
+ /** Called when Hybridly is waiting for a component to be mounted. The given callback should be executed after the view component is mounted. */
246
+ executeOnMounted: (callback: Function) => void;
247
+ }
248
+ interface ResolvedAdapter extends Adapter {
249
+ updateRoutingConfiguration: (routing?: RoutingConfiguration) => void;
250
+ }
251
+ interface ScrollRegion {
252
+ top: number;
253
+ left: number;
254
+ }
255
+ /** Provides methods to serialize the state into the history state. */
256
+ interface Serializer {
257
+ serialize: <T>(view: T) => string;
258
+ unserialize: <T>(state?: string) => T | undefined;
259
+ }
260
+ //#endregion
261
+ //#region src/context/context.d.ts
262
+ /** Gets the current context. */
263
+ declare function getRouterContext(): RouterContext;
264
+ //#endregion
265
+ //#region src/dialog/index.d.ts
266
+ interface CloseDialogOptions extends HybridRequestOptions {
267
+ /**
268
+ * Close the dialog without a round-trip to the server.
269
+ * @default false
270
+ */
271
+ local?: boolean;
272
+ }
273
+ //#endregion
274
+ //#region src/query.d.ts
275
+ type QueryArrayFormat = 'indices' | 'brackets';
276
+ type QueryValue = string | number | boolean | null | undefined | QueryValue[] | Set<QueryValue> | {
277
+ [key: string]: QueryValue;
278
+ };
279
+ interface StringifyQueryOptions {
280
+ arrayFormat?: QueryArrayFormat;
281
+ addQueryPrefix?: boolean;
282
+ }
283
+ declare function parseQueryString(query: string): Record<string, any>;
284
+ declare function stringifyQueryString(value: QueryValue, options?: StringifyQueryOptions): string;
285
+ //#endregion
124
286
  //#region src/url.d.ts
125
287
  type UrlResolvable = string | URL | Location;
126
288
  type UrlTransformable = BaseUrlTransformable | ((string: URL) => BaseUrlTransformable);
127
289
  type BaseUrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>> & {
128
- query?: any;
290
+ query?: Record<string, QueryValue>;
129
291
  trailingSlash?: boolean;
130
292
  };
131
293
  /** Normalizes the given input to an URL. */
132
-
133
294
  /**
134
295
  * Converts an input to an URL, optionally changing its properties after initialization.
135
296
  */
@@ -187,6 +348,12 @@ interface NavigationOptions {
187
348
  * @internal
188
349
  */
189
350
  updateHistoryState?: boolean;
351
+ /**
352
+ * Defines the type of view transition to use. If a string or array is given, uses it as the transition type.
353
+ *
354
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API/Using_types
355
+ */
356
+ viewTransition?: string | string[] | boolean;
190
357
  }
191
358
  interface InternalNavigationOptions extends NavigationOptions {
192
359
  /**
@@ -203,11 +370,34 @@ interface InternalNavigationOptions extends NavigationOptions {
203
370
  * @internal
204
371
  */
205
372
  hasDialog?: boolean;
373
+ /**
374
+ * Final properties object for the view.
375
+ * @internal
376
+ */
377
+ properties?: Properties;
206
378
  }
207
379
  type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
380
+ type RequestMode = 'navigation' | 'async';
381
+ type AsyncInterruptionScope = 'none' | 'all' | 'same-group';
208
382
  interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
209
383
  /** The URL to navigation. */
210
384
  url?: UrlResolvable;
385
+ /** Defines how this request should be executed. */
386
+ mode?: RequestMode;
387
+ /**
388
+ * Group identifier used to interrupt asynchronous requests.
389
+ * @see interruptAsyncOnStart
390
+ */
391
+ group?: string;
392
+ /** Whether this asynchronous request should be interrupted whenever a new navigation request starts. */
393
+ cancelOnNavigation?: boolean;
394
+ /**
395
+ * Defines which asynchronous requests should be interrupted when this request starts.
396
+ * `none` (default): does not interrupt any request
397
+ * `same-group` (default if `group` is specified): interrupts requests that share the same group identifier
398
+ * `all`: interrupts all asynchronous requests
399
+ */
400
+ interruptAsyncOnStart?: AsyncInterruptionScope;
211
401
  /** HTTP verb to use for the request. */
212
402
  method?: Method | Lowercase<Method>;
213
403
  /** Body of the request. */
@@ -216,6 +406,8 @@ interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
216
406
  only?: string | string[];
217
407
  /** Which properties not to update for this navigation. Other properties will be updated. */
218
408
  except?: string | string[];
409
+ /** Which properties to clear before the update. */
410
+ reset?: string | string[];
219
411
  /** Specific headers to add to the request. */
220
412
  headers?: Record<string, string>;
221
413
  /** The bag in which to put potential errors. */
@@ -229,27 +421,21 @@ interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
229
421
  * @see https://laravel.com/docs/master/routing#form-method-spoofing
230
422
  */
231
423
  spoof?: boolean;
232
- /**
233
- * If `false`, does not trigger the progress bar for this request.
234
- */
424
+ /** If `false`, does not trigger the progress bar for this request. */
235
425
  progress?: boolean;
426
+ /** Abort controller for this request. */
427
+ abortController?: AbortController;
236
428
  }
237
429
  interface NavigationResponse {
238
- response?: AxiosResponse;
239
- error?: {
240
- type: string;
241
- actual: Error;
242
- };
430
+ response?: HttpResponse;
431
+ error?: Error;
243
432
  }
244
433
  interface DialogRouter {
245
434
  /** Closes the current dialog. */
246
435
  close: (options?: CloseDialogOptions) => void;
247
436
  }
248
437
  interface Router {
249
- /** Aborts the currently pending navigate, if any. */
250
- abort: () => Promise<void>;
251
- /** Checks if there is an active navigate. */
252
- active: () => boolean;
438
+ abort: () => void;
253
439
  /** Makes a navigate with the given options. */
254
440
  navigate: (options: HybridRequestOptions) => Promise<NavigationResponse>;
255
441
  /** Reloads the current page. */
@@ -270,8 +456,6 @@ interface Router {
270
456
  external: (url: UrlResolvable, data?: HybridRequestOptions['data']) => void;
271
457
  /** Navigates to the given URL without a server round-trip. */
272
458
  local: (url: UrlResolvable, options: ComponentNavigationOptions) => Promise<void>;
273
- /** Preloads the given URL. The next time this URL is navigated to, it will be loaded from the cache. */
274
- preload: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<boolean>;
275
459
  /** Determines if the given route name and parameters matches the current route. */
276
460
  matches: <T extends RouteName>(name: T, parameters?: RouteParameters<T>) => boolean;
277
461
  /** Gets the current route name. Returns `undefined` is unknown. */
@@ -280,14 +464,12 @@ interface Router {
280
464
  dialog: DialogRouter;
281
465
  /** Access the history state. */
282
466
  history: {
283
- /** Remembers a value for the given route. */
284
- remember: (key: string, value: any) => void;
285
- /** Gets a remembered value. */
467
+ /** Remembers a value for the given route. */remember: (key: string, value: any) => void; /** Gets a remembered value. */
286
468
  get: <T = any>(key: string) => T | undefined;
287
469
  };
288
470
  }
289
- /** A navigation being made. */
290
- interface PendingNavigation {
471
+ /** A hybrid request being made. */
472
+ interface PendingHybridRequest {
291
473
  /** The URL to which the request is being made. */
292
474
  url: URL;
293
475
  /** Abort controller associated to this request. */
@@ -296,8 +478,18 @@ interface PendingNavigation {
296
478
  options: HybridRequestOptions;
297
479
  /** Navigation identifier. */
298
480
  id: string;
299
- /** Current status. */
300
- status: 'pending' | 'success' | 'error';
481
+ /** Whether the request has completed. */
482
+ completed: boolean;
483
+ /** Whether the request has been gracefully interrupted. */
484
+ cancelled: boolean;
485
+ /** Whether the request has been forcefully interrupted. */
486
+ interrupted: boolean;
487
+ /** Promise for the request. */
488
+ promise: Promise<NavigationResponse>;
489
+ /** Callback that resolves the request promise. */
490
+ resolve: (response: NavigationResponse) => void;
491
+ /** The view from which the request has started. */
492
+ view: View;
301
493
  }
302
494
  /** A view or dialog component. */
303
495
  interface View {
@@ -306,7 +498,9 @@ interface View {
306
498
  /** Properties to apply to the component. */
307
499
  properties: Properties;
308
500
  /** Deferred properties for this view. */
309
- deferred: string[];
501
+ deferred: Record<string, string | string[]>;
502
+ /** Properties that should be merged with the existing payload. */
503
+ mergeable: MergeableProperty[];
310
504
  }
311
505
  interface Dialog extends Required<View> {
312
506
  /** URL that is the base background view when navigating to the dialog directly. */
@@ -316,6 +510,8 @@ interface Dialog extends Required<View> {
316
510
  /** Unique identifier for this modal's lifecycle. */
317
511
  key: string;
318
512
  }
513
+ type MergeableProperty = [string, boolean, // true = prepend, false = append
514
+ string | null, string[]];
319
515
  type Property = null | string | number | boolean | Property[] | {
320
516
  [name: string]: Property;
321
517
  };
@@ -341,6 +537,8 @@ interface HybridPayload {
341
537
  view: View;
342
538
  /** An optional dialog. */
343
539
  dialog?: Dialog;
540
+ /** Validation errors grouped by error bag. */
541
+ validation: Validation;
344
542
  /** The current page URL. */
345
543
  url: string;
346
544
  /** The current asset version. */
@@ -348,101 +546,12 @@ interface HybridPayload {
348
546
  }
349
547
  interface Progress {
350
548
  /** Base event. */
351
- event: AxiosProgressEvent;
549
+ event: HttpUploadProgressEvent;
352
550
  /** Computed percentage. */
353
551
  percentage: Readonly<number>;
354
552
  }
355
- type Errors = any;
356
- //#endregion
357
- //#region src/plugins/plugin.d.ts
358
- interface Plugin extends Partial<Hooks> {
359
- /** Identifier of the plugin. */
360
- name: string;
361
- }
362
- declare function definePlugin(plugin: Plugin): Plugin;
363
- //#endregion
364
- //#region src/context/types.d.ts
365
- /** Options for creating a router context. */
366
- interface RouterContextOptions {
367
- /** The initial payload served by the browser. */
368
- payload: HybridPayload;
369
- /** Adapter-specific functions. */
370
- adapter: Adapter;
371
- /** History state serializer. */
372
- serializer?: Serializer;
373
- /** List of plugins. */
374
- plugins?: Plugin[];
375
- /** The Axios instance. */
376
- axios?: Axios;
377
- /** Initial routing configuration. */
378
- routing?: RoutingConfiguration;
379
- /** Whether to display response error modals. */
380
- responseErrorModals?: boolean;
381
- }
382
- /** Router context. */
383
- interface InternalRouterContext {
384
- /** The current, normalized URL. */
385
- url: string;
386
- /** The current view. */
387
- view: View;
388
- /** The current, optional dialog. */
389
- dialog?: Dialog;
390
- /** The current local asset version. */
391
- version: string;
392
- /** The current adapter's functions. */
393
- adapter: ResolvedAdapter;
394
- /** Scroll positions of the current page's DOM elements. */
395
- scrollRegions: ScrollRegion[];
396
- /** Arbitrary state. */
397
- memo: Record<string, any>;
398
- /** Currently pending navigation. */
399
- pendingNavigation?: PendingNavigation;
400
- /** History state serializer. */
401
- serializer: Serializer;
402
- /** List of plugins. */
403
- plugins: Plugin[];
404
- /** Global hooks. */
405
- hooks: Partial<Record<keyof Hooks, Array<Function>>>;
406
- /** The Axios instance. */
407
- axios: Axios;
408
- /** Routing configuration. */
409
- routing?: RoutingConfiguration;
410
- /** Whether to display response error modals. */
411
- responseErrorModals?: boolean;
412
- /** Cache of preload requests. */
413
- preloadCache: Map<string, AxiosResponse>;
414
- }
415
- /** Router context. */
416
- type RouterContext = Readonly<InternalRouterContext>;
417
- /** Adapter-specific functions. */
418
- interface Adapter {
419
- /** Resolves a component from the given name. */
420
- resolveComponent: ResolveComponent;
421
- /** Called when the view is swapped. */
422
- onViewSwap: SwapView;
423
- /** Called when the context is updated. */
424
- onContextUpdate?: (context: InternalRouterContext) => void;
425
- /** Called when a dialog is closed. */
426
- onDialogClose?: (context: InternalRouterContext) => void;
427
- /** Called when Hybridly is waiting for a component to be mounted. The given callback should be executed after the view component is mounted. */
428
- executeOnMounted: (callback: Function) => void;
429
- }
430
- interface ResolvedAdapter extends Adapter {
431
- updateRoutingConfiguration: (routing?: RoutingConfiguration) => void;
432
- }
433
- interface ScrollRegion {
434
- top: number;
435
- left: number;
436
- }
437
- /** Provides methods to serialize the state into the history state. */
438
- interface Serializer {
439
- serialize: <T>(view: T) => string;
440
- unserialize: <T>(state?: string) => T | undefined;
441
- }
442
- //#endregion
443
- //#region src/context/context.d.ts
444
- /** Gets the current context. */
445
- declare function getRouterContext(): RouterContext;
553
+ type Errors = Record<string, any>;
554
+ type Validation = Record<string, Errors>;
446
555
  //#endregion
447
556
  //#region src/router/router.d.ts
448
557
  /**
@@ -454,20 +563,31 @@ declare function getRouterContext(): RouterContext;
454
563
  * @example
455
564
  * router.get('/posts/edit', { post })
456
565
  */
457
- declare const router: Router;
566
+ declare const router: {
567
+ abort: () => void;
568
+ navigate: (options: HybridRequestOptions) => Promise<NavigationResponse>;
569
+ reload: (options?: HybridRequestOptions | undefined) => Promise<NavigationResponse>;
570
+ get: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
571
+ post: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
572
+ put: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
573
+ patch: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
574
+ delete: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
575
+ local: (url: UrlResolvable, options?: ComponentNavigationOptions) => Promise<void>;
576
+ external: (url: UrlResolvable, data?: _hybridly_utils0.RequestData) => void;
577
+ to: <T extends RouteName>(name: T, parameters?: Record<string, any> | undefined, options?: Omit<HybridRequestOptions, "url"> | undefined) => Promise<NavigationResponse>;
578
+ matches: <T extends RouteName>(name: T, parameters?: Record<string, any> | undefined) => boolean;
579
+ current: () => string | undefined;
580
+ dialog: {
581
+ close: (options?: CloseDialogOptions | undefined) => Promise<void | NavigationResponse>;
582
+ };
583
+ history: {
584
+ get: <T = any>(key: string) => T | undefined;
585
+ remember: (key: string, value: any) => void;
586
+ };
587
+ };
458
588
  /** Creates the hybridly router. */
459
589
  declare function createRouter(options: RouterContextOptions): Promise<InternalRouterContext>;
460
590
  //#endregion
461
- //#region src/authorization.d.ts
462
- interface Authorizable<Authorizations extends Record<string, boolean>> {
463
- authorization: Authorizations;
464
- }
465
- /**
466
- * Checks whether the given data has the authorization for the given action.
467
- * If the data object has no authorization definition corresponding to the given action, this method will return `false`.
468
- */
469
- declare function can<Authorizations extends Record<string, boolean>, Data extends Authorizable<Authorizations>, Action extends keyof Data['authorization']>(resource: Data, action: Action): Authorizations[Action];
470
- //#endregion
471
591
  //#region src/routing/route.d.ts
472
592
  /**
473
593
  * Generates a route from the given route name.
@@ -496,7 +616,6 @@ interface DynamicConfiguration {
496
616
  interface Component {
497
617
  path: string;
498
618
  identifier: string;
499
- namespace: string;
500
619
  }
501
620
  //#endregion
502
621
  //#region src/properties.d.ts
@@ -505,13 +624,14 @@ interface Component {
505
624
  */
506
625
  interface GlobalHybridlyProperties {}
507
626
  declare namespace constants_d_exports {
508
- export { DIALOG_KEY_HEADER, DIALOG_REDIRECT_HEADER, ERROR_BAG_HEADER, EXCEPT_DATA_HEADER, EXTERNAL_NAVIGATION_HEADER, EXTERNAL_NAVIGATION_TARGET_HEADER, HYBRIDLY_HEADER, ONLY_DATA_HEADER, PARTIAL_COMPONENT_HEADER, SCROLL_REGION_ATTRIBUTE, STORAGE_EXTERNAL_KEY, VERSION_HEADER };
627
+ export { DIALOG_KEY_HEADER, DIALOG_REDIRECT_HEADER, ERROR_BAG_HEADER, EXCEPT_DATA_HEADER, EXTERNAL_NAVIGATION_HEADER, EXTERNAL_NAVIGATION_TARGET_HEADER, HYBRIDLY_HEADER, ONLY_DATA_HEADER, PARTIAL_COMPONENT_HEADER, RESET_HEADER, SCROLL_REGION_ATTRIBUTE, STORAGE_EXTERNAL_KEY, VERSION_HEADER };
509
628
  }
510
629
  declare const STORAGE_EXTERNAL_KEY = "hybridly:external";
511
630
  declare const HYBRIDLY_HEADER = "x-hybrid";
512
631
  declare const EXTERNAL_NAVIGATION_HEADER = "x-hybrid-external";
513
632
  declare const EXTERNAL_NAVIGATION_TARGET_HEADER = "x-hybrid-external-target";
514
633
  declare const PARTIAL_COMPONENT_HEADER = "x-hybrid-partial-component";
634
+ declare const RESET_HEADER = "x-hybrid-reset";
515
635
  declare const ONLY_DATA_HEADER = "x-hybrid-only-data";
516
636
  declare const DIALOG_KEY_HEADER = "x-hybrid-dialog-key";
517
637
  declare const DIALOG_REDIRECT_HEADER = "x-hybrid-dialog-redirect";
@@ -520,4 +640,4 @@ declare const VERSION_HEADER = "x-hybrid-version";
520
640
  declare const ERROR_BAG_HEADER = "x-hybrid-error-bag";
521
641
  declare const SCROLL_REGION_ATTRIBUTE = "scroll-region";
522
642
  //#endregion
523
- export { type Authorizable, type DynamicConfiguration, type GlobalHybridlyProperties, type GlobalRouteCollection, type HybridPayload, type HybridRequestOptions, MaybePromise, type Method, type NavigationResponse, type Plugin, type Progress, type ResolveComponent, type RouteDefinition, type RouteName, type RouteParameters, type Router, type RouterContext, type RouterContextOptions, type RoutingConfiguration, type UrlResolvable, can, constants_d_exports as constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls };
643
+ export { type AsyncInterruptionScope, type DynamicConfiguration, type Errors, type GlobalHybridlyProperties, type GlobalRouteCollection, type HttpClient, type HttpErrorCode, type HttpErrorKind, type HttpRequest, type HttpResponse, type HttpUploadProgressEvent, type HybridPayload, type HybridRequestOptions, MaybePromise, type Method, type NavigationResponse, type PendingHybridRequest, type Plugin, type Progress, type QueryArrayFormat, type RequestMode, type ResolveComponent, type RouteDefinition, type RouteName, type RouteParameters, type Router, type RouterContext, type RouterContextOptions, type RoutingConfiguration, type StringifyQueryOptions, type UrlResolvable, type Validation, constants_d_exports as constants, createRouter, createXhrHttpClient, definePlugin, getRouterContext, isHttpAbortError, isHttpError, makeUrl, parseQueryString, registerHook, route, router, sameUrls, stringifyQueryString };