@chili-publish/studio-sdk 1.0.0 → 1.2.5

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.
Files changed (74) hide show
  1. package/_bundles/main.js +1 -2
  2. package/_bundles/main.js.map +1 -1
  3. package/_bundles/report.html +2 -2
  4. package/lib/editor-engine.json +1 -1
  5. package/lib/package.json +3 -3
  6. package/lib/src/controllers/FontConnectorController.d.ts +3 -31
  7. package/lib/src/controllers/FontConnectorController.js +1 -44
  8. package/lib/src/controllers/FontConnectorController.js.map +1 -1
  9. package/lib/src/controllers/FrameController.d.ts +7 -7
  10. package/lib/src/controllers/FrameController.js +7 -36
  11. package/lib/src/controllers/FrameController.js.map +1 -1
  12. package/lib/src/controllers/LayoutController.d.ts +17 -3
  13. package/lib/src/controllers/LayoutController.js +24 -11
  14. package/lib/src/controllers/LayoutController.js.map +1 -1
  15. package/lib/src/controllers/MediaConnectorController.d.ts +10 -31
  16. package/lib/src/controllers/MediaConnectorController.js +21 -46
  17. package/lib/src/controllers/MediaConnectorController.js.map +1 -1
  18. package/lib/src/controllers/PageController.d.ts +2 -2
  19. package/lib/src/controllers/PageController.js +2 -11
  20. package/lib/src/controllers/PageController.js.map +1 -1
  21. package/lib/src/controllers/SubscriberController.d.ts +7 -0
  22. package/lib/src/controllers/SubscriberController.js +10 -0
  23. package/lib/src/controllers/SubscriberController.js.map +1 -1
  24. package/lib/src/controllers/UtilsController.d.ts +0 -7
  25. package/lib/src/controllers/UtilsController.js +1 -13
  26. package/lib/src/controllers/UtilsController.js.map +1 -1
  27. package/lib/src/index.d.ts +3 -3
  28. package/lib/src/index.js +1 -1
  29. package/lib/src/index.js.map +1 -1
  30. package/lib/src/interactions/connector.d.ts +1 -0
  31. package/lib/src/interactions/connector.js +1 -0
  32. package/lib/src/interactions/connector.js.map +1 -1
  33. package/lib/src/sdk.js +1 -0
  34. package/lib/src/sdk.js.map +1 -1
  35. package/lib/src/tests/controllers/FontConnectorController.test.js +0 -22
  36. package/lib/src/tests/controllers/FontConnectorController.test.js.map +1 -1
  37. package/lib/src/tests/controllers/FrameController.test.js +10 -28
  38. package/lib/src/tests/controllers/FrameController.test.js.map +1 -1
  39. package/lib/src/tests/controllers/LayoutController.test.js +15 -17
  40. package/lib/src/tests/controllers/LayoutController.test.js.map +1 -1
  41. package/lib/src/tests/controllers/MediaConnectorController.test.js +9 -26
  42. package/lib/src/tests/controllers/MediaConnectorController.test.js.map +1 -1
  43. package/lib/src/tests/controllers/PageController.test.js +6 -6
  44. package/lib/src/tests/controllers/PageController.test.js.map +1 -1
  45. package/lib/src/tests/controllers/SubscriberContoller.test.js +8 -1
  46. package/lib/src/tests/controllers/SubscriberContoller.test.js.map +1 -1
  47. package/lib/src/tests/controllers/UtilsController.test.js +3 -9
  48. package/lib/src/tests/controllers/UtilsController.test.js.map +1 -1
  49. package/lib/src/tests/utils/round.test.js +1 -1
  50. package/lib/src/tests/utils/round.test.js.map +1 -1
  51. package/lib/src/types/CommonTypes.d.ts +2 -1
  52. package/lib/src/types/CommonTypes.js.map +1 -1
  53. package/lib/src/types/ConnectorTypes.d.ts +14 -7
  54. package/lib/src/types/ConnectorTypes.js +5 -1
  55. package/lib/src/types/ConnectorTypes.js.map +1 -1
  56. package/lib/src/types/LayoutTypes.d.ts +11 -3
  57. package/lib/src/types/LayoutTypes.js +8 -0
  58. package/lib/src/types/LayoutTypes.js.map +1 -1
  59. package/lib/src/types/MediaConnectorTypes.d.ts +7 -2
  60. package/lib/src/types/MediaConnectorTypes.js +8 -3
  61. package/lib/src/types/MediaConnectorTypes.js.map +1 -1
  62. package/lib/src/types/TextStyleTypes.d.ts +23 -22
  63. package/lib/src/types/TextStyleTypes.js.map +1 -1
  64. package/lib/src/utils/MathUtils.d.ts +1 -0
  65. package/lib/src/utils/MathUtils.js +5 -0
  66. package/lib/src/utils/MathUtils.js.map +1 -0
  67. package/package.json +3 -3
  68. package/_bundles/main.js.LICENSE.txt +0 -14
  69. package/lib/src/tests/utils/getClaculatedValue.test.d.ts +0 -1
  70. package/lib/src/tests/utils/getClaculatedValue.test.js +0 -78
  71. package/lib/src/tests/utils/getClaculatedValue.test.js.map +0 -1
  72. package/lib/src/utils/getCalculatedValue.d.ts +0 -2
  73. package/lib/src/utils/getCalculatedValue.js +0 -20
  74. package/lib/src/utils/getCalculatedValue.js.map +0 -1
