@ohos-ports/rsbuild-core 1.7.2-beta.1
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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@jridgewell/remapping/index.d.ts +1 -0
- package/compiled/@jridgewell/remapping/index.js +1222 -0
- package/compiled/@jridgewell/remapping/license +19 -0
- package/compiled/@jridgewell/remapping/package.json +1 -0
- package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
- package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
- package/compiled/@jridgewell/trace-mapping/license +19 -0
- package/compiled/@jridgewell/trace-mapping/package.json +1 -0
- package/compiled/chokidar/index.d.ts +384 -0
- package/compiled/chokidar/index.js +1793 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/index.js +371 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/index.d.ts +290 -0
- package/compiled/html-rspack-plugin/index.js +1602 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +166 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +319 -0
- package/compiled/http-proxy-middleware/index.js +5284 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +719 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/memfs/index.d.ts +1462 -0
- package/compiled/memfs/index.js +1 -0
- package/compiled/memfs/license +201 -0
- package/compiled/memfs/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +456 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +140 -0
- package/compiled/postcss/lib/comment.d.ts +68 -0
- package/compiled/postcss/lib/container.d.ts +483 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
- package/compiled/postcss/lib/declaration.d.ts +151 -0
- package/compiled/postcss/lib/document.d.ts +69 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +227 -0
- package/compiled/postcss/lib/lazy-result.d.ts +190 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +46 -0
- package/compiled/postcss/lib/node.d.ts +556 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +458 -0
- package/compiled/postcss/lib/previous-map.d.ts +81 -0
- package/compiled/postcss/lib/processor.d.ts +115 -0
- package/compiled/postcss/lib/result.d.ts +205 -0
- package/compiled/postcss/lib/root.d.ts +87 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +46 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +147 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +720 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +67 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +545 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/index.js +409 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +274 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/tinyglobby/index.d.ts +46 -0
- package/compiled/tinyglobby/index.js +2664 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +23 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +437 -0
- package/compiled/ws/index.js +3161 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/0~open.js +427 -0
- package/dist/0~range-parser.js +49 -0
- package/dist/0~range-parser.js.LICENSE.txt +6 -0
- package/dist/131.js +9305 -0
- package/dist/131.js.LICENSE.txt +26 -0
- package/dist/136.mjs +42 -0
- package/dist/2~open.cjs +436 -0
- package/dist/2~range-parser.cjs +52 -0
- package/dist/2~range-parser.cjs.LICENSE.txt +6 -0
- package/dist/client/59.js +22 -0
- package/dist/client/hmr.js +206 -0
- package/dist/client/overlay.js +203 -0
- package/dist/ignoreCssLoader.mjs +3 -0
- package/dist/index.cjs +9456 -0
- package/dist/index.cjs.LICENSE.txt +26 -0
- package/dist/index.js +1 -0
- package/dist/rslib-runtime.js +44 -0
- package/dist/transformLoader.mjs +1 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist-types/cli/commands.d.ts +28 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/client/hmr.d.ts +3 -0
- package/dist-types/client/log.d.ts +13 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/configChain.d.ts +154 -0
- package/dist-types/constants.d.ts +52 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +5 -0
- package/dist-types/defaultConfig.d.ts +25 -0
- package/dist-types/helpers/compiler.d.ts +5 -0
- package/dist-types/helpers/exitHook.d.ts +3 -0
- package/dist-types/helpers/format.d.ts +2 -0
- package/dist-types/helpers/fs.d.ts +17 -0
- package/dist-types/helpers/index.d.ts +29 -0
- package/dist-types/helpers/path.d.ts +26 -0
- package/dist-types/helpers/stats.d.ts +18 -0
- package/dist-types/helpers/url.d.ts +11 -0
- package/dist-types/helpers/vendors.d.ts +29 -0
- package/dist-types/helpers/version.d.ts +7 -0
- package/dist-types/hooks.d.ts +44 -0
- package/dist-types/index.d.ts +22 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/loadConfig.d.ts +60 -0
- package/dist-types/loadEnv.d.ts +63 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +3 -0
- package/dist-types/loader/transformLoader.d.ts +8 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +19 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +21 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +2 -0
- package/dist-types/plugins/css.d.ts +4 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/esm.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +6 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +6 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/sourceMap.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +5 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +4 -0
- package/dist-types/provider/createCompiler.d.ts +6 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +19 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/restart.d.ts +18 -0
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +38 -0
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +32 -0
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +28 -0
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +23 -0
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +22 -0
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/ansiHTML.d.ts +4 -0
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +12 -0
- package/dist-types/server/assets-middleware/index.d.ts +37 -0
- package/dist-types/server/assets-middleware/middleware.d.ts +2 -0
- package/dist-types/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist-types/server/browserLogs.d.ts +9 -0
- package/dist-types/server/buildManager.d.ts +33 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/devMiddlewares.d.ts +21 -0
- package/dist-types/server/devServer.d.ts +79 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/gracefulShutdown.d.ts +10 -0
- package/dist-types/server/gzipMiddleware.d.ts +2 -0
- package/dist-types/server/helper.d.ts +91 -0
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/server/hmrFallback.d.ts +1 -0
- package/dist-types/server/httpServer.d.ts +7 -0
- package/dist-types/server/middlewares.d.ts +33 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/overlay.d.ts +3 -0
- package/dist-types/server/prodServer.d.ts +24 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +29 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +4 -0
- package/dist-types/server/runner/type.d.ts +42 -0
- package/dist-types/server/socketServer.d.ts +81 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1882 -0
- package/dist-types/types/context.d.ts +110 -0
- package/dist-types/types/hooks.d.ts +275 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +585 -0
- package/dist-types/types/rsbuild.d.ts +286 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +186 -0
- package/dist-types/types/utils.d.ts +19 -0
- package/package.json +114 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +349 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
2
|
+
Copyright (c) 2013 Arnout Kazemier and contributors
|
|
3
|
+
Copyright (c) 2016 Luigi Pinca and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.18.3","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/0~open.js
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
let isDockerCached, cachedResult, canAccessPowerShellPromise, mountPoint, defaultMountPoint;
|
|
2
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
|
+
import node_child_process, { execFile } from "node:child_process";
|
|
4
|
+
import promises, { constants } from "node:fs/promises";
|
|
5
|
+
import { Buffer } from "node:buffer";
|
|
6
|
+
import { node_fs, node_process, node_os, external_node_util_promisify } from "./131.js";
|
|
7
|
+
function hasDockerEnv() {
|
|
8
|
+
try {
|
|
9
|
+
return node_fs.statSync('/.dockerenv'), !0;
|
|
10
|
+
} catch {
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function hasDockerCGroup() {
|
|
15
|
+
try {
|
|
16
|
+
return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
17
|
+
} catch {
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isDocker() {
|
|
22
|
+
return void 0 === isDockerCached && (isDockerCached = hasDockerEnv() || hasDockerCGroup()), isDockerCached;
|
|
23
|
+
}
|
|
24
|
+
function isInsideContainer() {
|
|
25
|
+
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
26
|
+
try {
|
|
27
|
+
return node_fs.statSync('/run/.containerenv'), !0;
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
})() || isDocker()), cachedResult;
|
|
32
|
+
}
|
|
33
|
+
let isWsl = ()=>{
|
|
34
|
+
if ('linux' !== node_process.platform) return !1;
|
|
35
|
+
if (node_os.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
|
|
36
|
+
try {
|
|
37
|
+
return !!node_fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
|
|
38
|
+
} catch {
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
}, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(), powershell_utils_execFile = external_node_util_promisify(node_child_process.execFile), powerShellPath = ()=>`${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {})=>{
|
|
42
|
+
let { powerShellPath: psPath, ...execFileOptions } = options, encodedCommand = executePowerShell.encodeCommand(command);
|
|
43
|
+
return powershell_utils_execFile(psPath ?? powerShellPath(), [
|
|
44
|
+
...executePowerShell.argumentsPrefix,
|
|
45
|
+
encodedCommand
|
|
46
|
+
], {
|
|
47
|
+
encoding: 'utf8',
|
|
48
|
+
...execFileOptions
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
executePowerShell.argumentsPrefix = [
|
|
52
|
+
'-NoProfile',
|
|
53
|
+
'-NonInteractive',
|
|
54
|
+
'-ExecutionPolicy',
|
|
55
|
+
'Bypass',
|
|
56
|
+
'-EncodedCommand'
|
|
57
|
+
], executePowerShell.encodeCommand = (command)=>Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
|
|
58
|
+
let wsl_utils_execFile = external_node_util_promisify(node_child_process.execFile), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
|
|
59
|
+
if (mountPoint) return mountPoint;
|
|
60
|
+
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
61
|
+
try {
|
|
62
|
+
await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
|
|
63
|
+
} catch {}
|
|
64
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
65
|
+
let configContent = await promises.readFile(configFilePath, {
|
|
66
|
+
encoding: 'utf8'
|
|
67
|
+
}), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
68
|
+
return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
|
|
69
|
+
}), powerShellPathFromWsl = async ()=>{
|
|
70
|
+
let mountPoint = await wslDrivesMountPoint();
|
|
71
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
72
|
+
}, wsl_utils_powerShellPath = is_wsl ? powerShellPathFromWsl : powerShellPath, wsl_utils_canAccessPowerShell = async ()=>canAccessPowerShellPromise ??= (async ()=>{
|
|
73
|
+
try {
|
|
74
|
+
let psPath = await wsl_utils_powerShellPath();
|
|
75
|
+
return await promises.access(psPath, constants.X_OK), !0;
|
|
76
|
+
} catch {
|
|
77
|
+
return !1;
|
|
78
|
+
}
|
|
79
|
+
})(), wslDefaultBrowser = async ()=>{
|
|
80
|
+
let psPath = await wsl_utils_powerShellPath(), command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { stdout } = await executePowerShell(command, {
|
|
81
|
+
powerShellPath: psPath
|
|
82
|
+
});
|
|
83
|
+
return stdout.trim();
|
|
84
|
+
}, convertWslPathToWindows = async (path)=>{
|
|
85
|
+
if (/^[a-z]+:\/\//i.test(path)) return path;
|
|
86
|
+
try {
|
|
87
|
+
let { stdout } = await wsl_utils_execFile('wslpath', [
|
|
88
|
+
'-aw',
|
|
89
|
+
path
|
|
90
|
+
], {
|
|
91
|
+
encoding: 'utf8'
|
|
92
|
+
});
|
|
93
|
+
return stdout.trim();
|
|
94
|
+
} catch {
|
|
95
|
+
return path;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
99
|
+
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
100
|
+
value,
|
|
101
|
+
enumerable: !0,
|
|
102
|
+
writable: !0
|
|
103
|
+
});
|
|
104
|
+
return Object.defineProperty(object, propertyName, {
|
|
105
|
+
configurable: !0,
|
|
106
|
+
enumerable: !0,
|
|
107
|
+
get () {
|
|
108
|
+
let result = valueGetter();
|
|
109
|
+
return define(result), result;
|
|
110
|
+
},
|
|
111
|
+
set (value) {
|
|
112
|
+
define(value);
|
|
113
|
+
}
|
|
114
|
+
}), object;
|
|
115
|
+
}
|
|
116
|
+
let execFileAsync = external_node_util_promisify(execFile);
|
|
117
|
+
async function defaultBrowserId() {
|
|
118
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
119
|
+
let { stdout } = await execFileAsync('defaults', [
|
|
120
|
+
'read',
|
|
121
|
+
'com.apple.LaunchServices/com.apple.launchservices.secure',
|
|
122
|
+
'LSHandlers'
|
|
123
|
+
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
124
|
+
return match?.groups.id ?? 'com.apple.Safari';
|
|
125
|
+
}
|
|
126
|
+
let run_applescript_execFileAsync = external_node_util_promisify(execFile);
|
|
127
|
+
async function runAppleScript(script, { humanReadableOutput = !0, signal } = {}) {
|
|
128
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
129
|
+
let execOptions = {};
|
|
130
|
+
signal && (execOptions.signal = signal);
|
|
131
|
+
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
132
|
+
'-e',
|
|
133
|
+
script,
|
|
134
|
+
humanReadableOutput ? [] : [
|
|
135
|
+
'-ss'
|
|
136
|
+
]
|
|
137
|
+
], execOptions);
|
|
138
|
+
return stdout.trim();
|
|
139
|
+
}
|
|
140
|
+
async function bundleName(bundleId) {
|
|
141
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
142
|
+
}
|
|
143
|
+
let windows_execFileAsync = external_node_util_promisify(execFile), windowsBrowserProgIds = {
|
|
144
|
+
MSEdgeHTM: {
|
|
145
|
+
name: 'Edge',
|
|
146
|
+
id: 'com.microsoft.edge'
|
|
147
|
+
},
|
|
148
|
+
MSEdgeBHTML: {
|
|
149
|
+
name: 'Edge Beta',
|
|
150
|
+
id: 'com.microsoft.edge.beta'
|
|
151
|
+
},
|
|
152
|
+
MSEdgeDHTML: {
|
|
153
|
+
name: 'Edge Dev',
|
|
154
|
+
id: 'com.microsoft.edge.dev'
|
|
155
|
+
},
|
|
156
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
157
|
+
name: 'Edge',
|
|
158
|
+
id: 'com.microsoft.edge.old'
|
|
159
|
+
},
|
|
160
|
+
ChromeHTML: {
|
|
161
|
+
name: 'Chrome',
|
|
162
|
+
id: 'com.google.chrome'
|
|
163
|
+
},
|
|
164
|
+
ChromeBHTML: {
|
|
165
|
+
name: 'Chrome Beta',
|
|
166
|
+
id: 'com.google.chrome.beta'
|
|
167
|
+
},
|
|
168
|
+
ChromeDHTML: {
|
|
169
|
+
name: 'Chrome Dev',
|
|
170
|
+
id: 'com.google.chrome.dev'
|
|
171
|
+
},
|
|
172
|
+
ChromiumHTM: {
|
|
173
|
+
name: 'Chromium',
|
|
174
|
+
id: 'org.chromium.Chromium'
|
|
175
|
+
},
|
|
176
|
+
BraveHTML: {
|
|
177
|
+
name: 'Brave',
|
|
178
|
+
id: 'com.brave.Browser'
|
|
179
|
+
},
|
|
180
|
+
BraveBHTML: {
|
|
181
|
+
name: 'Brave Beta',
|
|
182
|
+
id: 'com.brave.Browser.beta'
|
|
183
|
+
},
|
|
184
|
+
BraveDHTML: {
|
|
185
|
+
name: 'Brave Dev',
|
|
186
|
+
id: 'com.brave.Browser.dev'
|
|
187
|
+
},
|
|
188
|
+
BraveSSHTM: {
|
|
189
|
+
name: 'Brave Nightly',
|
|
190
|
+
id: 'com.brave.Browser.nightly'
|
|
191
|
+
},
|
|
192
|
+
FirefoxURL: {
|
|
193
|
+
name: 'Firefox',
|
|
194
|
+
id: 'org.mozilla.firefox'
|
|
195
|
+
},
|
|
196
|
+
OperaStable: {
|
|
197
|
+
name: 'Opera',
|
|
198
|
+
id: 'com.operasoftware.Opera'
|
|
199
|
+
},
|
|
200
|
+
VivaldiHTM: {
|
|
201
|
+
name: 'Vivaldi',
|
|
202
|
+
id: 'com.vivaldi.Vivaldi'
|
|
203
|
+
},
|
|
204
|
+
'IE.HTTP': {
|
|
205
|
+
name: 'Internet Explorer',
|
|
206
|
+
id: 'com.microsoft.ie'
|
|
207
|
+
}
|
|
208
|
+
}, _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
209
|
+
class UnknownBrowserError extends Error {
|
|
210
|
+
}
|
|
211
|
+
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
212
|
+
let { stdout } = await _execFileAsync('reg', [
|
|
213
|
+
'QUERY',
|
|
214
|
+
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
215
|
+
'/v',
|
|
216
|
+
'ProgId'
|
|
217
|
+
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
218
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
219
|
+
let { id } = match.groups, browser = windowsBrowserProgIds[id];
|
|
220
|
+
if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
|
|
221
|
+
return browser;
|
|
222
|
+
}
|
|
223
|
+
let default_browser_execFileAsync = external_node_util_promisify(execFile);
|
|
224
|
+
async function default_browser_defaultBrowser() {
|
|
225
|
+
if ('darwin' === node_process.platform) {
|
|
226
|
+
let id = await defaultBrowserId();
|
|
227
|
+
return {
|
|
228
|
+
name: await bundleName(id),
|
|
229
|
+
id
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if ('linux' === node_process.platform) {
|
|
233
|
+
let { stdout } = await default_browser_execFileAsync('xdg-mime', [
|
|
234
|
+
'query',
|
|
235
|
+
'default',
|
|
236
|
+
'x-scheme-handler/http'
|
|
237
|
+
]), id = stdout.trim();
|
|
238
|
+
return {
|
|
239
|
+
name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
|
|
240
|
+
id
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if ('win32' === node_process.platform) return defaultBrowser();
|
|
244
|
+
throw Error('Only macOS, Linux, and Windows are supported');
|
|
245
|
+
}
|
|
246
|
+
let isInSsh = !!(node_process.env.SSH_CONNECTION || node_process.env.SSH_CLIENT || node_process.env.SSH_TTY), external_node_path_ = __webpack_require__("node:path"), external_node_url_ = __webpack_require__("node:url"), fallbackAttemptSymbol = Symbol('fallbackAttempt'), open_dirname = import.meta.url ? external_node_path_.default.dirname((0, external_node_url_.fileURLToPath)(import.meta.url)) : '', localXdgOpenPath = external_node_path_.default.join(open_dirname, 'xdg-open'), { platform: platform, arch: arch } = node_process, tryEachApp = async (apps, opener)=>{
|
|
247
|
+
if (0 === apps.length) return;
|
|
248
|
+
let errors = [];
|
|
249
|
+
for (let app of apps)try {
|
|
250
|
+
return await opener(app);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
errors.push(error);
|
|
253
|
+
}
|
|
254
|
+
throw AggregateError(errors, 'Failed to open in all supported apps');
|
|
255
|
+
}, baseOpen = async (options)=>{
|
|
256
|
+
let command, isFallbackAttempt = !0 === (options = {
|
|
257
|
+
wait: !1,
|
|
258
|
+
background: !1,
|
|
259
|
+
newInstance: !1,
|
|
260
|
+
allowNonzeroExitCode: !1,
|
|
261
|
+
...options
|
|
262
|
+
})[fallbackAttemptSymbol];
|
|
263
|
+
if (delete options[fallbackAttemptSymbol], Array.isArray(options.app)) return tryEachApp(options.app, (singleApp)=>baseOpen({
|
|
264
|
+
...options,
|
|
265
|
+
app: singleApp,
|
|
266
|
+
[fallbackAttemptSymbol]: !0
|
|
267
|
+
}));
|
|
268
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
269
|
+
if (appArguments = [
|
|
270
|
+
...appArguments
|
|
271
|
+
], Array.isArray(app)) return tryEachApp(app, (appName)=>baseOpen({
|
|
272
|
+
...options,
|
|
273
|
+
app: {
|
|
274
|
+
name: appName,
|
|
275
|
+
arguments: appArguments
|
|
276
|
+
},
|
|
277
|
+
[fallbackAttemptSymbol]: !0
|
|
278
|
+
}));
|
|
279
|
+
if ('browser' === app || 'browserPrivate' === app) {
|
|
280
|
+
let browser, ids = {
|
|
281
|
+
'com.google.chrome': 'chrome',
|
|
282
|
+
'google-chrome.desktop': 'chrome',
|
|
283
|
+
'com.brave.browser': 'brave',
|
|
284
|
+
'org.mozilla.firefox': 'firefox',
|
|
285
|
+
'firefox.desktop': 'firefox',
|
|
286
|
+
'com.microsoft.msedge': 'edge',
|
|
287
|
+
'com.microsoft.edge': 'edge',
|
|
288
|
+
'com.microsoft.edgemac': 'edge',
|
|
289
|
+
'microsoft-edge.desktop': 'edge',
|
|
290
|
+
'com.apple.safari': 'safari'
|
|
291
|
+
};
|
|
292
|
+
if (is_wsl) {
|
|
293
|
+
let progId = await wslDefaultBrowser();
|
|
294
|
+
browser = _windowsBrowserProgIdMap.get(progId) ?? {};
|
|
295
|
+
} else browser = await default_browser_defaultBrowser();
|
|
296
|
+
if (browser.id in ids) {
|
|
297
|
+
let browserName = ids[browser.id.toLowerCase()];
|
|
298
|
+
if ('browserPrivate' === app) {
|
|
299
|
+
if ('safari' === browserName) throw Error('Safari doesn\'t support opening in private mode via command line');
|
|
300
|
+
appArguments.push({
|
|
301
|
+
chrome: '--incognito',
|
|
302
|
+
brave: '--incognito',
|
|
303
|
+
firefox: '--private-window',
|
|
304
|
+
edge: '--inPrivate'
|
|
305
|
+
}[browserName]);
|
|
306
|
+
}
|
|
307
|
+
return baseOpen({
|
|
308
|
+
...options,
|
|
309
|
+
app: {
|
|
310
|
+
name: open_apps[browserName],
|
|
311
|
+
arguments: appArguments
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
throw Error(`${browser.name} is not supported as a default browser`);
|
|
316
|
+
}
|
|
317
|
+
let cliArguments = [], childProcessOptions = {}, shouldUseWindowsInWsl = !1;
|
|
318
|
+
if (!is_wsl || isInsideContainer() || isInSsh || app || (shouldUseWindowsInWsl = await wsl_utils_canAccessPowerShell()), 'darwin' === platform) command = 'open', options.wait && cliArguments.push('--wait-apps'), options.background && cliArguments.push('--background'), options.newInstance && cliArguments.push('--new'), app && cliArguments.push('-a', app);
|
|
319
|
+
else if ('win32' === platform || shouldUseWindowsInWsl) {
|
|
320
|
+
command = await wsl_utils_powerShellPath(), cliArguments.push(...executePowerShell.argumentsPrefix), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0), is_wsl && options.target && (options.target = await convertWslPathToWindows(options.target));
|
|
321
|
+
let encodedArguments = [
|
|
322
|
+
'$ProgressPreference = \'SilentlyContinue\';',
|
|
323
|
+
'Start'
|
|
324
|
+
];
|
|
325
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(executePowerShell.escapeArgument(app)), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(executePowerShell.escapeArgument(options.target)), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>executePowerShell.escapeArgument(argument))).join(',')), options.target = executePowerShell.encodeCommand(encodedArguments.join(' ')), options.wait || (childProcessOptions.stdio = 'ignore');
|
|
326
|
+
} else {
|
|
327
|
+
if (app) command = app;
|
|
328
|
+
else {
|
|
329
|
+
let exeLocalXdgOpen = !1;
|
|
330
|
+
try {
|
|
331
|
+
await promises.access(localXdgOpenPath, constants.X_OK), exeLocalXdgOpen = !0;
|
|
332
|
+
} catch {}
|
|
333
|
+
command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
334
|
+
}
|
|
335
|
+
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
336
|
+
}
|
|
337
|
+
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
338
|
+
let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
|
|
339
|
+
return options.wait ? new Promise((resolve, reject)=>{
|
|
340
|
+
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
341
|
+
options.allowNonzeroExitCode || 0 === exitCode ? resolve(subprocess) : reject(Error(`Exited with code ${exitCode}`));
|
|
342
|
+
});
|
|
343
|
+
}) : isFallbackAttempt ? new Promise((resolve, reject)=>{
|
|
344
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
345
|
+
subprocess.once('close', (exitCode)=>{
|
|
346
|
+
(subprocess.off('error', reject), 0 !== exitCode) ? reject(Error(`Exited with code ${exitCode}`)) : (subprocess.unref(), resolve(subprocess));
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}) : (subprocess.unref(), new Promise((resolve, reject)=>{
|
|
350
|
+
subprocess.once('error', reject), subprocess.once('spawn', ()=>{
|
|
351
|
+
subprocess.off('error', reject), resolve(subprocess);
|
|
352
|
+
});
|
|
353
|
+
}));
|
|
354
|
+
};
|
|
355
|
+
function detectArchBinary(binary) {
|
|
356
|
+
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
357
|
+
let { [arch]: archBinary } = binary;
|
|
358
|
+
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
359
|
+
return archBinary;
|
|
360
|
+
}
|
|
361
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
362
|
+
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
363
|
+
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
364
|
+
return detectArchBinary(platformBinary);
|
|
365
|
+
}
|
|
366
|
+
let open_apps = {
|
|
367
|
+
browser: 'browser',
|
|
368
|
+
browserPrivate: 'browserPrivate'
|
|
369
|
+
};
|
|
370
|
+
defineLazyProperty(open_apps, 'chrome', ()=>detectPlatformBinary({
|
|
371
|
+
darwin: 'google chrome',
|
|
372
|
+
win32: 'chrome',
|
|
373
|
+
linux: [
|
|
374
|
+
'google-chrome',
|
|
375
|
+
'google-chrome-stable',
|
|
376
|
+
'chromium',
|
|
377
|
+
'chromium-browser'
|
|
378
|
+
]
|
|
379
|
+
}, {
|
|
380
|
+
wsl: {
|
|
381
|
+
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
382
|
+
x64: [
|
|
383
|
+
'/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
|
|
384
|
+
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
})), defineLazyProperty(open_apps, 'brave', ()=>detectPlatformBinary({
|
|
388
|
+
darwin: 'brave browser',
|
|
389
|
+
win32: 'brave',
|
|
390
|
+
linux: [
|
|
391
|
+
'brave-browser',
|
|
392
|
+
'brave'
|
|
393
|
+
]
|
|
394
|
+
}, {
|
|
395
|
+
wsl: {
|
|
396
|
+
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
397
|
+
x64: [
|
|
398
|
+
'/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
399
|
+
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
})), defineLazyProperty(open_apps, 'firefox', ()=>detectPlatformBinary({
|
|
403
|
+
darwin: 'firefox',
|
|
404
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
405
|
+
linux: 'firefox'
|
|
406
|
+
}, {
|
|
407
|
+
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
408
|
+
})), defineLazyProperty(open_apps, 'edge', ()=>detectPlatformBinary({
|
|
409
|
+
darwin: 'microsoft edge',
|
|
410
|
+
win32: 'msedge',
|
|
411
|
+
linux: [
|
|
412
|
+
'microsoft-edge',
|
|
413
|
+
'microsoft-edge-dev'
|
|
414
|
+
]
|
|
415
|
+
}, {
|
|
416
|
+
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
417
|
+
})), defineLazyProperty(open_apps, 'safari', ()=>detectPlatformBinary({
|
|
418
|
+
darwin: 'Safari'
|
|
419
|
+
}));
|
|
420
|
+
let node_modules_open = (target, options)=>{
|
|
421
|
+
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
422
|
+
return baseOpen({
|
|
423
|
+
...options,
|
|
424
|
+
target
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
export { node_modules_open, open_apps };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*! For license information please see 0~range-parser.js.LICENSE.txt */
|
|
2
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
|
+
__webpack_require__.add({
|
|
4
|
+
"../../node_modules/.pnpm/range-parser@1.2.1/node_modules/range-parser/index.js" (module) {
|
|
5
|
+
function combineRanges(ranges) {
|
|
6
|
+
for(var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart), j = 0, i = 1; i < ordered.length; i++){
|
|
7
|
+
var range = ordered[i], current = ordered[j];
|
|
8
|
+
range.start > current.end + 1 ? ordered[++j] = range : range.end > current.end && (current.end = range.end, current.index = Math.min(current.index, range.index));
|
|
9
|
+
}
|
|
10
|
+
ordered.length = j + 1;
|
|
11
|
+
var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex);
|
|
12
|
+
return combined.type = ranges.type, combined;
|
|
13
|
+
}
|
|
14
|
+
function mapWithIndex(range, index) {
|
|
15
|
+
return {
|
|
16
|
+
start: range.start,
|
|
17
|
+
end: range.end,
|
|
18
|
+
index: index
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function mapWithoutIndex(range) {
|
|
22
|
+
return {
|
|
23
|
+
start: range.start,
|
|
24
|
+
end: range.end
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function sortByRangeIndex(a, b) {
|
|
28
|
+
return a.index - b.index;
|
|
29
|
+
}
|
|
30
|
+
function sortByRangeStart(a, b) {
|
|
31
|
+
return a.start - b.start;
|
|
32
|
+
}
|
|
33
|
+
module.exports = function rangeParser(size, str, options) {
|
|
34
|
+
if ('string' != typeof str) throw TypeError('argument str must be a string');
|
|
35
|
+
var index = str.indexOf('=');
|
|
36
|
+
if (-1 === index) return -2;
|
|
37
|
+
var arr = str.slice(index + 1).split(','), ranges = [];
|
|
38
|
+
ranges.type = str.slice(0, index);
|
|
39
|
+
for(var i = 0; i < arr.length; i++){
|
|
40
|
+
var range = arr[i].split('-'), start = parseInt(range[0], 10), end = parseInt(range[1], 10);
|
|
41
|
+
isNaN(start) ? (start = size - end, end = size - 1) : isNaN(end) && (end = size - 1), end > size - 1 && (end = size - 1), isNaN(start) || isNaN(end) || start > end || start < 0 || ranges.push({
|
|
42
|
+
start: start,
|
|
43
|
+
end: end
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return ranges.length < 1 ? -1 : options && options.combine ? combineRanges(ranges) : ranges;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|