@akanjs/client 0.0.44 → 0.0.45

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 (2) hide show
  1. package/index.js +1300 -1270
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,68 +1,99 @@
1
- (() => {
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
13
- throw Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
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);
31
28
 
32
- // pkgs/@akanjs/client/src/types.ts
33
- var import_clsx = __require("clsx");
34
- var clsx = (...args) => (0, import_clsx.clsx)(...args);
35
- var loadFonts = (fonts) => {
36
- return fonts.map(({ name, nextFont, paths }) => nextFont ?? { name, paths });
37
- };
29
+ // pkgs/@akanjs/client/index.ts
30
+ var client_exports = {};
31
+ __export(client_exports, {
32
+ DEFAULT_BOTTOM_INSET: () => DEFAULT_BOTTOM_INSET,
33
+ DEFAULT_TOP_INSET: () => DEFAULT_TOP_INSET,
34
+ Nanum_Gothic_Coding: () => Nanum_Gothic_Coding,
35
+ Noto_Sans_KR: () => Noto_Sans_KR,
36
+ clsx: () => clsx,
37
+ cookies: () => cookies,
38
+ createFont: () => createFont,
39
+ csrContext: () => csrContext,
40
+ defaultPageState: () => defaultPageState,
41
+ device: () => device,
42
+ getAccount: () => getAccount,
43
+ getCookie: () => getCookie,
44
+ getHeader: () => getHeader,
45
+ getMe: () => getMe,
46
+ getPathInfo: () => getPathInfo,
47
+ getSelf: () => getSelf,
48
+ headers: () => headers,
49
+ initAuth: () => initAuth,
50
+ loadFonts: () => loadFonts,
51
+ pathContext: () => pathContext,
52
+ removeCookie: () => removeCookie,
53
+ resetAuth: () => resetAuth,
54
+ router: () => router,
55
+ setAuth: () => setAuth,
56
+ setCookie: () => setCookie,
57
+ storage: () => storage,
58
+ useCsr: () => useCsr,
59
+ usePathCtx: () => usePathCtx
60
+ });
61
+ module.exports = __toCommonJS(client_exports);
38
62
 
39
- // pkgs/@akanjs/client/src/csrTypes.ts
40
- var import_react = __require("react");
41
- var DEFAULT_TOP_INSET = 48;
42
- var DEFAULT_BOTTOM_INSET = 60;
43
- var defaultPageState = {
44
- transition: "none",
45
- topSafeArea: 0,
46
- bottomSafeArea: 0,
47
- topInset: 0,
48
- bottomInset: 0,
49
- gesture: true,
50
- cache: false
51
- };
52
- var csrContext = (0, import_react.createContext)({});
53
- var useCsr = () => {
54
- const contextValues = (0, import_react.useContext)(csrContext);
55
- return contextValues;
56
- };
57
- var pathContext = (0, import_react.createContext)({});
58
- var usePathCtx = () => {
59
- const contextValues = (0, import_react.useContext)(pathContext);
60
- return contextValues;
61
- };
63
+ // pkgs/@akanjs/client/src/types.ts
64
+ var import_clsx = require("clsx");
65
+ var clsx = (...args) => (0, import_clsx.clsx)(...args);
66
+ var loadFonts = (fonts) => {
67
+ return fonts.map(({ name, nextFont, paths }) => nextFont ?? { name, paths });
68
+ };
69
+
70
+ // pkgs/@akanjs/client/src/csrTypes.ts
71
+ var import_react = require("react");
72
+ var DEFAULT_TOP_INSET = 48;
73
+ var DEFAULT_BOTTOM_INSET = 60;
74
+ var defaultPageState = {
75
+ transition: "none",
76
+ topSafeArea: 0,
77
+ bottomSafeArea: 0,
78
+ topInset: 0,
79
+ bottomInset: 0,
80
+ gesture: true,
81
+ cache: false
82
+ };
83
+ var csrContext = (0, import_react.createContext)({});
84
+ var useCsr = () => {
85
+ const contextValues = (0, import_react.useContext)(csrContext);
86
+ return contextValues;
87
+ };
88
+ var pathContext = (0, import_react.createContext)({});
89
+ var usePathCtx = () => {
90
+ const contextValues = (0, import_react.useContext)(pathContext);
91
+ return contextValues;
92
+ };
62
93
 
63
- // pkgs/@akanjs/base/src/base.ts
64
- var version = "0.9.0";
65
- var logo = `
94
+ // pkgs/@akanjs/base/src/base.ts
95
+ var version = "0.9.0";
96
+ var logo = `
66
97
  _ _ _
67
98
  / \\ | | ____ _ _ __ (_)___
68
99
  / _ \\ | |/ / _' | '_ \\ | / __|
@@ -74,1274 +105,1273 @@
74
105
 
75
106
  `;
76
107
 
77
- // pkgs/@akanjs/base/src/baseEnv.ts
78
- var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
79
- var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
80
- var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
81
- if (appName === "unknown")
82
- throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
83
- if (repoName === "unknown")
84
- throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
85
- if (serveDomain === "unknown")
86
- throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
87
- var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
88
- var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
89
- var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
90
- var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
91
- var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
92
- var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
93
- var baseEnv = {
94
- repoName,
95
- serveDomain,
96
- appName,
97
- environment,
98
- operationType,
99
- operationMode,
100
- networkType,
101
- tunnelUsername,
102
- tunnelPassword
103
- };
104
- var side = typeof window === "undefined" ? "server" : "client";
105
- var renderMode = process.env.RENDER_ENV ?? "ssr";
106
- var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
107
- var clientPort = parseInt(
108
- process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
109
- );
110
- var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
111
- var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
112
- var serverHost = process.env.SERVER_HOST ?? (operationMode === "local" ? typeof window === "undefined" ? "localhost" : window.location.host.split(":")[0] : renderMode === "csr" ? `${appName}-${environment}.${serveDomain}` : side === "client" ? window.location.host.split(":")[0] : operationMode === "cloud" ? `backend-svc.${appName}-${environment}.svc.cluster.local` : "localhost");
113
- var serverPort = parseInt(
114
- process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
115
- );
116
- var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
117
- var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
118
- var serverGraphqlUri = `${serverHttpUri}/graphql`;
119
- var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
120
- var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
121
- var baseClientEnv = {
122
- ...baseEnv,
123
- side,
124
- renderMode,
125
- websocket: true,
126
- clientHost,
127
- clientPort,
128
- clientHttpProtocol,
129
- clientHttpUri,
130
- serverHost,
131
- serverPort,
132
- serverHttpProtocol,
133
- serverHttpUri,
134
- serverGraphqlUri,
135
- serverWsProtocol,
136
- serverWsUri
137
- };
108
+ // pkgs/@akanjs/base/src/baseEnv.ts
109
+ var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
110
+ var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
111
+ var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
112
+ if (appName === "unknown")
113
+ throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
114
+ if (repoName === "unknown")
115
+ throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
116
+ if (serveDomain === "unknown")
117
+ throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
118
+ var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
119
+ var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
120
+ var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
121
+ var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
122
+ var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
123
+ var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
124
+ var baseEnv = {
125
+ repoName,
126
+ serveDomain,
127
+ appName,
128
+ environment,
129
+ operationType,
130
+ operationMode,
131
+ networkType,
132
+ tunnelUsername,
133
+ tunnelPassword
134
+ };
135
+ var side = typeof window === "undefined" ? "server" : "client";
136
+ var renderMode = process.env.RENDER_ENV ?? "ssr";
137
+ var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
138
+ var clientPort = parseInt(
139
+ process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
140
+ );
141
+ var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
142
+ var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
143
+ var serverHost = process.env.SERVER_HOST ?? (operationMode === "local" ? typeof window === "undefined" ? "localhost" : window.location.host.split(":")[0] : renderMode === "csr" ? `${appName}-${environment}.${serveDomain}` : side === "client" ? window.location.host.split(":")[0] : operationMode === "cloud" ? `backend-svc.${appName}-${environment}.svc.cluster.local` : "localhost");
144
+ var serverPort = parseInt(
145
+ process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
146
+ );
147
+ var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
148
+ var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
149
+ var serverGraphqlUri = `${serverHttpUri}/graphql`;
150
+ var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
151
+ var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
152
+ var baseClientEnv = {
153
+ ...baseEnv,
154
+ side,
155
+ renderMode,
156
+ websocket: true,
157
+ clientHost,
158
+ clientPort,
159
+ clientHttpProtocol,
160
+ clientHttpUri,
161
+ serverHost,
162
+ serverPort,
163
+ serverHttpProtocol,
164
+ serverHttpUri,
165
+ serverGraphqlUri,
166
+ serverWsProtocol,
167
+ serverWsUri
168
+ };
138
169
 
139
- // pkgs/@akanjs/base/src/scalar.ts
140
- var import_dayjs = __toESM(__require("dayjs"));
141
- var dayjs = import_dayjs.default;
142
- var Int = class {
143
- __Scalar__;
144
- };
145
- var Upload = class {
146
- __Scalar__;
147
- filename;
148
- mimetype;
149
- encoding;
150
- createReadStream;
151
- };
152
- var Float = class {
153
- __Scalar__;
154
- };
155
- var ID = class {
156
- __Scalar__;
157
- };
158
- var JSON2 = class {
159
- __Scalar__;
160
- };
161
- var getNonArrayModel = (arraiedModel2) => {
162
- let arrDepth = 0;
163
- let target = arraiedModel2;
164
- while (Array.isArray(target)) {
165
- target = target[0];
166
- arrDepth++;
167
- }
168
- return [target, arrDepth];
169
- };
170
- var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON2, Map]);
171
- var scalarNameMap = /* @__PURE__ */ new Map([
172
- [ID, "ID"],
173
- [Int, "Int"],
174
- [Float, "Float"],
175
- [String, "String"],
176
- [Boolean, "Boolean"],
177
- [Date, "Date"],
178
- [Upload, "Upload"],
179
- [JSON2, "JSON"],
180
- [Map, "Map"]
181
- ]);
182
- var scalarArgMap = /* @__PURE__ */ new Map([
183
- [ID, null],
184
- [String, ""],
185
- [Boolean, false],
186
- [Date, dayjs(/* @__PURE__ */ new Date(-1))],
187
- [Int, 0],
188
- [Float, 0],
189
- [JSON2, {}],
190
- [Map, {}]
191
- ]);
192
- var scalarDefaultMap = /* @__PURE__ */ new Map([
193
- [ID, null],
194
- [String, ""],
195
- [Boolean, false],
196
- [Date, dayjs(/* @__PURE__ */ new Date(-1))],
197
- [Int, 0],
198
- [Float, 0],
199
- [JSON2, {}]
200
- ]);
201
- var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
202
- var isGqlMap = (modelRef) => modelRef === Map;
170
+ // pkgs/@akanjs/base/src/scalar.ts
171
+ var import_dayjs = __toESM(require("dayjs"));
172
+ var dayjs = import_dayjs.default;
173
+ var Int = class {
174
+ __Scalar__;
175
+ };
176
+ var Upload = class {
177
+ __Scalar__;
178
+ filename;
179
+ mimetype;
180
+ encoding;
181
+ createReadStream;
182
+ };
183
+ var Float = class {
184
+ __Scalar__;
185
+ };
186
+ var ID = class {
187
+ __Scalar__;
188
+ };
189
+ var JSON2 = class {
190
+ __Scalar__;
191
+ };
192
+ var getNonArrayModel = (arraiedModel2) => {
193
+ let arrDepth = 0;
194
+ let target = arraiedModel2;
195
+ while (Array.isArray(target)) {
196
+ target = target[0];
197
+ arrDepth++;
198
+ }
199
+ return [target, arrDepth];
200
+ };
201
+ var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON2, Map]);
202
+ var scalarNameMap = /* @__PURE__ */ new Map([
203
+ [ID, "ID"],
204
+ [Int, "Int"],
205
+ [Float, "Float"],
206
+ [String, "String"],
207
+ [Boolean, "Boolean"],
208
+ [Date, "Date"],
209
+ [Upload, "Upload"],
210
+ [JSON2, "JSON"],
211
+ [Map, "Map"]
212
+ ]);
213
+ var scalarArgMap = /* @__PURE__ */ new Map([
214
+ [ID, null],
215
+ [String, ""],
216
+ [Boolean, false],
217
+ [Date, dayjs(/* @__PURE__ */ new Date(-1))],
218
+ [Int, 0],
219
+ [Float, 0],
220
+ [JSON2, {}],
221
+ [Map, {}]
222
+ ]);
223
+ var scalarDefaultMap = /* @__PURE__ */ new Map([
224
+ [ID, null],
225
+ [String, ""],
226
+ [Boolean, false],
227
+ [Date, dayjs(/* @__PURE__ */ new Date(-1))],
228
+ [Int, 0],
229
+ [Float, 0],
230
+ [JSON2, {}]
231
+ ]);
232
+ var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
233
+ var isGqlMap = (modelRef) => modelRef === Map;
203
234
 
204
- // pkgs/@akanjs/common/src/isDayjs.ts
205
- var import_dayjs2 = __require("dayjs");
235
+ // pkgs/@akanjs/common/src/isDayjs.ts
236
+ var import_dayjs2 = require("dayjs");
206
237
 
207
- // pkgs/@akanjs/common/src/isQueryEqual.ts
208
- var import_dayjs3 = __toESM(__require("dayjs"));
238
+ // pkgs/@akanjs/common/src/isQueryEqual.ts
239
+ var import_dayjs3 = __toESM(require("dayjs"));
209
240
 
210
- // pkgs/@akanjs/common/src/isValidDate.ts
211
- var import_dayjs4 = __toESM(__require("dayjs"));
212
- var import_customParseFormat = __toESM(__require("dayjs/plugin/customParseFormat"));
213
- import_dayjs4.default.extend(import_customParseFormat.default);
241
+ // pkgs/@akanjs/common/src/isValidDate.ts
242
+ var import_dayjs4 = __toESM(require("dayjs"));
243
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
244
+ import_dayjs4.default.extend(import_customParseFormat.default);
214
245
 
215
- // pkgs/@akanjs/common/src/pluralize.ts
216
- var import_pluralize = __toESM(__require("pluralize"));
246
+ // pkgs/@akanjs/common/src/pluralize.ts
247
+ var import_pluralize = __toESM(require("pluralize"));
217
248
 
218
- // pkgs/@akanjs/common/src/Logger.ts
219
- var import_dayjs5 = __toESM(__require("dayjs"));
220
- var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
221
- var clc = {
222
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
223
- green: (text) => `\x1B[32m${text}\x1B[39m`,
224
- yellow: (text) => `\x1B[33m${text}\x1B[39m`,
225
- red: (text) => `\x1B[31m${text}\x1B[39m`,
226
- magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
227
- cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
228
- };
229
- var colorizeMap = {
230
- trace: clc.bold,
231
- verbose: clc.cyanBright,
232
- debug: clc.magentaBright,
233
- log: clc.green,
234
- info: clc.green,
235
- warn: clc.yellow,
236
- error: clc.red
237
- };
238
- var Logger = class _Logger {
239
- static #ignoreCtxSet = /* @__PURE__ */ new Set([
240
- "InstanceLoader",
241
- "RoutesResolver",
242
- "RouterExplorer",
243
- "NestFactory",
244
- "WebSocketsController",
245
- "GraphQLModule",
246
- "NestApplication"
247
- ]);
248
- static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
249
- static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
250
- static #startAt = (0, import_dayjs5.default)();
251
- static setLevel(level) {
252
- this.level = level;
253
- this.#levelIdx = logLevels.findIndex((l) => l === level);
254
- }
255
- name;
256
- constructor(name) {
257
- this.name = name;
258
- }
259
- trace(msg, context = "") {
260
- if (_Logger.#levelIdx <= 0)
261
- _Logger.#printMessages(this.name ?? "App", msg, context, "trace");
262
- }
263
- verbose(msg, context = "") {
264
- if (_Logger.#levelIdx <= 1)
265
- _Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
266
- }
267
- debug(msg, context = "") {
268
- if (_Logger.#levelIdx <= 2)
269
- _Logger.#printMessages(this.name ?? "App", msg, context, "debug");
270
- }
271
- log(msg, context = "") {
272
- if (_Logger.#levelIdx <= 3)
273
- _Logger.#printMessages(this.name ?? "App", msg, context, "log");
274
- }
275
- info(msg, context = "") {
276
- if (_Logger.#levelIdx <= 4)
277
- _Logger.#printMessages(this.name ?? "App", msg, context, "info");
278
- }
279
- warn(msg, context = "") {
280
- if (_Logger.#levelIdx <= 5)
281
- _Logger.#printMessages(this.name ?? "App", msg, context, "warn");
282
- }
283
- error(msg, context = "") {
284
- if (_Logger.#levelIdx <= 6)
285
- _Logger.#printMessages(this.name ?? "App", msg, context, "error");
286
- }
287
- raw(msg, method) {
288
- _Logger.rawLog(msg, method);
289
- }
290
- rawLog(msg, method) {
291
- _Logger.rawLog(msg, method);
292
- }
293
- static trace(msg, context = "") {
294
- if (_Logger.#levelIdx <= 0)
295
- _Logger.#printMessages("App", msg, context, "trace");
296
- }
297
- static verbose(msg, context = "") {
298
- if (_Logger.#levelIdx <= 1)
299
- _Logger.#printMessages("App", msg, context, "verbose");
300
- }
301
- static debug(msg, context = "") {
302
- if (_Logger.#levelIdx <= 2)
303
- _Logger.#printMessages("App", msg, context, "debug");
304
- }
305
- static log(msg, context = "") {
306
- if (_Logger.#levelIdx <= 3)
307
- _Logger.#printMessages("App", msg, context, "log");
308
- }
309
- static info(msg, context = "") {
310
- if (_Logger.#levelIdx <= 4)
311
- _Logger.#printMessages("App", msg, context, "info");
312
- }
313
- static warn(msg, context = "") {
314
- if (_Logger.#levelIdx <= 5)
315
- _Logger.#printMessages("App", msg, context, "warn");
316
- }
317
- static error(msg, context = "") {
318
- if (_Logger.#levelIdx <= 6)
319
- _Logger.#printMessages("App", msg, context, "error");
320
- }
321
- static #colorize(msg, logLevel) {
322
- return colorizeMap[logLevel](msg);
323
- }
324
- static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
325
- if (this.#ignoreCtxSet.has(context))
326
- return;
327
- const now = (0, import_dayjs5.default)();
328
- const processMsg = this.#colorize(
329
- `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
330
- logLevel
331
- );
332
- const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
333
- const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
334
- const contextMsg = context ? clc.yellow(`[${context}] `) : "";
335
- const contentMsg = this.#colorize(content, logLevel);
336
- const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
337
- if (typeof window === "undefined")
338
- process[writeStreamType].write(
339
- `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
249
+ // pkgs/@akanjs/common/src/Logger.ts
250
+ var import_dayjs5 = __toESM(require("dayjs"));
251
+ var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
252
+ var clc = {
253
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
254
+ green: (text) => `\x1B[32m${text}\x1B[39m`,
255
+ yellow: (text) => `\x1B[33m${text}\x1B[39m`,
256
+ red: (text) => `\x1B[31m${text}\x1B[39m`,
257
+ magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
258
+ cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
259
+ };
260
+ var colorizeMap = {
261
+ trace: clc.bold,
262
+ verbose: clc.cyanBright,
263
+ debug: clc.magentaBright,
264
+ log: clc.green,
265
+ info: clc.green,
266
+ warn: clc.yellow,
267
+ error: clc.red
268
+ };
269
+ var Logger = class _Logger {
270
+ static #ignoreCtxSet = /* @__PURE__ */ new Set([
271
+ "InstanceLoader",
272
+ "RoutesResolver",
273
+ "RouterExplorer",
274
+ "NestFactory",
275
+ "WebSocketsController",
276
+ "GraphQLModule",
277
+ "NestApplication"
278
+ ]);
279
+ static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
280
+ static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
281
+ static #startAt = (0, import_dayjs5.default)();
282
+ static setLevel(level) {
283
+ this.level = level;
284
+ this.#levelIdx = logLevels.findIndex((l) => l === level);
285
+ }
286
+ name;
287
+ constructor(name) {
288
+ this.name = name;
289
+ }
290
+ trace(msg, context = "") {
291
+ if (_Logger.#levelIdx <= 0)
292
+ _Logger.#printMessages(this.name ?? "App", msg, context, "trace");
293
+ }
294
+ verbose(msg, context = "") {
295
+ if (_Logger.#levelIdx <= 1)
296
+ _Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
297
+ }
298
+ debug(msg, context = "") {
299
+ if (_Logger.#levelIdx <= 2)
300
+ _Logger.#printMessages(this.name ?? "App", msg, context, "debug");
301
+ }
302
+ log(msg, context = "") {
303
+ if (_Logger.#levelIdx <= 3)
304
+ _Logger.#printMessages(this.name ?? "App", msg, context, "log");
305
+ }
306
+ info(msg, context = "") {
307
+ if (_Logger.#levelIdx <= 4)
308
+ _Logger.#printMessages(this.name ?? "App", msg, context, "info");
309
+ }
310
+ warn(msg, context = "") {
311
+ if (_Logger.#levelIdx <= 5)
312
+ _Logger.#printMessages(this.name ?? "App", msg, context, "warn");
313
+ }
314
+ error(msg, context = "") {
315
+ if (_Logger.#levelIdx <= 6)
316
+ _Logger.#printMessages(this.name ?? "App", msg, context, "error");
317
+ }
318
+ raw(msg, method) {
319
+ _Logger.rawLog(msg, method);
320
+ }
321
+ rawLog(msg, method) {
322
+ _Logger.rawLog(msg, method);
323
+ }
324
+ static trace(msg, context = "") {
325
+ if (_Logger.#levelIdx <= 0)
326
+ _Logger.#printMessages("App", msg, context, "trace");
327
+ }
328
+ static verbose(msg, context = "") {
329
+ if (_Logger.#levelIdx <= 1)
330
+ _Logger.#printMessages("App", msg, context, "verbose");
331
+ }
332
+ static debug(msg, context = "") {
333
+ if (_Logger.#levelIdx <= 2)
334
+ _Logger.#printMessages("App", msg, context, "debug");
335
+ }
336
+ static log(msg, context = "") {
337
+ if (_Logger.#levelIdx <= 3)
338
+ _Logger.#printMessages("App", msg, context, "log");
339
+ }
340
+ static info(msg, context = "") {
341
+ if (_Logger.#levelIdx <= 4)
342
+ _Logger.#printMessages("App", msg, context, "info");
343
+ }
344
+ static warn(msg, context = "") {
345
+ if (_Logger.#levelIdx <= 5)
346
+ _Logger.#printMessages("App", msg, context, "warn");
347
+ }
348
+ static error(msg, context = "") {
349
+ if (_Logger.#levelIdx <= 6)
350
+ _Logger.#printMessages("App", msg, context, "error");
351
+ }
352
+ static #colorize(msg, logLevel) {
353
+ return colorizeMap[logLevel](msg);
354
+ }
355
+ static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
356
+ if (this.#ignoreCtxSet.has(context))
357
+ return;
358
+ const now = (0, import_dayjs5.default)();
359
+ const processMsg = this.#colorize(
360
+ `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
361
+ logLevel
362
+ );
363
+ const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
364
+ const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
365
+ const contextMsg = context ? clc.yellow(`[${context}] `) : "";
366
+ const contentMsg = this.#colorize(content, logLevel);
367
+ const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
368
+ if (typeof window === "undefined")
369
+ process[writeStreamType].write(
370
+ `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
340
371
  `
341
- );
342
- else
343
- console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
372
+ );
373
+ else
374
+ console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
344
375
  `);
345
- }
346
- static rawLog(msg, method) {
347
- this.raw(`${msg}
376
+ }
377
+ static rawLog(msg, method) {
378
+ this.raw(`${msg}
348
379
  `, method);
349
- }
350
- static raw(msg, method) {
351
- if (typeof window === "undefined" && method !== "console" && global.process)
352
- global.process.stdout.write(msg);
353
- else
354
- console.log(msg);
355
- }
356
- };
380
+ }
381
+ static raw(msg, method) {
382
+ if (typeof window === "undefined" && method !== "console" && global.process)
383
+ global.process.stdout.write(msg);
384
+ else
385
+ console.log(msg);
386
+ }
387
+ };
357
388
 
358
- // pkgs/@akanjs/common/src/lowerlize.ts
359
- var lowerlize = (str) => {
360
- return str.charAt(0).toLowerCase() + str.slice(1);
361
- };
389
+ // pkgs/@akanjs/common/src/lowerlize.ts
390
+ var lowerlize = (str) => {
391
+ return str.charAt(0).toLowerCase() + str.slice(1);
392
+ };
362
393
 
363
- // pkgs/@akanjs/common/src/sleep.ts
364
- var sleep = async (ms) => {
365
- return new Promise((resolve) => {
366
- setTimeout(() => {
367
- resolve(true);
368
- }, ms);
369
- });
370
- };
394
+ // pkgs/@akanjs/common/src/sleep.ts
395
+ var sleep = async (ms) => {
396
+ return new Promise((resolve) => {
397
+ setTimeout(() => {
398
+ resolve(true);
399
+ }, ms);
400
+ });
401
+ };
371
402
 
372
- // pkgs/@akanjs/client/src/router.ts
373
- var import_navigation = __require("next/navigation");
374
- var getPathInfo = (href, lang, prefix) => {
375
- const langLength = lang.length + 1;
376
- const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
377
- const prefixLength = prefix ? prefix.length + 1 : 0;
378
- const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
379
- const subRoute = prefix ? `/${prefix}` : "";
380
- const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
381
- return { path, pathname };
403
+ // pkgs/@akanjs/client/src/router.ts
404
+ var import_navigation = require("next/navigation");
405
+ var getPathInfo = (href, lang, prefix) => {
406
+ const langLength = lang.length + 1;
407
+ const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
408
+ const prefixLength = prefix ? prefix.length + 1 : 0;
409
+ const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
410
+ const subRoute = prefix ? `/${prefix}` : "";
411
+ const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
412
+ return { path, pathname };
413
+ };
414
+ var Router = class {
415
+ isInitialized = false;
416
+ #prefix = "";
417
+ #lang = "en";
418
+ #instance = {
419
+ push: (href) => {
420
+ const { pathname } = this.#getPathInfo(href);
421
+ Logger.log(`push to:${pathname}`);
422
+ if (baseClientEnv.side === "server")
423
+ void (0, import_navigation.redirect)(pathname);
424
+ },
425
+ replace: (href) => {
426
+ const { pathname } = this.#getPathInfo(href);
427
+ Logger.log(`replace to:${pathname}`);
428
+ if (baseClientEnv.side === "server")
429
+ void (0, import_navigation.redirect)(pathname);
430
+ },
431
+ back: () => {
432
+ throw new Error("back is only available in client");
433
+ },
434
+ refresh: () => {
435
+ throw new Error("refresh is only available in client");
436
+ }
382
437
  };
383
- var Router = class {
384
- isInitialized = false;
385
- #prefix = "";
386
- #lang = "en";
387
- #instance = {
438
+ init(options) {
439
+ this.#prefix = options.prefix ?? "";
440
+ this.#lang = options.lang ?? "en";
441
+ if (options.type === "csr")
442
+ this.#initCSRClientRouter(options);
443
+ else if (options.side === "server")
444
+ this.#initNextServerRouter(options);
445
+ else
446
+ this.#initNextClientRouter(options);
447
+ this.isInitialized = true;
448
+ Logger.verbose("Router initialized");
449
+ }
450
+ #initNextServerRouter(options) {
451
+ }
452
+ #initNextClientRouter(options) {
453
+ this.#instance = {
388
454
  push: (href) => {
389
- const { pathname } = this.#getPathInfo(href);
390
- Logger.log(`push to:${pathname}`);
391
- if (baseClientEnv.side === "server")
392
- void (0, import_navigation.redirect)(pathname);
455
+ const { path, pathname } = this.#getPathInfo(href);
456
+ this.#postPathChange({ path, pathname });
457
+ options.router.push(pathname);
393
458
  },
394
459
  replace: (href) => {
395
- const { pathname } = this.#getPathInfo(href);
396
- Logger.log(`replace to:${pathname}`);
397
- if (baseClientEnv.side === "server")
398
- void (0, import_navigation.redirect)(pathname);
460
+ const { path, pathname } = this.#getPathInfo(href);
461
+ this.#postPathChange({ path, pathname });
462
+ options.router.replace(pathname);
399
463
  },
400
464
  back: () => {
401
- throw new Error("back is only available in client");
465
+ const { path, pathname } = this.#getPathInfo(document.referrer);
466
+ this.#postPathChange({ path, pathname });
467
+ options.router.back();
402
468
  },
403
469
  refresh: () => {
404
- throw new Error("refresh is only available in client");
470
+ const { path, pathname } = this.#getPathInfo(location.pathname);
471
+ this.#postPathChange({ path, pathname });
472
+ options.router.refresh();
405
473
  }
406
474
  };
407
- init(options) {
408
- this.#prefix = options.prefix ?? "";
409
- this.#lang = options.lang ?? "en";
410
- if (options.type === "csr")
411
- this.#initCSRClientRouter(options);
412
- else if (options.side === "server")
413
- this.#initNextServerRouter(options);
414
- else
415
- this.#initNextClientRouter(options);
416
- this.isInitialized = true;
417
- Logger.verbose("Router initialized");
418
- }
419
- #initNextServerRouter(options) {
420
- }
421
- #initNextClientRouter(options) {
422
- this.#instance = {
423
- push: (href) => {
424
- const { path, pathname } = this.#getPathInfo(href);
425
- this.#postPathChange({ path, pathname });
426
- options.router.push(pathname);
427
- },
428
- replace: (href) => {
429
- const { path, pathname } = this.#getPathInfo(href);
430
- this.#postPathChange({ path, pathname });
431
- options.router.replace(pathname);
432
- },
433
- back: () => {
434
- const { path, pathname } = this.#getPathInfo(document.referrer);
435
- this.#postPathChange({ path, pathname });
436
- options.router.back();
437
- },
438
- refresh: () => {
439
- const { path, pathname } = this.#getPathInfo(location.pathname);
440
- this.#postPathChange({ path, pathname });
441
- options.router.refresh();
442
- }
443
- };
444
- }
445
- #initCSRClientRouter(options) {
446
- this.#instance = {
447
- push: (href) => {
448
- const { path, pathname } = this.#getPathInfo(href);
449
- if (location.pathname === pathname)
450
- return;
451
- this.#postPathChange({ path, pathname });
452
- options.router.push(pathname);
453
- },
454
- replace: (href) => {
455
- const { path, pathname } = this.#getPathInfo(href);
456
- if (location.pathname === pathname)
457
- return;
458
- this.#postPathChange({ path, pathname });
459
- options.router.replace(pathname);
460
- },
461
- back: () => {
462
- const { path, pathname } = this.#getPathInfo(document.referrer);
463
- if (location.pathname === pathname)
464
- return;
465
- this.#postPathChange({ path, pathname });
466
- options.router.back();
467
- },
468
- refresh: () => {
469
- const { path, pathname } = this.#getPathInfo(location.pathname);
470
- this.#postPathChange({ path, pathname });
471
- options.router.refresh();
472
- }
473
- };
474
- }
475
- #checkInitialized() {
476
- if (!this.isInitialized)
477
- throw new Error("Router is not initialized");
478
- }
479
- #getPathInfo(href, prefix = this.#prefix) {
480
- return getPathInfo(href, this.#lang, prefix);
481
- }
482
- #postPathChange({ path, pathname }) {
483
- Logger.log(`pathChange-start:${path}`);
484
- window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
485
- }
486
- push(href) {
487
- this.#checkInitialized();
488
- this.#instance.push(href);
489
- return void 0;
490
- }
491
- replace(href) {
492
- this.#checkInitialized();
493
- this.#instance.replace(href);
494
- return void 0;
495
- }
496
- back() {
497
- if (baseClientEnv.side === "server")
498
- throw new Error("back is only available in client side");
499
- this.#checkInitialized();
500
- this.#instance.back();
501
- return void 0;
502
- }
503
- refresh() {
504
- if (baseClientEnv.side === "server")
505
- throw new Error("refresh is only available in client side");
506
- this.#checkInitialized();
507
- this.#instance.refresh();
508
- return void 0;
509
- }
510
- async redirect(href) {
511
- if (baseClientEnv.side === "server") {
512
- const nextHeaders = __require("next/headers");
513
- const headers2 = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
514
- const lang = headers2.get("x-locale") ?? this.#lang;
515
- const basePath = headers2.get("x-base-path");
516
- const { pathname } = getPathInfo(href, lang, basePath ?? "");
517
- Logger.log(`redirect to:${pathname}`);
518
- (0, import_navigation.redirect)(pathname);
519
- } else {
520
- const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
521
- this.#instance.replace(pathname);
475
+ }
476
+ #initCSRClientRouter(options) {
477
+ this.#instance = {
478
+ push: (href) => {
479
+ const { path, pathname } = this.#getPathInfo(href);
480
+ if (location.pathname === pathname)
481
+ return;
482
+ this.#postPathChange({ path, pathname });
483
+ options.router.push(pathname);
484
+ },
485
+ replace: (href) => {
486
+ const { path, pathname } = this.#getPathInfo(href);
487
+ if (location.pathname === pathname)
488
+ return;
489
+ this.#postPathChange({ path, pathname });
490
+ options.router.replace(pathname);
491
+ },
492
+ back: () => {
493
+ const { path, pathname } = this.#getPathInfo(document.referrer);
494
+ if (location.pathname === pathname)
495
+ return;
496
+ this.#postPathChange({ path, pathname });
497
+ options.router.back();
498
+ },
499
+ refresh: () => {
500
+ const { path, pathname } = this.#getPathInfo(location.pathname);
501
+ this.#postPathChange({ path, pathname });
502
+ options.router.refresh();
522
503
  }
523
- return void 0;
524
- }
525
- notFound() {
526
- this.#checkInitialized();
527
- if (baseClientEnv.side === "server") {
528
- Logger.log(`redirect to:/404`);
529
- (0, import_navigation.notFound)();
530
- } else
531
- this.#instance.replace("/404");
532
- return void 0;
533
- }
534
- setLang(lang) {
535
- if (baseClientEnv.side === "server")
536
- throw new Error("setLang is only available in client side");
537
- this.#checkInitialized();
538
- const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
539
- this.#lang = lang;
540
- this.#instance.replace(`/${lang}${path}`);
541
- return void 0;
542
- }
543
- getPath(pathname = window.location.pathname) {
544
- if (baseClientEnv.side === "server")
545
- throw new Error("getPath is only available in client side");
546
- const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
547
- return path;
548
- }
549
- getFullPath(withLang = true) {
550
- if (baseClientEnv.side === "server")
551
- throw new Error("getPath is only available in client side");
552
- return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
553
- }
554
- getPrefix() {
555
- return this.#prefix;
556
- }
557
- getPrefixedPath(path) {
558
- return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
559
- }
560
- };
561
- var router = new Router();
504
+ };
505
+ }
506
+ #checkInitialized() {
507
+ if (!this.isInitialized)
508
+ throw new Error("Router is not initialized");
509
+ }
510
+ #getPathInfo(href, prefix = this.#prefix) {
511
+ return getPathInfo(href, this.#lang, prefix);
512
+ }
513
+ #postPathChange({ path, pathname }) {
514
+ Logger.log(`pathChange-start:${path}`);
515
+ window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
516
+ }
517
+ push(href) {
518
+ this.#checkInitialized();
519
+ this.#instance.push(href);
520
+ return void 0;
521
+ }
522
+ replace(href) {
523
+ this.#checkInitialized();
524
+ this.#instance.replace(href);
525
+ return void 0;
526
+ }
527
+ back() {
528
+ if (baseClientEnv.side === "server")
529
+ throw new Error("back is only available in client side");
530
+ this.#checkInitialized();
531
+ this.#instance.back();
532
+ return void 0;
533
+ }
534
+ refresh() {
535
+ if (baseClientEnv.side === "server")
536
+ throw new Error("refresh is only available in client side");
537
+ this.#checkInitialized();
538
+ this.#instance.refresh();
539
+ return void 0;
540
+ }
541
+ async redirect(href) {
542
+ if (baseClientEnv.side === "server") {
543
+ const nextHeaders = require("next/headers");
544
+ const headers2 = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
545
+ const lang = headers2.get("x-locale") ?? this.#lang;
546
+ const basePath = headers2.get("x-base-path");
547
+ const { pathname } = getPathInfo(href, lang, basePath ?? "");
548
+ Logger.log(`redirect to:${pathname}`);
549
+ (0, import_navigation.redirect)(pathname);
550
+ } else {
551
+ const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
552
+ this.#instance.replace(pathname);
553
+ }
554
+ return void 0;
555
+ }
556
+ notFound() {
557
+ this.#checkInitialized();
558
+ if (baseClientEnv.side === "server") {
559
+ Logger.log(`redirect to:/404`);
560
+ (0, import_navigation.notFound)();
561
+ } else
562
+ this.#instance.replace("/404");
563
+ return void 0;
564
+ }
565
+ setLang(lang) {
566
+ if (baseClientEnv.side === "server")
567
+ throw new Error("setLang is only available in client side");
568
+ this.#checkInitialized();
569
+ const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
570
+ this.#lang = lang;
571
+ this.#instance.replace(`/${lang}${path}`);
572
+ return void 0;
573
+ }
574
+ getPath(pathname = window.location.pathname) {
575
+ if (baseClientEnv.side === "server")
576
+ throw new Error("getPath is only available in client side");
577
+ const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
578
+ return path;
579
+ }
580
+ getFullPath(withLang = true) {
581
+ if (baseClientEnv.side === "server")
582
+ throw new Error("getPath is only available in client side");
583
+ return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
584
+ }
585
+ getPrefix() {
586
+ return this.#prefix;
587
+ }
588
+ getPrefixedPath(path) {
589
+ return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
590
+ }
591
+ };
592
+ var router = new Router();
562
593
 
