@lark-apaas/client-toolkit-lite 1.1.7-alpha.0 → 1.1.7-alpha.10
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 +906 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -4
- package/dist/index.d.ts +68 -4
- package/dist/index.js +949 -152
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
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,
|
|
@@ -42,6 +43,7 @@ __export(index_exports, {
|
|
|
42
43
|
avatarImages: () => avatar_exports,
|
|
43
44
|
axiosForBackend: () => axiosForBackend,
|
|
44
45
|
bannerImages: () => banner_exports,
|
|
46
|
+
capabilityClient: () => capabilityClient,
|
|
45
47
|
clsxWithTw: () => clsxWithTw,
|
|
46
48
|
copyToClipboard: () => copyToClipboard,
|
|
47
49
|
coverImages: () => cover_exports,
|
|
@@ -58,6 +60,7 @@ __export(index_exports, {
|
|
|
58
60
|
isIpad: () => isIpad,
|
|
59
61
|
isMobile: () => isMobile,
|
|
60
62
|
isPreview: () => isPreview,
|
|
63
|
+
logger: () => logger,
|
|
61
64
|
normalizeBasePath: () => normalizeBasePath,
|
|
62
65
|
reportTeaEvent: () => reportTeaEvent,
|
|
63
66
|
resolveAppUrl: () => resolveAppUrl,
|
|
@@ -71,7 +74,8 @@ __export(index_exports, {
|
|
|
71
74
|
module.exports = __toCommonJS(index_exports);
|
|
72
75
|
|
|
73
76
|
// src/components/AppContainer/index.tsx
|
|
74
|
-
var
|
|
77
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
78
|
+
var import_miaoda_inspector = require("@lark-apaas/miaoda-inspector");
|
|
75
79
|
|
|
76
80
|
// src/runtime/react-devtools-hook.ts
|
|
77
81
|
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
@@ -127,15 +131,15 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
127
131
|
if (!axiosInstance2) {
|
|
128
132
|
axiosInstance2 = import_axios.default;
|
|
129
133
|
}
|
|
130
|
-
axiosInstance2.interceptors.request.use((
|
|
134
|
+
axiosInstance2.interceptors.request.use((config2) => {
|
|
131
135
|
const csrfToken = getCsrfToken();
|
|
132
136
|
if (csrfToken) {
|
|
133
|
-
|
|
137
|
+
config2.headers["X-Suda-Csrf-Token"] = csrfToken;
|
|
134
138
|
}
|
|
135
139
|
if (typeof window !== "undefined") {
|
|
136
|
-
|
|
140
|
+
config2.headers["X-Page-Route"] = window.location.pathname;
|
|
137
141
|
}
|
|
138
|
-
return
|
|
142
|
+
return config2;
|
|
139
143
|
}, (error) => Promise.reject(error));
|
|
140
144
|
axiosInstance2.interceptors.response.use((response) => response, (error) => {
|
|
141
145
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -146,10 +150,694 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
146
150
|
}
|
|
147
151
|
__name(initAxiosConfig, "initAxiosConfig");
|
|
148
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
|
+
|
|
149
834
|
// src/runtime/index.ts
|
|
150
835
|
if (!window.__FULLSTACK_RUNTIME_INITIALIZED__) {
|
|
151
836
|
window.__FULLSTACK_RUNTIME_INITIALIZED__ = true;
|
|
152
837
|
initAxiosConfig();
|
|
838
|
+
if (process.env.NODE_ENV !== "production") {
|
|
839
|
+
initIframeBridge();
|
|
840
|
+
}
|
|
153
841
|
}
|
|
154
842
|
|
|
155
843
|
// src/components/AppContainer/safety.tsx
|
|
@@ -224,36 +912,6 @@ function getInitialInfo(refresh = false) {
|
|
|
224
912
|
}
|
|
225
913
|
__name(getInitialInfo, "getInitialInfo");
|
|
226
914
|
|
|
227
|
-
// src/utils/utils.ts
|
|
228
|
-
var import_clsx = require("clsx");
|
|
229
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
230
|
-
function clsxWithTw(...inputs) {
|
|
231
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
232
|
-
}
|
|
233
|
-
__name(clsxWithTw, "clsxWithTw");
|
|
234
|
-
function isPreview() {
|
|
235
|
-
return window.IS_MIAODA_PREVIEW;
|
|
236
|
-
}
|
|
237
|
-
__name(isPreview, "isPreview");
|
|
238
|
-
function normalizeBasePath(basePath) {
|
|
239
|
-
if (!basePath || basePath === "/") {
|
|
240
|
-
return "";
|
|
241
|
-
}
|
|
242
|
-
return basePath.replace(/\/+$/, "");
|
|
243
|
-
}
|
|
244
|
-
__name(normalizeBasePath, "normalizeBasePath");
|
|
245
|
-
function getWsPath() {
|
|
246
|
-
const rawBasePath = process.env.CLIENT_BASE_PATH || "/";
|
|
247
|
-
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
248
|
-
const basePathWithoutTrailingSlash = normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
249
|
-
return `${basePathWithoutTrailingSlash}/ws`;
|
|
250
|
-
}
|
|
251
|
-
__name(getWsPath, "getWsPath");
|
|
252
|
-
function isSparkRuntime() {
|
|
253
|
-
return window._IS_Spark_RUNTIME ?? process.env.runtimeMode === "fullstack";
|
|
254
|
-
}
|
|
255
|
-
__name(isSparkRuntime, "isSparkRuntime");
|
|
256
|
-
|
|
257
915
|
// src/integrations/getAppInfo.ts
|
|
258
916
|
async function getAppInfo(refresh = false) {
|
|
259
917
|
let appInfo = typeof window !== "undefined" ? window._appInfo : void 0;
|
|
@@ -1136,6 +1794,92 @@ var QueryProvider = /* @__PURE__ */ __name(({ children, client }) => {
|
|
|
1136
1794
|
}, "QueryProvider");
|
|
1137
1795
|
var QueryProvider_default = QueryProvider;
|
|
1138
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
|
+
|
|
1139
1883
|
// src/components/AppContainer/utils/tea.ts
|
|
1140
1884
|
var import_blueimp_md5 = __toESM(require("blueimp-md5"), 1);
|
|
1141
1885
|
var import_sha1 = __toESM(require("crypto-js/sha1"), 1);
|
|
@@ -1247,6 +1991,31 @@ var reportTeaEvent = /* @__PURE__ */ __name(async ({ trackKey, trackParams = {}
|
|
|
1247
1991
|
}
|
|
1248
1992
|
}, "reportTeaEvent");
|
|
1249
1993
|
|
|
1994
|
+
// src/components/AppContainer/utils/observable.ts
|
|
1995
|
+
var import_observable_web2 = require("@lark-apaas/observable-web");
|
|
1996
|
+
var initObservable = /* @__PURE__ */ __name(() => {
|
|
1997
|
+
try {
|
|
1998
|
+
const appId = window.appId;
|
|
1999
|
+
import_observable_web2.observable.start({
|
|
2000
|
+
serviceName: "app",
|
|
2001
|
+
env: process.env.NODE_ENV === "development" ? import_observable_web2.AppEnv.Dev : import_observable_web2.AppEnv.Prod,
|
|
2002
|
+
collectorUrl: isNewPathEnabled() ? {
|
|
2003
|
+
log: `/app/${appId}/__runtime__/api/v1/observability/logs/collect`,
|
|
2004
|
+
trace: `/app/${appId}/__runtime__/api/v1/observability/traces/collect`,
|
|
2005
|
+
metric: `/app/${appId}/__runtime__/api/v1/observability/metrics/collect`,
|
|
2006
|
+
time: `/app/${appId}/__runtime__/api/v1/observability/current_server_timestamp`
|
|
2007
|
+
} : {
|
|
2008
|
+
log: `/spark/app/${appId}/runtime/api/v1/observability/logs/collect`,
|
|
2009
|
+
trace: `/spark/app/${appId}/runtime/api/v1/observability/traces/collect`,
|
|
2010
|
+
metric: `/spark/app/${appId}/runtime/api/v1/observability/metrics/collect`,
|
|
2011
|
+
time: `/spark/api/v1/observability/app/${appId}/current_server_timestamp`
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
} catch (error) {
|
|
2015
|
+
console.error("Failed to start WebObservableSdk:", error);
|
|
2016
|
+
}
|
|
2017
|
+
}, "initObservable");
|
|
2018
|
+
|
|
1250
2019
|
// src/types/tea.ts
|
|
1251
2020
|
var TrackKey = /* @__PURE__ */ (function(TrackKey2) {
|
|
1252
2021
|
TrackKey2["VIEW"] = "aily_agent_artifact_page_view";
|
|
@@ -1256,7 +2025,10 @@ var TrackKey = /* @__PURE__ */ (function(TrackKey2) {
|
|
|
1256
2025
|
// src/components/AppContainer/index.tsx
|
|
1257
2026
|
var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
1258
2027
|
useAppInfo();
|
|
1259
|
-
(0,
|
|
2028
|
+
(0, import_react9.useEffect)(() => {
|
|
2029
|
+
initObservable();
|
|
2030
|
+
}, []);
|
|
2031
|
+
(0, import_react9.useEffect)(() => {
|
|
1260
2032
|
if (process.env.NODE_ENV === "production") {
|
|
1261
2033
|
reportTeaEvent({
|
|
1262
2034
|
trackKey: TrackKey.VIEW,
|
|
@@ -1268,14 +2040,14 @@ var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
|
1268
2040
|
});
|
|
1269
2041
|
}
|
|
1270
2042
|
}, []);
|
|
1271
|
-
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));
|
|
1272
2044
|
}, "AppContainer");
|
|
1273
2045
|
var AppContainer_default = AppContainer;
|
|
1274
2046
|
|
|
1275
2047
|
// src/components/Welcome/index.tsx
|
|
1276
|
-
var
|
|
2048
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
1277
2049
|
var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
1278
|
-
return /* @__PURE__ */
|
|
2050
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1279
2051
|
style: {
|
|
1280
2052
|
display: "flex",
|
|
1281
2053
|
flexDirection: "column",
|
|
@@ -1286,7 +2058,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1286
2058
|
padding: "0 24px",
|
|
1287
2059
|
textAlign: "center"
|
|
1288
2060
|
}
|
|
1289
|
-
}, /* @__PURE__ */
|
|
2061
|
+
}, /* @__PURE__ */ import_react10.default.createElement("img", {
|
|
1290
2062
|
style: {
|
|
1291
2063
|
borderRadius: 6,
|
|
1292
2064
|
marginBottom: 24
|
|
@@ -1295,7 +2067,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1295
2067
|
height: "200",
|
|
1296
2068
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
1297
2069
|
alt: "Welcome"
|
|
1298
|
-
}), /* @__PURE__ */
|
|
2070
|
+
}), /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1299
2071
|
style: {
|
|
1300
2072
|
fontSize: 16,
|
|
1301
2073
|
fontWeight: 500,
|
|
@@ -1303,7 +2075,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1303
2075
|
marginBottom: 4,
|
|
1304
2076
|
color: "#1f2329"
|
|
1305
2077
|
}
|
|
1306
|
-
}, title), /* @__PURE__ */
|
|
2078
|
+
}, title), /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1307
2079
|
style: {
|
|
1308
2080
|
fontSize: 16,
|
|
1309
2081
|
lineHeight: "24px",
|
|
@@ -1315,9 +2087,9 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
1315
2087
|
var Welcome_default = Welcome;
|
|
1316
2088
|
|
|
1317
2089
|
// src/components/PagePlaceholder/index.tsx
|
|
1318
|
-
var
|
|
2090
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
1319
2091
|
var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
1320
|
-
return /* @__PURE__ */
|
|
2092
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1321
2093
|
style: {
|
|
1322
2094
|
display: "flex",
|
|
1323
2095
|
flexDirection: "column",
|
|
@@ -1328,7 +2100,7 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1328
2100
|
height: "calc(100vh - 64px)",
|
|
1329
2101
|
textAlign: "center"
|
|
1330
2102
|
}
|
|
1331
|
-
}, /* @__PURE__ */
|
|
2103
|
+
}, /* @__PURE__ */ import_react11.default.createElement("img", {
|
|
1332
2104
|
style: {
|
|
1333
2105
|
borderRadius: "6px",
|
|
1334
2106
|
marginBottom: "24px"
|
|
@@ -1337,14 +2109,14 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1337
2109
|
height: "200",
|
|
1338
2110
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
1339
2111
|
alt: "Welcome"
|
|
1340
|
-
}), /* @__PURE__ */
|
|
2112
|
+
}), /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1341
2113
|
style: {
|
|
1342
2114
|
fontSize: "16px",
|
|
1343
2115
|
fontWeight: 500,
|
|
1344
2116
|
marginBottom: "4px",
|
|
1345
2117
|
lineHeight: "24px"
|
|
1346
2118
|
}
|
|
1347
|
-
}, title), /* @__PURE__ */
|
|
2119
|
+
}, title), /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1348
2120
|
style: {
|
|
1349
2121
|
color: "#6b7280",
|
|
1350
2122
|
fontSize: "16px",
|
|
@@ -1359,13 +2131,62 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
1359
2131
|
}, "PagePlaceholder");
|
|
1360
2132
|
var PagePlaceholder_default = PagePlaceholder;
|
|
1361
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
|
+
|
|
1362
2183
|
// src/route-components/ActiveLink.tsx
|
|
1363
|
-
var
|
|
1364
|
-
var
|
|
1365
|
-
var ActiveLink = /* @__PURE__ */ (0,
|
|
1366
|
-
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 : "");
|
|
1367
2188
|
const isHashRoute = typeof to === "string" && to.startsWith("#");
|
|
1368
|
-
(0,
|
|
2189
|
+
(0, import_react13.useEffect)(() => {
|
|
1369
2190
|
if (!isHashRoute) return;
|
|
1370
2191
|
const handleHashChange = /* @__PURE__ */ __name(() => {
|
|
1371
2192
|
setCurrentHash(window.location.hash);
|
|
@@ -1377,7 +2198,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1377
2198
|
]);
|
|
1378
2199
|
const isActive = isHashRoute && currentHash === to;
|
|
1379
2200
|
if (!isHashRoute) {
|
|
1380
|
-
return /* @__PURE__ */
|
|
2201
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react_router_dom2.NavLink, {
|
|
1381
2202
|
ref,
|
|
1382
2203
|
to,
|
|
1383
2204
|
onClick,
|
|
@@ -1418,7 +2239,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1418
2239
|
isPending: false,
|
|
1419
2240
|
isTransitioning: false
|
|
1420
2241
|
}) : children;
|
|
1421
|
-
return /* @__PURE__ */
|
|
2242
|
+
return /* @__PURE__ */ import_react13.default.createElement("a", {
|
|
1422
2243
|
ref,
|
|
1423
2244
|
href: to,
|
|
1424
2245
|
onClick: handleHashClick,
|
|
@@ -1430,12 +2251,12 @@ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick,
|
|
|
1430
2251
|
ActiveLink.displayName = "ActiveLink";
|
|
1431
2252
|
|
|
1432
2253
|
// src/route-components/NavLink.tsx
|
|
1433
|
-
var
|
|
1434
|
-
var
|
|
1435
|
-
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) => {
|
|
1436
2257
|
const isHashLink = typeof to === "string" && to.startsWith("#");
|
|
1437
|
-
const location = (0,
|
|
1438
|
-
const navigate = (0,
|
|
2258
|
+
const location = (0, import_react_router_dom3.useLocation)();
|
|
2259
|
+
const navigate = (0, import_react_router_dom3.useNavigate)();
|
|
1439
2260
|
if (isHashLink) {
|
|
1440
2261
|
const handleClick = /* @__PURE__ */ __name((e) => {
|
|
1441
2262
|
e.preventDefault();
|
|
@@ -1456,7 +2277,7 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1456
2277
|
const resolvedClassName = typeof className === "function" ? className(renderProps) : className;
|
|
1457
2278
|
const resolvedStyle = typeof style === "function" ? style(renderProps) : style;
|
|
1458
2279
|
const { caseSensitive, end, replace, state, preventScrollReset, relative, viewTransition, ...restProps } = props;
|
|
1459
|
-
return /* @__PURE__ */
|
|
2280
|
+
return /* @__PURE__ */ React10.createElement("a", {
|
|
1460
2281
|
href: to,
|
|
1461
2282
|
onClick: handleClick,
|
|
1462
2283
|
ref,
|
|
@@ -1465,7 +2286,7 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1465
2286
|
...restProps
|
|
1466
2287
|
}, typeof children === "function" ? children(renderProps) : children);
|
|
1467
2288
|
}
|
|
1468
|
-
return /* @__PURE__ */
|
|
2289
|
+
return /* @__PURE__ */ React10.createElement(import_react_router_dom3.NavLink, {
|
|
1469
2290
|
to,
|
|
1470
2291
|
ref,
|
|
1471
2292
|
className,
|
|
@@ -1480,8 +2301,8 @@ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, sty
|
|
|
1480
2301
|
NavLink2.displayName = "NavLink";
|
|
1481
2302
|
|
|
1482
2303
|
// src/route-components/UniversalLink.tsx
|
|
1483
|
-
var
|
|
1484
|
-
var
|
|
2304
|
+
var import_react14 = __toESM(require("react"), 1);
|
|
2305
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
1485
2306
|
function isInternalRoute(to) {
|
|
1486
2307
|
return !to.startsWith("#") && !to.startsWith("http://") && !to.startsWith("https://") && !to.startsWith("//");
|
|
1487
2308
|
}
|
|
@@ -1490,15 +2311,15 @@ function isExternalLink(to) {
|
|
|
1490
2311
|
return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
|
|
1491
2312
|
}
|
|
1492
2313
|
__name(isExternalLink, "isExternalLink");
|
|
1493
|
-
var UniversalLink = /* @__PURE__ */
|
|
2314
|
+
var UniversalLink = /* @__PURE__ */ import_react14.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
|
|
1494
2315
|
if (isInternalRoute(to)) {
|
|
1495
|
-
return /* @__PURE__ */
|
|
2316
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react_router_dom4.Link, {
|
|
1496
2317
|
to,
|
|
1497
2318
|
ref,
|
|
1498
2319
|
...props
|
|
1499
2320
|
});
|
|
1500
2321
|
}
|
|
1501
|
-
return /* @__PURE__ */
|
|
2322
|
+
return /* @__PURE__ */ import_react14.default.createElement("a", {
|
|
1502
2323
|
href: to,
|
|
1503
2324
|
ref,
|
|
1504
2325
|
...props,
|
|
@@ -1644,45 +2465,6 @@ function getEnvPath() {
|
|
|
1644
2465
|
}
|
|
1645
2466
|
__name(getEnvPath, "getEnvPath");
|
|
1646
2467
|
|
|
1647
|
-
// src/utils/safeStringify.ts
|
|
1648
|
-
function safeStringify(obj) {
|
|
1649
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1650
|
-
try {
|
|
1651
|
-
return JSON.stringify(obj, (_key, value) => {
|
|
1652
|
-
if (typeof value === "object" && value !== null) {
|
|
1653
|
-
if (seen.has(value)) {
|
|
1654
|
-
return "[Circular]";
|
|
1655
|
-
}
|
|
1656
|
-
seen.add(value);
|
|
1657
|
-
}
|
|
1658
|
-
if (typeof value === "bigint") {
|
|
1659
|
-
return value.toString();
|
|
1660
|
-
}
|
|
1661
|
-
if (value instanceof Date) {
|
|
1662
|
-
return value.toISOString();
|
|
1663
|
-
}
|
|
1664
|
-
if (value instanceof Map) {
|
|
1665
|
-
return Object.fromEntries(value);
|
|
1666
|
-
}
|
|
1667
|
-
if (value instanceof Set) {
|
|
1668
|
-
return Array.from(value);
|
|
1669
|
-
}
|
|
1670
|
-
if (typeof value === "undefined") {
|
|
1671
|
-
return "undefined";
|
|
1672
|
-
}
|
|
1673
|
-
if (typeof value === "symbol") {
|
|
1674
|
-
return value.toString();
|
|
1675
|
-
}
|
|
1676
|
-
return value;
|
|
1677
|
-
});
|
|
1678
|
-
} catch {
|
|
1679
|
-
return "";
|
|
1680
|
-
} finally {
|
|
1681
|
-
seen.clear();
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
__name(safeStringify, "safeStringify");
|
|
1685
|
-
|
|
1686
2468
|
// src/utils/getAxiosForBackend.ts
|
|
1687
2469
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
1688
2470
|
var axiosInstance;
|
|
@@ -1762,6 +2544,22 @@ function getAxiosForBackend() {
|
|
|
1762
2544
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
1763
2545
|
var axiosForBackend = getAxiosForBackend();
|
|
1764
2546
|
|
|
2547
|
+
// src/integrations/capabilityClient.ts
|
|
2548
|
+
var import_client_capability = require("@lark-apaas/client-capability");
|
|
2549
|
+
var _appId = getAppId();
|
|
2550
|
+
var _acquireUploadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_upload_url` : `/af/api/v1/studio/plugins/tmp_files/acquire_upload_url`;
|
|
2551
|
+
var _acquireDownloadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_download_url` : `/af/api/v1/studio/plugins/tmp_files/acquire_download_url`;
|
|
2552
|
+
var capabilityClient = (0, import_client_capability.createClient)({
|
|
2553
|
+
baseURL: normalizeBasePath(process.env.CLIENT_BASE_PATH ?? "/"),
|
|
2554
|
+
acquireUploadUrl: _acquireUploadUrl,
|
|
2555
|
+
acquireDownloadUrl: _acquireDownloadUrl,
|
|
2556
|
+
fetchOptions: {
|
|
2557
|
+
headers: {
|
|
2558
|
+
"X-Suda-Csrf-Token": window.csrfToken ?? ""
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
|
|
1765
2563
|
// src/constants/img-resources/avatar.ts
|
|
1766
2564
|
var avatar_exports = {};
|
|
1767
2565
|
__export(avatar_exports, {
|
|
@@ -1922,6 +2720,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
1922
2720
|
0 && (module.exports = {
|
|
1923
2721
|
ActiveLink,
|
|
1924
2722
|
AppContainer,
|
|
2723
|
+
ErrorRender,
|
|
1925
2724
|
NavLink,
|
|
1926
2725
|
PagePlaceholder,
|
|
1927
2726
|
QueryProvider,
|
|
@@ -1931,6 +2730,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
1931
2730
|
avatarImages,
|
|
1932
2731
|
axiosForBackend,
|
|
1933
2732
|
bannerImages,
|
|
2733
|
+
capabilityClient,
|
|
1934
2734
|
clsxWithTw,
|
|
1935
2735
|
copyToClipboard,
|
|
1936
2736
|
coverImages,
|
|
@@ -1947,6 +2747,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
1947
2747
|
isIpad,
|
|
1948
2748
|
isMobile,
|
|
1949
2749
|
isPreview,
|
|
2750
|
+
logger,
|
|
1950
2751
|
normalizeBasePath,
|
|
1951
2752
|
reportTeaEvent,
|
|
1952
2753
|
resolveAppUrl,
|