@dxos/plugin-native 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3

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 (35) hide show
  1. package/dist/lib/browser/chunk-E2JDGVJI.mjs +12 -0
  2. package/dist/lib/browser/chunk-E2JDGVJI.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +45 -13
  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-7VZCJLY5.mjs +87 -0
  7. package/dist/lib/browser/ollama-7VZCJLY5.mjs.map +7 -0
  8. package/dist/lib/browser/updater-MNSUJ5ER.mjs +133 -0
  9. package/dist/lib/browser/updater-MNSUJ5ER.mjs.map +7 -0
  10. package/dist/lib/browser/window-5EBHZJJ4.mjs +34 -0
  11. package/dist/lib/browser/window-5EBHZJJ4.mjs.map +7 -0
  12. package/dist/types/src/NativePlugin.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/index.d.ts +4 -0
  14. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  15. package/dist/types/src/capabilities/ollama.d.ts +4 -0
  16. package/dist/types/src/capabilities/ollama.d.ts.map +1 -0
  17. package/dist/types/src/capabilities/updater.d.ts +4 -0
  18. package/dist/types/src/capabilities/updater.d.ts.map +1 -0
  19. package/dist/types/src/capabilities/window.d.ts +4 -0
  20. package/dist/types/src/capabilities/window.d.ts.map +1 -0
  21. package/dist/types/src/translations.d.ts +12 -0
  22. package/dist/types/src/translations.d.ts.map +1 -0
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +20 -10
  25. package/src/NativePlugin.tsx +21 -10
  26. package/src/capabilities/index.ts +9 -0
  27. package/src/capabilities/ollama.ts +79 -0
  28. package/src/capabilities/updater.ts +80 -0
  29. package/src/capabilities/window.ts +49 -0
  30. package/src/translations.ts +20 -0
  31. package/dist/lib/browser/initialize-36I7B24R.mjs +0 -161
  32. package/dist/lib/browser/initialize-36I7B24R.mjs.map +0 -7
  33. package/dist/types/src/initialize.d.ts +0 -3
  34. package/dist/types/src/initialize.d.ts.map +0 -1
  35. package/src/initialize.ts +0 -175
