@lark-apaas/fullstack-rspack-preset 1.0.26-alpha.0 → 1.0.26-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.
@@ -0,0 +1,148 @@
1
+ {
2
+ "version": 1,
3
+ "themeName": "UD Theme Style",
4
+ "theme": {
5
+ "seriesCnt": "6",
6
+ "backgroundColor": "rgba(0,0,0,0)",
7
+ "titleColor": "#1f2329",
8
+ "subtitleColor": "#8f959e",
9
+ "textColorShow": false,
10
+ "textColor": "#333",
11
+ "markTextColor": "#ffffff",
12
+ "color": [
13
+ "#3370eb",
14
+ "#1bcebf",
15
+ "#ffc60a",
16
+ "#ed6d0c",
17
+ "#dca1e4",
18
+ "#25b2e5",
19
+ "#6dcdeb",
20
+ "#288fcb",
21
+ "#94b5f5",
22
+ "#8f61d1",
23
+ "#8f61d1",
24
+ "#bf78e9",
25
+ "#008280",
26
+ "#27ad8e",
27
+ "#7bc335"
28
+ ],
29
+ "borderColor": "#dee0e3",
30
+ "borderWidth": 0,
31
+ "visualMapColor": ["#25b2e5", "#6dcdeb", "#288fcb"],
32
+ "legendTextColor": "#8f959e",
33
+ "kColor": "#fdc6c4",
34
+ "kColor0": "transparent",
35
+ "kBorderColor": "#f54a45",
36
+ "kBorderColor0": "#32a645",
37
+ "kBorderWidth": "2",
38
+ "lineWidth": "1",
39
+ "symbolSize": "6",
40
+ "symbol": "emptyCircle",
41
+ "symbolBorderWidth": "1",
42
+ "lineSmooth": true,
43
+ "graphLineWidth": 1,
44
+ "graphLineColor": "#dee0e3",
45
+ "mapLabelColor": "#000",
46
+ "mapLabelColorE": "#516b91",
47
+ "mapBorderColor": "#516b91",
48
+ "mapBorderColorE": "#516b91",
49
+ "mapBorderWidth": 0.5,
50
+ "mapBorderWidthE": 1,
51
+ "mapAreaColor": "#f3f3f3",
52
+ "mapAreaColorE": "#a5e7f0",
53
+ "axes": [
54
+ {
55
+ "type": "all",
56
+ "name": "通用坐标轴",
57
+ "axisLineShow": true,
58
+ "axisLineColor": "#dee0e3",
59
+ "axisTickShow": false,
60
+ "axisTickColor": "#333",
61
+ "axisLabelShow": true,
62
+ "axisLabelColor": "#8f959e",
63
+ "splitLineShow": true,
64
+ "splitLineColor": ["#dee0e3"],
65
+ "splitAreaShow": false,
66
+ "splitAreaColor": ["rgba(250,250,250,0.05)", "rgba(200,200,200,0.02)"]
67
+ },
68
+ {
69
+ "type": "category",
70
+ "name": "类目坐标轴",
71
+ "axisLineShow": true,
72
+ "axisLineColor": "#333",
73
+ "axisTickShow": true,
74
+ "axisTickColor": "#333",
75
+ "axisLabelShow": true,
76
+ "axisLabelColor": "#333",
77
+ "splitLineShow": false,
78
+ "splitLineColor": ["#ccc"],
79
+ "splitAreaShow": false,
80
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
81
+ },
82
+ {
83
+ "type": "value",
84
+ "name": "数值坐标轴",
85
+ "axisLineShow": true,
86
+ "axisLineColor": "#333",
87
+ "axisTickShow": true,
88
+ "axisTickColor": "#333",
89
+ "axisLabelShow": true,
90
+ "axisLabelColor": "#333",
91
+ "splitLineShow": true,
92
+ "splitLineColor": ["#ccc"],
93
+ "splitAreaShow": false,
94
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
95
+ },
96
+ {
97
+ "type": "log",
98
+ "name": "对数坐标轴",
99
+ "axisLineShow": true,
100
+ "axisLineColor": "#333",
101
+ "axisTickShow": true,
102
+ "axisTickColor": "#333",
103
+ "axisLabelShow": true,
104
+ "axisLabelColor": "#333",
105
+ "splitLineShow": true,
106
+ "splitLineColor": ["#ccc"],
107
+ "splitAreaShow": false,
108
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
109
+ },
110
+ {
111
+ "type": "time",
112
+ "name": "时间坐标轴",
113
+ "axisLineShow": true,
114
+ "axisLineColor": "#333",
115
+ "axisTickShow": true,
116
+ "axisTickColor": "#333",
117
+ "axisLabelShow": true,
118
+ "axisLabelColor": "#333",
119
+ "splitLineShow": true,
120
+ "splitLineColor": ["#ccc"],
121
+ "splitAreaShow": false,
122
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
123
+ }
124
+ ],
125
+ "axisSeperateSetting": false,
126
+ "toolboxColor": "#8f959e",
127
+ "toolboxEmphasisColor": "#1f2329",
128
+ "tooltipAxisColor": "#dee0e3",
129
+ "tooltipAxisWidth": 1,
130
+ "timelineLineColor": "#336df4",
131
+ "timelineLineWidth": "-1",
132
+ "timelineItemColor": "#336df4",
133
+ "timelineItemColorE": "#1456f0",
134
+ "timelineCheckColor": "#1456f0",
135
+ "timelineCheckBorderColor": "#94b4ff",
136
+ "timelineItemBorderWidth": "0.5",
137
+ "timelineControlColor": "#336df4",
138
+ "timelineControlBorderColor": "#336df4",
139
+ "timelineControlBorderWidth": 0.5,
140
+ "timelineLabelColor": "#8f959e",
141
+ "datazoomBackgroundColor": "rgba(0,0,0,0)",
142
+ "datazoomDataColor": "rgba(255,255,255,0.3)",
143
+ "datazoomFillColor": "rgba(167,183,204,0.4)",
144
+ "datazoomHandleColor": "#a7b7cc",
145
+ "datazoomHandleWidth": "100",
146
+ "datazoomLabelColor": "#333"
147
+ }
148
+ }
package/lib/preset.js CHANGED
@@ -23,26 +23,6 @@ function sendBackendUnavailable502(_err, _req, res) {
23
23
  });
