@cntrl-site/sdk 1.14.0 → 1.16.0

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.
@@ -7,6 +7,7 @@ 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
9
  const ItemArea_1 = require("../../types/article/ItemArea");
10
+ const pointerEvents = zod_1.z.enum(['never', 'when_visible', 'always']).optional();
10
11
  exports.FXControlSchema = zod_1.z.discriminatedUnion('type', [
11
12
  zod_1.z.object({
12
13
  type: zod_1.z.literal('float'),
@@ -24,19 +25,20 @@ exports.FXControlSchema = zod_1.z.discriminatedUnion('type', [
24
25
  value: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()])
25
26
  })
26
27
  ]);
28
+ const FXParams = zod_1.z.object({
29
+ url: zod_1.z.string().min(1),
30
+ hasGLEffect: zod_1.z.boolean().optional(),
31
+ fragmentShader: zod_1.z.string().nullable(),
32
+ FXCursor: zod_1.z.object({
33
+ type: zod_1.z.enum(['mouse', 'manual']),
34
+ x: zod_1.z.number(),
35
+ y: zod_1.z.number()
36
+ }).nullable(),
37
+ FXControls: zod_1.z.array(exports.FXControlSchema).optional()
38
+ });
27
39
  const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
28
40
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Image),
29
- commonParams: zod_1.z.object({
30
- url: zod_1.z.string().min(1),
31
- hasGLEffect: zod_1.z.boolean().optional(),
32
- fragmentShader: zod_1.z.string().nullable(),
33
- FXCursor: zod_1.z.object({
34
- type: zod_1.z.enum(['mouse', 'manual']),
35
- x: zod_1.z.number(),
36
- y: zod_1.z.number()
37
- }).nullable(),
38
- FXControls: zod_1.z.array(exports.FXControlSchema).optional()
39
- }),
41
+ commonParams: FXParams,
40
42
  sticky: zod_1.z.record(zod_1.z.object({
41
43
  from: zod_1.z.number(),
42
44
  to: zod_1.z.number().optional()
@@ -53,9 +55,9 @@ const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
53
55
  const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
54
56
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Video),
55
57
  commonParams: zod_1.z.object({
56
- url: zod_1.z.string().min(1),
57
- coverUrl: zod_1.z.string().nullable()
58
- }),
58
+ coverUrl: zod_1.z.string().nullable(),
59
+ pointerEvents
60
+ }).merge(FXParams),
59
61
  sticky: zod_1.z.record(zod_1.z.object({
60
62
  from: zod_1.z.number(),
61
63
  to: zod_1.z.number().optional()
@@ -77,7 +79,8 @@ const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
77
79
  const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
78
80
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Rectangle),
79
81
  commonParams: zod_1.z.object({
80
- ratioLock: zod_1.z.boolean()
82
+ ratioLock: zod_1.z.boolean(),
83
+ pointerEvents
81
84
  }),
82
85
  sticky: zod_1.z.record(zod_1.z.object({
83
86
  from: zod_1.z.number(),
@@ -97,7 +100,8 @@ const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
97
100
  const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
98
101
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Custom),
99
102
  commonParams: zod_1.z.object({
100
- name: zod_1.z.string()
103
+ name: zod_1.z.string(),
104
+ pointerEvents
101
105
  }),
102
106
  sticky: zod_1.z.record(zod_1.z.object({
103
107
  from: zod_1.z.number(),
@@ -116,7 +120,8 @@ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
116
120
  pictureInPicture: zod_1.z.boolean(),
117
121
  url: zod_1.z.string().min(1),
118
122
  coverUrl: zod_1.z.string().nullable(),
119
- ratioLock: zod_1.z.boolean()
123
+ ratioLock: zod_1.z.boolean(),
124
+ pointerEvents
120
125
  }),
121
126
  sticky: zod_1.z.record(zod_1.z.object({
122
127
  from: zod_1.z.number(),
@@ -136,7 +141,8 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
136
141
  controls: zod_1.z.boolean(),
137
142
  loop: zod_1.z.boolean(),
138
143
  url: zod_1.z.string().min(1),
139
- coverUrl: zod_1.z.string().nullable()
144
+ coverUrl: zod_1.z.string().nullable(),
145
+ pointerEvents
140
146
  }),
141
147
  sticky: zod_1.z.record(zod_1.z.object({
142
148
  from: zod_1.z.number(),
@@ -154,7 +160,8 @@ const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
154
160
  commonParams: zod_1.z.object({
155
161
  html: zod_1.z.string(),
156
162
  scale: zod_1.z.boolean(),
157
- iframe: zod_1.z.boolean()
163
+ iframe: zod_1.z.boolean(),
164
+ pointerEvents
158
165
  }),
159
166
  sticky: zod_1.z.record(zod_1.z.object({
160
167
  from: zod_1.z.number(),
@@ -178,7 +185,9 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
178
185
  CodeEmbedItemSchema,
179
186
  ItemBase_schema_1.ItemBaseSchema.extend({
180
187
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
181
- commonParams: zod_1.z.object({}),
188
+ commonParams: zod_1.z.object({
189
+ pointerEvents
190
+ }),
182
191
  items: zod_1.z.array(exports.ItemSchema),
183
192
  sticky: zod_1.z.record(zod_1.z.object({
184
193
  from: zod_1.z.number(),
@@ -193,6 +202,7 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
193
202
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Compound),
194
203
  commonParams: zod_1.z.object({
195
204
  overflow: zod_1.z.enum(['hidden', 'visible']),
205
+ pointerEvents,
196
206
  }),
197
207
  items: zod_1.z.array(exports.ItemSchema),
198
208
  sticky: zod_1.z.record(zod_1.z.object({
@@ -8,9 +8,6 @@ exports.Link = zod_1.z.object({
8
8
  url: zod_1.z.string().min(1),
9
9
  target: zod_1.z.string().min(1)
10
10
  });
11
- const CommonParamsBase = zod_1.z.object({
12
- sizing: zod_1.z.string().min(1)
13
- });
14
11
  exports.CompoundSettingsSchema = zod_1.z.object({
15
12
  positionAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor),
16
13
  widthMode: zod_1.z.nativeEnum(ItemArea_1.DimensionMode),
@@ -21,7 +18,6 @@ exports.ItemBaseSchema = zod_1.z.object({
21
18
  area: zod_1.z.record(ItemArea_schema_1.ItemAreaSchema),
22
19
  hidden: zod_1.z.record(zod_1.z.boolean()),
23
20
  link: exports.Link.optional(),
24
- commonParams: CommonParamsBase,
25
21
  compoundSettings: zod_1.z.record(exports.CompoundSettingsSchema).optional(),
26
22
  layoutParams: zod_1.z.record(zod_1.z.any()).optional()
27
23
  });
@@ -6,6 +6,7 @@ const RichText_1 = require("../../types/article/RichText");
6
6
  const ItemBase_schema_1 = require("./ItemBase.schema");
7
7
  const ArticleItemType_1 = require("../../types/article/ArticleItemType");
8
8
  const ItemState_schema_1 = require("./ItemState.schema");
9
+ const pointerEvents = zod_1.z.enum(['never', 'when_visible', 'always']).optional();
9
10
  exports.RichTextEntitySchema = zod_1.z.object({
10
11
  start: zod_1.z.number().nonnegative(),
11
12
  end: zod_1.z.number().nonnegative(),
@@ -30,7 +31,8 @@ exports.RichTextItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
30
31
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.RichText),
31
32
  commonParams: zod_1.z.object({
32
33
  text: zod_1.z.string(),
33
- blocks: zod_1.z.array(exports.RichTextBlockSchema).optional()
34
+ blocks: zod_1.z.array(exports.RichTextBlockSchema).optional(),
35
+ pointerEvents
34
36
  }),
35
37
  sticky: zod_1.z.record(zod_1.z.object({
36
38
  from: zod_1.z.number(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -22,6 +22,8 @@ import { ArticleItemType } from '../../types/article/ArticleItemType';
22
22
  import { FXControlAny } from '../../types/article/FX';
23
23
  import { AreaAnchor } from '../../types/article/ItemArea';
24
24
 
25
+ const pointerEvents = z.enum(['never', 'when_visible', 'always']).optional();
26
+
25
27
  export const FXControlSchema = z.discriminatedUnion('type',[
26
28
  z.object({
27
29
  type: z.literal('float'),
@@ -40,19 +42,21 @@ export const FXControlSchema = z.discriminatedUnion('type',[
40
42
  })
41
43
  ]) satisfies ZodType<FXControlAny>;
42
44
 
45
+ const FXParams = z.object({
46
+ url: z.string().min(1),
47
+ hasGLEffect: z.boolean().optional(),
48
+ fragmentShader: z.string().nullable(),
49
+ FXCursor: z.object({
50
+ type: z.enum(['mouse', 'manual']),
51
+ x: z.number(),
52
+ y: z.number()
53
+ }).nullable(),
54
+ FXControls: z.array(FXControlSchema).optional()
55
+ });
56
+
43
57
  const ImageItemSchema = ItemBaseSchema.extend({
44
58
  type: z.literal(ArticleItemType.Image),
45
- commonParams: z.object({
46
- url: z.string().min(1),
47
- hasGLEffect: z.boolean().optional(),
48
- fragmentShader: z.string().nullable(),
49
- FXCursor: z.object({
50
- type: z.enum(['mouse', 'manual']),
51
- x: z.number(),
52
- y: z.number()
53
- }).nullable(),
54
- FXControls: z.array(FXControlSchema).optional()
55
- }),
59
+ commonParams: FXParams,
56
60
  sticky: z.record(
57
61
  z.object({
58
62
  from: z.number(),
@@ -74,9 +78,9 @@ const ImageItemSchema = ItemBaseSchema.extend({
74
78
  const VideoItemSchema = ItemBaseSchema.extend({
75
79
  type: z.literal(ArticleItemType.Video),
76
80
  commonParams: z.object({
77
- url: z.string().min(1),
78
- coverUrl: z.string().nullable()
79
- }),
81
+ coverUrl: z.string().nullable(),
82
+ pointerEvents
83
+ }).merge(FXParams),
80
84
  sticky: z.record(
81
85
  z.object({
82
86
  from: z.number(),
@@ -103,7 +107,8 @@ const VideoItemSchema = ItemBaseSchema.extend({
103
107
  const RectangleItemSchema = ItemBaseSchema.extend({
104
108
  type: z.literal(ArticleItemType.Rectangle),
105
109
  commonParams: z.object({
106
- ratioLock: z.boolean()
110
+ ratioLock: z.boolean(),
111
+ pointerEvents
107
112
  }),
108
113
  sticky: z.record(
109
114
  z.object({
@@ -128,7 +133,8 @@ const RectangleItemSchema = ItemBaseSchema.extend({
128
133
  const CustomItemSchema = ItemBaseSchema.extend({
129
134
  type: z.literal(ArticleItemType.Custom),
130
135
  commonParams: z.object({
131
- name: z.string()
136
+ name: z.string(),
137
+ pointerEvents
132
138
  }),
133
139
  sticky: z.record(
134
140
  z.object({
@@ -150,7 +156,8 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
150
156
  pictureInPicture: z.boolean(),
151
157
  url: z.string().min(1),
152
158
  coverUrl: z.string().nullable(),
153
- ratioLock: z.boolean()
159
+ ratioLock: z.boolean(),
160
+ pointerEvents
154
161
  }),
155
162
  sticky: z.record(
156
163
  z.object({
@@ -175,7 +182,8 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
175
182
  controls: z.boolean(),
176
183
  loop: z.boolean(),
177
184
  url: z.string().min(1),
178
- coverUrl: z.string().nullable()
185
+ coverUrl: z.string().nullable(),
186
+ pointerEvents
179
187
  }),
180
188
  sticky: z.record(
181
189
  z.object({
@@ -198,7 +206,8 @@ const CodeEmbedItemSchema = ItemBaseSchema.extend({
198
206
  commonParams: z.object({
199
207
  html: z.string(),
200
208
  scale: z.boolean(),
201
- iframe: z.boolean()
209
+ iframe: z.boolean(),
210
+ pointerEvents
202
211
  }),
203
212
  sticky: z.record(
204
213
  z.object({
@@ -227,7 +236,9 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
227
236
  CodeEmbedItemSchema,
228
237
  ItemBaseSchema.extend({
229
238
  type: z.literal(ArticleItemType.Group),
230
- commonParams: z.object({}),
239
+ commonParams: z.object({
240
+ pointerEvents
241
+ }),
231
242
  items: z.array(ItemSchema),
232
243
  sticky: z.record(
233
244
  z.object({
@@ -246,6 +257,7 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
246
257
  type: z.literal(ArticleItemType.Compound),
247
258
  commonParams: z.object({
248
259
  overflow: z.enum(['hidden', 'visible']),
260
+ pointerEvents,
249
261
  }),
250
262
  items: z.array(ItemSchema),
251
263
  sticky: z.record(
@@ -7,10 +7,6 @@ export const Link = z.object({
7
7
  target: z.string().min(1)
8
8
  });
9
9
 
10
- const CommonParamsBase = z.object({
11
- sizing: z.string().min(1)
12
- });
13
-
14
10
  export const CompoundSettingsSchema = z.object({
15
11
  positionAnchor: z.nativeEnum(AreaAnchor),
16
12
  widthMode: z.nativeEnum(DimensionMode),
@@ -22,7 +18,6 @@ export const ItemBaseSchema = z.object({
22
18
  area: z.record(ItemAreaSchema),
23
19
  hidden: z.record(z.boolean()),
24
20
  link: Link.optional(),
25
- commonParams: CommonParamsBase,
26
21
  compoundSettings: z.record(CompoundSettingsSchema).optional(),
27
22
  layoutParams: z.record(z.any()).optional()
28
23
  });
@@ -5,6 +5,8 @@ import { ArticleItemType } from '../../types/article/ArticleItemType';
5
5
  import { RichTextStateParamsSchema } from './ItemState.schema';
6
6
  import { RichTextItem } from '../../types/article/Item';
7
7
 
8
+ const pointerEvents = z.enum(['never', 'when_visible', 'always']).optional();
9
+
8
10
  export const RichTextEntitySchema = z.object({
9
11
  start: z.number().nonnegative(),
10
12
  end: z.number().nonnegative(),
@@ -34,7 +36,8 @@ export const RichTextItemSchema = ItemBaseSchema.extend({
34
36
  type: z.literal(ArticleItemType.RichText),
35
37
  commonParams: z.object({
36
38
  text: z.string(),
37
- blocks: z.array(RichTextBlockSchema).optional()
39
+ blocks: z.array(RichTextBlockSchema).optional(),
40
+ pointerEvents
38
41
  }),
39
42
  sticky: z.record(
40
43
  z.object({
@@ -47,47 +47,50 @@ export interface ItemLayoutParamsMap {
47
47
  [ArticleItemType.CodeEmbed]: CodeEmbedLayoutParams;
48
48
  }
49
49
 
50
- interface MediaCommonParams {
51
- url: string;
52
- }
53
-
54
- interface VideoCommonParams extends MediaCommonParams {
55
- coverUrl: string | null;
50
+ interface CommonParamsBase {
51
+ pointerEvents?: 'never' | 'when_visible' | 'always';
56
52
  }
57
53
 
58
- interface ImageCommonParams extends MediaCommonParams {
54
+ interface MediaCommonParams extends CommonParamsBase {
55
+ url: string;
59
56
  hasGLEffect?: boolean;
60
57
  fragmentShader: string | null;
61
58
  FXCursor: FXCursor | null;
62
59
  FXControls?: FXControlAny[];
63
60
  }
64
61
 
65
- interface RichTextCommonParams {
62
+ interface VideoCommonParams extends MediaCommonParams {
63
+ coverUrl: string | null;
64
+ }
65
+
66
+ interface ImageCommonParams extends MediaCommonParams {}
67
+
68
+ interface RichTextCommonParams extends CommonParamsBase {
66
69
  text: string;
67
70
  blocks?: RichTextBlock[];
68
71
  }
69
72
 
70
- interface RectangleCommonParams {
73
+ interface RectangleCommonParams extends CommonParamsBase {
71
74
  ratioLock: boolean;
72
75
  }
73
76
 
74
- interface CustomCommonParams {
77
+ interface CustomCommonParams extends CommonParamsBase {
75
78
  name: string;
76
79
  }
77
80
 
78
- interface GroupCommonParams {}
81
+ interface GroupCommonParams extends CommonParamsBase {}
79
82
 
80
- interface CompoundCommonParams {
83
+ interface CompoundCommonParams extends CommonParamsBase {
81
84
  overflow: 'hidden' | 'visible';
82
85
  }
83
86
 
84
- interface CodeEmbedCommonParams {
87
+ interface CodeEmbedCommonParams extends CommonParamsBase {
85
88
  html: string;
86
89
  scale: boolean;
87
90
  iframe: boolean;
88
91
  }
89
92
 
90
- interface VimeoEmbedCommonParams {
93
+ interface VimeoEmbedCommonParams extends CommonParamsBase {
91
94
  play: 'on-hover' | 'on-click' | 'auto';
92
95
  controls: boolean;
93
96
  loop: boolean;
@@ -97,7 +100,7 @@ interface VimeoEmbedCommonParams {
97
100
  coverUrl: string | null;
98
101
  }
99
102
 
100
- interface YoutubeEmbedCommonParams {
103
+ interface YoutubeEmbedCommonParams extends CommonParamsBase {
101
104
  play: 'on-hover' | 'on-click' | 'auto';
102
105
  controls: boolean;
103
106
  loop: boolean;
Binary file