@rsdoctor/sdk 0.4.8 → 0.4.9

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.
@@ -1,5 +1,466 @@
1
- export * from "./webpack";
2
- import { RsdoctorWebpackSDK } from "./webpack";
1
+ import fse from "fs-extra";
2
+ import path from "path";
3
+ import { DevToolError } from "@rsdoctor/utils/error";
4
+ import { Constants, SDK } from "@rsdoctor/types";
5
+ import { File } from "@rsdoctor/utils/build";
6
+ import { SourceMapConsumer } from "source-map";
7
+ import { ModuleGraph, ChunkGraph, PackageGraph } from "@rsdoctor/graph";
8
+ import { debug } from "@rsdoctor/utils/logger";
9
+ import { RsdoctorServer } from "../server";
10
+ import { RsdoctorFakeServer } from "../server/fakeServer";
11
+ import { SDKCore } from "./core";
12
+ import { Algorithm } from "@rsdoctor/utils/common";
13
+ import { isNumber } from "lodash";
14
+ export * from "../utils/openBrowser";
15
+ class RsdoctorSDK extends SDKCore {
16
+ constructor(options) {
17
+ super(options);
18
+ this._summary = { costs: [] };
19
+ this._configs = [];
20
+ this._errors = [];
21
+ this._loader = [];
22
+ this._loaderStart = [];
23
+ this._resolver = [];
24
+ this._plugin = {};
25
+ this._moduleGraph = new ModuleGraph();
26
+ this._chunkGraph = new ChunkGraph();
27
+ this._rawSourceMapCache = /* @__PURE__ */ new Map();
28
+ this._sourceMap = /* @__PURE__ */ new Map();
29
+ this.server = options.config?.noServer ? new RsdoctorFakeServer(this, void 0) : new RsdoctorServer(this, options.port, {
30
+ innerClientPath: options.config?.innerClientPath || "",
31
+ printServerUrl: options.config?.printLog?.serverUrls
32
+ });
33
+ this.type = isNumber(options.type) ? options.type : SDK.ToDataType.Normal;
34
+ this.extraConfig = options.config;
35
+ }
36
+ async bootstrap() {
37
+ debug(() => `${Date.now()}`, "[RsdoctorSDK][bootstrap start]");
38
+ this.server && await this.server.bootstrap();
39
+ await super.bootstrap();
40
+ debug(
41
+ () => `${Date.now()} ${this.server.origin}`,
42
+ "[RsdoctorSDK][bootstrap end]"
43
+ );
44
+ }
45
+ async dispose() {
46
+ debug(() => `${Date.now()}`, "[RsdoctorSDK][dispose start]");
47
+ this.server && await this.server.dispose();
48
+ await super.dispose();
49
+ debug(() => `${Date.now()}`, "[RsdoctorSDK][dispose end]");
50
+ }
51
+ async applyErrorFix(id) {
52
+ const { _errors: errors } = this;
53
+ const error = errors.find((err) => err.id === id);
54
+ if (!error || !error.path || !error.fixData || error.fixData.isFixed) {
55
+ return;
56
+ }
57
+ const { path: filePath, fixData } = error;
58
+ const sameFileErrors = errors.filter(
59
+ (item) => item.path === filePath && item !== error
60
+ );
61
+ let content = (await File.fse.readFile(filePath, "utf-8")).toString();
62
+ const startTxt = content.substring(0, fixData.start);
63
+ const endTxt = content.substring(fixData.end, content.length);
64
+ const offset = (fixData.newText ?? "").length - (fixData.end - fixData.start);
65
+ content = startTxt + fixData.newText + endTxt;
66
+ for (const other of sameFileErrors) {
67
+ const { fixData: otherFixData } = other;
68
+ if (!otherFixData) {
69
+ continue;
70
+ }
71
+ if (otherFixData.start >= fixData.end) {
72
+ otherFixData.start += offset;
73
+ otherFixData.end += offset;
74
+ }
75
+ }
76
+ await File.fse.writeFile(filePath, content);
77
+ }
78
+ clear() {
79
+ this._errors = [];
80
+ this._loader = [];
81
+ this._resolver = [];
82
+ this._plugin = {};
83
+ this._moduleGraph = new ModuleGraph();
84
+ this._chunkGraph = new ChunkGraph();
85
+ }
86
+ clearSourceMapCache() {
87
+ this._rawSourceMapCache = /* @__PURE__ */ new Map();
88
+ this._sourceMap = /* @__PURE__ */ new Map();
89
+ }
90
+ async getSourceMap(file) {
91
+ const { _sourceMap: sourceMap, _rawSourceMapCache: rawMap } = this;
92
+ if (sourceMap.has(file)) {
93
+ return sourceMap.get(file);
94
+ }
95
+ const rawData = rawMap.get(file);
96
+ if (!rawData || rawData.version < 0 || !rawData.sourcesContent?.[0] || !rawData.mappings) {
97
+ return Promise.resolve(void 0);
98
+ }
99
+ try {
100
+ const result = await new SourceMapConsumer(rawData);
101
+ sourceMap.set(file, result);
102
+ return result;
103
+ } catch (e) {
104
+ return Promise.resolve(void 0);
105
+ }
106
+ }
107
+ reportSourceMap(data) {
108
+ this._rawSourceMapCache.set(data.file, data);
109
+ }
110
+ reportConfiguration(config) {
111
+ this._configs.push(config);
112
+ this.onDataReport();
113
+ }
114
+ reportError(errors) {
115
+ errors.forEach((item) => {
116
+ this._errors.push(
117
+ DevToolError.from(item, {
118
+ code: this.name
119
+ })
120
+ );
121
+ });
122
+ this.onDataReport();
123
+ }
124
+ reportLoader(data) {
125
+ data.forEach((item) => {
126
+ if (this.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) {
127
+ item.loaders.forEach((_loader) => {
128
+ _loader.input = "";
129
+ _loader.result = "";
130
+ });
131
+ }
132
+ let match = this._loader.find(
133
+ (e) => e.resource.path === item.resource.path
134
+ );
135
+ if (match) {
136
+ match.loaders.push(...item.loaders);
137
+ } else {
138
+ match = item;
139
+ this._loader.push(item);
140
+ }
141
+ match.loaders.sort((a, b) => {
142
+ if (a.startAt !== b.startAt) {
143
+ return a.startAt - b.startAt;
144
+ }
145
+ if (a.isPitch) {
146
+ if (b.isPitch) {
147
+ return a.loaderIndex - b.loaderIndex;
148
+ }
149
+ return -1;
150
+ }
151
+ if (b.isPitch) {
152
+ return 1;
153
+ }
154
+ return b.loaderIndex - a.loaderIndex;
155
+ });
156
+ });
157
+ this.onDataReport();
158
+ }
159
+ reportLoaderStartOrEnd(data) {
160
+ const _builtinLoader = data.loaders[0];
161
+ if (_builtinLoader.startAt) {
162
+ this._loaderStart.push(data);
163
+ } else if (_builtinLoader.endAt) {
164
+ const matchLoaderStart = this._loaderStart.find(
165
+ (e) => e.resource.path === data.resource.path && e.loaders[0].loader === _builtinLoader.loader
166
+ );
167
+ if (matchLoaderStart) {
168
+ matchLoaderStart.loaders[0].result = _builtinLoader.result;
169
+ matchLoaderStart.loaders[0].endAt = _builtinLoader.endAt;
170
+ this.reportLoader([matchLoaderStart]);
171
+ }
172
+ }
173
+ }
174
+ reportResolver(data) {
175
+ data.forEach((item) => this._resolver.push(item));
176
+ this.onDataReport();
177
+ }
178
+ reportPlugin(data) {
179
+ Object.keys(data).forEach((hook) => {
180
+ if (!this._plugin[hook]) {
181
+ this._plugin[hook] = data[hook];
182
+ } else {
183
+ data[hook].forEach((item) => {
184
+ this._plugin[hook].push(item);
185
+ });
186
+ }
187
+ });
188
+ this.onDataReport();
189
+ }
190
+ reportModuleGraph(data) {
191
+ debug(() => `data size: ${data.size()}`, "[SDK.reportModuleGraph][start]");
192
+ this._moduleGraph.fromInstance(data);
193
+ this.createPackageGraph();
194
+ this.onDataReport();
195
+ debug(
196
+ () => `sdk._moduleGraph size: ${this._moduleGraph.size()}`,
197
+ "[SDK reportModuleGraph][end]"
198
+ );
199
+ }
200
+ reportPackageGraph(data) {
201
+ debug(() => "[SDK.reportPackageGraph][start]");
202
+ if (!this._packageGraph) {
203
+ this._packageGraph = data;
204
+ }
205
+ this.onDataReport();
206
+ debug(
207
+ () => `sdk._moduleGraph size: ${this._moduleGraph.size()}`,
208
+ "[SDK reportPackageGraph][end]"
209
+ );
210
+ }
211
+ reportChunkGraph(data) {
212
+ this._chunkGraph.addAsset(...data.getAssets());
213
+ this._chunkGraph.addChunk(...data.getChunks());
214
+ this._chunkGraph.addEntryPoint(...data.getEntryPoints());
215
+ this.onDataReport();
216
+ }
217
+ reportSummaryData(part) {
218
+ const keys = ["costs"];
219
+ for (const key of keys) {
220
+ const v = part[key];
221
+ if (!v)
222
+ continue;
223
+ if (typeof v === "object") {
224
+ if (Array.isArray(v)) {
225
+ this._summary[key] = [
226
+ ...this._summary[key] || [],
227
+ ...v
228
+ ];
229
+ } else {
230
+ this._summary[key] = {
231
+ ...this._summary[key] || {},
232
+ ...v
233
+ };
234
+ }
235
+ } else {
236
+ this._summary[key] = v;
237
+ }
238
+ }
239
+ this.onDataReport();
240
+ }
241
+ reportTileHtml(tileReportHtml) {
242
+ this._tileReportHtml = tileReportHtml;
243
+ }
244
+ createPackageGraph() {
245
+ debug(
246
+ () => `sdk._moduleGraph size: ${this._moduleGraph.size()}`,
247
+ "[SDK.createPackageGraph][start]"
248
+ );
249
+ if (!this._packageGraph) {
250
+ const pkgGraph = PackageGraph.fromModuleGraph(
251
+ this._moduleGraph,
252
+ this.root,
253
+ (path2) => {
254
+ try {
255
+ const exists = File.fse.existsSync(path2);
256
+ if (exists) {
257
+ debug(
258
+ () => `sdk.PackageGraph package.json exists: ${exists}, path: ${path2}`,
259
+ "[SDK.createPackageGraph][load]"
260
+ );
261
+ return File.fse.readJSONSync(path2);
262
+ }
263
+ } catch (error) {
264
+ const { message, stack } = error;
265
+ debug(
266
+ () => `sdk.createPackageGraph error, path: ${path2}, error message: ${stack || message}`,
267
+ "[SDK.createPackageGraph][error]"
268
+ );
269
+ }
270
+ }
271
+ );
272
+ this._packageGraph = pkgGraph;
273
+ debug(
274
+ () => `sdk._packageGraph packages: ${this._packageGraph.getPackages().length}`,
275
+ "[SDK.createPackageGraph][end]"
276
+ );
277
+ }
278
+ }
279
+ async writeStore(options) {
280
+ debug(() => `sdk.writeStore has run.`, "[SDK.writeStore][end]");
281
+ if (this.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) {
282
+ const clientHtmlPath = this.extraConfig.innerClientPath ? this.extraConfig.innerClientPath : require.resolve("@rsdoctor/client");
283
+ if (this.extraConfig.brief?.writeDataJson) {
284
+ await this.saveManifest(this.getStoreData(), options || {});
285
+ }
286
+ return this.inlineScriptsAndStyles(clientHtmlPath);
287
+ }
288
+ return this.saveManifest(this.getStoreData(), options || {});
289
+ }
290
+ getStoreData() {
291
+ const ctx = this;
292
+ return {
293
+ get hash() {
294
+ return ctx.hash;
295
+ },
296
+ get root() {
297
+ return ctx.root;
298
+ },
299
+ get envinfo() {
300
+ return ctx._envinfo;
301
+ },
302
+ get pid() {
303
+ return ctx.pid;
304
+ },
305
+ get errors() {
306
+ return ctx._errors.map((err) => err.toData());
307
+ },
308
+ get configs() {
309
+ return ctx._configs.slice();
310
+ },
311
+ get summary() {
312
+ return { ...ctx._summary };
313
+ },
314
+ get resolver() {
315
+ return ctx._resolver.slice();
316
+ },
317
+ get loader() {
318
+ return ctx._loader.slice();
319
+ },
320
+ get moduleGraph() {
321
+ return ctx._moduleGraph.toData({
322
+ contextPath: ctx._configs?.[0]?.config?.context || ""
323
+ });
324
+ },
325
+ get chunkGraph() {
326
+ return ctx._chunkGraph.toData(ctx.type);
327
+ },
328
+ get moduleCodeMap() {
329
+ return ctx._moduleGraph.toCodeData(ctx.type);
330
+ },
331
+ get plugin() {
332
+ return { ...ctx._plugin };
333
+ },
334
+ get packageGraph() {
335
+ return ctx._packageGraph ? ctx._packageGraph.toData() : {
336
+ packages: [],
337
+ dependencies: []
338
+ };
339
+ },
340
+ get otherReports() {
341
+ return { tileReportHtml: ctx._tileReportHtml || "" };
342
+ }
343
+ };
344
+ }
345
+ getManifestData() {
346
+ const dataValue = this.getStoreData();
347
+ const data = {
348
+ client: {
349
+ enableRoutes: this.getClientRoutes()
350
+ },
351
+ data: Object.keys(dataValue).reduce((t, e) => {
352
+ const _e = e;
353
+ if (dataValue[_e] && typeof dataValue[_e] === "object") {
354
+ t[e] = [
355
+ `${this.server.origin}${SDK.ServerAPI.API.LoadDataByKey}/${e}`
356
+ ];
357
+ } else {
358
+ t[e] = dataValue[_e];
359
+ }
360
+ return t;
361
+ }, {}),
362
+ __LOCAL__SERVER__: true,
363
+ __SOCKET__PORT__: this.server.socketUrl.port.toString(),
364
+ __SOCKET__URL__: this.server.socketUrl.socketUrl
365
+ };
366
+ return data;
367
+ }
368
+ getRuleContext(_options) {
369
+ this.createPackageGraph();
370
+ return {
371
+ root: this.root,
372
+ errors: this._errors.slice(),
373
+ configs: this._configs.slice(),
374
+ moduleGraph: this._moduleGraph,
375
+ chunkGraph: this._chunkGraph,
376
+ packageGraph: this._packageGraph,
377
+ loader: this._loader.slice(),
378
+ otherReports: { tileReportHtml: this._tileReportHtml || "" }
379
+ };
380
+ }
381
+ onDataReport() {
382
+ this.server.broadcast();
383
+ }
384
+ addRsdoctorDataToHTML(storeData, htmlContent) {
385
+ let compressTextScripts = `<script>window.${Constants.WINDOW_RSDOCTOR_TAG}={}</script>`;
386
+ for (let key of Object.keys(storeData)) {
387
+ const data = storeData[key];
388
+ const jsonStrFn = () => {
389
+ try {
390
+ return JSON.stringify(data);
391
+ } catch (error) {
392
+ console.error(error);
393
+ return "";
394
+ }
395
+ };
396
+ const compressText = Algorithm.compressText(jsonStrFn());
397
+ compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.${key}=${JSON.stringify(compressText)}</script>`;
398
+ }
399
+ compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.enableRoutes=${JSON.stringify(this.getClientRoutes())}</script>`;
400
+ htmlContent = htmlContent.replace("<body>", `<body>${compressTextScripts}`);
401
+ return htmlContent;
402
+ }
403
+ inlineScriptsAndStyles(htmlFilePath) {
404
+ function inlineScripts(basePath2, scripts) {
405
+ return scripts.map((src) => {
406
+ const scriptPath = path.resolve(basePath2, src);
407
+ try {
408
+ const scriptContent = fse.readFileSync(scriptPath, "utf-8");
409
+ return `<script>${scriptContent}</script>`;
410
+ } catch (error) {
411
+ console.error(`Could not read script at ${scriptPath}:`, error);
412
+ return "";
413
+ }
414
+ }).join("");
415
+ }
416
+ function inlineCss(basePath2, cssFiles) {
417
+ return cssFiles.map((href) => {
418
+ const cssPath = path.resolve(basePath2, href);
419
+ try {
420
+ const cssContent = fse.readFileSync(cssPath, "utf-8");
421
+ return `<style>${cssContent}</style>`;
422
+ } catch (error) {
423
+ console.error(`Could not read CSS at ${cssPath}:`, error);
424
+ return "";
425
+ }
426
+ }).join("");
427
+ }
428
+ let htmlContent = fse.readFileSync(htmlFilePath, "utf-8");
429
+ const basePath = path.dirname(htmlFilePath);
430
+ const scriptSrcs = Array.from(
431
+ htmlContent.matchAll(
432
+ /<script\s+(?:defer="defer"|defer)\s+src=["'](.+?)["']><\/script>/g
433
+ ),
434
+ (m) => m[1]
435
+ );
436
+ const cssHrefs = Array.from(
437
+ htmlContent.matchAll(/<link\s+href=["'](.+?)["']\s+rel="stylesheet">/g),
438
+ (m) => m[1]
439
+ );
440
+ htmlContent = htmlContent.replace(
441
+ /<script\s+.*?src=["'].*?["']><\/script>/g,
442
+ ""
443
+ );
444
+ htmlContent = htmlContent.replace(
445
+ /<link\s+.*?rel=["']stylesheet["'].*?>/g,
446
+ ""
447
+ );
448
+ const inlinedScripts = inlineScripts(basePath, scriptSrcs);
449
+ const inlinedCss = inlineCss(basePath, cssHrefs);
450
+ const index = htmlContent.indexOf("</body>");
451
+ htmlContent = htmlContent.slice(0, index) + inlinedCss + inlinedScripts + htmlContent.slice(index);
452
+ htmlContent = this.addRsdoctorDataToHTML(this.getStoreData(), htmlContent);
453
+ const outputFilePath = path.resolve(
454
+ this.outputDir,
455
+ this.extraConfig?.brief?.reportHtmlName || "rsdoctor-report.html"
456
+ );
457
+ fse.outputFileSync(outputFilePath, htmlContent, {
458
+ encoding: "utf-8",
459
+ flag: "w"
460
+ });
461
+ return outputFilePath;
462
+ }
463
+ }
3
464
  export {
4
- RsdoctorWebpackSDK as RsdoctorSDK
465
+ RsdoctorSDK
5
466
  };
@@ -1,13 +1,13 @@
1
1
  import { Manifest } from '@rsdoctor/types';
2
- import { RsdoctorSlaveSDK } from './slave';
2
+ import { RsdoctorPrimarySDK } from './slave';
3
3
  export declare class RsdoctorSDKController {
4
- readonly slaves: RsdoctorSlaveSDK[];
4
+ readonly slaves: RsdoctorPrimarySDK[];
5
5
  root: string;
6
6
  constructor(root?: string);
7
- get master(): RsdoctorSlaveSDK;
8
- getLastSdk(): RsdoctorSlaveSDK;
7
+ get master(): RsdoctorPrimarySDK;
8
+ getLastSdk(): RsdoctorPrimarySDK;
9
9
  hasName(name: string): boolean;
10
10
  getSeriesData(serverUrl?: boolean): Manifest.RsdoctorManifestSeriesData[];
11
- createSlave({ name, stage, extraConfig, }: Omit<ConstructorParameters<typeof RsdoctorSlaveSDK>[0], 'controller'>): RsdoctorSlaveSDK;
11
+ createSlave({ name, stage, extraConfig, }: Omit<ConstructorParameters<typeof RsdoctorPrimarySDK>[0], 'controller'>): RsdoctorPrimarySDK;
12
12
  }
13
13
  //# sourceMappingURL=controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAM;IAElC,IAAI,SAAM;gBAEL,IAAI,SAAgB;IAIhC,IAAI,MAAM,qBAET;IAED,UAAU;IAIV,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,aAAa,CAAC,SAAS,UAAQ;IAgB/B,WAAW,CAAC,EACV,IAAI,EACJ,KAAK,EACL,WAAW,GACZ,EAAE,IAAI,CAAC,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;CAYzE"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAM;IAEpC,IAAI,SAAM;gBAEL,IAAI,SAAgB;IAIhC,IAAI,MAAM,uBAET;IAED,UAAU;IAIV,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,aAAa,CAAC,SAAS,UAAQ;IAgB/B,WAAW,CAAC,EACV,IAAI,EACJ,KAAK,EACL,WAAW,GACZ,EAAE,IAAI,CAAC,qBAAqB,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;CAY3E"}
@@ -1,8 +1,8 @@
1
1
  import { RsdoctorServer } from '../server';
2
- import type { RsdoctorSlaveSDK } from './slave';
2
+ import type { RsdoctorPrimarySDK } from './slave';
3
3
  export declare class RsdoctorSlaveServer extends RsdoctorServer {
4
- protected sdk: RsdoctorSlaveSDK;
5
- constructor(sdk: RsdoctorSlaveSDK, port?: number);
4
+ protected sdk: RsdoctorPrimarySDK;
5
+ constructor(sdk: RsdoctorPrimarySDK, port?: number);
6
6
  openClientPage(...args: unknown[]): Promise<void>;
7
7
  }
8
8
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,GAAG,EAAE,gBAAgB,CAAC;gBAEpB,GAAG,EAAE,gBAAgB,EAAE,IAAI,SAAqB;IAKtD,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;CAOxC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,GAAG,EAAE,kBAAkB,CAAC;gBAEtB,GAAG,EAAE,kBAAkB,EAAE,IAAI,SAAqB;IAKxD,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;CAOxC"}
@@ -1,5 +1,5 @@
1
1
  import { SDK } from '@rsdoctor/types';
2
- import { RsdoctorWebpackSDK } from '../sdk';
2
+ import { RsdoctorSDK } from '../sdk';
3
3
  import type { RsdoctorSDKController } from './controller';
4
4
  interface RsdoctorSlaveSDKOptions {
5
5
  name: string;
@@ -12,7 +12,7 @@ interface RsdoctorSlaveSDKOptions {
12
12
  extraConfig?: SDK.SDKOptionsType;
13
13
  controller: RsdoctorSDKController;
14
14
  }
15
- export declare class RsdoctorSlaveSDK extends RsdoctorWebpackSDK {
15
+ export declare class RsdoctorPrimarySDK extends RsdoctorSDK {
16
16
  id: number;
17
17
  parent: RsdoctorSDKController;
18
18
  readonly stage: number;
@@ -1 +1 @@
1
- {"version":3,"file":"slave.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/slave.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAI1D,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC;IACjC,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAED,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,EAAE,EAAE,MAAM,CAAC;IAEX,MAAM,EAAE,qBAAqB,CAAC;IAE9B,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,OAAO,CAAC,YAAY,CAAiB;IAErC,OAAO,CAAC,uBAAuB,CAAc;gBAEjC,EACV,IAAI,EACJ,KAAK,EACL,UAAU,EACV,WAAW,GACZ,EAAE,uBAAuB;IAe1B,OAAO,CAAC,WAAW;IAMnB,IAAI,QAAQ,YAEX;cAEe,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;cAe5B,aAAa;IAe7B,aAAa,CAAC,SAAS,UAAQ;IAI/B,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,eAAe;CAMhB"}
1
+ {"version":3,"file":"slave.d.ts","sourceRoot":"","sources":["../../../../src/sdk/multiple/slave.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAI1D,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC;IACjC,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAED,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,EAAE,EAAE,MAAM,CAAC;IAEX,MAAM,EAAE,qBAAqB,CAAC;IAE9B,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,OAAO,CAAC,YAAY,CAAiB;IAErC,OAAO,CAAC,uBAAuB,CAAc;gBAEjC,EACV,IAAI,EACJ,KAAK,EACL,UAAU,EACV,WAAW,GACZ,EAAE,uBAAuB;IAe1B,OAAO,CAAC,WAAW;IAMnB,IAAI,QAAQ,YAEX;cAEe,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;cAe5B,aAAa;IAe7B,aAAa,CAAC,SAAS,UAAQ;IAI/B,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,eAAe;CAMhB"}
@@ -1,3 +1,53 @@
1
- export * from './webpack';
2
- export { RsdoctorWebpackSDK as RsdoctorSDK } from './webpack';
1
+ import { Manifest, SDK } from '@rsdoctor/types';
2
+ import { RawSourceMap, SourceMapConsumer } from 'source-map';
3
+ import { ModuleGraph, ChunkGraph, PackageGraph } from '@rsdoctor/graph';
4
+ import { RsdoctorServer } from '../server';
5
+ import { RsdoctorWebpackSDKOptions } from './types';
6
+ import { SDKCore } from './core';
7
+ export * from '../utils/openBrowser';
8
+ export declare class RsdoctorSDK<T extends RsdoctorWebpackSDKOptions = RsdoctorWebpackSDKOptions> extends SDKCore<T> implements SDK.RsdoctorBuilderSDKInstance {
9
+ server: RsdoctorServer;
10
+ extraConfig: SDK.SDKOptionsType | undefined;
11
+ private type;
12
+ private _summary;
13
+ private _configs;
14
+ private _errors;
15
+ private _loader;
16
+ private _loaderStart;
17
+ private _resolver;
18
+ private _plugin;
19
+ private _moduleGraph;
20
+ private _chunkGraph;
21
+ private _rawSourceMapCache;
22
+ private _sourceMap;
23
+ private _packageGraph;
24
+ private _tileReportHtml;
25
+ constructor(options: T);
26
+ bootstrap(): Promise<void>;
27
+ dispose(): Promise<void>;
28
+ applyErrorFix(id: number): Promise<void>;
29
+ clear(): void;
30
+ clearSourceMapCache(): void;
31
+ getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
32
+ reportSourceMap(data: RawSourceMap): void;
33
+ reportConfiguration(config: SDK.ConfigData[0]): void;
34
+ reportError(errors: Error[]): void;
35
+ reportLoader(data: SDK.LoaderData): void;
36
+ reportLoaderStartOrEnd(data: SDK.ResourceLoaderData): void;
37
+ reportResolver(data: SDK.ResolverData): void;
38
+ reportPlugin(data: SDK.PluginData): void;
39
+ reportModuleGraph(data: ModuleGraph): void;
40
+ reportPackageGraph(data: PackageGraph): void;
41
+ reportChunkGraph(data: ChunkGraph): void;
42
+ reportSummaryData(part: Partial<SDK.SummaryData>): void;
43
+ reportTileHtml(tileReportHtml: string): void;
44
+ createPackageGraph(): void;
45
+ writeStore(options?: SDK.WriteStoreOptionsType): Promise<string>;
46
+ getStoreData(): SDK.BuilderStoreData;
47
+ getManifestData(): Manifest.RsdoctorManifestWithShardingFiles;
48
+ getRuleContext(_options: SDK.RuntimeContextOptions): SDK.RuntimeContext;
49
+ onDataReport(): void | Promise<void>;
50
+ addRsdoctorDataToHTML(storeData: SDK.BuilderStoreData, htmlContent: string): string;
51
+ inlineScriptsAndStyles(htmlFilePath: string): string;
52
+ }
3
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sdk/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,kBAAkB,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sdk/sdk/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,QAAQ,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAIjC,cAAc,sBAAsB,CAAC;AAErC,qBAAa,WAAW,CACpB,CAAC,SAAS,yBAAyB,GAAG,yBAAyB,CAEjE,SAAQ,OAAO,CAAC,CAAC,CACjB,YAAW,GAAG,CAAC,0BAA0B;IAElC,MAAM,EAAE,cAAc,CAAC;IAEvB,WAAW,EAAE,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;IAEnD,OAAO,CAAC,IAAI,CAAiB;IAE7B,OAAO,CAAC,QAAQ,CAAkC;IAElD,OAAO,CAAC,QAAQ,CAAsB;IAEtC,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,SAAS,CAAwB;IAEzC,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,YAAY,CAAqB;IAEzC,OAAO,CAAC,WAAW,CAAoB;IAEvC,OAAO,CAAC,kBAAkB,CAAmC;IAE7D,OAAO,CAAC,UAAU,CAAwC;IAE1D,OAAO,CAAC,aAAa,CAA4B;IAEjD,OAAO,CAAC,eAAe,CAAqB;gBAEhC,OAAO,EAAE,CAAC;IAYhB,SAAS;IAUT,OAAO;IAOP,aAAa,CAAC,EAAE,EAAE,MAAM;IA0C9B,KAAK;IASL,mBAAmB,IAAI,IAAI;IAKrB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA6BxE,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAIzC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAK7C,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE;IAW3B,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU;IA6CjC,sBAAsB,CAAC,IAAI,EAAE,GAAG,CAAC,kBAAkB;IAoBnD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,GAAG,IAAI;IAK5C,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,GAAG,IAAI;IAaxC,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAW1C,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAY5C,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAOxC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI;IA0BvD,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAI5C,kBAAkB;IA2CL,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,qBAAqB;IAepD,YAAY,IAAI,GAAG,CAAC,gBAAgB;IA2DpC,eAAe,IAAI,QAAQ,CAAC,iCAAiC;IA0B7D,cAAc,CACnB,QAAQ,EAAE,GAAG,CAAC,qBAAqB,GAClC,GAAG,CAAC,cAAc;IAed,YAAY,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,qBAAqB,CAC1B,SAAS,EAAE,GAAG,CAAC,gBAAgB,EAC/B,WAAW,EAAE,MAAM;IAyBd,sBAAsB,CAAC,YAAY,EAAE,MAAM;CAuFnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/sdk",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -26,15 +26,15 @@
26
26
  "socket.io": "4.7.2",
27
27
  "source-map": "^0.7.4",
28
28
  "tapable": "2.2.1",
29
- "@rsdoctor/client": "0.4.8",
30
- "@rsdoctor/graph": "0.4.8",
31
- "@rsdoctor/types": "0.4.8",
32
- "@rsdoctor/utils": "0.4.8"
29
+ "@rsdoctor/client": "0.4.9",
30
+ "@rsdoctor/graph": "0.4.9",
31
+ "@rsdoctor/types": "0.4.9",
32
+ "@rsdoctor/utils": "0.4.9"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/body-parser": "1.19.5",
36
36
  "@types/cors": "2.8.17",
37
- "@types/lodash": "^4.17.10",
37
+ "@types/lodash": "^4.17.13",
38
38
  "@types/node": "^16",
39
39
  "@types/serve-static": "1.15.7",
40
40
  "tslib": "2.7.0",