@ikonai/sdk-ui 0.0.1
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/ikon-ui-core.d.ts +36 -0
- package/index.d.ts +4 -0
- package/index.js +14210 -0
- package/package.json +16 -0
- package/parse-ui-update.d.ts +7 -0
- package/ui-store.d.ts +34 -0
- package/ui-types.d.ts +78 -0
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ikonai/sdk-ui",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"types": "./index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@ikonai/sdk": "*"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UIUpdate } from '../../platform-generated/src/index.ts';
|
|
2
|
+
import { ParsedUiUpdate } from './ui-types';
|
|
3
|
+
export declare class UiUpdateParseError extends Error {
|
|
4
|
+
readonly causeError?: unknown | undefined;
|
|
5
|
+
constructor(message: string, causeError?: unknown | undefined);
|
|
6
|
+
}
|
|
7
|
+
export declare function parseUiUpdate(update: UIUpdate): ParsedUiUpdate;
|
package/ui-store.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ParsedUiUpdate, UiStoreSnapshot } from './ui-types';
|
|
2
|
+
type StreamListener = (streamId: string) => void;
|
|
3
|
+
type StoreListener = () => void;
|
|
4
|
+
export interface StreamSnapshot extends UiStoreSnapshot {
|
|
5
|
+
readonly streamId: string;
|
|
6
|
+
readonly category?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class UiStreamStore {
|
|
9
|
+
private readonly containers;
|
|
10
|
+
private readonly listeners;
|
|
11
|
+
private readonly payloads;
|
|
12
|
+
private snapshot;
|
|
13
|
+
private rootContainerId?;
|
|
14
|
+
apply(update: ParsedUiUpdate): boolean;
|
|
15
|
+
clear(): void;
|
|
16
|
+
getSnapshot(): UiStoreSnapshot;
|
|
17
|
+
subscribe(listener: StoreListener): () => void;
|
|
18
|
+
private commitSnapshot;
|
|
19
|
+
private notify;
|
|
20
|
+
}
|
|
21
|
+
export declare class UiStore {
|
|
22
|
+
private readonly streams;
|
|
23
|
+
private readonly listeners;
|
|
24
|
+
apply(streamId: string, update: ParsedUiUpdate): boolean;
|
|
25
|
+
clear(streamId: string): void;
|
|
26
|
+
remove(streamId: string): void;
|
|
27
|
+
setCategory(streamId: string, category?: string): void;
|
|
28
|
+
getSnapshot(streamId: string): StreamSnapshot | undefined;
|
|
29
|
+
getSnapshots(): StreamSnapshot[];
|
|
30
|
+
subscribe(listener: StreamListener): () => void;
|
|
31
|
+
private getOrCreateStreamEntry;
|
|
32
|
+
private notify;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/ui-types.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { UIPayload } from '../../platform-generated/src/index.ts';
|
|
2
|
+
export type UiUpdateType = 'full' | 'diff';
|
|
3
|
+
export type UiElementProps = Record<string, unknown>;
|
|
4
|
+
export interface UiElementNode {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly type: string;
|
|
7
|
+
readonly props: UiElementProps;
|
|
8
|
+
readonly children: readonly UiElementNode[];
|
|
9
|
+
readonly styleIds: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export interface TextDelta {
|
|
12
|
+
readonly nodeId: string;
|
|
13
|
+
readonly propertyName: string;
|
|
14
|
+
readonly start: number;
|
|
15
|
+
readonly end?: number;
|
|
16
|
+
readonly insertedText: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UiElementDiffNode {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly type: string;
|
|
21
|
+
readonly added: readonly UiElementNode[];
|
|
22
|
+
readonly removed: readonly string[];
|
|
23
|
+
readonly updated: readonly UiElementDiffNode[];
|
|
24
|
+
readonly changedProps: ReadonlyMap<string, unknown>;
|
|
25
|
+
readonly textUpdates: readonly TextDelta[];
|
|
26
|
+
readonly replaceProps?: UiElementProps;
|
|
27
|
+
}
|
|
28
|
+
export interface UiSnapshotMetadata {
|
|
29
|
+
readonly containerId: string;
|
|
30
|
+
readonly optimisticActionId?: string | null;
|
|
31
|
+
readonly isOptimistic?: boolean;
|
|
32
|
+
readonly isUpdate?: boolean;
|
|
33
|
+
readonly optimisticPatch?: UiOptimisticPatchMetadata;
|
|
34
|
+
readonly optimisticReconcile?: UiOptimisticReconcileMetadata;
|
|
35
|
+
}
|
|
36
|
+
export interface UiOptimisticPatchMetadata {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly actionId: string;
|
|
39
|
+
readonly ordinal: number;
|
|
40
|
+
readonly baseVersion: number;
|
|
41
|
+
readonly supersedes?: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
export interface UiOptimisticReconcileMetadata {
|
|
44
|
+
readonly baseVersion: number;
|
|
45
|
+
readonly drop?: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
export interface UiOptimisticPatchState {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly actionId: string;
|
|
50
|
+
readonly ordinal: number;
|
|
51
|
+
readonly baseVersion: number;
|
|
52
|
+
}
|
|
53
|
+
export interface UiStoreSnapshot {
|
|
54
|
+
readonly rootContainerId?: string;
|
|
55
|
+
readonly containers: ReadonlyMap<string, UiElementNode>;
|
|
56
|
+
readonly payloads: ReadonlyMap<string, UIPayload>;
|
|
57
|
+
readonly optimisticPatches: ReadonlyMap<string, readonly UiOptimisticPatchState[]>;
|
|
58
|
+
readonly version?: number;
|
|
59
|
+
}
|
|
60
|
+
interface UiSnapshotBase {
|
|
61
|
+
readonly type: UiUpdateType;
|
|
62
|
+
readonly version: number;
|
|
63
|
+
readonly metadata: UiSnapshotMetadata;
|
|
64
|
+
}
|
|
65
|
+
export interface UiFullSnapshot extends UiSnapshotBase {
|
|
66
|
+
readonly type: 'full';
|
|
67
|
+
readonly root: UiElementNode;
|
|
68
|
+
}
|
|
69
|
+
export interface UiDiffSnapshot extends UiSnapshotBase {
|
|
70
|
+
readonly type: 'diff';
|
|
71
|
+
readonly diff: UiElementDiffNode;
|
|
72
|
+
}
|
|
73
|
+
export type UiSnapshot = UiFullSnapshot | UiDiffSnapshot;
|
|
74
|
+
export interface ParsedUiUpdate {
|
|
75
|
+
readonly snapshot: UiSnapshot;
|
|
76
|
+
readonly payloads: ReadonlyMap<string, UIPayload>;
|
|
77
|
+
}
|
|
78
|
+
export {};
|