24
24
  res.end(JSON.stringify({ error: 'Bad Gateway', message: 'Backend service is not running' }));
25
25
  }
26
- function forwardXForwardedHost(proxyReq, req) {
27
- const xForwardedHostRaw = req.headers['x-forwarded-host'];
28
- const hostRaw = req.headers.host;
29
- const normalizeHeader = (raw) => {
30
- if (!raw)
31
- return undefined;
32
- const combined = Array.isArray(raw) ? raw.join(',') : raw;
33
- const first = combined.split(',')[0]?.trim();
34
- return first || undefined;
35
- };
36
- const xForwardedHost = normalizeHeader(xForwardedHostRaw);
37
- const host = normalizeHeader(hostRaw);
38
- const forwardedHost = xForwardedHost || host;
39
- if (!forwardedHost)
40
- return;
41
- proxyReq.setHeader('X-Forwarded-Host', forwardedHost);
42
- if (xForwardedHost) {
43
- proxyReq.setHeader('Host', xForwardedHost);
44
- }
45
- }
46
26
  function createRecommendRspackConfig(options) {
47
27
  const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
48
28
  } = options;
@@ -313,18 +293,12 @@ function createRecommendRspackConfig(options) {
313
293
  target: `http://localhost:${serverPort}`,
314
294
  changeOrigin: true,
315
295
  onError: sendBackendUnavailable502,
316
- onProxyReq: (proxyReq, req) => {
317
- forwardXForwardedHost(proxyReq, req);
318
- },
319
296
  },
320
297
  {
321
298
  context: [`${clientBasePath}/__innerapi__`],
322
299
  target: `http://localhost:${serverPort}`,
323
300
  changeOrigin: true,
324
301
  onError: sendBackendUnavailable502,
325
- onProxyReq: (proxyReq, req) => {
326
- forwardXForwardedHost(proxyReq, req);
327
- },
328
302
  },
