@akanjs/next 0.0.97 → 0.0.98

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.
Files changed (58) hide show
  1. package/{bootCsr.mjs → bootCsr.cjs} +52 -28
  2. package/bootCsr.js +28 -52
  3. package/createNextMiddleware.cjs +78 -0
  4. package/createNextMiddleware.js +13 -42
  5. package/createRobotPage.cjs +34 -0
  6. package/createRobotPage.js +3 -22
  7. package/createSitemapPage.cjs +26 -0
  8. package/createSitemapPage.js +3 -22
  9. package/index.cjs +60 -0
  10. package/index.js +40 -59
  11. package/lazy.cjs +35 -0
  12. package/lazy.js +5 -34
  13. package/{makePageProto.mjs → makePageProto.cjs} +32 -13
  14. package/makePageProto.js +13 -32
  15. package/package.json +2 -2
  16. package/types.cjs +15 -0
  17. package/types.js +0 -15
  18. package/useCamera.cjs +96 -0
  19. package/useCamera.js +17 -36
  20. package/useCodepush.cjs +103 -0
  21. package/useCodepush.js +25 -54
  22. package/useContact.cjs +55 -0
  23. package/useContact.js +12 -31
  24. package/{useCsrValues.mjs → useCsrValues.cjs} +74 -59
  25. package/useCsrValues.js +59 -74
  26. package/useDebounce.cjs +37 -0
  27. package/useDebounce.js +5 -24
  28. package/useFetch.cjs +42 -0
  29. package/useFetch.js +6 -25
  30. package/useGeoLocation.cjs +40 -0
  31. package/useGeoLocation.js +6 -25
  32. package/{useHistory.mjs → useHistory.cjs} +29 -10
  33. package/useHistory.js +10 -29
  34. package/useInterval.cjs +40 -0
  35. package/useInterval.js +7 -26
  36. package/{useLocation.mjs → useLocation.cjs} +24 -5
  37. package/useLocation.js +5 -24
  38. package/{usePurchase.mjs → usePurchase.cjs} +29 -10
  39. package/usePurchase.js +10 -29
  40. package/usePushNoti.cjs +61 -0
  41. package/usePushNoti.js +16 -35
  42. package/useThrottle.cjs +39 -0
  43. package/useThrottle.js +6 -25
  44. package/createNextMiddleware.mjs +0 -49
  45. package/createRobotPage.mjs +0 -15
  46. package/createSitemapPage.mjs +0 -7
  47. package/index.mjs +0 -41
  48. package/lazy.mjs +0 -6
  49. package/types.mjs +0 -0
  50. package/useCamera.mjs +0 -77
  51. package/useCodepush.mjs +0 -74
  52. package/useContact.mjs +0 -36
  53. package/useDebounce.mjs +0 -18
  54. package/useFetch.mjs +0 -23
  55. package/useGeoLocation.mjs +0 -21
  56. package/useInterval.mjs +0 -21
  57. package/usePushNoti.mjs +0 -42
  58. package/useThrottle.mjs +0 -20