@@ -1,78 +0,0 @@
1
- import { getCalculatedValue } from '../../utils/getCalculatedValue';
2
- describe('getCalculatedValue', () => {
3
- it('calculates the correct value from a string with a sum operation', () => {
4
- const value = getCalculatedValue('1 + 1');
5
- expect(value).toBe(2);
6
- });
7
- it('calculates the correct value from a string with a subtract operation', () => {
8
- let value = getCalculatedValue('1 - 1');
9
- expect(value).toBe(0);
10
- value = getCalculatedValue('15 - 3');
11
- expect(value).toBe(12);
12
- });
13
- it('calculates the correct value from a string with a multiply operation', () => {
14
- let value = getCalculatedValue('1 * 1');
15
- expect(value).toBe(1);
16
- value = getCalculatedValue('5 * 3');
17
- expect(value).toBe(15);
18
- });
19
- it('calculates the correct value from a string with a division operation', () => {
20
- const value = getCalculatedValue('10 / 2');
21
- expect(value).toBe(5);
22
- });
23
- it('calculates the correct value from a string with a modulo operation', () => {
24
- let value = getCalculatedValue('10 % 2');
25
- expect(value).toBe(0);
26
- value = getCalculatedValue('5 % 2');
27
- expect(value).toBe(1);
28
- value = getCalculatedValue('3.2 % 0.5');
29
- expect(value).toBe(0.2);
30
- });
31
- it('calculates multiple operators, in correct order of operations', () => {
32
- const value = getCalculatedValue('10 / 2 + 5 - 3 * 3');
33
- expect(value).toBe(1);
34
- });
35
- it('rounds the result', () => {
36
- let value = getCalculatedValue('1 * 1,1254');
37
- expect(value).toBe(1.13);
38
- value = getCalculatedValue('1 * 0,999');
39
- expect(value).toBe(1);
40
- value = getCalculatedValue('1 * 0,999', 3);
41
- expect(value).toBe(0.999);
42
- value = getCalculatedValue('1 * 0,999', 4);
43
- expect(value).toBe(0.999);
44
- });
45
- it('filters out unrelated characters', () => {
46
- const value = getCalculatedValue('10px');
47
- expect(value).toBe(10);
48
- });
49
- it('can display negatives when calculated', () => {
50
- const value = getCalculatedValue('10 - 12px');
51
- expect(value).toBe(-2);
52
- });
53
- it('accepts negative numbers on the right side of the operator', () => {
54
- const value = getCalculatedValue('12 + -10');
55
- expect(value).toBe(2);
56
- });
57
- it('accepts negative numbers at the start', () => {
58
- const value = getCalculatedValue('-12 + 10');
59
- expect(value).toBe(-2);
60
- });
61
- it('accepts negative numbers on the left side of the operator', () => {
62
- let value = getCalculatedValue('10 + -10 * 5');
63
- expect(value).toBe(-40);
64
- value = getCalculatedValue('10 - -10 * 5');
65
- expect(value).toBe(60);
66
- value = getCalculatedValue('10 - -10 * 5 * 2');
67
- expect(value).toBe(110);
68
- });
69
- it('can handle a mix of everything', () => {
70
- const value = getCalculatedValue('-10 + -10 * 5 / -10');
71
- expect(value).toBe(-5);
72
- });
73
- it('can handle negative and subtraction', () => {
74
- const value = getCalculatedValue('-10-3');
75
- expect(value).toBe(-13);
76
- });
77
- });
78
- //# sourceMappingURL=getClaculatedValue.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getClaculatedValue.test.js","sourceRoot":"","sources":["../../../../src/tests/utils/getClaculatedValue.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACvE,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC5E,IAAI,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,C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EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,MAAM,KAAK,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACjE,IAAI,KAAK,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC/C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QAExB,KAAK,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEvB,KAAK,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;QAC/C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,MAAM,KAAK,GAAG,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const round: (val: number, precision?: number) => number;
2
- export declare const getCalculatedValue: (value: string, roundPrecision?: number) => number | null;
@@ -1,20 +0,0 @@
1
- import { create, evaluateDependencies, addDependencies, divideDependencies, multiplyDependencies, modDependencies, } from 'mathjs';
2
- const { evaluate } = create({
3
- evaluateDependencies,
4
- addDependencies,
5
- divideDependencies,
6
- multiplyDependencies,
7
- modDependencies,
8
- });
9
- const cleanupInput = (input) => input.replace(/[^0-9,\-+/*.%]/gi, '').replace(/,/gi, '.');
10
- export const round = (val, precision = 2) => {
11
- const hundred = Math.pow(10, precision);
12
- return Math.round(val * hundred) / hundred;
13
- };
14
- export const getCalculatedValue = (value, roundPrecision = 2) => {
15
- const input = cleanupInput(value);
16
- if (input.length === 0 || input === null)
17
- return null;
18
- return round(evaluate(input), roundPrecision);
19
- };
20
- //# sourceMappingURL=getCalculatedValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getCalculatedValue.js","sourceRoot":"","sources":["../../../src/utils/getCalculatedValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,EACN,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,GAClB,MAAM,QAAQ,CAAC;AAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACxB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,oBAAoB;IACpB,eAAe;CAClB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,SAAS,GAAG,CAAC,EAAE,EAAE;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,cAAc,GAAG,CAAC,EAAE,EAAE;IACpE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAElC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtD,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,CAAC;AAClD,CAAC,CAAC"}