@aethervtt/shard-net 0.3.0 → 0.4.1
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/plugin.js +15 -3
- package/package.json +5 -5
package/dist/plugin.js
CHANGED
|
@@ -9,7 +9,11 @@ import {
|
|
|
9
9
|
ShardError,
|
|
10
10
|
t
|
|
11
11
|
} from "@aethervtt/shard-core";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
definePlugin,
|
|
14
|
+
FixedTime,
|
|
15
|
+
Time
|
|
16
|
+
} from "@aethervtt/shard-runtime";
|
|
13
17
|
import { NetClient, PendingCommand } from "./client.js";
|
|
14
18
|
import * as components from "./components.js";
|
|
15
19
|
import { NetClock, NetRole, Replicated } from "./components.js";
|
|
@@ -201,12 +205,20 @@ function sendCommand(world, def, data) {
|
|
|
201
205
|
return pending;
|
|
202
206
|
}
|
|
203
207
|
function commands(world, def) {
|
|
204
|
-
const
|
|
208
|
+
const session = world.tryResource(NetSession);
|
|
209
|
+
if (!session) return [];
|
|
210
|
+
const server = session.server;
|
|
205
211
|
if (!server) throw notAuthority(`read ${def.name} commands`);
|
|
206
212
|
return server.pending(def);
|
|
207
213
|
}
|
|
208
214
|
function sendEvent(world, def, data, options = {}) {
|
|
209
|
-
const
|
|
215
|
+
const session = world.tryResource(NetSession);
|
|
216
|
+
if (!session) {
|
|
217
|
+
const tick = world.tryResource(FixedTime)?.tick ?? 0;
|
|
218
|
+
world.send(def.event, { data, tick });
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const server = session.server;
|
|
210
222
|
if (!server) throw notAuthority(`send ${def.name}`);
|
|
211
223
|
server.sendEvent(def, data, options.to ?? "all");
|
|
212
224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aethervtt/shard-net",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aethervtt/shard-core": "0.
|
|
24
|
-
"@aethervtt/shard-runtime": "0.
|
|
25
|
-
"@aethervtt/shard-transform": "0.
|
|
23
|
+
"@aethervtt/shard-core": "0.4.1",
|
|
24
|
+
"@aethervtt/shard-runtime": "0.4.1",
|
|
25
|
+
"@aethervtt/shard-transform": "0.4.1"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"shard": {
|
|
37
|
-
"buildSha": "
|
|
37
|
+
"buildSha": "0061be4019b2a0af985eada9a60f757a3c6e2ba4"
|
|
38
38
|
}
|
|
39
39
|
}
|