563
- // pkgs/@akanjs/signal/src/client.ts
564
- var import_core = __require("@urql/core");
565
- var import_socket = __require("socket.io-client");
566
- var SocketIo = class {
567
- socket;
568
- roomSubscribeMap = /* @__PURE__ */ new Map();
569
- constructor(uri) {
570
- this.socket = (0, import_socket.io)(uri, { transports: ["websocket"] });
571
- this.socket.on("connect", () => {
572
- this.roomSubscribeMap.forEach((option) => {
573
- this.socket.emit(option.key, { ...option.message, __subscribe__: true });
574
- });
575
- });
576
- }
577
- on(event, callback) {
578
- this.socket.on(event, callback);
579
- }
580
- removeListener(event, callback) {
581
- this.socket.removeListener(event, callback);
582
- }
583
- removeAllListeners() {
584
- this.socket.removeAllListeners();
585
- }
586
- hasListeners(event) {
587
- return this.socket.hasListeners(event);
588
- }
589
- emit(key, data) {
590
- this.socket.emit(key, data);
591
- }
592
- subscribe(option) {
593
- if (!this.roomSubscribeMap.has(option.roomId)) {
594
- this.roomSubscribeMap.set(option.roomId, option);
594
+ // pkgs/@akanjs/signal/src/client.ts
595
+ var import_core = require("@urql/core");
596
+ var import_socket = require("socket.io-client");
597
+ var SocketIo = class {
598
+ socket;
599
+ roomSubscribeMap = /* @__PURE__ */ new Map();
600
+ constructor(uri) {
601
+ this.socket = (0, import_socket.io)(uri, { transports: ["websocket"] });
602
+ this.socket.on("connect", () => {
603
+ this.roomSubscribeMap.forEach((option) => {
595
604
  this.socket.emit(option.key, { ...option.message, __subscribe__: true });
596
- }
597
- this.socket.on(option.roomId, option.handleEvent);
598
- }
599
- unsubscribe(roomId, handleEvent) {
600
- this.socket.removeListener(roomId, handleEvent);
601
- const option = this.roomSubscribeMap.get(roomId);
602
- if (this.hasListeners(roomId) || !option)
603
- return;
604
- this.roomSubscribeMap.delete(roomId);
605
- this.socket.emit(option.key, { ...option.message, __subscribe__: false });
606
- }
607
- disconnect() {
608
- this.socket.disconnect();
609
- return this;
610
- }
611
- };
612
- var Client = class _Client {
613
- static globalIoMap = /* @__PURE__ */ new Map();
614
- static tokenStore = /* @__PURE__ */ new Map();
615
- async waitUntilWebSocketConnected(ws = baseClientEnv.serverWsUri) {
616
- if (baseClientEnv.side === "server")
617
- return true;
618
- while (!this.getIo(ws).socket.connected) {
619
- Logger.verbose("waiting for websocket to initialize...");
620
- await sleep(300);
621
- }
622
- }
623
- isInitialized = false;
624
- uri = baseClientEnv.serverGraphqlUri;
625
- ws = baseClientEnv.serverWsUri;
626
- udp = null;
627
- gql = (0, import_core.createClient)({ url: this.uri, fetch, exchanges: [import_core.cacheExchange, import_core.fetchExchange] });
628
- jwt = null;
629
- async getJwt() {
630
- const isNextServer = baseClientEnv.side === "server" && baseEnv.operationType === "client";
631
- if (isNextServer) {
632
- const nextHeaders = __require("next/headers");
633
- return (await nextHeaders.cookies?.())?.get("jwt")?.value ?? (await nextHeaders.headers?.())?.get("jwt") ?? this.jwt ?? null;
634
- } else
635
- return _Client.tokenStore.get(this) ?? null;
636
- }
637
- io = null;
638
- init(data = {}) {
639
- Object.assign(this, data);
640
- this.setLink(data.uri);
641
- this.setIo(data.ws);
642
- this.isInitialized = true;
643
- }
644
- setIo(ws = baseClientEnv.serverWsUri) {
645
- this.ws = ws;
646
- const existingIo = _Client.globalIoMap.get(ws);
647
- if (existingIo) {
648
- this.io = existingIo;
649
- return;
650
- }
651
- this.io = new SocketIo(ws);
652
- _Client.globalIoMap.set(ws, this.io);
653
- }
654
- getIo(ws = baseClientEnv.serverWsUri) {
655
- const existingIo = _Client.globalIoMap.get(ws);
656
- if (existingIo)
657
- return existingIo;
658
- const io2 = new SocketIo(ws);
659
- _Client.globalIoMap.set(ws, io2);
660
- return io2;
661
- }
662
- setLink(uri = baseClientEnv.serverGraphqlUri) {
663
- this.uri = uri;
664
- this.gql = (0, import_core.createClient)({
665
- url: this.uri,
666
- fetch,
667
- exchanges: [import_core.cacheExchange, import_core.fetchExchange],
668
- // requestPolicy: "network-only",
669
- fetchOptions: () => {
670
- return {
671
- headers: {
672
- "apollo-require-preflight": "true",
673
- ...this.jwt ? { authorization: `Bearer ${this.jwt}` } : {}
674
- }
675
- };
676
- }
677
605
  });
606
+ });
607
+ }
608
+ on(event, callback) {
609
+ this.socket.on(event, callback);
610
+ }
611
+ removeListener(event, callback) {
612
+ this.socket.removeListener(event, callback);
613
+ }
614
+ removeAllListeners() {
615
+ this.socket.removeAllListeners();
616
+ }
617
+ hasListeners(event) {
618
+ return this.socket.hasListeners(event);
619
+ }
620
+ emit(key, data) {
621
+ this.socket.emit(key, data);
622
+ }
623
+ subscribe(option) {
624
+ if (!this.roomSubscribeMap.has(option.roomId)) {
625
+ this.roomSubscribeMap.set(option.roomId, option);
626
+ this.socket.emit(option.key, { ...option.message, __subscribe__: true });
678
627
  }
679
- setJwt(jwt) {
680
- _Client.tokenStore.set(this, jwt);
681
- }
682
- reset() {
683
- this.io?.disconnect();
684
- this.io = null;
685
- this.jwt = null;
686
- }
687
- clone(data = {}) {
688
- const newClient = new _Client();
689
- newClient.init({ ...this, ...data });
690
- if (data.jwt)
691
- _Client.tokenStore.set(newClient, data.jwt);
692
- return newClient;
693
- }
694
- terminate() {
695
- this.reset();
696
- _Client.globalIoMap.forEach((io2) => io2.disconnect());
697
- this.isInitialized = false;
628
+ this.socket.on(option.roomId, option.handleEvent);
629
+ }
630
+ unsubscribe(roomId, handleEvent) {
631
+ this.socket.removeListener(roomId, handleEvent);
632
+ const option = this.roomSubscribeMap.get(roomId);
633
+ if (this.hasListeners(roomId) || !option)
634
+ return;
635
+ this.roomSubscribeMap.delete(roomId);
636
+ this.socket.emit(option.key, { ...option.message, __subscribe__: false });
637
+ }
638
+ disconnect() {
639
+ this.socket.disconnect();
640
+ return this;
641
+ }
642
+ };
643
+ var Client = class _Client {
644
+ static globalIoMap = /* @__PURE__ */ new Map();
645
+ static tokenStore = /* @__PURE__ */ new Map();
646
+ async waitUntilWebSocketConnected(ws = baseClientEnv.serverWsUri) {
647
+ if (baseClientEnv.side === "server")
648
+ return true;
649
+ while (!this.getIo(ws).socket.connected) {
650
+ Logger.verbose("waiting for websocket to initialize...");
651
+ await sleep(300);
698
652
  }
699
- setUdp(udp) {
700
- this.udp = udp;
653
+ }
654
+ isInitialized = false;
655
+ uri = baseClientEnv.serverGraphqlUri;
656
+ ws = baseClientEnv.serverWsUri;
657
+ udp = null;
658
+ gql = (0, import_core.createClient)({ url: this.uri, fetch, exchanges: [import_core.cacheExchange, import_core.fetchExchange] });
659
+ jwt = null;
660
+ async getJwt() {
661
+ const isNextServer = baseClientEnv.side === "server" && baseEnv.operationType === "client";
662
+ if (isNextServer) {
663
+ const nextHeaders = require("next/headers");
664
+ return (await nextHeaders.cookies?.())?.get("jwt")?.value ?? (await nextHeaders.headers?.())?.get("jwt") ?? this.jwt ?? null;
665
+ } else
666
+ return _Client.tokenStore.get(this) ?? null;
667
+ }
668
+ io = null;
669
+ init(data = {}) {
670
+ Object.assign(this, data);
671
+ this.setLink(data.uri);
672
+ this.setIo(data.ws);
673
+ this.isInitialized = true;
674
+ }
675
+ setIo(ws = baseClientEnv.serverWsUri) {
676
+ this.ws = ws;
677
+ const existingIo = _Client.globalIoMap.get(ws);
678
+ if (existingIo) {
679
+ this.io = existingIo;
680
+ return;
701
681
  }
702
- };
703
- var client = new Client();
682
+ this.io = new SocketIo(ws);
683
+ _Client.globalIoMap.set(ws, this.io);
684
+ }
685
+ getIo(ws = baseClientEnv.serverWsUri) {
686
+ const existingIo = _Client.globalIoMap.get(ws);
687
+ if (existingIo)
688
+ return existingIo;
689
+ const io2 = new SocketIo(ws);
690
+ _Client.globalIoMap.set(ws, io2);
691
+ return io2;
692
+ }
693
+ setLink(uri = baseClientEnv.serverGraphqlUri) {
694
+ this.uri = uri;
695
+ this.gql = (0, import_core.createClient)({
696
+ url: this.uri,
697
+ fetch,
698
+ exchanges: [import_core.cacheExchange, import_core.fetchExchange],
699
+ // requestPolicy: "network-only",
700
+ fetchOptions: () => {
701
+ return {
702
+ headers: {
703
+ "apollo-require-preflight": "true",
704
+ ...this.jwt ? { authorization: `Bearer ${this.jwt}` } : {}
705
+ }
706
+ };
707
+ }
708
+ });
709
+ }
710
+ setJwt(jwt) {
711
+ _Client.tokenStore.set(this, jwt);
712
+ }
713
+ reset() {
714
+ this.io?.disconnect();
715
+ this.io = null;
716
+ this.jwt = null;
717
+ }
718
+ clone(data = {}) {
719
+ const newClient = new _Client();
720
+ newClient.init({ ...this, ...data });
721
+ if (data.jwt)
722
+ _Client.tokenStore.set(newClient, data.jwt);
723
+ return newClient;
724
+ }
725
+ terminate() {
726
+ this.reset();
727
+ _Client.globalIoMap.forEach((io2) => io2.disconnect());
728
+ this.isInitialized = false;
729
+ }
730
+ setUdp(udp) {
731
+ this.udp = udp;
732
+ }
733
+ };
734
+ var client = new Client();
704
735
 
705
- // pkgs/@akanjs/constant/src/scalar.ts
706
- var import_reflect_metadata = __require("reflect-metadata");
707
- var scalarExampleMap = /* @__PURE__ */ new Map([
708
- [ID, "1234567890abcdef12345678"],
709
- [Int, 0],
710
- [Float, 0],
711
- [String, "String"],
712
- [Boolean, true],
713
- [Date, (/* @__PURE__ */ new Date()).toISOString()],
714
- [Upload, "FileUpload"],
715
- [JSON2, {}],
716
- [Map, {}]
717
- ]);
718
- var getClassMeta = (modelRef) => {
719
- const [target] = getNonArrayModel(modelRef);
720
- const classMeta = Reflect.getMetadata("class", target.prototype);
721
- if (!classMeta)
722
- throw new Error(`No ClassMeta for this target ${target.name}`);
723
- return classMeta;
724
- };
725
- var getFieldMetas = (modelRef) => {
726
- const [target] = getNonArrayModel(modelRef);
727
- const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
728
- const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
729
- return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
730
- };
731
- var getFieldMetaMapOnPrototype = (prototype) => {
732
- const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
733
- return new Map(metadataMap);
734
- };
735
- var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
736
- Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
737
- };
736
+ // pkgs/@akanjs/constant/src/scalar.ts
737
+ var import_reflect_metadata = require("reflect-metadata");
738
+ var scalarExampleMap = /* @__PURE__ */ new Map([
739
+ [ID, "1234567890abcdef12345678"],
740
+ [Int, 0],
741
+ [Float, 0],
742
+ [String, "String"],
743
+ [Boolean, true],
744
+ [Date, (/* @__PURE__ */ new Date()).toISOString()],
745
+ [Upload, "FileUpload"],
746
+ [JSON2, {}],
747
+ [Map, {}]
748
+ ]);
749
+ var getClassMeta = (modelRef) => {
750
+ const [target] = getNonArrayModel(modelRef);
751
+ const classMeta = Reflect.getMetadata("class", target.prototype);
752
+ if (!classMeta)
753
+ throw new Error(`No ClassMeta for this target ${target.name}`);
754
+ return classMeta;
755
+ };
756
+ var getFieldMetas = (modelRef) => {
757
+ const [target] = getNonArrayModel(modelRef);
758
+ const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
759
+ const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
760
+ return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
761
+ };
762
+ var getFieldMetaMapOnPrototype = (prototype) => {
763
+ const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
764
+ return new Map(metadataMap);
765
+ };
766
+ var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
767
+ Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
768
+ };
738
769
 
739
- // pkgs/@akanjs/constant/src/fieldMeta.ts
740
- var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
741
- const isArray = arrDepth > 0;
742
- const isClass = !isGqlScalar(modelRef);
743
- const isMap = isGqlMap(modelRef);
744
- const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
745
- const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
746
- if (isMap && !option.of)
747
- throw new Error("Map type must have 'of' option");
748
- return (prototype, key) => {
749
- const metadata = {
750
- nullable: option.nullable ?? false,
751
- ref: option.ref,
752
- refPath: option.refPath,
753
- refType: option.refType,
754
- default: option.default ?? (isArray ? [] : null),
755
- type: option.type,
756
- fieldType: option.fieldType ?? "property",
757
- immutable: option.immutable ?? false,
758
- min: option.min,
759
- max: option.max,
760
- enum: option.enum,
761
- select: option.select ?? true,
762
- minlength: option.minlength,
763
- maxlength: option.maxlength,
764
- query: option.query,
765
- accumulate: option.accumulate,
766
- example: option.example,
767
- validate: option.validate,
768
- key,
769
- name,
770
- isClass,
771
- isScalar: type === "scalar",
772
- modelRef,
773
- arrDepth,
774
- isArray,
775
- optArrDepth: optionArrDepth,
776
- isMap,
777
- of: option.of,
778
- text: option.text
779
- };
780
- const metadataMap = getFieldMetaMapOnPrototype(prototype);
781
- metadataMap.set(key, metadata);
782
- setFieldMetaMapOnPrototype(prototype, metadataMap);
770
+ // pkgs/@akanjs/constant/src/fieldMeta.ts
771
+ var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
772
+ const isArray = arrDepth > 0;
773
+ const isClass = !isGqlScalar(modelRef);
774
+ const isMap = isGqlMap(modelRef);
775
+ const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
776
+ const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
777
+ if (isMap && !option.of)
778
+ throw new Error("Map type must have 'of' option");
779
+ return (prototype, key) => {
780
+ const metadata = {
781
+ nullable: option.nullable ?? false,
782
+ ref: option.ref,
783
+ refPath: option.refPath,
784
+ refType: option.refType,
785
+ default: option.default ?? (isArray ? [] : null),
786
+ type: option.type,
787
+ fieldType: option.fieldType ?? "property",
788
+ immutable: option.immutable ?? false,
789
+ min: option.min,
790
+ max: option.max,
791
+ enum: option.enum,
792
+ select: option.select ?? true,
793
+ minlength: option.minlength,
794
+ maxlength: option.maxlength,
795
+ query: option.query,
796
+ accumulate: option.accumulate,
797
+ example: option.example,
798
+ validate: option.validate,
799
+ key,
800
+ name,
801
+ isClass,
802
+ isScalar: type === "scalar",
803
+ modelRef,
804
+ arrDepth,
805
+ isArray,
806
+ optArrDepth: optionArrDepth,
807
+ isMap,
808
+ of: option.of,
809
+ text: option.text
783
810
  };
784
- };
785
- var makeField = (customOption) => (returns, fieldOption) => {
786
- const [modelRef, arrDepth] = getNonArrayModel(returns());
787
- if (!fieldOption)
788
- return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
789
- const [opt, optArrDepth] = getNonArrayModel(fieldOption);
790
- return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
791
- };
792
- var Field = {
793
- Prop: makeField({ fieldType: "property" }),
794
- Hidden: makeField({ fieldType: "hidden", nullable: true }),
795
- Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
796
- Resolve: makeField({ fieldType: "resolve" })
797
- };
811
+ const metadataMap = getFieldMetaMapOnPrototype(prototype);
812
+ metadataMap.set(key, metadata);
813
+ setFieldMetaMapOnPrototype(prototype, metadataMap);
814
+ };
815
+ };
816
+ var makeField = (customOption) => (returns, fieldOption) => {
817
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
818
+ if (!fieldOption)
819
+ return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
820
+ const [opt, optArrDepth] = getNonArrayModel(fieldOption);
821
+ return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
822
+ };
823
+ var Field = {
824
+ Prop: makeField({ fieldType: "property" }),
825
+ Hidden: makeField({ fieldType: "hidden", nullable: true }),
826
+ Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
827
+ Resolve: makeField({ fieldType: "resolve" })
828
+ };
798
829
 
799
- // pkgs/@akanjs/constant/src/constantDecorator.ts
800
- var import_reflect_metadata2 = __require("reflect-metadata");
830
+ // pkgs/@akanjs/constant/src/constantDecorator.ts
831
+ var import_reflect_metadata2 = require("reflect-metadata");
801
832
 
802
- // pkgs/@akanjs/constant/src/filterMeta.ts
803
- var setFilterMeta = (filterRef, filterMeta) => {
804
- const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
805
- if (existingFilterMeta)
806
- Object.assign(filterMeta.sort, existingFilterMeta.sort);
807
- Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
808
- };
809
- var getFilterKeyMetaMapOnPrototype = (prototype) => {
810
- const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
811
- return new Map(metadataMap);
812
- };
813
- var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
814
- Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
815
- };
816
- var applyFilterKeyMeta = (option) => {
817
- return (prototype, key, descriptor) => {
818
- const metadata = { key, ...option, descriptor };
819
- const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
820
- metadataMap.set(key, metadata);
821
- setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
822
- };
823
- };
824
- var makeFilter = (customOption) => (fieldOption) => {
825
- return applyFilterKeyMeta({ ...customOption, ...fieldOption });
826
- };
827
- var getFilterArgMetasOnPrototype = (prototype, key) => {
828
- const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
829
- return filterArgMetas;
830
- };
831
- var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
832
- Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
833
- };
834
- var applyFilterArgMeta = (name, returns, argOption) => {
835
- return (prototype, key, idx) => {
836
- const [modelRef, arrDepth] = getNonArrayModel(returns());
837
- const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
838
- const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
839
- const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
840
- filterArgMetas[idx] = filterArgMeta;
841
- setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
842
- };
843
- };
844
- var Filter = {
845
- Mongo: makeFilter({ type: "mongo" }),
846
- // Meili: makeFilter({ fieldType: "hidden", nullable: true }),
847
- Arg: applyFilterArgMeta
848
- };
833
+ // pkgs/@akanjs/constant/src/filterMeta.ts
834
+ var setFilterMeta = (filterRef, filterMeta) => {
835
+ const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
836
+ if (existingFilterMeta)
837
+ Object.assign(filterMeta.sort, existingFilterMeta.sort);
838
+ Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
839
+ };
840
+ var getFilterKeyMetaMapOnPrototype = (prototype) => {
841
+ const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
842
+ return new Map(metadataMap);
843
+ };
844
+ var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
845
+ Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
846
+ };
847
+ var applyFilterKeyMeta = (option) => {
848
+ return (prototype, key, descriptor) => {
849
+ const metadata = { key, ...option, descriptor };
850
+ const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
851
+ metadataMap.set(key, metadata);
852
+ setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
853
+ };
854
+ };
855
+ var makeFilter = (customOption) => (fieldOption) => {
856
+ return applyFilterKeyMeta({ ...customOption, ...fieldOption });
857
+ };
858
+ var getFilterArgMetasOnPrototype = (prototype, key) => {
859
+ const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
860
+ return filterArgMetas;
861
+ };
862
+ var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
863
+ Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
864
+ };
865
+ var applyFilterArgMeta = (name, returns, argOption) => {
866
+ return (prototype, key, idx) => {
867
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
868
+ const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
869
+ const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
870
+ const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
871
+ filterArgMetas[idx] = filterArgMeta;
872
+ setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
873
+ };
874
+ };
875
+ var Filter = {
876
+ Mongo: makeFilter({ type: "mongo" }),
877
+ // Meili: makeFilter({ fieldType: "hidden", nullable: true }),
878
+ Arg: applyFilterArgMeta
879
+ };
849
880
 
