@ikonai/sdk-ui 1.0.67 → 1.0.69
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/assets/{ui-worker-B0-YcaZ_.js → ui-worker-BQcelAkD.js} +762 -730
- package/ikon-ui-core.d.ts +16 -9
- package/index.d.ts +1 -1
- package/index.js +267 -231
- package/{last-snapshot-cache.d.ts → live-snapshot.d.ts} +29 -15
- package/package.json +1 -1
- package/ui-store-ops.d.ts +1 -0
|
@@ -1,47 +1,61 @@
|
|
|
1
1
|
import { StreamSnapshot } from './ui-store';
|
|
2
2
|
import { UiStreamSnapshotWire } from './ui-store-ops';
|
|
3
3
|
import { UiStylePayload } from './ikon-ui-core';
|
|
4
|
-
export interface
|
|
4
|
+
export interface LiveSnapshotConfig {
|
|
5
5
|
/** Stable per-app identifier (e.g. the space id). Part of the storage key. */
|
|
6
6
|
appId: string;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The connected user's id — real when logged in, or the unique id issued by anonymous auth (stable
|
|
9
|
+
* per browser instance). Part of the storage key. There is deliberately NO fallback: a falsy id
|
|
10
|
+
* disables the live snapshot entirely (it never reads, writes, or prunes), so an unidentified
|
|
11
|
+
* session can never paint another session's UI on a shared device.
|
|
12
|
+
*/
|
|
13
|
+
userId: string;
|
|
14
|
+
/**
|
|
15
|
+
* Stored state older than this is treated as missing. Default 5 minutes — kept under the app
|
|
16
|
+
* server's idle-kill window (per-space, default 15 min). Set this to the space's configured
|
|
17
|
+
* idle-kill time so the live snapshot never outlives the server it was captured from (a longer
|
|
18
|
+
* value risks flashing a stale tree that then snaps to the cold-started server's default view).
|
|
19
|
+
*/
|
|
10
20
|
maxAgeMs?: number;
|
|
11
21
|
/** Serialized envelopes larger than this are dropped (not written). Default ~5 MB. */
|
|
12
22
|
maxBytes?: number;
|
|
13
23
|
/** Throttle window for writes (at most one write per window). Default 1000 ms. */
|
|
14
24
|
debounceMs?: number;
|
|
15
25
|
}
|
|
16
|
-
/** UI state recovered from
|
|
17
|
-
export interface
|
|
26
|
+
/** UI state recovered from a live snapshot, shaped for `UiStore.applyStoreOp(ReplaceStreamSnapshot)`. */
|
|
27
|
+
export interface LiveSnapshotState {
|
|
18
28
|
streams: UiStreamSnapshotWire[];
|
|
19
29
|
styles: UiStylePayload[];
|
|
20
30
|
}
|
|
21
31
|
/**
|
|
22
|
-
* Persists the last rendered
|
|
32
|
+
* Persists the last rendered live snapshot (view tree + styles) per app/user in `localStorage`, so a
|
|
23
33
|
* return visit can paint the cached tree before the WebSocket connects. The store is
|
|
24
|
-
* schema-versioned, age-bounded, size-bounded, and silent on quota/serialization failure — a
|
|
25
|
-
*
|
|
34
|
+
* schema-versioned, age-bounded, size-bounded, and silent on quota/serialization failure — a miss
|
|
35
|
+
* always degrades cleanly to the live connect path.
|
|
26
36
|
*
|
|
27
|
-
* Binary payloads (images etc.) are **not**
|
|
28
|
-
* write re-encode unchanged bytes. The
|
|
37
|
+
* Binary payloads (images etc.) are **not** stored: they would dominate the size and make every
|
|
38
|
+
* write re-encode unchanged bytes. The seeded tree paints layout + text instantly; payload-backed
|
|
29
39
|
* content fills in once the live connection delivers it. Writes are throttled and run at idle time.
|
|
30
40
|
*
|
|
31
41
|
* The key embeds the user id, and sibling keys for other users of the same app are pruned on
|
|
32
|
-
* construction so a shared device never paints one user's UI for another.
|
|
42
|
+
* construction so a shared device never paints one user's UI for another. A missing user id
|
|
43
|
+
* disables the live snapshot rather than falling back to a shared key.
|
|
33
44
|
*/
|
|
34
|
-
export declare class
|
|
45
|
+
export declare class LiveSnapshotCache {
|
|
35
46
|
private readonly key;
|
|
36
47
|
private readonly appId;
|
|
37
48
|
private readonly userId;
|
|
49
|
+
private readonly disabled;
|
|
38
50
|
private readonly maxAgeMs;
|
|
39
51
|
private readonly maxBytes;
|
|
40
52
|
private readonly debounceMs;
|
|
41
53
|
private writeTimer;
|
|
42
54
|
private pending;
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
/** Remove every stored live snapshot (all apps and users) from localStorage. Call on logout. */
|
|
56
|
+
static clearAll(): void;
|
|
57
|
+
constructor(config: LiveSnapshotConfig);
|
|
58
|
+
load(): LiveSnapshotState | null;
|
|
45
59
|
/**
|
|
46
60
|
* Schedule a throttled write of the current UI state (at most one write per window, captured at
|
|
47
61
|
* the trailing edge). Streams with no root are skipped. The actual write runs at idle time.
|
package/package.json
CHANGED