@vibecuting/component-project-helper 0.1.15 → 0.1.16
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
|
@@ -43,3 +43,26 @@ test('attaches normalized metadata to decorated function components', () => {
|
|
|
43
43
|
expect(decorated).toBe(SceneTitle)
|
|
44
44
|
expect(getComponentProjectComponentMetadata(SceneTitle)).toEqual(metadata)
|
|
45
45
|
})
|
|
46
|
+
|
|
47
|
+
test('attaches metadata to components with required props', () => {
|
|
48
|
+
type RequiredProps = {
|
|
49
|
+
title: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const metadata = defineComponentProjectComponentMetadata({
|
|
53
|
+
name: 'RequiredPropsScene',
|
|
54
|
+
description: 'Exercises required props support',
|
|
55
|
+
sourceFile: 'src/components/RequiredPropsScene.tsx',
|
|
56
|
+
aspectRatio: '16:9',
|
|
57
|
+
sceneType: 'scene',
|
|
58
|
+
tags: ['required', 'props'],
|
|
59
|
+
propsTypeName: 'RequiredProps',
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const RequiredPropsScene = (_props: RequiredProps) => null
|
|
63
|
+
|
|
64
|
+
const decorated = VideoComponent(metadata)(RequiredPropsScene)
|
|
65
|
+
|
|
66
|
+
expect(decorated).toBe(RequiredPropsScene)
|
|
67
|
+
expect(getComponentProjectComponentMetadata(RequiredPropsScene)).toEqual(metadata)
|
|
68
|
+
})
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata'
|
|
2
2
|
|
|
3
|
-
import type { ComponentType } from 'react'
|
|
4
|
-
|
|
5
3
|
import {
|
|
6
4
|
ComponentProjectComponentMetadataSchema,
|
|
7
5
|
type ComponentProjectComponentMetadata,
|
|
@@ -20,7 +18,7 @@ export function defineComponentProjectComponentMetadata(
|
|
|
20
18
|
export function VideoComponent(metadata: ComponentProjectComponentMetadata) {
|
|
21
19
|
const normalized = defineComponentProjectComponentMetadata(metadata)
|
|
22
20
|
|
|
23
|
-
return function componentProjectDecorator<T extends
|
|
21
|
+
return function componentProjectDecorator<T extends (...args: any[]) => unknown>(target: T): T {
|
|
24
22
|
Reflect.defineMetadata(COMPONENT_PROJECT_METADATA_KEY, normalized, target)
|
|
25
23
|
return target
|
|
26
24
|
}
|