@akanjs/next 0.0.40 → 0.0.42

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 (46) hide show
  1. package/index.d.ts +1 -33
  2. package/index.js +2723 -20
  3. package/package.json +35 -2
  4. package/src/bootCsr.d.ts +1 -3
  5. package/src/createNextMiddleware.d.ts +2 -5
  6. package/src/createRobotPage.d.ts +2 -5
  7. package/src/createSitemapPage.d.ts +2 -5
  8. package/src/index.d.ts +20 -33
  9. package/src/lazy.d.ts +3 -6
  10. package/src/makePageProto.d.ts +3 -15
  11. package/src/types.d.ts +2 -4
  12. package/src/useCamera.d.ts +4 -8
  13. package/src/useCodepush.d.ts +2 -36
  14. package/src/useContact.d.ts +3 -7
  15. package/src/useCsrValues.d.ts +22 -36
  16. package/src/useDebounce.d.ts +1 -3
  17. package/src/useFetch.d.ts +1 -3
  18. package/src/useGeoLocation.d.ts +4 -9
  19. package/src/useHistory.d.ts +4 -8
  20. package/src/useInterval.d.ts +1 -5
  21. package/src/useLocation.d.ts +3 -7
  22. package/src/usePurchase.d.ts +5 -6
  23. package/src/usePushNoti.d.ts +1 -3
  24. package/src/useThrottle.d.ts +1 -3
  25. package/csrTypes-B6ATv9-y.d.ts +0 -88
  26. package/src/bootCsr.js +0 -206
  27. package/src/createNextMiddleware.js +0 -88
  28. package/src/createRobotPage.js +0 -39
  29. package/src/createSitemapPage.js +0 -34
  30. package/src/index.js +0 -82
  31. package/src/lazy.js +0 -40
  32. package/src/makePageProto.js +0 -147
  33. package/src/types.js +0 -15
  34. package/src/useCamera.js +0 -114
  35. package/src/useCodepush.js +0 -115
  36. package/src/useContact.js +0 -73
  37. package/src/useCsrValues.js +0 -924
  38. package/src/useDebounce.js +0 -42
  39. package/src/useFetch.js +0 -54
  40. package/src/useGeoLocation.js +0 -51
  41. package/src/useHistory.js +0 -88
  42. package/src/useInterval.js +0 -49
  43. package/src/useLocation.js +0 -92
  44. package/src/usePurchase.js +0 -139
  45. package/src/usePushNoti.js +0 -68
  46. package/src/useThrottle.js +0 -44
