@hybridly/core 0.8.3 → 0.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/chunk.mjs +20 -0
- package/dist/index.d.mts +391 -411
- package/dist/index.mjs +1045 -948
- package/package.json +11 -13
- package/LICENSE +0 -19
- package/dist/index.cjs +0 -1108
- package/dist/index.d.cts +0 -543
- package/dist/index.d.ts +0 -543
- package/properties.d.ts +0 -6
package/dist/index.d.cts
DELETED
|
@@ -1,543 +0,0 @@
|
|
|
1
|
-
import { RequestData } from '@hybridly/utils';
|
|
2
|
-
import { AxiosResponse, AxiosProgressEvent, Axios } from 'axios';
|
|
3
|
-
|
|
4
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
-
|
|
6
|
-
interface RequestHooks {
|
|
7
|
-
/**
|
|
8
|
-
* Called before a navigation request is going to happen.
|
|
9
|
-
*/
|
|
10
|
-
before: (options: HybridRequestOptions, context: InternalRouterContext) => MaybePromise<any | boolean>;
|
|
11
|
-
/**
|
|
12
|
-
* Called before the request of a navigation is going to happen.
|
|
13
|
-
*/
|
|
14
|
-
start: (context: InternalRouterContext) => MaybePromise<any>;
|
|
15
|
-
/**
|
|
16
|
-
* Called when progress on the request is being made.
|
|
17
|
-
*/
|
|
18
|
-
progress: (progress: Progress, context: InternalRouterContext) => MaybePromise<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Called when data is received after a request for a navigation.
|
|
21
|
-
*/
|
|
22
|
-
data: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
|
|
23
|
-
/**
|
|
24
|
-
* Called when a request is successful and there is no error.
|
|
25
|
-
*/
|
|
26
|
-
success: (payload: HybridPayload, context: InternalRouterContext) => MaybePromise<any>;
|
|
27
|
-
/**
|
|
28
|
-
* Called when a request is successful but there were errors.
|
|
29
|
-
*/
|
|
30
|
-
error: (errors: Errors, context: InternalRouterContext) => MaybePromise<any>;
|
|
31
|
-
/**
|
|
32
|
-
* Called when a request has been aborted.
|
|
33
|
-
*/
|
|
34
|
-
abort: (context: InternalRouterContext) => MaybePromise<any>;
|
|
35
|
-
/**
|
|
36
|
-
* Called when a response to a request is not a valid hybrid response.
|
|
37
|
-
*/
|
|
38
|
-
invalid: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
|
|
39
|
-
/**
|
|
40
|
-
* Called when an unknowne exception was triggered.
|
|
41
|
-
*/
|
|
42
|
-
exception: (error: Error, context: InternalRouterContext) => MaybePromise<any>;
|
|
43
|
-
/**
|
|
44
|
-
* Called whenever the request failed, for any reason, in addition to other hooks.
|
|
45
|
-
*/
|
|
46
|
-
fail: (context: InternalRouterContext) => MaybePromise<any>;
|
|
47
|
-
/**
|
|
48
|
-
* Called after a request has been made, even if it didn't succeed.
|
|
49
|
-
*/
|
|
50
|
-
after: (context: InternalRouterContext) => MaybePromise<any>;
|
|
51
|
-
}
|
|
52
|
-
interface Hooks extends RequestHooks {
|
|
53
|
-
/**
|
|
54
|
-
/////////////////////// * Called when Hybridly's context is initialized.
|
|
55
|
-
///////////////////////
|
|
56
|
-
///////////////////////
|
|
57
|
-
///////////////////////
|
|
58
|
-
///////////////////////
|
|
59
|
-
///////////////////////
|
|
60
|
-
///////////////////////
|
|
61
|
-
///////////////////////
|
|
62
|
-
///////////////////////
|
|
63
|
-
///////////////////////
|
|
64
|
-
///////////////////////
|
|
65
|
-
*/
|
|
66
|
-
initialized: (context: InternalRouterContext) => MaybePromise<any>;
|
|
67
|
-
/**
|
|
68
|
-
* Called after Hybridly's initial load.
|
|
69
|
-
*/
|
|
70
|
-
ready: (context: InternalRouterContext) => MaybePromise<any>;
|
|
71
|
-
/**
|
|
72
|
-
* Called when a back-forward navigation occurs.
|
|
73
|
-
*/
|
|
74
|
-
backForward: (state: any, context: InternalRouterContext) => MaybePromise<any>;
|
|
75
|
-
/**
|
|
76
|
-
* Called when a component navigation is being made.
|
|
77
|
-
*/
|
|
78
|
-
navigating: (options: InternalNavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
|
|
79
|
-
/**
|
|
80
|
-
* Called when a component has been navigated to.
|
|
81
|
-
*/
|
|
82
|
-
navigated: (options: InternalNavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
|
|
83
|
-
/**
|
|
84
|
-
* Called when a component has been navigated to and was mounted by the adapter.
|
|
85
|
-
*/
|
|
86
|
-
mounted: (options: InternalNavigationOptions & MountedHookOptions, context: InternalRouterContext) => MaybePromise<any>;
|
|
87
|
-
}
|
|
88
|
-
interface MountedHookOptions {
|
|
89
|
-
/**
|
|
90
|
-
* Whether the component being mounted is a dialog.
|
|
91
|
-
*/
|
|
92
|
-
isDialog: boolean;
|
|
93
|
-
}
|
|
94
|
-
interface HookOptions {
|
|
95
|
-
/** Executes the hook only once. */
|
|
96
|
-
once?: boolean;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Registers a global hook.
|
|
100
|
-
*/
|
|
101
|
-
declare function registerHook<T extends keyof Hooks>(hook: T, fn: Hooks[T], options?: HookOptions): () => void;
|
|
102
|
-
|
|
103
|
-
interface CloseDialogOptions extends HybridRequestOptions {
|
|
104
|
-
/**
|
|
105
|
-
* Close the dialog without a round-trip to the server.
|
|
106
|
-
* @default false
|
|
107
|
-
*/
|
|
108
|
-
local?: boolean;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
interface RoutingConfiguration {
|
|
112
|
-
url: string;
|
|
113
|
-
port?: number;
|
|
114
|
-
defaults: Record<string, any>;
|
|
115
|
-
routes: Record<string, RouteDefinition>;
|
|
116
|
-
}
|
|
117
|
-
interface RouteDefinition {
|
|
118
|
-
uri: string;
|
|
119
|
-
method: Method[];
|
|
120
|
-
bindings: Record<string, string>;
|
|
121
|
-
domain?: string;
|
|
122
|
-
wheres?: Record<string, string>;
|
|
123
|
-
name: string;
|
|
124
|
-
}
|
|
125
|
-
interface GlobalRouteCollection extends RoutingConfiguration {
|
|
126
|
-
}
|
|
127
|
-
type RouteName = keyof GlobalRouteCollection['routes'];
|
|
128
|
-
type RouteParameters<T extends RouteName> = Record<keyof GlobalRouteCollection['routes'][T]['bindings'], any> & Record<string, any>;
|
|
129
|
-
|
|
130
|
-
type UrlResolvable = string | URL | Location;
|
|
131
|
-
type UrlTransformable = BaseUrlTransformable | ((string: URL) => BaseUrlTransformable);
|
|
132
|
-
type BaseUrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>> & {
|
|
133
|
-
query?: any;
|
|
134
|
-
trailingSlash?: boolean;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Converts an input to an URL, optionally changing its properties after initialization.
|
|
138
|
-
*/
|
|
139
|
-
declare function makeUrl(href: UrlResolvable, transformations?: UrlTransformable): URL;
|
|
140
|
-
/**
|
|
141
|
-
* Checks if the given URLs have the same origin and path.
|
|
142
|
-
*/
|
|
143
|
-
declare function sameUrls(...hrefs: UrlResolvable[]): boolean;
|
|
144
|
-
|
|
145
|
-
type ConditionalNavigationOption<T extends boolean | string> = T | ((payload: NavigationOptions) => T);
|
|
146
|
-
interface ComponentNavigationOptions {
|
|
147
|
-
/** Dialog data. */
|
|
148
|
-
dialog?: Dialog | false;
|
|
149
|
-
/** Name of the component to use. */
|
|
150
|
-
component?: string;
|
|
151
|
-
/** Properties to apply to the component. */
|
|
152
|
-
properties?: Properties;
|
|
153
|
-
/**
|
|
154
|
-
* Whether to replace the current history state instead of adding
|
|
155
|
-
* one. This affects the browser's "back" and "forward" features.
|
|
156
|
-
*/
|
|
157
|
-
replace?: ConditionalNavigationOption<boolean>;
|
|
158
|
-
/** Whether to preserve the current scrollbar position. */
|
|
159
|
-
preserveScroll?: ConditionalNavigationOption<boolean>;
|
|
160
|
-
/** Whether to preserve the current view component state. */
|
|
161
|
-
preserveState?: ConditionalNavigationOption<boolean>;
|
|
162
|
-
}
|
|
163
|
-
interface NavigationOptions {
|
|
164
|
-
/** View to navigate to. */
|
|
165
|
-
payload?: HybridPayload;
|
|
166
|
-
/**
|
|
167
|
-
* Whether to replace the current history state instead of adding
|
|
168
|
-
* one. This affects the browser's "back" and "forward" features.
|
|
169
|
-
*/
|
|
170
|
-
replace?: ConditionalNavigationOption<boolean>;
|
|
171
|
-
/** Whether to preserve the scrollbars positions on the view. */
|
|
172
|
-
preserveScroll?: ConditionalNavigationOption<boolean>;
|
|
173
|
-
/** Whether to preserve the current view component's state. */
|
|
174
|
-
preserveState?: ConditionalNavigationOption<boolean>;
|
|
175
|
-
/** Whether to preserve the current URL. */
|
|
176
|
-
preserveUrl?: ConditionalNavigationOption<boolean>;
|
|
177
|
-
/**
|
|
178
|
-
* Properties of the given URL to override.
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* router.get('/login?redirect=/', {
|
|
182
|
-
* transformUrl: { search: '' }
|
|
183
|
-
* }
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
transformUrl?: UrlTransformable;
|
|
187
|
-
/**
|
|
188
|
-
* Defines whether the history state should be updated.
|
|
189
|
-
* @internal
|
|
190
|
-
*/
|
|
191
|
-
updateHistoryState?: boolean;
|
|
192
|
-
}
|
|
193
|
-
interface InternalNavigationOptions extends NavigationOptions {
|
|
194
|
-
/**
|
|
195
|
-
* Defines the kind of navigation being performed.
|
|
196
|
-
* - initial: the initial load's navigation
|
|
197
|
-
* - server: a navigation initiated by a server round-trip
|
|
198
|
-
* - local: a navigation initiated by `router.local`
|
|
199
|
-
* - back-forward: a navigation initiated by the browser's `popstate` event
|
|
200
|
-
* @internal
|
|
201
|
-
*/
|
|
202
|
-
type: 'initial' | 'local' | 'back-forward' | 'server';
|
|
203
|
-
/**
|
|
204
|
-
* Defines whether this navigation opens a dialog.
|
|
205
|
-
* @internal
|
|
206
|
-
*/
|
|
207
|
-
hasDialog?: boolean;
|
|
208
|
-
}
|
|
209
|
-
type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
210
|
-
interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
|
|
211
|
-
/** The URL to navigation. */
|
|
212
|
-
url?: UrlResolvable;
|
|
213
|
-
/** HTTP verb to use for the request. */
|
|
214
|
-
method?: Method | Lowercase<Method>;
|
|
215
|
-
/** Body of the request. */
|
|
216
|
-
data?: RequestData;
|
|
217
|
-
/** Which properties to update for this navigation. Other properties will be ignored. */
|
|
218
|
-
only?: string | string[];
|
|
219
|
-
/** Which properties not to update for this navigation. Other properties will be updated. */
|
|
220
|
-
except?: string | string[];
|
|
221
|
-
/** Specific headers to add to the request. */
|
|
222
|
-
headers?: Record<string, string>;
|
|
223
|
-
/** The bag in which to put potential errors. */
|
|
224
|
-
errorBag?: string;
|
|
225
|
-
/** Hooks for this navigation. */
|
|
226
|
-
hooks?: Partial<RequestHooks>;
|
|
227
|
-
/** If `true`, force the usage of a `FormData` object. */
|
|
228
|
-
useFormData?: boolean;
|
|
229
|
-
/**
|
|
230
|
-
* If `false`, disable automatic form spoofing.
|
|
231
|
-
* @see https://laravel.com/docs/master/routing#form-method-spoofing
|
|
232
|
-
*/
|
|
233
|
-
spoof?: boolean;
|
|
234
|
-
/**
|
|
235
|
-
* If `false`, does not trigger the progress bar for this request.
|
|
236
|
-
*/
|
|
237
|
-
progress?: boolean;
|
|
238
|
-
}
|
|
239
|
-
interface NavigationResponse {
|
|
240
|
-
response?: AxiosResponse;
|
|
241
|
-
error?: {
|
|
242
|
-
type: string;
|
|
243
|
-
actual: Error;
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
interface DialogRouter {
|
|
247
|
-
/** Closes the current dialog. */
|
|
248
|
-
close: (options?: CloseDialogOptions) => void;
|
|
249
|
-
}
|
|
250
|
-
interface Router {
|
|
251
|
-
/** Aborts the currently pending navigate, if any. */
|
|
252
|
-
abort: () => Promise<void>;
|
|
253
|
-
/** Checks if there is an active navigate. */
|
|
254
|
-
active: () => boolean;
|
|
255
|
-
/** Makes a navigate with the given options. */
|
|
256
|
-
navigate: (options: HybridRequestOptions) => Promise<NavigationResponse>;
|
|
257
|
-
/** Reloads the current page. */
|
|
258
|
-
reload: (options?: HybridRequestOptions) => Promise<NavigationResponse>;
|
|
259
|
-
/** Makes a request to given named route. The HTTP verb is determined automatically but can be overriden. */
|
|
260
|
-
to: <T extends RouteName>(name: T, parameters?: RouteParameters<T>, options?: Omit<HybridRequestOptions, 'url'>) => Promise<NavigationResponse>;
|
|
261
|
-
/** Makes a GET request to the given URL. */
|
|
262
|
-
get: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>;
|
|
263
|
-
/** Makes a POST request to the given URL. */
|
|
264
|
-
post: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>;
|
|
265
|
-
/** Makes a PUT request to the given URL. */
|
|
266
|
-
put: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>;
|
|
267
|
-
/** Makes a PATCH request to the given URL. */
|
|
268
|
-
patch: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>;
|
|
269
|
-
/** Makes a DELETE request to the given URL. */
|
|
270
|
-
delete: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>;
|
|
271
|
-
/** Navigates to the given external URL. Convenience method using `document.location.href`. */
|
|
272
|
-
external: (url: UrlResolvable, data?: HybridRequestOptions['data']) => void;
|
|
273
|
-
/** Navigates to the given URL without a server round-trip. */
|
|
274
|
-
local: (url: UrlResolvable, options: ComponentNavigationOptions) => Promise<void>;
|
|
275
|
-
/** Preloads the given URL. The next time this URL is navigated to, it will be loaded from the cache. */
|
|
276
|
-
preload: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<boolean>;
|
|
277
|
-
/** Determines if the given route name and parameters matches the current route. */
|
|
278
|
-
matches: <T extends RouteName>(name: T, parameters?: RouteParameters<T>) => boolean;
|
|
279
|
-
/** Gets the current route name. Returns `undefined` is unknown. */
|
|
280
|
-
current: () => RouteName | undefined;
|
|
281
|
-
/** Access the dialog router. */
|
|
282
|
-
dialog: DialogRouter;
|
|
283
|
-
/** Access the history state. */
|
|
284
|
-
history: {
|
|
285
|
-
/** Remembers a value for the given route. */
|
|
286
|
-
remember: (key: string, value: any) => void;
|
|
287
|
-
/** Gets a remembered value. */
|
|
288
|
-
get: <T = any>(key: string) => T | undefined;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
/** A navigation being made. */
|
|
292
|
-
interface PendingNavigation {
|
|
293
|
-
/** The URL to which the request is being made. */
|
|
294
|
-
url: URL;
|
|
295
|
-
/** Abort controller associated to this request. */
|
|
296
|
-
controller: AbortController;
|
|
297
|
-
/** Options for the associated hybrid request. */
|
|
298
|
-
options: HybridRequestOptions;
|
|
299
|
-
/** Navigation identifier. */
|
|
300
|
-
id: string;
|
|
301
|
-
/** Current status. */
|
|
302
|
-
status: 'pending' | 'success' | 'error';
|
|
303
|
-
}
|
|
304
|
-
/** A view or dialog component. */
|
|
305
|
-
interface View {
|
|
306
|
-
/** Name of the component to use. */
|
|
307
|
-
component?: string;
|
|
308
|
-
/** Properties to apply to the component. */
|
|
309
|
-
properties: Properties;
|
|
310
|
-
/** Deferred properties for this view. */
|
|
311
|
-
deferred: string[];
|
|
312
|
-
}
|
|
313
|
-
interface Dialog extends Required<View> {
|
|
314
|
-
/** URL that is the base background view when navigating to the dialog directly. */
|
|
315
|
-
baseUrl: string;
|
|
316
|
-
/** URL to which the dialog should redirect when closed. */
|
|
317
|
-
redirectUrl: string;
|
|
318
|
-
/** Unique identifier for this modal's lifecycle. */
|
|
319
|
-
key: string;
|
|
320
|
-
}
|
|
321
|
-
type Property = null | string | number | boolean | Property[] | {
|
|
322
|
-
[name: string]: Property;
|
|
323
|
-
};
|
|
324
|
-
type Properties = Record<string | number, Property>;
|
|
325
|
-
interface SwapOptions<T> {
|
|
326
|
-
/** The new component. */
|
|
327
|
-
component: T;
|
|
328
|
-
/** The new properties. */
|
|
329
|
-
properties?: any;
|
|
330
|
-
/** Whether to preserve the state of the component. */
|
|
331
|
-
preserveState?: boolean;
|
|
332
|
-
/** Current dialog. */
|
|
333
|
-
dialog?: Dialog;
|
|
334
|
-
/** On mounted callback. */
|
|
335
|
-
onMounted?: (options: MountedHookOptions) => void;
|
|
336
|
-
}
|
|
337
|
-
type ViewComponent = any;
|
|
338
|
-
type ResolveComponent = (name: string) => Promise<ViewComponent>;
|
|
339
|
-
type SwapView = (options: SwapOptions<ViewComponent>) => Promise<void>;
|
|
340
|
-
/** The payload of a navigation request from the server. */
|
|
341
|
-
interface HybridPayload {
|
|
342
|
-
/** The view to use in this request. */
|
|
343
|
-
view: View;
|
|
344
|
-
/** An optional dialog. */
|
|
345
|
-
dialog?: Dialog;
|
|
346
|
-
/** The current page URL. */
|
|
347
|
-
url: string;
|
|
348
|
-
/** The current asset version. */
|
|
349
|
-
version: string;
|
|
350
|
-
}
|
|
351
|
-
interface Progress {
|
|
352
|
-
/** Base event. */
|
|
353
|
-
event: AxiosProgressEvent;
|
|
354
|
-
/** Computed percentage. */
|
|
355
|
-
percentage: Readonly<number>;
|
|
356
|
-
}
|
|
357
|
-
type Errors = any;
|
|
358
|
-
|
|
359
|
-
interface Plugin extends Partial<Hooks> {
|
|
360
|
-
/** Identifier of the plugin. */
|
|
361
|
-
name: string;
|
|
362
|
-
}
|
|
363
|
-
declare function definePlugin(plugin: Plugin): Plugin;
|
|
364
|
-
|
|
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
|
-
|
|
443
|
-
/** Gets the current context. */
|
|
444
|
-
declare function getRouterContext(): RouterContext;
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* The hybridly router.
|
|
448
|
-
* This is the core function that you can use to navigate in
|
|
449
|
-
* your application. Make sure the routes you call return a
|
|
450
|
-
* hybrid response, otherwise you need to call `external`.
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* router.get('/posts/edit', { post })
|
|
454
|
-
*/
|
|
455
|
-
declare const router: Router;
|
|
456
|
-
/** Creates the hybridly router. */
|
|
457
|
-
declare function createRouter(options: RouterContextOptions): Promise<InternalRouterContext>;
|
|
458
|
-
|
|
459
|
-
interface Authorizable<Authorizations extends Record<string, boolean>> {
|
|
460
|
-
authorization: Authorizations;
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Checks whether the given data has the authorization for the given action.
|
|
464
|
-
* If the data object has no authorization definition corresponding to the given action, this method will return `false`.
|
|
465
|
-
*/
|
|
466
|
-
declare function can<Authorizations extends Record<string, boolean>, Data extends Authorizable<Authorizations>, Action extends keyof Data['authorization']>(resource: Data, action: Action): Authorizations[Action];
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Generates a route from the given route name.
|
|
470
|
-
*/
|
|
471
|
-
declare function route<T extends RouteName>(name: T, parameters?: RouteParameters<T>, absolute?: boolean): string;
|
|
472
|
-
|
|
473
|
-
interface DynamicConfiguration {
|
|
474
|
-
versions: {
|
|
475
|
-
composer: string;
|
|
476
|
-
npm: string;
|
|
477
|
-
latest: string;
|
|
478
|
-
is_latest: boolean;
|
|
479
|
-
};
|
|
480
|
-
architecture: {
|
|
481
|
-
root_directory: string;
|
|
482
|
-
components_directory: string;
|
|
483
|
-
application_main_path: string;
|
|
484
|
-
};
|
|
485
|
-
components: {
|
|
486
|
-
eager?: boolean;
|
|
487
|
-
files: string[];
|
|
488
|
-
views: Component[];
|
|
489
|
-
layouts: Component[];
|
|
490
|
-
components: Component[];
|
|
491
|
-
};
|
|
492
|
-
routing: RoutingConfiguration;
|
|
493
|
-
}
|
|
494
|
-
interface Component {
|
|
495
|
-
path: string;
|
|
496
|
-
identifier: string;
|
|
497
|
-
namespace: string;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
declare const STORAGE_EXTERNAL_KEY = "hybridly:external";
|
|
501
|
-
declare const HYBRIDLY_HEADER = "x-hybrid";
|
|
502
|
-
declare const EXTERNAL_NAVIGATION_HEADER = "x-hybrid-external";
|
|
503
|
-
declare const EXTERNAL_NAVIGATION_TARGET_HEADER = "x-hybrid-external-target";
|
|
504
|
-
declare const PARTIAL_COMPONENT_HEADER = "x-hybrid-partial-component";
|
|
505
|
-
declare const ONLY_DATA_HEADER = "x-hybrid-only-data";
|
|
506
|
-
declare const DIALOG_KEY_HEADER = "x-hybrid-dialog-key";
|
|
507
|
-
declare const DIALOG_REDIRECT_HEADER = "x-hybrid-dialog-redirect";
|
|
508
|
-
declare const EXCEPT_DATA_HEADER = "x-hybrid-except-data";
|
|
509
|
-
declare const VERSION_HEADER = "x-hybrid-version";
|
|
510
|
-
declare const ERROR_BAG_HEADER = "x-hybrid-error-bag";
|
|
511
|
-
declare const SCROLL_REGION_ATTRIBUTE = "scroll-region";
|
|
512
|
-
|
|
513
|
-
declare const constants_DIALOG_KEY_HEADER: typeof DIALOG_KEY_HEADER;
|
|
514
|
-
declare const constants_DIALOG_REDIRECT_HEADER: typeof DIALOG_REDIRECT_HEADER;
|
|
515
|
-
declare const constants_ERROR_BAG_HEADER: typeof ERROR_BAG_HEADER;
|
|
516
|
-
declare const constants_EXCEPT_DATA_HEADER: typeof EXCEPT_DATA_HEADER;
|
|
517
|
-
declare const constants_EXTERNAL_NAVIGATION_HEADER: typeof EXTERNAL_NAVIGATION_HEADER;
|
|
518
|
-
declare const constants_EXTERNAL_NAVIGATION_TARGET_HEADER: typeof EXTERNAL_NAVIGATION_TARGET_HEADER;
|
|
519
|
-
declare const constants_HYBRIDLY_HEADER: typeof HYBRIDLY_HEADER;
|
|
520
|
-
declare const constants_ONLY_DATA_HEADER: typeof ONLY_DATA_HEADER;
|
|
521
|
-
declare const constants_PARTIAL_COMPONENT_HEADER: typeof PARTIAL_COMPONENT_HEADER;
|
|
522
|
-
declare const constants_SCROLL_REGION_ATTRIBUTE: typeof SCROLL_REGION_ATTRIBUTE;
|
|
523
|
-
declare const constants_STORAGE_EXTERNAL_KEY: typeof STORAGE_EXTERNAL_KEY;
|
|
524
|
-
declare const constants_VERSION_HEADER: typeof VERSION_HEADER;
|
|
525
|
-
declare namespace constants {
|
|
526
|
-
export {
|
|
527
|
-
constants_DIALOG_KEY_HEADER as DIALOG_KEY_HEADER,
|
|
528
|
-
constants_DIALOG_REDIRECT_HEADER as DIALOG_REDIRECT_HEADER,
|
|
529
|
-
constants_ERROR_BAG_HEADER as ERROR_BAG_HEADER,
|
|
530
|
-
constants_EXCEPT_DATA_HEADER as EXCEPT_DATA_HEADER,
|
|
531
|
-
constants_EXTERNAL_NAVIGATION_HEADER as EXTERNAL_NAVIGATION_HEADER,
|
|
532
|
-
constants_EXTERNAL_NAVIGATION_TARGET_HEADER as EXTERNAL_NAVIGATION_TARGET_HEADER,
|
|
533
|
-
constants_HYBRIDLY_HEADER as HYBRIDLY_HEADER,
|
|
534
|
-
constants_ONLY_DATA_HEADER as ONLY_DATA_HEADER,
|
|
535
|
-
constants_PARTIAL_COMPONENT_HEADER as PARTIAL_COMPONENT_HEADER,
|
|
536
|
-
constants_SCROLL_REGION_ATTRIBUTE as SCROLL_REGION_ATTRIBUTE,
|
|
537
|
-
constants_STORAGE_EXTERNAL_KEY as STORAGE_EXTERNAL_KEY,
|
|
538
|
-
constants_VERSION_HEADER as VERSION_HEADER,
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export { can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls };
|
|
543
|
-
export type { Authorizable, DynamicConfiguration, GlobalRouteCollection, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, RouteDefinition, RouteName, RouteParameters, Router, RouterContext, RouterContextOptions, RoutingConfiguration, UrlResolvable };
|