@grame/faust-web-component 0.3.4 → 0.3.5

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.
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  (function() {
8
5
  "use strict";
9
6
  function ownKeys(object, enumerableOnly) {
@@ -45,14 +42,12 @@ var __publicField = (obj, key, value) => {
45
42
  var descriptor = props[i2];
46
43
  descriptor.enumerable = descriptor.enumerable || false;
47
44
  descriptor.configurable = true;
48
- if ("value" in descriptor)
49
- descriptor.writable = true;
45
+ if ("value" in descriptor) descriptor.writable = true;
50
46
  Object.defineProperty(target, descriptor.key, descriptor);
51
47
  }
52
48
  }
53
49
  function _createClass(Constructor, protoProps, staticProps) {
54
- if (protoProps)
55
- _defineProperties(Constructor.prototype, protoProps);
50
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
56
51
  Object.defineProperty(Constructor, "prototype", {
57
52
  writable: false
58
53
  });
@@ -78,21 +73,17 @@ var __publicField = (obj, key, value) => {
78
73
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
79
74
  }
80
75
  function _arrayWithoutHoles(arr) {
81
- if (Array.isArray(arr))
82
- return _arrayLikeToArray(arr);
76
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
83
77
  }
84
78
  function _arrayWithHoles(arr) {
85
- if (Array.isArray(arr))
86
- return arr;
79
+ if (Array.isArray(arr)) return arr;
87
80
  }
88
81
  function _iterableToArray(iter) {
89
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
90
- return Array.from(iter);
82
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
91
83
  }
92
84
  function _iterableToArrayLimit(arr, i2) {
93
85
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
94
- if (_i == null)
95
- return;
86
+ if (_i == null) return;
96
87
  var _arr = [];
97
88
  var _n = true;
98
89
  var _d = false;
@@ -100,41 +91,31 @@ var __publicField = (obj, key, value) => {
100
91
  try {
101
92
  for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
102
93
  _arr.push(_s.value);
103
- if (i2 && _arr.length === i2)
104
- break;
94
+ if (i2 && _arr.length === i2) break;
105
95
  }
106
96
  } catch (err) {
107
97
  _d = true;
108
98
  _e = err;
109
99
  } finally {
110
100
  try {
111
- if (!_n && _i["return"] != null)
112
- _i["return"]();
101
+ if (!_n && _i["return"] != null) _i["return"]();
113
102
  } finally {
114
- if (_d)
115
- throw _e;
103
+ if (_d) throw _e;
116
104
  }
117
105
  }
118
106
  return _arr;
119
107
  }
120
108
  function _unsupportedIterableToArray(o, minLen) {
121
- if (!o)
122
- return;
123
- if (typeof o === "string")
124
- return _arrayLikeToArray(o, minLen);
109
+ if (!o) return;
110
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
125
111
  var n = Object.prototype.toString.call(o).slice(8, -1);
126
- if (n === "Object" && o.constructor)
127
- n = o.constructor.name;
128
- if (n === "Map" || n === "Set")
129
- return Array.from(o);
130
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
131
- return _arrayLikeToArray(o, minLen);
112
+ if (n === "Object" && o.constructor) n = o.constructor.name;
113
+ if (n === "Map" || n === "Set") return Array.from(o);
114
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
132
115
  }
133
116
  function _arrayLikeToArray(arr, len) {
134
- if (len == null || len > arr.length)
135
- len = arr.length;
136
- for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++)
137
- arr2[i2] = arr[i2];
117
+ if (len == null || len > arr.length) len = arr.length;
118
+ for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) arr2[i2] = arr[i2];
138
119
  return arr2;
139
120
  }
140
121
  function _nonIterableSpread() {
@@ -153,14 +134,10 @@ var __publicField = (obj, key, value) => {
153
134
  measure: noop
154
135
  };
155
136
  try {
156
- if (typeof window !== "undefined")
157
- _WINDOW = window;
158
- if (typeof document !== "undefined")
159
- _DOCUMENT = document;
160
- if (typeof MutationObserver !== "undefined")
161
- _MUTATION_OBSERVER = MutationObserver;
162
- if (typeof performance !== "undefined")
163
- _PERFORMANCE = performance;
137
+ if (typeof window !== "undefined") _WINDOW = window;
138
+ if (typeof document !== "undefined") _DOCUMENT = document;
139
+ if (typeof MutationObserver !== "undefined") _MUTATION_OBSERVER = MutationObserver;
140
+ if (typeof performance !== "undefined") _PERFORMANCE = performance;
164
141
  } catch (e) {
165
142
  }
166
143
  var _ref = _WINDOW.navigator || {}, _ref$userAgent = _ref.userAgent, userAgent = _ref$userAgent === void 0 ? "" : _ref$userAgent;
@@ -312,12 +289,9 @@ var __publicField = (obj, key, value) => {
312
289
  }
313
290
  }
314
291
  function coerce(val) {
315
- if (val === "")
316
- return true;
317
- if (val === "false")
318
- return false;
319
- if (val === "true")
320
- return true;
292
+ if (val === "") return true;
293
+ if (val === "false") return false;
294
+ if (val === "true") return true;
321
295
  return val;
322
296
  }
323
297
  if (DOCUMENT && typeof DOCUMENT.querySelector === "function") {
@@ -349,8 +323,7 @@ var __publicField = (obj, key, value) => {
349
323
  initial.cssPrefix = initial.familyPrefix;
350
324
  }
351
325
  var _config = _objectSpread2(_objectSpread2({}, _default), initial);
352
- if (!_config.autoReplaceSvg)
353
- _config.observeMutations = false;
326
+ if (!_config.autoReplaceSvg) _config.observeMutations = false;
354
327
  var config$1 = {};
355
328
  Object.keys(_default).forEach(function(key) {
356
329
  Object.defineProperty(config$1, key, {
@@ -532,14 +505,10 @@ var __publicField = (obj, key, value) => {
532
505
  }
533
506
  };
534
507
  var w = WINDOW || {};
535
- if (!w[NAMESPACE_IDENTIFIER])
536
- w[NAMESPACE_IDENTIFIER] = {};
537
- if (!w[NAMESPACE_IDENTIFIER].styles)
538
- w[NAMESPACE_IDENTIFIER].styles = {};
539
- if (!w[NAMESPACE_IDENTIFIER].hooks)
540
- w[NAMESPACE_IDENTIFIER].hooks = {};
541
- if (!w[NAMESPACE_IDENTIFIER].shims)
542
- w[NAMESPACE_IDENTIFIER].shims = [];
508
+ if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
509
+ if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
510
+ if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
511
+ if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
543
512
  var namespace = w[NAMESPACE_IDENTIFIER];
544
513
  var functions = [];
545
514
  var listener = function listener2() {
@@ -552,12 +521,10 @@ var __publicField = (obj, key, value) => {
552
521
  var loaded = false;
553
522
  if (IS_DOM) {
554
523
  loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
555
- if (!loaded)
556
- DOCUMENT.addEventListener("DOMContentLoaded", listener);
524
+ if (!loaded) DOCUMENT.addEventListener("DOMContentLoaded", listener);
557
525
  }
558
526
  function domready(fn) {
559
- if (!IS_DOM)
560
- return;
527
+ if (!IS_DOM) return;
561
528
  loaded ? setTimeout(fn, 0) : functions.push(fn);
562
529
  }
563
530
  function toHtml(abstractNodes) {
@@ -878,8 +845,7 @@ var __publicField = (obj, key, value) => {
878
845
  _this.definitions[key] = _objectSpread2(_objectSpread2({}, _this.definitions[key] || {}), additions[key]);
879
846
  defineIcons(key, additions[key]);
880
847
  var longPrefix = PREFIX_TO_LONG_STYLE[FAMILY_CLASSIC][key];
881
- if (longPrefix)
882
- defineIcons(longPrefix, additions[key]);
848
+ if (longPrefix) defineIcons(longPrefix, additions[key]);
883
849
  build();
884
850
  });
885
851
  }
@@ -897,8 +863,7 @@ var __publicField = (obj, key, value) => {
897
863
  Object.keys(normalized).map(function(key) {
898
864
  var _normalized$key = normalized[key], prefix = _normalized$key.prefix, iconName = _normalized$key.iconName, icon2 = _normalized$key.icon;
899
865
  var aliases = icon2[2];
900
- if (!additions[prefix])
901
- additions[prefix] = {};
866
+ if (!additions[prefix]) additions[prefix] = {};
902
867
  if (aliases.length > 0) {
903
868
  aliases.forEach(function(alias) {
904
869
  if (typeof alias === "string") {
@@ -987,8 +952,7 @@ var __publicField = (obj, key, value) => {
987
952
  }
988
953
  var iconName = iconLookup.iconName;
989
954
  var prefix = iconLookup.prefix || getDefaultUsablePrefix();
990
- if (!iconName)
991
- return;
955
+ if (!iconName) return;
992
956
  iconName = byAlias(prefix, iconName) || iconName;
993
957
  return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
994
958
  }
@@ -1073,10 +1037,9 @@ var __publicField = (obj, key, value) => {
1073
1037
  var autoReplace = function autoReplace2() {
1074
1038
  var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1075
1039
  var _params$autoReplaceSv = params.autoReplaceSvgRoot, autoReplaceSvgRoot = _params$autoReplaceSv === void 0 ? DOCUMENT : _params$autoReplaceSv;
1076
- if ((Object.keys(namespace.styles).length > 0 || config$1.autoFetchSvg) && IS_DOM && config$1.autoReplaceSvg)
1077
- api.dom.i2svg({
1078
- node: autoReplaceSvgRoot
1079
- });
1040
+ if ((Object.keys(namespace.styles).length > 0 || config$1.autoFetchSvg) && IS_DOM && config$1.autoReplaceSvg) api.dom.i2svg({
1041
+ node: autoReplaceSvgRoot
1042
+ });
1080
1043
  };
1081
1044
  function domVariants(val, abstractCreator) {
1082
1045
  Object.defineProperty(val, "abstract", {
@@ -1091,8 +1054,7 @@ var __publicField = (obj, key, value) => {
1091
1054
  });
1092
1055
  Object.defineProperty(val, "node", {
1093
1056
  get: function get() {
1094
- if (!IS_DOM)
1095
- return;
1057
+ if (!IS_DOM) return;
1096
1058
  var container = DOCUMENT.createElement("div");
1097
1059
  container.innerHTML = val.html;
1098
1060
  return container.children;
@@ -1504,8 +1466,7 @@ var __publicField = (obj, key, value) => {
1504
1466
  }
1505
1467
  var _options$treeCallback = options.treeCallback, treeCallback = _options$treeCallback === void 0 ? noop$2 : _options$treeCallback, _options$nodeCallback = options.nodeCallback, nodeCallback = _options$nodeCallback === void 0 ? noop$2 : _options$nodeCallback, _options$pseudoElemen = options.pseudoElementsCallback, pseudoElementsCallback = _options$pseudoElemen === void 0 ? noop$2 : _options$pseudoElemen, _options$observeMutat = options.observeMutationsRoot, observeMutationsRoot = _options$observeMutat === void 0 ? DOCUMENT : _options$observeMutat;
1506
1468
  mo = new MUTATION_OBSERVER(function(objects) {
1507
- if (disabled)
1508
- return;
1469
+ if (disabled) return;
1509
1470
  var defaultPrefix = getDefaultUsablePrefix();
1510
1471
  toArray(objects).forEach(function(mutationRecord) {
1511
1472
  if (mutationRecord.type === "childList" && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
@@ -1521,16 +1482,14 @@ var __publicField = (obj, key, value) => {
1521
1482
  if (mutationRecord.attributeName === "class" && hasPrefixAndIcon(mutationRecord.target)) {
1522
1483
  var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)), prefix = _getCanonicalIcon.prefix, iconName = _getCanonicalIcon.iconName;
1523
1484
  mutationRecord.target.setAttribute(DATA_PREFIX, prefix || defaultPrefix);
1524
- if (iconName)
1525
- mutationRecord.target.setAttribute(DATA_ICON, iconName);
1485
+ if (iconName) mutationRecord.target.setAttribute(DATA_ICON, iconName);
1526
1486
  } else if (hasBeenReplaced(mutationRecord.target)) {
1527
1487
  nodeCallback(mutationRecord.target);
1528
1488
  }
1529
1489
  }
1530
1490
  });
1531
1491
  });
1532
- if (!IS_DOM)
1533
- return;
1492
+ if (!IS_DOM) return;
1534
1493
  mo.observe(observeMutationsRoot, {
1535
1494
  childList: true,
1536
1495
  attributes: true,
@@ -1539,8 +1498,7 @@ var __publicField = (obj, key, value) => {
1539
1498
  });
1540
1499
  }
1541
1500
  function disconnect() {
1542
- if (!mo)
1543
- return;
1501
+ if (!mo) return;
1544
1502
  mo.disconnect();
1545
1503
  }
1546
1504
  function styleParser(node) {
@@ -1670,8 +1628,7 @@ var __publicField = (obj, key, value) => {
1670
1628
  knownPrefixes = _toConsumableArray(knownPrefixes);
1671
1629
  function onTree(root) {
1672
1630
  var callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
1673
- if (!IS_DOM)
1674
- return Promise.resolve();
1631
+ if (!IS_DOM) return Promise.resolve();
1675
1632
  var htmlClassList = DOCUMENT.documentElement.classList;
1676
1633
  var hclAdd = function hclAdd2(suffix) {
1677
1634
  return htmlClassList.add("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
@@ -1724,8 +1681,7 @@ var __publicField = (obj, key, value) => {
1724
1681
  hclAdd("active");
1725
1682
  hclAdd("complete");
1726
1683
  hclRemove("pending");
1727
- if (typeof callback === "function")
1728
- callback();
1684
+ if (typeof callback === "function") callback();
1729
1685
  mark();
1730
1686
  resolve();
1731
1687
  });
@@ -1759,8 +1715,7 @@ var __publicField = (obj, key, value) => {
1759
1715
  var render = function render2(iconDefinition) {
1760
1716
  var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1761
1717
  var _params$transform = params.transform, transform = _params$transform === void 0 ? meaninglessTransform : _params$transform, _params$symbol = params.symbol, symbol = _params$symbol === void 0 ? false : _params$symbol, _params$mask = params.mask, mask = _params$mask === void 0 ? null : _params$mask, _params$maskId = params.maskId, maskId = _params$maskId === void 0 ? null : _params$maskId, _params$title = params.title, title = _params$title === void 0 ? null : _params$title, _params$titleId = params.titleId, titleId = _params$titleId === void 0 ? null : _params$titleId, _params$classes = params.classes, classes = _params$classes === void 0 ? [] : _params$classes, _params$attributes = params.attributes, attributes = _params$attributes === void 0 ? {} : _params$attributes, _params$styles = params.styles, styles2 = _params$styles === void 0 ? {} : _params$styles;
1762
- if (!iconDefinition)
1763
- return;
1718
+ if (!iconDefinition) return;
1764
1719
  var prefix = iconDefinition.prefix, iconName = iconDefinition.iconName, icon2 = iconDefinition.icon;
1765
1720
  return domVariants(_objectSpread2({
1766
1721
  type: "icon"
@@ -2077,8 +2032,7 @@ var __publicField = (obj, key, value) => {
2077
2032
  return node.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(node.tagName.toUpperCase()) && !node.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!node.parentNode || node.parentNode.tagName !== "svg");
2078
2033
  }
2079
2034
  function searchPseudoElements(root) {
2080
- if (!IS_DOM)
2081
- return;
2035
+ if (!IS_DOM) return;
2082
2036
  return new Promise(function(resolve, reject) {
2083
2037
  var operations = toArray(root.querySelectorAll("*")).filter(processable).map(replace);
2084
2038
  var end2 = perf.begin("searchPseudoElements");
@@ -3544,6 +3498,25 @@ var __publicField = (obj, key, value) => {
3544
3498
  /*! ./index.scss */
3545
3499
  "./src/index.scss"
3546
3500
  );
3501
+ var __defProp2 = Object.defineProperty;
3502
+ var __defProps = Object.defineProperties;
3503
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3504
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3505
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3506
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
3507
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3508
+ var __spreadValues = (a, b) => {
3509
+ for (var prop in b || (b = {}))
3510
+ if (__hasOwnProp.call(b, prop))
3511
+ __defNormalProp2(a, prop, b[prop]);
3512
+ if (__getOwnPropSymbols)
3513
+ for (var prop of __getOwnPropSymbols(b)) {
3514
+ if (__propIsEnum.call(b, prop))
3515
+ __defNormalProp2(a, prop, b[prop]);
3516
+ }
3517
+ return a;
3518
+ };
3519
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3547
3520
  class FaustUI {
3548
3521
  /**
3549
3522
  * Calculate incoming UI's layout, bind window events
@@ -3551,8 +3524,7 @@ var __publicField = (obj, key, value) => {
3551
3524
  constructor(options) {
3552
3525
  this.componentMap = {};
3553
3526
  this.paramChangeByUI = (path, value) => {
3554
- if (!this.hostWindow)
3555
- return;
3527
+ if (!this.hostWindow) return;
3556
3528
  this.hostWindow.postMessage({ path, value, type: "param" }, "*");
3557
3529
  };
3558
3530
  const { root, ui: uiIn, listenWindowResize, listenWindowMessage } = options;
@@ -3568,8 +3540,7 @@ var __publicField = (obj, key, value) => {
3568
3540
  const { data, source } = e;
3569
3541
  this.hostWindow = source;
3570
3542
  const { type } = data;
3571
- if (!type)
3572
- return;
3543
+ if (!type) return;
3573
3544
  if (type === "ui") {
3574
3545
  this.ui = data.ui;
3575
3546
  } else if (type === "param") {
@@ -3609,17 +3580,14 @@ var __publicField = (obj, key, value) => {
3609
3580
  * This method should be called by components to register itself to map.
3610
3581
  */
3611
3582
  register(path, item) {
3612
- if (this.componentMap[path])
3613
- this.componentMap[path].push(item);
3614
- else
3615
- this.componentMap[path] = [item];
3583
+ if (this.componentMap[path]) this.componentMap[path].push(item);
3584
+ else this.componentMap[path] = [item];
3616
3585
  }
3617
3586
  /**
3618
3587
  * Notify the component to change its value.
3619
3588
  */
3620
3589
  paramChangeByDSP(path, value) {
3621
- if (this.componentMap[path])
3622
- this.componentMap[path].forEach((item) => item.setState({ value }));
3590
+ if (this.componentMap[path]) this.componentMap[path].forEach((item) => item.setState({ value }));
3623
3591
  }
3624
3592
  /**
3625
3593
  * Calculate UI layout in grid then calculate grid size.
@@ -3643,16 +3611,30 @@ var __publicField = (obj, key, value) => {
3643
3611
  * Force recalculate grid size and resize UI
3644
3612
  */
3645
3613
  resize() {
3646
- if (!this.faustUIRoot)
3647
- return;
3614
+ if (!this.faustUIRoot) return;
3648
3615
  this.calcGrid();
3649
3616
  this.faustUIRoot.setState({ style: { grid: this.grid } });
3650
3617
  }
3618
+ /** Filter out items with `hidden` metadata and `soundfile` items */
3619
+ filter(ui) {
3620
+ const callback = (items, item) => {
3621
+ var _a2;
3622
+ if (item.type === "soundfile") return items;
3623
+ if (item.type === "hgroup" || item.type === "vgroup" || item.type === "tgroup") {
3624
+ items.push(__spreadProps(__spreadValues({}, item), { items: item.items.reduce(callback, []) }));
3625
+ return items;
3626
+ }
3627
+ if ((_a2 = item.meta) == null ? void 0 : _a2.find((m) => m.hidden && m.hidden === "1")) return items;
3628
+ items.push(item);
3629
+ return items;
3630
+ };
3631
+ return ui.reduce(callback, []);
3632
+ }
3651
3633
  get ui() {
3652
3634
  return this._ui;
3653
3635
  }
3654
3636
  set ui(uiIn) {
3655
- this._ui = uiIn;
3637
+ this._ui = this.filter(uiIn);
3656
3638
  this.calc();
3657
3639
  this.mount();
3658
3640
  }
@@ -3738,10 +3720,8 @@ var __publicField = (obj, key, value) => {
3738
3720
  if (stateKey in this.state && this.state[stateKey] !== stateValue) {
3739
3721
  this.state[stateKey] = stateValue;
3740
3722
  shouldUpdate = true;
3741
- } else
3742
- return;
3743
- if (shouldUpdate)
3744
- this.emit(stateKey, this.state[stateKey]);
3723
+ } else return;
3724
+ if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
3745
3725
  }
3746
3726
  }
3747
3727
  /**
@@ -3749,10 +3729,8 @@ var __publicField = (obj, key, value) => {
3749
3729
  * schedule what you need to do in next render tick in `raf` callback
3750
3730
  */
3751
3731
  schedule(func) {
3752
- if (this.tasks.indexOf(func) === -1)
3753
- this.tasks.push(func);
3754
- if (this.$raf)
3755
- return;
3732
+ if (this.tasks.indexOf(func) === -1) this.tasks.push(func);
3733
+ if (this.$raf) return;
3756
3734
  this.$raf = window.requestAnimationFrame(this.raf);
3757
3735
  }
3758
3736
  }
@@ -3803,7 +3781,7 @@ var __publicField = (obj, key, value) => {
3803
3781
  }
3804
3782
  return a;
3805
3783
  };
3806
- const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
3784
+ const _AbstractItem = class _AbstractItem2 extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
3807
3785
  /**
3808
3786
  * Initiate default state with incoming state.
3809
3787
  */
@@ -3890,19 +3868,16 @@ var __publicField = (obj, key, value) => {
3890
3868
  this.handleFocusIn = (e) => this.setState({ focus: true });
3891
3869
  this.handleFocusOut = (e) => this.setState({ focus: false });
3892
3870
  this.state.style = __spreadValues(__spreadValues({}, this.defaultProps.style), props.style);
3893
- if (this.state.emitter)
3894
- this.state.emitter.register(this.state.address, this);
3871
+ if (this.state.emitter) this.state.emitter.register(this.state.address, this);
3895
3872
  }
3896
3873
  /**
3897
3874
  * Get a nearest valid number
3898
3875
  */
3899
3876
  toValidNumber(value) {
3900
3877
  const { min, max, step } = this.state;
3901
- if (typeof min !== "number" || typeof max !== "number")
3902
- return value;
3878
+ if (typeof min !== "number" || typeof max !== "number") return value;
3903
3879
  const v = Math.min(max, Math.max(min, value));
3904
- if (!step)
3905
- return v;
3880
+ if (!step) return v;
3906
3881
  return min + Math.floor((v - min) / step) * step;
3907
3882
  }
3908
3883
  /**
@@ -3911,16 +3886,14 @@ var __publicField = (obj, key, value) => {
3911
3886
  setValue(valueIn) {
3912
3887
  const value = this.toValidNumber(valueIn);
3913
3888
  const changed = this.setState({ value });
3914
- if (changed)
3915
- this.change(value);
3889
+ if (changed) this.change(value);
3916
3890
  return changed;
3917
3891
  }
3918
3892
  /**
3919
3893
  * Send value to DSP
3920
3894
  */
3921
3895
  change(valueIn) {
3922
- if (this.state.emitter)
3923
- this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
3896
+ if (this.state.emitter) this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value);
3924
3897
  }
3925
3898
  /**
3926
3899
  * set internal state and fire events for UI parts subscribed
@@ -3942,10 +3915,8 @@ var __publicField = (obj, key, value) => {
3942
3915
  } else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
3943
3916
  this.state[stateKey] = stateValue;
3944
3917
  shouldUpdate = true;
3945
- } else
3946
- return false;
3947
- if (shouldUpdate)
3948
- this.emit(stateKey, this.state[stateKey]);
3918
+ } else return false;
3919
+ if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
3949
3920
  }
3950
3921
  return shouldUpdate;
3951
3922
  }
@@ -3958,8 +3929,7 @@ var __publicField = (obj, key, value) => {
3958
3929
  this.container.className = ["faust-ui-component", "faust-ui-component-" + this.className].join(" ");
3959
3930
  this.container.tabIndex = 1;
3960
3931
  this.container.id = this.state.address;
3961
- if (this.state.tooltip)
3962
- this.container.title = this.state.tooltip;
3932
+ if (this.state.tooltip) this.container.title = this.state.tooltip;
3963
3933
  this.label = document.createElement("div");
3964
3934
  this.label.className = "faust-ui-component-label";
3965
3935
  this.labelCanvas = document.createElement("canvas");
@@ -3980,8 +3950,7 @@ var __publicField = (obj, key, value) => {
3980
3950
  const canvas = this.labelCanvas;
3981
3951
  const ratio = window.devicePixelRatio || 1;
3982
3952
  let { width, height } = this.label.getBoundingClientRect();
3983
- if (!width || !height)
3984
- return this;
3953
+ if (!width || !height) return this;
3985
3954
  width = Math.floor(width);
3986
3955
  height = Math.floor(height);
3987
3956
  const scaledWidth = Math.floor(width * ratio);
@@ -4021,10 +3990,8 @@ var __publicField = (obj, key, value) => {
4021
3990
  const { type, max, min, step, enums } = this.state;
4022
3991
  const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
4023
3992
  if (step) {
4024
- if (type === "enum")
4025
- return enums.length;
4026
- if (type === "int")
4027
- return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
3993
+ if (type === "enum") return enums.length;
3994
+ if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);
4028
3995
  return Math.floor((max - min) / step);
4029
3996
  }
4030
3997
  return maxSteps;
@@ -4034,12 +4001,11 @@ var __publicField = (obj, key, value) => {
4034
4001
  */
4035
4002
  get distance() {
4036
4003
  const { type, max, min, value, enums, scale } = this.state;
4037
- return _AbstractItem.getDistance({ type, max, min, value, enums, scale });
4004
+ return _AbstractItem2.getDistance({ type, max, min, value, enums, scale });
4038
4005
  }
4039
4006
  static getDistance(state) {
4040
4007
  const { type, max, min, value, enums, scale } = state;
4041
- if (type === "enum")
4042
- return value / (enums.length - 1);
4008
+ if (type === "enum") return value / (enums.length - 1);
4043
4009
  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;
4044
4010
  return (0, _utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max);
4045
4011
  }
@@ -4052,8 +4018,7 @@ var __publicField = (obj, key, value) => {
4052
4018
  return full / stepsCount;
4053
4019
  }
4054
4020
  };
4055
- let AbstractItem = _AbstractItem;
4056
- AbstractItem.defaultProps = {
4021
+ _AbstractItem.defaultProps = {
4057
4022
  value: 0,
4058
4023
  active: true,
4059
4024
  focus: false,
@@ -4068,6 +4033,7 @@ var __publicField = (obj, key, value) => {
4068
4033
  step: 0.01,
4069
4034
  style: { width: 45, height: 15, left: 0, top: 0, labelcolor: "rgba(226, 222, 255, 0.5)" }
4070
4035
  };
4036
+ let AbstractItem = _AbstractItem;
4071
4037
  }
4072
4038
  ),
4073
4039
  /***/
@@ -4300,8 +4266,7 @@ var __publicField = (obj, key, value) => {
4300
4266
  this.children = [];
4301
4267
  const { style, type, items, emitter, isRoot } = this.state;
4302
4268
  const { grid, left, top: top2, width, height } = style;
4303
- if (!this.state.isRoot)
4304
- this.label.style.height = `${grid * 0.3}px`;
4269
+ if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
4305
4270
  this.container.style.left = `${left * grid}px`;
4306
4271
  this.container.style.top = `${top2 * grid}px`;
4307
4272
  this.container.style.width = `${width * grid}px`;
@@ -4310,13 +4275,11 @@ var __publicField = (obj, key, value) => {
4310
4275
  items.forEach((item) => {
4311
4276
  if (item.type.endsWith("group")) {
4312
4277
  const component = Group.getComponent(item, emitter, grid);
4313
- if (component)
4314
- this.children.push(component);
4278
+ if (component) this.children.push(component);
4315
4279
  } else {
4316
4280
  const ioItem = item;
4317
4281
  const itemComponent = Group.getComponent(ioItem, this.state.emitter, grid);
4318
- if (itemComponent)
4319
- this.children.push(itemComponent);
4282
+ if (itemComponent) this.children.push(itemComponent);
4320
4283
  }
4321
4284
  });
4322
4285
  if (type === "tgroup") {
@@ -4336,8 +4299,7 @@ var __publicField = (obj, key, value) => {
4336
4299
  const groups = [];
4337
4300
  for (let j = 0; j < this.container.children.length; j++) {
4338
4301
  const element = this.container.children[j];
4339
- if (j > 1)
4340
- groups.push(element);
4302
+ if (j > 1) groups.push(element);
4341
4303
  }
4342
4304
  for (let j = 0; j < groups.length; j++) {
4343
4305
  const element = groups[j];
@@ -4346,10 +4308,8 @@ var __publicField = (obj, key, value) => {
4346
4308
  for (let j = 0; j < this.tabs.children.length; j++) {
4347
4309
  const e = this.tabs.children[j];
4348
4310
  if (i2 !== j) {
4349
- if (e.classList.contains("active"))
4350
- e.classList.remove("active");
4351
- } else
4352
- e.classList.add("active");
4311
+ if (e.classList.contains("active")) e.classList.remove("active");
4312
+ } else e.classList.add("active");
4353
4313
  }
4354
4314
  });
4355
4315
  this.tabs.appendChild(tab);
@@ -4359,8 +4319,7 @@ var __publicField = (obj, key, value) => {
4359
4319
  }
4360
4320
  static parseMeta(metaIn) {
4361
4321
  const metaObject = {};
4362
- if (!metaIn)
4363
- return { metaObject };
4322
+ if (!metaIn) return { metaObject };
4364
4323
  metaIn.forEach((m) => Object.assign(metaObject, m));
4365
4324
  if (metaObject.style) {
4366
4325
  const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?))\}/;
@@ -4422,32 +4381,19 @@ var __publicField = (obj, key, value) => {
4422
4381
  step: "step" in item ? +item.step : 1,
4423
4382
  value: "init" in item ? +item.init || 0 : 0
4424
4383
  };
4425
- if (type === "button")
4426
- return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props);
4427
- if (type === "checkbox")
4428
- return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props);
4429
- if (type === "nentry")
4430
- return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props);
4431
- if (type === "soundfile")
4432
- return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props);
4433
- if (type === "knob")
4434
- return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props);
4435
- if (type === "menu")
4436
- return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props);
4437
- if (type === "radio")
4438
- return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
4439
- if (type === "hslider")
4440
- return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
4441
- if (type === "vslider")
4442
- return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
4443
- if (type === "hbargraph")
4444
- return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
4445
- if (type === "vbargraph")
4446
- return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
4447
- if (type === "numerical")
4448
- return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
4449
- if (type === "led")
4450
- return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
4384
+ if (type === "button") return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props);
4385
+ if (type === "checkbox") return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props);
4386
+ if (type === "nentry") return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props);
4387
+ if (type === "soundfile") return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props);
4388
+ if (type === "knob") return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props);
4389
+ if (type === "menu") return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props);
4390
+ if (type === "radio") return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props);
4391
+ if (type === "hslider") return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props);
4392
+ if (type === "vslider") return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props);
4393
+ if (type === "hbargraph") return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props);
4394
+ if (type === "vbargraph") return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props);
4395
+ if (type === "numerical") return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props);
4396
+ if (type === "led") return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props);
4451
4397
  return null;
4452
4398
  }
4453
4399
  setState(newState) {
@@ -4466,10 +4412,8 @@ var __publicField = (obj, key, value) => {
4466
4412
  } else if (stateKey in this.state && this.state[stateKey] !== stateValue) {
4467
4413
  this.state[stateKey] = stateValue;
4468
4414
  shouldUpdate = true;
4469
- } else
4470
- return;
4471
- if (shouldUpdate)
4472
- this.emit(stateKey, this.state[stateKey]);
4415
+ } else return;
4416
+ if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);
4473
4417
  }
4474
4418
  }
4475
4419
  componentWillMount() {
@@ -4487,16 +4431,14 @@ var __publicField = (obj, key, value) => {
4487
4431
  return this;
4488
4432
  }
4489
4433
  paintLabel() {
4490
- if (this.state.isRoot)
4491
- return this;
4434
+ if (this.state.isRoot) return this;
4492
4435
  const label = this.state.label;
4493
4436
  const color = this.state.style.labelcolor;
4494
4437
  const ctx = this.labelCtx;
4495
4438
  const canvas = this.labelCanvas;
4496
4439
  const ratio = window.devicePixelRatio || 1;
4497
4440
  let { width, height } = this.label.getBoundingClientRect();
4498
- if (!width || !height)
4499
- return this;
4441
+ if (!width || !height) return this;
4500
4442
  width = Math.floor(width);
4501
4443
  height = Math.floor(height);
4502
4444
  const scaledWidth = Math.floor(width * ratio);
@@ -4517,8 +4459,7 @@ var __publicField = (obj, key, value) => {
4517
4459
  this.label.appendChild(this.labelCanvas);
4518
4460
  this.container.appendChild(this.label);
4519
4461
  }
4520
- if (this.tabs.children.length)
4521
- this.container.appendChild(this.tabs);
4462
+ if (this.tabs.children.length) this.container.appendChild(this.tabs);
4522
4463
  this.children.forEach((item) => {
4523
4464
  item.mount();
4524
4465
  this.container.appendChild(item.container);
@@ -4526,10 +4467,10 @@ var __publicField = (obj, key, value) => {
4526
4467
  return this;
4527
4468
  }
4528
4469
  componentDidMount() {
4470
+ var _a2;
4529
4471
  const handleResize = () => {
4530
4472
  const { grid, left, top: top2, width, height } = this.state.style;
4531
- if (!this.state.isRoot)
4532
- this.label.style.height = `${grid * 0.3}px`;
4473
+ if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;
4533
4474
  this.container.style.width = `${width * grid}px`;
4534
4475
  this.container.style.height = `${height * grid}px`;
4535
4476
  this.container.style.left = `${left * grid}px`;
@@ -4560,8 +4501,7 @@ var __publicField = (obj, key, value) => {
4560
4501
  };
4561
4502
  this.on("label", () => this.schedule(labelChange));
4562
4503
  this.paintLabel();
4563
- if (this.tabs && this.tabs.children.length)
4564
- this.tabs.children[0].click();
4504
+ if ((_a2 = this.tabs) == null ? void 0 : _a2.children.length) this.tabs.children[0].click();
4565
4505
  this.children.forEach((item) => item.componentDidMount());
4566
4506
  return this;
4567
4507
  }
@@ -4629,8 +4569,7 @@ var __publicField = (obj, key, value) => {
4629
4569
  const paintValue = this.paintValue;
4630
4570
  if (paintValue > this.maxValue) {
4631
4571
  this.maxValue = paintValue;
4632
- if (this.maxTimer)
4633
- window.clearTimeout(this.maxTimer);
4572
+ if (this.maxTimer) window.clearTimeout(this.maxTimer);
4634
4573
  this.maxTimer = window.setTimeout(() => {
4635
4574
  this.maxValue = this.paintValue;
4636
4575
  this.maxTimer = void 0;
@@ -4650,23 +4589,15 @@ var __publicField = (obj, key, value) => {
4650
4589
  const hotStop = (-3 - min) / (max - min);
4651
4590
  const overloadStop = Math.max(0, -min / (max - min));
4652
4591
  const gradient = ctx.createLinearGradient(left, 0, drawWidth, 0);
4653
- if (coldStop <= 1 && coldStop >= 0)
4654
- gradient.addColorStop(coldStop, coldcolor);
4655
- else if (coldStop > 1)
4656
- gradient.addColorStop(1, coldcolor);
4657
- if (warmStop <= 1 && warmStop >= 0)
4658
- gradient.addColorStop(warmStop, warmcolor);
4659
- if (hotStop <= 1 && hotStop >= 0)
4660
- gradient.addColorStop(hotStop, hotcolor);
4661
- if (overloadStop <= 1 && overloadStop >= 0)
4662
- gradient.addColorStop(overloadStop, overloadcolor);
4663
- else if (overloadStop < 0)
4664
- gradient.addColorStop(0, coldcolor);
4592
+ if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
4593
+ else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
4594
+ if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
4595
+ if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
4596
+ if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
4597
+ else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
4665
4598
  ctx.fillStyle = barbgcolor;
4666
- if (paintValue < 0)
4667
- ctx.fillRect(left, top2, drawWidth * overloadStop, drawHeight);
4668
- if (paintValue < max)
4669
- ctx.fillRect(left + drawWidth * overloadStop + 1, top2, drawWidth * (1 - overloadStop) - 1, drawHeight);
4599
+ if (paintValue < 0) ctx.fillRect(left, top2, drawWidth * overloadStop, drawHeight);
4600
+ if (paintValue < max) ctx.fillRect(left + drawWidth * overloadStop + 1, top2, drawWidth * (1 - overloadStop) - 1, drawHeight);
4670
4601
  ctx.fillStyle = gradient;
4671
4602
  if (paintValue > min) {
4672
4603
  const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
@@ -4823,8 +4754,7 @@ var __publicField = (obj, key, value) => {
4823
4754
  const value = parseFloat(e.currentTarget.value);
4824
4755
  if (isFinite(value)) {
4825
4756
  const changed = this.setValue(+this.inputNumber.value);
4826
- if (changed)
4827
- return;
4757
+ if (changed) return;
4828
4758
  }
4829
4759
  this.input.value = this.inputNumber.value + (this.state.unit || "");
4830
4760
  };
@@ -4879,8 +4809,7 @@ var __publicField = (obj, key, value) => {
4879
4809
  };
4880
4810
  this.handlePointerDrag = (e) => {
4881
4811
  const newValue = this.getValueFromDelta(e);
4882
- if (newValue !== this.state.value)
4883
- this.setValue(newValue);
4812
+ if (newValue !== this.state.value) this.setValue(newValue);
4884
4813
  };
4885
4814
  }
4886
4815
  static get defaultProps() {
@@ -4973,10 +4902,8 @@ var __publicField = (obj, key, value) => {
4973
4902
  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;
4974
4903
  let steps = Math.round((0, _utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
4975
4904
  steps = Math.min(stepsCount, Math.max(0, steps));
4976
- if (type === "enum")
4977
- return steps;
4978
- if (type === "int")
4979
- return Math.round(steps * step + min);
4905
+ if (type === "enum") return steps;
4906
+ if (type === "int") return Math.round(steps * step + min);
4980
4907
  return steps * step + min;
4981
4908
  }
4982
4909
  }
@@ -5056,29 +4983,19 @@ var __publicField = (obj, key, value) => {
5056
4983
  const hotStop = (-3 - min) / (max - min);
5057
4984
  const overloadStop = -min / (max - min);
5058
4985
  const gradient = tempCtx.createLinearGradient(0, 0, tempCanvas.width, 0);
5059
- if (coldStop <= 1 && coldStop >= 0)
5060
- gradient.addColorStop(coldStop, coldcolor);
5061
- else if (coldStop > 1)
5062
- gradient.addColorStop(1, coldcolor);
5063
- if (warmStop <= 1 && warmStop >= 0)
5064
- gradient.addColorStop(warmStop, warmcolor);
5065
- if (hotStop <= 1 && hotStop >= 0)
5066
- gradient.addColorStop(hotStop, hotcolor);
5067
- if (overloadStop <= 1 && overloadStop >= 0)
5068
- gradient.addColorStop(overloadStop, overloadcolor);
5069
- else if (overloadStop < 0)
5070
- gradient.addColorStop(0, coldcolor);
4986
+ if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
4987
+ else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
4988
+ if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
4989
+ if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
4990
+ if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
4991
+ else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
5071
4992
  tempCtx.fillStyle = gradient;
5072
4993
  tempCtx.fillRect(0, 0, tempCanvas.width, 10);
5073
4994
  const d2 = tempCtx.getImageData(Math.min(tempCanvas.width - 1, distance * tempCanvas.width), 0, 1, 1).data;
5074
- if (distance)
5075
- ctx.fillStyle = `rgb(${d2[0]}, ${d2[1]}, ${d2[2]})`;
5076
- else
5077
- ctx.fillStyle = ledbgcolor;
5078
- if (shape === "circle")
5079
- ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
5080
- else
5081
- ctx.rect(left, top2, drawWidth, drawHeight);
4995
+ if (distance) ctx.fillStyle = `rgb(${d2[0]}, ${d2[1]}, ${d2[2]})`;
4996
+ else ctx.fillStyle = ledbgcolor;
4997
+ if (shape === "circle") ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);
4998
+ else ctx.rect(left, top2, drawWidth, drawHeight);
5082
4999
  ctx.fill();
5083
5000
  };
5084
5001
  }
@@ -5227,8 +5144,7 @@ var __publicField = (obj, key, value) => {
5227
5144
  const option = document.createElement("option");
5228
5145
  option.value = enums[key].toString();
5229
5146
  option.text = key;
5230
- if (i2 === 0)
5231
- option.selected = true;
5147
+ if (i2 === 0) option.selected = true;
5232
5148
  this.select.appendChild(option);
5233
5149
  i2++;
5234
5150
  }
@@ -5243,8 +5159,7 @@ var __publicField = (obj, key, value) => {
5243
5159
  const valueChange = () => {
5244
5160
  for (let i2 = this.select.children.length - 1; i2 >= 0; i2--) {
5245
5161
  const option = this.select.children[i2];
5246
- if (+option.value === this.state.value)
5247
- this.select.selectedIndex = i2;
5162
+ if (+option.value === this.state.value) this.select.selectedIndex = i2;
5248
5163
  }
5249
5164
  };
5250
5165
  this.on("value", () => this.schedule(valueChange));
@@ -5516,11 +5431,9 @@ var __publicField = (obj, key, value) => {
5516
5431
  input.value = enums[key].toString();
5517
5432
  input.name = address;
5518
5433
  input.type = "radio";
5519
- if (i2 === 0)
5520
- input.checked = true;
5434
+ if (i2 === 0) input.checked = true;
5521
5435
  input.addEventListener("change", () => {
5522
- if (input.checked)
5523
- this.setValue(enums[key]);
5436
+ if (input.checked) this.setValue(enums[key]);
5524
5437
  });
5525
5438
  div.appendChild(input);
5526
5439
  div.append(key);
@@ -5568,8 +5481,7 @@ var __publicField = (obj, key, value) => {
5568
5481
  const valueChange = () => {
5569
5482
  for (let i2 = this.group.children.length - 1; i2 >= 0; i2--) {
5570
5483
  const input = this.group.children[i2].querySelector("input");
5571
- if (+input.value === this.state.value)
5572
- input.checked = true;
5484
+ if (+input.value === this.state.value) input.checked = true;
5573
5485
  }
5574
5486
  };
5575
5487
  this.on("value", () => this.schedule(valueChange));
@@ -5767,8 +5679,7 @@ var __publicField = (obj, key, value) => {
5767
5679
  const paintValue = this.paintValue;
5768
5680
  if (paintValue > this.maxValue) {
5769
5681
  this.maxValue = paintValue;
5770
- if (this.maxTimer)
5771
- window.clearTimeout(this.maxTimer);
5682
+ if (this.maxTimer) window.clearTimeout(this.maxTimer);
5772
5683
  this.maxTimer = window.setTimeout(() => {
5773
5684
  this.maxValue = this.paintValue;
5774
5685
  this.maxTimer = void 0;
@@ -5788,23 +5699,15 @@ var __publicField = (obj, key, value) => {
5788
5699
  const hotStop = (-3 - min) / (max - min);
5789
5700
  const overloadStop = Math.max(0, -min / (max - min));
5790
5701
  const gradient = ctx.createLinearGradient(0, drawHeight, 0, top2);
5791
- if (coldStop <= 1 && coldStop >= 0)
5792
- gradient.addColorStop(coldStop, coldcolor);
5793
- else if (coldStop > 1)
5794
- gradient.addColorStop(1, coldcolor);
5795
- if (warmStop <= 1 && warmStop >= 0)
5796
- gradient.addColorStop(warmStop, warmcolor);
5797
- if (hotStop <= 1 && hotStop >= 0)
5798
- gradient.addColorStop(hotStop, hotcolor);
5799
- if (overloadStop <= 1 && overloadStop >= 0)
5800
- gradient.addColorStop(overloadStop, overloadcolor);
5801
- else if (overloadStop < 0)
5802
- gradient.addColorStop(0, coldcolor);
5702
+ if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);
5703
+ else if (coldStop > 1) gradient.addColorStop(1, coldcolor);
5704
+ if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);
5705
+ if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);
5706
+ if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);
5707
+ else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);
5803
5708
  ctx.fillStyle = barbgcolor;
5804
- if (paintValue < 0)
5805
- ctx.fillRect(left, top2 + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop);
5806
- if (paintValue < max)
5807
- ctx.fillRect(left, top2, drawWidth, (1 - overloadStop) * drawHeight - 1);
5709
+ if (paintValue < 0) ctx.fillRect(left, top2 + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop);
5710
+ if (paintValue < max) ctx.fillRect(left, top2, drawWidth, (1 - overloadStop) * drawHeight - 1);
5808
5711
  ctx.fillStyle = gradient;
5809
5712
  if (paintValue > min) {
5810
5713
  const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));
@@ -5949,8 +5852,7 @@ var __publicField = (obj, key, value) => {
5949
5852
  const value = parseFloat(e.currentTarget.value);
5950
5853
  if (isFinite(value)) {
5951
5854
  const changed = this.setValue(+value);
5952
- if (changed)
5953
- return;
5855
+ if (changed) return;
5954
5856
  }
5955
5857
  this.input.value = this.inputNumber.value + (this.state.unit || "");
5956
5858
  };
@@ -5992,16 +5894,13 @@ var __publicField = (obj, key, value) => {
5992
5894
  };
5993
5895
  this.handlePointerDown = (e) => {
5994
5896
  const { value } = this.state;
5995
- 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])
5996
- return;
5897
+ 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;
5997
5898
  const newValue = this.getValueFromPos(e);
5998
- if (newValue !== value)
5999
- this.setValue(this.getValueFromPos(e));
5899
+ if (newValue !== value) this.setValue(this.getValueFromPos(e));
6000
5900
  };
6001
5901
  this.handlePointerDrag = (e) => {
6002
5902
  const newValue = this.getValueFromPos(e);
6003
- if (newValue !== this.state.value)
6004
- this.setValue(newValue);
5903
+ if (newValue !== this.state.value) this.setValue(newValue);
6005
5904
  };
6006
5905
  }
6007
5906
  static get defaultProps() {
@@ -6092,10 +5991,8 @@ var __publicField = (obj, key, value) => {
6092
5991
  const { type, max, min, step, enums } = this.state;
6093
5992
  const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step;
6094
5993
  if (step) {
6095
- if (type === "enum")
6096
- return enums.length;
6097
- if (type === "int")
6098
- return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
5994
+ if (type === "enum") return enums.length;
5995
+ if (type === "int") return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);
6099
5996
  return Math.floor((max - min) / step);
6100
5997
  }
6101
5998
  return maxSteps;
@@ -6116,10 +6013,8 @@ var __publicField = (obj, key, value) => {
6116
6013
  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;
6117
6014
  let steps = Math.round((0, _utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange);
6118
6015
  steps = Math.min(stepsCount, Math.max(0, steps));
6119
- if (type === "enum")
6120
- return steps;
6121
- if (type === "int")
6122
- return Math.round(steps * step + min);
6016
+ if (type === "enum") return steps;
6017
+ if (type === "int") return Math.round(steps * step + min);
6123
6018
  return steps * step + min;
6124
6019
  }
6125
6020
  }
@@ -6222,10 +6117,8 @@ var __publicField = (obj, key, value) => {
6222
6117
  const iNormExp = normLog;
6223
6118
  const roundedRect = (ctx, x, y, width, height, radius) => {
6224
6119
  const radii = [0, 0, 0, 0];
6225
- if (typeof radius === "number")
6226
- radii.fill(radius);
6227
- else
6228
- radius.forEach((v, i2) => radii[i2] = v);
6120
+ if (typeof radius === "number") radii.fill(radius);
6121
+ else radius.forEach((v, i2) => radii[i2] = v);
6229
6122
  ctx.beginPath();
6230
6123
  ctx.moveTo(x + radii[0], y);
6231
6124
  ctx.lineTo(x + width - radii[1], y);
@@ -6241,10 +6134,8 @@ var __publicField = (obj, key, value) => {
6241
6134
  };
6242
6135
  const fillRoundedRect = (ctx, x, y, width, height, radius) => {
6243
6136
  const radii = [0, 0, 0, 0];
6244
- if (typeof radius === "number")
6245
- radii.fill(radius);
6246
- else
6247
- radius.forEach((v, i2) => radii[i2] = v);
6137
+ if (typeof radius === "number") radii.fill(radius);
6138
+ else radius.forEach((v, i2) => radii[i2] = v);
6248
6139
  ctx.beginPath();
6249
6140
  ctx.moveTo(x + radii[0], y);
6250
6141
  ctx.lineTo(x + width - radii[1], y);
@@ -6273,12 +6164,12 @@ var __publicField = (obj, key, value) => {
6273
6164
  "default": () => __WEBPACK_DEFAULT_EXPORT__
6274
6165
  /* harmony export */
6275
6166
  });
6276
- var _FaustUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__2(
6167
+ var _FaustUI__WEBPACK_IMPORTED_MODULE_0__2 = __webpack_require__2(
6277
6168
  /*! ./FaustUI */
6278
6169
  "./src/FaustUI.ts"
6279
6170
  );
6280
6171
  const instantiate = () => {
6281
- const faustUI = new _FaustUI__WEBPACK_IMPORTED_MODULE_0__["default"]({
6172
+ const faustUI = new _FaustUI__WEBPACK_IMPORTED_MODULE_0__2["default"]({
6282
6173
  root: document.getElementById("root"),
6283
6174
  listenWindowResize: true,
6284
6175
  listenWindowMessage: true
@@ -6289,12 +6180,10 @@ var __publicField = (obj, key, value) => {
6289
6180
  host = source;
6290
6181
  });
6291
6182
  window.addEventListener("keydown", (e) => {
6292
- if (host)
6293
- host.postMessage({ type: "keydown", key: e.key }, "*");
6183
+ if (host) host.postMessage({ type: "keydown", key: e.key }, "*");
6294
6184
  });
6295
6185
  window.addEventListener("keyup", (e) => {
6296
- if (host)
6297
- host.postMessage({ type: "keyup", key: e.key }, "*");
6186
+ if (host) host.postMessage({ type: "keyup", key: e.key }, "*");
6298
6187
  });
6299
6188
  window.faustUI = faustUI;
6300
6189
  };
@@ -6317,7 +6206,7 @@ var __publicField = (obj, key, value) => {
6317
6206
  )
6318
6207
  /* harmony export */
6319
6208
  });
6320
- const _AbstractGroup = class {
6209
+ const _AbstractGroup = class _AbstractGroup2 {
6321
6210
  constructor(group, isRoot) {
6322
6211
  this.isRoot = !!isRoot;
6323
6212
  Object.assign(this, group);
@@ -6325,8 +6214,8 @@ var __publicField = (obj, key, value) => {
6325
6214
  const sizing = hasHSizingDesc && hasVSizingDesc ? "both" : hasHSizingDesc ? "horizontal" : hasVSizingDesc ? "vertical" : "none";
6326
6215
  this.layout = {
6327
6216
  type: group.type,
6328
- width: _AbstractGroup.padding * 2,
6329
- height: _AbstractGroup.padding * 2 + (this.isRoot ? 0 : _AbstractGroup.labelHeight),
6217
+ width: _AbstractGroup2.padding * 2,
6218
+ height: _AbstractGroup2.padding * 2 + (this.isRoot ? 0 : _AbstractGroup2.labelHeight),
6330
6219
  sizing
6331
6220
  };
6332
6221
  }
@@ -6335,8 +6224,7 @@ var __publicField = (obj, key, value) => {
6335
6224
  */
6336
6225
  get hasHSizingDesc() {
6337
6226
  return !!this.items.find((item) => {
6338
- if (item instanceof _AbstractGroup)
6339
- return item.hasHSizingDesc;
6227
+ if (item instanceof _AbstractGroup2) return item.hasHSizingDesc;
6340
6228
  return item.layout.sizing === "horizontal" || item.layout.sizing === "both";
6341
6229
  });
6342
6230
  }
@@ -6345,8 +6233,7 @@ var __publicField = (obj, key, value) => {
6345
6233
  */
6346
6234
  get hasVSizingDesc() {
6347
6235
  return !!this.items.find((item) => {
6348
- if (item instanceof _AbstractGroup)
6349
- return item.hasVSizingDesc;
6236
+ if (item instanceof _AbstractGroup2) return item.hasVSizingDesc;
6350
6237
  return item.layout.sizing === "vertical" || item.layout.sizing === "both";
6351
6238
  });
6352
6239
  }
@@ -6360,10 +6247,10 @@ var __publicField = (obj, key, value) => {
6360
6247
  return this;
6361
6248
  }
6362
6249
  };
6250
+ _AbstractGroup.padding = 0.2;
6251
+ _AbstractGroup.labelHeight = 0.25;
6252
+ _AbstractGroup.spaceBetween = 0.1;
6363
6253
  let AbstractGroup = _AbstractGroup;
6364
- AbstractGroup.padding = 0.2;
6365
- AbstractGroup.labelHeight = 0.25;
6366
- AbstractGroup.spaceBetween = 0.1;
6367
6254
  }
6368
6255
  ),
6369
6256
  /***/
@@ -6580,15 +6467,13 @@ var __publicField = (obj, key, value) => {
6580
6467
  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));
6581
6468
  });
6582
6469
  this.layout.width += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
6583
- if (this.layout.width < 1)
6584
- this.layout.width += 1;
6470
+ if (this.layout.width < 1) this.layout.width += 1;
6585
6471
  return this;
6586
6472
  }
6587
6473
  expand(dX) {
6588
6474
  let hExpandItems = 0;
6589
6475
  this.items.forEach((item) => {
6590
- if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
6591
- hExpandItems++;
6476
+ if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") hExpandItems++;
6592
6477
  });
6593
6478
  this.items.forEach((item) => {
6594
6479
  let dX$ = 0;
@@ -6775,22 +6660,31 @@ var __publicField = (obj, key, value) => {
6775
6660
  * Get the rendering type of an item by parsing its metadata
6776
6661
  */
6777
6662
  static predictType(item) {
6778
- if (item.type === "vgroup" || item.type === "hgroup" || item.type === "tgroup" || item.type === "button" || item.type === "checkbox" || item.type === "soundfile")
6779
- return item.type;
6663
+ var _a2, _b, _c, _d, _e;
6780
6664
  if (item.type === "hbargraph" || item.type === "vbargraph") {
6781
- if (item.meta && item.meta.find((meta2) => meta2.style && meta2.style.startsWith("led")))
6782
- return "led";
6783
- if (item.meta && item.meta.find((meta2) => meta2.style && meta2.style.startsWith("numerical")))
6784
- return "numerical";
6665
+ if ((_a2 = item.meta) == null ? void 0 : _a2.find((meta2) => {
6666
+ var _a22;
6667
+ return (_a22 = meta2.style) == null ? void 0 : _a22.startsWith("led");
6668
+ })) return "led";
6669
+ if ((_b = item.meta) == null ? void 0 : _b.find((meta2) => {
6670
+ var _a22;
6671
+ return (_a22 = meta2.style) == null ? void 0 : _a22.startsWith("numerical");
6672
+ })) return "numerical";
6785
6673
  return item.type;
6786
6674
  }
6787
6675
  if (item.type === "hslider" || item.type === "nentry" || item.type === "vslider") {
6788
- if (item.meta && item.meta.find((meta2) => meta2.style && meta2.style.startsWith("knob")))
6789
- return "knob";
6790
- if (item.meta && item.meta.find((meta2) => meta2.style && meta2.style.startsWith("menu")))
6791
- return "menu";
6792
- if (item.meta && item.meta.find((meta2) => meta2.style && meta2.style.startsWith("radio")))
6793
- return "radio";
6676
+ if ((_c = item.meta) == null ? void 0 : _c.find((meta2) => {
6677
+ var _a22;
6678
+ return (_a22 = meta2.style) == null ? void 0 : _a22.startsWith("knob");
6679
+ })) return "knob";
6680
+ if ((_d = item.meta) == null ? void 0 : _d.find((meta2) => {
6681
+ var _a22;
6682
+ return (_a22 = meta2.style) == null ? void 0 : _a22.startsWith("menu");
6683
+ })) return "menu";
6684
+ if ((_e = item.meta) == null ? void 0 : _e.find((meta2) => {
6685
+ var _a22;
6686
+ return (_a22 = meta2.style) == null ? void 0 : _a22.startsWith("radio");
6687
+ })) return "radio";
6794
6688
  }
6795
6689
  return item.type;
6796
6690
  }
@@ -6821,8 +6715,7 @@ var __publicField = (obj, key, value) => {
6821
6715
  }
6822
6716
  static getItems(items) {
6823
6717
  return items.map((item) => {
6824
- if ("items" in item)
6825
- item.items = this.getItems(item.items);
6718
+ if ("items" in item) item.items = this.getItems(item.items);
6826
6719
  return this.getItem(item);
6827
6720
  });
6828
6721
  }
@@ -7055,18 +6948,17 @@ var __publicField = (obj, key, value) => {
7055
6948
  /*! ./AbstractGroup */
7056
6949
  "./src/layout/AbstractGroup.ts"
7057
6950
  );
7058
- const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
6951
+ const _TGroup = class _TGroup2 extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] {
7059
6952
  adjust() {
7060
6953
  this.items.forEach((item) => {
7061
6954
  item.adjust();
7062
6955
  this.layout.width = Math.max(this.layout.width, item.layout.width + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding);
7063
- this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding + _TGroup.labelHeight);
6956
+ this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding + _TGroup2.labelHeight);
7064
6957
  });
7065
6958
  const tabsCount = this.items.length;
7066
- this.layout.width = Math.max(this.layout.width, tabsCount * _TGroup.tabLayout.width);
7067
- this.layout.height += _TGroup.tabLayout.height;
7068
- if (this.layout.width < 1)
7069
- this.layout.width += 1;
6959
+ this.layout.width = Math.max(this.layout.width, tabsCount * _TGroup2.tabLayout.width);
6960
+ this.layout.height += _TGroup2.tabLayout.height;
6961
+ if (this.layout.width < 1) this.layout.width += 1;
7070
6962
  return this;
7071
6963
  }
7072
6964
  expand() {
@@ -7074,10 +6966,8 @@ var __publicField = (obj, key, value) => {
7074
6966
  this.items.forEach((item) => {
7075
6967
  let dY$ = 0;
7076
6968
  let dX$ = 0;
7077
- if (item.layout.sizing === "both" || item.layout.sizing === "horizontal")
7078
- dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width;
7079
- if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
7080
- 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;
6969
+ if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width;
6970
+ 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 ? _TGroup2.tabLayout.height : 0) - item.layout.height;
7081
6971
  item.expand(dX$, dY$);
7082
6972
  });
7083
6973
  return this;
@@ -7085,7 +6975,7 @@ var __publicField = (obj, key, value) => {
7085
6975
  offset() {
7086
6976
  const { labelHeight, padding } = _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"];
7087
6977
  const $left = padding;
7088
- const $top = padding + (this.isRoot ? 0 : labelHeight) + _TGroup.tabLayout.height;
6978
+ const $top = padding + (this.isRoot ? 0 : labelHeight) + _TGroup2.tabLayout.height;
7089
6979
  this.items.forEach((item) => {
7090
6980
  item.layout.offsetLeft = $left;
7091
6981
  item.layout.offsetTop = $top;
@@ -7096,11 +6986,11 @@ var __publicField = (obj, key, value) => {
7096
6986
  return this;
7097
6987
  }
7098
6988
  };
7099
- let TGroup = _TGroup;
7100
- TGroup.tabLayout = {
6989
+ _TGroup.tabLayout = {
7101
6990
  width: 2,
7102
6991
  height: 1
7103
6992
  };
6993
+ let TGroup = _TGroup;
7104
6994
  }
7105
6995
  ),
7106
6996
  /***/
@@ -7164,15 +7054,13 @@ var __publicField = (obj, key, value) => {
7164
7054
  this.layout.height += item.layout.height;
7165
7055
  });
7166
7056
  this.layout.height += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1);
7167
- if (this.layout.width < 1)
7168
- this.layout.width += 1;
7057
+ if (this.layout.width < 1) this.layout.width += 1;
7169
7058
  return this;
7170
7059
  }
7171
7060
  expand(dX, dY) {
7172
7061
  let vExpandItems = 0;
7173
7062
  this.items.forEach((item) => {
7174
- if (item.layout.sizing === "both" || item.layout.sizing === "vertical")
7175
- vExpandItems++;
7063
+ if (item.layout.sizing === "both" || item.layout.sizing === "vertical") vExpandItems++;
7176
7064
  });
7177
7065
  this.items.forEach((item) => {
7178
7066
  let dX$ = 0;
@@ -8448,33 +8336,31 @@ var __publicField = (obj, key, value) => {
8448
8336
  __webpack_require__.nc = void 0;
8449
8337
  })();
8450
8338
  var __webpack_exports__ = {};
8451
- (() => {
8452
- /*!**********************!*\
8453
- !*** ./src/index.ts ***!
8454
- \**********************/
8455
- __webpack_require__.r(__webpack_exports__);
8456
- __webpack_require__.d(__webpack_exports__, {
8457
- /* harmony export */
8458
- FaustUI: () => (
8459
- /* reexport safe */
8460
- _FaustUI__WEBPACK_IMPORTED_MODULE_0__["default"]
8461
- ),
8462
- /* harmony export */
8463
- instantiate: () => (
8464
- /* reexport safe */
8465
- _instantiate__WEBPACK_IMPORTED_MODULE_1__["default"]
8466
- )
8467
- /* harmony export */
8468
- });
8469
- var _FaustUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
8470
- /*! ./FaustUI */
8471
- "./src/FaustUI.ts"
8472
- );
8473
- var _instantiate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
8474
- /*! ./instantiate */
8475
- "./src/instantiate.ts"
8476
- );
8477
- })();
8339
+ /*!**********************!*\
8340
+ !*** ./src/index.ts ***!
8341
+ \**********************/
8342
+ __webpack_require__.r(__webpack_exports__);
8343
+ __webpack_require__.d(__webpack_exports__, {
8344
+ /* harmony export */
8345
+ FaustUI: () => (
8346
+ /* reexport safe */
8347
+ _FaustUI__WEBPACK_IMPORTED_MODULE_0__["default"]
8348
+ ),
8349
+ /* harmony export */
8350
+ instantiate: () => (
8351
+ /* reexport safe */
8352
+ _instantiate__WEBPACK_IMPORTED_MODULE_1__["default"]
8353
+ )
8354
+ /* harmony export */
8355
+ });
8356
+ var _FaustUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
8357
+ /*! ./FaustUI */
8358
+ "./src/FaustUI.ts"
8359
+ );
8360
+ var _instantiate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
8361
+ /*! ./instantiate */
8362
+ "./src/instantiate.ts"
8363
+ );
8478
8364
  return __webpack_exports__;
8479
8365
  })()
8480
8366
  );
@@ -8557,8 +8443,7 @@ var __publicField = (obj, key, value) => {
8557
8443
  return obj = {}, obj[dim] = gutSize + "px", obj;
8558
8444
  };
8559
8445
  var Split = function(idsOption, options) {
8560
- if (options === void 0)
8561
- options = {};
8446
+ if (options === void 0) options = {};
8562
8447
  if (ssr) {
8563
8448
  return {};
8564
8449
  }
@@ -8956,6 +8841,24 @@ var __publicField = (obj, key, value) => {
8956
8841
  pairs
8957
8842
  };
8958
8843
  };
8844
+ var __accessCheck = (obj, member, msg) => {
8845
+ if (!member.has(obj))
8846
+ throw TypeError("Cannot " + msg);
8847
+ };
8848
+ var __privateGet = (obj, member, getter) => {
8849
+ __accessCheck(obj, member, "read from private field");
8850
+ return getter ? getter.call(obj) : member.get(obj);
8851
+ };
8852
+ var __privateAdd = (obj, member, value) => {
8853
+ if (member.has(obj))
8854
+ throw TypeError("Cannot add the same private member more than once");
8855
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8856
+ };
8857
+ var __privateSet = (obj, member, value, setter) => {
8858
+ __accessCheck(obj, member, "write to private field");
8859
+ member.set(obj, value);
8860
+ return value;
8861
+ };
8959
8862
  var instantiateFaustModuleFromFile = async (jsFile, dataFile = jsFile.replace(/c?js$/, "data"), wasmFile = jsFile.replace(/c?js$/, "wasm")) => {
8960
8863
  var _a2, _b;
8961
8864
  let FaustModule;
@@ -9073,18 +8976,30 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9073
8976
  handleMessageAux(e) {
9074
8977
  const msg = e.data;
9075
8978
  switch (msg.type) {
9076
- case "midi":
8979
+ case "acc": {
8980
+ this.propagateAcc(msg.data, msg.invert);
8981
+ break;
8982
+ }
8983
+ case "gyr": {
8984
+ this.propagateGyr(msg.data);
8985
+ break;
8986
+ }
8987
+ case "midi": {
9077
8988
  this.midiMessage(msg.data);
9078
8989
  break;
9079
- case "ctrlChange":
8990
+ }
8991
+ case "ctrlChange": {
9080
8992
  this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);
9081
8993
  break;
9082
- case "pitchWheel":
8994
+ }
8995
+ case "pitchWheel": {
9083
8996
  this.pitchWheel(msg.data[0], msg.data[1]);
9084
8997
  break;
9085
- case "param":
8998
+ }
8999
+ case "param": {
9086
9000
  this.setParamValue(msg.data.path, msg.data.value);
9087
9001
  break;
9002
+ }
9088
9003
  case "setPlotHandler": {
9089
9004
  if (msg.data) {
9090
9005
  this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: "plot", value: output, index, events }));
@@ -9121,6 +9036,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9121
9036
  pitchWheel(channel, wheel) {
9122
9037
  this.fDSPCode.pitchWheel(channel, wheel);
9123
9038
  }
9039
+ propagateAcc(accelerationIncludingGravity, invert = false) {
9040
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
9041
+ }
9042
+ propagateGyr(event) {
9043
+ this.fDSPCode.propagateGyr(event);
9044
+ }
9124
9045
  }
9125
9046
  class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {
9126
9047
  constructor(options) {
@@ -10403,6 +10324,268 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
10403
10324
  }
10404
10325
  };
10405
10326
  var FaustWasmInstantiator_default = FaustWasmInstantiator;
10327
+ var FaustSensors = class _FaustSensors {
10328
+ /**
10329
+ * Function to convert a number to an axis type
10330
+ *
10331
+ * @param value number
10332
+ * @returns axis type
10333
+ */
10334
+ static convertToAxis(value) {
10335
+ switch (value) {
10336
+ case 0:
10337
+ return 0;
10338
+ case 1:
10339
+ return 1;
10340
+ case 2:
10341
+ return 2;
10342
+ default:
10343
+ console.error("Error: Axis not found value: " + value);
10344
+ return 0;
10345
+ }
10346
+ }
10347
+ /**
10348
+ * Function to convert a number to a curve type
10349
+ *
10350
+ * @param value number
10351
+ * @returns curve type
10352
+ */
10353
+ static convertToCurve(value) {
10354
+ switch (value) {
10355
+ case 0:
10356
+ return 0;
10357
+ case 1:
10358
+ return 1;
10359
+ case 2:
10360
+ return 2;
10361
+ case 3:
10362
+ return 3;
10363
+ default:
10364
+ console.error("Error: Curve not found value: " + value);
10365
+ return 0;
10366
+ }
10367
+ }
10368
+ static get Range() {
10369
+ if (!this._Range) {
10370
+ this._Range = class {
10371
+ constructor(x, y) {
10372
+ this.fLo = Math.min(x, y);
10373
+ this.fHi = Math.max(x, y);
10374
+ }
10375
+ clip(x) {
10376
+ if (x < this.fLo)
10377
+ return this.fLo;
10378
+ if (x > this.fHi)
10379
+ return this.fHi;
10380
+ return x;
10381
+ }
10382
+ };
10383
+ }
10384
+ return this._Range;
10385
+ }
10386
+ /**
10387
+ * Interpolator class
10388
+ */
10389
+ static get Interpolator() {
10390
+ if (!this._Interpolator) {
10391
+ this._Interpolator = class {
10392
+ constructor(lo, hi, v1, v2) {
10393
+ this.fRange = new _FaustSensors.Range(lo, hi);
10394
+ if (hi !== lo) {
10395
+ this.fCoef = (v2 - v1) / (hi - lo);
10396
+ this.fOffset = v1 - lo * this.fCoef;
10397
+ } else {
10398
+ this.fCoef = 0;
10399
+ this.fOffset = (v1 + v2) / 2;
10400
+ }
10401
+ }
10402
+ returnMappedValue(v) {
10403
+ var x = this.fRange.clip(v);
10404
+ return this.fOffset + x * this.fCoef;
10405
+ }
10406
+ getLowHigh(amin, amax) {
10407
+ return { amin: this.fRange.fLo, amax: this.fRange.fHi };
10408
+ }
10409
+ };
10410
+ }
10411
+ return this._Interpolator;
10412
+ }
10413
+ /**
10414
+ * Interpolator3pt class, combine two interpolators
10415
+ */
10416
+ static get Interpolator3pt() {
10417
+ if (!this._Interpolator3pt) {
10418
+ this._Interpolator3pt = class {
10419
+ constructor(lo, mid, hi, v1, vMid, v2) {
10420
+ this.fSegment1 = new _FaustSensors.Interpolator(lo, mid, v1, vMid);
10421
+ this.fSegment2 = new _FaustSensors.Interpolator(mid, hi, vMid, v2);
10422
+ this.fMid = mid;
10423
+ }
10424
+ returnMappedValue(x) {
10425
+ return x < this.fMid ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);
10426
+ }
10427
+ getMappingValues(amin, amid, amax) {
10428
+ var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);
10429
+ var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);
10430
+ return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };
10431
+ }
10432
+ };
10433
+ }
10434
+ return this._Interpolator3pt;
10435
+ }
10436
+ /**
10437
+ * UpConverter class, convert accelerometer value to Faust value
10438
+ */
10439
+ static get UpConverter() {
10440
+ if (!this._UpConverter) {
10441
+ this._UpConverter = class {
10442
+ constructor(amin, amid, amax, fmin, fmid, fmax) {
10443
+ this.fActive = true;
10444
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);
10445
+ this.fF2A = new _FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);
10446
+ }
10447
+ uiToFaust(x) {
10448
+ return this.fA2F.returnMappedValue(x);
10449
+ }
10450
+ faustToUi(x) {
10451
+ return this.fF2A.returnMappedValue(x);
10452
+ }
10453
+ setMappingValues(amin, amid, amax, min, init, max) {
10454
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);
10455
+ this.fF2A = new _FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);
10456
+ }
10457
+ getMappingValues(amin, amid, amax) {
10458
+ return this.fA2F.getMappingValues(amin, amid, amax);
10459
+ }
10460
+ setActive(onOff) {
10461
+ this.fActive = onOff;
10462
+ }
10463
+ getActive() {
10464
+ return this.fActive;
10465
+ }
10466
+ };
10467
+ }
10468
+ return this._UpConverter;
10469
+ }
10470
+ /**
10471
+ * DownConverter class, convert accelerometer value to Faust value
10472
+ */
10473
+ static get DownConverter() {
10474
+ if (!this._DownConverter) {
10475
+ this._DownConverter = class {
10476
+ constructor(amin, amid, amax, fmin, fmid, fmax) {
10477
+ this.fActive = true;
10478
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);
10479
+ this.fF2A = new _FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);
10480
+ }
10481
+ uiToFaust(x) {
10482
+ return this.fA2F.returnMappedValue(x);
10483
+ }
10484
+ faustToUi(x) {
10485
+ return this.fF2A.returnMappedValue(x);
10486
+ }
10487
+ setMappingValues(amin, amid, amax, min, init, max) {
10488
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);
10489
+ this.fF2A = new _FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);
10490
+ }
10491
+ getMappingValues(amin, amid, amax) {
10492
+ return this.fA2F.getMappingValues(amin, amid, amax);
10493
+ }
10494
+ setActive(onOff) {
10495
+ this.fActive = onOff;
10496
+ }
10497
+ getActive() {
10498
+ return this.fActive;
10499
+ }
10500
+ };
10501
+ }
10502
+ return this._DownConverter;
10503
+ }
10504
+ /**
10505
+ * UpDownConverter class, convert accelerometer value to Faust value
10506
+ */
10507
+ static get UpDownConverter() {
10508
+ if (!this._UpDownConverter) {
10509
+ this._UpDownConverter = class {
10510
+ constructor(amin, amid, amax, fmin, fmid, fmax) {
10511
+ this.fActive = true;
10512
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);
10513
+ this.fF2A = new _FaustSensors.Interpolator(fmin, fmax, amin, amax);
10514
+ }
10515
+ uiToFaust(x) {
10516
+ return this.fA2F.returnMappedValue(x);
10517
+ }
10518
+ faustToUi(x) {
10519
+ return this.fF2A.returnMappedValue(x);
10520
+ }
10521
+ setMappingValues(amin, amid, amax, min, init, max) {
10522
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);
10523
+ this.fF2A = new _FaustSensors.Interpolator(min, max, amin, amax);
10524
+ }
10525
+ getMappingValues(amin, amid, amax) {
10526
+ return this.fA2F.getMappingValues(amin, amid, amax);
10527
+ }
10528
+ setActive(onOff) {
10529
+ this.fActive = onOff;
10530
+ }
10531
+ getActive() {
10532
+ return this.fActive;
10533
+ }
10534
+ };
10535
+ }
10536
+ return this._UpDownConverter;
10537
+ }
10538
+ static get DownUpConverter() {
10539
+ if (!this._DownUpConverter) {
10540
+ this._DownUpConverter = class {
10541
+ constructor(amin, amid, amax, fmin, fmid, fmax) {
10542
+ this.fActive = true;
10543
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);
10544
+ this.fF2A = new _FaustSensors.Interpolator(fmin, fmax, amin, amax);
10545
+ }
10546
+ uiToFaust(x) {
10547
+ return this.fA2F.returnMappedValue(x);
10548
+ }
10549
+ faustToUi(x) {
10550
+ return this.fF2A.returnMappedValue(x);
10551
+ }
10552
+ setMappingValues(amin, amid, amax, min, init, max) {
10553
+ this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);
10554
+ this.fF2A = new _FaustSensors.Interpolator(min, max, amin, amax);
10555
+ }
10556
+ getMappingValues(amin, amid, amax) {
10557
+ return this.fA2F.getMappingValues(amin, amid, amax);
10558
+ }
10559
+ setActive(onOff) {
10560
+ this.fActive = onOff;
10561
+ }
10562
+ getActive() {
10563
+ return this.fActive;
10564
+ }
10565
+ };
10566
+ }
10567
+ return this._DownUpConverter;
10568
+ }
10569
+ /**
10570
+ * Public function to build the accelerometer handler
10571
+ *
10572
+ * @returns `UpdatableValueConverter` built for the given curve
10573
+ */
10574
+ static buildHandler(curve, amin, amid, amax, min, init, max) {
10575
+ switch (curve) {
10576
+ case 0:
10577
+ return new _FaustSensors.UpConverter(amin, amid, amax, min, init, max);
10578
+ case 1:
10579
+ return new _FaustSensors.DownConverter(amin, amid, amax, min, init, max);
10580
+ case 2:
10581
+ return new _FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);
10582
+ case 3:
10583
+ return new _FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);
10584
+ default:
10585
+ return new _FaustSensors.UpConverter(amin, amid, amax, min, init, max);
10586
+ }
10587
+ }
10588
+ };
10406
10589
  var WasmAllocator = class {
10407
10590
  constructor(memory, offset) {
10408
10591
  this.memory = memory;
@@ -10650,17 +10833,25 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
10650
10833
  if (!item.meta)
10651
10834
  return;
10652
10835
  item.meta.forEach((meta2) => {
10653
- const { midi } = meta2;
10654
- if (!midi)
10655
- return;
10656
- const strMidi = midi.trim();
10657
- if (strMidi === "pitchwheel") {
10658
- this.fPitchwheelLabel.push({ path: item.address, min: item.min, max: item.max });
10659
- } else {
10660
- const matched = strMidi.match(/^ctrl\s(\d+)/);
10661
- if (!matched)
10662
- return;
10663
- this.fCtrlLabel[parseInt(matched[1])].push({ path: item.address, min: item.min, max: item.max });
10836
+ const { midi, acc, gyr } = meta2;
10837
+ if (midi) {
10838
+ const strMidi = midi.trim();
10839
+ if (strMidi === "pitchwheel") {
10840
+ this.fPitchwheelLabel.push({ path: item.address, min: item.min, max: item.max });
10841
+ } else {
10842
+ const matched = strMidi.match(/^ctrl\s(\d+)/);
10843
+ if (matched) {
10844
+ this.fCtrlLabel[parseInt(matched[1])].push({ path: item.address, min: item.min, max: item.max });
10845
+ }
10846
+ }
10847
+ }
10848
+ if (acc) {
10849
+ const numAcc = acc.trim().split(" ").map(Number);
10850
+ this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min, item.init, item.max);
10851
+ }
10852
+ if (gyr) {
10853
+ const numAcc = gyr.trim().split(" ").map(Number);
10854
+ this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min, item.init, item.max);
10664
10855
  }
10665
10856
  });
10666
10857
  } else if (item.type === "soundfile") {
@@ -10674,6 +10865,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
10674
10865
  this.fPtrSize = sampleSize;
10675
10866
  this.fSampleSize = sampleSize;
10676
10867
  this.fSoundfileBuffers = soundfiles;
10868
+ this.fAcc = { x: [], y: [], z: [] };
10869
+ this.fGyr = { x: [], y: [], z: [] };
10677
10870
  }
