@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.
@@ -1,209 +1,10 @@
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
- // src/backend/components/tabs.ts
21
- var tabs_exports = {};
22
- __export(tabs_exports, {
23
- Tab: () => Tab,
24
- Tabs: () => Tabs
25
- });
26
- module.exports = __toCommonJS(tabs_exports);
27
3
 
28
- // src/backend/components/base.ts
29
- var Base = class {
30
- /** @hidden */
31
- parent = null;
32
- /** @hidden */
33
- defaultProps;
34
- /** @hidden */
35
- _props;
36
- constructor(defaultProps, props) {
37
- this.defaultProps = defaultProps;
38
- this._props = Object.freeze({
39
- ...defaultProps,
40
- ...props
41
- });
42
- }
43
- get props() {
44
- return this._props;
45
- }
46
- set props(props) {
47
- this.setProps(props);
48
- }
49
- setProps = (props) => {
50
- this._props = Object.freeze({
51
- ...this.defaultProps,
52
- ...props
53
- });
54
- this.updateTree();
55
- };
56
- updateProps = (updates) => {
57
- this._props = Object.freeze({
58
- ...this._props,
59
- ...updates
60
- });
61
- this.updateTree();
62
- };
63
- /** @hidden */
64
- setParent(parent) {
65
- if (this.parent && this.parent !== parent) {
66
- this.parent.removeChild(this);
67
- }
68
- this.parent = parent;
69
- }
70
- /** @hidden */
71
- updateTree() {
72
- if (this.parent) this.parent.updateTree();
73
- }
74
- /** @hidden */
75
- handleMessage(message) {
76
- console.log("Component Received Message:", message);
77
- }
78
- routeMessage(_idMap, _message) {
79
- }
80
- };
81
- var BaseParent = class extends Base {
82
- /** @hidden */
83
- children = [];
84
- appendChildren = (...children) => {
85
- for (const c of children) {
86
- const newChildren = [...this.children.filter((ch) => ch !== c), c];
87
- this.validateChildren(newChildren);
88
- this.children = Object.freeze(newChildren);
89
- c.setParent(this);
90
- }
91
- this.updateTree();
92
- return children;
93
- };
94
- appendChild = (child) => {
95
- this.appendChildren(child);
96
- return child;
97
- };
98
- removeChild = (component) => {
99
- const match = this.children.findIndex((c) => c === component);
100
- if (match >= 0) {
101
- const removingChild = this.children[match];
102
- const newChildren = [
103
- ...this.children.slice(0, match),
104
- ...this.children.slice(match + 1)
105
- ];
106
- this.validateChildren(newChildren);
107
- this.children = Object.freeze(newChildren);
108
- removingChild?.setParent(null);
109
- this.updateTree();
110
- }
111
- };
112
- removeAllChildren = () => {
113
- this.children.map((c) => c.setParent(null));
114
- this.children = Object.freeze([]);
115
- this.updateTree();
116
- };
117
- /**
118
- * Return all children components that messages need to be routed to
119
- */
120
- getChildren = () => this.children;
121
- /**
122
- * TODO: we can do this better, right now it broadcasts the message to all
123
- * components of the tree
124
- *
125
- * @hidden
126
- */
127
- routeMessage(idMap, message) {
128
- if (idMap.getId(this) === message.componentKey) {
129
- this.handleMessage(message);
130
- } else {
131
- for (const c of this.children) {
132
- if (idMap.getId(c) === message.componentKey) {
133
- c.handleMessage(message);
134
- } else {
135
- c.routeMessage(idMap, message);
136
- }
137
- }
138
- }
139
- }
140
- insertBefore(child, beforeChild) {
141
- const filteredChildren = this.children.filter((c) => c !== child);
142
- let match = filteredChildren.findIndex((c) => c === beforeChild);
143
- console.log("match", match);
144
- if (match === -1) {
145
- match = filteredChildren.length;
146
- }
147
- const newChildren = [
148
- ...filteredChildren.slice(0, match),
149
- child,
150
- ...filteredChildren.slice(match)
151
- ];
152
- this.validateChildren(newChildren);
153
- this.children = Object.freeze(newChildren);
154
- child.setParent(this);
155
- this.updateTree();
156
- }
157
- };
4
+ var _chunkRJS32OOAjs = require('../../chunk-RJS32OOA.js');
5
+ require('../../chunk-UBWCVW2U.js');
6
+ require('../../chunk-3RG5ZIWI.js');
158
7
 
