@visulima/fs 5.0.0-alpha.2 → 5.0.0-alpha.21

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 (223) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/LICENSE.md +208 -131
  3. package/dist/eol.d.ts +31 -30
  4. package/dist/eol.js +3 -26
  5. package/dist/error.d.ts +273 -7
  6. package/dist/error.js +1 -7
  7. package/dist/glob-parent.d.ts +35 -0
  8. package/dist/glob-parent.js +1 -0
  9. package/dist/glob.d.ts +4 -0
  10. package/dist/glob.js +1 -0
  11. package/dist/index.d.ts +858 -36
  12. package/dist/index.js +1 -33
  13. package/dist/ini.d.ts +70 -0
  14. package/dist/ini.js +1 -0
  15. package/dist/is-glob.d.ts +34 -0
  16. package/dist/is-glob.js +1 -0
  17. package/dist/json5.d.ts +36 -0
  18. package/dist/json5.js +1 -0
  19. package/dist/jsonc.d.ts +65 -0
  20. package/dist/jsonc.js +1 -0
  21. package/dist/match.d.ts +46 -0
  22. package/dist/match.js +1 -0
  23. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
  24. package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
  25. package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
  26. package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
  27. package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
  28. package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
  29. package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
  30. package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
  31. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  32. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
  33. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
  34. package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
  35. package/dist/packem_shared/collect-2KPTpCdX.js +1 -0
  36. package/dist/packem_shared/collectSync-BX55r_BH.js +1 -0
  37. package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
  38. package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
  39. package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
  40. package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
  41. package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
  42. package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
  43. package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
  44. package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
  45. package/dist/packem_shared/ensureSymlink-D50kj2zl.js +1 -0
  46. package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
  47. package/dist/packem_shared/findUp-BT07y_Me.js +1 -0
  48. package/dist/packem_shared/findUpSync-BvZiYsKJ.js +1 -0
  49. package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
  50. package/dist/packem_shared/glob-MHJQjR39.js +1 -0
  51. package/dist/packem_shared/glob-sync.d-ODRbh6wE.d.ts +54 -0
  52. package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
  53. package/dist/packem_shared/index-CYIVJA0W.js +1 -0
  54. package/dist/packem_shared/index-DrapuBsB.js +1 -0
  55. package/dist/packem_shared/index-K-NNTkpb.js +11 -0
  56. package/dist/packem_shared/index-yGx8uzZs.js +1 -0
  57. package/dist/packem_shared/indexToLineColumn-BRSZFC6I-BKj3uzZt.js +6 -0
  58. package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
  59. package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
  60. package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
  61. package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
  62. package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
  63. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  64. package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
  65. package/dist/packem_shared/move-LmP6P9sn.js +1 -0
  66. package/dist/packem_shared/parseJson-Xx6vHYbv.js +1 -0
  67. package/dist/packem_shared/readFile-BAVMZg5e.js +1 -0
  68. package/dist/packem_shared/readFileSync-CGmzMUF2.js +1 -0
  69. package/dist/packem_shared/readIni-Cfl6HmTS.js +1 -0
  70. package/dist/packem_shared/readIniSync-DPg4UD0P.js +1 -0
  71. package/dist/packem_shared/readJson-kPx68Wv1.js +1 -0
  72. package/dist/packem_shared/readJson5-pXTL9nUE.js +1 -0
  73. package/dist/packem_shared/readJson5Sync-BedQc292.js +1 -0
  74. package/dist/packem_shared/readJsonSync-_HXNI3Se.js +1 -0
  75. package/dist/packem_shared/readJsonc-BzvuAXbT.js +1 -0
  76. package/dist/packem_shared/readJsoncSync-CVG1_QnX.js +1 -0
  77. package/dist/packem_shared/readToml-BO5CZK2P.js +1 -0
  78. package/dist/packem_shared/readTomlSync-1fKo0R52.js +1 -0
  79. package/dist/packem_shared/readYaml-DjK_Vqj1.js +1 -0
  80. package/dist/packem_shared/readYamlSync-C3h6KA2c.js +1 -0
  81. package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
  82. package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
  83. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
  84. package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
  85. package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
  86. package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
  87. package/dist/packem_shared/types.d-CHp56oCv.d.ts +1660 -0
  88. package/dist/packem_shared/walk-D01Qmmvz.js +1 -0
  89. package/dist/packem_shared/walk-include-DCiVAwMP.js +1 -0
  90. package/dist/packem_shared/walkSync-BknSdmKD.js +1 -0
  91. package/dist/packem_shared/writeFile-DNGaDOMX.js +1 -0
  92. package/dist/packem_shared/writeFileSync-CE1i-eMA.js +1 -0
  93. package/dist/packem_shared/writeIni-DG7U4ji0.js +4 -0
  94. package/dist/packem_shared/writeIniSync-Ldt6HFLb.js +4 -0
  95. package/dist/packem_shared/writeJson-BkGlq1Kv.js +4 -0
  96. package/dist/packem_shared/writeJson5-Btud4sQh.js +4 -0
  97. package/dist/packem_shared/writeJson5Sync-Iln3i1IV.js +4 -0
  98. package/dist/packem_shared/writeJsonSync-HndmyvEK.js +4 -0
  99. package/dist/packem_shared/writeJsonc-9oiamG16.js +4 -0
  100. package/dist/packem_shared/writeJsoncSync-BHBziPiK.js +4 -0
  101. package/dist/packem_shared/writeToml-Cj57wZ8B.js +1 -0
  102. package/dist/packem_shared/writeTomlSync-B34ZZp0e.js +1 -0
  103. package/dist/packem_shared/writeYaml-BhQX2yN9.js +1 -0
  104. package/dist/packem_shared/writeYamlSync-DG01FBeC.js +1 -0
  105. package/dist/size.d.ts +246 -246
  106. package/dist/size.js +1 -144
  107. package/dist/toml.d.ts +63 -0
  108. package/dist/toml.js +1 -0
  109. package/dist/utils.d.ts +103 -6
  110. package/dist/utils.js +1 -6
  111. package/dist/yaml.d.ts +13 -5
  112. package/dist/yaml.js +1 -4
  113. package/package.json +89 -36
  114. package/dist/constants.d.ts +0 -42
  115. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  116. package/dist/ensure/ensure-dir.d.ts +0 -14
  117. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  118. package/dist/ensure/ensure-file.d.ts +0 -27
  119. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  120. package/dist/ensure/ensure-link.d.ts +0 -16
  121. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  122. package/dist/ensure/ensure-symlink.d.ts +0 -23
  123. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  124. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  125. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  126. package/dist/error/already-exists-error.d.ts +0 -39
  127. package/dist/error/directory-error.d.ts +0 -47
  128. package/dist/error/json-error.d.ts +0 -52
  129. package/dist/error/not-empty-error.d.ts +0 -51
  130. package/dist/error/not-found-error.d.ts +0 -44
  131. package/dist/error/permission-error.d.ts +0 -45
  132. package/dist/error/walk-error.d.ts +0 -51
  133. package/dist/find/collect-sync.d.ts +0 -31
  134. package/dist/find/collect.d.ts +0 -35
  135. package/dist/find/find-up-sync.d.ts +0 -42
  136. package/dist/find/find-up.d.ts +0 -46
  137. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  138. package/dist/find/utils/walk-include.d.ts +0 -2
  139. package/dist/find/walk-sync.d.ts +0 -34
  140. package/dist/find/walk.d.ts +0 -37
  141. package/dist/is-accessible-sync.d.ts +0 -3
  142. package/dist/is-accessible.d.ts +0 -29
  143. package/dist/move/index.d.ts +0 -68
  144. package/dist/move/types.d.ts +0 -36
  145. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  146. package/dist/move/utils/internal-move-file.d.ts +0 -3
  147. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  148. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  149. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  150. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  151. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  152. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  153. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  154. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  155. package/dist/packem_shared/WalkError-DUdQd6FT.js +0 -24
  156. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  157. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  158. package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
  159. package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
  160. package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
  161. package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
  162. package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
  163. package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
  164. package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
  165. package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
  166. package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
  167. package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
  168. package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
  169. package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
  170. package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
  171. package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
  172. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  173. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  174. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  175. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  176. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  177. package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +0 -62
  178. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  179. package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
  180. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  181. package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
  182. package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
  183. package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
  184. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  185. package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
  186. package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
  187. package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
  188. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  189. package/dist/packem_shared/sanitize-lOzE6k2A.js +0 -205
  190. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  191. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  192. package/dist/packem_shared/walk-BhTbpr3y.js +0 -115
  193. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  194. package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
  195. package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
  196. package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
  197. package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
  198. package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
  199. package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
  200. package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
  201. package/dist/read/read-file-sync.d.ts +0 -37
  202. package/dist/read/read-file.d.ts +0 -41
  203. package/dist/read/read-json-sync.d.ts +0 -5
  204. package/dist/read/read-json.d.ts +0 -5
  205. package/dist/read/read-yaml-sync.d.ts +0 -4
  206. package/dist/read/read-yaml.d.ts +0 -4
  207. package/dist/remove/empty-dir-sync.d.ts +0 -23
  208. package/dist/remove/empty-dir.d.ts +0 -28
  209. package/dist/remove/remove-sync.d.ts +0 -27
  210. package/dist/remove/remove.d.ts +0 -32
  211. package/dist/sanitize.d.ts +0 -31
  212. package/dist/types.d.ts +0 -304
  213. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  214. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  215. package/dist/utils/parse-json.d.ts +0 -5
  216. package/dist/utils/strip-json-comments.d.ts +0 -44
  217. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  218. package/dist/write/write-file-sync.d.ts +0 -30
  219. package/dist/write/write-file.d.ts +0 -30
  220. package/dist/write/write-json-sync.d.ts +0 -29
  221. package/dist/write/write-json.d.ts +0 -30
  222. package/dist/write/write-yaml-sync.d.ts +0 -4
  223. package/dist/write/write-yaml.d.ts +0 -4
