@grame/faustwasm 0.0.67 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/assets/standalone/faust-ui/index.css +17 -0
  3. package/assets/standalone/faust-ui/index.css.map +1 -1
  4. package/assets/standalone/faust-ui/index.js +294 -47
  5. package/assets/standalone/faust-ui/index.js.map +1 -1
  6. package/assets/standalone/faustwasm/index.d.ts +145 -4
  7. package/assets/standalone/faustwasm/index.js +449 -73
  8. package/assets/standalone/faustwasm/index.js.map +3 -3
  9. package/assets/standalone/index-poly.js +9 -6
  10. package/assets/standalone/index.js +9 -6
  11. package/dist/cjs/index.d.ts +145 -4
  12. package/dist/cjs/index.js +449 -73
  13. package/dist/cjs/index.js.map +3 -3
  14. package/dist/cjs-bundle/index.d.ts +145 -4
  15. package/dist/cjs-bundle/index.js +550 -174
  16. package/dist/cjs-bundle/index.js.map +3 -3
  17. package/dist/esm/index.d.ts +145 -4
  18. package/dist/esm/index.js +449 -73
  19. package/dist/esm/index.js.map +3 -3
  20. package/dist/esm-bundle/index.d.ts +145 -4
  21. package/dist/esm-bundle/index.js +550 -174
  22. package/dist/esm-bundle/index.js.map +3 -3
  23. package/libfaust-wasm/libfaust-wasm.data +0 -0
  24. package/libfaust-wasm/libfaust-wasm.js +1 -1
  25. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  26. package/package.json +2 -2
  27. package/src/FaustAudioWorkletProcessor.ts +16 -3
  28. package/src/FaustDspGenerator.ts +18 -3
  29. package/src/FaustWasmInstantiator.ts +62 -26
  30. package/src/FaustWebAudioDsp.ts +682 -51
  31. package/src/faust2wasmFiles.js +6 -4
  32. package/test/faustlive-wasm/faust-ui/index.css +17 -0
  33. package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
  34. package/test/faustlive-wasm/faust-ui/index.js +294 -47
  35. package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
  36. package/test/faustlive-wasm/faustwasm/index.d.ts +145 -4
  37. package/test/faustlive-wasm/faustwasm/index.js +449 -73
  38. package/test/faustlive-wasm/faustwasm/index.js.map +3 -3
  39. package/TODO.md +0 -5
  40. package/test/tp0.dsp +0 -17
  41. package/test/tp0.dsp.json +0 -30
  42. package/test/tp0_local.dsp +0 -5
@@ -133,8 +133,14 @@ __webpack_require__.r(__webpack_exports__);
133
133
 
134
134
 
135
135
  class FaustUI {
136
+ /**
137
+ * Calculate incoming UI's layout, bind window events
138
+ */
136
139
  constructor(options) {
137
140
  this.componentMap = {};
141
+ /**
142
+ * Can be overriden, called by components when its value is changed by user.
143
+ */
138
144
  this.paramChangeByUI = (path, value) => {
139
145
  if (!this.hostWindow)
140
146
  return;
@@ -164,6 +170,9 @@ class FaustUI {
164
170
  });
165
171
  }
166
172
  }
