@akanjs/client 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +14 -0
- package/index.js +20 -1346
- package/package.json +2 -21
- package/src/cookie.d.ts +71 -0
- package/src/cookie.js +155 -0
- package/src/createFont.d.ts +6 -0
- package/src/createFont.js +36 -0
- package/src/csrTypes.d.ts +181 -0
- package/src/csrTypes.js +62 -0
- package/src/device.d.ts +27 -0
- package/src/device.js +140 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +33 -0
- package/src/navigation.d.ts +12 -0
- package/src/navigation.js +58 -0
- package/src/router.d.ts +46 -0
- package/src/router.js +239 -0
- package/src/storage.d.ts +7 -0
- package/src/storage.js +60 -0
- package/src/types.d.ts +134 -0
- package/src/types.js +37 -0
package/index.js
CHANGED
|
@@ -1,1347 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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");
|
|
206
|
-
|
|
207
|
-
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
208
|
-
var import_dayjs3 = __toESM(__require("dayjs"));
|
|
209
|
-
|
|
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);
|
|
214
|
-
|
|
215
|
-
// pkgs/@akanjs/common/src/pluralize.ts
|
|
216
|
-
var import_pluralize = __toESM(__require("pluralize"));
|
|
217
|
-
|
|
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);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
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 = {
|
|
388
|
-
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);
|
|
393
|
-
},
|
|
394
|
-
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);
|
|
399
|
-
},
|
|
400
|
-
back: () => {
|
|
401
|
-
throw new Error("back is only available in client");
|
|
402
|
-
},
|
|
403
|
-
refresh: () => {
|
|
404
|
-
throw new Error("refresh is only available in client");
|
|
405
|
-
}
|
|
406
|
-
};
|
|
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;
|
|
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
|
-
});
|
|
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
|
-
};
|
|
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");
|
|
927
|
-
|
|
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
|
-
};
|
|
1092
|
-
|
|
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
|
-
});
|
|
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"));
|
|
1111
|
-
|
|
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 }) => {
|
|
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;
|
|
1171
|
-
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;
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1205
10
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
}
|
|
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
|
-
};
|
|
1235
|
-
|
|
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;
|
|
1304
|
-
}
|
|
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;
|
|
1331
|
-
}
|
|
1332
|
-
setScrollTop(scrollTop) {
|
|
1333
|
-
if (this.info.platform === "web") {
|
|
1334
|
-
window.scrollTo({ top: scrollTop });
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
var device = new Device();
|
|
1341
|
-
|
|
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같은것들 잘 동작안할 수 있음. 추후 수정 필요.
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(index_exports);
|
|
17
|
+
__reExport(index_exports, require("./src"), module.exports);
|
|
18
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
19
|
+
0 && (module.exports = {
|
|
20
|
+
...require("./src")
|
|
21
|
+
});
|