metadata-detector-streams 3.0.19 → 3.0.21
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/build/node/module.js +0 -6
- package/build/node/streams/locate.js +6 -43
- package/build/node/streams/strip.js +6 -42
- package/build/node/types/index.js +0 -4
- package/package.json +13 -13
package/build/node/module.js
CHANGED
|
@@ -4,15 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createStripStream = exports.createLocateStream = void 0;
|
|
7
|
-
|
|
8
7
|
var _locate = require("./streams/locate");
|
|
9
|
-
|
|
10
8
|
var _strip = require("./streams/strip");
|
|
11
|
-
|
|
12
9
|
const createLocateStream = () => new _locate.LocateStream();
|
|
13
|
-
|
|
14
10
|
exports.createLocateStream = createLocateStream;
|
|
15
|
-
|
|
16
11
|
const createStripStream = () => new _strip.StripStream();
|
|
17
|
-
|
|
18
12
|
exports.createStripStream = createStripStream;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.LocateStream = void 0;
|
|
7
|
-
|
|
8
7
|
var _buffer = require("buffer");
|
|
9
|
-
|
|
10
8
|
var _stream = require("stream");
|
|
11
|
-
|
|
12
9
|
var _synchsafe = require("synchsafe");
|
|
13
|
-
|
|
14
10
|
class LocateStream extends _stream.Writable {
|
|
15
11
|
constructor(options) {
|
|
16
12
|
super(options);
|
|
@@ -21,129 +17,96 @@ class LocateStream extends _stream.Writable {
|
|
|
21
17
|
this._nextOggPageStart = 0;
|
|
22
18
|
this._offset = 0;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
_final(callback) {
|
|
26
21
|
this._isLastAnalysis = true;
|
|
27
|
-
|
|
28
22
|
this._analyzeBuffer();
|
|
29
|
-
|
|
30
23
|
callback();
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
_write(chunk, _, callback) {
|
|
34
26
|
this._buffer = _buffer.Buffer.concat([this._buffer, chunk], this._buffer.length + chunk.length);
|
|
35
|
-
|
|
36
27
|
if (this._analyzeBuffer()) {
|
|
37
28
|
this._offset += this._buffer.length - 128;
|
|
38
29
|
this._buffer = this._buffer.slice(-128);
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
callback();
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
_analyzeBuffer() {
|
|
45
34
|
if (this._isFirstAnalysis && this._buffer.length < 8) {
|
|
46
35
|
return false;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 0, 4) === 'fLaC') {
|
|
50
38
|
let isLast = false;
|
|
51
39
|
let length = 0;
|
|
52
40
|
let offset = 4;
|
|
53
|
-
|
|
54
41
|
while (!isLast) {
|
|
55
42
|
offset += length;
|
|
56
|
-
|
|
57
43
|
if (this._buffer.length < offset + 4) {
|
|
58
44
|
return false;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
46
|
isLast = (this._buffer.readUInt8(offset) & 0x80) !== 0; // tslint:disable-line:no-bitwise
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this._buffer.readUInt8(offset + 2) << 8 |
|
|
65
|
-
|
|
47
|
+
length = (this._buffer.readUInt8(offset + 3) |
|
|
48
|
+
// tslint:disable-line:no-bitwise
|
|
49
|
+
this._buffer.readUInt8(offset + 2) << 8 |
|
|
50
|
+
// tslint:disable-line:no-bitwise
|
|
51
|
+
this._buffer.readUInt8(offset + 1) << 16) +
|
|
52
|
+
// tslint:disable-line:no-bitwise
|
|
66
53
|
4;
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
this.emit('location', [0, offset + length]);
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 4, 8) === 'ftyp' || this._nextMpeg4AtomStart > 0) {
|
|
73
58
|
let offset = this._nextMpeg4AtomStart - this._offset;
|
|
74
|
-
|
|
75
59
|
while (offset < this._buffer.length - 8) {
|
|
76
60
|
const length = this._buffer.readUInt32BE(offset);
|
|
77
|
-
|
|
78
61
|
const atom = this._buffer.toString('utf8', offset + 4, offset + 8);
|
|
79
|
-
|
|
80
62
|
if (atom === 'moov' || atom === 'wide') {
|
|
81
63
|
this.emit('location', [this._nextMpeg4AtomStart, this._nextMpeg4AtomStart + length]);
|
|
82
64
|
}
|
|
83
|
-
|
|
84
65
|
this._nextMpeg4AtomStart += length;
|
|
85
66
|
offset += length;
|
|
86
67
|
}
|
|
87
|
-
|
|
88
68
|
if (offset < this._buffer.length) {
|
|
89
69
|
return false;
|
|
90
70
|
}
|
|
91
71
|
}
|
|
92
|
-
|
|
93
72
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 0, 3) === 'ID3') {
|
|
94
73
|
this.emit('location', [0, (0, _synchsafe.decode)(this._buffer.readUInt32BE(6)) + 10]);
|
|
95
74
|
}
|
|
96
|
-
|
|
97
75
|
if (this._offset + this._buffer.length > this._nextOggPageStart + 4) {
|
|
98
76
|
const offset = this._nextOggPageStart - this._offset;
|
|
99
|
-
|
|
100
77
|
if (this._buffer.toString('utf8', offset, offset + 4) === 'OggS') {
|
|
101
78
|
if (this._offset + this._buffer.length < this._nextOggPageStart + 27) {
|
|
102
79
|
return false;
|
|
103
80
|
}
|
|
104
|
-
|
|
105
81
|
const streamStructureVersion = this._buffer.readUInt8(offset + 4);
|
|
106
|
-
|
|
107
82
|
if (streamStructureVersion === 0) {
|
|
108
83
|
const pageSegments = this._buffer.readUInt8(offset + 26);
|
|
109
|
-
|
|
110
84
|
let pageSize = 27 + pageSegments;
|
|
111
|
-
|
|
112
85
|
if (this._offset + this._buffer.length < this._nextOggPageStart + 28 + pageSegments + 1 + 6) {
|
|
113
86
|
return false;
|
|
114
87
|
}
|
|
115
|
-
|
|
116
88
|
for (let i = 0; i < pageSegments; i += 1) {
|
|
117
89
|
pageSize += this._buffer.readUInt8(offset + 27 + i);
|
|
118
90
|
}
|
|
119
|
-
|
|
120
91
|
const firstByte = this._buffer.readUInt8(offset + 27 + pageSegments);
|
|
121
|
-
|
|
122
92
|
if (firstByte === 3) {
|
|
123
93
|
const index = offset + 27 + pageSegments + 1;
|
|
124
|
-
|
|
125
94
|
const identifier = this._buffer.toString('utf8', index, index + 6);
|
|
126
|
-
|
|
127
95
|
if (identifier === 'vorbis') {
|
|
128
96
|
this.emit('location', [offset, offset + pageSize]);
|
|
129
97
|
}
|
|
130
98
|
}
|
|
131
|
-
|
|
132
99
|
this._nextOggPageStart += pageSize;
|
|
133
100
|
}
|
|
134
101
|
}
|
|
135
102
|
} else {
|
|
136
103
|
return false;
|
|
137
104
|
}
|
|
138
|
-
|
|
139
105
|
if (this._isLastAnalysis && this._buffer.toString('utf8', this._buffer.length - 128, this._buffer.length - 125) === 'TAG') {
|
|
140
106
|
this.emit('location', [this._offset + this._buffer.length - 128, this._offset + this._buffer.length]);
|
|
141
107
|
}
|
|
142
|
-
|
|
143
108
|
this._isFirstAnalysis = false;
|
|
144
109
|
return true;
|
|
145
110
|
}
|
|
146
|
-
|
|
147
111
|
}
|
|
148
|
-
|
|
149
112
|
exports.LocateStream = LocateStream;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StripStream = void 0;
|
|
7
|
-
|
|
8
7
|
var _buffer = require("buffer");
|
|
9
|
-
|
|
10
8
|
var _stream = require("stream");
|
|
11
|
-
|
|
12
9
|
var _synchsafe = require("synchsafe");
|
|
13
|
-
|
|
14
10
|
class StripStream extends _stream.Transform {
|
|
15
11
|
constructor(options) {
|
|
16
12
|
super(options);
|
|
@@ -21,69 +17,55 @@ class StripStream extends _stream.Transform {
|
|
|
21
17
|
this._nextOggPageStart = 0;
|
|
22
18
|
this._offset = 0;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
_flush(callback) {
|
|
26
21
|
this._isLastAnalysis = true;
|
|
27
|
-
|
|
28
22
|
this._analyzeBuffer();
|
|
29
|
-
|
|
30
23
|
this.push(this._buffer);
|
|
31
24
|
callback();
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
_transform(chunk, _, callback) {
|
|
35
27
|
this._buffer = _buffer.Buffer.concat([this._buffer, chunk], this._buffer.length + chunk.length);
|
|
36
|
-
|
|
37
28
|
if (this._analyzeBuffer()) {
|
|
38
29
|
const offset = Math.min(this._buffer.length, 128);
|
|
39
30
|
this.push(this._buffer.slice(0, -offset));
|
|
40
31
|
this._offset += this._buffer.length - offset;
|
|
41
32
|
this._buffer = this._buffer.slice(-offset);
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
callback();
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
_analyzeBuffer() {
|
|
48
37
|
if (this._isFirstAnalysis && this._buffer.length < 8) {
|
|
49
38
|
return false;
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 0, 4) === 'fLaC') {
|
|
53
41
|
let isLast = false;
|
|
54
42
|
let length = 0;
|
|
55
43
|
let offset = 4;
|
|
56
|
-
|
|
57
44
|
while (!isLast) {
|
|
58
45
|
offset += length;
|
|
59
|
-
|
|
60
46
|
if (this._buffer.length < offset + 4) {
|
|
61
47
|
return false;
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
isLast = (this._buffer.readUInt8(offset) & 0x80) !== 0; // tslint:disable-line:no-bitwise
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this._buffer.readUInt8(offset + 2) << 8 |
|
|
68
|
-
|
|
50
|
+
length = (this._buffer.readUInt8(offset + 3) |
|
|
51
|
+
// tslint:disable-line:no-bitwise
|
|
52
|
+
this._buffer.readUInt8(offset + 2) << 8 |
|
|
53
|
+
// tslint:disable-line:no-bitwise
|
|
54
|
+
this._buffer.readUInt8(offset + 1) << 16) +
|
|
55
|
+
// tslint:disable-line:no-bitwise
|
|
69
56
|
4;
|
|
70
57
|
}
|
|
71
|
-
|
|
72
58
|
if (this._buffer.length >= offset + length) {
|
|
73
59
|
this._buffer = this._buffer.slice(offset + length);
|
|
74
60
|
} else {
|
|
75
61
|
return false;
|
|
76
62
|
}
|
|
77
63
|
}
|
|
78
|
-
|
|
79
64
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 4, 8) === 'ftyp' || this._nextMpeg4AtomStart > 0) {
|
|
80
65
|
let offset = this._nextMpeg4AtomStart - this._offset;
|
|
81
|
-
|
|
82
66
|
while (offset < this._buffer.length - 8) {
|
|
83
67
|
const length = this._buffer.readUInt32BE(offset);
|
|
84
|
-
|
|
85
68
|
const atom = this._buffer.toString('utf8', offset + 4, offset + 8);
|
|
86
|
-
|
|
87
69
|
if (atom === 'moov' || atom === 'wide') {
|
|
88
70
|
if (this._buffer.length >= offset + length) {
|
|
89
71
|
this._buffer = _buffer.Buffer.concat([this._buffer.slice(0, offset), this._buffer.slice(offset + length)], this._buffer.length - length);
|
|
@@ -95,54 +77,40 @@ class StripStream extends _stream.Transform {
|
|
|
95
77
|
offset += length;
|
|
96
78
|
}
|
|
97
79
|
}
|
|
98
|
-
|
|
99
80
|
if (offset < this._buffer.length) {
|
|
100
81
|
return false;
|
|
101
82
|
}
|
|
102
83
|
}
|
|
103
|
-
|
|
104
84
|
if (this._isFirstAnalysis && this._buffer.toString('utf8', 0, 3) === 'ID3') {
|
|
105
85
|
const nextByte = (0, _synchsafe.decode)(this._buffer.readUInt32BE(6)) + 10;
|
|
106
|
-
|
|
107
86
|
if (this._buffer.length >= nextByte) {
|
|
108
87
|
this._buffer = this._buffer.slice(nextByte);
|
|
109
88
|
} else {
|
|
110
89
|
return false;
|
|
111
90
|
}
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
if (this._offset + this._buffer.length > this._nextOggPageStart + 4) {
|
|
115
93
|
const offset = this._nextOggPageStart - this._offset;
|
|
116
|
-
|
|
117
94
|
if (this._buffer.toString('utf8', offset, offset + 4) === 'OggS') {
|
|
118
95
|
if (this._offset + this._buffer.length < this._nextOggPageStart + 27) {
|
|
119
96
|
return false;
|
|
120
97
|
}
|
|
121
|
-
|
|
122
98
|
const streamStructureVersion = this._buffer.readUInt8(offset + 4);
|
|
123
|
-
|
|
124
99
|
if (streamStructureVersion === 0) {
|
|
125
100
|
const pageSegments = this._buffer.readUInt8(offset + 26);
|
|
126
|
-
|
|
127
101
|
let pageSize = 27 + pageSegments;
|
|
128
|
-
|
|
129
102
|
if (this._offset + this._buffer.length < this._nextOggPageStart + 28 + pageSegments + 1 + 6) {
|
|
130
103
|
return false;
|
|
131
104
|
}
|
|
132
|
-
|
|
133
105
|
for (let i = 0; i < pageSegments; i += 1) {
|
|
134
106
|
pageSize += this._buffer.readUInt8(offset + 27 + i);
|
|
135
107
|
}
|
|
136
|
-
|
|
137
108
|
const firstByte = this._buffer.readUInt8(offset + 27 + pageSegments);
|
|
138
|
-
|
|
139
109
|
const identifier = this._buffer.toString('utf8', offset + 27 + pageSegments + 1, offset + 27 + pageSegments + 1 + 6);
|
|
140
|
-
|
|
141
110
|
if (firstByte === 3 && identifier === 'vorbis') {
|
|
142
111
|
if (this._offset + this._buffer.length < this._nextOggPageStart + pageSize) {
|
|
143
112
|
return false;
|
|
144
113
|
}
|
|
145
|
-
|
|
146
114
|
this._buffer = _buffer.Buffer.concat([this._buffer.slice(0, this._nextOggPageStart - this._offset), this._buffer.slice(this._nextOggPageStart + pageSize - this._offset)], this._buffer.length - pageSize);
|
|
147
115
|
this._nextOggPageStart += pageSize;
|
|
148
116
|
} else {
|
|
@@ -153,15 +121,11 @@ class StripStream extends _stream.Transform {
|
|
|
153
121
|
} else {
|
|
154
122
|
return false;
|
|
155
123
|
}
|
|
156
|
-
|
|
157
124
|
if (this._isLastAnalysis && this._buffer.toString('utf8', this._buffer.length - 128, this._buffer.length - 125) === 'TAG') {
|
|
158
125
|
this._buffer = this._buffer.slice(0, -128);
|
|
159
126
|
}
|
|
160
|
-
|
|
161
127
|
this._isFirstAnalysis = false;
|
|
162
128
|
return true;
|
|
163
129
|
}
|
|
164
|
-
|
|
165
130
|
}
|
|
166
|
-
|
|
167
131
|
exports.StripStream = StripStream;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _transformCallback = require("./transform-callback");
|
|
8
|
-
|
|
9
7
|
Object.keys(_transformCallback).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _transformCallback[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_transformCallback).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _writableCallback = require("./writable-callback");
|
|
21
|
-
|
|
22
18
|
Object.keys(_writableCallback).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _writableCallback[key]) return;
|
package/package.json
CHANGED
|
@@ -9,37 +9,37 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"synchsafe": "^6.0.
|
|
13
|
-
"tslib": "^2.4.
|
|
12
|
+
"synchsafe": "^6.0.20",
|
|
13
|
+
"tslib": "^2.4.1"
|
|
14
14
|
},
|
|
15
15
|
"description": "A tool to locate and strip metadata from files.",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.
|
|
18
|
-
"@babel/core": "^7.
|
|
19
|
-
"@babel/preset-env": "^7.
|
|
17
|
+
"@babel/cli": "^7.19.3",
|
|
18
|
+
"@babel/core": "^7.20.2",
|
|
19
|
+
"@babel/preset-env": "^7.20.2",
|
|
20
20
|
"@babel/register": "^7.18.9",
|
|
21
|
-
"@commitlint/cli": "^17.
|
|
22
|
-
"@commitlint/config-angular": "^17.
|
|
21
|
+
"@commitlint/cli": "^17.2.0",
|
|
22
|
+
"@commitlint/config-angular": "^17.2.0",
|
|
23
23
|
"chai": "^4.3.6",
|
|
24
24
|
"commitizen": "^4.2.5",
|
|
25
25
|
"cz-conventional-changelog": "^3.3.0",
|
|
26
|
-
"eslint": "^8.
|
|
26
|
+
"eslint": "^8.27.0",
|
|
27
27
|
"eslint-config-holy-grail": "^52.0.33",
|
|
28
28
|
"grunt": "^1.5.3",
|
|
29
29
|
"grunt-cli": "^1.4.3",
|
|
30
30
|
"grunt-sh": "^0.2.0",
|
|
31
31
|
"husky": "^8.0.1",
|
|
32
32
|
"load-grunt-config": "^4.0.1",
|
|
33
|
-
"mocha": "^10.
|
|
33
|
+
"mocha": "^10.1.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
35
|
"pretty-quick": "^3.1.3",
|
|
36
36
|
"rimraf": "^3.0.2",
|
|
37
|
-
"sinon": "^14.0.
|
|
37
|
+
"sinon": "^14.0.1",
|
|
38
38
|
"sinon-chai": "^3.7.0",
|
|
39
39
|
"tsconfig-holy-grail": "^11.1.36",
|
|
40
40
|
"tslint": "^6.1.3",
|
|
41
|
-
"tslint-config-holy-grail": "^53.2.
|
|
42
|
-
"typescript": "^4.8.
|
|
41
|
+
"tslint-config-holy-grail": "^53.2.34",
|
|
42
|
+
"typescript": "^4.8.4"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=12.20.1"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"test": "grunt lint && grunt test"
|
|
64
64
|
},
|
|
65
65
|
"types": "build/es2019/module.d.ts",
|
|
66
|
-
"version": "3.0.
|
|
66
|
+
"version": "3.0.21"
|
|
67
67
|
}
|