cline 1.0.1 → 1.0.2

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,450 @@
1
+ const path = require('bare-path')
2
+ const binding = require('./binding')
3
+ const errors = require('./lib/errors')
4
+ const URLSearchParams = require('./lib/url-search-params')
5
+
6
+ const kind = Symbol.for('bare.url.kind')
7
+
8
+ const isWindows = Bare.platform === 'win32'
9
+
10
+ module.exports = exports = class URL {
11
+ static get [kind]() {
12
+ return 0 // Compatibility version
13
+ }
14
+
15
+ constructor(input, base, opts = {}) {
16
+ if (arguments.length === 0) throw errors.INVALID_URL()
17
+
18
+ input = String(input)
19
+
20
+ if (base !== undefined) base = String(base)
21
+
22
+ this._components = new Uint32Array(8)
23
+
24
+ this._parse(input, base, opts.throw !== false)
25
+
26
+ if (this._href) this._params = new URLSearchParams(this.search, this)
27
+ }
28
+
29
+ get [kind]() {
30
+ return URL[kind]
31
+ }
32
+
33
+ // https://url.spec.whatwg.org/#dom-url-href
34
+
35
+ get href() {
36
+ return this._href
37
+ }
38
+
39
+ set href(value) {
40
+ this._update(value)
41
+
42
+ this._params._parse(this.search)
43
+ }
44
+
45
+ // https://url.spec.whatwg.org/#dom-url-protocol
46
+
47
+ get protocol() {
48
+ return this._slice(0, this._components[0]) + ':'
49
+ }
50
+
51
+ set protocol(value) {
52
+ this._update(
53
+ this._replace(value.replace(/:+$/, ''), 0, this._components[0])
54
+ )
55
+ }
56
+
57
+ // https://url.spec.whatwg.org/#dom-url-username
58
+
59
+ get username() {
60
+ return this._slice(this._components[0] + 3 /* :// */, this._components[1])
61
+ }
62
+
63
+ set username(value) {
64
+ if (cannotHaveCredentialsOrPort(this)) {
65
+ return
66
+ }
67
+
68
+ if (this.username === '') value += '@'
69
+
70
+ this._update(
71
+ this._replace(
72
+ value,
73
+ this._components[0] + 3 /* :// */,
74
+ this._components[1]
75
+ )
76
+ )
77
+ }
78
+
79
+ // https://url.spec.whatwg.org/#dom-url-password
80
+
81
+ get password() {
82
+ return this._href.slice(
83
+ this._components[1] + 1 /* : */,
84
+ this._components[2] - 1 /* @ */
85
+ )
86
+ }
87
+
88
+ set password(value) {
89
+ if (cannotHaveCredentialsOrPort(this)) {
90
+ return
91
+ }
92
+
93
+ let start = this._components[1] + 1 /* : */
94
+ let end = this._components[2] - 1 /* @ */
95
+
96
+ if (this.password === '') {
97
+ value = ':' + value
98
+ start--
99
+ }
100
+
101
+ if (this.username === '') {
102
+ value += '@'
103
+ end++
104
+ }
105
+
106
+ this._update(this._replace(value, start, end))
107
+ }
108
+
109
+ // https://url.spec.whatwg.org/#dom-url-host
110
+
111
+ get host() {
112
+ return this._slice(this._components[2], this._components[5])
113
+ }
114
+
115
+ set host(value) {
116
+ if (hasOpaquePath(this)) {
117
+ return
118
+ }
119
+
120
+ this._update(
121
+ this._replace(
122
+ value,
123
+ this._components[2],
124
+ this._components[value.includes(':') ? 5 : 3]
125
+ )
126
+ )
127
+ }
128
+
129
+ // https://url.spec.whatwg.org/#dom-url-hostname
130
+
131
+ get hostname() {
132
+ return this._slice(this._components[2], this._components[3])
133
+ }
134
+
135
+ set hostname(value) {
136
+ if (hasOpaquePath(this)) {
137
+ return
138
+ }
139
+
140
+ this._update(this._replace(value, this._components[2], this._components[3]))
141
+ }
142
+
143
+ // https://url.spec.whatwg.org/#dom-url-port
144
+
145
+ get port() {
146
+ return this._slice(this._components[3] + 1 /* : */, this._components[5])
147
+ }
148
+
149
+ set port(value) {
150
+ if (cannotHaveCredentialsOrPort(this)) {
151
+ return
152
+ }
153
+
154
+ let start = this._components[3] + 1 /* : */
155
+
156
+ if (this.port === '') {
157
+ value = ':' + value
158
+ start--
159
+ }
160
+
161
+ this._update(this._replace(value, start, this._components[5]))
162
+ }
163
+
164
+ // https://url.spec.whatwg.org/#dom-url-pathname
165
+
166
+ get pathname() {
167
+ return this._slice(this._components[5], this._components[6] - 1 /* ? */)
168
+ }
169
+
170
+ set pathname(value) {
171
+ if (hasOpaquePath(this)) {
172
+ return
173
+ }
174
+
175
+ if (value[0] !== '/' && value[0] !== '\\') {
176
+ value = '/' + value
177
+ }
178
+
179
+ this._update(
180
+ this._replace(value, this._components[5], this._components[6] - 1 /* ? */)
181
+ )
182
+ }
183
+
184
+ // https://url.spec.whatwg.org/#dom-url-search
185
+
186
+ get search() {
187
+ return this._slice(
188
+ this._components[6] - 1 /* ? */,
189
+ this._components[7] - 1 /* # */
190
+ )
191
+ }
192
+
193
+ set search(value) {
194
+ if (value && value[0] !== '?') value = '?' + value
195
+
196
+ this._update(
197
+ this._replace(
198
+ value,
199
+ this._components[6] - 1 /* ? */,
200
+ this._components[7] - 1 /* # */
201
+ )
202
+ )
203
+
204
+ this._params._parse(this.search)
205
+ }
206
+
207
+ // https://url.spec.whatwg.org/#dom-url-searchparams
208
+
209
+ get searchParams() {
210
+ return this._params
211
+ }
212
+
213
+ // https://url.spec.whatwg.org/#dom-url-hash
214
+
215
+ get hash() {
216
+ return this._slice(this._components[7] - 1 /* # */)
217
+ }
218
+
219
+ set hash(value) {
220
+ if (value && value[0] !== '#') value = '#' + value
221
+
222
+ this._update(this._replace(value, this._components[7] - 1 /* # */))
223
+ }
224
+
225
+ toString() {
226
+ return this._href
227
+ }
228
+
229
+ toJSON() {
230
+ return this._href
231
+ }
232
+
233
+ [Symbol.for('bare.inspect')]() {
234
+ return {
235
+ __proto__: { constructor: URL },
236
+
237
+ href: this.href,
238
+ protocol: this.protocol,
239
+ username: this.username,
240
+ password: this.password,
241
+ host: this.host,
242
+ hostname: this.hostname,
243
+ port: this.port,
244
+ pathname: this.pathname,
245
+ search: this.search,
246
+ searchParams: this.searchParams,
247
+ hash: this.hash
248
+ }
249
+ }
250
+
251
+ _slice(start, end = this._href.length) {
252
+ return this._href.slice(start, end)
253
+ }
254
+
255
+ _replace(replacement, start, end = this._href.length) {
256
+ return this._slice(0, start) + replacement + this._slice(end)
257
+ }
258
+
259
+ _parse(input, base, shouldThrow) {
260
+ try {
261
+ this._href = binding.parse(
262
+ String(input),
263
+ base ? String(base) : null,
264
+ this._components,
265
+ shouldThrow
266
+ )
267
+ } catch (err) {
268
+ if (err instanceof TypeError) throw err
269
+
270
+ throw errors.INVALID_URL()
271
+ }
272
+ }
273
+
274
+ _update(input) {
275
+ try {
276
+ this._parse(input, null, true)
277
+ } catch (err) {
278
+ if (err instanceof TypeError) throw err
279
+ }
280
+ }
281
+ }
282
+
283
+ // https://url.spec.whatwg.org/#url-opaque-path
284
+ function hasOpaquePath(url) {
285
+ return url.pathname[0] !== '/'
286
+ }
287
+
288
+ // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
289
+ function cannotHaveCredentialsOrPort(url) {
290
+ return url.hostname === '' || url.protocol === 'file:'
291
+ }
292
+
293
+ const URL = exports
294
+
295
+ exports.URL = URL
296
+ exports.URLSearchParams = URLSearchParams
297
+
298
+ exports.errors = errors
299
+
300
+ exports.isURL = function isURL(value) {
301
+ if (value instanceof URL) return true
302
+
303
+ return (
304
+ typeof value === 'object' && value !== null && value[kind] === URL[kind]
305
+ )
306
+ }
307
+
308
+ // https://url.spec.whatwg.org/#dom-url-parse
309
+ exports.parse = function parse(input, base) {
310
+ const url = new URL(input, base, { throw: false })
311
+ return url._href ? url : null
312
+ }
313
+
314
+ // https://url.spec.whatwg.org/#dom-url-canparse
315
+ exports.canParse = function canParse(input, base) {
316
+ return binding.canParse(String(input), base ? String(base) : null)
317
+ }
318
+
319
+ exports.fileURLToPath = function fileURLToPath(url) {
320
+ if (typeof url === 'string') {
321
+ url = new URL(url)
322
+ }
323
+
324
+ if (url.protocol !== 'file:') {
325
+ throw errors.INVALID_URL_SCHEME('The URL must use the file: protocol')
326
+ }
327
+
328
+ if (isWindows) {
329
+ if (/%2f|%5c/i.test(url.pathname)) {
330
+ throw errors.INVALID_FILE_URL_PATH(
331
+ 'The file: URL path must not include encoded \\ or / characters'
332
+ )
333
+ }
334
+ } else {
335
+ if (url.hostname) {
336
+ throw errors.INVALID_FILE_URL_HOST(
337
+ "The file: URL host must be 'localhost' or empty"
338
+ )
339
+ }
340
+
341
+ if (/%2f/i.test(url.pathname)) {
342
+ throw errors.INVALID_FILE_URL_PATH(
343
+ 'The file: URL path must not include encoded / characters'
344
+ )
345
+ }
346
+ }
347
+
348
+ const pathname = path.normalize(decodeURIComponent(url.pathname))
349
+
350
+ if (isWindows) {
351
+ if (url.hostname) return '\\\\' + url.hostname + pathname
352
+
353
+ const letter = pathname.charCodeAt(1) | 0x20
354
+
355
+ if (
356
+ letter < 0x61 /* a */ ||
357
+ letter > 0x7a /* z */ ||
358
+ pathname.charCodeAt(2) !== 0x3a /* : */
359
+ ) {
360
+ throw errors.INVALID_FILE_URL_PATH('The file: URL path must be absolute')
361
+ }
362
+
363
+ return pathname.slice(1)
364
+ }
365
+
366
+ return pathname
367
+ }
368
+
369
+ exports.pathToFileURL = function pathToFileURL(pathname) {
370
+ let resolved = path.resolve(pathname)
371
+
372
+ if (pathname[pathname.length - 1] === '/') {
373
+ resolved += '/'
374
+ } else if (isWindows && pathname[pathname.length - 1] === '\\') {
375
+ resolved += '\\'
376
+ }
377
+
378
+ resolved = resolved
379
+ .replaceAll('%', '%25') // Must be first
380
+ .replaceAll('#', '%23')
381
+ .replaceAll('?', '%3f')
382
+ .replaceAll('\n', '%0a')
383
+ .replaceAll('\r', '%0d')
384
+ .replaceAll('\t', '%09')
385
+
386
+ if (!isWindows) {
387
+ resolved = resolved.replaceAll('\\', '%5c')
388
+ }
389
+
390
+ return new URL('file:' + resolved)
391
+ }
392
+
393
+ exports.format = function format(parts) {
394
+ const {
395
+ protocol,
396
+ auth,
397
+ host,
398
+ hostname,
399
+ port,
400
+ pathname,
401
+ search,
402
+ query,
403
+ hash,
404
+ slashes
405
+ } = parts
406
+
407
+ let result = ''
408
+
409
+ if (typeof protocol === 'string') {
410
+ result += protocol
411
+
412
+ if (protocol[protocol.length - 1] !== ':') {
413
+ result += ':'
414
+ }
415
+
416
+ if (slashes === true || /https?|ftp|gopher|file/.test(protocol)) {
417
+ result += '//'
418
+ }
419
+ }
420
+
421
+ if (typeof auth === 'string') {
422
+ if (host || hostname) result += auth + '@'
423
+ }
424
+
425
+ if (typeof host === 'string') result += host
426
+ else {
427
+ result += hostname
428
+
429
+ if (port) result += ':' + port
430
+ }
431
+
432
+ if (typeof pathname === 'string' && pathname !== '') {
433
+ if (pathname[0] !== '/') result += '/'
434
+ result += pathname
435
+ }
436
+
437
+ if (typeof search === 'string') {
438
+ if (search[0] !== '?') result += '?'
439
+ result += search
440
+ } else if (typeof query === 'object' && query !== null) {
441
+ result += '?' + new URLSearchParams(query)
442
+ }
443
+
444
+ if (typeof hash === 'string') {
445
+ if (hash[0] !== '#') result += '#'
446
+ result += hash
447
+ }
448
+
449
+ return result
450
+ }
@@ -0,0 +1,8 @@
1
+ declare class URLError extends Error {
2
+ static INVALID_URL(msg?: string): URLError
3
+ static INVALID_URL_SCHEME(msg?: string): URLError
4
+ static INVALID_FILE_URL_HOST(msg?: string): URLError
5
+ static INVALID_FILE_URL_PATH(msg?: string): URLError
6
+ }
7
+
8
+ export = URLError
@@ -0,0 +1,38 @@
1
+ module.exports = class URLError extends Error {
2
+ constructor(msg, code, fn = URLError) {
3
+ super(`${code}: ${msg}`)
4
+ this.code = code
5
+
6
+ if (Error.captureStackTrace) {
7
+ Error.captureStackTrace(this, fn)
8
+ }
9
+ }
10
+
11
+ get name() {
12
+ return 'URLError'
13
+ }
14
+
15
+ static INVALID_URL(msg = 'Invalid URL') {
16
+ return new URLError(msg, 'INVALID_URL', URLError.INVALID_URL)
17
+ }
18
+
19
+ static INVALID_URL_SCHEME(msg = 'Invalid URL') {
20
+ return new URLError(msg, 'INVALID_URL_SCHEME', URLError.INVALID_URL_SCHEME)
21
+ }
22
+
23
+ static INVALID_FILE_URL_HOST(msg = 'Invalid file: URL host') {
24
+ return new URLError(
25
+ msg,
26
+ 'INVALID_FILE_URL_HOST',
27
+ URLError.INVALID_FILE_URL_HOST
28
+ )
29
+ }
30
+
31
+ static INVALID_FILE_URL_PATH(msg = 'Invalid file: URL path') {
32
+ return new URLError(
33
+ msg,
34
+ 'INVALID_FILE_URL_PATH',
35
+ URLError.INVALID_FILE_URL_PATH
36
+ )
37
+ }
38
+ }
@@ -0,0 +1,21 @@
1
+ interface URLSearchParams extends Iterable<[name: string, value: string]> {
2
+ readonly size: number
3
+
4
+ append(name: string, value: string): void
5
+ delete(name: string, value?: string): void
6
+ get(name: string): string | undefined
7
+ getAll(name: string): string[]
8
+ has(name: string, value?: string): boolean
9
+ set(name: string, value: string): void
10
+
11
+ toString(): string
12
+ toJSON(): string
13
+ }
14
+
15
+ declare class URLSearchParams {
16
+ constructor(
17
+ init: string | Record<string, string> | Iterable<[string, string]>
18
+ )
19
+ }
20
+
21
+ export = URLSearchParams
@@ -0,0 +1,176 @@
1
+ module.exports = class URLSearchParams {
2
+ static _urls = new WeakMap()
3
+
4
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
5
+ constructor(init, url = null) {
6
+ this._params = new Map()
7
+
8
+ if (url) URLSearchParams._urls.set(this, url)
9
+
10
+ if (typeof init === 'string') {
11
+ this._parse(init)
12
+ } else if (init) {
13
+ for (const [name, value] of typeof init[Symbol.iterator] === 'function'
14
+ ? init
15
+ : Object.entries(init)) {
16
+ this.append(name, value)
17
+ }
18
+ }
19
+ }
20
+
21
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-size
22
+ get size() {
23
+ return this._params.length
24
+ }
25
+
26
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-append
27
+ append(name, value = null) {
28
+ if (value === null) return
29
+
30
+ let list = this._params.get(name)
31
+
32
+ if (list === undefined) {
33
+ list = []
34
+ this._params.set(name, list)
35
+ }
36
+
37
+ list.push(value)
38
+
39
+ this._update()
40
+ }
41
+
42
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
43
+ delete(name, value = null) {
44
+ if (value === null) this._params.delete(name)
45
+ else {
46
+ let list = this._params.get(name)
47
+
48
+ if (list === undefined) return
49
+
50
+ list = list.filter((found) => found !== value)
51
+
52
+ if (list.length === 0) this._params.delete(name)
53
+ else this._params.set(name, list)
54
+ }
55
+
56
+ this._update()
57
+ }
58
+
59
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-get
60
+ get(name) {
61
+ const list = this._params.get(name)
62
+
63
+ if (list === undefined) return null
64
+
65
+ return list[0]
66
+ }
67
+
68
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
69
+ getAll(name) {
70
+ const list = this._params.get(name)
71
+
72
+ if (list === undefined) return []
73
+
74
+ return Array.from(list)
75
+ }
76
+
77
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-has
78
+ has(name, value = null) {
79
+ const list = this._params.get(name)
80
+
81
+ if (list === undefined) return false
82
+
83
+ if (value === null) return true
84
+
85
+ return list.includes(value)
86
+ }
87
+
88
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-set
89
+ set(name, value = null) {
90
+ if (value === null) this._params.delete(name)
91
+ else this._params.set(name, [value])
92
+
93
+ this._update()
94
+ }
95
+
96
+ toString() {
97
+ return this._serialize()
98
+ }
99
+
100
+ toJSON() {
101
+ return [...this]
102
+ }
103
+
104
+ *[Symbol.iterator]() {
105
+ for (const [name, values] of this._params) {
106
+ for (const value of values) yield [name, value]
107
+ }
108
+ }
109
+
110
+ [Symbol.for('bare.inspect')]() {
111
+ const object = {
112
+ __proto__: { constructor: URLSearchParams }
113
+ }
114
+
115
+ for (const [name, values] of this._params) {
116
+ if (values.length === 1) object[name] = values[0]
117
+ else object[name] = values
118
+ }
119
+
120
+ return object
121
+ }
122
+
123
+ // https://url.spec.whatwg.org/#concept-urlsearchparams-update
124
+ _update() {
125
+ const url = URLSearchParams._urls.get(this)
126
+
127
+ if (url === undefined) return
128
+
129
+ url.search = this._serialize()
130
+ }
131
+
132
+ // https://url.spec.whatwg.org/#concept-urlencoded-parser
133
+ _parse(input) {
134
+ if (input[0] === '?') input = input.substring(1)
135
+
136
+ this._params = new Map()
137
+
138
+ for (const sequence of input.split('&')) {
139
+ if (sequence.length === 0) continue
140
+
141
+ let i = sequence.indexOf('=')
142
+ if (i === -1) i = sequence.length
143
+
144
+ const name = decodeURIComponent(sequence.substring(0, i))
145
+ const value = decodeURIComponent(
146
+ sequence.substring(i + 1, sequence.length)
147
+ )
148
+
149
+ let list = this._params.get(name)
150
+
151
+ if (list === undefined) {
152
+ list = []
153
+ this._params.set(name, list)
154
+ }
155
+
156
+ list.push(value)
157
+ }
158
+ }
159
+
160
+ // https://url.spec.whatwg.org/#concept-urlencoded-serializer
161
+ _serialize() {
162
+ let output = ''
163
+
164
+ for (let [name, values] of this._params) {
165
+ name = encodeURIComponent(name)
166
+
167
+ for (const value of values) {
168
+ if (output) output += '&'
169
+
170
+ output += name + '=' + encodeURIComponent(value)
171
+ }
172
+ }
173
+
174
+ return output
175
+ }
176
+ }