@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/useCodepush.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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"), 1);
|
|
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.NEXT_PUBLIC_APP_NAME ?? "";
|
|
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
|
+
};
|
package/useCodepush.js
CHANGED
|
@@ -1,55 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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");
|
|
2
|
+
import { mergeVersion, splitVersion } from "@akanjs/common";
|
|
3
|
+
import { App } from "@capacitor/app";
|
|
4
|
+
import { Device } from "@capacitor/device";
|
|
5
|
+
import { CapacitorUpdater } from "@capgo/capacitor-updater";
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
import { useState } from "react";
|
|
40
8
|
const useCodepush = ({ serverUrl, branch }) => {
|
|
41
|
-
const [update, setUpdate] =
|
|
42
|
-
const [version, setVersion] =
|
|
9
|
+
const [update, setUpdate] = useState(false);
|
|
10
|
+
const [version, setVersion] = useState("");
|
|
43
11
|
const initialize = async () => {
|
|
44
|
-
await
|
|
12
|
+
await CapacitorUpdater.notifyAppReady();
|
|
45
13
|
};
|
|
46
14
|
const checkNewRelease = async () => {
|
|
47
|
-
const info = await
|
|
48
|
-
const app = await
|
|
49
|
-
const pluginVersion = await
|
|
50
|
-
const { deviceId } = await
|
|
51
|
-
const { bundle: version2, native } = await
|
|
52
|
-
const builtInversion = await
|
|
15
|
+
const info = await Device.getInfo();
|
|
16
|
+
const app = await App.getInfo();
|
|
17
|
+
const pluginVersion = await CapacitorUpdater.getPluginVersion();
|
|
18
|
+
const { deviceId } = await CapacitorUpdater.getDeviceId();
|
|
19
|
+
const { bundle: version2, native } = await CapacitorUpdater.current();
|
|
20
|
+
const builtInversion = await CapacitorUpdater.getBuiltinVersion();
|
|
53
21
|
const appId = app.id;
|
|
54
22
|
const platform = info.platform;
|
|
55
23
|
window.alert(
|
|
@@ -57,7 +25,7 @@ const useCodepush = ({ serverUrl, branch }) => {
|
|
|
57
25
|
current.bundle:${version2.version}
|
|
58
26
|
currennt.native:${native}`
|
|
59
27
|
);
|
|
60
|
-
const { major, minor, patch } =
|
|
28
|
+
const { major, minor, patch } = splitVersion(version2.version === "builtin" ? app.version : version2.version);
|
|
61
29
|
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? "";
|
|
62
30
|
const appInfo = {
|
|
63
31
|
appId,
|
|
@@ -74,12 +42,12 @@ currennt.native:${native}`
|
|
|
74
42
|
versionOs: info.osVersion
|
|
75
43
|
};
|
|
76
44
|
const url = serverUrl.replace("lu", "akasys");
|
|
77
|
-
const release = (await
|
|
45
|
+
const release = (await axios.post(`${url}/release/codepush`, {
|
|
78
46
|
data: { ...appInfo }
|
|
79
47
|
})).data;
|
|
80
48
|
if (!release)
|
|
81
49
|
return;
|
|
82
|
-
const file = (await
|
|
50
|
+
const file = (await axios.get(`${url}/file/file/${release.appBuild}`)).data;
|
|
83
51
|
return { release, bundleFile: file };
|
|
84
52
|
};
|
|
85
53
|
const codepush = async () => {
|
|
@@ -88,16 +56,19 @@ currennt.native:${native}`
|
|
|
88
56
|
return;
|
|
89
57
|
const { release, bundleFile } = isNewRelease;
|
|
90
58
|
setUpdate(true);
|
|
91
|
-
const bundle = await
|
|
59
|
+
const bundle = await CapacitorUpdater.download({
|
|
92
60
|
url: bundleFile.url,
|
|
93
|
-
version:
|
|
61
|
+
version: mergeVersion(release.major, release.minor, release.patch)
|
|
94
62
|
});
|
|
95
|
-
await
|
|
63
|
+
await CapacitorUpdater.set(bundle);
|
|
96
64
|
};
|
|
97
65
|
const getVersion = async () => {
|
|
98
|
-
return await
|
|
66
|
+
return await CapacitorUpdater.getBuiltinVersion();
|
|
99
67
|
};
|
|
100
68
|
const statManager = async () => {
|
|
101
69
|
};
|
|
102
70
|
return { update, version, initialize, checkNewRelease, codepush, statManager };
|
|
103
71
|
};
|
|
72
|
+
export {
|
|
73
|
+
useCodepush
|
|
74
|
+
};
|
package/useContact.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
};
|
package/useContact.js
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
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 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");
|
|
2
|
+
import { device } from "@akanjs/client";
|
|
3
|
+
import { Contacts } from "@capacitor-community/contacts";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
27
5
|
const useContact = () => {
|
|
28
|
-
const [permissions, setPermissions] =
|
|
6
|
+
const [permissions, setPermissions] = useState({ contacts: "prompt" });
|
|
29
7
|
const checkPermission = async () => {
|
|
30
8
|
try {
|
|
31
9
|
if (permissions.contacts === "prompt") {
|
|
32
|
-
const { contacts } = await
|
|
10
|
+
const { contacts } = await Contacts.requestPermissions();
|
|
33
11
|
setPermissions((prev) => ({ ...prev, contacts }));
|
|
34
12
|
} else if (permissions.contacts === "denied") {
|
|
35
13
|
location.assign("app-settings:");
|
|
@@ -40,16 +18,19 @@ const useContact = () => {
|
|
|
40
18
|
};
|
|
41
19
|
const getContacts = async () => {
|
|
42
20
|
await checkPermission();
|
|
43
|
-
const { contacts } = await
|
|
21
|
+
const { contacts } = await Contacts.getContacts({ projection: { name: true, phones: true } });
|
|
44
22
|
return contacts;
|
|
45
23
|
};
|
|
46
|
-
|
|
24
|
+
useEffect(() => {
|
|
47
25
|
void (async () => {
|
|
48
|
-
if (
|
|
26
|
+
if (device.info.platform === "web")
|
|
49
27
|
return;
|
|
50
|
-
const permissions2 = await
|
|
28
|
+
const permissions2 = await Contacts.checkPermissions();
|
|
51
29
|
setPermissions(permissions2);
|
|
52
30
|
})();
|
|
53
31
|
}, []);
|
|
54
32
|
return { permissions, getContacts, checkPermission };
|
|
55
33
|
};
|
|
34
|
+
export {
|
|
35
|
+
useContact
|
|
36
|
+
};
|
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 useCsrValues_exports = {};
|
|
20
|
+
__export(useCsrValues_exports, {
|
|
21
|
+
useCsrValues: () => useCsrValues
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useCsrValues_exports);
|
|
24
|
+
var import_client = require("@akanjs/client");
|
|
25
|
+
var import_app = require("@capacitor/app");
|
|
26
|
+
var import_web = require("@react-spring/web");
|
|
27
|
+
var import_react = require("@use-gesture/react");
|
|
28
|
+
var import_react2 = require("react");
|
|
29
|
+
var import_useHistory = require("./useHistory");
|
|
30
|
+
var import_useLocation = require("./useLocation");
|
|
13
31
|
const useNoneTrans = ({ clientHeight, location, prevLocation }) => {
|
|
14
32
|
const transDirection = "none";
|
|
15
|
-
const transUnit = useSpringValue(0, { config: { clamp: true } });
|
|
16
|
-
const transUnitRange = useMemo(() => [0, 0], []);
|
|
33
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
34
|
+
const transUnitRange = (0, import_react2.useMemo)(() => [0, 0], []);
|
|
17
35
|
const transProgress = transUnit.to((unit) => 1);
|
|
18
36
|
const transPercent = transUnit.to((unit) => 100);
|
|
19
37
|
const pageState = location.pathRoute.pageState;
|
|
20
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
38
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
|
|
21
39
|
const csrTranstionStyles = {
|
|
22
40
|
topSafeArea: {
|
|
23
41
|
containerStyle: {
|
|
@@ -83,18 +101,18 @@ const useNoneTrans = ({ clientHeight, location, prevLocation }) => {
|
|
|
83
101
|
};
|
|
84
102
|
const useFadeTrans = ({ clientHeight, location, prevLocation, onBack, history }) => {
|
|
85
103
|
const transDirection = "none";
|
|
86
|
-
const transUnit = useSpringValue(1, { config: { clamp: true } });
|
|
87
|
-
const transUnitRange = useMemo(() => [0, 1], []);
|
|
104
|
+
const transUnit = (0, import_web.useSpringValue)(1, { config: { clamp: true } });
|
|
105
|
+
const transUnitRange = (0, import_react2.useMemo)(() => [0, 1], []);
|
|
88
106
|
const transProgress = transUnit.to((unit) => unit);
|
|
89
107
|
const transPercent = transUnit.to([0, 1], [0, 100], "clamp");
|
|
90
108
|
const pageState = location.pathRoute.pageState;
|
|
91
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
92
|
-
useEffect(() => {
|
|
109
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
|
|
110
|
+
(0, import_react2.useEffect)(() => {
|
|
93
111
|
onBack.current.fade = async () => {
|
|
94
112
|
await transUnit.start(transUnitRange[0]);
|
|
95
113
|
};
|
|
96
114
|
}, []);
|
|
97
|
-
useEffect(() => {
|
|
115
|
+
(0, import_react2.useEffect)(() => {
|
|
98
116
|
if (history.current.type === "forward") {
|
|
99
117
|
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
100
118
|
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
@@ -200,23 +218,23 @@ const useStackTrans = ({
|
|
|
200
218
|
onBack
|
|
201
219
|
}) => {
|
|
202
220
|
const transDirection = "horizontal";
|
|
203
|
-
const transUnit = useSpringValue(0, { config: { clamp: true } });
|
|
204
|
-
const transUnitRange = useMemo(() => [clientWidth, 0], []);
|
|
221
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
222
|
+
const transUnitRange = (0, import_react2.useMemo)(() => [clientWidth, 0], []);
|
|
205
223
|
const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
|
|
206
|
-
const transUnitRangeReversed = useMemo(() => [0, clientWidth], []);
|
|
224
|
+
const transUnitRangeReversed = (0, import_react2.useMemo)(() => [0, clientWidth], []);
|
|
207
225
|
const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
|
|
208
226
|
const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
|
|
209
|
-
const initThreshold = useMemo(() => Math.floor(clientWidth), []);
|
|
210
|
-
const threshold = useMemo(() => Math.floor(clientWidth / 3), []);
|
|
227
|
+
const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth), []);
|
|
228
|
+
const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
|
|
211
229
|
const pageState = location.pathRoute.pageState;
|
|
212
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
230
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
|
|
213
231
|
const pageClassName = "touch-pan-y";
|
|
214
|
-
useEffect(() => {
|
|
232
|
+
(0, import_react2.useEffect)(() => {
|
|
215
233
|
onBack.current.stack = async () => {
|
|
216
234
|
await transUnit.start(transUnitRange[0]);
|
|
217
235
|
};
|
|
218
236
|
}, []);
|
|
219
|
-
useEffect(() => {
|
|
237
|
+
(0, import_react2.useEffect)(() => {
|
|
220
238
|
if (history.current.type === "forward") {
|
|
221
239
|
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
222
240
|
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
@@ -225,10 +243,10 @@ const useStackTrans = ({
|
|
|
225
243
|
return;
|
|
226
244
|
}
|
|
227
245
|
}, [location.pathname]);
|
|
228
|
-
const pageBind = useDrag(
|
|
246
|
+
const pageBind = (0, import_react.useDrag)(
|
|
229
247
|
({ first, down, last, movement: [mx], initial: [ix], cancel }) => {
|
|
230
248
|
if (first)
|
|
231
|
-
void device.hideKeyboard();
|
|
249
|
+
void import_client.device.hideKeyboard();
|
|
232
250
|
if (ix > initThreshold) {
|
|
233
251
|
cancel();
|
|
234
252
|
return;
|
|
@@ -242,7 +260,7 @@ const useStackTrans = ({
|
|
|
242
260
|
else if (mx < threshold)
|
|
243
261
|
void transUnit.start(transUnitRange[1]);
|
|
244
262
|
if (last && mx > threshold)
|
|
245
|
-
router.back();
|
|
263
|
+
import_client.router.back();
|
|
246
264
|
},
|
|
247
265
|
{ axis: "x", filterTaps: true }
|
|
248
266
|
);
|
|
@@ -348,22 +366,22 @@ const useBottomUpTrans = ({
|
|
|
348
366
|
onBack
|
|
349
367
|
}) => {
|
|
350
368
|
const transDirection = "vertical";
|
|
351
|
-
const transUnit = useSpringValue(0, { config: { clamp: true } });
|
|
352
|
-
const transUnitRange = useMemo(() => [clientHeight, 0], []);
|
|
369
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
370
|
+
const transUnitRange = (0, import_react2.useMemo)(() => [clientHeight, 0], []);
|
|
353
371
|
const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
|
|
354
|
-
const transUnitRangeReversed = useMemo(() => [0, clientWidth], []);
|
|
372
|
+
const transUnitRangeReversed = (0, import_react2.useMemo)(() => [0, clientWidth], []);
|
|
355
373
|
const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
|
|
356
374
|
const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
|
|
357
|
-
const initThreshold = useMemo(() => Math.floor(clientWidth / 3), []);
|
|
358
|
-
const threshold = useMemo(() => Math.floor(clientWidth / 2), []);
|
|
375
|
+
const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
|
|
376
|
+
const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 2), []);
|
|
359
377
|
const pageState = location.pathRoute.pageState;
|
|
360
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
361
|
-
useEffect(() => {
|
|
378
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
|
|
379
|
+
(0, import_react2.useEffect)(() => {
|
|
362
380
|
onBack.current.bottomUp = async () => {
|
|
363
381
|
await transUnit.start(transUnitRange[0]);
|
|
364
382
|
};
|
|
365
383
|
}, []);
|
|
366
|
-
useEffect(() => {
|
|
384
|
+
(0, import_react2.useEffect)(() => {
|
|
367
385
|
if (history.current.type === "forward") {
|
|
368
386
|
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
369
387
|
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
@@ -372,10 +390,10 @@ const useBottomUpTrans = ({
|
|
|
372
390
|
return;
|
|
373
391
|
}
|
|
374
392
|
}, [location.pathname]);
|
|
375
|
-
const pageBind = useDrag(
|
|
393
|
+
const pageBind = (0, import_react.useDrag)(
|
|
376
394
|
({ first, last, movement: [, my], initial: [, iy], cancel }) => {
|
|
377
395
|
if (first)
|
|
378
|
-
void device.hideKeyboard();
|
|
396
|
+
void import_client.device.hideKeyboard();
|
|
379
397
|
if (iy > initThreshold) {
|
|
380
398
|
cancel();
|
|
381
399
|
return;
|
|
@@ -389,7 +407,7 @@ const useBottomUpTrans = ({
|
|
|
389
407
|
else if (my < threshold)
|
|
390
408
|
void transUnit.start(transUnitRange[1]);
|
|
391
409
|
if (last && my > threshold)
|
|
392
|
-
router.back();
|
|
410
|
+
import_client.router.back();
|
|
393
411
|
},
|
|
394
412
|
{ axis: "y", filterTaps: true, threshold: 10 }
|
|
395
413
|
);
|
|
@@ -486,23 +504,23 @@ const useBottomUpTrans = ({
|
|
|
486
504
|
return useCsrTransition;
|
|
487
505
|
};
|
|
488
506
|
const useCsrValues = (rootRouteGuide, pathRoutes) => {
|
|
489
|
-
const clientWidth = useRef(window.innerWidth);
|
|
490
|
-
const clientHeight = useRef(window.innerHeight);
|
|
491
|
-
const topSafeAreaRef = useRef(null);
|
|
492
|
-
const bottomSafeAreaRef = useRef(null);
|
|
493
|
-
const pageContentRef = useRef(null);
|
|
494
|
-
const prevPageContentRef = useRef(null);
|
|
495
|
-
const onBack = useRef({});
|
|
496
|
-
const frameRootRef = useRef(null);
|
|
497
|
-
const { getLocation } = useLocation({ rootRouteGuide });
|
|
498
|
-
const { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop } = useHistory([
|
|
507
|
+
const clientWidth = (0, import_react2.useRef)(window.innerWidth);
|
|
508
|
+
const clientHeight = (0, import_react2.useRef)(window.innerHeight);
|
|
509
|
+
const topSafeAreaRef = (0, import_react2.useRef)(null);
|
|
510
|
+
const bottomSafeAreaRef = (0, import_react2.useRef)(null);
|
|
511
|
+
const pageContentRef = (0, import_react2.useRef)(null);
|
|
512
|
+
const prevPageContentRef = (0, import_react2.useRef)(null);
|
|
513
|
+
const onBack = (0, import_react2.useRef)({});
|
|
514
|
+
const frameRootRef = (0, import_react2.useRef)(null);
|
|
515
|
+
const { getLocation } = (0, import_useLocation.useLocation)({ rootRouteGuide });
|
|
516
|
+
const { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop } = (0, import_useHistory.useHistory)([
|
|
499
517
|
getLocation(window.location.pathname)
|
|
500
518
|
]);
|
|
501
|
-
const [{ location, prevLocation }, setLocationState] = useState({
|
|
519
|
+
const [{ location, prevLocation }, setLocationState] = (0, import_react2.useState)({
|
|
502
520
|
location: getCurrentLocation(),
|
|
503
521
|
prevLocation: getPrevLocation()
|
|
504
522
|
});
|
|
505
|
-
const getRouter = useCallback(() => {
|
|
523
|
+
const getRouter = (0, import_react2.useCallback)(() => {
|
|
506
524
|
const router3 = {
|
|
507
525
|
push: (href) => {
|
|
508
526
|
const location2 = getCurrentLocation();
|
|
@@ -574,16 +592,16 @@ const useCsrValues = (rootRouteGuide, pathRoutes) => {
|
|
|
574
592
|
bottomUp: useBottomUpTransition,
|
|
575
593
|
scaleOut: useNonTransition
|
|
576
594
|
};
|
|
577
|
-
useEffect(() => {
|
|
595
|
+
(0, import_react2.useEffect)(() => {
|
|
578
596
|
if (pageContentRef.current)
|
|
579
597
|
pageContentRef.current.scrollTop = getScrollTop(location.pathname);
|
|
580
598
|
if (prevPageContentRef.current)
|
|
581
599
|
prevPageContentRef.current.scrollTop = prevLocation ? getScrollTop(prevLocation.pathname) : 0;
|
|
582
|
-
void App.addListener("backButton", () => {
|
|
600
|
+
void import_app.App.addListener("backButton", () => {
|
|
583
601
|
router2.back();
|
|
584
602
|
});
|
|
585
603
|
return () => {
|
|
586
|
-
void App.removeAllListeners();
|
|
604
|
+
void import_app.App.removeAllListeners();
|
|
587
605
|
};
|
|
588
606
|
}, [location.pathname]);
|
|
589
607
|
return {
|
|
@@ -591,6 +609,3 @@ const useCsrValues = (rootRouteGuide, pathRoutes) => {
|
|
|
591
609
|
...useCsrTransitionMap[location.pathRoute.pageState.transition]
|
|
592
610
|
};
|
|
593
611
|
};
|
|
594
|
-
export {
|
|
595
|
-
useCsrValues
|
|
596
|
-
};
|