@cntrl-site/sdk 1.11.1 → 1.12.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.
Binary file
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyframeType = exports.PositionType = exports.AnchorSide = exports.ScaleAnchor = exports.ArticleItemType = exports.VerticalAlign = exports.TextTransform = exports.TextDecoration = exports.TextAlign = exports.SectionHeightMode = exports.ScrollPlaybackVideoManager = exports.getLayoutMediaQuery = exports.getLayoutStyles = exports.FontFaceGenerator = exports.CntrlClient = void 0;
3
+ exports.KeyframeType = exports.PositionType = exports.AnchorSide = exports.AreaAnchor = exports.ArticleItemType = exports.VerticalAlign = exports.TextTransform = exports.TextDecoration = exports.TextAlign = exports.SectionHeightMode = exports.ScrollPlaybackVideoManager = exports.getLayoutMediaQuery = exports.getLayoutStyles = exports.FontFaceGenerator = exports.CntrlClient = void 0;
4
4
  // logic
5
5
  var Client_1 = require("./Client/Client");
6
6
  Object.defineProperty(exports, "CntrlClient", { enumerable: true, get: function () { return Client_1.Client; } });
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "VerticalAlign", { enumerable: true, get: functio
22
22
  var ArticleItemType_1 = require("./types/article/ArticleItemType");
23
23
  Object.defineProperty(exports, "ArticleItemType", { enumerable: true, get: function () { return ArticleItemType_1.ArticleItemType; } });
24
24
  var ItemArea_1 = require("./types/article/ItemArea");
25
- Object.defineProperty(exports, "ScaleAnchor", { enumerable: true, get: function () { return ItemArea_1.ScaleAnchor; } });
25
+ Object.defineProperty(exports, "AreaAnchor", { enumerable: true, get: function () { return ItemArea_1.AreaAnchor; } });
26
26
  Object.defineProperty(exports, "AnchorSide", { enumerable: true, get: function () { return ItemArea_1.AnchorSide; } });
27
27
  Object.defineProperty(exports, "PositionType", { enumerable: true, get: function () { return ItemArea_1.PositionType; } });
28
28
  var Keyframe_1 = require("./types/keyframe/Keyframe");
@@ -6,6 +6,7 @@ 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
+ const ItemArea_1 = require("../../types/article/ItemArea");
9
10
  exports.FXControlSchema = zod_1.z.discriminatedUnion('type', [
10
11
  zod_1.z.object({
11
12
  type: zod_1.z.literal('float'),
@@ -157,6 +158,25 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
157
158
  hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
158
159
  })
159
160
  });
161
+ const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
162
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.CodeEmbed),
163
+ commonParams: zod_1.z.object({
164
+ html: zod_1.z.string(),
165
+ scale: zod_1.z.boolean()
166
+ }),
167
+ sticky: zod_1.z.record(zod_1.z.object({
168
+ from: zod_1.z.number(),
169
+ to: zod_1.z.number().optional()
170
+ }).nullable()),
171
+ layoutParams: zod_1.z.record(zod_1.z.object({
172
+ areaAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor),
173
+ opacity: zod_1.z.number().nonnegative(),
174
+ blur: zod_1.z.number()
175
+ })),
176
+ state: zod_1.z.object({
177
+ hover: zod_1.z.record(ItemState_schema_1.CodeEmbedHoverStateParamsSchema)
178
+ })
179
+ });
160
180
  exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
161
181
  ImageItemSchema,
162
182
  VideoItemSchema,
@@ -165,6 +185,7 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
165
185
  RichTextItem_schema_1.RichTextItemSchema,
166
186
  VimeoEmbedItemSchema,
167
187
  YoutubeEmbedItemSchema,
