@arcanejs/toolkit 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/backend/components/base.d.mts +9 -2
  2. package/dist/backend/components/base.d.ts +9 -2
  3. package/dist/backend/components/base.js +2 -2
  4. package/dist/backend/components/base.mjs +1 -1
  5. package/dist/backend/components/button.d.mts +1 -0
  6. package/dist/backend/components/button.d.ts +1 -0
  7. package/dist/backend/components/button.js +3 -3
  8. package/dist/backend/components/button.mjs +2 -2
  9. package/dist/backend/components/group.d.mts +1 -0
  10. package/dist/backend/components/group.d.ts +1 -0
  11. package/dist/backend/components/group.js +3 -3
  12. package/dist/backend/components/group.mjs +2 -2
  13. package/dist/backend/components/label.d.mts +1 -0
  14. package/dist/backend/components/label.d.ts +1 -0
  15. package/dist/backend/components/label.js +3 -3
  16. package/dist/backend/components/label.mjs +2 -2
  17. package/dist/backend/components/rect.d.mts +1 -0
  18. package/dist/backend/components/rect.d.ts +1 -0
  19. package/dist/backend/components/rect.js +3 -3
  20. package/dist/backend/components/rect.mjs +2 -2
  21. package/dist/backend/components/slider-button.d.mts +10 -4
  22. package/dist/backend/components/slider-button.d.ts +10 -4
  23. package/dist/backend/components/slider-button.js +3 -3
  24. package/dist/backend/components/slider-button.mjs +2 -2
  25. package/dist/backend/components/switch.d.mts +9 -1
  26. package/dist/backend/components/switch.d.ts +9 -1
  27. package/dist/backend/components/switch.js +3 -3
  28. package/dist/backend/components/switch.mjs +2 -2
  29. package/dist/backend/components/tabs.d.mts +1 -0
  30. package/dist/backend/components/tabs.d.ts +1 -0
  31. package/dist/backend/components/tabs.js +3 -3
  32. package/dist/backend/components/tabs.mjs +2 -2
  33. package/dist/backend/components/text-input.d.mts +1 -0
  34. package/dist/backend/components/text-input.d.ts +1 -0
  35. package/dist/backend/components/text-input.js +3 -3
  36. package/dist/backend/components/text-input.mjs +2 -2
  37. package/dist/backend/components/timeline.d.mts +1 -0
  38. package/dist/backend/components/timeline.d.ts +1 -0
  39. package/dist/backend/components/timeline.js +3 -3
  40. package/dist/backend/components/timeline.mjs +2 -2
  41. package/dist/{chunk-K24YPCR5.js → chunk-4HHKW7VA.js} +4 -4
  42. package/dist/{chunk-KVJU3EAD.js → chunk-4X3QY5EP.js} +3 -3
  43. package/dist/{chunk-JW4GXS54.mjs → chunk-A2STBGBE.mjs} +28 -11
  44. package/dist/{chunk-RJS32OOA.js → chunk-C2TVGO43.js} +3 -3
  45. package/dist/{chunk-UBWCVW2U.js → chunk-CFO5PSSK.js} +27 -21
  46. package/dist/{chunk-SOC4TF3J.mjs → chunk-DBSYI5Z4.mjs} +1 -1
  47. package/dist/{chunk-MDFDWKGW.js → chunk-DONU33U4.js} +3 -3
  48. package/dist/{chunk-P43QUQ4T.js → chunk-FLRGYURV.js} +2 -2
  49. package/dist/{chunk-OEIGZ3NQ.js → chunk-FUINWM5H.js} +2 -2
  50. package/dist/{chunk-TAZH4BBH.mjs → chunk-G5QXW2L3.mjs} +1 -1
  51. package/dist/chunk-G7GFSIHY.js +76 -0
  52. package/dist/{chunk-TQ27Y7F4.mjs → chunk-H734NV65.mjs} +1 -1
  53. package/dist/{chunk-HNEUZVCX.mjs → chunk-JOW3XRQI.mjs} +1 -1
  54. package/dist/{chunk-RGIB65TI.js → chunk-K572ZPUS.js} +2 -2
  55. package/dist/{chunk-3O4P67DM.mjs → chunk-KBPQZJKE.mjs} +1 -1
  56. package/dist/{chunk-ZU5H6SVA.mjs → chunk-KOKUFP6V.mjs} +1 -1
  57. package/dist/{chunk-IXTM35YM.mjs → chunk-KR6LSBBX.mjs} +1 -1
  58. package/dist/{chunk-ZCHM3JJJ.mjs → chunk-PW7QVLLF.mjs} +10 -4
  59. package/dist/chunk-Q3NG5UUN.mjs +61 -0
  60. package/dist/chunk-Q5TEM6MM.js +61 -0
  61. package/dist/frontend.js +0 -3
  62. package/dist/frontend.js.map +2 -2
  63. package/dist/index.d.mts +21 -3
  64. package/dist/index.d.ts +21 -3
  65. package/dist/index.js +30 -26
  66. package/dist/index.mjs +28 -24
  67. package/package.json +8 -6
  68. package/dist/chunk-APCR3ITH.mjs +0 -42
  69. package/dist/chunk-M6EFK4GP.js +0 -42
  70. package/dist/chunk-T2PJEXYO.js +0 -59
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
3
 
