@arcanejs/toolkit 1.0.0 → 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.
@@ -18,25 +18,6 @@ var _styledcomponents = require('styled-components');
18
18
 
19
19
  var _styling = require('@arcanejs/toolkit-frontend/styling');
20
20
  var _toolkitfrontend = require('@arcanejs/toolkit-frontend');
21
-
22
- // src/frontend/styling.ts
23
-
24
-
25
- // src/shared/static.ts
26
- var FONTS = {
27
- materialSymbolsOutlined: "material-symbols-outlined.woff2"
28
- };
29
-
30
- // src/frontend/styling.ts
31
- var MaterialFontStyle = _styledcomponents.createGlobalStyle`
32
- @font-face {
33
- font-family: 'Material Symbols Outlined';
34
- font-style: normal;
35
- src: url(${FONTS.materialSymbolsOutlined}) format('woff');
36
- }
37
- `;
38
-
39
- // src/frontend/stage.tsx
40
21
  var _jsxruntime = require('react/jsx-runtime');
41
22
  var Stage = ({ className, renderers }) => {
42
23
  const [root, setRoot] = _react.useState.call(void 0,
@@ -123,7 +104,6 @@ function rootComponent(props) {
123
104
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
124
105
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _styling.BaseStyle, {}),
125
106
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _styling.GlobalStyle, {}),
126
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MaterialFontStyle, {}),
127
107
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _styledcomponents.ThemeProvider, { theme: _styling.THEME, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledStage, { ...props }) })
128
108
  ] });
129
109
  }
@@ -18,25 +18,6 @@ import {
18
18
  THEME
19
19
  } from "@arcanejs/toolkit-frontend/styling";
20
20
  import { GroupStateWrapper, StageContext } from "@arcanejs/toolkit-frontend";
21
-
22
- // src/frontend/styling.ts
23
- import { createGlobalStyle } from "styled-components";
24
-
25
- // src/shared/static.ts
26
- var FONTS = {
27
- materialSymbolsOutlined: "material-symbols-outlined.woff2"
28
- };
29
-
30
- // src/frontend/styling.ts
31
- var MaterialFontStyle = createGlobalStyle`
32
- @font-face {
33
- font-family: 'Material Symbols Outlined';
34
- font-style: normal;
35
- src: url(${FONTS.materialSymbolsOutlined}) format('woff');
36
- }
37
- `;
38
-
39
- // src/frontend/stage.tsx
40
21
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
41
22
  var Stage = ({ className, renderers }) => {
42
23
  const [root, setRoot] = useState(
@@ -123,7 +104,6 @@ function rootComponent(props) {
123
104
  return /* @__PURE__ */ jsxs(Fragment, { children: [
124
105
  /* @__PURE__ */ jsx(BaseStyle, {}),
125
106
  /* @__PURE__ */ jsx(GlobalStyle, {}),
126
- /* @__PURE__ */ jsx(MaterialFontStyle, {}),
127
107
  /* @__PURE__ */ jsx(ThemeProvider, { theme: THEME, children: /* @__PURE__ */ jsx(StyledStage, { ...props }) })
128
108
  ] });
129
109
  }
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 DIST_DIR = (() => {
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(DIST_DIR, "frontend", "entrypoint.js")));
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
- ...STATIC_FILES,
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,14 +98,22 @@ 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>Light Desk</title>
108
+ <title>${this.title}</title>
109
109
  <meta name="viewport" content="width=device-width, initial-scale=1">
110
+ <style type="text/css">
111
+ @font-face {
112
+ font-family: 'Material Symbols Outlined';
113
+ font-style: normal;
114
+ src: url(${FONTS.materialSymbolsOutlined}) format('woff');
115
+ }
116
+ </style>
110
117
  </head>
111
118
  <body>
112
119
  <div id="root"></div>
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 DIST_DIR = (() => {
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(DIST_DIR, "frontend", "entrypoint.js");
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
- ...STATIC_FILES,
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,14 +98,22 @@ 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>Light Desk</title>
108
+ <title>${this.title}</title>
109
109
  <meta name="viewport" content="width=device-width, initial-scale=1">
110
+ <style type="text/css">
111
+ @font-face {
112
+ font-family: 'Material Symbols Outlined';
113
+ font-style: normal;
114
+ src: url(${FONTS.materialSymbolsOutlined}) format('woff');
115
+ }
116
+ </style>
110
117
  </head>
111
118
  <body>
112
119
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcanejs/toolkit",
3
- "version": "1.0.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/toolkit-frontend": "^0.3.0",
118
- "@arcanejs/typescript-config": "^0.0.0"
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.0"
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.0"
134
+ "@arcanejs/toolkit-frontend": "^0.3.1"
133
135
  },
134
136
  "peerDependenciesMeta": {
135
137
  "@arcanejs/toolkit-frontend": {