🎥 Make videos programmatically with React
fix
Jonny Burger87215c8f2ca0
diff --git a/packages/layout-utils/package.json b/packages/layout-utils/package.jsonindex 7b8e6486a1..db8e5970db 100644--- a/packages/layout-utils/package.json+++ b/packages/layout-utils/package.json@@ -1,6 +1,6 @@{"name": "@remotion/layout-utils",- "version": "0.0.1",+ "version": "4.0.51","description": "Layout Utils for Remotion","main": "dist/cjs/index.js","types": "dist/cjs/index.d.ts",@@ -10,8 +10,7 @@"formatting": "prettier src --check","lint": "eslint src --ext ts,tsx","watch": "tsc -w",- "build": "rollup --config rollup.config.js && tsc -d",- "test": "vitest --run"+ "build": "rollup --config rollup.config.js && tsc -d"},"exports": {"./package.json": "./package.json",@@ -45,8 +44,7 @@"eslint": "8.42.0","prettier": "3.0.2","prettier-plugin-organize-imports": "^3.2.2",- "rollup": "^2.70.1",- "vitest": "0.31.1"+ "rollup": "^2.70.1"},"keywords": ["remotion",diff --git a/packages/layout-utils/src/layouts/measure-text.ts b/packages/layout-utils/src/layouts/measure-text.tsindex 80db44d793..7778d24659 100644--- a/packages/layout-utils/src/layouts/measure-text.ts+++ b/packages/layout-utils/src/layouts/measure-text.ts@@ -1,52 +1,52 @@type Dimensions = {- width: number;- height: number;+ width: number;+ height: number;};const wordCache = new Map<string, Dimensions>();export const measureText = ({- text,- fontFamily,- fontSize,- fontWeight,- letterSpacing,+ text,+ fontFamily,+ fontSize,+ fontWeight,+ letterSpacing,}: {- text: string;- fontFamily: string;- fontSize: number;- fontWeight?: number | string;- letterSpacing?: string;+ text: string;+ fontFamily: string;+ fontSize: number;+ fontWeight?: number | string;+ letterSpacing?: string;}): Dimensions => {- const key = `${text}-${fontFamily}-${fontWeight}-${fontSize}-${letterSpacing}`;+ const key = `${text}-${fontFamily}-${fontWeight}-${fontSize}-${letterSpacing}`;- if (wordCache.has(key)) {- return wordCache.get(key) as Dimensions;- }+ if (wordCache.has(key)) {+ return wordCache.get(key) as Dimensions;+ }- const node = document.createElement("span");+ const node = document.createElement('span');- node.style.fontFamily = fontFamily;- node.style.display = "inline-block";- node.style.position = "absolute";- node.style.top = `-10000px`;- node.style.whiteSpace = "pre";- if (fontWeight) {- node.style.fontWeight = fontWeight.toString();- }+ node.style.fontFamily = fontFamily;+ node.style.display = 'inline-block';+ node.style.position = 'absolute';+ node.style.top = `-10000px`;+ node.style.whiteSpace = 'pre';+ if (fontWeight) {+ node.style.fontWeight = fontWeight.toString();+ }- node.style.fontSize = `${fontSize}px`;- if (letterSpacing) {- node.style.letterSpacing = letterSpacing;- }+ node.style.fontSize = `${fontSize}px`;+ if (letterSpacing) {+ node.style.letterSpacing = letterSpacing;+ }- node.innerText = text;+ node.innerText = text;- document.body.appendChild(node);- const boundingBox = node.getBoundingClientRect();- document.body.removeChild(node);+ document.body.appendChild(node);+ const boundingBox = node.getBoundingClientRect();+ document.body.removeChild(node);- const result = { height: boundingBox.height, width: boundingBox.width };- wordCache.set(key, result);- return result;+ const result = {height: boundingBox.height, width: boundingBox.width};+ wordCache.set(key, result);+ return result;};diff --git a/packages/layout-utils/src/test/measure-text.test.ts b/packages/layout-utils/src/test/measure-text.test.tsdeleted file mode 100644index 31c0e685e2..0000000000--- a/packages/layout-utils/src/test/measure-text.test.ts+++ /dev/null@@ -1,19 +0,0 @@-import {expect, test} from 'vitest';-import {measureText} from '../index';--// Make Node.JS 14 pass-if (typeof performance === 'undefined') {- test('Pass', () => {- expect(1).toBe(1);- });-} else {- test('should return dimensions for given text', () => {- const text = 'Lorem ipsum';- const fontFamily = 'Arial';- const fontSize = 12;- const dimensions = measureText({ text, fontFamily, fontSize });-- expect(dimensions).toHaveProperty('height');- expect(dimensions).toHaveProperty('width');- });-}diff --git a/packages/noise/src/test/noise-cache.test.ts b/packages/noise/src/test/noise-cache.test.tsindex b407318092..31a759f5ad 100644--- a/packages/noise/src/test/noise-cache.test.ts+++ b/packages/noise/src/test/noise-cache.test.ts@@ -2,130 +2,124 @@ import {expect, test} from 'vitest';import {noise2D, noise3D, noise4D} from '../index';// Make Node.JS 14 pass-if (typeof performance === 'undefined') {- test('Pass', () => {- expect(1).toBe(1);- });-} else {- test(- 'Noise should be deterministic',- () => {- const noise1 = noise2D(1, 0, 0);- const noise2 = noise2D(1, 0, 0);- expect(noise1).toBe(noise2);- expect(noise1).toBe(0);- expect(noise2D('my-seed', 0.5, 0.5)).toBe(0.3071565136272162);- expect(noise3D('my-seed', 0.7, 0.5, 0.5)).toBe(0.6402128434567901);- expect(noise4D('my-seed', 0.7, 0.5, 0.5, 0.9)).toBe(0.2714290963058814);- },- {retry: 2},- );+test(+ 'Noise should be deterministic',+ () => {+ const noise1 = noise2D(1, 0, 0);+ const noise2 = noise2D(1, 0, 0);+ expect(noise1).toBe(noise2);+ expect(noise1).toBe(0);+ expect(noise2D('my-seed', 0.5, 0.5)).toBe(0.3071565136272162);+ expect(noise3D('my-seed', 0.7, 0.5, 0.5)).toBe(0.6402128434567901);+ expect(noise4D('my-seed', 0.7, 0.5, 0.5, 0.9)).toBe(0.2714290963058814);+ },+ {retry: 2},+);- test(- 'Noise should be cached',- () => {- const start = performance.now();- noise2D('new-seed', 0.5, 0.5);- const end = performance.now();- const time = end - start;+test(+ 'Noise should be cached',+ () => {+ const start = performance.now();+ noise2D('new-seed', 0.5, 0.5);+ const end = performance.now();+ const time = end - start;- const start2 = performance.now();- noise2D('new-seed', 0.5, 0.5);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 10).toBeLessThan(time);- },- {retry: 2},- );+ const start2 = performance.now();+ noise2D('new-seed', 0.5, 0.5);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 10).toBeLessThan(time);+ },+ {retry: 2},+);- test(- 'Should only keep 10 cache entries',- () => {- const start = performance.now();- noise2D('seed-1', 0.5, 0.5);- const end = performance.now();- const time = end - start;+test(+ 'Should only keep 10 cache entries',+ () => {+ const start = performance.now();+ noise2D('seed-1', 0.5, 0.5);+ const end = performance.now();+ const time = end - start;- noise2D('seed-2', 0.5, 0.5);- noise2D('seed-3', 0.5, 0.5);- noise2D('seed-4', 0.5, 0.5);- noise2D('seed-5', 0.5, 0.5);- noise2D('seed-6', 0.5, 0.5);- noise2D('seed-7', 0.5, 0.5);- noise2D('seed-8', 0.5, 0.5);- noise2D('seed-9', 0.5, 0.5);- noise2D('seed-10', 0.5, 0.5);- noise2D('seed-11', 0.5, 0.5);- noise2D('seed-12', 0.5, 0.5);+ noise2D('seed-2', 0.5, 0.5);+ noise2D('seed-3', 0.5, 0.5);+ noise2D('seed-4', 0.5, 0.5);+ noise2D('seed-5', 0.5, 0.5);+ noise2D('seed-6', 0.5, 0.5);+ noise2D('seed-7', 0.5, 0.5);+ noise2D('seed-8', 0.5, 0.5);+ noise2D('seed-9', 0.5, 0.5);+ noise2D('seed-10', 0.5, 0.5);+ noise2D('seed-11', 0.5, 0.5);+ noise2D('seed-12', 0.5, 0.5);- const start2 = performance.now();- noise2D('seed-1', 0.5, 0.5);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- },- {- retry: 2,- },- );+ const start2 = performance.now();+ noise2D('seed-1', 0.5, 0.5);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {+ retry: 2,+ },+);- test(- 'Should only keep 10 cache entries (3D)',- () => {- const start = performance.now();- noise3D('seed-1', 0.5, 0.5, 0.8);- const end = performance.now();- const time = end - start;+test(+ 'Should only keep 10 cache entries (3D)',+ () => {+ const start = performance.now();+ noise3D('seed-1', 0.5, 0.5, 0.8);+ const end = performance.now();+ const time = end - start;- noise3D('seed-2', 0.5, 0.5, 0.8);- noise3D('seed-3', 0.5, 0.5, 0.8);- noise3D('seed-4', 0.5, 0.5, 0.8);- noise3D('seed-5', 0.5, 0.5, 0.8);- noise3D('seed-6', 0.5, 0.5, 0.8);- noise3D('seed-7', 0.5, 0.5, 0.8);- noise3D('seed-8', 0.5, 0.5, 0.8);- noise3D('seed-9', 0.5, 0.5, 0.8);- noise3D('seed-10', 0.5, 0, 0.85);- noise3D('seed-11', 0.5, 0, 0.85);- noise3D('seed-12', 0.5, 0, 0.85);+ noise3D('seed-2', 0.5, 0.5, 0.8);+ noise3D('seed-3', 0.5, 0.5, 0.8);+ noise3D('seed-4', 0.5, 0.5, 0.8);+ noise3D('seed-5', 0.5, 0.5, 0.8);+ noise3D('seed-6', 0.5, 0.5, 0.8);+ noise3D('seed-7', 0.5, 0.5, 0.8);+ noise3D('seed-8', 0.5, 0.5, 0.8);+ noise3D('seed-9', 0.5, 0.5, 0.8);+ noise3D('seed-10', 0.5, 0, 0.85);+ noise3D('seed-11', 0.5, 0, 0.85);+ noise3D('seed-12', 0.5, 0, 0.85);- const start2 = performance.now();- noise3D('seed-1', 0.5, 0.5, 0.8);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- },- {retry: 2},- );+ const start2 = performance.now();+ noise3D('seed-1', 0.5, 0.5, 0.8);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {retry: 2},+);- test(- 'Should only keep 10 cache entries (4D)',- () => {- const start = performance.now();- noise4D('seed-1', 0.5, 0.5, 0.8, 9);- const end = performance.now();- const time = end - start;+test(+ 'Should only keep 10 cache entries (4D)',+ () => {+ const start = performance.now();+ noise4D('seed-1', 0.5, 0.5, 0.8, 9);+ const end = performance.now();+ const time = end - start;- noise4D('seed-2', 0.5, 0.5, 0.8, 9);- noise4D('seed-3', 0.5, 0.5, 0.8, 9);- noise4D('seed-4', 0.5, 0.5, 0.8, 9);- noise4D('seed-5', 0.5, 0.5, 0.8, 9);- noise4D('seed-6', 0.5, 0.5, 0.8, 9);- noise4D('seed-7', 0.5, 0.5, 0.8, 9);- noise4D('seed-8', 0.5, 0.5, 0.8, 9);- noise4D('seed-9', 0.5, 0.5, 0.8, 9);- noise4D('seed-10', 0.5, 0, 0.85, 9);- noise4D('seed-11', 0.5, 0, 0.85, 9);- noise4D('seed-12', 0.5, 0, 0.85, 9);+ noise4D('seed-2', 0.5, 0.5, 0.8, 9);+ noise4D('seed-3', 0.5, 0.5, 0.8, 9);+ noise4D('seed-4', 0.5, 0.5, 0.8, 9);+ noise4D('seed-5', 0.5, 0.5, 0.8, 9);+ noise4D('seed-6', 0.5, 0.5, 0.8, 9);+ noise4D('seed-7', 0.5, 0.5, 0.8, 9);+ noise4D('seed-8', 0.5, 0.5, 0.8, 9);+ noise4D('seed-9', 0.5, 0.5, 0.8, 9);+ noise4D('seed-10', 0.5, 0, 0.85, 9);+ noise4D('seed-11', 0.5, 0, 0.85, 9);+ noise4D('seed-12', 0.5, 0, 0.85, 9);- const start2 = performance.now();- noise4D('seed-1', 0.5, 0.5, 0.8, 9);- const end2 = performance.now();- const time2 = end2 - start2;- expect(time2 * 4).toBeGreaterThan(time);- },- {- retry: 2,- },- );-}+ const start2 = performance.now();+ noise4D('seed-1', 0.5, 0.5, 0.8, 9);+ const end2 = performance.now();+ const time2 = end2 - start2;+ expect(time2 * 4).toBeGreaterThan(time);+ },+ {+ retry: 2,+ },+);diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 078779e683..ca9ee5d133 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1188,9 +1188,6 @@ importers:rollup:specifier: ^2.70.1version: 2.76.0- vitest:- specifier: 0.31.1- version: 0.31.1([email protected])packages/lottie:dependencies: