@lark-apaas/client-toolkit-lite 1.1.15-alpha.1 → 1.1.15-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 +11 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +11 -84
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -281,19 +281,18 @@ function getLegacyParentOrigin() {
|
|
|
281
281
|
return "https://miaoda.feishu-boe.cn";
|
|
282
282
|
}
|
|
283
283
|
__name(getLegacyParentOrigin, "getLegacyParentOrigin");
|
|
284
|
-
var MIAODA_PARENT_ORIGIN_RE = /^https:\/\/(miaoda|force)\.feishu(-pre|-boe|-staging)?\.cn$/;
|
|
285
284
|
function resolveParentOrigin() {
|
|
286
|
-
const paramOrigin = getParentOriginFromParams();
|
|
287
|
-
if (paramOrigin) return paramOrigin;
|
|
288
285
|
try {
|
|
289
286
|
if (document.referrer) {
|
|
290
287
|
const referrerOrigin = new URL(document.referrer).origin;
|
|
291
|
-
if (
|
|
288
|
+
if (referrerOrigin.startsWith("http://localhost") || referrerOrigin.startsWith("http://127.0.0.1")) {
|
|
292
289
|
return referrerOrigin;
|
|
293
290
|
}
|
|
294
291
|
}
|
|
295
292
|
} catch {
|
|
296
293
|
}
|
|
294
|
+
const paramOrigin = getParentOriginFromParams();
|
|
295
|
+
if (paramOrigin) return paramOrigin;
|
|
297
296
|
return process.env?.FORCE_FRAMEWORK_DOMAIN_MAIN ?? getLegacyParentOrigin();
|
|
298
297
|
}
|
|
299
298
|
__name(resolveParentOrigin, "resolveParentOrigin");
|
|
@@ -301,10 +300,7 @@ function submitPostMessage(message, targetOrigin) {
|
|
|
301
300
|
try {
|
|
302
301
|
const parentOrigin = resolveParentOrigin();
|
|
303
302
|
const origin = targetOrigin ?? parentOrigin;
|
|
304
|
-
if (!origin)
|
|
305
|
-
console.error("postMessage skipped: cannot resolve parent origin");
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
303
|
+
if (!origin) return;
|
|
308
304
|
window.parent.postMessage(message, origin);
|
|
309
305
|
} catch (e) {
|
|
310
306
|
console.error("postMessage error", e);
|
|
@@ -2910,57 +2906,19 @@ function isExternalLink(to) {
|
|
|
2910
2906
|
return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
|
|
2911
2907
|
}
|
|
2912
2908
|
__name(isExternalLink, "isExternalLink");
|
|
2913
|
-
var
|
|
2914
|
-
function isIframeUnderMiaoda() {
|
|
2915
|
-
if (typeof window === "undefined") return false;
|
|
2916
|
-
if (window.parent === window) return false;
|
|
2917
|
-
try {
|
|
2918
|
-
if (!document.referrer) return false;
|
|
2919
|
-
const refOrigin = new URL(document.referrer).origin;
|
|
2920
|
-
return MIAODA_PARENT_ORIGIN_RE2.test(refOrigin);
|
|
2921
|
-
} catch {
|
|
2922
|
-
return false;
|
|
2923
|
-
}
|
|
2924
|
-
}
|
|
2925
|
-
__name(isIframeUnderMiaoda, "isIframeUnderMiaoda");
|
|
2926
|
-
var UniversalLink = /* @__PURE__ */ import_react15.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, onClick, ...props }, ref) {
|
|
2927
|
-
const isExternal = isExternalLink(to);
|
|
2928
|
-
const preview = (isPreview() || isIframeUnderMiaoda()) && isExternal;
|
|
2929
|
-
if (preview) {
|
|
2930
|
-
const handlePreviewClick = /* @__PURE__ */ __name((e) => {
|
|
2931
|
-
e.preventDefault();
|
|
2932
|
-
onClick?.(e);
|
|
2933
|
-
submitPostMessage({
|
|
2934
|
-
type: "OpenLink",
|
|
2935
|
-
data: {
|
|
2936
|
-
href: to,
|
|
2937
|
-
external: true
|
|
2938
|
-
}
|
|
2939
|
-
});
|
|
2940
|
-
}, "handlePreviewClick");
|
|
2941
|
-
return /* @__PURE__ */ import_react15.default.createElement("a", {
|
|
2942
|
-
href: to,
|
|
2943
|
-
ref,
|
|
2944
|
-
...props,
|
|
2945
|
-
onClick: handlePreviewClick,
|
|
2946
|
-
target: props.target ?? "_blank",
|
|
2947
|
-
rel: props.rel ?? "noopener noreferrer"
|
|
2948
|
-
});
|
|
2949
|
-
}
|
|
2909
|
+
var UniversalLink = /* @__PURE__ */ import_react15.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
|
|
2950
2910
|
if (isInternalRoute(to)) {
|
|
2951
2911
|
return /* @__PURE__ */ import_react15.default.createElement(import_react_router_dom4.Link, {
|
|
2952
2912
|
to,
|
|
2953
2913
|
ref,
|
|
2954
|
-
...props
|
|
2955
|
-
onClick
|
|
2914
|
+
...props
|
|
2956
2915
|
});
|
|
2957
2916
|
}
|
|
2958
2917
|
return /* @__PURE__ */ import_react15.default.createElement("a", {
|
|
2959
2918
|
href: to,
|
|
2960
2919
|
ref,
|
|
2961
2920
|
...props,
|
|
2962
|
-
|
|
2963
|
-
...isExternal && {
|
|
2921
|
+
...isExternalLink(to) && {
|
|
2964
2922
|
target: props.target ?? "_blank",
|
|
2965
2923
|
rel: props.rel ?? "noopener noreferrer"
|
|
2966
2924
|
}
|
|
@@ -3181,41 +3139,12 @@ function getAxiosForBackend() {
|
|
|
3181
3139
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
3182
3140
|
var axiosForBackend = getAxiosForBackend();
|
|
3183
3141
|
|
|
3184
|
-
// src/utils/url.ts
|
|
3185
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
3186
|
-
try {
|
|
3187
|
-
const url = new URL(fullUrl);
|
|
3188
|
-
const pathParts = url.pathname.split("/");
|
|
3189
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
3190
|
-
if (workspacesIndex === -1) {
|
|
3191
|
-
throw new Error("Invalid workspace URL format");
|
|
3192
|
-
}
|
|
3193
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
3194
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
3195
|
-
return {
|
|
3196
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
3197
|
-
workspace
|
|
3198
|
-
};
|
|
3199
|
-
} catch (error) {
|
|
3200
|
-
console.error("Error splitting workspace URL:", error);
|
|
3201
|
-
}
|
|
3202
|
-
return {
|
|
3203
|
-
baseUrl: fullUrl,
|
|
3204
|
-
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
3205
|
-
workspace: "workspace"
|
|
3206
|
-
};
|
|
3207
|
-
}
|
|
3208
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
3209
|
-
|
|
3210
3142
|
// src/integrations/dataloom.ts
|
|
3211
3143
|
var import_dataloom = require("@lark-apaas/dataloom");
|
|
3212
3144
|
var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
|
|
3213
|
-
var createDataLoomClient = /* @__PURE__ */ __name((
|
|
3214
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
3215
|
-
baseUrl: ""
|
|
3216
|
-
};
|
|
3145
|
+
var createDataLoomClient = /* @__PURE__ */ __name(() => {
|
|
3217
3146
|
const appId = getAppId() ?? "";
|
|
3218
|
-
return (0, import_dataloom.createClient)(
|
|
3147
|
+
return (0, import_dataloom.createClient)({
|
|
3219
3148
|
global: {
|
|
3220
3149
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
3221
3150
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
@@ -3237,10 +3166,8 @@ function getDataloom() {
|
|
|
3237
3166
|
if (pendingPromise3) {
|
|
3238
3167
|
return pendingPromise3;
|
|
3239
3168
|
}
|
|
3240
|
-
pendingPromise3 = getInitialInfo().then((
|
|
3241
|
-
|
|
3242
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
3243
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
3169
|
+
pendingPromise3 = getInitialInfo().then(() => {
|
|
3170
|
+
dataloom = createDataLoomClient();
|
|
3244
3171
|
return dataloom;
|
|
3245
3172
|
}).finally(() => {
|
|
3246
3173
|
pendingPromise3 = null;
|