@bitbybit-dev/base 1.3.2 → 1.4.0-rc.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 (77) hide show
  1. package/README.md +1 -1
  2. package/lib/api/GlobalCDNProvider.js +1 -1
  3. package/lib/api/index.d.ts +2 -0
  4. package/lib/api/index.js +2 -0
  5. package/lib/api/inputs/base-inputs.d.ts +10 -4
  6. package/lib/api/inputs/color-inputs.d.ts +24 -23
  7. package/lib/api/inputs/color-inputs.js +1 -0
  8. package/lib/api/inputs/dates-inputs.d.ts +16 -16
  9. package/lib/api/inputs/frame-inputs.d.ts +515 -0
  10. package/lib/api/inputs/frame-inputs.js +617 -0
  11. package/lib/api/inputs/index.d.ts +1 -0
  12. package/lib/api/inputs/index.js +1 -0
  13. package/lib/api/inputs/io-inputs.d.ts +3 -3
  14. package/lib/api/inputs/io-inputs.js +1 -1
  15. package/lib/api/inputs/lists-inputs.d.ts +23 -23
  16. package/lib/api/inputs/logic-inputs.d.ts +11 -11
  17. package/lib/api/inputs/math-inputs.d.ts +49 -49
  18. package/lib/api/inputs/math-inputs.js +4 -4
  19. package/lib/api/inputs/mesh-inputs.d.ts +3 -3
  20. package/lib/api/inputs/mesh-inputs.js +3 -3
  21. package/lib/api/inputs/point-inputs.d.ts +39 -38
  22. package/lib/api/inputs/point-inputs.js +6 -5
  23. package/lib/api/inputs/polyline-inputs.d.ts +5 -4
  24. package/lib/api/inputs/polyline-inputs.js +3 -3
  25. package/lib/api/inputs/text-inputs.d.ts +34 -33
  26. package/lib/api/inputs/text-inputs.js +15 -12
  27. package/lib/api/inputs/transforms-inputs.d.ts +16 -16
  28. package/lib/api/inputs/vector-inputs.d.ts +26 -25
  29. package/lib/api/inputs/vector-inputs.js +2 -1
  30. package/lib/api/kernel-calls/call-by-path.d.ts +12 -0
  31. package/lib/api/kernel-calls/call-by-path.js +36 -0
  32. package/lib/api/kernel-calls/constraints.d.ts +53 -0
  33. package/lib/api/kernel-calls/constraints.js +21 -0
  34. package/lib/api/kernel-calls/describe-failure.d.ts +32 -0
  35. package/lib/api/kernel-calls/describe-failure.js +164 -0
  36. package/lib/api/kernel-calls/errors.d.ts +55 -0
  37. package/lib/api/kernel-calls/errors.js +42 -0
  38. package/lib/api/kernel-calls/failure-message.d.ts +18 -0
  39. package/lib/api/kernel-calls/failure-message.js +36 -0
  40. package/lib/api/kernel-calls/index.d.ts +10 -0
  41. package/lib/api/kernel-calls/index.js +10 -0
  42. package/lib/api/kernel-calls/input-rules.d.ts +67 -0
  43. package/lib/api/kernel-calls/input-rules.js +135 -0
  44. package/lib/api/kernel-calls/input-validation.d.ts +130 -0
  45. package/lib/api/kernel-calls/input-validation.js +221 -0
  46. package/lib/api/kernel-calls/rehydrate.d.ts +16 -0
  47. package/lib/api/kernel-calls/rehydrate.js +38 -0
  48. package/lib/api/kernel-calls/resolve-dto.d.ts +59 -0
  49. package/lib/api/kernel-calls/resolve-dto.js +61 -0
  50. package/lib/api/kernel-calls/with-defaults.d.ts +16 -0
  51. package/lib/api/kernel-calls/with-defaults.js +53 -0
  52. package/lib/api/resolved-inputs/index.d.ts +304 -0
  53. package/lib/api/resolved-inputs/index.js +1 -0
  54. package/lib/api/services/color.js +43 -26
  55. package/lib/api/services/dates.js +53 -33
  56. package/lib/api/services/frame.d.ts +670 -0
  57. package/lib/api/services/frame.js +1040 -0
  58. package/lib/api/services/helpers/dxf/dxf-generator.d.ts +2 -3
  59. package/lib/api/services/helpers/dxf/dxf-generator.js +27 -37
  60. package/lib/api/services/helpers/dxf/dxf.js +10 -4
  61. package/lib/api/services/helpers/frame-axes.d.ts +36 -0
  62. package/lib/api/services/helpers/frame-axes.js +57 -0
  63. package/lib/api/services/helpers/matrices.d.ts +17 -0
  64. package/lib/api/services/helpers/matrices.js +51 -0
  65. package/lib/api/services/index.d.ts +1 -0
  66. package/lib/api/services/index.js +1 -0
  67. package/lib/api/services/line.js +15 -12
  68. package/lib/api/services/lists.js +174 -136
  69. package/lib/api/services/logic.js +44 -34
  70. package/lib/api/services/math.js +127 -82
  71. package/lib/api/services/mesh.js +20 -13
  72. package/lib/api/services/point.js +62 -46
  73. package/lib/api/services/polyline.js +22 -18
  74. package/lib/api/services/text.js +81 -46
  75. package/lib/api/services/transforms.js +38 -25
  76. package/lib/api/services/vector.js +37 -22
  77. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ import * as Inputs from "../inputs";
