@modern-js/plugin-devtools 2.35.0 → 2.36.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/cli.d.ts +2 -6
- package/dist/cli.js +93 -42
- package/dist/config.d.ts +12 -0
- package/dist/config.js +49 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +35 -17
- package/dist/rpc/index.d.ts +3 -4
- package/dist/rpc/index.js +66 -47
- package/dist/runtime.js +4 -6
- package/dist/types.js +15 -3
- package/dist/utils/module.js +46 -28
- package/dist/utils/socket.js +37 -11
- package/package.json +21 -17
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
@@ -1,78 +1,125 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
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) => {
|
6
9
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return devtoolsPlugin;
|
15
|
-
},
|
16
|
-
default: function() {
|
17
|
-
return _default;
|
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 });
|
18
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 cli_exports = {};
|
30
|
+
__export(cli_exports, {
|
31
|
+
default: () => cli_default,
|
32
|
+
devtoolsPlugin: () => devtoolsPlugin
|
19
33
|
});
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
module.exports = __toCommonJS(cli_exports);
|
35
|
+
var import_http = __toESM(require("http"));
|
36
|
+
var import_path = __toESM(require("path"));
|
37
|
+
var import_utils = require("@modern-js/utils");
|
38
|
+
var import_serve_static = __toESM(require("serve-static"));
|
39
|
+
var import_devtools_kit = require("@modern-js/devtools-kit");
|
40
|
+
var import_ufo = require("ufo");
|
41
|
+
var import_config = require("./config");
|
42
|
+
var import_rpc = require("./rpc");
|
43
|
+
var import_socket = require("./utils/socket");
|
28
44
|
const devtoolsPlugin = (options) => ({
|
29
45
|
name: "@modern-js/plugin-devtools",
|
30
46
|
usePlugins: [],
|
31
47
|
setup: async (api) => {
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
const port = await (0, import_utils.getPort)(8782, {
|
49
|
+
slient: true
|
50
|
+
});
|
51
|
+
const clientServeDir = import_path.default.resolve(require.resolve("@modern-js/devtools-client/package.json"), "../dist");
|
52
|
+
const serveMiddleware = (0, import_serve_static.default)(clientServeDir);
|
53
|
+
const httpServer = import_http.default.createServer((req, res) => {
|
54
|
+
const usePageNotFound = () => {
|
55
|
+
res.write("404");
|
56
|
+
res.statusCode = 404;
|
57
|
+
res.end();
|
58
|
+
};
|
59
|
+
const useMainRoute = () => {
|
60
|
+
req.url = "/html/main/index.html";
|
61
|
+
serveMiddleware(req, res, usePageNotFound);
|
62
|
+
};
|
63
|
+
serveMiddleware(req, res, useMainRoute);
|
64
|
+
});
|
65
|
+
httpServer.listen(port);
|
66
|
+
const socketServer = new import_socket.SocketServer({
|
67
|
+
server: httpServer,
|
68
|
+
path: "/rpc"
|
69
|
+
});
|
70
|
+
const rpc = await (0, import_rpc.setupClientConnection)({
|
39
71
|
api,
|
40
|
-
|
72
|
+
server: socketServer
|
41
73
|
});
|
42
74
|
return {
|
43
|
-
prepare: hooks.prepare,
|
44
|
-
modifyFileSystemRoutes: hooks.modifyFileSystemRoutes,
|
75
|
+
prepare: rpc.hooks.prepare,
|
76
|
+
modifyFileSystemRoutes: rpc.hooks.modifyFileSystemRoutes,
|
45
77
|
validateSchema() {
|
46
78
|
return [
|
47
79
|
{
|
48
|
-
target: "
|
80
|
+
target: "devtools",
|
49
81
|
schema: {
|
50
82
|
typeof: [
|
51
|
-
"boolean"
|
83
|
+
"boolean",
|
84
|
+
"object"
|
52
85
|
]
|
53
86
|
}
|
54
87
|
}
|
55
88
|
];
|
56
89
|
},
|
90
|
+
beforeRestart() {
|
91
|
+
return new Promise((resolve, reject) => httpServer.close((err) => err ? reject(err) : resolve()));
|
92
|
+
},
|
57
93
|
config() {
|
94
|
+
const opts = (0, import_config.resolveOptions)(api, options);
|
95
|
+
opts.def && rpc.setDefinition(opts.def);
|
96
|
+
const mountOpts = {
|
97
|
+
dataSource: `${import_devtools_kit.ROUTE_BASENAME}/rpc`,
|
98
|
+
endpoint: import_devtools_kit.ROUTE_BASENAME,
|
99
|
+
__keep: true
|
100
|
+
};
|
101
|
+
let runtimeEntry = require.resolve("@modern-js/plugin-devtools/runtime");
|
102
|
+
runtimeEntry = (0, import_ufo.withQuery)(runtimeEntry, mountOpts);
|
58
103
|
return {
|
59
104
|
builderPlugins: [
|
60
|
-
builderPlugin
|
105
|
+
rpc.builderPlugin
|
61
106
|
],
|
62
107
|
source: {
|
63
108
|
preEntry: [
|
64
|
-
|
109
|
+
runtimeEntry
|
65
110
|
],
|
66
111
|
globalVars: {
|
67
|
-
"process.env.
|
112
|
+
"process.env._MODERN_DEVTOOLS_LOGO_SRC": new import_devtools_kit.ClientDefinition().assets.logo
|
68
113
|
}
|
69
114
|
},
|
70
115
|
tools: {
|
71
116
|
devServer: {
|
72
117
|
proxy: {
|
73
|
-
[
|
74
|
-
target:
|
75
|
-
|
118
|
+
[import_devtools_kit.ROUTE_BASENAME]: {
|
119
|
+
target: `http://localhost:${port}`,
|
120
|
+
pathRewrite: {
|
121
|
+
[`^${import_devtools_kit.ROUTE_BASENAME}`]: ""
|
122
|
+
},
|
76
123
|
ws: true
|
77
124
|
}
|
78
125
|
}
|
@@ -83,4 +130,8 @@ const devtoolsPlugin = (options) => ({
|
|
83
130
|
};
|
84
131
|
}
|
85
132
|
});
|
86
|
-
|
133
|
+
var cli_default = devtoolsPlugin;
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
135
|
+
0 && (module.exports = {
|
136
|
+
devtoolsPlugin
|
137
|
+
});
|
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,49 @@
|
|
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 config_exports = {};
|
30
|
+
__export(config_exports, {
|
31
|
+
getDefaultOptions: () => getDefaultOptions,
|
32
|
+
resolveOptions: () => resolveOptions
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(config_exports);
|
35
|
+
var import_devtools_kit = require("@modern-js/devtools-kit");
|
36
|
+
var import_lodash = __toESM(require("@modern-js/utils/lodash"));
|
37
|
+
const getDefaultOptions = () => ({
|
38
|
+
def: new import_devtools_kit.ClientDefinition()
|
39
|
+
});
|
40
|
+
const resolveOptions = (api, options = {}) => {
|
41
|
+
const config = api.useConfigContext();
|
42
|
+
const opts = import_lodash.default.defaultsDeep({}, options, config.devtools, getDefaultOptions());
|
43
|
+
return opts;
|
44
|
+
};
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
46
|
+
0 && (module.exports = {
|
47
|
+
getDefaultOptions,
|
48
|
+
resolveOptions
|
49
|
+
});
|
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
@@ -1,21 +1,39 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
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) => {
|
6
9
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return _cli.devtoolsPlugin;
|
15
|
-
},
|
16
|
-
default: function() {
|
17
|
-
return _default;
|
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 });
|
18
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 src_exports = {};
|
30
|
+
__export(src_exports, {
|
31
|
+
default: () => import_cli.default,
|
32
|
+
devtoolsPlugin: () => import_cli.devtoolsPlugin
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
35
|
+
var import_cli = __toESM(require("./cli"));
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
37
|
+
0 && (module.exports = {
|
38
|
+
devtoolsPlugin
|
19
39
|
});
|
20
|
-
const _cli = require("./cli");
|
21
|
-
const _default = _cli.devtoolsPlugin;
|
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
@@ -1,56 +1,71 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
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 });
|
9
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 rpc_exports = {};
|
30
|
+
__export(rpc_exports, {
|
31
|
+
setupClientConnection: () => setupClientConnection
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
const _utils = require("@modern-js/utils");
|
18
|
-
const _socket = require("../utils/socket");
|
19
|
-
const _module = require("../utils/module");
|
33
|
+
module.exports = __toCommonJS(rpc_exports);
|
34
|
+
var import_lodash = __toESM(require("@modern-js/utils/lodash"));
|
35
|
+
var import_devtools_kit = require("@modern-js/devtools-kit");
|
36
|
+
var import_birpc = require("birpc");
|
37
|
+
var import_p_defer = __toESM(require("p-defer"));
|
38
|
+
var import_module = require("../utils/module");
|
20
39
|
const setupClientConnection = async (options) => {
|
21
|
-
const { api,
|
22
|
-
|
23
|
-
const
|
24
|
-
|
25
|
-
}
|
26
|
-
const url = new _url.URL(`ws://localhost:${port}`);
|
40
|
+
const { api, server } = options;
|
41
|
+
let def = {};
|
42
|
+
const setDefinition = (definition) => {
|
43
|
+
def = definition;
|
44
|
+
};
|
27
45
|
const _fileSystemRoutesMap = {};
|
28
46
|
let handleMessage = null;
|
29
47
|
const onceConnection = new Promise((resolve) => {
|
30
48
|
server.on("connection", (ws) => {
|
31
49
|
resolve();
|
32
|
-
ws.on("message", (data, isBinary) =>
|
33
|
-
var _handleMessage;
|
34
|
-
return (_handleMessage = handleMessage) === null || _handleMessage === void 0 ? void 0 : _handleMessage(data, isBinary);
|
35
|
-
});
|
50
|
+
ws.on("message", (data, isBinary) => handleMessage === null || handleMessage === void 0 ? void 0 : handleMessage(data, isBinary));
|
36
51
|
});
|
37
52
|
});
|
38
53
|
const deferred = {
|
39
|
-
prepare: (0,
|
54
|
+
prepare: (0, import_p_defer.default)(),
|
40
55
|
builder: {
|
41
|
-
context: (0,
|
56
|
+
context: (0, import_p_defer.default)(),
|
42
57
|
config: {
|
43
|
-
resolved: (0,
|
44
|
-
transformed: (0,
|
58
|
+
resolved: (0, import_p_defer.default)(),
|
59
|
+
transformed: (0, import_p_defer.default)()
|
45
60
|
}
|
46
61
|
},
|
47
62
|
bundler: {
|
48
63
|
config: {
|
49
|
-
resolved: (0,
|
50
|
-
transformed: (0,
|
64
|
+
resolved: (0, import_p_defer.default)(),
|
65
|
+
transformed: (0, import_p_defer.default)()
|
51
66
|
}
|
52
67
|
},
|
53
|
-
compileTimeCost: (0,
|
68
|
+
compileTimeCost: (0, import_p_defer.default)()
|
54
69
|
};
|
55
70
|
const serverFunctions = {
|
56
71
|
async getFrameworkConfig() {
|
@@ -78,7 +93,7 @@ const setupClientConnection = async (options) => {
|
|
78
93
|
const ctx = {
|
79
94
|
...api.useAppContext()
|
80
95
|
};
|
81
|
-
return
|
96
|
+
return import_lodash.default.omit(ctx, [
|
82
97
|
"builder",
|
83
98
|
"serverInternalPlugins"
|
84
99
|
]);
|
@@ -121,7 +136,7 @@ const setupClientConnection = async (options) => {
|
|
121
136
|
};
|
122
137
|
for (const [name, expr] of Object.entries(resolveExprs)) {
|
123
138
|
try {
|
124
|
-
ret[name] = (0,
|
139
|
+
ret[name] = (0, import_module.requireModule)(expr).version;
|
125
140
|
} catch {
|
126
141
|
}
|
127
142
|
}
|
@@ -132,9 +147,9 @@ const setupClientConnection = async (options) => {
|
|
132
147
|
},
|
133
148
|
async getClientDefinition() {
|
134
149
|
const ret = {
|
135
|
-
name: new
|
136
|
-
packages: new
|
137
|
-
assets: new
|
150
|
+
name: new import_devtools_kit.NameDefinition(),
|
151
|
+
packages: new import_devtools_kit.PackageDefinition(),
|
152
|
+
assets: new import_devtools_kit.AssetDefinition()
|
138
153
|
};
|
139
154
|
Object.assign(ret.name, def.name);
|
140
155
|
Object.assign(ret.packages, def.packages);
|
@@ -151,13 +166,13 @@ const setupClientConnection = async (options) => {
|
|
151
166
|
serialize: (v) => JSON.stringify(v),
|
152
167
|
deserialize: (v) => JSON.parse(v.toString())
|
153
168
|
};
|
154
|
-
const clientConn = (0,
|
169
|
+
const clientConn = (0, import_birpc.createBirpc)(serverFunctions, clientRpcOptions);
|
155
170
|
const hooks = {
|
156
171
|
prepare() {
|
157
172
|
deferred.prepare.resolve();
|
158
173
|
},
|
159
174
|
modifyFileSystemRoutes({ entrypoint, routes }) {
|
160
|
-
_fileSystemRoutesMap[entrypoint.entryName] =
|
175
|
+
_fileSystemRoutesMap[entrypoint.entryName] = import_lodash.default.cloneDeep(routes);
|
161
176
|
return {
|
162
177
|
entrypoint,
|
163
178
|
routes
|
@@ -167,22 +182,22 @@ const setupClientConnection = async (options) => {
|
|
167
182
|
const builderPlugin = {
|
168
183
|
name: "builder-plugin-devtools",
|
169
184
|
setup(api2) {
|
170
|
-
deferred.builder.context.resolve(
|
185
|
+
deferred.builder.context.resolve(import_lodash.default.cloneDeep(api2.context));
|
171
186
|
api2.modifyBundlerChain(() => {
|
172
|
-
deferred.builder.config.resolved.resolve(
|
173
|
-
deferred.builder.config.transformed.resolve(
|
187
|
+
deferred.builder.config.resolved.resolve(import_lodash.default.cloneDeep(api2.getBuilderConfig()));
|
188
|
+
deferred.builder.config.transformed.resolve(import_lodash.default.cloneDeep(api2.getNormalizedConfig()));
|
174
189
|
});
|
175
190
|
const modifyBundlerConfig = "modifyWebpackConfig" in api2 ? api2.modifyWebpackConfig : api2.modifyRspackConfig;
|
176
|
-
const expectBundlerNum =
|
191
|
+
const expectBundlerNum = import_lodash.default.castArray(api2.context.target).length;
|
177
192
|
const bundlerConfigs = [];
|
178
193
|
modifyBundlerConfig((config) => {
|
179
194
|
bundlerConfigs.push(config);
|
180
195
|
if (bundlerConfigs.length >= expectBundlerNum) {
|
181
|
-
deferred.bundler.config.resolved.resolve(
|
196
|
+
deferred.bundler.config.resolved.resolve(import_lodash.default.cloneDeep(bundlerConfigs));
|
182
197
|
}
|
183
198
|
});
|
184
199
|
api2.onBeforeCreateCompiler(({ bundlerConfigs: bundlerConfigs2 }) => {
|
185
|
-
deferred.bundler.config.transformed.resolve(
|
200
|
+
deferred.bundler.config.transformed.resolve(import_lodash.default.cloneDeep(bundlerConfigs2));
|
186
201
|
});
|
187
202
|
let buildStartedAt = NaN;
|
188
203
|
api2.onAfterCreateCompiler(() => {
|
@@ -200,6 +215,10 @@ const setupClientConnection = async (options) => {
|
|
200
215
|
client: clientConn,
|
201
216
|
hooks,
|
202
217
|
builderPlugin,
|
203
|
-
|
218
|
+
setDefinition
|
204
219
|
};
|
205
220
|
};
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
222
|
+
0 && (module.exports = {
|
223
|
+
setupClientConnection
|
224
|
+
});
|
package/dist/runtime.js
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const opts = process.env.__MODERN_DEVTOOLS_MOUNT_OPTIONS;
|
7
|
-
(0, _devtoolsmount.mountDevTools)(opts);
|
2
|
+
var import_devtools_mount = require("@modern-js/devtools-mount");
|
3
|
+
var import_ufo = require("ufo");
|
4
|
+
const opts = (0, import_ufo.parseQuery)(__resourceQuery);
|
5
|
+
(0, import_devtools_mount.mountDevTools)(opts);
|
package/dist/types.js
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var types_exports = {};
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/utils/module.js
CHANGED
@@ -1,29 +1,41 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
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) => {
|
6
9
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return getRequire;
|
15
|
-
},
|
16
|
-
resolveModule: function() {
|
17
|
-
return resolveModule;
|
18
|
-
},
|
19
|
-
requireModule: function() {
|
20
|
-
return requireModule;
|
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 });
|
21
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 module_exports = {};
|
30
|
+
__export(module_exports, {
|
31
|
+
getRequire: () => getRequire,
|
32
|
+
requireModule: () => requireModule,
|
33
|
+
resolveModule: () => resolveModule
|
22
34
|
});
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
35
|
+
module.exports = __toCommonJS(module_exports);
|
36
|
+
var import_assert = __toESM(require("assert"));
|
37
|
+
var import_module = __toESM(require("module"));
|
38
|
+
var import_path = __toESM(require("path"));
|
27
39
|
const getRequire = () => {
|
28
40
|
var _stack_split__match, _stack;
|
29
41
|
try {
|
@@ -32,10 +44,10 @@ const getRequire = () => {
|
|
32
44
|
}
|
33
45
|
const issuer = (_stack = new Error().stack) === null || _stack === void 0 ? void 0 : (_stack_split__match = _stack.split("\n")[2].match(/\s*at .+? \((.*)\)$/)) === null || _stack_split__match === void 0 ? void 0 : _stack_split__match[1];
|
34
46
|
console.log("issuer: ", issuer);
|
35
|
-
if (issuer &&
|
36
|
-
return
|
47
|
+
if (issuer && import_path.default.isAbsolute(issuer)) {
|
48
|
+
return import_module.default.createRequire(issuer);
|
37
49
|
} else {
|
38
|
-
return
|
50
|
+
return import_module.default.createRequire(process.cwd());
|
39
51
|
}
|
40
52
|
};
|
41
53
|
const resolveModule = (id) => {
|
@@ -45,7 +57,7 @@ const resolveModule = (id) => {
|
|
45
57
|
const _require = getRequire();
|
46
58
|
let resolved = process.cwd();
|
47
59
|
for (const id2 of exprs) {
|
48
|
-
if (
|
60
|
+
if (import_path.default.isAbsolute(id2)) {
|
49
61
|
resolved = id2;
|
50
62
|
continue;
|
51
63
|
}
|
@@ -63,10 +75,10 @@ const resolveModule = (id) => {
|
|
63
75
|
resolved,
|
64
76
|
pkgName
|
65
77
|
]);
|
66
|
-
(0,
|
78
|
+
(0, import_assert.default)(resolvedMain);
|
67
79
|
const resolveDir = `${resolvedMain.slice(0, resolvedMain.lastIndexOf(`/node_modules/${pkgName}`) + 1)}/node_modules/${pkgName}`;
|
68
80
|
const subpath = expr.replace(pkgName, ".");
|
69
|
-
return resolveModule(
|
81
|
+
return resolveModule(import_path.default.resolve(resolveDir, subpath));
|
70
82
|
}
|
71
83
|
const stackText = JSON.stringify(exprs, null, 2);
|
72
84
|
const err = new Error(`Failed to resolve "${id2}" from "${resolved}": ${stackText}`);
|
@@ -84,3 +96,9 @@ const requireModule = (id) => {
|
|
84
96
|
const _require = getRequire();
|
85
97
|
return _require(resolved);
|
86
98
|
};
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
100
|
+
0 && (module.exports = {
|
101
|
+
getRequire,
|
102
|
+
requireModule,
|
103
|
+
resolveModule
|
104
|
+
});
|
package/dist/utils/socket.js
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
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 });
|
9
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 socket_exports = {};
|
30
|
+
__export(socket_exports, {
|
31
|
+
SocketServer: () => SocketServer
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
class SocketServer extends
|
33
|
+
module.exports = __toCommonJS(socket_exports);
|
34
|
+
var import_ws = __toESM(require("ws"));
|
35
|
+
class SocketServer extends import_ws.default.Server {
|
14
36
|
handleHeartbeat(timeout = 3e4) {
|
15
37
|
const aliveMapping = /* @__PURE__ */ new WeakMap();
|
16
38
|
function heartbeat() {
|
@@ -39,10 +61,14 @@ class SocketServer extends _ws.default.Server {
|
|
39
61
|
broadcast(data, optsOrCb, cbOrNone) {
|
40
62
|
const opts = typeof optsOrCb === "function" ? {} : optsOrCb;
|
41
63
|
const cb = typeof optsOrCb === "function" ? optsOrCb : cbOrNone;
|
42
|
-
this.clients.forEach((client) => client.readyState ===
|
64
|
+
this.clients.forEach((client) => client.readyState === import_ws.default.OPEN && client.send(data, opts !== null && opts !== void 0 ? opts : {}, cb));
|
43
65
|
}
|
44
66
|
constructor(options, callback) {
|
45
67
|
super(options, callback);
|
46
68
|
this.handleHeartbeat();
|
47
69
|
}
|
48
70
|
}
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
72
|
+
0 && (module.exports = {
|
73
|
+
SocketServer
|
74
|
+
});
|
package/package.json
CHANGED
@@ -15,10 +15,10 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.36.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
|
-
"types": "./dist/
|
21
|
-
"main": "./dist/
|
20
|
+
"types": "./dist/index.d.ts",
|
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": "2.36.0",
|
46
|
+
"@modern-js/devtools-mount": "2.36.0",
|
47
|
+
"@modern-js/devtools-client": "2.36.0",
|
48
|
+
"@modern-js/utils": "2.36.0"
|
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": "2.
|
54
|
-
"@modern-js/core": "2.
|
55
|
-
"@modern-js/module-tools": "2.
|
56
|
-
"@modern-js/runtime": "2.
|
57
|
-
"@modern-js/server-core": "2.
|
58
|
-
"@modern-js/types": "2.
|
59
|
-
"@modern-js/builder-webpack-provider": "2.
|
60
|
-
"@modern-js/builder-rspack-provider": "2.
|
61
|
-
"@modern-js/builder-shared": "2.
|
62
|
-
"@scripts/build": "2.
|
57
|
+
"@modern-js/app-tools": "2.36.0",
|
58
|
+
"@modern-js/core": "2.36.0",
|
59
|
+
"@modern-js/module-tools": "2.36.0",
|
60
|
+
"@modern-js/runtime": "2.36.0",
|
61
|
+
"@modern-js/server-core": "2.36.0",
|
62
|
+
"@modern-js/types": "2.36.0",
|
63
|
+
"@modern-js/builder-webpack-provider": "2.36.0",
|
64
|
+
"@modern-js/builder-rspack-provider": "2.36.0",
|
65
|
+
"@modern-js/builder-shared": "2.36.0",
|
66
|
+
"@scripts/build": "2.36.0"
|
63
67
|
},
|
64
68
|
"peerDependencies": {
|
65
|
-
"@modern-js/runtime": "^2.
|
69
|
+
"@modern-js/runtime": "^2.36.0"
|
66
70
|
},
|
67
71
|
"peerDependenciesMeta": {
|
68
72
|
"@modern-js/runtime": {
|