@akanjs/next 0.0.24 → 0.0.26
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 +4 -6
- package/src/bootCsr.js +158 -0
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -3
- package/src/makePageProto.js +137 -0
- package/src/useCamera.js +100 -0
- package/src/useCodepush.js +107 -0
- package/src/useContact.js +59 -0
- package/src/useGeoLocation.js +43 -0
- package/src/usePurchase.js +143 -0
- package/src/usePushNoti.js +65 -0
- package/src/useFirebaseMessaging.d.ts +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"bull": "^4.16.5",
|
|
32
32
|
"capacitor-plugin-safe-area": "^3.0.4",
|
|
33
33
|
"clsx": "^2.1.1",
|
|
34
|
-
"copy-webpack-plugin": "^12.0.2",
|
|
35
34
|
"cordova-plugin-purchase": "^13.12.1",
|
|
36
35
|
"dayjs": "^1.11.13",
|
|
37
36
|
"express": "^4.21.2",
|
|
@@ -40,17 +39,16 @@
|
|
|
40
39
|
"jwt-decode": "^4.0.0",
|
|
41
40
|
"mongoose": "^8.9.3",
|
|
42
41
|
"negotiator": "^1.0.0",
|
|
43
|
-
"next": "^15.
|
|
42
|
+
"next": "^15.3.0",
|
|
44
43
|
"pluralize": "^8.0.0",
|
|
45
|
-
"react": "^18.
|
|
44
|
+
"react": "^18.3.1",
|
|
46
45
|
"react-device-detect": "^2.2.3",
|
|
47
|
-
"react-dom": "^18.
|
|
46
|
+
"react-dom": "^18.3.1",
|
|
48
47
|
"react-spring": "^9.7.5",
|
|
49
48
|
"reflect-metadata": "^0.2.2",
|
|
50
49
|
"socket.io": "^4.8.1",
|
|
51
50
|
"socket.io-client": "^4.8.1",
|
|
52
51
|
"tunnel-ssh": "^5.2.0",
|
|
53
|
-
"vm-browserify": "^1.1.2",
|
|
54
52
|
"zustand": "^5.0.2"
|
|
55
53
|
},
|
|
56
54
|
"main": "./index.js"
|
package/src/bootCsr.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bootCsr_exports = {};
|
|
30
|
+
__export(bootCsr_exports, {
|
|
31
|
+
bootCsr: () => bootCsr
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(bootCsr_exports);
|
|
34
|
+
var import_client = require("@akanjs/client");
|
|
35
|
+
var import_client2 = require("@akanjs/client");
|
|
36
|
+
var import_common = require("@akanjs/common");
|
|
37
|
+
var ReactDOM = __toESM(require("react-dom/client"));
|
|
38
|
+
var import_useCsrValues = require("./useCsrValues");
|
|
39
|
+
const supportLanguages = ["en", "ko"];
|
|
40
|
+
const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
41
|
+
const [, jwt] = await Promise.all([import_client.device.init({ supportLanguages }), import_client.storage.getItem("jwt")]);
|
|
42
|
+
if (jwt)
|
|
43
|
+
(0, import_client.initAuth)({ jwt });
|
|
44
|
+
import_common.Logger.verbose(`Set default language: ${import_client.device.lang}`);
|
|
45
|
+
const pages = {};
|
|
46
|
+
context.keys().forEach((key) => pages[key] = context(key));
|
|
47
|
+
const getPageState = (csrConfig) => {
|
|
48
|
+
const { transition, safeArea, topInset, bottomInset, gesture, cache } = csrConfig ?? {};
|
|
49
|
+
const pageState = {
|
|
50
|
+
transition: transition ?? "none",
|
|
51
|
+
topSafeArea: safeArea === false || import_client.device.info.platform === "android" ? 0 : import_client.device.topSafeArea,
|
|
52
|
+
bottomSafeArea: safeArea === false || import_client.device.info.platform === "android" ? 0 : import_client.device.bottomSafeArea,
|
|
53
|
+
topInset: topInset === true ? import_client2.DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
|
|
54
|
+
bottomInset: bottomInset === true ? import_client2.DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
|
|
55
|
+
gesture: gesture ?? true,
|
|
56
|
+
cache: cache ?? false
|
|
57
|
+
};
|
|
58
|
+
return pageState;
|
|
59
|
+
};
|
|
60
|
+
const routeMap = /* @__PURE__ */ new Map();
|
|
61
|
+
routeMap.set("/", { path: "/", children: /* @__PURE__ */ new Map() });
|
|
62
|
+
for (const filePath of Object.keys(pages)) {
|
|
63
|
+
const fileName = /\.\/(.*)\.tsx$/.exec(filePath)?.[1];
|
|
64
|
+
if (!fileName)
|
|
65
|
+
continue;
|
|
66
|
+
const fileType = fileName.endsWith("page") ? "page" : fileName.endsWith("layout") ? "layout" : null;
|
|
67
|
+
if (!fileType)
|
|
68
|
+
continue;
|
|
69
|
+
const pathSegments = [
|
|
70
|
+
"/",
|
|
71
|
+
...fileName.split("/").slice(0, -1).map((segment) => `/${segment.replace(/\[(.*?)\]/g, ":$1")}`)
|
|
72
|
+
];
|
|
73
|
+
const targetRouteMap = pathSegments.slice(0, -1).reduce((rMap, path) => {
|
|
74
|
+
if (!rMap.has(path))
|
|
75
|
+
rMap.set(path, { path, children: /* @__PURE__ */ new Map() });
|
|
76
|
+
return rMap.get(path)?.children;
|
|
77
|
+
}, routeMap);
|
|
78
|
+
if (!targetRouteMap)
|
|
79
|
+
continue;
|
|
80
|
+
const targetPath = pathSegments[pathSegments.length - 1];
|
|
81
|
+
targetRouteMap.set(targetPath, {
|
|
82
|
+
// action: pages[path]?.action,
|
|
83
|
+
// ErrorBoundary: pages[path]?.ErrorBoundary,
|
|
84
|
+
...targetRouteMap.get(targetPath) ?? { path: targetPath, children: /* @__PURE__ */ new Map() },
|
|
85
|
+
...fileType === "layout" ? { Layout: pages[filePath].default } : {
|
|
86
|
+
Page: pages[filePath].default,
|
|
87
|
+
pageState: getPageState(pages[filePath].default.csrConfig),
|
|
88
|
+
csrConfig: pages[filePath].default.csrConfig
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const pathname = window.location.pathname;
|
|
93
|
+
const initialPath = import_client.device.lang + entryPath;
|
|
94
|
+
window.document.body.style.overflow = "hidden";
|
|
95
|
+
const getPathRoutes = (route, parentRootLayouts = [], parentLayouts = [], parentPaths = []) => {
|
|
96
|
+
const parentPath = parentPaths.filter((path2) => path2 !== "/").join("");
|
|
97
|
+
const currentPathSegment = /^\/\(.*\)$/.test(route.path) ? "" : route.path;
|
|
98
|
+
const isRoot = ["/", "/:lang"].includes(parentPath + currentPathSegment) && parentRootLayouts.length < 2;
|
|
99
|
+
const path = parentPath + currentPathSegment;
|
|
100
|
+
const pathSegments = [...parentPaths, ...currentPathSegment ? [currentPathSegment] : []];
|
|
101
|
+
const RootLayouts = [...parentRootLayouts, ...isRoot && route.Layout ? [route.Layout] : []];
|
|
102
|
+
const Layouts = [...parentLayouts, ...!isRoot && route.Layout ? [route.Layout] : []];
|
|
103
|
+
return [
|
|
104
|
+
...route.Page ? [
|
|
105
|
+
{
|
|
106
|
+
path,
|
|
107
|
+
pathSegments,
|
|
108
|
+
Page: route.Page,
|
|
109
|
+
RootLayouts,
|
|
110
|
+
Layouts,
|
|
111
|
+
pageState: route.pageState ?? import_client2.defaultPageState
|
|
112
|
+
}
|
|
113
|
+
] : [],
|
|
114
|
+
...route.children.size ? [...route.children.values()].flatMap((child) => getPathRoutes(child, RootLayouts, Layouts, pathSegments)) : []
|
|
115
|
+
];
|
|
116
|
+
};
|
|
117
|
+
const rootRoute = routeMap.get("/");
|
|
118
|
+
if (!rootRoute)
|
|
119
|
+
throw new Error("No root route");
|
|
120
|
+
const pathRoutes = getPathRoutes(rootRoute);
|
|
121
|
+
const routeGuide = { pathSegment: "/", children: {} };
|
|
122
|
+
pathRoutes.forEach((pathRoute) => {
|
|
123
|
+
const pathSegments = pathRoute.pathSegments.slice(1);
|
|
124
|
+
pathSegments.reduce((routeGuide2, pathSegment, index) => {
|
|
125
|
+
routeGuide2.children[pathSegment] = {
|
|
126
|
+
...routeGuide2.children[pathSegment] ?? {},
|
|
127
|
+
pathSegment,
|
|
128
|
+
...index === pathSegments.length - 1 ? { pathRoute } : {},
|
|
129
|
+
children: routeGuide2.children[pathSegment].children ?? {}
|
|
130
|
+
};
|
|
131
|
+
return routeGuide2.children[pathSegment];
|
|
132
|
+
}, routeGuide);
|
|
133
|
+
});
|
|
134
|
+
const RouterProvider = () => {
|
|
135
|
+
const csrValues = (0, import_useCsrValues.useCsrValues)(routeGuide, pathRoutes);
|
|
136
|
+
const { location } = csrValues;
|
|
137
|
+
return /* @__PURE__ */ React.createElement(import_client2.csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
|
|
138
|
+
(children, Layout) => {
|
|
139
|
+
return /* @__PURE__ */ React.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
|
|
140
|
+
},
|
|
141
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null)
|
|
142
|
+
));
|
|
143
|
+
};
|
|
144
|
+
if (pathname !== `/${initialPath}`) {
|
|
145
|
+
window.location.replace(initialPath);
|
|
146
|
+
return;
|
|
147
|
+
} else {
|
|
148
|
+
const el = document.getElementById("root");
|
|
149
|
+
if (!el)
|
|
150
|
+
throw new Error("No root element");
|
|
151
|
+
const root = ReactDOM.createRoot(el);
|
|
152
|
+
root.render(/* @__PURE__ */ React.createElement(RouterProvider, null));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
bootCsr
|
|
158
|
+
});
|
package/src/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { useCsrValues } from "./useCsrValues";
|
|
|
15
15
|
export { createRobotPage } from "./createRobotPage";
|
|
16
16
|
export { createSitemapPage } from "./createSitemapPage";
|
|
17
17
|
export { createNextMiddleware } from "./createNextMiddleware";
|
|
18
|
-
export { useFirebaseMessaging, type UseFirebaseMessagingProps, type FirebaseMessagingOptions, } from "./useFirebaseMessaging";
|
|
19
18
|
export { useThrottle } from "./useThrottle";
|
|
20
19
|
export { useHistory } from "./useHistory";
|
|
21
20
|
export { useLocation } from "./useLocation";
|
package/src/index.js
CHANGED
|
@@ -29,7 +29,6 @@ __export(src_exports, {
|
|
|
29
29
|
useCsrValues: () => import_useCsrValues.useCsrValues,
|
|
30
30
|
useDebounce: () => import_useDebounce.useDebounce,
|
|
31
31
|
useFetch: () => import_useFetch.useFetch,
|
|
32
|
-
useFirebaseMessaging: () => import_useFirebaseMessaging.useFirebaseMessaging,
|
|
33
32
|
useGeoLocation: () => import_useGeoLocation.useGeoLocation,
|
|
34
33
|
useHistory: () => import_useHistory.useHistory,
|
|
35
34
|
useInterval: () => import_useInterval.useInterval,
|
|
@@ -55,7 +54,6 @@ var import_useCsrValues = require("./useCsrValues");
|
|
|
55
54
|
var import_createRobotPage = require("./createRobotPage");
|
|
56
55
|
var import_createSitemapPage = require("./createSitemapPage");
|
|
57
56
|
var import_createNextMiddleware = require("./createNextMiddleware");
|
|
58
|
-
var import_useFirebaseMessaging = require("./useFirebaseMessaging");
|
|
59
57
|
var import_useThrottle = require("./useThrottle");
|
|
60
58
|
var import_useHistory = require("./useHistory");
|
|
61
59
|
var import_useLocation = require("./useLocation");
|
|
@@ -74,7 +72,6 @@ var import_useLocation = require("./useLocation");
|
|
|
74
72
|
useCsrValues,
|
|
75
73
|
useDebounce,
|
|
76
74
|
useFetch,
|
|
77
|
-
useFirebaseMessaging,
|
|
78
75
|
useGeoLocation,
|
|
79
76
|
useHistory,
|
|
80
77
|
useInterval,
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var makePageProto_exports = {};
|
|
19
|
+
__export(makePageProto_exports, {
|
|
20
|
+
makePageProto: () => makePageProto
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(makePageProto_exports);
|
|
23
|
+
var import_base = require("@akanjs/base");
|
|
24
|
+
var import_client = require("@akanjs/client");
|
|
25
|
+
var import_common = require("@akanjs/common");
|
|
26
|
+
const getPageInfo = () => {
|
|
27
|
+
if (import_base.baseClientEnv.side !== "server") {
|
|
28
|
+
return {
|
|
29
|
+
locale: window.location.pathname.split("/")[1] ?? "en",
|
|
30
|
+
path: "/" + window.location.pathname.split("/").slice(2).join("/")
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const locale = (0, import_client.getHeader)("x-locale") ?? "en";
|
|
34
|
+
const path = (0, import_client.getHeader)("x-path") ?? "/";
|
|
35
|
+
return { locale, path };
|
|
36
|
+
};
|
|
37
|
+
const langIdx = { en: 0, ko: 1, zhChs: 2, zhCht: 3 };
|
|
38
|
+
const dictionary = {};
|
|
39
|
+
const translator = (lang, key, param) => {
|
|
40
|
+
const idx = langIdx[lang];
|
|
41
|
+
try {
|
|
42
|
+
const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
|
|
43
|
+
if (!msg) {
|
|
44
|
+
import_common.Logger.error(`No translation for ${key}`);
|
|
45
|
+
return key;
|
|
46
|
+
}
|
|
47
|
+
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return key;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
translator.rich = (lang, key, param) => {
|
|
53
|
+
const idx = langIdx[lang];
|
|
54
|
+
const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
|
|
55
|
+
if (!msg) {
|
|
56
|
+
import_common.Logger.error(`No translation for ${key}`);
|
|
57
|
+
return key;
|
|
58
|
+
}
|
|
59
|
+
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
60
|
+
};
|
|
61
|
+
const makePageProto = (locales) => {
|
|
62
|
+
locales.forEach((locale) => {
|
|
63
|
+
Object.keys(locale).forEach((key) => dictionary[key] = Object.assign(dictionary[key] ?? {}, locale[key]));
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
const { locale, path } = getPageInfo();
|
|
67
|
+
const lang = locale;
|
|
68
|
+
const l = (key, param) => translator(lang, key, param);
|
|
69
|
+
l.rich = (key, param) => /* @__PURE__ */ React.createElement(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
dangerouslySetInnerHTML: {
|
|
73
|
+
__html: translator.rich(lang, key, {
|
|
74
|
+
...param,
|
|
75
|
+
// strong: (chunks: string) => `<b>${chunks}</b>`,
|
|
76
|
+
// "bg-primary": (chunks: string) => `<span className="bg-primary text-base-100">${chunks}</span>`,
|
|
77
|
+
// primary: (chunks: string) => `<span className="bg-base-100 text-primary">${chunks}</span>`,
|
|
78
|
+
br: `<br />`
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
l.field = (model, field) => {
|
|
84
|
+
const key = `${model}.${field}`;
|
|
85
|
+
return l(key);
|
|
86
|
+
};
|
|
87
|
+
l.desc = (model, field) => {
|
|
88
|
+
const key = `${model}.desc-${field}`;
|
|
89
|
+
return l(key);
|
|
90
|
+
};
|
|
91
|
+
l.enum = (model, field, value) => {
|
|
92
|
+
const key = `${model}.enum-${field}-${value}`;
|
|
93
|
+
return l(key);
|
|
94
|
+
};
|
|
95
|
+
l.enumdesc = (model, field, value) => {
|
|
96
|
+
const key = `${model}.enumdesc-${field}-${value}`;
|
|
97
|
+
return l(key);
|
|
98
|
+
};
|
|
99
|
+
l.api = (model, endpoint) => {
|
|
100
|
+
const key = `${model}.api-${endpoint}`;
|
|
101
|
+
return l(key);
|
|
102
|
+
};
|
|
103
|
+
l.apidesc = (model, endpoint) => {
|
|
104
|
+
const key = `${model}.apidesc-${endpoint}`;
|
|
105
|
+
return l(key);
|
|
106
|
+
};
|
|
107
|
+
l.arg = (model, endpoint, arg) => {
|
|
108
|
+
const key = `${model}.arg-${endpoint}-${arg}`;
|
|
109
|
+
return l(key);
|
|
110
|
+
};
|
|
111
|
+
l.argdesc = (model, endpoint, arg) => {
|
|
112
|
+
const key = `${model}.argdesc-${endpoint}-${arg}`;
|
|
113
|
+
return l(key);
|
|
114
|
+
};
|
|
115
|
+
l.qry = (model, queryKey) => {
|
|
116
|
+
const key = `${model}.qry-${queryKey}`;
|
|
117
|
+
return l(key);
|
|
118
|
+
};
|
|
119
|
+
l.qrydesc = (model, queryKey) => {
|
|
120
|
+
const key = `${model}.qrydesc-${queryKey}`;
|
|
121
|
+
return l(key);
|
|
122
|
+
};
|
|
123
|
+
l.qarg = (model, queryKey, arg) => {
|
|
124
|
+
const key = `${model}.qarg-${queryKey}-${arg}`;
|
|
125
|
+
return l(key);
|
|
126
|
+
};
|
|
127
|
+
l.qargdesc = (model, queryKey, arg) => {
|
|
128
|
+
const key = `${model}.qargdesc-${queryKey}-${arg}`;
|
|
129
|
+
return l(key);
|
|
130
|
+
};
|
|
131
|
+
return { path, l, lang };
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
makePageProto
|
|
137
|
+
});
|
package/src/useCamera.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useCamera_exports = {};
|
|
20
|
+
__export(useCamera_exports, {
|
|
21
|
+
useCamera: () => useCamera
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useCamera_exports);
|
|
24
|
+
var import_client = require("@akanjs/client");
|
|
25
|
+
var import_camera = require("@capacitor/camera");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
const useCamera = () => {
|
|
28
|
+
const [permissions, setPermissions] = (0, import_react.useState)({ camera: "prompt", photos: "prompt" });
|
|
29
|
+
const checkPermission = async (type) => {
|
|
30
|
+
try {
|
|
31
|
+
if (type === "photos") {
|
|
32
|
+
if (permissions.photos === "prompt") {
|
|
33
|
+
const { photos } = await import_camera.Camera.requestPermissions();
|
|
34
|
+
setPermissions((prev) => ({ ...prev, photos }));
|
|
35
|
+
} else if (permissions.photos === "denied") {
|
|
36
|
+
location.assign("app-settings:");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
} else if (type === "camera") {
|
|
40
|
+
if (permissions.camera === "prompt") {
|
|
41
|
+
const { camera } = await import_camera.Camera.requestPermissions();
|
|
42
|
+
setPermissions((prev) => ({ ...prev, camera }));
|
|
43
|
+
} else if (permissions.camera === "denied") {
|
|
44
|
+
location.assign("app-settings:");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
if (permissions.camera === "prompt" || permissions.photos === "prompt") {
|
|
49
|
+
const permissions2 = await import_camera.Camera.requestPermissions();
|
|
50
|
+
setPermissions(permissions2);
|
|
51
|
+
} else if (permissions.camera === "denied" || permissions.photos === "denied") {
|
|
52
|
+
location.assign("app-settings:");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const getPhoto = async (src = "prompt") => {
|
|
60
|
+
const source = import_client.device.info.platform !== "web" ? src === "prompt" ? import_camera.CameraSource.Prompt : src === "camera" ? import_camera.CameraSource.Camera : import_camera.CameraSource.Photos : import_camera.CameraSource.Photos;
|
|
61
|
+
const permission = src === "prompt" ? "all" : src === "camera" ? "camera" : "photos";
|
|
62
|
+
void checkPermission(permission);
|
|
63
|
+
try {
|
|
64
|
+
const photo = await import_camera.Camera.getPhoto({
|
|
65
|
+
quality: 100,
|
|
66
|
+
source,
|
|
67
|
+
allowEditing: false,
|
|
68
|
+
resultType: import_camera.CameraResultType.DataUrl,
|
|
69
|
+
promptLabelHeader: "\uD504\uB85C\uD544 \uC0AC\uC9C4\uC744 \uC62C\uB824\uC8FC\uC138\uC694",
|
|
70
|
+
promptLabelPhoto: "\uC568\uBC94\uC5D0\uC11C \uC120\uD0DD\uD558\uAE30",
|
|
71
|
+
promptLabelPicture: "\uC0AC\uC9C4 \uCC0D\uAE30",
|
|
72
|
+
promptLabelCancel: "\uCDE8\uC18C"
|
|
73
|
+
});
|
|
74
|
+
return photo;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (e === "User cancelled photos app")
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const pickImage = async () => {
|
|
81
|
+
void checkPermission("photos");
|
|
82
|
+
const photo = await import_camera.Camera.pickImages({
|
|
83
|
+
quality: 90
|
|
84
|
+
});
|
|
85
|
+
return photo;
|
|
86
|
+
};
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
void (async () => {
|
|
89
|
+
if (import_client.device.info.platform !== "web") {
|
|
90
|
+
const permissions2 = await import_camera.Camera.checkPermissions();
|
|
91
|
+
setPermissions(permissions2);
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
}, []);
|
|
95
|
+
return { permissions, getPhoto, pickImage, checkPermission };
|
|
96
|
+
};
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
useCamera
|
|
100
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useCodepush_exports = {};
|
|
30
|
+
__export(useCodepush_exports, {
|
|
31
|
+
useCodepush: () => useCodepush
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useCodepush_exports);
|
|
34
|
+
var import_common = require("@akanjs/common");
|
|
35
|
+
var import_app = require("@capacitor/app");
|
|
36
|
+
var import_device = require("@capacitor/device");
|
|
37
|
+
var import_capacitor_updater = require("@capgo/capacitor-updater");
|
|
38
|
+
var import_axios = __toESM(require("axios"));
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
const useCodepush = ({ serverUrl, branch }) => {
|
|
41
|
+
const [update, setUpdate] = (0, import_react.useState)(false);
|
|
42
|
+
const [version, setVersion] = (0, import_react.useState)("");
|
|
43
|
+
const initialize = async () => {
|
|
44
|
+
await import_capacitor_updater.CapacitorUpdater.notifyAppReady();
|
|
45
|
+
};
|
|
46
|
+
const checkNewRelease = async () => {
|
|
47
|
+
const info = await import_device.Device.getInfo();
|
|
48
|
+
const app = await import_app.App.getInfo();
|
|
49
|
+
const pluginVersion = await import_capacitor_updater.CapacitorUpdater.getPluginVersion();
|
|
50
|
+
const { deviceId } = await import_capacitor_updater.CapacitorUpdater.getDeviceId();
|
|
51
|
+
const { bundle: version2, native } = await import_capacitor_updater.CapacitorUpdater.current();
|
|
52
|
+
const builtInversion = await import_capacitor_updater.CapacitorUpdater.getBuiltinVersion();
|
|
53
|
+
const appId = app.id;
|
|
54
|
+
const platform = info.platform;
|
|
55
|
+
window.alert(
|
|
56
|
+
`getBuildinVersion:${builtInversion.version}
|
|
57
|
+
current.bundle:${version2.version}
|
|
58
|
+
currennt.native:${native}`
|
|
59
|
+
);
|
|
60
|
+
const { major, minor, patch } = (0, import_common.splitVersion)(version2.version === "builtin" ? app.version : version2.version);
|
|
61
|
+
const appName = process.env.NX_TASK_TARGET_PROJECT ?? "";
|
|
62
|
+
const appInfo = {
|
|
63
|
+
appId,
|
|
64
|
+
appName,
|
|
65
|
+
deviceId,
|
|
66
|
+
platform,
|
|
67
|
+
branch,
|
|
68
|
+
isEmulator: info.isVirtual,
|
|
69
|
+
major: parseInt(major),
|
|
70
|
+
minor: parseInt(minor),
|
|
71
|
+
patch: parseInt(patch),
|
|
72
|
+
buildNum: app.build,
|
|
73
|
+
//앱내 빌드시 버전 횟수 모르면 고한테 물어보기
|
|
74
|
+
versionOs: info.osVersion
|
|
75
|
+
};
|
|
76
|
+
const url = serverUrl.replace("lu", "akasys");
|
|
77
|
+
const release = (await import_axios.default.post(`${url}/release/codepush`, {
|
|
78
|
+
data: { ...appInfo }
|
|
79
|
+
})).data;
|
|
80
|
+
if (!release)
|
|
81
|
+
return;
|
|
82
|
+
const file = (await import_axios.default.get(`${url}/file/file/${release.appBuild}`)).data;
|
|
83
|
+
return { release, bundleFile: file };
|
|
84
|
+
};
|
|
85
|
+
const codepush = async () => {
|
|
86
|
+
const isNewRelease = await checkNewRelease();
|
|
87
|
+
if (!isNewRelease)
|
|
88
|
+
return;
|
|
89
|
+
const { release, bundleFile } = isNewRelease;
|
|
90
|
+
setUpdate(true);
|
|
91
|
+
const bundle = await import_capacitor_updater.CapacitorUpdater.download({
|
|
92
|
+
url: bundleFile.url,
|
|
93
|
+
version: (0, import_common.mergeVersion)(release.major, release.minor, release.patch)
|
|
94
|
+
});
|
|
95
|
+
await import_capacitor_updater.CapacitorUpdater.set(bundle);
|
|
96
|
+
};
|
|
97
|
+
const getVersion = async () => {
|
|
98
|
+
return await import_capacitor_updater.CapacitorUpdater.getBuiltinVersion();
|
|
99
|
+
};
|
|
100
|
+
const statManager = async () => {
|
|
101
|
+
};
|
|
102
|
+
return { update, version, initialize, checkNewRelease, codepush, statManager };
|
|
103
|
+
};
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
useCodepush
|
|
107
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useContact_exports = {};
|
|
20
|
+
__export(useContact_exports, {
|
|
21
|
+
useContact: () => useContact
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useContact_exports);
|
|
24
|
+
var import_client = require("@akanjs/client");
|
|
25
|
+
var import_contacts = require("@capacitor-community/contacts");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
const useContact = () => {
|
|
28
|
+
const [permissions, setPermissions] = (0, import_react.useState)({ contacts: "prompt" });
|
|
29
|
+
const checkPermission = async () => {
|
|
30
|
+
try {
|
|
31
|
+
if (permissions.contacts === "prompt") {
|
|
32
|
+
const { contacts } = await import_contacts.Contacts.requestPermissions();
|
|
33
|
+
setPermissions((prev) => ({ ...prev, contacts }));
|
|
34
|
+
} else if (permissions.contacts === "denied") {
|
|
35
|
+
location.assign("app-settings:");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const getContacts = async () => {
|
|
42
|
+
await checkPermission();
|
|
43
|
+
const { contacts } = await import_contacts.Contacts.getContacts({ projection: { name: true, phones: true } });
|
|
44
|
+
return contacts;
|
|
45
|
+
};
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
void (async () => {
|
|
48
|
+
if (import_client.device.info.platform === "web")
|
|
49
|
+
return;
|
|
50
|
+
const permissions2 = await import_contacts.Contacts.checkPermissions();
|
|
51
|
+
setPermissions(permissions2);
|
|
52
|
+
})();
|
|
53
|
+
}, []);
|
|
54
|
+
return { permissions, getContacts, checkPermission };
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
useContact
|
|
59
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useGeoLocation_exports = {};
|
|
19
|
+
__export(useGeoLocation_exports, {
|
|
20
|
+
useGeoLocation: () => useGeoLocation
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useGeoLocation_exports);
|
|
23
|
+
var import_geolocation = require("@capacitor/geolocation");
|
|
24
|
+
const useGeoLocation = () => {
|
|
25
|
+
const checkPermission = async () => {
|
|
26
|
+
const { location: geolocation, coarseLocation } = await import_geolocation.Geolocation.requestPermissions();
|
|
27
|
+
return { geolocation, coarseLocation };
|
|
28
|
+
};
|
|
29
|
+
const getPosition = async () => {
|
|
30
|
+
const { geolocation, coarseLocation } = await checkPermission();
|
|
31
|
+
if (geolocation === "denied" || coarseLocation === "denied") {
|
|
32
|
+
location.assign("app-settings:");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const coordinates = await import_geolocation.Geolocation.getCurrentPosition();
|
|
36
|
+
return coordinates;
|
|
37
|
+
};
|
|
38
|
+
return { checkPermission, getPosition };
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
useGeoLocation
|
|
43
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePurchase_exports = {};
|
|
20
|
+
__export(usePurchase_exports, {
|
|
21
|
+
usePurchase: () => usePurchase
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(usePurchase_exports);
|
|
24
|
+
var import_store = require("cordova-plugin-purchase/www/store");
|
|
25
|
+
var import_app = require("@capacitor/app");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
const usePurchase = ({
|
|
28
|
+
platform,
|
|
29
|
+
productInfo,
|
|
30
|
+
url,
|
|
31
|
+
onPay,
|
|
32
|
+
onSubscribe
|
|
33
|
+
}) => {
|
|
34
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
35
|
+
const billingRef = (0, import_react.useRef)();
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
const init = async () => {
|
|
38
|
+
if (CdvPurchase.store.isReady) {
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const app = await import_app.App.getInfo();
|
|
43
|
+
if (platform === "all")
|
|
44
|
+
CdvPurchase.store.register([
|
|
45
|
+
...productInfo.map((prouct) => ({
|
|
46
|
+
id: prouct.id,
|
|
47
|
+
platform: CdvPurchase.Platform.GOOGLE_PLAY,
|
|
48
|
+
type: CdvPurchase.ProductType[prouct.type]
|
|
49
|
+
})),
|
|
50
|
+
...productInfo.map((prouct) => ({
|
|
51
|
+
id: prouct.id,
|
|
52
|
+
platform: CdvPurchase.Platform.APPLE_APPSTORE,
|
|
53
|
+
type: CdvPurchase.ProductType[prouct.type]
|
|
54
|
+
}))
|
|
55
|
+
]);
|
|
56
|
+
else
|
|
57
|
+
CdvPurchase.store.register(
|
|
58
|
+
productInfo.map((product) => ({
|
|
59
|
+
id: product.id,
|
|
60
|
+
platform: platform === "android" ? CdvPurchase.Platform.GOOGLE_PLAY : CdvPurchase.Platform.APPLE_APPSTORE,
|
|
61
|
+
type: CdvPurchase.ProductType[product.type]
|
|
62
|
+
}))
|
|
63
|
+
);
|
|
64
|
+
await CdvPurchase.store.initialize([
|
|
65
|
+
{ platform: CdvPurchase.Platform.APPLE_APPSTORE, options: { needAppReceipt: false } },
|
|
66
|
+
{ platform: CdvPurchase.Platform.GOOGLE_PLAY }
|
|
67
|
+
]);
|
|
68
|
+
await CdvPurchase.store.update();
|
|
69
|
+
await CdvPurchase.store.restorePurchases();
|
|
70
|
+
CdvPurchase.store.validator = async (request, callback) => {
|
|
71
|
+
const transactionId = request.transaction.id;
|
|
72
|
+
const transactions = CdvPurchase.store.localTransactions;
|
|
73
|
+
const verifingTransaction = transactions.find((transaction) => transaction.transactionId === transactionId);
|
|
74
|
+
if (verifingTransaction?.state !== "approved")
|
|
75
|
+
return;
|
|
76
|
+
const billing = await fetch(`${url}/billing/verifyBilling`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: {
|
|
79
|
+
"Content-Type": "application/json"
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify({
|
|
82
|
+
data: {
|
|
83
|
+
platform: verifingTransaction.platform === CdvPurchase.Platform.GOOGLE_PLAY ? "google" : "apple",
|
|
84
|
+
packageName: app.id,
|
|
85
|
+
productId: verifingTransaction.products[0].id,
|
|
86
|
+
receipt: verifingTransaction.platform === CdvPurchase.Platform.GOOGLE_PLAY ? request.transaction.purchaseToken : request.transaction.appStoreReceipt,
|
|
87
|
+
transactionId: verifingTransaction.transactionId
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
billingRef.current = billing.json();
|
|
92
|
+
callback({
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
94
|
+
ok: billing ? true : false,
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
96
|
+
data: { id: request.id, latest_receipt: true, transaction: request.transaction }
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
if (CdvPurchase.store.localReceipts.length > 0) {
|
|
100
|
+
CdvPurchase.store.localReceipts.forEach((receipt) => {
|
|
101
|
+
if (receipt.platform === CdvPurchase.Platform.GOOGLE_PLAY)
|
|
102
|
+
if (receipt.transactions[0].state === CdvPurchase.TransactionState.APPROVED)
|
|
103
|
+
void receipt.transactions[0].verify();
|
|
104
|
+
else
|
|
105
|
+
void receipt.transactions[0].finish();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
CdvPurchase.store.when().approved((transaction) => {
|
|
109
|
+
void transaction.verify();
|
|
110
|
+
}).verified((receipt) => {
|
|
111
|
+
void receipt.finish();
|
|
112
|
+
}).finished((transaction) => {
|
|
113
|
+
void inAppPurchase(transaction);
|
|
114
|
+
});
|
|
115
|
+
setIsLoading(false);
|
|
116
|
+
};
|
|
117
|
+
void init();
|
|
118
|
+
}, []);
|
|
119
|
+
const purchaseProduct = async (product) => {
|
|
120
|
+
await product.getOffer()?.order();
|
|
121
|
+
};
|
|
122
|
+
const restorePurchases = async () => {
|
|
123
|
+
await CdvPurchase.store.restorePurchases();
|
|
124
|
+
};
|
|
125
|
+
const inAppPurchase = async (transaction) => {
|
|
126
|
+
const product = CdvPurchase.store.get(transaction.products[0].id);
|
|
127
|
+
if (product?.type === "consumable")
|
|
128
|
+
await onPay?.(transaction);
|
|
129
|
+
else
|
|
130
|
+
await onSubscribe?.(transaction);
|
|
131
|
+
await transaction.finish();
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
isLoading,
|
|
135
|
+
products: CdvPurchase.store.products,
|
|
136
|
+
purchaseProduct,
|
|
137
|
+
restorePurchases
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
usePurchase
|
|
143
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePushNoti_exports = {};
|
|
20
|
+
__export(usePushNoti_exports, {
|
|
21
|
+
usePushNoti: () => usePushNoti
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(usePushNoti_exports);
|
|
24
|
+
var import_device = require("@capacitor/device");
|
|
25
|
+
var import_push_notifications = require("@capacitor/push-notifications");
|
|
26
|
+
var import_fcm = require("@capacitor-community/fcm");
|
|
27
|
+
const usePushNoti = () => {
|
|
28
|
+
const init = async () => {
|
|
29
|
+
const device = await import_device.Device.getInfo();
|
|
30
|
+
if (device.platform === "web")
|
|
31
|
+
return;
|
|
32
|
+
void import_fcm.FCM.setAutoInit({ enabled: true });
|
|
33
|
+
void import_push_notifications.PushNotifications.requestPermissions().then(async (result) => {
|
|
34
|
+
if (result.receive === "granted") {
|
|
35
|
+
await import_push_notifications.PushNotifications.register();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const checkPermission = async () => {
|
|
40
|
+
const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
|
|
41
|
+
return receive === "granted";
|
|
42
|
+
};
|
|
43
|
+
const register = async () => {
|
|
44
|
+
const device = await import_device.Device.getInfo();
|
|
45
|
+
if (device.platform === "web")
|
|
46
|
+
return;
|
|
47
|
+
const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
|
|
48
|
+
if (receive === "denied")
|
|
49
|
+
location.assign("app-settings:");
|
|
50
|
+
else
|
|
51
|
+
await import_push_notifications.PushNotifications.register();
|
|
52
|
+
};
|
|
53
|
+
const getToken = async () => {
|
|
54
|
+
const device = await import_device.Device.getInfo();
|
|
55
|
+
if (device.platform === "web")
|
|
56
|
+
return;
|
|
57
|
+
const { token } = await import_fcm.FCM.getToken();
|
|
58
|
+
return token;
|
|
59
|
+
};
|
|
60
|
+
return { init, checkPermission, register, getToken };
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
usePushNoti
|
|
65
|
+
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface UseFirebaseMessagingProps {
|
|
2
|
-
options: FirebaseMessagingOptions;
|
|
3
|
-
serverHttpUri: string;
|
|
4
|
-
}
|
|
5
|
-
export interface FirebaseMessagingOptions {
|
|
6
|
-
apiKey: string;
|
|
7
|
-
authDomain: string;
|
|
8
|
-
projectId: string;
|
|
9
|
-
storageBucket: string;
|
|
10
|
-
messagingSenderId: string;
|
|
11
|
-
appId: string;
|
|
12
|
-
measurementId: string;
|
|
13
|
-
vapidKey: string;
|
|
14
|
-
}
|
|
15
|
-
export declare const useFirebaseMessaging: ({ options, serverHttpUri }: UseFirebaseMessagingProps) => {
|
|
16
|
-
getToken: () => Promise<string>;
|
|
17
|
-
initialized: boolean;
|
|
18
|
-
};
|