173
+ /**
174
+ * Render the UI to DOM root
175
+ */
167
176
  mount() {
168
177
  this.componentMap = {};
169
178
  this.DOMroot.innerHTML = "";
@@ -187,28 +196,43 @@ class FaustUI {
187
196
  this.DOMroot.appendChild(this.faustUIRoot.container);
188
197
  this.faustUIRoot.componentDidMount();
189
198
  }
199
+ /**
200
+ * This method should be called by components to register itself to map.
201
+ */
190
202
  register(path, item) {
191
203
  if (this.componentMap[path])
192
204
  this.componentMap[path].push(item);
193
205
  else
194
206
  this.componentMap[path] = [item];
195
207
  }
208
+ /**
209
+ * Notify the component to change its value.
210
+ */
196
211
  paramChangeByDSP(path, value) {
197
212
  if (this.componentMap[path])
198
213
  this.componentMap[path].forEach((item) => item.setState({ value }));
199
214
  }
215
+ /**
216
+ * Calculate UI layout in grid then calculate grid size.
217
+ */
200
218
  calc() {
201
219
  const { items, layout } = _layout_Layout__WEBPACK_IMPORTED_MODULE_0__["default"].calc(this.ui);
202
220
  this._ui = items;
203
221
  this._layout = layout;
204
222
  this.calcGrid();
205
223
  }
224
+ /**
225
+ * Calculate grid size by DOM root size and layout size in grids.
226
+ */
206
227
  calcGrid() {
207
228
  const { width, height } = this.DOMroot.getBoundingClientRect();
208
229
  const grid = Math.max(40, Math.min(width / this._layout.width, height / this._layout.height));
209
230
  this.grid = grid;
210
231
  return grid;
211
232
  }
233
+ /**
234
+ * Force recalculate grid size and resize UI
235
+ */
212
236
  resize() {
213
237
  if (!this.faustUIRoot)
214
238
  return;
@@ -266,10 +290,22 @@ var __spreadValues = (a, b) => {
266
290
  };
267
291
 
268
292
  class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MODULE_0__["default"] {
293
+ /**
294
+ * Initiate default state with incoming state.
295
+ */
269
296
  constructor(props) {
270
297
  super();
298
+ /**
299
+ * Frame count in order to reduce frame rate
300
+ */
271
301
  this.$frame = 0;
302
+ /**
303
+ * Frame reducing factor, 1 = render at every browser rendering tick, 2 will skip one every two ticks.
304
+ */
272
305
  this.frameReduce = 1;
306
+ /**
307
+ * `requestAnimationFrame` callback
308
+ */
273
309
  this.raf = () => {
274
310
  this.$frame++;
275
311
  if (this.$frame % this.frameReduce !== 0) {
@@ -280,12 +316,18 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
280
316
  this.tasks.forEach((f) => f());
281
317
  this.tasks = [];
282
318
  };
319
+ /**
320
+ * tasks to execute in next redering tick
321
+ */
283
322
  this.tasks = [];
284
323
  this.state = __spreadValues(__spreadValues({}, this.defaultProps), props);
285
324
  }
286
325
  get defaultProps() {
287
326
  return this.constructor.defaultProps;
288
327
  }
328
+ /**
329
+ * set internal state and fire events for UI parts subscribed
330
+ */
289
331
  setState(newState) {
290
332
  let shouldUpdate = false;
291
333
  for (const stateKey in newState) {
@@ -299,6 +341,10 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
299
341
  this.emit(stateKey, this.state[stateKey]);
300
342
  }
301
343
  }
344
+ /**
345
+ * Use this method to request a new rendering
346
+ * schedule what you need to do in next render tick in `raf` callback
347
+ */
302
348
  schedule(func) {
303
349
  if (this.tasks.indexOf(func) === -1)
304
350
  this.tasks.push(func);
@@ -307,6 +353,9 @@ class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MOD
307
353
  this.$raf = window.requestAnimationFrame(this.raf);
308
354
  }
309
355
  }
356
+ /**
357
+ * The default state of the component.
358
+ */
310
359
  AbstractComponent.defaultProps = {};
311
360
 
312
361
 
@@ -345,9 +394,16 @@ var __spreadValues = (a, b) => {
345
394
 
346
395
 
347
396
  const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
397
+ /**
398
+ * Initiate default state with incoming state.
399
+ */
348
400
  constructor(props) {
349
401
  super(props);
350
402
  this.frameReduce = 3;
403
+ /**
404
+ * Default DOM event listeners, unify mousedown and touchstart events
405
+ * For mouse or touch events, please use `handlePointerDown` `handlePointerUp` `handlePointerDrag` callbacks
406
+ */
351
407
  this.handleKeyDown = (e) => {
352
408
  };
353
409
  this.handleKeyUp = (e) => {
@@ -431,6 +487,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
431
487
  if (this.state.emitter)
432
488
  this.state.emitter.register(this.state.address, this);
433
489
  }
490
+ /**
491
+ * Get a nearest valid number
492
+ */
434
493
  toValidNumber(value) {
435
494
  const { min, max, step } = this.state;
436
495
  if (typeof min !== "number" || typeof max !== "number")
@@ -440,6 +499,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
440
499
  return v;
441
500
  return min + Math.floor((v - min) / step) * step;
442
501
  }
502
+ /**
503
+ * Use this method if you want the emitter to send value to DSP
504
+ */
443
505
  setValue(valueIn) {
444
506
  const value = this.toValidNumber(valueIn);
445
507
  const changed = this.setState({ value });
@@ -447,10 +509,18 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
447
509
  this.change(value);
448
510
  return changed;
449
511
  }
512
+ /**
513
+ * Send value to DSP
514
+ */
450
515
  change(valueIn) {
451
516
  if (this.state.emitter)
452
517
  this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
453
518
  }
519
+ /**
520
+ * set internal state and fire events for UI parts subscribed
521
+ * This will not send anything to DSP
522
+ * @returns is state updated
523
+ */
454
524
  setState(newState) {
455
525
  let shouldUpdate = false;
456
526
  for (const key in newState) {
@@ -473,6 +543,10 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
473
543
  }
474
544
  return shouldUpdate;
475
545
  }
546
+ /**
547
+ * Create container with class name
548
+ * override it with `super.componentWillMount();`
549
+ */
476
550
  componentWillMount() {
477
551
  this.container = document.createElement("div");
478
552
  this.container.className = ["faust-ui-component", "faust-ui-component-" + this.className].join(" ");
@@ -486,6 +560,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
486
560
  this.labelCtx = this.labelCanvas.getContext("2d");
487
561
  return this;
488
562
  }
563
+ /**
564
+ * Here append all child DOM to container
565
+ */
489
566
  mount() {
490
567
  this.label.appendChild(this.labelCanvas);
491
568
  return this;
@@ -514,6 +591,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
514
591
  ctx.fillText(label, align === "left" ? 0 : align === "right" ? width : width / 2, height / 2, width);
515
592
  return this;
516
593
  }
594
+ /**
595
+ * will call this method when mounted
596
+ */
517
597
  componentDidMount() {
518
598
  const handleResize = () => {
519
599
  const { grid, left, top, width, height } = this.state.style;
@@ -528,6 +608,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
528
608
  handleResize();
529
609
  return this;
530
610
  }
611
+ /**
612
+ * Count steps in range min-max with step
613
+ */
531
614
  get stepsCount() {
532
615
  const { type, max, min, step, enums } = this.state;
533
616
  const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
@@ -540,6 +623,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
540
623
  }
541
624
  return maxSteps;
542
625
  }
626
+ /**
627
+ * Normalized value between 0 - 1.
628
+ */
543
629
  get distance() {
544
630
  const { type, max, min, value, enums, scale } = this.state;
545
631
  return _AbstractItem.getDistance({ type, max, min, value, enums, scale });
@@ -551,6 +637,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
551
637
  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;
552
638
  return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max);
553
639
  }
640
+ /**
641
+ * Mousemove pixels for each step
642
+ */
554
643
  get stepRange() {
555
644
  const full = 100;
556
645
  const stepsCount = this.stepsCount;
@@ -558,6 +647,9 @@ const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_
558
647
  }
559
648
  };
560
649
  let AbstractItem = _AbstractItem;
650
+ /**
651
+ * The default state of the component.
652
+ */
561
653
  AbstractItem.defaultProps = {
562
654
  value: 0,
563
655
  active: true,
@@ -719,17 +811,19 @@ __webpack_require__.r(__webpack_exports__);
719
811
  /* harmony import */ var _HSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HSlider */ "./src/components/HSlider.ts");
720
812
  /* harmony import */ var _VSlider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./VSlider */ "./src/components/VSlider.ts");
721
813
  /* harmony import */ var _Nentry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Nentry */ "./src/components/Nentry.ts");
722
- /* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Button */ "./src/components/Button.ts");
723
- /* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Checkbox */ "./src/components/Checkbox.ts");
724
- /* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Knob */ "./src/components/Knob.ts");
725
- /* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Menu */ "./src/components/Menu.ts");
726
- /* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Radio */ "./src/components/Radio.ts");
727
- /* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Led */ "./src/components/Led.ts");
728
- /* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Numerical */ "./src/components/Numerical.ts");
729
- /* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./HBargraph */ "./src/components/HBargraph.ts");
730
- /* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./VBargraph */ "./src/components/VBargraph.ts");
731
- /* harmony import */ var _layout_Layout__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../layout/Layout */ "./src/layout/Layout.ts");
732
- /* harmony import */ var _Group_scss__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Group.scss */ "./src/components/Group.scss");
814
+ /* harmony import */ var _Soundfile__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Soundfile */ "./src/components/Soundfile.ts");
815
+ /* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Button */ "./src/components/Button.ts");
816
+ /* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Checkbox */ "./src/components/Checkbox.ts");
817
+ /* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Knob */ "./src/components/Knob.ts");
818
+ /* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Menu */ "./src/components/Menu.ts");
819
+ /* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Radio */ "./src/components/Radio.ts");
820
+ /* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Led */ "./src/components/Led.ts");
821
+ /* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Numerical */ "./src/components/Numerical.ts");
822
+ /* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./HBargraph */ "./src/components/HBargraph.ts");
823
+ /* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./VBargraph */ "./src/components/VBargraph.ts");
824
+ /* harmony import */ var _layout_Layout__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../layout/Layout */ "./src/layout/Layout.ts");
825
+ /* harmony import */ var _Group_scss__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Group.scss */ "./src/components/Group.scss");
826
+
733
827
 
