@cntrl-site/sdk 1.25.7 → 1.25.9-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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 CNTRL
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 CNTRL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # CNTRL SDK
2
- This is a root SDK module for CNTRL. Should be used along with other framework-specific modules like `@cntrl-site/sdk-react`
1
+ # CNTRL SDK
2
+ This is a root SDK module for CNTRL. Should be used along with other framework-specific modules like `@cntrl-site/sdk-react`
@@ -15,12 +15,12 @@ class FontFaceGenerator {
15
15
  const otherFiles = font.files
16
16
  .filter(file => file.type !== 'eot')
17
17
  .map(file => `url('${file.url}') format('${FILE_TYPES_MAP[file.type] || file.type}')`);
18
- return `
19
- @font-face {
20
- font-family: "${font.name}";
21
- font-weight: ${font.weight};
22
- font-style: ${font.style};
23
- ${eotFile ? `src: url('${eotFile.url}');\n ` : ''}src: ${otherFiles.join(', ')};
18
+ return `
19
+ @font-face {
20
+ font-family: "${font.name}";
21
+ font-weight: ${font.weight};
22
+ font-style: ${font.style};
23
+ ${eotFile ? `src: url('${eotFile.url}');\n ` : ''}src: ${otherFiles.join(', ')};
24
24
  }`;
25
25
  }).join('\n');
26
26
  }
@@ -31,4 +31,5 @@ export declare class Rect {
31
31
  getScaled(xRatio: number, yRatio?: number): Rect;
32
32
  getRelative(source: Rect): Rect;
33
33
  private static getNewPosition;
34
+ private static getNormalizedFactor;
34
35
  }
package/lib/Rect/Rect.js CHANGED
@@ -30,8 +30,9 @@ class Rect {
30
30
  && Math.round(rect1.bottom) === Math.round(rect2.bottom);
31
31
  }
32
32
  static scale(rect, factor, origin) {
33
- const width = rect.width * factor;
34
- const height = rect.height * factor;
33
+ const normalizedFactor = _a.getNormalizedFactor(factor);
34
+ const width = rect.width * normalizedFactor;
35
+ const height = rect.height * normalizedFactor;
35
36
  const dw = rect.width - width;
36
37
  const dh = rect.height - height;
37
38
  const [kt, kl] = Rect_1.scaleMatrix[origin];
@@ -40,8 +41,9 @@ class Rect {
40
41
  return new _a(x, y, width, height);
41
42
  }
42
43
  static scaleWithOrigin(rect, factor, kt, kl) {
43
- const width = rect.width * factor;
44
- const height = rect.height * factor;
44
+ const normalizedFactor = _a.getNormalizedFactor(factor);
45
+ const width = rect.width * normalizedFactor;
46
+ const height = rect.height * normalizedFactor;
45
47
  const dw = rect.width - width;
46
48
  const dh = rect.height - height;
47
49
  const x = rect.left + (kl * dw);
@@ -181,6 +183,12 @@ class Rect {
181
183
  const y = rect.top + (rect.height - newDimensions.height) / 2;
182
184
  return { x, y };
183
185
  }
186
+ static getNormalizedFactor(factor) {
187
+ const EPSILON = 1e-10;
188
+ return factor === 0 ? EPSILON :
189
+ factor === Infinity ? 1 / EPSILON :
190
+ factor;
191
+ }
184
192
  }
185
193
  exports.Rect = Rect;
186
194
  _a = Rect;
package/lib/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { Rect } from './Rect/Rect';
6
6
  export { SectionHeightMode } from './types/article/Section';
7
7
  export { TextAlign, TextDecoration, TextTransform, VerticalAlign } from './types/article/RichText';
8
8
  export { ArticleItemType } from './types/article/ArticleItemType';
9
- export { AreaAnchor, AnchorSide, DimensionMode, PositionType } from './types/article/ItemArea';
9
+ export { AreaAnchor, AnchorSide, DimensionMode, PositionType, DimensionsType } from './types/article/ItemArea';
10
10
  export { KeyframeType } from './types/keyframe/Keyframe';
11
11
  export type { Article } from './types/article/Article';
12
12
  export type { Section, SectionHeight } from './types/article/Section';
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.DimensionMode = exports.AnchorSide = exports.AreaAnchor = exports.ArticleItemType = exports.VerticalAlign = exports.TextTransform = exports.TextDecoration = exports.TextAlign = exports.SectionHeightMode = exports.Rect = exports.ScrollPlaybackVideoManager = exports.measureFont = exports.getLayoutMediaQuery = exports.getLayoutStyles = exports.FontFaceGenerator = exports.CntrlClient = void 0;
3
+ exports.KeyframeType = exports.DimensionsType = exports.PositionType = exports.DimensionMode = exports.AnchorSide = exports.AreaAnchor = exports.ArticleItemType = exports.VerticalAlign = exports.TextTransform = exports.TextDecoration = exports.TextAlign = exports.SectionHeightMode = exports.Rect = exports.ScrollPlaybackVideoManager = exports.measureFont = 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; } });
@@ -29,5 +29,6 @@ Object.defineProperty(exports, "AreaAnchor", { enumerable: true, get: function (
29
29
  Object.defineProperty(exports, "AnchorSide", { enumerable: true, get: function () { return ItemArea_1.AnchorSide; } });
30
30
  Object.defineProperty(exports, "DimensionMode", { enumerable: true, get: function () { return ItemArea_1.DimensionMode; } });
31
31
  Object.defineProperty(exports, "PositionType", { enumerable: true, get: function () { return ItemArea_1.PositionType; } });
32
+ Object.defineProperty(exports, "DimensionsType", { enumerable: true, get: function () { return ItemArea_1.DimensionsType; } });
32
33
  var Keyframe_1 = require("./types/keyframe/Keyframe");
33
34
  Object.defineProperty(exports, "KeyframeType", { enumerable: true, get: function () { return Keyframe_1.KeyframeType; } });
@@ -57,7 +57,7 @@ export declare const RichTextItemSchema: z.ZodObject<{
57
57
  anchorSide: z.ZodOptional<z.ZodNativeEnum<typeof import("../..").AnchorSide>>;
58
58
  scale: z.ZodNumber;
59
59
  positionType: z.ZodNativeEnum<typeof import("../..").PositionType>;
60
- dimensionsType: z.ZodOptional<z.ZodNativeEnum<typeof import("../../types/article/ItemArea").DimensionsType>>;
60
+ dimensionsType: z.ZodOptional<z.ZodNativeEnum<typeof import("../..").DimensionsType>>;
61
61
  scaleAnchor: z.ZodNativeEnum<typeof import("../..").AreaAnchor>;
62
62
  }, "strip", z.ZodTypeAny, {
63
63
  left: number;
@@ -70,7 +70,7 @@ export declare const RichTextItemSchema: z.ZodObject<{
70
70
  positionType: import("../..").PositionType;
71
71
  scaleAnchor: import("../..").AreaAnchor;
72
72
  anchorSide?: import("../..").AnchorSide | undefined;
73
- dimensionsType?: import("../../types/article/ItemArea").DimensionsType | undefined;
73
+ dimensionsType?: import("../..").DimensionsType | undefined;
74
74
  }, {
75
75
  left: number;
76
76
  top: number;
@@ -82,7 +82,7 @@ export declare const RichTextItemSchema: z.ZodObject<{
82
82
  positionType: import("../..").PositionType;
83
83
  scaleAnchor: import("../..").AreaAnchor;
84
84
  anchorSide?: import("../..").AnchorSide | undefined;
85
- dimensionsType?: import("../../types/article/ItemArea").DimensionsType | undefined;
85
+ dimensionsType?: import("../..").DimensionsType | undefined;
86
86
  }>>;
87
87
  compoundSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
88
88
  positionAnchor: z.ZodNativeEnum<typeof import("../..").AreaAnchor>;
@@ -1010,7 +1010,7 @@ export declare const RichTextItemSchema: z.ZodObject<{
1010
1010
  positionType: import("../..").PositionType;
1011
1011
  scaleAnchor: import("../..").AreaAnchor;
1012
1012
  anchorSide?: import("../..").AnchorSide | undefined;
1013
- dimensionsType?: import("../../types/article/ItemArea").DimensionsType | undefined;
1013
+ dimensionsType?: import("../..").DimensionsType | undefined;
1014
1014
  }>;
1015
1015
  layoutParams: Record<string, {
1016
1016
  color: string;
@@ -1201,7 +1201,7 @@ export declare const RichTextItemSchema: z.ZodObject<{
1201
1201
  positionType: import("../..").PositionType;
1202
1202
  scaleAnchor: import("../..").AreaAnchor;
1203
1203
  anchorSide?: import("../..").AnchorSide | undefined;
1204
- dimensionsType?: import("../../types/article/ItemArea").DimensionsType | undefined;
1204
+ dimensionsType?: import("../..").DimensionsType | undefined;
1205
1205
  }>;
1206
1206
  layoutParams: Record<string, {
1207
1207
  color: string;
package/lib/utils.js CHANGED
@@ -8,8 +8,8 @@ function getLayoutStyles(layouts, layoutValues, mapToStyles) {
8
8
  .sort((a, b) => a.startsWith - b.startsWith)
9
9
  .reduce((acc, layout) => {
10
10
  const values = layoutValues.map(lv => lv[layout.id]);
11
- return `
12
- ${acc}
11
+ return `
12
+ ${acc}
13
13
  ${layout.startsWith !== 0
14
14
  ? `@media (min-width: ${layout.startsWith}px) {${mapToStyles(values, layout.exemplary)}}`
15
15
  : `${mapToStyles(values, layout.exemplary)}`}`;
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
- {
2
- "name": "@cntrl-site/sdk",
3
- "version": "1.25.7",
4
- "description": "Generic SDK for use in public websites.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "test": "jest",
9
- "prebuild": "rimraf ./lib",
10
- "build": "tsc --project tsconfig.build.json",
11
- "prepublishOnly": "cross-env NODE_ENV=production npm run build"
12
- },
13
- "bin": {
14
- "cntrl-sdk": "lib/cli.js"
15
- },
16
- "files": [
17
- "lib",
18
- "resources"
19
- ],
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/cntrl-site/sdk.git"
23
- },
24
- "author": "arsen@momdesign.nyc",
25
- "license": "MIT",
26
- "bugs": {
27
- "url": "https://github.com/cntrl-site/sdk/issues"
28
- },
29
- "homepage": "https://github.com/cntrl-site/sdk#readme",
30
- "directories": {
31
- "lib": "lib"
32
- },
33
- "dependencies": {
34
- "@splidejs/react-splide": "^0.7.12",
35
- "@types/ejs": "^3.1.2",
36
- "@types/isomorphic-fetch": "^0.0.36",
37
- "@types/ua-parser-js": "^0.7.39",
38
- "commander": "^10.0.1",
39
- "dotenv": "^16.1.3",
40
- "ejs": "^3.1.9",
41
- "isomorphic-fetch": "^3.0.0",
42
- "mp4box": "^0.5.2",
43
- "styled-jsx": "^5.1.6",
44
- "ts-node": "^10.9.1",
45
- "ua-parser-js": "^1.0.37",
46
- "url": "^0.11.0",
47
- "zod": "^3.22.4"
48
- },
49
- "devDependencies": {
50
- "@tsconfig/node16": "^1.0.3",
51
- "@tsconfig/recommended": "^1.0.1",
52
- "@types/jest": "^29.0.0",
53
- "@types/node": "^18.11.7",
54
- "@types/react": "^18.2.0",
55
- "@types/react-dom": "^18.2.0",
56
- "@vitejs/plugin-react": "^4.3.4",
57
- "cross-env": "^10.1.0",
58
- "jest": "^28.1.3",
59
- "ts-jest": "^28.0.8",
60
- "typescript": "^5.2.2"
61
- }
62
- }
1
+ {
2
+ "name": "@cntrl-site/sdk",
3
+ "version": "1.25.9-0",
4
+ "description": "Generic SDK for use in public websites.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest",
9
+ "prebuild": "rimraf ./lib",
10
+ "build": "tsc --project tsconfig.build.json",
11
+ "prepublishOnly": "cross-env NODE_ENV=production npm run build"
12
+ },
13
+ "bin": {
14
+ "cntrl-sdk": "lib/cli.js"
15
+ },
16
+ "files": [
17
+ "lib",
18
+ "resources"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/cntrl-site/sdk.git"
23
+ },
24
+ "author": "arsen@momdesign.nyc",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/cntrl-site/sdk/issues"
28
+ },
29
+ "homepage": "https://github.com/cntrl-site/sdk#readme",
30
+ "directories": {
31
+ "lib": "lib"
32
+ },
33
+ "dependencies": {
34
+ "@splidejs/react-splide": "^0.7.12",
35
+ "@types/ejs": "^3.1.2",
36
+ "@types/isomorphic-fetch": "^0.0.36",
37
+ "@types/ua-parser-js": "^0.7.39",
38
+ "commander": "^10.0.1",
39
+ "dotenv": "^16.1.3",
40
+ "ejs": "^3.1.9",
41
+ "isomorphic-fetch": "^3.0.0",
42
+ "mp4box": "^0.5.2",
43
+ "styled-jsx": "^5.1.6",
44
+ "ts-node": "^10.9.1",
45
+ "ua-parser-js": "^1.0.37",
46
+ "url": "^0.11.0",
47
+ "zod": "^3.22.4"
48
+ },
49
+ "devDependencies": {
50
+ "@tsconfig/node16": "^1.0.3",
51
+ "@tsconfig/recommended": "^1.0.1",
52
+ "@types/jest": "^29.0.0",
53
+ "@types/node": "^18.11.7",
54
+ "@types/react": "^18.2.0",
55
+ "@types/react-dom": "^18.2.0",
56
+ "@vitejs/plugin-react": "^4.3.4",
57
+ "cross-env": "^10.1.0",
58
+ "jest": "^28.1.3",
59
+ "ts-jest": "^28.0.8",
60
+ "typescript": "^5.2.2"
61
+ }
62
+ }
@@ -1,50 +1,50 @@
1
- // CAUTION: THIS FILE IS AUTO-GENERATED BASED ON
2
- // LAYOUT CONFIGURATION IN YOUR CNTRL PROJECT
3
- // WE HIGHLY ADVICE YOU TO NOT CHANGE IT MANUALLY
4
- @use "sass:map";
5
-
6
- $__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %>;
7
-
8
- $layout: (
9
- <% ranges.forEach(function(range) { %>
10
- <%= range.name %>: (
11
- start: <%= range.start %>,
12
- end: <%= range.end %>,
13
- exemplary: <%= range.exemplary %>,
14
- isFirst: <%= range.isFirst %>,
15
- isLast: <%= range.isLast %>
16
- ),
17
- <% }); %>
18
- );
19
-
20
- @function size($value) {
21
- @return #{$value/$__CNTRL_LAYOUT_WIDTH__*100}vw;
22
- }
23
-
24
- @mixin for($name) {
25
- $start: map.get(map.get($layout, $name), "start");
26
- $end: map.get(map.get($layout, $name), "end");
27
- $isFirst: map.get(map.get($layout, $name), "isFirst");
28
- $isLast: map.get(map.get($layout, $name), "isLast");
29
- $exemplary: map.get(map.get($layout, $name), "exemplary");
30
- $__CNTRL_LAYOUT_WIDTH__: $exemplary !global;
31
-
32
- @if $isFirst == true and $isLast == true {
33
- @content;
34
- } @else if $isFirst == true {
35
- @media (max-width: #{$end}px) {
36
- @content;
37
- }
38
- } @else if $isLast == true {
39
- @media (min-width: #{$start}px) {
40
- @content;
41
- }
42
- } @else {
43
- @media (min-width: #{$start}px) and (max-width: #{$end}px) {
44
- @content;
45
- }
46
- }
47
-
48
- // reset global variable back to first layout's exemplary (mobile-first)
49
- $__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %> !global;
50
- }
1
+ // CAUTION: THIS FILE IS AUTO-GENERATED BASED ON
2
+ // LAYOUT CONFIGURATION IN YOUR CNTRL PROJECT
3
+ // WE HIGHLY ADVICE YOU TO NOT CHANGE IT MANUALLY
4
+ @use "sass:map";
5
+
6
+ $__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %>;
7
+
8
+ $layout: (
9
+ <% ranges.forEach(function(range) { %>
10
+ <%= range.name %>: (
11
+ start: <%= range.start %>,
12
+ end: <%= range.end %>,
13
+ exemplary: <%= range.exemplary %>,
14
+ isFirst: <%= range.isFirst %>,
15
+ isLast: <%= range.isLast %>
16
+ ),
17
+ <% }); %>
18
+ );
19
+
20
+ @function size($value) {
21
+ @return #{$value/$__CNTRL_LAYOUT_WIDTH__*100}vw;
22
+ }
23
+
24
+ @mixin for($name) {
25
+ $start: map.get(map.get($layout, $name), "start");
26
+ $end: map.get(map.get($layout, $name), "end");
27
+ $isFirst: map.get(map.get($layout, $name), "isFirst");
28
+ $isLast: map.get(map.get($layout, $name), "isLast");
29
+ $exemplary: map.get(map.get($layout, $name), "exemplary");
30
+ $__CNTRL_LAYOUT_WIDTH__: $exemplary !global;
31
+
32
+ @if $isFirst == true and $isLast == true {
33
+ @content;
34
+ } @else if $isFirst == true {
35
+ @media (max-width: #{$end}px) {
36
+ @content;
37
+ }
38
+ } @else if $isLast == true {
39
+ @media (min-width: #{$start}px) {
40
+ @content;
41
+ }
42
+ } @else {
43
+ @media (min-width: #{$start}px) and (max-width: #{$end}px) {
44
+ @content;
45
+ }
46
+ }
47
+
48
+ // reset global variable back to first layout's exemplary (mobile-first)
49
+ $__CNTRL_LAYOUT_WIDTH__: <%= ranges[0].exemplary %> !global;
50
+ }