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,119 +1,119 @@
1
- import { DelegateEvent } from 'delegate-it';
2
- import { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';
3
- import { Cache } from './modules/Cache.js';
4
- import { Classes } from './modules/Classes.js';
5
- import { Visit, createVisit } from './modules/Visit.js';
6
- import { Hooks } from './modules/Hooks.js';
7
- import { awaitAnimations } from './modules/awaitAnimations.js';
8
- import { navigate, performNavigation, NavigationToSelfAction } from './modules/navigate.js';
9
- import { fetchPage } from './modules/fetchPage.js';
10
- import { unuse, findPlugin, Plugin } from './modules/plugins.js';
11
- import { isSameResolvedUrl, resolveUrl } from './modules/resolveUrl.js';
12
- /** Options for customizing swup's behavior. */
13
- export type Options = {
14
- /** Whether history visits are animated. Default: `false` */
15
- animateHistoryBrowsing: boolean;
16
- /** Selector for detecting animation timing. Default: `[class*="transition-"]` */
17
- animationSelector: string | false;
18
- /** Elements on which to add animation classes. Default: `html` element */
19
- animationScope: 'html' | 'containers';
20
- /** Enable in-memory page cache. Default: `true` */
21
- cache: boolean;
22
- /** Content containers to be replaced on page visits. Default: `['#swup']` */
23
- containers: string[];
24
- /** Callback for ignoring visits. Receives the element and event that triggered the visit. */
25
- ignoreVisit: (url: string, { el, event }: {
26
- el?: Element;
27
- event?: Event;
28
- }) => boolean;
29
- /** Selector for links that trigger visits. Default: `'a[href]'` */
30
- linkSelector: string;
31
- /** How swup handles links to the same page. Default: `scroll` */
32
- linkToSelf: NavigationToSelfAction;
33
- /** Plugins to register on startup. */
34
- plugins: Plugin[];
35
- /** Custom headers sent along with fetch requests. */
36
- requestHeaders: Record<string, string>;
37
- /** Rewrite URLs before loading them. */
38
- resolveUrl: (url: string) => string;
39
- /** Callback for telling swup to ignore certain popstate events. */
40
- skipPopStateHandling: (event: any) => boolean;
41
- };
42
- /** Swup page transition library. */
43
- export default class Swup {
44
- /** Library version */
45
- readonly version: string;
46
- /** Options passed into the instance */
47
- options: Options;
48
- /** Default options before merging user options */
49
- readonly defaults: Options;
50
- /** Registered plugin instances */
51
- plugins: Plugin[];
52
- /** Data about the current visit */
53
- visit: Visit;
54
- /** Cache instance */
55
- readonly cache: Cache;
56
- /** Hook registry */
57
- readonly hooks: Hooks;
58
- /** Animation class manager */
59
- readonly classes: Classes;
60
- /** URL of the currently visible page */
61
- currentPageUrl: string;
62
- /** Index of the current history entry */
63
- protected currentHistoryIndex: number;
64
- /** Delegated event subscription handle */
65
- protected clickDelegate?: DelegateEventUnsubscribe;
66
- /** Install a plugin */
67
- use: (this: Swup, plugin: unknown) => Plugin[] | undefined;
68
- /** Uninstall a plugin */
69
- unuse: typeof unuse;
70
- /** Find a plugin by name or instance */
71
- findPlugin: typeof findPlugin;
72
- /** Log a message. Has no effect unless debug plugin is installed */
73
- log: (message: string, context?: any) => void;
74
- /** Navigate to a new URL */
75
- navigate: typeof navigate;
76
- /** Actually perform a navigation */
77
- protected performNavigation: typeof performNavigation;
78
- /** Create a new context for this visit */
79
- protected createVisit: typeof createVisit;
80
- /** Register a delegated event listener */
81
- delegateEvent: <Selector extends string, TElement extends Element = import("typed-query-selector/parser.js").ParseSelector<Selector, HTMLElement>, TEvent extends keyof GlobalEventHandlersEventMap = keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: import("delegate-it").DelegateEventHandler<GlobalEventHandlersEventMap[TEvent], TElement>, options?: import("delegate-it").DelegateOptions | undefined) => DelegateEventUnsubscribe;
82
- /** Fetch a page from the server */
83
- fetchPage: typeof fetchPage;
84
- /** Resolve when animations on the page finish */
85
- awaitAnimations: typeof awaitAnimations;
86
- protected renderPage: (this: Swup, requestedUrl: string, page: import("./modules/fetchPage.js").PageData) => Promise<void>;
87
- /** Replace the content after page load */
88
- replaceContent: (this: Swup, { html }: import("./modules/fetchPage.js").PageData, { containers }?: {
89
- containers: string[];
90
- }) => boolean;
91
- protected animatePageIn: (this: Swup) => Promise<void>;
92
- protected animatePageOut: (this: Swup) => Promise<void>;
93
- protected scrollToContent: (this: Swup) => boolean;
94
- /** Find the anchor element for a given hash */
95
- getAnchorElement: (hash?: string | undefined) => Element | null;
96
- /** Get the current page URL */
97
- getCurrentUrl: ({ hash }?: {
98
- hash?: boolean | undefined;
99
- }) => string;
100
- /** Resolve a URL to its final location */
101
- resolveUrl: typeof resolveUrl;
102
- /** Check if two URLs resolve to the same location */
103
- protected isSameResolvedUrl: typeof isSameResolvedUrl;
104
- constructor(options?: Partial<Options>);
105
- protected checkRequirements(): boolean;
106
- /** Enable this instance, adding listeners and classnames. */
107
- enable(): Promise<void>;
108
- /** Disable this instance, removing listeners and classnames. */
109
- destroy(): Promise<void>;
110
- /** Determine if a visit should be ignored by swup, based on URL or trigger element. */
111
- shouldIgnoreVisit(href: string, { el, event }?: {
112
- el?: Element;
113
- event?: Event;
114
- }): boolean;
115
- protected handleLinkClick(event: DelegateEvent<MouseEvent>): void;
116
- protected handlePopState(event: PopStateEvent): void;
117
- /** Determine whether an element will open a new tab when clicking/activating. */
118
- protected triggerWillOpenNewWindow(triggerEl: Element): boolean;
119
- }
1
+ import { DelegateEvent } from 'delegate-it';
2
+ import { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';
3
+ import { Cache } from './modules/Cache.js';
4
+ import { Classes } from './modules/Classes.js';
5
+ import { Visit, createVisit } from './modules/Visit.js';
6
+ import { Hooks } from './modules/Hooks.js';
7
+ import { awaitAnimations } from './modules/awaitAnimations.js';
8
+ import { navigate, performNavigation, NavigationToSelfAction } from './modules/navigate.js';
9
+ import { fetchPage } from './modules/fetchPage.js';
10
+ import { unuse, findPlugin, Plugin } from './modules/plugins.js';
11
+ import { isSameResolvedUrl, resolveUrl } from './modules/resolveUrl.js';
12
+ /** Options for customizing swup's behavior. */
13
+ export type Options = {
14
+ /** Whether history visits are animated. Default: `false` */
15
+ animateHistoryBrowsing: boolean;
16
+ /** Selector for detecting animation timing. Default: `[class*="transition-"]` */
17
+ animationSelector: string | false;
18
+ /** Elements on which to add animation classes. Default: `html` element */
19
+ animationScope: 'html' | 'containers';
20
+ /** Enable in-memory page cache. Default: `true` */
21
+ cache: boolean;
22
+ /** Content containers to be replaced on page visits. Default: `['#swup']` */
23
+ containers: string[];
24
+ /** Callback for ignoring visits. Receives the element and event that triggered the visit. */
25
+ ignoreVisit: (url: string, { el, event }: {
26
+ el?: Element;
27
+ event?: Event;
28
+ }) => boolean;
29
+ /** Selector for links that trigger visits. Default: `'a[href]'` */
30
+ linkSelector: string;
31
+ /** How swup handles links to the same page. Default: `scroll` */
32
+ linkToSelf: NavigationToSelfAction;
33
+ /** Plugins to register on startup. */
34
+ plugins: Plugin[];
35
+ /** Custom headers sent along with fetch requests. */
36
+ requestHeaders: Record<string, string>;
37
+ /** Rewrite URLs before loading them. */
38
+ resolveUrl: (url: string) => string;
39
+ /** Callback for telling swup to ignore certain popstate events. */
40
+ skipPopStateHandling: (event: PopStateEvent) => boolean;
41
+ };
42
+ /** Swup page transition library. */
43
+ export default class Swup {
44
+ /** Library version */
45
+ readonly version: string;
46
+ /** Options passed into the instance */
47
+ options: Options;
48
+ /** Default options before merging user options */
49
+ readonly defaults: Options;
50
+ /** Registered plugin instances */
51
+ plugins: Plugin[];
52
+ /** Data about the current visit */
53
+ visit: Visit;
54
+ /** Cache instance */
55
+ readonly cache: Cache;
56
+ /** Hook registry */
57
+ readonly hooks: Hooks;
58
+ /** Animation class manager */
59
+ readonly classes: Classes;
60
+ /** URL of the currently visible page */
61
+ currentPageUrl: string;
62
+ /** Index of the current history entry */
63
+ protected currentHistoryIndex: number;
64
+ /** Delegated event subscription handle */
65
+ protected clickDelegate?: DelegateEventUnsubscribe;
66
+ /** Install a plugin */
67
+ use: (this: Swup, plugin: unknown) => Plugin[] | undefined;
68
+ /** Uninstall a plugin */
69
+ unuse: typeof unuse;
70
+ /** Find a plugin by name or instance */
71
+ findPlugin: typeof findPlugin;
72
+ /** Log a message. Has no effect unless debug plugin is installed */
73
+ log: (message: string, context?: unknown) => void;
74
+ /** Navigate to a new URL */
75
+ navigate: typeof navigate;
76
+ /** Actually perform a navigation */
77
+ protected performNavigation: typeof performNavigation;
78
+ /** Create a new context for this visit */
79
+ protected createVisit: typeof createVisit;
80
+ /** Register a delegated event listener */
81
+ delegateEvent: <Selector extends string, TElement extends Element = import("typed-query-selector/parser.js").ParseSelector<Selector, HTMLElement>, TEvent extends keyof GlobalEventHandlersEventMap = keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: import("delegate-it").DelegateEventHandler<GlobalEventHandlersEventMap[TEvent], TElement>, options?: import("delegate-it").DelegateOptions | undefined) => DelegateEventUnsubscribe;
82
+ /** Fetch a page from the server */
83
+ fetchPage: typeof fetchPage;
84
+ /** Resolve when animations on the page finish */
85
+ awaitAnimations: typeof awaitAnimations;
86
+ protected renderPage: (this: Swup, requestedUrl: string, page: import("./modules/fetchPage.js").PageData) => Promise<void>;
87
+ /** Replace the content after page load */
88
+ replaceContent: (this: Swup, { html }: import("./modules/fetchPage.js").PageData, { containers }?: {
89
+ containers: string[];
90
+ }) => boolean;
91
+ protected animatePageIn: (this: Swup) => Promise<void>;
92
+ protected animatePageOut: (this: Swup) => Promise<void>;
93
+ protected scrollToContent: (this: Swup) => boolean;
94
+ /** Find the anchor element for a given hash */
95
+ getAnchorElement: (hash?: string | undefined) => Element | null;
96
+ /** Get the current page URL */
97
+ getCurrentUrl: ({ hash }?: {
98
+ hash?: boolean | undefined;
99
+ }) => string;
100
+ /** Resolve a URL to its final location */
101
+ resolveUrl: typeof resolveUrl;
102
+ /** Check if two URLs resolve to the same location */
103
+ protected isSameResolvedUrl: typeof isSameResolvedUrl;
104
+ constructor(options?: Partial<Options>);
105
+ protected checkRequirements(): boolean;
106
+ /** Enable this instance, adding listeners and classnames. */
107
+ enable(): Promise<void>;
108
+ /** Disable this instance, removing listeners and classnames. */
109
+ destroy(): Promise<void>;
110
+ /** Determine if a visit should be ignored by swup, based on URL or trigger element. */
111
+ shouldIgnoreVisit(href: string, { el, event }?: {
112
+ el?: Element;
113
+ event?: Event;
114
+ }): boolean;
115
+ protected handleLinkClick(event: DelegateEvent<MouseEvent>): void;
116
+ protected handlePopState(event: PopStateEvent): void;
117
+ /** Determine whether an element will open a new tab when clicking/activating. */
118
+ protected triggerWillOpenNewWindow(triggerEl: Element): boolean;
119
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,5 +1,5 @@
1
- /**
2
- * Import swup's current version from package.json
3
- */
4
- declare const _default: string;
5
- export default _default;
1
+ /**
2
+ * Import swup's current version from package.json
3
+ */
4
+ declare const _default: string;
5
+ export default _default;
@@ -1,24 +1,24 @@
1
- /**
2
- * A helper for creating a Location from either an element
3
- * or a URL object/string
4
- *
5
- */
6
- export declare class Location extends URL {
7
- constructor(url: URL | string, base?: string);
8
- /**
9
- * The full local path including query params.
10
- */
11
- get url(): string;
12
- /**
13
- * Instantiate a Location from an element's href attribute
14
- * @param el
15
- * @returns new Location instance
16
- */
17
- static fromElement(el: Element): Location;
18
- /**
19
- * Instantiate a Location from a URL object or string
20
- * @param url
21
- * @returns new Location instance
22
- */
23
- static fromUrl(url: URL | string): Location;
24
- }
1
+ /**
2
+ * A helper for creating a Location from either an element
3
+ * or a URL object/string
4
+ *
5
+ */
6
+ export declare class Location extends URL {
7
+ constructor(url: URL | string, base?: string);
8
+ /**
9
+ * The full local path including query params.
10
+ */
11
+ get url(): string;
12
+ /**
13
+ * Instantiate a Location from an element's href attribute
14
+ * @param el
15
+ * @returns new Location instance
16
+ */
17
+ static fromElement(el: Element): Location;
18
+ /**
19
+ * Instantiate a Location from a URL object or string
20
+ * @param url
21
+ * @returns new Location instance
22
+ */
23
+ static fromUrl(url: URL | string): Location;
24
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,2 +1,2 @@
1
- /** Turn a string into a slug by lowercasing and replacing whitespace. */
2
- export declare const classify: (text: string, fallback?: string) => string;
1
+ /** Turn a string into a slug by lowercasing and replacing whitespace. */
2
+ export declare const classify: (text: string, fallback?: string) => string;
@@ -1,2 +1,9 @@
1
- /** Create a new history record with a custom swup identifier. */
2
- export declare const createHistoryRecord: (url: string, customData?: Record<string, unknown>) => void;
1
+ export interface HistoryState {
2
+ url: string;
3
+ source: 'swup';
4
+ random: number;
5
+ index?: number;
6
+ [key: string]: unknown;
7
+ }
8
+ /** Create a new history record with a custom swup identifier. */
9
+ export declare const createHistoryRecord: (url: string, customData?: Record<string, unknown>) => void;
@@ -1,7 +1,7 @@
1
- import { DelegateEventHandler, DelegateOptions } from 'delegate-it';
2
- import { ParseSelector } from 'typed-query-selector/parser.js';
3
- export type DelegateEventUnsubscribe = {
4
- destroy: () => void;
5
- };
6
- /** Register a delegated event listener. */
7
- export declare const delegateEvent: <Selector extends string, TElement extends Element = ParseSelector<Selector, HTMLElement>, TEvent extends keyof GlobalEventHandlersEventMap = keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEvent], TElement>, options?: DelegateOptions) => DelegateEventUnsubscribe;
1
+ import { DelegateEventHandler, DelegateOptions } from 'delegate-it';
2
+ import { ParseSelector } from 'typed-query-selector/parser.js';
3
+ export type DelegateEventUnsubscribe = {
4
+ destroy: () => void;
5
+ };
6
+ /** Register a delegated event listener. */
7
+ export declare const delegateEvent: <Selector extends string, TElement extends Element = ParseSelector<Selector, HTMLElement>, TEvent extends keyof GlobalEventHandlersEventMap = keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEvent], TElement>, options?: DelegateOptions) => DelegateEventUnsubscribe;
@@ -1,4 +1,4 @@
1
- /** Get the current page URL: path name + query params. Optionally including hash. */
2
- export declare const getCurrentUrl: ({ hash }?: {
3
- hash?: boolean | undefined;
4
- }) => string;
1
+ /** Get the current page URL: path name + query params. Optionally including hash. */
2
+ export declare const getCurrentUrl: ({ hash }?: {
3
+ hash?: boolean | undefined;
4
+ }) => string;
@@ -1,4 +1,4 @@
1
- import type { Path, ParseOptions, TokensToRegexpOptions, RegexpToFunctionOptions, MatchFunction } from 'path-to-regexp';
2
- export { Path };
3
- /** Create a match function from a path pattern that checks if a URLs matches it. */
4
- export declare const matchPath: <P extends object = object>(path: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions) => MatchFunction<P>;
1
+ import type { Path, ParseOptions, TokensToRegexpOptions, RegexpToFunctionOptions, MatchFunction } from 'path-to-regexp';
2
+ export { Path };
3
+ /** Create a match function from a path pattern that checks if a URLs matches it. */
4
+ export declare const matchPath: <P extends object = object>(path: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions) => MatchFunction<P>;
@@ -1,2 +1,2 @@
1
- /** Update the current history record with a custom swup identifier. */
2
- export declare const updateHistoryRecord: (url?: string | null, customData?: Record<string, unknown>) => void;
1
+ /** Update the current history record with a custom swup identifier. */
2
+ export declare const updateHistoryRecord: (url?: string | null, customData?: Record<string, unknown>) => void;
@@ -1,7 +1,7 @@
1
- export { classify } from './helpers/classify.js';
2
- export { createHistoryRecord } from './helpers/createHistoryRecord.js';
3
- export { updateHistoryRecord } from './helpers/updateHistoryRecord.js';
4
- export { delegateEvent } from './helpers/delegateEvent.js';
5
- export { getCurrentUrl } from './helpers/getCurrentUrl.js';
6
- export { Location } from './helpers/Location.js';
7
- export { matchPath } from './helpers/matchPath.js';
1
+ export { classify } from './helpers/classify.js';
2
+ export { createHistoryRecord } from './helpers/createHistoryRecord.js';
3
+ export { updateHistoryRecord } from './helpers/updateHistoryRecord.js';
4
+ export { delegateEvent } from './helpers/delegateEvent.js';
5
+ export { getCurrentUrl } from './helpers/getCurrentUrl.js';
6
+ export { Location } from './helpers/Location.js';
7
+ export { matchPath } from './helpers/matchPath.js';
@@ -1,14 +1,14 @@
1
- import type { Path } from 'path-to-regexp';
2
- import type { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';
3
- import type { DelegateEvent, DelegateEventHandler } from 'delegate-it';
4
- import Swup from './Swup.js';
5
- import type { Options } from './Swup.js';
6
- import type { CacheData } from './modules/Cache.js';
7
- import type { PageData } from './modules/fetchPage.js';
8
- import type { Visit, VisitFrom, VisitTo, VisitAnimation, VisitScroll, VisitHistory } from './modules/Visit.js';
9
- import type { HookArguments, HookDefinitions, HookName, HookOptions, HookUnregister, Handler } from './modules/Hooks.js';
10
- import type { Plugin } from './modules/plugins.js';
11
- export default Swup;
12
- export * from './helpers.js';
13
- export * from './utils.js';
14
- export type { Swup, Options, Plugin, CacheData, PageData, Visit, VisitFrom, VisitTo, VisitAnimation, VisitScroll, VisitHistory, HookArguments, HookDefinitions, HookName, HookOptions, HookUnregister, Handler, Path, DelegateEvent, DelegateEventHandler, DelegateEventUnsubscribe };
1
+ import type { Path } from 'path-to-regexp';
2
+ import type { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';
3
+ import type { DelegateEvent, DelegateEventHandler } from 'delegate-it';
4
+ import Swup from './Swup.js';
5
+ import type { Options } from './Swup.js';
6
+ import type { CacheData } from './modules/Cache.js';
7
+ import type { PageData } from './modules/fetchPage.js';
8
+ import type { Visit, VisitFrom, VisitTo, VisitAnimation, VisitScroll, VisitHistory } from './modules/Visit.js';
9
+ import type { HookArguments, HookDefinitions, HookName, HookOptions, HookUnregister, Handler } from './modules/Hooks.js';
10
+ import type { Plugin } from './modules/plugins.js';
11
+ export default Swup;
12
+ export * from './helpers.js';
13
+ export * from './utils.js';
14
+ export type { Swup, Options, Plugin, CacheData, PageData, Visit, VisitFrom, VisitTo, VisitAnimation, VisitScroll, VisitHistory, HookArguments, HookDefinitions, HookName, HookOptions, HookUnregister, Handler, Path, DelegateEvent, DelegateEventHandler, DelegateEventUnsubscribe };
@@ -1,34 +1,34 @@
1
- import Swup from '../Swup.js';
2
- import { PageData } from './fetchPage.js';
3
- export interface CacheData extends PageData {
4
- }
5
- /**
6
- * In-memory page cache.
7
- */
8
- export declare class Cache {
9
- /** Swup instance this cache belongs to */
10
- protected swup: Swup;
11
- /** Cached pages, indexed by URL */
12
- protected pages: Map<string, CacheData>;
13
- constructor(swup: Swup);
14
- /** Number of cached pages in memory. */
15
- get size(): number;
16
- /** All cached pages. */
17
- get all(): Map<any, any>;
18
- /** Check if the given URL has been cached. */
19
- has(url: string): boolean;
20
- /** Return a shallow copy of the cached page object if available. */
21
- get(url: string): CacheData | undefined;
22
- /** Create a cache record for the specified URL. */
23
- set(url: string, page: CacheData): void;
24
- /** Update a cache record, overwriting or adding custom data. */
25
- update(url: string, payload: Record<string, any>): void;
26
- /** Delete a cache record. */
27
- delete(url: string): void;
28
- /** Empty the cache. */
29
- clear(): void;
30
- /** Remove all cache entries that return true for a given predicate function. */
31
- prune(predicate: (url: string, page: CacheData) => boolean): void;
32
- /** Resolve URLs by making them local and letting swup resolve them. */
33
- protected resolve(urlToResolve: string): string;
34
- }
1
+ import Swup from '../Swup.js';
2
+ import { PageData } from './fetchPage.js';
3
+ export interface CacheData extends PageData {
4
+ }
5
+ /**
6
+ * In-memory page cache.
7
+ */
8
+ export declare class Cache {
9
+ /** Swup instance this cache belongs to */
10
+ protected swup: Swup;
11
+ /** Cached pages, indexed by URL */
12
+ protected pages: Map<string, CacheData>;
13
+ constructor(swup: Swup);
14
+ /** Number of cached pages in memory. */
15
+ get size(): number;
16
+ /** All cached pages. */
17
+ get all(): Map<any, any>;
18
+ /** Check if the given URL has been cached. */
19
+ has(url: string): boolean;
20
+ /** Return a shallow copy of the cached page object if available. */
21
+ get(url: string): CacheData | undefined;
22
+ /** Create a cache record for the specified URL. */
23
+ set(url: string, page: CacheData): void;
24
+ /** Update a cache record, overwriting or adding custom data. */
25
+ update(url: string, payload: object): void;
26
+ /** Delete a cache record. */
27
+ delete(url: string): void;
28
+ /** Empty the cache. */
29
+ clear(): void;
30
+ /** Remove all cache entries that return true for a given predicate function. */
31
+ prune(predicate: (url: string, page: CacheData) => boolean): void;
32
+ /** Resolve URLs by making them local and letting swup resolve them. */
33
+ protected resolve(urlToResolve: string): string;
34
+ }
@@ -1,13 +1,13 @@
1
- import Swup from '../Swup.js';
2
- export declare class Classes {
3
- protected swup: Swup;
4
- protected swupClasses: string[];
5
- constructor(swup: Swup);
6
- protected get selectors(): string[];
7
- protected get selector(): string;
8
- protected get targets(): HTMLElement[];
9
- add(...classes: string[]): void;
10
- remove(...classes: string[]): void;
11
- clear(): void;
12
- protected isSwupClass(className: string): boolean;
13
- }
1
+ import Swup from '../Swup.js';
2
+ export declare class Classes {
3
+ protected swup: Swup;
4
+ protected swupClasses: string[];
5
+ constructor(swup: Swup);
6
+ protected get selectors(): string[];
7
+ protected get selector(): string;
8
+ protected get targets(): HTMLElement[];
9
+ add(...classes: string[]): void;
10
+ remove(...classes: string[]): void;
11
+ clear(): void;
12
+ protected isSwupClass(className: string): boolean;
13
+ }