UNPKG

@modern-js/utils

Version:

A Progressive React Framework for modern web development.

1,201 lines (1,200 loc) 175 kB
/*! LICENSE: index.js.LICENSE.txt */ (()=>{ var t = { 372: (t, e, s)=>{ "use strict"; Object.defineProperty(e, "__esModule", { value: true }); const r = s(700); const i = s(498); const n = "!"; const o = { returnIndex: false }; const arrify = (t)=>Array.isArray(t) ? t : [ t ]; const createPattern = (t, e)=>{ if ("function" == typeof t) return t; if ("string" == typeof t) { const s = r(t, e); return (e)=>t === e || s(e); } if (t instanceof RegExp) return (e)=>t.test(e); return (t)=>false; }; const matchPatterns = (t, e, s, r)=>{ const n = Array.isArray(s); const o = n ? s[0] : s; if (!n && "string" != typeof o) throw new TypeError("anymatch: second argument must be a string: got " + Object.prototype.toString.call(o)); const a = i(o); for(let t = 0; t < e.length; t++){ const s = e[t]; if (s(a)) return r ? -1 : false; } const u = n && [ a ].concat(s.slice(1)); for(let e = 0; e < t.length; e++){ const s = t[e]; if (n ? s(...u) : s(a)) return r ? e : true; } return r ? -1 : false; }; const anymatch = (t, e, s = o)=>{ if (null == t) throw new TypeError("anymatch: specify first argument"); const i = "boolean" == typeof s ? { returnIndex: s } : s; const a = i.returnIndex || false; const u = arrify(t); const l = u.filter((t)=>"string" == typeof t && t.charAt(0) === n).map((t)=>t.slice(1)).map((t)=>r(t, i)); const c = u.filter((t)=>"string" != typeof t || "string" == typeof t && t.charAt(0) !== n).map((t)=>createPattern(t, i)); if (null == e) return (t, e = false)=>{ const s = "boolean" == typeof e ? e : false; return matchPatterns(c, l, t, s); }; return matchPatterns(c, l, e, a); }; anymatch.default = anymatch; t.exports = anymatch; }, 828: (t, e, s)=>{ t.exports = s(600); }, 570: (t, e, s)=>{ "use strict"; const r = s(625); const i = s(666); const n = s(183); const o = s(467); const braces = (t, e = {})=>{ let s = []; if (Array.isArray(t)) for (let r of t){ let t = braces.create(r, e); if (Array.isArray(t)) s.push(...t); else s.push(t); } else s = [].concat(braces.create(t, e)); if (e && true === e.expand && true === e.nodupes) s = [ ...new Set(s) ]; return s; }; braces.parse = (t, e = {})=>o(t, e); braces.stringify = (t, e = {})=>{ if ("string" == typeof t) return r(braces.parse(t, e), e); return r(t, e); }; braces.compile = (t, e = {})=>{ if ("string" == typeof t) t = braces.parse(t, e); return i(t, e); }; braces.expand = (t, e = {})=>{ if ("string" == typeof t) t = braces.parse(t, e); let s = n(t, e); if (true === e.noempty) s = s.filter(Boolean); if (true === e.nodupes) s = [ ...new Set(s) ]; return s; }; braces.create = (t, e = {})=>{ if ("" === t || t.length < 3) return [ t ]; return true !== e.expand ? braces.compile(t, e) : braces.expand(t, e); }; t.exports = braces; }, 666: (t, e, s)=>{ "use strict"; const r = s(442); const i = s(456); const compile = (t, e = {})=>{ let walk = (t, s = {})=>{ let n = i.isInvalidBrace(s); let o = true === t.invalid && true === e.escapeInvalid; let a = true === n || true === o; let u = true === e.escapeInvalid ? "\\" : ""; let l = ""; if (true === t.isOpen) return u + t.value; if (true === t.isClose) return u + t.value; if ("open" === t.type) return a ? u + t.value : "("; if ("close" === t.type) return a ? u + t.value : ")"; if ("comma" === t.type) return "comma" === t.prev.type ? "" : a ? t.value : "|"; if (t.value) return t.value; if (t.nodes && t.ranges > 0) { let s = i.reduce(t.nodes); let n = r(...s, { ...e, wrap: false, toRegex: true }); if (0 !== n.length) return s.length > 1 && n.length > 1 ? `(${n})` : n; } if (t.nodes) for (let e of t.nodes)l += walk(e, t); return l; }; return walk(t); }; t.exports = compile; }, 487: (t)=>{ "use strict"; t.exports = { MAX_LENGTH: 65536, CHAR_0: "0", CHAR_9: "9", CHAR_UPPERCASE_A: "A", CHAR_LOWERCASE_A: "a", CHAR_UPPERCASE_Z: "Z", CHAR_LOWERCASE_Z: "z", CHAR_LEFT_PARENTHESES: "(", CHAR_RIGHT_PARENTHESES: ")", CHAR_ASTERISK: "*", CHAR_AMPERSAND: "&", CHAR_AT: "@", CHAR_BACKSLASH: "\\", CHAR_BACKTICK: "`", CHAR_CARRIAGE_RETURN: "\r", CHAR_CIRCUMFLEX_ACCENT: "^", CHAR_COLON: ":", CHAR_COMMA: ",", CHAR_DOLLAR: "$", CHAR_DOT: ".", CHAR_DOUBLE_QUOTE: '"', CHAR_EQUAL: "=", CHAR_EXCLAMATION_MARK: "!", CHAR_FORM_FEED: "\f", CHAR_FORWARD_SLASH: "/", CHAR_HASH: "#", CHAR_HYPHEN_MINUS: "-", CHAR_LEFT_ANGLE_BRACKET: "<", CHAR_LEFT_CURLY_BRACE: "{", CHAR_LEFT_SQUARE_BRACKET: "[", CHAR_LINE_FEED: "\n", CHAR_NO_BREAK_SPACE: " ", CHAR_PERCENT: "%", CHAR_PLUS: "+", CHAR_QUESTION_MARK: "?", CHAR_RIGHT_ANGLE_BRACKET: ">", CHAR_RIGHT_CURLY_BRACE: "}", CHAR_RIGHT_SQUARE_BRACKET: "]", CHAR_SEMICOLON: ";", CHAR_SINGLE_QUOTE: "'", CHAR_SPACE: " ", CHAR_TAB: "\t", CHAR_UNDERSCORE: "_", CHAR_VERTICAL_LINE: "|", CHAR_ZERO_WIDTH_NOBREAK_SPACE: "\ufeff" }; }, 183: (t, e, s)=>{ "use strict"; const r = s(442); const i = s(625); const n = s(456); const append = (t = "", e = "", s = false)=>{ let r = []; t = [].concat(t); e = [].concat(e); if (!e.length) return t; if (!t.length) return s ? n.flatten(e).map((t)=>`{${t}}`) : e; for (let i of t)if (Array.isArray(i)) for (let t of i)r.push(append(t, e, s)); else for (let t of e){ if (true === s && "string" == typeof t) t = `{${t}}`; r.push(Array.isArray(t) ? append(i, t, s) : i + t); } return n.flatten(r); }; const expand = (t, e = {})=>{ let s = void 0 === e.rangeLimit ? 1e3 : e.rangeLimit; let walk = (t, o = {})=>{ t.queue = []; let a = o; let u = o.queue; while("brace" !== a.type && "root" !== a.type && a.parent){ a = a.parent; u = a.queue; } if (t.invalid || t.dollar) return void u.push(append(u.pop(), i(t, e))); if ("brace" === t.type && true !== t.invalid && 2 === t.nodes.length) return void u.push(append(u.pop(), [ "{}" ])); if (t.nodes && t.ranges > 0) { let o = n.reduce(t.nodes); if (n.exceedsLimit(...o, e.step, s)) throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit."); let a = r(...o, e); if (0 === a.length) a = i(t, e); u.push(append(u.pop(), a)); t.nodes = []; return; } let l = n.encloseBrace(t); let c = t.queue; let f = t; while("brace" !== f.type && "root" !== f.type && f.parent){ f = f.parent; c = f.queue; } for(let e = 0; e < t.nodes.length; e++){ let s = t.nodes[e]; if ("comma" === s.type && "brace" === t.type) { if (1 === e) c.push(""); c.push(""); continue; } if ("close" === s.type) { u.push(append(u.pop(), c, l)); continue; } if (s.value && "open" !== s.type) { c.push(append(c.pop(), s.value)); continue; } if (s.nodes) walk(s, t); } return c; }; return n.flatten(walk(t)); }; t.exports = expand; }, 467: (t, e, s)=>{ "use strict"; const r = s(625); const { MAX_LENGTH: i, CHAR_BACKSLASH: n, CHAR_BACKTICK: o, CHAR_COMMA: a, CHAR_DOT: u, CHAR_LEFT_PARENTHESES: l, CHAR_RIGHT_PARENTHESES: c, CHAR_LEFT_CURLY_BRACE: f, CHAR_RIGHT_CURLY_BRACE: h, CHAR_LEFT_SQUARE_BRACKET: p, CHAR_RIGHT_SQUARE_BRACKET: d, CHAR_DOUBLE_QUOTE: _, CHAR_SINGLE_QUOTE: E, CHAR_NO_BREAK_SPACE: g, CHAR_ZERO_WIDTH_NOBREAK_SPACE: m } = s(487); const parse = (t, e = {})=>{ if ("string" != typeof t) throw new TypeError("Expected a string"); let s = e || {}; let y = "number" == typeof s.maxLength ? Math.min(i, s.maxLength) : i; if (t.length > y) throw new SyntaxError(`Input length (${t.length}), exceeds max characters (${y})`); let R = { type: "root", input: t, nodes: [] }; let w = [ R ]; let A = R; let b = R; let v = 0; let S = t.length; let C = 0; let x = 0; let T; const advance = ()=>t[C++]; const push = (t)=>{ if ("text" === t.type && "dot" === b.type) b.type = "text"; if (b && "text" === b.type && "text" === t.type) { b.value += t.value; return; } A.nodes.push(t); t.parent = A; t.prev = b; b = t; return t; }; push({ type: "bos" }); while(C < S){ A = w[w.length - 1]; T = advance(); if (T === m || T === g) continue; if (T === n) { push({ type: "text", value: (e.keepEscaping ? T : "") + advance() }); continue; } if (T === d) { push({ type: "text", value: "\\" + T }); continue; } if (T === p) { v++; let e; while(C < S && (e = advance())){ T += e; if (e === p) { v++; continue; } if (e === n) { T += advance(); continue; } if (e === d) { v--; if (0 === v) break; } } push({ type: "text", value: T }); continue; } if (T === l) { A = push({ type: "paren", nodes: [] }); w.push(A); push({ type: "text", value: T }); continue; } if (T === c) { if ("paren" !== A.type) { push({ type: "text", value: T }); continue; } A = w.pop(); push({ type: "text", value: T }); A = w[w.length - 1]; continue; } if (T === _ || T === E || T === o) { let t = T; let s; if (true !== e.keepQuotes) T = ""; while(C < S && (s = advance())){ if (s === n) { T += s + advance(); continue; } if (s === t) { if (true === e.keepQuotes) T += s; break; } T += s; } push({ type: "text", value: T }); continue; } if (T === f) { x++; let t = b.value && "$" === b.value.slice(-1) || true === A.dollar; let e = { type: "brace", open: true, close: false, dollar: t, depth: x, commas: 0, ranges: 0, nodes: [] }; A = push(e); w.push(A); push({ type: "open", value: T }); continue; } if (T === h) { if ("brace" !== A.type) { push({ type: "text", value: T }); continue; } let t = "close"; A = w.pop(); A.close = true; push({ type: t, value: T }); x--; A = w[w.length - 1]; continue; } if (T === a && x > 0) { if (A.ranges > 0) { A.ranges = 0; let t = A.nodes.shift(); A.nodes = [ t, { type: "text", value: r(A) } ]; } push({ type: "comma", value: T }); A.commas++; continue; } if (T === u && x > 0 && 0 === A.commas) { let t = A.nodes; if (0 === x || 0 === t.length) { push({ type: "text", value: T }); continue; } if ("dot" === b.type) { A.range = []; b.value += T; b.type = "range"; if (3 !== A.nodes.length && 5 !== A.nodes.length) { A.invalid = true; A.ranges = 0; b.type = "text"; continue; } A.ranges++; A.args = []; continue; } if ("range" === b.type) { t.pop(); let e = t[t.length - 1]; e.value += b.value + T; b = e; A.ranges--; continue; } push({ type: "dot", value: T }); continue; } push({ type: "text", value: T }); } do { A = w.pop(); if ("root" !== A.type) { A.nodes.forEach((t)=>{ if (!t.nodes) { if ("open" === t.type) t.isOpen = true; if ("close" === t.type) t.isClose = true; if (!t.nodes) t.type = "text"; t.invalid = true; } }); let t = w[w.length - 1]; let e = t.nodes.indexOf(A); t.nodes.splice(e, 1, ...A.nodes); } }while (w.length > 0); push({ type: "eos" }); return R; }; t.exports = parse; }, 625: (t, e, s)=>{ "use strict"; const r = s(456); t.exports = (t, e = {})=>{ let stringify = (t, s = {})=>{ let i = e.escapeInvalid && r.isInvalidBrace(s); let n = true === t.invalid && true === e.escapeInvalid; let o = ""; if (t.value) { if ((i || n) && r.isOpenOrClose(t)) return "\\" + t.value; return t.value; } if (t.value) return t.value; if (t.nodes) for (let e of t.nodes)o += stringify(e); return o; }; return stringify(t); }; }, 456: (t, e)=>{ "use strict"; e.isInteger = (t)=>{ if ("number" == typeof t) return Number.isInteger(t); if ("string" == typeof t && "" !== t.trim()) return Number.isInteger(Number(t)); return false; }; e.find = (t, e)=>t.nodes.find((t)=>t.type === e); e.exceedsLimit = (t, s, r = 1, i)=>{ if (false === i) return false; if (!e.isInteger(t) || !e.isInteger(s)) return false; return (Number(s) - Number(t)) / Number(r) >= i; }; e.escapeNode = (t, e = 0, s)=>{ let r = t.nodes[e]; if (!r) return; if (s && r.type === s || "open" === r.type || "close" === r.type) { if (true !== r.escaped) { r.value = "\\" + r.value; r.escaped = true; } } }; e.encloseBrace = (t)=>{ if ("brace" !== t.type) return false; if (t.commas >> 0 + t.ranges === 0) { t.invalid = true; return true; } return false; }; e.isInvalidBrace = (t)=>{ if ("brace" !== t.type) return false; if (true === t.invalid || t.dollar) return true; if (t.commas >> 0 + t.ranges === 0) { t.invalid = true; return true; } if (true !== t.open || true !== t.close) { t.invalid = true; return true; } return false; }; e.isOpenOrClose = (t)=>{ if ("open" === t.type || "close" === t.type) return true; return true === t.open || true === t.close; }; e.reduce = (t)=>t.reduce((t, e)=>{ if ("text" === e.type) t.push(e.value); if ("range" === e.type) e.type = "text"; return t; }, []); e.flatten = (...t)=>{ const e = []; const flat = (t)=>{ for(let s = 0; s < t.length; s++){ let r = t[s]; Array.isArray(r) ? flat(r) : void 0 !== r && e.push(r); } return e; }; flat(t); return e; }; }, 240: (t, e, s)=>{ "use strict"; const { sep: r } = s(17); const { platform: i } = process; const n = s(37); e.EV_ALL = "all"; e.EV_READY = "ready"; e.EV_ADD = "add"; e.EV_CHANGE = "change"; e.EV_ADD_DIR = "addDir"; e.EV_UNLINK = "unlink"; e.EV_UNLINK_DIR = "unlinkDir"; e.EV_RAW = "raw"; e.EV_ERROR = "error"; e.STR_DATA = "data"; e.STR_END = "end"; e.STR_CLOSE = "close"; e.FSEVENT_CREATED = "created"; e.FSEVENT_MODIFIED = "modified"; e.FSEVENT_DELETED = "deleted"; e.FSEVENT_MOVED = "moved"; e.FSEVENT_CLONED = "cloned"; e.FSEVENT_UNKNOWN = "unknown"; e.FSEVENT_TYPE_FILE = "file"; e.FSEVENT_TYPE_DIRECTORY = "directory"; e.FSEVENT_TYPE_SYMLINK = "symlink"; e.KEY_LISTENERS = "listeners"; e.KEY_ERR = "errHandlers"; e.KEY_RAW = "rawEmitters"; e.HANDLER_KEYS = [ e.KEY_LISTENERS, e.KEY_ERR, e.KEY_RAW ]; e.DOT_SLASH = `.${r}`; e.BACK_SLASH_RE = /\\/g; e.DOUBLE_SLASH_RE = /\/\//; e.SLASH_OR_BACK_SLASH_RE = /[/\\]/; e.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/; e.REPLACER_RE = /^\.[/\\]/; e.SLASH = "/"; e.SLASH_SLASH = "//"; e.BRACE_START = "{"; e.BANG = "!"; e.ONE_DOT = "."; e.TWO_DOTS = ".."; e.STAR = "*"; e.GLOBSTAR = "**"; e.ROOT_GLOBSTAR = "/**/*"; e.SLASH_GLOBSTAR = "/**"; e.DIR_SUFFIX = "Dir"; e.ANYMATCH_OPTS = { dot: true }; e.STRING_TYPE = "string"; e.FUNCTION_TYPE = "function"; e.EMPTY_STR = ""; e.EMPTY_FN = ()=>{}; e.IDENTITY_FN = (t)=>t; e.isWindows = "win32" === i; e.isMacos = "darwin" === i; e.isLinux = "linux" === i; e.isIBMi = "OS400" === n.type(); }, 578: (t, e, s)=>{ "use strict"; const r = s(147); const i = s(17); const { promisify: n } = s(837); let o; try { o = s(249); } catch (t) { if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(t); } if (o) { const t = process.version.match(/v(\d+)\.(\d+)/); if (t && t[1] && t[2]) { const e = Number.parseInt(t[1], 10); const s = Number.parseInt(t[2], 10); if (8 === e && s < 16) o = void 0; } } const { EV_ADD: a, EV_CHANGE: u, EV_ADD_DIR: l, EV_UNLINK: c, EV_ERROR: f, STR_DATA: h, STR_END: p, FSEVENT_CREATED: d, FSEVENT_MODIFIED: _, FSEVENT_DELETED: E, FSEVENT_MOVED: g, FSEVENT_UNKNOWN: m, FSEVENT_TYPE_FILE: y, FSEVENT_TYPE_DIRECTORY: R, FSEVENT_TYPE_SYMLINK: w, ROOT_GLOBSTAR: A, DIR_SUFFIX: b, DOT_SLASH: v, FUNCTION_TYPE: S, EMPTY_FN: C, IDENTITY_FN: x } = s(240); const Depth = (t)=>isNaN(t) ? {} : { depth: t }; const T = n(r.stat); const H = n(r.lstat); const O = n(r.realpath); const P = { stat: T, lstat: H }; const I = new Map; const L = 10; const N = new Set([ 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912 ]); const createFSEventsInstance = (t, e)=>{ const s = o.watch(t, e); return { stop: s }; }; function setFSEventsListener(t, e, s, r) { let n = i.extname(e) ? i.dirname(e) : e; const a = i.dirname(n); let u = I.get(n); if (couldConsolidate(a)) n = a; const l = i.resolve(t); const c = l !== e; const filteredListener = (t, r, n)=>{ if (c) t = t.replace(e, l); if (t === l || !t.indexOf(l + i.sep)) s(t, r, n); }; let f = false; for (const t of I.keys())if (0 === e.indexOf(i.resolve(t) + i.sep)) { n = t; u = I.get(n); f = true; break; } if (u || f) u.listeners.add(filteredListener); else { u = { listeners: new Set([ filteredListener ]), rawEmitter: r, watcher: createFSEventsInstance(n, (t, e)=>{ if (!u.listeners.size) return; const s = o.getInfo(t, e); u.listeners.forEach((r)=>{ r(t, e, s); }); u.rawEmitter(s.event, t, s); }) }; I.set(n, u); } return ()=>{ const t = u.listeners; t.delete(filteredListener); if (!t.size) { I.delete(n); if (u.watcher) return u.watcher.stop().then(()=>{ u.rawEmitter = u.watcher = void 0; Object.freeze(u); }); } }; } const couldConsolidate = (t)=>{ let e = 0; for (const s of I.keys())if (0 === s.indexOf(t)) { e++; if (e >= L) return true; } return false; }; const canUse = ()=>o && I.size < 128; const calcDepth = (t, e)=>{ let s = 0; while(!t.indexOf(e) && (t = i.dirname(t)) !== e)s++; return s; }; const sameTypes = (t, e)=>t.type === R && e.isDirectory() || t.type === w && e.isSymbolicLink() || t.type === y && e.isFile(); class FsEventsHandler { constructor(t){ this.fsw = t; } checkIgnored(t, e) { const s = this.fsw._ignoredPaths; if (this.fsw._isIgnored(t, e)) { s.add(t); if (e && e.isDirectory()) s.add(t + A); return true; } s.delete(t); s.delete(t + A); } addOrChange(t, e, s, r, i, n, o, l) { const c = i.has(n) ? u : a; this.handleEvent(c, t, e, s, r, i, n, o, l); } async checkExists(t, e, s, r, i, n, o, a) { try { const u = await T(t); if (this.fsw.closed) return; if (sameTypes(o, u)) this.addOrChange(t, e, s, r, i, n, o, a); else this.handleEvent(c, t, e, s, r, i, n, o, a); } catch (u) { if ("EACCES" === u.code) this.addOrChange(t, e, s, r, i, n, o, a); else this.handleEvent(c, t, e, s, r, i, n, o, a); } } handleEvent(t, e, s, r, i, n, o, u, f) { if (this.fsw.closed || this.checkIgnored(e)) return; if (t === c) { const t = u.type === R; if (t || n.has(o)) this.fsw._remove(i, o, t); } else { if (t === a) { if (u.type === R) this.fsw._getWatchedDir(e); if (u.type === w && f.followSymlinks) { const t = void 0 === f.depth ? void 0 : calcDepth(s, r) + 1; return this._addToFsEvents(e, false, true, t); } this.fsw._getWatchedDir(i).add(o); } const n = u.type === R ? t + b : t; this.fsw._emit(n, e); if (n === l) this._addToFsEvents(e, false, true); } } _watchWithFsEvents(t, e, s, r) { if (this.fsw.closed || this.fsw._isIgnored(t)) return; const n = this.fsw.options; const watchCallback = async (o, a, u)=>{ if (this.fsw.closed) return; if (void 0 !== n.depth && calcDepth(o, e) > n.depth) return; const l = s(i.join(t, i.relative(t, o))); if (r && !r(l)) return; const f = i.dirname(l); const h = i.basename(l); const p = this.fsw._getWatchedDir(u.type === R ? l : f); if (N.has(a) || u.event === m) if (typeof n.ignored === S) { let t; try { t = await T(l); } catch (t) {} if (this.fsw.closed) return; if (this.checkIgnored(l, t)) return; if (sameTypes(u, t)) this.addOrChange(l, o, e, f, p, h, u, n); else this.handleEvent(c, l, o, e, f, p, h, u, n); } else this.checkExists(l, o, e, f, p, h, u, n); else switch(u.event){ case d: case _: return this.addOrChange(l, o, e, f, p, h, u, n); case E: case g: return this.checkExists(l, o, e, f, p, h, u, n); } }; const o = setFSEventsListener(t, e, watchCallback, this.fsw._emitRaw); this.fsw._emitReady(); return o; } async _handleFsEventsSymlink(t, e, s, r) { if (this.fsw.closed || this.fsw._symlinkPaths.has(e)) return; this.fsw._symlinkPaths.set(e, true); this.fsw._incrReadyCount(); try { const e = await O(t); if (this.fsw.closed) return; if (this.fsw._isIgnored(e)) return this.fsw._emitReady(); this.fsw._incrReadyCount(); this._addToFsEvents(e || t, (r)=>{ let n = t; if (e && e !== v) n = r.replace(e, t); else if (r !== v) n = i.join(t, r); return s(n); }, false, r); } catch (t) { if (this.fsw._handleError(t)) return this.fsw._emitReady(); } } emitAdd(t, e, s, r, n) { const o = s(t); const u = e.isDirectory(); const c = this.fsw._getWatchedDir(i.dirname(o)); const f = i.basename(o); if (u) this.fsw._getWatchedDir(o); if (c.has(f)) return; c.add(f); if (!r.ignoreInitial || true === n) this.fsw._emit(u ? l : a, o, e); } initWatch(t, e, s, r) { if (this.fsw.closed) return; const n = this._watchWithFsEvents(s.watchPath, i.resolve(t || s.watchPath), r, s.globFilter); this.fsw._addPathCloser(e, n); } async _addToFsEvents(t, e, s, r) { if (this.fsw.closed) return; const n = this.fsw.options; const o = typeof e === S ? e : x; const a = this.fsw._getWatchHelpers(t); try { const e = await P[a.statMethod](a.watchPath); if (this.fsw.closed) return; if (this.fsw._isIgnored(a.watchPath, e)) throw null; if (e.isDirectory()) { if (!a.globFilter) this.emitAdd(o(t), e, o, n, s); if (r && r > n.depth) return; this.fsw._readdirp(a.watchPath, { fileFilter: (t)=>a.filterPath(t), directoryFilter: (t)=>a.filterDir(t), ...Depth(n.depth - (r || 0)) }).on(h, (t)=>{ if (this.fsw.closed) return; if (t.stats.isDirectory() && !a.filterPath(t)) return; const e = i.join(a.watchPath, t.path); const { fullPath: r } = t; if (a.followSymlinks && t.stats.isSymbolicLink()) { const t = void 0 === n.depth ? void 0 : calcDepth(e, i.resolve(a.watchPath)) + 1; this._handleFsEventsSymlink(e, r, o, t); } else this.emitAdd(e, t.stats, o, n, s); }).on(f, C).on(p, ()=>{ this.fsw._emitReady(); }); } else { this.emitAdd(a.watchPath, e, o, n, s); this.fsw._emitReady(); } } catch (t) { if (!t || this.fsw._handleError(t)) { this.fsw._emitReady(); this.fsw._emitReady(); } } if (n.persistent && true !== s) if (typeof e === S) this.initWatch(void 0, t, a, o); else { let e; try { e = await O(a.watchPath); } catch (t) {} this.initWatch(e, t, a, o); } } } t.exports = FsEventsHandler; t.exports.canUse = canUse; }, 254: (t, e, s)=>{ "use strict"; const r = s(147); const i = s(17); const { promisify: n } = s(837); const o = s(41); const { isWindows: a, isLinux: u, EMPTY_FN: l, EMPTY_STR: c, KEY_LISTENERS: f, KEY_ERR: h, KEY_RAW: p, HANDLER_KEYS: d, EV_CHANGE: _, EV_ADD: E, EV_ADD_DIR: g, EV_ERROR: m, STR_DATA: y, STR_END: R, BRACE_START: w, STAR: A } = s(240); const b = "watch"; const v = n(r.open); const S = n(r.stat); const C = n(r.lstat); const x = n(r.close); const T = n(r.realpath); const H = { lstat: C, stat: S }; const foreach = (t, e)=>{ if (t instanceof Set) t.forEach(e); else e(t); }; const addAndConvert = (t, e, s)=>{ let r = t[e]; if (!(r instanceof Set)) t[e] = r = new Set([ r ]); r.add(s); }; const clearItem = (t)=>(e)=>{ const s = t[e]; if (s instanceof Set) s.clear(); else delete t[e]; }; const delFromSet = (t, e, s)=>{ const r = t[e]; if (r instanceof Set) r.delete(s); else if (r === s) delete t[e]; }; const isEmptySet = (t)=>t instanceof Set ? 0 === t.size : !t; const O = new Map; function createFsWatchInstance(t, e, s, n, o) { const handleEvent = (e, r)=>{ s(t); o(e, r, { watchedPath: t }); if (r && t !== r) fsWatchBroadcast(i.resolve(t, r), f, i.join(t, r)); }; try { return r.watch(t, e, handleEvent); } catch (t) { n(t); } } const fsWatchBroadcast = (t, e, s, r, i)=>{ const n = O.get(t); if (!n) return; foreach(n[e], (t)=>{ t(s, r, i); }); }; const setFsWatchListener = (t, e, s, r)=>{ const { listener: i, errHandler: n, rawEmitter: o } = r; let u = O.get(e); let l; if (!s.persistent) { l = createFsWatchInstance(t, s, i, n, o); return l.close.bind(l); } if (u) { addAndConvert(u, f, i); addAndConvert(u, h, n); addAndConvert(u, p, o); } else { l = createFsWatchInstance(t, s, fsWatchBroadcast.bind(null, e, f), n, fsWatchBroadcast.bind(null, e, p)); if (!l) return; l.on(m, async (s)=>{ const r = fsWatchBroadcast.bind(null, e, h); u.watcherUnusable = true; if (a && "EPERM" === s.code) try { const e = await v(t, "r"); await x(e); r(s); } catch (t) {} else r(s); }); u = { listeners: i, errHandlers: n, rawEmitters: o, watcher: l }; O.set(e, u); } return ()=>{ delFromSet(u, f, i); delFromSet(u, h, n); delFromSet(u, p, o); if (isEmptySet(u.listeners)) { u.watcher.close(); O.delete(e); d.forEach(clearItem(u)); u.watcher = void 0; Object.freeze(u); } }; }; const P = new Map; const setFsWatchFileListener = (t, e, s, i)=>{ const { listener: n, rawEmitter: o } = i; let a = P.get(e); new Set; new Set; const c = a && a.options; if (c && (c.persistent < s.persistent || c.interval > s.interval)) { a.listeners; a.rawEmitters; r.unwatchFile(e); a = void 0; } if (a) { addAndConvert(a, f, n); addAndConvert(a, p, o); } else { a = { listeners: n, rawEmitters: o, options: s, watcher: r.watchFile(e, s, (s, r)=>{ foreach(a.rawEmitters, (t)=>{ t(_, e, { curr: s, prev: r }); }); const i = s.mtimeMs; if (s.size !== r.size || i > r.mtimeMs || 0 === i) foreach(a.listeners, (e)=>e(t, s)); }) }; P.set(e, a); } return ()=>{ delFromSet(a, f, n); delFromSet(a, p, o); if (isEmptySet(a.listeners)) { P.delete(e); r.unwatchFile(e); a.options = a.watcher = void 0; Object.freeze(a); } }; }; class NodeFsHandler { constructor(t){ this.fsw = t; this._boundHandleError = (e)=>t._handleError(e); } _watchWithNodeFs(t, e) { const s = this.fsw.options; const r = i.dirname(t); const n = i.basename(t); const a = this.fsw._getWatchedDir(r); a.add(n); const u = i.resolve(t); const c = { persistent: s.persistent }; if (!e) e = l; let f; if (s.usePolling) { c.interval = s.enableBinaryInterval && o(n) ? s.binaryInterval : s.interval; f = setFsWatchFileListener(t, u, c, { listener: e, rawEmitter: this.fsw._emitRaw }); } else f = setFsWatchListener(t, u, c, { listener: e, errHandler: this._boundHandleError, rawEmitter: this.fsw._emitRaw }); return f; } _handleFile(t, e, s) { if (this.fsw.closed) return; const r = i.dirname(t); const n = i.basename(t); const o = this.fsw._getWatchedDir(r); let a = e; if (o.has(n)) return; const listener = async (e, s)=>{ if (!this.fsw._throttle(b, t, 5)) return; if (s && 0 !== s.mtimeMs) { if (o.has(n)) { const e = s.atimeMs; const r = s.mtimeMs; if (!e || e <= r || r !== a.mtimeMs) this.fsw._emit(_, t, s); a = s; } } else try { const s = await S(t); if (this.fsw.closed) return; const r = s.atimeMs; const i = s.mtimeMs; if (!r || r <= i || i !== a.mtimeMs) this.fsw._emit(_, t, s); if (u && a.ino !== s.ino) { this.fsw._closeFile(e); a = s; this.fsw._addPathCloser(e, this._watchWithNodeFs(t, listener)); } else a = s; } catch (t) { this.fsw._remove(r, n); } }; const l = this._watchWithNodeFs(t, listener); if (!(s && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(t)) { if (!this.fsw._throttle(E, t, 0)) return; this.fsw._emit(E, t, e); } return l; } async _handleSymlink(t, e, s, r) { if (this.fsw.closed) return; const i = t.fullPath; const n = this.fsw._getWatchedDir(e); if (!this.fsw.options.followSymlinks) { this.fsw._incrReadyCount(); let e; try { e = await T(s); } catch (t) { this.fsw._emitReady(); return true; } if (this.fsw.closed) return; if (n.has(r)) { if (this.fsw._symlinkPaths.get(i) !== e) { this.fsw._symlinkPaths.set(i, e); this.fsw._emit(_, s, t.stats); } } else { n.add(r); this.fsw._symlinkPaths.set(i, e); this.fsw._emit(E, s, t.stats); } this.fsw._emitReady(); return true; } if (this.fsw._symlinkPaths.has(i)) return true; this.fsw._symlinkPaths.set(i, true); } _handleRead(t, e, s, r, n, o, a) { t = i.join(t, c); if (!s.hasGlob) { a = this.fsw._throttle("readdir", t, 1e3);