cline 1.0.1 → 1.0.3

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 (299) hide show
  1. package/bin/cline +0 -0
  2. package/bin/cline-darwin-amd64 +0 -0
  3. package/bin/cline-darwin-arm64 +0 -0
  4. package/bin/cline-host +0 -0
  5. package/bin/cline-host-darwin-amd64 +0 -0
  6. package/bin/cline-host-darwin-arm64 +0 -0
  7. package/bin/cline-host-linux-amd64 +0 -0
  8. package/bin/cline-host-linux-arm64 +0 -0
  9. package/bin/cline-linux-amd64 +0 -0
  10. package/bin/cline-linux-arm64 +0 -0
  11. package/cline-core.js +24143 -16610
  12. package/extension/package.json +12 -4
  13. package/node_modules/b4a/LICENSE +201 -0
  14. package/node_modules/b4a/README.md +153 -0
  15. package/node_modules/b4a/browser.js +563 -0
  16. package/node_modules/b4a/index.js +188 -0
  17. package/node_modules/b4a/lib/ascii.js +31 -0
  18. package/node_modules/b4a/lib/base64.js +65 -0
  19. package/node_modules/b4a/lib/hex.js +51 -0
  20. package/node_modules/b4a/lib/utf16le.js +40 -0
  21. package/node_modules/b4a/lib/utf8.js +141 -0
  22. package/node_modules/b4a/package.json +49 -0
  23. package/node_modules/b4a/react-native.js +5 -0
  24. package/node_modules/bare-events/LICENSE +201 -0
  25. package/node_modules/bare-events/README.md +25 -0
  26. package/node_modules/bare-events/global.d.ts +15 -0
  27. package/node_modules/bare-events/global.js +5 -0
  28. package/node_modules/bare-events/index.d.ts +94 -0
  29. package/node_modules/bare-events/index.js +355 -0
  30. package/node_modules/bare-events/lib/errors.js +32 -0
  31. package/node_modules/bare-events/package.json +61 -0
  32. package/node_modules/bare-events/web.d.ts +79 -0
  33. package/node_modules/bare-events/web.js +347 -0
  34. package/node_modules/bare-fs/CMakeLists.txt +13 -0
  35. package/node_modules/bare-fs/LICENSE +201 -0
  36. package/node_modules/bare-fs/README.md +29 -0
  37. package/node_modules/bare-fs/binding.c +2238 -0
  38. package/node_modules/bare-fs/binding.js +1 -0
  39. package/node_modules/bare-fs/index.d.ts +1115 -0
  40. package/node_modules/bare-fs/index.js +2330 -0
  41. package/node_modules/bare-fs/lib/constants.d.ts +49 -0
  42. package/node_modules/bare-fs/lib/constants.js +49 -0
  43. package/node_modules/bare-fs/lib/errors.d.ts +11 -0
  44. package/node_modules/bare-fs/lib/errors.js +55 -0
  45. package/node_modules/bare-fs/package.json +71 -0
  46. package/node_modules/bare-fs/prebuilds/android-arm/bare-fs.bare +0 -0
  47. package/node_modules/bare-fs/prebuilds/android-arm64/bare-fs.bare +0 -0
  48. package/node_modules/bare-fs/prebuilds/android-ia32/bare-fs.bare +0 -0
  49. package/node_modules/bare-fs/prebuilds/android-x64/bare-fs.bare +0 -0
  50. package/node_modules/bare-fs/prebuilds/darwin-arm64/bare-fs.bare +0 -0
  51. package/node_modules/bare-fs/prebuilds/darwin-x64/bare-fs.bare +0 -0
  52. package/node_modules/bare-fs/prebuilds/ios-arm64/bare-fs.bare +0 -0
  53. package/node_modules/bare-fs/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
  54. package/node_modules/bare-fs/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
  55. package/node_modules/bare-fs/prebuilds/linux-arm64/bare-fs.bare +0 -0
  56. package/node_modules/bare-fs/prebuilds/linux-x64/bare-fs.bare +0 -0
  57. package/node_modules/bare-fs/prebuilds/win32-arm64/bare-fs.bare +0 -0
  58. package/node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare +0 -0
  59. package/node_modules/bare-fs/promises.d.ts +282 -0
  60. package/node_modules/bare-fs/promises.js +90 -0
  61. package/node_modules/bare-os/CMakeLists.txt +13 -0
  62. package/node_modules/bare-os/LICENSE +201 -0
  63. package/node_modules/bare-os/README.md +11 -0
  64. package/node_modules/bare-os/binding.c +1119 -0
  65. package/node_modules/bare-os/binding.js +1 -0
  66. package/node_modules/bare-os/index.d.ts +109 -0
  67. package/node_modules/bare-os/index.js +99 -0
  68. package/node_modules/bare-os/lib/constants.js +6 -0
  69. package/node_modules/bare-os/lib/errors.js +22 -0
  70. package/node_modules/bare-os/package.json +46 -0
  71. package/node_modules/bare-os/prebuilds/android-arm/bare-os.bare +0 -0
  72. package/node_modules/bare-os/prebuilds/android-arm64/bare-os.bare +0 -0
  73. package/node_modules/bare-os/prebuilds/android-ia32/bare-os.bare +0 -0
  74. package/node_modules/bare-os/prebuilds/android-x64/bare-os.bare +0 -0
  75. package/node_modules/bare-os/prebuilds/darwin-arm64/bare-os.bare +0 -0
  76. package/node_modules/bare-os/prebuilds/darwin-x64/bare-os.bare +0 -0
  77. package/node_modules/bare-os/prebuilds/ios-arm64/bare-os.bare +0 -0
  78. package/node_modules/bare-os/prebuilds/ios-arm64-simulator/bare-os.bare +0 -0
  79. package/node_modules/bare-os/prebuilds/ios-x64-simulator/bare-os.bare +0 -0
  80. package/node_modules/bare-os/prebuilds/linux-arm64/bare-os.bare +0 -0
  81. package/node_modules/bare-os/prebuilds/linux-x64/bare-os.bare +0 -0
  82. package/node_modules/bare-os/prebuilds/win32-arm64/bare-os.bare +0 -0
  83. package/node_modules/bare-os/prebuilds/win32-x64/bare-os.bare +0 -0
  84. package/node_modules/bare-path/LICENSE +201 -0
  85. package/node_modules/bare-path/NOTICE +28 -0
  86. package/node_modules/bare-path/README.md +19 -0
  87. package/node_modules/bare-path/index.js +11 -0
  88. package/node_modules/bare-path/lib/constants.js +11 -0
  89. package/node_modules/bare-path/lib/posix.js +242 -0
  90. package/node_modules/bare-path/lib/shared.js +67 -0
  91. package/node_modules/bare-path/lib/win32.js +513 -0
  92. package/node_modules/bare-path/package.json +36 -0
  93. package/node_modules/bare-stream/LICENSE +201 -0
  94. package/node_modules/bare-stream/README.md +15 -0
  95. package/node_modules/bare-stream/global.js +8 -0
  96. package/node_modules/bare-stream/index.d.ts +237 -0
  97. package/node_modules/bare-stream/index.js +355 -0
  98. package/node_modules/bare-stream/package.json +61 -0
  99. package/node_modules/bare-stream/promises.js +3 -0
  100. package/node_modules/bare-stream/web.d.ts +73 -0
  101. package/node_modules/bare-stream/web.js +229 -0
  102. package/node_modules/bare-url/CMakeLists.txt +27 -0
  103. package/node_modules/bare-url/LICENSE +201 -0
  104. package/node_modules/bare-url/README.md +19 -0
  105. package/node_modules/bare-url/binding.c +188 -0
  106. package/node_modules/bare-url/binding.js +1 -0
  107. package/node_modules/bare-url/global.d.ts +12 -0
  108. package/node_modules/bare-url/global.js +2 -0
  109. package/node_modules/bare-url/index.d.ts +39 -0
  110. package/node_modules/bare-url/index.js +450 -0
  111. package/node_modules/bare-url/lib/errors.d.ts +8 -0
  112. package/node_modules/bare-url/lib/errors.js +38 -0
  113. package/node_modules/bare-url/lib/url-search-params.d.ts +21 -0
  114. package/node_modules/bare-url/lib/url-search-params.js +176 -0
  115. package/node_modules/bare-url/package.json +51 -0
  116. package/node_modules/bare-url/prebuilds/android-arm/bare-url.bare +0 -0
  117. package/node_modules/bare-url/prebuilds/android-arm64/bare-url.bare +0 -0
  118. package/node_modules/bare-url/prebuilds/android-ia32/bare-url.bare +0 -0
  119. package/node_modules/bare-url/prebuilds/android-x64/bare-url.bare +0 -0
  120. package/node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare +0 -0
  121. package/node_modules/bare-url/prebuilds/darwin-x64/bare-url.bare +0 -0
  122. package/node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare +0 -0
  123. package/node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
  124. package/node_modules/bare-url/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
  125. package/node_modules/bare-url/prebuilds/linux-arm64/bare-url.bare +0 -0
  126. package/node_modules/bare-url/prebuilds/linux-x64/bare-url.bare +0 -0
  127. package/node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare +0 -0
  128. package/node_modules/bare-url/prebuilds/win32-x64/bare-url.bare +0 -0
  129. package/node_modules/better-sqlite3/deps/download.sh +1 -1
  130. package/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c +122 -81
  131. package/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h +45 -45
  132. package/node_modules/better-sqlite3/lib/database.js +1 -1
  133. package/node_modules/better-sqlite3/package.json +4 -7
  134. package/node_modules/better-sqlite3/src/addon.cpp +47 -0
  135. package/node_modules/better-sqlite3/src/better_sqlite3.cpp +44 -2164
  136. package/node_modules/better-sqlite3/src/objects/backup.cpp +120 -0
  137. package/node_modules/better-sqlite3/src/objects/backup.hpp +36 -0
  138. package/node_modules/better-sqlite3/src/objects/database.cpp +417 -0
  139. package/node_modules/better-sqlite3/src/objects/database.hpp +103 -0
  140. package/node_modules/better-sqlite3/src/objects/statement-iterator.cpp +113 -0
  141. package/node_modules/better-sqlite3/src/objects/statement-iterator.hpp +50 -0
  142. package/node_modules/better-sqlite3/src/objects/statement.cpp +383 -0
  143. package/node_modules/better-sqlite3/src/objects/statement.hpp +58 -0
  144. package/node_modules/better-sqlite3/src/util/bind-map.cpp +73 -0
  145. package/node_modules/better-sqlite3/src/util/binder.cpp +193 -0
  146. package/node_modules/better-sqlite3/src/util/constants.cpp +172 -0
  147. package/node_modules/better-sqlite3/src/util/custom-aggregate.cpp +121 -0
  148. package/node_modules/better-sqlite3/src/util/custom-function.cpp +59 -0
  149. package/node_modules/better-sqlite3/src/util/custom-table.cpp +409 -0
  150. package/node_modules/better-sqlite3/src/util/data-converter.cpp +17 -0
  151. package/node_modules/better-sqlite3/src/util/data.cpp +194 -0
  152. package/node_modules/better-sqlite3/src/util/helpers.cpp +109 -0
  153. package/node_modules/better-sqlite3/src/util/macros.cpp +63 -0
  154. package/node_modules/better-sqlite3/src/util/query-macros.cpp +71 -0
  155. package/node_modules/better-sqlite3/src/util/row-builder.cpp +49 -0
  156. package/node_modules/events-universal/LICENSE +201 -0
  157. package/node_modules/events-universal/README.md +17 -0
  158. package/node_modules/events-universal/bare.js +1 -0
  159. package/node_modules/events-universal/default.js +1 -0
  160. package/node_modules/events-universal/index.js +1 -0
  161. package/node_modules/events-universal/package.json +39 -0
  162. package/node_modules/events-universal/react-native.js +1 -0
  163. package/node_modules/{fs-constants → fast-fifo}/LICENSE +1 -1
  164. package/node_modules/fast-fifo/README.md +78 -0
  165. package/node_modules/fast-fifo/fixed-size.js +39 -0
  166. package/node_modules/fast-fifo/index.js +48 -0
  167. package/node_modules/fast-fifo/package.json +28 -0
  168. package/node_modules/{base64-js → streamx}/LICENSE +1 -1
  169. package/node_modules/streamx/README.md +489 -0
  170. package/node_modules/streamx/index.js +1184 -0
  171. package/node_modules/streamx/package.json +34 -0
  172. package/node_modules/tar-fs/README.md +23 -34
  173. package/node_modules/tar-fs/index.js +211 -184
  174. package/node_modules/tar-fs/package.json +27 -7
  175. package/node_modules/tar-stream/README.md +34 -19
  176. package/node_modules/tar-stream/constants.js +14 -0
  177. package/node_modules/tar-stream/extract.js +341 -192
  178. package/node_modules/tar-stream/headers.js +201 -175
  179. package/node_modules/tar-stream/pack.js +226 -194
  180. package/node_modules/tar-stream/package.json +23 -46
  181. package/node_modules/text-decoder/LICENSE +201 -0
  182. package/node_modules/text-decoder/README.md +36 -0
  183. package/node_modules/text-decoder/index.js +64 -0
  184. package/node_modules/text-decoder/lib/browser-decoder.js +17 -0
  185. package/node_modules/text-decoder/lib/pass-through-decoder.js +19 -0
  186. package/node_modules/text-decoder/lib/utf8-decoder.js +104 -0
  187. package/node_modules/text-decoder/package.json +38 -0
  188. package/package.json +1 -1
  189. package/proto/cline/account.proto +10 -8
  190. package/proto/cline/browser.proto +3 -1
  191. package/proto/cline/checkpoints.proto +5 -3
  192. package/proto/cline/commands.proto +4 -2
  193. package/proto/cline/common.proto +5 -7
  194. package/proto/cline/dictation.proto +3 -1
  195. package/proto/cline/file.proto +36 -34
  196. package/proto/cline/hooks.proto +3 -2
  197. package/proto/cline/mcp.proto +6 -4
  198. package/proto/cline/models.proto +189 -19
  199. package/proto/cline/oca_account.proto +6 -7
  200. package/proto/cline/slash.proto +3 -1
  201. package/proto/cline/state.proto +144 -292
  202. package/proto/cline/task.proto +4 -2
  203. package/proto/cline/ui.proto +25 -24
  204. package/proto/cline/web.proto +3 -1
  205. package/proto/descriptor_set.pb +0 -0
  206. package/proto/host/diff.proto +5 -4
  207. package/proto/host/env.proto +8 -7
  208. package/proto/host/testing.proto +3 -3
  209. package/proto/host/window.proto +2 -2
  210. package/proto/host/workspace.proto +13 -12
  211. package/node_modules/base64-js/README.md +0 -34
  212. package/node_modules/base64-js/base64js.min.js +0 -1
  213. package/node_modules/base64-js/index.d.ts +0 -3
  214. package/node_modules/base64-js/index.js +0 -150
  215. package/node_modules/base64-js/package.json +0 -47
  216. package/node_modules/better-sqlite3/src/better_sqlite3.hpp +0 -1036
  217. package/node_modules/bl/.travis.yml +0 -17
  218. package/node_modules/bl/BufferList.js +0 -396
  219. package/node_modules/bl/LICENSE.md +0 -13
  220. package/node_modules/bl/README.md +0 -247
  221. package/node_modules/bl/bl.js +0 -84
  222. package/node_modules/bl/package.json +0 -37
  223. package/node_modules/bl/test/convert.js +0 -21
  224. package/node_modules/bl/test/indexOf.js +0 -492
  225. package/node_modules/bl/test/isBufferList.js +0 -32
  226. package/node_modules/bl/test/test.js +0 -869
  227. package/node_modules/buffer/AUTHORS.md +0 -70
  228. package/node_modules/buffer/LICENSE +0 -21
  229. package/node_modules/buffer/README.md +0 -410
  230. package/node_modules/buffer/index.d.ts +0 -186
  231. package/node_modules/buffer/index.js +0 -1817
  232. package/node_modules/buffer/package.json +0 -96
  233. package/node_modules/chownr/LICENSE +0 -15
  234. package/node_modules/chownr/README.md +0 -3
  235. package/node_modules/chownr/chownr.js +0 -167
  236. package/node_modules/chownr/package.json +0 -29
  237. package/node_modules/fs-constants/README.md +0 -26
  238. package/node_modules/fs-constants/browser.js +0 -1
  239. package/node_modules/fs-constants/index.js +0 -1
  240. package/node_modules/fs-constants/package.json +0 -19
  241. package/node_modules/ieee754/LICENSE +0 -11
  242. package/node_modules/ieee754/README.md +0 -51
  243. package/node_modules/ieee754/index.d.ts +0 -10
  244. package/node_modules/ieee754/index.js +0 -85
  245. package/node_modules/ieee754/package.json +0 -52
  246. package/node_modules/inherits/LICENSE +0 -16
  247. package/node_modules/inherits/README.md +0 -42
  248. package/node_modules/inherits/inherits.js +0 -9
  249. package/node_modules/inherits/inherits_browser.js +0 -27
  250. package/node_modules/inherits/package.json +0 -29
  251. package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
  252. package/node_modules/readable-stream/GOVERNANCE.md +0 -136
  253. package/node_modules/readable-stream/LICENSE +0 -47
  254. package/node_modules/readable-stream/README.md +0 -106
  255. package/node_modules/readable-stream/errors-browser.js +0 -127
  256. package/node_modules/readable-stream/errors.js +0 -116
  257. package/node_modules/readable-stream/experimentalWarning.js +0 -17
  258. package/node_modules/readable-stream/lib/_stream_duplex.js +0 -126
  259. package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -37
  260. package/node_modules/readable-stream/lib/_stream_readable.js +0 -1027
  261. package/node_modules/readable-stream/lib/_stream_transform.js +0 -190
  262. package/node_modules/readable-stream/lib/_stream_writable.js +0 -641
  263. package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -180
  264. package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -183
  265. package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -96
  266. package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -86
  267. package/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -3
  268. package/node_modules/readable-stream/lib/internal/streams/from.js +0 -52
  269. package/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -86
  270. package/node_modules/readable-stream/lib/internal/streams/state.js +0 -22
  271. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
  272. package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
  273. package/node_modules/readable-stream/package.json +0 -68
  274. package/node_modules/readable-stream/readable-browser.js +0 -9
  275. package/node_modules/readable-stream/readable.js +0 -16
  276. package/node_modules/string_decoder/LICENSE +0 -48
  277. package/node_modules/string_decoder/README.md +0 -47
  278. package/node_modules/string_decoder/lib/string_decoder.js +0 -296
  279. package/node_modules/string_decoder/package.json +0 -34
  280. package/node_modules/tar-fs/.travis.yml +0 -6
  281. package/node_modules/tar-fs/test/fixtures/a/hello.txt +0 -1
  282. package/node_modules/tar-fs/test/fixtures/b/a/test.txt +0 -1
  283. package/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
  284. package/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
  285. package/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
  286. package/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
  287. package/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
  288. package/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
  289. package/node_modules/tar-fs/test/fixtures/e/file +0 -0
  290. package/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
  291. package/node_modules/tar-fs/test/index.js +0 -346
  292. package/node_modules/tar-stream/sandbox.js +0 -11
  293. package/node_modules/util-deprecate/History.md +0 -16
  294. package/node_modules/util-deprecate/LICENSE +0 -24
  295. package/node_modules/util-deprecate/README.md +0 -53
  296. package/node_modules/util-deprecate/browser.js +0 -67
  297. package/node_modules/util-deprecate/node.js +0 -6
  298. package/node_modules/util-deprecate/package.json +0 -27
  299. package/test-startup.sh +0 -14
