@baravak/risloo-profile-cli 3.1.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.
Files changed (200) hide show
  1. package/.github/workflows/push.yml +14 -0
  2. package/.prettierrc +16 -0
  3. package/.yarn/releases/yarn-1.22.19.cjs +147529 -0
  4. package/.yarnrc.yml +1 -0
  5. package/README.md +98 -0
  6. package/bin/risloo.js +9 -0
  7. package/package.json +44 -0
  8. package/src/Gift.js +29 -0
  9. package/src/Profile.js +405 -0
  10. package/src/cli-commands/Executor.js +118 -0
  11. package/src/cli-commands/ExtractExecutor.js +194 -0
  12. package/src/cli-commands/GiftExecutor.js +56 -0
  13. package/src/cli-commands/utilities/BaseOps.js +71 -0
  14. package/src/cli-commands/utilities/Benchmarker.js +88 -0
  15. package/src/cli-commands/utilities/CustomErrors.js +14 -0
  16. package/src/cli-commands/utilities/Response.js +59 -0
  17. package/src/cli-commands/utilities/STATUSES.js +16 -0
  18. package/src/cli-commands/utilities/Status.js +9 -0
  19. package/src/cli.js +125 -0
  20. package/src/handlebars/helpers/abs.js +8 -0
  21. package/src/handlebars/helpers/addCommas.js +8 -0
  22. package/src/handlebars/helpers/array.js +8 -0
  23. package/src/handlebars/helpers/assignGlobal.js +9 -0
  24. package/src/handlebars/helpers/boolean.js +19 -0
  25. package/src/handlebars/helpers/ceil.js +8 -0
  26. package/src/handlebars/helpers/concat.js +8 -0
  27. package/src/handlebars/helpers/cos.js +8 -0
  28. package/src/handlebars/helpers/displacePoint.js +11 -0
  29. package/src/handlebars/helpers/ellipsisChars.js +10 -0
  30. package/src/handlebars/helpers/ellipsisLines.js +11 -0
  31. package/src/handlebars/helpers/first.js +11 -0
  32. package/src/handlebars/helpers/floor.js +8 -0
  33. package/src/handlebars/helpers/forLoop.js +15 -0
  34. package/src/handlebars/helpers/getArrOfProp.js +8 -0
  35. package/src/handlebars/helpers/isArray.js +8 -0
  36. package/src/handlebars/helpers/join.js +10 -0
  37. package/src/handlebars/helpers/last.js +11 -0
  38. package/src/handlebars/helpers/lineWrap.js +28 -0
  39. package/src/handlebars/helpers/math.js +24 -0
  40. package/src/handlebars/helpers/modulo.js +8 -0
  41. package/src/handlebars/helpers/normalizeAngle.js +7 -0
  42. package/src/handlebars/helpers/object.js +8 -0
  43. package/src/handlebars/helpers/objectEntries.js +8 -0
  44. package/src/handlebars/helpers/polarToCartesian.js +14 -0
  45. package/src/handlebars/helpers/prepend.js +10 -0
  46. package/src/handlebars/helpers/profiles/bar.js +45 -0
  47. package/src/handlebars/helpers/profiles/calcGaugeSidePoints.js +34 -0
  48. package/src/handlebars/helpers/profiles/gauge.js +61 -0
  49. package/src/handlebars/helpers/profiles/polygon.js +40 -0
  50. package/src/handlebars/helpers/reverse.js +9 -0
  51. package/src/handlebars/helpers/roundToTwo.js +8 -0
  52. package/src/handlebars/helpers/setVar.js +8 -0
  53. package/src/handlebars/helpers/sin.js +8 -0
  54. package/src/handlebars/helpers/split.js +8 -0
  55. package/src/handlebars/helpers/tan.js +8 -0
  56. package/src/handlebars/helpers/ternary.js +9 -0
  57. package/src/handlebars/helpers/toDeg.js +8 -0
  58. package/src/handlebars/helpers/toRad.js +8 -0
  59. package/src/handlebars/helpers/withGroup.js +20 -0
  60. package/src/handlebars/helpers/wrapOnNewline.js +11 -0
  61. package/src/handlebars/helpers.js +86 -0
  62. package/src/handlebars/importPartials.js +40 -0
  63. package/src/handlebars/init.js +15 -0
  64. package/src/publish/bot.js +91 -0
  65. package/src/publish/json/gift/gift.json +16 -0
  66. package/src/publish/json/profiles/16PF93.json +201 -0
  67. package/src/publish/json/profiles/AEQ93.json +96 -0
  68. package/src/publish/json/profiles/AMS93.json +102 -0
  69. package/src/publish/json/profiles/AMS9A.json +102 -0
  70. package/src/publish/json/profiles/BAOMEIS93.json +99 -0
  71. package/src/publish/json/profiles/BEQI93.json +1589 -0
  72. package/src/publish/json/profiles/CAATS93.json +11355 -0
  73. package/src/publish/json/profiles/CADS93.json +351 -0
  74. package/src/publish/json/profiles/CARSP93.json +96 -0
  75. package/src/publish/json/profiles/CERQ93.json +106 -0
  76. package/src/publish/json/profiles/CRAAS93.json +98 -0
  77. package/src/publish/json/profiles/CSI93.json +143 -0
  78. package/src/publish/json/profiles/DSWLS93.json +93 -0
  79. package/src/publish/json/profiles/EMSS93.json +116 -0
  80. package/src/publish/json/profiles/FACES93.json +106 -0
  81. package/src/publish/json/profiles/FTEPT93.json +102 -0
  82. package/src/publish/json/profiles/GMIT93.json +98 -0
  83. package/src/publish/json/profiles/HPL93.json +102 -0
  84. package/src/publish/json/profiles/IBT93.json +106 -0
  85. package/src/publish/json/profiles/IUS93.json +93 -0
  86. package/src/publish/json/profiles/JCSI93.json +102 -0
  87. package/src/publish/json/profiles/JPFQ93.json +1 -0
  88. package/src/publish/json/profiles/KJGI93.json +100 -0
  89. package/src/publish/json/profiles/LMIQ93.json +109 -0
  90. package/src/publish/json/profiles/MMFAD93.json +103 -0
  91. package/src/publish/json/profiles/MMFAD9A.json +103 -0
  92. package/src/publish/json/profiles/MOCI93.json +100 -0
  93. package/src/publish/json/profiles/OBQ4493.json +96 -0
  94. package/src/publish/json/profiles/PIES93.json +104 -0
  95. package/src/publish/json/profiles/PIES9A.json +104 -0
  96. package/src/publish/json/profiles/PMCIEF93.json +1 -0
  97. package/src/publish/json/profiles/PSWQ93.json +97 -0
  98. package/src/publish/json/profiles/RIASEC93.json +2511 -0
  99. package/src/publish/json/profiles/SAFE93.json +110 -0
  100. package/src/publish/json/profiles/SASQ93.json +92 -0
  101. package/src/publish/json/profiles/SCASP93.json +611 -0
  102. package/src/publish/json/profiles/SDCAQ93.json +96 -0
  103. package/src/publish/json/profiles/STAIY93.json +98 -0
  104. package/src/publish/json/profiles/WAQ93.json +100 -0
  105. package/src/publish/json/profiles/YBOCS93.json +1322 -0
  106. package/src/publish/json/profiles/empty.json +139 -0
  107. package/src/publish/new-version.hbs +11 -0
  108. package/src/publish/test.js +109 -0
  109. package/src/qrcode/qrCodeGenerator.js +14 -0
  110. package/src/qrcode/qrRender.js +229 -0
  111. package/src/samples/16PF93.js +158 -0
  112. package/src/samples/AEQ93.js +121 -0
  113. package/src/samples/AMS93.js +139 -0
  114. package/src/samples/AMS9A.js +9 -0
  115. package/src/samples/BAOMEIS93.js +146 -0
  116. package/src/samples/BEQI93.js +255 -0
  117. package/src/samples/CAATS93.js +218 -0
  118. package/src/samples/CADS93.js +161 -0
  119. package/src/samples/CARSP93.js +134 -0
  120. package/src/samples/CERQ93.js +195 -0
  121. package/src/samples/CRAAS93.js +141 -0
  122. package/src/samples/CSI93.js +315 -0
  123. package/src/samples/DSWLS93.js +112 -0
  124. package/src/samples/EMSS93.js +178 -0
  125. package/src/samples/FACES93.js +225 -0
  126. package/src/samples/FTEPT93.js +167 -0
  127. package/src/samples/GMIT93.js +142 -0
  128. package/src/samples/HPL93.js +132 -0
  129. package/src/samples/IBT93.js +99 -0
  130. package/src/samples/IUS93.js +204 -0
  131. package/src/samples/JCSI93.js +174 -0
  132. package/src/samples/JPFQ93.js +74 -0
  133. package/src/samples/KJGI93.js +136 -0
  134. package/src/samples/LMIQ93.js +188 -0
  135. package/src/samples/MMFAD93.js +135 -0
  136. package/src/samples/MMFAD9A.js +31 -0
  137. package/src/samples/MOCI93.js +128 -0
  138. package/src/samples/OBQ4493.js +132 -0
  139. package/src/samples/PIES93.js +228 -0
  140. package/src/samples/PIES9A.js +32 -0
  141. package/src/samples/PMCIEF93.js +64 -0
  142. package/src/samples/PSWQ93.js +126 -0
  143. package/src/samples/RIASEC93.js +144 -0
  144. package/src/samples/SAFE93.js +64 -0
  145. package/src/samples/SASQ93.js +130 -0
  146. package/src/samples/SCASP93.js +207 -0
  147. package/src/samples/SDCAQ93.js +174 -0
  148. package/src/samples/STAIY93.js +159 -0
  149. package/src/samples/WAQ93.js +208 -0
  150. package/src/samples/YBOCS93.js +583 -0
  151. package/src/samples/empty.js +53 -0
  152. package/views/gift.hbs +160 -0
  153. package/views/profiles/fonts.css +18 -0
  154. package/views/profiles/layout.hbs +27 -0
  155. package/views/profiles/samples/16PF93.hbs +54 -0
  156. package/views/profiles/samples/AEQ93.hbs +31 -0
  157. package/views/profiles/samples/AMS93.hbs +97 -0
  158. package/views/profiles/samples/AMS9A.hbs +1 -0
  159. package/views/profiles/samples/BAOMEIS93.hbs +48 -0
  160. package/views/profiles/samples/BEQI93.hbs +118 -0
  161. package/views/profiles/samples/CAATS93.hbs +251 -0
  162. package/views/profiles/samples/CADS93.hbs +104 -0
  163. package/views/profiles/samples/CARSP93.hbs +26 -0
  164. package/views/profiles/samples/CERQ93.hbs +115 -0
  165. package/views/profiles/samples/CRAAS93.hbs +88 -0
  166. package/views/profiles/samples/CSI93_1.hbs +110 -0
  167. package/views/profiles/samples/CSI93_2.hbs +76 -0
  168. package/views/profiles/samples/DSWLS93.hbs +26 -0
  169. package/views/profiles/samples/EMSS93.hbs +101 -0
  170. package/views/profiles/samples/FACES93_1.hbs +107 -0
  171. package/views/profiles/samples/FACES93_2.hbs +51 -0
  172. package/views/profiles/samples/FTEPT93.hbs +67 -0
  173. package/views/profiles/samples/GMIT93.hbs +45 -0
  174. package/views/profiles/samples/HPL93.hbs +36 -0
  175. package/views/profiles/samples/IBT93.hbs +67 -0
  176. package/views/profiles/samples/IUS93.hbs +123 -0
  177. package/views/profiles/samples/JCSI93.hbs +65 -0
  178. package/views/profiles/samples/JPFQ93.hbs +44 -0
  179. package/views/profiles/samples/KJGI93.hbs +57 -0
  180. package/views/profiles/samples/LMIQ93.hbs +82 -0
  181. package/views/profiles/samples/MMFAD93.hbs +35 -0
  182. package/views/profiles/samples/MMFAD9A.hbs +1 -0
  183. package/views/profiles/samples/MOCI93.hbs +60 -0
  184. package/views/profiles/samples/OBQ4493.hbs +61 -0
  185. package/views/profiles/samples/PIES93.hbs +67 -0
  186. package/views/profiles/samples/PIES9A.hbs +1 -0
  187. package/views/profiles/samples/PMCIEF93.hbs +8 -0
  188. package/views/profiles/samples/PSWQ93.hbs +32 -0
  189. package/views/profiles/samples/RIASEC93.hbs +38 -0
  190. package/views/profiles/samples/SAFE93.hbs +118 -0
  191. package/views/profiles/samples/SASQ93.hbs +45 -0
  192. package/views/profiles/samples/SCASP93.hbs +94 -0
  193. package/views/profiles/samples/SDCAQ93.hbs +68 -0
  194. package/views/profiles/samples/STAIY93.hbs +67 -0
  195. package/views/profiles/samples/WAQ93.hbs +74 -0
  196. package/views/profiles/samples/YBOCS93_1.hbs +96 -0
  197. package/views/profiles/samples/YBOCS93_2.hbs +115 -0
  198. package/views/profiles/samples/YBOCS93_3.hbs +93 -0
  199. package/views/profiles/samples/empty.hbs +10 -0
  200. package/views/profiles/sidebar.hbs +193 -0
