@ikonai/sdk-ui 0.0.11 → 0.0.12
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-DeNP3tVp.js +15239 -0
- package/ikon-ui-core.d.ts +16 -0
- package/index.d.ts +1 -0
- package/index.js +6809 -6268
- package/package.json +1 -1
- package/ui-store-ops.d.ts +61 -0
- package/ui-store.d.ts +11 -2
- package/ui-types.d.ts +12 -13
- package/ui-worker.d.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { UIPayload } from '../../../shared/generated/src/index.ts';
|
|
2
|
+
import { UiNode, UiOptimisticPatchState } from './ui-types';
|
|
3
|
+
export interface UiStreamSnapshotWire {
|
|
4
|
+
streamId: string;
|
|
5
|
+
category?: string;
|
|
6
|
+
version: number;
|
|
7
|
+
rootViewId?: string;
|
|
8
|
+
views: Array<[viewId: string, node: UiNode]>;
|
|
9
|
+
payloads: Array<[key: string, payload: UIPayload]>;
|
|
10
|
+
optimisticPatches: Array<[viewId: string, patches: UiOptimisticPatchState[]]>;
|
|
11
|
+
}
|
|
12
|
+
export type UiStoreOp = {
|
|
13
|
+
type: 'ReplaceStreamSnapshot';
|
|
14
|
+
snapshot: UiStreamSnapshotWire;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'PatchStreamSnapshot';
|
|
17
|
+
streamId: string;
|
|
18
|
+
nextVersion: number;
|
|
19
|
+
expectedBaseVersion?: number;
|
|
20
|
+
rootViewId?: string;
|
|
21
|
+
upsertViews?: Array<[viewId: string, node: UiNode]>;
|
|
22
|
+
deleteViews?: string[];
|
|
23
|
+
upsertPayloads?: Array<[key: string, payload: UIPayload]>;
|
|
24
|
+
deletePayloads?: string[];
|
|
25
|
+
upsertOptimisticPatches?: Array<[viewId: string, patches: UiOptimisticPatchState[]]>;
|
|
26
|
+
deleteOptimisticPatchesForViews?: string[];
|
|
27
|
+
category?: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'SetStreamCategory';
|
|
30
|
+
streamId: string;
|
|
31
|
+
category?: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'ClearStream';
|
|
34
|
+
streamId: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'RemoveStream';
|
|
37
|
+
streamId: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'UpsertUiStyle';
|
|
40
|
+
style: {
|
|
41
|
+
styleId: string;
|
|
42
|
+
css?: string;
|
|
43
|
+
common?: string;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
type: 'RemoveUiStyle';
|
|
47
|
+
styleId: string;
|
|
48
|
+
};
|
|
49
|
+
export interface UiStoreOpBatch {
|
|
50
|
+
batchId: string;
|
|
51
|
+
createdAtMs: number;
|
|
52
|
+
ops: UiStoreOp[];
|
|
53
|
+
acks?: Array<{
|
|
54
|
+
trackId: number;
|
|
55
|
+
version: number;
|
|
56
|
+
}>;
|
|
57
|
+
stats?: {
|
|
58
|
+
uiMessagesConsumed: number;
|
|
59
|
+
bytesConsumed?: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
package/ui-store.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParsedUiUpdate, UiStoreSnapshot } from './ui-types';
|
|
2
|
+
import { UiStoreOp, UiStreamSnapshotWire } from './ui-store-ops';
|
|
2
3
|
type StreamListener = (streamId: string) => void;
|
|
3
4
|
type StoreListener = () => void;
|
|
4
5
|
export interface StreamSnapshot extends UiStoreSnapshot {
|
|
@@ -6,12 +7,18 @@ export interface StreamSnapshot extends UiStoreSnapshot {
|
|
|
6
7
|
readonly category?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare class UiStreamStore {
|
|
9
|
-
private readonly
|
|
10
|
+
private readonly views;
|
|
10
11
|
private readonly listeners;
|
|
11
12
|
private readonly payloads;
|
|
13
|
+
private snapshotMode;
|
|
12
14
|
private snapshot;
|
|
13
|
-
private
|
|
15
|
+
private rootViewId?;
|
|
14
16
|
apply(update: ParsedUiUpdate): boolean;
|
|
17
|
+
replaceFromWire(wire: UiStreamSnapshotWire): boolean;
|
|
18
|
+
patchFromOp(op: Extract<UiStoreOp, {
|
|
19
|
+
type: 'PatchStreamSnapshot';
|
|
20
|
+
}>): boolean;
|
|
21
|
+
replaceSnapshot(next: UiStoreSnapshot): boolean;
|
|
15
22
|
clear(): void;
|
|
16
23
|
getSnapshot(): UiStoreSnapshot;
|
|
17
24
|
subscribe(listener: StoreListener): () => void;
|
|
@@ -22,6 +29,8 @@ export declare class UiStore {
|
|
|
22
29
|
private readonly streams;
|
|
23
30
|
private readonly listeners;
|
|
24
31
|
apply(streamId: string, update: ParsedUiUpdate): boolean;
|
|
32
|
+
applyStoreOp(op: UiStoreOp): boolean;
|
|
33
|
+
applyStoreOps(ops: readonly UiStoreOp[]): void;
|
|
25
34
|
clear(streamId: string): void;
|
|
26
35
|
remove(streamId: string): void;
|
|
27
36
|
setCategory(streamId: string, category?: string): void;
|
package/ui-types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UIPayload } from '../../../shared/generated/src/index.ts';
|
|
2
2
|
export type UiUpdateType = 'full' | 'diff';
|
|
3
|
-
export type
|
|
4
|
-
export interface
|
|
3
|
+
export type UiNodeProps = Record<string, unknown>;
|
|
4
|
+
export interface UiNode {
|
|
5
5
|
readonly id: string;
|
|
6
6
|
readonly type: string;
|
|
7
|
-
readonly props:
|
|
8
|
-
readonly children: readonly
|
|
7
|
+
readonly props: UiNodeProps;
|
|
8
|
+
readonly children: readonly UiNode[];
|
|
9
9
|
readonly styleIds: readonly string[];
|
|
10
10
|
}
|
|
11
11
|
export interface TextDelta {
|
|
@@ -15,18 +15,17 @@ export interface TextDelta {
|
|
|
15
15
|
readonly end?: number;
|
|
16
16
|
readonly insertedText: string;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface UiNodeDiff {
|
|
19
19
|
readonly id: string;
|
|
20
20
|
readonly type: string;
|
|
21
|
-
readonly added: readonly
|
|
21
|
+
readonly added: readonly UiNode[];
|
|
22
22
|
readonly removed: readonly string[];
|
|
23
|
-
readonly updated: readonly
|
|
23
|
+
readonly updated: readonly UiNodeDiff[];
|
|
24
24
|
readonly changedProps: ReadonlyMap<string, unknown>;
|
|
25
25
|
readonly textUpdates: readonly TextDelta[];
|
|
26
|
-
readonly replaceProps?: UiElementProps;
|
|
27
26
|
}
|
|
28
27
|
export interface UiSnapshotMetadata {
|
|
29
|
-
readonly
|
|
28
|
+
readonly viewId: string;
|
|
30
29
|
readonly optimisticActionId?: string | null;
|
|
31
30
|
readonly isOptimistic?: boolean;
|
|
32
31
|
readonly isUpdate?: boolean;
|
|
@@ -51,8 +50,8 @@ export interface UiOptimisticPatchState {
|
|
|
51
50
|
readonly baseVersion: number;
|
|
52
51
|
}
|
|
53
52
|
export interface UiStoreSnapshot {
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
53
|
+
readonly rootViewId?: string;
|
|
54
|
+
readonly views: ReadonlyMap<string, UiNode>;
|
|
56
55
|
readonly payloads: ReadonlyMap<string, UIPayload>;
|
|
57
56
|
readonly optimisticPatches: ReadonlyMap<string, readonly UiOptimisticPatchState[]>;
|
|
58
57
|
readonly version?: number;
|
|
@@ -64,11 +63,11 @@ interface UiSnapshotBase {
|
|
|
64
63
|
}
|
|
65
64
|
export interface UiFullSnapshot extends UiSnapshotBase {
|
|
66
65
|
readonly type: 'full';
|
|
67
|
-
readonly root:
|
|
66
|
+
readonly root: UiNode;
|
|
68
67
|
}
|
|
69
68
|
export interface UiDiffSnapshot extends UiSnapshotBase {
|
|
70
69
|
readonly type: 'diff';
|
|
71
|
-
readonly diff:
|
|
70
|
+
readonly diff: UiNodeDiff;
|
|
72
71
|
}
|
|
73
72
|
export type UiSnapshot = UiFullSnapshot | UiDiffSnapshot;
|
|
74
73
|
export interface ParsedUiUpdate {
|
package/ui-worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|