@akanjs/next 0.0.33 → 0.0.35
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 +2723 -20
- package/package.json +29 -32
- package/README.md +0 -11
- package/index.d.ts +0 -1
- package/src/bootCsr.d.ts +0 -1
- package/src/bootCsr.js +0 -160
- package/src/createNextMiddleware.d.ts +0 -2
- package/src/createNextMiddleware.js +0 -82
- package/src/createRobotPage.d.ts +0 -2
- package/src/createRobotPage.js +0 -38
- package/src/createSitemapPage.d.ts +0 -2
- package/src/createSitemapPage.js +0 -30
- package/src/index.d.ts +0 -20
- package/src/index.js +0 -82
- package/src/lazy.d.ts +0 -5
- package/src/lazy.js +0 -39
- package/src/makePageProto.d.ts +0 -30
- package/src/makePageProto.js +0 -137
- package/src/types.d.ts +0 -7
- package/src/types.js +0 -15
- package/src/useCamera.d.ts +0 -7
- package/src/useCamera.js +0 -100
- package/src/useCodepush.d.ts +0 -17
- package/src/useCodepush.js +0 -107
- package/src/useContact.d.ts +0 -6
- package/src/useContact.js +0 -59
- package/src/useCsrValues.d.ts +0 -30
- package/src/useCsrValues.js +0 -615
- package/src/useDebounce.d.ts +0 -1
- package/src/useDebounce.js +0 -41
- package/src/useFetch.d.ts +0 -6
- package/src/useFetch.js +0 -46
- package/src/useGeoLocation.d.ts +0 -7
- package/src/useGeoLocation.js +0 -43
- package/src/useHistory.d.ts +0 -20
- package/src/useHistory.js +0 -69
- package/src/useInterval.d.ts +0 -1
- package/src/useInterval.js +0 -44
- package/src/useLocation.d.ts +0 -8
- package/src/useLocation.js +0 -82
- package/src/usePurchase.d.ts +0 -19
- package/src/usePurchase.js +0 -143
- package/src/usePushNoti.d.ts +0 -6
- package/src/usePushNoti.js +0 -65
- package/src/useThrottle.d.ts +0 -1
- package/src/useThrottle.js +0 -43
package/index.js
CHANGED
|
@@ -1,21 +1,2724 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined")
|
|
12
|
+
return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// pkgs/@akanjs/next/src/useFetch.ts
|
|
33
|
+
var import_react = __require("react");
|
|
34
|
+
var useFetch = (fnOrPromise, { onError } = {}) => {
|
|
35
|
+
const [fetchState, setFetchState] = (0, import_react.useState)(
|
|
36
|
+
fnOrPromise instanceof Promise ? { fulfilled: false, value: null } : { fulfilled: true, value: fnOrPromise }
|
|
37
|
+
);
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
39
|
+
void (async () => {
|
|
40
|
+
try {
|
|
41
|
+
const ret = fnOrPromise instanceof Promise ? await fnOrPromise : fnOrPromise;
|
|
42
|
+
setFetchState({ fulfilled: true, value: ret });
|
|
43
|
+
} catch (err) {
|
|
44
|
+
const content = `Error: ${typeof err === "string" ? err : err.message}`;
|
|
45
|
+
onError?.(content);
|
|
46
|
+
throw new Error(content);
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
}, []);
|
|
50
|
+
return fetchState;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// pkgs/@akanjs/next/src/lazy.ts
|
|
54
|
+
var import_dynamic = __toESM(__require("next/dynamic"));
|
|
55
|
+
var lazy = (loader, option) => (0, import_dynamic.default)(loader, option ?? {});
|
|
56
|
+
|
|
57
|
+
// pkgs/@akanjs/base/src/base.ts
|
|
58
|
+
var version = "0.9.0";
|
|
59
|
+
var logo = `
|
|
60
|
+
_ _ _
|
|
61
|
+
/ \\ | | ____ _ _ __ (_)___
|
|
62
|
+
/ _ \\ | |/ / _' | '_ \\ | / __|
|
|
63
|
+
/ ___ \\| < (_| | | | |_ | \\__ \\
|
|
64
|
+
/_/ \\_\\_|\\_\\__,_|_| |_(_)/ |___/
|
|
65
|
+
|__/ ver ${version}
|
|
66
|
+
? See more details on docs https://www.akanjs.com/docs
|
|
67
|
+
\u2605 Star Akanjs on GitHub https://github.com/aka-bassman/akanjs
|
|
68
|
+
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
// pkgs/@akanjs/base/src/baseEnv.ts
|
|
72
|
+
var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
|
|
73
|
+
var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
|
|
74
|
+
var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
|
|
75
|
+
if (appName === "unknown")
|
|
76
|
+
throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
|
|
77
|
+
if (repoName === "unknown")
|
|
78
|
+
throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
|
|
79
|
+
if (serveDomain === "unknown")
|
|
80
|
+
throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
|
|
81
|
+
var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
82
|
+
var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
|
|
83
|
+
var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
|
|
84
|
+
var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
|
|
85
|
+
var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
|
|
86
|
+
var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
|
|
87
|
+
var baseEnv = {
|
|
88
|
+
repoName,
|
|
89
|
+
serveDomain,
|
|
90
|
+
appName,
|
|
91
|
+
environment,
|
|
92
|
+
operationType,
|
|
93
|
+
operationMode,
|
|
94
|
+
networkType,
|
|
95
|
+
tunnelUsername,
|
|
96
|
+
tunnelPassword
|
|
97
|
+
};
|
|
98
|
+
var side = typeof window === "undefined" ? "server" : "client";
|
|
99
|
+
var renderMode = process.env.RENDER_ENV ?? "ssr";
|
|
100
|
+
var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
|
|
101
|
+
var clientPort = parseInt(
|
|
102
|
+
process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
|
|
103
|
+
);
|
|
104
|
+
var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
|
|
105
|
+
var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
|
|
106
|
+
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");
|
|
107
|
+
var serverPort = parseInt(
|
|
108
|
+
process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
|
|
109
|
+
);
|
|
110
|
+
var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
|
|
111
|
+
var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
|
|
112
|
+
var serverGraphqlUri = `${serverHttpUri}/graphql`;
|
|
113
|
+
var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
|
|
114
|
+
var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
|
|
115
|
+
var baseClientEnv = {
|
|
116
|
+
...baseEnv,
|
|
117
|
+
side,
|
|
118
|
+
renderMode,
|
|
119
|
+
websocket: true,
|
|
120
|
+
clientHost,
|
|
121
|
+
clientPort,
|
|
122
|
+
clientHttpProtocol,
|
|
123
|
+
clientHttpUri,
|
|
124
|
+
serverHost,
|
|
125
|
+
serverPort,
|
|
126
|
+
serverHttpProtocol,
|
|
127
|
+
serverHttpUri,
|
|
128
|
+
serverGraphqlUri,
|
|
129
|
+
serverWsProtocol,
|
|
130
|
+
serverWsUri
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// pkgs/@akanjs/base/src/scalar.ts
|
|
134
|
+
var import_dayjs = __toESM(__require("dayjs"));
|
|
135
|
+
var dayjs = import_dayjs.default;
|
|
136
|
+
var Int = class {
|
|
137
|
+
__Scalar__;
|
|
138
|
+
};
|
|
139
|
+
var Upload = class {
|
|
140
|
+
__Scalar__;
|
|
141
|
+
filename;
|
|
142
|
+
mimetype;
|
|
143
|
+
encoding;
|
|
144
|
+
createReadStream;
|
|
145
|
+
};
|
|
146
|
+
var Float = class {
|
|
147
|
+
__Scalar__;
|
|
148
|
+
};
|
|
149
|
+
var ID = class {
|
|
150
|
+
__Scalar__;
|
|
151
|
+
};
|
|
152
|
+
var JSON2 = class {
|
|
153
|
+
__Scalar__;
|
|
154
|
+
};
|
|
155
|
+
var getNonArrayModel = (arraiedModel2) => {
|
|
156
|
+
let arrDepth = 0;
|
|
157
|
+
let target = arraiedModel2;
|
|
158
|
+
while (Array.isArray(target)) {
|
|
159
|
+
target = target[0];
|
|
160
|
+
arrDepth++;
|
|
161
|
+
}
|
|
162
|
+
return [target, arrDepth];
|
|
163
|
+
};
|
|
164
|
+
var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON2, Map]);
|
|
165
|
+
var scalarNameMap = /* @__PURE__ */ new Map([
|
|
166
|
+
[ID, "ID"],
|
|
167
|
+
[Int, "Int"],
|
|
168
|
+
[Float, "Float"],
|
|
169
|
+
[String, "String"],
|
|
170
|
+
[Boolean, "Boolean"],
|
|
171
|
+
[Date, "Date"],
|
|
172
|
+
[Upload, "Upload"],
|
|
173
|
+
[JSON2, "JSON"],
|
|
174
|
+
[Map, "Map"]
|
|
175
|
+
]);
|
|
176
|
+
var scalarArgMap = /* @__PURE__ */ new Map([
|
|
177
|
+
[ID, null],
|
|
178
|
+
[String, ""],
|
|
179
|
+
[Boolean, false],
|
|
180
|
+
[Date, dayjs(/* @__PURE__ */ new Date(-1))],
|
|
181
|
+
[Int, 0],
|
|
182
|
+
[Float, 0],
|
|
183
|
+
[JSON2, {}],
|
|
184
|
+
[Map, {}]
|
|
185
|
+
]);
|
|
186
|
+
var scalarDefaultMap = /* @__PURE__ */ new Map([
|
|
187
|
+
[ID, null],
|
|
188
|
+
[String, ""],
|
|
189
|
+
[Boolean, false],
|
|
190
|
+
[Date, dayjs(/* @__PURE__ */ new Date(-1))],
|
|
191
|
+
[Int, 0],
|
|
192
|
+
[Float, 0],
|
|
193
|
+
[JSON2, {}]
|
|
194
|
+
]);
|
|
195
|
+
var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
|
|
196
|
+
var isGqlMap = (modelRef) => modelRef === Map;
|
|
197
|
+
|
|
198
|
+
// pkgs/@akanjs/client/src/types.ts
|
|
199
|
+
var import_clsx = __require("clsx");
|
|
200
|
+
|
|
201
|
+
// pkgs/@akanjs/client/src/csrTypes.ts
|
|
202
|
+
var import_react2 = __require("react");
|
|
203
|
+
var DEFAULT_TOP_INSET = 48;
|
|
204
|
+
var DEFAULT_BOTTOM_INSET = 60;
|
|
205
|
+
var defaultPageState = {
|
|
206
|
+
transition: "none",
|
|
207
|
+
topSafeArea: 0,
|
|
208
|
+
bottomSafeArea: 0,
|
|
209
|
+
topInset: 0,
|
|
210
|
+
bottomInset: 0,
|
|
211
|
+
gesture: true,
|
|
212
|
+
cache: false
|
|
213
|
+
};
|
|
214
|
+
var csrContext = (0, import_react2.createContext)({});
|
|
215
|
+
var pathContext = (0, import_react2.createContext)({});
|
|
216
|
+
|
|
217
|
+
// pkgs/@akanjs/common/src/splitVersion.ts
|
|
218
|
+
var splitVersion = (version2) => {
|
|
219
|
+
const [major, minor, patch] = version2.split(".");
|
|
220
|
+
return { major, minor, patch };
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// pkgs/@akanjs/common/src/isDayjs.ts
|
|
224
|
+
var import_dayjs2 = __require("dayjs");
|
|
225
|
+
|
|
226
|
+
// pkgs/@akanjs/common/src/pathGet.ts
|
|
227
|
+
var pathGet = (path, obj, separator = ".") => {
|
|
228
|
+
const properties = Array.isArray(path) ? path : path.split(separator);
|
|
229
|
+
return properties.reduce((prev, curr) => prev[curr], obj);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
233
|
+
var import_dayjs3 = __toESM(__require("dayjs"));
|
|
234
|
+
|
|
235
|
+
// pkgs/@akanjs/common/src/isValidDate.ts
|
|
236
|
+
var import_dayjs4 = __toESM(__require("dayjs"));
|
|
237
|
+
var import_customParseFormat = __toESM(__require("dayjs/plugin/customParseFormat"));
|
|
238
|
+
import_dayjs4.default.extend(import_customParseFormat.default);
|
|
239
|
+
|
|
240
|
+
// pkgs/@akanjs/common/src/mergeVersion.ts
|
|
241
|
+
var mergeVersion = (major, minor, patch) => `${major}.${minor}.${patch}`;
|
|
242
|
+
|
|
243
|
+
// pkgs/@akanjs/common/src/pluralize.ts
|
|
244
|
+
var import_pluralize = __toESM(__require("pluralize"));
|
|
245
|
+
|
|
246
|
+
// pkgs/@akanjs/common/src/Logger.ts
|
|
247
|
+
var import_dayjs5 = __toESM(__require("dayjs"));
|
|
248
|
+
var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
|
|
249
|
+
var clc = {
|
|
250
|
+
bold: (text) => `\x1B[1m${text}\x1B[0m`,
|
|
251
|
+
green: (text) => `\x1B[32m${text}\x1B[39m`,
|
|
252
|
+
yellow: (text) => `\x1B[33m${text}\x1B[39m`,
|
|
253
|
+
red: (text) => `\x1B[31m${text}\x1B[39m`,
|
|
254
|
+
magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
|
|
255
|
+
cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
|
|
256
|
+
};
|
|
257
|
+
var colorizeMap = {
|
|
258
|
+
trace: clc.bold,
|
|
259
|
+
verbose: clc.cyanBright,
|
|
260
|
+
debug: clc.magentaBright,
|
|
261
|
+
log: clc.green,
|
|
262
|
+
info: clc.green,
|
|
263
|
+
warn: clc.yellow,
|
|
264
|
+
error: clc.red
|
|
265
|
+
};
|
|
266
|
+
var Logger = class _Logger {
|
|
267
|
+
static #ignoreCtxSet = /* @__PURE__ */ new Set([
|
|
268
|
+
"InstanceLoader",
|
|
269
|
+
"RoutesResolver",
|
|
270
|
+
"RouterExplorer",
|
|
271
|
+
"NestFactory",
|
|
272
|
+
"WebSocketsController",
|
|
273
|
+
"GraphQLModule",
|
|
274
|
+
"NestApplication"
|
|
275
|
+
]);
|
|
276
|
+
static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
|
|
277
|
+
static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
|
|
278
|
+
static #startAt = (0, import_dayjs5.default)();
|
|
279
|
+
static setLevel(level) {
|
|
280
|
+
this.level = level;
|
|
281
|
+
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
282
|
+
}
|
|
283
|
+
name;
|
|
284
|
+
constructor(name) {
|
|
285
|
+
this.name = name;
|
|
286
|
+
}
|
|
287
|
+
trace(msg, context = "") {
|
|
288
|
+
if (_Logger.#levelIdx <= 0)
|
|
289
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "trace");
|
|
290
|
+
}
|
|
291
|
+
verbose(msg, context = "") {
|
|
292
|
+
if (_Logger.#levelIdx <= 1)
|
|
293
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
|
|
294
|
+
}
|
|
295
|
+
debug(msg, context = "") {
|
|
296
|
+
if (_Logger.#levelIdx <= 2)
|
|
297
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "debug");
|
|
298
|
+
}
|
|
299
|
+
log(msg, context = "") {
|
|
300
|
+
if (_Logger.#levelIdx <= 3)
|
|
301
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "log");
|
|
302
|
+
}
|
|
303
|
+
info(msg, context = "") {
|
|
304
|
+
if (_Logger.#levelIdx <= 4)
|
|
305
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "info");
|
|
306
|
+
}
|
|
307
|
+
warn(msg, context = "") {
|
|
308
|
+
if (_Logger.#levelIdx <= 5)
|
|
309
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "warn");
|
|
310
|
+
}
|
|
311
|
+
error(msg, context = "") {
|
|
312
|
+
if (_Logger.#levelIdx <= 6)
|
|
313
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "error");
|
|
314
|
+
}
|
|
315
|
+
raw(msg, method) {
|
|
316
|
+
_Logger.rawLog(msg, method);
|
|
317
|
+
}
|
|
318
|
+
rawLog(msg, method) {
|
|
319
|
+
_Logger.rawLog(msg, method);
|
|
320
|
+
}
|
|
321
|
+
static trace(msg, context = "") {
|
|
322
|
+
if (_Logger.#levelIdx <= 0)
|
|
323
|
+
_Logger.#printMessages("App", msg, context, "trace");
|
|
324
|
+
}
|
|
325
|
+
static verbose(msg, context = "") {
|
|
326
|
+
if (_Logger.#levelIdx <= 1)
|
|
327
|
+
_Logger.#printMessages("App", msg, context, "verbose");
|
|
328
|
+
}
|
|
329
|
+
static debug(msg, context = "") {
|
|
330
|
+
if (_Logger.#levelIdx <= 2)
|
|
331
|
+
_Logger.#printMessages("App", msg, context, "debug");
|
|
332
|
+
}
|
|
333
|
+
static log(msg, context = "") {
|
|
334
|
+
if (_Logger.#levelIdx <= 3)
|
|
335
|
+
_Logger.#printMessages("App", msg, context, "log");
|
|
336
|
+
}
|
|
337
|
+
static info(msg, context = "") {
|
|
338
|
+
if (_Logger.#levelIdx <= 4)
|
|
339
|
+
_Logger.#printMessages("App", msg, context, "info");
|
|
340
|
+
}
|
|
341
|
+
static warn(msg, context = "") {
|
|
342
|
+
if (_Logger.#levelIdx <= 5)
|
|
343
|
+
_Logger.#printMessages("App", msg, context, "warn");
|
|
344
|
+
}
|
|
345
|
+
static error(msg, context = "") {
|
|
346
|
+
if (_Logger.#levelIdx <= 6)
|
|
347
|
+
_Logger.#printMessages("App", msg, context, "error");
|
|
348
|
+
}
|
|
349
|
+
static #colorize(msg, logLevel) {
|
|
350
|
+
return colorizeMap[logLevel](msg);
|
|
351
|
+
}
|
|
352
|
+
static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
|
|
353
|
+
if (this.#ignoreCtxSet.has(context))
|
|
354
|
+
return;
|
|
355
|
+
const now = (0, import_dayjs5.default)();
|
|
356
|
+
const processMsg = this.#colorize(
|
|
357
|
+
`[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
|
|
358
|
+
logLevel
|
|
359
|
+
);
|
|
360
|
+
const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
|
|
361
|
+
const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
|
|
362
|
+
const contextMsg = context ? clc.yellow(`[${context}] `) : "";
|
|
363
|
+
const contentMsg = this.#colorize(content, logLevel);
|
|
364
|
+
const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
|
|
365
|
+
if (typeof window === "undefined")
|
|
366
|
+
process[writeStreamType].write(
|
|
367
|
+
`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
368
|
+
`
|
|
369
|
+
);
|
|
370
|
+
else
|
|
371
|
+
console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
372
|
+
`);
|
|
373
|
+
}
|
|
374
|
+
static rawLog(msg, method) {
|
|
375
|
+
this.raw(`${msg}
|
|
376
|
+
`, method);
|
|
377
|
+
}
|
|
378
|
+
static raw(msg, method) {
|
|
379
|
+
if (typeof window === "undefined" && method !== "console" && global.process)
|
|
380
|
+
global.process.stdout.write(msg);
|
|
381
|
+
else
|
|
382
|
+
console.log(msg);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// pkgs/@akanjs/common/src/lowerlize.ts
|
|
387
|
+
var lowerlize = (str) => {
|
|
388
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// pkgs/@akanjs/common/src/sleep.ts
|
|
392
|
+
var sleep = async (ms) => {
|
|
393
|
+
return new Promise((resolve) => {
|
|
394
|
+
setTimeout(() => {
|
|
395
|
+
resolve(true);
|
|
396
|
+
}, ms);
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// pkgs/@akanjs/client/src/router.ts
|
|
401
|
+
var import_navigation = __require("next/navigation");
|
|
402
|
+
var getPathInfo = (href, lang, prefix) => {
|
|
403
|
+
const langLength = lang.length + 1;
|
|
404
|
+
const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
|
|
405
|
+
const prefixLength = prefix ? prefix.length + 1 : 0;
|
|
406
|
+
const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
|
|
407
|
+
const subRoute = prefix ? `/${prefix}` : "";
|
|
408
|
+
const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
|
|
409
|
+
return { path, pathname };
|
|
410
|
+
};
|
|
411
|
+
var Router = class {
|
|
412
|
+
isInitialized = false;
|
|
413
|
+
#prefix = "";
|
|
414
|
+
#lang = "en";
|
|
415
|
+
#instance = {
|
|
416
|
+
push: (href) => {
|
|
417
|
+
const { pathname } = this.#getPathInfo(href);
|
|
418
|
+
Logger.log(`push to:${pathname}`);
|
|
419
|
+
if (baseClientEnv.side === "server")
|
|
420
|
+
void (0, import_navigation.redirect)(pathname);
|
|
421
|
+
},
|
|
422
|
+
replace: (href) => {
|
|
423
|
+
const { pathname } = this.#getPathInfo(href);
|
|
424
|
+
Logger.log(`replace to:${pathname}`);
|
|
425
|
+
if (baseClientEnv.side === "server")
|
|
426
|
+
void (0, import_navigation.redirect)(pathname);
|
|
427
|
+
},
|
|
428
|
+
back: () => {
|
|
429
|
+
throw new Error("back is only available in client");
|
|
430
|
+
},
|
|
431
|
+
refresh: () => {
|
|
432
|
+
throw new Error("refresh is only available in client");
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
init(options) {
|
|
436
|
+
this.#prefix = options.prefix ?? "";
|
|
437
|
+
this.#lang = options.lang ?? "en";
|
|
438
|
+
if (options.type === "csr")
|
|
439
|
+
this.#initCSRClientRouter(options);
|
|
440
|
+
else if (options.side === "server")
|
|
441
|
+
this.#initNextServerRouter(options);
|
|
442
|
+
else
|
|
443
|
+
this.#initNextClientRouter(options);
|
|
444
|
+
this.isInitialized = true;
|
|
445
|
+
Logger.verbose("Router initialized");
|
|
446
|
+
}
|
|
447
|
+
#initNextServerRouter(options) {
|
|
448
|
+
}
|
|
449
|
+
#initNextClientRouter(options) {
|
|
450
|
+
this.#instance = {
|
|
451
|
+
push: (href) => {
|
|
452
|
+
const { path, pathname } = this.#getPathInfo(href);
|
|
453
|
+
this.#postPathChange({ path, pathname });
|
|
454
|
+
options.router.push(pathname);
|
|
455
|
+
},
|
|
456
|
+
replace: (href) => {
|
|
457
|
+
const { path, pathname } = this.#getPathInfo(href);
|
|
458
|
+
this.#postPathChange({ path, pathname });
|
|
459
|
+
options.router.replace(pathname);
|
|
460
|
+
},
|
|
461
|
+
back: () => {
|
|
462
|
+
const { path, pathname } = this.#getPathInfo(document.referrer);
|
|
463
|
+
this.#postPathChange({ path, pathname });
|
|
464
|
+
options.router.back();
|
|
465
|
+
},
|
|
466
|
+
refresh: () => {
|
|
467
|
+
const { path, pathname } = this.#getPathInfo(location.pathname);
|
|
468
|
+
this.#postPathChange({ path, pathname });
|
|
469
|
+
options.router.refresh();
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
#initCSRClientRouter(options) {
|
|
474
|
+
this.#instance = {
|
|
475
|
+
push: (href) => {
|
|
476
|
+
const { path, pathname } = this.#getPathInfo(href);
|
|
477
|
+
if (location.pathname === pathname)
|
|
478
|
+
return;
|
|
479
|
+
this.#postPathChange({ path, pathname });
|
|
480
|
+
options.router.push(pathname);
|
|
481
|
+
},
|
|
482
|
+
replace: (href) => {
|
|
483
|
+
const { path, pathname } = this.#getPathInfo(href);
|
|
484
|
+
if (location.pathname === pathname)
|
|
485
|
+
return;
|
|
486
|
+
this.#postPathChange({ path, pathname });
|
|
487
|
+
options.router.replace(pathname);
|
|
488
|
+
},
|
|
489
|
+
back: () => {
|
|
490
|
+
const { path, pathname } = this.#getPathInfo(document.referrer);
|
|
491
|
+
if (location.pathname === pathname)
|
|
492
|
+
return;
|
|
493
|
+
this.#postPathChange({ path, pathname });
|
|
494
|
+
options.router.back();
|
|
495
|
+
},
|
|
496
|
+
refresh: () => {
|
|
497
|
+
const { path, pathname } = this.#getPathInfo(location.pathname);
|
|
498
|
+
this.#postPathChange({ path, pathname });
|
|
499
|
+
options.router.refresh();
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
#checkInitialized() {
|
|
504
|
+
if (!this.isInitialized)
|
|
505
|
+
throw new Error("Router is not initialized");
|
|
506
|
+
}
|
|
507
|
+
#getPathInfo(href, prefix = this.#prefix) {
|
|
508
|
+
return getPathInfo(href, this.#lang, prefix);
|
|
509
|
+
}
|
|
510
|
+
#postPathChange({ path, pathname }) {
|
|
511
|
+
Logger.log(`pathChange-start:${path}`);
|
|
512
|
+
window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
|
|
513
|
+
}
|
|
514
|
+
push(href) {
|
|
515
|
+
this.#checkInitialized();
|
|
516
|
+
this.#instance.push(href);
|
|
517
|
+
return void 0;
|
|
518
|
+
}
|
|
519
|
+
replace(href) {
|
|
520
|
+
this.#checkInitialized();
|
|
521
|
+
this.#instance.replace(href);
|
|
522
|
+
return void 0;
|
|
523
|
+
}
|
|
524
|
+
back() {
|
|
525
|
+
if (baseClientEnv.side === "server")
|
|
526
|
+
throw new Error("back is only available in client side");
|
|
527
|
+
this.#checkInitialized();
|
|
528
|
+
this.#instance.back();
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
refresh() {
|
|
532
|
+
if (baseClientEnv.side === "server")
|
|
533
|
+
throw new Error("refresh is only available in client side");
|
|
534
|
+
this.#checkInitialized();
|
|
535
|
+
this.#instance.refresh();
|
|
536
|
+
return void 0;
|
|
537
|
+
}
|
|
538
|
+
async redirect(href) {
|
|
539
|
+
if (baseClientEnv.side === "server") {
|
|
540
|
+
const nextHeaders = __require("next/headers");
|
|
541
|
+
const headers2 = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
|
|
542
|
+
const lang = headers2.get("x-locale") ?? this.#lang;
|
|
543
|
+
const basePath = headers2.get("x-base-path");
|
|
544
|
+
const { pathname } = getPathInfo(href, lang, basePath ?? "");
|
|
545
|
+
Logger.log(`redirect to:${pathname}`);
|
|
546
|
+
(0, import_navigation.redirect)(pathname);
|
|
547
|
+
} else {
|
|
548
|
+
const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
|
|
549
|
+
this.#instance.replace(pathname);
|
|
550
|
+
}
|
|
551
|
+
return void 0;
|
|
552
|
+
}
|
|
553
|
+
notFound() {
|
|
554
|
+
this.#checkInitialized();
|
|
555
|
+
if (baseClientEnv.side === "server") {
|
|
556
|
+
Logger.log(`redirect to:/404`);
|
|
557
|
+
(0, import_navigation.notFound)();
|
|
558
|
+
} else
|
|
559
|
+
this.#instance.replace("/404");
|
|
560
|
+
return void 0;
|
|
561
|
+
}
|
|
562
|
+
setLang(lang) {
|
|
563
|
+
if (baseClientEnv.side === "server")
|
|
564
|
+
throw new Error("setLang is only available in client side");
|
|
565
|
+
this.#checkInitialized();
|
|
566
|
+
const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
|
|
567
|
+
this.#lang = lang;
|
|
568
|
+
this.#instance.replace(`/${lang}${path}`);
|
|
569
|
+
return void 0;
|
|
570
|
+
}
|
|
571
|
+
getPath(pathname = window.location.pathname) {
|
|
572
|
+
if (baseClientEnv.side === "server")
|
|
573
|
+
throw new Error("getPath is only available in client side");
|
|
574
|
+
const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
|
|
575
|
+
return path;
|
|
576
|
+
}
|
|
577
|
+
getFullPath(withLang = true) {
|
|
578
|
+
if (baseClientEnv.side === "server")
|
|
579
|
+
throw new Error("getPath is only available in client side");
|
|
580
|
+
return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
|
|
581
|
+
}
|
|
582
|
+
getPrefix() {
|
|
583
|
+
return this.#prefix;
|
|
584
|
+
}
|
|
585
|
+
getPrefixedPath(path) {
|
|
586
|
+
return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
var router = new Router();
|
|
590
|
+
|
|
591
|
+
// pkgs/@akanjs/signal/src/client.ts
|
|
592
|
+
var import_core = __require("@urql/core");
|
|
593
|
+
var import_socket = __require("socket.io-client");
|
|
594
|
+
var SocketIo = class {
|
|
595
|
+
socket;
|
|
596
|
+
roomSubscribeMap = /* @__PURE__ */ new Map();
|
|
597
|
+
constructor(uri) {
|
|
598
|
+
this.socket = (0, import_socket.io)(uri, { transports: ["websocket"] });
|
|
599
|
+
this.socket.on("connect", () => {
|
|
600
|
+
this.roomSubscribeMap.forEach((option) => {
|
|
601
|
+
this.socket.emit(option.key, { ...option.message, __subscribe__: true });
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
on(event, callback) {
|
|
606
|
+
this.socket.on(event, callback);
|
|
607
|
+
}
|
|
608
|
+
removeListener(event, callback) {
|
|
609
|
+
this.socket.removeListener(event, callback);
|
|
610
|
+
}
|
|
611
|
+
removeAllListeners() {
|
|
612
|
+
this.socket.removeAllListeners();
|
|
613
|
+
}
|
|
614
|
+
hasListeners(event) {
|
|
615
|
+
return this.socket.hasListeners(event);
|
|
616
|
+
}
|
|
617
|
+
emit(key, data) {
|
|
618
|
+
this.socket.emit(key, data);
|
|
619
|
+
}
|
|
620
|
+
subscribe(option) {
|
|
621
|
+
if (!this.roomSubscribeMap.has(option.roomId)) {
|
|
622
|
+
this.roomSubscribeMap.set(option.roomId, option);
|
|
623
|
+
this.socket.emit(option.key, { ...option.message, __subscribe__: true });
|
|
624
|
+
}
|
|
625
|
+
this.socket.on(option.roomId, option.handleEvent);
|
|
626
|
+
}
|
|
627
|
+
unsubscribe(roomId, handleEvent) {
|
|
628
|
+
this.socket.removeListener(roomId, handleEvent);
|
|
629
|
+
const option = this.roomSubscribeMap.get(roomId);
|
|
630
|
+
if (this.hasListeners(roomId) || !option)
|
|
631
|
+
return;
|
|
632
|
+
this.roomSubscribeMap.delete(roomId);
|
|
633
|
+
this.socket.emit(option.key, { ...option.message, __subscribe__: false });
|
|
634
|
+
}
|
|
635
|
+
disconnect() {
|
|
636
|
+
this.socket.disconnect();
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
var Client = class _Client {
|
|
641
|
+
static globalIoMap = /* @__PURE__ */ new Map();
|
|
642
|
+
static tokenStore = /* @__PURE__ */ new Map();
|
|
643
|
+
async waitUntilWebSocketConnected(ws = baseClientEnv.serverWsUri) {
|
|
644
|
+
if (baseClientEnv.side === "server")
|
|
645
|
+
return true;
|
|
646
|
+
while (!this.getIo(ws).socket.connected) {
|
|
647
|
+
Logger.verbose("waiting for websocket to initialize...");
|
|
648
|
+
await sleep(300);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
isInitialized = false;
|
|
652
|
+
uri = baseClientEnv.serverGraphqlUri;
|
|
653
|
+
ws = baseClientEnv.serverWsUri;
|
|
654
|
+
udp = null;
|
|
655
|
+
gql = (0, import_core.createClient)({ url: this.uri, fetch, exchanges: [import_core.cacheExchange, import_core.fetchExchange] });
|
|
656
|
+
jwt = null;
|
|
657
|
+
async getJwt() {
|
|
658
|
+
const isNextServer = baseClientEnv.side === "server" && baseEnv.operationType === "client";
|
|
659
|
+
if (isNextServer) {
|
|
660
|
+
const nextHeaders = __require("next/headers");
|
|
661
|
+
return (await nextHeaders.cookies?.())?.get("jwt")?.value ?? (await nextHeaders.headers?.())?.get("jwt") ?? this.jwt ?? null;
|
|
662
|
+
} else
|
|
663
|
+
return _Client.tokenStore.get(this) ?? null;
|
|
664
|
+
}
|
|
665
|
+
io = null;
|
|
666
|
+
init(data = {}) {
|
|
667
|
+
Object.assign(this, data);
|
|
668
|
+
this.setLink(data.uri);
|
|
669
|
+
this.setIo(data.ws);
|
|
670
|
+
this.isInitialized = true;
|
|
671
|
+
}
|
|
672
|
+
setIo(ws = baseClientEnv.serverWsUri) {
|
|
673
|
+
this.ws = ws;
|
|
674
|
+
const existingIo = _Client.globalIoMap.get(ws);
|
|
675
|
+
if (existingIo) {
|
|
676
|
+
this.io = existingIo;
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
this.io = new SocketIo(ws);
|
|
680
|
+
_Client.globalIoMap.set(ws, this.io);
|
|
681
|
+
}
|
|
682
|
+
getIo(ws = baseClientEnv.serverWsUri) {
|
|
683
|
+
const existingIo = _Client.globalIoMap.get(ws);
|
|
684
|
+
if (existingIo)
|
|
685
|
+
return existingIo;
|
|
686
|
+
const io2 = new SocketIo(ws);
|
|
687
|
+
_Client.globalIoMap.set(ws, io2);
|
|
688
|
+
return io2;
|
|
689
|
+
}
|
|
690
|
+
setLink(uri = baseClientEnv.serverGraphqlUri) {
|
|
691
|
+
this.uri = uri;
|
|
692
|
+
this.gql = (0, import_core.createClient)({
|
|
693
|
+
url: this.uri,
|
|
694
|
+
fetch,
|
|
695
|
+
exchanges: [import_core.cacheExchange, import_core.fetchExchange],
|
|
696
|
+
// requestPolicy: "network-only",
|
|
697
|
+
fetchOptions: () => {
|
|
698
|
+
return {
|
|
699
|
+
headers: {
|
|
700
|
+
"apollo-require-preflight": "true",
|
|
701
|
+
...this.jwt ? { authorization: `Bearer ${this.jwt}` } : {}
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
setJwt(jwt) {
|
|
708
|
+
_Client.tokenStore.set(this, jwt);
|
|
709
|
+
}
|
|
710
|
+
reset() {
|
|
711
|
+
this.io?.disconnect();
|
|
712
|
+
this.io = null;
|
|
713
|
+
this.jwt = null;
|
|
714
|
+
}
|
|
715
|
+
clone(data = {}) {
|
|
716
|
+
const newClient = new _Client();
|
|
717
|
+
newClient.init({ ...this, ...data });
|
|
718
|
+
if (data.jwt)
|
|
719
|
+
_Client.tokenStore.set(newClient, data.jwt);
|
|
720
|
+
return newClient;
|
|
721
|
+
}
|
|
722
|
+
terminate() {
|
|
723
|
+
this.reset();
|
|
724
|
+
_Client.globalIoMap.forEach((io2) => io2.disconnect());
|
|
725
|
+
this.isInitialized = false;
|
|
726
|
+
}
|
|
727
|
+
setUdp(udp) {
|
|
728
|
+
this.udp = udp;
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var client = new Client();
|
|
732
|
+
|
|
733
|
+
// pkgs/@akanjs/constant/src/scalar.ts
|
|
734
|
+
var import_reflect_metadata = __require("reflect-metadata");
|
|
735
|
+
var scalarExampleMap = /* @__PURE__ */ new Map([
|
|
736
|
+
[ID, "1234567890abcdef12345678"],
|
|
737
|
+
[Int, 0],
|
|
738
|
+
[Float, 0],
|
|
739
|
+
[String, "String"],
|
|
740
|
+
[Boolean, true],
|
|
741
|
+
[Date, (/* @__PURE__ */ new Date()).toISOString()],
|
|
742
|
+
[Upload, "FileUpload"],
|
|
743
|
+
[JSON2, {}],
|
|
744
|
+
[Map, {}]
|
|
745
|
+
]);
|
|
746
|
+
var getClassMeta = (modelRef) => {
|
|
747
|
+
const [target] = getNonArrayModel(modelRef);
|
|
748
|
+
const classMeta = Reflect.getMetadata("class", target.prototype);
|
|
749
|
+
if (!classMeta)
|
|
750
|
+
throw new Error(`No ClassMeta for this target ${target.name}`);
|
|
751
|
+
return classMeta;
|
|
752
|
+
};
|
|
753
|
+
var getFieldMetas = (modelRef) => {
|
|
754
|
+
const [target] = getNonArrayModel(modelRef);
|
|
755
|
+
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
756
|
+
const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
|
|
757
|
+
return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
|
|
758
|
+
};
|
|
759
|
+
var getFieldMetaMapOnPrototype = (prototype) => {
|
|
760
|
+
const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
|
|
761
|
+
return new Map(metadataMap);
|
|
762
|
+
};
|
|
763
|
+
var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
764
|
+
Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
// pkgs/@akanjs/constant/src/fieldMeta.ts
|
|
768
|
+
var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
|
|
769
|
+
const isArray = arrDepth > 0;
|
|
770
|
+
const isClass = !isGqlScalar(modelRef);
|
|
771
|
+
const isMap = isGqlMap(modelRef);
|
|
772
|
+
const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
|
|
773
|
+
const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
|
|
774
|
+
if (isMap && !option.of)
|
|
775
|
+
throw new Error("Map type must have 'of' option");
|
|
776
|
+
return (prototype, key) => {
|
|
777
|
+
const metadata = {
|
|
778
|
+
nullable: option.nullable ?? false,
|
|
779
|
+
ref: option.ref,
|
|
780
|
+
refPath: option.refPath,
|
|
781
|
+
refType: option.refType,
|
|
782
|
+
default: option.default ?? (isArray ? [] : null),
|
|
783
|
+
type: option.type,
|
|
784
|
+
fieldType: option.fieldType ?? "property",
|
|
785
|
+
immutable: option.immutable ?? false,
|
|
786
|
+
min: option.min,
|
|
787
|
+
max: option.max,
|
|
788
|
+
enum: option.enum,
|
|
789
|
+
select: option.select ?? true,
|
|
790
|
+
minlength: option.minlength,
|
|
791
|
+
maxlength: option.maxlength,
|
|
792
|
+
query: option.query,
|
|
793
|
+
accumulate: option.accumulate,
|
|
794
|
+
example: option.example,
|
|
795
|
+
validate: option.validate,
|
|
796
|
+
key,
|
|
797
|
+
name,
|
|
798
|
+
isClass,
|
|
799
|
+
isScalar: type === "scalar",
|
|
800
|
+
modelRef,
|
|
801
|
+
arrDepth,
|
|
802
|
+
isArray,
|
|
803
|
+
optArrDepth: optionArrDepth,
|
|
804
|
+
isMap,
|
|
805
|
+
of: option.of,
|
|
806
|
+
text: option.text
|
|
807
|
+
};
|
|
808
|
+
const metadataMap = getFieldMetaMapOnPrototype(prototype);
|
|
809
|
+
metadataMap.set(key, metadata);
|
|
810
|
+
setFieldMetaMapOnPrototype(prototype, metadataMap);
|
|
811
|
+
};
|
|
812
|
+
};
|
|
813
|
+
var makeField = (customOption) => (returns, fieldOption) => {
|
|
814
|
+
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
815
|
+
if (!fieldOption)
|
|
816
|
+
return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
|
|
817
|
+
const [opt, optArrDepth] = getNonArrayModel(fieldOption);
|
|
818
|
+
return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
|
|
819
|
+
};
|
|
820
|
+
var Field = {
|
|
821
|
+
Prop: makeField({ fieldType: "property" }),
|
|
822
|
+
Hidden: makeField({ fieldType: "hidden", nullable: true }),
|
|
823
|
+
Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
|
|
824
|
+
Resolve: makeField({ fieldType: "resolve" })
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// pkgs/@akanjs/constant/src/constantDecorator.ts
|
|
828
|
+
var import_reflect_metadata2 = __require("reflect-metadata");
|
|
829
|
+
|
|
830
|
+
// pkgs/@akanjs/constant/src/filterMeta.ts
|
|
831
|
+
var setFilterMeta = (filterRef, filterMeta) => {
|
|
832
|
+
const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
833
|
+
if (existingFilterMeta)
|
|
834
|
+
Object.assign(filterMeta.sort, existingFilterMeta.sort);
|
|
835
|
+
Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
|
|
836
|
+
};
|
|
837
|
+
var getFilterKeyMetaMapOnPrototype = (prototype) => {
|
|
838
|
+
const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
|
|
839
|
+
return new Map(metadataMap);
|
|
840
|
+
};
|
|
841
|
+
var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
842
|
+
Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
|
|
843
|
+
};
|
|
844
|
+
var applyFilterKeyMeta = (option) => {
|
|
845
|
+
return (prototype, key, descriptor) => {
|
|
846
|
+
const metadata = { key, ...option, descriptor };
|
|
847
|
+
const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
|
|
848
|
+
metadataMap.set(key, metadata);
|
|
849
|
+
setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
var makeFilter = (customOption) => (fieldOption) => {
|
|
853
|
+
return applyFilterKeyMeta({ ...customOption, ...fieldOption });
|
|
854
|
+
};
|
|
855
|
+
var getFilterArgMetasOnPrototype = (prototype, key) => {
|
|
856
|
+
const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
|
|
857
|
+
return filterArgMetas;
|
|
858
|
+
};
|
|
859
|
+
var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
|
|
860
|
+
Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
|
|
861
|
+
};
|
|
862
|
+
var applyFilterArgMeta = (name, returns, argOption) => {
|
|
863
|
+
return (prototype, key, idx) => {
|
|
864
|
+
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
865
|
+
const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
|
|
866
|
+
const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
|
|
867
|
+
const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
|
|
868
|
+
filterArgMetas[idx] = filterArgMeta;
|
|
869
|
+
setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
var Filter = {
|
|
873
|
+
Mongo: makeFilter({ type: "mongo" }),
|
|
874
|
+
// Meili: makeFilter({ fieldType: "hidden", nullable: true }),
|
|
875
|
+
Arg: applyFilterArgMeta
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// pkgs/@akanjs/constant/src/baseGql.ts
|
|
879
|
+
var import_reflect_metadata3 = __require("reflect-metadata");
|
|
880
|
+
var defaultFieldMeta = {
|
|
881
|
+
fieldType: "property",
|
|
882
|
+
immutable: false,
|
|
883
|
+
select: true,
|
|
884
|
+
isClass: false,
|
|
885
|
+
isScalar: true,
|
|
886
|
+
nullable: false,
|
|
887
|
+
isArray: false,
|
|
888
|
+
arrDepth: 0,
|
|
889
|
+
optArrDepth: 0,
|
|
890
|
+
default: null,
|
|
891
|
+
isMap: false
|
|
892
|
+
};
|
|
893
|
+
var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
|
|
894
|
+
var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
|
|
895
|
+
var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
|
|
896
|
+
var removedAtFieldMeta = {
|
|
897
|
+
...defaultFieldMeta,
|
|
898
|
+
key: "removedAt",
|
|
899
|
+
name: "Date",
|
|
900
|
+
modelRef: Date,
|
|
901
|
+
nullable: true,
|
|
902
|
+
default: null
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
// pkgs/@akanjs/constant/src/classMeta.ts
|
|
906
|
+
var import_reflect_metadata4 = __require("reflect-metadata");
|
|
907
|
+
var InputModelStorage = class {
|
|
908
|
+
};
|
|
909
|
+
var LightModelStorage = class {
|
|
910
|
+
};
|
|
911
|
+
var FullModelStorage = class {
|
|
912
|
+
};
|
|
913
|
+
var ScalarModelStorage = class {
|
|
914
|
+
};
|
|
915
|
+
var FilterModelStorage = class {
|
|
916
|
+
};
|
|
917
|
+
var hasTextField = (modelRef) => {
|
|
918
|
+
const fieldMetas = getFieldMetas(modelRef);
|
|
919
|
+
return fieldMetas.some(
|
|
920
|
+
(fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
|
|
921
|
+
);
|
|
922
|
+
};
|
|
923
|
+
var applyClassMeta = (type, modelType, storage2) => {
|
|
924
|
+
return function(refName) {
|
|
925
|
+
return function(target) {
|
|
926
|
+
const modelRef = target;
|
|
927
|
+
const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
|
|
928
|
+
Reflect.defineMetadata("class", classMeta, modelRef.prototype);
|
|
929
|
+
Reflect.defineMetadata(refName, modelRef, storage2.prototype);
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
};
|
|
933
|
+
var applyFilterMeta = (storage2) => {
|
|
934
|
+
return function(refName) {
|
|
935
|
+
return function(target) {
|
|
936
|
+
const modelRef = target;
|
|
937
|
+
setFilterMeta(modelRef, { refName, sort: {} });
|
|
938
|
+
Reflect.defineMetadata(refName, modelRef, storage2.prototype);
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
var Model = {
|
|
943
|
+
Light: applyClassMeta("light", "data", LightModelStorage),
|
|
944
|
+
Object: applyClassMeta("full", "ephemeral", FullModelStorage),
|
|
945
|
+
Full: applyClassMeta("full", "data", FullModelStorage),
|
|
946
|
+
Input: applyClassMeta("input", "data", InputModelStorage),
|
|
947
|
+
Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
|
|
948
|
+
Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
|
|
949
|
+
Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
|
|
950
|
+
Filter: applyFilterMeta(FilterModelStorage)
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// pkgs/@akanjs/signal/src/immerify.ts
|
|
954
|
+
var import_immer = __require("immer");
|
|
955
|
+
|
|
956
|
+
// pkgs/@akanjs/signal/src/signalDecorators.ts
|
|
957
|
+
var import_reflect_metadata5 = __require("reflect-metadata");
|
|
958
|
+
var createArgMetaDecorator = (type) => {
|
|
959
|
+
return function(option = {}) {
|
|
960
|
+
return function(prototype, key, idx) {
|
|
961
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
962
|
+
argMetas[idx] = { key, idx, type, option };
|
|
963
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
964
|
+
};
|
|
965
|
+
};
|
|
966
|
+
};
|
|
967
|
+
var Account = createArgMetaDecorator("Account");
|
|
968
|
+
var defaultAccount = {
|
|
969
|
+
__InternalArg__: "Account",
|
|
970
|
+
appName: baseEnv.appName,
|
|
971
|
+
environment: baseEnv.environment
|
|
972
|
+
};
|
|
973
|
+
var Self = createArgMetaDecorator("Self");
|
|
974
|
+
var Me = createArgMetaDecorator("Me");
|
|
975
|
+
var UserIp = createArgMetaDecorator("UserIp");
|
|
976
|
+
var Access = createArgMetaDecorator("Access");
|
|
977
|
+
var Req = createArgMetaDecorator("Req");
|
|
978
|
+
var Res = createArgMetaDecorator("Res");
|
|
979
|
+
var Ws = createArgMetaDecorator("Ws");
|
|
980
|
+
var Job = createArgMetaDecorator("Job");
|
|
981
|
+
var getQuery = (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: "Query"
|
|
991
|
+
});
|
|
992
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
var getMutation = (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: "Mutation"
|
|
1005
|
+
});
|
|
1006
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
var getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
1010
|
+
return (prototype, key, descriptor) => {
|
|
1011
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1012
|
+
metadataMap.set(key, {
|
|
1013
|
+
returns,
|
|
1014
|
+
signalOption,
|
|
1015
|
+
key,
|
|
1016
|
+
descriptor,
|
|
1017
|
+
guards: [allow, ...guards],
|
|
1018
|
+
type: "Message"
|
|
1019
|
+
});
|
|
1020
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
var getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
1024
|
+
return (prototype, key, descriptor) => {
|
|
1025
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1026
|
+
metadataMap.set(key, {
|
|
1027
|
+
returns,
|
|
1028
|
+
signalOption,
|
|
1029
|
+
key,
|
|
1030
|
+
descriptor,
|
|
1031
|
+
guards: [allow, ...guards],
|
|
1032
|
+
type: "Pubsub"
|
|
1033
|
+
});
|
|
1034
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
var getProcess = (serverType) => function(returns, signalOption = {}) {
|
|
1038
|
+
return (prototype, key, descriptor) => {
|
|
1039
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1040
|
+
metadataMap.set(key, {
|
|
1041
|
+
returns,
|
|
1042
|
+
signalOption: { ...signalOption, serverType: lowerlize(serverType) },
|
|
1043
|
+
key,
|
|
1044
|
+
descriptor,
|
|
1045
|
+
guards: ["None"],
|
|
1046
|
+
type: "Process"
|
|
1047
|
+
});
|
|
1048
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
var Query = {
|
|
1052
|
+
Public: getQuery("Public"),
|
|
1053
|
+
Every: getQuery("Every"),
|
|
1054
|
+
Admin: getQuery("Admin"),
|
|
1055
|
+
User: getQuery("User"),
|
|
1056
|
+
SuperAdmin: getQuery("SuperAdmin"),
|
|
1057
|
+
None: getQuery("None"),
|
|
1058
|
+
Owner: getQuery("Owner")
|
|
1059
|
+
};
|
|
1060
|
+
var Mutation = {
|
|
1061
|
+
Public: getMutation("Public"),
|
|
1062
|
+
Every: getMutation("Every"),
|
|
1063
|
+
Admin: getMutation("Admin"),
|
|
1064
|
+
User: getMutation("User"),
|
|
1065
|
+
SuperAdmin: getMutation("SuperAdmin"),
|
|
1066
|
+
None: getMutation("None"),
|
|
1067
|
+
Owner: getMutation("Owner")
|
|
1068
|
+
};
|
|
1069
|
+
var Message = {
|
|
1070
|
+
Public: getMessage("Public"),
|
|
1071
|
+
Every: getMessage("Every"),
|
|
1072
|
+
Admin: getMessage("Admin"),
|
|
1073
|
+
User: getMessage("User"),
|
|
1074
|
+
SuperAdmin: getMessage("SuperAdmin"),
|
|
1075
|
+
None: getMessage("None"),
|
|
1076
|
+
Owner: getMessage("Owner")
|
|
1077
|
+
};
|
|
1078
|
+
var Pubsub = {
|
|
1079
|
+
Public: getPubsub("Public"),
|
|
1080
|
+
Every: getPubsub("Every"),
|
|
1081
|
+
Admin: getPubsub("Admin"),
|
|
1082
|
+
User: getPubsub("User"),
|
|
1083
|
+
SuperAdmin: getPubsub("SuperAdmin"),
|
|
1084
|
+
None: getPubsub("None"),
|
|
1085
|
+
Owner: getPubsub("Owner")
|
|
1086
|
+
};
|
|
1087
|
+
var Process = {
|
|
1088
|
+
Federation: getProcess("Federation"),
|
|
1089
|
+
Batch: getProcess("Batch"),
|
|
1090
|
+
All: getProcess("All")
|
|
1091
|
+
};
|
|
1092
|
+
var getArg = (type) => function(name, returns, argsOption = {}) {
|
|
1093
|
+
return function(prototype, key, idx) {
|
|
1094
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
1095
|
+
argMetas[idx] = { name, returns, argsOption, key, idx, type };
|
|
1096
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
1099
|
+
var Arg = {
|
|
1100
|
+
Body: getArg("Body"),
|
|
1101
|
+
Param: getArg("Param"),
|
|
1102
|
+
Query: getArg("Query"),
|
|
1103
|
+
Upload: getArg("Upload"),
|
|
1104
|
+
Msg: getArg("Msg"),
|
|
1105
|
+
Room: getArg("Room")
|
|
1106
|
+
};
|
|
1107
|
+
var getGqlMetaMapOnPrototype = (prototype) => {
|
|
1108
|
+
const gqlMetaMap = Reflect.getMetadata("gql", prototype);
|
|
1109
|
+
return gqlMetaMap ?? /* @__PURE__ */ new Map();
|
|
1110
|
+
};
|
|
1111
|
+
var setGqlMetaMapOnPrototype = (prototype, gqlMetaMap) => {
|
|
1112
|
+
Reflect.defineMetadata("gql", gqlMetaMap, prototype);
|
|
1113
|
+
};
|
|
1114
|
+
var getArgMetasOnPrototype = (prototype, key) => {
|
|
1115
|
+
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
1116
|
+
};
|
|
1117
|
+
var setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
1118
|
+
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
// pkgs/@akanjs/signal/src/baseFetch.ts
|
|
1122
|
+
var nativeFetch = fetch;
|
|
1123
|
+
var baseFetch = Object.assign(nativeFetch, {
|
|
1124
|
+
client,
|
|
1125
|
+
clone: function(option = {}) {
|
|
1126
|
+
return {
|
|
1127
|
+
...this,
|
|
1128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
1129
|
+
client: this.client.clone(option)
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
// pkgs/@akanjs/client/src/cookie.ts
|
|
1135
|
+
var import_core2 = __require("@capacitor/core");
|
|
1136
|
+
var import_js_cookie = __toESM(__require("js-cookie"));
|
|
1137
|
+
var import_jwt_decode = __require("jwt-decode");
|
|
1138
|
+
var import_react3 = __toESM(__require("react"));
|
|
1139
|
+
|
|
1140
|
+
// pkgs/@akanjs/client/src/storage.ts
|
|
1141
|
+
var import_preferences = __require("@capacitor/preferences");
|
|
1142
|
+
var storage = {
|
|
1143
|
+
getItem: async (key) => {
|
|
1144
|
+
if (baseClientEnv.side === "server")
|
|
1145
|
+
return;
|
|
1146
|
+
if (baseClientEnv.renderMode === "ssr")
|
|
1147
|
+
return localStorage.getItem(key);
|
|
1148
|
+
else
|
|
1149
|
+
return (await import_preferences.Preferences.get({ key })).value;
|
|
1150
|
+
},
|
|
1151
|
+
setItem: async (key, value) => {
|
|
1152
|
+
if (baseClientEnv.side === "server")
|
|
1153
|
+
return;
|
|
1154
|
+
if (baseClientEnv.renderMode === "ssr") {
|
|
1155
|
+
localStorage.setItem(key, value);
|
|
1156
|
+
return;
|
|
1157
|
+
} else {
|
|
1158
|
+
await import_preferences.Preferences.set({ key, value });
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
removeItem: (key) => {
|
|
1163
|
+
if (baseClientEnv.side === "server")
|
|
1164
|
+
return;
|
|
1165
|
+
if (baseClientEnv.renderMode === "ssr") {
|
|
1166
|
+
localStorage.removeItem(key);
|
|
1167
|
+
return;
|
|
1168
|
+
} else
|
|
1169
|
+
return import_preferences.Preferences.remove({ key });
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
// pkgs/@akanjs/client/src/cookie.ts
|
|
1174
|
+
var cookies = baseClientEnv.side === "server" ? () => {
|
|
1175
|
+
const nextHeaders = __require("next/headers");
|
|
1176
|
+
const cookies2 = nextHeaders.cookies();
|
|
1177
|
+
return import_react3.default.use(cookies2);
|
|
1178
|
+
} : () => {
|
|
1179
|
+
const cookie = import_js_cookie.default.get();
|
|
1180
|
+
return new Map(
|
|
1181
|
+
Object.entries(cookie).map(([key, value]) => [
|
|
1182
|
+
key,
|
|
1183
|
+
{
|
|
1184
|
+
name: key,
|
|
1185
|
+
value: typeof value === "string" && value.startsWith("j:") ? JSON.parse(value.slice(2)) : value
|
|
1186
|
+
}
|
|
1187
|
+
])
|
|
1188
|
+
);
|
|
1189
|
+
};
|
|
1190
|
+
var setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
|
|
1191
|
+
if (baseClientEnv.side === "server")
|
|
1192
|
+
return;
|
|
1193
|
+
else
|
|
1194
|
+
void import_core2.CapacitorCookies.setCookie({ key, value });
|
|
1195
|
+
};
|
|
1196
|
+
var headers = baseClientEnv.side === "server" ? () => import_react3.default.use(__require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
|
|
1197
|
+
var getHeader = (key) => {
|
|
1198
|
+
return headers().get(key);
|
|
1199
|
+
};
|
|
1200
|
+
var setAuth = ({ jwt }) => {
|
|
1201
|
+
client.setJwt(jwt);
|
|
1202
|
+
setCookie("jwt", jwt);
|
|
1203
|
+
void storage.setItem("jwt", jwt);
|
|
1204
|
+
};
|
|
1205
|
+
var initAuth = ({ jwt } = {}) => {
|
|
1206
|
+
const token = jwt ?? cookies().get("jwt")?.value;
|
|
1207
|
+
if (token)
|
|
1208
|
+
setAuth({ jwt: token });
|
|
1209
|
+
client.init();
|
|
1210
|
+
Logger.verbose(`JWT set from cookie: ${token}`);
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// pkgs/@akanjs/client/src/device.ts
|
|
1214
|
+
var import_device = __require("@capacitor/device");
|
|
1215
|
+
var import_haptics = __require("@capacitor/haptics");
|
|
1216
|
+
var import_keyboard = __require("@capacitor/keyboard");
|
|
1217
|
+
var import_capacitor_plugin_safe_area = __require("capacitor-plugin-safe-area");
|
|
1218
|
+
var import_react_device_detect = __require("react-device-detect");
|
|
1219
|
+
var Device = class {
|
|
1220
|
+
info;
|
|
1221
|
+
lang;
|
|
1222
|
+
topSafeArea;
|
|
1223
|
+
bottomSafeArea;
|
|
1224
|
+
isMobile = import_react_device_detect.isMobile;
|
|
1225
|
+
#keyboard = import_keyboard.Keyboard;
|
|
1226
|
+
#haptics = import_haptics.Haptics;
|
|
1227
|
+
#pageContentRef = null;
|
|
1228
|
+
async init({ lang, supportLanguages: supportLanguages2 = [] } = {}) {
|
|
1229
|
+
const [
|
|
1230
|
+
info,
|
|
1231
|
+
{ value: languageCode },
|
|
1232
|
+
{
|
|
1233
|
+
insets: { top: topSafeArea, bottom: bottomSafeArea }
|
|
1234
|
+
}
|
|
1235
|
+
] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
|
|
1236
|
+
const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
|
|
1237
|
+
const predefinedLang = supportLanguages2.find((language) => language === predefinedLangPath);
|
|
1238
|
+
this.info = info;
|
|
1239
|
+
this.lang = lang ?? predefinedLang ?? languageCode;
|
|
1240
|
+
this.topSafeArea = topSafeArea;
|
|
1241
|
+
this.bottomSafeArea = bottomSafeArea;
|
|
1242
|
+
}
|
|
1243
|
+
setPageContentRef(pageContentRef) {
|
|
1244
|
+
this.#pageContentRef = pageContentRef;
|
|
1245
|
+
}
|
|
1246
|
+
async showKeyboard() {
|
|
1247
|
+
if (this.info.platform === "web")
|
|
1248
|
+
return;
|
|
1249
|
+
await this.#keyboard.show();
|
|
1250
|
+
}
|
|
1251
|
+
async hideKeyboard() {
|
|
1252
|
+
if (this.info.platform === "web")
|
|
1253
|
+
return;
|
|
1254
|
+
await this.#keyboard.hide();
|
|
1255
|
+
}
|
|
1256
|
+
listenKeyboardChanged(onKeyboardChanged) {
|
|
1257
|
+
if (this.info.platform === "web")
|
|
1258
|
+
return;
|
|
1259
|
+
void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
|
|
1260
|
+
onKeyboardChanged(keyboard.keyboardHeight);
|
|
1261
|
+
});
|
|
1262
|
+
void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
|
|
1263
|
+
onKeyboardChanged(keyboard.keyboardHeight);
|
|
1264
|
+
});
|
|
1265
|
+
void this.#keyboard.addListener("keyboardWillHide", () => {
|
|
1266
|
+
onKeyboardChanged(0);
|
|
1267
|
+
});
|
|
1268
|
+
void this.#keyboard.addListener("keyboardDidHide", () => {
|
|
1269
|
+
onKeyboardChanged(0);
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
unlistenKeyboardChanged() {
|
|
1273
|
+
if (this.info.platform === "web")
|
|
1274
|
+
return;
|
|
1275
|
+
void this.#keyboard.removeAllListeners();
|
|
1276
|
+
}
|
|
1277
|
+
async vibrate(type = "medium") {
|
|
1278
|
+
if (typeof type === "number") {
|
|
1279
|
+
await this.#haptics.vibrate({ duration: type });
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
const handleImpact = {
|
|
1283
|
+
light: async () => {
|
|
1284
|
+
await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
|
|
1285
|
+
},
|
|
1286
|
+
medium: async () => {
|
|
1287
|
+
await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
|
|
1288
|
+
},
|
|
1289
|
+
heavy: async () => {
|
|
1290
|
+
await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
|
|
1291
|
+
},
|
|
1292
|
+
selectionStart: async () => {
|
|
1293
|
+
await this.#haptics.selectionStart();
|
|
1294
|
+
},
|
|
1295
|
+
selectionChanged: async () => {
|
|
1296
|
+
await this.#haptics.selectionChanged();
|
|
1297
|
+
},
|
|
1298
|
+
selectionEnd: async () => {
|
|
1299
|
+
await this.#haptics.selectionEnd();
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
await handleImpact[type]();
|
|
1303
|
+
}
|
|
1304
|
+
getScrollTop() {
|
|
1305
|
+
if (this.info.platform === "web")
|
|
1306
|
+
return window.scrollY;
|
|
1307
|
+
return this.#pageContentRef?.current?.scrollTop ?? 0;
|
|
1308
|
+
}
|
|
1309
|
+
setScrollTop(scrollTop) {
|
|
1310
|
+
if (this.info.platform === "web") {
|
|
1311
|
+
window.scrollTo({ top: scrollTop });
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
var device = new Device();
|
|
1318
|
+
|
|
1319
|
+
// pkgs/@akanjs/next/src/makePageProto.tsx
|
|
1320
|
+
var getPageInfo = () => {
|
|
1321
|
+
if (baseClientEnv.side !== "server") {
|
|
1322
|
+
return {
|
|
1323
|
+
locale: window.location.pathname.split("/")[1] ?? "en",
|
|
1324
|
+
path: "/" + window.location.pathname.split("/").slice(2).join("/")
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const locale = getHeader("x-locale") ?? "en";
|
|
1328
|
+
const path = getHeader("x-path") ?? "/";
|
|
1329
|
+
return { locale, path };
|
|
1330
|
+
};
|
|
1331
|
+
var langIdx = { en: 0, ko: 1, zhChs: 2, zhCht: 3 };
|
|
1332
|
+
var dictionary = {};
|
|
1333
|
+
var translator = (lang, key, param) => {
|
|
1334
|
+
const idx = langIdx[lang];
|
|
1335
|
+
try {
|
|
1336
|
+
const msg = pathGet(key, dictionary)?.[idx];
|
|
1337
|
+
if (!msg) {
|
|
1338
|
+
Logger.error(`No translation for ${key}`);
|
|
1339
|
+
return key;
|
|
1340
|
+
}
|
|
1341
|
+
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
1342
|
+
} catch (e) {
|
|
1343
|
+
return key;
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
translator.rich = (lang, key, param) => {
|
|
1347
|
+
const idx = langIdx[lang];
|
|
1348
|
+
const msg = pathGet(key, dictionary)?.[idx];
|
|
1349
|
+
if (!msg) {
|
|
1350
|
+
Logger.error(`No translation for ${key}`);
|
|
1351
|
+
return key;
|
|
1352
|
+
}
|
|
1353
|
+
return param ? msg.replace(/{([^}]+)}/g, (_, key2) => param[key2]) : msg;
|
|
1354
|
+
};
|
|
1355
|
+
var makePageProto = (locales) => {
|
|
1356
|
+
locales.forEach((locale) => {
|
|
1357
|
+
Object.keys(locale).forEach((key) => dictionary[key] = Object.assign(dictionary[key] ?? {}, locale[key]));
|
|
1358
|
+
});
|
|
1359
|
+
return () => {
|
|
1360
|
+
const { locale, path } = getPageInfo();
|
|
1361
|
+
const lang = locale;
|
|
1362
|
+
const l = (key, param) => translator(lang, key, param);
|
|
1363
|
+
l.rich = (key, param) => /* @__PURE__ */ React.createElement(
|
|
1364
|
+
"span",
|
|
1365
|
+
{
|
|
1366
|
+
dangerouslySetInnerHTML: {
|
|
1367
|
+
__html: translator.rich(lang, key, {
|
|
1368
|
+
...param,
|
|
1369
|
+
// strong: (chunks: string) => `<b>${chunks}</b>`,
|
|
1370
|
+
// "bg-primary": (chunks: string) => `<span className="bg-primary text-base-100">${chunks}</span>`,
|
|
1371
|
+
// primary: (chunks: string) => `<span className="bg-base-100 text-primary">${chunks}</span>`,
|
|
1372
|
+
br: `<br />`
|
|
1373
|
+
})
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
l.field = (model, field) => {
|
|
1378
|
+
const key = `${model}.${field}`;
|
|
1379
|
+
return l(key);
|
|
1380
|
+
};
|
|
1381
|
+
l.desc = (model, field) => {
|
|
1382
|
+
const key = `${model}.desc-${field}`;
|
|
1383
|
+
return l(key);
|
|
1384
|
+
};
|
|
1385
|
+
l.enum = (model, field, value) => {
|
|
1386
|
+
const key = `${model}.enum-${field}-${value}`;
|
|
1387
|
+
return l(key);
|
|
1388
|
+
};
|
|
1389
|
+
l.enumdesc = (model, field, value) => {
|
|
1390
|
+
const key = `${model}.enumdesc-${field}-${value}`;
|
|
1391
|
+
return l(key);
|
|
1392
|
+
};
|
|
1393
|
+
l.api = (model, endpoint) => {
|
|
1394
|
+
const key = `${model}.api-${endpoint}`;
|
|
1395
|
+
return l(key);
|
|
1396
|
+
};
|
|
1397
|
+
l.apidesc = (model, endpoint) => {
|
|
1398
|
+
const key = `${model}.apidesc-${endpoint}`;
|
|
1399
|
+
return l(key);
|
|
1400
|
+
};
|
|
1401
|
+
l.arg = (model, endpoint, arg) => {
|
|
1402
|
+
const key = `${model}.arg-${endpoint}-${arg}`;
|
|
1403
|
+
return l(key);
|
|
1404
|
+
};
|
|
1405
|
+
l.argdesc = (model, endpoint, arg) => {
|
|
1406
|
+
const key = `${model}.argdesc-${endpoint}-${arg}`;
|
|
1407
|
+
return l(key);
|
|
1408
|
+
};
|
|
1409
|
+
l.qry = (model, queryKey) => {
|
|
1410
|
+
const key = `${model}.qry-${queryKey}`;
|
|
1411
|
+
return l(key);
|
|
1412
|
+
};
|
|
1413
|
+
l.qrydesc = (model, queryKey) => {
|
|
1414
|
+
const key = `${model}.qrydesc-${queryKey}`;
|
|
1415
|
+
return l(key);
|
|
1416
|
+
};
|
|
1417
|
+
l.qarg = (model, queryKey, arg) => {
|
|
1418
|
+
const key = `${model}.qarg-${queryKey}-${arg}`;
|
|
1419
|
+
return l(key);
|
|
1420
|
+
};
|
|
1421
|
+
l.qargdesc = (model, queryKey, arg) => {
|
|
1422
|
+
const key = `${model}.qargdesc-${queryKey}-${arg}`;
|
|
1423
|
+
return l(key);
|
|
1424
|
+
};
|
|
1425
|
+
return { path, l, lang };
|
|
1426
|
+
};
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
// pkgs/@akanjs/next/src/useDebounce.ts
|
|
1430
|
+
var import_react4 = __require("react");
|
|
1431
|
+
var debounce = (callback, wait = 500) => {
|
|
1432
|
+
let timer;
|
|
1433
|
+
return (...args) => {
|
|
1434
|
+
clearTimeout(timer);
|
|
1435
|
+
timer = setTimeout(() => {
|
|
1436
|
+
callback(...args);
|
|
1437
|
+
}, wait);
|
|
1438
|
+
};
|
|
1439
|
+
};
|
|
1440
|
+
var useDebounce = (callback, states = [], wait = 100) => {
|
|
1441
|
+
const fn = (0, import_react4.useCallback)(debounce(callback, wait), states);
|
|
1442
|
+
return fn;
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
// pkgs/@akanjs/next/src/useInterval.ts
|
|
1446
|
+
var import_react5 = __require("react");
|
|
1447
|
+
var useInterval = (callback, delay) => {
|
|
1448
|
+
const savedCallback = (0, import_react5.useRef)(null);
|
|
1449
|
+
(0, import_react5.useEffect)(() => {
|
|
1450
|
+
savedCallback.current = callback;
|
|
1451
|
+
}, [callback]);
|
|
1452
|
+
(0, import_react5.useEffect)(() => {
|
|
1453
|
+
const tick = () => {
|
|
1454
|
+
void savedCallback.current?.();
|
|
1455
|
+
};
|
|
1456
|
+
const id = setInterval(tick, delay);
|
|
1457
|
+
return () => {
|
|
1458
|
+
clearInterval(id);
|
|
1459
|
+
};
|
|
1460
|
+
}, [delay]);
|
|
1461
|
+
return savedCallback;
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
// pkgs/@akanjs/next/src/bootCsr.tsx
|
|
1465
|
+
var import_react10 = __toESM(__require("react"));
|
|
1466
|
+
var ReactDOM = __toESM(__require("react-dom/client"));
|
|
1467
|
+
|
|
1468
|
+
// pkgs/@akanjs/next/src/useCsrValues.ts
|
|
1469
|
+
var import_app = __require("@capacitor/app");
|
|
1470
|
+
var import_web = __require("@react-spring/web");
|
|
1471
|
+
var import_react8 = __require("@use-gesture/react");
|
|
1472
|
+
var import_react9 = __require("react");
|
|
1473
|
+
|
|
1474
|
+
// pkgs/@akanjs/next/src/useHistory.ts
|
|
1475
|
+
var import_react6 = __require("react");
|
|
1476
|
+
var useHistory = (locations = []) => {
|
|
1477
|
+
const history = (0, import_react6.useRef)({
|
|
1478
|
+
type: "initial",
|
|
1479
|
+
locations,
|
|
1480
|
+
scrollMap: /* @__PURE__ */ new Map([[window.location.pathname, 0]]),
|
|
1481
|
+
idxMap: /* @__PURE__ */ new Map([[window.location.pathname, 0]]),
|
|
1482
|
+
cachedLocationMap: /* @__PURE__ */ new Map(),
|
|
1483
|
+
idx: 0
|
|
1484
|
+
});
|
|
1485
|
+
const setHistoryForward = (0, import_react6.useCallback)(({ type, location: location2, scrollTop = 0 }) => {
|
|
1486
|
+
history.current.type = "forward";
|
|
1487
|
+
history.current.scrollMap.set(location2.pathname, scrollTop);
|
|
1488
|
+
history.current.idxMap.set(location2.pathname, history.current.idx);
|
|
1489
|
+
if (type === "push")
|
|
1490
|
+
history.current.locations = [...history.current.locations.slice(0, history.current.idx + 1), location2];
|
|
1491
|
+
else if (type === "replace")
|
|
1492
|
+
history.current.locations = [...history.current.locations.slice(0, history.current.idx), location2];
|
|
1493
|
+
if (location2.pathRoute.pageState.cache)
|
|
1494
|
+
history.current.cachedLocationMap.set(location2.pathRoute.path, location2);
|
|
1495
|
+
if (type === "push" || type === "popForward")
|
|
1496
|
+
history.current.idx++;
|
|
1497
|
+
}, []);
|
|
1498
|
+
const setHistoryBack = (0, import_react6.useCallback)(({ location: location2, scrollTop = 0 }) => {
|
|
1499
|
+
history.current.type = "back";
|
|
1500
|
+
history.current.scrollMap.set(location2.pathname, scrollTop);
|
|
1501
|
+
history.current.idxMap.set(location2.pathname, history.current.idx);
|
|
1502
|
+
if (location2.pathRoute.pageState.cache)
|
|
1503
|
+
history.current.cachedLocationMap.set(location2.pathRoute.path, location2);
|
|
1504
|
+
history.current.idx--;
|
|
1505
|
+
}, []);
|
|
1506
|
+
const getCurrentLocation = (0, import_react6.useCallback)(() => {
|
|
1507
|
+
return history.current.locations[history.current.idx];
|
|
1508
|
+
}, []);
|
|
1509
|
+
const getPrevLocation = (0, import_react6.useCallback)(() => {
|
|
1510
|
+
return history.current.locations[history.current.idx - 1] ?? null;
|
|
1511
|
+
}, []);
|
|
1512
|
+
const getScrollTop = (0, import_react6.useCallback)((pathname = history.current.locations[history.current.idx]?.pathname ?? "/") => {
|
|
1513
|
+
return history.current.scrollMap.get(pathname) ?? 0;
|
|
1514
|
+
}, []);
|
|
1515
|
+
return { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop };
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
// pkgs/@akanjs/next/src/useLocation.ts
|
|
1519
|
+
var import_react7 = __require("react");
|
|
1520
|
+
var useLocation = ({ rootRouteGuide }) => {
|
|
1521
|
+
const getLocation = (0, import_react7.useCallback)((href) => {
|
|
1522
|
+
const getPathSegments = (pathname2) => {
|
|
1523
|
+
return [
|
|
1524
|
+
...pathname2.split("/").filter((pathSegment) => !!pathSegment).map((pathSegment) => `/${pathSegment}`)
|
|
1525
|
+
];
|
|
1526
|
+
};
|
|
1527
|
+
const getPathRoute = (pathname2) => {
|
|
1528
|
+
const pathSegments = getPathSegments(pathname2);
|
|
1529
|
+
const getTargetRouteGuide = (pathSegments2, routeGuide) => {
|
|
1530
|
+
const pathSegment = pathSegments2.shift();
|
|
1531
|
+
if (!pathSegment)
|
|
1532
|
+
return routeGuide;
|
|
1533
|
+
const childrenSegments = Object.keys(routeGuide.children);
|
|
1534
|
+
const matchingPathSegment = childrenSegments.find((segment) => segment === pathSegment);
|
|
1535
|
+
const paramSegment = childrenSegments.find((segment) => segment.startsWith("/:"));
|
|
1536
|
+
const childRouteGuide = matchingPathSegment ? routeGuide.children[pathSegment] : paramSegment ? routeGuide.children[paramSegment] : null;
|
|
1537
|
+
if (!childRouteGuide)
|
|
1538
|
+
throw new Error("404");
|
|
1539
|
+
return getTargetRouteGuide(pathSegments2, childRouteGuide);
|
|
1540
|
+
};
|
|
1541
|
+
const targetRouteGuide = getTargetRouteGuide(pathSegments, rootRouteGuide);
|
|
1542
|
+
const pathRoute2 = targetRouteGuide.pathRoute;
|
|
1543
|
+
if (!pathRoute2) {
|
|
1544
|
+
window.location.assign("/404");
|
|
1545
|
+
throw new Error("404");
|
|
1546
|
+
}
|
|
1547
|
+
return pathRoute2;
|
|
1548
|
+
};
|
|
1549
|
+
const getParams = (pathname2, pathRoute2) => {
|
|
1550
|
+
const pathSegments = getPathSegments(pathname2);
|
|
1551
|
+
return pathRoute2.pathSegments.reduce((params2, pathSegment, idx) => {
|
|
1552
|
+
if (pathSegment.startsWith("/:"))
|
|
1553
|
+
params2[pathSegment.slice(2)] = pathSegments[idx - 1].slice(1);
|
|
1554
|
+
return params2;
|
|
1555
|
+
}, {});
|
|
1556
|
+
};
|
|
1557
|
+
const getSearchParams = (search2) => {
|
|
1558
|
+
return [...new URLSearchParams(search2).entries()].reduce(
|
|
1559
|
+
(params2, [key, value]) => {
|
|
1560
|
+
params2[key] = params2[key] ? [...Array.isArray(params2[key]) ? params2[key] : [params2[key]], value] : value;
|
|
1561
|
+
return params2;
|
|
1562
|
+
},
|
|
1563
|
+
{}
|
|
1564
|
+
);
|
|
1565
|
+
};
|
|
1566
|
+
const [pathname, search] = href.split("?");
|
|
1567
|
+
const pathRoute = getPathRoute(pathname);
|
|
1568
|
+
const params = getParams(pathname, pathRoute);
|
|
1569
|
+
const searchParams = getSearchParams(search);
|
|
1570
|
+
return { pathname, search, params, searchParams, pathRoute };
|
|
1571
|
+
}, []);
|
|
1572
|
+
return { getLocation };
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
// pkgs/@akanjs/next/src/useCsrValues.ts
|
|
1576
|
+
var useNoneTrans = ({ clientHeight, location: location2, prevLocation }) => {
|
|
1577
|
+
const transDirection = "none";
|
|
1578
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
1579
|
+
const transUnitRange = (0, import_react9.useMemo)(() => [0, 0], []);
|
|
1580
|
+
const transProgress = transUnit.to((unit) => 1);
|
|
1581
|
+
const transPercent = transUnit.to((unit) => 100);
|
|
1582
|
+
const pageState = location2.pathRoute.pageState;
|
|
1583
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
1584
|
+
const csrTranstionStyles = {
|
|
1585
|
+
topSafeArea: {
|
|
1586
|
+
containerStyle: {
|
|
1587
|
+
height: pageState.topSafeArea
|
|
1588
|
+
}
|
|
1589
|
+
},
|
|
1590
|
+
bottomSafeArea: {
|
|
1591
|
+
containerStyle: {
|
|
1592
|
+
top: clientHeight - pageState.bottomSafeArea,
|
|
1593
|
+
height: pageState.bottomSafeArea
|
|
1594
|
+
}
|
|
1595
|
+
},
|
|
1596
|
+
page: {
|
|
1597
|
+
containerStyle: {},
|
|
1598
|
+
contentStyle: {
|
|
1599
|
+
paddingTop: pageState.topSafeArea + pageState.topInset,
|
|
1600
|
+
paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
|
|
1601
|
+
height: clientHeight
|
|
1602
|
+
}
|
|
1603
|
+
},
|
|
1604
|
+
prevPage: {
|
|
1605
|
+
containerStyle: {
|
|
1606
|
+
paddingTop: prevPageState.topSafeArea + prevPageState.topInset
|
|
1607
|
+
},
|
|
1608
|
+
contentStyle: { opacity: 0 }
|
|
1609
|
+
},
|
|
1610
|
+
topInset: {
|
|
1611
|
+
containerStyle: {
|
|
1612
|
+
top: pageState.topSafeArea,
|
|
1613
|
+
height: pageState.topInset
|
|
1614
|
+
},
|
|
1615
|
+
contentStyle: { opacity: 1 },
|
|
1616
|
+
prevContentStyle: { opacity: 0 }
|
|
1617
|
+
},
|
|
1618
|
+
topLeftAction: {
|
|
1619
|
+
containerStyle: {
|
|
1620
|
+
top: pageState.topSafeArea,
|
|
1621
|
+
height: pageState.topInset
|
|
1622
|
+
},
|
|
1623
|
+
contentStyle: { opacity: 1 },
|
|
1624
|
+
prevContentStyle: { opacity: 0 }
|
|
1625
|
+
},
|
|
1626
|
+
bottomInset: {
|
|
1627
|
+
containerStyle: {
|
|
1628
|
+
height: pageState.bottomInset,
|
|
1629
|
+
top: clientHeight - pageState.bottomInset - pageState.bottomSafeArea
|
|
1630
|
+
},
|
|
1631
|
+
contentStyle: { opacity: 1 },
|
|
1632
|
+
prevContentStyle: { opacity: 0 }
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
const useCsrTransition = {
|
|
1636
|
+
...csrTranstionStyles,
|
|
1637
|
+
pageBind: () => ({}),
|
|
1638
|
+
pageClassName: "touch-pan-y",
|
|
1639
|
+
transDirection,
|
|
1640
|
+
transUnitRange,
|
|
1641
|
+
transUnit,
|
|
1642
|
+
transPercent,
|
|
1643
|
+
transProgress
|
|
1644
|
+
};
|
|
1645
|
+
return useCsrTransition;
|
|
1646
|
+
};
|
|
1647
|
+
var useFadeTrans = ({ clientHeight, location: location2, prevLocation, onBack, history }) => {
|
|
1648
|
+
const transDirection = "none";
|
|
1649
|
+
const transUnit = (0, import_web.useSpringValue)(1, { config: { clamp: true } });
|
|
1650
|
+
const transUnitRange = (0, import_react9.useMemo)(() => [0, 1], []);
|
|
1651
|
+
const transProgress = transUnit.to((unit) => unit);
|
|
1652
|
+
const transPercent = transUnit.to([0, 1], [0, 100], "clamp");
|
|
1653
|
+
const pageState = location2.pathRoute.pageState;
|
|
1654
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
1655
|
+
(0, import_react9.useEffect)(() => {
|
|
1656
|
+
onBack.current.fade = async () => {
|
|
1657
|
+
await transUnit.start(transUnitRange[0]);
|
|
1658
|
+
};
|
|
1659
|
+
}, []);
|
|
1660
|
+
(0, import_react9.useEffect)(() => {
|
|
1661
|
+
if (history.current.type === "forward") {
|
|
1662
|
+
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
1663
|
+
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
1664
|
+
} else {
|
|
1665
|
+
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
}, [location2.pathname]);
|
|
1669
|
+
const csrTranstionStyles = {
|
|
1670
|
+
topSafeArea: {
|
|
1671
|
+
containerStyle: {
|
|
1672
|
+
height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
|
|
1673
|
+
}
|
|
1674
|
+
},
|
|
1675
|
+
bottomSafeArea: {
|
|
1676
|
+
containerStyle: {
|
|
1677
|
+
top: transProgress.to(
|
|
1678
|
+
[0, 1],
|
|
1679
|
+
[clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
|
|
1680
|
+
),
|
|
1681
|
+
height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
|
|
1682
|
+
}
|
|
1683
|
+
},
|
|
1684
|
+
page: {
|
|
1685
|
+
containerStyle: {},
|
|
1686
|
+
contentStyle: {
|
|
1687
|
+
paddingTop: pageState.topSafeArea + pageState.topInset,
|
|
1688
|
+
paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
|
|
1689
|
+
opacity: transUnit,
|
|
1690
|
+
height: clientHeight
|
|
1691
|
+
}
|
|
1692
|
+
},
|
|
1693
|
+
prevPage: {
|
|
1694
|
+
containerStyle: {
|
|
1695
|
+
paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
|
|
1696
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1697
|
+
},
|
|
1698
|
+
contentStyle: {}
|
|
1699
|
+
},
|
|
1700
|
+
topInset: {
|
|
1701
|
+
containerStyle: {
|
|
1702
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
1703
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
1704
|
+
},
|
|
1705
|
+
contentStyle: {
|
|
1706
|
+
opacity: transProgress
|
|
1707
|
+
},
|
|
1708
|
+
prevContentStyle: {
|
|
1709
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
topLeftAction: {
|
|
1713
|
+
containerStyle: {
|
|
1714
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
1715
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
1716
|
+
},
|
|
1717
|
+
contentStyle: {
|
|
1718
|
+
opacity: transProgress.to((progress) => progress)
|
|
1719
|
+
},
|
|
1720
|
+
prevContentStyle: {
|
|
1721
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1724
|
+
bottomInset: {
|
|
1725
|
+
containerStyle: {
|
|
1726
|
+
height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
|
|
1727
|
+
top: transProgress.to(
|
|
1728
|
+
[0, 1],
|
|
1729
|
+
[
|
|
1730
|
+
clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
|
|
1731
|
+
clientHeight - pageState.bottomInset - pageState.bottomSafeArea
|
|
1732
|
+
]
|
|
1733
|
+
)
|
|
1734
|
+
},
|
|
1735
|
+
contentStyle: {
|
|
1736
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
1737
|
+
opacity: transProgress.to((progress) => progress)
|
|
1738
|
+
},
|
|
1739
|
+
prevContentStyle: {
|
|
1740
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
1741
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
const useCsrTransition = {
|
|
1746
|
+
...csrTranstionStyles,
|
|
1747
|
+
pageBind: () => ({}),
|
|
1748
|
+
pageClassName: "",
|
|
1749
|
+
transDirection,
|
|
1750
|
+
transUnitRange,
|
|
1751
|
+
transUnit,
|
|
1752
|
+
transPercent,
|
|
1753
|
+
transProgress
|
|
1754
|
+
};
|
|
1755
|
+
return useCsrTransition;
|
|
1756
|
+
};
|
|
1757
|
+
var useStackTrans = ({
|
|
1758
|
+
clientWidth,
|
|
1759
|
+
clientHeight,
|
|
1760
|
+
location: location2,
|
|
1761
|
+
prevLocation,
|
|
1762
|
+
history,
|
|
1763
|
+
onBack
|
|
1764
|
+
}) => {
|
|
1765
|
+
const transDirection = "horizontal";
|
|
1766
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
1767
|
+
const transUnitRange = (0, import_react9.useMemo)(() => [clientWidth, 0], []);
|
|
1768
|
+
const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
|
|
1769
|
+
const transUnitRangeReversed = (0, import_react9.useMemo)(() => [0, clientWidth], []);
|
|
1770
|
+
const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
|
|
1771
|
+
const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
|
|
1772
|
+
const initThreshold = (0, import_react9.useMemo)(() => Math.floor(clientWidth), []);
|
|
1773
|
+
const threshold = (0, import_react9.useMemo)(() => Math.floor(clientWidth / 3), []);
|
|
1774
|
+
const pageState = location2.pathRoute.pageState;
|
|
1775
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
1776
|
+
const pageClassName = "touch-pan-y";
|
|
1777
|
+
(0, import_react9.useEffect)(() => {
|
|
1778
|
+
onBack.current.stack = async () => {
|
|
1779
|
+
await transUnit.start(transUnitRange[0]);
|
|
1780
|
+
};
|
|
1781
|
+
}, []);
|
|
1782
|
+
(0, import_react9.useEffect)(() => {
|
|
1783
|
+
if (history.current.type === "forward") {
|
|
1784
|
+
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
1785
|
+
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
1786
|
+
} else {
|
|
1787
|
+
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
}, [location2.pathname]);
|
|
1791
|
+
const pageBind = (0, import_react8.useDrag)(
|
|
1792
|
+
({ first, down, last, movement: [mx], initial: [ix], cancel }) => {
|
|
1793
|
+
if (first)
|
|
1794
|
+
void device.hideKeyboard();
|
|
1795
|
+
if (ix > initThreshold) {
|
|
1796
|
+
cancel();
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (mx < transUnitRange[1])
|
|
1800
|
+
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
1801
|
+
else if (mx > transUnitRange[0])
|
|
1802
|
+
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
1803
|
+
else if (!last)
|
|
1804
|
+
void transUnit.start(mx, { immediate: true });
|
|
1805
|
+
else if (mx < threshold)
|
|
1806
|
+
void transUnit.start(transUnitRange[1]);
|
|
1807
|
+
if (last && mx > threshold)
|
|
1808
|
+
router.back();
|
|
1809
|
+
},
|
|
1810
|
+
{ axis: "x", filterTaps: true }
|
|
1811
|
+
);
|
|
1812
|
+
const csrTranstionStyles = {
|
|
1813
|
+
topSafeArea: {
|
|
1814
|
+
containerStyle: {
|
|
1815
|
+
height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
bottomSafeArea: {
|
|
1819
|
+
containerStyle: {
|
|
1820
|
+
top: transProgress.to(
|
|
1821
|
+
[0, 1],
|
|
1822
|
+
[clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
|
|
1823
|
+
),
|
|
1824
|
+
height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
|
|
1825
|
+
}
|
|
1826
|
+
},
|
|
1827
|
+
page: {
|
|
1828
|
+
containerStyle: {},
|
|
1829
|
+
contentStyle: {
|
|
1830
|
+
paddingTop: pageState.topSafeArea + pageState.topInset,
|
|
1831
|
+
paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
|
|
1832
|
+
translateX: transUnit,
|
|
1833
|
+
height: clientHeight
|
|
1834
|
+
}
|
|
1835
|
+
},
|
|
1836
|
+
prevPage: {
|
|
1837
|
+
containerStyle: {
|
|
1838
|
+
paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
|
|
1839
|
+
translateX: transUnit.to((unit) => (unit - clientWidth) / 5)
|
|
1840
|
+
},
|
|
1841
|
+
contentStyle: {
|
|
1842
|
+
opacity: transProgress.to((progress) => 1 - progress / 2)
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
topInset: {
|
|
1846
|
+
containerStyle: {
|
|
1847
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
1848
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
1849
|
+
},
|
|
1850
|
+
contentStyle: {
|
|
1851
|
+
opacity: transProgress.to((progress) => progress),
|
|
1852
|
+
translateX: transProgress.to([0, 1], [clientWidth / 5, 0])
|
|
1853
|
+
},
|
|
1854
|
+
prevContentStyle: {
|
|
1855
|
+
opacity: transProgress.to((progress) => 1 - progress),
|
|
1856
|
+
translateX: transProgress.to([0, 1], [0, -clientWidth / 5])
|
|
1857
|
+
}
|
|
1858
|
+
},
|
|
1859
|
+
topLeftAction: {
|
|
1860
|
+
containerStyle: {
|
|
1861
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
1862
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset]),
|
|
1863
|
+
minWidth: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
1864
|
+
},
|
|
1865
|
+
contentStyle: {
|
|
1866
|
+
opacity: transProgress.to((progress) => progress)
|
|
1867
|
+
},
|
|
1868
|
+
prevContentStyle: {
|
|
1869
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1870
|
+
}
|
|
1871
|
+
},
|
|
1872
|
+
bottomInset: {
|
|
1873
|
+
containerStyle: {
|
|
1874
|
+
height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
|
|
1875
|
+
top: transProgress.to(
|
|
1876
|
+
[0, 1],
|
|
1877
|
+
[
|
|
1878
|
+
clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
|
|
1879
|
+
clientHeight - pageState.bottomInset - pageState.bottomSafeArea
|
|
1880
|
+
]
|
|
1881
|
+
)
|
|
1882
|
+
},
|
|
1883
|
+
contentStyle: {
|
|
1884
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
1885
|
+
opacity: transProgress.to((progress) => progress)
|
|
1886
|
+
},
|
|
1887
|
+
prevContentStyle: {
|
|
1888
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
1889
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
const useCsrTransition = {
|
|
1894
|
+
...csrTranstionStyles,
|
|
1895
|
+
pageBind,
|
|
1896
|
+
pageClassName,
|
|
1897
|
+
transDirection,
|
|
1898
|
+
transUnitRange,
|
|
1899
|
+
transUnit,
|
|
1900
|
+
transPercent,
|
|
1901
|
+
transProgress
|
|
1902
|
+
};
|
|
1903
|
+
return useCsrTransition;
|
|
1904
|
+
};
|
|
1905
|
+
var useBottomUpTrans = ({
|
|
1906
|
+
clientWidth,
|
|
1907
|
+
clientHeight,
|
|
1908
|
+
history,
|
|
1909
|
+
location: location2,
|
|
1910
|
+
prevLocation,
|
|
1911
|
+
onBack
|
|
1912
|
+
}) => {
|
|
1913
|
+
const transDirection = "vertical";
|
|
1914
|
+
const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
|
|
1915
|
+
const transUnitRange = (0, import_react9.useMemo)(() => [clientHeight, 0], []);
|
|
1916
|
+
const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
|
|
1917
|
+
const transUnitRangeReversed = (0, import_react9.useMemo)(() => [0, clientWidth], []);
|
|
1918
|
+
const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
|
|
1919
|
+
const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
|
|
1920
|
+
const initThreshold = (0, import_react9.useMemo)(() => Math.floor(clientWidth / 3), []);
|
|
1921
|
+
const threshold = (0, import_react9.useMemo)(() => Math.floor(clientWidth / 2), []);
|
|
1922
|
+
const pageState = location2.pathRoute.pageState;
|
|
1923
|
+
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
1924
|
+
(0, import_react9.useEffect)(() => {
|
|
1925
|
+
onBack.current.bottomUp = async () => {
|
|
1926
|
+
await transUnit.start(transUnitRange[0]);
|
|
1927
|
+
};
|
|
1928
|
+
}, []);
|
|
1929
|
+
(0, import_react9.useEffect)(() => {
|
|
1930
|
+
if (history.current.type === "forward") {
|
|
1931
|
+
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
1932
|
+
void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
|
|
1933
|
+
} else {
|
|
1934
|
+
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
}, [location2.pathname]);
|
|
1938
|
+
const pageBind = (0, import_react8.useDrag)(
|
|
1939
|
+
({ first, last, movement: [, my], initial: [, iy], cancel }) => {
|
|
1940
|
+
if (first)
|
|
1941
|
+
void device.hideKeyboard();
|
|
1942
|
+
if (iy > initThreshold) {
|
|
1943
|
+
cancel();
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
if (my < transUnitRange[1])
|
|
1947
|
+
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
1948
|
+
else if (my > transUnitRange[0])
|
|
1949
|
+
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
1950
|
+
else if (!last)
|
|
1951
|
+
void transUnit.start(my, { immediate: true });
|
|
1952
|
+
else if (my < threshold)
|
|
1953
|
+
void transUnit.start(transUnitRange[1]);
|
|
1954
|
+
if (last && my > threshold)
|
|
1955
|
+
router.back();
|
|
1956
|
+
},
|
|
1957
|
+
{ axis: "y", filterTaps: true, threshold: 10 }
|
|
1958
|
+
);
|
|
1959
|
+
const csrTranstionStyles = {
|
|
1960
|
+
topSafeArea: {
|
|
1961
|
+
containerStyle: {
|
|
1962
|
+
height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
|
|
1963
|
+
}
|
|
1964
|
+
},
|
|
1965
|
+
bottomSafeArea: {
|
|
1966
|
+
containerStyle: {
|
|
1967
|
+
top: transProgress.to(
|
|
1968
|
+
[0, 1],
|
|
1969
|
+
[clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
|
|
1970
|
+
),
|
|
1971
|
+
height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
page: {
|
|
1975
|
+
containerStyle: {},
|
|
1976
|
+
contentStyle: {
|
|
1977
|
+
paddingTop: pageState.topSafeArea + pageState.topInset,
|
|
1978
|
+
paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
|
|
1979
|
+
translateY: transUnit,
|
|
1980
|
+
height: clientHeight
|
|
1981
|
+
}
|
|
1982
|
+
},
|
|
1983
|
+
prevPage: {
|
|
1984
|
+
containerStyle: {
|
|
1985
|
+
paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
|
|
1986
|
+
translateY: 0
|
|
1987
|
+
},
|
|
1988
|
+
contentStyle: {
|
|
1989
|
+
opacity: transProgress.to((progress) => 1 - progress / 2)
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
topInset: {
|
|
1993
|
+
containerStyle: {
|
|
1994
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
1995
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
1996
|
+
},
|
|
1997
|
+
contentStyle: {
|
|
1998
|
+
opacity: transProgress.to((progress) => progress)
|
|
1999
|
+
// translateX: transProgress.to([0, 1], [clientWidth / 5, 0]),
|
|
2000
|
+
},
|
|
2001
|
+
prevContentStyle: {
|
|
2002
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
2003
|
+
// translateX: transProgress.to([0, 1], [0, -clientWidth / 5]),
|
|
2004
|
+
}
|
|
2005
|
+
},
|
|
2006
|
+
topLeftAction: {
|
|
2007
|
+
containerStyle: {
|
|
2008
|
+
top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
|
|
2009
|
+
height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
|
|
2010
|
+
},
|
|
2011
|
+
contentStyle: {
|
|
2012
|
+
opacity: transProgress.to((progress) => progress)
|
|
2013
|
+
},
|
|
2014
|
+
prevContentStyle: {
|
|
2015
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
2016
|
+
}
|
|
2017
|
+
},
|
|
2018
|
+
bottomInset: {
|
|
2019
|
+
containerStyle: {
|
|
2020
|
+
height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
|
|
2021
|
+
top: transProgress.to(
|
|
2022
|
+
[0, 1],
|
|
2023
|
+
[
|
|
2024
|
+
clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
|
|
2025
|
+
clientHeight - pageState.bottomInset - pageState.bottomSafeArea
|
|
2026
|
+
]
|
|
2027
|
+
)
|
|
2028
|
+
},
|
|
2029
|
+
contentStyle: {
|
|
2030
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
2031
|
+
opacity: transProgress.to((progress) => progress)
|
|
2032
|
+
},
|
|
2033
|
+
prevContentStyle: {
|
|
2034
|
+
top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
|
|
2035
|
+
opacity: transProgress.to((progress) => 1 - progress)
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
const useCsrTransition = {
|
|
2040
|
+
...csrTranstionStyles,
|
|
2041
|
+
pageBind,
|
|
2042
|
+
pageClassName: "touch-pan-x",
|
|
2043
|
+
transDirection,
|
|
2044
|
+
transUnitRange,
|
|
2045
|
+
transUnit,
|
|
2046
|
+
transPercent,
|
|
2047
|
+
transProgress
|
|
2048
|
+
};
|
|
2049
|
+
return useCsrTransition;
|
|
2050
|
+
};
|
|
2051
|
+
var useCsrValues = (rootRouteGuide, pathRoutes) => {
|
|
2052
|
+
const clientWidth = (0, import_react9.useRef)(window.innerWidth);
|
|
2053
|
+
const clientHeight = (0, import_react9.useRef)(window.innerHeight);
|
|
2054
|
+
const topSafeAreaRef = (0, import_react9.useRef)(null);
|
|
2055
|
+
const bottomSafeAreaRef = (0, import_react9.useRef)(null);
|
|
2056
|
+
const pageContentRef = (0, import_react9.useRef)(null);
|
|
2057
|
+
const prevPageContentRef = (0, import_react9.useRef)(null);
|
|
2058
|
+
const onBack = (0, import_react9.useRef)({});
|
|
2059
|
+
const frameRootRef = (0, import_react9.useRef)(null);
|
|
2060
|
+
const { getLocation } = useLocation({ rootRouteGuide });
|
|
2061
|
+
const { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop } = useHistory([
|
|
2062
|
+
getLocation(window.location.pathname)
|
|
2063
|
+
]);
|
|
2064
|
+
const [{ location: location2, prevLocation }, setLocationState] = (0, import_react9.useState)({
|
|
2065
|
+
location: getCurrentLocation(),
|
|
2066
|
+
prevLocation: getPrevLocation()
|
|
2067
|
+
});
|
|
2068
|
+
const getRouter = (0, import_react9.useCallback)(() => {
|
|
2069
|
+
const router3 = {
|
|
2070
|
+
push: (href) => {
|
|
2071
|
+
const location3 = getCurrentLocation();
|
|
2072
|
+
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
2073
|
+
setHistoryForward({ type: "push", location: getLocation(href), scrollTop });
|
|
2074
|
+
setLocationState({ location: getCurrentLocation(), prevLocation: location3 });
|
|
2075
|
+
window.history.pushState({}, "", href);
|
|
2076
|
+
},
|
|
2077
|
+
replace: (href) => {
|
|
2078
|
+
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
2079
|
+
setHistoryForward({ type: "replace", location: getLocation(href), scrollTop });
|
|
2080
|
+
setLocationState({ location: getCurrentLocation(), prevLocation });
|
|
2081
|
+
window.history.replaceState({}, "", href);
|
|
2082
|
+
},
|
|
2083
|
+
refresh: () => {
|
|
2084
|
+
window.location.reload();
|
|
2085
|
+
},
|
|
2086
|
+
back: async () => {
|
|
2087
|
+
const location3 = getCurrentLocation();
|
|
2088
|
+
await onBack.current[location3.pathRoute.pageState.transition]?.();
|
|
2089
|
+
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
2090
|
+
setHistoryBack({ type: "back", location: location3, scrollTop });
|
|
2091
|
+
setLocationState({ location: getCurrentLocation(), prevLocation: getPrevLocation() });
|
|
2092
|
+
window.history.back();
|
|
2093
|
+
}
|
|
2094
|
+
};
|
|
2095
|
+
window.onpopstate = async (ev) => {
|
|
2096
|
+
const routeType = window.location.pathname === getCurrentLocation().pathname && history.current.type !== "back" ? "forward" : window.location.pathname === getPrevLocation()?.pathname ? "back" : null;
|
|
2097
|
+
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
2098
|
+
if (!routeType)
|
|
2099
|
+
return;
|
|
2100
|
+
if (routeType === "forward") {
|
|
2101
|
+
const location3 = getCurrentLocation();
|
|
2102
|
+
setHistoryForward({ type: "popForward", location: location3, scrollTop });
|
|
2103
|
+
setLocationState({ location: getCurrentLocation(), prevLocation: location3 });
|
|
2104
|
+
} else {
|
|
2105
|
+
const location3 = getCurrentLocation();
|
|
2106
|
+
await onBack.current[location3.pathRoute.pageState.transition]?.();
|
|
2107
|
+
setHistoryBack({ type: "popBack", location: location3, scrollTop });
|
|
2108
|
+
setLocationState({ location: getCurrentLocation(), prevLocation: getPrevLocation() });
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
return router3;
|
|
2112
|
+
}, [location2]);
|
|
2113
|
+
const router2 = getRouter();
|
|
2114
|
+
const routeState = {
|
|
2115
|
+
clientWidth: clientWidth.current,
|
|
2116
|
+
clientHeight: clientHeight.current,
|
|
2117
|
+
location: location2,
|
|
2118
|
+
prevLocation,
|
|
2119
|
+
history,
|
|
2120
|
+
topSafeAreaRef,
|
|
2121
|
+
bottomSafeAreaRef,
|
|
2122
|
+
prevPageContentRef,
|
|
2123
|
+
pageContentRef,
|
|
2124
|
+
frameRootRef,
|
|
2125
|
+
onBack,
|
|
2126
|
+
router: router2,
|
|
2127
|
+
pathRoutes
|
|
2128
|
+
};
|
|
2129
|
+
const useNonTransition = useNoneTrans(routeState);
|
|
2130
|
+
const useFadeTransition = useFadeTrans(routeState);
|
|
2131
|
+
const useStackTransition = useStackTrans(routeState);
|
|
2132
|
+
const useBottomUpTransition = useBottomUpTrans(routeState);
|
|
2133
|
+
const useCsrTransitionMap = {
|
|
2134
|
+
none: useNonTransition,
|
|
2135
|
+
fade: useFadeTransition,
|
|
2136
|
+
stack: useStackTransition,
|
|
2137
|
+
bottomUp: useBottomUpTransition,
|
|
2138
|
+
scaleOut: useNonTransition
|
|
2139
|
+
};
|
|
2140
|
+
(0, import_react9.useEffect)(() => {
|
|
2141
|
+
if (pageContentRef.current)
|
|
2142
|
+
pageContentRef.current.scrollTop = getScrollTop(location2.pathname);
|
|
2143
|
+
if (prevPageContentRef.current)
|
|
2144
|
+
prevPageContentRef.current.scrollTop = prevLocation ? getScrollTop(prevLocation.pathname) : 0;
|
|
2145
|
+
void import_app.App.addListener("backButton", () => {
|
|
2146
|
+
router2.back();
|
|
2147
|
+
});
|
|
2148
|
+
return () => {
|
|
2149
|
+
void import_app.App.removeAllListeners();
|
|
2150
|
+
};
|
|
2151
|
+
}, [location2.pathname]);
|
|
2152
|
+
return {
|
|
2153
|
+
...routeState,
|
|
2154
|
+
...useCsrTransitionMap[location2.pathRoute.pageState.transition]
|
|
2155
|
+
};
|
|
2156
|
+
};
|
|
2157
|
+
|
|
2158
|
+
// pkgs/@akanjs/next/src/bootCsr.tsx
|
|
2159
|
+
var supportLanguages = ["en", "ko"];
|
|
2160
|
+
var bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
2161
|
+
const [, jwt] = await Promise.all([device.init({ supportLanguages }), storage.getItem("jwt")]);
|
|
2162
|
+
if (jwt)
|
|
2163
|
+
initAuth({ jwt });
|
|
2164
|
+
Logger.verbose(`Set default language: ${device.lang}`);
|
|
2165
|
+
const pages = {};
|
|
2166
|
+
await Promise.all(
|
|
2167
|
+
Object.entries(context).map(async ([key, value]) => {
|
|
2168
|
+
pages[key] = await value();
|
|
2169
|
+
})
|
|
2170
|
+
);
|
|
2171
|
+
const getPageState = (csrConfig) => {
|
|
2172
|
+
const { transition, safeArea, topInset, bottomInset, gesture, cache } = csrConfig ?? {};
|
|
2173
|
+
const pageState = {
|
|
2174
|
+
transition: transition ?? "none",
|
|
2175
|
+
topSafeArea: safeArea === false ? 0 : device.topSafeArea,
|
|
2176
|
+
bottomSafeArea: safeArea === false ? 0 : device.bottomSafeArea,
|
|
2177
|
+
// topSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.topSafeArea,
|
|
2178
|
+
// bottomSafeArea: safeArea === false || device.info.platform === "android" ? 0 : device.bottomSafeArea,
|
|
2179
|
+
topInset: topInset === true ? DEFAULT_TOP_INSET : topInset === false ? 0 : topInset ?? 0,
|
|
2180
|
+
bottomInset: bottomInset === true ? DEFAULT_BOTTOM_INSET : bottomInset === false ? 0 : bottomInset ?? 0,
|
|
2181
|
+
gesture: gesture ?? true,
|
|
2182
|
+
cache: cache ?? false
|
|
2183
|
+
};
|
|
2184
|
+
return pageState;
|
|
2185
|
+
};
|
|
2186
|
+
const routeMap = /* @__PURE__ */ new Map();
|
|
2187
|
+
routeMap.set("/", { path: "/", children: /* @__PURE__ */ new Map() });
|
|
2188
|
+
for (const filePath of Object.keys(pages)) {
|
|
2189
|
+
const fileName = /\.\/(.*)\.tsx$/.exec(filePath)?.[1];
|
|
2190
|
+
if (!fileName)
|
|
2191
|
+
continue;
|
|
2192
|
+
const fileType = fileName.endsWith("page") ? "page" : fileName.endsWith("layout") ? "layout" : null;
|
|
2193
|
+
if (!fileType)
|
|
2194
|
+
continue;
|
|
2195
|
+
const pathSegments = [
|
|
2196
|
+
"/",
|
|
2197
|
+
...fileName.split("/").slice(0, -1).map((segment) => `/${segment.replace(/\[(.*?)\]/g, ":$1")}`)
|
|
2198
|
+
];
|
|
2199
|
+
const targetRouteMap = pathSegments.slice(0, -1).reduce((rMap, path) => {
|
|
2200
|
+
if (!rMap.has(path))
|
|
2201
|
+
rMap.set(path, { path, children: /* @__PURE__ */ new Map() });
|
|
2202
|
+
return rMap.get(path)?.children;
|
|
2203
|
+
}, routeMap);
|
|
2204
|
+
if (!targetRouteMap)
|
|
2205
|
+
continue;
|
|
2206
|
+
const targetPath = pathSegments[pathSegments.length - 1];
|
|
2207
|
+
targetRouteMap.set(targetPath, {
|
|
2208
|
+
// action: pages[path]?.action,
|
|
2209
|
+
// ErrorBoundary: pages[path]?.ErrorBoundary,
|
|
2210
|
+
...targetRouteMap.get(targetPath) ?? { path: targetPath, children: /* @__PURE__ */ new Map() },
|
|
2211
|
+
...fileType === "layout" ? { Layout: pages[filePath].default } : {
|
|
2212
|
+
Page: pages[filePath].default,
|
|
2213
|
+
pageState: getPageState(pages[filePath].default.csrConfig),
|
|
2214
|
+
csrConfig: pages[filePath].default.csrConfig
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
const pathname = window.location.pathname;
|
|
2219
|
+
const initialPath = device.lang + entryPath;
|
|
2220
|
+
window.document.body.style.overflow = "hidden";
|
|
2221
|
+
const getPathRoutes = (route, parentRootLayouts = [], parentLayouts = [], parentPaths = []) => {
|
|
2222
|
+
const parentPath = parentPaths.filter((path2) => path2 !== "/").join("");
|
|
2223
|
+
const currentPathSegment = /^\/\(.*\)$/.test(route.path) ? "" : route.path;
|
|
2224
|
+
const isRoot = ["/", "/:lang"].includes(parentPath + currentPathSegment) && parentRootLayouts.length < 2;
|
|
2225
|
+
const path = parentPath + currentPathSegment;
|
|
2226
|
+
const pathSegments = [...parentPaths, ...currentPathSegment ? [currentPathSegment] : []];
|
|
2227
|
+
const RootLayouts = [...parentRootLayouts, ...isRoot && route.Layout ? [route.Layout] : []];
|
|
2228
|
+
const Layouts = [...parentLayouts, ...!isRoot && route.Layout ? [route.Layout] : []];
|
|
2229
|
+
return [
|
|
2230
|
+
...route.Page ? [
|
|
2231
|
+
{
|
|
2232
|
+
path,
|
|
2233
|
+
pathSegments,
|
|
2234
|
+
Page: route.Page,
|
|
2235
|
+
RootLayouts,
|
|
2236
|
+
Layouts,
|
|
2237
|
+
pageState: route.pageState ?? defaultPageState
|
|
2238
|
+
}
|
|
2239
|
+
] : [],
|
|
2240
|
+
...route.children.size ? [...route.children.values()].flatMap((child) => getPathRoutes(child, RootLayouts, Layouts, pathSegments)) : []
|
|
2241
|
+
];
|
|
2242
|
+
};
|
|
2243
|
+
const rootRoute = routeMap.get("/");
|
|
2244
|
+
if (!rootRoute)
|
|
2245
|
+
throw new Error("No root route");
|
|
2246
|
+
const pathRoutes = getPathRoutes(rootRoute);
|
|
2247
|
+
const routeGuide = { pathSegment: "/", children: {} };
|
|
2248
|
+
pathRoutes.forEach((pathRoute) => {
|
|
2249
|
+
const pathSegments = pathRoute.pathSegments.slice(1);
|
|
2250
|
+
pathSegments.reduce((routeGuide2, pathSegment, index) => {
|
|
2251
|
+
const child = routeGuide2.children[pathSegment];
|
|
2252
|
+
routeGuide2.children[pathSegment] = {
|
|
2253
|
+
...child ?? {},
|
|
2254
|
+
pathSegment,
|
|
2255
|
+
...index === pathSegments.length - 1 ? { pathRoute } : {},
|
|
2256
|
+
children: child?.children ?? {}
|
|
2257
|
+
};
|
|
2258
|
+
return routeGuide2.children[pathSegment];
|
|
2259
|
+
}, routeGuide);
|
|
2260
|
+
});
|
|
2261
|
+
const RouterProvider = () => {
|
|
2262
|
+
const csrValues = useCsrValues(routeGuide, pathRoutes);
|
|
2263
|
+
const { location: location2 } = csrValues;
|
|
2264
|
+
return /* @__PURE__ */ import_react10.default.createElement(csrContext.Provider, { value: csrValues }, location2.pathRoute.RootLayouts.reduceRight(
|
|
2265
|
+
(children, Layout) => {
|
|
2266
|
+
return /* @__PURE__ */ import_react10.default.createElement(Layout, { params: location2.params, searchParams: location2.searchParams }, children);
|
|
2267
|
+
},
|
|
2268
|
+
/* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null)
|
|
2269
|
+
));
|
|
2270
|
+
};
|
|
2271
|
+
if (pathname !== `/${initialPath}`) {
|
|
2272
|
+
window.location.replace(initialPath);
|
|
2273
|
+
return;
|
|
2274
|
+
} else {
|
|
2275
|
+
const el = document.getElementById("root");
|
|
2276
|
+
if (!el)
|
|
2277
|
+
throw new Error("No root element");
|
|
2278
|
+
const root = ReactDOM.createRoot(el);
|
|
2279
|
+
root.render(/* @__PURE__ */ import_react10.default.createElement(RouterProvider, null));
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
// pkgs/@akanjs/next/src/useCamera.tsx
|
|
2284
|
+
var import_camera = __require("@capacitor/camera");
|
|
2285
|
+
var import_react11 = __require("react");
|
|
2286
|
+
var useCamera = () => {
|
|
2287
|
+
const [permissions, setPermissions] = (0, import_react11.useState)({ camera: "prompt", photos: "prompt" });
|
|
2288
|
+
const checkPermission = async (type) => {
|
|
2289
|
+
try {
|
|
2290
|
+
if (type === "photos") {
|
|
2291
|
+
if (permissions.photos === "prompt") {
|
|
2292
|
+
const { photos } = await import_camera.Camera.requestPermissions();
|
|
2293
|
+
setPermissions((prev) => ({ ...prev, photos }));
|
|
2294
|
+
} else if (permissions.photos === "denied") {
|
|
2295
|
+
location.assign("app-settings:");
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
} else if (type === "camera") {
|
|
2299
|
+
if (permissions.camera === "prompt") {
|
|
2300
|
+
const { camera } = await import_camera.Camera.requestPermissions();
|
|
2301
|
+
setPermissions((prev) => ({ ...prev, camera }));
|
|
2302
|
+
} else if (permissions.camera === "denied") {
|
|
2303
|
+
location.assign("app-settings:");
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
} else {
|
|
2307
|
+
if (permissions.camera === "prompt" || permissions.photos === "prompt") {
|
|
2308
|
+
const permissions2 = await import_camera.Camera.requestPermissions();
|
|
2309
|
+
setPermissions(permissions2);
|
|
2310
|
+
} else if (permissions.camera === "denied" || permissions.photos === "denied") {
|
|
2311
|
+
location.assign("app-settings:");
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
} catch (e) {
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
const getPhoto = async (src = "prompt") => {
|
|
2319
|
+
const source = device.info.platform !== "web" ? src === "prompt" ? import_camera.CameraSource.Prompt : src === "camera" ? import_camera.CameraSource.Camera : import_camera.CameraSource.Photos : import_camera.CameraSource.Photos;
|
|
2320
|
+
const permission = src === "prompt" ? "all" : src === "camera" ? "camera" : "photos";
|
|
2321
|
+
void checkPermission(permission);
|
|
2322
|
+
try {
|
|
2323
|
+
const photo = await import_camera.Camera.getPhoto({
|
|
2324
|
+
quality: 100,
|
|
2325
|
+
source,
|
|
2326
|
+
allowEditing: false,
|
|
2327
|
+
resultType: import_camera.CameraResultType.DataUrl,
|
|
2328
|
+
promptLabelHeader: "\uD504\uB85C\uD544 \uC0AC\uC9C4\uC744 \uC62C\uB824\uC8FC\uC138\uC694",
|
|
2329
|
+
promptLabelPhoto: "\uC568\uBC94\uC5D0\uC11C \uC120\uD0DD\uD558\uAE30",
|
|
2330
|
+
promptLabelPicture: "\uC0AC\uC9C4 \uCC0D\uAE30",
|
|
2331
|
+
promptLabelCancel: "\uCDE8\uC18C"
|
|
2332
|
+
});
|
|
2333
|
+
return photo;
|
|
2334
|
+
} catch (e) {
|
|
2335
|
+
if (e === "User cancelled photos app")
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
const pickImage = async () => {
|
|
2340
|
+
void checkPermission("photos");
|
|
2341
|
+
const photo = await import_camera.Camera.pickImages({
|
|
2342
|
+
quality: 90
|
|
2343
|
+
});
|
|
2344
|
+
return photo;
|
|
2345
|
+
};
|
|
2346
|
+
(0, import_react11.useEffect)(() => {
|
|
2347
|
+
void (async () => {
|
|
2348
|
+
if (device.info.platform !== "web") {
|
|
2349
|
+
const permissions2 = await import_camera.Camera.checkPermissions();
|
|
2350
|
+
setPermissions(permissions2);
|
|
2351
|
+
}
|
|
2352
|
+
})();
|
|
2353
|
+
}, []);
|
|
2354
|
+
return { permissions, getPhoto, pickImage, checkPermission };
|
|
2355
|
+
};
|
|
2356
|
+
|
|
2357
|
+
// pkgs/@akanjs/next/src/useContact.tsx
|
|
2358
|
+
var import_contacts = __require("@capacitor-community/contacts");
|
|
2359
|
+
var import_react12 = __require("react");
|
|
2360
|
+
var useContact = () => {
|
|
2361
|
+
const [permissions, setPermissions] = (0, import_react12.useState)({ contacts: "prompt" });
|
|
2362
|
+
const checkPermission = async () => {
|
|
2363
|
+
try {
|
|
2364
|
+
if (permissions.contacts === "prompt") {
|
|
2365
|
+
const { contacts } = await import_contacts.Contacts.requestPermissions();
|
|
2366
|
+
setPermissions((prev) => ({ ...prev, contacts }));
|
|
2367
|
+
} else if (permissions.contacts === "denied") {
|
|
2368
|
+
location.assign("app-settings:");
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
} catch (e) {
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
const getContacts = async () => {
|
|
2375
|
+
await checkPermission();
|
|
2376
|
+
const { contacts } = await import_contacts.Contacts.getContacts({ projection: { name: true, phones: true } });
|
|
2377
|
+
return contacts;
|
|
2378
|
+
};
|
|
2379
|
+
(0, import_react12.useEffect)(() => {
|
|
2380
|
+
void (async () => {
|
|
2381
|
+
if (device.info.platform === "web")
|
|
2382
|
+
return;
|
|
2383
|
+
const permissions2 = await import_contacts.Contacts.checkPermissions();
|
|
2384
|
+
setPermissions(permissions2);
|
|
2385
|
+
})();
|
|
2386
|
+
}, []);
|
|
2387
|
+
return { permissions, getContacts, checkPermission };
|
|
2388
|
+
};
|
|
2389
|
+
|
|
2390
|
+
// pkgs/@akanjs/next/src/usePushNoti.tsx
|
|
2391
|
+
var import_device2 = __require("@capacitor/device");
|
|
2392
|
+
var import_push_notifications = __require("@capacitor/push-notifications");
|
|
2393
|
+
var import_fcm = __require("@capacitor-community/fcm");
|
|
2394
|
+
var usePushNoti = () => {
|
|
2395
|
+
const init = async () => {
|
|
2396
|
+
const device2 = await import_device2.Device.getInfo();
|
|
2397
|
+
if (device2.platform === "web")
|
|
2398
|
+
return;
|
|
2399
|
+
void import_fcm.FCM.setAutoInit({ enabled: true });
|
|
2400
|
+
void import_push_notifications.PushNotifications.requestPermissions().then(async (result) => {
|
|
2401
|
+
if (result.receive === "granted") {
|
|
2402
|
+
await import_push_notifications.PushNotifications.register();
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
};
|
|
2406
|
+
const checkPermission = async () => {
|
|
2407
|
+
const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
|
|
2408
|
+
return receive === "granted";
|
|
2409
|
+
};
|
|
2410
|
+
const register = async () => {
|
|
2411
|
+
const device2 = await import_device2.Device.getInfo();
|
|
2412
|
+
if (device2.platform === "web")
|
|
2413
|
+
return;
|
|
2414
|
+
const { receive } = await import_push_notifications.PushNotifications.checkPermissions();
|
|
2415
|
+
if (receive === "denied")
|
|
2416
|
+
location.assign("app-settings:");
|
|
2417
|
+
else
|
|
2418
|
+
await import_push_notifications.PushNotifications.register();
|
|
2419
|
+
};
|
|
2420
|
+
const getToken = async () => {
|
|
2421
|
+
const device2 = await import_device2.Device.getInfo();
|
|
2422
|
+
if (device2.platform === "web")
|
|
2423
|
+
return;
|
|
2424
|
+
const { token } = await import_fcm.FCM.getToken();
|
|
2425
|
+
return token;
|
|
2426
|
+
};
|
|
2427
|
+
return { init, checkPermission, register, getToken };
|
|
2428
|
+
};
|
|
2429
|
+
|
|
2430
|
+
// pkgs/@akanjs/next/src/useGeoLocation.tsx
|
|
2431
|
+
var import_geolocation = __require("@capacitor/geolocation");
|
|
2432
|
+
var useGeoLocation = () => {
|
|
2433
|
+
const checkPermission = async () => {
|
|
2434
|
+
const { location: geolocation, coarseLocation } = await import_geolocation.Geolocation.requestPermissions();
|
|
2435
|
+
return { geolocation, coarseLocation };
|
|
2436
|
+
};
|
|
2437
|
+
const getPosition = async () => {
|
|
2438
|
+
const { geolocation, coarseLocation } = await checkPermission();
|
|
2439
|
+
if (geolocation === "denied" || coarseLocation === "denied") {
|
|
2440
|
+
location.assign("app-settings:");
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
const coordinates = await import_geolocation.Geolocation.getCurrentPosition();
|
|
2444
|
+
return coordinates;
|
|
2445
|
+
};
|
|
2446
|
+
return { checkPermission, getPosition };
|
|
2447
|
+
};
|
|
2448
|
+
|
|
2449
|
+
// pkgs/@akanjs/next/src/useCodepush.tsx
|
|
2450
|
+
var import_app2 = __require("@capacitor/app");
|
|
2451
|
+
var import_device3 = __require("@capacitor/device");
|
|
2452
|
+
var import_capacitor_updater = __require("@capgo/capacitor-updater");
|
|
2453
|
+
var import_axios = __toESM(__require("axios"));
|
|
2454
|
+
var import_react13 = __require("react");
|
|
2455
|
+
var useCodepush = ({ serverUrl, branch }) => {
|
|
2456
|
+
const [update, setUpdate] = (0, import_react13.useState)(false);
|
|
2457
|
+
const [version2, setVersion] = (0, import_react13.useState)("");
|
|
2458
|
+
const initialize = async () => {
|
|
2459
|
+
await import_capacitor_updater.CapacitorUpdater.notifyAppReady();
|
|
2460
|
+
};
|
|
2461
|
+
const checkNewRelease = async () => {
|
|
2462
|
+
const info = await import_device3.Device.getInfo();
|
|
2463
|
+
const app = await import_app2.App.getInfo();
|
|
2464
|
+
const pluginVersion = await import_capacitor_updater.CapacitorUpdater.getPluginVersion();
|
|
2465
|
+
const { deviceId } = await import_capacitor_updater.CapacitorUpdater.getDeviceId();
|
|
2466
|
+
const { bundle: version3, native } = await import_capacitor_updater.CapacitorUpdater.current();
|
|
2467
|
+
const builtInversion = await import_capacitor_updater.CapacitorUpdater.getBuiltinVersion();
|
|
2468
|
+
const appId = app.id;
|
|
2469
|
+
const platform = info.platform;
|
|
2470
|
+
window.alert(
|
|
2471
|
+
`getBuildinVersion:${builtInversion.version}
|
|
2472
|
+
current.bundle:${version3.version}
|
|
2473
|
+
currennt.native:${native}`
|
|
2474
|
+
);
|
|
2475
|
+
const { major, minor, patch } = splitVersion(version3.version === "builtin" ? app.version : version3.version);
|
|
2476
|
+
const appName2 = process.env.NEXT_PUBLIC_APP_NAME ?? "";
|
|
2477
|
+
const appInfo = {
|
|
2478
|
+
appId,
|
|
2479
|
+
appName: appName2,
|
|
2480
|
+
deviceId,
|
|
2481
|
+
platform,
|
|
2482
|
+
branch,
|
|
2483
|
+
isEmulator: info.isVirtual,
|
|
2484
|
+
major: parseInt(major),
|
|
2485
|
+
minor: parseInt(minor),
|
|
2486
|
+
patch: parseInt(patch),
|
|
2487
|
+
buildNum: app.build,
|
|
2488
|
+
//앱내 빌드시 버전 횟수 모르면 고한테 물어보기
|
|
2489
|
+
versionOs: info.osVersion
|
|
2490
|
+
};
|
|
2491
|
+
const url = serverUrl.replace("lu", "akasys");
|
|
2492
|
+
const release = (await import_axios.default.post(`${url}/release/codepush`, {
|
|
2493
|
+
data: { ...appInfo }
|
|
2494
|
+
})).data;
|
|
2495
|
+
if (!release)
|
|
2496
|
+
return;
|
|
2497
|
+
const file = (await import_axios.default.get(`${url}/file/file/${release.appBuild}`)).data;
|
|
2498
|
+
return { release, bundleFile: file };
|
|
2499
|
+
};
|
|
2500
|
+
const codepush = async () => {
|
|
2501
|
+
const isNewRelease = await checkNewRelease();
|
|
2502
|
+
if (!isNewRelease)
|
|
2503
|
+
return;
|
|
2504
|
+
const { release, bundleFile } = isNewRelease;
|
|
2505
|
+
setUpdate(true);
|
|
2506
|
+
const bundle = await import_capacitor_updater.CapacitorUpdater.download({
|
|
2507
|
+
url: bundleFile.url,
|
|
2508
|
+
version: mergeVersion(release.major, release.minor, release.patch)
|
|
2509
|
+
});
|
|
2510
|
+
await import_capacitor_updater.CapacitorUpdater.set(bundle);
|
|
2511
|
+
};
|
|
2512
|
+
const getVersion = async () => {
|
|
2513
|
+
return await import_capacitor_updater.CapacitorUpdater.getBuiltinVersion();
|
|
2514
|
+
};
|
|
2515
|
+
const statManager = async () => {
|
|
2516
|
+
};
|
|
2517
|
+
return { update, version: version2, initialize, checkNewRelease, codepush, statManager };
|
|
2518
|
+
};
|
|
2519
|
+
|
|
2520
|
+
// pkgs/@akanjs/next/src/usePurchase.tsx
|
|
2521
|
+
var import_store = __require("cordova-plugin-purchase/www/store");
|
|
2522
|
+
var import_app3 = __require("@capacitor/app");
|
|
2523
|
+
var import_react14 = __require("react");
|
|
2524
|
+
var usePurchase = ({
|
|
2525
|
+
platform,
|
|
2526
|
+
productInfo,
|
|
2527
|
+
url,
|
|
2528
|
+
onPay,
|
|
2529
|
+
onSubscribe
|
|
2530
|
+
}) => {
|
|
2531
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
|
|
2532
|
+
const billingRef = (0, import_react14.useRef)();
|
|
2533
|
+
(0, import_react14.useEffect)(() => {
|
|
2534
|
+
const init = async () => {
|
|
2535
|
+
if (CdvPurchase.store.isReady) {
|
|
2536
|
+
setIsLoading(false);
|
|
2537
|
+
return;
|
|
2538
|
+
}
|
|
2539
|
+
const app = await import_app3.App.getInfo();
|
|
2540
|
+
if (platform === "all")
|
|
2541
|
+
CdvPurchase.store.register([
|
|
2542
|
+
...productInfo.map((prouct) => ({
|
|
2543
|
+
id: prouct.id,
|
|
2544
|
+
platform: CdvPurchase.Platform.GOOGLE_PLAY,
|
|
2545
|
+
type: CdvPurchase.ProductType[prouct.type]
|
|
2546
|
+
})),
|
|
2547
|
+
...productInfo.map((prouct) => ({
|
|
2548
|
+
id: prouct.id,
|
|
2549
|
+
platform: CdvPurchase.Platform.APPLE_APPSTORE,
|
|
2550
|
+
type: CdvPurchase.ProductType[prouct.type]
|
|
2551
|
+
}))
|
|
2552
|
+
]);
|
|
2553
|
+
else
|
|
2554
|
+
CdvPurchase.store.register(
|
|
2555
|
+
productInfo.map((product) => ({
|
|
2556
|
+
id: product.id,
|
|
2557
|
+
platform: platform === "android" ? CdvPurchase.Platform.GOOGLE_PLAY : CdvPurchase.Platform.APPLE_APPSTORE,
|
|
2558
|
+
type: CdvPurchase.ProductType[product.type]
|
|
2559
|
+
}))
|
|
2560
|
+
);
|
|
2561
|
+
await CdvPurchase.store.initialize([
|
|
2562
|
+
{ platform: CdvPurchase.Platform.APPLE_APPSTORE, options: { needAppReceipt: false } },
|
|
2563
|
+
{ platform: CdvPurchase.Platform.GOOGLE_PLAY }
|
|
2564
|
+
]);
|
|
2565
|
+
await CdvPurchase.store.update();
|
|
2566
|
+
await CdvPurchase.store.restorePurchases();
|
|
2567
|
+
CdvPurchase.store.validator = async (request, callback) => {
|
|
2568
|
+
const transactionId = request.transaction.id;
|
|
2569
|
+
const transactions = CdvPurchase.store.localTransactions;
|
|
2570
|
+
const verifingTransaction = transactions.find((transaction) => transaction.transactionId === transactionId);
|
|
2571
|
+
if (verifingTransaction?.state !== "approved")
|
|
2572
|
+
return;
|
|
2573
|
+
const billing = await fetch(`${url}/billing/verifyBilling`, {
|
|
2574
|
+
method: "POST",
|
|
2575
|
+
headers: {
|
|
2576
|
+
"Content-Type": "application/json"
|
|
2577
|
+
},
|
|
2578
|
+
body: JSON.stringify({
|
|
2579
|
+
data: {
|
|
2580
|
+
platform: verifingTransaction.platform === CdvPurchase.Platform.GOOGLE_PLAY ? "google" : "apple",
|
|
2581
|
+
packageName: app.id,
|
|
2582
|
+
productId: verifingTransaction.products[0].id,
|
|
2583
|
+
receipt: verifingTransaction.platform === CdvPurchase.Platform.GOOGLE_PLAY ? request.transaction.purchaseToken : request.transaction.appStoreReceipt,
|
|
2584
|
+
transactionId: verifingTransaction.transactionId
|
|
2585
|
+
}
|
|
2586
|
+
})
|
|
2587
|
+
});
|
|
2588
|
+
billingRef.current = billing.json();
|
|
2589
|
+
callback({
|
|
2590
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2591
|
+
ok: billing ? true : false,
|
|
2592
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2593
|
+
data: { id: request.id, latest_receipt: true, transaction: request.transaction }
|
|
2594
|
+
});
|
|
2595
|
+
};
|
|
2596
|
+
if (CdvPurchase.store.localReceipts.length > 0) {
|
|
2597
|
+
CdvPurchase.store.localReceipts.forEach((receipt) => {
|
|
2598
|
+
if (receipt.platform === CdvPurchase.Platform.GOOGLE_PLAY)
|
|
2599
|
+
if (receipt.transactions[0].state === CdvPurchase.TransactionState.APPROVED)
|
|
2600
|
+
void receipt.transactions[0].verify();
|
|
2601
|
+
else
|
|
2602
|
+
void receipt.transactions[0].finish();
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
CdvPurchase.store.when().approved((transaction) => {
|
|
2606
|
+
void transaction.verify();
|
|
2607
|
+
}).verified((receipt) => {
|
|
2608
|
+
void receipt.finish();
|
|
2609
|
+
}).finished((transaction) => {
|
|
2610
|
+
void inAppPurchase(transaction);
|
|
2611
|
+
});
|
|
2612
|
+
setIsLoading(false);
|
|
2613
|
+
};
|
|
2614
|
+
void init();
|
|
2615
|
+
}, []);
|
|
2616
|
+
const purchaseProduct = async (product) => {
|
|
2617
|
+
await product.getOffer()?.order();
|
|
2618
|
+
};
|
|
2619
|
+
const restorePurchases = async () => {
|
|
2620
|
+
await CdvPurchase.store.restorePurchases();
|
|
2621
|
+
};
|
|
2622
|
+
const inAppPurchase = async (transaction) => {
|
|
2623
|
+
const product = CdvPurchase.store.get(transaction.products[0].id);
|
|
2624
|
+
if (product?.type === "consumable")
|
|
2625
|
+
await onPay?.(transaction);
|
|
2626
|
+
else
|
|
2627
|
+
await onSubscribe?.(transaction);
|
|
2628
|
+
await transaction.finish();
|
|
2629
|
+
};
|
|
2630
|
+
return {
|
|
2631
|
+
isLoading,
|
|
2632
|
+
products: CdvPurchase.store.products,
|
|
2633
|
+
purchaseProduct,
|
|
2634
|
+
restorePurchases
|
|
2635
|
+
};
|
|
2636
|
+
};
|
|
2637
|
+
|
|
2638
|
+
// pkgs/@akanjs/next/src/createRobotPage.ts
|
|
2639
|
+
var createRobotPage = (clientHttpUri2, config) => {
|
|
2640
|
+
return {
|
|
2641
|
+
...config ?? {},
|
|
2642
|
+
rules: {
|
|
2643
|
+
userAgent: "*",
|
|
2644
|
+
allow: "/",
|
|
2645
|
+
disallow: "/admin/",
|
|
2646
|
+
...config?.rules ?? {}
|
|
2647
|
+
},
|
|
2648
|
+
sitemap: `${clientHttpUri2}/sitemap.xml`
|
|
2649
|
+
};
|
|
2650
|
+
};
|
|
2651
|
+
|
|
2652
|
+
// pkgs/@akanjs/next/src/createSitemapPage.ts
|
|
2653
|
+
var lastModified = /* @__PURE__ */ new Date();
|
|
2654
|
+
var createSitemapPage = (clientHttpUri2, paths) => {
|
|
2655
|
+
return paths.map((path) => ({ url: `${clientHttpUri2}${path}`, lastModified }));
|
|
2656
|
+
};
|
|
2657
|
+
|
|
2658
|
+
// pkgs/@akanjs/next/src/createNextMiddleware.ts
|
|
2659
|
+
var import_intl_localematcher = __require("@formatjs/intl-localematcher");
|
|
2660
|
+
var import_negotiator = __toESM(__require("negotiator"));
|
|
2661
|
+
var import_server = __require("next/server");
|
|
2662
|
+
var i18n = { defaultLocale: "en", locales: ["en", "ko"] };
|
|
2663
|
+
var basePaths = process.env.basePaths ? process.env.basePaths.split(",") : [];
|
|
2664
|
+
function getLocale(request) {
|
|
2665
|
+
if (!request.headers.get("accept-language"))
|
|
2666
|
+
return i18n.defaultLocale;
|
|
2667
|
+
const negotiatorHeaders = {};
|
|
2668
|
+
request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
2669
|
+
try {
|
|
2670
|
+
const languages = new import_negotiator.default({ headers: negotiatorHeaders }).languages();
|
|
2671
|
+
return (0, import_intl_localematcher.match)(languages, i18n.locales, i18n.defaultLocale);
|
|
2672
|
+
} catch (e) {
|
|
2673
|
+
return i18n.defaultLocale;
|
|
2674
|
+
}
|
|
10
2675
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2676
|
+
var createNextMiddleware = () => {
|
|
2677
|
+
Logger.rawLog(logo, "console");
|
|
2678
|
+
const middleware = (request) => {
|
|
2679
|
+
const pathname = request.nextUrl.pathname;
|
|
2680
|
+
const pathnameIsMissingLocale = i18n.locales.every(
|
|
2681
|
+
(locale2) => !pathname.startsWith(`/${locale2}/`) && pathname !== `/${locale2}`
|
|
2682
|
+
);
|
|
2683
|
+
if (pathnameIsMissingLocale)
|
|
2684
|
+
return import_server.NextResponse.redirect(
|
|
2685
|
+
new URL(`/${getLocale(request)}/${request.nextUrl.href.split("/").slice(3).join("/")}`, request.url)
|
|
2686
|
+
);
|
|
2687
|
+
const splits = pathname.split("/");
|
|
2688
|
+
const locale = splits[1];
|
|
2689
|
+
const basePath = basePaths.includes(splits[2]) ? splits[2] : null;
|
|
2690
|
+
const headers2 = new Headers(request.headers);
|
|
2691
|
+
const searchParams = new URLSearchParams(request.nextUrl.search);
|
|
2692
|
+
const searchParamJwt = searchParams.get("jwt");
|
|
2693
|
+
headers2.set("x-locale", locale);
|
|
2694
|
+
headers2.set("x-path", "/" + splits.slice(2).join("/"));
|
|
2695
|
+
if (basePath)
|
|
2696
|
+
headers2.set("x-base-path", basePath);
|
|
2697
|
+
if (searchParamJwt)
|
|
2698
|
+
headers2.set("jwt", searchParamJwt);
|
|
2699
|
+
return import_server.NextResponse.next({ request: { headers: headers2 } });
|
|
2700
|
+
};
|
|
2701
|
+
return middleware;
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
// pkgs/@akanjs/next/src/useThrottle.ts
|
|
2705
|
+
var import_react15 = __require("react");
|
|
2706
|
+
var useThrottle = (func, delay = 200, deps = []) => {
|
|
2707
|
+
const throttleSeed = (0, import_react15.useRef)(null);
|
|
2708
|
+
const throttleFunction = (0, import_react15.useCallback)(
|
|
2709
|
+
(...args) => {
|
|
2710
|
+
if (throttleSeed.current)
|
|
2711
|
+
return;
|
|
2712
|
+
func(...args);
|
|
2713
|
+
throttleSeed.current = setTimeout(() => {
|
|
2714
|
+
throttleSeed.current = null;
|
|
2715
|
+
}, delay);
|
|
2716
|
+
},
|
|
2717
|
+
[func, delay, ...deps]
|
|
2718
|
+
);
|
|
2719
|
+
return throttleFunction;
|
|
2720
|
+
};
|
|
2721
|
+
})();
|
|
2722
|
+
//! next build를 위해서 lint 무시
|
|
2723
|
+
//! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
|
|
2724
|
+
//! PageAgent csr에서 말썽 일으킨다
|