@lark-apaas/client-toolkit-lite 1.1.1-alpha.5 → 1.1.1-alpha.6
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 +5 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -347,53 +347,16 @@ function getCurrentUserProfile() {
|
|
|
347
347
|
}
|
|
348
348
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
349
349
|
|
|
350
|
-
// src/utils/url.ts
|
|
351
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
352
|
-
try {
|
|
353
|
-
const url = new URL(fullUrl);
|
|
354
|
-
const pathParts = url.pathname.split("/");
|
|
355
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
356
|
-
if (workspacesIndex === -1) {
|
|
357
|
-
throw new Error("Invalid workspace URL format");
|
|
358
|
-
}
|
|
359
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
360
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
361
|
-
return {
|
|
362
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
363
|
-
workspace
|
|
364
|
-
};
|
|
365
|
-
} catch (error) {
|
|
366
|
-
console.error("Error splitting workspace URL:", error);
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
baseUrl: fullUrl,
|
|
370
|
-
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
371
|
-
workspace: "workspace"
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
375
|
-
|
|
376
350
|
// src/integrations/dataloom.ts
|
|
377
|
-
var
|
|
351
|
+
var import_dataloom = require("@lark-apaas/dataloom");
|
|
378
352
|
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
379
|
-
const { baseUrl, workspace } = url ? splitWorkspaceUrl(url) : {
|
|
380
|
-
baseUrl: "",
|
|
381
|
-
workspace: ""
|
|
382
|
-
};
|
|
383
353
|
const appId = getAppId() ?? "";
|
|
384
|
-
return (0,
|
|
354
|
+
return (0, import_dataloom.createClient)(url ?? "", pat ?? "", {
|
|
385
355
|
global: {
|
|
386
356
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
387
357
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
388
358
|
brandName: "miaoda",
|
|
389
|
-
appId
|
|
390
|
-
onError: /* @__PURE__ */ __name((error, dataloomInstance) => {
|
|
391
|
-
if (error?.status === 401) {
|
|
392
|
-
if (error?.code === "k_ident_013001") {
|
|
393
|
-
dataloomInstance.service.session.redirectToLogin();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}, "onError")
|
|
359
|
+
appId
|
|
397
360
|
}
|
|
398
361
|
});
|
|
399
362
|
}, "createDataLoomClient");
|
|
@@ -571,52 +534,9 @@ var messages = {
|
|
|
571
534
|
var messages_default = messages;
|
|
572
535
|
|
|
573
536
|
// src/utils/locale.ts
|
|
574
|
-
var STORAGE_KEY = "miaoda:preview-locale";
|
|
575
|
-
function toLocale(value) {
|
|
576
|
-
const lang = value ?? "zh";
|
|
577
|
-
return lang.toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
578
|
-
}
|
|
579
|
-
__name(toLocale, "toLocale");
|
|
580
|
-
function readLocaleFromQuery() {
|
|
581
|
-
if (typeof window === "undefined") return null;
|
|
582
|
-
try {
|
|
583
|
-
const value = new URLSearchParams(window.location.search).get("locale");
|
|
584
|
-
return value && value.length > 0 ? value : null;
|
|
585
|
-
} catch {
|
|
586
|
-
return null;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
__name(readLocaleFromQuery, "readLocaleFromQuery");
|
|
590
|
-
function readLocaleFromStorage() {
|
|
591
|
-
if (typeof window === "undefined") return null;
|
|
592
|
-
try {
|
|
593
|
-
const value = window.localStorage?.getItem(STORAGE_KEY);
|
|
594
|
-
return value && value.length > 0 ? value : null;
|
|
595
|
-
} catch {
|
|
596
|
-
return null;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
__name(readLocaleFromStorage, "readLocaleFromStorage");
|
|
600
|
-
function writeLocaleToStorage(value) {
|
|
601
|
-
if (typeof window === "undefined") return;
|
|
602
|
-
try {
|
|
603
|
-
window.localStorage?.setItem(STORAGE_KEY, value);
|
|
604
|
-
} catch {
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
__name(writeLocaleToStorage, "writeLocaleToStorage");
|
|
608
537
|
function getLocale() {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
const fromQuery = readLocaleFromQuery();
|
|
613
|
-
if (fromQuery) {
|
|
614
|
-
writeLocaleToStorage(fromQuery);
|
|
615
|
-
return toLocale(fromQuery);
|
|
616
|
-
}
|
|
617
|
-
const fromStorage = readLocaleFromStorage();
|
|
618
|
-
if (fromStorage) return toLocale(fromStorage);
|
|
619
|
-
return toLocale(navigator.language);
|
|
538
|
+
const lang = navigator.language || "zh";
|
|
539
|
+
return lang.startsWith("zh") ? "zh" : "en";
|
|
620
540
|
}
|
|
621
541
|
__name(getLocale, "getLocale");
|
|
622
542
|
|