@arcanejs/toolkit 0.2.2 → 0.3.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 +4 -1
- package/dist/backend/components/base.d.ts +4 -1
- 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 +1 -0
- package/dist/backend/components/slider-button.d.ts +1 -0
- 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 +1 -0
- package/dist/backend/components/switch.d.ts +1 -0
- 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-3O4P67DM.mjs → chunk-3Y3HRYLC.mjs} +1 -1
- package/dist/{chunk-HNEUZVCX.mjs → chunk-7ITSSJE2.mjs} +1 -1
- package/dist/{chunk-M6EFK4GP.js → chunk-DNCHAOYH.js} +3 -3
- package/dist/{chunk-OEIGZ3NQ.js → chunk-DV5WTSFW.js} +2 -2
- package/dist/{chunk-ZCHM3JJJ.mjs → chunk-EDTJ75FT.mjs} +4 -3
- package/dist/{chunk-TAZH4BBH.mjs → chunk-EH73E5FP.mjs} +1 -1
- package/dist/{chunk-JW4GXS54.mjs → chunk-H2UQDFTS.mjs} +1 -1
- package/dist/{chunk-MDFDWKGW.js → chunk-IW3JCC73.js} +3 -3
- package/dist/{chunk-KVJU3EAD.js → chunk-J46AJUGE.js} +3 -3
- package/dist/{chunk-IXTM35YM.mjs → chunk-NKNDCRUR.mjs} +1 -1
- package/dist/{chunk-UBWCVW2U.js → chunk-NZUYU32Z.js} +21 -20
- package/dist/{chunk-SOC4TF3J.mjs → chunk-POUQGJN4.mjs} +1 -1
- package/dist/{chunk-K24YPCR5.js → chunk-QUA3NBLD.js} +4 -4
- package/dist/{chunk-ZU5H6SVA.mjs → chunk-SMTUN6HG.mjs} +1 -1
- package/dist/{chunk-P43QUQ4T.js → chunk-TSC5C5XR.js} +2 -2
- package/dist/{chunk-RGIB65TI.js → chunk-WIPEQNWR.js} +2 -2
- package/dist/{chunk-RJS32OOA.js → chunk-WXSKMMCV.js} +3 -3
- package/dist/{chunk-TQ27Y7F4.mjs → chunk-YIXRQHTA.mjs} +1 -1
- package/dist/{chunk-T2PJEXYO.js → chunk-YN3FZMXY.js} +3 -3
- package/dist/{chunk-APCR3ITH.mjs → chunk-YYM7PBRN.mjs} +1 -1
- 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 +4 -4
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 _chunkWXSKMMCVjs = require('./chunk-WXSKMMCV.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIW3JCC73js = require('./chunk-IW3JCC73.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkDV5WTSFWjs = require('./chunk-DV5WTSFW.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkJ46AJUGEjs = require('./chunk-J46AJUGE.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkQUA3NBLDjs = require('./chunk-QUA3NBLD.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkTSC5C5XRjs = require('./chunk-TSC5C5XR.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkWIPEQNWRjs = require('./chunk-WIPEQNWR.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkYN3FZMXYjs = require('./chunk-YN3FZMXY.js');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
33
|
-
require('./chunk-
|
|
32
|
+
var _chunkDNCHAOYHjs = require('./chunk-DNCHAOYH.js');
|
|
33
|
+
require('./chunk-NZUYU32Z.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 = _chunkJ46AJUGEjs.Button; exports.Group = _chunkQUA3NBLDjs.Group; exports.GroupHeader = _chunkQUA3NBLDjs.GroupHeader; exports.Label = _chunkTSC5C5XRjs.Label; exports.Rect = _chunkWIPEQNWRjs.Rect; exports.SliderButton = _chunkYN3FZMXYjs.SliderButton; exports.Switch = _chunkDNCHAOYHjs.Switch; exports.Tab = _chunkWXSKMMCVjs.Tab; exports.Tabs = _chunkWXSKMMCVjs.Tabs; exports.TextInput = _chunkIW3JCC73js.TextInput; exports.Timeline = _chunkDV5WTSFWjs.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-YIXRQHTA.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TextInput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NKNDCRUR.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Timeline
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-POUQGJN4.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-EH73E5FP.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Group,
|
|
19
19
|
GroupHeader
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3Y3HRYLC.mjs";
|
|
21
21
|
import {
|
|
22
22
|
Label
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-7ITSSJE2.mjs";
|
|
24
24
|
import {
|
|
25
25
|
Rect
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SMTUN6HG.mjs";
|
|
27
27
|
import {
|
|
28
28
|
SliderButton
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-H2UQDFTS.mjs";
|
|
30
30
|
import {
|
|
31
31
|
Switch
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-YYM7PBRN.mjs";
|
|
33
|
+
import "./chunk-EDTJ75FT.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.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"tsup": "^8.1.0",
|
|
107
107
|
"typescript": "^5.3.3",
|
|
108
108
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
109
|
-
"@arcanejs/toolkit-frontend": "^0.0
|
|
109
|
+
"@arcanejs/toolkit-frontend": "^0.1.0",
|
|
110
110
|
"@arcanejs/typescript-config": "^0.0.0"
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"lodash": "^4.17.21",
|
|
115
115
|
"material-symbols": "^0.25.0",
|
|
116
116
|
"ws": "^8.18.0",
|
|
117
|
-
"@arcanejs/
|
|
118
|
-
"@arcanejs/
|
|
117
|
+
"@arcanejs/diff": "^0.4.0",
|
|
118
|
+
"@arcanejs/protocol": "^0.2.0"
|
|
119
119
|
},
|
|
120
120
|
"files": [
|
|
121
121
|
"dist"
|