@bitbybit-dev/base 1.3.2-rc.1 → 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.
- package/README.md +1 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +2 -0
- package/lib/api/inputs/base-inputs.d.ts +10 -4
- package/lib/api/inputs/color-inputs.d.ts +24 -23
- package/lib/api/inputs/color-inputs.js +1 -0
- package/lib/api/inputs/dates-inputs.d.ts +16 -16
- package/lib/api/inputs/frame-inputs.d.ts +515 -0
- package/lib/api/inputs/frame-inputs.js +617 -0
- package/lib/api/inputs/index.d.ts +1 -0
- package/lib/api/inputs/index.js +1 -0
- package/lib/api/inputs/io-inputs.d.ts +3 -3
- package/lib/api/inputs/io-inputs.js +1 -1
- package/lib/api/inputs/lists-inputs.d.ts +23 -23
- package/lib/api/inputs/logic-inputs.d.ts +11 -11
- package/lib/api/inputs/math-inputs.d.ts +49 -49
- package/lib/api/inputs/math-inputs.js +4 -4
- package/lib/api/inputs/mesh-inputs.d.ts +3 -3
- package/lib/api/inputs/mesh-inputs.js +3 -3
- package/lib/api/inputs/point-inputs.d.ts +39 -38
- package/lib/api/inputs/point-inputs.js +6 -5
- package/lib/api/inputs/polyline-inputs.d.ts +5 -4
- package/lib/api/inputs/polyline-inputs.js +3 -3
- package/lib/api/inputs/text-inputs.d.ts +34 -33
- package/lib/api/inputs/text-inputs.js +15 -12
- package/lib/api/inputs/transforms-inputs.d.ts +16 -16
- package/lib/api/inputs/vector-inputs.d.ts +26 -25
- package/lib/api/inputs/vector-inputs.js +2 -1
- package/lib/api/kernel-calls/call-by-path.d.ts +12 -0
- package/lib/api/kernel-calls/call-by-path.js +36 -0
- package/lib/api/kernel-calls/constraints.d.ts +53 -0
- package/lib/api/kernel-calls/constraints.js +21 -0
- package/lib/api/kernel-calls/describe-failure.d.ts +32 -0
- package/lib/api/kernel-calls/describe-failure.js +164 -0
- package/lib/api/kernel-calls/errors.d.ts +55 -0
- package/lib/api/kernel-calls/errors.js +42 -0
- package/lib/api/kernel-calls/failure-message.d.ts +18 -0
- package/lib/api/kernel-calls/failure-message.js +36 -0
- package/lib/api/kernel-calls/index.d.ts +10 -0
- package/lib/api/kernel-calls/index.js +10 -0
- package/lib/api/kernel-calls/input-rules.d.ts +67 -0
- package/lib/api/kernel-calls/input-rules.js +135 -0
- package/lib/api/kernel-calls/input-validation.d.ts +130 -0
- package/lib/api/kernel-calls/input-validation.js +221 -0
- package/lib/api/kernel-calls/rehydrate.d.ts +16 -0
- package/lib/api/kernel-calls/rehydrate.js +38 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +59 -0
- package/lib/api/kernel-calls/resolve-dto.js +61 -0
- package/lib/api/kernel-calls/with-defaults.d.ts +16 -0
- package/lib/api/kernel-calls/with-defaults.js +53 -0
- package/lib/api/resolved-inputs/index.d.ts +304 -0
- package/lib/api/resolved-inputs/index.js +1 -0
- package/lib/api/services/color.js +43 -26
- package/lib/api/services/dates.js +53 -33
- package/lib/api/services/frame.d.ts +670 -0
- package/lib/api/services/frame.js +1040 -0
- package/lib/api/services/helpers/dxf/dxf-generator.d.ts +2 -3
- package/lib/api/services/helpers/dxf/dxf-generator.js +27 -37
- package/lib/api/services/helpers/dxf/dxf.js +10 -4
- package/lib/api/services/helpers/frame-axes.d.ts +36 -0
- package/lib/api/services/helpers/frame-axes.js +57 -0
- package/lib/api/services/helpers/matrices.d.ts +17 -0
- package/lib/api/services/helpers/matrices.js +51 -0
- package/lib/api/services/index.d.ts +1 -0
- package/lib/api/services/index.js +1 -0
- package/lib/api/services/line.js +15 -12
- package/lib/api/services/lists.js +174 -136
- package/lib/api/services/logic.js +44 -34
- package/lib/api/services/math.js +127 -82
- package/lib/api/services/mesh.js +20 -13
- package/lib/api/services/point.js +62 -46
- package/lib/api/services/polyline.js +22 -18
- package/lib/api/services/text.js +81 -46
- package/lib/api/services/transforms.js +38 -25
- package/lib/api/services/vector.js +37 -22
- 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
|
-
|
|
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 <
|
|
38
|
-
booleans.push(Math.random() <
|
|
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
|
-
|
|
67
|
-
if (n <
|
|
71
|
+
resolved.numbers.forEach(n => {
|
|
72
|
+
if (n < resolved.thresholdTotalTrue) {
|
|
68
73
|
booleans.push(true);
|
|
69
74
|
}
|
|
70
|
-
else if (n >
|
|
75
|
+
else if (n > resolved.thresholdTotalFalse) {
|
|
71
76
|
booleans.push(false);
|
|
72
77
|
}
|
|
73
78
|
else {
|
|
74
|
-
const leveledNr = n -
|
|
75
|
-
const step = (
|
|
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 /
|
|
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
|
-
|
|
107
|
-
if (n <
|
|
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 (
|
|
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
|
-
|
|
148
|
+
resolved.numbers.forEach(n => {
|
|
142
149
|
let foundInThresholds = false;
|
|
143
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
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.
|