Add .gitignore to exclude all node packages and lock files
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
# @remotion/streaming
|
||||
|
||||
Utilities for streaming data between programs
|
||||
|
||||
## Usage
|
||||
|
||||
This is an internal package and has no documentation.
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
// src/make-stream-payload-message.ts
|
||||
var magicWordStr = "remotion_buffer:";
|
||||
var makeStreamPayloadMessage = ({
|
||||
status,
|
||||
body,
|
||||
nonce
|
||||
}) => {
|
||||
const nonceArr = new TextEncoder().encode(nonce);
|
||||
const magicWordArr = new TextEncoder().encode(magicWordStr);
|
||||
const separatorArr = new TextEncoder().encode(":");
|
||||
const bodyLengthArr = new TextEncoder().encode(body.length.toString());
|
||||
const statusArr = new TextEncoder().encode(String(status));
|
||||
const totalLength = nonceArr.length + magicWordArr.length + separatorArr.length * 3 + bodyLengthArr.length + statusArr.length + body.length;
|
||||
const concat = new Uint8Array(totalLength);
|
||||
let offset = 0;
|
||||
const appendToConcat = (data) => {
|
||||
concat.set(data, offset);
|
||||
offset += data.length;
|
||||
};
|
||||
appendToConcat(magicWordArr);
|
||||
appendToConcat(nonceArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(bodyLengthArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(statusArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(body);
|
||||
return concat;
|
||||
};
|
||||
// src/make-streamer.ts
|
||||
var streamingKey = "remotion_buffer:";
|
||||
var makeStreamer = (onMessage) => {
|
||||
const separator = new Uint8Array(streamingKey.length);
|
||||
for (let i = 0;i < streamingKey.length; i++) {
|
||||
separator[i] = streamingKey.charCodeAt(i);
|
||||
}
|
||||
let unprocessedBuffers = [];
|
||||
let outputBuffer = new Uint8Array(0);
|
||||
let missingData = null;
|
||||
const findSeparatorIndex = () => {
|
||||
let searchIndex = 0;
|
||||
while (true) {
|
||||
const separatorIndex = outputBuffer.indexOf(separator[0], searchIndex);
|
||||
if (separatorIndex === -1) {
|
||||
return -1;
|
||||
}
|
||||
if (outputBuffer.subarray(separatorIndex, separatorIndex + separator.length).toString() !== separator.toString()) {
|
||||
searchIndex = separatorIndex + 1;
|
||||
continue;
|
||||
}
|
||||
return separatorIndex;
|
||||
}
|
||||
};
|
||||
const processInput = () => {
|
||||
let separatorIndex = findSeparatorIndex();
|
||||
if (separatorIndex === -1) {
|
||||
return;
|
||||
}
|
||||
separatorIndex += separator.length;
|
||||
let nonceString = "";
|
||||
let lengthString = "";
|
||||
let statusString = "";
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
separatorIndex++;
|
||||
if (nextDigit === 58) {
|
||||
break;
|
||||
}
|
||||
nonceString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
separatorIndex++;
|
||||
if (nextDigit === 58) {
|
||||
break;
|
||||
}
|
||||
lengthString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
if (nextDigit === 58) {
|
||||
break;
|
||||
}
|
||||
separatorIndex++;
|
||||
statusString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
const length = Number(lengthString);
|
||||
const status = Number(statusString);
|
||||
const dataLength = outputBuffer.length - separatorIndex - 1;
|
||||
if (dataLength < length) {
|
||||
missingData = {
|
||||
dataMissing: length - dataLength
|
||||
};
|
||||
return;
|
||||
}
|
||||
const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
|
||||
onMessage(status === 1 ? "error" : "success", nonceString, data);
|
||||
missingData = null;
|
||||
outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
|
||||
processInput();
|
||||
};
|
||||
const onData = (data) => {
|
||||
unprocessedBuffers.push(data);
|
||||
if (missingData) {
|
||||
missingData.dataMissing -= data.length;
|
||||
}
|
||||
if (missingData && missingData.dataMissing > 0) {
|
||||
return;
|
||||
}
|
||||
const newBuffer = new Uint8Array(outputBuffer.length + unprocessedBuffers.reduce((acc, val) => acc + val.length, 0));
|
||||
newBuffer.set(outputBuffer, 0);
|
||||
let offset = outputBuffer.length;
|
||||
for (const buf of unprocessedBuffers) {
|
||||
newBuffer.set(buf, offset);
|
||||
offset += buf.length;
|
||||
}
|
||||
outputBuffer = newBuffer;
|
||||
unprocessedBuffers = [];
|
||||
processInput();
|
||||
};
|
||||
return {
|
||||
onData,
|
||||
getOutputBuffer: () => outputBuffer,
|
||||
clear: () => {
|
||||
unprocessedBuffers = [];
|
||||
outputBuffer = new Uint8Array(0);
|
||||
}
|
||||
};
|
||||
};
|
||||
export {
|
||||
makeStreamer,
|
||||
makeStreamPayloadMessage
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { makeStreamPayloadMessage } from './make-stream-payload-message';
|
||||
export { makeStreamer } from './make-streamer';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeStreamer = exports.makeStreamPayloadMessage = void 0;
|
||||
var make_stream_payload_message_1 = require("./make-stream-payload-message");
|
||||
Object.defineProperty(exports, "makeStreamPayloadMessage", { enumerable: true, get: function () { return make_stream_payload_message_1.makeStreamPayloadMessage; } });
|
||||
var make_streamer_1 = require("./make-streamer");
|
||||
Object.defineProperty(exports, "makeStreamer", { enumerable: true, get: function () { return make_streamer_1.makeStreamer; } });
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export declare const magicWordStr = "remotion_buffer:";
|
||||
export declare const makeStreamPayloadMessage: ({ status, body, nonce, }: {
|
||||
nonce: string;
|
||||
status: 0 | 1;
|
||||
body: Uint8Array;
|
||||
}) => Uint8Array;
|
||||
Generated
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeStreamPayloadMessage = exports.magicWordStr = void 0;
|
||||
exports.magicWordStr = 'remotion_buffer:';
|
||||
const makeStreamPayloadMessage = ({ status, body, nonce, }) => {
|
||||
const nonceArr = new TextEncoder().encode(nonce);
|
||||
const magicWordArr = new TextEncoder().encode(exports.magicWordStr);
|
||||
const separatorArr = new TextEncoder().encode(':');
|
||||
const bodyLengthArr = new TextEncoder().encode(body.length.toString());
|
||||
const statusArr = new TextEncoder().encode(String(status));
|
||||
// Calculate total length of new Uint8Array
|
||||
const totalLength = nonceArr.length +
|
||||
magicWordArr.length +
|
||||
separatorArr.length * 3 +
|
||||
bodyLengthArr.length +
|
||||
statusArr.length +
|
||||
body.length;
|
||||
// Create a new Uint8Array to hold all combined parts
|
||||
const concat = new Uint8Array(totalLength);
|
||||
let offset = 0;
|
||||
// Function to append data to concat
|
||||
const appendToConcat = (data) => {
|
||||
concat.set(data, offset);
|
||||
offset += data.length;
|
||||
};
|
||||
// Building the final Uint8Array
|
||||
appendToConcat(magicWordArr);
|
||||
appendToConcat(nonceArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(bodyLengthArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(statusArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(body);
|
||||
return concat;
|
||||
};
|
||||
exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
export declare const streamingKey = "remotion_buffer:";
|
||||
export declare const makeStreamer: (onMessage: (statusType: "success" | "error", nonce: string, data: Uint8Array) => void) => {
|
||||
onData: (data: Uint8Array) => void;
|
||||
getOutputBuffer: () => Uint8Array<ArrayBuffer>;
|
||||
clear: () => void;
|
||||
};
|
||||
export declare const makeStreamPayloadMessage: ({ status, body, nonce, }: {
|
||||
nonce: string;
|
||||
status: 0 | 1;
|
||||
body: Uint8Array;
|
||||
}) => Uint8Array;
|
||||
Generated
Vendored
+148
@@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeStreamPayloadMessage = exports.makeStreamer = exports.streamingKey = void 0;
|
||||
exports.streamingKey = 'remotion_buffer:';
|
||||
const makeStreamer = (onMessage) => {
|
||||
const separator = new Uint8Array(exports.streamingKey.length);
|
||||
for (let i = 0; i < exports.streamingKey.length; i++) {
|
||||
separator[i] = exports.streamingKey.charCodeAt(i);
|
||||
}
|
||||
let unprocessedBuffers = [];
|
||||
let outputBuffer = new Uint8Array(0);
|
||||
let missingData = null;
|
||||
const findSeparatorIndex = () => {
|
||||
let searchIndex = 0;
|
||||
while (true) {
|
||||
const separatorIndex = outputBuffer.indexOf(separator[0], searchIndex); // Start checking for the first byte of the separator
|
||||
if (separatorIndex === -1) {
|
||||
return -1;
|
||||
}
|
||||
if (outputBuffer
|
||||
.subarray(separatorIndex, separatorIndex + separator.length)
|
||||
.toString() !== separator.toString()) {
|
||||
searchIndex = separatorIndex + 1;
|
||||
continue;
|
||||
}
|
||||
return separatorIndex;
|
||||
}
|
||||
};
|
||||
const processInput = () => {
|
||||
let separatorIndex = findSeparatorIndex(); // Start checking for the first byte of the separator
|
||||
if (separatorIndex === -1) {
|
||||
return;
|
||||
}
|
||||
separatorIndex += separator.length;
|
||||
let nonceString = '';
|
||||
let lengthString = '';
|
||||
let statusString = '';
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
separatorIndex++;
|
||||
if (nextDigit === 0x3a) {
|
||||
break;
|
||||
}
|
||||
nonceString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
separatorIndex++;
|
||||
if (nextDigit === 0x3a) {
|
||||
break;
|
||||
}
|
||||
lengthString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
while (true) {
|
||||
if (separatorIndex > outputBuffer.length - 1) {
|
||||
return;
|
||||
}
|
||||
const nextDigit = outputBuffer[separatorIndex];
|
||||
if (nextDigit === 0x3a) {
|
||||
break;
|
||||
}
|
||||
separatorIndex++;
|
||||
statusString += String.fromCharCode(nextDigit);
|
||||
}
|
||||
const length = Number(lengthString);
|
||||
const status = Number(statusString);
|
||||
const dataLength = outputBuffer.length - separatorIndex - 1;
|
||||
if (dataLength < length) {
|
||||
missingData = {
|
||||
dataMissing: length - dataLength,
|
||||
};
|
||||
return;
|
||||
}
|
||||
const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
|
||||
onMessage(status === 1 ? 'error' : 'success', nonceString, data);
|
||||
missingData = null;
|
||||
outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
|
||||
processInput();
|
||||
};
|
||||
const onData = (data) => {
|
||||
unprocessedBuffers.push(data);
|
||||
if (missingData) {
|
||||
missingData.dataMissing -= data.length;
|
||||
}
|
||||
if (missingData && missingData.dataMissing > 0) {
|
||||
return;
|
||||
}
|
||||
const newBuffer = new Uint8Array(outputBuffer.length +
|
||||
unprocessedBuffers.reduce((acc, val) => acc + val.length, 0));
|
||||
newBuffer.set(outputBuffer, 0);
|
||||
let offset = outputBuffer.length;
|
||||
for (const buf of unprocessedBuffers) {
|
||||
newBuffer.set(buf, offset);
|
||||
offset += buf.length;
|
||||
}
|
||||
outputBuffer = newBuffer;
|
||||
unprocessedBuffers = [];
|
||||
processInput();
|
||||
};
|
||||
return {
|
||||
onData,
|
||||
getOutputBuffer: () => outputBuffer,
|
||||
clear: () => {
|
||||
unprocessedBuffers = [];
|
||||
outputBuffer = new Uint8Array(0);
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.makeStreamer = makeStreamer;
|
||||
const makeStreamPayloadMessage = ({ status, body, nonce, }) => {
|
||||
const nonceArr = new TextEncoder().encode(nonce);
|
||||
const magicWordArr = new TextEncoder().encode(exports.streamingKey);
|
||||
const separatorArr = new TextEncoder().encode(':');
|
||||
const bodyLengthArr = new TextEncoder().encode(body.length.toString());
|
||||
const statusArr = new TextEncoder().encode(String(status));
|
||||
// Calculate total length of new Uint8Array
|
||||
const totalLength = nonceArr.length +
|
||||
magicWordArr.length +
|
||||
separatorArr.length * 3 +
|
||||
bodyLengthArr.length +
|
||||
statusArr.length +
|
||||
body.length;
|
||||
// Create a new Uint8Array to hold all combined parts
|
||||
const concat = new Uint8Array(totalLength);
|
||||
let offset = 0;
|
||||
// Function to append data to concat
|
||||
const appendToConcat = (data) => {
|
||||
concat.set(data, offset);
|
||||
offset += data.length;
|
||||
};
|
||||
// Building the final Uint8Array
|
||||
appendToConcat(magicWordArr);
|
||||
appendToConcat(nonceArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(bodyLengthArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(statusArr);
|
||||
appendToConcat(separatorArr);
|
||||
appendToConcat(body);
|
||||
return concat;
|
||||
};
|
||||
exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"repository": {
|
||||
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/streaming"
|
||||
},
|
||||
"name": "@remotion/streaming",
|
||||
"version": "4.0.423",
|
||||
"description": "Utilities for streaming data between programs",
|
||||
"main": "dist",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"lint": "eslint src",
|
||||
"formatting": "prettier --experimental-cli src --check",
|
||||
"make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
|
||||
},
|
||||
"author": "Jonny Burger <jonny@remotion.dev>",
|
||||
"contributors": [],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/remotion-dev/remotion/issues"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@remotion/eslint-config-internal": "4.0.423",
|
||||
"eslint": "9.19.0"
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.js",
|
||||
"module": "./dist/esm/index.mjs",
|
||||
"import": "./dist/esm/index.mjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user