package/src/bootCsr.js DELETED
@@ -1,206 +0,0 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var bootCsr_exports = {};
31
- __export(bootCsr_exports, {
32
- bootCsr: () => bootCsr
33
- });
34
- module.exports = __toCommonJS(bootCsr_exports);
35
- var import_client = require("@akanjs/client");
36
- var import_client2 = require("@akanjs/client");
37
- var import_common = require("@akanjs/common");
38
- var import_react = __toESM(require("react"));
39
- var ReactDOM = __toESM(require("react-dom/client"));
40
- var import_useCsrValues = require("./useCsrValues");
41
- const supportLanguages = [
42
- "en",
43
- "ko"
44
- ];
45
- const bootCsr = /* @__PURE__ */ __name(async (context, rootPath, entryPath = "/route") => {
46
- const [, jwt] = await Promise.all([
47
- import_client.device.init({
48
- supportLanguages
49
- }),
50
- import_client.storage.getItem("jwt")
51
- ]);
52
- if (jwt) (0, import_client.initAuth)({
53
- jwt
54
- });
55
- import_common.Logger.verbose(`Set default language: ${import_client.device.lang}`);
56
- const pages = {};
57
- await Promise.all(Object.entries(context).map(async ([key, value]) => {
58
- pages[key] = await value();
59
- }));
60
- const getPageState = /* @__PURE__ */ __name((csrConfig) => {
61
- const { transition, safeArea, topInset, bottomInset, gesture, cache } = csrConfig ?? {};
62
- const pageState = {
63
- transition: transition ?? "none",
64
- topSafeArea: safeArea === false ? 0 : import_client.device.topSafeArea,
65
- bottomSafeArea: safeArea === false ? 0 : import_client.device.bottomSafeArea,
66
- // topSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.topSafeArea,
67
- // bottomSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.bottomSafeArea,
68
- topInset: topInset === true ? import_client2.DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
69
- bottomInset: bottomInset === true ? import_client2.DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
70
- gesture: gesture ?? true,
71
- cache: cache ?? false
72
- };
73
- return pageState;
74
- }, "getPageState");
75
- const routeMap = /* @__PURE__ */ new Map();
76
- routeMap.set("/", {
77
- path: "/",
78
- children: /* @__PURE__ */ new Map()
79
- });
80
- for (const filePath of Object.keys(pages)) {
81
- const fileName = /\.\/(.*)\.tsx$/.exec(filePath)?.[1];
82
- if (!fileName) continue;
83
- const fileType = fileName.endsWith("page") ? "page" : fileName.endsWith("layout") ? "layout" : null;
84
- if (!fileType) continue;
85
- const pathSegments = [
86
- "/",
87
- ...fileName.split("/").slice(0, -1).map((segment) => `/${segment.replace(/\[(.*?)\]/g, ":$1")}`)
88
- ];
89
- const targetRouteMap = pathSegments.slice(0, -1).reduce((rMap, path) => {
90
- if (!rMap.has(path)) rMap.set(path, {
91
- path,
92
- children: /* @__PURE__ */ new Map()
93
- });
94
- return rMap.get(path)?.children;
95
- }, routeMap);
96
- if (!targetRouteMap) continue;
97
- const targetPath = pathSegments[pathSegments.length - 1];
98
- targetRouteMap.set(targetPath, {
99
- // action: pages[path]?.action,
100
- // ErrorBoundary: pages[path]?.ErrorBoundary,
101
- ...targetRouteMap.get(targetPath) ?? {
102
- path: targetPath,
103
- children: /* @__PURE__ */ new Map()
104
- },
105
- ...fileType === "layout" ? {
106
- Layout: pages[filePath].default
107
- } : {
108
- Page: pages[filePath].default,
109
- pageState: getPageState(pages[filePath].default.csrConfig),
110
- csrConfig: pages[filePath].default.csrConfig
111
- }
112
- });
113
- }
114
- const pathname = window.location.pathname;
115
- const initialPath = import_client.device.lang + entryPath;
116
- window.document.body.style.overflow = "hidden";
117
- const getPathRoutes = /* @__PURE__ */ __name((route, parentRootLayouts = [], parentLayouts = [], parentPaths = []) => {
118
- const parentPath = parentPaths.filter((path2) => path2 !== "/").join("");
119
- const currentPathSegment = /^\/\(.*\)$/.test(route.path) ? "" : route.path;
120
- const isRoot = [
121
- "/",
122
- "/:lang"
123
- ].includes(parentPath + currentPathSegment) && parentRootLayouts.length < 2;
124
- const path = parentPath + currentPathSegment;
125
- const pathSegments = [
126
- ...parentPaths,
127
- ...currentPathSegment ? [
128
- currentPathSegment
129
- ] : []
130
- ];
131
- const RootLayouts = [
132
- ...parentRootLayouts,
133
- ...isRoot && route.Layout ? [
134
- route.Layout
135
- ] : []
136
- ];
137
- const Layouts = [
138
- ...parentLayouts,
139
- ...!isRoot && route.Layout ? [
140
- route.Layout
141
- ] : []
142
- ];
143
- return [
144
- ...route.Page ? [
145
- {
146
- path,
147
- pathSegments,
148
- Page: route.Page,
149
- RootLayouts,
150
- Layouts,
151
- pageState: route.pageState ?? import_client2.defaultPageState
152
- }
153
- ] : [],
154
- ...route.children.size ? [
155
- ...route.children.values()
156
- ].flatMap((child) => getPathRoutes(child, RootLayouts, Layouts, pathSegments)) : []
157
- ];
158
- }, "getPathRoutes");
159
- const rootRoute = routeMap.get("/");
160
- if (!rootRoute) throw new Error("No root route");
161
- const pathRoutes = getPathRoutes(rootRoute);
162
- const routeGuide = {
163
- pathSegment: "/",
164
- children: {}
165
- };
166
- pathRoutes.forEach((pathRoute) => {
167
- const pathSegments = pathRoute.pathSegments.slice(1);
168
- pathSegments.reduce((routeGuide2, pathSegment, index) => {
169
- const child = routeGuide2.children[pathSegment];
170
- routeGuide2.children[pathSegment] = {
171
- ...child ?? {},
172
- pathSegment,
173
- ...index === pathSegments.length - 1 ? {
174
- pathRoute
175
- } : {},
176
- children: child?.children ?? {}
177
- };
178
- return routeGuide2.children[pathSegment];
179
- }, routeGuide);
180
- });
181
- const RouterProvider = /* @__PURE__ */ __name(() => {
182
- const csrValues = (0, import_useCsrValues.useCsrValues)(routeGuide, pathRoutes);
183
- const { location } = csrValues;
184
- return /* @__PURE__ */ import_react.default.createElement(import_client2.csrContext.Provider, {
185
- value: csrValues
186
- }, location.pathRoute.RootLayouts.reduceRight((children, Layout) => {
187
- return /* @__PURE__ */ import_react.default.createElement(Layout, {
188
- params: location.params,
189
- searchParams: location.searchParams
190
- }, children);
191
- }, /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null)));
192
- }, "RouterProvider");
193
- if (pathname !== `/${initialPath}`) {
194
- window.location.replace(initialPath);
195
- return;
196
- } else {
197
- const el = document.getElementById("root");
198
- if (!el) throw new Error("No root element");
199
- const root = ReactDOM.createRoot(el);
200
- root.render(/* @__PURE__ */ import_react.default.createElement(RouterProvider, null));
201
- }
202
- }, "bootCsr");
203
- // Annotate the CommonJS export names for ESM import in node:
204
- 0 && (module.exports = {
205
- bootCsr
206
- });
@@ -1,88 +0,0 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 createNextMiddleware_exports = {};
30
- __export(createNextMiddleware_exports, {
31
- createNextMiddleware: () => createNextMiddleware
32
- });
33
- module.exports = __toCommonJS(createNextMiddleware_exports);
34
- var import_base = require("@akanjs/base");
35
- var import_common = require("@akanjs/common");
36
- var import_intl_localematcher = require("@formatjs/intl-localematcher");
37
- var import_negotiator = __toESM(require("negotiator"));
38
- var import_server = require("next/server");
39
- const i18n = {
40
- defaultLocale: "en",
41
- locales: [
42
- "en",
43
- "ko"
44
- ]
45
- };
46
- const basePaths = process.env.basePaths ? process.env.basePaths.split(",") : [];
47
- function getLocale(request) {
48
- if (!request.headers.get("accept-language")) return i18n.defaultLocale;
49
- const negotiatorHeaders = {};
50
- request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
51
- try {
52
- const languages = new import_negotiator.default({
53
- headers: negotiatorHeaders
54
- }).languages();
55
- return (0, import_intl_localematcher.match)(languages, i18n.locales, i18n.defaultLocale);
56
- } catch (e) {
57
- return i18n.defaultLocale;
58
- }
59
- }
60
- __name(getLocale, "getLocale");
61
- const createNextMiddleware = /* @__PURE__ */ __name(() => {
62
- import_common.Logger.rawLog(import_base.logo, "console");
63
- const middleware = /* @__PURE__ */ __name((request) => {
64
- const pathname = request.nextUrl.pathname;
65
- const pathnameIsMissingLocale = i18n.locales.every((locale2) => !pathname.startsWith(`/${locale2}/`) && pathname !== `/${locale2}`);
66
- if (pathnameIsMissingLocale) return import_server.NextResponse.redirect(new URL(`/${getLocale(request)}/${request.nextUrl.href.split("/").slice(3).join("/")}`, request.url));
67
- const splits = pathname.split("/");
68
- const locale = splits[1];
69
- const basePath = basePaths.includes(splits[2]) ? splits[2] : null;
70
- const headers = new Headers(request.headers);
71
- const searchParams = new URLSearchParams(request.nextUrl.search);
72
- const searchParamJwt = searchParams.get("jwt");
73
- headers.set("x-locale", locale);
74
- headers.set("x-path", "/" + splits.slice(2).join("/"));
75
- if (basePath) headers.set("x-base-path", basePath);
76
- if (searchParamJwt) headers.set("jwt", searchParamJwt);
77
- return import_server.NextResponse.next({
78
- request: {
79
- headers
80
- }
81
- });
82
- }, "middleware");
83
- return middleware;
84
- }, "createNextMiddleware");
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- createNextMiddleware
88
- });
@@ -1,39 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 createRobotPage_exports = {};
20
- __export(createRobotPage_exports, {
21
- createRobotPage: () => createRobotPage
22
- });
23
- module.exports = __toCommonJS(createRobotPage_exports);
24
- const createRobotPage = /* @__PURE__ */ __name((clientHttpUri, config) => {
25
- return {
26
- ...config ?? {},
27
- rules: {
28
- userAgent: "*",
29
- allow: "/",
30
- disallow: "/admin/",
31
- ...config?.rules ?? {}
32
- },
33
- sitemap: `${clientHttpUri}/sitemap.xml`
34
- };
35
- }, "createRobotPage");
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- createRobotPage
39
- });
@@ -1,34 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 createSitemapPage_exports = {};
20
- __export(createSitemapPage_exports, {
21
- createSitemapPage: () => createSitemapPage
22
- });
23
- module.exports = __toCommonJS(createSitemapPage_exports);
24
- const lastModified = /* @__PURE__ */ new Date();
25
- const createSitemapPage = /* @__PURE__ */ __name((clientHttpUri, paths) => {
26
- return paths.map((path) => ({
27
- url: `${clientHttpUri}${path}`,
28
- lastModified
29
- }));
30
- }, "createSitemapPage");
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- createSitemapPage
34
- });
package/src/index.js DELETED
@@ -1,82 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __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 src_exports = {};
19
- __export(src_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(src_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에서 말썽 일으킨다
61
- // Annotate the CommonJS export names for ESM import in node:
62
- 0 && (module.exports = {
63
- bootCsr,
64
- createNextMiddleware,
65
- createRobotPage,
66
- createSitemapPage,
67
- lazy,
68
- makePageProto,
69
- useCamera,
70
- useCodepush,
71
- useContact,
72
- useCsrValues,
73
- useDebounce,
74
- useFetch,
75
- useGeoLocation,
76
- useHistory,
77
- useInterval,
78
- useLocation,
79
- usePurchase,
80
- usePushNoti,
81
- useThrottle
82
- });
package/src/lazy.js DELETED
@@ -1,40 +0,0 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 lazy_exports = {};
30
- __export(lazy_exports, {
31
- lazy: () => lazy
32
- });
33
- module.exports = __toCommonJS(lazy_exports);
34
- var import_dynamic = __toESM(require("next/dynamic"));
35
- //! next build를 위해서 lint 무시
36
- const lazy = /* @__PURE__ */ __name((loader, option) => (0, import_dynamic.default)(loader, option ?? {}), "lazy");
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- lazy
40
- });
@@ -1,147 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 makePageProto_exports = {};
20
- __export(makePageProto_exports, {
21
- makePageProto: () => makePageProto
22
- });
23
- module.exports = __toCommonJS(makePageProto_exports);
24
- var import_base = require("@akanjs/base");
25
- var import_client = require("@akanjs/client");
26
- var import_common = require("@akanjs/common");
27
- const getPageInfo = /* @__PURE__ */ __name(() => {
28
- if (import_base.baseClientEnv.side !== "server") {
29
- return {
30
- locale: window.location.pathname.split("/")[1] ?? "en",
31
- path: "/" + window.location.pathname.split("/").slice(2).join("/")
32
- };
33
- }
34
- const locale = (0, import_client.getHeader)("x-locale") ?? "en";
35
- const path = (0, import_client.getHeader)("x-path") ?? "/";
36
- return {
37
- locale,
38
- path
39
- };
40
- }, "getPageInfo");
41
- const langIdx = {
42
- en: 0,
43
- ko: 1,
44
- zhChs: 2,
45
- zhCht: 3
46
- };
47
- const dictionary = {};
48
- const translator = /* @__PURE__ */ __name((lang, key, param) => {
49
- const idx = langIdx[lang];
50
- try {
51
- const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
52
- if (!msg) {
53
- import_common.Logger.error(`No translation for ${key}`);
54
- return key;
55
- }
56
- return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
57
- } catch (e) {
58
- return key;
59
- }
60
- }, "translator");
61
- translator.rich = (lang, key, param) => {
62
- const idx = langIdx[lang];
63
- const msg = (0, import_common.pathGet)(key, dictionary)?.[idx];
64
- if (!msg) {
65
- import_common.Logger.error(`No translation for ${key}`);
66
- return key;
67
- }
68
- return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
69
- };
70
- const makePageProto = /* @__PURE__ */ __name((locales) => {
71
- locales.forEach((locale) => {
72
- Object.keys(locale).forEach((key) => dictionary[key] = Object.assign(dictionary[key] ?? {}, locale[key]));
73
- });
74
- return () => {
75
- const { locale, path } = getPageInfo();
76
- const lang = locale;
77
- const l = /* @__PURE__ */ __name((key, param) => translator(lang, key, param), "l");
78
- l.rich = (key, param) => /* @__PURE__ */ React.createElement("span", {
79
- dangerouslySetInnerHTML: {
80
- __html: translator.rich(lang, key, {
81
- ...param,
82
- // strong: (chunks: string) => `<b>${chunks}</b>`,
83
- // "bg-primary": (chunks: string) => `<span className="bg-primary text-base-100">${chunks}</span>`,
84
- // primary: (chunks: string) => `<span className="bg-base-100 text-primary">${chunks}</span>`,
85
- br: `<br />`
86
- })
87
- }
88
- });
89
- l.field = (model, field) => {
90
- const key = `${model}.${field}`;
91
- return l(key);
92
- };
93
- l.desc = (model, field) => {
94
- const key = `${model}.desc-${field}`;
95
- return l(key);
96
- };
97
- l.enum = (model, field, value) => {
98
- const key = `${model}.enum-${field}-${value}`;
99
- return l(key);
100
- };
101
- l.enumdesc = (model, field, value) => {
102
- const key = `${model}.enumdesc-${field}-${value}`;
103
- return l(key);
104
- };
105
- l.api = (model, endpoint) => {
106
- const key = `${model}.api-${endpoint}`;
107
- return l(key);
108
- };
109
- l.apidesc = (model, endpoint) => {
110
- const key = `${model}.apidesc-${endpoint}`;
111
- return l(key);
112
- };
113
- l.arg = (model, endpoint, arg) => {
114
- const key = `${model}.arg-${endpoint}-${arg}`;
115
- return l(key);
116
- };
117
- l.argdesc = (model, endpoint, arg) => {
118
- const key = `${model}.argdesc-${endpoint}-${arg}`;
119
- return l(key);
120
- };
121
- l.qry = (model, queryKey) => {
122
- const key = `${model}.qry-${queryKey}`;
123
- return l(key);
124
- };
125
- l.qrydesc = (model, queryKey) => {
126
- const key = `${model}.qrydesc-${queryKey}`;
127
- return l(key);
128
- };
129
- l.qarg = (model, queryKey, arg) => {
130
- const key = `${model}.qarg-${queryKey}-${arg}`;
131
- return l(key);
132
- };
133
- l.qargdesc = (model, queryKey, arg) => {
134
- const key = `${model}.qargdesc-${queryKey}-${arg}`;
135
- return l(key);
136
- };
137
- return {
138
- path,
139
- l,
140
- lang
141
- };
142
- };
143
- }, "makePageProto");
144
- // Annotate the CommonJS export names for ESM import in node:
145
- 0 && (module.exports = {
146
- makePageProto
147
- });
package/src/types.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);