@dxos/plugin-native 0.8.4-main.67995b8 → 0.8.4-main.6fa680abb7

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 (50) hide show
  1. package/dist/lib/browser/chunk-C7OU2UF6.mjs +15 -0
  2. package/dist/lib/browser/chunk-C7OU2UF6.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +34 -20
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/ollama-QOB3EVAJ.mjs +75 -0
  7. package/dist/lib/browser/ollama-QOB3EVAJ.mjs.map +7 -0
  8. package/dist/lib/browser/updater-XFTSQ4BS.mjs +190 -0
  9. package/dist/lib/browser/updater-XFTSQ4BS.mjs.map +7 -0
  10. package/dist/lib/browser/window-GKYYTCEI.mjs +38 -0
  11. package/dist/lib/browser/window-GKYYTCEI.mjs.map +7 -0
  12. package/dist/types/src/NativePlugin.d.ts +2 -1
  13. package/dist/types/src/NativePlugin.d.ts.map +1 -1
  14. package/dist/types/src/capabilities/index.d.ts +3 -1
  15. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/ollama/index.d.ts +3 -0
  17. package/dist/types/src/capabilities/ollama/index.d.ts.map +1 -0
  18. package/dist/types/src/capabilities/ollama/ollama.d.ts +7 -0
  19. package/dist/types/src/capabilities/ollama/ollama.d.ts.map +1 -0
  20. package/dist/types/src/capabilities/updater/index.d.ts +3 -0
  21. package/dist/types/src/capabilities/updater/index.d.ts.map +1 -0
  22. package/dist/types/src/capabilities/updater/updater.d.ts +5 -0
  23. package/dist/types/src/capabilities/updater/updater.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/window/index.d.ts +3 -0
  25. package/dist/types/src/capabilities/window/index.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/window/window.d.ts +11 -0
  27. package/dist/types/src/capabilities/window/window.d.ts.map +1 -0
  28. package/dist/types/src/index.d.ts +1 -0
  29. package/dist/types/src/index.d.ts.map +1 -1
  30. package/dist/types/src/meta.d.ts +2 -3
  31. package/dist/types/src/meta.d.ts.map +1 -1
  32. package/dist/types/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +25 -14
  34. package/src/NativePlugin.tsx +23 -15
  35. package/src/capabilities/index.ts +3 -3
  36. package/src/capabilities/ollama/index.ts +7 -0
  37. package/src/capabilities/ollama/ollama.ts +88 -0
  38. package/src/capabilities/updater/index.ts +7 -0
  39. package/src/capabilities/updater/updater.ts +120 -0
  40. package/src/capabilities/window/index.ts +7 -0
  41. package/src/capabilities/window/window.ts +72 -0
  42. package/src/index.ts +1 -0
  43. package/src/meta.ts +8 -5
  44. package/dist/lib/browser/chunk-E2JDGVJI.mjs +0 -12
  45. package/dist/lib/browser/chunk-E2JDGVJI.mjs.map +0 -7
  46. package/dist/lib/browser/updater-KSM3TUHI.mjs +0 -133
  47. package/dist/lib/browser/updater-KSM3TUHI.mjs.map +0 -7
  48. package/dist/types/src/capabilities/updater.d.ts +0 -4
  49. package/dist/types/src/capabilities/updater.d.ts.map +0 -1
  50. package/src/capabilities/updater.ts +0 -79
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@dxos/plugin-native",
3
- "version": "0.8.4-main.67995b8",
3
+ "version": "0.8.4-main.6fa680abb7",
4
4
  "description": "Composer plugin that runs when on a native device.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
17
+ "source": "./src/index.ts",
13
18
  "types": "./dist/types/src/index.d.ts",
14
- "browser": "./dist/lib/browser/index.mjs",
15
- "source": "./src/index.ts"
19
+ "browser": "./dist/lib/browser/index.mjs"
16
20
  }
17
21
  },
18
22
  "types": "dist/types/src/index.d.ts",
@@ -24,23 +28,30 @@
24
28
  "src"
