Add .gitignore to exclude all node packages and lock files

This commit is contained in:
Adolfo Reyna
2026-02-23 21:56:04 -05:00
parent faae96c9ed
commit dcc5c6c044
9747 changed files with 1555105 additions and 2 deletions
@@ -0,0 +1,126 @@
// src/is-network-error.ts
function isNetworkError(error) {
if (error.message.includes("Failed to fetch") || error.message.includes("Load failed") || error.message.includes("NetworkError when attempting to fetch resource")) {
return true;
}
return false;
}
// src/register-usage-event.ts
var HOST = "https://www.remotion.pro";
var DEFAULT_MAX_RETRIES = 3;
var exponentialBackoffMs = (attempt) => {
return 1000 * 2 ** (attempt - 1);
};
var sleep = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
var internalRegisterUsageEvent = async ({
host,
succeeded,
event,
isStill,
isProduction,
licenseKey
}) => {
let lastError;
const totalAttempts = DEFAULT_MAX_RETRIES + 1;
for (let attempt = 1;attempt <= totalAttempts; attempt++) {
const abortController = new AbortController;
const timeout = setTimeout(() => {
abortController.abort();
}, 1e4);
try {
const res = await fetch(`${HOST}/api/track/register-usage-point`, {
method: "POST",
body: JSON.stringify({
event,
apiKey: licenseKey,
host,
succeeded,
isStill,
isProduction
}),
headers: {
"Content-Type": "application/json"
},
signal: abortController.signal
});
clearTimeout(timeout);
const json = await res.json();
if (json.success) {
return {
billable: json.billable,
classification: json.classification
};
}
if (!res.ok) {
throw new Error(json.error);
}
throw new Error(`Unexpected response from server: ${JSON.stringify(json)}`);
} catch (err) {
clearTimeout(timeout);
const error = err;
const isTimeout = error.name === "AbortError";
const isRetryable = isNetworkError(error) || isTimeout;
if (!isRetryable) {
throw err;
}
lastError = isTimeout ? new Error("Request timed out after 10 seconds") : error;
if (attempt < totalAttempts) {
const backoffMs = exponentialBackoffMs(attempt);
console.log(`Failed to send usage event (attempt ${attempt}/${totalAttempts}), retrying in ${backoffMs}ms...`, err);
await sleep(backoffMs);
}
}
}
throw lastError;
};
var registerUsageEvent = (options) => {
const licenseKey = "licenseKey" in options ? options.licenseKey : null;
const apiKey = "apiKey" in options ? options.apiKey : null;
return internalRegisterUsageEvent({
...options,
isStill: options.isStill ?? false,
isProduction: options.isProduction ?? true,
licenseKey: licenseKey ?? apiKey ?? null
});
};
// src/get-usage.ts
var getUsage = async ({
since,
...apiOrLicenseKey
}) => {
const apiKey = "apiKey" in apiOrLicenseKey ? apiOrLicenseKey.apiKey : null;
const licenseKey = "licenseKey" in apiOrLicenseKey ? apiOrLicenseKey.licenseKey : null;
const res = await fetch(`${HOST}/api/track/get-usage`, {
method: "POST",
body: JSON.stringify({
apiKey: licenseKey ?? apiKey,
since: since ?? null
}),
headers: {
"Content-Type": "application/json"
}
});
const json = await res.json();
if (json.success) {
return {
cloudRenders: json.cloudRenders,
webcodecConversions: json.webcodecConversions
};
}
throw new Error(json.error);
};
// src/index.ts
var LicensingInternals = {
internalRegisterUsageEvent
};
export {
registerUsageEvent,
getUsage,
LicensingInternals
};