@opentray/spec 0.2.0 → 0.4.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/README.md +1 -1
- package/dist/index.d.mts +57 -32
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +12 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Shared TypeScript protocol and contract package for OpenTray.
|
|
|
6
6
|
|
|
7
7
|
- Define JSON-RPC payload shapes.
|
|
8
8
|
- Define broker protocol version and endpoint identity helpers.
|
|
9
|
-
- Define public `
|
|
9
|
+
- Define public `Space`, `Tray`, `Session`, and extension contract types.
|
|
10
10
|
- Keep protocol types reusable by the `opentray` package and official extensions.
|
|
11
11
|
|
|
12
12
|
This package must stay platform-neutral and must not import native implementation packages.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
//#region src/index.d.ts
|
|
2
|
-
type
|
|
2
|
+
type SessionId = string;
|
|
3
3
|
type RequestId = string;
|
|
4
|
-
type
|
|
4
|
+
type SpaceId = string;
|
|
5
5
|
type TrayId = string;
|
|
6
6
|
type MenuItemId = number;
|
|
7
|
+
/** @deprecated Use `SessionId`. */
|
|
8
|
+
type LeaseId = SessionId;
|
|
9
|
+
/** @deprecated Use `SpaceId`. */
|
|
10
|
+
type SurfaceId = SpaceId;
|
|
7
11
|
declare const PROTOCOL_VERSION = 1;
|
|
8
12
|
interface BrokerEndpointIdentity {
|
|
9
13
|
packageVersion: string;
|
|
@@ -22,16 +26,19 @@ declare const formatBrokerEndpointName: (identity: BrokerEndpointIdentity) => st
|
|
|
22
26
|
declare const formatBrokerStateRoot: (homeDir: string, identity: BrokerEndpointIdentity) => string;
|
|
23
27
|
declare const formatUnixSocketPath: (homeDir: string, identity: BrokerEndpointIdentity) => string;
|
|
24
28
|
declare const formatWindowsPipeName: (identity: BrokerEndpointIdentity) => string;
|
|
25
|
-
interface
|
|
26
|
-
|
|
29
|
+
interface SpaceOptions {
|
|
30
|
+
id?: SpaceId;
|
|
27
31
|
title?: string;
|
|
28
32
|
icon?: Icon;
|
|
29
33
|
default?: boolean;
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/** @deprecated Use `SpaceOptions`. */
|
|
36
|
+
type SurfaceOptions = SpaceOptions;
|
|
37
|
+
interface SpaceRef {
|
|
38
|
+
spaceId: SpaceId;
|
|
34
39
|
}
|
|
40
|
+
/** @deprecated Use `SpaceRef`. */
|
|
41
|
+
type SurfaceRef = SpaceRef;
|
|
35
42
|
interface TrayOptions {
|
|
36
43
|
trayId?: TrayId;
|
|
37
44
|
appId?: string;
|
|
@@ -51,6 +58,7 @@ type MenuItem = {
|
|
|
51
58
|
type: "item";
|
|
52
59
|
id: MenuItemId;
|
|
53
60
|
title: string;
|
|
61
|
+
primaryEvent?: boolean;
|
|
54
62
|
enabled?: boolean;
|
|
55
63
|
shortcut?: string;
|
|
56
64
|
} | {
|
|
@@ -92,30 +100,36 @@ interface Rect {
|
|
|
92
100
|
width: number;
|
|
93
101
|
height: number;
|
|
94
102
|
}
|
|
103
|
+
type TrayBoundsKind = "native" | "inferred" | "unavailable";
|
|
104
|
+
interface TrayBoundsResult {
|
|
105
|
+
kind: TrayBoundsKind;
|
|
106
|
+
source: string;
|
|
107
|
+
rect: Rect | null;
|
|
108
|
+
}
|
|
95
109
|
type MouseButton = "left" | "right" | "middle";
|
|
96
110
|
type TrayEvent = {
|
|
97
111
|
type: "ready";
|
|
98
|
-
|
|
112
|
+
spaceId: SpaceId;
|
|
99
113
|
} | {
|
|
100
114
|
type: "menuClick";
|
|
101
|
-
|
|
115
|
+
spaceId: SpaceId;
|
|
102
116
|
trayId: TrayId;
|
|
103
117
|
itemId: MenuItemId;
|
|
104
118
|
} | {
|
|
105
119
|
type: "trayClick";
|
|
106
|
-
|
|
120
|
+
spaceId: SpaceId;
|
|
107
121
|
button: MouseButton;
|
|
108
122
|
x: number;
|
|
109
123
|
y: number;
|
|
110
124
|
} | {
|
|
111
125
|
type: "trayDoubleClick";
|
|
112
|
-
|
|
126
|
+
spaceId: SpaceId;
|
|
113
127
|
button: MouseButton;
|
|
114
128
|
x: number;
|
|
115
129
|
y: number;
|
|
116
130
|
};
|
|
117
131
|
interface ExtensionScope {
|
|
118
|
-
|
|
132
|
+
spaceId: SpaceId;
|
|
119
133
|
trayId?: TrayId;
|
|
120
134
|
ext: string;
|
|
121
135
|
}
|
|
@@ -125,7 +139,7 @@ interface ExtensionEnvelope<TData = unknown> {
|
|
|
125
139
|
}
|
|
126
140
|
interface DaemonSessionHealth {
|
|
127
141
|
sessionId: number;
|
|
128
|
-
|
|
142
|
+
internalLeaseId?: SessionId;
|
|
129
143
|
initialized: boolean;
|
|
130
144
|
}
|
|
131
145
|
interface DaemonHealth {
|
|
@@ -144,56 +158,61 @@ type ClientFrame = {
|
|
|
144
158
|
type: "exit";
|
|
145
159
|
};
|
|
146
160
|
type ClientRequestFrame = ({
|
|
147
|
-
type: "create-
|
|
161
|
+
type: "create-space";
|
|
148
162
|
requestId: RequestId;
|
|
149
|
-
} &
|
|
150
|
-
type: "resolve-default-
|
|
163
|
+
} & SpaceOptions) | {
|
|
164
|
+
type: "resolve-default-space";
|
|
151
165
|
requestId: RequestId;
|
|
152
166
|
} | {
|
|
153
167
|
type: "create-tray";
|
|
154
168
|
requestId: RequestId;
|
|
155
|
-
|
|
169
|
+
space: SpaceRef;
|
|
156
170
|
tray: TrayOptions;
|
|
157
171
|
} | {
|
|
158
172
|
type: "destroy-tray";
|
|
159
173
|
requestId: RequestId;
|
|
160
|
-
|
|
174
|
+
spaceId: SpaceId;
|
|
175
|
+
trayId: TrayId;
|
|
176
|
+
} | {
|
|
177
|
+
type: "get-tray-bounds";
|
|
178
|
+
requestId: RequestId;
|
|
179
|
+
spaceId: SpaceId;
|
|
161
180
|
trayId: TrayId;
|
|
162
181
|
} | {
|
|
163
182
|
type: "set-tray-menu";
|
|
164
183
|
requestId: RequestId;
|
|
165
|
-
|
|
184
|
+
spaceId: SpaceId;
|
|
166
185
|
trayId: TrayId;
|
|
167
186
|
menu: Menu;
|
|
168
187
|
} | {
|
|
169
188
|
type: "set-tray-icon";
|
|
170
189
|
requestId: RequestId;
|
|
171
|
-
|
|
190
|
+
spaceId: SpaceId;
|
|
172
191
|
trayId: TrayId;
|
|
173
192
|
icon: Icon;
|
|
174
193
|
} | {
|
|
175
194
|
type: "set-tray-tooltip";
|
|
176
195
|
requestId: RequestId;
|
|
177
|
-
|
|
196
|
+
spaceId: SpaceId;
|
|
178
197
|
trayId: TrayId;
|
|
179
198
|
tooltip: Tooltip;
|
|
180
199
|
} | {
|
|
181
200
|
type: "load-ext";
|
|
182
201
|
requestId: RequestId;
|
|
183
|
-
|
|
202
|
+
spaceId: SpaceId;
|
|
184
203
|
name: string;
|
|
185
204
|
path: string;
|
|
186
205
|
} | {
|
|
187
206
|
type: "ext-command";
|
|
188
207
|
requestId: RequestId;
|
|
189
|
-
|
|
208
|
+
spaceId: SpaceId;
|
|
190
209
|
trayId: TrayId;
|
|
191
210
|
ext: string;
|
|
192
211
|
data: unknown;
|
|
193
212
|
} | {
|
|
194
213
|
type: "unload-ext";
|
|
195
214
|
requestId: RequestId;
|
|
196
|
-
|
|
215
|
+
spaceId: SpaceId;
|
|
197
216
|
name: string;
|
|
198
217
|
} | {
|
|
199
218
|
type: "health";
|
|
@@ -203,20 +222,26 @@ type ServerFrame = {
|
|
|
203
222
|
type: "ready";
|
|
204
223
|
protocolVersion: number;
|
|
205
224
|
brokerVersion: string;
|
|
206
|
-
|
|
225
|
+
sessionId: SessionId;
|
|
207
226
|
} | {
|
|
208
|
-
type: "
|
|
227
|
+
type: "space-created";
|
|
209
228
|
requestId: RequestId;
|
|
210
|
-
|
|
229
|
+
space: SpaceRef;
|
|
211
230
|
} | {
|
|
212
|
-
type: "default-
|
|
231
|
+
type: "default-space";
|
|
213
232
|
requestId: RequestId;
|
|
214
|
-
|
|
233
|
+
space: SpaceRef;
|
|
215
234
|
} | {
|
|
216
235
|
type: "tray-created";
|
|
217
236
|
requestId: RequestId;
|
|
218
|
-
|
|
237
|
+
spaceId: SpaceId;
|
|
238
|
+
trayId: TrayId;
|
|
239
|
+
} | {
|
|
240
|
+
type: "tray-bounds";
|
|
241
|
+
requestId: RequestId;
|
|
242
|
+
spaceId: SpaceId;
|
|
219
243
|
trayId: TrayId;
|
|
244
|
+
bounds: TrayBoundsResult;
|
|
220
245
|
} | {
|
|
221
246
|
type: "ack";
|
|
222
247
|
requestId: RequestId;
|
|
@@ -229,7 +254,7 @@ type ServerFrame = {
|
|
|
229
254
|
event: TrayEvent;
|
|
230
255
|
} | {
|
|
231
256
|
type: "ext-event";
|
|
232
|
-
|
|
257
|
+
spaceId: SpaceId;
|
|
233
258
|
trayId: TrayId;
|
|
234
259
|
ext: string;
|
|
235
260
|
data: unknown;
|
|
@@ -247,5 +272,5 @@ interface ParseResult<T> {
|
|
|
247
272
|
declare const parseServerFrame: (line: string) => ParseResult<ServerFrame>;
|
|
248
273
|
declare const isServerFrame: (value: unknown) => value is ServerFrame;
|
|
249
274
|
//#endregion
|
|
250
|
-
export { BrokerEndpointIdentity, BrokerEndpointIdentityOptions, ClientFrame, ClientRequestFrame, DaemonHealth, DaemonSessionHealth, ExtensionEnvelope, ExtensionScope, Icon, LeaseId, Menu, MenuItem, MenuItemId, MouseButton, PROTOCOL_VERSION, ParseResult, Rect, RequestId, ServerFrame, SurfaceId, SurfaceOptions, SurfaceRef, Tooltip, TrayEvent, TrayId, TrayOptions, createBrokerEndpointIdentity, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isServerFrame, isSupportedProtocolVersion, parseServerFrame };
|
|
275
|
+
export { BrokerEndpointIdentity, BrokerEndpointIdentityOptions, ClientFrame, ClientRequestFrame, DaemonHealth, DaemonSessionHealth, ExtensionEnvelope, ExtensionScope, Icon, LeaseId, Menu, MenuItem, MenuItemId, MouseButton, PROTOCOL_VERSION, ParseResult, Rect, RequestId, ServerFrame, SessionId, SpaceId, SpaceOptions, SpaceRef, SurfaceId, SurfaceOptions, SurfaceRef, Tooltip, TrayBoundsKind, TrayBoundsResult, TrayEvent, TrayId, TrayOptions, createBrokerEndpointIdentity, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isServerFrame, isSupportedProtocolVersion, parseServerFrame };
|
|
251
276
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,OAAA;AAAA,KACA,MAAA;AAAA,KACA,UAAA;AAJS;AAAA,KAOT,OAAA,GAAU,SAAS;;KAEnB,SAAA,GAAY,OAAO;AAAA,cAElB,gBAAA;AAAA,UAEI,sBAAA;EACf,cAAA;EACA,eAAe;AAAA;AAAA,UAGA,6BAAA;EACf,cAAA;EACA,eAAe;AAAA;AAAA,cAGJ,4BAAA;EAAgC,cAAA;EAAA;AAAA,GAG1C,6BAAA,KAAgC,sBAAA;AAAA,cAYtB,0BAAA,GAA8B,eAAuB;AAAA,cAGrD,wBAAA,GAA4B,QAAgC,EAAtB,sBAAsB;AAAA,cAK5D,qBAAA,GAAyB,OAAA,UAAiB,QAAA,EAAU,sBAAsB;AAAA,cAU1E,oBAAA,GAAwB,OAAA,UAAiB,QAAA,EAAU,sBAAsB;AAAA,cAGzE,qBAAA,GAAyB,QAAgC,EAAtB,sBAAsB;AAAA,UAqBrD,YAAA;EACf,EAAA,GAAK,OAAA;EACL,KAAA;EACA,IAAA,GAAO,IAAI;EACX,OAAA;AAAA;AA7E6B;AAAA,KAiFnB,cAAA,GAAiB,YAAY;AAAA,UA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AA,aAAe,WAAW,CAAC,WAAA;AAAA,cAkB/C,aAAA,GAAiB,KAAA,cAAiB,KAAA,IAAS,WAkDvD"}
|
package/dist/index.mjs
CHANGED
|
@@ -51,14 +51,15 @@ const isRecord = (value) => typeof value === "object" && value !== null && !Arra
|
|
|
51
51
|
const isServerFrame = (value) => {
|
|
52
52
|
if (!isRecord(value) || typeof value.type !== "string") return false;
|
|
53
53
|
switch (value.type) {
|
|
54
|
-
case "ready": return typeof value.protocolVersion === "number" && typeof value.brokerVersion === "string" && typeof value.
|
|
55
|
-
case "
|
|
56
|
-
case "default-
|
|
57
|
-
case "tray-created": return typeof value.requestId === "string" && typeof value.
|
|
54
|
+
case "ready": return typeof value.protocolVersion === "number" && typeof value.brokerVersion === "string" && typeof value.sessionId === "string";
|
|
55
|
+
case "space-created": return typeof value.requestId === "string" && isRecord(value.space);
|
|
56
|
+
case "default-space": return typeof value.requestId === "string" && isRecord(value.space);
|
|
57
|
+
case "tray-created": return typeof value.requestId === "string" && typeof value.spaceId === "string" && typeof value.trayId === "string";
|
|
58
|
+
case "tray-bounds": return typeof value.requestId === "string" && typeof value.spaceId === "string" && typeof value.trayId === "string" && isTrayBoundsResult(value.bounds);
|
|
58
59
|
case "ack": return typeof value.requestId === "string";
|
|
59
60
|
case "daemon-health": return typeof value.requestId === "string" && isDaemonHealth(value.health);
|
|
60
61
|
case "event": return isTrayEvent(value.event);
|
|
61
|
-
case "ext-event": return typeof value.
|
|
62
|
+
case "ext-event": return typeof value.spaceId === "string" && typeof value.trayId === "string" && typeof value.ext === "string";
|
|
62
63
|
case "error": return (value.requestId === void 0 || typeof value.requestId === "string") && typeof value.code === "string" && typeof value.message === "string";
|
|
63
64
|
default: return false;
|
|
64
65
|
}
|
|
@@ -67,14 +68,16 @@ const isDaemonHealth = (value) => {
|
|
|
67
68
|
if (!isRecord(value)) return false;
|
|
68
69
|
return typeof value.pid === "number" && typeof value.packageVersion === "string" && typeof value.protocolVersion === "number" && typeof value.endpoint === "string" && typeof value.sessionCount === "number" && Array.isArray(value.sessions) && value.sessions.every(isDaemonSessionHealth);
|
|
69
70
|
};
|
|
70
|
-
const isDaemonSessionHealth = (value) => isRecord(value) && typeof value.sessionId === "number" && (value.
|
|
71
|
+
const isDaemonSessionHealth = (value) => isRecord(value) && typeof value.sessionId === "number" && (value.internalLeaseId === void 0 || typeof value.internalLeaseId === "string") && typeof value.initialized === "boolean";
|
|
72
|
+
const isRect = (value) => isRecord(value) && typeof value.x === "number" && typeof value.y === "number" && typeof value.width === "number" && typeof value.height === "number";
|
|
73
|
+
const isTrayBoundsResult = (value) => isRecord(value) && (value.kind === "native" || value.kind === "inferred" || value.kind === "unavailable") && typeof value.source === "string" && (value.rect === null || isRect(value.rect));
|
|
71
74
|
const isTrayEvent = (value) => {
|
|
72
75
|
if (!isRecord(value) || typeof value.type !== "string") return false;
|
|
73
76
|
switch (value.type) {
|
|
74
|
-
case "ready": return typeof value.
|
|
75
|
-
case "menuClick": return typeof value.
|
|
77
|
+
case "ready": return typeof value.spaceId === "string";
|
|
78
|
+
case "menuClick": return typeof value.spaceId === "string" && typeof value.trayId === "string" && typeof value.itemId === "number";
|
|
76
79
|
case "trayClick":
|
|
77
|
-
case "trayDoubleClick": return typeof value.
|
|
80
|
+
case "trayDoubleClick": return typeof value.spaceId === "string" && isMouseButton(value.button) && typeof value.x === "number" && typeof value.y === "number";
|
|
78
81
|
default: return false;
|
|
79
82
|
}
|
|
80
83
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type LeaseId = string;\nexport type RequestId = string;\nexport type SurfaceId = string;\nexport type TrayId = string;\nexport type MenuItemId = number;\n\nexport const PROTOCOL_VERSION = 1;\n\nexport interface BrokerEndpointIdentity {\n packageVersion: string;\n protocolVersion: number;\n}\n\nexport interface BrokerEndpointIdentityOptions {\n packageVersion: string;\n protocolVersion?: number;\n}\n\nexport const createBrokerEndpointIdentity = ({\n packageVersion,\n protocolVersion = PROTOCOL_VERSION,\n}: BrokerEndpointIdentityOptions): BrokerEndpointIdentity => {\n assertEndpointComponent(packageVersion, \"packageVersion\");\n if (!Number.isInteger(protocolVersion) || protocolVersion <= 0) {\n throw new Error(`protocolVersion must be a positive integer: ${protocolVersion}`);\n }\n\n return {\n packageVersion,\n protocolVersion,\n };\n};\n\nexport const isSupportedProtocolVersion = (protocolVersion: number): boolean =>\n protocolVersion === PROTOCOL_VERSION;\n\nexport const formatBrokerEndpointName = (identity: BrokerEndpointIdentity): string => {\n assertEndpointIdentity(identity);\n return `opentray-${identity.packageVersion}-p${identity.protocolVersion}`;\n};\n\nexport const formatBrokerStateRoot = (homeDir: string, identity: BrokerEndpointIdentity): string => {\n assertEndpointIdentity(identity);\n if (homeDir.length === 0) {\n throw new Error(\"homeDir must not be empty\");\n }\n\n const normalizedHome = homeDir.replace(/[\\\\/]+$/u, \"\");\n return `${normalizedHome}/.opentray/${identity.packageVersion}`;\n};\n\nexport const formatUnixSocketPath = (homeDir: string, identity: BrokerEndpointIdentity): string =>\n `${formatBrokerStateRoot(homeDir, identity)}/opentray-p${identity.protocolVersion}.sock`;\n\nexport const formatWindowsPipeName = (identity: BrokerEndpointIdentity): string =>\n `\\\\\\\\.\\\\pipe\\\\${formatBrokerEndpointName(identity)}`;\n\nconst endpointComponentPattern = /^[0-9A-Za-z._+-]+$/u;\n\nconst assertEndpointIdentity = (identity: BrokerEndpointIdentity): void => {\n assertEndpointComponent(identity.packageVersion, \"packageVersion\");\n if (!Number.isInteger(identity.protocolVersion) || identity.protocolVersion <= 0) {\n throw new Error(`protocolVersion must be a positive integer: ${identity.protocolVersion}`);\n }\n};\n\nconst assertEndpointComponent = (value: string, name: string): void => {\n if (value.length === 0) {\n throw new Error(`${name} must not be empty`);\n }\n if (!endpointComponentPattern.test(value)) {\n throw new Error(`${name} contains invalid endpoint characters: ${value}`);\n }\n};\n\nexport interface SurfaceOptions {\n appId: string;\n title?: string;\n icon?: Icon;\n default?: boolean;\n}\n\nexport interface SurfaceRef {\n surfaceId: SurfaceId;\n appId: string;\n}\n\nexport interface TrayOptions {\n trayId?: TrayId;\n appId?: string;\n title?: string;\n tooltip?: Tooltip;\n icon: Icon;\n menu?: Menu;\n}\n\nexport interface Tooltip {\n title: string;\n description: string;\n}\n\nexport interface Menu {\n items: MenuItem[];\n}\n\nexport type MenuItem =\n | {\n type: \"item\";\n id: MenuItemId;\n title: string;\n enabled?: boolean;\n shortcut?: string;\n }\n | {\n type: \"check\";\n id: MenuItemId;\n title: string;\n enabled?: boolean;\n checked?: boolean;\n }\n | {\n type: \"radio\";\n id: MenuItemId;\n title: string;\n enabled?: boolean;\n checked?: boolean;\n group: number;\n }\n | {\n type: \"separator\";\n }\n | {\n type: \"submenu\";\n title: string;\n enabled?: boolean;\n items: MenuItem[];\n };\n\nexport type Icon =\n | { type: \"rgba\"; data: Uint8Array | number[]; width: number; height: number }\n | { type: \"encoded\"; data: Uint8Array | number[] }\n | { type: \"file\"; path: string };\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport type MouseButton = \"left\" | \"right\" | \"middle\";\n\nexport type TrayEvent =\n | { type: \"ready\"; surfaceId: SurfaceId }\n | { type: \"menuClick\"; surfaceId: SurfaceId; trayId: TrayId; itemId: MenuItemId }\n | { type: \"trayClick\"; surfaceId: SurfaceId; button: MouseButton; x: number; y: number }\n | { type: \"trayDoubleClick\"; surfaceId: SurfaceId; button: MouseButton; x: number; y: number };\n\nexport interface ExtensionScope {\n surfaceId: SurfaceId;\n trayId?: TrayId;\n ext: string;\n}\n\nexport interface ExtensionEnvelope<TData = unknown> {\n scope: ExtensionScope;\n data: TData;\n}\n\nexport interface DaemonSessionHealth {\n sessionId: number;\n leaseId?: LeaseId;\n initialized: boolean;\n}\n\nexport interface DaemonHealth {\n pid: number;\n packageVersion: string;\n protocolVersion: number;\n endpoint: string;\n sessionCount: number;\n sessions: DaemonSessionHealth[];\n}\n\nexport type ClientFrame =\n | { type: \"init\"; protocolVersion: number; clientVersion: string }\n | ClientRequestFrame\n | { type: \"exit\" };\n\nexport type ClientRequestFrame =\n | ({ type: \"create-surface\"; requestId: RequestId } & SurfaceOptions)\n | { type: \"resolve-default-surface\"; requestId: RequestId }\n | { type: \"create-tray\"; requestId: RequestId; surface: SurfaceRef; tray: TrayOptions }\n | { type: \"destroy-tray\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId }\n | { type: \"set-tray-menu\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId; menu: Menu }\n | { type: \"set-tray-icon\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId; icon: Icon }\n | { type: \"set-tray-tooltip\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId; tooltip: Tooltip }\n | { type: \"load-ext\"; requestId: RequestId; surfaceId: SurfaceId; name: string; path: string }\n | { type: \"ext-command\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId; ext: string; data: unknown }\n | { type: \"unload-ext\"; requestId: RequestId; surfaceId: SurfaceId; name: string }\n | { type: \"health\"; requestId: RequestId };\n\nexport type ServerFrame =\n | { type: \"ready\"; protocolVersion: number; brokerVersion: string; leaseId: LeaseId }\n | { type: \"surface-created\"; requestId: RequestId; surface: SurfaceRef }\n | { type: \"default-surface\"; requestId: RequestId; surface: SurfaceRef }\n | { type: \"tray-created\"; requestId: RequestId; surfaceId: SurfaceId; trayId: TrayId }\n | { type: \"ack\"; requestId: RequestId }\n | { type: \"daemon-health\"; requestId: RequestId; health: DaemonHealth }\n | { type: \"event\"; event: TrayEvent }\n | { type: \"ext-event\"; surfaceId: SurfaceId; trayId: TrayId; ext: string; data: unknown }\n | { type: \"error\"; requestId?: RequestId; code: string; message: string };\n\nexport interface ParseResult<T> {\n ok: boolean;\n frame?: T;\n error?: string;\n}\n\nexport const parseServerFrame = (line: string): ParseResult<ServerFrame> => {\n try {\n const value: unknown = JSON.parse(line);\n if (!isServerFrame(value)) {\n return { ok: false, error: \"invalid server frame\" };\n }\n return { ok: true, frame: value };\n } catch (error) {\n return {\n ok: false,\n error: error instanceof Error ? error.message : \"unknown parse error\",\n };\n }\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nexport const isServerFrame = (value: unknown): value is ServerFrame => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"ready\":\n return (\n typeof value.protocolVersion === \"number\" &&\n typeof value.brokerVersion === \"string\" &&\n typeof value.leaseId === \"string\"\n );\n case \"surface-created\":\n return typeof value.requestId === \"string\" && isRecord(value.surface);\n case \"default-surface\":\n return typeof value.requestId === \"string\" && isRecord(value.surface);\n case \"tray-created\":\n return (\n typeof value.requestId === \"string\" &&\n typeof value.surfaceId === \"string\" &&\n typeof value.trayId === \"string\"\n );\n case \"ack\":\n return typeof value.requestId === \"string\";\n case \"daemon-health\":\n return typeof value.requestId === \"string\" && isDaemonHealth(value.health);\n case \"event\":\n return isTrayEvent(value.event);\n case \"ext-event\":\n return (\n typeof value.surfaceId === \"string\" &&\n typeof value.trayId === \"string\" &&\n typeof value.ext === \"string\"\n );\n case \"error\":\n return (\n (value.requestId === undefined || typeof value.requestId === \"string\") &&\n typeof value.code === \"string\" &&\n typeof value.message === \"string\"\n );\n default:\n return false;\n }\n};\n\nconst isDaemonHealth = (value: unknown): value is DaemonHealth => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n typeof value.pid === \"number\" &&\n typeof value.packageVersion === \"string\" &&\n typeof value.protocolVersion === \"number\" &&\n typeof value.endpoint === \"string\" &&\n typeof value.sessionCount === \"number\" &&\n Array.isArray(value.sessions) &&\n value.sessions.every(isDaemonSessionHealth)\n );\n};\n\nconst isDaemonSessionHealth = (value: unknown): value is DaemonSessionHealth =>\n isRecord(value) &&\n typeof value.sessionId === \"number\" &&\n (value.leaseId === undefined || typeof value.leaseId === \"string\") &&\n typeof value.initialized === \"boolean\";\n\nconst isTrayEvent = (value: unknown): value is TrayEvent => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"ready\":\n return typeof value.surfaceId === \"string\";\n case \"menuClick\":\n return (\n typeof value.surfaceId === \"string\" &&\n typeof value.trayId === \"string\" &&\n typeof value.itemId === \"number\"\n );\n case \"trayClick\":\n case \"trayDoubleClick\":\n return (\n typeof value.surfaceId === \"string\" &&\n isMouseButton(value.button) &&\n typeof value.x === \"number\" &&\n typeof value.y === \"number\"\n );\n default:\n return false;\n }\n};\n\nconst isMouseButton = (value: unknown): value is MouseButton =>\n value === \"left\" || value === \"right\" || value === \"middle\";\n"],"mappings":";AAMA,MAAa,mBAAmB;AAYhC,MAAa,gCAAgC,EAC3C,gBACA,kBAAA,QAC2D;CAC3D,wBAAwB,gBAAgB,gBAAgB;CACxD,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,mBAAmB,GAC3D,MAAM,IAAI,MAAM,+CAA+C,iBAAiB;CAGlF,OAAO;EACL;EACA;CACF;AACF;AAEA,MAAa,8BAA8B,oBACzC,oBAAA;AAEF,MAAa,4BAA4B,aAA6C;CACpF,uBAAuB,QAAQ;CAC/B,OAAO,YAAY,SAAS,eAAe,IAAI,SAAS;AAC1D;AAEA,MAAa,yBAAyB,SAAiB,aAA6C;CAClG,uBAAuB,QAAQ;CAC/B,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,MAAM,2BAA2B;CAI7C,OAAO,GADgB,QAAQ,QAAQ,YAAY,EAC5B,EAAE,aAAa,SAAS;AACjD;AAEA,MAAa,wBAAwB,SAAiB,aACpD,GAAG,sBAAsB,SAAS,QAAQ,EAAE,aAAa,SAAS,gBAAgB;AAEpF,MAAa,yBAAyB,aACpC,gBAAgB,yBAAyB,QAAQ;AAEnD,MAAM,2BAA2B;AAEjC,MAAM,0BAA0B,aAA2C;CACzE,wBAAwB,SAAS,gBAAgB,gBAAgB;CACjE,I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E,KAAK,SACH,OAAO,YAAY,MAAM,KAAK;EAChC,KAAK,aACH,OACE,OAAO,MAAM,cAAc,YAC3B,OAAO,MAAM,WAAW,YACxB,OAAO,MAAM,QAAQ;EAEzB,KAAK,SACH,QACG,MAAM,cAAc,KAAA,KAAa,OAAO,MAAM,cAAc,aAC7D,OAAO,MAAM,SAAS,YACtB,OAAO,MAAM,YAAY;EAE7B,SACE,OAAO;CACX;AACF;AAEA,MAAM,kBAAkB,UAA0C;CAChE,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAGT,OACE,OAAO,MAAM,QAAQ,YACrB,OAAO,MAAM,mBAAmB,YAChC,OAAO,MAAM,oBAAoB,YACjC,OAAO,MAAM,aAAa,YAC1B,OAAO,MAAM,iBAAiB,YAC9B,MAAM,QAAQ,MAAM,QAAQ,KAC5B,MAAM,SAAS,MAAM,qBAAqB;AAE9C;AAEA,MAAM,yBAAyB,UAC7B,SAAS,KAAK,KACd,OAAO,MAAM,cAAc,aAC1B,MAAM,YAAY,KAAA,KAAa,OAAO,MAAM,YAAY,aACzD,OAAO,MAAM,gBAAgB;AAE/B,MAAM,eAAe,UAAuC;CAC1D,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,UAC5C,OAAO;CAGT,QAAQ,MAAM,MAAd;EACE,KAAK,SACH,OAAO,OAAO,MAAM,cAAc;EACpC,KAAK,aACH,OACE,OAAO,MAAM,cAAc,YAC3B,OAAO,MAAM,WAAW,YACxB,OAAO,MAAM,WAAW;EAE5B,KAAK;EACL,KAAK,mBACH,OACE,OAAO,MAAM,cAAc,YAC3B,cAAc,MAAM,MAAM,KAC1B,OAAO,MAAM,MAAM,YACnB,OAAO,MAAM,MAAM;EAEvB,SACE,OAAO;CACX;AACF;AAEA,MAAM,iBAAiB,UACrB,UAAU,UAAU,UAAU,WAAW,UAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type SessionId = string;\nexport type RequestId = string;\nexport type SpaceId = string;\nexport type TrayId = string;\nexport type MenuItemId = number;\n\n/** @deprecated Use `SessionId`. */\nexport type LeaseId = SessionId;\n/** @deprecated Use `SpaceId`. */\nexport type SurfaceId = SpaceId;\n\nexport const PROTOCOL_VERSION = 1;\n\nexport interface BrokerEndpointIdentity {\n packageVersion: string;\n protocolVersion: number;\n}\n\nexport interface BrokerEndpointIdentityOptions {\n packageVersion: string;\n protocolVersion?: number;\n}\n\nexport const createBrokerEndpointIdentity = ({\n packageVersion,\n protocolVersion = PROTOCOL_VERSION,\n}: BrokerEndpointIdentityOptions): BrokerEndpointIdentity => {\n assertEndpointComponent(packageVersion, \"packageVersion\");\n if (!Number.isInteger(protocolVersion) || protocolVersion <= 0) {\n throw new Error(`protocolVersion must be a positive integer: ${protocolVersion}`);\n }\n\n return {\n packageVersion,\n protocolVersion,\n };\n};\n\nexport const isSupportedProtocolVersion = (protocolVersion: number): boolean =>\n protocolVersion === PROTOCOL_VERSION;\n\nexport const formatBrokerEndpointName = (identity: BrokerEndpointIdentity): string => {\n assertEndpointIdentity(identity);\n return `opentray-${identity.packageVersion}-p${identity.protocolVersion}`;\n};\n\nexport const formatBrokerStateRoot = (homeDir: string, identity: BrokerEndpointIdentity): string => {\n assertEndpointIdentity(identity);\n if (homeDir.length === 0) {\n throw new Error(\"homeDir must not be empty\");\n }\n\n const normalizedHome = homeDir.replace(/[\\\\/]+$/u, \"\");\n return `${normalizedHome}/.opentray/${identity.packageVersion}`;\n};\n\nexport const formatUnixSocketPath = (homeDir: string, identity: BrokerEndpointIdentity): string =>\n `${formatBrokerStateRoot(homeDir, identity)}/opentray-p${identity.protocolVersion}.sock`;\n\nexport const formatWindowsPipeName = (identity: BrokerEndpointIdentity): string =>\n `\\\\\\\\.\\\\pipe\\\\${formatBrokerEndpointName(identity)}`;\n\nconst endpointComponentPattern = /^[0-9A-Za-z._+-]+$/u;\n\nconst assertEndpointIdentity = (identity: BrokerEndpointIdentity): void => {\n assertEndpointComponent(identity.packageVersion, \"packageVersion\");\n if (!Number.isInteger(identity.protocolVersion) || identity.protocolVersion <= 0) {\n throw new Error(`protocolVersion must be a positive integer: ${identity.protocolVersion}`);\n }\n};\n\nconst assertEndpointComponent = (value: string, name: string): void => {\n if (value.length === 0) {\n throw new Error(`${name} must not be empty`);\n }\n if (!endpointComponentPattern.test(value)) {\n throw new Error(`${name} contains invalid endpoint characters: ${value}`);\n }\n};\n\nexport interface SpaceOptions {\n id?: SpaceId;\n title?: string;\n icon?: Icon;\n default?: boolean;\n}\n\n/** @deprecated Use `SpaceOptions`. */\nexport type SurfaceOptions = SpaceOptions;\n\nexport interface SpaceRef {\n spaceId: SpaceId;\n}\n\n/** @deprecated Use `SpaceRef`. */\nexport type SurfaceRef = SpaceRef;\n\nexport interface TrayOptions {\n trayId?: TrayId;\n appId?: string;\n title?: string;\n tooltip?: Tooltip;\n icon: Icon;\n menu?: Menu;\n}\n\nexport interface Tooltip {\n title: string;\n description: string;\n}\n\nexport interface Menu {\n items: MenuItem[];\n}\n\nexport type MenuItem =\n | {\n type: \"item\";\n id: MenuItemId;\n title: string;\n primaryEvent?: boolean;\n enabled?: boolean;\n shortcut?: string;\n }\n | {\n type: \"check\";\n id: MenuItemId;\n title: string;\n enabled?: boolean;\n checked?: boolean;\n }\n | {\n type: \"radio\";\n id: MenuItemId;\n title: string;\n enabled?: boolean;\n checked?: boolean;\n group: number;\n }\n | {\n type: \"separator\";\n }\n | {\n type: \"submenu\";\n title: string;\n enabled?: boolean;\n items: MenuItem[];\n };\n\nexport type Icon =\n | { type: \"rgba\"; data: Uint8Array | number[]; width: number; height: number }\n | { type: \"encoded\"; data: Uint8Array | number[] }\n | { type: \"file\"; path: string };\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport type TrayBoundsKind = \"native\" | \"inferred\" | \"unavailable\";\n\nexport interface TrayBoundsResult {\n kind: TrayBoundsKind;\n source: string;\n rect: Rect | null;\n}\n\nexport type MouseButton = \"left\" | \"right\" | \"middle\";\n\nexport type TrayEvent =\n | { type: \"ready\"; spaceId: SpaceId }\n | { type: \"menuClick\"; spaceId: SpaceId; trayId: TrayId; itemId: MenuItemId }\n | { type: \"trayClick\"; spaceId: SpaceId; button: MouseButton; x: number; y: number }\n | { type: \"trayDoubleClick\"; spaceId: SpaceId; button: MouseButton; x: number; y: number };\n\nexport interface ExtensionScope {\n spaceId: SpaceId;\n trayId?: TrayId;\n ext: string;\n}\n\nexport interface ExtensionEnvelope<TData = unknown> {\n scope: ExtensionScope;\n data: TData;\n}\n\nexport interface DaemonSessionHealth {\n sessionId: number;\n internalLeaseId?: SessionId;\n initialized: boolean;\n}\n\nexport interface DaemonHealth {\n pid: number;\n packageVersion: string;\n protocolVersion: number;\n endpoint: string;\n sessionCount: number;\n sessions: DaemonSessionHealth[];\n}\n\nexport type ClientFrame =\n | { type: \"init\"; protocolVersion: number; clientVersion: string }\n | ClientRequestFrame\n | { type: \"exit\" };\n\nexport type ClientRequestFrame =\n | ({ type: \"create-space\"; requestId: RequestId } & SpaceOptions)\n | { type: \"resolve-default-space\"; requestId: RequestId }\n | { type: \"create-tray\"; requestId: RequestId; space: SpaceRef; tray: TrayOptions }\n | { type: \"destroy-tray\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId }\n | { type: \"get-tray-bounds\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId }\n | { type: \"set-tray-menu\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId; menu: Menu }\n | { type: \"set-tray-icon\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId; icon: Icon }\n | { type: \"set-tray-tooltip\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId; tooltip: Tooltip }\n | { type: \"load-ext\"; requestId: RequestId; spaceId: SpaceId; name: string; path: string }\n | { type: \"ext-command\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId; ext: string; data: unknown }\n | { type: \"unload-ext\"; requestId: RequestId; spaceId: SpaceId; name: string }\n | { type: \"health\"; requestId: RequestId };\n\nexport type ServerFrame =\n | { type: \"ready\"; protocolVersion: number; brokerVersion: string; sessionId: SessionId }\n | { type: \"space-created\"; requestId: RequestId; space: SpaceRef }\n | { type: \"default-space\"; requestId: RequestId; space: SpaceRef }\n | { type: \"tray-created\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId }\n | { type: \"tray-bounds\"; requestId: RequestId; spaceId: SpaceId; trayId: TrayId; bounds: TrayBoundsResult }\n | { type: \"ack\"; requestId: RequestId }\n | { type: \"daemon-health\"; requestId: RequestId; health: DaemonHealth }\n | { type: \"event\"; event: TrayEvent }\n | { type: \"ext-event\"; spaceId: SpaceId; trayId: TrayId; ext: string; data: unknown }\n | { type: \"error\"; requestId?: RequestId; code: string; message: string };\n\nexport interface ParseResult<T> {\n ok: boolean;\n frame?: T;\n error?: string;\n}\n\nexport const parseServerFrame = (line: string): ParseResult<ServerFrame> => {\n try {\n const value: unknown = JSON.parse(line);\n if (!isServerFrame(value)) {\n return { ok: false, error: \"invalid server frame\" };\n }\n return { ok: true, frame: value };\n } catch (error) {\n return {\n ok: false,\n error: error instanceof Error ? error.message : \"unknown parse error\",\n };\n }\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nexport const isServerFrame = (value: unknown): value is ServerFrame => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"ready\":\n return (\n typeof value.protocolVersion === \"number\" &&\n typeof value.brokerVersion === \"string\" &&\n typeof value.sessionId === \"string\"\n );\n case \"space-created\":\n return typeof value.requestId === \"string\" && isRecord(value.space);\n case \"default-space\":\n return typeof value.requestId === \"string\" && isRecord(value.space);\n case \"tray-created\":\n return (\n typeof value.requestId === \"string\" &&\n typeof value.spaceId === \"string\" &&\n typeof value.trayId === \"string\"\n );\n case \"tray-bounds\":\n return (\n typeof value.requestId === \"string\" &&\n typeof value.spaceId === \"string\" &&\n typeof value.trayId === \"string\" &&\n isTrayBoundsResult(value.bounds)\n );\n case \"ack\":\n return typeof value.requestId === \"string\";\n case \"daemon-health\":\n return typeof value.requestId === \"string\" && isDaemonHealth(value.health);\n case \"event\":\n return isTrayEvent(value.event);\n case \"ext-event\":\n return (\n typeof value.spaceId === \"string\" &&\n typeof value.trayId === \"string\" &&\n typeof value.ext === \"string\"\n );\n case \"error\":\n return (\n (value.requestId === undefined || typeof value.requestId === \"string\") &&\n typeof value.code === \"string\" &&\n typeof value.message === \"string\"\n );\n default:\n return false;\n }\n};\n\nconst isDaemonHealth = (value: unknown): value is DaemonHealth => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n typeof value.pid === \"number\" &&\n typeof value.packageVersion === \"string\" &&\n typeof value.protocolVersion === \"number\" &&\n typeof value.endpoint === \"string\" &&\n typeof value.sessionCount === \"number\" &&\n Array.isArray(value.sessions) &&\n value.sessions.every(isDaemonSessionHealth)\n );\n};\n\nconst isDaemonSessionHealth = (value: unknown): value is DaemonSessionHealth =>\n isRecord(value) &&\n typeof value.sessionId === \"number\" &&\n (value.internalLeaseId === undefined || typeof value.internalLeaseId === \"string\") &&\n typeof value.initialized === \"boolean\";\n\nconst isRect = (value: unknown): value is Rect =>\n isRecord(value) &&\n typeof value.x === \"number\" &&\n typeof value.y === \"number\" &&\n typeof value.width === \"number\" &&\n typeof value.height === \"number\";\n\nconst isTrayBoundsResult = (value: unknown): value is TrayBoundsResult =>\n isRecord(value) &&\n (value.kind === \"native\" || value.kind === \"inferred\" || value.kind === \"unavailable\") &&\n typeof value.source === \"string\" &&\n (value.rect === null || isRect(value.rect));\n\nconst isTrayEvent = (value: unknown): value is TrayEvent => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"ready\":\n return typeof value.spaceId === \"string\";\n case \"menuClick\":\n return (\n typeof value.spaceId === \"string\" &&\n typeof value.trayId === \"string\" &&\n typeof value.itemId === \"number\"\n );\n case \"trayClick\":\n case \"trayDoubleClick\":\n return (\n typeof value.spaceId === \"string\" &&\n isMouseButton(value.button) &&\n typeof value.x === \"number\" &&\n typeof value.y === \"number\"\n );\n default:\n return false;\n }\n};\n\nconst isMouseButton = (value: unknown): value is MouseButton =>\n value === \"left\" || value === \"right\" || value === \"middle\";\n"],"mappings":";AAWA,MAAa,mBAAmB;AAYhC,MAAa,gCAAgC,EAC3C,gBACA,kBAAA,QAC2D;CAC3D,wBAAwB,gBAAgB,gBAAgB;CACxD,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,mBAAmB,GAC3D,MAAM,IAAI,MAAM,+CAA+C,iBAAiB;CAGlF,OAAO;EACL;EACA;CACF;AACF;AAEA,MAAa,8BAA8B,oBACzC,oBAAA;AAEF,MAAa,4BAA4B,aAA6C;CACpF,uBAAuB,QAAQ;CAC/B,OAAO,YAAY,SAAS,eAAe,IAAI,SAAS;AAC1D;AAEA,MAAa,yBAAyB,SAAiB,aAA6C;CAClG,uBAAuB,QAAQ;CAC/B,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,MAAM,2BAA2B;CAI7C,OAAO,GADgB,QAAQ,QAAQ,YAAY,EAC5B,EAAE,aAAa,SAAS;AACjD;AAEA,MAAa,wBAAwB,SAAiB,aACpD,GAAG,sBAAsB,SAAS,QAAQ,EAAE,aAAa,SAAS,gBAAgB;AAEpF,MAAa,yBAAyB,aACpC,gBAAgB,yBAAyB,QAAQ;AAEnD,MAAM,2BAA2B;AAEjC,MAAM,0BAA0B,aAA2C;CACzE,wBAAwB,SAAS,gBAAgB,gBAAgB;CACjE,IAAI,CAAC,OAAO,UAAU,SAAS,eAAe,KAAK,SAAS,mBAAmB,GAC7E,MAAM,IAAI,MAAM,+CAA+C,SAAS,iBAAiB;AAE7F;AAEA,MAAM,2BAA2B,OAAe,SAAuB;CACrE,IAAI,MAAM,WAAW,GACnB,MAAM,IAAI,MAAM,GAAG,KAAK,mBAAmB;CAE7C,IAAI,CAAC,yBAAyB,KAAK,KAAK,G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