25
29
  ],
26
30
  "dependencies": {
27
- "@tauri-apps/plugin-os": "^2.3.0",
31
+ "@effect/platform": "0.94.4",
32
+ "@tauri-apps/api": "^2.8.0",
33
+ "@tauri-apps/plugin-os": "^2.3.1",
28
34
  "@tauri-apps/plugin-process": "^2.3.0",
35
+ "@tauri-apps/plugin-shell": "^2.3.1",
29
36
  "@tauri-apps/plugin-updater": "^2.9.0",
30
- "effect": "3.17.0",
31
- "@dxos/app-framework": "0.8.4-main.67995b8",
32
- "@dxos/log": "0.8.4-main.67995b8",
33
- "@dxos/plugin-help": "0.8.4-main.67995b8",
34
- "@dxos/plugin-navtree": "0.8.4-main.67995b8",
35
- "@dxos/util": "0.8.4-main.67995b8"
37
+ "effect": "3.19.16",
38
+ "@dxos/ai": "0.8.4-main.6fa680abb7",
39
+ "@dxos/app-framework": "0.8.4-main.6fa680abb7",
40
+ "@dxos/log": "0.8.4-main.6fa680abb7",
41
+ "@dxos/app-toolkit": "0.8.4-main.6fa680abb7",
42
+ "@dxos/operation": "0.8.4-main.6fa680abb7",
43
+ "@dxos/plugin-assistant": "0.8.4-main.6fa680abb7",
44
+ "@dxos/plugin-navtree": "0.8.4-main.6fa680abb7",
45
+ "@dxos/plugin-help": "0.8.4-main.6fa680abb7",
46
+ "@dxos/util": "0.8.4-main.6fa680abb7"
36
47
  },
37
48
  "devDependencies": {
38
- "vite": "5.4.7",
39
- "@dxos/react-ui": "0.8.4-main.67995b8"
49
+ "vite": "^7.1.11",
50
+ "@dxos/react-ui": "0.8.4-main.6fa680abb7"
40
51
  },
41
52
  "peerDependencies": {
42
- "effect": "^3.13.3",
43
- "@dxos/react-ui": "0.8.4-main.67995b8"
53
+ "effect": "3.19.16",
54
+ "@dxos/react-ui": "0.8.4-main.6fa680abb7"
44
55
  },
