@remotion/starburst 4.0.498 → 4.0.500

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.
@@ -1,361 +1,28 @@
1
1
  // src/starburst-effect.ts
2
- import { Internals } from "remotion";
3
-
4
- // src/color-to-rgb.ts
5
- import { NoReactInternals } from "remotion/no-react";
6
- var colorToRgb = (color) => {
7
- const packed = NoReactInternals.processColor(color);
8
- return [packed >>> 16 & 255, packed >>> 8 & 255, packed & 255];
9
- };
10
-
11
- // src/starburst-effect.ts
12
- var { createEffect, createWebGL2ContextError } = Internals;
13
- var DEFAULT_ORIGIN = [0.5, 0.5];
14
- var starburstEffectSchema = {
15
- rays: {
16
- type: "number",
17
- min: 2,
18
- max: 100,
19
- step: 1,
20
- default: undefined,
21
- description: "Number of Rays",
22
- hiddenFromList: false
23
- },
24
- colors: {
25
- type: "array",
26
- item: {
27
- type: "color"
28
- },
29
- default: undefined,
30
- minLength: 2,
31
- newItemDefault: "#ff0000",
32
- description: "Colors",
33
- keyframable: false
34
- },
35
- rotation: {
36
- type: "number",
37
- min: 0,
38
- max: 360,
39
- step: 1,
40
- default: 0,
41
- description: "Rotation",
42
- hiddenFromList: false
43
- },
44
- smoothness: {
45
- type: "number",
46
- min: 0,
47
- max: 1,
48
- step: 0.01,
49
- default: 0,
50
- description: "Edge Smoothness",
51
- hiddenFromList: false
52
- },
53
- origin: {
54
- type: "uv-coordinate",
55
- min: 0,
56
- max: 1,
57
- step: 0.01,
58
- default: DEFAULT_ORIGIN,
59
- description: "Origin"
60
- }
61
- };
62
- var resolve = (p) => ({
63
- rays: p.rays,
64
- colors: p.colors,
65
- rotation: p.rotation ?? 0,
66
- smoothness: p.smoothness ?? 0,
67
- origin: p.origin ?? DEFAULT_ORIGIN
68
- });
69
- var validateStarburstEffectParams = (params) => {
70
- if (params === null || typeof params !== "object") {
71
- throw new TypeError(`Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`);
72
- }
73
- const { rays, colors } = params;
74
- if (typeof rays !== "number" || !Number.isFinite(rays)) {
75
- throw new TypeError(`"rays" must be a finite number, but got ${JSON.stringify(rays)}`);
76
- }
77
- if (rays < 2 || rays > 100) {
78
- throw new RangeError(`"rays" must be between 2 and 100, but got ${rays}`);
79
- }
80
- if (!Array.isArray(colors) || colors.length < 2) {
81
- throw new TypeError(`"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`);
82
- }
83
- const r = resolve(params);
84
- if (typeof r.rotation !== "number" || !Number.isFinite(r.rotation)) {
85
- throw new TypeError(`"rotation" must be a finite number, but got ${JSON.stringify(params.rotation)}`);
86
- }
87
- if (typeof r.smoothness !== "number" || !Number.isFinite(r.smoothness)) {
88
- throw new TypeError(`"smoothness" must be a finite number, but got ${JSON.stringify(params.smoothness)}`);
89
- }
90
- if (r.smoothness < 0 || r.smoothness > 1) {
91
- throw new RangeError(`"smoothness" must be between 0 and 1, but got ${r.smoothness}`);
92
- }
93
- if (!Array.isArray(r.origin) || r.origin.length !== 2 || r.origin.some((coordinate) => {
94
- return typeof coordinate !== "number" || !Number.isFinite(coordinate);
95
- })) {
96
- throw new TypeError('"origin" must be a [number, number] tuple');
97
- }
98
- if (r.origin.some((coordinate) => coordinate < 0 || coordinate > 1)) {
99
- throw new RangeError(`"origin" must contain coordinates between 0 and 1, but got ${JSON.stringify(r.origin)}`);
100
- }
101
- for (const c of r.colors) {
102
- colorToRgb(c);
103
- }
104
- };
105
- var STARBURST_VS = `#version 300 es
106
- in vec2 aPos;
107
- in vec2 aUv;
108
- out vec2 vUv;
109
- void main() {
110
- vUv = aUv;
111
- gl_Position = vec4(aPos, 0.0, 1.0);
112
- }
113
- `;
114
- var STARBURST_FS = `#version 300 es
115
- precision highp float;
116
-
117
- uniform sampler2D colorPalette;
118
- uniform float numRays;
119
- uniform float rotationOffset;
120
- uniform float smoothEdge;
121
- uniform vec2 resolution;
122
- uniform float numColors;
123
- uniform vec2 origin;
124
-
125
- in vec2 vUv;
126
- out vec4 fragColor;
127
-
128
- const float Pi = 3.14159265359;
129
-
130
- void main() {
131
- vec2 uv = vUv;
132
- vec2 center = uv - origin;
133
- center.x *= resolution.x / resolution.y;
134
-
135
- float angle = atan(center.y, center.x) + rotationOffset;
136
- float normalizedAngle = (angle + Pi) / (2.0 * Pi);
137
- float sector = normalizedAngle * numRays;
138
- float rayIndex = mod(floor(sector), numRays);
139
-
140
- float colorIndex = mod(rayIndex, numColors);
141
- float texCoord = (colorIndex + 0.5) / numColors;
142
- vec3 col = texture(colorPalette, vec2(texCoord, 0.5)).rgb;
143
-
144
- float fractSector = fract(sector);
145
- float edgeSmooth = smoothEdge * 0.5;
146
- float nextColorIndex = mod(rayIndex + 1.0, numColors);
147
- float nextTexCoord = (nextColorIndex + 0.5) / numColors;
148
- vec3 nextCol = texture(colorPalette, vec2(nextTexCoord, 0.5)).rgb;
149
-
150
- float blend = smoothstep(1.0 - edgeSmooth, 1.0, fractSector);
151
- col = mix(col, nextCol, blend);
152
- float blendStart = smoothstep(edgeSmooth, 0.0, fractSector);
153
- float prevColorIndex = mod(rayIndex - 1.0 + numColors, numColors);
154
- float prevTexCoord = (prevColorIndex + 0.5) / numColors;
155
- vec3 prevCol = texture(colorPalette, vec2(prevTexCoord, 0.5)).rgb;
156
- col = mix(col, prevCol, blendStart);
157
-
158
- fragColor = vec4(col, 1.0);
159
- }
160
- `;
161
- var compileShader = (gl, type, source) => {
162
- const shader = gl.createShader(type);
163
- if (!shader) {
164
- throw new Error("Failed to create WebGL shader");
165
- }
166
- gl.shaderSource(shader, source);
167
- gl.compileShader(shader);
168
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
169
- const log = gl.getShaderInfoLog(shader);
170
- gl.deleteShader(shader);
171
- throw new Error(`Starburst shader compile failed: ${log ?? "(no log)"}`);
172
- }
173
- return shader;
174
- };
175
- var linkProgram = (gl, vs, fs) => {
176
- const program = gl.createProgram();
177
- if (!program) {
178
- throw new Error("Failed to create WebGL program");
179
- }
180
- gl.attachShader(program, vs);
181
- gl.attachShader(program, fs);
182
- gl.linkProgram(program);
183
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
184
- const log = gl.getProgramInfoLog(program);
185
- gl.deleteProgram(program);
186
- throw new Error(`Starburst program link failed: ${log ?? "(no log)"}`);
187
- }
188
- return program;
189
- };
190
- var starburst = createEffect({
191
- type: "dev.remotion.starburst.starburst",
192
- label: "starburst()",
193
- documentationLink: "https://www.remotion.dev/docs/starburst/starburst-effect",
194
- backend: "webgl2",
195
- calculateKey: (params) => {
196
- const r = resolve(params);
197
- return `starburst-${r.rays}-${r.colors.join("|")}-${r.rotation}-${r.smoothness}-${r.origin.join(":")}`;
198
- },
199
- setup: (target) => {
200
- const gl = target.getContext("webgl2", {
201
- premultipliedAlpha: true,
202
- alpha: true,
203
- preserveDrawingBuffer: true
204
- });
205
- if (!gl) {
206
- throw createWebGL2ContextError("starburst effect");
207
- }
208
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
209
- const vs = compileShader(gl, gl.VERTEX_SHADER, STARBURST_VS);
210
- const fs = compileShader(gl, gl.FRAGMENT_SHADER, STARBURST_FS);
211
- const program = linkProgram(gl, vs, fs);
212
- gl.deleteShader(vs);
213
- gl.deleteShader(fs);
214
- const vao = gl.createVertexArray();
215
- if (!vao) {
216
- throw new Error("Failed to create WebGL vertex array");
217
- }
218
- gl.bindVertexArray(vao);
219
- const data = new Float32Array([
220
- -1,
221
- -1,
222
- 0,
223
- 0,
224
- 1,
225
- -1,
226
- 1,
227
- 0,
228
- -1,
229
- 1,
230
- 0,
231
- 1,
232
- 1,
233
- 1,
234
- 1,
235
- 1
236
- ]);
237
- const vbo = gl.createBuffer();
238
- if (!vbo) {
239
- throw new Error("Failed to create WebGL buffer");
240
- }
241
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
242
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
243
- const aPos = gl.getAttribLocation(program, "aPos");
244
- const aUv = gl.getAttribLocation(program, "aUv");
245
- gl.enableVertexAttribArray(aPos);
246
- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
247
- gl.enableVertexAttribArray(aUv);
248
- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
249
- gl.bindVertexArray(null);
250
- const paletteTexture = gl.createTexture();
251
- if (!paletteTexture) {
252
- throw new Error("Failed to create WebGL palette texture");
253
- }
254
- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
255
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
256
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
257
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
258
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
259
- gl.bindTexture(gl.TEXTURE_2D, null);
260
- return {
261
- gl,
262
- program,
263
- vao,
264
- vbo,
265
- paletteTexture,
266
- uColorPalette: gl.getUniformLocation(program, "colorPalette"),
267
- uNumRays: gl.getUniformLocation(program, "numRays"),
268
- uRotationOffset: gl.getUniformLocation(program, "rotationOffset"),
269
- uSmoothEdge: gl.getUniformLocation(program, "smoothEdge"),
270
- uResolution: gl.getUniformLocation(program, "resolution"),
271
- uNumColors: gl.getUniformLocation(program, "numColors"),
272
- uOrigin: gl.getUniformLocation(program, "origin"),
273
- cachedPaletteKey: "",
274
- palettePixelData: new Uint8Array(0)
275
- };
276
- },
277
- apply: ({ width, height, params, state }) => {
278
- const r = resolve(params);
279
- const {
280
- gl,
281
- program,
282
- vao,
283
- paletteTexture,
284
- uColorPalette,
285
- uNumRays,
286
- uRotationOffset,
287
- uSmoothEdge,
288
- uResolution,
289
- uNumColors,
290
- uOrigin
291
- } = state;
292
- const rotationRad = r.rotation * Math.PI / 180;
293
- const paletteKey = r.colors.join("|");
294
- const paletteDirty = state.cachedPaletteKey !== paletteKey;
295
- if (paletteDirty) {
296
- state.cachedPaletteKey = paletteKey;
297
- const len = r.colors.length * 4;
298
- if (state.palettePixelData.length !== len) {
299
- state.palettePixelData = new Uint8Array(len);
300
- }
301
- const { palettePixelData } = state;
302
- for (let i = 0;i < r.colors.length; i++) {
303
- const rgb = colorToRgb(r.colors[i]);
304
- palettePixelData[i * 4] = rgb[0];
305
- palettePixelData[i * 4 + 1] = rgb[1];
306
- palettePixelData[i * 4 + 2] = rgb[2];
307
- palettePixelData[i * 4 + 3] = 255;
308
- }
309
- }
310
- gl.viewport(0, 0, width, height);
311
- gl.clearColor(0, 0, 0, 0);
312
- gl.clear(gl.COLOR_BUFFER_BIT);
313
- gl.useProgram(program);
314
- gl.bindVertexArray(vao);
315
- gl.activeTexture(gl.TEXTURE0);
316
- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
317
- if (paletteDirty) {
318
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, r.colors.length, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, state.palettePixelData);
319
- }
320
- if (uColorPalette)
321
- gl.uniform1i(uColorPalette, 0);
322
- if (uNumRays)
323
- gl.uniform1f(uNumRays, r.rays);
324
- if (uNumColors)
325
- gl.uniform1f(uNumColors, r.colors.length);
326
- if (uRotationOffset)
327
- gl.uniform1f(uRotationOffset, rotationRad);
328
- if (uSmoothEdge)
329
- gl.uniform1f(uSmoothEdge, r.smoothness);
330
- if (uOrigin)
331
- gl.uniform2f(uOrigin, r.origin[0], 1 - r.origin[1]);
332
- if (uResolution)
333
- gl.uniform2f(uResolution, width, height);
334
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
335
- gl.bindVertexArray(null);
336
- gl.bindTexture(gl.TEXTURE_2D, null);
337
- gl.useProgram(null);
338
- },
339
- cleanup: ({ gl, program, vao, vbo, paletteTexture }) => {
340
- gl.deleteBuffer(vbo);
341
- gl.deleteProgram(program);
342
- gl.deleteVertexArray(vao);
343
- gl.deleteTexture(paletteTexture);
344
- },
345
- schema: starburstEffectSchema,
346
- validateParams: validateStarburstEffectParams
347
- });
2
+ import {
3
+ starburst,
4
+ starburstEffectSchema
5
+ } from "@remotion/effects/starburst";
348
6
 
