@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.
- package/dist/backend/components/base.d.mts +9 -2
- package/dist/backend/components/base.d.ts +9 -2
- package/dist/backend/components/base.js +2 -2
- package/dist/backend/components/base.mjs +1 -1
- package/dist/backend/components/button.d.mts +1 -0
- package/dist/backend/components/button.d.ts +1 -0
- package/dist/backend/components/button.js +3 -3
- package/dist/backend/components/button.mjs +2 -2
- package/dist/backend/components/group.d.mts +1 -0
- package/dist/backend/components/group.d.ts +1 -0
- package/dist/backend/components/group.js +3 -3
- package/dist/backend/components/group.mjs +2 -2
- package/dist/backend/components/label.d.mts +1 -0
- package/dist/backend/components/label.d.ts +1 -0
- package/dist/backend/components/label.js +3 -3
- package/dist/backend/components/label.mjs +2 -2
- package/dist/backend/components/rect.d.mts +1 -0
- package/dist/backend/components/rect.d.ts +1 -0
- package/dist/backend/components/rect.js +3 -3
- package/dist/backend/components/rect.mjs +2 -2
- package/dist/backend/components/slider-button.d.mts +10 -4
- package/dist/backend/components/slider-button.d.ts +10 -4
- package/dist/backend/components/slider-button.js +3 -3
- package/dist/backend/components/slider-button.mjs +2 -2
- package/dist/backend/components/switch.d.mts +9 -1
- package/dist/backend/components/switch.d.ts +9 -1
- package/dist/backend/components/switch.js +3 -3
- package/dist/backend/components/switch.mjs +2 -2
- package/dist/backend/components/tabs.d.mts +1 -0
- package/dist/backend/components/tabs.d.ts +1 -0
- package/dist/backend/components/tabs.js +3 -3
- package/dist/backend/components/tabs.mjs +2 -2
- package/dist/backend/components/text-input.d.mts +1 -0
- package/dist/backend/components/text-input.d.ts +1 -0
- package/dist/backend/components/text-input.js +3 -3
- package/dist/backend/components/text-input.mjs +2 -2
- package/dist/backend/components/timeline.d.mts +1 -0
- package/dist/backend/components/timeline.d.ts +1 -0
- package/dist/backend/components/timeline.js +3 -3
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/{chunk-K24YPCR5.js → chunk-4HHKW7VA.js} +4 -4
- package/dist/{chunk-KVJU3EAD.js → chunk-4X3QY5EP.js} +3 -3
- package/dist/{chunk-JW4GXS54.mjs → chunk-A2STBGBE.mjs} +28 -11
- package/dist/{chunk-RJS32OOA.js → chunk-C2TVGO43.js} +3 -3
- package/dist/{chunk-UBWCVW2U.js → chunk-CFO5PSSK.js} +27 -21
- package/dist/{chunk-SOC4TF3J.mjs → chunk-DBSYI5Z4.mjs} +1 -1
- package/dist/{chunk-MDFDWKGW.js → chunk-DONU33U4.js} +3 -3
- package/dist/{chunk-P43QUQ4T.js → chunk-FLRGYURV.js} +2 -2
- package/dist/{chunk-OEIGZ3NQ.js → chunk-FUINWM5H.js} +2 -2
- package/dist/{chunk-TAZH4BBH.mjs → chunk-G5QXW2L3.mjs} +1 -1
- package/dist/chunk-G7GFSIHY.js +76 -0
- package/dist/{chunk-TQ27Y7F4.mjs → chunk-H734NV65.mjs} +1 -1
- package/dist/{chunk-HNEUZVCX.mjs → chunk-JOW3XRQI.mjs} +1 -1
- package/dist/{chunk-RGIB65TI.js → chunk-K572ZPUS.js} +2 -2
- package/dist/{chunk-3O4P67DM.mjs → chunk-KBPQZJKE.mjs} +1 -1
- package/dist/{chunk-ZU5H6SVA.mjs → chunk-KOKUFP6V.mjs} +1 -1
- package/dist/{chunk-IXTM35YM.mjs → chunk-KR6LSBBX.mjs} +1 -1
- package/dist/{chunk-ZCHM3JJJ.mjs → chunk-PW7QVLLF.mjs} +10 -4
- package/dist/chunk-Q3NG5UUN.mjs +61 -0
- package/dist/chunk-Q5TEM6MM.js +61 -0
- package/dist/frontend.js +0 -3
- package/dist/frontend.js.map +2 -2
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +30 -26
- package/dist/index.mjs +28 -24
- package/package.json +8 -6
- package/dist/chunk-APCR3ITH.mjs +0 -42
- package/dist/chunk-M6EFK4GP.js +0 -42
- package/dist/chunk-T2PJEXYO.js +0 -59
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as _arcanejs_protocol_logging from '@arcanejs/protocol/logging';
|
|
2
|
+
import { Logger } from '@arcanejs/protocol/logging';
|
|
1
3
|
import _ from 'lodash';
|
|
2
4
|
import * as http from 'http';
|
|
3
5
|
import { Application } from 'express';
|
|
@@ -5,7 +7,7 @@ import { WebSocket } from 'ws';
|
|
|
5
7
|
import { ClientMessage, ServerMessage } from '@arcanejs/protocol';
|
|
6
8
|
import { Group } from './backend/components/group.mjs';
|
|
7
9
|
export { GroupHeader } from './backend/components/group.mjs';
|
|
8
|
-
import { Component } from './backend/components/base.mjs';
|
|
10
|
+
import { Parent, Component } from './backend/components/base.mjs';
|
|
9
11
|
export { Button } from './backend/components/button.mjs';
|
|
10
12
|
export { Label } from './backend/components/label.mjs';
|
|
11
13
|
export { Rect } from './backend/components/rect.mjs';
|
|
@@ -25,7 +27,8 @@ declare class Server {
|
|
|
25
27
|
private readonly onNewConnection;
|
|
26
28
|
private readonly onClosedConnection;
|
|
27
29
|
private readonly onMessage;
|
|
28
|
-
|
|
30
|
+
private readonly log?;
|
|
31
|
+
constructor(options: LightDeskOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
29
32
|
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
30
33
|
private sendStaticFile;
|
|
31
34
|
handleWsConnection: <S extends WebSocket>(ws: S) => void;
|
|
@@ -38,12 +41,26 @@ interface LightDeskOptions {
|
|
|
38
41
|
* This is important if a express server will be used that serves other paths.
|
|
39
42
|
*/
|
|
40
43
|
path: string;
|
|
44
|
+
/**
|
|
45
|
+
* An optional object that can be used to output log events,
|
|
46
|
+
* we recommend using `pino` for this,
|
|
47
|
+
* as log levels etc... can be controlled.
|
|
48
|
+
*
|
|
49
|
+
* You can also always use `console` for logging,
|
|
50
|
+
* but this will be quite verbose.
|
|
51
|
+
*/
|
|
52
|
+
log?: Logger;
|
|
41
53
|
}
|
|
42
54
|
type InitializationOptions =
|
|
43
55
|
/** automatically start a simple */
|
|
44
56
|
{
|
|
45
57
|
mode: 'automatic';
|
|
46
58
|
port: number;
|
|
59
|
+
/**
|
|
60
|
+
* Optional callback that is called when the server is ready,
|
|
61
|
+
* with the url that the server is running on.
|
|
62
|
+
*/
|
|
63
|
+
onReady?: (url: string) => void;
|
|
47
64
|
}
|
|
48
65
|
/** Create a websocket server that attaches to an existing express and http server */
|
|
49
66
|
| {
|
|
@@ -57,7 +74,7 @@ type InitializationOptions =
|
|
|
57
74
|
setup: (server: Server) => void;
|
|
58
75
|
};
|
|
59
76
|
|
|
60
|
-
declare class Toolkit {
|
|
77
|
+
declare class Toolkit implements Parent {
|
|
61
78
|
private readonly options;
|
|
62
79
|
/**
|
|
63
80
|
* Mapping from components to unique IDs that identify them
|
|
@@ -68,6 +85,7 @@ declare class Toolkit {
|
|
|
68
85
|
constructor(options?: Partial<LightDeskOptions>);
|
|
69
86
|
start: (opts: InitializationOptions) => void;
|
|
70
87
|
setRoot: (group: Group) => void;
|
|
88
|
+
log(): _arcanejs_protocol_logging.Logger | null;
|
|
71
89
|
updateTree: _.DebouncedFuncLeading<() => void>;
|
|
72
90
|
removeChild: (component: Component) => void;
|
|
73
91
|
private onNewConnection;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as _arcanejs_protocol_logging from '@arcanejs/protocol/logging';
|
|
2
|
+
import { Logger } from '@arcanejs/protocol/logging';
|
|
1
3
|
import _ from 'lodash';
|
|
2
4
|
import * as http from 'http';
|
|
3
5
|
import { Application } from 'express';
|
|
@@ -5,7 +7,7 @@ import { WebSocket } from 'ws';
|
|
|
5
7
|
import { ClientMessage, ServerMessage } from '@arcanejs/protocol';
|
|
6
8
|
import { Group } from './backend/components/group.js';
|
|
7
9
|
export { GroupHeader } from './backend/components/group.js';
|
|
8
|
-
import { Component } from './backend/components/base.js';
|
|
10
|
+
import { Parent, Component } from './backend/components/base.js';
|
|
9
11
|
export { Button } from './backend/components/button.js';
|
|
10
12
|
export { Label } from './backend/components/label.js';
|
|
11
13
|
export { Rect } from './backend/components/rect.js';
|
|
@@ -25,7 +27,8 @@ declare class Server {
|
|
|
25
27
|
private readonly onNewConnection;
|
|
26
28
|
private readonly onClosedConnection;
|
|
27
29
|
private readonly onMessage;
|
|
28
|
-
|
|
30
|
+
private readonly log?;
|
|
31
|
+
constructor(options: LightDeskOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
29
32
|
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
30
33
|
private sendStaticFile;
|
|
31
34
|
handleWsConnection: <S extends WebSocket>(ws: S) => void;
|
|
@@ -38,12 +41,26 @@ interface LightDeskOptions {
|
|
|
38
41
|
* This is important if a express server will be used that serves other paths.
|
|
39
42
|
*/
|
|
40
43
|
path: string;
|
|
44
|
+
/**
|
|
45
|
+
* An optional object that can be used to output log events,
|
|
46
|
+
* we recommend using `pino` for this,
|
|
47
|
+
* as log levels etc... can be controlled.
|
|
48
|
+
*
|
|
49
|
+
* You can also always use `console` for logging,
|
|
50
|
+
* but this will be quite verbose.
|
|
51
|
+
*/
|
|
52
|
+
log?: Logger;
|
|
41
53
|
}
|
|
42
54
|
type InitializationOptions =
|
|
43
55
|
/** automatically start a simple */
|
|
44
56
|
{
|
|
45
57
|
mode: 'automatic';
|
|
46
58
|
port: number;
|
|
59
|
+
/**
|
|
60
|
+
* Optional callback that is called when the server is ready,
|
|
61
|
+
* with the url that the server is running on.
|
|
62
|
+
*/
|
|
63
|
+
onReady?: (url: string) => void;
|
|
47
64
|
}
|
|
48
65
|
/** Create a websocket server that attaches to an existing express and http server */
|
|
49
66
|
| {
|
|
@@ -57,7 +74,7 @@ type InitializationOptions =
|
|
|
57
74
|
setup: (server: Server) => void;
|
|
58
75
|
};
|
|
59
76
|
|
|
60
|
-
declare class Toolkit {
|
|
77
|
+
declare class Toolkit implements Parent {
|
|
61
78
|
private readonly options;
|
|
62
79
|
/**
|
|
63
80
|
* Mapping from components to unique IDs that identify them
|
|
@@ -68,6 +85,7 @@ declare class Toolkit {
|
|
|
68
85
|
constructor(options?: Partial<LightDeskOptions>);
|
|
69
86
|
start: (opts: InitializationOptions) => void;
|
|
70
87
|
setRoot: (group: Group) => void;
|
|
88
|
+
log(): _arcanejs_protocol_logging.Logger | null;
|
|
71
89
|
updateTree: _.DebouncedFuncLeading<() => void>;
|
|
72
90
|
removeChild: (component: Component) => void;
|
|
73
91
|
private onNewConnection;
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkC2TVGO43js = require('./chunk-C2TVGO43.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkDONU33U4js = require('./chunk-DONU33U4.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFUINWM5Hjs = require('./chunk-FUINWM5H.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunk4X3QY5EPjs = require('./chunk-4X3QY5EP.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunk4HHKW7VAjs = require('./chunk-4HHKW7VA.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkFLRGYURVjs = require('./chunk-FLRGYURV.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkK572ZPUSjs = require('./chunk-K572ZPUS.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkG7GFSIHYjs = require('./chunk-G7GFSIHY.js');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
33
|
-
require('./chunk-
|
|
32
|
+
var _chunkQ5TEM6MMjs = require('./chunk-Q5TEM6MM.js');
|
|
33
|
+
require('./chunk-CFO5PSSK.js');
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
@@ -79,16 +79,17 @@ var STATIC_FILES = {
|
|
|
79
79
|
contentType: "font/woff2"
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
console.log("STATIC_FILES", STATIC_FILES);
|
|
83
82
|
var Server = (_class = class {
|
|
84
|
-
constructor(options, onNewConnection, onClosedConnection, onMessage) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
83
|
+
constructor(options, onNewConnection, onClosedConnection, onMessage, log) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
85
84
|
this.options = options;
|
|
86
85
|
this.onNewConnection = onNewConnection;
|
|
87
86
|
this.onClosedConnection = onClosedConnection;
|
|
88
87
|
this.onMessage = onMessage;
|
|
88
|
+
this.log = log;
|
|
89
|
+
_optionalChain([log, 'optionalAccess', _14 => _14.debug, 'call', _15 => _15("Static Assets: %o", STATIC_FILES)]);
|
|
89
90
|
}
|
|
90
91
|
__init() {this.handleHttpRequest = async (req, res) => {
|
|
91
|
-
|
|
92
|
+
_optionalChain([this, 'access', _16 => _16.log, 'optionalAccess', _17 => _17.debug, 'call', _18 => _18("handleHttpRequest %s", req.url)]);
|
|
92
93
|
if (req.url === this.options.path) {
|
|
93
94
|
const content = `
|
|
94
95
|
<html>
|
|
@@ -114,7 +115,7 @@ var Server = (_class = class {
|
|
|
114
115
|
this.sendStaticFile(f.path, res, f.contentType);
|
|
115
116
|
},
|
|
116
117
|
(err) => {
|
|
117
|
-
|
|
118
|
+
_optionalChain([this, 'access', _19 => _19.log, 'optionalAccess', _20 => _20.error, 'call', _21 => _21(err)]);
|
|
118
119
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
119
120
|
res.end("Expected static file not found", "utf-8");
|
|
120
121
|
}
|
|
@@ -125,7 +126,7 @@ var Server = (_class = class {
|
|
|
125
126
|
res.end("not found", "utf-8");
|
|
126
127
|
}}
|
|
127
128
|
__init2() {this.sendStaticFile = (file, response, contentType) => {
|
|
128
|
-
fs.readFile(file,
|
|
129
|
+
fs.readFile(file, (error, content) => {
|
|
129
130
|
if (error) {
|
|
130
131
|
if (error.code === "ENOENT") {
|
|
131
132
|
response.writeHead(404, { "Content-Type": "text/plain" });
|
|
@@ -133,7 +134,7 @@ var Server = (_class = class {
|
|
|
133
134
|
} else {
|
|
134
135
|
response.writeHead(500, { "Content-Type": "text/plain" });
|
|
135
136
|
response.end("Error", "utf-8");
|
|
136
|
-
|
|
137
|
+
_optionalChain([this, 'access', _22 => _22.log, 'optionalAccess', _23 => _23.error, 'call', _24 => _24(`Error reading static file: %s`, error)]);
|
|
137
138
|
}
|
|
138
139
|
} else {
|
|
139
140
|
response.writeHead(200, { "Content-Type": contentType });
|
|
@@ -146,7 +147,7 @@ var Server = (_class = class {
|
|
|
146
147
|
sendMessage: (msg) => ws.send(JSON.stringify(msg))
|
|
147
148
|
};
|
|
148
149
|
this.onNewConnection(connection);
|
|
149
|
-
|
|
150
|
+
_optionalChain([this, 'access', _25 => _25.log, 'optionalAccess', _26 => _26.debug, 'call', _27 => _27("new connection")]);
|
|
150
151
|
ws.on(
|
|
151
152
|
"message",
|
|
152
153
|
(msg) => this.onMessage(connection, JSON.parse(msg.toString()))
|
|
@@ -158,7 +159,6 @@ var Server = (_class = class {
|
|
|
158
159
|
// src/backend/toolkit.ts
|
|
159
160
|
var _ws = require('ws');
|
|
160
161
|
var _http = require('http');
|
|
161
|
-
console.log(_diff.diffJson);
|
|
162
162
|
var Toolkit = (_class2 = class {
|
|
163
163
|
|
|
164
164
|
/**
|
|
@@ -183,7 +183,8 @@ var Toolkit = (_class2 = class {
|
|
|
183
183
|
this.options,
|
|
184
184
|
this.onNewConnection,
|
|
185
185
|
this.onClosedConnection,
|
|
186
|
-
this.onMessage
|
|
186
|
+
this.onMessage,
|
|
187
|
+
this.options.log
|
|
187
188
|
);
|
|
188
189
|
if (opts.mode === "automatic") {
|
|
189
190
|
const httpServer = _http.createServer.call(void 0, server.handleHttpRequest);
|
|
@@ -191,10 +192,10 @@ var Toolkit = (_class2 = class {
|
|
|
191
192
|
server: httpServer
|
|
192
193
|
});
|
|
193
194
|
wss.on("connection", server.handleWsConnection);
|
|
195
|
+
const url = `http://localhost:${opts.port}${this.options.path}`;
|
|
194
196
|
httpServer.listen(opts.port, () => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
197
|
+
_optionalChain([opts, 'access', _45 => _45.onReady, 'optionalCall', _46 => _46(url)]);
|
|
198
|
+
_optionalChain([this, 'access', _47 => _47.options, 'access', _48 => _48.log, 'optionalAccess', _49 => _49.info, 'call', _50 => _50(`Light Desk Started: ${url}`)]);
|
|
198
199
|
});
|
|
199
200
|
} else if (opts.mode === "express") {
|
|
200
201
|
const wss = new (0, _ws.WebSocketServer)({
|
|
@@ -215,6 +216,9 @@ var Toolkit = (_class2 = class {
|
|
|
215
216
|
this.rootGroup = group;
|
|
216
217
|
this.rootGroup.setParent(this);
|
|
217
218
|
}}
|
|
219
|
+
log() {
|
|
220
|
+
return _nullishCoalesce(this.options.log, () => ( null));
|
|
221
|
+
}
|
|
218
222
|
__init9() {this.updateTree = _lodash2.default.throttle(
|
|
219
223
|
() => {
|
|
220
224
|
setImmediate(() => {
|
|
@@ -239,7 +243,7 @@ var Toolkit = (_class2 = class {
|
|
|
239
243
|
}
|
|
240
244
|
}}
|
|
241
245
|
__init11() {this.onNewConnection = (connection) => {
|
|
242
|
-
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access',
|
|
246
|
+
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access', _51 => _51.rootGroup, 'optionalAccess', _52 => _52.getProtoInfo, 'call', _53 => _53(this.componentIDMap)]), () => ( void 0));
|
|
243
247
|
this.connections.set(connection, { lastTreeSent });
|
|
244
248
|
if (lastTreeSent) {
|
|
245
249
|
connection.sendMessage({
|
|
@@ -249,11 +253,11 @@ var Toolkit = (_class2 = class {
|
|
|
249
253
|
}
|
|
250
254
|
}}
|
|
251
255
|
__init12() {this.onClosedConnection = (connection) => {
|
|
252
|
-
|
|
256
|
+
_optionalChain([this, 'access', _54 => _54.options, 'access', _55 => _55.log, 'optionalAccess', _56 => _56.debug, 'call', _57 => _57("removing connection")]);
|
|
253
257
|
this.connections.delete(connection);
|
|
254
258
|
}}
|
|
255
259
|
__init13() {this.onMessage = (_connection, message) => {
|
|
256
|
-
|
|
260
|
+
_optionalChain([this, 'access', _58 => _58.options, 'access', _59 => _59.log, 'optionalAccess', _60 => _60.debug, 'call', _61 => _61("got message: %o", message)]);
|
|
257
261
|
switch (message.type) {
|
|
258
262
|
case "component-message":
|
|
259
263
|
if (this.rootGroup)
|
|
@@ -275,4 +279,4 @@ var Toolkit = (_class2 = class {
|
|
|
275
279
|
|
|
276
280
|
|
|
277
281
|
|
|
278
|
-
exports.Button =
|
|
282
|
+
exports.Button = _chunk4X3QY5EPjs.Button; exports.Group = _chunk4HHKW7VAjs.Group; exports.GroupHeader = _chunk4HHKW7VAjs.GroupHeader; exports.Label = _chunkFLRGYURVjs.Label; exports.Rect = _chunkK572ZPUSjs.Rect; exports.SliderButton = _chunkG7GFSIHYjs.SliderButton; exports.Switch = _chunkQ5TEM6MMjs.Switch; exports.Tab = _chunkC2TVGO43js.Tab; exports.Tabs = _chunkC2TVGO43js.Tabs; exports.TextInput = _chunkDONU33U4js.TextInput; exports.Timeline = _chunkFUINWM5Hjs.Timeline; exports.Toolkit = Toolkit;
|
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tab,
|
|
3
3
|
Tabs
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-H734NV65.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TextInput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KR6LSBBX.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Timeline
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DBSYI5Z4.mjs";
|
|
11
11
|
import {
|
|
12
12
|
IDMap
|
|
13
13
|
} from "./chunk-RGHJEMWG.mjs";
|
|
14
14
|
import {
|
|
15
15
|
Button
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-G5QXW2L3.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Group,
|
|
19
19
|
GroupHeader
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-KBPQZJKE.mjs";
|
|
21
21
|
import {
|
|
22
22
|
Label
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JOW3XRQI.mjs";
|
|
24
24
|
import {
|
|
25
25
|
Rect
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KOKUFP6V.mjs";
|
|
27
27
|
import {
|
|
28
28
|
SliderButton
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-A2STBGBE.mjs";
|
|
30
30
|
import {
|
|
31
31
|
Switch
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-Q3NG5UUN.mjs";
|
|
33
|
+
import "./chunk-PW7QVLLF.mjs";
|
|
34
34
|
import {
|
|
35
35
|
__require
|
|
36
36
|
} from "./chunk-Y6FXYEAI.mjs";
|
|
@@ -79,16 +79,17 @@ var STATIC_FILES = {
|
|
|
79
79
|
contentType: "font/woff2"
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
console.log("STATIC_FILES", STATIC_FILES);
|
|
83
82
|
var Server = class {
|
|
84
|
-
constructor(options, onNewConnection, onClosedConnection, onMessage) {
|
|
83
|
+
constructor(options, onNewConnection, onClosedConnection, onMessage, log) {
|
|
85
84
|
this.options = options;
|
|
86
85
|
this.onNewConnection = onNewConnection;
|
|
87
86
|
this.onClosedConnection = onClosedConnection;
|
|
88
87
|
this.onMessage = onMessage;
|
|
88
|
+
this.log = log;
|
|
89
|
+
log?.debug("Static Assets: %o", STATIC_FILES);
|
|
89
90
|
}
|
|
90
91
|
handleHttpRequest = async (req, res) => {
|
|
91
|
-
|
|
92
|
+
this.log?.debug("handleHttpRequest %s", req.url);
|
|
92
93
|
if (req.url === this.options.path) {
|
|
93
94
|
const content = `
|
|
94
95
|
<html>
|
|
@@ -114,7 +115,7 @@ var Server = class {
|
|
|
114
115
|
this.sendStaticFile(f.path, res, f.contentType);
|
|
115
116
|
},
|
|
116
117
|
(err) => {
|
|
117
|
-
|
|
118
|
+
this.log?.error(err);
|
|
118
119
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
119
120
|
res.end("Expected static file not found", "utf-8");
|
|
120
121
|
}
|
|
@@ -125,7 +126,7 @@ var Server = class {
|
|
|
125
126
|
res.end("not found", "utf-8");
|
|
126
127
|
};
|
|
127
128
|
sendStaticFile = (file, response, contentType) => {
|
|
128
|
-
fs.readFile(file,
|
|
129
|
+
fs.readFile(file, (error, content) => {
|
|
129
130
|
if (error) {
|
|
130
131
|
if (error.code === "ENOENT") {
|
|
131
132
|
response.writeHead(404, { "Content-Type": "text/plain" });
|
|
@@ -133,7 +134,7 @@ var Server = class {
|
|
|
133
134
|
} else {
|
|
134
135
|
response.writeHead(500, { "Content-Type": "text/plain" });
|
|
135
136
|
response.end("Error", "utf-8");
|
|
136
|
-
|
|
137
|
+
this.log?.error(`Error reading static file: %s`, error);
|
|
137
138
|
}
|
|
138
139
|
} else {
|
|
139
140
|
response.writeHead(200, { "Content-Type": contentType });
|
|
@@ -146,7 +147,7 @@ var Server = class {
|
|
|
146
147
|
sendMessage: (msg) => ws.send(JSON.stringify(msg))
|
|
147
148
|
};
|
|
148
149
|
this.onNewConnection(connection);
|
|
149
|
-
|
|
150
|
+
this.log?.debug("new connection");
|
|
150
151
|
ws.on(
|
|
151
152
|
"message",
|
|
152
153
|
(msg) => this.onMessage(connection, JSON.parse(msg.toString()))
|
|
@@ -158,7 +159,6 @@ var Server = class {
|
|
|
158
159
|
// src/backend/toolkit.ts
|
|
159
160
|
import { WebSocketServer } from "ws";
|
|
160
161
|
import { createServer } from "http";
|
|
161
|
-
console.log(diffJson);
|
|
162
162
|
var Toolkit = class {
|
|
163
163
|
options;
|
|
164
164
|
/**
|
|
@@ -183,7 +183,8 @@ var Toolkit = class {
|
|
|
183
183
|
this.options,
|
|
184
184
|
this.onNewConnection,
|
|
185
185
|
this.onClosedConnection,
|
|
186
|
-
this.onMessage
|
|
186
|
+
this.onMessage,
|
|
187
|
+
this.options.log
|
|
187
188
|
);
|
|
188
189
|
if (opts.mode === "automatic") {
|
|
189
190
|
const httpServer = createServer(server.handleHttpRequest);
|
|
@@ -191,10 +192,10 @@ var Toolkit = class {
|
|
|
191
192
|
server: httpServer
|
|
192
193
|
});
|
|
193
194
|
wss.on("connection", server.handleWsConnection);
|
|
195
|
+
const url = `http://localhost:${opts.port}${this.options.path}`;
|
|
194
196
|
httpServer.listen(opts.port, () => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
197
|
+
opts.onReady?.(url);
|
|
198
|
+
this.options.log?.info(`Light Desk Started: ${url}`);
|
|
198
199
|
});
|
|
199
200
|
} else if (opts.mode === "express") {
|
|
200
201
|
const wss = new WebSocketServer({
|
|
@@ -215,6 +216,9 @@ var Toolkit = class {
|
|
|
215
216
|
this.rootGroup = group;
|
|
216
217
|
this.rootGroup.setParent(this);
|
|
217
218
|
};
|
|
219
|
+
log() {
|
|
220
|
+
return this.options.log ?? null;
|
|
221
|
+
}
|
|
218
222
|
updateTree = _.throttle(
|
|
219
223
|
() => {
|
|
220
224
|
setImmediate(() => {
|
|
@@ -249,11 +253,11 @@ var Toolkit = class {
|
|
|
249
253
|
}
|
|
250
254
|
};
|
|
251
255
|
onClosedConnection = (connection) => {
|
|
252
|
-
|
|
256
|
+
this.options.log?.debug("removing connection");
|
|
253
257
|
this.connections.delete(connection);
|
|
254
258
|
};
|
|
255
259
|
onMessage = (_connection, message) => {
|
|
256
|
-
|
|
260
|
+
this.options.log?.debug("got message: %o", message);
|
|
257
261
|
switch (message.type) {
|
|
258
262
|
case "component-message":
|
|
259
263
|
if (this.rootGroup)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
"import": "./dist/backend/util/index.mjs",
|
|
89
89
|
"require": "./dist/backend/util/index.js",
|
|
90
90
|
"types": "./dist/backend/util/index.d.ts"
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
|
+
"./package.json": "./package.json"
|
|
92
93
|
},
|
|
93
94
|
"devDependencies": {
|
|
94
95
|
"@types/eslint": "^8.56.5",
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
"@types/react": "^18",
|
|
99
100
|
"@types/react-dom": "^18",
|
|
100
101
|
"@types/ws": "^8.5.12",
|
|
102
|
+
"check-export-map": "^1.3.1",
|
|
101
103
|
"esbuild": "^0.24.0",
|
|
102
104
|
"eslint": "^8.57.0",
|
|
103
105
|
"react": "^18",
|
|
@@ -106,7 +108,7 @@
|
|
|
106
108
|
"tsup": "^8.1.0",
|
|
107
109
|
"typescript": "^5.3.3",
|
|
108
110
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
109
|
-
"@arcanejs/toolkit-frontend": "^0.0
|
|
111
|
+
"@arcanejs/toolkit-frontend": "^0.1.0",
|
|
110
112
|
"@arcanejs/typescript-config": "^0.0.0"
|
|
111
113
|
},
|
|
112
114
|
"dependencies": {
|
|
@@ -114,8 +116,8 @@
|
|
|
114
116
|
"lodash": "^4.17.21",
|
|
115
117
|
"material-symbols": "^0.25.0",
|
|
116
118
|
"ws": "^8.18.0",
|
|
117
|
-
"@arcanejs/
|
|
118
|
-
"@arcanejs/
|
|
119
|
+
"@arcanejs/diff": "^0.4.0",
|
|
120
|
+
"@arcanejs/protocol": "^0.2.0"
|
|
119
121
|
},
|
|
120
122
|
"files": [
|
|
121
123
|
"dist"
|
|
@@ -125,7 +127,7 @@
|
|
|
125
127
|
},
|
|
126
128
|
"scripts": {
|
|
127
129
|
"lint": "eslint . --max-warnings 0",
|
|
128
|
-
"build": "pnpm build:backend && pnpm type-check:frontend && pnpm build:frontend",
|
|
130
|
+
"build": "rm -rf dist && pnpm build:backend && pnpm type-check:frontend && pnpm build:frontend && check-export-map",
|
|
129
131
|
"build:backend": "tsup",
|
|
130
132
|
"build:frontend": "esbuild src/frontend/frontend.ts --bundle --sourcemap --outfile=dist/frontend.js",
|
|
131
133
|
"dev": "pnpm dev:backend & pnpm dev:frontend",
|
package/dist/chunk-APCR3ITH.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base,
|
|
3
|
-
EventEmitter
|
|
4
|
-
} from "./chunk-ZCHM3JJJ.mjs";
|
|
5
|
-
|
|
6
|
-
// src/backend/components/switch.ts
|
|
7
|
-
var DEFAULT_PROPS = {
|
|
8
|
-
state: "off"
|
|
9
|
-
};
|
|
10
|
-
var Switch = class extends Base {
|
|
11
|
-
/** @hidden */
|
|
12
|
-
events = new EventEmitter();
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(DEFAULT_PROPS, props);
|
|
15
|
-
}
|
|
16
|
-
addListener = this.events.addListener;
|
|
17
|
-
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
|
-
};
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
Switch
|
|
42
|
-
};
|
package/dist/chunk-M6EFK4GP.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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;
|
package/dist/chunk-T2PJEXYO.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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;
|