734
828
 
735
829
 
@@ -830,7 +924,7 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
830
924
  return { metaObject };
831
925
  }
832
926
  static getComponent(item, emitter, grid) {
833
- const type = _layout_Layout__WEBPACK_IMPORTED_MODULE_13__["default"].predictType(item);
927
+ const type = _layout_Layout__WEBPACK_IMPORTED_MODULE_14__["default"].predictType(item);
834
928
  if (type.endsWith("group")) {
835
929
  const { label: label2, items, type: type2, layout: layout2 } = item;
836
930
  const props2 = {
@@ -875,29 +969,31 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
875
969
  value: "init" in item ? +item.init || 0 : 0
876
970
  };
877
971
  if (type === "button")
878
- return new _Button__WEBPACK_IMPORTED_MODULE_4__["default"](props);
972
+ return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props);
879
973
  if (type === "checkbox")
880
- return new _Checkbox__WEBPACK_IMPORTED_MODULE_5__["default"](props);
974
+ return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props);
881
975
  if (type === "nentry")
882
976
  return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props);
977
+ if (type === "soundfile")
978
+ return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props);
883
979
  if (type === "knob")
884
- return new _Knob__WEBPACK_IMPORTED_MODULE_6__["default"](props);
980
+ return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props);
885
981
  if (type === "menu")
