@cntrl-site/sdk 1.11.0 → 1.12.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.
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,24 @@ 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
+ }),
166
+ sticky: zod_1.z.record(zod_1.z.object({
167
+ from: zod_1.z.number(),
168
+ to: zod_1.z.number().optional()
169
+ }).nullable()),
170
+ layoutParams: zod_1.z.record(zod_1.z.object({
171
+ areaAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor),
172
+ opacity: zod_1.z.number().nonnegative(),
173
+ blur: zod_1.z.number()
174
+ })),
175
+ state: zod_1.z.object({
176
+ hover: zod_1.z.record(ItemState_schema_1.CodeEmbedHoverStateParamsSchema)
177
+ })
178
+ });
160
179
  exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
161
180
  ImageItemSchema,
162
181
  VideoItemSchema,
@@ -165,6 +184,7 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
165
184
  RichTextItem_schema_1.RichTextItemSchema,
166
185
  VimeoEmbedItemSchema,
167
186
  YoutubeEmbedItemSchema,
187
+ CodeEmbedItemSchema,
168
188
  ItemBase_schema_1.ItemBaseSchema.extend({
169
189
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
170
190
  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({
@@ -36,7 +36,8 @@ exports.RectangleHoverStateParamsSchema = zod_1.z.object({
36
36
  }).merge(exports.ItemHoverStateBaseSchema);
37
37
  exports.CustomItemHoverStateParamsSchema = exports.ItemHoverStateBaseSchema;
38
38
  exports.EmbedHoverStateParamsSchema = zod_1.z.object({
39
- radius: (0, exports.getHoverParamsSchema)(zod_1.z.number())
39
+ radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
40
+ opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
40
41
  }).merge(exports.ItemHoverStateBaseSchema);
41
42
  exports.RichTextHoverStateParamsSchema = zod_1.z.object({
42
43
  color: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
@@ -46,11 +47,15 @@ exports.RichTextHoverStateParamsSchema = zod_1.z.object({
46
47
  exports.GroupHoverStateParamsSchema = zod_1.z.object({
47
48
  opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
48
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);
49
53
  exports.ItemHoverStateParamsSchema = zod_1.z.union([
50
54
  exports.EmbedHoverStateParamsSchema,
51
55
  exports.MediaHoverStateParamsSchema,
52
56
  exports.RectangleHoverStateParamsSchema,
53
57
  exports.RichTextHoverStateParamsSchema,
54
58
  exports.CustomItemHoverStateParamsSchema,
55
- exports.GroupHoverStateParamsSchema
59
+ exports.GroupHoverStateParamsSchema,
60
+ exports.CodeEmbedHoverStateParamsSchema
56
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.0",
3
+ "version": "1.12.0",
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,29 @@ 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
+ }),
209
+ sticky: z.record(
210
+ z.object({
211
+ from: z.number(),
212
+ to: z.number().optional()
213
+ }).nullable(),
214
+ ),
215
+ layoutParams: z.record(
216
+ z.object({
217
+ areaAnchor: z.nativeEnum(AreaAnchor),
218
+ opacity: z.number().nonnegative(),
219
+ blur: z.number()
220
+ })
221
+ ),
222
+ state: z.object({
223
+ hover: z.record(CodeEmbedHoverStateParamsSchema)
224
+ })
225
+ }) satisfies ZodType<CodeEmbedItem>;
226
+
201
227
  export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('type', [
202
228
  ImageItemSchema,
203
229
  VideoItemSchema,
@@ -206,6 +232,7 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
206
232
  RichTextItemSchema,
207
233
  VimeoEmbedItemSchema,
208
234
  YoutubeEmbedItemSchema,
235
+ CodeEmbedItemSchema,
209
236
  ItemBaseSchema.extend({
210
237
  type: z.literal(ArticleItemType.Group),
211
238
  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
@@ -44,7 +45,8 @@ export const RectangleHoverStateParamsSchema = z.object({
44
45
  export const CustomItemHoverStateParamsSchema = ItemHoverStateBaseSchema satisfies ZodType<CustomHoverStateParams>;
45
46
 
46
47
  export const EmbedHoverStateParamsSchema = z.object({
47
- radius: getHoverParamsSchema(z.number())
48
+ radius: getHoverParamsSchema(z.number()),
49
+ opacity: getHoverParamsSchema(z.number().nonnegative())
48
50
  }).merge(ItemHoverStateBaseSchema) satisfies ZodType<EmbedHoverStateParams>;
49
51
 
50
52
  export const RichTextHoverStateParamsSchema = z.object({
@@ -57,11 +59,16 @@ export const GroupHoverStateParamsSchema = z.object({
57
59
  opacity: getHoverParamsSchema(z.number().nonnegative())
58
60
  }).merge(ItemHoverStateBaseSchema) satisfies ZodType<GroupHoverStateParams>;
59
61
 
62
+ export const CodeEmbedHoverStateParamsSchema = z.object({
63
+ opacity: getHoverParamsSchema(z.number().nonnegative())
64
+ }).merge(ItemHoverStateBaseSchema) satisfies ZodType<CodeEmbedHoverStateParams>;
65
+
60
66
  export const ItemHoverStateParamsSchema = z.union([
61
67
  EmbedHoverStateParamsSchema,
62
68
  MediaHoverStateParamsSchema,
63
69
  RectangleHoverStateParamsSchema,
64
70
  RichTextHoverStateParamsSchema,
65
71
  CustomItemHoverStateParamsSchema,
66
- GroupHoverStateParamsSchema
72
+ GroupHoverStateParamsSchema,
73
+ CodeEmbedHoverStateParamsSchema
67
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,10 @@ interface CustomCommonParams {
69
71
 
70
72
  interface GroupCommonParams {}
71
73
 
74
+ interface CodeEmbedCommonParams {
75
+ html: string;
76
+ }
77
+
72
78
  interface VimeoEmbedCommonParams {
73
79
  play: 'on-hover' | 'on-click' | 'auto';
74
80
  controls: boolean;
@@ -99,6 +105,12 @@ interface GroupLayoutParams {
99
105
  opacity: number;
100
106
  }
101
107
 
108
+ interface CodeEmbedLayoutParams {
109
+ areaAnchor: AreaAnchor;
110
+ opacity: number;
111
+ blur: number;
112
+ }
113
+
102
114
  interface VimeoEmbedLayoutParams {
103
115
  radius: number;
104
116
  blur: number;
@@ -171,3 +183,4 @@ export type VimeoEmbedItem = Item<ArticleItemType.VimeoEmbed>;
171
183
  export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
172
184
  export type CustomItem = Item<ArticleItemType.Custom>;
173
185
  export type GroupItem = Item<ArticleItemType.Group>;
186
+ 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> {
@@ -60,6 +61,7 @@ export interface RectangleHoverStateParams extends ItemHoversBaseMap {
60
61
 
61
62
  export interface EmbedHoverStateParams extends ItemHoversBaseMap {
62
63
  radius?: HoverParams<number>;
64
+ opacity?: HoverParams<number>;
63
65
  }
64
66
 
65
67
  export interface CustomHoverStateParams extends ItemHoversBaseMap {}
@@ -67,3 +69,7 @@ export interface CustomHoverStateParams extends ItemHoversBaseMap {}
67
69
  export interface GroupHoverStateParams extends ItemHoversBaseMap {
68
70
  opacity?: HoverParams<number>;
69
71
  }
72
+
73
+ export interface CodeEmbedHoverStateParams extends ItemHoversBaseMap {
74
+ opacity?: HoverParams<number>;
75
+ }