@thepassle/app-tools 0.9.0 → 0.9.2
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/package.json +36 -15
- package/router/index.js +16 -2
- package/types/api/index.d.ts +57 -0
- package/types/api/plugins/abort.d.ts +5 -0
- package/types/api/plugins/cache.d.ts +8 -0
- package/types/api/plugins/debounce.d.ts +10 -0
- package/types/api/plugins/delay.d.ts +2 -0
- package/types/api/plugins/jsonPrefix.d.ts +6 -0
- package/types/api/plugins/logger.d.ts +10 -0
- package/types/api/plugins/mock.d.ts +5 -0
- package/types/api/plugins/xsrf.d.ts +12 -0
- package/types/dialog/events.d.ts +8 -0
- package/types/dialog/index.d.ts +43 -0
- package/types/dialog/utils.d.ts +1 -0
- package/types/env/dev.d.ts +2 -0
- package/types/env/prod.d.ts +2 -0
- package/types/pwa/capabilities.d.ts +7 -0
- package/types/pwa/events.d.ts +25 -0
- package/types/pwa/index.d.ts +40 -0
- package/types/router/index.d.ts +64 -0
- package/types/router/plugins/appName.d.ts +5 -0
- package/types/router/plugins/checkServiceWorkerUpdate.d.ts +4 -0
- package/types/router/plugins/data.d.ts +5 -0
- package/types/router/plugins/lazy.d.ts +6 -0
- package/types/router/plugins/offline.d.ts +7 -0
- package/types/router/plugins/redirect.d.ts +5 -0
- package/types/router/plugins/resetFocus.d.ts +4 -0
- package/types/router/plugins/scrollToTop.d.ts +4 -0
- package/types/state/index.d.ts +15 -0
- package/types/utils/CONSTANTS.d.ts +2 -0
- package/types/utils/Service.d.ts +23 -0
- package/types/utils/async.d.ts +29 -0
- package/types/utils/index.d.ts +9 -0
- package/types/utils/keycodes.d.ts +13 -0
- package/types/utils/log.d.ts +18 -0
- package/types/utils/media.d.ts +37 -0
- package/api/types.d.ts +0 -41
- package/dialog/types.d.ts +0 -21
- package/router/types.d.ts +0 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thepassle/app-tools",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,25 +10,46 @@
|
|
|
10
10
|
"lint:types:watch": "tsc --watch"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
|
-
"./state.js":
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"./state.js": {
|
|
14
|
+
"types": "./types/state/index.d.ts",
|
|
15
|
+
"default": "./state.js"
|
|
16
|
+
},
|
|
17
|
+
"./pwa.js": {
|
|
18
|
+
"types": "./types/pwa/index.d.ts",
|
|
19
|
+
"default": "./pwa.js"
|
|
20
|
+
},
|
|
21
|
+
"./dialog.js": {
|
|
22
|
+
"types": "./types/dialog/index.d.ts",
|
|
17
23
|
"default": "./dialog.js"
|
|
18
24
|
},
|
|
19
|
-
"./pwa/*":
|
|
20
|
-
|
|
21
|
-
"
|
|
25
|
+
"./pwa/*": {
|
|
26
|
+
"types": "./types/pwa/*",
|
|
27
|
+
"default": "./pwa/*"
|
|
28
|
+
},
|
|
29
|
+
"./api.js": {
|
|
30
|
+
"types": "./types/api/index.d.ts",
|
|
22
31
|
"default": "./api.js"
|
|
23
32
|
},
|
|
24
|
-
"./router.js": {
|
|
25
|
-
"types": "./router/
|
|
33
|
+
"./router.js": {
|
|
34
|
+
"types": "./types/router/index.d.ts",
|
|
26
35
|
"default": "./router.js"
|
|
27
36
|
},
|
|
28
|
-
"./router/plugins/*":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
"./router/plugins/*": {
|
|
38
|
+
"types": "./types/router/index/*",
|
|
39
|
+
"default": "./router/plugins/*"
|
|
40
|
+
},
|
|
41
|
+
"./api/plugins/*": {
|
|
42
|
+
"types": "./types/api/plugins/*",
|
|
43
|
+
"default": "./api/plugins/*"
|
|
44
|
+
},
|
|
45
|
+
"./utils.js": {
|
|
46
|
+
"types": "./types/utils/index.d.ts",
|
|
47
|
+
"default": "./utils.js"
|
|
48
|
+
},
|
|
49
|
+
"./utils/*": {
|
|
50
|
+
"types": "./types/utils/*",
|
|
51
|
+
"default": "./utils/*"
|
|
52
|
+
},
|
|
32
53
|
"./env.js": {
|
|
33
54
|
"development": "./env/dev.js",
|
|
34
55
|
"default": "./env/prod.js"
|
|
@@ -36,7 +57,7 @@
|
|
|
36
57
|
"./package.json": "./package.json"
|
|
37
58
|
},
|
|
38
59
|
"files": [
|
|
39
|
-
"
|
|
60
|
+
"./types/**/*.d.ts",
|
|
40
61
|
"./env.js",
|
|
41
62
|
"./pwa.js",
|
|
42
63
|
"./dialog.js",
|
package/router/index.js
CHANGED
|
@@ -77,12 +77,17 @@ export class Router extends EventTarget {
|
|
|
77
77
|
return new URL('./', document.baseURI);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @template RenderResult
|
|
82
|
+
* @returns {RenderResult}
|
|
83
|
+
*/
|
|
80
84
|
render() {
|
|
81
85
|
log(`Rendering route ${this.context.url.pathname}${this.context.url.search}`, { context: this.context, route: this.route });
|
|
82
86
|
return this.route?.render?.(this.context);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
/**
|
|
90
|
+
* @private
|
|
86
91
|
* @param {URL} url
|
|
87
92
|
* @returns {Route | null}
|
|
88
93
|
*/
|
|
@@ -106,14 +111,23 @@ export class Router extends EventTarget {
|
|
|
106
111
|
return null;
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
109
117
|
_notifyUrlChanged() {
|
|
110
118
|
this.dispatchEvent(new RouteEvent(this.context));
|
|
111
119
|
}
|
|
112
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
113
124
|
_onPopState = () => {
|
|
114
125
|
this.navigate(new URL(window.location.href), { backNav: true });
|
|
115
126
|
}
|
|
116
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
117
131
|
_onAnchorClick = (e) => {
|
|
118
132
|
if (
|
|
119
133
|
e.defaultPrevented ||
|
|
@@ -143,9 +157,9 @@ export class Router extends EventTarget {
|
|
|
143
157
|
|
|
144
158
|
/**
|
|
145
159
|
* @param {string | URL} url The URL to navigate to.
|
|
146
|
-
* @param {
|
|
160
|
+
* @param {{
|
|
147
161
|
* backNav?: boolean
|
|
148
|
-
* }} options
|
|
162
|
+
* }} options options An options object to configure the navigation. The backNav property specifies whether the navigation is a backward navigation, which doesn't push the navigation into browser nav history.
|
|
149
163
|
*/
|
|
150
164
|
async navigate(url, options = {}) {
|
|
151
165
|
if (typeof url === 'string') {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** @typedef {import('./types.js').Config} Config */
|
|
2
|
+
/** @typedef {import('./types.js').Method} Method */
|
|
3
|
+
/** @typedef {import('./types.js').Plugin} Plugin */
|
|
4
|
+
/** @typedef {import('./types.js').CustomRequestOptions} CustomRequestOptions */
|
|
5
|
+
/** @typedef {import('./types.js').RequestOptions} RequestOptions */
|
|
6
|
+
/** @typedef {import('./types.js').MetaParams} MetaParams */
|
|
7
|
+
/**
|
|
8
|
+
* @example
|
|
9
|
+
* const api = new Api({
|
|
10
|
+
* baseURL: 'https://api.foo.com/',
|
|
11
|
+
* responseType: 'text',
|
|
12
|
+
* plugins: [
|
|
13
|
+
* {
|
|
14
|
+
* beforeFetch: ({url, method, opts, data}) => {},
|
|
15
|
+
* afterFetch: (res) => res,
|
|
16
|
+
* }
|
|
17
|
+
* ]
|
|
18
|
+
*});
|
|
19
|
+
*/
|
|
20
|
+
export class Api {
|
|
21
|
+
/** @param {Config} config */
|
|
22
|
+
constructor(config?: Config);
|
|
23
|
+
config: {
|
|
24
|
+
plugins: import("./types.js").Plugin[];
|
|
25
|
+
responseType: string;
|
|
26
|
+
baseURL?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} url
|
|
30
|
+
* @param {Method} method
|
|
31
|
+
* @param {RequestOptions} [opts]
|
|
32
|
+
* @param {object} [data]
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
fetch(url: string, method: Method, opts?: RequestOptions, data?: object): Promise<any>;
|
|
36
|
+
/** @type {import('./types.js').BodylessMethod<object>} */
|
|
37
|
+
get: import('./types.js').BodylessMethod<object>;
|
|
38
|
+
/** @type {import('./types.js').BodylessMethod<object>} */
|
|
39
|
+
options: import('./types.js').BodylessMethod<object>;
|
|
40
|
+
/** @type {import('./types.js').BodylessMethod<object>} */
|
|
41
|
+
delete: import('./types.js').BodylessMethod<object>;
|
|
42
|
+
/** @type {import('./types.js').BodylessMethod<object>} */
|
|
43
|
+
head: import('./types.js').BodylessMethod<object>;
|
|
44
|
+
/** @type {import('./types.js').BodyMethod<object>} */
|
|
45
|
+
post: import('./types.js').BodyMethod<object>;
|
|
46
|
+
/** @type {import('./types.js').BodyMethod<object>} */
|
|
47
|
+
put: import('./types.js').BodyMethod<object>;
|
|
48
|
+
/** @type {import('./types.js').BodyMethod<object>} */
|
|
49
|
+
patch: import('./types.js').BodyMethod<object>;
|
|
50
|
+
}
|
|
51
|
+
export const api: Api;
|
|
52
|
+
export type Config = import('./types.js').Config;
|
|
53
|
+
export type Method = import('./types.js').Method;
|
|
54
|
+
export type Plugin = import('./types.js').Plugin;
|
|
55
|
+
export type CustomRequestOptions = import('./types.js').CustomRequestOptions;
|
|
56
|
+
export type RequestOptions = import('./types.js').RequestOptions;
|
|
57
|
+
export type MetaParams = import('./types.js').MetaParams;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{
|
|
3
|
+
* xsrfCookieName?: string,
|
|
4
|
+
* xsrfHeaderName?: string,
|
|
5
|
+
* }} options
|
|
6
|
+
* @returns {import('../index').Plugin}
|
|
7
|
+
*/
|
|
8
|
+
export function xsrfPlugin({ xsrfCookieName, xsrfHeaderName }?: {
|
|
9
|
+
xsrfCookieName?: string;
|
|
10
|
+
xsrfHeaderName?: string;
|
|
11
|
+
}): import('../index').Plugin;
|
|
12
|
+
export const xsrf: import("../types").Plugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export class DialogStateEvent extends Event {
|
|
2
|
+
/**
|
|
3
|
+
* @param {'opening' | 'opened' | 'closing' | 'closed'} kind
|
|
4
|
+
* @param {import('./types.js').Context} context
|
|
5
|
+
*/
|
|
6
|
+
constructor(kind: 'opening' | 'opened' | 'closing' | 'closed', context: import('./types.js').Context);
|
|
7
|
+
context: import("./types.js").Context;
|
|
8
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class Dialog extends EventTarget {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {Config} config
|
|
5
|
+
*/
|
|
6
|
+
constructor(config: Config);
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
opened: Promise<any>;
|
|
9
|
+
__resolveOpened: (value: any) => void;
|
|
10
|
+
closed: Promise<any>;
|
|
11
|
+
__resolveClosed: (value: any) => void;
|
|
12
|
+
/** @type {Context} */
|
|
13
|
+
context: Context;
|
|
14
|
+
/**
|
|
15
|
+
* @returns {DialogNode}
|
|
16
|
+
*/
|
|
17
|
+
__initDialogNode(): DialogNode;
|
|
18
|
+
__onLightDismiss: ({ target }: {
|
|
19
|
+
target: any;
|
|
20
|
+
}) => void;
|
|
21
|
+
close: (kind?: string) => void;
|
|
22
|
+
__onDialogClose: () => Promise<void>;
|
|
23
|
+
__dialog: import("./types.js").DialogNode;
|
|
24
|
+
/**
|
|
25
|
+
* @param {OpenDialogOptions} options
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
open({ id, parameters }: OpenDialogOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Can be used to modify the dialog
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* dialog.modify(node => {node.classList.add('foo')});
|
|
34
|
+
* @param {(dialog: DialogNode | undefined) => void} cb
|
|
35
|
+
*/
|
|
36
|
+
modify(cb: (dialog: DialogNode | undefined) => void): void;
|
|
37
|
+
#private;
|
|
38
|
+
}
|
|
39
|
+
export type DialogNode = import('./types.js').DialogNode;
|
|
40
|
+
export type DialogCallbacks = import('./types.js').DialogCallbacks;
|
|
41
|
+
export type Config = import('./types.js').Config;
|
|
42
|
+
export type OpenDialogOptions = import('./types.js').OpenDialogOptions;
|
|
43
|
+
export type Context = import('./types.js').Context;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function setupGlobalDialogStyles(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `'installable'` event
|
|
3
|
+
* @example pwa.dispatchEvent(new InstallableEvent());
|
|
4
|
+
*/
|
|
5
|
+
export class InstallableEvent extends Event {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `'installed'` event
|
|
10
|
+
* @example pwa.dispatchEvent(new InstalledEvent(installed));
|
|
11
|
+
*/
|
|
12
|
+
export class InstalledEvent extends Event {
|
|
13
|
+
/**
|
|
14
|
+
* @param {boolean} installed
|
|
15
|
+
*/
|
|
16
|
+
constructor(installed: boolean);
|
|
17
|
+
installed: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `'update-available'` event
|
|
21
|
+
* @example pwa.dispatchEvent(new UpdateAvailableEvent());
|
|
22
|
+
*/
|
|
23
|
+
export class UpdateAvailableEvent extends Event {
|
|
24
|
+
constructor();
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type BeforeInstallPromptEvent = Event & {
|
|
2
|
+
prompt(): Promise<void>;
|
|
3
|
+
userChoice: Promise<{
|
|
4
|
+
outcome: 'accepted' | 'dismissed';
|
|
5
|
+
platform: string;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
export const pwa: Pwa;
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Event & {
|
|
11
|
+
* prompt(): Promise<void>,
|
|
12
|
+
* userChoice: Promise<{
|
|
13
|
+
* outcome: 'accepted' | 'dismissed',
|
|
14
|
+
* platform: string
|
|
15
|
+
* }>
|
|
16
|
+
* }} BeforeInstallPromptEvent
|
|
17
|
+
*/
|
|
18
|
+
declare class Pwa extends EventTarget {
|
|
19
|
+
/** @type {boolean} */
|
|
20
|
+
updateAvailable: boolean;
|
|
21
|
+
/** @type {boolean} */
|
|
22
|
+
installable: boolean;
|
|
23
|
+
/** @type {BeforeInstallPromptEvent | undefined} */
|
|
24
|
+
installPrompt: BeforeInstallPromptEvent | undefined;
|
|
25
|
+
/** @type {ServiceWorker | undefined} */
|
|
26
|
+
__waitingServiceWorker: ServiceWorker | undefined;
|
|
27
|
+
isInstalled: boolean;
|
|
28
|
+
/** Triggers the install prompt, when it's available. You can call this method when the `'installable'` event has fired. */
|
|
29
|
+
triggerPrompt: () => Promise<void>;
|
|
30
|
+
/** Update */
|
|
31
|
+
update: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} swPath
|
|
34
|
+
* @param {RegistrationOptions} [opts]
|
|
35
|
+
* @returns {Promise<ServiceWorkerRegistration> | Promise<void>}
|
|
36
|
+
*/
|
|
37
|
+
register(swPath: string, opts?: RegistrationOptions): Promise<ServiceWorkerRegistration> | Promise<void>;
|
|
38
|
+
kill(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./types.js').Plugin} Plugin
|
|
3
|
+
* @typedef {import('./types.js').Context} Context
|
|
4
|
+
* @typedef {import('./types.js').RouteDefinition} RouteDefinition
|
|
5
|
+
* @typedef {import('./types.js').Route} Route
|
|
6
|
+
* @typedef {import('./types.js').Config} Config
|
|
7
|
+
*/
|
|
8
|
+
export class Router extends EventTarget {
|
|
9
|
+
/**
|
|
10
|
+
* @param {Config} config
|
|
11
|
+
*/
|
|
12
|
+
constructor(config: Config);
|
|
13
|
+
context: {
|
|
14
|
+
params: {};
|
|
15
|
+
query: {};
|
|
16
|
+
title: string;
|
|
17
|
+
url: URL;
|
|
18
|
+
};
|
|
19
|
+
config: import("./types.js").Config;
|
|
20
|
+
/** @type {Route[]} */
|
|
21
|
+
routes: Route[];
|
|
22
|
+
uninstall(): void;
|
|
23
|
+
get url(): URL;
|
|
24
|
+
get fallback(): URL;
|
|
25
|
+
get baseUrl(): URL;
|
|
26
|
+
/**
|
|
27
|
+
* @template RenderResult
|
|
28
|
+
* @returns {RenderResult}
|
|
29
|
+
*/
|
|
30
|
+
render<RenderResult>(): RenderResult;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @param {URL} url
|
|
34
|
+
* @returns {Route | null}
|
|
35
|
+
*/
|
|
36
|
+
private _matchRoute;
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
private _notifyUrlChanged;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private _onPopState;
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private _onAnchorClick;
|
|
49
|
+
/**
|
|
50
|
+
* @param {string | URL} url The URL to navigate to.
|
|
51
|
+
* @param {{
|
|
52
|
+
* backNav?: boolean
|
|
53
|
+
* }} options options An options object to configure the navigation. The backNav property specifies whether the navigation is a backward navigation, which doesn't push the navigation into browser nav history.
|
|
54
|
+
*/
|
|
55
|
+
navigate(url: string | URL, options?: {
|
|
56
|
+
backNav?: boolean;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
route: import("./types.js").Route;
|
|
59
|
+
}
|
|
60
|
+
export type Plugin = import('./types.js').Plugin;
|
|
61
|
+
export type Context = import('./types.js').Context;
|
|
62
|
+
export type RouteDefinition = import('./types.js').RouteDefinition;
|
|
63
|
+
export type Route = import('./types.js').Route;
|
|
64
|
+
export type Config = import('./types.js').Config;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example offlinePlugin('/my-offline-page')
|
|
3
|
+
* @param {string} offlineRoute
|
|
4
|
+
* @returns {import('../index.js').Plugin}
|
|
5
|
+
*/
|
|
6
|
+
export function offlinePlugin(offlineRoute?: string): import('../index.js').Plugin;
|
|
7
|
+
export const offline: import("../types.js").Plugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `'state-changed'` event
|
|
3
|
+
* @example this.dispatchEvent(new StateEvent(data));
|
|
4
|
+
*/
|
|
5
|
+
export class StateEvent extends Event {
|
|
6
|
+
constructor(state?: {});
|
|
7
|
+
state: {};
|
|
8
|
+
}
|
|
9
|
+
export class State extends EventTarget {
|
|
10
|
+
constructor(initialState: any);
|
|
11
|
+
setState(state: any): void;
|
|
12
|
+
getState(): any;
|
|
13
|
+
#private;
|
|
14
|
+
}
|
|
15
|
+
export const state: State;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function createService(defaults: any): {
|
|
2
|
+
new (host: any, promise: any): {
|
|
3
|
+
host: any;
|
|
4
|
+
promise: any;
|
|
5
|
+
state: string;
|
|
6
|
+
setPromise(promise: any): void;
|
|
7
|
+
setError(msg: any): void;
|
|
8
|
+
errorMessage: any;
|
|
9
|
+
request(params: any): any;
|
|
10
|
+
data: any;
|
|
11
|
+
/**
|
|
12
|
+
* Use states individually, useful if you may need to render stuff in different locations
|
|
13
|
+
*/
|
|
14
|
+
initialized(templateFn: any): any;
|
|
15
|
+
pending(templateFn: any): any;
|
|
16
|
+
success(templateFn: any): any;
|
|
17
|
+
error(templateFn: any): any;
|
|
18
|
+
/**
|
|
19
|
+
* Combined render method, if you want to just render everything in place
|
|
20
|
+
*/
|
|
21
|
+
render(templates: any): any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function debounce(f: any, scheduleTask: any, cancelTask: any): (...args: any[]) => void;
|
|
2
|
+
/**
|
|
3
|
+
* @param {() => void} f
|
|
4
|
+
* @param {number} ms
|
|
5
|
+
* @param {{
|
|
6
|
+
* signal?: AbortSignal
|
|
7
|
+
* }} options
|
|
8
|
+
*/
|
|
9
|
+
export function setAbortableTimeout(f: () => void, ms: number, { signal }: {
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}): void;
|
|
12
|
+
/**
|
|
13
|
+
* @param {() => boolean} predicate
|
|
14
|
+
* @param {{
|
|
15
|
+
* timeout?: number,
|
|
16
|
+
* message?: string,
|
|
17
|
+
* interval?: number
|
|
18
|
+
* }} options
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
export function waitUntil(predicate: () => boolean, options?: {
|
|
22
|
+
timeout?: number;
|
|
23
|
+
message?: string;
|
|
24
|
+
interval?: number;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export function debounceAtTimeout(f: any, ms: any): (...args: any[]) => void;
|
|
27
|
+
export function debounceAtFrame(f: any): (...args: any[]) => void;
|
|
28
|
+
export function onePaint(): Promise<number>;
|
|
29
|
+
export function animationsComplete(element: HTMLElement): Promise<PromiseSettledResult<Animation>[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax sugar to conditionally render a template
|
|
3
|
+
*
|
|
4
|
+
* @param {boolean} expression
|
|
5
|
+
* @param {() => any} trueValue
|
|
6
|
+
* @param {() => any} [falseValue]
|
|
7
|
+
* @returns {any | undefined}
|
|
8
|
+
*/
|
|
9
|
+
export function when(expression: boolean, trueValue: () => any, falseValue?: () => any): any | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export namespace KEYCODES {
|
|
2
|
+
const TAB: number;
|
|
3
|
+
const ENTER: number;
|
|
4
|
+
const SHIFT: number;
|
|
5
|
+
const ESC: number;
|
|
6
|
+
const SPACE: number;
|
|
7
|
+
const END: number;
|
|
8
|
+
const HOME: number;
|
|
9
|
+
const LEFT: number;
|
|
10
|
+
const UP: number;
|
|
11
|
+
const RIGHT: number;
|
|
12
|
+
const DOWN: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {boolean} value
|
|
3
|
+
*/
|
|
4
|
+
export function setDebug(value: boolean): void;
|
|
5
|
+
/**
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
export function getDebug(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} action - describing the action
|
|
11
|
+
* @param {*} [data] - any js value
|
|
12
|
+
*/
|
|
13
|
+
export function log(action: string, data?: any): void;
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} title
|
|
16
|
+
* @returns {(action: string, data?: any) => void}
|
|
17
|
+
*/
|
|
18
|
+
export function createLogger(title: string): (action: string, data?: any) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export namespace media {
|
|
2
|
+
namespace MIN {
|
|
3
|
+
function XXXL(callback: any): boolean | (() => void);
|
|
4
|
+
function XXL(callback: any): boolean | (() => void);
|
|
5
|
+
function XL(callback: any): boolean | (() => void);
|
|
6
|
+
function LG(callback: any): boolean | (() => void);
|
|
7
|
+
function MD(callback: any): boolean | (() => void);
|
|
8
|
+
function SM(callback: any): boolean | (() => void);
|
|
9
|
+
function XS(callback: any): boolean | (() => void);
|
|
10
|
+
function XXS(callback: any): boolean | (() => void);
|
|
11
|
+
function XXXS(callback: any): boolean | (() => void);
|
|
12
|
+
}
|
|
13
|
+
namespace MAX {
|
|
14
|
+
export function XXXL_1(callback: any): boolean | (() => void);
|
|
15
|
+
export { XXXL_1 as XXXL };
|
|
16
|
+
export function XXL_1(callback: any): boolean | (() => void);
|
|
17
|
+
export { XXL_1 as XXL };
|
|
18
|
+
export function XL_1(callback: any): boolean | (() => void);
|
|
19
|
+
export { XL_1 as XL };
|
|
20
|
+
export function LG_1(callback: any): boolean | (() => void);
|
|
21
|
+
export { LG_1 as LG };
|
|
22
|
+
export function MD_1(callback: any): boolean | (() => void);
|
|
23
|
+
export { MD_1 as MD };
|
|
24
|
+
export function SM_1(callback: any): boolean | (() => void);
|
|
25
|
+
export { SM_1 as SM };
|
|
26
|
+
export function XS_1(callback: any): boolean | (() => void);
|
|
27
|
+
export { XS_1 as XS };
|
|
28
|
+
export function XXS_1(callback: any): boolean | (() => void);
|
|
29
|
+
export { XXS_1 as XXS };
|
|
30
|
+
export function XXXS_1(callback: any): boolean | (() => void);
|
|
31
|
+
export { XXXS_1 as XXXS };
|
|
32
|
+
}
|
|
33
|
+
function STANDALONE(callback: any): boolean | (() => void);
|
|
34
|
+
function REDUCED_MOTION(callback: any): boolean | (() => void);
|
|
35
|
+
function DARK_MODE(callback: any): boolean | (() => void);
|
|
36
|
+
function LIGHT_MODE(callback: any): boolean | (() => void);
|
|
37
|
+
}
|
package/api/types.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export type ResponseType = 'text'|'json'|'stream'|'blob'|'arrayBuffer'|'formData'|'stream';
|
|
2
|
-
|
|
3
|
-
export interface Config {
|
|
4
|
-
plugins?: Plugin[];
|
|
5
|
-
responseType?: ResponseType;
|
|
6
|
-
baseURL?: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type BodyMethod<R> = (url: string, data?: object, opts?: RequestOptions) => Promise<R>;
|
|
10
|
-
export type BodylessMethod<R> = (url: string, opts?: RequestOptions) => Promise<R>;
|
|
11
|
-
|
|
12
|
-
export type Method = 'GET'|'DELETE'|'HEAD'|'OPTIONS'|'POST'|'PUT'|'PATCH';
|
|
13
|
-
|
|
14
|
-
export interface Plugin {
|
|
15
|
-
beforeFetch?: (meta: MetaParams) => MetaParams | Promise<MetaParams> | void;
|
|
16
|
-
afterFetch?: (res: Response) => void | Promise<void> | Response | Promise<Response>;
|
|
17
|
-
transform?: (data: any) => any;
|
|
18
|
-
name: string;
|
|
19
|
-
handleError?: (e: Error) => boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface CustomRequestOptions {
|
|
23
|
-
transform?: (data: object) => object;
|
|
24
|
-
responseType?: ResponseType;
|
|
25
|
-
params?: Record<string, string>;
|
|
26
|
-
plugins?: Plugin[];
|
|
27
|
-
baseURL?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type RequestOptions = RequestInit & CustomRequestOptions;
|
|
31
|
-
|
|
32
|
-
export interface MetaParams {
|
|
33
|
-
responseType: string;
|
|
34
|
-
baseURL: string;
|
|
35
|
-
url: string;
|
|
36
|
-
method: Method;
|
|
37
|
-
headers: Headers;
|
|
38
|
-
opts?: RequestOptions;
|
|
39
|
-
data?: any;
|
|
40
|
-
fetchFn: typeof globalThis.fetch;
|
|
41
|
-
}
|
package/dialog/types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type DialogNode = HTMLDialogElement & { form: HTMLFormElement };
|
|
2
|
-
|
|
3
|
-
export interface DialogCallbacks {
|
|
4
|
-
opening?: <Parameters>(context: Context) => void;
|
|
5
|
-
opened?: <Parameters>(context: Context) => void;
|
|
6
|
-
closing?: (context: Context) => void;
|
|
7
|
-
closed?: (context: Context) => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type Config = Record<string, DialogCallbacks>;
|
|
11
|
-
|
|
12
|
-
export interface OpenDialogOptions {
|
|
13
|
-
id: string;
|
|
14
|
-
parameters?: object;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface Context {
|
|
18
|
-
dialog: DialogNode | undefined,
|
|
19
|
-
id: string,
|
|
20
|
-
parameters?: Record<string, any>
|
|
21
|
-
}
|
package/router/types.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface Config {
|
|
2
|
-
fallback?: string;
|
|
3
|
-
plugins?: Plugin[];
|
|
4
|
-
routes: RouteDefinition[];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface Plugin {
|
|
8
|
-
name: string;
|
|
9
|
-
shouldNavigate?: (context: Context) => {
|
|
10
|
-
redirect: string,
|
|
11
|
-
condition: () => boolean | (() => Promise<Boolean>),
|
|
12
|
-
};
|
|
13
|
-
beforeNavigation?: (context: Context) => void;
|
|
14
|
-
afterNavigation?: (context: Context) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface Context {
|
|
18
|
-
title?: string;
|
|
19
|
-
query: Record<string, string>;
|
|
20
|
-
params: Record<string, string>;
|
|
21
|
-
url: URL;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type Render<RenderResult> = (context: Context) => RenderResult;
|
|
26
|
-
|
|
27
|
-
export interface RouteDefinition {
|
|
28
|
-
path: string;
|
|
29
|
-
title: string | ((context: Partial<Context>) => string);
|
|
30
|
-
render?: Render<RenderResult>;
|
|
31
|
-
plugins?: Plugin[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** @TODO URLPattern type */
|
|
35
|
-
export type Route = RouteDefinition & { urlPattern?: any };
|