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.
- package/bin/cline +0 -0
- package/bin/cline-darwin-amd64 +0 -0
- package/bin/cline-darwin-arm64 +0 -0
- package/bin/cline-host +0 -0
- package/bin/cline-host-darwin-amd64 +0 -0
- package/bin/cline-host-darwin-arm64 +0 -0
- package/bin/cline-host-linux-amd64 +0 -0
- package/bin/cline-host-linux-arm64 +0 -0
- package/bin/cline-linux-amd64 +0 -0
- package/bin/cline-linux-arm64 +0 -0
- package/cline-core.js +24143 -16610
- package/extension/package.json +12 -4
- package/node_modules/b4a/LICENSE +201 -0
- package/node_modules/b4a/README.md +153 -0
- package/node_modules/b4a/browser.js +563 -0
- package/node_modules/b4a/index.js +188 -0
- package/node_modules/b4a/lib/ascii.js +31 -0
- package/node_modules/b4a/lib/base64.js +65 -0
- package/node_modules/b4a/lib/hex.js +51 -0
- package/node_modules/b4a/lib/utf16le.js +40 -0
- package/node_modules/b4a/lib/utf8.js +141 -0
- package/node_modules/b4a/package.json +49 -0
- package/node_modules/b4a/react-native.js +5 -0
- package/node_modules/bare-events/LICENSE +201 -0
- package/node_modules/bare-events/README.md +25 -0
- package/node_modules/bare-events/global.d.ts +15 -0
- package/node_modules/bare-events/global.js +5 -0
- package/node_modules/bare-events/index.d.ts +94 -0
- package/node_modules/bare-events/index.js +355 -0
- package/node_modules/bare-events/lib/errors.js +32 -0
- package/node_modules/bare-events/package.json +61 -0
- package/node_modules/bare-events/web.d.ts +79 -0
- package/node_modules/bare-events/web.js +347 -0
- package/node_modules/bare-fs/CMakeLists.txt +13 -0
- package/node_modules/bare-fs/LICENSE +201 -0
- package/node_modules/bare-fs/README.md +29 -0
- package/node_modules/bare-fs/binding.c +2238 -0
- package/node_modules/bare-fs/binding.js +1 -0
- package/node_modules/bare-fs/index.d.ts +1115 -0
- package/node_modules/bare-fs/index.js +2330 -0
- package/node_modules/bare-fs/lib/constants.d.ts +49 -0
- package/node_modules/bare-fs/lib/constants.js +49 -0
- package/node_modules/bare-fs/lib/errors.d.ts +11 -0
- package/node_modules/bare-fs/lib/errors.js +55 -0
- package/node_modules/bare-fs/package.json +71 -0
- package/node_modules/bare-fs/prebuilds/android-arm/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/android-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/android-ia32/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/android-x64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/darwin-x64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/ios-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/win32-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/promises.d.ts +282 -0
- package/node_modules/bare-fs/promises.js +90 -0
- package/node_modules/bare-os/CMakeLists.txt +13 -0
- package/node_modules/bare-os/LICENSE +201 -0
- package/node_modules/bare-os/README.md +11 -0
- package/node_modules/bare-os/binding.c +1119 -0
- package/node_modules/bare-os/binding.js +1 -0
- package/node_modules/bare-os/index.d.ts +109 -0
- package/node_modules/bare-os/index.js +99 -0
- package/node_modules/bare-os/lib/constants.js +6 -0
- package/node_modules/bare-os/lib/errors.js +22 -0
- package/node_modules/bare-os/package.json +46 -0
- package/node_modules/bare-os/prebuilds/android-arm/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/android-arm64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/android-ia32/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/android-x64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/darwin-arm64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/darwin-x64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/ios-arm64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/ios-arm64-simulator/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/ios-x64-simulator/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/linux-arm64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/linux-x64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/win32-arm64/bare-os.bare +0 -0
- package/node_modules/bare-os/prebuilds/win32-x64/bare-os.bare +0 -0
- package/node_modules/bare-path/LICENSE +201 -0
- package/node_modules/bare-path/NOTICE +28 -0
- package/node_modules/bare-path/README.md +19 -0
- package/node_modules/bare-path/index.js +11 -0
- package/node_modules/bare-path/lib/constants.js +11 -0
- package/node_modules/bare-path/lib/posix.js +242 -0
- package/node_modules/bare-path/lib/shared.js +67 -0
- package/node_modules/bare-path/lib/win32.js +513 -0
- package/node_modules/bare-path/package.json +36 -0
- package/node_modules/bare-stream/LICENSE +201 -0
- package/node_modules/bare-stream/README.md +15 -0
- package/node_modules/bare-stream/global.js +8 -0
- package/node_modules/bare-stream/index.d.ts +237 -0
- package/node_modules/bare-stream/index.js +355 -0
- package/node_modules/bare-stream/package.json +61 -0
- package/node_modules/bare-stream/promises.js +3 -0
- package/node_modules/bare-stream/web.d.ts +73 -0
- package/node_modules/bare-stream/web.js +229 -0
- package/node_modules/bare-url/CMakeLists.txt +27 -0
- package/node_modules/bare-url/LICENSE +201 -0
- package/node_modules/bare-url/README.md +19 -0
- package/node_modules/bare-url/binding.c +188 -0
- package/node_modules/bare-url/binding.js +1 -0
- package/node_modules/bare-url/global.d.ts +12 -0
- package/node_modules/bare-url/global.js +2 -0
- package/node_modules/bare-url/index.d.ts +39 -0
- package/node_modules/bare-url/index.js +450 -0
- package/node_modules/bare-url/lib/errors.d.ts +8 -0
- package/node_modules/bare-url/lib/errors.js +38 -0
- package/node_modules/bare-url/lib/url-search-params.d.ts +21 -0
- package/node_modules/bare-url/lib/url-search-params.js +176 -0
- package/node_modules/bare-url/package.json +51 -0
- package/node_modules/bare-url/prebuilds/android-arm/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/android-arm64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/android-ia32/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/android-x64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/darwin-x64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/linux-arm64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/linux-x64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare +0 -0
- package/node_modules/bare-url/prebuilds/win32-x64/bare-url.bare +0 -0
- package/node_modules/better-sqlite3/deps/download.sh +1 -1
- package/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c +122 -81
- package/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h +45 -45
- package/node_modules/better-sqlite3/lib/database.js +1 -1
- package/node_modules/better-sqlite3/package.json +4 -7
- package/node_modules/better-sqlite3/src/addon.cpp +47 -0
- package/node_modules/better-sqlite3/src/better_sqlite3.cpp +44 -2164
- package/node_modules/better-sqlite3/src/objects/backup.cpp +120 -0
- package/node_modules/better-sqlite3/src/objects/backup.hpp +36 -0
- package/node_modules/better-sqlite3/src/objects/database.cpp +417 -0
- package/node_modules/better-sqlite3/src/objects/database.hpp +103 -0
- package/node_modules/better-sqlite3/src/objects/statement-iterator.cpp +113 -0
- package/node_modules/better-sqlite3/src/objects/statement-iterator.hpp +50 -0
- package/node_modules/better-sqlite3/src/objects/statement.cpp +383 -0
- package/node_modules/better-sqlite3/src/objects/statement.hpp +58 -0
- package/node_modules/better-sqlite3/src/util/bind-map.cpp +73 -0
- package/node_modules/better-sqlite3/src/util/binder.cpp +193 -0
- package/node_modules/better-sqlite3/src/util/constants.cpp +172 -0
- package/node_modules/better-sqlite3/src/util/custom-aggregate.cpp +121 -0
- package/node_modules/better-sqlite3/src/util/custom-function.cpp +59 -0
- package/node_modules/better-sqlite3/src/util/custom-table.cpp +409 -0
- package/node_modules/better-sqlite3/src/util/data-converter.cpp +17 -0
- package/node_modules/better-sqlite3/src/util/data.cpp +194 -0
- package/node_modules/better-sqlite3/src/util/helpers.cpp +109 -0
- package/node_modules/better-sqlite3/src/util/macros.cpp +63 -0
- package/node_modules/better-sqlite3/src/util/query-macros.cpp +71 -0
- package/node_modules/better-sqlite3/src/util/row-builder.cpp +49 -0
- package/node_modules/events-universal/LICENSE +201 -0
- package/node_modules/events-universal/README.md +17 -0
- package/node_modules/events-universal/bare.js +1 -0
- package/node_modules/events-universal/default.js +1 -0
- package/node_modules/events-universal/index.js +1 -0
- package/node_modules/events-universal/package.json +39 -0
- package/node_modules/events-universal/react-native.js +1 -0
- package/node_modules/{fs-constants → fast-fifo}/LICENSE +1 -1
- package/node_modules/fast-fifo/README.md +78 -0
- package/node_modules/fast-fifo/fixed-size.js +39 -0
- package/node_modules/fast-fifo/index.js +48 -0
- package/node_modules/fast-fifo/package.json +28 -0
- package/node_modules/{base64-js → streamx}/LICENSE +1 -1
- package/node_modules/streamx/README.md +489 -0
- package/node_modules/streamx/index.js +1184 -0
- package/node_modules/streamx/package.json +34 -0
- package/node_modules/tar-fs/README.md +23 -34
- package/node_modules/tar-fs/index.js +211 -184
- package/node_modules/tar-fs/package.json +27 -7
- package/node_modules/tar-stream/README.md +34 -19
- package/node_modules/tar-stream/constants.js +14 -0
- package/node_modules/tar-stream/extract.js +341 -192
- package/node_modules/tar-stream/headers.js +201 -175
- package/node_modules/tar-stream/pack.js +226 -194
- package/node_modules/tar-stream/package.json +23 -46
- package/node_modules/text-decoder/LICENSE +201 -0
- package/node_modules/text-decoder/README.md +36 -0
- package/node_modules/text-decoder/index.js +64 -0
- package/node_modules/text-decoder/lib/browser-decoder.js +17 -0
- package/node_modules/text-decoder/lib/pass-through-decoder.js +19 -0
- package/node_modules/text-decoder/lib/utf8-decoder.js +104 -0
- package/node_modules/text-decoder/package.json +38 -0
- package/package.json +1 -1
- package/proto/cline/account.proto +10 -8
- package/proto/cline/browser.proto +3 -1
- package/proto/cline/checkpoints.proto +5 -3
- package/proto/cline/commands.proto +4 -2
- package/proto/cline/common.proto +5 -7
- package/proto/cline/dictation.proto +3 -1
- package/proto/cline/file.proto +36 -34
- package/proto/cline/hooks.proto +3 -2
- package/proto/cline/mcp.proto +6 -4
- package/proto/cline/models.proto +189 -19
- package/proto/cline/oca_account.proto +6 -7
- package/proto/cline/slash.proto +3 -1
- package/proto/cline/state.proto +144 -292
- package/proto/cline/task.proto +4 -2
- package/proto/cline/ui.proto +25 -24
- package/proto/cline/web.proto +3 -1
- package/proto/descriptor_set.pb +0 -0
- package/proto/host/diff.proto +5 -4
- package/proto/host/env.proto +8 -7
- package/proto/host/testing.proto +3 -3
- package/proto/host/window.proto +2 -2
- package/proto/host/workspace.proto +13 -12
- package/node_modules/base64-js/README.md +0 -34
- package/node_modules/base64-js/base64js.min.js +0 -1
- package/node_modules/base64-js/index.d.ts +0 -3
- package/node_modules/base64-js/index.js +0 -150
- package/node_modules/base64-js/package.json +0 -47
- package/node_modules/better-sqlite3/src/better_sqlite3.hpp +0 -1036
- package/node_modules/bl/.travis.yml +0 -17
- package/node_modules/bl/BufferList.js +0 -396
- package/node_modules/bl/LICENSE.md +0 -13
- package/node_modules/bl/README.md +0 -247
- package/node_modules/bl/bl.js +0 -84
- package/node_modules/bl/package.json +0 -37
- package/node_modules/bl/test/convert.js +0 -21
- package/node_modules/bl/test/indexOf.js +0 -492
- package/node_modules/bl/test/isBufferList.js +0 -32
- package/node_modules/bl/test/test.js +0 -869
- package/node_modules/buffer/AUTHORS.md +0 -70
- package/node_modules/buffer/LICENSE +0 -21
- package/node_modules/buffer/README.md +0 -410
- package/node_modules/buffer/index.d.ts +0 -186
- package/node_modules/buffer/index.js +0 -1817
- package/node_modules/buffer/package.json +0 -96
- package/node_modules/chownr/LICENSE +0 -15
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/chownr.js +0 -167
- package/node_modules/chownr/package.json +0 -29
- package/node_modules/fs-constants/README.md +0 -26
- package/node_modules/fs-constants/browser.js +0 -1
- package/node_modules/fs-constants/index.js +0 -1
- package/node_modules/fs-constants/package.json +0 -19
- package/node_modules/ieee754/LICENSE +0 -11
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/ieee754/index.d.ts +0 -10
- package/node_modules/ieee754/index.js +0 -85
- package/node_modules/ieee754/package.json +0 -52
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/readable-stream/README.md +0 -106
- package/node_modules/readable-stream/errors-browser.js +0 -127
- package/node_modules/readable-stream/errors.js +0 -116
- package/node_modules/readable-stream/experimentalWarning.js +0 -17
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -126
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -37
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -1027
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -190
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -641
- package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -180
- package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -183
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -96
- package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -86
- package/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -3
- package/node_modules/readable-stream/lib/internal/streams/from.js +0 -52
- package/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -86
- package/node_modules/readable-stream/lib/internal/streams/state.js +0 -22
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/readable-stream/package.json +0 -68
- package/node_modules/readable-stream/readable-browser.js +0 -9
- package/node_modules/readable-stream/readable.js +0 -16
- package/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/string_decoder/README.md +0 -47
- package/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/string_decoder/package.json +0 -34
- package/node_modules/tar-fs/.travis.yml +0 -6
- package/node_modules/tar-fs/test/fixtures/a/hello.txt +0 -1
- package/node_modules/tar-fs/test/fixtures/b/a/test.txt +0 -1
- package/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
- package/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
- package/node_modules/tar-fs/test/fixtures/e/file +0 -0
- package/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
- package/node_modules/tar-fs/test/index.js +0 -346
- package/node_modules/tar-stream/sandbox.js +0 -11
- package/node_modules/util-deprecate/History.md +0 -16
- package/node_modules/util-deprecate/LICENSE +0 -24
- package/node_modules/util-deprecate/README.md +0 -53
- package/node_modules/util-deprecate/browser.js +0 -67
- package/node_modules/util-deprecate/node.js +0 -6
- package/node_modules/util-deprecate/package.json +0 -27
- package/test-startup.sh +0 -14
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
const os = require('bare-os')
|
|
2
|
+
|
|
3
|
+
const { normalizeString } = require('./shared')
|
|
4
|
+
const {
|
|
5
|
+
CHAR_DOT,
|
|
6
|
+
CHAR_FORWARD_SLASH
|
|
7
|
+
} = require('./constants')
|
|
8
|
+
|
|
9
|
+
function isPosixPathSeparator (code) {
|
|
10
|
+
return code === CHAR_FORWARD_SLASH
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.win32 = require('./win32')
|
|
14
|
+
exports.posix = exports
|
|
15
|
+
|
|
16
|
+
exports.sep = '/'
|
|
17
|
+
exports.delimiter = ':'
|
|
18
|
+
|
|
19
|
+
exports.resolve = function resolve (...args) {
|
|
20
|
+
let resolvedPath = ''
|
|
21
|
+
let resolvedAbsolute = false
|
|
22
|
+
|
|
23
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
24
|
+
const path = i >= 0 ? args[i] : os.cwd()
|
|
25
|
+
|
|
26
|
+
if (path.length === 0) {
|
|
27
|
+
continue
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
resolvedPath = `${path}/${resolvedPath}`
|
|
31
|
+
resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator)
|
|
35
|
+
|
|
36
|
+
if (resolvedAbsolute) {
|
|
37
|
+
return `/${resolvedPath}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return resolvedPath.length > 0 ? resolvedPath : '.'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.normalize = function normalize (path) {
|
|
44
|
+
if (path.length === 0) return '.'
|
|
45
|
+
|
|
46
|
+
const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH
|
|
47
|
+
const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH
|
|
48
|
+
|
|
49
|
+
path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator)
|
|
50
|
+
|
|
51
|
+
if (path.length === 0) {
|
|
52
|
+
if (isAbsolute) return '/'
|
|
53
|
+
return trailingSeparator ? './' : '.'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (trailingSeparator) path += '/'
|
|
57
|
+
|
|
58
|
+
return isAbsolute ? `/${path}` : path
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.isAbsolute = function isAbsolute (path) {
|
|
62
|
+
return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.join = function join (...args) {
|
|
66
|
+
if (args.length === 0) return '.'
|
|
67
|
+
let joined
|
|
68
|
+
for (let i = 0; i < args.length; ++i) {
|
|
69
|
+
const arg = args[i]
|
|
70
|
+
if (arg.length > 0) {
|
|
71
|
+
if (joined === undefined) joined = arg
|
|
72
|
+
else joined += `/${arg}`
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (joined === undefined) return '.'
|
|
76
|
+
return exports.normalize(joined)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.relative = function relative (from, to) {
|
|
80
|
+
if (from === to) return ''
|
|
81
|
+
|
|
82
|
+
from = exports.resolve(from)
|
|
83
|
+
to = exports.resolve(to)
|
|
84
|
+
|
|
85
|
+
if (from === to) return ''
|
|
86
|
+
|
|
87
|
+
const fromStart = 1
|
|
88
|
+
const fromEnd = from.length
|
|
89
|
+
const fromLen = fromEnd - fromStart
|
|
90
|
+
const toStart = 1
|
|
91
|
+
const toLen = to.length - toStart
|
|
92
|
+
|
|
93
|
+
const length = (fromLen < toLen ? fromLen : toLen)
|
|
94
|
+
let lastCommonSep = -1
|
|
95
|
+
let i = 0
|
|
96
|
+
for (; i < length; i++) {
|
|
97
|
+
const fromCode = from.charCodeAt(fromStart + i)
|
|
98
|
+
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
99
|
+
break
|
|
100
|
+
} else if (fromCode === CHAR_FORWARD_SLASH) {
|
|
101
|
+
lastCommonSep = i
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (i === length) {
|
|
105
|
+
if (toLen > length) {
|
|
106
|
+
if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
|
|
107
|
+
return to.substring(toStart + i + 1)
|
|
108
|
+
}
|
|
109
|
+
if (i === 0) {
|
|
110
|
+
return to.substring(toStart + i)
|
|
111
|
+
}
|
|
112
|
+
} else if (fromLen > length) {
|
|
113
|
+
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
|
|
114
|
+
lastCommonSep = i
|
|
115
|
+
} else if (i === 0) {
|
|
116
|
+
lastCommonSep = 0
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let out = ''
|
|
122
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
123
|
+
if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
124
|
+
out += out.length === 0 ? '..' : '/..'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return `${out}${to.substring(toStart + lastCommonSep)}`
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports.toNamespacedPath = function toNamespacedPath (path) {
|
|
132
|
+
return path
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exports.dirname = function dirname (path) {
|
|
136
|
+
if (path.length === 0) return '.'
|
|
137
|
+
const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH
|
|
138
|
+
let end = -1
|
|
139
|
+
let matchedSlash = true
|
|
140
|
+
for (let i = path.length - 1; i >= 1; --i) {
|
|
141
|
+
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
142
|
+
if (!matchedSlash) {
|
|
143
|
+
end = i
|
|
144
|
+
break
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
matchedSlash = false
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (end === -1) return hasRoot ? '/' : '.'
|
|
152
|
+
if (hasRoot && end === 1) return '//'
|
|
153
|
+
return path.substring(0, end)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.basename = function basename (path, suffix) {
|
|
157
|
+
let start = 0
|
|
158
|
+
let end = -1
|
|
159
|
+
let matchedSlash = true
|
|
160
|
+
|
|
161
|
+
if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {
|
|
162
|
+
if (suffix === path) { return '' }
|
|
163
|
+
let extIdx = suffix.length - 1
|
|
164
|
+
let firstNonSlashEnd = -1
|
|
165
|
+
for (let i = path.length - 1; i >= 0; --i) {
|
|
166
|
+
const code = path.charCodeAt(i)
|
|
167
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
168
|
+
if (!matchedSlash) {
|
|
169
|
+
start = i + 1
|
|
170
|
+
break
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
if (firstNonSlashEnd === -1) {
|
|
174
|
+
matchedSlash = false
|
|
175
|
+
firstNonSlashEnd = i + 1
|
|
176
|
+
}
|
|
177
|
+
if (extIdx >= 0) {
|
|
178
|
+
if (code === suffix.charCodeAt(extIdx)) {
|
|
179
|
+
if (--extIdx === -1) {
|
|
180
|
+
end = i
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
extIdx = -1
|
|
184
|
+
end = firstNonSlashEnd
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (start === end) end = firstNonSlashEnd
|
|
191
|
+
else if (end === -1) end = path.length
|
|
192
|
+
return path.substring(start, end)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (let i = path.length - 1; i >= 0; --i) {
|
|
196
|
+
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
197
|
+
if (!matchedSlash) {
|
|
198
|
+
start = i + 1
|
|
199
|
+
break
|
|
200
|
+
}
|
|
201
|
+
} else if (end === -1) {
|
|
202
|
+
matchedSlash = false
|
|
203
|
+
end = i + 1
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (end === -1) return ''
|
|
208
|
+
return path.substring(start, end)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
exports.extname = function extname (path) {
|
|
212
|
+
let startDot = -1
|
|
213
|
+
let startPart = 0
|
|
214
|
+
let end = -1
|
|
215
|
+
let matchedSlash = true
|
|
216
|
+
let preDotState = 0
|
|
217
|
+
for (let i = path.length - 1; i >= 0; --i) {
|
|
218
|
+
const code = path.charCodeAt(i)
|
|
219
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
220
|
+
if (!matchedSlash) {
|
|
221
|
+
startPart = i + 1
|
|
222
|
+
break
|
|
223
|
+
}
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
if (end === -1) {
|
|
227
|
+
matchedSlash = false
|
|
228
|
+
end = i + 1
|
|
229
|
+
}
|
|
230
|
+
if (code === CHAR_DOT) {
|
|
231
|
+
if (startDot === -1) startDot = i
|
|
232
|
+
else if (preDotState !== 1) preDotState = 1
|
|
233
|
+
} else if (startDot !== -1) {
|
|
234
|
+
preDotState = -1
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
|
|
239
|
+
return ''
|
|
240
|
+
}
|
|
241
|
+
return path.substring(startDot, end)
|
|
242
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const {
|
|
2
|
+
CHAR_DOT,
|
|
3
|
+
CHAR_FORWARD_SLASH
|
|
4
|
+
} = require('./constants')
|
|
5
|
+
|
|
6
|
+
exports.normalizeString = function normalizeString (path, allowAboveRoot, separator, isPathSeparator) {
|
|
7
|
+
let res = ''
|
|
8
|
+
let lastSegmentLength = 0
|
|
9
|
+
let lastSlash = -1
|
|
10
|
+
let dots = 0
|
|
11
|
+
let code = 0
|
|
12
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
13
|
+
if (i < path.length) {
|
|
14
|
+
code = path.charCodeAt(i)
|
|
15
|
+
} else if (isPathSeparator(code)) {
|
|
16
|
+
break
|
|
17
|
+
} else {
|
|
18
|
+
code = CHAR_FORWARD_SLASH
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (isPathSeparator(code)) {
|
|
22
|
+
if (lastSlash === i - 1 || dots === 1) ;
|
|
23
|
+
else if (dots === 2) {
|
|
24
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
|
25
|
+
if (res.length > 2) {
|
|
26
|
+
const lastSlashIndex = res.lastIndexOf(separator)
|
|
27
|
+
if (lastSlashIndex === -1) {
|
|
28
|
+
res = ''
|
|
29
|
+
lastSegmentLength = 0
|
|
30
|
+
} else {
|
|
31
|
+
res = res.substring(0, lastSlashIndex)
|
|
32
|
+
lastSegmentLength =
|
|
33
|
+
res.length - 1 - res.lastIndexOf(separator)
|
|
34
|
+
}
|
|
35
|
+
lastSlash = i
|
|
36
|
+
dots = 0
|
|
37
|
+
continue
|
|
38
|
+
} else if (res.length !== 0) {
|
|
39
|
+
res = ''
|
|
40
|
+
lastSegmentLength = 0
|
|
41
|
+
lastSlash = i
|
|
42
|
+
dots = 0
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (allowAboveRoot) {
|
|
47
|
+
res += res.length > 0 ? `${separator}..` : '..'
|
|
48
|
+
lastSegmentLength = 2
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
if (res.length > 0) {
|
|
52
|
+
res += `${separator}${path.substring(lastSlash + 1, i)}`
|
|
53
|
+
} else {
|
|
54
|
+
res = path.substring(lastSlash + 1, i)
|
|
55
|
+
}
|
|
56
|
+
lastSegmentLength = i - lastSlash - 1
|
|
57
|
+
}
|
|
58
|
+
lastSlash = i
|
|
59
|
+
dots = 0
|
|
60
|
+
} else if (code === CHAR_DOT && dots !== -1) {
|
|
61
|
+
++dots
|
|
62
|
+
} else {
|
|
63
|
+
dots = -1
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return res
|
|
67
|
+
}
|