@remotion/licensing 4.0.397 → 4.0.399
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/esm/index.mjs +18 -6
- package/dist/get-usage.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/is-network-error.d.ts +1 -0
- package/dist/is-network-error.js +15 -0
- package/dist/register-usage-event.d.ts +24 -0
- package/dist/register-usage-event.js +52 -0
- package/package.json +4 -3
package/dist/esm/index.mjs
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/is-network-error.ts
|
|
2
|
+
function isNetworkError(error) {
|
|
3
|
+
if (error.message.includes("Failed to fetch") || error.message.includes("Load failed") || error.message.includes("NetworkError when attempting to fetch resource")) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/register-usage-event.ts
|
|
2
10
|
var HOST = "https://www.remotion.pro";
|
|
3
11
|
var registerUsageEvent = async ({
|
|
4
|
-
apiKey,
|
|
5
12
|
host,
|
|
6
13
|
succeeded,
|
|
7
|
-
event
|
|
14
|
+
event,
|
|
15
|
+
...apiOrLicenseKey
|
|
8
16
|
}) => {
|
|
9
17
|
const abortController = new AbortController;
|
|
10
18
|
const timeout = setTimeout(() => {
|
|
11
19
|
abortController.abort();
|
|
12
20
|
}, 1e4);
|
|
21
|
+
const apiKey = "apiKey" in apiOrLicenseKey ? apiOrLicenseKey.apiKey : null;
|
|
22
|
+
const licenseKey = "licenseKey" in apiOrLicenseKey ? apiOrLicenseKey.licenseKey : null;
|
|
13
23
|
try {
|
|
14
24
|
const res = await fetch(`${HOST}/api/track/register-usage-point`, {
|
|
15
25
|
method: "POST",
|
|
16
26
|
body: JSON.stringify({
|
|
17
27
|
event,
|
|
18
|
-
apiKey,
|
|
28
|
+
apiKey: licenseKey ?? apiKey,
|
|
19
29
|
host,
|
|
20
30
|
succeeded
|
|
21
31
|
}),
|
|
@@ -35,9 +45,11 @@ var registerUsageEvent = async ({
|
|
|
35
45
|
if (!res.ok) {
|
|
36
46
|
throw new Error(json.error);
|
|
37
47
|
}
|
|
38
|
-
|
|
39
|
-
return read;
|
|
48
|
+
throw new Error("Unexpected response from server");
|
|
40
49
|
} catch (err) {
|
|
50
|
+
if (isNetworkError(err)) {
|
|
51
|
+
console.log("Failed to send usage event", err);
|
|
52
|
+
}
|
|
41
53
|
clearTimeout(timeout);
|
|
42
54
|
if (err instanceof Error && err.name === "AbortError") {
|
|
43
55
|
throw new Error("Request timed out after 10 seconds");
|
package/dist/get-usage.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUsage = void 0;
|
|
4
|
-
const
|
|
4
|
+
const register_usage_event_1 = require("./register-usage-event");
|
|
5
5
|
const getUsage = async ({ apiKey, since, }) => {
|
|
6
|
-
const res = await fetch(`${
|
|
6
|
+
const res = await fetch(`${register_usage_event_1.HOST}/api/track/get-usage`, {
|
|
7
7
|
method: 'POST',
|
|
8
8
|
body: JSON.stringify({
|
|
9
9
|
apiKey,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { UsageEventClassification as Classification, RegisterUsageEventResponse, registerUsageEvent, } from './register-usage-
|
|
1
|
+
export { UsageEventClassification as Classification, RegisterUsageEventResponse, registerUsageEvent, } from './register-usage-event';
|
|
2
2
|
export { EventCount, GetUsageResponse, getUsage } from './get-usage';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUsage = exports.registerUsageEvent = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "registerUsageEvent", { enumerable: true, get: function () { return
|
|
4
|
+
var register_usage_event_1 = require("./register-usage-event");
|
|
5
|
+
Object.defineProperty(exports, "registerUsageEvent", { enumerable: true, get: function () { return register_usage_event_1.registerUsageEvent; } });
|
|
6
6
|
var get_usage_1 = require("./get-usage");
|
|
7
7
|
Object.defineProperty(exports, "getUsage", { enumerable: true, get: function () { return get_usage_1.getUsage; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isNetworkError(error: Error): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNetworkError = isNetworkError;
|
|
4
|
+
function isNetworkError(error) {
|
|
5
|
+
if (
|
|
6
|
+
// Chrome
|
|
7
|
+
error.message.includes('Failed to fetch') ||
|
|
8
|
+
// Safari
|
|
9
|
+
error.message.includes('Load failed') ||
|
|
10
|
+
// Firefox
|
|
11
|
+
error.message.includes('NetworkError when attempting to fetch resource')) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const HOST = "https://www.remotion.pro";
|
|
2
|
+
import type { NoReactInternals } from 'remotion/no-react';
|
|
3
|
+
export type RegisterUsageEventResponse = {
|
|
4
|
+
billable: boolean;
|
|
5
|
+
classification: UsageEventClassification;
|
|
6
|
+
};
|
|
7
|
+
type UsageEventType = 'webcodec-conversion' | 'cloud-render';
|
|
8
|
+
export type UsageEventClassification = 'billable' | 'development' | 'failed';
|
|
9
|
+
type EitherApiKeyOrLicenseKey = true extends typeof NoReactInternals.ENABLE_V5_BREAKING_CHANGES ? {
|
|
10
|
+
licenseKey: string | null;
|
|
11
|
+
} : {
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `licenseKey` instead
|
|
14
|
+
*/
|
|
15
|
+
apiKey: string | null;
|
|
16
|
+
} | {
|
|
17
|
+
licenseKey: string | null;
|
|
18
|
+
};
|
|
19
|
+
export declare const registerUsageEvent: ({ host, succeeded, event, ...apiOrLicenseKey }: {
|
|
20
|
+
host: string | null;
|
|
21
|
+
succeeded: boolean;
|
|
22
|
+
event: UsageEventType;
|
|
23
|
+
} & EitherApiKeyOrLicenseKey) => Promise<RegisterUsageEventResponse>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerUsageEvent = exports.HOST = void 0;
|
|
4
|
+
exports.HOST = 'https://www.remotion.pro';
|
|
5
|
+
const is_network_error_1 = require("./is-network-error");
|
|
6
|
+
const registerUsageEvent = async ({ host, succeeded, event, ...apiOrLicenseKey }) => {
|
|
7
|
+
const abortController = new AbortController();
|
|
8
|
+
const timeout = setTimeout(() => {
|
|
9
|
+
abortController.abort();
|
|
10
|
+
}, 10000);
|
|
11
|
+
const apiKey = 'apiKey' in apiOrLicenseKey ? apiOrLicenseKey.apiKey : null;
|
|
12
|
+
const licenseKey = 'licenseKey' in apiOrLicenseKey ? apiOrLicenseKey.licenseKey : null;
|
|
13
|
+
try {
|
|
14
|
+
const res = await fetch(`${exports.HOST}/api/track/register-usage-point`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
event,
|
|
18
|
+
apiKey: licenseKey !== null && licenseKey !== void 0 ? licenseKey : apiKey,
|
|
19
|
+
host,
|
|
20
|
+
succeeded,
|
|
21
|
+
}),
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
},
|
|
25
|
+
signal: abortController.signal,
|
|
26
|
+
});
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
const json = (await res.json());
|
|
29
|
+
if (json.success) {
|
|
30
|
+
return {
|
|
31
|
+
billable: json.billable,
|
|
32
|
+
classification: json.classification,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
throw new Error(json.error);
|
|
37
|
+
}
|
|
38
|
+
throw new Error('Unexpected response from server');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if ((0, is_network_error_1.isNetworkError)(err)) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('Failed to send usage event', err);
|
|
44
|
+
}
|
|
45
|
+
clearTimeout(timeout);
|
|
46
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
47
|
+
throw new Error('Request timed out after 10 seconds');
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.registerUsageEvent = registerUsageEvent;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/licensing"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/licensing",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.399",
|
|
7
7
|
"description": "Manage your Remotion.pro license",
|
|
8
8
|
"main": "dist",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
28
|
-
"eslint": "9.19.0"
|
|
27
|
+
"@remotion/eslint-config-internal": "4.0.399",
|
|
28
|
+
"eslint": "9.19.0",
|
|
29
|
+
"remotion": "4.0.399"
|
|
29
30
|
},
|
|
30
31
|
"homepage": "https://www.remotion.dev/docs/licensing",
|
|
31
32
|
"exports": {
|