@dxos/react-ui-attention 0.16.0 → 0.17.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/dist/lib/chunk-ViewStateProvider.mjs +1 -1
- package/dist/lib/chunk-types.mjs +240 -9
- package/dist/lib/chunk-types.mjs.map +1 -1
- package/dist/lib/index.mjs +242 -56
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/testing.mjs +1 -1
- package/dist/lib/types.mjs +1 -1
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts +6 -11
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts.map +1 -1
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts +13 -6
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts.map +1 -1
- package/dist/types/src/components/RemoteCursor/RemoteCursor.d.ts +18 -0
- package/dist/types/src/components/RemoteCursor/RemoteCursor.d.ts.map +1 -0
- package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.d.ts +32 -0
- package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.d.ts.map +1 -0
- package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.test.d.ts +2 -0
- package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.test.d.ts.map +1 -0
- package/dist/types/src/components/RemoteCursor/index.d.ts +3 -0
- package/dist/types/src/components/RemoteCursor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScrollScope/ScrollScope.d.ts +11 -0
- package/dist/types/src/components/ScrollScope/ScrollScope.d.ts.map +1 -0
- package/dist/types/src/components/ScrollScope/ScrollScope.stories.d.ts +15 -0
- package/dist/types/src/components/ScrollScope/ScrollScope.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScrollScope/index.d.ts +2 -0
- package/dist/types/src/components/ScrollScope/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/types/Activity.d.ts +71 -0
- package/dist/types/src/types/Activity.d.ts.map +1 -0
- package/dist/types/src/types/Activity.test.d.ts +2 -0
- package/dist/types/src/types/Activity.test.d.ts.map +1 -0
- package/dist/types/src/types/ScrollPosition.d.ts +24 -0
- package/dist/types/src/types/ScrollPosition.d.ts.map +1 -0
- package/dist/types/src/types/ViewLocation.d.ts +16 -0
- package/dist/types/src/types/ViewLocation.d.ts.map +1 -0
- package/dist/types/src/types/ViewState.d.ts +44 -2
- package/dist/types/src/types/ViewState.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/components/AttentionGlyph/AttentionGlyph.stories.tsx +424 -31
- package/src/components/AttentionGlyph/AttentionGlyph.tsx +80 -56
- package/src/components/RemoteCursor/RemoteCursor.tsx +55 -0
- package/src/components/RemoteCursor/RemoteCursorLayer.test.tsx +98 -0
- package/src/components/RemoteCursor/RemoteCursorLayer.tsx +97 -0
- package/src/components/RemoteCursor/index.ts +6 -0
- package/src/components/ScrollScope/ScrollScope.stories.tsx +97 -0
- package/src/components/ScrollScope/ScrollScope.tsx +59 -0
- package/src/components/ScrollScope/index.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/types/Activity.test.ts +53 -0
- package/src/types/Activity.ts +110 -0
- package/src/types/ScrollPosition.ts +34 -0
- package/src/types/ViewLocation.ts +28 -0
- package/src/types/ViewState.test.ts +74 -1
- package/src/types/ViewState.ts +217 -4
- package/src/types/index.ts +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as toggle, d as Manager, g as attendElement, m as AttentionManager, o as aspect, p as ATTENDABLE_ATTRIBUTE, r as createDefaultBackends, s as resolve } from "./chunk-types.mjs";
|
|
2
2
|
import { forwardRef, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { mx } from "@dxos/ui-theme";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
package/dist/lib/chunk-types.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as Atom from "effect/reactivity/Atom";
|
|
2
|
-
import
|
|
2
|
+
import { log } from "@dxos/log";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import { EID } from "@dxos/keys";
|
|
6
|
+
import * as Match from "effect/Match";
|
|
4
7
|
import * as Struct from "effect/Struct";
|
|
5
8
|
//#region \0rolldown/runtime.js
|
|
6
9
|
var __defProp = Object.defineProperty;
|
|
@@ -14,6 +17,44 @@ var __exportAll = (all, no_symbols) => {
|
|
|
14
17
|
return target;
|
|
15
18
|
};
|
|
16
19
|
//#endregion
|
|
20
|
+
//#region src/types/Activity.ts
|
|
21
|
+
var Activity_exports = /* @__PURE__ */ __exportAll({
|
|
22
|
+
Slots: () => Slots,
|
|
23
|
+
resolve: () => resolve$1
|
|
24
|
+
});
|
|
25
|
+
/** The slots in drawing order, back to front. */
|
|
26
|
+
var Slots = [
|
|
27
|
+
"fill",
|
|
28
|
+
"mark",
|
|
29
|
+
"edge",
|
|
30
|
+
"corner"
|
|
31
|
+
];
|
|
32
|
+
/** Which slot keeps its motion when several animate: what asks for you first, then who is there. */
|
|
33
|
+
var MOTION_ORDER = [
|
|
34
|
+
"corner",
|
|
35
|
+
"mark",
|
|
36
|
+
"fill"
|
|
37
|
+
];
|
|
38
|
+
var winner = (treatments, slot) => treatments.filter((treatment) => treatment.slot === slot).reduce((best, treatment) => !best || treatment.priority > best.priority ? treatment : best, void 0);
|
|
39
|
+
/**
|
|
40
|
+
* Reduces any set of requested treatments to one per slot by priority, then lets only the first animated slot in
|
|
41
|
+
* {@link MOTION_ORDER} move, so every combination draws at most four things and animates at most one.
|
|
42
|
+
*/
|
|
43
|
+
var resolve$1 = (treatments, { attention } = {}) => {
|
|
44
|
+
const requested = [...treatments];
|
|
45
|
+
const resolved = {
|
|
46
|
+
fill: attention ? void 0 : winner(requested, "fill"),
|
|
47
|
+
mark: winner(requested, "mark"),
|
|
48
|
+
edge: winner(requested, "edge"),
|
|
49
|
+
corner: winner(requested, "corner")
|
|
50
|
+
};
|
|
51
|
+
const moving = MOTION_ORDER.find((slot) => resolved[slot]?.animate);
|
|
52
|
+
return {
|
|
53
|
+
...resolved,
|
|
54
|
+
moving
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
17
58
|
//#region src/types/Attention.ts
|
|
18
59
|
var Attention_exports = /* @__PURE__ */ __exportAll({
|
|
19
60
|
ATTENDABLE_ATTRIBUTE: () => ATTENDABLE_ATTRIBUTE,
|
|
@@ -233,8 +274,13 @@ var getSegmentId = (qualifiedId) => {
|
|
|
233
274
|
//#region src/types/ViewState.ts
|
|
234
275
|
var ViewState_exports = /* @__PURE__ */ __exportAll({
|
|
235
276
|
Manager: () => Manager,
|
|
236
|
-
|
|
277
|
+
Patch: () => Patch,
|
|
278
|
+
define: () => define,
|
|
279
|
+
getFollowPolicy: () => getFollowPolicy,
|
|
280
|
+
patch: () => patch
|
|
237
281
|
});
|
|
282
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-attention/src/types/ViewState.ts";
|
|
283
|
+
var getFollowPolicy = (aspect) => typeof aspect.follow === "object" ? aspect.follow.policy : aspect.follow;
|
|
238
284
|
/**
|
|
239
285
|
* Identity helper that pins the value type from the schema while keeping the literal `key`/`backend`.
|
|
240
286
|
* Declares an aspect of per-context UI state (selection, scroll, view mode, split) read/written via
|
|
@@ -250,6 +296,24 @@ var ViewState_exports = /* @__PURE__ */ __exportAll({
|
|
|
250
296
|
* related: org.dxos.effect.kvsStore
|
|
251
297
|
*/
|
|
252
298
|
var define = (def) => def;
|
|
299
|
+
/** Encoded fields to merge over one aspect's value for one context; plain JSON, so it can cross an operation. */
|
|
300
|
+
var Patch = Schema.Struct({
|
|
301
|
+
aspect: Schema.String.annotate({ description: "The aspect's key." }),
|
|
302
|
+
context: Schema.String.annotate({ description: "The context the aspect is keyed by." }),
|
|
303
|
+
fields: Schema.Record(Schema.String, Schema.Unknown).annotate({ description: "Encoded top-level fields, merged over the aspect's current value." })
|
|
304
|
+
});
|
|
305
|
+
/** A patch setting `fields` of `aspect` for `context`, encoded by the aspect's schema. */
|
|
306
|
+
var patch = (aspect, context, fields) => {
|
|
307
|
+
const encoded = Schema.encodeUnknownSync(Schema.toCodecJson(aspect.schema))({
|
|
308
|
+
...aspect.defaultValue(),
|
|
309
|
+
...fields
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
aspect: aspect.key,
|
|
313
|
+
context,
|
|
314
|
+
fields: isRecord(encoded) ? pickKeys(encoded, Object.keys(fields)) : {}
|
|
315
|
+
};
|
|
316
|
+
};
|
|
253
317
|
/**
|
|
254
318
|
* Routes per-context UI state to the backend declared by each aspect. Reads/writes go through the
|
|
255
319
|
* effect-atom registry so React hooks and graph atoms observe changes uniformly.
|
|
@@ -257,38 +321,182 @@ var define = (def) => def;
|
|
|
257
321
|
var Manager = class {
|
|
258
322
|
#registry;
|
|
259
323
|
#backends;
|
|
324
|
+
#aspects = /* @__PURE__ */ new Map();
|
|
325
|
+
#pending = /* @__PURE__ */ new Map();
|
|
326
|
+
#pendingPatches = /* @__PURE__ */ new Map();
|
|
327
|
+
#followListeners = /* @__PURE__ */ new Set();
|
|
328
|
+
#fromFollow = /* @__PURE__ */ new Set();
|
|
329
|
+
#warned = /* @__PURE__ */ new Set();
|
|
260
330
|
constructor({ registry, backends }) {
|
|
261
331
|
this.#registry = registry;
|
|
262
332
|
this.#backends = backends;
|
|
263
333
|
}
|
|
264
334
|
/** Reactive atom for `(aspect, contextId)`; pass to `registry.get` inside derived atoms/hooks. */
|
|
265
335
|
atom(aspect, contextId) {
|
|
336
|
+
this.#learn(aspect);
|
|
337
|
+
if (aspect.follow && !EID.isEID(contextId) && !this.#warned.has(aspect.key)) {
|
|
338
|
+
this.#warned.add(aspect.key);
|
|
339
|
+
log.warn("a followed aspect is keyed by something other than an EID, so it is never followed", {
|
|
340
|
+
aspect: aspect.key,
|
|
341
|
+
contextId
|
|
342
|
+
}, {
|
|
343
|
+
"~LogMeta": "~LogMeta",
|
|
344
|
+
F: __dxlog_file,
|
|
345
|
+
L: 142,
|
|
346
|
+
S: this
|
|
347
|
+
});
|
|
348
|
+
}
|
|
266
349
|
return this.#backends[aspect.backend].atom(aspect, contextId);
|
|
267
350
|
}
|
|
268
351
|
get(aspect, contextId) {
|
|
269
352
|
return this.#registry.get(this.atom(aspect, contextId));
|
|
270
353
|
}
|
|
271
354
|
set(aspect, contextId, value) {
|
|
355
|
+
this.#write(aspect, contextId, value, "local");
|
|
356
|
+
}
|
|
357
|
+
/** Whether the value of `(aspect, contextId)` was set here or written from the followed session. */
|
|
358
|
+
origin(aspect, contextId) {
|
|
359
|
+
return this.#fromFollow.has(originKey(aspect.key, contextId)) ? "follow" : "local";
|
|
360
|
+
}
|
|
361
|
+
#write(aspect, contextId, value, origin) {
|
|
272
362
|
const backend = this.#backends[aspect.backend];
|
|
273
|
-
this.#
|
|
363
|
+
if (origin === "follow") this.#fromFollow.add(originKey(aspect.key, contextId));
|
|
364
|
+
else this.#fromFollow.delete(originKey(aspect.key, contextId));
|
|
365
|
+
this.#registry.set(this.atom(aspect, contextId), value);
|
|
274
366
|
backend.persist?.(aspect, contextId, value);
|
|
367
|
+
if (aspect.follow) this.#followListeners.forEach((listener) => listener(aspect.key, contextId));
|
|
275
368
|
}
|
|
276
369
|
update(aspect, contextId, fn) {
|
|
277
370
|
this.set(aspect, contextId, fn(this.get(aspect, contextId)));
|
|
278
371
|
}
|
|
279
372
|
subscribe(aspect, contextId, cb) {
|
|
280
373
|
const atom = this.atom(aspect, contextId);
|
|
281
|
-
return this.#registry.subscribe(atom, () => cb(this.#registry.get(atom)));
|
|
374
|
+
return this.#registry.subscribe(atom, () => cb(this.#registry.get(atom), this.origin(aspect, contextId)));
|
|
282
375
|
}
|
|
283
376
|
contexts(aspect) {
|
|
377
|
+
this.#learn(aspect);
|
|
284
378
|
return this.#backends[aspect.backend].contexts(aspect);
|
|
285
379
|
}
|
|
380
|
+
/** The aspect with `key`, once this session has used it. */
|
|
381
|
+
aspect(key) {
|
|
382
|
+
return this.#aspects.get(key);
|
|
383
|
+
}
|
|
384
|
+
/** This session's values of every followed aspect it has used, encoded as JSON, by aspect key and then context. */
|
|
385
|
+
followed(contextIds) {
|
|
386
|
+
return Object.fromEntries([...this.#aspects.values()].flatMap((aspect) => {
|
|
387
|
+
if (!aspect.follow) return [];
|
|
388
|
+
const held = new Set(this.contexts(aspect));
|
|
389
|
+
const values = Object.fromEntries(contextIds.flatMap((contextId) => held.has(contextId) ? Option.match(this.#encode(aspect, contextId), {
|
|
390
|
+
onNone: () => [],
|
|
391
|
+
onSome: (json) => [[contextId, pickFollowed(aspect, json)]]
|
|
392
|
+
}) : []));
|
|
393
|
+
return Object.keys(values).length > 0 ? [[aspect.key, values]] : [];
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
/** Calls `listener` when a followed aspect's value is set. */
|
|
397
|
+
subscribeFollowed(listener) {
|
|
398
|
+
this.#followListeners.add(listener);
|
|
399
|
+
return () => this.#followListeners.delete(listener);
|
|
400
|
+
}
|
|
401
|
+
/** Sets a leader's encoded value of a `write` aspect; one not used yet is held until it is, and one that does not decode is dropped. */
|
|
402
|
+
setEncoded(key, contextId, value) {
|
|
403
|
+
const aspect = this.#aspects.get(key);
|
|
404
|
+
if (aspect) this.#decodeInto(aspect, contextId, value);
|
|
405
|
+
else this.#pending.set(key, (this.#pending.get(key) ?? /* @__PURE__ */ new Map()).set(contextId, value));
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Merges a patch's fields over its aspect's value for its context, as a local write. A patch to an aspect this
|
|
409
|
+
* session has not used yet is held until it is; one whose merged value does not decode is dropped.
|
|
410
|
+
*/
|
|
411
|
+
apply(patch) {
|
|
412
|
+
const aspect = this.#aspects.get(patch.aspect);
|
|
413
|
+
if (aspect) this.#patchInto(aspect, patch);
|
|
414
|
+
else this.#pendingPatches.set(patch.aspect, [...this.#pendingPatches.get(patch.aspect) ?? [], patch]);
|
|
415
|
+
}
|
|
416
|
+
#learn(aspect) {
|
|
417
|
+
if (this.#aspects.has(aspect.key)) return;
|
|
418
|
+
this.#aspects.set(aspect.key, aspect);
|
|
419
|
+
const pending = this.#pending.get(aspect.key);
|
|
420
|
+
this.#pending.delete(aspect.key);
|
|
421
|
+
pending?.forEach((value, contextId) => this.#decodeInto(aspect, contextId, value));
|
|
422
|
+
const patches = this.#pendingPatches.get(aspect.key);
|
|
423
|
+
this.#pendingPatches.delete(aspect.key);
|
|
424
|
+
patches?.forEach((patch) => this.#patchInto(aspect, patch));
|
|
425
|
+
}
|
|
426
|
+
#patchInto(aspect, { context, fields }) {
|
|
427
|
+
const own = this.#encode(aspect, context).pipe(Option.filter(isRecord), Option.getOrElse(() => ({})));
|
|
428
|
+
Option.match(Schema.decodeUnknownOption(Schema.toCodecJson(aspect.schema))({
|
|
429
|
+
...own,
|
|
430
|
+
...fields
|
|
431
|
+
}), {
|
|
432
|
+
onNone: () => log.warn("dropped a view-state patch that does not decode", {
|
|
433
|
+
aspect: aspect.key,
|
|
434
|
+
context
|
|
435
|
+
}, {
|
|
436
|
+
"~LogMeta": "~LogMeta",
|
|
437
|
+
F: __dxlog_file,
|
|
438
|
+
L: 271,
|
|
439
|
+
S: this
|
|
440
|
+
}),
|
|
441
|
+
onSome: (decoded) => this.#write(aspect, context, decoded, "local")
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
#encode(aspect, contextId) {
|
|
445
|
+
return Schema.encodeUnknownOption(Schema.toCodecJson(aspect.schema))(this.get(aspect, contextId));
|
|
446
|
+
}
|
|
447
|
+
#decodeInto(aspect, contextId, value) {
|
|
448
|
+
if (getFollowPolicy(aspect) !== "write") return;
|
|
449
|
+
const merged = typeof aspect.follow === "object" && isRecord(value) ? Option.match(this.#encode(aspect, contextId), {
|
|
450
|
+
onNone: () => value,
|
|
451
|
+
onSome: (own) => ({
|
|
452
|
+
...isRecord(own) ? own : {},
|
|
453
|
+
...pickFields(aspect, value)
|
|
454
|
+
})
|
|
455
|
+
}) : value;
|
|
456
|
+
Option.match(Schema.decodeUnknownOption(Schema.toCodecJson(aspect.schema))(merged), {
|
|
457
|
+
onNone: () => {},
|
|
458
|
+
onSome: (decoded) => this.#write(aspect, contextId, decoded, "follow")
|
|
459
|
+
});
|
|
460
|
+
}
|
|
286
461
|
};
|
|
462
|
+
var originKey = (key, contextId) => `${key}\n${contextId}`;
|
|
463
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
464
|
+
var isJsonObject = (value) => isRecord(value);
|
|
465
|
+
var pickKeys = (record, keys) => Object.fromEntries(Object.entries(record).filter(([key]) => keys.includes(key)));
|
|
466
|
+
var pickFields = (aspect, record) => pickKeys(record, typeof aspect.follow === "object" ? aspect.follow.fields : []);
|
|
467
|
+
var pickFollowed = (aspect, json) => typeof aspect.follow === "object" && isJsonObject(json) ? pickFields(aspect, json) : json;
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/types/ScrollPosition.ts
|
|
470
|
+
var ScrollPosition_exports = /* @__PURE__ */ __exportAll({
|
|
471
|
+
Position: () => Position,
|
|
472
|
+
State: () => State,
|
|
473
|
+
aspect: () => aspect$2
|
|
474
|
+
});
|
|
475
|
+
/** Where one scrolling area is scrolled to; see `ScrollArea.ScrollPosition` in react-ui. */
|
|
476
|
+
var Position = Schema.Struct({
|
|
477
|
+
anchor: Schema.optional(Schema.String),
|
|
478
|
+
offset: Schema.optional(Schema.Number),
|
|
479
|
+
y: Schema.Number,
|
|
480
|
+
x: Schema.optional(Schema.Number)
|
|
481
|
+
});
|
|
482
|
+
/** The position of each tracked scrolling area in an object's view, by area name (`main` for the outermost). */
|
|
483
|
+
var State = Schema.Record(Schema.String, Position);
|
|
484
|
+
/**
|
|
485
|
+
* The scroll of an object's article, keyed by the object's EID and kept for the session, so a view comes back where it
|
|
486
|
+
* was left; a follower takes the leader's.
|
|
487
|
+
*/
|
|
488
|
+
var aspect$2 = define({
|
|
489
|
+
key: "org.dxos.react-ui-attention.scroll",
|
|
490
|
+
backend: "memory",
|
|
491
|
+
schema: State,
|
|
492
|
+
defaultValue: () => ({}),
|
|
493
|
+
follow: "write"
|
|
494
|
+
});
|
|
287
495
|
//#endregion
|
|
288
496
|
//#region src/types/Selection.ts
|
|
289
497
|
var Selection_exports = /* @__PURE__ */ __exportAll({
|
|
290
498
|
Selection: () => Selection,
|
|
291
|
-
aspect: () => aspect,
|
|
499
|
+
aspect: () => aspect$1,
|
|
292
500
|
defaultValue: () => defaultValue,
|
|
293
501
|
getValue: () => getValue,
|
|
294
502
|
resolve: () => resolve,
|
|
@@ -325,7 +533,7 @@ var defaultValue = Match.type().pipe(Match.withReturnType(), Match.when("single"
|
|
|
325
533
|
ranges: []
|
|
326
534
|
})), Match.exhaustive);
|
|
327
535
|
/** Selection state for a context, stored in memory (ephemeral, per-device session). */
|
|
328
|
-
var aspect = define({
|
|
536
|
+
var aspect$1 = define({
|
|
329
537
|
key: "selection",
|
|
330
538
|
backend: "memory",
|
|
331
539
|
schema: Selection,
|
|
@@ -358,13 +566,36 @@ var toAnchors = (selection) => selection == null ? [] : Match.type().pipe(Match.
|
|
|
358
566
|
/** Union of all multi-selected ids across every selection context, plus an optional explicit id. */
|
|
359
567
|
var getValue = (manager, contextId) => {
|
|
360
568
|
const ids = new Set(contextId ? [contextId] : []);
|
|
361
|
-
for (const context of manager.contexts(aspect)) {
|
|
362
|
-
const selection = manager.get(aspect, context);
|
|
569
|
+
for (const context of manager.contexts(aspect$1)) {
|
|
570
|
+
const selection = manager.get(aspect$1, context);
|
|
363
571
|
if (selection.mode === "multi") for (const id of selection.ids) ids.add(id);
|
|
364
572
|
}
|
|
365
573
|
return ids;
|
|
366
574
|
};
|
|
367
575
|
//#endregion
|
|
576
|
+
//#region src/types/ViewLocation.ts
|
|
577
|
+
var ViewLocation_exports = /* @__PURE__ */ __exportAll({
|
|
578
|
+
ViewLocation: () => ViewLocation,
|
|
579
|
+
aspect: () => aspect
|
|
580
|
+
});
|
|
581
|
+
/**
|
|
582
|
+
* Where the local user is in an object, as anchors in the object type's own format (the format its
|
|
583
|
+
* comments and its `Locator` use), so a peer's view of the same object can reveal it.
|
|
584
|
+
*/
|
|
585
|
+
var ViewLocation = Schema.Struct({
|
|
586
|
+
/** The caret or selection. */
|
|
587
|
+
selection: Schema.optional(Schema.String),
|
|
588
|
+
/** The top of what the view shows. */
|
|
589
|
+
viewport: Schema.optional(Schema.String)
|
|
590
|
+
});
|
|
591
|
+
/** View location for an object, keyed by the object's URI and stored in memory (ephemeral, per-device session). */
|
|
592
|
+
var aspect = define({
|
|
593
|
+
key: "view-location",
|
|
594
|
+
backend: "memory",
|
|
595
|
+
schema: ViewLocation,
|
|
596
|
+
defaultValue: () => ({})
|
|
597
|
+
});
|
|
598
|
+
//#endregion
|
|
368
599
|
//#region src/core/backends.ts
|
|
369
600
|
var cacheKey = (aspect, contextId) => `${aspect.key}:${contextId}`;
|
|
370
601
|
/** In-memory backend: state is ephemeral and scoped to the session (never persisted). */
|
|
@@ -463,6 +694,6 @@ var createDefaultBackends = (registry) => ({
|
|
|
463
694
|
local: new LocalBackend({ registry })
|
|
464
695
|
});
|
|
465
696
|
//#endregion
|
|
466
|
-
export {
|
|
697
|
+
export { Activity_exports as _, Selection_exports as a, toggle as c, Manager as d, ViewState_exports as f, attendElement as g, Attention_exports as h, ViewLocation_exports as i, ScrollPosition_exports as l, AttentionManager as m, MemoryBackend as n, aspect$1 as o, ATTENDABLE_ATTRIBUTE as p, createDefaultBackends as r, resolve as s, LocalBackend as t, aspect$2 as u, resolve$1 as v };
|
|
467
698
|
|
|
468
699
|
//# sourceMappingURL=chunk-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-types.mjs","names":[],"sources":["../../src/types/Attention.ts","../../src/types/ViewState.ts","../../src/types/Selection.ts","../../src/core/backends.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\n\nexport type Attention = {\n hasAttention: boolean;\n isAncestor: boolean;\n isRelated: boolean;\n};\n\n/**\n * Manages attention state for an application.\n * Attention keys are slash-qualified graph IDs; ancestry is derived from progressive prefixes.\n */\nexport class AttentionManager {\n readonly #map = new Map<string, Atom.Writable<Attention>>();\n readonly #currentAtom: Atom.Writable<string[]>;\n readonly #registry: Registry.AtomRegistry;\n\n constructor(registry: Registry.AtomRegistry, initial: string[] = []) {\n this.#registry = registry;\n this.#currentAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Atom for the currently attended element IDs.\n */\n get current(): Atom.Atom<string[]> {\n return this.#currentAtom;\n }\n\n /**\n * Gets the currently attended element IDs.\n */\n getCurrent(): readonly string[] {\n return this.#registry.get(this.#currentAtom);\n }\n\n /**\n * Subscribe to changes in the current attention IDs.\n */\n subscribeCurrent(cb: (current: readonly string[]) => void): () => void {\n this.#registry.get(this.#currentAtom);\n return this.#registry.subscribe(this.#currentAtom, () => {\n cb(this.#registry.get(this.#currentAtom));\n });\n }\n\n /**\n * All tracked qualified IDs.\n */\n keys(): string[] {\n return Array.from(this.#map.keys());\n }\n\n /**\n * Get the attention state for a given qualified ID.\n */\n get(id: string): Attention {\n const atom = this.#getAtom(id);\n return this.#registry.get(atom);\n }\n\n /**\n * Subscribe to changes in the attention state for a given qualified ID.\n */\n subscribe(id: string, cb: (attention: Attention) => void): () => void {\n const atom = this.#getAtom(id);\n this.#registry.get(atom);\n return this.#registry.subscribe(atom, () => {\n cb(this.#registry.get(atom));\n });\n }\n\n #getAtom(id: string): Atom.Writable<Attention> {\n const existing = this.#map.get(id);\n if (existing) {\n return existing;\n }\n\n const newAtom = Atom.make<Attention>({ hasAttention: false, isAncestor: false, isRelated: false }).pipe(\n Atom.keepAlive,\n );\n this.#map.set(id, newAtom);\n return newAtom;\n }\n\n /**\n * Update the currently attended element.\n * Takes the array of qualified IDs collected from the DOM; the first element is the primary attended item.\n * Ancestry is derived from the progressive prefixes of the primary ID.\n * Relatedness is derived from the segment ID: any tracked key whose last `/` segment matches the\n * attended ID's segment ID is marked `isRelated`. Additionally, if the primary ID is a linked segment\n * (starts with `~`), its immediate parent gets `isRelated` alongside `isAncestor`.\n *\n * @internal\n */\n update(nextIds: string[]): void {\n const primaryId = nextIds[0];\n if (!primaryId) {\n return;\n }\n\n const currentIds = this.getCurrent();\n const prevPrimaryId = currentIds[0];\n // Clear previous attention state: ancestors, primary, and related keys.\n if (prevPrimaryId) {\n const prevPrefixes = expandAttendableId(prevPrimaryId);\n for (const prefix of prevPrefixes) {\n this.#set(prefix, {});\n }\n const prevSegmentId = getSegmentId(prevPrimaryId);\n for (const key of this.keys()) {\n if (getSegmentId(key) === prevSegmentId) {\n this.#set(key, {});\n }\n }\n }\n\n this.#registry.set(this.#currentAtom, nextIds);\n\n // Set ancestors and primary.\n const prefixes = expandAttendableId(primaryId);\n const prefixSet = new Set(prefixes);\n const linkedParent = isLinkedSegment(primaryId) ? getParentId(primaryId) : undefined;\n\n for (const prefix of prefixes) {\n if (prefix === primaryId) {\n this.#set(prefix, { hasAttention: true });\n } else if (prefix === linkedParent) {\n this.#set(prefix, { isAncestor: true, isRelated: true });\n } else {\n this.#set(prefix, { isAncestor: true });\n }\n }\n\n // Set related keys: any tracked key sharing the same segment ID.\n const segmentId = getSegmentId(primaryId);\n for (const key of this.keys()) {\n if (!prefixSet.has(key) && getSegmentId(key) === segmentId) {\n this.#set(key, { isRelated: true });\n }\n }\n }\n\n #set(id: string, attention: Partial<Attention>): void {\n const atom = this.#getAtom(id);\n this.#registry.set(atom, {\n hasAttention: attention.hasAttention ?? false,\n isAncestor: attention.isAncestor ?? false,\n isRelated: attention.isRelated ?? false,\n });\n }\n}\n\n/** The attribute marking an element as attendable, carrying its qualified id. */\nexport const ATTENDABLE_ATTRIBUTE = 'data-attendable-id';\n\n/** Selector matching any attendable element. */\nexport const ATTENDABLE_SELECTOR = `[${ATTENDABLE_ATTRIBUTE}]`;\n\n/**\n * Accumulates all attendable IDs between the element provided and the root, inclusive.\n * Each `data-attendable-id` value is treated as a single qualified ID (no splitting).\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute(ATTENDABLE_ATTRIBUTE);\n if (!attendableId) {\n // This has an id of an aria-controls elsewhere on the page, move cursor to that trigger.\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(attendableId);\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\n/**\n * Attend `element` the way focusing it would, without moving focus. Answers the attended ids, or\n * undefined when nothing changed: an element outside any attendable leaves attention where it was.\n */\nexport const attendElement = (attention: AttentionManager, element: Element): string[] | undefined => {\n const selector = [\n ATTENDABLE_SELECTOR,\n ...Array.from(document.querySelectorAll('[aria-controls]')).map(\n (el) => `[id=\"${el.getAttribute('aria-controls')}\"]`,\n ),\n ].join(',');\n const prev = attention.getCurrent();\n const next = getAttendables(selector, element);\n if (next.length === 0 || (prev.length === next.length && prev.every((id, index) => next[index] === id))) {\n return undefined;\n }\n\n attention.update(next);\n return next;\n};\n\n/**\n * The outermost attendable ancestor of `element` — the root of any nested attendables (e.g. a section\n * within a stack). Structural (real DOM ancestry), so it is independent of what currently has attention.\n * Resolve it from an in-DOM element: a portaled subtree (a menu, a popover) is not under its own\n * attendable, so walk from the trigger or anchor instead.\n */\nexport const getRootAttendableId = (element: Element): string | undefined =>\n getAttendables(ATTENDABLE_SELECTOR, element).at(-1);\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n\n/**\n * Prefix for linked segments. A linked segment's attention state is shared with its parent:\n * when a linked node has attention, the parent is marked as both ancestor and related.\n */\nconst LINKED_PREFIX = '~';\n\n/**\n * Decompose a qualified graph ID into progressive prefixes for ancestry tracking.\n * e.g. `root/a/b/c` yields `['root', 'root/a', 'root/a/b', 'root/a/b/c']`.\n */\nexport const expandAttendableId = (qualifiedId: string): string[] => {\n const segments = qualifiedId.split('/');\n return segments.map((_, index) => segments.slice(0, index + 1).join('/'));\n};\n\n/**\n * Whether the last segment of a qualified ID is a linked segment (starts with `~`).\n * Linked segments share their attention state with the parent node.\n */\nexport const isLinkedSegment = (qualifiedId: string): boolean => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX);\n};\n\n/**\n * Build a linked segment ID from a variant name (e.g., `'settings'` -> `'~settings'`).\n * Nodes identified by linked segments share their attention state with the parent node.\n */\nexport const linkedSegment = (variant: string): string => `${LINKED_PREFIX}${variant}`;\n\n/**\n * Extract the variant name from the last segment of a qualified ID, stripping the linked prefix.\n * e.g. `'root/space/obj/~settings'` -> `'settings'`.\n * If the segment is not linked (no `~` prefix), returns the segment as-is.\n */\nexport const getLinkedVariant = (qualifiedId: string): string => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX) ? lastSegment.slice(LINKED_PREFIX.length) : lastSegment;\n};\n\n/**\n * Get the parent qualified ID (everything before the last `/` segment).\n */\nexport const getParentId = (qualifiedId: string | undefined): string | undefined => {\n if (!qualifiedId) {\n return undefined;\n }\n\n const lastSlash = qualifiedId.lastIndexOf('/');\n return lastSlash > 0 ? qualifiedId.slice(0, lastSlash) : undefined;\n};\n\n/**\n * Extract the segment ID (last segment) of a qualified ID.\n */\nexport const getSegmentId = (qualifiedId: string): string => {\n return qualifiedId.split('/').pop() ?? qualifiedId;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport type * as Schema from 'effect/Schema';\n\n/**\n * Persistence backend identifier. `personal` (ECHO/personal-space) is reserved for a future backend.\n */\nexport type BackendName = 'memory' | 'local';\n\n/**\n * Declares a kind of per-context UI state. The value type `T` and its persisted wire type `Encoded`\n * are inferred from the schema; `Encoded` defaults to `T` for the common no-transform case.\n */\nexport interface Aspect<T, Encoded = T> {\n readonly key: string;\n readonly backend: BackendName;\n readonly schema: Schema.Codec<T, Encoded>;\n readonly defaultValue: () => T;\n}\n\n/**\n * Identity helper that pins the value type from the schema while keeping the literal `key`/`backend`.\n * Declares an aspect of per-context UI state (selection, scroll, view mode, split) read/written via\n * {@link Manager} — through `useViewState`/`useViewStateActions` in React or the\n * `AttentionCapabilities.ViewState` capability in operations. Durability is the `backend`'s: `local`\n * survives reloads (best-effort — degrades to in-memory when storage is blocked), `memory` is\n * session-only.\n *\n * @idiom org.dxos.react-ui-attention.viewState\n * applies: Holding per-context UI state (selection, view mode, scroll, split) that survives navigation (and reloads with the `local` backend)\n * instead-of: ad-hoc `useState` that resets on remount, or stuffing per-context state into the plugin Settings store\n * uses: {@link define}, {@link Manager}\n * related: org.dxos.effect.kvsStore\n */\nexport const define = <T, Encoded = T>(def: Aspect<T, Encoded>): Aspect<T, Encoded> => def;\n\n/**\n * A backend produces a reactive, writable atom for each `(aspect, contextId)` pair. Backends may\n * hydrate asynchronously (an ECHO backend would), yielding `aspect.defaultValue()` until loaded;\n * the memory and local backends resolve synchronously.\n */\nexport interface Backend {\n /** Stable atom for the pair; created (and seeded) on first access, cached thereafter. */\n atom: <T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string) => Atom.Writable<T>;\n /** Persist a value after the atom is updated. No-op for in-memory backends. */\n persist?: <T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, value: T) => void;\n /** Context ids that currently hold a value for the aspect. */\n contexts: <T, Encoded>(aspect: Aspect<T, Encoded>) => string[];\n /** Release listeners/timers (used by tests; app-lifetime managers do not call this). */\n dispose?: () => void;\n}\n\nexport interface ManagerOptions {\n readonly registry: Registry.AtomRegistry;\n readonly backends: Record<BackendName, Backend>;\n}\n\n/**\n * Routes per-context UI state to the backend declared by each aspect. Reads/writes go through the\n * effect-atom registry so React hooks and graph atoms observe changes uniformly.\n */\nexport class Manager {\n readonly #registry: Registry.AtomRegistry;\n readonly #backends: Record<BackendName, Backend>;\n\n constructor({ registry, backends }: ManagerOptions) {\n this.#registry = registry;\n this.#backends = backends;\n }\n\n /** Reactive atom for `(aspect, contextId)`; pass to `registry.get` inside derived atoms/hooks. */\n atom<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n return this.#backends[aspect.backend].atom(aspect, contextId);\n }\n\n get<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string): T {\n return this.#registry.get(this.atom(aspect, contextId));\n }\n\n set<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, value: T): void {\n const backend = this.#backends[aspect.backend];\n this.#registry.set(backend.atom(aspect, contextId), value);\n backend.persist?.(aspect, contextId, value);\n }\n\n update<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, fn: (prev: T) => T): void {\n this.set(aspect, contextId, fn(this.get(aspect, contextId)));\n }\n\n subscribe<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, cb: (value: T) => void): () => void {\n const atom = this.atom(aspect, contextId);\n return this.#registry.subscribe(atom, () => cb(this.#registry.get(atom)));\n }\n\n contexts<T, Encoded>(aspect: Aspect<T, Encoded>): string[] {\n return this.#backends[aspect.backend].contexts(aspect);\n }\n}\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type Aspect, type Manager, define } from './ViewState.ts';\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const Selection = Schema.Union([\n Schema.Struct({\n mode: Schema.Literal('single'),\n id: Schema.optional(Schema.String),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('multi'),\n ids: Schema.Array(Schema.String).pipe(Schema.mutable),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('multi-range'),\n ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),\n }).mapFields(Struct.map(Schema.mutableKey)),\n]);\n\nexport type Selection = Schema.Schema.Type<typeof Selection>;\n\nexport const defaultValue = Match.type<SelectionMode>().pipe(\n Match.withReturnType<Selection>(),\n Match.when('single', () => ({ mode: 'single' })),\n Match.when('multi', () => ({ mode: 'multi', ids: [] })),\n Match.when('range', () => ({ mode: 'range' })),\n Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),\n Match.exhaustive,\n);\n\nexport type Result<T extends SelectionMode> = T extends 'single'\n ? string | undefined\n : T extends 'multi'\n ? string[]\n : T extends 'range'\n ? { from: string; to: string } | undefined\n : T extends 'multi-range'\n ? { from: string; to: string }[]\n : never;\n\n/** Selection state for a context, stored in memory (ephemeral, per-device session). */\nexport const aspect: Aspect<Selection> = define<Selection>({\n key: 'selection',\n backend: 'memory',\n schema: Selection,\n defaultValue: () => ({ mode: 'multi', ids: [] }),\n});\n\n/**\n * Extract the typed result for `mode` from a stored selection value, returning the requested\n * mode's default when the stored value is absent or holds a different mode.\n */\nexport const resolve = <T extends SelectionMode>(selection: Selection | undefined, mode: T): Result<T> => {\n const value = selection?.mode === mode ? selection : defaultValue(mode);\n // Cast required because TypeScript cannot relate the `Match` result to the generic `T`.\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(value) as Result<T>;\n};\n\n/** Toggle `id` within a multi selection; resets to a multi selection if the current value differs. */\nexport const toggle = (selection: Selection | undefined, id: string): Selection => {\n const ids = selection?.mode === 'multi' ? selection.ids : [];\n return { mode: 'multi', ids: ids.includes(id) ? ids.filter((existing) => existing !== id) : [...ids, id] };\n};\n\n/** Anchor strings for a selection: ids for single/multi modes, `\"${from}:${to}\"` cursor pairs for range modes. */\nexport const toAnchors = (selection: Selection | undefined): string[] =>\n selection == null\n ? []\n : Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (value) => (value.id ? [value.id] : [])),\n Match.when({ mode: 'multi' }, (value) => [...value.ids]),\n Match.when({ mode: 'range' }, (value) => (value.from && value.to ? [`${value.from}:${value.to}`] : [])),\n Match.when({ mode: 'multi-range' }, (value) => value.ranges.map((range) => `${range.from}:${range.to}`)),\n Match.exhaustive,\n )(selection);\n\n/** Union of all multi-selected ids across every selection context, plus an optional explicit id. */\nexport const getValue = (manager: Manager, contextId?: string): Set<string> => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of manager.contexts(aspect)) {\n const selection = manager.get(aspect, context);\n if (selection.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n\n return ids;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport * as Schema from 'effect/Schema';\n\nimport { ViewState } from '../types/index.ts';\n\n// Only the stable `key` string is needed to form the map key; avoids variance issues with Aspect<T>.\nconst cacheKey = (aspect: { key: string }, contextId: string) => `${aspect.key}:${contextId}`;\n\n/** In-memory backend: state is ephemeral and scoped to the session (never persisted). */\nexport class MemoryBackend implements ViewState.Backend {\n readonly #atoms = new Map<string, Atom.Writable<unknown>>();\n\n atom<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n const key = cacheKey(aspect, contextId);\n let atom = this.#atoms.get(key);\n if (!atom) {\n // `keepAlive` pins the node so a written value survives for the session; without it the registry\n // sweeps the unsubscribed atom back to its default, dropping state that no UI happens to observe\n // (e.g. a selection read on-demand by an agent tool rather than a live subscriber).\n atom = Atom.make<unknown>(aspect.defaultValue()).pipe(Atom.keepAlive);\n this.#atoms.set(key, atom);\n }\n // Cast bridges the per-aspect value type erased by the shared atom map; safe by construction.\n return atom as Atom.Writable<T>;\n }\n\n contexts<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>): string[] {\n const prefix = `${aspect.key}:`;\n return [...this.#atoms.keys()].filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));\n }\n}\n\nconst STORAGE_PREFIX = 'dxos:view-state:';\n\nconst storageKeyFor = (aspect: { key: string }, contextId: string) => `${STORAGE_PREFIX}${aspect.key}:${contextId}`;\n\n// Accessing `globalThis.localStorage` can throw a SecurityError in sandboxed iframes or when\n// storage is blocked; degrade to in-memory behaviour instead of crashing.\nconst safeLocalStorage = (): Storage | undefined => {\n try {\n return globalThis.localStorage;\n } catch {\n return undefined;\n }\n};\n\nexport interface LocalBackendOptions {\n readonly registry: Registry.AtomRegistry;\n /** Injectable for tests; defaults to `window.localStorage`. */\n readonly storage?: Storage;\n}\n\n/** localStorage-backed backend: seeds atoms from storage, persists on set, syncs across tabs. */\nexport class LocalBackend implements ViewState.Backend {\n readonly #registry: Registry.AtomRegistry;\n // Absent in non-browser contexts (SSR/tests without injection); the backend then degrades to\n // ephemeral, in-memory behaviour rather than crashing on a missing `localStorage`.\n readonly #storage: Storage | undefined;\n readonly #atoms = new Map<string, Atom.Writable<unknown>>();\n // Reverse map: storage key -> (aspect, contextId) so `storage` events can target the right atom.\n readonly #byStorageKey = new Map<string, { aspect: ViewState.Aspect<unknown, unknown>; contextId: string }>();\n #storageListener?: (event: StorageEvent) => void;\n\n constructor({ registry, storage }: LocalBackendOptions) {\n this.#registry = registry;\n this.#storage = storage ?? safeLocalStorage();\n if (this.#storage && typeof globalThis.addEventListener === 'function') {\n this.#storageListener = (event) => {\n if (!event.key || !event.key.startsWith(STORAGE_PREFIX)) {\n return;\n }\n const entry = this.#byStorageKey.get(event.key);\n const atom = entry && this.#atoms.get(cacheKey(entry.aspect, entry.contextId));\n if (entry && atom) {\n this.#registry.set(atom, this.#read(entry.aspect, event.key));\n }\n };\n globalThis.addEventListener('storage', this.#storageListener);\n }\n }\n\n atom<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n const key = cacheKey(aspect, contextId);\n let atom = this.#atoms.get(key);\n if (!atom) {\n const storageKey = storageKeyFor(aspect, contextId);\n // `keepAlive` pins the node so the in-memory value stays consistent with storage without a live\n // subscriber; otherwise the registry sweeps the unsubscribed atom back to its creation-time seed.\n atom = Atom.make<unknown>(this.#read(aspect, storageKey)).pipe(Atom.keepAlive);\n this.#atoms.set(key, atom);\n // Cast erases the per-aspect value type so the reverse map can hold aspects of any `T`; the\n // stored aspect is only used to re-read/decode its own value, so the erasure is safe.\n this.#byStorageKey.set(storageKey, { aspect: aspect as ViewState.Aspect<unknown, unknown>, contextId });\n }\n // Cast bridges the per-aspect value type erased by the shared atom map; safe by construction.\n return atom as Atom.Writable<T>;\n }\n\n persist<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string, value: T): void {\n this.#storage?.setItem(storageKeyFor(aspect, contextId), JSON.stringify(Schema.encodeSync(aspect.schema)(value)));\n }\n\n contexts<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>): string[] {\n if (!this.#storage) {\n // No persistent storage: fall back to the in-memory atoms (mirrors `atom()`'s ephemeral path).\n const prefix = `${aspect.key}:`;\n return [...this.#atoms.keys()].filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));\n }\n const prefix = storageKeyFor(aspect, '');\n const ids: string[] = [];\n for (let index = 0; index < this.#storage.length; index++) {\n const key = this.#storage.key(index);\n if (key?.startsWith(prefix)) {\n ids.push(key.slice(prefix.length));\n }\n }\n return ids;\n }\n\n dispose(): void {\n if (this.#storageListener && typeof globalThis.removeEventListener === 'function') {\n globalThis.removeEventListener('storage', this.#storageListener);\n }\n // Allow safe reuse after disposal: drop cached atoms and their reverse-key entries.\n this.#atoms.clear();\n this.#byStorageKey.clear();\n }\n\n #read<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, storageKey: string): T {\n const raw = this.#storage?.getItem(storageKey);\n if (raw == null) {\n return aspect.defaultValue();\n }\n try {\n return Schema.decodeUnknownSync(aspect.schema)(JSON.parse(raw));\n } catch {\n // Tolerate stale/corrupt entries (e.g., a prior schema shape) by falling back to the default.\n return aspect.defaultValue();\n }\n }\n}\n\nexport const createDefaultBackends = (\n registry: Registry.AtomRegistry,\n): Record<ViewState.BackendName, ViewState.Backend> => ({\n memory: new MemoryBackend(),\n local: new LocalBackend({ registry }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAa,mBAAb,MAA8B;CAC5B,uBAAgB,IAAI,IAAsC;CAC1D;CACA;CAEA,YAAY,UAAiC,UAAoB,CAAC,GAAG;EACnE,KAAK,YAAY;EACjB,KAAK,eAAe,KAAK,KAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS;EAC/D,IAAI,QAAQ,SAAS,GACnB,KAAK,OAAO,OAAO;CAEvB;;;;CAKA,IAAI,UAA+B;EACjC,OAAO,KAAK;CACd;;;;CAKA,aAAgC;EAC9B,OAAO,KAAK,UAAU,IAAI,KAAK,YAAY;CAC7C;;;;CAKA,iBAAiB,IAAsD;EACrE,KAAK,UAAU,IAAI,KAAK,YAAY;EACpC,OAAO,KAAK,UAAU,UAAU,KAAK,oBAAoB;GACvD,GAAG,K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E,WAAW,oBAAoB,WAAW,KAAK,gBAAgB;EAGjE,KAAK,OAAO,MAAM;EAClB,KAAK,cAAc,MAAM;CAC3B;CAEA,MAAkB,QAAsC,YAAuB;EAC7E,MAAM,MAAM,KAAK,UAAU,QAAQ,UAAU;EAC7C,IAAI,OAAO,MACT,OAAO,OAAO,aAAa;EAE7B,IAAI;GACF,OAAO,OAAO,kBAAkB,OAAO,MAAM,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC;EAChE,QAAQ;GAEN,OAAO,OAAO,aAAa;EAC7B;CACF;AACF;AAEA,IAAa,yBACX,cACsD;CACtD,QAAQ,IAAI,cAAc;CAC1B,OAAO,IAAI,aAAa,EAAE,SAAS,CAAC;AACtC"}
|
|
1
|
+
{"version":3,"file":"chunk-types.mjs","names":["resolve","aspect","aspect"],"sources":["../../src/types/Activity.ts","../../src/types/Attention.ts","../../src/types/ViewState.ts","../../src/types/ScrollPosition.ts","../../src/types/Selection.ts","../../src/types/ViewLocation.ts","../../src/core/backends.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Hue, type Label } from '@dxos/ui-types';\n\n/**\n * The places on the attention glyph an activity can draw: the square's fill, the mark inside it, its edge, and a dot\n * at its corner. Each holds at most one treatment.\n */\nexport type Slot = 'fill' | 'mark' | 'edge' | 'corner';\n\n/** The slots in drawing order, back to front. */\nexport const Slots: readonly Slot[] = ['fill', 'mark', 'edge', 'corner'];\n\n/** A mark the glyph draws itself; any other mark is a Phosphor icon id (e.g. `ph--warning--fill`). */\nexport type MarkShape = 'dot' | 'dots' | 'star';\n\n/** What every treatment carries, whatever its slot. */\ntype Common = {\n /** Within a slot the highest priority wins, and a tie goes to the first requested. */\n readonly priority: number;\n /** Asks for the slot's motion; at most one slot moves (see {@link resolve}). */\n readonly animate?: boolean;\n};\n\n/** A wash of colour behind the mark. Attention always takes the fill first. */\nexport type Fill = Common & {\n readonly slot: 'fill';\n readonly hue: Hue;\n /** How much of the hue shows, from 0 to 1; 0.25 when unset. */\n readonly opacity?: number;\n};\n\nexport type Mark = Common & {\n readonly slot: 'mark';\n readonly icon: MarkShape | (string & {});\n /** The text colour when unset. */\n readonly hue?: Hue;\n};\n\n/** An outline around the square, dashed for something due rather than under way. */\nexport type Edge = Omit<Common, 'animate'> & {\n readonly slot: 'edge';\n readonly hue: Hue;\n readonly dashed?: boolean;\n};\n\n/** A dot, or a ring, just outside the square's top-right corner. */\nexport type Corner = Common & {\n readonly slot: 'corner';\n readonly hue: Hue;\n readonly shape?: 'dot' | 'ring';\n};\n\n/** How one activity draws: which slot it claims, what it draws there and how strongly it claims it. */\nexport type Treatment = Fill | Mark | Edge | Corner;\n\n/** Something happening on an object, as one line of the glyph's tooltip and, optionally, one treatment on it. */\nexport type Entry = {\n /** Who reported it, e.g. `presence` or `assistant`. */\n readonly source: string;\n /** Shown in the tooltip whether or not the treatment wins its slot. */\n readonly label: Label;\n readonly treatment?: Treatment;\n};\n\n/** Which slot keeps its motion when several animate: what asks for you first, then who is there. */\nconst MOTION_ORDER: readonly ('corner' | 'mark' | 'fill')[] = ['corner', 'mark', 'fill'];\n\n/** What the glyph draws: the winning treatment per slot, and the one slot whose treatment animates. */\nexport type Resolved = {\n readonly fill?: Fill;\n readonly mark?: Mark;\n readonly edge?: Edge;\n readonly corner?: Corner;\n readonly moving?: Slot;\n};\n\nexport type ResolveOptions = {\n /** The item is attended, or contains the attended item: attention holds the fill, still, over any treatment. */\n readonly attention?: boolean;\n};\n\ntype InSlot<S extends Slot> = Extract<Treatment, { slot: S }>;\n\nconst winner = <S extends Slot>(treatments: readonly Treatment[], slot: S): InSlot<S> | undefined =>\n treatments\n .filter((treatment): treatment is InSlot<S> => treatment.slot === slot)\n .reduce<InSlot<S> | undefined>(\n (best, treatment) => (!best || treatment.priority > best.priority ? treatment : best),\n undefined,\n );\n\n/**\n * Reduces any set of requested treatments to one per slot by priority, then lets only the first animated slot in\n * {@link MOTION_ORDER} move, so every combination draws at most four things and animates at most one.\n */\nexport const resolve = (treatments: Iterable<Treatment>, { attention }: ResolveOptions = {}): Resolved => {\n const requested = [...treatments];\n const resolved = {\n fill: attention ? undefined : winner(requested, 'fill'),\n mark: winner(requested, 'mark'),\n edge: winner(requested, 'edge'),\n corner: winner(requested, 'corner'),\n };\n const moving = MOTION_ORDER.find((slot) => resolved[slot]?.animate);\n\n return { ...resolved, moving };\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\n\nexport type Attention = {\n hasAttention: boolean;\n isAncestor: boolean;\n isRelated: boolean;\n};\n\n/**\n * Manages attention state for an application.\n * Attention keys are slash-qualified graph IDs; ancestry is derived from progressive prefixes.\n */\nexport class AttentionManager {\n readonly #map = new Map<string, Atom.Writable<Attention>>();\n readonly #currentAtom: Atom.Writable<string[]>;\n readonly #registry: Registry.AtomRegistry;\n\n constructor(registry: Registry.AtomRegistry, initial: string[] = []) {\n this.#registry = registry;\n this.#currentAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Atom for the currently attended element IDs.\n */\n get current(): Atom.Atom<string[]> {\n return this.#currentAtom;\n }\n\n /**\n * Gets the currently attended element IDs.\n */\n getCurrent(): readonly string[] {\n return this.#registry.get(this.#currentAtom);\n }\n\n /**\n * Subscribe to changes in the current attention IDs.\n */\n subscribeCurrent(cb: (current: readonly string[]) => void): () => void {\n this.#registry.get(this.#currentAtom);\n return this.#registry.subscribe(this.#currentAtom, () => {\n cb(this.#registry.get(this.#currentAtom));\n });\n }\n\n /**\n * All tracked qualified IDs.\n */\n keys(): string[] {\n return Array.from(this.#map.keys());\n }\n\n /**\n * Get the attention state for a given qualified ID.\n */\n get(id: string): Attention {\n const atom = this.#getAtom(id);\n return this.#registry.get(atom);\n }\n\n /**\n * Subscribe to changes in the attention state for a given qualified ID.\n */\n subscribe(id: string, cb: (attention: Attention) => void): () => void {\n const atom = this.#getAtom(id);\n this.#registry.get(atom);\n return this.#registry.subscribe(atom, () => {\n cb(this.#registry.get(atom));\n });\n }\n\n #getAtom(id: string): Atom.Writable<Attention> {\n const existing = this.#map.get(id);\n if (existing) {\n return existing;\n }\n\n const newAtom = Atom.make<Attention>({ hasAttention: false, isAncestor: false, isRelated: false }).pipe(\n Atom.keepAlive,\n );\n this.#map.set(id, newAtom);\n return newAtom;\n }\n\n /**\n * Update the currently attended element.\n * Takes the array of qualified IDs collected from the DOM; the first element is the primary attended item.\n * Ancestry is derived from the progressive prefixes of the primary ID.\n * Relatedness is derived from the segment ID: any tracked key whose last `/` segment matches the\n * attended ID's segment ID is marked `isRelated`. Additionally, if the primary ID is a linked segment\n * (starts with `~`), its immediate parent gets `isRelated` alongside `isAncestor`.\n *\n * @internal\n */\n update(nextIds: string[]): void {\n const primaryId = nextIds[0];\n if (!primaryId) {\n return;\n }\n\n const currentIds = this.getCurrent();\n const prevPrimaryId = currentIds[0];\n // Clear previous attention state: ancestors, primary, and related keys.\n if (prevPrimaryId) {\n const prevPrefixes = expandAttendableId(prevPrimaryId);\n for (const prefix of prevPrefixes) {\n this.#set(prefix, {});\n }\n const prevSegmentId = getSegmentId(prevPrimaryId);\n for (const key of this.keys()) {\n if (getSegmentId(key) === prevSegmentId) {\n this.#set(key, {});\n }\n }\n }\n\n this.#registry.set(this.#currentAtom, nextIds);\n\n // Set ancestors and primary.\n const prefixes = expandAttendableId(primaryId);\n const prefixSet = new Set(prefixes);\n const linkedParent = isLinkedSegment(primaryId) ? getParentId(primaryId) : undefined;\n\n for (const prefix of prefixes) {\n if (prefix === primaryId) {\n this.#set(prefix, { hasAttention: true });\n } else if (prefix === linkedParent) {\n this.#set(prefix, { isAncestor: true, isRelated: true });\n } else {\n this.#set(prefix, { isAncestor: true });\n }\n }\n\n // Set related keys: any tracked key sharing the same segment ID.\n const segmentId = getSegmentId(primaryId);\n for (const key of this.keys()) {\n if (!prefixSet.has(key) && getSegmentId(key) === segmentId) {\n this.#set(key, { isRelated: true });\n }\n }\n }\n\n #set(id: string, attention: Partial<Attention>): void {\n const atom = this.#getAtom(id);\n this.#registry.set(atom, {\n hasAttention: attention.hasAttention ?? false,\n isAncestor: attention.isAncestor ?? false,\n isRelated: attention.isRelated ?? false,\n });\n }\n}\n\n/** The attribute marking an element as attendable, carrying its qualified id. */\nexport const ATTENDABLE_ATTRIBUTE = 'data-attendable-id';\n\n/** Selector matching any attendable element. */\nexport const ATTENDABLE_SELECTOR = `[${ATTENDABLE_ATTRIBUTE}]`;\n\n/**\n * Accumulates all attendable IDs between the element provided and the root, inclusive.\n * Each `data-attendable-id` value is treated as a single qualified ID (no splitting).\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute(ATTENDABLE_ATTRIBUTE);\n if (!attendableId) {\n // This has an id of an aria-controls elsewhere on the page, move cursor to that trigger.\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(attendableId);\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\n/**\n * Attend `element` the way focusing it would, without moving focus. Answers the attended ids, or\n * undefined when nothing changed: an element outside any attendable leaves attention where it was.\n */\nexport const attendElement = (attention: AttentionManager, element: Element): string[] | undefined => {\n const selector = [\n ATTENDABLE_SELECTOR,\n ...Array.from(document.querySelectorAll('[aria-controls]')).map(\n (el) => `[id=\"${el.getAttribute('aria-controls')}\"]`,\n ),\n ].join(',');\n const prev = attention.getCurrent();\n const next = getAttendables(selector, element);\n if (next.length === 0 || (prev.length === next.length && prev.every((id, index) => next[index] === id))) {\n return undefined;\n }\n\n attention.update(next);\n return next;\n};\n\n/**\n * The outermost attendable ancestor of `element` — the root of any nested attendables (e.g. a section\n * within a stack). Structural (real DOM ancestry), so it is independent of what currently has attention.\n * Resolve it from an in-DOM element: a portaled subtree (a menu, a popover) is not under its own\n * attendable, so walk from the trigger or anchor instead.\n */\nexport const getRootAttendableId = (element: Element): string | undefined =>\n getAttendables(ATTENDABLE_SELECTOR, element).at(-1);\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n\n/**\n * Prefix for linked segments. A linked segment's attention state is shared with its parent:\n * when a linked node has attention, the parent is marked as both ancestor and related.\n */\nconst LINKED_PREFIX = '~';\n\n/**\n * Decompose a qualified graph ID into progressive prefixes for ancestry tracking.\n * e.g. `root/a/b/c` yields `['root', 'root/a', 'root/a/b', 'root/a/b/c']`.\n */\nexport const expandAttendableId = (qualifiedId: string): string[] => {\n const segments = qualifiedId.split('/');\n return segments.map((_, index) => segments.slice(0, index + 1).join('/'));\n};\n\n/**\n * Whether the last segment of a qualified ID is a linked segment (starts with `~`).\n * Linked segments share their attention state with the parent node.\n */\nexport const isLinkedSegment = (qualifiedId: string): boolean => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX);\n};\n\n/**\n * Build a linked segment ID from a variant name (e.g., `'settings'` -> `'~settings'`).\n * Nodes identified by linked segments share their attention state with the parent node.\n */\nexport const linkedSegment = (variant: string): string => `${LINKED_PREFIX}${variant}`;\n\n/**\n * Extract the variant name from the last segment of a qualified ID, stripping the linked prefix.\n * e.g. `'root/space/obj/~settings'` -> `'settings'`.\n * If the segment is not linked (no `~` prefix), returns the segment as-is.\n */\nexport const getLinkedVariant = (qualifiedId: string): string => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX) ? lastSegment.slice(LINKED_PREFIX.length) : lastSegment;\n};\n\n/**\n * Get the parent qualified ID (everything before the last `/` segment).\n */\nexport const getParentId = (qualifiedId: string | undefined): string | undefined => {\n if (!qualifiedId) {\n return undefined;\n }\n\n const lastSlash = qualifiedId.lastIndexOf('/');\n return lastSlash > 0 ? qualifiedId.slice(0, lastSlash) : undefined;\n};\n\n/**\n * Extract the segment ID (last segment) of a qualified ID.\n */\nexport const getSegmentId = (qualifiedId: string): string => {\n return qualifiedId.split('/').pop() ?? qualifiedId;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport type * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport * as Schema from 'effect/Schema';\n\nimport { EID } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\n/**\n * Persistence backend identifier. `personal` (ECHO/personal-space) is reserved for a future backend.\n */\nexport type BackendName = 'memory' | 'local';\n\n/**\n * How a session following another takes the leader's values of an aspect: `write` sets them into its own view state,\n * which the view already reads; `reveal` leaves them to the follow, for state a view reports but does not read back.\n */\nexport type FollowPolicy = 'write' | 'reveal';\n\n/**\n * What of an aspect a follower takes: the whole value under a policy, or only the named fields of a struct value,\n * which a `write` follower merges into its own value.\n */\nexport type Follow<T> =\n | FollowPolicy\n | { readonly policy: FollowPolicy; readonly fields: ReadonlyArray<keyof T & string> };\n\n/** Whether a value was set by this session or written from the session it follows. */\nexport type Origin = 'local' | 'follow';\n\nexport const getFollowPolicy = (aspect: Aspect<any, any>): FollowPolicy | undefined =>\n typeof aspect.follow === 'object' ? aspect.follow.policy : aspect.follow;\n\n/**\n * Declares a kind of per-context UI state. The value type `T` and its persisted wire type `Encoded`\n * are inferred from the schema; `Encoded` defaults to `T` for the common no-transform case.\n */\nexport interface Aspect<T, Encoded = T> {\n readonly key: string;\n readonly backend: BackendName;\n readonly schema: Schema.Codec<T, Encoded>;\n readonly defaultValue: () => T;\n /** Set for state a follower takes from the session it follows; contexts are then EIDs of the space or its objects. */\n readonly follow?: Follow<T>;\n}\n\n/**\n * Identity helper that pins the value type from the schema while keeping the literal `key`/`backend`.\n * Declares an aspect of per-context UI state (selection, scroll, view mode, split) read/written via\n * {@link Manager} — through `useViewState`/`useViewStateActions` in React or the\n * `AttentionCapabilities.ViewState` capability in operations. Durability is the `backend`'s: `local`\n * survives reloads (best-effort — degrades to in-memory when storage is blocked), `memory` is\n * session-only.\n *\n * @idiom org.dxos.react-ui-attention.viewState\n * applies: Holding per-context UI state (selection, view mode, scroll, split) that survives navigation (and reloads with the `local` backend)\n * instead-of: ad-hoc `useState` that resets on remount, or stuffing per-context state into the plugin Settings store\n * uses: {@link define}, {@link Manager}\n * related: org.dxos.effect.kvsStore\n */\nexport const define = <T, Encoded = T>(def: Aspect<T, Encoded>): Aspect<T, Encoded> => def;\n\n/** Encoded fields to merge over one aspect's value for one context; plain JSON, so it can cross an operation. */\nexport const Patch = Schema.Struct({\n aspect: Schema.String.annotate({ description: \"The aspect's key.\" }),\n context: Schema.String.annotate({ description: 'The context the aspect is keyed by.' }),\n fields: Schema.Record(Schema.String, Schema.Unknown).annotate({\n description: \"Encoded top-level fields, merged over the aspect's current value.\",\n }),\n});\n\nexport type Patch = Schema.Schema.Type<typeof Patch>;\n\n/** A patch setting `fields` of `aspect` for `context`, encoded by the aspect's schema. */\nexport const patch = <T extends object, Encoded>(\n aspect: Aspect<T, Encoded>,\n context: string,\n fields: Partial<T>,\n): Patch => {\n const encoded = Schema.encodeUnknownSync(Schema.toCodecJson(aspect.schema))({ ...aspect.defaultValue(), ...fields });\n return {\n aspect: aspect.key,\n context,\n fields: isRecord(encoded) ? pickKeys(encoded, Object.keys(fields)) : {},\n };\n};\n\n/**\n * A backend produces a reactive, writable atom for each `(aspect, contextId)` pair. Backends may\n * hydrate asynchronously (an ECHO backend would), yielding `aspect.defaultValue()` until loaded;\n * the memory and local backends resolve synchronously.\n */\nexport interface Backend {\n /** Stable atom for the pair; created (and seeded) on first access, cached thereafter. */\n atom: <T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string) => Atom.Writable<T>;\n /** Persist a value after the atom is updated. No-op for in-memory backends. */\n persist?: <T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, value: T) => void;\n /** Context ids that currently hold a value for the aspect. */\n contexts: <T, Encoded>(aspect: Aspect<T, Encoded>) => string[];\n /** Release listeners/timers (used by tests; app-lifetime managers do not call this). */\n dispose?: () => void;\n}\n\nexport interface ManagerOptions {\n readonly registry: Registry.AtomRegistry;\n readonly backends: Record<BackendName, Backend>;\n}\n\n/**\n * Routes per-context UI state to the backend declared by each aspect. Reads/writes go through the\n * effect-atom registry so React hooks and graph atoms observe changes uniformly.\n */\nexport class Manager {\n readonly #registry: Registry.AtomRegistry;\n readonly #backends: Record<BackendName, Backend>;\n // Aspects are declared where they are used, so the manager learns them from the calls that pass them.\n readonly #aspects = new Map<string, Aspect<any, any>>();\n // A leader's encoded values of an aspect this session has not used yet, decoded when it first is.\n readonly #pending = new Map<string, Map<string, unknown>>();\n // Patches to an aspect this session has not used yet, applied in order when it first is.\n readonly #pendingPatches = new Map<string, Patch[]>();\n readonly #followListeners = new Set<(key: string, contextId: string) => void>();\n // Values written from the followed session, by aspect key and context; a local write clears its entry.\n readonly #fromFollow = new Set<string>();\n // Followed aspects already warned about for a context that is not an EID.\n readonly #warned = new Set<string>();\n\n constructor({ registry, backends }: ManagerOptions) {\n this.#registry = registry;\n this.#backends = backends;\n }\n\n /** Reactive atom for `(aspect, contextId)`; pass to `registry.get` inside derived atoms/hooks. */\n atom<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n this.#learn(aspect);\n if (aspect.follow && !EID.isEID(contextId) && !this.#warned.has(aspect.key)) {\n this.#warned.add(aspect.key);\n log.warn('a followed aspect is keyed by something other than an EID, so it is never followed', {\n aspect: aspect.key,\n contextId,\n });\n }\n return this.#backends[aspect.backend].atom(aspect, contextId);\n }\n\n get<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string): T {\n return this.#registry.get(this.atom(aspect, contextId));\n }\n\n set<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, value: T): void {\n this.#write(aspect, contextId, value, 'local');\n }\n\n /** Whether the value of `(aspect, contextId)` was set here or written from the followed session. */\n origin<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string): Origin {\n return this.#fromFollow.has(originKey(aspect.key, contextId)) ? 'follow' : 'local';\n }\n\n #write<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, value: T, origin: Origin): void {\n const backend = this.#backends[aspect.backend];\n if (origin === 'follow') {\n this.#fromFollow.add(originKey(aspect.key, contextId));\n } else {\n this.#fromFollow.delete(originKey(aspect.key, contextId));\n }\n this.#registry.set(this.atom(aspect, contextId), value);\n backend.persist?.(aspect, contextId, value);\n if (aspect.follow) {\n this.#followListeners.forEach((listener) => listener(aspect.key, contextId));\n }\n }\n\n update<T, Encoded>(aspect: Aspect<T, Encoded>, contextId: string, fn: (prev: T) => T): void {\n this.set(aspect, contextId, fn(this.get(aspect, contextId)));\n }\n\n subscribe<T, Encoded>(\n aspect: Aspect<T, Encoded>,\n contextId: string,\n cb: (value: T, origin: Origin) => void,\n ): () => void {\n const atom = this.atom(aspect, contextId);\n return this.#registry.subscribe(atom, () => cb(this.#registry.get(atom), this.origin(aspect, contextId)));\n }\n\n contexts<T, Encoded>(aspect: Aspect<T, Encoded>): string[] {\n this.#learn(aspect);\n return this.#backends[aspect.backend].contexts(aspect);\n }\n\n /** The aspect with `key`, once this session has used it. */\n aspect(key: string): Aspect<unknown, unknown> | undefined {\n return this.#aspects.get(key);\n }\n\n /** This session's values of every followed aspect it has used, encoded as JSON, by aspect key and then context. */\n followed(contextIds: readonly string[]): Record<string, Record<string, Schema.Json>> {\n return Object.fromEntries(\n [...this.#aspects.values()].flatMap((aspect) => {\n if (!aspect.follow) {\n return [];\n }\n const held = new Set(this.contexts(aspect));\n const values = Object.fromEntries(\n contextIds.flatMap((contextId) =>\n held.has(contextId)\n ? Option.match(this.#encode(aspect, contextId), {\n onNone: () => [],\n onSome: (json) => [[contextId, pickFollowed(aspect, json)]],\n })\n : [],\n ),\n );\n return Object.keys(values).length > 0 ? [[aspect.key, values]] : [];\n }),\n );\n }\n\n /** Calls `listener` when a followed aspect's value is set. */\n subscribeFollowed(listener: (key: string, contextId: string) => void): () => void {\n this.#followListeners.add(listener);\n return () => this.#followListeners.delete(listener);\n }\n\n /** Sets a leader's encoded value of a `write` aspect; one not used yet is held until it is, and one that does not decode is dropped. */\n setEncoded(key: string, contextId: string, value: unknown): void {\n const aspect = this.#aspects.get(key);\n if (aspect) {\n this.#decodeInto(aspect, contextId, value);\n } else {\n this.#pending.set(key, (this.#pending.get(key) ?? new Map()).set(contextId, value));\n }\n }\n\n /**\n * Merges a patch's fields over its aspect's value for its context, as a local write. A patch to an aspect this\n * session has not used yet is held until it is; one whose merged value does not decode is dropped.\n */\n apply(patch: Patch): void {\n const aspect = this.#aspects.get(patch.aspect);\n if (aspect) {\n this.#patchInto(aspect, patch);\n } else {\n this.#pendingPatches.set(patch.aspect, [...(this.#pendingPatches.get(patch.aspect) ?? []), patch]);\n }\n }\n\n #learn(aspect: Aspect<any, any>): void {\n if (this.#aspects.has(aspect.key)) {\n return;\n }\n this.#aspects.set(aspect.key, aspect);\n const pending = this.#pending.get(aspect.key);\n this.#pending.delete(aspect.key);\n pending?.forEach((value, contextId) => this.#decodeInto(aspect, contextId, value));\n const patches = this.#pendingPatches.get(aspect.key);\n this.#pendingPatches.delete(aspect.key);\n patches?.forEach((patch) => this.#patchInto(aspect, patch));\n }\n\n #patchInto(aspect: Aspect<any, any>, { context, fields }: Patch): void {\n const own = this.#encode(aspect, context).pipe(\n Option.filter(isRecord),\n Option.getOrElse(() => ({})),\n );\n Option.match(Schema.decodeUnknownOption(Schema.toCodecJson(aspect.schema))({ ...own, ...fields }), {\n onNone: () => log.warn('dropped a view-state patch that does not decode', { aspect: aspect.key, context }),\n onSome: (decoded) => this.#write(aspect, context, decoded, 'local'),\n });\n }\n\n #encode(aspect: Aspect<any, any>, contextId: string): Option.Option<Schema.Json> {\n return Schema.encodeUnknownOption(Schema.toCodecJson(aspect.schema))(this.get(aspect, contextId));\n }\n\n // Only a `write` aspect takes a leader's value; a `reveal` one is the follow's to apply. An aspect that follows some\n // fields takes the leader's values of those over its own value.\n #decodeInto(aspect: Aspect<any, any>, contextId: string, value: unknown): void {\n if (getFollowPolicy(aspect) !== 'write') {\n return;\n }\n const merged =\n typeof aspect.follow === 'object' && isRecord(value)\n ? Option.match(this.#encode(aspect, contextId), {\n onNone: () => value,\n onSome: (own) => ({ ...(isRecord(own) ? own : {}), ...pickFields(aspect, value) }),\n })\n : value;\n Option.match(Schema.decodeUnknownOption(Schema.toCodecJson(aspect.schema))(merged), {\n onNone: () => {},\n onSome: (decoded) => this.#write(aspect, contextId, decoded, 'follow'),\n });\n }\n}\n\nconst originKey = (key: string, contextId: string) => `${key}\\n${contextId}`;\n\nconst isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isJsonObject = (value: Schema.Json): value is Schema.JsonObject => isRecord(value);\n\nconst pickKeys = <V>(record: Readonly<Record<string, V>>, keys: readonly string[]): Record<string, V> =>\n Object.fromEntries(Object.entries(record).filter(([key]) => keys.includes(key)));\n\nconst pickFields = <V>(aspect: Aspect<any, any>, record: Readonly<Record<string, V>>): Record<string, V> =>\n pickKeys(record, typeof aspect.follow === 'object' ? aspect.follow.fields : []);\n\n// An aspect that follows some fields sends only those; struct fields encode under their own names.\nconst pickFollowed = (aspect: Aspect<any, any>, json: Schema.Json): Schema.Json =>\n typeof aspect.follow === 'object' && isJsonObject(json) ? pickFields(aspect, json) : json;\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type Aspect, define } from './ViewState.ts';\n\n/** Where one scrolling area is scrolled to; see `ScrollArea.ScrollPosition` in react-ui. */\nexport const Position = Schema.Struct({\n anchor: Schema.optional(Schema.String),\n offset: Schema.optional(Schema.Number),\n y: Schema.Number,\n x: Schema.optional(Schema.Number),\n});\n\nexport type Position = Schema.Schema.Type<typeof Position>;\n\n/** The position of each tracked scrolling area in an object's view, by area name (`main` for the outermost). */\nexport const State = Schema.Record(Schema.String, Position);\n\nexport type State = Schema.Schema.Type<typeof State>;\n\n/**\n * The scroll of an object's article, keyed by the object's EID and kept for the session, so a view comes back where it\n * was left; a follower takes the leader's.\n */\nexport const aspect: Aspect<State> = define<State>({\n key: 'org.dxos.react-ui-attention.scroll',\n backend: 'memory',\n schema: State,\n defaultValue: () => ({}),\n follow: 'write',\n});\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type Aspect, type Manager, define } from './ViewState.ts';\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const Selection = Schema.Union([\n Schema.Struct({\n mode: Schema.Literal('single'),\n id: Schema.optional(Schema.String),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('multi'),\n ids: Schema.Array(Schema.String).pipe(Schema.mutable),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).mapFields(Struct.map(Schema.mutableKey)),\n Schema.Struct({\n mode: Schema.Literal('multi-range'),\n ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),\n }).mapFields(Struct.map(Schema.mutableKey)),\n]);\n\nexport type Selection = Schema.Schema.Type<typeof Selection>;\n\nexport const defaultValue = Match.type<SelectionMode>().pipe(\n Match.withReturnType<Selection>(),\n Match.when('single', () => ({ mode: 'single' })),\n Match.when('multi', () => ({ mode: 'multi', ids: [] })),\n Match.when('range', () => ({ mode: 'range' })),\n Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),\n Match.exhaustive,\n);\n\nexport type Result<T extends SelectionMode> = T extends 'single'\n ? string | undefined\n : T extends 'multi'\n ? string[]\n : T extends 'range'\n ? { from: string; to: string } | undefined\n : T extends 'multi-range'\n ? { from: string; to: string }[]\n : never;\n\n/** Selection state for a context, stored in memory (ephemeral, per-device session). */\nexport const aspect: Aspect<Selection> = define<Selection>({\n key: 'selection',\n backend: 'memory',\n schema: Selection,\n defaultValue: () => ({ mode: 'multi', ids: [] }),\n});\n\n/**\n * Extract the typed result for `mode` from a stored selection value, returning the requested\n * mode's default when the stored value is absent or holds a different mode.\n */\nexport const resolve = <T extends SelectionMode>(selection: Selection | undefined, mode: T): Result<T> => {\n const value = selection?.mode === mode ? selection : defaultValue(mode);\n // Cast required because TypeScript cannot relate the `Match` result to the generic `T`.\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(value) as Result<T>;\n};\n\n/** Toggle `id` within a multi selection; resets to a multi selection if the current value differs. */\nexport const toggle = (selection: Selection | undefined, id: string): Selection => {\n const ids = selection?.mode === 'multi' ? selection.ids : [];\n return { mode: 'multi', ids: ids.includes(id) ? ids.filter((existing) => existing !== id) : [...ids, id] };\n};\n\n/** Anchor strings for a selection: ids for single/multi modes, `\"${from}:${to}\"` cursor pairs for range modes. */\nexport const toAnchors = (selection: Selection | undefined): string[] =>\n selection == null\n ? []\n : Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (value) => (value.id ? [value.id] : [])),\n Match.when({ mode: 'multi' }, (value) => [...value.ids]),\n Match.when({ mode: 'range' }, (value) => (value.from && value.to ? [`${value.from}:${value.to}`] : [])),\n Match.when({ mode: 'multi-range' }, (value) => value.ranges.map((range) => `${range.from}:${range.to}`)),\n Match.exhaustive,\n )(selection);\n\n/** Union of all multi-selected ids across every selection context, plus an optional explicit id. */\nexport const getValue = (manager: Manager, contextId?: string): Set<string> => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of manager.contexts(aspect)) {\n const selection = manager.get(aspect, context);\n if (selection.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n\n return ids;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type Aspect, define } from './ViewState.ts';\n\n/**\n * Where the local user is in an object, as anchors in the object type's own format (the format its\n * comments and its `Locator` use), so a peer's view of the same object can reveal it.\n */\nexport const ViewLocation = Schema.Struct({\n /** The caret or selection. */\n selection: Schema.optional(Schema.String),\n /** The top of what the view shows. */\n viewport: Schema.optional(Schema.String),\n});\n\nexport type ViewLocation = Schema.Schema.Type<typeof ViewLocation>;\n\n/** View location for an object, keyed by the object's URI and stored in memory (ephemeral, per-device session). */\nexport const aspect: Aspect<ViewLocation> = define<ViewLocation>({\n key: 'view-location',\n backend: 'memory',\n schema: ViewLocation,\n defaultValue: () => ({}),\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport * as Schema from 'effect/Schema';\n\nimport { ViewState } from '../types/index.ts';\n\n// Only the stable `key` string is needed to form the map key; avoids variance issues with Aspect<T>.\nconst cacheKey = (aspect: { key: string }, contextId: string) => `${aspect.key}:${contextId}`;\n\n/** In-memory backend: state is ephemeral and scoped to the session (never persisted). */\nexport class MemoryBackend implements ViewState.Backend {\n readonly #atoms = new Map<string, Atom.Writable<unknown>>();\n\n atom<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n const key = cacheKey(aspect, contextId);\n let atom = this.#atoms.get(key);\n if (!atom) {\n // `keepAlive` pins the node so a written value survives for the session; without it the registry\n // sweeps the unsubscribed atom back to its default, dropping state that no UI happens to observe\n // (e.g. a selection read on-demand by an agent tool rather than a live subscriber).\n atom = Atom.make<unknown>(aspect.defaultValue()).pipe(Atom.keepAlive);\n this.#atoms.set(key, atom);\n }\n // Cast bridges the per-aspect value type erased by the shared atom map; safe by construction.\n return atom as Atom.Writable<T>;\n }\n\n contexts<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>): string[] {\n const prefix = `${aspect.key}:`;\n return [...this.#atoms.keys()].filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));\n }\n}\n\nconst STORAGE_PREFIX = 'dxos:view-state:';\n\nconst storageKeyFor = (aspect: { key: string }, contextId: string) => `${STORAGE_PREFIX}${aspect.key}:${contextId}`;\n\n// Accessing `globalThis.localStorage` can throw a SecurityError in sandboxed iframes or when\n// storage is blocked; degrade to in-memory behaviour instead of crashing.\nconst safeLocalStorage = (): Storage | undefined => {\n try {\n return globalThis.localStorage;\n } catch {\n return undefined;\n }\n};\n\nexport interface LocalBackendOptions {\n readonly registry: Registry.AtomRegistry;\n /** Injectable for tests; defaults to `window.localStorage`. */\n readonly storage?: Storage;\n}\n\n/** localStorage-backed backend: seeds atoms from storage, persists on set, syncs across tabs. */\nexport class LocalBackend implements ViewState.Backend {\n readonly #registry: Registry.AtomRegistry;\n // Absent in non-browser contexts (SSR/tests without injection); the backend then degrades to\n // ephemeral, in-memory behaviour rather than crashing on a missing `localStorage`.\n readonly #storage: Storage | undefined;\n readonly #atoms = new Map<string, Atom.Writable<unknown>>();\n // Reverse map: storage key -> (aspect, contextId) so `storage` events can target the right atom.\n readonly #byStorageKey = new Map<string, { aspect: ViewState.Aspect<unknown, unknown>; contextId: string }>();\n #storageListener?: (event: StorageEvent) => void;\n\n constructor({ registry, storage }: LocalBackendOptions) {\n this.#registry = registry;\n this.#storage = storage ?? safeLocalStorage();\n if (this.#storage && typeof globalThis.addEventListener === 'function') {\n this.#storageListener = (event) => {\n if (!event.key || !event.key.startsWith(STORAGE_PREFIX)) {\n return;\n }\n const entry = this.#byStorageKey.get(event.key);\n const atom = entry && this.#atoms.get(cacheKey(entry.aspect, entry.contextId));\n if (entry && atom) {\n this.#registry.set(atom, this.#read(entry.aspect, event.key));\n }\n };\n globalThis.addEventListener('storage', this.#storageListener);\n }\n }\n\n atom<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string): Atom.Writable<T> {\n const key = cacheKey(aspect, contextId);\n let atom = this.#atoms.get(key);\n if (!atom) {\n const storageKey = storageKeyFor(aspect, contextId);\n // `keepAlive` pins the node so the in-memory value stays consistent with storage without a live\n // subscriber; otherwise the registry sweeps the unsubscribed atom back to its creation-time seed.\n atom = Atom.make<unknown>(this.#read(aspect, storageKey)).pipe(Atom.keepAlive);\n this.#atoms.set(key, atom);\n // Cast erases the per-aspect value type so the reverse map can hold aspects of any `T`; the\n // stored aspect is only used to re-read/decode its own value, so the erasure is safe.\n this.#byStorageKey.set(storageKey, { aspect: aspect as ViewState.Aspect<unknown, unknown>, contextId });\n }\n // Cast bridges the per-aspect value type erased by the shared atom map; safe by construction.\n return atom as Atom.Writable<T>;\n }\n\n persist<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, contextId: string, value: T): void {\n this.#storage?.setItem(storageKeyFor(aspect, contextId), JSON.stringify(Schema.encodeSync(aspect.schema)(value)));\n }\n\n contexts<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>): string[] {\n if (!this.#storage) {\n // No persistent storage: fall back to the in-memory atoms (mirrors `atom()`'s ephemeral path).\n const prefix = `${aspect.key}:`;\n return [...this.#atoms.keys()].filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));\n }\n const prefix = storageKeyFor(aspect, '');\n const ids: string[] = [];\n for (let index = 0; index < this.#storage.length; index++) {\n const key = this.#storage.key(index);\n if (key?.startsWith(prefix)) {\n ids.push(key.slice(prefix.length));\n }\n }\n return ids;\n }\n\n dispose(): void {\n if (this.#storageListener && typeof globalThis.removeEventListener === 'function') {\n globalThis.removeEventListener('storage', this.#storageListener);\n }\n // Allow safe reuse after disposal: drop cached atoms and their reverse-key entries.\n this.#atoms.clear();\n this.#byStorageKey.clear();\n }\n\n #read<T, Encoded>(aspect: ViewState.Aspect<T, Encoded>, storageKey: string): T {\n const raw = this.#storage?.getItem(storageKey);\n if (raw == null) {\n return aspect.defaultValue();\n }\n try {\n return Schema.decodeUnknownSync(aspect.schema)(JSON.parse(raw));\n } catch {\n // Tolerate stale/corrupt entries (e.g., a prior schema shape) by falling back to the default.\n return aspect.defaultValue();\n }\n }\n}\n\nexport const createDefaultBackends = (\n registry: Registry.AtomRegistry,\n): Record<ViewState.BackendName, ViewState.Backend> => ({\n memory: new MemoryBackend(),\n local: new LocalBackend({ registry }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,QAAyB;CAAC;CAAQ;CAAQ;CAAQ;AAAQ;;AAuDvE,IAAM,eAAwD;CAAC;CAAU;CAAQ;AAAM;AAkBvF,IAAM,UAA0B,YAAkC,SAChE,WACG,QAAQ,cAAsC,UAAU,SAAS,IAAI,CAAC,CACtE,QACE,MAAM,cAAe,CAAC,QAAQ,UAAU,WAAW,KAAK,WAAW,YAAY,MAChF,KAAA,CACF;;;;;AAMJ,IAAaA,aAAW,YAAiC,EAAE,cAA8B,CAAC,MAAgB;CACxG,MAAM,YAAY,CAAC,GAAG,UAAU;CAChC,MAAM,WAAW;EACf,MAAM,YAAY,KAAA,IAAY,OAAO,WAAW,MAAM;EACtD,MAAM,OAAO,WAAW,MAAM;EAC9B,MAAM,OAAO,WAAW,MAAM;EAC9B,QAAQ,OAAO,WAAW,QAAQ;CACpC;CACA,MAAM,SAAS,aAAa,MAAM,SAAS,SAAS,KAAK,EAAE,OAAO;CAElE,OAAO;EAAE,GAAG;EAAU;CAAO;AAC/B;;;;;;;;;;;;;;;;;;;;;AC5FA,IAAa,mBAAb,MAA8B;CAC5B,uBAAgB,IAAI,IAAsC;CAC1D;CACA;CAEA,YAAY,UAAiC,UAAoB,CAAC,GAAG;EACnE,KAAK,YAAY;EACjB,KAAK,eAAe,KAAK,KAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS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