850
- // pkgs/@akanjs/constant/src/baseGql.ts
851
- var import_reflect_metadata3 = __require("reflect-metadata");
852
- var defaultFieldMeta = {
853
- fieldType: "property",
854
- immutable: false,
855
- select: true,
856
- isClass: false,
857
- isScalar: true,
858
- nullable: false,
859
- isArray: false,
860
- arrDepth: 0,
861
- optArrDepth: 0,
862
- default: null,
863
- isMap: false
864
- };
865
- var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
866
- var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
867
- var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
868
- var removedAtFieldMeta = {
869
- ...defaultFieldMeta,
870
- key: "removedAt",
871
- name: "Date",
872
- modelRef: Date,
873
- nullable: true,
874
- default: null
875
- };
881
+ // pkgs/@akanjs/constant/src/baseGql.ts
882
+ var import_reflect_metadata3 = require("reflect-metadata");
883
+ var defaultFieldMeta = {
884
+ fieldType: "property",
885
+ immutable: false,
886
+ select: true,
887
+ isClass: false,
888
+ isScalar: true,
889
+ nullable: false,
890
+ isArray: false,
891
+ arrDepth: 0,
892
+ optArrDepth: 0,
893
+ default: null,
894
+ isMap: false
895
+ };
896
+ var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
897
+ var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
898
+ var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
899
+ var removedAtFieldMeta = {
900
+ ...defaultFieldMeta,
901
+ key: "removedAt",
902
+ name: "Date",
903
+ modelRef: Date,
904
+ nullable: true,
905
+ default: null
906
+ };
876
907
 
