@somewhere-cloud/cli 0.38.32 → 0.38.34
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/CHANGELOG.md +14 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/runtime/DECLARED-DATA-VENDOR.json +3 -3
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/SOURCE-LINT-VENDOR.json +4 -4
- package/runtime/declared-data.cjs +42 -3
- package/runtime/source-lint.cjs +49 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.33
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Typecheck knows the typed browser specifier `somewhere:rooms` (joinRoom,
|
|
8
|
+
watchLive), so a TypeScript page can import the rooms client without TS2307
|
|
9
|
+
(tsk_5cc533ad). The absolute `/__sw/rooms/client.js` path still builds.
|
|
10
|
+
- A leftover `sw.db.live` call is reported with the rename to
|
|
11
|
+
`sw.rooms.live(name, sw.db.from(...))` instead of a bare missing-property
|
|
12
|
+
error.
|
|
13
|
+
- The vendored platform parser, types, lint, deploy-path policy and repro
|
|
14
|
+
guidance are re-synced with the platform at consumer contract 5 (tech
|
|
15
|
+
8a604872).
|
|
16
|
+
|
|
3
17
|
## 0.38.32
|
|
4
18
|
|
|
5
19
|
### Changed
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@somewhere-cloud/cli",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.34",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@somewhere-cloud/cli",
|
|
9
|
-
"version": "0.38.
|
|
9
|
+
"version": "0.38.34",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@modelcontextprotocol/sdk",
|
|
12
12
|
"chokidar",
|
package/package.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"shared/d1-session.ts": "2ae29b74bba68016c86d25fa2a58f8c2fce4aca8fe57fafc253d380c47a3c0ab",
|
|
7
7
|
"shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
|
|
8
8
|
"worker/containers/compile/checker-contract.cjs": "3a8355b9477d89d00bca47cf74032c3b3c6458941cf5c57ddae9e2228b51915d",
|
|
9
|
-
"worker/containers/compile/consumer-contract.cjs": "
|
|
9
|
+
"worker/containers/compile/consumer-contract.cjs": "e76505a4ef8155123cffb61853e23dd66d34137ec777f22457e3440b549fb405",
|
|
10
10
|
"worker/containers/compile/declared-data-contract.cjs": "47ab54cbf6fb20b77e00b2f06e0d283733ee1f3774459f2a6f82c77042c1c93a",
|
|
11
11
|
"worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
|
|
12
12
|
"worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
|
|
13
13
|
"worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
|
|
14
|
-
"worker/containers/compile/runtime-types.cjs": "
|
|
14
|
+
"worker/containers/compile/runtime-types.cjs": "451690bc1977d68139a538c270dc1ae1c28260f07249eb569c5a743db9d192cb",
|
|
15
15
|
"worker/containers/compile/schema-types.cjs": "c62cc074de5da631c44f7da33ad949e3db2d288b2d2d63b2b615c5bc549c7f4a",
|
|
16
16
|
"worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
|
|
17
17
|
"worker/containers/compile/typed-files.cjs": "a0b1818afbc7673f84583c76436a3b3ca1d1fdf63d8d8db138b36646103f0708",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"worker/src/utils/telegram-attempt-receipts.ts": "a9ba55ae71f63ada44a105f1ceae04b0491bda0d6e77e5762db2dbecdd2981dd",
|
|
58
58
|
"worker/src/utils/telegram.ts": "dfbc9e756b44b445b3c3504c90a1094a94e6f9853ff9c0e0a84fba0e8c4518da"
|
|
59
59
|
},
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "3728e85d47ff56425e147895e697e4e3fe4ab3ea4ba993f19d6583a3928fe6d9"
|
|
61
61
|
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"worker/src/runtime/inbox.ts": "ace614a3e25f21c05f19c89526d564dc678f2b6131993963ef29e1ef1a53c154",
|
|
67
67
|
"worker/src/runtime/jobs.ts": "eeb96f356cdb51dcc72517d43f1d83d461127f2537c4b970bebba70d313979aa",
|
|
68
68
|
"worker/src/runtime/live-bridge.ts": "2909c5d38625b3ea9d21a10906fe7a503644c9d69f521701fd1cfbed38ea7fd5",
|
|
69
|
-
"worker/src/runtime/live-client.ts": "
|
|
69
|
+
"worker/src/runtime/live-client.ts": "ea04138b4394af4c42ae4eab7c303752a78bf5e2d40fc6e21cda3d25bf93f2f4",
|
|
70
70
|
"worker/src/runtime/logs.ts": "0a28e0c3770bcda51a1daa4efdc6af9324568197cf0b3730ee609b376019b265",
|
|
71
71
|
"worker/src/runtime/managed-intent-wire.ts": "f983c34732c20f98a17cdd2a8087b46dd313f37e1d1ad5fb6771cc6f2a40a6a9",
|
|
72
72
|
"worker/src/runtime/notifications.ts": "52360bfd5a14d5e588ce00bc2db623da510f9e9fc57b1275d1ea85a2b6117396",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"worker/src/runtime/queue.ts": "8f0bdda9bb857125d42cfbe0a4a50561daca56cc929f17bc91e1d4ba151cc998",
|
|
80
80
|
"worker/src/runtime/rate-limit.ts": "a63481a2144a46f39228b3e22b2c18df6e4f02d3ae4fac928cd2ee708cc1d1c8",
|
|
81
81
|
"worker/src/runtime/render.ts": "cbb484f18e410d26fcc87db259e1d10a1b18308405256b6c1a26afc2985707ed",
|
|
82
|
-
"worker/src/runtime/rooms-client.ts": "
|
|
82
|
+
"worker/src/runtime/rooms-client.ts": "b057aadecdff768d16e54f079c127a894d4a1ba51edfe4298a5060ab30bb6313",
|
|
83
83
|
"worker/src/runtime/rooms.ts": "081fecc37d0dcf09ee9f25ccf6060a29ade7b273e21225d962c74b9dd004904f",
|
|
84
84
|
"worker/src/runtime/runtime-console-capture.ts": "db26d6b10dd811fe01ca43405a8a8a6209fb46befae13e2bb1354baeed824fdd",
|
|
85
85
|
"worker/src/runtime/runtime-log-lifecycle.ts": "2019cb8c7c828528c64efbd0150875acb728c552ee4f3a6dbed75c2b836f97fa",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"worker/src/runtime/storage.ts": "15c7953b994497c7883b774f79ae93bae96e16373a0826cc733d21005de22ad7",
|
|
89
89
|
"worker/src/runtime/tasks.ts": "75efa2e3083853bfba1dc49745ede8865ddd218b84d568a00da2dbd669f9ab23",
|
|
90
90
|
"worker/src/runtime/verify-signup.ts": "dcac46b4581794fe875e3f85e3d93a2253b470f60a3c7fcee68543d8be8a6fa1",
|
|
91
|
-
"worker/src/runtime/version.ts": "
|
|
91
|
+
"worker/src/runtime/version.ts": "23c41a315eabe0c9b4d099ef65729ff73d2217f0ba97f3981c5035a27f9b8474",
|
|
92
92
|
"worker/src/runtime/visitor-session.generated.ts": "f788a0c4efe22b18c313d8433150931d48a5f872e3bd98549d94138a5b0dfe5d",
|
|
93
93
|
"worker/src/runtime/web.ts": "269590d44ffa6239bb6e79999b58ba42435c230f045daea52bf73d09519afb0e",
|
|
94
94
|
"worker/src/security/browser-secret-scan.ts": "31ebc9dd94eed4d0a9a6b67b3b1e2505d4f7812c557c90337e034c1e3994c039",
|
|
@@ -161,6 +161,6 @@
|
|
|
161
161
|
"worker/src/utils/telegram.ts": "dfbc9e756b44b445b3c3504c90a1094a94e6f9853ff9c0e0a84fba0e8c4518da",
|
|
162
162
|
"worker/src/vendor/neondatabase-serverless/source.generated.ts": "96a3c18fde7d8888fdb53a4d7cd0721c238a234521d2084d1e66868a8df8e69c"
|
|
163
163
|
},
|
|
164
|
-
"sha256": "
|
|
164
|
+
"sha256": "a9942d5c202b93227f3c0579e3fdd7b930bb68af9bd56211ee5ca41ee02a8874",
|
|
165
165
|
"fixtures_sha256": "908827d1430f4af5a83cae59ed476abc51dc9648757eac0089fe6e6db95f66c5"
|
|
166
166
|
}
|
|
@@ -1277,6 +1277,8 @@ interface SomewhereServerDb {
|
|
|
1277
1277
|
aggregate<T extends SomewhereDbTable>(table: T, options: SomewhereDbAggregateOptionsFor<T>): Promise<SomewhereDbAggregateResult<SomewhereDbAggregateRow<T>>>;
|
|
1278
1278
|
}
|
|
1279
1279
|
interface SomewhereCallerDb {
|
|
1280
|
+
/** @deprecated Replaced by sw.rooms.live(name, sw.db.from(...)); deploy refuses sw.db.live. */
|
|
1281
|
+
live(name: 'sw.db.live was replaced by sw.rooms.live(name, sw.db.from(...))', read: never): never;
|
|
1280
1282
|
query(sql: string, params?: readonly unknown[] | null, options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereDbResult>;
|
|
1281
1283
|
batch(statements: readonly SomewhereRawDbStatement[], options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereRawBatchResult[]>;
|
|
1282
1284
|
aggregate<T extends SomewhereDbTable>(table: T, options: SomewhereDbAggregateOptionsFor<T> & { asServer?: true }): Promise<SomewhereDbAggregateResult<SomewhereDbAggregateRow<T>>>;
|
|
@@ -3476,6 +3478,42 @@ declare module 'somewhere:push' {
|
|
|
3476
3478
|
export function listenToPush(handler: (message: PushMessage) => void): () => void;
|
|
3477
3479
|
}
|
|
3478
3480
|
|
|
3481
|
+
// The rooms browser module (/__sw/rooms/client.js), typed under this
|
|
3482
|
+
// specifier. Plain browser scripts import the absolute path directly.
|
|
3483
|
+
declare module 'somewhere:rooms' {
|
|
3484
|
+
export interface RoomPerson { id: string; user: string | null; me: boolean; info: Record<string, unknown> | null }
|
|
3485
|
+
export type RoomStatus = 'connecting' | 'open' | 'reconnecting' | 'closed';
|
|
3486
|
+
export interface Room {
|
|
3487
|
+
readonly table: string;
|
|
3488
|
+
readonly id: string | number;
|
|
3489
|
+
readonly state: Record<string, unknown>;
|
|
3490
|
+
readonly version: number;
|
|
3491
|
+
readonly people: RoomPerson[];
|
|
3492
|
+
readonly status: RoomStatus;
|
|
3493
|
+
readonly me: { readonly info: Record<string, unknown> | null; set(info: Record<string, unknown>): void };
|
|
3494
|
+
on(event: 'state', handler: (state: Record<string, unknown>, change: { by: string; pending?: boolean } | null) => void): () => void;
|
|
3495
|
+
on(event: 'people', handler: (people: RoomPerson[]) => void): () => void;
|
|
3496
|
+
on(event: 'message', handler: (data: unknown, from: string) => void): () => void;
|
|
3497
|
+
on(event: 'status', handler: (status: RoomStatus) => void): () => void;
|
|
3498
|
+
on(event: 'timer_failed', handler: () => void): () => void;
|
|
3499
|
+
// Rooms without a referee: merge top-level keys (null deletes one).
|
|
3500
|
+
set(patch: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
3501
|
+
// Rooms with a referee: resolves with the state after the referee accepts.
|
|
3502
|
+
act(action: unknown): Promise<Record<string, unknown>>;
|
|
3503
|
+
// A throwaway message to everyone else; false when not connected.
|
|
3504
|
+
send(data: unknown): boolean;
|
|
3505
|
+
leave(): void;
|
|
3506
|
+
}
|
|
3507
|
+
export function joinRoom(table: string, id: string | number): Promise<Room>;
|
|
3508
|
+
// A live list declared with sw.rooms.live: load re-calls your function,
|
|
3509
|
+
// render gets its data array and the whole result. Returns stop().
|
|
3510
|
+
export function watchLive<Row = Record<string, unknown>>(
|
|
3511
|
+
load: () => Promise<{ data: Row[]; live?: unknown }> | { data: Row[]; live?: unknown },
|
|
3512
|
+
render: (rows: Row[], result: { data: Row[]; live?: unknown }) => void,
|
|
3513
|
+
onError?: (error: Error & { code?: string }, info: { attempt: number; retrying: boolean }) => void,
|
|
3514
|
+
): () => void;
|
|
3515
|
+
}
|
|
3516
|
+
|
|
3479
3517
|
// \u2500\u2500 sw.queue / sw.jobs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
3480
3518
|
interface SomewhereQueuePushOptions {
|
|
3481
3519
|
// A project-relative /api path or an https:// URL.
|
|
@@ -4407,8 +4445,8 @@ var require_consumer_contract = __commonJS({
|
|
|
4407
4445
|
"worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
|
|
4408
4446
|
"use strict";
|
|
4409
4447
|
var CONSUMER_CONTRACT2 = Object.freeze({
|
|
4410
|
-
version:
|
|
4411
|
-
digest: "
|
|
4448
|
+
version: 6,
|
|
4449
|
+
digest: "8318cd690fc6072c5429b9c64791ead8c4af99058b37b7e83d038dda97308832"
|
|
4412
4450
|
});
|
|
4413
4451
|
var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
|
|
4414
4452
|
var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
|
|
@@ -4448,7 +4486,7 @@ export default schema({
|
|
|
4448
4486
|
["refused: a column named mine", one("owner", "notes: table({ id: id(), mine: text() }, { scope: owner(), client: { read: true } }),")]
|
|
4449
4487
|
]);
|
|
4450
4488
|
var DERIVED = ["generateFromFiles", "localDeclarationFromFiles", "declaredTablesFromFiles", "runtimeDeclarationFromFiles", "filesDeclarationFromFiles"];
|
|
4451
|
-
function consumerContractComponents2(data, sourceLintVersion, hash) {
|
|
4489
|
+
function consumerContractComponents2(data, sourceLintVersion, hash, sourceLintImplementation) {
|
|
4452
4490
|
const forms = {};
|
|
4453
4491
|
for (const [name, source] of CONSUMER_CONTRACT_FORMS) {
|
|
4454
4492
|
const files = { "db/schema.ts": source };
|
|
@@ -4466,6 +4504,7 @@ export default schema({
|
|
|
4466
4504
|
endpoint_declaration: hash(String(data.ENDPOINT_DECLARATION)),
|
|
4467
4505
|
files_declaration: hash(String(data.FILES_DECLARATION_FILE)),
|
|
4468
4506
|
source_lint_version: String(sourceLintVersion),
|
|
4507
|
+
source_lint_implementation: hash(sourceLintImplementation),
|
|
4469
4508
|
forms
|
|
4470
4509
|
};
|
|
4471
4510
|
}
|
package/runtime/source-lint.cjs
CHANGED
|
@@ -17690,6 +17690,9 @@ const LIVE_PING_MS = 25000;
|
|
|
17690
17690
|
const LIVE_PONG_TIMEOUT_MS = 10000;
|
|
17691
17691
|
const LIVE_SAFETY_REFRESH_MS = 60000;
|
|
17692
17692
|
const LIVE_RETRY_LIMIT = 6;
|
|
17693
|
+
// Refusals that another attempt cannot change: report once, do not retry.
|
|
17694
|
+
// The next reconnect, focus or safety refresh still asks again.
|
|
17695
|
+
const LIVE_FINAL = { LIVE_ROLE_REQUIRED: 1, LIVE_MEMBERSHIP_REQUIRED: 1, LIVE_SCOPE_NOT_SUBSCRIBABLE: 1, LIVE_VIEW_NOT_DECLARED: 1, LIVE_VIEW_POLICY_SCOPE_UNSUPPORTED: 1, LIVE_NOT_DECLARED: 1, ROOMS_DRAFT_UNAVAILABLE: 1 };
|
|
17693
17696
|
|
|
17694
17697
|
function liveError(code, message, cause) {
|
|
17695
17698
|
const err = new Error(message);
|
|
@@ -17715,6 +17718,12 @@ export function watchLive(load, render, onError) {
|
|
|
17715
17718
|
let pongTimer = null;
|
|
17716
17719
|
let reconnectTimer = null;
|
|
17717
17720
|
let drops = 0;
|
|
17721
|
+
// Set by an account_full control (tsk_d1da4622): terminal until the page is deliberately shown again or comes
|
|
17722
|
+
// back online; the automatic safety refresh does not re-ask, so a full account never causes a reconnect storm.
|
|
17723
|
+
let accountFull = null;
|
|
17724
|
+
// Set by an admission_unavailable control: a temporary refusal. The reconnect backs off (never at once) and the
|
|
17725
|
+
// back-off is kept across refused handshakes; only a healthy admission (the socket's first resync) resets it.
|
|
17726
|
+
let refused = null;
|
|
17718
17727
|
|
|
17719
17728
|
function report(err) {
|
|
17720
17729
|
const retrying = failures <= LIVE_RETRY_LIMIT;
|
|
@@ -17733,7 +17742,7 @@ export function watchLive(load, render, onError) {
|
|
|
17733
17742
|
}
|
|
17734
17743
|
|
|
17735
17744
|
function fail(err, reconnect) {
|
|
17736
|
-
failures
|
|
17745
|
+
failures = err && LIVE_FINAL[err.code] ? LIVE_RETRY_LIMIT + 1 : failures + 1;
|
|
17737
17746
|
report(err);
|
|
17738
17747
|
scheduleRetry(reconnect);
|
|
17739
17748
|
}
|
|
@@ -17756,20 +17765,29 @@ export function watchLive(load, render, onError) {
|
|
|
17756
17765
|
ws.onmessage = function (message) {
|
|
17757
17766
|
if (stopped || generation !== socketGeneration) return;
|
|
17758
17767
|
if (pongTimer !== null) { clearTimeout(pongTimer); pongTimer = null; }
|
|
17759
|
-
drops = 0;
|
|
17760
17768
|
let frame = null;
|
|
17761
17769
|
try { frame = JSON.parse(message.data); } catch (_) { return; }
|
|
17762
17770
|
if (!frame || frame.type !== 'live_control') return;
|
|
17763
17771
|
// resync_required: rows changed, or this socket just went live.
|
|
17764
17772
|
// release_changed / access_revoked / reauthorize_required: the socket
|
|
17765
17773
|
// closes next; the close handler reconnects through a fresh load.
|
|
17766
|
-
|
|
17774
|
+
// Only an admitted socket is sent resync_required, so it is the healthy-admission signal that resets back-off.
|
|
17775
|
+
if (frame.event === 'resync_required') { drops = 0; refused = null; refresh(false); }
|
|
17776
|
+
if (frame.event === 'admission_unavailable') refused = { code: frame.code || 'ROOM_ADMISSION_UNAVAILABLE', message: frame.message || 'Live list admission is temporarily unavailable.' };
|
|
17777
|
+
if (frame.event === 'account_full') {
|
|
17778
|
+
accountFull = { code: frame.code || 'ROOM_ACCOUNT_FULL', message: frame.message || 'This app has reached its limit of people connected at once.' };
|
|
17779
|
+
// Terminal: cancel pending retries and reconnects; an in-flight load will not reconnect either (see refresh).
|
|
17780
|
+
if (retryTimer !== null) { clearTimeout(retryTimer); retryTimer = null; }
|
|
17781
|
+
if (reconnectTimer !== null) { clearTimeout(reconnectTimer); reconnectTimer = null; }
|
|
17782
|
+
}
|
|
17767
17783
|
};
|
|
17768
17784
|
ws.onopen = function () {
|
|
17769
17785
|
if (stopped || generation !== socketGeneration) return;
|
|
17770
17786
|
pingTimer = setInterval(function () {
|
|
17771
17787
|
if (stopped || generation !== socketGeneration) return;
|
|
17772
|
-
|
|
17788
|
+
// A socket that is no longer open is dead even if its close event is late.
|
|
17789
|
+
if (ws.readyState !== 1) { onClose(); return; }
|
|
17790
|
+
try { ws.send(LIVE_PING_FRAME); } catch (_) { onClose(); return; }
|
|
17773
17791
|
if (pongTimer === null) pongTimer = setTimeout(function () {
|
|
17774
17792
|
pongTimer = null;
|
|
17775
17793
|
if (generation === socketGeneration) { try { ws.close(4000, 'no_pong'); } catch (_) {} onClose(); }
|
|
@@ -17780,6 +17798,13 @@ export function watchLive(load, render, onError) {
|
|
|
17780
17798
|
if (closed || stopped || generation !== socketGeneration) return;
|
|
17781
17799
|
closed = true;
|
|
17782
17800
|
stopPing();
|
|
17801
|
+
if (accountFull) {
|
|
17802
|
+
socket = null;
|
|
17803
|
+
liveKey = null;
|
|
17804
|
+
failures = LIVE_RETRY_LIMIT + 1;
|
|
17805
|
+
report(liveError(accountFull.code, accountFull.message));
|
|
17806
|
+
return;
|
|
17807
|
+
}
|
|
17783
17808
|
// An error may leave the socket half-open; close it explicitly so no stale
|
|
17784
17809
|
// connection lingers behind the replacement.
|
|
17785
17810
|
try { ws.close(1000, 'replaced'); } catch (_) {}
|
|
@@ -17789,9 +17814,13 @@ export function watchLive(load, render, onError) {
|
|
|
17789
17814
|
// anything that changed while the socket was down. The first drop
|
|
17790
17815
|
// reconnects at once; repeated drops back off and are reported.
|
|
17791
17816
|
drops += 1;
|
|
17792
|
-
|
|
17817
|
+
const wasRefused = refused;
|
|
17818
|
+
refused = null;
|
|
17819
|
+
if (wasRefused) report(liveError(wasRefused.code, wasRefused.message));
|
|
17820
|
+
else if (drops > 3) report(liveError('LIVE_DISCONNECTED', 'The live connection keeps closing; reconnecting.'));
|
|
17793
17821
|
if (reconnectTimer !== null) return;
|
|
17794
|
-
|
|
17822
|
+
// A temporary admission refusal never reconnects at once; the back-off grows across refused handshakes.
|
|
17823
|
+
const delay = wasRefused ? Math.min(1000 * Math.pow(2, drops - 1), 30000) : drops === 1 ? 0 : Math.min(500 * Math.pow(2, drops - 2), 15000);
|
|
17795
17824
|
reconnectTimer = setTimeout(function () { reconnectTimer = null; refresh(true); }, delay);
|
|
17796
17825
|
}
|
|
17797
17826
|
ws.onclose = onClose;
|
|
@@ -17820,6 +17849,8 @@ export function watchLive(load, render, onError) {
|
|
|
17820
17849
|
: 'load() must return the JSON of a function that returns sw.rooms.live(name, read).');
|
|
17821
17850
|
}
|
|
17822
17851
|
failures = 0;
|
|
17852
|
+
// A full account is terminal until a deliberate retry: a load already in flight renders but never reconnects.
|
|
17853
|
+
if (accountFull) return;
|
|
17823
17854
|
const nextKey = String(live.release_id) + ':' + String(live.fingerprint);
|
|
17824
17855
|
if (reconnect || !socket || nextKey !== liveKey) connect(live);
|
|
17825
17856
|
}).catch(function (err) {
|
|
@@ -17842,10 +17873,11 @@ export function watchLive(load, render, onError) {
|
|
|
17842
17873
|
failures = Math.min(failures, LIVE_RETRY_LIMIT);
|
|
17843
17874
|
refresh(!socket && reconnectTimer === null);
|
|
17844
17875
|
}
|
|
17845
|
-
function
|
|
17876
|
+
function deliberateRepair() { accountFull = null; repair(); }
|
|
17877
|
+
function onVisibility() { if (document.visibilityState === 'visible') deliberateRepair(); }
|
|
17846
17878
|
document.addEventListener('visibilitychange', onVisibility);
|
|
17847
|
-
if (typeof window !== 'undefined') window.addEventListener('online',
|
|
17848
|
-
const safety = setInterval(function () { if (document.visibilityState !== 'hidden') repair(); }, LIVE_SAFETY_REFRESH_MS);
|
|
17879
|
+
if (typeof window !== 'undefined') window.addEventListener('online', deliberateRepair);
|
|
17880
|
+
const safety = setInterval(function () { if (document.visibilityState !== 'hidden' && !accountFull) repair(); }, LIVE_SAFETY_REFRESH_MS);
|
|
17849
17881
|
refresh(true);
|
|
17850
17882
|
|
|
17851
17883
|
return function stop() {
|
|
@@ -17856,7 +17888,7 @@ export function watchLive(load, render, onError) {
|
|
|
17856
17888
|
if (reconnectTimer !== null) clearTimeout(reconnectTimer);
|
|
17857
17889
|
clearInterval(safety);
|
|
17858
17890
|
document.removeEventListener('visibilitychange', onVisibility);
|
|
17859
|
-
if (typeof window !== 'undefined') window.removeEventListener('online',
|
|
17891
|
+
if (typeof window !== 'undefined') window.removeEventListener('online', deliberateRepair);
|
|
17860
17892
|
if (socket) { try { socket.close(1000, 'stopped'); } catch (_) {} }
|
|
17861
17893
|
};
|
|
17862
17894
|
}
|
|
@@ -17870,7 +17902,12 @@ const RENEW_MS = 240000;
|
|
|
17870
17902
|
const PING_MS = 30000;
|
|
17871
17903
|
const PING_FRAME = '{"t":"ping"}';
|
|
17872
17904
|
const PONG_FRAME = '{"t":"pong"}';
|
|
17873
|
-
const FINAL_BYE = { row_deleted: 'ROOM_ROW_DELETED', full: 'ROOM_FULL' };
|
|
17905
|
+
const FINAL_BYE = { row_deleted: 'ROOM_ROW_DELETED', full: 'ROOM_FULL', account_full: 'ROOM_ACCOUNT_FULL' };
|
|
17906
|
+
const FINAL_MESSAGE = {
|
|
17907
|
+
ROOM_FULL: 'This room is full.',
|
|
17908
|
+
ROOM_ROW_DELETED: 'This room\\'s row was deleted.',
|
|
17909
|
+
ROOM_ACCOUNT_FULL: 'This app has reached its limit of people connected at once across all its rooms. Try again later.',
|
|
17910
|
+
};
|
|
17874
17911
|
|
|
17875
17912
|
function roomError(code, message, extra) {
|
|
17876
17913
|
const err = new Error(message);
|
|
@@ -18189,7 +18226,7 @@ class Room {
|
|
|
18189
18226
|
if (this._stopped) return;
|
|
18190
18227
|
const finalCode = this._bye && FINAL_BYE[this._bye];
|
|
18191
18228
|
if (finalCode) {
|
|
18192
|
-
return this._finish(roomError(finalCode, finalCode
|
|
18229
|
+
return this._finish(roomError(finalCode, FINAL_MESSAGE[finalCode]));
|
|
18193
18230
|
}
|
|
18194
18231
|
this._setStatus('reconnecting', { code: this._bye || 'dropped' });
|
|
18195
18232
|
// expired / app_updated rejoin at once with a fresh ticket; a drop backs off.
|