Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"vite-plugin-dts": "^4.5.4"
},
"dependencies": {
"@shotstack/schemas": "1.11.0",
"@shotstack/schemas": "1.14.0",
"@shotstack/shotstack-canvas": "^2.10.0",
"howler": "^2.2.4",
"mediabunny": "^1.11.2",
Expand Down
7 changes: 7 additions & 0 deletions src/components/canvas/players/audio-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class AudioPlayer extends Player {
const audioClipConfiguration = this.clipConfiguration.asset as AudioAsset;

const identifier = audioClipConfiguration.src;
if (!identifier) {
// Prompt-driven audio has no src until it's generated — fail this clip's load, not the edit
throw new Error("Audio asset has no src to load.");
}
const loadOptions: pixi.UnresolvedAsset = { src: identifier, parser: AudioLoadParser.Name };
const audioResource = await this.edit.assetLoader.load<howler.Howl>(identifier, loadOptions);

Expand Down Expand Up @@ -123,6 +127,9 @@ export class AudioPlayer extends Player {
this.syncTimer = 0;

const audioAsset = this.clipConfiguration.asset as AudioAsset;
if (!audioAsset.src) {
throw new Error("Audio asset has no src to load.");
}
const loadOptions: pixi.UnresolvedAsset = { src: audioAsset.src, parser: AudioLoadParser.Name };
const audioResource = await this.edit.assetLoader.load<howler.Howl>(audioAsset.src, loadOptions);

Expand Down
4 changes: 4 additions & 0 deletions src/components/canvas/players/image-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export class ImagePlayer extends Player {
private async loadTexture(): Promise<void> {
const imageAsset = this.clipConfiguration.asset as ImageAsset;
const { src } = imageAsset;
if (!src) {
// Prompt-driven images have no src until they're generated — fail this clip's load, not the edit
throw new Error("Image asset has no src to load.");
}

const corsUrl = `${src}${src.includes("?") ? "&" : "?"}x-cors=1`;
const loadOptions: pixi.UnresolvedAsset = { src: corsUrl, crossorigin: "anonymous", data: {} };
Expand Down
4 changes: 4 additions & 0 deletions src/components/canvas/players/video-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ export class VideoPlayer extends Player {
private async loadVideo(): Promise<void> {
const videoAsset = this.clipConfiguration.asset as VideoAsset;
const { src } = videoAsset;
if (!src) {
// Generated video assets have no src until they're rendered — fail this clip's load, not the edit
throw new Error("Video asset has no src to load.");
}

if (src.endsWith(".mov")) {
throw new Error(`Video source '${src}' is not supported. .mov files cannot be played in the browser. Please convert to .webm or .mp4 first.`);
Expand Down
6 changes: 6 additions & 0 deletions src/components/timeline/media-thumbnail-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export class MediaThumbnailRenderer implements ClipRenderer {
this.clipStates.set(clipKey, state);

try {
if (!asset.src) {
throw new Error("Video asset has no src for thumbnail generation.");
}
const result = await this.generator.generateThumbnail(asset.src, asset.trim ?? 0);

// Check if element is still in DOM (might have been disposed)
Expand Down Expand Up @@ -156,6 +159,9 @@ export class MediaThumbnailRenderer implements ClipRenderer {
this.clipStates.set(clipKey, state);

try {
if (!asset.src) {
throw new Error("Image asset has no src for thumbnail generation.");
}
const result = await this.loadImageThumbnail(asset.src);

// Check if element is still in DOM (might have been disposed)
Expand Down
36 changes: 36 additions & 0 deletions tests/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,39 @@ describe("Real-world Use Cases", () => {
expect(result.success).toBe(true);
});
});

describe("API-accepted templates parse at load", () => {
// Templates created via the render API (e.g. by the MCP server) must open in the
// editor. These shapes were rejected by the previously pinned schemas version.
it("accepts text-to-speech assets with the newscaster option", () => {
const result = ClipSchema.safeParse({
asset: { type: "text-to-speech", text: "Tonight's headlines", voice: "Matthew", newscaster: true },
start: 0,
length: 5
});
expect(result.success).toBe(true);
});

it("accepts prompt-driven audio assets with voice and newscaster", () => {
const result = ClipSchema.safeParse({
asset: { type: "audio", prompt: "Read the news intro", voice: "Joanna", newscaster: true },
start: 0,
length: 5
});
expect(result.success).toBe(true);
});

it("accepts a destination without an options object", () => {
const result = EditSchema.safeParse({
timeline: {
tracks: [{ clips: [{ asset: { type: "image", src: "https://example.com/a.jpg" }, start: 0, length: 3 }] }]
},
output: {
size: { width: 1280, height: 720 },
format: "mp4",
destinations: [{ provider: "shotstack" }]
}
});
expect(result.success).toBe(true);
});
});
Loading