@lark-apaas/devtool-kits 1.2.13 → 1.2.14-alpha.1

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/error.html CHANGED
@@ -163,35 +163,12 @@
163
163
 
164
164
  // 发送 postMessage
165
165
  function sendPostMessage(message, targetOrigin) {
166
- const origin = targetOrigin || getPreviewParentOrigin();
166
+ const origin = targetOrigin || parentOrigin || undefined;
167
+ if (!origin) return;
167
168
  console.log('sendPostMessage', message, origin);
168
169
  window.parent.postMessage(message, origin);
169
170
  }
170
-
171
- // 获取父窗口 origin
172
- function getPreviewParentOrigin() {
173
- const { origin } = window.location;
174
- if (origin.includes('force.feishuapp.net')) {
175
- return 'https://force.feishu.cn';
176
- }
177
- if (origin.includes('force-pre.feishuapp.net')) {
178
- return 'https://force.feishu-pre.cn';
179
- }
180
- // force BOE环境
181
- if (origin.includes('force.byted.org')) {
182
- return 'https://force.feishu-boe.cn';
183
- }
184
- // MIAODA 线上环境
185
- if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) {
186
- return 'https://miaoda.feishu.cn';
187
- }
188
- // MIAODA PRE 环境
189
- if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) {
190
- return 'https://miaoda.feishu-pre.cn';
191
- }
192
- // MIAODA BOE 环境
193
- return 'https://miaoda.feishu-boe.cn';
194
- }
171
+ const parentOrigin = '{{.parentOrigin}}';
195
172
 
196
173
  // 页面加载完成后初始化
197
174
  if (document.readyState === 'loading') {
package/dist/index.cjs CHANGED
@@ -1435,8 +1435,8 @@ function checkForErrors(logs) {
1435
1435
  return false;
1436
1436
  }
1437
1437
  __name(checkForErrors, "checkForErrors");
1438
- function injectTemplateData(template, clientBasePath) {
1439
- return template.replace("{{.clientBasePath}}", clientBasePath);
1438
+ function injectTemplateData(template, clientBasePath, parentOrigin) {
1439
+ return template.replace("{{.clientBasePath}}", clientBasePath).replace("{{.parentOrigin}}", parentOrigin);
1440
1440
  }
1441
1441
  __name(injectTemplateData, "injectTemplateData");
1442
1442
  function handleDevProxyError(err, req, res, options) {
@@ -1474,7 +1474,8 @@ function handleDevProxyError(err, req, res, options) {
1474
1474
  console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
1475
1475
  }
1476
1476
  const template = getErrorHtmlTemplate();
1477
- const html = injectTemplateData(template, clientBasePathWithoutSlash);
1477
+ const parentOrigin = process.env.FORCE_FRAMEWORK_DOMAIN_MAIN || "";
1478
+ const html = injectTemplateData(template, clientBasePathWithoutSlash, parentOrigin);
1478
1479
  res.writeHead(200, {
1479
1480
  "Content-Type": "text/html; charset=utf-8",
1480
1481
  "Cache-Control": "no-cache, no-store, must-revalidate",