@midscene/shared 1.0.1-beta-20251208070218.0 → 1.0.1-beta-20251208071759.0
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.
|
@@ -12,9 +12,20 @@ function injectReportHtmlFromCore(packageDir) {
|
|
|
12
12
|
if (!node_fs.existsSync(coreUtilsPath)) return void console.warn('[inject-report-html] @midscene/core dist not found, skipping');
|
|
13
13
|
const coreContent = node_fs.readFileSync(coreUtilsPath, 'utf-8');
|
|
14
14
|
if (!coreContent.includes(REPLACED_MARK)) return void console.warn('[inject-report-html] HTML not found in core dist. Ensure report builds first.');
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const markerIndex = coreContent.indexOf(REPLACED_MARK);
|
|
16
|
+
const jsonStart = markerIndex + REPLACED_MARK.length;
|
|
17
|
+
let jsonEnd = jsonStart;
|
|
18
|
+
if ('"' === coreContent[jsonStart]) {
|
|
19
|
+
jsonEnd = jsonStart + 1;
|
|
20
|
+
while(jsonEnd < coreContent.length)if ('\\' === coreContent[jsonEnd]) jsonEnd += 2;
|
|
21
|
+
else if ('"' === coreContent[jsonEnd]) {
|
|
22
|
+
jsonEnd += 1;
|
|
23
|
+
break;
|
|
24
|
+
} else jsonEnd += 1;
|
|
25
|
+
}
|
|
26
|
+
const jsonString = coreContent.slice(jsonStart, jsonEnd);
|
|
27
|
+
if (!jsonString || jsonString.length < 10) return void console.warn('[inject-report-html] Failed to extract HTML from core');
|
|
28
|
+
const finalContent = `${REPLACED_MARK}${jsonString}`;
|
|
18
29
|
const distDir = node_path.join(packageDir, 'dist');
|
|
19
30
|
if (!node_fs.existsSync(distDir)) return;
|
|
20
31
|
const jsFiles = node_fs.readdirSync(distDir).filter((f)=>f.endsWith('.js'));
|
|
@@ -51,9 +51,20 @@ function injectReportHtmlFromCore(packageDir) {
|
|
|
51
51
|
if (!external_node_fs_default().existsSync(coreUtilsPath)) return void console.warn('[inject-report-html] @midscene/core dist not found, skipping');
|
|
52
52
|
const coreContent = external_node_fs_default().readFileSync(coreUtilsPath, 'utf-8');
|
|
53
53
|
if (!coreContent.includes(REPLACED_MARK)) return void console.warn('[inject-report-html] HTML not found in core dist. Ensure report builds first.');
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const markerIndex = coreContent.indexOf(REPLACED_MARK);
|
|
55
|
+
const jsonStart = markerIndex + REPLACED_MARK.length;
|
|
56
|
+
let jsonEnd = jsonStart;
|
|
57
|
+
if ('"' === coreContent[jsonStart]) {
|
|
58
|
+
jsonEnd = jsonStart + 1;
|
|
59
|
+
while(jsonEnd < coreContent.length)if ('\\' === coreContent[jsonEnd]) jsonEnd += 2;
|
|
60
|
+
else if ('"' === coreContent[jsonEnd]) {
|
|
61
|
+
jsonEnd += 1;
|
|
62
|
+
break;
|
|
63
|
+
} else jsonEnd += 1;
|
|
64
|
+
}
|
|
65
|
+
const jsonString = coreContent.slice(jsonStart, jsonEnd);
|
|
66
|
+
if (!jsonString || jsonString.length < 10) return void console.warn('[inject-report-html] Failed to extract HTML from core');
|
|
67
|
+
const finalContent = `${REPLACED_MARK}${jsonString}`;
|
|
57
68
|
const distDir = external_node_path_default().join(packageDir, 'dist');
|
|
58
69
|
if (!external_node_fs_default().existsSync(distDir)) return;
|
|
59
70
|
const jsFiles = external_node_fs_default().readdirSync(distDir).filter((f)=>f.endsWith('.js'));
|
package/package.json
CHANGED
|
@@ -48,13 +48,34 @@ export function injectReportHtmlFromCore(packageDir: string) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Extract the JSON string after the marker
|
|
52
|
+
// JSON strings can contain escaped quotes, so we need to properly parse it
|
|
53
|
+
const markerIndex = coreContent.indexOf(REPLACED_MARK);
|
|
54
|
+
const jsonStart = markerIndex + REPLACED_MARK.length;
|
|
55
|
+
|
|
56
|
+
// Find the end of the JSON string by tracking quote escaping
|
|
57
|
+
let jsonEnd = jsonStart;
|
|
58
|
+
if (coreContent[jsonStart] === '"') {
|
|
59
|
+
jsonEnd = jsonStart + 1;
|
|
60
|
+
while (jsonEnd < coreContent.length) {
|
|
61
|
+
if (coreContent[jsonEnd] === '\\') {
|
|
62
|
+
jsonEnd += 2; // Skip escaped character
|
|
63
|
+
} else if (coreContent[jsonEnd] === '"') {
|
|
64
|
+
jsonEnd += 1; // Include closing quote
|
|
65
|
+
break;
|
|
66
|
+
} else {
|
|
67
|
+
jsonEnd += 1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const jsonString = coreContent.slice(jsonStart, jsonEnd);
|
|
73
|
+
if (!jsonString || jsonString.length < 10) {
|
|
53
74
|
console.warn('[inject-report-html] Failed to extract HTML from core');
|
|
54
75
|
return;
|
|
55
76
|
}
|
|
56
77
|
|
|
57
|
-
const finalContent = `${REPLACED_MARK}${
|
|
78
|
+
const finalContent = `${REPLACED_MARK}${jsonString}`;
|
|
58
79
|
const distDir = path.join(packageDir, 'dist');
|
|
59
80
|
|
|
60
81
|
if (!fs.existsSync(distDir)) return;
|