886
- return new _Menu__WEBPACK_IMPORTED_MODULE_7__["default"](props);
982
+ return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props);
887
983
  if (type === "radio")
888
- return new _Radio__WEBPACK_IMPORTED_MODULE_8__["default"](props);
984
+ return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
889
985
  if (type === "hslider")
890
986
  return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
891
987
  if (type === "vslider")
892
988
  return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
893
989
  if (type === "hbargraph")
894
- return new _HBargraph__WEBPACK_IMPORTED_MODULE_11__["default"](props);
990
+ return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
895
991
  if (type === "vbargraph")
896
- return new _VBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
992
+ return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
897
993
  if (type === "numerical")
898
- return new _Numerical__WEBPACK_IMPORTED_MODULE_10__["default"](props);
994
+ return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
899
995
  if (type === "led")
900
- return new _Led__WEBPACK_IMPORTED_MODULE_9__["default"](props);
996
+ return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
901
997
  return null;
902
998
  }
903
999
  setState(newState) {
@@ -1964,6 +2060,102 @@ class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
1964
2060
  }
1965
2061
 
1966
2062
 
2063
+ /***/ }),
2064
+
2065
+ /***/ "./src/components/Soundfile.ts":
2066
+ /*!*************************************!*\
2067
+ !*** ./src/components/Soundfile.ts ***!
2068
+ \*************************************/
2069
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2070
+
2071
+ __webpack_require__.r(__webpack_exports__);
2072
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2073
+ /* harmony export */ "default": () => (/* binding */ Soundfile)
2074
+ /* harmony export */ });
2075
+ /* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts");
2076
+ /* harmony import */ var _Soundfile_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Soundfile.scss */ "./src/components/Soundfile.scss");
2077
+ var __defProp = Object.defineProperty;
2078
+ var __defProps = Object.defineProperties;
2079
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2080
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2081
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2082
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2083
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2084
+ var __spreadValues = (a, b) => {
2085
+ for (var prop in b || (b = {}))
2086
+ if (__hasOwnProp.call(b, prop))
2087
+ __defNormalProp(a, prop, b[prop]);
2088
+ if (__getOwnPropSymbols)
2089
+ for (var prop of __getOwnPropSymbols(b)) {
2090
+ if (__propIsEnum.call(b, prop))
2091
+ __defNormalProp(a, prop, b[prop]);
2092
+ }
2093
+ return a;
2094
+ };
2095
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2096
+
2097
+
2098
+ class Soundfile extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2099
+ constructor() {
2100
+ super(...arguments);
2101
+ this.className = "soundfile";
2102
+ this.setStyle = () => {
2103
+ const { value, style } = this.state;
2104
+ const { height, grid, fontsize, fontname, fontface, textcolor, textoncolor, bgoncolor, bgcolor, bordercolor, borderoncolor } = style;
2105
+ this.btn.style.backgroundColor = value ? bgoncolor : bgcolor;
2106
+ this.btn.style.borderColor = value ? borderoncolor : bordercolor;
2107
+ this.btn.style.color = value ? textoncolor : textcolor;
2108
+ this.btn.style.fontSize = `${fontsize || height * grid / 4}px`;
2109
+ this.btn.style.fontFamily = `${fontname}, sans-serif`;
2110
+ this.btn.style.fontStyle = fontface;
2111
+ };
2112
+ this.handlePointerDown = () => {
2113
+ };
2114
+ this.handlePointerUp = () => {
2115
+ };
2116
+ }
2117
+ static get defaultProps() {
2118
+ const inherited = super.defaultProps;
2119
+ return __spreadProps(__spreadValues({}, inherited), {
2120
+ style: __spreadProps(__spreadValues({}, inherited.style), {
2121
+ fontname: "Arial",
2122
+ fontsize: void 0,
2123
+ fontface: "normal",
2124
+ bgcolor: "rgba(40, 40, 40, 1)",
2125
+ bgoncolor: "rgba(18, 18, 18, 1)",
2126
+ bordercolor: "rgba(80, 80, 80, 1)",
2127
+ borderoncolor: "rgba(255, 165, 0, 1)",
2128
+ textcolor: "rgba(226, 222, 255, 0.5)",
2129
+ textoncolor: "rgba(255, 165, 0, 1)"
2130
+ })
2131
+ });
2132
+ }
2133
+ componentWillMount() {
2134
+ super.componentWillMount();
2135
+ this.btn = document.createElement("div");
2136
+ this.span = document.createElement("span");
2137
+ this.span.innerText = this.state.label;
2138
+ this.setStyle();
2139
+ return this;
2140
+ }
2141
+ mount() {
2142
+ this.btn.appendChild(this.span);
2143
+ this.container.appendChild(this.btn);
2144
+ return super.mount();
2145
+ }
2146
+ componentDidMount() {
2147
+ super.componentDidMount();
2148
+ this.btn.addEventListener("mousedown", this.handleMouseDown);
2149
+ this.btn.addEventListener("touchstart", this.handleTouchStart);
2150
+ this.on("style", () => this.schedule(this.setStyle));
2151
+ const labelChange = () => this.span.innerText = this.state.label;
2152
+ this.on("label", () => this.schedule(labelChange));
2153
+ this.on("value", () => this.schedule(this.setStyle));
2154
+ return this;
2155
+ }
2156
+ }
2157
+
2158
+
1967
2159
  /***/ }),
