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