@ohos-ports/rsbuild-core 2.2.9-beta.0 → 2.3.3-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/README.md +10 -0
- package/bin/rsbuild.js +3 -1
- package/compiled/@rstackjs/load-config/index.d.ts +10 -1
- package/compiled/@rstackjs/load-config/package.json +1 -1
- package/compiled/chokidar/index.d.ts +448 -161
- package/compiled/chokidar/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.d.ts +16 -2
- package/compiled/html-rspack-plugin/index.js +78 -28
- package/compiled/http-proxy-middleware/index.d.ts +10 -10
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/jiti/dist/babel.cjs +1 -1
- package/compiled/jiti/lib/jiti-cli.mjs +0 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/declaration.d.ts +2 -2
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +1 -0
- package/compiled/ws/index.d.ts +4 -0
- package/compiled/ws/package.json +1 -1
- package/dist/1.js +85 -0
- package/dist/chokidar.js +1 -1
- package/dist/client/hmr.js +31 -8
- package/dist/client/overlay.js +15 -11
- package/dist/cssUrlLoader.mjs +18 -7
- package/dist/defaultConfig.d.ts +7 -2
- package/dist/helpers/compilation.d.ts +2 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/path.d.ts +9 -0
- package/dist/helpers/stats.d.ts +1 -0
- package/dist/helpers/workspace.d.ts +1 -0
- package/dist/hooks.d.ts +2 -1
- package/dist/http-proxy-middleware.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/launch-editor-middleware.js +1 -1
- package/dist/loader/cssUrlLoader.d.ts +1 -0
- package/dist/m.js +1902 -1681
- package/dist/m.js.LICENSE.txt +0 -13
- package/dist/manifest-plugin.js +1 -1
- package/dist/memfs.js +1 -1
- package/dist/open.js +2 -2
- package/dist/plugins/fileSize.d.ts +11 -0
- package/dist/server/assets-middleware/getFileFromUrl.d.ts +4 -1
- package/dist/server/assets-middleware/index.d.ts +2 -1
- package/dist/server/assets-middleware/middleware.d.ts +4 -6
- package/dist/server/assets-middleware/setupMemoryFileSystemCleanup.d.ts +3 -0
- package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +1 -2
- package/dist/server/assets-middleware/setupWriteToDisk.d.ts +19 -7
- package/dist/server/browserLogs.d.ts +5 -2
- package/dist/server/devMiddlewares.d.ts +1 -1
- package/dist/server/gracefulShutdown.d.ts +1 -2
- package/dist/server/helper.d.ts +6 -3
- package/dist/server/hostCheck.d.ts +7 -0
- package/dist/server/socketServer.d.ts +18 -2
- package/dist/server/watchFiles.d.ts +3 -1
- package/dist/sirv.js +3 -2
- package/dist/trace-mapping.js +16 -14
- package/dist/transformLoader.mjs +10 -10
- package/dist/transformRawLoader.mjs +2 -2
- package/dist/types/config.d.ts +38 -6
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/plugin.d.ts +27 -4
- package/dist/types/rsbuild.d.ts +1 -1
- package/dist/workerLoader.mjs +3 -3
- package/dist/ws.js +2 -2
- package/package.json +9 -50
package/compiled/ws/index.d.ts
CHANGED
|
@@ -261,6 +261,8 @@ declare namespace WebSocket {
|
|
|
261
261
|
allowSynchronousEvents?: boolean | undefined;
|
|
262
262
|
autoPong?: boolean | undefined;
|
|
263
263
|
maxPayload?: number | undefined;
|
|
264
|
+
maxBufferedChunks?: number | undefined;
|
|
265
|
+
maxFragments?: number | undefined;
|
|
264
266
|
skipUTF8Validation?: boolean | undefined;
|
|
265
267
|
createConnection?: typeof createConnection | undefined;
|
|
266
268
|
finishRequest?: FinishRequestCallback | undefined;
|
|
@@ -344,6 +346,8 @@ declare namespace WebSocket {
|
|
|
344
346
|
clientTracking?: boolean | undefined;
|
|
345
347
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
346
348
|
maxPayload?: number | undefined;
|
|
349
|
+
maxBufferedChunks?: number | undefined;
|
|
350
|
+
maxFragments?: number | undefined;
|
|
347
351
|
skipUTF8Validation?: boolean | undefined;
|
|
348
352
|
WebSocket?: U | undefined;
|
|
349
353
|
}
|
package/compiled/ws/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ws","version":"8.18.
|
|
1
|
+
{"name":"ws","version":"8.18.2","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/1.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isAbsolute, join, relative, sep, win32 } from "node:path";
|
|
2
|
+
let isDeno = "u" > typeof Deno, isWindows = 'win32' === process.platform, JS_DIST_DIR = 'static/js', CSS_DIST_DIR = 'static/css', SVG_DIST_DIR = 'static/svg', FONT_DIST_DIR = 'static/font', WASM_DIST_DIR = 'static/wasm', IMAGE_DIST_DIR = 'static/image', MEDIA_DIST_DIR = 'static/media', ASSETS_DIST_DIR = 'static/assets', dirname = import.meta.dirname, LOADER_PATH = dirname, STATIC_PATH = join(dirname, '../static'), CLIENT_PATH = join(dirname, 'client'), COMPILED_PATH = join(dirname, '../compiled'), TS_CONFIG_FILE = 'tsconfig.json', HMR_SOCKET_PATH = '/rsbuild-hmr', RSBUILD_OUTPUTS_PATH = '.rsbuild', LOCALHOST = 'localhost', ALL_INTERFACES_IPV4 = '0.0.0.0', DEFAULT_STACK_TRACE = 'summary', DEFAULT_WEB_BROWSERSLIST = [
|
|
3
|
+
'chrome >= 107',
|
|
4
|
+
'edge >= 107',
|
|
5
|
+
'firefox >= 104',
|
|
6
|
+
'safari >= 16'
|
|
7
|
+
], DEFAULT_BROWSERSLIST = {
|
|
8
|
+
web: DEFAULT_WEB_BROWSERSLIST,
|
|
9
|
+
'web-worker': DEFAULT_WEB_BROWSERSLIST,
|
|
10
|
+
node: [
|
|
11
|
+
'node >= 20'
|
|
12
|
+
]
|
|
13
|
+
}, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /[?&]raw(?:&|=|$)/, INLINE_QUERY_REGEX = /[?&]inline(?:&|=|$)/, URL_QUERY_REGEX = /[?&]url(?:&|=|$)/, WORKER_QUERY_REGEX = /[?&]worker(?:&|=|$)/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
|
|
14
|
+
'woff',
|
|
15
|
+
'woff2',
|
|
16
|
+
'eot',
|
|
17
|
+
'ttf',
|
|
18
|
+
'otf',
|
|
19
|
+
'ttc'
|
|
20
|
+
], ASSET_EXTENSIONS = [
|
|
21
|
+
'webmanifest',
|
|
22
|
+
'pdf',
|
|
23
|
+
'txt'
|
|
24
|
+
], IMAGE_EXTENSIONS = [
|
|
25
|
+
'png',
|
|
26
|
+
'jpg',
|
|
27
|
+
'jpeg',
|
|
28
|
+
'pjpeg',
|
|
29
|
+
'pjp',
|
|
30
|
+
'gif',
|
|
31
|
+
'bmp',
|
|
32
|
+
'webp',
|
|
33
|
+
'ico',
|
|
34
|
+
'apng',
|
|
35
|
+
'avif',
|
|
36
|
+
'tif',
|
|
37
|
+
'tiff',
|
|
38
|
+
'jfif',
|
|
39
|
+
'cur',
|
|
40
|
+
'jxl'
|
|
41
|
+
], VIDEO_EXTENSIONS = [
|
|
42
|
+
'mp4',
|
|
43
|
+
'webm',
|
|
44
|
+
'ogg',
|
|
45
|
+
'mov'
|
|
46
|
+
], AUDIO_EXTENSIONS = [
|
|
47
|
+
'mp3',
|
|
48
|
+
'wav',
|
|
49
|
+
'flac',
|
|
50
|
+
'aac',
|
|
51
|
+
'm4a',
|
|
52
|
+
'opus'
|
|
53
|
+
], TRACK_EXTENSIONS = [
|
|
54
|
+
'vtt'
|
|
55
|
+
], LAZY_COMPILATION_IDENTIFIER = 'lazy-compilation-proxy', BROWSER_LOG_PREFIX = '[browser]';
|
|
56
|
+
function toRelativePath(base, filepath) {
|
|
57
|
+
let relativePath = relative(base, filepath);
|
|
58
|
+
return '' === relativePath ? `.${sep}` : relativePath.startsWith('.') ? relativePath : `.${sep}${relativePath}`;
|
|
59
|
+
}
|
|
60
|
+
function relativeWithin(parent, target) {
|
|
61
|
+
let relativePath = relative(parent, target);
|
|
62
|
+
if (!('..' === relativePath || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath))) return relativePath;
|
|
63
|
+
}
|
|
64
|
+
function getCommonParentPath(paths) {
|
|
65
|
+
if (1 === paths.length) return paths[0];
|
|
66
|
+
let uniquePaths = [
|
|
67
|
+
...new Set(paths)
|
|
68
|
+
];
|
|
69
|
+
if (1 === uniquePaths.length) return uniquePaths[0];
|
|
70
|
+
let [first, ...rest] = uniquePaths.map((p)=>p.split(sep)), common = [];
|
|
71
|
+
for(let i = 0; i < first.length; i++){
|
|
72
|
+
let segment = first[i];
|
|
73
|
+
if (rest.every((p)=>p[i] === segment)) common.push(segment);
|
|
74
|
+
else break;
|
|
75
|
+
}
|
|
76
|
+
return common.join(sep);
|
|
77
|
+
}
|
|
78
|
+
let getCompiledPath = (packageName)=>join(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>isAbsolute(filePath) ? filePath : join(base, filePath), getPathnameFromUrl = (url)=>{
|
|
79
|
+
try {
|
|
80
|
+
return url ? new URL(url, 'http://localhost').pathname : url;
|
|
81
|
+
} catch {
|
|
82
|
+
return url;
|
|
83
|
+
}
|
|
84
|
+
}, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.some((p)=>void 0 !== relativeWithin(p, curr)) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === sep ? filepath : filepath.replace(/\\/g, '/'), normalizeRuleConditionPath = (filepath)=>isWindows && 'string' == typeof filepath && filepath.includes('/') && win32.isAbsolute(filepath) ? filepath.replace(/\//g, '\\') : filepath;
|
|
85
|
+
export { ALL_INTERFACES_IPV4, ASSETS_DIST_DIR, ASSET_EXTENSIONS, AUDIO_EXTENSIONS, BROWSER_LOG_PREFIX, CLIENT_PATH, COMPILED_PATH, CSS_DIST_DIR, CSS_REGEX, DEFAULT_BROWSERSLIST, DEFAULT_STACK_TRACE, DEFAULT_WEB_BROWSERSLIST, FONT_DIST_DIR, FONT_EXTENSIONS, HMR_SOCKET_PATH, IMAGE_DIST_DIR, IMAGE_EXTENSIONS, INLINE_QUERY_REGEX, JS_DIST_DIR, JS_REGEX, LAZY_COMPILATION_IDENTIFIER, LOADER_PATH, LOCALHOST, MEDIA_DIST_DIR, NODE_MODULES_REGEX, PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, RAW_QUERY_REGEX, RSBUILD_OUTPUTS_PATH, SCRIPT_REGEX, STATIC_PATH, SVG_DIST_DIR, TRACK_EXTENSIONS, TS_CONFIG_FILE, URL_QUERY_REGEX, VIDEO_EXTENSIONS, WASM_DIST_DIR, WORKER_QUERY_REGEX, dedupeNestedPaths, ensureAbsolutePath, getCommonParentPath, getCompiledPath, getPathnameFromUrl, isDeno, isWindows, normalizeRuleConditionPath, relativeWithin, toPosixPath, toRelativePath };
|
package/dist/chokidar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! LICENSE: chokidar.js.LICENSE.txt */
|
|
2
|
-
import{definePropertyGetters as t,makeNamespaceObject as e}from"./rslib-runtime.js";import{EventEmitter as i}from"node:events";import{stat as s,unwatchFile as r,watch as a,watchFile as h}from"node:fs";import{lstat as n,open as o,readdir as l,realpath as d,stat as c}from"node:fs/promises";import{join as f,relative as m,resolve as p,sep as _}from"node:path";import{Readable as u}from"node:stream";import{type as w}from"node:os";import*as g from"node:path";var y={};e(y),t(y,{FSWatcher:()=>tx,WatchHelper:()=>tE,default:()=>tW,watch:()=>tk});let v="files",P="directories",b="files_directories",E={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:v,lstat:!1,depth:0x80000000,alwaysStat:!1,highWaterMark:4096};Object.freeze(E);let x="READDIRP_RECURSIVE_ERROR",k=new Set(["ENOENT","EPERM","EACCES","ELOOP",x]),W=[P,"all",b,v],D=new Set([P,"all",b]),F=new Set(["all",b,v]),S="win32"===process.platform,R=t=>!0,I=t=>{if(void 0===t)return R;if("function"==typeof t)return t;if("string"==typeof t){let e=t.trim();return t=>t.basename===e}if(Array.isArray(t)){let e=t.map(t=>t.trim());return t=>e.some(e=>t.basename===e)}return R};class z extends u{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...E,...t},{root:i,type:s}=e;this._fileFilter=I(e.fileFilter),this._directoryFilter=I(e.directoryFilter);let r=e.lstat?n:c;S?this._stat=t=>r(t,{bigint:!0}):this._stat=r,this._maxDepth=null!=e.depth&&Number.isSafeInteger(e.depth)?e.depth:E.depth,this._wantsDir=!!s&&D.has(s),this._wantsFile=!!s&&F.has(s),this._wantsEverything="all"===s,this._root=p(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:s,depth:r}=e,a=i.splice(0,t).map(t=>this._formatEntry(t,s));for(let e of(await Promise.all(a))){if(!e)continue;if(this.destroyed)return;let i=await this._getEntryType(e);"directory"===i&&this._directoryFilter(e)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(e.fullPath,r+1)),this._wantsDir&&(this.push(e),t--)):("file"===i||this._includeAsFile(e))&&this._fileFilter(e)&&this._wantsFile&&(this.push(e),t--)}}else{let t=this.parents.pop();if(!t){this.push(null);break}if(this.parent=await t,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await l(t,this._rdOptions)}catch(t){this._onError(t)}return{files:i,depth:e,path:t}}async _formatEntry(t,e){let i,s=this._isDirent?t.name:t;try{let r=p(f(e,s));(i={path:m(this._root,r),fullPath:r,basename:s})[this._statsProp]=this._isDirent?t:await this._stat(r)}catch(t){this._onError(t);return}return i}_onError(t){k.has(t.code)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let e=t.fullPath;try{let t=await d(e),i=await n(t);if(i.isFile())return"file";if(i.isDirectory()){let i=t.length;if(e.startsWith(t)&&e.substr(i,1)===_){let i=Error(`Circular symlink detected: "${e}" points to "${t}"`);return i.code=x,this._onError(i)}return"directory"}}catch(t){return this._onError(t),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}let j=()=>{},C=process.platform,M="win32"===C,T="darwin"===C,A="linux"===C,O="freebsd"===C,N="OS400"===w(),H="all",U="ready",L="add",$="change",K="addDir",q="unlink",V="unlinkDir",G="raw",B="error",J={lstat:n,stat:c},Q="listeners",X="errHandlers",Y="rawEmitters",Z=[Q,X,Y],tt=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),te=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},ti=(t,e,i)=>{let s=t[e];s instanceof Set||(t[e]=s=new Set([s])),s.add(i)},ts=(t,e,i)=>{let s=t[e];s instanceof Set?s.delete(i):s===i&&delete t[e]},tr=t=>t instanceof Set?0===t.size:!t,ta=new Map;function th(t,e,i,s,r){try{return a(t,{persistent:e.persistent},(e,s)=>{i(t),r(e,s,{watchedPath:t}),s&&t!==s&&tn(g.resolve(t,s),Q,g.join(t,s))})}catch(t){s(t);return}}let tn=(t,e,i,s,r)=>{let a=ta.get(t);a&&te(a[e],t=>{t(i,s,r)})},to=new Map;class tl{fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i,s=this.fsw.options,a=g.dirname(t),n=g.basename(t);this.fsw._getWatchedDir(a).add(n);let l=g.resolve(t),d={persistent:s.persistent};if(e||(e=j),s.usePolling)d.interval=s.interval!==s.binaryInterval&&tt.has(g.extname(n).slice(1).toLowerCase())?s.binaryInterval:s.interval,i=((t,e,i,s)=>{let{listener:a,rawEmitter:n}=s,o=to.get(e),l=o&&o.options;return l&&(l.persistent<i.persistent||l.interval>i.interval)&&(r(e),o=void 0),o?(ti(o,Q,a),ti(o,Y,n)):(o={listeners:a,rawEmitters:n,options:i,watcher:h(e,i,(i,s)=>{te(o.rawEmitters,t=>{t($,e,{curr:i,prev:s})});let r=i.mtimeMs;(i.size!==s.size||r>s.mtimeMs||0===r)&&te(o.listeners,e=>e(t,i))})},to.set(e,o)),()=>{ts(o,Q,a),ts(o,Y,n),tr(o.listeners)&&(to.delete(e),r(e),o.options=o.watcher=void 0,Object.freeze(o))}})(t,l,d,{listener:e,rawEmitter:this.fsw._emitRaw});else i=((t,e,i,s)=>{let r,{listener:a,errHandler:h,rawEmitter:n}=s,l=ta.get(e);if(!i.persistent){if(!(r=th(t,i,a,h,n)))return;return r.close.bind(r)}if(l)ti(l,Q,a),ti(l,X,h),ti(l,Y,n);else{if(!(r=th(t,i,tn.bind(null,e,Q),h,tn.bind(null,e,Y))))return;r.on(B,async i=>{let s=tn.bind(null,e,X);if(l&&(l.watcherUnusable=!0),M&&"EPERM"===i.code)try{let e=await o(t,"r");await e.close(),s(i)}catch(t){}else s(i)}),l={listeners:a,errHandlers:h,rawEmitters:n,watcher:r},ta.set(e,l)}return()=>{if(ts(l,Q,a),ts(l,X,h),ts(l,Y,n),tr(l.listeners)){let t;l.watcher.close(),ta.delete(e),Z.forEach((t=l,e=>{let i=t[e];i instanceof Set?i.clear():delete t[e]})),l.watcher=void 0,Object.freeze(l)}}})(t,l,d,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return i}_handleFile(t,e,i){if(this.fsw.closed)return;let s=g.dirname(t),r=g.basename(t),a=this.fsw._getWatchedDir(s),h=e;if(a.has(r))return;let n=async(e,i)=>{if(this.fsw._throttle("watch",t,5))if(i&&0!==i.mtimeMs){if(a.has(r)){let e=i.atimeMs,s=i.mtimeMs;(!e||e<=s||s!==h.mtimeMs)&&this.fsw._emit($,t,i),h=i}}else try{let i=await c(t);if(this.fsw.closed)return;let s=i.atimeMs,r=i.mtimeMs;if((!s||s<=r||r!==h.mtimeMs)&&this.fsw._emit($,t,i),(T||A||O)&&h.ino!==i.ino){this.fsw._closeFile(e),h=i;let s=this._watchWithNodeFs(t,n);s&&this.fsw._addPathCloser(e,s)}else h=i}catch(t){this.fsw._remove(s,r)}},o=this._watchWithNodeFs(t,n);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(L,t,0))return;this.fsw._emit(L,t,e)}return o}async _handleSymlink(t,e,i,s){if(this.fsw.closed)return;let r=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){let e;this.fsw._incrReadyCount();try{e=await d(i)}catch(t){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;return a.has(s)?this.fsw._symlinkPaths.get(r)!==e&&(this.fsw._symlinkPaths.set(r,e),this.fsw._emit($,i,t.stats)):(a.add(s),this.fsw._symlinkPaths.set(r,e),this.fsw._emit(L,i,t.stats)),this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(r))return!0;this.fsw._symlinkPaths.set(r,!0)}_handleRead(t,e,i,s,r,a,h){t=g.join(t,"");let n=s?`${t}:${s}`:t;if(!(h=this.fsw._throttle("readdir",n,1e3)))return;let o=this.fsw._getWatchedDir(i.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:t=>i.filterPath(t),directoryFilter:t=>i.filterDir(t)});if(d)return d.on("data",async h=>{if(this.fsw.closed){d=void 0;return}let n=h.path,c=g.join(t,n);if(l.add(n),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,c,n))){if(this.fsw.closed){d=void 0;return}n!==s&&(s||o.has(n))||(this.fsw._incrReadyCount(),c=g.join(r,g.relative(r,c)),this._addToNodeFs(c,e,i,a+1))}}).on(B,this._boundHandleError),new Promise((e,n)=>{if(!d)return n();d.once("end",()=>{if(this.fsw.closed){d=void 0;return}let n=!!h&&h.clear();e(void 0),o.getChildren().filter(e=>e!==t&&!l.has(e)).forEach(e=>{this.fsw._remove(t,e)}),d=void 0,n&&this._handleRead(t,!1,i,s,r,a,h)})})}async _handleDir(t,e,i,s,r,a,h){let n,o,l=this.fsw._getWatchedDir(g.dirname(t)),d=l.has(g.basename(t));i&&this.fsw.options.ignoreInitial||r||d||this.fsw._emit(K,t,e),l.add(g.basename(t)),this.fsw._getWatchedDir(t);let c=this.fsw.options.depth;if((null==c||s<=c)&&!this.fsw._symlinkPaths.has(h)){if(!r&&(await this._handleRead(t,i,a,r,t,s,n),this.fsw.closed))return;o=this._watchWithNodeFs(t,(e,i)=>{i&&0===i.mtimeMs||this._handleRead(e,!1,a,r,t,s,n)})}return o}async _addToNodeFs(t,e,i,s,r){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let h=this.fsw._getWatchHelpers(t);i&&(h.filterPath=t=>i.filterPath(t),h.filterDir=t=>i.filterDir(t));try{let i,n=await J[h.statMethod](h.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(h.watchPath,n))return a(),!1;let o=this.fsw.options.followSymlinks;if(n.isDirectory()){let a=g.resolve(t),l=o?await d(t):t;if(this.fsw.closed||(i=await this._handleDir(h.watchPath,n,e,s,r,h,l),this.fsw.closed))return;a!==l&&void 0!==l&&this.fsw._symlinkPaths.set(a,l)}else if(n.isSymbolicLink()){let r=o?await d(t):t;if(this.fsw.closed)return;let a=g.dirname(h.watchPath);if(this.fsw._getWatchedDir(a).add(h.watchPath),this.fsw._emit(L,h.watchPath,n),i=await this._handleDir(a,n,e,s,t,h,r),this.fsw.closed)return;void 0!==r&&this.fsw._symlinkPaths.set(g.resolve(t),r)}else i=this._handleFile(h.watchPath,n,e);return a(),i&&this.fsw._addPathCloser(t,i),!1}catch(e){if(this.fsw._handleError(e))return a(),t}}}let td=/\\/g,tc=/\/\//g,tf=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,tm=/^\.[/\\]/;function tp(t){return Array.isArray(t)?t:[t]}let t_=t=>"object"==typeof t&&null!==t&&!(t instanceof RegExp);function tu(t,e,i){let s=function(t){if("string"!=typeof t)throw Error("string expected");t=(t=g.normalize(t)).replace(/\\/g,"/");let e=!1;return t.startsWith("//")&&(e=!0),t=t.replace(tc,"/"),e&&(t="/"+t),t}(e);for(let e=0;e<t.length;e++)if((0,t[e])(s,i))return!0;return!1}let tw=t=>{let e=tp(t).flat();if(!e.every(t=>"string"==typeof t))throw TypeError(`Non-string provided as watch path: ${e}`);return e.map(ty)},tg=t=>{let e=t.replace(td,"/"),i=!1;return e.startsWith("//")&&(i=!0),e=e.replace(tc,"/"),i&&(e="/"+e),e},ty=t=>tg(g.normalize(tg(t))),tv=(t="")=>e=>"string"==typeof e?ty(g.isAbsolute(e)?e:g.join(t,e)):e,tP=Object.freeze(new Set);class tb{path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&"."!==t&&".."!==t&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await l(i)}catch(t){this._removeWatcher&&this._removeWatcher(g.dirname(i),g.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=j,this.items=tP,Object.freeze(this)}}class tE{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,i){this.fsw=i;let s=t;this.path=t=t.replace(tm,""),this.watchPath=s,this.fullWatchPath=g.resolve(s),this.dirParts=[],this.dirParts.forEach(t=>{t.length>1&&t.pop()}),this.followSymlinks=e,this.statMethod=e?"stat":"lstat"}entryPath(t){return g.join(this.watchPath,g.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}}class tx extends i{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tp(t.ignored):tp([]),awaitWriteFinish:!0===e?i:"object"==typeof e&&{...i,...e}};N&&(s.usePolling=!0),void 0===s.atomic&&(s.atomic=!s.usePolling);let r=process.env.CHOKIDAR_USEPOLLING;if(void 0!==r){let t=r.toLowerCase();"false"===t||"0"===t?s.usePolling=!1:"true"===t||"1"===t?s.usePolling=!0:s.usePolling=!!t}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let h=0;this._emitReady=()=>{++h>=this._readyCount&&(this._emitReady=j,this._readyEmitted=!0,process.nextTick(()=>this.emit(U)))},this._emitRaw=(...t)=>this.emit(G,...t),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new tl(this),Object.freeze(s)}_addIgnoredPath(t){if(t_(t)){for(let e of this._ignoredPaths)if(t_(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),"string"==typeof t)for(let e of this._ignoredPaths)t_(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let r=tw(t);return s&&(r=r.map(t=>g.isAbsolute(t)?t:g.join(s,t))),r.forEach(t=>{this._removeIgnoredPath(t)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async t=>{let s=await this._nodeFsHandler._addToNodeFs(t,!i,void 0,0,e);return s&&this._emitReady(),s})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(g.dirname(t),g.basename(e||t))})}),this}unwatch(t){if(this.closed)return this;let e=tw(t),{cwd:i}=this.options;return e.forEach(t=>{g.isAbsolute(t)||this._closers.has(t)||(i&&(t=g.join(i,t)),t=g.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(e=>{let i=e();i instanceof Promise&&t.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{t[(this.options.cwd?g.relative(this.options.cwd,i):i)||"."]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==B&&this.emit(H,t,...e)}async _emit(t,e,i){let s;if(this.closed)return;let r=this.options;M&&(e=g.normalize(e)),r.cwd&&(e=g.relative(r.cwd,e));let a=[e];null!=i&&a.push(i);let h=r.awaitWriteFinish;if(h&&(s=this._pendingWrites.get(e)))return s.lastChange=new Date,this;if(r.atomic){if(t===q)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((t,e)=>{this.emit(...t),this.emit(H,...t),this._pendingUnlinks.delete(e)})},"number"==typeof r.atomic?r.atomic:100),this;t===L&&this._pendingUnlinks.has(e)&&(t=$,this._pendingUnlinks.delete(e))}if(h&&(t===L||t===$)&&this._readyEmitted){let i=(e,i)=>{e?(t=B,a[0]=e,this.emitWithAll(t,a)):i&&(a.length>1?a[1]=i:a.push(i),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,h.stabilityThreshold,t,i),this}if(t===$&&!this._throttle($,e,50))return this;if(r.alwaysStat&&void 0===i&&(t===L||t===K||t===$)){let t,i=r.cwd?g.join(r.cwd,e):e;try{t=await c(i)}catch(t){}if(!t||this.closed)return;a.push(t)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&"ENOENT"!==e&&"ENOTDIR"!==e&&(!this.options.ignorePermissionErrors||"EPERM"!==e&&"EACCES"!==e)&&this.emit(B,t),t||this.closed}_throttle(t,e,i){let s;this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw Error("invalid throttle");let a=r.get(e);if(a)return a.count++,!1;let h=()=>{let t=r.get(e),i=t?t.count:0;return r.delete(e),clearTimeout(s),t&&clearTimeout(t.timeoutObject),i},n={timeoutObject:s=setTimeout(h,i),clear:h,count:0};return r.set(e,n),n}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,r){let a,h=this.options.awaitWriteFinish;if("object"!=typeof h)return;let n=h.pollInterval,o=t;this.options.cwd&&!g.isAbsolute(t)&&(o=g.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(a),i)}),a=setTimeout(function i(h){s(o,(s,o)=>{if(s||!d.has(t)){s&&"ENOENT"!==s.code&&r(s);return}let l=Number(new Date);h&&o.size!==h.size&&(d.get(t).lastChange=l),l-d.get(t).lastChange>=e?(d.delete(t),r(void 0,o)):a=setTimeout(i,n,o)})},n))}_isIgnored(t,e){if(this.options.atomic&&tf.test(t))return!0;if(!this._userIgnored){let{cwd:t}=this.options,e=(this.options.ignored||[]).map(tv(t)),i=[...[...this._ignoredPaths].map(tv(t)),...e];this._userIgnored=function(t,e){if(null==t)throw TypeError("anymatch: specify first argument");let i=tp(t).map(t=>"function"==typeof t?t:"string"==typeof t?e=>t===e:t instanceof RegExp?e=>t.test(e):"object"==typeof t&&null!==t?e=>{if(t.path===e)return!0;if(t.recursive){let i=g.relative(t.path,e);return!!i&&!i.startsWith("..")&&!g.isAbsolute(i)}return!1}:()=>!1);return null==e?(t,e)=>tu(i,t,e):tu(i,e)}(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tE(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=g.resolve(t);return this._watched.has(e)||this._watched.set(e,new tb(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return!!this.options.ignorePermissionErrors||!!(256&Number(t.mode))}_remove(t,e,i){let s=g.join(t,e),r=g.resolve(s);if(i=null!=i?i:this._watched.has(s)||this._watched.has(r),!this._throttle("remove",s,100))return;i||1!==this._watched.size||this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(t=>this._remove(s,t));let a=this._getWatchedDir(t),h=a.has(e);a.remove(e),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let n=s;if(this.options.cwd&&(n=g.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(n)&&this._pendingWrites.get(n).cancelWait()===L)return;this._watched.delete(s),this._watched.delete(r);let o=i?V:q;h&&!this._isIgnored(s)&&this._emit(o,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=g.dirname(t);this._getWatchedDir(e).remove(g.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(t=>t()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i=function(t,e={}){let i=e.entryType||e.type;if("both"===i&&(i=b),i&&(e.type=i),t){if("string"!=typeof t)throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(i&&!W.includes(i))throw Error(`readdirp: Invalid type passed. Use one of ${W.join(", ")}`)}else throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new z(e)}(t,{type:H,alwaysStat:!0,lstat:!0,...e,depth:0});return this._streams.add(i),i.once("close",()=>{i=void 0}),i.once("end",()=>{i&&(this._streams.delete(i),i=void 0)}),i}}function tk(t,e={}){let i=new tx(e);return i.add(t),i}let tW={watch:tk,FSWatcher:tx};export{y as chokidar_namespaceObject};
|
|
2
|
+
import{definePropertyGetters as e,makeNamespaceObject as t}from"./rslib-runtime.js";import{EventEmitter as i}from"node:events";import{realpathSync as r,watch as s}from"node:fs";import{lstat as n,open as a,readdir as o,readlink as l,realpath as h,stat as c}from"node:fs/promises";import{join as d,resolve as u,sep as p}from"node:path";import{Readable as f}from"node:stream";import{type as m}from"node:os";import*as v from"node:path";var g={};t(g),e(g,{FSWatcher:()=>e2,default:()=>e4,watch:()=>e3});let w="files",y="directories",b="files_directories",P={root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:w,lstat:!1,depth:0x80000000,alwaysStat:!1,highWaterMark:256};Object.freeze(P);let k="READDIRP_RECURSIVE_ERROR",E=new Set(["ENOENT","EPERM","EACCES","ELOOP",k]),A=[y,"all",b,w],x=new Set([y,"all",b]),D=new Set(["all",b,w]),S="win32"===process.platform,T=e=>!0,I=e=>{if(void 0===e)return T;if("function"==typeof e)return e;if("string"==typeof e){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return T};class R extends f{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;_relStart;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark??P.highWaterMark});let t={...P,...e},i=t.root??P.root,r=t.type??P.type;this._fileFilter=I(t.fileFilter),this._directoryFilter=I(t.directoryFilter);let s=t.lstat?n:c;S?this._stat=e=>s(e,{bigint:!0}):this._stat=s,this._maxDepth=null!=t.depth&&Number.isSafeInteger(t.depth)?t.depth:P.depth,this._wantsDir=x.has(r),this._wantsFile=D.has(r),this._wantsEverything="all"===r,this._root=u(i),this._relStart=this._root.endsWith(p)?this._root.length:this._root.length+1,this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent};let a={path:this._root,depth:1};a.pending=this._exploreDir(this._root,1),this.parents=[a],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,i=t&&t.files;if(i&&i.length>0){let{path:r,depth:s}=t,n=i.splice(0,e).map(e=>this._formatEntry(e,r));for(let t of this._isDirent?n:await Promise.all(n)){if(!t)continue;if(this.destroyed)return;let i=this._getEntryType(t);"string"!=typeof i&&(i=await i),"directory"===i&&this._directoryFilter(t)?(s<=this._maxDepth&&this.parents.push({path:t.fullPath,depth:s+1}),this._wantsDir&&(this.push(t),e--)):("file"===i||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}let t=e.pending??this._exploreDir(e.path,e.depth),i=this.parents[this.parents.length-1];if(i&&!i.pending&&(i.pending=this._exploreDir(i.path,i.depth)),this.parent=await t,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let i;try{i=await o(e,this._rdOptions)}catch(e){this._onError(e)}return{files:i,depth:t,path:e}}_formatEntry(e,t){let i=this._isDirent?e.name:e,r=d(t,i),s={path:r.slice(this._relStart),fullPath:r,basename:i};return this._isDirent?(s.dirent=e,s):this._stat(r).then(e=>(s.stats=e,s),e=>{this._onError(e)})}_onError(e){E.has(e.code)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}_getEntryType(e){if(!e||!(this._statsProp in e))return"";let t=e[this._statsProp];return t.isFile()?"file":t.isDirectory()?"directory":t.isSymbolicLink()?this._getSymlinkEntryType(e):""}async _getSymlinkEntryType(e){let t=e.fullPath;try{let e=await h(t),i=await n(e);if(i.isFile())return"file";if(i.isDirectory()){let i=e.length;if(t.startsWith(e)&&t[i]===p){let i=Error(`Circular symlink detected: "${t}" points to "${e}"`);return i.code=k,this._onError(i),""}return"directory"}}catch(e){this._onError(e)}return""}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}}let C=process.platform,_="win32"===C,M="darwin"===C,O="linux"===C,z="OS400"===m();function j(e){let t=e?.code;return"ENOENT"===t||"ENOTDIR"===t?"missing":"EPERM"===t||"EACCES"===t?"permission":"ERR_FEATURE_UNAVAILABLE_ON_PLATFORM"===t?"recursive-unsupported":"other"}function F(e){return"missing"===j(e)}let W=Object.freeze({now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>{e&&clearTimeout(e)}}),H="all",N="ready",G="add",L="change",q="addDir",U="unlink",B="unlinkDir",$="raw",K="error",V=/\\/g,X=/\/\//g;function J(e){if("string"!=typeof e)throw TypeError("string expected");let t=e.replace(V,"/"),i=t.startsWith("//"),r=v.normalize(t).replace(V,"/").replace(X,"/");return i&&!r.startsWith("//")&&(r=`/${r}`),r}function Q(e){if("bigint"!=typeof e.mtimeMs)return e;let t=e.mtimeNs/1000000000n,i=e.mtimeNs%1000000000n,r=1e3*Number(t)+Number(i)/1e6;return{size:Number(e.size),mtimeMs:r,ino:Number(e.ino)}}function Y(e){let t=v.resolve(e);return _||!t.includes("\\")?t.replace(V,"/"):J(t)}function Z(e){return".."!==e&&!e.startsWith(`..${v.sep}`)&&!v.isAbsolute(e)}function ee(e,t){let i=v.relative(e,t);return""===i||Z(i)}function et(e,t){let i=v.relative(e,t);return""!==i&&Z(i)}function ei(e){return"object"==typeof e&&null!==e&&!(e instanceof RegExp)}function er(e){return e instanceof RegExp?new RegExp(e.source,e.flags):ei(e)?Object.freeze({...e}):e}function es(e){return"function"==typeof e?e:"string"==typeof e?t=>e===t:e instanceof RegExp?t=>(e.lastIndex=0,e.test(t)):ei(e)?t=>e.path===t||!!(e.recursive&&et(e.path,t)):()=>!1}function en(e){let t=e.map(es);return(e,i)=>{if(0===t.length)return!1;let r=J(e);return t.some(e=>e(r,i))}}let ea=/^\.[/\\]/;class eo{watchPath;followSymlinks;recursiveRoot;recursiveDisabled;observationTrigger;realpathAncestry;pathGeneration;context;constructor(e,t,i){this.context=i,this.watchPath=e.replace(ea,""),this.followSymlinks=t,this.realpathAncestry=new Set,this.pathGeneration=i.capturePathGeneration()}fork(e){let t=new eo(e,this.followSymlinks,this.context);return t.recursiveRoot=this.recursiveRoot,t.recursiveDisabled=this.recursiveDisabled,t.observationTrigger=this.observationTrigger,t.realpathAncestry=new Set(this.realpathAncestry),t.pathGeneration=this.pathGeneration,t}withObservation(e){let t=Object.create(this);return t.observationTrigger=e,t}filterPath(e){return e.stats?.isSymbolicLink()?this.filterDir(e):this.context.isntIgnored(v.join(this.watchPath,e.path),e.stats)}filterDir(e){return this.context.isntIgnored(v.join(this.watchPath,e.path),e.stats)}}let el=0;function eh(e){[...e.subscribers].some(e=>e.persistent)?e.watcher.ref():e.watcher.unref()}function ec(e,t){let i=function(e){if(e.closed)return;e.closed=!0;let t=[...e.subscribers];return e.subscribers.clear(),t}(e);if(i)return t.get(e.resource)===e&&t.delete(e.resource),e.watcher.close(),i}function ed(e,t){e.closed||e.subscribers.add(t),eh(e)}function eu(e,t,i){let r=!1;return{resource:e.resource,close:()=>{if(r)return;r=!0;let s=function(e,t){if(!e.closed&&e.subscribers.delete(t))return e.subscribers.size>0?"remaining":"last"}(e,t);"remaining"===s?eh(e):"last"===s&&i.get(e.resource)===e&&ec(e,i)}}}function ep(){return performance.now()}function ef(e){let t=v.normalize(e);if(!_)return t;try{return r.native(t)}catch{return t}}function em(e,t){if(!_||null===t||!v.isAbsolute(t))return t;let i=v.normalize(v.toNamespacedPath(e)),r=v.normalize(v.toNamespacedPath(t)),s=v.relative(i,r);return ee(i,r)?s||null:t}let ev=new Map,eg=new Map,ew=!1;function ey(e,t,i,r,s=i){if(e.closed||ev.get(e.resource)!==e)return;let n={kind:"native",resource:e.resource,rawEvent:t,relativePath:i,sequence:++e.sequence,observedAt:ep()};e.subscribers.forEach(e=>{r&&e.rawEmitter(t,s,{watchedPath:e.watchedPath}),e.publish(n)})}function eb(e,t){e.closed||ev.get(e.resource)!==e||e.subscribers.forEach(e=>e.errHandler(t))}function eP(e,t){let i=ec(e,ev);i?.forEach(e=>e.failure?.(t))}function ek(e,t,i,r,o){let l={...r,watchedPath:e,persistent:i.persistent??!0},h=ev.get(t);if(h)ed(h,l);else if(!(h=function(e,t,i,r,o){let l,h=function(e,t,i,r){try{var n;return n={persistent:t.persistent},s(e,n,i)}catch(e){r(e);return}}(t,r,(e,i)=>{let r=em(t,i);ey(l,e,r,!0,i),O&&"rename"===e&&i===v.basename(t)&&async function(e,t){try{await n(v.join(t,v.basename(t)));return}catch(e){if(!F(e))return}try{if(!(await c(t)).isDirectory())return}catch{return}e.closed||ev.get(e.resource)!==e||eP(e,Error(`Watched directory was replaced: ${t}`))}(l,t)},o.errHandler);if(h)return l={resource:i,generation:++el,subscribers:new Set([o]),closed:!1,watcher:h,sequence:0},ev.set(i,l),h.on(K,t=>{!async function(e,t,i){if(_&&"EPERM"===i.code)try{let r=await a(e,"r");await r.close(),eb(t,i)}catch{ey(t,"rename",null,!1)}else eb(t,i);eP(t,i)}(e,l,t)}),l}(e,ef(e),t,i,l)))return;let d=eu(h,l,ev);return o.aborted?void d.close():d}let eE=Object.freeze({missing:!0}),eA=new Map;function ex(e){return"missing"in e}function eD(e){e.timer&&(e.persistent?e.timer.ref():e.timer.unref())}function eS(e,t=e.interval){e.closed||0===e.subscribers.size||(e.timer=e.scheduler.setTimeout(()=>{e.timer=void 0;let t=async function(e){let t;if(e.closed||e.running||0===e.subscribers.size)return;e.running=!0;let i=e.scheduler.now();try{t=await c(e.resource)}catch(i){F(i)?t=eE:e.subscribers.forEach(e=>e.errHandler(i))}if(!e.closed&&t){let i=e.previous;e.previous=t;let r=e.scheduler.now(),s=i&&function(e,t){let i=ex(e),r=ex(t);if(i||r)return i!==r;let s=!_&&0!==e.ino&&0!==t.ino&&e.ino!==t.ino;return e.size!==t.size||e.mtimeMs!==t.mtimeMs||s}(i,t),n=void 0!==e.directoryReplayAt&&r>=e.directoryReplayAt;if(!ex(t)&&t.isDirectory()?s?e.directoryReplayAt=r+1e3:n&&(e.directoryReplayAt=void 0):e.directoryReplayAt=void 0,i&&(s||n)){let r={kind:"poll",resource:e.resource,current:t,previous:i,sequence:++e.sequence,observedAt:e.scheduler.now()};e.subscribers.forEach(s=>{s.rawEmitter(L,e.resource,{current:t,previous:i}),s.publish(r)})}}if(e.running=!1,!e.closed&&e.subscribers.size>0){let t=e.scheduler.now()-i;eS(e,Math.max(0,e.interval-t))}}(e);e.currentPoll=t,t.then(()=>{e.currentPoll===t&&(e.currentPoll=void 0)},()=>{e.currentPoll===t&&(e.currentPoll=void 0)})},t),eD(e))}function eT(e){if(e.closed||0===e.subscribers.size)return;let t=Math.min(...[...e.subscribers].map(e=>e.interval)),i=[...e.subscribers].some(e=>e.persistent),r=e.interval!==t;e.interval=t,e.persistent=i,e.timer&&r?(e.scheduler.clearTimeout(e.timer),e.timer=void 0,eS(e)):e.timer?eD(e):e.running||eS(e)}function eI(e){return void 0!==e&&e.isFile()&&0===Q(e).size}class eR{pendingWrites=new Map;pendingUnlinks=new Map;pendingChanges=new Map;heldAdds=new Map;throttled=new Map;context;constructor(e){this.context=e}presentPath(e){return _&&(e=v.normalize(e)),this.context.options.cwd?v.relative(this.context.options.cwd,e):e}dropHeldAdd(e){let t=this.heldAdds.get(e);t&&this.context.scheduler.clearTimeout(t.timer),this.heldAdds.delete(e)}dropPendingChange(e){let t=this.pendingChanges.get(e);t?.held&&this.context.scheduler.clearTimeout(t.held.timer),this.pendingChanges.delete(e)}setTimeout(e,t){let i=this.context.scheduler.setTimeout(e,t);return this.context.options.persistent||i.unref(),i}async emit(e,t,i){if(this.context.isClosed())return;let{options:r,scheduler:s}=this.context,n=t,a=Y(t),o=this.context.lifecycle.generation,l=this.context.capturePathGeneration(),h=[t=this.presentPath(t)];null!=i&&h.push(i);let d=this.heldAdds.get(a);if(d){if(e===L){d.path=n,i&&(d.stats=i),eI(i)||d.release();return}d.release()}(e===U||e===B)&&(this.dropPendingChange(a),this.throttled.get(L)?.get(a)?.clear(!1));let u=r.awaitWriteFinish,p=u?this.pendingWrites.get(a):void 0;if(p){p.lastChange=s.now();return}if(r.atomic){if(e===U){let t=this.pendingUnlinks.get(a);t&&s.clearTimeout(t.timer);let i=[e,...h],n=this.setTimeout(()=>{let e=this.pendingUnlinks.get(a);if(!e||e.timer!==n||(this.pendingUnlinks.delete(a),this.context.isClosed()))return;let[t,...i]=e.event;this.context.publish(t,i)},"number"==typeof r.atomic?r.atomic:100);this.pendingUnlinks.set(a,{event:i,timer:n});return}let t=this.pendingUnlinks.get(a);e===G&&t&&(e=L,s.clearTimeout(t.timer),this.pendingUnlinks.delete(a))}if(u&&(e===G||e===L)&&this.context.isReady()){let i=(t,i)=>{!this.context.isClosed()&&(t?(e=K,h[0]=t,this.context.publish(e,h)):i&&(h.length>1?h[1]=i:h.push(i),this.context.publish(e,h)))};this.awaitWriteFinish(t,u.stabilityThreshold,e,i,a);return}if(e===G&&eI(i)&&this.context.isReady()){let e={path:n,stats:i,release:()=>{if(this.context.scheduler.clearTimeout(e.timer),this.heldAdds.get(a)!==e||(this.heldAdds.delete(a),this.context.isClosed()||!this.context.lifecycle.isActive(o)||!this.context.isPathGenerationActive(a,l)))return;let t=[this.presentPath(e.path)];e.stats&&t.push(e.stats),this.context.publish(G,t)}};e.timer=this.setTimeout(e.release,10),this.heldAdds.set(a,e);return}if(e===L){if(!this.throttle(L,n,50,e=>{let t=this.pendingChanges.get(a);this.dropPendingChange(a),e>0&&t?.replay&&this.context.lifecycle.isActive(o)&&this.context.isPathGenerationActive(a,l)&&this.emit(L,t.path,t.stats)})){let e=this.pendingChanges.get(a);e&&!function(e,t){if(void 0===e||void 0===t)return!1;let i=Q(e),r=Q(t);return i.size===r.size&&i.mtimeMs===r.mtimeMs&&i.ino===r.ino}(e.stats,i)&&(e.path=n,e.stats=i,e.replay=!0,e.held&&!eI(i)&&e.held.release());return}let e={path:n,stats:i,replay:!1};if(this.pendingChanges.set(a,e),eI(i)){let t=()=>{if(e.held&&this.context.scheduler.clearTimeout(e.held.timer),e.held=void 0,this.pendingChanges.get(a)!==e||this.context.isClosed()||!this.context.lifecycle.isActive(o)||!this.context.isPathGenerationActive(a,l))return;e.replay=!1;let t=[this.presentPath(e.path)];e.stats&&t.push(e.stats),this.context.publish(L,t)};e.held={timer:this.setTimeout(t,10),release:t};return}}if(r.alwaysStat&&void 0===i&&(e===G||e===q||e===L)){let e=r.cwd?v.join(r.cwd,t):t;try{i=await c(e)}catch(e){this.context.handleError(e)}if(!i||!this.context.lifecycle.isActive(o)||!this.context.isPathGenerationActive(a,l))return;h.push(i)}this.context.publish(e,h)}throttle(e,t,i,r){let s,n=this.throttled.get(e);n||(n=new Map,this.throttled.set(e,n));let a="readdir"===e?t:Y(t),o=n.get(a);if(o)return o.count+=1,!1;let l=(e=!0)=>{let t=n.get(a),i=t?.count??0;return n.delete(a),this.context.scheduler.clearTimeout(s),t&&this.context.scheduler.clearTimeout(t.timeoutObject),e&&r&&r(i),i},h={timeoutObject:s=this.setTimeout(l,i),clear:l,count:0};return n.set(a,h),h}awaitWriteFinish(e,t,i,r,s){let n,a=this.context.options.awaitWriteFinish;if("object"!=typeof a)return;let o=a.pollInterval,l=e;this.context.options.cwd&&!v.isAbsolute(e)&&(l=v.join(this.context.options.cwd,e));let h=s??Y(l);if(this.pendingWrites.has(h))return;let d=this.context.lifecycle.generation,u={lastChange:this.context.scheduler.now(),cancelWait:()=>(this.pendingWrites.get(h)===u&&this.pendingWrites.delete(h),this.context.scheduler.clearTimeout(n),i)},p=()=>this.context.lifecycle.isActive(d)&&this.pendingWrites.get(h)===u,f=e=>{let i=(async()=>{let i;try{i=await c(l)}catch(e){if(!p())return;F(e)?(this.context.remove(v.dirname(l),v.basename(l)),this.pendingWrites.get(h)===u&&u.cancelWait()):(this.pendingWrites.delete(h),r(e));return}if(!p())return;let s=this.context.scheduler.now();e&&i.size!==e.size&&(u.lastChange=s),s-u.lastChange>=t?(this.pendingWrites.delete(h),r(void 0,i)):n=this.setTimeout(()=>f(i),o)})();this.context.lifecycle.track(i)};this.pendingWrites.set(h,u),n=this.setTimeout(f,o)}cancelPath(e){let t=Y(e),i=this.pendingUnlinks.get(t);i&&(this.context.scheduler.clearTimeout(i.timer),this.pendingUnlinks.delete(t)),this.pendingWrites.get(t)?.cancelWait(),this.dropPendingChange(t),this.dropHeldAdd(t),["watch","add","remove","change"].forEach(e=>{this.throttled.get(e)?.get(t)?.clear(!1)});let r=this.throttled.get("readdir");r?.get(t)?.clear(!1),r?.get(`${Y(v.dirname(t))}\0${v.basename(t)}`)?.clear(!1)}cancelWhere(e){[...new Set([...this.pendingUnlinks.keys(),...this.pendingWrites.keys(),...this.pendingChanges.keys(),...this.heldAdds.keys()])].filter(e).forEach(e=>this.cancelPath(e)),this.throttled.forEach((t,i)=>{[...t.keys()].filter(t=>e("readdir"===i?t.split("\0",1)[0]:t)).forEach(e=>t.get(e)?.clear(!1))})}close(){this.pendingWrites.forEach(e=>e.cancelWait()),this.pendingUnlinks.forEach(({timer:e})=>this.context.scheduler.clearTimeout(e)),this.pendingUnlinks.clear(),this.pendingChanges.forEach(({held:e})=>this.context.scheduler.clearTimeout(e?.timer)),this.pendingChanges.clear(),this.heldAdds.forEach(({timer:e})=>this.context.scheduler.clearTimeout(e)),this.heldAdds.clear(),this.throttled.forEach(e=>{e.forEach(e=>e.clear(!1))}),this.throttled.clear()}}class eC{state="OPEN";generation=0;abortController=new AbortController;tasks=new Set;closers=new Map;onTaskSettled;onTaskError;constructor(e,t){this.onTaskSettled=e,this.onTaskError=t}isActive(e){return"OPEN"===this.state&&this.generation===e}track(e){let t=Promise.resolve(e).finally(()=>{this.tasks.delete(t),this.onTaskSettled()});return this.tasks.add(t),t.catch(this.onTaskError),t}addCloser(e,t){let i=this.closers.get(e);i?i.push(t):this.closers.set(e,[t])}takeClosers(e){let t=this.closers.get(e)??[];return this.closers.delete(e),t}beginClose(){if("OPEN"!==this.state)return[];this.state="CLOSING",this.generation+=1,this.abortController.abort();let e=[];return this.closers.forEach(t=>{t.forEach(t=>{try{e.push(Promise.resolve(t()))}catch(t){e.push(Promise.reject(t))}})}),this.closers.clear(),e}async drain(){for(;this.tasks.size>0;)await Promise.allSettled([...this.tasks])}finishClose(){this.state="CLOSED"}}function e_(){}function eM(e,t){if(v.isAbsolute(t))return;let i=v.resolve(e),r=v.resolve(i,t);if(ee(i,r))return v.join(e,t)}class eO{queues=new Map;pending=new Map;lifecycle;constructor(e){this.lifecycle=e}enqueue(e,t,i=e){let r=Y(e),s=!1===i?void 0:`${r}\0${Y(i)}`,n=s?this.pending.get(s):void 0;if(n)return n.work=t,n.replay=!0,n.promise;let a=this.lifecycle.generation,o={promise:Promise.resolve(),work:t,replay:!1},l=(this.queues.get(r)??Promise.resolve()).catch(e_).then(async()=>{do{let e=o.work;if(o.replay=!1,!this.lifecycle.isActive(a))return;await e()}while(o.replay)}).finally(()=>{this.queues.get(r)===l&&this.queues.delete(r),s&&this.pending.get(s)===o&&this.pending.delete(s)});this.queues.set(r,l);let h=this.lifecycle.track(l);return o.promise=h,s&&this.pending.set(s,o),h}forgetPending(e){for(let t of this.pending.keys()){let[i,r]=t.split("\0",2);e(i,r)&&this.pending.delete(t)}}clear(){this.queues.clear(),this.pending.clear()}}let ez=Object.freeze({size:0,mtimeMs:0,ino:0,kind:"other",initialRecursive:!0});function ej(e){return e.isSymbolicLink()?"symlink":e.isDirectory()?"directory":e.isFile()?"file":"other"}function eF(e,t){let i=Q(t);return e?.size===i.size&&e.mtimeMs===i.mtimeMs&&e.ino===i.ino&&e.kind===ej(t)}function eW(e,t,i){return e?.observedAt!==void 0&&t.observedAt>=e.observedAt&&t.observedAt-e.observedAt<=i}class eH{path;items=new Set;constructor(e){this.path=e}add(e){"."!==e&&".."!==e&&""!==e&&this.items.add(e)}remove(e){return this.items.delete(e)&&0===this.items.size}has(e){return this.items.has(e)}getChildren(){return[...this.items]}dispose(){this.items.clear(),this.path=""}}class eN{watched=new Map;observed=new Map;symlinkPaths=new Map;recursiveRoots=new Set;observesNative;constructor(e){this.observesNative=e}getDirectory(e){let t=v.resolve(e),i=Y(t),r=this.watched.get(i);return r||(r=new eH(t),this.watched.set(i,r)),r}peekDirectory(e){return this.watched.get(Y(v.resolve(e)))}recordObserved(e,t,i,r,s=!1,n=!1){if(!this.observesNative()||!r&&!s&&!n)return;let{size:a,mtimeMs:o,ino:l}=Q(t);this.observed.set(Y(e),{size:a,mtimeMs:o,ino:l,kind:ej(t),transition:i,rawEvent:r?.rawEvent,relativePath:r?.relativePath,observedAt:r?.observedAt,initialRecursive:s})}consumeInitialCreate(e,t,i,r){let s=this.observed.get(Y(e));if(s?.initialRecursive&&"rename"===i.rawEvent)return this.recordObserved(e,t,"add",i),!!r&&(t.isDirectory()?q:G)}markInitialCreate(e){let t=Y(e),i=this.observed.get(t);i?i.initialRecursive=!0:this.observed.set(t,{...ez})}clearInitialCreate(e){let t=this.observed.get(Y(e));t&&(t.initialRecursive=!1)}clearInitialCreates(e){let t=Y(e);for(let[e,i]of this.observed)ee(t,e)&&i.initialRecursive&&(i.initialRecursive=!1)}replacedSinceObserved(e,t){let i=this.observed.get(Y(e)),{ino:r}=Q(t);return i?.kind==="directory"&&t.isDirectory()&&0!==i.ino&&0!==r&&i.ino!==r}changedSinceObserved(e,t){let i=this.observed.get(Y(e));return void 0!==i&&i.kind===ej(t)&&!eF(i,t)}isDuplicateObservation(e,t,i){let r=this.observed.get(Y(e)),s=eF(r,t),n=s&&r?.transition==="add"&&r?.relativePath===i.relativePath&&"rename"===r.rawEvent&&"change"===i.rawEvent&&eW(r,i,25),a=s&&t.isFile()&&!r?.initialRecursive&&(r?.transition==="add"||null===i.relativePath),o=s&&r?.transition==="change"&&r.relativePath===i.relativePath&&eW(r,i,10)&&r.rawEvent===i.rawEvent,l=o?void 0:a?r?.transition:"change";return this.recordObserved(e,t,l,i),a||n||o}dispose(){this.watched.forEach(e=>e.dispose()),this.watched.clear(),this.observed.clear(),this.symlinkPaths.clear(),this.recursiveRoots.clear()}}let eG=Object.freeze({});function eL(e){return{kind:"native",resource:e,rawEvent:L,relativePath:null,sequence:Number.MAX_SAFE_INTEGER,observedAt:ep()}}class eq{entries=[];overflow;limit;constructor(e){this.limit=e}get overflowed(){return void 0!==this.overflow}push(e){this.entries.length<this.limit&&!this.overflowed?this.entries.push(e):this.overflow=e}clear(){this.entries.length=0,this.overflow=void 0}}function eU(e,t){let i=[];return e.on("data",e=>{let r;try{r=t(e)}catch(e){r=Promise.reject(e)}r&&i.push(Promise.resolve(r))}),new Promise(t=>{e.once("end",()=>t({complete:!0})),e.once("close",()=>t({complete:!1})),e.once(K,e=>t({complete:!1,error:e}))}).then(async({complete:e,error:t})=>{let r=(await Promise.allSettled(i)).filter(e=>"rejected"===e.status).map(e=>e.reason);return{complete:e&&0===r.length,error:t,failures:r}})}let eB=new Set("3dm 3ds 3g2 3gp 7z a aac adp afdesign afphoto afpub ai aif aiff alz ape apk appimage ar arj asf au avi bak baml bh bin bk bmp btif bz2 bzip2 cab caf cgm class cmx cpio cr2 cur dat dcm deb dex djvu dll dmg dng doc docm docx dot dotm dra ds_store dsk dts dtshd dvb dwg dxf ecelp4800 ecelp7470 ecelp9600 egg eol eot epub exe f4v fbs fh fla flac flatpak fli flv fpx fst fvt g3 gh gif graffle gz gzip h261 h263 h264 icns ico ief img ipa iso jar jpeg jpg jpgv jpm jxr key ktx lha lib lvp lz lzh lzma lzo m3u m4a m4v mar mdi mht mid midi mj2 mka mkv mmr mng mobi mov movie mp3 mp4 mp4a mpeg mpg mpga mxu nef npx numbers nupkg o odp ods odt oga ogg ogv otf ott pages pbm pcx pdb pdf pea pgm pic png pnm pot potm potx ppa ppam ppm pps ppsm ppsx ppt pptm pptx psd pya pyc pyo pyv qt rar ras raw resources rgb rip rlc rmf rmvb rpm rtf rz s3m s7z scpt sgi shar snap sil sketch slk smv snk so stl suo sub swf tar tbz tbz2 tga tgz thmx tif tiff tlz ttc ttf txz udf uvh uvi uvm uvp uvs uvu viv vob war wav wax wbmp wdp weba webm webp whl wim wm wma wmv wmx woff woff2 wrm wvx xbm xif xla xlam xls xlsb xlsm xlsx xlt xltm xltx xm xmind xpi xpm xwd xz z zip zipx".split(" "));class e${fsw;reportError;constructor(e){this.fsw=e,this.reportError=t=>e.handleError(t)}subscribePath(e,t,i,r=!1,s=e){let n,a=this.fsw.options,o=v.basename(e),l=v.resolve(e),h={persistent:a.persistent},c=this.fsw.lifecycle.generation,d=!0,u=(e,i,r)=>{if(d&&this.fsw.lifecycle.isActive(c))return t(e,i,r)},p=t=>{this.reconcileBackendTrigger(e,r,t,e=>u(e,"poll"!==t.kind||ex(t.current)?void 0:t.current,t),()=>d&&this.fsw.lifecycle.isActive(c),!0,s)},f=0,m=()=>ek(e,l,h,{publish:e=>{f=0,p(e)},errHandler:this.reportError,rawEmitter:(...e)=>this.fsw.emitRaw(...e),failure:()=>{d&&this.fsw.lifecycle.isActive(c)&&(n=f++<3?m():void 0,p(eL(l)))}},this.fsw.lifecycle.abortController.signal);if(a.backendCapabilities.polling){var g,w,y,b;let t,r,s,h,c,d;g={interval:a.pollingInterval!==a.pollingBinaryInterval&&eB.has(v.extname(o).slice(1).toLowerCase())?a.pollingBinaryInterval:a.pollingInterval,persistent:a.persistent},w=this.fsw.scheduler,y={publish:p,errHandler:this.reportError,rawEmitter:(...e)=>this.fsw.emitRaw(...e)},b=this.fsw.lifecycle.abortController.signal,r={watchedPath:e,...g,...y},(s=eA.get(l))||(s=new Map,eA.set(l,s)),(h=s.get(w))?!h.previous&&i&&(h.previous=i):(h={resource:l,generation:++el,scheduler:w,subscribers:new Set,interval:g.interval,persistent:g.persistent,previous:i,running:!1,closed:!1,sequence:0},s.set(w,h)),h.subscribers.add(r),eT(h),c=!1,d={resource:l,close:()=>t||(t=(async()=>{if(c)return;if(c=!0,h.subscribers.delete(r),h.subscribers.size>0)return void eT(h);if(h.closed)return;h.closed=!0,h.timer&&h.scheduler.clearTimeout(h.timer),h.timer=void 0;let e=eA.get(l);e?.get(w)===h&&(e.delete(w),0===e.size&&eA.delete(l)),h.currentPoll&&await Promise.allSettled([h.currentPoll])})())},n=b.aborted?void d.close():d}else n=m();if(n)return()=>{if(d)return d=!1,n?.close()}}subscribeMappedFile(e,t,i,r,s=M){let n,a,o;if(this.fsw.options.backendCapabilities.polling)return;let l=v.dirname(t),h=Y(t),c=v.dirname(e),d=this.fsw.lifecycle.generation,u=!0,p=s,f=!1,m=()=>u&&this.fsw.lifecycle.isActive(d)&&this.isHelperActive(i,e),g=e=>{if(null===e)return!0;let t=Y(v.isAbsolute(e)?e:v.resolve(l,e));return _?t.toLowerCase()===h.toLowerCase():t===h},w=()=>{p&&(p=!1,o&&o.close())},y=(s,o)=>{if("native"!==o.kind||!g(o.relativePath)||!m())return;let h="directory"===s&&f;"directory"===s?(f=!1,w()):a&&(f=!0,w()),this.reconcileBackendTrigger(l,!0,o,async()=>{if(h&&void 0!==n){var a;let e=await this.mappedFileSnapshot(t);if(void 0!==e&&(!1===(a=n)||!1===e?a===e:a.size===e.size&&a.mtimeMs===e.mtimeMs&&a.ctimeMs===e.ctimeMs&&a.ino===e.ino&&a.mode===e.mode))return}await this.reconcileNativeTrigger(c,i,o,e,r-1,eG),"exact"===s&&(n=await this.mappedFileSnapshot(t))},m,!1,e)},b=0,P=t=>({publish:e=>{"directory"===t&&(b=0),y(t,e)},errHandler:this.reportError,rawEmitter:(i,r)=>{("directory"===t||p)&&g(r)&&m()&&this.fsw.emitRaw(i,r,{watchedPath:e})},failure:()=>{if("exact"===t){o=void 0,p=!1;return}a=void 0,m()&&(b++<3&&(a=k(t)),y(t,eL(v.resolve(l))))}}),k=e=>{let i="directory"===e?l:t;return ek(i,v.resolve(i),{persistent:this.fsw.options.persistent},P(e),this.fsw.lifecycle.abortController.signal)};if(a=k("directory"),(o=s?k("exact"):void 0)||(p=!1),a||o)return async()=>{if(!u)return;u=!1;let e=[a,o].filter(e=>void 0!==e);await Promise.allSettled(e.map(e=>e.close()))}}async mappedFileSnapshot(e){try{return await n(e)}catch(e){if(F(e))return!1;this.reportError(e);return}}watchSymlinkDeletion(e,t=!1){let i;if(!M&&!t||this.fsw.options.backendCapabilities.polling)return;let r=this.fsw,s=r.lifecycle.generation,a=v.dirname(e),o=v.basename(e),l=!0,h=()=>{i=r.scheduler.setTimeout(()=>{i=void 0,(async()=>{try{await n(e)}catch(e){if(!l||!r.lifecycle.isActive(s))return;if(F(e)){l=!1,r.removePath(a,o);return}this.reportError(e)}l&&r.lifecycle.isActive(s)&&h()})()},r.options.pollingInterval),r.options.persistent||i.unref()};return h(),()=>{l&&(l=!1,r.scheduler.clearTimeout(i),i=void 0)}}reconcileBackendTrigger(e,t,i,r,s=()=>!0,n=!0,a=e){let o=e;if(t&&"native"===i.kind&&null!==i.relativePath){let t=eM(e,i.relativePath);if(!t)return this.reportError(Error(`Watcher reported a path outside its root: ${i.relativePath}`)),Promise.resolve();o=t}if(!s()||this.fsw.isUnwatched(o))return Promise.resolve();let l=Y(a),h=Y(o);return this.fsw.reconciliation.enqueue(l,async()=>{!s()||this.fsw.isUnwatched(h)||await r(o)},!!n&&h)}handleFile(e,t,i,r=!0,s,a=!1,o=!1){if(this.fsw.closed)return;let l=v.dirname(e),h=v.basename(e),d=this.fsw.tree.getDirectory(l),u=t;if(d.has(h))return;let p=this.fsw.capturePathGeneration(),f=()=>this.fsw.isPathGenerationActive(e,p),m=async(t,i)=>{if(i&&0!==i.mtimeMs){if(d.has(h)){let t=i.atimeMs,r=i.mtimeMs;(!t||t<=r||r!==u.mtimeMs)&&this.fsw.emitEvent(L,e,i),this.fsw.tree.recordObserved(e,i,"change"),u=i}}else try{let t=u.isSymbolicLink()&&!this.fsw.options.followSymlinks?await n(e):await c(e);if(!f())return;let i=t.atimeMs,r=t.mtimeMs;(!i||i<=r||r!==u.mtimeMs)&&this.fsw.emitEvent(L,e,t),this.fsw.tree.recordObserved(e,t,"change"),u=t}catch(e){if(!f())return;F(e)?this.fsw.removePath(l,h):this.reportError(e)}},g=r&&this.fsw.options.backendCapabilities.polling?this.subscribePath(e,m,t):void 0;return d.add(h),this.fsw.tree.recordObserved(e,t,"add",s,a,o),i&&this.fsw.options.ignoreInitial||this.fsw.isIgnored(e,t)||this.fsw.emitEvent(G,e,t),g}async handleSymlink(e,t,i,r,s,n){if(this.fsw.closed||n&&!this.isHelperActive(n,i))return;let a=Y(e.fullPath),o=this.fsw.tree.getDirectory(t);if(!this.fsw.options.followSymlinks){let t;try{t=await l(i)}catch(e){return F(e)||this.reportError(e),!0}return!(!this.fsw.closed&&(!n||this.isHelperActive(n,i)))||(o.has(r)?this.fsw.tree.symlinkPaths.get(a)!==t&&(this.fsw.tree.symlinkPaths.set(a,t),this.fsw.emitEvent(L,i,e.stats)):(o.add(r),this.fsw.tree.symlinkPaths.set(a,t),this.fsw.tree.recordObserved(i,e.stats,"add",n?.observationTrigger,s&&!!n?.recursiveRoot),s&&this.fsw.options.ignoreInitial||this.fsw.emitEvent(G,i,e.stats)),!0)}if(this.fsw.tree.symlinkPaths.has(a))return!0;this.fsw.tree.symlinkPaths.set(a,!0)}readDirectory(e,t,i,r,s,a){if(!this.isHelperActive(i,e))return;let o=Y(e=v.join(e,"")),l=this.fsw.tree.getDirectory(i.watchPath),h=new Set,d=this.fsw.createScanStream(e,{fileFilter:e=>i.filterPath(e),directoryFilter:e=>i.filterDir(e)});if(d)return eU(d,n=>{if(!this.isHelperActive(i,e))return;let o=n.stats;if(!o)return;let c=n.path,d=v.join(e,c);if(!this.isHelperActive(i,d))return;h.add(c);let u=c===r||!r&&!l.has(c);if(void 0===r&&!o.isSymbolicLink()&&!o.isDirectory()){if(!u)return;d=v.join(s,v.relative(s,d));let e=this.handleFile(d,o,t,!i.recursiveRoot,i.observationTrigger,t&&!!i.recursiveRoot);e&&this.fsw.addPathCloser(d,e);return}return(async()=>{o.isSymbolicLink()&&await this.handleSymlink(n,e,d,c,t,i)||this.isHelperActive(i,d)&&u&&(d=v.join(s,v.relative(s,d)),await this.addPathOnce(d,t,i,a+1))})()}).then(async({complete:t,error:s,failures:d})=>{if(d.forEach(this.reportError),s)if(F(s)&&this.isHelperActive(i,e)){let t=r?v.join(e,r):e,s=!1,h=!1;try{let e=r?await n(t):await c(t);h=!r&&!e.isDirectory()}catch(e){F(e)?s=!0:this.reportError(e)}r?s&&l.has(r)&&this.fsw.removePath(e,r):(s||h)&&this.fsw.tree.watched.has(o)&&(this.fsw.removePath(v.dirname(e),v.basename(e),!0),h&&await this.addPathOnce(e,!1,i,a))}else this.reportError(s);t&&this.isHelperActive(i,e)&&await Promise.all(l.getChildren().filter(e=>!h.has(e)).map(t=>this.removeIfMissing(i,e,t,l)))})}async removeIfMissing(e,t,i,r){let s=v.join(t,i);if(this.isHelperActive(e,s)){try{await n(s);return}catch(e){if(!F(e))return}this.isHelperActive(e,s)&&r.has(i)&&this.fsw.removePath(t,i)}}scanRecursiveTree(e,t,i,r,s){if(!this.isHelperActive(i,e))return;let n=this.fsw,a=n.options.depth,o=n.createScanStream(e,{fileFilter:e=>i.filterPath(e),directoryFilter:e=>!e.stats?.isSymbolicLink()&&i.filterDir(e),depth:void 0===a?void 0:a-r});if(o)return eU(o,a=>{if(!this.isHelperActive(i,e))return;let o=a.stats;if(!o)return;let l=v.join(e,a.path);if(!this.isHelperActive(i,l))return;let h=v.dirname(l),c=v.basename(l);if(s&&(s.seen.add(Y(l)),o.isDirectory()&&s.directories.push(l)),o.isSymbolicLink())return(async()=>{if(await this.handleSymlink(a,h,l,c,t,i)||!this.isHelperActive(i,l))return;let e=r+a.path.split(/[/\\]/).length;await this.addPathOnce(l,t,i,e)})();let d=n.tree.getDirectory(h);if(d.has(c)){s&&o.isFile()&&n.tree.changedSinceObserved(l,o)&&(n.tree.recordObserved(l,o,"change",void 0,!1,!0),n.emitEvent(L,l,o));return}d.add(c);let u=o.isDirectory();u&&n.tree.getDirectory(l),n.tree.recordObserved(l,o,"add",i.observationTrigger,t),t&&n.options.ignoreInitial||n.emitEvent(u?q:G,l,o)}).then(e=>{e.error&&this.reportError(e.error),e.failures.forEach(this.reportError),s&&(s.complete=e.complete)})}async rescanRecursiveTree(e,t,i){let r={seen:new Set,directories:[e],complete:!1};if(await this.scanRecursiveTree(e,!1,t,i,r),!r.complete||!this.isHelperActive(t,e))return;let s=[];for(let e of r.directories)for(let t of this.fsw.tree.peekDirectory(e)?.getChildren()??[]){let i=v.join(e,t);r.seen.has(Y(i))||s.push(i)}for(let e of(s.sort((e,t)=>e.length-t.length),s)){let i=this.fsw.tree.peekDirectory(v.dirname(e));i?.has(v.basename(e))&&await this.removeIfMissing(t,v.dirname(e),v.basename(e),i)}}isHelperActive(e,t=e.watchPath){return this.fsw.isPathGenerationActive(t,e.pathGeneration)}candidateDepth(e,t){let i=v.relative(e,t);return i?i.split(v.sep).length:0}candidateIgnored(e,t,i){let r=v.relative(e,t),s=e;if(this.fsw.isIgnored(s))return!0;if(r){let e=r.split(v.sep);for(let t=0;t<e.length-1;t++)if(s=v.join(s,e[t]),this.fsw.isIgnored(s))return!0}return this.fsw.isIgnored(t,i)}async highestMissingPath(e,t){let i=t,r=v.dirname(t);for(;;){try{return await n(r),i}catch(e){if(!F(e))return this.reportError(e),i}if(i=r,r===e)return i;let t=v.dirname(r);if(t===r)return i;r=t}}async reconcileNativeTrigger(e,t,i,r,s=0,a){let o,c,d=this.fsw;if(!this.isHelperActive(t,e))return;let u=()=>o??=t.withObservation(i),p=r??(null===i.relativePath?e:eM(e,i.relativePath));if(!p)return void this.reportError(Error(`Native watcher reported a path outside its root: ${i.relativePath}`));let f=s+this.candidateDepth(e,p),m=d.options.depth;if(void 0!==m&&f>m+1||this.candidateIgnored(e,p))return;try{c=await n(p)}catch(n){if(!F(n)){if(this.reportError(n),a)return;let t=p===e?e:v.dirname(p),i=Math.max(0,s+this.candidateDepth(e,t));await this.readDirectory(t,!1,u().fork(t),void 0,t,i);return}if(d.closed)return;let t=p===e?e:await this.highestMissingPath(e,p);if(d.closed)return;if(t===e){d.removePath(v.dirname(e),v.basename(e),!0),a?.onRootMissing?.();return}let i=v.dirname(t),r=v.basename(t);d.tree.getDirectory(i).has(r)?d.removePath(i,r):a||await this.readDirectory(i,!1,u().fork(i),void 0,i,Math.max(0,s+this.candidateDepth(e,i)));return}if(!this.isHelperActive(t,p)||this.candidateIgnored(e,p,c))return;if(!c.isDirectory()&&!(c.isSymbolicLink()&&d.options.followSymlinks)){let e=d.tree.consumeInitialCreate(p,c,i,d.options.ignoreInitial);if(void 0!==e){e&&d.emitEvent(e,p,c);return}}if(p===e){if(!c.isDirectory())return;t.recursiveRoot===e?await this.rescanRecursiveTree(e,u(),s):await this.readDirectory(e,!1,u(),void 0,e,s);return}let g=v.dirname(p),w=v.basename(p),y=d.tree.getDirectory(g),b=y.has(w);if(c.isSymbolicLink()){let e;if(!d.options.followSymlinks){let e=!0;try{e=await l(p)}catch{}b||y.add(w),d.tree.symlinkPaths.set(Y(p),e),b&&d.tree.isDuplicateObservation(p,c,i)||d.emitEvent(b?L:G,p,c),b||d.tree.recordObserved(p,c,"add",i);return}let r=Y(p),s=d.tree.symlinkPaths.get(r);try{e=await h(p)}catch(e){if(!F(e))return void this.reportError(e)}if(b&&"string"==typeof s&&(void 0===e||Y(s)!==Y(e))){let i=d.tree.observed.get(r)?.kind;if(d.removePath(g,w,"directory"===i),!e||!this.isHelperActive(t,p))return;let s=u().fork(p);s.recursiveRoot=void 0,await this.addPathOnce(p,!1,s,f);return}let n=d.tree.consumeInitialCreate(p,c,i,d.options.ignoreInitial);if(void 0!==n){if(n){d.closePath(p,!0);let e=u().fork(p);e.recursiveRoot=void 0,await this.addPathOnce(p,!1,e,f)}return}if(b)d.emitEvent(L,p,c);else{let e=u().fork(p);e.recursiveRoot=void 0,await this.addPathOnce(p,!1,e,f)}return}if(c.isDirectory()){let e=u().fork(p),t=d.tree.consumeInitialCreate(p,c,i,d.options.ignoreInitial);if(void 0!==t){t&&(d.closePath(p,!0),await this.addPathOnce(p,!1,e,f));return}b?d.tree.replacedSinceObserved(p,c)?(d.removePath(g,w,!0),await this.addPathOnce(p,!1,e,f)):(void 0===m||f<=m)&&await this.readDirectory(p,!1,e,void 0,p,f):await this.addPathOnce(p,!1,e,f);return}b?d.tree.isDuplicateObservation(p,c,i)||d.emitEvent(L,p,c):await this.addPathOnce(p,!1,u(),f)}watchRootParent(e,t){if(!this.fsw.options.backendCapabilities.perDirectory||!_)return;let i=v.dirname(e);if(v.resolve(i)===v.resolve(e))return;let r=v.normalize(v.toNamespacedPath(v.resolve(i))).toLowerCase(),s=v.basename(e).toLowerCase(),a=this.fsw.lifecycle.generation,o=!0,l=e=>{if(null===e)return!0;let t=v.isAbsolute(e)?v.resolve(e):v.resolve(i,e);return v.normalize(v.toNamespacedPath(v.dirname(t))).toLowerCase()===r&&v.basename(t).toLowerCase()===s},h=()=>o&&this.fsw.lifecycle.isActive(a)&&this.isHelperActive(t,e),c=r=>{"native"===r.kind&&l(r.relativePath)&&h()&&this.reconcileBackendTrigger(e,!1,r,async()=>{let r;try{r=await n(e)}catch(t){F(t)?this.fsw.removePath(i,v.basename(e),!0):this.reportError(t);return}if(h()){if(!r.isDirectory()){this.fsw.removePath(i,v.basename(e),!0),await this.addPathOnce(e,!1,t,0);return}await this.readDirectory(e,!1,t,void 0,e,0)}},h)},d=ek(i,v.resolve(i),{persistent:this.fsw.options.persistent},{publish:c,errHandler:this.reportError,rawEmitter:(e,t,i)=>{l(t)&&this.fsw.emitRaw(e,t,i)}},this.fsw.lifecycle.abortController.signal);if(d)return()=>{if(o)return o=!1,d.close()}}async watchRecursiveDirectory(e,t,i,r){let a,o,l,h=this.fsw,c=h.lifecycle.generation,d=Y(e),u=new eq(1024),p=[],f="scanning",m=!1,g=(t=e)=>h.lifecycle.isActive(c)&&h.isPathGenerationActive(t,r.pathGeneration),w=(t=e)=>"recovering"!==f&&"closed"!==f&&g(t),y=async t=>{let s;if(!g())return;r.recursiveRoot=void 0,r.recursiveDisabled=!0;try{s=await n(e)}catch(i){F(i)?h.removePath(v.dirname(e),v.basename(e),!0):this.reportError(i),this.reportError(t);return}let a=await this.handleDirectory(e,s,!1,i,void 0,r);if(!g()){a&&await a();return}a&&p.push(a),await this.subscribeTrackedDirectories(e,r,i),this.reportError(t)},b=t=>{if(!w())return;if("live"!==f)return void u.push(t);let i=null===t.relativePath?e:eM(e,t.relativePath)??e;this.reconcileBackendTrigger(e,!0,t,()=>w()?this.reconcileNativeTrigger(e,r,t):void 0,()=>w(i))},P=function(e,t,i,r){if(ew)return{kind:"unsupported"};let n=v.resolve(e),a={...i,watchedPath:e,persistent:t},o=eg.get(n);if(!o){let i,r,a=ef(e);try{i=s(a,{persistent:t,recursive:!0},(e,t)=>{let i=r;if(!i||i.closed||eg.get(n)!==i)return;let s={kind:"native",resource:n,rawEvent:e,relativePath:em(a,t),sequence:++i.sequence,observedAt:ep()};i.subscribers.forEach(i=>{i.rawEmitter(e,t,{watchedPath:i.watchedPath}),i.publish(s)})})}catch(e){if("recursive-unsupported"===j(e))return ew=!0,{kind:"unsupported"};return{kind:"failed",error:e}}r=o={resource:n,generation:++el,subscribers:new Set,closed:!1,watcher:i,sequence:0},eg.set(n,o),i.on(K,e=>{let t;(t=ec(o,eg))&&t.forEach(t=>t.failure(e))})}ed(o,a);let l=eu(o,a,eg);return r.aborted&&l.close(),{kind:"subscribed",subscription:l}}(e,h.options.persistent,{publish:b,failure:t=>{if(!w())return;let i="live"!==f;f="recovering",h.tree.recursiveRoots.delete(d),a=t,m=!0,i||(o=h.reconciliation.enqueue(e,()=>y(t),!1))},rawEmitter:(...e)=>h.emitRaw(...e)},h.lifecycle.abortController.signal);if("unsupported"===P.kind)return!1;if("failed"===P.kind)throw P.error;l=P.subscription,h.tree.recursiveRoots.add(d),r.recursiveRoot=e;let k=async()=>{"closed"!==f&&(f="closed",h.tree.recursiveRoots.delete(d),u.clear(),await l?.close(),o&&await Promise.allSettled([o]),await Promise.allSettled(p.map(e=>e())))};try{if(await this.scanRecursiveTree(e,t,r,i),!m){f="replaying";let t=0;for(;w();){if(u.overflowed){u.clear(),t=0;let i={kind:"native",resource:l.resource,rawEvent:L,relativePath:null,sequence:Number.MAX_SAFE_INTEGER,observedAt:ep()};await this.reconcileBackendTrigger(e,!0,i,()=>this.reconcileNativeTrigger(e,r,i),()=>w(),!1);continue}if(t>=u.entries.length)break;let i=u.entries[t++];if("rename"===i.rawEvent&&null!==i.relativePath){let t=eM(e,i.relativePath);t&&t!==e&&h.tree.getDirectory(v.dirname(t)).has(v.basename(t))&&h.tree.markInitialCreate(t)}await this.reconcileBackendTrigger(e,!0,i,()=>this.reconcileNativeTrigger(e,r,i),()=>w(),!1)}"recovering"!==f&&(f="live")}m&&(u.clear(),await y(a)),u.clear(),h.tree.clearInitialCreates(e)}catch(e){throw await k(),e}return g()?k:void await k()}async subscribeTrackedDirectories(e,t,i){let r=this.fsw,s=v.resolve(e),n=e=>{let i=Y(e);return this.isHelperActive(t,e)&&!r.lifecycle.closers.has(i)&&!r.tree.symlinkPaths.has(i)&&(r.tree.peekDirectory(v.dirname(e))?.has(v.basename(e))??!1)},a=[...r.tree.watched.values()].filter(e=>et(s,e.path)).map(t=>v.join(e,v.relative(s,t.path))).filter(n).sort((e,t)=>e.length-t.length),o=0,l=async()=>{for(;o<a.length;){let r=a[o++];n(r)&&await this.addPathOnce(r,!1,t,i+this.candidateDepth(e,r))}},h=Math.min(16,a.length);await Promise.all(Array.from({length:h},l))}async handleDirectory(e,t,i,r,s,a){let o;if(!this.isHelperActive(a,e))return;if(s)this.fsw.tree.getDirectory(e);else{let r=this.fsw.tree.getDirectory(v.dirname(e)),s=r.has(v.basename(e));i&&this.fsw.options.ignoreInitial||s||this.fsw.emitEvent(q,e,t),r.add(v.basename(e)),this.fsw.tree.getDirectory(e),this.fsw.tree.recordObserved(e,t,s?void 0:"add",a.observationTrigger,i&&!!a.recursiveRoot,!0)}let l=this.fsw.options.depth;if(null==l||r<=l){if(this.fsw.options.backendCapabilities.recursive&&0===r&&!s&&!a.recursiveRoot&&!a.recursiveDisabled){let t=await this.watchRecursiveDirectory(e,i,r,a);if(!1!==t)return t}if(a.recursiveRoot){s||await this.scanRecursiveTree(e,i,a,r);return}let l=new eq(1024),h=new Set,d=!s,u=!0,p=M&&!s,f=s?v.join(e,s):void 0,m=()=>{f&&u&&this.isHelperActive(a,f)&&this.fsw.rewatchMissingPath(f)},g=e=>{if(s){this.fsw.tree.getDirectory(e).has(s)&&this.fsw.removePath(e,s),m();return}this.fsw.removePath(v.dirname(e),v.basename(e),!0)},w=async(t,i,o)=>{if(u&&this.isHelperActive(a,t)){if(this.fsw.options.backendCapabilities.polling&&!i)return void g(t);if("native"===o.kind){let e;try{let i=await n(t);e=i.isSymbolicLink()&&this.fsw.options.followSymlinks?await c(t):i}catch(e){F(e)?g(t):this.reportError(e);return}if(!e.isDirectory()){g(t),s||await this.addPathOnce(t,!1,a,r);return}}await this.readDirectory(t,!1,a,s,e,r)}},y=(t,i,n)=>{if(u&&this.isHelperActive(a,t))return d?void l.push({path:t,stats:i,trigger:n}):"native"!==n.kind||s?"native"===n.kind&&s&&(t===e||(_?v.basename(t).toLowerCase()===s.toLowerCase():v.basename(t)===s))?this.reconcileNativeTrigger(e,a,n,f,r,{onRootMissing:m}):w(e,i,n):p?(p=!1,(async()=>{await this.reconcileNativeTrigger(e,a,n,t,r),await w(e,void 0,n)})()):this.reconcileNativeTrigger(e,a,n,t,r)},b=0!==r||s?void 0:this.watchRootParent(e,a);if(o=this.subscribePath(e,y,t.isDirectory()?t:void 0,!0,s?v.join(e,s):e),s&&f&&o){let t=eL(v.resolve(e));await this.fsw.reconciliation.enqueue(f,async()=>{this.fsw.tree.getDirectory(e).has(s)||await y(f,void 0,t)},f)}if(!s){await this.readDirectory(e,i,a,s,e,r);let t=0;for(;!this.fsw.closed;){if(l.overflow){let i=l.overflow;l.clear(),t=0,await w(e,i.stats,i.trigger);continue}if(t>=l.entries.length)break;let i=l.entries[t++];"native"===i.trigger.kind&&"rename"===i.trigger.rawEvent&&i.path!==e&&this.fsw.tree.getDirectory(v.dirname(i.path)).has(v.basename(i.path))&&(this.fsw.tree.markInitialCreate(i.path),h.add(i.path)),await this.reconcileBackendTrigger(e,!0,i.trigger,()=>"native"!==i.trigger.kind||s?w(e,i.stats,i.trigger):this.reconcileNativeTrigger(e,a,i.trigger,i.path,r),()=>u&&this.isHelperActive(a,i.path),!1)}l.clear(),h.forEach(e=>this.fsw.tree.clearInitialCreate(e)),d=!1}if(!this.isHelperActive(a,e)){u=!1,o&&await o(),b&&await b();return}if(o||b){let e=[o,b].filter(e=>void 0!==e);o=async()=>{u&&(u=!1,l.clear(),await Promise.allSettled(e.map(e=>e())))}}}return o}async addRoot(e,t,i,r){let s=e,n=r,a=this.fsw.lifecycle.generation;for(;this.fsw.lifecycle.isActive(a);){if("complete"===await this.addPathOnce(s,t,void 0,0,n,i))return;let e=v.dirname(s);if(e===s)return;n=v.basename(s),s=e}}async addPathOnce(e,t,i,r,s,a){if(this.fsw.isIgnored(e)||this.fsw.closed)return"complete";let o=i?i.fork(e):this.fsw.createHelper(e);if(i||void 0===a||(o.pathGeneration=a),!this.isHelperActive(o))return"complete";try{let a,d=await n(o.watchPath);if(!this.isHelperActive(o)||this.fsw.isIgnored(o.watchPath,d))return"complete";let u=this.fsw.options.followSymlinks,p=d.isSymbolicLink(),f=p&&u?await c(o.watchPath):d,m=p&&u?await h(e):void 0;if(f.isDirectory()){let i=Y(e),n=u?await h(e):e,l=m??e,c=Y(n);if(!this.isHelperActive(o))return"complete";if(p&&o.realpathAncestry.has(c))return this.fsw.tree.getDirectory(v.dirname(o.watchPath)).add(v.basename(o.watchPath)),this.fsw.tree.getDirectory(o.watchPath),this.fsw.tree.symlinkPaths.set(i,l),this.fsw.tree.recordObserved(o.watchPath,f,"add",o.observationTrigger,t&&!!o.recursiveRoot),t&&this.fsw.options.ignoreInitial||this.fsw.emitEvent(q,o.watchPath,f),"complete";if(o.realpathAncestry.add(c),o.recursiveRoot&&p&&(o.recursiveRoot=void 0),p&&(o.recursiveDisabled=!0),a=await this.handleDirectory(o.watchPath,f,t,r,s,o),!this.isHelperActive(o))return a&&await a(),"complete";if(s&&!a)return"watch-parent";p&&this.fsw.tree.symlinkPaths.set(i,l)}else if(p&&!u){let s=await l(e),n=!this.fsw.options.backendCapabilities.polling&&!o.recursiveRoot&&!i,h=this.handleFile(o.watchPath,f,t,!o.recursiveRoot,o.observationTrigger,t&&!!o.recursiveRoot,n);if(o.recursiveRoot)return this.fsw.tree.symlinkPaths.set(Y(e),s),"complete";let d=v.dirname(o.watchPath),u=await c(d),p=this.fsw.createHelper(d);p.pathGeneration=o.pathGeneration;let m=await this.handleDirectory(d,u,t,r,v.basename(o.watchPath),p),g=this.watchSymlinkDeletion(o.watchPath);if(!this.isHelperActive(o))return h&&await h(),m&&await m(),g&&g(),"complete";a=async()=>{await Promise.allSettled([h,m,g].filter(e=>void 0!==e).map(e=>e()))},this.fsw.tree.symlinkPaths.set(Y(e),s)}else{let s;m&&this.fsw.tree.symlinkPaths.set(Y(e),m);let n=!this.fsw.options.backendCapabilities.polling&&!o.recursiveRoot&&!i,l=this.handleFile(o.watchPath,f,t,!o.recursiveRoot,o.observationTrigger,t&&!!o.recursiveRoot,n),h=m??(n?o.watchPath:void 0),d=h?this.subscribeMappedFile(o.watchPath,h,o,r,M&&f.isFile()):void 0;if(n&&m){let e=v.dirname(o.watchPath),i=await c(e),n=this.fsw.createHelper(e);n.pathGeneration=o.pathGeneration,s=await this.handleDirectory(e,i,t,r,v.basename(o.watchPath),n)}let u=[l,d,s].filter(e=>void 0!==e);a=0===u.length?void 0:async()=>{await Promise.allSettled(u.map(e=>e()))}}if(!this.isHelperActive(o))return a&&await a(),"complete";return a&&this.fsw.addPathCloser(s?v.join(e,s):e,a),"complete"}catch(e){if(!this.isHelperActive(o))return"complete";return this.fsw.handleError(e),"watch-parent"}}}let eK=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,eV=new Set(["auto","native","native-recursive","polling"]),eX=Object.freeze({stabilityThreshold:2e3,pollInterval:100});function*eJ(e){let t=v.resolve(e);for(let e=v.dirname(t);e!==t;e=v.dirname(e))yield Y(e),t=e}function eQ(e){return Array.isArray(e)?e:[e]}function eY(e){let t=eQ(e).flat();if(!t.every(e=>"string"==typeof e))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(J)}function eZ(e,t){return v.isAbsolute(e)?e:v.join(t,e)}function e0(e,t){if(!Number.isFinite(t)||t<=0)throw TypeError(`${e} must be a finite number greater than zero`)}function e1(e,t){if(!Number.isFinite(t)||t<0)throw TypeError(`${e} must be a finite non-negative number`)}class e2 extends i{options;lifecycle;tree;reconciliation;events;scheduler;handler;readyEmitted;streams;get closed(){return void 0!==this.lifecycle&&"OPEN"!==this.lifecycle.state}#e;#t;#i;#r;#s;#n;#a;#o;#l;#h;#c;#d;constructor(e={},t=W){let i,r;if(super(),void 0!==e.backend&&!eV.has(e.backend))throw TypeError("backend must be auto, native, native-recursive, or polling");this.#e=new Set,this.streams=new Set,this.#t=new Map,this.#i=0,this.#r=new Map,this.#a=new Map,this.#o=new Set,this.#l=new Map,this.readyEmitted=!1,this.#c=!1,this.#d=!1,this.scheduler=t;let s=e.awaitWriteFinish,n={...e,persistent:e.persistent??!0,ignoreInitial:e.ignoreInitial??!1,ignorePermissionErrors:e.ignorePermissionErrors??!1,pollingInterval:e.pollingInterval??e.interval??100,pollingBinaryInterval:e.pollingBinaryInterval??e.binaryInterval??300,interval:100,binaryInterval:300,followSymlinks:e.followSymlinks??!0,backend:e.backend??"auto",usePolling:e.usePolling??!1,depth:1/0===e.depth?void 0:e.depth,backendStrategy:"native-per-directory",backendCapabilities:void 0,atomic:e.atomic??!0,ignored:Object.freeze(e.ignored?eQ(e.ignored).map(er):[]),awaitWriteFinish:!0===s?eX:"object"==typeof s&&Object.freeze({...eX,...s})};(!0===e.usePolling||z)&&(n.backend="polling");let a=process.env.CHOKIDAR_USEPOLLING;if(void 0!==a){let e=a.toLowerCase();"false"!==e&&"0"!==e&&("true"===e||"1"===e||e)?n.backend="polling":"polling"===n.backend&&(n.backend="auto")}let o=process.env.CHOKIDAR_INTERVAL;if(void 0!==o&&(n.pollingInterval=Number(o)),n.interval=n.pollingInterval,n.binaryInterval=n.pollingBinaryInterval,n.usePolling="polling"===n.backend,i="native-recursive"===n.backend||"auto"===n.backend&&(M||_),r="polling"===n.backend?"polling":i&&void 0===n.depth?"native-recursive-preferred":"native-per-directory",n.backendCapabilities=Object.freeze({kind:r,polling:"polling"===r,recursive:"native-recursive-preferred"===r,perDirectory:"native-per-directory"===r}),n.backendStrategy=n.backendCapabilities.kind,void 0===e.atomic&&(n.atomic=!n.usePolling),e0("pollingInterval",n.pollingInterval),e0("pollingBinaryInterval",n.pollingBinaryInterval),"number"==typeof n.atomic)e1("atomic",n.atomic);else if("boolean"!=typeof n.atomic)throw TypeError("atomic must be a boolean or finite non-negative number");if(void 0!==n.depth&&(!Number.isSafeInteger(n.depth)||n.depth<0))throw TypeError("depth must be a non-negative safe integer");n.awaitWriteFinish&&(e0("awaitWriteFinish.pollInterval",n.awaitWriteFinish.pollInterval),e1("awaitWriteFinish.stabilityThreshold",n.awaitWriteFinish.stabilityThreshold)),this.options=n,this.lifecycle=new eC(()=>{this.#c&&this.queueReady()},e=>{this.closed||this.handleError(e instanceof Error?e:Error(String(e)))}),this.tree=new eN(()=>!this.options.backendCapabilities.polling),this.reconciliation=new eO(this.lifecycle),this.events=new eR({options:this.options,scheduler:this.scheduler,lifecycle:this.lifecycle,isClosed:()=>this.closed,capturePathGeneration:()=>this.capturePathGeneration(),isPathGenerationActive:(e,t)=>this.isPathGenerationActive(e,t),isReady:()=>this.readyEmitted,remove:(e,t)=>this.removePath(e,t),handleError:e=>this.handleError(e),publish:(e,t)=>this.emitWithAll(e,t)}),this.handler=new e$(this),Object.freeze(n)}addIgnoredPath(e){if(ei(e=this.ignoredMatcher(e))){for(let t of this.#e)if(ei(t)&&t.path===e.path&&t.recursive===e.recursive)return}this.#e.add(e),this.#h=void 0}removeIgnoredPath(e){if(e=this.ignoredMatcher(e),this.#e.delete(e),"string"==typeof e)for(let t of this.#e)ei(t)&&t.path===e&&this.#e.delete(t);this.#h=void 0}ignoredMatcher(e){return"string"==typeof e?Y(e):ei(e)?{path:Y(e.path),recursive:e.recursive}:e}capturePathGeneration(){return this.#i}invalidatePath(e){this.#r.set(Y(e),++this.#i)}isPathGenerationActive(e,t){if("OPEN"!==this.lifecycle.state)return!1;if(0===this.#r.size)return!0;let i=Y(e);for(let[e,r]of this.#r)if(!(r<=t)&&ee(e,i))return!1;return!0}queueReady(){this.closed||this.readyEmitted||(this.#c=!0,this.lifecycle.tasks.size>0||this.#d||(this.#d=!0,process.nextTick(()=>{this.#d=!1,this.closed||this.readyEmitted||this.lifecycle.tasks.size>0||(this.#c=!1,this.readyEmitted=!0,this.emit(N))})))}add(e){if(this.closed)throw Error("Cannot add paths after FSWatcher.close() has been called");let{cwd:t}=this.options,i=eY(e);t&&(i=i.map(e=>eZ(e,t))),i.forEach(e=>{this.removeIgnoredPath(e),this.addRootAncestors(e)}),this.readyEmitted||(this.#c=!0);let r=Promise.all(i.map(async e=>{let t=Y(e);if(this.lifecycle.closers.has(t)||this.#t.has(t))return;let i=Symbol(t),r=this.capturePathGeneration();this.#t.set(t,i);try{await this.handler.addRoot(e,!0,r)}finally{this.#t.get(t)===i&&this.#t.delete(t)}}));return this.lifecycle.track(r),this.readyEmitted||this.queueReady(),this}unwatch(e){if(this.closed)return this;let t=eY(e),{cwd:i}=this.options;return i&&(t=t.map(e=>eZ(e,i))),t.forEach(e=>{let t=Y(e),i=this.tree.watched.has(t);this.invalidatePath(t),this.removeRootAncestors(t),this.#t.delete(t),this.events.cancelPath(t),this.closePath(t,i),this.addIgnoredPath(t),i&&this.addIgnoredPath({path:t,recursive:!0}),this.#h=void 0}),this}close(){if(this.#s)return this.#s;let e=this.lifecycle.beginClose();return this.removeAllListeners(),this.events.close(),this.#t.clear(),this.#o.clear(),this.#l.clear(),this.streams.forEach(e=>e.destroy()),this.#n=void 0,this.#h=void 0,this.readyEmitted=!1,this.tree.dispose(),this.#r.clear(),this.streams.clear(),this.reconciliation.clear(),this.#a.clear(),this.#s=(async()=>{let t=await Promise.allSettled(e);await this.lifecycle.drain(),this.lifecycle.finishClose();let i=t.find(e=>"rejected"===e.status);if(i)throw i.reason})(),this.#s}getWatched(){let e=Object.create(null);return this.tree.watched.forEach(t=>{let i=t.path;e[(this.options.cwd?v.relative(this.options.cwd,i):i)||"."]=t.getChildren().sort()}),e}emitRaw(...e){this.closed||this.emit($,...e)}emitWithAll(e,t){this.emit(e,...t),e!==K&&this.emit(H,e,...t)}async emitEvent(e,t,i){this.closed||await this.events.emit(e,t,i)}handleError(e){if(this.closed)return;let t=e instanceof Error?e:Error(String(e));F(t)||this.options.ignorePermissionErrors&&"permission"===j(t)||this.emit(K,t)}isIgnored(e,t){if(this.options.atomic&&eK.test(e))return!0;if(!this.#n){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(t=>(function(e,t=process.cwd()){return"string"==typeof e?J(v.isAbsolute(e)?e:v.join(t,e)):ei(e)?{path:J(v.isAbsolute(e.path)?e.path:v.join(t,e.path)),recursive:e.recursive}:e})(t,e)),i=en(t),r=t.filter(e=>"string"==typeof e||ei(e)),s=en(r);this.#n=(e,t)=>{let n;if(i(e,t))return!0;if(_||0===r.length)return!1;let a=v.resolve(e);if(t?.isDirectory())n=this.realDirectory(a);else{let e=this.realDirectory(v.dirname(a));void 0!==e&&(n=v.join(e,v.basename(a)))}return void 0!==n&&n!==a&&s(n,t)}}return!(!this.#n(e,t)||this.isRootAncestor(e,t))||0!==this.#e.size&&(this.#h||(this.#h=en([...this.#e])),this.#h(Y(e),t))}isRootAncestor(e,t){return!t?.isFile()&&this.#l.has(Y(e))}addRootAncestors(e){let t=Y(e);if(!this.#o.has(t))for(let i of(this.#o.add(t),eJ(e)))this.#l.set(i,(this.#l.get(i)??0)+1)}removeRootAncestors(e){if(this.#o.delete(Y(e)))for(let t of eJ(e)){let e=(this.#l.get(t)??1)-1;e>0?this.#l.set(t,e):this.#l.delete(t)}}realDirectory(e){let t,i=Y(e);if(this.#a.has(i))return this.#a.get(i);try{t=r.native(e)}catch{}return this.#a.set(i,t),t}isUnwatched(e){return 0!==this.#e.size&&(this.#h||(this.#h=en([...this.#e])),this.#h(Y(e)))}createHelper(e){return new eo(e,this.options.followSymlinks,{capturePathGeneration:()=>this.capturePathGeneration(),isntIgnored:(e,t)=>!this.isIgnored(e,t)})}removeTreeItem(e,t){let i=this.tree.peekDirectory(e);if(!i?.remove(t))return;let r=i.path,s=this.lifecycle.generation;this.lifecycle.track((async()=>{try{await o(r)}catch(e){F(e)&&this.lifecycle.isActive(s)&&this.removePath(v.dirname(r),v.basename(r))}})())}removePath(e,t,i){let r=v.join(e,t),s=Y(r);for(let e of(i=null!=i?i:this.tree.watched.has(s),this.tree.peekDirectory(r)?.getChildren()??[]))this.removePath(r,e);let n=this.tree.peekDirectory(e)?.has(t)??!1,a=this.lifecycle.closers.has(s);this.removeTreeItem(e,t),this.tree.symlinkPaths.has(s)&&this.tree.symlinkPaths.delete(s);let o=this.events.pendingWrites.get(s),l=!1;this.options.awaitWriteFinish&&o&&(l=o.cancelWait()===G),this.tree.watched.delete(s),this.tree.observed.delete(s);let h=i?B:U;!n||l||this.isIgnored(r)||this.emitEvent(h,r),this.closePath(r),(n||a)&&this.#o.has(s)&&this.rewatchMissingPath(r)}rewatchMissingPath(e){this.closed||this.isUnwatched(e)||(this.closePath(e),this.lifecycle.track(this.handler.addRoot(e,!1,this.capturePathGeneration())))}closePath(e,t=!1){let i=Y(e),r=e=>e===i||!!t&&et(i,e);if([...this.lifecycle.closers.keys()].filter(r).forEach(e=>this.closeFile(e)),this.#a.delete(i)||t){let e=i.endsWith("/")?i:`${i}/`;for(let t of this.#a.keys())t.startsWith(e)&&this.#a.delete(t)}if(t){for(let[e,t]of this.tree.watched)r(e)&&(t.dispose(),this.tree.watched.delete(e));for(let e of this.tree.observed.keys())r(e)&&this.tree.observed.delete(e);for(let e of this.tree.symlinkPaths.keys())r(e)&&this.tree.symlinkPaths.delete(e);for(let e of(this.events.cancelWhere(r),this.reconciliation.forgetPending((e,t)=>r(e)||r(t)),this.#t.keys()))r(e)&&this.#t.delete(e)}let s=v.dirname(i);this.removeTreeItem(s,v.basename(i))}closeFile(e){let t=Y(e),i=this.lifecycle.takeClosers(t);0!==i.length&&i.forEach(e=>{try{let t=e();t instanceof Promise&&this.lifecycle.track(t)}catch(e){this.lifecycle.track(Promise.reject(e))}})}addPathCloser(e,t){if(!t)return;if(this.closed||this.isUnwatched(e)){try{let e=t();e instanceof Promise&&this.lifecycle.track(e)}catch(e){this.lifecycle.track(Promise.reject(e))}return}let i=Y(e);this.lifecycle.addCloser(i,t)}createScanStream(e,t){if(this.closed)return;let i=function(e,t={}){let i=t.entryType||t.type;if("both"===i&&(i=b),e){if("string"!=typeof e)throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(i&&!A.includes(i))throw Error(`readdirp: Invalid type passed. Use one of ${A.join(", ")}`)}else throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");let r={...t,root:e};return i&&(r.type=i),new R(r)}(e,{type:H,alwaysStat:!0,lstat:!0,depth:0,...t});this.streams.add(i);let r=()=>this.streams.delete(i);return i.once("close",r),i.once("end",r),i.once(K,r),i}}function e3(e,t={}){let i=new e2(t);return i.add(e),i}let e4={watch:e3,FSWatcher:e2};export{g as chokidar_namespaceObject};
|
package/dist/client/hmr.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { logger } from "./f~0.js";
|
|
2
|
+
function resolveLocation(location1) {
|
|
3
|
+
if ("u" > typeof URL && 'blob:' === location1.protocol && location1.origin && 'null' !== location1.origin) return new URL(location1.origin);
|
|
4
|
+
return location1;
|
|
5
|
+
}
|
|
2
6
|
let createOverlay;
|
|
3
7
|
let clearOverlay;
|
|
4
8
|
const getErrorField = (error, field)=>{
|
|
@@ -44,7 +48,7 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
44
48
|
let hasBuildErrors = false;
|
|
45
49
|
const base = serverBase.endsWith('/') ? serverBase : `${serverBase}/`;
|
|
46
50
|
function formatURL(fallback) {
|
|
47
|
-
const
|
|
51
|
+
const location1 = resolveLocation(self.location);
|
|
48
52
|
const hostname = (fallback ? serverHost : config.host) || location1.hostname;
|
|
49
53
|
const port = (fallback ? serverPort : config.port) || location1.port;
|
|
50
54
|
const protocol = config.protocol || ('https:' === location1.protocol ? 'wss' : 'ws');
|
|
@@ -66,8 +70,13 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
66
70
|
return resolveWebSocketUrl ? resolveWebSocketUrl(url) : url;
|
|
67
71
|
}
|
|
68
72
|
function clearBuildErrors() {
|
|
69
|
-
if (
|
|
70
|
-
|
|
73
|
+
if (hasBuildErrors) {
|
|
74
|
+
var _console_clear, _console;
|
|
75
|
+
null == (_console_clear = (_console = console).clear) || _console_clear.call(_console);
|
|
76
|
+
hasBuildErrors = false;
|
|
77
|
+
null == clearOverlay || clearOverlay();
|
|
78
|
+
renderClientErrors();
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
function handleSuccess() {
|
|
73
82
|
clearBuildErrors();
|
|
@@ -85,7 +94,10 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
85
94
|
tryApplyUpdates();
|
|
86
95
|
}
|
|
87
96
|
function handleErrors({ text, html }) {
|
|
88
|
-
|
|
97
|
+
if (hasBuildErrors) {
|
|
98
|
+
var _console_clear, _console;
|
|
99
|
+
null == (_console_clear = (_console = console).clear) || _console_clear.call(_console);
|
|
100
|
+
}
|
|
89
101
|
hasBuildErrors = true;
|
|
90
102
|
for (const error of text)logger.error(error);
|
|
91
103
|
const { overlay } = config;
|
|
@@ -93,9 +105,15 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
93
105
|
else null == clearOverlay || clearOverlay();
|
|
94
106
|
}
|
|
95
107
|
function handleResolvedClientError({ id, message }) {
|
|
108
|
+
const clientError = clientErrors.find((item)=>item.id === id);
|
|
109
|
+
if (!clientError) return;
|
|
110
|
+
clientError.message = message;
|
|
111
|
+
renderClientErrors();
|
|
112
|
+
}
|
|
113
|
+
function renderClientErrors() {
|
|
96
114
|
if (!createOverlay || hasBuildErrors) return;
|
|
97
|
-
|
|
98
|
-
createOverlay('Runtime errors',
|
|
115
|
+
const message = clientErrors.map((item)=>item.message).filter(Boolean).join('\n\n');
|
|
116
|
+
if (message) createOverlay('Runtime errors', message);
|
|
99
117
|
}
|
|
100
118
|
const shouldUpdate = ()=>lastHash !== import.meta.rspackHash;
|
|
101
119
|
const handleApplyUpdates = (err, updatedModules)=>{
|
|
@@ -144,8 +162,13 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
144
162
|
const message = JSON.parse(e.data);
|
|
145
163
|
switch(message.type){
|
|
146
164
|
case 'hash':
|
|
165
|
+
case 'early-update':
|
|
147
166
|
lastHash = message.data;
|
|
148
|
-
if (
|
|
167
|
+
if (shouldUpdate()) {
|
|
168
|
+
clientErrors.length = 0;
|
|
169
|
+
if (!hasBuildErrors) null == clearOverlay || clearOverlay();
|
|
170
|
+
}
|
|
171
|
+
if ('early-update' === message.type) tryApplyUpdates();
|
|
149
172
|
break;
|
|
150
173
|
case 'ok':
|
|
151
174
|
handleSuccess();
|
|
@@ -244,7 +267,7 @@ function hmr_init(token, config, serverHost, serverPort, serverBase, liveReload,
|
|
|
244
267
|
}
|
|
245
268
|
}
|
|
246
269
|
function fullReload(data) {
|
|
247
|
-
if (!liveReload) return;
|
|
270
|
+
if (!liveReload || "u" < typeof document) return;
|
|
248
271
|
const path = null == data ? void 0 : data.path;
|
|
249
272
|
if (null == path ? void 0 : path.endsWith('.html')) {
|
|
250
273
|
const pathname = decodeURI(location.pathname);
|
package/dist/client/overlay.js
CHANGED
|
@@ -10,9 +10,15 @@ function _define_property(obj, key, value) {
|
|
|
10
10
|
else obj[key] = value;
|
|
11
11
|
return obj;
|
|
12
12
|
}
|
|
13
|
-
const { HTMLElement
|
|
14
|
-
}, customElements
|
|
13
|
+
const { HTMLElement = class {
|
|
14
|
+
}, customElements } = "u" > typeof window ? window : globalThis;
|
|
15
15
|
class ErrorOverlay extends HTMLElement {
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
document.addEventListener('keydown', this.onEscKeydown);
|
|
18
|
+
}
|
|
19
|
+
disconnectedCallback() {
|
|
20
|
+
document.removeEventListener('keydown', this.onEscKeydown);
|
|
21
|
+
}
|
|
16
22
|
init(html) {
|
|
17
23
|
var _root_querySelector, _root_querySelector1;
|
|
18
24
|
const root = this.attachShadow({
|
|
@@ -28,14 +34,11 @@ class ErrorOverlay extends HTMLElement {
|
|
|
28
34
|
}
|
|
29
35
|
e.stopPropagation();
|
|
30
36
|
});
|
|
31
|
-
const onEscKeydown = (e)=>{
|
|
32
|
-
if ('Escape' === e.key || 'Escape' === e.code) this.close();
|
|
33
|
-
document.removeEventListener('keydown', onEscKeydown);
|
|
34
|
-
};
|
|
35
|
-
document.addEventListener('keydown', onEscKeydown);
|
|
36
37
|
}
|
|
37
38
|
constructor(...args){
|
|
38
|
-
super(...args), _define_property(this, "
|
|
39
|
+
super(...args), _define_property(this, "onEscKeydown", (e)=>{
|
|
40
|
+
if ('Escape' === e.key || 'Escape' === e.code) this.close();
|
|
41
|
+
}), _define_property(this, "close", (immediate = false)=>{
|
|
39
42
|
const remove = ()=>{
|
|
40
43
|
var _this_parentNode;
|
|
41
44
|
return null == (_this_parentNode = this.parentNode) ? void 0 : _this_parentNode.removeChild(this);
|
|
@@ -56,7 +59,6 @@ class ErrorOverlay extends HTMLElement {
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
const overlayId = 'rsbuild-error-overlay';
|
|
59
|
-
if (customElements && !customElements.get(overlayId)) customElements.define(overlayId, ErrorOverlay);
|
|
60
62
|
function getOverlayHtml(title, content) {
|
|
61
63
|
return `
|
|
62
64
|
<style>
|
|
@@ -210,5 +212,7 @@ function clearOverlay() {
|
|
|
210
212
|
n.close(true);
|
|
211
213
|
});
|
|
212
214
|
}
|
|
213
|
-
if ("u" > typeof document)
|
|
214
|
-
|
|
215
|
+
if ("u" > typeof document) {
|
|
216
|
+
if (customElements && !customElements.get(overlayId)) customElements.define(overlayId, ErrorOverlay);
|
|
217
|
+
registerOverlay(createOverlay, clearOverlay);
|
|
218
|
+
}
|
package/dist/cssUrlLoader.mjs
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
|
+
import { relativeWithin } from "./1.js";
|
|
2
3
|
import { isCSSModules } from "./c.js";
|
|
3
|
-
let HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullhash)(?::[^\]]+)?]/i, getRelativePath = (root, resourcePath)=>{
|
|
4
|
-
let relativePath =
|
|
5
|
-
if (relativePath
|
|
4
|
+
let HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullhash)(?::[^\]]+)?]/i, BASE_URI = 'rsbuild-css-url://', ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/public-path/`, AUTO_PUBLIC_PATH = '__rsbuild_css_url_auto_public_path__', SINGLE_DOT_PATH_SEGMENT = '__rsbuild_css_url_single_dot__', getPublicPathForExtract = (publicPath)=>/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath) ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replaceAll('.', SINGLE_DOT_PATH_SEGMENT)}`, getRelativePath = (root, resourcePath)=>{
|
|
5
|
+
let relativePath = relativeWithin(root, resourcePath);
|
|
6
|
+
if (relativePath) return relativePath.replace(/\\/g, '/');
|
|
6
7
|
}, pitch = async function(remainingRequest) {
|
|
7
8
|
let root, resourcePath, nameSource, hash, options = this.getOptions();
|
|
8
9
|
if (isCSSModules(options.modules, this)) throw Error('[rsbuild:css] CSS Modules do not support the ?url query. Use ?inline to import the compiled CSS content as a string.');
|
|
9
|
-
let
|
|
10
|
+
let { publicPath } = this._compilation.outputOptions;
|
|
11
|
+
'auto' === publicPath && (publicPath = AUTO_PUBLIC_PATH);
|
|
12
|
+
let publicPathForExtract = 'function' == typeof publicPath ? (pathData, assetInfo)=>getPublicPathForExtract(publicPath(pathData, assetInfo)) : 'string' == typeof publicPath ? getPublicPathForExtract(publicPath) : publicPath, content = ((moduleExports)=>{
|
|
10
13
|
let content = moduleExports && 'object' == typeof moduleExports && 'default' in moduleExports ? moduleExports.default : moduleExports;
|
|
11
14
|
if ('string' != typeof content) throw Error('[rsbuild:css] Expected CSS ?url imports to export a string.');
|
|
12
15
|
return content;
|
|
13
|
-
})(await this.importModule(`!!${remainingRequest}
|
|
16
|
+
})(await this.importModule(`!!${remainingRequest}`, {
|
|
17
|
+
publicPath: publicPathForExtract,
|
|
18
|
+
baseUri: `${BASE_URI}/`
|
|
19
|
+
})).replaceAll(ABSOLUTE_PUBLIC_PATH, '').replaceAll(SINGLE_DOT_PATH_SEGMENT, '.'), ext = node_path.extname(this.resourcePath), sourceFilename = node_path.relative(this.rootContext, this.resourcePath).replace(/\\/g, '/'), name = (root = this.rootContext, resourcePath = this.resourcePath, nameSource = getRelativePath(node_path.join(root, 'src'), resourcePath) ?? getRelativePath(root, resourcePath) ?? node_path.basename(resourcePath), ext ? nameSource.slice(0, -ext.length) : nameSource), contentHash = ((hash = this.utils.createHash(this._compilation.outputOptions.hashFunction)).update(Buffer.from(content)), hash.digest(this._compilation.outputOptions.hashDigest || 'hex')), pathData = {
|
|
14
20
|
contentHash,
|
|
15
21
|
chunk: {
|
|
16
22
|
name,
|
|
@@ -21,10 +27,15 @@ let HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullh
|
|
|
21
27
|
}
|
|
22
28
|
}, assetInfo = {
|
|
23
29
|
sourceFilename
|
|
24
|
-
}, filenameTemplate = 'function' == typeof options.filename ? options.filename(pathData, assetInfo) : options.filename, { path: filename, info } = this._compilation.getAssetPathWithInfo(filenameTemplate, pathData);
|
|
25
|
-
|
|
30
|
+
}, filenameTemplate = 'function' == typeof options.filename ? options.filename(pathData, assetInfo) : options.filename, { path: filename, info } = this._compilation.getAssetPathWithInfo(filenameTemplate, pathData), css = content;
|
|
31
|
+
if (publicPath === AUTO_PUBLIC_PATH) {
|
|
32
|
+
let undoPath = node_path.posix.relative(node_path.posix.dirname(filename), '.');
|
|
33
|
+
css = content.replaceAll(AUTO_PUBLIC_PATH, undoPath ? `${undoPath}/` : '');
|
|
34
|
+
}
|
|
35
|
+
return this.emitFile(filename, css, void 0, {
|
|
26
36
|
...info,
|
|
27
37
|
...assetInfo,
|
|
38
|
+
minimized: options.minimized,
|
|
28
39
|
immutable: info.immutable || HASH_PLACEHOLDER_REGEX.test(filenameTemplate)
|
|
29
40
|
}), `export default import.meta.rspackPublicPath + ${JSON.stringify(filename)};`;
|
|
30
41
|
};
|
package/dist/defaultConfig.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NormalizedConfig, RsbuildConfig, RsbuildEntry } from './types/index.js';
|
|
1
|
+
import type { EnvironmentConfig, NormalizedConfig, PublicDir, PublicDirOptions, RsbuildConfig, RsbuildEntry } from './types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Default allowed origins for CORS.
|
|
4
4
|
* - localhost
|
|
@@ -17,7 +17,12 @@ import type { NormalizedConfig, RsbuildConfig, RsbuildEntry } from './types/inde
|
|
|
17
17
|
*/ export declare const defaultAllowedOrigins: RegExp;
|
|
18
18
|
export declare function getDefaultEntry(root: string): RsbuildEntry;
|
|
19
19
|
export declare const withDefaultConfig: (rootPath: string, userConfig: RsbuildConfig) => Promise<RsbuildConfig>;
|
|
20
|
+
type NormalizedBaseConfig = Omit<NormalizedConfig, 'environments'> & {
|
|
21
|
+
environments: Record<string, EnvironmentConfig>;
|
|
22
|
+
};
|
|
20
23
|
/**
|
|
21
24
|
* Normalizes the user configuration by merging it with defaults and ensuring
|
|
22
25
|
* consistent structure.
|
|
23
|
-
*/ export declare const normalizeConfig: (config: RsbuildConfig, rootPath: string) =>
|
|
26
|
+
*/ export declare const normalizeConfig: (config: RsbuildConfig, rootPath: string) => NormalizedBaseConfig;
|
|
27
|
+
export declare const normalizePublicDirs: (rootPath: string, publicDir?: PublicDir) => Required<PublicDirOptions>[];
|
|
28
|
+
export { };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { require } from './vendors.js';
|
|
|
5
5
|
export { color, RspackChain };
|
|
6
6
|
export declare const getNodeEnv: () => string;
|
|
7
7
|
export declare const setNodeEnv: (env: string) => void;
|
|
8
|
+
export declare const isCI: () => boolean;
|
|
8
9
|
export declare const isFunction: (func: unknown) => func is (...args: any[]) => any;
|
|
9
10
|
export declare const isObject: (obj: unknown) => obj is Record<string, any>;
|
|
10
11
|
export declare const isPlainObject: (obj: unknown) => obj is Record<string, any>;
|
package/dist/helpers/path.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { Rspack } from '../types/index.js';
|
|
2
2
|
export declare function toRelativePath(base: string, filepath: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Returns `target` relative to `parent`, or `undefined` if it is outside `parent`.
|
|
5
|
+
* Returns `''` for the same directory.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* relativeWithin('/project', '/project/src'); // 'src'
|
|
9
|
+
* relativeWithin('/project', '/project'); // ''
|
|
10
|
+
* relativeWithin('/project', '/project-legacy'); // undefined
|
|
11
|
+
*/ export declare function relativeWithin(parent: string, target: string): string | undefined;
|
|
3
12
|
export declare function getCommonParentPath(paths: string[]): string;
|
|
4
13
|
export declare const getCompiledPath: (packageName: string) => string;
|
|
5
14
|
/**
|
package/dist/helpers/stats.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ActionType, RsbuildStats, Rspack } from '../types/index.js';
|
|
|
7
7
|
*/ export declare const getStatsErrors: ({ errors, children }: RsbuildStats) => Rspack.StatsError[];
|
|
8
8
|
export declare const getStatsWarnings: ({ warnings, children }: RsbuildStats) => Rspack.StatsError[];
|
|
9
9
|
export declare function getRsbuildStats(statsInstance: Rspack.Stats | Rspack.MultiStats, compiler: Rspack.Compiler | Rspack.MultiCompiler, logger: Logger, action?: ActionType): RsbuildStats;
|
|
10
|
+
export declare function getEarlyStats(stats: Rspack.Stats): RsbuildStats;
|
|
10
11
|
export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, root: string, logger: Logger): {
|
|
11
12
|
message?: string;
|
|
12
13
|
level?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/** Find the nearest workspace root, falling back to the nearest package root. */ export declare function findWorkspaceRoot(root: string): string;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn, OnRestartFn, Rspack } from './types/index.js';
|
|
1
|
+
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnClosePreviewServerFn, OnExitFn, OnRestartFn, Rspack } from './types/index.js';
|
|
2
2
|
export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
|
|
3
3
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
4
4
|
export declare function initHooks(): {
|
|
@@ -10,6 +10,7 @@ export declare function initHooks(): {
|
|
|
10
10
|
onBeforeDevCompile: AsyncHook<OnBeforeDevCompileFn>;
|
|
11
11
|
onAfterDevCompile: AsyncHook<OnAfterDevCompileFn>;
|
|
12
12
|
onCloseDevServer: AsyncHook<OnCloseDevServerFn>;
|
|
13
|
+
onClosePreviewServer: AsyncHook<OnClosePreviewServerFn>;
|
|
13
14
|
onAfterStartDevServer: AsyncHook<OnAfterStartDevServerFn>;
|
|
14
15
|
onBeforeStartDevServer: AsyncHook<OnBeforeStartDevServerFn>;
|
|
15
16
|
onAfterStartPreviewServer: AsyncHook<OnAfterStartPreviewServerFn>;
|