@trycua/cua 0.2.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.
Files changed (91) hide show
  1. package/README.md +121 -0
  2. package/bin/cua.js +37 -0
  3. package/browser/cua_sdk-ffi.d.ts +6 -0
  4. package/browser/cua_sdk-ffi.js +3 -0
  5. package/browser/cua_sdk-ffi.ts +14 -0
  6. package/browser/cua_sdk.d.ts +2237 -0
  7. package/browser/cua_sdk.js +2607 -0
  8. package/browser/cua_sdk.ts +3644 -0
  9. package/browser/cyclops_sdk_schema-ffi.d.ts +6 -0
  10. package/browser/cyclops_sdk_schema-ffi.js +3 -0
  11. package/browser/cyclops_sdk_schema-ffi.ts +14 -0
  12. package/browser/cyclops_sdk_schema.d.ts +996 -0
  13. package/browser/cyclops_sdk_schema.js +2194 -0
  14. package/browser/cyclops_sdk_schema.ts +2934 -0
  15. package/browser/fleet_sdk-ffi.d.ts +28 -0
  16. package/browser/fleet_sdk-ffi.js +3 -0
  17. package/browser/fleet_sdk-ffi.ts +35 -0
  18. package/browser/fleet_sdk.d.ts +3056 -0
  19. package/browser/fleet_sdk.js +5088 -0
  20. package/browser/fleet_sdk.ts +6830 -0
  21. package/browser/index.d.ts +2 -0
  22. package/browser/index.js +18 -0
  23. package/browser/index.web.ts +34 -0
  24. package/browser/tsconfig.json +20 -0
  25. package/browser/wasm-bindgen/index.d.ts +2346 -0
  26. package/browser/wasm-bindgen/index.js +6642 -0
  27. package/browser/wasm-bindgen/index_bg.wasm +0 -0
  28. package/browser/wasm-bindgen/index_bg.wasm.d.ts +1154 -0
  29. package/dist/index.d.ts +118 -0
  30. package/dist/index.js +207 -0
  31. package/dist/mcp.d.ts +33 -0
  32. package/dist/mcp.js +41 -0
  33. package/dist/native/cua_sdk-ffi.d.ts +1038 -0
  34. package/dist/native/cua_sdk-ffi.js +5095 -0
  35. package/dist/native/cua_sdk.d.ts +15906 -0
  36. package/dist/native/cua_sdk.js +27061 -0
  37. package/dist/native/index.d.ts +7 -0
  38. package/dist/native/index.js +12 -0
  39. package/dist/native/node-runtime.d.ts +72 -0
  40. package/dist/native/node-runtime.js +35 -0
  41. package/dist/spaces/cursorArt.d.ts +27 -0
  42. package/dist/spaces/cursorArt.js +59 -0
  43. package/dist/spaces/errors.d.ts +81 -0
  44. package/dist/spaces/errors.js +102 -0
  45. package/dist/spaces/events.d.ts +154 -0
  46. package/dist/spaces/events.js +182 -0
  47. package/dist/spaces/groups.d.ts +130 -0
  48. package/dist/spaces/groups.js +275 -0
  49. package/dist/spaces/host.d.ts +71 -0
  50. package/dist/spaces/host.js +154 -0
  51. package/dist/spaces/index.d.ts +48 -0
  52. package/dist/spaces/index.js +44 -0
  53. package/dist/spaces/pip.d.ts +128 -0
  54. package/dist/spaces/pip.js +250 -0
  55. package/dist/spaces/presence.d.ts +187 -0
  56. package/dist/spaces/presence.js +449 -0
  57. package/dist/spaces/presenceTypes.check.d.ts +12 -0
  58. package/dist/spaces/presenceTypes.check.js +1 -0
  59. package/dist/spaces/presenceTypes.d.ts +47 -0
  60. package/dist/spaces/presenceTypes.js +7 -0
  61. package/dist/spaces/routines.d.ts +158 -0
  62. package/dist/spaces/routines.js +339 -0
  63. package/dist/spaces/thread.d.ts +147 -0
  64. package/dist/spaces/thread.js +285 -0
  65. package/dist/spaces/transport/http.d.ts +51 -0
  66. package/dist/spaces/transport/http.js +113 -0
  67. package/dist/spaces/transport/index.d.ts +19 -0
  68. package/dist/spaces/transport/index.js +19 -0
  69. package/dist/spaces/transport/session.d.ts +120 -0
  70. package/dist/spaces/transport/session.js +188 -0
  71. package/dist/spaces/transport/tauri.d.ts +50 -0
  72. package/dist/spaces/transport/tauri.js +90 -0
  73. package/dist/spaces/transport/types.d.ts +123 -0
  74. package/dist/spaces/transport/types.js +59 -0
  75. package/dist/teleport/controller.d.ts +34 -0
  76. package/dist/teleport/controller.js +107 -0
  77. package/dist/teleport/drop.d.ts +62 -0
  78. package/dist/teleport/drop.js +138 -0
  79. package/dist/teleport/dropZone.d.ts +59 -0
  80. package/dist/teleport/dropZone.js +166 -0
  81. package/dist/teleport/element.d.ts +28 -0
  82. package/dist/teleport/element.js +340 -0
  83. package/dist/teleport/index.d.ts +32 -0
  84. package/dist/teleport/index.js +32 -0
  85. package/dist/teleport/install.d.ts +31 -0
  86. package/dist/teleport/install.js +65 -0
  87. package/dist/teleport/model.d.ts +245 -0
  88. package/dist/teleport/model.js +334 -0
  89. package/dist/teleport/windowDrag.d.ts +86 -0
  90. package/dist/teleport/windowDrag.js +71 -0
  91. package/package.json +93 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Dragging a real app window onto a Space: the drop-zone state every client