10678
10871
  // Tools
10679
10872
  static remap(v, mn0, mx0, mn1, mx1) {
@@ -10703,6 +10896,69 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
10703
10896
  let trimmed = input.replace(/^\{|\}$/g, "");
10704
10897
  return trimmed.split(";").map((str) => str.length <= 2 ? "" : str.substring(1, str.length - 1));
10705
10898
  }
10899
+ get hasAccInput() {
10900
+ return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
10901
+ }
10902
+ propagateAcc(accelerationIncludingGravity, invert = false) {
10903
+ const { x, y, z } = accelerationIncludingGravity;
10904
+ if (invert) {
10905
+ if (x !== null)
10906
+ this.fAcc.x.forEach((handler) => handler(-x));
10907
+ if (y !== null)
10908
+ this.fAcc.y.forEach((handler) => handler(-y));
10909
+ if (z !== null)
10910
+ this.fAcc.z.forEach((handler) => handler(-z));
10911
+ } else {
10912
+ if (x !== null)
10913
+ this.fAcc.x.forEach((handler) => handler(x));
10914
+ if (y !== null)
10915
+ this.fAcc.y.forEach((handler) => handler(y));
10916
+ if (z !== null)
10917
+ this.fAcc.z.forEach((handler) => handler(z));
10918
+ }
10919
+ }
10920
+ get hasGyrInput() {
10921
+ return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0;
10922
+ }
10923
+ propagateGyr(event) {
10924
+ const { alpha, beta, gamma } = event;
10925
+ if (alpha !== null)
10926
+ this.fGyr.x.forEach((handler) => handler(alpha));
10927
+ if (beta !== null)
10928
+ this.fGyr.y.forEach((handler) => handler(beta));
10929
+ if (gamma !== null)
10930
+ this.fGyr.z.forEach((handler) => handler(gamma));
10931
+ }
10932
+ /** Build the accelerometer handler */
10933
+ setupAccHandler(path, axis, curve, amin, amid, amax, min, init, max) {
10934
+ const handler = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);
10935
+ switch (axis) {
10936
+ case 0:
10937
+ this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10938
+ break;
10939
+ case 1:
10940
+ this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10941
+ break;
10942
+ case 2:
10943
+ this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10944
+ break;
10945
+ }
10946
+ }
10947
+ /** Build the gyroscope handler */
10948
+ setupGyrHandler(path, axis, curve, amin, amid, amax, min, init, max) {
10949
+ const handler = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);
10950
+ switch (axis) {
10951
+ case 0:
10952
+ this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10953
+ break;
10954
+ case 1:
10955
+ this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10956
+ break;
10957
+ case 2:
10958
+ this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));
10959
+ break;
10960
+ }
10961
+ }
10706
10962
  static extractUrlsFromMeta(dspMeta) {
10707
10963
  const soundfilesEntry = dspMeta.meta.find((entry) => entry.soundfiles !== void 0);
10708
10964
  if (soundfilesEntry) {
@@ -11511,6 +11767,18 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11511
11767
  destroy() {
11512
11768
  this.fDSPCode.destroy();
11513
11769
  }
11770
+ get hasAccInput() {
11771
+ return this.fDSPCode.hasAccInput;
11772
+ }
11773
+ propagateAcc(accelerationIncludingGravity, invert = false) {
11774
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
11775
+ }
11776
+ get hasGyrInput() {
11777
+ return this.fDSPCode.hasGyrInput;
11778
+ }
11779
+ propagateGyr(event) {
11780
+ this.fDSPCode.propagateGyr(event);
11781
+ }
11514
11782
  /**
11515
11783
  * Render frames in an array.
11516
11784
  *
@@ -11635,8 +11903,17 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11635
11903
  };
11636
11904
  var LibFaust_default = LibFaust;
11637
11905
  var SoundfileReader = class {
11906
+ // Set the fallback paths
11638
11907
  static get fallbackPaths() {
11639
- return [location.href, location.origin];
11908
+ return [location.href, this.getParentUrl(location.href), location.origin];
11909
+ }
11910
+ /**
11911
+ * Extract the parent URL from an URL.
11912
+ * @param url : the URL
11913
+ * @returns : the parent URL
11914
+ */
11915
+ static getParentUrl(url) {
11916
+ return url.substring(0, url.lastIndexOf("/") + 1);
11640
11917
  }
11641
11918
  /**
11642
11919
  * Convert an audio buffer to audio data.
@@ -11677,7 +11954,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11677
11954
  static async checkFileExists(url) {
11678
11955
  try {
11679
11956
  console.log(`"checkFileExists" url: ${url}`);
11680
- const response = await fetch(url, { method: "HEAD" });
11957
+ const response = await fetch(url);
11958
+ console.log(`"checkFileExists" response.ok: ${response.ok}`);
11681
11959
  return response.ok;
11682
11960
  } catch (error) {
11683
11961
  console.error("Fetch error:", error);
@@ -11744,6 +12022,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11744
12022
  }
11745
12023
  };
11746
12024
  var SoundfileReader_default = SoundfileReader;
12025
+ var _hasAccInput, _hasGyrInput;
11747
12026
  var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
11748
12027
  constructor(context, name2, factory, options, nodeOptions = {}) {
11749
12028
  const JSONObj = JSON.parse(factory.json);
@@ -11757,6 +12036,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11757
12036
  processorOptions: options,
11758
12037
  ...nodeOptions
11759
12038
  });
12039
+ __privateAdd(this, _hasAccInput, false);
12040
+ __privateAdd(this, _hasGyrInput, false);
11760
12041
  this.fJSONDsp = JSONObj;
11761
12042
  this.fJSON = factory.json;
11762
12043
  this.fOutputHandler = null;
@@ -11768,6 +12049,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11768
12049
  if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
11769
12050
  this.fInputsItems.push(item.address);
11770
12051
  this.fDescriptor.push(item);
12052
+ if (!item.meta)
12053
+ return;
12054
+ item.meta.forEach((meta2) => {
12055
+ const { midi, acc, gyr } = meta2;
12056
+ if (acc)
12057
+ __privateSet(this, _hasAccInput, true);
12058
+ if (gyr)
12059
+ __privateSet(this, _hasGyrInput, true);
12060
+ });
11771
12061
  }
11772
12062
  };
11773
12063
  FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
@@ -11780,6 +12070,65 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11780
12070
  };
11781
12071
  }
11782
12072
  // Public API
12073
+ /** Setup accelerometer and gyroscope handlers */
12074
+ async listenSensors() {
12075
+ if (this.hasAccInput) {
12076
+ const isAndroid = /Android/i.test(navigator.userAgent);
12077
+ let handleDeviceMotion = null;
12078
+ if (isAndroid) {
12079
+ handleDeviceMotion = ({ accelerationIncludingGravity }) => {
12080
+ if (!accelerationIncludingGravity)
12081
+ return;
12082
+ const { x, y, z } = accelerationIncludingGravity;
12083
+ this.propagateAcc({ x, y, z }, true);
12084
+ };
12085
+ } else {
12086
+ handleDeviceMotion = ({ accelerationIncludingGravity }) => {
12087
+ if (!accelerationIncludingGravity)
12088
+ return;
12089
+ const { x, y, z } = accelerationIncludingGravity;
12090
+ this.propagateAcc({ x, y, z });
12091
+ };
12092
+ }
12093
+ if (window.DeviceMotionEvent) {
12094
+ if (typeof window.DeviceMotionEvent.requestPermission === "function") {
12095
+ try {
12096
+ const response = await window.DeviceMotionEvent.requestPermission();
12097
+ if (response !== "granted")
12098
+ throw new Error("Unable to access the accelerometer.");
12099
+ window.addEventListener("devicemotion", handleDeviceMotion, true);
12100
+ } catch (error) {
12101
+ console.error(error);
12102
+ }
12103
+ } else {
12104
+ window.addEventListener("devicemotion", handleDeviceMotion, true);
12105
+ }
12106
+ } else {
12107
+ console.log("Cannot set the accelerometer handler.");
12108
+ }
12109
+ }
12110
+ if (this.hasGyrInput) {
12111
+ const handleDeviceOrientation = ({ alpha, beta, gamma }) => {
12112
+ this.propagateGyr({ alpha, beta, gamma });
12113
+ };
12114
+ if (window.DeviceMotionEvent) {
12115
+ if (typeof window.DeviceOrientationEvent.requestPermission === "function") {
12116
+ try {
12117
+ const response = await window.DeviceOrientationEvent.requestPermission();
12118
+ if (response !== "granted")
12119
+ throw new Error("Unable to access the gyroscope.");
12120
+ window.addEventListener("deviceorientation", handleDeviceOrientation, true);
12121
+ } catch (error) {
12122
+ console.error(error);
12123
+ }
12124
+ } else {
12125
+ window.addEventListener("deviceorientation", handleDeviceOrientation, true);
12126
+ }
12127
+ } else {
12128
+ console.log("Cannot set the gyroscope handler.");
12129
+ }
12130
+ }
12131
+ }
11783
12132
  setOutputParamHandler(handler) {
11784
12133
  this.fOutputHandler = handler;
11785
12134
  }
@@ -11838,6 +12187,24 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11838
12187
  const e = { type: "pitchWheel", data: [channel, wheel] };
11839
12188
  this.port.postMessage(e);
11840
12189
  }
12190
+ get hasAccInput() {
12191
+ return __privateGet(this, _hasAccInput);
12192
+ }
12193
+ propagateAcc(accelerationIncludingGravity, invert = false) {
12194
+ if (!accelerationIncludingGravity)
12195
+ return;
12196
+ const e = { type: "acc", data: accelerationIncludingGravity, invert };
12197
+ this.port.postMessage(e);
12198
+ }
12199
+ get hasGyrInput() {
12200
+ return __privateGet(this, _hasGyrInput);
12201
+ }
12202
+ propagateGyr(event) {
12203
+ if (!event)
12204
+ return;
12205
+ const e = { type: "gyr", data: event };
12206
+ this.port.postMessage(e);
12207
+ }
11841
12208
  setParamValue(path, value) {
11842
12209
  const e = { type: "param", data: { path, value } };
11843
12210
  this.port.postMessage(e);
@@ -11875,6 +12242,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11875
12242
  this.port.close();
11876
12243
  }
11877
12244
  };
