@arcanejs/toolkit 1.1.1 → 3.0.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 +10 -79
- package/dist/backend/components/base.d.ts +10 -79
- package/dist/backend/components/base.js +2 -2
- package/dist/backend/components/base.mjs +1 -1
- package/dist/backend/components/button.d.mts +9 -33
- package/dist/backend/components/button.d.ts +9 -33
- package/dist/backend/components/button.js +3 -3
- package/dist/backend/components/button.mjs +2 -2
- package/dist/backend/components/group.d.mts +9 -54
- package/dist/backend/components/group.d.ts +9 -54
- package/dist/backend/components/group.js +3 -3
- package/dist/backend/components/group.mjs +2 -2
- package/dist/backend/components/label.d.mts +6 -2
- package/dist/backend/components/label.d.ts +6 -2
- package/dist/backend/components/label.js +3 -3
- package/dist/backend/components/label.mjs +2 -2
- package/dist/backend/components/rect.d.mts +7 -2
- package/dist/backend/components/rect.d.ts +7 -2
- package/dist/backend/components/rect.js +3 -3
- package/dist/backend/components/rect.mjs +2 -2
- package/dist/backend/components/slider-button.d.mts +8 -3
- package/dist/backend/components/slider-button.d.ts +8 -3
- 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 +8 -3
- package/dist/backend/components/switch.d.ts +8 -3
- package/dist/backend/components/switch.js +3 -3
- package/dist/backend/components/switch.mjs +2 -2
- package/dist/backend/components/tabs.d.mts +7 -2
- package/dist/backend/components/tabs.d.ts +7 -2
- package/dist/backend/components/tabs.js +3 -3
- package/dist/backend/components/tabs.mjs +2 -2
- package/dist/backend/components/text-input.d.mts +8 -3
- package/dist/backend/components/text-input.d.ts +8 -3
- 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 +7 -2
- package/dist/backend/components/timeline.d.ts +7 -2
- package/dist/backend/components/timeline.js +3 -3
- package/dist/backend/components/timeline.mjs +2 -2
- package/dist/{chunk-HNFNG5MD.js → chunk-4OZ22IQU.js} +5 -5
- package/dist/{chunk-5TGGF5UJ.mjs → chunk-5D7OSUZ6.mjs} +3 -3
- package/dist/{chunk-T4TMVBFM.js → chunk-6CWEURJP.js} +2 -2
- package/dist/{chunk-5JPYL5IU.js → chunk-7OX2FB6C.js} +2 -2
- package/dist/{chunk-PXYXUWXE.mjs → chunk-7TTY7CBH.mjs} +1 -1
- package/dist/{chunk-SIXWXDZW.js → chunk-CME7HZZK.js} +5 -5
- package/dist/{chunk-OAPIVG6M.mjs → chunk-CUZSHFDP.mjs} +1 -1
- package/dist/{chunk-ZLJECS4H.js → chunk-DG75CS7F.js} +5 -5
- package/dist/{chunk-V5T44HCM.js → chunk-DRQVYGTI.js} +2 -2
- package/dist/{chunk-ARRRZPUK.js → chunk-GMDJYFHD.js} +3 -3
- package/dist/{chunk-IBIEYR3L.mjs → chunk-JFZXSCGK.mjs} +3 -3
- package/dist/{chunk-LX5IL6WX.mjs → chunk-K37TZB75.mjs} +1 -1
- package/dist/{chunk-BDBRQJSI.mjs → chunk-N6IHYBZH.mjs} +1 -1
- package/dist/{chunk-SBHNIFAS.mjs → chunk-NEQRLPXK.mjs} +3 -3
- package/dist/{chunk-TOPIQUBZ.js → chunk-O5ZW6JYG.js} +6 -6
- package/dist/{chunk-7SZA6JUN.mjs → chunk-RYR5I5FT.mjs} +6 -6
- package/dist/{chunk-ADH7RZG5.js → chunk-SGACFY53.js} +6 -6
- package/dist/{chunk-25LALCAN.js → chunk-VEZGD2PG.js} +5 -5
- package/dist/{chunk-EFNFSHV3.mjs → chunk-W42AOMM6.mjs} +3 -3
- package/dist/{chunk-ISHGZXPO.mjs → chunk-YBBUC3QC.mjs} +3 -3
- package/dist/frontend/entrypoint.js +492 -221
- package/dist/frontend/entrypoint.js.map +4 -4
- package/dist/frontend/index.js +242 -6
- package/dist/frontend/index.mjs +255 -19
- package/dist/index.d.mts +7 -111
- package/dist/index.d.ts +7 -111
- package/dist/index.js +65 -26
- package/dist/index.mjs +54 -15
- package/dist/toolkit-2w2SWHlT.d.ts +269 -0
- package/dist/toolkit-DB8G2TaA.d.mts +269 -0
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Logger } from '@arcanejs/protocol/logging';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
import * as http from 'http';
|
|
5
|
-
import { Application } from 'express';
|
|
6
|
-
import { WebSocket } from 'ws';
|
|
7
|
-
import { ClientMessage, ServerMessage } from '@arcanejs/protocol';
|
|
8
|
-
import { Group } from './backend/components/group.mjs';
|
|
9
|
-
export { GroupHeader } from './backend/components/group.mjs';
|
|
10
|
-
import { Parent, AnyComponent } from './backend/components/base.mjs';
|
|
11
|
-
export { Button } from './backend/components/button.mjs';
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-DB8G2TaA.mjs';
|
|
12
2
|
export { Label } from './backend/components/label.mjs';
|
|
13
3
|
export { Rect } from './backend/components/rect.mjs';
|
|
14
4
|
export { SliderButton } from './backend/components/slider-button.mjs';
|
|
@@ -16,106 +6,12 @@ export { Switch } from './backend/components/switch.mjs';
|
|
|
16
6
|
export { Tab, Tabs } from './backend/components/tabs.mjs';
|
|
17
7
|
export { TextInput } from './backend/components/text-input.mjs';
|
|
18
8
|
export { Timeline } from './backend/components/timeline.mjs';
|
|
9
|
+
import '@arcanejs/protocol/logging';
|
|
10
|
+
import 'lodash';
|
|
11
|
+
import 'http';
|
|
12
|
+
import 'express';
|
|
13
|
+
import 'ws';
|
|
14
|
+
import '@arcanejs/protocol';
|
|
19
15
|
import '@arcanejs/protocol/core';
|
|
20
16
|
import '@arcanejs/protocol/styles';
|
|
21
17
|
import './id-map-DxQ3_gyA.mjs';
|
|
22
|
-
|
|
23
|
-
interface Connection {
|
|
24
|
-
sendMessage(msg: ServerMessage): void;
|
|
25
|
-
}
|
|
26
|
-
declare class Server {
|
|
27
|
-
private readonly options;
|
|
28
|
-
private readonly onNewConnection;
|
|
29
|
-
private readonly onClosedConnection;
|
|
30
|
-
private readonly onMessage;
|
|
31
|
-
private readonly log?;
|
|
32
|
-
private readonly staticFiles;
|
|
33
|
-
private readonly entrypointFilename;
|
|
34
|
-
private title;
|
|
35
|
-
constructor(options: ToolkitOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
36
|
-
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
37
|
-
private sendStaticFile;
|
|
38
|
-
handleWsConnection: <S extends WebSocket>(ws: S) => void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ToolkitOptions {
|
|
42
|
-
/**
|
|
43
|
-
* What window title should the toolkit be initialized with?
|
|
44
|
-
*/
|
|
45
|
-
title?: string;
|
|
46
|
-
/**
|
|
47
|
-
* What path should be used to serve the light desk.
|
|
48
|
-
*
|
|
49
|
-
* This is important if a express server will be used that serves other paths.
|
|
50
|
-
*/
|
|
51
|
-
path: string;
|
|
52
|
-
/**
|
|
53
|
-
* An optional object that can be used to output log events,
|
|
54
|
-
* we recommend using `pino` for this,
|
|
55
|
-
* as log levels etc... can be controlled.
|
|
56
|
-
*
|
|
57
|
-
* You can also always use `console` for logging,
|
|
58
|
-
* but this will be quite verbose.
|
|
59
|
-
*/
|
|
60
|
-
log?: Logger;
|
|
61
|
-
/**
|
|
62
|
-
* The entrypoint file that should be used to serve the light desk.
|
|
63
|
-
*
|
|
64
|
-
* This is only needed if you have defined custom extensions,
|
|
65
|
-
* and need to load custom frontend code that includes your extensions.
|
|
66
|
-
*
|
|
67
|
-
* This will allow access to both the js file and the `.map.js` file,
|
|
68
|
-
* that matches this name.
|
|
69
|
-
*/
|
|
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;
|
|
78
|
-
}
|
|
79
|
-
type InitializationOptions =
|
|
80
|
-
/** automatically start a simple */
|
|
81
|
-
{
|
|
82
|
-
mode: 'automatic';
|
|
83
|
-
port: number;
|
|
84
|
-
/**
|
|
85
|
-
* Optional callback that is called when the server is ready,
|
|
86
|
-
* with the url that the server is running on.
|
|
87
|
-
*/
|
|
88
|
-
onReady?: (url: string) => void;
|
|
89
|
-
}
|
|
90
|
-
/** Create a websocket server that attaches to an existing express and http server */
|
|
91
|
-
| {
|
|
92
|
-
mode: 'express';
|
|
93
|
-
express: Application;
|
|
94
|
-
server: http.Server;
|
|
95
|
-
}
|
|
96
|
-
/** Create a websocket server that attaches to an existing express and http server */
|
|
97
|
-
| {
|
|
98
|
-
mode: 'manual';
|
|
99
|
-
setup: (server: Server) => void;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
declare class Toolkit implements Parent {
|
|
103
|
-
private readonly options;
|
|
104
|
-
/**
|
|
105
|
-
* Mapping from components to unique IDs that identify them
|
|
106
|
-
*/
|
|
107
|
-
private readonly componentIDMap;
|
|
108
|
-
private readonly connections;
|
|
109
|
-
private rootGroup;
|
|
110
|
-
constructor(options?: Partial<ToolkitOptions>);
|
|
111
|
-
start: (opts: InitializationOptions) => void;
|
|
112
|
-
setRoot: (group: Group) => void;
|
|
113
|
-
log(): _arcanejs_protocol_logging.Logger | null;
|
|
114
|
-
updateTree: _.DebouncedFuncLeading<() => void>;
|
|
115
|
-
removeChild: (component: AnyComponent) => void;
|
|
116
|
-
private onNewConnection;
|
|
117
|
-
private onClosedConnection;
|
|
118
|
-
private onMessage;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { AnyComponent, Group, Toolkit, type ToolkitOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Logger } from '@arcanejs/protocol/logging';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
import * as http from 'http';
|
|
5
|
-
import { Application } from 'express';
|
|
6
|
-
import { WebSocket } from 'ws';
|
|
7
|
-
import { ClientMessage, ServerMessage } from '@arcanejs/protocol';
|
|
8
|
-
import { Group } from './backend/components/group.js';
|
|
9
|
-
export { GroupHeader } from './backend/components/group.js';
|
|
10
|
-
import { Parent, AnyComponent } from './backend/components/base.js';
|
|
11
|
-
export { Button } from './backend/components/button.js';
|
|
1
|
+
export { A as AnyComponent, B as Button, G as Group, c as GroupHeader, T as Toolkit, a as ToolkitConnection, b as ToolkitOptions } from './toolkit-2w2SWHlT.js';
|
|
12
2
|
export { Label } from './backend/components/label.js';
|
|
13
3
|
export { Rect } from './backend/components/rect.js';
|
|
14
4
|
export { SliderButton } from './backend/components/slider-button.js';
|
|
@@ -16,106 +6,12 @@ export { Switch } from './backend/components/switch.js';
|
|
|
16
6
|
export { Tab, Tabs } from './backend/components/tabs.js';
|
|
17
7
|
export { TextInput } from './backend/components/text-input.js';
|
|
18
8
|
export { Timeline } from './backend/components/timeline.js';
|
|
9
|
+
import '@arcanejs/protocol/logging';
|
|
10
|
+
import 'lodash';
|
|
11
|
+
import 'http';
|
|
12
|
+
import 'express';
|
|
13
|
+
import 'ws';
|
|
14
|
+
import '@arcanejs/protocol';
|
|
19
15
|
import '@arcanejs/protocol/core';
|
|
20
16
|
import '@arcanejs/protocol/styles';
|
|
21
17
|
import './id-map-DxQ3_gyA.js';
|
|
22
|
-
|
|
23
|
-
interface Connection {
|
|
24
|
-
sendMessage(msg: ServerMessage): void;
|
|
25
|
-
}
|
|
26
|
-
declare class Server {
|
|
27
|
-
private readonly options;
|
|
28
|
-
private readonly onNewConnection;
|
|
29
|
-
private readonly onClosedConnection;
|
|
30
|
-
private readonly onMessage;
|
|
31
|
-
private readonly log?;
|
|
32
|
-
private readonly staticFiles;
|
|
33
|
-
private readonly entrypointFilename;
|
|
34
|
-
private title;
|
|
35
|
-
constructor(options: ToolkitOptions, onNewConnection: (connection: Connection) => void, onClosedConnection: (connection: Connection) => void, onMessage: (connection: Connection, message: ClientMessage) => void, log?: Logger | undefined);
|
|
36
|
-
handleHttpRequest: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
37
|
-
private sendStaticFile;
|
|
38
|
-
handleWsConnection: <S extends WebSocket>(ws: S) => void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ToolkitOptions {
|
|
42
|
-
/**
|
|
43
|
-
* What window title should the toolkit be initialized with?
|
|
44
|
-
*/
|
|
45
|
-
title?: string;
|
|
46
|
-
/**
|
|
47
|
-
* What path should be used to serve the light desk.
|
|
48
|
-
*
|
|
49
|
-
* This is important if a express server will be used that serves other paths.
|
|
50
|
-
*/
|
|
51
|
-
path: string;
|
|
52
|
-
/**
|
|
53
|
-
* An optional object that can be used to output log events,
|
|
54
|
-
* we recommend using `pino` for this,
|
|
55
|
-
* as log levels etc... can be controlled.
|
|
56
|
-
*
|
|
57
|
-
* You can also always use `console` for logging,
|
|
58
|
-
* but this will be quite verbose.
|
|
59
|
-
*/
|
|
60
|
-
log?: Logger;
|
|
61
|
-
/**
|
|
62
|
-
* The entrypoint file that should be used to serve the light desk.
|
|
63
|
-
*
|
|
64
|
-
* This is only needed if you have defined custom extensions,
|
|
65
|
-
* and need to load custom frontend code that includes your extensions.
|
|
66
|
-
*
|
|
67
|
-
* This will allow access to both the js file and the `.map.js` file,
|
|
68
|
-
* that matches this name.
|
|
69
|
-
*/
|
|
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;
|
|
78
|
-
}
|
|
79
|
-
type InitializationOptions =
|
|
80
|
-
/** automatically start a simple */
|
|
81
|
-
{
|
|
82
|
-
mode: 'automatic';
|
|
83
|
-
port: number;
|
|
84
|
-
/**
|
|
85
|
-
* Optional callback that is called when the server is ready,
|
|
86
|
-
* with the url that the server is running on.
|
|
87
|
-
*/
|
|
88
|
-
onReady?: (url: string) => void;
|
|
89
|
-
}
|
|
90
|
-
/** Create a websocket server that attaches to an existing express and http server */
|
|
91
|
-
| {
|
|
92
|
-
mode: 'express';
|
|
93
|
-
express: Application;
|
|
94
|
-
server: http.Server;
|
|
95
|
-
}
|
|
96
|
-
/** Create a websocket server that attaches to an existing express and http server */
|
|
97
|
-
| {
|
|
98
|
-
mode: 'manual';
|
|
99
|
-
setup: (server: Server) => void;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
declare class Toolkit implements Parent {
|
|
103
|
-
private readonly options;
|
|
104
|
-
/**
|
|
105
|
-
* Mapping from components to unique IDs that identify them
|
|
106
|
-
*/
|
|
107
|
-
private readonly componentIDMap;
|
|
108
|
-
private readonly connections;
|
|
109
|
-
private rootGroup;
|
|
110
|
-
constructor(options?: Partial<ToolkitOptions>);
|
|
111
|
-
start: (opts: InitializationOptions) => void;
|
|
112
|
-
setRoot: (group: Group) => void;
|
|
113
|
-
log(): _arcanejs_protocol_logging.Logger | null;
|
|
114
|
-
updateTree: _.DebouncedFuncLeading<() => void>;
|
|
115
|
-
removeChild: (component: AnyComponent) => void;
|
|
116
|
-
private onNewConnection;
|
|
117
|
-
private onClosedConnection;
|
|
118
|
-
private onMessage;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { AnyComponent, Group, Toolkit, type ToolkitOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
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 _chunkGMDJYFHDjs = require('./chunk-GMDJYFHD.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk4OZ22IQUjs = require('./chunk-4OZ22IQU.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk6CWEURJPjs = require('./chunk-6CWEURJP.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkEABM5X65js = require('./chunk-EABM5X65.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkDG75CS7Fjs = require('./chunk-DG75CS7F.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkO5ZW6JYGjs = require('./chunk-O5ZW6JYG.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkDRQVYGTIjs = require('./chunk-DRQVYGTI.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunk7OX2FB6Cjs = require('./chunk-7OX2FB6C.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkCME7HZZKjs = require('./chunk-CME7HZZK.js');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
33
|
-
|
|
32
|
+
var _chunkVEZGD2PGjs = require('./chunk-VEZGD2PG.js');
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkSGACFY53js = require('./chunk-SGACFY53.js');
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
@@ -177,6 +179,7 @@ var Server = (_class = class {
|
|
|
177
179
|
// src/backend/toolkit.ts
|
|
178
180
|
var _ws = require('ws');
|
|
179
181
|
var _http = require('http');
|
|
182
|
+
var _uuid = require('uuid');
|
|
180
183
|
var Toolkit = (_class2 = class {
|
|
181
184
|
|
|
182
185
|
/**
|
|
@@ -185,7 +188,9 @@ var Toolkit = (_class2 = class {
|
|
|
185
188
|
__init4() {this.componentIDMap = new (0, _chunkEABM5X65js.IDMap)()}
|
|
186
189
|
__init5() {this.connections = /* @__PURE__ */ new Map()}
|
|
187
190
|
__init6() {this.rootGroup = null}
|
|
188
|
-
|
|
191
|
+
/** @hidden */
|
|
192
|
+
__init7() {this.events = new (0, _chunkSGACFY53js.EventEmitter)()}
|
|
193
|
+
constructor(options = {}) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);
|
|
189
194
|
this.options = {
|
|
190
195
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
191
196
|
...options
|
|
@@ -196,7 +201,9 @@ var Toolkit = (_class2 = class {
|
|
|
196
201
|
);
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
|
-
|
|
204
|
+
__init8() {this.addListener = this.events.addListener}
|
|
205
|
+
__init9() {this.removeListener = this.events.removeListener}
|
|
206
|
+
__init10() {this.start = (opts) => {
|
|
200
207
|
const server = new Server(
|
|
201
208
|
this.options,
|
|
202
209
|
this.onNewConnection,
|
|
@@ -212,8 +219,8 @@ var Toolkit = (_class2 = class {
|
|
|
212
219
|
wss.on("connection", server.handleWsConnection);
|
|
213
220
|
const url = `http://localhost:${opts.port}${this.options.path}`;
|
|
214
221
|
httpServer.listen(opts.port, () => {
|
|
215
|
-
_optionalChain([opts, 'access',
|
|
216
|
-
_optionalChain([this, 'access',
|
|
222
|
+
_optionalChain([opts, 'access', _49 => _49.onReady, 'optionalCall', _50 => _50(url)]);
|
|
223
|
+
_optionalChain([this, 'access', _51 => _51.options, 'access', _52 => _52.log, 'optionalAccess', _53 => _53.info, 'call', _54 => _54(`Light Desk Started: ${url}`)]);
|
|
217
224
|
});
|
|
218
225
|
} else if (opts.mode === "express") {
|
|
219
226
|
const wss = new (0, _ws.WebSocketServer)({
|
|
@@ -227,7 +234,7 @@ var Toolkit = (_class2 = class {
|
|
|
227
234
|
throw new Error(`Unsupported mode`);
|
|
228
235
|
}
|
|
229
236
|
}}
|
|
230
|
-
|
|
237
|
+
__init11() {this.setRoot = (group) => {
|
|
231
238
|
if (this.rootGroup) {
|
|
232
239
|
throw new Error("Can only set root group once");
|
|
233
240
|
}
|
|
@@ -237,7 +244,10 @@ var Toolkit = (_class2 = class {
|
|
|
237
244
|
log() {
|
|
238
245
|
return _nullishCoalesce(this.options.log, () => ( null));
|
|
239
246
|
}
|
|
240
|
-
|
|
247
|
+
__init12() {this.getConnections = () => {
|
|
248
|
+
return [...this.connections.values()].map((c) => c.publicConnection);
|
|
249
|
+
}}
|
|
250
|
+
__init13() {this.updateTree = _lodash2.default.throttle(
|
|
241
251
|
() => {
|
|
242
252
|
setImmediate(() => {
|
|
243
253
|
if (!this.rootGroup) return;
|
|
@@ -254,15 +264,26 @@ var Toolkit = (_class2 = class {
|
|
|
254
264
|
10,
|
|
255
265
|
{ leading: true, trailing: true }
|
|
256
266
|
)}
|
|
257
|
-
|
|
267
|
+
__init14() {this.removeChild = (component) => {
|
|
258
268
|
if (this.rootGroup === component) {
|
|
259
269
|
this.rootGroup = null;
|
|
260
270
|
component.setParent(null);
|
|
261
271
|
}
|
|
262
272
|
}}
|
|
263
|
-
|
|
264
|
-
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access',
|
|
265
|
-
|
|
273
|
+
__init15() {this.onNewConnection = (connection) => {
|
|
274
|
+
const lastTreeSent = _nullishCoalesce(_optionalChain([this, 'access', _55 => _55.rootGroup, 'optionalAccess', _56 => _56.getProtoInfo, 'call', _57 => _57(this.componentIDMap)]), () => ( void 0));
|
|
275
|
+
const uuid = _uuid.v4.call(void 0, );
|
|
276
|
+
const publicConnection = {
|
|
277
|
+
get uuid() {
|
|
278
|
+
return uuid;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
this.connections.set(connection, { publicConnection, lastTreeSent });
|
|
282
|
+
this.events.emit("new-connection", publicConnection);
|
|
283
|
+
connection.sendMessage({
|
|
284
|
+
type: "metadata",
|
|
285
|
+
connectionUuid: uuid
|
|
286
|
+
});
|
|
266
287
|
if (lastTreeSent) {
|
|
267
288
|
connection.sendMessage({
|
|
268
289
|
type: "tree-full",
|
|
@@ -270,16 +291,34 @@ var Toolkit = (_class2 = class {
|
|
|
270
291
|
});
|
|
271
292
|
}
|
|
272
293
|
}}
|
|
273
|
-
|
|
274
|
-
_optionalChain([this, 'access',
|
|
294
|
+
__init16() {this.onClosedConnection = (connection) => {
|
|
295
|
+
_optionalChain([this, 'access', _58 => _58.log, 'call', _59 => _59(), 'optionalAccess', _60 => _60.debug, 'call', _61 => _61("removing connection")]);
|
|
296
|
+
const con = this.connections.get(connection);
|
|
275
297
|
this.connections.delete(connection);
|
|
298
|
+
if (con) {
|
|
299
|
+
this.events.emit("closed-connection", con.publicConnection);
|
|
300
|
+
}
|
|
276
301
|
}}
|
|
277
|
-
|
|
278
|
-
|
|
302
|
+
__init17() {this.onMessage = (connection, message) => {
|
|
303
|
+
const con = this.connections.get(connection);
|
|
304
|
+
if (!con) {
|
|
305
|
+
_optionalChain([this, 'access', _62 => _62.log, 'call', _63 => _63(), 'optionalAccess', _64 => _64.warn, 'call', _65 => _65(`got message from unknown connection`)]);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const { publicConnection } = con;
|
|
309
|
+
_optionalChain([this, 'access', _66 => _66.log, 'call', _67 => _67(), 'optionalAccess', _68 => _68.debug, 'call', _69 => _69(
|
|
310
|
+
"got message: %o from %s",
|
|
311
|
+
message,
|
|
312
|
+
publicConnection.uuid
|
|
313
|
+
)]);
|
|
279
314
|
switch (message.type) {
|
|
280
315
|
case "component-message":
|
|
281
316
|
if (this.rootGroup)
|
|
282
|
-
this.rootGroup.routeMessage(
|
|
317
|
+
this.rootGroup.routeMessage(
|
|
318
|
+
this.componentIDMap,
|
|
319
|
+
message,
|
|
320
|
+
publicConnection
|
|
321
|
+
);
|
|
283
322
|
break;
|
|
284
323
|
}
|
|
285
324
|
}}
|
|
@@ -297,4 +336,4 @@ var Toolkit = (_class2 = class {
|
|
|
297
336
|
|
|
298
337
|
|
|
299
338
|
|
|
300
|
-
exports.Button =
|
|
339
|
+
exports.Button = _chunkDG75CS7Fjs.Button; exports.Group = _chunkO5ZW6JYGjs.Group; exports.GroupHeader = _chunkO5ZW6JYGjs.GroupHeader; exports.Label = _chunkDRQVYGTIjs.Label; exports.Rect = _chunk7OX2FB6Cjs.Rect; exports.SliderButton = _chunkCME7HZZKjs.SliderButton; exports.Switch = _chunkVEZGD2PGjs.Switch; exports.Tab = _chunkGMDJYFHDjs.Tab; exports.Tabs = _chunkGMDJYFHDjs.Tabs; exports.TextInput = _chunk4OZ22IQUjs.TextInput; exports.Timeline = _chunk6CWEURJPjs.Timeline; exports.Toolkit = Toolkit;
|
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tab,
|
|
3
3
|
Tabs
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7TTY7CBH.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TextInput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YBBUC3QC.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Timeline
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-K37TZB75.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-W42AOMM6.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Group,
|
|
19
19
|
GroupHeader
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5D7OSUZ6.mjs";
|
|
21
21
|
import {
|
|
22
22
|
Label
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-CUZSHFDP.mjs";
|
|
24
24
|
import {
|
|
25
25
|
Rect
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-N6IHYBZH.mjs";
|
|
27
27
|
import {
|
|
28
28
|
SliderButton
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JFZXSCGK.mjs";
|
|
30
30
|
import {
|
|
31
31
|
Switch
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import
|
|
32
|
+
} from "./chunk-NEQRLPXK.mjs";
|
|
33
|
+
import {
|
|
34
|
+
EventEmitter
|
|
35
|
+
} from "./chunk-RYR5I5FT.mjs";
|
|
34
36
|
import {
|
|
35
37
|
__require
|
|
36
38
|
} from "./chunk-Y6FXYEAI.mjs";
|
|
@@ -177,6 +179,7 @@ var Server = class {
|
|
|
177
179
|
// src/backend/toolkit.ts
|
|
178
180
|
import { WebSocketServer } from "ws";
|
|
179
181
|
import { createServer } from "http";
|
|
182
|
+
import { v4 as uuidv4 } from "uuid";
|
|
180
183
|
var Toolkit = class {
|
|
181
184
|
options;
|
|
182
185
|
/**
|
|
@@ -185,6 +188,8 @@ var Toolkit = class {
|
|
|
185
188
|
componentIDMap = new IDMap();
|
|
186
189
|
connections = /* @__PURE__ */ new Map();
|
|
187
190
|
rootGroup = null;
|
|
191
|
+
/** @hidden */
|
|
192
|
+
events = new EventEmitter();
|
|
188
193
|
constructor(options = {}) {
|
|
189
194
|
this.options = {
|
|
190
195
|
...DEFAULT_LIGHT_DESK_OPTIONS,
|
|
@@ -196,6 +201,8 @@ var Toolkit = class {
|
|
|
196
201
|
);
|
|
197
202
|
}
|
|
198
203
|
}
|
|
204
|
+
addListener = this.events.addListener;
|
|
205
|
+
removeListener = this.events.removeListener;
|
|
199
206
|
start = (opts) => {
|
|
200
207
|
const server = new Server(
|
|
201
208
|
this.options,
|
|
@@ -237,6 +244,9 @@ var Toolkit = class {
|
|
|
237
244
|
log() {
|
|
238
245
|
return this.options.log ?? null;
|
|
239
246
|
}
|
|
247
|
+
getConnections = () => {
|
|
248
|
+
return [...this.connections.values()].map((c) => c.publicConnection);
|
|
249
|
+
};
|
|
240
250
|
updateTree = _.throttle(
|
|
241
251
|
() => {
|
|
242
252
|
setImmediate(() => {
|
|
@@ -262,7 +272,18 @@ var Toolkit = class {
|
|
|
262
272
|
};
|
|
263
273
|
onNewConnection = (connection) => {
|
|
264
274
|
const lastTreeSent = this.rootGroup?.getProtoInfo(this.componentIDMap) ?? void 0;
|
|
265
|
-
|
|
275
|
+
const uuid = uuidv4();
|
|
276
|
+
const publicConnection = {
|
|
277
|
+
get uuid() {
|
|
278
|
+
return uuid;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
this.connections.set(connection, { publicConnection, lastTreeSent });
|
|
282
|
+
this.events.emit("new-connection", publicConnection);
|
|
283
|
+
connection.sendMessage({
|
|
284
|
+
type: "metadata",
|
|
285
|
+
connectionUuid: uuid
|
|
286
|
+
});
|
|
266
287
|
if (lastTreeSent) {
|
|
267
288
|
connection.sendMessage({
|
|
268
289
|
type: "tree-full",
|
|
@@ -271,15 +292,33 @@ var Toolkit = class {
|
|
|
271
292
|
}
|
|
272
293
|
};
|
|
273
294
|
onClosedConnection = (connection) => {
|
|
274
|
-
this.
|
|
295
|
+
this.log()?.debug("removing connection");
|
|
296
|
+
const con = this.connections.get(connection);
|
|
275
297
|
this.connections.delete(connection);
|
|
298
|
+
if (con) {
|
|
299
|
+
this.events.emit("closed-connection", con.publicConnection);
|
|
300
|
+
}
|
|
276
301
|
};
|
|
277
|
-
onMessage = (
|
|
278
|
-
this.
|
|
302
|
+
onMessage = (connection, message) => {
|
|
303
|
+
const con = this.connections.get(connection);
|
|
304
|
+
if (!con) {
|
|
305
|
+
this.log()?.warn(`got message from unknown connection`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const { publicConnection } = con;
|
|
309
|
+
this.log()?.debug(
|
|
310
|
+
"got message: %o from %s",
|
|
311
|
+
message,
|
|
312
|
+
publicConnection.uuid
|
|
313
|
+
);
|
|
279
314
|
switch (message.type) {
|
|
280
315
|
case "component-message":
|
|
281
316
|
if (this.rootGroup)
|
|
282
|
-
this.rootGroup.routeMessage(
|
|
317
|
+
this.rootGroup.routeMessage(
|
|
318
|
+
this.componentIDMap,
|
|
319
|
+
message,
|
|
320
|
+
publicConnection
|
|
321
|
+
);
|
|
283
322
|
break;
|
|
284
323
|
}
|
|
285
324
|
};
|