@shopify/cli 3.85.3 → 3.85.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/assets/hydrogen/bundle/analyzer.html +155 -148
  2. package/dist/assets/hydrogen/starter/CHANGELOG.md +125 -49
  3. package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +1 -1
  4. package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +1 -1
  5. package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +1 -1
  6. package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +62 -29
  7. package/dist/assets/hydrogen/starter/app/components/Header.tsx +1 -1
  8. package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
  9. package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +2 -2
  10. package/dist/assets/hydrogen/starter/app/components/SearchForm.tsx +1 -1
  11. package/dist/assets/hydrogen/starter/app/components/SearchFormPredictive.tsx +8 -3
  12. package/dist/assets/hydrogen/starter/app/components/SearchResults.tsx +3 -11
  13. package/dist/assets/hydrogen/starter/app/components/SearchResultsPredictive.tsx +2 -6
  14. package/dist/assets/hydrogen/starter/app/entry.client.tsx +10 -2
  15. package/dist/assets/hydrogen/starter/app/entry.server.tsx +5 -3
  16. package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerAddressMutations.ts +7 -4
  17. package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +1 -1
  18. package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerOrderQuery.ts +4 -1
  19. package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +10 -5
  20. package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +3 -2
  21. package/dist/assets/hydrogen/starter/app/lib/context.ts +34 -17
  22. package/dist/assets/hydrogen/starter/app/lib/fragments.ts +1 -0
  23. package/dist/assets/hydrogen/starter/app/lib/orderFilters.ts +90 -0
  24. package/dist/assets/hydrogen/starter/app/lib/redirect.ts +1 -1
  25. package/dist/assets/hydrogen/starter/app/lib/session.ts +1 -1
  26. package/dist/assets/hydrogen/starter/app/lib/variants.ts +1 -1
  27. package/dist/assets/hydrogen/starter/app/root.tsx +23 -18
  28. package/dist/assets/hydrogen/starter/app/routes/$.tsx +2 -2
  29. package/dist/assets/hydrogen/starter/app/routes/[robots.txt].tsx +2 -2
  30. package/dist/assets/hydrogen/starter/app/routes/[sitemap.xml].tsx +2 -3
  31. package/dist/assets/hydrogen/starter/app/routes/_index.tsx +12 -8
  32. package/dist/assets/hydrogen/starter/app/routes/account.$.tsx +4 -3
  33. package/dist/assets/hydrogen/starter/app/routes/account._index.tsx +1 -1
  34. package/dist/assets/hydrogen/starter/app/routes/account.addresses.tsx +15 -11
  35. package/dist/assets/hydrogen/starter/app/routes/account.orders.$id.tsx +47 -22
  36. package/dist/assets/hydrogen/starter/app/routes/account.orders._index.tsx +152 -23
  37. package/dist/assets/hydrogen/starter/app/routes/account.profile.tsx +11 -8
  38. package/dist/assets/hydrogen/starter/app/routes/account.tsx +16 -4
  39. package/dist/assets/hydrogen/starter/app/routes/account_.authorize.tsx +2 -2
  40. package/dist/assets/hydrogen/starter/app/routes/account_.login.tsx +5 -3
  41. package/dist/assets/hydrogen/starter/app/routes/account_.logout.tsx +3 -2
  42. package/dist/assets/hydrogen/starter/app/routes/api.$version.[graphql.json].tsx +2 -2
  43. package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +6 -10
  44. package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle._index.tsx +10 -7
  45. package/dist/assets/hydrogen/starter/app/routes/blogs._index.tsx +13 -7
  46. package/dist/assets/hydrogen/starter/app/routes/cart.$lines.tsx +3 -2
  47. package/dist/assets/hydrogen/starter/app/routes/cart.tsx +13 -9
  48. package/dist/assets/hydrogen/starter/app/routes/collections.$handle.tsx +8 -11
  49. package/dist/assets/hydrogen/starter/app/routes/collections._index.tsx +6 -6
  50. package/dist/assets/hydrogen/starter/app/routes/collections.all.tsx +10 -7
  51. package/dist/assets/hydrogen/starter/app/routes/discount.$code.tsx +3 -2
  52. package/dist/assets/hydrogen/starter/app/routes/pages.$handle.tsx +8 -6
  53. package/dist/assets/hydrogen/starter/app/routes/policies.$handle.tsx +7 -4
  54. package/dist/assets/hydrogen/starter/app/routes/policies._index.tsx +19 -13
  55. package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +9 -6
  56. package/dist/assets/hydrogen/starter/app/routes/search.tsx +14 -14
  57. package/dist/assets/hydrogen/starter/app/routes/sitemap.$type.$page[.xml].tsx +2 -3
  58. package/dist/assets/hydrogen/starter/app/routes.ts +1 -1
  59. package/dist/assets/hydrogen/starter/app/styles/app.css +53 -1
  60. package/dist/assets/hydrogen/starter/customer-accountapi.generated.d.ts +47 -13
  61. package/dist/assets/hydrogen/starter/env.d.ts +1 -39
  62. package/dist/assets/hydrogen/starter/eslint.config.js +35 -52
  63. package/dist/assets/hydrogen/starter/package.json +14 -15
  64. package/dist/assets/hydrogen/starter/react-router.config.ts +9 -3
  65. package/dist/assets/hydrogen/starter/server.ts +7 -7
  66. package/dist/assets/hydrogen/starter/storefrontapi.generated.d.ts +1 -1
  67. package/dist/assets/hydrogen/starter/tsconfig.json +17 -13
  68. package/dist/assets/hydrogen/starter/vite.config.ts +3 -0
  69. package/dist/assets/hydrogen/virtual-routes/components/RequestDetails.jsx +13 -20
  70. package/dist/assets/hydrogen/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx +37 -0
  71. package/dist/{chokidar-TTCYG5AA.js → chokidar-HTKREZL3.js} +482 -7
  72. package/dist/{chunk-RPU6TIF2.js → chunk-3ULYQTX3.js} +7 -7
  73. package/dist/{chunk-IHXRXBUN.js → chunk-AVSSZ6MY.js} +6 -6
  74. package/dist/{chunk-I4ATBX6D.js → chunk-CHLX44DR.js} +4 -4
  75. package/dist/{chunk-UW4ASA6Y.js → chunk-CQSO2B3C.js} +2 -2
  76. package/dist/{chunk-OQKAZQIC.js → chunk-DHW4GI57.js} +5 -5
  77. package/dist/{chunk-HTTZVPR6.js → chunk-FGSQR4VQ.js} +3 -3
  78. package/dist/{chunk-3XWYM7QS.js → chunk-FMD2ETAR.js} +3 -3
  79. package/dist/{chunk-FGEKMLLA.js → chunk-FRHZJBJZ.js} +5 -5
  80. package/dist/{chunk-Y4H4HMEZ.js → chunk-G2I4CD5D.js} +2 -2
  81. package/dist/{chunk-HS2O5IHL.js → chunk-GG2ELY5O.js} +2 -3
  82. package/dist/{chunk-F7TU455C.js → chunk-GQ63RYWN.js} +2 -2
  83. package/dist/{chunk-VVUZFYUK.js → chunk-IAX3IWUQ.js} +4 -4
  84. package/dist/{chunk-EWEA4LRT.js → chunk-J6T7KVRL.js} +2 -2
  85. package/dist/{chunk-GRVHLYQS.js → chunk-JF6DQIJR.js} +3 -3
  86. package/dist/{chunk-JAUHWNMJ.js → chunk-MDDWB46W.js} +5 -5
  87. package/dist/{chunk-QHKSKL4E.js → chunk-MR763CPY.js} +3 -3
  88. package/dist/{chunk-6A6GDV25.js → chunk-MUZ7NPCX.js} +4 -4
  89. package/dist/{chunk-NLFRHIZY.js → chunk-NMGJYSTC.js} +5 -5
  90. package/dist/{chunk-D5DJSKHK.js → chunk-NTCXWD2Q.js} +111 -112
  91. package/dist/{chunk-HBANZKAF.js → chunk-O2O5GRI6.js} +3 -3
  92. package/dist/{chunk-CAONVM2S.js → chunk-ODJ7LSLO.js} +3 -3
  93. package/dist/{chunk-5RNGA7FX.js → chunk-P46WMXBU.js} +5 -5
  94. package/dist/{chunk-LJXXOFEJ.js → chunk-PFBQBDNU.js} +2 -2
  95. package/dist/{chunk-OURS5IQY.js → chunk-PZUWEJO3.js} +3 -3
  96. package/dist/{chunk-VR6Z7LKU.js → chunk-R6BNSDGA.js} +3 -3
  97. package/dist/{chunk-AMWSD3HH.js → chunk-RAZVOMJW.js} +3 -3
  98. package/dist/{chunk-C45MKMJT.js → chunk-RZPYG7LO.js} +28 -25
  99. package/dist/{chunk-EDXQ22O4.js → chunk-SMBX232U.js} +6 -6
  100. package/dist/{chunk-QP2MOS2Y.js → chunk-TE4CUUT4.js} +2 -2
  101. package/dist/{chunk-V5ONTA7N.js → chunk-TXX6R3WL.js} +2 -2
  102. package/dist/{chunk-L54PNQGV.js → chunk-TYHJPUOR.js} +2 -2
  103. package/dist/{chunk-XJBIASMX.js → chunk-UF2X5VHR.js} +3 -3
  104. package/dist/{chunk-ZHKIKKU7.js → chunk-UQT7B7DM.js} +3 -3
  105. package/dist/{chunk-6RJ7HBOQ.js → chunk-VVDGGMKJ.js} +3 -3
  106. package/dist/cli/commands/auth/login.js +10 -10
  107. package/dist/cli/commands/auth/login.test.js +11 -11
  108. package/dist/cli/commands/auth/logout.js +10 -10
  109. package/dist/cli/commands/auth/logout.test.js +11 -11
  110. package/dist/cli/commands/cache/clear.js +10 -10
  111. package/dist/cli/commands/debug/command-flags.js +10 -10
  112. package/dist/cli/commands/docs/generate.js +10 -10
  113. package/dist/cli/commands/docs/generate.test.js +10 -10
  114. package/dist/cli/commands/help.js +10 -10
  115. package/dist/cli/commands/kitchen-sink/async.js +11 -11
  116. package/dist/cli/commands/kitchen-sink/async.test.js +11 -11
  117. package/dist/cli/commands/kitchen-sink/index.js +13 -13
  118. package/dist/cli/commands/kitchen-sink/index.test.js +13 -13
  119. package/dist/cli/commands/kitchen-sink/prompts.js +11 -11
  120. package/dist/cli/commands/kitchen-sink/prompts.test.js +11 -11
  121. package/dist/cli/commands/kitchen-sink/static.js +11 -11
  122. package/dist/cli/commands/kitchen-sink/static.test.js +11 -11
  123. package/dist/cli/commands/notifications/generate.js +11 -11
  124. package/dist/cli/commands/notifications/list.js +11 -11
  125. package/dist/cli/commands/search.js +11 -11
  126. package/dist/cli/commands/upgrade.js +11 -11
  127. package/dist/cli/commands/version.js +11 -11
  128. package/dist/cli/commands/version.test.js +11 -11
  129. package/dist/cli/services/commands/notifications.js +6 -6
  130. package/dist/cli/services/commands/search.js +2 -2
  131. package/dist/cli/services/commands/search.test.js +2 -2
  132. package/dist/cli/services/commands/version.js +3 -3
  133. package/dist/cli/services/commands/version.test.js +4 -4
  134. package/dist/cli/services/kitchen-sink/async.js +2 -2
  135. package/dist/cli/services/kitchen-sink/prompts.js +2 -2
  136. package/dist/cli/services/kitchen-sink/static.js +2 -2
  137. package/dist/cli/services/upgrade.js +3 -3
  138. package/dist/cli/services/upgrade.test.js +4 -4
  139. package/dist/{custom-oclif-loader-YDKLB47A.js → custom-oclif-loader-X7GLA66E.js} +2 -2
  140. package/dist/{error-handler-BYZU2C5C.js → error-handler-QOTWDLMF.js} +8 -8
  141. package/dist/hooks/postrun.js +6 -6
  142. package/dist/hooks/prerun.js +7 -7
  143. package/dist/index.js +1800 -3480
  144. package/dist/{local-XLJD5WYP.js → local-FS3UI7PE.js} +2 -2
  145. package/dist/{morph-5D7H6MU2.js → morph-D4BXY376.js} +9 -9
  146. package/dist/{node-package-manager-I7AWSWJ4.js → node-package-manager-TX3WZQGI.js} +3 -3
  147. package/dist/tsconfig.tsbuildinfo +1 -1
  148. package/dist/{ui-2AJAFJYY.js → ui-PUN5STUM.js} +2 -2
  149. package/dist/{workerd-4DJKRJUB.js → workerd-GJFM5MYN.js} +12 -12
  150. package/oclif.manifest.json +11 -56
  151. package/package.json +8 -8
  152. package/dist/chokidar-XUA2BN3J.js +0 -1120
  153. package/dist/chunk-F7J5CUMZ.js +0 -497