1968
2160
 
1969
2161
  /***/ "./src/components/VBargraph.ts":
@@ -2533,6 +2725,9 @@ const _AbstractGroup = class {
2533
2725
  sizing
2534
2726
  };
2535
2727
  }
2728
+ /**
2729
+ * find recursively if the group has horizontal-sizable item
2730
+ */
2536
2731
  get hasHSizingDesc() {
2537
2732
  return !!this.items.find((item) => {
2538
2733
  if (item instanceof _AbstractGroup)
@@ -2540,6 +2735,9 @@ const _AbstractGroup = class {
2540
2735
  return item.layout.sizing === "horizontal" || item.layout.sizing === "both";
2541
2736
  });
2542
2737
  }
2738
+ /**
2739
+ * find recursively if the group has vertical-sizable item
2740
+ */
2543
2741
  get hasVSizingDesc() {
2544
2742
  return !!this.items.find((item) => {
2545
2743
  if (item instanceof _AbstractGroup)
@@ -2851,18 +3049,20 @@ __webpack_require__.r(__webpack_exports__);
2851
3049
  /* harmony import */ var _HSlider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HSlider */ "./src/layout/HSlider.ts");
2852
3050
  /* harmony import */ var _VSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./VSlider */ "./src/layout/VSlider.ts");
2853
3051
  /* harmony import */ var _Nentry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Nentry */ "./src/layout/Nentry.ts");
2854
- /* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Button */ "./src/layout/Button.ts");
2855
- /* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Checkbox */ "./src/layout/Checkbox.ts");
2856
- /* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Knob */ "./src/layout/Knob.ts");
2857
- /* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Menu */ "./src/layout/Menu.ts");
2858
- /* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Radio */ "./src/layout/Radio.ts");
2859
- /* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Led */ "./src/layout/Led.ts");
2860
- /* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Numerical */ "./src/layout/Numerical.ts");
2861
- /* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HBargraph */ "./src/layout/HBargraph.ts");
2862
- /* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./VBargraph */ "./src/layout/VBargraph.ts");
2863
- /* harmony import */ var _HGroup__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./HGroup */ "./src/layout/HGroup.ts");
2864
- /* harmony import */ var _VGroup__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./VGroup */ "./src/layout/VGroup.ts");
2865
- /* harmony import */ var _TGroup__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./TGroup */ "./src/layout/TGroup.ts");
3052
+ /* harmony import */ var _Soundfile__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Soundfile */ "./src/layout/Soundfile.ts");
3053
+ /* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Button */ "./src/layout/Button.ts");
3054
+ /* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Checkbox */ "./src/layout/Checkbox.ts");
3055
+ /* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Knob */ "./src/layout/Knob.ts");
3056
+ /* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Menu */ "./src/layout/Menu.ts");
3057
+ /* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Radio */ "./src/layout/Radio.ts");
3058
+ /* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Led */ "./src/layout/Led.ts");
3059
+ /* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Numerical */ "./src/layout/Numerical.ts");
3060
+ /* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./HBargraph */ "./src/layout/HBargraph.ts");
3061
+ /* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./VBargraph */ "./src/layout/VBargraph.ts");
3062
+ /* harmony import */ var _HGroup__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./HGroup */ "./src/layout/HGroup.ts");
3063
+ /* harmony import */ var _VGroup__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./VGroup */ "./src/layout/VGroup.ts");
3064
+ /* harmony import */ var _TGroup__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./TGroup */ "./src/layout/TGroup.ts");
3065
+
2866
3066
 
