@grame/faustwasm 0.7.6 → 0.7.8
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/assets/standalone/faust-ui/index.js +136 -251
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/dist/cjs-bundle/index.js +4 -4
- package/dist/cjs-bundle/index.js.map +1 -1
- package/dist/esm-bundle/index.js +4 -4
- package/dist/esm-bundle/index.js.map +1 -1
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/test/faustlive-wasm/faust-ui/index.js +136 -251
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
|
@@ -161,8 +161,7 @@ class FaustUI {
|
|
|
161
161
|
* Can be overriden, called by components when its value is changed by user.
|
|
162
162
|
*/
|
|
163
163
|
this.paramChangeByUI = (path, value) => {
|
|
164
|
-
if (!this.hostWindow)
|
|
165
|
-
return;
|
|
164
|
+
if (!this.hostWindow) return;
|
|
166
165
|
this.hostWindow.postMessage({ path, value, type: "param" }, "*");
|
|
167
166
|
};
|
|
168
167
|
const { root, ui: uiIn, listenWindowResize, listenWindowMessage } = options;
|
|
@@ -176,10 +175,10 @@ class FaustUI {
|
|
|
176
175
|
if (typeof listenWindowMessage === "undefined" || listenWindowMessage === true) {
|
|
177
176
|
window.addEventListener("message", (e) => {
|
|
178
177
|
const { data, source } = e;
|
|
179
|
-
|
|
178
|
+
if (!data) return;
|
|
180
179
|
const { type } = data;
|
|
181
|
-
if (!type)
|
|
182
|
-
|
|
180
|
+
if (!type) return;
|
|
181
|
+
this.hostWindow = source;
|
|
183
182
|
if (type === "ui") {
|
|
184
183
|
this.ui = data.ui;
|
|
185
184
|
} else if (type === "param") {
|
|
@@ -219,17 +218,14 @@ class FaustUI {
|
|
|
219
218
|
* This method should be called by components to register itself to map.
|
|
220
219
|
*/
|
|
221
220
|
register(path, item) {
|
|
222
|
-
if (this.componentMap[path])
|
|
223
|
-
|
|
224
|
-
else
|
|
225
|
-
this.componentMap[path] = [item];
|
|
221
|
+
if (this.componentMap[path]) this.componentMap[path].push(item);
|
|
222
|
+
else this.componentMap[path] = [item];
|
|
226
223
|
}
|
|
227
224
|
/**
|
|
228
225
|
* Notify the component to change its value.
|
|
229
226
|
*/
|
|
230
227
|
paramChangeByDSP(path, value) {
|
|
231
|
-
if (this.componentMap[path])
|
|
232
|
-
this.componentMap[path].forEach((item) => item.setState({ value }));
|
|
228
|
+
if (this.componentMap[path]) this.componentMap[path].forEach((item) => item.setState({ value }));
|
|
233
229
|
}
|
|
234
230
|
/**
|
|
235
231
|
* Calculate UI layout in grid then calculate grid size.
|
|
@@ -253,8 +249,7 @@ class FaustUI {
|
|
|
253
249
|
* Force recalculate grid size and resize UI
|
|
254
250
|
*/
|
|
255
251
|
resize() {
|
|
256
|
-
if (!this.faustUIRoot)
|
|
257
|
-
return;
|
|
252
|
+
if (!this.faustUIRoot) return;
|
|
258
253
|
this.calcGrid();
|
|
259
254
|
this.faustUIRoot.setState({ style: { grid: this.grid } });
|
|
260
255
|
}
|
|
@@ -262,14 +257,12 @@ class FaustUI {
|
|
|
262
257
|
filter(ui) {
|
|
263
258
|
const callback = (items, item) => {
|
|
264
259
|
var _a;
|
|
265
|
-
if (item.type === "soundfile")
|
|
266
|
-
return items;
|
|
260
|
+
if (item.type === "soundfile") return items;
|
|
267
261
|
if (item.type === "hgroup" || item.type === "vgroup" || item.type === "tgroup") {
|
|
268
262
|
items.push(__spreadProps(__spreadValues({}, item), { items: item.items.reduce(callback, []) }));
|
|
269
263
|
return items;
|
|
270
264
|
}
|
|
271
|
-
if ((_a = item.meta) == null ? void 0 : _a.find((m) => m.hidden && m.hidden === "1"))
|
|
272
|
-
return items;
|
|
265
|
+
if ((_a = item.meta) == null ? void 0 : _a.find((m) => m.hidden && m.hidden === "1")) return items;
|
|
273
266
|
items.push(item);
|
|
274
267
|
return items;
|
|
275
268
|
};
|
|
@@ -371,10 +364,8 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
|
|
|
371
364
|
if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
372
365
|
this.state[stateKey] = stateValue;
|
|
373
366
|
shouldUpdate = true;
|
|
374
|
-
} else
|
|
375
|
-
|
|
376
|
-
if (shouldUpdate)
|
|
377
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
367
|
+
} else return;
|
|
368
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
378
369
|
}
|
|
379
370
|
}
|
|
380
371
|
/**
|
|
@@ -382,10 +373,8 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
|
|
|
382
373
|
* schedule what you need to do in next render tick in `raf` callback
|
|
383
374
|
*/
|
|
384
375
|
schedule(func) {
|
|
385
|
-
if (this.tasks.indexOf(func) === -1)
|
|
386
|
-
|
|
387
|
-
if (this.$raf)
|
|
388
|
-
return;
|
|
376
|
+
if (this.tasks.indexOf(func) === -1) this.tasks.push(func);
|
|
377
|
+
if (this.$raf) return;
|
|
389
378
|
this.$raf = window.requestAnimationFrame(this.raf);
|
|
390
379
|
}
|
|
391
380
|
}
|
|
@@ -429,7 +418,7 @@ var __spreadValues = (a, b) => {
|
|
|
429
418
|
|
|
430
419
|
|
|
431
420
|
|
|
432
|
-
const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
421
|
+
const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
433
422
|
/**
|
|
434
423
|
* Initiate default state with incoming state.
|
|
435
424
|
*/
|
|
@@ -521,16 +510,14 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
521
510
|
const prevValue = this.state.value;
|
|
522
511
|
this.handleMouseOrTouchDown({ pointerId, x: fromX, y: fromY, originalEvent: e });
|
|
523
512
|
const handlePointerMove = (e2) => {
|
|
524
|
-
if (e2.pointerId !== pointerId)
|
|
525
|
-
return;
|
|
513
|
+
if (e2.pointerId !== pointerId) return;
|
|
526
514
|
e2.preventDefault();
|
|
527
515
|
const x = e2.clientX - rect.left;
|
|
528
516
|
const y = e2.clientY - rect.top;
|
|
529
517
|
this.handleMouseOrTouchMove({ pointerId, prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 });
|
|
530
518
|
};
|
|
531
519
|
const handlePointerUp = (e2) => {
|
|
532
|
-
if (e2.pointerId !== pointerId)
|
|
533
|
-
return;
|
|
520
|
+
if (e2.pointerId !== pointerId) return;
|
|
534
521
|
e2.preventDefault();
|
|
535
522
|
const x = e2.clientX - rect.left;
|
|
536
523
|
const y = e2.clientY - rect.top;
|
|
@@ -550,19 +537,16 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
550
537
|
this.handleFocusIn = (e) => this.setState({ focus: true });
|
|
551
538
|
this.handleFocusOut = (e) => this.setState({ focus: false });
|
|
552
539
|
this.state.style = __spreadValues(__spreadValues({}, this.defaultProps.style), props.style);
|
|
553
|
-
if (this.state.emitter)
|
|
554
|
-
this.state.emitter.register(this.state.address, this);
|
|
540
|
+
if (this.state.emitter) this.state.emitter.register(this.state.address, this);
|
|
555
541
|
}
|
|
556
542
|
/**
|
|
557
543
|
* Get a nearest valid number
|
|
558
544
|
*/
|
|
559
545
|
toValidNumber(value) {
|
|
560
546
|
const { min, max, step } = this.state;
|
|
561
|
-
if (typeof min !== "number" || typeof max !== "number")
|
|
562
|
-
return value;
|
|
547
|
+
if (typeof min !== "number" || typeof max !== "number") return value;
|
|
563
548
|
const v = Math.min(max, Math.max(min, value));
|
|
564
|
-
if (!step)
|
|
565
|
-
return v;
|
|
549
|
+
if (!step) return v;
|
|
566
550
|
return min + Math.floor((v - min) / step) * step;
|
|
567
551
|
}
|
|
568
552
|
/**
|
|
@@ -571,16 +555,14 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
571
555
|
setValue(valueIn) {
|
|
572
556
|
const value = this.toValidNumber(valueIn);
|
|
573
557
|
const changed = this.setState({ value });
|
|
574
|
-
if (changed)
|
|
575
|
-
this.change(value);
|
|
558
|
+
if (changed) this.change(value);
|
|
576
559
|
return changed;
|
|
577
560
|
}
|
|
578
561
|
/**
|
|
579
562
|
* Send value to DSP
|
|
580
563
|
*/
|
|
581
564
|
change(valueIn) {
|
|
582
|
-
if (this.state.emitter)
|
|
583
|
-
this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
|
|
565
|
+
if (this.state.emitter) this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
|
|
584
566
|
}
|
|
585
567
|
/**
|
|
586
568
|
* set internal state and fire events for UI parts subscribed
|
|
@@ -602,10 +584,8 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
602
584
|
} else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
603
585
|
this.state[stateKey] = stateValue;
|
|
604
586
|
shouldUpdate = true;
|
|
605
|
-
} else
|
|
606
|
-
|
|
607
|
-
if (shouldUpdate)
|
|
608
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
587
|
+
} else return false;
|
|
588
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
609
589
|
}
|
|
610
590
|
return shouldUpdate;
|
|
611
591
|
}
|
|
@@ -618,8 +598,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
618
598
|
this.container.className = ["faust-ui-component", "faust-ui-component-" + this.className].join(" ");
|
|
619
599
|
this.container.tabIndex = 1;
|
|
620
600
|
this.container.id = this.state.address;
|
|
621
|
-
if (this.state.tooltip)
|
|
622
|
-
this.container.title = this.state.tooltip;
|
|
601
|
+
if (this.state.tooltip) this.container.title = this.state.tooltip;
|
|
623
602
|
this.label = document.createElement("div");
|
|
624
603
|
this.label.className = "faust-ui-component-label";
|
|
625
604
|
this.labelCanvas = document.createElement("canvas");
|
|
@@ -640,8 +619,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
640
619
|
const canvas = this.labelCanvas;
|
|
641
620
|
const ratio = window.devicePixelRatio || 1;
|
|
642
621
|
let { width, height } = this.label.getBoundingClientRect();
|
|
643
|
-
if (!width || !height)
|
|
644
|
-
return this;
|
|
622
|
+
if (!width || !height) return this;
|
|
645
623
|
width = Math.floor(width);
|
|
646
624
|
height = Math.floor(height);
|
|
647
625
|
const scaledWidth = Math.floor(width * ratio);
|
|
@@ -681,10 +659,8 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
681
659
|
const { type, max, min, step, enums } = this.state;
|
|
682
660
|
const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
|
|
683
661
|
if (step) {
|
|
684
|
-
if (type === "enum")
|
|
685
|
-
|
|
686
|
-
if (type === "int")
|
|
687
|
-
return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
|
|
662
|
+
if (type === "enum") return enums.length;
|
|
663
|
+
if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
|
|
688
664
|
return Math.floor((max - min) / step);
|
|
689
665
|
}
|
|
690
666
|
return maxSteps;
|
|
@@ -698,8 +674,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
698
674
|
}
|
|
699
675
|
static getDistance(state) {
|
|
700
676
|
const { type, max, min, value, enums, scale } = state;
|
|
701
|
-
if (type === "enum")
|
|
702
|
-
return value / (enums.length - 1);
|
|
677
|
+
if (type === "enum") return value / (enums.length - 1);
|
|
703
678
|
const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(value, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(value, min, max) : value;
|
|
704
679
|
return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max);
|
|
705
680
|
}
|
|
@@ -712,11 +687,10 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
712
687
|
return full / stepsCount;
|
|
713
688
|
}
|
|
714
689
|
};
|
|
715
|
-
let AbstractItem = _AbstractItem;
|
|
716
690
|
/**
|
|
717
691
|
* The default state of the component.
|
|
718
692
|
*/
|
|
719
|
-
|
|
693
|
+
_AbstractItem.defaultProps = {
|
|
720
694
|
value: 0,
|
|
721
695
|
active: true,
|
|
722
696
|
focus: false,
|
|
@@ -731,6 +705,7 @@ AbstractItem.defaultProps = {
|
|
|
731
705
|
step: 0.01,
|
|
732
706
|
style: { width: 45, height: 15, left: 0, top: 0, labelcolor: "rgba(226, 222, 255, 0.5)" }
|
|
733
707
|
};
|
|
708
|
+
let AbstractItem = _AbstractItem;
|
|
734
709
|
|
|
735
710
|
|
|
736
711
|
|
|
@@ -915,8 +890,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
915
890
|
this.children = [];
|
|
916
891
|
const { style, type, items, emitter, isRoot } = this.state;
|
|
917
892
|
const { grid, left, top, width, height } = style;
|
|
918
|
-
if (!this.state.isRoot)
|
|
919
|
-
this.label.style.height = `${grid * 0.3}px`;
|
|
893
|
+
if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
|
|
920
894
|
this.container.style.left = `${left * grid}px`;
|
|
921
895
|
this.container.style.top = `${top * grid}px`;
|
|
922
896
|
this.container.style.width = `${width * grid}px`;
|
|
@@ -925,13 +899,11 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
925
899
|
items.forEach((item) => {
|
|
926
900
|
if (item.type.endsWith("group")) {
|
|
927
901
|
const component = Group.getComponent(item, emitter, grid);
|
|
928
|
-
if (component)
|
|
929
|
-
this.children.push(component);
|
|
902
|
+
if (component) this.children.push(component);
|
|
930
903
|
} else {
|
|
931
904
|
const ioItem = item;
|
|
932
905
|
const itemComponent = Group.getComponent(ioItem, this.state.emitter, grid);
|
|
933
|
-
if (itemComponent)
|
|
934
|
-
this.children.push(itemComponent);
|
|
906
|
+
if (itemComponent) this.children.push(itemComponent);
|
|
935
907
|
}
|
|
936
908
|
});
|
|
937
909
|
if (type === "tgroup") {
|
|
@@ -951,8 +923,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
951
923
|
const groups = [];
|
|
952
924
|
for (let j = 0; j < this.container.children.length; j++) {
|
|
953
925
|
const element = this.container.children[j];
|
|
954
|
-
if (j > 1)
|
|
955
|
-
groups.push(element);
|
|
926
|
+
if (j > 1) groups.push(element);
|
|
956
927
|
}
|
|
957
928
|
for (let j = 0; j < groups.length; j++) {
|
|
958
929
|
const element = groups[j];
|
|
@@ -961,10 +932,8 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
961
932
|
for (let j = 0; j < this.tabs.children.length; j++) {
|
|
962
933
|
const e = this.tabs.children[j];
|
|
963
934
|
if (i !== j) {
|
|
964
|
-
if (e.classList.contains("active"))
|
|
965
|
-
|
|
966
|
-
} else
|
|
967
|
-
e.classList.add("active");
|
|
935
|
+
if (e.classList.contains("active")) e.classList.remove("active");
|
|
936
|
+
} else e.classList.add("active");
|
|
968
937
|
}
|
|
969
938
|
});
|
|
970
939
|
this.tabs.appendChild(tab);
|
|
@@ -974,8 +943,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
974
943
|
}
|
|
975
944
|
static parseMeta(metaIn) {
|
|
976
945
|
const metaObject = {};
|
|
977
|
-
if (!metaIn)
|
|
978
|
-
return { metaObject };
|
|
946
|
+
if (!metaIn) return { metaObject };
|
|
979
947
|
metaIn.forEach((m) => Object.assign(metaObject, m));
|
|
980
948
|
if (metaObject.style) {
|
|
981
949
|
const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?))\}/;
|
|
@@ -1037,32 +1005,19 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1037
1005
|
step: "step" in item ? +item.step : 1,
|
|
1038
1006
|
value: "init" in item ? +item.init || 0 : 0
|
|
1039
1007
|
};
|
|
1040
|
-
if (type === "button")
|
|
1041
|
-
|
|
1042
|
-
if (type === "
|
|
1043
|
-
|
|
1044
|
-
if (type === "
|
|
1045
|
-
|
|
1046
|
-
if (type === "
|
|
1047
|
-
|
|
1048
|
-
if (type === "
|
|
1049
|
-
|
|
1050
|
-
if (type === "
|
|
1051
|
-
|
|
1052
|
-
if (type === "
|
|
1053
|
-
return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
|
|
1054
|
-
if (type === "hslider")
|
|
1055
|
-
return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
|
|
1056
|
-
if (type === "vslider")
|
|
1057
|
-
return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
|
|
1058
|
-
if (type === "hbargraph")
|
|
1059
|
-
return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
|
|
1060
|
-
if (type === "vbargraph")
|
|
1061
|
-
return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
|
|
1062
|
-
if (type === "numerical")
|
|
1063
|
-
return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
|
|
1064
|
-
if (type === "led")
|
|
1065
|
-
return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
|
|
1008
|
+
if (type === "button") return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props);
|
|
1009
|
+
if (type === "checkbox") return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props);
|
|
1010
|
+
if (type === "nentry") return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props);
|
|
1011
|
+
if (type === "soundfile") return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props);
|
|
1012
|
+
if (type === "knob") return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props);
|
|
1013
|
+
if (type === "menu") return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props);
|
|
1014
|
+
if (type === "radio") return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
|
|
1015
|
+
if (type === "hslider") return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
|
|
1016
|
+
if (type === "vslider") return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
|
|
1017
|
+
if (type === "hbargraph") return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
|
|
1018
|
+
if (type === "vbargraph") return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
|
|
1019
|
+
if (type === "numerical") return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
|
|
1020
|
+
if (type === "led") return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
|
|
1066
1021
|
return null;
|
|
1067
1022
|
}
|
|
1068
1023
|
setState(newState) {
|
|
@@ -1081,10 +1036,8 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1081
1036
|
} else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
1082
1037
|
this.state[stateKey] = stateValue;
|
|
1083
1038
|
shouldUpdate = true;
|
|
1084
|
-
} else
|
|
1085
|
-
|
|
1086
|
-
if (shouldUpdate)
|
|
1087
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
1039
|
+
} else return;
|
|
1040
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
1088
1041
|
}
|
|
1089
1042
|
}
|
|
1090
1043
|
componentWillMount() {
|
|
@@ -1102,16 +1055,14 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1102
1055
|
return this;
|
|
1103
1056
|
}
|
|
1104
1057
|
paintLabel() {
|
|
1105
|
-
if (this.state.isRoot)
|
|
1106
|
-
return this;
|
|
1058
|
+
if (this.state.isRoot) return this;
|
|
1107
1059
|
const label = this.state.label;
|
|
1108
1060
|
const color = this.state.style.labelcolor;
|
|
1109
1061
|
const ctx = this.labelCtx;
|
|
1110
1062
|
const canvas = this.labelCanvas;
|
|
1111
1063
|
const ratio = window.devicePixelRatio || 1;
|
|
1112
1064
|
let { width, height } = this.label.getBoundingClientRect();
|
|
1113
|
-
if (!width || !height)
|
|
1114
|
-
return this;
|
|
1065
|
+
if (!width || !height) return this;
|
|
1115
1066
|
width = Math.floor(width);
|
|
1116
1067
|
height = Math.floor(height);
|
|
1117
1068
|
const scaledWidth = Math.floor(width * ratio);
|
|
@@ -1132,8 +1083,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1132
1083
|
this.label.appendChild(this.labelCanvas);
|
|
1133
1084
|
this.container.appendChild(this.label);
|
|
1134
1085
|
}
|
|
1135
|
-
if (this.tabs.children.length)
|
|
1136
|
-
this.container.appendChild(this.tabs);
|
|
1086
|
+
if (this.tabs.children.length) this.container.appendChild(this.tabs);
|
|
1137
1087
|
this.children.forEach((item) => {
|
|
1138
1088
|
item.mount();
|
|
1139
1089
|
this.container.appendChild(item.container);
|
|
@@ -1144,8 +1094,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1144
1094
|
var _a;
|
|
1145
1095
|
const handleResize = () => {
|
|
1146
1096
|
const { grid, left, top, width, height } = this.state.style;
|
|
1147
|
-
if (!this.state.isRoot)
|
|
1148
|
-
this.label.style.height = `${grid * 0.3}px`;
|
|
1097
|
+
if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
|
|
1149
1098
|
this.container.style.width = `${width * grid}px`;
|
|
1150
1099
|
this.container.style.height = `${height * grid}px`;
|
|
1151
1100
|
this.container.style.left = `${left * grid}px`;
|
|
@@ -1176,8 +1125,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1176
1125
|
};
|
|
1177
1126
|
this.on("label", () => this.schedule(labelChange));
|
|
1178
1127
|
this.paintLabel();
|
|
1179
|
-
if ((_a = this.tabs) == null ? void 0 : _a.children.length)
|
|
1180
|
-
this.tabs.children[0].click();
|
|
1128
|
+
if ((_a = this.tabs) == null ? void 0 : _a.children.length) this.tabs.children[0].click();
|
|
1181
1129
|
this.children.forEach((item) => item.componentDidMount());
|
|
1182
1130
|
return this;
|
|
1183
1131
|
}
|
|
@@ -1235,8 +1183,7 @@ class HBargraph extends _VBargraph__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
1235
1183
|
const paintValue = this.paintValue;
|
|
1236
1184
|
if (paintValue > this.maxValue) {
|
|
1237
1185
|
this.maxValue = paintValue;
|
|
1238
|
-
if (this.maxTimer)
|
|
1239
|
-
window.clearTimeout(this.maxTimer);
|
|
1186
|
+
if (this.maxTimer) window.clearTimeout(this.maxTimer);
|
|
1240
1187
|
this.maxTimer = window.setTimeout(() => {
|
|
1241
1188
|
this.maxValue = this.paintValue;
|
|
1242
1189
|
this.maxTimer = void 0;
|
|
@@ -1256,23 +1203,15 @@ class HBargraph extends _VBargraph__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
1256
1203
|
const hotStop = (-3 - min) / (max - min);
|
|
1257
1204
|
const overloadStop = Math.max(0, -min / (max - min));
|
|
1258
1205
|
const gradient = ctx.createLinearGradient(left, 0, drawWidth, 0);
|
|
1259
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
if (
|
|
1264
|
-
|
|
1265
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
1266
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
1267
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
1268
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
1269
|
-
else if (overloadStop < 0)
|
|
1270
|
-
gradient.addColorStop(0, coldcolor);
|
|
1206
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
1207
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
1208
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
1209
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
1210
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
1211
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
1271
1212
|
ctx.fillStyle = barbgcolor;
|
|
1272
|
-
if (paintValue < 0)
|
|
1273
|
-
|
|
1274
|
-
if (paintValue < max)
|
|
1275
|
-
ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight);
|
|
1213
|
+
if (paintValue < 0) ctx.fillRect(left, top, drawWidth * overloadStop, drawHeight);
|
|
1214
|
+
if (paintValue < max) ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight);
|
|
1276
1215
|
ctx.fillStyle = gradient;
|
|
1277
1216
|
if (paintValue > min) {
|
|
1278
1217
|
const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
|
|
@@ -1409,8 +1348,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1409
1348
|
const value = parseFloat(e.currentTarget.value);
|
|
1410
1349
|
if (isFinite(value)) {
|
|
1411
1350
|
const changed = this.setValue(+value);
|
|
1412
|
-
if (changed)
|
|
1413
|
-
return;
|
|
1351
|
+
if (changed) return;
|
|
1414
1352
|
}
|
|
1415
1353
|
this.input.value = this.inputNumber.value + (this.state.unit || "");
|
|
1416
1354
|
};
|
|
@@ -1465,8 +1403,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1465
1403
|
};
|
|
1466
1404
|
this.handleMouseOrTouchMove = (e) => {
|
|
1467
1405
|
const newValue = this.getValueFromDelta(e);
|
|
1468
|
-
if (newValue !== this.state.value)
|
|
1469
|
-
this.setValue(newValue);
|
|
1406
|
+
if (newValue !== this.state.value) this.setValue(newValue);
|
|
1470
1407
|
};
|
|
1471
1408
|
}
|
|
1472
1409
|
static get defaultProps() {
|
|
@@ -1558,10 +1495,8 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1558
1495
|
const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(denormalized, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(denormalized, min, max) : denormalized;
|
|
1559
1496
|
let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
|
|
1560
1497
|
steps = Math.min(stepsCount, Math.max(0, steps));
|
|
1561
|
-
if (type === "enum")
|
|
1562
|
-
|
|
1563
|
-
if (type === "int")
|
|
1564
|
-
return Math.round(steps * step + min);
|
|
1498
|
+
if (type === "enum") return steps;
|
|
1499
|
+
if (type === "int") return Math.round(steps * step + min);
|
|
1565
1500
|
return steps * step + min;
|
|
1566
1501
|
}
|
|
1567
1502
|
}
|
|
@@ -1633,29 +1568,19 @@ class Led extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1633
1568
|
const hotStop = (-3 - min) / (max - min);
|
|
1634
1569
|
const overloadStop = -min / (max - min);
|
|
1635
1570
|
const gradient = tempCtx.createLinearGradient(0, 0, tempCanvas.width, 0);
|
|
1636
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
if (
|
|
1641
|
-
|
|
1642
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
1643
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
1644
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
1645
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
1646
|
-
else if (overloadStop < 0)
|
|
1647
|
-
gradient.addColorStop(0, coldcolor);
|
|
1571
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
1572
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
1573
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
1574
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
1575
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
1576
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
1648
1577
|
tempCtx.fillStyle = gradient;
|
|
1649
1578
|
tempCtx.fillRect(0, 0, tempCanvas.width, 10);
|
|
1650
1579
|
const d = tempCtx.getImageData(Math.min(tempCanvas.width - 1, distance * tempCanvas.width), 0, 1, 1).data;
|
|
1651
|
-
if (distance)
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
if (shape === "circle")
|
|
1656
|
-
ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
|
|
1657
|
-
else
|
|
1658
|
-
ctx.rect(left, top, drawWidth, drawHeight);
|
|
1580
|
+
if (distance) ctx.fillStyle = `rgb(${d[0]}, ${d[1]}, ${d[2]})`;
|
|
1581
|
+
else ctx.fillStyle = ledbgcolor;
|
|
1582
|
+
if (shape === "circle") ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
|
|
1583
|
+
else ctx.rect(left, top, drawWidth, drawHeight);
|
|
1659
1584
|
ctx.fill();
|
|
1660
1585
|
};
|
|
1661
1586
|
}
|
|
@@ -1795,8 +1720,7 @@ class Menu extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1795
1720
|
const option = document.createElement("option");
|
|
1796
1721
|
option.value = enums[key].toString();
|
|
1797
1722
|
option.text = key;
|
|
1798
|
-
if (i === 0)
|
|
1799
|
-
option.selected = true;
|
|
1723
|
+
if (i === 0) option.selected = true;
|
|
1800
1724
|
this.select.appendChild(option);
|
|
1801
1725
|
i++;
|
|
1802
1726
|
}
|
|
@@ -1811,8 +1735,7 @@ class Menu extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1811
1735
|
const valueChange = () => {
|
|
1812
1736
|
for (let i = this.select.children.length - 1; i >= 0; i--) {
|
|
1813
1737
|
const option = this.select.children[i];
|
|
1814
|
-
if (+option.value === this.state.value)
|
|
1815
|
-
this.select.selectedIndex = i;
|
|
1738
|
+
if (+option.value === this.state.value) this.select.selectedIndex = i;
|
|
1816
1739
|
}
|
|
1817
1740
|
};
|
|
1818
1741
|
this.on("value", () => this.schedule(valueChange));
|
|
@@ -2060,11 +1983,9 @@ class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2060
1983
|
input.value = enums[key].toString();
|
|
2061
1984
|
input.name = address;
|
|
2062
1985
|
input.type = "radio";
|
|
2063
|
-
if (i === 0)
|
|
2064
|
-
input.checked = true;
|
|
1986
|
+
if (i === 0) input.checked = true;
|
|
2065
1987
|
input.addEventListener("change", () => {
|
|
2066
|
-
if (input.checked)
|
|
2067
|
-
this.setValue(enums[key]);
|
|
1988
|
+
if (input.checked) this.setValue(enums[key]);
|
|
2068
1989
|
});
|
|
2069
1990
|
div.appendChild(input);
|
|
2070
1991
|
div.append(key);
|
|
@@ -2112,8 +2033,7 @@ class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2112
2033
|
const valueChange = () => {
|
|
2113
2034
|
for (let i = this.group.children.length - 1; i >= 0; i--) {
|
|
2114
2035
|
const input = this.group.children[i].querySelector("input");
|
|
2115
|
-
if (+input.value === this.state.value)
|
|
2116
|
-
input.checked = true;
|
|
2036
|
+
if (+input.value === this.state.value) input.checked = true;
|
|
2117
2037
|
}
|
|
2118
2038
|
};
|
|
2119
2039
|
this.on("value", () => this.schedule(valueChange));
|
|
@@ -2294,8 +2214,7 @@ class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2294
2214
|
const paintValue = this.paintValue;
|
|
2295
2215
|
if (paintValue > this.maxValue) {
|
|
2296
2216
|
this.maxValue = paintValue;
|
|
2297
|
-
if (this.maxTimer)
|
|
2298
|
-
window.clearTimeout(this.maxTimer);
|
|
2217
|
+
if (this.maxTimer) window.clearTimeout(this.maxTimer);
|
|
2299
2218
|
this.maxTimer = window.setTimeout(() => {
|
|
2300
2219
|
this.maxValue = this.paintValue;
|
|
2301
2220
|
this.maxTimer = void 0;
|
|
@@ -2315,23 +2234,15 @@ class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2315
2234
|
const hotStop = (-3 - min) / (max - min);
|
|
2316
2235
|
const overloadStop = Math.max(0, -min / (max - min));
|
|
2317
2236
|
const gradient = ctx.createLinearGradient(0, drawHeight, 0, top);
|
|
2318
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
if (
|
|
2323
|
-
|
|
2324
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
2325
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
2326
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
2327
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
2328
|
-
else if (overloadStop < 0)
|
|
2329
|
-
gradient.addColorStop(0, coldcolor);
|
|
2237
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
2238
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
2239
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
2240
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
2241
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
2242
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
2330
2243
|
ctx.fillStyle = barbgcolor;
|
|
2331
|
-
if (paintValue < 0)
|
|
2332
|
-
|
|
2333
|
-
if (paintValue < max)
|
|
2334
|
-
ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1);
|
|
2244
|
+
if (paintValue < 0) ctx.fillRect(left, top + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop);
|
|
2245
|
+
if (paintValue < max) ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1);
|
|
2335
2246
|
ctx.fillStyle = gradient;
|
|
2336
2247
|
if (paintValue > min) {
|
|
2337
2248
|
const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
|
|
@@ -2465,8 +2376,7 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2465
2376
|
const value = parseFloat(e.currentTarget.value);
|
|
2466
2377
|
if (isFinite(value)) {
|
|
2467
2378
|
const changed = this.setValue(+value);
|
|
2468
|
-
if (changed)
|
|
2469
|
-
return;
|
|
2379
|
+
if (changed) return;
|
|
2470
2380
|
}
|
|
2471
2381
|
this.input.value = this.inputNumber.value + (this.state.unit || "");
|
|
2472
2382
|
};
|
|
@@ -2508,16 +2418,13 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2508
2418
|
};
|
|
2509
2419
|
this.handleMouseOrTouchDown = (e) => {
|
|
2510
2420
|
const { value } = this.state;
|
|
2511
|
-
if (e.x < this.interactionRect[0] || e.x > this.interactionRect[0] + this.interactionRect[2] || e.y < this.interactionRect[1] || e.y > this.interactionRect[1] + this.interactionRect[3])
|
|
2512
|
-
return;
|
|
2421
|
+
if (e.x < this.interactionRect[0] || e.x > this.interactionRect[0] + this.interactionRect[2] || e.y < this.interactionRect[1] || e.y > this.interactionRect[1] + this.interactionRect[3]) return;
|
|
2513
2422
|
const newValue = this.getValueFromPos(e);
|
|
2514
|
-
if (newValue !== value)
|
|
2515
|
-
this.setValue(this.getValueFromPos(e));
|
|
2423
|
+
if (newValue !== value) this.setValue(this.getValueFromPos(e));
|
|
2516
2424
|
};
|
|
2517
2425
|
this.handleMouseOrTouchMove = (e) => {
|
|
2518
2426
|
const newValue = this.getValueFromPos(e);
|
|
2519
|
-
if (newValue !== this.state.value)
|
|
2520
|
-
this.setValue(newValue);
|
|
2427
|
+
if (newValue !== this.state.value) this.setValue(newValue);
|
|
2521
2428
|
};
|
|
2522
2429
|
}
|
|
2523
2430
|
static get defaultProps() {
|
|
@@ -2607,10 +2514,8 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2607
2514
|
const { type, max, min, step, enums } = this.state;
|
|
2608
2515
|
const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
|
|
2609
2516
|
if (step) {
|
|
2610
|
-
if (type === "enum")
|
|
2611
|
-
|
|
2612
|
-
if (type === "int")
|
|
2613
|
-
return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
|
|
2517
|
+
if (type === "enum") return enums.length;
|
|
2518
|
+
if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
|
|
2614
2519
|
return Math.floor((max - min) / step);
|
|
2615
2520
|
}
|
|
2616
2521
|
return maxSteps;
|
|
@@ -2631,10 +2536,8 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2631
2536
|
const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(denormalized, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(denormalized, min, max) : denormalized;
|
|
2632
2537
|
let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
|
|
2633
2538
|
steps = Math.min(stepsCount, Math.max(0, steps));
|
|
2634
|
-
if (type === "enum")
|
|
2635
|
-
|
|
2636
|
-
if (type === "int")
|
|
2637
|
-
return Math.round(steps * step + min);
|
|
2539
|
+
if (type === "enum") return steps;
|
|
2540
|
+
if (type === "int") return Math.round(steps * step + min);
|
|
2638
2541
|
return steps * step + min;
|
|
2639
2542
|
}
|
|
2640
2543
|
}
|
|
@@ -2689,10 +2592,8 @@ const normExp = iNormLog;
|
|
|
2689
2592
|
const iNormExp = normLog;
|
|
2690
2593
|
const roundedRect = (ctx, x, y, width, height, radius) => {
|
|
2691
2594
|
const radii = [0, 0, 0, 0];
|
|
2692
|
-
if (typeof radius === "number")
|
|
2693
|
-
|
|
2694
|
-
else
|
|
2695
|
-
radius.forEach((v, i) => radii[i] = v);
|
|
2595
|
+
if (typeof radius === "number") radii.fill(radius);
|
|
2596
|
+
else radius.forEach((v, i) => radii[i] = v);
|
|
2696
2597
|
ctx.beginPath();
|
|
2697
2598
|
ctx.moveTo(x + radii[0], y);
|
|
2698
2599
|
ctx.lineTo(x + width - radii[1], y);
|
|
@@ -2708,10 +2609,8 @@ const roundedRect = (ctx, x, y, width, height, radius) => {
|
|
|
2708
2609
|
};
|
|
2709
2610
|
const fillRoundedRect = (ctx, x, y, width, height, radius) => {
|
|
2710
2611
|
const radii = [0, 0, 0, 0];
|
|
2711
|
-
if (typeof radius === "number")
|
|
2712
|
-
|
|
2713
|
-
else
|
|
2714
|
-
radius.forEach((v, i) => radii[i] = v);
|
|
2612
|
+
if (typeof radius === "number") radii.fill(radius);
|
|
2613
|
+
else radius.forEach((v, i) => radii[i] = v);
|
|
2715
2614
|
ctx.beginPath();
|
|
2716
2615
|
ctx.moveTo(x + radii[0], y);
|
|
2717
2616
|
ctx.lineTo(x + width - radii[1], y);
|
|
@@ -2749,16 +2648,17 @@ const instantiate = () => {
|
|
|
2749
2648
|
});
|
|
2750
2649
|
let host;
|
|
2751
2650
|
window.addEventListener("message", (e) => {
|
|
2752
|
-
const { source } = e;
|
|
2651
|
+
const { data, source } = e;
|
|
2652
|
+
if (!data) return;
|
|
2653
|
+
const { type } = data;
|
|
2654
|
+
if (!type) return;
|
|
2753
2655
|
host = source;
|
|
2754
2656
|
});
|
|
2755
2657
|
window.addEventListener("keydown", (e) => {
|
|
2756
|
-
if (host)
|
|
2757
|
-
host.postMessage({ type: "keydown", key: e.key }, "*");
|
|
2658
|
+
if (host) host.postMessage({ type: "keydown", key: e.key }, "*");
|
|
2758
2659
|
});
|
|
2759
2660
|
window.addEventListener("keyup", (e) => {
|
|
2760
|
-
if (host)
|
|
2761
|
-
host.postMessage({ type: "keyup", key: e.key }, "*");
|
|
2661
|
+
if (host) host.postMessage({ type: "keyup", key: e.key }, "*");
|
|
2762
2662
|
});
|
|
2763
2663
|
window.faustUI = faustUI;
|
|
2764
2664
|
};
|
|
@@ -2777,7 +2677,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2777
2677
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2778
2678
|
/* harmony export */ "default": () => (/* binding */ AbstractGroup)
|
|
2779
2679
|
/* harmony export */ });
|
|
2780
|
-
const _AbstractGroup = class {
|
|
2680
|
+
const _AbstractGroup = class _AbstractGroup {
|
|
2781
2681
|
constructor(group, isRoot) {
|
|
2782
2682
|
this.isRoot = !!isRoot;
|
|
2783
2683
|
Object.assign(this, group);
|
|
@@ -2795,8 +2695,7 @@ const _AbstractGroup = class {
|
|
|
2795
2695
|
*/
|
|
2796
2696
|
get hasHSizingDesc() {
|
|
2797
2697
|
return !!this.items.find((item) => {
|
|
2798
|
-
if (item instanceof _AbstractGroup)
|
|
2799
|
-
return item.hasHSizingDesc;
|
|
2698
|
+
if (item instanceof _AbstractGroup) return item.hasHSizingDesc;
|
|
2800
2699
|
return item.layout.sizing === "horizontal" || item.layout.sizing === "both";
|
|
2801
2700
|
});
|
|
2802
2701
|
}
|
|
@@ -2805,8 +2704,7 @@ const _AbstractGroup = class {
|
|
|
2805
2704
|
*/
|
|
2806
2705
|
get hasVSizingDesc() {
|
|
2807
2706
|
return !!this.items.find((item) => {
|
|
2808
|
-
if (item instanceof _AbstractGroup)
|
|
2809
|
-
return item.hasVSizingDesc;
|
|
2707
|
+
if (item instanceof _AbstractGroup) return item.hasVSizingDesc;
|
|
2810
2708
|
return item.layout.sizing === "vertical" || item.layout.sizing === "both";
|
|
2811
2709
|
});
|
|
2812
2710
|
}
|
|
@@ -2820,10 +2718,10 @@ const _AbstractGroup = class {
|
|
|
2820
2718
|
return this;
|
|
2821
2719
|
}
|
|
2822
2720
|
};
|
|
2721
|
+
_AbstractGroup.padding = 0.2;
|
|
2722
|
+
_AbstractGroup.labelHeight = 0.25;
|
|
2723
|
+
_AbstractGroup.spaceBetween = 0.1;
|
|
2823
2724
|
let AbstractGroup = _AbstractGroup;
|
|
2824
|
-
AbstractGroup.padding = 0.2;
|
|
2825
|
-
AbstractGroup.labelHeight = 0.25;
|
|
2826
|
-
AbstractGroup.spaceBetween = 0.1;
|
|
2827
2725
|
|
|
2828
2726
|
|
|
2829
2727
|
|
|
@@ -3001,15 +2899,13 @@ class HGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3001
2899
|
this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding + (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight));
|
|
3002
2900
|
});
|
|
3003
2901
|
this.layout.width += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
|
|
3004
|
-
if (this.layout.width < 1)
|
|
3005
|
-
this.layout.width += 1;
|
|
2902
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
3006
2903
|
return this;
|
|
3007
2904
|
}
|
|
3008
2905
|
expand(dX) {
|
|
3009
2906
|
let hExpandItems = 0;
|
|
3010
2907
|
this.items.forEach((item) => {
|
|
3011
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
|
|
3012
|
-
hExpandItems++;
|
|
2908
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") hExpandItems++;
|
|
3013
2909
|
});
|
|
3014
2910
|
this.items.forEach((item) => {
|
|
3015
2911
|
let dX$ = 0;
|
|
@@ -3153,31 +3049,26 @@ class Layout {
|
|
|
3153
3049
|
if ((_a = item.meta) == null ? void 0 : _a.find((meta) => {
|
|
3154
3050
|
var _a2;
|
|
3155
3051
|
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("led");
|
|
3156
|
-
}))
|
|
3157
|
-
return "led";
|
|
3052
|
+
})) return "led";
|
|
3158
3053
|
if ((_b = item.meta) == null ? void 0 : _b.find((meta) => {
|
|
3159
3054
|
var _a2;
|
|
3160
3055
|
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("numerical");
|
|
3161
|
-
}))
|
|
3162
|
-
return "numerical";
|
|
3056
|
+
})) return "numerical";
|
|
3163
3057
|
return item.type;
|
|
3164
3058
|
}
|
|
3165
3059
|
if (item.type === "hslider" || item.type === "nentry" || item.type === "vslider") {
|
|
3166
3060
|
if ((_c = item.meta) == null ? void 0 : _c.find((meta) => {
|
|
3167
3061
|
var _a2;
|
|
3168
3062
|
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("knob");
|
|
3169
|
-
}))
|
|
3170
|
-
return "knob";
|
|
3063
|
+
})) return "knob";
|
|
3171
3064
|
if ((_d = item.meta) == null ? void 0 : _d.find((meta) => {
|
|
3172
3065
|
var _a2;
|
|
3173
3066
|
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("menu");
|
|
3174
|
-
}))
|
|
3175
|
-
return "menu";
|
|
3067
|
+
})) return "menu";
|
|
3176
3068
|
if ((_e = item.meta) == null ? void 0 : _e.find((meta) => {
|
|
3177
3069
|
var _a2;
|
|
3178
3070
|
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("radio");
|
|
3179
|
-
}))
|
|
3180
|
-
return "radio";
|
|
3071
|
+
})) return "radio";
|
|
3181
3072
|
}
|
|
3182
3073
|
return item.type;
|
|
3183
3074
|
}
|
|
@@ -3208,8 +3099,7 @@ class Layout {
|
|
|
3208
3099
|
}
|
|
3209
3100
|
static getItems(items) {
|
|
3210
3101
|
return items.map((item) => {
|
|
3211
|
-
if ("items" in item)
|
|
3212
|
-
item.items = this.getItems(item.items);
|
|
3102
|
+
if ("items" in item) item.items = this.getItems(item.items);
|
|
3213
3103
|
return this.getItem(item);
|
|
3214
3104
|
});
|
|
3215
3105
|
}
|
|
@@ -3400,7 +3290,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3400
3290
|
/* harmony export */ });
|
|
3401
3291
|
/* harmony import */ var _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractGroup */ "./src/layout/AbstractGroup.ts");
|
|
3402
3292
|
|
|
3403
|
-
const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
3293
|
+
const _TGroup = class _TGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
3404
3294
|
adjust() {
|
|
3405
3295
|
this.items.forEach((item) => {
|
|
3406
3296
|
item.adjust();
|
|
@@ -3410,8 +3300,7 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3410
3300
|
const tabsCount = this.items.length;
|
|
3411
3301
|
this.layout.width = Math.max(this.layout.width, tabsCount * _TGroup.tabLayout.width);
|
|
3412
3302
|
this.layout.height += _TGroup.tabLayout.height;
|
|
3413
|
-
if (this.layout.width < 1)
|
|
3414
|
-
this.layout.width += 1;
|
|
3303
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
3415
3304
|
return this;
|
|
3416
3305
|
}
|
|
3417
3306
|
expand() {
|
|
@@ -3419,10 +3308,8 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3419
3308
|
this.items.forEach((item) => {
|
|
3420
3309
|
let dY$ = 0;
|
|
3421
3310
|
let dX$ = 0;
|
|
3422
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
|
|
3423
|
-
|
|
3424
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
|
|
3425
|
-
dY$ = this.layout.height - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight) - (tabsCount ? _TGroup.tabLayout.height : 0) - item.layout.height;
|
|
3311
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width;
|
|
3312
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "vertical") dY$ = this.layout.height - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight) - (tabsCount ? _TGroup.tabLayout.height : 0) - item.layout.height;
|
|
3426
3313
|
item.expand(dX$, dY$);
|
|
3427
3314
|
});
|
|
3428
3315
|
return this;
|
|
@@ -3441,11 +3328,11 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3441
3328
|
return this;
|
|
3442
3329
|
}
|
|
3443
3330
|
};
|
|
3444
|
-
|
|
3445
|
-
TGroup.tabLayout = {
|
|
3331
|
+
_TGroup.tabLayout = {
|
|
3446
3332
|
width: 2,
|
|
3447
3333
|
height: 1
|
|
3448
3334
|
};
|
|
3335
|
+
let TGroup = _TGroup;
|
|
3449
3336
|
|
|
3450
3337
|
|
|
3451
3338
|
|
|
@@ -3498,15 +3385,13 @@ class VGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3498
3385
|
this.layout.height += item.layout.height;
|
|
3499
3386
|
});
|
|
3500
3387
|
this.layout.height += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
|
|
3501
|
-
if (this.layout.width < 1)
|
|
3502
|
-
this.layout.width += 1;
|
|
3388
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
3503
3389
|
return this;
|
|
3504
3390
|
}
|
|
3505
3391
|
expand(dX, dY) {
|
|
3506
3392
|
let vExpandItems = 0;
|
|
3507
3393
|
this.items.forEach((item) => {
|
|
3508
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
|
|
3509
|
-
vExpandItems++;
|
|
3394
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "vertical") vExpandItems++;
|
|
3510
3395
|
});
|
|
3511
3396
|
this.items.forEach((item) => {
|
|
3512
3397
|
let dX$ = 0;
|
|
@@ -3820,7 +3705,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3820
3705
|
/******/
|
|
3821
3706
|
/************************************************************************/
|
|
3822
3707
|
var __webpack_exports__ = {};
|
|
3823
|
-
// This entry
|
|
3708
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
3824
3709
|
(() => {
|
|
3825
3710
|
/*!**********************!*\
|
|
3826
3711
|
!*** ./src/index.ts ***!
|