@cntrl-site/sdk 1.13.0 → 1.15.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.
@@ -24,19 +24,20 @@ exports.FXControlSchema = zod_1.z.discriminatedUnion('type', [
24
24
  value: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()])
25
25
  })
26
26
  ]);
27
+ const FXParams = zod_1.z.object({
28
+ url: zod_1.z.string().min(1),
29
+ hasGLEffect: zod_1.z.boolean().optional(),
30
+ fragmentShader: zod_1.z.string().nullable(),
31
+ FXCursor: zod_1.z.object({
32
+ type: zod_1.z.enum(['mouse', 'manual']),
33
+ x: zod_1.z.number(),
34
+ y: zod_1.z.number()
35
+ }).nullable(),
36
+ FXControls: zod_1.z.array(exports.FXControlSchema).optional()
37
+ });
27
38
  const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
28
39
  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
- }),
40
+ commonParams: FXParams,
40
41
  sticky: zod_1.z.record(zod_1.z.object({
41
42
  from: zod_1.z.number(),
42
43
  to: zod_1.z.number().optional()
@@ -53,9 +54,8 @@ const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
53
54
  const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
54
55
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Video),
55
56
  commonParams: zod_1.z.object({
56
- url: zod_1.z.string().min(1),
57
57
  coverUrl: zod_1.z.string().nullable()
58
- }),
58
+ }).merge(FXParams),
59
59
  sticky: zod_1.z.record(zod_1.z.object({
60
60
  from: zod_1.z.number(),
61
61
  to: zod_1.z.number().optional()
@@ -188,5 +188,20 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
188
188
  opacity: zod_1.z.number().nonnegative()
189
189
  })),
190
190
  state: zod_1.z.record(zod_1.z.record(ItemState_schema_1.GroupStateParamsSchema))
191
+ }),
192
+ ItemBase_schema_1.ItemBaseSchema.extend({
193
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Compound),
194
+ commonParams: zod_1.z.object({
195
+ overflow: zod_1.z.enum(['hidden', 'visible']),
196
+ }),
197
+ items: zod_1.z.array(exports.ItemSchema),
198
+ sticky: zod_1.z.record(zod_1.z.object({
199
+ from: zod_1.z.number(),
200
+ to: zod_1.z.number().optional()
201
+ }).nullable()),
202
+ layoutParams: zod_1.z.record(zod_1.z.object({
203
+ opacity: zod_1.z.number().nonnegative()
204
+ })),
205
+ state: zod_1.z.record(zod_1.z.record(ItemState_schema_1.CompoundStateParamsSchema))
191
206
  })
