@akanjs/next 0.0.97 → 0.0.99
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.mjs → bootCsr.cjs} +52 -28
- package/bootCsr.js +28 -52
- package/createNextMiddleware.cjs +78 -0
- package/createNextMiddleware.js +13 -42
- package/createRobotPage.cjs +34 -0
- package/createRobotPage.js +3 -22
- package/createSitemapPage.cjs +26 -0
- package/createSitemapPage.js +3 -22
- package/index.cjs +60 -0
- package/index.js +40 -59
- package/lazy.cjs +35 -0
- package/lazy.js +5 -34
- package/{makePageProto.mjs → makePageProto.cjs} +32 -13
- package/makePageProto.js +13 -32
- package/package.json +4 -4
- package/types.cjs +15 -0
- package/types.js +0 -15
- package/useCamera.cjs +96 -0
- package/useCamera.js +17 -36
- package/useCodepush.cjs +103 -0
- package/useCodepush.js +25 -54
- package/useContact.cjs +55 -0
- package/useContact.js +12 -31
- package/{useCsrValues.mjs → useCsrValues.cjs} +74 -59
- package/useCsrValues.js +59 -74
- package/useDebounce.cjs +37 -0
- package/useDebounce.js +5 -24
- package/useFetch.cjs +42 -0
- package/useFetch.js +6 -25
- package/useGeoLocation.cjs +40 -0
- package/useGeoLocation.js +6 -25
- package/{useHistory.mjs → useHistory.cjs} +29 -10
- package/useHistory.js +10 -29
- package/useInterval.cjs +40 -0
- package/useInterval.js +7 -26
- package/{useLocation.mjs → useLocation.cjs} +24 -5
- package/useLocation.js +5 -24
- package/{usePurchase.mjs → usePurchase.cjs} +29 -10
- package/usePurchase.js +10 -29
- package/usePushNoti.cjs +61 -0
- package/usePushNoti.js +16 -35
- package/useThrottle.cjs +39 -0
- package/useThrottle.js +6 -25
- package/createNextMiddleware.mjs +0 -49
- package/createRobotPage.mjs +0 -15
- package/createSitemapPage.mjs +0 -7
- package/index.mjs +0 -41
- package/lazy.mjs +0 -6
- package/types.mjs +0 -0
- package/useCamera.mjs +0 -77
- package/useCodepush.mjs +0 -74
- package/useContact.mjs +0 -36
- package/useDebounce.mjs +0 -18
- package/useFetch.mjs +0 -23
- package/useGeoLocation.mjs +0 -21
- package/useInterval.mjs +0 -21
- package/usePushNoti.mjs +0 -42
- package/useThrottle.mjs +0 -20
package/index.js
CHANGED
|
@@ -1,60 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var next_exports = {};
|
|
19
|
-
__export(next_exports, {
|
|
20
|
-
bootCsr: () => import_bootCsr.bootCsr,
|
|
21
|
-
createNextMiddleware: () => import_createNextMiddleware.createNextMiddleware,
|
|
22
|
-
createRobotPage: () => import_createRobotPage.createRobotPage,
|
|
23
|
-
createSitemapPage: () => import_createSitemapPage.createSitemapPage,
|
|
24
|
-
lazy: () => import_lazy.lazy,
|
|
25
|
-
makePageProto: () => import_makePageProto.makePageProto,
|
|
26
|
-
useCamera: () => import_useCamera.useCamera,
|
|
27
|
-
useCodepush: () => import_useCodepush.useCodepush,
|
|
28
|
-
useContact: () => import_useContact.useContact,
|
|
29
|
-
useCsrValues: () => import_useCsrValues.useCsrValues,
|
|
30
|
-
useDebounce: () => import_useDebounce.useDebounce,
|
|
31
|
-
useFetch: () => import_useFetch.useFetch,
|
|
32
|
-
useGeoLocation: () => import_useGeoLocation.useGeoLocation,
|
|
33
|
-
useHistory: () => import_useHistory.useHistory,
|
|
34
|
-
useInterval: () => import_useInterval.useInterval,
|
|
35
|
-
useLocation: () => import_useLocation.useLocation,
|
|
36
|
-
usePurchase: () => import_usePurchase.usePurchase,
|
|
37
|
-
usePushNoti: () => import_usePushNoti.usePushNoti,
|
|
38
|
-
useThrottle: () => import_useThrottle.useThrottle
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(next_exports);
|
|
41
|
-
var import_useFetch = require("./useFetch");
|
|
42
|
-
var import_lazy = require("./lazy");
|
|
43
|
-
var import_makePageProto = require("./makePageProto");
|
|
44
|
-
var import_useDebounce = require("./useDebounce");
|
|
45
|
-
var import_useInterval = require("./useInterval");
|
|
46
|
-
var import_bootCsr = require("./bootCsr");
|
|
47
|
-
var import_useCamera = require("./useCamera");
|
|
48
|
-
var import_useContact = require("./useContact");
|
|
49
|
-
var import_usePushNoti = require("./usePushNoti");
|
|
50
|
-
var import_useGeoLocation = require("./useGeoLocation");
|
|
51
|
-
var import_useCodepush = require("./useCodepush");
|
|
52
|
-
var import_usePurchase = require("./usePurchase");
|
|
53
|
-
var import_useCsrValues = require("./useCsrValues");
|
|
54
|
-
var import_createRobotPage = require("./createRobotPage");
|
|
55
|
-
var import_createSitemapPage = require("./createSitemapPage");
|
|
56
|
-
var import_createNextMiddleware = require("./createNextMiddleware");
|
|
57
|
-
var import_useThrottle = require("./useThrottle");
|
|
58
|
-
var import_useHistory = require("./useHistory");
|
|
59
|
-
var import_useLocation = require("./useLocation");
|
|
1
|
+
import { useFetch } from "./useFetch";
|
|
2
|
+
import { lazy } from "./lazy";
|
|
3
|
+
import { makePageProto } from "./makePageProto";
|
|
4
|
+
import { useDebounce } from "./useDebounce";
|
|
5
|
+
import { useInterval } from "./useInterval";
|
|
6
|
+
import { bootCsr } from "./bootCsr";
|
|
7
|
+
import { useCamera } from "./useCamera";
|
|
8
|
+
import { useContact } from "./useContact";
|
|
9
|
+
import { usePushNoti } from "./usePushNoti";
|
|
10
|
+
import { useGeoLocation } from "./useGeoLocation";
|
|
11
|
+
import { useCodepush } from "./useCodepush";
|
|
12
|
+
import { usePurchase } from "./usePurchase";
|
|
13
|
+
import { useCsrValues } from "./useCsrValues";
|
|
14
|
+
import { createRobotPage } from "./createRobotPage";
|
|
15
|
+
import { createSitemapPage } from "./createSitemapPage";
|
|
16
|
+
import { createNextMiddleware } from "./createNextMiddleware";
|
|
60
17
|
//! PageAgent csr에서 말썽 일으킨다
|
|
18
|
+
import { useThrottle } from "./useThrottle";
|
|
19
|
+
import { useHistory } from "./useHistory";
|
|
20
|
+
import { useLocation } from "./useLocation";
|
|
21
|
+
export {
|
|
22
|
+
bootCsr,
|
|
23
|
+
createNextMiddleware,
|
|
24
|
+
createRobotPage,
|
|
25
|
+
createSitemapPage,
|
|
26
|
+
lazy,
|
|
27
|
+
makePageProto,
|
|
28
|
+
useCamera,
|
|
29
|
+
useCodepush,
|
|
30
|
+
useContact,
|
|
31
|
+
useCsrValues,
|
|
32
|
+
useDebounce,
|
|
33
|
+
useFetch,
|
|
34
|
+
useGeoLocation,
|
|
35
|
+
useHistory,
|
|
36
|
+
useInterval,
|
|
37
|
+
useLocation,
|
|
38
|
+
usePurchase,
|
|
39
|
+
usePushNoti,
|
|
40
|
+
useThrottle
|
|
41
|
+
};
|
package/lazy.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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"), 1);
|
|
34
|
+
//! next build를 위해서 lint 무시
|
|
35
|
+
const lazy = (loader, option) => (0, import_dynamic.default)(loader, { ...option ?? {} });
|
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
|
+
};
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 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");
|
|
4
26
|
const getPageInfo = () => {
|
|
5
|
-
if (baseClientEnv.side !== "server") {
|
|
27
|
+
if (import_base.baseClientEnv.side !== "server") {
|
|
6
28
|
return {
|
|
7
29
|
locale: window.location.pathname.split("/")[1] ?? "en",
|
|
8
30
|
path: "/" + window.location.pathname.split("/").slice(2).join("/")
|
|
9
31
|
};
|
|
10
32
|
}
|
|
11
|
-
const locale = getHeader("x-locale") ?? "en";
|
|
12
|
-
const path = getHeader("x-path") ?? "/";
|
|
33
|
+
const locale = (0, import_client.getHeader)("x-locale") ?? "en";
|
|
34
|
+
const path = (0, import_client.getHeader)("x-path") ?? "/";
|
|
13
35
|
return { locale, path };
|
|
14
36
|
};
|
|
15
37
|
const langIdx = { en: 0, ko: 1, zhChs: 2, zhCht: 3 };
|
|
@@ -17,9 +39,9 @@ const dictionary = {};
|
|
|
17
39
|
const translator = (lang, key, param) => {
|
|
18
40
|
const idx = langIdx[lang];
|
|
19
41
|
try {
|
|
20
|
-
const msg = pathGet(key, dictionary)?.[idx];
|
|
42
|
+
const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
|
|
21
43
|
if (!msg) {
|
|
22
|
-
Logger.error(`No translation for ${key}`);
|
|
44
|
+
import_common.Logger.error(`No translation for ${key}`);
|
|
23
45
|
return key;
|
|
24
46
|
}
|
|
25
47
|
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
@@ -29,9 +51,9 @@ const translator = (lang, key, param) => {
|
|
|
29
51
|
};
|
|
30
52
|
translator.rich = (lang, key, param) => {
|
|
31
53
|
const idx = langIdx[lang];
|
|
32
|
-
const msg = pathGet(key, dictionary)?.[idx];
|
|
54
|
+
const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
|
|
33
55
|
if (!msg) {
|
|
34
|
-
Logger.error(`No translation for ${key}`);
|
|
56
|
+
import_common.Logger.error(`No translation for ${key}`);
|
|
35
57
|
return key;
|
|
36
58
|
}
|
|
37
59
|
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
@@ -109,6 +131,3 @@ const makePageProto = (locales) => {
|
|
|
109
131
|
return { path, l, lang };
|
|
110
132
|
};
|
|
111
133
|
};
|
|
112
|
-
export {
|
|
113
|
-
makePageProto
|
|
114
|
-
};
|
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.99",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
|
-
"require": "./index.
|
|
39
|
-
"import": "./index.
|
|
38
|
+
"require": "./index.cjs",
|
|
39
|
+
"import": "./index.js"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"esbuild": {
|
package/types.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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/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.cjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
};
|
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
|
+
};
|