159
- // src/backend/components/tabs.ts
160
- var Tab = class extends BaseParent {
161
- validateChildren = (children) => {
162
- if (children.length > 1) {
163
- throw new Error("Tab can only have one child");
164
- }
165
- };
166
- /** @hidden */
167
- getProtoInfo = (idMap) => ({
168
- component: "tab",
169
- key: idMap.getId(this),
170
- name: this.props.name,
171
- child: this.getChildren().slice(0, 1).map((c) => c.getProtoInfo(idMap))[0]
172
- });
173
- };
174
- var Tabs = class extends BaseParent {
175
- validateChildren = (children) => {
176
- for (const child of children) {
177
- if (!(child instanceof Tab)) {
178
- throw new Error("Tabs can only have Tab children");
179
- }
180
- }
181
- };
182
- constructor(props) {
183
- super({}, { ...props });
184
- }
185
- addTabs(...tabs) {
186
- for (const t of tabs) {
187
- const tab = new Tab({ name: t.name });
188
- tab.appendChildren(t.component);
189
- this.appendChild(tab);
190
- }
191
- }
192
- addTab(name, component) {
193
- this.addTabs({ name, component });
194
- return component;
195
- }
196
- /** @hidden */
197
- getProtoInfo(idMap) {
198
- return {
199
- component: "tabs",
200
- key: idMap.getId(this),
201
- tabs: this.getChildren().map((c) => c.getProtoInfo(idMap))
202
- };
203
- }
204
- };
205
- // Annotate the CommonJS export names for ESM import in node:
206
- 0 && (module.exports = {
207
- Tab,
208
- Tabs
209
- });
8
+
9
+
10
+ exports.Tab = _chunkRJS32OOAjs.Tab; exports.Tabs = _chunkRJS32OOAjs.Tabs;
@@ -1,146 +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
- // src/backend/components/text-input.ts
21
- var text_input_exports = {};
22
- __export(text_input_exports, {
23
- TextInput: () => TextInput
24
- });
25
- module.exports = __toCommonJS(text_input_exports);
3
+ var _chunkMDFDWKGWjs = require('../../chunk-MDFDWKGW.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
- // src/backend/components/text-input.ts
109
- var DEFAULT_PROPS = {
110
- value: null
111
- };
112
- var TextInput = 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: "text-input",
124
- key: idMap.getId(this),
125
- value: this.props.value ?? ""
126
- };
127
- };
128
- /** @hidden */
129
- handleMessage = (message) => {
130
- if (message.component === "text-input") {
131
- if (this.props.value !== message.value) {
132
- this.updateProps({ value: message.value });
133
- this.events.emit("change", message.value);
134
- }
135
- }
136
- };
137
- getValue = () => this.props.value;
138
- getValidatedValue = (validator) => this.props.value === "" ? null : validator(this.props.value || "");
139
- setValue = (value) => {
140
- this.updateProps({ value });
141
- };
142
- };
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- TextInput
146
- });
8
+ exports.TextInput = _chunkMDFDWKGWjs.TextInput;
@@ -1,109 +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
- // src/backend/components/timeline.ts
21
- var timeline_exports = {};
22
- __export(timeline_exports, {
23
- Timeline: () => Timeline
24
- });
25
- module.exports = __toCommonJS(timeline_exports);
3
+ var _chunkOEIGZ3NQjs = require('../../chunk-OEIGZ3NQ.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
- // src/backend/components/timeline.ts
82
- var DEFAULT_PROPS = {
83
- state: {
84
- state: "stopped",
85
- totalTimeMillis: 0,
86
- currentTimeMillis: 0
87
- },
88
- title: null,
89
- subtitles: null,
90
- source: null
91
- };
92
- var Timeline = class extends Base {
93
- constructor(props) {
94
- super(DEFAULT_PROPS, props);
95
- }
96
- /** @hidden */
97
- getProtoInfo = (idMap) => ({
98
- component: "timeline",
99
- key: idMap.getId(this),
100
- state: this.props.state,
101
- title: this.props.title ?? void 0,
102
- subtitles: this.props.subtitles ?? void 0,
103
- source: this.props.source ?? void 0
104
- });
105
- };
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
108
- Timeline
109
- });
8
+ exports.Timeline = _chunkOEIGZ3NQjs.Timeline;
@@ -1,43 +1,7 @@
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
- // src/backend/util/index.ts
21
- var util_exports = {};
22
- __export(util_exports, {
23
- IDMap: () => IDMap
24
- });
25
- module.exports = __toCommonJS(util_exports);
3
+ var _chunkEABM5X65js = require('../../chunk-EABM5X65.js');
4
+ require('../../chunk-3RG5ZIWI.js');
26
5
 
