@lark-apaas/client-toolkit-lite 1.1.7-alpha.7 → 1.1.7-alpha.9
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/dist/index.cjs +863 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -4
- package/dist/index.d.ts +65 -4
- package/dist/index.js +906 -155
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ var index_exports = {};
|
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
ActiveLink: () => ActiveLink,
|
|
35
35
|
AppContainer: () => AppContainer_default,
|
|
36
|
+
ErrorRender: () => ErrorRender_default,
|
|
36
37
|
NavLink: () => NavLink2,
|
|
37
38
|
PagePlaceholder: () => PagePlaceholder_default,
|
|
38
39
|
QueryProvider: () => QueryProvider_default,
|
|
@@ -59,6 +60,7 @@ __export(index_exports, {
|
|
|
59
60
|
isIpad: () => isIpad,
|
|
60
61
|
isMobile: () => isMobile,
|
|
61
62
|
isPreview: () => isPreview,
|
|
63
|
+
logger: () => logger,
|
|
62
64
|
normalizeBasePath: () => normalizeBasePath,
|
|
63
65
|
reportTeaEvent: () => reportTeaEvent,
|
|
64
66
|
resolveAppUrl: () => resolveAppUrl,
|
|
@@ -72,7 +74,7 @@ __export(index_exports, {
|
|
|
72
74
|
module.exports = __toCommonJS(index_exports);
|
|
73
75
|
|
|
74
76
|
// src/components/AppContainer/index.tsx
|
|
75
|
-
var
|
|
77
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
76
78
|
var import_miaoda_inspector = require("@lark-apaas/miaoda-inspector");
|
|
77
79
|
|
|
78
80
|
// src/runtime/react-devtools-hook.ts
|
|
@@ -129,15 +131,15 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
129
131
|
if (!axiosInstance2) {
|
|
130
132
|
axiosInstance2 = import_axios.default;
|
|
131
133
|
}
|
|
132
|
-
axiosInstance2.interceptors.request.use((
|
|
134
|
+
axiosInstance2.interceptors.request.use((config2) => {
|
|
133
135
|
const csrfToken = getCsrfToken();
|
|
134
136
|
if (csrfToken) {
|
|
135
|
-
|
|
137
|
+
config2.headers["X-Suda-Csrf-Token"] = csrfToken;
|
|
136
138
|
}
|
|
137
139
|
if (typeof window !== "undefined") {
|
|
138
|
-
|
|
140
|
+
config2.headers["X-Page-Route"] = window.location.pathname;
|
|
139
141
|
}
|
|
140
|
-
return
|
|
142
|
+
return config2;
|
|
141
143
|
}, (error) => Promise.reject(error));
|
|
142
144
|
axiosInstance2.interceptors.response.use((response) => response, (error) => {
|
|
143
145
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -148,10 +150,694 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
148
150
|
}
|
|
149
151
|
__name(initAxiosConfig, "initAxiosConfig");
|
|
150
152
|
|
|
153
|
+
// src/logger/logger.ts
|
|
154
|
+
var import_observable_web = require("@lark-apaas/observable-web");
|
|
155
|
+
|
|
156
|
+
// src/utils/hmr-api.ts
|
|
157
|
+
var import_meta = {};
|
|
158
|
+
function createWebpackHmrApi(hot) {
|
|
159
|
+
return {
|
|
160
|
+
onSuccess(callback) {
|
|
161
|
+
let lastStatus = null;
|
|
162
|
+
const handler = /* @__PURE__ */ __name((status) => {
|
|
163
|
+
if (status === "idle" && lastStatus === "apply") {
|
|
164
|
+
try {
|
|
165
|
+
callback();
|
|
166
|
+
} catch (e) {
|
|
167
|
+
console.error("[HMR] Success callback error:", e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
lastStatus = status;
|
|
171
|
+
}, "handler");
|
|
172
|
+
hot.addStatusHandler(handler);
|
|
173
|
+
return () => hot.removeStatusHandler(handler);
|
|
174
|
+
},
|
|
175
|
+
onError(callback) {
|
|
176
|
+
const handler = /* @__PURE__ */ __name((status) => {
|
|
177
|
+
if (status === "fail" || status === "abort") {
|
|
178
|
+
try {
|
|
179
|
+
callback(new Error(`HMR ${status}`));
|
|
180
|
+
} catch (e) {
|
|
181
|
+
console.error("[HMR] Error callback error:", e);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, "handler");
|
|
185
|
+
hot.addStatusHandler(handler);
|
|
186
|
+
return () => hot.removeStatusHandler(handler);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
__name(createWebpackHmrApi, "createWebpackHmrApi");
|
|
191
|
+
function getHmrApi() {
|
|
192
|
+
if (process.env.NODE_ENV === "production") return null;
|
|
193
|
+
if (import_meta.webpackHot) {
|
|
194
|
+
return createWebpackHmrApi(import_meta.webpackHot);
|
|
195
|
+
}
|
|
196
|
+
if (typeof module !== "undefined" && module.hot) {
|
|
197
|
+
return createWebpackHmrApi(module.hot);
|
|
198
|
+
}
|
|
199
|
+
if (window.__VITE_HMR__) {
|
|
200
|
+
return window.__VITE_HMR__;
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
__name(getHmrApi, "getHmrApi");
|
|
205
|
+
|
|
206
|
+
// src/utils/postMessage.ts
|
|
207
|
+
var PARENT_ORIGIN_KEY = "__parentOrigin";
|
|
208
|
+
function getParentOriginFromParams() {
|
|
209
|
+
try {
|
|
210
|
+
const params = new URLSearchParams(window.location.search);
|
|
211
|
+
const origin = params.get(PARENT_ORIGIN_KEY);
|
|
212
|
+
if (origin) {
|
|
213
|
+
sessionStorage.setItem(PARENT_ORIGIN_KEY, origin);
|
|
214
|
+
return origin;
|
|
215
|
+
}
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
return sessionStorage.getItem(PARENT_ORIGIN_KEY) || void 0;
|
|
220
|
+
} catch {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
__name(getParentOriginFromParams, "getParentOriginFromParams");
|
|
225
|
+
function getLegacyParentOrigin() {
|
|
226
|
+
const { origin } = window.location;
|
|
227
|
+
if (origin.includes("force.feishuapp.net")) {
|
|
228
|
+
return "https://force.feishu.cn";
|
|
229
|
+
}
|
|
230
|
+
if (origin.includes("force-pre.feishuapp.net")) {
|
|
231
|
+
return "https://force.feishu-pre.cn";
|
|
232
|
+
}
|
|
233
|
+
if (origin.includes("force.byted.org")) {
|
|
234
|
+
return "https://force.feishu-boe.cn";
|
|
235
|
+
}
|
|
236
|
+
if (origin.includes("feishuapp.cn") || origin.includes("miaoda.feishuapp.net")) {
|
|
237
|
+
return "https://miaoda.feishu.cn";
|
|
238
|
+
}
|
|
239
|
+
if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
|
|
240
|
+
return "https://miaoda.feishu-pre.cn";
|
|
241
|
+
}
|
|
242
|
+
return "https://miaoda.feishu-boe.cn";
|
|
243
|
+
}
|
|
244
|
+
__name(getLegacyParentOrigin, "getLegacyParentOrigin");
|
|
245
|
+
function resolveParentOrigin() {
|
|
246
|
+
try {
|
|
247
|
+
if (document.referrer) {
|
|
248
|
+
const referrerOrigin = new URL(document.referrer).origin;
|
|
249
|
+
if (referrerOrigin.startsWith("http://localhost") || referrerOrigin.startsWith("http://127.0.0.1")) {
|
|
250
|
+
return referrerOrigin;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
} catch {
|
|
254
|
+
}
|
|
255
|
+
const paramOrigin = getParentOriginFromParams();
|
|
256
|
+
if (paramOrigin) return paramOrigin;
|
|
257
|
+
return process.env?.FORCE_FRAMEWORK_DOMAIN_MAIN ?? getLegacyParentOrigin();
|
|
258
|
+
}
|
|
259
|
+
__name(resolveParentOrigin, "resolveParentOrigin");
|
|
260
|
+
function submitPostMessage(message, targetOrigin) {
|
|
261
|
+
try {
|
|
262
|
+
const parentOrigin = resolveParentOrigin();
|
|
263
|
+
const origin = targetOrigin ?? parentOrigin;
|
|
264
|
+
if (!origin) return;
|
|
265
|
+
window.parent.postMessage(message, origin);
|
|
266
|
+
} catch (e) {
|
|
267
|
+
console.error("postMessage error", e);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
__name(submitPostMessage, "submitPostMessage");
|
|
271
|
+
|
|
272
|
+
// src/logger/log-types.ts
|
|
273
|
+
var LOG_LEVELS = [
|
|
274
|
+
"debug",
|
|
275
|
+
"info",
|
|
276
|
+
"warn",
|
|
277
|
+
"error",
|
|
278
|
+
"success"
|
|
279
|
+
];
|
|
280
|
+
function isLogLevel(value) {
|
|
281
|
+
return typeof value === "string" && LOG_LEVELS.includes(value);
|
|
282
|
+
}
|
|
283
|
+
__name(isLogLevel, "isLogLevel");
|
|
284
|
+
|
|
285
|
+
// src/logger/intercept-global-error.ts
|
|
286
|
+
var devServerDisconnectInfo = null;
|
|
287
|
+
var retryCount = 0;
|
|
288
|
+
function processDevServerLog(log) {
|
|
289
|
+
if (!log) return;
|
|
290
|
+
const devFlag = log.includes("[webpack-dev-server]") || log.includes("[vite]");
|
|
291
|
+
if (devFlag && log.includes("Disconnected")) {
|
|
292
|
+
const time = Date.now();
|
|
293
|
+
devServerDisconnectInfo = {
|
|
294
|
+
time
|
|
295
|
+
};
|
|
296
|
+
submitPostMessage({
|
|
297
|
+
type: "DevServerMessage",
|
|
298
|
+
data: {
|
|
299
|
+
type: "devServer-status",
|
|
300
|
+
status: "disconnected"
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (!devServerDisconnectInfo) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (devFlag && log.includes("Trying to reconnect")) {
|
|
309
|
+
retryCount++;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const hmrFlag = log.includes("[HMR]");
|
|
313
|
+
if (hmrFlag || devFlag && (log.includes("Socket connected") || log.includes("App updated") || log.includes("App hot update") || log.includes("connected"))) {
|
|
314
|
+
submitPostMessage({
|
|
315
|
+
type: "DevServerMessage",
|
|
316
|
+
data: {
|
|
317
|
+
type: "devServer-status",
|
|
318
|
+
status: "connected"
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
devServerDisconnectInfo = null;
|
|
322
|
+
retryCount = 0;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
__name(processDevServerLog, "processDevServerLog");
|
|
326
|
+
function listenModuleHmr() {
|
|
327
|
+
const hmr = getHmrApi();
|
|
328
|
+
if (hmr) {
|
|
329
|
+
hmr.onSuccess(() => {
|
|
330
|
+
submitPostMessage({
|
|
331
|
+
type: "DevServerMessage",
|
|
332
|
+
data: {
|
|
333
|
+
type: "devServer-status",
|
|
334
|
+
status: "hmr-apply-success"
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
hmr.onError((error) => {
|
|
339
|
+
console.warn("hmr apply failed", error);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
__name(listenModuleHmr, "listenModuleHmr");
|
|
344
|
+
var PROXY_CONSOLE_METHOD = [
|
|
345
|
+
"log",
|
|
346
|
+
"info",
|
|
347
|
+
"warn",
|
|
348
|
+
"error"
|
|
349
|
+
];
|
|
350
|
+
function interceptErrors() {
|
|
351
|
+
window.addEventListener("error", (event) => {
|
|
352
|
+
logger.error(event.error);
|
|
353
|
+
});
|
|
354
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
355
|
+
logger.error(event.reason);
|
|
356
|
+
});
|
|
357
|
+
listenModuleHmr();
|
|
358
|
+
PROXY_CONSOLE_METHOD.forEach((method) => {
|
|
359
|
+
const originalMethod = window.console[method];
|
|
360
|
+
window.console[method] = (...args) => {
|
|
361
|
+
originalMethod(...args);
|
|
362
|
+
const level = method === "log" ? "info" : method;
|
|
363
|
+
const first = args[0];
|
|
364
|
+
if (typeof first === "string") {
|
|
365
|
+
processDevServerLog(first);
|
|
366
|
+
}
|
|
367
|
+
if (typeof first === "string" && first.startsWith("[Dataloom]") && isLogLevel(level)) {
|
|
368
|
+
logger.log({
|
|
369
|
+
level,
|
|
370
|
+
args
|
|
371
|
+
});
|
|
372
|
+
submitPostMessage({
|
|
373
|
+
type: "Console",
|
|
374
|
+
method,
|
|
375
|
+
data: args
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
__name(interceptErrors, "interceptErrors");
|
|
382
|
+
|
|
383
|
+
// src/utils/safeStringify.ts
|
|
384
|
+
function safeStringify(obj) {
|
|
385
|
+
const seen = /* @__PURE__ */ new Set();
|
|
386
|
+
try {
|
|
387
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
388
|
+
if (typeof value === "object" && value !== null) {
|
|
389
|
+
if (seen.has(value)) {
|
|
390
|
+
return "[Circular]";
|
|
391
|
+
}
|
|
392
|
+
seen.add(value);
|
|
393
|
+
}
|
|
394
|
+
if (typeof value === "bigint") {
|
|
395
|
+
return value.toString();
|
|
396
|
+
}
|
|
397
|
+
if (value instanceof Date) {
|
|
398
|
+
return value.toISOString();
|
|
399
|
+
}
|
|
400
|
+
if (value instanceof Map) {
|
|
401
|
+
return Object.fromEntries(value);
|
|
402
|
+
}
|
|
403
|
+
if (value instanceof Set) {
|
|
404
|
+
return Array.from(value);
|
|
405
|
+
}
|
|
406
|
+
if (value instanceof Error) {
|
|
407
|
+
return {
|
|
408
|
+
name: value.name,
|
|
409
|
+
message: value.message,
|
|
410
|
+
stack: value.stack
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (typeof value === "undefined") {
|
|
414
|
+
return "undefined";
|
|
415
|
+
}
|
|
416
|
+
if (typeof value === "symbol") {
|
|
417
|
+
return value.toString();
|
|
418
|
+
}
|
|
419
|
+
return value;
|
|
420
|
+
});
|
|
421
|
+
} catch {
|
|
422
|
+
return "";
|
|
423
|
+
} finally {
|
|
424
|
+
seen.clear();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
__name(safeStringify, "safeStringify");
|
|
428
|
+
function processLogParams(args) {
|
|
429
|
+
return args.map((arg) => {
|
|
430
|
+
if (typeof arg === "string") return arg;
|
|
431
|
+
if (arg instanceof Error) {
|
|
432
|
+
return `${arg.name}: ${arg.message}
|
|
433
|
+
${arg.stack ?? ""}`;
|
|
434
|
+
}
|
|
435
|
+
if (typeof arg === "object" && arg !== null) {
|
|
436
|
+
return safeStringify(arg);
|
|
437
|
+
}
|
|
438
|
+
return String(arg);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
__name(processLogParams, "processLogParams");
|
|
442
|
+
function mapLogLevel(level) {
|
|
443
|
+
if (level === "warn") return "WARN";
|
|
444
|
+
if (level === "error") return "ERROR";
|
|
445
|
+
return "INFO";
|
|
446
|
+
}
|
|
447
|
+
__name(mapLogLevel, "mapLogLevel");
|
|
448
|
+
|
|
449
|
+
// src/logger/logger.ts
|
|
450
|
+
var shouldReportToObservable = process.env.NODE_ENV === "production";
|
|
451
|
+
var ORDERED_LEVELS = [
|
|
452
|
+
"debug",
|
|
453
|
+
"info",
|
|
454
|
+
"warn",
|
|
455
|
+
"error"
|
|
456
|
+
];
|
|
457
|
+
var defaultConfig = {
|
|
458
|
+
showLevel: false,
|
|
459
|
+
showTimestamp: false,
|
|
460
|
+
level: "info",
|
|
461
|
+
prefix: ""
|
|
462
|
+
};
|
|
463
|
+
var config = {
|
|
464
|
+
...defaultConfig
|
|
465
|
+
};
|
|
466
|
+
function configureLogger(options) {
|
|
467
|
+
config = {
|
|
468
|
+
...defaultConfig,
|
|
469
|
+
...options
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
__name(configureLogger, "configureLogger");
|
|
473
|
+
function shouldLog(level) {
|
|
474
|
+
return ORDERED_LEVELS.indexOf(level) >= ORDERED_LEVELS.indexOf(config.level);
|
|
475
|
+
}
|
|
476
|
+
__name(shouldLog, "shouldLog");
|
|
477
|
+
function getFormattedPrefix(level) {
|
|
478
|
+
const parts = [];
|
|
479
|
+
if (config.prefix) {
|
|
480
|
+
parts.push(`[${config.prefix}]`);
|
|
481
|
+
}
|
|
482
|
+
if (config.showLevel) {
|
|
483
|
+
parts.push(`[${level.toUpperCase()}]`);
|
|
484
|
+
}
|
|
485
|
+
return parts;
|
|
486
|
+
}
|
|
487
|
+
__name(getFormattedPrefix, "getFormattedPrefix");
|
|
488
|
+
configureLogger({
|
|
489
|
+
showLevel: true,
|
|
490
|
+
showTimestamp: false,
|
|
491
|
+
level: process.env.NODE_ENV === "development" ? "debug" : "error",
|
|
492
|
+
prefix: "MiaoDa"
|
|
493
|
+
});
|
|
494
|
+
var logger = {
|
|
495
|
+
debug(message, ...args) {
|
|
496
|
+
if (shouldLog("debug")) {
|
|
497
|
+
console.log(...getFormattedPrefix("debug"), message, ...args);
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
info(message, ...args) {
|
|
501
|
+
if (shouldLog("info")) {
|
|
502
|
+
console.log(...getFormattedPrefix("info"), message, ...args);
|
|
503
|
+
}
|
|
504
|
+
if (shouldReportToObservable) {
|
|
505
|
+
import_observable_web.observable.log("INFO", processLogParams([
|
|
506
|
+
message,
|
|
507
|
+
...args
|
|
508
|
+
]).join(" "));
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
warn(message, ...args) {
|
|
512
|
+
if (shouldLog("warn")) {
|
|
513
|
+
console.log(...getFormattedPrefix("warn"), message, ...args);
|
|
514
|
+
}
|
|
515
|
+
if (shouldReportToObservable) {
|
|
516
|
+
import_observable_web.observable.log("WARN", processLogParams([
|
|
517
|
+
message,
|
|
518
|
+
...args
|
|
519
|
+
]).join(" "));
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
error(message, ...args) {
|
|
523
|
+
if (shouldLog("error")) {
|
|
524
|
+
console.error(...getFormattedPrefix("error"), message, ...args);
|
|
525
|
+
}
|
|
526
|
+
if (shouldReportToObservable) {
|
|
527
|
+
import_observable_web.observable.log("ERROR", processLogParams([
|
|
528
|
+
message,
|
|
529
|
+
...args
|
|
530
|
+
]).join(" "));
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
success(message, ...args) {
|
|
534
|
+
if (shouldLog("info")) {
|
|
535
|
+
console.log(...getFormattedPrefix("success"), message, ...args);
|
|
536
|
+
}
|
|
537
|
+
if (shouldReportToObservable) {
|
|
538
|
+
import_observable_web.observable.log("INFO", processLogParams([
|
|
539
|
+
message,
|
|
540
|
+
...args
|
|
541
|
+
]).join(" "));
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
log({ level, args }) {
|
|
545
|
+
if (shouldLog(level)) {
|
|
546
|
+
console.log(...getFormattedPrefix(level), ...args);
|
|
547
|
+
}
|
|
548
|
+
if (shouldReportToObservable && level !== "debug") {
|
|
549
|
+
import_observable_web.observable.log(mapLogLevel(level), processLogParams(args).join(" "));
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
if (process.env.NODE_ENV !== "production") {
|
|
554
|
+
window.__RUNTIME_LOGGER__ = {
|
|
555
|
+
get() {
|
|
556
|
+
return logger;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (process.env.NODE_ENV !== "production") {
|
|
561
|
+
interceptErrors();
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/runtime/iframe-bridge.ts
|
|
565
|
+
var import_penpal = require("penpal");
|
|
566
|
+
|
|
567
|
+
// src/logger/batch-logger.ts
|
|
568
|
+
var BatchLogger = class {
|
|
569
|
+
static {
|
|
570
|
+
__name(this, "BatchLogger");
|
|
571
|
+
}
|
|
572
|
+
config;
|
|
573
|
+
logQueue = [];
|
|
574
|
+
flushTimer = null;
|
|
575
|
+
isProcessing = false;
|
|
576
|
+
originConsole;
|
|
577
|
+
constructor(console1, config2) {
|
|
578
|
+
this.originConsole = {
|
|
579
|
+
...console1
|
|
580
|
+
};
|
|
581
|
+
const { userId = "", tenantId = "", appId = "" } = window || {};
|
|
582
|
+
this.config = {
|
|
583
|
+
userId,
|
|
584
|
+
tenantId,
|
|
585
|
+
appId,
|
|
586
|
+
// 需要加请求路径前缀
|
|
587
|
+
endpoint: (process.env.CLIENT_BASE_PATH || "") + "/dev/logs/collect-batch",
|
|
588
|
+
sizeThreshold: 20,
|
|
589
|
+
flushInterval: 1e3,
|
|
590
|
+
maxRetries: 3,
|
|
591
|
+
retryDelay: 500,
|
|
592
|
+
headers: {
|
|
593
|
+
"Content-Type": "application/json"
|
|
594
|
+
},
|
|
595
|
+
...config2 || {}
|
|
596
|
+
};
|
|
597
|
+
this.startFlushTimer();
|
|
598
|
+
this.setupBeforeUnloadHandler();
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* 批量记录日志(对外暴露的唯一方法)
|
|
602
|
+
*/
|
|
603
|
+
batchLog(level, message, source) {
|
|
604
|
+
const logEntry = {
|
|
605
|
+
id: this.generateId(),
|
|
606
|
+
level,
|
|
607
|
+
message,
|
|
608
|
+
source,
|
|
609
|
+
timestamp: Date.now()
|
|
610
|
+
};
|
|
611
|
+
this.logQueue.push(logEntry);
|
|
612
|
+
if (this.logQueue.length >= this.config.sizeThreshold) {
|
|
613
|
+
this.flush();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* 刷新日志队列,全部发送
|
|
618
|
+
*/
|
|
619
|
+
async flush() {
|
|
620
|
+
if (this.isProcessing || this.logQueue.length === 0) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
this.isProcessing = true;
|
|
624
|
+
const logsToSend = this.logQueue.splice(0, this.logQueue.length);
|
|
625
|
+
try {
|
|
626
|
+
await this.sendBatch(logsToSend);
|
|
627
|
+
} catch (error) {
|
|
628
|
+
this.logQueue.unshift(...logsToSend);
|
|
629
|
+
} finally {
|
|
630
|
+
this.isProcessing = false;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* 发送日志批次到后端
|
|
635
|
+
*/
|
|
636
|
+
async sendBatch(logs) {
|
|
637
|
+
const collectLogs = logs.map((log) => ({
|
|
638
|
+
level: log.level,
|
|
639
|
+
message: log.message,
|
|
640
|
+
time: new Date(log.timestamp).toISOString(),
|
|
641
|
+
source: log.source,
|
|
642
|
+
user_id: this.config.userId,
|
|
643
|
+
tenant_id: this.config.tenantId,
|
|
644
|
+
app_id: this.config.appId
|
|
645
|
+
}));
|
|
646
|
+
let retries = 0;
|
|
647
|
+
while (retries <= this.config.maxRetries) {
|
|
648
|
+
try {
|
|
649
|
+
await this.execFetch(this.config.endpoint, {
|
|
650
|
+
method: "POST",
|
|
651
|
+
headers: this.config.headers,
|
|
652
|
+
body: JSON.stringify(collectLogs)
|
|
653
|
+
});
|
|
654
|
+
return;
|
|
655
|
+
} catch (error) {
|
|
656
|
+
retries++;
|
|
657
|
+
if (retries > this.config.maxRetries) {
|
|
658
|
+
this.originConsole.error(`Failed to send logs (attempt ${retries}), retrying in ${this.config.retryDelay}ms...`);
|
|
659
|
+
} else {
|
|
660
|
+
this.originConsole.warn(`Failed to send logs (attempt ${retries}), retrying in ${this.config.retryDelay}ms...`);
|
|
661
|
+
}
|
|
662
|
+
await this.delay(this.config.retryDelay * retries);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* 执行实际的fetch请求
|
|
668
|
+
*/
|
|
669
|
+
async execFetch(url, options) {
|
|
670
|
+
return fetch(url, options);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* 启动自动刷新定时器
|
|
674
|
+
*/
|
|
675
|
+
startFlushTimer() {
|
|
676
|
+
if (this.flushTimer) {
|
|
677
|
+
clearInterval(this.flushTimer);
|
|
678
|
+
}
|
|
679
|
+
this.flushTimer = setInterval(() => {
|
|
680
|
+
if (this.logQueue.length > 0) {
|
|
681
|
+
this.flush();
|
|
682
|
+
}
|
|
683
|
+
}, this.config.flushInterval);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* 设置页面卸载时的处理
|
|
687
|
+
*/
|
|
688
|
+
setupBeforeUnloadHandler() {
|
|
689
|
+
if (typeof window !== "undefined") {
|
|
690
|
+
window.addEventListener("beforeunload", () => {
|
|
691
|
+
this.flush().finally(() => {
|
|
692
|
+
this.destroy();
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 延迟函数
|
|
699
|
+
*/
|
|
700
|
+
delay(ms) {
|
|
701
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* 生成唯一ID
|
|
705
|
+
*/
|
|
706
|
+
generateId() {
|
|
707
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* 销毁资源
|
|
711
|
+
*/
|
|
712
|
+
async destroy() {
|
|
713
|
+
if (this.flushTimer) {
|
|
714
|
+
clearInterval(this.flushTimer);
|
|
715
|
+
this.flushTimer = null;
|
|
716
|
+
}
|
|
717
|
+
if (this.logQueue.length > 0) {
|
|
718
|
+
await this.flush();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* 获取队列大小
|
|
723
|
+
*/
|
|
724
|
+
getQueueSize() {
|
|
725
|
+
return this.logQueue.length;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* 更新配置
|
|
729
|
+
*/
|
|
730
|
+
updateConfig(newConfig) {
|
|
731
|
+
this.config = {
|
|
732
|
+
...this.config,
|
|
733
|
+
...newConfig
|
|
734
|
+
};
|
|
735
|
+
this.startFlushTimer();
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
var defaultBatchLogger = null;
|
|
739
|
+
function batchLogInfo(level, message, source) {
|
|
740
|
+
if (!defaultBatchLogger) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
defaultBatchLogger.batchLog(level, message, source);
|
|
744
|
+
}
|
|
745
|
+
__name(batchLogInfo, "batchLogInfo");
|
|
746
|
+
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
747
|
+
defaultBatchLogger = new BatchLogger(console);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// src/utils/utils.ts
|
|
751
|
+
var import_clsx = require("clsx");
|
|
752
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
753
|
+
function clsxWithTw(...inputs) {
|
|
754
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
755
|
+
}
|
|
756
|
+
__name(clsxWithTw, "clsxWithTw");
|
|
757
|
+
function isPreview() {
|
|
758
|
+
return window.IS_MIAODA_PREVIEW;
|
|
759
|
+
}
|
|
760
|
+
__name(isPreview, "isPreview");
|
|
761
|
+
function normalizeBasePath(basePath) {
|
|
762
|
+
if (!basePath || basePath === "/") {
|
|
763
|
+
return "";
|
|
764
|
+
}
|
|
765
|
+
return basePath.replace(/\/+$/, "");
|
|
766
|
+
}
|
|
767
|
+
__name(normalizeBasePath, "normalizeBasePath");
|
|
768
|
+
function getWsPath() {
|
|
769
|
+
const rawBasePath = process.env.CLIENT_BASE_PATH || "/";
|
|
770
|
+
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
771
|
+
const basePathWithoutTrailingSlash = normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
772
|
+
return `${basePathWithoutTrailingSlash}/ws`;
|
|
773
|
+
}
|
|
774
|
+
__name(getWsPath, "getWsPath");
|
|
775
|
+
function isSparkRuntime() {
|
|
776
|
+
return window._IS_Spark_RUNTIME ?? process.env.runtimeMode === "fullstack";
|
|
777
|
+
}
|
|
778
|
+
__name(isSparkRuntime, "isSparkRuntime");
|
|
779
|
+
|
|
780
|
+
// src/components/AppContainer/utils/childApi.ts
|
|
781
|
+
async function getRoutes() {
|
|
782
|
+
let routes = [
|
|
783
|
+
{
|
|
784
|
+
path: "/"
|
|
785
|
+
}
|
|
786
|
+
];
|
|
787
|
+
try {
|
|
788
|
+
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
|
789
|
+
const res = await fetch(`${basePath}/routes.json`);
|
|
790
|
+
routes = await res.json();
|
|
791
|
+
} catch (error) {
|
|
792
|
+
console.warn("get routes.json error", error);
|
|
793
|
+
}
|
|
794
|
+
return routes;
|
|
795
|
+
}
|
|
796
|
+
__name(getRoutes, "getRoutes");
|
|
797
|
+
var childApi = {
|
|
798
|
+
getRoutes,
|
|
799
|
+
updateAppInfo: /* @__PURE__ */ __name((appInfo) => {
|
|
800
|
+
dispatchEvent(new CustomEvent("MiaoDaMetaInfoChanged", {
|
|
801
|
+
detail: appInfo
|
|
802
|
+
}));
|
|
803
|
+
}, "updateAppInfo")
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
// src/runtime/iframe-bridge.ts
|
|
807
|
+
async function connectParent() {
|
|
808
|
+
submitPostMessage({
|
|
809
|
+
type: "PreviewReady",
|
|
810
|
+
data: {}
|
|
811
|
+
});
|
|
812
|
+
batchLogInfo("info", JSON.stringify({
|
|
813
|
+
type: "PreviewReady",
|
|
814
|
+
timestamp: Date.now(),
|
|
815
|
+
url: window.location.href
|
|
816
|
+
}));
|
|
817
|
+
const parentOrigin = resolveParentOrigin();
|
|
818
|
+
if (!parentOrigin) return;
|
|
819
|
+
const connection = (0, import_penpal.connectToParent)({
|
|
820
|
+
parentOrigin,
|
|
821
|
+
methods: {
|
|
822
|
+
...childApi
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
await connection.promise;
|
|
826
|
+
}
|
|
827
|
+
__name(connectParent, "connectParent");
|
|
828
|
+
function initIframeBridge() {
|
|
829
|
+
if (window.parent === window) return;
|
|
830
|
+
connectParent();
|
|
831
|
+
}
|
|
832
|
+
__name(initIframeBridge, "initIframeBridge");
|
|
833
|
+
|
|
151
834
|
// src/runtime/index.ts
|
|
152
835
|
if (!window.__FULLSTACK_RUNTIME_INITIALIZED__) {
|
|
153
836
|
window.__FULLSTACK_RUNTIME_INITIALIZED__ = true;
|
|
154
837
|
initAxiosConfig();
|
|
838
|
+
if (process.env.NODE_ENV !== "production") {
|
|
839
|
+
initIframeBridge();
|
|
840
|
+
}
|
|
155
841
|
}
|
|
156
842
|
|
|
157
843
|
// src/components/AppContainer/safety.tsx
|
|
@@ -226,36 +912,6 @@ function getInitialInfo(refresh = false) {
|
|
|
226
912
|
}
|
|
227
913
|
__name(getInitialInfo, "getInitialInfo");
|
|
228
914
|
|
|
229
|
-
// src/utils/utils.ts
|
|
230
|
-
var import_clsx = require("clsx");
|
|
231
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
232
|
-
function clsxWithTw(...inputs) {
|
|
233
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
234
|
-
}
|
|
235
|
-
__name(clsxWithTw, "clsxWithTw");
|
|
236
|
-
function isPreview() {
|
|
237
|
-
return window.IS_MIAODA_PREVIEW;
|
|
238
|
-
}
|
|
239
|
-
__name(isPreview, "isPreview");
|
|
240
|
-
function normalizeBasePath(basePath) {
|
|
241
|
-
if (!basePath || basePath === "/") {
|
|
242
|
-
return "";
|
|
243
|
-
}
|
|
244
|
-
return basePath.replace(/\/+$/, "");
|
|
245
|
-
}
|
|
246
|
-
__name(normalizeBasePath, "normalizeBasePath");
|
|
247
|
-
function getWsPath() {
|
|
248
|
-
const rawBasePath = process.env.CLIENT_BASE_PATH || "/";
|
|
249
|
-
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
250
|
-
const basePathWithoutTrailingSlash = normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
251
|
-
return `${basePathWithoutTrailingSlash}/ws`;
|
|
252
|
-
}
|
|
253
|
-
__name(getWsPath, "getWsPath");
|
|
254
|
-
function isSparkRuntime() {
|
|
255
|
-
return window._IS_Spark_RUNTIME ?? process.env.runtimeMode === "fullstack";
|
|
256
|
-
}
|
|
257
|
-
__name(isSparkRuntime, "isSparkRuntime");
|
|
258
|
-
|
|
259
915
|
// src/integrations/getAppInfo.ts
|
|
260
916
|
async function getAppInfo(refresh = false) {
|
|
261
917
|
let appInfo = typeof window !== "undefined" ? window._appInfo : void 0;
|
|
@@ -1138,6 +1794,92 @@ var QueryProvider = /* @__PURE__ */ __name(({ children, client }) => {
|
|
|
1138
1794
|
}, "QueryProvider");
|
|
1139
1795
|
var QueryProvider_default = QueryProvider;
|
|
1140
1796
|
|
|
1797
|
+
// src/components/AppContainer/IframeBridge.tsx
|
|
1798
|
+
var import_react8 = require("react");
|
|
1799
|
+
var import_react_router_dom = require("react-router-dom");
|
|
1800
|
+
|
|
1801
|
+
// src/hooks/useUpdatingRef.ts
|
|
1802
|
+
var import_react7 = require("react");
|
|
1803
|
+
function useUpdatingRef(value) {
|
|
1804
|
+
const ref = (0, import_react7.useRef)(value);
|
|
1805
|
+
ref.current = value;
|
|
1806
|
+
return ref;
|
|
1807
|
+
}
|
|
1808
|
+
__name(useUpdatingRef, "useUpdatingRef");
|
|
1809
|
+
|
|
1810
|
+
// src/components/AppContainer/IframeBridge.tsx
|
|
1811
|
+
var RouteMessageType = /* @__PURE__ */ (function(RouteMessageType2) {
|
|
1812
|
+
RouteMessageType2["RouteChange"] = "RouteChange";
|
|
1813
|
+
RouteMessageType2["RouteBack"] = "RouteBack";
|
|
1814
|
+
RouteMessageType2["RouteForward"] = "RouteForward";
|
|
1815
|
+
return RouteMessageType2;
|
|
1816
|
+
})(RouteMessageType || {});
|
|
1817
|
+
function isRouteMessageType(type) {
|
|
1818
|
+
return Object.values(RouteMessageType).includes(type);
|
|
1819
|
+
}
|
|
1820
|
+
__name(isRouteMessageType, "isRouteMessageType");
|
|
1821
|
+
function IframeBridge() {
|
|
1822
|
+
const location = (0, import_react_router_dom.useLocation)();
|
|
1823
|
+
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
1824
|
+
const navigateRef = useUpdatingRef(navigate);
|
|
1825
|
+
const isActive = (0, import_react8.useRef)(false);
|
|
1826
|
+
const historyBack = (0, import_react8.useCallback)((_payload) => {
|
|
1827
|
+
navigateRef.current(-1);
|
|
1828
|
+
isActive.current = true;
|
|
1829
|
+
}, [
|
|
1830
|
+
navigateRef
|
|
1831
|
+
]);
|
|
1832
|
+
const historyForward = (0, import_react8.useCallback)((_payload) => {
|
|
1833
|
+
navigateRef.current(1);
|
|
1834
|
+
isActive.current = true;
|
|
1835
|
+
}, [
|
|
1836
|
+
navigateRef
|
|
1837
|
+
]);
|
|
1838
|
+
const operatorMessage = (0, import_react8.useMemo)(() => ({
|
|
1839
|
+
["RouteBack"]: historyBack,
|
|
1840
|
+
["RouteForward"]: historyForward,
|
|
1841
|
+
["RouteChange"]: navigateRef.current
|
|
1842
|
+
}), [
|
|
1843
|
+
historyBack,
|
|
1844
|
+
historyForward,
|
|
1845
|
+
navigateRef
|
|
1846
|
+
]);
|
|
1847
|
+
(0, import_react8.useEffect)(() => {
|
|
1848
|
+
if (isActive.current) {
|
|
1849
|
+
isActive.current = false;
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
submitPostMessage({
|
|
1853
|
+
type: "ChildLocationChange",
|
|
1854
|
+
data: location
|
|
1855
|
+
});
|
|
1856
|
+
}, [
|
|
1857
|
+
location
|
|
1858
|
+
]);
|
|
1859
|
+
const handleMessage = (0, import_react8.useCallback)((event) => {
|
|
1860
|
+
const data = event.data ?? {};
|
|
1861
|
+
if (typeof data.type === "string" && isRouteMessageType(data.type)) {
|
|
1862
|
+
operatorMessage[data.type](data.data);
|
|
1863
|
+
}
|
|
1864
|
+
}, [
|
|
1865
|
+
operatorMessage
|
|
1866
|
+
]);
|
|
1867
|
+
(0, import_react8.useEffect)(() => {
|
|
1868
|
+
window.addEventListener("message", handleMessage);
|
|
1869
|
+
return () => {
|
|
1870
|
+
window.removeEventListener("message", handleMessage);
|
|
1871
|
+
};
|
|
1872
|
+
}, [
|
|
1873
|
+
handleMessage
|
|
1874
|
+
]);
|
|
1875
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1876
|
+
style: {
|
|
1877
|
+
display: "none"
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
__name(IframeBridge, "IframeBridge");
|
|
1882
|
+
|
|
1141
1883
|
// src/components/AppContainer/utils/tea.ts
|
|
1142
1884
|
var import_blueimp_md5 = __toESM(require("blueimp-md5"), 1);
|
|
1143
1885
|
var import_sha1 = __toESM(require("crypto-js/sha1"), 1);
|
|
@@ -1250,13 +1992,13 @@ var reportTeaEvent = /* @__PURE__ */ __name(async ({ trackKey, trackParams = {}
|
|
|
1250
1992
|
}, "reportTeaEvent");
|
|
1251
1993
|
|
|
1252
1994
|
// src/components/AppContainer/utils/observable.ts
|
|
1253
|
-
var
|
|
1995
|
+
var import_observable_web2 = require("@lark-apaas/observable-web");
|
|
1254
1996
|
var initObservable = /* @__PURE__ */ __name(() => {
|
|
1255
1997
|
try {
|
|
1256
1998
|
const appId = window.appId;
|
|
1257
|
-
|
|
1999
|
+
import_observable_web2.observable.start({
|
|
1258
2000
|
serviceName: "app",
|
|
1259
|
-
env: process.env.NODE_ENV === "development" ?
|
|
2001
|
+
env: process.env.NODE_ENV === "development" ? import_observable_web2.AppEnv.Dev : import_observable_web2.AppEnv.Prod,
|
|
1260
2002
|
collectorUrl: isNewPathEnabled() ? {
|
|
1261
2003
|
log: `/app/${appId}/__runtime__/api/v1/observability/logs/collect`,
|
|
1262
2004
|
trace: `/app/${appId}/__runtime__/api/v1/observability/traces/collect`,
|
|
@@ -1283,10 +2025,10 @@ var TrackKey = /* @__PURE__ */ (function(TrackKey2) {
|
|
|
1283
2025
|
// src/components/AppContainer/index.tsx
|
|
1284
2026
|
var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
1285
2027
|
useAppInfo();
|
|
1286
|
-
(0,
|
|
2028
|
+
(0, import_react9.useEffect)(() => {
|
|
1287
2029
|
initObservable();
|
|
1288
2030
|
}, []);
|
|
1289
|
-
(0,
|
|
2031
|
+
(0, import_react9.useEffect)(() => {
|
|
1290
2032
|
if (process.env.NODE_ENV === "production") {
|
|
1291
2033
|
reportTeaEvent({
|
|
1292
2034
|
trackKey: TrackKey.VIEW,
|
|
@@ -1298,14 +2040,14 @@ var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
|
1298
2040
|
});
|
|
1299
2041
|
}
|
|
1300
2042
|
}, []);
|
|
1301
|
-
return /* @__PURE__ */
|
|
2043
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement(safety_default, null), process.env.NODE_ENV !== "production" && /* @__PURE__ */ import_react9.default.createElement(import_miaoda_inspector.MiaodaInspector, null), process.env.NODE_ENV !== "production" && /* @__PURE__ */ import_react9.default.createElement(IframeBridge, null), /* @__PURE__ */ import_react9.default.createElement(QueryProvider_default, null, children));
|
|
1302
2044
|
}, "AppContainer");
|
|
1303
2045
|
var AppContainer_default = AppContainer;
|
|
1304
2046
|
|
|
1305
2047
|
// src/components/Welcome/index.tsx
|
|
1306
|
-
var
|
|
2048
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
1307
2049
|
var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
1308
|
-
return /* @__PURE__ */
|
|
2050
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1309
2051
|
style: {
|
|
1310
2052
|
display: "flex",
|
|
1311
2053
|
flexDirection: "column",
|
|
@@ -1316,7 +2058,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1316
2058
|
padding: "0 24px",
|
|
1317
2059
|
textAlign: "center"
|
|
1318
2060
|
}
|
|
1319
|
-
}, /* @__PURE__ */
|
|
2061
|
+
}, /* @__PURE__ */ import_react10.default.createElement("img", {
|
|
1320
2062
|
style: {
|
|
1321
2063
|
borderRadius: 6,
|
|
1322
2064
|
marginBottom: 24
|
|
@@ -1325,7 +2067,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1325
2067
|
height: "200",
|
|
1326
2068
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
1327
2069
|
alt: "Welcome"
|
|
1328
|
-
}), /* @__PURE__ */
|
|
2070
|
+
}), /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1329
2071
|
style: {
|
|
1330
2072
|
fontSize: 16,
|
|
1331
2073
|
fontWeight: 500,
|
|
@@ -1333,7 +2075,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1333
2075
|
marginBottom: 4,
|
|
1334
2076
|
color: "#1f2329"
|
|
1335
2077
|
}
|
|
1336
|
-
}, title), /* @__PURE__ */
|
|
2078
|
+
}, title), /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1337
2079
|
style: {
|
|
1338
2080
|
fontSize: 16,
|
|
1339
2081
|
lineHeight: "24px",
|
|
@@ -1345,9 +2087,9 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1345
2087
|
var Welcome_default = Welcome;
|
|
1346
2088
|
|
|
1347
2089
|
// src/components/PagePlaceholder/index.tsx
|
|
1348
|
-
var
|
|
2090
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
1349
2091
|
var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
1350
|
-
return /* @__PURE__ */
|
|
2092
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1351
2093
|
style: {
|
|
1352
2094
|
display: "flex",
|
|
1353
2095
|
flexDirection: "column",
|
|
@@ -1358,7 +2100,7 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1358
2100
|
height: "calc(100vh - 64px)",
|
|
1359
2101
|
textAlign: "center"
|
|
1360
2102
|
}
|
|
1361
|
-
}, /* @__PURE__ */
|
|
2103
|
+
}, /* @__PURE__ */ import_react11.default.createElement("img", {
|
|
1362
2104
|
style: {
|
|
1363
2105
|
borderRadius: "6px",
|
|
1364
2106
|
marginBottom: "24px"
|
|
@@ -1367,14 +2109,14 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1367
2109
|
height: "200",
|
|
1368
2110
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
1369
2111
|
alt: "Welcome"
|
|
1370
|
-
}), /* @__PURE__ */
|
|
2112
|
+
}), /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1371
2113
|
style: {
|
|
1372
2114
|
fontSize: "16px",
|
|
1373
2115
|
fontWeight: 500,
|
|
1374
2116
|
marginBottom: "4px",
|
|
1375
2117
|
lineHeight: "24px"
|
|
1376
2118
|
}
|
|
1377
|
-
}, title), /* @__PURE__ */
|
|
2119
|
+
}, title), /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1378
2120
|
style: {
|
|
1379
2121
|
color: "#6b7280",
|
|
1380
2122
|
fontSize: "16px",
|
|
@@ -1389,13 +2131,62 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1389
2131
|
}, "PagePlaceholder");
|
|
1390
2132
|
var PagePlaceholder_default = PagePlaceholder;
|
|
1391
2133
|
|
|
2134
|
+
// src/components/ErrorRender/index.tsx
|
|
2135
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
2136
|
+
var ErrorRender = /* @__PURE__ */ __name((props) => {
|
|
2137
|
+
const { error, resetErrorBoundary } = props;
|
|
2138
|
+
(0, import_react12.useEffect)(() => {
|
|
2139
|
+
if (error) {
|
|
2140
|
+
submitPostMessage({
|
|
2141
|
+
type: "RenderError",
|
|
2142
|
+
data: error
|
|
2143
|
+
});
|
|
2144
|
+
logger.log({
|
|
2145
|
+
level: "error",
|
|
2146
|
+
args: [
|
|
2147
|
+
"Render Error",
|
|
2148
|
+
error
|
|
2149
|
+
],
|
|
2150
|
+
meta: {
|
|
2151
|
+
type: "render-error"
|
|
2152
|
+
}
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
}, [
|
|
2156
|
+
error
|
|
2157
|
+
]);
|
|
2158
|
+
(0, import_react12.useEffect)(() => {
|
|
2159
|
+
if (!resetErrorBoundary) return;
|
|
2160
|
+
const hmr = getHmrApi();
|
|
2161
|
+
if (hmr) {
|
|
2162
|
+
return hmr.onSuccess(() => {
|
|
2163
|
+
resetErrorBoundary();
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}, [
|
|
2167
|
+
resetErrorBoundary
|
|
2168
|
+
]);
|
|
2169
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
2170
|
+
className: "min-h-screen flex items-center justify-center bg-white"
|
|
2171
|
+
}, /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
2172
|
+
className: "flex flex-col justify-center items-center text-center"
|
|
2173
|
+
}, /* @__PURE__ */ import_react12.default.createElement("img", {
|
|
2174
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg",
|
|
2175
|
+
alt: "render error",
|
|
2176
|
+
className: "mb-3 w-[100px]"
|
|
2177
|
+
}), /* @__PURE__ */ import_react12.default.createElement("p", {
|
|
2178
|
+
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium"
|
|
2179
|
+
}, "\u9875\u9762\u51FA\u9519\u4E86")));
|
|
2180
|
+
}, "ErrorRender");
|
|
2181
|
+
var ErrorRender_default = ErrorRender;
|
|
2182
|
+
|
|
1392
2183
|
// src/route-components/ActiveLink.tsx
|
|
1393
|
-
var
|
|
1394
|
-
var
|
|
1395
|
-
var ActiveLink = /* @__PURE__ */ (0,
|
|
1396
|
-
const [currentHash, setCurrentHash] = (0,
|
|
2184
|
+
var import_react13 = __toESM(require("react"), 1);
|
|
2185
|
+
var import_react_router_dom2 = require("react-router-dom");
|
|
2186
|
+
var ActiveLink = /* @__PURE__ */ (0, import_react13.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
|
|
2187
|
+
const [currentHash, setCurrentHash] = (0, import_react13.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
|
|
1397
2188
|
const isHashRoute = typeof to === "string" && to.startsWith("#");
|
|
1398
|
-
(0,
|
|
2189
|
+
(0, import_react13.useEffect)(() => {
|
|
1399
2190
|
if (!isHashRoute) return;
|
|
1400
2191
|
const handleHashChange = /* @__PURE__ */ __name(() => {
|
|
1401
2192
|
setCurrentHash(window.location.hash);
|
|
@@ -1407,7 +2198,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1407
2198
|
]);
|
|
1408
2199
|
const isActive = isHashRoute && currentHash === to;
|
|
1409
2200
|
if (!isHashRoute) {
|
|
1410
|
-
return /* @__PURE__ */
|
|
2201
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react_router_dom2.NavLink, {
|
|
1411
2202
|
ref,
|
|
1412
2203
|
to,
|
|
1413
2204
|
onClick,
|
|
@@ -1448,7 +2239,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1448
2239
|
isPending: false,
|
|
1449
2240
|
isTransitioning: false
|
|
1450
2241
|
}) : children;
|
|
1451
|
-
return /* @__PURE__ */
|
|
2242
|
+
return /* @__PURE__ */ import_react13.default.createElement("a", {
|
|
1452
2243
|
ref,
|
|
1453
2244
|
href: to,
|
|
1454
2245
|
onClick: handleHashClick,
|
|
@@ -1460,12 +2251,12 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1460
2251
|
ActiveLink.displayName = "ActiveLink";
|
|
1461
2252
|
|
|
1462
2253
|
// src/route-components/NavLink.tsx
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1465
|
-
var NavLink2 = /* @__PURE__ */
|
|
2254
|
+
var React10 = __toESM(require("react"), 1);
|
|
2255
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
2256
|
+
var NavLink2 = /* @__PURE__ */ React10.forwardRef(({ to, children, className, style, ...props }, ref) => {
|
|
1466
2257
|
const isHashLink = typeof to === "string" && to.startsWith("#");
|
|
1467
|
-
const location = (0,
|
|
1468
|
-
const navigate = (0,
|
|
2258
|
+
const location = (0, import_react_router_dom3.useLocation)();
|
|
2259
|
+
const navigate = (0, import_react_router_dom3.useNavigate)();
|
|
1469
2260
|
if (isHashLink) {
|
|
1470
2261
|
const handleClick = /* @__PURE__ */ __name((e) => {
|
|
1471
2262
|
e.preventDefault();
|
|
@@ -1486,7 +2277,7 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1486
2277
|
const resolvedClassName = typeof className === "function" ? className(renderProps) : className;
|
|
1487
2278
|
const resolvedStyle = typeof style === "function" ? style(renderProps) : style;
|
|
1488
2279
|
const { caseSensitive, end, replace, state, preventScrollReset, relative, viewTransition, ...restProps } = props;
|
|
1489
|
-
return /* @__PURE__ */
|
|
2280
|
+
return /* @__PURE__ */ React10.createElement("a", {
|
|
1490
2281
|
href: to,
|
|
1491
2282
|
onClick: handleClick,
|
|
1492
2283
|
ref,
|
|
@@ -1495,7 +2286,7 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1495
2286
|
...restProps
|
|
1496
2287
|
}, typeof children === "function" ? children(renderProps) : children);
|
|
1497
2288
|
}
|
|
1498
|
-
return /* @__PURE__ */
|
|
2289
|
+
return /* @__PURE__ */ React10.createElement(import_react_router_dom3.NavLink, {
|
|
1499
2290
|
to,
|
|
1500
2291
|
ref,
|
|
1501
2292
|
className,
|
|
@@ -1510,8 +2301,8 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1510
2301
|
NavLink2.displayName = "NavLink";
|
|
1511
2302
|
|
|
1512
2303
|
// src/route-components/UniversalLink.tsx
|
|
1513
|
-
var
|
|
1514
|
-
var
|
|
2304
|
+
var import_react14 = __toESM(require("react"), 1);
|
|
2305
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
1515
2306
|
function isInternalRoute(to) {
|
|
1516
2307
|
return !to.startsWith("#") && !to.startsWith("http://") && !to.startsWith("https://") && !to.startsWith("//");
|
|
1517
2308
|
}
|
|
@@ -1520,15 +2311,15 @@ function isExternalLink(to) {
|
|
|
1520
2311
|
return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
|
|
1521
2312
|
}
|
|
1522
2313
|
__name(isExternalLink, "isExternalLink");
|
|
1523
|
-
var UniversalLink = /* @__PURE__ */
|
|
2314
|
+
var UniversalLink = /* @__PURE__ */ import_react14.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
|
|
1524
2315
|
if (isInternalRoute(to)) {
|
|
1525
|
-
return /* @__PURE__ */
|
|
2316
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react_router_dom4.Link, {
|
|
1526
2317
|
to,
|
|
1527
2318
|
ref,
|
|
1528
2319
|
...props
|
|
1529
2320
|
});
|
|
1530
2321
|
}
|
|
1531
|
-
return /* @__PURE__ */
|
|
2322
|
+
return /* @__PURE__ */ import_react14.default.createElement("a", {
|
|
1532
2323
|
href: to,
|
|
1533
2324
|
ref,
|
|
1534
2325
|
...props,
|
|
@@ -1674,45 +2465,6 @@ function getEnvPath() {
|
|
|
1674
2465
|
}
|
|
1675
2466
|
__name(getEnvPath, "getEnvPath");
|
|
1676
2467
|
|
|
1677
|
-
// src/utils/safeStringify.ts
|
|
1678
|
-
function safeStringify(obj) {
|
|
1679
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1680
|
-
try {
|
|
1681
|
-
return JSON.stringify(obj, (_key, value) => {
|
|
1682
|
-
if (typeof value === "object" && value !== null) {
|
|
1683
|
-
if (seen.has(value)) {
|
|
1684
|
-
return "[Circular]";
|
|
1685
|
-
}
|
|
1686
|
-
seen.add(value);
|
|
1687
|
-
}
|
|
1688
|
-
if (typeof value === "bigint") {
|
|
1689
|
-
return value.toString();
|
|
1690
|
-
}
|
|
1691
|
-
if (value instanceof Date) {
|
|
1692
|
-
return value.toISOString();
|
|
1693
|
-
}
|
|
1694
|
-
if (value instanceof Map) {
|
|
1695
|
-
return Object.fromEntries(value);
|
|
1696
|
-
}
|
|
1697
|
-
if (value instanceof Set) {
|
|
1698
|
-
return Array.from(value);
|
|
1699
|
-
}
|
|
1700
|
-
if (typeof value === "undefined") {
|
|
1701
|
-
return "undefined";
|
|
1702
|
-
}
|
|
1703
|
-
if (typeof value === "symbol") {
|
|
1704
|
-
return value.toString();
|
|
1705
|
-
}
|
|
1706
|
-
return value;
|
|
1707
|
-
});
|
|
1708
|
-
} catch {
|
|
1709
|
-
return "";
|
|
1710
|
-
} finally {
|
|
1711
|
-
seen.clear();
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
__name(safeStringify, "safeStringify");
|
|
1715
|
-
|
|
1716
2468
|
// src/utils/getAxiosForBackend.ts
|
|
1717
2469
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
1718
2470
|
var axiosInstance;
|
|
@@ -1968,6 +2720,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
1968
2720
|
0 && (module.exports = {
|
|
1969
2721
|
ActiveLink,
|
|
1970
2722
|
AppContainer,
|
|
2723
|
+
ErrorRender,
|
|
1971
2724
|
NavLink,
|
|
1972
2725
|
PagePlaceholder,
|
|
1973
2726
|
QueryProvider,
|
|
@@ -1994,6 +2747,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
1994
2747
|
isIpad,
|
|
1995
2748
|
isMobile,
|
|
1996
2749
|
isPreview,
|
|
2750
|
+
logger,
|
|
1997
2751
|
normalizeBasePath,
|
|
1998
2752
|
reportTeaEvent,
|
|
1999
2753
|
resolveAppUrl,
|