@grame/faustwasm 0.3.2 → 0.4.1
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 +10 -4
- package/assets/standalone/faust-ui/index.js +177 -247
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +6 -0
- package/assets/standalone/faustwasm/index.js +12 -4
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/icon.png +0 -0
- package/assets/standalone/index-poly.js +11 -0
- package/assets/standalone/index.html +4 -2
- package/assets/standalone/index.js +11 -0
- package/assets/standalone/manifest.json +18 -0
- package/assets/standalone/service-worker.js +48 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +12 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +6 -0
- package/dist/cjs-bundle/index.js +12 -4
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +12 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +6 -0
- package/dist/esm-bundle/index.js +12 -4
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +2 -2
- package/src/FaustAudioWorkletNode.ts +0 -3
- package/src/SoundfileReader.ts +16 -2
- package/src/copyWebStandaloneAssets.js +11 -1
- package/test/faustlive-wasm/faust-ui/index.js +177 -247
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +6 -0
- package/test/faustlive-wasm/faustwasm/index.js +12 -4
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/osc2.dsp +1 -1
- package/0001-Invert-x-y-z-accelerometer-on-Android.patch +0 -194
- package/build +0 -17
|
@@ -129,6 +129,25 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
129
129
|
/* harmony import */ var _layout_Layout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./layout/Layout */ "./src/layout/Layout.ts");
|
|
130
130
|
/* harmony import */ var _components_Group__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/Group */ "./src/components/Group.ts");
|
|
131
131
|
/* harmony import */ var _index_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./index.scss */ "./src/index.scss");
|
|
132
|
+
var __defProp = Object.defineProperty;
|
|
133
|
+
var __defProps = Object.defineProperties;
|
|
134
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
135
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
136
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
137
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
138
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
139
|
+
var __spreadValues = (a, b) => {
|
|
140
|
+
for (var prop in b || (b = {}))
|
|
141
|
+
if (__hasOwnProp.call(b, prop))
|
|
142
|
+
__defNormalProp(a, prop, b[prop]);
|
|
143
|
+
if (__getOwnPropSymbols)
|
|
144
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
145
|
+
if (__propIsEnum.call(b, prop))
|
|
146
|
+
__defNormalProp(a, prop, b[prop]);
|
|
147
|
+
}
|
|
148
|
+
return a;
|
|
149
|
+
};
|
|
150
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
132
151
|
|
|
133
152
|
|
|
134
153
|
|
|
@@ -142,8 +161,7 @@ class FaustUI {
|
|
|
142
161
|
* Can be overriden, called by components when its value is changed by user.
|
|
143
162
|
*/
|
|
144
163
|
this.paramChangeByUI = (path, value) => {
|
|
145
|
-
if (!this.hostWindow)
|
|
146
|
-
return;
|
|
164
|
+
if (!this.hostWindow) return;
|
|
147
165
|
this.hostWindow.postMessage({ path, value, type: "param" }, "*");
|
|
148
166
|
};
|
|
149
167
|
const { root, ui: uiIn, listenWindowResize, listenWindowMessage } = options;
|
|
@@ -159,8 +177,7 @@ class FaustUI {
|
|
|
159
177
|
const { data, source } = e;
|
|
160
178
|
this.hostWindow = source;
|
|
161
179
|
const { type } = data;
|
|
162
|
-
if (!type)
|
|
163
|
-
return;
|
|
180
|
+
if (!type) return;
|
|
164
181
|
if (type === "ui") {
|
|
165
182
|
this.ui = data.ui;
|
|
166
183
|
} else if (type === "param") {
|
|
@@ -200,17 +217,14 @@ class FaustUI {
|
|
|
200
217
|
* This method should be called by components to register itself to map.
|
|
201
218
|
*/
|
|
202
219
|
register(path, item) {
|
|
203
|
-
if (this.componentMap[path])
|
|
204
|
-
|
|
205
|
-
else
|
|
206
|
-
this.componentMap[path] = [item];
|
|
220
|
+
if (this.componentMap[path]) this.componentMap[path].push(item);
|
|
221
|
+
else this.componentMap[path] = [item];
|
|
207
222
|
}
|
|
208
223
|
/**
|
|
209
224
|
* Notify the component to change its value.
|
|
210
225
|
*/
|
|
211
226
|
paramChangeByDSP(path, value) {
|
|
212
|
-
if (this.componentMap[path])
|
|
213
|
-
this.componentMap[path].forEach((item) => item.setState({ value }));
|
|
227
|
+
if (this.componentMap[path]) this.componentMap[path].forEach((item) => item.setState({ value }));
|
|
214
228
|
}
|
|
215
229
|
/**
|
|
216
230
|
* Calculate UI layout in grid then calculate grid size.
|
|
@@ -234,16 +248,30 @@ class FaustUI {
|
|
|
234
248
|
* Force recalculate grid size and resize UI
|
|
235
249
|
*/
|
|
236
250
|
resize() {
|
|
237
|
-
if (!this.faustUIRoot)
|
|
238
|
-
return;
|
|
251
|
+
if (!this.faustUIRoot) return;
|
|
239
252
|
this.calcGrid();
|
|
240
253
|
this.faustUIRoot.setState({ style: { grid: this.grid } });
|
|
241
254
|
}
|
|
255
|
+
/** Filter out items with `hidden` metadata and `soundfile` items */
|
|
256
|
+
filter(ui) {
|
|
257
|
+
const callback = (items, item) => {
|
|
258
|
+
var _a;
|
|
259
|
+
if (item.type === "soundfile") return items;
|
|
260
|
+
if (item.type === "hgroup" || item.type === "vgroup" || item.type === "tgroup") {
|
|
261
|
+
items.push(__spreadProps(__spreadValues({}, item), { items: item.items.reduce(callback, []) }));
|
|
262
|
+
return items;
|
|
263
|
+
}
|
|
264
|
+
if ((_a = item.meta) == null ? void 0 : _a.find((m) => m.hidden && m.hidden === "1")) return items;
|
|
265
|
+
items.push(item);
|
|
266
|
+
return items;
|
|
267
|
+
};
|
|
268
|
+
return ui.reduce(callback, []);
|
|
269
|
+
}
|
|
242
270
|
get ui() {
|
|
243
271
|
return this._ui;
|
|
244
272
|
}
|
|
245
273
|
set ui(uiIn) {
|
|
246
|
-
this._ui = uiIn;
|
|
274
|
+
this._ui = this.filter(uiIn);
|
|
247
275
|
this.calc();
|
|
248
276
|
this.mount();
|
|
249
277
|
}
|
|
@@ -335,10 +363,8 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
|
|
|
335
363
|
if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
336
364
|
this.state[stateKey] = stateValue;
|
|
337
365
|
shouldUpdate = true;
|
|
338
|
-
} else
|
|
339
|
-
|
|
340
|
-
if (shouldUpdate)
|
|
341
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
366
|
+
} else return;
|
|
367
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
342
368
|
}
|
|
343
369
|
}
|
|
344
370
|
/**
|
|
@@ -346,10 +372,8 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
|
|
|
346
372
|
* schedule what you need to do in next render tick in `raf` callback
|
|
347
373
|
*/
|
|
348
374
|
schedule(func) {
|
|
349
|
-
if (this.tasks.indexOf(func) === -1)
|
|
350
|
-
|
|
351
|
-
if (this.$raf)
|
|
352
|
-
return;
|
|
375
|
+
if (this.tasks.indexOf(func) === -1) this.tasks.push(func);
|
|
376
|
+
if (this.$raf) return;
|
|
353
377
|
this.$raf = window.requestAnimationFrame(this.raf);
|
|
354
378
|
}
|
|
355
379
|
}
|
|
@@ -393,7 +417,7 @@ var __spreadValues = (a, b) => {
|
|
|
393
417
|
|
|
394
418
|
|
|
395
419
|
|
|
396
|
-
const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
420
|
+
const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
397
421
|
/**
|
|
398
422
|
* Initiate default state with incoming state.
|
|
399
423
|
*/
|
|
@@ -484,19 +508,16 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
484
508
|
this.handleFocusIn = (e) => this.setState({ focus: true });
|
|
485
509
|
this.handleFocusOut = (e) => this.setState({ focus: false });
|
|
486
510
|
this.state.style = __spreadValues(__spreadValues({}, this.defaultProps.style), props.style);
|
|
487
|
-
if (this.state.emitter)
|
|
488
|
-
this.state.emitter.register(this.state.address, this);
|
|
511
|
+
if (this.state.emitter) this.state.emitter.register(this.state.address, this);
|
|
489
512
|
}
|
|
490
513
|
/**
|
|
491
514
|
* Get a nearest valid number
|
|
492
515
|
*/
|
|
493
516
|
toValidNumber(value) {
|
|
494
517
|
const { min, max, step } = this.state;
|
|
495
|
-
if (typeof min !== "number" || typeof max !== "number")
|
|
496
|
-
return value;
|
|
518
|
+
if (typeof min !== "number" || typeof max !== "number") return value;
|
|
497
519
|
const v = Math.min(max, Math.max(min, value));
|
|
498
|
-
if (!step)
|
|
499
|
-
return v;
|
|
520
|
+
if (!step) return v;
|
|
500
521
|
return min + Math.floor((v - min) / step) * step;
|
|
501
522
|
}
|
|
502
523
|
/**
|
|
@@ -505,16 +526,14 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
505
526
|
setValue(valueIn) {
|
|
506
527
|
const value = this.toValidNumber(valueIn);
|
|
507
528
|
const changed = this.setState({ value });
|
|
508
|
-
if (changed)
|
|
509
|
-
this.change(value);
|
|
529
|
+
if (changed) this.change(value);
|
|
510
530
|
return changed;
|
|
511
531
|
}
|
|
512
532
|
/**
|
|
513
533
|
* Send value to DSP
|
|
514
534
|
*/
|
|
515
535
|
change(valueIn) {
|
|
516
|
-
if (this.state.emitter)
|
|
517
|
-
this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
|
|
536
|
+
if (this.state.emitter) this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
|
|
518
537
|
}
|
|
519
538
|
/**
|
|
520
539
|
* set internal state and fire events for UI parts subscribed
|
|
@@ -536,10 +555,8 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
536
555
|
} else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
537
556
|
this.state[stateKey] = stateValue;
|
|
538
557
|
shouldUpdate = true;
|
|
539
|
-
} else
|
|
540
|
-
|
|
541
|
-
if (shouldUpdate)
|
|
542
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
558
|
+
} else return false;
|
|
559
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
543
560
|
}
|
|
544
561
|
return shouldUpdate;
|
|
545
562
|
}
|
|
@@ -552,8 +569,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
552
569
|
this.container.className = ["faust-ui-component", "faust-ui-component-" + this.className].join(" ");
|
|
553
570
|
this.container.tabIndex = 1;
|
|
554
571
|
this.container.id = this.state.address;
|
|
555
|
-
if (this.state.tooltip)
|
|
556
|
-
this.container.title = this.state.tooltip;
|
|
572
|
+
if (this.state.tooltip) this.container.title = this.state.tooltip;
|
|
557
573
|
this.label = document.createElement("div");
|
|
558
574
|
this.label.className = "faust-ui-component-label";
|
|
559
575
|
this.labelCanvas = document.createElement("canvas");
|
|
@@ -574,8 +590,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
574
590
|
const canvas = this.labelCanvas;
|
|
575
591
|
const ratio = window.devicePixelRatio || 1;
|
|
576
592
|
let { width, height } = this.label.getBoundingClientRect();
|
|
577
|
-
if (!width || !height)
|
|
578
|
-
return this;
|
|
593
|
+
if (!width || !height) return this;
|
|
579
594
|
width = Math.floor(width);
|
|
580
595
|
height = Math.floor(height);
|
|
581
596
|
const scaledWidth = Math.floor(width * ratio);
|
|
@@ -615,10 +630,8 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
615
630
|
const { type, max, min, step, enums } = this.state;
|
|
616
631
|
const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
|
|
617
632
|
if (step) {
|
|
618
|
-
if (type === "enum")
|
|
619
|
-
|
|
620
|
-
if (type === "int")
|
|
621
|
-
return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
|
|
633
|
+
if (type === "enum") return enums.length;
|
|
634
|
+
if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
|
|
622
635
|
return Math.floor((max - min) / step);
|
|
623
636
|
}
|
|
624
637
|
return maxSteps;
|
|
@@ -632,8 +645,7 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
632
645
|
}
|
|
633
646
|
static getDistance(state) {
|
|
634
647
|
const { type, max, min, value, enums, scale } = state;
|
|
635
|
-
if (type === "enum")
|
|
636
|
-
return value / (enums.length - 1);
|
|
648
|
+
if (type === "enum") return value / (enums.length - 1);
|
|
637
649
|
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;
|
|
638
650
|
return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max);
|
|
639
651
|
}
|
|
@@ -646,11 +658,10 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
|
|
|
646
658
|
return full / stepsCount;
|
|
647
659
|
}
|
|
648
660
|
};
|
|
649
|
-
let AbstractItem = _AbstractItem;
|
|
650
661
|
/**
|
|
651
662
|
* The default state of the component.
|
|
652
663
|
*/
|
|
653
|
-
|
|
664
|
+
_AbstractItem.defaultProps = {
|
|
654
665
|
value: 0,
|
|
655
666
|
active: true,
|
|
656
667
|
focus: false,
|
|
@@ -665,6 +676,7 @@ AbstractItem.defaultProps = {
|
|
|
665
676
|
step: 0.01,
|
|
666
677
|
style: { width: 45, height: 15, left: 0, top: 0, labelcolor: "rgba(226, 222, 255, 0.5)" }
|
|
667
678
|
};
|
|
679
|
+
let AbstractItem = _AbstractItem;
|
|
668
680
|
|
|
669
681
|
|
|
670
682
|
|
|
@@ -846,8 +858,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
846
858
|
this.children = [];
|
|
847
859
|
const { style, type, items, emitter, isRoot } = this.state;
|
|
848
860
|
const { grid, left, top, width, height } = style;
|
|
849
|
-
if (!this.state.isRoot)
|
|
850
|
-
this.label.style.height = `${grid * 0.3}px`;
|
|
861
|
+
if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
|
|
851
862
|
this.container.style.left = `${left * grid}px`;
|
|
852
863
|
this.container.style.top = `${top * grid}px`;
|
|
853
864
|
this.container.style.width = `${width * grid}px`;
|
|
@@ -856,13 +867,11 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
856
867
|
items.forEach((item) => {
|
|
857
868
|
if (item.type.endsWith("group")) {
|
|
858
869
|
const component = Group.getComponent(item, emitter, grid);
|
|
859
|
-
if (component)
|
|
860
|
-
this.children.push(component);
|
|
870
|
+
if (component) this.children.push(component);
|
|
861
871
|
} else {
|
|
862
872
|
const ioItem = item;
|
|
863
873
|
const itemComponent = Group.getComponent(ioItem, this.state.emitter, grid);
|
|
864
|
-
if (itemComponent)
|
|
865
|
-
this.children.push(itemComponent);
|
|
874
|
+
if (itemComponent) this.children.push(itemComponent);
|
|
866
875
|
}
|
|
867
876
|
});
|
|
868
877
|
if (type === "tgroup") {
|
|
@@ -882,8 +891,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
882
891
|
const groups = [];
|
|
883
892
|
for (let j = 0; j < this.container.children.length; j++) {
|
|
884
893
|
const element = this.container.children[j];
|
|
885
|
-
if (j > 1)
|
|
886
|
-
groups.push(element);
|
|
894
|
+
if (j > 1) groups.push(element);
|
|
887
895
|
}
|
|
888
896
|
for (let j = 0; j < groups.length; j++) {
|
|
889
897
|
const element = groups[j];
|
|
@@ -892,10 +900,8 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
892
900
|
for (let j = 0; j < this.tabs.children.length; j++) {
|
|
893
901
|
const e = this.tabs.children[j];
|
|
894
902
|
if (i !== j) {
|
|
895
|
-
if (e.classList.contains("active"))
|
|
896
|
-
|
|
897
|
-
} else
|
|
898
|
-
e.classList.add("active");
|
|
903
|
+
if (e.classList.contains("active")) e.classList.remove("active");
|
|
904
|
+
} else e.classList.add("active");
|
|
899
905
|
}
|
|
900
906
|
});
|
|
901
907
|
this.tabs.appendChild(tab);
|
|
@@ -905,8 +911,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
905
911
|
}
|
|
906
912
|
static parseMeta(metaIn) {
|
|
907
913
|
const metaObject = {};
|
|
908
|
-
if (!metaIn)
|
|
909
|
-
return { metaObject };
|
|
914
|
+
if (!metaIn) return { metaObject };
|
|
910
915
|
metaIn.forEach((m) => Object.assign(metaObject, m));
|
|
911
916
|
if (metaObject.style) {
|
|
912
917
|
const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?))\}/;
|
|
@@ -968,32 +973,19 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
968
973
|
step: "step" in item ? +item.step : 1,
|
|
969
974
|
value: "init" in item ? +item.init || 0 : 0
|
|
970
975
|
};
|
|
971
|
-
if (type === "button")
|
|
972
|
-
|
|
973
|
-
if (type === "
|
|
974
|
-
|
|
975
|
-
if (type === "
|
|
976
|
-
|
|
977
|
-
if (type === "
|
|
978
|
-
|
|
979
|
-
if (type === "
|
|
980
|
-
|
|
981
|
-
if (type === "
|
|
982
|
-
|
|
983
|
-
if (type === "
|
|
984
|
-
return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
|
|
985
|
-
if (type === "hslider")
|
|
986
|
-
return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
|
|
987
|
-
if (type === "vslider")
|
|
988
|
-
return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
|
|
989
|
-
if (type === "hbargraph")
|
|
990
|
-
return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
|
|
991
|
-
if (type === "vbargraph")
|
|
992
|
-
return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
|
|
993
|
-
if (type === "numerical")
|
|
994
|
-
return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
|
|
995
|
-
if (type === "led")
|
|
996
|
-
return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
|
|
976
|
+
if (type === "button") return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props);
|
|
977
|
+
if (type === "checkbox") return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props);
|
|
978
|
+
if (type === "nentry") return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props);
|
|
979
|
+
if (type === "soundfile") return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props);
|
|
980
|
+
if (type === "knob") return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props);
|
|
981
|
+
if (type === "menu") return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props);
|
|
982
|
+
if (type === "radio") return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
|
|
983
|
+
if (type === "hslider") return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
|
|
984
|
+
if (type === "vslider") return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
|
|
985
|
+
if (type === "hbargraph") return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
|
|
986
|
+
if (type === "vbargraph") return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
|
|
987
|
+
if (type === "numerical") return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
|
|
988
|
+
if (type === "led") return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
|
|
997
989
|
return null;
|
|
998
990
|
}
|
|
999
991
|
setState(newState) {
|
|
@@ -1012,10 +1004,8 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1012
1004
|
} else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
|
|
1013
1005
|
this.state[stateKey] = stateValue;
|
|
1014
1006
|
shouldUpdate = true;
|
|
1015
|
-
} else
|
|
1016
|
-
|
|
1017
|
-
if (shouldUpdate)
|
|
1018
|
-
this.emit(stateKey, this.state[stateKey]);
|
|
1007
|
+
} else return;
|
|
1008
|
+
if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
|
|
1019
1009
|
}
|
|
1020
1010
|
}
|
|
1021
1011
|
componentWillMount() {
|
|
@@ -1033,16 +1023,14 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1033
1023
|
return this;
|
|
1034
1024
|
}
|
|
1035
1025
|
paintLabel() {
|
|
1036
|
-
if (this.state.isRoot)
|
|
1037
|
-
return this;
|
|
1026
|
+
if (this.state.isRoot) return this;
|
|
1038
1027
|
const label = this.state.label;
|
|
1039
1028
|
const color = this.state.style.labelcolor;
|
|
1040
1029
|
const ctx = this.labelCtx;
|
|
1041
1030
|
const canvas = this.labelCanvas;
|
|
1042
1031
|
const ratio = window.devicePixelRatio || 1;
|
|
1043
1032
|
let { width, height } = this.label.getBoundingClientRect();
|
|
1044
|
-
if (!width || !height)
|
|
1045
|
-
return this;
|
|
1033
|
+
if (!width || !height) return this;
|
|
1046
1034
|
width = Math.floor(width);
|
|
1047
1035
|
height = Math.floor(height);
|
|
1048
1036
|
const scaledWidth = Math.floor(width * ratio);
|
|
@@ -1063,8 +1051,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1063
1051
|
this.label.appendChild(this.labelCanvas);
|
|
1064
1052
|
this.container.appendChild(this.label);
|
|
1065
1053
|
}
|
|
1066
|
-
if (this.tabs.children.length)
|
|
1067
|
-
this.container.appendChild(this.tabs);
|
|
1054
|
+
if (this.tabs.children.length) this.container.appendChild(this.tabs);
|
|
1068
1055
|
this.children.forEach((item) => {
|
|
1069
1056
|
item.mount();
|
|
1070
1057
|
this.container.appendChild(item.container);
|
|
@@ -1072,10 +1059,10 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1072
1059
|
return this;
|
|
1073
1060
|
}
|
|
1074
1061
|
componentDidMount() {
|
|
1062
|
+
var _a;
|
|
1075
1063
|
const handleResize = () => {
|
|
1076
1064
|
const { grid, left, top, width, height } = this.state.style;
|
|
1077
|
-
if (!this.state.isRoot)
|
|
1078
|
-
this.label.style.height = `${grid * 0.3}px`;
|
|
1065
|
+
if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
|
|
1079
1066
|
this.container.style.width = `${width * grid}px`;
|
|
1080
1067
|
this.container.style.height = `${height * grid}px`;
|
|
1081
1068
|
this.container.style.left = `${left * grid}px`;
|
|
@@ -1106,8 +1093,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1106
1093
|
};
|
|
1107
1094
|
this.on("label", () => this.schedule(labelChange));
|
|
1108
1095
|
this.paintLabel();
|
|
1109
|
-
if (this.tabs
|
|
1110
|
-
this.tabs.children[0].click();
|
|
1096
|
+
if ((_a = this.tabs) == null ? void 0 : _a.children.length) this.tabs.children[0].click();
|
|
1111
1097
|
this.children.forEach((item) => item.componentDidMount());
|
|
1112
1098
|
return this;
|
|
1113
1099
|
}
|
|
@@ -1165,8 +1151,7 @@ class HBargraph extends _VBargraph__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
1165
1151
|
const paintValue = this.paintValue;
|
|
1166
1152
|
if (paintValue > this.maxValue) {
|
|
1167
1153
|
this.maxValue = paintValue;
|
|
1168
|
-
if (this.maxTimer)
|
|
1169
|
-
window.clearTimeout(this.maxTimer);
|
|
1154
|
+
if (this.maxTimer) window.clearTimeout(this.maxTimer);
|
|
1170
1155
|
this.maxTimer = window.setTimeout(() => {
|
|
1171
1156
|
this.maxValue = this.paintValue;
|
|
1172
1157
|
this.maxTimer = void 0;
|
|
@@ -1186,23 +1171,15 @@ class HBargraph extends _VBargraph__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
1186
1171
|
const hotStop = (-3 - min) / (max - min);
|
|
1187
1172
|
const overloadStop = Math.max(0, -min / (max - min));
|
|
1188
1173
|
const gradient = ctx.createLinearGradient(left, 0, drawWidth, 0);
|
|
1189
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1195
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
1196
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
1197
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
1198
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
1199
|
-
else if (overloadStop < 0)
|
|
1200
|
-
gradient.addColorStop(0, coldcolor);
|
|
1174
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
1175
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
1176
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
1177
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
1178
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
1179
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
1201
1180
|
ctx.fillStyle = barbgcolor;
|
|
1202
|
-
if (paintValue < 0)
|
|
1203
|
-
|
|
1204
|
-
if (paintValue < max)
|
|
1205
|
-
ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight);
|
|
1181
|
+
if (paintValue < 0) ctx.fillRect(left, top, drawWidth * overloadStop, drawHeight);
|
|
1182
|
+
if (paintValue < max) ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight);
|
|
1206
1183
|
ctx.fillStyle = gradient;
|
|
1207
1184
|
if (paintValue > min) {
|
|
1208
1185
|
const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
|
|
@@ -1339,8 +1316,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1339
1316
|
const value = parseFloat(e.currentTarget.value);
|
|
1340
1317
|
if (isFinite(value)) {
|
|
1341
1318
|
const changed = this.setValue(+this.inputNumber.value);
|
|
1342
|
-
if (changed)
|
|
1343
|
-
return;
|
|
1319
|
+
if (changed) return;
|
|
1344
1320
|
}
|
|
1345
1321
|
this.input.value = this.inputNumber.value + (this.state.unit || "");
|
|
1346
1322
|
};
|
|
@@ -1395,8 +1371,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1395
1371
|
};
|
|
1396
1372
|
this.handlePointerDrag = (e) => {
|
|
1397
1373
|
const newValue = this.getValueFromDelta(e);
|
|
1398
|
-
if (newValue !== this.state.value)
|
|
1399
|
-
this.setValue(newValue);
|
|
1374
|
+
if (newValue !== this.state.value) this.setValue(newValue);
|
|
1400
1375
|
};
|
|
1401
1376
|
}
|
|
1402
1377
|
static get defaultProps() {
|
|
@@ -1489,10 +1464,8 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1489
1464
|
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;
|
|
1490
1465
|
let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
|
|
1491
1466
|
steps = Math.min(stepsCount, Math.max(0, steps));
|
|
1492
|
-
if (type === "enum")
|
|
1493
|
-
|
|
1494
|
-
if (type === "int")
|
|
1495
|
-
return Math.round(steps * step + min);
|
|
1467
|
+
if (type === "enum") return steps;
|
|
1468
|
+
if (type === "int") return Math.round(steps * step + min);
|
|
1496
1469
|
return steps * step + min;
|
|
1497
1470
|
}
|
|
1498
1471
|
}
|
|
@@ -1564,29 +1537,19 @@ class Led extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1564
1537
|
const hotStop = (-3 - min) / (max - min);
|
|
1565
1538
|
const overloadStop = -min / (max - min);
|
|
1566
1539
|
const gradient = tempCtx.createLinearGradient(0, 0, tempCanvas.width, 0);
|
|
1567
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
if (
|
|
1572
|
-
|
|
1573
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
1574
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
1575
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
1576
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
1577
|
-
else if (overloadStop < 0)
|
|
1578
|
-
gradient.addColorStop(0, coldcolor);
|
|
1540
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
1541
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
1542
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
1543
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
1544
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
1545
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
1579
1546
|
tempCtx.fillStyle = gradient;
|
|
1580
1547
|
tempCtx.fillRect(0, 0, tempCanvas.width, 10);
|
|
1581
1548
|
const d = tempCtx.getImageData(Math.min(tempCanvas.width - 1, distance * tempCanvas.width), 0, 1, 1).data;
|
|
1582
|
-
if (distance)
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
if (shape === "circle")
|
|
1587
|
-
ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
|
|
1588
|
-
else
|
|
1589
|
-
ctx.rect(left, top, drawWidth, drawHeight);
|
|
1549
|
+
if (distance) ctx.fillStyle = `rgb(${d[0]}, ${d[1]}, ${d[2]})`;
|
|
1550
|
+
else ctx.fillStyle = ledbgcolor;
|
|
1551
|
+
if (shape === "circle") ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
|
|
1552
|
+
else ctx.rect(left, top, drawWidth, drawHeight);
|
|
1590
1553
|
ctx.fill();
|
|
1591
1554
|
};
|
|
1592
1555
|
}
|
|
@@ -1727,8 +1690,7 @@ class Menu extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1727
1690
|
const option = document.createElement("option");
|
|
1728
1691
|
option.value = enums[key].toString();
|
|
1729
1692
|
option.text = key;
|
|
1730
|
-
if (i === 0)
|
|
1731
|
-
option.selected = true;
|
|
1693
|
+
if (i === 0) option.selected = true;
|
|
1732
1694
|
this.select.appendChild(option);
|
|
1733
1695
|
i++;
|
|
1734
1696
|
}
|
|
@@ -1743,8 +1705,7 @@ class Menu extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1743
1705
|
const valueChange = () => {
|
|
1744
1706
|
for (let i = this.select.children.length - 1; i >= 0; i--) {
|
|
1745
1707
|
const option = this.select.children[i];
|
|
1746
|
-
if (+option.value === this.state.value)
|
|
1747
|
-
this.select.selectedIndex = i;
|
|
1708
|
+
if (+option.value === this.state.value) this.select.selectedIndex = i;
|
|
1748
1709
|
}
|
|
1749
1710
|
};
|
|
1750
1711
|
this.on("value", () => this.schedule(valueChange));
|
|
@@ -1992,11 +1953,9 @@ class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
1992
1953
|
input.value = enums[key].toString();
|
|
1993
1954
|
input.name = address;
|
|
1994
1955
|
input.type = "radio";
|
|
1995
|
-
if (i === 0)
|
|
1996
|
-
input.checked = true;
|
|
1956
|
+
if (i === 0) input.checked = true;
|
|
1997
1957
|
input.addEventListener("change", () => {
|
|
1998
|
-
if (input.checked)
|
|
1999
|
-
this.setValue(enums[key]);
|
|
1958
|
+
if (input.checked) this.setValue(enums[key]);
|
|
2000
1959
|
});
|
|
2001
1960
|
div.appendChild(input);
|
|
2002
1961
|
div.append(key);
|
|
@@ -2044,8 +2003,7 @@ class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2044
2003
|
const valueChange = () => {
|
|
2045
2004
|
for (let i = this.group.children.length - 1; i >= 0; i--) {
|
|
2046
2005
|
const input = this.group.children[i].querySelector("input");
|
|
2047
|
-
if (+input.value === this.state.value)
|
|
2048
|
-
input.checked = true;
|
|
2006
|
+
if (+input.value === this.state.value) input.checked = true;
|
|
2049
2007
|
}
|
|
2050
2008
|
};
|
|
2051
2009
|
this.on("value", () => this.schedule(valueChange));
|
|
@@ -2227,8 +2185,7 @@ class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2227
2185
|
const paintValue = this.paintValue;
|
|
2228
2186
|
if (paintValue > this.maxValue) {
|
|
2229
2187
|
this.maxValue = paintValue;
|
|
2230
|
-
if (this.maxTimer)
|
|
2231
|
-
window.clearTimeout(this.maxTimer);
|
|
2188
|
+
if (this.maxTimer) window.clearTimeout(this.maxTimer);
|
|
2232
2189
|
this.maxTimer = window.setTimeout(() => {
|
|
2233
2190
|
this.maxValue = this.paintValue;
|
|
2234
2191
|
this.maxTimer = void 0;
|
|
@@ -2248,23 +2205,15 @@ class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2248
2205
|
const hotStop = (-3 - min) / (max - min);
|
|
2249
2206
|
const overloadStop = Math.max(0, -min / (max - min));
|
|
2250
2207
|
const gradient = ctx.createLinearGradient(0, drawHeight, 0, top);
|
|
2251
|
-
if (coldStop <= 1 && coldStop >= 0)
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
if (
|
|
2256
|
-
|
|
2257
|
-
if (hotStop <= 1 && hotStop >= 0)
|
|
2258
|
-
gradient.addColorStop(hotStop, hotcolor);
|
|
2259
|
-
if (overloadStop <= 1 && overloadStop >= 0)
|
|
2260
|
-
gradient.addColorStop(overloadStop, overloadcolor);
|
|
2261
|
-
else if (overloadStop < 0)
|
|
2262
|
-
gradient.addColorStop(0, coldcolor);
|
|
2208
|
+
if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
|
|
2209
|
+
else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
|
|
2210
|
+
if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
|
|
2211
|
+
if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
|
|
2212
|
+
if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
|
|
2213
|
+
else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
|
|
2263
2214
|
ctx.fillStyle = barbgcolor;
|
|
2264
|
-
if (paintValue < 0)
|
|
2265
|
-
|
|
2266
|
-
if (paintValue < max)
|
|
2267
|
-
ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1);
|
|
2215
|
+
if (paintValue < 0) ctx.fillRect(left, top + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop);
|
|
2216
|
+
if (paintValue < max) ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1);
|
|
2268
2217
|
ctx.fillStyle = gradient;
|
|
2269
2218
|
if (paintValue > min) {
|
|
2270
2219
|
const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
|
|
@@ -2399,8 +2348,7 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2399
2348
|
const value = parseFloat(e.currentTarget.value);
|
|
2400
2349
|
if (isFinite(value)) {
|
|
2401
2350
|
const changed = this.setValue(+value);
|
|
2402
|
-
if (changed)
|
|
2403
|
-
return;
|
|
2351
|
+
if (changed) return;
|
|
2404
2352
|
}
|
|
2405
2353
|
this.input.value = this.inputNumber.value + (this.state.unit || "");
|
|
2406
2354
|
};
|
|
@@ -2442,16 +2390,13 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2442
2390
|
};
|
|
2443
2391
|
this.handlePointerDown = (e) => {
|
|
2444
2392
|
const { value } = this.state;
|
|
2445
|
-
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])
|
|
2446
|
-
return;
|
|
2393
|
+
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;
|
|
2447
2394
|
const newValue = this.getValueFromPos(e);
|
|
2448
|
-
if (newValue !== value)
|
|
2449
|
-
this.setValue(this.getValueFromPos(e));
|
|
2395
|
+
if (newValue !== value) this.setValue(this.getValueFromPos(e));
|
|
2450
2396
|
};
|
|
2451
2397
|
this.handlePointerDrag = (e) => {
|
|
2452
2398
|
const newValue = this.getValueFromPos(e);
|
|
2453
|
-
if (newValue !== this.state.value)
|
|
2454
|
-
this.setValue(newValue);
|
|
2399
|
+
if (newValue !== this.state.value) this.setValue(newValue);
|
|
2455
2400
|
};
|
|
2456
2401
|
}
|
|
2457
2402
|
static get defaultProps() {
|
|
@@ -2542,10 +2487,8 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2542
2487
|
const { type, max, min, step, enums } = this.state;
|
|
2543
2488
|
const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
|
|
2544
2489
|
if (step) {
|
|
2545
|
-
if (type === "enum")
|
|
2546
|
-
|
|
2547
|
-
if (type === "int")
|
|
2548
|
-
return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
|
|
2490
|
+
if (type === "enum") return enums.length;
|
|
2491
|
+
if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
|
|
2549
2492
|
return Math.floor((max - min) / step);
|
|
2550
2493
|
}
|
|
2551
2494
|
return maxSteps;
|
|
@@ -2566,10 +2509,8 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2566
2509
|
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;
|
|
2567
2510
|
let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
|
|
2568
2511
|
steps = Math.min(stepsCount, Math.max(0, steps));
|
|
2569
|
-
if (type === "enum")
|
|
2570
|
-
|
|
2571
|
-
if (type === "int")
|
|
2572
|
-
return Math.round(steps * step + min);
|
|
2512
|
+
if (type === "enum") return steps;
|
|
2513
|
+
if (type === "int") return Math.round(steps * step + min);
|
|
2573
2514
|
return steps * step + min;
|
|
2574
2515
|
}
|
|
2575
2516
|
}
|
|
@@ -2624,10 +2565,8 @@ const normExp = iNormLog;
|
|
|
2624
2565
|
const iNormExp = normLog;
|
|
2625
2566
|
const roundedRect = (ctx, x, y, width, height, radius) => {
|
|
2626
2567
|
const radii = [0, 0, 0, 0];
|
|
2627
|
-
if (typeof radius === "number")
|
|
2628
|
-
|
|
2629
|
-
else
|
|
2630
|
-
radius.forEach((v, i) => radii[i] = v);
|
|
2568
|
+
if (typeof radius === "number") radii.fill(radius);
|
|
2569
|
+
else radius.forEach((v, i) => radii[i] = v);
|
|
2631
2570
|
ctx.beginPath();
|
|
2632
2571
|
ctx.moveTo(x + radii[0], y);
|
|
2633
2572
|
ctx.lineTo(x + width - radii[1], y);
|
|
@@ -2643,10 +2582,8 @@ const roundedRect = (ctx, x, y, width, height, radius) => {
|
|
|
2643
2582
|
};
|
|
2644
2583
|
const fillRoundedRect = (ctx, x, y, width, height, radius) => {
|
|
2645
2584
|
const radii = [0, 0, 0, 0];
|
|
2646
|
-
if (typeof radius === "number")
|
|
2647
|
-
|
|
2648
|
-
else
|
|
2649
|
-
radius.forEach((v, i) => radii[i] = v);
|
|
2585
|
+
if (typeof radius === "number") radii.fill(radius);
|
|
2586
|
+
else radius.forEach((v, i) => radii[i] = v);
|
|
2650
2587
|
ctx.beginPath();
|
|
2651
2588
|
ctx.moveTo(x + radii[0], y);
|
|
2652
2589
|
ctx.lineTo(x + width - radii[1], y);
|
|
@@ -2688,12 +2625,10 @@ const instantiate = () => {
|
|
|
2688
2625
|
host = source;
|
|
2689
2626
|
});
|
|
2690
2627
|
window.addEventListener("keydown", (e) => {
|
|
2691
|
-
if (host)
|
|
2692
|
-
host.postMessage({ type: "keydown", key: e.key }, "*");
|
|
2628
|
+
if (host) host.postMessage({ type: "keydown", key: e.key }, "*");
|
|
2693
2629
|
});
|
|
2694
2630
|
window.addEventListener("keyup", (e) => {
|
|
2695
|
-
if (host)
|
|
2696
|
-
host.postMessage({ type: "keyup", key: e.key }, "*");
|
|
2631
|
+
if (host) host.postMessage({ type: "keyup", key: e.key }, "*");
|
|
2697
2632
|
});
|
|
2698
2633
|
window.faustUI = faustUI;
|
|
2699
2634
|
};
|
|
@@ -2712,7 +2647,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2712
2647
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2713
2648
|
/* harmony export */ "default": () => (/* binding */ AbstractGroup)
|
|
2714
2649
|
/* harmony export */ });
|
|
2715
|
-
const _AbstractGroup = class {
|
|
2650
|
+
const _AbstractGroup = class _AbstractGroup {
|
|
2716
2651
|
constructor(group, isRoot) {
|
|
2717
2652
|
this.isRoot = !!isRoot;
|
|
2718
2653
|
Object.assign(this, group);
|
|
@@ -2730,8 +2665,7 @@ const _AbstractGroup = class {
|
|
|
2730
2665
|
*/
|
|
2731
2666
|
get hasHSizingDesc() {
|
|
2732
2667
|
return !!this.items.find((item) => {
|
|
2733
|
-
if (item instanceof _AbstractGroup)
|
|
2734
|
-
return item.hasHSizingDesc;
|
|
2668
|
+
if (item instanceof _AbstractGroup) return item.hasHSizingDesc;
|
|
2735
2669
|
return item.layout.sizing === "horizontal" || item.layout.sizing === "both";
|
|
2736
2670
|
});
|
|
2737
2671
|
}
|
|
@@ -2740,8 +2674,7 @@ const _AbstractGroup = class {
|
|
|
2740
2674
|
*/
|
|
2741
2675
|
get hasVSizingDesc() {
|
|
2742
2676
|
return !!this.items.find((item) => {
|
|
2743
|
-
if (item instanceof _AbstractGroup)
|
|
2744
|
-
return item.hasVSizingDesc;
|
|
2677
|
+
if (item instanceof _AbstractGroup) return item.hasVSizingDesc;
|
|
2745
2678
|
return item.layout.sizing === "vertical" || item.layout.sizing === "both";
|
|
2746
2679
|
});
|
|
2747
2680
|
}
|
|
@@ -2755,10 +2688,10 @@ const _AbstractGroup = class {
|
|
|
2755
2688
|
return this;
|
|
2756
2689
|
}
|
|
2757
2690
|
};
|
|
2691
|
+
_AbstractGroup.padding = 0.2;
|
|
2692
|
+
_AbstractGroup.labelHeight = 0.25;
|
|
2693
|
+
_AbstractGroup.spaceBetween = 0.1;
|
|
2758
2694
|
let AbstractGroup = _AbstractGroup;
|
|
2759
|
-
AbstractGroup.padding = 0.2;
|
|
2760
|
-
AbstractGroup.labelHeight = 0.25;
|
|
2761
|
-
AbstractGroup.spaceBetween = 0.1;
|
|
2762
2695
|
|
|
2763
2696
|
|
|
2764
2697
|
|
|
@@ -2936,15 +2869,13 @@ class HGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
2936
2869
|
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));
|
|
2937
2870
|
});
|
|
2938
2871
|
this.layout.width += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
|
|
2939
|
-
if (this.layout.width < 1)
|
|
2940
|
-
this.layout.width += 1;
|
|
2872
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
2941
2873
|
return this;
|
|
2942
2874
|
}
|
|
2943
2875
|
expand(dX) {
|
|
2944
2876
|
let hExpandItems = 0;
|
|
2945
2877
|
this.items.forEach((item) => {
|
|
2946
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
|
|
2947
|
-
hExpandItems++;
|
|
2878
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") hExpandItems++;
|
|
2948
2879
|
});
|
|
2949
2880
|
this.items.forEach((item) => {
|
|
2950
2881
|
let dX$ = 0;
|
|
@@ -3083,22 +3014,31 @@ class Layout {
|
|
|
3083
3014
|
* Get the rendering type of an item by parsing its metadata
|
|
3084
3015
|
*/
|
|
3085
3016
|
static predictType(item) {
|
|
3086
|
-
|
|
3087
|
-
return item.type;
|
|
3017
|
+
var _a, _b, _c, _d, _e;
|
|
3088
3018
|
if (item.type === "hbargraph" || item.type === "vbargraph") {
|
|
3089
|
-
if (item.meta
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3019
|
+
if ((_a = item.meta) == null ? void 0 : _a.find((meta) => {
|
|
3020
|
+
var _a2;
|
|
3021
|
+
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("led");
|
|
3022
|
+
})) return "led";
|
|
3023
|
+
if ((_b = item.meta) == null ? void 0 : _b.find((meta) => {
|
|
3024
|
+
var _a2;
|
|
3025
|
+
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("numerical");
|
|
3026
|
+
})) return "numerical";
|
|
3093
3027
|
return item.type;
|
|
3094
3028
|
}
|
|
3095
3029
|
if (item.type === "hslider" || item.type === "nentry" || item.type === "vslider") {
|
|
3096
|
-
if (item.meta
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
if (item.meta
|
|
3101
|
-
|
|
3030
|
+
if ((_c = item.meta) == null ? void 0 : _c.find((meta) => {
|
|
3031
|
+
var _a2;
|
|
3032
|
+
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("knob");
|
|
3033
|
+
})) return "knob";
|
|
3034
|
+
if ((_d = item.meta) == null ? void 0 : _d.find((meta) => {
|
|
3035
|
+
var _a2;
|
|
3036
|
+
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("menu");
|
|
3037
|
+
})) return "menu";
|
|
3038
|
+
if ((_e = item.meta) == null ? void 0 : _e.find((meta) => {
|
|
3039
|
+
var _a2;
|
|
3040
|
+
return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("radio");
|
|
3041
|
+
})) return "radio";
|
|
3102
3042
|
}
|
|
3103
3043
|
return item.type;
|
|
3104
3044
|
}
|
|
@@ -3129,8 +3069,7 @@ class Layout {
|
|
|
3129
3069
|
}
|
|
3130
3070
|
static getItems(items) {
|
|
3131
3071
|
return items.map((item) => {
|
|
3132
|
-
if ("items" in item)
|
|
3133
|
-
item.items = this.getItems(item.items);
|
|
3072
|
+
if ("items" in item) item.items = this.getItems(item.items);
|
|
3134
3073
|
return this.getItem(item);
|
|
3135
3074
|
});
|
|
3136
3075
|
}
|
|
@@ -3321,7 +3260,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3321
3260
|
/* harmony export */ });
|
|
3322
3261
|
/* harmony import */ var _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractGroup */ "./src/layout/AbstractGroup.ts");
|
|
3323
3262
|
|
|
3324
|
-
const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
3263
|
+
const _TGroup = class _TGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
3325
3264
|
adjust() {
|
|
3326
3265
|
this.items.forEach((item) => {
|
|
3327
3266
|
item.adjust();
|
|
@@ -3331,8 +3270,7 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3331
3270
|
const tabsCount = this.items.length;
|
|
3332
3271
|
this.layout.width = Math.max(this.layout.width, tabsCount * _TGroup.tabLayout.width);
|
|
3333
3272
|
this.layout.height += _TGroup.tabLayout.height;
|
|
3334
|
-
if (this.layout.width < 1)
|
|
3335
|
-
this.layout.width += 1;
|
|
3273
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
3336
3274
|
return this;
|
|
3337
3275
|
}
|
|
3338
3276
|
expand() {
|
|
@@ -3340,10 +3278,8 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3340
3278
|
this.items.forEach((item) => {
|
|
3341
3279
|
let dY$ = 0;
|
|
3342
3280
|
let dX$ = 0;
|
|
3343
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
|
|
3344
|
-
|
|
3345
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
|
|
3346
|
-
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;
|
|
3281
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width;
|
|
3282
|
+
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;
|
|
3347
3283
|
item.expand(dX$, dY$);
|
|
3348
3284
|
});
|
|
3349
3285
|
return this;
|
|
@@ -3362,11 +3298,11 @@ const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["defau
|
|
|
3362
3298
|
return this;
|
|
3363
3299
|
}
|
|
3364
3300
|
};
|
|
3365
|
-
|
|
3366
|
-
TGroup.tabLayout = {
|
|
3301
|
+
_TGroup.tabLayout = {
|
|
3367
3302
|
width: 2,
|
|
3368
3303
|
height: 1
|
|
3369
3304
|
};
|
|
3305
|
+
let TGroup = _TGroup;
|
|
3370
3306
|
|
|
3371
3307
|
|
|
3372
3308
|
|
|
@@ -3419,15 +3355,13 @@ class VGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3419
3355
|
this.layout.height += item.layout.height;
|
|
3420
3356
|
});
|
|
3421
3357
|
this.layout.height += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
|
|
3422
|
-
if (this.layout.width < 1)
|
|
3423
|
-
this.layout.width += 1;
|
|
3358
|
+
if (this.layout.width < 1) this.layout.width += 1;
|
|
3424
3359
|
return this;
|
|
3425
3360
|
}
|
|
3426
3361
|
expand(dX, dY) {
|
|
3427
3362
|
let vExpandItems = 0;
|
|
3428
3363
|
this.items.forEach((item) => {
|
|
3429
|
-
if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
|
|
3430
|
-
vExpandItems++;
|
|
3364
|
+
if (item.layout.sizing === "both" || item.layout.sizing === "vertical") vExpandItems++;
|
|
3431
3365
|
});
|
|
3432
3366
|
this.items.forEach((item) => {
|
|
3433
3367
|
let dX$ = 0;
|
|
@@ -3741,8 +3675,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3741
3675
|
/******/
|
|
3742
3676
|
/************************************************************************/
|
|
3743
3677
|
var __webpack_exports__ = {};
|
|
3744
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
3745
|
-
(() => {
|
|
3746
3678
|
/*!**********************!*\
|
|
3747
3679
|
!*** ./src/index.ts ***!
|
|
3748
3680
|
\**********************/
|
|
@@ -3756,8 +3688,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3756
3688
|
|
|
3757
3689
|
|
|
3758
3690
|
|
|
3759
|
-
})();
|
|
3760
|
-
|
|
3761
3691
|
var __webpack_exports__FaustUI = __webpack_exports__.FaustUI;
|
|
3762
3692
|
var __webpack_exports__instantiate = __webpack_exports__.instantiate;
|
|
3763
3693
|
export { __webpack_exports__FaustUI as FaustUI, __webpack_exports__instantiate as instantiate };
|