@visulima/fs 5.0.0-alpha.9 → 5.0.0

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 (198) hide show
  1. package/CHANGELOG.md +459 -0
  2. package/LICENSE.md +81 -4
  3. package/README.md +65 -0
  4. package/dist/eol.d.ts +30 -0
  5. package/dist/eol.js +3 -26
  6. package/dist/error.d.ts +243 -13
  7. package/dist/error.js +1 -7
  8. package/dist/glob-parent.d.ts +30 -0
  9. package/dist/glob-parent.js +1 -90
  10. package/dist/glob.d.ts +3 -4
  11. package/dist/glob.js +1 -2
  12. package/dist/index.d.ts +877 -28
  13. package/dist/index.js +1 -38
  14. package/dist/ini.d.ts +64 -4
  15. package/dist/ini.js +1 -4
  16. package/dist/is-glob.d.ts +29 -0
  17. package/dist/is-glob.js +1 -9
  18. package/dist/json5.d.ts +28 -4
  19. package/dist/json5.js +1 -4
  20. package/dist/jsonc.d.ts +59 -4
  21. package/dist/jsonc.js +1 -4
  22. package/dist/match.d.ts +77 -2
  23. package/dist/match.js +1 -15
  24. package/dist/packem_shared/AlreadyExistsError-DEb3UWja.js +1 -0
  25. package/dist/packem_shared/DirectoryError-BtwSTLmT.js +1 -0
  26. package/dist/packem_shared/FIND_UP_STOP-CAwY1qU7.js +1 -0
  27. package/dist/packem_shared/JSONError-Cvp9ycba.js +4 -0
  28. package/dist/packem_shared/NotEmptyError-DZ1Ix089.js +1 -0
  29. package/dist/packem_shared/NotFoundError-CnRY6lVp.js +1 -0
  30. package/dist/packem_shared/PermissionError-DJ_2VWEj.js +1 -0
  31. package/dist/packem_shared/WalkError-B8qTd-v-.js +1 -0
  32. package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
  33. package/dist/packem_shared/assertValidFileContents-CbIN7sy7.js +1 -0
  34. package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +1 -0
  35. package/dist/packem_shared/build-rm-options-avnusYx-.js +1 -0
  36. package/dist/packem_shared/collect-CIKDOMiD.js +1 -0
  37. package/dist/packem_shared/collectSync-D0FRLLqg.js +1 -0
  38. package/dist/packem_shared/copy-Beb64BYG.js +1 -0
  39. package/dist/packem_shared/copySync-CagcIEBi.js +1 -0
  40. package/dist/packem_shared/emptyDir-C7lyd1lW.js +1 -0
  41. package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +1 -0
  42. package/dist/packem_shared/ensureDir-DGarVZw8.js +1 -0
  43. package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +1 -0
  44. package/dist/packem_shared/ensureFile-CMugWljp.js +1 -0
  45. package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +1 -0
  46. package/dist/packem_shared/ensureLink-ChShf3lf.js +1 -0
  47. package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +1 -0
  48. package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +1 -0
  49. package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +1 -0
  50. package/dist/packem_shared/findUp-Cii5ATt5.js +1 -0
  51. package/dist/packem_shared/findUpSync-C9Lkh7-v.js +1 -0
  52. package/dist/packem_shared/get-file-info-type-DzWpohDB.js +1 -0
  53. package/dist/packem_shared/glob-fqg4KepW.js +1 -0
  54. package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +54 -0
  55. package/dist/packem_shared/globSync-B8_ne93E.js +1 -0
  56. package/dist/packem_shared/index-B2MhYg3r.js +1 -0
  57. package/dist/packem_shared/index-BHy3Kcr7.js +11 -0
  58. package/dist/packem_shared/index-BLg3XWiD.js +1 -0
  59. package/dist/packem_shared/index-D8MDd0tv.js +1 -0
  60. package/dist/packem_shared/ini-preserve-D1DopDLd.js +4 -0
  61. package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +1 -0
  62. package/dist/packem_shared/isAccessible-PmWJhV6I.js +1 -0
  63. package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +1 -0
  64. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  65. package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +2 -0
  66. package/dist/packem_shared/map-read-error-CR3rQUxx.js +1 -0
  67. package/dist/packem_shared/move-DopmzT-2.js +1 -0
  68. package/dist/packem_shared/parseJson-EASgP4J9.js +1 -0
  69. package/dist/packem_shared/readFile-BswaBgM0.js +1 -0
  70. package/dist/packem_shared/readFileSync-_fDF6Oj1.js +1 -0
  71. package/dist/packem_shared/readIni-BsXudu2r.js +1 -0
  72. package/dist/packem_shared/readIniSync-DKwRbbs9.js +1 -0
  73. package/dist/packem_shared/readJson-CcAsHxE5.js +1 -0
  74. package/dist/packem_shared/readJson5-CM1TIiHd.js +1 -0
  75. package/dist/packem_shared/readJson5Sync-Bc26c3Fy.js +1 -0
  76. package/dist/packem_shared/readJsonSync-DuMMeB3s.js +1 -0
  77. package/dist/packem_shared/readJsonc-BZjMw_0f.js +1 -0
  78. package/dist/packem_shared/readJsoncSync-C-xzeZz4.js +1 -0
  79. package/dist/packem_shared/readToml-D4jpe9q_.js +1 -0
  80. package/dist/packem_shared/readTomlSync-B5PIYT9z.js +1 -0
  81. package/dist/packem_shared/readYaml-DvPxndW_.js +1 -0
  82. package/dist/packem_shared/readYamlSync-DZ-0hSbZ.js +1 -0
  83. package/dist/packem_shared/remove-CSbrd0dl.js +1 -0
  84. package/dist/packem_shared/removeSync-BoLAzRQE.js +1 -0
  85. package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +6 -0
  86. package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +1 -0
  87. package/dist/packem_shared/sanitize-DGZ3w-_w.js +1 -0
  88. package/dist/packem_shared/stripJsonComments-Bfcn2PKv.js +1 -0
  89. package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +1 -0
  90. package/dist/packem_shared/types.d-BMdL_ygj.d.ts +1773 -0
  91. package/dist/packem_shared/walk-OX4-6oCP.js +1 -0
  92. package/dist/packem_shared/walk-include-BXhGSn6t.js +1 -0
  93. package/dist/packem_shared/walkSync-BPs6czIM.js +1 -0
  94. package/dist/packem_shared/writeFile-BrMtsJY7.js +1 -0
  95. package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +1 -0
  96. package/dist/packem_shared/writeIni-BWX3cP1K.js +4 -0
  97. package/dist/packem_shared/writeIniSync-fOdgPFfL.js +4 -0
  98. package/dist/packem_shared/writeJson-bEVi25gX.js +4 -0
  99. package/dist/packem_shared/writeJson5-Ch8TpNPI.js +4 -0
  100. package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +4 -0
  101. package/dist/packem_shared/writeJsonSync-DkGnd416.js +4 -0
  102. package/dist/packem_shared/writeJsonc-CefrwsOc.js +4 -0
  103. package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +4 -0
  104. package/dist/packem_shared/writeToml-IuMO-yDu.js +1 -0
  105. package/dist/packem_shared/writeTomlSync-DhL7hHzB.js +1 -0
  106. package/dist/packem_shared/writeYaml-ClQgvQID.js +1 -0
  107. package/dist/packem_shared/writeYamlSync-DrXtHQQq.js +1 -0
  108. package/dist/size.d.ts +244 -0
  109. package/dist/size.js +1 -146
  110. package/dist/toml.d.ts +57 -3
  111. package/dist/toml.js +1 -4
  112. package/dist/utils.d.ts +92 -4
  113. package/dist/utils.js +1 -6
  114. package/dist/yaml.d.ts +3 -4
  115. package/dist/yaml.js +1 -4
  116. package/package.json +20 -23
  117. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  118. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  119. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  120. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  121. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  122. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  123. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  124. package/dist/packem_shared/WalkError-DER5A43G.js +0 -24
  125. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  126. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  127. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  128. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
  129. package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
  130. package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
  131. package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
  132. package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
  133. package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
  134. package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
  135. package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
  136. package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
  137. package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
  138. package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
  139. package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
  140. package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
  141. package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
  142. package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
  143. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  144. package/dist/packem_shared/glob-DY8l7izD.js +0 -5
  145. package/dist/packem_shared/glob-sync.d-B83kqwUd.d.ts +0 -4
  146. package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
  147. package/dist/packem_shared/index-C8W8sfzP.js +0 -830
  148. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  149. package/dist/packem_shared/index-bhgnhm4u.js +0 -167
  150. package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
  151. package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
  152. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
  153. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  154. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  155. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  156. package/dist/packem_shared/isFsCaseSensitive-DunL7Iry.js +0 -62
  157. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +0 -10
  158. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
  159. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  160. package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
  161. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  162. package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
  163. package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
  164. package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
  165. package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
  166. package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
  167. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
  168. package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
  169. package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
  170. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
  171. package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
  172. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
  173. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  174. package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
  175. package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
  176. package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
  177. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  178. package/dist/packem_shared/sanitize-BZoLN9Fg.js +0 -205
  179. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  180. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  181. package/dist/packem_shared/types.d-dP-lAGNn.d.ts +0 -145
  182. package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
  183. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  184. package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
  185. package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
  186. package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
  187. package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
  188. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
  189. package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
  190. package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
  191. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
  192. package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
  193. package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
  194. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
  195. package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
  196. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
  197. package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
  198. package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
