topazcube 0.1.31 → 0.1.35
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/LICENSE.txt +0 -0
- package/README.md +0 -0
- package/dist/Renderer.cjs +20844 -0
- package/dist/Renderer.cjs.map +1 -0
- package/dist/Renderer.js +20827 -0
- package/dist/Renderer.js.map +1 -0
- package/dist/client.cjs +91 -260
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +68 -215
- package/dist/client.js.map +1 -1
- package/dist/server.cjs +165 -432
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +117 -370
- package/dist/server.js.map +1 -1
- package/dist/terminal.cjs +113 -200
- package/dist/terminal.cjs.map +1 -1
- package/dist/terminal.js +50 -51
- package/dist/terminal.js.map +1 -1
- package/dist/utils-CRhi1BDa.cjs +259 -0
- package/dist/utils-CRhi1BDa.cjs.map +1 -0
- package/dist/utils-D7tXt6-2.js +260 -0
- package/dist/utils-D7tXt6-2.js.map +1 -0
- package/package.json +19 -15
- package/src/{client.ts → network/client.js} +170 -403
- package/src/{compress-browser.ts → network/compress-browser.js} +2 -4
- package/src/{compress-node.ts → network/compress-node.js} +8 -14
- package/src/{server.ts → network/server.js} +229 -317
- package/src/{terminal.js → network/terminal.js} +0 -0
- package/src/{topazcube.ts → network/topazcube.js} +2 -2
- package/src/network/utils.js +375 -0
- package/src/renderer/Camera.js +191 -0
- package/src/renderer/DebugUI.js +703 -0
- package/src/renderer/Geometry.js +1049 -0
- package/src/renderer/Material.js +64 -0
- package/src/renderer/Mesh.js +211 -0
- package/src/renderer/Node.js +112 -0
- package/src/renderer/Pipeline.js +645 -0
- package/src/renderer/Renderer.js +1496 -0
- package/src/renderer/Skin.js +792 -0
- package/src/renderer/Texture.js +584 -0
- package/src/renderer/core/AssetManager.js +394 -0
- package/src/renderer/core/CullingSystem.js +308 -0
- package/src/renderer/core/EntityManager.js +541 -0
- package/src/renderer/core/InstanceManager.js +343 -0
- package/src/renderer/core/ParticleEmitter.js +358 -0
- package/src/renderer/core/ParticleSystem.js +564 -0
- package/src/renderer/core/SpriteSystem.js +349 -0
- package/src/renderer/gltf.js +563 -0
- package/src/renderer/math.js +161 -0
- package/src/renderer/rendering/HistoryBufferManager.js +333 -0
- package/src/renderer/rendering/ProbeCapture.js +1495 -0
- package/src/renderer/rendering/ReflectionProbeManager.js +352 -0
- package/src/renderer/rendering/RenderGraph.js +2258 -0
- package/src/renderer/rendering/passes/AOPass.js +308 -0
- package/src/renderer/rendering/passes/AmbientCapturePass.js +593 -0
- package/src/renderer/rendering/passes/BasePass.js +101 -0
- package/src/renderer/rendering/passes/BloomPass.js +420 -0
- package/src/renderer/rendering/passes/CRTPass.js +724 -0
- package/src/renderer/rendering/passes/FogPass.js +445 -0
- package/src/renderer/rendering/passes/GBufferPass.js +730 -0
- package/src/renderer/rendering/passes/HiZPass.js +744 -0
- package/src/renderer/rendering/passes/LightingPass.js +753 -0
- package/src/renderer/rendering/passes/ParticlePass.js +841 -0
- package/src/renderer/rendering/passes/PlanarReflectionPass.js +456 -0
- package/src/renderer/rendering/passes/PostProcessPass.js +405 -0
- package/src/renderer/rendering/passes/ReflectionPass.js +157 -0
- package/src/renderer/rendering/passes/RenderPostPass.js +364 -0
- package/src/renderer/rendering/passes/SSGIPass.js +266 -0
- package/src/renderer/rendering/passes/SSGITilePass.js +305 -0
- package/src/renderer/rendering/passes/ShadowPass.js +2072 -0
- package/src/renderer/rendering/passes/TransparentPass.js +831 -0
- package/src/renderer/rendering/passes/VolumetricFogPass.js +715 -0
- package/src/renderer/rendering/shaders/ao.wgsl +182 -0
- package/src/renderer/rendering/shaders/bloom.wgsl +97 -0
- package/src/renderer/rendering/shaders/bloom_blur.wgsl +80 -0
- package/src/renderer/rendering/shaders/crt.wgsl +455 -0
- package/src/renderer/rendering/shaders/depth_copy.wgsl +17 -0
- package/src/renderer/rendering/shaders/geometry.wgsl +580 -0
- package/src/renderer/rendering/shaders/hiz_reduce.wgsl +114 -0
- package/src/renderer/rendering/shaders/light_culling.wgsl +204 -0
- package/src/renderer/rendering/shaders/lighting.wgsl +932 -0
- package/src/renderer/rendering/shaders/lighting_common.wgsl +143 -0
- package/src/renderer/rendering/shaders/particle_render.wgsl +672 -0
- package/src/renderer/rendering/shaders/particle_simulate.wgsl +440 -0
- package/src/renderer/rendering/shaders/postproc.wgsl +293 -0
- package/src/renderer/rendering/shaders/render_post.wgsl +289 -0
- package/src/renderer/rendering/shaders/shadow.wgsl +117 -0
- package/src/renderer/rendering/shaders/ssgi.wgsl +266 -0
- package/src/renderer/rendering/shaders/ssgi_accumulate.wgsl +114 -0
- package/src/renderer/rendering/shaders/ssgi_propagate.wgsl +132 -0
- package/src/renderer/rendering/shaders/volumetric_blur.wgsl +80 -0
- package/src/renderer/rendering/shaders/volumetric_composite.wgsl +80 -0
- package/src/renderer/rendering/shaders/volumetric_raymarch.wgsl +634 -0
- package/src/renderer/utils/BoundingSphere.js +439 -0
- package/src/renderer/utils/Frustum.js +281 -0
- package/src/renderer/utils/Raycaster.js +761 -0
- package/dist/client.d.cts +0 -211
- package/dist/client.d.ts +0 -211
- package/dist/server.d.cts +0 -120
- package/dist/server.d.ts +0 -120
- package/dist/terminal.d.cts +0 -64
- package/dist/terminal.d.ts +0 -64
- package/src/utils.ts +0 -403
package/dist/server.js
CHANGED
|
@@ -1,281 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
// src/utils.ts
|
|
6
|
-
import { Packr } from "msgpackr";
|
|
7
|
-
import { FLOAT32_OPTIONS } from "msgpackr";
|
|
8
|
-
var { ALWAYS } = FLOAT32_OPTIONS;
|
|
9
|
-
var packr = new Packr({
|
|
10
|
-
useFloat32: ALWAYS
|
|
11
|
-
});
|
|
12
|
-
function encode(obj) {
|
|
13
|
-
return packr.pack(obj);
|
|
14
|
-
}
|
|
15
|
-
function decode(data) {
|
|
16
|
-
return packr.unpack(data);
|
|
17
|
-
}
|
|
18
|
-
function reactive(name, object, callback, path = "", excludedProperties = false) {
|
|
19
|
-
if (object === null || typeof object !== "object") {
|
|
20
|
-
return object;
|
|
21
|
-
}
|
|
22
|
-
function isReactive(p) {
|
|
23
|
-
let r = true;
|
|
24
|
-
if (p.startsWith("_")) {
|
|
25
|
-
r = false;
|
|
26
|
-
}
|
|
27
|
-
if (excludedProperties) {
|
|
28
|
-
if (excludedProperties[p]) {
|
|
29
|
-
r = false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (path == "/entities") {
|
|
33
|
-
r = false;
|
|
34
|
-
}
|
|
35
|
-
return r;
|
|
36
|
-
}
|
|
37
|
-
for (const property in object) {
|
|
38
|
-
if (isReactive(property)) {
|
|
39
|
-
object[property] = reactive(
|
|
40
|
-
name,
|
|
41
|
-
object[property],
|
|
42
|
-
callback,
|
|
43
|
-
path + "/" + property,
|
|
44
|
-
excludedProperties
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return new Proxy(object, {
|
|
50
|
-
get(target, property, receiver) {
|
|
51
|
-
return Reflect.get(target, property, receiver);
|
|
52
|
-
},
|
|
53
|
-
set(target, property, value) {
|
|
54
|
-
let newvalue;
|
|
55
|
-
let pn = path + "/" + String(property);
|
|
56
|
-
if (isReactive(String(property))) {
|
|
57
|
-
newvalue = reactive(name, value, callback, pn, excludedProperties);
|
|
58
|
-
callback(name, "replace", target, pn, newvalue);
|
|
59
|
-
} else {
|
|
60
|
-
newvalue = value;
|
|
61
|
-
}
|
|
62
|
-
return Reflect.set(target, property, newvalue);
|
|
63
|
-
},
|
|
64
|
-
deleteProperty(target, property) {
|
|
65
|
-
let pn = path + "/" + String(property);
|
|
66
|
-
if (isReactive(String(property))) {
|
|
67
|
-
callback(name, "remove", target, pn, null);
|
|
68
|
-
}
|
|
69
|
-
delete target[property];
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function clonewo_(obj, excludeStart = "_") {
|
|
75
|
-
if (obj === null || typeof obj !== "object") {
|
|
76
|
-
return obj;
|
|
77
|
-
}
|
|
78
|
-
function isExcluded(key) {
|
|
79
|
-
let e = false;
|
|
80
|
-
if (typeof excludeStart == "string" && key.startsWith(excludeStart)) {
|
|
81
|
-
e = true;
|
|
82
|
-
} else if (typeof excludeStart == "object") {
|
|
83
|
-
if (excludeStart[key] || key.startsWith("_")) {
|
|
84
|
-
e = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return e;
|
|
88
|
-
}
|
|
89
|
-
if (obj instanceof Map) {
|
|
90
|
-
const mapClone = /* @__PURE__ */ new Map();
|
|
91
|
-
Array.from(obj.entries()).forEach(([key, value]) => {
|
|
92
|
-
mapClone.set(clonewo_(key, excludeStart), clonewo_(value, excludeStart));
|
|
93
|
-
});
|
|
94
|
-
return mapClone;
|
|
95
|
-
}
|
|
96
|
-
let clone;
|
|
97
|
-
if (Array.isArray(obj)) {
|
|
98
|
-
clone = [];
|
|
99
|
-
for (let i = 0; i < obj.length; i++) {
|
|
100
|
-
clone[i] = clonewo_(obj[i], excludeStart);
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
clone = {};
|
|
104
|
-
for (let key in obj) {
|
|
105
|
-
if (obj.hasOwnProperty(key) && !isExcluded(key)) {
|
|
106
|
-
if (typeof obj[key] === "object") {
|
|
107
|
-
clone[key] = clonewo_(obj[key], excludeStart);
|
|
108
|
-
} else {
|
|
109
|
-
clone[key] = obj[key];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return clone;
|
|
115
|
-
}
|
|
116
|
-
function limitPrecision(obj) {
|
|
117
|
-
if (Array.isArray(obj)) {
|
|
118
|
-
return obj.map(limitPrecision);
|
|
119
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
120
|
-
const result = {};
|
|
121
|
-
for (const key in obj) {
|
|
122
|
-
result[key] = limitPrecision(obj[key]);
|
|
123
|
-
}
|
|
124
|
-
return result;
|
|
125
|
-
} else if (typeof obj === "number") {
|
|
126
|
-
if (Number.isInteger(obj)) {
|
|
127
|
-
return obj;
|
|
128
|
-
} else {
|
|
129
|
-
return parseFloat(obj.toFixed(3));
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
return obj;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function msgop(op) {
|
|
136
|
-
let nop = {};
|
|
137
|
-
if (!op.o) {
|
|
138
|
-
nop.op = "replace";
|
|
139
|
-
} else {
|
|
140
|
-
nop.op = {
|
|
141
|
-
a: "add",
|
|
142
|
-
r: "remove",
|
|
143
|
-
d: "delete",
|
|
144
|
-
t: "test"
|
|
145
|
-
}[op.o];
|
|
146
|
-
}
|
|
147
|
-
nop.path = op.p;
|
|
148
|
-
nop.value = op.v;
|
|
149
|
-
return nop;
|
|
150
|
-
}
|
|
151
|
-
function opmsg(op, target, path, value) {
|
|
152
|
-
let c = { p: path, v: value };
|
|
153
|
-
if (op != "replace") {
|
|
154
|
-
c.o = {
|
|
155
|
-
add: "a",
|
|
156
|
-
remove: "r",
|
|
157
|
-
delete: "d",
|
|
158
|
-
test: "t"
|
|
159
|
-
}[op];
|
|
160
|
-
}
|
|
161
|
-
return c;
|
|
162
|
-
}
|
|
163
|
-
function encode_uint32(uint, byteArray, offset = 0) {
|
|
164
|
-
if (!byteArray) {
|
|
165
|
-
byteArray = new Uint8Array(4);
|
|
166
|
-
}
|
|
167
|
-
let p = offset + 3;
|
|
168
|
-
byteArray[p--] = uint & 255;
|
|
169
|
-
uint >>= 8;
|
|
170
|
-
byteArray[p--] = uint & 255;
|
|
171
|
-
uint >>= 8;
|
|
172
|
-
byteArray[p--] = uint & 255;
|
|
173
|
-
uint >>= 8;
|
|
174
|
-
byteArray[p] = uint;
|
|
175
|
-
return byteArray;
|
|
176
|
-
}
|
|
177
|
-
function encode_uint24(uint, byteArray, offset = 0) {
|
|
178
|
-
if (!byteArray) {
|
|
179
|
-
byteArray = new Uint8Array(3);
|
|
180
|
-
}
|
|
181
|
-
let p = offset + 2;
|
|
182
|
-
byteArray[p--] = uint & 255;
|
|
183
|
-
uint >>= 8;
|
|
184
|
-
byteArray[p--] = uint & 255;
|
|
185
|
-
uint >>= 8;
|
|
186
|
-
byteArray[p] = uint;
|
|
187
|
-
return byteArray;
|
|
188
|
-
}
|
|
189
|
-
function encode_uint16(uint, byteArray, offset = 0) {
|
|
190
|
-
if (!byteArray) {
|
|
191
|
-
byteArray = new Uint8Array(2);
|
|
192
|
-
}
|
|
193
|
-
let p = offset + 1;
|
|
194
|
-
byteArray[p--] = uint & 255;
|
|
195
|
-
uint >>= 8;
|
|
196
|
-
byteArray[p] = uint;
|
|
197
|
-
return byteArray;
|
|
198
|
-
}
|
|
199
|
-
function encode_fp168(float, byteArray, offset = 0) {
|
|
200
|
-
const fp = Math.round(Math.abs(float) * 256);
|
|
201
|
-
encode_uint24(fp, byteArray, offset);
|
|
202
|
-
if (float < 0 && byteArray) {
|
|
203
|
-
byteArray[offset] |= 128;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function encode_fp1616(float, byteArray, offset = 0) {
|
|
207
|
-
const fp = Math.round(Math.abs(float) * 65536);
|
|
208
|
-
encode_uint32(fp, byteArray, offset);
|
|
209
|
-
if (float < 0 && byteArray) {
|
|
210
|
-
byteArray[offset] |= 128;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function encode_fp412(float, byteArray, offset = 0) {
|
|
214
|
-
const fp = Math.round(Math.abs(float) * 4096);
|
|
215
|
-
encode_uint16(fp, byteArray, offset);
|
|
216
|
-
if (float < 0 && byteArray) {
|
|
217
|
-
byteArray[offset] |= 128;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// src/compress-node.ts
|
|
1
|
+
import * as https from "node:https";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { r as reactive, d as decode, m as msgop, e as encode, g as clonewo_, l as limitPrecision, h as encode_uint32, i as encode_fp168, j as encode_fp412, k as encode_fp1616, o as opmsg } from "./utils-D7tXt6-2.js";
|
|
222
4
|
import { promisify } from "util";
|
|
223
|
-
import { gzip, gunzip
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
5
|
+
import { constants, gzip, gunzip } from "zlib";
|
|
6
|
+
import fastjsonpatch from "fast-json-patch";
|
|
7
|
+
import { WebSocketServer } from "ws";
|
|
8
|
+
import { MongoClient } from "mongodb";
|
|
9
|
+
import { glMatrix } from "gl-matrix";
|
|
10
|
+
import { RTCPeerConnection, RTCSessionDescription } from "werift";
|
|
11
|
+
const MIN_COMPRESSED_BUFFER_SIZE = 256;
|
|
12
|
+
const MAX_COMPRESSED_BUFFER_SIZE = 999999;
|
|
13
|
+
const lib_compress = promisify(gzip);
|
|
14
|
+
promisify(gunzip);
|
|
228
15
|
async function compress(buffer) {
|
|
229
16
|
if (buffer.byteLength <= MIN_COMPRESSED_BUFFER_SIZE || buffer.byteLength >= MAX_COMPRESSED_BUFFER_SIZE) return buffer;
|
|
230
17
|
try {
|
|
231
|
-
|
|
232
|
-
let cbytes = await lib_compress(buffer, {
|
|
18
|
+
const cbytes = await lib_compress(buffer, {
|
|
233
19
|
level: constants.Z_BEST_SPEED
|
|
234
20
|
});
|
|
235
|
-
|
|
236
|
-
let cbuffer = Buffer.from(cbytes);
|
|
237
|
-
let t3 = Date.now();
|
|
21
|
+
const cbuffer = Buffer.from(cbytes);
|
|
238
22
|
return cbuffer;
|
|
239
23
|
} catch (error) {
|
|
240
24
|
console.error("Error compressing buffer:", error);
|
|
241
25
|
return buffer;
|
|
242
26
|
}
|
|
243
27
|
}
|
|
244
|
-
|
|
245
|
-
// src/server.ts
|
|
246
|
-
import fastjsonpatch from "fast-json-patch";
|
|
247
|
-
import { WebSocketServer } from "ws";
|
|
248
|
-
import { MongoClient } from "mongodb";
|
|
249
|
-
import { glMatrix } from "gl-matrix";
|
|
250
|
-
import { RTCPeerConnection, RTCSessionDescription } from "werift";
|
|
251
28
|
glMatrix.setMatrixArrayType(Array);
|
|
252
|
-
|
|
29
|
+
const fastPatchProperties = {
|
|
253
30
|
"type": true,
|
|
254
|
-
// string 'enemy'
|
|
255
31
|
"status": true,
|
|
256
|
-
// string 'idle'
|
|
257
32
|
"level": true,
|
|
258
|
-
// number 2
|
|
259
33
|
"race": true,
|
|
260
|
-
// string 'goblin'
|
|
261
34
|
"class": true,
|
|
262
|
-
// string 'warrior'
|
|
263
35
|
"model": true,
|
|
264
|
-
// string 'models/models.glb|goblin'
|
|
265
36
|
"animation": true,
|
|
266
|
-
|
|
37
|
+
"sprite": true,
|
|
38
|
+
"frame": true,
|
|
39
|
+
"pivot": true,
|
|
40
|
+
// 'center' | 'bottom' | 'horizontal'
|
|
41
|
+
"color": true,
|
|
267
42
|
"sound": true,
|
|
268
|
-
// string 'sound/goblin.snd|snarl'
|
|
269
43
|
"effect": true,
|
|
270
|
-
// 'selected'
|
|
271
44
|
"position": true,
|
|
272
|
-
// [0, 0, 0] Vector (Number)
|
|
273
45
|
"rotation": true,
|
|
274
|
-
// [0, 0, 0, 1] Quaternion (Number)
|
|
275
46
|
"scale": true
|
|
276
|
-
// [1, 1, 1] Vector (Number)
|
|
277
47
|
};
|
|
278
|
-
|
|
48
|
+
const dictionaryProperties = {
|
|
279
49
|
"type": true,
|
|
280
50
|
"status": true,
|
|
281
51
|
"level": true,
|
|
@@ -283,17 +53,21 @@ var dictionaryProperties = {
|
|
|
283
53
|
"class": true,
|
|
284
54
|
"model": true,
|
|
285
55
|
"animation": true,
|
|
56
|
+
"sprite": true,
|
|
57
|
+
"frame": true,
|
|
58
|
+
"pivot": true,
|
|
59
|
+
"color": true,
|
|
286
60
|
"sound": true,
|
|
287
61
|
"effect": true
|
|
288
62
|
};
|
|
289
|
-
|
|
290
|
-
|
|
63
|
+
const { applyOperation } = fastjsonpatch;
|
|
64
|
+
const LITTLE_ENDIAN = (() => {
|
|
291
65
|
const buffer = new ArrayBuffer(2);
|
|
292
66
|
new DataView(buffer).setInt16(0, 256, true);
|
|
293
67
|
return new Int16Array(buffer)[0] === 256;
|
|
294
68
|
})();
|
|
295
|
-
|
|
296
|
-
|
|
69
|
+
const MAX_PACKAGE_SIZE = 65400;
|
|
70
|
+
class TopazCubeServer {
|
|
297
71
|
DEBUG = false;
|
|
298
72
|
name = "TopazCubeServer";
|
|
299
73
|
cycle = 100;
|
|
@@ -442,26 +216,17 @@ var TopazCubeServer = class {
|
|
|
442
216
|
});
|
|
443
217
|
this._startLoop();
|
|
444
218
|
}
|
|
445
|
-
/*= DOCUMENTS ==============================================================*/
|
|
446
|
-
// to be redefined. Called before a new document is created. Returns true if
|
|
447
|
-
// the client has the right to create an empty document
|
|
448
219
|
canCreate(client, name) {
|
|
449
220
|
return true;
|
|
450
221
|
}
|
|
451
|
-
// to be redefined. Called when a new document is created
|
|
452
|
-
// (returns an empty document)
|
|
453
222
|
onCreate(name) {
|
|
454
223
|
return {
|
|
455
224
|
data: {}
|
|
456
225
|
};
|
|
457
226
|
}
|
|
458
|
-
// to be redefined. Called when a client wants to sync (modify) a document.
|
|
459
|
-
// Returns true if the client has the right to sync that operation.
|
|
460
227
|
canSync(client, name, op) {
|
|
461
228
|
return true;
|
|
462
229
|
}
|
|
463
|
-
// to be redefined. Called when a new document is hydrated
|
|
464
|
-
// (created, or loaded from db)
|
|
465
230
|
async onHydrate(name, document) {
|
|
466
231
|
document.__hydrated = true;
|
|
467
232
|
}
|
|
@@ -483,7 +248,7 @@ var TopazCubeServer = class {
|
|
|
483
248
|
}
|
|
484
249
|
}
|
|
485
250
|
_createEmptyDocument(name) {
|
|
486
|
-
|
|
251
|
+
const doc = this.onCreate(name);
|
|
487
252
|
if (!doc) {
|
|
488
253
|
return;
|
|
489
254
|
}
|
|
@@ -516,11 +281,11 @@ var TopazCubeServer = class {
|
|
|
516
281
|
}
|
|
517
282
|
}
|
|
518
283
|
_updateAllDocumentsState() {
|
|
519
|
-
for (
|
|
284
|
+
for (const name in this.documents) {
|
|
520
285
|
if (name != "_server") {
|
|
521
|
-
|
|
286
|
+
this.documents[name];
|
|
522
287
|
this._documentState[name].subscibers = 0;
|
|
523
|
-
for (
|
|
288
|
+
for (const client of this.clients) {
|
|
524
289
|
if (client.subscribed && client.subscribed[name]) {
|
|
525
290
|
this._documentState[name].subscibers++;
|
|
526
291
|
}
|
|
@@ -528,8 +293,6 @@ var TopazCubeServer = class {
|
|
|
528
293
|
}
|
|
529
294
|
}
|
|
530
295
|
}
|
|
531
|
-
/*= UPDATE LOOP ============================================================*/
|
|
532
|
-
// to be redefined. called every this.cycle ms
|
|
533
296
|
onUpdate(name, doc, dt) {
|
|
534
297
|
}
|
|
535
298
|
_startLoop() {
|
|
@@ -543,22 +306,22 @@ var TopazCubeServer = class {
|
|
|
543
306
|
}, 1e3);
|
|
544
307
|
}
|
|
545
308
|
_loop() {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
309
|
+
const now = Date.now();
|
|
310
|
+
const dtms = now - this.lastUpdate;
|
|
311
|
+
const dt = dtms / 1e3;
|
|
549
312
|
this.lastUpdate = now;
|
|
550
313
|
this._stillUpdating = true;
|
|
551
|
-
for (
|
|
314
|
+
for (const name in this.documents) {
|
|
552
315
|
this.onUpdate(name, this.documents[name], dt);
|
|
553
316
|
}
|
|
554
|
-
|
|
317
|
+
const t1 = Date.now();
|
|
555
318
|
this._stillUpdating = false;
|
|
556
|
-
|
|
319
|
+
const updateTime = t1 - now;
|
|
557
320
|
this.stats.tUpdate.push(updateTime);
|
|
558
321
|
let patchTime = 0;
|
|
559
322
|
if (this.update % this.patchCycleDivider == 0) {
|
|
560
323
|
this._sendPatches();
|
|
561
|
-
|
|
324
|
+
const t2 = Date.now();
|
|
562
325
|
patchTime = t2 - t1;
|
|
563
326
|
this.stats.tPatch.push(patchTime);
|
|
564
327
|
if (this.allowFastPatch) {
|
|
@@ -567,15 +330,15 @@ var TopazCubeServer = class {
|
|
|
567
330
|
this.stats._sendRTCUpdate = 0;
|
|
568
331
|
}
|
|
569
332
|
this.update++;
|
|
570
|
-
|
|
571
|
-
|
|
333
|
+
const endUpdate = Date.now();
|
|
334
|
+
const totalUpdate = endUpdate - now;
|
|
572
335
|
setTimeout(() => {
|
|
573
336
|
this._loop();
|
|
574
337
|
}, Math.max(this.cycle - totalUpdate, 10));
|
|
575
338
|
}
|
|
576
339
|
_doStats() {
|
|
577
|
-
for (
|
|
578
|
-
|
|
340
|
+
for (const key in this.stats) {
|
|
341
|
+
const i = this.stats[key];
|
|
579
342
|
if (Array.isArray(i) && i.length > 0) {
|
|
580
343
|
while (i.length > 60) {
|
|
581
344
|
i.shift();
|
|
@@ -587,14 +350,10 @@ var TopazCubeServer = class {
|
|
|
587
350
|
}
|
|
588
351
|
}
|
|
589
352
|
}
|
|
590
|
-
/*= MESSAGES ===============================================================*/
|
|
591
|
-
// to be redefined. Called on message (operation) from client
|
|
592
353
|
onMessage(client, message) {
|
|
593
354
|
}
|
|
594
|
-
// to be redefined. Called when a client connects
|
|
595
355
|
onConnect(client) {
|
|
596
356
|
}
|
|
597
|
-
// to be redefined. Called when a client disconnects
|
|
598
357
|
onDisconnect(client) {
|
|
599
358
|
}
|
|
600
359
|
_onConnected(client) {
|
|
@@ -610,7 +369,7 @@ var TopazCubeServer = class {
|
|
|
610
369
|
this._onError(client, args);
|
|
611
370
|
});
|
|
612
371
|
client.on("message", (message) => {
|
|
613
|
-
|
|
372
|
+
const dec = decode(message);
|
|
614
373
|
if (this.simulateLatency) {
|
|
615
374
|
setTimeout(() => {
|
|
616
375
|
this._onMessage(client, dec);
|
|
@@ -627,18 +386,18 @@ var TopazCubeServer = class {
|
|
|
627
386
|
}
|
|
628
387
|
async _onMessage(client, message) {
|
|
629
388
|
if (message.c == "sync" && this.allowSync && client.subscribed && client.subscribed[message.n] && this.documents[message.n]) {
|
|
630
|
-
|
|
389
|
+
const name = message.n;
|
|
631
390
|
if (!this._documentChanges[name]) {
|
|
632
391
|
this._documentChanges[name] = [];
|
|
633
392
|
this._documentChanged[name] = false;
|
|
634
393
|
}
|
|
635
|
-
for (
|
|
394
|
+
for (const op of message.p) {
|
|
636
395
|
if (!this.canSync(client, name, op)) {
|
|
637
396
|
continue;
|
|
638
397
|
}
|
|
639
398
|
this._documentChanges[name].push(op);
|
|
640
399
|
this._documentChanged[name] = true;
|
|
641
|
-
|
|
400
|
+
const dop = msgop(op);
|
|
642
401
|
applyOperation(this.documents[name], dop);
|
|
643
402
|
}
|
|
644
403
|
} else if (message.c == "ping") {
|
|
@@ -649,8 +408,8 @@ var TopazCubeServer = class {
|
|
|
649
408
|
ID: client.ID
|
|
650
409
|
});
|
|
651
410
|
} else if (message.c == "peng") {
|
|
652
|
-
|
|
653
|
-
|
|
411
|
+
const time = Date.now();
|
|
412
|
+
const ping = time - message.st;
|
|
654
413
|
client.ctdiff = message.ct + ping / 2 - time;
|
|
655
414
|
client.ping = ping;
|
|
656
415
|
} else if (message.c == "rtc-offer") {
|
|
@@ -690,21 +449,21 @@ var TopazCubeServer = class {
|
|
|
690
449
|
client.peerConnection.close();
|
|
691
450
|
}
|
|
692
451
|
this.log("client disconnected");
|
|
693
|
-
|
|
452
|
+
const index = this.clients.indexOf(client);
|
|
694
453
|
if (index !== -1) {
|
|
695
454
|
this.clients.splice(index, 1);
|
|
696
455
|
}
|
|
697
456
|
}
|
|
698
457
|
async send(client, message) {
|
|
699
458
|
try {
|
|
700
|
-
|
|
459
|
+
const t1 = Date.now();
|
|
701
460
|
let data = encode(message);
|
|
702
|
-
|
|
703
|
-
|
|
461
|
+
const t2 = Date.now();
|
|
462
|
+
const dl = data.byteLength;
|
|
704
463
|
if (this.allowCompression) {
|
|
705
464
|
data = await compress(data);
|
|
706
465
|
}
|
|
707
|
-
|
|
466
|
+
const t3 = Date.now();
|
|
708
467
|
if (data.length > 4096) {
|
|
709
468
|
this.log(`Big message ${dl} -> ${data.length} (${(100 * data.length / dl).toFixed()}%) encoding:${t2 - t1}ms compression:${t3 - t1}ms`);
|
|
710
469
|
}
|
|
@@ -728,7 +487,7 @@ var TopazCubeServer = class {
|
|
|
728
487
|
if (this.allowCompression) {
|
|
729
488
|
data = await compress(data);
|
|
730
489
|
}
|
|
731
|
-
for (
|
|
490
|
+
for (const client of this.clients) {
|
|
732
491
|
this.stats.send += data.byteLength;
|
|
733
492
|
if (this.simulateLatency) {
|
|
734
493
|
setTimeout(() => {
|
|
@@ -745,13 +504,13 @@ var TopazCubeServer = class {
|
|
|
745
504
|
if (this.allowFastPatch) {
|
|
746
505
|
excluded = fastPatchProperties;
|
|
747
506
|
}
|
|
748
|
-
|
|
507
|
+
const doc = clonewo_(this.documents[name], excluded);
|
|
749
508
|
limitPrecision(doc);
|
|
750
509
|
let fdata = false;
|
|
751
510
|
if (this.allowFastPatch) {
|
|
752
511
|
fdata = this._encodeFastChanges(name, false);
|
|
753
512
|
}
|
|
754
|
-
|
|
513
|
+
const fullState = {
|
|
755
514
|
c: "full",
|
|
756
515
|
le: LITTLE_ENDIAN,
|
|
757
516
|
t: Date.now(),
|
|
@@ -762,7 +521,7 @@ var TopazCubeServer = class {
|
|
|
762
521
|
this.send(client, fullState);
|
|
763
522
|
}
|
|
764
523
|
_encodeFastChanges(name, changesOnly = true) {
|
|
765
|
-
|
|
524
|
+
const doc = this.documents[name];
|
|
766
525
|
if (!doc) {
|
|
767
526
|
return false;
|
|
768
527
|
}
|
|
@@ -771,17 +530,17 @@ var TopazCubeServer = class {
|
|
|
771
530
|
origin = [0, 0, 0];
|
|
772
531
|
this.documents[name].origin = origin;
|
|
773
532
|
}
|
|
774
|
-
|
|
775
|
-
|
|
533
|
+
const entities = doc.entities;
|
|
534
|
+
const ids = Object.keys(entities);
|
|
776
535
|
if (!entities) {
|
|
777
536
|
return false;
|
|
778
537
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
for (
|
|
538
|
+
const count = {};
|
|
539
|
+
const changed = {};
|
|
540
|
+
const hasChanges = {};
|
|
541
|
+
const dictionary = {};
|
|
542
|
+
const encodedChanges = {};
|
|
543
|
+
for (const key in fastPatchProperties) {
|
|
785
544
|
if (changesOnly) {
|
|
786
545
|
count[key] = 0;
|
|
787
546
|
changed[key] = {};
|
|
@@ -794,9 +553,9 @@ var TopazCubeServer = class {
|
|
|
794
553
|
dictionary[key] = {};
|
|
795
554
|
}
|
|
796
555
|
if (changesOnly) {
|
|
797
|
-
for (
|
|
798
|
-
|
|
799
|
-
for (
|
|
556
|
+
for (const id in entities) {
|
|
557
|
+
const e = entities[id];
|
|
558
|
+
for (const key in fastPatchProperties) {
|
|
800
559
|
if (e["__changed_" + key]) {
|
|
801
560
|
changed["" + key]["" + id] = true;
|
|
802
561
|
count["" + key] = parseInt("" + count["" + key]) + 1;
|
|
@@ -806,18 +565,18 @@ var TopazCubeServer = class {
|
|
|
806
565
|
}
|
|
807
566
|
}
|
|
808
567
|
} else {
|
|
809
|
-
for (
|
|
810
|
-
for (
|
|
568
|
+
for (const id in entities) {
|
|
569
|
+
for (const key in fastPatchProperties) {
|
|
811
570
|
changed["" + key]["" + id] = true;
|
|
812
571
|
}
|
|
813
572
|
}
|
|
814
573
|
}
|
|
815
574
|
let dictUID = 1;
|
|
816
|
-
for (
|
|
575
|
+
for (const key in hasChanges) {
|
|
817
576
|
if (hasChanges[key] && dictionaryProperties[key]) {
|
|
818
|
-
for (
|
|
819
|
-
|
|
820
|
-
|
|
577
|
+
for (const id in changed[key]) {
|
|
578
|
+
const e = entities[id];
|
|
579
|
+
const value = e[key];
|
|
821
580
|
if (!dictionary[key][value]) {
|
|
822
581
|
dictionary[key][value] = dictUID++;
|
|
823
582
|
}
|
|
@@ -825,21 +584,21 @@ var TopazCubeServer = class {
|
|
|
825
584
|
}
|
|
826
585
|
}
|
|
827
586
|
this.log("--------------------------------------------------");
|
|
828
|
-
for (
|
|
587
|
+
for (const key in hasChanges) {
|
|
829
588
|
if (hasChanges[key]) {
|
|
830
|
-
|
|
831
|
-
|
|
589
|
+
const size = parseInt("" + count["" + key]);
|
|
590
|
+
const encoded = {};
|
|
832
591
|
if (dictionaryProperties[key]) {
|
|
833
592
|
encoded.dict = dictionary[key];
|
|
834
|
-
|
|
593
|
+
const pdata = new Uint8Array(size * 8);
|
|
835
594
|
let offset = 0;
|
|
836
|
-
for (
|
|
837
|
-
|
|
838
|
-
|
|
595
|
+
for (const id in changed[key]) {
|
|
596
|
+
const e = entities[id];
|
|
597
|
+
const nid = parseInt(id);
|
|
839
598
|
encode_uint32(nid, pdata, offset);
|
|
840
599
|
offset += 4;
|
|
841
|
-
|
|
842
|
-
|
|
600
|
+
const value = e[key];
|
|
601
|
+
const did = parseInt(dictionary[key][value]);
|
|
843
602
|
encode_uint32(did, pdata, offset);
|
|
844
603
|
offset += 4;
|
|
845
604
|
}
|
|
@@ -856,9 +615,9 @@ var TopazCubeServer = class {
|
|
|
856
615
|
pdata = new Uint8Array(0);
|
|
857
616
|
}
|
|
858
617
|
let offset = 0;
|
|
859
|
-
for (
|
|
860
|
-
|
|
861
|
-
|
|
618
|
+
for (const id in changed[key]) {
|
|
619
|
+
const e = entities[id];
|
|
620
|
+
const nid = parseInt(id);
|
|
862
621
|
encode_uint32(nid, pdata, offset);
|
|
863
622
|
offset += 4;
|
|
864
623
|
if (key == "position") {
|
|
@@ -894,17 +653,16 @@ var TopazCubeServer = class {
|
|
|
894
653
|
return encodedChanges;
|
|
895
654
|
}
|
|
896
655
|
_sendPatches() {
|
|
897
|
-
|
|
898
|
-
for (
|
|
899
|
-
|
|
656
|
+
const now = Date.now();
|
|
657
|
+
for (const name in this._documentChanges) {
|
|
658
|
+
const dc = this._documentChanges[name];
|
|
900
659
|
this._documentChanges[name] = [];
|
|
901
|
-
|
|
660
|
+
const sus = this.clients.filter((client) => client.subscribed && client.subscribed[name]);
|
|
902
661
|
if (sus.length > 0) {
|
|
903
662
|
if (dc && dc.length > 0) {
|
|
904
|
-
|
|
663
|
+
const record = {
|
|
905
664
|
c: "patch",
|
|
906
665
|
t: now,
|
|
907
|
-
// server time
|
|
908
666
|
u: this.update,
|
|
909
667
|
n: name,
|
|
910
668
|
doc: dc
|
|
@@ -914,19 +672,18 @@ var TopazCubeServer = class {
|
|
|
914
672
|
}
|
|
915
673
|
if (this.allowFastPatch) {
|
|
916
674
|
if (sus.length > 0) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
675
|
+
const t1 = Date.now();
|
|
676
|
+
const changes = this._encodeFastChanges(name);
|
|
677
|
+
const t2 = Date.now();
|
|
678
|
+
const record = {
|
|
921
679
|
c: "fpatch",
|
|
922
680
|
t: now,
|
|
923
|
-
// server time
|
|
924
681
|
u: this.update,
|
|
925
682
|
n: name,
|
|
926
683
|
fdata: changes
|
|
927
684
|
};
|
|
928
685
|
this.broadcastRTC(record, sus);
|
|
929
|
-
|
|
686
|
+
const t3 = Date.now();
|
|
930
687
|
this.log(`_sendPatches: ${name} encode_changes: ${t2 - t1}ms broadcast:${t3 - t2}ms`);
|
|
931
688
|
}
|
|
932
689
|
}
|
|
@@ -937,21 +694,20 @@ var TopazCubeServer = class {
|
|
|
937
694
|
this._documentChanged[name] = true;
|
|
938
695
|
}
|
|
939
696
|
propertyChange(name, id, property) {
|
|
940
|
-
|
|
697
|
+
const doc = this.documents[name];
|
|
941
698
|
if (!doc) {
|
|
942
699
|
return;
|
|
943
700
|
}
|
|
944
|
-
|
|
701
|
+
const entities = doc.entities;
|
|
945
702
|
if (!entities) {
|
|
946
703
|
return;
|
|
947
704
|
}
|
|
948
|
-
|
|
705
|
+
const e = entities[id];
|
|
949
706
|
if (!e) {
|
|
950
707
|
return;
|
|
951
708
|
}
|
|
952
709
|
e["__changed_" + property] = true;
|
|
953
710
|
}
|
|
954
|
-
/*= WEBRTC ===================================================================*/
|
|
955
711
|
async _processOffer(client, data) {
|
|
956
712
|
if (!this.allowWebRTC) {
|
|
957
713
|
this.warn("WebRTC is disabled");
|
|
@@ -964,7 +720,6 @@ var TopazCubeServer = class {
|
|
|
964
720
|
{ urls: "stun:stun.cloudflare.com:3478" },
|
|
965
721
|
{ urls: "stun:freestun.net:3478" }
|
|
966
722
|
]
|
|
967
|
-
//iceCandidatePoolSize: 10,
|
|
968
723
|
});
|
|
969
724
|
client.peerConnection = peerConnection;
|
|
970
725
|
peerConnection.onicecandidate = (event) => {
|
|
@@ -974,7 +729,6 @@ var TopazCubeServer = class {
|
|
|
974
729
|
c: "rtc-candidate",
|
|
975
730
|
type: "ice-candidate",
|
|
976
731
|
candidate: event.candidate
|
|
977
|
-
// .toJSON()
|
|
978
732
|
});
|
|
979
733
|
} else {
|
|
980
734
|
this.log("RTC: ICE candidate gathering complete");
|
|
@@ -1002,7 +756,6 @@ var TopazCubeServer = class {
|
|
|
1002
756
|
try {
|
|
1003
757
|
this.log("RTC: Remote description set from data", data);
|
|
1004
758
|
await peerConnection.setRemoteDescription(
|
|
1005
|
-
//data
|
|
1006
759
|
new RTCSessionDescription(data.sdp, data.type)
|
|
1007
760
|
);
|
|
1008
761
|
this.log("RTC: Remote description set successfully");
|
|
@@ -1066,7 +819,6 @@ var TopazCubeServer = class {
|
|
|
1066
819
|
if (client.peerConnection && data.candidate) {
|
|
1067
820
|
await client.peerConnection.addIceCandidate(
|
|
1068
821
|
data.candidate
|
|
1069
|
-
//new wrtc.RTCIceCandidate(data.candidate)
|
|
1070
822
|
);
|
|
1071
823
|
this.log(`RTC: ICE candidate added successfully for client ${client.ID}`);
|
|
1072
824
|
} else {
|
|
@@ -1086,7 +838,7 @@ var TopazCubeServer = class {
|
|
|
1086
838
|
}
|
|
1087
839
|
this.stats.sendRTC += data.byteLength;
|
|
1088
840
|
this.stats._sendRTCUpdate += data.byteLength;
|
|
1089
|
-
|
|
841
|
+
const packages = this._splitRTCMessage(data);
|
|
1090
842
|
if (this.simulateLatency) {
|
|
1091
843
|
setTimeout(() => {
|
|
1092
844
|
if (this._clientRTCOpen(client)) {
|
|
@@ -1107,19 +859,19 @@ var TopazCubeServer = class {
|
|
|
1107
859
|
if (clients.length == 0) {
|
|
1108
860
|
clients = this.clients;
|
|
1109
861
|
}
|
|
1110
|
-
|
|
862
|
+
const t1 = Date.now();
|
|
1111
863
|
let data = encode(message);
|
|
1112
|
-
|
|
1113
|
-
|
|
864
|
+
const dl = data.byteLength;
|
|
865
|
+
const t2 = Date.now();
|
|
1114
866
|
if (this.allowCompression) {
|
|
1115
867
|
data = await compress(data);
|
|
1116
868
|
}
|
|
1117
|
-
|
|
869
|
+
const t3 = Date.now();
|
|
1118
870
|
if (data.length > 16384) {
|
|
1119
871
|
this.log(`BroadcastRTC message ${dl} -> ${data.length} (${(100 * data.length / dl).toFixed()}%) encoding:${t2 - t1}ms compression:${t3 - t1}ms`);
|
|
1120
872
|
}
|
|
1121
|
-
|
|
1122
|
-
for (
|
|
873
|
+
const packages = this._splitRTCMessage(data);
|
|
874
|
+
for (const client of this.clients) {
|
|
1123
875
|
this.stats.sendRTC += data.byteLength;
|
|
1124
876
|
this.stats._sendRTCUpdate += data.byteLength;
|
|
1125
877
|
if (this.simulateLatency) {
|
|
@@ -1146,13 +898,13 @@ var TopazCubeServer = class {
|
|
|
1146
898
|
this.warn(`RTC: Message too large: ${data.byteLength} bytes`);
|
|
1147
899
|
packages = [];
|
|
1148
900
|
let offset = 0;
|
|
1149
|
-
|
|
901
|
+
const mid = this.update + "-" + now;
|
|
1150
902
|
let seq = 0;
|
|
1151
903
|
while (offset < data.byteLength) {
|
|
1152
904
|
const remaining = data.byteLength - offset;
|
|
1153
905
|
const chunkSize = Math.min(remaining, MAX_PACKAGE_SIZE);
|
|
1154
906
|
const chunk = new Uint8Array(data.buffer, offset, chunkSize);
|
|
1155
|
-
|
|
907
|
+
const cmessage = {
|
|
1156
908
|
c: "chunk",
|
|
1157
909
|
t: now,
|
|
1158
910
|
mid,
|
|
@@ -1174,9 +926,6 @@ var TopazCubeServer = class {
|
|
|
1174
926
|
}
|
|
1175
927
|
return packages;
|
|
1176
928
|
}
|
|
1177
|
-
/*= DATABASE =================================================================*/
|
|
1178
|
-
// properties (of the documents) that starts with __ are not saved to the database.
|
|
1179
|
-
// __properties are restored on hydration. (for example __physicsBody or __bigObject)
|
|
1180
929
|
getUID() {
|
|
1181
930
|
this.documents["_server"].nextUID++;
|
|
1182
931
|
return this.documents["_server"].nextUID;
|
|
@@ -1222,7 +971,7 @@ var TopazCubeServer = class {
|
|
|
1222
971
|
if (this.DB) {
|
|
1223
972
|
try {
|
|
1224
973
|
const doc = this.documents[name];
|
|
1225
|
-
|
|
974
|
+
const newdoc = clonewo_(doc, "__");
|
|
1226
975
|
this.log(`Saving document '${name}' to MongoDB`);
|
|
1227
976
|
await this.DB.collection(this.collection).updateOne(
|
|
1228
977
|
{ name },
|
|
@@ -1241,7 +990,7 @@ var TopazCubeServer = class {
|
|
|
1241
990
|
if (!this.allowSave) {
|
|
1242
991
|
return;
|
|
1243
992
|
}
|
|
1244
|
-
for (
|
|
993
|
+
for (const name in this.documents) {
|
|
1245
994
|
await this._saveDocument(name);
|
|
1246
995
|
}
|
|
1247
996
|
}
|
|
@@ -1249,11 +998,11 @@ var TopazCubeServer = class {
|
|
|
1249
998
|
if (!this.allowSave) {
|
|
1250
999
|
return;
|
|
1251
1000
|
}
|
|
1252
|
-
for (
|
|
1001
|
+
for (const name in this._documentChanged) {
|
|
1253
1002
|
if (!this._lastSave[name]) {
|
|
1254
1003
|
this._lastSave[name] = Date.now() - 6e4;
|
|
1255
1004
|
}
|
|
1256
|
-
|
|
1005
|
+
const lastSave = this._lastSave[name];
|
|
1257
1006
|
if (Date.now() - lastSave < 1e4) {
|
|
1258
1007
|
continue;
|
|
1259
1008
|
}
|
|
@@ -1269,7 +1018,6 @@ var TopazCubeServer = class {
|
|
|
1269
1018
|
nextUID: 100
|
|
1270
1019
|
};
|
|
1271
1020
|
}
|
|
1272
|
-
/*= EXIT ===================================================================*/
|
|
1273
1021
|
_exitSignal(signal) {
|
|
1274
1022
|
if (!this._exited) {
|
|
1275
1023
|
this.log("\nEXIT: Caught interrupt signal " + signal);
|
|
@@ -1284,11 +1032,10 @@ var TopazCubeServer = class {
|
|
|
1284
1032
|
setTimeout(() => process.exit(0), 1e3);
|
|
1285
1033
|
}
|
|
1286
1034
|
}
|
|
1287
|
-
// To be redefined. Called BEFORE program exit, and saving all documents
|
|
1288
1035
|
onBeforeExit() {
|
|
1289
1036
|
}
|
|
1290
|
-
}
|
|
1037
|
+
}
|
|
1291
1038
|
export {
|
|
1292
1039
|
TopazCubeServer as default
|
|
1293
1040
|
};
|
|
1294
|
-
//# sourceMappingURL=server.js.map
|
|
1041
|
+
//# sourceMappingURL=server.js.map
|