-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfast-canvas-types.ts
More file actions
117 lines (107 loc) · 3.89 KB
/
Copy pathfast-canvas-types.ts
File metadata and controls
117 lines (107 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type {
CreateStartUpPageContainer,
DeviceInfo,
DeviceStatus,
EvenHubEvent,
ImageRawDataUpdate,
OsEventTypeList,
RebuildPageContainer,
TextContainerUpgrade,
} from "@evenrealities/even_hub_sdk";
import type { encodeCanvasTiles, Tile } from "./g2-canvas";
import type { G2TileImageFormat } from "./g2-tile-format";
import type { G2TilePaletteMode } from "./g2-tile-palette";
import type { ImageSendConcurrency } from "./image-send-concurrency";
import type { G2DisplayHideStrategy } from "./g2-display-hide";
import type { NativeConversateContent } from "./native-conversate-text";
export type Bridge = {
createStartUpPageContainer: (
page: CreateStartUpPageContainer,
) => Promise<unknown>;
getDeviceInfo?: () => Promise<DeviceInfo | null>;
onDeviceStatusChanged?: (
listener: (status: DeviceStatus) => void,
) => () => void;
rebuildPageContainer: (page: RebuildPageContainer) => Promise<boolean>;
textContainerUpgrade?: (update: TextContainerUpgrade) => Promise<boolean>;
updateImageRawData: (update: ImageRawDataUpdate) => Promise<unknown>;
onEvenHubEvent: (listener: (event: EvenHubEvent) => void) => () => void;
shutDownPageContainer: (exitMode: number) => Promise<unknown>;
};
export type TransportDependencies = {
waitForBridge: () => Promise<Bridge>;
waitForPageReady?: (milliseconds: number) => Promise<void>;
encode: typeof encodeCanvasTiles;
};
export type DisplayToggle = {
readonly beforeRestore?: () => void | Promise<void>;
readonly createHiddenSource: () => HTMLCanvasElement;
};
export type ExternalRefresh = {
readonly beforeExternalRefresh?: () => void | Promise<void>;
readonly onRefreshReady?: (request: FastCanvasRefreshRequest) => void;
readonly onNativeTextReady?: (
controller: FastCanvasNativeTextController,
) => void;
readonly targetTiles: Readonly<
Record<FastCanvasRefreshTarget, readonly Tile[]>
>;
};
export type PageDirection = "next" | "previous";
export type FastCanvasInput =
| "tap"
| "double-tap"
| "scroll-next"
| "scroll-previous";
export type FastCanvasInputResult = "unhandled" | "consume" | "redraw";
export type FastCanvasRawEvent = {
readonly count: number;
readonly hidden: boolean;
readonly sysEventType?: OsEventTypeList;
readonly textEventType?: OsEventTypeList;
readonly eventSource?: number;
};
export type FastCanvasBattery = {
readonly label: "G1" | "G2" | "R1";
readonly level?: number;
readonly charging?: boolean;
};
export type FastCanvasRefreshTarget =
| "left"
| "right"
| "right-top"
| "all";
export type FastCanvasRefreshRequest = (
target: FastCanvasRefreshTarget,
) => void;
export type FastCanvasNativeTextController = {
active(): boolean;
enter(content: string): Promise<boolean>;
update(content: string): Promise<boolean>;
enterConversate?(content: NativeConversateContent): Promise<boolean>;
updateConversate?(content: NativeConversateContent): Promise<boolean>;
restore(): Promise<boolean>;
};
export type FastCanvasOptions = {
readonly beforeExternalRefresh?: () => void | Promise<void>;
readonly beforeRestore?: () => void | Promise<void>;
readonly createHiddenSource?: () => HTMLCanvasElement;
readonly dependencies?: TransportDependencies;
readonly displayHideStrategy?: G2DisplayHideStrategy;
readonly imageSendConcurrency?: ImageSendConcurrency;
readonly tileImageFormat?: G2TileImageFormat;
readonly tilePaletteMode?: G2TilePaletteMode;
readonly now?: () => number;
readonly onBattery?: (
battery: FastCanvasBattery | undefined,
) => void;
readonly onDisplayCommitted?: (minute: number) => void;
readonly onInput?: (
input: FastCanvasInput,
) => FastCanvasInputResult | Promise<FastCanvasInputResult>;
readonly onRawEvent?: (event: FastCanvasRawEvent) => void;
readonly onNativeTextReady?: (
controller: FastCanvasNativeTextController,
) => void;
readonly onRefreshReady?: (request: FastCanvasRefreshRequest) => void;
};