329
303
  {
330
304
  context: (pathname, req) => {
@@ -337,9 +311,6 @@ function createRecommendRspackConfig(options) {
337
311
  target: `http://localhost:${serverPort}`,
338
312
  changeOrigin: true,
339
313
  logLevel: 'debug',
340
- onProxyReq: (proxyReq, req) => {
341
- forwardXForwardedHost(proxyReq, req);
342
- },
343
314
  onError: (err, req, res) => (0, devtool_kits_1.handleDevProxyError)(err, req, res, {
344
315
  logDir: process.env.LOG_DIR || './logs',
345
316
  logFileName: 'server.std.log',
@@ -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
- const slardarTag = {
46
- tagName: 'script',
47
- voidTag: false,
48
- innerHTML: snippet,
49
- attributes: {},
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,11 +71,15 @@ 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, slardarTag, teaTag);
74
+ data.headTags = [
75
+ ...data.headTags.slice(0, mainJsIndex),
76
+ ...slardarTags,
77
+ ...data.headTags.slice(mainJsIndex),
78
+ ];
66
79
  }
67
80
  else {
68
81
  // 如果没找到 main.js,插入到 headTags 最前面
69
- data.headTags.unshift(slardarTag);
82
+ data.headTags = slardarTags.concat(data.headTags);
70
83
  data.headTags.unshift(teaTag);
71
84
  }
72
85
  return data;
@@ -82,38 +95,50 @@ exports.default = SlardarPerformanceMonitorPlugin;
82
95
  function getSlardarScriptContent(option = {}) {
83
96
  const bid = option.bid || 'apaas_ai';
84
97
  const globalName = option.globalName || 'KSlardarWeb';
85
- return `
86
- // 创建 Slardar 脚本元素
87
- const slardarScript = document.createElement('script');
88
- slardarScript.src = 'https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js?bid=${bid}&globalName=${globalName}';
89
- slardarScript.crossOrigin = 'anonymous';
98
+ return [
99
+ {
100
+ tagName: 'script',
101
+ voidTag: false,
102
+ attributes: {
103
+ src: `https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js?bid=${bid}&globalName=${globalName}`,
104
+ crossOrigin: 'anonymous',
105
+ defer: true,
106
+ },
107
+ },
108
+ {
109
+ tagName: 'script',
110
+ voidTag: false,
111
+ innerHTML: `
112
+ // 添加 onload 事件处理
113
+ slardarScript.onload = function() {
114
+ // 脚本加载完成后执行初始化
115
+ if (window.${globalName}) {
116
+ window.${globalName}('init', {
117
+ bid: '${bid}',
118
+ // 四种类型:dev/boe/pre/online
119
+ env: 'online',
120
+ });
121
+ window.${globalName}('start');
122
+ }
123
+ };
90
124
 
91
- // 添加 onload 事件处理
92
- slardarScript.onload = function() {
93
- // 脚本加载完成后执行初始化
94
- if (window.${globalName}) {
95
- window.${globalName}('init', {
96
- bid: '${bid}',
97
- // 四种类型:dev/boe/pre/online
98
- env: 'online',
99
- });
100
- window.${globalName}('start');
101
- }
102
- };
103
-
104
- // 添加错误处理
105
- slardarScript.onerror = function() {
106
- console.warn('Failed to load Slardar script');
107
- };
108
-
109
- // 将脚本添加到页面
110
- document.head.appendChild(slardarScript);
111
-
112
- // 添加 TTI 监控脚本
113
- const performanceScript = document.createElement('script');
114
- performanceScript.src = 'https://sf3-scmcdn-cn.feishucdn.com/obj/unpkg/byted/performance/0.1.2/dist/performance.iife.js';
115
- document.head.appendChild(performanceScript);
116
- `;
125
+ // 添加错误处理
126
+ slardarScript.onerror = function() {
127
+ console.warn('Failed to load Slardar script');
128
+ };
129
+ `,
130
+ attributes: {},
131
+ },
132
+ {
133
+ tagName: 'script',
134
+ voidTag: false,
135
+ attributes: {
136
+ src: 'https://sf3-scmcdn-cn.feishucdn.com/obj/unpkg/byted/performance/0.1.2/dist/performance.iife.js',
137
+ crossOrigin: 'anonymous',
138
+ defer: true,
139
+ },
140
+ },
141
+ ];
117
142
  }
118
143
  // 获取 tea sdk 脚本
119
144
  function getTeaScriptContent() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.26-alpha.0",
3
+ "version": "1.0.26-alpha.3",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",