@lark-apaas/miaoda-presets 1.0.7 → 1.0.8
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/lib/overlay/index.js
CHANGED
|
@@ -170,22 +170,6 @@ async function copyToClipboard(text) {
|
|
|
170
170
|
return fallbackCopyToClipboard(text);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
// 获取父窗口 origin
|
|
174
|
-
function getPreviewParentOrigin() {
|
|
175
|
-
const { origin } = window.location;
|
|
176
|
-
// 线上环境
|
|
177
|
-
if (origin.includes('feishuapp.cn') ||
|
|
178
|
-
origin.includes('miaoda.feishuapp.net')) {
|
|
179
|
-
return 'https://miaoda.feishu.cn';
|
|
180
|
-
}
|
|
181
|
-
// PRE 环境
|
|
182
|
-
if (origin.includes('fsapp.kundou.cn') ||
|
|
183
|
-
origin.includes('miaoda-pre.feishuapp.net')) {
|
|
184
|
-
return 'https://miaoda.feishu-pre.cn';
|
|
185
|
-
}
|
|
186
|
-
// BOE 环境
|
|
187
|
-
return 'https://miaoda.feishu-boe.cn';
|
|
188
|
-
}
|
|
189
173
|
/**
|
|
190
174
|
* Creates the main `div` element for the overlay to render.
|
|
191
175
|
* @returns {void}
|
|
@@ -193,9 +177,34 @@ function getPreviewParentOrigin() {
|
|
|
193
177
|
function render() {
|
|
194
178
|
ensureRootExists(function () {
|
|
195
179
|
removeAllChildren(root);
|
|
180
|
+
const getEnvOrigin = () => {
|
|
181
|
+
return typeof process !== 'undefined' && process.env
|
|
182
|
+
? process.env.FORCE_FRAMEWORK_DOMAIN_MAIN
|
|
183
|
+
: undefined;
|
|
184
|
+
};
|
|
185
|
+
const getLegacyParentOrigin = () => {
|
|
186
|
+
const currentOrigin = window.location?.origin || '';
|
|
187
|
+
if (currentOrigin.includes('force.feishuapp.net')) {
|
|
188
|
+
return 'https://force.feishu.cn';
|
|
189
|
+
}
|
|
190
|
+
if (currentOrigin.includes('force-pre.feishuapp.net')) {
|
|
191
|
+
return 'https://force.feishu-pre.cn';
|
|
192
|
+
}
|
|
193
|
+
if (currentOrigin.includes('force.byted.org')) {
|
|
194
|
+
return 'https://force.feishu-boe.cn';
|
|
195
|
+
}
|
|
196
|
+
if (currentOrigin.includes('feishuapp.cn') || currentOrigin.includes('miaoda.feishuapp.net')) {
|
|
197
|
+
return 'https://miaoda.feishu.cn';
|
|
198
|
+
}
|
|
199
|
+
if (currentOrigin.includes('fsapp.kundou.cn') || currentOrigin.includes('miaoda-pre.feishuapp.net')) {
|
|
200
|
+
return 'https://miaoda.feishu-pre.cn';
|
|
201
|
+
}
|
|
202
|
+
return 'https://miaoda.feishu-boe.cn';
|
|
203
|
+
};
|
|
196
204
|
// 发送 postMessage
|
|
197
205
|
const sendPostMessage = (message, targetOrigin) => {
|
|
198
|
-
const
|
|
206
|
+
const parentOrigin = getEnvOrigin() || getLegacyParentOrigin();
|
|
207
|
+
const origin = targetOrigin || parentOrigin;
|
|
199
208
|
window.parent.postMessage(message, origin);
|
|
200
209
|
};
|
|
201
210
|
// 通知前端,渲染错误页面已准备就绪
|
package/lib/recommend/rspack.js
CHANGED
|
@@ -119,6 +119,7 @@ function createRecommendRspackConfig(options) {
|
|
|
119
119
|
'process.env.NODE_ENV': JSON.stringify(isDev ? 'development' : 'production'),
|
|
120
120
|
'process.env.CWD': JSON.stringify(process.cwd()),
|
|
121
121
|
'process.env.runtimeMode': JSON.stringify(runtimeMode),
|
|
122
|
+
'process.env.FORCE_FRAMEWORK_DOMAIN_MAIN': JSON.stringify(process.env.FORCE_FRAMEWORK_DOMAIN_MAIN ?? ''),
|
|
122
123
|
}),
|
|
123
124
|
new core_1.default.optimize.LimitChunkCountPlugin({
|
|
124
125
|
maxChunks: 1,
|
|
@@ -180,22 +181,13 @@ function createRecommendRspackConfig(options) {
|
|
|
180
181
|
},
|
|
181
182
|
devtool: isDev ? 'source-map' : false, // 对应vite的sourcemap配置
|
|
182
183
|
devServer: {
|
|
183
|
-
headers:
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
'https://miaoda.feishu-pre.cn',
|
|
191
|
-
];
|
|
192
|
-
// 检查请求的Origin是否在允许的列表中
|
|
193
|
-
const allowedOrigin = allowedOrigins.includes(requestOrigin)
|
|
194
|
-
? requestOrigin
|
|
195
|
-
: allowedOrigins[0]; // 默认返回第一个允许的域名
|
|
196
|
-
return {
|
|
197
|
-
'Access-Control-Allow-Origin': allowedOrigin,
|
|
198
|
-
};
|
|
184
|
+
headers: _req => {
|
|
185
|
+
const headers = {};
|
|
186
|
+
const allowedOrigin = process.env.FORCE_FRAMEWORK_DOMAIN_MAIN;
|
|
187
|
+
if (!allowedOrigin)
|
|
188
|
+
return headers;
|
|
189
|
+
headers['Access-Control-Allow-Origin'] = allowedOrigin;
|
|
190
|
+
return headers;
|
|
199
191
|
},
|
|
200
192
|
onListening(server) {
|
|
201
193
|
if (runtimeMode === 'fullstack') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/miaoda-presets",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -61,5 +61,6 @@
|
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": ">=16.14.0",
|
|
63
63
|
"react-dom": ">=16.14.0"
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "68657b650e5f2343843850323db2b3beae697ace"
|
|
65
66
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"moduleDetection": "force",
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": false,
|
|
19
|
-
"noUnusedLocals": false,
|
|
20
|
-
"noUnusedParameters": false,
|
|
21
|
-
"noImplicitAny": false,
|
|
22
|
-
"noFallthroughCasesInSwitch": false,
|
|
23
|
-
|
|
24
|
-
"sourceMap": true,
|
|
25
|
-
"allowJs": true,
|
|
26
|
-
"strictNullChecks": false,
|
|
27
|
-
|
|
28
|
-
"incremental": false,
|
|
29
|
-
},
|
|
30
|
-
"include": [
|
|
31
|
-
"client/**/*"
|
|
32
|
-
],
|
|
33
|
-
"exclude": [
|
|
34
|
-
"node_modules",
|
|
35
|
-
"dist",
|
|
36
|
-
"public"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"emitDecoratorMetadata": true,
|
|
13
|
-
"importHelpers": true,
|
|
14
|
-
"incremental": true,
|
|
15
|
-
|
|
16
|
-
"strict": false,
|
|
17
|
-
"composite": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"removeComments": false,
|
|
20
|
-
"noEmit": false,
|
|
21
|
-
|
|
22
|
-
"types": ["node"]
|
|
23
|
-
},
|
|
24
|
-
"ts-node": { "require": ["tsconfig-paths/register"] }
|
|
25
|
-
}
|