@logtape/file 1.4.0-dev.444 → 1.4.0-dev.446

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/filesink.base.d.cts +1 -1
  2. package/dist/filesink.base.d.ts +1 -1
  3. package/dist/filesink.deno.cjs +46 -1
  4. package/dist/filesink.deno.d.cts +31 -1
  5. package/dist/filesink.deno.d.cts.map +1 -1
  6. package/dist/filesink.deno.d.ts +31 -1
  7. package/dist/filesink.deno.d.ts.map +1 -1
  8. package/dist/filesink.deno.js +43 -1
  9. package/dist/filesink.deno.js.map +1 -1
  10. package/dist/filesink.node.cjs +38 -1
  11. package/dist/filesink.node.d.cts +31 -1
  12. package/dist/filesink.node.d.cts.map +1 -1
  13. package/dist/filesink.node.d.ts +31 -1
  14. package/dist/filesink.node.d.ts.map +1 -1
  15. package/dist/filesink.node.js +35 -1
  16. package/dist/filesink.node.js.map +1 -1
  17. package/dist/mod.cjs +7 -1
  18. package/dist/mod.d.cts +3 -2
  19. package/dist/mod.d.ts +3 -2
  20. package/dist/mod.js +2 -2
  21. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/assert_path.cjs +8 -0
  22. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/assert_path.js +8 -0
  23. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/assert_path.js.map +1 -0
  24. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/constants.cjs +20 -0
  25. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/constants.js +13 -0
  26. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/constants.js.map +1 -0
  27. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/from_file_url.cjs +10 -0
  28. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/from_file_url.js +10 -0
  29. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/from_file_url.js.map +1 -0
  30. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize.cjs +10 -0
  31. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize.js +11 -0
  32. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize.js.map +1 -0
  33. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize_string.cjs +56 -0
  34. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize_string.js +57 -0
  35. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_common/normalize_string.js.map +1 -0
  36. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_os.cjs +6 -0
  37. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_os.js +6 -0
  38. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/_os.js.map +1 -0
  39. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/join.cjs +31 -0
  40. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/join.js +32 -0
  41. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/join.js.map +1 -0
  42. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/_util.cjs +9 -0
  43. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/_util.js +10 -0
  44. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/_util.js.map +1 -0
  45. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/from_file_url.cjs +23 -0
  46. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/from_file_url.js +24 -0
  47. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/from_file_url.js.map +1 -0
  48. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/join.cjs +44 -0
  49. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/join.js +45 -0
  50. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/join.js.map +1 -0
  51. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/normalize.cjs +54 -0
  52. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/normalize.js +55 -0
  53. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/posix/normalize.js.map +1 -0
  54. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.cjs +13 -0
  55. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.js +13 -0
  56. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.js.map +1 -0
  57. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.cjs +27 -0
  58. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.js +28 -0
  59. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.js.map +1 -0
  60. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/join.cjs +51 -0
  61. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/join.js +52 -0
  62. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/join.js.map +1 -0
  63. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.cjs +82 -0
  64. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.js +83 -0
  65. package/dist/node_modules/.pnpm/@jsr_std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.js.map +1 -0
  66. package/dist/timefilesink.cjs +208 -0
  67. package/dist/timefilesink.d.cts +104 -0
  68. package/dist/timefilesink.d.cts.map +1 -0
  69. package/dist/timefilesink.d.ts +104 -0
  70. package/dist/timefilesink.d.ts.map +1 -0
  71. package/dist/timefilesink.js +208 -0
  72. package/dist/timefilesink.js.map +1 -0
  73. package/package.json +2 -2