192
207
  ]));
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemBaseSchema = exports.Link = void 0;
3
+ exports.ItemBaseSchema = exports.CompoundSettingsSchema = exports.Link = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ItemArea_schema_1 = require("./ItemArea.schema");
6
+ const ItemArea_1 = require("../../types/article/ItemArea");
6
7
  exports.Link = zod_1.z.object({
7
8
  url: zod_1.z.string().min(1),
8
9
  target: zod_1.z.string().min(1)
@@ -10,11 +11,17 @@ exports.Link = zod_1.z.object({
10
11
  const CommonParamsBase = zod_1.z.object({
11
12
  sizing: zod_1.z.string().min(1)
12
13
  });
14
+ exports.CompoundSettingsSchema = zod_1.z.object({
15
+ positionAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor),
16
+ widthMode: zod_1.z.nativeEnum(ItemArea_1.DimensionMode),
17
+ heightMode: zod_1.z.nativeEnum(ItemArea_1.DimensionMode),
18
+ });
13
19
  exports.ItemBaseSchema = zod_1.z.object({
14
20
  id: zod_1.z.string().min(1),
15
21
  area: zod_1.z.record(ItemArea_schema_1.ItemAreaSchema),
16
22
  hidden: zod_1.z.record(zod_1.z.boolean()),
17
23
  link: exports.Link.optional(),
18
24
  commonParams: CommonParamsBase,
25
+ compoundSettings: zod_1.z.record(exports.CompoundSettingsSchema).optional(),
19
26
  layoutParams: zod_1.z.record(zod_1.z.any()).optional()
20
27
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemStateParamsSchema = exports.CodeEmbedStateParamsSchema = exports.GroupStateParamsSchema = exports.RichTextStateParamsSchema = exports.EmbedStateParamsSchema = exports.CustomItemStateParamsSchema = exports.RectangleStateParamsSchema = exports.MediaStateParamsSchema = exports.ItemStateBaseSchema = exports.getStateParamsSchema = void 0;
3
+ exports.ItemStateParamsSchema = exports.CodeEmbedStateParamsSchema = exports.CompoundStateParamsSchema = exports.GroupStateParamsSchema = exports.RichTextStateParamsSchema = exports.EmbedStateParamsSchema = exports.CustomItemStateParamsSchema = exports.RectangleStateParamsSchema = exports.MediaStateParamsSchema = exports.ItemStateBaseSchema = exports.getStateParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const TransitionSchema = zod_1.z.object({
6
6
  timing: zod_1.z.string(),
@@ -51,6 +51,9 @@ exports.RichTextStateParamsSchema = zod_1.z.object({
51
51
  exports.GroupStateParamsSchema = zod_1.z.object({
52
52
  opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
53
53
  }).merge(exports.ItemStateBaseSchema);
54
+ exports.CompoundStateParamsSchema = zod_1.z.object({
55
+ opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
56
+ }).merge(exports.ItemStateBaseSchema);
54
57
  exports.CodeEmbedStateParamsSchema = zod_1.z.object({
55
58
  opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
56
59
  }).merge(exports.ItemStateBaseSchema);
@@ -61,5 +64,6 @@ exports.ItemStateParamsSchema = zod_1.z.union([
61
64
  exports.RichTextStateParamsSchema,
62
65
  exports.CustomItemStateParamsSchema,
63
66
  exports.GroupStateParamsSchema,
67
+ exports.CompoundStateParamsSchema,
64
68
  exports.CodeEmbedStateParamsSchema
65
69
  ]);
@@ -12,4 +12,5 @@ var ArticleItemType;
12
12
  ArticleItemType["Custom"] = "custom";
13
13
  ArticleItemType["Group"] = "group";
14
14
  ArticleItemType["CodeEmbed"] = "code-embed";
15
+ ArticleItemType["Compound"] = "compound";
15
16
  })(ArticleItemType || (exports.ArticleItemType = ArticleItemType = {}));
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AreaAnchor = exports.PositionType = exports.AnchorSide = void 0;
3
+ exports.DimensionMode = exports.AreaAnchor = exports.PositionType = exports.AnchorSide = void 0;
4
4
  var AnchorSide;
5
5
  (function (AnchorSide) {
6
6
  AnchorSide["Top"] = "top";
@@ -24,3 +24,8 @@ var AreaAnchor;
24
24
  AreaAnchor["BottomCenter"] = "bottom-center";
25
25
  AreaAnchor["BottomRight"] = "bottom-right";
26
26
  })(AreaAnchor || (exports.AreaAnchor = AreaAnchor = {}));
27
+ var DimensionMode;
28
+ (function (DimensionMode) {
29
+ DimensionMode["ControlUnits"] = "control-units";
30
+ DimensionMode["Relative"] = "relative";
31
+ })(DimensionMode || (exports.DimensionMode = DimensionMode = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -11,5 +11,6 @@ export const articleMock: Article = {
11
11
  hidden: {},
12
12
  color: {}
13
13
  }
14
- ]
14
+ ],
15
+ interactions: []
15
16
  };
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ export type { Section, SectionHeight } from './types/article/Section';
17
17
  export type {
18
18
  Item, ImageItem, ItemAny, CustomItem, ItemCommonParamsMap,
19
19
  ItemLayoutParamsMap, RectangleItem, StickyParams, VideoItem, RichTextItem,
20
- Link, VimeoEmbedItem, YoutubeEmbedItem, GroupItem, CodeEmbedItem
20
+ Link, VimeoEmbedItem, YoutubeEmbedItem, GroupItem, CodeEmbedItem, CompoundItem
21
21
  } from './types/article/Item';
22
22
  export type { RichTextBlock, RichTextEntity, RichTextStyle } from './types/article/RichText';
23
23
  export type { ItemArea } from './types/article/ItemArea';
@@ -27,3 +27,4 @@ export type { Layout } from './types/project/Layout';
27
27
  export type { Project } from './types/project/Project';
28
28
  export type { Meta } from './types/project/Meta';
29
29
  export type { KeyframeValueMap, KeyframeAny } from './types/keyframe/Keyframe';
30
+ export type { CompoundSettings } from './types/article/CompoundSettings';
@@ -10,7 +10,7 @@ import {
10
10
  YoutubeEmbedItem
11
11
  } from '../../types/article/Item';
12
12
  import {
13
- CodeEmbedStateParamsSchema,
13
+ CodeEmbedStateParamsSchema, CompoundStateParamsSchema,
14
14
  CustomItemStateParamsSchema,
15
15
  EmbedStateParamsSchema, GroupStateParamsSchema,
16
16
  MediaStateParamsSchema,
@@ -40,19 +40,21 @@ export const FXControlSchema = z.discriminatedUnion('type',[
40
40
  })
41
41
  ]) satisfies ZodType<FXControlAny>;
42
42
 
43
+ const FXParams = z.object({
44
+ url: z.string().min(1),
45
+ hasGLEffect: z.boolean().optional(),
46
+ fragmentShader: z.string().nullable(),
47
+ FXCursor: z.object({
48
+ type: z.enum(['mouse', 'manual']),
49
+ x: z.number(),
50
+ y: z.number()
51
+ }).nullable(),
52
+ FXControls: z.array(FXControlSchema).optional()
53
+ });
54
+
43
55
  const ImageItemSchema = ItemBaseSchema.extend({
44
56
  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
- }),
57
+ commonParams: FXParams,
56
58
  sticky: z.record(
57
59
  z.object({
58
60
  from: z.number(),
@@ -74,9 +76,8 @@ const ImageItemSchema = ItemBaseSchema.extend({
74
76
  const VideoItemSchema = ItemBaseSchema.extend({
75
77
  type: z.literal(ArticleItemType.Video),
76
78
  commonParams: z.object({
77
- url: z.string().min(1),
78
79
  coverUrl: z.string().nullable()
79
- }),
80
+ }).merge(FXParams),
80
81
  sticky: z.record(
81
82
  z.object({
82
83
  from: z.number(),
@@ -241,5 +242,24 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
241
242
  })
242
243
  ),
243
244
  state: z.record(z.record(GroupStateParamsSchema))
245
+ }),
246
+ ItemBaseSchema.extend({
247
+ type: z.literal(ArticleItemType.Compound),
248
+ commonParams: z.object({
249
+ overflow: z.enum(['hidden', 'visible']),
250
+ }),
251
+ items: z.array(ItemSchema),
252
+ sticky: z.record(
253
+ z.object({
254
+ from: z.number(),
255
+ to: z.number().optional()
256
+ }).nullable(),
257
+ ),
258
+ layoutParams: z.record(
259
+ z.object({
260
+ opacity: z.number().nonnegative()
261
+ })
262
+ ),
263
+ state: z.record(z.record(CompoundStateParamsSchema))
244
264
  })
245
265
  ]));
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { ItemAreaSchema } from './ItemArea.schema';
3
+ import { AreaAnchor, DimensionMode } from '../../types/article/ItemArea';
3
4
 
4
5
  export const Link = z.object({
5
6
  url: z.string().min(1),
@@ -10,11 +11,18 @@ const CommonParamsBase = z.object({
10
11
  sizing: z.string().min(1)
11
12
  });
12
13
 
14
+ export const CompoundSettingsSchema = z.object({
15
+ positionAnchor: z.nativeEnum(AreaAnchor),
16
+ widthMode: z.nativeEnum(DimensionMode),
17
+ heightMode: z.nativeEnum(DimensionMode),
18
+ });
19
+
13
20
  export const ItemBaseSchema = z.object({
14
21
  id: z.string().min(1),
15
22
  area: z.record(ItemAreaSchema),
16
23
  hidden: z.record(z.boolean()),
17
24
  link: Link.optional(),
18
25
  commonParams: CommonParamsBase,
26
+ compoundSettings: z.record(CompoundSettingsSchema).optional(),
19
27
  layoutParams: z.record(z.any()).optional()
20
28
  });
@@ -6,7 +6,7 @@ import {
6
6
  GroupStateParams,
7
7
  MediaStateParams,
8
8
  RectangleStateParams,
9
- RichTextStateParams
9
+ RichTextStateParams, CompoundStateParams
10
10
  } from '../../types/article/ItemState';
11
11
 
12
12
  const TransitionSchema = z.object({
@@ -67,6 +67,10 @@ export const GroupStateParamsSchema = z.object({
67
67
  opacity: getStateParamsSchema(z.number().nonnegative())
68
68
  }).merge(ItemStateBaseSchema) satisfies ZodType<GroupStateParams>;
69
69
 
70
+ export const CompoundStateParamsSchema = z.object({
71
+ opacity: getStateParamsSchema(z.number().nonnegative())
72
+ }).merge(ItemStateBaseSchema) satisfies ZodType<CompoundStateParams>;
73
+
70
74
  export const CodeEmbedStateParamsSchema = z.object({
71
75
  opacity: getStateParamsSchema(z.number().nonnegative())
72
76
  }).merge(ItemStateBaseSchema) satisfies ZodType<CodeEmbedStateParams>;
@@ -78,5 +82,6 @@ export const ItemStateParamsSchema = z.union([
78
82
  RichTextStateParamsSchema,
79
83
  CustomItemStateParamsSchema,
80
84
  GroupStateParamsSchema,
85
+ CompoundStateParamsSchema,
81
86
  CodeEmbedStateParamsSchema
82
87
  ]);
@@ -7,5 +7,6 @@ export enum ArticleItemType {
7
7
  YoutubeEmbed = 'youtube-embed',
8
8
  Custom = 'custom',
9
9
  Group = 'group',
10
- CodeEmbed = 'code-embed'
10
+ CodeEmbed = 'code-embed',
11
+ Compound = 'compound'
11
12
  }
@@ -0,0 +1,7 @@
1
+ import { AreaAnchor, DimensionMode } from './ItemArea';
2
+
3
+ export interface CompoundSettings {
4
+ positionAnchor: AreaAnchor;
5
+ widthMode: DimensionMode;
6
+ heightMode: DimensionMode;
7
+ }
@@ -3,7 +3,7 @@ import { ArticleItemType } from './ArticleItemType';
3
3
  import { AreaAnchor, ItemArea } from './ItemArea';
4
4
  import { ItemState } from './ItemState';
5
5
  import { FXControlAny, FXCursor } from './FX';
6
- import { z } from 'zod';
6
+ import { CompoundSettings } from './CompoundSettings';
7
7
 
8
8
  export type ItemAny = Item<ArticleItemType>;
9
9
 
@@ -13,8 +13,9 @@ export interface Item<T extends ArticleItemType> {
13
13
  area: Record<LayoutIdentifier, ItemArea>;
14
14
  hidden: Record<LayoutIdentifier, boolean>;
15
15
  link?: Link;
16
- items?: T extends ArticleItemType.Group ? ItemAny[] : never;
16
+ items?: T extends (ArticleItemType.Group | ArticleItemType.Compound) ? ItemAny[] : never;
17
17
  sticky: Record<LayoutIdentifier, StickyParams | null>;
18
+ compoundSettings?: Record<LayoutIdentifier, CompoundSettings>;
18
19
  commonParams: ItemCommonParamsMap[T];
19
20
  state: ItemState<T>;
20
21
  layoutParams: Record<LayoutIdentifier, ItemLayoutParamsMap[T]>;
@@ -29,6 +30,7 @@ export interface ItemCommonParamsMap {
29
30
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
30
31
  [ArticleItemType.Custom]: CustomCommonParams;
31
32
  [ArticleItemType.Group]: GroupCommonParams;
33
+ [ArticleItemType.Compound]: CompoundCommonParams;
32
34
  [ArticleItemType.CodeEmbed]: CodeEmbedCommonParams
33
35
  }
34
36
 
@@ -41,23 +43,23 @@ export interface ItemLayoutParamsMap {
41
43
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
42
44
  [ArticleItemType.Custom]: CustomLayoutParams;
43
45
  [ArticleItemType.Group]: GroupLayoutParams;
46
+ [ArticleItemType.Compound]: CompoundLayoutParams;
44
47
  [ArticleItemType.CodeEmbed]: CodeEmbedLayoutParams;
45
48
  }
46
49
 
47
50
  interface MediaCommonParams {
48
51
  url: string;
52
+ hasGLEffect?: boolean;
53
+ fragmentShader: string | null;
54
+ FXCursor: FXCursor | null;
55
+ FXControls?: FXControlAny[];
49
56
  }
50
57
 
51
58
  interface VideoCommonParams extends MediaCommonParams {
52
59
  coverUrl: string | null;
53
60
  }
54
61
 
55
- interface ImageCommonParams extends MediaCommonParams {
56
- hasGLEffect?: boolean;
57
- fragmentShader: string | null;
58
- FXCursor: FXCursor | null;
59
- FXControls?: FXControlAny[];
60
- }
62
+ interface ImageCommonParams extends MediaCommonParams {}
61
63
 
62
64
  interface RichTextCommonParams {
63
65
  text: string;
@@ -74,6 +76,10 @@ interface CustomCommonParams {
74
76
 
75
77
  interface GroupCommonParams {}
76
78
 
79
+ interface CompoundCommonParams {
80
+ overflow: 'hidden' | 'visible';
81
+ }
82
+
77
83
  interface CodeEmbedCommonParams {
78
84
  html: string;
79
85
  scale: boolean;
@@ -112,6 +118,10 @@ interface GroupLayoutParams {
112
118
  opacity: number;
113
119
  }
114
120
 
121
+ interface CompoundLayoutParams {
122
+ opacity: number;
123
+ }
124
+
115
125
  interface CodeEmbedLayoutParams {
116
126
  areaAnchor: AreaAnchor;
117
127
  opacity: number;
@@ -191,3 +201,4 @@ export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
191
201
  export type CustomItem = Item<ArticleItemType.Custom>;
192
202
  export type GroupItem = Item<ArticleItemType.Group>;
193
203
  export type CodeEmbedItem = Item<ArticleItemType.CodeEmbed>;
204
+ export type CompoundItem = Item<ArticleItemType.Compound>;
@@ -21,6 +21,11 @@ export enum AreaAnchor {
21
21
  BottomRight = 'bottom-right'
22
22
  }
23
23
 
24
+ export enum DimensionMode {
25
+ ControlUnits = 'control-units',
26
+ Relative = 'relative',
27
+ }
28
+
24
29
  export interface ItemArea {
25
30
  top: number;
26
31
  left: number;
@@ -17,6 +17,7 @@ export interface ItemStatesMap {
17
17
  [ArticleItemType.Custom]: CustomItemStateParams;
18
18
  [ArticleItemType.Group]: GroupStateParams;
19
19
  [ArticleItemType.CodeEmbed]: CodeEmbedStateParams;
20
+ [ArticleItemType.Compound]: CompoundStateParams;
20
21
  }
21
22
 
22
23
  export interface StateParams<T> {
@@ -75,6 +76,10 @@ export interface GroupStateParams extends ItemStatesBaseMap {
75
76
  opacity?: StateParams<number>;
76
77
  }
77
78
 
79
+ export interface CompoundStateParams extends ItemStatesBaseMap {
80
+ opacity?: StateParams<number>;
81
+ }
82
+
78
83
  export interface CodeEmbedStateParams extends ItemStatesBaseMap {
79
84
  opacity?: StateParams<number>;
80
85
  }