@remotion/motion-blur 4.0.142 → 4.0.144

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/LICENSE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Remotion License
2
2
 
3
+ In Remotion 5.0, the license will slightly change. [View the changes here](https://github.com/remotion-dev/remotion/pull/3750).
4
+
5
+ ---
6
+
3
7
  Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
4
8
 
5
9
  - [Free license](#free-license)
package/bundle.ts ADDED
@@ -0,0 +1,16 @@
1
+ import {build} from 'bun';
2
+
3
+ const output = await build({
4
+ entrypoints: ['src/index.ts'],
5
+ naming: '[name].mjs',
6
+ external: ['react', 'remotion', 'remotion/no-react', 'react/jsx-runtime'],
7
+ });
8
+
9
+ const [file] = output.outputs;
10
+ const text = (await file.text())
11
+ .replace(/jsxDEV/g, 'jsx')
12
+ .replace(/react\/jsx-dev-runtime/g, 'react/jsx-runtime');
13
+
14
+ await Bun.write('dist/esm/index.mjs', text);
15
+
16
+ export {};
@@ -1,90 +1,109 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useCurrentFrame, AbsoluteFill, Freeze } from 'remotion';
3
-
4
- /**
5
- * If the current frame is 0, then it is rendered with low opacity,
6
- * and the trailing elements have frame numbers -1, -2, -3, -4, etc.
7
- * To fix this, we instead reduce the number of samples to not go into negative territory.
8
- */
9
- const getNumberOfSamples = ({ shutterFraction, samples, currentFrame, }) => {
10
- const maxOffset = shutterFraction * samples;
11
- const maxTimeReverse = currentFrame - maxOffset;
12
- const factor = Math.min(1, Math.max(0, maxTimeReverse / maxOffset + 1));
13
- return Math.max(1, Math.round(Math.min(factor * samples, samples)));
1
+ // src/CameraMotionBlur.tsx
2
+ import {AbsoluteFill, Freeze, useCurrentFrame} from "remotion";
3
+ import {
4
+ jsx
5
+ } from "react/jsx-runtime";
6
+ var getNumberOfSamples = ({
7
+ shutterFraction,
8
+ samples,
9
+ currentFrame
10
+ }) => {
11
+ const maxOffset = shutterFraction * samples;
12
+ const maxTimeReverse = currentFrame - maxOffset;
13
+ const factor = Math.min(1, Math.max(0, maxTimeReverse / maxOffset + 1));
14
+ return Math.max(1, Math.round(Math.min(factor * samples, samples)));
14
15
  };
15
- /**
16
- * @description Produces natural looking motion blur similar to what would be produced by a film camera.
17
- * @see [Documentation](https://www.remotion.dev/docs/motion-blur/camera-motion-blur)
18
- */
19
- const CameraMotionBlur = ({ children, shutterAngle = 180, samples = 10, }) => {
20
- const currentFrame = useCurrentFrame();
21
- if (typeof samples !== 'number' ||
22
- Number.isNaN(samples) ||
23
- !Number.isFinite(samples)) {
24
- throw new TypeError(`"samples" must be a number, but got ${JSON.stringify(samples)}`);
25
- }
26
- if (samples % 1 !== 0) {
27
- throw new TypeError(`"samples" must be an integer, but got ${JSON.stringify(samples)}`);
28
- }
29
- if (samples < 0) {
30
- throw new TypeError(`"samples" must be non-negative, but got ${JSON.stringify(samples)}`);
31
- }
32
- if (typeof shutterAngle !== 'number' ||
33
- Number.isNaN(shutterAngle) ||
34
- !Number.isFinite(shutterAngle)) {
35
- throw new TypeError(`"shutterAngle" must be a number, but got ${JSON.stringify(shutterAngle)}`);
36
- }
37
- if (shutterAngle < 0 || shutterAngle > 360) {
38
- throw new TypeError(`"shutterAngle" must be between 0 and 360, but got ${JSON.stringify(shutterAngle)}`);
39
- }
40
- const shutterFraction = shutterAngle / 360;
41
- const actualSamples = getNumberOfSamples({
42
- currentFrame,
43
- samples,
44
- shutterFraction,
45
- });
46
- return (jsx(AbsoluteFill, { style: { isolation: 'isolate' }, children: new Array(actualSamples).fill(true).map((_, i) => {
47
- const sample = i + 1;
48
- const sampleFrameOffset = shutterFraction * (sample / actualSamples);
49
- return (jsx(AbsoluteFill, { style: {
50
- mixBlendMode: 'plus-lighter',
51
- filter: `opacity(${1 / actualSamples})`,
52
- }, children: jsx(Freeze, { frame: currentFrame - sampleFrameOffset + 1, children: children }) }, `frame-${i.toString()}`));
53
- }) }));
16
+ var CameraMotionBlur = ({
17
+ children,
18
+ shutterAngle = 180,
19
+ samples = 10
20
+ }) => {
21
+ const currentFrame = useCurrentFrame();
22
+ if (typeof samples !== "number" || Number.isNaN(samples) || !Number.isFinite(samples)) {
23
+ throw new TypeError(`"samples" must be a number, but got ${JSON.stringify(samples)}`);
24
+ }
25
+ if (samples % 1 !== 0) {
26
+ throw new TypeError(`"samples" must be an integer, but got ${JSON.stringify(samples)}`);
27
+ }
28
+ if (samples < 0) {
29
+ throw new TypeError(`"samples" must be non-negative, but got ${JSON.stringify(samples)}`);
30
+ }
31
+ if (typeof shutterAngle !== "number" || Number.isNaN(shutterAngle) || !Number.isFinite(shutterAngle)) {
32
+ throw new TypeError(`"shutterAngle" must be a number, but got ${JSON.stringify(shutterAngle)}`);
33
+ }
34
+ if (shutterAngle < 0 || shutterAngle > 360) {
35
+ throw new TypeError(`"shutterAngle" must be between 0 and 360, but got ${JSON.stringify(shutterAngle)}`);
36
+ }
37
+ const shutterFraction = shutterAngle / 360;
38
+ const actualSamples = getNumberOfSamples({
39
+ currentFrame,
40
+ samples,
41
+ shutterFraction
42
+ });
43
+ return jsx(AbsoluteFill, {
44
+ style: { isolation: "isolate" },
45
+ children: new Array(actualSamples).fill(true).map((_, i) => {
46
+ const sample = i + 1;
47
+ const sampleFrameOffset = shutterFraction * (sample / actualSamples);
48
+ return jsx(AbsoluteFill, {
49
+ style: {
50
+ mixBlendMode: "plus-lighter",
51
+ filter: `opacity(${1 / actualSamples})`
52
+ },
53
+ children: jsx(Freeze, {
54
+ frame: currentFrame - sampleFrameOffset + 1,
55
+ children
56
+ }, undefined, false, undefined, this)
57
+ }, `frame-${i.toString()}`, false, undefined, this);
58
+ })
59
+ }, undefined, false, undefined, this);
54
60
  };
55
61
 
56
- /**
57
- * @description The <Trail> component duplicates it's children and adds a time offset to each layer in order to create a trail effect.
58
- * @see [Documentation](https://www.remotion.dev/docs/motion-blur/trail)
59
- */
60
- const Trail = ({ children, layers, lagInFrames, trailOpacity, }) => {
61
- const frame = useCurrentFrame();
62
- if (typeof layers !== 'number' ||
63
- Number.isNaN(layers) ||
64
- !Number.isFinite(layers)) {
65
- throw new TypeError(`"layers" must be a number, but got ${JSON.stringify(layers)}`);
66
- }
67
- if (layers % 1 !== 0) {
68
- throw new TypeError(`"layers" must be an integer, but got ${JSON.stringify(layers)}`);
69
- }
70
- if (layers < 0) {
71
- throw new TypeError(`"layers" must be non-negative, but got ${JSON.stringify(layers)}`);
72
- }
73
- if (typeof trailOpacity !== 'number' ||
74
- Number.isNaN(trailOpacity) ||
75
- !Number.isFinite(trailOpacity)) {
76
- throw new TypeError(`"trailOpacity" must be a number, but got ${JSON.stringify(trailOpacity)}`);
77
- }
78
- if (typeof lagInFrames !== 'number' ||
79
- Number.isNaN(lagInFrames) ||
80
- !Number.isFinite(lagInFrames)) {
81
- throw new TypeError(`"lagInFrames" must be a number, but got ${JSON.stringify(lagInFrames)}`);
82
- }
83
- return (jsxs(AbsoluteFill, { children: [new Array(layers).fill(true).map((_, i) => {
84
- return (jsx(AbsoluteFill, { style: {
85
- opacity: trailOpacity - ((layers - i) / layers) * trailOpacity,
86
- }, children: jsx(Freeze, { frame: frame - lagInFrames * (layers - i), children: children }) }, `frame-${i.toString()}`));
87
- }), children] }));
62
+ // src/Trail.tsx
63
+ import {AbsoluteFill as AbsoluteFill2, Freeze as Freeze2, useCurrentFrame as useCurrentFrame2} from "remotion";
64
+ import {
65
+ jsx as jsx2
66
+ } from "react/jsx-runtime";
67
+ var Trail = ({
68
+ children,
69
+ layers,
70
+ lagInFrames,
71
+ trailOpacity
72
+ }) => {
73
+ const frame = useCurrentFrame2();
74
+ if (typeof layers !== "number" || Number.isNaN(layers) || !Number.isFinite(layers)) {
75
+ throw new TypeError(`"layers" must be a number, but got ${JSON.stringify(layers)}`);
76
+ }
77
+ if (layers % 1 !== 0) {
78
+ throw new TypeError(`"layers" must be an integer, but got ${JSON.stringify(layers)}`);
79
+ }
80
+ if (layers < 0) {
81
+ throw new TypeError(`"layers" must be non-negative, but got ${JSON.stringify(layers)}`);
82
+ }
83
+ if (typeof trailOpacity !== "number" || Number.isNaN(trailOpacity) || !Number.isFinite(trailOpacity)) {
84
+ throw new TypeError(`"trailOpacity" must be a number, but got ${JSON.stringify(trailOpacity)}`);
85
+ }
86
+ if (typeof lagInFrames !== "number" || Number.isNaN(lagInFrames) || !Number.isFinite(lagInFrames)) {
87
+ throw new TypeError(`"lagInFrames" must be a number, but got ${JSON.stringify(lagInFrames)}`);
88
+ }
89
+ return jsx2(AbsoluteFill2, {
90
+ children: [
91
+ new Array(layers).fill(true).map((_, i) => {
92
+ return jsx2(AbsoluteFill2, {
93
+ style: {
94
+ opacity: trailOpacity - (layers - i) / layers * trailOpacity
95
+ },
96
+ children: jsx2(Freeze2, {
97
+ frame: frame - lagInFrames * (layers - i),
98
+ children
99
+ }, undefined, false, undefined, this)
100
+ }, `frame-${i.toString()}`, false, undefined, this);
101
+ }),
102
+ children
103
+ ]
104
+ }, undefined, true, undefined, this);
105
+ };
106
+ export {
107
+ Trail,
108
+ CameraMotionBlur
88
109
  };
89
-
90
- export { CameraMotionBlur, Trail };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/motion-blur",
3
- "version": "4.0.142",
3
+ "version": "4.0.144",
4
4
  "description": "Motion blur effect for Remotion",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "url": "https://github.com/remotion-dev/remotion/issues"
17
17
  },
18
18
  "dependencies": {
19
- "remotion": "4.0.142"
19
+ "remotion": "4.0.144"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": ">=16.8.0",
@@ -33,15 +33,13 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.281",
36
- "@rollup/plugin-typescript": "^8.2.0",
37
36
  "@types/react": "18.2.48",
38
37
  "eslint": "8.56.0",
39
38
  "prettier": "3.2.5",
40
39
  "prettier-plugin-organize-imports": "3.2.4",
41
40
  "react": "18.2.0",
42
41
  "react-dom": "18.2.0",
43
- "rollup": "^2.70.1",
44
- "remotion": "4.0.142"
42
+ "remotion": "4.0.144"
45
43
  },
46
44
  "keywords": [
47
45
  "remotion",
@@ -55,6 +53,6 @@
55
53
  "formatting": "prettier src --check",
56
54
  "lint": "eslint src --ext ts,tsx",
57
55
  "watch": "tsc -w",
58
- "build": "rollup --config rollup.config.js && tsc -d"
56
+ "build": "bun bundle.ts && tsc -d"
59
57
  }
60
58
  }
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- export type CameraMotionBlurProps = {
3
- children: React.ReactNode;
4
- shutterAngle?: number;
5
- samples?: number;
6
- };
7
- /**
8
- * @description Produces natural looking motion blur similar to what would be produced by a film camera.
9
- * @see [Documentation](https://www.remotion.dev/docs/motion-blur/camera-motion-blur)
10
- */
11
- export declare const CameraMotionBlur: React.FC<CameraMotionBlurProps>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- export type TrailProps = {
3
- children: React.ReactNode;
4
- layers: number;
5
- lagInFrames: number;
6
- trailOpacity: number;
7
- };
8
- /**
9
- * @description The <Trail> component duplicates it's children and adds a time offset to each layer in order to create a trail effect.
10
- * @see [Documentation](https://www.remotion.dev/docs/motion-blur/trail)
11
- */
12
- export declare const Trail: React.FC<TrailProps>;
@@ -1,2 +0,0 @@
1
- export { CameraMotionBlur, CameraMotionBlurProps } from './CameraMotionBlur';
2
- export { Trail, TrailProps } from './Trail';