@reboot-dev/reboot-std 0.22.0 → 0.24.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/package.json +5 -4
- package/presence/index.js +5 -5
- package/vitest/index.d.ts +5 -0
- package/vitest/index.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reboot-dev/reboot-std",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Reboot standard library.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"author": "reboot-dev",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@reboot-dev/reboot-std-api": "0.
|
|
14
|
-
"@reboot-dev/reboot": "0.
|
|
13
|
+
"@reboot-dev/reboot-std-api": "0.24.0",
|
|
14
|
+
"@reboot-dev/reboot": "0.24.0"
|
|
15
15
|
},
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"devDependencies": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"./package.json": "./package.json",
|
|
22
22
|
".": "./index.js",
|
|
23
23
|
"./collections/sorted_map.js": "./collections/sorted_map.js",
|
|
24
|
-
"./presence": "./presence/index.js"
|
|
24
|
+
"./presence": "./presence/index.js",
|
|
25
|
+
"./vitest": "./vitest/index.js"
|
|
25
26
|
}
|
|
26
27
|
}
|
package/presence/index.js
CHANGED
|
@@ -12,9 +12,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _Event_resolve, _Event_promise, _SubscriberServicer_disconnectEvents;
|
|
13
13
|
import { until, } from "@reboot-dev/reboot";
|
|
14
14
|
import { AlreadyExists, FailedPrecondition, NotFound, } from "@reboot-dev/reboot-api/errors_pb.js";
|
|
15
|
-
import { Presence, } from "@reboot-dev/reboot-std-api/presence/v1/presence_rbt.js";
|
|
16
15
|
import { MousePosition, } from "@reboot-dev/reboot-std-api/presence/mouse_tracker/v1/mouse_position_rbt.js";
|
|
17
16
|
import { Subscriber, } from "@reboot-dev/reboot-std-api/presence/subscriber/v1/subscriber_rbt.js";
|
|
17
|
+
import { Presence, } from "@reboot-dev/reboot-std-api/presence/v1/presence_rbt.js";
|
|
18
18
|
class Event {
|
|
19
19
|
constructor() {
|
|
20
20
|
_Event_resolve.set(this, void 0);
|
|
@@ -39,12 +39,12 @@ class PresenceServicer extends Presence.Servicer {
|
|
|
39
39
|
if (state.subscriberIds.includes(request.subscriberId)) {
|
|
40
40
|
return {};
|
|
41
41
|
}
|
|
42
|
-
const status = await Subscriber.
|
|
42
|
+
const status = await Subscriber.ref(request.subscriberId).status(context);
|
|
43
43
|
if (!status.present) {
|
|
44
44
|
throw new Presence.SubscribeAborted(new FailedPrecondition());
|
|
45
45
|
}
|
|
46
46
|
state.subscriberIds = state.subscriberIds.concat(request.subscriberId);
|
|
47
|
-
await this.
|
|
47
|
+
await this.ref().schedule().watch(context, {
|
|
48
48
|
subscriberId: request.subscriberId,
|
|
49
49
|
});
|
|
50
50
|
return {};
|
|
@@ -53,7 +53,7 @@ class PresenceServicer extends Presence.Servicer {
|
|
|
53
53
|
// We *atomically* wait until no longer present and remove.
|
|
54
54
|
await until("no longer present", context, async () => {
|
|
55
55
|
return this.state.unidempotently().write(context, async (state) => {
|
|
56
|
-
const subscriber = Subscriber.
|
|
56
|
+
const subscriber = Subscriber.ref(request.subscriberId);
|
|
57
57
|
const { present } = await subscriber.status(context);
|
|
58
58
|
if (!present) {
|
|
59
59
|
state.subscriberIds = state.subscriberIds.filter((subscriberId) => subscriberId !== request.subscriberId);
|
|
@@ -97,7 +97,7 @@ class SubscriberServicer extends Subscriber.Servicer {
|
|
|
97
97
|
throw new Subscriber.ToggleAborted(new NotFound());
|
|
98
98
|
}
|
|
99
99
|
state.toggles += 1;
|
|
100
|
-
await this.
|
|
100
|
+
await this.ref()
|
|
101
101
|
.schedule()
|
|
102
102
|
.waitForDisconnect(context, { nonce: request.nonce });
|
|
103
103
|
return {};
|
package/vitest/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BasicReporter } from "vitest/reporters";
|
|
2
|
+
// Vitest, a 'modern' and powerful test framework isn't able to print verbose errors out-of-the-box.
|
|
3
|
+
// Use this vitest reporter to see all errors printed to the console.
|
|
4
|
+
export class BetterErrorTracingReporter extends BasicReporter {
|
|
5
|
+
onTaskUpdate(packs) {
|
|
6
|
+
if (this.isTTY) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
for (const pack of packs) {
|
|
10
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
11
|
+
if (task) {
|
|
12
|
+
this.printTask(task);
|
|
13
|
+
}
|
|
14
|
+
if (task &&
|
|
15
|
+
task.type === "test" &&
|
|
16
|
+
task.result?.state &&
|
|
17
|
+
task.result?.state !== "run") {
|
|
18
|
+
if (task.result.state === "fail") {
|
|
19
|
+
task.result.errors?.forEach((error) => {
|
|
20
|
+
this.ctx.logger.error({
|
|
21
|
+
name: error?.name,
|
|
22
|
+
error: error.error,
|
|
23
|
+
code: error.code,
|
|
24
|
+
}, error.stack);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|