12245
+ _hasAccInput = /* @__PURE__ */ new WeakMap();
12246
+ _hasGyrInput = /* @__PURE__ */ new WeakMap();
11878
12247
  var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
11879
12248
  constructor(context, name2, factory, sampleSize, nodeOptions = {}) {
11880
12249
  super(context, name2, factory, { name: name2, factory, sampleSize }, nodeOptions);
@@ -11968,6 +12337,65 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
11968
12337
  this.start();
11969
12338
  }
11970
12339
  // Public API
12340
+ /** Setup accelerometer and gyroscope handlers */
12341
+ async listenSensors() {
12342
+ if (this.hasAccInput) {
12343
+ const isAndroid = /Android/i.test(navigator.userAgent);
12344
+ let handleDeviceMotion = null;
12345
+ if (isAndroid) {
12346
+ handleDeviceMotion = ({ accelerationIncludingGravity }) => {
12347
+ if (!accelerationIncludingGravity)
12348
+ return;
12349
+ const { x, y, z } = accelerationIncludingGravity;
12350
+ this.propagateAcc({ x, y, z }, true);
12351
+ };
12352
+ } else {
12353
+ handleDeviceMotion = ({ accelerationIncludingGravity }) => {
12354
+ if (!accelerationIncludingGravity)
12355
+ return;
12356
+ const { x, y, z } = accelerationIncludingGravity;
12357
+ this.propagateAcc({ x, y, z });
12358
+ };
12359
+ }
12360
+ if (window.DeviceMotionEvent) {
12361
+ if (typeof window.DeviceMotionEvent.requestPermission === "function") {
12362
+ try {
12363
+ const response = await window.DeviceMotionEvent.requestPermission();
12364
+ if (response !== "granted")
12365
+ throw new Error("Unable to access the accelerometer.");
12366
+ window.addEventListener("devicemotion", handleDeviceMotion, true);
12367
+ } catch (error) {
12368
+ console.error(error);
12369
+ }
12370
+ } else {
12371
+ window.addEventListener("devicemotion", handleDeviceMotion, true);
12372
+ }
12373
+ } else {
12374
+ console.log("Cannot set the accelerometer handler.");
12375
+ }
12376
+ }
12377
+ if (this.hasGyrInput) {
12378
+ const handleDeviceOrientation = ({ alpha, beta, gamma }) => {
12379
+ this.propagateGyr({ alpha, beta, gamma });
12380
+ };
12381
+ if (window.DeviceMotionEvent) {
12382
+ if (typeof window.DeviceOrientationEvent.requestPermission === "function") {
12383
+ try {
12384
+ const response = await window.DeviceOrientationEvent.requestPermission();
12385
+ if (response !== "granted")
12386
+ throw new Error("Unable to access the gyroscope.");
12387
+ window.addEventListener("deviceorientation", handleDeviceOrientation, true);
12388
+ } catch (error) {
12389
+ console.error(error);
12390
+ }
12391
+ } else {
12392
+ window.addEventListener("deviceorientation", handleDeviceOrientation, true);
12393
+ }
12394
+ } else {
12395
+ console.log("Cannot set the gyroscope handler.");
12396
+ }
12397
+ }
12398
+ }
11971
12399
  compute(input, output) {
11972
12400
  return this.fDSPCode.compute(input, output);
11973
12401
  }
