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
|
@@ -1,257 +1,406 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { Writable, Readable, getStreamError } = require('streamx')
|
|
2
|
+
const FIFO = require('fast-fifo')
|
|
3
|
+
const b4a = require('b4a')
|
|
4
|
+
const headers = require('./headers')
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
var PassThrough = require('readable-stream').PassThrough
|
|
6
|
+
const EMPTY = b4a.alloc(0)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
class BufferList {
|
|
9
|
+
constructor () {
|
|
10
|
+
this.buffered = 0
|
|
11
|
+
this.shifted = 0
|
|
12
|
+
this.queue = new FIFO()
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return size && 512 - size
|
|
13
|
-
}
|
|
14
|
+
this._offset = 0
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
push (buffer) {
|
|
18
|
+
this.buffered += buffer.byteLength
|
|
19
|
+
this.queue.push(buffer)
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (pax.size) header.size = parseInt(pax.size, 10)
|
|
25
|
-
header.pax = pax
|
|
26
|
-
return header
|
|
27
|
-
}
|
|
22
|
+
shiftFirst (size) {
|
|
23
|
+
return this._buffered === 0 ? null : this._next(size)
|
|
24
|
+
}
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
PassThrough.call(this, { autoDestroy: false })
|
|
33
|
-
}
|
|
26
|
+
shift (size) {
|
|
27
|
+
if (size > this.buffered) return null
|
|
28
|
+
if (size === 0) return EMPTY
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
let chunk = this._next(size)
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
if (size === chunk.byteLength) return chunk // likely case
|
|
33
|
+
|
|
34
|
+
const chunks = [chunk]
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this._offset = 0
|
|
48
|
-
this._buffer = bl()
|
|
49
|
-
this._missing = 0
|
|
50
|
-
this._partial = false
|
|
51
|
-
this._onparse = noop
|
|
52
|
-
this._header = null
|
|
53
|
-
this._stream = null
|
|
54
|
-
this._overflow = null
|
|
55
|
-
this._cb = null
|
|
56
|
-
this._locked = false
|
|
57
|
-
this._destroyed = false
|
|
58
|
-
this._pax = null
|
|
59
|
-
this._paxGlobal = null
|
|
60
|
-
this._gnuLongPath = null
|
|
61
|
-
this._gnuLongLinkPath = null
|
|
62
|
-
|
|
63
|
-
var self = this
|
|
64
|
-
var b = self._buffer
|
|
65
|
-
|
|
66
|
-
var oncontinue = function () {
|
|
67
|
-
self._continue()
|
|
36
|
+
while ((size -= chunk.byteLength) > 0) {
|
|
37
|
+
chunk = this._next(size)
|
|
38
|
+
chunks.push(chunk)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return b4a.concat(chunks)
|
|
68
42
|
}
|
|
69
43
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
44
|
+
_next (size) {
|
|
45
|
+
const buf = this.queue.peek()
|
|
46
|
+
const rem = buf.byteLength - this._offset
|
|
47
|
+
|
|
48
|
+
if (size >= rem) {
|
|
49
|
+
const sub = this._offset ? buf.subarray(this._offset, buf.byteLength) : buf
|
|
50
|
+
this.queue.shift()
|
|
51
|
+
this._offset = 0
|
|
52
|
+
this.buffered -= rem
|
|
53
|
+
this.shifted += rem
|
|
54
|
+
return sub
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.buffered -= size
|
|
58
|
+
this.shifted += size
|
|
59
|
+
|
|
60
|
+
return buf.subarray(this._offset, (this._offset += size))
|
|
74
61
|
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class Source extends Readable {
|
|
65
|
+
constructor (self, header, offset) {
|
|
66
|
+
super()
|
|
67
|
+
|
|
68
|
+
this.header = header
|
|
69
|
+
this.offset = offset
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
self._stream = null
|
|
78
|
-
var drain = overflow(self._header.size)
|
|
79
|
-
if (drain) self._parse(drain, ondrain)
|
|
80
|
-
else self._parse(512, onheader)
|
|
81
|
-
if (!self._locked) oncontinue()
|
|
71
|
+
this._parent = self
|
|
82
72
|
}
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
_read (cb) {
|
|
75
|
+
if (this.header.size === 0) {
|
|
76
|
+
this.push(null)
|
|
77
|
+
}
|
|
78
|
+
if (this._parent._stream === this) {
|
|
79
|
+
this._parent._update()
|
|
80
|
+
}
|
|
81
|
+
cb(null)
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
self._paxGlobal = headers.decodePax(b.slice(0, size))
|
|
93
|
-
b.consume(size)
|
|
94
|
-
onstreamend()
|
|
84
|
+
_predestroy () {
|
|
85
|
+
this._parent.destroy(getStreamError(this))
|
|
95
86
|
}
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
88
|
+
_detach () {
|
|
89
|
+
if (this._parent._stream === this) {
|
|
90
|
+
this._parent._stream = null
|
|
91
|
+
this._parent._missing = overflow(this.header.size)
|
|
92
|
+
this._parent._update()
|
|
93
|
+
}
|
|
103
94
|
}
|
|
104
95
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
b.consume(size)
|
|
109
|
-
onstreamend()
|
|
96
|
+
_destroy (cb) {
|
|
97
|
+
this._detach()
|
|
98
|
+
cb(null)
|
|
110
99
|
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
class Extract extends Writable {
|
|
103
|
+
constructor (opts) {
|
|
104
|
+
super(opts)
|
|
105
|
+
|
|
106
|
+
if (!opts) opts = {}
|
|
107
|
+
|
|
108
|
+
this._buffer = new BufferList()
|
|
109
|
+
this._offset = 0
|
|
110
|
+
this._header = null
|
|
111
|
+
this._stream = null
|
|
112
|
+
this._missing = 0
|
|
113
|
+
this._longHeader = false
|
|
114
|
+
this._callback = noop
|
|
115
|
+
this._locked = false
|
|
116
|
+
this._finished = false
|
|
117
|
+
this._pax = null
|
|
118
|
+
this._paxGlobal = null
|
|
119
|
+
this._gnuLongPath = null
|
|
120
|
+
this._gnuLongLinkPath = null
|
|
121
|
+
this._filenameEncoding = opts.filenameEncoding || 'utf-8'
|
|
122
|
+
this._allowUnknownFormat = !!opts.allowUnknownFormat
|
|
123
|
+
this._unlockBound = this._unlock.bind(this)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_unlock (err) {
|
|
127
|
+
this._locked = false
|
|
111
128
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
if (err) {
|
|
130
|
+
this.destroy(err)
|
|
131
|
+
this._continueWrite(err)
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._update()
|
|
117
136
|
}
|
|
118
137
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
_consumeHeader () {
|
|
139
|
+
if (this._locked) return false
|
|
140
|
+
|
|
141
|
+
this._offset = this._buffer.shifted
|
|
142
|
+
|
|
122
143
|
try {
|
|
123
|
-
|
|
144
|
+
this._header = headers.decode(this._buffer.shift(512), this._filenameEncoding, this._allowUnknownFormat)
|
|
124
145
|
} catch (err) {
|
|
125
|
-
|
|
146
|
+
this._continueWrite(err)
|
|
147
|
+
return false
|
|
126
148
|
}
|
|
127
|
-
b.consume(512)
|
|
128
149
|
|
|
129
|
-
if (!
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
if (!this._header) return true
|
|
151
|
+
|
|
152
|
+
switch (this._header.type) {
|
|
153
|
+
case 'gnu-long-path':
|
|
154
|
+
case 'gnu-long-link-path':
|
|
155
|
+
case 'pax-global-header':
|
|
156
|
+
case 'pax-header':
|
|
157
|
+
this._longHeader = true
|
|
158
|
+
this._missing = this._header.size
|
|
159
|
+
return true
|
|
133
160
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
161
|
+
|
|
162
|
+
this._locked = true
|
|
163
|
+
this._applyLongHeaders()
|
|
164
|
+
|
|
165
|
+
if (this._header.size === 0 || this._header.type === 'directory') {
|
|
166
|
+
this.emit('entry', this._header, this._createStream(), this._unlockBound)
|
|
167
|
+
return true
|
|
138
168
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
169
|
+
|
|
170
|
+
this._stream = this._createStream()
|
|
171
|
+
this._missing = this._header.size
|
|
172
|
+
|
|
173
|
+
this.emit('entry', this._header, this._stream, this._unlockBound)
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_applyLongHeaders () {
|
|
178
|
+
if (this._gnuLongPath) {
|
|
179
|
+
this._header.name = this._gnuLongPath
|
|
180
|
+
this._gnuLongPath = null
|
|
143
181
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
182
|
+
|
|
183
|
+
if (this._gnuLongLinkPath) {
|
|
184
|
+
this._header.linkname = this._gnuLongLinkPath
|
|
185
|
+
this._gnuLongLinkPath = null
|
|
148
186
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
187
|
+
|
|
188
|
+
if (this._pax) {
|
|
189
|
+
if (this._pax.path) this._header.name = this._pax.path
|
|
190
|
+
if (this._pax.linkpath) this._header.linkname = this._pax.linkpath
|
|
191
|
+
if (this._pax.size) this._header.size = parseInt(this._pax.size, 10)
|
|
192
|
+
this._header.pax = this._pax
|
|
193
|
+
this._pax = null
|
|
153
194
|
}
|
|
195
|
+
}
|
|
154
196
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
197
|
+
_decodeLongHeader (buf) {
|
|
198
|
+
switch (this._header.type) {
|
|
199
|
+
case 'gnu-long-path':
|
|
200
|
+
this._gnuLongPath = headers.decodeLongPath(buf, this._filenameEncoding)
|
|
201
|
+
break
|
|
202
|
+
case 'gnu-long-link-path':
|
|
203
|
+
this._gnuLongLinkPath = headers.decodeLongPath(buf, this._filenameEncoding)
|
|
204
|
+
break
|
|
205
|
+
case 'pax-global-header':
|
|
206
|
+
this._paxGlobal = headers.decodePax(buf)
|
|
207
|
+
break
|
|
208
|
+
case 'pax-header':
|
|
209
|
+
this._pax = this._paxGlobal === null
|
|
210
|
+
? headers.decodePax(buf)
|
|
211
|
+
: Object.assign({}, this._paxGlobal, headers.decodePax(buf))
|
|
212
|
+
break
|
|
158
213
|
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
_consumeLongHeader () {
|
|
217
|
+
this._longHeader = false
|
|
218
|
+
this._missing = overflow(this._header.size)
|
|
219
|
+
|
|
220
|
+
const buf = this._buffer.shift(this._header.size)
|
|
159
221
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
222
|
+
try {
|
|
223
|
+
this._decodeLongHeader(buf)
|
|
224
|
+
} catch (err) {
|
|
225
|
+
this._continueWrite(err)
|
|
226
|
+
return false
|
|
163
227
|
}
|
|
164
228
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
229
|
+
return true
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_consumeStream () {
|
|
233
|
+
const buf = this._buffer.shiftFirst(this._missing)
|
|
234
|
+
if (buf === null) return false
|
|
235
|
+
|
|
236
|
+
this._missing -= buf.byteLength
|
|
237
|
+
const drained = this._stream.push(buf)
|
|
238
|
+
|
|
239
|
+
if (this._missing === 0) {
|
|
240
|
+
this._stream.push(null)
|
|
241
|
+
if (drained) this._stream._detach()
|
|
242
|
+
return drained && this._locked === false
|
|
168
243
|
}
|
|
169
244
|
|
|
170
|
-
|
|
245
|
+
return drained
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_createStream () {
|
|
249
|
+
return new Source(this, this._header, this._offset)
|
|
250
|
+
}
|
|
171
251
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
252
|
+
_update () {
|
|
253
|
+
while (this._buffer.buffered > 0 && !this.destroying) {
|
|
254
|
+
if (this._missing > 0) {
|
|
255
|
+
if (this._stream !== null) {
|
|
256
|
+
if (this._consumeStream() === false) return
|
|
257
|
+
continue
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (this._longHeader === true) {
|
|
261
|
+
if (this._missing > this._buffer.buffered) break
|
|
262
|
+
if (this._consumeLongHeader() === false) return false
|
|
263
|
+
continue
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const ignore = this._buffer.shiftFirst(this._missing)
|
|
267
|
+
if (ignore !== null) this._missing -= ignore.byteLength
|
|
268
|
+
continue
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (this._buffer.buffered < 512) break
|
|
272
|
+
if (this._stream !== null || this._consumeHeader() === false) return
|
|
176
273
|
}
|
|
177
274
|
|
|
178
|
-
|
|
275
|
+
this._continueWrite(null)
|
|
276
|
+
}
|
|
179
277
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
278
|
+
_continueWrite (err) {
|
|
279
|
+
const cb = this._callback
|
|
280
|
+
this._callback = noop
|
|
281
|
+
cb(err)
|
|
183
282
|
}
|
|
184
283
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
284
|
+
_write (data, cb) {
|
|
285
|
+
this._callback = cb
|
|
286
|
+
this._buffer.push(data)
|
|
287
|
+
this._update()
|
|
288
|
+
}
|
|
188
289
|
|
|
189
|
-
|
|
290
|
+
_final (cb) {
|
|
291
|
+
this._finished = this._missing === 0 && this._buffer.buffered === 0
|
|
292
|
+
cb(this._finished ? null : new Error('Unexpected end of data'))
|
|
293
|
+
}
|
|
190
294
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
295
|
+
_predestroy () {
|
|
296
|
+
this._continueWrite(null)
|
|
297
|
+
}
|
|
194
298
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
299
|
+
_destroy (cb) {
|
|
300
|
+
if (this._stream) this._stream.destroy(getStreamError(this))
|
|
301
|
+
cb(null)
|
|
302
|
+
}
|
|
199
303
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
304
|
+
[Symbol.asyncIterator] () {
|
|
305
|
+
let error = null
|
|
306
|
+
|
|
307
|
+
let promiseResolve = null
|
|
308
|
+
let promiseReject = null
|
|
309
|
+
|
|
310
|
+
let entryStream = null
|
|
311
|
+
let entryCallback = null
|
|
312
|
+
|
|
313
|
+
const extract = this
|
|
314
|
+
|
|
315
|
+
this.on('entry', onentry)
|
|
316
|
+
this.on('error', (err) => { error = err })
|
|
317
|
+
this.on('close', onclose)
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
[Symbol.asyncIterator] () {
|
|
321
|
+
return this
|
|
322
|
+
},
|
|
323
|
+
next () {
|
|
324
|
+
return new Promise(onnext)
|
|
325
|
+
},
|
|
326
|
+
return () {
|
|
327
|
+
return destroy(null)
|
|
328
|
+
},
|
|
329
|
+
throw (err) {
|
|
330
|
+
return destroy(err)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
207
333
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
334
|
+
function consumeCallback (err) {
|
|
335
|
+
if (!entryCallback) return
|
|
336
|
+
const cb = entryCallback
|
|
337
|
+
entryCallback = null
|
|
338
|
+
cb(err)
|
|
339
|
+
}
|
|
215
340
|
|
|
216
|
-
|
|
217
|
-
|
|
341
|
+
function onnext (resolve, reject) {
|
|
342
|
+
if (error) {
|
|
343
|
+
return reject(error)
|
|
344
|
+
}
|
|
218
345
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
346
|
+
if (entryStream) {
|
|
347
|
+
resolve({ value: entryStream, done: false })
|
|
348
|
+
entryStream = null
|
|
349
|
+
return
|
|
350
|
+
}
|
|
223
351
|
|
|
224
|
-
|
|
352
|
+
promiseResolve = resolve
|
|
353
|
+
promiseReject = reject
|
|
225
354
|
|
|
226
|
-
|
|
227
|
-
this._missing -= data.length
|
|
228
|
-
this._overflow = null
|
|
229
|
-
if (s) return s.write(data, cb)
|
|
230
|
-
b.append(data)
|
|
231
|
-
return cb()
|
|
232
|
-
}
|
|
355
|
+
consumeCallback(null)
|
|
233
356
|
|
|
234
|
-
|
|
357
|
+
if (extract._finished && promiseResolve) {
|
|
358
|
+
promiseResolve({ value: undefined, done: true })
|
|
359
|
+
promiseResolve = promiseReject = null
|
|
360
|
+
}
|
|
361
|
+
}
|
|
235
362
|
|
|
236
|
-
|
|
237
|
-
|
|
363
|
+
function onentry (header, stream, callback) {
|
|
364
|
+
entryCallback = callback
|
|
365
|
+
stream.on('error', noop) // no way around this due to tick sillyness
|
|
238
366
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
367
|
+
if (promiseResolve) {
|
|
368
|
+
promiseResolve({ value: stream, done: false })
|
|
369
|
+
promiseResolve = promiseReject = null
|
|
370
|
+
} else {
|
|
371
|
+
entryStream = stream
|
|
372
|
+
}
|
|
373
|
+
}
|
|
244
374
|
|
|
245
|
-
|
|
246
|
-
|
|
375
|
+
function onclose () {
|
|
376
|
+
consumeCallback(error)
|
|
377
|
+
if (!promiseResolve) return
|
|
378
|
+
if (error) promiseReject(error)
|
|
379
|
+
else promiseResolve({ value: undefined, done: true })
|
|
380
|
+
promiseResolve = promiseReject = null
|
|
381
|
+
}
|
|
247
382
|
|
|
248
|
-
|
|
249
|
-
|
|
383
|
+
function destroy (err) {
|
|
384
|
+
extract.destroy(err)
|
|
385
|
+
consumeCallback(err)
|
|
386
|
+
return new Promise((resolve, reject) => {
|
|
387
|
+
if (extract.destroyed) return resolve({ value: undefined, done: true })
|
|
388
|
+
extract.once('close', function () {
|
|
389
|
+
if (err) reject(err)
|
|
390
|
+
else resolve({ value: undefined, done: true })
|
|
391
|
+
})
|
|
392
|
+
})
|
|
393
|
+
}
|
|
394
|
+
}
|
|
250
395
|
}
|
|
251
396
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
cb()
|
|
397
|
+
module.exports = function extract (opts) {
|
|
398
|
+
return new Extract(opts)
|
|
255
399
|
}
|
|
256
400
|
|
|
257
|
-
|
|
401
|
+
function noop () {}
|
|
402
|
+
|
|
403
|
+
function overflow (size) {
|
|
404
|
+
size &= 511
|
|
405
|
+
return size && 512 - size
|
|
406
|
+
}
|