@ziplayer/plugin 0.1.41 → 0.1.50
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/README.md +38 -2
- package/dist/AttachmentsPlugin.d.ts +192 -0
- package/dist/AttachmentsPlugin.d.ts.map +1 -0
- package/dist/AttachmentsPlugin.js +481 -0
- package/dist/AttachmentsPlugin.js.map +1 -0
- package/dist/TTSPlugin.d.ts +17 -0
- package/dist/TTSPlugin.d.ts.map +1 -1
- package/dist/TTSPlugin.js +68 -7
- package/dist/TTSPlugin.js.map +1 -1
- package/dist/index.d.ts +27 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/AttachmentsPlugin.ts +523 -0
- package/src/TTSPlugin.ts +79 -7
- package/src/index.ts +28 -5
- package/src/utils/stream-converter.ts +79 -79
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { Readable } from "stream";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Converts a Web ReadableStream to a Node.js Readable stream
|
|
5
|
-
*/
|
|
6
|
-
export function webStreamToNodeStream(webStream: ReadableStream): Readable {
|
|
7
|
-
const nodeStream = new Readable({
|
|
8
|
-
read() {
|
|
9
|
-
// This will be handled by the Web Stream reader
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Create a reader from the Web Stream
|
|
14
|
-
const reader = webStream.getReader();
|
|
15
|
-
|
|
16
|
-
// Read chunks and push to Node.js stream
|
|
17
|
-
const pump = async () => {
|
|
18
|
-
try {
|
|
19
|
-
while (true) {
|
|
20
|
-
const { done, value } = await reader.read();
|
|
21
|
-
if (done) {
|
|
22
|
-
nodeStream.push(null); // End the stream
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
nodeStream.push(Buffer.from(value));
|
|
26
|
-
}
|
|
27
|
-
} catch (error) {
|
|
28
|
-
nodeStream.destroy(error as Error);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Start pumping data
|
|
33
|
-
pump();
|
|
34
|
-
|
|
35
|
-
return nodeStream;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Converts a Web ReadableStream to a Node.js Readable stream with progress tracking
|
|
40
|
-
*/
|
|
41
|
-
export function webStreamToNodeStreamWithProgress(
|
|
42
|
-
webStream: ReadableStream,
|
|
43
|
-
progressCallback?: (bytesRead: number) => void,
|
|
44
|
-
): Readable {
|
|
45
|
-
const nodeStream = new Readable({
|
|
46
|
-
read() {
|
|
47
|
-
// This will be handled by the Web Stream reader
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
let bytesRead = 0;
|
|
52
|
-
const reader = webStream.getReader();
|
|
53
|
-
|
|
54
|
-
const pump = async () => {
|
|
55
|
-
try {
|
|
56
|
-
while (true) {
|
|
57
|
-
const { done, value } = await reader.read();
|
|
58
|
-
if (done) {
|
|
59
|
-
nodeStream.push(null); // End the stream
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const buffer = Buffer.from(value);
|
|
64
|
-
nodeStream.push(buffer);
|
|
65
|
-
|
|
66
|
-
bytesRead += buffer.length;
|
|
67
|
-
if (progressCallback) {
|
|
68
|
-
progressCallback(bytesRead);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
nodeStream.destroy(error as Error);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
pump();
|
|
77
|
-
|
|
78
|
-
return nodeStream;
|
|
79
|
-
}
|
|
1
|
+
import { Readable } from "stream";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a Web ReadableStream to a Node.js Readable stream
|
|
5
|
+
*/
|
|
6
|
+
export function webStreamToNodeStream(webStream: ReadableStream): Readable {
|
|
7
|
+
const nodeStream = new Readable({
|
|
8
|
+
read() {
|
|
9
|
+
// This will be handled by the Web Stream reader
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Create a reader from the Web Stream
|
|
14
|
+
const reader = webStream.getReader();
|
|
15
|
+
|
|
16
|
+
// Read chunks and push to Node.js stream
|
|
17
|
+
const pump = async () => {
|
|
18
|
+
try {
|
|
19
|
+
while (true) {
|
|
20
|
+
const { done, value } = await reader.read();
|
|
21
|
+
if (done) {
|
|
22
|
+
nodeStream.push(null); // End the stream
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
nodeStream.push(Buffer.from(value));
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
nodeStream.destroy(error as Error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Start pumping data
|
|
33
|
+
pump();
|
|
34
|
+
|
|
35
|
+
return nodeStream;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts a Web ReadableStream to a Node.js Readable stream with progress tracking
|
|
40
|
+
*/
|
|
41
|
+
export function webStreamToNodeStreamWithProgress(
|
|
42
|
+
webStream: ReadableStream,
|
|
43
|
+
progressCallback?: (bytesRead: number) => void,
|
|
44
|
+
): Readable {
|
|
45
|
+
const nodeStream = new Readable({
|
|
46
|
+
read() {
|
|
47
|
+
// This will be handled by the Web Stream reader
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
let bytesRead = 0;
|
|
52
|
+
const reader = webStream.getReader();
|
|
53
|
+
|
|
54
|
+
const pump = async () => {
|
|
55
|
+
try {
|
|
56
|
+
while (true) {
|
|
57
|
+
const { done, value } = await reader.read();
|
|
58
|
+
if (done) {
|
|
59
|
+
nodeStream.push(null); // End the stream
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const buffer = Buffer.from(value);
|
|
64
|
+
nodeStream.push(buffer);
|
|
65
|
+
|
|
66
|
+
bytesRead += buffer.length;
|
|
67
|
+
if (progressCallback) {
|
|
68
|
+
progressCallback(bytesRead);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
nodeStream.destroy(error as Error);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
pump();
|
|
77
|
+
|
|
78
|
+
return nodeStream;
|
|
79
|
+
}
|