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