rsbuild-plugin-devtools-json 0.2.2 → 0.2.3
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/index.cjs +92 -0
- package/dist/index.js +3 -3
- package/package.json +10 -7
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
pluginDevtoolsJson: ()=>pluginDevtoolsJson
|
|
37
|
+
});
|
|
38
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
39
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
40
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
41
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
42
|
+
const core_namespaceObject = require("@rsbuild/core");
|
|
43
|
+
const external_uuid_namespaceObject = require("uuid");
|
|
44
|
+
const ENDPOINT = '/.well-known/appspecific/com.chrome.devtools.json';
|
|
45
|
+
const pluginDevtoolsJson = (options)=>({
|
|
46
|
+
name: 'rsbuild-plugin-devtools-json',
|
|
47
|
+
setup (api) {
|
|
48
|
+
const getOrCreateUUID = ()=>{
|
|
49
|
+
if (null == options ? void 0 : options.uuid) return options.uuid;
|
|
50
|
+
const cacheDir = api.context.cachePath;
|
|
51
|
+
const uuidPath = external_node_path_default().resolve(cacheDir, 'uuid.json');
|
|
52
|
+
if (external_node_fs_default().existsSync(uuidPath)) {
|
|
53
|
+
const uuid = external_node_fs_default().readFileSync(uuidPath, {
|
|
54
|
+
encoding: 'utf-8'
|
|
55
|
+
});
|
|
56
|
+
if ((0, external_uuid_namespaceObject.validate)(uuid)) return uuid;
|
|
57
|
+
}
|
|
58
|
+
if (!external_node_fs_default().existsSync(cacheDir)) external_node_fs_default().mkdirSync(cacheDir, {
|
|
59
|
+
recursive: true
|
|
60
|
+
});
|
|
61
|
+
const uuid = (0, external_uuid_namespaceObject.v4)();
|
|
62
|
+
external_node_fs_default().writeFileSync(uuidPath, uuid, {
|
|
63
|
+
encoding: 'utf-8'
|
|
64
|
+
});
|
|
65
|
+
core_namespaceObject.logger.info(`[rsbuild-plugin-devtools-json] Generated UUID '${uuid}' for DevTools project settings.`);
|
|
66
|
+
return uuid;
|
|
67
|
+
};
|
|
68
|
+
api.onBeforeStartDevServer(({ server })=>{
|
|
69
|
+
server.middlewares.use((req, res, next)=>{
|
|
70
|
+
if (req.url !== ENDPOINT) return next();
|
|
71
|
+
let root = (null == options ? void 0 : options.rootPath) || api.context.rootPath;
|
|
72
|
+
if (!(null == options ? void 0 : options.rootPath) && process.env.WSL_DISTRO_NAME) root = external_node_path_default().join('\\\\wsl.localhost', process.env.WSL_DISTRO_NAME, root).replace(/\//g, '\\');
|
|
73
|
+
const uuid = getOrCreateUUID();
|
|
74
|
+
const devtoolsJson = {
|
|
75
|
+
workspace: {
|
|
76
|
+
root,
|
|
77
|
+
uuid
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
res.setHeader('Content-Type', 'application/json');
|
|
81
|
+
res.end(JSON.stringify(devtoolsJson, null, 2));
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
exports.pluginDevtoolsJson = __webpack_exports__.pluginDevtoolsJson;
|
|
87
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
88
|
+
"pluginDevtoolsJson"
|
|
89
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
90
|
+
Object.defineProperty(exports, '__esModule', {
|
|
91
|
+
value: true
|
|
92
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const pluginDevtoolsJson = (options)=>({
|
|
|
7
7
|
name: 'rsbuild-plugin-devtools-json',
|
|
8
8
|
setup (api) {
|
|
9
9
|
const getOrCreateUUID = ()=>{
|
|
10
|
-
if (options
|
|
10
|
+
if (null == options ? void 0 : options.uuid) return options.uuid;
|
|
11
11
|
const cacheDir = api.context.cachePath;
|
|
12
12
|
const uuidPath = node_path.resolve(cacheDir, 'uuid.json');
|
|
13
13
|
if (node_fs.existsSync(uuidPath)) {
|
|
@@ -29,8 +29,8 @@ const pluginDevtoolsJson = (options)=>({
|
|
|
29
29
|
api.onBeforeStartDevServer(({ server })=>{
|
|
30
30
|
server.middlewares.use((req, res, next)=>{
|
|
31
31
|
if (req.url !== ENDPOINT) return next();
|
|
32
|
-
let root = options
|
|
33
|
-
if (!options
|
|
32
|
+
let root = (null == options ? void 0 : options.rootPath) || api.context.rootPath;
|
|
33
|
+
if (!(null == options ? void 0 : options.rootPath) && process.env.WSL_DISTRO_NAME) root = node_path.join('\\\\wsl.localhost', process.env.WSL_DISTRO_NAME, root).replace(/\//g, '\\');
|
|
34
34
|
const uuid = getOrCreateUUID();
|
|
35
35
|
const devtoolsJson = {
|
|
36
36
|
workspace: {
|
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-devtools-json",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-devtools-json",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"import": "./dist/index.js"
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
10
12
|
}
|
|
11
13
|
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
12
15
|
"types": "./dist/index.d.ts",
|
|
13
16
|
"files": [
|
|
14
17
|
"dist"
|
|
15
18
|
],
|
|
16
19
|
"scripts": {
|
|
17
20
|
"build": "rslib build",
|
|
18
|
-
"
|
|
19
|
-
"lint:write": "biome check . --write",
|
|
21
|
+
"bump": "npx bumpp",
|
|
20
22
|
"dev": "rslib build --watch",
|
|
21
|
-
"prepare": "simple-git-hooks && npm run build",
|
|
22
23
|
"format": "biome format --write",
|
|
23
|
-
"
|
|
24
|
+
"lint": "biome check",
|
|
25
|
+
"lint:write": "biome check . --write",
|
|
26
|
+
"prepare": "simple-git-hooks && npm run build"
|
|
24
27
|
},
|
|
25
28
|
"simple-git-hooks": {
|
|
26
29
|
"pre-commit": "npx nano-staged"
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
"typescript": "5.8.3"
|
|
43
46
|
},
|
|
44
47
|
"peerDependencies": {
|
|
45
|
-
"@rsbuild/core": "
|
|
48
|
+
"@rsbuild/core": "1.x"
|
|
46
49
|
},
|
|
47
50
|
"peerDependenciesMeta": {
|
|
48
51
|
"@rsbuild/core": {
|