@modern-js/plugin-devtools 0.0.0-next-20230920182238 → 0.0.0-next-20230921090041
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/cli.d.ts +2 -6
- package/dist/cli.js +56 -23
- package/dist/config.d.ts +12 -0
- package/dist/config.js +31 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -3
- package/dist/rpc/index.d.ts +3 -4
- package/dist/rpc/index.js +6 -10
- package/dist/runtime.js +2 -1
- package/package.json +20 -16
package/dist/cli.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export interface Options extends SetupClientOptions {
|
|
5
|
-
rpcPath?: string;
|
|
6
|
-
def?: PartialDeep<ClientDefinition>;
|
|
7
|
-
}
|
|
2
|
+
import { Options } from './config';
|
|
3
|
+
export type { Options };
|
|
8
4
|
export declare const devtoolsPlugin: (options?: Options) => CliPlugin<AppTools>;
|
|
9
5
|
export default devtoolsPlugin;
|
package/dist/cli.js
CHANGED
|
@@ -18,61 +18,94 @@ _export(exports, {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
-
const
|
|
21
|
+
const _http = /* @__PURE__ */ _interop_require_default._(require("http"));
|
|
22
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
23
|
+
const _utils = require("@modern-js/utils");
|
|
24
|
+
const _servestatic = /* @__PURE__ */ _interop_require_default._(require("serve-static"));
|
|
22
25
|
const _devtoolskit = require("@modern-js/devtools-kit");
|
|
26
|
+
const _ufo = require("ufo");
|
|
27
|
+
const _config = require("./config");
|
|
23
28
|
const _rpc = require("./rpc");
|
|
24
|
-
const
|
|
25
|
-
rpcPath: "/_modern_js/devtools/rpc",
|
|
26
|
-
def: new _devtoolskit.ClientDefinition()
|
|
27
|
-
});
|
|
29
|
+
const _socket = require("./utils/socket");
|
|
28
30
|
const devtoolsPlugin = (options) => ({
|
|
29
31
|
name: "@modern-js/plugin-devtools",
|
|
30
32
|
usePlugins: [],
|
|
31
33
|
setup: async (api) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const port = await (0, _utils.getPort)(8782, {
|
|
35
|
+
slient: true
|
|
36
|
+
});
|
|
37
|
+
const clientServeDir = _path.default.resolve(require.resolve("@modern-js/devtools-client/package.json"), "../dist");
|
|
38
|
+
const serveMiddleware = (0, _servestatic.default)(clientServeDir);
|
|
39
|
+
const httpServer = _http.default.createServer((req, res) => {
|
|
40
|
+
const usePageNotFound = () => {
|
|
41
|
+
res.write("404");
|
|
42
|
+
res.statusCode = 404;
|
|
43
|
+
res.end();
|
|
44
|
+
};
|
|
45
|
+
const useMainRoute = () => {
|
|
46
|
+
req.url = "/html/main/index.html";
|
|
47
|
+
serveMiddleware(req, res, usePageNotFound);
|
|
48
|
+
};
|
|
49
|
+
serveMiddleware(req, res, useMainRoute);
|
|
50
|
+
});
|
|
51
|
+
httpServer.listen(port);
|
|
52
|
+
const socketServer = new _socket.SocketServer({
|
|
53
|
+
server: httpServer,
|
|
54
|
+
path: "/rpc"
|
|
55
|
+
});
|
|
56
|
+
const rpc = await (0, _rpc.setupClientConnection)({
|
|
39
57
|
api,
|
|
40
|
-
|
|
58
|
+
server: socketServer
|
|
41
59
|
});
|
|
42
60
|
return {
|
|
43
|
-
prepare: hooks.prepare,
|
|
44
|
-
modifyFileSystemRoutes: hooks.modifyFileSystemRoutes,
|
|
61
|
+
prepare: rpc.hooks.prepare,
|
|
62
|
+
modifyFileSystemRoutes: rpc.hooks.modifyFileSystemRoutes,
|
|
45
63
|
validateSchema() {
|
|
46
64
|
return [
|
|
47
65
|
{
|
|
48
|
-
target: "
|
|
66
|
+
target: "devtools",
|
|
49
67
|
schema: {
|
|
50
68
|
typeof: [
|
|
51
|
-
"boolean"
|
|
69
|
+
"boolean",
|
|
70
|
+
"object"
|
|
52
71
|
]
|
|
53
72
|
}
|
|
54
73
|
}
|
|
55
74
|
];
|
|
56
75
|
},
|
|
76
|
+
beforeRestart() {
|
|
77
|
+
return new Promise((resolve, reject) => httpServer.close((err) => err ? reject(err) : resolve()));
|
|
78
|
+
},
|
|
57
79
|
config() {
|
|
80
|
+
const opts = (0, _config.resolveOptions)(api, options);
|
|
81
|
+
opts.def && rpc.setDefinition(opts.def);
|
|
82
|
+
const mountOpts = {
|
|
83
|
+
dataSource: `/_modern_js/devtools/rpc`,
|
|
84
|
+
endpoint: `/_modern_js/devtools`,
|
|
85
|
+
__keep: true
|
|
86
|
+
};
|
|
87
|
+
let runtimeEntry = require.resolve("@modern-js/plugin-devtools/runtime");
|
|
88
|
+
runtimeEntry = (0, _ufo.withQuery)(runtimeEntry, mountOpts);
|
|
58
89
|
return {
|
|
59
90
|
builderPlugins: [
|
|
60
|
-
builderPlugin
|
|
91
|
+
rpc.builderPlugin
|
|
61
92
|
],
|
|
62
93
|
source: {
|
|
63
94
|
preEntry: [
|
|
64
|
-
|
|
95
|
+
runtimeEntry
|
|
65
96
|
],
|
|
66
97
|
globalVars: {
|
|
67
|
-
"process.env.
|
|
98
|
+
"process.env._MODERN_DEVTOOLS_LOGO_SRC": new _devtoolskit.ClientDefinition().assets.logo
|
|
68
99
|
}
|
|
69
100
|
},
|
|
70
101
|
tools: {
|
|
71
102
|
devServer: {
|
|
72
103
|
proxy: {
|
|
73
|
-
|
|
74
|
-
target:
|
|
75
|
-
|
|
104
|
+
"/_modern_js/devtools": {
|
|
105
|
+
target: `http://localhost:${port}`,
|
|
106
|
+
pathRewrite: {
|
|
107
|
+
"^/_modern_js/devtools": ""
|
|
108
|
+
},
|
|
76
109
|
ws: true
|
|
77
110
|
}
|
|
78
111
|
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClientDefinition } from '@modern-js/devtools-kit';
|
|
2
|
+
import { PartialDeep } from 'type-fest';
|
|
3
|
+
import { CliPluginAPI } from './types';
|
|
4
|
+
export interface Options {
|
|
5
|
+
def?: PartialDeep<ClientDefinition>;
|
|
6
|
+
}
|
|
7
|
+
export declare const getDefaultOptions: () => {
|
|
8
|
+
def: ClientDefinition;
|
|
9
|
+
};
|
|
10
|
+
export declare const resolveOptions: (api: CliPluginAPI, options?: Options) => Options & {
|
|
11
|
+
def: ClientDefinition;
|
|
12
|
+
};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
getDefaultOptions: function() {
|
|
14
|
+
return getDefaultOptions;
|
|
15
|
+
},
|
|
16
|
+
resolveOptions: function() {
|
|
17
|
+
return resolveOptions;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
+
const _devtoolskit = require("@modern-js/devtools-kit");
|
|
22
|
+
const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
|
|
23
|
+
const getDefaultOptions = () => ({
|
|
24
|
+
// prefix: '/_modern_js/devtools',
|
|
25
|
+
def: new _devtoolskit.ClientDefinition()
|
|
26
|
+
});
|
|
27
|
+
const resolveOptions = (api, options = {}) => {
|
|
28
|
+
const config = api.useConfigContext();
|
|
29
|
+
const opts = _lodash.default.defaultsDeep({}, options, config.devtools, getDefaultOptions());
|
|
30
|
+
return opts;
|
|
31
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export default devtoolsPlugin;
|
|
1
|
+
export { devtoolsPlugin, default } from './cli';
|
|
2
|
+
export type { Options } from './cli';
|
package/dist/index.js
CHANGED
|
@@ -14,8 +14,8 @@ _export(exports, {
|
|
|
14
14
|
return _cli.devtoolsPlugin;
|
|
15
15
|
},
|
|
16
16
|
default: function() {
|
|
17
|
-
return
|
|
17
|
+
return _cli.default;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
21
|
+
const _cli = /* @__PURE__ */ _interop_require_wildcard._(require("./cli"));
|
package/dist/rpc/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { URL } from 'url';
|
|
3
1
|
import { type ClientDefinition, type ClientFunctions, type ServerFunctions } from '@modern-js/devtools-kit';
|
|
4
2
|
import type { PartialDeep } from 'type-fest';
|
|
5
3
|
import type { BuilderPlugin } from '@modern-js/builder-shared';
|
|
6
4
|
import { CliPluginAPI, BuilderPluginAPI, InjectedHooks } from '../types';
|
|
5
|
+
import { SocketServer } from '../utils/socket';
|
|
7
6
|
export interface SetupClientConnectionOptions {
|
|
8
7
|
api: CliPluginAPI;
|
|
9
|
-
|
|
8
|
+
server: SocketServer;
|
|
10
9
|
}
|
|
11
10
|
export declare const setupClientConnection: (options: SetupClientConnectionOptions) => Promise<{
|
|
12
11
|
client: import("birpc").BirpcReturn<ClientFunctions, ServerFunctions>;
|
|
13
12
|
hooks: InjectedHooks;
|
|
14
13
|
builderPlugin: BuilderPlugin<BuilderPluginAPI>;
|
|
15
|
-
|
|
14
|
+
setDefinition: (definition: PartialDeep<ClientDefinition>) => void;
|
|
16
15
|
}>;
|
package/dist/rpc/index.js
CHANGED
|
@@ -9,21 +9,17 @@ Object.defineProperty(exports, "setupClientConnection", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
-
const _url = require("url");
|
|
13
12
|
const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
|
|
14
13
|
const _devtoolskit = require("@modern-js/devtools-kit");
|
|
15
14
|
const _birpc = require("birpc");
|
|
16
15
|
const _pdefer = /* @__PURE__ */ _interop_require_default._(require("p-defer"));
|
|
17
|
-
const _utils = require("@modern-js/utils");
|
|
18
|
-
const _socket = require("../utils/socket");
|
|
19
16
|
const _module = require("../utils/module");
|
|
20
17
|
const setupClientConnection = async (options) => {
|
|
21
|
-
const { api,
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const url = new _url.URL(`ws://localhost:${port}`);
|
|
18
|
+
const { api, server } = options;
|
|
19
|
+
let def = {};
|
|
20
|
+
const setDefinition = (definition) => {
|
|
21
|
+
def = definition;
|
|
22
|
+
};
|
|
27
23
|
const _fileSystemRoutesMap = {};
|
|
28
24
|
let handleMessage = null;
|
|
29
25
|
const onceConnection = new Promise((resolve) => {
|
|
@@ -197,6 +193,6 @@ const setupClientConnection = async (options) => {
|
|
|
197
193
|
client: clientConn,
|
|
198
194
|
hooks,
|
|
199
195
|
builderPlugin,
|
|
200
|
-
|
|
196
|
+
setDefinition
|
|
201
197
|
};
|
|
202
198
|
};
|
package/dist/runtime.js
CHANGED
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _devtoolsmount = require("@modern-js/devtools-mount");
|
|
6
|
-
const
|
|
6
|
+
const _ufo = require("ufo");
|
|
7
|
+
const opts = (0, _ufo.parseQuery)(__resourceQuery);
|
|
7
8
|
(0, _devtoolsmount.mountDevTools)(opts);
|
package/package.json
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-next-
|
|
18
|
+
"version": "0.0.0-next-20230921090041",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
|
-
"main": "./dist/
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"node": {
|
|
@@ -38,31 +38,35 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"birpc": "0.2.13",
|
|
41
|
+
"serve-static": "^1.14.1",
|
|
41
42
|
"p-defer": "^3.0.0",
|
|
42
43
|
"ws": "8.13.0",
|
|
43
|
-
"
|
|
44
|
-
"@modern-js/devtools-
|
|
45
|
-
"@modern-js/
|
|
44
|
+
"ufo": "^1.3.0",
|
|
45
|
+
"@modern-js/devtools-kit": "0.0.0-next-20230921090041",
|
|
46
|
+
"@modern-js/devtools-mount": "0.0.0-next-20230921090041",
|
|
47
|
+
"@modern-js/devtools-client": "0.0.0-next-20230921090041",
|
|
48
|
+
"@modern-js/utils": "0.0.0-next-20230921090041"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
51
|
+
"@types/serve-static": "^1.13.10",
|
|
48
52
|
"@swc/helpers": "0.5.1",
|
|
49
53
|
"@types/node": "^14",
|
|
50
54
|
"@types/ws": "^8.5.5",
|
|
51
55
|
"type-fest": "^4.1.0",
|
|
52
56
|
"typescript": "^5",
|
|
53
|
-
"@modern-js/app-tools": "0.0.0-next-
|
|
54
|
-
"@modern-js/
|
|
55
|
-
"@modern-js/
|
|
56
|
-
"@modern-js/runtime": "0.0.0-next-
|
|
57
|
-
"@modern-js/server-core": "0.0.0-next-
|
|
58
|
-
"@modern-js/types": "0.0.0-next-
|
|
59
|
-
"@modern-js/builder-
|
|
60
|
-
"@modern-js/builder-
|
|
61
|
-
"@modern-js/builder-
|
|
62
|
-
"@scripts/build": "0.0.0-next-
|
|
57
|
+
"@modern-js/app-tools": "0.0.0-next-20230921090041",
|
|
58
|
+
"@modern-js/core": "0.0.0-next-20230921090041",
|
|
59
|
+
"@modern-js/module-tools": "0.0.0-next-20230921090041",
|
|
60
|
+
"@modern-js/runtime": "0.0.0-next-20230921090041",
|
|
61
|
+
"@modern-js/server-core": "0.0.0-next-20230921090041",
|
|
62
|
+
"@modern-js/types": "0.0.0-next-20230921090041",
|
|
63
|
+
"@modern-js/builder-webpack-provider": "0.0.0-next-20230921090041",
|
|
64
|
+
"@modern-js/builder-rspack-provider": "0.0.0-next-20230921090041",
|
|
65
|
+
"@modern-js/builder-shared": "0.0.0-next-20230921090041",
|
|
66
|
+
"@scripts/build": "0.0.0-next-20230921090041"
|
|
63
67
|
},
|
|
64
68
|
"peerDependencies": {
|
|
65
|
-
"@modern-js/runtime": "0.0.0-next-
|
|
69
|
+
"@modern-js/runtime": "0.0.0-next-20230921090041"
|
|
66
70
|
},
|
|
67
71
|
"peerDependenciesMeta": {
|
|
68
72
|
"@modern-js/runtime": {
|