188
+ CodeEmbedItemSchema,
168
189
  ItemBase_schema_1.ItemBaseSchema.extend({
169
190
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
170
191
  commonParams: zod_1.z.object({}),
@@ -13,5 +13,5 @@ exports.ItemAreaSchema = zod_1.z.object({
13
13
  anchorSide: zod_1.z.nativeEnum(ItemArea_1.AnchorSide).optional(),
14
14
  scale: zod_1.z.number().nonnegative(),
15
15
  positionType: zod_1.z.nativeEnum(ItemArea_1.PositionType),
16
- scaleAnchor: zod_1.z.nativeEnum(ItemArea_1.ScaleAnchor)
16
+ scaleAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor)
17
17
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemHoverStateParamsSchema = exports.GroupHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
3
+ exports.ItemHoverStateParamsSchema = exports.CodeEmbedHoverStateParamsSchema = exports.GroupHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const getHoverParamsSchema = (schema) => {
6
6
  return zod_1.z.object({
@@ -47,11 +47,15 @@ exports.RichTextHoverStateParamsSchema = zod_1.z.object({
47
47
  exports.GroupHoverStateParamsSchema = zod_1.z.object({
48
48
  opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
49
49
  }).merge(exports.ItemHoverStateBaseSchema);
50
+ exports.CodeEmbedHoverStateParamsSchema = zod_1.z.object({
51
+ opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
52
+ }).merge(exports.ItemHoverStateBaseSchema);
50
53
  exports.ItemHoverStateParamsSchema = zod_1.z.union([
51
54
  exports.EmbedHoverStateParamsSchema,
52
55
  exports.MediaHoverStateParamsSchema,
53
56
  exports.RectangleHoverStateParamsSchema,
54
57
  exports.RichTextHoverStateParamsSchema,
55
58
  exports.CustomItemHoverStateParamsSchema,
56
- exports.GroupHoverStateParamsSchema
59
+ exports.GroupHoverStateParamsSchema,
60
+ exports.CodeEmbedHoverStateParamsSchema
57
61
  ]);
@@ -11,4 +11,5 @@ var ArticleItemType;
11
11
  ArticleItemType["YoutubeEmbed"] = "youtube-embed";
12
12
  ArticleItemType["Custom"] = "custom";
13
13
  ArticleItemType["Group"] = "group";
14
+ ArticleItemType["CodeEmbed"] = "code-embed";
14
15
  })(ArticleItemType || (exports.ArticleItemType = ArticleItemType = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScaleAnchor = exports.PositionType = exports.AnchorSide = void 0;
3
+ exports.AreaAnchor = exports.PositionType = exports.AnchorSide = void 0;
4
4
  var AnchorSide;
5
5
  (function (AnchorSide) {
6
6
  AnchorSide["Top"] = "top";
@@ -12,15 +12,15 @@ var PositionType;
12
12
  PositionType["SectionBased"] = "section-based";
13
13
  PositionType["ScreenBased"] = "screen-based";
14
14
  })(PositionType || (exports.PositionType = PositionType = {}));
15
- var ScaleAnchor;
16
- (function (ScaleAnchor) {
17
- ScaleAnchor["TopLeft"] = "top-left";
18
- ScaleAnchor["TopCenter"] = "top-center";
19
- ScaleAnchor["TopRight"] = "top-right";
20
- ScaleAnchor["MiddleLeft"] = "middle-left";
21
- ScaleAnchor["MiddleCenter"] = "middle-center";
22
- ScaleAnchor["MiddleRight"] = "middle-right";
23
- ScaleAnchor["BottomLeft"] = "bottom-left";
24
- ScaleAnchor["BottomCenter"] = "bottom-center";
25
- ScaleAnchor["BottomRight"] = "bottom-right";
26
- })(ScaleAnchor || (exports.ScaleAnchor = ScaleAnchor = {}));
15
+ var AreaAnchor;
16
+ (function (AreaAnchor) {
17
+ AreaAnchor["TopLeft"] = "top-left";
18
+ AreaAnchor["TopCenter"] = "top-center";
19
+ AreaAnchor["TopRight"] = "top-right";
20
+ AreaAnchor["MiddleLeft"] = "middle-left";
21
+ AreaAnchor["MiddleCenter"] = "middle-center";
22
+ AreaAnchor["MiddleRight"] = "middle-right";
23
+ AreaAnchor["BottomLeft"] = "bottom-left";
24
+ AreaAnchor["BottomCenter"] = "bottom-center";
25
+ AreaAnchor["BottomRight"] = "bottom-right";
26
+ })(AreaAnchor || (exports.AreaAnchor = AreaAnchor = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.11.1",
3
+ "version": "1.12.1",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ export {ScrollPlaybackVideoManager} from './ScrollPlaybackVideoManager/ScrollPla
8
8
  export { SectionHeightMode } from './types/article/Section';
9
9
  export { TextAlign, TextDecoration, TextTransform, VerticalAlign } from './types/article/RichText';
10
10
  export { ArticleItemType } from './types/article/ArticleItemType';
11
- export { ScaleAnchor, AnchorSide, PositionType } from './types/article/ItemArea';
11
+ export { AreaAnchor, AnchorSide, PositionType } from './types/article/ItemArea';
12
12
  export { KeyframeType } from './types/keyframe/Keyframe';
13
13
 
14
14
  // types
@@ -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
20
+ Link, VimeoEmbedItem, YoutubeEmbedItem, GroupItem, CodeEmbedItem
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';
@@ -1,5 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
+ CodeEmbedItem,
3
4
  CustomItem,
4
5
  ImageItem,
5
6
  ItemAny,
@@ -9,6 +10,7 @@ import {
9
10
  YoutubeEmbedItem
10
11
  } from '../../types/article/Item';
11
12
  import {
13
+ CodeEmbedHoverStateParamsSchema,
12
14
  CustomItemHoverStateParamsSchema,
13
15
  EmbedHoverStateParamsSchema, GroupHoverStateParamsSchema, MediaHoverStateParamsSchema,
14
16
  RectangleHoverStateParamsSchema
@@ -17,6 +19,7 @@ import { RichTextItemSchema } from './RichTextItem.schema';
17
19
  import { ItemBaseSchema } from './ItemBase.schema';
18
20
  import { ArticleItemType } from '../../types/article/ArticleItemType';
19
21
  import { FXControlAny } from '../../types/article/FX';
22
+ import { AreaAnchor } from '../../types/article/ItemArea';
20
23
 
21
24
  export const FXControlSchema = z.discriminatedUnion('type',[
22
25
  z.object({
@@ -198,6 +201,30 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
198
201
  })
199
202
  }) satisfies ZodType<YoutubeEmbedItem>;
200
203
 
204
+ const CodeEmbedItemSchema = ItemBaseSchema.extend({
205
+ type: z.literal(ArticleItemType.CodeEmbed),
206
+ commonParams: z.object({
207
+ html: z.string(),
208
+ scale: z.boolean()
209
+ }),
210
+ sticky: z.record(
211
+ z.object({
212
+ from: z.number(),
213
+ to: z.number().optional()
214
+ }).nullable(),
215
+ ),
216
+ layoutParams: z.record(
217
+ z.object({
218
+ areaAnchor: z.nativeEnum(AreaAnchor),
219
+ opacity: z.number().nonnegative(),
220
+ blur: z.number()
221
+ })
222
+ ),
223
+ state: z.object({
224
+ hover: z.record(CodeEmbedHoverStateParamsSchema)
225
+ })
226
+ }) satisfies ZodType<CodeEmbedItem>;
227
+
201
228
  export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('type', [
202
229
  ImageItemSchema,
203
230
  VideoItemSchema,
@@ -206,6 +233,7 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
206
233
  RichTextItemSchema,
207
234
  VimeoEmbedItemSchema,
208
235
  YoutubeEmbedItemSchema,
236
+ CodeEmbedItemSchema,
209
237
  ItemBaseSchema.extend({
210
238
  type: z.literal(ArticleItemType.Group),
211
239
  commonParams: z.object({}),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AnchorSide, PositionType, ScaleAnchor } from '../../types/article/ItemArea';
2
+ import { AnchorSide, PositionType, AreaAnchor } from '../../types/article/ItemArea';
3
3
 
4
4
  export const ItemAreaSchema = z.object({
5
5
  top: z.number(),
@@ -11,5 +11,5 @@ export const ItemAreaSchema = z.object({
11
11
  anchorSide: z.nativeEnum(AnchorSide).optional(),
12
12
  scale: z.number().nonnegative(),
13
13
  positionType: z.nativeEnum(PositionType),
14
- scaleAnchor: z.nativeEnum(ScaleAnchor)
14
+ scaleAnchor: z.nativeEnum(AreaAnchor)
15
15
  });
@@ -1,5 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
+ CodeEmbedHoverStateParams,
3
4
  CustomHoverStateParams, EmbedHoverStateParams, GroupHoverStateParams,
4
5
  MediaHoverStateParams,
5
6
  RectangleHoverStateParams, RichTextHoverStateParams
@@ -58,11 +59,16 @@ export const GroupHoverStateParamsSchema = z.object({
58
59
  opacity: getHoverParamsSchema(z.number().nonnegative())
59
60
  }).merge(ItemHoverStateBaseSchema) satisfies ZodType<GroupHoverStateParams>;
60
61
 
62
+ export const CodeEmbedHoverStateParamsSchema = z.object({
63
+ opacity: getHoverParamsSchema(z.number().nonnegative())
64
+ }).merge(ItemHoverStateBaseSchema) satisfies ZodType<CodeEmbedHoverStateParams>;
65
+
61
66
  export const ItemHoverStateParamsSchema = z.union([
62
67
  EmbedHoverStateParamsSchema,
63
68
  MediaHoverStateParamsSchema,
64
69
  RectangleHoverStateParamsSchema,
65
70
  RichTextHoverStateParamsSchema,
66
71
  CustomItemHoverStateParamsSchema,
67
- GroupHoverStateParamsSchema
72
+ GroupHoverStateParamsSchema,
73
+ CodeEmbedHoverStateParamsSchema
68
74
  ]);
@@ -6,5 +6,6 @@ export enum ArticleItemType {
6
6
  VimeoEmbed = 'vimeo-embed',
7
7
  YoutubeEmbed = 'youtube-embed',
8
8
  Custom = 'custom',
9
- Group = 'group'
9
+ Group = 'group',
10
+ CodeEmbed = 'code-embed'
10
11
  }
@@ -1,6 +1,6 @@
1
1
  import { RichTextBlock, RichTextStyle, TextAlign, TextTransform, VerticalAlign } from './RichText';
2
2
  import { ArticleItemType } from './ArticleItemType';
3
- import { ItemArea } from './ItemArea';
3
+ import { AreaAnchor, ItemArea } from './ItemArea';
4
4
  import { ItemState } from './ItemState';
5
5
  import { FXControlAny, FXCursor } from './FX';
6
6
 
@@ -28,6 +28,7 @@ export interface ItemCommonParamsMap {
28
28
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
29
29
  [ArticleItemType.Custom]: CustomCommonParams;
30
30
  [ArticleItemType.Group]: GroupCommonParams;
31
+ [ArticleItemType.CodeEmbed]: CodeEmbedCommonParams
31
32
  }
32
33
 
33
34
  export interface ItemLayoutParamsMap {
@@ -39,6 +40,7 @@ export interface ItemLayoutParamsMap {
39
40
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
40
41
  [ArticleItemType.Custom]: CustomLayoutParams;
41
42
  [ArticleItemType.Group]: GroupLayoutParams;
43
+ [ArticleItemType.CodeEmbed]: CodeEmbedLayoutParams;
42
44
  }
43
45
 
44
46
  interface MediaCommonParams {
@@ -69,6 +71,11 @@ interface CustomCommonParams {
69
71
 
70
72
  interface GroupCommonParams {}
71
73
 
74
+ interface CodeEmbedCommonParams {
75
+ html: string;
76
+ scale: boolean;
77
+ }
78
+
72
79
  interface VimeoEmbedCommonParams {
73
80
  play: 'on-hover' | 'on-click' | 'auto';
74
81
  controls: boolean;
@@ -99,6 +106,12 @@ interface GroupLayoutParams {
99
106
  opacity: number;
100
107
  }
101
108
 
109
+ interface CodeEmbedLayoutParams {
110
+ areaAnchor: AreaAnchor;
111
+ opacity: number;
112
+ blur: number;
113
+ }
114
+
102
115
  interface VimeoEmbedLayoutParams {
103
116
  radius: number;
104
117
  blur: number;
@@ -171,3 +184,4 @@ export type VimeoEmbedItem = Item<ArticleItemType.VimeoEmbed>;
171
184
  export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
172
185
  export type CustomItem = Item<ArticleItemType.Custom>;
173
186
  export type GroupItem = Item<ArticleItemType.Group>;
187
+ export type CodeEmbedItem = Item<ArticleItemType.CodeEmbed>;
@@ -9,7 +9,7 @@ export enum PositionType {
9
9
  ScreenBased = 'screen-based'
10
10
  }
11
11
 
12
- export enum ScaleAnchor {
12
+ export enum AreaAnchor {
13
13
  TopLeft = 'top-left',
14
14
  TopCenter = 'top-center',
15
15
  TopRight = 'top-right',
@@ -31,5 +31,5 @@ export interface ItemArea {
31
31
  angle: number;
32
32
  anchorSide?: AnchorSide;
33
33
  scale: number;
34
- scaleAnchor: ScaleAnchor;
34
+ scaleAnchor: AreaAnchor;
35
35
  }
@@ -17,6 +17,7 @@ export interface ItemHoverStatesMap {
17
17
  [ArticleItemType.YoutubeEmbed]: EmbedHoverStateParams;
18
18
  [ArticleItemType.Custom]: CustomHoverStateParams;
19
19
  [ArticleItemType.Group]: GroupHoverStateParams;
20
+ [ArticleItemType.CodeEmbed]: CodeEmbedHoverStateParams;
20
21
  }
21
22
 
22
23
  export interface HoverParams<T> {
@@ -68,3 +69,7 @@ export interface CustomHoverStateParams extends ItemHoversBaseMap {}
68
69
  export interface GroupHoverStateParams extends ItemHoversBaseMap {
69
70
  opacity?: HoverParams<number>;
70
71
  }
72
+
73
+ export interface CodeEmbedHoverStateParams extends ItemHoversBaseMap {
74
+ opacity?: HoverParams<number>;
75
+ }