@lark-apaas/fullstack-rspack-preset 1.0.23-alpha.4 → 1.0.23-alpha.5
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.
|
@@ -39,15 +39,24 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
39
39
|
globalName: this.options.globalName,
|
|
40
40
|
});
|
|
41
41
|
const teaSnippet = getTeaScriptContent();
|
|
42
|
-
if (!snippet)
|
|
42
|
+
if (!snippet) {
|
|
43
43
|
return data;
|
|
44
|
+
}
|
|
44
45
|
// 创建 Slardar 脚本标签对象
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
let slardarTags;
|
|
47
|
+
if (Array.isArray(snippet)) {
|
|
48
|
+
slardarTags = snippet;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
slardarTags = [
|
|
52
|
+
{
|
|
53
|
+
tagName: 'script',
|
|
54
|
+
voidTag: false,
|
|
55
|
+
innerHTML: snippet,
|
|
56
|
+
attributes: {},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
51
60
|
// 创建 Tea 脚本标签对象
|
|
52
61
|
const teaTag = {
|
|
53
62
|
tagName: 'script',
|
|
@@ -62,12 +71,11 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
62
71
|
tag.attributes.src.includes('main.js'));
|
|
63
72
|
if (mainJsIndex !== -1) {
|
|
64
73
|
// 在 main.js 之前插入 Slardar 脚本
|
|
65
|
-
data.headTags.splice(mainJsIndex, 0,
|
|
74
|
+
data.headTags.splice(mainJsIndex, 0, ...slardarTags, teaTag);
|
|
66
75
|
}
|
|
67
76
|
else {
|
|
68
77
|
// 如果没找到 main.js,插入到 headTags 最前面
|
|
69
|
-
data.headTags.unshift(
|
|
70
|
-
data.headTags.unshift(teaTag);
|
|
78
|
+
data.headTags.unshift(...slardarTags, teaTag);
|
|
71
79
|
}
|
|
72
80
|
return data;
|
|
73
81
|
});
|
|
@@ -82,38 +90,48 @@ exports.default = SlardarPerformanceMonitorPlugin;
|
|
|
82
90
|
function getSlardarScriptContent(option = {}) {
|
|
83
91
|
const bid = option.bid || 'apaas_ai';
|
|
84
92
|
const globalName = option.globalName || 'KSlardarWeb';
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
tagName: 'script',
|
|
96
|
+
voidTag: false,
|
|
97
|
+
innerHTML: `
|
|
98
|
+
const slardarScript = document.createElement('script');
|
|
99
|
+
slardarScript.src = 'https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js?bid=${bid}&globalName=${globalName}';
|
|
100
|
+
slardarScript.crossOrigin = 'anonymous';
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// 添加错误处理
|
|
105
|
-
slardarScript.onerror = function() {
|
|
106
|
-
console.warn('Failed to load Slardar script');
|
|
107
|
-
};
|
|
102
|
+
// 添加 onload 事件处理
|
|
103
|
+
slardarScript.onload = function() {
|
|
104
|
+
// 脚本加载完成后执行初始化
|
|
105
|
+
if (window.${globalName}) {
|
|
106
|
+
window.${globalName}('init', {
|
|
107
|
+
bid: '${bid}',
|
|
108
|
+
// 四种类型:dev/boe/pre/online
|
|
109
|
+
env: 'online',
|
|
110
|
+
});
|
|
111
|
+
window.${globalName}('start');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
// 添加错误处理
|
|
116
|
+
slardarScript.onerror = function() {
|
|
117
|
+
console.warn('Failed to load Slardar script');
|
|
118
|
+
};
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
// 将脚本添加到页面
|
|
121
|
+
document.head.appendChild(slardarScript);
|
|
122
|
+
`,
|
|
123
|
+
attributes: {},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
tagName: 'script',
|
|
127
|
+
voidTag: false,
|
|
128
|
+
attributes: {
|
|
129
|
+
src: 'https://sf3-scmcdn-cn.feishucdn.com/obj/unpkg/byted/performance/0.1.2/dist/performance.iife.js',
|
|
130
|
+
crossOrigin: 'anonymous',
|
|
131
|
+
defer: true,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
];
|
|
117
135
|
}
|
|
118
136
|
// 获取 tea sdk 脚本
|
|
119
137
|
function getTeaScriptContent() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-rspack-preset",
|
|
3
|
-
"version": "1.0.23-alpha.
|
|
3
|
+
"version": "1.0.23-alpha.5",
|
|
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.11-alpha.
|
|
34
|
+
"@lark-apaas/devtool-kits": "1.2.11-alpha.2",
|
|
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",
|