2
+ import { resolveDto } from "../kernel-calls";
1
3
  /**
2
4
  * Booleans and decisions: comparing values, flipping booleans, turning lists of numbers into lists
3
5
  * of booleans by thresholds, drawing random booleans, and gating a value so it passes only when a
@@ -16,7 +18,8 @@ export class Logic {
16
18
  * @drawable false
17
19
  */
18
20
  boolean(inputs) {
19
- return inputs.boolean;
21
+ const resolved = resolveDto(Inputs.Logic.BooleanDto, inputs);
22
+ return resolved.boolean;
20
23
  }
21
24
  /**
22
25
  * Draws a list of random booleans, each true with a given probability.
@@ -33,9 +36,10 @@ export class Logic {
33
36
  * ```
34
37
  */
35
38
  randomBooleans(inputs) {
39
+ const resolved = resolveDto(Inputs.Logic.RandomBooleansDto, inputs);
36
40
  const booleans = [];
37
- for (let i = 0; i < inputs.length; i++) {
38
- booleans.push(Math.random() < inputs.trueThreshold);
41
+ for (let i = 0; i < resolved.length; i++) {
42
+ booleans.push(Math.random() < resolved.trueThreshold);
39
43
  }
40
44
  return booleans;
41
45
  }
@@ -62,19 +66,20 @@ export class Logic {
62
66
  * ```
63
67
  */
64
68
  twoThresholdRandomGradient(inputs) {
69
+ const resolved = resolveDto(Inputs.Logic.TwoThresholdRandomGradientDto, inputs);
65
70
  const booleans = [];
66
- inputs.numbers.forEach(n => {
67
- if (n < inputs.thresholdTotalTrue) {
71
+ resolved.numbers.forEach(n => {
72
+ if (n < resolved.thresholdTotalTrue) {
68
73
  booleans.push(true);
69
74
  }
70
- else if (n > inputs.thresholdTotalFalse) {
75
+ else if (n > resolved.thresholdTotalFalse) {
71
76
  booleans.push(false);
72
77
  }
73
78
  else {
74
- const leveledNr = n - inputs.thresholdTotalTrue;
75
- const step = (inputs.thresholdTotalFalse - inputs.thresholdTotalTrue) / inputs.nrLevels;
79
+ const leveledNr = n - resolved.thresholdTotalTrue;
80
+ const step = (resolved.thresholdTotalFalse - resolved.thresholdTotalTrue) / resolved.nrLevels;
76
81
  const whichCat = Math.ceil(leveledNr / step);
77
- const bound = whichCat / inputs.nrLevels;
82
+ const bound = whichCat / resolved.nrLevels;
78
83
  const random = Math.random();
79
84
  if (random > bound) {
80
85
  booleans.push(true);
@@ -102,16 +107,17 @@ export class Logic {
102
107
  * ```
103
108
  */
104
109
  thresholdBooleanList(inputs) {
110
+ const resolved = resolveDto(Inputs.Logic.ThresholdBooleanListDto, inputs);
105
111
  const booleans = [];
106
- inputs.numbers.forEach(n => {
107
- if (n < inputs.threshold) {
112
+ resolved.numbers.forEach(n => {
113
+ if (n < resolved.threshold) {
108
114
  booleans.push(true);
109
115
  }
110
116
  else {
111
117
  booleans.push(false);
112
118
  }
113
119
  });
114
- if (inputs.inverse) {
120
+ if (resolved.inverse) {
115
121
  return booleans.map(b => !b);
116
122
  }
117
123
  return booleans;
@@ -137,10 +143,11 @@ export class Logic {
137
143
  * ```
138
144
  */
139
145
  thresholdGapsBooleanList(inputs) {
146
+ const resolved = resolveDto(Inputs.Logic.ThresholdGapsBooleanListDto, inputs);
140
147
  const booleans = [];
141
- inputs.numbers.forEach(n => {
148
+ resolved.numbers.forEach(n => {
142
149
  let foundInThresholds = false;
143
- inputs.gapThresholds.forEach(t => {
150
+ resolved.gapThresholds.forEach(t => {
144
151
  const min = t[0];
145
152
  const max = t[1];
146
153
  if (n >= min && n <= max) {
@@ -152,7 +159,7 @@ export class Logic {
152
159
  booleans.push(false);
153
160
  }
154
161
  });
155
- if (inputs.inverse) {
162
+ if (resolved.inverse) {
156
163
  return booleans.map(b => !b);
157
164
  }
158
165
  return booleans;
@@ -168,7 +175,8 @@ export class Logic {
168
175
  * @drawable false
169
176
  */
170
177
  not(inputs) {
171
- return !inputs.boolean;
178
+ const resolved = resolveDto(Inputs.Logic.BooleanDto, inputs);
179
+ return !resolved.boolean;
172
180
  }
173
181
  /**
174
182
  * Flips every boolean in a list.
@@ -199,23 +207,24 @@ export class Logic {
199
207
  * ```
200
208
  */
201
209
  compare(inputs) {
202
- switch (inputs.operator) {
203
- case "==":
204
- return inputs.first == inputs.second;
205
- case "!=":
206
- return inputs.first != inputs.second;
207
- case "===":
208
- return inputs.first === inputs.second;
209
- case "!==":
210
- return inputs.first !== inputs.second;
211
- case "<":
212
- return inputs.first < inputs.second;
213
- case "<=":
214
- return inputs.first <= inputs.second;
215
- case ">":
216
- return inputs.first > inputs.second;
217
- case ">=":
218
- return inputs.first >= inputs.second;
210
+ const resolved = resolveDto(Inputs.Logic.ComparisonDto, inputs);
211
+ switch (resolved.operator) {
212
+ case Inputs.Logic.BooleanOperatorsEnum.equal:
213
+ return resolved.first == resolved.second;
214
+ case Inputs.Logic.BooleanOperatorsEnum.notEqual:
215
+ return resolved.first != resolved.second;
216
+ case Inputs.Logic.BooleanOperatorsEnum.tripleEqual:
217
+ return resolved.first === resolved.second;
218
+ case Inputs.Logic.BooleanOperatorsEnum.tripleNotEqual:
219
+ return resolved.first !== resolved.second;
220
+ case Inputs.Logic.BooleanOperatorsEnum.less:
221
+ return resolved.first < resolved.second;
222
+ case Inputs.Logic.BooleanOperatorsEnum.lessOrEqual:
223
+ return resolved.first <= resolved.second;
224
+ case Inputs.Logic.BooleanOperatorsEnum.greater:
225
+ return resolved.first > resolved.second;
226
+ case Inputs.Logic.BooleanOperatorsEnum.greaterOrEqual:
227
+ return resolved.first >= resolved.second;
219
228
  default:
220
229
  return false;
221
230
  }
@@ -235,7 +244,8 @@ export class Logic {
235
244
  * ```
236
245
  */
237
246
  valueGate(inputs) {
238
- return inputs.boolean ? inputs.value : undefined;
247
+ const resolved = resolveDto(Inputs.Logic.ValueGateDto, inputs);
248
+ return resolved.boolean ? resolved.value : undefined;
239
249
  }
240
250
  /**
241
251
  * Picks the first of two values that is defined, so the second acts as a fallback.