@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.
- 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 +2 -2
- 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
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bootCsr_exports = {};
|
|
30
|
+
__export(bootCsr_exports, {
|
|
31
|
+
bootCsr: () => bootCsr
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(bootCsr_exports);
|
|
34
|
+
var import_client = require("@akanjs/client");
|
|
35
|
+
var import_client2 = require("@akanjs/client");
|
|
36
|
+
var import_common = require("@akanjs/common");
|
|
37
|
+
var import_react = __toESM(require("react"), 1);
|
|
38
|
+
var ReactDOM = __toESM(require("react-dom/client"), 1);
|
|
39
|
+
var import_useCsrValues = require("./useCsrValues");
|
|
13
40
|
const supportLanguages = ["en", "ko"];
|
|
14
41
|
const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
15
|
-
const [, jwt] = await Promise.all([device.init({ supportLanguages }), storage.getItem("jwt")]);
|
|
42
|
+
const [, jwt] = await Promise.all([import_client.device.init({ supportLanguages }), import_client.storage.getItem("jwt")]);
|
|
16
43
|
if (jwt)
|
|
17
|
-
initAuth({ jwt });
|
|
18
|
-
Logger.verbose(`Set default language: ${device.lang}`);
|
|
44
|
+
(0, import_client.initAuth)({ jwt });
|
|
45
|
+
import_common.Logger.verbose(`Set default language: ${import_client.device.lang}`);
|
|
19
46
|
const pages = {};
|
|
20
47
|
await Promise.all(
|
|
21
48
|
Object.entries(context).map(async ([key, value]) => {
|
|
@@ -26,12 +53,12 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
26
53
|
const { transition, safeArea, topInset, bottomInset, gesture, cache } = csrConfig ?? {};
|
|
27
54
|
const pageState = {
|
|
28
55
|
transition: transition ?? "none",
|
|
29
|
-
topSafeArea: safeArea === false ? 0 : device.topSafeArea,
|
|
30
|
-
bottomSafeArea: safeArea === false ? 0 : device.bottomSafeArea,
|
|
56
|
+
topSafeArea: safeArea === false ? 0 : import_client.device.topSafeArea,
|
|
57
|
+
bottomSafeArea: safeArea === false ? 0 : import_client.device.bottomSafeArea,
|
|
31
58
|
// topSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.topSafeArea,
|
|
32
59
|
// bottomSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.bottomSafeArea,
|
|
33
|
-
topInset: topInset === true ? DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
|
|
34
|
-
bottomInset: bottomInset === true ? DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
|
|
60
|
+
topInset: topInset === true ? import_client2.DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
|
|
61
|
+
bottomInset: bottomInset === true ? import_client2.DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
|
|
35
62
|
gesture: gesture ?? true,
|
|
36
63
|
cache: cache ?? false
|
|
37
64
|
};
|
|
@@ -70,7 +97,7 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
70
97
|
});
|
|
71
98
|
}
|
|
72
99
|
const pathname = window.location.pathname;
|
|
73
|
-
const initialPath = device.lang + entryPath;
|
|
100
|
+
const initialPath = import_client.device.lang + entryPath;
|
|
74
101
|
window.document.body.style.overflow = "hidden";
|
|
75
102
|
const getPathRoutes = (route, parentRootLayouts = [], parentLayouts = [], parentPaths = []) => {
|
|
76
103
|
const parentPath = parentPaths.filter((path2) => path2 !== "/").join("");
|
|
@@ -88,7 +115,7 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
88
115
|
Page: route.Page,
|
|
89
116
|
RootLayouts,
|
|
90
117
|
Layouts,
|
|
91
|
-
pageState: route.pageState ?? defaultPageState
|
|
118
|
+
pageState: route.pageState ?? import_client2.defaultPageState
|
|
92
119
|
}
|
|
93
120
|
] : [],
|
|
94
121
|
...route.children.size ? [...route.children.values()].flatMap((child) => getPathRoutes(child, RootLayouts, Layouts, pathSegments)) : []
|
|
@@ -113,13 +140,13 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
113
140
|
}, routeGuide);
|
|
114
141
|
});
|
|
115
142
|
const RouterProvider = () => {
|
|
116
|
-
const csrValues = useCsrValues(routeGuide, pathRoutes);
|
|
143
|
+
const csrValues = (0, import_useCsrValues.useCsrValues)(routeGuide, pathRoutes);
|
|
117
144
|
const { location } = csrValues;
|
|
118
|
-
return /* @__PURE__ */
|
|
145
|
+
return /* @__PURE__ */ import_react.default.createElement(import_client2.csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
|
|
119
146
|
(children, Layout) => {
|
|
120
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ import_react.default.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
|
|
121
148
|
},
|
|
122
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null)
|
|
123
150
|
));
|
|
124
151
|
};
|
|
125
152
|
if (pathname !== `/${initialPath}`) {
|
|
@@ -130,9 +157,6 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
130
157
|
if (!el)
|
|
131
158
|
throw new Error("No root element");
|
|
132
159
|
const root = ReactDOM.createRoot(el);
|
|
133
|
-
root.render(/* @__PURE__ */
|
|
160
|
+
root.render(/* @__PURE__ */ import_react.default.createElement(RouterProvider, null));
|
|
134
161
|
}
|
|
135
162
|
};
|
|
136
|
-
export {
|
|
137
|
-
bootCsr
|
|
138
|
-
};
|
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
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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 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"), 1);
|
|
37
|
+
var import_server = require("next/server");
|
|
38
|
+
const i18n = { defaultLocale: "en", locales: ["en", "ko"] };
|
|
39
|
+
const basePaths = process.env.basePaths ? process.env.basePaths.split(",") : [];
|
|
40
|
+
function getLocale(request) {
|
|
41
|
+
if (!request.headers.get("accept-language"))
|
|
42
|
+
return i18n.defaultLocale;
|
|
43
|
+
const negotiatorHeaders = {};
|
|
44
|
+
request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
45
|
+
try {
|
|
46
|
+
const languages = new import_negotiator.default({ headers: negotiatorHeaders }).languages();
|
|
47
|
+
return (0, import_intl_localematcher.match)(languages, i18n.locales, i18n.defaultLocale);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return i18n.defaultLocale;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const createNextMiddleware = () => {
|
|
53
|
+
import_common.Logger.rawLog(import_base.logo, "console");
|
|
54
|
+
const middleware = (request) => {
|
|
55
|
+
const pathname = request.nextUrl.pathname;
|
|
56
|
+
const pathnameIsMissingLocale = i18n.locales.every(
|
|
57
|
+
(locale2) => !pathname.startsWith(`/${locale2}/`) && pathname !== `/${locale2}`
|
|
58
|
+
);
|
|
59
|
+
if (pathnameIsMissingLocale)
|
|
60
|
+
return import_server.NextResponse.redirect(
|
|
61
|
+
new URL(`/${getLocale(request)}/${request.nextUrl.href.split("/").slice(3).join("/")}`, request.url)
|
|
62
|
+
);
|
|
63
|
+
const splits = pathname.split("/");
|
|
64
|
+
const locale = splits[1];
|
|
65
|
+
const basePath = basePaths.includes(splits[2]) ? splits[2] : null;
|
|
66
|
+
const headers = new Headers(request.headers);
|
|
67
|
+
const searchParams = new URLSearchParams(request.nextUrl.search);
|
|
68
|
+
const searchParamJwt = searchParams.get("jwt");
|
|
69
|
+
headers.set("x-locale", locale);
|
|
70
|
+
headers.set("x-path", "/" + splits.slice(2).join("/"));
|
|
71
|
+
if (basePath)
|
|
72
|
+
headers.set("x-base-path", basePath);
|
|
73
|
+
if (searchParamJwt)
|
|
74
|
+
headers.set("jwt", searchParamJwt);
|
|
75
|
+
return import_server.NextResponse.next({ request: { headers } });
|
|
76
|
+
};
|
|
77
|
+
return middleware;
|
|
78
|
+
};
|
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
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
const createRobotPage = (clientHttpUri, config) => {
|
|
24
|
+
return {
|
|
25
|
+
...config ?? {},
|
|
26
|
+
rules: {
|
|
27
|
+
userAgent: "*",
|
|
28
|
+
allow: "/",
|
|
29
|
+
disallow: "/admin/",
|
|
30
|
+
...config?.rules ?? {}
|
|
31
|
+
},
|
|
32
|
+
sitemap: `${clientHttpUri}/sitemap.xml`
|
|
33
|
+
};
|
|
34
|
+
};
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const lastModified = /* @__PURE__ */ new Date();
|
|
24
|
+
const createSitemapPage = (clientHttpUri, paths) => {
|
|
25
|
+
return paths.map((path) => ({ url: `${clientHttpUri}${path}`, lastModified }));
|
|
26
|
+
};
|
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/index.cjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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 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");
|
|
60
|
+
//! PageAgent csr에서 말썽 일으킨다
|