@@ -1,1120 +0,0 @@
1
- import {
2
- require_anymatch,
3
- require_is_binary_path,
4
- require_readdirp
5
- } from "./chunk-F7J5CUMZ.js";
6
- import {
7
- require_normalize_path
8
- } from "./chunk-X7YTIMNN.js";
9
- import {
10
- require_braces,
11
- require_glob_parent,
12
- require_is_glob
13
- } from "./chunk-7IK72W75.js";
14
- import {
15
- __commonJS,
16
- __require,
17
- init_cjs_shims
18
- } from "./chunk-PKR7KJ6P.js";
19
-
20
- // ../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/constants.js
21
- var require_constants = __commonJS({
22
- "../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/constants.js"(exports) {
23
- "use strict";
24
- init_cjs_shims();
25
- var { sep } = __require("path"), { platform } = process, os = __require("os");
26
- exports.EV_ALL = "all";
27
- exports.EV_READY = "ready";
28
- exports.EV_ADD = "add";
29
- exports.EV_CHANGE = "change";
30
- exports.EV_ADD_DIR = "addDir";
31
- exports.EV_UNLINK = "unlink";
32
- exports.EV_UNLINK_DIR = "unlinkDir";
33
- exports.EV_RAW = "raw";
34
- exports.EV_ERROR = "error";
35
- exports.STR_DATA = "data";
36
- exports.STR_END = "end";
37
- exports.STR_CLOSE = "close";
38
- exports.FSEVENT_CREATED = "created";
39
- exports.FSEVENT_MODIFIED = "modified";
40
- exports.FSEVENT_DELETED = "deleted";
41
- exports.FSEVENT_MOVED = "moved";
42
- exports.FSEVENT_CLONED = "cloned";
43
- exports.FSEVENT_UNKNOWN = "unknown";
44
- exports.FSEVENT_TYPE_FILE = "file";
45
- exports.FSEVENT_TYPE_DIRECTORY = "directory";
46
- exports.FSEVENT_TYPE_SYMLINK = "symlink";
47
- exports.KEY_LISTENERS = "listeners";
48
- exports.KEY_ERR = "errHandlers";
49
- exports.KEY_RAW = "rawEmitters";
50
- exports.HANDLER_KEYS = [exports.KEY_LISTENERS, exports.KEY_ERR, exports.KEY_RAW];
51
- exports.DOT_SLASH = `.${sep}`;
52
- exports.BACK_SLASH_RE = /\\/g;
53
- exports.DOUBLE_SLASH_RE = /\/\//;
54
- exports.SLASH_OR_BACK_SLASH_RE = /[/\\]/;
55
- exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
56
- exports.REPLACER_RE = /^\.[/\\]/;
57
- exports.SLASH = "/";
58
- exports.SLASH_SLASH = "//";
59
- exports.BRACE_START = "{";
60
- exports.BANG = "!";
61
- exports.ONE_DOT = ".";
62
- exports.TWO_DOTS = "..";
63
- exports.STAR = "*";
64
- exports.GLOBSTAR = "**";
65
- exports.ROOT_GLOBSTAR = "/**/*";
66
- exports.SLASH_GLOBSTAR = "/**";
67
- exports.DIR_SUFFIX = "Dir";
68
- exports.ANYMATCH_OPTS = { dot: !0 };
69
- exports.STRING_TYPE = "string";
70
- exports.FUNCTION_TYPE = "function";
71
- exports.EMPTY_STR = "";
72
- exports.EMPTY_FN = () => {
73
- };
74
- exports.IDENTITY_FN = (val) => val;
75
- exports.isWindows = platform === "win32";
76
- exports.isMacos = platform === "darwin";
77
- exports.isLinux = platform === "linux";
78
- exports.isIBMi = os.type() === "OS400";
79
- }
80
- });
81
-
82
- // ../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/nodefs-handler.js
83
- var require_nodefs_handler = __commonJS({
84
- "../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/nodefs-handler.js"(exports, module) {
85
- "use strict";
86
- init_cjs_shims();
87
- var fs = __require("fs"), sysPath = __require("path"), { promisify } = __require("util"), isBinaryPath = require_is_binary_path(), {
88
- isWindows,
89
- isLinux,
90
- EMPTY_FN,
91
- EMPTY_STR,
92
- KEY_LISTENERS,
93
- KEY_ERR,
94
- KEY_RAW,
95
- HANDLER_KEYS,
96
- EV_CHANGE,
97
- EV_ADD,
98
- EV_ADD_DIR,
99
- EV_ERROR,
100
- STR_DATA,
101
- STR_END,
102
- BRACE_START,
103
- STAR
104
- } = require_constants(), THROTTLE_MODE_WATCH = "watch", open = promisify(fs.open), stat = promisify(fs.stat), lstat = promisify(fs.lstat), close = promisify(fs.close), fsrealpath = promisify(fs.realpath), statMethods = { lstat, stat }, foreach = (val, fn) => {
105
- val instanceof Set ? val.forEach(fn) : fn(val);
106
- }, addAndConvert = (main, prop, item) => {
107
- let container = main[prop];
108
- container instanceof Set || (main[prop] = container = /* @__PURE__ */ new Set([container])), container.add(item);
109
- }, clearItem = (cont) => (key) => {
110
- let set = cont[key];
111
- set instanceof Set ? set.clear() : delete cont[key];
112
- }, delFromSet = (main, prop, item) => {
113
- let container = main[prop];
114
- container instanceof Set ? container.delete(item) : container === item && delete main[prop];
115
- }, isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val, FsWatchInstances = /* @__PURE__ */ new Map();
116
- function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
117
- let handleEvent = (rawEvent, evPath) => {
118
- listener(path), emitRaw(rawEvent, evPath, { watchedPath: path }), evPath && path !== evPath && fsWatchBroadcast(
119
- sysPath.resolve(path, evPath),
120
- KEY_LISTENERS,
121
- sysPath.join(path, evPath)
122
- );
123
- };
124
- try {
125
- return fs.watch(path, options, handleEvent);
126
- } catch (error) {
127
- errHandler(error);
128
- }
129
- }
130
- var fsWatchBroadcast = (fullPath, type, val1, val2, val3) => {
131
- let cont = FsWatchInstances.get(fullPath);
132
- cont && foreach(cont[type], (listener) => {
133
- listener(val1, val2, val3);
134
- });
135
- }, setFsWatchListener = (path, fullPath, options, handlers) => {
136
- let { listener, errHandler, rawEmitter } = handlers, cont = FsWatchInstances.get(fullPath), watcher;
137
- if (!options.persistent)
138
- return watcher = createFsWatchInstance(
139
- path,
140
- options,
141
- listener,
142
- errHandler,
143
- rawEmitter
144
- ), watcher.close.bind(watcher);
145
- if (cont)
146
- addAndConvert(cont, KEY_LISTENERS, listener), addAndConvert(cont, KEY_ERR, errHandler), addAndConvert(cont, KEY_RAW, rawEmitter);
147
- else {
148
- if (watcher = createFsWatchInstance(
149
- path,
150
- options,
151
- fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
152
- errHandler,
153
- // no need to use broadcast here
154
- fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
155
- ), !watcher) return;
156
- watcher.on(EV_ERROR, async (error) => {
157
- let broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
158
- if (cont.watcherUnusable = !0, isWindows && error.code === "EPERM")
159
- try {
160
- let fd = await open(path, "r");
161
- await close(fd), broadcastErr(error);
162
- } catch {
163
- }
164
- else
165
- broadcastErr(error);
166
- }), cont = {
167
- listeners: listener,
168
- errHandlers: errHandler,
169
- rawEmitters: rawEmitter,
170
- watcher
171
- }, FsWatchInstances.set(fullPath, cont);
172
- }
173
- return () => {
174
- delFromSet(cont, KEY_LISTENERS, listener), delFromSet(cont, KEY_ERR, errHandler), delFromSet(cont, KEY_RAW, rawEmitter), isEmptySet(cont.listeners) && (cont.watcher.close(), FsWatchInstances.delete(fullPath), HANDLER_KEYS.forEach(clearItem(cont)), cont.watcher = void 0, Object.freeze(cont));
175
- };
176
- }, FsWatchFileInstances = /* @__PURE__ */ new Map(), setFsWatchFileListener = (path, fullPath, options, handlers) => {
177
- let { listener, rawEmitter } = handlers, cont = FsWatchFileInstances.get(fullPath), listeners = /* @__PURE__ */ new Set(), rawEmitters = /* @__PURE__ */ new Set(), copts = cont && cont.options;
178
- return copts && (copts.persistent < options.persistent || copts.interval > options.interval) && (listeners = cont.listeners, rawEmitters = cont.rawEmitters, fs.unwatchFile(fullPath), cont = void 0), cont ? (addAndConvert(cont, KEY_LISTENERS, listener), addAndConvert(cont, KEY_RAW, rawEmitter)) : (cont = {
179
- listeners: listener,
180
- rawEmitters: rawEmitter,
181
- options,
182
- watcher: fs.watchFile(fullPath, options, (curr, prev) => {
183
- foreach(cont.rawEmitters, (rawEmitter2) => {
184
- rawEmitter2(EV_CHANGE, fullPath, { curr, prev });
185
- });
186
- let currmtime = curr.mtimeMs;
187
- (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) && foreach(cont.listeners, (listener2) => listener2(path, curr));
188
- })
189
- }, FsWatchFileInstances.set(fullPath, cont)), () => {
190
- delFromSet(cont, KEY_LISTENERS, listener), delFromSet(cont, KEY_RAW, rawEmitter), isEmptySet(cont.listeners) && (FsWatchFileInstances.delete(fullPath), fs.unwatchFile(fullPath), cont.options = cont.watcher = void 0, Object.freeze(cont));
191
- };
192
- }, NodeFsHandler = class {
193
- /**
194
- * @param {import("../index").FSWatcher} fsW
195
- */
196
- constructor(fsW) {
197
- this.fsw = fsW, this._boundHandleError = (error) => fsW._handleError(error);
198
- }
199
- /**
200
- * Watch file for changes with fs_watchFile or fs_watch.
201
- * @param {String} path to file or dir
202
- * @param {Function} listener on fs change
203
- * @returns {Function} closer for the watcher instance
204
- */
205
- _watchWithNodeFs(path, listener) {
206
- let opts = this.fsw.options, directory = sysPath.dirname(path), basename = sysPath.basename(path);
207
- this.fsw._getWatchedDir(directory).add(basename);
208
- let absolutePath = sysPath.resolve(path), options = { persistent: opts.persistent };
209
- listener || (listener = EMPTY_FN);
210
- let closer;
211
- return opts.usePolling ? (options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval, closer = setFsWatchFileListener(path, absolutePath, options, {
212
- listener,
213
- rawEmitter: this.fsw._emitRaw
214
- })) : closer = setFsWatchListener(path, absolutePath, options, {
215
- listener,
216
- errHandler: this._boundHandleError,
217
- rawEmitter: this.fsw._emitRaw
218
- }), closer;
219
- }
220
- /**
221
- * Watch a file and emit add event if warranted.
222
- * @param {Path} file Path
223
- * @param {fs.Stats} stats result of fs_stat
224
- * @param {Boolean} initialAdd was the file added at watch instantiation?
225
- * @returns {Function} closer for the watcher instance
226
- */
227
- _handleFile(file, stats, initialAdd) {
228
- if (this.fsw.closed)
229
- return;
230
- let dirname = sysPath.dirname(file), basename = sysPath.basename(file), parent = this.fsw._getWatchedDir(dirname), prevStats = stats;
231
- if (parent.has(basename)) return;
232
- let listener = async (path, newStats) => {
233
- if (this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) {
234
- if (!newStats || newStats.mtimeMs === 0)
235
- try {
236
- let newStats2 = await stat(file);
237
- if (this.fsw.closed) return;
238
- let at = newStats2.atimeMs, mt = newStats2.mtimeMs;
239
- (!at || at <= mt || mt !== prevStats.mtimeMs) && this.fsw._emit(EV_CHANGE, file, newStats2), isLinux && prevStats.ino !== newStats2.ino ? (this.fsw._closeFile(path), prevStats = newStats2, this.fsw._addPathCloser(path, this._watchWithNodeFs(file, listener))) : prevStats = newStats2;
240
- } catch {
241
- this.fsw._remove(dirname, basename);
242
- }
243
- else if (parent.has(basename)) {
244
- let at = newStats.atimeMs, mt = newStats.mtimeMs;
245
- (!at || at <= mt || mt !== prevStats.mtimeMs) && this.fsw._emit(EV_CHANGE, file, newStats), prevStats = newStats;
246
- }
247
- }
248
- }, closer = this._watchWithNodeFs(file, listener);
249
- if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
250
- if (!this.fsw._throttle(EV_ADD, file, 0)) return;
251
- this.fsw._emit(EV_ADD, file, stats);
252
- }
253
- return closer;
254
- }
255
- /**
256
- * Handle symlinks encountered while reading a dir.
257
- * @param {Object} entry returned by readdirp
258
- * @param {String} directory path of dir being read
259
- * @param {String} path of this item
260
- * @param {String} item basename of this item
261
- * @returns {Promise<Boolean>} true if no more processing is needed for this entry.
262
- */
263
- async _handleSymlink(entry, directory, path, item) {
264
- if (this.fsw.closed)
265
- return;
266
- let full = entry.fullPath, dir = this.fsw._getWatchedDir(directory);
267
- if (!this.fsw.options.followSymlinks) {
268
- this.fsw._incrReadyCount();
269
- let linkPath;
270
- try {
271
- linkPath = await fsrealpath(path);
272
- } catch {
273
- return this.fsw._emitReady(), !0;
274
- }
275
- return this.fsw.closed ? void 0 : (dir.has(item) ? this.fsw._symlinkPaths.get(full) !== linkPath && (this.fsw._symlinkPaths.set(full, linkPath), this.fsw._emit(EV_CHANGE, path, entry.stats)) : (dir.add(item), this.fsw._symlinkPaths.set(full, linkPath), this.fsw._emit(EV_ADD, path, entry.stats)), this.fsw._emitReady(), !0);
276
- }
277
- if (this.fsw._symlinkPaths.has(full))
278
- return !0;
279
- this.fsw._symlinkPaths.set(full, !0);
280
- }
281
- _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
282
- if (directory = sysPath.join(directory, EMPTY_STR), !wh.hasGlob && (throttler = this.fsw._throttle("readdir", directory, 1e3), !throttler))
283
- return;
284
- let previous = this.fsw._getWatchedDir(wh.path), current = /* @__PURE__ */ new Set(), stream = this.fsw._readdirp(directory, {
285
- fileFilter: (entry) => wh.filterPath(entry),
286
- directoryFilter: (entry) => wh.filterDir(entry),
287
- depth: 0
288
- }).on(STR_DATA, async (entry) => {
289
- if (this.fsw.closed) {
290
- stream = void 0;
291
- return;
292
- }
293
- let item = entry.path, path = sysPath.join(directory, item);
294
- if (current.add(item), !(entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item))) {
295
- if (this.fsw.closed) {
296
- stream = void 0;
297
- return;
298
- }
299
- (item === target || !target && !previous.has(item)) && (this.fsw._incrReadyCount(), path = sysPath.join(dir, sysPath.relative(dir, path)), this._addToNodeFs(path, initialAdd, wh, depth + 1));
300
- }
301
- }).on(EV_ERROR, this._boundHandleError);
302
- return new Promise(
303
- (resolve) => stream.once(STR_END, () => {
304
- if (this.fsw.closed) {
305
- stream = void 0;
306
- return;
307
- }
308
- let wasThrottled = throttler ? throttler.clear() : !1;
309
- resolve(), previous.getChildren().filter((item) => item !== directory && !current.has(item) && // in case of intersecting globs;
310
- // a path may have been filtered out of this readdir, but
311
- // shouldn't be removed because it matches a different glob
312
- (!wh.hasGlob || wh.filterPath({
313
- fullPath: sysPath.resolve(directory, item)
314
- }))).forEach((item) => {
315
- this.fsw._remove(directory, item);
316
- }), stream = void 0, wasThrottled && this._handleRead(directory, !1, wh, target, dir, depth, throttler);
317
- })
318
- );
319
- }
320
- /**
321
- * Read directory to add / remove files from `@watched` list and re-read it on change.
322
- * @param {String} dir fs path
323
- * @param {fs.Stats} stats
324
- * @param {Boolean} initialAdd
325
- * @param {Number} depth relative to user-supplied path
326
- * @param {String} target child path targeted for watch
327
- * @param {Object} wh Common watch helpers for this path
328
- * @param {String} realpath
329
- * @returns {Promise<Function>} closer for the watcher instance.
330
- */
331
- async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
332
- let parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir)), tracked = parentDir.has(sysPath.basename(dir));
333
- !(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked && (!wh.hasGlob || wh.globFilter(dir)) && this.fsw._emit(EV_ADD_DIR, dir, stats), parentDir.add(sysPath.basename(dir)), this.fsw._getWatchedDir(dir);
334
- let throttler, closer, oDepth = this.fsw.options.depth;
335
- if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
336
- if (!target && (await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler), this.fsw.closed))
337
- return;
338
- closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
339
- stats2 && stats2.mtimeMs === 0 || this._handleRead(dirPath, !1, wh, target, dir, depth, throttler);
340
- });
341
- }
342
- return closer;
343
- }
344
- /**
345
- * Handle added file, directory, or glob pattern.
346
- * Delegates call to _handleFile / _handleDir after checks.
347
- * @param {String} path to file or ir
348
- * @param {Boolean} initialAdd was the file added at watch instantiation?
349
- * @param {Object} priorWh depth relative to user-supplied path
350
- * @param {Number} depth Child path actually targeted for watch
351
- * @param {String=} target Child path actually targeted for watch
352
- * @returns {Promise}
353
- */
354
- async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
355
- let ready = this.fsw._emitReady;
356
- if (this.fsw._isIgnored(path) || this.fsw.closed)
357
- return ready(), !1;
358
- let wh = this.fsw._getWatchHelpers(path, depth);
359
- !wh.hasGlob && priorWh && (wh.hasGlob = priorWh.hasGlob, wh.globFilter = priorWh.globFilter, wh.filterPath = (entry) => priorWh.filterPath(entry), wh.filterDir = (entry) => priorWh.filterDir(entry));
360
- try {
361
- let stats = await statMethods[wh.statMethod](wh.watchPath);
362
- if (this.fsw.closed) return;
363
- if (this.fsw._isIgnored(wh.watchPath, stats))
364
- return ready(), !1;
365
- let follow = this.fsw.options.followSymlinks && !path.includes(STAR) && !path.includes(BRACE_START), closer;
366
- if (stats.isDirectory()) {
367
- let absPath = sysPath.resolve(path), targetPath = follow ? await fsrealpath(path) : path;
368
- if (this.fsw.closed || (closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath), this.fsw.closed)) return;
369
- absPath !== targetPath && targetPath !== void 0 && this.fsw._symlinkPaths.set(absPath, targetPath);
370
- } else if (stats.isSymbolicLink()) {
371
- let targetPath = follow ? await fsrealpath(path) : path;
372
- if (this.fsw.closed) return;
373
- let parent = sysPath.dirname(wh.watchPath);
374
- if (this.fsw._getWatchedDir(parent).add(wh.watchPath), this.fsw._emit(EV_ADD, wh.watchPath, stats), closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath), this.fsw.closed) return;
375
- targetPath !== void 0 && this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
376
- } else
377
- closer = this._handleFile(wh.watchPath, stats, initialAdd);
378
- return ready(), this.fsw._addPathCloser(path, closer), !1;
379
- } catch (error) {
380
- if (this.fsw._handleError(error))
381
- return ready(), path;
382
- }
383
- }
384
- };
385
- module.exports = NodeFsHandler;
386
- }
387
- });
388
-
389
- // ../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/fsevents-handler.js
390
- var require_fsevents_handler = __commonJS({
391
- "../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/lib/fsevents-handler.js"(exports, module) {
392
- "use strict";
393
- init_cjs_shims();
394
- var fs = __require("fs"), sysPath = __require("path"), { promisify } = __require("util"), fsevents;
395
- try {
396
- fsevents = __require("fsevents");
397
- } catch (error) {
398
- process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR && console.error(error);
399
- }
400
- if (fsevents) {
401
- let mtch = process.version.match(/v(\d+)\.(\d+)/);
402
- if (mtch && mtch[1] && mtch[2]) {
403
- let maj = Number.parseInt(mtch[1], 10), min = Number.parseInt(mtch[2], 10);
404
- maj === 8 && min < 16 && (fsevents = void 0);
405
- }
406
- }
407
- var {
408
- EV_ADD,
409
- EV_CHANGE,
410
- EV_ADD_DIR,
411
- EV_UNLINK,
412
- EV_ERROR,
413
- STR_DATA,
414
- STR_END,
415
- FSEVENT_CREATED,
416
- FSEVENT_MODIFIED,
417
- FSEVENT_DELETED,
418
- FSEVENT_MOVED,
419
- // FSEVENT_CLONED,
420
- FSEVENT_UNKNOWN,
421
- FSEVENT_TYPE_FILE,
422
- FSEVENT_TYPE_DIRECTORY,
423
- FSEVENT_TYPE_SYMLINK,
424
- ROOT_GLOBSTAR,
425
- DIR_SUFFIX,
426
- DOT_SLASH,
427
- FUNCTION_TYPE,
428
- EMPTY_FN,
429
- IDENTITY_FN
430
- } = require_constants(), Depth = (value) => isNaN(value) ? {} : { depth: value }, stat = promisify(fs.stat), lstat = promisify(fs.lstat), realpath = promisify(fs.realpath), statMethods = { stat, lstat }, FSEventsWatchers = /* @__PURE__ */ new Map(), consolidateThreshhold = 10, wrongEventFlags = /* @__PURE__ */ new Set([
431
- 69888,
432
- 70400,
433
- 71424,
434
- 72704,
435
- 73472,
436
- 131328,
437
- 131840,
438
- 262912
439
- ]), createFSEventsInstance = (path, callback) => ({ stop: fsevents.watch(path, callback) });
440
- function setFSEventsListener(path, realPath, listener, rawEmitter) {
441
- let watchPath = sysPath.extname(realPath) ? sysPath.dirname(realPath) : realPath, parentPath = sysPath.dirname(watchPath), cont = FSEventsWatchers.get(watchPath);
442
- couldConsolidate(parentPath) && (watchPath = parentPath);
443
- let resolvedPath = sysPath.resolve(path), hasSymlink = resolvedPath !== realPath, filteredListener = (fullPath, flags, info) => {
444
- hasSymlink && (fullPath = fullPath.replace(realPath, resolvedPath)), (fullPath === resolvedPath || !fullPath.indexOf(resolvedPath + sysPath.sep)) && listener(fullPath, flags, info);
445
- }, watchedParent = !1;
446
- for (let watchedPath of FSEventsWatchers.keys())
447
- if (realPath.indexOf(sysPath.resolve(watchedPath) + sysPath.sep) === 0) {
448
- watchPath = watchedPath, cont = FSEventsWatchers.get(watchPath), watchedParent = !0;
449
- break;
450
- }
451
- return cont || watchedParent ? cont.listeners.add(filteredListener) : (cont = {
452
- listeners: /* @__PURE__ */ new Set([filteredListener]),
453
- rawEmitter,
454
- watcher: createFSEventsInstance(watchPath, (fullPath, flags) => {
455
- if (!cont.listeners.size) return;
456
- let info = fsevents.getInfo(fullPath, flags);
457
- cont.listeners.forEach((list) => {
458
- list(fullPath, flags, info);
459
- }), cont.rawEmitter(info.event, fullPath, info);
460
- })
461
- }, FSEventsWatchers.set(watchPath, cont)), () => {
462
- let lst = cont.listeners;
463
- if (lst.delete(filteredListener), !lst.size && (FSEventsWatchers.delete(watchPath), cont.watcher))
464
- return cont.watcher.stop().then(() => {
465
- cont.rawEmitter = cont.watcher = void 0, Object.freeze(cont);
466
- });
467
- };
468
- }
469
- var couldConsolidate = (path) => {
470
- let count = 0;
471
- for (let watchPath of FSEventsWatchers.keys())
472
- if (watchPath.indexOf(path) === 0 && (count++, count >= consolidateThreshhold))
473
- return !0;
474
- return !1;
475
- }, canUse = () => fsevents && FSEventsWatchers.size < 128, calcDepth = (path, root) => {
476
- let i = 0;
477
- for (; !path.indexOf(root) && (path = sysPath.dirname(path)) !== root; ) i++;
478
- return i;
479
- }, sameTypes = (info, stats) => info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() || info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() || info.type === FSEVENT_TYPE_FILE && stats.isFile(), FsEventsHandler = class {
480
- /**
481
- * @param {import('../index').FSWatcher} fsw
482
- */
483
- constructor(fsw) {
484
- this.fsw = fsw;
485
- }
486
- checkIgnored(path, stats) {
487
- let ipaths = this.fsw._ignoredPaths;
488
- if (this.fsw._isIgnored(path, stats))
489
- return ipaths.add(path), stats && stats.isDirectory() && ipaths.add(path + ROOT_GLOBSTAR), !0;
490
- ipaths.delete(path), ipaths.delete(path + ROOT_GLOBSTAR);
491
- }
492
- addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
493
- let event = watchedDir.has(item) ? EV_CHANGE : EV_ADD;
494
- this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts);
495
- }
496
- async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
497
- try {
498
- let stats = await stat(path);
499
- if (this.fsw.closed) return;
500
- sameTypes(info, stats) ? this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) : this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
501
- } catch (error) {
502
- error.code === "EACCES" ? this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) : this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
503
- }
504
- }
505
- handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts) {
506
- if (!(this.fsw.closed || this.checkIgnored(path)))
507
- if (event === EV_UNLINK) {
508
- let isDirectory = info.type === FSEVENT_TYPE_DIRECTORY;
509
- (isDirectory || watchedDir.has(item)) && this.fsw._remove(parent, item, isDirectory);
510
- } else {
511
- if (event === EV_ADD) {
512
- if (info.type === FSEVENT_TYPE_DIRECTORY && this.fsw._getWatchedDir(path), info.type === FSEVENT_TYPE_SYMLINK && opts.followSymlinks) {
513
- let curDepth = opts.depth === void 0 ? void 0 : calcDepth(fullPath, realPath) + 1;
514
- return this._addToFsEvents(path, !1, !0, curDepth);
515
- }
516
- this.fsw._getWatchedDir(parent).add(item);
517
- }
518
- let eventName = info.type === FSEVENT_TYPE_DIRECTORY ? event + DIR_SUFFIX : event;
519
- this.fsw._emit(eventName, path), eventName === EV_ADD_DIR && this._addToFsEvents(path, !1, !0);
520
- }
521
- }
522
- /**
523
- * Handle symlinks encountered during directory scan
524
- * @param {String} watchPath - file/dir path to be watched with fsevents
525
- * @param {String} realPath - real path (in case of symlinks)
526
- * @param {Function} transform - path transformer
527
- * @param {Function} globFilter - path filter in case a glob pattern was provided
528
- * @returns {Function} closer for the watcher instance
529
- */
530
- _watchWithFsEvents(watchPath, realPath, transform, globFilter) {
531
- if (this.fsw.closed || this.fsw._isIgnored(watchPath)) return;
532
- let opts = this.fsw.options, closer = setFSEventsListener(
533
- watchPath,
534
- realPath,
535
- async (fullPath, flags, info) => {
536
- if (this.fsw.closed || opts.depth !== void 0 && calcDepth(fullPath, realPath) > opts.depth) return;
537
- let path = transform(sysPath.join(
538
- watchPath,
539
- sysPath.relative(watchPath, fullPath)
540
- ));
541
- if (globFilter && !globFilter(path)) return;
542
- let parent = sysPath.dirname(path), item = sysPath.basename(path), watchedDir = this.fsw._getWatchedDir(
543
- info.type === FSEVENT_TYPE_DIRECTORY ? path : parent
544
- );
545
- if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN)
546
- if (typeof opts.ignored === FUNCTION_TYPE) {
547
- let stats;
548
- try {
549
- stats = await stat(path);
550
- } catch {
551
- }
552
- if (this.fsw.closed || this.checkIgnored(path, stats)) return;
553
- sameTypes(info, stats) ? this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) : this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
554
- } else
555
- this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
556
- else
557
- switch (info.event) {
558
- case FSEVENT_CREATED:
559
- case FSEVENT_MODIFIED:
560
- return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
561
- case FSEVENT_DELETED:
562
- case FSEVENT_MOVED:
563
- return this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
564
- }
565
- },
566
- this.fsw._emitRaw
567
- );
568
- return this.fsw._emitReady(), closer;
569
- }
570
- /**
571
- * Handle symlinks encountered during directory scan
572
- * @param {String} linkPath path to symlink
573
- * @param {String} fullPath absolute path to the symlink
574
- * @param {Function} transform pre-existing path transformer
575
- * @param {Number} curDepth level of subdirectories traversed to where symlink is
576
- * @returns {Promise<void>}
577
- */
578
- async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
579
- if (!(this.fsw.closed || this.fsw._symlinkPaths.has(fullPath))) {
580
- this.fsw._symlinkPaths.set(fullPath, !0), this.fsw._incrReadyCount();
581
- try {
582
- let linkTarget = await realpath(linkPath);
583
- if (this.fsw.closed) return;
584
- if (this.fsw._isIgnored(linkTarget))
585
- return this.fsw._emitReady();
586
- this.fsw._incrReadyCount(), this._addToFsEvents(linkTarget || linkPath, (path) => {
587
- let aliasedPath = linkPath;
588
- return linkTarget && linkTarget !== DOT_SLASH ? aliasedPath = path.replace(linkTarget, linkPath) : path !== DOT_SLASH && (aliasedPath = sysPath.join(linkPath, path)), transform(aliasedPath);
589
- }, !1, curDepth);
590
- } catch (error) {
591
- if (this.fsw._handleError(error))
592
- return this.fsw._emitReady();
593
- }
594
- }
595
- }
596
- /**
597
- *
598
- * @param {Path} newPath
599
- * @param {fs.Stats} stats
600
- */
601
- emitAdd(newPath, stats, processPath, opts, forceAdd) {
602
- let pp = processPath(newPath), isDir = stats.isDirectory(), dirObj = this.fsw._getWatchedDir(sysPath.dirname(pp)), base = sysPath.basename(pp);
603
- isDir && this.fsw._getWatchedDir(pp), !dirObj.has(base) && (dirObj.add(base), (!opts.ignoreInitial || forceAdd === !0) && this.fsw._emit(isDir ? EV_ADD_DIR : EV_ADD, pp, stats));
604
- }
605
- initWatch(realPath, path, wh, processPath) {
606
- if (this.fsw.closed) return;
607
- let closer = this._watchWithFsEvents(
608
- wh.watchPath,
609
- sysPath.resolve(realPath || wh.watchPath),
610
- processPath,
611
- wh.globFilter
612
- );
613
- this.fsw._addPathCloser(path, closer);
614
- }
615
- /**
616
- * Handle added path with fsevents
617
- * @param {String} path file/dir path or glob pattern
618
- * @param {Function|Boolean=} transform converts working path to what the user expects
619
- * @param {Boolean=} forceAdd ensure add is emitted
620
- * @param {Number=} priorDepth Level of subdirectories already traversed.
621
- * @returns {Promise<void>}
622
- */
623
- async _addToFsEvents(path, transform, forceAdd, priorDepth) {
624
- if (this.fsw.closed)
625
- return;
626
- let opts = this.fsw.options, processPath = typeof transform === FUNCTION_TYPE ? transform : IDENTITY_FN, wh = this.fsw._getWatchHelpers(path);
627
- try {
628
- let stats = await statMethods[wh.statMethod](wh.watchPath);
629
- if (this.fsw.closed) return;
630
- if (this.fsw._isIgnored(wh.watchPath, stats))
631
- throw null;
632
- if (stats.isDirectory()) {
633
- if (wh.globFilter || this.emitAdd(processPath(path), stats, processPath, opts, forceAdd), priorDepth && priorDepth > opts.depth) return;
634
- this.fsw._readdirp(wh.watchPath, {
635
- fileFilter: (entry) => wh.filterPath(entry),
636
- directoryFilter: (entry) => wh.filterDir(entry),
637
- ...Depth(opts.depth - (priorDepth || 0))
638
- }).on(STR_DATA, (entry) => {
639
- if (this.fsw.closed || entry.stats.isDirectory() && !wh.filterPath(entry)) return;
640
- let joinedPath = sysPath.join(wh.watchPath, entry.path), { fullPath } = entry;
641
- if (wh.followSymlinks && entry.stats.isSymbolicLink()) {
642
- let curDepth = opts.depth === void 0 ? void 0 : calcDepth(joinedPath, sysPath.resolve(wh.watchPath)) + 1;
643
- this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth);
644
- } else
645
- this.emitAdd(joinedPath, entry.stats, processPath, opts, forceAdd);
646
- }).on(EV_ERROR, EMPTY_FN).on(STR_END, () => {
647
- this.fsw._emitReady();
648
- });
649
- } else
650
- this.emitAdd(wh.watchPath, stats, processPath, opts, forceAdd), this.fsw._emitReady();
651
- } catch (error) {
652
- (!error || this.fsw._handleError(error)) && (this.fsw._emitReady(), this.fsw._emitReady());
653
- }
654
- if (opts.persistent && forceAdd !== !0)
655
- if (typeof transform === FUNCTION_TYPE)
656
- this.initWatch(void 0, path, wh, processPath);
657
- else {
658
- let realPath;
659
- try {
660
- realPath = await realpath(wh.watchPath);
661
- } catch {
662
- }
663
- this.initWatch(realPath, path, wh, processPath);
664
- }
665
- }
666
- };
667
- module.exports = FsEventsHandler;
668
- module.exports.canUse = canUse;
669
- }
670
- });
671
-
672
- // ../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/index.js
673
- var require_chokidar = __commonJS({
674
- "../../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/index.js"(exports) {
675
- init_cjs_shims();
676
- var { EventEmitter } = __require("events"), fs = __require("fs"), sysPath = __require("path"), { promisify } = __require("util"), readdirp = require_readdirp(), anymatch = require_anymatch().default, globParent = require_glob_parent(), isGlob = require_is_glob(), braces = require_braces(), normalizePath = require_normalize_path(), NodeFsHandler = require_nodefs_handler(), FsEventsHandler = require_fsevents_handler(), {
677
- EV_ALL,
678
- EV_READY,
679
- EV_ADD,
680
- EV_CHANGE,
681
- EV_UNLINK,
682
- EV_ADD_DIR,
683
- EV_UNLINK_DIR,
684
- EV_RAW,
685
- EV_ERROR,
686
- STR_CLOSE,
687
- STR_END,
688
- BACK_SLASH_RE,
689
- DOUBLE_SLASH_RE,
690
- SLASH_OR_BACK_SLASH_RE,
691
- DOT_RE,
692
- REPLACER_RE,
693
- SLASH,
694
- SLASH_SLASH,
695
- BRACE_START,
696
- BANG,
697
- ONE_DOT,
698
- TWO_DOTS,
699
- GLOBSTAR,
700
- SLASH_GLOBSTAR,
701
- ANYMATCH_OPTS,
702
- STRING_TYPE,
703
- FUNCTION_TYPE,
704
- EMPTY_STR,
705
- EMPTY_FN,
706
- isWindows,
707
- isMacos,
708
- isIBMi
709
- } = require_constants(), stat = promisify(fs.stat), readdir = promisify(fs.readdir), arrify = (value = []) => Array.isArray(value) ? value : [value], flatten = (list, result = []) => (list.forEach((item) => {
710
- Array.isArray(item) ? flatten(item, result) : result.push(item);
711
- }), result), unifyPaths = (paths_) => {
712
- let paths = flatten(arrify(paths_));
713
- if (!paths.every((p) => typeof p === STRING_TYPE))
714
- throw new TypeError(`Non-string provided as watch path: ${paths}`);
715
- return paths.map(normalizePathToUnix);
716
- }, toUnix = (string) => {
717
- let str = string.replace(BACK_SLASH_RE, SLASH), prepend = !1;
718
- for (str.startsWith(SLASH_SLASH) && (prepend = !0); str.match(DOUBLE_SLASH_RE); )
719
- str = str.replace(DOUBLE_SLASH_RE, SLASH);
720
- return prepend && (str = SLASH + str), str;
721
- }, normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path))), normalizeIgnored = (cwd = EMPTY_STR) => (path) => typeof path !== STRING_TYPE ? path : normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path)), getAbsolutePath = (path, cwd) => sysPath.isAbsolute(path) ? path : path.startsWith(BANG) ? BANG + sysPath.join(cwd, path.slice(1)) : sysPath.join(cwd, path), undef = (opts, key) => opts[key] === void 0, DirEntry = class {
722
- /**
723
- * @param {Path} dir
724
- * @param {Function} removeWatcher
725
- */
726
- constructor(dir, removeWatcher) {
727
- this.path = dir, this._removeWatcher = removeWatcher, this.items = /* @__PURE__ */ new Set();
728
- }
729
- add(item) {
730
- let { items } = this;
731
- items && item !== ONE_DOT && item !== TWO_DOTS && items.add(item);
732
- }
733
- async remove(item) {
734
- let { items } = this;
735
- if (!items || (items.delete(item), items.size > 0)) return;
736
- let dir = this.path;
737
- try {
738
- await readdir(dir);
739
- } catch {
740
- this._removeWatcher && this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
741
- }
742
- }
743
- has(item) {
744
- let { items } = this;
745
- if (items)
746
- return items.has(item);
747
- }
748
- /**
749
- * @returns {Array<String>}
750
- */
751
- getChildren() {
752
- let { items } = this;
753
- if (items)
754
- return [...items.values()];
755
- }
756
- dispose() {
757
- this.items.clear(), delete this.path, delete this._removeWatcher, delete this.items, Object.freeze(this);
758
- }
759
- }, STAT_METHOD_F = "stat", STAT_METHOD_L = "lstat", WatchHelper = class {
760
- constructor(path, watchPath, follow, fsw) {
761
- this.fsw = fsw, this.path = path = path.replace(REPLACER_RE, EMPTY_STR), this.watchPath = watchPath, this.fullWatchPath = sysPath.resolve(watchPath), this.hasGlob = watchPath !== path, path === EMPTY_STR && (this.hasGlob = !1), this.globSymlink = this.hasGlob && follow ? void 0 : !1, this.globFilter = this.hasGlob ? anymatch(path, void 0, ANYMATCH_OPTS) : !1, this.dirParts = this.getDirParts(path), this.dirParts.forEach((parts) => {
762
- parts.length > 1 && parts.pop();
763
- }), this.followSymlinks = follow, this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
764
- }
765
- checkGlobSymlink(entry) {
766
- return this.globSymlink === void 0 && (this.globSymlink = entry.fullParentDir === this.fullWatchPath ? !1 : { realPath: entry.fullParentDir, linkPath: this.fullWatchPath }), this.globSymlink ? entry.fullPath.replace(this.globSymlink.realPath, this.globSymlink.linkPath) : entry.fullPath;
767
- }
768
- entryPath(entry) {
769
- return sysPath.join(
770
- this.watchPath,
771
- sysPath.relative(this.watchPath, this.checkGlobSymlink(entry))
772
- );
773
- }
774
- filterPath(entry) {
775
- let { stats } = entry;
776
- if (stats && stats.isSymbolicLink()) return this.filterDir(entry);
777
- let resolvedPath = this.entryPath(entry);
778
- return (this.hasGlob && typeof this.globFilter === FUNCTION_TYPE ? this.globFilter(resolvedPath) : !0) && this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
779
- }
780
- getDirParts(path) {
781
- if (!this.hasGlob) return [];
782
- let parts = [];
783
- return (path.includes(BRACE_START) ? braces.expand(path) : [path]).forEach((path2) => {
784
- parts.push(sysPath.relative(this.watchPath, path2).split(SLASH_OR_BACK_SLASH_RE));
785
- }), parts;
786
- }
787
- filterDir(entry) {
788
- if (this.hasGlob) {
789
- let entryParts = this.getDirParts(this.checkGlobSymlink(entry)), globstar = !1;
790
- this.unmatchedGlob = !this.dirParts.some((parts) => parts.every((part, i) => (part === GLOBSTAR && (globstar = !0), globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS))));
791
- }
792
- return !this.unmatchedGlob && this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
793
- }
794
- }, FSWatcher = class extends EventEmitter {
795
- // Not indenting methods for history sake; for now.
796
- constructor(_opts) {
797
- super();
798
- let opts = {};
799
- _opts && Object.assign(opts, _opts), this._watched = /* @__PURE__ */ new Map(), this._closers = /* @__PURE__ */ new Map(), this._ignoredPaths = /* @__PURE__ */ new Set(), this._throttled = /* @__PURE__ */ new Map(), this._symlinkPaths = /* @__PURE__ */ new Map(), this._streams = /* @__PURE__ */ new Set(), this.closed = !1, undef(opts, "persistent") && (opts.persistent = !0), undef(opts, "ignoreInitial") && (opts.ignoreInitial = !1), undef(opts, "ignorePermissionErrors") && (opts.ignorePermissionErrors = !1), undef(opts, "interval") && (opts.interval = 100), undef(opts, "binaryInterval") && (opts.binaryInterval = 300), undef(opts, "disableGlobbing") && (opts.disableGlobbing = !1), opts.enableBinaryInterval = opts.binaryInterval !== opts.interval, undef(opts, "useFsEvents") && (opts.useFsEvents = !opts.usePolling), FsEventsHandler.canUse() || (opts.useFsEvents = !1), undef(opts, "usePolling") && !opts.useFsEvents && (opts.usePolling = isMacos), isIBMi && (opts.usePolling = !0);
800
- let envPoll = process.env.CHOKIDAR_USEPOLLING;
801
- if (envPoll !== void 0) {
802
- let envLower = envPoll.toLowerCase();
803
- envLower === "false" || envLower === "0" ? opts.usePolling = !1 : envLower === "true" || envLower === "1" ? opts.usePolling = !0 : opts.usePolling = !!envLower;
804
- }
805
- let envInterval = process.env.CHOKIDAR_INTERVAL;
806
- envInterval && (opts.interval = Number.parseInt(envInterval, 10)), undef(opts, "atomic") && (opts.atomic = !opts.usePolling && !opts.useFsEvents), opts.atomic && (this._pendingUnlinks = /* @__PURE__ */ new Map()), undef(opts, "followSymlinks") && (opts.followSymlinks = !0), undef(opts, "awaitWriteFinish") && (opts.awaitWriteFinish = !1), opts.awaitWriteFinish === !0 && (opts.awaitWriteFinish = {});
807
- let awf = opts.awaitWriteFinish;
808
- awf && (awf.stabilityThreshold || (awf.stabilityThreshold = 2e3), awf.pollInterval || (awf.pollInterval = 100), this._pendingWrites = /* @__PURE__ */ new Map()), opts.ignored && (opts.ignored = arrify(opts.ignored));
809
- let readyCalls = 0;
810
- this._emitReady = () => {
811
- readyCalls++, readyCalls >= this._readyCount && (this._emitReady = EMPTY_FN, this._readyEmitted = !0, process.nextTick(() => this.emit(EV_READY)));
812
- }, this._emitRaw = (...args) => this.emit(EV_RAW, ...args), this._readyEmitted = !1, this.options = opts, opts.useFsEvents ? this._fsEventsHandler = new FsEventsHandler(this) : this._nodeFsHandler = new NodeFsHandler(this), Object.freeze(opts);
813
- }
814
- // Public methods
815
- /**
816
- * Adds paths to be watched on an existing FSWatcher instance
817
- * @param {Path|Array<Path>} paths_
818
- * @param {String=} _origAdd private; for handling non-existent paths to be watched
819
- * @param {Boolean=} _internal private; indicates a non-user add
820
- * @returns {FSWatcher} for chaining
821
- */
822
- add(paths_, _origAdd, _internal) {
823
- let { cwd, disableGlobbing } = this.options;
824
- this.closed = !1;
825
- let paths = unifyPaths(paths_);
826
- return cwd && (paths = paths.map((path) => {
827
- let absPath = getAbsolutePath(path, cwd);
828
- return disableGlobbing || !isGlob(path) ? absPath : normalizePath(absPath);
829
- })), paths = paths.filter((path) => path.startsWith(BANG) ? (this._ignoredPaths.add(path.slice(1)), !1) : (this._ignoredPaths.delete(path), this._ignoredPaths.delete(path + SLASH_GLOBSTAR), this._userIgnored = void 0, !0)), this.options.useFsEvents && this._fsEventsHandler ? (this._readyCount || (this._readyCount = paths.length), this.options.persistent && (this._readyCount *= 2), paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path))) : (this._readyCount || (this._readyCount = 0), this._readyCount += paths.length, Promise.all(
830
- paths.map(async (path) => {
831
- let res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd);
832
- return res && this._emitReady(), res;
833
- })
834
- ).then((results) => {
835
- this.closed || results.filter((item) => item).forEach((item) => {
836
- this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));
837
- });
838
- })), this;
839
- }
840
- /**
841
- * Close watchers or start ignoring events from specified paths.
842
- * @param {Path|Array<Path>} paths_ - string or array of strings, file/directory paths and/or globs
843
- * @returns {FSWatcher} for chaining
844
- */
845
- unwatch(paths_) {
846
- if (this.closed) return this;
847
- let paths = unifyPaths(paths_), { cwd } = this.options;
848
- return paths.forEach((path) => {
849
- !sysPath.isAbsolute(path) && !this._closers.has(path) && (cwd && (path = sysPath.join(cwd, path)), path = sysPath.resolve(path)), this._closePath(path), this._ignoredPaths.add(path), this._watched.has(path) && this._ignoredPaths.add(path + SLASH_GLOBSTAR), this._userIgnored = void 0;
850
- }), this;
851
- }
852
- /**
853
- * Close watchers and remove all listeners from watched paths.
854
- * @returns {Promise<void>}.
855
- */
856
- close() {
857
- if (this.closed) return this._closePromise;
858
- this.closed = !0, this.removeAllListeners();
859
- let closers = [];
860
- return this._closers.forEach((closerList) => closerList.forEach((closer) => {
861
- let promise = closer();
862
- promise instanceof Promise && closers.push(promise);
863
- })), this._streams.forEach((stream) => stream.destroy()), this._userIgnored = void 0, this._readyCount = 0, this._readyEmitted = !1, this._watched.forEach((dirent) => dirent.dispose()), ["closers", "watched", "streams", "symlinkPaths", "throttled"].forEach((key) => {
864
- this[`_${key}`].clear();
865
- }), this._closePromise = closers.length ? Promise.all(closers).then(() => {
866
- }) : Promise.resolve(), this._closePromise;
867
- }
868
- /**
869
- * Expose list of watched paths
870
- * @returns {Object} for chaining
871
- */
872
- getWatched() {
873
- let watchList = {};
874
- return this._watched.forEach((entry, dir) => {
875
- let key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;
876
- watchList[key || ONE_DOT] = entry.getChildren().sort();
877
- }), watchList;
878
- }
879
- emitWithAll(event, args) {
880
- this.emit(...args), event !== EV_ERROR && this.emit(EV_ALL, ...args);
881
- }
882
- // Common helpers
883
- // --------------
884
- /**
885
- * Normalize and emit events.
886
- * Calling _emit DOES NOT MEAN emit() would be called!
887
- * @param {EventName} event Type of event
888
- * @param {Path} path File or directory path
889
- * @param {*=} val1 arguments to be passed with event
890
- * @param {*=} val2
891
- * @param {*=} val3
892
- * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
893
- */
894
- async _emit(event, path, val1, val2, val3) {
895
- if (this.closed) return;
896
- let opts = this.options;
897
- isWindows && (path = sysPath.normalize(path)), opts.cwd && (path = sysPath.relative(opts.cwd, path));
898
- let args = [event, path];
899
- val3 !== void 0 ? args.push(val1, val2, val3) : val2 !== void 0 ? args.push(val1, val2) : val1 !== void 0 && args.push(val1);
900
- let awf = opts.awaitWriteFinish, pw;
901
- if (awf && (pw = this._pendingWrites.get(path)))
902
- return pw.lastChange = /* @__PURE__ */ new Date(), this;
903
- if (opts.atomic) {
904
- if (event === EV_UNLINK)
905
- return this._pendingUnlinks.set(path, args), setTimeout(() => {
906
- this._pendingUnlinks.forEach((entry, path2) => {
907
- this.emit(...entry), this.emit(EV_ALL, ...entry), this._pendingUnlinks.delete(path2);
908
- });
909
- }, typeof opts.atomic == "number" ? opts.atomic : 100), this;
910
- event === EV_ADD && this._pendingUnlinks.has(path) && (event = args[0] = EV_CHANGE, this._pendingUnlinks.delete(path));
911
- }
912
- if (awf && (event === EV_ADD || event === EV_CHANGE) && this._readyEmitted) {
913
- let awfEmit = (err, stats) => {
914
- err ? (event = args[0] = EV_ERROR, args[1] = err, this.emitWithAll(event, args)) : stats && (args.length > 2 ? args[2] = stats : args.push(stats), this.emitWithAll(event, args));
915
- };
916
- return this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit), this;
917
- }
918
- if (event === EV_CHANGE && !this._throttle(EV_CHANGE, path, 50))
919
- return this;
920
- if (opts.alwaysStat && val1 === void 0 && (event === EV_ADD || event === EV_ADD_DIR || event === EV_CHANGE)) {
921
- let fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path, stats;
922
- try {
923
- stats = await stat(fullPath);
924
- } catch {
925
- }
926
- if (!stats || this.closed) return;
927
- args.push(stats);
928
- }
929
- return this.emitWithAll(event, args), this;
930
- }
931
- /**
932
- * Common handler for errors
933
- * @param {Error} error
934
- * @returns {Error|Boolean} The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
935
- */
936
- _handleError(error) {
937
- let code = error && error.code;
938
- return error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES") && this.emit(EV_ERROR, error), error || this.closed;
939
- }
940
- /**
941
- * Helper utility for throttling
942
- * @param {ThrottleType} actionType type being throttled
943
- * @param {Path} path being acted upon
944
- * @param {Number} timeout duration of time to suppress duplicate actions
945
- * @returns {Object|false} tracking object or false if action should be suppressed
946
- */
947
- _throttle(actionType, path, timeout) {
948
- this._throttled.has(actionType) || this._throttled.set(actionType, /* @__PURE__ */ new Map());
949
- let action = this._throttled.get(actionType), actionPath = action.get(path);
950
- if (actionPath)
951
- return actionPath.count++, !1;
952
- let timeoutObject, clear = () => {
953
- let item = action.get(path), count = item ? item.count : 0;
954
- return action.delete(path), clearTimeout(timeoutObject), item && clearTimeout(item.timeoutObject), count;
955
- };
956
- timeoutObject = setTimeout(clear, timeout);
957
- let thr = { timeoutObject, clear, count: 0 };
958
- return action.set(path, thr), thr;
959
- }
960
- _incrReadyCount() {
961
- return this._readyCount++;
962
- }
963
- /**
964
- * Awaits write operation to finish.
965
- * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
966
- * @param {Path} path being acted upon
967
- * @param {Number} threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
968
- * @param {EventName} event
969
- * @param {Function} awfEmit Callback to be called when ready for event to be emitted.
970
- */
971
- _awaitWriteFinish(path, threshold, event, awfEmit) {
972
- let timeoutHandler, fullPath = path;
973
- this.options.cwd && !sysPath.isAbsolute(path) && (fullPath = sysPath.join(this.options.cwd, path));
974
- let now = /* @__PURE__ */ new Date(), awaitWriteFinish = (prevStat) => {
975
- fs.stat(fullPath, (err, curStat) => {
976
- if (err || !this._pendingWrites.has(path)) {
977
- err && err.code !== "ENOENT" && awfEmit(err);
978
- return;
979
- }
980
- let now2 = Number(/* @__PURE__ */ new Date());
981
- prevStat && curStat.size !== prevStat.size && (this._pendingWrites.get(path).lastChange = now2);
982
- let pw = this._pendingWrites.get(path);
983
- now2 - pw.lastChange >= threshold ? (this._pendingWrites.delete(path), awfEmit(void 0, curStat)) : timeoutHandler = setTimeout(
984
- awaitWriteFinish,
985
- this.options.awaitWriteFinish.pollInterval,
986
- curStat
987
- );
988
- });
989
- };
990
- this._pendingWrites.has(path) || (this._pendingWrites.set(path, {
991
- lastChange: now,
992
- cancelWait: () => (this._pendingWrites.delete(path), clearTimeout(timeoutHandler), event)
993
- }), timeoutHandler = setTimeout(
994
- awaitWriteFinish,
995
- this.options.awaitWriteFinish.pollInterval
996
- ));
997
- }
998
- _getGlobIgnored() {
999
- return [...this._ignoredPaths.values()];
1000
- }
1001
- /**
1002
- * Determines whether user has asked to ignore this path.
1003
- * @param {Path} path filepath or dir
1004
- * @param {fs.Stats=} stats result of fs.stat
1005
- * @returns {Boolean}
1006
- */
1007
- _isIgnored(path, stats) {
1008
- if (this.options.atomic && DOT_RE.test(path)) return !0;
1009
- if (!this._userIgnored) {
1010
- let { cwd } = this.options, ign = this.options.ignored, ignored = ign && ign.map(normalizeIgnored(cwd)), paths = arrify(ignored).filter((path2) => typeof path2 === STRING_TYPE && !isGlob(path2)).map((path2) => path2 + SLASH_GLOBSTAR), list = this._getGlobIgnored().map(normalizeIgnored(cwd)).concat(ignored, paths);
1011
- this._userIgnored = anymatch(list, void 0, ANYMATCH_OPTS);
1012
- }
1013
- return this._userIgnored([path, stats]);
1014
- }
1015
- _isntIgnored(path, stat2) {
1016
- return !this._isIgnored(path, stat2);
1017
- }
1018
- /**
1019
- * Provides a set of common helpers and properties relating to symlink and glob handling.
1020
- * @param {Path} path file, directory, or glob pattern being watched
1021
- * @param {Number=} depth at any depth > 0, this isn't a glob
1022
- * @returns {WatchHelper} object containing helpers for this path
1023
- */
1024
- _getWatchHelpers(path, depth) {
1025
- let watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path), follow = this.options.followSymlinks;
1026
- return new WatchHelper(path, watchPath, follow, this);
1027
- }
1028
- // Directory helpers
1029
- // -----------------
1030
- /**
1031
- * Provides directory tracking objects
1032
- * @param {String} directory path of the directory
1033
- * @returns {DirEntry} the directory's tracking object
1034
- */
1035
- _getWatchedDir(directory) {
1036
- this._boundRemove || (this._boundRemove = this._remove.bind(this));
1037
- let dir = sysPath.resolve(directory);
1038
- return this._watched.has(dir) || this._watched.set(dir, new DirEntry(dir, this._boundRemove)), this._watched.get(dir);
1039
- }
1040
- // File helpers
1041
- // ------------
1042
- /**
1043
- * Check for read permissions.
1044
- * Based on this answer on SO: https://stackoverflow.com/a/11781404/1358405
1045
- * @param {fs.Stats} stats - object, result of fs_stat
1046
- * @returns {Boolean} indicates whether the file can be read
1047
- */
1048
- _hasReadPermissions(stats) {
1049
- if (this.options.ignorePermissionErrors) return !0;
1050
- let st = (stats && Number.parseInt(stats.mode, 10)) & 511;
1051
- return !!(4 & Number.parseInt(st.toString(8)[0], 10));
1052
- }
1053
- /**
1054
- * Handles emitting unlink events for
1055
- * files and directories, and via recursion, for
1056
- * files and directories within directories that are unlinked
1057
- * @param {String} directory within which the following item is located
1058
- * @param {String} item base path of item/directory
1059
- * @returns {void}
1060
- */
1061
- _remove(directory, item, isDirectory) {
1062
- let path = sysPath.join(directory, item), fullPath = sysPath.resolve(path);
1063
- if (isDirectory = isDirectory ?? (this._watched.has(path) || this._watched.has(fullPath)), !this._throttle("remove", path, 100)) return;
1064
- !isDirectory && !this.options.useFsEvents && this._watched.size === 1 && this.add(directory, item, !0), this._getWatchedDir(path).getChildren().forEach((nested) => this._remove(path, nested));
1065
- let parent = this._getWatchedDir(directory), wasTracked = parent.has(item);
1066
- parent.remove(item), this._symlinkPaths.has(fullPath) && this._symlinkPaths.delete(fullPath);
1067
- let relPath = path;
1068
- if (this.options.cwd && (relPath = sysPath.relative(this.options.cwd, path)), this.options.awaitWriteFinish && this._pendingWrites.has(relPath) && this._pendingWrites.get(relPath).cancelWait() === EV_ADD)
1069
- return;
1070
- this._watched.delete(path), this._watched.delete(fullPath);
1071
- let eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK;
1072
- wasTracked && !this._isIgnored(path) && this._emit(eventName, path), this.options.useFsEvents || this._closePath(path);
1073
- }
1074
- /**
1075
- * Closes all watchers for a path
1076
- * @param {Path} path
1077
- */
1078
- _closePath(path) {
1079
- this._closeFile(path);
1080
- let dir = sysPath.dirname(path);
1081
- this._getWatchedDir(dir).remove(sysPath.basename(path));
1082
- }
1083
- /**
1084
- * Closes only file-specific watchers
1085
- * @param {Path} path
1086
- */
1087
- _closeFile(path) {
1088
- let closers = this._closers.get(path);
1089
- closers && (closers.forEach((closer) => closer()), this._closers.delete(path));
1090
- }
1091
- /**
1092
- *
1093
- * @param {Path} path
1094
- * @param {Function} closer
1095
- */
1096
- _addPathCloser(path, closer) {
1097
- if (!closer) return;
1098
- let list = this._closers.get(path);
1099
- list || (list = [], this._closers.set(path, list)), list.push(closer);
1100
- }
1101
- _readdirp(root, opts) {
1102
- if (this.closed) return;
1103
- let options = { type: EV_ALL, alwaysStat: !0, lstat: !0, ...opts }, stream = readdirp(root, options);
1104
- return this._streams.add(stream), stream.once(STR_CLOSE, () => {
1105
- stream = void 0;
1106
- }), stream.once(STR_END, () => {
1107
- stream && (this._streams.delete(stream), stream = void 0);
1108
- }), stream;
1109
- }
1110
- };
1111
- exports.FSWatcher = FSWatcher;
1112
- var watch = (paths, options) => {
1113
- let watcher = new FSWatcher(options);
1114
- return watcher.add(paths), watcher;
1115
- };
1116
- exports.watch = watch;
1117
- }
1118
- });
1119
- export default require_chokidar();
1120
- //# sourceMappingURL=chokidar-XUA2BN3J.js.map