@@ -0,0 +1,13 @@
1
+ const require_constants = require('../_common/constants.cjs');
2
+
3
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.js
4
+ function isPathSeparator(code) {
5
+ return code === require_constants.CHAR_FORWARD_SLASH || code === require_constants.CHAR_BACKWARD_SLASH;
6
+ }
7
+ function isWindowsDeviceRoot(code) {
8
+ return code >= require_constants.CHAR_LOWERCASE_A && code <= require_constants.CHAR_LOWERCASE_Z || code >= require_constants.CHAR_UPPERCASE_A && code <= require_constants.CHAR_UPPERCASE_Z;
9
+ }
10
+
11
+ //#endregion
12
+ exports.isPathSeparator = isPathSeparator;
13
+ exports.isWindowsDeviceRoot = isWindowsDeviceRoot;
@@ -0,0 +1,13 @@
1
+ import { CHAR_BACKWARD_SLASH, CHAR_FORWARD_SLASH, CHAR_LOWERCASE_A, CHAR_LOWERCASE_Z, CHAR_UPPERCASE_A, CHAR_UPPERCASE_Z } from "../_common/constants.js";
2
+
3
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.js
4
+ function isPathSeparator(code) {
5
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
6
+ }
7
+ function isWindowsDeviceRoot(code) {
8
+ return code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z || code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z;
9
+ }
10
+
11
+ //#endregion
12
+ export { isPathSeparator, isWindowsDeviceRoot };
13
+ //# sourceMappingURL=_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_util.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/_util.js"],"sourcesContent":["// Copyright 2018-2025 the Deno authors. MIT license.\n// Copyright the Browserify authors. MIT License.\n// Ported from https://github.com/browserify/path-browserify/\n// This module is browser compatible.\nimport { CHAR_BACKWARD_SLASH, CHAR_FORWARD_SLASH, CHAR_LOWERCASE_A, CHAR_LOWERCASE_Z, CHAR_UPPERCASE_A, CHAR_UPPERCASE_Z } from \"../_common/constants.js\";\nexport function isPosixPathSeparator(code) {\n return code === CHAR_FORWARD_SLASH;\n}\nexport function isPathSeparator(code) {\n return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;\n}\nexport function isWindowsDeviceRoot(code) {\n return code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z || code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z;\n}\n//# sourceMappingURL=_util.js.map"],"x_google_ignoreList":[0],"mappings":";;;AAQA,SAAgB,gBAAgB,MAAM;AACpC,QAAO,SAAS,sBAAsB,SAAS;AAChD;AACD,SAAgB,oBAAoB,MAAM;AACxC,QAAO,QAAQ,oBAAoB,QAAQ,oBAAoB,QAAQ,oBAAoB,QAAQ;AACpG"}
@@ -0,0 +1,27 @@
1
+ const require_from_file_url = require('../_common/from_file_url.cjs');
2
+
3
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.js
4
+ /**
5
+ * Converts a file URL to a path string.
6
+ *
7
+ * @example Usage
8
+ * ```ts
9
+ * import { fromFileUrl } from "@std/path/windows/from-file-url";
10
+ * import { assertEquals } from "@std/assert";
11
+ *
12
+ * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");
13
+ * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo");
14
+ * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo");
15
+ * ```
16
+ *
17
+ * @param url The file URL to convert.
18
+ * @returns The path string.
19
+ */ function fromFileUrl(url) {
20
+ url = require_from_file_url.assertArg(url);
21
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
22
+ if (url.hostname !== "") path = `\\\\${url.hostname}${path}`;
23
+ return path;
24
+ }
25
+
26
+ //#endregion
27
+ exports.fromFileUrl = fromFileUrl;
@@ -0,0 +1,28 @@
1
+ import { assertArg } from "../_common/from_file_url.js";
2
+
3
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.js
4
+ /**
5
+ * Converts a file URL to a path string.
6
+ *
7
+ * @example Usage
8
+ * ```ts
9
+ * import { fromFileUrl } from "@std/path/windows/from-file-url";
10
+ * import { assertEquals } from "@std/assert";
11
+ *
12
+ * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");
13
+ * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo");
14
+ * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo");
15
+ * ```
16
+ *
17
+ * @param url The file URL to convert.
18
+ * @returns The path string.
19
+ */ function fromFileUrl(url) {
20
+ url = assertArg(url);
21
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
22
+ if (url.hostname !== "") path = `\\\\${url.hostname}${path}`;
23
+ return path;
24
+ }
25
+
26
+ //#endregion
27
+ export { fromFileUrl };
28
+ //# sourceMappingURL=from_file_url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from_file_url.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/from_file_url.js"],"sourcesContent":["// Copyright 2018-2025 the Deno authors. MIT license.\n// This module is browser compatible.\nimport { assertArg } from \"../_common/from_file_url.js\";\n/**\n * Converts a file URL to a path string.\n *\n * @example Usage\n * ```ts\n * import { fromFileUrl } from \"@std/path/windows/from-file-url\";\n * import { assertEquals } from \"@std/assert\";\n *\n * assertEquals(fromFileUrl(\"file:///home/foo\"), \"\\\\home\\\\foo\");\n * assertEquals(fromFileUrl(\"file:///C:/Users/foo\"), \"C:\\\\Users\\\\foo\");\n * assertEquals(fromFileUrl(\"file://localhost/home/foo\"), \"\\\\home\\\\foo\");\n * ```\n *\n * @param url The file URL to convert.\n * @returns The path string.\n */ export function fromFileUrl(url) {\n url = assertArg(url);\n let path = decodeURIComponent(url.pathname.replace(/\\//g, \"\\\\\").replace(/%(?![0-9A-Fa-f]{2})/g, \"%25\")).replace(/^\\\\*([A-Za-z]:)(\\\\|$)/, \"$1\\\\\");\n if (url.hostname !== \"\") {\n // Note: The `URL` implementation guarantees that the drive letter and\n // hostname are mutually exclusive. Otherwise it would not have been valid\n // to append the hostname and path like this.\n path = `\\\\\\\\${url.hostname}${path}`;\n }\n return path;\n}\n//# sourceMappingURL=from_file_url.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;GAkBI,SAAgB,YAAY,KAAK;AACnC,OAAM,UAAU,IAAI;CACpB,IAAI,OAAO,mBAAmB,IAAI,SAAS,QAAQ,OAAO,KAAK,CAAC,QAAQ,wBAAwB,MAAM,CAAC,CAAC,QAAQ,yBAAyB,OAAO;AAChJ,KAAI,IAAI,aAAa,GAInB,SAAQ,MAAM,IAAI,SAAS,EAAE,KAAK;AAEpC,QAAO;AACR"}
@@ -0,0 +1,51 @@
1
+ const require_assert_path = require('../_common/assert_path.cjs');
2
+ const require__util = require('./_util.cjs');
3
+ const require_from_file_url = require('./from_file_url.cjs');
4
+ const require_normalize = require('./normalize.cjs');
5
+
6
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/join.js
7
+ /**
8
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
9
+ *
10
+ * @example Usage
11
+ * ```ts
12
+ * import { join } from "@std/path/windows/join";
13
+ * import { assertEquals } from "@std/assert";
14
+ *
15
+ * assertEquals(join("C:\\foo", "bar", "baz\\.."), "C:\\foo\\bar");
16
+ * assertEquals(join(new URL("file:///C:/foo"), "bar", "baz\\.."), "C:\\foo\\bar");
17
+ * ```
18
+ *
19
+ * @param path The path to join. This can be string or file URL.
20
+ * @param paths The paths to join.
21
+ * @returns The joined path.
22
+ */ function join(path, ...paths) {
23
+ if (path instanceof URL) path = require_from_file_url.fromFileUrl(path);
24
+ paths = path ? [path, ...paths] : paths;
25
+ paths.forEach((path$1) => require_assert_path.assertPath(path$1));
26
+ paths = paths.filter((path$1) => path$1.length > 0);
27
+ if (paths.length === 0) return ".";
28
+ let needsReplace = true;
29
+ let slashCount = 0;
30
+ const firstPart = paths[0];
31
+ if (require__util.isPathSeparator(firstPart.charCodeAt(0))) {
32
+ ++slashCount;
33
+ const firstLen = firstPart.length;
34
+ if (firstLen > 1) {
35
+ if (require__util.isPathSeparator(firstPart.charCodeAt(1))) {
36
+ ++slashCount;
37
+ if (firstLen > 2) if (require__util.isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
38
+ else needsReplace = false;
39
+ }
40
+ }
41
+ }
42
+ let joined = paths.join("\\");
43
+ if (needsReplace) {
44
+ for (; slashCount < joined.length; ++slashCount) if (!require__util.isPathSeparator(joined.charCodeAt(slashCount))) break;
45
+ if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
46
+ }
47
+ return require_normalize.normalize(joined);
48
+ }
49
+
50
+ //#endregion
51
+ exports.join = join;
@@ -0,0 +1,52 @@
1
+ import { assertPath } from "../_common/assert_path.js";
2
+ import { isPathSeparator } from "./_util.js";
3
+ import { fromFileUrl } from "./from_file_url.js";
4
+ import { normalize } from "./normalize.js";
5
+
6
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/join.js
7
+ /**
8
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
9
+ *
10
+ * @example Usage
11
+ * ```ts
12
+ * import { join } from "@std/path/windows/join";
13
+ * import { assertEquals } from "@std/assert";
14
+ *
15
+ * assertEquals(join("C:\\foo", "bar", "baz\\.."), "C:\\foo\\bar");
16
+ * assertEquals(join(new URL("file:///C:/foo"), "bar", "baz\\.."), "C:\\foo\\bar");
17
+ * ```
18
+ *
19
+ * @param path The path to join. This can be string or file URL.
20
+ * @param paths The paths to join.
21
+ * @returns The joined path.
22
+ */ function join(path, ...paths) {
23
+ if (path instanceof URL) path = fromFileUrl(path);
24
+ paths = path ? [path, ...paths] : paths;
25
+ paths.forEach((path$1) => assertPath(path$1));
26
+ paths = paths.filter((path$1) => path$1.length > 0);
27
+ if (paths.length === 0) return ".";
28
+ let needsReplace = true;
29
+ let slashCount = 0;
30
+ const firstPart = paths[0];
31
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
32
+ ++slashCount;
33
+ const firstLen = firstPart.length;
34
+ if (firstLen > 1) {
35
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
36
+ ++slashCount;
37
+ if (firstLen > 2) if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
38
+ else needsReplace = false;
39
+ }
40
+ }
41
+ }
42
+ let joined = paths.join("\\");
43
+ if (needsReplace) {
44
+ for (; slashCount < joined.length; ++slashCount) if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
45
+ if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
46
+ }
47
+ return normalize(joined);
48
+ }
49
+
50
+ //#endregion
51
+ export { join };
52
+ //# sourceMappingURL=join.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.js","names":["path"],"sources":["../../../../../../../../../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/join.js"],"sourcesContent":["// Copyright 2018-2025 the Deno authors. MIT license.\n// This module is browser compatible.\nimport { assertPath } from \"../_common/assert_path.js\";\nimport { isPathSeparator } from \"./_util.js\";\nimport { normalize } from \"./normalize.js\";\nimport { fromFileUrl } from \"./from_file_url.js\";\n/**\n * Join all given a sequence of `paths`,then normalizes the resulting path.\n *\n * @example Usage\n * ```ts\n * import { join } from \"@std/path/windows/join\";\n * import { assertEquals } from \"@std/assert\";\n *\n * assertEquals(join(\"C:\\\\foo\", \"bar\", \"baz\\\\..\"), \"C:\\\\foo\\\\bar\");\n * assertEquals(join(new URL(\"file:///C:/foo\"), \"bar\", \"baz\\\\..\"), \"C:\\\\foo\\\\bar\");\n * ```\n *\n * @param path The path to join. This can be string or file URL.\n * @param paths The paths to join.\n * @returns The joined path.\n */ export function join(path, ...paths) {\n if (path instanceof URL) {\n path = fromFileUrl(path);\n }\n paths = path ? [\n path,\n ...paths\n ] : paths;\n paths.forEach((path)=>assertPath(path));\n paths = paths.filter((path)=>path.length > 0);\n if (paths.length === 0) return \".\";\n // Make sure that the joined path doesn't start with two slashes, because\n // normalize() will mistake it for an UNC path then.\n //\n // This step is skipped when it is very clear that the user actually\n // intended to point at an UNC path. This is assumed when the first\n // non-empty string arguments starts with exactly two slashes followed by\n // at least one more non-slash character.\n //\n // Note that for normalize() to treat a path as an UNC path it needs to\n // have at least 2 components, so we don't filter for that here.\n // This means that the user can use join to construct UNC paths from\n // a server name and a share name; for example:\n // path.join('//server', 'share') -> '\\\\\\\\server\\\\share\\\\'\n let needsReplace = true;\n let slashCount = 0;\n const firstPart = paths[0];\n if (isPathSeparator(firstPart.charCodeAt(0))) {\n ++slashCount;\n const firstLen = firstPart.length;\n if (firstLen > 1) {\n if (isPathSeparator(firstPart.charCodeAt(1))) {\n ++slashCount;\n if (firstLen > 2) {\n if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;\n else {\n // We matched a UNC path in the first part\n needsReplace = false;\n }\n }\n }\n }\n }\n let joined = paths.join(\"\\\\\");\n if (needsReplace) {\n // Find any more consecutive slashes we need to replace\n for(; slashCount < joined.length; ++slashCount){\n if (!isPathSeparator(joined.charCodeAt(slashCount))) break;\n }\n // Replace the slashes if needed\n if (slashCount >= 2) joined = `\\\\${joined.slice(slashCount)}`;\n }\n return normalize(joined);\n}\n//# sourceMappingURL=join.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;GAqBI,SAAgB,KAAK,MAAM,GAAG,OAAO;AACvC,KAAI,gBAAgB,IAClB,QAAO,YAAY,KAAK;AAE1B,SAAQ,OAAO,CACb,MACA,GAAG,KACJ,IAAG;AACJ,OAAM,QAAQ,CAACA,WAAO,WAAWA,OAAK,CAAC;AACvC,SAAQ,MAAM,OAAO,CAACA,WAAOA,OAAK,SAAS,EAAE;AAC7C,KAAI,MAAM,WAAW,EAAG,QAAO;CAc/B,IAAI,eAAe;CACnB,IAAI,aAAa;CACjB,MAAM,YAAY,MAAM;AACxB,KAAI,gBAAgB,UAAU,WAAW,EAAE,CAAC,EAAE;AAC5C,IAAE;EACF,MAAM,WAAW,UAAU;AAC3B,MAAI,WAAW,GACb;OAAI,gBAAgB,UAAU,WAAW,EAAE,CAAC,EAAE;AAC5C,MAAE;AACF,QAAI,WAAW,EACb,KAAI,gBAAgB,UAAU,WAAW,EAAE,CAAC,CAAE,GAAE;QAG9C,gBAAe;GAGpB;;CAEJ;CACD,IAAI,SAAS,MAAM,KAAK,KAAK;AAC7B,KAAI,cAAc;AAEhB,SAAM,aAAa,OAAO,QAAQ,EAAE,WAClC,MAAK,gBAAgB,OAAO,WAAW,WAAW,CAAC,CAAE;AAGvD,MAAI,cAAc,EAAG,WAAU,IAAI,OAAO,MAAM,WAAW,CAAC;CAC7D;AACD,QAAO,UAAU,OAAO;AACzB"}
@@ -0,0 +1,82 @@
1
+ const require_normalize = require('../_common/normalize.cjs');
2
+ const require_constants = require('../_common/constants.cjs');
3
+ const require_normalize_string = require('../_common/normalize_string.cjs');
4
+ const require__util = require('./_util.cjs');
5
+ const require_from_file_url = require('./from_file_url.cjs');
6
+
7
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.js
8
+ /**
9
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
10
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
11
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { normalize } from "@std/path/windows/normalize";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * assertEquals(normalize("C:\\foo\\..\\bar"), "C:\\bar");
19
+ * assertEquals(normalize(new URL("file:///C:/foo/../bar")), "C:\\bar");
20
+ * ```
21
+ *
22
+ * @param path The path to normalize
23
+ * @returns The normalized path
24
+ */ function normalize(path) {
25
+ if (path instanceof URL) path = require_from_file_url.fromFileUrl(path);
26
+ require_normalize.assertArg(path);
27
+ const len = path.length;
28
+ let rootEnd = 0;
29
+ let device;
30
+ let isAbsolute = false;
31
+ const code = path.charCodeAt(0);
32
+ if (len > 1) {
33
+ if (require__util.isPathSeparator(code)) {
34
+ isAbsolute = true;
35
+ if (require__util.isPathSeparator(path.charCodeAt(1))) {
36
+ let j = 2;
37
+ let last = j;
38
+ for (; j < len; ++j) if (require__util.isPathSeparator(path.charCodeAt(j))) break;
39
+ if (j < len && j !== last) {
40
+ const firstPart = path.slice(last, j);
41
+ last = j;
42
+ for (; j < len; ++j) if (!require__util.isPathSeparator(path.charCodeAt(j))) break;
43
+ if (j < len && j !== last) {
44
+ last = j;
45
+ for (; j < len; ++j) if (require__util.isPathSeparator(path.charCodeAt(j))) break;
46
+ if (j === len) return `\\\\${firstPart}\\${path.slice(last)}\\`;
47
+ else if (j !== last) {
48
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
49
+ rootEnd = j;
50
+ }
51
+ }
52
+ }
53
+ } else rootEnd = 1;
54
+ } else if (require__util.isWindowsDeviceRoot(code)) {
55
+ if (path.charCodeAt(1) === require_constants.CHAR_COLON) {
56
+ device = path.slice(0, 2);
57
+ rootEnd = 2;
58
+ if (len > 2) {
59
+ if (require__util.isPathSeparator(path.charCodeAt(2))) {
60
+ isAbsolute = true;
61
+ rootEnd = 3;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ } else if (require__util.isPathSeparator(code)) return "\\";
67
+ let tail;
68
+ if (rootEnd < len) tail = require_normalize_string.normalizeString(path.slice(rootEnd), !isAbsolute, "\\", require__util.isPathSeparator);
69
+ else tail = "";
70
+ if (tail.length === 0 && !isAbsolute) tail = ".";
71
+ if (tail.length > 0 && require__util.isPathSeparator(path.charCodeAt(len - 1))) tail += "\\";
72
+ if (device === void 0) {
73
+ if (isAbsolute) if (tail.length > 0) return `\\${tail}`;
74
+ else return "\\";
75
+ return tail;
76
+ } else if (isAbsolute) if (tail.length > 0) return `${device}\\${tail}`;
77
+ else return `${device}\\`;
78
+ return device + tail;
79
+ }
80
+
81
+ //#endregion
82
+ exports.normalize = normalize;
@@ -0,0 +1,83 @@
1
+ import { assertArg } from "../_common/normalize.js";
2
+ import { CHAR_COLON } from "../_common/constants.js";
3
+ import { normalizeString } from "../_common/normalize_string.js";
4
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
5
+ import { fromFileUrl } from "./from_file_url.js";
6
+
7
+ //#region ../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.js
8
+ /**
9
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
10
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
11
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { normalize } from "@std/path/windows/normalize";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * assertEquals(normalize("C:\\foo\\..\\bar"), "C:\\bar");
19
+ * assertEquals(normalize(new URL("file:///C:/foo/../bar")), "C:\\bar");
20
+ * ```
21
+ *
22
+ * @param path The path to normalize
23
+ * @returns The normalized path
24
+ */ function normalize(path) {
25
+ if (path instanceof URL) path = fromFileUrl(path);
26
+ assertArg(path);
27
+ const len = path.length;
28
+ let rootEnd = 0;
29
+ let device;
30
+ let isAbsolute = false;
31
+ const code = path.charCodeAt(0);
32
+ if (len > 1) {
33
+ if (isPathSeparator(code)) {
34
+ isAbsolute = true;
35
+ if (isPathSeparator(path.charCodeAt(1))) {
36
+ let j = 2;
37
+ let last = j;
38
+ for (; j < len; ++j) if (isPathSeparator(path.charCodeAt(j))) break;
39
+ if (j < len && j !== last) {
40
+ const firstPart = path.slice(last, j);
41
+ last = j;
42
+ for (; j < len; ++j) if (!isPathSeparator(path.charCodeAt(j))) break;
43
+ if (j < len && j !== last) {
44
+ last = j;
45
+ for (; j < len; ++j) if (isPathSeparator(path.charCodeAt(j))) break;
46
+ if (j === len) return `\\\\${firstPart}\\${path.slice(last)}\\`;
47
+ else if (j !== last) {
48
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
49
+ rootEnd = j;
50
+ }
51
+ }
52
+ }
53
+ } else rootEnd = 1;
54
+ } else if (isWindowsDeviceRoot(code)) {
55
+ if (path.charCodeAt(1) === CHAR_COLON) {
56
+ device = path.slice(0, 2);
57
+ rootEnd = 2;
58
+ if (len > 2) {
59
+ if (isPathSeparator(path.charCodeAt(2))) {
60
+ isAbsolute = true;
61
+ rootEnd = 3;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ } else if (isPathSeparator(code)) return "\\";
67
+ let tail;
68
+ if (rootEnd < len) tail = normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator);
69
+ else tail = "";
70
+ if (tail.length === 0 && !isAbsolute) tail = ".";
71
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) tail += "\\";
72
+ if (device === void 0) {
73
+ if (isAbsolute) if (tail.length > 0) return `\\${tail}`;
74
+ else return "\\";
75
+ return tail;
76
+ } else if (isAbsolute) if (tail.length > 0) return `${device}\\${tail}`;
77
+ else return `${device}\\`;
78
+ return device + tail;
79
+ }
80
+
81
+ //#endregion
82
+ export { normalize };
83
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@jsr+std__path@1.1.0/node_modules/@jsr/std__path/windows/normalize.js"],"sourcesContent":["// Copyright 2018-2025 the Deno authors. MIT license.\n// This module is browser compatible.\nimport { assertArg } from \"../_common/normalize.js\";\nimport { CHAR_COLON } from \"../_common/constants.js\";\nimport { normalizeString } from \"../_common/normalize_string.js\";\nimport { isPathSeparator, isWindowsDeviceRoot } from \"./_util.js\";\nimport { fromFileUrl } from \"./from_file_url.js\";\n/**\n * Normalize the `path`, resolving `'..'` and `'.'` segments.\n * Note that resolving these segments does not necessarily mean that all will be eliminated.\n * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.\n *\n * @example Usage\n * ```ts\n * import { normalize } from \"@std/path/windows/normalize\";\n * import { assertEquals } from \"@std/assert\";\n *\n * assertEquals(normalize(\"C:\\\\foo\\\\..\\\\bar\"), \"C:\\\\bar\");\n * assertEquals(normalize(new URL(\"file:///C:/foo/../bar\")), \"C:\\\\bar\");\n * ```\n *\n * @param path The path to normalize\n * @returns The normalized path\n */ export function normalize(path) {\n if (path instanceof URL) {\n path = fromFileUrl(path);\n }\n assertArg(path);\n const len = path.length;\n let rootEnd = 0;\n let device;\n let isAbsolute = false;\n const code = path.charCodeAt(0);\n // Try to match a root\n if (len > 1) {\n if (isPathSeparator(code)) {\n // Possible UNC root\n // If we started with a separator, we know we at least have an absolute\n // path of some kind (UNC or otherwise)\n isAbsolute = true;\n if (isPathSeparator(path.charCodeAt(1))) {\n // Matched double path separator at beginning\n let j = 2;\n let last = j;\n // Match 1 or more non-path separators\n for(; j < len; ++j){\n if (isPathSeparator(path.charCodeAt(j))) break;\n }\n if (j < len && j !== last) {\n const firstPart = path.slice(last, j);\n // Matched!\n last = j;\n // Match 1 or more path separators\n for(; j < len; ++j){\n if (!isPathSeparator(path.charCodeAt(j))) break;\n }\n if (j < len && j !== last) {\n // Matched!\n last = j;\n // Match 1 or more non-path separators\n for(; j < len; ++j){\n if (isPathSeparator(path.charCodeAt(j))) break;\n }\n if (j === len) {\n // We matched a UNC root only\n // Return the normalized version of the UNC root since there\n // is nothing left to process\n return `\\\\\\\\${firstPart}\\\\${path.slice(last)}\\\\`;\n } else if (j !== last) {\n // We matched a UNC root with leftovers\n device = `\\\\\\\\${firstPart}\\\\${path.slice(last, j)}`;\n rootEnd = j;\n }\n }\n }\n } else {\n rootEnd = 1;\n }\n } else if (isWindowsDeviceRoot(code)) {\n // Possible device root\n if (path.charCodeAt(1) === CHAR_COLON) {\n device = path.slice(0, 2);\n rootEnd = 2;\n if (len > 2) {\n if (isPathSeparator(path.charCodeAt(2))) {\n // Treat separator following drive name as an absolute path\n // indicator\n isAbsolute = true;\n rootEnd = 3;\n }\n }\n }\n }\n } else if (isPathSeparator(code)) {\n // `path` contains just a path separator, exit early to avoid unnecessary\n // work\n return \"\\\\\";\n }\n let tail;\n if (rootEnd < len) {\n tail = normalizeString(path.slice(rootEnd), !isAbsolute, \"\\\\\", isPathSeparator);\n } else {\n tail = \"\";\n }\n if (tail.length === 0 && !isAbsolute) tail = \".\";\n if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {\n tail += \"\\\\\";\n }\n if (device === undefined) {\n if (isAbsolute) {\n if (tail.length > 0) return `\\\\${tail}`;\n else return \"\\\\\";\n }\n return tail;\n } else if (isAbsolute) {\n if (tail.length > 0) return `${device}\\\\${tail}`;\n else return `${device}\\\\`;\n }\n return device + tail;\n}\n//# sourceMappingURL=normalize.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;GAuBI,SAAgB,UAAU,MAAM;AAClC,KAAI,gBAAgB,IAClB,QAAO,YAAY,KAAK;AAE1B,WAAU,KAAK;CACf,MAAM,MAAM,KAAK;CACjB,IAAI,UAAU;CACd,IAAI;CACJ,IAAI,aAAa;CACjB,MAAM,OAAO,KAAK,WAAW,EAAE;AAE/B,KAAI,MAAM,GACR;MAAI,gBAAgB,KAAK,EAAE;AAIzB,gBAAa;AACb,OAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC,EAAE;IAEvC,IAAI,IAAI;IACR,IAAI,OAAO;AAEX,WAAM,IAAI,KAAK,EAAE,EACf,KAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC,CAAE;AAE3C,QAAI,IAAI,OAAO,MAAM,MAAM;KACzB,MAAM,YAAY,KAAK,MAAM,MAAM,EAAE;AAErC,YAAO;AAEP,YAAM,IAAI,KAAK,EAAE,EACf,MAAK,gBAAgB,KAAK,WAAW,EAAE,CAAC,CAAE;AAE5C,SAAI,IAAI,OAAO,MAAM,MAAM;AAEzB,aAAO;AAEP,aAAM,IAAI,KAAK,EAAE,EACf,KAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC,CAAE;AAE3C,UAAI,MAAM,IAIR,SAAQ,MAAM,UAAU,IAAI,KAAK,MAAM,KAAK,CAAC;eACpC,MAAM,MAAM;AAErB,iBAAU,MAAM,UAAU,IAAI,KAAK,MAAM,MAAM,EAAE,CAAC;AAClD,iBAAU;MACX;KACF;IACF;GACF,MACC,WAAU;EAEb,WAAU,oBAAoB,KAAK,EAElC;OAAI,KAAK,WAAW,EAAE,KAAK,YAAY;AACrC,aAAS,KAAK,MAAM,GAAG,EAAE;AACzB,cAAU;AACV,QAAI,MAAM,GACR;SAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC,EAAE;AAGvC,mBAAa;AACb,gBAAU;KACX;;GAEJ;;CACF,WACQ,gBAAgB,KAAK,CAG9B,QAAO;CAET,IAAI;AACJ,KAAI,UAAU,IACZ,QAAO,gBAAgB,KAAK,MAAM,QAAQ,GAAG,YAAY,MAAM,gBAAgB;KAE/E,QAAO;AAET,KAAI,KAAK,WAAW,MAAM,WAAY,QAAO;AAC7C,KAAI,KAAK,SAAS,KAAK,gBAAgB,KAAK,WAAW,MAAM,EAAE,CAAC,CAC9D,SAAQ;AAEV,KAAI,mBAAsB;AACxB,MAAI,WACF,KAAI,KAAK,SAAS,EAAG,SAAQ,IAAI,KAAK;MACjC,QAAO;AAEd,SAAO;CACR,WAAU,WACT,KAAI,KAAK,SAAS,EAAG,SAAQ,EAAE,OAAO,IAAI,KAAK;KAC1C,SAAQ,EAAE,OAAO;AAExB,QAAO,SAAS;AACjB"}
@@ -0,0 +1,208 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/logtape"));
3
+
4
+ //#region src/timefilesink.ts
5
+ /**
6
+ * Get the ISO week number of a date.
7
+ * @param date The date to get the week number of.
8
+ * @returns The ISO week number (1-53).
9
+ */
10
+ function getISOWeek(date) {
11
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
12
+ const dayNum = d.getUTCDay() || 7;
13
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
14
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
15
+ return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
16
+ }
17
+ /**
18
+ * Get the ISO week year of a date. This may differ from the calendar year
19
+ * for dates near the start or end of a year.
20
+ * @param date The date to get the ISO week year of.
21
+ * @returns The ISO week year.
22
+ */
23
+ function getISOWeekYear(date) {
24
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
25
+ const dayNum = d.getUTCDay() || 7;
26
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
27
+ return d.getUTCFullYear();
28
+ }
29
+ /**
30
+ * Get the default filename generator for the given interval.
31
+ * @param interval The rotation interval.
32
+ * @returns A function that generates a filename for a given date.
33
+ */
34
+ function getDefaultFilename(interval) {
35
+ switch (interval) {
36
+ case "hourly": return (date) => {
37
+ const yyyy = date.getFullYear();
38
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
39
+ const dd = String(date.getDate()).padStart(2, "0");
40
+ const hh = String(date.getHours()).padStart(2, "0");
41
+ return `${yyyy}-${mm}-${dd}-${hh}.log`;
42
+ };
43
+ case "daily": return (date) => {
44
+ const yyyy = date.getFullYear();
45
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
46
+ const dd = String(date.getDate()).padStart(2, "0");
47
+ return `${yyyy}-${mm}-${dd}.log`;
48
+ };
49
+ case "weekly": return (date) => {
50
+ const yyyy = getISOWeekYear(date);
51
+ const week = getISOWeek(date);
52
+ return `${yyyy}-W${String(week).padStart(2, "0")}.log`;
53
+ };
54
+ }
55
+ }
56
+ /**
57
+ * Get the rotation key for the given date and interval.
58
+ * The key is used to determine when to rotate to a new file.
59
+ * @param date The date to get the rotation key of.
60
+ * @param interval The rotation interval.
61
+ * @returns A string key that changes when rotation should occur.
62
+ */
63
+ function getRotationKey(date, interval) {
64
+ switch (interval) {
65
+ case "hourly": return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getHours()}`;
66
+ case "daily": return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
67
+ case "weekly": return `${getISOWeekYear(date)}-${getISOWeek(date)}`;
68
+ }
69
+ }
70
+ function getBaseTimeRotatingFileSink(options) {
71
+ const formatter = options.formatter ?? __logtape_logtape.defaultTextFormatter;
72
+ const encoder = options.encoder ?? new TextEncoder();
73
+ const interval = options.interval ?? "daily";
74
+ const filenameGenerator = options.filename ?? getDefaultFilename(interval);
75
+ const maxAgeMs = options.maxAgeMs;
76
+ const bufferSize = options.bufferSize ?? 1024 * 8;
77
+ const flushInterval = options.flushInterval ?? 5e3;
78
+ const directory = options.directory;
79
+ try {
80
+ options.mkdirSync(directory, { recursive: true });
81
+ } catch {}
82
+ let currentFilename = filenameGenerator(/* @__PURE__ */ new Date());
83
+ let currentPath = options.joinPath(directory, currentFilename);
84
+ let currentRotationKey = getRotationKey(/* @__PURE__ */ new Date(), interval);
85
+ let fd = options.openSync(currentPath);
86
+ let lastFlushTimestamp = Date.now();
87
+ let buffer = "";
88
+ function shouldRotate() {
89
+ const now = /* @__PURE__ */ new Date();
90
+ const newKey = getRotationKey(now, interval);
91
+ return newKey !== currentRotationKey;
92
+ }
93
+ function performRotation() {
94
+ options.closeSync(fd);
95
+ const now = /* @__PURE__ */ new Date();
96
+ currentFilename = filenameGenerator(now);
97
+ currentPath = options.joinPath(directory, currentFilename);
98
+ currentRotationKey = getRotationKey(now, interval);
99
+ fd = options.openSync(currentPath);
100
+ }
101
+ function cleanupOldFiles() {
102
+ if (maxAgeMs === void 0) return;
103
+ const now = Date.now();
104
+ let files;
105
+ try {
106
+ files = options.readdirSync(directory);
107
+ } catch {
108
+ return;
109
+ }
110
+ for (const file of files) {
111
+ if (!file.endsWith(".log")) continue;
112
+ if (file === currentFilename) continue;
113
+ const filePath = options.joinPath(directory, file);
114
+ const dateMatch = file.match(/^(\d{4})-(\d{2})-(\d{2})(?:-(\d{2}))?\.log$/);
115
+ const weekMatch = file.match(/^(\d{4})-W(\d{2})\.log$/);
116
+ let fileDate = null;
117
+ if (dateMatch) {
118
+ const [, year, month, day, hour] = dateMatch;
119
+ fileDate = new Date(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), hour ? parseInt(hour, 10) : 0);
120
+ } else if (weekMatch) {
121
+ const [, year, week] = weekMatch;
122
+ const jan4 = new Date(parseInt(year, 10), 0, 4);
123
+ const dayOfWeek = jan4.getDay() || 7;
124
+ fileDate = new Date(jan4);
125
+ fileDate.setDate(jan4.getDate() - dayOfWeek + 1 + (parseInt(week, 10) - 1) * 7);
126
+ }
127
+ if (fileDate && now - fileDate.getTime() > maxAgeMs) try {
128
+ options.unlinkSync(filePath);
129
+ } catch {}
130
+ }
131
+ }
132
+ if (!options.nonBlocking) {
133
+ function flushBuffer$1() {
134
+ if (buffer.length > 0) {
135
+ if (shouldRotate()) performRotation();
136
+ const bytes = encoder.encode(buffer);
137
+ buffer = "";
138
+ options.writeSync(fd, bytes);
139
+ options.flushSync(fd);
140
+ lastFlushTimestamp = Date.now();
141
+ cleanupOldFiles();
142
+ }
143
+ }
144
+ const sink = (record) => {
145
+ buffer += formatter(record);
146
+ const shouldFlushBySize = buffer.length >= bufferSize;
147
+ const shouldFlushByTime = flushInterval > 0 && record.timestamp - lastFlushTimestamp >= flushInterval;
148
+ if (shouldFlushBySize || shouldFlushByTime) flushBuffer$1();
149
+ };
150
+ sink[Symbol.dispose] = () => {
151
+ flushBuffer$1();
152
+ options.closeSync(fd);
153
+ };
154
+ return sink;
155
+ }
156
+ const asyncOptions = options;
157
+ let disposed = false;
158
+ let activeFlush = null;
159
+ let flushTimer = null;
160
+ async function flushBuffer() {
161
+ if (buffer.length === 0) return;
162
+ if (shouldRotate()) performRotation();
163
+ const data = buffer;
164
+ buffer = "";
165
+ try {
166
+ const bytes = encoder.encode(data);
167
+ asyncOptions.writeSync(fd, bytes);
168
+ await asyncOptions.flush(fd);
169
+ lastFlushTimestamp = Date.now();
170
+ cleanupOldFiles();
171
+ } catch {}
172
+ }
173
+ function scheduleFlush() {
174
+ if (activeFlush || disposed) return;
175
+ activeFlush = flushBuffer().finally(() => {
176
+ activeFlush = null;
177
+ });
178
+ }
179
+ function startFlushTimer() {
180
+ if (flushTimer !== null || disposed) return;
181
+ flushTimer = setInterval(() => {
182
+ scheduleFlush();
183
+ }, flushInterval);
184
+ }
185
+ const nonBlockingSink = (record) => {
186
+ if (disposed) return;
187
+ buffer += formatter(record);
188
+ const shouldFlushBySize = buffer.length >= bufferSize;
189
+ const shouldFlushByTime = flushInterval > 0 && record.timestamp - lastFlushTimestamp >= flushInterval;
190
+ if (shouldFlushBySize || shouldFlushByTime) scheduleFlush();
191
+ else if (flushTimer === null && flushInterval > 0) startFlushTimer();
192
+ };
193
+ nonBlockingSink[Symbol.asyncDispose] = async () => {
194
+ disposed = true;
195
+ if (flushTimer !== null) {
196
+ clearInterval(flushTimer);
197
+ flushTimer = null;
198
+ }
199
+ await flushBuffer();
200
+ try {
201
+ await asyncOptions.close(fd);
202
+ } catch {}
203
+ };
204
+ return nonBlockingSink;
205
+ }
206
+
207
+ //#endregion
208
+ exports.getBaseTimeRotatingFileSink = getBaseTimeRotatingFileSink;