@@ -12036,6 +12464,18 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
12036
12464
  destroy() {
12037
12465
  this.fDSPCode.destroy();
12038
12466
  }
12467
+ get hasAccInput() {
12468
+ return this.fDSPCode.hasAccInput;
12469
+ }
12470
+ propagateAcc(accelerationIncludingGravity, invert = false) {
12471
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
12472
+ }
12473
+ get hasGyrInput() {
12474
+ return this.fDSPCode.hasGyrInput;
12475
+ }
12476
+ propagateGyr(event) {
12477
+ this.fDSPCode.propagateGyr(event);
12478
+ }
12039
12479
  };
12040
12480
  var FaustMonoScriptProcessorNode = class extends FaustScriptProcessorNode {
12041
12481
  };
@@ -12117,6 +12557,8 @@ var ${Soundfile.name} = ${Soundfile.toString()}
12117
12557
  var Soundfile = ${Soundfile.name};
12118
12558
  var ${WasmAllocator.name} = ${WasmAllocator.toString()}
12119
12559
  var WasmAllocator = ${WasmAllocator.name};
12560
+ var ${FaustSensors.name} = ${FaustSensors.toString()}
12561
+ var FaustSensors = ${FaustSensors.name};
12120
12562
  // Put them in dependencies
12121
12563
  const dependencies = {
12122
12564
  FaustBaseWebAudioDsp,
@@ -12169,6 +12611,8 @@ var ${Soundfile.name} = ${Soundfile.toString()}
12169
12611
  var Soundfile = ${Soundfile.name};
12170
12612
  var ${WasmAllocator.name} = ${WasmAllocator.toString()}
12171
12613
  var WasmAllocator = ${WasmAllocator.name};
12614
+ var ${FaustSensors.name} = ${FaustSensors.toString()}
12615
+ var FaustSensors = ${FaustSensors.name};
12172
12616
  var FFTUtils = ${fftUtils.toString()}
12173
12617
  // Put them in dependencies
12174
12618
  const dependencies = {
@@ -12395,6 +12839,8 @@ var ${Soundfile.name} = ${Soundfile.toString()}
12395
12839
  var Soundfile = ${Soundfile.name};
12396
12840
  var ${WasmAllocator.name} = ${WasmAllocator.toString()}
12397
12841
  var WasmAllocator = ${WasmAllocator.name};
12842
+ var ${FaustSensors.name} = ${FaustSensors.toString()}
12843
+ var FaustSensors = ${FaustSensors.name};
12398
12844
  // Put them in dependencies
12399
12845
  const dependencies = {
12400
12846
  FaustBaseWebAudioDsp,
@@ -12614,16 +13060,11 @@ const dependencies = {
12614
13060
  const channel = data[0] & 15;
12615
13061
  const data1 = data[1];
12616
13062
  const data2 = data[2];
12617
- if (channel === 9)
12618
- return;
12619
- else if (cmd2 === 8 || cmd2 === 9 && data2 === 0)
12620
- node.keyOff(channel, data1, data2);
12621
- else if (cmd2 === 9)
12622
- node.keyOn(channel, data1, data2);
12623
- else if (cmd2 === 11)
12624
- node.ctrlChange(channel, data1, data2);
12625
- else if (cmd2 === 14)
12626
- node.pitchWheel(channel, data2 * 128 + data1);
13063
+ if (channel === 9) return;
13064
+ else if (cmd2 === 8 || cmd2 === 9 && data2 === 0) node.keyOff(channel, data1, data2);
13065
+ else if (cmd2 === 9) node.keyOn(channel, data1, data2);
13066
+ else if (cmd2 === 11) node.ctrlChange(channel, data1, data2);
13067
+ else if (cmd2 === 14) node.pitchWheel(channel, data2 * 128 + data1);
12627
13068
  };
12628
13069
  };
12629
13070
  function extractMidiAndNvoices(jsonData) {
@@ -13535,32 +13976,31 @@ const dependencies = {
13535
13976
  filter(ranges) {
13536
13977
  let resultSections = [], resultInserted = [], filteredSections = [];
13537
13978
  let iter = new SectionIter(this);
13538
- done:
13539
- for (let i2 = 0, pos = 0; ; ) {
13540
- let next = i2 == ranges.length ? 1e9 : ranges[i2++];
13541
- while (pos < next || pos == next && iter.len == 0) {
13542
- if (iter.done)
13543
- break done;
13544
- let len = Math.min(iter.len, next - pos);
13545
- addSection(filteredSections, len, -1);
13546
- let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
13547
- addSection(resultSections, len, ins);
13548
- if (ins > 0)
13549
- addInsert(resultInserted, resultSections, iter.text);
13550
- iter.forward(len);
13551
- pos += len;
13552
- }
13553
- let end2 = ranges[i2++];
13554
- while (pos < end2) {
13555
- if (iter.done)
13556
- break done;
13557
- let len = Math.min(iter.len, end2 - pos);
13558
- addSection(resultSections, len, -1);
13559
- addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
13560
- iter.forward(len);
13561
- pos += len;
13562
- }
13979
+ done: for (let i2 = 0, pos = 0; ; ) {
13980
+ let next = i2 == ranges.length ? 1e9 : ranges[i2++];
13981
+ while (pos < next || pos == next && iter.len == 0) {
13982
+ if (iter.done)
13983
+ break done;
13984
+ let len = Math.min(iter.len, next - pos);
13985
+ addSection(filteredSections, len, -1);
13986
+ let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
13987
+ addSection(resultSections, len, ins);
13988
+ if (ins > 0)
13989
+ addInsert(resultInserted, resultSections, iter.text);
13990
+ iter.forward(len);
13991
+ pos += len;
13992
+ }
13993
+ let end2 = ranges[i2++];
13994
+ while (pos < end2) {
13995
+ if (iter.done)
13996
+ break done;
13997
+ let len = Math.min(iter.len, end2 - pos);
13998
+ addSection(resultSections, len, -1);
13999
+ addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
14000
+ iter.forward(len);
14001
+ pos += len;
13563
14002
  }
14003
+ }
13564
14004
  return {
13565
14005
  changes: new ChangeSet(resultSections, resultInserted),
13566
14006
  filtered: ChangeDesc.create(filteredSections)
@@ -15224,8 +15664,7 @@ const dependencies = {
15224
15664
  let value = config2[key], current = result[key];
15225
15665
  if (current === void 0)
15226
15666
  result[key] = value;
15227
- else if (current === value || value === void 0)
15228
- ;
15667
+ else if (current === value || value === void 0) ;
15229
15668
  else if (Object.hasOwnProperty.call(combine, key))
15230
15669
  result[key] = combine[key](current, value);
15231
15670
  else
@@ -16042,8 +16481,7 @@ const dependencies = {
16042
16481
  }
16043
16482
  function render2(selectors, spec2, target, isKeyframes) {
16044
16483
  let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
16045
- if (isAt && spec2 == null)
16046
- return target.push(selectors[0] + ";");
16484
+ if (isAt && spec2 == null) return target.push(selectors[0] + ";");
16047
16485
  for (let prop in spec2) {
16048
16486
  let value = spec2[prop];
16049
16487
  if (/&/.test(prop)) {
@@ -16053,8 +16491,7 @@ const dependencies = {
16053
16491
  target
16054
16492
  );
16055
16493
  } else if (value && typeof value == "object") {
16056
- if (!isAt)
16057
- throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
16494
+ if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
16058
16495
  render2(splitSelector(prop), value, local, keyframes);
16059
16496
  } else if (value != null) {
16060
16497
  local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, (l) => "-" + l.toLowerCase()) + ": " + value + ";");
@@ -16064,8 +16501,7 @@ const dependencies = {
16064
16501
  target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
16065
16502
  }
16066
16503
  }
16067
- for (let prop in spec)
16068
- render2(splitSelector(prop), spec[prop], this.rules);
16504
+ for (let prop in spec) render2(splitSelector(prop), spec[prop], this.rules);
16069
16505
  }
16070
16506
  // :: () → string
16071
16507
  // Returns a string containing the module's CSS rules.
@@ -16097,10 +16533,8 @@ const dependencies = {
16097
16533
  // the `<style>` tag generated by the library.
16098
16534
  static mount(root, modules, options) {
16099
16535
  let set = root[SET], nonce = options && options.nonce;
16100
- if (!set)
16101
- set = new StyleSet(root, nonce);
16102
- else if (nonce)
16103
- set.setNonce(nonce);
16536
+ if (!set) set = new StyleSet(root, nonce);
16537
+ else if (nonce) set.setNonce(nonce);
16104
16538
  set.mount(Array.isArray(modules) ? modules : [modules], root);
16105
16539
  }
16106
16540
  }
@@ -16110,14 +16544,12 @@ const dependencies = {
16110
16544
  let doc2 = root.ownerDocument || root, win = doc2.defaultView;
16111
16545
  if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
16112
16546
  let adopted = adoptedSet.get(doc2);
16113
- if (adopted)
16114
- return root[SET] = adopted;
16547
+ if (adopted) return root[SET] = adopted;
16115
16548
  this.sheet = new win.CSSStyleSheet();
16116
16549
  adoptedSet.set(doc2, this);
16117
16550
  } else {
16118
16551
  this.styleTag = doc2.createElement("style");
16119
- if (nonce)
16120
- this.styleTag.setAttribute("nonce", nonce);
16552
+ if (nonce) this.styleTag.setAttribute("nonce", nonce);
16121
16553
  }
16122
16554
  this.modules = [];
16123
16555
  root[SET] = this;
@@ -16134,12 +16566,10 @@ const dependencies = {
16134
16566
  }
16135
16567
  if (index == -1) {
16136
16568
  this.modules.splice(j++, 0, mod);
16137
- if (sheet)
16138
- for (let k = 0; k < mod.rules.length; k++)
16139
- sheet.insertRule(mod.rules[k], pos++);
16569
+ if (sheet) for (let k = 0; k < mod.rules.length; k++)
16570
+ sheet.insertRule(mod.rules[k], pos++);
16140
16571
  } else {
16141
- while (j < index)
16142
- pos += this.modules[j++].rules.length;
16572
+ while (j < index) pos += this.modules[j++].rules.length;
16143
16573
  pos += mod.rules.length;
16144
16574
  j++;
16145
16575
  }
@@ -16244,32 +16674,22 @@ const dependencies = {
16244
16674
  };
16245
16675
  var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
16246
16676
  var ie$1 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
16247
- for (var i = 0; i < 10; i++)
16248
- base[48 + i] = base[96 + i] = String(i);
16249
- for (var i = 1; i <= 24; i++)
16250
- base[i + 111] = "F" + i;
16677
+ for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
16678
+ for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i;
16251
16679
  for (var i = 65; i <= 90; i++) {
16252
16680
  base[i] = String.fromCharCode(i + 32);
16253
16681
  shift[i] = String.fromCharCode(i);
16254
16682
  }
16255
- for (var code in base)
16256
- if (!shift.hasOwnProperty(code))
16257
- shift[code] = base[code];
16683
+ for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];
16258
16684
  function keyName(event) {
16259
16685
  var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie$1 && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
16260
16686
  var name2 = !ignoreKey && event.key || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified";
16261
- if (name2 == "Esc")
16262
- name2 = "Escape";
16263
- if (name2 == "Del")
16264
- name2 = "Delete";
16265
- if (name2 == "Left")
16266
- name2 = "ArrowLeft";
16267
- if (name2 == "Up")
16268
- name2 = "ArrowUp";
16269
- if (name2 == "Right")
16270
- name2 = "ArrowRight";
16271
- if (name2 == "Down")
16272
- name2 = "ArrowDown";
16687
+ if (name2 == "Esc") name2 = "Escape";
16688
+ if (name2 == "Del") name2 = "Delete";
16689
+ if (name2 == "Left") name2 = "ArrowLeft";
16690
+ if (name2 == "Up") name2 = "ArrowUp";
16691
+ if (name2 == "Right") name2 = "ArrowRight";
16692
+ if (name2 == "Down") name2 = "ArrowDown";
16273
16693
  return name2;
16274
16694
  }
16275
16695
  function getSelection(root) {
@@ -16981,7 +17401,7 @@ const dependencies = {
16981
17401
  android: /* @__PURE__ */ /Android\b/.test(nav.userAgent),
16982
17402
  webkit,
16983
17403
  safari,
16984
- webkit_version: webkit ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
17404
+ webkit_version: webkit ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
16985
17405
  tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
16986
17406
  };
16987
17407
  const MaxJoinLen = 256;
@@ -18277,40 +18697,39 @@ const dependencies = {
18277
18697
  let recurse = !sameDir && ourType == 1 ? [] : null;
18278
18698
  let localLevel = sameDir ? level : level + 1;
18279
18699
  let iScan = iCh;
18280
- run:
18281
- for (; ; ) {
18282
- if (iI < isolates.length && iScan == isolates[iI].from) {
18283
- if (isNum)
18284
- break run;
18285
- let iso = isolates[iI];
18286
- if (!sameDir)
18287
- for (let upto = iso.to, jI = iI + 1; ; ) {
18288
- if (upto == to)
18289
- break run;
18290
- if (jI < isolates.length && isolates[jI].from == upto)
18291
- upto = isolates[jI++].to;
18292
- else if (types[upto] == ourType)
18293
- break run;
18294
- else
18295
- break;
18296
- }
18297
- iI++;
18298
- if (recurse) {
18299
- recurse.push(iso);
18300
- } else {
18301
- if (iso.from > iCh)
18302
- order.push(new BidiSpan(iCh, iso.from, localLevel));
18303
- let dirSwap = iso.direction == LTR != !(localLevel % 2);
18304
- computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
18305
- iCh = iso.to;
18700
+ run: for (; ; ) {
18701
+ if (iI < isolates.length && iScan == isolates[iI].from) {
18702
+ if (isNum)
18703
+ break run;
18704
+ let iso = isolates[iI];
18705
+ if (!sameDir)
18706
+ for (let upto = iso.to, jI = iI + 1; ; ) {
18707
+ if (upto == to)
18708
+ break run;
18709
+ if (jI < isolates.length && isolates[jI].from == upto)
18710
+ upto = isolates[jI++].to;
18711
+ else if (types[upto] == ourType)
18712
+ break run;
18713
+ else
18714
+ break;
18306
18715
  }
18307
- iScan = iso.to;
18308
- } else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {
18309
- break;
18716
+ iI++;
18717
+ if (recurse) {
18718
+ recurse.push(iso);
18310
18719
  } else {
18311
- iScan++;
18720
+ if (iso.from > iCh)
18721
+ order.push(new BidiSpan(iCh, iso.from, localLevel));
18722
+ let dirSwap = iso.direction == LTR != !(localLevel % 2);
18723
+ computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
18724
+ iCh = iso.to;
18312
18725
  }
18726
+ iScan = iso.to;
18727
+ } else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {
18728
+ break;
18729
+ } else {
18730
+ iScan++;
18313
18731
  }
18732
+ }
18314
18733
  if (recurse)
18315
18734
  emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);
18316
18735
  else if (iCh < iScan)
@@ -18330,39 +18749,38 @@ const dependencies = {
18330
18749
  let recurse = !sameDir && ourType == 1 ? [] : null;
18331
18750
  let localLevel = sameDir ? level : level + 1;
18332
18751
  let iScan = iCh;
18333
- run:
18334
- for (; ; ) {
18335
- if (iI && iScan == isolates[iI - 1].to) {
18336
- if (isNum)
18337
- break run;
18338
- let iso = isolates[--iI];
18339
- if (!sameDir)
18340
- for (let upto = iso.from, jI = iI; ; ) {
18341
- if (upto == from)
18342
- break run;
18343
- if (jI && isolates[jI - 1].to == upto)
18344
- upto = isolates[--jI].from;
18345
- else if (types[upto - 1] == ourType)
18346
- break run;
18347
- else
18348
- break;
18349
- }
18350
- if (recurse) {
18351
- recurse.push(iso);
18352
- } else {
18353
- if (iso.to < iCh)
18354
- order.push(new BidiSpan(iso.to, iCh, localLevel));
18355
- let dirSwap = iso.direction == LTR != !(localLevel % 2);
18356
- computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
18357
- iCh = iso.from;
18752
+ run: for (; ; ) {
18753
+ if (iI && iScan == isolates[iI - 1].to) {
18754
+ if (isNum)
18755
+ break run;
18756
+ let iso = isolates[--iI];
18757
+ if (!sameDir)
18758
+ for (let upto = iso.from, jI = iI; ; ) {
18759
+ if (upto == from)
18760
+ break run;
18761
+ if (jI && isolates[jI - 1].to == upto)
18762
+ upto = isolates[--jI].from;
18763
+ else if (types[upto - 1] == ourType)
18764
+ break run;
18765
+ else
18766
+ break;
18358
18767
  }
18359
- iScan = iso.from;
18360
- } else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
18361
- break;
18768
+ if (recurse) {
18769
+ recurse.push(iso);
18362
18770
  } else {
18363
- iScan--;
18771
+ if (iso.to < iCh)
18772
+ order.push(new BidiSpan(iso.to, iCh, localLevel));
18773
+ let dirSwap = iso.direction == LTR != !(localLevel % 2);
18774
+ computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
18775
+ iCh = iso.from;
18364
18776
  }
18777
+ iScan = iso.from;
18778
+ } else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
18779
+ break;
18780
+ } else {
18781
+ iScan--;
18365
18782
  }
18783
+ }
18366
18784
  if (recurse)
18367
18785
  emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
18368
18786
  else if (iScan < iCh)
@@ -18457,6 +18875,7 @@ const dependencies = {
18457
18875
  }
18458
18876
  }
18459
18877
  const scrollIntoView$1 = /* @__PURE__ */ StateEffect.define({ map: (t2, ch) => t2.map(ch) });
18878
+ const setEditContextFormatting = /* @__PURE__ */ StateEffect.define();
18460
18879
  function logException(state, exception, context) {
18461
18880
  let handler = state.facet(exceptionSink);
18462
18881
  if (handler.length)
@@ -18732,10 +19151,11 @@ const dependencies = {
18732
19151
  super();
18733
19152
  this.view = view;
18734
19153
  this.decorations = [];
18735
- this.dynamicDecorationMap = [];
19154
+ this.dynamicDecorationMap = [false];
18736
19155
  this.domChanged = null;
18737
19156
  this.hasComposition = null;
18738
19157
  this.markedForComposition = /* @__PURE__ */ new Set();
19158
+ this.editContextFormatting = Decoration.none;
18739
19159
  this.lastCompositionAfterCursor = false;
18740
19160
  this.minWidth = 0;
18741
19161
  this.minWidthFrom = 0;
@@ -18762,8 +19182,9 @@ const dependencies = {
18762
19182
  this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
18763
19183
  }
18764
19184
  }
19185
+ this.updateEditContextFormatting(update);
18765
19186
  let readCompositionAt = -1;
18766
- if (this.view.inputState.composing >= 0) {
19187
+ if (this.view.inputState.composing >= 0 && !this.view.observer.editContext) {
18767
19188
  if ((_a2 = this.domChanged) === null || _a2 === void 0 ? void 0 : _a2.newSel)
18768
19189
  readCompositionAt = this.domChanged.newSel.head;
18769
19190
  else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)
@@ -18854,6 +19275,14 @@ const dependencies = {
18854
19275
  if (composition)
18855
19276
  this.fixCompositionDOM(composition);
18856
19277
  }
19278
+ updateEditContextFormatting(update) {
19279
+ this.editContextFormatting = this.editContextFormatting.map(update.changes);
19280
+ for (let tr of update.transactions)
19281
+ for (let effect of tr.effects)
19282
+ if (effect.is(setEditContextFormatting)) {
19283
+ this.editContextFormatting = effect.value;
19284
+ }
19285
+ }
18857
19286
  compositionView(composition) {
18858
19287
  let cur2 = new TextView(composition.text.nodeValue);
18859
19288
  cur2.flags |= 8;
@@ -18911,8 +19340,7 @@ const dependencies = {
18911
19340
  this.dom.focus({ preventScroll: true });
18912
19341
  }
18913
19342
  let rawSel = getSelection(this.view.root);
18914
- if (!rawSel)
18915
- ;
19343
+ if (!rawSel) ;
18916
19344
  else if (main.empty) {
18917
19345
  if (browser.gecko) {
18918
19346
  let nextTo = nextToUneditable(anchor.node, anchor.offset);
@@ -19035,6 +19463,11 @@ const dependencies = {
19035
19463
  if (start <= pos && (start < pos || child.covers(-1)) && (end2 > pos || child.covers(1)) && (!best || child instanceof LineView && !(best instanceof LineView && side >= 0))) {
19036
19464
  best = child;
19037
19465
  bestPos = start;
19466
+ } else if (best && start == pos && end2 == pos && child instanceof BlockWidgetView && Math.abs(side) < 2) {
19467
+ if (child.deco.startSide < 0)
19468
+ break;
19469
+ else if (i2)
19470
+ best = null;
19038
19471
  }
19039
19472
  off = start;
19040
19473
  }
@@ -19152,7 +19585,7 @@ const dependencies = {
19152
19585
  return Decoration.set(deco);
19153
19586
  }
19154
19587
  updateDeco() {
19155
- let i2 = 0;
19588
+ let i2 = 1;
19156
19589
  let allDeco = this.view.state.facet(decorations).map((d2) => {
19157
19590
  let dynamic = this.dynamicDecorationMap[i2++] = typeof d2 == "function";
19158
19591
  return dynamic ? d2(this.view) : d2;
@@ -19168,6 +19601,7 @@ const dependencies = {
19168
19601
  allDeco.push(RangeSet.join(outerDeco));
19169
19602
  }
19170
19603
  this.decorations = [
19604
+ this.editContextFormatting,
19171
19605
  ...allDeco,
19172
19606
  this.computeBlockGapDeco(),
19173
19607
  this.view.viewState.lineGapDeco
@@ -19681,9 +20115,9 @@ const dependencies = {
19681
20115
  this.lastScrollTop = 0;
19682
20116
  this.lastScrollLeft = 0;
19683
20117
  this.pendingIOSKey = void 0;
20118
+ this.tabFocusMode = -1;
19684
20119
  this.lastSelectionOrigin = null;
19685
20120
  this.lastSelectionTime = 0;
19686
- this.lastEscPress = 0;
19687
20121
  this.lastContextMenu = 0;
19688
20122
  this.scrollHandlers = [];
19689
20123
  this.handlers = /* @__PURE__ */ Object.create(null);
@@ -19744,10 +20178,10 @@ const dependencies = {
19744
20178
  keydown(event) {
19745
20179
  this.lastKeyCode = event.keyCode;
19746
20180
  this.lastKeyTime = Date.now();
19747
- if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2e3)
20181
+ if (event.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
19748
20182
  return true;
19749
- if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
19750
- this.view.inputState.lastEscPress = 0;
20183
+ if (this.tabFocusMode > 0 && event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
20184
+ this.tabFocusMode = -1;
19751
20185
  if (browser.android && browser.chrome && !event.synthetic && (event.keyCode == 13 || event.keyCode == 8)) {
19752
20186
  this.view.observer.delayAndroidKey(event.key, event.keyCode);
19753
20187
  return true;
@@ -19788,6 +20222,7 @@ const dependencies = {
19788
20222
  this.mouseSelection = mouseSelection;
19789
20223
  }
19790
20224
  update(update) {
20225
+ this.view.observer.update(update);
19791
20226
  if (this.mouseSelection)
19792
20227
  this.mouseSelection.update(update);
19793
20228
  if (this.draggedContent && update.docChanged)
@@ -19958,7 +20393,9 @@ const dependencies = {
19958
20393
  this.mustSelect = false;
19959
20394
  }
19960
20395
  update(update) {
19961
- if (this.style.update(update))
20396
+ if (update.transactions.some((tr) => tr.isUserEvent("input.type")))
20397
+ this.destroy();
20398
+ else if (this.style.update(update))
19962
20399
  setTimeout(() => this.select(this.lastEvent), 20);
19963
20400
  }
19964
20401
  }
@@ -20050,8 +20487,8 @@ const dependencies = {
20050
20487
  };
20051
20488
  handlers.keydown = (view, event) => {
20052
20489
  view.inputState.setSelectionOrigin("select");
20053
- if (event.keyCode == 27)
20054
- view.inputState.lastEscPress = Date.now();
20490
+ if (event.keyCode == 27 && view.inputState.tabFocusMode != 0)
20491
+ view.inputState.tabFocusMode = Date.now() + 2e3;
20055
20492
  return false;
20056
20493
  };
20057
20494
  observers.touchstart = (view, e) => {
@@ -20077,7 +20514,12 @@ const dependencies = {
20077
20514
  let mustFocus = !view.hasFocus;
20078
20515
  view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));
20079
20516
  if (mustFocus)
20080
- view.observer.ignore(() => focusPreventScroll(view.contentDOM));
20517
+ view.observer.ignore(() => {
20518
+ focusPreventScroll(view.contentDOM);
20519
+ let active = view.root.activeElement;
20520
+ if (active && !active.contains(view.contentDOM))
20521
+ active.blur();
20522
+ });
20081
20523
  let mouseSel = view.inputState.mouseSelection;
20082
20524
  if (mouseSel) {
20083
20525
  mouseSel.start(event);
@@ -20347,6 +20789,8 @@ const dependencies = {
20347
20789
  updateForFocusChange(view);
20348
20790
  };
20349
20791
  observers.compositionstart = observers.compositionupdate = (view) => {
20792
+ if (view.observer.editContext)
20793
+ return;
20350
20794
  if (view.inputState.compositionFirstChange == null)
20351
20795
  view.inputState.compositionFirstChange = true;
20352
20796
  if (view.inputState.composing < 0) {
@@ -20354,6 +20798,8 @@ const dependencies = {
20354
20798
  }
20355
20799
  };
20356
20800
  observers.compositionend = (view) => {
20801
+ if (view.observer.editContext)
20802
+ return;
20357
20803
  view.inputState.composing = -1;
20358
20804
  view.inputState.compositionEndedAt = Date.now();
20359
20805
  view.inputState.compositionPendingKey = true;
@@ -21203,9 +21649,12 @@ const dependencies = {
21203
21649
  this.heightOracle = new HeightOracle(guessWrapping);
21204
21650
  this.stateDeco = state.facet(decorations).filter((d2) => typeof d2 != "function");
21205
21651
  this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
21206
- this.viewport = this.getViewport(0, null);
21652
+ for (let i2 = 0; i2 < 2; i2++) {
21653
+ this.viewport = this.getViewport(0, null);
21654
+ if (!this.updateForViewport())
21655
+ break;
21656
+ }
21207
21657
  this.updateViewportLines();
21208
- this.updateForViewport();
21209
21658
  this.lineGaps = this.ensureLineGaps([]);
21210
21659
  this.lineGapDeco = Decoration.set(this.lineGaps.map((gap) => gap.draw(this, false)));
21211
21660
  this.computeVisibleRanges();
@@ -21220,12 +21669,17 @@ const dependencies = {
21220
21669
  }
21221
21670
  }
21222
21671
  this.viewports = viewports.sort((a, b) => a.from - b.from);
21672
+ return this.updateScaler();
21673
+ }
21674
+ updateScaler() {
21675
+ let scaler = this.scaler;
21223
21676
  this.scaler = this.heightMap.height <= 7e6 ? IdScaler : new BigScaler(this.heightOracle, this.heightMap, this.viewports);
21677
+ return scaler.eq(this.scaler) ? 0 : 2;
21224
21678
  }
21225
21679
  updateViewportLines() {
21226
21680
  this.viewportLines = [];
21227
21681
  this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, (block) => {
21228
- this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock(block, this.scaler));
21682
+ this.viewportLines.push(scaleBlock(block, this.scaler));
21229
21683
  });
21230
21684
  }
21231
21685
  update(update, scrollTarget = null) {
@@ -21249,10 +21703,10 @@ const dependencies = {
21249
21703
  let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
21250
21704
  if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) || !this.viewportIsAppropriate(viewport))
21251
21705
  viewport = this.getViewport(0, scrollTarget);
21252
- let updateLines = !update.changes.empty || update.flags & 2 || viewport.from != this.viewport.from || viewport.to != this.viewport.to;
21706
+ let viewportChange = viewport.from != this.viewport.from || viewport.to != this.viewport.to;
21253
21707
  this.viewport = viewport;
21254
- this.updateForViewport();
21255
- if (updateLines)
21708
+ update.flags |= this.updateForViewport();
21709
+ if (viewportChange || !update.changes.empty || update.flags & 2)
21256
21710
  this.updateViewportLines();
21257
21711
  if (this.lineGaps.length || this.viewport.to - this.viewport.from > 2e3 << 1)
21258
21712
  this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
@@ -21343,9 +21797,12 @@ const dependencies = {
21343
21797
  result |= 2;
21344
21798
  }
21345
21799
  let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
21346
- if (viewportChange)
21800
+ if (viewportChange) {
21801
+ if (result & 2)
21802
+ result |= this.updateScaler();
21347
21803
  this.viewport = this.getViewport(bias, this.scrollTarget);
21348
- this.updateForViewport();
21804
+ result |= this.updateForViewport();
21805
+ }
21349
21806
  if (result & 2 || viewportChange)
21350
21807
  this.updateViewportLines();
21351
21808
  if (this.lineGaps.length || this.viewport.to - this.viewport.from > 2e3 << 1)
@@ -21452,12 +21909,12 @@ const dependencies = {
21452
21909
  }
21453
21910
  gaps.push(gap);
21454
21911
  };
21455
- for (let line of this.viewportLines) {
21456
- if (line.length < doubleMargin)
21457
- continue;
21912
+ let checkLine = (line) => {
21913
+ if (line.length < doubleMargin || line.type != BlockType.Text)
21914
+ return;
21458
21915
  let structure = lineStructure(line.from, line.to, this.stateDeco);
21459
21916
  if (structure.total < doubleMargin)
21460
- continue;
21917
+ return;
21461
21918
  let target = this.scrollTarget ? this.scrollTarget.range.head : null;
21462
21919
  let viewFrom, viewTo;
21463
21920
  if (wrapping) {
@@ -21494,6 +21951,12 @@ const dependencies = {
21494
21951
  addGap(line.from, viewFrom, line, structure);
21495
21952
  if (viewTo < line.to)
21496
21953
  addGap(viewTo, line.to, line, structure);
21954
+ };
21955
+ for (let line of this.viewportLines) {
21956
+ if (Array.isArray(line.type))
21957
+ line.type.forEach(checkLine);
21958
+ else
21959
+ checkLine(line);
21497
21960
  }
21498
21961
  return gaps;
21499
21962
  }
@@ -21531,7 +21994,7 @@ const dependencies = {
21531
21994
  return pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find((b) => b.from <= pos && b.to >= pos) || scaleBlock(this.heightMap.lineAt(pos, QueryType$1.ByPos, this.heightOracle, 0, 0), this.scaler);
21532
21995
  }
21533
21996
  lineBlockAtHeight(height) {
21534
- return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$1.ByHeight, this.heightOracle, 0, 0), this.scaler);
21997
+ return height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom && this.viewportLines.find((l) => l.top <= height && l.bottom >= height) || scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$1.ByHeight, this.heightOracle, 0, 0), this.scaler);
21535
21998
  }
21536
21999
  scrollAnchorAt(scrollTop) {
21537
22000
  let block = this.lineBlockAtHeight(scrollTop + 8);
@@ -21609,7 +22072,10 @@ const dependencies = {
21609
22072
  fromDOM(n) {
21610
22073
  return n;
21611
22074
  },
21612
- scale: 1
22075
+ scale: 1,
22076
+ eq(other) {
22077
+ return other == this;
22078
+ }
21613
22079
  };
21614
22080
  class BigScaler {
21615
22081
  constructor(oracle, heightMap, viewports) {
@@ -21649,6 +22115,11 @@ const dependencies = {
21649
22115
  domBase = vp.domBottom;
21650
22116
  }
21651
22117
  }
22118
+ eq(other) {
22119
+ if (!(other instanceof BigScaler))
22120
+ return false;
22121
+ return this.scale == other.scale && this.viewports.length == other.viewports.length && this.viewports.every((vp, i2) => vp.from == other.viewports[i2].from && vp.to == other.viewports[i2].to);
22122
+ }
21652
22123
  }
21653
22124
  function scaleBlock(block, scaler) {
21654
22125
  if (scaler.scale == 1)
@@ -22036,6 +22507,7 @@ const dependencies = {
22036
22507
  this.typeOver = typeOver;
22037
22508
  this.bounds = null;
22038
22509
  this.text = "";
22510
+ this.domChanged = start > -1;
22039
22511
  let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
22040
22512
  if (view.state.readOnly && start > -1) {
22041
22513
  this.newSel = null;
@@ -22106,20 +22578,7 @@ const dependencies = {
22106
22578
  change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
22107
22579
  }
22108
22580
  if (change) {
22109
- if (browser.ios && view.inputState.flushIOSKey(change))
22110
- return true;
22111
- if (browser.android && (change.to == sel.to && // GBoard will sometimes remove a space it just inserted
22112
- // after a completion when you press enter
22113
- (change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 || lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46)))
22114
- return true;
22115
- let text = change.insert.toString();
22116
- if (view.inputState.composing >= 0)
22117
- view.inputState.composing++;
22118
- let defaultTr;
22119
- let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
22120
- if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to, text, defaultInsert)))
22121
- view.dispatch(defaultInsert());
22122
- return true;
22581
+ return applyDOMChangeInner(view, change, newSel, lastKey);
22123
22582
  } else if (newSel && !newSel.main.eq(sel)) {
22124
22583
  let scrollIntoView2 = false, userEvent = "select";
22125
22584
  if (view.inputState.lastSelectionTime > Date.now() - 50) {
@@ -22133,6 +22592,23 @@ const dependencies = {
22133
22592
  return false;
22134
22593
  }
22135
22594
  }
22595
+ function applyDOMChangeInner(view, change, newSel, lastKey = -1) {
22596
+ if (browser.ios && view.inputState.flushIOSKey(change))
22597
+ return true;
22598
+ let sel = view.state.selection.main;
22599
+ if (browser.android && (change.to == sel.to && // GBoard will sometimes remove a space it just inserted
22600
+ // after a completion when you press enter
22601
+ (change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 || lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46)))
22602
+ return true;
22603
+ let text = change.insert.toString();
22604
+ if (view.inputState.composing >= 0)
22605
+ view.inputState.composing++;
22606
+ let defaultTr;
22607
+ let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
22608
+ if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to, text, defaultInsert)))
22609
+ view.dispatch(defaultInsert());
22610
+ return true;
22611
+ }
22136
22612
  function applyDefaultInsert(view, change, newSel) {
22137
22613
  let tr, startState = view.state, sel = startState.selection.main;
22138
22614
  if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 && (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) && view.inputState.composing < 0) {
@@ -22245,6 +22721,7 @@ const dependencies = {
22245
22721
  constructor(view) {
22246
22722
  this.view = view;
22247
22723
  this.active = false;
22724
+ this.editContext = null;
22248
22725
  this.selectionRange = new DOMSelectionState();
22249
22726
  this.selectionChanged = false;
22250
22727
  this.delayedFlush = -1;
@@ -22270,6 +22747,11 @@ const dependencies = {
22270
22747
  else
22271
22748
  this.flush();
22272
22749
  });
22750
+ if (window.EditContext && view.constructor.EDIT_CONTEXT === true) {
22751
+ this.editContext = new EditContextManager(view);
22752
+ if (view.state.facet(editable))
22753
+ view.contentDOM.editContext = this.editContext.editContext;
22754
+ }
22273
22755
  if (useCharData)
22274
22756
  this.onCharData = (event) => {
22275
22757
  this.queue.push({
@@ -22322,6 +22804,8 @@ const dependencies = {
22322
22804
  onScroll(e) {
22323
22805
  if (this.intersecting)
22324
22806
  this.flush(false);
22807
+ if (this.editContext)
22808
+ this.view.requestMeasure(this.editContext.measureReq);
22325
22809
  this.onScrollChanged(e);
22326
22810
  }
22327
22811
  onResize() {
@@ -22559,7 +23043,7 @@ const dependencies = {
22559
23043
  }
22560
23044
  let startState = this.view.state;
22561
23045
  let handled = applyDOMChange(this.view, domChange);
22562
- if (this.view.state == startState)
23046
+ if (this.view.state == startState && (domChange.domChanged || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main)))
22563
23047
  this.view.update([]);
22564
23048
  return handled;
22565
23049
  }
@@ -22609,6 +23093,13 @@ const dependencies = {
22609
23093
  win.removeEventListener("beforeprint", this.onPrint);
22610
23094
  win.document.removeEventListener("selectionchange", this.onSelectionChange);
22611
23095
  }
23096
+ update(update) {
23097
+ if (this.editContext) {
23098
+ this.editContext.update(update);
23099
+ if (update.startState.facet(editable) != update.state.facet(editable))
23100
+ update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
23101
+ }
23102
+ }
22612
23103
  destroy() {
22613
23104
  var _a2, _b, _c;
22614
23105
  this.stop();
@@ -22659,6 +23150,155 @@ const dependencies = {
22659
23150
  view.contentDOM.removeEventListener("beforeinput", read, true);
22660
23151
  return found ? buildSelectionRangeFromRange(view, found) : null;
22661
23152
  }
23153
+ class EditContextManager {
23154
+ constructor(view) {
23155
+ this.from = 0;
23156
+ this.to = 0;
23157
+ this.pendingContextChange = null;
23158
+ this.resetRange(view.state);
23159
+ let context = this.editContext = new window.EditContext({
23160
+ text: view.state.doc.sliceString(this.from, this.to),
23161
+ selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, view.state.selection.main.anchor))),
23162
+ selectionEnd: this.toContextPos(view.state.selection.main.head)
23163
+ });
23164
+ context.addEventListener("textupdate", (e) => {
23165
+ let { anchor } = view.state.selection.main;
23166
+ let change = {
23167
+ from: this.toEditorPos(e.updateRangeStart),
23168
+ to: this.toEditorPos(e.updateRangeEnd),
23169
+ insert: Text.of(e.text.split("\n"))
23170
+ };
23171
+ if (change.from == this.from && anchor < this.from)
23172
+ change.from = anchor;
23173
+ else if (change.to == this.to && anchor > this.to)
23174
+ change.to = anchor;
23175
+ if (change.from == change.to && !change.insert.length)
23176
+ return;
23177
+ this.pendingContextChange = change;
23178
+ applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd)));
23179
+ if (this.pendingContextChange)
23180
+ this.revertPending(view.state);
23181
+ });
23182
+ context.addEventListener("characterboundsupdate", (e) => {
23183
+ let rects = [], prev = null;
23184
+ for (let i2 = this.toEditorPos(e.rangeStart), end2 = this.toEditorPos(e.rangeEnd); i2 < end2; i2++) {
23185
+ let rect = view.coordsForChar(i2);
23186
+ prev = rect && new DOMRect(rect.left, rect.right, rect.right - rect.left, rect.bottom - rect.top) || prev || new DOMRect();
23187
+ rects.push(prev);
23188
+ }
23189
+ context.updateCharacterBounds(e.rangeStart, rects);
23190
+ });
23191
+ context.addEventListener("textformatupdate", (e) => {
23192
+ let deco = [];
23193
+ for (let format of e.getTextFormats()) {
23194
+ let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
23195
+ if (lineStyle != "None" && thickness != "None") {
23196
+ let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
23197
+ deco.push(Decoration.mark({ attributes: { style } }).range(this.toEditorPos(format.rangeStart), this.toEditorPos(format.rangeEnd)));
23198
+ }
23199
+ }
23200
+ view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
23201
+ });
23202
+ context.addEventListener("compositionstart", () => {
23203
+ if (view.inputState.composing < 0) {
23204
+ view.inputState.composing = 0;
23205
+ view.inputState.compositionFirstChange = true;
23206
+ }
23207
+ });
23208
+ context.addEventListener("compositionend", () => {
23209
+ view.inputState.composing = -1;
23210
+ view.inputState.compositionFirstChange = null;
23211
+ });
23212
+ this.measureReq = { read: (view2) => {
23213
+ this.editContext.updateControlBounds(view2.contentDOM.getBoundingClientRect());
23214
+ let sel = getSelection(view2.root);
23215
+ if (sel && sel.rangeCount)
23216
+ this.editContext.updateSelectionBounds(sel.getRangeAt(0).getBoundingClientRect());
23217
+ } };
23218
+ }
23219
+ applyEdits(update) {
23220
+ let off = 0, abort = false, pending = this.pendingContextChange;
23221
+ update.changes.iterChanges((fromA, toA, _fromB, _toB, insert2) => {
23222
+ if (abort)
23223
+ return;
23224
+ let dLen = insert2.length - (toA - fromA);
23225
+ if (pending && toA >= pending.to) {
23226
+ if (pending.from == fromA && pending.to == toA && pending.insert.eq(insert2)) {
23227
+ pending = this.pendingContextChange = null;
23228
+ off += dLen;
23229
+ return;
23230
+ } else {
23231
+ pending = null;
23232
+ this.revertPending(update.state);
23233
+ }
23234
+ }
23235
+ fromA += off;
23236
+ toA += off;
23237
+ if (toA <= this.from) {
23238
+ this.from += dLen;
23239
+ this.to += dLen;
23240
+ } else if (fromA < this.to) {
23241
+ if (fromA < this.from || toA > this.to || this.to - this.from + insert2.length > 3e4) {
23242
+ abort = true;
23243
+ return;
23244
+ }
23245
+ this.editContext.updateText(this.toContextPos(fromA), this.toContextPos(toA), insert2.toString());
23246
+ this.to += dLen;
23247
+ }
23248
+ off += dLen;
23249
+ });
23250
+ if (pending && !abort)
23251
+ this.revertPending(update.state);
23252
+ return !abort;
23253
+ }
23254
+ update(update) {
23255
+ if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {
23256
+ this.pendingContextChange = null;
23257
+ this.resetRange(update.state);
23258
+ this.editContext.updateText(0, this.editContext.text.length, update.state.doc.sliceString(this.from, this.to));
23259
+ this.setSelection(update.state);
23260
+ } else if (update.docChanged || update.selectionSet) {
23261
+ this.setSelection(update.state);
23262
+ }
23263
+ if (update.geometryChanged || update.docChanged || update.selectionSet)
23264
+ update.view.requestMeasure(this.measureReq);
23265
+ }
23266
+ resetRange(state) {
23267
+ let { head } = state.selection.main;
23268
+ this.from = Math.max(
23269
+ 0,
23270
+ head - 1e4
23271
+ /* CxVp.Margin */
23272
+ );
23273
+ this.to = Math.min(
23274
+ state.doc.length,
23275
+ head + 1e4
23276
+ /* CxVp.Margin */
23277
+ );
23278
+ }
23279
+ revertPending(state) {
23280
+ let pending = this.pendingContextChange;
23281
+ this.pendingContextChange = null;
23282
+ this.editContext.updateText(this.toContextPos(pending.from), this.toContextPos(pending.to + pending.insert.length), state.doc.sliceString(pending.from, pending.to));
23283
+ }
23284
+ setSelection(state) {
23285
+ let { main } = state.selection;
23286
+ let start = this.toContextPos(Math.max(this.from, Math.min(this.to, main.anchor)));
23287
+ let end2 = this.toContextPos(main.head);
23288
+ if (this.editContext.selectionStart != start || this.editContext.selectionEnd != end2)
23289
+ this.editContext.updateSelection(start, end2);
23290
+ }
23291
+ rangeIsValid(state) {
23292
+ let { head } = state.selection.main;
23293
+ return !(this.from > 0 && head - this.from < 500 || this.to < state.doc.length && this.to - head < 500 || this.to - this.from > 1e4 * 3);
23294
+ }
23295
+ toEditorPos(contextPos) {
23296
+ return contextPos + this.from;
23297
+ }
23298
+ toContextPos(editorPos) {
23299
+ return editorPos - this.from;
23300
+ }
23301
+ }
22662
23302
  class EditorView {
22663
23303
  /**
22664
23304
  The current editor state.
@@ -23443,6 +24083,8 @@ const dependencies = {
23443
24083
  calling this.
23444
24084
  */
23445
24085
  destroy() {
24086
+ if (this.root.activeElement == this.contentDOM)
24087
+ this.contentDOM.blur();
23446
24088
  for (let plugin of this.plugins)
23447
24089
  plugin.destroy(this);
23448
24090
  this.plugins = [];
@@ -23480,6 +24122,25 @@ const dependencies = {
23480
24122
  return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(ref.from), "start", "start", ref.top - scrollTop, scrollLeft, true));
23481
24123
  }
23482
24124
  /**
24125
+ Enable or disable tab-focus mode, which disables key bindings
24126
+ for Tab and Shift-Tab, letting the browser's default
24127
+ focus-changing behavior go through instead. This is useful to
24128
+ prevent trapping keyboard users in your editor.
24129
+
24130
+ Without argument, this toggles the mode. With a boolean, it
24131
+ enables (true) or disables it (false). Given a number, it
24132
+ temporarily enables the mode until that number of milliseconds
24133
+ have passed or another non-Tab key is pressed.
24134
+ */
24135
+ setTabFocusMode(to) {
24136
+ if (to == null)
24137
+ this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1;
24138
+ else if (typeof to == "boolean")
24139
+ this.inputState.tabFocusMode = to ? 0 : -1;
24140
+ else if (this.inputState.tabFocusMode != 0)
24141
+ this.inputState.tabFocusMode = Date.now() + to;
24142
+ }
24143
+ /**
23483
24144
  Returns an extension that can be used to add DOM event handlers.
23484
24145
  The value should be an object mapping event names to handler
23485
24146
  functions. For any given event, such functions are ordered by
@@ -23721,8 +24382,9 @@ const dependencies = {
23721
24382
  let scopeObj = bound[scope] || (bound[scope] = /* @__PURE__ */ Object.create(null));
23722
24383
  if (!scopeObj._any)
23723
24384
  scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };
24385
+ let { any } = b;
23724
24386
  for (let key in scopeObj)
23725
- scopeObj[key].run.push(b.any);
24387
+ scopeObj[key].run.push((view) => any(view, currentKeyEvent));
23726
24388
  }
23727
24389
  let name2 = b[platform] || b.key;
23728
24390
  if (!name2)
@@ -23735,7 +24397,9 @@ const dependencies = {
23735
24397
  }
23736
24398
  return bound;
23737
24399
  }
24400
+ let currentKeyEvent = null;
23738
24401
  function runHandlers(map, event, view, scope) {
24402
+ currentKeyEvent = event;
23739
24403
  let name2 = keyName(event);
23740
24404
  let charCode = codePointAt(name2, 0), isChar = codePointSize(charCode) == name2.length && name2 != " ";
23741
24405
  let prefix = "", handled = false, prevented = false, stopPropagation = false;
@@ -23752,7 +24416,7 @@ const dependencies = {
23752
24416
  for (let cmd2 of binding.run)
23753
24417
  if (!ran.has(cmd2)) {
23754
24418
  ran.add(cmd2);
23755
- if (cmd2(view, event)) {
24419
+ if (cmd2(view)) {
23756
24420
  if (binding.stopPropagation)
23757
24421
  stopPropagation = true;
23758
24422
  return true;
@@ -23787,6 +24451,7 @@ const dependencies = {
23787
24451
  handled = true;
23788
24452
  if (handled && stopPropagation)
23789
24453
  event.stopPropagation();
24454
+ currentKeyEvent = null;
23790
24455
  return handled;
23791
24456
  }
23792
24457
  class RectangleMarker {
@@ -23847,13 +24512,17 @@ const dependencies = {
23847
24512
  let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;
23848
24513
  return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };
23849
24514
  }
23850
- function wrappedLine(view, pos, inside2) {
23851
- let range = EditorSelection.cursor(pos);
23852
- return {
23853
- from: Math.max(inside2.from, view.moveToLineBoundary(range, false, true).from),
23854
- to: Math.min(inside2.to, view.moveToLineBoundary(range, true, true).from),
23855
- type: BlockType.Text
23856
- };
24515
+ function wrappedLine(view, pos, side, inside2) {
24516
+ let coords = view.coordsAtPos(pos, side * 2);
24517
+ if (!coords)
24518
+ return inside2;
24519
+ let editorRect = view.dom.getBoundingClientRect();
24520
+ let y = (coords.top + coords.bottom) / 2;
24521
+ let left = view.posAtCoords({ x: editorRect.left + 1, y });
24522
+ let right = view.posAtCoords({ x: editorRect.right - 1, y });
24523
+ if (left == null || right == null)
24524
+ return inside2;
24525
+ return { from: Math.max(inside2.from, Math.min(left, right)), to: Math.min(inside2.to, Math.max(left, right)) };
23857
24526
  }
23858
24527
  function rectanglesForRange(view, className, range) {
23859
24528
  if (range.to <= view.viewport.from || range.from >= view.viewport.to)
@@ -23868,10 +24537,10 @@ const dependencies = {
23868
24537
  let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
23869
24538
  let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
23870
24539
  if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
23871
- visualStart = wrappedLine(view, from, visualStart);
24540
+ visualStart = wrappedLine(view, from, 1, visualStart);
23872
24541
  if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
23873
- visualEnd = wrappedLine(view, to, visualEnd);
23874
- if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
24542
+ visualEnd = wrappedLine(view, to, -1, visualEnd);
24543
+ if (visualStart && visualEnd && visualStart.from == visualEnd.from && visualStart.to == visualEnd.to) {
23875
24544
  return pieces(drawForLine(range.from, range.to, visualStart));
23876
24545
  } else {
23877
24546
  let top2 = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
@@ -24092,14 +24761,19 @@ const dependencies = {
24092
24761
  });
24093
24762
  const themeSpec = {
24094
24763
  ".cm-line": {
24095
- "& ::selection": { backgroundColor: "transparent !important" },
24096
- "&::selection": { backgroundColor: "transparent !important" }
24764
+ "& ::selection, &::selection": { backgroundColor: "transparent !important" }
24765
+ },
24766
+ ".cm-content": {
24767
+ "& :focus": {
24768
+ caretColor: "initial !important",
24769
+ "&::selection, & ::selection": {
24770
+ backgroundColor: "Highlight !important"
24771
+ }
24772
+ }
24097
24773
  }
24098
24774
  };
24099
- if (CanHidePrimary) {
24100
- themeSpec[".cm-line"].caretColor = "transparent !important";
24101
- themeSpec[".cm-content"] = { caretColor: "transparent !important" };
24102
- }
24775
+ if (CanHidePrimary)
24776
+ themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
24103
24777
  const hideNativeSelection = /* @__PURE__ */ Prec.highest(/* @__PURE__ */ EditorView.theme(themeSpec));
24104
24778
  const setDropCursorPos = /* @__PURE__ */ StateEffect.define({
24105
24779
  map(pos, mapping) {
@@ -26933,18 +27607,17 @@ const dependencies = {
26933
27607
  return this._tree;
26934
27608
  let cache = this.bufferNode, result = null, depth = 0;
26935
27609
  if (cache && cache.context == this.buffer) {
26936
- scan:
26937
- for (let index = this.index, d2 = this.stack.length; d2 >= 0; ) {
26938
- for (let c = cache; c; c = c._parent)
26939
- if (c.index == index) {
26940
- if (index == this.index)
26941
- return c;
26942
- result = c;
26943
- depth = d2 + 1;
26944
- break scan;
26945
- }
26946
- index = this.stack[--d2];
26947
- }
27610
+ scan: for (let index = this.index, d2 = this.stack.length; d2 >= 0; ) {
27611
+ for (let c = cache; c; c = c._parent)
27612
+ if (c.index == index) {
27613
+ if (index == this.index)
27614
+ return c;
27615
+ result = c;
27616
+ depth = d2 + 1;
27617
+ break scan;
27618
+ }
27619
+ index = this.stack[--d2];
27620
+ }
26948
27621
  }
26949
27622
  for (let i2 = depth; i2 < this.stack.length; i2++)
26950
27623
  result = new BufferNode(this.buffer, result, this.stack[i2]);
@@ -27149,39 +27822,38 @@ const dependencies = {
27149
27822
  let fork = cursor.fork();
27150
27823
  let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
27151
27824
  let result = { size: 0, start: 0, skip: 0 };
27152
- scan:
27153
- for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
27154
- let nodeSize2 = fork.size;
27155
- if (fork.id == inRepeat && nodeSize2 >= 0) {
27156
- result.size = size;
27157
- result.start = start;
27158
- result.skip = skip;
27159
- skip += 4;
27160
- size += 4;
27161
- fork.next();
27162
- continue;
27163
- }
27164
- let startPos = fork.pos - nodeSize2;
27165
- if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
27166
- break;
27167
- let localSkipped = fork.id >= minRepeatType ? 4 : 0;
27168
- let nodeStart2 = fork.start;
27825
+ scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
27826
+ let nodeSize2 = fork.size;
27827
+ if (fork.id == inRepeat && nodeSize2 >= 0) {
27828
+ result.size = size;
27829
+ result.start = start;
27830
+ result.skip = skip;
27831
+ skip += 4;
27832
+ size += 4;
27169
27833
  fork.next();
27170
- while (fork.pos > startPos) {
27171
- if (fork.size < 0) {
27172
- if (fork.size == -3)
27173
- localSkipped += 4;
27174
- else
27175
- break scan;
27176
- } else if (fork.id >= minRepeatType) {
27834
+ continue;
27835
+ }
27836
+ let startPos = fork.pos - nodeSize2;
27837
+ if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
27838
+ break;
27839
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0;
27840
+ let nodeStart2 = fork.start;
27841
+ fork.next();
27842
+ while (fork.pos > startPos) {
27843
+ if (fork.size < 0) {
27844
+ if (fork.size == -3)
27177
27845
  localSkipped += 4;
27178
- }
27179
- fork.next();
27846
+ else
27847
+ break scan;
27848
+ } else if (fork.id >= minRepeatType) {
27849
+ localSkipped += 4;
27180
27850
  }
27181
- start = nodeStart2;
27182
- size += nodeSize2;
27183
- skip += localSkipped;
27851
+ fork.next();
27184
27852
  }
27853
+ start = nodeStart2;
27854
+ size += nodeSize2;
27855
+ skip += localSkipped;
27856
+ }
27185
27857
  if (inRepeat < 0 || size == maxSize) {
27186
27858
  result.size = size;
27187
27859
  result.start = start;
@@ -30670,6 +31342,10 @@ const dependencies = {
30670
31342
  }), { userEvent: "delete.dedent" }));
30671
31343
  return true;
30672
31344
  };
31345
+ const toggleTabFocusMode = (view) => {
31346
+ view.setTabFocusMode();
31347
+ return true;
31348
+ };
30673
31349
  const emacsStyleKeymap = [
30674
31350
  { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
30675
31351
  { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight },
@@ -30730,38 +31406,32 @@ const dependencies = {
30730
31406
  { key: "Shift-Mod-k", run: deleteLine },
30731
31407
  { key: "Shift-Mod-\\", run: cursorMatchingBracket },
30732
31408
  { key: "Mod-/", run: toggleComment },
30733
- { key: "Alt-A", run: toggleBlockComment }
31409
+ { key: "Alt-A", run: toggleBlockComment },
31410
+ { key: "Ctrl-m", mac: "Shift-Alt-m", run: toggleTabFocusMode }
30734
31411
  ].concat(standardKeymap);
30735
31412
  function crelt() {
30736
31413
  var elt = arguments[0];
30737
- if (typeof elt == "string")
30738
- elt = document.createElement(elt);
31414
+ if (typeof elt == "string") elt = document.createElement(elt);
30739
31415
  var i2 = 1, next = arguments[1];
30740
31416
  if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
30741
- for (var name2 in next)
30742
- if (Object.prototype.hasOwnProperty.call(next, name2)) {
30743
- var value = next[name2];
30744
- if (typeof value == "string")
30745
- elt.setAttribute(name2, value);
30746
- else if (value != null)
30747
- elt[name2] = value;
30748
- }
31417
+ for (var name2 in next) if (Object.prototype.hasOwnProperty.call(next, name2)) {
31418
+ var value = next[name2];
31419
+ if (typeof value == "string") elt.setAttribute(name2, value);
31420
+ else if (value != null) elt[name2] = value;
31421
+ }
30749
31422
  i2++;
30750
31423
  }
30751
- for (; i2 < arguments.length; i2++)
30752
- add(elt, arguments[i2]);
31424
+ for (; i2 < arguments.length; i2++) add(elt, arguments[i2]);
30753
31425
  return elt;
30754
31426
  }
30755
31427
  function add(elt, child) {
30756
31428
  if (typeof child == "string") {
30757
31429
  elt.appendChild(document.createTextNode(child));
30758
- } else if (child == null)
30759
- ;
31430
+ } else if (child == null) ;
30760
31431
  else if (child.nodeType != null) {
30761
31432
  elt.appendChild(child);
30762
31433
  } else if (Array.isArray(child)) {
30763
- for (var i2 = 0; i2 < child.length; i2++)
30764
- add(elt, child[i2]);
31434
+ for (var i2 = 0; i2 < child.length; i2++) add(elt, child[i2]);
30765
31435
  } else {
30766
31436
  throw new RangeError("Unsupported child node: " + child);
30767
31437
  }
@@ -32003,8 +32673,7 @@ const dependencies = {
32003
32673
  if (chars.length == 1) {
32004
32674
  let first = codePointAt(word, 0), firstSize = codePointSize(first);
32005
32675
  let score2 = firstSize == word.length ? 0 : -100;
32006
- if (first == chars[0])
32007
- ;
32676
+ if (first == chars[0]) ;
32008
32677
  else if (first == folded[0])
32009
32678
  score2 += -200;
32010
32679
  else
@@ -33549,17 +34218,16 @@ const dependencies = {
33549
34218
  function assignKeys(actions) {
33550
34219
  let assigned = [];
33551
34220
  if (actions)
33552
- actions:
33553
- for (let { name: name2 } of actions) {
33554
- for (let i2 = 0; i2 < name2.length; i2++) {
33555
- let ch = name2[i2];
33556
- if (/[a-zA-Z]/.test(ch) && !assigned.some((c) => c.toLowerCase() == ch.toLowerCase())) {
33557
- assigned.push(ch);
33558
- continue actions;
33559
- }
34221
+ actions: for (let { name: name2 } of actions) {
34222
+ for (let i2 = 0; i2 < name2.length; i2++) {
34223
+ let ch = name2[i2];
34224
+ if (/[a-zA-Z]/.test(ch) && !assigned.some((c) => c.toLowerCase() == ch.toLowerCase())) {
34225
+ assigned.push(ch);
34226
+ continue actions;
33560
34227
  }
33561
- assigned.push("");
33562
34228
  }
34229
+ assigned.push("");
34230
+ }
33563
34231
  return assigned;
33564
34232
  }
33565
34233
  function renderDiagnostic(view, diagnostic, inPanel) {
@@ -33900,19 +34568,14 @@ const dependencies = {
33900
34568
  return state.context = state.context.prev;
33901
34569
  }
33902
34570
  function typeBefore(stream, state, pos) {
33903
- if (state.prevToken == "variable" || state.prevToken == "type")
33904
- return true;
33905
- if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos)))
33906
- return true;
33907
- if (state.typeAtEndOfLine && stream.column() == stream.indentation())
33908
- return true;
34571
+ if (state.prevToken == "variable" || state.prevToken == "type") return true;
34572
+ if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
34573
+ if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
33909
34574
  }
33910
34575
  function isTopScope(context) {
33911
34576
  for (; ; ) {
33912
- if (!context || context.type == "top")
33913
- return true;
33914
- if (context.type == "}" && context.prev.info != "namespace")
33915
- return false;
34577
+ if (!context || context.type == "top") return true;
34578
+ if (context.type == "}" && context.prev.info != "namespace") return false;
33916
34579
  context = context.prev;
33917
34580
  }
33918
34581
  }
@@ -33923,8 +34586,7 @@ const dependencies = {
33923
34586
  var ch = stream.next();
33924
34587
  if (hooks[ch]) {
33925
34588
  var result = hooks[ch](stream, state);
33926
- if (result !== false)
33927
- return result;
34589
+ if (result !== false) return result;
33928
34590
  }
33929
34591
  if (ch == '"' || ch == "'") {
33930
34592
  state.tokenize = tokenString(ch);
@@ -33932,8 +34594,7 @@ const dependencies = {
33932
34594
  }
33933
34595
  if (numberStart.test(ch)) {
33934
34596
  stream.backUp(1);
33935
- if (stream.match(number2))
33936
- return "number";
34597
+ if (stream.match(number2)) return "number";
33937
34598
  stream.next();
33938
34599
  }
33939
34600
  if (isPunctuationChar.test(ch)) {
@@ -33956,26 +34617,20 @@ const dependencies = {
33956
34617
  return "operator";
33957
34618
  }
33958
34619
  stream.eatWhile(isIdentifierChar);
33959
- if (namespaceSeparator)
33960
- while (stream.match(namespaceSeparator))
33961
- stream.eatWhile(isIdentifierChar);
34620
+ if (namespaceSeparator) while (stream.match(namespaceSeparator))
34621
+ stream.eatWhile(isIdentifierChar);
33962
34622
  var cur2 = stream.current();
33963
34623
  if (contains(keywords2, cur2)) {
33964
- if (contains(blockKeywords, cur2))
33965
- curPunc = "newstatement";
33966
- if (contains(defKeywords, cur2))
33967
- isDefKeyword = true;
34624
+ if (contains(blockKeywords, cur2)) curPunc = "newstatement";
34625
+ if (contains(defKeywords, cur2)) isDefKeyword = true;
33968
34626
  return "keyword";
33969
34627
  }
33970
- if (contains(types2, cur2))
33971
- return "type";
34628
+ if (contains(types2, cur2)) return "type";
33972
34629
  if (contains(builtin, cur2) || isReservedIdentifier && isReservedIdentifier(cur2)) {
33973
- if (contains(blockKeywords, cur2))
33974
- curPunc = "newstatement";
34630
+ if (contains(blockKeywords, cur2)) curPunc = "newstatement";
33975
34631
  return "builtin";
33976
34632
  }
33977
- if (contains(atoms2, cur2))
33978
- return "atom";
34633
+ if (contains(atoms2, cur2)) return "atom";
33979
34634
  return "variable";
33980
34635
  }
33981
34636
  function tokenString(quote) {
@@ -34022,8 +34677,7 @@ const dependencies = {
34022
34677
  token: function(stream, state) {
34023
34678
  var ctx = state.context;
34024
34679
  if (stream.sol()) {
34025
- if (ctx.align == null)
34026
- ctx.align = false;
34680
+ if (ctx.align == null) ctx.align = false;
34027
34681
  state.indented = stream.indentation();
34028
34682
  state.startOfLine = true;
34029
34683
  }
@@ -34033,28 +34687,18 @@ const dependencies = {
34033
34687
  }
34034
34688
  curPunc = isDefKeyword = null;
34035
34689
  var style = (state.tokenize || tokenBase)(stream, state);
34036
- if (style == "comment" || style == "meta")
34037
- return style;
34038
- if (ctx.align == null)
34039
- ctx.align = true;
34690
+ if (style == "comment" || style == "meta") return style;
34691
+ if (ctx.align == null) ctx.align = true;
34040
34692
  if (curPunc == ";" || curPunc == ":" || curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false))
34041
- while (state.context.type == "statement")
34042
- popContext(state);
34043
- else if (curPunc == "{")
34044
- pushContext(state, stream.column(), "}");
34045
- else if (curPunc == "[")
34046
- pushContext(state, stream.column(), "]");
34047
- else if (curPunc == "(")
34048
- pushContext(state, stream.column(), ")");
34693
+ while (state.context.type == "statement") popContext(state);
34694
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
34695
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
34696
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
34049
34697
  else if (curPunc == "}") {
34050
- while (ctx.type == "statement")
34051
- ctx = popContext(state);
34052
- if (ctx.type == "}")
34053
- ctx = popContext(state);
34054
- while (ctx.type == "statement")
34055
- ctx = popContext(state);
34056
- } else if (curPunc == ctx.type)
34057
- popContext(state);
34698
+ while (ctx.type == "statement") ctx = popContext(state);
34699
+ if (ctx.type == "}") ctx = popContext(state);
34700
+ while (ctx.type == "statement") ctx = popContext(state);
34701
+ } else if (curPunc == ctx.type) popContext(state);
34058
34702
  else if (indentStatements && ((ctx.type == "}" || ctx.type == "top") && curPunc != ";" || ctx.type == "statement" && curPunc == "newstatement")) {
34059
34703
  pushContext(state, stream.column(), "statement", stream.current());
34060
34704
  }
@@ -34062,11 +34706,9 @@ const dependencies = {
34062
34706
  style = "def";
34063
34707
  if (hooks.token) {
34064
34708
  var result = hooks.token(stream, state, style);
34065
- if (result !== void 0)
34066
- style = result;
34709
+ if (result !== void 0) style = result;
34067
34710
  }
34068
- if (style == "def" && parserConfig.styleDefs === false)
34069
- style = "variable";
34711
+ if (style == "def" && parserConfig.styleDefs === false) style = "variable";
34070
34712
  state.startOfLine = false;
34071
34713
  state.prevToken = isDefKeyword ? "def" : style || curPunc;
34072
34714
  maybeEOL(stream, state);
@@ -34077,20 +34719,17 @@ const dependencies = {
34077
34719
  return null;
34078
34720
  var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
34079
34721
  var closing2 = firstChar == ctx.type;
34080
- if (ctx.type == "statement" && firstChar == "}")
34081
- ctx = ctx.prev;
34722
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
34082
34723
  if (parserConfig.dontIndentStatements)
34083
34724
  while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
34084
34725
  ctx = ctx.prev;
34085
34726
  if (hooks.indent) {
34086
34727
  var hook = hooks.indent(state, ctx, textAfter, context.unit);
34087
- if (typeof hook == "number")
34088
- return hook;
34728
+ if (typeof hook == "number") return hook;
34089
34729
  }
34090
34730
  var switchBlock = ctx.prev && ctx.prev.info == "switch";
34091
34731
  if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
34092
- while (ctx.type != "top" && ctx.type != "}")
34093
- ctx = ctx.prev;
34732
+ while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev;
34094
34733
  return ctx.indented;
34095
34734
  }
34096
34735
  if (ctx.type == "statement")
@@ -34111,8 +34750,7 @@ const dependencies = {
34111
34750
  }
34112
34751
  function words$1(str) {
34113
34752
  var obj = {}, words2 = str.split(" ");
34114
- for (var i2 = 0; i2 < words2.length; ++i2)
34115
- obj[words2[i2]] = true;
34753
+ for (var i2 = 0; i2 < words2.length; ++i2) obj[words2[i2]] = true;
34116
34754
  return obj;
34117
34755
  }
34118
34756
  function contains(words2, word) {
@@ -34137,8 +34775,7 @@ const dependencies = {
34137
34775
  var cBlockKeywords = "case do else for if switch while struct enum union";
34138
34776
  var cDefKeywords = "struct enum union";
34139
34777
  function cppHook(stream, state) {
34140
- if (!state.startOfLine)
34141
- return false;
34778
+ if (!state.startOfLine) return false;
34142
34779
  for (var ch, next = null; ch = stream.peek(); ) {
34143
34780
  if (ch == "\\" && stream.match(/^.$/)) {
34144
34781
  next = cppHook;
@@ -34152,15 +34789,12 @@ const dependencies = {
34152
34789
  return "meta";
34153
34790
  }
34154
34791
  function pointerHook(_stream, state) {
34155
- if (state.prevToken == "type")
34156
- return "type";
34792
+ if (state.prevToken == "type") return "type";
34157
34793
  return false;
34158
34794
  }
34159
34795
  function cIsReservedIdentifier(token) {
34160
- if (!token || token.length < 2)
34161
- return false;
34162
- if (token[0] != "_")
34163
- return false;
34796
+ if (!token || token.length < 2) return false;
34797
+ if (token[0] != "_") return false;
34164
34798
  return token[1] == "_" || token[1] !== token[1].toLowerCase();
34165
34799
  }
34166
34800
  function cpp14Literal(stream) {
@@ -34274,14 +34908,12 @@ const dependencies = {
34274
34908
  number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
34275
34909
  hooks: {
34276
34910
  "@": function(stream) {
34277
- if (stream.match("interface", false))
34278
- return false;
34911
+ if (stream.match("interface", false)) return false;
34279
34912
  stream.eatWhile(/[\w\$_]/);
34280
34913
  return "meta";
34281
34914
  },
34282
34915
  '"': function(stream, state) {
34283
- if (!stream.match(/""$/))
34284
- return false;
34916
+ if (!stream.match(/""$/)) return false;
34285
34917
  state.tokenize = tokenTripleString;
34286
34918
  return state.tokenize(stream, state);
34287
34919
  }
@@ -34359,14 +34991,12 @@ const dependencies = {
34359
34991
  return "meta";
34360
34992
  },
34361
34993
  '"': function(stream, state) {
34362
- if (!stream.match('""'))
34363
- return false;
34994
+ if (!stream.match('""')) return false;
34364
34995
  state.tokenize = tokenTripleString;
34365
34996
  return state.tokenize(stream, state);
34366
34997
  },
34367
34998
  "'": function(stream) {
34368
- if (stream.match(/^(\\[^'\s]+|[^\\'])'/))
34369
- return "character";
34999
+ if (stream.match(/^(\\[^'\s]+|[^\\'])'/)) return "character";
34370
35000
  stream.eatWhile(/[\w\$_\xa1-\uffff]/);
34371
35001
  return "atom";
34372
35002
  },
@@ -34380,8 +35010,7 @@ const dependencies = {
34380
35010
  }
34381
35011
  },
34382
35012
  "/": function(stream, state) {
34383
- if (!stream.eat("*"))
34384
- return false;
35013
+ if (!stream.eat("*")) return false;
34385
35014
  state.tokenize = tokenNestedComment(1);
34386
35015
  return state.tokenize(stream, state);
34387
35016
  }
@@ -34442,8 +35071,7 @@ const dependencies = {
34442
35071
  return state.tokenize(stream, state);
34443
35072
  },
34444
35073
  "/": function(stream, state) {
34445
- if (!stream.eat("*"))
34446
- return false;
35074
+ if (!stream.eat("*")) return false;
34447
35075
  state.tokenize = tokenNestedComment(1);
34448
35076
  return state.tokenize(stream, state);
34449
35077
  },
@@ -34591,15 +35219,13 @@ const dependencies = {
34591
35219
  return state.tokenize(stream, state);
34592
35220
  },
34593
35221
  "`": function(stream, state) {
34594
- if (!stringTokenizer || !stream.match("`"))
34595
- return false;
35222
+ if (!stringTokenizer || !stream.match("`")) return false;
34596
35223
  state.tokenize = stringTokenizer;
34597
35224
  stringTokenizer = null;
34598
35225
  return state.tokenize(stream, state);
34599
35226
  },
34600
35227
  "'": function(stream) {
34601
- if (stream.match(/^(\\[^'\s]+|[^\\'])'/))
34602
- return "string.special";
35228
+ if (stream.match(/^(\\[^'\s]+|[^\\'])'/)) return "string.special";
34603
35229
  stream.eatWhile(/[\w\$_\xa1-\uffff]/);
34604
35230
  return "atom";
34605
35231
  },
@@ -34625,10 +35251,8 @@ const dependencies = {
34625
35251
  function tokenDartString(quote, stream, state, raw) {
34626
35252
  var tripleQuoted = false;
34627
35253
  if (stream.eat(quote)) {
34628
- if (stream.eat(quote))
34629
- tripleQuoted = true;
34630
- else
34631
- return "string";
35254
+ if (stream.eat(quote)) tripleQuoted = true;
35255
+ else return "string";
34632
35256
  }
34633
35257
  function tokenStringHelper(stream2, state2) {
34634
35258
  var escaped = false;
@@ -34697,8 +35321,7 @@ const dependencies = {
34697
35321
  return false;
34698
35322
  },
34699
35323
  "/": function(stream, state) {
34700
- if (!stream.eat("*"))
34701
- return false;
35324
+ if (!stream.eat("*")) return false;
34702
35325
  state.tokenize = tokenNestedComment(1);
34703
35326
  return state.tokenize(stream, state);
34704
35327
  },
@@ -34717,8 +35340,7 @@ const dependencies = {
34717
35340
  function words(str) {
34718
35341
  const obj = {};
34719
35342
  const words2 = str.split(" ");
34720
- for (let i2 = 0; i2 < words2.length; i2++)
34721
- obj[words2[i2]] = true;
35343
+ for (let i2 = 0; i2 < words2.length; i2++) obj[words2[i2]] = true;
34722
35344
  return obj;
34723
35345
  }
34724
35346
  const faustLanguage = StreamLanguage.define(clike({
@@ -35216,8 +35838,7 @@ const dependencies = {
35216
35838
  return;
35217
35839
  }
35218
35840
  clearError(editor);
35219
- if (node !== void 0)
35220
- node.disconnect();
35841
+ if (node !== void 0) node.disconnect();
35221
35842
  if (gnvoices > 0) {
35222
35843
  node = await generator.createNode(audioCtx, gnvoices);
35223
35844
  } else {
@@ -35245,8 +35866,7 @@ const dependencies = {
35245
35866
  }
35246
35867
  openSidebar();
35247
35868
  for (const tab of tabContents) {
35248
- while (tab.lastChild)
35249
- tab.lastChild.remove();
35869
+ while (tab.lastChild) tab.lastChild.remove();
35250
35870
  }
35251
35871
  analyser = new AnalyserNode(audioCtx, {
35252
35872
  fftSize: Math.pow(2, 11),
@@ -35303,13 +35923,11 @@ const dependencies = {
35303
35923
  }
35304
35924
  if (i2 === 2) {
35305
35925
  scope.onResize();
35306
- if (animPlot !== void 0)
35307
- cancelAnimationFrame(animPlot);
35926
+ if (animPlot !== void 0) cancelAnimationFrame(animPlot);
35308
35927
  animPlot = requestAnimationFrame(drawScope);
35309
35928
  } else if (i2 === 3) {
35310
35929
  spectrum.onResize();
35311
- if (animPlot !== void 0)
35312
- cancelAnimationFrame(animPlot);
35930
+ if (animPlot !== void 0) cancelAnimationFrame(animPlot);
35313
35931
  animPlot = requestAnimationFrame(drawSpectrum);
35314
35932
  } else if (animPlot !== void 0) {
35315
35933
  cancelAnimationFrame(animPlot);
@@ -35329,10 +35947,8 @@ const dependencies = {
35329
35947
  };
35330
35948
  const audioInputSelector = this.shadowRoot.querySelector("#audio-input");
35331
35949
  const updateInputDevices = (devices2) => {
35332
- if (audioInputSelector.disabled)
35333
- return;
35334
- while (audioInputSelector.lastChild)
35335
- audioInputSelector.lastChild.remove();
35950
+ if (audioInputSelector.disabled) return;
35951
+ while (audioInputSelector.lastChild) audioInputSelector.lastChild.remove();
35336
35952
  for (const device of devices2) {
35337
35953
  if (device.kind === "audioinput") {
35338
35954
  audioInputSelector.appendChild(new Option(device.label || device.deviceId, device.deviceId));
@@ -35545,10 +36161,8 @@ const dependencies = {
35545
36161
  };
35546
36162
  const audioInputSelector = this.shadowRoot.querySelector("#audio-input");
35547
36163
  const updateInputDevices = (devices2) => {
35548
- if (audioInputSelector.disabled)
35549
- return;
35550
- while (audioInputSelector.lastChild)
35551
- audioInputSelector.lastChild.remove();
36164
+ if (audioInputSelector.disabled) return;
36165
+ while (audioInputSelector.lastChild) audioInputSelector.lastChild.remove();
35552
36166
  for (const device of devices2) {
35553
36167
  if (device.kind === "audioinput") {
35554
36168
  audioInputSelector.appendChild(new Option(device.label || device.deviceId, device.deviceId));