@editframe/api 0.12.0-beta.8 → 0.13.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/ProgressIterator.d.ts +1 -1
  2. package/dist/{api/src/ProgressIterator.js → ProgressIterator.js} +14 -2
  3. package/dist/StreamEventSource.d.ts +5 -3
  4. package/dist/{api/src/StreamEventSource.js → StreamEventSource.js} +0 -2
  5. package/dist/client.d.ts +1 -1
  6. package/dist/index.d.ts +13 -10
  7. package/dist/{api/src/index.js → index.js} +7 -5
  8. package/dist/node.d.ts +7 -0
  9. package/dist/node.js +98 -0
  10. package/dist/resources/caption-file.d.ts +32 -4
  11. package/dist/{api/src/resources → resources}/caption-file.js +9 -0
  12. package/dist/resources/image-file.d.ts +28 -10
  13. package/dist/{api/src/resources → resources}/image-file.js +18 -1
  14. package/dist/resources/isobmff-file.d.ts +25 -5
  15. package/dist/resources/isobmff-track.d.ts +497 -6
  16. package/dist/{api/src/resources → resources}/isobmff-track.js +24 -18
  17. package/dist/resources/process-isobmff.d.ts +2 -2
  18. package/dist/resources/renders.d.ts +27 -15
  19. package/dist/{api/src/resources → resources}/renders.js +21 -13
  20. package/dist/resources/transcriptions.d.ts +4 -3
  21. package/dist/resources/unprocessed-file.d.ts +11 -10
  22. package/dist/{api/src/resources → resources}/unprocessed-file.js +0 -33
  23. package/dist/resources/url-token.d.ts +1 -1
  24. package/dist/uploadChunks.d.ts +4 -1
  25. package/dist/utils/assertTypesMatch.d.ts +3 -0
  26. package/dist/utils/createReadableStreamFromReadable.d.ts +4 -0
  27. package/docs/packages/api/docs/.nojekyll +1 -0
  28. package/docs/packages/api/docs/assets/highlight.css +71 -0
  29. package/docs/packages/api/docs/assets/icons.js +18 -0
  30. package/docs/packages/api/docs/assets/icons.svg +1 -0
  31. package/docs/packages/api/docs/assets/main.js +60 -0
  32. package/docs/packages/api/docs/assets/navigation.js +1 -0
  33. package/docs/packages/api/docs/assets/search.js +1 -0
  34. package/docs/packages/api/docs/assets/style.css +1493 -0
  35. package/docs/packages/api/docs/classes/Client.html +4 -0
  36. package/docs/packages/api/docs/functions/createCaptionFile.html +8 -0
  37. package/docs/packages/api/docs/functions/createISOBMFFFile.html +1 -0
  38. package/docs/packages/api/docs/functions/createISOBMFFTrack.html +1 -0
  39. package/docs/packages/api/docs/functions/createImageFile.html +1 -0
  40. package/docs/packages/api/docs/functions/createRender.html +1 -0
  41. package/docs/packages/api/docs/functions/createTranscription.html +1 -0
  42. package/docs/packages/api/docs/functions/createURLToken.html +1 -0
  43. package/docs/packages/api/docs/functions/createUnprocessedFile.html +1 -0
  44. package/docs/packages/api/docs/functions/getISOBMFFFileTranscription.html +1 -0
  45. package/docs/packages/api/docs/functions/getIsobmffProcessInfo.html +1 -0
  46. package/docs/packages/api/docs/functions/getIsobmffProcessProgress.html +1 -0
  47. package/docs/packages/api/docs/functions/getTranscriptionInfo.html +1 -0
  48. package/docs/packages/api/docs/functions/getTranscriptionProgress.html +1 -0
  49. package/docs/packages/api/docs/functions/lookupCaptionFileByMd5.html +1 -0
  50. package/docs/packages/api/docs/functions/lookupISOBMFFFileByMd5.html +1 -0
  51. package/docs/packages/api/docs/functions/lookupImageFileByMd5.html +1 -0
  52. package/docs/packages/api/docs/functions/lookupRenderByMd5.html +1 -0
  53. package/docs/packages/api/docs/functions/lookupUnprocessedFileByMd5.html +1 -0
  54. package/docs/packages/api/docs/functions/processIsobmffFile.html +1 -0
  55. package/docs/packages/api/docs/functions/transcribeISOBMFFFile.html +1 -0
  56. package/docs/packages/api/docs/functions/uploadCaptionFile.html +1 -0
  57. package/docs/packages/api/docs/functions/uploadFragmentIndex.html +1 -0
  58. package/docs/packages/api/docs/functions/uploadISOBMFFTrack.html +1 -0
  59. package/docs/packages/api/docs/functions/uploadImageFile.html +1 -0
  60. package/docs/packages/api/docs/functions/uploadRender.html +1 -0
  61. package/docs/packages/api/docs/functions/uploadUnprocessedReadableStream.html +1 -0
  62. package/docs/packages/api/docs/index.html +39 -0
  63. package/docs/packages/api/docs/interfaces/CreateCaptionFileResult.html +4 -0
  64. package/docs/packages/api/docs/interfaces/CreateISOBMFFFileResult.html +5 -0
  65. package/docs/packages/api/docs/interfaces/CreateISOBMFFTrackResult.html +6 -0
  66. package/docs/packages/api/docs/interfaces/CreateImageFileResult.html +5 -0
  67. package/docs/packages/api/docs/interfaces/CreateRenderResult.html +4 -0
  68. package/docs/packages/api/docs/interfaces/CreateTranscriptionResult.html +3 -0
  69. package/docs/packages/api/docs/interfaces/CreateUnprocessedFileResult.html +6 -0
  70. package/docs/packages/api/docs/interfaces/GetISOBMFFFileTranscriptionResult.html +4 -0
  71. package/docs/packages/api/docs/interfaces/IsobmffProcessInfoResult.html +7 -0
  72. package/docs/packages/api/docs/interfaces/LookupCaptionFileByMd5Result.html +4 -0
  73. package/docs/packages/api/docs/interfaces/LookupISOBMFFFileByMd5Result.html +5 -0
  74. package/docs/packages/api/docs/interfaces/LookupImageFileByMd5Result.html +5 -0
  75. package/docs/packages/api/docs/interfaces/LookupRenderByMd5Result.html +4 -0
  76. package/docs/packages/api/docs/interfaces/LookupUnprocessedFileByMd5Result.html +6 -0
  77. package/docs/packages/api/docs/interfaces/ProcessIsobmffFileResult.html +2 -0
  78. package/docs/packages/api/docs/interfaces/TranscribeISOBMFFFileResult.html +4 -0
  79. package/docs/packages/api/docs/interfaces/TranscriptionInfoResult.html +3 -0
  80. package/docs/packages/api/docs/interfaces/URLTokenResult.html +2 -0
  81. package/docs/packages/api/docs/modules.html +54 -0
  82. package/docs/packages/api/docs/variables/CreateCaptionFilePayload.html +1 -0
  83. package/docs/packages/api/docs/variables/CreateISOBMFFFilePayload.html +1 -0
  84. package/docs/packages/api/docs/variables/CreateISOBMFFTrackPayload.html +1 -0
  85. package/docs/packages/api/docs/variables/CreateImageFilePayload.html +1 -0
  86. package/docs/packages/api/docs/variables/CreateRenderPayload.html +1 -0
  87. package/docs/packages/api/docs/variables/CreateTranscriptionPayload.html +1 -0
  88. package/docs/packages/api/docs/variables/CreateUnprocessedFilePayload.html +1 -0
  89. package/docs/packages/api/docs/variables/TranscribeISOBMFFFilePayload.html +1 -0
  90. package/package.json +12 -4
  91. package/src/resources/caption-file.test.ts +3 -3
  92. package/src/resources/caption-file.ts +31 -2
  93. package/src/resources/image-file.test.ts +3 -3
  94. package/src/resources/image-file.ts +23 -37
  95. package/src/resources/isobmff-file.test.ts +3 -3
  96. package/src/resources/isobmff-file.ts +27 -3
  97. package/src/resources/isobmff-track.test.ts +4 -4
  98. package/src/resources/isobmff-track.ts +147 -25
  99. package/src/resources/process-isobmff.test.ts +3 -3
  100. package/src/resources/process-isobmff.ts +2 -2
  101. package/src/resources/renders.test.ts +3 -18
  102. package/src/resources/renders.ts +44 -15
  103. package/src/resources/transcriptions.test.ts +2 -2
  104. package/src/resources/transcriptions.ts +7 -3
  105. package/src/resources/unprocessed-file.test.ts +3 -3
  106. package/src/resources/unprocessed-file.ts +20 -53
  107. package/src/resources/url-token.test.ts +3 -3
  108. package/src/resources/url-token.ts +1 -1
  109. package/src/utils/assertTypesMatch.ts +10 -0
  110. package/src/utils/createReadableStreamFromReadable.ts +117 -0
  111. /package/dist/{api/src/CHUNK_SIZE_BYTES.js → CHUNK_SIZE_BYTES.js} +0 -0
  112. /package/dist/{api/src/client.js → client.js} +0 -0
  113. /package/dist/{api/src/resources → resources}/isobmff-file.js +0 -0
  114. /package/dist/{api/src/resources → resources}/process-isobmff.js +0 -0
  115. /package/dist/{api/src/resources → resources}/transcriptions.js +0 -0
  116. /package/dist/{api/src/resources → resources}/url-token.js +0 -0
  117. /package/dist/{api/src/streamChunker.js → streamChunker.js} +0 -0
  118. /package/dist/{api/src/uploadChunks.js → uploadChunks.js} +0 -0
  119. /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