877
- // pkgs/@akanjs/constant/src/classMeta.ts
878
- var import_reflect_metadata4 = __require("reflect-metadata");
879
- var InputModelStorage = class {
880
- };
881
- var LightModelStorage = class {
882
- };
883
- var FullModelStorage = class {
884
- };
885
- var ScalarModelStorage = class {
886
- };
887
- var FilterModelStorage = class {
888
- };
889
- var hasTextField = (modelRef) => {
890
- const fieldMetas = getFieldMetas(modelRef);
891
- return fieldMetas.some(
892
- (fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
893
- );
894
- };
895
- var applyClassMeta = (type, modelType, storage2) => {
896
- return function(refName) {
897
- return function(target) {
898
- const modelRef = target;
899
- const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
900
- Reflect.defineMetadata("class", classMeta, modelRef.prototype);
901
- Reflect.defineMetadata(refName, modelRef, storage2.prototype);
902
- };
908
+ // pkgs/@akanjs/constant/src/classMeta.ts
909
+ var import_reflect_metadata4 = require("reflect-metadata");
910
+ var InputModelStorage = class {
911
+ };
912
+ var LightModelStorage = class {
913
+ };
914
+ var FullModelStorage = class {
915
+ };
916
+ var ScalarModelStorage = class {
917
+ };
918
+ var FilterModelStorage = class {
919
+ };
920
+ var hasTextField = (modelRef) => {
921
+ const fieldMetas = getFieldMetas(modelRef);
922
+ return fieldMetas.some(
923
+ (fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
924
+ );
925
+ };
926
+ var applyClassMeta = (type, modelType, storage2) => {
927
+ return function(refName) {
928
+ return function(target) {
929
+ const modelRef = target;
930
+ const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
931
+ Reflect.defineMetadata("class", classMeta, modelRef.prototype);
932
+ Reflect.defineMetadata(refName, modelRef, storage2.prototype);
903
933
  };
904
934
  };
905
- var applyFilterMeta = (storage2) => {
906
- return function(refName) {
907
- return function(target) {
908
- const modelRef = target;
909
- setFilterMeta(modelRef, { refName, sort: {} });
910
- Reflect.defineMetadata(refName, modelRef, storage2.prototype);
911
- };
935
+ };
936
+ var applyFilterMeta = (storage2) => {
937
+ return function(refName) {
938
+ return function(target) {
939
+ const modelRef = target;
940
+ setFilterMeta(modelRef, { refName, sort: {} });
941
+ Reflect.defineMetadata(refName, modelRef, storage2.prototype);
912
942
  };
913
943
  };
914
- var Model = {
915
- Light: applyClassMeta("light", "data", LightModelStorage),
916
- Object: applyClassMeta("full", "ephemeral", FullModelStorage),
917
- Full: applyClassMeta("full", "data", FullModelStorage),
918
- Input: applyClassMeta("input", "data", InputModelStorage),
919
- Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
920
- Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
921
- Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
922
- Filter: applyFilterMeta(FilterModelStorage)
923
- };
944
+ };
945
+ var Model = {
946
+ Light: applyClassMeta("light", "data", LightModelStorage),
947
+ Object: applyClassMeta("full", "ephemeral", FullModelStorage),
948
+ Full: applyClassMeta("full", "data", FullModelStorage),
949
+ Input: applyClassMeta("input", "data", InputModelStorage),
950
+ Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
951
+ Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
952
+ Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
953
+ Filter: applyFilterMeta(FilterModelStorage)
954
+ };
924
955
 
925
- // pkgs/@akanjs/signal/src/immerify.ts
926
- var import_immer = __require("immer");
956
+ // pkgs/@akanjs/signal/src/immerify.ts
957
+ var import_immer = require("immer");
927
958
 
928
- // pkgs/@akanjs/signal/src/signalDecorators.ts
929
- var import_reflect_metadata5 = __require("reflect-metadata");
930
- var createArgMetaDecorator = (type) => {
931
- return function(option = {}) {
932
- return function(prototype, key, idx) {
933
- const argMetas = getArgMetasOnPrototype(prototype, key);
934
- argMetas[idx] = { key, idx, type, option };
935
- setArgMetasOnPrototype(prototype, key, argMetas);
936
- };
937
- };
938
- };
939
- var Account = createArgMetaDecorator("Account");
940
- var defaultAccount = {
941
- __InternalArg__: "Account",
942
- appName: baseEnv.appName,
943
- environment: baseEnv.environment
944
- };
945
- var Self = createArgMetaDecorator("Self");
946
- var Me = createArgMetaDecorator("Me");
947
- var UserIp = createArgMetaDecorator("UserIp");
948
- var Access = createArgMetaDecorator("Access");
949
- var Req = createArgMetaDecorator("Req");
950
- var Res = createArgMetaDecorator("Res");
951
- var Ws = createArgMetaDecorator("Ws");
952
- var Job = createArgMetaDecorator("Job");
953
- var getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
954
- return (prototype, key, descriptor) => {
955
- const metadataMap = getGqlMetaMapOnPrototype(prototype);
956
- metadataMap.set(key, {
957
- returns,
958
- signalOption,
959
- key,
960
- descriptor,
961
- guards: [allow, ...guards],
962
- type: "Query"
963
- });
964
- setGqlMetaMapOnPrototype(prototype, metadataMap);
965
- };
966
- };
967
- var getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
968
- return (prototype, key, descriptor) => {
969
- const metadataMap = getGqlMetaMapOnPrototype(prototype);
970
- metadataMap.set(key, {
971
- returns,
972
- signalOption,
973
- key,
974
- descriptor,
975
- guards: [allow, ...guards],
976
- type: "Mutation"
977
- });
978
- setGqlMetaMapOnPrototype(prototype, metadataMap);
979
- };
980
- };
981
- var getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
982
- return (prototype, key, descriptor) => {
983
- const metadataMap = getGqlMetaMapOnPrototype(prototype);
984
- metadataMap.set(key, {
985
- returns,
986
- signalOption,
987
- key,
988
- descriptor,
989
- guards: [allow, ...guards],
990
- type: "Message"
991
- });
992
- setGqlMetaMapOnPrototype(prototype, metadataMap);
993
- };
994
- };
995
- var getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
996
- return (prototype, key, descriptor) => {
997
- const metadataMap = getGqlMetaMapOnPrototype(prototype);
998
- metadataMap.set(key, {
999
- returns,
1000
- signalOption,
1001
- key,
1002
- descriptor,
1003
- guards: [allow, ...guards],
1004
- type: "Pubsub"
1005
- });
1006
- setGqlMetaMapOnPrototype(prototype, metadataMap);
1007
- };
1008
- };
1009
- var getProcess = (serverType) => function(returns, signalOption = {}) {
1010
- return (prototype, key, descriptor) => {
1011
- const metadataMap = getGqlMetaMapOnPrototype(prototype);
1012
- metadataMap.set(key, {
1013
- returns,
1014
- signalOption: { ...signalOption, serverType: lowerlize(serverType) },
1015
- key,
1016
- descriptor,
1017
- guards: ["None"],
1018
- type: "Process"
1019
- });
1020
- setGqlMetaMapOnPrototype(prototype, metadataMap);
1021
- };
1022
- };
1023
- var Query = {
1024
- Public: getQuery("Public"),
1025
- Every: getQuery("Every"),
1026
- Admin: getQuery("Admin"),
1027
- User: getQuery("User"),
1028
- SuperAdmin: getQuery("SuperAdmin"),
1029
- None: getQuery("None"),
1030
- Owner: getQuery("Owner")
1031
- };
1032
- var Mutation = {
1033
- Public: getMutation("Public"),
1034
- Every: getMutation("Every"),
1035
- Admin: getMutation("Admin"),
1036
- User: getMutation("User"),
1037
- SuperAdmin: getMutation("SuperAdmin"),
1038
- None: getMutation("None"),
1039
- Owner: getMutation("Owner")
1040
- };
1041
- var Message = {
1042
- Public: getMessage("Public"),
1043
- Every: getMessage("Every"),
1044
- Admin: getMessage("Admin"),
1045
- User: getMessage("User"),
1046
- SuperAdmin: getMessage("SuperAdmin"),
1047
- None: getMessage("None"),
1048
- Owner: getMessage("Owner")
1049
- };
1050
- var Pubsub = {
1051
- Public: getPubsub("Public"),
1052
- Every: getPubsub("Every"),
1053
- Admin: getPubsub("Admin"),
1054
- User: getPubsub("User"),
1055
- SuperAdmin: getPubsub("SuperAdmin"),
1056
- None: getPubsub("None"),
1057
- Owner: getPubsub("Owner")
1058
- };
1059
- var Process = {
1060
- Federation: getProcess("Federation"),
1061
- Batch: getProcess("Batch"),
1062
- All: getProcess("All")
1063
- };
1064
- var getArg = (type) => function(name, returns, argsOption = {}) {
959
+ // pkgs/@akanjs/signal/src/signalDecorators.ts
960
+ var import_reflect_metadata5 = require("reflect-metadata");
961
+ var createArgMetaDecorator = (type) => {
962
+ return function(option = {}) {
1065
963
  return function(prototype, key, idx) {
1066
964
  const argMetas = getArgMetasOnPrototype(prototype, key);
1067
- argMetas[idx] = { name, returns, argsOption, key, idx, type };
965
+ argMetas[idx] = { key, idx, type, option };
1068
966
  setArgMetasOnPrototype(prototype, key, argMetas);
1069
967
  };
1070
968
  };
1071
- var Arg = {
1072
- Body: getArg("Body"),
1073
- Param: getArg("Param"),
1074
- Query: getArg("Query"),
1075
- Upload: getArg("Upload"),
1076
- Msg: getArg("Msg"),
1077
- Room: getArg("Room")
1078
- };
1079
- var getGqlMetaMapOnPrototype = (prototype) => {
1080
- const gqlMetaMap = Reflect.getMetadata("gql", prototype);
1081
- return gqlMetaMap ?? /* @__PURE__ */ new Map();
1082
- };
1083
- var setGqlMetaMapOnPrototype = (prototype, gqlMetaMap) => {
1084
- Reflect.defineMetadata("gql", gqlMetaMap, prototype);
1085
- };
1086
- var getArgMetasOnPrototype = (prototype, key) => {
1087
- return Reflect.getMetadata("args", prototype, key) ?? [];
1088
- };
1089
- var setArgMetasOnPrototype = (prototype, key, argMetas) => {
1090
- Reflect.defineMetadata("args", argMetas, prototype, key);
1091
- };
969
+ };
970
+ var Account = createArgMetaDecorator("Account");
971
+ var defaultAccount = {
972
+ __InternalArg__: "Account",
973
+ appName: baseEnv.appName,
974
+ environment: baseEnv.environment
975
+ };
976
+ var Self = createArgMetaDecorator("Self");
977
+ var Me = createArgMetaDecorator("Me");
978
+ var UserIp = createArgMetaDecorator("UserIp");
979
+ var Access = createArgMetaDecorator("Access");
980
+ var Req = createArgMetaDecorator("Req");
981
+ var Res = createArgMetaDecorator("Res");
982
+ var Ws = createArgMetaDecorator("Ws");
983
+ var Job = createArgMetaDecorator("Job");
984
+ var getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
985
+ return (prototype, key, descriptor) => {
986
+ const metadataMap = getGqlMetaMapOnPrototype(prototype);
987
+ metadataMap.set(key, {
988
+ returns,
989
+ signalOption,
990
+ key,
991
+ descriptor,
992
+ guards: [allow, ...guards],
993
+ type: "Query"
994
+ });
995
+ setGqlMetaMapOnPrototype(prototype, metadataMap);
996
+ };
997
+ };
998
+ var getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
999
+ return (prototype, key, descriptor) => {
1000
+ const metadataMap = getGqlMetaMapOnPrototype(prototype);
1001
+ metadataMap.set(key, {
1002
+ returns,
1003
+ signalOption,
1004
+ key,
1005
+ descriptor,
1006
+ guards: [allow, ...guards],
1007
+ type: "Mutation"
1008
+ });
1009
+ setGqlMetaMapOnPrototype(prototype, metadataMap);
1010
+ };
1011
+ };
1012
+ var getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
1013
+ return (prototype, key, descriptor) => {
1014
+ const metadataMap = getGqlMetaMapOnPrototype(prototype);
1015
+ metadataMap.set(key, {
1016
+ returns,
1017
+ signalOption,
1018
+ key,
1019
+ descriptor,
1020
+ guards: [allow, ...guards],
1021
+ type: "Message"
1022
+ });
1023
+ setGqlMetaMapOnPrototype(prototype, metadataMap);
1024
+ };
1025
+ };
1026
+ var getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
1027
+ return (prototype, key, descriptor) => {
1028
+ const metadataMap = getGqlMetaMapOnPrototype(prototype);
1029
+ metadataMap.set(key, {
1030
+ returns,
1031
+ signalOption,
1032
+ key,
1033
+ descriptor,
1034
+ guards: [allow, ...guards],
1035
+ type: "Pubsub"
1036
+ });
1037
+ setGqlMetaMapOnPrototype(prototype, metadataMap);
1038
+ };
1039
+ };
1040
+ var getProcess = (serverType) => function(returns, signalOption = {}) {
1041
+ return (prototype, key, descriptor) => {
1042
+ const metadataMap = getGqlMetaMapOnPrototype(prototype);
1043
+ metadataMap.set(key, {
1044
+ returns,
1045
+ signalOption: { ...signalOption, serverType: lowerlize(serverType) },
1046
+ key,
1047
+ descriptor,
1048
+ guards: ["None"],
1049
+ type: "Process"
1050
+ });
1051
+ setGqlMetaMapOnPrototype(prototype, metadataMap);
1052
+ };
1053
+ };
1054
+ var Query = {
1055
+ Public: getQuery("Public"),
1056
+ Every: getQuery("Every"),
1057
+ Admin: getQuery("Admin"),
1058
+ User: getQuery("User"),
1059
+ SuperAdmin: getQuery("SuperAdmin"),
1060
+ None: getQuery("None"),
1061
+ Owner: getQuery("Owner")
1062
+ };
1063
+ var Mutation = {
1064
+ Public: getMutation("Public"),
1065
+ Every: getMutation("Every"),
1066
+ Admin: getMutation("Admin"),
1067
+ User: getMutation("User"),
1068
+ SuperAdmin: getMutation("SuperAdmin"),
1069
+ None: getMutation("None"),
1070
+ Owner: getMutation("Owner")
1071
+ };
1072
+ var Message = {
1073
+ Public: getMessage("Public"),
1074
+ Every: getMessage("Every"),
1075
+ Admin: getMessage("Admin"),
1076
+ User: getMessage("User"),
1077
+ SuperAdmin: getMessage("SuperAdmin"),
1078
+ None: getMessage("None"),
1079
+ Owner: getMessage("Owner")
1080
+ };
1081
+ var Pubsub = {
1082
+ Public: getPubsub("Public"),
1083
+ Every: getPubsub("Every"),
1084
+ Admin: getPubsub("Admin"),
1085
+ User: getPubsub("User"),
1086
+ SuperAdmin: getPubsub("SuperAdmin"),
1087
+ None: getPubsub("None"),
1088
+ Owner: getPubsub("Owner")
1089
+ };
1090
+ var Process = {
1091
+ Federation: getProcess("Federation"),
1092
+ Batch: getProcess("Batch"),
1093
+ All: getProcess("All")
1094
+ };
1095
+ var getArg = (type) => function(name, returns, argsOption = {}) {
1096
+ return function(prototype, key, idx) {
1097
+ const argMetas = getArgMetasOnPrototype(prototype, key);
1098
+ argMetas[idx] = { name, returns, argsOption, key, idx, type };
1099
+ setArgMetasOnPrototype(prototype, key, argMetas);
1100
+ };
1101
+ };
1102
+ var Arg = {
1103
+ Body: getArg("Body"),
1104
+ Param: getArg("Param"),
1105
+ Query: getArg("Query"),
1106
+ Upload: getArg("Upload"),
1107
+ Msg: getArg("Msg"),
1108
+ Room: getArg("Room")
1109
+ };
1110
+ var getGqlMetaMapOnPrototype = (prototype) => {
1111
+ const gqlMetaMap = Reflect.getMetadata("gql", prototype);
1112
+ return gqlMetaMap ?? /* @__PURE__ */ new Map();
1113
+ };
1114
+ var setGqlMetaMapOnPrototype = (prototype, gqlMetaMap) => {
1115
+ Reflect.defineMetadata("gql", gqlMetaMap, prototype);
1116
+ };
1117
+ var getArgMetasOnPrototype = (prototype, key) => {
1118
+ return Reflect.getMetadata("args", prototype, key) ?? [];
1119
+ };
1120
+ var setArgMetasOnPrototype = (prototype, key, argMetas) => {
1121
+ Reflect.defineMetadata("args", argMetas, prototype, key);
1122
+ };
1092
1123
 