@@ -1,100 +0,0 @@
1
- const INDENT_REGEX = /^(?:( )+|\t+)/;
2
- const INDENT_TYPE_SPACE = "space";
3
- const INDENT_TYPE_TAB = "tab";
4
- function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
5
- return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1;
6
- }
7
- function makeIndentsMap(string, ignoreSingleSpaces) {
8
- const indents = /* @__PURE__ */ new Map();
9
- let previousSize = 0;
10
- let previousIndentType;
11
- let key;
12
- for (const line of string.split(/\n/g)) {
13
- if (!line) {
14
- continue;
15
- }
16
- const matches = line.match(INDENT_REGEX);
17
- if (matches === null) {
18
- previousSize = 0;
19
- previousIndentType = "";
20
- } else {
21
- const indent = matches[0].length;
22
- const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
23
- if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) {
24
- continue;
25
- }
26
- if (indentType !== previousIndentType) {
27
- previousSize = 0;
28
- }
29
- previousIndentType = indentType;
30
- let use = 1;
31
- let weight = 0;
32
- const indentDifference = indent - previousSize;
33
- previousSize = indent;
34
- if (indentDifference === 0) {
35
- use = 0;
36
- weight = 1;
37
- } else {
38
- const absoluteIndentDifference = Math.abs(indentDifference);
39
- if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) {
40
- continue;
41
- }
42
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
43
- }
44
- const entry = indents.get(key);
45
- indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]);
46
- }
47
- }
48
- return indents;
49
- }
50
- function encodeIndentsKey(indentType, indentAmount) {
51
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
52
- return typeCharacter + String(indentAmount);
53
- }
54
- function decodeIndentsKey(indentsKey) {
55
- const keyHasTypeSpace = indentsKey[0] === "s";
56
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
57
- const amount = Number(indentsKey.slice(1));
58
- return { type, amount };
59
- }
60
- function getMostUsedKey(indents) {
61
- let result;
62
- let maxUsed = 0;
63
- let maxWeight = 0;
64
- for (const [key, [usedCount, weight]] of indents) {
65
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
66
- maxUsed = usedCount;
67
- maxWeight = weight;
68
- result = key;
69
- }
70
- }
71
- return result;
72
- }
73
- function makeIndentString(type, amount) {
74
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
75
- return indentCharacter.repeat(amount);
76
- }
77
- function detectIndent(string) {
78
- if (typeof string !== "string") {
79
- throw new TypeError("Expected a string");
80
- }
81
- let indents = makeIndentsMap(string, true);
82
- if (indents.size === 0) {
83
- indents = makeIndentsMap(string, false);
84
- }
85
- const keyOfMostUsedIndent = getMostUsedKey(indents);
86
- let type;
87
- let amount = 0;
88
- let indent = "";
89
- if (keyOfMostUsedIndent !== void 0) {
90
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
91
- indent = makeIndentString(type, amount);
92
- }
93
- return {
94
- amount,
95
- type,
96
- indent
97
- };
98
- }
99
-
100
- export { detectIndent as d };
@@ -1,3 +0,0 @@
1
- const isStatsIdentical = (sourceStat, destinationStat) => !!destinationStat.ino && !!destinationStat.dev && destinationStat.ino === sourceStat.ino && destinationStat.dev === sourceStat.dev;
2
-
3
- export { isStatsIdentical as i };
@@ -1,38 +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
- access
22
- } = __cjs_getBuiltinModule("node:fs/promises");
23
- import { toPath } from '@visulima/path/utils';
24
- import { F_OK } from './F_OK-MldBaGxb.js';
25
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
26
-
27
- async function isAccessible(path, mode = F_OK) {
28
- assertValidFileOrDirectoryPath(path);
29
- path = toPath(path);
30
- try {
31
- await access(path, mode);
32
- return true;
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- export { isAccessible as default };
@@ -1,38 +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
- accessSync
22
- } = __cjs_getBuiltinModule("node:fs");
23
- import { toPath } from '@visulima/path/utils';
24
- import { F_OK } from './F_OK-MldBaGxb.js';
25
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
26
-
27
- function isAccessibleSync(path, mode = F_OK) {
28
- assertValidFileOrDirectoryPath(path);
29
- path = toPath(path);
30
- try {
31
- accessSync(path, mode);
32
- return true;
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- export { isAccessibleSync as default };
@@ -1,62 +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 y = __cjs_getBuiltinModule("fs");
21
- const h = __cjs_getBuiltinModule("os");
22
- const u = __cjs_getBuiltinModule("path");
23
-
24
- var l = Object.defineProperty;
25
- var s = (i, t) => l(i, "name", { value: t, configurable: true });
26
- const a = s((i) => {
27
- let t = "";
28
- for (let e = 0; e < i.length; e += 1) {
29
- const r = i[e], o = r.toUpperCase();
30
- t += r === o ? r.toLowerCase() : o;
31
- }
32
- return t;
33
- }, "invertCase");
34
- const c = /* @__PURE__ */ new Map();
35
- const p = s((i, t) => {
36
- const e = u.join(i, `.is-fs-case-sensitive-test-${process.pid}`);
37
- try {
38
- return t.writeFileSync(e, ""), !t.existsSync(a(e));
39
- } finally {
40
- try {
41
- t.unlinkSync(e);
42
- } catch {
43
- }
44
- }
45
- }, "checkDirectoryCaseWithWrite");
46
- const m = s((i, t, e) => {
47
- try {
48
- return p(i, e);
49
- } catch (r) {
50
- if (t === void 0) return p(h.tmpdir(), e);
51
- throw r;
52
- }
53
- }, "checkDirectoryCaseWithFallback");
54
- const S = s((i, t = y, e = true) => {
55
- const r = i ?? process.cwd();
56
- if (e && c.has(r)) return c.get(r);
57
- let o;
58
- const n = a(r);
59
- return n !== r && t.existsSync(r) ? o = !t.existsSync(n) : o = m(r, i, t), e && c.set(r, o), o;
60
- }, "isFsCaseSensitive");
61
-
62
- export { S as isFsCaseSensitive };
@@ -1,134 +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
- cwd
22
- } = __cjs_getProcess;
23
- import { toPath } from '@visulima/path/utils';
24
- const {
25
- mkdir,
26
- rename: rename$1,
27
- copyFile,
28
- unlink
29
- } = __cjs_getBuiltinModule("node:fs/promises");
30
- import { dirname, resolve } from '@visulima/path';
31
- import isAccessible from './isAccessible-DuVrTNFV.js';
32
- const {
33
- mkdirSync,
34
- renameSync: renameSync$1,
35
- copyFileSync,
36
- unlinkSync
37
- } = __cjs_getBuiltinModule("node:fs");
38
- import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
39
-
40
- class SameDirectoryError extends Error {
41
- constructor(source, destination) {
42
- super(`Source directory "${dirname(source)}" does not match destination directory "${dirname(destination)}"`);
43
- this.name = "SameDirectoryError";
44
- }
45
- }
46
- const validateSameDirectory = (source, destination) => {
47
- if (!source || !destination) {
48
- throw new Error("Source and destination paths must not be empty");
49
- }
50
- if (dirname(source) !== dirname(destination)) {
51
- throw new SameDirectoryError(source, destination);
52
- }
53
- };
54
-
55
- const internalMoveFile = async (sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
56
- if (cwd) {
57
- sourcePath = resolve(cwd, sourcePath);
58
- destinationPath = resolve(cwd, destinationPath);
59
- }
60
- if (validateDirectory) {
61
- validateSameDirectory(sourcePath, destinationPath);
62
- }
63
- if (!overwrite && await isAccessible(destinationPath)) {
64
- throw new Error(`The destination file exists: ${destinationPath}`);
65
- }
66
- await mkdir(dirname(destinationPath), {
67
- mode: directoryMode,
68
- recursive: true
69
- });
70
- try {
71
- await rename$1(sourcePath, destinationPath);
72
- } catch (error) {
73
- if (error.code === "EXDEV") {
74
- await copyFile(sourcePath, destinationPath);
75
- await unlink(sourcePath);
76
- } else {
77
- throw error;
78
- }
79
- }
80
- };
81
-
82
- const internalMoveFileSync = (sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
83
- if (cwd) {
84
- sourcePath = resolve(cwd, sourcePath);
85
- destinationPath = resolve(cwd, destinationPath);
86
- }
87
- if (validateDirectory) {
88
- validateSameDirectory(sourcePath, destinationPath);
89
- }
90
- if (!overwrite && isAccessibleSync(destinationPath)) {
91
- throw new Error(`The destination file exists: ${destinationPath}`);
92
- }
93
- mkdirSync(dirname(destinationPath), {
94
- mode: directoryMode,
95
- recursive: true
96
- });
97
- try {
98
- renameSync$1(sourcePath, destinationPath);
99
- } catch (error) {
100
- if (error.code === "EXDEV") {
101
- copyFileSync(sourcePath, destinationPath);
102
- unlinkSync(sourcePath);
103
- } else {
104
- throw error;
105
- }
106
- }
107
- };
108
-
109
- const move = async (sourcePath, destinationPath, options = {}) => {
110
- const internalOptions = {
111
- overwrite: true,
112
- validateDirectory: false,
113
- ...options,
114
- cwd: options.cwd ? toPath(options.cwd) : cwd()
115
- };
116
- await internalMoveFile(sourcePath, destinationPath, internalOptions);
117
- };
118
- const moveSync = (sourcePath, destinationPath, options) => {
119
- const internalOptions = { overwrite: true, validateDirectory: false, ...options };
120
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
121
- internalMoveFileSync(sourcePath, destinationPath, internalOptions);
122
- };
123
- const rename = async (source, destination, options) => {
124
- const internalOptions = { overwrite: true, ...options, validateDirectory: true };
125
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
126
- await internalMoveFile(source, destination, internalOptions);
127
- };
128
- const renameSync = (source, destination, options) => {
129
- const internalOptions = { overwrite: true, ...options, validateDirectory: true };
130
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
131
- internalMoveFileSync(source, destination, internalOptions);
132
- };
133
-
134
- export { move, moveSync, rename, renameSync };
@@ -1,231 +0,0 @@
1
- import JSONError from './JSONError-BkHRnInH.js';
2
-
3
- const normalizeLF = (code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n");
4
- const _process = globalThis.process || /* @__PURE__ */ Object.create(null);
5
- const processShims = {
6
- versions: {}
7
- };
8
- const process = new Proxy(_process, {
9
- get(target, property) {
10
- if (property in target) {
11
- return target[property];
12
- }
13
- if (property in processShims) {
14
- return processShims[property];
15
- }
16
- return void 0;
17
- }
18
- });
19
- const getMarkerLines = (loc, source, linesAbove, linesBelow) => {
20
- const startLoc = {
21
- column: 0,
22
- // @ts-expect-error Can be overwritten
23
- line: -1,
24
- ...loc.start
25
- };
26
- const endLoc = {
27
- ...startLoc,
28
- ...loc.end
29
- };
30
- const startLine = startLoc.line;
31
- const startColumn = startLoc.column;
32
- const endLine = endLoc.line;
33
- const endColumn = endLoc.column;
34
- let start = Math.max(startLine - (linesAbove + 1), 0);
35
- let end = Math.min(source.length, endLine + linesBelow);
36
- if (startLine === -1) {
37
- start = 0;
38
- }
39
- if (endLine === -1) {
40
- end = source.length;
41
- }
42
- const lineDiff = endLine - startLine;
43
- const markerLines = {};
44
- if (lineDiff) {
45
- for (let index = 0; index <= lineDiff; index++) {
46
- const lineNumber = index + startLine;
47
- if (!startColumn) {
48
- markerLines[lineNumber] = true;
49
- } else if (index === 0) {
50
- const sourceLength = source[lineNumber - 1]?.length;
51
- markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];
52
- } else if (index === lineDiff) {
53
- markerLines[lineNumber] = [0, endColumn];
54
- } else {
55
- const sourceLength = source[lineNumber - index]?.length;
56
- markerLines[lineNumber] = [0, sourceLength];
57
- }
58
- }
59
- } else if (startColumn === endColumn) {
60
- markerLines[startLine] = startColumn ? [startColumn, 0] : true;
61
- } else {
62
- markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];
63
- }
64
- return { end, markerLines, start };
65
- };
66
- const CODE_FRAME_POINTER = process.platform === "win32" && !process.env?.WT_SESSION ? ">" : "❯";
67
- const codeFrame = (source, loc, options) => {
68
- const config = {
69
- // grab 2 lines before, and 3 lines after focused line
70
- linesAbove: 2,
71
- linesBelow: 3,
72
- prefix: "",
73
- showGutter: true,
74
- tabWidth: 4,
75
- ...options,
76
- color: {
77
- gutter: (value) => value,
78
- marker: (value) => value,
79
- message: (value) => value,
80
- ...options?.color
81
- }
82
- };
83
- const hasColumns = loc.start && typeof loc.start.column === "number";
84
- let lines = normalizeLF(source).split("\n");
85
- if (typeof config?.tabWidth === "number") {
86
- lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
87
- }
88
- const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
89
- const numberMaxWidth = String(end).length;
90
- const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;
91
- let frame = lines.slice(start, end).map((line, index) => {
92
- const number = start + 1 + index;
93
- const hasMarker = markerLines[number];
94
- const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
95
- const lastMarkerLine = !markerLines[number + 1];
96
- const gutter = ` ${paddedNumber}${config.showGutter ? " |" : ""}`;
97
- if (hasMarker) {
98
- let markerLine = "";
99
- if (Array.isArray(hasMarker)) {
100
- const markerSpacing = line.replaceAll(/[^\t]/g, " ").slice(0, Math.max(hasMarker[0] - 1, 0));
101
- const numberOfMarkers = hasMarker[1] || 1;
102
- markerLine = [
103
- "\n ",
104
- config.prefix + colorizeGutter(gutter.replaceAll(/\d/g, " ")),
105
- " ",
106
- markerSpacing,
107
- colorizeMarker("^").repeat(numberOfMarkers)
108
- ].join("");
109
- if (lastMarkerLine && config.message) {
110
- markerLine += ` ${colorizeMessage(config.message)}`;
111
- }
112
- }
113
- return [config.prefix + colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
114
- }
115
- return `${config.prefix} ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
116
- }).join("\n");
117
- if (config.message && !hasColumns) {
118
- frame = `${config.prefix + " ".repeat(numberMaxWidth + 1) + config.message}
119
- ${frame}`;
120
- }
121
- return frame;
122
- };
123
-
124
- const binarySearch = (element, array) => {
125
- let m = 0;
126
- let n = array.length - 2;
127
- while (m < n) {
128
- const key = m + (n - m >> 1);
129
- if (element < array[key]) {
130
- n = key - 1;
131
- } else if (element >= array[key + 1]) {
132
- m = key + 1;
133
- } else {
134
- m = key;
135
- break;
136
- }
137
- }
138
- return m;
139
- };
140
- const getLineStartIndexes = (string_) => (
141
- // eslint-disable-next-line unicorn/no-array-reduce
142
- string_.split(/\n|\r(?!\n)/).reduce(
143
- (accumulator, current) => {
144
- accumulator.push(accumulator.at(-1) + current.length + 1);
145
- return accumulator;
146
- },
147
- [0]
148
- )
149
- );
150
- const indexToLineColumn = (input, index, options) => {
151
- if ((!Array.isArray(input) && typeof input !== "string" || (typeof input === "string" || Array.isArray(input)) && input.length === 0)) {
152
- return { column: 0, line: 0 };
153
- }
154
- if ((typeof index !== "number" || typeof input === "string" && index >= input.length || Array.isArray(input) && index + 1 >= input.at(-1))) {
155
- return { column: 0, line: 0 };
156
- }
157
- if (typeof input === "string") {
158
- const startIndexesOfEachLine = getLineStartIndexes(input);
159
- const line2 = binarySearch(index, startIndexesOfEachLine);
160
- return {
161
- column: index - startIndexesOfEachLine[line2] + 1,
162
- line: line2 + 1
163
- };
164
- }
165
- const line = binarySearch(index, input);
166
- return {
167
- column: index - input[line] + 1,
168
- line: line + 1
169
- };
170
- };
171
-
172
- const getCodePoint = (character) => String.raw`\u{${character.codePointAt(0).toString(16)}}`;
173
- const generateCodeFrame = (source, location, options) => codeFrame(
174
- source,
175
- { start: location },
176
- {
177
- tabWidth: false,
178
- ...options
179
- }
180
- );
181
- const getErrorLocation = (source, message) => {
182
- const match = /in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(message);
183
- if (!match) {
184
- return void 0;
185
- }
186
- let { column, index, line } = match.groups;
187
- if (line && column) {
188
- return { column: Number(column), line: Number(line) };
189
- }
190
- index = Number(index);
191
- if (index === source.length) {
192
- index = source.length - 1;
193
- }
194
- return indexToLineColumn(source, index);
195
- };
196
- const addCodePointToUnexpectedToken = (message) => message.replace(
197
- // The token is always quoted after Node.js 20, but we handle both cases for compatibility
198
- // eslint-disable-next-line regexp/no-potentially-useless-backreference
199
- /(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
200
- (_, _quote, token) => `"${token}"(${getCodePoint(token)})`
201
- );
202
- function parseJson(string, reviver, fileName, options) {
203
- if (typeof reviver === "string") {
204
- if (typeof fileName === "object") {
205
- options = fileName;
206
- }
207
- fileName = reviver;
208
- reviver = void 0;
209
- }
210
- let message;
211
- try {
212
- return JSON.parse(string, reviver);
213
- } catch (error) {
214
- message = error.message;
215
- }
216
- let location;
217
- if (string) {
218
- location = getErrorLocation(string, message);
219
- message = addCodePointToUnexpectedToken(message);
220
- } else {
221
- message += " while parsing empty string";
222
- }
223
- const jsonError = new JSONError(message);
224
- jsonError.fileName = fileName;
225
- if (location) {
226
- jsonError.codeFrame = generateCodeFrame(string, location, options);
227
- }
228
- throw jsonError;
229
- }
230
-
231
- export { parseJson as default };
@@ -1,65 +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
- readFile: readFile$1
22
- } = __cjs_getBuiltinModule("node:fs/promises");
23
- const {
24
- unzip,
25
- brotliDecompress
26
- } = __cjs_getBuiltinModule("node:zlib");
27
- import { toPath } from '@visulima/path/utils';
28
- import { R_OK } from './F_OK-MldBaGxb.js';
29
- import PermissionError from './PermissionError-CjoiJgip.js';
30
- import isAccessible from './isAccessible-DuVrTNFV.js';
31
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
32
-
33
- const decompressionMethods = {
34
- brotli: brotliDecompress,
35
- gzip: unzip,
36
- none: (buffer, callback) => {
37
- callback(null, buffer);
38
- }
39
- };
40
- const readFile = async (path, options) => {
41
- assertValidFileOrDirectoryPath(path);
42
- path = toPath(path);
43
- if (!await isAccessible(path)) {
44
- throw new PermissionError(`unable to read the non-accessible file: ${path}`);
45
- }
46
- if (!await isAccessible(path, R_OK)) {
47
- throw new Error(`Unable to read the non-readable file: ${path}`);
48
- }
49
- const { buffer, compression, encoding, flag } = options ?? {};
50
- return await readFile$1(path, flag ? { encoding, flag } : { encoding }).then(
51
- async (content) => await new Promise((resolve, reject) => {
52
- decompressionMethods[compression ?? "none"](content, (error, result) => {
53
- if (error) {
54
- reject(error);
55
- } else {
56
- resolve(buffer ? result : result.toString());
57
- }
58
- });
59
- })
60
- ).catch((error) => {
61
- throw error;
62
- });
63
- };
64
-
65
- export { readFile as default };