package/src/initialize.ts DELETED
@@ -1,175 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import type { PluginContext } from '@dxos/app-framework';
6
- import { SettingsAction, LayoutAction, createIntent, Capabilities } from '@dxos/app-framework';
7
- import { HELP_PLUGIN } from '@dxos/plugin-help';
8
- import { COMMANDS_DIALOG } from '@dxos/plugin-navtree';
9
- import { safeParseJson } from '@dxos/util';
10
-
11
- // TODO(burdon): Reconcile with other properties.
12
- const KEY_WINDOW_SIZE = 'dxos.org/plugin/native/window-size';
13
-
14
- /**
15
- * Native code for socketsupply app.
16
- * https://www.npmjs.com/package/@socketsupply/socket
17
- * https://github.com/socketsupply/socket-examples
18
- */
19
-
20
- const loadSocketSupplyModules = async () => {
21
- // SocketSupply implements the dynamic import.
22
- const module = 'socket:application';
23
- const app = await import(/* @vite-ignore */ module);
24
- const windowModule = 'socket:window';
25
- const socketWindow = await import(/* @vite-ignore */ windowModule);
26
- const osModule = 'socket:os';
27
- const socketOs = await import(/* @vite-ignore */ osModule);
28
- const { meta_title: appName } = app.config;
29
-
30
- return { app, socketWindow, socketOs, appName };
31
- };
32
-
33
- const configureDesktopWindowSizing = async (app: any) => {
34
- const { width, height } = safeParseJson<{ width?: number; height?: number }>(
35
- localStorage.getItem(KEY_WINDOW_SIZE),
36
- {},
37
- );
38
-
39
- if (width && height) {
40
- const appWindow = await app.getCurrentWindow();
41
- await appWindow.setSize({ width, height });
42
- }
43
-
44
- window.addEventListener('resize', async () => {
45
- const appWindow = await app.getCurrentWindow();
46
- const { width, height } = appWindow.getSize();
47
- localStorage.setItem(KEY_WINDOW_SIZE, JSON.stringify({ width, height }));
48
- });
49
- };
50
-
51
- const configureSystemMenu = async (app: any, appName: string) => {
52
- const itemsMac = `
53
- Hide ${appName}: h + CommandOrControl
54
- Hide Others: h + Control + Meta
55
- ---
56
- `;
57
-
58
- // TODO(mjamesderocher) Change menu names to use translations
59
- const menu = `
60
- App Name:
61
- About ${appName}: _
62
- Settings...: , + CommandOrControl
63
- ---
64
- Show shortcuts: / + CommandOrControl
65
- Search commands: k + CommandOrControl
66
- ---
67
- ${itemsMac}
68
- Quit: q + CommandOrControl
69
- ;
70
-
71
- Edit:
72
- Cut: x + CommandOrControl
73
- Copy: c + CommandOrControl
74
- Paste: v + CommandOrControl
75
- Delete: _
76
- Select All: a + CommandOrControl
77
- ;
78
- `;
79
-
80
- void app.setSystemMenu({ index: 0, value: menu });
81
- };
82
-
83
- const setupMenuItemListener = (dispatch: any, app: any) => {
84
- window.addEventListener('menuItemSelected', async (event: any) => {
85
- const id = `${event.detail.parent}:${event.detail.title}`;
86
- switch (id) {
87
- case 'App Name:Search commands': {
88
- void dispatch(
89
- createIntent(LayoutAction.UpdateDialog, {
90
- part: 'dialog',
91
- subject: COMMANDS_DIALOG,
92
- options: {
93
- blockAlign: 'start',
94
- },
95
- }),
96
- );
97
- break;
98
- }
99
- case 'App Name:Settings...': {
100
- void dispatch(createIntent(SettingsAction.Open));
101
- break;
102
- }
103
- case 'App Name:Show shortcuts': {
104
- void dispatch(
105
- createIntent(LayoutAction.UpdateDialog, {
106
- part: 'dialog',
107
- subject: `${HELP_PLUGIN}/Shortcuts`,
108
- options: {
109
- blockAlign: 'center',
110
- },
111
- }),
112
- );
113
- break;
114
- }
115
- case 'App Name:Quit': {
116
- await app.exit();
117
- break;
118
- }
119
- }
120
- });
121
- };
122
-
123
- const setupApplicationUrlListener = (app: any, dispatch: any) => {
124
- const appWindow = app.getCurrentWindow();
125
-
126
- // applicationurl is a custom event fired by the Socket Supply Runtime:
127
- // https://github.com/socketsupply/socket/blob/ef7fb5559876e41062d5896aafb7b79989fc96e5/api/internal/events.js#L6
128
- window.addEventListener('applicationurl', ({ url }: any) => {
129
- appWindow.restore();
130
- const location = url.toString().replace('composer://', '');
131
- if (location.includes('InvitationCode')) {
132
- // TODO(mjamesderocher): Integrate this with app routing.
133
- // Currently, the dialogs are controlled by Client Plugin and not the Layout Plugin.
134
- window.location.href = location;
135
- } else {
136
- // TODO(thure): What is `location` and is this right?
137
- void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [location] }));
138
- }
139
- });
140
- };
141
-
142
- const setupGlobalHotkey = async (socketWindow: any, appWindow: any, dispatch: any) => {
143
- const binding = await socketWindow.hotkey.bind('cmd + k');
144
-
145
- // Global hotkey listener
146
- binding.addEventListener('hotkey', () => {
147
- appWindow.restore();
148
- void dispatch(
149
- createIntent(LayoutAction.UpdateDialog, {
150
- part: 'dialog',
151
- subject: COMMANDS_DIALOG,
152
- options: {
153
- blockAlign: 'start',
154
- },
155
- }),
156
- );
157
- });
158
- };
159
-
160
- export const initializeNativeApp = async (context: PluginContext) => {
161
- const { app, socketWindow, socketOs, appName } = await loadSocketSupplyModules();
162
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
163
-
164
- const platform = socketOs.platform();
165
-
166
- document.body.setAttribute('data-platform', platform);
167
-
168
- if (platform === 'darwin' || platform === 'win32') {
169
- await configureDesktopWindowSizing(app);
170
- await configureSystemMenu(app, appName);
171
- setupMenuItemListener(dispatch, app);
172
- setupApplicationUrlListener(app, dispatch);
173
- await setupGlobalHotkey(socketWindow, app, dispatch);
174
- }
175
- };