45
56
  "publishConfig": {
46
57
  "access": "public"
@@ -2,22 +2,30 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { definePlugin, Events, defineModule, contributes, Capabilities } from '@dxos/app-framework';
5
+ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+ import { AssistantEvents } from '@dxos/plugin-assistant';
6
8
 
7
- import { Updater } from './capabilities';
9
+ import { Ollama, Updater, Window } from './capabilities';
8
10
  import { meta } from './meta';
9
11
  import { translations } from './translations';
10
12
 
11
- export const NativePlugin = () =>
12
- definePlugin(meta, [
13
- defineModule({
14
- id: `${meta.id}/module/translations`,
15
- activatesOn: Events.SetupTranslations,
16
- activate: () => contributes(Capabilities.Translations, translations),
17
- }),
18
- defineModule({
19
- id: `${meta.id}/module/updater`,
20
- activatesOn: Events.DispatcherReady,
21
- activate: Updater,
22
- }),
23
- ]);
13
+ export const NativePlugin = Plugin.define(meta).pipe(
14
+ AppPlugin.addTranslationsModule({ translations }),
15
+ Plugin.addModule({
16
+ id: 'updater',
17
+ activatesOn: ActivationEvents.OperationInvokerReady,
18
+ activate: Updater,
19
+ }),
20
+ Plugin.addModule({
21
+ id: 'window',
22
+ activatesOn: ActivationEvents.OperationInvokerReady,
23
+ activate: Window,
24
+ }),
25
+ Plugin.addModule({
26
+ id: 'ollama',
27
+ activatesOn: AssistantEvents.SetupAiServiceProviders,
28
+ activate: Ollama,
29
+ }),
30
+ Plugin.make,
31
+ );
@@ -2,6 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
6
-
7
- export const Updater = lazy(() => import('./updater'));
5
+ export * from './ollama';
6
+ export * from './updater';
7
+ export * from './window';
@@ -0,0 +1,7 @@
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'));
@@ -0,0 +1,88 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
6
+ import * as HttpClient from '@effect/platform/HttpClient';
7
+ import { Command } from '@tauri-apps/plugin-shell';
8
+ import * as Context from 'effect/Context';
9
+ import * as Effect from 'effect/Effect';
10
+ import * as Layer from 'effect/Layer';
11
+ import * as ManagedRuntime from 'effect/ManagedRuntime';
12
+
13
+ import { type AiModelResolver } from '@dxos/ai';
14
+ import { OllamaResolver } from '@dxos/ai/resolvers';
15
+ import { Capability } from '@dxos/app-framework';
16
+ import { AppCapabilities } from '@dxos/app-toolkit';
17
+ import { log } from '@dxos/log';
18
+
19
+ // NOTE: Running ollama on non-standard port (config Tauri).
20
+ const OLLAMA_HOST = 'http://localhost:21434';
21
+
22
+ export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
23
+
24
+ export default Capability.makeModule<[], OllamaCapabilities>(() =>
25
+ Effect.sync(() => {
26
+ const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
27
+
28
+ // Layer for the sidecar but the lifecycle is managed by the runtime.
29
+ const sidecarLayer = Layer.effectContext(
30
+ runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),
31
+ );
32
+
33
+ return Capability.contributes(
34
+ AppCapabilities.AiModelResolver,
35
+ OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),
36
+ () => Effect.tryPromise(() => runtime.dispose()),
37
+ );
38
+ }),
39
+ );
40
+
41
+ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
42
+ OllamaSidecar,
43
+ {
44
+ endpoint: string;
45
+ }
46
+ >() {
47
+ static layerLive = Layer.scoped(
48
+ OllamaSidecar,
49
+ Effect.gen(function* () {
50
+ const command = Command.sidecar('sidecar/ollama', ['serve'], {
51
+ env: {
52
+ OLLAMA_HOST,
53
+ OLLAMA_ORIGINS: '*', // CORS
54
+ },
55
+ });
56
+
57
+ // NOTE: Keeping those as console.log for consistent formatting.
58
+ // eslint-disable-next-line no-console
59
+ command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
60
+ // eslint-disable-next-line no-console
61
+ command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
62
+ command.on('close', (code) => log.info('Ollama process exited', { code }));
63
+ command.on('error', (error) => log.error('Ollama error', { error }));
64
+ const child = yield* Effect.promise(() => command.spawn());
65
+ yield* Effect.addFinalizer(
66
+ Effect.fn(function* () {
67
+ yield* Effect.promise(() => child.kill());
68
+ }),
69
+ );
70
+ log.info('Running ollama', { pid: child.pid });
71
+
72
+ return {
73
+ endpoint: OLLAMA_HOST,
74
+ };
75
+ }),
76
+ );
77
+ }
78
+
79
+ const OllamaSidecarModelResolver: Layer.Layer<AiModelResolver.AiModelResolver, never, OllamaSidecar> =
80
+ Layer.unwrapEffect(
81
+ Effect.gen(function* () {
82
+ const { endpoint } = yield* OllamaSidecar;
83
+ return OllamaResolver.make({
84
+ endpoint,
85
+ transformClient: HttpClient.withTracerPropagation(false),
86
+ });
87
+ }),
88
+ ).pipe(Layer.provide(FetchHttpClient.layer));
@@ -0,0 +1,7 @@
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'));
@@ -0,0 +1,120 @@
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 * as Updater 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 Match from 'effect/Match';
12
+ import * as Schedule from 'effect/Schedule';
13
+
14
+ import { Capabilities, Capability } from '@dxos/app-framework';
15
+ import { LayoutOperation } from '@dxos/app-toolkit';
16
+ import { log } from '@dxos/log';
17
+
18
+ import { meta } from '../../meta';
19
+
20
+ const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
21
+
22
+ /**
23
+ * Safely check for updates with error logging.
24
+ */
25
+ const check = async (): Promise<Updater.Update | null> => {
26
+ try {
27
+ return await Updater.check();
28
+ } catch (error) {
29
+ log.error('failed to check for updates', { error });
30
+ return null;
31
+ }
32
+ };
33
+
34
+ /**
35
+ * Safely download and install update with error logging.
36
+ */
37
+ const downloadAndInstall = async (
38
+ update: Updater.Update,
39
+ handleDownload: (event: Updater.DownloadEvent) => void,
40
+ ): Promise<boolean> => {
41
+ try {
42
+ await update.downloadAndInstall(handleDownload);
43
+ return true;
44
+ } catch (error) {
45
+ log.error('failed to download and install update', { error });
46
+ return false;
47
+ }
48
+ };
49
+
50
+ export default Capability.makeModule(
51
+ Effect.fnUntraced(function* () {
52
+ // Skip updates if not supported or in dev mode.
53
+ const platform = type();
54
+ if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === 'localhost') {
55
+ log.info('skipping updater', { platform, hostname: window.location.hostname });
56
+ return;
57
+ }
58
+
59
+ const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
60
+
61
+ // https://tauri.app/plugin/updater/#checking-for-updates
62
+ const action = Effect.gen(function* () {
63
+ log.info('checking for updates');
64
+ const update = yield* Effect.promise(() => check());
65
+ if (!update) {
66
+ log.info('no update available');
67
+ return;
68
+ }
69
+ log.info('update check complete', {
70
+ available: update.available,
71
+ currentVersion: update.currentVersion,
72
+ version: update.version,
73
+ date: update.date,
74
+ body: update.body,
75
+ });
76
+ if (update.available) {
77
+ log.info('update available, starting download', { version: update.version });
78
+ let downloaded = 0;
79
+ let contentLength = 0;
80
+
81
+ const handleDownload = Match.type<Updater.DownloadEvent>().pipe(
82
+ Match.when({ event: 'Started' }, (event) => {
83
+ contentLength = event.data.contentLength ?? 0;
84
+ log.info('download started', { contentLength });
85
+ }),
86
+ Match.when({ event: 'Progress' }, (event) => {
87
+ downloaded += event.data.chunkLength;
88
+ log.verbose('download progress', { downloaded, contentLength });
89
+ }),
90
+ Match.when({ event: 'Finished' }, () => {
91
+ log.info('download completed');
92
+ }),
93
+ Match.exhaustive,
94
+ );
95
+
96
+ const downloadSuccess = yield* Effect.promise(() => downloadAndInstall(update, handleDownload));
97
+
98
+ if (downloadSuccess) {
99
+ yield* invoke(LayoutOperation.AddToast, {
100
+ id: `${meta.id}.update-ready`,
101
+ title: ['update ready label', { ns: meta.id }],
102
+ description: ['update ready description', { ns: meta.id }],
103
+ duration: Infinity,
104
+ actionLabel: ['update label', { ns: meta.id }],
105
+ actionAlt: ['update alt', { ns: meta.id }],
106
+ onAction: () => relaunch(),
107
+ });
108
+ }
109
+ }
110
+ });
111
+
112
+ // Run immediately on startup, then repeat every hour.
113
+ const fiber = yield* action.pipe(Effect.repeat(Schedule.fixed(Duration.hours(1))), Effect.forkDaemon);
114
+ log.info('updater module initialized, update check scheduled');
115
+
116
+ return Capability.contributes(Capabilities.Null, null, () =>
117
+ Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
118
+ );
119
+ }),
120
+ );
@@ -0,0 +1,7 @@
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'));
@@ -0,0 +1,72 @@
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 { Capabilities, Capability } 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
+ Capabilities.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 = '.dx-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 `dx-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 dx-app-drag class.
52
+ const dragElement = target.closest('.dx-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
+ };
package/src/index.ts CHANGED
@@ -2,5 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './capabilities';
5
6
  export * from './meta';
