@apps-in-toss/cli 0.0.24 → 0.0.26
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/dist/index.cjs +22 -1454
- package/dist/index.js +20 -1452
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -52,13 +52,13 @@ var require_ms = __commonJS({
|
|
|
52
52
|
var d = h * 24;
|
|
53
53
|
var w = d * 7;
|
|
54
54
|
var y = d * 365.25;
|
|
55
|
-
module.exports = function(val,
|
|
56
|
-
|
|
55
|
+
module.exports = function(val, options) {
|
|
56
|
+
options = options || {};
|
|
57
57
|
var type = typeof val;
|
|
58
58
|
if (type === "string" && val.length > 0) {
|
|
59
59
|
return parse(val);
|
|
60
60
|
} else if (type === "number" && isFinite(val)) {
|
|
61
|
-
return
|
|
61
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
62
62
|
}
|
|
63
63
|
throw new Error(
|
|
64
64
|
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
@@ -773,1387 +773,6 @@ var require_picocolors = __commonJS({
|
|
|
773
773
|
}
|
|
774
774
|
});
|
|
775
775
|
|
|
776
|
-
// ../../.yarn/cache/pend-npm-1.2.0-dddaab3bf3-8a87e63f7a.zip/node_modules/pend/index.js
|
|
777
|
-
var require_pend = __commonJS({
|
|
778
|
-
"../../.yarn/cache/pend-npm-1.2.0-dddaab3bf3-8a87e63f7a.zip/node_modules/pend/index.js"(exports, module) {
|
|
779
|
-
"use strict";
|
|
780
|
-
init_esm_shims();
|
|
781
|
-
module.exports = Pend;
|
|
782
|
-
function Pend() {
|
|
783
|
-
this.pending = 0;
|
|
784
|
-
this.max = Infinity;
|
|
785
|
-
this.listeners = [];
|
|
786
|
-
this.waiting = [];
|
|
787
|
-
this.error = null;
|
|
788
|
-
}
|
|
789
|
-
Pend.prototype.go = function(fn) {
|
|
790
|
-
if (this.pending < this.max) {
|
|
791
|
-
pendGo(this, fn);
|
|
792
|
-
} else {
|
|
793
|
-
this.waiting.push(fn);
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
Pend.prototype.wait = function(cb) {
|
|
797
|
-
if (this.pending === 0) {
|
|
798
|
-
cb(this.error);
|
|
799
|
-
} else {
|
|
800
|
-
this.listeners.push(cb);
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
Pend.prototype.hold = function() {
|
|
804
|
-
return pendHold(this);
|
|
805
|
-
};
|
|
806
|
-
function pendHold(self) {
|
|
807
|
-
self.pending += 1;
|
|
808
|
-
var called = false;
|
|
809
|
-
return onCb;
|
|
810
|
-
function onCb(err) {
|
|
811
|
-
if (called) throw new Error("callback called twice");
|
|
812
|
-
called = true;
|
|
813
|
-
self.error = self.error || err;
|
|
814
|
-
self.pending -= 1;
|
|
815
|
-
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
816
|
-
pendGo(self, self.waiting.shift());
|
|
817
|
-
} else if (self.pending === 0) {
|
|
818
|
-
var listeners = self.listeners;
|
|
819
|
-
self.listeners = [];
|
|
820
|
-
listeners.forEach(cbListener);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
function cbListener(listener) {
|
|
824
|
-
listener(self.error);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
function pendGo(self, fn) {
|
|
828
|
-
fn(pendHold(self));
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
// ../../.yarn/cache/yauzl-npm-3.2.0-b1af038bc6-7b40b3dc46.zip/node_modules/yauzl/fd-slicer.js
|
|
834
|
-
var require_fd_slicer = __commonJS({
|
|
835
|
-
"../../.yarn/cache/yauzl-npm-3.2.0-b1af038bc6-7b40b3dc46.zip/node_modules/yauzl/fd-slicer.js"(exports) {
|
|
836
|
-
"use strict";
|
|
837
|
-
init_esm_shims();
|
|
838
|
-
var fs5 = __require("fs");
|
|
839
|
-
var util = __require("util");
|
|
840
|
-
var stream = __require("stream");
|
|
841
|
-
var Readable = stream.Readable;
|
|
842
|
-
var Writable = stream.Writable;
|
|
843
|
-
var PassThrough = stream.PassThrough;
|
|
844
|
-
var Pend = require_pend();
|
|
845
|
-
var EventEmitter = __require("events").EventEmitter;
|
|
846
|
-
exports.createFromBuffer = createFromBuffer;
|
|
847
|
-
exports.createFromFd = createFromFd;
|
|
848
|
-
exports.BufferSlicer = BufferSlicer;
|
|
849
|
-
exports.FdSlicer = FdSlicer;
|
|
850
|
-
util.inherits(FdSlicer, EventEmitter);
|
|
851
|
-
function FdSlicer(fd, options2) {
|
|
852
|
-
options2 = options2 || {};
|
|
853
|
-
EventEmitter.call(this);
|
|
854
|
-
this.fd = fd;
|
|
855
|
-
this.pend = new Pend();
|
|
856
|
-
this.pend.max = 1;
|
|
857
|
-
this.refCount = 0;
|
|
858
|
-
this.autoClose = !!options2.autoClose;
|
|
859
|
-
}
|
|
860
|
-
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
861
|
-
var self = this;
|
|
862
|
-
self.pend.go(function(cb) {
|
|
863
|
-
fs5.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
864
|
-
cb();
|
|
865
|
-
callback(err, bytesRead, buffer2);
|
|
866
|
-
});
|
|
867
|
-
});
|
|
868
|
-
};
|
|
869
|
-
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
870
|
-
var self = this;
|
|
871
|
-
self.pend.go(function(cb) {
|
|
872
|
-
fs5.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
|
|
873
|
-
cb();
|
|
874
|
-
callback(err, written, buffer2);
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
};
|
|
878
|
-
FdSlicer.prototype.createReadStream = function(options2) {
|
|
879
|
-
return new ReadStream(this, options2);
|
|
880
|
-
};
|
|
881
|
-
FdSlicer.prototype.createWriteStream = function(options2) {
|
|
882
|
-
return new WriteStream(this, options2);
|
|
883
|
-
};
|
|
884
|
-
FdSlicer.prototype.ref = function() {
|
|
885
|
-
this.refCount += 1;
|
|
886
|
-
};
|
|
887
|
-
FdSlicer.prototype.unref = function() {
|
|
888
|
-
var self = this;
|
|
889
|
-
self.refCount -= 1;
|
|
890
|
-
if (self.refCount > 0) return;
|
|
891
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
|
892
|
-
if (self.autoClose) {
|
|
893
|
-
fs5.close(self.fd, onCloseDone);
|
|
894
|
-
}
|
|
895
|
-
function onCloseDone(err) {
|
|
896
|
-
if (err) {
|
|
897
|
-
self.emit("error", err);
|
|
898
|
-
} else {
|
|
899
|
-
self.emit("close");
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
util.inherits(ReadStream, Readable);
|
|
904
|
-
function ReadStream(context, options2) {
|
|
905
|
-
options2 = options2 || {};
|
|
906
|
-
Readable.call(this, options2);
|
|
907
|
-
this.context = context;
|
|
908
|
-
this.context.ref();
|
|
909
|
-
this.start = options2.start || 0;
|
|
910
|
-
this.endOffset = options2.end;
|
|
911
|
-
this.pos = this.start;
|
|
912
|
-
this.destroyed = false;
|
|
913
|
-
}
|
|
914
|
-
ReadStream.prototype._read = function(n) {
|
|
915
|
-
var self = this;
|
|
916
|
-
if (self.destroyed) return;
|
|
917
|
-
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
918
|
-
if (self.endOffset != null) {
|
|
919
|
-
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
920
|
-
}
|
|
921
|
-
if (toRead <= 0) {
|
|
922
|
-
self.destroyed = true;
|
|
923
|
-
self.push(null);
|
|
924
|
-
self.context.unref();
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
|
-
self.context.pend.go(function(cb) {
|
|
928
|
-
if (self.destroyed) return cb();
|
|
929
|
-
var buffer = Buffer.allocUnsafe(toRead);
|
|
930
|
-
fs5.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
931
|
-
if (err) {
|
|
932
|
-
self.destroy(err);
|
|
933
|
-
} else if (bytesRead === 0) {
|
|
934
|
-
self.destroyed = true;
|
|
935
|
-
self.push(null);
|
|
936
|
-
self.context.unref();
|
|
937
|
-
} else {
|
|
938
|
-
self.pos += bytesRead;
|
|
939
|
-
self.push(buffer.slice(0, bytesRead));
|
|
940
|
-
}
|
|
941
|
-
cb();
|
|
942
|
-
});
|
|
943
|
-
});
|
|
944
|
-
};
|
|
945
|
-
ReadStream.prototype.destroy = function(err) {
|
|
946
|
-
if (this.destroyed) return;
|
|
947
|
-
err = err || new Error("stream destroyed");
|
|
948
|
-
this.destroyed = true;
|
|
949
|
-
this.emit("error", err);
|
|
950
|
-
this.context.unref();
|
|
951
|
-
};
|
|
952
|
-
util.inherits(WriteStream, Writable);
|
|
953
|
-
function WriteStream(context, options2) {
|
|
954
|
-
options2 = options2 || {};
|
|
955
|
-
Writable.call(this, options2);
|
|
956
|
-
this.context = context;
|
|
957
|
-
this.context.ref();
|
|
958
|
-
this.start = options2.start || 0;
|
|
959
|
-
this.endOffset = options2.end == null ? Infinity : +options2.end;
|
|
960
|
-
this.bytesWritten = 0;
|
|
961
|
-
this.pos = this.start;
|
|
962
|
-
this.destroyed = false;
|
|
963
|
-
this.on("finish", this.destroy.bind(this));
|
|
964
|
-
}
|
|
965
|
-
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
966
|
-
var self = this;
|
|
967
|
-
if (self.destroyed) return;
|
|
968
|
-
if (self.pos + buffer.length > self.endOffset) {
|
|
969
|
-
var err = new Error("maximum file length exceeded");
|
|
970
|
-
err.code = "ETOOBIG";
|
|
971
|
-
self.destroy();
|
|
972
|
-
callback(err);
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
|
-
self.context.pend.go(function(cb) {
|
|
976
|
-
if (self.destroyed) return cb();
|
|
977
|
-
fs5.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
|
|
978
|
-
if (err2) {
|
|
979
|
-
self.destroy();
|
|
980
|
-
cb();
|
|
981
|
-
callback(err2);
|
|
982
|
-
} else {
|
|
983
|
-
self.bytesWritten += bytes;
|
|
984
|
-
self.pos += bytes;
|
|
985
|
-
self.emit("progress");
|
|
986
|
-
cb();
|
|
987
|
-
callback();
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
};
|
|
992
|
-
WriteStream.prototype.destroy = function() {
|
|
993
|
-
if (this.destroyed) return;
|
|
994
|
-
this.destroyed = true;
|
|
995
|
-
this.context.unref();
|
|
996
|
-
};
|
|
997
|
-
util.inherits(BufferSlicer, EventEmitter);
|
|
998
|
-
function BufferSlicer(buffer, options2) {
|
|
999
|
-
EventEmitter.call(this);
|
|
1000
|
-
options2 = options2 || {};
|
|
1001
|
-
this.refCount = 0;
|
|
1002
|
-
this.buffer = buffer;
|
|
1003
|
-
this.maxChunkSize = options2.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
1004
|
-
}
|
|
1005
|
-
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1006
|
-
if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
|
|
1007
|
-
if (position < 0) throw new RangeError("position is negative: " + position);
|
|
1008
|
-
if (offset + length > buffer.length) {
|
|
1009
|
-
length = buffer.length - offset;
|
|
1010
|
-
}
|
|
1011
|
-
if (position + length > this.buffer.length) {
|
|
1012
|
-
length = this.buffer.length - position;
|
|
1013
|
-
}
|
|
1014
|
-
if (length <= 0) {
|
|
1015
|
-
setImmediate(function() {
|
|
1016
|
-
callback(null, 0);
|
|
1017
|
-
});
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
this.buffer.copy(buffer, offset, position, position + length);
|
|
1021
|
-
setImmediate(function() {
|
|
1022
|
-
callback(null, length);
|
|
1023
|
-
});
|
|
1024
|
-
};
|
|
1025
|
-
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
1026
|
-
buffer.copy(this.buffer, position, offset, offset + length);
|
|
1027
|
-
setImmediate(function() {
|
|
1028
|
-
callback(null, length, buffer);
|
|
1029
|
-
});
|
|
1030
|
-
};
|
|
1031
|
-
BufferSlicer.prototype.createReadStream = function(options2) {
|
|
1032
|
-
options2 = options2 || {};
|
|
1033
|
-
var readStream = new PassThrough(options2);
|
|
1034
|
-
readStream.destroyed = false;
|
|
1035
|
-
readStream.start = options2.start || 0;
|
|
1036
|
-
readStream.endOffset = options2.end;
|
|
1037
|
-
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
1038
|
-
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
1039
|
-
var offset = 0;
|
|
1040
|
-
while (true) {
|
|
1041
|
-
var nextOffset = offset + this.maxChunkSize;
|
|
1042
|
-
if (nextOffset >= entireSlice.length) {
|
|
1043
|
-
if (offset < entireSlice.length) {
|
|
1044
|
-
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
1045
|
-
}
|
|
1046
|
-
break;
|
|
1047
|
-
}
|
|
1048
|
-
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
1049
|
-
offset = nextOffset;
|
|
1050
|
-
}
|
|
1051
|
-
readStream.end();
|
|
1052
|
-
readStream.destroy = function() {
|
|
1053
|
-
readStream.destroyed = true;
|
|
1054
|
-
};
|
|
1055
|
-
return readStream;
|
|
1056
|
-
};
|
|
1057
|
-
BufferSlicer.prototype.createWriteStream = function(options2) {
|
|
1058
|
-
var bufferSlicer = this;
|
|
1059
|
-
options2 = options2 || {};
|
|
1060
|
-
var writeStream = new Writable(options2);
|
|
1061
|
-
writeStream.start = options2.start || 0;
|
|
1062
|
-
writeStream.endOffset = options2.end == null ? this.buffer.length : +options2.end;
|
|
1063
|
-
writeStream.bytesWritten = 0;
|
|
1064
|
-
writeStream.pos = writeStream.start;
|
|
1065
|
-
writeStream.destroyed = false;
|
|
1066
|
-
writeStream._write = function(buffer, encoding, callback) {
|
|
1067
|
-
if (writeStream.destroyed) return;
|
|
1068
|
-
var end = writeStream.pos + buffer.length;
|
|
1069
|
-
if (end > writeStream.endOffset) {
|
|
1070
|
-
var err = new Error("maximum file length exceeded");
|
|
1071
|
-
err.code = "ETOOBIG";
|
|
1072
|
-
writeStream.destroyed = true;
|
|
1073
|
-
callback(err);
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
1077
|
-
writeStream.bytesWritten += buffer.length;
|
|
1078
|
-
writeStream.pos = end;
|
|
1079
|
-
writeStream.emit("progress");
|
|
1080
|
-
callback();
|
|
1081
|
-
};
|
|
1082
|
-
writeStream.destroy = function() {
|
|
1083
|
-
writeStream.destroyed = true;
|
|
1084
|
-
};
|
|
1085
|
-
return writeStream;
|
|
1086
|
-
};
|
|
1087
|
-
BufferSlicer.prototype.ref = function() {
|
|
1088
|
-
this.refCount += 1;
|
|
1089
|
-
};
|
|
1090
|
-
BufferSlicer.prototype.unref = function() {
|
|
1091
|
-
this.refCount -= 1;
|
|
1092
|
-
if (this.refCount < 0) {
|
|
1093
|
-
throw new Error("invalid unref");
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
function createFromBuffer(buffer, options2) {
|
|
1097
|
-
return new BufferSlicer(buffer, options2);
|
|
1098
|
-
}
|
|
1099
|
-
function createFromFd(fd, options2) {
|
|
1100
|
-
return new FdSlicer(fd, options2);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
});
|
|
1104
|
-
|
|
1105
|
-
// ../../.yarn/cache/buffer-crc32-npm-0.2.13-e25ddc91f5-cb0a8ddf5c.zip/node_modules/buffer-crc32/index.js
|
|
1106
|
-
var require_buffer_crc32 = __commonJS({
|
|
1107
|
-
"../../.yarn/cache/buffer-crc32-npm-0.2.13-e25ddc91f5-cb0a8ddf5c.zip/node_modules/buffer-crc32/index.js"(exports, module) {
|
|
1108
|
-
"use strict";
|
|
1109
|
-
init_esm_shims();
|
|
1110
|
-
var Buffer2 = __require("buffer").Buffer;
|
|
1111
|
-
var CRC_TABLE = [
|
|
1112
|
-
0,
|
|
1113
|
-
1996959894,
|
|
1114
|
-
3993919788,
|
|
1115
|
-
2567524794,
|
|
1116
|
-
124634137,
|
|
1117
|
-
1886057615,
|
|
1118
|
-
3915621685,
|
|
1119
|
-
2657392035,
|
|
1120
|
-
249268274,
|
|
1121
|
-
2044508324,
|
|
1122
|
-
3772115230,
|
|
1123
|
-
2547177864,
|
|
1124
|
-
162941995,
|
|
1125
|
-
2125561021,
|
|
1126
|
-
3887607047,
|
|
1127
|
-
2428444049,
|
|
1128
|
-
498536548,
|
|
1129
|
-
1789927666,
|
|
1130
|
-
4089016648,
|
|
1131
|
-
2227061214,
|
|
1132
|
-
450548861,
|
|
1133
|
-
1843258603,
|
|
1134
|
-
4107580753,
|
|
1135
|
-
2211677639,
|
|
1136
|
-
325883990,
|
|
1137
|
-
1684777152,
|
|
1138
|
-
4251122042,
|
|
1139
|
-
2321926636,
|
|
1140
|
-
335633487,
|
|
1141
|
-
1661365465,
|
|
1142
|
-
4195302755,
|
|
1143
|
-
2366115317,
|
|
1144
|
-
997073096,
|
|
1145
|
-
1281953886,
|
|
1146
|
-
3579855332,
|
|
1147
|
-
2724688242,
|
|
1148
|
-
1006888145,
|
|
1149
|
-
1258607687,
|
|
1150
|
-
3524101629,
|
|
1151
|
-
2768942443,
|
|
1152
|
-
901097722,
|
|
1153
|
-
1119000684,
|
|
1154
|
-
3686517206,
|
|
1155
|
-
2898065728,
|
|
1156
|
-
853044451,
|
|
1157
|
-
1172266101,
|
|
1158
|
-
3705015759,
|
|
1159
|
-
2882616665,
|
|
1160
|
-
651767980,
|
|
1161
|
-
1373503546,
|
|
1162
|
-
3369554304,
|
|
1163
|
-
3218104598,
|
|
1164
|
-
565507253,
|
|
1165
|
-
1454621731,
|
|
1166
|
-
3485111705,
|
|
1167
|
-
3099436303,
|
|
1168
|
-
671266974,
|
|
1169
|
-
1594198024,
|
|
1170
|
-
3322730930,
|
|
1171
|
-
2970347812,
|
|
1172
|
-
795835527,
|
|
1173
|
-
1483230225,
|
|
1174
|
-
3244367275,
|
|
1175
|
-
3060149565,
|
|
1176
|
-
1994146192,
|
|
1177
|
-
31158534,
|
|
1178
|
-
2563907772,
|
|
1179
|
-
4023717930,
|
|
1180
|
-
1907459465,
|
|
1181
|
-
112637215,
|
|
1182
|
-
2680153253,
|
|
1183
|
-
3904427059,
|
|
1184
|
-
2013776290,
|
|
1185
|
-
251722036,
|
|
1186
|
-
2517215374,
|
|
1187
|
-
3775830040,
|
|
1188
|
-
2137656763,
|
|
1189
|
-
141376813,
|
|
1190
|
-
2439277719,
|
|
1191
|
-
3865271297,
|
|
1192
|
-
1802195444,
|
|
1193
|
-
476864866,
|
|
1194
|
-
2238001368,
|
|
1195
|
-
4066508878,
|
|
1196
|
-
1812370925,
|
|
1197
|
-
453092731,
|
|
1198
|
-
2181625025,
|
|
1199
|
-
4111451223,
|
|
1200
|
-
1706088902,
|
|
1201
|
-
314042704,
|
|
1202
|
-
2344532202,
|
|
1203
|
-
4240017532,
|
|
1204
|
-
1658658271,
|
|
1205
|
-
366619977,
|
|
1206
|
-
2362670323,
|
|
1207
|
-
4224994405,
|
|
1208
|
-
1303535960,
|
|
1209
|
-
984961486,
|
|
1210
|
-
2747007092,
|
|
1211
|
-
3569037538,
|
|
1212
|
-
1256170817,
|
|
1213
|
-
1037604311,
|
|
1214
|
-
2765210733,
|
|
1215
|
-
3554079995,
|
|
1216
|
-
1131014506,
|
|
1217
|
-
879679996,
|
|
1218
|
-
2909243462,
|
|
1219
|
-
3663771856,
|
|
1220
|
-
1141124467,
|
|
1221
|
-
855842277,
|
|
1222
|
-
2852801631,
|
|
1223
|
-
3708648649,
|
|
1224
|
-
1342533948,
|
|
1225
|
-
654459306,
|
|
1226
|
-
3188396048,
|
|
1227
|
-
3373015174,
|
|
1228
|
-
1466479909,
|
|
1229
|
-
544179635,
|
|
1230
|
-
3110523913,
|
|
1231
|
-
3462522015,
|
|
1232
|
-
1591671054,
|
|
1233
|
-
702138776,
|
|
1234
|
-
2966460450,
|
|
1235
|
-
3352799412,
|
|
1236
|
-
1504918807,
|
|
1237
|
-
783551873,
|
|
1238
|
-
3082640443,
|
|
1239
|
-
3233442989,
|
|
1240
|
-
3988292384,
|
|
1241
|
-
2596254646,
|
|
1242
|
-
62317068,
|
|
1243
|
-
1957810842,
|
|
1244
|
-
3939845945,
|
|
1245
|
-
2647816111,
|
|
1246
|
-
81470997,
|
|
1247
|
-
1943803523,
|
|
1248
|
-
3814918930,
|
|
1249
|
-
2489596804,
|
|
1250
|
-
225274430,
|
|
1251
|
-
2053790376,
|
|
1252
|
-
3826175755,
|
|
1253
|
-
2466906013,
|
|
1254
|
-
167816743,
|
|
1255
|
-
2097651377,
|
|
1256
|
-
4027552580,
|
|
1257
|
-
2265490386,
|
|
1258
|
-
503444072,
|
|
1259
|
-
1762050814,
|
|
1260
|
-
4150417245,
|
|
1261
|
-
2154129355,
|
|
1262
|
-
426522225,
|
|
1263
|
-
1852507879,
|
|
1264
|
-
4275313526,
|
|
1265
|
-
2312317920,
|
|
1266
|
-
282753626,
|
|
1267
|
-
1742555852,
|
|
1268
|
-
4189708143,
|
|
1269
|
-
2394877945,
|
|
1270
|
-
397917763,
|
|
1271
|
-
1622183637,
|
|
1272
|
-
3604390888,
|
|
1273
|
-
2714866558,
|
|
1274
|
-
953729732,
|
|
1275
|
-
1340076626,
|
|
1276
|
-
3518719985,
|
|
1277
|
-
2797360999,
|
|
1278
|
-
1068828381,
|
|
1279
|
-
1219638859,
|
|
1280
|
-
3624741850,
|
|
1281
|
-
2936675148,
|
|
1282
|
-
906185462,
|
|
1283
|
-
1090812512,
|
|
1284
|
-
3747672003,
|
|
1285
|
-
2825379669,
|
|
1286
|
-
829329135,
|
|
1287
|
-
1181335161,
|
|
1288
|
-
3412177804,
|
|
1289
|
-
3160834842,
|
|
1290
|
-
628085408,
|
|
1291
|
-
1382605366,
|
|
1292
|
-
3423369109,
|
|
1293
|
-
3138078467,
|
|
1294
|
-
570562233,
|
|
1295
|
-
1426400815,
|
|
1296
|
-
3317316542,
|
|
1297
|
-
2998733608,
|
|
1298
|
-
733239954,
|
|
1299
|
-
1555261956,
|
|
1300
|
-
3268935591,
|
|
1301
|
-
3050360625,
|
|
1302
|
-
752459403,
|
|
1303
|
-
1541320221,
|
|
1304
|
-
2607071920,
|
|
1305
|
-
3965973030,
|
|
1306
|
-
1969922972,
|
|
1307
|
-
40735498,
|
|
1308
|
-
2617837225,
|
|
1309
|
-
3943577151,
|
|
1310
|
-
1913087877,
|
|
1311
|
-
83908371,
|
|
1312
|
-
2512341634,
|
|
1313
|
-
3803740692,
|
|
1314
|
-
2075208622,
|
|
1315
|
-
213261112,
|
|
1316
|
-
2463272603,
|
|
1317
|
-
3855990285,
|
|
1318
|
-
2094854071,
|
|
1319
|
-
198958881,
|
|
1320
|
-
2262029012,
|
|
1321
|
-
4057260610,
|
|
1322
|
-
1759359992,
|
|
1323
|
-
534414190,
|
|
1324
|
-
2176718541,
|
|
1325
|
-
4139329115,
|
|
1326
|
-
1873836001,
|
|
1327
|
-
414664567,
|
|
1328
|
-
2282248934,
|
|
1329
|
-
4279200368,
|
|
1330
|
-
1711684554,
|
|
1331
|
-
285281116,
|
|
1332
|
-
2405801727,
|
|
1333
|
-
4167216745,
|
|
1334
|
-
1634467795,
|
|
1335
|
-
376229701,
|
|
1336
|
-
2685067896,
|
|
1337
|
-
3608007406,
|
|
1338
|
-
1308918612,
|
|
1339
|
-
956543938,
|
|
1340
|
-
2808555105,
|
|
1341
|
-
3495958263,
|
|
1342
|
-
1231636301,
|
|
1343
|
-
1047427035,
|
|
1344
|
-
2932959818,
|
|
1345
|
-
3654703836,
|
|
1346
|
-
1088359270,
|
|
1347
|
-
936918e3,
|
|
1348
|
-
2847714899,
|
|
1349
|
-
3736837829,
|
|
1350
|
-
1202900863,
|
|
1351
|
-
817233897,
|
|
1352
|
-
3183342108,
|
|
1353
|
-
3401237130,
|
|
1354
|
-
1404277552,
|
|
1355
|
-
615818150,
|
|
1356
|
-
3134207493,
|
|
1357
|
-
3453421203,
|
|
1358
|
-
1423857449,
|
|
1359
|
-
601450431,
|
|
1360
|
-
3009837614,
|
|
1361
|
-
3294710456,
|
|
1362
|
-
1567103746,
|
|
1363
|
-
711928724,
|
|
1364
|
-
3020668471,
|
|
1365
|
-
3272380065,
|
|
1366
|
-
1510334235,
|
|
1367
|
-
755167117
|
|
1368
|
-
];
|
|
1369
|
-
if (typeof Int32Array !== "undefined") {
|
|
1370
|
-
CRC_TABLE = new Int32Array(CRC_TABLE);
|
|
1371
|
-
}
|
|
1372
|
-
function ensureBuffer(input) {
|
|
1373
|
-
if (Buffer2.isBuffer(input)) {
|
|
1374
|
-
return input;
|
|
1375
|
-
}
|
|
1376
|
-
var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
|
|
1377
|
-
if (typeof input === "number") {
|
|
1378
|
-
return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
|
|
1379
|
-
} else if (typeof input === "string") {
|
|
1380
|
-
return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
|
|
1381
|
-
} else {
|
|
1382
|
-
throw new Error("input must be buffer, number, or string, received " + typeof input);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
function bufferizeInt(num) {
|
|
1386
|
-
var tmp = ensureBuffer(4);
|
|
1387
|
-
tmp.writeInt32BE(num, 0);
|
|
1388
|
-
return tmp;
|
|
1389
|
-
}
|
|
1390
|
-
function _crc32(buf, previous) {
|
|
1391
|
-
buf = ensureBuffer(buf);
|
|
1392
|
-
if (Buffer2.isBuffer(previous)) {
|
|
1393
|
-
previous = previous.readUInt32BE(0);
|
|
1394
|
-
}
|
|
1395
|
-
var crc = ~~previous ^ -1;
|
|
1396
|
-
for (var n = 0; n < buf.length; n++) {
|
|
1397
|
-
crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
|
|
1398
|
-
}
|
|
1399
|
-
return crc ^ -1;
|
|
1400
|
-
}
|
|
1401
|
-
function crc32() {
|
|
1402
|
-
return bufferizeInt(_crc32.apply(null, arguments));
|
|
1403
|
-
}
|
|
1404
|
-
crc32.signed = function() {
|
|
1405
|
-
return _crc32.apply(null, arguments);
|
|
1406
|
-
};
|
|
1407
|
-
crc32.unsigned = function() {
|
|
1408
|
-
return _crc32.apply(null, arguments) >>> 0;
|
|
1409
|
-
};
|
|
1410
|
-
module.exports = crc32;
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
|
|
1414
|
-
// ../../.yarn/cache/yauzl-npm-3.2.0-b1af038bc6-7b40b3dc46.zip/node_modules/yauzl/index.js
|
|
1415
|
-
var require_yauzl = __commonJS({
|
|
1416
|
-
"../../.yarn/cache/yauzl-npm-3.2.0-b1af038bc6-7b40b3dc46.zip/node_modules/yauzl/index.js"(exports) {
|
|
1417
|
-
"use strict";
|
|
1418
|
-
init_esm_shims();
|
|
1419
|
-
var fs5 = __require("fs");
|
|
1420
|
-
var zlib = __require("zlib");
|
|
1421
|
-
var fd_slicer = require_fd_slicer();
|
|
1422
|
-
var crc32 = require_buffer_crc32();
|
|
1423
|
-
var util = __require("util");
|
|
1424
|
-
var EventEmitter = __require("events").EventEmitter;
|
|
1425
|
-
var Transform = __require("stream").Transform;
|
|
1426
|
-
var PassThrough = __require("stream").PassThrough;
|
|
1427
|
-
var Writable = __require("stream").Writable;
|
|
1428
|
-
exports.open = open;
|
|
1429
|
-
exports.fromFd = fromFd;
|
|
1430
|
-
exports.fromBuffer = fromBuffer;
|
|
1431
|
-
exports.fromRandomAccessReader = fromRandomAccessReader;
|
|
1432
|
-
exports.dosDateTimeToDate = dosDateTimeToDate;
|
|
1433
|
-
exports.getFileNameLowLevel = getFileNameLowLevel;
|
|
1434
|
-
exports.validateFileName = validateFileName;
|
|
1435
|
-
exports.parseExtraFields = parseExtraFields;
|
|
1436
|
-
exports.ZipFile = ZipFile;
|
|
1437
|
-
exports.Entry = Entry;
|
|
1438
|
-
exports.LocalFileHeader = LocalFileHeader;
|
|
1439
|
-
exports.RandomAccessReader = RandomAccessReader;
|
|
1440
|
-
function open(path4, options2, callback) {
|
|
1441
|
-
if (typeof options2 === "function") {
|
|
1442
|
-
callback = options2;
|
|
1443
|
-
options2 = null;
|
|
1444
|
-
}
|
|
1445
|
-
if (options2 == null) options2 = {};
|
|
1446
|
-
if (options2.autoClose == null) options2.autoClose = true;
|
|
1447
|
-
if (options2.lazyEntries == null) options2.lazyEntries = false;
|
|
1448
|
-
if (options2.decodeStrings == null) options2.decodeStrings = true;
|
|
1449
|
-
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1450
|
-
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1451
|
-
if (callback == null) callback = defaultCallback;
|
|
1452
|
-
fs5.open(path4, "r", function(err, fd) {
|
|
1453
|
-
if (err) return callback(err);
|
|
1454
|
-
fromFd(fd, options2, function(err2, zipfile) {
|
|
1455
|
-
if (err2) fs5.close(fd, defaultCallback);
|
|
1456
|
-
callback(err2, zipfile);
|
|
1457
|
-
});
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
function fromFd(fd, options2, callback) {
|
|
1461
|
-
if (typeof options2 === "function") {
|
|
1462
|
-
callback = options2;
|
|
1463
|
-
options2 = null;
|
|
1464
|
-
}
|
|
1465
|
-
if (options2 == null) options2 = {};
|
|
1466
|
-
if (options2.autoClose == null) options2.autoClose = false;
|
|
1467
|
-
if (options2.lazyEntries == null) options2.lazyEntries = false;
|
|
1468
|
-
if (options2.decodeStrings == null) options2.decodeStrings = true;
|
|
1469
|
-
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1470
|
-
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1471
|
-
if (callback == null) callback = defaultCallback;
|
|
1472
|
-
fs5.fstat(fd, function(err, stats) {
|
|
1473
|
-
if (err) return callback(err);
|
|
1474
|
-
var reader = fd_slicer.createFromFd(fd, { autoClose: true });
|
|
1475
|
-
fromRandomAccessReader(reader, stats.size, options2, callback);
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
function fromBuffer(buffer, options2, callback) {
|
|
1479
|
-
if (typeof options2 === "function") {
|
|
1480
|
-
callback = options2;
|
|
1481
|
-
options2 = null;
|
|
1482
|
-
}
|
|
1483
|
-
if (options2 == null) options2 = {};
|
|
1484
|
-
options2.autoClose = false;
|
|
1485
|
-
if (options2.lazyEntries == null) options2.lazyEntries = false;
|
|
1486
|
-
if (options2.decodeStrings == null) options2.decodeStrings = true;
|
|
1487
|
-
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1488
|
-
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1489
|
-
var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
|
|
1490
|
-
fromRandomAccessReader(reader, buffer.length, options2, callback);
|
|
1491
|
-
}
|
|
1492
|
-
function fromRandomAccessReader(reader, totalSize, options2, callback) {
|
|
1493
|
-
if (typeof options2 === "function") {
|
|
1494
|
-
callback = options2;
|
|
1495
|
-
options2 = null;
|
|
1496
|
-
}
|
|
1497
|
-
if (options2 == null) options2 = {};
|
|
1498
|
-
if (options2.autoClose == null) options2.autoClose = true;
|
|
1499
|
-
if (options2.lazyEntries == null) options2.lazyEntries = false;
|
|
1500
|
-
if (options2.decodeStrings == null) options2.decodeStrings = true;
|
|
1501
|
-
var decodeStrings = !!options2.decodeStrings;
|
|
1502
|
-
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1503
|
-
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1504
|
-
if (callback == null) callback = defaultCallback;
|
|
1505
|
-
if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
|
|
1506
|
-
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
|
1507
|
-
throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
|
|
1508
|
-
}
|
|
1509
|
-
reader.ref();
|
|
1510
|
-
var eocdrWithoutCommentSize = 22;
|
|
1511
|
-
var zip64EocdlSize = 20;
|
|
1512
|
-
var maxCommentSize = 65535;
|
|
1513
|
-
var bufferSize = Math.min(zip64EocdlSize + eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
|
1514
|
-
var buffer = newBuffer(bufferSize);
|
|
1515
|
-
var bufferReadStart = totalSize - buffer.length;
|
|
1516
|
-
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
|
1517
|
-
if (err) return callback(err);
|
|
1518
|
-
for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
|
|
1519
|
-
if (buffer.readUInt32LE(i) !== 101010256) continue;
|
|
1520
|
-
var eocdrBuffer = buffer.subarray(i);
|
|
1521
|
-
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
|
1522
|
-
var entryCount = eocdrBuffer.readUInt16LE(10);
|
|
1523
|
-
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
|
1524
|
-
var commentLength = eocdrBuffer.readUInt16LE(20);
|
|
1525
|
-
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
|
1526
|
-
if (commentLength !== expectedCommentLength) {
|
|
1527
|
-
return callback(new Error("Invalid comment length. Expected: " + expectedCommentLength + ". Found: " + commentLength + ". Are there extra bytes at the end of the file? Or is the end of central dir signature `PK\u263A\u263B` in the comment?"));
|
|
1528
|
-
}
|
|
1529
|
-
var comment = decodeStrings ? decodeBuffer(eocdrBuffer.subarray(22), false) : eocdrBuffer.subarray(22);
|
|
1530
|
-
if (i - zip64EocdlSize >= 0 && buffer.readUInt32LE(i - zip64EocdlSize) === 117853008) {
|
|
1531
|
-
var zip64EocdlBuffer = buffer.subarray(i - zip64EocdlSize, i - zip64EocdlSize + zip64EocdlSize);
|
|
1532
|
-
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
|
1533
|
-
var zip64EocdrBuffer = newBuffer(56);
|
|
1534
|
-
return readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err2) {
|
|
1535
|
-
if (err2) return callback(err2);
|
|
1536
|
-
if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
|
|
1537
|
-
return callback(new Error("invalid zip64 end of central directory record signature"));
|
|
1538
|
-
}
|
|
1539
|
-
diskNumber = zip64EocdrBuffer.readUInt32LE(16);
|
|
1540
|
-
if (diskNumber !== 0) {
|
|
1541
|
-
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
1542
|
-
}
|
|
1543
|
-
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
|
1544
|
-
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
|
1545
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
if (diskNumber !== 0) {
|
|
1549
|
-
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
1550
|
-
}
|
|
1551
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
|
|
1552
|
-
}
|
|
1553
|
-
callback(new Error("End of central directory record signature not found. Either not a zip file, or file is truncated."));
|
|
1554
|
-
});
|
|
1555
|
-
}
|
|
1556
|
-
util.inherits(ZipFile, EventEmitter);
|
|
1557
|
-
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
1558
|
-
var self = this;
|
|
1559
|
-
EventEmitter.call(self);
|
|
1560
|
-
self.reader = reader;
|
|
1561
|
-
self.reader.on("error", function(err) {
|
|
1562
|
-
emitError(self, err);
|
|
1563
|
-
});
|
|
1564
|
-
self.reader.once("close", function() {
|
|
1565
|
-
self.emit("close");
|
|
1566
|
-
});
|
|
1567
|
-
self.readEntryCursor = centralDirectoryOffset;
|
|
1568
|
-
self.fileSize = fileSize;
|
|
1569
|
-
self.entryCount = entryCount;
|
|
1570
|
-
self.comment = comment;
|
|
1571
|
-
self.entriesRead = 0;
|
|
1572
|
-
self.autoClose = !!autoClose;
|
|
1573
|
-
self.lazyEntries = !!lazyEntries;
|
|
1574
|
-
self.decodeStrings = !!decodeStrings;
|
|
1575
|
-
self.validateEntrySizes = !!validateEntrySizes;
|
|
1576
|
-
self.strictFileNames = !!strictFileNames;
|
|
1577
|
-
self.isOpen = true;
|
|
1578
|
-
self.emittedError = false;
|
|
1579
|
-
if (!self.lazyEntries) self._readEntry();
|
|
1580
|
-
}
|
|
1581
|
-
ZipFile.prototype.close = function() {
|
|
1582
|
-
if (!this.isOpen) return;
|
|
1583
|
-
this.isOpen = false;
|
|
1584
|
-
this.reader.unref();
|
|
1585
|
-
};
|
|
1586
|
-
function emitErrorAndAutoClose(self, err) {
|
|
1587
|
-
if (self.autoClose) self.close();
|
|
1588
|
-
emitError(self, err);
|
|
1589
|
-
}
|
|
1590
|
-
function emitError(self, err) {
|
|
1591
|
-
if (self.emittedError) return;
|
|
1592
|
-
self.emittedError = true;
|
|
1593
|
-
self.emit("error", err);
|
|
1594
|
-
}
|
|
1595
|
-
ZipFile.prototype.readEntry = function() {
|
|
1596
|
-
if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
|
|
1597
|
-
this._readEntry();
|
|
1598
|
-
};
|
|
1599
|
-
ZipFile.prototype._readEntry = function() {
|
|
1600
|
-
var self = this;
|
|
1601
|
-
if (self.entryCount === self.entriesRead) {
|
|
1602
|
-
setImmediate(function() {
|
|
1603
|
-
if (self.autoClose) self.close();
|
|
1604
|
-
if (self.emittedError) return;
|
|
1605
|
-
self.emit("end");
|
|
1606
|
-
});
|
|
1607
|
-
return;
|
|
1608
|
-
}
|
|
1609
|
-
if (self.emittedError) return;
|
|
1610
|
-
var buffer = newBuffer(46);
|
|
1611
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
1612
|
-
if (err) return emitErrorAndAutoClose(self, err);
|
|
1613
|
-
if (self.emittedError) return;
|
|
1614
|
-
var entry = new Entry();
|
|
1615
|
-
var signature = buffer.readUInt32LE(0);
|
|
1616
|
-
if (signature !== 33639248) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
|
1617
|
-
entry.versionMadeBy = buffer.readUInt16LE(4);
|
|
1618
|
-
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
|
1619
|
-
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
|
1620
|
-
entry.compressionMethod = buffer.readUInt16LE(10);
|
|
1621
|
-
entry.lastModFileTime = buffer.readUInt16LE(12);
|
|
1622
|
-
entry.lastModFileDate = buffer.readUInt16LE(14);
|
|
1623
|
-
entry.crc32 = buffer.readUInt32LE(16);
|
|
1624
|
-
entry.compressedSize = buffer.readUInt32LE(20);
|
|
1625
|
-
entry.uncompressedSize = buffer.readUInt32LE(24);
|
|
1626
|
-
entry.fileNameLength = buffer.readUInt16LE(28);
|
|
1627
|
-
entry.extraFieldLength = buffer.readUInt16LE(30);
|
|
1628
|
-
entry.fileCommentLength = buffer.readUInt16LE(32);
|
|
1629
|
-
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
|
1630
|
-
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
|
1631
|
-
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
|
1632
|
-
if (entry.generalPurposeBitFlag & 64) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
|
1633
|
-
self.readEntryCursor += 46;
|
|
1634
|
-
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
|
1635
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
|
|
1636
|
-
if (err2) return emitErrorAndAutoClose(self, err2);
|
|
1637
|
-
if (self.emittedError) return;
|
|
1638
|
-
entry.fileNameRaw = buffer.subarray(0, entry.fileNameLength);
|
|
1639
|
-
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
|
1640
|
-
entry.extraFieldRaw = buffer.subarray(entry.fileNameLength, fileCommentStart);
|
|
1641
|
-
entry.fileCommentRaw = buffer.subarray(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
|
1642
|
-
try {
|
|
1643
|
-
entry.extraFields = parseExtraFields(entry.extraFieldRaw);
|
|
1644
|
-
} catch (err3) {
|
|
1645
|
-
return emitErrorAndAutoClose(self, err3);
|
|
1646
|
-
}
|
|
1647
|
-
if (self.decodeStrings) {
|
|
1648
|
-
var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
|
|
1649
|
-
entry.fileComment = decodeBuffer(entry.fileCommentRaw, isUtf8);
|
|
1650
|
-
entry.fileName = getFileNameLowLevel(entry.generalPurposeBitFlag, entry.fileNameRaw, entry.extraFields, self.strictFileNames);
|
|
1651
|
-
var errorMessage = validateFileName(entry.fileName);
|
|
1652
|
-
if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
|
|
1653
|
-
} else {
|
|
1654
|
-
entry.fileComment = entry.fileCommentRaw;
|
|
1655
|
-
entry.fileName = entry.fileNameRaw;
|
|
1656
|
-
}
|
|
1657
|
-
entry.comment = entry.fileComment;
|
|
1658
|
-
self.readEntryCursor += buffer.length;
|
|
1659
|
-
self.entriesRead += 1;
|
|
1660
|
-
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
1661
|
-
var extraField = entry.extraFields[i];
|
|
1662
|
-
if (extraField.id !== 1) continue;
|
|
1663
|
-
var zip64EiefBuffer = extraField.data;
|
|
1664
|
-
var index = 0;
|
|
1665
|
-
if (entry.uncompressedSize === 4294967295) {
|
|
1666
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1667
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
|
1668
|
-
}
|
|
1669
|
-
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
1670
|
-
index += 8;
|
|
1671
|
-
}
|
|
1672
|
-
if (entry.compressedSize === 4294967295) {
|
|
1673
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1674
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
|
1675
|
-
}
|
|
1676
|
-
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
1677
|
-
index += 8;
|
|
1678
|
-
}
|
|
1679
|
-
if (entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
1680
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1681
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
|
1682
|
-
}
|
|
1683
|
-
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
|
1684
|
-
index += 8;
|
|
1685
|
-
}
|
|
1686
|
-
break;
|
|
1687
|
-
}
|
|
1688
|
-
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
|
1689
|
-
var expectedCompressedSize = entry.uncompressedSize;
|
|
1690
|
-
if (entry.isEncrypted()) {
|
|
1691
|
-
expectedCompressedSize += 12;
|
|
1692
|
-
}
|
|
1693
|
-
if (entry.compressedSize !== expectedCompressedSize) {
|
|
1694
|
-
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
|
1695
|
-
return emitErrorAndAutoClose(self, new Error(msg));
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
self.emit("entry", entry);
|
|
1699
|
-
if (!self.lazyEntries) self._readEntry();
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
};
|
|
1703
|
-
ZipFile.prototype.openReadStream = function(entry, options2, callback) {
|
|
1704
|
-
var self = this;
|
|
1705
|
-
var relativeStart = 0;
|
|
1706
|
-
var relativeEnd = entry.compressedSize;
|
|
1707
|
-
if (callback == null) {
|
|
1708
|
-
callback = options2;
|
|
1709
|
-
options2 = null;
|
|
1710
|
-
}
|
|
1711
|
-
if (options2 == null) {
|
|
1712
|
-
options2 = {};
|
|
1713
|
-
} else {
|
|
1714
|
-
if (options2.decrypt != null) {
|
|
1715
|
-
if (!entry.isEncrypted()) {
|
|
1716
|
-
throw new Error("options.decrypt can only be specified for encrypted entries");
|
|
1717
|
-
}
|
|
1718
|
-
if (options2.decrypt !== false) throw new Error("invalid options.decrypt value: " + options2.decrypt);
|
|
1719
|
-
if (entry.isCompressed()) {
|
|
1720
|
-
if (options2.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
if (options2.decompress != null) {
|
|
1724
|
-
if (!entry.isCompressed()) {
|
|
1725
|
-
throw new Error("options.decompress can only be specified for compressed entries");
|
|
1726
|
-
}
|
|
1727
|
-
if (!(options2.decompress === false || options2.decompress === true)) {
|
|
1728
|
-
throw new Error("invalid options.decompress value: " + options2.decompress);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
if (options2.start != null || options2.end != null) {
|
|
1732
|
-
if (entry.isCompressed() && options2.decompress !== false) {
|
|
1733
|
-
throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
|
|
1734
|
-
}
|
|
1735
|
-
if (entry.isEncrypted() && options2.decrypt !== false) {
|
|
1736
|
-
throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
if (options2.start != null) {
|
|
1740
|
-
relativeStart = options2.start;
|
|
1741
|
-
if (relativeStart < 0) throw new Error("options.start < 0");
|
|
1742
|
-
if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
|
|
1743
|
-
}
|
|
1744
|
-
if (options2.end != null) {
|
|
1745
|
-
relativeEnd = options2.end;
|
|
1746
|
-
if (relativeEnd < 0) throw new Error("options.end < 0");
|
|
1747
|
-
if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
|
|
1748
|
-
if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
if (!self.isOpen) return callback(new Error("closed"));
|
|
1752
|
-
if (entry.isEncrypted()) {
|
|
1753
|
-
if (options2.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
|
|
1754
|
-
}
|
|
1755
|
-
var decompress;
|
|
1756
|
-
if (entry.compressionMethod === 0) {
|
|
1757
|
-
decompress = false;
|
|
1758
|
-
} else if (entry.compressionMethod === 8) {
|
|
1759
|
-
decompress = options2.decompress != null ? options2.decompress : true;
|
|
1760
|
-
} else {
|
|
1761
|
-
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
|
1762
|
-
}
|
|
1763
|
-
self.readLocalFileHeader(entry, { minimal: true }, function(err, localFileHeader) {
|
|
1764
|
-
if (err) return callback(err);
|
|
1765
|
-
self.openReadStreamLowLevel(
|
|
1766
|
-
localFileHeader.fileDataStart,
|
|
1767
|
-
entry.compressedSize,
|
|
1768
|
-
relativeStart,
|
|
1769
|
-
relativeEnd,
|
|
1770
|
-
decompress,
|
|
1771
|
-
entry.uncompressedSize,
|
|
1772
|
-
callback
|
|
1773
|
-
);
|
|
1774
|
-
});
|
|
1775
|
-
};
|
|
1776
|
-
ZipFile.prototype.openReadStreamLowLevel = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, callback) {
|
|
1777
|
-
var self = this;
|
|
1778
|
-
var fileDataEnd = fileDataStart + compressedSize;
|
|
1779
|
-
var readStream = self.reader.createReadStream({
|
|
1780
|
-
start: fileDataStart + relativeStart,
|
|
1781
|
-
end: fileDataStart + relativeEnd
|
|
1782
|
-
});
|
|
1783
|
-
var endpointStream = readStream;
|
|
1784
|
-
if (decompress) {
|
|
1785
|
-
var destroyed = false;
|
|
1786
|
-
var inflateFilter = zlib.createInflateRaw();
|
|
1787
|
-
readStream.on("error", function(err) {
|
|
1788
|
-
setImmediate(function() {
|
|
1789
|
-
if (!destroyed) inflateFilter.emit("error", err);
|
|
1790
|
-
});
|
|
1791
|
-
});
|
|
1792
|
-
readStream.pipe(inflateFilter);
|
|
1793
|
-
if (self.validateEntrySizes) {
|
|
1794
|
-
endpointStream = new AssertByteCountStream(uncompressedSize);
|
|
1795
|
-
inflateFilter.on("error", function(err) {
|
|
1796
|
-
setImmediate(function() {
|
|
1797
|
-
if (!destroyed) endpointStream.emit("error", err);
|
|
1798
|
-
});
|
|
1799
|
-
});
|
|
1800
|
-
inflateFilter.pipe(endpointStream);
|
|
1801
|
-
} else {
|
|
1802
|
-
endpointStream = inflateFilter;
|
|
1803
|
-
}
|
|
1804
|
-
installDestroyFn(endpointStream, function() {
|
|
1805
|
-
destroyed = true;
|
|
1806
|
-
if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
|
|
1807
|
-
readStream.unpipe(inflateFilter);
|
|
1808
|
-
readStream.destroy();
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
callback(null, endpointStream);
|
|
1812
|
-
};
|
|
1813
|
-
ZipFile.prototype.readLocalFileHeader = function(entry, options2, callback) {
|
|
1814
|
-
var self = this;
|
|
1815
|
-
if (callback == null) {
|
|
1816
|
-
callback = options2;
|
|
1817
|
-
options2 = null;
|
|
1818
|
-
}
|
|
1819
|
-
if (options2 == null) options2 = {};
|
|
1820
|
-
self.reader.ref();
|
|
1821
|
-
var buffer = newBuffer(30);
|
|
1822
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
|
1823
|
-
try {
|
|
1824
|
-
if (err) return callback(err);
|
|
1825
|
-
var signature = buffer.readUInt32LE(0);
|
|
1826
|
-
if (signature !== 67324752) {
|
|
1827
|
-
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
|
1828
|
-
}
|
|
1829
|
-
var fileNameLength = buffer.readUInt16LE(26);
|
|
1830
|
-
var extraFieldLength = buffer.readUInt16LE(28);
|
|
1831
|
-
var fileDataStart = entry.relativeOffsetOfLocalHeader + 30 + fileNameLength + extraFieldLength;
|
|
1832
|
-
if (fileDataStart + entry.compressedSize > self.fileSize) {
|
|
1833
|
-
return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
|
1834
|
-
}
|
|
1835
|
-
if (options2.minimal) {
|
|
1836
|
-
return callback(null, { fileDataStart });
|
|
1837
|
-
}
|
|
1838
|
-
var localFileHeader = new LocalFileHeader();
|
|
1839
|
-
localFileHeader.fileDataStart = fileDataStart;
|
|
1840
|
-
localFileHeader.versionNeededToExtract = buffer.readUInt16LE(4);
|
|
1841
|
-
localFileHeader.generalPurposeBitFlag = buffer.readUInt16LE(6);
|
|
1842
|
-
localFileHeader.compressionMethod = buffer.readUInt16LE(8);
|
|
1843
|
-
localFileHeader.lastModFileTime = buffer.readUInt16LE(10);
|
|
1844
|
-
localFileHeader.lastModFileDate = buffer.readUInt16LE(12);
|
|
1845
|
-
localFileHeader.crc32 = buffer.readUInt32LE(14);
|
|
1846
|
-
localFileHeader.compressedSize = buffer.readUInt32LE(18);
|
|
1847
|
-
localFileHeader.uncompressedSize = buffer.readUInt32LE(22);
|
|
1848
|
-
localFileHeader.fileNameLength = fileNameLength;
|
|
1849
|
-
localFileHeader.extraFieldLength = extraFieldLength;
|
|
1850
|
-
buffer = newBuffer(fileNameLength + extraFieldLength);
|
|
1851
|
-
self.reader.ref();
|
|
1852
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader + 30, function(err2) {
|
|
1853
|
-
try {
|
|
1854
|
-
if (err2) return callback(err2);
|
|
1855
|
-
localFileHeader.fileName = buffer.subarray(0, fileNameLength);
|
|
1856
|
-
localFileHeader.extraField = buffer.subarray(fileNameLength);
|
|
1857
|
-
return callback(null, localFileHeader);
|
|
1858
|
-
} finally {
|
|
1859
|
-
self.reader.unref();
|
|
1860
|
-
}
|
|
1861
|
-
});
|
|
1862
|
-
} finally {
|
|
1863
|
-
self.reader.unref();
|
|
1864
|
-
}
|
|
1865
|
-
});
|
|
1866
|
-
};
|
|
1867
|
-
function Entry() {
|
|
1868
|
-
}
|
|
1869
|
-
Entry.prototype.getLastModDate = function(options2) {
|
|
1870
|
-
if (options2 == null) options2 = {};
|
|
1871
|
-
if (!options2.forceDosFormat) {
|
|
1872
|
-
for (var i = 0; i < this.extraFields.length; i++) {
|
|
1873
|
-
var extraField = this.extraFields[i];
|
|
1874
|
-
if (extraField.id === 21589) {
|
|
1875
|
-
var data = extraField.data;
|
|
1876
|
-
if (data.length < 5) continue;
|
|
1877
|
-
var flags = data[0];
|
|
1878
|
-
var HAS_MTIME = 1;
|
|
1879
|
-
if (!(flags & HAS_MTIME)) continue;
|
|
1880
|
-
var posixTimestamp = data.readInt32LE(1);
|
|
1881
|
-
return new Date(posixTimestamp * 1e3);
|
|
1882
|
-
} else if (extraField.id === 10) {
|
|
1883
|
-
var data = extraField.data;
|
|
1884
|
-
var cursor = 4;
|
|
1885
|
-
while (cursor < data.length + 4) {
|
|
1886
|
-
var tag = data.readUInt16LE(cursor);
|
|
1887
|
-
cursor += 2;
|
|
1888
|
-
var size = data.readUInt16LE(cursor);
|
|
1889
|
-
cursor += 2;
|
|
1890
|
-
if (tag !== 1) {
|
|
1891
|
-
cursor += size;
|
|
1892
|
-
continue;
|
|
1893
|
-
}
|
|
1894
|
-
if (size < 8 || cursor + size > data.length) break;
|
|
1895
|
-
var hundredNanoSecondsSince1601 = 4294967296 * data.readInt32LE(cursor + 4) + data.readUInt32LE(cursor);
|
|
1896
|
-
var millisecondsSince1970 = hundredNanoSecondsSince1601 / 1e4 - 116444736e5;
|
|
1897
|
-
return new Date(millisecondsSince1970);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime, options2.timezone);
|
|
1903
|
-
};
|
|
1904
|
-
Entry.prototype.isEncrypted = function() {
|
|
1905
|
-
return (this.generalPurposeBitFlag & 1) !== 0;
|
|
1906
|
-
};
|
|
1907
|
-
Entry.prototype.isCompressed = function() {
|
|
1908
|
-
return this.compressionMethod === 8;
|
|
1909
|
-
};
|
|
1910
|
-
function LocalFileHeader() {
|
|
1911
|
-
}
|
|
1912
|
-
function dosDateTimeToDate(date, time, timezone) {
|
|
1913
|
-
var day = date & 31;
|
|
1914
|
-
var month = (date >> 5 & 15) - 1;
|
|
1915
|
-
var year = (date >> 9 & 127) + 1980;
|
|
1916
|
-
var millisecond = 0;
|
|
1917
|
-
var second = (time & 31) * 2;
|
|
1918
|
-
var minute = time >> 5 & 63;
|
|
1919
|
-
var hour = time >> 11 & 31;
|
|
1920
|
-
if (timezone == null || timezone === "local") {
|
|
1921
|
-
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
1922
|
-
} else if (timezone === "UTC") {
|
|
1923
|
-
return new Date(Date.UTC(year, month, day, hour, minute, second, millisecond));
|
|
1924
|
-
} else {
|
|
1925
|
-
throw new Error("unrecognized options.timezone: " + options.timezone);
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
function getFileNameLowLevel(generalPurposeBitFlag, fileNameBuffer, extraFields, strictFileNames) {
|
|
1929
|
-
var fileName = null;
|
|
1930
|
-
for (var i = 0; i < extraFields.length; i++) {
|
|
1931
|
-
var extraField = extraFields[i];
|
|
1932
|
-
if (extraField.id === 28789) {
|
|
1933
|
-
if (extraField.data.length < 6) {
|
|
1934
|
-
continue;
|
|
1935
|
-
}
|
|
1936
|
-
if (extraField.data.readUInt8(0) !== 1) {
|
|
1937
|
-
continue;
|
|
1938
|
-
}
|
|
1939
|
-
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
|
1940
|
-
if (crc32.unsigned(fileNameBuffer) !== oldNameCrc32) {
|
|
1941
|
-
continue;
|
|
1942
|
-
}
|
|
1943
|
-
fileName = decodeBuffer(extraField.data.subarray(5), true);
|
|
1944
|
-
break;
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (fileName == null) {
|
|
1948
|
-
var isUtf8 = (generalPurposeBitFlag & 2048) !== 0;
|
|
1949
|
-
fileName = decodeBuffer(fileNameBuffer, isUtf8);
|
|
1950
|
-
}
|
|
1951
|
-
if (!strictFileNames) {
|
|
1952
|
-
fileName = fileName.replace(/\\/g, "/");
|
|
1953
|
-
}
|
|
1954
|
-
return fileName;
|
|
1955
|
-
}
|
|
1956
|
-
function validateFileName(fileName) {
|
|
1957
|
-
if (fileName.indexOf("\\") !== -1) {
|
|
1958
|
-
return "invalid characters in fileName: " + fileName;
|
|
1959
|
-
}
|
|
1960
|
-
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
|
1961
|
-
return "absolute path: " + fileName;
|
|
1962
|
-
}
|
|
1963
|
-
if (fileName.split("/").indexOf("..") !== -1) {
|
|
1964
|
-
return "invalid relative path: " + fileName;
|
|
1965
|
-
}
|
|
1966
|
-
return null;
|
|
1967
|
-
}
|
|
1968
|
-
function parseExtraFields(extraFieldBuffer) {
|
|
1969
|
-
var extraFields = [];
|
|
1970
|
-
var i = 0;
|
|
1971
|
-
while (i < extraFieldBuffer.length - 3) {
|
|
1972
|
-
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
|
1973
|
-
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
|
1974
|
-
var dataStart = i + 4;
|
|
1975
|
-
var dataEnd = dataStart + dataSize;
|
|
1976
|
-
if (dataEnd > extraFieldBuffer.length) throw new Error("extra field length exceeds extra field buffer size");
|
|
1977
|
-
var dataBuffer = extraFieldBuffer.subarray(dataStart, dataEnd);
|
|
1978
|
-
extraFields.push({
|
|
1979
|
-
id: headerId,
|
|
1980
|
-
data: dataBuffer
|
|
1981
|
-
});
|
|
1982
|
-
i = dataEnd;
|
|
1983
|
-
}
|
|
1984
|
-
return extraFields;
|
|
1985
|
-
}
|
|
1986
|
-
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
|
1987
|
-
if (length === 0) {
|
|
1988
|
-
return setImmediate(function() {
|
|
1989
|
-
callback(null, newBuffer(0));
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
|
1993
|
-
if (err) return callback(err);
|
|
1994
|
-
if (bytesRead < length) {
|
|
1995
|
-
return callback(new Error("unexpected EOF"));
|
|
1996
|
-
}
|
|
1997
|
-
callback();
|
|
1998
|
-
});
|
|
1999
|
-
}
|
|
2000
|
-
util.inherits(AssertByteCountStream, Transform);
|
|
2001
|
-
function AssertByteCountStream(byteCount) {
|
|
2002
|
-
Transform.call(this);
|
|
2003
|
-
this.actualByteCount = 0;
|
|
2004
|
-
this.expectedByteCount = byteCount;
|
|
2005
|
-
}
|
|
2006
|
-
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
|
2007
|
-
this.actualByteCount += chunk.length;
|
|
2008
|
-
if (this.actualByteCount > this.expectedByteCount) {
|
|
2009
|
-
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
|
2010
|
-
return cb(new Error(msg));
|
|
2011
|
-
}
|
|
2012
|
-
cb(null, chunk);
|
|
2013
|
-
};
|
|
2014
|
-
AssertByteCountStream.prototype._flush = function(cb) {
|
|
2015
|
-
if (this.actualByteCount < this.expectedByteCount) {
|
|
2016
|
-
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
|
2017
|
-
return cb(new Error(msg));
|
|
2018
|
-
}
|
|
2019
|
-
cb();
|
|
2020
|
-
};
|
|
2021
|
-
util.inherits(RandomAccessReader, EventEmitter);
|
|
2022
|
-
function RandomAccessReader() {
|
|
2023
|
-
EventEmitter.call(this);
|
|
2024
|
-
this.refCount = 0;
|
|
2025
|
-
}
|
|
2026
|
-
RandomAccessReader.prototype.ref = function() {
|
|
2027
|
-
this.refCount += 1;
|
|
2028
|
-
};
|
|
2029
|
-
RandomAccessReader.prototype.unref = function() {
|
|
2030
|
-
var self = this;
|
|
2031
|
-
self.refCount -= 1;
|
|
2032
|
-
if (self.refCount > 0) return;
|
|
2033
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
|
2034
|
-
self.close(onCloseDone);
|
|
2035
|
-
function onCloseDone(err) {
|
|
2036
|
-
if (err) return self.emit("error", err);
|
|
2037
|
-
self.emit("close");
|
|
2038
|
-
}
|
|
2039
|
-
};
|
|
2040
|
-
RandomAccessReader.prototype.createReadStream = function(options2) {
|
|
2041
|
-
if (options2 == null) options2 = {};
|
|
2042
|
-
var start = options2.start;
|
|
2043
|
-
var end = options2.end;
|
|
2044
|
-
if (start === end) {
|
|
2045
|
-
var emptyStream = new PassThrough();
|
|
2046
|
-
setImmediate(function() {
|
|
2047
|
-
emptyStream.end();
|
|
2048
|
-
});
|
|
2049
|
-
return emptyStream;
|
|
2050
|
-
}
|
|
2051
|
-
var stream = this._readStreamForRange(start, end);
|
|
2052
|
-
var destroyed = false;
|
|
2053
|
-
var refUnrefFilter = new RefUnrefFilter(this);
|
|
2054
|
-
stream.on("error", function(err) {
|
|
2055
|
-
setImmediate(function() {
|
|
2056
|
-
if (!destroyed) refUnrefFilter.emit("error", err);
|
|
2057
|
-
});
|
|
2058
|
-
});
|
|
2059
|
-
installDestroyFn(refUnrefFilter, function() {
|
|
2060
|
-
stream.unpipe(refUnrefFilter);
|
|
2061
|
-
refUnrefFilter.unref();
|
|
2062
|
-
stream.destroy();
|
|
2063
|
-
});
|
|
2064
|
-
var byteCounter = new AssertByteCountStream(end - start);
|
|
2065
|
-
refUnrefFilter.on("error", function(err) {
|
|
2066
|
-
setImmediate(function() {
|
|
2067
|
-
if (!destroyed) byteCounter.emit("error", err);
|
|
2068
|
-
});
|
|
2069
|
-
});
|
|
2070
|
-
installDestroyFn(byteCounter, function() {
|
|
2071
|
-
destroyed = true;
|
|
2072
|
-
refUnrefFilter.unpipe(byteCounter);
|
|
2073
|
-
refUnrefFilter.destroy();
|
|
2074
|
-
});
|
|
2075
|
-
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
|
2076
|
-
};
|
|
2077
|
-
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
|
2078
|
-
throw new Error("not implemented");
|
|
2079
|
-
};
|
|
2080
|
-
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
|
2081
|
-
var readStream = this.createReadStream({ start: position, end: position + length });
|
|
2082
|
-
var writeStream = new Writable();
|
|
2083
|
-
var written = 0;
|
|
2084
|
-
writeStream._write = function(chunk, encoding, cb) {
|
|
2085
|
-
chunk.copy(buffer, offset + written, 0, chunk.length);
|
|
2086
|
-
written += chunk.length;
|
|
2087
|
-
cb();
|
|
2088
|
-
};
|
|
2089
|
-
writeStream.on("finish", callback);
|
|
2090
|
-
readStream.on("error", function(error) {
|
|
2091
|
-
callback(error);
|
|
2092
|
-
});
|
|
2093
|
-
readStream.pipe(writeStream);
|
|
2094
|
-
};
|
|
2095
|
-
RandomAccessReader.prototype.close = function(callback) {
|
|
2096
|
-
setImmediate(callback);
|
|
2097
|
-
};
|
|
2098
|
-
util.inherits(RefUnrefFilter, PassThrough);
|
|
2099
|
-
function RefUnrefFilter(context) {
|
|
2100
|
-
PassThrough.call(this);
|
|
2101
|
-
this.context = context;
|
|
2102
|
-
this.context.ref();
|
|
2103
|
-
this.unreffedYet = false;
|
|
2104
|
-
}
|
|
2105
|
-
RefUnrefFilter.prototype._flush = function(cb) {
|
|
2106
|
-
this.unref();
|
|
2107
|
-
cb();
|
|
2108
|
-
};
|
|
2109
|
-
RefUnrefFilter.prototype.unref = function(cb) {
|
|
2110
|
-
if (this.unreffedYet) return;
|
|
2111
|
-
this.unreffedYet = true;
|
|
2112
|
-
this.context.unref();
|
|
2113
|
-
};
|
|
2114
|
-
var cp437 = "\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
|
|
2115
|
-
function decodeBuffer(buffer, isUtf8) {
|
|
2116
|
-
if (isUtf8) {
|
|
2117
|
-
return buffer.toString("utf8");
|
|
2118
|
-
} else {
|
|
2119
|
-
var result = "";
|
|
2120
|
-
for (var i = 0; i < buffer.length; i++) {
|
|
2121
|
-
result += cp437[buffer[i]];
|
|
2122
|
-
}
|
|
2123
|
-
return result;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
function readUInt64LE(buffer, offset) {
|
|
2127
|
-
var lower32 = buffer.readUInt32LE(offset);
|
|
2128
|
-
var upper32 = buffer.readUInt32LE(offset + 4);
|
|
2129
|
-
return upper32 * 4294967296 + lower32;
|
|
2130
|
-
}
|
|
2131
|
-
var newBuffer;
|
|
2132
|
-
if (typeof Buffer.allocUnsafe === "function") {
|
|
2133
|
-
newBuffer = function(len) {
|
|
2134
|
-
return Buffer.allocUnsafe(len);
|
|
2135
|
-
};
|
|
2136
|
-
} else {
|
|
2137
|
-
newBuffer = function(len) {
|
|
2138
|
-
return new Buffer(len);
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
function installDestroyFn(stream, fn) {
|
|
2142
|
-
if (typeof stream.destroy === "function") {
|
|
2143
|
-
stream._destroy = function(err, cb) {
|
|
2144
|
-
fn();
|
|
2145
|
-
if (cb != null) cb(err);
|
|
2146
|
-
};
|
|
2147
|
-
} else {
|
|
2148
|
-
stream.destroy = fn;
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
function defaultCallback(err) {
|
|
2152
|
-
if (err) throw err;
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
});
|
|
2156
|
-
|
|
2157
776
|
// src/index.ts
|
|
2158
777
|
init_esm_shims();
|
|
2159
778
|
import { Cli } from "clipanion";
|
|
@@ -2163,9 +782,10 @@ init_esm_shims();
|
|
|
2163
782
|
var import_debug2 = __toESM(require_src(), 1);
|
|
2164
783
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
2165
784
|
import assert from "assert";
|
|
2166
|
-
import
|
|
2167
|
-
import
|
|
785
|
+
import fs2 from "fs";
|
|
786
|
+
import path from "path";
|
|
2168
787
|
import * as p from "@clack/prompts";
|
|
788
|
+
import { getPackageRoot, readZipContent } from "@react-native-bedrock/utils";
|
|
2169
789
|
import { Command, Option } from "clipanion";
|
|
2170
790
|
|
|
2171
791
|
// src/utils/constants.ts
|
|
@@ -2173,63 +793,10 @@ init_esm_shims();
|
|
|
2173
793
|
var APP_MANIFEST_NAME = "app.json";
|
|
2174
794
|
var DEFAULT_API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
2175
795
|
|
|
2176
|
-
// src/utils/getPackageRoot.ts
|
|
2177
|
-
init_esm_shims();
|
|
2178
|
-
import fs from "fs";
|
|
2179
|
-
import path from "path";
|
|
2180
|
-
function getPackageRoot() {
|
|
2181
|
-
let cwd = process.cwd();
|
|
2182
|
-
const root = path.parse(cwd).root;
|
|
2183
|
-
while (cwd !== root) {
|
|
2184
|
-
if (fs.existsSync(path.join(cwd, "package.json"))) {
|
|
2185
|
-
return cwd;
|
|
2186
|
-
}
|
|
2187
|
-
cwd = path.dirname(cwd);
|
|
2188
|
-
}
|
|
2189
|
-
return cwd;
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
// src/utils/readZipContent.ts
|
|
2193
|
-
init_esm_shims();
|
|
2194
|
-
var import_yauzl = __toESM(require_yauzl(), 1);
|
|
2195
|
-
function readZipContent(zipPath, fileName) {
|
|
2196
|
-
return new Promise((resolve, reject) => {
|
|
2197
|
-
import_yauzl.default.open(zipPath, { lazyEntries: true }, (error, zipFile) => {
|
|
2198
|
-
if (error) {
|
|
2199
|
-
reject(error);
|
|
2200
|
-
return;
|
|
2201
|
-
}
|
|
2202
|
-
zipFile.on("entry", (entry) => {
|
|
2203
|
-
if (entry.fileName === fileName) {
|
|
2204
|
-
zipFile.openReadStream(entry, (error2, readStream) => {
|
|
2205
|
-
if (error2) {
|
|
2206
|
-
throw error2;
|
|
2207
|
-
}
|
|
2208
|
-
let fileData = "";
|
|
2209
|
-
readStream.on("data", (chunk) => fileData += chunk.toString("utf8")).on("end", () => {
|
|
2210
|
-
zipFile.close();
|
|
2211
|
-
resolve(fileData);
|
|
2212
|
-
});
|
|
2213
|
-
});
|
|
2214
|
-
} else {
|
|
2215
|
-
zipFile.readEntry();
|
|
2216
|
-
}
|
|
2217
|
-
}).on("end", () => {
|
|
2218
|
-
zipFile.close();
|
|
2219
|
-
reject(new Error(`'${fileName}' not found in zip file`));
|
|
2220
|
-
}).on("error", (error2) => {
|
|
2221
|
-
zipFile.close();
|
|
2222
|
-
reject(error2);
|
|
2223
|
-
});
|
|
2224
|
-
zipFile.readEntry();
|
|
2225
|
-
});
|
|
2226
|
-
});
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
796
|
// src/utils/upload.ts
|
|
2230
797
|
init_esm_shims();
|
|
2231
798
|
var import_debug = __toESM(require_src(), 1);
|
|
2232
|
-
import
|
|
799
|
+
import fs from "fs";
|
|
2233
800
|
var debug = (0, import_debug.default)("cli:deploy");
|
|
2234
801
|
async function uploadArtifact(config) {
|
|
2235
802
|
debug("uploadArtifact", config);
|
|
@@ -2242,7 +809,7 @@ async function uploadArtifact(config) {
|
|
|
2242
809
|
"Content-Type": "application/octet-stream",
|
|
2243
810
|
"X-Ait-Console-Api-Key": config.apiKey
|
|
2244
811
|
},
|
|
2245
|
-
body:
|
|
812
|
+
body: fs.createReadStream(config.artifactPath),
|
|
2246
813
|
duplex: "half"
|
|
2247
814
|
}
|
|
2248
815
|
);
|
|
@@ -2289,11 +856,11 @@ var DeployCommand = class extends Command {
|
|
|
2289
856
|
}
|
|
2290
857
|
try {
|
|
2291
858
|
const packageRoot = getPackageRoot();
|
|
2292
|
-
const artifactFile =
|
|
859
|
+
const artifactFile = fs2.readdirSync(packageRoot).find((file) => file.endsWith(".ait"));
|
|
2293
860
|
if (!artifactFile) {
|
|
2294
861
|
throw new Error("\uBC30\uD3EC\uD560 .ait \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
2295
862
|
}
|
|
2296
|
-
const resolvedArtifactPath =
|
|
863
|
+
const resolvedArtifactPath = path.resolve(packageRoot, artifactFile);
|
|
2297
864
|
const { appName, deploymentId } = await readZipContent(resolvedArtifactPath, APP_MANIFEST_NAME).then((rawAppManifest) => {
|
|
2298
865
|
const appManifest = JSON.parse(rawAppManifest);
|
|
2299
866
|
const appName2 = appManifest.appName;
|
|
@@ -2335,9 +902,10 @@ var DeployCommand = class extends Command {
|
|
|
2335
902
|
|
|
2336
903
|
// src/InitCommand.ts
|
|
2337
904
|
init_esm_shims();
|
|
2338
|
-
import
|
|
2339
|
-
import
|
|
905
|
+
import fs3 from "fs";
|
|
906
|
+
import path2 from "path";
|
|
2340
907
|
import * as p2 from "@clack/prompts";
|
|
908
|
+
import { getPackageRoot as getPackageRoot2 } from "@react-native-bedrock/utils";
|
|
2341
909
|
import { Command as Command2, Option as Option2 } from "clipanion";
|
|
2342
910
|
|
|
2343
911
|
// ../../.yarn/cache/es-toolkit-npm-1.32.0-019fc7c155-56ba965570.zip/node_modules/es-toolkit/dist/index.mjs
|
|
@@ -2436,7 +1004,7 @@ function transformTemplate(templateString, values) {
|
|
|
2436
1004
|
|
|
2437
1005
|
// src/InitCommand.ts
|
|
2438
1006
|
async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
2439
|
-
const packageJson = await
|
|
1007
|
+
const packageJson = await fs3.promises.readFile(path2.join(cwd, "package.json"), {
|
|
2440
1008
|
encoding: "utf-8"
|
|
2441
1009
|
});
|
|
2442
1010
|
const scripts = JSON.parse(packageJson);
|
|
@@ -2447,11 +1015,11 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
2447
1015
|
scripts.scripts.dev = "bedrock dev";
|
|
2448
1016
|
scripts.scripts.build = "bedrock build";
|
|
2449
1017
|
scripts.scripts.deploy = "ait deploy";
|
|
2450
|
-
await
|
|
1018
|
+
await fs3.promises.writeFile(path2.join(cwd, "package.json"), JSON.stringify(scripts, null, 2), {
|
|
2451
1019
|
encoding: "utf-8"
|
|
2452
1020
|
});
|
|
2453
1021
|
p2.log.step(".gitignore \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
|
|
2454
|
-
await
|
|
1022
|
+
await fs3.promises.appendFile(path2.join(cwd, ".gitignore"), "\n.bedrock\n");
|
|
2455
1023
|
const placeholder = {
|
|
2456
1024
|
dev: originalScripts.dev === "bedrock dev" ? "" : originalScripts.dev,
|
|
2457
1025
|
build: originalScripts.build === "bedrock build" ? "" : originalScripts.build
|
|
@@ -2491,7 +1059,7 @@ async function templateWebFramework({ appName, cwd, skipInput }) {
|
|
|
2491
1059
|
webDevCommand: scriptInputs.dev === "bedrock dev" ? "" : scriptInputs.dev,
|
|
2492
1060
|
webBuildCommand: scriptInputs.build === "bedrock build" ? "" : scriptInputs.build
|
|
2493
1061
|
});
|
|
2494
|
-
await
|
|
1062
|
+
await fs3.promises.writeFile(path2.join(cwd, "bedrock.config.ts"), config, {
|
|
2495
1063
|
encoding: "utf-8"
|
|
2496
1064
|
});
|
|
2497
1065
|
}
|
|
@@ -2500,11 +1068,11 @@ async function templateReactNative({ appName, cwd }) {
|
|
|
2500
1068
|
const config = transformTemplate(REACT_NATIVE_FRAMEWORK_CONFIG_TEMPLATE, {
|
|
2501
1069
|
appName
|
|
2502
1070
|
});
|
|
2503
|
-
await
|
|
1071
|
+
await fs3.promises.writeFile(path2.join(cwd, "bedrock.config.ts"), config, {
|
|
2504
1072
|
encoding: "utf-8"
|
|
2505
1073
|
});
|
|
2506
1074
|
p2.log.step("src/_app.tsx \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
2507
|
-
await
|
|
1075
|
+
await fs3.promises.writeFile(path2.join(cwd, "src", "_app.tsx"), APP_TEMPLATE, {
|
|
2508
1076
|
encoding: "utf-8"
|
|
2509
1077
|
});
|
|
2510
1078
|
}
|
|
@@ -2535,7 +1103,7 @@ var InitCommand = class extends Command2 {
|
|
|
2535
1103
|
if (p2.isCancel(template)) {
|
|
2536
1104
|
process.exit(0);
|
|
2537
1105
|
}
|
|
2538
|
-
const cwd =
|
|
1106
|
+
const cwd = getPackageRoot2();
|
|
2539
1107
|
p2.intro("\u{1F680} \uC571 \uCD08\uAE30\uD654\uB97C \uC2DC\uC791\uD569\uB2C8\uB2E4");
|
|
2540
1108
|
const appName = await ensureSelect({
|
|
2541
1109
|
value: this.appName,
|