nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-121649-98b56dfe
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/dist/_build/common.mjs +763 -0
- package/dist/_build/rolldown.mjs +216 -0
- package/dist/_build/rollup.mjs +359 -0
- package/dist/_build/vite.build.mjs +67 -0
- package/dist/_build/vite.plugin.mjs +747 -0
- package/dist/_chunks/B-7HiF0V.mjs +1303 -0
- package/dist/_chunks/B3asVbT4.mjs +151 -0
- package/dist/_chunks/B5ooyfLk.mjs +372 -0
- package/dist/_chunks/DXMHy5ca.mjs +43 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +675 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2798 -0
- package/dist/_libs/chokidar.mjs +1560 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/debug.mjs +848 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/depd.mjs +314 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/ee-first.mjs +68 -0
- package/dist/_libs/encodeurl.mjs +49 -0
- package/dist/_libs/escape-html.mjs +58 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +75 -0
- package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
- package/dist/_libs/fresh.mjs +85 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19076 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/http-errors.mjs +436 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
- package/dist/_libs/klona.mjs +90 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
- package/dist/_libs/mime-db.mjs +7642 -0
- package/dist/_libs/mime-types.mjs +162 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/on-finished.mjs +170 -0
- package/dist/_libs/parseurl.mjs +103 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1489 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/range-parser.mjs +102 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
- package/dist/_libs/send.mjs +857 -0
- package/dist/_libs/serve-static.mjs +124 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5825 -0
- package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
- package/dist/_presets.mjs +1723 -0
- package/dist/builder.d.mts +37 -35
- package/dist/builder.mjs +45 -117
- package/dist/cli/_chunks/build.mjs +43 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +79 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -18
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +18 -17
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
- package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
- package/dist/presets/deno/runtime/deno-server.mjs +31 -39
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
- package/dist/presets/netlify/runtime/netlify.mjs +11 -17
- package/dist/presets/node/runtime/node-cluster.mjs +49 -48
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
- package/dist/presets/node/runtime/node-middleware.mjs +7 -6
- package/dist/presets/node/runtime/node-server.mjs +33 -23
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +1 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
- package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
- package/dist/presets/vercel/runtime/vercel.mjs +15 -14
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/runtime/index.d.mts +12 -1
- package/dist/runtime/index.mjs +12 -7
- package/dist/runtime/internal/app.mjs +175 -162
- package/dist/runtime/internal/cache.d.mts +10 -4
- package/dist/runtime/internal/cache.mjs +247 -216
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/prod.d.mts +2 -2
- package/dist/runtime/internal/error/prod.mjs +48 -52
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +2 -0
- package/dist/runtime/internal/index.mjs +2 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/renderer.mjs +39 -31
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +53 -51
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/shutdown.d.mts +2 -7
- package/dist/runtime/internal/shutdown.mjs +30 -29
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -59
- package/dist/runtime/internal/utils.d.mts +1 -1
- package/dist/runtime/internal/utils.mjs +4 -10
- package/dist/types/index.d.mts +2566 -3851
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +56 -52
- package/dist/vite.mjs +55 -132
- package/package.json +10 -10
- package/dist/_build/build.mjs +0 -368
- package/dist/_build/build2.mjs +0 -556
- package/dist/_build/info.mjs +0 -1002
- package/dist/_build/prepare.mjs +0 -1511
- package/dist/_build/snapshot.mjs +0 -185
- package/dist/_build/vite.mjs +0 -959
- package/dist/_build/vite2.mjs +0 -149
- package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
- package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
- package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
- package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
- package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
- package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
- package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
- package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
- package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
- package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
- package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
- package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
- package/dist/_chunks/_deps/acorn.mjs +0 -6225
- package/dist/_chunks/_deps/c12.mjs +0 -510
- package/dist/_chunks/_deps/chokidar.mjs +0 -1428
- package/dist/_chunks/_deps/citty.mjs +0 -460
- package/dist/_chunks/_deps/commondir.mjs +0 -77
- package/dist/_chunks/_deps/compatx.mjs +0 -76
- package/dist/_chunks/_deps/confbox.mjs +0 -300
- package/dist/_chunks/_deps/debug.mjs +0 -885
- package/dist/_chunks/_deps/deepmerge.mjs +0 -147
- package/dist/_chunks/_deps/depd.mjs +0 -550
- package/dist/_chunks/_deps/dot-prop.mjs +0 -282
- package/dist/_chunks/_deps/dotenv.mjs +0 -555
- package/dist/_chunks/_deps/duplexer.mjs +0 -1
- package/dist/_chunks/_deps/ee-first.mjs +0 -104
- package/dist/_chunks/_deps/encodeurl.mjs +0 -69
- package/dist/_chunks/_deps/escape-html.mjs +0 -87
- package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
- package/dist/_chunks/_deps/estree-walker.mjs +0 -433
- package/dist/_chunks/_deps/etag.mjs +0 -147
- package/dist/_chunks/_deps/exsolve.mjs +0 -1416
- package/dist/_chunks/_deps/fresh.mjs +0 -145
- package/dist/_chunks/_deps/function-bind.mjs +0 -106
- package/dist/_chunks/_deps/giget.mjs +0 -451
- package/dist/_chunks/_deps/gzip-size.mjs +0 -19
- package/dist/_chunks/_deps/hasown.mjs +0 -19
- package/dist/_chunks/_deps/http-errors.mjs +0 -307
- package/dist/_chunks/_deps/httpxy.mjs +0 -580
- package/dist/_chunks/_deps/inherits.mjs +0 -57
- package/dist/_chunks/_deps/is-core-module.mjs +0 -596
- package/dist/_chunks/_deps/is-module.mjs +0 -25
- package/dist/_chunks/_deps/is-reference.mjs +0 -31
- package/dist/_chunks/_deps/klona.mjs +0 -137
- package/dist/_chunks/_deps/knitwork.mjs +0 -172
- package/dist/_chunks/_deps/local-pkg.mjs +0 -163
- package/dist/_chunks/_deps/mime-db.mjs +0 -11685
- package/dist/_chunks/_deps/mime-types.mjs +0 -287
- package/dist/_chunks/_deps/mime.mjs +0 -1172
- package/dist/_chunks/_deps/mlly.mjs +0 -2413
- package/dist/_chunks/_deps/ms.mjs +0 -172
- package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
- package/dist/_chunks/_deps/nypm.mjs +0 -219
- package/dist/_chunks/_deps/on-finished.mjs +0 -246
- package/dist/_chunks/_deps/parseurl.mjs +0 -168
- package/dist/_chunks/_deps/path-parse.mjs +0 -85
- package/dist/_chunks/_deps/pathe.mjs +0 -251
- package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
- package/dist/_chunks/_deps/picomatch.mjs +0 -2144
- package/dist/_chunks/_deps/pkg-types.mjs +0 -247
- package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
- package/dist/_chunks/_deps/quansync.mjs +0 -99
- package/dist/_chunks/_deps/range-parser.mjs +0 -171
- package/dist/_chunks/_deps/rc9.mjs +0 -219
- package/dist/_chunks/_deps/readdirp.mjs +0 -245
- package/dist/_chunks/_deps/resolve.mjs +0 -1260
- package/dist/_chunks/_deps/send.mjs +0 -1022
- package/dist/_chunks/_deps/serve-static.mjs +0 -228
- package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
- package/dist/_chunks/_deps/statuses.mjs +0 -457
- package/dist/_chunks/_deps/std-env.mjs +0 -3
- package/dist/_chunks/_deps/strip-literal.mjs +0 -67
- package/dist/_chunks/_deps/supports-color.mjs +0 -44
- package/dist/_chunks/_deps/tinyexec.mjs +0 -552
- package/dist/_chunks/_deps/toidentifier.mjs +0 -41
- package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
- package/dist/_chunks/_deps/unimport.mjs +0 -2267
- package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
- package/dist/_chunks/_deps/unplugin.mjs +0 -1294
- package/dist/_chunks/_deps/untyped.mjs +0 -375
- package/dist/_chunks/_deps/unwasm.mjs +0 -6959
- package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
- package/dist/_chunks/_presets/_all.mjs +0 -59
- package/dist/_chunks/_presets/_nitro.mjs +0 -74
- package/dist/_chunks/_presets/_resolve.mjs +0 -64
- package/dist/_chunks/_presets/_static.mjs +0 -69
- package/dist/_chunks/_presets/_types.mjs +0 -3
- package/dist/_chunks/_presets/_utils.mjs +0 -31
- package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
- package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
- package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
- package/dist/_chunks/_presets/azure.mjs +0 -162
- package/dist/_chunks/_presets/bun.mjs +0 -19
- package/dist/_chunks/_presets/cleavr.mjs +0 -15
- package/dist/_chunks/_presets/cloudflare.mjs +0 -608
- package/dist/_chunks/_presets/deno.mjs +0 -196
- package/dist/_chunks/_presets/digitalocean.mjs +0 -14
- package/dist/_chunks/_presets/firebase.mjs +0 -47
- package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
- package/dist/_chunks/_presets/genezio.mjs +0 -13
- package/dist/_chunks/_presets/heroku.mjs +0 -14
- package/dist/_chunks/_presets/iis.mjs +0 -194
- package/dist/_chunks/_presets/index.mjs +0 -62
- package/dist/_chunks/_presets/koyeb.mjs +0 -14
- package/dist/_chunks/_presets/netlify.mjs +0 -241
- package/dist/_chunks/_presets/node.mjs +0 -54
- package/dist/_chunks/_presets/platform.mjs +0 -14
- package/dist/_chunks/_presets/render.mjs +0 -14
- package/dist/_chunks/_presets/standard.mjs +0 -23
- package/dist/_chunks/_presets/stormkit.mjs +0 -18
- package/dist/_chunks/_presets/vercel.mjs +0 -375
- package/dist/_chunks/_presets/winterjs.mjs +0 -22
- package/dist/_chunks/_presets/zeabur.mjs +0 -69
- package/dist/_chunks/_presets/zerops.mjs +0 -27
- package/dist/_chunks/app.mjs +0 -600
- package/dist/_chunks/builder.mjs +0 -648
- package/dist/_chunks/server.mjs +0 -256
- package/dist/_cli/build.mjs +0 -49
- package/dist/_cli/common.mjs +0 -13
- package/dist/_cli/dev.mjs +0 -121
- package/dist/_cli/index.mjs +0 -16
- package/dist/_cli/list.mjs +0 -33
- package/dist/_cli/prepare.mjs +0 -23
- package/dist/_cli/run.mjs +0 -59
- package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- /package/lib/{indexd.mts → index.d.mts} +0 -0
|
@@ -0,0 +1,1560 @@
|
|
|
1
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { lstat, readdir, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { stat as stat$1, unwatchFile, watch, watchFile } from "fs";
|
|
4
|
+
import * as sysPath from "path";
|
|
5
|
+
import { type } from "os";
|
|
6
|
+
import { lstat as lstat$1, open, readdir as readdir$1, realpath as realpath$1, stat as stat$2 } from "fs/promises";
|
|
7
|
+
import { EventEmitter } from "events";
|
|
8
|
+
import { Readable } from "node:stream";
|
|
9
|
+
|
|
10
|
+
//#region node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js
|
|
11
|
+
const EntryTypes = {
|
|
12
|
+
FILE_TYPE: "files",
|
|
13
|
+
DIR_TYPE: "directories",
|
|
14
|
+
FILE_DIR_TYPE: "files_directories",
|
|
15
|
+
EVERYTHING_TYPE: "all"
|
|
16
|
+
};
|
|
17
|
+
const defaultOptions = {
|
|
18
|
+
root: ".",
|
|
19
|
+
fileFilter: (_entryInfo) => true,
|
|
20
|
+
directoryFilter: (_entryInfo) => true,
|
|
21
|
+
type: EntryTypes.FILE_TYPE,
|
|
22
|
+
lstat: false,
|
|
23
|
+
depth: 2147483648,
|
|
24
|
+
alwaysStat: false,
|
|
25
|
+
highWaterMark: 4096
|
|
26
|
+
};
|
|
27
|
+
Object.freeze(defaultOptions);
|
|
28
|
+
const RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
29
|
+
const NORMAL_FLOW_ERRORS = new Set([
|
|
30
|
+
"ENOENT",
|
|
31
|
+
"EPERM",
|
|
32
|
+
"EACCES",
|
|
33
|
+
"ELOOP",
|
|
34
|
+
RECURSIVE_ERROR_CODE
|
|
35
|
+
]);
|
|
36
|
+
const ALL_TYPES = [
|
|
37
|
+
EntryTypes.DIR_TYPE,
|
|
38
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
39
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
40
|
+
EntryTypes.FILE_TYPE
|
|
41
|
+
];
|
|
42
|
+
const DIR_TYPES = new Set([
|
|
43
|
+
EntryTypes.DIR_TYPE,
|
|
44
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
45
|
+
EntryTypes.FILE_DIR_TYPE
|
|
46
|
+
]);
|
|
47
|
+
const FILE_TYPES = new Set([
|
|
48
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
49
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
50
|
+
EntryTypes.FILE_TYPE
|
|
51
|
+
]);
|
|
52
|
+
const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
|
53
|
+
const wantBigintFsStats = process.platform === "win32";
|
|
54
|
+
const emptyFn = (_entryInfo) => true;
|
|
55
|
+
const normalizeFilter = (filter) => {
|
|
56
|
+
if (filter === void 0) return emptyFn;
|
|
57
|
+
if (typeof filter === "function") return filter;
|
|
58
|
+
if (typeof filter === "string") {
|
|
59
|
+
const fl = filter.trim();
|
|
60
|
+
return (entry) => entry.basename === fl;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(filter)) {
|
|
63
|
+
const trItems = filter.map((item) => item.trim());
|
|
64
|
+
return (entry) => trItems.some((f) => entry.basename === f);
|
|
65
|
+
}
|
|
66
|
+
return emptyFn;
|
|
67
|
+
};
|
|
68
|
+
/** Readable readdir stream, emitting new files as they're being listed. */
|
|
69
|
+
var ReaddirpStream = class extends Readable {
|
|
70
|
+
constructor(options = {}) {
|
|
71
|
+
super({
|
|
72
|
+
objectMode: true,
|
|
73
|
+
autoDestroy: true,
|
|
74
|
+
highWaterMark: options.highWaterMark
|
|
75
|
+
});
|
|
76
|
+
const opts = {
|
|
77
|
+
...defaultOptions,
|
|
78
|
+
...options
|
|
79
|
+
};
|
|
80
|
+
const { root, type: type$1 } = opts;
|
|
81
|
+
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
82
|
+
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
83
|
+
const statMethod = opts.lstat ? lstat : stat;
|
|
84
|
+
if (wantBigintFsStats) this._stat = (path$2) => statMethod(path$2, { bigint: true });
|
|
85
|
+
else this._stat = statMethod;
|
|
86
|
+
this._maxDepth = opts.depth ?? defaultOptions.depth;
|
|
87
|
+
this._wantsDir = type$1 ? DIR_TYPES.has(type$1) : false;
|
|
88
|
+
this._wantsFile = type$1 ? FILE_TYPES.has(type$1) : false;
|
|
89
|
+
this._wantsEverything = type$1 === EntryTypes.EVERYTHING_TYPE;
|
|
90
|
+
this._root = resolve(root);
|
|
91
|
+
this._isDirent = !opts.alwaysStat;
|
|
92
|
+
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
93
|
+
this._rdOptions = {
|
|
94
|
+
encoding: "utf8",
|
|
95
|
+
withFileTypes: this._isDirent
|
|
96
|
+
};
|
|
97
|
+
this.parents = [this._exploreDir(root, 1)];
|
|
98
|
+
this.reading = false;
|
|
99
|
+
this.parent = void 0;
|
|
100
|
+
}
|
|
101
|
+
async _read(batch) {
|
|
102
|
+
if (this.reading) return;
|
|
103
|
+
this.reading = true;
|
|
104
|
+
try {
|
|
105
|
+
while (!this.destroyed && batch > 0) {
|
|
106
|
+
const par = this.parent;
|
|
107
|
+
const fil = par && par.files;
|
|
108
|
+
if (fil && fil.length > 0) {
|
|
109
|
+
const { path: path$2, depth } = par;
|
|
110
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path$2));
|
|
111
|
+
const awaited = await Promise.all(slice);
|
|
112
|
+
for (const entry of awaited) {
|
|
113
|
+
if (!entry) continue;
|
|
114
|
+
if (this.destroyed) return;
|
|
115
|
+
const entryType = await this._getEntryType(entry);
|
|
116
|
+
if (entryType === "directory" && this._directoryFilter(entry)) {
|
|
117
|
+
if (depth <= this._maxDepth) this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
|
118
|
+
if (this._wantsDir) {
|
|
119
|
+
this.push(entry);
|
|
120
|
+
batch--;
|
|
121
|
+
}
|
|
122
|
+
} else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
|
|
123
|
+
if (this._wantsFile) {
|
|
124
|
+
this.push(entry);
|
|
125
|
+
batch--;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
const parent = this.parents.pop();
|
|
131
|
+
if (!parent) {
|
|
132
|
+
this.push(null);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
this.parent = await parent;
|
|
136
|
+
if (this.destroyed) return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} catch (error) {
|
|
140
|
+
this.destroy(error);
|
|
141
|
+
} finally {
|
|
142
|
+
this.reading = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async _exploreDir(path$2, depth) {
|
|
146
|
+
let files;
|
|
147
|
+
try {
|
|
148
|
+
files = await readdir(path$2, this._rdOptions);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
this._onError(error);
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
files,
|
|
154
|
+
depth,
|
|
155
|
+
path: path$2
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async _formatEntry(dirent, path$2) {
|
|
159
|
+
let entry;
|
|
160
|
+
const basename$2 = this._isDirent ? dirent.name : dirent;
|
|
161
|
+
try {
|
|
162
|
+
const fullPath = resolve(join(path$2, basename$2));
|
|
163
|
+
entry = {
|
|
164
|
+
path: relative(this._root, fullPath),
|
|
165
|
+
fullPath,
|
|
166
|
+
basename: basename$2
|
|
167
|
+
};
|
|
168
|
+
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
this._onError(err);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
return entry;
|
|
174
|
+
}
|
|
175
|
+
_onError(err) {
|
|
176
|
+
if (isNormalFlowError(err) && !this.destroyed) this.emit("warn", err);
|
|
177
|
+
else this.destroy(err);
|
|
178
|
+
}
|
|
179
|
+
async _getEntryType(entry) {
|
|
180
|
+
if (!entry && this._statsProp in entry) return "";
|
|
181
|
+
const stats = entry[this._statsProp];
|
|
182
|
+
if (stats.isFile()) return "file";
|
|
183
|
+
if (stats.isDirectory()) return "directory";
|
|
184
|
+
if (stats && stats.isSymbolicLink()) {
|
|
185
|
+
const full = entry.fullPath;
|
|
186
|
+
try {
|
|
187
|
+
const entryRealPath = await realpath(full);
|
|
188
|
+
const entryRealPathStats = await lstat(entryRealPath);
|
|
189
|
+
if (entryRealPathStats.isFile()) return "file";
|
|
190
|
+
if (entryRealPathStats.isDirectory()) {
|
|
191
|
+
const len = entryRealPath.length;
|
|
192
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sep) {
|
|
193
|
+
const recursiveError = /* @__PURE__ */ new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
194
|
+
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
195
|
+
return this._onError(recursiveError);
|
|
196
|
+
}
|
|
197
|
+
return "directory";
|
|
198
|
+
}
|
|
199
|
+
} catch (error) {
|
|
200
|
+
this._onError(error);
|
|
201
|
+
return "";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_includeAsFile(entry) {
|
|
206
|
+
const stats = entry && entry[this._statsProp];
|
|
207
|
+
return stats && this._wantsEverything && !stats.isDirectory();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Streaming version: Reads all files and directories in given root recursively.
|
|
212
|
+
* Consumes ~constant small amount of RAM.
|
|
213
|
+
* @param root Root directory
|
|
214
|
+
* @param options Options to specify root (start directory), filters and recursion depth
|
|
215
|
+
*/
|
|
216
|
+
function readdirp(root, options = {}) {
|
|
217
|
+
let type$1 = options.entryType || options.type;
|
|
218
|
+
if (type$1 === "both") type$1 = EntryTypes.FILE_DIR_TYPE;
|
|
219
|
+
if (type$1) options.type = type$1;
|
|
220
|
+
if (!root) throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
221
|
+
else if (typeof root !== "string") throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
222
|
+
else if (type$1 && !ALL_TYPES.includes(type$1)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
223
|
+
options.root = root;
|
|
224
|
+
return new ReaddirpStream(options);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
|
|
229
|
+
const STR_DATA = "data";
|
|
230
|
+
const STR_END = "end";
|
|
231
|
+
const STR_CLOSE = "close";
|
|
232
|
+
const EMPTY_FN = () => {};
|
|
233
|
+
const pl = process.platform;
|
|
234
|
+
const isWindows = pl === "win32";
|
|
235
|
+
const isMacos = pl === "darwin";
|
|
236
|
+
const isLinux = pl === "linux";
|
|
237
|
+
const isFreeBSD = pl === "freebsd";
|
|
238
|
+
const isIBMi = type() === "OS400";
|
|
239
|
+
const EVENTS = {
|
|
240
|
+
ALL: "all",
|
|
241
|
+
READY: "ready",
|
|
242
|
+
ADD: "add",
|
|
243
|
+
CHANGE: "change",
|
|
244
|
+
ADD_DIR: "addDir",
|
|
245
|
+
UNLINK: "unlink",
|
|
246
|
+
UNLINK_DIR: "unlinkDir",
|
|
247
|
+
RAW: "raw",
|
|
248
|
+
ERROR: "error"
|
|
249
|
+
};
|
|
250
|
+
const EV = EVENTS;
|
|
251
|
+
const THROTTLE_MODE_WATCH = "watch";
|
|
252
|
+
const statMethods = {
|
|
253
|
+
lstat: lstat$1,
|
|
254
|
+
stat: stat$2
|
|
255
|
+
};
|
|
256
|
+
const KEY_LISTENERS = "listeners";
|
|
257
|
+
const KEY_ERR = "errHandlers";
|
|
258
|
+
const KEY_RAW = "rawEmitters";
|
|
259
|
+
const HANDLER_KEYS = [
|
|
260
|
+
KEY_LISTENERS,
|
|
261
|
+
KEY_ERR,
|
|
262
|
+
KEY_RAW
|
|
263
|
+
];
|
|
264
|
+
const binaryExtensions = new Set([
|
|
265
|
+
"3dm",
|
|
266
|
+
"3ds",
|
|
267
|
+
"3g2",
|
|
268
|
+
"3gp",
|
|
269
|
+
"7z",
|
|
270
|
+
"a",
|
|
271
|
+
"aac",
|
|
272
|
+
"adp",
|
|
273
|
+
"afdesign",
|
|
274
|
+
"afphoto",
|
|
275
|
+
"afpub",
|
|
276
|
+
"ai",
|
|
277
|
+
"aif",
|
|
278
|
+
"aiff",
|
|
279
|
+
"alz",
|
|
280
|
+
"ape",
|
|
281
|
+
"apk",
|
|
282
|
+
"appimage",
|
|
283
|
+
"ar",
|
|
284
|
+
"arj",
|
|
285
|
+
"asf",
|
|
286
|
+
"au",
|
|
287
|
+
"avi",
|
|
288
|
+
"bak",
|
|
289
|
+
"baml",
|
|
290
|
+
"bh",
|
|
291
|
+
"bin",
|
|
292
|
+
"bk",
|
|
293
|
+
"bmp",
|
|
294
|
+
"btif",
|
|
295
|
+
"bz2",
|
|
296
|
+
"bzip2",
|
|
297
|
+
"cab",
|
|
298
|
+
"caf",
|
|
299
|
+
"cgm",
|
|
300
|
+
"class",
|
|
301
|
+
"cmx",
|
|
302
|
+
"cpio",
|
|
303
|
+
"cr2",
|
|
304
|
+
"cur",
|
|
305
|
+
"dat",
|
|
306
|
+
"dcm",
|
|
307
|
+
"deb",
|
|
308
|
+
"dex",
|
|
309
|
+
"djvu",
|
|
310
|
+
"dll",
|
|
311
|
+
"dmg",
|
|
312
|
+
"dng",
|
|
313
|
+
"doc",
|
|
314
|
+
"docm",
|
|
315
|
+
"docx",
|
|
316
|
+
"dot",
|
|
317
|
+
"dotm",
|
|
318
|
+
"dra",
|
|
319
|
+
"DS_Store",
|
|
320
|
+
"dsk",
|
|
321
|
+
"dts",
|
|
322
|
+
"dtshd",
|
|
323
|
+
"dvb",
|
|
324
|
+
"dwg",
|
|
325
|
+
"dxf",
|
|
326
|
+
"ecelp4800",
|
|
327
|
+
"ecelp7470",
|
|
328
|
+
"ecelp9600",
|
|
329
|
+
"egg",
|
|
330
|
+
"eol",
|
|
331
|
+
"eot",
|
|
332
|
+
"epub",
|
|
333
|
+
"exe",
|
|
334
|
+
"f4v",
|
|
335
|
+
"fbs",
|
|
336
|
+
"fh",
|
|
337
|
+
"fla",
|
|
338
|
+
"flac",
|
|
339
|
+
"flatpak",
|
|
340
|
+
"fli",
|
|
341
|
+
"flv",
|
|
342
|
+
"fpx",
|
|
343
|
+
"fst",
|
|
344
|
+
"fvt",
|
|
345
|
+
"g3",
|
|
346
|
+
"gh",
|
|
347
|
+
"gif",
|
|
348
|
+
"graffle",
|
|
349
|
+
"gz",
|
|
350
|
+
"gzip",
|
|
351
|
+
"h261",
|
|
352
|
+
"h263",
|
|
353
|
+
"h264",
|
|
354
|
+
"icns",
|
|
355
|
+
"ico",
|
|
356
|
+
"ief",
|
|
357
|
+
"img",
|
|
358
|
+
"ipa",
|
|
359
|
+
"iso",
|
|
360
|
+
"jar",
|
|
361
|
+
"jpeg",
|
|
362
|
+
"jpg",
|
|
363
|
+
"jpgv",
|
|
364
|
+
"jpm",
|
|
365
|
+
"jxr",
|
|
366
|
+
"key",
|
|
367
|
+
"ktx",
|
|
368
|
+
"lha",
|
|
369
|
+
"lib",
|
|
370
|
+
"lvp",
|
|
371
|
+
"lz",
|
|
372
|
+
"lzh",
|
|
373
|
+
"lzma",
|
|
374
|
+
"lzo",
|
|
375
|
+
"m3u",
|
|
376
|
+
"m4a",
|
|
377
|
+
"m4v",
|
|
378
|
+
"mar",
|
|
379
|
+
"mdi",
|
|
380
|
+
"mht",
|
|
381
|
+
"mid",
|
|
382
|
+
"midi",
|
|
383
|
+
"mj2",
|
|
384
|
+
"mka",
|
|
385
|
+
"mkv",
|
|
386
|
+
"mmr",
|
|
387
|
+
"mng",
|
|
388
|
+
"mobi",
|
|
389
|
+
"mov",
|
|
390
|
+
"movie",
|
|
391
|
+
"mp3",
|
|
392
|
+
"mp4",
|
|
393
|
+
"mp4a",
|
|
394
|
+
"mpeg",
|
|
395
|
+
"mpg",
|
|
396
|
+
"mpga",
|
|
397
|
+
"mxu",
|
|
398
|
+
"nef",
|
|
399
|
+
"npx",
|
|
400
|
+
"numbers",
|
|
401
|
+
"nupkg",
|
|
402
|
+
"o",
|
|
403
|
+
"odp",
|
|
404
|
+
"ods",
|
|
405
|
+
"odt",
|
|
406
|
+
"oga",
|
|
407
|
+
"ogg",
|
|
408
|
+
"ogv",
|
|
409
|
+
"otf",
|
|
410
|
+
"ott",
|
|
411
|
+
"pages",
|
|
412
|
+
"pbm",
|
|
413
|
+
"pcx",
|
|
414
|
+
"pdb",
|
|
415
|
+
"pdf",
|
|
416
|
+
"pea",
|
|
417
|
+
"pgm",
|
|
418
|
+
"pic",
|
|
419
|
+
"png",
|
|
420
|
+
"pnm",
|
|
421
|
+
"pot",
|
|
422
|
+
"potm",
|
|
423
|
+
"potx",
|
|
424
|
+
"ppa",
|
|
425
|
+
"ppam",
|
|
426
|
+
"ppm",
|
|
427
|
+
"pps",
|
|
428
|
+
"ppsm",
|
|
429
|
+
"ppsx",
|
|
430
|
+
"ppt",
|
|
431
|
+
"pptm",
|
|
432
|
+
"pptx",
|
|
433
|
+
"psd",
|
|
434
|
+
"pya",
|
|
435
|
+
"pyc",
|
|
436
|
+
"pyo",
|
|
437
|
+
"pyv",
|
|
438
|
+
"qt",
|
|
439
|
+
"rar",
|
|
440
|
+
"ras",
|
|
441
|
+
"raw",
|
|
442
|
+
"resources",
|
|
443
|
+
"rgb",
|
|
444
|
+
"rip",
|
|
445
|
+
"rlc",
|
|
446
|
+
"rmf",
|
|
447
|
+
"rmvb",
|
|
448
|
+
"rpm",
|
|
449
|
+
"rtf",
|
|
450
|
+
"rz",
|
|
451
|
+
"s3m",
|
|
452
|
+
"s7z",
|
|
453
|
+
"scpt",
|
|
454
|
+
"sgi",
|
|
455
|
+
"shar",
|
|
456
|
+
"snap",
|
|
457
|
+
"sil",
|
|
458
|
+
"sketch",
|
|
459
|
+
"slk",
|
|
460
|
+
"smv",
|
|
461
|
+
"snk",
|
|
462
|
+
"so",
|
|
463
|
+
"stl",
|
|
464
|
+
"suo",
|
|
465
|
+
"sub",
|
|
466
|
+
"swf",
|
|
467
|
+
"tar",
|
|
468
|
+
"tbz",
|
|
469
|
+
"tbz2",
|
|
470
|
+
"tga",
|
|
471
|
+
"tgz",
|
|
472
|
+
"thmx",
|
|
473
|
+
"tif",
|
|
474
|
+
"tiff",
|
|
475
|
+
"tlz",
|
|
476
|
+
"ttc",
|
|
477
|
+
"ttf",
|
|
478
|
+
"txz",
|
|
479
|
+
"udf",
|
|
480
|
+
"uvh",
|
|
481
|
+
"uvi",
|
|
482
|
+
"uvm",
|
|
483
|
+
"uvp",
|
|
484
|
+
"uvs",
|
|
485
|
+
"uvu",
|
|
486
|
+
"viv",
|
|
487
|
+
"vob",
|
|
488
|
+
"war",
|
|
489
|
+
"wav",
|
|
490
|
+
"wax",
|
|
491
|
+
"wbmp",
|
|
492
|
+
"wdp",
|
|
493
|
+
"weba",
|
|
494
|
+
"webm",
|
|
495
|
+
"webp",
|
|
496
|
+
"whl",
|
|
497
|
+
"wim",
|
|
498
|
+
"wm",
|
|
499
|
+
"wma",
|
|
500
|
+
"wmv",
|
|
501
|
+
"wmx",
|
|
502
|
+
"woff",
|
|
503
|
+
"woff2",
|
|
504
|
+
"wrm",
|
|
505
|
+
"wvx",
|
|
506
|
+
"xbm",
|
|
507
|
+
"xif",
|
|
508
|
+
"xla",
|
|
509
|
+
"xlam",
|
|
510
|
+
"xls",
|
|
511
|
+
"xlsb",
|
|
512
|
+
"xlsm",
|
|
513
|
+
"xlsx",
|
|
514
|
+
"xlt",
|
|
515
|
+
"xltm",
|
|
516
|
+
"xltx",
|
|
517
|
+
"xm",
|
|
518
|
+
"xmind",
|
|
519
|
+
"xpi",
|
|
520
|
+
"xpm",
|
|
521
|
+
"xwd",
|
|
522
|
+
"xz",
|
|
523
|
+
"z",
|
|
524
|
+
"zip",
|
|
525
|
+
"zipx"
|
|
526
|
+
]);
|
|
527
|
+
const isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
|
|
528
|
+
const foreach = (val, fn) => {
|
|
529
|
+
if (val instanceof Set) val.forEach(fn);
|
|
530
|
+
else fn(val);
|
|
531
|
+
};
|
|
532
|
+
const addAndConvert = (main, prop, item) => {
|
|
533
|
+
let container = main[prop];
|
|
534
|
+
if (!(container instanceof Set)) main[prop] = container = new Set([container]);
|
|
535
|
+
container.add(item);
|
|
536
|
+
};
|
|
537
|
+
const clearItem = (cont) => (key) => {
|
|
538
|
+
const set = cont[key];
|
|
539
|
+
if (set instanceof Set) set.clear();
|
|
540
|
+
else delete cont[key];
|
|
541
|
+
};
|
|
542
|
+
const delFromSet = (main, prop, item) => {
|
|
543
|
+
const container = main[prop];
|
|
544
|
+
if (container instanceof Set) container.delete(item);
|
|
545
|
+
else if (container === item) delete main[prop];
|
|
546
|
+
};
|
|
547
|
+
const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
548
|
+
const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
549
|
+
/**
|
|
550
|
+
* Instantiates the fs_watch interface
|
|
551
|
+
* @param path to be watched
|
|
552
|
+
* @param options to be passed to fs_watch
|
|
553
|
+
* @param listener main event handler
|
|
554
|
+
* @param errHandler emits info about errors
|
|
555
|
+
* @param emitRaw emits raw event data
|
|
556
|
+
* @returns {NativeFsWatcher}
|
|
557
|
+
*/
|
|
558
|
+
function createFsWatchInstance(path$2, options, listener, errHandler, emitRaw) {
|
|
559
|
+
const handleEvent = (rawEvent, evPath) => {
|
|
560
|
+
listener(path$2);
|
|
561
|
+
emitRaw(rawEvent, evPath, { watchedPath: path$2 });
|
|
562
|
+
if (evPath && path$2 !== evPath) fsWatchBroadcast(sysPath.resolve(path$2, evPath), KEY_LISTENERS, sysPath.join(path$2, evPath));
|
|
563
|
+
};
|
|
564
|
+
try {
|
|
565
|
+
return watch(path$2, { persistent: options.persistent }, handleEvent);
|
|
566
|
+
} catch (error) {
|
|
567
|
+
errHandler(error);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Helper for passing fs_watch event data to a collection of listeners
|
|
573
|
+
* @param fullPath absolute path bound to fs_watch instance
|
|
574
|
+
*/
|
|
575
|
+
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
576
|
+
const cont = FsWatchInstances.get(fullPath);
|
|
577
|
+
if (!cont) return;
|
|
578
|
+
foreach(cont[listenerType], (listener) => {
|
|
579
|
+
listener(val1, val2, val3);
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* Instantiates the fs_watch interface or binds listeners
|
|
584
|
+
* to an existing one covering the same file system entry
|
|
585
|
+
* @param path
|
|
586
|
+
* @param fullPath absolute path
|
|
587
|
+
* @param options to be passed to fs_watch
|
|
588
|
+
* @param handlers container for event listener functions
|
|
589
|
+
*/
|
|
590
|
+
const setFsWatchListener = (path$2, fullPath, options, handlers) => {
|
|
591
|
+
const { listener, errHandler, rawEmitter } = handlers;
|
|
592
|
+
let cont = FsWatchInstances.get(fullPath);
|
|
593
|
+
let watcher;
|
|
594
|
+
if (!options.persistent) {
|
|
595
|
+
watcher = createFsWatchInstance(path$2, options, listener, errHandler, rawEmitter);
|
|
596
|
+
if (!watcher) return;
|
|
597
|
+
return watcher.close.bind(watcher);
|
|
598
|
+
}
|
|
599
|
+
if (cont) {
|
|
600
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
601
|
+
addAndConvert(cont, KEY_ERR, errHandler);
|
|
602
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
603
|
+
} else {
|
|
604
|
+
watcher = createFsWatchInstance(path$2, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
605
|
+
if (!watcher) return;
|
|
606
|
+
watcher.on(EV.ERROR, async (error) => {
|
|
607
|
+
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
608
|
+
if (cont) cont.watcherUnusable = true;
|
|
609
|
+
if (isWindows && error.code === "EPERM") try {
|
|
610
|
+
await (await open(path$2, "r")).close();
|
|
611
|
+
broadcastErr(error);
|
|
612
|
+
} catch (err) {}
|
|
613
|
+
else broadcastErr(error);
|
|
614
|
+
});
|
|
615
|
+
cont = {
|
|
616
|
+
listeners: listener,
|
|
617
|
+
errHandlers: errHandler,
|
|
618
|
+
rawEmitters: rawEmitter,
|
|
619
|
+
watcher
|
|
620
|
+
};
|
|
621
|
+
FsWatchInstances.set(fullPath, cont);
|
|
622
|
+
}
|
|
623
|
+
return () => {
|
|
624
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
625
|
+
delFromSet(cont, KEY_ERR, errHandler);
|
|
626
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
627
|
+
if (isEmptySet(cont.listeners)) {
|
|
628
|
+
cont.watcher.close();
|
|
629
|
+
FsWatchInstances.delete(fullPath);
|
|
630
|
+
HANDLER_KEYS.forEach(clearItem(cont));
|
|
631
|
+
cont.watcher = void 0;
|
|
632
|
+
Object.freeze(cont);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
};
|
|
636
|
+
const FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
637
|
+
/**
|
|
638
|
+
* Instantiates the fs_watchFile interface or binds listeners
|
|
639
|
+
* to an existing one covering the same file system entry
|
|
640
|
+
* @param path to be watched
|
|
641
|
+
* @param fullPath absolute path
|
|
642
|
+
* @param options options to be passed to fs_watchFile
|
|
643
|
+
* @param handlers container for event listener functions
|
|
644
|
+
* @returns closer
|
|
645
|
+
*/
|
|
646
|
+
const setFsWatchFileListener = (path$2, fullPath, options, handlers) => {
|
|
647
|
+
const { listener, rawEmitter } = handlers;
|
|
648
|
+
let cont = FsWatchFileInstances.get(fullPath);
|
|
649
|
+
const copts = cont && cont.options;
|
|
650
|
+
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
651
|
+
unwatchFile(fullPath);
|
|
652
|
+
cont = void 0;
|
|
653
|
+
}
|
|
654
|
+
if (cont) {
|
|
655
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
656
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
657
|
+
} else {
|
|
658
|
+
cont = {
|
|
659
|
+
listeners: listener,
|
|
660
|
+
rawEmitters: rawEmitter,
|
|
661
|
+
options,
|
|
662
|
+
watcher: watchFile(fullPath, options, (curr, prev) => {
|
|
663
|
+
foreach(cont.rawEmitters, (rawEmitter$1) => {
|
|
664
|
+
rawEmitter$1(EV.CHANGE, fullPath, {
|
|
665
|
+
curr,
|
|
666
|
+
prev
|
|
667
|
+
});
|
|
668
|
+
});
|
|
669
|
+
const currmtime = curr.mtimeMs;
|
|
670
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener$1) => listener$1(path$2, curr));
|
|
671
|
+
})
|
|
672
|
+
};
|
|
673
|
+
FsWatchFileInstances.set(fullPath, cont);
|
|
674
|
+
}
|
|
675
|
+
return () => {
|
|
676
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
677
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
678
|
+
if (isEmptySet(cont.listeners)) {
|
|
679
|
+
FsWatchFileInstances.delete(fullPath);
|
|
680
|
+
unwatchFile(fullPath);
|
|
681
|
+
cont.options = cont.watcher = void 0;
|
|
682
|
+
Object.freeze(cont);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
/**
|
|
687
|
+
* @mixin
|
|
688
|
+
*/
|
|
689
|
+
var NodeFsHandler = class {
|
|
690
|
+
constructor(fsW) {
|
|
691
|
+
this.fsw = fsW;
|
|
692
|
+
this._boundHandleError = (error) => fsW._handleError(error);
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Watch file for changes with fs_watchFile or fs_watch.
|
|
696
|
+
* @param path to file or dir
|
|
697
|
+
* @param listener on fs change
|
|
698
|
+
* @returns closer for the watcher instance
|
|
699
|
+
*/
|
|
700
|
+
_watchWithNodeFs(path$2, listener) {
|
|
701
|
+
const opts = this.fsw.options;
|
|
702
|
+
const directory = sysPath.dirname(path$2);
|
|
703
|
+
const basename$2 = sysPath.basename(path$2);
|
|
704
|
+
this.fsw._getWatchedDir(directory).add(basename$2);
|
|
705
|
+
const absolutePath = sysPath.resolve(path$2);
|
|
706
|
+
const options = { persistent: opts.persistent };
|
|
707
|
+
if (!listener) listener = EMPTY_FN;
|
|
708
|
+
let closer;
|
|
709
|
+
if (opts.usePolling) {
|
|
710
|
+
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename$2) ? opts.binaryInterval : opts.interval;
|
|
711
|
+
closer = setFsWatchFileListener(path$2, absolutePath, options, {
|
|
712
|
+
listener,
|
|
713
|
+
rawEmitter: this.fsw._emitRaw
|
|
714
|
+
});
|
|
715
|
+
} else closer = setFsWatchListener(path$2, absolutePath, options, {
|
|
716
|
+
listener,
|
|
717
|
+
errHandler: this._boundHandleError,
|
|
718
|
+
rawEmitter: this.fsw._emitRaw
|
|
719
|
+
});
|
|
720
|
+
return closer;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Watch a file and emit add event if warranted.
|
|
724
|
+
* @returns closer for the watcher instance
|
|
725
|
+
*/
|
|
726
|
+
_handleFile(file, stats, initialAdd) {
|
|
727
|
+
if (this.fsw.closed) return;
|
|
728
|
+
const dirname$2 = sysPath.dirname(file);
|
|
729
|
+
const basename$2 = sysPath.basename(file);
|
|
730
|
+
const parent = this.fsw._getWatchedDir(dirname$2);
|
|
731
|
+
let prevStats = stats;
|
|
732
|
+
if (parent.has(basename$2)) return;
|
|
733
|
+
const listener = async (path$2, newStats) => {
|
|
734
|
+
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
|
|
735
|
+
if (!newStats || newStats.mtimeMs === 0) try {
|
|
736
|
+
const newStats$1 = await stat$2(file);
|
|
737
|
+
if (this.fsw.closed) return;
|
|
738
|
+
const at = newStats$1.atimeMs;
|
|
739
|
+
const mt = newStats$1.mtimeMs;
|
|
740
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats$1);
|
|
741
|
+
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats$1.ino) {
|
|
742
|
+
this.fsw._closeFile(path$2);
|
|
743
|
+
prevStats = newStats$1;
|
|
744
|
+
const closer$1 = this._watchWithNodeFs(file, listener);
|
|
745
|
+
if (closer$1) this.fsw._addPathCloser(path$2, closer$1);
|
|
746
|
+
} else prevStats = newStats$1;
|
|
747
|
+
} catch (error) {
|
|
748
|
+
this.fsw._remove(dirname$2, basename$2);
|
|
749
|
+
}
|
|
750
|
+
else if (parent.has(basename$2)) {
|
|
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
|
+
prevStats = newStats;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
const closer = this._watchWithNodeFs(file, listener);
|
|
758
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
|
|
759
|
+
if (!this.fsw._throttle(EV.ADD, file, 0)) return;
|
|
760
|
+
this.fsw._emit(EV.ADD, file, stats);
|
|
761
|
+
}
|
|
762
|
+
return closer;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Handle symlinks encountered while reading a dir.
|
|
766
|
+
* @param entry returned by readdirp
|
|
767
|
+
* @param directory path of dir being read
|
|
768
|
+
* @param path of this item
|
|
769
|
+
* @param item basename of this item
|
|
770
|
+
* @returns true if no more processing is needed for this entry.
|
|
771
|
+
*/
|
|
772
|
+
async _handleSymlink(entry, directory, path$2, item) {
|
|
773
|
+
if (this.fsw.closed) return;
|
|
774
|
+
const full = entry.fullPath;
|
|
775
|
+
const dir = this.fsw._getWatchedDir(directory);
|
|
776
|
+
if (!this.fsw.options.followSymlinks) {
|
|
777
|
+
this.fsw._incrReadyCount();
|
|
778
|
+
let linkPath;
|
|
779
|
+
try {
|
|
780
|
+
linkPath = await realpath$1(path$2);
|
|
781
|
+
} catch (e) {
|
|
782
|
+
this.fsw._emitReady();
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
if (this.fsw.closed) return;
|
|
786
|
+
if (dir.has(item)) {
|
|
787
|
+
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
788
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
789
|
+
this.fsw._emit(EV.CHANGE, path$2, entry.stats);
|
|
790
|
+
}
|
|
791
|
+
} else {
|
|
792
|
+
dir.add(item);
|
|
793
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
794
|
+
this.fsw._emit(EV.ADD, path$2, entry.stats);
|
|
795
|
+
}
|
|
796
|
+
this.fsw._emitReady();
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
if (this.fsw._symlinkPaths.has(full)) return true;
|
|
800
|
+
this.fsw._symlinkPaths.set(full, true);
|
|
801
|
+
}
|
|
802
|
+
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
803
|
+
directory = sysPath.join(directory, "");
|
|
804
|
+
throttler = this.fsw._throttle("readdir", directory, 1e3);
|
|
805
|
+
if (!throttler) return;
|
|
806
|
+
const previous = this.fsw._getWatchedDir(wh.path);
|
|
807
|
+
const current = /* @__PURE__ */ new Set();
|
|
808
|
+
let stream = this.fsw._readdirp(directory, {
|
|
809
|
+
fileFilter: (entry) => wh.filterPath(entry),
|
|
810
|
+
directoryFilter: (entry) => wh.filterDir(entry)
|
|
811
|
+
});
|
|
812
|
+
if (!stream) return;
|
|
813
|
+
stream.on(STR_DATA, async (entry) => {
|
|
814
|
+
if (this.fsw.closed) {
|
|
815
|
+
stream = void 0;
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const item = entry.path;
|
|
819
|
+
let path$2 = sysPath.join(directory, item);
|
|
820
|
+
current.add(item);
|
|
821
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path$2, item)) return;
|
|
822
|
+
if (this.fsw.closed) {
|
|
823
|
+
stream = void 0;
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (item === target || !target && !previous.has(item)) {
|
|
827
|
+
this.fsw._incrReadyCount();
|
|
828
|
+
path$2 = sysPath.join(dir, sysPath.relative(dir, path$2));
|
|
829
|
+
this._addToNodeFs(path$2, initialAdd, wh, depth + 1);
|
|
830
|
+
}
|
|
831
|
+
}).on(EV.ERROR, this._boundHandleError);
|
|
832
|
+
return new Promise((resolve$2, reject) => {
|
|
833
|
+
if (!stream) return reject();
|
|
834
|
+
stream.once(STR_END, () => {
|
|
835
|
+
if (this.fsw.closed) {
|
|
836
|
+
stream = void 0;
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
const wasThrottled = throttler ? throttler.clear() : false;
|
|
840
|
+
resolve$2(void 0);
|
|
841
|
+
previous.getChildren().filter((item) => {
|
|
842
|
+
return item !== directory && !current.has(item);
|
|
843
|
+
}).forEach((item) => {
|
|
844
|
+
this.fsw._remove(directory, item);
|
|
845
|
+
});
|
|
846
|
+
stream = void 0;
|
|
847
|
+
if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
|
848
|
+
});
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
|
853
|
+
* @param dir fs path
|
|
854
|
+
* @param stats
|
|
855
|
+
* @param initialAdd
|
|
856
|
+
* @param depth relative to user-supplied path
|
|
857
|
+
* @param target child path targeted for watch
|
|
858
|
+
* @param wh Common watch helpers for this path
|
|
859
|
+
* @param realpath
|
|
860
|
+
* @returns closer for the watcher instance.
|
|
861
|
+
*/
|
|
862
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath$2) {
|
|
863
|
+
const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
|
|
864
|
+
const tracked = parentDir.has(sysPath.basename(dir));
|
|
865
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
866
|
+
parentDir.add(sysPath.basename(dir));
|
|
867
|
+
this.fsw._getWatchedDir(dir);
|
|
868
|
+
let throttler;
|
|
869
|
+
let closer;
|
|
870
|
+
const oDepth = this.fsw.options.depth;
|
|
871
|
+
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath$2)) {
|
|
872
|
+
if (!target) {
|
|
873
|
+
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
874
|
+
if (this.fsw.closed) return;
|
|
875
|
+
}
|
|
876
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats$1) => {
|
|
877
|
+
if (stats$1 && stats$1.mtimeMs === 0) return;
|
|
878
|
+
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
return closer;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Handle added file, directory, or glob pattern.
|
|
885
|
+
* Delegates call to _handleFile / _handleDir after checks.
|
|
886
|
+
* @param path to file or ir
|
|
887
|
+
* @param initialAdd was the file added at watch instantiation?
|
|
888
|
+
* @param priorWh depth relative to user-supplied path
|
|
889
|
+
* @param depth Child path actually targeted for watch
|
|
890
|
+
* @param target Child path actually targeted for watch
|
|
891
|
+
*/
|
|
892
|
+
async _addToNodeFs(path$2, initialAdd, priorWh, depth, target) {
|
|
893
|
+
const ready = this.fsw._emitReady;
|
|
894
|
+
if (this.fsw._isIgnored(path$2) || this.fsw.closed) {
|
|
895
|
+
ready();
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
const wh = this.fsw._getWatchHelpers(path$2);
|
|
899
|
+
if (priorWh) {
|
|
900
|
+
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
901
|
+
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
902
|
+
}
|
|
903
|
+
try {
|
|
904
|
+
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
|
905
|
+
if (this.fsw.closed) return;
|
|
906
|
+
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
|
907
|
+
ready();
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
const follow = this.fsw.options.followSymlinks;
|
|
911
|
+
let closer;
|
|
912
|
+
if (stats.isDirectory()) {
|
|
913
|
+
const absPath = sysPath.resolve(path$2);
|
|
914
|
+
const targetPath = follow ? await realpath$1(path$2) : path$2;
|
|
915
|
+
if (this.fsw.closed) return;
|
|
916
|
+
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
917
|
+
if (this.fsw.closed) return;
|
|
918
|
+
if (absPath !== targetPath && targetPath !== void 0) this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
919
|
+
} else if (stats.isSymbolicLink()) {
|
|
920
|
+
const targetPath = follow ? await realpath$1(path$2) : path$2;
|
|
921
|
+
if (this.fsw.closed) return;
|
|
922
|
+
const parent = sysPath.dirname(wh.watchPath);
|
|
923
|
+
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
924
|
+
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
925
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path$2, wh, targetPath);
|
|
926
|
+
if (this.fsw.closed) return;
|
|
927
|
+
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sysPath.resolve(path$2), targetPath);
|
|
928
|
+
} else closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
929
|
+
ready();
|
|
930
|
+
if (closer) this.fsw._addPathCloser(path$2, closer);
|
|
931
|
+
return false;
|
|
932
|
+
} catch (error) {
|
|
933
|
+
if (this.fsw._handleError(error)) {
|
|
934
|
+
ready();
|
|
935
|
+
return path$2;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
943
|
+
const SLASH = "/";
|
|
944
|
+
const SLASH_SLASH = "//";
|
|
945
|
+
const ONE_DOT = ".";
|
|
946
|
+
const TWO_DOTS = "..";
|
|
947
|
+
const STRING_TYPE = "string";
|
|
948
|
+
const BACK_SLASH_RE = /\\/g;
|
|
949
|
+
const DOUBLE_SLASH_RE = /\/\//;
|
|
950
|
+
const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
951
|
+
const REPLACER_RE = /^\.[/\\]/;
|
|
952
|
+
function arrify(item) {
|
|
953
|
+
return Array.isArray(item) ? item : [item];
|
|
954
|
+
}
|
|
955
|
+
const isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
|
|
956
|
+
function createPattern(matcher) {
|
|
957
|
+
if (typeof matcher === "function") return matcher;
|
|
958
|
+
if (typeof matcher === "string") return (string) => matcher === string;
|
|
959
|
+
if (matcher instanceof RegExp) return (string) => matcher.test(string);
|
|
960
|
+
if (typeof matcher === "object" && matcher !== null) return (string) => {
|
|
961
|
+
if (matcher.path === string) return true;
|
|
962
|
+
if (matcher.recursive) {
|
|
963
|
+
const relative$2 = sysPath.relative(matcher.path, string);
|
|
964
|
+
if (!relative$2) return false;
|
|
965
|
+
return !relative$2.startsWith("..") && !sysPath.isAbsolute(relative$2);
|
|
966
|
+
}
|
|
967
|
+
return false;
|
|
968
|
+
};
|
|
969
|
+
return () => false;
|
|
970
|
+
}
|
|
971
|
+
function normalizePath(path$2) {
|
|
972
|
+
if (typeof path$2 !== "string") throw new Error("string expected");
|
|
973
|
+
path$2 = sysPath.normalize(path$2);
|
|
974
|
+
path$2 = path$2.replace(/\\/g, "/");
|
|
975
|
+
let prepend = false;
|
|
976
|
+
if (path$2.startsWith("//")) prepend = true;
|
|
977
|
+
const DOUBLE_SLASH_RE$1 = /\/\//;
|
|
978
|
+
while (path$2.match(DOUBLE_SLASH_RE$1)) path$2 = path$2.replace(DOUBLE_SLASH_RE$1, "/");
|
|
979
|
+
if (prepend) path$2 = "/" + path$2;
|
|
980
|
+
return path$2;
|
|
981
|
+
}
|
|
982
|
+
function matchPatterns(patterns, testString, stats) {
|
|
983
|
+
const path$2 = normalizePath(testString);
|
|
984
|
+
for (let index = 0; index < patterns.length; index++) {
|
|
985
|
+
const pattern = patterns[index];
|
|
986
|
+
if (pattern(path$2, stats)) return true;
|
|
987
|
+
}
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
990
|
+
function anymatch(matchers, testString) {
|
|
991
|
+
if (matchers == null) throw new TypeError("anymatch: specify first argument");
|
|
992
|
+
const patterns = arrify(matchers).map((matcher) => createPattern(matcher));
|
|
993
|
+
if (testString == null) return (testString$1, stats) => {
|
|
994
|
+
return matchPatterns(patterns, testString$1, stats);
|
|
995
|
+
};
|
|
996
|
+
return matchPatterns(patterns, testString);
|
|
997
|
+
}
|
|
998
|
+
const unifyPaths = (paths_) => {
|
|
999
|
+
const paths = arrify(paths_).flat();
|
|
1000
|
+
if (!paths.every((p) => typeof p === STRING_TYPE)) throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
|
1001
|
+
return paths.map(normalizePathToUnix);
|
|
1002
|
+
};
|
|
1003
|
+
const toUnix = (string) => {
|
|
1004
|
+
let str = string.replace(BACK_SLASH_RE, SLASH);
|
|
1005
|
+
let prepend = false;
|
|
1006
|
+
if (str.startsWith(SLASH_SLASH)) prepend = true;
|
|
1007
|
+
while (str.match(DOUBLE_SLASH_RE)) str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
1008
|
+
if (prepend) str = SLASH + str;
|
|
1009
|
+
return str;
|
|
1010
|
+
};
|
|
1011
|
+
const normalizePathToUnix = (path$2) => toUnix(sysPath.normalize(toUnix(path$2)));
|
|
1012
|
+
const normalizeIgnored = (cwd = "") => (path$2) => {
|
|
1013
|
+
if (typeof path$2 === "string") return normalizePathToUnix(sysPath.isAbsolute(path$2) ? path$2 : sysPath.join(cwd, path$2));
|
|
1014
|
+
else return path$2;
|
|
1015
|
+
};
|
|
1016
|
+
const getAbsolutePath = (path$2, cwd) => {
|
|
1017
|
+
if (sysPath.isAbsolute(path$2)) return path$2;
|
|
1018
|
+
return sysPath.join(cwd, path$2);
|
|
1019
|
+
};
|
|
1020
|
+
const EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
1021
|
+
/**
|
|
1022
|
+
* Directory entry.
|
|
1023
|
+
*/
|
|
1024
|
+
var DirEntry = class {
|
|
1025
|
+
constructor(dir, removeWatcher) {
|
|
1026
|
+
this.path = dir;
|
|
1027
|
+
this._removeWatcher = removeWatcher;
|
|
1028
|
+
this.items = /* @__PURE__ */ new Set();
|
|
1029
|
+
}
|
|
1030
|
+
add(item) {
|
|
1031
|
+
const { items } = this;
|
|
1032
|
+
if (!items) return;
|
|
1033
|
+
if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item);
|
|
1034
|
+
}
|
|
1035
|
+
async remove(item) {
|
|
1036
|
+
const { items } = this;
|
|
1037
|
+
if (!items) return;
|
|
1038
|
+
items.delete(item);
|
|
1039
|
+
if (items.size > 0) return;
|
|
1040
|
+
const dir = this.path;
|
|
1041
|
+
try {
|
|
1042
|
+
await readdir$1(dir);
|
|
1043
|
+
} catch (err) {
|
|
1044
|
+
if (this._removeWatcher) this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
has(item) {
|
|
1048
|
+
const { items } = this;
|
|
1049
|
+
if (!items) return;
|
|
1050
|
+
return items.has(item);
|
|
1051
|
+
}
|
|
1052
|
+
getChildren() {
|
|
1053
|
+
const { items } = this;
|
|
1054
|
+
if (!items) return [];
|
|
1055
|
+
return [...items.values()];
|
|
1056
|
+
}
|
|
1057
|
+
dispose() {
|
|
1058
|
+
this.items.clear();
|
|
1059
|
+
this.path = "";
|
|
1060
|
+
this._removeWatcher = EMPTY_FN;
|
|
1061
|
+
this.items = EMPTY_SET;
|
|
1062
|
+
Object.freeze(this);
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
const STAT_METHOD_F = "stat";
|
|
1066
|
+
const STAT_METHOD_L = "lstat";
|
|
1067
|
+
var WatchHelper = class {
|
|
1068
|
+
constructor(path$2, follow, fsw) {
|
|
1069
|
+
this.fsw = fsw;
|
|
1070
|
+
const watchPath = path$2;
|
|
1071
|
+
this.path = path$2 = path$2.replace(REPLACER_RE, "");
|
|
1072
|
+
this.watchPath = watchPath;
|
|
1073
|
+
this.fullWatchPath = sysPath.resolve(watchPath);
|
|
1074
|
+
this.dirParts = [];
|
|
1075
|
+
this.dirParts.forEach((parts) => {
|
|
1076
|
+
if (parts.length > 1) parts.pop();
|
|
1077
|
+
});
|
|
1078
|
+
this.followSymlinks = follow;
|
|
1079
|
+
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
1080
|
+
}
|
|
1081
|
+
entryPath(entry) {
|
|
1082
|
+
return sysPath.join(this.watchPath, sysPath.relative(this.watchPath, entry.fullPath));
|
|
1083
|
+
}
|
|
1084
|
+
filterPath(entry) {
|
|
1085
|
+
const { stats } = entry;
|
|
1086
|
+
if (stats && stats.isSymbolicLink()) return this.filterDir(entry);
|
|
1087
|
+
const resolvedPath = this.entryPath(entry);
|
|
1088
|
+
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
|
1089
|
+
}
|
|
1090
|
+
filterDir(entry) {
|
|
1091
|
+
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* Watches files & directories for changes. Emitted events:
|
|
1096
|
+
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
|
1097
|
+
*
|
|
1098
|
+
* new FSWatcher()
|
|
1099
|
+
* .add(directories)
|
|
1100
|
+
* .on('add', path => log('File', path, 'was added'))
|
|
1101
|
+
*/
|
|
1102
|
+
var FSWatcher = class extends EventEmitter {
|
|
1103
|
+
constructor(_opts = {}) {
|
|
1104
|
+
super();
|
|
1105
|
+
this.closed = false;
|
|
1106
|
+
this._closers = /* @__PURE__ */ new Map();
|
|
1107
|
+
this._ignoredPaths = /* @__PURE__ */ new Set();
|
|
1108
|
+
this._throttled = /* @__PURE__ */ new Map();
|
|
1109
|
+
this._streams = /* @__PURE__ */ new Set();
|
|
1110
|
+
this._symlinkPaths = /* @__PURE__ */ new Map();
|
|
1111
|
+
this._watched = /* @__PURE__ */ new Map();
|
|
1112
|
+
this._pendingWrites = /* @__PURE__ */ new Map();
|
|
1113
|
+
this._pendingUnlinks = /* @__PURE__ */ new Map();
|
|
1114
|
+
this._readyCount = 0;
|
|
1115
|
+
this._readyEmitted = false;
|
|
1116
|
+
const awf = _opts.awaitWriteFinish;
|
|
1117
|
+
const DEF_AWF = {
|
|
1118
|
+
stabilityThreshold: 2e3,
|
|
1119
|
+
pollInterval: 100
|
|
1120
|
+
};
|
|
1121
|
+
const opts = {
|
|
1122
|
+
persistent: true,
|
|
1123
|
+
ignoreInitial: false,
|
|
1124
|
+
ignorePermissionErrors: false,
|
|
1125
|
+
interval: 100,
|
|
1126
|
+
binaryInterval: 300,
|
|
1127
|
+
followSymlinks: true,
|
|
1128
|
+
usePolling: false,
|
|
1129
|
+
atomic: true,
|
|
1130
|
+
..._opts,
|
|
1131
|
+
ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
|
|
1132
|
+
awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? {
|
|
1133
|
+
...DEF_AWF,
|
|
1134
|
+
...awf
|
|
1135
|
+
} : false
|
|
1136
|
+
};
|
|
1137
|
+
if (isIBMi) opts.usePolling = true;
|
|
1138
|
+
if (opts.atomic === void 0) opts.atomic = !opts.usePolling;
|
|
1139
|
+
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
|
1140
|
+
if (envPoll !== void 0) {
|
|
1141
|
+
const envLower = envPoll.toLowerCase();
|
|
1142
|
+
if (envLower === "false" || envLower === "0") opts.usePolling = false;
|
|
1143
|
+
else if (envLower === "true" || envLower === "1") opts.usePolling = true;
|
|
1144
|
+
else opts.usePolling = !!envLower;
|
|
1145
|
+
}
|
|
1146
|
+
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
|
1147
|
+
if (envInterval) opts.interval = Number.parseInt(envInterval, 10);
|
|
1148
|
+
let readyCalls = 0;
|
|
1149
|
+
this._emitReady = () => {
|
|
1150
|
+
readyCalls++;
|
|
1151
|
+
if (readyCalls >= this._readyCount) {
|
|
1152
|
+
this._emitReady = EMPTY_FN;
|
|
1153
|
+
this._readyEmitted = true;
|
|
1154
|
+
process.nextTick(() => this.emit(EVENTS.READY));
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
|
|
1158
|
+
this._boundRemove = this._remove.bind(this);
|
|
1159
|
+
this.options = opts;
|
|
1160
|
+
this._nodeFsHandler = new NodeFsHandler(this);
|
|
1161
|
+
Object.freeze(opts);
|
|
1162
|
+
}
|
|
1163
|
+
_addIgnoredPath(matcher) {
|
|
1164
|
+
if (isMatcherObject(matcher)) {
|
|
1165
|
+
for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) return;
|
|
1166
|
+
}
|
|
1167
|
+
this._ignoredPaths.add(matcher);
|
|
1168
|
+
}
|
|
1169
|
+
_removeIgnoredPath(matcher) {
|
|
1170
|
+
this._ignoredPaths.delete(matcher);
|
|
1171
|
+
if (typeof matcher === "string") {
|
|
1172
|
+
for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher) this._ignoredPaths.delete(ignored);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Adds paths to be watched on an existing FSWatcher instance.
|
|
1177
|
+
* @param paths_ file or file list. Other arguments are unused
|
|
1178
|
+
*/
|
|
1179
|
+
add(paths_, _origAdd, _internal) {
|
|
1180
|
+
const { cwd } = this.options;
|
|
1181
|
+
this.closed = false;
|
|
1182
|
+
this._closePromise = void 0;
|
|
1183
|
+
let paths = unifyPaths(paths_);
|
|
1184
|
+
if (cwd) paths = paths.map((path$2) => {
|
|
1185
|
+
return getAbsolutePath(path$2, cwd);
|
|
1186
|
+
});
|
|
1187
|
+
paths.forEach((path$2) => {
|
|
1188
|
+
this._removeIgnoredPath(path$2);
|
|
1189
|
+
});
|
|
1190
|
+
this._userIgnored = void 0;
|
|
1191
|
+
if (!this._readyCount) this._readyCount = 0;
|
|
1192
|
+
this._readyCount += paths.length;
|
|
1193
|
+
Promise.all(paths.map(async (path$2) => {
|
|
1194
|
+
const res = await this._nodeFsHandler._addToNodeFs(path$2, !_internal, void 0, 0, _origAdd);
|
|
1195
|
+
if (res) this._emitReady();
|
|
1196
|
+
return res;
|
|
1197
|
+
})).then((results) => {
|
|
1198
|
+
if (this.closed) return;
|
|
1199
|
+
results.forEach((item) => {
|
|
1200
|
+
if (item) this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));
|
|
1201
|
+
});
|
|
1202
|
+
});
|
|
1203
|
+
return this;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Close watchers or start ignoring events from specified paths.
|
|
1207
|
+
*/
|
|
1208
|
+
unwatch(paths_) {
|
|
1209
|
+
if (this.closed) return this;
|
|
1210
|
+
const paths = unifyPaths(paths_);
|
|
1211
|
+
const { cwd } = this.options;
|
|
1212
|
+
paths.forEach((path$2) => {
|
|
1213
|
+
if (!sysPath.isAbsolute(path$2) && !this._closers.has(path$2)) {
|
|
1214
|
+
if (cwd) path$2 = sysPath.join(cwd, path$2);
|
|
1215
|
+
path$2 = sysPath.resolve(path$2);
|
|
1216
|
+
}
|
|
1217
|
+
this._closePath(path$2);
|
|
1218
|
+
this._addIgnoredPath(path$2);
|
|
1219
|
+
if (this._watched.has(path$2)) this._addIgnoredPath({
|
|
1220
|
+
path: path$2,
|
|
1221
|
+
recursive: true
|
|
1222
|
+
});
|
|
1223
|
+
this._userIgnored = void 0;
|
|
1224
|
+
});
|
|
1225
|
+
return this;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Close watchers and remove all listeners from watched paths.
|
|
1229
|
+
*/
|
|
1230
|
+
close() {
|
|
1231
|
+
if (this._closePromise) return this._closePromise;
|
|
1232
|
+
this.closed = true;
|
|
1233
|
+
this.removeAllListeners();
|
|
1234
|
+
const closers = [];
|
|
1235
|
+
this._closers.forEach((closerList) => closerList.forEach((closer) => {
|
|
1236
|
+
const promise = closer();
|
|
1237
|
+
if (promise instanceof Promise) closers.push(promise);
|
|
1238
|
+
}));
|
|
1239
|
+
this._streams.forEach((stream) => stream.destroy());
|
|
1240
|
+
this._userIgnored = void 0;
|
|
1241
|
+
this._readyCount = 0;
|
|
1242
|
+
this._readyEmitted = false;
|
|
1243
|
+
this._watched.forEach((dirent) => dirent.dispose());
|
|
1244
|
+
this._closers.clear();
|
|
1245
|
+
this._watched.clear();
|
|
1246
|
+
this._streams.clear();
|
|
1247
|
+
this._symlinkPaths.clear();
|
|
1248
|
+
this._throttled.clear();
|
|
1249
|
+
this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
|
|
1250
|
+
return this._closePromise;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Expose list of watched paths
|
|
1254
|
+
* @returns for chaining
|
|
1255
|
+
*/
|
|
1256
|
+
getWatched() {
|
|
1257
|
+
const watchList = {};
|
|
1258
|
+
this._watched.forEach((entry, dir) => {
|
|
1259
|
+
const index = (this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir) || ONE_DOT;
|
|
1260
|
+
watchList[index] = entry.getChildren().sort();
|
|
1261
|
+
});
|
|
1262
|
+
return watchList;
|
|
1263
|
+
}
|
|
1264
|
+
emitWithAll(event, args) {
|
|
1265
|
+
this.emit(event, ...args);
|
|
1266
|
+
if (event !== EVENTS.ERROR) this.emit(EVENTS.ALL, event, ...args);
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Normalize and emit events.
|
|
1270
|
+
* Calling _emit DOES NOT MEAN emit() would be called!
|
|
1271
|
+
* @param event Type of event
|
|
1272
|
+
* @param path File or directory path
|
|
1273
|
+
* @param stats arguments to be passed with event
|
|
1274
|
+
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1275
|
+
*/
|
|
1276
|
+
async _emit(event, path$2, stats) {
|
|
1277
|
+
if (this.closed) return;
|
|
1278
|
+
const opts = this.options;
|
|
1279
|
+
if (isWindows) path$2 = sysPath.normalize(path$2);
|
|
1280
|
+
if (opts.cwd) path$2 = sysPath.relative(opts.cwd, path$2);
|
|
1281
|
+
const args = [path$2];
|
|
1282
|
+
if (stats != null) args.push(stats);
|
|
1283
|
+
const awf = opts.awaitWriteFinish;
|
|
1284
|
+
let pw;
|
|
1285
|
+
if (awf && (pw = this._pendingWrites.get(path$2))) {
|
|
1286
|
+
pw.lastChange = /* @__PURE__ */ new Date();
|
|
1287
|
+
return this;
|
|
1288
|
+
}
|
|
1289
|
+
if (opts.atomic) {
|
|
1290
|
+
if (event === EVENTS.UNLINK) {
|
|
1291
|
+
this._pendingUnlinks.set(path$2, [event, ...args]);
|
|
1292
|
+
setTimeout(() => {
|
|
1293
|
+
this._pendingUnlinks.forEach((entry, path$3) => {
|
|
1294
|
+
this.emit(...entry);
|
|
1295
|
+
this.emit(EVENTS.ALL, ...entry);
|
|
1296
|
+
this._pendingUnlinks.delete(path$3);
|
|
1297
|
+
});
|
|
1298
|
+
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
1299
|
+
return this;
|
|
1300
|
+
}
|
|
1301
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path$2)) {
|
|
1302
|
+
event = EVENTS.CHANGE;
|
|
1303
|
+
this._pendingUnlinks.delete(path$2);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
1307
|
+
const awfEmit = (err, stats$1) => {
|
|
1308
|
+
if (err) {
|
|
1309
|
+
event = EVENTS.ERROR;
|
|
1310
|
+
args[0] = err;
|
|
1311
|
+
this.emitWithAll(event, args);
|
|
1312
|
+
} else if (stats$1) {
|
|
1313
|
+
if (args.length > 1) args[1] = stats$1;
|
|
1314
|
+
else args.push(stats$1);
|
|
1315
|
+
this.emitWithAll(event, args);
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
this._awaitWriteFinish(path$2, awf.stabilityThreshold, event, awfEmit);
|
|
1319
|
+
return this;
|
|
1320
|
+
}
|
|
1321
|
+
if (event === EVENTS.CHANGE) {
|
|
1322
|
+
if (!this._throttle(EVENTS.CHANGE, path$2, 50)) return this;
|
|
1323
|
+
}
|
|
1324
|
+
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
1325
|
+
const fullPath = opts.cwd ? sysPath.join(opts.cwd, path$2) : path$2;
|
|
1326
|
+
let stats$1;
|
|
1327
|
+
try {
|
|
1328
|
+
stats$1 = await stat$2(fullPath);
|
|
1329
|
+
} catch (err) {}
|
|
1330
|
+
if (!stats$1 || this.closed) return;
|
|
1331
|
+
args.push(stats$1);
|
|
1332
|
+
}
|
|
1333
|
+
this.emitWithAll(event, args);
|
|
1334
|
+
return this;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Common handler for errors
|
|
1338
|
+
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1339
|
+
*/
|
|
1340
|
+
_handleError(error) {
|
|
1341
|
+
const code = error && error.code;
|
|
1342
|
+
if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) this.emit(EVENTS.ERROR, error);
|
|
1343
|
+
return error || this.closed;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Helper utility for throttling
|
|
1347
|
+
* @param actionType type being throttled
|
|
1348
|
+
* @param path being acted upon
|
|
1349
|
+
* @param timeout duration of time to suppress duplicate actions
|
|
1350
|
+
* @returns tracking object or false if action should be suppressed
|
|
1351
|
+
*/
|
|
1352
|
+
_throttle(actionType, path$2, timeout) {
|
|
1353
|
+
if (!this._throttled.has(actionType)) this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
1354
|
+
const action = this._throttled.get(actionType);
|
|
1355
|
+
if (!action) throw new Error("invalid throttle");
|
|
1356
|
+
const actionPath = action.get(path$2);
|
|
1357
|
+
if (actionPath) {
|
|
1358
|
+
actionPath.count++;
|
|
1359
|
+
return false;
|
|
1360
|
+
}
|
|
1361
|
+
let timeoutObject;
|
|
1362
|
+
const clear = () => {
|
|
1363
|
+
const item = action.get(path$2);
|
|
1364
|
+
const count = item ? item.count : 0;
|
|
1365
|
+
action.delete(path$2);
|
|
1366
|
+
clearTimeout(timeoutObject);
|
|
1367
|
+
if (item) clearTimeout(item.timeoutObject);
|
|
1368
|
+
return count;
|
|
1369
|
+
};
|
|
1370
|
+
timeoutObject = setTimeout(clear, timeout);
|
|
1371
|
+
const thr = {
|
|
1372
|
+
timeoutObject,
|
|
1373
|
+
clear,
|
|
1374
|
+
count: 0
|
|
1375
|
+
};
|
|
1376
|
+
action.set(path$2, thr);
|
|
1377
|
+
return thr;
|
|
1378
|
+
}
|
|
1379
|
+
_incrReadyCount() {
|
|
1380
|
+
return this._readyCount++;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Awaits write operation to finish.
|
|
1384
|
+
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
|
1385
|
+
* @param path being acted upon
|
|
1386
|
+
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
|
1387
|
+
* @param event
|
|
1388
|
+
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
1389
|
+
*/
|
|
1390
|
+
_awaitWriteFinish(path$2, threshold, event, awfEmit) {
|
|
1391
|
+
const awf = this.options.awaitWriteFinish;
|
|
1392
|
+
if (typeof awf !== "object") return;
|
|
1393
|
+
const pollInterval = awf.pollInterval;
|
|
1394
|
+
let timeoutHandler;
|
|
1395
|
+
let fullPath = path$2;
|
|
1396
|
+
if (this.options.cwd && !sysPath.isAbsolute(path$2)) fullPath = sysPath.join(this.options.cwd, path$2);
|
|
1397
|
+
const now = /* @__PURE__ */ new Date();
|
|
1398
|
+
const writes = this._pendingWrites;
|
|
1399
|
+
function awaitWriteFinishFn(prevStat) {
|
|
1400
|
+
stat$1(fullPath, (err, curStat) => {
|
|
1401
|
+
if (err || !writes.has(path$2)) {
|
|
1402
|
+
if (err && err.code !== "ENOENT") awfEmit(err);
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
const now$1 = Number(/* @__PURE__ */ new Date());
|
|
1406
|
+
if (prevStat && curStat.size !== prevStat.size) writes.get(path$2).lastChange = now$1;
|
|
1407
|
+
if (now$1 - writes.get(path$2).lastChange >= threshold) {
|
|
1408
|
+
writes.delete(path$2);
|
|
1409
|
+
awfEmit(void 0, curStat);
|
|
1410
|
+
} else timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
if (!writes.has(path$2)) {
|
|
1414
|
+
writes.set(path$2, {
|
|
1415
|
+
lastChange: now,
|
|
1416
|
+
cancelWait: () => {
|
|
1417
|
+
writes.delete(path$2);
|
|
1418
|
+
clearTimeout(timeoutHandler);
|
|
1419
|
+
return event;
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Determines whether user has asked to ignore this path.
|
|
1427
|
+
*/
|
|
1428
|
+
_isIgnored(path$2, stats) {
|
|
1429
|
+
if (this.options.atomic && DOT_RE.test(path$2)) return true;
|
|
1430
|
+
if (!this._userIgnored) {
|
|
1431
|
+
const { cwd } = this.options;
|
|
1432
|
+
const ignored = (this.options.ignored || []).map(normalizeIgnored(cwd));
|
|
1433
|
+
this._userIgnored = anymatch([...[...this._ignoredPaths].map(normalizeIgnored(cwd)), ...ignored], void 0);
|
|
1434
|
+
}
|
|
1435
|
+
return this._userIgnored(path$2, stats);
|
|
1436
|
+
}
|
|
1437
|
+
_isntIgnored(path$2, stat$3) {
|
|
1438
|
+
return !this._isIgnored(path$2, stat$3);
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Provides a set of common helpers and properties relating to symlink handling.
|
|
1442
|
+
* @param path file or directory pattern being watched
|
|
1443
|
+
*/
|
|
1444
|
+
_getWatchHelpers(path$2) {
|
|
1445
|
+
return new WatchHelper(path$2, this.options.followSymlinks, this);
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Provides directory tracking objects
|
|
1449
|
+
* @param directory path of the directory
|
|
1450
|
+
*/
|
|
1451
|
+
_getWatchedDir(directory) {
|
|
1452
|
+
const dir = sysPath.resolve(directory);
|
|
1453
|
+
if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
1454
|
+
return this._watched.get(dir);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
|
1458
|
+
*/
|
|
1459
|
+
_hasReadPermissions(stats) {
|
|
1460
|
+
if (this.options.ignorePermissionErrors) return true;
|
|
1461
|
+
return Boolean(Number(stats.mode) & 256);
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Handles emitting unlink events for
|
|
1465
|
+
* files and directories, and via recursion, for
|
|
1466
|
+
* files and directories within directories that are unlinked
|
|
1467
|
+
* @param directory within which the following item is located
|
|
1468
|
+
* @param item base path of item/directory
|
|
1469
|
+
*/
|
|
1470
|
+
_remove(directory, item, isDirectory) {
|
|
1471
|
+
const path$2 = sysPath.join(directory, item);
|
|
1472
|
+
const fullPath = sysPath.resolve(path$2);
|
|
1473
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path$2) || this._watched.has(fullPath);
|
|
1474
|
+
if (!this._throttle("remove", path$2, 100)) return;
|
|
1475
|
+
if (!isDirectory && this._watched.size === 1) this.add(directory, item, true);
|
|
1476
|
+
this._getWatchedDir(path$2).getChildren().forEach((nested) => this._remove(path$2, nested));
|
|
1477
|
+
const parent = this._getWatchedDir(directory);
|
|
1478
|
+
const wasTracked = parent.has(item);
|
|
1479
|
+
parent.remove(item);
|
|
1480
|
+
if (this._symlinkPaths.has(fullPath)) this._symlinkPaths.delete(fullPath);
|
|
1481
|
+
let relPath = path$2;
|
|
1482
|
+
if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path$2);
|
|
1483
|
+
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1484
|
+
if (this._pendingWrites.get(relPath).cancelWait() === EVENTS.ADD) return;
|
|
1485
|
+
}
|
|
1486
|
+
this._watched.delete(path$2);
|
|
1487
|
+
this._watched.delete(fullPath);
|
|
1488
|
+
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
1489
|
+
if (wasTracked && !this._isIgnored(path$2)) this._emit(eventName, path$2);
|
|
1490
|
+
this._closePath(path$2);
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Closes all watchers for a path
|
|
1494
|
+
*/
|
|
1495
|
+
_closePath(path$2) {
|
|
1496
|
+
this._closeFile(path$2);
|
|
1497
|
+
const dir = sysPath.dirname(path$2);
|
|
1498
|
+
this._getWatchedDir(dir).remove(sysPath.basename(path$2));
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Closes only file-specific watchers
|
|
1502
|
+
*/
|
|
1503
|
+
_closeFile(path$2) {
|
|
1504
|
+
const closers = this._closers.get(path$2);
|
|
1505
|
+
if (!closers) return;
|
|
1506
|
+
closers.forEach((closer) => closer());
|
|
1507
|
+
this._closers.delete(path$2);
|
|
1508
|
+
}
|
|
1509
|
+
_addPathCloser(path$2, closer) {
|
|
1510
|
+
if (!closer) return;
|
|
1511
|
+
let list = this._closers.get(path$2);
|
|
1512
|
+
if (!list) {
|
|
1513
|
+
list = [];
|
|
1514
|
+
this._closers.set(path$2, list);
|
|
1515
|
+
}
|
|
1516
|
+
list.push(closer);
|
|
1517
|
+
}
|
|
1518
|
+
_readdirp(root, opts) {
|
|
1519
|
+
if (this.closed) return;
|
|
1520
|
+
let stream = readdirp(root, {
|
|
1521
|
+
type: EVENTS.ALL,
|
|
1522
|
+
alwaysStat: true,
|
|
1523
|
+
lstat: true,
|
|
1524
|
+
...opts,
|
|
1525
|
+
depth: 0
|
|
1526
|
+
});
|
|
1527
|
+
this._streams.add(stream);
|
|
1528
|
+
stream.once(STR_CLOSE, () => {
|
|
1529
|
+
stream = void 0;
|
|
1530
|
+
});
|
|
1531
|
+
stream.once(STR_END, () => {
|
|
1532
|
+
if (stream) {
|
|
1533
|
+
this._streams.delete(stream);
|
|
1534
|
+
stream = void 0;
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
return stream;
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
/**
|
|
1541
|
+
* Instantiates watcher with paths to be tracked.
|
|
1542
|
+
* @param paths file / directory paths
|
|
1543
|
+
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
|
1544
|
+
* @returns an instance of FSWatcher for chaining.
|
|
1545
|
+
* @example
|
|
1546
|
+
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
|
1547
|
+
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
|
1548
|
+
*/
|
|
1549
|
+
function watch$1(paths, options = {}) {
|
|
1550
|
+
const watcher = new FSWatcher(options);
|
|
1551
|
+
watcher.add(paths);
|
|
1552
|
+
return watcher;
|
|
1553
|
+
}
|
|
1554
|
+
var esm_default = {
|
|
1555
|
+
watch: watch$1,
|
|
1556
|
+
FSWatcher
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
//#endregion
|
|
1560
|
+
export { watch$1 as i, WatchHelper as n, esm_default as r, FSWatcher as t };
|