@eum-agent/desktop-presence 0.0.0-stage → 1.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/dist/index.js +13 -0
- package/package.json +51 -3
- package/ui/ui.js +47 -0
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
/** Owns this optional client feature and its browser activation. */
|
|
5
|
+
const plugin = {
|
|
6
|
+
name: "@eum-agent/desktop-presence",
|
|
7
|
+
apply(ctx) {
|
|
8
|
+
const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
|
|
9
|
+
if (existsSync(module)) ctx.client.registerUi({ module });
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { plugin as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eum-agent/desktop-presence",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"displayName": {
|
|
4
|
+
"en-US": "Desktop Presence",
|
|
5
|
+
"zh-CN": "桌面驻留"
|
|
6
|
+
},
|
|
7
|
+
"version": "1.1.0",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"description": "Tray, background presence and desktop wake controls",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"ui"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"zod": "^4.4.3",
|
|
22
|
+
"i18next": "^26.4.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@eum-agent/plugin": "1.1.0",
|
|
26
|
+
"@types/react": "^19.2.18",
|
|
27
|
+
"@types/react-dom": "^19.2.5",
|
|
28
|
+
"react": "^19.2.0",
|
|
29
|
+
"react-dom": "^19.2.0",
|
|
30
|
+
"vite": "^8.2.2",
|
|
31
|
+
"@eum-agent/protocol": "1.0.0",
|
|
32
|
+
"@eum-agent/kernel": "1.0.0",
|
|
33
|
+
"@types/ws": "^8.18.1",
|
|
34
|
+
"@testing-library/react": "^16.3.3",
|
|
35
|
+
"@testing-library/user-event": "^14.6.6",
|
|
36
|
+
"zustand": "^5.0.15",
|
|
37
|
+
"react-i18next": "^17.0.13",
|
|
38
|
+
"lucide-react": "^1.40.0",
|
|
39
|
+
"@types/semver": "7.8.0"
|
|
40
|
+
},
|
|
41
|
+
"yaoguang": {
|
|
42
|
+
"kind": "extension",
|
|
43
|
+
"description": {
|
|
44
|
+
"en-US": "Tray, background presence and desktop wake controls",
|
|
45
|
+
"zh-CN": "托盘、后台驻留与桌面唤醒"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {}
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsdown && vite build",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.ui.json"
|
|
53
|
+
}
|
|
6
54
|
}
|
package/ui/ui.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region ui-src/activation.ts
|
|
2
|
+
/** Acquires optional native resources before installing this feature's observers. */
|
|
3
|
+
function activateNativeFeature(ctx, feature, start) {
|
|
4
|
+
const native = ctx.services.get("native-client-features");
|
|
5
|
+
if (!native) {
|
|
6
|
+
start();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
native.activate(feature, ctx.signal).then(() => {
|
|
10
|
+
if (!ctx.signal.aborted) start();
|
|
11
|
+
}).catch(() => {});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ui-src/index.tsx
|
|
15
|
+
/** Browser module version understood by the host. */
|
|
16
|
+
var runtimeVersion = 5;
|
|
17
|
+
/** Desktop residency uses optional host capabilities and has no hard feature dependency. */
|
|
18
|
+
var provides = ["desktop-presence"];
|
|
19
|
+
/** Owns tray recovery and close-to-background; browsers acquire no native resources. */
|
|
20
|
+
function register(ctx) {
|
|
21
|
+
let ready = false;
|
|
22
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
23
|
+
const notify = () => {
|
|
24
|
+
for (const listener of listeners) listener();
|
|
25
|
+
};
|
|
26
|
+
ctx.services.provide("desktop-presence", {
|
|
27
|
+
host: () => ready ? ctx.services.get("native-presence") ?? null : null,
|
|
28
|
+
subscribe(listener) {
|
|
29
|
+
listeners.add(listener);
|
|
30
|
+
return () => {
|
|
31
|
+
listeners.delete(listener);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const stop = ctx.services.subscribe("native-presence", notify);
|
|
36
|
+
ctx.signal.addEventListener("abort", () => {
|
|
37
|
+
ready = false;
|
|
38
|
+
stop();
|
|
39
|
+
listeners.clear();
|
|
40
|
+
}, { once: true });
|
|
41
|
+
activateNativeFeature(ctx, "desktop-presence", () => {
|
|
42
|
+
ready = true;
|
|
43
|
+
notify();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { provides, register, runtimeVersion };
|
package/README.md
DELETED