1093
- // pkgs/@akanjs/signal/src/baseFetch.ts
1094
- var nativeFetch = fetch;
1095
- var baseFetch = Object.assign(nativeFetch, {
1096
- client,
1097
- clone: function(option = {}) {
1098
- return {
1099
- ...this,
1100
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1101
- client: this.client.clone(option)
1102
- };
1103
- }
1104
- });
1124
+ // pkgs/@akanjs/signal/src/baseFetch.ts
1125
+ var nativeFetch = fetch;
1126
+ var baseFetch = Object.assign(nativeFetch, {
1127
+ client,
1128
+ clone: function(option = {}) {
1129
+ return {
1130
+ ...this,
1131
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1132
+ client: this.client.clone(option)
1133
+ };
1134
+ }
1135
+ });
1105
1136
 
1106
- // pkgs/@akanjs/client/src/cookie.ts
1107
- var import_core2 = __require("@capacitor/core");
1108
- var import_js_cookie = __toESM(__require("js-cookie"));
1109
- var import_jwt_decode = __require("jwt-decode");
1110
- var import_react2 = __toESM(__require("react"));
1137
+ // pkgs/@akanjs/client/src/cookie.ts
1138
+ var import_core2 = require("@capacitor/core");
1139
+ var import_js_cookie = __toESM(require("js-cookie"));
1140
+ var import_jwt_decode = require("jwt-decode");
1141
+ var import_react2 = __toESM(require("react"));
1111
1142
 
