@rsdoctor/sdk 1.5.3 → 1.5.5
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/compiled/dayjs/index.js +2 -2
- package/compiled/dayjs/package.json +1 -1
- package/dist/0~open.js +346 -0
- package/dist/index.cjs +1865 -1857
- package/dist/index.js +120 -172
- package/dist/rslib-runtime.js +30 -0
- package/package.json +9 -9
- package/dist/0~604.js +0 -354
package/compiled/dayjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 403:
|
|
5
5
|
/***/ (function(module) {
|
|
6
6
|
|
|
7
7
|
!function(t,e){ true?module.exports=e():0}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
/******/ // startup
|
|
51
51
|
/******/ // Load entry module and return exports
|
|
52
52
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
53
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
53
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(403);
|
|
54
54
|
/******/ module.exports = __webpack_exports__;
|
|
55
55
|
/******/
|
|
56
56
|
/******/ })()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"dayjs","author":"iamkun","version":"1.11.
|
|
1
|
+
{"name":"dayjs","author":"iamkun","version":"1.11.20","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/0~open.js
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
let isDockerCached, cachedResult, mountPoint, defaultMountPoint;
|
|
2
|
+
import "node:module";
|
|
3
|
+
import node_process from "node:process";
|
|
4
|
+
import { Buffer } from "node:buffer";
|
|
5
|
+
import node_path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
import node_child_process, { execFile } from "node:child_process";
|
|
9
|
+
import promises, { constants } from "node:fs/promises";
|
|
10
|
+
import node_os from "node:os";
|
|
11
|
+
import node_fs from "node:fs";
|
|
12
|
+
function isInsideContainer() {
|
|
13
|
+
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
14
|
+
try {
|
|
15
|
+
return node_fs.statSync('/run/.containerenv'), !0;
|
|
16
|
+
} catch {
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
})() || (void 0 === isDockerCached && (isDockerCached = function() {
|
|
20
|
+
try {
|
|
21
|
+
return node_fs.statSync('/.dockerenv'), !0;
|
|
22
|
+
} catch {
|
|
23
|
+
return !1;
|
|
24
|
+
}
|
|
25
|
+
}() || function() {
|
|
26
|
+
try {
|
|
27
|
+
return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
}()), isDockerCached)), 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(), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
|
|
42
|
+
if (mountPoint) return mountPoint;
|
|
43
|
+
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
44
|
+
try {
|
|
45
|
+
await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
|
|
46
|
+
} catch {}
|
|
47
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
48
|
+
let configContent = await promises.readFile(configFilePath, {
|
|
49
|
+
encoding: 'utf8'
|
|
50
|
+
}), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
51
|
+
return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
|
|
52
|
+
}), powerShellPathFromWsl = async ()=>{
|
|
53
|
+
let mountPoint = await wslDrivesMountPoint();
|
|
54
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
55
|
+
}, powerShellPath = async ()=>is_wsl ? powerShellPathFromWsl() : `${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
56
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
57
|
+
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
58
|
+
value,
|
|
59
|
+
enumerable: !0,
|
|
60
|
+
writable: !0
|
|
61
|
+
});
|
|
62
|
+
return Object.defineProperty(object, propertyName, {
|
|
63
|
+
configurable: !0,
|
|
64
|
+
enumerable: !0,
|
|
65
|
+
get () {
|
|
66
|
+
let result = valueGetter();
|
|
67
|
+
return define(result), result;
|
|
68
|
+
},
|
|
69
|
+
set (value) {
|
|
70
|
+
define(value);
|
|
71
|
+
}
|
|
72
|
+
}), object;
|
|
73
|
+
}
|
|
74
|
+
let execFileAsync = promisify(execFile);
|
|
75
|
+
async function defaultBrowserId() {
|
|
76
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
77
|
+
let { stdout } = await execFileAsync('defaults', [
|
|
78
|
+
'read',
|
|
79
|
+
'com.apple.LaunchServices/com.apple.launchservices.secure',
|
|
80
|
+
'LSHandlers'
|
|
81
|
+
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
82
|
+
return match?.groups.id ?? 'com.apple.Safari';
|
|
83
|
+
}
|
|
84
|
+
let run_applescript_execFileAsync = promisify(execFile);
|
|
85
|
+
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
86
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
87
|
+
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
88
|
+
'-e',
|
|
89
|
+
script,
|
|
90
|
+
humanReadableOutput ? [] : [
|
|
91
|
+
'-ss'
|
|
92
|
+
]
|
|
93
|
+
]);
|
|
94
|
+
return stdout.trim();
|
|
95
|
+
}
|
|
96
|
+
async function bundleName(bundleId) {
|
|
97
|
+
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")`);
|
|
98
|
+
}
|
|
99
|
+
let windows_execFileAsync = promisify(execFile), windowsBrowserProgIds = {
|
|
100
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
101
|
+
name: 'Edge',
|
|
102
|
+
id: 'com.microsoft.edge.old'
|
|
103
|
+
},
|
|
104
|
+
MSEdgeDHTML: {
|
|
105
|
+
name: 'Edge',
|
|
106
|
+
id: 'com.microsoft.edge'
|
|
107
|
+
},
|
|
108
|
+
MSEdgeHTM: {
|
|
109
|
+
name: 'Edge',
|
|
110
|
+
id: 'com.microsoft.edge'
|
|
111
|
+
},
|
|
112
|
+
'IE.HTTP': {
|
|
113
|
+
name: 'Internet Explorer',
|
|
114
|
+
id: 'com.microsoft.ie'
|
|
115
|
+
},
|
|
116
|
+
FirefoxURL: {
|
|
117
|
+
name: 'Firefox',
|
|
118
|
+
id: 'org.mozilla.firefox'
|
|
119
|
+
},
|
|
120
|
+
ChromeHTML: {
|
|
121
|
+
name: 'Chrome',
|
|
122
|
+
id: 'com.google.chrome'
|
|
123
|
+
},
|
|
124
|
+
BraveHTML: {
|
|
125
|
+
name: 'Brave',
|
|
126
|
+
id: 'com.brave.Browser'
|
|
127
|
+
},
|
|
128
|
+
BraveBHTML: {
|
|
129
|
+
name: 'Brave Beta',
|
|
130
|
+
id: 'com.brave.Browser.beta'
|
|
131
|
+
},
|
|
132
|
+
BraveSSHTM: {
|
|
133
|
+
name: 'Brave Nightly',
|
|
134
|
+
id: 'com.brave.Browser.nightly'
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
class UnknownBrowserError extends Error {
|
|
138
|
+
}
|
|
139
|
+
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
140
|
+
let { stdout } = await _execFileAsync('reg', [
|
|
141
|
+
'QUERY',
|
|
142
|
+
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
143
|
+
'/v',
|
|
144
|
+
'ProgId'
|
|
145
|
+
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
146
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
147
|
+
let { id } = match.groups, browser = windowsBrowserProgIds[id];
|
|
148
|
+
if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
|
|
149
|
+
return browser;
|
|
150
|
+
}
|
|
151
|
+
let default_browser_execFileAsync = promisify(execFile);
|
|
152
|
+
async function default_browser_defaultBrowser() {
|
|
153
|
+
if ('darwin' === node_process.platform) {
|
|
154
|
+
let id = await defaultBrowserId();
|
|
155
|
+
return {
|
|
156
|
+
name: await bundleName(id),
|
|
157
|
+
id
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if ('linux' === node_process.platform) {
|
|
161
|
+
let { stdout } = await default_browser_execFileAsync('xdg-mime', [
|
|
162
|
+
'query',
|
|
163
|
+
'default',
|
|
164
|
+
'x-scheme-handler/http'
|
|
165
|
+
]), id = stdout.trim();
|
|
166
|
+
return {
|
|
167
|
+
name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
|
|
168
|
+
id
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if ('win32' === node_process.platform) return defaultBrowser();
|
|
172
|
+
throw Error('Only macOS, Linux, and Windows are supported');
|
|
173
|
+
}
|
|
174
|
+
let open_execFile = promisify(node_child_process.execFile), open_dirname = node_path.dirname(fileURLToPath(import.meta.url)), localXdgOpenPath = node_path.join(open_dirname, 'xdg-open'), { platform: platform, arch: arch } = node_process;
|
|
175
|
+
async function getWindowsDefaultBrowserFromWsl() {
|
|
176
|
+
let powershellPath = await powerShellPath(), rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, encodedCommand = Buffer.from(rawCommand, 'utf16le').toString('base64'), { stdout } = await open_execFile(powershellPath, [
|
|
177
|
+
'-NoProfile',
|
|
178
|
+
'-NonInteractive',
|
|
179
|
+
'-ExecutionPolicy',
|
|
180
|
+
'Bypass',
|
|
181
|
+
'-EncodedCommand',
|
|
182
|
+
encodedCommand
|
|
183
|
+
], {
|
|
184
|
+
encoding: 'utf8'
|
|
185
|
+
}), progId = stdout.trim(), browserMap = {
|
|
186
|
+
ChromeHTML: 'com.google.chrome',
|
|
187
|
+
BraveHTML: 'com.brave.Browser',
|
|
188
|
+
MSEdgeHTM: 'com.microsoft.edge',
|
|
189
|
+
FirefoxURL: 'org.mozilla.firefox'
|
|
190
|
+
};
|
|
191
|
+
return browserMap[progId] ? {
|
|
192
|
+
id: browserMap[progId]
|
|
193
|
+
} : {};
|
|
194
|
+
}
|
|
195
|
+
let pTryEach = async (array, mapper)=>{
|
|
196
|
+
let latestError;
|
|
197
|
+
for (let item of array)try {
|
|
198
|
+
return await mapper(item);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
latestError = error;
|
|
201
|
+
}
|
|
202
|
+
throw latestError;
|
|
203
|
+
}, baseOpen = async (options)=>{
|
|
204
|
+
let command;
|
|
205
|
+
if (Array.isArray((options = {
|
|
206
|
+
wait: !1,
|
|
207
|
+
background: !1,
|
|
208
|
+
newInstance: !1,
|
|
209
|
+
allowNonzeroExitCode: !1,
|
|
210
|
+
...options
|
|
211
|
+
}).app)) return pTryEach(options.app, (singleApp)=>baseOpen({
|
|
212
|
+
...options,
|
|
213
|
+
app: singleApp
|
|
214
|
+
}));
|
|
215
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
216
|
+
if (appArguments = [
|
|
217
|
+
...appArguments
|
|
218
|
+
], Array.isArray(app)) return pTryEach(app, (appName)=>baseOpen({
|
|
219
|
+
...options,
|
|
220
|
+
app: {
|
|
221
|
+
name: appName,
|
|
222
|
+
arguments: appArguments
|
|
223
|
+
}
|
|
224
|
+
}));
|
|
225
|
+
if ('browser' === app || 'browserPrivate' === app) {
|
|
226
|
+
let ids = {
|
|
227
|
+
'com.google.chrome': 'chrome',
|
|
228
|
+
'google-chrome.desktop': 'chrome',
|
|
229
|
+
'com.brave.Browser': 'brave',
|
|
230
|
+
'org.mozilla.firefox': 'firefox',
|
|
231
|
+
'firefox.desktop': 'firefox',
|
|
232
|
+
'com.microsoft.msedge': 'edge',
|
|
233
|
+
'com.microsoft.edge': 'edge',
|
|
234
|
+
'com.microsoft.edgemac': 'edge',
|
|
235
|
+
'microsoft-edge.desktop': 'edge'
|
|
236
|
+
}, browser = is_wsl ? await getWindowsDefaultBrowserFromWsl() : await default_browser_defaultBrowser();
|
|
237
|
+
if (browser.id in ids) {
|
|
238
|
+
let browserName = ids[browser.id];
|
|
239
|
+
return 'browserPrivate' === app && appArguments.push({
|
|
240
|
+
chrome: '--incognito',
|
|
241
|
+
brave: '--incognito',
|
|
242
|
+
firefox: '--private-window',
|
|
243
|
+
edge: '--inPrivate'
|
|
244
|
+
}[browserName]), baseOpen({
|
|
245
|
+
...options,
|
|
246
|
+
app: {
|
|
247
|
+
name: apps[browserName],
|
|
248
|
+
arguments: appArguments
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
throw Error(`${browser.name} is not supported as a default browser`);
|
|
253
|
+
}
|
|
254
|
+
let cliArguments = [], childProcessOptions = {};
|
|
255
|
+
if ('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);
|
|
256
|
+
else if ('win32' !== platform && (!is_wsl || isInsideContainer() || app)) {
|
|
257
|
+
if (app) command = app;
|
|
258
|
+
else {
|
|
259
|
+
let exeLocalXdgOpen = !1;
|
|
260
|
+
try {
|
|
261
|
+
await promises.access(localXdgOpenPath, constants.X_OK), exeLocalXdgOpen = !0;
|
|
262
|
+
} catch {}
|
|
263
|
+
command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
264
|
+
}
|
|
265
|
+
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
266
|
+
} else {
|
|
267
|
+
command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
|
|
268
|
+
let encodedArguments = [
|
|
269
|
+
'Start'
|
|
270
|
+
];
|
|
271
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(`"\`"${app}\`""`), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(`"${options.target}"`), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>`"\`"${argument}\`""`)).join(',')), options.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
|
|
272
|
+
}
|
|
273
|
+
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
274
|
+
let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
|
|
275
|
+
return options.wait ? new Promise((resolve, reject)=>{
|
|
276
|
+
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
277
|
+
!options.allowNonzeroExitCode && exitCode > 0 ? reject(Error(`Exited with code ${exitCode}`)) : resolve(subprocess);
|
|
278
|
+
});
|
|
279
|
+
}) : (subprocess.unref(), subprocess);
|
|
280
|
+
};
|
|
281
|
+
function detectArchBinary(binary) {
|
|
282
|
+
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
283
|
+
let { [arch]: archBinary } = binary;
|
|
284
|
+
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
285
|
+
return archBinary;
|
|
286
|
+
}
|
|
287
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
288
|
+
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
289
|
+
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
290
|
+
return detectArchBinary(platformBinary);
|
|
291
|
+
}
|
|
292
|
+
let apps = {};
|
|
293
|
+
defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
|
|
294
|
+
darwin: 'google chrome',
|
|
295
|
+
win32: 'chrome',
|
|
296
|
+
linux: [
|
|
297
|
+
'google-chrome',
|
|
298
|
+
'google-chrome-stable',
|
|
299
|
+
'chromium'
|
|
300
|
+
]
|
|
301
|
+
}, {
|
|
302
|
+
wsl: {
|
|
303
|
+
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
304
|
+
x64: [
|
|
305
|
+
'/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
|
|
306
|
+
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
})), defineLazyProperty(apps, 'brave', ()=>detectPlatformBinary({
|
|
310
|
+
darwin: 'brave browser',
|
|
311
|
+
win32: 'brave',
|
|
312
|
+
linux: [
|
|
313
|
+
'brave-browser',
|
|
314
|
+
'brave'
|
|
315
|
+
]
|
|
316
|
+
}, {
|
|
317
|
+
wsl: {
|
|
318
|
+
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
319
|
+
x64: [
|
|
320
|
+
'/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
321
|
+
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
})), defineLazyProperty(apps, 'firefox', ()=>detectPlatformBinary({
|
|
325
|
+
darwin: 'firefox',
|
|
326
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
327
|
+
linux: 'firefox'
|
|
328
|
+
}, {
|
|
329
|
+
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
330
|
+
})), defineLazyProperty(apps, 'edge', ()=>detectPlatformBinary({
|
|
331
|
+
darwin: 'microsoft edge',
|
|
332
|
+
win32: 'msedge',
|
|
333
|
+
linux: [
|
|
334
|
+
'microsoft-edge',
|
|
335
|
+
'microsoft-edge-dev'
|
|
336
|
+
]
|
|
337
|
+
}, {
|
|
338
|
+
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
339
|
+
})), defineLazyProperty(apps, 'browser', ()=>'browser'), defineLazyProperty(apps, 'browserPrivate', ()=>'browserPrivate');
|
|
340
|
+
export default ((target, options)=>{
|
|
341
|
+
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
342
|
+
return baseOpen({
|
|
343
|
+
...options,
|
|
344
|
+
target
|
|
345
|
+
});
|
|
346
|
+
});
|