@astrosheep/square 0.3.51 → 0.3.53
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.
|
@@ -36,10 +36,6 @@ function frameBoundary(lines) {
|
|
|
36
36
|
return `\n${lines.join('\n')}\n`;
|
|
37
37
|
}
|
|
38
38
|
function renderBoundary(inbox) {
|
|
39
|
-
const count = pendingCount(inbox);
|
|
40
|
-
const noun = count === 1 ? 'notification' : 'notifications';
|
|
41
|
-
const header = `<system-reminder source="square">You have ${count} Square ${noun}.`;
|
|
42
|
-
const footer = ['</system-reminder>'];
|
|
43
39
|
const queued = inbox.flatMap((membership) => membership.notifications.map((notification) => ({ membership, notification })));
|
|
44
40
|
const blocks = [];
|
|
45
41
|
const complete = [];
|
|
@@ -57,15 +53,7 @@ function renderBoundary(inbox) {
|
|
|
57
53
|
}),
|
|
58
54
|
].join('\n');
|
|
59
55
|
const omittedAfter = omitted + queued.length - index - 1;
|
|
60
|
-
const prospective = frameBoundary([
|
|
61
|
-
header,
|
|
62
|
-
...blocks,
|
|
63
|
-
block,
|
|
64
|
-
...(omittedAfter > 0
|
|
65
|
-
? [`… ${omittedAfter} ${omittedAfter === 1 ? 'notification' : 'notifications'} omitted.`]
|
|
66
|
-
: []),
|
|
67
|
-
...footer,
|
|
68
|
-
]);
|
|
56
|
+
const prospective = frameBoundary([...blocks, block, ...(omittedAfter > 0 ? [`… ${omittedAfter} ${omittedAfter === 1 ? 'notification' : 'notifications'} omitted.`] : [])]);
|
|
69
57
|
if (prospective.length > CONTEXT_MAX) {
|
|
70
58
|
omitted += 1;
|
|
71
59
|
continue;
|
|
@@ -78,14 +66,7 @@ function renderBoundary(inbox) {
|
|
|
78
66
|
});
|
|
79
67
|
}
|
|
80
68
|
return {
|
|
81
|
-
context: frameBoundary([
|
|
82
|
-
header,
|
|
83
|
-
...blocks,
|
|
84
|
-
...(omitted > 0
|
|
85
|
-
? [`… ${omitted} ${omitted === 1 ? 'notification' : 'notifications'} omitted.`]
|
|
86
|
-
: []),
|
|
87
|
-
...footer,
|
|
88
|
-
]),
|
|
69
|
+
context: frameBoundary([...blocks, ...(omitted > 0 ? [`… ${omitted} ${omitted === 1 ? 'notification' : 'notifications'} omitted.`] : [])]),
|
|
89
70
|
complete,
|
|
90
71
|
};
|
|
91
72
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cmdActivity } from '../activity.js';
|
|
2
2
|
import { formatActivityId, formatHardCap, parseActivityId, } from '../model.js';
|
|
3
3
|
import { participantCommandPrefix, participantIdentity, quoteShell, renderEventCli, renderAmbientEvent, withPathOutput, } from '../presentation.js';
|
|
4
|
-
import { claimSessionParticipant, hasAutomaticDeliveryIdentity, lookupParticipant, recordSessionDone, } from '../registry.js';
|
|
4
|
+
import { claimSessionParticipant, hasAutomaticDeliveryIdentity, localSessionIdentities, lookupParticipant, readParticipantOwner, recordSessionDone, } from '../registry.js';
|
|
5
5
|
import { createHostLedgerPort } from '../host-ledger-file-adapter.js';
|
|
6
|
-
import {
|
|
6
|
+
import { sessionIdsFromEnvironment } from '../square-projections.js';
|
|
7
7
|
import { nowMs } from '../runtime.js';
|
|
8
8
|
import { createSquare, openSquare } from '../square-file-adapter.js';
|
|
9
9
|
import { closeOpenSquare } from '../open-square.js';
|
|
@@ -90,13 +90,9 @@ export const joinCommand = {
|
|
|
90
90
|
const hostLedger = createHostLedgerPort();
|
|
91
91
|
const square = await Square.at({ path: squarePath, clock: nowMs, hostLedger, wakeTransport: await createDefaultWakeTransport(hostLedger, nowMs) });
|
|
92
92
|
try {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
location: squarePath,
|
|
97
|
-
participant: intent.name,
|
|
98
|
-
sessionIds: sessionIdsFromEnvironment(),
|
|
99
|
-
}) !== undefined;
|
|
93
|
+
const identity = localSessionIdentities()[0];
|
|
94
|
+
const owner = before.joined ? await readParticipantOwner(squarePath, intent.name) : undefined;
|
|
95
|
+
const reconnect = before.joined && identity !== undefined && owner?.sessionId === identity.sessionId;
|
|
100
96
|
const isRejoin = before.joined;
|
|
101
97
|
if (isRejoin && !intent.kick && !reconnect) {
|
|
102
98
|
fail([
|
|
@@ -106,7 +102,7 @@ export const joinCommand = {
|
|
|
106
102
|
`» ${participantCommandPrefix(squarePath, intent.name)} join --kick`,
|
|
107
103
|
].join('\n'));
|
|
108
104
|
}
|
|
109
|
-
const takeoverNeeded = isRejoin && intent.kick
|
|
105
|
+
const takeoverNeeded = isRejoin && intent.kick;
|
|
110
106
|
const oldBindings = takeoverNeeded ? await lookupParticipant(squarePath, intent.name) : [];
|
|
111
107
|
let participant;
|
|
112
108
|
if (takeoverNeeded) {
|
package/dist/square-actions.js
CHANGED
|
@@ -28,6 +28,9 @@ export async function catchUp(square, name, options = {}, project) {
|
|
|
28
28
|
throw new SquareError('invalid_args', 'Catch idle duration must be a non-negative number');
|
|
29
29
|
const deadline = Date.now() + idle;
|
|
30
30
|
while (true) {
|
|
31
|
+
if (!await assertLiveOwner(square, name)) {
|
|
32
|
+
throw new SquareError('already_joined', `${participantIdentity(name)} is already bound to another session`);
|
|
33
|
+
}
|
|
31
34
|
const attempt = await square.artifact.transact((state, version) => {
|
|
32
35
|
const decision = decideCatch(state, name, options, square.clock(), project);
|
|
33
36
|
return { ...(decision.changed ? { state } : {}), result: { version, decision } };
|