@cntrl-site/sdk 1.6.0 → 1.7.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.
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ItemSchema = void 0;
|
|
3
|
+
exports.ItemSchema = exports.FXControlSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const ItemState_schema_1 = require("./ItemState.schema");
|
|
6
6
|
const RichTextItem_schema_1 = require("./RichTextItem.schema");
|
|
7
7
|
const ItemBase_schema_1 = require("./ItemBase.schema");
|
|
8
8
|
const ArticleItemType_1 = require("../../types/article/ArticleItemType");
|
|
9
|
+
exports.FXControlSchema = zod_1.z.discriminatedUnion('type', [
|
|
10
|
+
zod_1.z.object({
|
|
11
|
+
type: zod_1.z.literal('float'),
|
|
12
|
+
shaderParam: zod_1.z.string(),
|
|
13
|
+
value: zod_1.z.number()
|
|
14
|
+
}),
|
|
15
|
+
zod_1.z.object({
|
|
16
|
+
type: zod_1.z.literal('int'),
|
|
17
|
+
shaderParam: zod_1.z.string(),
|
|
18
|
+
value: zod_1.z.number()
|
|
19
|
+
}),
|
|
20
|
+
zod_1.z.object({
|
|
21
|
+
type: zod_1.z.literal('vec2'),
|
|
22
|
+
shaderParam: zod_1.z.string(),
|
|
23
|
+
value: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()])
|
|
24
|
+
})
|
|
25
|
+
]);
|
|
9
26
|
const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
10
27
|
type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Image),
|
|
11
28
|
commonParams: zod_1.z.object({
|
|
@@ -16,7 +33,8 @@ const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
16
33
|
type: zod_1.z.enum(['mouse', 'manual']),
|
|
17
34
|
x: zod_1.z.number(),
|
|
18
35
|
y: zod_1.z.number()
|
|
19
|
-
}).optional()
|
|
36
|
+
}).optional(),
|
|
37
|
+
FXControls: zod_1.z.array(exports.FXControlSchema).optional()
|
|
20
38
|
}),
|
|
21
39
|
sticky: zod_1.z.record(zod_1.z.object({
|
|
22
40
|
from: zod_1.z.number(),
|
package/package.json
CHANGED
|
@@ -17,6 +17,25 @@ import {
|
|
|
17
17
|
import { RichTextItemSchema } from './RichTextItem.schema';
|
|
18
18
|
import { ItemBaseSchema } from './ItemBase.schema';
|
|
19
19
|
import { ArticleItemType } from '../../types/article/ArticleItemType';
|
|
20
|
+
import { FXControlAny } from '../../types/article/FX';
|
|
21
|
+
|
|
22
|
+
export const FXControlSchema = z.discriminatedUnion('type',[
|
|
23
|
+
z.object({
|
|
24
|
+
type: z.literal('float'),
|
|
25
|
+
shaderParam: z.string(),
|
|
26
|
+
value: z.number()
|
|
27
|
+
}),
|
|
28
|
+
z.object({
|
|
29
|
+
type: z.literal('int'),
|
|
30
|
+
shaderParam: z.string(),
|
|
31
|
+
value: z.number()
|
|
32
|
+
}),
|
|
33
|
+
z.object({
|
|
34
|
+
type: z.literal('vec2'),
|
|
35
|
+
shaderParam: z.string(),
|
|
36
|
+
value: z.tuple([z.number(), z.number()])
|
|
37
|
+
})
|
|
38
|
+
]) satisfies ZodType<FXControlAny>;
|
|
20
39
|
|
|
21
40
|
const ImageItemSchema = ItemBaseSchema.extend({
|
|
22
41
|
type: z.literal(ArticleItemType.Image),
|
|
@@ -28,7 +47,8 @@ const ImageItemSchema = ItemBaseSchema.extend({
|
|
|
28
47
|
type: z.enum(['mouse', 'manual']),
|
|
29
48
|
x: z.number(),
|
|
30
49
|
y: z.number()
|
|
31
|
-
}).optional()
|
|
50
|
+
}).optional(),
|
|
51
|
+
FXControls: z.array(FXControlSchema).optional()
|
|
32
52
|
}),
|
|
33
53
|
sticky: z.record(
|
|
34
54
|
z.object({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type FXControlType = 'float' | 'int' | 'vec2';
|
|
2
|
+
export type FXControlInput = 'knob' | 'matrix2d' | 'slider';
|
|
3
|
+
|
|
4
|
+
export interface FXCursor {
|
|
5
|
+
type: 'mouse' | 'manual';
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FXControlValuesMap {
|
|
11
|
+
'float': number;
|
|
12
|
+
'int': number;
|
|
13
|
+
'vec2': [number, number];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface FXControlTypeMap {
|
|
17
|
+
'float': 'knob' | 'slider';
|
|
18
|
+
'int': 'knob';
|
|
19
|
+
'vec2': 'matrix2d';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FXControl<Type extends FXControlType, Input extends FXControlTypeMap[Type]> {
|
|
23
|
+
type: Type;
|
|
24
|
+
shaderParam: string;
|
|
25
|
+
value: FXControlValuesMap[Type];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type FXControlAny = FXControl<FXControlType, FXControlInput>;
|
|
@@ -2,6 +2,7 @@ import { RichTextBlock, RichTextStyle, TextAlign, TextDecoration, TextTransform,
|
|
|
2
2
|
import { ArticleItemType } from './ArticleItemType';
|
|
3
3
|
import { ItemArea } from './ItemArea';
|
|
4
4
|
import { ItemState } from './ItemState';
|
|
5
|
+
import { FXControlAny, FXCursor } from './FX';
|
|
5
6
|
|
|
6
7
|
export type ItemAny = Item<ArticleItemType>;
|
|
7
8
|
|
|
@@ -44,18 +45,13 @@ interface MediaCommonParams {
|
|
|
44
45
|
url: string;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
interface FXCursor {
|
|
48
|
-
type: 'mouse' | 'manual';
|
|
49
|
-
x: number;
|
|
50
|
-
y: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
interface VideoCommonParams extends MediaCommonParams {}
|
|
54
49
|
|
|
55
50
|
interface ImageCommonParams extends MediaCommonParams {
|
|
56
51
|
hasGLEffect?: boolean;
|
|
57
52
|
fragmentShader?: string;
|
|
58
53
|
FXCursor?: FXCursor;
|
|
54
|
+
FXControls?: FXControlAny[];
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
interface RichTextCommonParams {
|