@@ -0,0 +1,40 @@
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 useInterval_exports = {};
20
+ __export(useInterval_exports, {
21
+ useInterval: () => useInterval
22
+ });
23
+ module.exports = __toCommonJS(useInterval_exports);
24
+ var import_react = require("react");
25
+ const useInterval = (callback, delay) => {
26
+ const savedCallback = (0, import_react.useRef)(null);
27
+ (0, import_react.useEffect)(() => {
28
+ savedCallback.current = callback;
29
+ }, [callback]);
30
+ (0, import_react.useEffect)(() => {
31
+ const tick = () => {
32
+ void savedCallback.current?.();
33
+ };
34
+ const id = setInterval(tick, delay);
35
+ return () => {
36
+ clearInterval(id);
37
+ };
38
+ }, [delay]);
39
+ return savedCallback;
40
+ };
package/useInterval.js CHANGED
@@ -1,33 +1,11 @@
1
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 useInterval_exports = {};
20
- __export(useInterval_exports, {
21
- useInterval: () => useInterval
22
- });
23
- module.exports = __toCommonJS(useInterval_exports);
24
- var import_react = require("react");
2
+ import { useEffect, useRef } from "react";
25
3
  const useInterval = (callback, delay) => {
26
- const savedCallback = (0, import_react.useRef)(null);
27
- (0, import_react.useEffect)(() => {
4
+ const savedCallback = useRef(null);
5
+ useEffect(() => {
28
6
  savedCallback.current = callback;
29
7
  }, [callback]);
30
- (0, import_react.useEffect)(() => {
8
+ useEffect(() => {
31
9
  const tick = () => {
32
10
  void savedCallback.current?.();
33
11
  };
@@ -38,3 +16,6 @@ const useInterval = (callback, delay) => {
38
16
  }, [delay]);
39
17
  return savedCallback;
40
18
  };
19
+ export {
20
+ useInterval
21
+ };
@@ -1,7 +1,29 @@
1
1
  "use client";
2
- import { useCallback } from "react";
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 useLocation_exports = {};
20
+ __export(useLocation_exports, {
21
+ useLocation: () => useLocation
22
+ });
23
+ module.exports = __toCommonJS(useLocation_exports);
24
+ var import_react = require("react");
3
25
  const useLocation = ({ rootRouteGuide }) => {
4
- const getLocation = useCallback((href) => {
26
+ const getLocation = (0, import_react.useCallback)((href) => {
5
27
  const getPathSegments = (pathname2) => {
6
28
  return [
7
29
  ...pathname2.split("/").filter((pathSegment) => !!pathSegment).map((pathSegment) => `/${pathSegment}`)
@@ -54,6 +76,3 @@ const useLocation = ({ rootRouteGuide }) => {
54
76
  }, []);
55
77
  return { getLocation };
56
78
  };
57
- export {
58
- useLocation
59
- };
package/useLocation.js CHANGED
@@ -1,29 +1,7 @@
1
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 useLocation_exports = {};
20
- __export(useLocation_exports, {
21
- useLocation: () => useLocation
22
- });
23
- module.exports = __toCommonJS(useLocation_exports);
24
- var import_react = require("react");
2
+ import { useCallback } from "react";
25
3
  const useLocation = ({ rootRouteGuide }) => {
26
- const getLocation = (0, import_react.useCallback)((href) => {
4
+ const getLocation = useCallback((href) => {
27
5
  const getPathSegments = (pathname2) => {
28
6
  return [
29
7
  ...pathname2.split("/").filter((pathSegment) => !!pathSegment).map((pathSegment) => `/${pathSegment}`)
@@ -76,3 +54,6 @@ const useLocation = ({ rootRouteGuide }) => {
76
54
  }, []);
77
55
  return { getLocation };
78
56
  };
57
+ export {
58
+ useLocation
59
+ };
@@ -1,7 +1,29 @@
1
1
  "use client";
2
- import "cordova-plugin-purchase/www/store";
3
- import { App } from "@capacitor/app";
4
- import { useEffect, useRef, useState } from "react";
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");
5
27
  const usePurchase = ({
6
28
  platform,
7
29
  productInfo,
@@ -9,15 +31,15 @@ const usePurchase = ({
9
31
  onPay,
10
32
  onSubscribe
11
33
  }) => {
12
- const [isLoading, setIsLoading] = useState(true);
13
- const billingRef = useRef();
14
- useEffect(() => {
34
+ const [isLoading, setIsLoading] = (0, import_react.useState)(true);
35
+ const billingRef = (0, import_react.useRef)();
36
+ (0, import_react.useEffect)(() => {
15
37
  const init = async () => {
16
38
  if (CdvPurchase.store.isReady) {
17
39
  setIsLoading(false);
18
40
  return;
19
41
  }
20
- const app = await App.getInfo();
42
+ const app = await import_app.App.getInfo();
21
43
  if (platform === "all")
22
44
  CdvPurchase.store.register([
23
45
  ...productInfo.map((prouct) => ({
@@ -115,6 +137,3 @@ const usePurchase = ({
115
137
  restorePurchases
116
138
  };
117
139
  };
118
- export {
119
- usePurchase
120
- };
package/usePurchase.js CHANGED
@@ -1,29 +1,7 @@
1
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");
2
+ import "cordova-plugin-purchase/www/store";
3
+ import { App } from "@capacitor/app";
4
+ import { useEffect, useRef, useState } from "react";
27
5
  const usePurchase = ({
28
6
  platform,
29
7
  productInfo,
@@ -31,15 +9,15 @@ const usePurchase = ({
31
9
  onPay,
32
10
  onSubscribe
33
11
  }) => {
34
- const [isLoading, setIsLoading] = (0, import_react.useState)(true);
35
- const billingRef = (0, import_react.useRef)();
36
- (0, import_react.useEffect)(() => {
12
+ const [isLoading, setIsLoading] = useState(true);
13
+ const billingRef = useRef();
14
+ useEffect(() => {
37
15
  const init = async () => {
38
16
  if (CdvPurchase.store.isReady) {
39
17
  setIsLoading(false);
40
18
  return;
41
19
  }
42
- const app = await import_app.App.getInfo();
20
+ const app = await App.getInfo();
43
21
  if (platform === "all")
44
22
  CdvPurchase.store.register([
45
23
  ...productInfo.map((prouct) => ({
@@ -137,3 +115,6 @@ const usePurchase = ({
137
115
  restorePurchases
138
116
  };
139
117
  };
118
+ export {
119
+ usePurchase
120
+ };
@@ -0,0 +1,61 @@
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
+ };
package/usePushNoti.js CHANGED
@@ -1,61 +1,42 @@
1
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");
2
+ import { Device } from "@capacitor/device";
3
+ import { PushNotifications } from "@capacitor/push-notifications";
4
+ import { FCM } from "@capacitor-community/fcm";
27
5
  const usePushNoti = () => {
28
6
  const init = async () => {
29
- const device = await import_device.Device.getInfo();
7
+ const device = await Device.getInfo();
30
8
  if (device.platform === "web")
31
9
  return;
32
- void import_fcm.FCM.setAutoInit({ enabled: true });
33
- void import_push_notifications.PushNotifications.requestPermissions().then(async (result) => {
10
+ void FCM.setAutoInit({ enabled: true });
11
+ void PushNotifications.requestPermissions().then(async (result) => {
34
12
  if (result.receive === "granted") {
35
- await import_push_notifications.PushNotifications.register();
13
+ await PushNotifications.register();
36
14
  }
37
15
  });
38
16
  };
39
17
  const checkPermission = async () => {
40
- const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
18
+ const { receive } = await PushNotifications.checkPermissions();
41
19
  return receive === "granted";
42
20
  };
43
21
  const register = async () => {
44
- const device = await import_device.Device.getInfo();
22
+ const device = await Device.getInfo();
45
23
  if (device.platform === "web")
46
24
  return;
47
- const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
25
+ const { receive } = await PushNotifications.checkPermissions();
48
26
  if (receive === "denied")
49
27
  location.assign("app-settings:");
50
28
  else
51
- await import_push_notifications.PushNotifications.register();
29
+ await PushNotifications.register();
52
30
  };
53
31
  const getToken = async () => {
54
- const device = await import_device.Device.getInfo();
32
+ const device = await Device.getInfo();
55
33
  if (device.platform === "web")
56
34
  return;
57
- const { token } = await import_fcm.FCM.getToken();
35
+ const { token } = await FCM.getToken();
58
36
  return token;
59
37
  };
60
38
  return { init, checkPermission, register, getToken };
61
39
  };
40
+ export {
41
+ usePushNoti
42
+ };
@@ -0,0 +1,39 @@
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 useThrottle_exports = {};
20
+ __export(useThrottle_exports, {
21
+ useThrottle: () => useThrottle
22
+ });
23
+ module.exports = __toCommonJS(useThrottle_exports);
24
+ var import_react = require("react");
25
+ const useThrottle = (func, delay = 200, deps = []) => {
26
+ const throttleSeed = (0, import_react.useRef)(null);
27
+ const throttleFunction = (0, import_react.useCallback)(
28
+ (...args) => {
29
+ if (throttleSeed.current)
30
+ return;
31
+ func(...args);
32
+ throttleSeed.current = setTimeout(() => {
33
+ throttleSeed.current = null;
34
+ }, delay);
35
+ },
36
+ [func, delay, ...deps]
37
+ );
38
+ return throttleFunction;
39
+ };
package/useThrottle.js CHANGED
@@ -1,30 +1,8 @@
1
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 useThrottle_exports = {};
20
- __export(useThrottle_exports, {
21
- useThrottle: () => useThrottle
22
- });
23
- module.exports = __toCommonJS(useThrottle_exports);
24
- var import_react = require("react");
2
+ import { useCallback, useRef } from "react";
25
3
  const useThrottle = (func, delay = 200, deps = []) => {
26
- const throttleSeed = (0, import_react.useRef)(null);
27
- const throttleFunction = (0, import_react.useCallback)(
4
+ const throttleSeed = useRef(null);
5
+ const throttleFunction = useCallback(
28
6
  (...args) => {
29
7
  if (throttleSeed.current)
30
8
  return;
@@ -37,3 +15,6 @@ const useThrottle = (func, delay = 200, deps = []) => {
37
15
  );
38
16
  return throttleFunction;
39
17
  };
18
+ export {
19
+ useThrottle
20
+ };
@@ -1,49 +0,0 @@
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";
6
- const i18n = { defaultLocale: "en", locales: ["en", "ko"] };
7
- const basePaths = process.env.basePaths ? process.env.basePaths.split(",") : [];
8
- function getLocale(request) {
9
- if (!request.headers.get("accept-language"))
10
- return i18n.defaultLocale;
11
- const negotiatorHeaders = {};
12
- request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
13
- try {
14
- const languages = new Negotiator({ headers: negotiatorHeaders }).languages();
15
- return matchLocale(languages, i18n.locales, i18n.defaultLocale);
16
- } catch (e) {
17
- return i18n.defaultLocale;
18
- }
19
- }
20
- const createNextMiddleware = () => {
21
- Logger.rawLog(logo, "console");
22
- const middleware = (request) => {
23
- const pathname = request.nextUrl.pathname;
24
- const pathnameIsMissingLocale = i18n.locales.every(
25
- (locale2) => !pathname.startsWith(`/${locale2}/`) && pathname !== `/${locale2}`
26
- );
27
- if (pathnameIsMissingLocale)
28
- return NextResponse.redirect(
29
- new URL(`/${getLocale(request)}/${request.nextUrl.href.split("/").slice(3).join("/")}`, request.url)
30
- );
31
- const splits = pathname.split("/");
32
- const locale = splits[1];
33
- const basePath = basePaths.includes(splits[2]) ? splits[2] : null;
34
- const headers = new Headers(request.headers);
35
- const searchParams = new URLSearchParams(request.nextUrl.search);
36
- const searchParamJwt = searchParams.get("jwt");
37
- headers.set("x-locale", locale);
38
- headers.set("x-path", "/" + splits.slice(2).join("/"));
39
- if (basePath)
40
- headers.set("x-base-path", basePath);
41
- if (searchParamJwt)
42
- headers.set("jwt", searchParamJwt);
43
- return NextResponse.next({ request: { headers } });
44
- };
45
- return middleware;
46
- };
47
- export {
48
- createNextMiddleware
49
- };
@@ -1,15 +0,0 @@
1
- const createRobotPage = (clientHttpUri, config) => {
2
- return {
3
- ...config ?? {},
4
- rules: {
5
- userAgent: "*",
6
- allow: "/",
7
- disallow: "/admin/",
8
- ...config?.rules ?? {}
9
- },
10
- sitemap: `${clientHttpUri}/sitemap.xml`
11
- };
12
- };
13
- export {
14
- createRobotPage
15
- };
@@ -1,7 +0,0 @@
1
- const lastModified = /* @__PURE__ */ new Date();
2
- const createSitemapPage = (clientHttpUri, paths) => {
3
- return paths.map((path) => ({ url: `${clientHttpUri}${path}`, lastModified }));
4
- };
5
- export {
6
- createSitemapPage
7
- };
package/index.mjs DELETED
@@ -1,41 +0,0 @@
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";
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.mjs DELETED
@@ -1,6 +0,0 @@
1
- //! next build를 위해서 lint 무시
2
- import dynamic from "next/dynamic";
3
- const lazy = (loader, option) => dynamic(loader, { ...option ?? {} });
4
- export {
5
- lazy
6
- };
package/types.mjs DELETED
File without changes