@lark-apaas/client-toolkit 1.2.1-alpha.1 → 1.2.1-alpha.3

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.
@@ -4,7 +4,6 @@ import { useLocation, useNavigate } from "react-router-dom";
4
4
  import { connectToParent } from "penpal";
5
5
  import { useUpdatingRef } from "../../hooks/useUpdatingRef.js";
6
6
  import { submitPostMessage } from "../../utils/postMessage.js";
7
- import { getPreviewParentOrigin } from "../../utils/getParentOrigin.js";
8
7
  import { childApi } from "./utils/childApi.js";
9
8
  import "./utils/listenHot.js";
10
9
  var IframeBridge_RouteMessageType = /*#__PURE__*/ function(RouteMessageType) {
@@ -21,8 +20,10 @@ async function connectParent() {
21
20
  type: 'PreviewReady',
22
21
  data: {}
23
22
  });
23
+ const parentOrigin = process.env.FORCE_FRAMEWORK_DOMAIN_MAIN;
24
+ if (!parentOrigin) return;
24
25
  const connection = connectToParent({
25
- parentOrigin: getPreviewParentOrigin(),
26
+ parentOrigin,
26
27
  methods: {
27
28
  ...childApi
28
29
  }
@@ -35,13 +36,13 @@ function IframeBridge() {
35
36
  const navigate = useNavigate();
36
37
  const navigateRef = useUpdatingRef(navigate);
37
38
  const isActive = useRef(false);
38
- const historyBack = useCallback(()=>{
39
+ const historyBack = useCallback((_payload)=>{
39
40
  navigateRef.current(-1);
40
41
  isActive.current = true;
41
42
  }, [
42
43
  navigateRef
43
44
  ]);
44
- const historyForward = useCallback(()=>{
45
+ const historyForward = useCallback((_payload)=>{
45
46
  navigateRef.current(1);
46
47
  isActive.current = true;
47
48
  }, [
@@ -69,8 +70,8 @@ function IframeBridge() {
69
70
  location
70
71
  ]);
71
72
  const handleMessage = useCallback((event)=>{
72
- const { data } = event;
73
- if (isRouteMessageType(data?.type)) operatorMessage[data?.type](data?.data);
73
+ const data = event.data ?? {};
74
+ if ('string' == typeof data.type && isRouteMessageType(data.type)) operatorMessage[data.type](data.data);
74
75
  }, [
75
76
  operatorMessage
76
77
  ]);
@@ -1,6 +1 @@
1
1
  export declare function getEnv(): 'BOE' | 'PRE' | 'ONLINE';
2
- /**
3
- * @internal
4
- * 获取预览环境父级域名
5
- */
6
- export declare function getPreviewParentOrigin(): "https://force.feishu.cn" | "https://force.feishu-pre.cn" | "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
@@ -4,13 +4,4 @@ function getEnv() {
4
4
  if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'PRE';
5
5
  return 'BOE';
6
6
  }
7
- function getPreviewParentOrigin() {
8
- const { origin } = window.location;
9
- if (origin.includes('force.feishuapp.net')) return 'https://force.feishu.cn';
10
- if (origin.includes('force-pre.feishuapp.net')) return 'https://force.feishu-pre.cn';
11
- if (origin.includes('force.byted.org')) return 'https://force.feishu-boe.cn';
12
- if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
13
- if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
14
- return 'https://miaoda.feishu-boe.cn';
15
- }
16
- export { getEnv, getPreviewParentOrigin };
7
+ export { getEnv };
@@ -1,7 +1,9 @@
1
- import { getPreviewParentOrigin } from "./getParentOrigin.js";
2
1
  function submitPostMessage(message, targetOrigin) {
3
2
  try {
4
- window.parent.postMessage(message, targetOrigin ?? getPreviewParentOrigin());
3
+ const parentOrigin = process.env.FORCE_FRAMEWORK_DOMAIN_MAIN;
4
+ const origin = targetOrigin ?? parentOrigin;
5
+ if (!origin) return;
6
+ window.parent.postMessage(message, origin);
5
7
  } catch (e) {
6
8
  console.error('postMessage error', e);
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.1-alpha.1",
3
+ "version": "1.2.1-alpha.3",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -82,7 +82,7 @@
82
82
  "@ant-design/cssinjs": "^1.24.0",
83
83
  "@data-loom/js": "^0.4.3",
84
84
  "@lark-apaas/client-capability": "^0.1.1",
85
- "@lark-apaas/miaoda-inspector": "^1.0.8",
85
+ "@lark-apaas/miaoda-inspector": "1.0.10-alpha.1",
86
86
  "@lark-apaas/observable-web": "^1.0.0",
87
87
  "@radix-ui/react-avatar": "^1.1.10",
88
88
  "@radix-ui/react-popover": "^1.1.15",