nitro 3.0.1-alpha.2 → 3.0.260415-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 +7261 -3812
- package/dist/_build/rolldown.mjs +32 -42
- package/dist/_build/rollup.mjs +28 -48
- package/dist/_build/vite.build.mjs +10 -10
- package/dist/_chunks/nitro.mjs +102 -327
- package/dist/_chunks/nitro2.mjs +8 -9
- package/dist/_chunks/nitro3.mjs +136 -0
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +40 -29
- package/dist/_common.mjs +13 -25
- package/dist/_dev.d.mts +0 -3
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
- package/dist/_libs/_.mjs +2 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +2 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +2 -0
- package/dist/_libs/_6.mjs +2 -0
- package/dist/_libs/_7.mjs +2 -0
- package/dist/_libs/c12+rc9.mjs +814 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
- package/dist/_libs/citty.mjs +142 -41
- package/dist/_libs/commondir+is-reference.mjs +60 -56
- package/dist/_libs/compatx.d.mts +0 -2
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/esbuild.d.mts +0 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
- package/dist/_libs/httpxy.d.mts +20 -13
- package/dist/_libs/httpxy.mjs +519 -95
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/magic-string.d.mts +0 -2
- package/dist/_libs/mlly.d.mts +0 -2
- package/dist/_libs/nypm+tinyexec.mjs +822 -0
- package/dist/_libs/perfect-debounce.mjs +68 -0
- package/dist/_libs/pkg-types.d.mts +0 -3
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -7
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils.mjs +3 -35
- package/dist/_libs/readdirp+chokidar.mjs +187 -365
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
- package/dist/_libs/rou3.d.mts +1 -4
- package/dist/_libs/rou3.mjs +223 -78
- package/dist/_libs/std-env.d.mts +8 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +244 -388
- package/dist/_libs/unplugin+unimport.d.mts +5 -15
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +576 -488
- package/dist/builder.d.mts +5 -25
- package/dist/builder.mjs +3 -8
- package/dist/cli/_chunks/build.mjs +22 -25
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/deploy.mjs +37 -0
- package/dist/cli/_chunks/dev.mjs +6 -11
- package/dist/cli/_chunks/docs.mjs +28 -0
- package/dist/cli/_chunks/list.mjs +4 -8
- package/dist/cli/_chunks/prepare.mjs +2 -6
- package/dist/cli/_chunks/preview.mjs +48 -0
- package/dist/cli/_chunks/run.mjs +7 -11
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +5 -6
- package/dist/docs/0.docs/0.index/index.md +56 -0
- package/dist/docs/0.docs/1.quick-start.md +110 -0
- package/dist/docs/0.docs/10.lifecycle.md +204 -0
- package/dist/docs/0.docs/11.openapi.md +291 -0
- package/dist/docs/0.docs/12.plugins.md +164 -0
- package/dist/docs/0.docs/13.tasks.md +277 -0
- package/dist/docs/0.docs/14.websocket.md +386 -0
- package/dist/docs/0.docs/15.migration.md +213 -0
- package/dist/docs/0.docs/16.nightly.md +31 -0
- package/dist/docs/0.docs/2.renderer.md +322 -0
- package/dist/docs/0.docs/3.routing.md +711 -0
- package/dist/docs/0.docs/4.server-entry.md +239 -0
- package/dist/docs/0.docs/5.cache.md +408 -0
- package/dist/docs/0.docs/6.storage.md +261 -0
- package/dist/docs/0.docs/7.assets.md +166 -0
- package/dist/docs/0.docs/8.configuration.md +256 -0
- package/dist/docs/0.docs/9.database.md +185 -0
- package/dist/docs/1.deploy/0.index/index.md +64 -0
- package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
- package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
- package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
- package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
- package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
- package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
- package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
- package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
- package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
- package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
- package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
- package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
- package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
- package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
- package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
- package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
- package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
- package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
- package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
- package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
- package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
- package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
- package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
- package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
- package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
- package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
- package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
- package/dist/docs/2.config/0.index/index.md +1221 -0
- package/dist/docs/3.examples/0.index/index.md +3 -0
- package/dist/docs/3.examples/1.api-routes.md +145 -0
- package/dist/docs/3.examples/10.hono.md +74 -0
- package/dist/docs/3.examples/11.import-alias.md +97 -0
- package/dist/docs/3.examples/12.middleware.md +91 -0
- package/dist/docs/3.examples/13.mono-jsx.md +68 -0
- package/dist/docs/3.examples/14.nano-jsx.md +70 -0
- package/dist/docs/3.examples/15.plugins.md +91 -0
- package/dist/docs/3.examples/16.renderer.md +113 -0
- package/dist/docs/3.examples/17.runtime-config.md +97 -0
- package/dist/docs/3.examples/18.server-fetch.md +87 -0
- package/dist/docs/3.examples/19.shiki.md +198 -0
- package/dist/docs/3.examples/2.auto-imports.md +92 -0
- package/dist/docs/3.examples/20.virtual-routes.md +74 -0
- package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
- package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
- package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
- package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
- package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
- package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
- package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
- package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
- package/dist/docs/3.examples/3.cached-handler.md +81 -0
- package/dist/docs/3.examples/30.vite-trpc.md +335 -0
- package/dist/docs/3.examples/31.websocket.md +282 -0
- package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
- package/dist/docs/3.examples/5.database.md +157 -0
- package/dist/docs/3.examples/6.elysia.md +70 -0
- package/dist/docs/3.examples/7.express.md +78 -0
- package/dist/docs/3.examples/8.fastify.md +79 -0
- package/dist/docs/3.examples/9.hello-world.md +68 -0
- package/dist/docs/README.md +86 -0
- package/dist/docs/index.md +121 -0
- 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/@speed-highlight/core/dist/index.js +4 -4
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +1 -1
- package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
- package/dist/node_modules/cookie-es/package.json +26 -23
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/defu/dist/defu.mjs +2 -2
- package/dist/node_modules/defu/package.json +33 -28
- package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
- package/dist/node_modules/rendu/dist/index.mjs +5 -112
- package/dist/node_modules/rendu/package.json +25 -24
- 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 +35 -32
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
- package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/azure/runtime/_utils.mjs +5 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
- package/dist/presets/bun/runtime/bun.mjs +9 -6
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
- package/dist/presets/deno/runtime/deno-server.mjs +9 -6
- package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -4
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.mjs +8 -5
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
- package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/app.mjs +12 -11
- 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/context.mjs +1 -9
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +47 -49
- 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 +11 -4
- package/dist/runtime/internal/route-rules.mjs +15 -5
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
- package/dist/runtime/internal/routes/openapi.mjs +2 -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/routes/scalar.mjs +3 -3
- package/dist/runtime/internal/routes/swagger.mjs +7 -4
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/runtime-config.mjs +2 -2
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +7 -7
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.d.mts +1 -0
- package/dist/runtime/meta.mjs +2 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +4 -2
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/renderer-template.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/virtual/tracing.d.mts +5 -0
- package/dist/runtime/virtual/tracing.mjs +1 -0
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +215 -195
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -8
- package/dist/vite.mjs +285 -253
- package/lib/tsconfig.json +3 -5
- package/package.json +97 -80
- 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,13 +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
|
-
//#region node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js
|
|
11
9
|
const EntryTypes = {
|
|
12
10
|
FILE_TYPE: "files",
|
|
13
11
|
DIR_TYPE: "directories",
|
|
@@ -65,7 +63,6 @@ const normalizeFilter = (filter) => {
|
|
|
65
63
|
}
|
|
66
64
|
return emptyFn;
|
|
67
65
|
};
|
|
68
|
-
/** Readable readdir stream, emitting new files as they're being listed. */
|
|
69
66
|
var ReaddirpStream = class extends Readable {
|
|
70
67
|
parents;
|
|
71
68
|
reading;
|
|
@@ -91,16 +88,16 @@ var ReaddirpStream = class extends Readable {
|
|
|
91
88
|
...defaultOptions,
|
|
92
89
|
...options
|
|
93
90
|
};
|
|
94
|
-
const { root, type
|
|
91
|
+
const { root, type } = opts;
|
|
95
92
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
96
93
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
97
94
|
const statMethod = opts.lstat ? lstat : stat$1;
|
|
98
|
-
if (wantBigintFsStats) this._stat = (path
|
|
95
|
+
if (wantBigintFsStats) this._stat = (path) => statMethod(path, { bigint: true });
|
|
99
96
|
else this._stat = statMethod;
|
|
100
97
|
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
|
|
98
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
99
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
100
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
104
101
|
this._root = resolve(root);
|
|
105
102
|
this._isDirent = !opts.alwaysStat;
|
|
106
103
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
@@ -120,8 +117,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
120
117
|
const par = this.parent;
|
|
121
118
|
const fil = par && par.files;
|
|
122
119
|
if (fil && fil.length > 0) {
|
|
123
|
-
const { path
|
|
124
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path
|
|
120
|
+
const { path, depth } = par;
|
|
121
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
|
125
122
|
const awaited = await Promise.all(slice);
|
|
126
123
|
for (const entry of awaited) {
|
|
127
124
|
if (!entry) continue;
|
|
@@ -156,28 +153,28 @@ var ReaddirpStream = class extends Readable {
|
|
|
156
153
|
this.reading = false;
|
|
157
154
|
}
|
|
158
155
|
}
|
|
159
|
-
async _exploreDir(path
|
|
156
|
+
async _exploreDir(path, depth) {
|
|
160
157
|
let files;
|
|
161
158
|
try {
|
|
162
|
-
files = await readdir(path
|
|
159
|
+
files = await readdir(path, this._rdOptions);
|
|
163
160
|
} catch (error) {
|
|
164
161
|
this._onError(error);
|
|
165
162
|
}
|
|
166
163
|
return {
|
|
167
164
|
files,
|
|
168
165
|
depth,
|
|
169
|
-
path
|
|
166
|
+
path
|
|
170
167
|
};
|
|
171
168
|
}
|
|
172
|
-
async _formatEntry(dirent, path
|
|
169
|
+
async _formatEntry(dirent, path) {
|
|
173
170
|
let entry;
|
|
174
|
-
const basename
|
|
171
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
175
172
|
try {
|
|
176
|
-
const fullPath = resolve(join(path
|
|
173
|
+
const fullPath = resolve(join(path, basename));
|
|
177
174
|
entry = {
|
|
178
175
|
path: relative(this._root, fullPath),
|
|
179
176
|
fullPath,
|
|
180
|
-
basename
|
|
177
|
+
basename
|
|
181
178
|
};
|
|
182
179
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
183
180
|
} catch (err) {
|
|
@@ -221,27 +218,17 @@ var ReaddirpStream = class extends Readable {
|
|
|
221
218
|
return stats && this._wantsEverything && !stats.isDirectory();
|
|
222
219
|
}
|
|
223
220
|
};
|
|
224
|
-
/**
|
|
225
|
-
* Streaming version: Reads all files and directories in given root recursively.
|
|
226
|
-
* Consumes ~constant small amount of RAM.
|
|
227
|
-
* @param root Root directory
|
|
228
|
-
* @param options Options to specify root (start directory), filters and recursion depth
|
|
229
|
-
*/
|
|
230
221
|
function readdirp(root, options = {}) {
|
|
231
|
-
let type
|
|
232
|
-
if (type
|
|
233
|
-
if (type
|
|
222
|
+
let type = options.entryType || options.type;
|
|
223
|
+
if (type === "both") type = EntryTypes.FILE_DIR_TYPE;
|
|
224
|
+
if (type) options.type = type;
|
|
234
225
|
if (!root) throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
235
226
|
else if (typeof root !== "string") throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
236
|
-
else if (type
|
|
227
|
+
else if (type && !ALL_TYPES.includes(type)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
237
228
|
options.root = root;
|
|
238
229
|
return new ReaddirpStream(options);
|
|
239
230
|
}
|
|
240
|
-
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js
|
|
243
231
|
const STR_DATA = "data";
|
|
244
|
-
const STR_END = "end";
|
|
245
232
|
const STR_CLOSE = "close";
|
|
246
233
|
const EMPTY_FN = () => {};
|
|
247
234
|
const pl = process.platform;
|
|
@@ -560,32 +547,19 @@ const delFromSet = (main, prop, item) => {
|
|
|
560
547
|
};
|
|
561
548
|
const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
562
549
|
const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
563
|
-
|
|
564
|
-
* Instantiates the fs_watch interface
|
|
565
|
-
* @param path to be watched
|
|
566
|
-
* @param options to be passed to fs_watch
|
|
567
|
-
* @param listener main event handler
|
|
568
|
-
* @param errHandler emits info about errors
|
|
569
|
-
* @param emitRaw emits raw event data
|
|
570
|
-
* @returns {NativeFsWatcher}
|
|
571
|
-
*/
|
|
572
|
-
function createFsWatchInstance(path$1, options, listener, errHandler, emitRaw) {
|
|
550
|
+
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
573
551
|
const handleEvent = (rawEvent, evPath) => {
|
|
574
|
-
listener(path
|
|
575
|
-
emitRaw(rawEvent, evPath, { watchedPath: path
|
|
576
|
-
if (evPath && path
|
|
552
|
+
listener(path);
|
|
553
|
+
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
554
|
+
if (evPath && path !== evPath) fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
577
555
|
};
|
|
578
556
|
try {
|
|
579
|
-
return watch(path
|
|
557
|
+
return watch(path, { persistent: options.persistent }, handleEvent);
|
|
580
558
|
} catch (error) {
|
|
581
559
|
errHandler(error);
|
|
582
560
|
return;
|
|
583
561
|
}
|
|
584
562
|
}
|
|
585
|
-
/**
|
|
586
|
-
* Helper for passing fs_watch event data to a collection of listeners
|
|
587
|
-
* @param fullPath absolute path bound to fs_watch instance
|
|
588
|
-
*/
|
|
589
563
|
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
590
564
|
const cont = FsWatchInstances.get(fullPath);
|
|
591
565
|
if (!cont) return;
|
|
@@ -593,20 +567,12 @@ const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
593
567
|
listener(val1, val2, val3);
|
|
594
568
|
});
|
|
595
569
|
};
|
|
596
|
-
|
|
597
|
-
* Instantiates the fs_watch interface or binds listeners
|
|
598
|
-
* to an existing one covering the same file system entry
|
|
599
|
-
* @param path
|
|
600
|
-
* @param fullPath absolute path
|
|
601
|
-
* @param options to be passed to fs_watch
|
|
602
|
-
* @param handlers container for event listener functions
|
|
603
|
-
*/
|
|
604
|
-
const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
570
|
+
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
|
605
571
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
606
572
|
let cont = FsWatchInstances.get(fullPath);
|
|
607
573
|
let watcher;
|
|
608
574
|
if (!options.persistent) {
|
|
609
|
-
watcher = createFsWatchInstance(path
|
|
575
|
+
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
|
610
576
|
if (!watcher) return;
|
|
611
577
|
return watcher.close.bind(watcher);
|
|
612
578
|
}
|
|
@@ -615,13 +581,13 @@ const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
|
615
581
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
616
582
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
617
583
|
} else {
|
|
618
|
-
watcher = createFsWatchInstance(path
|
|
584
|
+
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
619
585
|
if (!watcher) return;
|
|
620
586
|
watcher.on(EV.ERROR, async (error) => {
|
|
621
587
|
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
622
588
|
if (cont) cont.watcherUnusable = true;
|
|
623
589
|
if (isWindows && error.code === "EPERM") try {
|
|
624
|
-
await (await open(path
|
|
590
|
+
await (await open(path, "r")).close();
|
|
625
591
|
broadcastErr(error);
|
|
626
592
|
} catch (err) {}
|
|
627
593
|
else broadcastErr(error);
|
|
@@ -648,16 +614,7 @@ const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
|
648
614
|
};
|
|
649
615
|
};
|
|
650
616
|
const FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
651
|
-
|
|
652
|
-
* Instantiates the fs_watchFile interface or binds listeners
|
|
653
|
-
* to an existing one covering the same file system entry
|
|
654
|
-
* @param path to be watched
|
|
655
|
-
* @param fullPath absolute path
|
|
656
|
-
* @param options options to be passed to fs_watchFile
|
|
657
|
-
* @param handlers container for event listener functions
|
|
658
|
-
* @returns closer
|
|
659
|
-
*/
|
|
660
|
-
const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
617
|
+
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
661
618
|
const { listener, rawEmitter } = handlers;
|
|
662
619
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
663
620
|
const copts = cont && cont.options;
|
|
@@ -674,14 +631,14 @@ const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
|
674
631
|
rawEmitters: rawEmitter,
|
|
675
632
|
options,
|
|
676
633
|
watcher: watchFile(fullPath, options, (curr, prev) => {
|
|
677
|
-
foreach(cont.rawEmitters, (rawEmitter
|
|
678
|
-
rawEmitter
|
|
634
|
+
foreach(cont.rawEmitters, (rawEmitter) => {
|
|
635
|
+
rawEmitter(EV.CHANGE, fullPath, {
|
|
679
636
|
curr,
|
|
680
637
|
prev
|
|
681
638
|
});
|
|
682
639
|
});
|
|
683
640
|
const currmtime = curr.mtimeMs;
|
|
684
|
-
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener
|
|
641
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener) => listener(path, curr));
|
|
685
642
|
})
|
|
686
643
|
};
|
|
687
644
|
FsWatchFileInstances.set(fullPath, cont);
|
|
@@ -697,9 +654,6 @@ const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
|
697
654
|
}
|
|
698
655
|
};
|
|
699
656
|
};
|
|
700
|
-
/**
|
|
701
|
-
* @mixin
|
|
702
|
-
*/
|
|
703
657
|
var NodeFsHandler = class {
|
|
704
658
|
fsw;
|
|
705
659
|
_boundHandleError;
|
|
@@ -707,63 +661,53 @@ var NodeFsHandler = class {
|
|
|
707
661
|
this.fsw = fsW;
|
|
708
662
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
709
663
|
}
|
|
710
|
-
|
|
711
|
-
* Watch file for changes with fs_watchFile or fs_watch.
|
|
712
|
-
* @param path to file or dir
|
|
713
|
-
* @param listener on fs change
|
|
714
|
-
* @returns closer for the watcher instance
|
|
715
|
-
*/
|
|
716
|
-
_watchWithNodeFs(path$1, listener) {
|
|
664
|
+
_watchWithNodeFs(path, listener) {
|
|
717
665
|
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
|
|
666
|
+
const directory = sp.dirname(path);
|
|
667
|
+
const basename = sp.basename(path);
|
|
668
|
+
this.fsw._getWatchedDir(directory).add(basename);
|
|
669
|
+
const absolutePath = sp.resolve(path);
|
|
722
670
|
const options = { persistent: opts.persistent };
|
|
723
671
|
if (!listener) listener = EMPTY_FN;
|
|
724
672
|
let closer;
|
|
725
673
|
if (opts.usePolling) {
|
|
726
|
-
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename
|
|
727
|
-
closer = setFsWatchFileListener(path
|
|
674
|
+
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
|
675
|
+
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
728
676
|
listener,
|
|
729
677
|
rawEmitter: this.fsw._emitRaw
|
|
730
678
|
});
|
|
731
|
-
} else closer = setFsWatchListener(path
|
|
679
|
+
} else closer = setFsWatchListener(path, absolutePath, options, {
|
|
732
680
|
listener,
|
|
733
681
|
errHandler: this._boundHandleError,
|
|
734
682
|
rawEmitter: this.fsw._emitRaw
|
|
735
683
|
});
|
|
736
684
|
return closer;
|
|
737
685
|
}
|
|
738
|
-
/**
|
|
739
|
-
* Watch a file and emit add event if warranted.
|
|
740
|
-
* @returns closer for the watcher instance
|
|
741
|
-
*/
|
|
742
686
|
_handleFile(file, stats, initialAdd) {
|
|
743
687
|
if (this.fsw.closed) return;
|
|
744
|
-
const dirname
|
|
745
|
-
const basename
|
|
746
|
-
const parent = this.fsw._getWatchedDir(dirname
|
|
688
|
+
const dirname = sp.dirname(file);
|
|
689
|
+
const basename = sp.basename(file);
|
|
690
|
+
const parent = this.fsw._getWatchedDir(dirname);
|
|
747
691
|
let prevStats = stats;
|
|
748
|
-
if (parent.has(basename
|
|
749
|
-
const listener = async (path
|
|
692
|
+
if (parent.has(basename)) return;
|
|
693
|
+
const listener = async (path, newStats) => {
|
|
750
694
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
|
|
751
695
|
if (!newStats || newStats.mtimeMs === 0) try {
|
|
752
|
-
const newStats
|
|
696
|
+
const newStats = await stat$1(file);
|
|
753
697
|
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
|
|
698
|
+
const at = newStats.atimeMs;
|
|
699
|
+
const mt = newStats.mtimeMs;
|
|
700
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
701
|
+
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
|
|
702
|
+
this.fsw._closeFile(path);
|
|
703
|
+
prevStats = newStats;
|
|
704
|
+
const closer = this._watchWithNodeFs(file, listener);
|
|
705
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
706
|
+
} else prevStats = newStats;
|
|
763
707
|
} catch (error) {
|
|
764
|
-
this.fsw._remove(dirname
|
|
708
|
+
this.fsw._remove(dirname, basename);
|
|
765
709
|
}
|
|
766
|
-
else if (parent.has(basename
|
|
710
|
+
else if (parent.has(basename)) {
|
|
767
711
|
const at = newStats.atimeMs;
|
|
768
712
|
const mt = newStats.mtimeMs;
|
|
769
713
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
@@ -777,15 +721,7 @@ var NodeFsHandler = class {
|
|
|
777
721
|
}
|
|
778
722
|
return closer;
|
|
779
723
|
}
|
|
780
|
-
|
|
781
|
-
* Handle symlinks encountered while reading a dir.
|
|
782
|
-
* @param entry returned by readdirp
|
|
783
|
-
* @param directory path of dir being read
|
|
784
|
-
* @param path of this item
|
|
785
|
-
* @param item basename of this item
|
|
786
|
-
* @returns true if no more processing is needed for this entry.
|
|
787
|
-
*/
|
|
788
|
-
async _handleSymlink(entry, directory, path$1, item) {
|
|
724
|
+
async _handleSymlink(entry, directory, path, item) {
|
|
789
725
|
if (this.fsw.closed) return;
|
|
790
726
|
const full = entry.fullPath;
|
|
791
727
|
const dir = this.fsw._getWatchedDir(directory);
|
|
@@ -793,7 +729,7 @@ var NodeFsHandler = class {
|
|
|
793
729
|
this.fsw._incrReadyCount();
|
|
794
730
|
let linkPath;
|
|
795
731
|
try {
|
|
796
|
-
linkPath = await realpath(path
|
|
732
|
+
linkPath = await realpath(path);
|
|
797
733
|
} catch (e) {
|
|
798
734
|
this.fsw._emitReady();
|
|
799
735
|
return true;
|
|
@@ -802,12 +738,12 @@ var NodeFsHandler = class {
|
|
|
802
738
|
if (dir.has(item)) {
|
|
803
739
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
804
740
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
805
|
-
this.fsw._emit(EV.CHANGE, path
|
|
741
|
+
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
|
806
742
|
}
|
|
807
743
|
} else {
|
|
808
744
|
dir.add(item);
|
|
809
745
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
810
|
-
this.fsw._emit(EV.ADD, path
|
|
746
|
+
this.fsw._emit(EV.ADD, path, entry.stats);
|
|
811
747
|
}
|
|
812
748
|
this.fsw._emitReady();
|
|
813
749
|
return true;
|
|
@@ -833,28 +769,28 @@ var NodeFsHandler = class {
|
|
|
833
769
|
return;
|
|
834
770
|
}
|
|
835
771
|
const item = entry.path;
|
|
836
|
-
let path
|
|
772
|
+
let path = sp.join(directory, item);
|
|
837
773
|
current.add(item);
|
|
838
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path
|
|
774
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) return;
|
|
839
775
|
if (this.fsw.closed) {
|
|
840
776
|
stream = void 0;
|
|
841
777
|
return;
|
|
842
778
|
}
|
|
843
779
|
if (item === target || !target && !previous.has(item)) {
|
|
844
780
|
this.fsw._incrReadyCount();
|
|
845
|
-
path
|
|
846
|
-
this._addToNodeFs(path
|
|
781
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
782
|
+
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
847
783
|
}
|
|
848
784
|
}).on(EV.ERROR, this._boundHandleError);
|
|
849
|
-
return new Promise((resolve
|
|
785
|
+
return new Promise((resolve, reject) => {
|
|
850
786
|
if (!stream) return reject();
|
|
851
|
-
stream.once(
|
|
787
|
+
stream.once("end", () => {
|
|
852
788
|
if (this.fsw.closed) {
|
|
853
789
|
stream = void 0;
|
|
854
790
|
return;
|
|
855
791
|
}
|
|
856
792
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
857
|
-
resolve
|
|
793
|
+
resolve(void 0);
|
|
858
794
|
previous.getChildren().filter((item) => {
|
|
859
795
|
return item !== directory && !current.has(item);
|
|
860
796
|
}).forEach((item) => {
|
|
@@ -865,18 +801,7 @@ var NodeFsHandler = class {
|
|
|
865
801
|
});
|
|
866
802
|
});
|
|
867
803
|
}
|
|
868
|
-
|
|
869
|
-
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
|
870
|
-
* @param dir fs path
|
|
871
|
-
* @param stats
|
|
872
|
-
* @param initialAdd
|
|
873
|
-
* @param depth relative to user-supplied path
|
|
874
|
-
* @param target child path targeted for watch
|
|
875
|
-
* @param wh Common watch helpers for this path
|
|
876
|
-
* @param realpath
|
|
877
|
-
* @returns closer for the watcher instance.
|
|
878
|
-
*/
|
|
879
|
-
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath$1) {
|
|
804
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
880
805
|
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
881
806
|
const tracked = parentDir.has(sp.basename(dir));
|
|
882
807
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
@@ -885,34 +810,25 @@ var NodeFsHandler = class {
|
|
|
885
810
|
let throttler;
|
|
886
811
|
let closer;
|
|
887
812
|
const oDepth = this.fsw.options.depth;
|
|
888
|
-
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath
|
|
813
|
+
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
|
889
814
|
if (!target) {
|
|
890
815
|
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
891
816
|
if (this.fsw.closed) return;
|
|
892
817
|
}
|
|
893
|
-
closer = this._watchWithNodeFs(dir, (dirPath, stats
|
|
894
|
-
if (stats
|
|
818
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
|
819
|
+
if (stats && stats.mtimeMs === 0) return;
|
|
895
820
|
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
896
821
|
});
|
|
897
822
|
}
|
|
898
823
|
return closer;
|
|
899
824
|
}
|
|
900
|
-
|
|
901
|
-
* Handle added file, directory, or glob pattern.
|
|
902
|
-
* Delegates call to _handleFile / _handleDir after checks.
|
|
903
|
-
* @param path to file or ir
|
|
904
|
-
* @param initialAdd was the file added at watch instantiation?
|
|
905
|
-
* @param priorWh depth relative to user-supplied path
|
|
906
|
-
* @param depth Child path actually targeted for watch
|
|
907
|
-
* @param target Child path actually targeted for watch
|
|
908
|
-
*/
|
|
909
|
-
async _addToNodeFs(path$1, initialAdd, priorWh, depth, target) {
|
|
825
|
+
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
|
910
826
|
const ready = this.fsw._emitReady;
|
|
911
|
-
if (this.fsw._isIgnored(path
|
|
827
|
+
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
|
912
828
|
ready();
|
|
913
829
|
return false;
|
|
914
830
|
}
|
|
915
|
-
const wh = this.fsw._getWatchHelpers(path
|
|
831
|
+
const wh = this.fsw._getWatchHelpers(path);
|
|
916
832
|
if (priorWh) {
|
|
917
833
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
918
834
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -927,37 +843,33 @@ var NodeFsHandler = class {
|
|
|
927
843
|
const follow = this.fsw.options.followSymlinks;
|
|
928
844
|
let closer;
|
|
929
845
|
if (stats.isDirectory()) {
|
|
930
|
-
const absPath = sp.resolve(path
|
|
931
|
-
const targetPath = follow ? await realpath(path
|
|
846
|
+
const absPath = sp.resolve(path);
|
|
847
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
932
848
|
if (this.fsw.closed) return;
|
|
933
849
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
934
850
|
if (this.fsw.closed) return;
|
|
935
851
|
if (absPath !== targetPath && targetPath !== void 0) this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
936
852
|
} else if (stats.isSymbolicLink()) {
|
|
937
|
-
const targetPath = follow ? await realpath(path
|
|
853
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
938
854
|
if (this.fsw.closed) return;
|
|
939
855
|
const parent = sp.dirname(wh.watchPath);
|
|
940
856
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
941
857
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
942
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth, path
|
|
858
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
943
859
|
if (this.fsw.closed) return;
|
|
944
|
-
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path
|
|
860
|
+
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
945
861
|
} else closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
946
862
|
ready();
|
|
947
|
-
if (closer) this.fsw._addPathCloser(path
|
|
863
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
948
864
|
return false;
|
|
949
865
|
} catch (error) {
|
|
950
866
|
if (this.fsw._handleError(error)) {
|
|
951
867
|
ready();
|
|
952
|
-
return path
|
|
868
|
+
return path;
|
|
953
869
|
}
|
|
954
870
|
}
|
|
955
871
|
}
|
|
956
872
|
};
|
|
957
|
-
|
|
958
|
-
//#endregion
|
|
959
|
-
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js
|
|
960
|
-
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
961
873
|
var chokidar_exports = /* @__PURE__ */ __exportAll({
|
|
962
874
|
FSWatcher: () => FSWatcher,
|
|
963
875
|
WatchHelper: () => WatchHelper,
|
|
@@ -984,37 +896,37 @@ function createPattern(matcher) {
|
|
|
984
896
|
if (typeof matcher === "object" && matcher !== null) return (string) => {
|
|
985
897
|
if (matcher.path === string) return true;
|
|
986
898
|
if (matcher.recursive) {
|
|
987
|
-
const relative
|
|
988
|
-
if (!relative
|
|
989
|
-
return !relative
|
|
899
|
+
const relative = sp.relative(matcher.path, string);
|
|
900
|
+
if (!relative) return false;
|
|
901
|
+
return !relative.startsWith("..") && !sp.isAbsolute(relative);
|
|
990
902
|
}
|
|
991
903
|
return false;
|
|
992
904
|
};
|
|
993
905
|
return () => false;
|
|
994
906
|
}
|
|
995
|
-
function normalizePath(path
|
|
996
|
-
if (typeof path
|
|
997
|
-
path
|
|
998
|
-
path
|
|
907
|
+
function normalizePath(path) {
|
|
908
|
+
if (typeof path !== "string") throw new Error("string expected");
|
|
909
|
+
path = sp.normalize(path);
|
|
910
|
+
path = path.replace(/\\/g, "/");
|
|
999
911
|
let prepend = false;
|
|
1000
|
-
if (path
|
|
1001
|
-
path
|
|
1002
|
-
if (prepend) path
|
|
1003
|
-
return path
|
|
912
|
+
if (path.startsWith("//")) prepend = true;
|
|
913
|
+
path = path.replace(DOUBLE_SLASH_RE, "/");
|
|
914
|
+
if (prepend) path = "/" + path;
|
|
915
|
+
return path;
|
|
1004
916
|
}
|
|
1005
917
|
function matchPatterns(patterns, testString, stats) {
|
|
1006
|
-
const path
|
|
918
|
+
const path = normalizePath(testString);
|
|
1007
919
|
for (let index = 0; index < patterns.length; index++) {
|
|
1008
920
|
const pattern = patterns[index];
|
|
1009
|
-
if (pattern(path
|
|
921
|
+
if (pattern(path, stats)) return true;
|
|
1010
922
|
}
|
|
1011
923
|
return false;
|
|
1012
924
|
}
|
|
1013
925
|
function anymatch(matchers, testString) {
|
|
1014
926
|
if (matchers == null) throw new TypeError("anymatch: specify first argument");
|
|
1015
927
|
const patterns = arrify(matchers).map((matcher) => createPattern(matcher));
|
|
1016
|
-
if (testString == null) return (testString
|
|
1017
|
-
return matchPatterns(patterns, testString
|
|
928
|
+
if (testString == null) return (testString, stats) => {
|
|
929
|
+
return matchPatterns(patterns, testString, stats);
|
|
1018
930
|
};
|
|
1019
931
|
return matchPatterns(patterns, testString);
|
|
1020
932
|
}
|
|
@@ -1031,19 +943,16 @@ const toUnix = (string) => {
|
|
|
1031
943
|
if (prepend) str = SLASH + str;
|
|
1032
944
|
return str;
|
|
1033
945
|
};
|
|
1034
|
-
const normalizePathToUnix = (path
|
|
1035
|
-
const normalizeIgnored = (cwd = "") => (path
|
|
1036
|
-
if (typeof path
|
|
1037
|
-
else return path
|
|
946
|
+
const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
|
|
947
|
+
const normalizeIgnored = (cwd = "") => (path) => {
|
|
948
|
+
if (typeof path === "string") return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
|
|
949
|
+
else return path;
|
|
1038
950
|
};
|
|
1039
|
-
const getAbsolutePath = (path
|
|
1040
|
-
if (sp.isAbsolute(path
|
|
1041
|
-
return sp.join(cwd, path
|
|
951
|
+
const getAbsolutePath = (path, cwd) => {
|
|
952
|
+
if (sp.isAbsolute(path)) return path;
|
|
953
|
+
return sp.join(cwd, path);
|
|
1042
954
|
};
|
|
1043
955
|
const EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
1044
|
-
/**
|
|
1045
|
-
* Directory entry.
|
|
1046
|
-
*/
|
|
1047
956
|
var DirEntry = class {
|
|
1048
957
|
path;
|
|
1049
958
|
_removeWatcher;
|
|
@@ -1098,10 +1007,10 @@ var WatchHelper = class {
|
|
|
1098
1007
|
dirParts;
|
|
1099
1008
|
followSymlinks;
|
|
1100
1009
|
statMethod;
|
|
1101
|
-
constructor(path
|
|
1010
|
+
constructor(path, follow, fsw) {
|
|
1102
1011
|
this.fsw = fsw;
|
|
1103
|
-
const watchPath = path
|
|
1104
|
-
this.path = path
|
|
1012
|
+
const watchPath = path;
|
|
1013
|
+
this.path = path = path.replace(REPLACER_RE, "");
|
|
1105
1014
|
this.watchPath = watchPath;
|
|
1106
1015
|
this.fullWatchPath = sp.resolve(watchPath);
|
|
1107
1016
|
this.dirParts = [];
|
|
@@ -1124,14 +1033,6 @@ var WatchHelper = class {
|
|
|
1124
1033
|
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
1125
1034
|
}
|
|
1126
1035
|
};
|
|
1127
|
-
/**
|
|
1128
|
-
* Watches files & directories for changes. Emitted events:
|
|
1129
|
-
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
|
1130
|
-
*
|
|
1131
|
-
* new FSWatcher()
|
|
1132
|
-
* .add(directories)
|
|
1133
|
-
* .on('add', path => log('File', path, 'was added'))
|
|
1134
|
-
*/
|
|
1135
1036
|
var FSWatcher = class extends EventEmitter {
|
|
1136
1037
|
closed;
|
|
1137
1038
|
options;
|
|
@@ -1223,26 +1124,22 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1223
1124
|
for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher) this._ignoredPaths.delete(ignored);
|
|
1224
1125
|
}
|
|
1225
1126
|
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Adds paths to be watched on an existing FSWatcher instance.
|
|
1228
|
-
* @param paths_ file or file list. Other arguments are unused
|
|
1229
|
-
*/
|
|
1230
1127
|
add(paths_, _origAdd, _internal) {
|
|
1231
1128
|
const { cwd } = this.options;
|
|
1232
1129
|
this.closed = false;
|
|
1233
1130
|
this._closePromise = void 0;
|
|
1234
1131
|
let paths = unifyPaths(paths_);
|
|
1235
|
-
if (cwd) paths = paths.map((path
|
|
1236
|
-
return getAbsolutePath(path
|
|
1132
|
+
if (cwd) paths = paths.map((path) => {
|
|
1133
|
+
return getAbsolutePath(path, cwd);
|
|
1237
1134
|
});
|
|
1238
|
-
paths.forEach((path
|
|
1239
|
-
this._removeIgnoredPath(path
|
|
1135
|
+
paths.forEach((path) => {
|
|
1136
|
+
this._removeIgnoredPath(path);
|
|
1240
1137
|
});
|
|
1241
1138
|
this._userIgnored = void 0;
|
|
1242
1139
|
if (!this._readyCount) this._readyCount = 0;
|
|
1243
1140
|
this._readyCount += paths.length;
|
|
1244
|
-
Promise.all(paths.map(async (path
|
|
1245
|
-
const res = await this._nodeFsHandler._addToNodeFs(path
|
|
1141
|
+
Promise.all(paths.map(async (path) => {
|
|
1142
|
+
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
|
|
1246
1143
|
if (res) this._emitReady();
|
|
1247
1144
|
return res;
|
|
1248
1145
|
})).then((results) => {
|
|
@@ -1253,31 +1150,25 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1253
1150
|
});
|
|
1254
1151
|
return this;
|
|
1255
1152
|
}
|
|
1256
|
-
/**
|
|
1257
|
-
* Close watchers or start ignoring events from specified paths.
|
|
1258
|
-
*/
|
|
1259
1153
|
unwatch(paths_) {
|
|
1260
1154
|
if (this.closed) return this;
|
|
1261
1155
|
const paths = unifyPaths(paths_);
|
|
1262
1156
|
const { cwd } = this.options;
|
|
1263
|
-
paths.forEach((path
|
|
1264
|
-
if (!sp.isAbsolute(path
|
|
1265
|
-
if (cwd) path
|
|
1266
|
-
path
|
|
1157
|
+
paths.forEach((path) => {
|
|
1158
|
+
if (!sp.isAbsolute(path) && !this._closers.has(path)) {
|
|
1159
|
+
if (cwd) path = sp.join(cwd, path);
|
|
1160
|
+
path = sp.resolve(path);
|
|
1267
1161
|
}
|
|
1268
|
-
this._closePath(path
|
|
1269
|
-
this._addIgnoredPath(path
|
|
1270
|
-
if (this._watched.has(path
|
|
1271
|
-
path
|
|
1162
|
+
this._closePath(path);
|
|
1163
|
+
this._addIgnoredPath(path);
|
|
1164
|
+
if (this._watched.has(path)) this._addIgnoredPath({
|
|
1165
|
+
path,
|
|
1272
1166
|
recursive: true
|
|
1273
1167
|
});
|
|
1274
1168
|
this._userIgnored = void 0;
|
|
1275
1169
|
});
|
|
1276
1170
|
return this;
|
|
1277
1171
|
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Close watchers and remove all listeners from watched paths.
|
|
1280
|
-
*/
|
|
1281
1172
|
close() {
|
|
1282
1173
|
if (this._closePromise) return this._closePromise;
|
|
1283
1174
|
this.closed = true;
|
|
@@ -1300,10 +1191,6 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1300
1191
|
this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
|
|
1301
1192
|
return this._closePromise;
|
|
1302
1193
|
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Expose list of watched paths
|
|
1305
|
-
* @returns for chaining
|
|
1306
|
-
*/
|
|
1307
1194
|
getWatched() {
|
|
1308
1195
|
const watchList = {};
|
|
1309
1196
|
this._watched.forEach((entry, dir) => {
|
|
@@ -1316,104 +1203,85 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1316
1203
|
this.emit(event, ...args);
|
|
1317
1204
|
if (event !== EVENTS.ERROR) this.emit(EVENTS.ALL, event, ...args);
|
|
1318
1205
|
}
|
|
1319
|
-
|
|
1320
|
-
* Normalize and emit events.
|
|
1321
|
-
* Calling _emit DOES NOT MEAN emit() would be called!
|
|
1322
|
-
* @param event Type of event
|
|
1323
|
-
* @param path File or directory path
|
|
1324
|
-
* @param stats arguments to be passed with event
|
|
1325
|
-
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1326
|
-
*/
|
|
1327
|
-
async _emit(event, path$1, stats) {
|
|
1206
|
+
async _emit(event, path, stats) {
|
|
1328
1207
|
if (this.closed) return;
|
|
1329
1208
|
const opts = this.options;
|
|
1330
|
-
if (isWindows) path
|
|
1331
|
-
if (opts.cwd) path
|
|
1332
|
-
const args = [path
|
|
1209
|
+
if (isWindows) path = sp.normalize(path);
|
|
1210
|
+
if (opts.cwd) path = sp.relative(opts.cwd, path);
|
|
1211
|
+
const args = [path];
|
|
1333
1212
|
if (stats != null) args.push(stats);
|
|
1334
1213
|
const awf = opts.awaitWriteFinish;
|
|
1335
1214
|
let pw;
|
|
1336
|
-
if (awf && (pw = this._pendingWrites.get(path
|
|
1215
|
+
if (awf && (pw = this._pendingWrites.get(path))) {
|
|
1337
1216
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
1338
1217
|
return this;
|
|
1339
1218
|
}
|
|
1340
1219
|
if (opts.atomic) {
|
|
1341
1220
|
if (event === EVENTS.UNLINK) {
|
|
1342
|
-
this._pendingUnlinks.set(path
|
|
1221
|
+
this._pendingUnlinks.set(path, [event, ...args]);
|
|
1343
1222
|
setTimeout(() => {
|
|
1344
|
-
this._pendingUnlinks.forEach((entry, path
|
|
1223
|
+
this._pendingUnlinks.forEach((entry, path) => {
|
|
1345
1224
|
this.emit(...entry);
|
|
1346
1225
|
this.emit(EVENTS.ALL, ...entry);
|
|
1347
|
-
this._pendingUnlinks.delete(path
|
|
1226
|
+
this._pendingUnlinks.delete(path);
|
|
1348
1227
|
});
|
|
1349
1228
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
1350
1229
|
return this;
|
|
1351
1230
|
}
|
|
1352
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(path
|
|
1231
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
|
|
1353
1232
|
event = EVENTS.CHANGE;
|
|
1354
|
-
this._pendingUnlinks.delete(path
|
|
1233
|
+
this._pendingUnlinks.delete(path);
|
|
1355
1234
|
}
|
|
1356
1235
|
}
|
|
1357
1236
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
1358
|
-
const awfEmit = (err, stats
|
|
1237
|
+
const awfEmit = (err, stats) => {
|
|
1359
1238
|
if (err) {
|
|
1360
1239
|
event = EVENTS.ERROR;
|
|
1361
1240
|
args[0] = err;
|
|
1362
1241
|
this.emitWithAll(event, args);
|
|
1363
|
-
} else if (stats
|
|
1364
|
-
if (args.length > 1) args[1] = stats
|
|
1365
|
-
else args.push(stats
|
|
1242
|
+
} else if (stats) {
|
|
1243
|
+
if (args.length > 1) args[1] = stats;
|
|
1244
|
+
else args.push(stats);
|
|
1366
1245
|
this.emitWithAll(event, args);
|
|
1367
1246
|
}
|
|
1368
1247
|
};
|
|
1369
|
-
this._awaitWriteFinish(path
|
|
1248
|
+
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
|
1370
1249
|
return this;
|
|
1371
1250
|
}
|
|
1372
1251
|
if (event === EVENTS.CHANGE) {
|
|
1373
|
-
if (!this._throttle(EVENTS.CHANGE, path
|
|
1252
|
+
if (!this._throttle(EVENTS.CHANGE, path, 50)) return this;
|
|
1374
1253
|
}
|
|
1375
1254
|
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
|
|
1255
|
+
const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
|
|
1256
|
+
let stats;
|
|
1378
1257
|
try {
|
|
1379
|
-
stats
|
|
1258
|
+
stats = await stat$1(fullPath);
|
|
1380
1259
|
} catch (err) {}
|
|
1381
|
-
if (!stats
|
|
1382
|
-
args.push(stats
|
|
1260
|
+
if (!stats || this.closed) return;
|
|
1261
|
+
args.push(stats);
|
|
1383
1262
|
}
|
|
1384
1263
|
this.emitWithAll(event, args);
|
|
1385
1264
|
return this;
|
|
1386
1265
|
}
|
|
1387
|
-
/**
|
|
1388
|
-
* Common handler for errors
|
|
1389
|
-
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1390
|
-
*/
|
|
1391
1266
|
_handleError(error) {
|
|
1392
1267
|
const code = error && error.code;
|
|
1393
1268
|
if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) this.emit(EVENTS.ERROR, error);
|
|
1394
1269
|
return error || this.closed;
|
|
1395
1270
|
}
|
|
1396
|
-
|
|
1397
|
-
* Helper utility for throttling
|
|
1398
|
-
* @param actionType type being throttled
|
|
1399
|
-
* @param path being acted upon
|
|
1400
|
-
* @param timeout duration of time to suppress duplicate actions
|
|
1401
|
-
* @returns tracking object or false if action should be suppressed
|
|
1402
|
-
*/
|
|
1403
|
-
_throttle(actionType, path$1, timeout) {
|
|
1271
|
+
_throttle(actionType, path, timeout) {
|
|
1404
1272
|
if (!this._throttled.has(actionType)) this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
1405
1273
|
const action = this._throttled.get(actionType);
|
|
1406
1274
|
if (!action) throw new Error("invalid throttle");
|
|
1407
|
-
const actionPath = action.get(path
|
|
1275
|
+
const actionPath = action.get(path);
|
|
1408
1276
|
if (actionPath) {
|
|
1409
1277
|
actionPath.count++;
|
|
1410
1278
|
return false;
|
|
1411
1279
|
}
|
|
1412
1280
|
let timeoutObject;
|
|
1413
1281
|
const clear = () => {
|
|
1414
|
-
const item = action.get(path
|
|
1282
|
+
const item = action.get(path);
|
|
1415
1283
|
const count = item ? item.count : 0;
|
|
1416
|
-
action.delete(path
|
|
1284
|
+
action.delete(path);
|
|
1417
1285
|
clearTimeout(timeoutObject);
|
|
1418
1286
|
if (item) clearTimeout(item.timeoutObject);
|
|
1419
1287
|
return count;
|
|
@@ -1424,48 +1292,40 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1424
1292
|
clear,
|
|
1425
1293
|
count: 0
|
|
1426
1294
|
};
|
|
1427
|
-
action.set(path
|
|
1295
|
+
action.set(path, thr);
|
|
1428
1296
|
return thr;
|
|
1429
1297
|
}
|
|
1430
1298
|
_incrReadyCount() {
|
|
1431
1299
|
return this._readyCount++;
|
|
1432
1300
|
}
|
|
1433
|
-
|
|
1434
|
-
* Awaits write operation to finish.
|
|
1435
|
-
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
|
1436
|
-
* @param path being acted upon
|
|
1437
|
-
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
|
1438
|
-
* @param event
|
|
1439
|
-
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
1440
|
-
*/
|
|
1441
|
-
_awaitWriteFinish(path$1, threshold, event, awfEmit) {
|
|
1301
|
+
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
|
1442
1302
|
const awf = this.options.awaitWriteFinish;
|
|
1443
1303
|
if (typeof awf !== "object") return;
|
|
1444
1304
|
const pollInterval = awf.pollInterval;
|
|
1445
1305
|
let timeoutHandler;
|
|
1446
|
-
let fullPath = path
|
|
1447
|
-
if (this.options.cwd && !sp.isAbsolute(path
|
|
1306
|
+
let fullPath = path;
|
|
1307
|
+
if (this.options.cwd && !sp.isAbsolute(path)) fullPath = sp.join(this.options.cwd, path);
|
|
1448
1308
|
const now = /* @__PURE__ */ new Date();
|
|
1449
1309
|
const writes = this._pendingWrites;
|
|
1450
1310
|
function awaitWriteFinishFn(prevStat) {
|
|
1451
1311
|
stat(fullPath, (err, curStat) => {
|
|
1452
|
-
if (err || !writes.has(path
|
|
1312
|
+
if (err || !writes.has(path)) {
|
|
1453
1313
|
if (err && err.code !== "ENOENT") awfEmit(err);
|
|
1454
1314
|
return;
|
|
1455
1315
|
}
|
|
1456
|
-
const now
|
|
1457
|
-
if (prevStat && curStat.size !== prevStat.size) writes.get(path
|
|
1458
|
-
if (now
|
|
1459
|
-
writes.delete(path
|
|
1316
|
+
const now = Number(/* @__PURE__ */ new Date());
|
|
1317
|
+
if (prevStat && curStat.size !== prevStat.size) writes.get(path).lastChange = now;
|
|
1318
|
+
if (now - writes.get(path).lastChange >= threshold) {
|
|
1319
|
+
writes.delete(path);
|
|
1460
1320
|
awfEmit(void 0, curStat);
|
|
1461
1321
|
} else timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
1462
1322
|
});
|
|
1463
1323
|
}
|
|
1464
|
-
if (!writes.has(path
|
|
1465
|
-
writes.set(path
|
|
1324
|
+
if (!writes.has(path)) {
|
|
1325
|
+
writes.set(path, {
|
|
1466
1326
|
lastChange: now,
|
|
1467
1327
|
cancelWait: () => {
|
|
1468
|
-
writes.delete(path
|
|
1328
|
+
writes.delete(path);
|
|
1469
1329
|
clearTimeout(timeoutHandler);
|
|
1470
1330
|
return event;
|
|
1471
1331
|
}
|
|
@@ -1473,96 +1333,69 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1473
1333
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
1474
1334
|
}
|
|
1475
1335
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
*/
|
|
1479
|
-
_isIgnored(path$1, stats) {
|
|
1480
|
-
if (this.options.atomic && DOT_RE.test(path$1)) return true;
|
|
1336
|
+
_isIgnored(path, stats) {
|
|
1337
|
+
if (this.options.atomic && DOT_RE.test(path)) return true;
|
|
1481
1338
|
if (!this._userIgnored) {
|
|
1482
1339
|
const { cwd } = this.options;
|
|
1483
1340
|
const ignored = (this.options.ignored || []).map(normalizeIgnored(cwd));
|
|
1484
1341
|
this._userIgnored = anymatch([...[...this._ignoredPaths].map(normalizeIgnored(cwd)), ...ignored], void 0);
|
|
1485
1342
|
}
|
|
1486
|
-
return this._userIgnored(path
|
|
1343
|
+
return this._userIgnored(path, stats);
|
|
1487
1344
|
}
|
|
1488
|
-
_isntIgnored(path
|
|
1489
|
-
return !this._isIgnored(path
|
|
1345
|
+
_isntIgnored(path, stat) {
|
|
1346
|
+
return !this._isIgnored(path, stat);
|
|
1490
1347
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
* @param path file or directory pattern being watched
|
|
1494
|
-
*/
|
|
1495
|
-
_getWatchHelpers(path$1) {
|
|
1496
|
-
return new WatchHelper(path$1, this.options.followSymlinks, this);
|
|
1348
|
+
_getWatchHelpers(path) {
|
|
1349
|
+
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
1497
1350
|
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Provides directory tracking objects
|
|
1500
|
-
* @param directory path of the directory
|
|
1501
|
-
*/
|
|
1502
1351
|
_getWatchedDir(directory) {
|
|
1503
1352
|
const dir = sp.resolve(directory);
|
|
1504
1353
|
if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
1505
1354
|
return this._watched.get(dir);
|
|
1506
1355
|
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
|
1509
|
-
*/
|
|
1510
1356
|
_hasReadPermissions(stats) {
|
|
1511
1357
|
if (this.options.ignorePermissionErrors) return true;
|
|
1512
1358
|
return Boolean(Number(stats.mode) & 256);
|
|
1513
1359
|
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Handles emitting unlink events for
|
|
1516
|
-
* files and directories, and via recursion, for
|
|
1517
|
-
* files and directories within directories that are unlinked
|
|
1518
|
-
* @param directory within which the following item is located
|
|
1519
|
-
* @param item base path of item/directory
|
|
1520
|
-
*/
|
|
1521
1360
|
_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
|
|
1361
|
+
const path = sp.join(directory, item);
|
|
1362
|
+
const fullPath = sp.resolve(path);
|
|
1363
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
1364
|
+
if (!this._throttle("remove", path, 100)) return;
|
|
1526
1365
|
if (!isDirectory && this._watched.size === 1) this.add(directory, item, true);
|
|
1527
|
-
this._getWatchedDir(path
|
|
1366
|
+
this._getWatchedDir(path).getChildren().forEach((nested) => this._remove(path, nested));
|
|
1528
1367
|
const parent = this._getWatchedDir(directory);
|
|
1529
1368
|
const wasTracked = parent.has(item);
|
|
1530
1369
|
parent.remove(item);
|
|
1531
1370
|
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
|
|
1371
|
+
let relPath = path;
|
|
1372
|
+
if (this.options.cwd) relPath = sp.relative(this.options.cwd, path);
|
|
1534
1373
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1535
1374
|
if (this._pendingWrites.get(relPath).cancelWait() === EVENTS.ADD) return;
|
|
1536
1375
|
}
|
|
1537
|
-
this._watched.delete(path
|
|
1376
|
+
this._watched.delete(path);
|
|
1538
1377
|
this._watched.delete(fullPath);
|
|
1539
1378
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
1540
|
-
if (wasTracked && !this._isIgnored(path
|
|
1541
|
-
this._closePath(path
|
|
1379
|
+
if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
|
|
1380
|
+
this._closePath(path);
|
|
1542
1381
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
this._closeFile(path$1);
|
|
1548
|
-
const dir = sp.dirname(path$1);
|
|
1549
|
-
this._getWatchedDir(dir).remove(sp.basename(path$1));
|
|
1382
|
+
_closePath(path) {
|
|
1383
|
+
this._closeFile(path);
|
|
1384
|
+
const dir = sp.dirname(path);
|
|
1385
|
+
this._getWatchedDir(dir).remove(sp.basename(path));
|
|
1550
1386
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
*/
|
|
1554
|
-
_closeFile(path$1) {
|
|
1555
|
-
const closers = this._closers.get(path$1);
|
|
1387
|
+
_closeFile(path) {
|
|
1388
|
+
const closers = this._closers.get(path);
|
|
1556
1389
|
if (!closers) return;
|
|
1557
1390
|
closers.forEach((closer) => closer());
|
|
1558
|
-
this._closers.delete(path
|
|
1391
|
+
this._closers.delete(path);
|
|
1559
1392
|
}
|
|
1560
|
-
_addPathCloser(path
|
|
1393
|
+
_addPathCloser(path, closer) {
|
|
1561
1394
|
if (!closer) return;
|
|
1562
|
-
let list = this._closers.get(path
|
|
1395
|
+
let list = this._closers.get(path);
|
|
1563
1396
|
if (!list) {
|
|
1564
1397
|
list = [];
|
|
1565
|
-
this._closers.set(path
|
|
1398
|
+
this._closers.set(path, list);
|
|
1566
1399
|
}
|
|
1567
1400
|
list.push(closer);
|
|
1568
1401
|
}
|
|
@@ -1579,7 +1412,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1579
1412
|
stream.once(STR_CLOSE, () => {
|
|
1580
1413
|
stream = void 0;
|
|
1581
1414
|
});
|
|
1582
|
-
stream.once(
|
|
1415
|
+
stream.once("end", () => {
|
|
1583
1416
|
if (stream) {
|
|
1584
1417
|
this._streams.delete(stream);
|
|
1585
1418
|
stream = void 0;
|
|
@@ -1588,15 +1421,6 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1588
1421
|
return stream;
|
|
1589
1422
|
}
|
|
1590
1423
|
};
|
|
1591
|
-
/**
|
|
1592
|
-
* Instantiates watcher with paths to be tracked.
|
|
1593
|
-
* @param paths file / directory paths
|
|
1594
|
-
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
|
1595
|
-
* @returns an instance of FSWatcher for chaining.
|
|
1596
|
-
* @example
|
|
1597
|
-
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
|
1598
|
-
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
|
1599
|
-
*/
|
|
1600
1424
|
function watch$1(paths, options = {}) {
|
|
1601
1425
|
const watcher = new FSWatcher(options);
|
|
1602
1426
|
watcher.add(paths);
|
|
@@ -1606,6 +1430,4 @@ var chokidar_default = {
|
|
|
1606
1430
|
watch: watch$1,
|
|
1607
1431
|
FSWatcher
|
|
1608
1432
|
};
|
|
1609
|
-
|
|
1610
|
-
//#endregion
|
|
1611
|
-
export { watch$1 as n, chokidar_exports as t };
|
|
1433
|
+
export { watch$1 as n, chokidar_exports as t };
|