@arcanejs/toolkit 0.2.1 → 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 +10 -188
- 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 +5 -165
- 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 +7 -281
- 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 +5 -102
- 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 +5 -102
- 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 +5 -158
- 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 +5 -141
- 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 +7 -206
- 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 +5 -143
- 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 +5 -106
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/backend/util/index.js +5 -41
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-3O4P67DM.mjs → chunk-3Y3HRYLC.mjs} +1 -1
- package/dist/{chunk-HNEUZVCX.mjs → chunk-7ITSSJE2.mjs} +1 -1
- package/dist/chunk-DNCHAOYH.js +42 -0
- package/dist/chunk-DV5WTSFW.js +33 -0
- package/dist/chunk-EABM5X65.js +17 -0
- 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-IW3JCC73.js +44 -0
- package/dist/chunk-J46AJUGE.js +66 -0
- package/dist/{chunk-IXTM35YM.mjs → chunk-NKNDCRUR.mjs} +1 -1
- package/dist/chunk-NZUYU32Z.js +164 -0
- package/dist/{chunk-SOC4TF3J.mjs → chunk-POUQGJN4.mjs} +1 -1
- package/dist/chunk-QUA3NBLD.js +104 -0
- package/dist/{chunk-ZU5H6SVA.mjs → chunk-SMTUN6HG.mjs} +1 -1
- package/dist/chunk-TSC5C5XR.js +29 -0
- package/dist/chunk-WIPEQNWR.js +29 -0
- package/dist/chunk-WXSKMMCV.js +55 -0
- package/dist/{chunk-TQ27Y7F4.mjs → chunk-YIXRQHTA.mjs} +1 -1
- package/dist/chunk-YN3FZMXY.js +59 -0
- 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 +99 -669
- package/dist/index.mjs +28 -24
- package/package.json +5 -5
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,16 +106,16 @@
|
|
|
106
106
|
"tsup": "^8.1.0",
|
|
107
107
|
"typescript": "^5.3.3",
|
|
108
108
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
109
|
-
"@arcanejs/
|
|
110
|
-
"@arcanejs/
|
|
109
|
+
"@arcanejs/toolkit-frontend": "^0.1.0",
|
|
110
|
+
"@arcanejs/typescript-config": "^0.0.0"
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"express": "^4.21.1",
|
|
114
114
|
"lodash": "^4.17.21",
|
|
115
115
|
"material-symbols": "^0.25.0",
|
|
116
116
|
"ws": "^8.18.0",
|
|
117
|
-
"@arcanejs/diff": "^0.
|
|
118
|
-
"@arcanejs/protocol": "^0.
|
|
117
|
+
"@arcanejs/diff": "^0.4.0",
|
|
118
|
+
"@arcanejs/protocol": "^0.2.0"
|
|
119
119
|
},
|
|
120
120
|
"files": [
|
|
121
121
|
"dist"
|