@lalalic/markcut 3.2.41 → 3.2.42
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.
|
@@ -10,6 +10,10 @@ export function SharedPlayer({root, playerRef, ...props}: {root:any;playerRef?:R
|
|
|
10
10
|
return <Player ref={playerRef as any} component={MarkCut} inputProps={inputProps}
|
|
11
11
|
durationInFrames={durationInFrames} fps={fps}
|
|
12
12
|
compositionWidth={root?.width||1080} compositionHeight={root?.height||1920}
|
|
13
|
+
errorFallback={({error}) => <div data-testid="markcut-player-error" role="alert" style={{
|
|
14
|
+
color:"#fff",background:"#471818",fontSize:16,padding:24,whiteSpace:"pre-wrap",overflowWrap:"anywhere",
|
|
15
|
+
width:"100%",height:"100%",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",
|
|
16
|
+
}}>{"Playback error: "+String(error?.message||error).slice(0,800)}</div>}
|
|
13
17
|
controls={true} showPlaybackRateControl={true} allowFullscreen={true}
|
|
14
18
|
clickToPlay={false} doubleClickToFullscreen={true} autoPlay={false} {...props}/>;
|
|
15
19
|
}
|
package/src/types/Scene.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { ComposeContext, AudioContext, useFrameEvents } from "../context/index";
|
|
|
13
13
|
import { cssJS, toClassName } from "../utils/index";
|
|
14
14
|
import type { Scene as SceneStream } from "../schema/index";
|
|
15
15
|
import { FolderLeaf } from "./Folder";
|
|
16
|
+
import { remotionFolderName } from "./remotion-folder-name";
|
|
16
17
|
|
|
17
18
|
export function SceneLeaf({ stream }: { stream: SceneStream }) {
|
|
18
19
|
const { Container } = React.useContext(ComposeContext);
|
|
@@ -33,7 +34,7 @@ export function SceneLeaf({ stream }: { stream: SceneStream }) {
|
|
|
33
34
|
style={cssJS(stream.style) as React.CSSProperties}
|
|
34
35
|
className={`scene ${toClassName(stream.name ?? "")}`}
|
|
35
36
|
>
|
|
36
|
-
<Folder name={stream.name
|
|
37
|
+
<Folder name={remotionFolderName(stream.name, stream.id)}>
|
|
37
38
|
<FolderLeaf stream={stream as any} />
|
|
38
39
|
</Folder>
|
|
39
40
|
</Container>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Remotion's <Folder> accepts only ASCII letters, digits, '-', and basic CJK.
|
|
2
|
+
// This is an internal timeline label, not the authored scene name or review ID.
|
|
3
|
+
const VALID_NAME = /^[a-zA-Z0-9\u4E00-\u9FFF-]+$/;
|
|
4
|
+
function safePart(value: string, limit: number): string {
|
|
5
|
+
return value.normalize("NFKC")
|
|
6
|
+
.replace(/[^a-zA-Z0-9\u4E00-\u9FFF-]+/g, "-")
|
|
7
|
+
.replace(/-+/g, "-")
|
|
8
|
+
.replace(/^-+|-+$/g, "")
|
|
9
|
+
.slice(0, limit)
|
|
10
|
+
.replace(/-+$/g, "");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function remotionFolderName(name?: string, id?: string): string {
|
|
14
|
+
const authored = (name ?? "").trim();
|
|
15
|
+
if (VALID_NAME.test(authored)) return authored;
|
|
16
|
+
const base = safePart(authored, 80) || "Scene";
|
|
17
|
+
const suffix = safePart(id ?? "", 24);
|
|
18
|
+
return suffix ? `${base}-${suffix}` : base;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {describe,expect,it} from "vitest";
|
|
2
|
+
import {remotionFolderName} from "../src/types/remotion-folder-name";
|
|
3
|
+
|
|
4
|
+
const accepted=/^[a-zA-Z0-9\u4E00-\u9FFF-]+$/;
|
|
5
|
+
describe("Remotion scene folder name",()=>{
|
|
6
|
+
it("preserves valid authored names",()=>{
|
|
7
|
+
expect(remotionFolderName("Opening-Long","a1")).toBe("Opening-Long");
|
|
8
|
+
expect(remotionFolderName("湖边","a2")).toBe("湖边");
|
|
9
|
+
});
|
|
10
|
+
it("sanitizes names rejected by Remotion without altering source metadata",()=>{
|
|
11
|
+
for(const [name,id] of [
|
|
12
|
+
["Opening_Long","xxvsny5a"],["Scene with spaces","id-1"],["emoji 🎬 !","scene-3"],
|
|
13
|
+
["シーン 一","scene-4"],["/","scene-5"],["","scene-6"],
|
|
14
|
+
]){
|
|
15
|
+
const safe=remotionFolderName(name,id);
|
|
16
|
+
expect(safe).toMatch(accepted);
|
|
17
|
+
expect(safe).not.toContain("_");
|
|
18
|
+
expect(remotionFolderName(name,id)).toBe(safe);
|
|
19
|
+
}
|
|
20
|
+
expect(remotionFolderName("Opening_Long","xxvsny5a")).toBe("Opening-Long-xxvsny5a");
|
|
21
|
+
});
|
|
22
|
+
it("keeps distinct invalid names distinct when IDs differ",()=>{
|
|
23
|
+
expect(remotionFolderName("A_B","id1")).not.toBe(remotionFolderName("A B","id2"));
|
|
24
|
+
});
|
|
25
|
+
});
|