nitro 3.0.1-alpha.2 → 3.0.260311-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +6977 -2556
- package/dist/_build/rolldown.mjs +32 -31
- package/dist/_build/rollup.mjs +28 -35
- package/dist/_build/vite.build.mjs +10 -8
- package/dist/_chunks/nitro.mjs +80 -112
- package/dist/_chunks/nitro2.mjs +8 -7
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +42 -24
- package/dist/_common.mjs +14 -24
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
- package/dist/_libs/citty.mjs +10 -12
- package/dist/_libs/commondir+is-reference.mjs +60 -49
- package/dist/_libs/compatx.mjs +1 -2
- package/dist/_libs/esbuild.d.mts +1 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -2
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
- package/dist/_libs/estree-walker.mjs +1 -4
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
- package/dist/_libs/httpxy.d.mts +12 -9
- package/dist/_libs/httpxy.mjs +299 -43
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -2
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/plugin-alias.mjs +2 -4
- package/dist/_libs/plugin-inject.mjs +2 -6
- package/dist/_libs/plugin-json.mjs +2 -4
- package/dist/_libs/pluginutils.mjs +5 -11
- package/dist/_libs/readdirp+chokidar.mjs +187 -192
- package/dist/_libs/remapping.mjs +1 -3
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
- package/dist/_libs/rou3.d.mts +3 -2
- package/dist/_libs/rou3.mjs +225 -51
- package/dist/_libs/std-env.d.mts +10 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -40
- package/dist/_libs/ultrahtml.mjs +3 -14
- package/dist/_libs/unimport+unplugin.mjs +250 -351
- package/dist/_libs/unplugin+unimport.d.mts +7 -10
- package/dist/_presets.mjs +389 -432
- package/dist/builder.d.mts +5 -4
- package/dist/builder.mjs +12 -6
- package/dist/cli/_chunks/build.mjs +22 -23
- package/dist/cli/_chunks/common.mjs +1 -2
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +9 -9
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +4 -6
- package/dist/cli/_chunks/prepare.mjs +2 -4
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +7 -9
- package/dist/cli/_chunks/task.mjs +1 -3
- package/dist/cli/index.mjs +5 -4
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +34 -31
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/bun/runtime/bun.mjs +4 -3
- package/dist/presets/deno/runtime/deno-server.mjs +4 -3
- package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +3 -2
- package/dist/presets/node/runtime/node-server.mjs +3 -2
- package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +38 -40
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +9 -4
- package/dist/runtime/internal/route-rules.mjs +9 -1
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +2 -2
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.mjs +1 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +2 -0
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +68 -117
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +236 -233
- package/package.json +83 -68
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { n as __exportAll } from "../_common.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { stat, unwatchFile, watch, watchFile } from "node:fs";
|
|
3
3
|
import { lstat, open, readdir, realpath, stat as stat$1 } from "node:fs/promises";
|
|
4
4
|
import { type } from "node:os";
|
|
5
5
|
import * as sp from "node:path";
|
|
6
6
|
import { join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { EventEmitter } from "node:events";
|
|
8
8
|
import { Readable } from "node:stream";
|
|
9
|
-
|
|
10
9
|
//#region node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js
|
|
11
10
|
const EntryTypes = {
|
|
12
11
|
FILE_TYPE: "files",
|
|
@@ -91,16 +90,16 @@ var ReaddirpStream = class extends Readable {
|
|
|
91
90
|
...defaultOptions,
|
|
92
91
|
...options
|
|
93
92
|
};
|
|
94
|
-
const { root, type
|
|
93
|
+
const { root, type } = opts;
|
|
95
94
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
96
95
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
97
96
|
const statMethod = opts.lstat ? lstat : stat$1;
|
|
98
|
-
if (wantBigintFsStats) this._stat = (path
|
|
97
|
+
if (wantBigintFsStats) this._stat = (path) => statMethod(path, { bigint: true });
|
|
99
98
|
else this._stat = statMethod;
|
|
100
99
|
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
101
|
-
this._wantsDir = type
|
|
102
|
-
this._wantsFile = type
|
|
103
|
-
this._wantsEverything = type
|
|
100
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
101
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
102
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
104
103
|
this._root = resolve(root);
|
|
105
104
|
this._isDirent = !opts.alwaysStat;
|
|
106
105
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
@@ -120,8 +119,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
120
119
|
const par = this.parent;
|
|
121
120
|
const fil = par && par.files;
|
|
122
121
|
if (fil && fil.length > 0) {
|
|
123
|
-
const { path
|
|
124
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path
|
|
122
|
+
const { path, depth } = par;
|
|
123
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
|
125
124
|
const awaited = await Promise.all(slice);
|
|
126
125
|
for (const entry of awaited) {
|
|
127
126
|
if (!entry) continue;
|
|
@@ -156,28 +155,28 @@ var ReaddirpStream = class extends Readable {
|
|
|
156
155
|
this.reading = false;
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
|
-
async _exploreDir(path
|
|
158
|
+
async _exploreDir(path, depth) {
|
|
160
159
|
let files;
|
|
161
160
|
try {
|
|
162
|
-
files = await readdir(path
|
|
161
|
+
files = await readdir(path, this._rdOptions);
|
|
163
162
|
} catch (error) {
|
|
164
163
|
this._onError(error);
|
|
165
164
|
}
|
|
166
165
|
return {
|
|
167
166
|
files,
|
|
168
167
|
depth,
|
|
169
|
-
path
|
|
168
|
+
path
|
|
170
169
|
};
|
|
171
170
|
}
|
|
172
|
-
async _formatEntry(dirent, path
|
|
171
|
+
async _formatEntry(dirent, path) {
|
|
173
172
|
let entry;
|
|
174
|
-
const basename
|
|
173
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
175
174
|
try {
|
|
176
|
-
const fullPath = resolve(join(path
|
|
175
|
+
const fullPath = resolve(join(path, basename));
|
|
177
176
|
entry = {
|
|
178
177
|
path: relative(this._root, fullPath),
|
|
179
178
|
fullPath,
|
|
180
|
-
basename
|
|
179
|
+
basename
|
|
181
180
|
};
|
|
182
181
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
183
182
|
} catch (err) {
|
|
@@ -228,20 +227,18 @@ var ReaddirpStream = class extends Readable {
|
|
|
228
227
|
* @param options Options to specify root (start directory), filters and recursion depth
|
|
229
228
|
*/
|
|
230
229
|
function readdirp(root, options = {}) {
|
|
231
|
-
let type
|
|
232
|
-
if (type
|
|
233
|
-
if (type
|
|
230
|
+
let type = options.entryType || options.type;
|
|
231
|
+
if (type === "both") type = EntryTypes.FILE_DIR_TYPE;
|
|
232
|
+
if (type) options.type = type;
|
|
234
233
|
if (!root) throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
235
234
|
else if (typeof root !== "string") throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
236
|
-
else if (type
|
|
235
|
+
else if (type && !ALL_TYPES.includes(type)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
237
236
|
options.root = root;
|
|
238
237
|
return new ReaddirpStream(options);
|
|
239
238
|
}
|
|
240
|
-
|
|
241
239
|
//#endregion
|
|
242
240
|
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js
|
|
243
241
|
const STR_DATA = "data";
|
|
244
|
-
const STR_END = "end";
|
|
245
242
|
const STR_CLOSE = "close";
|
|
246
243
|
const EMPTY_FN = () => {};
|
|
247
244
|
const pl = process.platform;
|
|
@@ -569,14 +566,14 @@ const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
|
569
566
|
* @param emitRaw emits raw event data
|
|
570
567
|
* @returns {NativeFsWatcher}
|
|
571
568
|
*/
|
|
572
|
-
function createFsWatchInstance(path
|
|
569
|
+
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
573
570
|
const handleEvent = (rawEvent, evPath) => {
|
|
574
|
-
listener(path
|
|
575
|
-
emitRaw(rawEvent, evPath, { watchedPath: path
|
|
576
|
-
if (evPath && path
|
|
571
|
+
listener(path);
|
|
572
|
+
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
573
|
+
if (evPath && path !== evPath) fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
577
574
|
};
|
|
578
575
|
try {
|
|
579
|
-
return watch(path
|
|
576
|
+
return watch(path, { persistent: options.persistent }, handleEvent);
|
|
580
577
|
} catch (error) {
|
|
581
578
|
errHandler(error);
|
|
582
579
|
return;
|
|
@@ -601,12 +598,12 @@ const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
601
598
|
* @param options to be passed to fs_watch
|
|
602
599
|
* @param handlers container for event listener functions
|
|
603
600
|
*/
|
|
604
|
-
const setFsWatchListener = (path
|
|
601
|
+
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
|
605
602
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
606
603
|
let cont = FsWatchInstances.get(fullPath);
|
|
607
604
|
let watcher;
|
|
608
605
|
if (!options.persistent) {
|
|
609
|
-
watcher = createFsWatchInstance(path
|
|
606
|
+
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
|
610
607
|
if (!watcher) return;
|
|
611
608
|
return watcher.close.bind(watcher);
|
|
612
609
|
}
|
|
@@ -615,13 +612,13 @@ const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
|
615
612
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
616
613
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
617
614
|
} else {
|
|
618
|
-
watcher = createFsWatchInstance(path
|
|
615
|
+
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
619
616
|
if (!watcher) return;
|
|
620
617
|
watcher.on(EV.ERROR, async (error) => {
|
|
621
618
|
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
622
619
|
if (cont) cont.watcherUnusable = true;
|
|
623
620
|
if (isWindows && error.code === "EPERM") try {
|
|
624
|
-
await (await open(path
|
|
621
|
+
await (await open(path, "r")).close();
|
|
625
622
|
broadcastErr(error);
|
|
626
623
|
} catch (err) {}
|
|
627
624
|
else broadcastErr(error);
|
|
@@ -657,7 +654,7 @@ const FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
|
657
654
|
* @param handlers container for event listener functions
|
|
658
655
|
* @returns closer
|
|
659
656
|
*/
|
|
660
|
-
const setFsWatchFileListener = (path
|
|
657
|
+
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
661
658
|
const { listener, rawEmitter } = handlers;
|
|
662
659
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
663
660
|
const copts = cont && cont.options;
|
|
@@ -674,14 +671,14 @@ const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
|
674
671
|
rawEmitters: rawEmitter,
|
|
675
672
|
options,
|
|
676
673
|
watcher: watchFile(fullPath, options, (curr, prev) => {
|
|
677
|
-
foreach(cont.rawEmitters, (rawEmitter
|
|
678
|
-
rawEmitter
|
|
674
|
+
foreach(cont.rawEmitters, (rawEmitter) => {
|
|
675
|
+
rawEmitter(EV.CHANGE, fullPath, {
|
|
679
676
|
curr,
|
|
680
677
|
prev
|
|
681
678
|
});
|
|
682
679
|
});
|
|
683
680
|
const currmtime = curr.mtimeMs;
|
|
684
|
-
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener
|
|
681
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener) => listener(path, curr));
|
|
685
682
|
})
|
|
686
683
|
};
|
|
687
684
|
FsWatchFileInstances.set(fullPath, cont);
|
|
@@ -713,22 +710,22 @@ var NodeFsHandler = class {
|
|
|
713
710
|
* @param listener on fs change
|
|
714
711
|
* @returns closer for the watcher instance
|
|
715
712
|
*/
|
|
716
|
-
_watchWithNodeFs(path
|
|
713
|
+
_watchWithNodeFs(path, listener) {
|
|
717
714
|
const opts = this.fsw.options;
|
|
718
|
-
const directory = sp.dirname(path
|
|
719
|
-
const basename
|
|
720
|
-
this.fsw._getWatchedDir(directory).add(basename
|
|
721
|
-
const absolutePath = sp.resolve(path
|
|
715
|
+
const directory = sp.dirname(path);
|
|
716
|
+
const basename = sp.basename(path);
|
|
717
|
+
this.fsw._getWatchedDir(directory).add(basename);
|
|
718
|
+
const absolutePath = sp.resolve(path);
|
|
722
719
|
const options = { persistent: opts.persistent };
|
|
723
720
|
if (!listener) listener = EMPTY_FN;
|
|
724
721
|
let closer;
|
|
725
722
|
if (opts.usePolling) {
|
|
726
|
-
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename
|
|
727
|
-
closer = setFsWatchFileListener(path
|
|
723
|
+
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
|
724
|
+
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
728
725
|
listener,
|
|
729
726
|
rawEmitter: this.fsw._emitRaw
|
|
730
727
|
});
|
|
731
|
-
} else closer = setFsWatchListener(path
|
|
728
|
+
} else closer = setFsWatchListener(path, absolutePath, options, {
|
|
732
729
|
listener,
|
|
733
730
|
errHandler: this._boundHandleError,
|
|
734
731
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -741,29 +738,29 @@ var NodeFsHandler = class {
|
|
|
741
738
|
*/
|
|
742
739
|
_handleFile(file, stats, initialAdd) {
|
|
743
740
|
if (this.fsw.closed) return;
|
|
744
|
-
const dirname
|
|
745
|
-
const basename
|
|
746
|
-
const parent = this.fsw._getWatchedDir(dirname
|
|
741
|
+
const dirname = sp.dirname(file);
|
|
742
|
+
const basename = sp.basename(file);
|
|
743
|
+
const parent = this.fsw._getWatchedDir(dirname);
|
|
747
744
|
let prevStats = stats;
|
|
748
|
-
if (parent.has(basename
|
|
749
|
-
const listener = async (path
|
|
745
|
+
if (parent.has(basename)) return;
|
|
746
|
+
const listener = async (path, newStats) => {
|
|
750
747
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
|
|
751
748
|
if (!newStats || newStats.mtimeMs === 0) try {
|
|
752
|
-
const newStats
|
|
749
|
+
const newStats = await stat$1(file);
|
|
753
750
|
if (this.fsw.closed) return;
|
|
754
|
-
const at = newStats
|
|
755
|
-
const mt = newStats
|
|
756
|
-
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats
|
|
757
|
-
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats
|
|
758
|
-
this.fsw._closeFile(path
|
|
759
|
-
prevStats = newStats
|
|
760
|
-
const closer
|
|
761
|
-
if (closer
|
|
762
|
-
} else prevStats = newStats
|
|
751
|
+
const at = newStats.atimeMs;
|
|
752
|
+
const mt = newStats.mtimeMs;
|
|
753
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
754
|
+
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
|
|
755
|
+
this.fsw._closeFile(path);
|
|
756
|
+
prevStats = newStats;
|
|
757
|
+
const closer = this._watchWithNodeFs(file, listener);
|
|
758
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
759
|
+
} else prevStats = newStats;
|
|
763
760
|
} catch (error) {
|
|
764
|
-
this.fsw._remove(dirname
|
|
761
|
+
this.fsw._remove(dirname, basename);
|
|
765
762
|
}
|
|
766
|
-
else if (parent.has(basename
|
|
763
|
+
else if (parent.has(basename)) {
|
|
767
764
|
const at = newStats.atimeMs;
|
|
768
765
|
const mt = newStats.mtimeMs;
|
|
769
766
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
@@ -785,7 +782,7 @@ var NodeFsHandler = class {
|
|
|
785
782
|
* @param item basename of this item
|
|
786
783
|
* @returns true if no more processing is needed for this entry.
|
|
787
784
|
*/
|
|
788
|
-
async _handleSymlink(entry, directory, path
|
|
785
|
+
async _handleSymlink(entry, directory, path, item) {
|
|
789
786
|
if (this.fsw.closed) return;
|
|
790
787
|
const full = entry.fullPath;
|
|
791
788
|
const dir = this.fsw._getWatchedDir(directory);
|
|
@@ -793,7 +790,7 @@ var NodeFsHandler = class {
|
|
|
793
790
|
this.fsw._incrReadyCount();
|
|
794
791
|
let linkPath;
|
|
795
792
|
try {
|
|
796
|
-
linkPath = await realpath(path
|
|
793
|
+
linkPath = await realpath(path);
|
|
797
794
|
} catch (e) {
|
|
798
795
|
this.fsw._emitReady();
|
|
799
796
|
return true;
|
|
@@ -802,12 +799,12 @@ var NodeFsHandler = class {
|
|
|
802
799
|
if (dir.has(item)) {
|
|
803
800
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
804
801
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
805
|
-
this.fsw._emit(EV.CHANGE, path
|
|
802
|
+
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
|
806
803
|
}
|
|
807
804
|
} else {
|
|
808
805
|
dir.add(item);
|
|
809
806
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
810
|
-
this.fsw._emit(EV.ADD, path
|
|
807
|
+
this.fsw._emit(EV.ADD, path, entry.stats);
|
|
811
808
|
}
|
|
812
809
|
this.fsw._emitReady();
|
|
813
810
|
return true;
|
|
@@ -833,28 +830,28 @@ var NodeFsHandler = class {
|
|
|
833
830
|
return;
|
|
834
831
|
}
|
|
835
832
|
const item = entry.path;
|
|
836
|
-
let path
|
|
833
|
+
let path = sp.join(directory, item);
|
|
837
834
|
current.add(item);
|
|
838
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path
|
|
835
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) return;
|
|
839
836
|
if (this.fsw.closed) {
|
|
840
837
|
stream = void 0;
|
|
841
838
|
return;
|
|
842
839
|
}
|
|
843
840
|
if (item === target || !target && !previous.has(item)) {
|
|
844
841
|
this.fsw._incrReadyCount();
|
|
845
|
-
path
|
|
846
|
-
this._addToNodeFs(path
|
|
842
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
843
|
+
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
847
844
|
}
|
|
848
845
|
}).on(EV.ERROR, this._boundHandleError);
|
|
849
|
-
return new Promise((resolve
|
|
846
|
+
return new Promise((resolve, reject) => {
|
|
850
847
|
if (!stream) return reject();
|
|
851
|
-
stream.once(
|
|
848
|
+
stream.once("end", () => {
|
|
852
849
|
if (this.fsw.closed) {
|
|
853
850
|
stream = void 0;
|
|
854
851
|
return;
|
|
855
852
|
}
|
|
856
853
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
857
|
-
resolve
|
|
854
|
+
resolve(void 0);
|
|
858
855
|
previous.getChildren().filter((item) => {
|
|
859
856
|
return item !== directory && !current.has(item);
|
|
860
857
|
}).forEach((item) => {
|
|
@@ -876,7 +873,7 @@ var NodeFsHandler = class {
|
|
|
876
873
|
* @param realpath
|
|
877
874
|
* @returns closer for the watcher instance.
|
|
878
875
|
*/
|
|
879
|
-
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath
|
|
876
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
880
877
|
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
881
878
|
const tracked = parentDir.has(sp.basename(dir));
|
|
882
879
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
@@ -885,13 +882,13 @@ var NodeFsHandler = class {
|
|
|
885
882
|
let throttler;
|
|
886
883
|
let closer;
|
|
887
884
|
const oDepth = this.fsw.options.depth;
|
|
888
|
-
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath
|
|
885
|
+
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
|
889
886
|
if (!target) {
|
|
890
887
|
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
891
888
|
if (this.fsw.closed) return;
|
|
892
889
|
}
|
|
893
|
-
closer = this._watchWithNodeFs(dir, (dirPath, stats
|
|
894
|
-
if (stats
|
|
890
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
|
891
|
+
if (stats && stats.mtimeMs === 0) return;
|
|
895
892
|
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
896
893
|
});
|
|
897
894
|
}
|
|
@@ -906,13 +903,13 @@ var NodeFsHandler = class {
|
|
|
906
903
|
* @param depth Child path actually targeted for watch
|
|
907
904
|
* @param target Child path actually targeted for watch
|
|
908
905
|
*/
|
|
909
|
-
async _addToNodeFs(path
|
|
906
|
+
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
|
910
907
|
const ready = this.fsw._emitReady;
|
|
911
|
-
if (this.fsw._isIgnored(path
|
|
908
|
+
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
|
912
909
|
ready();
|
|
913
910
|
return false;
|
|
914
911
|
}
|
|
915
|
-
const wh = this.fsw._getWatchHelpers(path
|
|
912
|
+
const wh = this.fsw._getWatchHelpers(path);
|
|
916
913
|
if (priorWh) {
|
|
917
914
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
918
915
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -927,34 +924,33 @@ var NodeFsHandler = class {
|
|
|
927
924
|
const follow = this.fsw.options.followSymlinks;
|
|
928
925
|
let closer;
|
|
929
926
|
if (stats.isDirectory()) {
|
|
930
|
-
const absPath = sp.resolve(path
|
|
931
|
-
const targetPath = follow ? await realpath(path
|
|
927
|
+
const absPath = sp.resolve(path);
|
|
928
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
932
929
|
if (this.fsw.closed) return;
|
|
933
930
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
934
931
|
if (this.fsw.closed) return;
|
|
935
932
|
if (absPath !== targetPath && targetPath !== void 0) this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
936
933
|
} else if (stats.isSymbolicLink()) {
|
|
937
|
-
const targetPath = follow ? await realpath(path
|
|
934
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
938
935
|
if (this.fsw.closed) return;
|
|
939
936
|
const parent = sp.dirname(wh.watchPath);
|
|
940
937
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
941
938
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
942
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth, path
|
|
939
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
943
940
|
if (this.fsw.closed) return;
|
|
944
|
-
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path
|
|
941
|
+
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
945
942
|
} else closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
946
943
|
ready();
|
|
947
|
-
if (closer) this.fsw._addPathCloser(path
|
|
944
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
948
945
|
return false;
|
|
949
946
|
} catch (error) {
|
|
950
947
|
if (this.fsw._handleError(error)) {
|
|
951
948
|
ready();
|
|
952
|
-
return path
|
|
949
|
+
return path;
|
|
953
950
|
}
|
|
954
951
|
}
|
|
955
952
|
}
|
|
956
953
|
};
|
|
957
|
-
|
|
958
954
|
//#endregion
|
|
959
955
|
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js
|
|
960
956
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
@@ -984,37 +980,37 @@ function createPattern(matcher) {
|
|
|
984
980
|
if (typeof matcher === "object" && matcher !== null) return (string) => {
|
|
985
981
|
if (matcher.path === string) return true;
|
|
986
982
|
if (matcher.recursive) {
|
|
987
|
-
const relative
|
|
988
|
-
if (!relative
|
|
989
|
-
return !relative
|
|
983
|
+
const relative = sp.relative(matcher.path, string);
|
|
984
|
+
if (!relative) return false;
|
|
985
|
+
return !relative.startsWith("..") && !sp.isAbsolute(relative);
|
|
990
986
|
}
|
|
991
987
|
return false;
|
|
992
988
|
};
|
|
993
989
|
return () => false;
|
|
994
990
|
}
|
|
995
|
-
function normalizePath(path
|
|
996
|
-
if (typeof path
|
|
997
|
-
path
|
|
998
|
-
path
|
|
991
|
+
function normalizePath(path) {
|
|
992
|
+
if (typeof path !== "string") throw new Error("string expected");
|
|
993
|
+
path = sp.normalize(path);
|
|
994
|
+
path = path.replace(/\\/g, "/");
|
|
999
995
|
let prepend = false;
|
|
1000
|
-
if (path
|
|
1001
|
-
path
|
|
1002
|
-
if (prepend) path
|
|
1003
|
-
return path
|
|
996
|
+
if (path.startsWith("//")) prepend = true;
|
|
997
|
+
path = path.replace(DOUBLE_SLASH_RE, "/");
|
|
998
|
+
if (prepend) path = "/" + path;
|
|
999
|
+
return path;
|
|
1004
1000
|
}
|
|
1005
1001
|
function matchPatterns(patterns, testString, stats) {
|
|
1006
|
-
const path
|
|
1002
|
+
const path = normalizePath(testString);
|
|
1007
1003
|
for (let index = 0; index < patterns.length; index++) {
|
|
1008
1004
|
const pattern = patterns[index];
|
|
1009
|
-
if (pattern(path
|
|
1005
|
+
if (pattern(path, stats)) return true;
|
|
1010
1006
|
}
|
|
1011
1007
|
return false;
|
|
1012
1008
|
}
|
|
1013
1009
|
function anymatch(matchers, testString) {
|
|
1014
1010
|
if (matchers == null) throw new TypeError("anymatch: specify first argument");
|
|
1015
1011
|
const patterns = arrify(matchers).map((matcher) => createPattern(matcher));
|
|
1016
|
-
if (testString == null) return (testString
|
|
1017
|
-
return matchPatterns(patterns, testString
|
|
1012
|
+
if (testString == null) return (testString, stats) => {
|
|
1013
|
+
return matchPatterns(patterns, testString, stats);
|
|
1018
1014
|
};
|
|
1019
1015
|
return matchPatterns(patterns, testString);
|
|
1020
1016
|
}
|
|
@@ -1031,14 +1027,14 @@ const toUnix = (string) => {
|
|
|
1031
1027
|
if (prepend) str = SLASH + str;
|
|
1032
1028
|
return str;
|
|
1033
1029
|
};
|
|
1034
|
-
const normalizePathToUnix = (path
|
|
1035
|
-
const normalizeIgnored = (cwd = "") => (path
|
|
1036
|
-
if (typeof path
|
|
1037
|
-
else return path
|
|
1030
|
+
const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
|
|
1031
|
+
const normalizeIgnored = (cwd = "") => (path) => {
|
|
1032
|
+
if (typeof path === "string") return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
|
|
1033
|
+
else return path;
|
|
1038
1034
|
};
|
|
1039
|
-
const getAbsolutePath = (path
|
|
1040
|
-
if (sp.isAbsolute(path
|
|
1041
|
-
return sp.join(cwd, path
|
|
1035
|
+
const getAbsolutePath = (path, cwd) => {
|
|
1036
|
+
if (sp.isAbsolute(path)) return path;
|
|
1037
|
+
return sp.join(cwd, path);
|
|
1042
1038
|
};
|
|
1043
1039
|
const EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
1044
1040
|
/**
|
|
@@ -1098,10 +1094,10 @@ var WatchHelper = class {
|
|
|
1098
1094
|
dirParts;
|
|
1099
1095
|
followSymlinks;
|
|
1100
1096
|
statMethod;
|
|
1101
|
-
constructor(path
|
|
1097
|
+
constructor(path, follow, fsw) {
|
|
1102
1098
|
this.fsw = fsw;
|
|
1103
|
-
const watchPath = path
|
|
1104
|
-
this.path = path
|
|
1099
|
+
const watchPath = path;
|
|
1100
|
+
this.path = path = path.replace(REPLACER_RE, "");
|
|
1105
1101
|
this.watchPath = watchPath;
|
|
1106
1102
|
this.fullWatchPath = sp.resolve(watchPath);
|
|
1107
1103
|
this.dirParts = [];
|
|
@@ -1232,17 +1228,17 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1232
1228
|
this.closed = false;
|
|
1233
1229
|
this._closePromise = void 0;
|
|
1234
1230
|
let paths = unifyPaths(paths_);
|
|
1235
|
-
if (cwd) paths = paths.map((path
|
|
1236
|
-
return getAbsolutePath(path
|
|
1231
|
+
if (cwd) paths = paths.map((path) => {
|
|
1232
|
+
return getAbsolutePath(path, cwd);
|
|
1237
1233
|
});
|
|
1238
|
-
paths.forEach((path
|
|
1239
|
-
this._removeIgnoredPath(path
|
|
1234
|
+
paths.forEach((path) => {
|
|
1235
|
+
this._removeIgnoredPath(path);
|
|
1240
1236
|
});
|
|
1241
1237
|
this._userIgnored = void 0;
|
|
1242
1238
|
if (!this._readyCount) this._readyCount = 0;
|
|
1243
1239
|
this._readyCount += paths.length;
|
|
1244
|
-
Promise.all(paths.map(async (path
|
|
1245
|
-
const res = await this._nodeFsHandler._addToNodeFs(path
|
|
1240
|
+
Promise.all(paths.map(async (path) => {
|
|
1241
|
+
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
|
|
1246
1242
|
if (res) this._emitReady();
|
|
1247
1243
|
return res;
|
|
1248
1244
|
})).then((results) => {
|
|
@@ -1260,15 +1256,15 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1260
1256
|
if (this.closed) return this;
|
|
1261
1257
|
const paths = unifyPaths(paths_);
|
|
1262
1258
|
const { cwd } = this.options;
|
|
1263
|
-
paths.forEach((path
|
|
1264
|
-
if (!sp.isAbsolute(path
|
|
1265
|
-
if (cwd) path
|
|
1266
|
-
path
|
|
1259
|
+
paths.forEach((path) => {
|
|
1260
|
+
if (!sp.isAbsolute(path) && !this._closers.has(path)) {
|
|
1261
|
+
if (cwd) path = sp.join(cwd, path);
|
|
1262
|
+
path = sp.resolve(path);
|
|
1267
1263
|
}
|
|
1268
|
-
this._closePath(path
|
|
1269
|
-
this._addIgnoredPath(path
|
|
1270
|
-
if (this._watched.has(path
|
|
1271
|
-
path
|
|
1264
|
+
this._closePath(path);
|
|
1265
|
+
this._addIgnoredPath(path);
|
|
1266
|
+
if (this._watched.has(path)) this._addIgnoredPath({
|
|
1267
|
+
path,
|
|
1272
1268
|
recursive: true
|
|
1273
1269
|
});
|
|
1274
1270
|
this._userIgnored = void 0;
|
|
@@ -1324,62 +1320,62 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1324
1320
|
* @param stats arguments to be passed with event
|
|
1325
1321
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1326
1322
|
*/
|
|
1327
|
-
async _emit(event, path
|
|
1323
|
+
async _emit(event, path, stats) {
|
|
1328
1324
|
if (this.closed) return;
|
|
1329
1325
|
const opts = this.options;
|
|
1330
|
-
if (isWindows) path
|
|
1331
|
-
if (opts.cwd) path
|
|
1332
|
-
const args = [path
|
|
1326
|
+
if (isWindows) path = sp.normalize(path);
|
|
1327
|
+
if (opts.cwd) path = sp.relative(opts.cwd, path);
|
|
1328
|
+
const args = [path];
|
|
1333
1329
|
if (stats != null) args.push(stats);
|
|
1334
1330
|
const awf = opts.awaitWriteFinish;
|
|
1335
1331
|
let pw;
|
|
1336
|
-
if (awf && (pw = this._pendingWrites.get(path
|
|
1332
|
+
if (awf && (pw = this._pendingWrites.get(path))) {
|
|
1337
1333
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
1338
1334
|
return this;
|
|
1339
1335
|
}
|
|
1340
1336
|
if (opts.atomic) {
|
|
1341
1337
|
if (event === EVENTS.UNLINK) {
|
|
1342
|
-
this._pendingUnlinks.set(path
|
|
1338
|
+
this._pendingUnlinks.set(path, [event, ...args]);
|
|
1343
1339
|
setTimeout(() => {
|
|
1344
|
-
this._pendingUnlinks.forEach((entry, path
|
|
1340
|
+
this._pendingUnlinks.forEach((entry, path) => {
|
|
1345
1341
|
this.emit(...entry);
|
|
1346
1342
|
this.emit(EVENTS.ALL, ...entry);
|
|
1347
|
-
this._pendingUnlinks.delete(path
|
|
1343
|
+
this._pendingUnlinks.delete(path);
|
|
1348
1344
|
});
|
|
1349
1345
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
1350
1346
|
return this;
|
|
1351
1347
|
}
|
|
1352
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(path
|
|
1348
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
|
|
1353
1349
|
event = EVENTS.CHANGE;
|
|
1354
|
-
this._pendingUnlinks.delete(path
|
|
1350
|
+
this._pendingUnlinks.delete(path);
|
|
1355
1351
|
}
|
|
1356
1352
|
}
|
|
1357
1353
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
1358
|
-
const awfEmit = (err, stats
|
|
1354
|
+
const awfEmit = (err, stats) => {
|
|
1359
1355
|
if (err) {
|
|
1360
1356
|
event = EVENTS.ERROR;
|
|
1361
1357
|
args[0] = err;
|
|
1362
1358
|
this.emitWithAll(event, args);
|
|
1363
|
-
} else if (stats
|
|
1364
|
-
if (args.length > 1) args[1] = stats
|
|
1365
|
-
else args.push(stats
|
|
1359
|
+
} else if (stats) {
|
|
1360
|
+
if (args.length > 1) args[1] = stats;
|
|
1361
|
+
else args.push(stats);
|
|
1366
1362
|
this.emitWithAll(event, args);
|
|
1367
1363
|
}
|
|
1368
1364
|
};
|
|
1369
|
-
this._awaitWriteFinish(path
|
|
1365
|
+
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
|
1370
1366
|
return this;
|
|
1371
1367
|
}
|
|
1372
1368
|
if (event === EVENTS.CHANGE) {
|
|
1373
|
-
if (!this._throttle(EVENTS.CHANGE, path
|
|
1369
|
+
if (!this._throttle(EVENTS.CHANGE, path, 50)) return this;
|
|
1374
1370
|
}
|
|
1375
1371
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
1376
|
-
const fullPath = opts.cwd ? sp.join(opts.cwd, path
|
|
1377
|
-
let stats
|
|
1372
|
+
const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
|
|
1373
|
+
let stats;
|
|
1378
1374
|
try {
|
|
1379
|
-
stats
|
|
1375
|
+
stats = await stat$1(fullPath);
|
|
1380
1376
|
} catch (err) {}
|
|
1381
|
-
if (!stats
|
|
1382
|
-
args.push(stats
|
|
1377
|
+
if (!stats || this.closed) return;
|
|
1378
|
+
args.push(stats);
|
|
1383
1379
|
}
|
|
1384
1380
|
this.emitWithAll(event, args);
|
|
1385
1381
|
return this;
|
|
@@ -1400,20 +1396,20 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1400
1396
|
* @param timeout duration of time to suppress duplicate actions
|
|
1401
1397
|
* @returns tracking object or false if action should be suppressed
|
|
1402
1398
|
*/
|
|
1403
|
-
_throttle(actionType, path
|
|
1399
|
+
_throttle(actionType, path, timeout) {
|
|
1404
1400
|
if (!this._throttled.has(actionType)) this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
1405
1401
|
const action = this._throttled.get(actionType);
|
|
1406
1402
|
if (!action) throw new Error("invalid throttle");
|
|
1407
|
-
const actionPath = action.get(path
|
|
1403
|
+
const actionPath = action.get(path);
|
|
1408
1404
|
if (actionPath) {
|
|
1409
1405
|
actionPath.count++;
|
|
1410
1406
|
return false;
|
|
1411
1407
|
}
|
|
1412
1408
|
let timeoutObject;
|
|
1413
1409
|
const clear = () => {
|
|
1414
|
-
const item = action.get(path
|
|
1410
|
+
const item = action.get(path);
|
|
1415
1411
|
const count = item ? item.count : 0;
|
|
1416
|
-
action.delete(path
|
|
1412
|
+
action.delete(path);
|
|
1417
1413
|
clearTimeout(timeoutObject);
|
|
1418
1414
|
if (item) clearTimeout(item.timeoutObject);
|
|
1419
1415
|
return count;
|
|
@@ -1424,7 +1420,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1424
1420
|
clear,
|
|
1425
1421
|
count: 0
|
|
1426
1422
|
};
|
|
1427
|
-
action.set(path
|
|
1423
|
+
action.set(path, thr);
|
|
1428
1424
|
return thr;
|
|
1429
1425
|
}
|
|
1430
1426
|
_incrReadyCount() {
|
|
@@ -1438,34 +1434,34 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1438
1434
|
* @param event
|
|
1439
1435
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
1440
1436
|
*/
|
|
1441
|
-
_awaitWriteFinish(path
|
|
1437
|
+
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
|
1442
1438
|
const awf = this.options.awaitWriteFinish;
|
|
1443
1439
|
if (typeof awf !== "object") return;
|
|
1444
1440
|
const pollInterval = awf.pollInterval;
|
|
1445
1441
|
let timeoutHandler;
|
|
1446
|
-
let fullPath = path
|
|
1447
|
-
if (this.options.cwd && !sp.isAbsolute(path
|
|
1442
|
+
let fullPath = path;
|
|
1443
|
+
if (this.options.cwd && !sp.isAbsolute(path)) fullPath = sp.join(this.options.cwd, path);
|
|
1448
1444
|
const now = /* @__PURE__ */ new Date();
|
|
1449
1445
|
const writes = this._pendingWrites;
|
|
1450
1446
|
function awaitWriteFinishFn(prevStat) {
|
|
1451
1447
|
stat(fullPath, (err, curStat) => {
|
|
1452
|
-
if (err || !writes.has(path
|
|
1448
|
+
if (err || !writes.has(path)) {
|
|
1453
1449
|
if (err && err.code !== "ENOENT") awfEmit(err);
|
|
1454
1450
|
return;
|
|
1455
1451
|
}
|
|
1456
|
-
const now
|
|
1457
|
-
if (prevStat && curStat.size !== prevStat.size) writes.get(path
|
|
1458
|
-
if (now
|
|
1459
|
-
writes.delete(path
|
|
1452
|
+
const now = Number(/* @__PURE__ */ new Date());
|
|
1453
|
+
if (prevStat && curStat.size !== prevStat.size) writes.get(path).lastChange = now;
|
|
1454
|
+
if (now - writes.get(path).lastChange >= threshold) {
|
|
1455
|
+
writes.delete(path);
|
|
1460
1456
|
awfEmit(void 0, curStat);
|
|
1461
1457
|
} else timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
1462
1458
|
});
|
|
1463
1459
|
}
|
|
1464
|
-
if (!writes.has(path
|
|
1465
|
-
writes.set(path
|
|
1460
|
+
if (!writes.has(path)) {
|
|
1461
|
+
writes.set(path, {
|
|
1466
1462
|
lastChange: now,
|
|
1467
1463
|
cancelWait: () => {
|
|
1468
|
-
writes.delete(path
|
|
1464
|
+
writes.delete(path);
|
|
1469
1465
|
clearTimeout(timeoutHandler);
|
|
1470
1466
|
return event;
|
|
1471
1467
|
}
|
|
@@ -1476,24 +1472,24 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1476
1472
|
/**
|
|
1477
1473
|
* Determines whether user has asked to ignore this path.
|
|
1478
1474
|
*/
|
|
1479
|
-
_isIgnored(path
|
|
1480
|
-
if (this.options.atomic && DOT_RE.test(path
|
|
1475
|
+
_isIgnored(path, stats) {
|
|
1476
|
+
if (this.options.atomic && DOT_RE.test(path)) return true;
|
|
1481
1477
|
if (!this._userIgnored) {
|
|
1482
1478
|
const { cwd } = this.options;
|
|
1483
1479
|
const ignored = (this.options.ignored || []).map(normalizeIgnored(cwd));
|
|
1484
1480
|
this._userIgnored = anymatch([...[...this._ignoredPaths].map(normalizeIgnored(cwd)), ...ignored], void 0);
|
|
1485
1481
|
}
|
|
1486
|
-
return this._userIgnored(path
|
|
1482
|
+
return this._userIgnored(path, stats);
|
|
1487
1483
|
}
|
|
1488
|
-
_isntIgnored(path
|
|
1489
|
-
return !this._isIgnored(path
|
|
1484
|
+
_isntIgnored(path, stat) {
|
|
1485
|
+
return !this._isIgnored(path, stat);
|
|
1490
1486
|
}
|
|
1491
1487
|
/**
|
|
1492
1488
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
1493
1489
|
* @param path file or directory pattern being watched
|
|
1494
1490
|
*/
|
|
1495
|
-
_getWatchHelpers(path
|
|
1496
|
-
return new WatchHelper(path
|
|
1491
|
+
_getWatchHelpers(path) {
|
|
1492
|
+
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
1497
1493
|
}
|
|
1498
1494
|
/**
|
|
1499
1495
|
* Provides directory tracking objects
|
|
@@ -1519,50 +1515,50 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1519
1515
|
* @param item base path of item/directory
|
|
1520
1516
|
*/
|
|
1521
1517
|
_remove(directory, item, isDirectory) {
|
|
1522
|
-
const path
|
|
1523
|
-
const fullPath = sp.resolve(path
|
|
1524
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path
|
|
1525
|
-
if (!this._throttle("remove", path
|
|
1518
|
+
const path = sp.join(directory, item);
|
|
1519
|
+
const fullPath = sp.resolve(path);
|
|
1520
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
1521
|
+
if (!this._throttle("remove", path, 100)) return;
|
|
1526
1522
|
if (!isDirectory && this._watched.size === 1) this.add(directory, item, true);
|
|
1527
|
-
this._getWatchedDir(path
|
|
1523
|
+
this._getWatchedDir(path).getChildren().forEach((nested) => this._remove(path, nested));
|
|
1528
1524
|
const parent = this._getWatchedDir(directory);
|
|
1529
1525
|
const wasTracked = parent.has(item);
|
|
1530
1526
|
parent.remove(item);
|
|
1531
1527
|
if (this._symlinkPaths.has(fullPath)) this._symlinkPaths.delete(fullPath);
|
|
1532
|
-
let relPath = path
|
|
1533
|
-
if (this.options.cwd) relPath = sp.relative(this.options.cwd, path
|
|
1528
|
+
let relPath = path;
|
|
1529
|
+
if (this.options.cwd) relPath = sp.relative(this.options.cwd, path);
|
|
1534
1530
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1535
1531
|
if (this._pendingWrites.get(relPath).cancelWait() === EVENTS.ADD) return;
|
|
1536
1532
|
}
|
|
1537
|
-
this._watched.delete(path
|
|
1533
|
+
this._watched.delete(path);
|
|
1538
1534
|
this._watched.delete(fullPath);
|
|
1539
1535
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
1540
|
-
if (wasTracked && !this._isIgnored(path
|
|
1541
|
-
this._closePath(path
|
|
1536
|
+
if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
|
|
1537
|
+
this._closePath(path);
|
|
1542
1538
|
}
|
|
1543
1539
|
/**
|
|
1544
1540
|
* Closes all watchers for a path
|
|
1545
1541
|
*/
|
|
1546
|
-
_closePath(path
|
|
1547
|
-
this._closeFile(path
|
|
1548
|
-
const dir = sp.dirname(path
|
|
1549
|
-
this._getWatchedDir(dir).remove(sp.basename(path
|
|
1542
|
+
_closePath(path) {
|
|
1543
|
+
this._closeFile(path);
|
|
1544
|
+
const dir = sp.dirname(path);
|
|
1545
|
+
this._getWatchedDir(dir).remove(sp.basename(path));
|
|
1550
1546
|
}
|
|
1551
1547
|
/**
|
|
1552
1548
|
* Closes only file-specific watchers
|
|
1553
1549
|
*/
|
|
1554
|
-
_closeFile(path
|
|
1555
|
-
const closers = this._closers.get(path
|
|
1550
|
+
_closeFile(path) {
|
|
1551
|
+
const closers = this._closers.get(path);
|
|
1556
1552
|
if (!closers) return;
|
|
1557
1553
|
closers.forEach((closer) => closer());
|
|
1558
|
-
this._closers.delete(path
|
|
1554
|
+
this._closers.delete(path);
|
|
1559
1555
|
}
|
|
1560
|
-
_addPathCloser(path
|
|
1556
|
+
_addPathCloser(path, closer) {
|
|
1561
1557
|
if (!closer) return;
|
|
1562
|
-
let list = this._closers.get(path
|
|
1558
|
+
let list = this._closers.get(path);
|
|
1563
1559
|
if (!list) {
|
|
1564
1560
|
list = [];
|
|
1565
|
-
this._closers.set(path
|
|
1561
|
+
this._closers.set(path, list);
|
|
1566
1562
|
}
|
|
1567
1563
|
list.push(closer);
|
|
1568
1564
|
}
|
|
@@ -1579,7 +1575,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1579
1575
|
stream.once(STR_CLOSE, () => {
|
|
1580
1576
|
stream = void 0;
|
|
1581
1577
|
});
|
|
1582
|
-
stream.once(
|
|
1578
|
+
stream.once("end", () => {
|
|
1583
1579
|
if (stream) {
|
|
1584
1580
|
this._streams.delete(stream);
|
|
1585
1581
|
stream = void 0;
|
|
@@ -1606,6 +1602,5 @@ var chokidar_default = {
|
|
|
1606
1602
|
watch: watch$1,
|
|
1607
1603
|
FSWatcher
|
|
1608
1604
|
};
|
|
1609
|
-
|
|
1610
1605
|
//#endregion
|
|
1611
|
-
export { watch$1 as n, chokidar_exports as t };
|
|
1606
|
+
export { watch$1 as n, chokidar_exports as t };
|