@rspack/dev-server 2.2.0 → 2.2.2
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/client/index.js +8 -6
- package/client/overlay.js +5 -6
- package/dist/{0~chokidar.js → chokidar~0.js} +3 -3
- package/dist/{0~connect-history-api-fallback.js → connect-history-api-fallback~0.js} +8 -8
- package/dist/{0~connect-next.js → connect-next~0.js} +38 -22
- package/dist/{0~debug.js → debug~0.js} +8 -7
- package/dist/{0~http-proxy-middleware.js → http-proxy-middleware~0.js} +32 -24
- package/dist/index.d.ts +16 -10
- package/dist/index.js +1 -1
- package/dist/{0~launch-editor.js → launch-editor~0.js} +225 -99
- package/dist/{0~open.js → open~0.js} +64 -19
- package/dist/{0~serve-static.js → serve-static~0.js} +22 -20
- package/dist/{619.js → t~0.js} +2380 -2397
- package/package.json +25 -42
- /package/dist/{0~chokidar.js.LICENSE.txt → chokidar~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~connect-next.js.LICENSE.txt → connect-next~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~http-proxy-middleware.js.LICENSE.txt → http-proxy-middleware~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~p-retry.js → p-retry~0.js} +0 -0
- /package/dist/{0~serve-static.js.LICENSE.txt → serve-static~0.js.LICENSE.txt} +0 -0
|
@@ -127,24 +127,66 @@ const wslDefaultBrowser = async ()=>{
|
|
|
127
127
|
const psPath = await wsl_utils_powerShellPath();
|
|
128
128
|
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
129
129
|
const { stdout } = await executePowerShell(command, {
|
|
130
|
-
powerShellPath: psPath
|
|
130
|
+
powerShellPath: psPath,
|
|
131
|
+
cwd: node_path.dirname(psPath)
|
|
131
132
|
});
|
|
132
133
|
return stdout.trim();
|
|
133
134
|
};
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const isUrl = (path)=>/^[a-z]+:\/\//i.test(path);
|
|
136
|
+
const convertWslPathToWindows = async (paths)=>{
|
|
137
|
+
const isBatch = Array.isArray(paths);
|
|
138
|
+
const pathArray = isBatch ? paths : [
|
|
139
|
+
paths
|
|
140
|
+
];
|
|
141
|
+
const indicesToConvert = [];
|
|
142
|
+
const pathsToConvert = [];
|
|
143
|
+
for (const [index, path] of pathArray.entries())if (!isUrl(path)) {
|
|
144
|
+
indicesToConvert.push(index);
|
|
145
|
+
pathsToConvert.push(path);
|
|
146
|
+
}
|
|
147
|
+
const results = [
|
|
148
|
+
...pathArray
|
|
149
|
+
];
|
|
150
|
+
if (pathsToConvert.length > 0) try {
|
|
137
151
|
const { stdout } = await wsl_utils_execFile('wslpath', [
|
|
138
152
|
'-aw',
|
|
139
|
-
|
|
153
|
+
...pathsToConvert
|
|
140
154
|
], {
|
|
141
155
|
encoding: 'utf8'
|
|
142
156
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
const convertedPaths = stdout.split(/\r?\n/).filter(Boolean);
|
|
158
|
+
for (const [index, originalIndex] of indicesToConvert.entries())results[originalIndex] = convertedPaths[index] ?? pathArray[originalIndex];
|
|
159
|
+
} catch {}
|
|
160
|
+
return isBatch ? results : results[0];
|
|
161
|
+
};
|
|
162
|
+
const powershell_utils_execFile = promisify(node_child_process.execFile);
|
|
163
|
+
const powershell_utils_powerShellPath = ()=>`${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
164
|
+
const argumentsPrefix = [
|
|
165
|
+
'-NoProfile',
|
|
166
|
+
'-NonInteractive',
|
|
167
|
+
'-ExecutionPolicy',
|
|
168
|
+
'Bypass',
|
|
169
|
+
'-EncodedCommand'
|
|
170
|
+
];
|
|
171
|
+
const encodeCommand = (command)=>Buffer.from(command, 'utf16le').toString('base64');
|
|
172
|
+
const escapeArgument = (value)=>`'${String(value).replaceAll(/['‘’‚‛]/g, (match)=>match + match)}'`;
|
|
173
|
+
const createArguments = (command)=>[
|
|
174
|
+
...argumentsPrefix,
|
|
175
|
+
encodeCommand(command)
|
|
176
|
+
];
|
|
177
|
+
const createExecFileOptions = (options)=>({
|
|
178
|
+
encoding: 'utf8',
|
|
179
|
+
...options,
|
|
180
|
+
shell: false
|
|
181
|
+
});
|
|
182
|
+
const powershell_utils_executePowerShell = async (command, options = {})=>{
|
|
183
|
+
const { powerShellPath: psPath, ...execFileOptions } = options;
|
|
184
|
+
return powershell_utils_execFile(psPath ?? powershell_utils_powerShellPath(), createArguments(command), createExecFileOptions(execFileOptions));
|
|
147
185
|
};
|
|
186
|
+
powershell_utils_executePowerShell.argumentsPrefix = argumentsPrefix;
|
|
187
|
+
powershell_utils_executePowerShell.encodeCommand = encodeCommand;
|
|
188
|
+
powershell_utils_executePowerShell.escapeArgument = escapeArgument;
|
|
189
|
+
powershell_utils_executePowerShell.createArguments = createArguments;
|
|
148
190
|
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
149
191
|
const define = (value)=>Object.defineProperty(object, propertyName, {
|
|
150
192
|
value,
|
|
@@ -267,7 +309,8 @@ const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
|
267
309
|
class UnknownBrowserError extends Error {
|
|
268
310
|
}
|
|
269
311
|
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
270
|
-
const {
|
|
312
|
+
const regPath = `${node_process.env.SYSTEMROOT ?? node_process.env.windir ?? 'C:\\Windows'}\\System32\\reg.exe`;
|
|
313
|
+
const { stdout } = await _execFileAsync(regPath, [
|
|
271
314
|
'QUERY',
|
|
272
315
|
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
273
316
|
'/v',
|
|
@@ -380,8 +423,9 @@ const baseOpen = async (options)=>{
|
|
|
380
423
|
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
381
424
|
browser = browserInfo ?? {};
|
|
382
425
|
} else browser = await default_browser_defaultBrowser();
|
|
383
|
-
|
|
384
|
-
|
|
426
|
+
const browserId = browser.id?.toLowerCase();
|
|
427
|
+
if (Object.hasOwn(ids, browserId)) {
|
|
428
|
+
const browserName = ids[browserId];
|
|
385
429
|
if ('browserPrivate' === app) {
|
|
386
430
|
if ('safari' === browserName) throw new Error('Safari doesn\'t support opening in private mode via command line');
|
|
387
431
|
appArguments.push(flags[browserName]);
|
|
@@ -409,7 +453,7 @@ const baseOpen = async (options)=>{
|
|
|
409
453
|
if (app) cliArguments.push('-a', app);
|
|
410
454
|
} else if ('win32' === platform || shouldUseWindowsInWsl) {
|
|
411
455
|
command = await wsl_utils_powerShellPath();
|
|
412
|
-
cliArguments.push(...
|
|
456
|
+
cliArguments.push(...powershell_utils_executePowerShell.argumentsPrefix);
|
|
413
457
|
if (!is_wsl) childProcessOptions.windowsVerbatimArguments = true;
|
|
414
458
|
if (is_wsl && options.target) options.target = await convertWslPathToWindows(options.target);
|
|
415
459
|
const encodedArguments = [
|
|
@@ -418,15 +462,16 @@ const baseOpen = async (options)=>{
|
|
|
418
462
|
];
|
|
419
463
|
if (options.wait) encodedArguments.push('-Wait');
|
|
420
464
|
if (app) {
|
|
421
|
-
encodedArguments.push(
|
|
465
|
+
encodedArguments.push(powershell_utils_executePowerShell.escapeArgument(app));
|
|
422
466
|
if (options.target) appArguments.push(options.target);
|
|
423
|
-
} else if (options.target) encodedArguments.push(
|
|
467
|
+
} else if (options.target) encodedArguments.push(powershell_utils_executePowerShell.escapeArgument(options.target));
|
|
424
468
|
if (appArguments.length > 0) {
|
|
425
|
-
appArguments = appArguments.map((argument)=>
|
|
469
|
+
appArguments = appArguments.map((argument)=>powershell_utils_executePowerShell.escapeArgument(argument));
|
|
426
470
|
encodedArguments.push('-ArgumentList', appArguments.join(','));
|
|
427
471
|
}
|
|
428
|
-
options.target =
|
|
472
|
+
options.target = powershell_utils_executePowerShell.encodeCommand(encodedArguments.join(' '));
|
|
429
473
|
if (!options.wait) childProcessOptions.stdio = 'ignore';
|
|
474
|
+
if (is_wsl) childProcessOptions.cwd = node_path.dirname(command);
|
|
430
475
|
} else {
|
|
431
476
|
if (app) command = app;
|
|
432
477
|
else {
|
|
@@ -455,12 +500,12 @@ const baseOpen = async (options)=>{
|
|
|
455
500
|
resolve(subprocess);
|
|
456
501
|
});
|
|
457
502
|
});
|
|
458
|
-
if (isFallbackAttempt) return new Promise((resolve, reject)=>{
|
|
503
|
+
if (isFallbackAttempt || 'win32' === platform || shouldUseWindowsInWsl) return new Promise((resolve, reject)=>{
|
|
459
504
|
subprocess.once('error', reject);
|
|
460
505
|
subprocess.once('spawn', ()=>{
|
|
461
506
|
subprocess.once('close', (exitCode)=>{
|
|
462
507
|
subprocess.off('error', reject);
|
|
463
|
-
if (0 !== exitCode) return void reject(new Error(`Exited with code ${exitCode}`));
|
|
508
|
+
if (isFallbackAttempt && 0 !== exitCode) return void reject(new Error(`Exited with code ${exitCode}`));
|
|
464
509
|
subprocess.unref();
|
|
465
510
|
resolve(subprocess);
|
|
466
511
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
/*! LICENSE:
|
|
2
|
-
import { __webpack_require__ } from "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./0
|
|
1
|
+
/*! LICENSE: serve-static~0.js.LICENSE.txt */
|
|
2
|
+
import { __webpack_require__ } from "./t~0.js";
|
|
3
|
+
import "./t~0.js";
|
|
4
|
+
import "./debug~0.js";
|
|
5
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
6
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
5
7
|
__webpack_require__.add({
|
|
6
|
-
"./node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js" (module
|
|
8
|
+
"./node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js" (module) {
|
|
7
9
|
/*!
|
|
8
10
|
* depd
|
|
9
11
|
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
|
10
12
|
* MIT Licensed
|
|
11
|
-
*/ var relative =
|
|
13
|
+
*/ var relative = __rspack_createRequire_require("path").relative;
|
|
12
14
|
module.exports = depd;
|
|
13
15
|
var basePath = process.cwd();
|
|
14
16
|
function containsNamespace(str, namespace) {
|
|
@@ -356,14 +358,14 @@ __webpack_require__.add({
|
|
|
356
358
|
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
357
359
|
}
|
|
358
360
|
},
|
|
359
|
-
"./node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js" (module
|
|
361
|
+
"./node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js" (module) {
|
|
360
362
|
/*!
|
|
361
363
|
* etag
|
|
362
364
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
363
365
|
* MIT Licensed
|
|
364
366
|
*/ module.exports = etag;
|
|
365
|
-
var crypto =
|
|
366
|
-
var Stats =
|
|
367
|
+
var crypto = __rspack_createRequire_require("crypto");
|
|
368
|
+
var Stats = __rspack_createRequire_require("fs").Stats;
|
|
367
369
|
var toString = Object.prototype.toString;
|
|
368
370
|
function entitytag(entity) {
|
|
369
371
|
if (0 === entity.length) return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
|
@@ -423,7 +425,7 @@ __webpack_require__.add({
|
|
|
423
425
|
}
|
|
424
426
|
function parseHttpDate(date) {
|
|
425
427
|
var timestamp = date && Date.parse(date);
|
|
426
|
-
return 'number' == typeof timestamp ? timestamp :
|
|
428
|
+
return 'number' == typeof timestamp ? timestamp : 0 / 0;
|
|
427
429
|
}
|
|
428
430
|
function parseTokenList(str) {
|
|
429
431
|
var end = 0;
|
|
@@ -640,7 +642,7 @@ __webpack_require__.add({
|
|
|
640
642
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
641
643
|
* MIT Licensed
|
|
642
644
|
*/ var db = __webpack_require__("./node_modules/.pnpm/mime-db@1.54.0/node_modules/mime-db/index.js");
|
|
643
|
-
var extname =
|
|
645
|
+
var extname = __rspack_createRequire_require("path").extname;
|
|
644
646
|
var mimeScore = __webpack_require__("./node_modules/.pnpm/mime-types@3.0.2/node_modules/mime-types/mimeScore.js");
|
|
645
647
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
646
648
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
@@ -854,13 +856,13 @@ __webpack_require__.add({
|
|
|
854
856
|
return res.runInAsyncScope.bind(res, fn, null);
|
|
855
857
|
}
|
|
856
858
|
},
|
|
857
|
-
"./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js" (module
|
|
859
|
+
"./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js" (module) {
|
|
858
860
|
/*!
|
|
859
861
|
* parseurl
|
|
860
862
|
* Copyright(c) 2014 Jonathan Ong
|
|
861
863
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
862
864
|
* MIT Licensed
|
|
863
|
-
*/ var url =
|
|
865
|
+
*/ var url = __rspack_createRequire_require("url");
|
|
864
866
|
var parse = url.parse;
|
|
865
867
|
var Url = url.Url;
|
|
866
868
|
module.exports = parseurl;
|
|
@@ -999,15 +1001,15 @@ __webpack_require__.add({
|
|
|
999
1001
|
var escapeHtml = __webpack_require__("./node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js");
|
|
1000
1002
|
var etag = __webpack_require__("./node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js");
|
|
1001
1003
|
var fresh = __webpack_require__("./node_modules/.pnpm/fresh@2.0.0/node_modules/fresh/index.js");
|
|
1002
|
-
var fs =
|
|
1004
|
+
var fs = __rspack_createRequire_require("fs");
|
|
1003
1005
|
var mime = __webpack_require__("./node_modules/.pnpm/mime-types@3.0.2/node_modules/mime-types/index.js");
|
|
1004
1006
|
var ms = __webpack_require__("./node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js");
|
|
1005
1007
|
var onFinished = __webpack_require__("./node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js");
|
|
1006
1008
|
var parseRange = __webpack_require__("./node_modules/.pnpm/range-parser@1.2.1/node_modules/range-parser/index.js");
|
|
1007
|
-
var path =
|
|
1009
|
+
var path = __rspack_createRequire_require("path");
|
|
1008
1010
|
var statuses = __webpack_require__("./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js");
|
|
1009
|
-
var Stream =
|
|
1010
|
-
var util =
|
|
1011
|
+
var Stream = __rspack_createRequire_require("stream");
|
|
1012
|
+
var util = __rspack_createRequire_require("util");
|
|
1011
1013
|
var extname = path.extname;
|
|
1012
1014
|
var join = path.join;
|
|
1013
1015
|
var normalize = path.normalize;
|
|
@@ -1389,7 +1391,7 @@ __webpack_require__.add({
|
|
|
1389
1391
|
}
|
|
1390
1392
|
function parseHttpDate(date) {
|
|
1391
1393
|
var timestamp = date && Date.parse(date);
|
|
1392
|
-
return 'number' == typeof timestamp ? timestamp :
|
|
1394
|
+
return 'number' == typeof timestamp ? timestamp : 0 / 0;
|
|
1393
1395
|
}
|
|
1394
1396
|
function parseTokenList(str) {
|
|
1395
1397
|
var end = 0;
|
|
@@ -1428,9 +1430,9 @@ __webpack_require__.add({
|
|
|
1428
1430
|
*/ var encodeUrl = __webpack_require__("./node_modules/.pnpm/encodeurl@2.0.0/node_modules/encodeurl/index.js");
|
|
1429
1431
|
var escapeHtml = __webpack_require__("./node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js");
|
|
1430
1432
|
var parseUrl = __webpack_require__("./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js");
|
|
1431
|
-
var resolve =
|
|
1433
|
+
var resolve = __rspack_createRequire_require("path").resolve;
|
|
1432
1434
|
var send = __webpack_require__("./node_modules/.pnpm/send@1.2.1_supports-color@8.1.1/node_modules/send/index.js");
|
|
1433
|
-
var url =
|
|
1435
|
+
var url = __rspack_createRequire_require("url");
|
|
1434
1436
|
module.exports = serveStatic;
|
|
1435
1437
|
function serveStatic(root, options) {
|
|
1436
1438
|
if (!root) throw new TypeError('root path required');
|