vite 3.1.3 → 3.2.0-beta.0
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.d.ts +38 -11
- package/dist/client/client.mjs +27 -22
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-42c2c4e4.js → dep-39e6741e.js} +0 -0
- package/dist/node/chunks/{dep-0fc42251.js → dep-553f6a62.js} +1 -1
- package/dist/node/chunks/{dep-557f29e6.js → dep-92763d7a.js} +1073 -655
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +85 -164
- package/dist/node/index.js +1 -1
- package/dist/node-cjs/publicUtils.cjs +30 -28
- package/package.json +23 -16
- package/src/client/client.ts +4 -3
- package/src/client/overlay.ts +23 -19
- package/src/client/tsconfig.json +1 -1
- package/types/alias.d.ts +6 -59
- package/types/anymatch.d.ts +1 -5
- package/types/chokidar.d.ts +6 -224
- package/types/commonjs.d.ts +1 -230
- package/types/connect.d.ts +1 -111
- package/types/customEvent.d.ts +5 -0
- package/types/dynamicImportVars.d.ts +1 -17
- package/types/http-proxy.d.ts +1 -250
- package/types/importMeta.d.ts +7 -14
- package/types/terser.d.ts +1 -250
- package/types/ws.d.ts +1 -553
- package/types/package.json +0 -3
- package/types/shims.d.ts +0 -96
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -47,35 +47,36 @@
|
|
|
47
47
|
"dev": "rimraf dist && pnpm run build-bundle -w",
|
|
48
48
|
"build": "rimraf dist && run-s build-bundle build-types",
|
|
49
49
|
"build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
|
|
50
|
-
"build-types": "run-s build-temp-types
|
|
51
|
-
"build-temp
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
50
|
+
"build-types": "run-s build-types-temp build-types-pre-patch build-types-roll build-types-post-patch build-types-check",
|
|
51
|
+
"build-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
|
|
52
|
+
"build-types-pre-patch": "tsx scripts/prePatchTypes.ts",
|
|
53
|
+
"build-types-roll": "api-extractor run && rimraf temp",
|
|
54
|
+
"build-types-post-patch": "tsx scripts/postPatchTypes.ts",
|
|
55
|
+
"build-types-check": "tsc --project tsconfig.check.json",
|
|
55
56
|
"lint": "eslint --cache --ext .ts src/**",
|
|
56
57
|
"format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
|
|
57
58
|
"prepublishOnly": "npm run build"
|
|
58
59
|
},
|
|
59
60
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
|
60
61
|
"dependencies": {
|
|
61
|
-
"esbuild": "^0.15.
|
|
62
|
-
"postcss": "^8.4.
|
|
62
|
+
"esbuild": "^0.15.9",
|
|
63
|
+
"postcss": "^8.4.17",
|
|
63
64
|
"resolve": "^1.22.1",
|
|
64
|
-
"rollup": "
|
|
65
|
+
"rollup": "^2.79.1"
|
|
65
66
|
},
|
|
66
67
|
"optionalDependencies": {
|
|
67
68
|
"fsevents": "~2.3.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@ampproject/remapping": "^2.2.0",
|
|
71
|
-
"@babel/parser": "^7.19.
|
|
72
|
-
"@babel/types": "^7.19.
|
|
72
|
+
"@babel/parser": "^7.19.3",
|
|
73
|
+
"@babel/types": "^7.19.3",
|
|
73
74
|
"@jridgewell/trace-mapping": "^0.3.15",
|
|
74
75
|
"@rollup/plugin-alias": "^3.1.9",
|
|
75
76
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
76
77
|
"@rollup/plugin-dynamic-import-vars": "^1.4.4",
|
|
77
78
|
"@rollup/plugin-json": "^4.1.0",
|
|
78
|
-
"@rollup/plugin-node-resolve": "14.0
|
|
79
|
+
"@rollup/plugin-node-resolve": "14.1.0",
|
|
79
80
|
"@rollup/plugin-typescript": "^8.5.0",
|
|
80
81
|
"@rollup/pluginutils": "^4.2.1",
|
|
81
82
|
"acorn": "^8.8.0",
|
|
@@ -96,15 +97,16 @@
|
|
|
96
97
|
"http-proxy": "^1.18.1",
|
|
97
98
|
"json5": "^2.2.1",
|
|
98
99
|
"launch-editor-middleware": "^2.6.0",
|
|
99
|
-
"magic-string": "^0.26.
|
|
100
|
+
"magic-string": "^0.26.5",
|
|
100
101
|
"micromatch": "^4.0.5",
|
|
101
|
-
"mlly": "^0.5.
|
|
102
|
+
"mlly": "^0.5.16",
|
|
102
103
|
"mrmime": "^1.0.1",
|
|
103
104
|
"okie": "^1.0.1",
|
|
104
105
|
"open": "^8.4.0",
|
|
105
106
|
"parse5": "^7.1.1",
|
|
106
107
|
"periscopic": "^3.0.4",
|
|
107
108
|
"picocolors": "^1.0.0",
|
|
109
|
+
"picomatch": "^2.3.1",
|
|
108
110
|
"postcss-import": "^15.0.0",
|
|
109
111
|
"postcss-load-config": "^4.0.1",
|
|
110
112
|
"postcss-modules": "^5.0.0",
|
|
@@ -113,17 +115,19 @@
|
|
|
113
115
|
"source-map-js": "^1.0.2",
|
|
114
116
|
"source-map-support": "^0.5.21",
|
|
115
117
|
"strip-ansi": "^7.0.1",
|
|
116
|
-
"strip-literal": "^0.4.
|
|
118
|
+
"strip-literal": "^0.4.2",
|
|
117
119
|
"tsconfck": "^2.0.1",
|
|
118
120
|
"tslib": "^2.4.0",
|
|
121
|
+
"dep-types": "link:./src/types",
|
|
119
122
|
"types": "link:./types",
|
|
120
123
|
"ufo": "^0.8.5",
|
|
121
|
-
"ws": "^8.
|
|
124
|
+
"ws": "^8.9.0"
|
|
122
125
|
},
|
|
123
126
|
"peerDependencies": {
|
|
124
127
|
"less": "*",
|
|
125
128
|
"sass": "*",
|
|
126
129
|
"stylus": "*",
|
|
130
|
+
"sugarss": "*",
|
|
127
131
|
"terser": "^5.4.0"
|
|
128
132
|
},
|
|
129
133
|
"peerDependenciesMeta": {
|
|
@@ -136,6 +140,9 @@
|
|
|
136
140
|
"less": {
|
|
137
141
|
"optional": true
|
|
138
142
|
},
|
|
143
|
+
"sugarss": {
|
|
144
|
+
"optional": true
|
|
145
|
+
},
|
|
139
146
|
"terser": {
|
|
140
147
|
"optional": true
|
|
141
148
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -364,6 +364,7 @@ export function updateStyle(id: string, content: string): void {
|
|
|
364
364
|
if (!style) {
|
|
365
365
|
style = document.createElement('style')
|
|
366
366
|
style.setAttribute('type', 'text/css')
|
|
367
|
+
style.setAttribute('data-vite-dev-id', id)
|
|
367
368
|
style.innerHTML = content
|
|
368
369
|
document.head.appendChild(style)
|
|
369
370
|
} else {
|
|
@@ -545,10 +546,10 @@ export function createHotContext(ownerPath: string): ViteHotContext {
|
|
|
545
546
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
546
547
|
decline() {},
|
|
547
548
|
|
|
549
|
+
// tell the server to re-perform hmr propagation from this module as root
|
|
548
550
|
invalidate() {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
location.reload()
|
|
551
|
+
notifyListeners('vite:invalidate', { path: ownerPath })
|
|
552
|
+
this.send('vite:invalidate', { path: ownerPath })
|
|
552
553
|
},
|
|
553
554
|
|
|
554
555
|
// custom events
|
package/src/client/overlay.ts
CHANGED
|
@@ -9,6 +9,17 @@ const template = /*html*/ `
|
|
|
9
9
|
left: 0;
|
|
10
10
|
width: 100%;
|
|
11
11
|
height: 100%;
|
|
12
|
+
|
|
13
|
+
--monospace: 'SFMono-Regular', Consolas,
|
|
14
|
+
'Liberation Mono', Menlo, Courier, monospace;
|
|
15
|
+
--red: #ff5555;
|
|
16
|
+
--yellow: #e2aa53;
|
|
17
|
+
--purple: #cfa4ff;
|
|
18
|
+
--cyan: #2dd9da;
|
|
19
|
+
--dim: #c9c9c9;
|
|
20
|
+
|
|
21
|
+
--window-background: #181818;
|
|
22
|
+
--window-color: #d8d8d8;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
.backdrop {
|
|
@@ -21,24 +32,17 @@ const template = /*html*/ `
|
|
|
21
32
|
overflow-y: scroll;
|
|
22
33
|
margin: 0;
|
|
23
34
|
background: rgba(0, 0, 0, 0.66);
|
|
24
|
-
--monospace: 'SFMono-Regular', Consolas,
|
|
25
|
-
'Liberation Mono', Menlo, Courier, monospace;
|
|
26
|
-
--red: #ff5555;
|
|
27
|
-
--yellow: #e2aa53;
|
|
28
|
-
--purple: #cfa4ff;
|
|
29
|
-
--cyan: #2dd9da;
|
|
30
|
-
--dim: #c9c9c9;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
.window {
|
|
34
38
|
font-family: var(--monospace);
|
|
35
39
|
line-height: 1.5;
|
|
36
40
|
width: 800px;
|
|
37
|
-
color:
|
|
41
|
+
color: var(--window-color);
|
|
38
42
|
margin: 30px auto;
|
|
39
43
|
padding: 25px 40px;
|
|
40
44
|
position: relative;
|
|
41
|
-
background:
|
|
45
|
+
background: var(--window-background);
|
|
42
46
|
border-radius: 6px 6px 8px 8px;
|
|
43
47
|
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
|
44
48
|
overflow: hidden;
|
|
@@ -108,13 +112,13 @@ code {
|
|
|
108
112
|
cursor: pointer;
|
|
109
113
|
}
|
|
110
114
|
</style>
|
|
111
|
-
<div class="backdrop">
|
|
112
|
-
<div class="window">
|
|
113
|
-
<pre class="message"><span class="plugin"></span><span class="message-body"></span></pre>
|
|
114
|
-
<pre class="file"></pre>
|
|
115
|
-
<pre class="frame"></pre>
|
|
116
|
-
<pre class="stack"></pre>
|
|
117
|
-
<div class="tip">
|
|
115
|
+
<div class="backdrop" part="backdrop">
|
|
116
|
+
<div class="window" part="window">
|
|
117
|
+
<pre class="message" part="message"><span class="plugin"></span><span class="message-body"></span></pre>
|
|
118
|
+
<pre class="file" part="file"></pre>
|
|
119
|
+
<pre class="frame" part="frame"></pre>
|
|
120
|
+
<pre class="stack" part="stack"></pre>
|
|
121
|
+
<div class="tip" part="tip">
|
|
118
122
|
Click outside or fix the code to dismiss.<br>
|
|
119
123
|
You can also disable this overlay by setting
|
|
120
124
|
<code>server.hmr.overlay</code> to <code>false</code> in <code>vite.config.js.</code>
|
|
@@ -132,7 +136,7 @@ const { HTMLElement = class {} as typeof globalThis.HTMLElement } = globalThis
|
|
|
132
136
|
export class ErrorOverlay extends HTMLElement {
|
|
133
137
|
root: ShadowRoot
|
|
134
138
|
|
|
135
|
-
constructor(err: ErrorPayload['err']) {
|
|
139
|
+
constructor(err: ErrorPayload['err'], links = true) {
|
|
136
140
|
super()
|
|
137
141
|
this.root = this.attachShadow({ mode: 'open' })
|
|
138
142
|
this.root.innerHTML = template
|
|
@@ -149,7 +153,7 @@ export class ErrorOverlay extends HTMLElement {
|
|
|
149
153
|
|
|
150
154
|
const [file] = (err.loc?.file || err.id || 'unknown file').split(`?`)
|
|
151
155
|
if (err.loc) {
|
|
152
|
-
this.text('.file', `${file}:${err.loc.line}:${err.loc.column}`,
|
|
156
|
+
this.text('.file', `${file}:${err.loc.line}:${err.loc.column}`, links)
|
|
153
157
|
} else if (err.id) {
|
|
154
158
|
this.text('.file', file)
|
|
155
159
|
}
|
|
@@ -157,7 +161,7 @@ export class ErrorOverlay extends HTMLElement {
|
|
|
157
161
|
if (hasFrame) {
|
|
158
162
|
this.text('.frame', err.frame!.trim())
|
|
159
163
|
}
|
|
160
|
-
this.text('.stack', err.stack,
|
|
164
|
+
this.text('.stack', err.stack, links)
|
|
161
165
|
|
|
162
166
|
this.root.querySelector('.window')!.addEventListener('click', (e) => {
|
|
163
167
|
e.stopPropagation()
|
package/src/client/tsconfig.json
CHANGED
package/types/alias.d.ts
CHANGED
|
@@ -1,59 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The MIT License (MIT)
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in
|
|
19
|
-
all copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
-
THE SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import type { PluginHooks } from 'rollup'
|
|
31
|
-
|
|
32
|
-
export interface Alias {
|
|
33
|
-
find: string | RegExp
|
|
34
|
-
replacement: string
|
|
35
|
-
/**
|
|
36
|
-
* Instructs the plugin to use an alternative resolving algorithm,
|
|
37
|
-
* rather than the Rollup's resolver.
|
|
38
|
-
* @default null
|
|
39
|
-
*/
|
|
40
|
-
customResolver?: ResolverFunction | ResolverObject | null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type ResolverFunction = PluginHooks['resolveId']
|
|
44
|
-
|
|
45
|
-
export interface ResolverObject {
|
|
46
|
-
buildStart?: PluginHooks['buildStart']
|
|
47
|
-
resolveId: ResolverFunction
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Specifies an `Object`, or an `Array` of `Object`,
|
|
52
|
-
* which defines aliases used to replace values in `import` or `require` statements.
|
|
53
|
-
* With either format, the order of the entries is important,
|
|
54
|
-
* in that the first defined rules are applied first.
|
|
55
|
-
*
|
|
56
|
-
* This is passed to \@rollup/plugin-alias as the "entries" field
|
|
57
|
-
* https://github.com/rollup/plugins/tree/master/packages/alias#entries
|
|
58
|
-
*/
|
|
59
|
-
export type AliasOptions = readonly Alias[] | { [find: string]: string }
|
|
1
|
+
export type {
|
|
2
|
+
Alias,
|
|
3
|
+
ResolverFunction,
|
|
4
|
+
ResolverObject,
|
|
5
|
+
AliasOptions
|
|
6
|
+
} from '../dist/node'
|
package/types/anymatch.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export type AnymatchFn
|
|
2
|
-
export type AnymatchPattern = string | RegExp | AnymatchFn
|
|
3
|
-
type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]
|
|
4
|
-
|
|
5
|
-
export { AnymatchMatcher as Matcher }
|
|
1
|
+
export type { AnymatchFn, AnymatchPattern, Matcher } from '../dist/node'
|
package/types/chokidar.d.ts
CHANGED
|
@@ -1,228 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
export type {
|
|
2
|
+
FSWatcher,
|
|
3
|
+
WatchOptions,
|
|
4
|
+
AwaitWriteFinishOptions
|
|
5
|
+
} from '../dist/node'
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
// MIT Licensed https://github.com/paulmillr/chokidar/blob/master/LICENSE
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
The MIT License (MIT)
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2012-2019 Paul Miller (https://paulmillr.com), Elan Shanker
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the “Software”), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in
|
|
19
|
-
all copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
-
THE SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
/// <reference types="node" />
|
|
30
|
-
|
|
31
|
-
import type * as fs from 'node:fs'
|
|
32
|
-
import { EventEmitter } from 'node:events'
|
|
33
|
-
import type { Matcher } from './anymatch'
|
|
34
|
-
|
|
35
|
-
export class FSWatcher extends EventEmitter implements fs.FSWatcher {
|
|
36
|
-
options: WatchOptions
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Constructs a new FSWatcher instance with optional WatchOptions parameter.
|
|
40
|
-
*/
|
|
41
|
-
constructor(options?: WatchOptions)
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
|
|
45
|
-
* string.
|
|
46
|
-
*/
|
|
47
|
-
add(paths: string | ReadonlyArray<string>): this
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Stop watching files, directories, or glob patterns. Takes an array of strings or just one
|
|
51
|
-
* string.
|
|
52
|
-
*/
|
|
53
|
-
unwatch(paths: string | ReadonlyArray<string>): this
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns an object representing all the paths on the file system being watched by this
|
|
57
|
-
* `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
|
|
58
|
-
* the `cwd` option was used), and the values are arrays of the names of the items contained in
|
|
59
|
-
* each directory.
|
|
60
|
-
*/
|
|
61
|
-
getWatched(): {
|
|
62
|
-
[directory: string]: string[]
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Removes all listeners from watched files.
|
|
67
|
-
*/
|
|
68
|
-
close(): Promise<void>
|
|
69
|
-
|
|
70
|
-
on(
|
|
71
|
-
event: 'add' | 'addDir' | 'change',
|
|
72
|
-
listener: (path: string, stats?: fs.Stats) => void
|
|
73
|
-
): this
|
|
74
|
-
|
|
75
|
-
on(
|
|
76
|
-
event: 'all',
|
|
77
|
-
listener: (
|
|
78
|
-
eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
|
|
79
|
-
path: string,
|
|
80
|
-
stats?: fs.Stats
|
|
81
|
-
) => void
|
|
82
|
-
): this
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Error occurred
|
|
86
|
-
*/
|
|
87
|
-
on(event: 'error', listener: (error: Error) => void): this
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Exposes the native Node `fs.FSWatcher events`
|
|
91
|
-
*/
|
|
92
|
-
on(
|
|
93
|
-
event: 'raw',
|
|
94
|
-
listener: (eventName: string, path: string, details: any) => void
|
|
95
|
-
): this
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Fires when the initial scan is complete
|
|
99
|
-
*/
|
|
100
|
-
on(event: 'ready', listener: () => void): this
|
|
101
|
-
|
|
102
|
-
on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this
|
|
103
|
-
|
|
104
|
-
on(event: string, listener: (...args: any[]) => void): this
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface WatchOptions {
|
|
108
|
-
/**
|
|
109
|
-
* Indicates whether the process should continue to run as long as files are being watched. If
|
|
110
|
-
* set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
|
|
111
|
-
* even if the process continues to run.
|
|
112
|
-
*/
|
|
113
|
-
persistent?: boolean
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
|
|
117
|
-
* be ignored. The whole relative or absolute path is tested, not just filename. If a function
|
|
118
|
-
* with two arguments is provided, it gets called twice per path - once with a single argument
|
|
119
|
-
* (the path), second time with two arguments (the path and the
|
|
120
|
-
* [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
|
|
121
|
-
*/
|
|
122
|
-
ignored?: Matcher
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* If set to `false` then `add`/`addDir` events are also emitted for matching paths while
|
|
126
|
-
* instantiating the watching as chokidar discovers these file paths (before the `ready` event).
|
|
127
|
-
*/
|
|
128
|
-
ignoreInitial?: boolean
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* When `false`, only the symlinks themselves will be watched for changes instead of following
|
|
132
|
-
* the link references and bubbling events through the link's path.
|
|
133
|
-
*/
|
|
134
|
-
followSymlinks?: boolean
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* The base directory from which watch `paths` are to be derived. Paths emitted with events will
|
|
138
|
-
* be relative to this.
|
|
139
|
-
*/
|
|
140
|
-
cwd?: string
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* If set to true then the strings passed to .watch() and .add() are treated as literal path
|
|
144
|
-
* names, even if they look like globs.
|
|
145
|
-
*
|
|
146
|
-
* @default false
|
|
147
|
-
*/
|
|
148
|
-
disableGlobbing?: boolean
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
|
|
152
|
-
* utilization, consider setting this to `false`. It is typically necessary to **set this to
|
|
153
|
-
* `true` to successfully watch files over a network**, and it may be necessary to successfully
|
|
154
|
-
* watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
|
|
155
|
-
* the `useFsEvents` default.
|
|
156
|
-
*/
|
|
157
|
-
usePolling?: boolean
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
|
|
161
|
-
* and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on
|
|
162
|
-
* OS X, `usePolling: true` becomes the default.
|
|
163
|
-
*/
|
|
164
|
-
useFsEvents?: boolean
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
|
|
168
|
-
* may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
|
|
169
|
-
* provided even in cases where it wasn't already available from the underlying watch events.
|
|
170
|
-
*/
|
|
171
|
-
alwaysStat?: boolean
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* If set, limits how many levels of subdirectories will be traversed.
|
|
175
|
-
*/
|
|
176
|
-
depth?: number
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Interval of file system polling.
|
|
180
|
-
*/
|
|
181
|
-
interval?: number
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Interval of file system polling for binary files. ([see list of binary extensions](https://gi
|
|
185
|
-
* thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
|
|
186
|
-
*/
|
|
187
|
-
binaryInterval?: number
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Indicates whether to watch files that don't have read permissions if possible. If watching
|
|
191
|
-
* fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
|
|
192
|
-
* silently.
|
|
193
|
-
*/
|
|
194
|
-
ignorePermissionErrors?: boolean
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
|
|
198
|
-
* that occur when using editors that use "atomic writes" instead of writing directly to the
|
|
199
|
-
* source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
|
|
200
|
-
* event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
|
|
201
|
-
* you can override it by setting `atomic` to a custom value, in milliseconds.
|
|
202
|
-
*/
|
|
203
|
-
atomic?: boolean | number
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* can be set to an object in order to adjust timing params:
|
|
207
|
-
*/
|
|
208
|
-
awaitWriteFinish?: AwaitWriteFinishOptions | boolean
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export interface AwaitWriteFinishOptions {
|
|
212
|
-
/**
|
|
213
|
-
* Amount of time in milliseconds for a file size to remain constant before emitting its event.
|
|
214
|
-
*/
|
|
215
|
-
stabilityThreshold?: number
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* File size polling interval.
|
|
219
|
-
*/
|
|
220
|
-
pollInterval?: number
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* produces an instance of `FSWatcher`.
|
|
225
|
-
*/
|
|
7
|
+
import type { FSWatcher, WatchOptions } from '../dist/node'
|
|
226
8
|
export function watch(
|
|
227
9
|
paths: string | ReadonlyArray<string>,
|
|
228
10
|
options?: WatchOptions
|