@graview/ship 0.1.0 → 0.1.2

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.
Files changed (73) hide show
  1. package/README.md +54 -6
  2. package/dist/browser-adapter.d.ts +9 -9
  3. package/dist/browser-adapter.d.ts.map +1 -1
  4. package/dist/browser-adapter.js +6 -3
  5. package/dist/browser-adapter.js.map +1 -1
  6. package/dist/browser.d.ts +10 -6
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.js +4 -2
  9. package/dist/browser.js.map +1 -1
  10. package/dist/cli.d.ts +17 -7
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +41 -7
  13. package/dist/cli.js.map +1 -1
  14. package/dist/export.d.ts +27 -2
  15. package/dist/export.d.ts.map +1 -1
  16. package/dist/export.js +38 -5
  17. package/dist/export.js.map +1 -1
  18. package/dist/file-adapter.d.ts +8 -8
  19. package/dist/file-adapter.d.ts.map +1 -1
  20. package/dist/file-adapter.js +58 -8
  21. package/dist/file-adapter.js.map +1 -1
  22. package/dist/handler.d.ts +162 -0
  23. package/dist/handler.d.ts.map +1 -0
  24. package/dist/handler.js +585 -0
  25. package/dist/handler.js.map +1 -0
  26. package/dist/health.d.ts +9 -0
  27. package/dist/health.d.ts.map +1 -1
  28. package/dist/health.js +5 -1
  29. package/dist/health.js.map +1 -1
  30. package/dist/index.d.ts +12 -7
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/live.d.ts +150 -0
  35. package/dist/live.d.ts.map +1 -0
  36. package/dist/live.js +44 -0
  37. package/dist/live.js.map +1 -0
  38. package/dist/meta.d.ts +13 -0
  39. package/dist/meta.d.ts.map +1 -0
  40. package/dist/meta.js +2 -0
  41. package/dist/meta.js.map +1 -0
  42. package/dist/open-store.d.ts +56 -7
  43. package/dist/open-store.d.ts.map +1 -1
  44. package/dist/open-store.js +141 -12
  45. package/dist/open-store.js.map +1 -1
  46. package/dist/remote.d.ts +93 -12
  47. package/dist/remote.d.ts.map +1 -1
  48. package/dist/remote.js +446 -76
  49. package/dist/remote.js.map +1 -1
  50. package/dist/runtime.d.ts +32 -0
  51. package/dist/runtime.d.ts.map +1 -0
  52. package/dist/runtime.js +21 -0
  53. package/dist/runtime.js.map +1 -0
  54. package/dist/seat-headers.d.ts +20 -0
  55. package/dist/seat-headers.d.ts.map +1 -0
  56. package/dist/seat-headers.js +20 -0
  57. package/dist/seat-headers.js.map +1 -0
  58. package/dist/serve.d.ts +15 -107
  59. package/dist/serve.d.ts.map +1 -1
  60. package/dist/serve.js +82 -217
  61. package/dist/serve.js.map +1 -1
  62. package/dist/source-edit.d.ts.map +1 -1
  63. package/dist/source-edit.js +6 -1
  64. package/dist/source-edit.js.map +1 -1
  65. package/dist/steps.d.ts +43 -0
  66. package/dist/steps.d.ts.map +1 -1
  67. package/dist/steps.js +69 -0
  68. package/dist/steps.js.map +1 -1
  69. package/dist/websocket.d.ts +14 -0
  70. package/dist/websocket.d.ts.map +1 -0
  71. package/dist/websocket.js +155 -0
  72. package/dist/websocket.js.map +1 -0
  73. package/package.json +6 -2
@@ -1,4 +1,5 @@
1
- import { Store, } from "@graview/core";
1
+ import { assertReadable, formatStamp, OperationLog, snapshotHash, Store, } from "@graview/core";
2
+ import { rememberArchive } from "./export.js";
2
3
  import { migrateSnapshot } from "./migrations.js";
