@gd-kirie/tray 0.0.0-stage → 0.11.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 CHANGED
@@ -1,3 +1,48 @@
1
- # Temporary Holding Version
1
+ # `@gd-kirie/tray`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@gd-kirie/tray` exposes system tray and native menu capabilities over an
4
+ existing Kirie Eventa context.
5
+
6
+ Install the plugin explicitly in `kirie.config.ts`:
7
+
8
+ ```ts
9
+ import tray from "@gd-kirie/tray/plugin";
10
+ import { defineKirieConfig } from "kirie";
11
+ import core from "kirie/plugin/core";
12
+
13
+ export default defineKirieConfig({
14
+ plugins: [core, tray],
15
+ });
16
+ ```
17
+
18
+ Create the browser client from the same context used by the application:
19
+
20
+ ```ts
21
+ import { createContext } from "@gd-kirie/ipc-eventa";
22
+ import { createTrayClient, trayMenuItemActivated } from "@gd-kirie/tray";
23
+
24
+ const eventa = createContext();
25
+ const tray = createTrayClient(eventa.context);
26
+
27
+ await tray.configure({
28
+ icon: "res://tray-template.svg",
29
+ iconAsTemplate: true,
30
+ tooltip: "Kirie",
31
+ });
32
+ await tray.setMenu([
33
+ { id: "show", text: "Show Kirie" },
34
+ { id: "enabled", text: "Enabled", type: "check", checked: true },
35
+ ]);
36
+ const stop = eventa.context.on(trayMenuItemActivated, ({ body }) => console.log(body?.id));
37
+ await tray.updateItem({ id: "enabled", checked: false });
38
+ ```
39
+
40
+ Browser icons are imported Godot resources referenced by `res://` paths. Use
41
+ black artwork with transparency when `iconAsTemplate` is enabled. The option is
42
+ supported only on macOS; other platforms reject `true`. See Apple's
43
+ [`NSImage.isTemplate`](https://developer.apple.com/documentation/appkit/nsimage/istemplate)
44
+ documentation for the native rendering behavior.
45
+
46
+ Menu types are `item`, `check`, `radio`, `multistate`, `separator`, and
47
+ `submenu`. IDs must be non-empty and unique across the menu tree. The tray
48
+ survives browser reloads and is destroyed explicitly or with its C# host.
@@ -0,0 +1,43 @@
1
+ import { InboundEventa } from "@moeru/eventa";
2
+ import { KirieEventaContext } from "@gd-kirie/ipc-eventa";
3
+
4
+ //#region src/index.d.ts
5
+ type TrayMenuItemType = "item" | "check" | "radio" | "multistate" | "separator" | "submenu";
6
+ interface TrayConfiguration {
7
+ icon: string;
8
+ /** Render the icon as a macOS template image. Non-macOS hosts reject `true`. */
9
+ iconAsTemplate?: boolean;
10
+ tooltip?: string;
11
+ visible?: boolean;
12
+ }
13
+ interface TrayMenuItem {
14
+ id: string;
15
+ text: string;
16
+ type?: TrayMenuItemType;
17
+ icon?: string;
18
+ accelerator?: number;
19
+ disabled?: boolean;
20
+ checked?: boolean;
21
+ state?: number;
22
+ maxStates?: number;
23
+ tooltip?: string;
24
+ indent?: number;
25
+ children?: TrayMenuItem[];
26
+ }
27
+ interface TrayMenuItemUpdate extends Omit<Partial<TrayMenuItem>, "id" | "type" | "children"> {
28
+ id: string;
29
+ clearIcon?: boolean;
30
+ }
31
+ interface TrayClient {
32
+ configure: (configuration: TrayConfiguration) => Promise<void>;
33
+ setMenu: (items: TrayMenuItem[]) => Promise<void>;
34
+ updateItem: (update: TrayMenuItemUpdate) => Promise<void>;
35
+ destroy: () => Promise<void>;
36
+ }
37
+ declare const trayMenuItemActivated: InboundEventa<{
38
+ id: string;
39
+ }>;
40
+ declare function createTrayClient(context: KirieEventaContext): TrayClient;
41
+ //#endregion
42
+ export { TrayClient, TrayConfiguration, TrayMenuItem, TrayMenuItemType, TrayMenuItemUpdate, createTrayClient, trayMenuItemActivated };
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAIY,gBAAA;AAAA,UAEK,iBAAA;EACf,IAAA;EAHU;EAKV,cAAA;EACA,OAAA;EACA,OAAA;AAAA;AAAA,UAGe,YAAA;EACf,EAAA;EACA,IAAA;EACA,IAAA,GAAO,gBAAA;EACP,IAAA;EACA,WAAA;EACA,QAAA;EACA,OAAA;EACA,KAAA;EACA,SAAA;EACA,OAAA;EACA,MAAA;EACA,QAAA,GAAW,YAAA;AAAA;AAAA,UAGI,kBAAA,SAA2B,IAAA,CAAK,OAAA,CAAQ,YAAA;EACvD,EAAA;EACA,SAAA;AAAA;AAAA,UAGe,UAAA;EACf,SAAA,GAAY,aAAA,EAAe,iBAAA,KAAsB,OAAA;EACjD,OAAA,GAAU,KAAA,EAAO,YAAA,OAAmB,OAAA;EACpC,UAAA,GAAa,MAAA,EAAQ,kBAAA,KAAuB,OAAA;EAC5C,OAAA,QAAe,OAAA;AAAA;AAAA,cAYJ,qBAAA,EAAuB,aAAA;EAAgB,EAAA;AAAA;AAAA,iBAIpC,gBAAA,CAAiB,OAAA,EAAS,kBAAA,GAAqB,UAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { defineInboundEventa, defineInvokeEventa, defineInvokes } from "@moeru/eventa";
2
+ //#region src/index.ts
3
+ const events = {
4
+ configure: defineInvokeEventa("kirie:tray:configure"),
5
+ setMenu: defineInvokeEventa("kirie:tray:set-menu"),
6
+ updateItem: defineInvokeEventa("kirie:tray:update-item"),
7
+ destroy: defineInvokeEventa("kirie:tray:destroy")
8
+ };
9
+ const trayMenuItemActivated = defineInboundEventa("kirie:tray:menu-item-activated");
10
+ function createTrayClient(context) {
11
+ const invokes = defineInvokes(context, events);
12
+ return {
13
+ async configure(configuration) {
14
+ await invokes.configure(configuration);
15
+ },
16
+ async setMenu(items) {
17
+ await invokes.setMenu(items);
18
+ },
19
+ async updateItem(update) {
20
+ await invokes.updateItem(update);
21
+ },
22
+ async destroy() {
23
+ await invokes.destroy({});
24
+ }
25
+ };
26
+ }
27
+ //#endregion
28
+ export { createTrayClient, trayMenuItemActivated };
29
+
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { KirieEventaContext } from \"@gd-kirie/ipc-eventa\";\nimport type { InboundEventa } from \"@moeru/eventa\";\nimport { defineInboundEventa, defineInvokeEventa, defineInvokes } from \"@moeru/eventa\";\n\nexport type TrayMenuItemType = \"item\" | \"check\" | \"radio\" | \"multistate\" | \"separator\" | \"submenu\";\n\nexport interface TrayConfiguration {\n icon: string;\n /** Render the icon as a macOS template image. Non-macOS hosts reject `true`. */\n iconAsTemplate?: boolean;\n tooltip?: string;\n visible?: boolean;\n}\n\nexport interface TrayMenuItem {\n id: string;\n text: string;\n type?: TrayMenuItemType;\n icon?: string;\n accelerator?: number;\n disabled?: boolean;\n checked?: boolean;\n state?: number;\n maxStates?: number;\n tooltip?: string;\n indent?: number;\n children?: TrayMenuItem[];\n}\n\nexport interface TrayMenuItemUpdate extends Omit<Partial<TrayMenuItem>, \"id\" | \"type\" | \"children\"> {\n id: string;\n clearIcon?: boolean;\n}\n\nexport interface TrayClient {\n configure: (configuration: TrayConfiguration) => Promise<void>;\n setMenu: (items: TrayMenuItem[]) => Promise<void>;\n updateItem: (update: TrayMenuItemUpdate) => Promise<void>;\n destroy: () => Promise<void>;\n}\n\ntype EmptyPayload = Record<string, never>;\n\nconst events = {\n configure: defineInvokeEventa<EmptyPayload, TrayConfiguration>(\"kirie:tray:configure\"),\n setMenu: defineInvokeEventa<EmptyPayload, TrayMenuItem[]>(\"kirie:tray:set-menu\"),\n updateItem: defineInvokeEventa<EmptyPayload, TrayMenuItemUpdate>(\"kirie:tray:update-item\"),\n destroy: defineInvokeEventa<EmptyPayload, EmptyPayload>(\"kirie:tray:destroy\"),\n};\n\nexport const trayMenuItemActivated: InboundEventa<{ id: string }> = defineInboundEventa(\n \"kirie:tray:menu-item-activated\",\n);\n\nexport function createTrayClient(context: KirieEventaContext): TrayClient {\n const invokes = defineInvokes(context, events);\n\n return {\n async configure(configuration) {\n await invokes.configure(configuration);\n },\n async setMenu(items) {\n await invokes.setMenu(items);\n },\n async updateItem(update) {\n await invokes.updateItem(update);\n },\n async destroy() {\n await invokes.destroy({});\n },\n };\n}\n"],"mappings":";;AA2CA,MAAM,SAAS;CACb,WAAW,mBAAoD,sBAAsB;CACrF,SAAS,mBAAiD,qBAAqB;CAC/E,YAAY,mBAAqD,wBAAwB;CACzF,SAAS,mBAA+C,oBAAoB;AAC9E;AAEA,MAAa,wBAAuD,oBAClE,gCACF;AAEA,SAAgB,iBAAiB,SAAyC;CACxE,MAAM,UAAU,cAAc,SAAS,MAAM;CAE7C,OAAO;EACL,MAAM,UAAU,eAAe;GAC7B,MAAM,QAAQ,UAAU,aAAa;EACvC;EACA,MAAM,QAAQ,OAAO;GACnB,MAAM,QAAQ,QAAQ,KAAK;EAC7B;EACA,MAAM,WAAW,QAAQ;GACvB,MAAM,QAAQ,WAAW,MAAM;EACjC;EACA,MAAM,UAAU;GACd,MAAM,QAAQ,QAAQ,CAAC,CAAC;EAC1B;CACF;AACF"}
@@ -0,0 +1,7 @@
1
+ import { KiriePlugin } from "kirie/plugin";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare const _default: KiriePlugin;
5
+ //#endregion
6
+ export { _default as default };
7
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;cAMA,QAAA,EAQM,WAAA"}
package/dist/plugin.js ADDED
@@ -0,0 +1,14 @@
1
+ import { defineKiriePlugin } from "kirie/plugin";
2
+ //#endregion
3
+ //#region src/plugin.ts
4
+ var plugin_default = defineKiriePlugin({
5
+ id: "tray",
6
+ dotnetPackages: [{
7
+ id: "GdKirie.Tray",
8
+ version: "0.11.0"
9
+ }]
10
+ });
11
+ //#endregion
12
+ export { plugin_default as default };
13
+
14
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","names":["packageJson.version"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import type { KiriePlugin } from \"kirie/plugin\";\nimport { defineKiriePlugin } from \"kirie/plugin\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\n\n// ADR-0012: Tray is installed explicitly and owns its .NET host dependency.\n// See docs/decisions/0012-extract-system-tray-into-a-kirie-plugin.md.\nexport default defineKiriePlugin({\n id: \"tray\",\n dotnetPackages: [\n {\n id: \"GdKirie.Tray\",\n version: packageJson.version,\n },\n ],\n}) as KiriePlugin;\n"],"mappings":";;;ACMA,IAAA,iBAAe,kBAAkB;CAC/B,IAAI;CACJ,gBAAgB,CACd;EACE,IAAI;EACKA;CACX,CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@gd-kirie/tray",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.11.0",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/moeru-ai/godot-kirie.git",
8
+ "directory": "packages/tray"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./plugin": {
18
+ "types": "./dist/plugin.d.ts",
19
+ "import": "./dist/plugin.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "@gd-kirie/ipc-eventa": "0.11.0",
27
+ "@moeru/eventa": "^1.0.2"
28
+ },
29
+ "peerDependencies": {
30
+ "kirie": "^0.11.0"
31
+ },
32
+ "devDependencies": {
33
+ "tsdown": "^0.22.2",
34
+ "typescript": "^6.0.3",
35
+ "vitest": "4.1.10"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org"
40
+ },
41
+ "scripts": {
42
+ "build": "tsdown",
43
+ "test:run": "vitest run",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit"
45
+ }
6
46
  }