@arcanejs/toolkit 0.2.0 → 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.d.mts +69 -2
- package/dist/backend/components/base.d.ts +69 -2
- package/dist/backend/components/base.js +10 -188
- package/dist/backend/components/base.mjs +2 -1
- package/dist/backend/components/button.d.mts +5 -4
- package/dist/backend/components/button.d.ts +5 -4
- package/dist/backend/components/button.js +5 -165
- package/dist/backend/components/button.mjs +3 -2
- package/dist/backend/components/group.d.mts +9 -7
- package/dist/backend/components/group.d.ts +9 -7
- package/dist/backend/components/group.js +6 -282
- package/dist/backend/components/group.mjs +3 -2
- package/dist/backend/components/label.d.mts +5 -3
- package/dist/backend/components/label.d.ts +5 -3
- package/dist/backend/components/label.js +5 -102
- package/dist/backend/components/label.mjs +3 -2
- package/dist/backend/components/rect.d.mts +4 -3
- package/dist/backend/components/rect.d.ts +4 -3
- package/dist/backend/components/rect.js +5 -102
- package/dist/backend/components/rect.mjs +3 -2
- package/dist/backend/components/slider-button.d.mts +5 -4
- package/dist/backend/components/slider-button.d.ts +5 -4
- package/dist/backend/components/slider-button.js +5 -158
- package/dist/backend/components/slider-button.mjs +3 -2
- package/dist/backend/components/switch.d.mts +5 -4
- package/dist/backend/components/switch.d.ts +5 -4
- package/dist/backend/components/switch.js +5 -141
- package/dist/backend/components/switch.mjs +3 -2
- package/dist/backend/components/tabs.d.mts +5 -4
- package/dist/backend/components/tabs.d.ts +5 -4
- package/dist/backend/components/tabs.js +7 -206
- package/dist/backend/components/tabs.mjs +3 -2
- package/dist/backend/components/text-input.d.mts +5 -4
- package/dist/backend/components/text-input.d.ts +5 -4
- package/dist/backend/components/text-input.js +5 -143
- package/dist/backend/components/text-input.mjs +3 -2
- package/dist/backend/components/timeline.d.mts +6 -5
- package/dist/backend/components/timeline.d.ts +6 -5
- package/dist/backend/components/timeline.js +5 -106
- package/dist/backend/components/timeline.mjs +3 -2
- package/dist/backend/util/index.d.mts +7 -0
- package/dist/backend/util/index.d.ts +7 -0
- package/dist/backend/util/index.js +7 -0
- package/dist/backend/util/index.mjs +7 -0
- package/dist/{chunk-L243ZOAR.mjs → chunk-3O4P67DM.mjs} +2 -4
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-37VNFO5S.mjs → chunk-APCR3ITH.mjs} +1 -1
- package/dist/chunk-EABM5X65.js +17 -0
- package/dist/{chunk-P6X5GIDT.mjs → chunk-HNEUZVCX.mjs} +1 -1
- package/dist/{chunk-6LL3X7ZZ.mjs → chunk-IXTM35YM.mjs} +1 -1
- package/dist/{chunk-HVFTRNLQ.mjs → chunk-JW4GXS54.mjs} +1 -1
- 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-RGHJEMWG.mjs +17 -0
- package/dist/chunk-RGIB65TI.js +29 -0
- package/dist/chunk-RJS32OOA.js +55 -0
- package/dist/{chunk-DBW4OPGN.mjs → chunk-SOC4TF3J.mjs} +1 -1
- package/dist/chunk-T2PJEXYO.js +59 -0
- package/dist/{chunk-DP3QFYSS.mjs → chunk-TAZH4BBH.mjs} +1 -1
- package/dist/{chunk-3ZBM7Q4A.mjs → chunk-TQ27Y7F4.mjs} +1 -1
- package/dist/chunk-UBWCVW2U.js +163 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/{chunk-HF77PS7J.mjs → chunk-ZCHM3JJJ.mjs} +0 -8
- package/dist/{chunk-GQZA5K4M.mjs → chunk-ZU5H6SVA.mjs} +1 -1
- package/dist/frontend.js +1345 -398
- package/dist/frontend.js.map +4 -4
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +82 -658
- package/dist/index.mjs +14 -24
- package/package.json +10 -2
- package/dist/base-BJAPu0O1.d.mts +0 -234
- package/dist/base-BJAPu0O1.d.ts +0 -234
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
5
|
+
|
|
6
|
+
// src/backend/components/switch.ts
|
|
7
|
+
var DEFAULT_PROPS = {
|
|
8
|
+
state: "off"
|
|
9
|
+
};
|
|
10
|
+
var Switch = (_class = class extends _chunkUBWCVW2Ujs.Base {
|
|
11
|
+
/** @hidden */
|
|
12
|
+
__init() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);;
|
|
15
|
+
}
|
|
16
|
+
__init2() {this.addListener = this.events.addListener}
|
|
17
|
+
__init3() {this.removeListener = this.events.removeListener}
|
|
18
|
+
/** @hidden */
|
|
19
|
+
getProtoInfo(idMap) {
|
|
20
|
+
return {
|
|
21
|
+
component: "switch",
|
|
22
|
+
key: idMap.getId(this),
|
|
23
|
+
state: this.props.state
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** @hidden */
|
|
27
|
+
handleMessage(message) {
|
|
28
|
+
if (message.component === "switch") {
|
|
29
|
+
const state = this.props.state === "on" ? "off" : "on";
|
|
30
|
+
this.updateProps({ state });
|
|
31
|
+
this.events.emit("change", state);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
setValue(state) {
|
|
35
|
+
if (state === this.props.state) return;
|
|
36
|
+
this.updateProps({ state });
|
|
37
|
+
}
|
|
38
|
+
}, _class);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.Switch = Switch;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
5
|
+
|
|
6
|
+
// src/backend/components/text-input.ts
|
|
7
|
+
var DEFAULT_PROPS = {
|
|
8
|
+
value: null
|
|
9
|
+
};
|
|
10
|
+
var TextInput = (_class = class extends _chunkUBWCVW2Ujs.Base {
|
|
11
|
+
/** @hidden */
|
|
12
|
+
__init() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
|
|
13
|
+
constructor(props) {
|
|
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
|
+
}
|
|
16
|
+
__init2() {this.addListener = this.events.addListener}
|
|
17
|
+
__init3() {this.removeListener = this.events.removeListener}
|
|
18
|
+
/** @hidden */
|
|
19
|
+
__init4() {this.getProtoInfo = (idMap) => {
|
|
20
|
+
return {
|
|
21
|
+
component: "text-input",
|
|
22
|
+
key: idMap.getId(this),
|
|
23
|
+
value: _nullishCoalesce(this.props.value, () => ( ""))
|
|
24
|
+
};
|
|
25
|
+
}}
|
|
26
|
+
/** @hidden */
|
|
27
|
+
__init5() {this.handleMessage = (message) => {
|
|
28
|
+
if (message.component === "text-input") {
|
|
29
|
+
if (this.props.value !== message.value) {
|
|
30
|
+
this.updateProps({ value: message.value });
|
|
31
|
+
this.events.emit("change", message.value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}}
|
|
35
|
+
__init6() {this.getValue = () => this.props.value}
|
|
36
|
+
__init7() {this.getValidatedValue = (validator) => this.props.value === "" ? null : validator(this.props.value || "")}
|
|
37
|
+
__init8() {this.setValue = (value) => {
|
|
38
|
+
this.updateProps({ value });
|
|
39
|
+
}}
|
|
40
|
+
}, _class);
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
exports.TextInput = TextInput;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/timeline.ts
|
|
6
|
+
var DEFAULT_PROPS = {
|
|
7
|
+
state: {
|
|
8
|
+
state: "stopped",
|
|
9
|
+
totalTimeMillis: 0,
|
|
10
|
+
currentTimeMillis: 0
|
|
11
|
+
},
|
|
12
|
+
title: null,
|
|
13
|
+
subtitles: null,
|
|
14
|
+
source: null
|
|
15
|
+
};
|
|
16
|
+
var Timeline = (_class = class extends _chunkUBWCVW2Ujs.Base {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);;
|
|
19
|
+
}
|
|
20
|
+
/** @hidden */
|
|
21
|
+
__init() {this.getProtoInfo = (idMap) => ({
|
|
22
|
+
component: "timeline",
|
|
23
|
+
key: idMap.getId(this),
|
|
24
|
+
state: this.props.state,
|
|
25
|
+
title: _nullishCoalesce(this.props.title, () => ( void 0)),
|
|
26
|
+
subtitles: _nullishCoalesce(this.props.subtitles, () => ( void 0)),
|
|
27
|
+
source: _nullishCoalesce(this.props.source, () => ( void 0))
|
|
28
|
+
})}
|
|
29
|
+
}, _class);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.Timeline = Timeline;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/label.ts
|
|
6
|
+
var Label = class extends _chunkUBWCVW2Ujs.Base {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super({ text: null }, props);
|
|
9
|
+
}
|
|
10
|
+
/** @hidden */
|
|
11
|
+
getProtoInfo(idMap) {
|
|
12
|
+
return {
|
|
13
|
+
component: "label",
|
|
14
|
+
key: idMap.getId(this),
|
|
15
|
+
bold: this.props.bold,
|
|
16
|
+
text: _nullishCoalesce(this.props.text, () => ( ""))
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
setText(text) {
|
|
20
|
+
this.updateProps({
|
|
21
|
+
text
|
|
22
|
+
});
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.Label = Label;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/backend/util/id-map.ts
|
|
2
|
+
var IDMap = class {
|
|
3
|
+
idMap = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
nextId = 0;
|
|
5
|
+
getId(object) {
|
|
6
|
+
let i = this.idMap.get(object);
|
|
7
|
+
if (i === void 0) {
|
|
8
|
+
i = this.nextId++;
|
|
9
|
+
this.idMap.set(object, i);
|
|
10
|
+
}
|
|
11
|
+
return i;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
IDMap
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
4
|
+
|
|
5
|
+
// src/backend/components/rect.ts
|
|
6
|
+
var DEFAULT_PROPS = {
|
|
7
|
+
color: "rgba(0, 0, 0, 0)"
|
|
8
|
+
};
|
|
9
|
+
var Rect = class extends _chunkUBWCVW2Ujs.Base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(DEFAULT_PROPS, props);
|
|
12
|
+
}
|
|
13
|
+
/** @hidden */
|
|
14
|
+
getProtoInfo(idMap) {
|
|
15
|
+
return {
|
|
16
|
+
component: "rect",
|
|
17
|
+
key: idMap.getId(this),
|
|
18
|
+
color: this.props.color
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
setColor(color) {
|
|
22
|
+
this.updateProps({ color });
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.Rect = Rect;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
4
|
+
|
|
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); }
|
|
7
|
+
__init() {this.validateChildren = (children) => {
|
|
8
|
+
if (children.length > 1) {
|
|
9
|
+
throw new Error("Tab can only have one child");
|
|
10
|
+
}
|
|
11
|
+
}}
|
|
12
|
+
/** @hidden */
|
|
13
|
+
__init2() {this.getProtoInfo = (idMap) => ({
|
|
14
|
+
component: "tab",
|
|
15
|
+
key: idMap.getId(this),
|
|
16
|
+
name: this.props.name,
|
|
17
|
+
child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
|
|
18
|
+
})}
|
|
19
|
+
}, _class);
|
|
20
|
+
var Tabs = (_class2 = class extends _chunkUBWCVW2Ujs.BaseParent {
|
|
21
|
+
__init3() {this.validateChildren = (children) => {
|
|
22
|
+
for (const child of children) {
|
|
23
|
+
if (!(child instanceof Tab)) {
|
|
24
|
+
throw new Error("Tabs can only have Tab children");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}}
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super({}, { ...props });_class2.prototype.__init3.call(this);;
|
|
30
|
+
}
|
|
31
|
+
addTabs(...tabs) {
|
|
32
|
+
for (const t of tabs) {
|
|
33
|
+
const tab = new Tab({ name: t.name });
|
|
34
|
+
tab.appendChildren(t.component);
|
|
35
|
+
this.appendChild(tab);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
addTab(name, component) {
|
|
39
|
+
this.addTabs({ name, component });
|
|
40
|
+
return component;
|
|
41
|
+
}
|
|
42
|
+
/** @hidden */
|
|
43
|
+
getProtoInfo(idMap) {
|
|
44
|
+
return {
|
|
45
|
+
component: "tabs",
|
|
46
|
+
key: idMap.getId(this),
|
|
47
|
+
tabs: this.getChildren().map((c) => c.getProtoInfo(idMap))
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}, _class2);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.Tab = Tab; exports.Tabs = Tabs;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
|
|
5
|
+
|
|
6
|
+
// src/backend/components/slider-button.ts
|
|
7
|
+
var DEFAULT_PROPS = {
|
|
8
|
+
value: null,
|
|
9
|
+
min: 0,
|
|
10
|
+
max: 255,
|
|
11
|
+
step: 5,
|
|
12
|
+
mode: "writeBack"
|
|
13
|
+
};
|
|
14
|
+
var SliderButton = (_class = class extends _chunkUBWCVW2Ujs.Base {
|
|
15
|
+
/** @hidden */
|
|
16
|
+
__init() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(DEFAULT_PROPS, props);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);;
|
|
19
|
+
}
|
|
20
|
+
__init2() {this.addListener = this.events.addListener}
|
|
21
|
+
__init3() {this.removeListener = this.events.removeListener}
|
|
22
|
+
/** @hidden */
|
|
23
|
+
getProtoInfo(idMap) {
|
|
24
|
+
return {
|
|
25
|
+
component: "slider_button",
|
|
26
|
+
key: idMap.getId(this),
|
|
27
|
+
min: this.props.min,
|
|
28
|
+
max: this.props.max,
|
|
29
|
+
step: this.props.step,
|
|
30
|
+
value: this.props.value
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** @hidden */
|
|
34
|
+
handleMessage(message) {
|
|
35
|
+
if (message.component !== "slider_button") return;
|
|
36
|
+
const newValue = this.sanitizeNumber(message.value);
|
|
37
|
+
if (this.props.value === newValue) return;
|
|
38
|
+
if (this.props.mode === "writeBack") {
|
|
39
|
+
this.updateProps({ value: newValue });
|
|
40
|
+
}
|
|
41
|
+
this.events.emit("change", newValue);
|
|
42
|
+
}
|
|
43
|
+
setValue(value) {
|
|
44
|
+
const newValue = this.sanitizeNumber(value);
|
|
45
|
+
if (newValue === this.props.value) return;
|
|
46
|
+
this.updateProps({ value });
|
|
47
|
+
this.updateTree();
|
|
48
|
+
}
|
|
49
|
+
sanitizeNumber(value) {
|
|
50
|
+
const i = Math.round((value - this.props.min) / this.props.step);
|
|
51
|
+
const v = i * this.props.step + this.props.min;
|
|
52
|
+
const clampedValue = Math.max(this.props.min, Math.min(this.props.max, v));
|
|
53
|
+
return clampedValue;
|
|
54
|
+
}
|
|
55
|
+
}, _class);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.SliderButton = SliderButton;
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
|
2
|
+
var Base = (_class = class {
|
|
3
|
+
/** @hidden */
|
|
4
|
+
__init() {this.parent = null}
|
|
5
|
+
/** @hidden */
|
|
6
|
+
|
|
7
|
+
/** @hidden */
|
|
8
|
+
|
|
9
|
+
constructor(defaultProps, props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
10
|
+
this.defaultProps = defaultProps;
|
|
11
|
+
this._props = Object.freeze({
|
|
12
|
+
...defaultProps,
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get props() {
|
|
17
|
+
return this._props;
|
|
18
|
+
}
|
|
19
|
+
set props(props) {
|
|
20
|
+
this.setProps(props);
|
|
21
|
+
}
|
|
22
|
+
__init2() {this.setProps = (props) => {
|
|
23
|
+
this._props = Object.freeze({
|
|
24
|
+
...this.defaultProps,
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
this.updateTree();
|
|
28
|
+
}}
|
|
29
|
+
__init3() {this.updateProps = (updates) => {
|
|
30
|
+
this._props = Object.freeze({
|
|
31
|
+
...this._props,
|
|
32
|
+
...updates
|
|
33
|
+
});
|
|
34
|
+
this.updateTree();
|
|
35
|
+
}}
|
|
36
|
+
/** @hidden */
|
|
37
|
+
setParent(parent) {
|
|
38
|
+
if (this.parent && this.parent !== parent) {
|
|
39
|
+
this.parent.removeChild(this);
|
|
40
|
+
}
|
|
41
|
+
this.parent = parent;
|
|
42
|
+
}
|
|
43
|
+
/** @hidden */
|
|
44
|
+
updateTree() {
|
|
45
|
+
if (this.parent) this.parent.updateTree();
|
|
46
|
+
}
|
|
47
|
+
/** @hidden */
|
|
48
|
+
handleMessage(message) {
|
|
49
|
+
console.log("Component Received Message:", message);
|
|
50
|
+
}
|
|
51
|
+
routeMessage(_idMap, _message) {
|
|
52
|
+
}
|
|
53
|
+
}, _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); }
|
|
55
|
+
/** @hidden */
|
|
56
|
+
__init4() {this.children = []}
|
|
57
|
+
__init5() {this.appendChildren = (...children) => {
|
|
58
|
+
for (const c of children) {
|
|
59
|
+
const newChildren = [...this.children.filter((ch) => ch !== c), c];
|
|
60
|
+
this.validateChildren(newChildren);
|
|
61
|
+
this.children = Object.freeze(newChildren);
|
|
62
|
+
c.setParent(this);
|
|
63
|
+
}
|
|
64
|
+
this.updateTree();
|
|
65
|
+
return children;
|
|
66
|
+
}}
|
|
67
|
+
__init6() {this.appendChild = (child) => {
|
|
68
|
+
this.appendChildren(child);
|
|
69
|
+
return child;
|
|
70
|
+
}}
|
|
71
|
+
__init7() {this.removeChild = (component) => {
|
|
72
|
+
const match = this.children.findIndex((c) => c === component);
|
|
73
|
+
if (match >= 0) {
|
|
74
|
+
const removingChild = this.children[match];
|
|
75
|
+
const newChildren = [
|
|
76
|
+
...this.children.slice(0, match),
|
|
77
|
+
...this.children.slice(match + 1)
|
|
78
|
+
];
|
|
79
|
+
this.validateChildren(newChildren);
|
|
80
|
+
this.children = Object.freeze(newChildren);
|
|
81
|
+
_optionalChain([removingChild, 'optionalAccess', _3 => _3.setParent, 'call', _4 => _4(null)]);
|
|
82
|
+
this.updateTree();
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
__init8() {this.removeAllChildren = () => {
|
|
86
|
+
this.children.map((c) => c.setParent(null));
|
|
87
|
+
this.children = Object.freeze([]);
|
|
88
|
+
this.updateTree();
|
|
89
|
+
}}
|
|
90
|
+
/**
|
|
91
|
+
* Return all children components that messages need to be routed to
|
|
92
|
+
*/
|
|
93
|
+
__init9() {this.getChildren = () => this.children}
|
|
94
|
+
/**
|
|
95
|
+
* TODO: we can do this better, right now it broadcasts the message to all
|
|
96
|
+
* components of the tree
|
|
97
|
+
*
|
|
98
|
+
* @hidden
|
|
99
|
+
*/
|
|
100
|
+
routeMessage(idMap, message) {
|
|
101
|
+
if (idMap.getId(this) === message.componentKey) {
|
|
102
|
+
this.handleMessage(message);
|
|
103
|
+
} else {
|
|
104
|
+
for (const c of this.children) {
|
|
105
|
+
if (idMap.getId(c) === message.componentKey) {
|
|
106
|
+
c.handleMessage(message);
|
|
107
|
+
} else {
|
|
108
|
+
c.routeMessage(idMap, message);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
insertBefore(child, beforeChild) {
|
|
114
|
+
const filteredChildren = this.children.filter((c) => c !== child);
|
|
115
|
+
let match = filteredChildren.findIndex((c) => c === beforeChild);
|
|
116
|
+
console.log("match", match);
|
|
117
|
+
if (match === -1) {
|
|
118
|
+
match = filteredChildren.length;
|
|
119
|
+
}
|
|
120
|
+
const newChildren = [
|
|
121
|
+
...filteredChildren.slice(0, match),
|
|
122
|
+
child,
|
|
123
|
+
...filteredChildren.slice(match)
|
|
124
|
+
];
|
|
125
|
+
this.validateChildren(newChildren);
|
|
126
|
+
this.children = Object.freeze(newChildren);
|
|
127
|
+
child.setParent(this);
|
|
128
|
+
this.updateTree();
|
|
129
|
+
}
|
|
130
|
+
}, _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) => {
|
|
134
|
+
let set = this.listeners.get(type);
|
|
135
|
+
if (!set) {
|
|
136
|
+
set = /* @__PURE__ */ new Set();
|
|
137
|
+
this.listeners.set(type, set);
|
|
138
|
+
}
|
|
139
|
+
set.add(listener);
|
|
140
|
+
}}
|
|
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)]);
|
|
143
|
+
}}
|
|
144
|
+
__init13() {this.emit = (type, ...args) => {
|
|
145
|
+
return Promise.all(
|
|
146
|
+
[...this.listeners.get(type) || []].map(
|
|
147
|
+
(l) => new Promise((resolve, reject) => {
|
|
148
|
+
try {
|
|
149
|
+
resolve(l(...args));
|
|
150
|
+
} catch (e) {
|
|
151
|
+
reject(e);
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
)
|
|
155
|
+
);
|
|
156
|
+
}}
|
|
157
|
+
}, _class3);
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
exports.Base = Base; exports.BaseParent = BaseParent; exports.EventEmitter = EventEmitter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/backend/components/base.ts
|
|
9
2
|
var Base = class {
|
|
10
3
|
/** @hidden */
|
|
@@ -164,7 +157,6 @@ var EventEmitter = class {
|
|
|
164
157
|
};
|
|
165
158
|
|
|
166
159
|
export {
|
|
167
|
-
__require,
|
|
168
160
|
Base,
|
|
169
161
|
BaseParent,
|
|
170
162
|
EventEmitter
|