27
- // src/backend/util/id-map.ts
28
- var IDMap = class {
29
- idMap = /* @__PURE__ */ new WeakMap();
30
- nextId = 0;
31
- getId(object) {
32
- let i = this.idMap.get(object);
33
- if (i === void 0) {
34
- i = this.nextId++;
35
- this.idMap.set(object, i);
36
- }
37
- return i;
38
- }
39
- };
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- IDMap
43
- });
6
+
7
+ exports.IDMap = _chunkEABM5X65js.IDMap;
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});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
+
9
+
10
+ exports.__require = __require;
@@ -0,0 +1,17 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;// src/backend/util/id-map.ts
2
+ var IDMap = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
3
+ __init() {this.idMap = /* @__PURE__ */ new WeakMap()}
4
+ __init2() {this.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
+ }, _class);
14
+
15
+
16
+
17
+ exports.IDMap = IDMap;
@@ -0,0 +1,104 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2;
2
+
3
+
4
+ var _chunkUBWCVW2Ujs = require('./chunk-UBWCVW2U.js');
5
+
6
+ // src/backend/components/group.ts
7
+ var GROUP_DEFAULT_STYLE = {
8
+ direction: "horizontal"
9
+ };
10
+ var DEFAULT_PROPS = {
11
+ ...GROUP_DEFAULT_STYLE,
12
+ title: null,
13
+ labels: null
14
+ };
15
+ var GroupHeader = (_class = class extends _chunkUBWCVW2Ujs.BaseParent {constructor(...args) { super(...args); _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
16
+ __init() {this.validateChildren = () => {
17
+ }}
18
+ /** @hidden */
19
+ __init2() {this.getProtoInfo = (idMap) => ({
20
+ component: "group-header",
21
+ key: idMap.getId(this),
22
+ children: this.getChildren().map((c) => c.getProtoInfo(idMap))
23
+ })}
24
+ }, _class);
25
+ var Group = (_class2 = class extends _chunkUBWCVW2Ujs.BaseParent {
26
+ /** @hidden */
27
+ __init3() {this.events = new (0, _chunkUBWCVW2Ujs.EventEmitter)()}
28
+ constructor(props) {
29
+ super(DEFAULT_PROPS, props);_class2.prototype.__init3.call(this);_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);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);;
30
+ }
31
+ __init4() {this.addListener = this.events.addListener}
32
+ __init5() {this.removeListener = this.events.removeListener}
33
+ __init6() {this.validateChildren = () => {
34
+ }}
35
+ __init7() {this.setOptions = (options) => {
36
+ this.updateProps(options);
37
+ }}
38
+ __init8() {this.setTitle = (title) => {
39
+ this.updateProps({ title });
40
+ }}
41
+ __init9() {this.addLabel = (label) => {
42
+ this.updateProps({ labels: [...this.props.labels || [], label] });
43
+ }}
44
+ __init10() {this.setLabels = (labels) => {
45
+ this.updateProps({ labels });
46
+ }}
47
+ __init11() {this.addHeaderChild = (child) => {
48
+ const header = new GroupHeader({});
49
+ header.appendChild(child);
50
+ this.appendChild(header);
51
+ return child;
52
+ }}
53
+ __init12() {this.removeHeaderChild = (child) => {
54
+ for (const c of this.getChildren()) {
55
+ if (c instanceof GroupHeader) {
56
+ c.removeChild(child);
57
+ }
58
+ }
59
+ }}
60
+ __init13() {this.removeAllHeaderChildren = () => {
61
+ for (const child of this.getChildren()) {
62
+ if (child instanceof GroupHeader) {
63
+ child.removeAllChildren();
64
+ }
65
+ }
66
+ }}
67
+ /** @hidden */
68
+ __init14() {this.getProtoInfo = (idMap) => {
69
+ const children = [];
70
+ const headers = [];
71
+ for (const c of this.getChildren()) {
72
+ const childProto = c.getProtoInfo(idMap);
73
+ if (childProto.component === "group-header") {
74
+ headers.push(childProto);
75
+ } else {
76
+ children.push(childProto);
77
+ }
78
+ }
79
+ return {
80
+ component: "group",
81
+ key: idMap.getId(this),
82
+ title: _nullishCoalesce(this.props.title, () => ( void 0)),
83
+ direction: this.props.direction,
84
+ border: this.props.border,
85
+ wrap: this.props.wrap,
86
+ children,
87
+ headers: headers.length > 0 ? headers : void 0,
88
+ labels: _nullishCoalesce(this.props.labels, () => ( void 0)),
89
+ editableTitle: this.props.editableTitle || false,
90
+ defaultCollapsibleState: this.props.defaultCollapsibleState
91
+ };
92
+ }}
93
+ /** @hidden */
94
+ __init15() {this.handleMessage = (message) => {
95
+ if (message.component === "group") {
96
+ this.events.emit("title-changed", message.title);
97
+ }
98
+ }}
99
+ }, _class2);
100
+
101
+
102
+
103
+
104
+ exports.GroupHeader = GroupHeader; exports.Group = Group;