6
7
  export * from './NativePlugin';
package/src/meta.ts CHANGED
@@ -2,11 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const NATIVE_PLUGIN = 'dxos.org/plugin/native';
8
-
9
- export const meta: PluginMeta = {
10
- id: NATIVE_PLUGIN,
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.native',
11
10
  name: 'Native',
11
+ description: trim`
12
+ Native platform integration providing desktop-specific features and system-level capabilities.
13
+ Access native file dialogs, notifications, and OS integrations.
14
+ `,
12
15
  };
@@ -1,12 +0,0 @@
1
- // src/meta.ts
2
- var NATIVE_PLUGIN = "dxos.org/plugin/native";
3
- var meta = {
4
- id: NATIVE_PLUGIN,
5
- name: "Native"
6
- };
7
-
8
- export {
9
- NATIVE_PLUGIN,
10
- meta
11
- };
12
- //# sourceMappingURL=chunk-E2JDGVJI.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const NATIVE_PLUGIN = 'dxos.org/plugin/native';\n\nexport const meta: PluginMeta = {\n id: NATIVE_PLUGIN,\n name: 'Native',\n};\n"],
5
- "mappings": ";AAMO,IAAMA,gBAAgB;AAEtB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;",
6
- "names": ["NATIVE_PLUGIN", "meta", "id", "name"]
7
- }
@@ -1,133 +0,0 @@
1
- import {
2
- NATIVE_PLUGIN
3
- } from "./chunk-E2JDGVJI.mjs";
4
-
5
- // src/capabilities/updater.ts
6
- import { type } from "@tauri-apps/plugin-os";
7
- import { relaunch } from "@tauri-apps/plugin-process";
8
- import { check } from "@tauri-apps/plugin-updater";
9
- import { Duration, Effect, Fiber, Match, pipe, Schedule } from "effect";
10
- import { Capabilities, contributes, createIntent, LayoutAction } from "@dxos/app-framework";
11
- import { log } from "@dxos/log";
12
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-native/src/capabilities/updater.ts";
13
- var SUPPORTS_OTA = [
14
- "linux",
15
- "macos",
16
- "windows"
17
- ];
18
- var updater_default = (context) => {
19
- const platform = type();
20
- if (!SUPPORTS_OTA.includes(platform)) {
21
- return contributes(Capabilities.Null, null);
22
- }
23
- const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
24
- const action = Effect.gen(function* () {
25
- log.info("checking for updates", void 0, {
26
- F: __dxlog_file,
27
- L: 27,
28
- S: this,
29
- C: (f, a) => f(...a)
30
- });
31
- const update = yield* Effect.tryPromise(() => check());
32
- log.info("checked for updates", {
33
- version: update?.version,
34
- currentVersion: update?.currentVersion
35
- }, {
36
- F: __dxlog_file,
37
- L: 29,
38
- S: this,
39
- C: (f, a) => f(...a)
40
- });
41
- if (update) {
42
- log.info("update available", update, {
43
- F: __dxlog_file,
44
- L: 31,
45
- S: this,
46
- C: (f, a) => f(...a)
47
- });
48
- let downloaded = 0;
49
- let contentLength = 0;
50
- const handleDownload = Match.type().pipe(Match.when({
51
- event: "Started"
52
- }, (event) => {
53
- contentLength = event.data.contentLength ?? 0;
54
- log.info("download started", {
55
- contentLength
56
- }, {
57
- F: __dxlog_file,
58
- L: 38,
59
- S: this,
60
- C: (f, a) => f(...a)
61
- });
62
- }), Match.when({
63
- event: "Progress"
64
- }, (event) => {
65
- downloaded += event.data.chunkLength;
66
- log.info("download progress", {
67
- downloaded,
68
- contentLength
69
- }, {
70
- F: __dxlog_file,
71
- L: 42,
72
- S: this,
73
- C: (f, a) => f(...a)
74
- });
75
- }), Match.when({
76
- event: "Finished"
77
- }, () => {
78
- log.info("download completed", void 0, {
79
- F: __dxlog_file,
80
- L: 45,
81
- S: this,
82
- C: (f, a) => f(...a)
83
- });
84
- }), Match.exhaustive);
85
- yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));
86
- yield* dispatch(createIntent(LayoutAction.AddToast, {
87
- part: "toast",
88
- subject: {
89
- id: `${NATIVE_PLUGIN}/update-ready`,
90
- title: [
91
- "update ready label",
92
- {
93
- ns: NATIVE_PLUGIN
94
- }
95
- ],
96
- description: [
97
- "update ready description",
98
- {
99
- ns: NATIVE_PLUGIN
100
- }
101
- ],
102
- duration: Infinity,
103
- actionLabel: [
104
- "update label",
105
- {
106
- ns: NATIVE_PLUGIN
107
- }
108
- ],
109
- actionAlt: [
110
- "update alt",
111
- {
112
- ns: NATIVE_PLUGIN
113
- }
114
- ],
115
- onAction: () => relaunch()
116
- }
117
- }));
118
- }
119
- });
120
- const fiber = pipe(
121
- // prettier-ignore
122
- action,
123
- Effect.repeat(Schedule.fixed(Duration.hours(1))),
124
- Effect.runFork
125
- );
126
- return contributes(Capabilities.Null, null, () => {
127
- Effect.runSync(Fiber.interrupt(fiber));
128
- });
129
- };
130
- export {
131
- updater_default as default
132
- };
133
- //# sourceMappingURL=updater-KSM3TUHI.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/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 { check, type DownloadEvent } from '@tauri-apps/plugin-updater';\nimport { Duration, Effect, Fiber, Match, pipe, Schedule } from 'effect';\n\nimport { Capabilities, contributes, createIntent, LayoutAction, type PluginContext } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\nimport { NATIVE_PLUGIN } from '../meta';\n\nconst SUPPORTS_OTA = ['linux', 'macos', 'windows'];\n\nexport default (context: PluginContext) => {\n const platform = type();\n if (!SUPPORTS_OTA.includes(platform)) {\n return contributes(Capabilities.Null, null);\n }\n\n const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);\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.info('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* dispatch(\n createIntent(LayoutAction.AddToast, {\n part: 'toast',\n subject: {\n id: `${NATIVE_PLUGIN}/update-ready`,\n title: ['update ready label', { ns: NATIVE_PLUGIN }],\n description: ['update ready description', { ns: NATIVE_PLUGIN }],\n duration: Infinity,\n actionLabel: ['update label', { ns: NATIVE_PLUGIN }],\n actionAlt: ['update alt', { ns: NATIVE_PLUGIN }],\n onAction: () => relaunch(),\n },\n }),\n );\n }\n });\n\n const fiber = pipe(\n // prettier-ignore\n action,\n Effect.repeat(Schedule.fixed(Duration.hours(1))),\n Effect.runFork,\n );\n\n return contributes(Capabilities.Null, null, () => {\n Effect.runSync(Fiber.interrupt(fiber));\n });\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,YAAY;AACrB,SAASC,gBAAgB;AACzB,SAASC,aAAiC;AAC1C,SAASC,UAAUC,QAAQC,OAAOC,OAAOC,MAAMC,gBAAgB;AAE/D,SAASC,cAAcC,aAAaC,cAAcC,oBAAwC;AAC1F,SAASC,WAAW;;AAIpB,IAAMC,eAAe;EAAC;EAAS;EAAS;;AAExC,IAAA,kBAAe,CAACC,YAAAA;AACd,QAAMC,WAAWC,KAAAA;AACjB,MAAI,CAACH,aAAaI,SAASF,QAAAA,GAAW;AACpC,WAAOG,YAAYC,aAAaC,MAAM,IAAA;EACxC;AAEA,QAAM,EAAEC,SAAQ,IAAKP,QAAQQ,cAAcH,aAAaI,gBAAgB;AAGxE,QAAMC,SAASC,OAAOC,IAAI,aAAA;AACxBC,QAAIC,KAAK,wBAAA,QAAA;;;;;;AACT,UAAMC,SAAS,OAAOJ,OAAOK,WAAW,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,iBAAiBC,MAAMrB,KAAI,EAAkBsB,KACjDD,MAAME,KAAK;QAAEC,OAAO;MAAU,GAAG,CAACA,UAAAA;AAChCL,wBAAgBK,MAAMC,KAAKN,iBAAiB;AAC5CR,YAAIC,KAAK,oBAAoB;UAAEO;QAAc,GAAA;;;;;;MAC/C,CAAA,GACAE,MAAME,KAAK;QAAEC,OAAO;MAAW,GAAG,CAACA,UAAAA;AACjCN,sBAAcM,MAAMC,KAAKC;AACzBf,YAAIC,KAAK,qBAAqB;UAAEM;UAAYC;QAAc,GAAA;;;;;;MAC5D,CAAA,GACAE,MAAME,KAAK;QAAEC,OAAO;MAAW,GAAG,MAAA;AAChCb,YAAIC,KAAK,sBAAA,QAAA;;;;;;MACX,CAAA,GACAS,MAAMM,UAAU;AAGlB,aAAOlB,OAAOK,WAAW,MAAMD,OAAOe,mBAAmBR,cAAAA,CAAAA;AAEzD,aAAOf,SACLwB,aAAaC,aAAaC,UAAU;QAClCC,MAAM;QACNC,SAAS;UACPC,IAAI,GAAGC,aAAAA;UACPC,OAAO;YAAC;YAAsB;cAAEC,IAAIF;YAAc;;UAClDG,aAAa;YAAC;YAA4B;cAAED,IAAIF;YAAc;;UAC9DI,UAAUC;UACVC,aAAa;YAAC;YAAgB;cAAEJ,IAAIF;YAAc;;UAClDO,WAAW;YAAC;YAAc;cAAEL,IAAIF;YAAc;;UAC9CQ,UAAU,MAAMC,SAAAA;QAClB;MACF,CAAA,CAAA;IAEJ;EACF,CAAA;AAEA,QAAMC,QAAQvB;;IAEZd;IACAC,OAAOqC,OAAOC,SAASC,MAAMC,SAASC,MAAM,CAAA,CAAA,CAAA;IAC5CzC,OAAO0C;EAAO;AAGhB,SAAOjD,YAAYC,aAAaC,MAAM,MAAM,MAAA;AAC1CK,WAAO2C,QAAQC,MAAMC,UAAUT,KAAAA,CAAAA;EACjC,CAAA;AACF;",
6
- "names": ["type", "relaunch", "check", "Duration", "Effect", "Fiber", "Match", "pipe", "Schedule", "Capabilities", "contributes", "createIntent", "LayoutAction", "log", "SUPPORTS_OTA", "context", "platform", "type", "includes", "contributes", "Capabilities", "Null", "dispatch", "getCapability", "IntentDispatcher", "action", "Effect", "gen", "log", "info", "update", "tryPromise", "check", "version", "currentVersion", "downloaded", "contentLength", "handleDownload", "Match", "pipe", "when", "event", "data", "chunkLength", "exhaustive", "downloadAndInstall", "createIntent", "LayoutAction", "AddToast", "part", "subject", "id", "NATIVE_PLUGIN", "title", "ns", "description", "duration", "Infinity", "actionLabel", "actionAlt", "onAction", "relaunch", "fiber", "repeat", "Schedule", "fixed", "Duration", "hours", "runFork", "runSync", "Fiber", "interrupt"]
7
- }
@@ -1,4 +0,0 @@
1
- import { type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<null>;
3
- export default _default;
4
- //# sourceMappingURL=updater.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/updater.ts"],"names":[],"mappings":"AASA,OAAO,EAAyD,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;yBAOhG,SAAS,aAAa;AAAtC,wBA8DE"}