@akanjs/next 0.0.53 → 0.0.54
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/bootCsr.js +28 -52
- package/createNextMiddleware.js +13 -42
- package/createRobotPage.js +3 -22
- package/createSitemapPage.js +3 -22
- package/lazy.js +5 -34
- package/makePageProto.js +13 -32
- package/package.json +3 -21
- package/types.js +0 -15
- package/useCamera.js +17 -36
- package/useCodepush.js +25 -54
- package/useContact.js +12 -31
- package/useCsrValues.js +59 -74
- package/useDebounce.js +5 -24
- package/useFetch.js +6 -25
- package/useGeoLocation.js +6 -25
- package/useHistory.js +10 -29
- package/useInterval.js +7 -26
- package/useLocation.js +5 -24
- package/usePurchase.js +10 -29
- package/usePushNoti.js +16 -35
- package/useThrottle.js +6 -25
package/bootCsr.js
CHANGED
|
@@ -1,48 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 import_react = __toESM(require("react"));
|
|
38
|
-
var ReactDOM = __toESM(require("react-dom/client"));
|
|
39
|
-
var import_useCsrValues = require("./useCsrValues");
|
|
2
|
+
import { device, initAuth, storage } from "@akanjs/client";
|
|
3
|
+
import {
|
|
4
|
+
csrContext,
|
|
5
|
+
DEFAULT_BOTTOM_INSET,
|
|
6
|
+
DEFAULT_TOP_INSET,
|
|
7
|
+
defaultPageState
|
|
8
|
+
} from "@akanjs/client";
|
|
9
|
+
import { Logger } from "@akanjs/common";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import * as ReactDOM from "react-dom/client";
|
|
12
|
+
import { useCsrValues } from "./useCsrValues";
|
|
40
13
|
const supportLanguages = ["en", "ko"];
|
|
41
14
|
const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
42
|
-
const [, jwt] = await Promise.all([
|
|
15
|
+
const [, jwt] = await Promise.all([device.init({ supportLanguages }), storage.getItem("jwt")]);
|
|
43
16
|
if (jwt)
|
|
44
|
-
|
|
45
|
-
|
|
17
|
+
initAuth({ jwt });
|
|
18
|
+
Logger.verbose(`Set default language: ${device.lang}`);
|
|
46
19
|
const pages = {};
|
|
47
20
|
await Promise.all(
|
|
48
21
|
Object.entries(context).map(async ([key, value]) => {
|
|
@@ -53,12 +26,12 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
53
26
|
const { transition, safeArea, topInset, bottomInset, gesture, cache } = csrConfig ?? {};
|
|
54
27
|
const pageState = {
|
|
55
28
|
transition: transition ?? "none",
|
|
56
|
-
topSafeArea: safeArea === false ? 0 :
|
|
57
|
-
bottomSafeArea: safeArea === false ? 0 :
|
|
29
|
+
topSafeArea: safeArea === false ? 0 : device.topSafeArea,
|
|
30
|
+
bottomSafeArea: safeArea === false ? 0 : device.bottomSafeArea,
|
|
58
31
|
// topSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.topSafeArea,
|
|
59
32
|
// bottomSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.bottomSafeArea,
|
|
60
|
-
topInset: topInset === true ?
|
|
61
|
-
bottomInset: bottomInset === true ?
|
|
33
|
+
topInset: topInset === true ? DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
|
|
34
|
+
bottomInset: bottomInset === true ? DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
|
|
62
35
|
gesture: gesture ?? true,
|
|
63
36
|
cache: cache ?? false
|
|
64
37
|
};
|
|
@@ -97,7 +70,7 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
97
70
|
});
|
|
98
71
|
}
|
|
99
72
|
const pathname = window.location.pathname;
|
|
100
|
-
const initialPath =
|
|
73
|
+
const initialPath = device.lang + entryPath;
|
|
101
74
|
window.document.body.style.overflow = "hidden";
|
|
102
75
|
const getPathRoutes = (route, parentRootLayouts = [], parentLayouts = [], parentPaths = []) => {
|
|
103
76
|
const parentPath = parentPaths.filter((path2) => path2 !== "/").join("");
|
|
@@ -115,7 +88,7 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
115
88
|
Page: route.Page,
|
|
116
89
|
RootLayouts,
|
|
117
90
|
Layouts,
|
|
118
|
-
pageState: route.pageState ??
|
|
91
|
+
pageState: route.pageState ?? defaultPageState
|
|
119
92
|
}
|
|
120
93
|
] : [],
|
|
121
94
|
...route.children.size ? [...route.children.values()].flatMap((child) => getPathRoutes(child, RootLayouts, Layouts, pathSegments)) : []
|
|
@@ -140,13 +113,13 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
140
113
|
}, routeGuide);
|
|
141
114
|
});
|
|
142
115
|
const RouterProvider = () => {
|
|
143
|
-
const csrValues =
|
|
116
|
+
const csrValues = useCsrValues(routeGuide, pathRoutes);
|
|
144
117
|
const { location } = csrValues;
|
|
145
|
-
return /* @__PURE__ */
|
|
118
|
+
return /* @__PURE__ */ React.createElement(csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
|
|
146
119
|
(children, Layout) => {
|
|
147
|
-
return /* @__PURE__ */
|
|
120
|
+
return /* @__PURE__ */ React.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
|
|
148
121
|
},
|
|
149
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null)
|
|
150
123
|
));
|
|
151
124
|
};
|
|
152
125
|
if (pathname !== `/${initialPath}`) {
|
|
@@ -157,6 +130,9 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
157
130
|
if (!el)
|
|
158
131
|
throw new Error("No root element");
|
|
159
132
|
const root = ReactDOM.createRoot(el);
|
|
160
|
-
root.render(/* @__PURE__ */
|
|
133
|
+
root.render(/* @__PURE__ */ React.createElement(RouterProvider, null));
|
|
161
134
|
}
|
|
162
135
|
};
|
|
136
|
+
export {
|
|
137
|
+
bootCsr
|
|
138
|
+
};
|
package/createNextMiddleware.js
CHANGED
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var createNextMiddleware_exports = {};
|
|
29
|
-
__export(createNextMiddleware_exports, {
|
|
30
|
-
createNextMiddleware: () => createNextMiddleware
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(createNextMiddleware_exports);
|
|
33
|
-
var import_base = require("@akanjs/base");
|
|
34
|
-
var import_common = require("@akanjs/common");
|
|
35
|
-
var import_intl_localematcher = require("@formatjs/intl-localematcher");
|
|
36
|
-
var import_negotiator = __toESM(require("negotiator"));
|
|
37
|
-
var import_server = require("next/server");
|
|
1
|
+
import { logo } from "@akanjs/base";
|
|
2
|
+
import { Logger } from "@akanjs/common";
|
|
3
|
+
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
|
4
|
+
import Negotiator from "negotiator";
|
|
5
|
+
import { NextResponse } from "next/server";
|
|
38
6
|
const i18n = { defaultLocale: "en", locales: ["en", "ko"] };
|
|
39
7
|
const basePaths = process.env.basePaths ? process.env.basePaths.split(",") : [];
|
|
40
8
|
function getLocale(request) {
|
|
@@ -43,21 +11,21 @@ function getLocale(request) {
|
|
|
43
11
|
const negotiatorHeaders = {};
|
|
44
12
|
request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
45
13
|
try {
|
|
46
|
-
const languages = new
|
|
47
|
-
return (
|
|
14
|
+
const languages = new Negotiator({ headers: negotiatorHeaders }).languages();
|
|
15
|
+
return matchLocale(languages, i18n.locales, i18n.defaultLocale);
|
|
48
16
|
} catch (e) {
|
|
49
17
|
return i18n.defaultLocale;
|
|
50
18
|
}
|
|
51
19
|
}
|
|
52
20
|
const createNextMiddleware = () => {
|
|
53
|
-
|
|
21
|
+
Logger.rawLog(logo, "console");
|
|
54
22
|
const middleware = (request) => {
|
|
55
23
|
const pathname = request.nextUrl.pathname;
|
|
56
24
|
const pathnameIsMissingLocale = i18n.locales.every(
|
|
57
25
|
(locale2) => !pathname.startsWith(`/${locale2}/`) && pathname !== `/${locale2}`
|
|
58
26
|
);
|
|
59
27
|
if (pathnameIsMissingLocale)
|
|
60
|
-
return
|
|
28
|
+
return NextResponse.redirect(
|
|
61
29
|
new URL(`/${getLocale(request)}/${request.nextUrl.href.split("/").slice(3).join("/")}`, request.url)
|
|
62
30
|
);
|
|
63
31
|
const splits = pathname.split("/");
|
|
@@ -72,7 +40,10 @@ const createNextMiddleware = () => {
|
|
|
72
40
|
headers.set("x-base-path", basePath);
|
|
73
41
|
if (searchParamJwt)
|
|
74
42
|
headers.set("jwt", searchParamJwt);
|
|
75
|
-
return
|
|
43
|
+
return NextResponse.next({ request: { headers } });
|
|
76
44
|
};
|
|
77
45
|
return middleware;
|
|
78
46
|
};
|
|
47
|
+
export {
|
|
48
|
+
createNextMiddleware
|
|
49
|
+
};
|
package/createRobotPage.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
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 createRobotPage_exports = {};
|
|
19
|
-
__export(createRobotPage_exports, {
|
|
20
|
-
createRobotPage: () => createRobotPage
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(createRobotPage_exports);
|
|
23
1
|
const createRobotPage = (clientHttpUri, config) => {
|
|
24
2
|
return {
|
|
25
3
|
...config ?? {},
|
|
@@ -32,3 +10,6 @@ const createRobotPage = (clientHttpUri, config) => {
|
|
|
32
10
|
sitemap: `${clientHttpUri}/sitemap.xml`
|
|
33
11
|
};
|
|
34
12
|
};
|
|
13
|
+
export {
|
|
14
|
+
createRobotPage
|
|
15
|
+
};
|
package/createSitemapPage.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
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 createSitemapPage_exports = {};
|
|
19
|
-
__export(createSitemapPage_exports, {
|
|
20
|
-
createSitemapPage: () => createSitemapPage
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(createSitemapPage_exports);
|
|
23
1
|
const lastModified = /* @__PURE__ */ new Date();
|
|
24
2
|
const createSitemapPage = (clientHttpUri, paths) => {
|
|
25
3
|
return paths.map((path) => ({ url: `${clientHttpUri}${path}`, lastModified }));
|
|
26
4
|
};
|
|
5
|
+
export {
|
|
6
|
+
createSitemapPage
|
|
7
|
+
};
|
package/lazy.js
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var lazy_exports = {};
|
|
29
|
-
__export(lazy_exports, {
|
|
30
|
-
lazy: () => lazy
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(lazy_exports);
|
|
33
|
-
var import_dynamic = __toESM(require("next/dynamic"));
|
|
34
1
|
//! next build를 위해서 lint 무시
|
|
35
|
-
|
|
2
|
+
import dynamic from "next/dynamic";
|
|
3
|
+
const lazy = (loader, option) => dynamic(loader, { ...option ?? {} });
|
|
4
|
+
export {
|
|
5
|
+
lazy
|
|
6
|
+
};
|
package/makePageProto.js
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
1
|
+
import { baseClientEnv } from "@akanjs/base";
|
|
2
|
+
import { getHeader } from "@akanjs/client";
|
|
3
|
+
import { Logger, pathGet } from "@akanjs/common";
|
|
26
4
|
const getPageInfo = () => {
|
|
27
|
-
if (
|
|
5
|
+
if (baseClientEnv.side !== "server") {
|
|
28
6
|
return {
|
|
29
7
|
locale: window.location.pathname.split("/")[1] ?? "en",
|
|
30
8
|
path: "/" + window.location.pathname.split("/").slice(2).join("/")
|
|
31
9
|
};
|
|
32
10
|
}
|
|
33
|
-
const locale =
|
|
34
|
-
const path =
|
|
11
|
+
const locale = getHeader("x-locale") ?? "en";
|
|
12
|
+
const path = getHeader("x-path") ?? "/";
|
|
35
13
|
return { locale, path };
|
|
36
14
|
};
|
|
37
15
|
const langIdx = { en: 0, ko: 1, zhChs: 2, zhCht: 3 };
|
|
@@ -39,9 +17,9 @@ const dictionary = {};
|
|
|
39
17
|
const translator = (lang, key, param) => {
|
|
40
18
|
const idx = langIdx[lang];
|
|
41
19
|
try {
|
|
42
|
-
const msg =
|
|
20
|
+
const msg = pathGet(key, dictionary)?.[idx];
|
|
43
21
|
if (!msg) {
|
|
44
|
-
|
|
22
|
+
Logger.error(`No translation for ${key}`);
|
|
45
23
|
return key;
|
|
46
24
|
}
|
|
47
25
|
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
@@ -51,9 +29,9 @@ const translator = (lang, key, param) => {
|
|
|
51
29
|
};
|
|
52
30
|
translator.rich = (lang, key, param) => {
|
|
53
31
|
const idx = langIdx[lang];
|
|
54
|
-
const msg =
|
|
32
|
+
const msg = pathGet(key, dictionary)?.[idx];
|
|
55
33
|
if (!msg) {
|
|
56
|
-
|
|
34
|
+
Logger.error(`No translation for ${key}`);
|
|
57
35
|
return key;
|
|
58
36
|
}
|
|
59
37
|
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
@@ -131,3 +109,6 @@ const makePageProto = (locales) => {
|
|
|
131
109
|
return { path, l, lang };
|
|
132
110
|
};
|
|
133
111
|
};
|
|
112
|
+
export {
|
|
113
|
+
makePageProto
|
|
114
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/next",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "0.0.54",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -14,23 +14,5 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@capacitor-community/contacts": "^6.1.1",
|
|
19
|
-
"@capacitor-community/fcm": "^7.1.1",
|
|
20
|
-
"@capacitor/app": "^7.0.1",
|
|
21
|
-
"@capacitor/camera": "^7.0.1",
|
|
22
|
-
"@capacitor/device": "^7.0.1",
|
|
23
|
-
"@capacitor/geolocation": "^7.1.2",
|
|
24
|
-
"@capacitor/push-notifications": "^7.0.1",
|
|
25
|
-
"@capgo/capacitor-updater": "^7.0.50",
|
|
26
|
-
"@formatjs/intl-localematcher": "^0.5.10",
|
|
27
|
-
"@react-spring/web": "^9.7.5",
|
|
28
|
-
"@use-gesture/react": "^10.3.1",
|
|
29
|
-
"axios": "^1.7.9",
|
|
30
|
-
"cordova-plugin-purchase": "^13.12.1",
|
|
31
|
-
"negotiator": "^1.0.0",
|
|
32
|
-
"next": "^15.3.2",
|
|
33
|
-
"react": "^18.3.1",
|
|
34
|
-
"react-dom": "^18.3.1"
|
|
35
|
-
}
|
|
17
|
+
"dependencies": {}
|
|
36
18
|
}
|
package/types.js
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var types_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
package/useCamera.js
CHANGED
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
2
|
+
import { device } from "@akanjs/client";
|
|
3
|
+
import { Camera, CameraResultType, CameraSource } from "@capacitor/camera";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
27
5
|
const useCamera = () => {
|
|
28
|
-
const [permissions, setPermissions] =
|
|
6
|
+
const [permissions, setPermissions] = useState({ camera: "prompt", photos: "prompt" });
|
|
29
7
|
const checkPermission = async (type) => {
|
|
30
8
|
try {
|
|
31
9
|
if (type === "photos") {
|
|
32
10
|
if (permissions.photos === "prompt") {
|
|
33
|
-
const { photos } = await
|
|
11
|
+
const { photos } = await Camera.requestPermissions();
|
|
34
12
|
setPermissions((prev) => ({ ...prev, photos }));
|
|
35
13
|
} else if (permissions.photos === "denied") {
|
|
36
14
|
location.assign("app-settings:");
|
|
@@ -38,7 +16,7 @@ const useCamera = () => {
|
|
|
38
16
|
}
|
|
39
17
|
} else if (type === "camera") {
|
|
40
18
|
if (permissions.camera === "prompt") {
|
|
41
|
-
const { camera } = await
|
|
19
|
+
const { camera } = await Camera.requestPermissions();
|
|
42
20
|
setPermissions((prev) => ({ ...prev, camera }));
|
|
43
21
|
} else if (permissions.camera === "denied") {
|
|
44
22
|
location.assign("app-settings:");
|
|
@@ -46,7 +24,7 @@ const useCamera = () => {
|
|
|
46
24
|
}
|
|
47
25
|
} else {
|
|
48
26
|
if (permissions.camera === "prompt" || permissions.photos === "prompt") {
|
|
49
|
-
const permissions2 = await
|
|
27
|
+
const permissions2 = await Camera.requestPermissions();
|
|
50
28
|
setPermissions(permissions2);
|
|
51
29
|
} else if (permissions.camera === "denied" || permissions.photos === "denied") {
|
|
52
30
|
location.assign("app-settings:");
|
|
@@ -57,15 +35,15 @@ const useCamera = () => {
|
|
|
57
35
|
}
|
|
58
36
|
};
|
|
59
37
|
const getPhoto = async (src = "prompt") => {
|
|
60
|
-
const source =
|
|
38
|
+
const source = device.info.platform !== "web" ? src === "prompt" ? CameraSource.Prompt : src === "camera" ? CameraSource.Camera : CameraSource.Photos : CameraSource.Photos;
|
|
61
39
|
const permission = src === "prompt" ? "all" : src === "camera" ? "camera" : "photos";
|
|
62
40
|
void checkPermission(permission);
|
|
63
41
|
try {
|
|
64
|
-
const photo = await
|
|
42
|
+
const photo = await Camera.getPhoto({
|
|
65
43
|
quality: 100,
|
|
66
44
|
source,
|
|
67
45
|
allowEditing: false,
|
|
68
|
-
resultType:
|
|
46
|
+
resultType: CameraResultType.DataUrl,
|
|
69
47
|
promptLabelHeader: "\uD504\uB85C\uD544 \uC0AC\uC9C4\uC744 \uC62C\uB824\uC8FC\uC138\uC694",
|
|
70
48
|
promptLabelPhoto: "\uC568\uBC94\uC5D0\uC11C \uC120\uD0DD\uD558\uAE30",
|
|
71
49
|
promptLabelPicture: "\uC0AC\uC9C4 \uCC0D\uAE30",
|
|
@@ -79,18 +57,21 @@ const useCamera = () => {
|
|
|
79
57
|
};
|
|
80
58
|
const pickImage = async () => {
|
|
81
59
|
void checkPermission("photos");
|
|
82
|
-
const photo = await
|
|
60
|
+
const photo = await Camera.pickImages({
|
|
83
61
|
quality: 90
|
|
84
62
|
});
|
|
85
63
|
return photo;
|
|
86
64
|
};
|
|
87
|
-
|
|
65
|
+
useEffect(() => {
|
|
88
66
|
void (async () => {
|
|
89
|
-
if (
|
|
90
|
-
const permissions2 = await
|
|
67
|
+
if (device.info.platform !== "web") {
|
|
68
|
+
const permissions2 = await Camera.checkPermissions();
|
|
91
69
|
setPermissions(permissions2);
|
|
92
70
|
}
|
|
93
71
|
})();
|
|
94
72
|
}, []);
|
|
95
73
|
return { permissions, getPhoto, pickImage, checkPermission };
|
|
96
74
|
};
|
|
75
|
+
export {
|
|
76
|
+
useCamera
|
|
77
|
+
};
|