@parlor/sync 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/channel.d.ts +21 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +2 -0
- package/dist/channel.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/sse.d.ts +10 -0
- package/dist/client/sse.d.ts.map +1 -0
- package/dist/client/sse.js +48 -0
- package/dist/client/sse.js.map +1 -0
- package/dist/client/sync-client.d.ts +84 -0
- package/dist/client/sync-client.d.ts.map +1 -0
- package/dist/client/sync-client.js +459 -0
- package/dist/client/sync-client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +39 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +30 -0
- package/dist/protocol.js.map +1 -0
- package/dist/server/hub.d.ts +15 -0
- package/dist/server/hub.d.ts.map +1 -0
- package/dist/server/hub.js +75 -0
- package/dist/server/hub.js.map +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/pruner.d.ts +11 -0
- package/dist/server/pruner.d.ts.map +1 -0
- package/dist/server/pruner.js +23 -0
- package/dist/server/pruner.js.map +1 -0
- package/dist/server/routes.d.ts +36 -0
- package/dist/server/routes.d.ts.map +1 -0
- package/dist/server/routes.js +127 -0
- package/dist/server/routes.js.map +1 -0
- package/dist/server/store.d.ts +42 -0
- package/dist/server/store.d.ts.map +1 -0
- package/dist/server/store.js +155 -0
- package/dist/server/store.js.map +1 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cychien
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @parlor/sync
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The live-update protocol: the cursor and event types the server and the page exchange so queries refresh when data changes. Installed by `@parlor/server` and `@parlor/client`; you do not depend on it directly.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { INITIAL_CURSOR, SYNC_PROTOCOL_VERSION } from "@parlor/sync";
|
|
7
|
+
|
|
8
|
+
console.log(SYNC_PROTOCOL_VERSION, INITIAL_CURSOR);
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Docs: https://cychien.github.io/parlor/guides/deploy/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Principal } from "@parlor/core";
|
|
2
|
+
export interface ServerChannel {
|
|
3
|
+
readonly event: string;
|
|
4
|
+
connect(connection: ChannelConnection): () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface ChannelConnection {
|
|
7
|
+
readonly clientId: string | undefined;
|
|
8
|
+
readonly scope: string;
|
|
9
|
+
/** Who holds the stream; absent when the server resolves no identity. */
|
|
10
|
+
readonly principal?: Principal | undefined;
|
|
11
|
+
/** Aborts when the stream ends, including when its holder's credential is revoked. */
|
|
12
|
+
readonly closed?: AbortSignal | undefined;
|
|
13
|
+
send(data: string): void;
|
|
14
|
+
}
|
|
15
|
+
export interface ClientChannel {
|
|
16
|
+
readonly event: string;
|
|
17
|
+
opened(): void;
|
|
18
|
+
receive(data: string): void;
|
|
19
|
+
closed(): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC3C,sFAAsF;IACtF,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,IAAI,IAAI,CAAC;CAChB"}
|
package/dist/channel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"","sourcesContent":["import type { Principal } from \"@parlor/core\";\n\nexport interface ServerChannel {\n readonly event: string;\n connect(connection: ChannelConnection): () => void;\n}\n\nexport interface ChannelConnection {\n readonly clientId: string | undefined;\n readonly scope: string;\n /** Who holds the stream; absent when the server resolves no identity. */\n readonly principal?: Principal | undefined;\n /** Aborts when the stream ends, including when its holder's credential is revoked. */\n readonly closed?: AbortSignal | undefined;\n send(data: string): void;\n}\n\nexport interface ClientChannel {\n readonly event: string;\n opened(): void;\n receive(data: string): void;\n closed(): void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAiB,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,gBAAgB,EAIhB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC","sourcesContent":["export { parseSseChunk, readSse, type SseFrame } from \"./sse.js\";\nexport {\n createSyncClient,\n type SyncClient,\n type SyncClientOptions,\n type SyncRequest,\n SyncRequestTimeout,\n SyncUnauthorized,\n} from \"./sync-client.js\";\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SseFrame {
|
|
2
|
+
readonly event: string;
|
|
3
|
+
readonly data: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function parseSseChunk(buffer: string): {
|
|
6
|
+
frames: SseFrame[];
|
|
7
|
+
rest: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function readSse(body: ReadableStream<Uint8Array>, onFrame: (frame: SseFrame) => void, signal?: AbortSignal, onChunk?: () => void): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAkBlF;AAED,wBAAsB,OAAO,CAC3B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EAClC,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function parseSseChunk(buffer) {
|
|
2
|
+
const frames = [];
|
|
3
|
+
let rest = buffer;
|
|
4
|
+
for (;;) {
|
|
5
|
+
const end = rest.indexOf("\n\n");
|
|
6
|
+
if (end === -1)
|
|
7
|
+
break;
|
|
8
|
+
const block = rest.slice(0, end);
|
|
9
|
+
rest = rest.slice(end + 2);
|
|
10
|
+
let event = "message";
|
|
11
|
+
const data = [];
|
|
12
|
+
for (const line of block.split("\n")) {
|
|
13
|
+
if (line.startsWith(":"))
|
|
14
|
+
continue;
|
|
15
|
+
if (line.startsWith("event:"))
|
|
16
|
+
event = line.slice(6).trim();
|
|
17
|
+
else if (line.startsWith("data:"))
|
|
18
|
+
data.push(line.slice(5).trimStart());
|
|
19
|
+
}
|
|
20
|
+
if (data.length > 0)
|
|
21
|
+
frames.push({ event, data: data.join("\n") });
|
|
22
|
+
}
|
|
23
|
+
return { frames, rest };
|
|
24
|
+
}
|
|
25
|
+
export async function readSse(body, onFrame, signal, onChunk) {
|
|
26
|
+
const reader = body.getReader();
|
|
27
|
+
const decoder = new TextDecoder();
|
|
28
|
+
let buffer = "";
|
|
29
|
+
const abort = () => void reader.cancel().catch(() => { });
|
|
30
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
31
|
+
try {
|
|
32
|
+
for (;;) {
|
|
33
|
+
const { value, done } = await reader.read();
|
|
34
|
+
if (done)
|
|
35
|
+
break;
|
|
36
|
+
onChunk?.();
|
|
37
|
+
buffer += decoder.decode(value, { stream: true });
|
|
38
|
+
const { frames, rest } = parseSseChunk(buffer);
|
|
39
|
+
buffer = rest;
|
|
40
|
+
for (const frame of frames)
|
|
41
|
+
onFrame(frame);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
signal?.removeEventListener("abort", abort);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,MAAM,GAAe,EA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,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,OAAO,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;YAC/C,MAAM,GAAG,IAAI,CAAC;YACd,KAAK,MAAM,KAAK,IAAI,MAAM;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC","sourcesContent":["export interface SseFrame {\n readonly event: string;\n readonly data: string;\n}\n\nexport function parseSseChunk(buffer: string): { frames: SseFrame[]; rest: string } {\n const frames: SseFrame[] = [];\n let rest = buffer;\n for (;;) {\n const end = rest.indexOf(\"\\n\\n\");\n if (end === -1) break;\n const block = rest.slice(0, end);\n rest = rest.slice(end + 2);\n let event = \"message\";\n const data: string[] = [];\n for (const line of block.split(\"\\n\")) {\n if (line.startsWith(\":\")) continue;\n if (line.startsWith(\"event:\")) event = line.slice(6).trim();\n else if (line.startsWith(\"data:\")) data.push(line.slice(5).trimStart());\n }\n if (data.length > 0) frames.push({ event, data: data.join(\"\\n\") });\n }\n return { frames, rest };\n}\n\nexport async function readSse(\n body: ReadableStream<Uint8Array>,\n onFrame: (frame: SseFrame) => void,\n signal?: AbortSignal,\n onChunk?: () => void,\n): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n const abort = () => void reader.cancel().catch(() => {});\n signal?.addEventListener(\"abort\", abort, { once: true });\n try {\n for (;;) {\n const { value, done } = await reader.read();\n if (done) break;\n onChunk?.();\n buffer += decoder.decode(value, { stream: true });\n const { frames, rest } = parseSseChunk(buffer);\n buffer = rest;\n for (const frame of frames) onFrame(frame);\n }\n } finally {\n signal?.removeEventListener(\"abort\", abort);\n }\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ClientChannel } from "../channel.js";
|
|
2
|
+
import { type SyncEvent } from "../protocol.js";
|
|
3
|
+
export type SyncRequest = (path: string, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export interface SyncClientOptions {
|
|
5
|
+
readonly request: SyncRequest;
|
|
6
|
+
readonly basePath?: string | undefined;
|
|
7
|
+
readonly clientId?: string | undefined;
|
|
8
|
+
readonly onEvents: (events: SyncEvent[]) => void;
|
|
9
|
+
readonly onError?: ((error: unknown) => void) | undefined;
|
|
10
|
+
readonly coalesceMs?: number | undefined;
|
|
11
|
+
readonly safetyPollMs?: number | undefined;
|
|
12
|
+
readonly hiddenPollMs?: number | undefined;
|
|
13
|
+
readonly reconnectBaseMs?: number | undefined;
|
|
14
|
+
readonly reconnectMaxMs?: number | undefined;
|
|
15
|
+
readonly isHidden?: (() => boolean) | undefined;
|
|
16
|
+
readonly setTimeout?: typeof globalThis.setTimeout | undefined;
|
|
17
|
+
readonly clearTimeout?: typeof globalThis.clearTimeout | undefined;
|
|
18
|
+
readonly channels?: readonly ClientChannel[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Read each time the next poll is scheduled; the interval is the larger of this and the
|
|
21
|
+
* negotiated one, so a caller can only slow polling down.
|
|
22
|
+
*/
|
|
23
|
+
readonly pollEveryMs?: (() => number) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Where to read from while the client has no cursor of its own: the encoded cursor of the
|
|
26
|
+
* oldest data the page holds, so the first stream does not replay what that data already
|
|
27
|
+
* shows. Defaults to the start of the retained log.
|
|
28
|
+
*/
|
|
29
|
+
readonly startAt?: (() => string) | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The server could not replay every event since the client's cursor: the client fell
|
|
32
|
+
* more than one batch behind, or behind what the server keeps. Sync continues from
|
|
33
|
+
* `cursor`, where the client's streams stand now; reread whatever predates it. Without
|
|
34
|
+
* it, the client is never reset and a poll pages through the backlog.
|
|
35
|
+
*/
|
|
36
|
+
readonly onReset?: ((cursor: string) => void) | undefined;
|
|
37
|
+
/** Bounds a negotiation or a poll, not the SSE stream. Defaults to 10 s. */
|
|
38
|
+
readonly requestTimeoutMs?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* What the server negotiated, each time it does; `SyncClient.transport` reads `poll`
|
|
41
|
+
* during the fallback poll of a failed negotiation, this never does.
|
|
42
|
+
*/
|
|
43
|
+
readonly onNegotiated?: ((transport: "sse" | "poll") => void) | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The negotiated transport's connection came back after a failure: a stream reopened
|
|
46
|
+
* after it dropped, or a poll succeeded after a failed one. A fallback poll on an SSE
|
|
47
|
+
* deployment does not count.
|
|
48
|
+
*/
|
|
49
|
+
readonly onResume?: (() => void) | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The server refused the credential (401 or 403). The client never degrades to polling
|
|
52
|
+
* on it; it keeps retrying the negotiation with backoff, unless this calls `stop`.
|
|
53
|
+
* Defaults to `onError`.
|
|
54
|
+
*/
|
|
55
|
+
readonly onUnauthorized?: ((error: SyncUnauthorized) => void) | undefined;
|
|
56
|
+
}
|
|
57
|
+
export declare class SyncUnauthorized extends Error {
|
|
58
|
+
readonly status: number;
|
|
59
|
+
readonly name = "SyncUnauthorized";
|
|
60
|
+
constructor(status: number);
|
|
61
|
+
}
|
|
62
|
+
export declare class SyncRequestTimeout extends Error {
|
|
63
|
+
readonly ms: number;
|
|
64
|
+
readonly name = "SyncRequestTimeout";
|
|
65
|
+
constructor(ms: number);
|
|
66
|
+
}
|
|
67
|
+
export interface SyncClient {
|
|
68
|
+
start(): void;
|
|
69
|
+
stop(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Registers a channel after `start`, for features loaded lazily. It opens at once when
|
|
72
|
+
* the live stream's handshake lists it, else on the next stream. Returns the detach.
|
|
73
|
+
*/
|
|
74
|
+
addChannel(channel: ClientChannel): () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Skips the remaining reconnect backoff, for `online` and visibility events. While
|
|
77
|
+
* polling it polls at once; with a stream open or a request in flight it does nothing.
|
|
78
|
+
*/
|
|
79
|
+
reconnectNow(): void;
|
|
80
|
+
readonly cursor: string;
|
|
81
|
+
readonly transport: "sse" | "poll" | undefined;
|
|
82
|
+
}
|
|
83
|
+
export declare function createSyncClient(options: SyncClientOptions): SyncClient;
|
|
84
|
+
//# sourceMappingURL=sync-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-client.d.ts","sourceRoot":"","sources":["../../src/client/sync-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EASL,KAAK,SAAS,EAGf,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAElF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EA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