@visulima/fs 5.0.0-alpha.13 → 5.0.0-alpha.15

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 (186) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE.md +30 -0
  3. package/dist/eol.js +3 -26
  4. package/dist/error.js +1 -7
  5. package/dist/glob-parent.js +1 -90
  6. package/dist/glob.d.ts +2 -2
  7. package/dist/glob.js +1 -2
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +1 -38
  10. package/dist/ini.d.ts +2 -2
  11. package/dist/ini.js +1 -4
  12. package/dist/is-glob.js +1 -9
  13. package/dist/json5.d.ts +2 -2
  14. package/dist/json5.js +1 -4
  15. package/dist/jsonc.d.ts +2 -2
  16. package/dist/jsonc.js +1 -4
  17. package/dist/match.d.ts +1 -1
  18. package/dist/match.js +1 -15
  19. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
  20. package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
  21. package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
  22. package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
  23. package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
  24. package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
  25. package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
  26. package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
  27. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  28. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
  29. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
  30. package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
  31. package/dist/packem_shared/collect-2KPTpCdX.js +1 -0
  32. package/dist/packem_shared/collectSync-BX55r_BH.js +1 -0
  33. package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
  34. package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
  35. package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
  36. package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
  37. package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
  38. package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
  39. package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
  40. package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
  41. package/dist/packem_shared/ensureSymlink-D50kj2zl.js +1 -0
  42. package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
  43. package/dist/packem_shared/findUp-BT07y_Me.js +1 -0
  44. package/dist/packem_shared/findUpSync-BvZiYsKJ.js +1 -0
  45. package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
  46. package/dist/packem_shared/glob-MHJQjR39.js +1 -0
  47. package/dist/packem_shared/{glob-sync.d-Dsxhj3BW.d.ts → glob-sync.d-D2sDeSpa.d.ts} +1 -1
  48. package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
  49. package/dist/packem_shared/index-CYIVJA0W.js +1 -0
  50. package/dist/packem_shared/index-DrapuBsB.js +1 -0
  51. package/dist/packem_shared/index-K-NNTkpb.js +11 -0
  52. package/dist/packem_shared/index-yGx8uzZs.js +1 -0
  53. package/dist/packem_shared/indexToLineColumn-BRSZFC6I-BKj3uzZt.js +6 -0
  54. package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
  55. package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
  56. package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
  57. package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
  58. package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
  59. package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
  60. package/dist/packem_shared/move-LmP6P9sn.js +1 -0
  61. package/dist/packem_shared/parseJson-Xx6vHYbv.js +1 -0
  62. package/dist/packem_shared/readFile-BAVMZg5e.js +1 -0
  63. package/dist/packem_shared/readFileSync-CGmzMUF2.js +1 -0
  64. package/dist/packem_shared/readIni-Cfl6HmTS.js +1 -0
  65. package/dist/packem_shared/readIniSync-DPg4UD0P.js +1 -0
  66. package/dist/packem_shared/readJson-kPx68Wv1.js +1 -0
  67. package/dist/packem_shared/readJson5-pXTL9nUE.js +1 -0
  68. package/dist/packem_shared/readJson5Sync-BedQc292.js +1 -0
  69. package/dist/packem_shared/readJsonSync-_HXNI3Se.js +1 -0
  70. package/dist/packem_shared/readJsonc-BzvuAXbT.js +1 -0
  71. package/dist/packem_shared/readJsoncSync-CVG1_QnX.js +1 -0
  72. package/dist/packem_shared/readToml-BO5CZK2P.js +1 -0
  73. package/dist/packem_shared/readTomlSync-1fKo0R52.js +1 -0
  74. package/dist/packem_shared/readYaml-DjK_Vqj1.js +1 -0
  75. package/dist/packem_shared/readYamlSync-C3h6KA2c.js +1 -0
  76. package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
  77. package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
  78. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
  79. package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
  80. package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
  81. package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
  82. package/dist/packem_shared/{types.d-CixEXeyM.d.ts → types.d-DjZtAjkJ.d.ts} +26 -26
  83. package/dist/packem_shared/walk-D01Qmmvz.js +1 -0
  84. package/dist/packem_shared/walk-include-DCiVAwMP.js +1 -0
  85. package/dist/packem_shared/walkSync-BknSdmKD.js +1 -0
  86. package/dist/packem_shared/writeFile-DNGaDOMX.js +1 -0
  87. package/dist/packem_shared/writeFileSync-CE1i-eMA.js +1 -0
  88. package/dist/packem_shared/writeIni-DG7U4ji0.js +4 -0
  89. package/dist/packem_shared/writeIniSync-Ldt6HFLb.js +4 -0
  90. package/dist/packem_shared/writeJson-BkGlq1Kv.js +4 -0
  91. package/dist/packem_shared/writeJson5-Btud4sQh.js +4 -0
  92. package/dist/packem_shared/writeJson5Sync-Iln3i1IV.js +4 -0
  93. package/dist/packem_shared/writeJsonSync-HndmyvEK.js +4 -0
  94. package/dist/packem_shared/writeJsonc-9oiamG16.js +4 -0
  95. package/dist/packem_shared/writeJsoncSync-BHBziPiK.js +4 -0
  96. package/dist/packem_shared/writeToml-Cj57wZ8B.js +1 -0
  97. package/dist/packem_shared/writeTomlSync-B34ZZp0e.js +1 -0
  98. package/dist/packem_shared/writeYaml-BhQX2yN9.js +1 -0
  99. package/dist/packem_shared/writeYamlSync-DG01FBeC.js +1 -0
  100. package/dist/size.js +1 -146
  101. package/dist/toml.d.ts +1 -1
  102. package/dist/toml.js +1 -4
  103. package/dist/utils.d.ts +1 -1
  104. package/dist/utils.js +1 -6
  105. package/dist/yaml.d.ts +2 -2
  106. package/dist/yaml.js +1 -4
  107. package/package.json +22 -22
  108. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  109. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  110. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  111. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  112. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  113. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  114. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  115. package/dist/packem_shared/WalkError-DER5A43G.js +0 -24
  116. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  117. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  118. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  119. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
  120. package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
  121. package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
  122. package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
  123. package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
  124. package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
  125. package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
  126. package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
  127. package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
  128. package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
  129. package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
  130. package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
  131. package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
  132. package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
  133. package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
  134. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  135. package/dist/packem_shared/glob-DY8l7izD.js +0 -5
  136. package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
  137. package/dist/packem_shared/index-C8W8sfzP.js +0 -830
  138. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  139. package/dist/packem_shared/index-bhgnhm4u.js +0 -167
  140. package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
  141. package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
  142. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
  143. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  144. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  145. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  146. package/dist/packem_shared/isFsCaseSensitive-DunL7Iry.js +0 -62
  147. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
  148. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  149. package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
  150. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  151. package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
  152. package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
  153. package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
  154. package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
  155. package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
  156. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
  157. package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
  158. package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
  159. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
  160. package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
  161. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
  162. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  163. package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
  164. package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
  165. package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
  166. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  167. package/dist/packem_shared/sanitize-BZoLN9Fg.js +0 -205
  168. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  169. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  170. package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
  171. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  172. package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
  173. package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
  174. package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
  175. package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
  176. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
  177. package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
  178. package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
  179. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
  180. package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
  181. package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
  182. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
  183. package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
  184. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
  185. package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
  186. package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