1112
- // pkgs/@akanjs/client/src/storage.ts
1113
- var import_preferences = __require("@capacitor/preferences");
1114
- var storage = {
1115
- getItem: async (key) => {
1116
- if (baseClientEnv.side === "server")
1117
- return;
1118
- if (baseClientEnv.renderMode === "ssr")
1119
- return localStorage.getItem(key);
1120
- else
1121
- return (await import_preferences.Preferences.get({ key })).value;
1122
- },
1123
- setItem: async (key, value) => {
1124
- if (baseClientEnv.side === "server")
1125
- return;
1126
- if (baseClientEnv.renderMode === "ssr") {
1127
- localStorage.setItem(key, value);
1128
- return;
1129
- } else {
1130
- await import_preferences.Preferences.set({ key, value });
1131
- return;
1132
- }
1133
- },
1134
- removeItem: (key) => {
1135
- if (baseClientEnv.side === "server")
1136
- return;
1137
- if (baseClientEnv.renderMode === "ssr") {
1138
- localStorage.removeItem(key);
1139
- return;
1140
- } else
1141
- return import_preferences.Preferences.remove({ key });
1142
- }
1143
- };
1144
-
1145
- // pkgs/@akanjs/client/src/cookie.ts
1146
- var cookies = baseClientEnv.side === "server" ? () => {
1147
- const nextHeaders = __require("next/headers");
1148
- const cookies2 = nextHeaders.cookies();
1149
- return import_react2.default.use(cookies2);
1150
- } : () => {
1151
- const cookie = import_js_cookie.default.get();
1152
- return new Map(
1153
- Object.entries(cookie).map(([key, value]) => [
1154
- key,
1155
- {
1156
- name: key,
1157
- value: typeof value === "string" && value.startsWith("j:") ? JSON.parse(value.slice(2)) : value
1158
- }
1159
- ])
1160
- );
1161
- };
1162
- var setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
1143
+ // pkgs/@akanjs/client/src/storage.ts
1144
+ var import_preferences = require("@capacitor/preferences");
1145
+ var storage = {
1146
+ getItem: async (key) => {
1163
1147
  if (baseClientEnv.side === "server")
1164
1148
  return;
1149
+ if (baseClientEnv.renderMode === "ssr")
1150
+ return localStorage.getItem(key);
1165
1151
  else
1166
- void import_core2.CapacitorCookies.setCookie({ key, value });
1167
- };
1168
- var getCookie = (key) => {
1169
- if (baseClientEnv.side === "server")
1170
- return cookies().get(key)?.value;
1171
- else
1172
- return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
1173
- };
1174
- var removeCookie = (key, options = { path: "/" }) => {
1152
+ return (await import_preferences.Preferences.get({ key })).value;
1153
+ },
1154
+ setItem: async (key, value) => {
1175
1155
  if (baseClientEnv.side === "server")
1176
- return cookies().delete(key);
1177
- else {
1178
- document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
1179
- }
1180
- };
1181
- var headers = baseClientEnv.side === "server" ? () => import_react2.default.use(__require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
1182
- var getHeader = (key) => {
1183
- return headers().get(key);
1184
- };
1185
- var getAccount = () => {
1186
- const jwt = getCookie("jwt") ?? getHeader("jwt");
1187
- if (!jwt)
1188
- return defaultAccount;
1189
- const account = (0, import_jwt_decode.jwtDecode)(jwt);
1190
- if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
1191
- return defaultAccount;
1192
- return account;
1193
- };
1194
- function getMe(option) {
1195
- const me = getAccount().me;
1196
- if (!me && option) {
1197
- if (option.unauthorize === "notFound")
1198
- router.notFound();
1199
- else if (baseClientEnv.side === "client")
1200
- router.replace(option.unauthorize);
1201
- else
1202
- import_react2.default.use(router.redirect(option.unauthorize));
1203
- }
1204
- return me;
1205
- }
1206
- function getSelf(option) {
1207
- const self = getAccount().self;
1208
- if (!self && option) {
1209
- if (option.unauthorize === "notFound")
1210
- router.notFound();
1211
- else if (baseClientEnv.side === "client")
1212
- router.replace(option.unauthorize);
1213
- else
1214
- import_react2.default.use(router.redirect(option.unauthorize));
1156
+ return;
1157
+ if (baseClientEnv.renderMode === "ssr") {
1158
+ localStorage.setItem(key, value);
1159
+ return;
1160
+ } else {
1161
+ await import_preferences.Preferences.set({ key, value });
1162
+ return;
1215
1163
  }
1216
- return self;
1164
+ },
1165
+ removeItem: (key) => {
1166
+ if (baseClientEnv.side === "server")
1167
+ return;
1168
+ if (baseClientEnv.renderMode === "ssr") {
1169
+ localStorage.removeItem(key);
1170
+ return;
1171
+ } else
1172
+ return import_preferences.Preferences.remove({ key });
1217
1173
  }
1218
- var setAuth = ({ jwt }) => {
1219
- client.setJwt(jwt);
1220
- setCookie("jwt", jwt);
1221
- void storage.setItem("jwt", jwt);
1222
- };
1223
- var initAuth = ({ jwt } = {}) => {
1224
- const token = jwt ?? cookies().get("jwt")?.value;
1225
- if (token)
1226
- setAuth({ jwt: token });
1227
- client.init();
1228
- Logger.verbose(`JWT set from cookie: ${token}`);
1229
- };
1230
- var resetAuth = () => {
1231
- client.reset();
1232
- removeCookie("jwt");
1233
- void storage.removeItem("jwt");
1234
- };
1174
+ };
1235
1175
 
1236
- // pkgs/@akanjs/client/src/device.ts
1237
- var import_device = __require("@capacitor/device");
1238
- var import_haptics = __require("@capacitor/haptics");
1239
- var import_keyboard = __require("@capacitor/keyboard");
1240
- var import_capacitor_plugin_safe_area = __require("capacitor-plugin-safe-area");
1241
- var import_react_device_detect = __require("react-device-detect");
1242
- var Device = class {
1243
- info;
1244
- lang;
1245
- topSafeArea;
1246
- bottomSafeArea;
1247
- isMobile = import_react_device_detect.isMobile;
1248
- #keyboard = import_keyboard.Keyboard;
1249
- #haptics = import_haptics.Haptics;
1250
- #pageContentRef = null;
1251
- async init({ lang, supportLanguages = [] } = {}) {
1252
- const [
1253
- info,
1254
- { value: languageCode },
1255
- {
1256
- insets: { top: topSafeArea, bottom: bottomSafeArea }
1257
- }
1258
- ] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
1259
- const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
1260
- const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
1261
- this.info = info;
1262
- this.lang = lang ?? predefinedLang ?? languageCode;
1263
- this.topSafeArea = topSafeArea;
1264
- this.bottomSafeArea = bottomSafeArea;
1265
- }
1266
- setPageContentRef(pageContentRef) {
1267
- this.#pageContentRef = pageContentRef;
1268
- }
1269
- async showKeyboard() {
1270
- if (this.info.platform === "web")
1271
- return;
1272
- await this.#keyboard.show();
1273
- }
1274
- async hideKeyboard() {
1275
- if (this.info.platform === "web")
1276
- return;
1277
- await this.#keyboard.hide();
1278
- }
1279
- listenKeyboardChanged(onKeyboardChanged) {
1280
- if (this.info.platform === "web")
1281
- return;
1282
- void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
1283
- onKeyboardChanged(keyboard.keyboardHeight);
1284
- });
1285
- void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
1286
- onKeyboardChanged(keyboard.keyboardHeight);
1287
- });
1288
- void this.#keyboard.addListener("keyboardWillHide", () => {
1289
- onKeyboardChanged(0);
1290
- });
1291
- void this.#keyboard.addListener("keyboardDidHide", () => {
1292
- onKeyboardChanged(0);
1293
- });
1294
- }
1295
- unlistenKeyboardChanged() {
1296
- if (this.info.platform === "web")
1297
- return;
1298
- void this.#keyboard.removeAllListeners();
1299
- }
1300
- async vibrate(type = "medium") {
1301
- if (typeof type === "number") {
1302
- await this.#haptics.vibrate({ duration: type });
1303
- return;
1176
+ // pkgs/@akanjs/client/src/cookie.ts
1177
+ var cookies = baseClientEnv.side === "server" ? () => {
1178
+ const nextHeaders = require("next/headers");
1179
+ const cookies2 = nextHeaders.cookies();
1180
+ return import_react2.default.use(cookies2);
1181
+ } : () => {
1182
+ const cookie = import_js_cookie.default.get();
1183
+ return new Map(
1184
+ Object.entries(cookie).map(([key, value]) => [
1185
+ key,
1186
+ {
1187
+ name: key,
1188
+ value: typeof value === "string" && value.startsWith("j:") ? JSON.parse(value.slice(2)) : value
1304
1189
  }
1305
- const handleImpact = {
1306
- light: async () => {
1307
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
1308
- },
1309
- medium: async () => {
1310
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
1311
- },
1312
- heavy: async () => {
1313
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
1314
- },
1315
- selectionStart: async () => {
1316
- await this.#haptics.selectionStart();
1317
- },
1318
- selectionChanged: async () => {
1319
- await this.#haptics.selectionChanged();
1320
- },
1321
- selectionEnd: async () => {
1322
- await this.#haptics.selectionEnd();
1323
- }
1324
- };
1325
- await handleImpact[type]();
1326
- }
1327
- getScrollTop() {
1328
- if (this.info.platform === "web")
1329
- return window.scrollY;
1330
- return this.#pageContentRef?.current?.scrollTop ?? 0;
1190
+ ])
1191
+ );
1192
+ };
1193
+ var setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
1194
+ if (baseClientEnv.side === "server")
1195
+ return;
1196
+ else
1197
+ void import_core2.CapacitorCookies.setCookie({ key, value });
1198
+ };
1199
+ var getCookie = (key) => {
1200
+ if (baseClientEnv.side === "server")
1201
+ return cookies().get(key)?.value;
1202
+ else
1203
+ return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
1204
+ };
1205
+ var removeCookie = (key, options = { path: "/" }) => {
1206
+ if (baseClientEnv.side === "server")
1207
+ return cookies().delete(key);
1208
+ else {
1209
+ document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
1210
+ }
1211
+ };
1212
+ var headers = baseClientEnv.side === "server" ? () => import_react2.default.use(require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
1213
+ var getHeader = (key) => {
1214
+ return headers().get(key);
1215
+ };
1216
+ var getAccount = () => {
1217
+ const jwt = getCookie("jwt") ?? getHeader("jwt");
1218
+ if (!jwt)
1219
+ return defaultAccount;
1220
+ const account = (0, import_jwt_decode.jwtDecode)(jwt);
1221
+ if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
1222
+ return defaultAccount;
1223
+ return account;
1224
+ };
1225
+ function getMe(option) {
1226
+ const me = getAccount().me;
1227
+ if (!me && option) {
1228
+ if (option.unauthorize === "notFound")
1229
+ router.notFound();
1230
+ else if (baseClientEnv.side === "client")
1231
+ router.replace(option.unauthorize);
1232
+ else
1233
+ import_react2.default.use(router.redirect(option.unauthorize));
1234
+ }
1235
+ return me;
1236
+ }
1237
+ function getSelf(option) {
1238
+ const self = getAccount().self;
1239
+ if (!self && option) {
1240
+ if (option.unauthorize === "notFound")
1241
+ router.notFound();
1242
+ else if (baseClientEnv.side === "client")
1243
+ router.replace(option.unauthorize);
1244
+ else
1245
+ import_react2.default.use(router.redirect(option.unauthorize));
1246
+ }
1247
+ return self;
1248
+ }
1249
+ var setAuth = ({ jwt }) => {
1250
+ client.setJwt(jwt);
1251
+ setCookie("jwt", jwt);
1252
+ void storage.setItem("jwt", jwt);
1253
+ };
1254
+ var initAuth = ({ jwt } = {}) => {
1255
+ const token = jwt ?? cookies().get("jwt")?.value;
1256
+ if (token)
1257
+ setAuth({ jwt: token });
1258
+ client.init();
1259
+ Logger.verbose(`JWT set from cookie: ${token}`);
1260
+ };
1261
+ var resetAuth = () => {
1262
+ client.reset();
1263
+ removeCookie("jwt");
1264
+ void storage.removeItem("jwt");
1265
+ };
1266
+
1267
+ // pkgs/@akanjs/client/src/device.ts
1268
+ var import_device = require("@capacitor/device");
1269
+ var import_haptics = require("@capacitor/haptics");
1270
+ var import_keyboard = require("@capacitor/keyboard");
1271
+ var import_capacitor_plugin_safe_area = require("capacitor-plugin-safe-area");
1272
+ var import_react_device_detect = require("react-device-detect");
1273
+ var Device = class {
1274
+ info;
1275
+ lang;
1276
+ topSafeArea;
1277
+ bottomSafeArea;
1278
+ isMobile = import_react_device_detect.isMobile;
1279
+ #keyboard = import_keyboard.Keyboard;
1280
+ #haptics = import_haptics.Haptics;
1281
+ #pageContentRef = null;
1282
+ async init({ lang, supportLanguages = [] } = {}) {
1283
+ const [
1284
+ info,
1285
+ { value: languageCode },
1286
+ {
1287
+ insets: { top: topSafeArea, bottom: bottomSafeArea }
1288
+ }
1289
+ ] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
1290
+ const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
1291
+ const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
1292
+ this.info = info;
1293
+ this.lang = lang ?? predefinedLang ?? languageCode;
1294
+ this.topSafeArea = topSafeArea;
1295
+ this.bottomSafeArea = bottomSafeArea;
1296
+ }
1297
+ setPageContentRef(pageContentRef) {
1298
+ this.#pageContentRef = pageContentRef;
1299
+ }
1300
+ async showKeyboard() {
1301
+ if (this.info.platform === "web")
1302
+ return;
1303
+ await this.#keyboard.show();
1304
+ }
1305
+ async hideKeyboard() {
1306
+ if (this.info.platform === "web")
1307
+ return;
1308
+ await this.#keyboard.hide();
1309
+ }
1310
+ listenKeyboardChanged(onKeyboardChanged) {
1311
+ if (this.info.platform === "web")
1312
+ return;
1313
+ void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
1314
+ onKeyboardChanged(keyboard.keyboardHeight);
1315
+ });
1316
+ void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
1317
+ onKeyboardChanged(keyboard.keyboardHeight);
1318
+ });
1319
+ void this.#keyboard.addListener("keyboardWillHide", () => {
1320
+ onKeyboardChanged(0);
1321
+ });
1322
+ void this.#keyboard.addListener("keyboardDidHide", () => {
1323
+ onKeyboardChanged(0);
1324
+ });
1325
+ }
1326
+ unlistenKeyboardChanged() {
1327
+ if (this.info.platform === "web")
1328
+ return;
1329
+ void this.#keyboard.removeAllListeners();
1330
+ }
1331
+ async vibrate(type = "medium") {
1332
+ if (typeof type === "number") {
1333
+ await this.#haptics.vibrate({ duration: type });
1334
+ return;
1331
1335
  }
1332
- setScrollTop(scrollTop) {
1333
- if (this.info.platform === "web") {
1334
- window.scrollTo({ top: scrollTop });
1335
- return;
1336
+ const handleImpact = {
1337
+ light: async () => {
1338
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
1339
+ },
1340
+ medium: async () => {
1341
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
1342
+ },
1343
+ heavy: async () => {
1344
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
1345
+ },
1346
+ selectionStart: async () => {
1347
+ await this.#haptics.selectionStart();
1348
+ },
1349
+ selectionChanged: async () => {
1350
+ await this.#haptics.selectionChanged();
1351
+ },
1352
+ selectionEnd: async () => {
1353
+ await this.#haptics.selectionEnd();
1336
1354
  }
1337
- return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
1355
+ };
1356
+ await handleImpact[type]();
1357
+ }
1358
+ getScrollTop() {
1359
+ if (this.info.platform === "web")
1360
+ return window.scrollY;
1361
+ return this.#pageContentRef?.current?.scrollTop ?? 0;
1362
+ }
1363
+ setScrollTop(scrollTop) {
1364
+ if (this.info.platform === "web") {
1365
+ window.scrollTo({ top: scrollTop });
1366
+ return;
1338
1367
  }
1339
- };
1340
- var device = new Device();
1368
+ return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
1369
+ }
1370
+ };
1371
+ var device = new Device();
1341
1372
 
1342
- // pkgs/@akanjs/client/src/createFont.ts
1343
- var createFont = (data) => null;
1344
- var Nanum_Gothic_Coding = createFont;
1345
- var Noto_Sans_KR = createFont;
1346
- })();
1373
+ // pkgs/@akanjs/client/src/createFont.ts
1374
+ var createFont = (data) => null;
1375
+ var Nanum_Gothic_Coding = createFont;
1376
+ var Noto_Sans_KR = createFont;
1347
1377
  //! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.