2867
3067
 
2868
3068
 
@@ -2879,8 +3079,11 @@ __webpack_require__.r(__webpack_exports__);
2879
3079
 
2880
3080
 
2881
3081
  class Layout {
3082
+ /**
3083
+ * Get the rendering type of an item by parsing its metadata
3084
+ */
2882
3085
  static predictType(item) {
2883
- if (item.type === "vgroup" || item.type === "hgroup" || item.type === "tgroup" || item.type === "button" || item.type === "checkbox")
3086
+ if (item.type === "vgroup" || item.type === "hgroup" || item.type === "tgroup" || item.type === "button" || item.type === "checkbox" || item.type === "soundfile")
2884
3087
  return item.type;
2885
3088
  if (item.type === "hbargraph" || item.type === "vbargraph") {
2886
3089
  if (item.meta && item.meta.find((meta) => meta.style && meta.style.startsWith("led")))
@@ -2899,23 +3102,27 @@ class Layout {
2899
3102
  }
2900
3103
  return item.type;
2901
3104
  }
3105
+ /**
3106
+ * Get the Layout class constructor of an item
3107
+ */
2902
3108
  static getItem(item) {
2903
3109
  const Ctor = {
2904
3110
  hslider: _HSlider__WEBPACK_IMPORTED_MODULE_0__["default"],
2905
3111
  vslider: _VSlider__WEBPACK_IMPORTED_MODULE_1__["default"],
2906
3112
  nentry: _Nentry__WEBPACK_IMPORTED_MODULE_2__["default"],
2907
- button: _Button__WEBPACK_IMPORTED_MODULE_3__["default"],
2908
- checkbox: _Checkbox__WEBPACK_IMPORTED_MODULE_4__["default"],
2909
- knob: _Knob__WEBPACK_IMPORTED_MODULE_5__["default"],
2910
- menu: _Menu__WEBPACK_IMPORTED_MODULE_6__["default"],
2911
- radio: _Radio__WEBPACK_IMPORTED_MODULE_7__["default"],
2912
- led: _Led__WEBPACK_IMPORTED_MODULE_8__["default"],
2913
- numerical: _Numerical__WEBPACK_IMPORTED_MODULE_9__["default"],
2914
- hbargraph: _HBargraph__WEBPACK_IMPORTED_MODULE_10__["default"],
2915
- vbargraph: _VBargraph__WEBPACK_IMPORTED_MODULE_11__["default"],
2916
- hgroup: _HGroup__WEBPACK_IMPORTED_MODULE_12__["default"],
2917
- vgroup: _VGroup__WEBPACK_IMPORTED_MODULE_13__["default"],
2918
- tgroup: _TGroup__WEBPACK_IMPORTED_MODULE_14__["default"]
3113
+ soundfile: _Soundfile__WEBPACK_IMPORTED_MODULE_3__["default"],
3114
+ button: _Button__WEBPACK_IMPORTED_MODULE_4__["default"],
3115
+ checkbox: _Checkbox__WEBPACK_IMPORTED_MODULE_5__["default"],
3116
+ knob: _Knob__WEBPACK_IMPORTED_MODULE_6__["default"],
3117
+ menu: _Menu__WEBPACK_IMPORTED_MODULE_7__["default"],
3118
+ radio: _Radio__WEBPACK_IMPORTED_MODULE_8__["default"],
3119
+ led: _Led__WEBPACK_IMPORTED_MODULE_9__["default"],
3120
+ numerical: _Numerical__WEBPACK_IMPORTED_MODULE_10__["default"],
3121
+ hbargraph: _HBargraph__WEBPACK_IMPORTED_MODULE_11__["default"],
3122
+ vbargraph: _VBargraph__WEBPACK_IMPORTED_MODULE_12__["default"],
3123
+ hgroup: _HGroup__WEBPACK_IMPORTED_MODULE_13__["default"],
3124
+ vgroup: _VGroup__WEBPACK_IMPORTED_MODULE_14__["default"],
3125
+ tgroup: _TGroup__WEBPACK_IMPORTED_MODULE_15__["default"]
2919
3126
  };
2920
3127
  const layoutType = this.predictType(item);
2921
3128
  return new Ctor[layoutType](item);
@@ -2928,7 +3135,7 @@ class Layout {
2928
3135
  });
2929
3136
  }
2930
3137
  static calc(ui) {
2931
- const rootGroup = new _VGroup__WEBPACK_IMPORTED_MODULE_13__["default"]({ items: this.getItems(ui), type: "vgroup", label: "" }, true);
3138
+ const rootGroup = new _VGroup__WEBPACK_IMPORTED_MODULE_14__["default"]({ items: this.getItems(ui), type: "vgroup", label: "" }, true);
2932
3139
  rootGroup.adjust();
2933
3140
  rootGroup.expand(0, 0);
2934
3141
  rootGroup.offset();
@@ -3066,12 +3273,40 @@ class Radio extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
3066
3273
  type: "radio",
3067
3274
  width: 2,
3068
3275
  height: 2,
3276
+ // TODO: vradio and hradio
3069
3277
  sizing: "both"
3070
3278
  };
3071
3279
  }
