@akanjs/client 0.0.44 → 0.0.46

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 +500 -1316
  2. package/package.json +2 -8
package/index.js CHANGED
@@ -1,1347 +1,531 @@
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
- ));
31
-
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
- };
38
-
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
- };
62
-
63
- // pkgs/@akanjs/base/src/base.ts
64
- var version = "0.9.0";
65
- var logo = `
66
- _ _ _
67
- / \\ | | ____ _ _ __ (_)___
68
- / _ \\ | |/ / _' | '_ \\ | / __|
69
- / ___ \\| < (_| | | | |_ | \\__ \\
70
- /_/ \\_\\_|\\_\\__,_|_| |_(_)/ |___/
71
- |__/ ver ${version}
72
- ? See more details on docs https://www.akanjs.com/docs
73
- \u2605 Star Akanjs on GitHub https://github.com/aka-bassman/akanjs
74
-
75
- `;
76
-
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
- };
138
-
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;
203
-
204
- // pkgs/@akanjs/common/src/isDayjs.ts
205
- var import_dayjs2 = __require("dayjs");
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);
206
28
 
207
- // pkgs/@akanjs/common/src/isQueryEqual.ts
208
- var import_dayjs3 = __toESM(__require("dayjs"));
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);
209
62
 
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);
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
+ };
214
69
 
215
- // pkgs/@akanjs/common/src/pluralize.ts
216
- var import_pluralize = __toESM(__require("pluralize"));
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
+ };
217
93
 
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}
340
- `
341
- );
342
- else
343
- console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
344
- `);
345
- }
346
- static rawLog(msg, method) {
347
- this.raw(`${msg}
348
- `, 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);
94
+ // pkgs/@akanjs/client/src/router.ts
95
+ var import_base = require("@akanjs/base");
96
+ var import_common = require("@akanjs/common");
97
+ var import_navigation = require("next/navigation");
98
+ var getPathInfo = (href, lang, prefix) => {
99
+ const langLength = lang.length + 1;
100
+ const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
101
+ const prefixLength = prefix ? prefix.length + 1 : 0;
102
+ const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
103
+ const subRoute = prefix ? `/${prefix}` : "";
104
+ const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
105
+ return { path, pathname };
106
+ };
107
+ var Router = class {
108
+ isInitialized = false;
109
+ #prefix = "";
110
+ #lang = "en";
111
+ #instance = {
112
+ push: (href) => {
113
+ const { pathname } = this.#getPathInfo(href);
114
+ import_common.Logger.log(`push to:${pathname}`);
115
+ if (import_base.baseClientEnv.side === "server")
116
+ void (0, import_navigation.redirect)(pathname);
117
+ },
118
+ replace: (href) => {
119
+ const { pathname } = this.#getPathInfo(href);
120
+ import_common.Logger.log(`replace to:${pathname}`);
121
+ if (import_base.baseClientEnv.side === "server")
122
+ void (0, import_navigation.redirect)(pathname);
123
+ },
124
+ back: () => {
125
+ throw new Error("back is only available in client");
126
+ },
127
+ refresh: () => {
128
+ throw new Error("refresh is only available in client");
355
129
  }
356
130
  };
357
-
358
- // pkgs/@akanjs/common/src/lowerlize.ts
359
- var lowerlize = (str) => {
360
- return str.charAt(0).toLowerCase() + str.slice(1);
361
- };
362
-
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
- };
371
-
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 };
382
- };
383
- var Router = class {
384
- isInitialized = false;
385
- #prefix = "";
386
- #lang = "en";
387
- #instance = {
131
+ init(options) {
132
+ this.#prefix = options.prefix ?? "";
133
+ this.#lang = options.lang ?? "en";
134
+ if (options.type === "csr")
135
+ this.#initCSRClientRouter(options);
136
+ else if (options.side === "server")
137
+ this.#initNextServerRouter(options);
138
+ else
139
+ this.#initNextClientRouter(options);
140
+ this.isInitialized = true;
141
+ import_common.Logger.verbose("Router initialized");
142
+ }
143
+ #initNextServerRouter(options) {
144
+ }
145
+ #initNextClientRouter(options) {
146
+ this.#instance = {
388
147
  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);
