swup 4.2.0 → 4.3.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.
Files changed (66) hide show
  1. package/dist/Swup.cjs +1 -1
  2. package/dist/Swup.cjs.map +1 -1
  3. package/dist/Swup.modern.js +1 -1
  4. package/dist/Swup.modern.js.map +1 -1
  5. package/dist/Swup.module.js +1 -1
  6. package/dist/Swup.module.js.map +1 -1
  7. package/dist/Swup.umd.js +1 -1
  8. package/dist/Swup.umd.js.map +1 -1
  9. package/dist/types/Swup.d.ts +119 -119
  10. package/dist/types/__test__/index.test.d.ts +1 -1
  11. package/dist/types/config/version.d.ts +5 -5
  12. package/dist/types/helpers/Location.d.ts +24 -24
  13. package/dist/types/helpers/__test__/matchPath.test.d.ts +1 -1
  14. package/dist/types/helpers/classify.d.ts +2 -2
  15. package/dist/types/helpers/createHistoryRecord.d.ts +9 -2
  16. package/dist/types/helpers/delegateEvent.d.ts +7 -7
  17. package/dist/types/helpers/getCurrentUrl.d.ts +4 -4
  18. package/dist/types/helpers/matchPath.d.ts +4 -4
  19. package/dist/types/helpers/updateHistoryRecord.d.ts +2 -2
  20. package/dist/types/helpers.d.ts +7 -7
  21. package/dist/types/index.d.ts +14 -14
  22. package/dist/types/modules/Cache.d.ts +34 -34
  23. package/dist/types/modules/Classes.d.ts +13 -13
  24. package/dist/types/modules/Hooks.d.ts +268 -250
  25. package/dist/types/modules/Visit.d.ts +80 -77
  26. package/dist/types/modules/__test__/cache.test.d.ts +1 -1
  27. package/dist/types/modules/__test__/{delegateEvent.d.ts → delegateEvent.test.d.ts} +1 -1
  28. package/dist/types/modules/__test__/hooks.test.d.ts +1 -1
  29. package/dist/types/modules/__test__/plugins.test.d.ts +1 -1
  30. package/dist/types/modules/__test__/replaceContent.test.d.ts +1 -1
  31. package/dist/types/modules/animatePageIn.d.ts +6 -6
  32. package/dist/types/modules/animatePageOut.d.ts +6 -6
  33. package/dist/types/modules/awaitAnimations.d.ts +19 -19
  34. package/dist/types/modules/fetchPage.d.ts +27 -29
  35. package/dist/types/modules/getAnchorElement.d.ts +9 -9
  36. package/dist/types/modules/navigate.d.ts +41 -35
  37. package/dist/types/modules/plugins.d.ts +26 -26
  38. package/dist/types/modules/renderPage.d.ts +7 -7
  39. package/dist/types/modules/replaceContent.d.ts +13 -13
  40. package/dist/types/modules/resolveUrl.d.ts +14 -14
  41. package/dist/types/modules/scrollToContent.d.ts +6 -6
  42. package/dist/types/utils/index.d.ts +20 -20
  43. package/dist/types/utils.d.ts +1 -1
  44. package/package.json +9 -3
  45. package/src/Swup.ts +26 -17
  46. package/src/config/version.ts +1 -2
  47. package/src/helpers/createHistoryRecord.ts +9 -1
  48. package/src/helpers/matchPath.ts +1 -1
  49. package/src/helpers/updateHistoryRecord.ts +4 -2
  50. package/src/modules/Cache.ts +2 -2
  51. package/src/modules/Classes.ts +1 -1
  52. package/src/modules/Hooks.ts +91 -39
  53. package/src/modules/Visit.ts +19 -21
  54. package/src/modules/__test__/cache.test.ts +3 -3
  55. package/src/modules/__test__/hooks.test.ts +12 -13
  56. package/src/modules/animatePageIn.ts +1 -1
  57. package/src/modules/animatePageOut.ts +2 -2
  58. package/src/modules/awaitAnimations.ts +1 -1
  59. package/src/modules/fetchPage.ts +7 -5
  60. package/src/modules/navigate.ts +23 -4
  61. package/src/modules/plugins.ts +3 -3
  62. package/src/modules/renderPage.ts +1 -5
  63. package/src/modules/replaceContent.ts +13 -0
  64. package/src/modules/scrollToContent.ts +1 -1
  65. package/src/utils/index.ts +5 -4
  66. /package/src/modules/__test__/{delegateEvent.ts → delegateEvent.test.ts} +0 -0
