@arcanejs/toolkit 1.0.1 → 1.1.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/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10 -10
- package/dist/index.mjs +10 -10
- package/package.json +7 -5
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,7 @@ declare class Server {
|
|
|
31
31
|
private readonly log?;
|
|
32
32
|
private readonly staticFiles;
|
|
33
33
|
private readonly entrypointFilename;
|
|
34
|
+
private title;
|
|
34
35
|
constructor(options: LightDeskOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
35
36
|
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
36
37
|
private sendStaticFile;
|
|
@@ -38,6 +39,10 @@ declare class Server {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
interface LightDeskOptions {
|
|
42
|
+
/**
|
|
43
|
+
* What window title should the toolkit be initialized with?
|
|
44
|
+
*/
|
|
45
|
+
title?: string;
|
|
41
46
|
/**
|
|
42
47
|
* What path should be used to serve the light desk.
|
|
43
48
|
*
|
|
@@ -63,6 +68,13 @@ interface LightDeskOptions {
|
|
|
63
68
|
* that matches this name.
|
|
64
69
|
*/
|
|
65
70
|
entrypointJsFile?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If it's not possible to automatically resolve and import the
|
|
73
|
+
* material-symbols package in node_modules
|
|
74
|
+
* (for example when bundling an electron app),
|
|
75
|
+
* you can provide the path to the material-symbols-outlined.woff2 file here.
|
|
76
|
+
*/
|
|
77
|
+
materialIconsFontFile?: string;
|
|
66
78
|
}
|
|
67
79
|
type InitializationOptions =
|
|
68
80
|
/** automatically start a simple */
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ declare class Server {
|
|
|
31
31
|
private readonly log?;
|
|
32
32
|
private readonly staticFiles;
|
|
33
33
|
private readonly entrypointFilename;
|
|
34
|
+
private title;
|
|
34
35
|
constructor(options: LightDeskOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
35
36
|
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
36
37
|
private sendStaticFile;
|
|
@@ -38,6 +39,10 @@ declare class Server {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
interface LightDeskOptions {
|
|
42
|
+
/**
|
|
43
|
+
* What window title should the toolkit be initialized with?
|
|
44
|
+
*/
|
|
45
|
+
title?: string;
|
|
41
46
|
/**
|
|
42
47
|
* What path should be used to serve the light desk.
|
|
43
48
|
*
|
|
@@ -63,6 +68,13 @@ interface LightDeskOptions {
|
|
|
63
68
|
* that matches this name.
|
|
64
69
|
*/
|
|
65
70
|
entrypointJsFile?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If it's not possible to automatically resolve and import the
|
|
73
|
+
* material-symbols package in node_modules
|
|
74
|
+
* (for example when bundling an electron app),
|
|
75
|
+
* you can provide the path to the material-symbols-outlined.woff2 file here.
|
|
76
|
+
*/
|
|
77
|
+
materialIconsFontFile?: string;
|
|
66
78
|
}
|
|
67
79
|
type InitializationOptions =
|
|
68
80
|
/** automatically start a simple */
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ var DEFAULT_LIGHT_DESK_OPTIONS = {
|
|
|
47
47
|
// src/backend/server.ts
|
|
48
48
|
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
49
49
|
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
50
|
+
var _escapehtml = require('escape-html'); var _escapehtml2 = _interopRequireDefault(_escapehtml);
|
|
50
51
|
|
|
51
52
|
// src/shared/static.ts
|
|
52
53
|
var FONTS = {
|
|
@@ -55,7 +56,7 @@ var FONTS = {
|
|
|
55
56
|
|
|
56
57
|
// src/backend/server.ts
|
|
57
58
|
var parentDir = path.basename(__dirname);
|
|
58
|
-
var
|
|
59
|
+
var distDir = () => {
|
|
59
60
|
switch (parentDir) {
|
|
60
61
|
case "backend":
|
|
61
62
|
return path.resolve(__dirname, "../../dist");
|
|
@@ -64,12 +65,6 @@ var DIST_DIR = (() => {
|
|
|
64
65
|
default:
|
|
65
66
|
throw new Error(`Server running from unknown location: ${__dirname}`);
|
|
66
67
|
}
|
|
67
|
-
})();
|
|
68
|
-
var STATIC_FILES = {
|
|
69
|
-
[`/${FONTS.materialSymbolsOutlined}`]: {
|
|
70
|
-
path: _chunk3RG5ZIWIjs.__require.resolve("material-symbols/material-symbols-outlined.woff2"),
|
|
71
|
-
contentType: "font/woff2"
|
|
72
|
-
}
|
|
73
68
|
};
|
|
74
69
|
var Server = (_class = class {
|
|
75
70
|
constructor(options, onNewConnection, onClosedConnection, onMessage, log) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
@@ -78,14 +73,18 @@ var Server = (_class = class {
|
|
|
78
73
|
this.onClosedConnection = onClosedConnection;
|
|
79
74
|
this.onMessage = onMessage;
|
|
80
75
|
this.log = log;
|
|
81
|
-
const entrypoint = _nullishCoalesce(this.options.entrypointJsFile, () => ( path.join(
|
|
76
|
+
const entrypoint = _nullishCoalesce(this.options.entrypointJsFile, () => ( path.join(distDir(), "frontend", "entrypoint.js")));
|
|
82
77
|
if (!entrypoint.endsWith(".js")) {
|
|
83
78
|
throw new Error("Entrypoint file must be a .js file");
|
|
84
79
|
}
|
|
85
80
|
const entrypointMap = entrypoint + ".map";
|
|
86
81
|
this.entrypointFilename = path.basename(entrypoint);
|
|
82
|
+
this.title = _escapehtml2.default.call(void 0, _nullishCoalesce(options.title, () => ( "@arcanejs")));
|
|
87
83
|
this.staticFiles = {
|
|
88
|
-
|
|
84
|
+
[`/${FONTS.materialSymbolsOutlined}`]: {
|
|
85
|
+
path: _nullishCoalesce(this.options.materialIconsFontFile, () => ( _chunk3RG5ZIWIjs.__require.resolve("material-symbols/material-symbols-outlined.woff2"))),
|
|
86
|
+
contentType: "font/woff2"
|
|
87
|
+
},
|
|
89
88
|
[`/${this.entrypointFilename}`]: {
|
|
90
89
|
path: entrypoint,
|
|
91
90
|
contentType: "text/javascript"
|
|
@@ -99,13 +98,14 @@ var Server = (_class = class {
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
|
|
101
|
+
|
|
102
102
|
__init() {this.handleHttpRequest = async (req, res) => {
|
|
103
103
|
_optionalChain([this, 'access', _16 => _16.log, 'optionalAccess', _17 => _17.debug, 'call', _18 => _18("handleHttpRequest %s", req.url)]);
|
|
104
104
|
if (req.url === this.options.path) {
|
|
105
105
|
const content = `
|
|
106
106
|
<html>
|
|
107
107
|
<head>
|
|
108
|
-
<title
|
|
108
|
+
<title>${this.title}</title>
|
|
109
109
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
110
110
|
<style type="text/css">
|
|
111
111
|
@font-face {
|
package/dist/index.mjs
CHANGED
|
@@ -47,6 +47,7 @@ var DEFAULT_LIGHT_DESK_OPTIONS = {
|
|
|
47
47
|
// src/backend/server.ts
|
|
48
48
|
import * as fs from "fs";
|
|
49
49
|
import * as path from "path";
|
|
50
|
+
import escapeHTML from "escape-html";
|
|
50
51
|
|
|
51
52
|
// src/shared/static.ts
|
|
52
53
|
var FONTS = {
|
|
@@ -55,7 +56,7 @@ var FONTS = {
|
|
|
55
56
|
|
|
56
57
|
// src/backend/server.ts
|
|
57
58
|
var parentDir = path.basename(__dirname);
|
|
58
|
-
var
|
|
59
|
+
var distDir = () => {
|
|
59
60
|
switch (parentDir) {
|
|
60
61
|
case "backend":
|
|
61
62
|
return path.resolve(__dirname, "../../dist");
|
|
@@ -64,12 +65,6 @@ var DIST_DIR = (() => {
|
|
|
64
65
|
default:
|
|
65
66
|
throw new Error(`Server running from unknown location: ${__dirname}`);
|
|
66
67
|
}
|
|
67
|
-
})();
|
|
68
|
-
var STATIC_FILES = {
|
|
69
|
-
[`/${FONTS.materialSymbolsOutlined}`]: {
|
|
70
|
-
path: __require.resolve("material-symbols/material-symbols-outlined.woff2"),
|
|
71
|
-
contentType: "font/woff2"
|
|
72
|
-
}
|
|
73
68
|
};
|
|
74
69
|
var Server = class {
|
|
75
70
|
constructor(options, onNewConnection, onClosedConnection, onMessage, log) {
|
|
@@ -78,14 +73,18 @@ var Server = class {
|
|
|
78
73
|
this.onClosedConnection = onClosedConnection;
|
|
79
74
|
this.onMessage = onMessage;
|
|
80
75
|
this.log = log;
|
|
81
|
-
const entrypoint = this.options.entrypointJsFile ?? path.join(
|
|
76
|
+
const entrypoint = this.options.entrypointJsFile ?? path.join(distDir(), "frontend", "entrypoint.js");
|
|
82
77
|
if (!entrypoint.endsWith(".js")) {
|
|
83
78
|
throw new Error("Entrypoint file must be a .js file");
|
|
84
79
|
}
|
|
85
80
|
const entrypointMap = entrypoint + ".map";
|
|
86
81
|
this.entrypointFilename = path.basename(entrypoint);
|
|
82
|
+
this.title = escapeHTML(options.title ?? "@arcanejs");
|
|
87
83
|
this.staticFiles = {
|
|
88
|
-
|
|
84
|
+
[`/${FONTS.materialSymbolsOutlined}`]: {
|
|
85
|
+
path: this.options.materialIconsFontFile ?? __require.resolve("material-symbols/material-symbols-outlined.woff2"),
|
|
86
|
+
contentType: "font/woff2"
|
|
87
|
+
},
|
|
89
88
|
[`/${this.entrypointFilename}`]: {
|
|
90
89
|
path: entrypoint,
|
|
91
90
|
contentType: "text/javascript"
|
|
@@ -99,13 +98,14 @@ var Server = class {
|
|
|
99
98
|
}
|
|
100
99
|
staticFiles;
|
|
101
100
|
entrypointFilename;
|
|
101
|
+
title;
|
|
102
102
|
handleHttpRequest = async (req, res) => {
|
|
103
103
|
this.log?.debug("handleHttpRequest %s", req.url);
|
|
104
104
|
if (req.url === this.options.path) {
|
|
105
105
|
const content = `
|
|
106
106
|
<html>
|
|
107
107
|
<head>
|
|
108
|
-
<title
|
|
108
|
+
<title>${this.title}</title>
|
|
109
109
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
110
110
|
<style type="text/css">
|
|
111
111
|
@font-face {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/toolkit",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"./package.json": "./package.json"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
+
"@types/escape-html": "^1.0.4",
|
|
101
102
|
"@types/eslint": "^8.56.5",
|
|
102
103
|
"@types/express": "^5.0.0",
|
|
103
104
|
"@types/lodash": "^4.17.10",
|
|
@@ -114,22 +115,23 @@
|
|
|
114
115
|
"tsup": "^8.1.0",
|
|
115
116
|
"typescript": "^5.3.3",
|
|
116
117
|
"@arcanejs/eslint-config": "^0.0.0",
|
|
117
|
-
"@arcanejs/
|
|
118
|
-
"@arcanejs/
|
|
118
|
+
"@arcanejs/typescript-config": "^0.0.0",
|
|
119
|
+
"@arcanejs/toolkit-frontend": "^0.3.1"
|
|
119
120
|
},
|
|
120
121
|
"dependencies": {
|
|
122
|
+
"escape-html": "^1.0.3",
|
|
121
123
|
"express": "^4.21.1",
|
|
122
124
|
"lodash": "^4.17.21",
|
|
123
125
|
"material-symbols": "^0.25.0",
|
|
124
126
|
"ws": "^8.18.0",
|
|
125
127
|
"@arcanejs/diff": "^0.5.1",
|
|
126
|
-
"@arcanejs/protocol": "^0.4.
|
|
128
|
+
"@arcanejs/protocol": "^0.4.1"
|
|
127
129
|
},
|
|
128
130
|
"peerDependencies": {
|
|
129
131
|
"react": "^18",
|
|
130
132
|
"react-dom": "18.3.1",
|
|
131
133
|
"styled-components": "^6.1.13",
|
|
132
|
-
"@arcanejs/toolkit-frontend": "^0.3.
|
|
134
|
+
"@arcanejs/toolkit-frontend": "^0.3.1"
|
|
133
135
|
},
|
|
134
136
|
"peerDependenciesMeta": {
|
|
135
137
|
"@arcanejs/toolkit-frontend": {
|