@modern-js/plugin-devtools 0.0.0-next-20240701110742 → 0.0.0-next-20240701111908
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 +0 -1
- package/dist/cli.js +7 -13
- package/dist/plugins/cleanup.js +0 -1
- package/dist/plugins/debug.js +10 -12
- package/dist/plugins/html.js +11 -11
- package/dist/plugins/http.d.ts +1 -3
- package/dist/plugins/http.js +21 -11
- package/dist/plugins/manifest.js +2 -10
- package/dist/plugins/rpc.js +0 -1
- package/dist/plugins/service-worker.js +0 -1
- package/dist/plugins/settle.js +0 -1
- package/dist/plugins/state.js +56 -61
- package/dist/plugins/watcher.js +0 -1
- package/dist/runtime.js +4 -20
- package/dist/types/common.d.ts +1 -7
- package/package.json +13 -13
- package/dist/plugins/route.d.ts +0 -0
- package/dist/plugins/route.js +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { Plugin } from './types';
|
|
|
5
5
|
export type { DevtoolsPluginOptions };
|
|
6
6
|
export type DevtoolsPlugin = CliPlugin<AppTools> & {
|
|
7
7
|
setClientDefinition: (def: ClientDefinition) => void;
|
|
8
|
-
plugins: Plugin[];
|
|
9
8
|
};
|
|
10
9
|
export declare const BUILTIN_PLUGINS: Plugin[];
|
|
11
10
|
export declare const devtoolsPlugin: (inlineOptions?: DevtoolsPluginOptions) => DevtoolsPlugin;
|
package/dist/cli.js
CHANGED
|
@@ -53,10 +53,10 @@ const BUILTIN_PLUGINS = [
|
|
|
53
53
|
import_debug.pluginDebug,
|
|
54
54
|
import_watcher.pluginWatcher,
|
|
55
55
|
import_service_worker.pluginServiceWorker,
|
|
56
|
-
// --- //
|
|
57
|
-
import_http.pluginHttp,
|
|
58
56
|
import_html.pluginHtml,
|
|
57
|
+
// --- //
|
|
59
58
|
import_state.pluginState,
|
|
59
|
+
import_http.pluginHttp,
|
|
60
60
|
import_rpc.pluginRpc,
|
|
61
61
|
import_settle.pluginSettleState,
|
|
62
62
|
import_manifest.pluginManifest,
|
|
@@ -85,12 +85,12 @@ const devtoolsPlugin = (inlineOptions = {}) => {
|
|
|
85
85
|
setupBuilder.reject(new Error("Devtools Plugin is disabled"));
|
|
86
86
|
setupFramework.reject(new Error("Devtools Plugin is disabled"));
|
|
87
87
|
});
|
|
88
|
-
const
|
|
88
|
+
for (const plugin of BUILTIN_PLUGINS) {
|
|
89
|
+
plugin.setup(api);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
89
92
|
name: "@modern-js/plugin-devtools",
|
|
90
93
|
usePlugins: [],
|
|
91
|
-
plugins: [
|
|
92
|
-
...BUILTIN_PLUGINS
|
|
93
|
-
],
|
|
94
94
|
setClientDefinition(def) {
|
|
95
95
|
Object.assign(ctx.def, def);
|
|
96
96
|
},
|
|
@@ -98,10 +98,6 @@ const devtoolsPlugin = (inlineOptions = {}) => {
|
|
|
98
98
|
if (!ctx.enable)
|
|
99
99
|
return {};
|
|
100
100
|
setupFramework.resolve(frameworkApi);
|
|
101
|
-
for (const plugin of instance.plugins) {
|
|
102
|
-
await plugin.setup(api);
|
|
103
|
-
}
|
|
104
|
-
await api.frameworkHooks.callHook("setup", frameworkApi);
|
|
105
101
|
return {
|
|
106
102
|
async prepare() {
|
|
107
103
|
await api.frameworkHooks.callHook("prepare");
|
|
@@ -134,8 +130,7 @@ const devtoolsPlugin = (inlineOptions = {}) => {
|
|
|
134
130
|
const configs = await api.frameworkHooks.callHookParallel("config");
|
|
135
131
|
const builderPlugin = {
|
|
136
132
|
name: "builder-plugin-devtools",
|
|
137
|
-
|
|
138
|
-
await api.builderHooks.callHook("setup", builderApi);
|
|
133
|
+
setup(builderApi) {
|
|
139
134
|
setupBuilder.resolve(builderApi);
|
|
140
135
|
builderApi.modifyBundlerChain(async (options, utils) => {
|
|
141
136
|
await api.builderHooks.callHook("modifyBundlerChain", options, utils);
|
|
@@ -173,7 +168,6 @@ const devtoolsPlugin = (inlineOptions = {}) => {
|
|
|
173
168
|
};
|
|
174
169
|
}
|
|
175
170
|
};
|
|
176
|
-
return instance;
|
|
177
171
|
};
|
|
178
172
|
var cli_default = devtoolsPlugin;
|
|
179
173
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/cleanup.js
CHANGED
package/dist/plugins/debug.js
CHANGED
|
@@ -26,21 +26,19 @@ const logger = (0, import_utils.createLogger)({
|
|
|
26
26
|
level: process.env.LOG_LEVEL || "info"
|
|
27
27
|
});
|
|
28
28
|
const pluginDebug = {
|
|
29
|
-
name: "debug",
|
|
30
29
|
async setup(api) {
|
|
31
30
|
await api.setupFramework();
|
|
32
31
|
logger.debug("setup framework api");
|
|
33
|
-
api.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
32
|
+
await api.setupBuilder();
|
|
33
|
+
logger.debug("setup builder api");
|
|
34
|
+
api.builderHooks.beforeEach((e) => {
|
|
35
|
+
logger.debug("after builder hook:", e.name);
|
|
36
|
+
});
|
|
37
|
+
api.frameworkHooks.beforeEach((e) => {
|
|
38
|
+
logger.debug("after framework hook:", e.name);
|
|
39
|
+
});
|
|
40
|
+
api.hooks.beforeEach((e) => {
|
|
41
|
+
logger.debug("after hook:", e.name);
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
44
|
};
|
package/dist/plugins/html.js
CHANGED
|
@@ -32,25 +32,25 @@ __export(html_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(html_exports);
|
|
34
34
|
const pluginHtml = {
|
|
35
|
-
name: "html",
|
|
36
35
|
async setup(api) {
|
|
37
36
|
api.frameworkHooks.hook("config", async () => {
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const clientOptions = {
|
|
38
|
+
def: api.context.def,
|
|
39
|
+
src: "/__devtools"
|
|
40
|
+
};
|
|
41
|
+
Object.assign(clientOptions, {
|
|
42
|
+
__keep: true
|
|
43
|
+
});
|
|
40
44
|
const config = {
|
|
41
45
|
source: {
|
|
42
46
|
preEntry: [
|
|
43
47
|
require.resolve("../runtime")
|
|
44
|
-
]
|
|
48
|
+
],
|
|
49
|
+
globalVars: {
|
|
50
|
+
"process.env.__USE_MODERNJS_DEVTOOLS__": "/__devtools/manifest"
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
};
|
|
47
|
-
if (port) {
|
|
48
|
-
var _config;
|
|
49
|
-
(_config = config).source || (_config.source = {});
|
|
50
|
-
config.source.globalVars = {
|
|
51
|
-
"process.env.__USE_MODERNJS_DEVTOOLS__": `http://localhost:${port}/manifest`
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
54
|
return config;
|
|
55
55
|
});
|
|
56
56
|
}
|
package/dist/plugins/http.d.ts
CHANGED
package/dist/plugins/http.js
CHANGED
|
@@ -36,7 +36,6 @@ var import_assert = __toESM(require("assert"));
|
|
|
36
36
|
var import_http = __toESM(require("http"));
|
|
37
37
|
var import_url = require("url");
|
|
38
38
|
var import_hono = require("hono");
|
|
39
|
-
var import_cors = require("hono/cors");
|
|
40
39
|
var import_utils = require("@modern-js/utils");
|
|
41
40
|
var import_node_server = require("@hono/node-server");
|
|
42
41
|
var import_serve_static = require("@hono/node-server/serve-static");
|
|
@@ -79,13 +78,16 @@ const hotUpdateHandler = async (c) => {
|
|
|
79
78
|
}
|
|
80
79
|
return newResp;
|
|
81
80
|
};
|
|
81
|
+
const fallbackHtmlHandler = async (c) => {
|
|
82
|
+
const filename = import_path.default.resolve(CLIENT_SERVE_DIR, "html/client/index.html");
|
|
83
|
+
const content = await import_utils.fs.readFile(filename, "utf-8");
|
|
84
|
+
return c.html(content);
|
|
85
|
+
};
|
|
82
86
|
const pluginHttp = {
|
|
83
|
-
name: "http",
|
|
84
87
|
async setup(api) {
|
|
85
88
|
if (process.env.NODE_ENV === "production")
|
|
86
89
|
return;
|
|
87
90
|
const app = new import_hono.Hono();
|
|
88
|
-
app.use("*", (0, import_cors.cors)());
|
|
89
91
|
app.all("/api/cookies", cookiesServiceHandler);
|
|
90
92
|
app.use(
|
|
91
93
|
"/static/*",
|
|
@@ -101,6 +103,7 @@ const pluginHttp = {
|
|
|
101
103
|
"Content-Type": "application/json"
|
|
102
104
|
});
|
|
103
105
|
});
|
|
106
|
+
app.get("*", fallbackHtmlHandler);
|
|
104
107
|
const server = (0, import_node_server.createAdaptorServer)({
|
|
105
108
|
fetch: app.fetch,
|
|
106
109
|
hostname: "127.0.0.1",
|
|
@@ -108,22 +111,29 @@ const pluginHttp = {
|
|
|
108
111
|
allowHTTP1: true
|
|
109
112
|
}
|
|
110
113
|
});
|
|
111
|
-
const port = await (0, import_utils.getPort)(8782, {
|
|
112
|
-
slient: true
|
|
113
|
-
});
|
|
114
114
|
(0, import_assert.default)(server instanceof import_http.default.Server, "instance should be http.Server");
|
|
115
|
-
server
|
|
116
|
-
api.vars.http = Object.assign(server, {
|
|
117
|
-
port
|
|
118
|
-
});
|
|
115
|
+
api.vars.http = server;
|
|
119
116
|
api.frameworkHooks.hook("config", async () => {
|
|
117
|
+
const port = await (0, import_utils.getPort)(8782, {
|
|
118
|
+
slient: true
|
|
119
|
+
});
|
|
120
|
+
server.listen(port);
|
|
120
121
|
const proxy = {
|
|
121
122
|
[import_node.ROUTE_BASENAME]: {
|
|
122
123
|
target: `http://127.0.0.1:${port}`,
|
|
123
124
|
pathRewrite: {
|
|
124
125
|
[`^${import_node.ROUTE_BASENAME}`]: ""
|
|
125
126
|
},
|
|
126
|
-
ws: true
|
|
127
|
+
ws: true,
|
|
128
|
+
onProxyReq(proxyReq, req) {
|
|
129
|
+
const addrInfo = req.socket.address();
|
|
130
|
+
if ("address" in addrInfo) {
|
|
131
|
+
const { address } = addrInfo;
|
|
132
|
+
proxyReq.setHeader("X-Forwarded-For", address);
|
|
133
|
+
} else {
|
|
134
|
+
proxyReq.removeHeader("X-Forwarded-For");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
127
137
|
}
|
|
128
138
|
};
|
|
129
139
|
return {
|
package/dist/plugins/manifest.js
CHANGED
|
@@ -36,28 +36,20 @@ var import_node = require("@modern-js/devtools-kit/node");
|
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
|
37
37
|
var import_p_defer = __toESM(require("p-defer"));
|
|
38
38
|
const pluginManifest = {
|
|
39
|
-
name: "manifest",
|
|
40
39
|
async setup(api) {
|
|
41
40
|
const deferredManifest = (0, import_p_defer.default)();
|
|
42
41
|
const deferredManifestJson = (0, import_p_defer.default)();
|
|
43
42
|
api.vars.useManifest = deferredManifest.promise;
|
|
44
43
|
api.vars.useManifestJson = deferredManifestJson.promise;
|
|
45
44
|
api.hooks.hook("settleState", async () => {
|
|
46
|
-
var _api_vars_http;
|
|
47
45
|
const routesManifestName = require.resolve("@modern-js/devtools-client/manifest");
|
|
48
46
|
const routesManifest = await import_utils.fs.readJSON(routesManifestName);
|
|
49
47
|
const manifest = {
|
|
50
48
|
...api.vars.state,
|
|
49
|
+
client: "/__devtools",
|
|
50
|
+
websocket: "/__devtools/rpc",
|
|
51
51
|
routeAssets: routesManifest.routeAssets
|
|
52
52
|
};
|
|
53
|
-
const port = (_api_vars_http = api.vars.http) === null || _api_vars_http === void 0 ? void 0 : _api_vars_http.port;
|
|
54
|
-
if (port) {
|
|
55
|
-
manifest.client = `http://localhost:${port}/static/html/client/index.html`;
|
|
56
|
-
manifest.websocket = `ws://localhost:${port}/rpc`;
|
|
57
|
-
}
|
|
58
|
-
await api.hooks.callHook("createManifest", {
|
|
59
|
-
manifest
|
|
60
|
-
});
|
|
61
53
|
api.vars.manifest = manifest;
|
|
62
54
|
deferredManifest.resolve(manifest);
|
|
63
55
|
const stringified = JSON.stringify(manifest, (0, import_node.replacer)());
|
package/dist/plugins/rpc.js
CHANGED
|
@@ -32,7 +32,6 @@ __export(service_worker_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(service_worker_exports);
|
|
34
34
|
const pluginServiceWorker = {
|
|
35
|
-
name: "service-worker",
|
|
36
35
|
async setup(api) {
|
|
37
36
|
api.frameworkHooks.hook("modifyServerRoutes", ({ routes }) => {
|
|
38
37
|
routes.push({
|
package/dist/plugins/settle.js
CHANGED
package/dist/plugins/state.js
CHANGED
|
@@ -114,7 +114,6 @@ const getDoctorOverview = async (ctx) => {
|
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
116
|
const pluginState = {
|
|
117
|
-
name: "state",
|
|
118
117
|
async setup(api) {
|
|
119
118
|
api.vars.state = (0, import_valtio.proxy)({
|
|
120
119
|
framework: {
|
|
@@ -133,70 +132,66 @@ const pluginState = {
|
|
|
133
132
|
api.frameworkHooks.hook("modifyFileSystemRoutes", ({ entrypoint, routes }) => {
|
|
134
133
|
api.vars.state.fileSystemRoutes[entrypoint.entryName] = import_lodash.default.cloneDeep(routes);
|
|
135
134
|
});
|
|
136
|
-
api.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
builder: null,
|
|
141
|
-
serverInternalPlugins: null
|
|
142
|
-
};
|
|
143
|
-
api.hooks.hook("settleState", async () => {
|
|
144
|
-
try {
|
|
145
|
-
api.vars.state.doctor = await getDoctorOverview(frameworkContext);
|
|
146
|
-
} catch (err) {
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
api.vars.state.framework = {
|
|
150
|
-
context: frameworkContext,
|
|
151
|
-
config: {
|
|
152
|
-
resolved: frameworkApi.useConfigContext(),
|
|
153
|
-
transformed: frameworkApi.useResolvedConfigContext()
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
});
|
|
135
|
+
const builderApi = await api.setupBuilder();
|
|
136
|
+
api.vars.state.builder.context = builderApi.context;
|
|
137
|
+
resolveDependencies(builderApi.context.rootPath).then((deps) => {
|
|
138
|
+
api.vars.state.dependencies = deps;
|
|
157
139
|
});
|
|
158
|
-
api.builderHooks.hook("
|
|
159
|
-
api.vars.state.builder.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
api.builderHooks.hook("modifyBundlerChain", () => {
|
|
164
|
-
api.vars.state.builder.config = {
|
|
165
|
-
resolved: import_lodash.default.cloneDeep(builderApi.getRsbuildConfig()),
|
|
166
|
-
transformed: import_lodash.default.cloneDeep(builderApi.getNormalizedConfig())
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
const expectBundlerNum = import_lodash.default.castArray(builderApi.context.targets).length;
|
|
170
|
-
const bundlerConfigs = [];
|
|
171
|
-
const handleBundlerConfig = (config) => {
|
|
172
|
-
bundlerConfigs.push(config);
|
|
173
|
-
if (bundlerConfigs.length >= expectBundlerNum) {
|
|
174
|
-
api.vars.state.bundler.configs.resolved = import_lodash.default.cloneDeep(bundlerConfigs);
|
|
175
|
-
}
|
|
140
|
+
api.builderHooks.hook("modifyBundlerChain", () => {
|
|
141
|
+
api.vars.state.builder.config = {
|
|
142
|
+
resolved: import_lodash.default.cloneDeep(builderApi.getRsbuildConfig()),
|
|
143
|
+
transformed: import_lodash.default.cloneDeep(builderApi.getNormalizedConfig())
|
|
176
144
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
145
|
+
});
|
|
146
|
+
const expectBundlerNum = import_lodash.default.castArray(builderApi.context.targets).length;
|
|
147
|
+
const bundlerConfigs = [];
|
|
148
|
+
const handleBundlerConfig = (config) => {
|
|
149
|
+
bundlerConfigs.push(config);
|
|
150
|
+
if (bundlerConfigs.length >= expectBundlerNum) {
|
|
151
|
+
api.vars.state.bundler.configs.resolved = import_lodash.default.cloneDeep(bundlerConfigs);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
if (builderApi.context.bundlerType === "webpack") {
|
|
155
|
+
api.builderHooks.hook("modifyWebpackConfig", handleBundlerConfig);
|
|
156
|
+
} else {
|
|
157
|
+
api.builderHooks.hook("modifyRspackConfig", handleBundlerConfig);
|
|
158
|
+
}
|
|
159
|
+
api.builderHooks.hook("onBeforeCreateCompiler", ({ bundlerConfigs: bundlerConfigs2 }) => {
|
|
160
|
+
api.vars.state.bundler.configs.transformed = import_lodash.default.cloneDeep(bundlerConfigs2);
|
|
161
|
+
});
|
|
162
|
+
let buildStartedAt = NaN;
|
|
163
|
+
api.builderHooks.hook("onAfterCreateCompiler", () => {
|
|
164
|
+
buildStartedAt = Date.now();
|
|
165
|
+
});
|
|
166
|
+
api.builderHooks.hook("onDevCompileDone", () => {
|
|
167
|
+
api.vars.state.performance = {
|
|
168
|
+
compileDuration: Date.now() - buildStartedAt
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
api.builderHooks.hook("onAfterBuild", () => {
|
|
172
|
+
api.vars.state.performance = {
|
|
173
|
+
compileDuration: Date.now() - buildStartedAt
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
api.hooks.hook("settleState", async () => {
|
|
177
|
+
try {
|
|
178
|
+
api.vars.state.doctor = await getDoctorOverview(frameworkContext);
|
|
179
|
+
} catch (err) {
|
|
181
180
|
}
|
|
182
|
-
api.builderHooks.hook("onBeforeCreateCompiler", ({ bundlerConfigs: bundlerConfigs2 }) => {
|
|
183
|
-
api.vars.state.bundler.configs.transformed = import_lodash.default.cloneDeep(bundlerConfigs2);
|
|
184
|
-
});
|
|
185
|
-
let buildStartedAt = NaN;
|
|
186
|
-
api.builderHooks.hook("onAfterCreateCompiler", () => {
|
|
187
|
-
buildStartedAt = Date.now();
|
|
188
|
-
});
|
|
189
|
-
api.builderHooks.hook("onDevCompileDone", () => {
|
|
190
|
-
api.vars.state.performance = {
|
|
191
|
-
compileDuration: Date.now() - buildStartedAt
|
|
192
|
-
};
|
|
193
|
-
});
|
|
194
|
-
api.builderHooks.hook("onAfterBuild", () => {
|
|
195
|
-
api.vars.state.performance = {
|
|
196
|
-
compileDuration: Date.now() - buildStartedAt
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
181
|
});
|
|
182
|
+
const frameworkApi = await api.setupFramework();
|
|
183
|
+
const frameworkContext = {
|
|
184
|
+
...frameworkApi.useAppContext(),
|
|
185
|
+
builder: null,
|
|
186
|
+
serverInternalPlugins: null
|
|
187
|
+
};
|
|
188
|
+
api.vars.state.framework = {
|
|
189
|
+
context: frameworkContext,
|
|
190
|
+
config: {
|
|
191
|
+
resolved: frameworkApi.useConfigContext(),
|
|
192
|
+
transformed: frameworkApi.useResolvedConfigContext()
|
|
193
|
+
}
|
|
194
|
+
};
|
|
200
195
|
}
|
|
201
196
|
};
|
|
202
197
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/watcher.js
CHANGED
|
@@ -25,7 +25,6 @@ var import_utils = require("@modern-js/utils");
|
|
|
25
25
|
var import_config = require("../utils/config");
|
|
26
26
|
var import_options = require("../options");
|
|
27
27
|
const pluginWatcher = {
|
|
28
|
-
name: "watcher",
|
|
29
28
|
async setup(api) {
|
|
30
29
|
const frameworkApi = await api.setupFramework();
|
|
31
30
|
const basename = `${api.context.def.name.shortName}.runtime.json`;
|
package/dist/runtime.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
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 runtime_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(runtime_exports);
|
|
2
|
+
var import_runtime = require("@modern-js/devtools-kit/runtime");
|
|
17
3
|
const fetchSync = (url, body) => {
|
|
18
4
|
const xhr = new XMLHttpRequest();
|
|
19
5
|
xhr.open("GET", url, false);
|
|
@@ -22,8 +8,8 @@ const fetchSync = (url, body) => {
|
|
|
22
8
|
text() {
|
|
23
9
|
return xhr.responseText;
|
|
24
10
|
},
|
|
25
|
-
json(
|
|
26
|
-
return JSON.parse(xhr.responseText,
|
|
11
|
+
json(reviver2) {
|
|
12
|
+
return JSON.parse(xhr.responseText, reviver2);
|
|
27
13
|
},
|
|
28
14
|
blob() {
|
|
29
15
|
return new Blob([
|
|
@@ -51,10 +37,8 @@ const setup = () => {
|
|
|
51
37
|
const devtoolsUrl = cookieManifestUrl || injectedManifestUrl;
|
|
52
38
|
if (!devtoolsUrl)
|
|
53
39
|
return;
|
|
54
|
-
const manifest = fetchSync(devtoolsUrl).json();
|
|
40
|
+
const manifest = fetchSync(devtoolsUrl).json((0, import_runtime.reviver)());
|
|
55
41
|
manifest.source = devtoolsUrl;
|
|
56
|
-
if (!manifest.client)
|
|
57
|
-
return;
|
|
58
42
|
const template = document.createElement("template");
|
|
59
43
|
template.id = "_modern_js_devtools_styles";
|
|
60
44
|
document.body.appendChild(template);
|
package/dist/types/common.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AppTools, AppToolsHooks, CliPlugin } from '@modern-js/app-tools';
|
|
|
4
4
|
import type { ServerPlugin, ToThreads } from '@modern-js/server-core';
|
|
5
5
|
import type { RsbuildPluginAPI } from '@rsbuild/core';
|
|
6
6
|
import { Hookable } from 'hookable';
|
|
7
|
-
import { DevtoolsContext
|
|
7
|
+
import { DevtoolsContext } from '@modern-js/devtools-kit/node';
|
|
8
8
|
export type CliPluginAPI = Parameters<NonNullable<CliPlugin<AppTools>['setup']>>[0];
|
|
9
9
|
export type ServerPluginAPI = Parameters<NonNullable<ServerPlugin['setup']>>[0];
|
|
10
10
|
export type BufferLike = string | Buffer | DataView | number | ArrayBufferView | Uint8Array | ArrayBuffer | SharedArrayBuffer | ReadonlyArray<any> | ReadonlyArray<number> | {
|
|
@@ -26,21 +26,16 @@ export type CleanHooks<T> = {
|
|
|
26
26
|
export type $FrameworkHooks = CleanHooks<Pick<ToThreads<BaseHooks<any> & AppToolsHooks<any>>, 'prepare' | 'modifyFileSystemRoutes' | 'modifyServerRoutes' | 'afterCreateCompiler' | 'afterDev' | 'beforeRestart' | 'beforeExit' | 'afterBuild'>>;
|
|
27
27
|
export interface FrameworkHooks extends $FrameworkHooks {
|
|
28
28
|
config: () => void;
|
|
29
|
-
setup: (api: CliPluginAPI) => void;
|
|
30
29
|
}
|
|
31
30
|
type UnwrapBuilderHooks<T> = {
|
|
32
31
|
[K in keyof T]: T[K] extends (...args: any) => any ? (...params: [...Parameters<Parameters<T[K]>[0]>]) => void : never;
|
|
33
32
|
};
|
|
34
33
|
export type $BuilderHooks = UnwrapBuilderHooks<Pick<RsbuildPluginAPI, 'modifyBundlerChain' | 'modifyWebpackConfig' | 'modifyRspackConfig' | 'onBeforeCreateCompiler' | 'onAfterCreateCompiler' | 'onDevCompileDone' | 'onAfterBuild' | 'onExit'>>;
|
|
35
34
|
export interface BuilderHooks extends $BuilderHooks {
|
|
36
|
-
setup: (api: RsbuildPluginAPI) => void;
|
|
37
35
|
}
|
|
38
36
|
export interface DevtoolsHooks {
|
|
39
37
|
cleanup: () => Promise<void> | void;
|
|
40
38
|
settleState: () => Promise<void> | void;
|
|
41
|
-
createManifest: (arg: {
|
|
42
|
-
manifest: ServerManifest;
|
|
43
|
-
}) => Promise<void> | void;
|
|
44
39
|
}
|
|
45
40
|
declare global {
|
|
46
41
|
interface DevtoolsPluginVars extends Record<string, unknown> {
|
|
@@ -56,7 +51,6 @@ export interface PluginApi {
|
|
|
56
51
|
vars: DevtoolsPluginVars;
|
|
57
52
|
}
|
|
58
53
|
export interface Plugin {
|
|
59
|
-
name: string;
|
|
60
54
|
setup: (api: PluginApi) => Promise<void>;
|
|
61
55
|
}
|
|
62
56
|
export {};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-next-
|
|
18
|
+
"version": "0.0.0-next-20240701111908",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"main": "./dist/index.js",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"valtio": "^1.11.1",
|
|
56
56
|
"ws": "^8.13.0",
|
|
57
57
|
"hookable": "^5.5.3",
|
|
58
|
-
"@modern-js/devtools-
|
|
59
|
-
"@modern-js/devtools-
|
|
60
|
-
"@modern-js/utils": "0.0.0-next-
|
|
58
|
+
"@modern-js/devtools-kit": "0.0.0-next-20240701111908",
|
|
59
|
+
"@modern-js/devtools-client": "0.0.0-next-20240701111908",
|
|
60
|
+
"@modern-js/utils": "0.0.0-next-20240701111908"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@swc/helpers": "0.5.3",
|
|
@@ -66,17 +66,17 @@
|
|
|
66
66
|
"type-fest": "^4.1.0",
|
|
67
67
|
"typescript": "^5",
|
|
68
68
|
"@rsbuild/core": "0.7.10",
|
|
69
|
-
"@modern-js/
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/uni-builder": "0.0.0-next-
|
|
76
|
-
"@scripts/build": "0.0.0-next-
|
|
69
|
+
"@modern-js/app-tools": "0.0.0-next-20240701111908",
|
|
70
|
+
"@modern-js/core": "0.0.0-next-20240701111908",
|
|
71
|
+
"@modern-js/module-tools": "0.0.0-next-20240701111908",
|
|
72
|
+
"@modern-js/runtime": "0.0.0-next-20240701111908",
|
|
73
|
+
"@modern-js/server-core": "0.0.0-next-20240701111908",
|
|
74
|
+
"@modern-js/types": "0.0.0-next-20240701111908",
|
|
75
|
+
"@modern-js/uni-builder": "0.0.0-next-20240701111908",
|
|
76
|
+
"@scripts/build": "0.0.0-next-20240701111908"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@modern-js/runtime": "0.0.0-next-
|
|
79
|
+
"@modern-js/runtime": "0.0.0-next-20240701111908"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@modern-js/runtime": {
|
package/dist/plugins/route.d.ts
DELETED
|
File without changes
|
package/dist/plugins/route.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|