@arcanejs/toolkit 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/components/base.js +10 -188
- package/dist/backend/components/button.js +5 -165
- package/dist/backend/components/group.js +7 -281
- package/dist/backend/components/label.js +5 -102
- package/dist/backend/components/rect.js +5 -102
- package/dist/backend/components/slider-button.js +5 -158
- package/dist/backend/components/switch.js +5 -141
- package/dist/backend/components/tabs.js +7 -206
- package/dist/backend/components/text-input.js +5 -143
- package/dist/backend/components/timeline.js +5 -106
- package/dist/backend/util/index.js +5 -41
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-EABM5X65.js +17 -0
- package/dist/chunk-K24YPCR5.js +104 -0
- package/dist/chunk-KVJU3EAD.js +66 -0
- package/dist/chunk-M6EFK4GP.js +42 -0
- package/dist/chunk-MDFDWKGW.js +44 -0
- package/dist/chunk-OEIGZ3NQ.js +33 -0
- package/dist/chunk-P43QUQ4T.js +29 -0
- package/dist/chunk-RGIB65TI.js +29 -0
- package/dist/chunk-RJS32OOA.js +55 -0
- package/dist/chunk-T2PJEXYO.js +59 -0
- package/dist/chunk-UBWCVW2U.js +163 -0
- package/dist/index.js +83 -657
- package/package.json +5 -5
|
@@ -1,105 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Label: () => Label
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(label_exports);
|
|
3
|
+
var _chunkP43QUQ4Tjs = require('../../chunk-P43QUQ4T.js');
|
|
4
|
+
require('../../chunk-UBWCVW2U.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
7
|
|
|
81
|
-
|
|
82
|
-
var Label = class extends Base {
|
|
83
|
-
constructor(props) {
|
|
84
|
-
super({ text: null }, props);
|
|
85
|
-
}
|
|
86
|
-
/** @hidden */
|
|
87
|
-
getProtoInfo(idMap) {
|
|
88
|
-
return {
|
|
89
|
-
component: "label",
|
|
90
|
-
key: idMap.getId(this),
|
|
91
|
-
bold: this.props.bold,
|
|
92
|
-
text: this.props.text ?? ""
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
setText(text) {
|
|
96
|
-
this.updateProps({
|
|
97
|
-
text
|
|
98
|
-
});
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
Label
|
|
105
|
-
});
|
|
8
|
+
exports.Label = _chunkP43QUQ4Tjs.Label;
|
|
@@ -1,105 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Rect: () => Rect
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(rect_exports);
|
|
3
|
+
var _chunkRGIB65TIjs = require('../../chunk-RGIB65TI.js');
|
|
4
|
+
require('../../chunk-UBWCVW2U.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
7
|
|
|
81
|
-
|
|
82
|
-
var DEFAULT_PROPS = {
|
|
83
|
-
color: "rgba(0, 0, 0, 0)"
|
|
84
|
-
};
|
|
85
|
-
var Rect = class extends Base {
|
|
86
|
-
constructor(props) {
|
|
87
|
-
super(DEFAULT_PROPS, props);
|
|
88
|
-
}
|
|
89
|
-
/** @hidden */
|
|
90
|
-
getProtoInfo(idMap) {
|
|
91
|
-
return {
|
|
92
|
-
component: "rect",
|
|
93
|
-
key: idMap.getId(this),
|
|
94
|
-
color: this.props.color
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
setColor(color) {
|
|
98
|
-
this.updateProps({ color });
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
Rect
|
|
105
|
-
});
|
|
8
|
+
exports.Rect = _chunkRGIB65TIjs.Rect;
|
|
@@ -1,161 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
SliderButton: () => SliderButton
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(slider_button_exports);
|
|
3
|
+
var _chunkT2PJEXYOjs = require('../../chunk-T2PJEXYO.js');
|
|
4
|
+
require('../../chunk-UBWCVW2U.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var EventEmitter = class {
|
|
81
|
-
listeners = /* @__PURE__ */ new Map();
|
|
82
|
-
addListener = (type, listener) => {
|
|
83
|
-
let set = this.listeners.get(type);
|
|
84
|
-
if (!set) {
|
|
85
|
-
set = /* @__PURE__ */ new Set();
|
|
86
|
-
this.listeners.set(type, set);
|
|
87
|
-
}
|
|
88
|
-
set.add(listener);
|
|
89
|
-
};
|
|
90
|
-
removeListener = (type, listener) => {
|
|
91
|
-
this.listeners.get(type)?.delete(listener);
|
|
92
|
-
};
|
|
93
|
-
emit = (type, ...args) => {
|
|
94
|
-
return Promise.all(
|
|
95
|
-
[...this.listeners.get(type) || []].map(
|
|
96
|
-
(l) => new Promise((resolve, reject) => {
|
|
97
|
-
try {
|
|
98
|
-
resolve(l(...args));
|
|
99
|
-
} catch (e) {
|
|
100
|
-
reject(e);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
7
|
|
|
108
|
-
|
|
109
|
-
var DEFAULT_PROPS = {
|
|
110
|
-
value: null,
|
|
111
|
-
min: 0,
|
|
112
|
-
max: 255,
|
|
113
|
-
step: 5,
|
|
114
|
-
mode: "writeBack"
|
|
115
|
-
};
|
|
116
|
-
var SliderButton = class extends Base {
|
|
117
|
-
/** @hidden */
|
|
118
|
-
events = new EventEmitter();
|
|
119
|
-
constructor(props) {
|
|
120
|
-
super(DEFAULT_PROPS, props);
|
|
121
|
-
}
|
|
122
|
-
addListener = this.events.addListener;
|
|
123
|
-
removeListener = this.events.removeListener;
|
|
124
|
-
/** @hidden */
|
|
125
|
-
getProtoInfo(idMap) {
|
|
126
|
-
return {
|
|
127
|
-
component: "slider_button",
|
|
128
|
-
key: idMap.getId(this),
|
|
129
|
-
min: this.props.min,
|
|
130
|
-
max: this.props.max,
|
|
131
|
-
step: this.props.step,
|
|
132
|
-
value: this.props.value
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/** @hidden */
|
|
136
|
-
handleMessage(message) {
|
|
137
|
-
if (message.component !== "slider_button") return;
|
|
138
|
-
const newValue = this.sanitizeNumber(message.value);
|
|
139
|
-
if (this.props.value === newValue) return;
|
|
140
|
-
if (this.props.mode === "writeBack") {
|
|
141
|
-
this.updateProps({ value: newValue });
|
|
142
|
-
}
|
|
143
|
-
this.events.emit("change", newValue);
|
|
144
|
-
}
|
|
145
|
-
setValue(value) {
|
|
146
|
-
const newValue = this.sanitizeNumber(value);
|
|
147
|
-
if (newValue === this.props.value) return;
|
|
148
|
-
this.updateProps({ value });
|
|
149
|
-
this.updateTree();
|
|
150
|
-
}
|
|
151
|
-
sanitizeNumber(value) {
|
|
152
|
-
const i = Math.round((value - this.props.min) / this.props.step);
|
|
153
|
-
const v = i * this.props.step + this.props.min;
|
|
154
|
-
const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
|
|
155
|
-
return clampedValue;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
SliderButton
|
|
161
|
-
});
|
|
8
|
+
exports.SliderButton = _chunkT2PJEXYOjs.SliderButton;
|
|
@@ -1,144 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Switch: () => Switch
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(switch_exports);
|
|
3
|
+
var _chunkM6EFK4GPjs = require('../../chunk-M6EFK4GP.js');
|
|
4
|
+
require('../../chunk-UBWCVW2U.js');
|
|
5
|
+
require('../../chunk-3RG5ZIWI.js');
|
|
26
6
|
|
|
27
|
-
// src/backend/components/base.ts
|
|
28
|
-
var Base = class {
|
|
29
|
-
/** @hidden */
|
|
30
|
-
parent = null;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
defaultProps;
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_props;
|
|
35
|
-
constructor(defaultProps, props) {
|
|
36
|
-
this.defaultProps = defaultProps;
|
|
37
|
-
this._props = Object.freeze({
|
|
38
|
-
...defaultProps,
|
|
39
|
-
...props
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get props() {
|
|
43
|
-
return this._props;
|
|
44
|
-
}
|
|
45
|
-
set props(props) {
|
|
46
|
-
this.setProps(props);
|
|
47
|
-
}
|
|
48
|
-
setProps = (props) => {
|
|
49
|
-
this._props = Object.freeze({
|
|
50
|
-
...this.defaultProps,
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
53
|
-
this.updateTree();
|
|
54
|
-
};
|
|
55
|
-
updateProps = (updates) => {
|
|
56
|
-
this._props = Object.freeze({
|
|
57
|
-
...this._props,
|
|
58
|
-
...updates
|
|
59
|
-
});
|
|
60
|
-
this.updateTree();
|
|
61
|
-
};
|
|
62
|
-
/** @hidden */
|
|
63
|
-
setParent(parent) {
|
|
64
|
-
if (this.parent && this.parent !== parent) {
|
|
65
|
-
this.parent.removeChild(this);
|
|
66
|
-
}
|
|
67
|
-
this.parent = parent;
|
|
68
|
-
}
|
|
69
|
-
/** @hidden */
|
|
70
|
-
updateTree() {
|
|
71
|
-
if (this.parent) this.parent.updateTree();
|
|
72
|
-
}
|
|
73
|
-
/** @hidden */
|
|
74
|
-
handleMessage(message) {
|
|
75
|
-
console.log("Component Received Message:", message);
|
|
76
|
-
}
|
|
77
|
-
routeMessage(_idMap, _message) {
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var EventEmitter = class {
|
|
81
|
-
listeners = /* @__PURE__ */ new Map();
|
|
82
|
-
addListener = (type, listener) => {
|
|
83
|
-
let set = this.listeners.get(type);
|
|
84
|
-
if (!set) {
|
|
85
|
-
set = /* @__PURE__ */ new Set();
|
|
86
|
-
this.listeners.set(type, set);
|
|
87
|
-
}
|
|
88
|
-
set.add(listener);
|
|
89
|
-
};
|
|
90
|
-
removeListener = (type, listener) => {
|
|
91
|
-
this.listeners.get(type)?.delete(listener);
|
|
92
|
-
};
|
|
93
|
-
emit = (type, ...args) => {
|
|
94
|
-
return Promise.all(
|
|
95
|
-
[...this.listeners.get(type) || []].map(
|
|
96
|
-
(l) => new Promise((resolve, reject) => {
|
|
97
|
-
try {
|
|
98
|
-
resolve(l(...args));
|
|
99
|
-
} catch (e) {
|
|
100
|
-
reject(e);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
7
|
|
|
108
|
-
|
|
109
|
-
var DEFAULT_PROPS = {
|
|
110
|
-
state: "off"
|
|
111
|
-
};
|
|
112
|
-
var Switch = class extends Base {
|
|
113
|
-
/** @hidden */
|
|
114
|
-
events = new EventEmitter();
|
|
115
|
-
constructor(props) {
|
|
116
|
-
super(DEFAULT_PROPS, props);
|
|
117
|
-
}
|
|
118
|
-
addListener = this.events.addListener;
|
|
119
|
-
removeListener = this.events.removeListener;
|
|
120
|
-
/** @hidden */
|
|
121
|
-
getProtoInfo(idMap) {
|
|
122
|
-
return {
|
|
123
|
-
component: "switch",
|
|
124
|
-
key: idMap.getId(this),
|
|
125
|
-
state: this.props.state
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/** @hidden */
|
|
129
|
-
handleMessage(message) {
|
|
130
|
-
if (message.component === "switch") {
|
|
131
|
-
const state = this.props.state === "on" ? "off" : "on";
|
|
132
|
-
this.updateProps({ state });
|
|
133
|
-
this.events.emit("change", state);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
setValue(state) {
|
|
137
|
-
if (state === this.props.state) return;
|
|
138
|
-
this.updateProps({ state });
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
-
0 && (module.exports = {
|
|
143
|
-
Switch
|
|
144
|
-
});
|
|
8
|
+
exports.Switch = _chunkM6EFK4GPjs.Switch;
|