349
7
  // src/Starburst.tsx
350
8
  import { useCallback, useEffect, useRef, useState } from "react";
351
9
  import {
352
10
  AbsoluteFill,
353
- Internals as Internals2,
11
+ Internals,
354
12
  Interactive,
355
13
  Sequence,
356
14
  useDelayRender,
357
15
  useVideoConfig
358
16
  } from "remotion";
17
+
18
+ // src/color-to-rgb.ts
19
+ import { NoReactInternals } from "remotion/no-react";
20
+ var colorToRgb = (color) => {
21
+ const packed = NoReactInternals.processColor(color);
22
+ return [packed >>> 16 & 255, packed >>> 8 & 255, packed & 255];
23
+ };
24
+
25
+ // src/Starburst.tsx
359
26
  import { jsx } from "react/jsx-runtime";
360
27
  var VERTEX_SHADER = `
361
28
  attribute vec2 position;
@@ -543,7 +210,7 @@ var StarburstCanvas = ({
543
210
  });
544
211
  };
545
212
  var starburstSchema = {
546
- ...Internals2.baseSchema,
213
+ ...Internals.baseSchema,
547
214
  rays: {
548
215
  type: "number",
549
216
  min: 2,
@@ -609,10 +276,10 @@ var starburstSchema = {
609
276
  description: "Origin Offset Y",
610
277
  hiddenFromList: false
611
278
  },
612
- ...Internals2.transformSchema,
279
+ ...Internals.transformSchema,
613
280
  ...Interactive.backgroundSchema,
614
281
  ...Interactive.borderSchema,
615
- ...Internals2.premountSchema
282
+ ...Internals.premountSchema
616
283
  };
617
284
  var StarburstInner = ({
618
285
  rays,
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { Starburst } from './Starburst';
2
2
  export type { StarburstProps } from './Starburst';
3
3
  export { starburst, starburstEffectSchema, type StarburstEffectParams, type StarburstOrigin, } from './starburst-effect';
4
4
  export declare const StarburstInternals: {
5
- readonly starburst: (params: import("./starburst-effect").StarburstEffectParams & {
5
+ readonly starburst: (params: import("@remotion/effects/starburst").StarburstEffectParams & {
6
6
  readonly disabled?: boolean | undefined;
7
7
  }) => import("remotion").EffectDescriptor<unknown>;
8
8
  };
@@ -1,59 +1 @@
1
- export declare const starburstEffectSchema: {
2
- readonly rays: {
3
- readonly type: "number";
4
- readonly min: 2;
5
- readonly max: 100;
6
- readonly step: 1;
7
- readonly default: undefined;
8
- readonly description: "Number of Rays";
9
- readonly hiddenFromList: false;
10
- };
11
- readonly colors: {
12
- readonly type: "array";
13
- readonly item: {
14
- readonly type: "color";
15
- };
16
- readonly default: undefined;
17
- readonly minLength: 2;
18
- readonly newItemDefault: "#ff0000";
19
- readonly description: "Colors";
20
- readonly keyframable: false;
21
- };
22
- readonly rotation: {
23
- readonly type: "number";
24
- readonly min: 0;
25
- readonly max: 360;
26
- readonly step: 1;
27
- readonly default: 0;
28
- readonly description: "Rotation";
29
- readonly hiddenFromList: false;
30
- };
31
- readonly smoothness: {
32
- readonly type: "number";
33
- readonly min: 0;
34
- readonly max: 1;
35
- readonly step: 0.01;
36
- readonly default: 0;
37
- readonly description: "Edge Smoothness";
38
- readonly hiddenFromList: false;
39
- };
40
- readonly origin: {
41
- readonly type: "uv-coordinate";
42
- readonly min: 0;
43
- readonly max: 1;
44
- readonly step: 0.01;
45
- readonly default: readonly [0.5, 0.5];
46
- readonly description: "Origin";
47
- };
48
- };
49
- export type StarburstOrigin = readonly [number, number];
50
- export type StarburstEffectParams = {
51
- readonly rays: number;
52
- readonly colors: readonly string[];
53
- readonly rotation?: number;
54
- readonly smoothness?: number;
55
- readonly origin?: StarburstOrigin;
56
- };
57
- export declare const starburst: (params: StarburstEffectParams & {
58
- readonly disabled?: boolean | undefined;
59
- }) => import("remotion").EffectDescriptor<unknown>;
1
+ export { starburst, starburstEffectSchema, type StarburstEffectParams, type StarburstOrigin, } from '@remotion/effects/starburst';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/starburst",
3
- "version": "4.0.498",
3
+ "version": "4.0.500",
4
4
  "description": "Starburst ray effect for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,8 +24,9 @@
24
24
  "url": "https://github.com/remotion-dev/remotion/issues"
25
25
  },
26
26
  "dependencies": {
27
- "remotion": "4.0.498",
28
- "zod": "4.3.6"
27
+ "@remotion/effects": "4.0.500",
28
+ "remotion": "4.0.500",
29
+ "zod": "4.4.3"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": ">=16.8.0",
@@ -42,7 +43,7 @@
42
43
  "devDependencies": {
43
44
  "react": "19.2.3",
44
45
  "react-dom": "19.2.3",
45
- "@remotion/eslint-config-internal": "4.0.498",
46
+ "@remotion/eslint-config-internal": "4.0.500",
46
47
  "eslint": "9.19.0",
47
48
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
48
49
  },