@dxos/plugin-native 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
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/index.mjs +28 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +18 -0
- package/dist/lib/browser/translations.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 +5 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ollama.d.ts +7 -0
- package/dist/types/src/capabilities/ollama.d.ts.map +1 -0
- package/dist/types/src/capabilities/spotlight-listener.d.ts +8 -0
- package/dist/types/src/capabilities/spotlight-listener.d.ts.map +1 -0
- package/dist/types/src/capabilities/updater.d.ts +5 -0
- package/dist/types/src/capabilities/updater.d.ts.map +1 -0
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -13
- package/src/NativePlugin.tsx +25 -17
- package/src/capabilities/index.ts +9 -0
- package/src/capabilities/ollama.ts +88 -0
- package/src/capabilities/spotlight-listener.ts +58 -0
- package/src/capabilities/updater.ts +129 -0
- package/src/constants.ts +7 -0
- package/src/meta.ts +8 -5
- package/src/translations.ts +20 -0
- package/dist/lib/browser/initialize-36I7B24R.mjs +0 -161
- package/dist/lib/browser/initialize-36I7B24R.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -28
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/initialize-QFY5UBRW.mjs +0 -163
- package/dist/lib/node-esm/initialize-QFY5UBRW.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/src/initialize.d.ts +0 -3
- package/dist/types/src/initialize.d.ts.map +0 -1
- package/src/initialize.ts +0 -175
package/package.json
CHANGED
|
@@ -1,41 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-native",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcc0d83b33",
|
|
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",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
17
|
+
"#meta": "./src/meta.ts",
|
|
18
|
+
"#translations": "./src/translations.ts"
|
|
19
|
+
},
|
|
11
20
|
"exports": {
|
|
12
21
|
".": {
|
|
22
|
+
"source": "./src/index.ts",
|
|
13
23
|
"types": "./dist/types/src/index.d.ts",
|
|
14
24
|
"browser": "./dist/lib/browser/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./translations": {
|
|
27
|
+
"source": "./src/translations.ts",
|
|
28
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
29
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
30
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
15
31
|
}
|
|
16
32
|
},
|
|
17
33
|
"types": "dist/types/src/index.d.ts",
|
|
18
|
-
"typesVersions": {
|
|
19
|
-
"*": {}
|
|
20
|
-
},
|
|
21
34
|
"files": [
|
|
22
35
|
"dist",
|
|
23
36
|
"src"
|
|
24
37
|
],
|
|
25
38
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
39
|
+
"@effect/platform": "0.94.4",
|
|
40
|
+
"@tauri-apps/api": "^2.8.0",
|
|
41
|
+
"@tauri-apps/plugin-os": "^2.3.1",
|
|
42
|
+
"@tauri-apps/plugin-process": "^2.3.0",
|
|
43
|
+
"@tauri-apps/plugin-shell": "^2.3.1",
|
|
44
|
+
"@tauri-apps/plugin-updater": "^2.9.0",
|
|
45
|
+
"effect": "3.20.0",
|
|
46
|
+
"@dxos/ai": "0.8.4-main.fcc0d83b33",
|
|
47
|
+
"@dxos/app-toolkit": "0.8.4-main.fcc0d83b33",
|
|
48
|
+
"@dxos/operation": "0.8.4-main.fcc0d83b33",
|
|
49
|
+
"@dxos/log": "0.8.4-main.fcc0d83b33",
|
|
50
|
+
"@dxos/plugin-help": "0.8.4-main.fcc0d83b33",
|
|
51
|
+
"@dxos/plugin-assistant": "0.8.4-main.fcc0d83b33",
|
|
52
|
+
"@dxos/util": "0.8.4-main.fcc0d83b33",
|
|
53
|
+
"@dxos/plugin-navtree": "0.8.4-main.fcc0d83b33",
|
|
54
|
+
"@dxos/app-framework": "0.8.4-main.fcc0d83b33"
|
|
33
55
|
},
|
|
34
56
|
"devDependencies": {
|
|
35
|
-
"vite": "
|
|
57
|
+
"vite": "^8.0.10",
|
|
58
|
+
"@dxos/react-ui": "0.8.4-main.fcc0d83b33"
|
|
36
59
|
},
|
|
37
60
|
"peerDependencies": {
|
|
38
|
-
"effect": "
|
|
61
|
+
"effect": "3.20.0",
|
|
62
|
+
"@dxos/react-ui": "0.8.4-main.fcc0d83b33"
|
|
39
63
|
},
|
|
40
64
|
"publishConfig": {
|
|
41
65
|
"access": "public"
|
package/src/NativePlugin.tsx
CHANGED
|
@@ -2,22 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import { ActivationEvents, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
import { AssistantEvents } from '@dxos/plugin-assistant/types';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { Ollama, SpotlightListener, Updater } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
import { translations } from '#translations';
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export const NativePlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
15
|
+
Plugin.addModule({
|
|
16
|
+
id: 'spotlight-listener',
|
|
17
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
18
|
+
activate: SpotlightListener,
|
|
19
|
+
}),
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
id: 'updater',
|
|
22
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
23
|
+
activate: Updater,
|
|
24
|
+
}),
|
|
25
|
+
Plugin.addModule({
|
|
26
|
+
id: 'ollama',
|
|
27
|
+
activatesOn: AssistantEvents.SetupAiServiceProviders,
|
|
28
|
+
activate: Ollama,
|
|
29
|
+
}),
|
|
30
|
+
Plugin.make,
|
|
31
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
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'));
|
|
8
|
+
export const SpotlightListener = Capability.lazy('SpotlightListener', () => import('./spotlight-listener'));
|
|
9
|
+
export const Updater = Capability.lazy('Updater', () => import('./updater'));
|
|
@@ -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,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
|
|
11
|
+
// TODO(wittjosiah): Formalize with a stricter schema if we evolve this protocol.
|
|
12
|
+
type SpotlightInvokePayload = {
|
|
13
|
+
operation: string;
|
|
14
|
+
payload?: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Listens for spotlight:invoke events from the popover window and dispatches the corresponding operation.
|
|
19
|
+
*/
|
|
20
|
+
export default Capability.makeModule(
|
|
21
|
+
Effect.fnUntraced(function* () {
|
|
22
|
+
const { invokePromise } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
23
|
+
|
|
24
|
+
const unlisten = yield* Effect.promise(async () => {
|
|
25
|
+
const { listen } = await import('@tauri-apps/api/event');
|
|
26
|
+
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
27
|
+
|
|
28
|
+
return listen<SpotlightInvokePayload>('spotlight:invoke', async (event) => {
|
|
29
|
+
const { operation, payload } = event.payload;
|
|
30
|
+
log.info('Received spotlight invoke event', { operation, payload });
|
|
31
|
+
try {
|
|
32
|
+
switch (operation) {
|
|
33
|
+
case 'open':
|
|
34
|
+
await invokePromise(LayoutOperation.Open, payload as any);
|
|
35
|
+
break;
|
|
36
|
+
case 'switch-workspace':
|
|
37
|
+
await invokePromise(LayoutOperation.SwitchWorkspace, payload as any);
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
log.warn('Unknown spotlight operation', { operation });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const mainWindow = getCurrentWindow();
|
|
44
|
+
await mainWindow.show();
|
|
45
|
+
await mainWindow.setFocus();
|
|
46
|
+
} catch (err) {
|
|
47
|
+
log.catch(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
53
|
+
Effect.sync(() => {
|
|
54
|
+
unlisten();
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
import { TAURI_LOCALHOST_PORT } from '../constants';
|
|
21
|
+
|
|
22
|
+
const SUPPORTS_OTA = ['linux', 'macos', 'windows'];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Safely check for updates with error logging.
|
|
26
|
+
*/
|
|
27
|
+
const check = async (): Promise<Updater.Update | null> => {
|
|
28
|
+
try {
|
|
29
|
+
return await Updater.check();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
log.error('failed to check for updates', { error });
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Safely download and install update with error logging.
|
|
38
|
+
*/
|
|
39
|
+
const downloadAndInstall = async (
|
|
40
|
+
update: Updater.Update,
|
|
41
|
+
handleDownload: (event: Updater.DownloadEvent) => void,
|
|
42
|
+
): Promise<boolean> => {
|
|
43
|
+
try {
|
|
44
|
+
await update.downloadAndInstall(handleDownload);
|
|
45
|
+
return true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
log.error('failed to download and install update', { error });
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Capability.makeModule(
|
|
53
|
+
Effect.fnUntraced(function* () {
|
|
54
|
+
// Skip updates if not supported or in dev mode.
|
|
55
|
+
const platform = type();
|
|
56
|
+
const isDevServer = window.location.port !== TAURI_LOCALHOST_PORT;
|
|
57
|
+
if (!SUPPORTS_OTA.includes(platform) || isDevServer) {
|
|
58
|
+
log.info('skipping updater', { platform, port: window.location.port });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
63
|
+
|
|
64
|
+
// https://tauri.app/plugin/updater/#checking-for-updates
|
|
65
|
+
// Returns true to keep checking, false to stop.
|
|
66
|
+
const action = Effect.gen(function* () {
|
|
67
|
+
log.info('checking for updates');
|
|
68
|
+
const update = yield* Effect.promise(() => check());
|
|
69
|
+
if (!update) {
|
|
70
|
+
log.info('no update available');
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
log.info('update check complete', {
|
|
74
|
+
available: update.available,
|
|
75
|
+
currentVersion: update.currentVersion,
|
|
76
|
+
version: update.version,
|
|
77
|
+
date: update.date,
|
|
78
|
+
body: update.body,
|
|
79
|
+
});
|
|
80
|
+
if (update.available) {
|
|
81
|
+
log.info('update available, starting download', { version: update.version });
|
|
82
|
+
let downloaded = 0;
|
|
83
|
+
let contentLength = 0;
|
|
84
|
+
|
|
85
|
+
const handleDownload = Match.type<Updater.DownloadEvent>().pipe(
|
|
86
|
+
Match.when({ event: 'Started' }, (event) => {
|
|
87
|
+
contentLength = event.data.contentLength ?? 0;
|
|
88
|
+
log.info('download started', { contentLength });
|
|
89
|
+
}),
|
|
90
|
+
Match.when({ event: 'Progress' }, (event) => {
|
|
91
|
+
downloaded += event.data.chunkLength;
|
|
92
|
+
log.verbose('download progress', { downloaded, contentLength });
|
|
93
|
+
}),
|
|
94
|
+
Match.when({ event: 'Finished' }, () => {
|
|
95
|
+
log.info('download completed');
|
|
96
|
+
}),
|
|
97
|
+
Match.exhaustive,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const downloadSuccess = yield* Effect.promise(() => downloadAndInstall(update, handleDownload));
|
|
101
|
+
|
|
102
|
+
if (downloadSuccess) {
|
|
103
|
+
yield* invoke(LayoutOperation.AddToast, {
|
|
104
|
+
id: `${meta.id}.update-ready`,
|
|
105
|
+
title: ['update-ready.label', { ns: meta.id }],
|
|
106
|
+
description: ['update-ready.description', { ns: meta.id }],
|
|
107
|
+
duration: Infinity,
|
|
108
|
+
actionLabel: ['update.label', { ns: meta.id }],
|
|
109
|
+
actionAlt: ['update.alt', { ns: meta.id }],
|
|
110
|
+
onAction: () => relaunch(),
|
|
111
|
+
});
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Run immediately on startup, then repeat every hour. Stop once an update is found.
|
|
119
|
+
const schedule = Schedule.fixed(Duration.hours(1)).pipe(
|
|
120
|
+
Schedule.whileInput((keepChecking: boolean) => keepChecking),
|
|
121
|
+
);
|
|
122
|
+
const fiber = yield* action.pipe(Effect.repeat(schedule), Effect.forkDaemon);
|
|
123
|
+
log.info('updater module initialized, update check scheduled');
|
|
124
|
+
|
|
125
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
126
|
+
Effect.sync(() => Effect.runSync(Fiber.interrupt(fiber))),
|
|
127
|
+
);
|
|
128
|
+
}),
|
|
129
|
+
);
|
package/src/constants.ts
ADDED
package/src/meta.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
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
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
6
|
+
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
|
|
9
|
+
export const translations = [
|
|
10
|
+
{
|
|
11
|
+
'en-US': {
|
|
12
|
+
[meta.id]: {
|
|
13
|
+
'update-ready.label': 'Ready to update',
|
|
14
|
+
'update-ready.description': 'A new version of Composer is available.',
|
|
15
|
+
'update.label': 'Update',
|
|
16
|
+
'update.alt': 'Relaunch the app to update',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
] as const satisfies Resource[];
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// src/initialize.ts
|
|
2
|
-
import { SettingsAction, LayoutAction, createIntent, Capabilities } from "@dxos/app-framework";
|
|
3
|
-
import { HELP_PLUGIN } from "@dxos/plugin-help";
|
|
4
|
-
import { COMMANDS_DIALOG } from "@dxos/plugin-navtree";
|
|
5
|
-
import { safeParseJson } from "@dxos/util";
|
|
6
|
-
var KEY_WINDOW_SIZE = "dxos.org/plugin/native/window-size";
|
|
7
|
-
var loadSocketSupplyModules = async () => {
|
|
8
|
-
const module = "socket:application";
|
|
9
|
-
const app = await import(
|
|
10
|
-
/* @vite-ignore */
|
|
11
|
-
module
|
|
12
|
-
);
|
|
13
|
-
const windowModule = "socket:window";
|
|
14
|
-
const socketWindow = await import(
|
|
15
|
-
/* @vite-ignore */
|
|
16
|
-
windowModule
|
|
17
|
-
);
|
|
18
|
-
const osModule = "socket:os";
|
|
19
|
-
const socketOs = await import(
|
|
20
|
-
/* @vite-ignore */
|
|
21
|
-
osModule
|
|
22
|
-
);
|
|
23
|
-
const { meta_title: appName } = app.config;
|
|
24
|
-
return {
|
|
25
|
-
app,
|
|
26
|
-
socketWindow,
|
|
27
|
-
socketOs,
|
|
28
|
-
appName
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
var configureDesktopWindowSizing = async (app) => {
|
|
32
|
-
const { width, height } = safeParseJson(localStorage.getItem(KEY_WINDOW_SIZE), {});
|
|
33
|
-
if (width && height) {
|
|
34
|
-
const appWindow = await app.getCurrentWindow();
|
|
35
|
-
await appWindow.setSize({
|
|
36
|
-
width,
|
|
37
|
-
height
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
window.addEventListener("resize", async () => {
|
|
41
|
-
const appWindow = await app.getCurrentWindow();
|
|
42
|
-
const { width: width2, height: height2 } = appWindow.getSize();
|
|
43
|
-
localStorage.setItem(KEY_WINDOW_SIZE, JSON.stringify({
|
|
44
|
-
width: width2,
|
|
45
|
-
height: height2
|
|
46
|
-
}));
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var configureSystemMenu = async (app, appName) => {
|
|
50
|
-
const itemsMac = `
|
|
51
|
-
Hide ${appName}: h + CommandOrControl
|
|
52
|
-
Hide Others: h + Control + Meta
|
|
53
|
-
---
|
|
54
|
-
`;
|
|
55
|
-
const menu = `
|
|
56
|
-
App Name:
|
|
57
|
-
About ${appName}: _
|
|
58
|
-
Settings...: , + CommandOrControl
|
|
59
|
-
---
|
|
60
|
-
Show shortcuts: / + CommandOrControl
|
|
61
|
-
Search commands: k + CommandOrControl
|
|
62
|
-
---
|
|
63
|
-
${itemsMac}
|
|
64
|
-
Quit: q + CommandOrControl
|
|
65
|
-
;
|
|
66
|
-
|
|
67
|
-
Edit:
|
|
68
|
-
Cut: x + CommandOrControl
|
|
69
|
-
Copy: c + CommandOrControl
|
|
70
|
-
Paste: v + CommandOrControl
|
|
71
|
-
Delete: _
|
|
72
|
-
Select All: a + CommandOrControl
|
|
73
|
-
;
|
|
74
|
-
`;
|
|
75
|
-
void app.setSystemMenu({
|
|
76
|
-
index: 0,
|
|
77
|
-
value: menu
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
var setupMenuItemListener = (dispatch, app) => {
|
|
81
|
-
window.addEventListener("menuItemSelected", async (event) => {
|
|
82
|
-
const id = `${event.detail.parent}:${event.detail.title}`;
|
|
83
|
-
switch (id) {
|
|
84
|
-
case "App Name:Search commands": {
|
|
85
|
-
void dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
86
|
-
part: "dialog",
|
|
87
|
-
subject: COMMANDS_DIALOG,
|
|
88
|
-
options: {
|
|
89
|
-
blockAlign: "start"
|
|
90
|
-
}
|
|
91
|
-
}));
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
case "App Name:Settings...": {
|
|
95
|
-
void dispatch(createIntent(SettingsAction.Open));
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case "App Name:Show shortcuts": {
|
|
99
|
-
void dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
100
|
-
part: "dialog",
|
|
101
|
-
subject: `${HELP_PLUGIN}/Shortcuts`,
|
|
102
|
-
options: {
|
|
103
|
-
blockAlign: "center"
|
|
104
|
-
}
|
|
105
|
-
}));
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case "App Name:Quit": {
|
|
109
|
-
await app.exit();
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
var setupApplicationUrlListener = (app, dispatch) => {
|
|
116
|
-
const appWindow = app.getCurrentWindow();
|
|
117
|
-
window.addEventListener("applicationurl", ({ url }) => {
|
|
118
|
-
appWindow.restore();
|
|
119
|
-
const location = url.toString().replace("composer://", "");
|
|
120
|
-
if (location.includes("InvitationCode")) {
|
|
121
|
-
window.location.href = location;
|
|
122
|
-
} else {
|
|
123
|
-
void dispatch(createIntent(LayoutAction.Open, {
|
|
124
|
-
part: "main",
|
|
125
|
-
subject: [
|
|
126
|
-
location
|
|
127
|
-
]
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
var setupGlobalHotkey = async (socketWindow, appWindow, dispatch) => {
|
|
133
|
-
const binding = await socketWindow.hotkey.bind("cmd + k");
|
|
134
|
-
binding.addEventListener("hotkey", () => {
|
|
135
|
-
appWindow.restore();
|
|
136
|
-
void dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
137
|
-
part: "dialog",
|
|
138
|
-
subject: COMMANDS_DIALOG,
|
|
139
|
-
options: {
|
|
140
|
-
blockAlign: "start"
|
|
141
|
-
}
|
|
142
|
-
}));
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
var initializeNativeApp = async (context) => {
|
|
146
|
-
const { app, socketWindow, socketOs, appName } = await loadSocketSupplyModules();
|
|
147
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
148
|
-
const platform = socketOs.platform();
|
|
149
|
-
document.body.setAttribute("data-platform", platform);
|
|
150
|
-
if (platform === "darwin" || platform === "win32") {
|
|
151
|
-
await configureDesktopWindowSizing(app);
|
|
152
|
-
await configureSystemMenu(app, appName);
|
|
153
|
-
setupMenuItemListener(dispatch, app);
|
|
154
|
-
setupApplicationUrlListener(app, dispatch);
|
|
155
|
-
await setupGlobalHotkey(socketWindow, app, dispatch);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
export {
|
|
159
|
-
initializeNativeApp
|
|
160
|
-
};
|
|
161
|
-
//# sourceMappingURL=initialize-36I7B24R.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/initialize.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type { PluginContext } from '@dxos/app-framework';\nimport { SettingsAction, LayoutAction, createIntent, Capabilities } from '@dxos/app-framework';\nimport { HELP_PLUGIN } from '@dxos/plugin-help';\nimport { COMMANDS_DIALOG } from '@dxos/plugin-navtree';\nimport { safeParseJson } from '@dxos/util';\n\n// TODO(burdon): Reconcile with other properties.\nconst KEY_WINDOW_SIZE = 'dxos.org/plugin/native/window-size';\n\n/**\n * Native code for socketsupply app.\n * https://www.npmjs.com/package/@socketsupply/socket\n * https://github.com/socketsupply/socket-examples\n */\n\nconst loadSocketSupplyModules = async () => {\n // SocketSupply implements the dynamic import.\n const module = 'socket:application';\n const app = await import(/* @vite-ignore */ module);\n const windowModule = 'socket:window';\n const socketWindow = await import(/* @vite-ignore */ windowModule);\n const osModule = 'socket:os';\n const socketOs = await import(/* @vite-ignore */ osModule);\n const { meta_title: appName } = app.config;\n\n return { app, socketWindow, socketOs, appName };\n};\n\nconst configureDesktopWindowSizing = async (app: any) => {\n const { width, height } = safeParseJson<{ width?: number; height?: number }>(\n localStorage.getItem(KEY_WINDOW_SIZE),\n {},\n );\n\n if (width && height) {\n const appWindow = await app.getCurrentWindow();\n await appWindow.setSize({ width, height });\n }\n\n window.addEventListener('resize', async () => {\n const appWindow = await app.getCurrentWindow();\n const { width, height } = appWindow.getSize();\n localStorage.setItem(KEY_WINDOW_SIZE, JSON.stringify({ width, height }));\n });\n};\n\nconst configureSystemMenu = async (app: any, appName: string) => {\n const itemsMac = `\n Hide ${appName}: h + CommandOrControl\n Hide Others: h + Control + Meta\n ---\n `;\n\n // TODO(mjamesderocher) Change menu names to use translations\n const menu = `\n App Name:\n About ${appName}: _\n Settings...: , + CommandOrControl\n ---\n Show shortcuts: / + CommandOrControl\n Search commands: k + CommandOrControl\n ---\n ${itemsMac}\n Quit: q + CommandOrControl\n ;\n\n Edit:\n Cut: x + CommandOrControl\n Copy: c + CommandOrControl\n Paste: v + CommandOrControl\n Delete: _\n Select All: a + CommandOrControl\n ;\n `;\n\n void app.setSystemMenu({ index: 0, value: menu });\n};\n\nconst setupMenuItemListener = (dispatch: any, app: any) => {\n window.addEventListener('menuItemSelected', async (event: any) => {\n const id = `${event.detail.parent}:${event.detail.title}`;\n switch (id) {\n case 'App Name:Search commands': {\n void dispatch(\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: COMMANDS_DIALOG,\n options: {\n blockAlign: 'start',\n },\n }),\n );\n break;\n }\n case 'App Name:Settings...': {\n void dispatch(createIntent(SettingsAction.Open));\n break;\n }\n case 'App Name:Show shortcuts': {\n void dispatch(\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: `${HELP_PLUGIN}/Shortcuts`,\n options: {\n blockAlign: 'center',\n },\n }),\n );\n break;\n }\n case 'App Name:Quit': {\n await app.exit();\n break;\n }\n }\n });\n};\n\nconst setupApplicationUrlListener = (app: any, dispatch: any) => {\n const appWindow = app.getCurrentWindow();\n\n // applicationurl is a custom event fired by the Socket Supply Runtime:\n // https://github.com/socketsupply/socket/blob/ef7fb5559876e41062d5896aafb7b79989fc96e5/api/internal/events.js#L6\n window.addEventListener('applicationurl', ({ url }: any) => {\n appWindow.restore();\n const location = url.toString().replace('composer://', '');\n if (location.includes('InvitationCode')) {\n // TODO(mjamesderocher): Integrate this with app routing.\n // Currently, the dialogs are controlled by Client Plugin and not the Layout Plugin.\n window.location.href = location;\n } else {\n // TODO(thure): What is `location` and is this right?\n void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [location] }));\n }\n });\n};\n\nconst setupGlobalHotkey = async (socketWindow: any, appWindow: any, dispatch: any) => {\n const binding = await socketWindow.hotkey.bind('cmd + k');\n\n // Global hotkey listener\n binding.addEventListener('hotkey', () => {\n appWindow.restore();\n void dispatch(\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: COMMANDS_DIALOG,\n options: {\n blockAlign: 'start',\n },\n }),\n );\n });\n};\n\nexport const initializeNativeApp = async (context: PluginContext) => {\n const { app, socketWindow, socketOs, appName } = await loadSocketSupplyModules();\n const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n\n const platform = socketOs.platform();\n\n document.body.setAttribute('data-platform', platform);\n\n if (platform === 'darwin' || platform === 'win32') {\n await configureDesktopWindowSizing(app);\n await configureSystemMenu(app, appName);\n setupMenuItemListener(dispatch, app);\n setupApplicationUrlListener(app, dispatch);\n await setupGlobalHotkey(socketWindow, app, dispatch);\n }\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,gBAAgBC,cAAcC,cAAcC,oBAAoB;AACzE,SAASC,mBAAmB;AAC5B,SAASC,uBAAuB;AAChC,SAASC,qBAAqB;AAG9B,IAAMC,kBAAkB;AAQxB,IAAMC,0BAA0B,YAAA;AAE9B,QAAMC,SAAS;AACf,QAAMC,MAAM,MAAM;;IAA0BD;;AAC5C,QAAME,eAAe;AACrB,QAAMC,eAAe,MAAM;;IAA0BD;;AACrD,QAAME,WAAW;AACjB,QAAMC,WAAW,MAAM;;IAA0BD;;AACjD,QAAM,EAAEE,YAAYC,QAAO,IAAKN,IAAIO;AAEpC,SAAO;IAAEP;IAAKE;IAAcE;IA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AA;AACnC,UAAMuB,oBAAoBvB,KAAKM,OAAAA;AAC/BuB,0BAAsBC,UAAU9B,GAAAA;AAChCgD,gCAA4BhD,KAAK8B,QAAAA;AACjC,UAAM0B,kBAAkBtD,cAAcF,KAAK8B,QAAAA;EAC7C;AACF;",
|
|
6
|
-
"names": ["SettingsAction", "LayoutAction", "createIntent", "Capabilities", "HELP_PLUGIN", "COMMANDS_DIALOG", "safeParseJson", "KEY_WINDOW_SIZE", "loadSocketSupplyModules", "module", "app", "windowModule", "socketWindow", "osModule", "socketOs", "meta_title", "appName", "config", "configureDesktopWindowSizing", "width", "height", "safeParseJson", "localStorage", "getItem", "appWindow", "getCurrentWindow", "setSize", "window", "addEventListener", "getSize", "setItem", "JSON", "stringify", "configureSystemMenu", "itemsMac", "menu", "setSystemMenu", "index", "value", "setupMenuItemListener", "dispatch", "event", "id", "detail", "parent", "title", "createIntent", "LayoutAction", "UpdateDialog", "part", "subject", "COMMANDS_DIALOG", "options", "blockAlign", "SettingsAction", "Open", "HELP_PLUGIN", "exit", "setupApplicationUrlListener", "url", "restore", "location", "toString", "replace", "includes", "href", "setupGlobalHotkey", "binding", "hotkey", "bind", "initializeNativeApp", "context", "dispatchPromise", "getCapability", "Capabilities", "IntentDispatcher", "platform", "document", "body", "setAttribute"]
|
|
7
|
-
}
|