@@ -1,171 +0,0 @@
1
- const normalizeLF = (code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n");
2
- const rawProcess = globalThis.process ?? /* @__PURE__ */ Object.create(null);
3
- const processShims = {
4
- versions: {}
5
- };
6
- const process = /* @__PURE__ */ new Proxy(rawProcess, {
7
- get(target, property) {
8
- if (property in target) {
9
- return target[property];
10
- }
11
- if (property in processShims) {
12
- return processShims[property];
13
- }
14
- return void 0;
15
- }
16
- });
17
- const getMarkerLines = (loc, source, linesAbove, linesBelow) => {
18
- const startLoc = {
19
- column: 0,
20
- // @ts-expect-error Can be overwritten
21
- line: -1,
22
- ...loc.start
23
- };
24
- const endLoc = {
25
- ...startLoc,
26
- ...loc.end
27
- };
28
- const startLine = startLoc.line;
29
- const startColumn = startLoc.column;
30
- const endLine = endLoc.line;
31
- const endColumn = endLoc.column;
32
- let start = Math.max(startLine - (linesAbove + 1), 0);
33
- let end = Math.min(source.length, endLine + linesBelow);
34
- if (startLine === -1) {
35
- start = 0;
36
- }
37
- if (endLine === -1) {
38
- end = source.length;
39
- }
40
- const lineDiff = endLine - startLine;
41
- const markerLines = {};
42
- if (lineDiff) {
43
- for (let index = 0; index <= lineDiff; index++) {
44
- const lineNumber = index + startLine;
45
- if (!startColumn) {
46
- markerLines[lineNumber] = true;
47
- } else if (index === 0) {
48
- const sourceLength = source[lineNumber - 1]?.length;
49
- markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];
50
- } else if (index === lineDiff) {
51
- markerLines[lineNumber] = [0, endColumn];
52
- } else {
53
- const sourceLength = source[lineNumber - index]?.length;
54
- markerLines[lineNumber] = [0, sourceLength];
55
- }
56
- }
57
- } else if (startColumn === endColumn) {
58
- markerLines[startLine] = startColumn ? [startColumn, 0] : true;
59
- } else {
60
- markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];
61
- }
62
- return { end, markerLines, start };
63
- };
64
- const CODE_FRAME_POINTER = process.platform === "win32" && !process.env?.WT_SESSION ? ">" : "❯";
65
- const codeFrame = (source, loc, options) => {
66
- const config = {
67
- // grab 2 lines before, and 3 lines after focused line
68
- linesAbove: 2,
69
- linesBelow: 3,
70
- prefix: "",
71
- showGutter: true,
72
- tabWidth: 4,
73
- ...options,
74
- color: {
75
- gutter: (value) => value,
76
- marker: (value) => value,
77
- message: (value) => value,
78
- ...options?.color
79
- }
80
- };
81
- const hasColumns = typeof loc.start.column === "number";
82
- let lines = normalizeLF(source).split("\n");
83
- if (typeof config.tabWidth === "number") {
84
- lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
85
- }
86
- const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
87
- const numberMaxWidth = String(end).length;
88
- const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;
89
- let frame = lines.slice(start, end).map((line, index) => {
90
- const number = start + 1 + index;
91
- const hasMarker = markerLines[number];
92
- const paddedNumber = ` ${String(number)}`.slice(-numberMaxWidth);
93
- const lastMarkerLine = !markerLines[number + 1];
94
- const gutter = ` ${paddedNumber}${config.showGutter ? " |" : ""}`;
95
- if (hasMarker) {
96
- let markerLine = "";
97
- if (Array.isArray(hasMarker)) {
98
- const markerSpacing = line.replaceAll(/[^\t]/g, " ").slice(0, Math.max(hasMarker[0] - 1, 0));
99
- const numberOfMarkers = hasMarker[1] || 1;
100
- markerLine = [
101
- "\n ",
102
- config.prefix + colorizeGutter(gutter.replaceAll(/\d/g, " ")),
103
- " ",
104
- markerSpacing,
105
- colorizeMarker("^").repeat(numberOfMarkers)
106
- ].join("");
107
- if (lastMarkerLine && config.message) {
108
- markerLine += ` ${colorizeMessage(config.message)}`;
109
- }
110
- }
111
- return [config.prefix + colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
112
- }
113
- return `${config.prefix} ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
114
- }).join("\n");
115
- if (config.message && !hasColumns) {
116
- frame = `${config.prefix + " ".repeat(numberMaxWidth + 1) + config.message}
117
- ${frame}`;
118
- }
119
- return frame;
120
- };
121
-
122
- const binarySearch = (element, array) => {
123
- let m = 0;
124
- let n = array.length - 2;
125
- while (m < n) {
126
- const key = m + (n - m >> 1);
127
- if (element < array[key]) {
128
- n = key - 1;
129
- } else if (element >= array[key + 1]) {
130
- m = key + 1;
131
- } else {
132
- m = key;
133
- break;
134
- }
135
- }
136
- return m;
137
- };
138
- const LINE_BREAK_REGEX = /\n|\r(?!\n)/;
139
- const getLineStartIndexes = (string_) => (
140
- // eslint-disable-next-line unicorn/no-array-reduce
141
- string_.split(LINE_BREAK_REGEX).reduce(
142
- (accumulator, current) => {
143
- accumulator.push(accumulator.at(-1) + current.length + 1);
144
- return accumulator;
145
- },
146
- [0]
147
- )
148
- );
149
- const indexToLineColumn = (input, index, options) => {
150
- if ((!Array.isArray(input) && typeof input !== "string" || (typeof input === "string" || Array.isArray(input)) && input.length === 0)) {
151
- return { column: 0, line: 0 };
152
- }
153
- if ((typeof index !== "number" || typeof input === "string" && index >= input.length || Array.isArray(input) && index + 1 >= input.at(-1))) {
154
- return { column: 0, line: 0 };
155
- }
156
- if (typeof input === "string") {
157
- const startIndexesOfEachLine = getLineStartIndexes(input);
158
- const line2 = binarySearch(index, startIndexesOfEachLine);
159
- return {
160
- column: index - startIndexesOfEachLine[line2] + 1,
161
- line: line2 + 1
162
- };
163
- }
164
- const line = binarySearch(index, input);
165
- return {
166
- column: index - input[line] + 1,
167
- line: line + 1
168
- };
169
- };
170
-
171
- export { codeFrame as c, indexToLineColumn as i };
@@ -1,251 +0,0 @@
1
- const BLANK_OR_COMMENT_REGEX = /^\s*(?:[;#].*)?$/;
2
- const SECTION_HEADER_REGEX = /^\s*\[([^\]]+)\]\s*$/;
3
- const LINE_SPLIT_REGEX = /\r?\n/;
4
- const TRAILING_EOL_REGEX = /\r?\n$/;
5
- const ENTRY_REGEX = /^[^=]+=/;
6
- const isWhitespace = (character) => character === " " || character === " ";
7
- const splitLeadingWhitespace = (source) => {
8
- let index = 0;
9
- while (index < source.length && isWhitespace(source[index])) {
10
- index += 1;
11
- }
12
- return { indent: source.slice(0, index), rest: source.slice(index) };
13
- };
14
- const splitTrailingWhitespace = (source) => {
15
- let index = source.length;
16
- while (index > 0 && isWhitespace(source[index - 1])) {
17
- index -= 1;
18
- }
19
- return { rest: source.slice(0, index), trailing: source.slice(index) };
20
- };
21
- const parseKeyValue = (raw) => {
22
- const equalsIndex = raw.indexOf("=");
23
- if (equalsIndex === -1) {
24
- return void 0;
25
- }
26
- const leftSide = raw.slice(0, equalsIndex);
27
- const rightSide = raw.slice(equalsIndex + 1);
28
- const { indent, rest: keyAndBefore } = splitLeadingWhitespace(leftSide);
29
- const { rest: key, trailing: before } = splitTrailingWhitespace(keyAndBefore);
30
- if (key === "" || key.startsWith(";") || key.startsWith("#") || key.startsWith("[")) {
31
- return void 0;
32
- }
33
- const { indent: after, rest: valueAndTrailing } = splitLeadingWhitespace(rightSide);
34
- const { rest: value, trailing } = splitTrailingWhitespace(valueAndTrailing);
35
- return { after, before, indent, key, trailing, value };
36
- };
37
- const countStyleMatches = (text) => {
38
- let spaced = 0;
39
- let unspaced = 0;
40
- for (const line of text.split(LINE_SPLIT_REGEX)) {
41
- if (BLANK_OR_COMMENT_REGEX.test(line) || SECTION_HEADER_REGEX.test(line)) {
42
- continue;
43
- }
44
- const parts = parseKeyValue(line);
45
- if (!parts) {
46
- continue;
47
- }
48
- if (parts.before === " " && parts.after === " ") {
49
- spaced += 1;
50
- } else if (parts.before === "" && parts.after === "") {
51
- unspaced += 1;
52
- }
53
- }
54
- return { spaced, unspaced };
55
- };
56
- const getSection = (data, section) => {
57
- if (!data) {
58
- return void 0;
59
- }
60
- if (section === void 0) {
61
- return data;
62
- }
63
- let cursor = data;
64
- for (const part of section.split(".")) {
65
- if (cursor && typeof cursor === "object" && !Array.isArray(cursor)) {
66
- cursor = cursor[part];
67
- } else {
68
- return void 0;
69
- }
70
- }
71
- return cursor && typeof cursor === "object" && !Array.isArray(cursor) ? cursor : void 0;
72
- };
73
- const extractValueToken = (serialized, key) => {
74
- for (const candidate of serialized.split(LINE_SPLIT_REGEX)) {
75
- if (!candidate || candidate.startsWith("[")) {
76
- continue;
77
- }
78
- const match = ENTRY_REGEX.exec(candidate);
79
- if (!match) {
80
- continue;
81
- }
82
- const candidateKey = candidate.slice(0, match[0].length - 1).trim();
83
- if (candidateKey === key || candidateKey === `${key}[]`) {
84
- return candidate.slice(match[0].length).trimStart();
85
- }
86
- }
87
- return "";
88
- };
89
- const classifyLine = (raw, currentSection) => {
90
- if (raw.trim() === "") {
91
- return { line: { kind: "blank", raw, section: currentSection }, nextSection: currentSection };
92
- }
93
- const trimmed = raw.trimStart();
94
- if (trimmed.startsWith(";") || trimmed.startsWith("#")) {
95
- return { line: { kind: "comment", raw, section: currentSection }, nextSection: currentSection };
96
- }
97
- const headerMatch = SECTION_HEADER_REGEX.exec(raw);
98
- if (headerMatch) {
99
- const nextSection = headerMatch[1];
100
- return { line: { kind: "header", raw, section: nextSection }, nextSection };
101
- }
102
- const parts = parseKeyValue(raw);
103
- if (parts) {
104
- return { line: { key: parts.key, kind: "key", raw, section: currentSection }, nextSection: currentSection };
105
- }
106
- return { line: { kind: "unknown", raw, section: currentSection }, nextSection: currentSection };
107
- };
108
- const parseLines = (original) => {
109
- const stripped = original.replace(TRAILING_EOL_REGEX, "");
110
- const rawLines = stripped.split(LINE_SPLIT_REGEX);
111
- const parsed = [];
112
- let currentSection;
113
- for (const raw of rawLines) {
114
- const { line, nextSection } = classifyLine(raw, currentSection);
115
- parsed.push(line);
116
- currentSection = nextSection;
117
- }
118
- return parsed;
119
- };
120
- const renderChangedKey = (line, newValue, freshStringify) => {
121
- const parts = parseKeyValue(line.raw);
122
- if (!parts || !line.key) {
123
- return line.raw;
124
- }
125
- const serialized = freshStringify({ [line.key]: newValue });
126
- const valueToken = extractValueToken(serialized, line.key);
127
- return `${parts.indent}${parts.key}${parts.before}=${parts.after}${valueToken}${parts.trailing}`;
128
- };
129
- const collectSections = (data, prefix = []) => {
130
- const sections = [];
131
- for (const [key, value] of Object.entries(data)) {
132
- if (value && typeof value === "object" && !Array.isArray(value)) {
133
- const path = [...prefix, key];
134
- sections.push(path.join("."), ...collectSections(value, path));
135
- }
136
- }
137
- return sections;
138
- };
139
- const pickScalars = (data, skip) => {
140
- const scalars = {};
141
- for (const [key, value] of Object.entries(data)) {
142
- if (skip.has(key) || value && typeof value === "object" && !Array.isArray(value)) {
143
- continue;
144
- }
145
- scalars[key] = value;
146
- }
147
- return scalars;
148
- };
149
- const appendSerialized = (outputLines, serialized) => {
150
- const added = [];
151
- for (const line of serialized.split(LINE_SPLIT_REGEX)) {
152
- if (line !== "") {
153
- added.push(line);
154
- }
155
- }
156
- if (added.length > 0) {
157
- outputLines.push(...added);
158
- }
159
- };
160
- const processKeyLine = (context) => {
161
- const { line, markWritten, nextData, oldData, renderValue } = context;
162
- if (!line.key) {
163
- return line.raw;
164
- }
165
- const newSection = getSection(nextData, line.section);
166
- if (!newSection || !(line.key in newSection)) {
167
- return void 0;
168
- }
169
- markWritten(line.section, line.key);
170
- const oldSection = getSection(oldData, line.section);
171
- const oldValue = oldSection?.[line.key];
172
- const newValue = newSection[line.key];
173
- if (JSON.stringify(oldValue) === JSON.stringify(newValue)) {
174
- return line.raw;
175
- }
176
- return renderValue(line, newValue);
177
- };
178
- const flushAdditions = (outputLines, section, writtenPerSection, nextData, freshStringify) => {
179
- const sectionData = getSection(nextData, section);
180
- if (!sectionData) {
181
- return;
182
- }
183
- const written = writtenPerSection.get(section) ?? /* @__PURE__ */ new Set();
184
- const additions = pickScalars(sectionData, written);
185
- if (Object.keys(additions).length === 0) {
186
- return;
187
- }
188
- appendSerialized(outputLines, freshStringify(additions));
189
- };
190
- const flushNewSections = (outputLines, parsedLines, nextData, freshStringify) => {
191
- const existingSections = new Set(parsedLines.filter((line) => line.kind === "header" && line.section).map((line) => line.section));
192
- for (const section of collectSections(nextData)) {
193
- if (existingSections.has(section)) {
194
- continue;
195
- }
196
- const sectionData = getSection(nextData, section);
197
- if (!sectionData || Object.keys(sectionData).length === 0) {
198
- continue;
199
- }
200
- const scalars = pickScalars(sectionData, /* @__PURE__ */ new Set());
201
- if (Object.keys(scalars).length === 0) {
202
- continue;
203
- }
204
- appendSerialized(outputLines, freshStringify(scalars, section));
205
- }
206
- };
207
- const detectIniStyle = (text) => {
208
- const eol = text.includes("\r\n") ? "\r\n" : "\n";
209
- const { spaced, unspaced } = countStyleMatches(text);
210
- return { eol, whitespace: spaced > 0 && spaced >= unspaced };
211
- };
212
- const mergeIniPreservingLines = (original, oldData, nextData, freshStringify, style) => {
213
- const { eol } = style;
214
- const endsWithEol = TRAILING_EOL_REGEX.test(original);
215
- const parsedLines = parseLines(original);
216
- const writtenPerSection = /* @__PURE__ */ new Map();
217
- const sectionLastIndex = /* @__PURE__ */ new Map();
218
- for (const [index, line] of parsedLines.entries()) {
219
- if (line.kind !== "blank") {
220
- sectionLastIndex.set(line.section, index);
221
- }
222
- }
223
- const markWritten = (section, key) => {
224
- let set = writtenPerSection.get(section);
225
- if (!set) {
226
- set = /* @__PURE__ */ new Set();
227
- writtenPerSection.set(section, set);
228
- }
229
- set.add(key);
230
- };
231
- const renderValue = (line, value) => renderChangedKey(line, value, freshStringify);
232
- const outputLines = [];
233
- for (const [index, line] of parsedLines.entries()) {
234
- if (line.kind === "key") {
235
- const rendered = processKeyLine({ line, markWritten, nextData, oldData, renderValue });
236
- if (rendered !== void 0) {
237
- outputLines.push(rendered);
238
- }
239
- continue;
240
- }
241
- outputLines.push(line.raw);
242
- if (sectionLastIndex.get(line.section) === index) {
243
- flushAdditions(outputLines, line.section, writtenPerSection, nextData, freshStringify);
244
- }
245
- }
246
- flushNewSections(outputLines, parsedLines, nextData, freshStringify);
247
- const joined = outputLines.join(eol);
248
- return endsWithEol && !joined.endsWith(eol) ? `${joined}${eol}` : joined;
249
- };
250
-
251
- export { detectIniStyle as d, mergeIniPreservingLines as m };
@@ -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 nativeFs__default = __cjs_getBuiltinModule("fs");
21
- const require$$2 = __cjs_getBuiltinModule("os");
22
- const require$$1 = __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 = require$$1.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(require$$2.tmpdir(), e);
51
- throw r;
52
- }
53
- }, "checkDirectoryCaseWithFallback");
54
- const S = s((i, t = nativeFs__default, 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,72 +0,0 @@
1
- import { parse, modify, applyEdits } from 'jsonc-parser';
2
-
3
- const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
- const applyModification = (context, path, value) => {
5
- const edits = modify(context.text, path, value, { formattingOptions: context.formattingOptions });
6
- context.text = applyEdits(context.text, edits);
7
- };
8
- const walkObject = (context, oldValue, newValue, path, walk) => {
9
- const keys = /* @__PURE__ */ new Set([...Object.keys(oldValue), ...Object.keys(newValue)]);
10
- for (const key of keys) {
11
- const keyPath = [...path, key];
12
- if (key in newValue) {
13
- if (key in oldValue) {
14
- walk(context, oldValue[key], newValue[key], keyPath);
15
- } else {
16
- applyModification(context, keyPath, newValue[key]);
17
- }
18
- } else {
19
- applyModification(context, keyPath, void 0);
20
- }
21
- }
22
- };
23
- const walkValue = (context, oldValue, newValue, path) => {
24
- if (oldValue === newValue) {
25
- return;
26
- }
27
- if (isPlainObject(oldValue) && isPlainObject(newValue)) {
28
- walkObject(context, oldValue, newValue, path, walkValue);
29
- return;
30
- }
31
- if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length) {
32
- for (const [index, oldItem] of oldValue.entries()) {
33
- walkValue(context, oldItem, newValue[index], [...path, index]);
34
- }
35
- return;
36
- }
37
- if (JSON.stringify(oldValue) === JSON.stringify(newValue)) {
38
- return;
39
- }
40
- applyModification(context, path, newValue);
41
- };
42
- const mergeJsoncPreservingComments = (original, next, formattingOptions) => {
43
- const existing = parse(original, [], { allowTrailingComma: true });
44
- const context = { formattingOptions, text: original };
45
- walkValue(context, existing, next, []);
46
- return context.text;
47
- };
48
- const formattingFromIndent = (indent) => {
49
- if (typeof indent === "number") {
50
- return { insertSpaces: true, tabSize: indent };
51
- }
52
- if (typeof indent === "string") {
53
- if (indent === " " || indent.includes(" ")) {
54
- return { insertSpaces: false, tabSize: indent.length || 1 };
55
- }
56
- return { insertSpaces: true, tabSize: indent.length || 2 };
57
- }
58
- return { insertSpaces: true, tabSize: 2 };
59
- };
60
- const buildJsoncOutput = (existingText, data, preserveComments, indent, trailingNewline, formattingOptions, replacer) => {
61
- if (preserveComments && existingText !== void 0) {
62
- const resolvedFormatting = { ...formattingFromIndent(indent), ...formattingOptions };
63
- let merged = mergeJsoncPreservingComments(existingText, data, resolvedFormatting);
64
- if (trailingNewline && !merged.endsWith("\n")) {
65
- merged += trailingNewline;
66
- }
67
- return merged;
68
- }
69
- return `${JSON.stringify(data, replacer, indent)}${trailingNewline}`;
70
- };
71
-
72
- export { buildJsoncOutput as b };