@lark-apaas/client-toolkit-lite 1.1.7 → 1.1.8-alpha.0
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/README.md +1 -49
- package/dist/index.cjs +211 -1410
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -90
- package/dist/index.d.ts +4 -90
- package/dist/index.js +199 -1392
- package/dist/index.js.map +1 -1
- package/package.json +8 -18
- package/dist/styles/font-family.css +0 -39
- package/dist/styles/index.css +0 -4
- package/dist/styles/inspector.dev.css +0 -5
- package/dist/styles/override.css +0 -18
- package/dist/styles/tailwind-theme.css +0 -361
- package/dist/styles/theme-layer.css +0 -8
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,6 @@ var index_exports = {};
|
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
ActiveLink: () => ActiveLink,
|
|
35
35
|
AppContainer: () => AppContainer_default,
|
|
36
|
-
ErrorRender: () => ErrorRender_default,
|
|
37
36
|
NavLink: () => NavLink2,
|
|
38
37
|
PagePlaceholder: () => PagePlaceholder_default,
|
|
39
38
|
QueryProvider: () => QueryProvider_default,
|
|
@@ -43,7 +42,6 @@ __export(index_exports, {
|
|
|
43
42
|
avatarImages: () => avatar_exports,
|
|
44
43
|
axiosForBackend: () => axiosForBackend,
|
|
45
44
|
bannerImages: () => banner_exports,
|
|
46
|
-
capabilityClient: () => capabilityClient,
|
|
47
45
|
clsxWithTw: () => clsxWithTw,
|
|
48
46
|
copyToClipboard: () => copyToClipboard,
|
|
49
47
|
coverImages: () => cover_exports,
|
|
@@ -56,18 +54,15 @@ __export(index_exports, {
|
|
|
56
54
|
getEnvPath: () => getEnvPath,
|
|
57
55
|
getWsPath: () => getWsPath,
|
|
58
56
|
initAxiosConfig: () => initAxiosConfig,
|
|
59
|
-
initObservable: () => initObservable,
|
|
60
57
|
isIOS: () => isIOS,
|
|
61
58
|
isIpad: () => isIpad,
|
|
62
59
|
isMobile: () => isMobile,
|
|
63
60
|
isPreview: () => isPreview,
|
|
64
|
-
logger: () => logger,
|
|
65
61
|
normalizeBasePath: () => normalizeBasePath,
|
|
66
62
|
reportTeaEvent: () => reportTeaEvent,
|
|
67
63
|
resolveAppUrl: () => resolveAppUrl,
|
|
68
64
|
safeStringify: () => safeStringify,
|
|
69
65
|
scopedStorage: () => scopedStorage,
|
|
70
|
-
trace: () => trace,
|
|
71
66
|
useAppInfo: () => useAppInfo,
|
|
72
67
|
useCurrentUserProfile: () => useCurrentUserProfile,
|
|
73
68
|
useIsMobile: () => useIsMobile,
|
|
@@ -76,8 +71,7 @@ __export(index_exports, {
|
|
|
76
71
|
module.exports = __toCommonJS(index_exports);
|
|
77
72
|
|
|
78
73
|
// src/components/AppContainer/index.tsx
|
|
79
|
-
var
|
|
80
|
-
var import_miaoda_inspector = require("@lark-apaas/miaoda-inspector");
|
|
74
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
81
75
|
|
|
82
76
|
// src/runtime/react-devtools-hook.ts
|
|
83
77
|
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
@@ -133,15 +127,15 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
133
127
|
if (!axiosInstance2) {
|
|
134
128
|
axiosInstance2 = import_axios.default;
|
|
135
129
|
}
|
|
136
|
-
axiosInstance2.interceptors.request.use((
|
|
130
|
+
axiosInstance2.interceptors.request.use((config) => {
|
|
137
131
|
const csrfToken = getCsrfToken();
|
|
138
132
|
if (csrfToken) {
|
|
139
|
-
|
|
133
|
+
config.headers["X-Suda-Csrf-Token"] = csrfToken;
|
|
140
134
|
}
|
|
141
135
|
if (typeof window !== "undefined") {
|
|
142
|
-
|
|
136
|
+
config.headers["X-Page-Route"] = window.location.pathname;
|
|
143
137
|
}
|
|
144
|
-
return
|
|
138
|
+
return config;
|
|
145
139
|
}, (error) => Promise.reject(error));
|
|
146
140
|
axiosInstance2.interceptors.response.use((response) => response, (error) => {
|
|
147
141
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -152,1018 +146,10 @@ function initAxiosConfig(axiosInstance2) {
|
|
|
152
146
|
}
|
|
153
147
|
__name(initAxiosConfig, "initAxiosConfig");
|
|
154
148
|
|
|
155
|
-
// src/runtime/observable.ts
|
|
156
|
-
var import_observable_web = require("@lark-apaas/observable-web");
|
|
157
|
-
|
|
158
|
-
// src/utils/apiPath.ts
|
|
159
|
-
function isNewPathEnabled() {
|
|
160
|
-
const basePath = process.env.CLIENT_BASE_PATH || "/";
|
|
161
|
-
return /^\/app\/[^/]/.test(basePath);
|
|
162
|
-
}
|
|
163
|
-
__name(isNewPathEnabled, "isNewPathEnabled");
|
|
164
|
-
|
|
165
|
-
// src/runtime/observable.ts
|
|
166
|
-
var initObservable = /* @__PURE__ */ __name(() => {
|
|
167
|
-
try {
|
|
168
|
-
const appId = window.appId;
|
|
169
|
-
import_observable_web.observable.start({
|
|
170
|
-
serviceName: "app",
|
|
171
|
-
env: process.env.NODE_ENV === "development" ? import_observable_web.AppEnv.Dev : import_observable_web.AppEnv.Prod,
|
|
172
|
-
collectorUrl: isNewPathEnabled() ? {
|
|
173
|
-
log: `/app/${appId}/__runtime__/api/v1/observability/logs/collect`,
|
|
174
|
-
trace: `/app/${appId}/__runtime__/api/v1/observability/traces/collect`,
|
|
175
|
-
metric: `/app/${appId}/__runtime__/api/v1/observability/metrics/collect`,
|
|
176
|
-
time: `/app/${appId}/__runtime__/api/v1/observability/current_server_timestamp`
|
|
177
|
-
} : {
|
|
178
|
-
log: `/spark/app/${appId}/runtime/api/v1/observability/logs/collect`,
|
|
179
|
-
trace: `/spark/app/${appId}/runtime/api/v1/observability/traces/collect`,
|
|
180
|
-
metric: `/spark/app/${appId}/runtime/api/v1/observability/metrics/collect`,
|
|
181
|
-
time: `/spark/api/v1/observability/app/${appId}/current_server_timestamp`
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.error("Failed to start WebObservableSdk:", error);
|
|
186
|
-
}
|
|
187
|
-
}, "initObservable");
|
|
188
|
-
|
|
189
|
-
// src/logger/logger.ts
|
|
190
|
-
var import_observable_web2 = require("@lark-apaas/observable-web");
|
|
191
|
-
|
|
192
|
-
// src/logger/intercept-global-error.ts
|
|
193
|
-
var import_internal_slardar = require("@lark-apaas/internal-slardar");
|
|
194
|
-
|
|
195
|
-
// src/utils/hmr-api.ts
|
|
196
|
-
var import_meta = {};
|
|
197
|
-
function createWebpackHmrApi(hot) {
|
|
198
|
-
return {
|
|
199
|
-
onSuccess(callback) {
|
|
200
|
-
let lastStatus = null;
|
|
201
|
-
const handler = /* @__PURE__ */ __name((status) => {
|
|
202
|
-
if (status === "idle" && lastStatus === "apply") {
|
|
203
|
-
try {
|
|
204
|
-
callback();
|
|
205
|
-
} catch (e) {
|
|
206
|
-
console.error("[HMR] Success callback error:", e);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
lastStatus = status;
|
|
210
|
-
}, "handler");
|
|
211
|
-
hot.addStatusHandler(handler);
|
|
212
|
-
return () => hot.removeStatusHandler(handler);
|
|
213
|
-
},
|
|
214
|
-
onError(callback) {
|
|
215
|
-
const handler = /* @__PURE__ */ __name((status) => {
|
|
216
|
-
if (status === "fail" || status === "abort") {
|
|
217
|
-
try {
|
|
218
|
-
callback(new Error(`HMR ${status}`));
|
|
219
|
-
} catch (e) {
|
|
220
|
-
console.error("[HMR] Error callback error:", e);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}, "handler");
|
|
224
|
-
hot.addStatusHandler(handler);
|
|
225
|
-
return () => hot.removeStatusHandler(handler);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
__name(createWebpackHmrApi, "createWebpackHmrApi");
|
|
230
|
-
function getHmrApi() {
|
|
231
|
-
if (process.env.NODE_ENV === "production") return null;
|
|
232
|
-
if (import_meta.webpackHot) {
|
|
233
|
-
return createWebpackHmrApi(import_meta.webpackHot);
|
|
234
|
-
}
|
|
235
|
-
if (typeof module !== "undefined" && module.hot) {
|
|
236
|
-
return createWebpackHmrApi(module.hot);
|
|
237
|
-
}
|
|
238
|
-
if (window.__VITE_HMR__) {
|
|
239
|
-
return window.__VITE_HMR__;
|
|
240
|
-
}
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
__name(getHmrApi, "getHmrApi");
|
|
244
|
-
|
|
245
|
-
// src/utils/postMessage.ts
|
|
246
|
-
var PARENT_ORIGIN_KEY = "__parentOrigin";
|
|
247
|
-
function getParentOriginFromParams() {
|
|
248
|
-
try {
|
|
249
|
-
const params = new URLSearchParams(window.location.search);
|
|
250
|
-
const origin = params.get(PARENT_ORIGIN_KEY);
|
|
251
|
-
if (origin) {
|
|
252
|
-
sessionStorage.setItem(PARENT_ORIGIN_KEY, origin);
|
|
253
|
-
return origin;
|
|
254
|
-
}
|
|
255
|
-
} catch {
|
|
256
|
-
}
|
|
257
|
-
try {
|
|
258
|
-
return sessionStorage.getItem(PARENT_ORIGIN_KEY) || void 0;
|
|
259
|
-
} catch {
|
|
260
|
-
return void 0;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
__name(getParentOriginFromParams, "getParentOriginFromParams");
|
|
264
|
-
function getLegacyParentOrigin() {
|
|
265
|
-
const { origin } = window.location;
|
|
266
|
-
if (origin.includes("force.feishuapp.net")) {
|
|
267
|
-
return "https://force.feishu.cn";
|
|
268
|
-
}
|
|
269
|
-
if (origin.includes("force-pre.feishuapp.net")) {
|
|
270
|
-
return "https://force.feishu-pre.cn";
|
|
271
|
-
}
|
|
272
|
-
if (origin.includes("force.byted.org")) {
|
|
273
|
-
return "https://force.feishu-boe.cn";
|
|
274
|
-
}
|
|
275
|
-
if (origin.includes("feishuapp.cn") || origin.includes("miaoda.feishuapp.net")) {
|
|
276
|
-
return "https://miaoda.feishu.cn";
|
|
277
|
-
}
|
|
278
|
-
if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
|
|
279
|
-
return "https://miaoda.feishu-pre.cn";
|
|
280
|
-
}
|
|
281
|
-
return "https://miaoda.feishu-boe.cn";
|
|
282
|
-
}
|
|
283
|
-
__name(getLegacyParentOrigin, "getLegacyParentOrigin");
|
|
284
|
-
function resolveParentOrigin() {
|
|
285
|
-
try {
|
|
286
|
-
if (document.referrer) {
|
|
287
|
-
const referrerOrigin = new URL(document.referrer).origin;
|
|
288
|
-
if (referrerOrigin.startsWith("http://localhost") || referrerOrigin.startsWith("http://127.0.0.1")) {
|
|
289
|
-
return referrerOrigin;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
} catch {
|
|
293
|
-
}
|
|
294
|
-
const paramOrigin = getParentOriginFromParams();
|
|
295
|
-
if (paramOrigin) return paramOrigin;
|
|
296
|
-
return process.env?.FORCE_FRAMEWORK_DOMAIN_MAIN ?? getLegacyParentOrigin();
|
|
297
|
-
}
|
|
298
|
-
__name(resolveParentOrigin, "resolveParentOrigin");
|
|
299
|
-
function submitPostMessage(message, targetOrigin) {
|
|
300
|
-
try {
|
|
301
|
-
const parentOrigin = resolveParentOrigin();
|
|
302
|
-
const origin = targetOrigin ?? parentOrigin;
|
|
303
|
-
if (!origin) return;
|
|
304
|
-
window.parent.postMessage(message, origin);
|
|
305
|
-
} catch (e) {
|
|
306
|
-
console.error("postMessage error", e);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
__name(submitPostMessage, "submitPostMessage");
|
|
310
|
-
|
|
311
|
-
// src/logger/log-types.ts
|
|
312
|
-
var LOG_LEVELS = [
|
|
313
|
-
"debug",
|
|
314
|
-
"info",
|
|
315
|
-
"warn",
|
|
316
|
-
"error",
|
|
317
|
-
"success"
|
|
318
|
-
];
|
|
319
|
-
function isLogLevel(value) {
|
|
320
|
-
return typeof value === "string" && LOG_LEVELS.includes(value);
|
|
321
|
-
}
|
|
322
|
-
__name(isLogLevel, "isLogLevel");
|
|
323
|
-
|
|
324
|
-
// src/logger/intercept-global-error.ts
|
|
325
|
-
var devServerDisconnectInfo = null;
|
|
326
|
-
var retryCount = 0;
|
|
327
|
-
function processDevServerLog(log) {
|
|
328
|
-
if (!log) return;
|
|
329
|
-
const devFlag = log.includes("[webpack-dev-server]") || log.includes("[vite]");
|
|
330
|
-
if (devFlag && log.includes("Disconnected")) {
|
|
331
|
-
const time = Date.now();
|
|
332
|
-
devServerDisconnectInfo = {
|
|
333
|
-
time
|
|
334
|
-
};
|
|
335
|
-
submitPostMessage({
|
|
336
|
-
type: "DevServerMessage",
|
|
337
|
-
data: {
|
|
338
|
-
type: "devServer-status",
|
|
339
|
-
status: "disconnected"
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
import_internal_slardar.slardar.sendEvent({
|
|
343
|
-
name: "sandbox-devServer",
|
|
344
|
-
metrics: {
|
|
345
|
-
time
|
|
346
|
-
},
|
|
347
|
-
categories: {
|
|
348
|
-
type: "disconnected"
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
if (!devServerDisconnectInfo) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
if (devFlag && log.includes("Trying to reconnect")) {
|
|
357
|
-
if (retryCount) {
|
|
358
|
-
import_internal_slardar.slardar.sendEvent({
|
|
359
|
-
name: "sandbox-devServer",
|
|
360
|
-
metrics: {
|
|
361
|
-
retryCount: retryCount + 1
|
|
362
|
-
},
|
|
363
|
-
categories: {
|
|
364
|
-
type: "reconnect-failed"
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
retryCount++;
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const hmrFlag = log.includes("[HMR]");
|
|
372
|
-
if (hmrFlag || devFlag && (log.includes("Socket connected") || log.includes("App updated") || log.includes("App hot update") || log.includes("connected"))) {
|
|
373
|
-
submitPostMessage({
|
|
374
|
-
type: "DevServerMessage",
|
|
375
|
-
data: {
|
|
376
|
-
type: "devServer-status",
|
|
377
|
-
status: "connected"
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
const startTime = devServerDisconnectInfo.time;
|
|
381
|
-
const duration = Date.now() - startTime;
|
|
382
|
-
import_internal_slardar.slardar.sendEvent({
|
|
383
|
-
name: "sandbox-devServer",
|
|
384
|
-
metrics: {
|
|
385
|
-
startTime,
|
|
386
|
-
duration
|
|
387
|
-
},
|
|
388
|
-
categories: {
|
|
389
|
-
type: "devServer-reconnected"
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
devServerDisconnectInfo = null;
|
|
393
|
-
retryCount = 0;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
__name(processDevServerLog, "processDevServerLog");
|
|
397
|
-
function listenModuleHmr() {
|
|
398
|
-
const hmr = getHmrApi();
|
|
399
|
-
if (hmr) {
|
|
400
|
-
hmr.onSuccess(() => {
|
|
401
|
-
submitPostMessage({
|
|
402
|
-
type: "DevServerMessage",
|
|
403
|
-
data: {
|
|
404
|
-
type: "devServer-status",
|
|
405
|
-
status: "hmr-apply-success"
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
hmr.onError((error) => {
|
|
410
|
-
console.warn("hmr apply failed", error);
|
|
411
|
-
import_internal_slardar.slardar.sendEvent({
|
|
412
|
-
name: "sandbox-devServer",
|
|
413
|
-
categories: {
|
|
414
|
-
type: "hmr-apply-failed",
|
|
415
|
-
error: String(error)
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
__name(listenModuleHmr, "listenModuleHmr");
|
|
422
|
-
var PROXY_CONSOLE_METHOD = [
|
|
423
|
-
"log",
|
|
424
|
-
"info",
|
|
425
|
-
"warn",
|
|
426
|
-
"error"
|
|
427
|
-
];
|
|
428
|
-
function interceptErrors() {
|
|
429
|
-
window.addEventListener("error", (event) => {
|
|
430
|
-
logger.error(event.error);
|
|
431
|
-
});
|
|
432
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
433
|
-
logger.error(event.reason);
|
|
434
|
-
});
|
|
435
|
-
listenModuleHmr();
|
|
436
|
-
PROXY_CONSOLE_METHOD.forEach((method) => {
|
|
437
|
-
const originalMethod = window.console[method];
|
|
438
|
-
window.console[method] = (...args) => {
|
|
439
|
-
originalMethod(...args);
|
|
440
|
-
const level = method === "log" ? "info" : method;
|
|
441
|
-
const first = args[0];
|
|
442
|
-
if (typeof first === "string") {
|
|
443
|
-
processDevServerLog(first);
|
|
444
|
-
}
|
|
445
|
-
if (typeof first === "string" && first.startsWith("[Dataloom]") && isLogLevel(level)) {
|
|
446
|
-
logger.log({
|
|
447
|
-
level,
|
|
448
|
-
args
|
|
449
|
-
});
|
|
450
|
-
submitPostMessage({
|
|
451
|
-
type: "Console",
|
|
452
|
-
method,
|
|
453
|
-
data: args
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
__name(interceptErrors, "interceptErrors");
|
|
460
|
-
|
|
461
|
-
// src/utils/safeStringify.ts
|
|
462
|
-
function safeStringify(obj) {
|
|
463
|
-
const seen = /* @__PURE__ */ new Set();
|
|
464
|
-
try {
|
|
465
|
-
return JSON.stringify(obj, (_key, value) => {
|
|
466
|
-
if (typeof value === "object" && value !== null) {
|
|
467
|
-
if (seen.has(value)) {
|
|
468
|
-
return "[Circular]";
|
|
469
|
-
}
|
|
470
|
-
seen.add(value);
|
|
471
|
-
}
|
|
472
|
-
if (typeof value === "bigint") {
|
|
473
|
-
return value.toString();
|
|
474
|
-
}
|
|
475
|
-
if (value instanceof Date) {
|
|
476
|
-
return value.toISOString();
|
|
477
|
-
}
|
|
478
|
-
if (value instanceof Map) {
|
|
479
|
-
return Object.fromEntries(value);
|
|
480
|
-
}
|
|
481
|
-
if (value instanceof Set) {
|
|
482
|
-
return Array.from(value);
|
|
483
|
-
}
|
|
484
|
-
if (value instanceof Error) {
|
|
485
|
-
return {
|
|
486
|
-
name: value.name,
|
|
487
|
-
message: value.message,
|
|
488
|
-
stack: value.stack
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
if (typeof value === "undefined") {
|
|
492
|
-
return "undefined";
|
|
493
|
-
}
|
|
494
|
-
if (typeof value === "symbol") {
|
|
495
|
-
return value.toString();
|
|
496
|
-
}
|
|
497
|
-
return value;
|
|
498
|
-
});
|
|
499
|
-
} catch {
|
|
500
|
-
return "";
|
|
501
|
-
} finally {
|
|
502
|
-
seen.clear();
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
__name(safeStringify, "safeStringify");
|
|
506
|
-
function processLogParams(args) {
|
|
507
|
-
return args.map((arg) => {
|
|
508
|
-
if (typeof arg === "string") return arg;
|
|
509
|
-
if (arg instanceof Error) {
|
|
510
|
-
return `${arg.name}: ${arg.message}
|
|
511
|
-
${arg.stack ?? ""}`;
|
|
512
|
-
}
|
|
513
|
-
if (typeof arg === "object" && arg !== null) {
|
|
514
|
-
return safeStringify(arg);
|
|
515
|
-
}
|
|
516
|
-
return String(arg);
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
__name(processLogParams, "processLogParams");
|
|
520
|
-
function mapLogLevel(level) {
|
|
521
|
-
if (level === "warn") return "WARN";
|
|
522
|
-
if (level === "error") return "ERROR";
|
|
523
|
-
return "INFO";
|
|
524
|
-
}
|
|
525
|
-
__name(mapLogLevel, "mapLogLevel");
|
|
526
|
-
|
|
527
|
-
// src/logger/selected-logs.ts
|
|
528
|
-
var import_stacktrace_js = __toESM(require("stacktrace-js"), 1);
|
|
529
|
-
|
|
530
|
-
// src/logger/batch-logger.ts
|
|
531
|
-
var BatchLogger = class {
|
|
532
|
-
static {
|
|
533
|
-
__name(this, "BatchLogger");
|
|
534
|
-
}
|
|
535
|
-
config;
|
|
536
|
-
logQueue = [];
|
|
537
|
-
flushTimer = null;
|
|
538
|
-
isProcessing = false;
|
|
539
|
-
originConsole;
|
|
540
|
-
constructor(console1, config2) {
|
|
541
|
-
this.originConsole = {
|
|
542
|
-
...console1
|
|
543
|
-
};
|
|
544
|
-
const { userId = "", tenantId = "", appId = "" } = window || {};
|
|
545
|
-
this.config = {
|
|
546
|
-
userId,
|
|
547
|
-
tenantId,
|
|
548
|
-
appId,
|
|
549
|
-
// 需要加请求路径前缀
|
|
550
|
-
endpoint: (process.env.CLIENT_BASE_PATH || "") + "/dev/logs/collect-batch",
|
|
551
|
-
sizeThreshold: 20,
|
|
552
|
-
flushInterval: 1e3,
|
|
553
|
-
maxRetries: 3,
|
|
554
|
-
retryDelay: 500,
|
|
555
|
-
headers: {
|
|
556
|
-
"Content-Type": "application/json"
|
|
557
|
-
},
|
|
558
|
-
...config2 || {}
|
|
559
|
-
};
|
|
560
|
-
this.startFlushTimer();
|
|
561
|
-
this.setupBeforeUnloadHandler();
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* 批量记录日志(对外暴露的唯一方法)
|
|
565
|
-
*/
|
|
566
|
-
batchLog(level, message, source) {
|
|
567
|
-
const logEntry = {
|
|
568
|
-
id: this.generateId(),
|
|
569
|
-
level,
|
|
570
|
-
message,
|
|
571
|
-
source,
|
|
572
|
-
timestamp: Date.now()
|
|
573
|
-
};
|
|
574
|
-
this.logQueue.push(logEntry);
|
|
575
|
-
if (this.logQueue.length >= this.config.sizeThreshold) {
|
|
576
|
-
this.flush();
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* 刷新日志队列,全部发送
|
|
581
|
-
*/
|
|
582
|
-
async flush() {
|
|
583
|
-
if (this.isProcessing || this.logQueue.length === 0) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
this.isProcessing = true;
|
|
587
|
-
const logsToSend = this.logQueue.splice(0, this.logQueue.length);
|
|
588
|
-
try {
|
|
589
|
-
await this.sendBatch(logsToSend);
|
|
590
|
-
} catch (error) {
|
|
591
|
-
this.logQueue.unshift(...logsToSend);
|
|
592
|
-
} finally {
|
|
593
|
-
this.isProcessing = false;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* 发送日志批次到后端
|
|
598
|
-
*/
|
|
599
|
-
async sendBatch(logs) {
|
|
600
|
-
const collectLogs = logs.map((log) => ({
|
|
601
|
-
level: log.level,
|
|
602
|
-
message: log.message,
|
|
603
|
-
time: new Date(log.timestamp).toISOString(),
|
|
604
|
-
source: log.source,
|
|
605
|
-
user_id: this.config.userId,
|
|
606
|
-
tenant_id: this.config.tenantId,
|
|
607
|
-
app_id: this.config.appId
|
|
608
|
-
}));
|
|
609
|
-
let retries = 0;
|
|
610
|
-
while (retries <= this.config.maxRetries) {
|
|
611
|
-
try {
|
|
612
|
-
await this.execFetch(this.config.endpoint, {
|
|
613
|
-
method: "POST",
|
|
614
|
-
headers: this.config.headers,
|
|
615
|
-
body: JSON.stringify(collectLogs)
|
|
616
|
-
});
|
|
617
|
-
return;
|
|
618
|
-
} catch (error) {
|
|
619
|
-
retries++;
|
|
620
|
-
if (retries > this.config.maxRetries) {
|
|
621
|
-
this.originConsole.error(`Failed to send logs (attempt ${retries}), retrying in ${this.config.retryDelay}ms...`);
|
|
622
|
-
} else {
|
|
623
|
-
this.originConsole.warn(`Failed to send logs (attempt ${retries}), retrying in ${this.config.retryDelay}ms...`);
|
|
624
|
-
}
|
|
625
|
-
await this.delay(this.config.retryDelay * retries);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* 执行实际的fetch请求
|
|
631
|
-
*/
|
|
632
|
-
async execFetch(url, options) {
|
|
633
|
-
return fetch(url, options);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* 启动自动刷新定时器
|
|
637
|
-
*/
|
|
638
|
-
startFlushTimer() {
|
|
639
|
-
if (this.flushTimer) {
|
|
640
|
-
clearInterval(this.flushTimer);
|
|
641
|
-
}
|
|
642
|
-
this.flushTimer = setInterval(() => {
|
|
643
|
-
if (this.logQueue.length > 0) {
|
|
644
|
-
this.flush();
|
|
645
|
-
}
|
|
646
|
-
}, this.config.flushInterval);
|
|
647
|
-
}
|
|
648
|
-
/**
|
|
649
|
-
* 设置页面卸载时的处理
|
|
650
|
-
*/
|
|
651
|
-
setupBeforeUnloadHandler() {
|
|
652
|
-
if (typeof window !== "undefined") {
|
|
653
|
-
window.addEventListener("beforeunload", () => {
|
|
654
|
-
this.flush().finally(() => {
|
|
655
|
-
this.destroy();
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* 延迟函数
|
|
662
|
-
*/
|
|
663
|
-
delay(ms) {
|
|
664
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* 生成唯一ID
|
|
668
|
-
*/
|
|
669
|
-
generateId() {
|
|
670
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* 销毁资源
|
|
674
|
-
*/
|
|
675
|
-
async destroy() {
|
|
676
|
-
if (this.flushTimer) {
|
|
677
|
-
clearInterval(this.flushTimer);
|
|
678
|
-
this.flushTimer = null;
|
|
679
|
-
}
|
|
680
|
-
if (this.logQueue.length > 0) {
|
|
681
|
-
await this.flush();
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* 获取队列大小
|
|
686
|
-
*/
|
|
687
|
-
getQueueSize() {
|
|
688
|
-
return this.logQueue.length;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* 更新配置
|
|
692
|
-
*/
|
|
693
|
-
updateConfig(newConfig) {
|
|
694
|
-
this.config = {
|
|
695
|
-
...this.config,
|
|
696
|
-
...newConfig
|
|
697
|
-
};
|
|
698
|
-
this.startFlushTimer();
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
var defaultBatchLogger = null;
|
|
702
|
-
function batchLogInfo(level, message, source) {
|
|
703
|
-
if (!defaultBatchLogger) {
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
defaultBatchLogger.batchLog(level, message, source);
|
|
707
|
-
}
|
|
708
|
-
__name(batchLogInfo, "batchLogInfo");
|
|
709
|
-
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
710
|
-
defaultBatchLogger = new BatchLogger(console);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/logger/selected-logs.ts
|
|
714
|
-
function mapStacktrace(stacktrace) {
|
|
715
|
-
return stacktrace.map((frame) => ({
|
|
716
|
-
functionName: frame.functionName || "",
|
|
717
|
-
fileName: frame.fileName || "",
|
|
718
|
-
lineNumber: frame.lineNumber || 0,
|
|
719
|
-
columnNumber: frame.columnNumber || 0
|
|
720
|
-
}));
|
|
721
|
-
}
|
|
722
|
-
__name(mapStacktrace, "mapStacktrace");
|
|
723
|
-
function reportStacktraceParseError(e, context) {
|
|
724
|
-
if (window.parent === window) return;
|
|
725
|
-
try {
|
|
726
|
-
submitPostMessage({
|
|
727
|
-
type: "STACKTRACE_PARSE_ERROR",
|
|
728
|
-
payload: {
|
|
729
|
-
error: e instanceof Error ? e.message : String(e),
|
|
730
|
-
context
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
} catch {
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
__name(reportStacktraceParseError, "reportStacktraceParseError");
|
|
737
|
-
async function getStacktrace() {
|
|
738
|
-
const stacktrace = await import_stacktrace_js.default.get();
|
|
739
|
-
return mapStacktrace(stacktrace);
|
|
740
|
-
}
|
|
741
|
-
__name(getStacktrace, "getStacktrace");
|
|
742
|
-
function errorReplacer(_key, value) {
|
|
743
|
-
if (value instanceof Error) {
|
|
744
|
-
return {
|
|
745
|
-
message: value.message,
|
|
746
|
-
stack: value.stack,
|
|
747
|
-
name: value.name
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
return value;
|
|
751
|
-
}
|
|
752
|
-
__name(errorReplacer, "errorReplacer");
|
|
753
|
-
function generateLogId() {
|
|
754
|
-
try {
|
|
755
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
756
|
-
return crypto.randomUUID();
|
|
757
|
-
}
|
|
758
|
-
} catch {
|
|
759
|
-
}
|
|
760
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
761
|
-
}
|
|
762
|
-
__name(generateLogId, "generateLogId");
|
|
763
|
-
var lastLogInfo = null;
|
|
764
|
-
async function sendSelectedLog(logWithoutID) {
|
|
765
|
-
try {
|
|
766
|
-
const log = {
|
|
767
|
-
...logWithoutID,
|
|
768
|
-
id: generateLogId()
|
|
769
|
-
};
|
|
770
|
-
const newParts = [];
|
|
771
|
-
for (let i = 0; i < log.args.length; i++) {
|
|
772
|
-
const item = log.args[i];
|
|
773
|
-
if (item instanceof Error) {
|
|
774
|
-
const newError = {
|
|
775
|
-
message: item.message,
|
|
776
|
-
stack: item.stack,
|
|
777
|
-
name: item.name
|
|
778
|
-
};
|
|
779
|
-
if (!log.meta.stacktrace) {
|
|
780
|
-
try {
|
|
781
|
-
const stacktrace = await import_stacktrace_js.default.fromError(item);
|
|
782
|
-
log.meta.stacktrace = mapStacktrace(stacktrace);
|
|
783
|
-
} catch (e) {
|
|
784
|
-
reportStacktraceParseError(e, "StackTrace.fromError");
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
newParts.push(newError.message, newError);
|
|
788
|
-
} else {
|
|
789
|
-
newParts.push(item);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
log.args = newParts;
|
|
793
|
-
if (!log.meta.stacktrace) {
|
|
794
|
-
try {
|
|
795
|
-
const frames = await getStacktrace();
|
|
796
|
-
const firstFrameIndex = frames.findIndex((frame) => !frame.fileName.includes("client-toolkit-lite/dist/logger"));
|
|
797
|
-
log.meta.stacktrace = firstFrameIndex === -1 ? [] : frames.slice(firstFrameIndex);
|
|
798
|
-
} catch (e) {
|
|
799
|
-
reportStacktraceParseError(e, "getStacktrace");
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
if (log.meta.skipFrame === void 0) {
|
|
803
|
-
log.meta.skipFrame = 2;
|
|
804
|
-
}
|
|
805
|
-
const logJSON = JSON.stringify(log, errorReplacer);
|
|
806
|
-
const logForDedup = {
|
|
807
|
-
...log
|
|
808
|
-
};
|
|
809
|
-
delete logForDedup.id;
|
|
810
|
-
const logContentForDedup = JSON.stringify(logForDedup, errorReplacer);
|
|
811
|
-
if (lastLogInfo && lastLogInfo.content === logContentForDedup) {
|
|
812
|
-
lastLogInfo.count++;
|
|
813
|
-
log.meta.isDuplicate = true;
|
|
814
|
-
log.meta.duplicateCount = lastLogInfo.count;
|
|
815
|
-
log.meta.duplicateOfId = lastLogInfo.id;
|
|
816
|
-
const updatedJSON = JSON.stringify(log, errorReplacer);
|
|
817
|
-
try {
|
|
818
|
-
batchLogInfo("info", updatedJSON);
|
|
819
|
-
} catch {
|
|
820
|
-
}
|
|
821
|
-
if (window.parent !== window) {
|
|
822
|
-
try {
|
|
823
|
-
submitPostMessage({
|
|
824
|
-
type: "SELECTED_LOG",
|
|
825
|
-
payload: updatedJSON
|
|
826
|
-
});
|
|
827
|
-
} catch {
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
lastLogInfo = {
|
|
833
|
-
content: logContentForDedup,
|
|
834
|
-
id: log.id,
|
|
835
|
-
count: 1
|
|
836
|
-
};
|
|
837
|
-
try {
|
|
838
|
-
batchLogInfo("info", logJSON);
|
|
839
|
-
} catch {
|
|
840
|
-
}
|
|
841
|
-
if (window.parent !== window) {
|
|
842
|
-
try {
|
|
843
|
-
submitPostMessage({
|
|
844
|
-
type: "SELECTED_LOG",
|
|
845
|
-
payload: logJSON
|
|
846
|
-
});
|
|
847
|
-
} catch {
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
} catch {
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
__name(sendSelectedLog, "sendSelectedLog");
|
|
854
|
-
function sendTypedLogV2(logWithMeta) {
|
|
855
|
-
void sendSelectedLog({
|
|
856
|
-
type: "typedLogV2",
|
|
857
|
-
level: logWithMeta.level,
|
|
858
|
-
args: logWithMeta.args,
|
|
859
|
-
meta: logWithMeta.meta ?? {}
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
__name(sendTypedLogV2, "sendTypedLogV2");
|
|
863
|
-
var typedLogInterceptor = /* @__PURE__ */ __name((originLogger) => ({
|
|
864
|
-
debug: /* @__PURE__ */ __name((message, ...args) => {
|
|
865
|
-
try {
|
|
866
|
-
originLogger.debug(message, ...args);
|
|
867
|
-
} catch {
|
|
868
|
-
}
|
|
869
|
-
sendTypedLogV2({
|
|
870
|
-
level: "info",
|
|
871
|
-
args: [
|
|
872
|
-
message,
|
|
873
|
-
...args
|
|
874
|
-
],
|
|
875
|
-
meta: {}
|
|
876
|
-
});
|
|
877
|
-
}, "debug"),
|
|
878
|
-
info: /* @__PURE__ */ __name((message, ...args) => {
|
|
879
|
-
try {
|
|
880
|
-
originLogger.info(message, ...args);
|
|
881
|
-
} catch {
|
|
882
|
-
}
|
|
883
|
-
sendTypedLogV2({
|
|
884
|
-
level: "info",
|
|
885
|
-
args: [
|
|
886
|
-
message,
|
|
887
|
-
...args
|
|
888
|
-
],
|
|
889
|
-
meta: {}
|
|
890
|
-
});
|
|
891
|
-
}, "info"),
|
|
892
|
-
warn: /* @__PURE__ */ __name((message, ...args) => {
|
|
893
|
-
try {
|
|
894
|
-
originLogger.warn(message, ...args);
|
|
895
|
-
} catch {
|
|
896
|
-
}
|
|
897
|
-
sendTypedLogV2({
|
|
898
|
-
level: "warn",
|
|
899
|
-
args: [
|
|
900
|
-
message,
|
|
901
|
-
...args
|
|
902
|
-
],
|
|
903
|
-
meta: {}
|
|
904
|
-
});
|
|
905
|
-
}, "warn"),
|
|
906
|
-
error: /* @__PURE__ */ __name((message, ...args) => {
|
|
907
|
-
try {
|
|
908
|
-
originLogger.error(message, ...args);
|
|
909
|
-
} catch {
|
|
910
|
-
}
|
|
911
|
-
sendTypedLogV2({
|
|
912
|
-
level: "error",
|
|
913
|
-
args: [
|
|
914
|
-
message,
|
|
915
|
-
...args
|
|
916
|
-
],
|
|
917
|
-
meta: {}
|
|
918
|
-
});
|
|
919
|
-
}, "error"),
|
|
920
|
-
success: /* @__PURE__ */ __name((message, ...args) => {
|
|
921
|
-
try {
|
|
922
|
-
originLogger.success(message, ...args);
|
|
923
|
-
} catch {
|
|
924
|
-
}
|
|
925
|
-
sendTypedLogV2({
|
|
926
|
-
level: "success",
|
|
927
|
-
args: [
|
|
928
|
-
message,
|
|
929
|
-
...args
|
|
930
|
-
],
|
|
931
|
-
meta: {}
|
|
932
|
-
});
|
|
933
|
-
}, "success"),
|
|
934
|
-
log: /* @__PURE__ */ __name(({ level, args, meta }) => {
|
|
935
|
-
try {
|
|
936
|
-
originLogger.log({
|
|
937
|
-
level,
|
|
938
|
-
args,
|
|
939
|
-
meta
|
|
940
|
-
});
|
|
941
|
-
} catch {
|
|
942
|
-
}
|
|
943
|
-
sendTypedLogV2({
|
|
944
|
-
level,
|
|
945
|
-
args,
|
|
946
|
-
meta: meta ?? {}
|
|
947
|
-
});
|
|
948
|
-
}, "log")
|
|
949
|
-
}), "typedLogInterceptor");
|
|
950
|
-
var interceptors = [
|
|
951
|
-
typedLogInterceptor
|
|
952
|
-
];
|
|
953
|
-
|
|
954
|
-
// src/logger/logger.ts
|
|
955
|
-
var shouldReportToObservable = process.env.NODE_ENV === "production";
|
|
956
|
-
var ORDERED_LEVELS = [
|
|
957
|
-
"debug",
|
|
958
|
-
"info",
|
|
959
|
-
"warn",
|
|
960
|
-
"error"
|
|
961
|
-
];
|
|
962
|
-
var defaultConfig = {
|
|
963
|
-
showLevel: false,
|
|
964
|
-
showTimestamp: false,
|
|
965
|
-
level: "info",
|
|
966
|
-
prefix: ""
|
|
967
|
-
};
|
|
968
|
-
var config = {
|
|
969
|
-
...defaultConfig
|
|
970
|
-
};
|
|
971
|
-
function configureLogger(options) {
|
|
972
|
-
config = {
|
|
973
|
-
...defaultConfig,
|
|
974
|
-
...options
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
__name(configureLogger, "configureLogger");
|
|
978
|
-
function shouldLog(level) {
|
|
979
|
-
return ORDERED_LEVELS.indexOf(level) >= ORDERED_LEVELS.indexOf(config.level);
|
|
980
|
-
}
|
|
981
|
-
__name(shouldLog, "shouldLog");
|
|
982
|
-
function getFormattedPrefix(level) {
|
|
983
|
-
const parts = [];
|
|
984
|
-
if (config.prefix) {
|
|
985
|
-
parts.push(`[${config.prefix}]`);
|
|
986
|
-
}
|
|
987
|
-
if (config.showLevel) {
|
|
988
|
-
parts.push(`[${level.toUpperCase()}]`);
|
|
989
|
-
}
|
|
990
|
-
return parts;
|
|
991
|
-
}
|
|
992
|
-
__name(getFormattedPrefix, "getFormattedPrefix");
|
|
993
|
-
configureLogger({
|
|
994
|
-
showLevel: true,
|
|
995
|
-
showTimestamp: false,
|
|
996
|
-
level: process.env.NODE_ENV === "development" ? "debug" : "error",
|
|
997
|
-
prefix: "MiaoDa"
|
|
998
|
-
});
|
|
999
|
-
var logger = {
|
|
1000
|
-
debug(message, ...args) {
|
|
1001
|
-
if (shouldLog("debug")) {
|
|
1002
|
-
console.log(...getFormattedPrefix("debug"), message, ...args);
|
|
1003
|
-
}
|
|
1004
|
-
},
|
|
1005
|
-
info(message, ...args) {
|
|
1006
|
-
if (shouldLog("info")) {
|
|
1007
|
-
console.log(...getFormattedPrefix("info"), message, ...args);
|
|
1008
|
-
}
|
|
1009
|
-
if (shouldReportToObservable) {
|
|
1010
|
-
import_observable_web2.observable.log("INFO", processLogParams([
|
|
1011
|
-
message,
|
|
1012
|
-
...args
|
|
1013
|
-
]).join(" "));
|
|
1014
|
-
}
|
|
1015
|
-
},
|
|
1016
|
-
warn(message, ...args) {
|
|
1017
|
-
if (shouldLog("warn")) {
|
|
1018
|
-
console.log(...getFormattedPrefix("warn"), message, ...args);
|
|
1019
|
-
}
|
|
1020
|
-
if (shouldReportToObservable) {
|
|
1021
|
-
import_observable_web2.observable.log("WARN", processLogParams([
|
|
1022
|
-
message,
|
|
1023
|
-
...args
|
|
1024
|
-
]).join(" "));
|
|
1025
|
-
}
|
|
1026
|
-
},
|
|
1027
|
-
error(message, ...args) {
|
|
1028
|
-
if (shouldLog("error")) {
|
|
1029
|
-
console.error(...getFormattedPrefix("error"), message, ...args);
|
|
1030
|
-
}
|
|
1031
|
-
if (shouldReportToObservable) {
|
|
1032
|
-
import_observable_web2.observable.log("ERROR", processLogParams([
|
|
1033
|
-
message,
|
|
1034
|
-
...args
|
|
1035
|
-
]).join(" "));
|
|
1036
|
-
}
|
|
1037
|
-
},
|
|
1038
|
-
success(message, ...args) {
|
|
1039
|
-
if (shouldLog("info")) {
|
|
1040
|
-
console.log(...getFormattedPrefix("success"), message, ...args);
|
|
1041
|
-
}
|
|
1042
|
-
if (shouldReportToObservable) {
|
|
1043
|
-
import_observable_web2.observable.log("INFO", processLogParams([
|
|
1044
|
-
message,
|
|
1045
|
-
...args
|
|
1046
|
-
]).join(" "));
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
log({ level, args }) {
|
|
1050
|
-
if (shouldLog(level)) {
|
|
1051
|
-
console.log(...getFormattedPrefix(level), ...args);
|
|
1052
|
-
}
|
|
1053
|
-
if (shouldReportToObservable && level !== "debug") {
|
|
1054
|
-
import_observable_web2.observable.log(mapLogLevel(level), processLogParams(args).join(" "));
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
};
|
|
1058
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1059
|
-
window.__RUNTIME_LOGGER__ = {
|
|
1060
|
-
get() {
|
|
1061
|
-
return logger;
|
|
1062
|
-
}
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
for (const interceptor of interceptors) {
|
|
1066
|
-
logger = interceptor(logger);
|
|
1067
|
-
}
|
|
1068
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1069
|
-
interceptErrors();
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
// src/runtime/iframe-bridge.ts
|
|
1073
|
-
var import_penpal = require("penpal");
|
|
1074
|
-
|
|
1075
|
-
// src/utils/utils.ts
|
|
1076
|
-
var import_clsx = require("clsx");
|
|
1077
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
1078
|
-
function clsxWithTw(...inputs) {
|
|
1079
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
1080
|
-
}
|
|
1081
|
-
__name(clsxWithTw, "clsxWithTw");
|
|
1082
|
-
function isPreview() {
|
|
1083
|
-
return window.IS_MIAODA_PREVIEW;
|
|
1084
|
-
}
|
|
1085
|
-
__name(isPreview, "isPreview");
|
|
1086
|
-
function normalizeBasePath(basePath) {
|
|
1087
|
-
if (!basePath || basePath === "/") {
|
|
1088
|
-
return "";
|
|
1089
|
-
}
|
|
1090
|
-
return basePath.replace(/\/+$/, "");
|
|
1091
|
-
}
|
|
1092
|
-
__name(normalizeBasePath, "normalizeBasePath");
|
|
1093
|
-
function getWsPath() {
|
|
1094
|
-
const rawBasePath = process.env.CLIENT_BASE_PATH || "/";
|
|
1095
|
-
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
1096
|
-
const basePathWithoutTrailingSlash = normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
1097
|
-
return `${basePathWithoutTrailingSlash}/ws`;
|
|
1098
|
-
}
|
|
1099
|
-
__name(getWsPath, "getWsPath");
|
|
1100
|
-
function isSparkRuntime() {
|
|
1101
|
-
return window._IS_Spark_RUNTIME ?? process.env.runtimeMode === "fullstack";
|
|
1102
|
-
}
|
|
1103
|
-
__name(isSparkRuntime, "isSparkRuntime");
|
|
1104
|
-
|
|
1105
|
-
// src/components/AppContainer/utils/childApi.ts
|
|
1106
|
-
async function getRoutes() {
|
|
1107
|
-
let routes = [
|
|
1108
|
-
{
|
|
1109
|
-
path: "/"
|
|
1110
|
-
}
|
|
1111
|
-
];
|
|
1112
|
-
try {
|
|
1113
|
-
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
|
1114
|
-
const res = await fetch(`${basePath}/routes.json`);
|
|
1115
|
-
routes = await res.json();
|
|
1116
|
-
} catch (error) {
|
|
1117
|
-
console.warn("get routes.json error", error);
|
|
1118
|
-
}
|
|
1119
|
-
return routes;
|
|
1120
|
-
}
|
|
1121
|
-
__name(getRoutes, "getRoutes");
|
|
1122
|
-
var childApi = {
|
|
1123
|
-
getRoutes,
|
|
1124
|
-
updateAppInfo: /* @__PURE__ */ __name((appInfo) => {
|
|
1125
|
-
dispatchEvent(new CustomEvent("MiaoDaMetaInfoChanged", {
|
|
1126
|
-
detail: appInfo
|
|
1127
|
-
}));
|
|
1128
|
-
}, "updateAppInfo")
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
|
-
// src/runtime/iframe-bridge.ts
|
|
1132
|
-
async function connectParent() {
|
|
1133
|
-
submitPostMessage({
|
|
1134
|
-
type: "PreviewReady",
|
|
1135
|
-
data: {}
|
|
1136
|
-
});
|
|
1137
|
-
batchLogInfo("info", JSON.stringify({
|
|
1138
|
-
type: "PreviewReady",
|
|
1139
|
-
timestamp: Date.now(),
|
|
1140
|
-
url: window.location.href
|
|
1141
|
-
}));
|
|
1142
|
-
const parentOrigin = resolveParentOrigin();
|
|
1143
|
-
if (!parentOrigin) return;
|
|
1144
|
-
const connection = (0, import_penpal.connectToParent)({
|
|
1145
|
-
parentOrigin,
|
|
1146
|
-
methods: {
|
|
1147
|
-
...childApi
|
|
1148
|
-
}
|
|
1149
|
-
});
|
|
1150
|
-
await connection.promise;
|
|
1151
|
-
}
|
|
1152
|
-
__name(connectParent, "connectParent");
|
|
1153
|
-
function initIframeBridge() {
|
|
1154
|
-
if (window.parent === window) return;
|
|
1155
|
-
connectParent();
|
|
1156
|
-
}
|
|
1157
|
-
__name(initIframeBridge, "initIframeBridge");
|
|
1158
|
-
|
|
1159
149
|
// src/runtime/index.ts
|
|
1160
150
|
if (!window.__FULLSTACK_RUNTIME_INITIALIZED__) {
|
|
1161
151
|
window.__FULLSTACK_RUNTIME_INITIALIZED__ = true;
|
|
1162
152
|
initAxiosConfig();
|
|
1163
|
-
initObservable();
|
|
1164
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1165
|
-
initIframeBridge();
|
|
1166
|
-
}
|
|
1167
153
|
}
|
|
1168
154
|
|
|
1169
155
|
// src/components/AppContainer/safety.tsx
|
|
@@ -1178,6 +164,16 @@ function getAppId() {
|
|
|
1178
164
|
}
|
|
1179
165
|
__name(getAppId, "getAppId");
|
|
1180
166
|
|
|
167
|
+
// src/utils/apiPath.ts
|
|
168
|
+
function isNewPathEnabled() {
|
|
169
|
+
const basePath = process.env.CLIENT_BASE_PATH || "/";
|
|
170
|
+
return /^\/app\/[^/]/.test(basePath);
|
|
171
|
+
}
|
|
172
|
+
__name(isNewPathEnabled, "isNewPathEnabled");
|
|
173
|
+
|
|
174
|
+
// src/hooks/useAppInfo.tsx
|
|
175
|
+
var import_react = require("react");
|
|
176
|
+
|
|
1181
177
|
// src/utils/getInitialInfo.ts
|
|
1182
178
|
async function getAppPublished() {
|
|
1183
179
|
try {
|
|
@@ -1228,46 +224,35 @@ function getInitialInfo(refresh = false) {
|
|
|
1228
224
|
}
|
|
1229
225
|
__name(getInitialInfo, "getInitialInfo");
|
|
1230
226
|
|
|
1231
|
-
// src/utils/
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const response = await fetch(`${window.location.origin}${path}`, {
|
|
1237
|
-
method: "GET",
|
|
1238
|
-
headers: {
|
|
1239
|
-
"X-Suda-Csrf-Token": getCsrfToken() ?? ""
|
|
1240
|
-
},
|
|
1241
|
-
credentials: "include"
|
|
1242
|
-
});
|
|
1243
|
-
const res = await response.json();
|
|
1244
|
-
return res?.data;
|
|
1245
|
-
} catch {
|
|
1246
|
-
return void 0;
|
|
1247
|
-
}
|
|
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));
|
|
1248
232
|
}
|
|
1249
|
-
__name(
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
return pendingPromise2;
|
|
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 "";
|
|
1258
241
|
}
|
|
1259
|
-
|
|
1260
|
-
tenantInfo = info;
|
|
1261
|
-
return tenantInfo;
|
|
1262
|
-
}).finally(() => {
|
|
1263
|
-
pendingPromise2 = null;
|
|
1264
|
-
});
|
|
1265
|
-
return pendingPromise2;
|
|
242
|
+
return basePath.replace(/\/+$/, "");
|
|
1266
243
|
}
|
|
1267
|
-
__name(
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
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");
|
|
1271
256
|
|
|
1272
257
|
// src/integrations/getAppInfo.ts
|
|
1273
258
|
async function getAppInfo(refresh = false) {
|
|
@@ -1340,90 +325,28 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
1340
325
|
const onUpdate = /* @__PURE__ */ __name((e) => {
|
|
1341
326
|
const info = e.detail;
|
|
1342
327
|
handleMetaInfoChanged(info);
|
|
1343
|
-
}, "onUpdate");
|
|
1344
|
-
window.addEventListener("MiaoDaMetaInfoChanged", onUpdate);
|
|
1345
|
-
return () => {
|
|
1346
|
-
window.removeEventListener("MiaoDaMetaInfoChanged", onUpdate);
|
|
1347
|
-
};
|
|
1348
|
-
}, []);
|
|
1349
|
-
return {
|
|
1350
|
-
...appInfo,
|
|
1351
|
-
appName: appInfo.name,
|
|
1352
|
-
appLogo: appInfo.avatar
|
|
1353
|
-
};
|
|
1354
|
-
}, "useAppInfo");
|
|
1355
|
-
|
|
1356
|
-
// src/hooks/useCurrentUserProfile.tsx
|
|
1357
|
-
var import_react2 = require("react");
|
|
1358
|
-
|
|
1359
|
-
// src/integrations/getCurrentUserProfile.ts
|
|
1360
|
-
function getCurrentUserProfile() {
|
|
1361
|
-
return window._userInfo || {};
|
|
1362
|
-
}
|
|
1363
|
-
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1364
|
-
|
|
1365
|
-
// src/utils/url.ts
|
|
1366
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
1367
|
-
try {
|
|
1368
|
-
const url = new URL(fullUrl);
|
|
1369
|
-
const pathParts = url.pathname.split("/");
|
|
1370
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
1371
|
-
if (workspacesIndex === -1) {
|
|
1372
|
-
throw new Error("Invalid workspace URL format");
|
|
1373
|
-
}
|
|
1374
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
1375
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
1376
|
-
return {
|
|
1377
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
1378
|
-
workspace
|
|
328
|
+
}, "onUpdate");
|
|
329
|
+
window.addEventListener("MiaoDaMetaInfoChanged", onUpdate);
|
|
330
|
+
return () => {
|
|
331
|
+
window.removeEventListener("MiaoDaMetaInfoChanged", onUpdate);
|
|
1379
332
|
};
|
|
1380
|
-
}
|
|
1381
|
-
console.error("Error splitting workspace URL:", error);
|
|
1382
|
-
}
|
|
333
|
+
}, []);
|
|
1383
334
|
return {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
335
|
+
...appInfo,
|
|
336
|
+
appName: appInfo.name,
|
|
337
|
+
appLogo: appInfo.avatar
|
|
1387
338
|
};
|
|
1388
|
-
}
|
|
1389
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
339
|
+
}, "useAppInfo");
|
|
1390
340
|
|
|
1391
|
-
// src/
|
|
1392
|
-
var
|
|
1393
|
-
var
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
1399
|
-
global: {
|
|
1400
|
-
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
1401
|
-
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
1402
|
-
brandName: "miaoda",
|
|
1403
|
-
appId
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1406
|
-
}, "createDataLoomClient");
|
|
1407
|
-
var dataloom = null;
|
|
1408
|
-
var pendingPromise3 = null;
|
|
1409
|
-
function getDataloom() {
|
|
1410
|
-
if (dataloom) {
|
|
1411
|
-
return Promise.resolve(dataloom);
|
|
1412
|
-
}
|
|
1413
|
-
if (pendingPromise3) {
|
|
1414
|
-
return pendingPromise3;
|
|
1415
|
-
}
|
|
1416
|
-
pendingPromise3 = getInitialInfo().then((info) => {
|
|
1417
|
-
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
1418
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
1419
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
1420
|
-
return dataloom;
|
|
1421
|
-
}).finally(() => {
|
|
1422
|
-
pendingPromise3 = null;
|
|
1423
|
-
});
|
|
1424
|
-
return pendingPromise3;
|
|
341
|
+
// src/hooks/useCurrentUserProfile.tsx
|
|
342
|
+
var import_react2 = require("react");
|
|
343
|
+
var import_auth_sdk = require("@lark-apaas/auth-sdk");
|
|
344
|
+
|
|
345
|
+
// src/integrations/getCurrentUserProfile.ts
|
|
346
|
+
function getCurrentUserProfile() {
|
|
347
|
+
return window._userInfo || {};
|
|
1425
348
|
}
|
|
1426
|
-
__name(
|
|
349
|
+
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1427
350
|
|
|
1428
351
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1429
352
|
function getNameFromArray(nameArray) {
|
|
@@ -1449,8 +372,7 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
1449
372
|
(0, import_react2.useEffect)(() => {
|
|
1450
373
|
let cancelled = false;
|
|
1451
374
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
1452
|
-
const
|
|
1453
|
-
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
375
|
+
const result = await import_auth_sdk.authClient.session.getUserInfo();
|
|
1454
376
|
if (cancelled) return;
|
|
1455
377
|
const info = result?.data?.user_info;
|
|
1456
378
|
const userName = getNameFromArray(info?.name);
|
|
@@ -1514,6 +436,7 @@ __name(useIsMobile, "useIsMobile");
|
|
|
1514
436
|
|
|
1515
437
|
// src/hooks/useLogout.ts
|
|
1516
438
|
var import_react4 = require("react");
|
|
439
|
+
var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
|
|
1517
440
|
function useLogout() {
|
|
1518
441
|
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
1519
442
|
async function handlerLogout() {
|
|
@@ -1523,8 +446,7 @@ function useLogout() {
|
|
|
1523
446
|
}
|
|
1524
447
|
setIsLoading(true);
|
|
1525
448
|
try {
|
|
1526
|
-
|
|
1527
|
-
await dataloom2.service.session.signOut();
|
|
449
|
+
await import_auth_sdk2.authClient.session.signOut();
|
|
1528
450
|
} catch (error) {
|
|
1529
451
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
1530
452
|
} finally {
|
|
@@ -1541,11 +463,6 @@ __name(useLogout, "useLogout");
|
|
|
1541
463
|
|
|
1542
464
|
// src/locales/messages.ts
|
|
1543
465
|
var messages = {
|
|
1544
|
-
// ── Index / 通用 ──────────────────────────────────────────────
|
|
1545
|
-
"index.rateLimitError": {
|
|
1546
|
-
zh: "\u5E94\u7528\u989D\u5EA6\u5DF2\u8017\u5C3D\uFF0C\u8BF7\u8054\u7CFB\u5E94\u7528\u5F00\u53D1\u8005",
|
|
1547
|
-
en: "Application quota exhausted, please contact the app developer"
|
|
1548
|
-
},
|
|
1549
466
|
// ── Safety 组件 ──────────────────────────────────────────────
|
|
1550
467
|
"safety.badge.label": {
|
|
1551
468
|
zh: "\u5999\u642D",
|
|
@@ -1925,14 +842,24 @@ var Safety = /* @__PURE__ */ __name(() => {
|
|
|
1925
842
|
const [badgeLoaded, setBadgeLoaded] = (0, import_react5.useState)(false);
|
|
1926
843
|
const timeoutRef = (0, import_react5.useRef)(null);
|
|
1927
844
|
(0, import_react5.useEffect)(() => {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
845
|
+
const appId = getAppId();
|
|
846
|
+
const csrfToken = getCsrfToken() ?? "";
|
|
847
|
+
const csrfHeaders = {
|
|
848
|
+
"X-Suda-Csrf-Token": csrfToken
|
|
849
|
+
};
|
|
850
|
+
const tenantInfoUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/tenant_info` : `/spark/b/${appId}/tenant_info`;
|
|
851
|
+
fetch(tenantInfoUrl, {
|
|
852
|
+
headers: csrfHeaders
|
|
853
|
+
}).then((res) => res.json()).then((data) => {
|
|
854
|
+
setUserinfo(data?.data?.tenant_info);
|
|
855
|
+
setIsInternetVisible(data?.data?.is_internet_visible);
|
|
1932
856
|
}).catch(() => {
|
|
1933
857
|
});
|
|
1934
|
-
|
|
1935
|
-
|
|
858
|
+
const getPublishedUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/get_published` : `/spark/b/${appId}/get_published`;
|
|
859
|
+
fetch(getPublishedUrl, {
|
|
860
|
+
headers: csrfHeaders
|
|
861
|
+
}).then((res) => res.json()).then((data) => {
|
|
862
|
+
const badge = data?.data?.app_info?.show_badge;
|
|
1936
863
|
setShowBadge(badge !== false);
|
|
1937
864
|
}).catch(() => {
|
|
1938
865
|
setShowBadge(true);
|
|
@@ -2146,92 +1073,6 @@ var QueryProvider = /* @__PURE__ */ __name(({ children, client }) => {
|
|
|
2146
1073
|
}, "QueryProvider");
|
|
2147
1074
|
var QueryProvider_default = QueryProvider;
|
|
2148
1075
|
|
|
2149
|
-
// src/components/AppContainer/IframeBridge.tsx
|
|
2150
|
-
var import_react8 = require("react");
|
|
2151
|
-
var import_react_router_dom = require("react-router-dom");
|
|
2152
|
-
|
|
2153
|
-
// src/hooks/useUpdatingRef.ts
|
|
2154
|
-
var import_react7 = require("react");
|
|
2155
|
-
function useUpdatingRef(value) {
|
|
2156
|
-
const ref = (0, import_react7.useRef)(value);
|
|
2157
|
-
ref.current = value;
|
|
2158
|
-
return ref;
|
|
2159
|
-
}
|
|
2160
|
-
__name(useUpdatingRef, "useUpdatingRef");
|
|
2161
|
-
|
|
2162
|
-
// src/components/AppContainer/IframeBridge.tsx
|
|
2163
|
-
var RouteMessageType = /* @__PURE__ */ (function(RouteMessageType2) {
|
|
2164
|
-
RouteMessageType2["RouteChange"] = "RouteChange";
|
|
2165
|
-
RouteMessageType2["RouteBack"] = "RouteBack";
|
|
2166
|
-
RouteMessageType2["RouteForward"] = "RouteForward";
|
|
2167
|
-
return RouteMessageType2;
|
|
2168
|
-
})(RouteMessageType || {});
|
|
2169
|
-
function isRouteMessageType(type) {
|
|
2170
|
-
return Object.values(RouteMessageType).includes(type);
|
|
2171
|
-
}
|
|
2172
|
-
__name(isRouteMessageType, "isRouteMessageType");
|
|
2173
|
-
function IframeBridge() {
|
|
2174
|
-
const location = (0, import_react_router_dom.useLocation)();
|
|
2175
|
-
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
2176
|
-
const navigateRef = useUpdatingRef(navigate);
|
|
2177
|
-
const isActive = (0, import_react8.useRef)(false);
|
|
2178
|
-
const historyBack = (0, import_react8.useCallback)((_payload) => {
|
|
2179
|
-
navigateRef.current(-1);
|
|
2180
|
-
isActive.current = true;
|
|
2181
|
-
}, [
|
|
2182
|
-
navigateRef
|
|
2183
|
-
]);
|
|
2184
|
-
const historyForward = (0, import_react8.useCallback)((_payload) => {
|
|
2185
|
-
navigateRef.current(1);
|
|
2186
|
-
isActive.current = true;
|
|
2187
|
-
}, [
|
|
2188
|
-
navigateRef
|
|
2189
|
-
]);
|
|
2190
|
-
const operatorMessage = (0, import_react8.useMemo)(() => ({
|
|
2191
|
-
["RouteBack"]: historyBack,
|
|
2192
|
-
["RouteForward"]: historyForward,
|
|
2193
|
-
["RouteChange"]: navigateRef.current
|
|
2194
|
-
}), [
|
|
2195
|
-
historyBack,
|
|
2196
|
-
historyForward,
|
|
2197
|
-
navigateRef
|
|
2198
|
-
]);
|
|
2199
|
-
(0, import_react8.useEffect)(() => {
|
|
2200
|
-
if (isActive.current) {
|
|
2201
|
-
isActive.current = false;
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2204
|
-
submitPostMessage({
|
|
2205
|
-
type: "ChildLocationChange",
|
|
2206
|
-
data: location
|
|
2207
|
-
});
|
|
2208
|
-
}, [
|
|
2209
|
-
location
|
|
2210
|
-
]);
|
|
2211
|
-
const handleMessage = (0, import_react8.useCallback)((event) => {
|
|
2212
|
-
const data = event.data ?? {};
|
|
2213
|
-
if (typeof data.type === "string" && isRouteMessageType(data.type)) {
|
|
2214
|
-
operatorMessage[data.type](data.data);
|
|
2215
|
-
}
|
|
2216
|
-
}, [
|
|
2217
|
-
operatorMessage
|
|
2218
|
-
]);
|
|
2219
|
-
(0, import_react8.useEffect)(() => {
|
|
2220
|
-
window.addEventListener("message", handleMessage);
|
|
2221
|
-
return () => {
|
|
2222
|
-
window.removeEventListener("message", handleMessage);
|
|
2223
|
-
};
|
|
2224
|
-
}, [
|
|
2225
|
-
handleMessage
|
|
2226
|
-
]);
|
|
2227
|
-
return /* @__PURE__ */ (0, import_react8.createElement)("div", {
|
|
2228
|
-
style: {
|
|
2229
|
-
display: "none"
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
}
|
|
2233
|
-
__name(IframeBridge, "IframeBridge");
|
|
2234
|
-
|
|
2235
1076
|
// src/components/AppContainer/utils/tea.ts
|
|
2236
1077
|
var import_blueimp_md5 = __toESM(require("blueimp-md5"), 1);
|
|
2237
1078
|
var import_sha1 = __toESM(require("crypto-js/sha1"), 1);
|
|
@@ -2352,7 +1193,7 @@ var TrackKey = /* @__PURE__ */ (function(TrackKey2) {
|
|
|
2352
1193
|
// src/components/AppContainer/index.tsx
|
|
2353
1194
|
var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
2354
1195
|
useAppInfo();
|
|
2355
|
-
(0,
|
|
1196
|
+
(0, import_react7.useEffect)(() => {
|
|
2356
1197
|
if (process.env.NODE_ENV === "production") {
|
|
2357
1198
|
reportTeaEvent({
|
|
2358
1199
|
trackKey: TrackKey.VIEW,
|
|
@@ -2364,14 +1205,14 @@ var AppContainer = /* @__PURE__ */ __name(({ children }) => {
|
|
|
2364
1205
|
});
|
|
2365
1206
|
}
|
|
2366
1207
|
}, []);
|
|
2367
|
-
return /* @__PURE__ */
|
|
1208
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(safety_default, null), /* @__PURE__ */ import_react7.default.createElement(QueryProvider_default, null, children));
|
|
2368
1209
|
}, "AppContainer");
|
|
2369
1210
|
var AppContainer_default = AppContainer;
|
|
2370
1211
|
|
|
2371
1212
|
// src/components/Welcome/index.tsx
|
|
2372
|
-
var
|
|
1213
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
2373
1214
|
var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
2374
|
-
return /* @__PURE__ */
|
|
1215
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2375
1216
|
style: {
|
|
2376
1217
|
display: "flex",
|
|
2377
1218
|
flexDirection: "column",
|
|
@@ -2382,7 +1223,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
2382
1223
|
padding: "0 24px",
|
|
2383
1224
|
textAlign: "center"
|
|
2384
1225
|
}
|
|
2385
|
-
}, /* @__PURE__ */
|
|
1226
|
+
}, /* @__PURE__ */ import_react8.default.createElement("img", {
|
|
2386
1227
|
style: {
|
|
2387
1228
|
borderRadius: 6,
|
|
2388
1229
|
marginBottom: 24
|
|
@@ -2391,7 +1232,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
2391
1232
|
height: "200",
|
|
2392
1233
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
2393
1234
|
alt: "Welcome"
|
|
2394
|
-
}), /* @__PURE__ */
|
|
1235
|
+
}), /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2395
1236
|
style: {
|
|
2396
1237
|
fontSize: 16,
|
|
2397
1238
|
fontWeight: 500,
|
|
@@ -2399,7 +1240,7 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
2399
1240
|
marginBottom: 4,
|
|
2400
1241
|
color: "#1f2329"
|
|
2401
1242
|
}
|
|
2402
|
-
}, title), /* @__PURE__ */
|
|
1243
|
+
}, title), /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2403
1244
|
style: {
|
|
2404
1245
|
fontSize: 16,
|
|
2405
1246
|
lineHeight: "24px",
|
|
@@ -2411,9 +1252,9 @@ var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1"
|
|
|
2411
1252
|
var Welcome_default = Welcome;
|
|
2412
1253
|
|
|
2413
1254
|
// src/components/PagePlaceholder/index.tsx
|
|
2414
|
-
var
|
|
1255
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
2415
1256
|
var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
|
|
2416
|
-
return /* @__PURE__ */
|
|
1257
|
+
return /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
2417
1258
|
style: {
|
|
2418
1259
|
display: "flex",
|
|
2419
1260
|
flexDirection: "column",
|
|
@@ -2424,7 +1265,7 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
2424
1265
|
height: "calc(100vh - 64px)",
|
|
2425
1266
|
textAlign: "center"
|
|
2426
1267
|
}
|
|
2427
|
-
}, /* @__PURE__ */
|
|
1268
|
+
}, /* @__PURE__ */ import_react9.default.createElement("img", {
|
|
2428
1269
|
style: {
|
|
2429
1270
|
borderRadius: "6px",
|
|
2430
1271
|
marginBottom: "24px"
|
|
@@ -2433,14 +1274,14 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
2433
1274
|
height: "200",
|
|
2434
1275
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
|
|
2435
1276
|
alt: "Welcome"
|
|
2436
|
-
}), /* @__PURE__ */
|
|
1277
|
+
}), /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
2437
1278
|
style: {
|
|
2438
1279
|
fontSize: "16px",
|
|
2439
1280
|
fontWeight: 500,
|
|
2440
1281
|
marginBottom: "4px",
|
|
2441
1282
|
lineHeight: "24px"
|
|
2442
1283
|
}
|
|
2443
|
-
}, title), /* @__PURE__ */
|
|
1284
|
+
}, title), /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
2444
1285
|
style: {
|
|
2445
1286
|
color: "#6b7280",
|
|
2446
1287
|
fontSize: "16px",
|
|
@@ -2455,67 +1296,13 @@ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F0
|
|
|
2455
1296
|
}, "PagePlaceholder");
|
|
2456
1297
|
var PagePlaceholder_default = PagePlaceholder;
|
|
2457
1298
|
|
|
2458
|
-
// src/components/ErrorRender/index.tsx
|
|
2459
|
-
var import_react12 = __toESM(require("react"), 1);
|
|
2460
|
-
var ErrorRender = /* @__PURE__ */ __name((props) => {
|
|
2461
|
-
const { error, resetErrorBoundary } = props;
|
|
2462
|
-
(0, import_react12.useEffect)(() => {
|
|
2463
|
-
if (error) {
|
|
2464
|
-
submitPostMessage({
|
|
2465
|
-
type: "RenderError",
|
|
2466
|
-
data: error
|
|
2467
|
-
});
|
|
2468
|
-
logger.log({
|
|
2469
|
-
level: "error",
|
|
2470
|
-
args: [
|
|
2471
|
-
"Render Error",
|
|
2472
|
-
error
|
|
2473
|
-
],
|
|
2474
|
-
meta: {
|
|
2475
|
-
type: "render-error",
|
|
2476
|
-
repairMessage: "\u9875\u9762\u6E32\u67D3\u65F6\u62A5\u9519\uFF0C\u8BF7\u6839\u636E\u9519\u8BEF\u4FE1\u606F\u4FEE\u590D\u5BF9\u5E94\u9875\u9762\u7684\u4EE3\u7801"
|
|
2477
|
-
}
|
|
2478
|
-
});
|
|
2479
|
-
}
|
|
2480
|
-
}, [
|
|
2481
|
-
error
|
|
2482
|
-
]);
|
|
2483
|
-
(0, import_react12.useEffect)(() => {
|
|
2484
|
-
if (!resetErrorBoundary) return;
|
|
2485
|
-
const hmr = getHmrApi();
|
|
2486
|
-
if (!hmr) return;
|
|
2487
|
-
return hmr.onSuccess(() => {
|
|
2488
|
-
const isVite = typeof window !== "undefined" && Boolean(window.__VITE_HMR__);
|
|
2489
|
-
if (isVite) {
|
|
2490
|
-
window.location.reload();
|
|
2491
|
-
} else {
|
|
2492
|
-
resetErrorBoundary();
|
|
2493
|
-
}
|
|
2494
|
-
});
|
|
2495
|
-
}, [
|
|
2496
|
-
resetErrorBoundary
|
|
2497
|
-
]);
|
|
2498
|
-
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
2499
|
-
className: "min-h-screen flex items-center justify-center bg-white"
|
|
2500
|
-
}, /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
2501
|
-
className: "flex flex-col justify-center items-center text-center"
|
|
2502
|
-
}, /* @__PURE__ */ import_react12.default.createElement("img", {
|
|
2503
|
-
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg",
|
|
2504
|
-
alt: "render error",
|
|
2505
|
-
className: "mb-3 w-[100px]"
|
|
2506
|
-
}), /* @__PURE__ */ import_react12.default.createElement("p", {
|
|
2507
|
-
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium"
|
|
2508
|
-
}, "\u9875\u9762\u51FA\u9519\u4E86")));
|
|
2509
|
-
}, "ErrorRender");
|
|
2510
|
-
var ErrorRender_default = ErrorRender;
|
|
2511
|
-
|
|
2512
1299
|
// src/route-components/ActiveLink.tsx
|
|
2513
|
-
var
|
|
2514
|
-
var
|
|
2515
|
-
var ActiveLink = /* @__PURE__ */ (0,
|
|
2516
|
-
const [currentHash, setCurrentHash] = (0,
|
|
1300
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
1301
|
+
var import_react_router_dom = require("react-router-dom");
|
|
1302
|
+
var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
|
|
1303
|
+
const [currentHash, setCurrentHash] = (0, import_react10.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
|
|
2517
1304
|
const isHashRoute = typeof to === "string" && to.startsWith("#");
|
|
2518
|
-
(0,
|
|
1305
|
+
(0, import_react10.useEffect)(() => {
|
|
2519
1306
|
if (!isHashRoute) return;
|
|
2520
1307
|
const handleHashChange = /* @__PURE__ */ __name(() => {
|
|
2521
1308
|
setCurrentHash(window.location.hash);
|
|
@@ -2527,7 +1314,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react13.forwardRef)(({ to, onClick,
|
|
|
2527
1314
|
]);
|
|
2528
1315
|
const isActive = isHashRoute && currentHash === to;
|
|
2529
1316
|
if (!isHashRoute) {
|
|
2530
|
-
return /* @__PURE__ */
|
|
1317
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_router_dom.NavLink, {
|
|
2531
1318
|
ref,
|
|
2532
1319
|
to,
|
|
2533
1320
|
onClick,
|
|
@@ -2568,7 +1355,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react13.forwardRef)(({ to, onClick,
|
|
|
2568
1355
|
isPending: false,
|
|
2569
1356
|
isTransitioning: false
|
|
2570
1357
|
}) : children;
|
|
2571
|
-
return /* @__PURE__ */
|
|
1358
|
+
return /* @__PURE__ */ import_react10.default.createElement("a", {
|
|
2572
1359
|
ref,
|
|
2573
1360
|
href: to,
|
|
2574
1361
|
onClick: handleHashClick,
|
|
@@ -2580,12 +1367,12 @@ var ActiveLink = /* @__PURE__ */ (0, import_react13.forwardRef)(({ to, onClick,
|
|
|
2580
1367
|
ActiveLink.displayName = "ActiveLink";
|
|
2581
1368
|
|
|
2582
1369
|
// src/route-components/NavLink.tsx
|
|
2583
|
-
var
|
|
2584
|
-
var
|
|
2585
|
-
var NavLink2 = /* @__PURE__ */
|
|
1370
|
+
var React8 = __toESM(require("react"), 1);
|
|
1371
|
+
var import_react_router_dom2 = require("react-router-dom");
|
|
1372
|
+
var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, style, ...props }, ref) => {
|
|
2586
1373
|
const isHashLink = typeof to === "string" && to.startsWith("#");
|
|
2587
|
-
const location = (0,
|
|
2588
|
-
const navigate = (0,
|
|
1374
|
+
const location = (0, import_react_router_dom2.useLocation)();
|
|
1375
|
+
const navigate = (0, import_react_router_dom2.useNavigate)();
|
|
2589
1376
|
if (isHashLink) {
|
|
2590
1377
|
const handleClick = /* @__PURE__ */ __name((e) => {
|
|
2591
1378
|
e.preventDefault();
|
|
@@ -2606,7 +1393,7 @@ var NavLink2 = /* @__PURE__ */ React9.forwardRef(({ to, children, className, sty
|
|
|
2606
1393
|
const resolvedClassName = typeof className === "function" ? className(renderProps) : className;
|
|
2607
1394
|
const resolvedStyle = typeof style === "function" ? style(renderProps) : style;
|
|
2608
1395
|
const { caseSensitive, end, replace, state, preventScrollReset, relative, viewTransition, ...restProps } = props;
|
|
2609
|
-
return /* @__PURE__ */
|
|
1396
|
+
return /* @__PURE__ */ React8.createElement("a", {
|
|
2610
1397
|
href: to,
|
|
2611
1398
|
onClick: handleClick,
|
|
2612
1399
|
ref,
|
|
@@ -2615,7 +1402,7 @@ var NavLink2 = /* @__PURE__ */ React9.forwardRef(({ to, children, className, sty
|
|
|
2615
1402
|
...restProps
|
|
2616
1403
|
}, typeof children === "function" ? children(renderProps) : children);
|
|
2617
1404
|
}
|
|
2618
|
-
return /* @__PURE__ */
|
|
1405
|
+
return /* @__PURE__ */ React8.createElement(import_react_router_dom2.NavLink, {
|
|
2619
1406
|
to,
|
|
2620
1407
|
ref,
|
|
2621
1408
|
className,
|
|
@@ -2630,8 +1417,8 @@ var NavLink2 = /* @__PURE__ */ React9.forwardRef(({ to, children, className, sty
|
|
|
2630
1417
|
NavLink2.displayName = "NavLink";
|
|
2631
1418
|
|
|
2632
1419
|
// src/route-components/UniversalLink.tsx
|
|
2633
|
-
var
|
|
2634
|
-
var
|
|
1420
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
1421
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
2635
1422
|
function isInternalRoute(to) {
|
|
2636
1423
|
return !to.startsWith("#") && !to.startsWith("http://") && !to.startsWith("https://") && !to.startsWith("//");
|
|
2637
1424
|
}
|
|
@@ -2640,15 +1427,15 @@ function isExternalLink(to) {
|
|
|
2640
1427
|
return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
|
|
2641
1428
|
}
|
|
2642
1429
|
__name(isExternalLink, "isExternalLink");
|
|
2643
|
-
var UniversalLink = /* @__PURE__ */
|
|
1430
|
+
var UniversalLink = /* @__PURE__ */ import_react11.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
|
|
2644
1431
|
if (isInternalRoute(to)) {
|
|
2645
|
-
return /* @__PURE__ */
|
|
1432
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_react_router_dom3.Link, {
|
|
2646
1433
|
to,
|
|
2647
1434
|
ref,
|
|
2648
1435
|
...props
|
|
2649
1436
|
});
|
|
2650
1437
|
}
|
|
2651
|
-
return /* @__PURE__ */
|
|
1438
|
+
return /* @__PURE__ */ import_react11.default.createElement("a", {
|
|
2652
1439
|
href: to,
|
|
2653
1440
|
ref,
|
|
2654
1441
|
...props,
|
|
@@ -2794,6 +1581,45 @@ function getEnvPath() {
|
|
|
2794
1581
|
}
|
|
2795
1582
|
__name(getEnvPath, "getEnvPath");
|
|
2796
1583
|
|
|
1584
|
+
// src/utils/safeStringify.ts
|
|
1585
|
+
function safeStringify(obj) {
|
|
1586
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1587
|
+
try {
|
|
1588
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
1589
|
+
if (typeof value === "object" && value !== null) {
|
|
1590
|
+
if (seen.has(value)) {
|
|
1591
|
+
return "[Circular]";
|
|
1592
|
+
}
|
|
1593
|
+
seen.add(value);
|
|
1594
|
+
}
|
|
1595
|
+
if (typeof value === "bigint") {
|
|
1596
|
+
return value.toString();
|
|
1597
|
+
}
|
|
1598
|
+
if (value instanceof Date) {
|
|
1599
|
+
return value.toISOString();
|
|
1600
|
+
}
|
|
1601
|
+
if (value instanceof Map) {
|
|
1602
|
+
return Object.fromEntries(value);
|
|
1603
|
+
}
|
|
1604
|
+
if (value instanceof Set) {
|
|
1605
|
+
return Array.from(value);
|
|
1606
|
+
}
|
|
1607
|
+
if (typeof value === "undefined") {
|
|
1608
|
+
return "undefined";
|
|
1609
|
+
}
|
|
1610
|
+
if (typeof value === "symbol") {
|
|
1611
|
+
return value.toString();
|
|
1612
|
+
}
|
|
1613
|
+
return value;
|
|
1614
|
+
});
|
|
1615
|
+
} catch {
|
|
1616
|
+
return "";
|
|
1617
|
+
} finally {
|
|
1618
|
+
seen.clear();
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
__name(safeStringify, "safeStringify");
|
|
1622
|
+
|
|
2797
1623
|
// src/utils/getAxiosForBackend.ts
|
|
2798
1624
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
2799
1625
|
var axiosInstance;
|
|
@@ -2873,93 +1699,73 @@ function getAxiosForBackend() {
|
|
|
2873
1699
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2874
1700
|
var axiosForBackend = getAxiosForBackend();
|
|
2875
1701
|
|
|
2876
|
-
// src/
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
const
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
position: "fixed",
|
|
2900
|
-
top: "32px",
|
|
2901
|
-
left: "50%",
|
|
2902
|
-
transform: "translate(-50%, -50%)",
|
|
2903
|
-
display: "flex",
|
|
2904
|
-
alignItems: "center",
|
|
2905
|
-
padding: "12px 16px",
|
|
2906
|
-
backgroundColor: "#fff",
|
|
2907
|
-
color: "#1f2329",
|
|
2908
|
-
border: "1px solid #dee0e3",
|
|
2909
|
-
borderRadius: "6px",
|
|
2910
|
-
fontSize: "14px",
|
|
2911
|
-
lineHeight: "1.5",
|
|
2912
|
-
zIndex: "99999",
|
|
2913
|
-
maxWidth: "80vw",
|
|
2914
|
-
wordBreak: "break-word",
|
|
2915
|
-
boxShadow: "0 4px 8px rgba(0, 0, 0, 0.03), 0 3px 6px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.03)",
|
|
2916
|
-
opacity: "0",
|
|
2917
|
-
transition: "opacity 0.3s ease"
|
|
2918
|
-
});
|
|
2919
|
-
document.body.appendChild(toast);
|
|
2920
|
-
requestAnimationFrame(() => {
|
|
2921
|
-
toast.style.opacity = "1";
|
|
2922
|
-
});
|
|
2923
|
-
setTimeout(() => {
|
|
2924
|
-
toast.style.opacity = "0";
|
|
2925
|
-
setTimeout(() => {
|
|
2926
|
-
document.body.removeChild(toast);
|
|
2927
|
-
resolve();
|
|
2928
|
-
}, 300);
|
|
2929
|
-
}, duration);
|
|
2930
|
-
});
|
|
1702
|
+
// src/utils/url.ts
|
|
1703
|
+
function splitWorkspaceUrl(fullUrl) {
|
|
1704
|
+
try {
|
|
1705
|
+
const url = new URL(fullUrl);
|
|
1706
|
+
const pathParts = url.pathname.split("/");
|
|
1707
|
+
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
1708
|
+
if (workspacesIndex === -1) {
|
|
1709
|
+
throw new Error("Invalid workspace URL format");
|
|
1710
|
+
}
|
|
1711
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
1712
|
+
const workspace = pathParts[workspacesIndex + 1];
|
|
1713
|
+
return {
|
|
1714
|
+
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
1715
|
+
workspace
|
|
1716
|
+
};
|
|
1717
|
+
} catch (error) {
|
|
1718
|
+
console.error("Error splitting workspace URL:", error);
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
baseUrl: fullUrl,
|
|
1722
|
+
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
1723
|
+
workspace: "workspace"
|
|
1724
|
+
};
|
|
2931
1725
|
}
|
|
2932
|
-
__name(
|
|
1726
|
+
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
2933
1727
|
|
|
2934
|
-
// src/integrations/
|
|
2935
|
-
var
|
|
2936
|
-
var
|
|
2937
|
-
var
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
central: {
|
|
2953
|
-
enabled: true,
|
|
2954
|
-
// window.appId 由妙搭沙箱 / 线上环境注入;非妙搭场景下 capability 调用本身不可用
|
|
2955
|
-
appId: _appId ?? ""
|
|
1728
|
+
// src/integrations/dataloom.ts
|
|
1729
|
+
var import_dataloom = require("@lark-apaas/dataloom");
|
|
1730
|
+
var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
|
|
1731
|
+
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
1732
|
+
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
1733
|
+
baseUrl: ""
|
|
1734
|
+
};
|
|
1735
|
+
const appId = getAppId() ?? "";
|
|
1736
|
+
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
1737
|
+
global: {
|
|
1738
|
+
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
1739
|
+
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
1740
|
+
brandName: "miaoda",
|
|
1741
|
+
appId,
|
|
1742
|
+
accountServices: {
|
|
1743
|
+
user: import_auth_sdk3.authClient.user,
|
|
1744
|
+
session: import_auth_sdk3.authClient.session
|
|
1745
|
+
}
|
|
2956
1746
|
}
|
|
2957
|
-
}
|
|
2958
|
-
});
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
1747
|
+
});
|
|
1748
|
+
}, "createDataLoomClient");
|
|
1749
|
+
var dataloom = null;
|
|
1750
|
+
var pendingPromise2 = null;
|
|
1751
|
+
function getDataloom() {
|
|
1752
|
+
if (dataloom) {
|
|
1753
|
+
return Promise.resolve(dataloom);
|
|
1754
|
+
}
|
|
1755
|
+
if (pendingPromise2) {
|
|
1756
|
+
return pendingPromise2;
|
|
1757
|
+
}
|
|
1758
|
+
pendingPromise2 = getInitialInfo().then((info) => {
|
|
1759
|
+
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
1760
|
+
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
1761
|
+
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
1762
|
+
return dataloom;
|
|
1763
|
+
}).finally(() => {
|
|
1764
|
+
pendingPromise2 = null;
|
|
1765
|
+
});
|
|
1766
|
+
return pendingPromise2;
|
|
1767
|
+
}
|
|
1768
|
+
__name(getDataloom, "getDataloom");
|
|
2963
1769
|
|
|
2964
1770
|
// src/constants/img-resources/avatar.ts
|
|
2965
1771
|
var avatar_exports = {};
|
|
@@ -3121,7 +1927,6 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
3121
1927
|
0 && (module.exports = {
|
|
3122
1928
|
ActiveLink,
|
|
3123
1929
|
AppContainer,
|
|
3124
|
-
ErrorRender,
|
|
3125
1930
|
NavLink,
|
|
3126
1931
|
PagePlaceholder,
|
|
3127
1932
|
QueryProvider,
|
|
@@ -3131,7 +1936,6 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
3131
1936
|
avatarImages,
|
|
3132
1937
|
axiosForBackend,
|
|
3133
1938
|
bannerImages,
|
|
3134
|
-
capabilityClient,
|
|
3135
1939
|
clsxWithTw,
|
|
3136
1940
|
copyToClipboard,
|
|
3137
1941
|
coverImages,
|
|
@@ -3144,18 +1948,15 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
|
|
|
3144
1948
|
getEnvPath,
|
|
3145
1949
|
getWsPath,
|
|
3146
1950
|
initAxiosConfig,
|
|
3147
|
-
initObservable,
|
|
3148
1951
|
isIOS,
|
|
3149
1952
|
isIpad,
|
|
3150
1953
|
isMobile,
|
|
3151
1954
|
isPreview,
|
|
3152
|
-
logger,
|
|
3153
1955
|
normalizeBasePath,
|
|
3154
1956
|
reportTeaEvent,
|
|
3155
1957
|
resolveAppUrl,
|
|
3156
1958
|
safeStringify,
|
|
3157
1959
|
scopedStorage,
|
|
3158
|
-
trace,
|
|
3159
1960
|
useAppInfo,
|
|
3160
1961
|
useCurrentUserProfile,
|
|
3161
1962
|
useIsMobile,
|