@@ -1,250 +1,268 @@
1
- import { DelegateEvent } from 'delegate-it';
2
- import Swup from '../Swup.js';
3
- import { Visit } from './Visit.js';
4
- import { FetchOptions, PageData } from './fetchPage.js';
5
- export interface HookDefinitions {
6
- 'animation:out:start': undefined;
7
- 'animation:out:await': {
8
- skip: boolean;
9
- };
10
- 'animation:out:end': undefined;
11
- 'animation:in:start': undefined;
12
- 'animation:in:await': {
13
- skip: boolean;
14
- };
15
- 'animation:in:end': undefined;
16
- 'animation:skip': undefined;
17
- 'cache:clear': undefined;
18
- 'cache:set': {
19
- page: PageData;
20
- };
21
- 'content:replace': {
22
- page: PageData;
23
- };
24
- 'content:scroll': undefined;
25
- 'enable': undefined;
26
- 'disable': undefined;
27
- 'fetch:request': {
28
- url: string;
29
- options: FetchOptions;
30
- };
31
- 'fetch:error': {
32
- url: string;
33
- status: number;
34
- response: Response;
35
- };
36
- 'history:popstate': {
37
- event: PopStateEvent;
38
- };
39
- 'link:click': {
40
- el: HTMLAnchorElement;
41
- event: DelegateEvent<MouseEvent>;
42
- };
43
- 'link:self': undefined;
44
- 'link:anchor': {
45
- hash: string;
46
- };
47
- 'link:newtab': {
48
- href: string;
49
- };
50
- 'page:load': {
51
- page?: PageData;
52
- cache?: boolean;
53
- options: FetchOptions;
54
- };
55
- 'page:view': {
56
- url: string;
57
- title: string;
58
- };
59
- 'scroll:top': {
60
- options: ScrollIntoViewOptions;
61
- };
62
- 'scroll:anchor': {
63
- hash: string;
64
- options: ScrollIntoViewOptions;
65
- };
66
- 'visit:start': undefined;
67
- 'visit:end': undefined;
68
- }
69
- export type HookArguments<T extends HookName> = HookDefinitions[T];
70
- export type HookName = keyof HookDefinitions;
71
- /** A hook handler. */
72
- export type Handler<T extends HookName> = (
73
- /** Context about the current visit. */
74
- visit: Visit,
75
- /** Local arguments passed into the handler. */
76
- args: HookArguments<T>,
77
- /** Default handler to be executed. Available if replacing an internal hook handler. */
78
- defaultHandler?: Handler<T>) => Promise<any> | any;
79
- export type Handlers = {
80
- [K in HookName]: Handler<K>[];
81
- };
82
- /** Unregister a previously registered hook handler. */
83
- export type HookUnregister = () => void;
84
- /** Define when and how a hook handler is executed. */
85
- export type HookOptions = {
86
- /** Execute the hook once, then remove the handler */
87
- once?: boolean;
88
- /** Execute the hook before the internal default handler */
89
- before?: boolean;
90
- /** Set a priority for when to execute this hook. Lower numbers execute first. Default: `0` */
91
- priority?: number;
92
- /** Replace the internal default handler with this hook handler */
93
- replace?: boolean;
94
- };
95
- export type HookRegistration<T extends HookName> = {
96
- id: number;
97
- hook: T;
98
- handler: Handler<T>;
99
- defaultHandler?: Handler<T>;
100
- } & HookOptions;
101
- type HookLedger<T extends HookName> = Map<Handler<T>, HookRegistration<T>>;
102
- interface HookRegistry extends Map<HookName, HookLedger<HookName>> {
103
- get<K extends HookName>(key: K): HookLedger<K> | undefined;
104
- set<K extends HookName>(key: K, value: HookLedger<K>): this;
105
- }
106
- /**
107
- * Hook registry.
108
- *
109
- * Create, trigger and handle hooks.
110
- *
111
- */
112
- export declare class Hooks {
113
- /** Swup instance this registry belongs to */
114
- protected swup: Swup;
115
- /** Map of all registered hook handlers. */
116
- protected registry: HookRegistry;
117
- protected readonly hooks: HookName[];
118
- constructor(swup: Swup);
119
- /**
120
- * Create ledgers for all core hooks.
121
- */
122
- protected init(): void;
123
- /**
124
- * Create a new hook type.
125
- */
126
- create(hook: string): void;
127
- /**
128
- * Check if a hook type exists.
129
- */
130
- exists(hook: HookName): boolean;
131
- /**
132
- * Get the ledger with all registrations for a hook.
133
- */
134
- protected get<T extends HookName>(hook: T): HookLedger<T> | undefined;
135
- /**
136
- * Remove all handlers of all hooks.
137
- */
138
- clear(): void;
139
- /**
140
- * Register a new hook handler.
141
- * @param hook Name of the hook to listen for
142
- * @param handler The handler function to execute
143
- * @param options Object to specify how and when the handler is executed
144
- * Available options:
145
- * - `once`: Only execute the handler once
146
- * - `before`: Execute the handler before the default handler
147
- * - `priority`: Specify the order in which the handlers are executed
148
- * - `replace`: Replace the default handler with this handler
149
- * @returns A function to unregister the handler
150
- */
151
- on<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
152
- on<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
153
- /**
154
- * Register a new hook handler to run before the default handler.
155
- * Shortcut for `hooks.on(hook, handler, { before: true })`.
156
- * @param hook Name of the hook to listen for
157
- * @param handler The handler function to execute
158
- * @param options Any other event options (see `hooks.on()` for details)
159
- * @returns A function to unregister the handler
160
- * @see on
161
- */
162
- before<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
163
- before<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
164
- /**
165
- * Register a new hook handler to replace the default handler.
166
- * Shortcut for `hooks.on(hook, handler, { replace: true })`.
167
- * @param hook Name of the hook to listen for
168
- * @param handler The handler function to execute instead of the default handler
169
- * @param options Any other event options (see `hooks.on()` for details)
170
- * @returns A function to unregister the handler
171
- * @see on
172
- */
173
- replace<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
174
- replace<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
175
- /**
176
- * Register a new hook handler to run once.
177
- * Shortcut for `hooks.on(hook, handler, { once: true })`.
178
- * @param hook Name of the hook to listen for
179
- * @param handler The handler function to execute
180
- * @param options Any other event options (see `hooks.on()` for details)
181
- * @see on
182
- */
183
- once<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
184
- once<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
185
- /**
186
- * Unregister a hook handler.
187
- * @param hook Name of the hook the handler is registered for
188
- * @param handler The handler function that was registered.
189
- * If omitted, all handlers for the hook will be removed.
190
- */
191
- off<T extends HookName>(hook: T): void;
192
- off<T extends HookName>(hook: T, handler: Handler<T>): void;
193
- /**
194
- * Trigger a hook asynchronously, executing its default handler and all registered handlers.
195
- * Will execute all handlers in order and `await` any `Promise`s they return.
196
- * @param hook Name of the hook to trigger
197
- * @param args Arguments to pass to the handler
198
- * @param defaultHandler A default implementation of this hook to execute
199
- * @returns The resolved return value of the executed default handler
200
- */
201
- call<T extends HookName>(hook: T, args?: HookArguments<T>, defaultHandler?: Handler<T>): Promise<any>;
202
- /**
203
- * Trigger a hook synchronously, executing its default handler and all registered handlers.
204
- * Will execute all handlers in order, but will **not** `await` any `Promise`s they return.
205
- * @param hook Name of the hook to trigger
206
- * @param args Arguments to pass to the handler
207
- * @param defaultHandler A default implementation of this hook to execute
208
- * @returns The (possibly unresolved) return value of the executed default handler
209
- */
210
- callSync<T extends HookName>(hook: T, args?: HookArguments<T>, defaultHandler?: Handler<T>): any;
211
- /**
212
- * Execute the handlers for a hook, in order, as `Promise`s that will be `await`ed.
213
- * @param registrations The registrations (handler + options) to execute
214
- * @param args Arguments to pass to the handler
215
- */
216
- protected run<T extends HookName>(registrations: HookRegistration<T>[], args?: HookArguments<T>): Promise<any>;
217
- /**
218
- * Execute the handlers for a hook, in order, without `await`ing any returned `Promise`s.
219
- * @param registrations The registrations (handler + options) to execute
220
- * @param args Arguments to pass to the handler
221
- */
222
- protected runSync<T extends HookName>(registrations: HookRegistration<T>[], args?: HookArguments<T>): any[];
223
- /**
224
- * Get all registered handlers for a hook, sorted by priority and registration order.
225
- * @param hook Name of the hook
226
- * @param defaultHandler The optional default handler of this hook
227
- * @returns An object with the handlers sorted into `before` and `after` arrays,
228
- * as well as a flag indicating if the original handler was replaced
229
- */
230
- protected getHandlers<T extends HookName>(hook: T, defaultHandler?: Handler<T>): {
231
- found: boolean;
232
- before: HookRegistration<T>[];
233
- handler: HookRegistration<T>[];
234
- after: HookRegistration<T>[];
235
- replaced: boolean;
236
- };
237
- /**
238
- * Sort two hook registrations by priority and registration order.
239
- * @param a The registration object to compare
240
- * @param b The other registration object to compare with
241
- * @returns The sort direction
242
- */
243
- protected sortRegistrations<T extends HookName>(a: HookRegistration<T>, b: HookRegistration<T>): number;
244
- /**
245
- * Dispatch a custom event on the `document` for a hook. Prefixed with `swup:`
246
- * @param hook Name of the hook.
247
- */
248
- protected dispatchDomEvent<T extends HookName>(hook: T, args?: HookArguments<T>): void;
249
- }
250
- export {};
1
+ import { DelegateEvent } from 'delegate-it';
2
+ import Swup from '../Swup.js';
3
+ import { Visit } from './Visit.js';
4
+ import { FetchOptions, PageData } from './fetchPage.js';
5
+ export interface HookDefinitions {
6
+ 'animation:out:start': undefined;
7
+ 'animation:out:await': {
8
+ skip: boolean;
9
+ };
10
+ 'animation:out:end': undefined;
11
+ 'animation:in:start': undefined;
12
+ 'animation:in:await': {
13
+ skip: boolean;
14
+ };
15
+ 'animation:in:end': undefined;
16
+ 'animation:skip': undefined;
17
+ 'cache:clear': undefined;
18
+ 'cache:set': {
19
+ page: PageData;
20
+ };
21
+ 'content:replace': {
22
+ page: PageData;
23
+ };
24
+ 'content:scroll': undefined;
25
+ 'enable': undefined;
26
+ 'disable': undefined;
27
+ 'fetch:request': {
28
+ url: string;
29
+ options: FetchOptions;
30
+ };
31
+ 'fetch:error': {
32
+ url: string;
33
+ status: number;
34
+ response: Response;
35
+ };
36
+ 'history:popstate': {
37
+ event: PopStateEvent;
38
+ };
39
+ 'link:click': {
40
+ el: HTMLAnchorElement;
41
+ event: DelegateEvent<MouseEvent>;
42
+ };
43
+ 'link:self': undefined;
44
+ 'link:anchor': {
45
+ hash: string;
46
+ };
47
+ 'link:newtab': {
48
+ href: string;
49
+ };
50
+ 'page:load': {
51
+ page?: PageData;
52
+ cache?: boolean;
53
+ options: FetchOptions;
54
+ };
55
+ 'page:view': {
56
+ url: string;
57
+ title: string;
58
+ };
59
+ 'scroll:top': {
60
+ options: ScrollIntoViewOptions;
61
+ };
62
+ 'scroll:anchor': {
63
+ hash: string;
64
+ options: ScrollIntoViewOptions;
65
+ };
66
+ 'visit:start': undefined;
67
+ 'visit:end': undefined;
68
+ }
69
+ export interface HookReturnValues {
70
+ 'content:scroll': Promise<boolean>;
71
+ 'fetch:request': Promise<Response>;
72
+ 'page:load': Promise<PageData>;
73
+ 'scroll:top': boolean;
74
+ 'scroll:anchor': boolean;
75
+ }
76
+ export type HookArguments<T extends HookName> = HookDefinitions[T];
77
+ export type HookName = keyof HookDefinitions;
78
+ /** A generic hook handler. */
79
+ export type Handler<T extends HookName> = (
80
+ /** Context about the current visit. */
81
+ visit: Visit,
82
+ /** Local arguments passed into the handler. */
83
+ args: HookArguments<T>) => Promise<unknown> | unknown;
84
+ /** A default hook handler with an expected return type. */
85
+ export type DefaultHandler<T extends HookName> = (
86
+ /** Context about the current visit. */
87
+ visit: Visit,
88
+ /** Local arguments passed into the handler. */
89
+ args: HookArguments<T>,
90
+ /** Default handler to be executed. Available if replacing an internal hook handler. */
91
+ defaultHandler?: DefaultHandler<T>) => T extends keyof HookReturnValues ? HookReturnValues[T] : Promise<unknown> | unknown;
92
+ export type Handlers = {
93
+ [K in HookName]: Handler<K>[];
94
+ };
95
+ /** Unregister a previously registered hook handler. */
96
+ export type HookUnregister = () => void;
97
+ /** Define when and how a hook handler is executed. */
98
+ export type HookOptions = {
99
+ /** Execute the hook once, then remove the handler */
100
+ once?: boolean;
101
+ /** Execute the hook before the internal default handler */
102
+ before?: boolean;
103
+ /** Set a priority for when to execute this hook. Lower numbers execute first. Default: `0` */
104
+ priority?: number;
105
+ /** Replace the internal default handler with this hook handler */
106
+ replace?: boolean;
107
+ };
108
+ export type HookRegistration<T extends HookName, H extends Handler<T> | DefaultHandler<T> = Handler<T>> = {
109
+ id: number;
110
+ hook: T;
111
+ handler: H;
112
+ defaultHandler?: DefaultHandler<T>;
113
+ } & HookOptions;
114
+ type HookLedger<T extends HookName> = Map<Handler<T>, HookRegistration<T>>;
115
+ interface HookRegistry extends Map<HookName, HookLedger<HookName>> {
116
+ get<K extends HookName>(key: K): HookLedger<K> | undefined;
117
+ set<K extends HookName>(key: K, value: HookLedger<K>): this;
118
+ }
119
+ /**
120
+ * Hook registry.
121
+ *
122
+ * Create, trigger and handle hooks.
123
+ *
124
+ */
125
+ export declare class Hooks {
126
+ /** Swup instance this registry belongs to */
127
+ protected swup: Swup;
128
+ /** Map of all registered hook handlers. */
129
+ protected registry: HookRegistry;
130
+ protected readonly hooks: HookName[];
131
+ constructor(swup: Swup);
132
+ /**
133
+ * Create ledgers for all core hooks.
134
+ */
135
+ protected init(): void;
136
+ /**
137
+ * Create a new hook type.
138
+ */
139
+ create(hook: string): void;
140
+ /**
141
+ * Check if a hook type exists.
142
+ */
143
+ exists(hook: HookName): boolean;
144
+ /**
145
+ * Get the ledger with all registrations for a hook.
146
+ */
147
+ protected get<T extends HookName>(hook: T): HookLedger<T> | undefined;
148
+ /**
149
+ * Remove all handlers of all hooks.
150
+ */
151
+ clear(): void;
152
+ /**
153
+ * Register a new hook handler.
154
+ * @param hook Name of the hook to listen for
155
+ * @param handler The handler function to execute
156
+ * @param options Object to specify how and when the handler is executed
157
+ * Available options:
158
+ * - `once`: Only execute the handler once
159
+ * - `before`: Execute the handler before the default handler
160
+ * - `priority`: Specify the order in which the handlers are executed
161
+ * - `replace`: Replace the default handler with this handler
162
+ * @returns A function to unregister the handler
163
+ */
164
+ on<T extends HookName, O extends HookOptions>(hook: T, handler: DefaultHandler<T>, options: O & {
165
+ replace: true;
166
+ }): HookUnregister;
167
+ on<T extends HookName, O extends HookOptions>(hook: T, handler: Handler<T>, options: O): HookUnregister;
168
+ on<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
169
+ /**
170
+ * Register a new hook handler to run before the default handler.
171
+ * Shortcut for `hooks.on(hook, handler, { before: true })`.
172
+ * @param hook Name of the hook to listen for
173
+ * @param handler The handler function to execute
174
+ * @param options Any other event options (see `hooks.on()` for details)
175
+ * @returns A function to unregister the handler
176
+ * @see on
177
+ */
178
+ before<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
179
+ before<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
180
+ /**
181
+ * Register a new hook handler to replace the default handler.
182
+ * Shortcut for `hooks.on(hook, handler, { replace: true })`.
183
+ * @param hook Name of the hook to listen for
184
+ * @param handler The handler function to execute instead of the default handler
185
+ * @param options Any other event options (see `hooks.on()` for details)
186
+ * @returns A function to unregister the handler
187
+ * @see on
188
+ */
189
+ replace<T extends HookName>(hook: T, handler: DefaultHandler<T>, options: HookOptions): HookUnregister;
190
+ replace<T extends HookName>(hook: T, handler: DefaultHandler<T>): HookUnregister;
191
+ /**
192
+ * Register a new hook handler to run once.
193
+ * Shortcut for `hooks.on(hook, handler, { once: true })`.
194
+ * @param hook Name of the hook to listen for
195
+ * @param handler The handler function to execute
196
+ * @param options Any other event options (see `hooks.on()` for details)
197
+ * @see on
198
+ */
199
+ once<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;
200
+ once<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;
201
+ /**
202
+ * Unregister a hook handler.
203
+ * @param hook Name of the hook the handler is registered for
204
+ * @param handler The handler function that was registered.
205
+ * If omitted, all handlers for the hook will be removed.
206
+ */
207
+ off<T extends HookName>(hook: T, handler: Handler<T> | DefaultHandler<T>): void;
208
+ off<T extends HookName>(hook: T): void;
209
+ /**
210
+ * Trigger a hook asynchronously, executing its default handler and all registered handlers.
211
+ * Will execute all handlers in order and `await` any `Promise`s they return.
212
+ * @param hook Name of the hook to trigger
213
+ * @param args Arguments to pass to the handler
214
+ * @param defaultHandler A default implementation of this hook to execute
215
+ * @returns The resolved return value of the executed default handler
216
+ */
217
+ call<T extends HookName>(hook: T, args: HookArguments<T>, defaultHandler?: DefaultHandler<T>): Promise<Awaited<ReturnType<DefaultHandler<T>>>>;
218
+ /**
219
+ * Trigger a hook synchronously, executing its default handler and all registered handlers.
220
+ * Will execute all handlers in order, but will **not** `await` any `Promise`s they return.
221
+ * @param hook Name of the hook to trigger
222
+ * @param args Arguments to pass to the handler
223
+ * @param defaultHandler A default implementation of this hook to execute
224
+ * @returns The (possibly unresolved) return value of the executed default handler
225
+ */
226
+ callSync<T extends HookName>(hook: T, args: HookArguments<T>, defaultHandler?: DefaultHandler<T>): ReturnType<DefaultHandler<T>>;
227
+ /**
228
+ * Execute the handlers for a hook, in order, as `Promise`s that will be `await`ed.
229
+ * @param registrations The registrations (handler + options) to execute
230
+ * @param args Arguments to pass to the handler
231
+ */
232
+ protected run<T extends HookName>(registrations: HookRegistration<T, DefaultHandler<T>>[], args: HookArguments<T>): Promise<Awaited<ReturnType<DefaultHandler<T>>>[]>;
233
+ protected run<T extends HookName>(registrations: HookRegistration<T>[], args: HookArguments<T>): Promise<unknown[]>;
234
+ /**
235
+ * Execute the handlers for a hook, in order, without `await`ing any returned `Promise`s.
236
+ * @param registrations The registrations (handler + options) to execute
237
+ * @param args Arguments to pass to the handler
238
+ */
239
+ protected runSync<T extends HookName>(registrations: HookRegistration<T, DefaultHandler<T>>[], args: HookArguments<T>): ReturnType<DefaultHandler<T>>[];
240
+ protected runSync<T extends HookName>(registrations: HookRegistration<T>[], args: HookArguments<T>): unknown[];
241
+ /**
242
+ * Get all registered handlers for a hook, sorted by priority and registration order.
243
+ * @param hook Name of the hook
244
+ * @param defaultHandler The optional default handler of this hook
245
+ * @returns An object with the handlers sorted into `before` and `after` arrays,
246
+ * as well as a flag indicating if the original handler was replaced
247
+ */
248
+ protected getHandlers<T extends HookName>(hook: T, defaultHandler?: DefaultHandler<T>): {
249
+ found: boolean;
250
+ before: HookRegistration<T, Handler<T>>[];
251
+ handler: HookRegistration<T, DefaultHandler<T>>[];
252
+ after: HookRegistration<T, Handler<T>>[];
253
+ replaced: boolean;
254
+ };
255
+ /**
256
+ * Sort two hook registrations by priority and registration order.
257
+ * @param a The registration object to compare
258
+ * @param b The other registration object to compare with
259
+ * @returns The sort direction
260
+ */
261
+ protected sortRegistrations<T extends HookName>(a: HookRegistration<T>, b: HookRegistration<T>): number;
262
+ /**
263
+ * Dispatch a custom event on the `document` for a hook. Prefixed with `swup:`
264
+ * @param hook Name of the hook.
265
+ */
266
+ protected dispatchDomEvent<T extends HookName>(hook: T, args?: HookArguments<T>): void;
267
+ }
268
+ export {};