3
+ * renders (the dragged window's preview, its app, the Space under the
4
+ * cursor). Events come from the SDK's window-drag monitor
5
+ * (`Teleport.startWindowDrag`, or a host relaying it); the preview is the
6
+ * SDK's in-memory thumbnail of that one window.
7
+ */
8
+ export const idleWindowDrop = {
9
+ active: false,
10
+ window: null,
11
+ app: null,
12
+ thumbnail: null,
13
+ overId: null,
14
+ x: 0,
15
+ y: 0,
16
+ };
17
+ /**
18
+ * The reducer. Only apps teleport can bring up start a drop (an
19
+ * unsupported app's window drag is ignored, as before). `end` returns the
20
+ * commit when released over a target.
21
+ */
22
+ export function reduceWindowDrop(s, e) {
23
+ switch (e.phase) {
24
+ case "start": {
25
+ if (!e.window || !e.app || e.app.capability === "unsupported") {
26
+ return { state: idleWindowDrop, commit: null, capture: null };
27
+ }
28
+ return {
29
+ state: { active: true, window: e.window, app: e.app, thumbnail: null, overId: null, x: e.x, y: e.y },
30
+ commit: null,
31
+ capture: e.window.windowId,
32
+ };
33
+ }
34
+ case "move":
35
+ return { state: s.active ? { ...s, x: e.x, y: e.y } : s, commit: null, capture: null };
36
+ case "thumbnail":
37
+ return { state: s.active ? { ...s, thumbnail: e.url } : s, commit: null, capture: null };
38
+ case "over":
39
+ return { state: s.active ? { ...s, overId: e.id } : s, commit: null, capture: null };
40
+ case "end": {
41
+ const commit = s.active && s.overId && s.app && s.window ? { targetId: s.overId, app: s.app, window: s.window } : null;
42
+ return { state: idleWindowDrop, commit, capture: null };
43
+ }
44
+ }
45
+ }
46
+ /** Screen point to client point, given the viewport's screen origin. */
47
+ export function screenToClient(x, y, origin) {
48
+ return { x: x - origin.x, y: y - origin.y };
49
+ }
50
+ /**
51
+ * A browser viewport's screen origin (approximate: assumes the browser
52
+ * chrome sits above the page, as in desktop browsers).
53
+ */
54
+ export function browserViewportOrigin(w) {
55
+ const side = Math.max(0, (w.outerWidth - w.innerWidth) / 2);
56
+ return { x: w.screenX + side, y: w.screenY + Math.max(0, w.outerHeight - w.innerHeight - side) };
57
+ }
58
+ /** The closest `[attr]` element's value at a client point, or null. */
59
+ export function targetAt(doc, x, y, attr = "data-space-id") {
60
+ const el = doc.elementFromPoint(x, y);
61
+ const hit = el?.closest(`[${attr}]`);
62
+ return hit?.getAttribute(attr) ?? null;
63
+ }
64
+ /** PNG bytes (from the SDK) as a `data:` URL for an `<img>`. */
65
+ export function pngDataUrl(bytes) {
66
+ const u8 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
67
+ let bin = "";
68
+ for (let i = 0; i < u8.length; i += 0x8000)
69
+ bin += String.fromCharCode(...u8.subarray(i, i + 0x8000));
70
+ return `data:image/png;base64,${btoa(bin)}`;
71
+ }
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@trycua/cua",
3
+ "version": "0.2.0",
4
+ "description": "The cua SDK for Node and the browser: sandboxes, cua-spacesd, media streaming, Spaces and the cua daemon, on a Rust core",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/trycua/cua.git"
10
+ },
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./spaces": {
19
+ "types": "./dist/spaces/index.d.ts",
20
+ "import": "./dist/spaces/index.js"
21
+ },
22
+ "./spaces/transport": {
23
+ "types": "./dist/spaces/transport/index.d.ts",
24
+ "import": "./dist/spaces/transport/index.js"
25
+ },
26
+ "./spaces/host": {
27
+ "types": "./dist/spaces/host.d.ts",
28
+ "import": "./dist/spaces/host.js"
29
+ },
30
+ "./spaces/pip": {
31
+ "types": "./dist/spaces/pip.d.ts",
32
+ "import": "./dist/spaces/pip.js"
33
+ },
34
+ "./spaces/presence": {
35
+ "types": "./dist/spaces/presence.d.ts",
36
+ "import": "./dist/spaces/presence.js"
37
+ },
38
+ "./spaces/routines": {
39
+ "types": "./dist/spaces/routines.d.ts",
40
+ "import": "./dist/spaces/routines.js"
41
+ },
42
+ "./spaces/groups": {
43
+ "types": "./dist/spaces/groups.d.ts",
44
+ "import": "./dist/spaces/groups.js"
45
+ },
46
+ "./teleport": {
47
+ "types": "./dist/teleport/index.d.ts",
48
+ "import": "./dist/teleport/index.js"
49
+ },
50
+ "./browser": {
51
+ "types": "./browser/index.d.ts",
52
+ "import": "./browser/index.js"
53
+ }
54
+ },
55
+ "files": [
56
+ "dist/index.js",
57
+ "dist/index.d.ts",
58
+ "dist/mcp.d.ts",
59
+ "dist/mcp.js",
60
+ "dist/native",
61
+ "dist/spaces",
62
+ "dist/teleport",
63
+ "browser",
64
+ "README.md",
65
+ "bin"
66
+ ],
67
+ "publishConfig": {
68
+ "access": "public"
69
+ },
70
+ "dependencies": {
71
+ "@ubjs/core": "0.31.0-3",
72
+ "@ubjs/node": "0.31.0-3"
73
+ },
74
+ "peerDependencies": {
75
+ "@modelcontextprotocol/client": "^2.1.0"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "@modelcontextprotocol/client": {
79
+ "optional": true
80
+ }
81
+ },
82
+ "bin": {
83
+ "cua": "bin/cua.js"
84
+ },
85
+ "optionalDependencies": {
86
+ "@trycua/cua-darwin-arm64": "0.2.0",
87
+ "@trycua/cua-darwin-x64": "0.2.0",
88
+ "@trycua/cua-linux-arm64-gnu": "0.2.0",
89
+ "@trycua/cua-linux-x64-gnu": "0.2.0",
90
+ "@trycua/cua-win32-arm64-msvc": "0.2.0",
91
+ "@trycua/cua-win32-x64-msvc": "0.2.0"
92
+ }
93
+ }