@shotstack/shotstack-studio 1.0.0 → 1.1.1

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "cpuccino",
6
6
  "dazzatron"
7
7
  ],
8
- "version": "1.0.0",
8
+ "version": "1.1.1",
9
9
  "description": "A video editing library for creating and editing videos with Shotstack",
10
10
  "type": "module",
11
11
  "main": "dist/shotstack-studio.umd.js",
@@ -31,6 +31,9 @@
31
31
  "build": "vite build && tsc --emitDeclarationOnly",
32
32
  "prepublishOnly": "npm run build"
33
33
  },
34
+ "peerDependencies": {
35
+ "@ffmpeg/ffmpeg": "^0.12.15"
36
+ },
34
37
  "devDependencies": {
35
38
  "@types/howler": "^2.2.12",
36
39
  "@types/node": "^22.9.0",
@@ -46,7 +49,6 @@
46
49
  "vite": "^5.4.10"
47
50
  },
48
51
  "dependencies": {
49
- "@ffmpeg/ffmpeg": "^0.12.15",
50
52
  "howler": "^2.2.4",
51
53
  "opentype.js": "^1.3.4",
52
54
  "pixi-filters": "^6.0.5",
package/readme.md CHANGED
@@ -6,6 +6,16 @@
6
6
 
7
7
  A JavaScript library for creating and editing videos in the browser.
8
8
 
9
+ ## Interactive Examples
10
+
11
+ Try Shotstack Studio in your preferred framework:
12
+
13
+ [![TypeScript](https://img.shields.io/badge/TypeScript-StackBlitz-blue?style=for-the-badge&logo=typescript)](https://stackblitz.com/edit/studio-sdk-typescript?file=src%2Fmain.ts)
14
+ [![React](https://img.shields.io/badge/React-StackBlitz-blue?style=for-the-badge&logo=react)](https://stackblitz.com/edit/studio-sdk-typescript?file=src%2Fmain.ts)
15
+ [![Vue](https://img.shields.io/badge/Vue-StackBlitz-blue?style=for-the-badge&logo=vue.js)](https://stackblitz.com/edit/shotstack-studio-vue?file=src%2FApp.vue)
16
+ [![Angular](https://img.shields.io/badge/Angular-StackBlitz-blue?style=for-the-badge&logo=angular)](https://stackblitz.com/edit/shotstack-studio-angular?file=src%2Fmain.ts)
17
+ [![Next.js](https://img.shields.io/badge/Next.js-StackBlitz-blue?style=for-the-badge&logo=next.js)](https://stackblitz.com/edit/shotstack-studio-nextjs?file=app%2Fpage.tsx)
18
+
9
19
  ## Installation
10
20
 
11
21
  ```bash
@@ -16,14 +26,23 @@ npm install @shotstack/shotstack-studio
16
26
  yarn add @shotstack/shotstack-studio
17
27
  ```
18
28
 
29
+ ### FFmpeg (peer dependency)
30
+
31
+ Install FFmpeg to use the browser based `VideoExporter` class. This is kept separate to prevent WASM / Web Worker clashes in frameworks like Next.js.
32
+
33
+ ```bash
34
+ npm install @ffmpeg/ffmpeg
35
+ ```
36
+
37
+ You can skip this if you're using the [Shotstack Edit API](https://shotstack.io/docs/guide/getting-started/hello-world-using-curl/) for rendering videos.
38
+
19
39
  ## Quick Start
20
40
 
21
41
  ```typescript
22
42
  import { Edit, Canvas, Controls } from "@shotstack/shotstack-studio";
23
- import myTemplateJson from "hello.json"
24
43
 
25
44
  // 1. Retrieve an edit from a template
26
- const templateUrl = 'https://shotstack-assets.s3.amazonaws.com/templates/hello-world/hello.json'
45
+ const templateUrl = "https://shotstack-assets.s3.amazonaws.com/templates/hello-world/hello.json";
27
46
  const response = await fetch(templateUrl);
28
47
  const template = await response.json();
29
48
 
@@ -36,7 +55,7 @@ const canvas = new Canvas(template.output.size, edit);
36
55
  await canvas.load(); // Renders to [data-shotstack-studio] element
37
56
 
38
57
  // 4. Load the template
39
- await edit.loadEdit(myTemplateJson);
58
+ await edit.loadEdit(template);
40
59
 
41
60
  // 5. Add keyboard controls
42
61
  const controls = new Controls(edit);
@@ -46,13 +65,13 @@ await controls.load();
46
65
  Your HTML should include a container with the `data-shotstack-studio` attribute:
47
66
 
48
67
  ```html
49
- <div data-shotstack-studio class="canvas-container"></div>
68
+ <div data-shotstack-studio></div>
50
69
  ```
51
70
 
52
71
  ## Features
53
72
 
54
73
  - Create video compositions with multiple tracks and clips
55
- - Use in conjunction with the Shotstack Edit API to render video
74
+ - Use in conjunction with the [Shotstack Edit API](https://shotstack.io/docs/guide/getting-started/hello-world-using-curl/) to render video
56
75
  - Export to video using browser-based FFmpeg
57
76
 
58
77
  ## Main Components
@@ -96,6 +115,23 @@ const editJson = edit.getEdit();
96
115
  const duration = edit.totalDuration; // in milliseconds
97
116
  ```
98
117
 
118
+ #### Events
119
+
120
+ The Edit class provides an event system to listen for specific actions:
121
+
122
+ ```typescript
123
+ // Listen for clip selection events
124
+ edit.events.on("clip:selected", data => {
125
+ console.log("Clip selected:", data.clip);
126
+ console.log("Track index:", data.trackIndex);
127
+ console.log("Clip index:", data.clipIndex);
128
+ });
129
+ ```
130
+
131
+ Available events:
132
+
133
+ - `clip:selected` - Emitted when a clip is selected, providing data about the clip, its track index, and clip index
134
+
99
135
  ### Canvas
100
136
 
101
137
  The Canvas class provides the visual rendering of the edit.
@@ -233,6 +269,23 @@ Creates a new Edit instance with the specified dimensions and background color.
233
269
  - `deleteTrack(trackIdx: number)` - Delete a track
234
270
  - `getEdit()` - Get the full edit configuration as a JSON object
235
271
 
272
+ #### Events
273
+
274
+ The Edit class provides an event system to listen for specific actions:
275
+
276
+ ```typescript
277
+ // Listen for clip selection events
278
+ edit.events.on("clip:selected", data => {
279
+ console.log("Clip selected:", data.clip);
280
+ console.log("Track index:", data.trackIndex);
281
+ console.log("Clip index:", data.clipIndex);
282
+ });
283
+ ```
284
+
285
+ Available events:
286
+
287
+ - `clip:selected` - Emitted when a clip is selected, providing data about the clip, its track index, and clip index
288
+
236
289
  ### Canvas
237
290
 
238
291
  The `Canvas` class provides the visual rendering of the edit.