148
+ const { path, pathname } = this.#getPathInfo(href);
149
+ this.#postPathChange({ path, pathname });
150
+ options.router.push(pathname);
393
151
  },
394
152
  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);
153
+ const { path, pathname } = this.#getPathInfo(href);
154
+ this.#postPathChange({ path, pathname });
155
+ options.router.replace(pathname);
399
156
  },
400
157
  back: () => {
401
- throw new Error("back is only available in client");
158
+ const { path, pathname } = this.#getPathInfo(document.referrer);
159
+ this.#postPathChange({ path, pathname });
160
+ options.router.back();
402
161
  },
403
162
  refresh: () => {
404
- throw new Error("refresh is only available in client");
163
+ const { path, pathname } = this.#getPathInfo(location.pathname);
164
+ this.#postPathChange({ path, pathname });
165
+ options.router.refresh();
405
166
  }
406
167
  };
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);
522
- }
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();
562
-
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);
595
- 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;
168
+ }
169
+ #initCSRClientRouter(options) {
170
+ this.#instance = {
171
+ push: (href) => {
172
+ const { path, pathname } = this.#getPathInfo(href);
173
+ if (location.pathname === pathname)
174
+ return;
175
+ this.#postPathChange({ path, pathname });
176
+ options.router.push(pathname);
177
+ },
178
+ replace: (href) => {
179
+ const { path, pathname } = this.#getPathInfo(href);
180
+ if (location.pathname === pathname)
181
+ return;
182
+ this.#postPathChange({ path, pathname });
183
+ options.router.replace(pathname);
184
+ },
185
+ back: () => {
186
+ const { path, pathname } = this.#getPathInfo(document.referrer);
187
+ if (location.pathname === pathname)
188
+ return;
189
+ this.#postPathChange({ path, pathname });
190
+ options.router.back();
191
+ },
192
+ refresh: () => {
193
+ const { path, pathname } = this.#getPathInfo(location.pathname);
194
+ this.#postPathChange({ path, pathname });
195
+ options.router.refresh();
650
196
  }
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
- });
678
- }
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;
698
- }
699
- setUdp(udp) {
700
- this.udp = udp;
701
- }
702
- };
703
- var client = new Client();
704
-
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
- };
738
-
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);
783
- };
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
- };
798
-
799
- // pkgs/@akanjs/constant/src/constantDecorator.ts
800
- var import_reflect_metadata2 = __require("reflect-metadata");
801
-
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
- };
849
-
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
- };
876
-
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
- };
903
- };
904
- };
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
- };
912
197
  };
