@lark-apaas/fullstack-rspack-preset 1.0.14 → 1.0.16
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
|
@@ -132,17 +132,21 @@ function removeAllChildren(element, skip) {
|
|
|
132
132
|
// 获取父窗口 origin
|
|
133
133
|
function getPreviewParentOrigin() {
|
|
134
134
|
const { origin } = window.location;
|
|
135
|
-
//
|
|
135
|
+
// force BOE环境
|
|
136
|
+
if (origin.includes('force.byted.org')) {
|
|
137
|
+
return 'https://force.feishu-boe.cn';
|
|
138
|
+
}
|
|
139
|
+
// MIAODA 线上环境
|
|
136
140
|
if (origin.includes('feishuapp.cn') ||
|
|
137
141
|
origin.includes('miaoda.feishuapp.net')) {
|
|
138
142
|
return 'https://miaoda.feishu.cn';
|
|
139
143
|
}
|
|
140
|
-
// PRE 环境
|
|
144
|
+
// MIAODA PRE 环境
|
|
141
145
|
if (origin.includes('fsapp.kundou.cn') ||
|
|
142
146
|
origin.includes('miaoda-pre.feishuapp.net')) {
|
|
143
147
|
return 'https://miaoda.feishu-pre.cn';
|
|
144
148
|
}
|
|
145
|
-
// BOE 环境
|
|
149
|
+
// MIAODA BOE 环境
|
|
146
150
|
return 'https://miaoda.feishu-boe.cn';
|
|
147
151
|
}
|
|
148
152
|
function sendPostMessage(message, targetOrigin) {
|
package/lib/preset.js
CHANGED
|
@@ -153,7 +153,7 @@ function createRecommendRspackConfig(options) {
|
|
|
153
153
|
},
|
|
154
154
|
minify: false, // 关闭 html 压缩,导致数据注入异常
|
|
155
155
|
}),
|
|
156
|
-
//
|
|
156
|
+
// 性能监控&tea埋点sdk插件
|
|
157
157
|
new slardar_performance_monitor_plugin_1.default(),
|
|
158
158
|
// 视图上下文注入插件
|
|
159
159
|
new view_context_injection_plugin_1.default(),
|
|
@@ -233,13 +233,17 @@ function createRecommendRspackConfig(options) {
|
|
|
233
233
|
publicPath: publicPath,
|
|
234
234
|
},
|
|
235
235
|
webSocketServer: {
|
|
236
|
-
|
|
236
|
+
// TODO 这里临时耦合了 CLIENT_BASE_PATH 包含 'af/p' 字符串判断是否为 force 部署
|
|
237
|
+
// 由于后期合并沙箱后会统一为 ws 协议,因此合并后直接删掉这里逻辑即可
|
|
238
|
+
type: clientBasePath.includes('af/p') ? 'ws' : 'sockjs',
|
|
237
239
|
options: {
|
|
238
240
|
path: `${clientBasePath}/ws`,
|
|
239
241
|
},
|
|
240
242
|
},
|
|
241
243
|
client: {
|
|
242
|
-
|
|
244
|
+
// TODO 这里临时耦合了 CLIENT_BASE_PATH 包含 'af/p' 字符串判断是否为 force 部署
|
|
245
|
+
// 由于后期合并沙箱后会统一为 ws 协议,因此合并后直接删掉这里逻辑即可
|
|
246
|
+
webSocketTransport: clientBasePath.includes('af/p') ? 'ws' : 'sockjs',
|
|
243
247
|
webSocketURL: {
|
|
244
248
|
port: 0,
|
|
245
249
|
pathname: `${clientBasePath}/ws`
|
|
@@ -251,6 +255,7 @@ function createRecommendRspackConfig(options) {
|
|
|
251
255
|
const requestOrigin = req.headers.origin ?? '';
|
|
252
256
|
// 定义允许的域名白名单
|
|
253
257
|
const allowedOrigins = [
|
|
258
|
+
'https://force.feishu-boe.cn',
|
|
254
259
|
'https://miaoda.feishu.cn',
|
|
255
260
|
'https://miaoda.feishu-boe.cn',
|
|
256
261
|
'https://miaoda.feishu-pre.cn',
|
|
@@ -38,6 +38,7 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
38
38
|
bid: this.options.bid,
|
|
39
39
|
globalName: this.options.globalName,
|
|
40
40
|
});
|
|
41
|
+
const teaSnippet = getTeaScriptContent();
|
|
41
42
|
if (!snippet)
|
|
42
43
|
return data;
|
|
43
44
|
// 创建 Slardar 脚本标签对象
|
|
@@ -47,6 +48,13 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
47
48
|
innerHTML: snippet,
|
|
48
49
|
attributes: {},
|
|
49
50
|
};
|
|
51
|
+
// 创建 Tea 脚本标签对象
|
|
52
|
+
const teaTag = {
|
|
53
|
+
tagName: 'script',
|
|
54
|
+
voidTag: false,
|
|
55
|
+
innerHTML: teaSnippet,
|
|
56
|
+
attributes: {},
|
|
57
|
+
};
|
|
50
58
|
// 找到 main.js 的索引位置
|
|
51
59
|
const mainJsIndex = data.headTags.findIndex((tag) => tag.tagName === 'script' &&
|
|
52
60
|
tag.attributes &&
|
|
@@ -54,11 +62,12 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
54
62
|
tag.attributes.src.includes('main.js'));
|
|
55
63
|
if (mainJsIndex !== -1) {
|
|
56
64
|
// 在 main.js 之前插入 Slardar 脚本
|
|
57
|
-
data.headTags.splice(mainJsIndex, 0, slardarTag);
|
|
65
|
+
data.headTags.splice(mainJsIndex, 0, slardarTag, teaTag);
|
|
58
66
|
}
|
|
59
67
|
else {
|
|
60
68
|
// 如果没找到 main.js,插入到 headTags 最前面
|
|
61
69
|
data.headTags.unshift(slardarTag);
|
|
70
|
+
data.headTags.unshift(teaTag);
|
|
62
71
|
}
|
|
63
72
|
return data;
|
|
64
73
|
});
|
|
@@ -106,3 +115,33 @@ function getSlardarScriptContent(option = {}) {
|
|
|
106
115
|
document.head.appendChild(performanceScript);
|
|
107
116
|
`;
|
|
108
117
|
}
|
|
118
|
+
// 获取 tea sdk 脚本
|
|
119
|
+
function getTeaScriptContent() {
|
|
120
|
+
return `
|
|
121
|
+
(function (win, export_obj) {
|
|
122
|
+
win['LogAnalyticsObject'] = export_obj;
|
|
123
|
+
if (!win[export_obj]) {
|
|
124
|
+
function _collect() {
|
|
125
|
+
_collect.q.push(arguments);
|
|
126
|
+
}
|
|
127
|
+
_collect.q = _collect.q || [];
|
|
128
|
+
win[export_obj] = _collect;
|
|
129
|
+
}
|
|
130
|
+
win[export_obj].l = +new Date();
|
|
131
|
+
})(window, 'collectEvent');
|
|
132
|
+
|
|
133
|
+
// 创建 tea sdk 脚本元素
|
|
134
|
+
const teaScript = document.createElement('script');
|
|
135
|
+
teaScript.src = 'https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.1/collect.js';
|
|
136
|
+
teaScript.crossOrigin = 'anonymous';
|
|
137
|
+
teaScript.async = true;
|
|
138
|
+
|
|
139
|
+
// 添加错误处理
|
|
140
|
+
teaScript.onerror = function() {
|
|
141
|
+
console.warn('Failed to load Tea script');
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// 将脚本添加到页面
|
|
145
|
+
document.head.appendChild(teaScript);
|
|
146
|
+
`;
|
|
147
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-rspack-preset",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"patches",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/parser": "^7.28.0",
|
|
32
32
|
"@babel/traverse": "^7.28.0",
|
|
33
33
|
"@babel/types": "^7.28.2",
|
|
34
|
-
"@lark-apaas/devtool-kits": "^1.2.
|
|
34
|
+
"@lark-apaas/devtool-kits": "^1.2.4",
|
|
35
35
|
"@lark-apaas/miaoda-inspector-babel-plugin": "^1.0.0",
|
|
36
36
|
"@lark-apaas/miaoda-inspector-jsx-runtime": "^1.0.0",
|
|
37
37
|
"@rspack/plugin-react-refresh": "^1.5.1",
|