@@ -0,0 +1,513 @@
1
+ const os = require('bare-os')
2
+
3
+ const { normalizeString } = require('./shared')
4
+ const {
5
+ CHAR_UPPERCASE_A,
6
+ CHAR_LOWERCASE_A,
7
+ CHAR_UPPERCASE_Z,
8
+ CHAR_LOWERCASE_Z,
9
+ CHAR_DOT,
10
+ CHAR_FORWARD_SLASH,
11
+ CHAR_BACKWARD_SLASH,
12
+ CHAR_COLON,
13
+ CHAR_QUESTION_MARK
14
+ } = require('./constants')
15
+
16
+ function isWindowsPathSeparator (code) {
17
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH
18
+ }
19
+
20
+ function isWindowsDeviceRoot (code) {
21
+ return (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
22
+ (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z)
23
+ }
24
+
25
+ exports.posix = require('./posix')
26
+ exports.win32 = exports
27
+
28
+ exports.sep = '\\'
29
+ exports.delimiter = ';'
30
+
31
+ exports.resolve = function resolve (...args) {
32
+ let resolvedDevice = ''
33
+ let resolvedTail = ''
34
+ let resolvedAbsolute = false
35
+
36
+ for (let i = args.length - 1; i >= -1; i--) {
37
+ let path
38
+ if (i >= 0) {
39
+ path = args[i]
40
+
41
+ if (path.length === 0) continue
42
+ } else if (resolvedDevice.length === 0) {
43
+ path = os.cwd()
44
+ } else {
45
+ path = os.getEnv(`=${resolvedDevice}`) || os.cwd()
46
+
47
+ if (path === undefined || (path.substring(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() && path.charCodeAt(2) === CHAR_BACKWARD_SLASH)) {
48
+ path = `${resolvedDevice}\\`
49
+ }
50
+ }
51
+
52
+ const len = path.length
53
+ let rootEnd = 0
54
+ let device = ''
55
+ let isAbsolute = false
56
+ const code = path.charCodeAt(0)
57
+
58
+ if (len === 1) {
59
+ if (isWindowsPathSeparator(code)) {
60
+ rootEnd = 1
61
+ isAbsolute = true
62
+ }
63
+ } else if (isWindowsPathSeparator(code)) {
64
+ isAbsolute = true
65
+
66
+ if (isWindowsPathSeparator(path.charCodeAt(1))) {
67
+ let j = 2
68
+ let last = j
69
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
70
+ j++
71
+ }
72
+ if (j < len && j !== last) {
73
+ const firstPart = path.substring(last, j)
74
+ last = j
75
+ while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
76
+ j++
77
+ }
78
+ if (j < len && j !== last) {
79
+ last = j
80
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
81
+ j++
82
+ }
83
+ if (j === len || j !== last) {
84
+ device = `\\\\${firstPart}\\${path.substring(last, j)}`
85
+ rootEnd = j
86
+ }
87
+ }
88
+ }
89
+ } else {
90
+ rootEnd = 1
91
+ }
92
+ } else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
93
+ device = path.substring(0, 2)
94
+ rootEnd = 2
95
+ if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
96
+ isAbsolute = true
97
+ rootEnd = 3
98
+ }
99
+ }
100
+
101
+ if (device.length > 0) {
102
+ if (resolvedDevice.length > 0) {
103
+ if (device.toLowerCase() !== resolvedDevice.toLowerCase()) { continue }
104
+ } else {
105
+ resolvedDevice = device
106
+ }
107
+ }
108
+
109
+ if (resolvedAbsolute) {
110
+ if (resolvedDevice.length > 0) { break }
111
+ } else {
112
+ resolvedTail = `${path.substring(rootEnd)}\\${resolvedTail}`
113
+ resolvedAbsolute = isAbsolute
114
+ if (isAbsolute && resolvedDevice.length > 0) {
115
+ break
116
+ }
117
+ }
118
+ }
119
+
120
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isWindowsPathSeparator)
121
+
122
+ return resolvedAbsolute ? `${resolvedDevice}\\${resolvedTail}` : `${resolvedDevice}${resolvedTail}` || '.'
123
+ }
124
+
125
+ exports.normalize = function normalize (path) {
126
+ const len = path.length
127
+ if (len === 0) return '.'
128
+ let rootEnd = 0
129
+ let device
130
+ let isAbsolute = false
131
+ const code = path.charCodeAt(0)
132
+
133
+ if (len === 1) {
134
+ return code === CHAR_FORWARD_SLASH ? '\\' : path
135
+ }
136
+
137
+ if (isWindowsPathSeparator(code)) {
138
+ isAbsolute = true
139
+
140
+ if (isWindowsPathSeparator(path.charCodeAt(1))) {
141
+ let j = 2
142
+ let last = j
143
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
144
+ j++
145
+ }
146
+ if (j < len && j !== last) {
147
+ const firstPart = path.substring(last, j)
148
+ last = j
149
+ while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
150
+ j++
151
+ }
152
+ if (j < len && j !== last) {
153
+ last = j
154
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
155
+ j++
156
+ }
157
+ if (j === len) {
158
+ return `\\\\${firstPart}\\${path.substring(last)}\\`
159
+ }
160
+ if (j !== last) {
161
+ device = `\\\\${firstPart}\\${path.substring(last, j)}`
162
+ rootEnd = j
163
+ }
164
+ }
165
+ }
166
+ } else {
167
+ rootEnd = 1
168
+ }
169
+ } else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
170
+ device = path.substring(0, 2)
171
+ rootEnd = 2
172
+ if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
173
+ isAbsolute = true
174
+ rootEnd = 3
175
+ }
176
+ }
177
+
178
+ let tail = rootEnd < len ? normalizeString(path.substring(rootEnd), !isAbsolute, '\\', isWindowsPathSeparator) : ''
179
+ if (tail.length === 0 && !isAbsolute) {
180
+ tail = '.'
181
+ }
182
+ if (tail.length > 0 && isWindowsPathSeparator(path.charCodeAt(len - 1))) {
183
+ tail += '\\'
184
+ }
185
+ if (device === undefined) {
186
+ return isAbsolute ? `\\${tail}` : tail
187
+ }
188
+ return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`
189
+ }
190
+
191
+ exports.isAbsolute = function isAbsolute (path) {
192
+ const len = path.length
193
+ if (len === 0) return false
194
+
195
+ const code = path.charCodeAt(0)
196
+
197
+ return isWindowsPathSeparator(code) || (len > 2 && isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON && isWindowsPathSeparator(path.charCodeAt(2)))
198
+ }
199
+
200
+ exports.join = function join (...args) {
201
+ if (args.length === 0) return '.'
202
+
203
+ let joined
204
+ let firstPart
205
+ for (let i = 0; i < args.length; ++i) {
206
+ const arg = args[i]
207
+ if (arg.length > 0) {
208
+ if (joined === undefined) joined = firstPart = arg
209
+ else joined += `\\${arg}`
210
+ }
211
+ }
212
+
213
+ if (joined === undefined) return '.'
214
+
215
+ let needsReplace = true
216
+ let slashCount = 0
217
+ if (isWindowsPathSeparator(firstPart.charCodeAt(0))) {
218
+ ++slashCount
219
+ const firstLen = firstPart.length
220
+ if (firstLen > 1 && isWindowsPathSeparator(firstPart.charCodeAt(1))) {
221
+ ++slashCount
222
+ if (firstLen > 2) {
223
+ if (isWindowsPathSeparator(firstPart.charCodeAt(2))) {
224
+ ++slashCount
225
+ } else {
226
+ needsReplace = false
227
+ }
228
+ }
229
+ }
230
+ }
231
+ if (needsReplace) {
232
+ while (slashCount < joined.length && isWindowsPathSeparator(joined.charCodeAt(slashCount))) {
233
+ slashCount++
234
+ }
235
+
236
+ if (slashCount >= 2) {
237
+ joined = `\\${joined.substring(slashCount)}`
238
+ }
239
+ }
240
+
241
+ return exports.normalize(joined)
242
+ }
243
+
244
+ exports.relative = function relative (from, to) {
245
+ if (from === to) return ''
246
+
247
+ const fromOrig = exports.resolve(from)
248
+ const toOrig = exports.resolve(to)
249
+
250
+ if (fromOrig === toOrig) return ''
251
+
252
+ from = fromOrig.toLowerCase()
253
+ to = toOrig.toLowerCase()
254
+
255
+ if (from === to) return ''
256
+
257
+ let fromStart = 0
258
+ while (fromStart < from.length && from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
259
+ fromStart++
260
+ }
261
+ let fromEnd = from.length
262
+ while (fromEnd - 1 > fromStart && from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
263
+ fromEnd--
264
+ }
265
+ const fromLen = fromEnd - fromStart
266
+
267
+ let toStart = 0
268
+ while (toStart < to.length && to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
269
+ toStart++
270
+ }
271
+ let toEnd = to.length
272
+ while (toEnd - 1 > toStart && to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
273
+ toEnd--
274
+ }
275
+ const toLen = toEnd - toStart
276
+
277
+ const length = fromLen < toLen ? fromLen : toLen
278
+ let lastCommonSep = -1
279
+ let i = 0
280
+ for (; i < length; i++) {
281
+ const fromCode = from.charCodeAt(fromStart + i)
282
+ if (fromCode !== to.charCodeAt(toStart + i)) {
283
+ break
284
+ } else if (fromCode === CHAR_BACKWARD_SLASH) {
285
+ lastCommonSep = i
286
+ }
287
+ }
288
+
289
+ if (i !== length) {
290
+ if (lastCommonSep === -1) return toOrig
291
+ } else {
292
+ if (toLen > length) {
293
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
294
+ return toOrig.substring(toStart + i + 1)
295
+ }
296
+ if (i === 2) {
297
+ return toOrig.substring(toStart + i)
298
+ }
299
+ }
300
+ if (fromLen > length) {
301
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
302
+ lastCommonSep = i
303
+ } else if (i === 2) {
304
+ lastCommonSep = 3
305
+ }
306
+ }
307
+ if (lastCommonSep === -1) lastCommonSep = 0
308
+ }
309
+
310
+ let out = ''
311
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
312
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
313
+ out += out.length === 0 ? '..' : '\\..'
314
+ }
315
+ }
316
+
317
+ toStart += lastCommonSep
318
+
319
+ if (out.length > 0) {
320
+ return `${out}${toOrig.substring(toStart, toEnd)}`
321
+ }
322
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
323
+ ++toStart
324
+ }
325
+ return toOrig.substring(toStart, toEnd)
326
+ }
327
+
328
+ exports.toNamespacedPath = function toNamespacedPath (path) {
329
+ if (path.length === 0) return path
330
+
331
+ const resolvedPath = exports.resolve(path)
332
+
333
+ if (resolvedPath.length <= 2) return path
334
+
335
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
336
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
337
+ const code = resolvedPath.charCodeAt(2)
338
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
339
+ return `\\\\?\\UNC\\${resolvedPath.substring(2)}`
340
+ }
341
+ }
342
+ } else if (
343
+ isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) &&
344
+ resolvedPath.charCodeAt(1) === CHAR_COLON &&
345
+ resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH
346
+ ) {
347
+ return `\\\\?\\${resolvedPath}`
348
+ }
349
+
350
+ return path
351
+ }
352
+
353
+ exports.dirname = function dirname (path) {
354
+ const len = path.length
355
+ if (len === 0) return '.'
356
+ let rootEnd = -1
357
+ let offset = 0
358
+ const code = path.charCodeAt(0)
359
+
360
+ if (len === 1) {
361
+ return isWindowsPathSeparator(code) ? path : '.'
362
+ }
363
+
364
+ if (isWindowsPathSeparator(code)) {
365
+ rootEnd = offset = 1
366
+
367
+ if (isWindowsPathSeparator(path.charCodeAt(1))) {
368
+ let j = 2
369
+ let last = j
370
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
371
+ j++
372
+ }
373
+ if (j < len && j !== last) {
374
+ last = j
375
+ while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
376
+ j++
377
+ }
378
+ if (j < len && j !== last) {
379
+ last = j
380
+ while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
381
+ j++
382
+ }
383
+ if (j === len) {
384
+ return path
385
+ }
386
+ if (j !== last) {
387
+ rootEnd = offset = j + 1
388
+ }
389
+ }
390
+ }
391
+ }
392
+ } else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
393
+ rootEnd = len > 2 && isWindowsPathSeparator(path.charCodeAt(2)) ? 3 : 2
394
+ offset = rootEnd
395
+ }
396
+
397
+ let end = -1
398
+ let matchedSlash = true
399
+ for (let i = len - 1; i >= offset; --i) {
400
+ if (isWindowsPathSeparator(path.charCodeAt(i))) {
401
+ if (!matchedSlash) {
402
+ end = i
403
+ break
404
+ }
405
+ } else {
406
+ matchedSlash = false
407
+ }
408
+ }
409
+
410
+ if (end === -1) {
411
+ if (rootEnd === -1) return '.'
412
+
413
+ end = rootEnd
414
+ }
415
+ return path.substring(0, end)
416
+ }
417
+
418
+ exports.basename = function basename (path, suffix) {
419
+ let start = 0
420
+ let end = -1
421
+ let matchedSlash = true
422
+
423
+ if (path.length >= 2 && isWindowsDeviceRoot(path.charCodeAt(0)) && path.charCodeAt(1) === CHAR_COLON) {
424
+ start = 2
425
+ }
426
+
427
+ if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {
428
+ if (suffix === path) return ''
429
+ let extIdx = suffix.length - 1
430
+ let firstNonSlashEnd = -1
431
+ for (let i = path.length - 1; i >= start; --i) {
432
+ const code = path.charCodeAt(i)
433
+ if (isWindowsPathSeparator(code)) {
434
+ if (!matchedSlash) {
435
+ start = i + 1
436
+ break
437
+ }
438
+ } else {
439
+ if (firstNonSlashEnd === -1) {
440
+ matchedSlash = false
441
+ firstNonSlashEnd = i + 1
442
+ }
443
+ if (extIdx >= 0) {
444
+ if (code === suffix.charCodeAt(extIdx)) {
445
+ if (--extIdx === -1) {
446
+ end = i
447
+ }
448
+ } else {
449
+ extIdx = -1
450
+ end = firstNonSlashEnd
451
+ }
452
+ }
453
+ }
454
+ }
455
+
456
+ if (start === end) end = firstNonSlashEnd
457
+ else if (end === -1) end = path.length
458
+ return path.substring(start, end)
459
+ }
460
+ for (let i = path.length - 1; i >= start; --i) {
461
+ if (isWindowsPathSeparator(path.charCodeAt(i))) {
462
+ if (!matchedSlash) {
463
+ start = i + 1
464
+ break
465
+ }
466
+ } else if (end === -1) {
467
+ matchedSlash = false
468
+ end = i + 1
469
+ }
470
+ }
471
+
472
+ if (end === -1) return ''
473
+ return path.substring(start, end)
474
+ }
475
+
476
+ exports.extname = function extname (path) {
477
+ let start = 0
478
+ let startDot = -1
479
+ let startPart = 0
480
+ let end = -1
481
+ let matchedSlash = true
482
+ let preDotState = 0
483
+
484
+ if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
485
+ start = startPart = 2
486
+ }
487
+
488
+ for (let i = path.length - 1; i >= start; --i) {
489
+ const code = path.charCodeAt(i)
490
+ if (isWindowsPathSeparator(code)) {
491
+ if (!matchedSlash) {
492
+ startPart = i + 1
493
+ break
494
+ }
495
+ continue
496
+ }
497
+ if (end === -1) {
498
+ matchedSlash = false
499
+ end = i + 1
500
+ }
501
+ if (code === CHAR_DOT) {
502
+ if (startDot === -1) startDot = i
503
+ else if (preDotState !== 1) preDotState = 1
504
+ } else if (startDot !== -1) {
505
+ preDotState = -1
506
+ }
507
+ }
508
+
509
+ if (startDot === -1 || end === -1 || preDotState === 0 || (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
510
+ return ''
511
+ }
512
+ return path.substring(startDot, end)
513
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "bare-path",
3
+ "version": "3.0.0",
4
+ "description": "Path manipulation library for JavaScript",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./package": "./package.json",
8
+ "./posix": "./lib/posix.js",
9
+ "./win32": "./lib/win32.js"
10
+ },
11
+ "files": [
12
+ "index.js",
13
+ "lib",
14
+ "NOTICE"
15
+ ],
16
+ "scripts": {
17
+ "test": "standard && bare test.js"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/holepunchto/bare-path.git"
22
+ },
23
+ "author": "Holepunch",
24
+ "license": "Apache-2.0",
25
+ "bugs": {
26
+ "url": "https://github.com/holepunchto/bare-path/issues"
27
+ },
28
+ "homepage": "https://github.com/holepunchto/bare-path#readme",
29
+ "dependencies": {
30
+ "bare-os": "^3.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "brittle": "^3.3.2",
34
+ "standard": "^17.0.0"
35
+ }
36
+ }