4
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
4
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
5
5
 
6
6
  // src/backend/components/button.ts
7
7
  var DEFAULT_PROPS = {
@@ -10,9 +10,9 @@ var DEFAULT_PROPS = {
10
10
  mode: "normal",
11
11
  error: null
12
12
  };
13
- var Button = (_class = class extends _chunkUBWCVW2Ujs.Base {
13
+ var Button = (_class = class extends _chunkCFO5PSSKjs.Base {
14
14
  /** @hidden */
15
- __init() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
15
+ __init() {this.events = new (0, _chunkCFO5PSSKjs.EventEmitter)()}
16
16
  constructor(props) {
17
17
  super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);;
18
18
  }
@@ -1,21 +1,27 @@
1
1
  import {
2
2
  Base,
3
3
  EventEmitter
4
- } from "./chunk-ZCHM3JJJ.mjs";
4
+ } from "./chunk-PW7QVLLF.mjs";
5
5
 
6
6
  // src/backend/components/slider-button.ts
7
7
  var DEFAULT_PROPS = {
8
- value: null,
9
8
  min: 0,
10
9
  max: 255,
11
- step: 5,
12
- mode: "writeBack"
10
+ step: 5
13
11
  };
14
12
  var SliderButton = class extends Base {
15
13
  /** @hidden */
16
14
  events = new EventEmitter();
15
+ /**
16
+ * Manually manage the state of the slider,
17
+ * to support both controlled and uncontrolled inputs.
18
+ */
19
+ _value = null;
17
20
  constructor(props) {
18
- super(DEFAULT_PROPS, props);
21
+ super(DEFAULT_PROPS, props, {
22
+ onPropsUpdated: () => this.onPropsUpdated()
23
+ });
24
+ this.onPropsUpdated();
19
25
  }
20
26
  addListener = this.events.addListener;
21
27
  removeListener = this.events.removeListener;
@@ -27,23 +33,27 @@ var SliderButton = class extends Base {
27
33
  min: this.props.min,
28
34
  max: this.props.max,
29
35
  step: this.props.step,
30
- value: this.props.value
36
+ value: this._value
31
37
  };
32
38
  }
33
39
  /** @hidden */
34
40
  handleMessage(message) {
35
41
  if (message.component !== "slider_button") return;
36
42
  const newValue = this.sanitizeNumber(message.value);
37
- if (this.props.value === newValue) return;
38
- if (this.props.mode === "writeBack") {
39
- this.updateProps({ value: newValue });
43
+ if (this._value === newValue) return;
44
+ if (this.props.value === void 0) {
45
+ this._value = newValue;
46
+ this.updateTree();
40
47
  }
41
48
  this.events.emit("change", newValue);
42
49
  }
43
50
  setValue(value) {
51
+ if (this.props.value) {
52
+ throw new Error("Cannot set value on controlled input");
53
+ }
44
54
  const newValue = this.sanitizeNumber(value);
45
- if (newValue === this.props.value) return;
46
- this.updateProps({ value });
55
+ if (this._value === newValue) return;
56
+ this._value = newValue;
47
57
  this.updateTree();
48
58
  }
49
59
  sanitizeNumber(value) {
@@ -52,6 +62,13 @@ var SliderButton = class extends Base {
52
62
  const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
53
63
  return clampedValue;
54
64
  }
65
+ onPropsUpdated = () => {
66
+ if (this.props.value !== void 0) {
67
+ this._value = this.props.value;
68
+ } else if (this._value === null && this.props.defaultValue) {
69
+ this._value = this.props.defaultValue;
70
+ }
71
+ };
55
72
  };
56
73
 
57
74
  export {
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2;
2
2
 
3
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
3
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
4
4
 
5
5
  // src/backend/components/tabs.ts
6
- var Tab = (_class = class extends _chunkUBWCVW2Ujs.BaseParent {constructor(...args) { super(...args); _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
6
+ var Tab = (_class = class extends _chunkCFO5PSSKjs.BaseParent {constructor(...args) { super(...args); _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
7
7
  __init() {this.validateChildren = (children) => {
8
8
  if (children.length > 1) {
9
9
  throw new Error("Tab can only have one child");
@@ -17,7 +17,7 @@ var Tab = (_class = class extends _chunkUBWCVW2Ujs.BaseParent {constructor(...ar
17
17
  child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
18
18
  })}
19
19
  }, _class);
20
- var Tabs = (_class2 = class extends _chunkUBWCVW2Ujs.BaseParent {
20
+ var Tabs = (_class2 = class extends _chunkCFO5PSSKjs.BaseParent {
21
21
  __init3() {this.validateChildren = (children) => {
22
22
  for (const child of children) {
23
23
  if (!(child instanceof Tab)) {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;// src/backend/components/base.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;// src/backend/components/base.ts
2
2
  var Base = (_class = class {
3
3
  /** @hidden */
4
4
  __init() {this.parent = null}
@@ -6,31 +6,39 @@ var Base = (_class = class {
6
6
 
7
7
  /** @hidden */
8
8
 
9
- constructor(defaultProps, props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
9
+ /** @hidden */
10
+ __init2() {this._onPropsUpdated = null}
11
+ constructor(defaultProps, props, options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
10
12
  this.defaultProps = defaultProps;
11
13
  this._props = Object.freeze({
12
14
  ...defaultProps,
13
15
  ...props
14
16
  });
17
+ this._onPropsUpdated = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.onPropsUpdated]), () => ( null));
15
18
  }
19
+ __init3() {this.log = () => {
20
+ return _optionalChain([this, 'access', _9 => _9.parent, 'optionalAccess', _10 => _10.log, 'call', _11 => _11()]) || null;
21
+ }}
16
22
  get props() {
17
23
  return this._props;
18
24
  }
19
25
  set props(props) {
20
26
  this.setProps(props);
21
27
  }
22
- __init2() {this.setProps = (props) => {
28
+ __init4() {this.setProps = (props) => {
23
29
  this._props = Object.freeze({
24
30
  ...this.defaultProps,
25
31
  ...props
26
32
  });
33
+ _optionalChain([this, 'access', _12 => _12._onPropsUpdated, 'optionalCall', _13 => _13()]);
27
34
  this.updateTree();
28
35
  }}
29
- __init3() {this.updateProps = (updates) => {
36
+ __init5() {this.updateProps = (updates) => {
30
37
  this._props = Object.freeze({
31
38
  ...this._props,
32
39
  ...updates
33
40
  });
41
+ _optionalChain([this, 'access', _14 => _14._onPropsUpdated, 'optionalCall', _15 => _15()]);
34
42
  this.updateTree();
35
43
  }}
36
44
  /** @hidden */
@@ -45,16 +53,15 @@ var Base = (_class = class {
45
53
  if (this.parent) this.parent.updateTree();
46
54
  }
47
55
  /** @hidden */
48
- handleMessage(message) {
49
- console.log("Component Received Message:", message);
56
+ handleMessage(_message) {
50
57
  }
51
58
  routeMessage(_idMap, _message) {
52
59
  }
53
60
  }, _class);
54
- var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(...args2); _class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this); }
61
+ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(...args2); _class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this); }
55
62
  /** @hidden */
56
- __init4() {this.children = []}
57
- __init5() {this.appendChildren = (...children) => {
63
+ __init6() {this.children = []}
64
+ __init7() {this.appendChildren = (...children) => {
58
65
  for (const c of children) {
59
66
  const newChildren = [...this.children.filter((ch) => ch !== c), c];
60
67
  this.validateChildren(newChildren);
@@ -64,11 +71,11 @@ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(..
64
71
  this.updateTree();
65
72
  return children;
66
73
  }}
67
- __init6() {this.appendChild = (child) => {
74
+ __init8() {this.appendChild = (child) => {
68
75
  this.appendChildren(child);
69
76
  return child;
70
77
  }}
71
- __init7() {this.removeChild = (component) => {
78
+ __init9() {this.removeChild = (component) => {
72
79
  const match = this.children.findIndex((c) => c === component);
73
80
  if (match >= 0) {
74
81
  const removingChild = this.children[match];
@@ -78,11 +85,11 @@ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(..
78
85
  ];
79
86
  this.validateChildren(newChildren);
80
87
  this.children = Object.freeze(newChildren);
81
- _optionalChain([removingChild, 'optionalAccess', _3 => _3.setParent, 'call', _4 => _4(null)]);
88
+ _optionalChain([removingChild, 'optionalAccess', _18 => _18.setParent, 'call', _19 => _19(null)]);
82
89
  this.updateTree();
83
90
  }
84
91
  }}
85
- __init8() {this.removeAllChildren = () => {
92
+ __init10() {this.removeAllChildren = () => {
86
93
  this.children.map((c) => c.setParent(null));
87
94
  this.children = Object.freeze([]);
88
95
  this.updateTree();
@@ -90,7 +97,7 @@ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(..
90
97
  /**
91
98
  * Return all children components that messages need to be routed to
92
99
  */
93
- __init9() {this.getChildren = () => this.children}
100
+ __init11() {this.getChildren = () => this.children}
94
101
  /**
95
102
  * TODO: we can do this better, right now it broadcasts the message to all
96
103
  * components of the tree
@@ -113,7 +120,6 @@ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(..
113
120
  insertBefore(child, beforeChild) {
114
121
  const filteredChildren = this.children.filter((c) => c !== child);
115
122
  let match = filteredChildren.findIndex((c) => c === beforeChild);
116
- console.log("match", match);
117
123
  if (match === -1) {
118
124
  match = filteredChildren.length;
119
125
  }
@@ -128,9 +134,9 @@ var BaseParent = (_class2 = class extends Base {constructor(...args2) { super(..
128
134
  this.updateTree();
129
135
  }
130
136
  }, _class2);
131
- var EventEmitter = (_class3 = class {constructor() { _class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this); }
132
- __init10() {this.listeners = /* @__PURE__ */ new Map()}
133
- __init11() {this.addListener = (type, listener) => {
137
+ var EventEmitter = (_class3 = class {constructor() { _class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);_class3.prototype.__init15.call(this); }
138
+ __init12() {this.listeners = /* @__PURE__ */ new Map()}
139
+ __init13() {this.addListener = (type, listener) => {
134
140
  let set = this.listeners.get(type);
135
141
  if (!set) {
136
142
  set = /* @__PURE__ */ new Set();
@@ -138,10 +144,10 @@ var EventEmitter = (_class3 = class {constructor() { _class3.prototype.__init10.
138
144
  }
139
145
  set.add(listener);
140
146
  }}
141
- __init12() {this.removeListener = (type, listener) => {
142
- _optionalChain([this, 'access', _10 => _10.listeners, 'access', _11 => _11.get, 'call', _12 => _12(type), 'optionalAccess', _13 => _13.delete, 'call', _14 => _14(listener)]);
147
+ __init14() {this.removeListener = (type, listener) => {
148
+ _optionalChain([this, 'access', _25 => _25.listeners, 'access', _26 => _26.get, 'call', _27 => _27(type), 'optionalAccess', _28 => _28.delete, 'call', _29 => _29(listener)]);
143
149
  }}
144
- __init13() {this.emit = (type, ...args) => {
150
+ __init15() {this.emit = (type, ...args) => {
145
151
  return Promise.all(
146
152
  [...this.listeners.get(type) || []].map(
147
153
  (l) => new Promise((resolve, reject) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Base
3
- } from "./chunk-ZCHM3JJJ.mjs";
3
+ } from "./chunk-PW7QVLLF.mjs";
4
4
 
5
5
  // src/backend/components/timeline.ts
6
6
  var DEFAULT_PROPS = {
@@ -1,15 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
3
 
4
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
4
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
5
5
 
6
6
  // src/backend/components/text-input.ts
7
7
  var DEFAULT_PROPS = {
8
8
  value: null
9
9
  };
10
- var TextInput = (_class = class extends _chunkUBWCVW2Ujs.Base {
10
+ var TextInput = (_class = class extends _chunkCFO5PSSKjs.Base {
11
11
  /** @hidden */
12
- __init() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
12
+ __init() {this.events = new (0, _chunkCFO5PSSKjs.EventEmitter)()}
13
13
  constructor(props) {
14
14
  super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);;
15
15
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
3
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
4
4
 
5
5
  // src/backend/components/label.ts
6
- var Label = class extends _chunkUBWCVW2Ujs.Base {
6
+ var Label = class extends _chunkCFO5PSSKjs.Base {
7
7
  constructor(props) {
8
8
  super({ text: null }, props);
9
9
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
3
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
4
4
 
5
5
  // src/backend/components/timeline.ts
6
6
  var DEFAULT_PROPS = {
@@ -13,7 +13,7 @@ var DEFAULT_PROPS = {
13
13
  subtitles: null,
14
14
  source: null
15
15
  };
16
- var Timeline = (_class = class extends _chunkUBWCVW2Ujs.Base {
16
+ var Timeline = (_class = class extends _chunkCFO5PSSKjs.Base {
17
17
  constructor(props) {
18
18
  super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);;
19
19
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Base,
3
3
  EventEmitter
4
- } from "./chunk-ZCHM3JJJ.mjs";
4
+ } from "./chunk-PW7QVLLF.mjs";
5
5
 
6
6
  // src/backend/components/button.ts
7
7
  var DEFAULT_PROPS = {
@@ -0,0 +1,76 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
+
3
+
4
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
5
+
6
+ // src/backend/components/slider-button.ts
7
+ var DEFAULT_PROPS = {
8
+ min: 0,
9
+ max: 255,
10
+ step: 5
11
+ };
12
+ var SliderButton = (_class = class extends _chunkCFO5PSSKjs.Base {
13
+ /** @hidden */
14
+ __init() {this.events = new (0, _chunkCFO5PSSKjs.EventEmitter)()}
15
+ /**
16
+ * Manually manage the state of the slider,
17
+ * to support both controlled and uncontrolled inputs.
18
+ */
19
+ __init2() {this._value = null}
20
+ constructor(props) {
21
+ super(DEFAULT_PROPS, props, {
22
+ onPropsUpdated: () => this.onPropsUpdated()
23
+ });_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);;
24
+ this.onPropsUpdated();
25
+ }
26
+ __init3() {this.addListener = this.events.addListener}
27
+ __init4() {this.removeListener = this.events.removeListener}
28
+ /** @hidden */
29
+ getProtoInfo(idMap) {
30
+ return {
31
+ component: "slider_button",
32
+ key: idMap.getId(this),
33
+ min: this.props.min,
34
+ max: this.props.max,
35
+ step: this.props.step,
36
+ value: this._value
37
+ };
38
+ }
39
+ /** @hidden */
40
+ handleMessage(message) {
41
+ if (message.component !== "slider_button") return;
42
+ const newValue = this.sanitizeNumber(message.value);
43
+ if (this._value === newValue) return;
44
+ if (this.props.value === void 0) {
45
+ this._value = newValue;
46
+ this.updateTree();
47
+ }
48
+ this.events.emit("change", newValue);
49
+ }
50
+ setValue(value) {
51
+ if (this.props.value) {
52
+ throw new Error("Cannot set value on controlled input");
53
+ }
54
+ const newValue = this.sanitizeNumber(value);
55
+ if (this._value === newValue) return;
56
+ this._value = newValue;
57
+ this.updateTree();
58
+ }
59
+ sanitizeNumber(value) {
60
+ const i = Math.round((value - this.props.min) / this.props.step);
61
+ const v = i * this.props.step + this.props.min;
62
+ const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
63
+ return clampedValue;
64
+ }
65
+ __init5() {this.onPropsUpdated = () => {
66
+ if (this.props.value !== void 0) {
67
+ this._value = this.props.value;
68
+ } else if (this._value === null && this.props.defaultValue) {
69
+ this._value = this.props.defaultValue;
70
+ }
71
+ }}
72
+ }, _class);
73
+
74
+
75
+
76
+ exports.SliderButton = SliderButton;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseParent
3
- } from "./chunk-ZCHM3JJJ.mjs";
3
+ } from "./chunk-PW7QVLLF.mjs";
4
4
 
5
5
  // src/backend/components/tabs.ts
6
6
  var Tab = class extends BaseParent {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Base
3
- } from "./chunk-ZCHM3JJJ.mjs";
3
+ } from "./chunk-PW7QVLLF.mjs";
4
4
 
5
5
  // src/backend/components/label.ts
6
6
  var Label = class extends Base {
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
3
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
4
4
 
5
5
  // src/backend/components/rect.ts
6
6
  var DEFAULT_PROPS = {
7
7
  color: "rgba(0, 0, 0, 0)"
8
8
  };
9
- var Rect = class extends _chunkUBWCVW2Ujs.Base {
9
+ var Rect = class extends _chunkCFO5PSSKjs.Base {
10
10
  constructor(props) {
11
11
  super(DEFAULT_PROPS, props);
12
12
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BaseParent,
3
3
  EventEmitter
4
- } from "./chunk-ZCHM3JJJ.mjs";
4
+ } from "./chunk-PW7QVLLF.mjs";
5
5
 
6
6
  // src/backend/components/group.ts
7
7
  var GROUP_DEFAULT_STYLE = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Base
3
- } from "./chunk-ZCHM3JJJ.mjs";
3
+ } from "./chunk-PW7QVLLF.mjs";
4
4
 
5
5
  // src/backend/components/rect.ts
6
6
  var DEFAULT_PROPS = {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Base,
3
3
  EventEmitter
4
- } from "./chunk-ZCHM3JJJ.mjs";
4
+ } from "./chunk-PW7QVLLF.mjs";
5
5
 
6
6
  // src/backend/components/text-input.ts
7
7
  var DEFAULT_PROPS = {
@@ -6,13 +6,19 @@ var Base = class {
6
6
  defaultProps;
7
7
  /** @hidden */
8
8
  _props;
9
- constructor(defaultProps, props) {
9
+ /** @hidden */
10
+ _onPropsUpdated = null;
11
+ constructor(defaultProps, props, options) {
10
12
  this.defaultProps = defaultProps;
11
13
  this._props = Object.freeze({
12
14
  ...defaultProps,
13
15
  ...props
14
16
  });
17
+ this._onPropsUpdated = options?.onPropsUpdated ?? null;
15
18
  }
19
+ log = () => {
20
+ return this.parent?.log() || null;
21
+ };
16
22
  get props() {
17
23
  return this._props;
18
24
  }
@@ -24,6 +30,7 @@ var Base = class {
24
30
  ...this.defaultProps,
25
31
  ...props
26
32
  });
33
+ this._onPropsUpdated?.();
27
34
  this.updateTree();
28
35
  };
29
36
  updateProps = (updates) => {
@@ -31,6 +38,7 @@ var Base = class {
31
38
  ...this._props,
32
39
  ...updates
33
40
  });
41
+ this._onPropsUpdated?.();
34
42
  this.updateTree();
35
43
  };
36
44
  /** @hidden */
@@ -45,8 +53,7 @@ var Base = class {
45
53
  if (this.parent) this.parent.updateTree();
46
54
  }
47
55
  /** @hidden */
48
- handleMessage(message) {
49
- console.log("Component Received Message:", message);
56
+ handleMessage(_message) {
50
57
  }
51
58
  routeMessage(_idMap, _message) {
52
59
  }
@@ -113,7 +120,6 @@ var BaseParent = class extends Base {
113
120
  insertBefore(child, beforeChild) {
114
121
  const filteredChildren = this.children.filter((c) => c !== child);
115
122
  let match = filteredChildren.findIndex((c) => c === beforeChild);
116
- console.log("match", match);
117
123
  if (match === -1) {
118
124
  match = filteredChildren.length;
119
125
  }
@@ -0,0 +1,61 @@
1
+ import {
2
+ Base,
3
+ EventEmitter
4
+ } from "./chunk-PW7QVLLF.mjs";
5
+
6
+ // src/backend/components/switch.ts
7
+ var DEFAULT_PROPS = {};
8
+ var Switch = class extends Base {
9
+ /** @hidden */
10
+ events = new EventEmitter();
11
+ /**
12
+ * Manually manage the state of the switch,
13
+ * to support both controlled and uncontrolled inputs.
14
+ */
15
+ _value = null;
16
+ constructor(props) {
17
+ super(DEFAULT_PROPS, props, {
18
+ onPropsUpdated: () => this.onPropsUpdated()
19
+ });
20
+ this.onPropsUpdated();
21
+ }
22
+ addListener = this.events.addListener;
23
+ removeListener = this.events.removeListener;
24
+ /** @hidden */
25
+ getProtoInfo(idMap) {
26
+ return {
27
+ component: "switch",
28
+ key: idMap.getId(this),
29
+ state: this._value ?? "off"
30
+ };
31
+ }
32
+ /** @hidden */
33
+ handleMessage(message) {
34
+ if (message.component === "switch") {
35
+ const state = this._value === "on" ? "off" : "on";
36
+ if (this.props.value === void 0) {
37
+ this._value = state;
38
+ this.updateTree();
39
+ }
40
+ this.events.emit("change", state);
41
+ }
42
+ }
43
+ setValue(state) {
44
+ if (this.props.value) {
45
+ throw new Error("Cannot set value on controlled input");
46
+ }
47
+ this._value = state;
48
+ this.updateTree();
49
+ }
50
+ onPropsUpdated = () => {
51
+ if (this.props.value !== void 0) {
52
+ this._value = this.props.value;
53
+ } else if (this._value === null && this.props.defaultValue) {
54
+ this._value = this.props.defaultValue;
55
+ }
56
+ };
57
+ };
58
+
59
+ export {
60
+ Switch
61
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
+
3
+
4
+ var _chunkCFO5PSSKjs = require('./chunk-CFO5PSSK.js');
5
+
6
+ // src/backend/components/switch.ts
7
+ var DEFAULT_PROPS = {};
8
+ var Switch = (_class = class extends _chunkCFO5PSSKjs.Base {
9
+ /** @hidden */
10
+ __init() {this.events = new (0, _chunkCFO5PSSKjs.EventEmitter)()}
11
+ /**
12
+ * Manually manage the state of the switch,
13
+ * to support both controlled and uncontrolled inputs.
14
+ */
15
+ __init2() {this._value = null}
16
+ constructor(props) {
17
+ super(DEFAULT_PROPS, props, {
18
+ onPropsUpdated: () => this.onPropsUpdated()
19
+ });_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);;
20
+ this.onPropsUpdated();
21
+ }
22
+ __init3() {this.addListener = this.events.addListener}
23
+ __init4() {this.removeListener = this.events.removeListener}
24
+ /** @hidden */
25
+ getProtoInfo(idMap) {
26
+ return {
27
+ component: "switch",
28
+ key: idMap.getId(this),
29
+ state: _nullishCoalesce(this._value, () => ( "off"))
30
+ };
31
+ }
32
+ /** @hidden */
33
+ handleMessage(message) {
34
+ if (message.component === "switch") {
35
+ const state = this._value === "on" ? "off" : "on";
36
+ if (this.props.value === void 0) {
37
+ this._value = state;
38
+ this.updateTree();
39
+ }
40
+ this.events.emit("change", state);
41
+ }
42
+ }
43
+ setValue(state) {
44
+ if (this.props.value) {
45
+ throw new Error("Cannot set value on controlled input");
46
+ }
47
+ this._value = state;
48
+ this.updateTree();
49
+ }
50
+ __init5() {this.onPropsUpdated = () => {
51
+ if (this.props.value !== void 0) {
52
+ this._value = this.props.value;
53
+ } else if (this._value === null && this.props.defaultValue) {
54
+ this._value = this.props.defaultValue;
55
+ }
56
+ }}
57
+ }, _class);
58
+
59
+
60
+
61
+ exports.Switch = Switch;