3
4
  export async function openStore(options) {
4
5
  const { app, adapter } = options;
@@ -7,8 +8,23 @@ export async function openStore(options) {
7
8
  await adapter.delete(scope);
8
9
  const stored = (await adapter.load(scope));
9
10
  const persisted = (await adapter.loadLog?.(scope)) ?? [];
10
- let seq = persisted.length;
11
+ const epochs = (await adapter.loadEpochs?.(scope)) ?? [];
12
+ /*
13
+ * A COMPACTED LOG BEGINS AT ITS HORIZON (FR-23): the adapter hands over
14
+ * the checkpoint and the ops from its seq on, and nothing older is read.
15
+ */
16
+ const checkpoint = [...epochs].reverse().find((epoch) => epoch.horizon);
17
+ const horizon = checkpoint?.seq ?? 0;
18
+ let seq = horizon + persisted.length;
11
19
  const meta = adapter.loadMeta?.(scope) ?? null;
20
+ /*
21
+ * A SNAPSHOT IN A NEWER FORMAT IS NOT FOLDED (FR-31). A rolled-back
22
+ * framework meeting what its successor wrote says so — the host refolds
23
+ * from the log or rolls forward — rather than reading a shape it does not
24
+ * know and writing its misreading back.
25
+ */
26
+ if (stored !== null)
27
+ assertReadable(meta);
12
28
  const target = app.version ?? 1;
13
29
  /*
14
30
  * THE LOG OUTRANKS THE META. A crash between writing the migrated
@@ -23,7 +39,8 @@ export async function openStore(options) {
23
39
  .reduce((highest, version) => Math.max(highest, version), 0);
24
40
  const storedVersion = stored === null
25
41
  ? target
26
- : Math.max(meta?.version ?? options.assumeVersion ?? target, migratedTo);
42
+ : // A migration run behind the horizon is archived; the checkpoint still says the version it stood at.
43
+ Math.max(meta?.version ?? options.assumeVersion ?? target, migratedTo, checkpoint?.version ?? 0);
27
44
  let snapshot = stored ?? options.seed ?? { nodes: [], edges: [] };
28
45
  let migrated = [];
29
46
  if (storedVersion < target) {
@@ -32,6 +49,40 @@ export async function openStore(options) {
32
49
  migrated = run.ops.map((op) => ({ ...op, seq: seq++ }));
33
50
  await adapter.appendOps?.(scope, migrated);
34
51
  }
52
+ /*
53
+ * EACH DECLARATION VERSION BEGINS AN EPOCH (FR-27): a base graph and the
54
+ * seq the log folds onto it from. A new scope begins one at its seed,
55
+ * which was never an operation. A migration run begins one at the graph
56
+ * it left, naming the change, so the log verifies from there and undo
57
+ * does not reach back across it. A store from before epochs begins one
58
+ * at what it holds — from empty, when its whole log folds to it, since
59
+ * then the whole history is proof — and is verifiable from then on.
60
+ * Recorded straight after the migration's ops, before the snapshot: a
61
+ * crash between the two leaves a stale snapshot that verifying finds.
62
+ */
63
+ const at = new Date().toISOString();
64
+ let epoch;
65
+ if (migrated.length > 0) {
66
+ epoch = { seq, base: snapshot, version: target, change: migrated.map((op) => op.intent).join("; "), at };
67
+ }
68
+ else if (stored === null) {
69
+ epoch = { seq, base: snapshot, version: target, at };
70
+ }
71
+ else if (epochs.length === 0 && adapter.saveEpochs) {
72
+ /*
73
+ * Adopted once, where it can be kept: folding the whole log and hashing
74
+ * it is the cost of proving a store from before epochs, and an adapter
75
+ * that cannot keep the result would pay it on every open — a page with
76
+ * two thousand talks did, and the gauntlet took five times as long.
77
+ */
78
+ epoch = foldsFromEmpty(app.schema, persisted, stored)
79
+ ? { seq: 0, base: { nodes: [], edges: [] }, version: storedVersion, at }
80
+ : { seq, base: stored, version: storedVersion, at };
81
+ }
82
+ if (epoch) {
83
+ epochs.push(epoch);
84
+ await adapter.saveEpochs?.(scope, epochs);
85
+ }
35
86
  /*
36
87
  * The store REOPENS WITH ITS HISTORY. The snapshot is the graph; the
37
88
  * persisted log (plus the migration run just appended) is how it got
@@ -48,7 +99,8 @@ export async function openStore(options) {
48
99
  * A supplied `ids` still wins.
49
100
  */
50
101
  const taken = new Set(history.map((op) => op.id));
51
- let n = history.length;
102
+ // Counting the archived ops too (FR-23): their ids are not here to collide with, but they are taken.
103
+ let n = horizon + history.length;
52
104
  const ids = () => {
53
105
  let id = `op${++n}`;
54
106
  while (taken.has(id))
@@ -56,6 +108,9 @@ export async function openStore(options) {
56
108
  taken.add(id);
57
109
  return id;
58
110
  };
111
+ /* A starting set given here is the host's word too, and is recorded below rather than assumed. */
112
+ const storeOptions = { ...(options.storeOptions ?? {}) };
113
+ delete storeOptions.enabledModules;
59
114
  const store = new Store({
60
115
  schema: app.schema,
61
116
  mutations: app.mutations ?? [],
@@ -67,21 +122,48 @@ export async function openStore(options) {
67
122
  ...(app.intelligence ? { intelligence: app.intelligence } : {}),
68
123
  snapshot,
69
124
  log: history,
125
+ epochs,
70
126
  ids,
71
127
  // A stored history is read back later, so its timestamps are real ones.
72
128
  now: () => new Date().toISOString(),
73
- ...(options.storeOptions ?? {}),
129
+ ...storeOptions,
74
130
  });
75
131
  /*
76
- * Write at open only when opening CHANGED something — a fresh scope or a
77
- * migration run. Re-saving an untouched store rewrites the snapshot
78
- * through the current schema's parse, which silently strips any field a
79
- * rolled-back declaration does not know — data loss with no prior copy.
132
+ * A STORE OPENED TO VERIFY PROVES ITS GRAPH AGAINST ITS LOG (FR-20). A
133
+ * drifted snapshot — a write that landed without its ops, an edit by hand
134
+ * — is replaced by what the log folds to, which is the record, and the
135
+ * opening says what it did. A log that does not fold is not a record to
136
+ * rebuild from: nothing is replaced, and the open refuses.
137
+ */
138
+ const verified = options.verify ? store.verify() : undefined;
139
+ let rebuilt;
140
+ if (verified && !verified.ok) {
141
+ let folded;
142
+ try {
143
+ const from = store.log.lastEpoch();
144
+ folded = store.log.fold(app.schema, { validate: options.storeOptions?.validate ?? true, ...(from ? { from } : {}) }).snapshot();
145
+ }
146
+ catch {
147
+ throw new Error(`graview ship: "${scope}" does not verify, and its log cannot be rebuilt from. ${verified.reason} Nothing was rebuilt.`);
148
+ }
149
+ store.graph.load(folded);
150
+ rebuilt = {
151
+ from: verified.actual,
152
+ to: verified.expected,
153
+ ...(verified.divergedAfter !== undefined ? { divergedAfter: verified.divergedAfter } : {}),
154
+ };
155
+ }
156
+ /*
157
+ * Write at open only when opening CHANGED something — a fresh scope, a
158
+ * rebuild or a migration run. A store opens over records that no longer
159
+ * fit and holds them exactly as stored (FR-28); writing them straight back
160
+ * would only churn the file, and `store.findings()` is how a host hears
161
+ * about them.
80
162
  */
81
- if (stored === null || migrated.length > 0) {
163
+ if (stored === null || migrated.length > 0 || rebuilt) {
82
164
  await adapter.save(scope, store.snapshot());
83
165
  }
84
- adapter.saveMeta?.(scope, { version: target });
166
+ adapter.saveMeta?.(scope, { version: target, ...formatStamp() });
85
167
  /*
86
168
  * Writes are SERIALISED: a second diff's ops never land before the
87
169
  * first's snapshot, and a failure is reported rather than swallowed —
@@ -98,6 +180,53 @@ export async function openStore(options) {
98
180
  })
99
181
  .catch(report);
100
182
  });
101
- return { store, migrated, flush: () => writing, close: unsubscribe };
183
+ /* The host's word on modules, recorded where it changes the log's (FR-12). */
184
+ const enabledModules = options.enabledModules ?? options.storeOptions?.enabledModules;
185
+ if (enabledModules !== undefined)
186
+ store.setEnabledModules(enabledModules);
187
+ // A full export of this store reads what a normal open did not load (FR-23).
188
+ const loadArchive = adapter.loadArchive?.bind(adapter);
189
+ if (loadArchive)
190
+ rememberArchive(store, () => loadArchive(scope));
191
+ return {
192
+ store,
193
+ migrated,
194
+ ...(epoch ? { epoch } : {}),
195
+ ...(verified ? { verified } : {}),
196
+ ...(rebuilt ? { rebuilt } : {}),
197
+ flush: () => writing,
198
+ close: unsubscribe,
199
+ compact: (compactOptions) => {
200
+ /*
201
+ * On the write chain, after every write accepted so far, and ARCHIVE
202
+ * FIRST: the adapter moves what is behind the checkpoint before the
203
+ * store lets go of it, so a failed write leaves a whole log on disk
204
+ * and a whole log in memory, never an archive that is missing ops.
205
+ */
206
+ const done = writing.then(async () => {
207
+ if (!adapter.compact || !adapter.loadArchive) {
208
+ throw new Error(`The ${adapter.name} adapter keeps no archive, so its log cannot be compacted behind an undo horizon. ` +
209
+ "It keeps no epochs either, and a checkpoint is one: compaction is for an adapter that keeps both, as the memory, file and SQL adapters do.");
210
+ }
211
+ const made = store.checkpoint(compactOptions);
212
+ if (!made)
213
+ return { horizon: store.log.horizon, archived: 0 };
214
+ await adapter.compact(scope, made);
215
+ const archived = store.compact(made);
216
+ return { horizon: store.log.horizon, archived: archived.ops.length, checkpoint: made };
217
+ });
218
+ writing = done.then(() => undefined, () => undefined);
219
+ return done;
220
+ },
221
+ };
222
+ }
223
+ /** Whether a log with no epochs folds from empty to exactly what is stored. */
224
+ function foldsFromEmpty(schema, ops, stored) {
225
+ try {
226
+ return snapshotHash(OperationLog.from(ops).fold(schema).snapshot()) === snapshotHash(stored);
227
+ }
228
+ catch {
229
+ return false;
230
+ }
102
231
  }
103
232
  //# sourceMappingURL=open-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"open-store.js","sourceRoot":"","sources":["../src/open-store.ts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,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,SAAS,cAAc,CAAC,MAAiB,EAAE,GAAyB,EAAE,MAAqB;IACzF,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
package/dist/remote.d.ts CHANGED
@@ -1,30 +1,56 @@
1
- import { Store, type AnySchema, type GraviewApp, type MutationCall, type Operation, type PresenceChannel, type Principal } from "@graview/core";
1
+ import { Store, type AnySchema, type FieldConflict, type GraviewApp, type MutationCall, type Operation, type PresenceChannel, type Principal, type Via } from "@graview/core";
2
2
  /**
3
3
  * THE OTHER END OF THE WIRE: a store whose graph lives on a server.
4
4
  *
5
5
  * The browser still holds a real `Store` — the scene, the strip, the rules
6
6
  * and the routed face all read it the way they always have — but it does not
7
7
  * own the truth. A call goes to the server, which judges it under this
8
- * seat's principal and answers with the op it produced; the op is `receive`d
9
- * here, so it lands with its own id, author and sequence and the interface
10
- * updates exactly as it does for a local change.
8
+ * seat's principal and answers with the op it produced; the op lands here by
9
+ * `store.rebase`, under whatever is still pending, with its own id, author
10
+ * and sequence, and the interface updates exactly as it does for a local
11
+ * change.
11
12
  *
12
- * Everyone else's ops arrive the same way, on a poll. Two browsers open on
13
- * the same roster see each other within a second, and neither of them has a
14
- * second way to write the graph.
13
+ * Everyone else's ops arrive the same way: on a poll, or — `live: true` —
14
+ * pushed down a WebSocket the moment they land (FR-05). Two browsers open on
15
+ * the same roster see each other at once, and neither of them has a second
16
+ * way to write the graph.
17
+ *
18
+ * A call carries the revision of every field it changes, as this client
19
+ * last saw it (FR-05). One that somebody else changed meanwhile comes back
20
+ * as a conflict, naming the field, theirs and yours, and the person
21
+ * chooses: keep theirs, or send theirs over with `useMine`. Nothing is
22
+ * overwritten without anybody knowing.
15
23
  *
16
24
  * Undo is the interesting case and it needed no special handling: `undo`
17
25
  * produces ordinary calls, and they go down the same wire and are judged by
18
26
  * the same policy — what you may undo is what you may have done, decided on
19
27
  * the server rather than trusted from the client.
20
28
  */
29
+ /** As much of a WebSocket as the live wire needs: the platform's own, or a host's or a test's. */
30
+ export interface LiveSocketLike {
31
+ readonly readyState: number;
32
+ send(data: string): void;
33
+ close(code?: number, reason?: string): void;
34
+ onopen: ((event: unknown) => void) | null;
35
+ onmessage: ((event: {
36
+ readonly data: unknown;
37
+ }) => void) | null;
38
+ onclose: ((event: {
39
+ readonly code: number;
40
+ readonly reason: string;
41
+ }) => void) | null;
42
+ onerror: ((event: unknown) => void) | null;
43
+ }
21
44
  export interface RemoteOptions<S extends AnySchema> {
22
45
  readonly app: GraviewApp<S>;
23
46
  /** Where the server is: `http://localhost:5196`, say. */
24
47
  readonly url: string;
25
48
  /** Who is at this keyboard. Sent with every call; the server judges by it. */
26
49
  readonly principal?: Principal;
27
- /** How often to ask for everybody else's ops, in milliseconds. 0 never asks. */
50
+ /**
51
+ * How often to ask for everybody else's ops, in milliseconds. 0 never asks.
52
+ * A live client polls only while its socket is down.
53
+ */
28
54
  readonly pollMs?: number;
29
55
  readonly fetch?: typeof fetch;
30
56
  readonly storeOptions?: Record<string, unknown>;
@@ -35,6 +61,40 @@ export interface RemoteOptions<S extends AnySchema> {
35
61
  * where a hosted store's own auth goes without the framework knowing it.
36
62
  */
37
63
  readonly headers?: Readonly<Record<string, string>>;
64
+ /** What the calls come through, recorded on each op the server makes: `web` unless said (FR-06). */
65
+ readonly via?: Via;
66
+ /**
67
+ * THE LIVE WIRE (FR-05): hold a WebSocket to the server's `LIVE_PATH`,
68
+ * and have every op pushed down it as it lands. Calls go down it too.
69
+ * While it is down, the client polls and posts as it would without it,
70
+ * and reconnects, catching up from the last op it has.
71
+ */
72
+ readonly live?: boolean;
73
+ /**
74
+ * How to open the socket: the platform's `WebSocket` by default, with the
75
+ * headers where the runtime can send them (Node 22 can; a page cannot,
76
+ * and its seat rides in the query, which only a store trusting seat
77
+ * headers reads).
78
+ */
79
+ readonly socket?: (url: string, headers: Readonly<Record<string, string>>) => LiveSocketLike;
80
+ /** How long `openRemote({ live: true })` waits for the socket's welcome before it opens polling. 3000 by default. */
81
+ readonly openTimeoutMs?: number;
82
+ /**
83
+ * The modules on, for a server that does not say (FR-12). The server's
84
+ * word wins: its state names the set it serves, and an op of its that
85
+ * turns one off or on reaches this client like any other.
86
+ */
87
+ readonly enabledModules?: readonly string[];
88
+ }
89
+ /** A stale write, as this client is told of it: the fields that moved, and the person's two answers. */
90
+ export interface RemoteConflict {
91
+ /** In words: "Ana changed label to “Book the church hall” while you were editing; yours was …" */
92
+ readonly sentence: string;
93
+ readonly conflicts: readonly FieldConflict[];
94
+ /** Leave it as they made it. Nothing more is sent. */
95
+ keepTheirs(): void;
96
+ /** Make the same change again, over theirs: the calls are applied and sent again without the old revisions. */
97
+ useMine(): void;
38
98
  }
39
99
  export interface RemoteStore<S extends AnySchema> {
40
100
  readonly store: Store<S>;
@@ -51,9 +111,23 @@ export interface RemoteStore<S extends AnySchema> {
51
111
  /**
52
112
  * Told when the server refused something this browser had already shown.
53
113
  * The change is taken back before the listener runs; what is left is
54
- * saying so, in the policy's own words.
114
+ * saying so, in the policy's own words. A conflict nobody listens for
115
+ * with `onConflict` is told here too, in its sentence.
55
116
  */
56
117
  onRefusal(listener: (reason: string) => void): () => void;
118
+ /**
119
+ * Told when a change this browser had already shown was refused as a
120
+ * stale write (FR-05): somebody changed a field it changes since this
121
+ * browser last saw it. The change is taken back first — theirs stands —
122
+ * and the listener is handed the way to put yours over it.
123
+ */
124
+ onConflict(listener: (conflict: RemoteConflict) => void): () => void;
125
+ /** The revision this client knows a field at: the seq of the op that last wrote it, or -1. */
126
+ revision(node: string, field: string): number;
127
+ /** The last op of the server's this client has. */
128
+ seq(): number;
129
+ /** How everybody else's ops reach this client now: pushed down the socket, or on the poll. */
130
+ transport(): "socket" | "poll";
57
131
  /**
58
132
  * Resolves once every call sent so far has been answered — accepted and
59
133
  * landed, or refused and taken back. A browser never waits for this; a
@@ -62,12 +136,19 @@ export interface RemoteStore<S extends AnySchema> {
62
136
  */
63
137
  settled(): Promise<void>;
64
138
  /**
65
- * WHO IS HERE, over the same poll. Saying where you are rides on the next
66
- * heartbeat and the answer carries everybody else — no round trip of its
67
- * own, nothing written to the store, the adapter or the log.
139
+ * WHO IS HERE, over the same poll — or the socket. Saying where you are
140
+ * rides on the next heartbeat and the answer carries everybody else — no
141
+ * round trip of its own, nothing written to the store, the adapter or
142
+ * the log.
68
143
  */
69
144
  readonly presence: PresenceChannel;
70
145
  close(): void;
71
146
  }
72
147
  export declare function openRemote<S extends AnySchema>(options: RemoteOptions<S>): Promise<RemoteStore<S>>;
148
+ /**
149
+ * A principal as the headers a TRUSTED server reads (`trustSeatHeaders`):
150
+ * who, as what, by what name, and for whom. A server that does not trust
151
+ * headers ignores every one of them and asks its own `seatOf`.
152
+ */
153
+ export declare function seatHeaders(principal: Principal | undefined): Record<string, string>;
73
154
  //# sourceMappingURL=remote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EAEd,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,eAAe,CAAC;AAGvB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,SAAS;IAChD,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,yDAAyD;IACzD,QAA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