@rsdoctor/sdk 1.2.2-beta.3 → 1.2.2
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,7 +12,7 @@ var __webpack_modules__ = {
|
|
|
12
12
|
"../utils": function(module) {
|
|
13
13
|
module.exports = require("../utils/index.js");
|
|
14
14
|
},
|
|
15
|
-
"
|
|
15
|
+
"../utils/openBrowser": function(module) {
|
|
16
16
|
module.exports = require("../utils/openBrowser.js");
|
|
17
17
|
},
|
|
18
18
|
"./core": function(module) {
|
|
@@ -110,7 +110,7 @@ var __webpack_exports__ = {};
|
|
|
110
110
|
var _core__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__("./core");
|
|
111
111
|
var _rsdoctor_utils_common__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("@rsdoctor/utils/common");
|
|
112
112
|
var _utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("../utils");
|
|
113
|
-
var _utils_openBrowser__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("
|
|
113
|
+
var _utils_openBrowser__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("../utils/openBrowser");
|
|
114
114
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
115
115
|
for(var __WEBPACK_IMPORT_KEY__ in _utils_openBrowser__WEBPACK_IMPORTED_MODULE_13__)if ([
|
|
116
116
|
"default",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"
|
|
3
|
+
"../utils/openBrowser": function(module) {
|
|
4
4
|
module.exports = require("../utils/openBrowser.js");
|
|
5
5
|
},
|
|
6
6
|
"./apis": function(module) {
|
|
@@ -108,7 +108,7 @@ var __webpack_exports__ = {};
|
|
|
108
108
|
var _router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("./router");
|
|
109
109
|
var _apis__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__("./apis");
|
|
110
110
|
var _rsdoctor_utils_logger__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("@rsdoctor/utils/logger");
|
|
111
|
-
var _sdk_utils_openBrowser__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("
|
|
111
|
+
var _sdk_utils_openBrowser__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("../utils/openBrowser");
|
|
112
112
|
var path__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("path");
|
|
113
113
|
var path__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_13__);
|
|
114
114
|
var _utils__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__("./utils");
|
|
@@ -1,64 +1,22 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE__server_fakeServer_mjs_179969cf__ from "../server/fakeServer.mjs";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__server_index_mjs_ad27270e__ from "../server/index.mjs";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs_be7570d9__ from "../utils/index.mjs";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__utils_openBrowser_mjs_06d7bf6d__ from "../utils/openBrowser.mjs";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE__core_mjs_165c2562__ from "./core.mjs";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_graph_0dbfec78__ from "@rsdoctor/graph";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_types_d1991c3b__ from "@rsdoctor/types";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_build_f62ed182__ from "@rsdoctor/utils/build";
|
|
9
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_common_f9f17f84__ from "@rsdoctor/utils/common";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_error_c16cc6f1__ from "@rsdoctor/utils/error";
|
|
11
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_logger_39923349__ from "@rsdoctor/utils/logger";
|
|
12
|
-
import * as __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__ from "fs-extra";
|
|
13
1
|
import * as __WEBPACK_EXTERNAL_MODULE_json_cycle_87a8e8e6__ from "json-cycle";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
2
|
+
import fs_extra from "fs-extra";
|
|
3
|
+
import path_0 from "path";
|
|
4
|
+
import { DevToolError } from "@rsdoctor/utils/error";
|
|
5
|
+
import { Constants, SDK } from "@rsdoctor/types";
|
|
6
|
+
import { File } from "@rsdoctor/utils/build";
|
|
7
|
+
import { SourceMapConsumer } from "source-map";
|
|
8
|
+
import { ChunkGraph, ModuleGraph, PackageGraph } from "@rsdoctor/graph";
|
|
9
|
+
import { logger } from "@rsdoctor/utils/logger";
|
|
10
|
+
import { RsdoctorServer } from "../server/index.mjs";
|
|
11
|
+
import { RsdoctorFakeServer } from "../server/fakeServer.mjs";
|
|
12
|
+
import { SDKCore } from "./core.mjs";
|
|
13
|
+
import { Algorithm, Lodash } from "@rsdoctor/utils/common";
|
|
14
|
+
import { findRoot } from "../utils/index.mjs";
|
|
15
|
+
export * from "../utils/openBrowser.mjs";
|
|
16
16
|
export * from "../utils/base.mjs";
|
|
17
17
|
var __webpack_modules__ = {
|
|
18
|
-
"../server/fakeServer": function(module) {
|
|
19
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__server_fakeServer_mjs_179969cf__;
|
|
20
|
-
},
|
|
21
|
-
"../server": function(module) {
|
|
22
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__server_index_mjs_ad27270e__;
|
|
23
|
-
},
|
|
24
|
-
"../utils": function(module) {
|
|
25
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__utils_index_mjs_be7570d9__;
|
|
26
|
-
},
|
|
27
|
-
"@/sdk/utils/openBrowser": function(module) {
|
|
28
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__utils_openBrowser_mjs_06d7bf6d__;
|
|
29
|
-
},
|
|
30
|
-
"./core": function(module) {
|
|
31
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__core_mjs_165c2562__;
|
|
32
|
-
},
|
|
33
|
-
"@rsdoctor/graph": function(module) {
|
|
34
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_graph_0dbfec78__;
|
|
35
|
-
},
|
|
36
|
-
"@rsdoctor/types": function(module) {
|
|
37
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_types_d1991c3b__;
|
|
38
|
-
},
|
|
39
|
-
"@rsdoctor/utils/build": function(module) {
|
|
40
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_build_f62ed182__;
|
|
41
|
-
},
|
|
42
|
-
"@rsdoctor/utils/common": function(module) {
|
|
43
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_common_f9f17f84__;
|
|
44
|
-
},
|
|
45
|
-
"@rsdoctor/utils/error": function(module) {
|
|
46
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_error_c16cc6f1__;
|
|
47
|
-
},
|
|
48
|
-
"@rsdoctor/utils/logger": function(module) {
|
|
49
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__rsdoctor_utils_logger_39923349__;
|
|
50
|
-
},
|
|
51
|
-
"fs-extra": function(module) {
|
|
52
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__;
|
|
53
|
-
},
|
|
54
18
|
"json-cycle": function(module) {
|
|
55
19
|
module.exports = __WEBPACK_EXTERNAL_MODULE_json_cycle_87a8e8e6__;
|
|
56
|
-
},
|
|
57
|
-
path: function(module) {
|
|
58
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_path__;
|
|
59
|
-
},
|
|
60
|
-
"source-map": function(module) {
|
|
61
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_source_map_c2f0c629__;
|
|
62
20
|
}
|
|
63
21
|
};
|
|
64
22
|
var __webpack_module_cache__ = {};
|
|
@@ -71,33 +29,19 @@ function __webpack_require__(moduleId) {
|
|
|
71
29
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
72
30
|
return module.exports;
|
|
73
31
|
}
|
|
74
|
-
var external_fs_extra_ = __webpack_require__("fs-extra");
|
|
75
|
-
var external_path_ = __webpack_require__("path");
|
|
76
|
-
var error_ = __webpack_require__("@rsdoctor/utils/error");
|
|
77
|
-
var types_ = __webpack_require__("@rsdoctor/types");
|
|
78
|
-
var build_ = __webpack_require__("@rsdoctor/utils/build");
|
|
79
|
-
var external_source_map_ = __webpack_require__("source-map");
|
|
80
|
-
var graph_ = __webpack_require__("@rsdoctor/graph");
|
|
81
|
-
var logger_ = __webpack_require__("@rsdoctor/utils/logger");
|
|
82
|
-
var index_mjs_ = __webpack_require__("../server");
|
|
83
|
-
var fakeServer_mjs_ = __webpack_require__("../server/fakeServer");
|
|
84
|
-
var external_core_mjs_ = __webpack_require__("./core");
|
|
85
|
-
var common_ = __webpack_require__("@rsdoctor/utils/common");
|
|
86
|
-
var external_utils_index_mjs_ = __webpack_require__("../utils");
|
|
87
|
-
__webpack_require__("@/sdk/utils/openBrowser");
|
|
88
32
|
const jc = __webpack_require__("json-cycle");
|
|
89
|
-
class RsdoctorSDK extends
|
|
33
|
+
class RsdoctorSDK extends SDKCore {
|
|
90
34
|
async bootstrap() {
|
|
91
|
-
|
|
35
|
+
logger.debug(`${Date.now()}`, '[RsdoctorSDK][bootstrap start]');
|
|
92
36
|
this.server && await this.server.bootstrap();
|
|
93
37
|
await super.bootstrap();
|
|
94
|
-
|
|
38
|
+
logger.debug(`${Date.now()} ${this.server.origin}`, '[RsdoctorSDK][bootstrap end]');
|
|
95
39
|
}
|
|
96
40
|
async dispose() {
|
|
97
|
-
|
|
41
|
+
logger.debug(`${Date.now()}`, '[RsdoctorSDK][dispose start]');
|
|
98
42
|
this.server && await this.server.dispose();
|
|
99
43
|
await super.dispose();
|
|
100
|
-
|
|
44
|
+
logger.debug(`${Date.now()}`, '[RsdoctorSDK][dispose end]');
|
|
101
45
|
}
|
|
102
46
|
async applyErrorFix(id) {
|
|
103
47
|
const { _errors: errors } = this;
|
|
@@ -105,7 +49,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
105
49
|
if (!error || !error.path || !error.fixData || error.fixData.isFixed) return;
|
|
106
50
|
const { path: filePath, fixData } = error;
|
|
107
51
|
const sameFileErrors = errors.filter((item)=>item.path === filePath && item !== error);
|
|
108
|
-
let content = (await
|
|
52
|
+
let content = (await File.fse.readFile(filePath, 'utf-8')).toString();
|
|
109
53
|
const startTxt = content.substring(0, fixData.start);
|
|
110
54
|
const endTxt = content.substring(fixData.end, content.length);
|
|
111
55
|
const offset = (fixData.newText ?? '').length - (fixData.end - fixData.start);
|
|
@@ -119,15 +63,15 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
119
63
|
}
|
|
120
64
|
}
|
|
121
65
|
}
|
|
122
|
-
await
|
|
66
|
+
await File.fse.writeFile(filePath, content);
|
|
123
67
|
}
|
|
124
68
|
clear() {
|
|
125
69
|
this._errors = [];
|
|
126
70
|
this._loader = [];
|
|
127
71
|
this._resolver = [];
|
|
128
72
|
this._plugin = {};
|
|
129
|
-
this._moduleGraph = new
|
|
130
|
-
this._chunkGraph = new
|
|
73
|
+
this._moduleGraph = new ModuleGraph();
|
|
74
|
+
this._chunkGraph = new ChunkGraph();
|
|
131
75
|
}
|
|
132
76
|
clearSourceMapCache() {
|
|
133
77
|
this._rawSourceMapCache = new Map();
|
|
@@ -140,7 +84,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
140
84
|
const rawData = rawMap.get(file);
|
|
141
85
|
if (!rawData || rawData.version < 0 || !(null == (_rawData_sourcesContent = rawData.sourcesContent) ? void 0 : _rawData_sourcesContent[0]) || !rawData.mappings) return Promise.resolve(void 0);
|
|
142
86
|
try {
|
|
143
|
-
const result = await new
|
|
87
|
+
const result = await new SourceMapConsumer(rawData);
|
|
144
88
|
sourceMap.set(file, result);
|
|
145
89
|
return result;
|
|
146
90
|
} catch (e) {
|
|
@@ -157,7 +101,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
157
101
|
}
|
|
158
102
|
reportError(errors) {
|
|
159
103
|
errors.forEach((item)=>{
|
|
160
|
-
this._errors.push(
|
|
104
|
+
this._errors.push(DevToolError.from(item, {
|
|
161
105
|
code: this.name
|
|
162
106
|
}));
|
|
163
107
|
});
|
|
@@ -166,7 +110,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
166
110
|
reportLoader(data) {
|
|
167
111
|
data.forEach((item)=>{
|
|
168
112
|
var _this_extraConfig;
|
|
169
|
-
if ((null == (_this_extraConfig = this.extraConfig) ? void 0 : _this_extraConfig.mode) ===
|
|
113
|
+
if ((null == (_this_extraConfig = this.extraConfig) ? void 0 : _this_extraConfig.mode) === SDK.IMode[SDK.IMode.brief]) item.loaders.forEach((_loader)=>{
|
|
170
114
|
_loader.input = '';
|
|
171
115
|
_loader.result = '';
|
|
172
116
|
});
|
|
@@ -216,17 +160,17 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
216
160
|
this.onDataReport();
|
|
217
161
|
}
|
|
218
162
|
reportModuleGraph(data) {
|
|
219
|
-
|
|
163
|
+
logger.debug(`data size: ${data.size()}`, '[SDK.reportModuleGraph][start]');
|
|
220
164
|
this._moduleGraph.fromInstance(data);
|
|
221
165
|
this.createPackageGraph();
|
|
222
166
|
this.onDataReport();
|
|
223
|
-
|
|
167
|
+
logger.debug(`sdk._moduleGraph size: ${this._moduleGraph.size()}`, '[SDK reportModuleGraph][end]');
|
|
224
168
|
}
|
|
225
169
|
reportPackageGraph(data) {
|
|
226
|
-
|
|
170
|
+
logger.debug('[SDK.reportPackageGraph][start]');
|
|
227
171
|
if (!this._packageGraph) this._packageGraph = data;
|
|
228
172
|
this.onDataReport();
|
|
229
|
-
|
|
173
|
+
logger.debug(`sdk._moduleGraph size: ${this._moduleGraph.size()}`, '[SDK reportPackageGraph][end]');
|
|
230
174
|
}
|
|
231
175
|
reportChunkGraph(data) {
|
|
232
176
|
this._chunkGraph.addAsset(...data.getAssets());
|
|
@@ -256,25 +200,25 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
256
200
|
this._tileReportHtml = tileReportHtml;
|
|
257
201
|
}
|
|
258
202
|
createPackageGraph() {
|
|
259
|
-
|
|
203
|
+
logger.debug(`sdk._moduleGraph size: ${this._moduleGraph.size()}`, '[SDK.createPackageGraph][start]');
|
|
260
204
|
if (!this._packageGraph) {
|
|
261
|
-
const pkgGraph =
|
|
205
|
+
const pkgGraph = PackageGraph.fromModuleGraph(this._moduleGraph, this.root, (path)=>{
|
|
262
206
|
try {
|
|
263
|
-
const exists =
|
|
264
|
-
if (exists) return
|
|
207
|
+
const exists = File.fse.existsSync(path);
|
|
208
|
+
if (exists) return File.fse.readJSONSync(path);
|
|
265
209
|
} catch (error) {
|
|
266
210
|
const { message, stack } = error;
|
|
267
|
-
|
|
211
|
+
logger.debug(()=>`sdk.createPackageGraph error, path: ${path}, error message: ${stack || message}`, '[SDK.createPackageGraph][error]');
|
|
268
212
|
}
|
|
269
213
|
});
|
|
270
214
|
this._packageGraph = pkgGraph;
|
|
271
|
-
|
|
215
|
+
logger.debug(`sdk._packageGraph packages: ${this._packageGraph.getPackages().length}`, '[SDK.createPackageGraph][end]');
|
|
272
216
|
}
|
|
273
217
|
}
|
|
274
218
|
async writeStore(options) {
|
|
275
219
|
var _this_extraConfig;
|
|
276
|
-
|
|
277
|
-
if ((null == (_this_extraConfig = this.extraConfig) ? void 0 : _this_extraConfig.mode) ===
|
|
220
|
+
logger.debug("sdk.writeStore has run.", '[SDK.writeStore][end]');
|
|
221
|
+
if ((null == (_this_extraConfig = this.extraConfig) ? void 0 : _this_extraConfig.mode) === SDK.IMode[SDK.IMode.brief]) {
|
|
278
222
|
var _this_extraConfig_brief;
|
|
279
223
|
const clientHtmlPath = this.extraConfig.innerClientPath ? this.extraConfig.innerClientPath : require.resolve('@rsdoctor/client');
|
|
280
224
|
if (null == (_this_extraConfig_brief = this.extraConfig.brief) ? void 0 : _this_extraConfig_brief.writeDataJson) await this.saveManifest(this.getStoreData(), options || {});
|
|
@@ -353,7 +297,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
353
297
|
data: Object.keys(dataValue).reduce((t, e)=>{
|
|
354
298
|
const _e = e;
|
|
355
299
|
if (dataValue[_e] && 'object' == typeof dataValue[_e]) t[e] = [
|
|
356
|
-
`${this.server.origin}${
|
|
300
|
+
`${this.server.origin}${SDK.ServerAPI.API.LoadDataByKey}/${e}`
|
|
357
301
|
];
|
|
358
302
|
else t[e] = dataValue[_e];
|
|
359
303
|
return t;
|
|
@@ -383,7 +327,7 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
383
327
|
this.server.broadcast();
|
|
384
328
|
}
|
|
385
329
|
addRsdoctorDataToHTML(storeData, htmlContent) {
|
|
386
|
-
let compressTextScripts = `<script>window.${
|
|
330
|
+
let compressTextScripts = `<script>window.${Constants.WINDOW_RSDOCTOR_TAG}={}</script>`;
|
|
387
331
|
for (let key of Object.keys(storeData)){
|
|
388
332
|
const data = storeData[key];
|
|
389
333
|
const jsonStrFn = ()=>{
|
|
@@ -395,10 +339,10 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
395
339
|
return '';
|
|
396
340
|
}
|
|
397
341
|
};
|
|
398
|
-
const compressText =
|
|
399
|
-
compressTextScripts = `${compressTextScripts} <script>window.${
|
|
342
|
+
const compressText = Algorithm.compressText(jsonStrFn());
|
|
343
|
+
compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.${key}=${JSON.stringify(compressText)}</script>`;
|
|
400
344
|
}
|
|
401
|
-
compressTextScripts = `${compressTextScripts} <script>window.${
|
|
345
|
+
compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.enableRoutes=${JSON.stringify(this.getClientRoutes())}</script>`;
|
|
402
346
|
htmlContent = htmlContent.replace('<body>', `<body>${compressTextScripts}`);
|
|
403
347
|
return htmlContent;
|
|
404
348
|
}
|
|
@@ -406,9 +350,9 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
406
350
|
var _this_extraConfig_brief, _this_extraConfig;
|
|
407
351
|
function inlineScripts(basePath, scripts) {
|
|
408
352
|
return scripts.map((src)=>{
|
|
409
|
-
const scriptPath =
|
|
353
|
+
const scriptPath = path_0.resolve(basePath, src);
|
|
410
354
|
try {
|
|
411
|
-
const scriptContent =
|
|
355
|
+
const scriptContent = fs_extra.readFileSync(scriptPath, 'utf-8');
|
|
412
356
|
return `<script>${scriptContent}</script>`;
|
|
413
357
|
} catch (error) {
|
|
414
358
|
console.error(`Could not read script at ${scriptPath}:`, error);
|
|
@@ -418,9 +362,9 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
418
362
|
}
|
|
419
363
|
function inlineCss(basePath, cssFiles) {
|
|
420
364
|
return cssFiles.map((href)=>{
|
|
421
|
-
const cssPath =
|
|
365
|
+
const cssPath = path_0.resolve(basePath, href);
|
|
422
366
|
try {
|
|
423
|
-
const cssContent =
|
|
367
|
+
const cssContent = fs_extra.readFileSync(cssPath, 'utf-8');
|
|
424
368
|
return `<style>${cssContent}</style>`;
|
|
425
369
|
} catch (error) {
|
|
426
370
|
console.error(`Could not read CSS at ${cssPath}:`, error);
|
|
@@ -428,8 +372,8 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
428
372
|
}
|
|
429
373
|
}).join('');
|
|
430
374
|
}
|
|
431
|
-
let htmlContent =
|
|
432
|
-
const basePath =
|
|
375
|
+
let htmlContent = fs_extra.readFileSync(htmlFilePath, 'utf-8');
|
|
376
|
+
const basePath = path_0.dirname(htmlFilePath);
|
|
433
377
|
const scriptSrcs = Array.from(htmlContent.matchAll(/<script\s+(?:defer="defer"|defer)\s+src=["'](.+?)["']><\/script>/g), (m)=>m[1]);
|
|
434
378
|
const cssHrefs = Array.from(htmlContent.matchAll(/<link\s+href=["'](.+?)["']\s+rel="stylesheet">/g), (m)=>m[1]);
|
|
435
379
|
htmlContent = htmlContent.replace(/<script\s+.*?src=["'].*?["']><\/script>/g, '');
|
|
@@ -439,8 +383,8 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
439
383
|
const index = htmlContent.indexOf('</body>');
|
|
440
384
|
htmlContent = htmlContent.slice(0, index) + inlinedCss + inlinedScripts + htmlContent.slice(index);
|
|
441
385
|
htmlContent = this.addRsdoctorDataToHTML(this.getStoreData(), htmlContent);
|
|
442
|
-
const outputFilePath =
|
|
443
|
-
|
|
386
|
+
const outputFilePath = path_0.resolve(this.outputDir, (null == (_this_extraConfig = this.extraConfig) ? void 0 : null == (_this_extraConfig_brief = _this_extraConfig.brief) ? void 0 : _this_extraConfig_brief.reportHtmlName) || 'rsdoctor-report.html');
|
|
387
|
+
fs_extra.outputFileSync(outputFilePath, htmlContent, {
|
|
444
388
|
encoding: 'utf-8',
|
|
445
389
|
flag: 'w'
|
|
446
390
|
});
|
|
@@ -450,14 +394,14 @@ class RsdoctorSDK extends external_core_mjs_.SDKCore {
|
|
|
450
394
|
var _options_config, _options_config1, _options_config_printLog, _options_config2;
|
|
451
395
|
super(options), this._summary = {
|
|
452
396
|
costs: []
|
|
453
|
-
}, this._configs = [], this._errors = [], this._loader = [], this._loaderStart = [], this._resolver = [], this._plugin = {}, this._moduleGraph = new
|
|
454
|
-
this.server = (null == (_options_config = options.config) ? void 0 : _options_config.noServer) ? new
|
|
397
|
+
}, this._configs = [], this._errors = [], this._loader = [], this._loaderStart = [], this._resolver = [], this._plugin = {}, this._moduleGraph = new ModuleGraph(), this._chunkGraph = new ChunkGraph(), this._rawSourceMapCache = new Map(), this._sourceMap = new Map();
|
|
398
|
+
this.server = (null == (_options_config = options.config) ? void 0 : _options_config.noServer) ? new RsdoctorFakeServer(this, void 0) : new RsdoctorServer(this, options.port, {
|
|
455
399
|
innerClientPath: (null == (_options_config1 = options.config) ? void 0 : _options_config1.innerClientPath) || '',
|
|
456
400
|
printServerUrl: null == (_options_config2 = options.config) ? void 0 : null == (_options_config_printLog = _options_config2.printLog) ? void 0 : _options_config_printLog.serverUrls
|
|
457
401
|
});
|
|
458
|
-
this.type =
|
|
402
|
+
this.type = Lodash.isNumber(options.type) ? options.type : SDK.ToDataType.Normal;
|
|
459
403
|
this.extraConfig = options.config;
|
|
460
|
-
this._root =
|
|
404
|
+
this._root = findRoot() ?? '';
|
|
461
405
|
}
|
|
462
406
|
}
|
|
463
407
|
export { RsdoctorSDK };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/sdk",
|
|
3
|
-
"version": "1.2.2
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"socket.io": "4.8.1",
|
|
28
28
|
"source-map": "^0.7.4",
|
|
29
29
|
"tapable": "2.2.2",
|
|
30
|
-
"@rsdoctor/
|
|
31
|
-
"@rsdoctor/
|
|
32
|
-
"@rsdoctor/
|
|
33
|
-
"@rsdoctor/utils": "1.2.2
|
|
30
|
+
"@rsdoctor/client": "1.2.2",
|
|
31
|
+
"@rsdoctor/types": "1.2.2",
|
|
32
|
+
"@rsdoctor/graph": "1.2.2",
|
|
33
|
+
"@rsdoctor/utils": "1.2.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@rslib/core": "^0.11.0",
|