@editframe/api 0.12.0-beta.6 → 0.13.0-beta.1
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/ProgressIterator.d.ts +1 -1
- package/dist/{api/src/ProgressIterator.js → ProgressIterator.js} +14 -2
- package/dist/StreamEventSource.d.ts +5 -3
- package/dist/{api/src/StreamEventSource.js → StreamEventSource.js} +0 -2
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +14 -10
- package/dist/{api/src/index.js → index.js} +10 -7
- package/dist/node.d.ts +6 -0
- package/dist/node.js +98 -0
- package/dist/resources/caption-file.d.ts +32 -4
- package/dist/{api/src/resources → resources}/caption-file.js +9 -0
- package/dist/resources/image-file.d.ts +28 -10
- package/dist/{api/src/resources → resources}/image-file.js +18 -21
- package/dist/resources/isobmff-file.d.ts +25 -5
- package/dist/resources/isobmff-track.d.ts +497 -6
- package/dist/{api/src/resources → resources}/isobmff-track.js +24 -18
- package/dist/resources/process-isobmff.d.ts +2 -2
- package/dist/resources/renders.d.ts +27 -15
- package/dist/{api/src/resources → resources}/renders.js +21 -13
- package/dist/resources/transcriptions.d.ts +4 -3
- package/dist/resources/unprocessed-file.d.ts +11 -10
- package/dist/{api/src/resources → resources}/unprocessed-file.js +0 -25
- package/dist/resources/url-token.d.ts +1 -1
- package/dist/uploadChunks.d.ts +4 -1
- package/dist/utils/assertTypesMatch.d.ts +3 -0
- package/dist/utils/createReadableStreamFromReadable.d.ts +4 -0
- package/docs/packages/api/docs/.nojekyll +1 -0
- package/docs/packages/api/docs/assets/highlight.css +71 -0
- package/docs/packages/api/docs/assets/icons.js +18 -0
- package/docs/packages/api/docs/assets/icons.svg +1 -0
- package/docs/packages/api/docs/assets/main.js +60 -0
- package/docs/packages/api/docs/assets/navigation.js +1 -0
- package/docs/packages/api/docs/assets/search.js +1 -0
- package/docs/packages/api/docs/assets/style.css +1493 -0
- package/docs/packages/api/docs/classes/Client.html +4 -0
- package/docs/packages/api/docs/functions/createCaptionFile.html +8 -0
- package/docs/packages/api/docs/functions/createISOBMFFFile.html +1 -0
- package/docs/packages/api/docs/functions/createISOBMFFTrack.html +1 -0
- package/docs/packages/api/docs/functions/createImageFile.html +1 -0
- package/docs/packages/api/docs/functions/createRender.html +1 -0
- package/docs/packages/api/docs/functions/createTranscription.html +1 -0
- package/docs/packages/api/docs/functions/createURLToken.html +1 -0
- package/docs/packages/api/docs/functions/createUnprocessedFile.html +1 -0
- package/docs/packages/api/docs/functions/getISOBMFFFileTranscription.html +1 -0
- package/docs/packages/api/docs/functions/getIsobmffProcessInfo.html +1 -0
- package/docs/packages/api/docs/functions/getIsobmffProcessProgress.html +1 -0
- package/docs/packages/api/docs/functions/getTranscriptionInfo.html +1 -0
- package/docs/packages/api/docs/functions/getTranscriptionProgress.html +1 -0
- package/docs/packages/api/docs/functions/lookupCaptionFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupISOBMFFFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupImageFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupRenderByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupUnprocessedFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/processIsobmffFile.html +1 -0
- package/docs/packages/api/docs/functions/transcribeISOBMFFFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadCaptionFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadFragmentIndex.html +1 -0
- package/docs/packages/api/docs/functions/uploadISOBMFFTrack.html +1 -0
- package/docs/packages/api/docs/functions/uploadImageFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadRender.html +1 -0
- package/docs/packages/api/docs/functions/uploadUnprocessedReadableStream.html +1 -0
- package/docs/packages/api/docs/index.html +39 -0
- package/docs/packages/api/docs/interfaces/CreateCaptionFileResult.html +4 -0
- package/docs/packages/api/docs/interfaces/CreateISOBMFFFileResult.html +5 -0
- package/docs/packages/api/docs/interfaces/CreateISOBMFFTrackResult.html +6 -0
- package/docs/packages/api/docs/interfaces/CreateImageFileResult.html +5 -0
- package/docs/packages/api/docs/interfaces/CreateRenderResult.html +4 -0
- package/docs/packages/api/docs/interfaces/CreateTranscriptionResult.html +3 -0
- package/docs/packages/api/docs/interfaces/CreateUnprocessedFileResult.html +6 -0
- package/docs/packages/api/docs/interfaces/GetISOBMFFFileTranscriptionResult.html +4 -0
- package/docs/packages/api/docs/interfaces/IsobmffProcessInfoResult.html +7 -0
- package/docs/packages/api/docs/interfaces/LookupCaptionFileByMd5Result.html +4 -0
- package/docs/packages/api/docs/interfaces/LookupISOBMFFFileByMd5Result.html +5 -0
- package/docs/packages/api/docs/interfaces/LookupImageFileByMd5Result.html +5 -0
- package/docs/packages/api/docs/interfaces/LookupRenderByMd5Result.html +4 -0
- package/docs/packages/api/docs/interfaces/LookupUnprocessedFileByMd5Result.html +6 -0
- package/docs/packages/api/docs/interfaces/ProcessIsobmffFileResult.html +2 -0
- package/docs/packages/api/docs/interfaces/TranscribeISOBMFFFileResult.html +4 -0
- package/docs/packages/api/docs/interfaces/TranscriptionInfoResult.html +3 -0
- package/docs/packages/api/docs/interfaces/URLTokenResult.html +2 -0
- package/docs/packages/api/docs/modules.html +54 -0
- package/docs/packages/api/docs/variables/CreateCaptionFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateISOBMFFFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateISOBMFFTrackPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateImageFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateRenderPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateTranscriptionPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateUnprocessedFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/TranscribeISOBMFFFilePayload.html +1 -0
- package/package.json +12 -4
- package/src/resources/caption-file.test.ts +3 -3
- package/src/resources/caption-file.ts +31 -2
- package/src/resources/image-file.test.ts +3 -3
- package/src/resources/image-file.ts +23 -28
- package/src/resources/isobmff-file.test.ts +3 -3
- package/src/resources/isobmff-file.ts +27 -3
- package/src/resources/isobmff-track.test.ts +4 -4
- package/src/resources/isobmff-track.ts +147 -25
- package/src/resources/process-isobmff.test.ts +3 -3
- package/src/resources/process-isobmff.ts +2 -2
- package/src/resources/renders.test.ts +3 -18
- package/src/resources/renders.ts +44 -15
- package/src/resources/transcriptions.test.ts +2 -2
- package/src/resources/transcriptions.ts +7 -3
- package/src/resources/unprocessed-file.test.ts +3 -3
- package/src/resources/unprocessed-file.ts +20 -41
- package/src/resources/url-token.test.ts +3 -3
- package/src/resources/url-token.ts +1 -1
- package/src/utils/assertTypesMatch.ts +10 -0
- package/src/utils/createReadableStreamFromReadable.ts +117 -0
- /package/dist/{api/src/CHUNK_SIZE_BYTES.js → CHUNK_SIZE_BYTES.js} +0 -0
- /package/dist/{api/src/client.js → client.js} +0 -0
- /package/dist/{api/src/resources → resources}/isobmff-file.js +0 -0
- /package/dist/{api/src/resources → resources}/process-isobmff.js +0 -0
- /package/dist/{api/src/resources → resources}/transcriptions.js +0 -0
- /package/dist/{api/src/resources → resources}/url-token.js +0 -0
- /package/dist/{api/src/streamChunker.js → streamChunker.js} +0 -0
- /package/dist/{api/src/uploadChunks.js → uploadChunks.js} +0 -0
- /package/dist/{cli/src/utils → utils}/createReadableStreamFromReadable.js +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type Readable, Stream } from "node:stream";
|
|
2
|
+
|
|
3
|
+
export const createReadableStreamFromReadable = (
|
|
4
|
+
source: Readable & { readableHighWaterMark?: number },
|
|
5
|
+
) => {
|
|
6
|
+
const pump = new StreamPump(source);
|
|
7
|
+
const stream = new ReadableStream(pump, pump);
|
|
8
|
+
return stream;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
class StreamPump {
|
|
12
|
+
public highWaterMark: number;
|
|
13
|
+
public accumalatedSize: number;
|
|
14
|
+
private stream: Stream & {
|
|
15
|
+
readableHighWaterMark?: number;
|
|
16
|
+
readable?: boolean;
|
|
17
|
+
resume?: () => void;
|
|
18
|
+
pause?: () => void;
|
|
19
|
+
destroy?: (error?: Error) => void;
|
|
20
|
+
};
|
|
21
|
+
private controller?: ReadableStreamController<Uint8Array>;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
stream: Stream & {
|
|
25
|
+
readableHighWaterMark?: number;
|
|
26
|
+
readable?: boolean;
|
|
27
|
+
resume?: () => void;
|
|
28
|
+
pause?: () => void;
|
|
29
|
+
destroy?: (error?: Error) => void;
|
|
30
|
+
},
|
|
31
|
+
) {
|
|
32
|
+
this.highWaterMark =
|
|
33
|
+
stream.readableHighWaterMark ||
|
|
34
|
+
new Stream.Readable().readableHighWaterMark;
|
|
35
|
+
this.accumalatedSize = 0;
|
|
36
|
+
this.stream = stream;
|
|
37
|
+
this.enqueue = this.enqueue.bind(this);
|
|
38
|
+
this.error = this.error.bind(this);
|
|
39
|
+
this.close = this.close.bind(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
size(chunk: Uint8Array) {
|
|
43
|
+
return chunk?.byteLength || 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
start(controller: ReadableStreamController<Uint8Array>) {
|
|
47
|
+
this.controller = controller;
|
|
48
|
+
this.stream.on("data", this.enqueue);
|
|
49
|
+
this.stream.once("error", this.error);
|
|
50
|
+
this.stream.once("end", this.close);
|
|
51
|
+
this.stream.once("close", this.close);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pull() {
|
|
55
|
+
this.resume();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
cancel(reason?: Error) {
|
|
59
|
+
if (this.stream.destroy) {
|
|
60
|
+
this.stream.destroy(reason);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.stream.off("data", this.enqueue);
|
|
64
|
+
this.stream.off("error", this.error);
|
|
65
|
+
this.stream.off("end", this.close);
|
|
66
|
+
this.stream.off("close", this.close);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
enqueue(chunk: Uint8Array | string) {
|
|
70
|
+
if (this.controller) {
|
|
71
|
+
try {
|
|
72
|
+
const bytes = chunk instanceof Uint8Array ? chunk : Buffer.from(chunk);
|
|
73
|
+
|
|
74
|
+
const available = (this.controller.desiredSize || 0) - bytes.byteLength;
|
|
75
|
+
this.controller.enqueue(bytes);
|
|
76
|
+
if (available <= 0) {
|
|
77
|
+
this.pause();
|
|
78
|
+
}
|
|
79
|
+
} catch (error: any) {
|
|
80
|
+
this.controller.error(
|
|
81
|
+
new Error(
|
|
82
|
+
"Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object",
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
this.cancel();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pause() {
|
|
91
|
+
if (this.stream.pause) {
|
|
92
|
+
this.stream.pause();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
resume() {
|
|
97
|
+
if (this.stream.readable && this.stream.resume) {
|
|
98
|
+
this.stream.resume();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
close() {
|
|
103
|
+
if (this.controller) {
|
|
104
|
+
this.controller.close();
|
|
105
|
+
// biome-ignore lint/performance/noDelete: infrequent use
|
|
106
|
+
delete this.controller;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
error(error: Error) {
|
|
111
|
+
if (this.controller) {
|
|
112
|
+
this.controller.error(error);
|
|
113
|
+
// biome-ignore lint/performance/noDelete: infrequent use
|
|
114
|
+
delete this.controller;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|