913
- };
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
- };
924
-
925
- // pkgs/@akanjs/signal/src/immerify.ts
926
- var import_immer = __require("immer");
198
+ }
199
+ #checkInitialized() {
200
+ if (!this.isInitialized)
201
+ throw new Error("Router is not initialized");
202
+ }
203
+ #getPathInfo(href, prefix = this.#prefix) {
204
+ return getPathInfo(href, this.#lang, prefix);
205
+ }
206
+ #postPathChange({ path, pathname }) {
207
+ import_common.Logger.log(`pathChange-start:${path}`);
208
+ window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
209
+ }
210
+ push(href) {
211
+ this.#checkInitialized();
212
+ this.#instance.push(href);
213
+ return void 0;
214
+ }
215
+ replace(href) {
216
+ this.#checkInitialized();
217
+ this.#instance.replace(href);
218
+ return void 0;
219
+ }
220
+ back() {
221
+ if (import_base.baseClientEnv.side === "server")
222
+ throw new Error("back is only available in client side");
223
+ this.#checkInitialized();
224
+ this.#instance.back();
225
+ return void 0;
226
+ }
227
+ refresh() {
228
+ if (import_base.baseClientEnv.side === "server")
229
+ throw new Error("refresh is only available in client side");
230
+ this.#checkInitialized();
231
+ this.#instance.refresh();
232
+ return void 0;
233
+ }
234
+ async redirect(href) {
235
+ if (import_base.baseClientEnv.side === "server") {
236
+ const nextHeaders = require("next/headers");
237
+ const headers2 = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
238
+ const lang = headers2.get("x-locale") ?? this.#lang;
239
+ const basePath = headers2.get("x-base-path");
240
+ const { pathname } = getPathInfo(href, lang, basePath ?? "");
241
+ import_common.Logger.log(`redirect to:${pathname}`);
242
+ (0, import_navigation.redirect)(pathname);
243
+ } else {
244
+ const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
245
+ this.#instance.replace(pathname);
246
+ }
247
+ return void 0;
248
+ }
249
+ notFound() {
250
+ this.#checkInitialized();
251
+ if (import_base.baseClientEnv.side === "server") {
252
+ import_common.Logger.log(`redirect to:/404`);
253
+ (0, import_navigation.notFound)();
254
+ } else
255
+ this.#instance.replace("/404");
256
+ return void 0;
257
+ }
258
+ setLang(lang) {
259
+ if (import_base.baseClientEnv.side === "server")
260
+ throw new Error("setLang is only available in client side");
261
+ this.#checkInitialized();
262
+ const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
263
+ this.#lang = lang;
264
+ this.#instance.replace(`/${lang}${path}`);
265
+ return void 0;
266
+ }
267
+ getPath(pathname = window.location.pathname) {
268
+ if (import_base.baseClientEnv.side === "server")
269
+ throw new Error("getPath is only available in client side");
270
+ const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
271
+ return path;
272
+ }
273
+ getFullPath(withLang = true) {
274
+ if (import_base.baseClientEnv.side === "server")
275
+ throw new Error("getPath is only available in client side");
276
+ return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
277
+ }
278
+ getPrefix() {
279
+ return this.#prefix;
280
+ }
281
+ getPrefixedPath(path) {
282
+ return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
283
+ }
284
+ };
285
+ var router = new Router();
927
286
 
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 = {}) {
1065
- return function(prototype, key, idx) {
1066
- const argMetas = getArgMetasOnPrototype(prototype, key);
1067
- argMetas[idx] = { name, returns, argsOption, key, idx, type };
1068
- setArgMetasOnPrototype(prototype, key, argMetas);
1069
- };
1070
- };
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
- };
287
+ // pkgs/@akanjs/client/src/cookie.ts
288
+ var import_base3 = require("@akanjs/base");
289
+ var import_common2 = require("@akanjs/common");
290
+ var import_signal = require("@akanjs/signal");
291
+ var import_signal2 = require("@akanjs/signal");
292
+ var import_core = require("@capacitor/core");
293
+ var import_js_cookie = __toESM(require("js-cookie"));
294
+ var import_jwt_decode = require("jwt-decode");
295
+ var import_react2 = __toESM(require("react"));
1092
296
 
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
- };
297
+ // pkgs/@akanjs/client/src/storage.ts
298
+ var import_base2 = require("@akanjs/base");
299
+ var import_preferences = require("@capacitor/preferences");
300
+ var storage = {
301
+ getItem: async (key) => {
302
+ if (import_base2.baseClientEnv.side === "server")
303
+ return;
304
+ if (import_base2.baseClientEnv.renderMode === "ssr")
305
+ return localStorage.getItem(key);
306
+ else
307
+ return (await import_preferences.Preferences.get({ key })).value;
308
+ },
309
+ setItem: async (key, value) => {
310
+ if (import_base2.baseClientEnv.side === "server")
311
+ return;
312
+ if (import_base2.baseClientEnv.renderMode === "ssr") {
313
+ localStorage.setItem(key, value);
314
+ return;
315
+ } else {
316
+ await import_preferences.Preferences.set({ key, value });
317
+ return;
1103
318
  }
1104
- });
1105
-
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"));
319
+ },
320
+ removeItem: (key) => {
321
+ if (import_base2.baseClientEnv.side === "server")
322
+ return;
323
+ if (import_base2.baseClientEnv.renderMode === "ssr") {
324
+ localStorage.removeItem(key);
325
+ return;
326
+ } else
327
+ return import_preferences.Preferences.remove({ key });
328
+ }
329
+ };
1111
330
 
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;
331
+ // pkgs/@akanjs/client/src/cookie.ts
332
+ var cookies = import_base3.baseClientEnv.side === "server" ? () => {
333
+ const nextHeaders = require("next/headers");
334
+ const cookies2 = nextHeaders.cookies();
335
+ return import_react2.default.use(cookies2);
336
+ } : () => {
337
+ const cookie = import_js_cookie.default.get();
338
+ return new Map(
339
+ Object.entries(cookie).map(([key, value]) => [
340
+ key,
341
+ {
342
+ name: key,
343
+ value: typeof value === "string" && value.startsWith("j:") ? JSON.parse(value.slice(2)) : value
1132
344
  }
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 }) => {
1163
- if (baseClientEnv.side === "server")
1164
- return;
1165
- 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;
345
+ ])
346
+ );
347
+ };
348
+ var setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
349
+ if (import_base3.baseClientEnv.side === "server")
350
+ return;
351
+ else
352
+ void import_core.CapacitorCookies.setCookie({ key, value });
353
+ };
354
+ var getCookie = (key) => {
355
+ if (import_base3.baseClientEnv.side === "server")
356
+ return cookies().get(key)?.value;
357
+ else
358
+ return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
359
+ };
360
+ var removeCookie = (key, options = { path: "/" }) => {
361
+ if (import_base3.baseClientEnv.side === "server")
362
+ return cookies().delete(key);
363
+ else {
364
+ document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
365
+ }
366
+ };
367
+ var headers = import_base3.baseClientEnv.side === "server" ? () => import_react2.default.use(require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
368
+ var getHeader = (key) => {
369
+ return headers().get(key);
370
+ };
371
+ var getAccount = () => {
372
+ const jwt = getCookie("jwt") ?? getHeader("jwt");
373
+ if (!jwt)
374
+ return import_signal2.defaultAccount;
375
+ const account = (0, import_jwt_decode.jwtDecode)(jwt);
376
+ if (account.appName !== import_base3.baseEnv.appName || account.environment !== import_base3.baseEnv.environment)
377
+ return import_signal2.defaultAccount;
378
+ return account;
379
+ };
380
+ function getMe(option) {
381
+ const me = getAccount().me;
382
+ if (!me && option) {
383
+ if (option.unauthorize === "notFound")
384
+ router.notFound();
385
+ else if (import_base3.baseClientEnv.side === "client")
386
+ router.replace(option.unauthorize);
1171
387
  else
1172
- return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
1173
- };
1174
- var removeCookie = (key, options = { path: "/" }) => {
1175
- 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;
388
+ import_react2.default.use(router.redirect(option.unauthorize));
1205
389
  }
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));
1215
- }
1216
- return self;
390
+ return me;
391
+ }
392
+ function getSelf(option) {
393
+ const self = getAccount().self;
394
+ if (!self && option) {
395
+ if (option.unauthorize === "notFound")
396
+ router.notFound();
397
+ else if (import_base3.baseClientEnv.side === "client")
398
+ router.replace(option.unauthorize);
399
+ else
400
+ import_react2.default.use(router.redirect(option.unauthorize));
1217
401
  }
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
- };
402
+ return self;
403
+ }
404
+ var setAuth = ({ jwt }) => {
405
+ import_signal.client.setJwt(jwt);
406
+ setCookie("jwt", jwt);
407
+ void storage.setItem("jwt", jwt);
408
+ };
409
+ var initAuth = ({ jwt } = {}) => {
410
+ const token = jwt ?? cookies().get("jwt")?.value;
411
+ if (token)
412
+ setAuth({ jwt: token });
413
+ import_signal.client.init();
414
+ import_common2.Logger.verbose(`JWT set from cookie: ${token}`);
415
+ };
416
+ var resetAuth = () => {
417
+ import_signal.client.reset();
418
+ removeCookie("jwt");
419
+ void storage.removeItem("jwt");
420
+ };
1235
421
 
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;
422
+ // pkgs/@akanjs/client/src/device.ts
423
+ var import_device = require("@capacitor/device");
424
+ var import_haptics = require("@capacitor/haptics");
425
+ var import_keyboard = require("@capacitor/keyboard");
426
+ var import_capacitor_plugin_safe_area = require("capacitor-plugin-safe-area");
427
+ var import_react_device_detect = require("react-device-detect");
428
+ var Device = class {
429
+ info;
430
+ lang;
431
+ topSafeArea;
432
+ bottomSafeArea;
433
+ isMobile = import_react_device_detect.isMobile;
434
+ #keyboard = import_keyboard.Keyboard;
435
+ #haptics = import_haptics.Haptics;
436
+ #pageContentRef = null;
437
+ async init({ lang, supportLanguages = [] } = {}) {
438
+ const [
439
+ info,
440
+ { value: languageCode },
441
+ {
442
+ insets: { top: topSafeArea, bottom: bottomSafeArea }
1304
443
  }
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;
444
+ ] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
445
+ const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
446
+ const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
447
+ this.info = info;
448
+ this.lang = lang ?? predefinedLang ?? languageCode;
449
+ this.topSafeArea = topSafeArea;
450
+ this.bottomSafeArea = bottomSafeArea;
451
+ }
452
+ setPageContentRef(pageContentRef) {
453
+ this.#pageContentRef = pageContentRef;
454
+ }
455
+ async showKeyboard() {
456
+ if (this.info.platform === "web")
457
+ return;
458
+ await this.#keyboard.show();
459
+ }
460
+ async hideKeyboard() {
461
+ if (this.info.platform === "web")
462
+ return;
463
+ await this.#keyboard.hide();
464
+ }
465
+ listenKeyboardChanged(onKeyboardChanged) {
466
+ if (this.info.platform === "web")
467
+ return;
468
+ void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
469
+ onKeyboardChanged(keyboard.keyboardHeight);
470
+ });
471
+ void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
472
+ onKeyboardChanged(keyboard.keyboardHeight);
473
+ });
474
+ void this.#keyboard.addListener("keyboardWillHide", () => {
475
+ onKeyboardChanged(0);
476
+ });
477
+ void this.#keyboard.addListener("keyboardDidHide", () => {
478
+ onKeyboardChanged(0);
479
+ });
480
+ }
481
+ unlistenKeyboardChanged() {
482
+ if (this.info.platform === "web")
483
+ return;
484
+ void this.#keyboard.removeAllListeners();
485
+ }
486
+ async vibrate(type = "medium") {
487
+ if (typeof type === "number") {
488
+ await this.#haptics.vibrate({ duration: type });
489
+ return;
1331
490
  }
1332
- setScrollTop(scrollTop) {
1333
- if (this.info.platform === "web") {
1334
- window.scrollTo({ top: scrollTop });
1335
- return;
491
+ const handleImpact = {
492
+ light: async () => {
493
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
494
+ },
495
+ medium: async () => {
496
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
497
+ },
498
+ heavy: async () => {
499
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
500
+ },
501
+ selectionStart: async () => {
502
+ await this.#haptics.selectionStart();
503
+ },
504
+ selectionChanged: async () => {
505
+ await this.#haptics.selectionChanged();
506
+ },
507
+ selectionEnd: async () => {
508
+ await this.#haptics.selectionEnd();
1336
509
  }
1337
- return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
510
+ };
511
+ await handleImpact[type]();
512
+ }
513
+ getScrollTop() {
514
+ if (this.info.platform === "web")
515
+ return window.scrollY;
516
+ return this.#pageContentRef?.current?.scrollTop ?? 0;
517
+ }
518
+ setScrollTop(scrollTop) {
519
+ if (this.info.platform === "web") {
520
+ window.scrollTo({ top: scrollTop });
521
+ return;
1338
522
  }
1339
- };
1340
- var device = new Device();
523
+ return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
524
+ }
525
+ };
526
+ var device = new Device();
1341
527
 
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
- })();
1347
- //! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
528
+ // pkgs/@akanjs/client/src/createFont.ts
529
+ var createFont = (data) => null;
530
+ var Nanum_Gothic_Coding = createFont;
531
+ var Noto_Sans_KR = createFont;