@@ -0,0 +1,8 @@
1
+ // ceil Helper
2
+ // Get the `Math.ceil()` of the given value.
3
+
4
+ function ceil(num) {
5
+ return Math.ceil(num);
6
+ };
7
+
8
+ module.exports = ceil;
@@ -0,0 +1,8 @@
1
+ // concat Helper
2
+ // Concatenate Two Strings
3
+
4
+ function concat(str1, str2, options) {
5
+ return String(str1) + String(str2);
6
+ }
7
+
8
+ module.exports = concat;
@@ -0,0 +1,8 @@
1
+ // cos Helper
2
+ // Calculate Cosine of An Angle
3
+
4
+ function cos(angle) {
5
+ return Math.cos(angle);
6
+ }
7
+
8
+ module.exports = cos;
@@ -0,0 +1,11 @@
1
+ // displacePoint Helper
2
+ // This helper is used to displace given point by given vector and distance
3
+
4
+ function displacePoint(pt, u, d) {
5
+ return {
6
+ x: pt.x + d * u.x,
7
+ y: pt.y + d * u.y,
8
+ };
9
+ }
10
+
11
+ module.exports = displacePoint;
@@ -0,0 +1,10 @@
1
+ // ellipsisChars Helper
2
+ // Putting Ellipsis onto String if Exceeded Our Limit
3
+
4
+ function ellipsisChars(string, maxChar, options) {
5
+ if (string.length <= maxChar) return string;
6
+ const output = string.slice(0, maxChar) + " ...";
7
+ return output;
8
+ }
9
+
10
+ module.exports = ellipsisChars;
@@ -0,0 +1,11 @@
1
+ // ellipsisLines Helper
2
+ // Putting Ellipsis onto Lines if Exceeded Our Limit
3
+
4
+ function ellipsisLines(lines, maxLines, options) {
5
+ if (lines.length <= maxLines) return lines;
6
+ const output = lines.slice(0, maxLines);
7
+ output[maxLines - 1] += " ...";
8
+ return output;
9
+ }
10
+
11
+ module.exports = ellipsisLines;
@@ -0,0 +1,11 @@
1
+ // first Helper
2
+ // Returns the first item, or first `n` items of an array.
3
+
4
+ function first(array, n) {
5
+ if (typeof n !== 'number') {
6
+ return array[0];
7
+ }
8
+ return array.slice(0, n);
9
+ }
10
+
11
+ module.exports = first;
@@ -0,0 +1,8 @@
1
+ // ceil Helper
2
+ // Get the `Math.floor()` of the given value.
3
+
4
+ function floor(num) {
5
+ return Math.floor(num);
6
+ };
7
+
8
+ module.exports = floor;
@@ -0,0 +1,15 @@
1
+ // forLoop Helper
2
+ // Implement For Loop in Handlebars
3
+
4
+ function forLoop(from, to, incr, block) {
5
+ let accum = "";
6
+ for (let i = from; i < to; i += incr) {
7
+ block.data.i = i;
8
+ block.data.first = i === 0;
9
+ block.data.last = i === to - 1;
10
+ accum += block.fn({i});
11
+ }
12
+ return accum;
13
+ }
14
+
15
+ module.exports = forLoop;
@@ -0,0 +1,8 @@
1
+ // getArrOfProp Helper
2
+ // Used to get one specific property of object in an array (as an array itself)
3
+
4
+ function getArrOfProp(arr, prop) {
5
+ return arr.map(elem => elem[prop])
6
+ }
7
+
8
+ module.exports = getArrOfProp;
@@ -0,0 +1,8 @@
1
+ // isArray Helper
2
+ // Checks whether input is array or not
3
+
4
+ function isArray(arr) {
5
+ return Array.isArray(arr);
6
+ }
7
+
8
+ module.exports = isArray;
@@ -0,0 +1,10 @@
1
+ // join Helper
2
+ // Join all elements of array into a string, optionally using a given separator
3
+
4
+ function join(array, separator) {
5
+ if (typeof array === 'string') return array;
6
+ if (!Array.isArray(array)) return '';
7
+ return array.join(separator);
8
+ };
9
+
10
+ module.exports = join;
@@ -0,0 +1,11 @@
1
+ // last Helper
2
+ // Returns the last item, or last `n` items of an array or string.
3
+
4
+ function last(value, n) {
5
+ if (typeof n !== 'number') {
6
+ return value[value.length - 1];
7
+ }
8
+ return value.slice(-Math.abs(n));
9
+ };
10
+
11
+ module.exports = last;
@@ -0,0 +1,28 @@
1
+ // lineWrap Helper
2
+ // Wrapping Words into Lines
3
+
4
+ function lineWrap(string, maxChar, options) {
5
+ let tokens = string.split(" ");
6
+ let lines = [];
7
+ let i = 0;
8
+ let L = 0;
9
+ while(true) {
10
+ let tokenLength = tokens[i].replace(/‌/g, '').length;
11
+ L += tokenLength + 1;
12
+ if (L - 1 > maxChar) {
13
+ lines.push(tokens.slice(0, i).join(" ").trim());
14
+ tokens = tokens.slice(i);
15
+ i = 0;
16
+ L = 0;
17
+ continue;
18
+ } else if (i >= tokens.length - 1) {
19
+ lines.push(tokens.slice(0, i + 1).join(" "));
20
+ break;
21
+ }
22
+ i++;
23
+ }
24
+
25
+ return lines;
26
+ }
27
+
28
+ module.exports = lineWrap;
@@ -0,0 +1,24 @@
1
+ // math Helper
2
+ // Implements Arithmetic Operations in Handlebars
3
+
4
+ function math(lvalue, operator, rvalue, options) {
5
+ if (arguments.length < 4) {
6
+ // Operator omitted, assuming "+"
7
+ options = rvalue;
8
+ rvalue = operator;
9
+ operator = "+";
10
+ }
11
+
12
+ lvalue = parseFloat(lvalue);
13
+ rvalue = parseFloat(rvalue);
14
+
15
+ return {
16
+ "+": lvalue + rvalue,
17
+ "-": lvalue - rvalue,
18
+ "*": lvalue * rvalue,
19
+ "/": lvalue / rvalue,
20
+ "%": lvalue % rvalue,
21
+ }[operator];
22
+ }
23
+
24
+ module.exports = math;
@@ -0,0 +1,8 @@
1
+ // modulo Helper
2
+ // Calculates Remainder of Division
3
+
4
+ function modulo(a, b) {
5
+ return Number(a) % Number(b);
6
+ }
7
+
8
+ module.exports = modulo;
@@ -0,0 +1,7 @@
1
+ // This function is for normalizing given angles in the range (-PI, PI]
2
+
3
+ function normalizeAngle(angle) {
4
+ return Math.atan2(Math.sin(angle), Math.cos(angle));
5
+ }
6
+
7
+ module.exports = normalizeAngle;
@@ -0,0 +1,8 @@
1
+ // object Helper
2
+ // This helper is used to defined object literals in handlebars
3
+
4
+ function object({hash}) {
5
+ return hash;
6
+ }
7
+
8
+ module.exports = object;
@@ -0,0 +1,8 @@
1
+ // objectEntries Helper
2
+ // This helper is used to get object entries
3
+
4
+ function objectEntries(obj) {
5
+ return Object.entries(obj);
6
+ }
7
+
8
+ module.exports = objectEntries;
@@ -0,0 +1,14 @@
1
+ // polarToCartesian Helper
2
+ // Convert Polar Coordinates to Cartesian
3
+
4
+ function polarToCartesian(r, theta) {
5
+ return {
6
+ x: +(r * Math.cos(theta)).toFixed(2),
7
+ y: +(r * Math.sin(theta)).toFixed(2),
8
+ get toString() {
9
+ return `${this.x} ${this.y}`
10
+ }
11
+ }
12
+ }
13
+
14
+ module.exports = polarToCartesian;
@@ -0,0 +1,10 @@
1
+ // prepend Helper
2
+ // Prepends the Given String with the Specified Prefix
3
+
4
+ function prepend(str, prefix) {
5
+ return typeof str === 'string' && typeof prefix === 'string'
6
+ ? (prefix + str)
7
+ : str;
8
+ };
9
+
10
+ module.exports = prepend;
@@ -0,0 +1,45 @@
1
+ // bar Helper
2
+ // This helper is used to provide the path tag for the bar chart
3
+
4
+ const Handlebars = require("handlebars");
5
+ const polarToCartesian = require("../polarToCartesian");
6
+
7
+ const P2C = polarToCartesian;
8
+ const PI = Math.PI;
9
+
10
+ function bar(W, H, brs, angle, options) {
11
+ // W: width
12
+ // H: height
13
+ // brs: border radiuses : {tl: top-left, tr: top-right, bl: bottom-left, br: bottom-right}
14
+
15
+ const attributes = [];
16
+
17
+ Object.keys(options.hash).forEach((key) => {
18
+ const escapedKey = Handlebars.escapeExpression(key);
19
+ const escapedValue = Handlebars.escapeExpression(options.hash[key]);
20
+ attributes.push(escapedKey + '="' + escapedValue + '"');
21
+ });
22
+
23
+ // Calculate "d" Attribute of Path
24
+ let dAttr = `M ${P2C(W / 2, angle).toString}`;
25
+
26
+ dAttr += `L ${P2C(brs.tl, angle).toString}`;
27
+ dAttr += brs.tl ? `A ${brs.tl} ${brs.tl} 90 0 0 ${P2C(brs.tl, PI / 2 + angle).toString}` : "";
28
+
29
+ dAttr += `L ${P2C(H - brs.bl, PI / 2 + angle).toString}`;
30
+ dAttr += brs.bl ? `a ${brs.bl} ${brs.bl} 90 0 0 ${P2C(1.414 * brs.bl, PI / 4 + angle).toString}` : "";
31
+
32
+ dAttr += `l ${P2C(W - brs.bl - brs.br, angle).toString}`;
33
+ dAttr += brs.br ? `a ${brs.br} ${brs.br} 90 0 0 ${P2C(1.414 * brs.br, -PI / 4 + angle).toString}` : "";
34
+
35
+ dAttr += `l ${P2C(-(H - brs.br - brs.tr), PI / 2 + angle).toString}`;
36
+ dAttr += brs.tr ? `A ${brs.tr} ${brs.tr} 90 0 0 ${P2C(W - brs.tr, angle).toString}` : "";
37
+
38
+ dAttr += `L ${P2C(W / 2, angle).toString}`;
39
+
40
+ let result = `<path d="${dAttr}" ${attributes.join(" ")}/>`;
41
+
42
+ return new Handlebars.SafeString(result);
43
+ }
44
+
45
+ module.exports = bar;
@@ -0,0 +1,34 @@
1
+ // This Function is Used in the Gauge Helper and It's not an Independant Helper Itself.
2
+
3
+ const polarToCartesian = require("../polarToCartesian");
4
+ const P2C = polarToCartesian;
5
+
6
+ /**
7
+ * This function is used to calculate gauge element side points
8
+ * @param {number} R - outer radius
9
+ * @param {number} r - inner radius
10
+ * @param {object} br - border radiuses: {top, bottom}
11
+ * @param {number} angle - angle of the end in radians
12
+ * @param {boolean} start - whether the corresponding side is start or end of the gauge element
13
+ * @param {boolean} direction - direction of the gauge (false: clockwise, true: counterclockwise)
14
+ */
15
+ function calcGaugeSidePoints(R, r, brs, angle, start, direction) {
16
+ const alpha = {},
17
+ theta = {};
18
+ for (let key in brs) {
19
+ alpha[key] = Math.asin(brs[key] / (R - brs[key]));
20
+ theta[key] = angle + (start ^ direction ? 1 : -1) * alpha[key];
21
+ }
22
+
23
+ let points = {
24
+ P1: P2C(R, theta.top),
25
+ P2: P2C(r, theta.bottom),
26
+ };
27
+
28
+ if (brs.top) points["P1_PRIME"] = P2C((R - brs.top) * Math.cos(alpha.top), angle);
29
+ if (brs.bottom) points["P2_PRIME"] = P2C((r + brs.bottom) * Math.cos(alpha.bottom), angle);
30
+
31
+ return points;
32
+ }
33
+
34
+ module.exports = calcGaugeSidePoints;
@@ -0,0 +1,61 @@
1
+ // gauge Helper
2
+ // This helper is used to provide the path tag for the gauge chart
3
+
4
+ const Handlebars = require("handlebars");
5
+ const calcGaugeSidePoints = require("./calcGaugeSidePoints");
6
+ const normalizeAngle = require("../normalizeAngle");
7
+
8
+ /**
9
+ * Create path tag for the gauge element used in the profiles
10
+ * @param {number} R - outer radius
11
+ * @param {number} r - inner radius
12
+ * @param {object} brs - border radiuses: {tl: top-left, tr: top-right, bl: bottom-left, br: bottom-right}
13
+ * @param {object} angles - angles of sides of the gauge: {start, end}
14
+ * @param {boolean} direction - direction of the gauge (false: clockwise, true: counterclockwise)
15
+ * @param {object} options
16
+ */
17
+ function gauge(R, r, brs, angles, direction, options) {
18
+ // Extract attributes out of options
19
+ const attributes = [];
20
+
21
+ Object.keys(options.hash).forEach((key) => {
22
+ const escapedKey = Handlebars.escapeExpression(key);
23
+ const escapedValue = Handlebars.escapeExpression(options.hash[key]);
24
+ attributes.push(escapedKey + '="' + escapedValue + '"');
25
+ });
26
+
27
+ // Normalize the angles to be in the range (-PI, PI]
28
+ for (let key in angles) angles[key] = normalizeAngle(angles[key]);
29
+
30
+ let isGreater = true;
31
+ if (angles.end < angles.start) isGreater = false;
32
+
33
+ const totalAngle =
34
+ direction ^ isGreater ? Math.abs(angles.end - angles.start) : 2 * Math.PI - Math.abs(angles.end - angles.start);
35
+
36
+ const sidePoints = {
37
+ start: calcGaugeSidePoints(R, r, { top: brs.tl, bottom: brs.bl }, angles.start, true, direction),
38
+ end: calcGaugeSidePoints(R, r, { top: brs.tr, bottom: brs.br }, angles.end, false, direction),
39
+ };
40
+
41
+ // Calculate "d" Attribute of Path
42
+ let dAttr = `M ${sidePoints.start.P1.toString}`;
43
+
44
+ dAttr += `A ${R} ${R} 1 ${totalAngle > Math.PI ? 1 : 0} ${direction ? 0 : 1} ${sidePoints.end.P1.toString}`;
45
+
46
+ dAttr += brs.tr ? `A ${brs.tr} ${brs.tr} 1 0 ${direction ? 0 : 1} ${sidePoints.end.P1_PRIME.toString}` : "";
47
+ dAttr += `L ${sidePoints.end.P2_PRIME?.toString || sidePoints.end.P2.toString}`;
48
+ dAttr += brs.br ? `A ${brs.br} ${brs.br} 1 0 ${direction ? 0 : 1} ${sidePoints.end.P2.toString}` : "";
49
+
50
+ dAttr += `A ${r} ${r} 1 ${totalAngle > Math.PI ? 1 : 0} ${direction ? 1 : 0} ${sidePoints.start.P2.toString}`;
51
+
52
+ dAttr += brs.bl ? `A ${brs.bl} ${brs.bl} 1 0 ${direction ? 0 : 1} ${sidePoints.start.P2_PRIME.toString}` : "";
53
+ dAttr += `L ${sidePoints.start.P1_PRIME?.toString || sidePoints.start.P1.toString}`;
54
+ dAttr += brs.tl ? `A ${brs.tl} ${brs.tl} 1 0 ${direction ? 0 : 1} ${sidePoints.start.P1.toString}` : "";
55
+
56
+ let result = `<path d="${dAttr}" ${attributes.join(" ")}/>`;
57
+
58
+ return new Handlebars.SafeString(result);
59
+ }
60
+
61
+ module.exports = gauge;
@@ -0,0 +1,40 @@
1
+ // bar Helper
2
+ // This helper is used to provide the path tag for the radar chart
3
+
4
+ const Handlebars = require("handlebars");
5
+ const polarToCartesian = require("../polarToCartesian");
6
+
7
+ const P2C = polarToCartesian;
8
+ const PI = Math.PI;
9
+
10
+ /**
11
+ * Create path tag for the polygon of the radar chart
12
+ * @param {number} n - number of the vertices of the polygon
13
+ * @param {array} radiuses - array of radius of the corresponding vertice of the polygon
14
+ * @param {number} angle - angle of one vertice in radians
15
+ * @param {object} options
16
+ */
17
+ function polygon(n, radiuses, angle, options) {
18
+ if (!Array.isArray(radiuses)) radiuses = Array(n).fill(radiuses);
19
+
20
+ const attributes = [];
21
+
22
+ Object.keys(options.hash).forEach((key) => {
23
+ const escapedKey = Handlebars.escapeExpression(key);
24
+ const escapedValue = Handlebars.escapeExpression(options.hash[key]);
25
+ attributes.push(escapedKey + '="' + escapedValue + '"');
26
+ });
27
+
28
+ // theta is the angle of the polygon
29
+ const theta = (2 * PI) / n;
30
+
31
+ const points = radiuses.map((radius, index) => P2C(radius, angle - index * theta));
32
+
33
+ let pointsAttr = points.reduce((accm, point) => accm + `${point.x},${point.y} `, "");
34
+
35
+ let result = `<polygon points="${pointsAttr}" ${attributes.join(" ")}/>`;
36
+
37
+ return new Handlebars.SafeString(result);
38
+ }
39
+
40
+ module.exports = polygon;
@@ -0,0 +1,9 @@
1
+ // reverse Helper
2
+ // This helper is used to reverse an array elements
3
+
4
+ function reverse(arr) {
5
+ const newArr = arr.slice();
6
+ return newArr.reverse();
7
+ }
8
+
9
+ module.exports = reverse;
@@ -0,0 +1,8 @@
1
+ // roundToTwo Helper
2
+ // This helper rounds given number to two decimal places
3
+
4
+ function roundToTwo(num) {
5
+ return +num.toFixed(2);
6
+ }
7
+
8
+ module.exports = roundToTwo;
@@ -0,0 +1,8 @@
1
+ // setVar Helper
2
+ // Setting Variable inside Handlebars
3
+
4
+ function setVar(varName, varValue, options) {
5
+ this[varName] = varValue
6
+ }
7
+
8
+ module.exports = setVar;
@@ -0,0 +1,8 @@
1
+ // sin Helper
2
+ // Calculate Sine of An Angle
3
+
4
+ function sin(angle) {
5
+ return Math.sin(angle);
6
+ }
7
+
8
+ module.exports = sin;
@@ -0,0 +1,8 @@
1
+ // split Helper
2
+ // Split string by the given character
3
+
4
+ function split(str, ch) {
5
+ return str.split(ch);
6
+ };
7
+
8
+ module.exports = split;
@@ -0,0 +1,8 @@
1
+ // tan Helper
2
+ // Calculate Tangent of An Angle
3
+
4
+ function tan(angle) {
5
+ return Math.tan(angle);
6
+ }
7
+
8
+ module.exports = tan;
@@ -0,0 +1,9 @@
1
+ // ternary Helper
2
+ // Evaluates Ternary Conditional Operator
3
+
4
+ function ternary(boolean, v1, v2, options) {
5
+ return boolean ? v1 : v2;
6
+ }
7
+
8
+ module.exports = ternary;
9
+
@@ -0,0 +1,8 @@
1
+ // toDeg Helper
2
+ // Convert an Angle to Degree
3
+
4
+ function toDeg(angle) {
5
+ return angle * 180 / Math.PI;
6
+ }
7
+
8
+ module.exports = toDeg;
@@ -0,0 +1,8 @@
1
+ // toRad Helper
2
+ // Convert an Angle to Radians
3
+
4
+ function toRad(angle) {
5
+ return angle * Math.PI / 180;
6
+ }
7
+
8
+ module.exports = toRad;
@@ -0,0 +1,20 @@
1
+ // withGroup Helper
2
+ // Block Helper that Groups Array Elements by Given Group Size
3
+
4
+ function withGroup(array, size, options) {
5
+ var result = '';
6
+ if (Array.isArray(array) && array.length > 0) {
7
+ var subcontext = [];
8
+ for (var i = 0; i < array.length; i++) {
9
+ if (i > 0 && (i % size) === 0) {
10
+ result += options.fn(subcontext);
11
+ subcontext = [];
12
+ }
13
+ subcontext.push(array[i]);
14
+ }
15
+ result += options.fn(subcontext);
16
+ }
17
+ return result;
18
+ };
19
+
20
+ module.exports = withGroup;
@@ -0,0 +1,11 @@
1
+ // wrapOnNewline Helper
2
+ // Used to split a string by \n to create lines
3
+
4
+ const Handlebars = require("handlebars");
5
+
6
+ function wrapOnNewline(string) {
7
+ string = string.replace(/\\n/gm, '\n');
8
+ return string.split(/\n/gm);
9
+ }
10
+
11
+ module.exports = wrapOnNewline;
@@ -0,0 +1,86 @@
1
+ const isArray = require("./helpers/isArray");
2
+ const addCommas = require("./helpers/addCommas");
3
+ const boolean = require("./helpers/boolean");
4
+ const math = require("./helpers/math");
5
+ const modulo = require("./helpers/modulo");
6
+ const ternary = require("./helpers/ternary");
7
+ const lineWrap = require("./helpers/lineWrap");
8
+ const wrapOnNewline = require("./helpers/wrapOnNewline");
9
+ const ellipsisLines = require("./helpers/ellipsisLines");
10
+ const ellipsisChars = require("./helpers/ellipsisChars");
11
+ const setVar = require("./helpers/setVar");
12
+ const assignGlobal = require("./helpers/assignGlobal");
13
+ const forLoop = require("./helpers/forLoop");
14
+ const concat = require("./helpers/concat");
15
+ const sin = require("./helpers/sin");
16
+ const cos = require("./helpers/cos");
17
+ const tan = require("./helpers/tan");
18
+ const toDeg = require("./helpers/toDeg");
19
+ const toRad = require("./helpers/toRad");
20
+ const roundToTwo = require("./helpers/roundToTwo");
21
+ const objectEntries = require("./helpers/objectEntries");
22
+ const object = require("./helpers/object");
23
+ const array = require("./helpers/array");
24
+ const reverse = require("./helpers/reverse");
25
+ const prepend = require("./helpers/prepend");
26
+ const polarToCartesian = require("./helpers/polarToCartesian");
27
+ const abs = require("./helpers/abs");
28
+ const getArrOfProp = require("./helpers/getArrOfProp");
29
+ const displacePoint = require("./helpers/displacePoint");
30
+ const normalizeAngle = require("./helpers/normalizeAngle");
31
+ const withGroup = require("./helpers/withGroup");
32
+ const join = require("./helpers/join");
33
+ const split = require("./helpers/split");
34
+ const first = require("./helpers/first");
35
+ const last = require("./helpers/last");
36
+ const ceil = require("./helpers/ceil");
37
+ const floor = require("./helpers/floor");
38
+
39
+ const polygon = require("./helpers/profiles/polygon");
40
+ const gauge = require("./helpers/profiles/gauge");
41
+ const bar = require("./helpers/profiles/bar");
42
+
43
+ const helpers = {
44
+ isArray,
45
+ addCommas,
46
+ boolean,
47
+ math,
48
+ modulo,
49
+ ternary,
50
+ lineWrap,
51
+ wrapOnNewline,
52
+ ellipsisLines,
53
+ ellipsisChars,
54
+ setVar,
55
+ assignGlobal,
56
+ forLoop,
57
+ concat,
58
+ sin,
59
+ cos,
60
+ tan,
61
+ toDeg,
62
+ toRad,
63
+ roundToTwo,
64
+ objectEntries,
65
+ object,
66
+ array,
67
+ reverse,
68
+ prepend,
69
+ polarToCartesian,
70
+ abs,
71
+ getArrOfProp,
72
+ displacePoint,
73
+ normalizeAngle,
74
+ withGroup,
75
+ join,
76
+ split,
77
+ first,
78
+ last,
79
+ ceil,
80
+ floor,
81
+ polygon,
82
+ gauge,
83
+ bar,
84
+ };
85
+
86
+ module.exports = helpers;