opentray 0.0.0 → 0.1.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 +8 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -10
package/README.md
CHANGED
|
@@ -16,3 +16,11 @@ pnpm add opentray
|
|
|
16
16
|
- Resolve per-platform optional binary packages.
|
|
17
17
|
|
|
18
18
|
`packages/cli` is the only unscoped npm package in this monorepo.
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
Run a protocol-only example that creates a surface, creates a tray, dispatches an extension command, and prints each client frame:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm --filter opentray example:basic
|
|
26
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ClientFrame, SurfaceOptions, SurfaceRef, TrayId, TrayOptions } from "@opentray/spec";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface OpenTrayTransport {
|
|
5
|
+
send(frame: ClientFrame): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
interface SurfaceHandle {
|
|
8
|
+
surface: SurfaceRef;
|
|
9
|
+
createTray(options: TrayOptions): Promise<TrayHandle>;
|
|
10
|
+
}
|
|
11
|
+
interface TrayHandle {
|
|
12
|
+
surface: SurfaceRef;
|
|
13
|
+
trayId: TrayId;
|
|
14
|
+
commandExtension(ext: string, data: unknown): Promise<void>;
|
|
15
|
+
destroy(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
declare const createClient: (transport: OpenTrayTransport) => {
|
|
18
|
+
createSurface(options: SurfaceOptions): Promise<SurfaceHandle>;
|
|
19
|
+
};
|
|
20
|
+
declare const createSurfaceHandle: (transport: OpenTrayTransport, surface: SurfaceRef) => SurfaceHandle;
|
|
21
|
+
declare const createTrayHandle: (transport: OpenTrayTransport, surface: SurfaceRef, trayId: TrayId) => TrayHandle;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { OpenTrayTransport, SurfaceHandle, TrayHandle, createClient, createSurfaceHandle, createTrayHandle };
|
|
24
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAEiB,iBAAA;EACf,IAAA,CAAK,KAAA,EAAO,WAAA,GAAc,OAAO;AAAA;AAAA,UAGlB,aAAA;EACf,OAAA,EAAS,UAAA;EACT,UAAA,CAAW,OAAA,EAAS,WAAA,GAAc,OAAA,CAAQ,UAAA;AAAA;AAAA,UAG3B,UAAA;EACf,OAAA,EAAS,UAAA;EACT,MAAA,EAAQ,MAAA;EACR,gBAAA,CAAiB,GAAA,UAAa,IAAA,YAAgB,OAAA;EAC9C,OAAA,IAAW,OAAA;AAAA;AAAA,cAGA,YAAA,GAAgB,SAAA,EAAW,iBAAA;yBACT,cAAA,GAAiB,OAAA,CAAQ,aAAA;AAAA;AAAA,cAU3C,mBAAA,GAAuB,SAAA,EAAW,iBAAA,EAAmB,OAAA,EAAS,UAAA,KAAa,aAAA;AAAA,cAQ3E,gBAAA,GACX,SAAA,EAAW,iBAAA,EACX,OAAA,EAAS,UAAA,EACT,MAAA,EAAQ,MAAA,KACP,UAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
const createClient = (transport) => ({ async createSurface(options) {
|
|
3
|
+
await transport.send({
|
|
4
|
+
type: "create-surface",
|
|
5
|
+
...options
|
|
6
|
+
});
|
|
7
|
+
return createSurfaceHandle(transport, {
|
|
8
|
+
surfaceId: `pending:${options.appId}`,
|
|
9
|
+
appId: options.appId
|
|
10
|
+
});
|
|
11
|
+
} });
|
|
12
|
+
const createSurfaceHandle = (transport, surface) => ({
|
|
13
|
+
surface,
|
|
14
|
+
async createTray(options) {
|
|
15
|
+
await transport.send({
|
|
16
|
+
type: "create-tray",
|
|
17
|
+
surface,
|
|
18
|
+
tray: options
|
|
19
|
+
});
|
|
20
|
+
return createTrayHandle(transport, surface, options.trayId ?? "pending");
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const createTrayHandle = (transport, surface, trayId) => ({
|
|
24
|
+
surface,
|
|
25
|
+
trayId,
|
|
26
|
+
async commandExtension(ext, data) {
|
|
27
|
+
await transport.send({
|
|
28
|
+
type: "ext-command",
|
|
29
|
+
surfaceId: surface.surfaceId,
|
|
30
|
+
trayId,
|
|
31
|
+
ext,
|
|
32
|
+
data
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
async destroy() {
|
|
36
|
+
await transport.send({
|
|
37
|
+
type: "destroy-tray",
|
|
38
|
+
surfaceId: surface.surfaceId,
|
|
39
|
+
trayId
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { createClient, createSurfaceHandle, createTrayHandle };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { ClientFrame, SurfaceOptions, SurfaceRef, TrayId, TrayOptions } from \"@opentray/spec\";\n\nexport interface OpenTrayTransport {\n send(frame: ClientFrame): Promise<void>;\n}\n\nexport interface SurfaceHandle {\n surface: SurfaceRef;\n createTray(options: TrayOptions): Promise<TrayHandle>;\n}\n\nexport interface TrayHandle {\n surface: SurfaceRef;\n trayId: TrayId;\n commandExtension(ext: string, data: unknown): Promise<void>;\n destroy(): Promise<void>;\n}\n\nexport const createClient = (transport: OpenTrayTransport) => ({\n async createSurface(options: SurfaceOptions): Promise<SurfaceHandle> {\n await transport.send({ type: \"create-surface\", ...options });\n const surface: SurfaceRef = {\n surfaceId: `pending:${options.appId}`,\n appId: options.appId,\n };\n return createSurfaceHandle(transport, surface);\n },\n});\n\nexport const createSurfaceHandle = (transport: OpenTrayTransport, surface: SurfaceRef): SurfaceHandle => ({\n surface,\n async createTray(options: TrayOptions): Promise<TrayHandle> {\n await transport.send({ type: \"create-tray\", surface, tray: options });\n return createTrayHandle(transport, surface, options.trayId ?? \"pending\");\n },\n});\n\nexport const createTrayHandle = (\n transport: OpenTrayTransport,\n surface: SurfaceRef,\n trayId: TrayId,\n): TrayHandle => ({\n surface,\n trayId,\n async commandExtension(ext: string, data: unknown): Promise<void> {\n await transport.send({\n type: \"ext-command\",\n surfaceId: surface.surfaceId,\n trayId,\n ext,\n data,\n });\n },\n async destroy(): Promise<void> {\n await transport.send({\n type: \"destroy-tray\",\n surfaceId: surface.surfaceId,\n trayId,\n });\n },\n});\n"],"mappings":";AAkBA,MAAa,gBAAgB,eAAkC,EAC7D,MAAM,cAAc,SAAiD;CACnE,MAAM,UAAU,KAAK;EAAE,MAAM;EAAkB,GAAG;CAAQ,CAAC;CAK3D,OAAO,oBAAoB,WAAW;EAHpC,WAAW,WAAW,QAAQ;EAC9B,OAAO,QAAQ;CAE2B,CAAC;AAC/C,EACF;AAEA,MAAa,uBAAuB,WAA8B,aAAwC;CACxG;CACA,MAAM,WAAW,SAA2C;EAC1D,MAAM,UAAU,KAAK;GAAE,MAAM;GAAe;GAAS,MAAM;EAAQ,CAAC;EACpE,OAAO,iBAAiB,WAAW,SAAS,QAAQ,UAAU,SAAS;CACzE;AACF;AAEA,MAAa,oBACX,WACA,SACA,YACgB;CAChB;CACA;CACA,MAAM,iBAAiB,KAAa,MAA8B;EAChE,MAAM,UAAU,KAAK;GACnB,MAAM;GACN,WAAW,QAAQ;GACnB;GACA;GACA;EACF,CAAC;CACH;CACA,MAAM,UAAyB;EAC7B,MAAM,UAAU,KAAK;GACnB,MAAM;GACN,WAAW,QAAQ;GACnB;EACF,CAAC;CACH;AACF"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opentray",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Developer-facing OpenTray SDK and CLI package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/jixoai/opentray"
|
|
9
10
|
},
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
|
-
"types": "./dist/index.d.
|
|
13
|
-
"import": "./dist/index.
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"import": "./dist/index.mjs"
|
|
14
15
|
},
|
|
15
16
|
"./package.json": "./package.json"
|
|
16
17
|
},
|
|
@@ -20,14 +21,25 @@
|
|
|
20
21
|
],
|
|
21
22
|
"sideEffects": false,
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@opentray/spec": "0.
|
|
24
|
+
"@opentray/spec": "0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"tsdown": "^0.22.1",
|
|
28
|
+
"typescript": "^6.0.3",
|
|
29
|
+
"vitest": "^4.1.7"
|
|
24
30
|
},
|
|
25
31
|
"optionalDependencies": {
|
|
26
|
-
"@opentray/darwin-arm64": "0.0.0",
|
|
27
32
|
"@opentray/darwin-x64": "0.0.0",
|
|
28
|
-
"@opentray/
|
|
29
|
-
"@opentray/windows-x64": "0.0.0",
|
|
33
|
+
"@opentray/darwin-arm64": "0.0.0",
|
|
30
34
|
"@opentray/linux-x64": "0.0.0",
|
|
31
|
-
"@opentray/linux-arm64": "0.0.0"
|
|
35
|
+
"@opentray/linux-arm64": "0.0.0",
|
|
36
|
+
"@opentray/windows-arm64": "0.0.0",
|
|
37
|
+
"@opentray/windows-x64": "0.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsdown src/index.ts --format esm --dts",
|
|
41
|
+
"example:basic": "bun run examples/basic-surface.ts",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
32
44
|
}
|
|
33
45
|
}
|