3072
3280
  }
3073
3281
 
3074
3282
 
3283
+ /***/ }),
3284
+
3285
+ /***/ "./src/layout/Soundfile.ts":
3286
+ /*!*********************************!*\
3287
+ !*** ./src/layout/Soundfile.ts ***!
3288
+ \*********************************/
3289
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3290
+
3291
+ __webpack_require__.r(__webpack_exports__);
3292
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3293
+ /* harmony export */ "default": () => (/* binding */ Soundfile)
3294
+ /* harmony export */ });
3295
+ /* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts");
3296
+
3297
+ class Soundfile extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
3298
+ constructor() {
3299
+ super(...arguments);
3300
+ this.layout = {
3301
+ type: "soundfile",
3302
+ width: 2,
3303
+ height: 1,
3304
+ sizing: "horizontal"
3305
+ };
3306
+ }
3307
+ }
3308
+
3309
+
3075
3310
  /***/ }),
3076
3311
 
3077
3312
  /***/ "./src/layout/TGroup.ts":
@@ -3399,6 +3634,18 @@ __webpack_require__.r(__webpack_exports__);
3399
3634
  // extracted by mini-css-extract-plugin
3400
3635
 
3401
3636
 
3637
+ /***/ }),
3638
+
3639
+ /***/ "./src/components/Soundfile.scss":
3640
+ /*!***************************************!*\
3641
+ !*** ./src/components/Soundfile.scss ***!
3642
+ \***************************************/
3643
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3644
+
3645
+ __webpack_require__.r(__webpack_exports__);
3646
+ // extracted by mini-css-extract-plugin
3647
+
3648
+
3402
3649
  /***/ }),
3403
3650
 
3404
3651
  /***/ "./src/components/VBargraph.scss":