@dxos/plugin-native 0.8.4-main.3c1ae3b → 0.8.4-main.52d7546f51
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/lib/browser/{chunk-SP3MEGKI.mjs → chunk-6374DBU4.mjs} +1 -1
- package/dist/lib/browser/chunk-6374DBU4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +33 -30
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{ollama-CQE7ZIWL.mjs → ollama-QOB3EVAJ.mjs} +14 -15
- package/dist/lib/browser/ollama-QOB3EVAJ.mjs.map +7 -0
- package/dist/lib/browser/updater-AR27PYM4.mjs +190 -0
- package/dist/lib/browser/updater-AR27PYM4.mjs.map +7 -0
- package/dist/lib/browser/window-WKAABR3P.mjs +38 -0
- package/dist/lib/browser/window-WKAABR3P.mjs.map +7 -0
- package/dist/types/src/NativePlugin.d.ts +2 -1
- package/dist/types/src/NativePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ollama/index.d.ts +3 -0
- package/dist/types/src/capabilities/ollama/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ollama/ollama.d.ts +7 -0
- package/dist/types/src/capabilities/ollama/ollama.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater/index.d.ts +3 -0
- package/dist/types/src/capabilities/updater/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater/updater.d.ts +5 -0
- package/dist/types/src/capabilities/updater/updater.d.ts.map +1 -0
- package/dist/types/src/capabilities/window/index.d.ts +3 -0
- package/dist/types/src/capabilities/window/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/window/window.d.ts +11 -0
- package/dist/types/src/capabilities/window/window.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -13
- package/src/NativePlugin.tsx +14 -16
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/ollama/index.ts +7 -0
- package/src/capabilities/{ollama.ts → ollama/ollama.ts} +26 -20
- package/src/capabilities/updater/index.ts +7 -0
- package/src/capabilities/updater/updater.ts +120 -0
- package/src/capabilities/window/index.ts +7 -0
- package/src/capabilities/window/window.ts +72 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +2 -2
- package/dist/lib/browser/chunk-SP3MEGKI.mjs.map +0 -7
- package/dist/lib/browser/ollama-CQE7ZIWL.mjs.map +0 -7
- package/dist/lib/browser/updater-SDBPTCXA.mjs +0 -138
- package/dist/lib/browser/updater-SDBPTCXA.mjs.map +0 -7
- package/dist/lib/browser/window-6G542FZL.mjs +0 -34
- package/dist/lib/browser/window-6G542FZL.mjs.map +0 -7
- package/dist/types/src/capabilities/ollama.d.ts +0 -4
- package/dist/types/src/capabilities/ollama.d.ts.map +0 -1
- package/dist/types/src/capabilities/updater.d.ts +0 -4
- package/dist/types/src/capabilities/updater.d.ts.map +0 -1
- package/dist/types/src/capabilities/window.d.ts +0 -4
- package/dist/types/src/capabilities/window.d.ts.map +0 -1
- package/src/capabilities/updater.ts +0 -85
- package/src/capabilities/window.ts +0 -49
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-native",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.52d7546f51",
|
|
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,
|
|
@@ -24,28 +28,30 @@
|
|
|
24
28
|
"src"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@effect/platform": "
|
|
31
|
+
"@effect/platform": "0.94.4",
|
|
28
32
|
"@tauri-apps/api": "^2.8.0",
|
|
29
33
|
"@tauri-apps/plugin-os": "^2.3.1",
|
|
30
34
|
"@tauri-apps/plugin-process": "^2.3.0",
|
|
31
35
|
"@tauri-apps/plugin-shell": "^2.3.1",
|
|
32
36
|
"@tauri-apps/plugin-updater": "^2.9.0",
|
|
33
|
-
"effect": "3.
|
|
34
|
-
"@dxos/ai": "0.8.4-main.
|
|
35
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/plugin-
|
|
40
|
-
"@dxos/
|
|
37
|
+
"effect": "3.19.16",
|
|
38
|
+
"@dxos/ai": "0.8.4-main.52d7546f51",
|
|
39
|
+
"@dxos/app-framework": "0.8.4-main.52d7546f51",
|
|
40
|
+
"@dxos/app-toolkit": "0.8.4-main.52d7546f51",
|
|
41
|
+
"@dxos/log": "0.8.4-main.52d7546f51",
|
|
42
|
+
"@dxos/operation": "0.8.4-main.52d7546f51",
|
|
43
|
+
"@dxos/plugin-assistant": "0.8.4-main.52d7546f51",
|
|
44
|
+
"@dxos/plugin-help": "0.8.4-main.52d7546f51",
|
|
45
|
+
"@dxos/util": "0.8.4-main.52d7546f51",
|
|
46
|
+
"@dxos/plugin-navtree": "0.8.4-main.52d7546f51"
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
49
|
"vite": "7.1.9",
|
|
44
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
50
|
+
"@dxos/react-ui": "0.8.4-main.52d7546f51"
|
|
45
51
|
},
|
|
46
52
|
"peerDependencies": {
|
|
47
|
-
"effect": "
|
|
48
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
53
|
+
"effect": "3.19.16",
|
|
54
|
+
"@dxos/react-ui": "0.8.4-main.52d7546f51"
|
|
49
55
|
},
|
|
50
56
|
"publishConfig": {
|
|
51
57
|
"access": "public"
|
package/src/NativePlugin.tsx
CHANGED
|
@@ -2,32 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
6
7
|
import { AssistantEvents } from '@dxos/plugin-assistant';
|
|
7
8
|
|
|
8
9
|
import { Ollama, Updater, Window } from './capabilities';
|
|
9
10
|
import { meta } from './meta';
|
|
10
11
|
import { translations } from './translations';
|
|
11
12
|
|
|
12
|
-
export const NativePlugin =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
defineModule({
|
|
19
|
-
id: `${meta.id}/module/updater`,
|
|
20
|
-
activatesOn: Events.DispatcherReady,
|
|
13
|
+
export const NativePlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
15
|
+
Plugin.addModule({
|
|
16
|
+
id: 'updater',
|
|
17
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
21
18
|
activate: Updater,
|
|
22
19
|
}),
|
|
23
|
-
|
|
24
|
-
id:
|
|
25
|
-
activatesOn:
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
id: 'window',
|
|
22
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
26
23
|
activate: Window,
|
|
27
24
|
}),
|
|
28
|
-
|
|
29
|
-
id:
|
|
25
|
+
Plugin.addModule({
|
|
26
|
+
id: 'ollama',
|
|
30
27
|
activatesOn: AssistantEvents.SetupAiServiceProviders,
|
|
31
28
|
activate: Ollama,
|
|
32
29
|
}),
|
|
33
|
-
|
|
30
|
+
Plugin.make,
|
|
31
|
+
);
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export const Updater = lazy(() => import('./updater'));
|
|
9
|
-
export const Window = lazy(() => import('./window'));
|
|
5
|
+
export * from './ollama';
|
|
6
|
+
export * from './updater';
|
|
7
|
+
export * from './window';
|
|
@@ -10,29 +10,33 @@ import * as Effect from 'effect/Effect';
|
|
|
10
10
|
import * as Layer from 'effect/Layer';
|
|
11
11
|
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
12
12
|
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
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';
|
|
15
17
|
import { log } from '@dxos/log';
|
|
16
18
|
|
|
17
|
-
// Running ollama on non-standard port.
|
|
19
|
+
// NOTE: Running ollama on non-standard port (config Tauri).
|
|
18
20
|
const OLLAMA_HOST = 'http://localhost:21434';
|
|
19
21
|
|
|
20
|
-
export
|
|
21
|
-
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
22
|
+
export type OllamaCapabilities = Capability.Capability<typeof AppCapabilities.AiModelResolver>;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
runtime
|
|
26
|
-
);
|
|
24
|
+
export default Capability.makeModule<[], OllamaCapabilities>(() =>
|
|
25
|
+
Effect.sync(() => {
|
|
26
|
+
const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
);
|
|
36
40
|
|
|
37
41
|
class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
38
42
|
OllamaSidecar,
|
|
@@ -51,7 +55,9 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
// NOTE: Keeping those as console.log for consistent formatting.
|
|
58
|
+
// eslint-disable-next-line no-console
|
|
54
59
|
command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
55
61
|
command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));
|
|
56
62
|
command.on('close', (code) => log.info('Ollama process exited', { code }));
|
|
57
63
|
command.on('error', (error) => log.error('Ollama error', { error }));
|
|
@@ -70,12 +76,12 @@ class OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<
|
|
|
70
76
|
);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
const OllamaSidecarModelResolver: Layer.Layer<
|
|
79
|
+
const OllamaSidecarModelResolver: Layer.Layer<AiModelResolver.AiModelResolver, never, OllamaSidecar> =
|
|
74
80
|
Layer.unwrapEffect(
|
|
75
81
|
Effect.gen(function* () {
|
|
76
82
|
const { endpoint } = yield* OllamaSidecar;
|
|
77
|
-
return
|
|
78
|
-
|
|
83
|
+
return OllamaResolver.make({
|
|
84
|
+
endpoint,
|
|
79
85
|
transformClient: HttpClient.withTracerPropagation(false),
|
|
80
86
|
});
|
|
81
87
|
}),
|
|
@@ -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,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 = '.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
|
+
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/native',
|
|
10
10
|
name: 'Native',
|
|
11
11
|
description: trim`
|
|
@@ -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';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/native',\n name: 'Native',\n description: trim`\n Native platform integration providing desktop-specific features and system-level capabilities.\n Access native file dialogs, notifications, and OS integrations.\n `,\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;AAIf;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/ollama.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport { Command } from '@tauri-apps/plugin-shell';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport * as AiServiceRouter from '@dxos/ai/AiServiceRouter';\nimport { Capabilities, type Capability, type PluginContext, contributes } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\n// Running ollama on non-standard port.\nconst OLLAMA_HOST = 'http://localhost:21434';\n\nexport default (_context: PluginContext): Capability<any> => {\n const runtime = ManagedRuntime.make(OllamaSidecar.layerLive);\n\n // Layer for the sidecar but the lifecycle is managed by the runtime.\n const sidecarLayer = Layer.effectContext(\n runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(OllamaSidecar)))),\n );\n\n return contributes(\n Capabilities.AiModelResolver,\n OllamaSidecarModelResolver.pipe(Layer.provide(sidecarLayer)),\n async () => {\n await runtime.dispose();\n },\n );\n};\n\nclass OllamaSidecar extends Context.Tag('@dxos/plugin-native/OllamaSidecar')<\n OllamaSidecar,\n {\n endpoint: string;\n }\n>() {\n static layerLive = Layer.scoped(\n OllamaSidecar,\n Effect.gen(function* () {\n const command = Command.sidecar('sidecar/ollama', ['serve'], {\n env: {\n OLLAMA_HOST,\n OLLAMA_ORIGINS: '*', // CORS\n },\n });\n\n // NOTE: Keeping those as console.log for consistent formatting.\n command.stdout.on('data', (data) => console.log('[ollama]', data.toString()));\n command.stderr.on('data', (data) => console.error('[ollama]', data.toString()));\n command.on('close', (code) => log.info('Ollama process exited', { code }));\n command.on('error', (error) => log.error('Ollama error', { error }));\n const child = yield* Effect.promise(() => command.spawn());\n yield* Effect.addFinalizer(\n Effect.fn(function* () {\n yield* Effect.promise(() => child.kill());\n }),\n );\n log.info('Running ollama', { pid: child.pid });\n\n return {\n endpoint: OLLAMA_HOST,\n };\n }),\n );\n}\n\nconst OllamaSidecarModelResolver: Layer.Layer<AiServiceRouter.AiModelResolver, never, OllamaSidecar> =\n Layer.unwrapEffect(\n Effect.gen(function* () {\n const { endpoint } = yield* OllamaSidecar;\n return AiServiceRouter.OllamaResolver({\n host: endpoint,\n transformClient: HttpClient.withTracerPropagation(false),\n });\n }),\n ).pipe(Layer.provide(FetchHttpClient.layer));\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,qBAAqB;AACjC,YAAYC,gBAAgB;AAC5B,SAASC,eAAe;AACxB,YAAYC,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,YAAYC,qBAAqB;AACjC,SAASC,cAAmDC,mBAAmB;AAC/E,SAASC,WAAW;;AAGpB,IAAMC,cAAc;AAEpB,IAAA,kBAAe,CAACC,aAAAA;AACd,QAAMC,UAAyBC,oBAAKC,cAAcC,SAAS;AAG3D,QAAMC,eAAqBC,oBACzBL,QAAQM,cAAcC,KAAYC,WAAI,CAACC,OAAOA,GAAGC,QAAQH,KAAaI,aAAKT,aAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAG7E,SAAON,YACLD,aAAaiB,iBACbC,2BAA2BN,KAAWO,cAAQV,YAAAA,CAAAA,GAC9C,YAAA;AACE,UAAMJ,QAAQe,QAAO;EACvB,CAAA;AAEJ;AAEA,IAAMb,gBAAN,MAAMA,uBAA8Bc,YAAI,mCAAA,EAAA,EAAA;EAMtC,OAAOb,YAAkBc,aACvBf,gBACOgB,WAAI,aAAA;AACT,UAAMC,UAAU9B,QAAQ+B,QAAQ,kBAAkB;MAAC;OAAU;MAC3DC,KAAK;QACHvB;QACAwB,gBAAgB;MAClB;IACF,CAAA;AAGAH,YAAQI,OAAOC,GAAG,QAAQ,CAACC,SAASC,QAAQ7B,IAAI,YAAY4B,KAAKE,SAAQ,CAAA,CAAA;AACzER,YAAQS,OAAOJ,GAAG,QAAQ,CAACC,SAASC,QAAQG,MAAM,YAAYJ,KAAKE,SAAQ,CAAA,CAAA;AAC3ER,YAAQK,GAAG,SAAS,CAACM,SAASjC,IAAIkC,KAAK,yBAAyB;MAAED;IAAK,GAAA;;;;;;AACvEX,YAAQK,GAAG,SAAS,CAACK,UAAUhC,IAAIgC,MAAM,gBAAgB;MAAEA;IAAM,GAAA;;;;;;AACjE,UAAMG,QAAQ,OAAcC,eAAQ,MAAMd,QAAQe,MAAK,CAAA;AACvD,WAAcC,oBACLC,UAAG,aAAA;AACR,aAAcH,eAAQ,MAAMD,MAAMK,KAAI,CAAA;IACxC,CAAA,CAAA;AAEFxC,QAAIkC,KAAK,kBAAkB;MAAEO,KAAKN,MAAMM;IAAI,GAAA;;;;;;AAE5C,WAAO;MACLC,UAAUzC;IACZ;EACF,CAAA,CAAA;AAEJ;AAEA,IAAMe,6BACE2B,mBACGtB,WAAI,aAAA;AACT,QAAM,EAAEqB,SAAQ,IAAK,OAAOrC;AAC5B,SAAuBuC,+BAAe;IACpCC,MAAMH;IACNI,iBAA4BC,iCAAsB,KAAA;EACpD,CAAA;AACF,CAAA,CAAA,EACArC,KAAWO,cAAwB+B,qBAAK,CAAA;",
|
|
6
|
-
"names": ["FetchHttpClient", "HttpClient", "Command", "Context", "Effect", "Layer", "ManagedRuntime", "AiServiceRouter", "Capabilities", "contributes", "log", "OLLAMA_HOST", "_context", "runtime", "make", "OllamaSidecar", "layerLive", "sidecarLayer", "effectContext", "runtimeEffect", "pipe", "map", "rt", "context", "pick", "AiModelResolver", "OllamaSidecarModelResolver", "provide", "dispose", "Tag", "scoped", "gen", "command", "sidecar", "env", "OLLAMA_ORIGINS", "stdout", "on", "data", "console", "toString", "stderr", "error", "code", "info", "child", "promise", "spawn", "addFinalizer", "fn", "kill", "pid", "endpoint", "unwrapEffect", "OllamaResolver", "host", "transformClient", "withTracerPropagation", "layer"]
|
|
7
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-SP3MEGKI.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 * as Duration from "effect/Duration";
|
|
10
|
-
import * as Effect from "effect/Effect";
|
|
11
|
-
import * as Fiber from "effect/Fiber";
|
|
12
|
-
import * as Function from "effect/Function";
|
|
13
|
-
import * as Match from "effect/Match";
|
|
14
|
-
import * as Schedule from "effect/Schedule";
|
|
15
|
-
import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
|
|
16
|
-
import { log } from "@dxos/log";
|
|
17
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-native/src/capabilities/updater.ts";
|
|
18
|
-
var SUPPORTS_OTA = [
|
|
19
|
-
"linux",
|
|
20
|
-
"macos",
|
|
21
|
-
"windows"
|
|
22
|
-
];
|
|
23
|
-
var updater_default = ((context) => {
|
|
24
|
-
const platform = type();
|
|
25
|
-
if (!SUPPORTS_OTA.includes(platform) || window.location.hostname === "localhost") {
|
|
26
|
-
return contributes(Capabilities.Null, null);
|
|
27
|
-
}
|
|
28
|
-
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
29
|
-
const action = Effect.gen(function* () {
|
|
30
|
-
log.info("checking for updates", void 0, {
|
|
31
|
-
F: __dxlog_file,
|
|
32
|
-
L: 33,
|
|
33
|
-
S: this,
|
|
34
|
-
C: (f, a) => f(...a)
|
|
35
|
-
});
|
|
36
|
-
const update = yield* Effect.tryPromise(() => check());
|
|
37
|
-
log.info("checked for updates", {
|
|
38
|
-
version: update?.version,
|
|
39
|
-
currentVersion: update?.currentVersion
|
|
40
|
-
}, {
|
|
41
|
-
F: __dxlog_file,
|
|
42
|
-
L: 35,
|
|
43
|
-
S: this,
|
|
44
|
-
C: (f, a) => f(...a)
|
|
45
|
-
});
|
|
46
|
-
if (update) {
|
|
47
|
-
log.info("update available", update, {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 37,
|
|
50
|
-
S: this,
|
|
51
|
-
C: (f, a) => f(...a)
|
|
52
|
-
});
|
|
53
|
-
let downloaded = 0;
|
|
54
|
-
let contentLength = 0;
|
|
55
|
-
const handleDownload = Match.type().pipe(Match.when({
|
|
56
|
-
event: "Started"
|
|
57
|
-
}, (event) => {
|
|
58
|
-
contentLength = event.data.contentLength ?? 0;
|
|
59
|
-
log.info("download started", {
|
|
60
|
-
contentLength
|
|
61
|
-
}, {
|
|
62
|
-
F: __dxlog_file,
|
|
63
|
-
L: 44,
|
|
64
|
-
S: this,
|
|
65
|
-
C: (f, a) => f(...a)
|
|
66
|
-
});
|
|
67
|
-
}), Match.when({
|
|
68
|
-
event: "Progress"
|
|
69
|
-
}, (event) => {
|
|
70
|
-
downloaded += event.data.chunkLength;
|
|
71
|
-
log.verbose("download progress", {
|
|
72
|
-
downloaded,
|
|
73
|
-
contentLength
|
|
74
|
-
}, {
|
|
75
|
-
F: __dxlog_file,
|
|
76
|
-
L: 48,
|
|
77
|
-
S: this,
|
|
78
|
-
C: (f, a) => f(...a)
|
|
79
|
-
});
|
|
80
|
-
}), Match.when({
|
|
81
|
-
event: "Finished"
|
|
82
|
-
}, () => {
|
|
83
|
-
log.info("download completed", void 0, {
|
|
84
|
-
F: __dxlog_file,
|
|
85
|
-
L: 51,
|
|
86
|
-
S: this,
|
|
87
|
-
C: (f, a) => f(...a)
|
|
88
|
-
});
|
|
89
|
-
}), Match.exhaustive);
|
|
90
|
-
yield* Effect.tryPromise(() => update.downloadAndInstall(handleDownload));
|
|
91
|
-
yield* dispatch(createIntent(LayoutAction.AddToast, {
|
|
92
|
-
part: "toast",
|
|
93
|
-
subject: {
|
|
94
|
-
id: `${meta.id}/update-ready`,
|
|
95
|
-
title: [
|
|
96
|
-
"update ready label",
|
|
97
|
-
{
|
|
98
|
-
ns: meta.id
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
description: [
|
|
102
|
-
"update ready description",
|
|
103
|
-
{
|
|
104
|
-
ns: meta.id
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
duration: Infinity,
|
|
108
|
-
actionLabel: [
|
|
109
|
-
"update label",
|
|
110
|
-
{
|
|
111
|
-
ns: meta.id
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
actionAlt: [
|
|
115
|
-
"update alt",
|
|
116
|
-
{
|
|
117
|
-
ns: meta.id
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
onAction: () => relaunch()
|
|
121
|
-
}
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
const fiber = Function.pipe(
|
|
126
|
-
// prettier-ignore
|
|
127
|
-
action,
|
|
128
|
-
Effect.repeat(Schedule.fixed(Duration.hours(1))),
|
|
129
|
-
Effect.runFork
|
|
130
|
-
);
|
|
131
|
-
return contributes(Capabilities.Null, null, () => {
|
|
132
|
-
Effect.runSync(Fiber.interrupt(fiber));
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
export {
|
|
136
|
-
updater_default as default
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=updater-SDBPTCXA.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 { 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 { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\n\nimport { meta } from '../meta';\n\nconst SUPPORTS_OTA = ['linux', 'macos', 'windows'];\n\nexport default (context: PluginContext) => {\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 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.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* dispatch(\n createIntent(LayoutAction.AddToast, {\n part: 'toast',\n subject: {\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 });\n\n const fiber = Function.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,SAA6BC,aAAa;AAC1C,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,SAASC,WAAW;;AAIpB,IAAMC,eAAe;EAAC;EAAS;EAAS;;AAExC,IAAA,mBAAe,CAACC,YAAAA;AAEd,QAAMC,WAAWC,KAAAA;AACjB,MAAI,CAACH,aAAaI,SAASF,QAAAA,KAAaG,OAAOC,SAASC,aAAa,aAAa;AAChF,WAAOC,YAAYC,aAAaC,MAAM,IAAA;EACxC;AAEA,QAAM,EAAEC,SAAQ,IAAKV,QAAQW,cAAcH,aAAaI,gBAAgB;AAGxE,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,iBAAuBtB,WAAI,EAAkBuB,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,aAAOd,SACLuB,aAAaC,aAAaC,UAAU;QAClCC,MAAM;QACNC,SAAS;UACPC,IAAI,GAAGC,KAAKD,EAAE;UACdE,OAAO;YAAC;YAAsB;cAAEC,IAAIF,KAAKD;YAAG;;UAC5CI,aAAa;YAAC;YAA4B;cAAED,IAAIF,KAAKD;YAAG;;UACxDK,UAAUC;UACVC,aAAa;YAAC;YAAgB;cAAEJ,IAAIF,KAAKD;YAAG;;UAC5CQ,WAAW;YAAC;YAAc;cAAEL,IAAIF,KAAKD;YAAG;;UACxCS,UAAU,MAAMC,SAAAA;QAClB;MACF,CAAA,CAAA;IAEJ;EACF,CAAA;AAEA,QAAMC,QAAiBxB;;IAErBZ;IACOqC,cAAgBC,eAAeC,eAAM,CAAA,CAAA,CAAA;IACrCC;EAAO;AAGhB,SAAO9C,YAAYC,aAAaC,MAAM,MAAM,MAAA;AAC1C6C,IAAOC,eAAcC,gBAAUP,KAAAA,CAAAA;EACjC,CAAA;AACF;",
|
|
6
|
-
"names": ["type", "relaunch", "check", "Duration", "Effect", "Fiber", "Function", "Match", "Schedule", "Capabilities", "LayoutAction", "contributes", "createIntent", "log", "SUPPORTS_OTA", "context", "platform", "type", "includes", "window", "location", "hostname", "contributes", "Capabilities", "Null", "dispatch", "getCapability", "IntentDispatcher", "action", "gen", "log", "info", "update", "tryPromise", "check", "version", "currentVersion", "downloaded", "contentLength", "handleDownload", "pipe", "when", "event", "data", "chunkLength", "verbose", "exhaustive", "downloadAndInstall", "createIntent", "LayoutAction", "AddToast", "part", "subject", "id", "meta", "title", "ns", "description", "duration", "Infinity", "actionLabel", "actionAlt", "onAction", "relaunch", "fiber", "repeat", "fixed", "hours", "runFork", "Effect", "runSync", "interrupt"]
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/capabilities/window.ts
|
|
2
|
-
import { LogicalPosition, LogicalSize, getCurrentWindow } from "@tauri-apps/api/window";
|
|
3
|
-
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
4
|
-
var window_default = ((_context) => {
|
|
5
|
-
return contributes(Capabilities.Null, null, () => {
|
|
6
|
-
const appWindow = getCurrentWindow();
|
|
7
|
-
async function saveWindowState() {
|
|
8
|
-
const size = await appWindow.innerSize();
|
|
9
|
-
const position = await appWindow.innerPosition();
|
|
10
|
-
localStorage.setItem("windowState", JSON.stringify({
|
|
11
|
-
width: size.width,
|
|
12
|
-
height: size.height,
|
|
13
|
-
x: position.x,
|
|
14
|
-
y: position.y
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
async function restoreWindowState() {
|
|
18
|
-
const savedState = localStorage.getItem("windowState");
|
|
19
|
-
if (savedState) {
|
|
20
|
-
const state = JSON.parse(savedState);
|
|
21
|
-
await appWindow.setSize(new LogicalSize(state.width, state.height));
|
|
22
|
-
await appWindow.setPosition(new LogicalPosition(state.x, state.y));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
void appWindow.listen("tauri://resize", saveWindowState);
|
|
26
|
-
void appWindow.listen("tauri://move", saveWindowState);
|
|
27
|
-
document.addEventListener("DOMContentLoaded", restoreWindowState);
|
|
28
|
-
window.addEventListener("beforeunload", saveWindowState);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
export {
|
|
32
|
-
window_default as default
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=window-6G542FZL.mjs.map
|