miragedev-sdk 0.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/LICENSE +21 -0
- package/README.md +393 -0
- package/dist/auth/biometric.cjs +85 -0
- package/dist/auth/biometric.d.cts +7 -0
- package/dist/auth/biometric.d.ts +7 -0
- package/dist/auth/biometric.js +81 -0
- package/dist/auth/client.cjs +44 -0
- package/dist/auth/client.d.cts +12 -0
- package/dist/auth/client.d.ts +12 -0
- package/dist/auth/client.js +40 -0
- package/dist/auth/index.cjs +17 -0
- package/dist/auth/index.d.cts +6 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/middleware.cjs +37 -0
- package/dist/auth/middleware.d.cts +10 -0
- package/dist/auth/middleware.d.ts +10 -0
- package/dist/auth/middleware.js +35 -0
- package/dist/auth-BC8JI28z.d.cts +22 -0
- package/dist/auth-BC8JI28z.d.ts +22 -0
- package/dist/billing/client.cjs +43 -0
- package/dist/billing/client.d.cts +11 -0
- package/dist/billing/client.d.ts +11 -0
- package/dist/billing/client.js +40 -0
- package/dist/billing/index.cjs +139 -0
- package/dist/billing/index.d.cts +12 -0
- package/dist/billing/index.d.ts +12 -0
- package/dist/billing/index.js +130 -0
- package/dist/billing/mobile.cjs +81 -0
- package/dist/billing/mobile.d.cts +17 -0
- package/dist/billing/mobile.d.ts +17 -0
- package/dist/billing/mobile.js +74 -0
- package/dist/billing/webhook.cjs +84 -0
- package/dist/billing/webhook.d.cts +19 -0
- package/dist/billing/webhook.d.ts +19 -0
- package/dist/billing/webhook.js +78 -0
- package/dist/billing-Bv2V7KWF.d.cts +23 -0
- package/dist/billing-Bv2V7KWF.d.ts +23 -0
- package/dist/chunk-5YXI4Q2K.js +13813 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-BW4BLEIM.cjs +18 -0
- package/dist/chunk-DZDDLA4G.js +271 -0
- package/dist/chunk-E5YC2MHX.cjs +13816 -0
- package/dist/chunk-JUTTFY3W.js +16 -0
- package/dist/chunk-M26EDKMY.cjs +280 -0
- package/dist/chunk-M3DPIKWT.js +23 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PHTUPKEM.cjs +26 -0
- package/dist/cli/commands/init.cjs +11 -0
- package/dist/cli/commands/init.d.cts +3 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.js +2 -0
- package/dist/cli/index.cjs +11 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/email/index.cjs +526 -0
- package/dist/email/index.d.cts +6 -0
- package/dist/email/index.d.ts +6 -0
- package/dist/email/index.js +523 -0
- package/dist/email-DZN1-bHa.d.cts +19 -0
- package/dist/email-DZN1-bHa.d.ts +19 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +21 -0
- package/dist/mobile/index.cjs +101 -0
- package/dist/mobile/index.d.cts +15 -0
- package/dist/mobile/index.d.ts +15 -0
- package/dist/mobile/index.js +96 -0
- package/dist/pwa/index.cjs +80 -0
- package/dist/pwa/index.d.cts +51 -0
- package/dist/pwa/index.d.ts +51 -0
- package/dist/pwa/index.js +76 -0
- package/package.json +140 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../chunk-75ZPJI57.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
function useNetworkStatus() {
|
|
7
|
+
const [isOnline, setIsOnline] = react.useState(
|
|
8
|
+
typeof window !== "undefined" ? window.navigator.onLine : true
|
|
9
|
+
);
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
const handleOnline = () => setIsOnline(true);
|
|
12
|
+
const handleOffline = () => setIsOnline(false);
|
|
13
|
+
window.addEventListener("online", handleOnline);
|
|
14
|
+
window.addEventListener("offline", handleOffline);
|
|
15
|
+
return () => {
|
|
16
|
+
window.removeEventListener("online", handleOnline);
|
|
17
|
+
window.removeEventListener("offline", handleOffline);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return isOnline;
|
|
21
|
+
}
|
|
22
|
+
function useInstallPrompt() {
|
|
23
|
+
const [installPrompt, setInstallPrompt] = react.useState(null);
|
|
24
|
+
const [canInstall, setCanInstall] = react.useState(false);
|
|
25
|
+
react.useEffect(() => {
|
|
26
|
+
const handleBeforeInstallPrompt = (e) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
setInstallPrompt(e);
|
|
29
|
+
setCanInstall(true);
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener("beforeinstallprompt", handleBeforeInstallPrompt);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener("beforeinstallprompt", handleBeforeInstallPrompt);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
const promptInstall = react.useCallback(async () => {
|
|
37
|
+
if (!installPrompt) return;
|
|
38
|
+
installPrompt.prompt();
|
|
39
|
+
const result = await installPrompt.userChoice;
|
|
40
|
+
if (result.outcome === "accepted") {
|
|
41
|
+
setCanInstall(false);
|
|
42
|
+
setInstallPrompt(null);
|
|
43
|
+
}
|
|
44
|
+
}, [installPrompt]);
|
|
45
|
+
return { canInstall, promptInstall };
|
|
46
|
+
}
|
|
47
|
+
function useNotifications() {
|
|
48
|
+
const [permission, setPermission] = react.useState(
|
|
49
|
+
typeof window !== "undefined" && "Notification" in window ? Notification.permission : "default"
|
|
50
|
+
);
|
|
51
|
+
const requestPermission = react.useCallback(async () => {
|
|
52
|
+
if (!("Notification" in window)) {
|
|
53
|
+
console.warn("Notifications not supported");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const result = await Notification.requestPermission();
|
|
57
|
+
setPermission(result);
|
|
58
|
+
}, []);
|
|
59
|
+
const sendNotification = react.useCallback((title, options) => {
|
|
60
|
+
if (permission === "granted") {
|
|
61
|
+
new Notification(title, options);
|
|
62
|
+
}
|
|
63
|
+
}, [permission]);
|
|
64
|
+
return { permission, requestPermission, sendNotification };
|
|
65
|
+
}
|
|
66
|
+
function usePullToRefresh(onRefresh) {
|
|
67
|
+
const [isRefreshing, setIsRefreshing] = react.useState(false);
|
|
68
|
+
react.useEffect(() => {
|
|
69
|
+
let touchStartY = 0;
|
|
70
|
+
const handleTouchStart = (e) => {
|
|
71
|
+
touchStartY = e.touches[0].clientY;
|
|
72
|
+
};
|
|
73
|
+
const handleTouchMove = (e) => {
|
|
74
|
+
const touchY = e.touches[0].clientY;
|
|
75
|
+
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
76
|
+
if (scrollTop === 0 && touchY > touchStartY + 50 && !isRefreshing) {
|
|
77
|
+
handleRefresh();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const handleRefresh = async () => {
|
|
81
|
+
setIsRefreshing(true);
|
|
82
|
+
try {
|
|
83
|
+
await onRefresh();
|
|
84
|
+
} finally {
|
|
85
|
+
setIsRefreshing(false);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
window.addEventListener("touchstart", handleTouchStart, { passive: true });
|
|
89
|
+
window.addEventListener("touchmove", handleTouchMove, { passive: true });
|
|
90
|
+
return () => {
|
|
91
|
+
window.removeEventListener("touchstart", handleTouchStart);
|
|
92
|
+
window.removeEventListener("touchmove", handleTouchMove);
|
|
93
|
+
};
|
|
94
|
+
}, [onRefresh, isRefreshing]);
|
|
95
|
+
return { isRefreshing };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.useInstallPrompt = useInstallPrompt;
|
|
99
|
+
exports.useNetworkStatus = useNetworkStatus;
|
|
100
|
+
exports.useNotifications = useNotifications;
|
|
101
|
+
exports.usePullToRefresh = usePullToRefresh;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function useNetworkStatus(): boolean;
|
|
2
|
+
declare function useInstallPrompt(): {
|
|
3
|
+
canInstall: boolean;
|
|
4
|
+
promptInstall: () => Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
declare function useNotifications(): {
|
|
7
|
+
permission: NotificationPermission;
|
|
8
|
+
requestPermission: () => Promise<void>;
|
|
9
|
+
sendNotification: (title: string, options?: NotificationOptions) => void;
|
|
10
|
+
};
|
|
11
|
+
declare function usePullToRefresh(onRefresh: () => Promise<void>): {
|
|
12
|
+
isRefreshing: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useInstallPrompt, useNetworkStatus, useNotifications, usePullToRefresh };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function useNetworkStatus(): boolean;
|
|
2
|
+
declare function useInstallPrompt(): {
|
|
3
|
+
canInstall: boolean;
|
|
4
|
+
promptInstall: () => Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
declare function useNotifications(): {
|
|
7
|
+
permission: NotificationPermission;
|
|
8
|
+
requestPermission: () => Promise<void>;
|
|
9
|
+
sendNotification: (title: string, options?: NotificationOptions) => void;
|
|
10
|
+
};
|
|
11
|
+
declare function usePullToRefresh(onRefresh: () => Promise<void>): {
|
|
12
|
+
isRefreshing: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useInstallPrompt, useNetworkStatus, useNotifications, usePullToRefresh };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import '../chunk-MLKGABMK.js';
|
|
2
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
function useNetworkStatus() {
|
|
5
|
+
const [isOnline, setIsOnline] = useState(
|
|
6
|
+
typeof window !== "undefined" ? window.navigator.onLine : true
|
|
7
|
+
);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const handleOnline = () => setIsOnline(true);
|
|
10
|
+
const handleOffline = () => setIsOnline(false);
|
|
11
|
+
window.addEventListener("online", handleOnline);
|
|
12
|
+
window.addEventListener("offline", handleOffline);
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener("online", handleOnline);
|
|
15
|
+
window.removeEventListener("offline", handleOffline);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return isOnline;
|
|
19
|
+
}
|
|
20
|
+
function useInstallPrompt() {
|
|
21
|
+
const [installPrompt, setInstallPrompt] = useState(null);
|
|
22
|
+
const [canInstall, setCanInstall] = useState(false);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const handleBeforeInstallPrompt = (e) => {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
setInstallPrompt(e);
|
|
27
|
+
setCanInstall(true);
|
|
28
|
+
};
|
|
29
|
+
window.addEventListener("beforeinstallprompt", handleBeforeInstallPrompt);
|
|
30
|
+
return () => {
|
|
31
|
+
window.removeEventListener("beforeinstallprompt", handleBeforeInstallPrompt);
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
const promptInstall = useCallback(async () => {
|
|
35
|
+
if (!installPrompt) return;
|
|
36
|
+
installPrompt.prompt();
|
|
37
|
+
const result = await installPrompt.userChoice;
|
|
38
|
+
if (result.outcome === "accepted") {
|
|
39
|
+
setCanInstall(false);
|
|
40
|
+
setInstallPrompt(null);
|
|
41
|
+
}
|
|
42
|
+
}, [installPrompt]);
|
|
43
|
+
return { canInstall, promptInstall };
|
|
44
|
+
}
|
|
45
|
+
function useNotifications() {
|
|
46
|
+
const [permission, setPermission] = useState(
|
|
47
|
+
typeof window !== "undefined" && "Notification" in window ? Notification.permission : "default"
|
|
48
|
+
);
|
|
49
|
+
const requestPermission = useCallback(async () => {
|
|
50
|
+
if (!("Notification" in window)) {
|
|
51
|
+
console.warn("Notifications not supported");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const result = await Notification.requestPermission();
|
|
55
|
+
setPermission(result);
|
|
56
|
+
}, []);
|
|
57
|
+
const sendNotification = useCallback((title, options) => {
|
|
58
|
+
if (permission === "granted") {
|
|
59
|
+
new Notification(title, options);
|
|
60
|
+
}
|
|
61
|
+
}, [permission]);
|
|
62
|
+
return { permission, requestPermission, sendNotification };
|
|
63
|
+
}
|
|
64
|
+
function usePullToRefresh(onRefresh) {
|
|
65
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let touchStartY = 0;
|
|
68
|
+
const handleTouchStart = (e) => {
|
|
69
|
+
touchStartY = e.touches[0].clientY;
|
|
70
|
+
};
|
|
71
|
+
const handleTouchMove = (e) => {
|
|
72
|
+
const touchY = e.touches[0].clientY;
|
|
73
|
+
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
74
|
+
if (scrollTop === 0 && touchY > touchStartY + 50 && !isRefreshing) {
|
|
75
|
+
handleRefresh();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const handleRefresh = async () => {
|
|
79
|
+
setIsRefreshing(true);
|
|
80
|
+
try {
|
|
81
|
+
await onRefresh();
|
|
82
|
+
} finally {
|
|
83
|
+
setIsRefreshing(false);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
window.addEventListener("touchstart", handleTouchStart, { passive: true });
|
|
87
|
+
window.addEventListener("touchmove", handleTouchMove, { passive: true });
|
|
88
|
+
return () => {
|
|
89
|
+
window.removeEventListener("touchstart", handleTouchStart);
|
|
90
|
+
window.removeEventListener("touchmove", handleTouchMove);
|
|
91
|
+
};
|
|
92
|
+
}, [onRefresh, isRefreshing]);
|
|
93
|
+
return { isRefreshing };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { useInstallPrompt, useNetworkStatus, useNotifications, usePullToRefresh };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../chunk-75ZPJI57.cjs');
|
|
4
|
+
|
|
5
|
+
// src/pwa/index.ts
|
|
6
|
+
function generateManifest(options) {
|
|
7
|
+
return {
|
|
8
|
+
name: options.name,
|
|
9
|
+
short_name: options.shortName || options.name,
|
|
10
|
+
description: options.description || "",
|
|
11
|
+
start_url: options.startUrl || "/",
|
|
12
|
+
display: "standalone",
|
|
13
|
+
background_color: options.backgroundColor || "#ffffff",
|
|
14
|
+
theme_color: options.theme || "#000000",
|
|
15
|
+
icons: options.icons || [
|
|
16
|
+
{
|
|
17
|
+
src: "/icon-192.png",
|
|
18
|
+
sizes: "192x192",
|
|
19
|
+
type: "image/png"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
src: "/icon-512.png",
|
|
23
|
+
sizes: "512x512",
|
|
24
|
+
type: "image/png"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function generateServiceWorker(options) {
|
|
30
|
+
const cacheName = `${options.name.toLowerCase().replace(/\s+/g, "-")}-v1`;
|
|
31
|
+
const offlinePages = options.offline?.pages || ["/"];
|
|
32
|
+
return `
|
|
33
|
+
const CACHE_NAME = '${cacheName}';
|
|
34
|
+
const OFFLINE_PAGES = ${JSON.stringify(offlinePages)};
|
|
35
|
+
|
|
36
|
+
self.addEventListener('install', (event) => {
|
|
37
|
+
event.waitUntil(
|
|
38
|
+
caches.open(CACHE_NAME).then((cache) => {
|
|
39
|
+
return cache.addAll(OFFLINE_PAGES);
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
self.skipWaiting();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
self.addEventListener('activate', (event) => {
|
|
46
|
+
event.waitUntil(
|
|
47
|
+
caches.keys().then((cacheNames) => {
|
|
48
|
+
return Promise.all(
|
|
49
|
+
cacheNames.map((cacheName) => {
|
|
50
|
+
if (cacheName !== CACHE_NAME) {
|
|
51
|
+
return caches.delete(cacheName);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
self.clients.claim();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
self.addEventListener('fetch', (event) => {
|
|
61
|
+
event.respondWith(
|
|
62
|
+
caches.match(event.request).then((response) => {
|
|
63
|
+
return response || fetch(event.request).catch(() => {
|
|
64
|
+
return caches.match('/');
|
|
65
|
+
});
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
`.trim();
|
|
70
|
+
}
|
|
71
|
+
function configurePWA(options) {
|
|
72
|
+
return {
|
|
73
|
+
manifest: generateManifest(options),
|
|
74
|
+
serviceWorker: options.offline?.enabled ? generateServiceWorker(options) : null
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exports.configurePWA = configurePWA;
|
|
79
|
+
exports.generateManifest = generateManifest;
|
|
80
|
+
exports.generateServiceWorker = generateServiceWorker;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface PWAOptions {
|
|
2
|
+
name: string;
|
|
3
|
+
shortName?: string;
|
|
4
|
+
theme?: string;
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
startUrl?: string;
|
|
8
|
+
icons?: {
|
|
9
|
+
src: string;
|
|
10
|
+
sizes: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
}[];
|
|
13
|
+
offline?: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
pages?: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
declare function generateManifest(options: PWAOptions): {
|
|
19
|
+
name: string;
|
|
20
|
+
short_name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
start_url: string;
|
|
23
|
+
display: string;
|
|
24
|
+
background_color: string;
|
|
25
|
+
theme_color: string;
|
|
26
|
+
icons: {
|
|
27
|
+
src: string;
|
|
28
|
+
sizes: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
declare function generateServiceWorker(options: PWAOptions): string;
|
|
33
|
+
declare function configurePWA(options: PWAOptions): {
|
|
34
|
+
manifest: {
|
|
35
|
+
name: string;
|
|
36
|
+
short_name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
start_url: string;
|
|
39
|
+
display: string;
|
|
40
|
+
background_color: string;
|
|
41
|
+
theme_color: string;
|
|
42
|
+
icons: {
|
|
43
|
+
src: string;
|
|
44
|
+
sizes: string;
|
|
45
|
+
type?: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
serviceWorker: string | null;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { type PWAOptions, configurePWA, generateManifest, generateServiceWorker };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface PWAOptions {
|
|
2
|
+
name: string;
|
|
3
|
+
shortName?: string;
|
|
4
|
+
theme?: string;
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
startUrl?: string;
|
|
8
|
+
icons?: {
|
|
9
|
+
src: string;
|
|
10
|
+
sizes: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
}[];
|
|
13
|
+
offline?: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
pages?: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
declare function generateManifest(options: PWAOptions): {
|
|
19
|
+
name: string;
|
|
20
|
+
short_name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
start_url: string;
|
|
23
|
+
display: string;
|
|
24
|
+
background_color: string;
|
|
25
|
+
theme_color: string;
|
|
26
|
+
icons: {
|
|
27
|
+
src: string;
|
|
28
|
+
sizes: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
declare function generateServiceWorker(options: PWAOptions): string;
|
|
33
|
+
declare function configurePWA(options: PWAOptions): {
|
|
34
|
+
manifest: {
|
|
35
|
+
name: string;
|
|
36
|
+
short_name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
start_url: string;
|
|
39
|
+
display: string;
|
|
40
|
+
background_color: string;
|
|
41
|
+
theme_color: string;
|
|
42
|
+
icons: {
|
|
43
|
+
src: string;
|
|
44
|
+
sizes: string;
|
|
45
|
+
type?: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
serviceWorker: string | null;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { type PWAOptions, configurePWA, generateManifest, generateServiceWorker };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import '../chunk-MLKGABMK.js';
|
|
2
|
+
|
|
3
|
+
// src/pwa/index.ts
|
|
4
|
+
function generateManifest(options) {
|
|
5
|
+
return {
|
|
6
|
+
name: options.name,
|
|
7
|
+
short_name: options.shortName || options.name,
|
|
8
|
+
description: options.description || "",
|
|
9
|
+
start_url: options.startUrl || "/",
|
|
10
|
+
display: "standalone",
|
|
11
|
+
background_color: options.backgroundColor || "#ffffff",
|
|
12
|
+
theme_color: options.theme || "#000000",
|
|
13
|
+
icons: options.icons || [
|
|
14
|
+
{
|
|
15
|
+
src: "/icon-192.png",
|
|
16
|
+
sizes: "192x192",
|
|
17
|
+
type: "image/png"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
src: "/icon-512.png",
|
|
21
|
+
sizes: "512x512",
|
|
22
|
+
type: "image/png"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function generateServiceWorker(options) {
|
|
28
|
+
const cacheName = `${options.name.toLowerCase().replace(/\s+/g, "-")}-v1`;
|
|
29
|
+
const offlinePages = options.offline?.pages || ["/"];
|
|
30
|
+
return `
|
|
31
|
+
const CACHE_NAME = '${cacheName}';
|
|
32
|
+
const OFFLINE_PAGES = ${JSON.stringify(offlinePages)};
|
|
33
|
+
|
|
34
|
+
self.addEventListener('install', (event) => {
|
|
35
|
+
event.waitUntil(
|
|
36
|
+
caches.open(CACHE_NAME).then((cache) => {
|
|
37
|
+
return cache.addAll(OFFLINE_PAGES);
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
self.skipWaiting();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
self.addEventListener('activate', (event) => {
|
|
44
|
+
event.waitUntil(
|
|
45
|
+
caches.keys().then((cacheNames) => {
|
|
46
|
+
return Promise.all(
|
|
47
|
+
cacheNames.map((cacheName) => {
|
|
48
|
+
if (cacheName !== CACHE_NAME) {
|
|
49
|
+
return caches.delete(cacheName);
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
self.clients.claim();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
self.addEventListener('fetch', (event) => {
|
|
59
|
+
event.respondWith(
|
|
60
|
+
caches.match(event.request).then((response) => {
|
|
61
|
+
return response || fetch(event.request).catch(() => {
|
|
62
|
+
return caches.match('/');
|
|
63
|
+
});
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
`.trim();
|
|
68
|
+
}
|
|
69
|
+
function configurePWA(options) {
|
|
70
|
+
return {
|
|
71
|
+
manifest: generateManifest(options),
|
|
72
|
+
serviceWorker: options.offline?.enabled ? generateServiceWorker(options) : null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { configurePWA, generateManifest, generateServiceWorker };
|
package/package.json
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "miragedev-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI-first SDK for building SAAS applications with Next.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"miragedev": "./dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./auth": {
|
|
19
|
+
"types": "./dist/auth/index.d.ts",
|
|
20
|
+
"import": "./dist/auth/index.js",
|
|
21
|
+
"require": "./dist/auth/index.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./auth/client": {
|
|
24
|
+
"types": "./dist/auth/client.d.ts",
|
|
25
|
+
"import": "./dist/auth/client.js",
|
|
26
|
+
"require": "./dist/auth/client.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./auth/biometric": {
|
|
29
|
+
"types": "./dist/auth/biometric.d.ts",
|
|
30
|
+
"import": "./dist/auth/biometric.js",
|
|
31
|
+
"require": "./dist/auth/biometric.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./auth/middleware": {
|
|
34
|
+
"types": "./dist/auth/middleware.d.ts",
|
|
35
|
+
"import": "./dist/auth/middleware.js",
|
|
36
|
+
"require": "./dist/auth/middleware.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./billing": {
|
|
39
|
+
"types": "./dist/billing/index.d.ts",
|
|
40
|
+
"import": "./dist/billing/index.js",
|
|
41
|
+
"require": "./dist/billing/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./billing/client": {
|
|
44
|
+
"types": "./dist/billing/client.d.ts",
|
|
45
|
+
"import": "./dist/billing/client.js",
|
|
46
|
+
"require": "./dist/billing/client.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./billing/mobile": {
|
|
49
|
+
"types": "./dist/billing/mobile.d.ts",
|
|
50
|
+
"import": "./dist/billing/mobile.js",
|
|
51
|
+
"require": "./dist/billing/mobile.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./billing/webhook": {
|
|
54
|
+
"types": "./dist/billing/webhook.d.ts",
|
|
55
|
+
"import": "./dist/billing/webhook.js",
|
|
56
|
+
"require": "./dist/billing/webhook.cjs"
|
|
57
|
+
},
|
|
58
|
+
"./email": {
|
|
59
|
+
"types": "./dist/email/index.d.ts",
|
|
60
|
+
"import": "./dist/email/index.js",
|
|
61
|
+
"require": "./dist/email/index.cjs"
|
|
62
|
+
},
|
|
63
|
+
"./pwa": {
|
|
64
|
+
"types": "./dist/pwa/index.d.ts",
|
|
65
|
+
"import": "./dist/pwa/index.js",
|
|
66
|
+
"require": "./dist/pwa/index.cjs"
|
|
67
|
+
},
|
|
68
|
+
"./mobile": {
|
|
69
|
+
"types": "./dist/mobile/index.d.ts",
|
|
70
|
+
"import": "./dist/mobile/index.js",
|
|
71
|
+
"require": "./dist/mobile/index.cjs"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
"dist"
|
|
76
|
+
],
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "tsup",
|
|
79
|
+
"dev": "tsup --watch",
|
|
80
|
+
"test": "vitest",
|
|
81
|
+
"test:coverage": "vitest --coverage",
|
|
82
|
+
"type-check": "tsc --noEmit",
|
|
83
|
+
"prepublishOnly": "npm run type-check && npm run test -- --run && npm run build"
|
|
84
|
+
},
|
|
85
|
+
"keywords": [
|
|
86
|
+
"saas",
|
|
87
|
+
"nextjs",
|
|
88
|
+
"next",
|
|
89
|
+
"auth",
|
|
90
|
+
"authentication",
|
|
91
|
+
"billing",
|
|
92
|
+
"stripe",
|
|
93
|
+
"subscriptions",
|
|
94
|
+
"email",
|
|
95
|
+
"resend",
|
|
96
|
+
"pwa",
|
|
97
|
+
"mobile",
|
|
98
|
+
"react",
|
|
99
|
+
"typescript",
|
|
100
|
+
"sdk",
|
|
101
|
+
"ai-friendly",
|
|
102
|
+
"jsdoc"
|
|
103
|
+
],
|
|
104
|
+
"author": "MirageDev",
|
|
105
|
+
"license": "MIT",
|
|
106
|
+
"repository": {
|
|
107
|
+
"type": "git",
|
|
108
|
+
"url": "git+https://github.com/miragedev/miragedev-sdk.git"
|
|
109
|
+
},
|
|
110
|
+
"bugs": {
|
|
111
|
+
"url": "https://github.com/miragedev/miragedev-sdk/issues"
|
|
112
|
+
},
|
|
113
|
+
"homepage": "https://github.com/miragedev/miragedev-sdk#readme",
|
|
114
|
+
"peerDependencies": {
|
|
115
|
+
"next": ">=14.0.0",
|
|
116
|
+
"react": ">=18.0.0",
|
|
117
|
+
"react-dom": ">=18.0.0"
|
|
118
|
+
},
|
|
119
|
+
"devDependencies": {
|
|
120
|
+
"@testing-library/react": "^16.3.1",
|
|
121
|
+
"@types/node": "^25.0.3",
|
|
122
|
+
"@types/react": "^19.2.7",
|
|
123
|
+
"@types/react-dom": "^19.2.3",
|
|
124
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
125
|
+
"happy-dom": "^20.1.0",
|
|
126
|
+
"tsup": "^8.5.1",
|
|
127
|
+
"typescript": "^5.9.3",
|
|
128
|
+
"vitest": "^4.0.16",
|
|
129
|
+
"zod": "^4.3.5"
|
|
130
|
+
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"@react-email/components": "^1.0.4",
|
|
133
|
+
"chalk": "^5.6.2",
|
|
134
|
+
"commander": "^14.0.2",
|
|
135
|
+
"inquirer": "^13.1.0",
|
|
136
|
+
"ora": "^9.0.0",
|
|
137
|
+
"resend": "^6.7.0",
|
|
138
|
+
"stripe": "^20.1.2"
|
|
139
|
+
}
|
|
140
|
+
}
|