@rsbuild/core 0.6.7 → 0.6.9
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/commander/{typings/index.d.ts → index.d.ts} +26 -24
- package/compiled/commander/index.js +3528 -1
- package/compiled/commander/package.json +1 -1
- package/compiled/connect-history-api-fallback/index.js +186 -1
- package/compiled/dotenv/{lib/main.d.ts → index.d.ts} +16 -12
- package/compiled/dotenv/index.js +458 -1
- package/compiled/dotenv/package.json +1 -1
- package/compiled/dotenv-expand/{lib/main.d.ts → index.d.ts} +9 -7
- package/compiled/dotenv-expand/index.js +146 -1
- package/compiled/dotenv-expand/package.json +1 -1
- package/compiled/http-compression/index.js +185 -1
- package/compiled/launch-editor-middleware/index.js +843 -1
- package/compiled/on-finished/index.d.ts +2 -2
- package/compiled/on-finished/index.js +390 -3
- package/compiled/on-finished/package.json +1 -1
- package/compiled/open/index.d.ts +1 -153
- package/compiled/open/index.js +526 -1
- package/compiled/open/package.json +1 -1
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +798 -1
- package/compiled/sirv/package.json +1 -1
- package/compiled/webpack-dev-middleware/index.d.ts +1 -0
- package/compiled/webpack-dev-middleware/index.js +6696 -0
- package/compiled/webpack-dev-middleware/license +20 -0
- package/compiled/webpack-dev-middleware/package.json +1 -0
- package/compiled/webpack-dev-middleware/schema-utils.js +1 -0
- package/compiled/ws/index.d.ts +7 -15
- package/compiled/ws/index.js +4885 -1
- package/compiled/ws/package.json +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/format.d.ts +5 -0
- package/dist/client/{formatStats.js → format.js} +22 -46
- package/dist/client/hmr.d.ts +5 -0
- package/dist/client/hmr.mjs +201 -474
- package/dist/client/overlay.mjs +208 -237
- package/dist/createContext.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/target.js +19 -16
- package/dist/provider/plugins/swc.js +1 -0
- package/dist/provider/shared.js +2 -2
- package/dist/server/devMiddleware.js +1 -1
- package/dist/server/devServer.js +6 -1
- package/dist/server/getDevMiddlewares.d.ts +3 -0
- package/dist/server/getDevMiddlewares.js +6 -8
- package/dist/server/helper.d.ts +4 -4
- package/dist/server/middlewares.d.ts +5 -2
- package/dist/server/middlewares.js +1 -7
- package/package.json +6 -5
- package/compiled/open/license +0 -9
- package/compiled/sirv/sirv.d.ts +0 -27
- package/dist/client/formatStats.d.ts +0 -12
- package/dist/client/hmr/createSocketUrl.d.ts +0 -12
- package/dist/client/hmr/index.d.ts +0 -4
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, OutgoingMessage } from 'http';
|
|
3
3
|
|
|
4
|
-
export = onFinished;
|
|
5
|
-
|
|
6
4
|
declare function onFinished<T extends IncomingMessage | OutgoingMessage>(
|
|
7
5
|
msg: T,
|
|
8
6
|
listener: (err: Error | null, msg: T) => void,
|
|
@@ -11,3 +9,5 @@ declare function onFinished<T extends IncomingMessage | OutgoingMessage>(
|
|
|
11
9
|
declare namespace onFinished {
|
|
12
10
|
function isFinished(msg: IncomingMessage | OutgoingMessage): boolean;
|
|
13
11
|
}
|
|
12
|
+
|
|
13
|
+
export { onFinished as default };
|
|
@@ -1,14 +1,401 @@
|
|
|
1
|
-
(()=>{
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ "use strict";
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
4
|
+
|
|
5
|
+
/***/ 261:
|
|
6
|
+
/***/ ((module) => {
|
|
7
|
+
|
|
2
8
|
/*!
|
|
3
9
|
* ee-first
|
|
4
10
|
* Copyright(c) 2014 Jonathan Ong
|
|
5
11
|
* MIT Licensed
|
|
6
12
|
*/
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Module exports.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
module.exports = first
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the first event in a set of event emitters and event pairs.
|
|
25
|
+
*
|
|
26
|
+
* @param {array} stuff
|
|
27
|
+
* @param {function} done
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function first(stuff, done) {
|
|
32
|
+
if (!Array.isArray(stuff))
|
|
33
|
+
throw new TypeError('arg must be an array of [ee, events...] arrays')
|
|
34
|
+
|
|
35
|
+
var cleanups = []
|
|
36
|
+
|
|
37
|
+
for (var i = 0; i < stuff.length; i++) {
|
|
38
|
+
var arr = stuff[i]
|
|
39
|
+
|
|
40
|
+
if (!Array.isArray(arr) || arr.length < 2)
|
|
41
|
+
throw new TypeError('each array member must be [ee, events...]')
|
|
42
|
+
|
|
43
|
+
var ee = arr[0]
|
|
44
|
+
|
|
45
|
+
for (var j = 1; j < arr.length; j++) {
|
|
46
|
+
var event = arr[j]
|
|
47
|
+
var fn = listener(event, callback)
|
|
48
|
+
|
|
49
|
+
// listen to the event
|
|
50
|
+
ee.on(event, fn)
|
|
51
|
+
// push this listener to the list of cleanups
|
|
52
|
+
cleanups.push({
|
|
53
|
+
ee: ee,
|
|
54
|
+
event: event,
|
|
55
|
+
fn: fn,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function callback() {
|
|
61
|
+
cleanup()
|
|
62
|
+
done.apply(null, arguments)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function cleanup() {
|
|
66
|
+
var x
|
|
67
|
+
for (var i = 0; i < cleanups.length; i++) {
|
|
68
|
+
x = cleanups[i]
|
|
69
|
+
x.ee.removeListener(x.event, x.fn)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function thunk(fn) {
|
|
74
|
+
done = fn
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
thunk.cancel = cleanup
|
|
78
|
+
|
|
79
|
+
return thunk
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create the event listener.
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
function listener(event, done) {
|
|
88
|
+
return function onevent(arg1) {
|
|
89
|
+
var args = new Array(arguments.length)
|
|
90
|
+
var ee = this
|
|
91
|
+
var err = event === 'error'
|
|
92
|
+
? arg1
|
|
93
|
+
: null
|
|
94
|
+
|
|
95
|
+
// copy args to prevent arguments escaping scope
|
|
96
|
+
for (var i = 0; i < args.length; i++) {
|
|
97
|
+
args[i] = arguments[i]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
done(err, ee, event, args)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/***/ }),
|
|
106
|
+
|
|
107
|
+
/***/ 772:
|
|
108
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
109
|
+
|
|
8
110
|
/*!
|
|
9
111
|
* on-finished
|
|
10
112
|
* Copyright(c) 2013 Jonathan Ong
|
|
11
113
|
* Copyright(c) 2014 Douglas Christopher Wilson
|
|
12
114
|
* MIT Licensed
|
|
13
115
|
*/
|
|
14
|
-
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Module exports.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
module.exports = onFinished
|
|
125
|
+
module.exports.isFinished = isFinished
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Module dependencies.
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
var asyncHooks = tryRequireAsyncHooks()
|
|
133
|
+
var first = __nccwpck_require__(261)
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Variables.
|
|
137
|
+
* @private
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/* istanbul ignore next */
|
|
141
|
+
var defer = typeof setImmediate === 'function'
|
|
142
|
+
? setImmediate
|
|
143
|
+
: function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) }
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Invoke callback when the response has finished, useful for
|
|
147
|
+
* cleaning up resources afterwards.
|
|
148
|
+
*
|
|
149
|
+
* @param {object} msg
|
|
150
|
+
* @param {function} listener
|
|
151
|
+
* @return {object}
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
function onFinished (msg, listener) {
|
|
156
|
+
if (isFinished(msg) !== false) {
|
|
157
|
+
defer(listener, null, msg)
|
|
158
|
+
return msg
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// attach the listener to the message
|
|
162
|
+
attachListener(msg, wrap(listener))
|
|
163
|
+
|
|
164
|
+
return msg
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Determine if message is already finished.
|
|
169
|
+
*
|
|
170
|
+
* @param {object} msg
|
|
171
|
+
* @return {boolean}
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
function isFinished (msg) {
|
|
176
|
+
var socket = msg.socket
|
|
177
|
+
|
|
178
|
+
if (typeof msg.finished === 'boolean') {
|
|
179
|
+
// OutgoingMessage
|
|
180
|
+
return Boolean(msg.finished || (socket && !socket.writable))
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (typeof msg.complete === 'boolean') {
|
|
184
|
+
// IncomingMessage
|
|
185
|
+
return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable))
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// don't know
|
|
189
|
+
return undefined
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Attach a finished listener to the message.
|
|
194
|
+
*
|
|
195
|
+
* @param {object} msg
|
|
196
|
+
* @param {function} callback
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
function attachFinishedListener (msg, callback) {
|
|
201
|
+
var eeMsg
|
|
202
|
+
var eeSocket
|
|
203
|
+
var finished = false
|
|
204
|
+
|
|
205
|
+
function onFinish (error) {
|
|
206
|
+
eeMsg.cancel()
|
|
207
|
+
eeSocket.cancel()
|
|
208
|
+
|
|
209
|
+
finished = true
|
|
210
|
+
callback(error)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// finished on first message event
|
|
214
|
+
eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish)
|
|
215
|
+
|
|
216
|
+
function onSocket (socket) {
|
|
217
|
+
// remove listener
|
|
218
|
+
msg.removeListener('socket', onSocket)
|
|
219
|
+
|
|
220
|
+
if (finished) return
|
|
221
|
+
if (eeMsg !== eeSocket) return
|
|
222
|
+
|
|
223
|
+
// finished on first socket event
|
|
224
|
+
eeSocket = first([[socket, 'error', 'close']], onFinish)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (msg.socket) {
|
|
228
|
+
// socket already assigned
|
|
229
|
+
onSocket(msg.socket)
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// wait for socket to be assigned
|
|
234
|
+
msg.on('socket', onSocket)
|
|
235
|
+
|
|
236
|
+
if (msg.socket === undefined) {
|
|
237
|
+
// istanbul ignore next: node.js 0.8 patch
|
|
238
|
+
patchAssignSocket(msg, onSocket)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Attach the listener to the message.
|
|
244
|
+
*
|
|
245
|
+
* @param {object} msg
|
|
246
|
+
* @return {function}
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
function attachListener (msg, listener) {
|
|
251
|
+
var attached = msg.__onFinished
|
|
252
|
+
|
|
253
|
+
// create a private single listener with queue
|
|
254
|
+
if (!attached || !attached.queue) {
|
|
255
|
+
attached = msg.__onFinished = createListener(msg)
|
|
256
|
+
attachFinishedListener(msg, attached)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
attached.queue.push(listener)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Create listener on message.
|
|
264
|
+
*
|
|
265
|
+
* @param {object} msg
|
|
266
|
+
* @return {function}
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
function createListener (msg) {
|
|
271
|
+
function listener (err) {
|
|
272
|
+
if (msg.__onFinished === listener) msg.__onFinished = null
|
|
273
|
+
if (!listener.queue) return
|
|
274
|
+
|
|
275
|
+
var queue = listener.queue
|
|
276
|
+
listener.queue = null
|
|
277
|
+
|
|
278
|
+
for (var i = 0; i < queue.length; i++) {
|
|
279
|
+
queue[i](err, msg)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
listener.queue = []
|
|
284
|
+
|
|
285
|
+
return listener
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Patch ServerResponse.prototype.assignSocket for node.js 0.8.
|
|
290
|
+
*
|
|
291
|
+
* @param {ServerResponse} res
|
|
292
|
+
* @param {function} callback
|
|
293
|
+
* @private
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
// istanbul ignore next: node.js 0.8 patch
|
|
297
|
+
function patchAssignSocket (res, callback) {
|
|
298
|
+
var assignSocket = res.assignSocket
|
|
299
|
+
|
|
300
|
+
if (typeof assignSocket !== 'function') return
|
|
301
|
+
|
|
302
|
+
// res.on('socket', callback) is broken in 0.8
|
|
303
|
+
res.assignSocket = function _assignSocket (socket) {
|
|
304
|
+
assignSocket.call(this, socket)
|
|
305
|
+
callback(socket)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Try to require async_hooks
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
function tryRequireAsyncHooks () {
|
|
315
|
+
try {
|
|
316
|
+
return __nccwpck_require__(852)
|
|
317
|
+
} catch (e) {
|
|
318
|
+
return {}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Wrap function with async resource, if possible.
|
|
324
|
+
* AsyncResource.bind static method backported.
|
|
325
|
+
* @private
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
function wrap (fn) {
|
|
329
|
+
var res
|
|
330
|
+
|
|
331
|
+
// create anonymous resource
|
|
332
|
+
if (asyncHooks.AsyncResource) {
|
|
333
|
+
res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// incompatible node.js
|
|
337
|
+
if (!res || !res.runInAsyncScope) {
|
|
338
|
+
return fn
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// return bound function
|
|
342
|
+
return res.runInAsyncScope.bind(res, fn, null)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
/***/ }),
|
|
347
|
+
|
|
348
|
+
/***/ 852:
|
|
349
|
+
/***/ ((module) => {
|
|
350
|
+
|
|
351
|
+
module.exports = require("async_hooks");
|
|
352
|
+
|
|
353
|
+
/***/ })
|
|
354
|
+
|
|
355
|
+
/******/ });
|
|
356
|
+
/************************************************************************/
|
|
357
|
+
/******/ // The module cache
|
|
358
|
+
/******/ var __webpack_module_cache__ = {};
|
|
359
|
+
/******/
|
|
360
|
+
/******/ // The require function
|
|
361
|
+
/******/ function __nccwpck_require__(moduleId) {
|
|
362
|
+
/******/ // Check if module is in cache
|
|
363
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
364
|
+
/******/ if (cachedModule !== undefined) {
|
|
365
|
+
/******/ return cachedModule.exports;
|
|
366
|
+
/******/ }
|
|
367
|
+
/******/ // Create a new module (and put it into the cache)
|
|
368
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
369
|
+
/******/ // no module.id needed
|
|
370
|
+
/******/ // no module.loaded needed
|
|
371
|
+
/******/ exports: {}
|
|
372
|
+
/******/ };
|
|
373
|
+
/******/
|
|
374
|
+
/******/ // Execute the module function
|
|
375
|
+
/******/ var threw = true;
|
|
376
|
+
/******/ try {
|
|
377
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
|
|
378
|
+
/******/ threw = false;
|
|
379
|
+
/******/ } finally {
|
|
380
|
+
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
381
|
+
/******/ }
|
|
382
|
+
/******/
|
|
383
|
+
/******/ // Return the exports of the module
|
|
384
|
+
/******/ return module.exports;
|
|
385
|
+
/******/ }
|
|
386
|
+
/******/
|
|
387
|
+
/************************************************************************/
|
|
388
|
+
/******/ /* webpack/runtime/compat */
|
|
389
|
+
/******/
|
|
390
|
+
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
391
|
+
/******/
|
|
392
|
+
/************************************************************************/
|
|
393
|
+
/******/
|
|
394
|
+
/******/ // startup
|
|
395
|
+
/******/ // Load entry module and return exports
|
|
396
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
397
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(772);
|
|
398
|
+
/******/ module.exports = __webpack_exports__;
|
|
399
|
+
/******/
|
|
400
|
+
/******/ })()
|
|
401
|
+
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"on-finished","version":"2.4.1","license":"MIT","type":"commonjs"}
|
|
1
|
+
{"name":"on-finished","version":"2.4.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/compiled/open/index.d.ts
CHANGED
|
@@ -1,153 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare namespace open {
|
|
4
|
-
interface Options {
|
|
5
|
-
/**
|
|
6
|
-
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
|
7
|
-
|
|
8
|
-
Note that it waits for the app to exit, not just for the window to close.
|
|
9
|
-
|
|
10
|
-
On Windows, you have to explicitly specify an app for it to be able to wait.
|
|
11
|
-
|
|
12
|
-
@default false
|
|
13
|
-
*/
|
|
14
|
-
readonly wait?: boolean;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
__macOS only__
|
|
18
|
-
|
|
19
|
-
Do not bring the app to the foreground.
|
|
20
|
-
|
|
21
|
-
@default false
|
|
22
|
-
*/
|
|
23
|
-
readonly background?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
__macOS only__
|
|
27
|
-
|
|
28
|
-
Open a new instance of the app even it's already running.
|
|
29
|
-
|
|
30
|
-
A new instance is always opened on other platforms.
|
|
31
|
-
|
|
32
|
-
@default false
|
|
33
|
-
*/
|
|
34
|
-
readonly newInstance?: boolean;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
|
|
38
|
-
|
|
39
|
-
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`open.apps`](#openapps) which auto-detects the correct binary to use.
|
|
40
|
-
|
|
41
|
-
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
|
42
|
-
|
|
43
|
-
The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
|
|
44
|
-
*/
|
|
45
|
-
readonly app?: App | readonly App[];
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
|
49
|
-
|
|
50
|
-
We do not recommend setting this option. The convention for success is exit code zero.
|
|
51
|
-
|
|
52
|
-
@default false
|
|
53
|
-
*/
|
|
54
|
-
readonly allowNonzeroExitCode?: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface OpenAppOptions extends Omit<Options, 'app'> {
|
|
58
|
-
/**
|
|
59
|
-
Arguments passed to the app.
|
|
60
|
-
|
|
61
|
-
These arguments are app dependent. Check the app's documentation for what arguments it accepts.
|
|
62
|
-
*/
|
|
63
|
-
readonly arguments?: readonly string[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type AppName =
|
|
67
|
-
| 'chrome'
|
|
68
|
-
| 'firefox'
|
|
69
|
-
| 'edge';
|
|
70
|
-
|
|
71
|
-
type App = {
|
|
72
|
-
name: string | readonly string[];
|
|
73
|
-
arguments?: readonly string[];
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line no-redeclare
|
|
78
|
-
declare const open: {
|
|
79
|
-
/**
|
|
80
|
-
Open stuff like URLs, files, executables. Cross-platform.
|
|
81
|
-
|
|
82
|
-
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
|
83
|
-
|
|
84
|
-
There is a caveat for [double-quotes on Windows](https://github.com/sindresorhus/open#double-quotes-on-windows) where all double-quotes are stripped from the `target`.
|
|
85
|
-
|
|
86
|
-
@param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
|
|
87
|
-
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
|
88
|
-
|
|
89
|
-
@example
|
|
90
|
-
```
|
|
91
|
-
import open = require('./open');
|
|
92
|
-
|
|
93
|
-
// Opens the image in the default image viewer
|
|
94
|
-
await open('unicorn.png', {wait: true});
|
|
95
|
-
console.log('The image viewer app closed');
|
|
96
|
-
|
|
97
|
-
// Opens the url in the default browser
|
|
98
|
-
await open('https://sindresorhus.com');
|
|
99
|
-
|
|
100
|
-
// Opens the URL in a specified browser.
|
|
101
|
-
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
|
|
102
|
-
|
|
103
|
-
// Specify app arguments.
|
|
104
|
-
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
|
|
105
|
-
```
|
|
106
|
-
*/
|
|
107
|
-
(
|
|
108
|
-
target: string,
|
|
109
|
-
options?: open.Options
|
|
110
|
-
): Promise<ChildProcess>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
|
|
114
|
-
|
|
115
|
-
@example
|
|
116
|
-
```
|
|
117
|
-
import open = require('./open');
|
|
118
|
-
|
|
119
|
-
await open('https://google.com', {
|
|
120
|
-
app: {
|
|
121
|
-
name: open.apps.chrome
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
*/
|
|
126
|
-
apps: Record<open.AppName, string | readonly string[]>;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
Open an app. Cross-platform.
|
|
130
|
-
|
|
131
|
-
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
|
132
|
-
|
|
133
|
-
@param name - The app you want to open. Can be either builtin supported `open.apps` names or other name supported in platform.
|
|
134
|
-
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
|
135
|
-
|
|
136
|
-
@example
|
|
137
|
-
```
|
|
138
|
-
const {apps, openApp} = require('open');
|
|
139
|
-
|
|
140
|
-
// Open Firefox
|
|
141
|
-
await openApp(apps.firefox);
|
|
142
|
-
|
|
143
|
-
// Open Chrome incognito mode
|
|
144
|
-
await openApp(apps.chrome, {arguments: ['--incognito']});
|
|
145
|
-
|
|
146
|
-
// Open Xcode
|
|
147
|
-
await openApp('xcode');
|
|
148
|
-
```
|
|
149
|
-
*/
|
|
150
|
-
openApp: (name: open.App['name'], options?: open.OpenAppOptions) => Promise<ChildProcess>;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export = open;
|
|
1
|
+
export = any;
|