🎥 Make videos programmatically with React
`@remotion/licensing` package
Jonny Burgerbf680d78f1ff
diff --git a/packages/cli/src/list-of-remotion-packages.ts b/packages/cli/src/list-of-remotion-packages.tsindex c965e18413..171eeaacfd 100644--- a/packages/cli/src/list-of-remotion-packages.ts+++ b/packages/cli/src/list-of-remotion-packages.ts@@ -17,6 +17,7 @@ export const listOfRemotionPackages = ['@remotion/paths','@remotion/babel-loader','@remotion/lambda',+ '@remotion/licensing','@remotion/player','@remotion/preload','@remotion/three',diff --git a/packages/licensing/bundle.ts b/packages/licensing/bundle.tsnew file mode 100644index 0000000000..5ab0df753b--- /dev/null+++ b/packages/licensing/bundle.ts@@ -0,0 +1,18 @@+import {build} from 'bun';++if (process.env.NODE_ENV !== 'production') {+ throw new Error('This script must be run using NODE_ENV=production');+}++const output = await build({+ entrypoints: ['src/index.ts'],+ naming: '[name].mjs',+ external: [],+});++const [file] = output.outputs;+const text = await file.text();++await Bun.write('dist/esm/index.mjs', text);++export {};diff --git a/packages/licensing/package.json b/packages/licensing/package.jsonnew file mode 100644index 0000000000..6379b2191a--- /dev/null+++ b/packages/licensing/package.json@@ -0,0 +1,33 @@+{+ "repository": {+ "url": "https://github.com/remotion-dev/remotion/tree/main/packages/licensing"+ },+ "name": "@remotion/licensing",+ "version": "4.0.236",+ "description": "A runtime for distributed rendering",+ "main": "dist",+ "sideEffects": false,+ "scripts": {+ "lint": "eslint src",+ "formatting": "prettier src --check",+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"+ },+ "author": "Jonny Burger <[email protected]>",+ "contributors": [],+ "license": "MIT",+ "bugs": {+ "url": "https://github.com/remotion-dev/remotion/issues"+ },+ "publishConfig": {+ "access": "public"+ },+ "dependencies": {+ "remotion": "workspace:*",+ "@remotion/renderer": "workspace:*",+ "@remotion/streaming": "workspace:*"+ },+ "devDependencies": {+ "@remotion/eslint-config-internal": "workspace:*",+ "eslint": "9.14.0"+ }+}diff --git a/packages/licensing/src/index.ts b/packages/licensing/src/index.tsnew file mode 100644index 0000000000..7db220961a--- /dev/null+++ b/packages/licensing/src/index.ts@@ -0,0 +1,5 @@+import {registerCompanyLicenseUsageEvent} from './register-company-license-usage-point';++export const LicensingInternals = {+ trackWebCodecConversion: registerCompanyLicenseUsageEvent,+};diff --git a/packages/licensing/src/register-company-license-usage-point.ts b/packages/licensing/src/register-company-license-usage-point.tsnew file mode 100644index 0000000000..f453288000--- /dev/null+++ b/packages/licensing/src/register-company-license-usage-point.ts@@ -0,0 +1,63 @@+const HOST = 'http://localhost:51748/';++type ApiResponse =+ | {+ success: true;+ billable: boolean;+ classification: Classification;+ }+ | {+ success: false;+ error: string;+ };++export type TrackWebCodecConversionResponse = {+ success: true;+ billable: boolean;+ classification: Classification;+};++type CompanyLicenseUsageEvent = 'webcodec-conversion' | 'cloud-render';++export type Classification = 'billable' | 'development' | 'failed';++export const registerCompanyLicenseUsageEvent = async ({+ apiKey,+ host,+ succeeded,+ event,+}: {+ apiKey: string;+ host: string;+ succeeded: boolean;+ event: CompanyLicenseUsageEvent;+}): Promise<TrackWebCodecConversionResponse> => {+ const res = await fetch(`${HOST}/api/track`, {+ method: 'POST',+ body: JSON.stringify({+ event: event,+ apiKey,+ host,+ succeeded,+ }),+ headers: {+ 'Content-Type': 'application/json',+ },+ });+ const json = (await res.json()) as ApiResponse;++ if (json.success) {+ return {+ billable: json.billable,+ success: true,+ classification: json.classification,+ };+ }++ if (!res.ok) {+ throw new Error(json.error);+ }++ const read = await res.json();+ return read;+};diff --git a/packages/licensing/src/test/register.test.ts b/packages/licensing/src/test/register.test.tsnew file mode 100644index 0000000000..d6507951af--- /dev/null+++ b/packages/licensing/src/test/register.test.ts@@ -0,0 +1,55 @@+// These tests can only be run locally on a machine+// of a Remotion team member with an instance of remotion.pro running locally++import {expect, test} from 'bun:test';+import {registerCompanyLicenseUsageEvent} from '../register-company-license-usage-point';++test('Should be able to track production usage', async () => {+ const result = await registerCompanyLicenseUsageEvent({+ apiKey: 'rm_pub_1dd7193534bbe72571b55bd43926654ddaaca3dd6f07772b',+ host: 'http://localhost:50955',+ succeeded: true,+ event: 'webcodec-conversion',+ });+ expect(result).toEqual({+ success: true,+ billable: false,+ classification: 'development',+ });+});++test('Should be able to track development usage', async () => {+ const result = await registerCompanyLicenseUsageEvent({+ apiKey: 'rm_pub_1dd7193534bbe72571b55bd43926654ddaaca3dd6f07772b',+ host: 'https://remotion.dev',+ succeeded: true,+ event: 'webcodec-conversion',+ });+ expect(result).toEqual({+ success: true,+ billable: true,+ classification: 'billable',+ });+});++test('Should reject invalid API key', async () => {+ const result = registerCompanyLicenseUsageEvent({+ apiKey: 'rm_pub_1dd719b',+ host: 'http://localhost:50955',+ succeeded: true,+ event: 'webcodec-conversion',+ });+ expect(result).rejects.toThrowError(/Invalid API key/);+});++test('Should reject invalid secret API key', async () => {+ const result = registerCompanyLicenseUsageEvent({+ apiKey: 'rm_sec_1dd719b',+ host: 'http://localhost:50955',+ succeeded: true,+ event: 'webcodec-conversion',+ });+ expect(result).rejects.toThrowError(+ /Secret API passed - use public key instead/,+ );+});diff --git a/packages/licensing/tsconfig.json b/packages/licensing/tsconfig.jsonnew file mode 100644index 0000000000..5b9931e6fc--- /dev/null+++ b/packages/licensing/tsconfig.json@@ -0,0 +1,12 @@+{+ "extends": "../tsconfig.settings.json",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "dist",+ "jsx": "react-jsx",+ "skipLibCheck": true,+ "target": "ES2023"+ },+ "include": ["src"],+ "references": []+}diff --git a/packages/studio-shared/src/package-info.ts b/packages/studio-shared/src/package-info.tsindex fbc5f8a5dc..06d73505fa 100644--- a/packages/studio-shared/src/package-info.ts+++ b/packages/studio-shared/src/package-info.ts@@ -39,6 +39,7 @@ export const packages = ['lambda-python','lambda','layout-utils',+ 'licensing','lottie','media-utils','motion-blur',@@ -86,6 +87,7 @@ export const descriptions: {[key in Pkgs]: string | null} = {'google-fonts': 'Use Google Fonts in Remotion','media-utils': 'Utilities for working with media files',lottie: 'Include Lottie animations in Remotion',+ licensing: 'Manage your Remotion.pro license','layout-utils': 'Utilities for working with layouts',noise: 'Noise generation functions','motion-blur': 'Motion blur effect for Remotion',@@ -160,6 +162,7 @@ export const apiDocs: {[key in Pkgs]: string | null} = {'google-fonts': 'https://www.remotion.dev/docs/google-fonts','media-utils': 'https://www.remotion.dev/docs/media-utils',lottie: 'https://www.remotion.dev/docs/lottie',+ licensing: 'https://www.remotion.dev/docs/licensing','layout-utils': 'https://www.remotion.dev/docs/layout-utils',noise: 'https://www.remotion.dev/docs/noise','motion-blur': 'https://www.remotion.dev/docs/motion-blur',diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 23ac052d00..a7a2e382aa 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1419,6 +1419,25 @@ importers:specifier: 9.14.0version: 9.14.0+ packages/licensing:+ dependencies:+ '@remotion/renderer':+ specifier: workspace:*+ version: link:../renderer+ '@remotion/streaming':+ specifier: workspace:*+ version: link:../streaming+ remotion:+ specifier: workspace:*+ version: link:../core+ devDependencies:+ '@remotion/eslint-config-internal':+ specifier: workspace:*+ version: link:../eslint-config-internal+ eslint:+ specifier: 9.14.0+ version: 9.14.0+packages/lottie:dependencies:lottie-web:diff --git a/tsconfig.json b/tsconfig.jsonindex 86a1cd89ec..ac3d7c7022 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -105,6 +105,9 @@{"path": "./packages/player-example"},+ {+ "path": "./packages/licensing"+ },{"path": "./packages/preload"},