@vibecuting/component-project-helper 0.1.135 → 0.1.137

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecuting/component-project-helper",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "main": "./src/index.ts",
@@ -8,6 +8,7 @@ import {
8
8
  VIDEO_RESOURCE_METADATA_KEY,
9
9
  createVideoResourceAnnotation,
10
10
  defineScenePluginMetadata as defineScenePluginMetadataBase,
11
+ inferSceneMotion,
11
12
  defineThemePluginMetadata as defineThemePluginMetadataBase,
12
13
  defineTransitionPluginMetadata as defineTransitionPluginMetadataBase,
13
14
  getVideoResourceMetadata,
@@ -31,7 +32,11 @@ export type ComponentProjectComponentMetadata = LegacyComponentProjectComponentM
31
32
  export function defineComponentProjectComponentMetadata(
32
33
  metadata: ComponentProjectComponentMetadata,
33
34
  ): ComponentProjectComponentMetadata {
34
- return ComponentProjectComponentMetadataSchema.parse(metadata) as ComponentProjectComponentMetadata
35
+ const parsed = ComponentProjectComponentMetadataSchema.parse(metadata)
36
+ return {
37
+ ...parsed,
38
+ motion: parsed.motion ?? inferSceneMotion(parsed),
39
+ } as ComponentProjectComponentMetadata
35
40
  }
36
41
 
37
42
  const sceneAnnotation = createVideoResourceAnnotation(sceneResourceDescriptor)
@@ -42,7 +47,7 @@ function normalizeSceneMetadata(
42
47
  metadata: ComponentProjectComponentMetadata | ScenePluginMetadata,
43
48
  ): ScenePluginMetadata {
44
49
  if ('resourceKind' in metadata) {
45
- return ScenePluginMetadataSchema.parse(metadata)
50
+ return defineScenePluginMetadataBase(metadata)
46
51
  }
47
52
 
48
53
  return ScenePluginMetadataSchema.parse({
@@ -52,6 +57,7 @@ function normalizeSceneMetadata(
52
57
  sourceFile: metadata.sourceFile,
53
58
  aspectRatio: metadata.aspectRatio,
54
59
  sceneType: metadata.sceneType,
60
+ motion: inferSceneMotion(metadata),
55
61
  sceneFamily: 'custom',
56
62
  themePreset: undefined,
57
63
  slots: undefined,
@@ -71,6 +77,7 @@ export const TransitionComponent = transitionAnnotation.annotate
71
77
  export const ThemeComponent = themeAnnotation.annotate
72
78
 
73
79
  export const defineScenePluginMetadata = defineScenePluginMetadataBase
80
+ export { inferSceneMotion }
74
81
  export const defineTransitionPluginMetadata = defineTransitionPluginMetadataBase
75
82
  export const defineThemePluginMetadata = defineThemePluginMetadataBase
76
83
 
@@ -10,6 +10,8 @@ import {
10
10
  type TransitionPluginMetadata,
11
11
  type VideoResourceDescriptor,
12
12
  type VideoResourceMetadata,
13
+ defineScenePluginMetadata,
14
+ inferSceneMotion,
13
15
  ScenePluginMetadataSchema,
14
16
  } from '../resources/video-resource.ts'
15
17
  import {
@@ -358,7 +360,13 @@ function collectMetadataVariables(sourceFile: ts.SourceFile): Map<string, ts.Exp
358
360
  function normalizeSceneMetadata(value: unknown, filePath: string): ScenePluginMetadata {
359
361
  const modern = ScenePluginMetadataSchema.safeParse(value)
360
362
  if (modern.success) {
361
- return modern.data
363
+ const explicitMotion = value && typeof value === 'object' && 'motion' in value ? value.motion : undefined
364
+ return defineScenePluginMetadata({
365
+ ...modern.data,
366
+ motion: explicitMotion === 'animated' || explicitMotion === 'static'
367
+ ? explicitMotion
368
+ : inferSceneMotion(modern.data),
369
+ })
362
370
  }
363
371
 
364
372
  const legacy = ComponentProjectComponentMetadataSchema.safeParse(value)
@@ -366,7 +374,7 @@ function normalizeSceneMetadata(value: unknown, filePath: string): ScenePluginMe
366
374
  throw new Error(`${filePath}: invalid scene metadata`)
367
375
  }
368
376
 
369
- return ScenePluginMetadataSchema.parse({
377
+ return defineScenePluginMetadata({
370
378
  resourceKind: 'scene',
371
379
  name: legacy.data.name,
372
380
  description: legacy.data.description,
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export {
2
2
  VIDEO_RESOURCE_METADATA_KEY,
3
3
  BaseVideoResourceMetadataSchema,
4
4
  ScenePluginMetadataSchema,
5
+ SceneMotionSchema,
5
6
  SceneSlotsSchema,
6
7
  SceneSlotHintSchema,
7
8
  ThemePluginMetadataSchema,
@@ -11,6 +12,7 @@ export {
11
12
  createVideoResourceAnnotation,
12
13
  getVideoResourceMetadata,
13
14
  type ScenePluginMetadata,
15
+ type ScenePluginMetadataInput,
14
16
  type SceneSlotHint,
15
17
  type ThemePluginMetadata,
16
18
  type TransitionPluginMetadata,
@@ -45,6 +47,7 @@ export {
45
47
  VideoComponent,
46
48
  defineComponentProjectComponentMetadata,
47
49
  defineScenePluginMetadata,
50
+ inferSceneMotion,
48
51
  defineThemePluginMetadata,
49
52
  defineTransitionPluginMetadata,
50
53
  getScenePluginMetadata,
@@ -20,6 +20,7 @@ type VideoResourceMetaRecord = {
20
20
  tags: string[]
21
21
  aspectRatio?: '9:16' | '16:9'
22
22
  sceneType?: 'intro' | 'scene' | 'outro'
23
+ motion?: 'static' | 'animated'
23
24
  sceneFamily?: string
24
25
  themePreset?: string
25
26
  slots?: Array<string | {
@@ -132,6 +133,7 @@ function renderSceneMetadata(record: VideoResourceMetaRecord): string {
132
133
  `- resourceKind: ${metadata.resourceKind}`,
133
134
  ` aspectRatio: ${metadata.aspectRatio ?? ''}`,
134
135
  ` sceneType: ${metadata.sceneType ?? ''}`,
136
+ ` motion: ${metadata.motion ?? 'static'}`,
135
137
  ` sceneFamily: ${metadata.sceneFamily ?? ''}`,
136
138
  ` themePreset: ${metadata.themePreset ?? ''}`,
137
139
  ` rootLayout: ${metadata.rootLayout ?? ''}`,
@@ -28,11 +28,13 @@ export const SceneSlotsSchema = z.union([
28
28
  ])
29
29
 
30
30
  const SceneFamilySchema = z.enum(['slide', 'canvas-2d', 'game-2d', 'three-3d', 'custom'])
31
+ export const SceneMotionSchema = z.enum(['static', 'animated'])
31
32
 
32
33
  export const ScenePluginMetadataSchema = BaseVideoResourceMetadataSchema.extend({
33
34
  resourceKind: z.literal('scene'),
34
35
  aspectRatio: z.enum(['9:16', '16:9']),
35
36
  sceneType: z.enum(['intro', 'scene', 'outro']).optional(),
37
+ motion: SceneMotionSchema.default('static'),
36
38
  sceneFamily: SceneFamilySchema.default('custom'),
37
39
  themePreset: z.string().min(1).optional(),
38
40
  slots: SceneSlotsSchema.optional(),
@@ -58,6 +60,7 @@ export const VideoResourceMetadataSchema = z.discriminatedUnion('resourceKind',
58
60
  ])
59
61
 
60
62
  export type ScenePluginMetadata = z.infer<typeof ScenePluginMetadataSchema>
63
+ export type ScenePluginMetadataInput = z.input<typeof ScenePluginMetadataSchema>
61
64
  export type SceneSlotHint = z.infer<typeof SceneSlotHintSchema>
62
65
  export type TransitionPluginMetadata = z.infer<typeof TransitionPluginMetadataSchema>
63
66
  export type ThemePluginMetadata = z.infer<typeof ThemePluginMetadataSchema>
@@ -128,8 +131,17 @@ export function getVideoResourceMetadata<TMetadata extends VideoResourceMetadata
128
131
  return parsed.data as TMetadata
129
132
  }
130
133
 
131
- export function defineScenePluginMetadata(input: ScenePluginMetadata): ScenePluginMetadata {
132
- return ScenePluginMetadataSchema.parse(input)
134
+ export function inferSceneMotion(input: Pick<ScenePluginMetadataInput, 'name' | 'sourceFile'>): z.infer<typeof SceneMotionSchema> {
135
+ return input.name.endsWith('Animated') && /(?:^|\/)animated(?:\/|$)/u.test(input.sourceFile)
136
+ ? 'animated'
137
+ : 'static'
138
+ }
139
+
140
+ export function defineScenePluginMetadata(input: ScenePluginMetadataInput): ScenePluginMetadata {
141
+ return ScenePluginMetadataSchema.parse({
142
+ ...input,
143
+ motion: input.motion ?? inferSceneMotion(input),
144
+ })
133
145
  }
134
146
 
135
147
  export function defineTransitionPluginMetadata(
@@ -25,6 +25,7 @@ const ComponentProjectComponentMetadataInputSchema = z.object({
25
25
  sourceFile: z.string().min(1),
26
26
  aspectRatio: z.enum(['9:16', '16:9']),
27
27
  sceneType: z.enum(['intro', 'scene', 'outro']).optional(),
28
+ motion: z.enum(['static', 'animated']).optional(),
28
29
  tags: z.array(z.string().min(1)).default([]),
29
30
  propsTypeName: z.string().min(1).optional(),
30
31
  })