@modern-js/devtools-kit 2.46.0 → 2.47.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.
package/dist/channel.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var channel_exports = {};
20
30
  __export(channel_exports, {
@@ -24,6 +34,7 @@ __export(channel_exports, {
24
34
  });
25
35
  module.exports = __toCommonJS(channel_exports);
26
36
  var import_nanoid = require("nanoid");
37
+ var flatted = __toESM(require("flatted"));
27
38
  class WebSocketChannel {
28
39
  static link(ws) {
29
40
  return new Promise((resolve, reject) => {
@@ -62,10 +73,12 @@ class WebSocketChannel {
62
73
  this.ws.onmessage = fn;
63
74
  }
64
75
  serialize(data) {
65
- return JSON.stringify(data);
76
+ return flatted.stringify([
77
+ data
78
+ ]);
66
79
  }
67
80
  deserialize(e) {
68
- return JSON.parse(e.data.toString());
81
+ return flatted.parse(e.data.toString())[0];
69
82
  }
70
83
  constructor(ws) {
71
84
  this.ws = ws;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Entrypoint } from '@modern-js/types/cli';
1
+ import type { Entrypoint } from '@modern-js/types';
2
2
  import { FileSystemRoutes } from './server';
3
3
  export interface ClientFunctions {
4
4
  refresh: () => void;
@@ -26,10 +26,15 @@ export declare class AnnouncementDefinition {
26
26
  src: string;
27
27
  fallback: string;
28
28
  }
29
+ export declare class DoctorDefinition {
30
+ home: string;
31
+ quickStart: string;
32
+ }
29
33
  export declare class ClientDefinition {
30
34
  name: NameDefinition;
31
35
  packages: PackageDefinition;
32
36
  assets: AssetDefinition;
37
+ doctor: DoctorDefinition;
33
38
  announcement: AnnouncementDefinition;
34
39
  }
35
40
  export interface IframeTabView {
package/dist/client.js CHANGED
@@ -31,6 +31,7 @@ __export(client_exports, {
31
31
  AnnouncementDefinition: () => AnnouncementDefinition,
32
32
  AssetDefinition: () => AssetDefinition,
33
33
  ClientDefinition: () => ClientDefinition,
34
+ DoctorDefinition: () => DoctorDefinition,
34
35
  NameDefinition: () => NameDefinition,
35
36
  PackageDefinition: () => PackageDefinition
36
37
  });
@@ -59,11 +60,18 @@ class AnnouncementDefinition {
59
60
  this.fallback = "https://modernjs.dev/";
60
61
  }
61
62
  }
63
+ class DoctorDefinition {
64
+ constructor() {
65
+ this.home = "https://rsdoctor.dev";
66
+ this.quickStart = "https://rsdoctor.dev/guide/start/quick-start";
67
+ }
68
+ }
62
69
  class ClientDefinition {
63
70
  constructor() {
64
71
  this.name = new NameDefinition();
65
72
  this.packages = new PackageDefinition();
66
73
  this.assets = new AssetDefinition();
74
+ this.doctor = new DoctorDefinition();
67
75
  this.announcement = new AnnouncementDefinition();
68
76
  }
69
77
  }
@@ -72,6 +80,7 @@ class ClientDefinition {
72
80
  AnnouncementDefinition,
73
81
  AssetDefinition,
74
82
  ClientDefinition,
83
+ DoctorDefinition,
75
84
  NameDefinition,
76
85
  PackageDefinition
77
86
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1 @@
1
- export * from './server';
2
- export * from './client';
3
- export * from './mount-point';
4
- export * from './utils';
5
- export * from './constants';
6
- export * from './channel';
1
+ export * from './node';
package/dist/index.js CHANGED
@@ -15,18 +15,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var src_exports = {};
17
17
  module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./server"), module.exports);
19
- __reExport(src_exports, require("./client"), module.exports);
20
- __reExport(src_exports, require("./mount-point"), module.exports);
21
- __reExport(src_exports, require("./utils"), module.exports);
22
- __reExport(src_exports, require("./constants"), module.exports);
23
- __reExport(src_exports, require("./channel"), module.exports);
18
+ __reExport(src_exports, require("./node"), module.exports);
24
19
  // Annotate the CommonJS export names for ESM import in node:
25
20
  0 && (module.exports = {
26
- ...require("./server"),
27
- ...require("./client"),
28
- ...require("./mount-point"),
29
- ...require("./utils"),
30
- ...require("./constants"),
31
- ...require("./channel")
21
+ ...require("./node")
32
22
  });
package/dist/node.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './server';
2
+ export * from './client';
3
+ export * from './mount-point';
4
+ export * from './utils';
5
+ export * from './constants';
6
+ export * from './channel';
7
+ export * from './rsdoctor';
package/dist/node.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var node_exports = {};
17
+ module.exports = __toCommonJS(node_exports);
18
+ __reExport(node_exports, require("./server"), module.exports);
19
+ __reExport(node_exports, require("./client"), module.exports);
20
+ __reExport(node_exports, require("./mount-point"), module.exports);
21
+ __reExport(node_exports, require("./utils"), module.exports);
22
+ __reExport(node_exports, require("./constants"), module.exports);
23
+ __reExport(node_exports, require("./channel"), module.exports);
24
+ __reExport(node_exports, require("./rsdoctor"), module.exports);
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ ...require("./server"),
28
+ ...require("./client"),
29
+ ...require("./mount-point"),
30
+ ...require("./utils"),
31
+ ...require("./constants"),
32
+ ...require("./channel"),
33
+ ...require("./rsdoctor")
34
+ });
@@ -0,0 +1,7 @@
1
+ import type { Manifest } from '@rsdoctor/types';
2
+ export declare function fetchShardingFile(url: string): Promise<string>;
3
+ export declare function parseManifest(json: Manifest.RsdoctorManifestWithShardingFiles): Promise<Manifest.RsdoctorManifest>;
4
+ /**
5
+ * @throws {Error} Cannot find manifest.json in ${rootPath}
6
+ */
7
+ export declare function findManifest(dirname: string, silent?: boolean): Promise<string>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var rsdoctor_exports = {};
30
+ __export(rsdoctor_exports, {
31
+ fetchShardingFile: () => fetchShardingFile,
32
+ findManifest: () => findManifest,
33
+ parseManifest: () => parseManifest
34
+ });
35
+ module.exports = __toCommonJS(rsdoctor_exports);
36
+ var import_path = __toESM(require("path"));
37
+ var import_fs_extra = __toESM(require("@modern-js/utils/fs-extra"));
38
+ var utils = __toESM(require("@rsdoctor/utils/common"));
39
+ async function fetchShardingFile(url) {
40
+ const { Url } = await Promise.resolve().then(() => __toESM(require("@rsdoctor/utils/common")));
41
+ if (Url.isUrl(url)) {
42
+ const resp = await fetch(url);
43
+ return resp.text();
44
+ }
45
+ return url;
46
+ }
47
+ async function parseManifest(json) {
48
+ if ("cloudManifestUrl" in json && "cloudData" in json) {
49
+ try {
50
+ const data2 = await utils.Manifest.fetchShardingFiles(json.data, fetchShardingFile);
51
+ return {
52
+ ...json,
53
+ data: data2
54
+ };
55
+ } catch (err) {
56
+ console.error(err);
57
+ }
58
+ }
59
+ const data = await utils.Manifest.fetchShardingFiles(json.data, (url) => import_fs_extra.default.readFile(url, "utf-8"));
60
+ return {
61
+ ...json,
62
+ data
63
+ };
64
+ }
65
+ const MANIFEST_DIRS = [
66
+ ".rsdoctor",
67
+ ".web-doctor"
68
+ ];
69
+ const MANIFEST_NAME = "manifest.json";
70
+ async function findManifest(dirname, silent = false) {
71
+ for (const dir of MANIFEST_DIRS) {
72
+ const manifestPath = import_path.default.resolve(dirname, dir, MANIFEST_NAME);
73
+ if (import_fs_extra.default.existsSync(manifestPath)) {
74
+ return manifestPath;
75
+ }
76
+ }
77
+ if (silent) {
78
+ return "";
79
+ } else {
80
+ throw new Error(`Cannot find manifest.json in ${dirname}`);
81
+ }
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ fetchShardingFile,
86
+ findManifest,
87
+ parseManifest
88
+ });
@@ -0,0 +1,7 @@
1
+ export type * from './server';
2
+ export * from './client';
3
+ export * from './mount-point';
4
+ export * from './utils';
5
+ export * from './constants';
6
+ export * from './channel';
7
+ export type * from './rsdoctor';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var runtime_exports = {};
17
+ module.exports = __toCommonJS(runtime_exports);
18
+ __reExport(runtime_exports, require("./client"), module.exports);
19
+ __reExport(runtime_exports, require("./mount-point"), module.exports);
20
+ __reExport(runtime_exports, require("./utils"), module.exports);
21
+ __reExport(runtime_exports, require("./constants"), module.exports);
22
+ __reExport(runtime_exports, require("./channel"), module.exports);
23
+ // Annotate the CommonJS export names for ESM import in node:
24
+ 0 && (module.exports = {
25
+ ...require("./client"),
26
+ ...require("./mount-point"),
27
+ ...require("./utils"),
28
+ ...require("./constants"),
29
+ ...require("./channel")
30
+ });
package/dist/server.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { AppTools, IAppContext, UserConfig } from '@modern-js/app-tools';
2
2
  import type { RsbuildContext, NormalizedConfig as NormalizedBuilderConfig, RsbuildConfig, webpack, Rspack, WebpackConfig, RspackConfig } from '@modern-js/uni-builder';
3
3
  import { NormalizedConfig } from '@modern-js/core';
4
- import { RouteLegacy, NestedRouteForCli, PageRoute } from '@modern-js/types/cli';
4
+ import { RouteLegacy, NestedRouteForCli, PageRoute } from '@modern-js/types';
5
+ import type { Manifest } from '@rsdoctor/types';
5
6
  import type { ClientDefinition } from './client';
6
7
  export type BuilderContext = RsbuildContext;
7
8
  export type FrameworkConfig = UserConfig<AppTools>;
@@ -13,6 +14,13 @@ export type BundlerConfig = WebpackConfig | RspackConfig;
13
14
  export type Compiler = webpack.Compiler | Rspack.Compiler | webpack.MultiCompiler | Rspack.MultiCompiler;
14
15
  export type AppContext = Omit<IAppContext, 'builder' | 'serverInternalPlugins'>;
15
16
  export type FileSystemRoutes = RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
17
+ export interface DoctorManifestOverview {
18
+ numModules: number;
19
+ numChunks: number;
20
+ numPackages: number;
21
+ summary: Manifest.RsdoctorManifest['data']['summary'];
22
+ errors: Manifest.RsdoctorManifest['data']['errors'];
23
+ }
16
24
  export interface ServerFunctions {
17
25
  getFrameworkConfig: () => Promise<FrameworkConfig>;
18
26
  getTransformedFrameworkConfig: () => Promise<TransformedFrameworkConfig>;
@@ -26,5 +34,6 @@ export interface ServerFunctions {
26
34
  getDependencies: () => Promise<Record<string, string>>;
27
35
  getCompileTimeCost: () => Promise<number>;
28
36
  getClientDefinition: () => Promise<ClientDefinition>;
37
+ getDoctorOverview: () => Promise<DoctorManifestOverview>;
29
38
  echo: (content: string) => string;
30
39
  }
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "modern",
22
22
  "modern.js"
23
23
  ],
24
- "version": "2.46.0",
24
+ "version": "2.47.0",
25
25
  "jsnext:source": "./src/index.ts",
26
26
  "types": "./dist/index.d.ts",
27
27
  "main": "./dist/index.js",
@@ -32,9 +32,14 @@
32
32
  "default": "./dist/index.js"
33
33
  },
34
34
  "./runtime": {
35
- "jsnext:source": "./src/runtime/index.ts",
36
- "types": "./dist/runtime/index.d.ts",
37
- "default": "./dist/runtime/index.js"
35
+ "jsnext:source": "./src/runtime.ts",
36
+ "types": "./dist/runtime.d.ts",
37
+ "default": "./dist/runtime.js"
38
+ },
39
+ "./node": {
40
+ "jsnext:source": "./src/node.ts",
41
+ "types": "./dist/node.d.ts",
42
+ "default": "./dist/node.js"
38
43
  },
39
44
  "./package.json": {
40
45
  "default": "./package.json"
@@ -43,7 +48,10 @@
43
48
  "typesVersions": {
44
49
  "*": {
45
50
  "runtime": [
46
- "./dist/runtime/index.d.ts"
51
+ "./dist/runtime.d.ts"
52
+ ],
53
+ "node": [
54
+ "./dist/node.d.ts"
47
55
  ]
48
56
  }
49
57
  },
@@ -51,9 +59,12 @@
51
59
  "birpc": "0.2.13",
52
60
  "hookable": "^5.5.3",
53
61
  "ufo": "^1.3.0",
62
+ "flatted": "^3.2.9",
54
63
  "ws": "^8.13.0",
55
- "@modern-js/types": "2.46.0",
56
- "@modern-js/utils": "2.46.0"
64
+ "@rsdoctor/types": "^0.1.3",
65
+ "@rsdoctor/utils": "^0.1.3",
66
+ "@modern-js/types": "2.47.0",
67
+ "@modern-js/utils": "2.47.0"
57
68
  },
58
69
  "devDependencies": {
59
70
  "@babel/core": "^7.23.2",
@@ -68,13 +79,13 @@
68
79
  "react": "~18.2.0",
69
80
  "type-fest": "^4.1.0",
70
81
  "typescript": "^5",
71
- "@modern-js/app-tools": "2.46.0",
72
- "@modern-js/core": "2.46.0",
73
- "@modern-js/types": "2.46.0",
74
- "@modern-js/uni-builder": "2.46.0",
75
- "@modern-js/module-tools": "2.46.0",
76
- "@scripts/jest-config": "2.46.0",
77
- "@scripts/build": "2.46.0"
82
+ "@modern-js/app-tools": "2.47.0",
83
+ "@modern-js/module-tools": "2.47.0",
84
+ "@modern-js/types": "2.47.0",
85
+ "@modern-js/core": "2.47.0",
86
+ "@scripts/build": "2.47.0",
87
+ "@modern-js/uni-builder": "2.47.0",
88
+ "@scripts/jest-config": "2.47.0"
78
89
  },
79
90
  "peerDependencies": {
80
91
  "react": "~18.2.0"