@dxos/react-ui-attention 0.9.1-staging.ee54ba693a → 0.11.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 +308 -0
- package/dist/lib/chunk-ViewStateProvider.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +351 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/index.mjs +149 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/testing.mjs +20 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts +2 -15
- package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts.map +1 -1
- package/dist/types/src/components/AttentionProvider/attention-context.d.ts +20 -0
- package/dist/types/src/components/AttentionProvider/attention-context.d.ts.map +1 -0
- package/dist/types/src/components/AttentionProvider/index.d.ts +1 -0
- package/dist/types/src/components/AttentionProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewStateProvider/ViewStateProvider.d.ts +2 -26
- package/dist/types/src/components/ViewStateProvider/ViewStateProvider.d.ts.map +1 -1
- package/dist/types/src/components/ViewStateProvider/index.d.ts +1 -0
- package/dist/types/src/components/ViewStateProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewStateProvider/view-state-hooks.d.ts +32 -0
- package/dist/types/src/components/ViewStateProvider/view-state-hooks.d.ts.map +1 -0
- package/dist/types/src/core/backends.d.ts +24 -0
- package/dist/types/src/core/backends.d.ts.map +1 -0
- package/dist/types/src/core/backends.test.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +2 -0
- package/dist/types/src/core/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useArticleKeyboardNavigation.d.ts.map +1 -0
- package/dist/types/src/hooks/useArticleKeyboardNavigation.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/{attention.d.ts → types/Attention.d.ts} +13 -2
- package/dist/types/src/types/Attention.d.ts.map +1 -0
- package/dist/types/src/types/Attention.test.d.ts +2 -0
- package/dist/types/src/types/Attention.test.d.ts.map +1 -0
- package/dist/types/src/{selection.d.ts → types/Selection.d.ts} +12 -10
- package/dist/types/src/types/Selection.d.ts.map +1 -0
- package/dist/types/src/types/Selection.test.d.ts +2 -0
- package/dist/types/src/types/Selection.test.d.ts.map +1 -0
- package/dist/types/src/types/ViewState.d.ts +66 -0
- package/dist/types/src/types/ViewState.d.ts.map +1 -0
- package/dist/types/src/types/ViewState.test.d.ts +2 -0
- package/dist/types/src/types/ViewState.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -20
- package/src/components/AttentionProvider/AttentionProvider.stories.tsx +1 -1
- package/src/components/AttentionProvider/AttentionProvider.tsx +4 -86
- package/src/components/AttentionProvider/attention-context.ts +81 -0
- package/src/components/AttentionProvider/index.ts +2 -0
- package/src/components/ViewStateProvider/ViewStateProvider.test.tsx +7 -5
- package/src/components/ViewStateProvider/ViewStateProvider.tsx +6 -110
- package/src/components/ViewStateProvider/index.ts +9 -0
- package/src/components/ViewStateProvider/view-state-hooks.ts +115 -0
- package/src/{view-state → core}/backends.test.ts +5 -5
- package/src/{view-state → core}/backends.ts +24 -17
- package/src/{view-state → core}/index.ts +0 -1
- package/src/hooks/index.ts +5 -0
- package/src/{useArticleKeyboardNavigation.ts → hooks/useArticleKeyboardNavigation.ts} +1 -1
- package/src/index.ts +3 -4
- package/src/testing/decorators/withAttention.ts +2 -2
- package/src/{attention.test.ts → types/Attention.test.ts} +2 -2
- package/src/{attention.ts → types/Attention.ts} +17 -2
- package/src/types/Selection.test.ts +100 -0
- package/src/{selection.ts → types/Selection.ts} +27 -17
- package/src/{view-state/view-state.test.ts → types/ViewState.test.ts} +6 -6
- package/src/types/ViewState.ts +101 -0
- package/src/types/index.ts +8 -7
- package/dist/lib/browser/chunk-4HYAJ4IO.mjs +0 -434
- package/dist/lib/browser/chunk-4HYAJ4IO.mjs.map +0 -7
- package/dist/lib/browser/chunk-I4FDY4AZ.mjs +0 -236
- package/dist/lib/browser/chunk-I4FDY4AZ.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -218
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs +0 -30
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -43
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DLBZMHST.mjs +0 -237
- package/dist/lib/node-esm/chunk-DLBZMHST.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HWN7KJDX.mjs +0 -436
- package/dist/lib/node-esm/chunk-HWN7KJDX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -219
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -31
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -44
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/attention.d.ts.map +0 -1
- package/dist/types/src/attention.test.d.ts +0 -2
- package/dist/types/src/attention.test.d.ts.map +0 -1
- package/dist/types/src/selection.d.ts.map +0 -1
- package/dist/types/src/selection.test.d.ts +0 -2
- package/dist/types/src/selection.test.d.ts.map +0 -1
- package/dist/types/src/useArticleKeyboardNavigation.d.ts.map +0 -1
- package/dist/types/src/useArticleKeyboardNavigation.test.d.ts.map +0 -1
- package/dist/types/src/view-state/backends.d.ts +0 -24
- package/dist/types/src/view-state/backends.d.ts.map +0 -1
- package/dist/types/src/view-state/backends.test.d.ts.map +0 -1
- package/dist/types/src/view-state/index.d.ts +0 -3
- package/dist/types/src/view-state/index.d.ts.map +0 -1
- package/dist/types/src/view-state/view-state.d.ts +0 -54
- package/dist/types/src/view-state/view-state.d.ts.map +0 -1
- package/dist/types/src/view-state/view-state.test.d.ts +0 -2
- package/dist/types/src/view-state/view-state.test.d.ts.map +0 -1
- package/src/selection.test.ts +0 -67
- package/src/view-state/view-state.ts +0 -91
- /package/dist/types/src/{view-state → core}/backends.test.d.ts +0 -0
- /package/dist/types/src/{useArticleKeyboardNavigation.d.ts → hooks/useArticleKeyboardNavigation.d.ts} +0 -0
- /package/dist/types/src/{useArticleKeyboardNavigation.test.d.ts → hooks/useArticleKeyboardNavigation.test.d.ts} +0 -0
- /package/src/{useArticleKeyboardNavigation.test.ts → hooks/useArticleKeyboardNavigation.test.ts} +0 -0
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
// src/attention.ts
|
|
2
|
-
import { Atom } from "@effect-atom/atom-react";
|
|
3
|
-
var AttentionManager = class {
|
|
4
|
-
_registry;
|
|
5
|
-
_map = /* @__PURE__ */ new Map();
|
|
6
|
-
_currentAtom;
|
|
7
|
-
constructor(_registry, initial = []) {
|
|
8
|
-
this._registry = _registry;
|
|
9
|
-
this._currentAtom = Atom.make([]).pipe(Atom.keepAlive);
|
|
10
|
-
if (initial.length > 0) {
|
|
11
|
-
this.update(initial);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Atom for the currently attended element IDs.
|
|
16
|
-
*/
|
|
17
|
-
get current() {
|
|
18
|
-
return this._currentAtom;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Gets the currently attended element IDs.
|
|
22
|
-
*/
|
|
23
|
-
getCurrent() {
|
|
24
|
-
return this._registry.get(this._currentAtom);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Subscribe to changes in the current attention IDs.
|
|
28
|
-
*/
|
|
29
|
-
subscribeCurrent(cb) {
|
|
30
|
-
this._registry.get(this._currentAtom);
|
|
31
|
-
return this._registry.subscribe(this._currentAtom, () => {
|
|
32
|
-
cb(this._registry.get(this._currentAtom));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* All tracked qualified IDs.
|
|
37
|
-
*/
|
|
38
|
-
keys() {
|
|
39
|
-
return Array.from(this._map.keys());
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get the attention state for a given qualified ID.
|
|
43
|
-
*/
|
|
44
|
-
get(id) {
|
|
45
|
-
const atom = this._getAtom(id);
|
|
46
|
-
return this._registry.get(atom);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Subscribe to changes in the attention state for a given qualified ID.
|
|
50
|
-
*/
|
|
51
|
-
subscribe(id, cb) {
|
|
52
|
-
const atom = this._getAtom(id);
|
|
53
|
-
this._registry.get(atom);
|
|
54
|
-
return this._registry.subscribe(atom, () => {
|
|
55
|
-
cb(this._registry.get(atom));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
_getAtom(id) {
|
|
59
|
-
const existing = this._map.get(id);
|
|
60
|
-
if (existing) {
|
|
61
|
-
return existing;
|
|
62
|
-
}
|
|
63
|
-
const newAtom = Atom.make({
|
|
64
|
-
hasAttention: false,
|
|
65
|
-
isAncestor: false,
|
|
66
|
-
isRelated: false
|
|
67
|
-
}).pipe(Atom.keepAlive);
|
|
68
|
-
this._map.set(id, newAtom);
|
|
69
|
-
return newAtom;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Update the currently attended element.
|
|
73
|
-
* Takes the array of qualified IDs collected from the DOM; the first element is the primary attended item.
|
|
74
|
-
* Ancestry is derived from the progressive prefixes of the primary ID.
|
|
75
|
-
* Relatedness is derived from the segment ID: any tracked key whose last `/` segment matches the
|
|
76
|
-
* attended ID's segment ID is marked `isRelated`. Additionally, if the primary ID is a linked segment
|
|
77
|
-
* (starts with `~`), its immediate parent gets `isRelated` alongside `isAncestor`.
|
|
78
|
-
*
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
update(nextIds) {
|
|
82
|
-
const primaryId = nextIds[0];
|
|
83
|
-
if (!primaryId) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const currentIds = this.getCurrent();
|
|
87
|
-
const prevPrimaryId = currentIds[0];
|
|
88
|
-
if (prevPrimaryId) {
|
|
89
|
-
const prevPrefixes = expandAttendableId(prevPrimaryId);
|
|
90
|
-
for (const prefix of prevPrefixes) {
|
|
91
|
-
this._set(prefix, {});
|
|
92
|
-
}
|
|
93
|
-
const prevSegmentId = getSegmentId(prevPrimaryId);
|
|
94
|
-
for (const key of this.keys()) {
|
|
95
|
-
if (getSegmentId(key) === prevSegmentId) {
|
|
96
|
-
this._set(key, {});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this._registry.set(this._currentAtom, nextIds);
|
|
101
|
-
const prefixes = expandAttendableId(primaryId);
|
|
102
|
-
const prefixSet = new Set(prefixes);
|
|
103
|
-
const linkedParent = isLinkedSegment(primaryId) ? getParentId(primaryId) : void 0;
|
|
104
|
-
for (const prefix of prefixes) {
|
|
105
|
-
if (prefix === primaryId) {
|
|
106
|
-
this._set(prefix, {
|
|
107
|
-
hasAttention: true
|
|
108
|
-
});
|
|
109
|
-
} else if (prefix === linkedParent) {
|
|
110
|
-
this._set(prefix, {
|
|
111
|
-
isAncestor: true,
|
|
112
|
-
isRelated: true
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
this._set(prefix, {
|
|
116
|
-
isAncestor: true
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const segmentId = getSegmentId(primaryId);
|
|
121
|
-
for (const key of this.keys()) {
|
|
122
|
-
if (!prefixSet.has(key) && getSegmentId(key) === segmentId) {
|
|
123
|
-
this._set(key, {
|
|
124
|
-
isRelated: true
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
_set(id, attention) {
|
|
130
|
-
const atom = this._getAtom(id);
|
|
131
|
-
this._registry.set(atom, {
|
|
132
|
-
hasAttention: attention.hasAttention ?? false,
|
|
133
|
-
isAncestor: attention.isAncestor ?? false,
|
|
134
|
-
isRelated: attention.isRelated ?? false
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var getAttendables = (selector, cursor, acc = []) => {
|
|
139
|
-
const closestAttendable = cursor.closest(selector);
|
|
140
|
-
if (closestAttendable) {
|
|
141
|
-
const attendableId = closestAttendable.getAttribute("data-attendable-id");
|
|
142
|
-
if (!attendableId) {
|
|
143
|
-
const trigger = document.querySelector(`[aria-controls="${closestAttendable.getAttribute("id")}"]`);
|
|
144
|
-
if (!trigger) {
|
|
145
|
-
return acc;
|
|
146
|
-
} else {
|
|
147
|
-
return getAttendables(selector, trigger, acc);
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
acc.push(attendableId);
|
|
151
|
-
return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return [
|
|
155
|
-
...new Set(acc)
|
|
156
|
-
];
|
|
157
|
-
};
|
|
158
|
-
var LINKED_PREFIX = "~";
|
|
159
|
-
var expandAttendableId = (qualifiedId) => {
|
|
160
|
-
const segments = qualifiedId.split("/");
|
|
161
|
-
return segments.map((_, index) => segments.slice(0, index + 1).join("/"));
|
|
162
|
-
};
|
|
163
|
-
var isLinkedSegment = (qualifiedId) => {
|
|
164
|
-
const lastSegment = qualifiedId.split("/").pop() ?? "";
|
|
165
|
-
return lastSegment.startsWith(LINKED_PREFIX);
|
|
166
|
-
};
|
|
167
|
-
var linkedSegment = (variant) => `${LINKED_PREFIX}${variant}`;
|
|
168
|
-
var getLinkedVariant = (qualifiedId) => {
|
|
169
|
-
const lastSegment = qualifiedId.split("/").pop() ?? "";
|
|
170
|
-
return lastSegment.startsWith(LINKED_PREFIX) ? lastSegment.slice(LINKED_PREFIX.length) : lastSegment;
|
|
171
|
-
};
|
|
172
|
-
var getParentId = (qualifiedId) => {
|
|
173
|
-
if (!qualifiedId) {
|
|
174
|
-
return void 0;
|
|
175
|
-
}
|
|
176
|
-
const lastSlash = qualifiedId.lastIndexOf("/");
|
|
177
|
-
return lastSlash > 0 ? qualifiedId.slice(0, lastSlash) : void 0;
|
|
178
|
-
};
|
|
179
|
-
var getSegmentId = (qualifiedId) => {
|
|
180
|
-
return qualifiedId.split("/").pop() ?? qualifiedId;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// src/view-state/view-state.ts
|
|
184
|
-
var defineViewState = (def) => def;
|
|
185
|
-
var ViewStateManager = class {
|
|
186
|
-
#registry;
|
|
187
|
-
#backends;
|
|
188
|
-
constructor({ registry, backends }) {
|
|
189
|
-
this.#registry = registry;
|
|
190
|
-
this.#backends = backends;
|
|
191
|
-
}
|
|
192
|
-
/** Reactive atom for `(aspect, contextId)`; pass to `registry.get` inside derived atoms/hooks. */
|
|
193
|
-
atom(aspect, contextId) {
|
|
194
|
-
return this.#backends[aspect.backend].atom(aspect, contextId);
|
|
195
|
-
}
|
|
196
|
-
get(aspect, contextId) {
|
|
197
|
-
return this.#registry.get(this.atom(aspect, contextId));
|
|
198
|
-
}
|
|
199
|
-
set(aspect, contextId, value) {
|
|
200
|
-
const backend = this.#backends[aspect.backend];
|
|
201
|
-
this.#registry.set(backend.atom(aspect, contextId), value);
|
|
202
|
-
backend.persist?.(aspect, contextId, value);
|
|
203
|
-
}
|
|
204
|
-
update(aspect, contextId, fn) {
|
|
205
|
-
this.set(aspect, contextId, fn(this.get(aspect, contextId)));
|
|
206
|
-
}
|
|
207
|
-
subscribe(aspect, contextId, cb) {
|
|
208
|
-
const atom = this.atom(aspect, contextId);
|
|
209
|
-
return this.#registry.subscribe(atom, () => cb(this.#registry.get(atom)));
|
|
210
|
-
}
|
|
211
|
-
contexts(aspect) {
|
|
212
|
-
return this.#backends[aspect.backend].contexts(aspect);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// src/view-state/backends.ts
|
|
217
|
-
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
218
|
-
import * as Schema from "effect/Schema";
|
|
219
|
-
var cacheKey = (aspect, contextId) => `${aspect.key}:${contextId}`;
|
|
220
|
-
var MemoryBackend = class {
|
|
221
|
-
#atoms = /* @__PURE__ */ new Map();
|
|
222
|
-
atom(aspect, contextId) {
|
|
223
|
-
const key = cacheKey(aspect, contextId);
|
|
224
|
-
let atom = this.#atoms.get(key);
|
|
225
|
-
if (!atom) {
|
|
226
|
-
atom = Atom2.make(aspect.defaultValue());
|
|
227
|
-
this.#atoms.set(key, atom);
|
|
228
|
-
}
|
|
229
|
-
return atom;
|
|
230
|
-
}
|
|
231
|
-
contexts(aspect) {
|
|
232
|
-
const prefix = `${aspect.key}:`;
|
|
233
|
-
return [
|
|
234
|
-
...this.#atoms.keys()
|
|
235
|
-
].filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length));
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
var STORAGE_PREFIX = "dxos:view-state:";
|
|
239
|
-
var storageKeyFor = (aspect, contextId) => `${STORAGE_PREFIX}${aspect.key}:${contextId}`;
|
|
240
|
-
var safeLocalStorage = () => {
|
|
241
|
-
try {
|
|
242
|
-
return globalThis.localStorage;
|
|
243
|
-
} catch {
|
|
244
|
-
return void 0;
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
var LocalBackend = class {
|
|
248
|
-
#registry;
|
|
249
|
-
// Absent in non-browser contexts (SSR/tests without injection); the backend then degrades to
|
|
250
|
-
// ephemeral, in-memory behaviour rather than crashing on a missing `localStorage`.
|
|
251
|
-
#storage;
|
|
252
|
-
#atoms = /* @__PURE__ */ new Map();
|
|
253
|
-
// Reverse map: storage key -> (aspect, contextId) so `storage` events can target the right atom.
|
|
254
|
-
#byStorageKey = /* @__PURE__ */ new Map();
|
|
255
|
-
#storageListener;
|
|
256
|
-
constructor({ registry, storage }) {
|
|
257
|
-
this.#registry = registry;
|
|
258
|
-
this.#storage = storage ?? safeLocalStorage();
|
|
259
|
-
if (this.#storage && typeof globalThis.addEventListener === "function") {
|
|
260
|
-
this.#storageListener = (event) => {
|
|
261
|
-
if (!event.key || !event.key.startsWith(STORAGE_PREFIX)) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
const entry = this.#byStorageKey.get(event.key);
|
|
265
|
-
const atom = entry && this.#atoms.get(cacheKey(entry.aspect, entry.contextId));
|
|
266
|
-
if (entry && atom) {
|
|
267
|
-
this.#registry.set(atom, this.#read(entry.aspect, event.key));
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
globalThis.addEventListener("storage", this.#storageListener);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
atom(aspect, contextId) {
|
|
274
|
-
const key = cacheKey(aspect, contextId);
|
|
275
|
-
let atom = this.#atoms.get(key);
|
|
276
|
-
if (!atom) {
|
|
277
|
-
const storageKey = storageKeyFor(aspect, contextId);
|
|
278
|
-
atom = Atom2.make(this.#read(aspect, storageKey));
|
|
279
|
-
this.#atoms.set(key, atom);
|
|
280
|
-
this.#byStorageKey.set(storageKey, {
|
|
281
|
-
aspect,
|
|
282
|
-
contextId
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
return atom;
|
|
286
|
-
}
|
|
287
|
-
persist(aspect, contextId, value) {
|
|
288
|
-
this.#storage?.setItem(storageKeyFor(aspect, contextId), JSON.stringify(Schema.encodeSync(aspect.schema)(value)));
|
|
289
|
-
}
|
|
290
|
-
contexts(aspect) {
|
|
291
|
-
if (!this.#storage) {
|
|
292
|
-
const prefix2 = `${aspect.key}:`;
|
|
293
|
-
return [
|
|
294
|
-
...this.#atoms.keys()
|
|
295
|
-
].filter((key) => key.startsWith(prefix2)).map((key) => key.slice(prefix2.length));
|
|
296
|
-
}
|
|
297
|
-
const prefix = storageKeyFor(aspect, "");
|
|
298
|
-
const ids = [];
|
|
299
|
-
for (let index = 0; index < this.#storage.length; index++) {
|
|
300
|
-
const key = this.#storage.key(index);
|
|
301
|
-
if (key?.startsWith(prefix)) {
|
|
302
|
-
ids.push(key.slice(prefix.length));
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return ids;
|
|
306
|
-
}
|
|
307
|
-
dispose() {
|
|
308
|
-
if (this.#storageListener && typeof globalThis.removeEventListener === "function") {
|
|
309
|
-
globalThis.removeEventListener("storage", this.#storageListener);
|
|
310
|
-
}
|
|
311
|
-
this.#atoms.clear();
|
|
312
|
-
this.#byStorageKey.clear();
|
|
313
|
-
}
|
|
314
|
-
#read(aspect, storageKey) {
|
|
315
|
-
const raw = this.#storage?.getItem(storageKey);
|
|
316
|
-
if (raw == null) {
|
|
317
|
-
return aspect.defaultValue();
|
|
318
|
-
}
|
|
319
|
-
try {
|
|
320
|
-
return Schema.decodeUnknownSync(aspect.schema)(JSON.parse(raw));
|
|
321
|
-
} catch {
|
|
322
|
-
return aspect.defaultValue();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
var createDefaultBackends = (registry) => ({
|
|
327
|
-
memory: new MemoryBackend(),
|
|
328
|
-
local: new LocalBackend({
|
|
329
|
-
registry
|
|
330
|
-
})
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
// src/selection.ts
|
|
334
|
-
import * as Match from "effect/Match";
|
|
335
|
-
import * as Schema2 from "effect/Schema";
|
|
336
|
-
var SelectionSchema = Schema2.Union(Schema2.Struct({
|
|
337
|
-
mode: Schema2.Literal("single"),
|
|
338
|
-
id: Schema2.optional(Schema2.String)
|
|
339
|
-
}).pipe(Schema2.mutable), Schema2.Struct({
|
|
340
|
-
mode: Schema2.Literal("multi"),
|
|
341
|
-
ids: Schema2.Array(Schema2.String).pipe(Schema2.mutable)
|
|
342
|
-
}).pipe(Schema2.mutable), Schema2.Struct({
|
|
343
|
-
mode: Schema2.Literal("range"),
|
|
344
|
-
from: Schema2.optional(Schema2.String),
|
|
345
|
-
to: Schema2.optional(Schema2.String)
|
|
346
|
-
}).pipe(Schema2.mutable), Schema2.Struct({
|
|
347
|
-
mode: Schema2.Literal("multi-range"),
|
|
348
|
-
ranges: Schema2.Array(Schema2.Struct({
|
|
349
|
-
from: Schema2.String,
|
|
350
|
-
to: Schema2.String
|
|
351
|
-
})).pipe(Schema2.mutable)
|
|
352
|
-
}).pipe(Schema2.mutable)).pipe(Schema2.mutable);
|
|
353
|
-
var defaultSelection = Match.type().pipe(Match.withReturnType(), Match.when("single", () => ({
|
|
354
|
-
mode: "single"
|
|
355
|
-
})), Match.when("multi", () => ({
|
|
356
|
-
mode: "multi",
|
|
357
|
-
ids: []
|
|
358
|
-
})), Match.when("range", () => ({
|
|
359
|
-
mode: "range"
|
|
360
|
-
})), Match.when("multi-range", () => ({
|
|
361
|
-
mode: "multi-range",
|
|
362
|
-
ranges: []
|
|
363
|
-
})), Match.exhaustive);
|
|
364
|
-
var selectionAspect = defineViewState({
|
|
365
|
-
key: "selection",
|
|
366
|
-
backend: "memory",
|
|
367
|
-
schema: SelectionSchema,
|
|
368
|
-
defaultValue: () => ({
|
|
369
|
-
mode: "multi",
|
|
370
|
-
ids: []
|
|
371
|
-
})
|
|
372
|
-
});
|
|
373
|
-
var resolveSelection = (selection, mode) => {
|
|
374
|
-
const value = selection?.mode === mode ? selection : defaultSelection(mode);
|
|
375
|
-
return Match.type().pipe(Match.when({
|
|
376
|
-
mode: "single"
|
|
377
|
-
}, (s) => s.id), Match.when({
|
|
378
|
-
mode: "multi"
|
|
379
|
-
}, (s) => s.ids), Match.when({
|
|
380
|
-
mode: "range"
|
|
381
|
-
}, (s) => s.from && s.to ? {
|
|
382
|
-
from: s.from,
|
|
383
|
-
to: s.to
|
|
384
|
-
} : void 0), Match.when({
|
|
385
|
-
mode: "multi-range"
|
|
386
|
-
}, (s) => s.ranges), Match.exhaustive)(value);
|
|
387
|
-
};
|
|
388
|
-
var toggleSelection = (selection, id) => {
|
|
389
|
-
const ids = selection?.mode === "multi" ? selection.ids : [];
|
|
390
|
-
return {
|
|
391
|
-
mode: "multi",
|
|
392
|
-
ids: ids.includes(id) ? ids.filter((existing) => existing !== id) : [
|
|
393
|
-
...ids,
|
|
394
|
-
id
|
|
395
|
-
]
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
var getSelectionSet = (manager, contextId) => {
|
|
399
|
-
const ids = new Set(contextId ? [
|
|
400
|
-
contextId
|
|
401
|
-
] : []);
|
|
402
|
-
for (const context of manager.contexts(selectionAspect)) {
|
|
403
|
-
const selection = manager.get(selectionAspect, context);
|
|
404
|
-
if (selection.mode === "multi") {
|
|
405
|
-
for (const id of selection.ids) {
|
|
406
|
-
ids.add(id);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return ids;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
export {
|
|
414
|
-
AttentionManager,
|
|
415
|
-
getAttendables,
|
|
416
|
-
expandAttendableId,
|
|
417
|
-
isLinkedSegment,
|
|
418
|
-
linkedSegment,
|
|
419
|
-
getLinkedVariant,
|
|
420
|
-
getParentId,
|
|
421
|
-
getSegmentId,
|
|
422
|
-
defineViewState,
|
|
423
|
-
ViewStateManager,
|
|
424
|
-
MemoryBackend,
|
|
425
|
-
LocalBackend,
|
|
426
|
-
createDefaultBackends,
|
|
427
|
-
SelectionSchema,
|
|
428
|
-
defaultSelection,
|
|
429
|
-
selectionAspect,
|
|
430
|
-
resolveSelection,
|
|
431
|
-
toggleSelection,
|
|
432
|
-
getSelectionSet
|
|
433
|
-
};
|
|
434
|
-
//# sourceMappingURL=chunk-4HYAJ4IO.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/attention.ts", "../../../src/view-state/view-state.ts", "../../../src/view-state/backends.ts", "../../../src/selection.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\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 private readonly _map = new Map<string, Atom.Writable<Attention>>();\n private readonly _currentAtom: Atom.Writable<string[]>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: string[] = [],\n ) {\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 private _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 private _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/**\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('data-attendable-id');\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\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 Atom, type Registry } from '@effect-atom/atom-react';\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` is inferred from the schema.\n */\nexport interface AspectDef<T> {\n readonly key: string;\n readonly backend: BackendName;\n // Encoded type is intentionally unconstrained: persisted backends serialize `T` through the\n // schema to an arbitrary wire form, and only the decoded `T` matters to consumers.\n readonly schema: Schema.Schema<T, any>;\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 */\nexport const defineViewState = <T>(def: AspectDef<T>): AspectDef<T> => 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 ViewStateBackend {\n /** Stable atom for the pair; created (and seeded) on first access, cached thereafter. */\n atom: <T>(aspect: AspectDef<T>, contextId: string) => Atom.Writable<T>;\n /** Persist a value after the atom is updated. No-op for in-memory backends. */\n persist?: <T>(aspect: AspectDef<T>, contextId: string, value: T) => void;\n /** Context ids that currently hold a value for the aspect. */\n contexts: <T>(aspect: AspectDef<T>) => string[];\n /** Release listeners/timers (used by tests; app-lifetime managers do not call this). */\n dispose?: () => void;\n}\n\nexport interface ViewStateManagerOptions {\n readonly registry: Registry.Registry;\n readonly backends: Record<BackendName, ViewStateBackend>;\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 ViewStateManager {\n readonly #registry: Registry.Registry;\n readonly #backends: Record<BackendName, ViewStateBackend>;\n\n constructor({ registry, backends }: ViewStateManagerOptions) {\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>(aspect: AspectDef<T>, contextId: string): Atom.Writable<T> {\n return this.#backends[aspect.backend].atom(aspect, contextId);\n }\n\n get<T>(aspect: AspectDef<T>, contextId: string): T {\n return this.#registry.get(this.atom(aspect, contextId));\n }\n\n set<T>(aspect: AspectDef<T>, 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>(aspect: AspectDef<T>, contextId: string, fn: (prev: T) => T): void {\n this.set(aspect, contextId, fn(this.get(aspect, contextId)));\n }\n\n subscribe<T>(aspect: AspectDef<T>, 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>(aspect: AspectDef<T>): string[] {\n return this.#backends[aspect.backend].contexts(aspect);\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Schema from 'effect/Schema';\n\nimport { type AspectDef, type BackendName, type ViewStateBackend } from './view-state';\n\n// Only the stable `key` string is needed to form the map key; avoids variance issues with AspectDef<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 ViewStateBackend {\n readonly #atoms = new Map<string, Atom.Writable<unknown>>();\n\n atom<T>(aspect: AspectDef<T>, contextId: string): Atom.Writable<T> {\n const key = cacheKey(aspect, contextId);\n let atom = this.#atoms.get(key);\n if (!atom) {\n atom = Atom.make<unknown>(aspect.defaultValue());\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>(aspect: AspectDef<T>): 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.Registry;\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 ViewStateBackend {\n readonly #registry: Registry.Registry;\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: AspectDef<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>(aspect: AspectDef<T>, 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 atom = Atom.make<unknown>(this.#read(aspect, storageKey));\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 AspectDef<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>(aspect: AspectDef<T>, contextId: string, value: T): void {\n this.#storage?.setItem(storageKeyFor(aspect, contextId), JSON.stringify(Schema.encodeSync(aspect.schema)(value)));\n }\n\n contexts<T>(aspect: AspectDef<T>): 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>(aspect: AspectDef<T>, 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 = (registry: Registry.Registry): Record<BackendName, ViewStateBackend> => ({\n memory: new MemoryBackend(),\n local: new LocalBackend({ registry }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\n\nimport { type AspectDef, type ViewStateManager, defineViewState } from './view-state';\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const SelectionSchema = Schema.Union(\n Schema.Struct({\n mode: Schema.Literal('single'),\n id: Schema.optional(Schema.String),\n }).pipe(Schema.mutable),\n Schema.Struct({\n mode: Schema.Literal('multi'),\n ids: Schema.Array(Schema.String).pipe(Schema.mutable),\n }).pipe(Schema.mutable),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).pipe(Schema.mutable),\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 }).pipe(Schema.mutable),\n).pipe(Schema.mutable);\n\nexport type Selection = Schema.Schema.Type<typeof SelectionSchema>;\n\nexport const defaultSelection = 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 SelectionResult<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 selectionAspect: AspectDef<Selection> = defineViewState<Selection>({\n key: 'selection',\n backend: 'memory',\n schema: SelectionSchema,\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 resolveSelection = <T extends SelectionMode>(\n selection: Selection | undefined,\n mode: T,\n): SelectionResult<T> => {\n const value = selection?.mode === mode ? selection : defaultSelection(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 SelectionResult<T>;\n};\n\n/** Toggle `id` within a multi selection; resets to a multi selection if the current value differs. */\nexport const toggleSelection = (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/** Union of all multi-selected ids across every selection context, plus an optional explicit id. */\nexport const getSelectionSet = (manager: ViewStateManager, contextId?: string): Set<string> => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of manager.contexts(selectionAspect)) {\n const selection = manager.get(selectionAspect, context);\n if (selection.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n return ids;\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAA2B;AAY7B,IAAMC,mBAAN,MAAMA;;EACMC,OAAO,oBAAIC,IAAAA;E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AAEhB;EAAG,IAAIiB,MAAAA,GAC9EZ,WAAK;IAAEf,MAAM;EAAc,GAAG,CAAC0B,MAAMA,EAAEf,MAAM,GAC7CK,gBAAU,EAChBS,KAAAA;AACJ;AAGO,IAAMG,kBAAkB,CAACJ,WAAkCtB,OAAAA;AAChE,QAAMK,MAAMiB,WAAWxB,SAAS,UAAUwB,UAAUjB,MAAM,CAAA;AAC1D,SAAO;IAAEP,MAAM;IAASO,KAAKA,IAAIsB,SAAS3B,EAAAA,IAAMK,IAAIuB,OAAO,CAACC,aAAaA,aAAa7B,EAAAA,IAAM;SAAIK;MAAKL;;EAAI;AAC3G;AAGO,IAAM8B,kBAAkB,CAACC,SAA2BC,cAAAA;AACzD,QAAM3B,MAAM,IAAI4B,IAAYD,YAAY;IAACA;MAAa,CAAA,CAAE;AACxD,aAAWE,WAAWH,QAAQI,SAASpB,eAAAA,GAAkB;AACvD,UAAMO,YAAYS,QAAQK,IAAIrB,iBAAiBmB,OAAAA;AAC/C,QAAIZ,UAAUxB,SAAS,SAAS;AAC9B,iBAAWE,MAAMsB,UAAUjB,KAAK;AAC9BA,YAAIgC,IAAIrC,EAAAA;MACV;IACF;EACF;AACA,SAAOK;AACT;",
|
|
6
|
-
"names": ["Atom", "AttentionManager", "_map", "Map", "_currentAtom", "_registry", "initial", "make", "pipe", "keepAlive", "length", "update", "current", "getCurrent", "get", "subscribeCurrent", "cb", "subscribe", "keys", "Array", "from", "id", "atom", "_getAtom", "existing", "newAtom", "hasAttention", "isAncestor", "isRelated", "set", "nextIds", "primaryId", "currentIds", "prevPrimaryId", "prevPrefixes", "expandAttendableId", "prefix", "_set", "prevSegmentId", "getSegmentId", "key", "prefixes", "prefixSet", "Set", "linkedParent", "isLinkedSegment", "getParentId", "undefined", "segmentId", "has", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "parentElement", "LINKED_PREFIX", "qualifiedId", "segments", "split", "map", "_", "index", "slice", "join", "lastSegment", "pop", "startsWith", "linkedSegment", "variant", "getLinkedVariant", "lastSlash", "lastIndexOf", "defineViewState", "def", "ViewStateManager", "registry", "backends", "atom", "aspect", "contextId", "backend", "get", "set", "value", "persist", "update", "fn", "subscribe", "cb", "contexts", "Atom", "Schema", "cacheKey", "aspect", "contextId", "key", "MemoryBackend", "Map", "atom", "get", "make", "defaultValue", "set", "contexts", "prefix", "keys", "filter", "startsWith", "map", "slice", "length", "STORAGE_PREFIX", "storageKeyFor", "safeLocalStorage", "globalThis", "localStorage", "undefined", "LocalBackend", "registry", "storage", "addEventListener", "event", "entry", "storageKey", "persist", "value", "setItem", "JSON", "stringify", "encodeSync", "schema", "ids", "index", "push", "dispose", "removeEventListener", "clear", "raw", "getItem", "decodeUnknownSync", "parse", "createDefaultBackends", "memory", "local", "Match", "Schema", "SelectionSchema", "Union", "Struct", "mode", "Literal", "id", "optional", "String", "pipe", "mutable", "ids", "Array", "from", "to", "ranges", "defaultSelection", "type", "withReturnType", "when", "exhaustive", "selectionAspect", "defineViewState", "key", "backend", "schema", "defaultValue", "resolveSelection", "selection", "value", "s", "undefined", "toggleSelection", "includes", "filter", "existing", "getSelectionSet", "manager", "contextId", "Set", "context", "contexts", "get", "add"]
|
|
7
|
-
}
|