mokup 2.0.2 → 2.1.0
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/cli-bin.cjs +3 -1
- package/dist/cli-bin.mjs +3 -1
- package/dist/index.cjs +39 -0
- package/dist/index.d.cts +62 -44
- package/dist/index.d.mts +62 -44
- package/dist/index.d.ts +64 -44
- package/dist/index.mjs +37 -0
- package/dist/server/worker.d.ts +2 -0
- package/dist/shared/{mokup.jeVwRMia.mjs → mokup.Bp9u3JKA.mjs} +1630 -1220
- package/dist/shared/mokup.CWQ8woZc.d.cts +302 -0
- package/dist/shared/mokup.CWQ8woZc.d.mts +302 -0
- package/dist/shared/mokup.CWQ8woZc.d.ts +302 -0
- package/dist/shared/{mokup.B-yfMz5B.cjs → mokup.i875Kuim.cjs} +1630 -1220
- package/dist/sw.cjs +5 -2
- package/dist/sw.d.cts +63 -0
- package/dist/sw.d.mts +63 -0
- package/dist/sw.d.ts +63 -0
- package/dist/sw.mjs +5 -2
- package/dist/types/virtual.d.ts +9 -0
- package/dist/vite.cjs +645 -347
- package/dist/vite.d.cts +20 -2
- package/dist/vite.d.mts +20 -2
- package/dist/vite.d.ts +22 -2
- package/dist/vite.mjs +637 -340
- package/dist/webpack.cjs +276 -204
- package/dist/webpack.d.cts +36 -4
- package/dist/webpack.d.mts +37 -3
- package/dist/webpack.d.ts +36 -4
- package/dist/webpack.mjs +272 -197
- package/package.json +7 -6
package/dist/sw.cjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const logger$1 = require('@mokup/shared/logger');
|
|
4
|
+
|
|
3
5
|
const defaultSwPath = "/mokup-sw.js";
|
|
4
6
|
const defaultSwScope = "/";
|
|
7
|
+
const logger = logger$1.createLogger();
|
|
5
8
|
function normalizeSwPath(path) {
|
|
6
9
|
if (!path) {
|
|
7
10
|
return defaultSwPath;
|
|
@@ -44,7 +47,7 @@ async function registerMokupServiceWorker(options = {}) {
|
|
|
44
47
|
scope
|
|
45
48
|
});
|
|
46
49
|
} catch (error) {
|
|
47
|
-
|
|
50
|
+
logger.warn("Failed to register service worker:", error);
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
@@ -81,7 +84,7 @@ async function unregisterMokupServiceWorker(options = {}) {
|
|
|
81
84
|
}
|
|
82
85
|
return removed;
|
|
83
86
|
} catch (error) {
|
|
84
|
-
|
|
87
|
+
logger.warn("Failed to unregister service worker:", error);
|
|
85
88
|
return [];
|
|
86
89
|
}
|
|
87
90
|
}
|
package/dist/sw.d.cts
CHANGED
|
@@ -1,13 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for registering the mokup service worker.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import type { ServiceWorkerRegisterOptions } from 'mokup/sw'
|
|
6
|
+
*
|
|
7
|
+
* const options: ServiceWorkerRegisterOptions = { path: '/mokup-sw.js' }
|
|
8
|
+
*/
|
|
1
9
|
interface ServiceWorkerRegisterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Service worker script path.
|
|
12
|
+
*
|
|
13
|
+
* @default "/mokup-sw.js"
|
|
14
|
+
*/
|
|
2
15
|
path?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Service worker scope.
|
|
18
|
+
*
|
|
19
|
+
* @default "/"
|
|
20
|
+
*/
|
|
3
21
|
scope?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Toggle registration.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
4
27
|
enabled?: boolean;
|
|
5
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for unregistering the mokup service worker.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import type { ServiceWorkerUnregisterOptions } from 'mokup/sw'
|
|
34
|
+
*
|
|
35
|
+
* const options: ServiceWorkerUnregisterOptions = { path: '/mokup-sw.js' }
|
|
36
|
+
*/
|
|
6
37
|
interface ServiceWorkerUnregisterOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Service worker script path.
|
|
40
|
+
*
|
|
41
|
+
* @default "/mokup-sw.js"
|
|
42
|
+
*/
|
|
7
43
|
path?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Service worker scope.
|
|
46
|
+
*
|
|
47
|
+
* @default "/"
|
|
48
|
+
*/
|
|
8
49
|
scope?: string;
|
|
9
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Register the mokup service worker in the browser.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Registration options.
|
|
55
|
+
* @returns The registration or null if unsupported.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { registerMokupServiceWorker } from 'mokup/sw'
|
|
59
|
+
*
|
|
60
|
+
* await registerMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
61
|
+
*/
|
|
10
62
|
declare function registerMokupServiceWorker(options?: ServiceWorkerRegisterOptions): Promise<ServiceWorkerRegistration | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Unregister matching mokup service worker registrations.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Unregister options.
|
|
67
|
+
* @returns List of removed registrations.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* import { unregisterMokupServiceWorker } from 'mokup/sw'
|
|
71
|
+
*
|
|
72
|
+
* await unregisterMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
73
|
+
*/
|
|
11
74
|
declare function unregisterMokupServiceWorker(options?: ServiceWorkerUnregisterOptions): Promise<ServiceWorkerRegistration[]>;
|
|
12
75
|
|
|
13
76
|
export { registerMokupServiceWorker, unregisterMokupServiceWorker };
|
package/dist/sw.d.mts
CHANGED
|
@@ -1,13 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for registering the mokup service worker.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import type { ServiceWorkerRegisterOptions } from 'mokup/sw'
|
|
6
|
+
*
|
|
7
|
+
* const options: ServiceWorkerRegisterOptions = { path: '/mokup-sw.js' }
|
|
8
|
+
*/
|
|
1
9
|
interface ServiceWorkerRegisterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Service worker script path.
|
|
12
|
+
*
|
|
13
|
+
* @default "/mokup-sw.js"
|
|
14
|
+
*/
|
|
2
15
|
path?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Service worker scope.
|
|
18
|
+
*
|
|
19
|
+
* @default "/"
|
|
20
|
+
*/
|
|
3
21
|
scope?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Toggle registration.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
4
27
|
enabled?: boolean;
|
|
5
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for unregistering the mokup service worker.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import type { ServiceWorkerUnregisterOptions } from 'mokup/sw'
|
|
34
|
+
*
|
|
35
|
+
* const options: ServiceWorkerUnregisterOptions = { path: '/mokup-sw.js' }
|
|
36
|
+
*/
|
|
6
37
|
interface ServiceWorkerUnregisterOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Service worker script path.
|
|
40
|
+
*
|
|
41
|
+
* @default "/mokup-sw.js"
|
|
42
|
+
*/
|
|
7
43
|
path?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Service worker scope.
|
|
46
|
+
*
|
|
47
|
+
* @default "/"
|
|
48
|
+
*/
|
|
8
49
|
scope?: string;
|
|
9
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Register the mokup service worker in the browser.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Registration options.
|
|
55
|
+
* @returns The registration or null if unsupported.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { registerMokupServiceWorker } from 'mokup/sw'
|
|
59
|
+
*
|
|
60
|
+
* await registerMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
61
|
+
*/
|
|
10
62
|
declare function registerMokupServiceWorker(options?: ServiceWorkerRegisterOptions): Promise<ServiceWorkerRegistration | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Unregister matching mokup service worker registrations.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Unregister options.
|
|
67
|
+
* @returns List of removed registrations.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* import { unregisterMokupServiceWorker } from 'mokup/sw'
|
|
71
|
+
*
|
|
72
|
+
* await unregisterMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
73
|
+
*/
|
|
11
74
|
declare function unregisterMokupServiceWorker(options?: ServiceWorkerUnregisterOptions): Promise<ServiceWorkerRegistration[]>;
|
|
12
75
|
|
|
13
76
|
export { registerMokupServiceWorker, unregisterMokupServiceWorker };
|
package/dist/sw.d.ts
CHANGED
|
@@ -1,13 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for registering the mokup service worker.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import type { ServiceWorkerRegisterOptions } from 'mokup/sw'
|
|
6
|
+
*
|
|
7
|
+
* const options: ServiceWorkerRegisterOptions = { path: '/mokup-sw.js' }
|
|
8
|
+
*/
|
|
1
9
|
interface ServiceWorkerRegisterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Service worker script path.
|
|
12
|
+
*
|
|
13
|
+
* @default "/mokup-sw.js"
|
|
14
|
+
*/
|
|
2
15
|
path?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Service worker scope.
|
|
18
|
+
*
|
|
19
|
+
* @default "/"
|
|
20
|
+
*/
|
|
3
21
|
scope?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Toggle registration.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
4
27
|
enabled?: boolean;
|
|
5
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for unregistering the mokup service worker.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import type { ServiceWorkerUnregisterOptions } from 'mokup/sw'
|
|
34
|
+
*
|
|
35
|
+
* const options: ServiceWorkerUnregisterOptions = { path: '/mokup-sw.js' }
|
|
36
|
+
*/
|
|
6
37
|
interface ServiceWorkerUnregisterOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Service worker script path.
|
|
40
|
+
*
|
|
41
|
+
* @default "/mokup-sw.js"
|
|
42
|
+
*/
|
|
7
43
|
path?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Service worker scope.
|
|
46
|
+
*
|
|
47
|
+
* @default "/"
|
|
48
|
+
*/
|
|
8
49
|
scope?: string;
|
|
9
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Register the mokup service worker in the browser.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Registration options.
|
|
55
|
+
* @returns The registration or null if unsupported.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { registerMokupServiceWorker } from 'mokup/sw'
|
|
59
|
+
*
|
|
60
|
+
* await registerMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
61
|
+
*/
|
|
10
62
|
declare function registerMokupServiceWorker(options?: ServiceWorkerRegisterOptions): Promise<ServiceWorkerRegistration | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Unregister matching mokup service worker registrations.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Unregister options.
|
|
67
|
+
* @returns List of removed registrations.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* import { unregisterMokupServiceWorker } from 'mokup/sw'
|
|
71
|
+
*
|
|
72
|
+
* await unregisterMokupServiceWorker({ path: '/mokup-sw.js' })
|
|
73
|
+
*/
|
|
11
74
|
declare function unregisterMokupServiceWorker(options?: ServiceWorkerUnregisterOptions): Promise<ServiceWorkerRegistration[]>;
|
|
12
75
|
|
|
13
76
|
export { registerMokupServiceWorker, unregisterMokupServiceWorker };
|
package/dist/sw.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { createLogger } from '@mokup/shared/logger';
|
|
2
|
+
|
|
1
3
|
const defaultSwPath = "/mokup-sw.js";
|
|
2
4
|
const defaultSwScope = "/";
|
|
5
|
+
const logger = createLogger();
|
|
3
6
|
function normalizeSwPath(path) {
|
|
4
7
|
if (!path) {
|
|
5
8
|
return defaultSwPath;
|
|
@@ -42,7 +45,7 @@ async function registerMokupServiceWorker(options = {}) {
|
|
|
42
45
|
scope
|
|
43
46
|
});
|
|
44
47
|
} catch (error) {
|
|
45
|
-
|
|
48
|
+
logger.warn("Failed to register service worker:", error);
|
|
46
49
|
return null;
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -79,7 +82,7 @@ async function unregisterMokupServiceWorker(options = {}) {
|
|
|
79
82
|
}
|
|
80
83
|
return removed;
|
|
81
84
|
} catch (error) {
|
|
82
|
-
|
|
85
|
+
logger.warn("Failed to unregister service worker:", error);
|
|
83
86
|
return [];
|
|
84
87
|
}
|
|
85
88
|
}
|