@@ -1,205 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const {
8
- platform
9
- } = __cjs_getProcess;
10
-
11
- const FALLBACK_NAME = "unnamed";
12
- const MAX_LENGTH = 128;
13
- const REPLACEMENT_CHARACTERS = {
14
- '"': "ˮ",
15
- // 0x02EE - MODIFIER LETTER DOUBLE APOSTROPHE
16
- "*": "⁎",
17
- // 0x204E - LOW ASTERISK
18
- "/": "⁄",
19
- // 0x2044 - FRACTION SLASH
20
- ":": "꞉",
21
- // 0xA789 - MODIFIER LETTER COLON
22
- "<": "‹",
23
- // 0x2039 - SINGLE LEFT-POINTING ANGLE QUOTATION MARK
24
- ">": "›",
25
- // 0x203A - SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
26
- "?": "ʔ",
27
- // 0x0294 - LATIN LETTER GLOTTAL STOP
28
- "\\": "∖",
29
- // 0x2216 - SET MINUS
30
- "|": "ǀ"
31
- // 0x01C0 - LATIN LETTER DENTAL CLICK
32
- };
33
- const CONTROL_CHARS_REGEX = /[\u0000-\u001F\u0080-\u009F]/g;
34
- const RELATIVE_PATHS_REGEX = /^(?:\.+[/\\]+)+|^\.+$/g;
35
- const WINDOWS_SPECIAL_NAMES_REGEX = /^(?:con|prn|aux|nul|com\d|lpt\d)$/i;
36
- const WINDOWS_FORBIDDEN_CHARS_REGEX = /[<>:"/\\|?*]/g;
37
- const UNIX_FORBIDDEN_CHARS_REGEX = /\//g;
38
- const TRIM_CHARS = /* @__PURE__ */ new Set([" ", " ", "."]);
39
- const hasExtension = (name, lastDotIndex) => lastDotIndex > 0 && lastDotIndex < name.length - 1;
40
- const truncateWithExtension = (name, maxLength) => {
41
- const lastDotIndex = name.lastIndexOf(".");
42
- if (!hasExtension(name, lastDotIndex)) {
43
- return name.slice(0, maxLength);
44
- }
45
- const baseName = name.slice(0, lastDotIndex);
46
- const extension = name.slice(lastDotIndex);
47
- const maxBaseLength = maxLength - extension.length;
48
- return maxBaseLength > 0 ? `${baseName.slice(0, maxBaseLength)}${extension}` : name.slice(0, maxLength);
49
- };
50
- const trimSpacesAndPeriods = (input) => {
51
- let start = 0;
52
- let end = input.length;
53
- while (start < end) {
54
- const char = input[start];
55
- if (char === void 0 || !TRIM_CHARS.has(char)) {
56
- break;
57
- }
58
- start += 1;
59
- }
60
- while (end > start) {
61
- const char = input[end - 1];
62
- if (char === void 0 || !TRIM_CHARS.has(char)) {
63
- break;
64
- }
65
- end -= 1;
66
- }
67
- return input.slice(start, end);
68
- };
69
- const cleanWindowsName = (name) => {
70
- const lastDotIndex = name.lastIndexOf(".");
71
- if (hasExtension(name, lastDotIndex)) {
72
- const baseName = name.slice(0, lastDotIndex);
73
- const extension = name.slice(lastDotIndex);
74
- let cleanedBaseName = baseName;
75
- while (cleanedBaseName.length > 0) {
76
- const char = cleanedBaseName.at(-1);
77
- if (char === void 0 || !TRIM_CHARS.has(char)) {
78
- break;
79
- }
80
- cleanedBaseName = cleanedBaseName.slice(0, -1);
81
- }
82
- if (cleanedBaseName.length === 0) {
83
- return extension.slice(1);
84
- }
85
- return `${cleanedBaseName}${extension}`;
86
- }
87
- let cleaned = name;
88
- while (cleaned.length > 0) {
89
- const char = cleaned.at(-1);
90
- if (char === void 0 || !TRIM_CHARS.has(char)) {
91
- break;
92
- }
93
- cleaned = cleaned.slice(0, -1);
94
- }
95
- return cleaned;
96
- };
97
- const isWindowsReservedName = (name) => {
98
- const lastDotIndex = name.lastIndexOf(".");
99
- if (hasExtension(name, lastDotIndex)) {
100
- return false;
101
- }
102
- if (WINDOWS_SPECIAL_NAMES_REGEX.test(name)) {
103
- return true;
104
- }
105
- let trimmed = name;
106
- while (trimmed.length > 0) {
107
- const char = trimmed.at(-1);
108
- if (char === void 0 || !TRIM_CHARS.has(char)) {
109
- break;
110
- }
111
- trimmed = trimmed.slice(0, -1);
112
- }
113
- if (trimmed.length > 0 && WINDOWS_SPECIAL_NAMES_REGEX.test(trimmed)) {
114
- return true;
115
- }
116
- return false;
117
- };
118
- const cleanFat32Name = (name) => {
119
- const lastDotIndex = name.lastIndexOf(".");
120
- if (hasExtension(name, lastDotIndex)) {
121
- const baseName = name.slice(0, lastDotIndex);
122
- const extension = name.slice(lastDotIndex);
123
- const cleanedBaseName = trimSpacesAndPeriods(baseName);
124
- if (cleanedBaseName.length === 0) {
125
- return void 0;
126
- }
127
- return `${cleanedBaseName}${extension}`;
128
- }
129
- const trimmed = name.trim();
130
- if (trimmed.length > 0 && trimmed[0] === "." && trimmed.length <= 5) {
131
- const secondDotIndex = trimmed.indexOf(".", 1);
132
- if (secondDotIndex === -1) {
133
- return void 0;
134
- }
135
- }
136
- const cleaned = trimSpacesAndPeriods(name);
137
- if (cleaned.length === 0) {
138
- return void 0;
139
- }
140
- return cleaned;
141
- };
142
- const getFileSystemType = (options) => {
143
- const filesystem = options?.filesystem ?? "auto";
144
- if (filesystem === "auto") {
145
- return platform === "win32" ? "win32" : "unix";
146
- }
147
- if (filesystem === "darwin") {
148
- return "unix";
149
- }
150
- return filesystem;
151
- };
152
- const sanitize = (name, options) => {
153
- if (typeof name !== "string" || name.length === 0) {
154
- return FALLBACK_NAME;
155
- }
156
- const fileSystemType = getFileSystemType(options);
157
- let sanitized = name;
158
- sanitized = sanitized.replace(CONTROL_CHARS_REGEX, "");
159
- if (sanitized.length === 0) {
160
- return FALLBACK_NAME;
161
- }
162
- sanitized = sanitized.replace(RELATIVE_PATHS_REGEX, "");
163
- if (sanitized.length === 0) {
164
- return FALLBACK_NAME;
165
- }
166
- if (fileSystemType === "win32" || fileSystemType === "fat32") {
167
- const lastDotIndex = sanitized.lastIndexOf(".");
168
- if (!hasExtension(sanitized, lastDotIndex) && WINDOWS_SPECIAL_NAMES_REGEX.test(sanitized)) {
169
- return FALLBACK_NAME;
170
- }
171
- }
172
- sanitized = fileSystemType === "win32" || fileSystemType === "fat32" ? sanitized.replaceAll(WINDOWS_FORBIDDEN_CHARS_REGEX, (char) => REPLACEMENT_CHARACTERS[char] ?? "") : sanitized.replaceAll(UNIX_FORBIDDEN_CHARS_REGEX, REPLACEMENT_CHARACTERS["/"]);
173
- sanitized = sanitized.trim();
174
- if (fileSystemType === "win32" || fileSystemType === "fat32") {
175
- if (isWindowsReservedName(sanitized)) {
176
- return FALLBACK_NAME;
177
- }
178
- if (fileSystemType === "win32") {
179
- sanitized = cleanWindowsName(sanitized);
180
- if (sanitized.length === 0) {
181
- return FALLBACK_NAME;
182
- }
183
- }
184
- }
185
- if (fileSystemType === "fat32") {
186
- const cleaned = cleanFat32Name(sanitized);
187
- if (cleaned === void 0) {
188
- return FALLBACK_NAME;
189
- }
190
- sanitized = cleaned;
191
- }
192
- if (sanitized.length === 0) {
193
- return FALLBACK_NAME;
194
- }
195
- const maxLength = options?.maxLength ?? MAX_LENGTH;
196
- if (sanitized.length > maxLength) {
197
- sanitized = truncateWithExtension(sanitized, maxLength);
198
- if (sanitized.length === 0) {
199
- return FALLBACK_NAME;
200
- }
201
- }
202
- return sanitized;
203
- };
204
-
205
- export { sanitize };
@@ -1,19 +0,0 @@
1
- import { INTERNAL_STRIP_JSON_REGEX } from './F_OK-MldBaGxb.js';
2
-
3
- const stripJsonComments = (jsonString, { whitespace = true } = {}) => (
4
- // This regular expression translates to:
5
- //
6
- // /quoted-string|line-comment|block-comment/g
7
- //
8
- // This means that comment characters inside of strings will match
9
- // as strings, not comments, so we can just skip the whole string
10
- // in the replacer function.
11
- jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {
12
- if (match.startsWith('"') || match[1] === "*" && !match.endsWith("*/")) {
13
- return match;
14
- }
15
- return whitespace ? match.replaceAll(/\S/g, " ") : "";
16
- })
17
- );
18
-
19
- export { stripJsonComments as default };
@@ -1,19 +0,0 @@
1
- const encoder = new TextEncoder();
2
- const toUint8Array = (contents) => {
3
- if (contents instanceof Uint8Array) {
4
- return contents;
5
- }
6
- if (typeof contents === "string") {
7
- return encoder.encode(contents);
8
- }
9
- if (contents instanceof ArrayBuffer) {
10
- return new Uint8Array(contents);
11
- }
12
- if (ArrayBuffer.isView(contents)) {
13
- const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);
14
- return new Uint8Array(bytes);
15
- }
16
- throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.");
17
- };
18
-
19
- export { toUint8Array as t };
@@ -1,145 +0,0 @@
1
- import { PathLike, Dirent } from 'node:fs';
2
- import { GlobOptions as GlobOptions$1 } from 'tinyglobby';
3
- import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, CreateNodeOptions, ToStringOptions } from './options';
4
- declare const F_OK: number;
5
- declare const R_OK: number;
6
- declare const W_OK: number;
7
- declare const X_OK: number;
8
- declare const FIND_UP_STOP: symbol;
9
- type ColorizeMethod = (value: string) => string;
10
- type JsoncParseOptions = {
11
- allowEmptyContent?: boolean;
12
- allowTrailingComma?: boolean;
13
- disallowComments?: boolean;
14
- };
15
- type JsoncFormattingOptions = {
16
- eol?: string;
17
- insertFinalNewline?: boolean;
18
- insertSpaces?: boolean;
19
- keepLines?: boolean;
20
- tabSize?: number;
21
- };
22
- type IniEncodeOptions = {
23
- align?: boolean;
24
- bracketedArray?: boolean;
25
- newline?: boolean;
26
- platform?: string;
27
- section?: string;
28
- sort?: boolean;
29
- whitespace?: boolean;
30
- };
31
- type Json5Replacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
32
- type GlobOptions = Omit<GlobOptions$1, "patterns">;
33
- interface WalkOptions {
34
- extensions?: string[];
35
- followSymlinks?: boolean;
36
- includeDirs?: boolean;
37
- includeFiles?: boolean;
38
- includeSymlinks?: boolean;
39
- match?: (RegExp | string)[];
40
- maxDepth?: number;
41
- skip?: (RegExp | string)[];
42
- }
43
- interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
44
- path: string;
45
- }
46
- type CompressionType = "brotli" | "gzip" | "none";
47
- type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
48
- type ReadFileOptions<C> = {
49
- buffer?: boolean;
50
- compression?: C;
51
- encoding?: ReadFileEncoding;
52
- flag?: number | string;
53
- };
54
- type ContentType<O = undefined> = O extends {
55
- buffer: true;
56
- } ? Buffer : string;
57
- type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
58
- type CodeFrameLocation = {
59
- column?: number;
60
- line: number;
61
- };
62
- type CodeFrameOptions = {
63
- color?: {
64
- gutter?: ColorizeMethod;
65
- marker?: ColorizeMethod;
66
- message?: ColorizeMethod;
67
- };
68
- };
69
- type ReadJsonOptions = CodeFrameOptions & {
70
- beforeParse?: (source: string) => string;
71
- };
72
- type WriteFileOptions = {
73
- chown?: {
74
- gid: number;
75
- uid: number;
76
- };
77
- encoding?: BufferEncoding | null;
78
- flag?: string;
79
- mode?: number;
80
- overwrite?: boolean;
81
- recursive?: boolean;
82
- };
83
- type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
84
- type YamlReplacer = JsonReplacer;
85
- type WriteJsonOptions = WriteFileOptions & {
86
- detectIndent?: boolean;
87
- indent?: number | string;
88
- replacer?: JsonReplacer;
89
- stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
90
- };
91
- type FindUpOptions = {
92
- allowSymlinks?: boolean;
93
- cwd?: URL | string;
94
- stopAt?: URL | string;
95
- type?: "directory" | "file";
96
- };
97
- type FindUpNameFnResult = PathLike | Promise<PathLike | typeof FIND_UP_STOP> | typeof FIND_UP_STOP | undefined;
98
- type FindUpName = string[] | string | ((directory: string) => FindUpNameFnResult);
99
- type FindUpNameSyncFnResult = PathLike | typeof FIND_UP_STOP | undefined;
100
- type FindUpNameSync = string[] | string | ((directory: string) => FindUpNameSyncFnResult);
101
- type RetryOptions = {
102
- maxRetries?: number;
103
- retryDelay?: number;
104
- };
105
- type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
106
- type YamlReviver = (key: unknown, value: unknown) => unknown;
107
- type WriteYamlExtras = {
108
- replacer?: JsonReplacer;
109
- space?: number | string;
110
- };
111
- type WriteYamlOptions = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions & WriteFileOptions & WriteYamlExtras;
112
- type ReadTomlOptions<C> = ReadFileOptions<C>;
113
- type WriteTomlOptions = WriteFileOptions;
114
- type ReadJsoncExtras = {
115
- beforeParse?: (source: string) => string;
116
- };
117
- type ReadJsoncOptions<C> = CodeFrameOptions & JsoncParseOptions & ReadFileOptions<C> & ReadJsoncExtras;
118
- type WriteJsoncOptions = WriteFileOptions & {
119
- detectIndent?: boolean;
120
- formattingOptions?: JsoncFormattingOptions;
121
- indent?: number | string;
122
- preserveComments?: boolean;
123
- replacer?: JsonReplacer;
124
- };
125
- type Json5Reviver = (this: unknown, key: string, value: unknown) => unknown;
126
- type ReadJson5Extras = {
127
- beforeParse?: (source: string) => string;
128
- };
129
- type ReadJson5Options<C> = CodeFrameOptions & ReadFileOptions<C> & ReadJson5Extras;
130
- type WriteJson5Options = WriteFileOptions & {
131
- detectIndent?: boolean;
132
- indent?: number | string;
133
- quote?: string;
134
- replacer?: Json5Replacer;
135
- };
136
- type ReadIniOptions<C> = ReadFileOptions<C> & {
137
- bracketedArray?: boolean;
138
- };
139
- type IniLineEnding = "\n" | "\r\n";
140
- type WriteIniExtras = {
141
- eol?: IniLineEnding;
142
- preserveStyle?: boolean;
143
- };
144
- type WriteIniOptions = IniEncodeOptions & WriteFileOptions & WriteIniExtras;
145
- export { CodeFrameLocation as A, FIND_UP_STOP as B, CompressionType as C, F_OK as D, FindUpNameFnResult as E, FindUpName as F, GlobOptions as G, FindUpNameSyncFnResult as H, IniEncodeOptions as I, JsonReviver as J, R_OK as K, ReadFileEncoding as L, W_OK as M, ReadTomlOptions as R, WriteTomlOptions as W, X_OK as X, YamlReviver as Y, CodeFrameOptions as a, ReadJson5Options as b, Json5Reviver as c, WriteJson5Options as d, Json5Replacer as e, ReadJsoncOptions as f, WriteJsoncOptions as g, JsoncFormattingOptions as h, JsoncParseOptions as i, ReadIniOptions as j, WriteIniOptions as k, IniLineEnding as l, ReadYamlOptions as m, WriteYamlOptions as n, JsonReplacer as o, YamlReplacer as p, WalkOptions as q, FindUpOptions as r, FindUpNameSync as s, WalkEntry as t, ReadFileOptions as u, ContentType as v, ReadJsonOptions as w, RetryOptions as x, WriteFileOptions as y, WriteJsonOptions as z };
@@ -1,124 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- readdir,
22
- realpath,
23
- stat
24
- } = __cjs_getBuiltinModule("node:fs/promises");
25
- import { resolve, join, normalize, basename } from '@visulima/path';
26
- import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DER5A43G.js';
28
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
-
31
- const _createWalkEntry = async (path) => {
32
- const normalizePath = normalize(path);
33
- const name = basename(normalizePath);
34
- const info = await stat(normalizePath);
35
- return {
36
- isDirectory: () => info.isDirectory(),
37
- isFile: () => info.isFile(),
38
- isSymbolicLink: () => info.isSymbolicLink(),
39
- name,
40
- path: normalizePath
41
- };
42
- };
43
- async function* walk(directory, {
44
- extensions,
45
- followSymlinks = false,
46
- includeDirs: includeDirectories = true,
47
- includeFiles = true,
48
- includeSymlinks = true,
49
- match,
50
- maxDepth = Number.POSITIVE_INFINITY,
51
- skip
52
- } = {}) {
53
- assertValidFileOrDirectoryPath(directory);
54
- if (maxDepth < 0) {
55
- return;
56
- }
57
- const mappedMatch = match ? match.map(
58
- // eslint-disable-next-line no-confusing-arrow
59
- (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
60
- ) : void 0;
61
- const mappedSkip = skip ? skip.map(
62
- // eslint-disable-next-line no-confusing-arrow
63
- (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
64
- ) : void 0;
65
- const resolvedDirectory = resolve(toPath(directory));
66
- directory = resolvedDirectory;
67
- if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
68
- yield await _createWalkEntry(directory);
69
- }
70
- if (maxDepth < 1 || !walkInclude(directory, void 0, void 0, mappedSkip)) {
71
- return;
72
- }
73
- try {
74
- const entries = await readdir(directory, {
75
- withFileTypes: true
76
- });
77
- for (const entry of entries) {
78
- let path = join(directory, entry.name);
79
- if (entry.isSymbolicLink()) {
80
- if (followSymlinks) {
81
- path = await realpath(path);
82
- } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
83
- yield {
84
- isDirectory: () => entry.isDirectory(),
85
- isFile: () => entry.isFile(),
86
- isSymbolicLink: () => entry.isSymbolicLink(),
87
- name: entry.name,
88
- path
89
- };
90
- continue;
91
- } else {
92
- continue;
93
- }
94
- }
95
- if (entry.isDirectory()) {
96
- yield* walk(path, {
97
- extensions,
98
- followSymlinks,
99
- includeDirs: includeDirectories,
100
- includeFiles,
101
- includeSymlinks,
102
- match: mappedMatch,
103
- maxDepth: maxDepth - 1,
104
- skip: mappedSkip
105
- });
106
- } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
107
- yield {
108
- isDirectory: () => entry.isDirectory(),
109
- isFile: () => entry.isFile(),
110
- isSymbolicLink: () => entry.isSymbolicLink(),
111
- name: entry.name,
112
- path
113
- };
114
- }
115
- }
116
- } catch (error) {
117
- if (error instanceof WalkError) {
118
- throw error;
119
- }
120
- throw new WalkError(error, directory);
121
- }
122
- }
123
-
124
- export { walk as default };
@@ -1,16 +0,0 @@
1
- const globToRegExp = (glob) => {
2
- const reString = glob.replace(/\.\*/g, ".([^/]*)").replace(/\*\*/g, "(.*)").replace(/(?<!\.)\*(?!\*)/g, "([^/]*)").replace(/\?/g, "[^/]").replace(/\.(?!\*)/g, String.raw`\.`).replace(/\{/g, "(").replace(/\}/g, ")").replace(/,/g, "|").replace(/\[!(.*?)\]/g, "[^$1]");
3
- return new RegExp(`^${reString}$`);
4
- };
5
-
6
- const walkInclude = (path, extensions, match, skip) => {
7
- if (Array.isArray(extensions) && extensions.length > 0 && !extensions.some((extension) => path.endsWith(extension))) {
8
- return false;
9
- }
10
- if (match && !match.some((pattern) => pattern.test(path))) {
11
- return false;
12
- }
13
- return !skip?.some((pattern) => pattern.test(path));
14
- };
15
-
16
- export { globToRegExp as g, walkInclude as w };
@@ -1,123 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- readdirSync,
22
- realpathSync,
23
- statSync
24
- } = __cjs_getBuiltinModule("node:fs");
25
- import { resolve, join, normalize, basename } from '@visulima/path';
26
- import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DER5A43G.js';
28
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
-
31
- const _createWalkEntry = (path) => {
32
- const normalizePath = normalize(path);
33
- const info = statSync(normalizePath);
34
- return {
35
- isDirectory: () => info.isDirectory(),
36
- isFile: () => info.isFile(),
37
- isSymbolicLink: () => info.isSymbolicLink(),
38
- name: basename(normalizePath),
39
- path: normalizePath
40
- };
41
- };
42
- function* walkSync(directory, {
43
- extensions,
44
- followSymlinks = false,
45
- includeDirs: includeDirectories = true,
46
- includeFiles = true,
47
- includeSymlinks = true,
48
- match,
49
- maxDepth = Number.POSITIVE_INFINITY,
50
- skip
51
- } = {}) {
52
- assertValidFileOrDirectoryPath(directory);
53
- if (maxDepth < 0) {
54
- return;
55
- }
56
- const mappedMatch = match ? match.map(
57
- // eslint-disable-next-line no-confusing-arrow
58
- (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
59
- ) : void 0;
60
- const mappedSkip = skip ? skip.map(
61
- // eslint-disable-next-line no-confusing-arrow
62
- (pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern
63
- ) : void 0;
64
- const resolvedDirectory = resolve(toPath(directory));
65
- directory = resolvedDirectory;
66
- if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
67
- yield _createWalkEntry(directory);
68
- }
69
- if (maxDepth < 1 || !walkInclude(directory, void 0, void 0, mappedSkip)) {
70
- return;
71
- }
72
- try {
73
- const entries = readdirSync(directory, {
74
- withFileTypes: true
75
- });
76
- for (const entry of entries) {
77
- let path = join(directory, entry.name);
78
- if (entry.isSymbolicLink()) {
79
- if (followSymlinks) {
80
- path = realpathSync(path);
81
- } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
82
- yield {
83
- isDirectory: () => entry.isDirectory(),
84
- isFile: () => entry.isFile(),
85
- isSymbolicLink: () => entry.isSymbolicLink(),
86
- name: entry.name,
87
- path: normalize(path)
88
- };
89
- continue;
90
- } else {
91
- continue;
92
- }
93
- }
94
- if (entry.isDirectory()) {
95
- yield* walkSync(path, {
96
- extensions,
97
- followSymlinks,
98
- includeDirs: includeDirectories,
99
- includeFiles,
100
- includeSymlinks,
101
- match: mappedMatch,
102
- maxDepth: maxDepth - 1,
103
- skip: mappedSkip
104
- });
105
- } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
106
- yield {
107
- isDirectory: () => entry.isDirectory(),
108
- isFile: () => entry.isFile(),
109
- isSymbolicLink: () => entry.isSymbolicLink(),
110
- name: entry.name,
111
- path: normalize(path)
112
- };
113
- }
114
- }
115
- } catch (error) {
116
- if (error instanceof WalkError) {
117
- throw error;
118
- }
119
- throw new WalkError(error, directory);
120
- }
121
- }
122
-
123
- export { walkSync as default };