@dxos/plugin-native 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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 (59) hide show
  1. package/dist/lib/browser/NativePlugin-QANFCCIM.mjs +28 -0
  2. package/dist/lib/browser/NativePlugin-QANFCCIM.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +14 -51
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/translations.mjs +18 -0
  7. package/dist/lib/browser/translations.mjs.map +7 -0
  8. package/dist/types/src/NativePlugin.d.ts +1 -0
  9. package/dist/types/src/NativePlugin.d.ts.map +1 -1
  10. package/dist/types/src/capabilities/index.d.ts +4 -3
  11. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  12. package/dist/types/src/capabilities/ollama.d.ts +7 -0
  13. package/dist/types/src/capabilities/ollama.d.ts.map +1 -0
  14. package/dist/types/src/capabilities/spotlight-listener.d.ts +8 -0
  15. package/dist/types/src/capabilities/spotlight-listener.d.ts.map +1 -0
  16. package/dist/types/src/capabilities/updater.d.ts +5 -0
  17. package/dist/types/src/capabilities/updater.d.ts.map +1 -0
  18. package/dist/types/src/constants.d.ts +2 -0
  19. package/dist/types/src/constants.d.ts.map +1 -0
  20. package/dist/types/src/index.d.ts +2 -2
  21. package/dist/types/src/index.d.ts.map +1 -1
  22. package/dist/types/src/translations.d.ts +5 -6
  23. package/dist/types/src/translations.d.ts.map +1 -1
  24. package/dist/types/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +28 -18
  26. package/src/NativePlugin.tsx +15 -12
  27. package/src/capabilities/index.ts +5 -3
  28. package/src/capabilities/{ollama/ollama.ts → ollama.ts} +4 -3
  29. package/src/capabilities/spotlight-listener.ts +58 -0
  30. package/src/capabilities/updater.ts +129 -0
  31. package/src/constants.ts +7 -0
  32. package/src/index.ts +6 -2
  33. package/src/meta.ts +1 -1
  34. package/src/translations.ts +5 -5
  35. package/dist/lib/browser/chunk-6374DBU4.mjs +0 -15
  36. package/dist/lib/browser/chunk-6374DBU4.mjs.map +0 -7
  37. package/dist/lib/browser/ollama-KSB3XG6S.mjs +0 -74
  38. package/dist/lib/browser/ollama-KSB3XG6S.mjs.map +0 -7
  39. package/dist/lib/browser/updater-XQTSH4ZZ.mjs +0 -133
  40. package/dist/lib/browser/updater-XQTSH4ZZ.mjs.map +0 -7
  41. package/dist/lib/browser/window-JDFVLF4U.mjs +0 -38
  42. package/dist/lib/browser/window-JDFVLF4U.mjs.map +0 -7
  43. package/dist/types/src/capabilities/ollama/index.d.ts +0 -3
  44. package/dist/types/src/capabilities/ollama/index.d.ts.map +0 -1
  45. package/dist/types/src/capabilities/ollama/ollama.d.ts +0 -6
  46. package/dist/types/src/capabilities/ollama/ollama.d.ts.map +0 -1
  47. package/dist/types/src/capabilities/updater/index.d.ts +0 -3
  48. package/dist/types/src/capabilities/updater/index.d.ts.map +0 -1
  49. package/dist/types/src/capabilities/updater/updater.d.ts +0 -5
  50. package/dist/types/src/capabilities/updater/updater.d.ts.map +0 -1
  51. package/dist/types/src/capabilities/window/index.d.ts +0 -3
  52. package/dist/types/src/capabilities/window/index.d.ts.map +0 -1
  53. package/dist/types/src/capabilities/window/window.d.ts +0 -11
  54. package/dist/types/src/capabilities/window/window.d.ts.map +0 -1
  55. package/src/capabilities/ollama/index.ts +0 -7
  56. package/src/capabilities/updater/index.ts +0 -7
  57. package/src/capabilities/updater/updater.ts +0 -82
  58. package/src/capabilities/window/index.ts +0 -7
  59. package/src/capabilities/window/window.ts +0 -72
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/updater/updater.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type } from '@tauri-apps/plugin-os';\nimport { relaunch } from '@tauri-apps/plugin-process';\nimport { type DownloadEvent, check } from '@tauri-apps/plugin-updater';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as Function from 'effect/Function';\nimport * as Match from 'effect/Match';\nimport * as Schedule from 'effect/Schedule';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\nimport { meta } from '../../meta';\n\nconst SUPPORTS_OTA = ['linux', 'macos', 'windows'];\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Skip updates if not supported or in dev mode.\n const platform = type();\n if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === 'localhost') {\n return;\n }\n\n const { invoke } = yield* Capability.get(Common.Capability.OperationInvoker);\n\n // https://tauri.app/plugin/updater/#checking-for-updates\n const action = Effect.gen(function* () {\n log.info('checking for updates');\n const update = yield* Effect.tryPromise(() => check());\n log.info('checked for updates', { version: update?.version, currentVersion: update?.currentVersion });\n if (update) {\n log.info('update available', update);\n let downloaded = 0;\n let contentLength = 0;\n\n const handleDownload = Match.type<DownloadEvent>().pipe(\n Match.when({ event: 'Started' }, (event) => {\n contentLength = event.data.contentLength ?? 0;\n log.info('download started', { contentLength });\n }),\n Match.when({ event: 'Progress' }, (event) => {\n downloaded += event.data.chunkLength;\n log.verbose('download progress', { downloaded, contentLength });\n }),\n Match.when({ event: 'Finished' }, () => {\n log.info('download completed');\n }),\n Match.exhaustive,\n );\n\n yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));\n\n yield* invoke(Common.LayoutOperation.AddToast, {\n id: `${meta.id}/update-ready`,\n title: ['update ready label', { ns: meta.id }],\n description: ['update ready description', { ns: meta.id }],\n duration: Infinity,\n actionLabel: ['update label', { ns: meta.id }],\n actionAlt: ['update alt', { ns: meta.id }],\n onAction: () => relaunch(),\n });\n }\n });\n\n const fiber: Fiber.RuntimeFiber<number, unknown> = Function.pipe(\n // prettier-ignore\n action,\n Effect.repeat(Schedule.fixed(Duration.hours(1))),\n Effect.runFork,\n );\n\n return Capability.contributes(Common.Capability.Null, null, () =>\n Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),\n );\n }),\n);\n"],
5
- "mappings": ";;;;;AAIA,SAASA,YAAY;AACrB,SAASC,gBAAgB;AACzB,SAA6BC,aAAa;AAC1C,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,YAAYC,cAAc;AACnC,SAASC,WAAW;;AAIpB,IAAMC,eAAe;EAAC;EAAS;EAAS;;AAExC,IAAA,kBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,WAAWC,KAAAA;AACjB,MAAI,CAACL,aAAaM,SAASF,QAAAA,KAAaG,OAAOC,SAASC,aAAa,aAAa;AAChF;EACF;AAEA,QAAM,EAAEC,OAAM,IAAK,OAAOT,WAAWU,IAAIC,OAAOX,WAAWY,gBAAgB;AAG3E,QAAMC,SAAgBC,WAAI,aAAA;AACxBC,QAAIC,KAAK,wBAAA,QAAA;;;;;;AACT,UAAMC,SAAS,OAAcC,kBAAW,MAAMC,MAAAA,CAAAA;AAC9CJ,QAAIC,KAAK,uBAAuB;MAAEI,SAASH,QAAQG;MAASC,gBAAgBJ,QAAQI;IAAe,GAAA;;;;;;AACnG,QAAIJ,QAAQ;AACVF,UAAIC,KAAK,oBAAoBC,QAAAA;;;;;;AAC7B,UAAIK,aAAa;AACjB,UAAIC,gBAAgB;AAEpB,YAAMC,iBAAuBpB,WAAI,EAAkBqB,KAC3CC,WAAK;QAAEC,OAAO;MAAU,GAAG,CAACA,UAAAA;AAChCJ,wBAAgBI,MAAMC,KAAKL,iBAAiB;AAC5CR,YAAIC,KAAK,oBAAoB;UAAEO;QAAc,GAAA;;;;;;MAC/C,CAAA,GACMG,WAAK;QAAEC,OAAO;MAAW,GAAG,CAACA,UAAAA;AACjCL,sBAAcK,MAAMC,KAAKC;AACzBd,YAAIe,QAAQ,qBAAqB;UAAER;UAAYC;QAAc,GAAA;;;;;;MAC/D,CAAA,GACMG,WAAK;QAAEC,OAAO;MAAW,GAAG,MAAA;AAChCZ,YAAIC,KAAK,sBAAA,QAAA;;;;;;MACX,CAAA,GACMe,gBAAU;AAGlB,aAAcb,kBAAW,MAAMD,OAAOe,mBAAmBR,cAAAA,CAAAA;AAEzD,aAAOf,OAAOE,OAAOsB,gBAAgBC,UAAU;QAC7CC,IAAI,GAAGC,KAAKD,EAAE;QACdE,OAAO;UAAC;UAAsB;YAAEC,IAAIF,KAAKD;UAAG;;QAC5CI,aAAa;UAAC;UAA4B;YAAED,IAAIF,KAAKD;UAAG;;QACxDK,UAAUC;QACVC,aAAa;UAAC;UAAgB;YAAEJ,IAAIF,KAAKD;UAAG;;QAC5CQ,WAAW;UAAC;UAAc;YAAEL,IAAIF,KAAKD;UAAG;;QACxCS,UAAU,MAAMC,SAAAA;MAClB,CAAA;IACF;EACF,CAAA;AAEA,QAAMC,QAAsDrB;;IAE1DZ;IACOkC,cAAgBC,eAAeC,eAAM,CAAA,CAAA,CAAA;IACrCC;EAAO;AAGhB,SAAOlD,WAAWmD,YAAYxC,OAAOX,WAAWoD,MAAM,MAAM,MACnDC,YAAK,MAAaC,eAAcC,gBAAUT,KAAAA,CAAAA,CAAAA,CAAAA;AAErD,CAAA,CAAA;",
6
- "names": ["type", "relaunch", "check", "Duration", "Effect", "Fiber", "Function", "Match", "Schedule", "Capability", "Common", "log", "SUPPORTS_OTA", "Capability", "makeModule", "fnUntraced", "platform", "type", "includes", "window", "location", "hostname", "invoke", "get", "Common", "OperationInvoker", "action", "gen", "log", "info", "update", "tryPromise", "check", "version", "currentVersion", "downloaded", "contentLength", "handleDownload", "pipe", "when", "event", "data", "chunkLength", "verbose", "exhaustive", "downloadAndInstall", "LayoutOperation", "AddToast", "id", "meta", "title", "ns", "description", "duration", "Infinity", "actionLabel", "actionAlt", "onAction", "relaunch", "fiber", "repeat", "fixed", "hours", "runFork", "contributes", "Null", "sync", "runSync", "interrupt"]
7
- }
@@ -1,38 +0,0 @@
1
- // src/capabilities/window/window.ts
2
- import { getCurrentWindow } from "@tauri-apps/api/window";
3
- import * as Effect from "effect/Effect";
4
- import { Capability, Common } from "@dxos/app-framework";
5
- var window_default = Capability.makeModule(Effect.fnUntraced(function* () {
6
- const appWindow = getCurrentWindow();
7
- const cleanupDragRegions = setupWindowDrag(appWindow);
8
- return Capability.contributes(Common.Capability.Null, null, Effect.fnUntraced(function* () {
9
- cleanupDragRegions();
10
- }));
11
- }));
12
- var INTERACTIVE_SELECTORS = '.app-no-drag, button, a, input, select, textarea, [role="button"], [role="menuitem"]';
13
- var setupWindowDrag = (appWindow) => {
14
- const handleMouseDown = (event) => {
15
- const target = event.target;
16
- if (!target) {
17
- return;
18
- }
19
- const dragElement = target.closest(".app-drag");
20
- if (!dragElement) {
21
- return;
22
- }
23
- const interactiveElement = target.closest(INTERACTIVE_SELECTORS);
24
- if (interactiveElement && dragElement.contains(interactiveElement)) {
25
- return;
26
- }
27
- event.preventDefault();
28
- void appWindow.startDragging();
29
- };
30
- document.addEventListener("mousedown", handleMouseDown);
31
- return () => {
32
- document.removeEventListener("mousedown", handleMouseDown);
33
- };
34
- };
35
- export {
36
- window_default as default
37
- };
38
- //# sourceMappingURL=window-JDFVLF4U.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/window/window.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { getCurrentWindow } from '@tauri-apps/api/window';\nimport * as Effect from 'effect/Effect';\n\nimport { Capability, Common } from '@dxos/app-framework';\n\n/**\n * Window capability module.\n * Sets up window drag regions for Tauri windows.\n * Note: Window state persistence (size/position) is handled on the Rust side\n * in src-tauri/src/window_state.rs for instant restoration on startup.\n */\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const appWindow = getCurrentWindow();\n\n // Set up drag regions for window dragging.\n const cleanupDragRegions = setupWindowDrag(appWindow);\n\n return Capability.contributes(\n Common.Capability.Null,\n null,\n Effect.fnUntraced(function* () {\n cleanupDragRegions();\n }),\n );\n }),\n);\n\n/**\n * Interactive element selectors that should not trigger window dragging.\n */\nconst INTERACTIVE_SELECTORS = '.app-no-drag, button, a, input, select, textarea, [role=\"button\"], [role=\"menuitem\"]';\n\n/**\n * Sets up window drag regions.\n *\n * Tauri 2.0 does not support the `-webkit-app-region` CSS property with overlay titlebars.\n * This uses the Tauri window API to enable dragging on elements with the `app-drag` class.\n */\nconst setupWindowDrag = (appWindow: ReturnType<typeof getCurrentWindow>): (() => void) => {\n const handleMouseDown = (event: MouseEvent) => {\n const target = event.target as Element | null;\n if (!target) {\n return;\n }\n\n // Check if the click target or any ancestor has the app-drag class.\n const dragElement = target.closest('.app-drag');\n if (!dragElement) {\n return;\n }\n\n // Don't trigger drag on interactive elements within the drag region.\n const interactiveElement = target.closest(INTERACTIVE_SELECTORS);\n if (interactiveElement && dragElement.contains(interactiveElement)) {\n return;\n }\n\n event.preventDefault();\n void appWindow.startDragging();\n };\n\n document.addEventListener('mousedown', handleMouseDown);\n\n return () => {\n document.removeEventListener('mousedown', handleMouseDown);\n };\n};\n"],
5
- "mappings": ";AAIA,SAASA,wBAAwB;AACjC,YAAYC,YAAY;AAExB,SAASC,YAAYC,cAAc;AAQnC,IAAA,iBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,YAAYC,iBAAAA;AAGlB,QAAMC,qBAAqBC,gBAAgBH,SAAAA;AAE3C,SAAOH,WAAWO,YAChBC,OAAOR,WAAWS,MAClB,MACOP,kBAAW,aAAA;AAChBG,uBAAAA;EACF,CAAA,CAAA;AAEJ,CAAA,CAAA;AAMF,IAAMK,wBAAwB;AAQ9B,IAAMJ,kBAAkB,CAACH,cAAAA;AACvB,QAAMQ,kBAAkB,CAACC,UAAAA;AACvB,UAAMC,SAASD,MAAMC;AACrB,QAAI,CAACA,QAAQ;AACX;IACF;AAGA,UAAMC,cAAcD,OAAOE,QAAQ,WAAA;AACnC,QAAI,CAACD,aAAa;AAChB;IACF;AAGA,UAAME,qBAAqBH,OAAOE,QAAQL,qBAAAA;AAC1C,QAAIM,sBAAsBF,YAAYG,SAASD,kBAAAA,GAAqB;AAClE;IACF;AAEAJ,UAAMM,eAAc;AACpB,SAAKf,UAAUgB,cAAa;EAC9B;AAEAC,WAASC,iBAAiB,aAAaV,eAAAA;AAEvC,SAAO,MAAA;AACLS,aAASE,oBAAoB,aAAaX,eAAAA;EAC5C;AACF;",
6
- "names": ["getCurrentWindow", "Effect", "Capability", "Common", "Capability", "makeModule", "fnUntraced", "appWindow", "getCurrentWindow", "cleanupDragRegions", "setupWindowDrag", "contributes", "Common", "Null", "INTERACTIVE_SELECTORS", "handleMouseDown", "event", "target", "dragElement", "closest", "interactiveElement", "contains", "preventDefault", "startDragging", "document", "addEventListener", "removeEventListener"]
7
- }
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const Ollama: Capability.LazyCapability<[], import("./ollama").OllamaCapabilities, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/ollama/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,MAAM,6EAAsD,CAAC"}
@@ -1,6 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability, Common } from '@dxos/app-framework';
3
- export type OllamaCapabilities = Capability.Capability<typeof Common.Capability.AiModelResolver>;
4
- declare const _default: (props?: [] | undefined) => Effect.Effect<OllamaCapabilities, Error, Capability.Service>;
5
- export default _default;
6
- //# sourceMappingURL=ollama.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/ollama/ollama.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMzD,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;;AAEjG,wBAeE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const Updater: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<null>> | undefined, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/updater/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,OAAO,0GAAwD,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<null>> | undefined, Error, Capability.Service>;
4
- export default _default;
5
- //# sourceMappingURL=updater.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/updater/updater.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,OAAO,EAAE,UAAU,EAAU,MAAM,qBAAqB,CAAC;;AAOzD,wBA4DE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const Window: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<null>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/window/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,MAAM,8FAAsD,CAAC"}
@@ -1,11 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability } from '@dxos/app-framework';
3
- /**
4
- * Window capability module.
5
- * Sets up window drag regions for Tauri windows.
6
- * Note: Window state persistence (size/position) is handled on the Rust side
7
- * in src-tauri/src/window_state.rs for instant restoration on startup.
8
- */
9
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<null>>, never, never>;
10
- export default _default;
11
- //# sourceMappingURL=window.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/window/window.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAU,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;;AACH,wBAeE"}
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const Ollama = Capability.lazy('Ollama', () => import('./ollama'));
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const Updater = Capability.lazy('Updater', () => import('./updater'));
@@ -1,82 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type } from '@tauri-apps/plugin-os';
6
- import { relaunch } from '@tauri-apps/plugin-process';
7
- import { type DownloadEvent, check } from '@tauri-apps/plugin-updater';
8
- import * as Duration from 'effect/Duration';
9
- import * as Effect from 'effect/Effect';
10
- import * as Fiber from 'effect/Fiber';
11
- import * as Function from 'effect/Function';
12
- import * as Match from 'effect/Match';
13
- import * as Schedule from 'effect/Schedule';
14
-
15
- import { Capability, Common } from '@dxos/app-framework';
16
- import { log } from '@dxos/log';
17
-
18
- import { meta } from '../../meta';
19
-
20
- const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
21
-
22
- export default Capability.makeModule(
23
- Effect.fnUntraced(function* () {
24
- // Skip updates if not supported or in dev mode.
25
- const platform = type();
26
- if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === 'localhost') {
27
- return;
28
- }
29
-
30
- const { invoke } = yield* Capability.get(Common.Capability.OperationInvoker);
31
-
32
- // https://tauri.app/plugin/updater/#checking-for-updates
33
- const action = Effect.gen(function* () {
34
- log.info('checking for updates');
35
- const update = yield* Effect.tryPromise(() => check());
36
- log.info('checked for updates', { version: update?.version, currentVersion: update?.currentVersion });
37
- if (update) {
38
- log.info('update available', update);
39
- let downloaded = 0;
40
- let contentLength = 0;
41
-
42
- const handleDownload = Match.type<DownloadEvent>().pipe(
43
- Match.when({ event: 'Started' }, (event) => {
44
- contentLength = event.data.contentLength ?? 0;
45
- log.info('download started', { contentLength });
46
- }),
47
- Match.when({ event: 'Progress' }, (event) => {
48
- downloaded += event.data.chunkLength;
49
- log.verbose('download progress', { downloaded, contentLength });
50
- }),
51
- Match.when({ event: 'Finished' }, () => {
52
- log.info('download completed');
53
- }),
54
- Match.exhaustive,
55
- );
56
-
57
- yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));
58
-
59
- yield* invoke(Common.LayoutOperation.AddToast, {
60
- id: `${meta.id}/update-ready`,
61
- title: ['update ready label', { ns: meta.id }],
62
- description: ['update ready description', { ns: meta.id }],
63
- duration: Infinity,
64
- actionLabel: ['update label', { ns: meta.id }],
65
- actionAlt: ['update alt', { ns: meta.id }],
66
- onAction: () => relaunch(),
67
- });
68
- }
69
- });
70
-
71
- const fiber: Fiber.RuntimeFiber<number, unknown> = Function.pipe(
72
- // prettier-ignore
73
- action,
74
- Effect.repeat(Schedule.fixed(Duration.hours(1))),
75
- Effect.runFork,
76
- );
77
-
78
- return Capability.contributes(Common.Capability.Null, null, () =>
79
- Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
80
- );
81
- }),
82
- );
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const Window = Capability.lazy('Window', () => import('./window'));
@@ -1,72 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { getCurrentWindow } from '@tauri-apps/api/window';
6
- import * as Effect from 'effect/Effect';
7
-
8
- import { Capability, Common } from '@dxos/app-framework';
9
-
10
- /**
11
- * Window capability module.
12
- * Sets up window drag regions for Tauri windows.
13
- * Note: Window state persistence (size/position) is handled on the Rust side
14
- * in src-tauri/src/window_state.rs for instant restoration on startup.
15
- */
16
- export default Capability.makeModule(
17
- Effect.fnUntraced(function* () {
18
- const appWindow = getCurrentWindow();
19
-
20
- // Set up drag regions for window dragging.
21
- const cleanupDragRegions = setupWindowDrag(appWindow);
22
-
23
- return Capability.contributes(
24
- Common.Capability.Null,
25
- null,
26
- Effect.fnUntraced(function* () {
27
- cleanupDragRegions();
28
- }),
29
- );
30
- }),
31
- );
32
-
33
- /**
34
- * Interactive element selectors that should not trigger window dragging.
35
- */
36
- const INTERACTIVE_SELECTORS = '.app-no-drag, button, a, input, select, textarea, [role="button"], [role="menuitem"]';
37
-
38
- /**
39
- * Sets up window drag regions.
40
- *
41
- * Tauri 2.0 does not support the `-webkit-app-region` CSS property with overlay titlebars.
42
- * This uses the Tauri window API to enable dragging on elements with the `app-drag` class.
43
- */
44
- const setupWindowDrag = (appWindow: ReturnType<typeof getCurrentWindow>): (() => void) => {
45
- const handleMouseDown = (event: MouseEvent) => {
46
- const target = event.target as Element | null;
47
- if (!target) {
48
- return;
49
- }
50
-
51
- // Check if the click target or any ancestor has the app-drag class.
52
- const dragElement = target.closest('.app-drag');
53
- if (!dragElement) {
54
- return;
55
- }
56
-
57
- // Don't trigger drag on interactive elements within the drag region.
58
- const interactiveElement = target.closest(INTERACTIVE_SELECTORS);
59
- if (interactiveElement && dragElement.contains(interactiveElement)) {
60
- return;
61
- }
62
-
63
- event.preventDefault();
64
- void appWindow.startDragging();
65
- };
66
-
67
- document.addEventListener('mousedown', handleMouseDown);
68
-
69
- return () => {
70
- document.removeEventListener('mousedown', handleMouseDown);
71
- };
72
- };