@omujs/omu 0.9.42 → 0.9.47

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 (154) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/package.json +1 -1
  3. package/src/api/dashboard/extension.ts +42 -42
  4. package/src/api/dashboard/handler.ts +1 -1
  5. package/src/api/registry/extension.ts +109 -23
  6. package/src/network/network.ts +5 -0
  7. package/src/omu.ts +1 -0
  8. package/src/serialize/bytebuffer.ts +8 -0
  9. package/src/version.ts +1 -1
  10. package/dist/dts/address.d.ts +0 -6
  11. package/dist/dts/api/asset/extension.d.ts +0 -25
  12. package/dist/dts/api/asset/index.d.ts +0 -2
  13. package/dist/dts/api/dashboard/extension.d.ts +0 -181
  14. package/dist/dts/api/dashboard/handler.d.ts +0 -22
  15. package/dist/dts/api/dashboard/index.d.ts +0 -3
  16. package/dist/dts/api/dashboard/packets.d.ts +0 -73
  17. package/dist/dts/api/endpoint/endpoint.d.ts +0 -32
  18. package/dist/dts/api/endpoint/extension.d.ts +0 -23
  19. package/dist/dts/api/endpoint/index.d.ts +0 -2
  20. package/dist/dts/api/endpoint/packets.d.ts +0 -51
  21. package/dist/dts/api/extension-registry.d.ts +0 -8
  22. package/dist/dts/api/extension.d.ts +0 -11
  23. package/dist/dts/api/http/extension.d.ts +0 -41
  24. package/dist/dts/api/http/http.d.ts +0 -36
  25. package/dist/dts/api/http/index.d.ts +0 -2
  26. package/dist/dts/api/http/websocket.d.ts +0 -123
  27. package/dist/dts/api/i18n/extension.d.ts +0 -19
  28. package/dist/dts/api/i18n/index.d.ts +0 -1
  29. package/dist/dts/api/index.d.ts +0 -2
  30. package/dist/dts/api/logger/extension.d.ts +0 -25
  31. package/dist/dts/api/logger/index.d.ts +0 -1
  32. package/dist/dts/api/logger/packets.d.ts +0 -18
  33. package/dist/dts/api/permission/extension.d.ts +0 -19
  34. package/dist/dts/api/permission/index.d.ts +0 -1
  35. package/dist/dts/api/permission/permission.d.ts +0 -25
  36. package/dist/dts/api/plugin/extension.d.ts +0 -43
  37. package/dist/dts/api/plugin/index.d.ts +0 -2
  38. package/dist/dts/api/plugin/package-info.d.ts +0 -84
  39. package/dist/dts/api/registry/extension.d.ts +0 -26
  40. package/dist/dts/api/registry/index.d.ts +0 -2
  41. package/dist/dts/api/registry/packets.d.ts +0 -20
  42. package/dist/dts/api/registry/registry.d.ts +0 -57
  43. package/dist/dts/api/server/extension.d.ts +0 -61
  44. package/dist/dts/api/server/index.d.ts +0 -1
  45. package/dist/dts/api/session/extension.d.ts +0 -52
  46. package/dist/dts/api/session/index.d.ts +0 -1
  47. package/dist/dts/api/signal/extension.d.ts +0 -22
  48. package/dist/dts/api/signal/index.d.ts +0 -1
  49. package/dist/dts/api/signal/packets.d.ts +0 -21
  50. package/dist/dts/api/signal/signal.d.ts +0 -33
  51. package/dist/dts/api/table/extension.d.ts +0 -29
  52. package/dist/dts/api/table/index.d.ts +0 -2
  53. package/dist/dts/api/table/packets.d.ts +0 -65
  54. package/dist/dts/api/table/table.d.ts +0 -76
  55. package/dist/dts/app.d.ts +0 -49
  56. package/dist/dts/const.d.ts +0 -2
  57. package/dist/dts/errors.d.ts +0 -36
  58. package/dist/dts/event/index.d.ts +0 -6
  59. package/dist/dts/helper.d.ts +0 -13
  60. package/dist/dts/identifier.d.ts +0 -51
  61. package/dist/dts/index.d.ts +0 -36
  62. package/dist/dts/localization/index.d.ts +0 -2
  63. package/dist/dts/localization/locale.d.ts +0 -735
  64. package/dist/dts/localization/localization.d.ts +0 -5
  65. package/dist/dts/lock.d.ts +0 -6
  66. package/dist/dts/network/connection.d.ts +0 -17
  67. package/dist/dts/network/encryption.d.ts +0 -38
  68. package/dist/dts/network/frame-transport.d.ts +0 -22
  69. package/dist/dts/network/index.d.ts +0 -5
  70. package/dist/dts/network/network.d.ts +0 -58
  71. package/dist/dts/network/packet/index.d.ts +0 -2
  72. package/dist/dts/network/packet/packet-types.d.ts +0 -84
  73. package/dist/dts/network/packet/packet.d.ts +0 -28
  74. package/dist/dts/network/websocket-transport.d.ts +0 -24
  75. package/dist/dts/omu.d.ts +0 -61
  76. package/dist/dts/result.d.ts +0 -41
  77. package/dist/dts/serialize/bytebuffer.d.ts +0 -71
  78. package/dist/dts/serialize/index.d.ts +0 -2
  79. package/dist/dts/serialize/serializer.d.ts +0 -38
  80. package/dist/dts/token.d.ts +0 -14
  81. package/dist/dts/version.d.ts +0 -2
  82. package/dist/esm/address.js +0 -4
  83. package/dist/esm/api/asset/extension.js +0 -905
  84. package/dist/esm/api/asset/index.js +0 -903
  85. package/dist/esm/api/dashboard/extension.js +0 -1355
  86. package/dist/esm/api/dashboard/handler.js +0 -4
  87. package/dist/esm/api/dashboard/index.js +0 -1354
  88. package/dist/esm/api/dashboard/packets.js +0 -413
  89. package/dist/esm/api/endpoint/endpoint.js +0 -383
  90. package/dist/esm/api/endpoint/extension.js +0 -1090
  91. package/dist/esm/api/endpoint/index.js +0 -383
  92. package/dist/esm/api/endpoint/packets.js +0 -793
  93. package/dist/esm/api/extension-registry.js +0 -23
  94. package/dist/esm/api/extension.js +0 -278
  95. package/dist/esm/api/http/extension.js +0 -1414
  96. package/dist/esm/api/http/http.js +0 -442
  97. package/dist/esm/api/http/index.js +0 -1413
  98. package/dist/esm/api/http/websocket.js +0 -220
  99. package/dist/esm/api/i18n/extension.js +0 -1270
  100. package/dist/esm/api/i18n/index.js +0 -1268
  101. package/dist/esm/api/index.js +0 -295
  102. package/dist/esm/api/logger/extension.js +0 -850
  103. package/dist/esm/api/logger/index.js +0 -846
  104. package/dist/esm/api/logger/packets.js +0 -667
  105. package/dist/esm/api/permission/extension.js +0 -535
  106. package/dist/esm/api/permission/index.js +0 -294
  107. package/dist/esm/api/permission/permission.js +0 -294
  108. package/dist/esm/api/plugin/extension.js +0 -531
  109. package/dist/esm/api/plugin/index.js +0 -529
  110. package/dist/esm/api/plugin/package-info.js +0 -4
  111. package/dist/esm/api/registry/extension.js +0 -1217
  112. package/dist/esm/api/registry/index.js +0 -1216
  113. package/dist/esm/api/registry/packets.js +0 -688
  114. package/dist/esm/api/registry/registry.js +0 -383
  115. package/dist/esm/api/server/extension.js +0 -2071
  116. package/dist/esm/api/server/index.js +0 -2049
  117. package/dist/esm/api/session/extension.js +0 -2166
  118. package/dist/esm/api/session/index.js +0 -2166
  119. package/dist/esm/api/signal/extension.js +0 -1025
  120. package/dist/esm/api/signal/index.js +0 -379
  121. package/dist/esm/api/signal/packets.js +0 -684
  122. package/dist/esm/api/signal/signal.js +0 -379
  123. package/dist/esm/api/table/extension.js +0 -1547
  124. package/dist/esm/api/table/index.js +0 -1546
  125. package/dist/esm/api/table/packets.js +0 -898
  126. package/dist/esm/api/table/table.js +0 -383
  127. package/dist/esm/app.js +0 -264
  128. package/dist/esm/const.js +0 -11
  129. package/dist/esm/errors.js +0 -548
  130. package/dist/esm/event/index.js +0 -22
  131. package/dist/esm/helper.js +0 -15
  132. package/dist/esm/identifier.js +0 -266
  133. package/dist/esm/index.js +0 -5111
  134. package/dist/esm/localization/index.js +0 -742
  135. package/dist/esm/localization/locale.js +0 -742
  136. package/dist/esm/localization/localization.js +0 -4
  137. package/dist/esm/lock.js +0 -46
  138. package/dist/esm/network/connection.js +0 -293
  139. package/dist/esm/network/encryption.js +0 -980
  140. package/dist/esm/network/frame-transport.js +0 -525
  141. package/dist/esm/network/index.js +0 -1617
  142. package/dist/esm/network/network.js +0 -1358
  143. package/dist/esm/network/packet/index.js +0 -485
  144. package/dist/esm/network/packet/packet-types.js +0 -486
  145. package/dist/esm/network/packet/packet.js +0 -126
  146. package/dist/esm/network/websocket-transport.js +0 -487
  147. package/dist/esm/omu.js +0 -4870
  148. package/dist/esm/result.js +0 -68
  149. package/dist/esm/serialize/bytebuffer.js +0 -378
  150. package/dist/esm/serialize/index.js +0 -465
  151. package/dist/esm/serialize/serializer.js +0 -97
  152. package/dist/esm/token.js +0 -42
  153. package/dist/esm/version.js +0 -11
  154. package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.9.47 (2025-12-18)
7
+
8
+ **Note:** Version bump only for package @omujs/omu
9
+
10
+
11
+
12
+
13
+
14
+ ## 0.9.46 (2025-12-09)
15
+
16
+ **Note:** Version bump only for package @omujs/omu
17
+
18
+
19
+
20
+
21
+
22
+ ## 0.9.45 (2025-11-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **dash:** token.txtを生成できない場合のエラーメッセージを修正 ([29d4c34](https://github.com/OMUAPPS/omuapps/commit/29d4c34e1fbfa60b909a56d7fbcc5e65c3424cae))
28
+
29
+
30
+
31
+
32
+
33
+ ## 0.9.44 (2025-11-22)
34
+
35
+ **Note:** Version bump only for package @omujs/omu
36
+
37
+
38
+
39
+
40
+
41
+ ## 0.9.43 (2025-11-22)
42
+
43
+ **Note:** Version bump only for package @omujs/omu
44
+
45
+
46
+
47
+
48
+
6
49
  ## 0.9.42 (2025-11-20)
7
50
 
8
51
  **Note:** Version bump only for package @omujs/omu
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@omujs/omu",
4
- "version": "0.9.42",
4
+ "version": "0.9.47",
5
5
  "main": "./dist/esm/index.js",
6
6
  "types": "./dist/dts/index.d.ts",
7
7
  "exports": {
@@ -5,6 +5,7 @@ import { Omu } from '../../omu.js';
5
5
  import { PromiseResult } from '../../result.js';
6
6
  import { Serializer } from '../../serialize';
7
7
  import { EndpointType } from '../endpoint/endpoint.js';
8
+ import { InvokedParams } from '../endpoint/packets.js';
8
9
  import { ExtensionType } from '../extension.js';
9
10
  import { PermissionTypeJson } from '../permission/permission.js';
10
11
  import { PackageInfo } from '../plugin/package-info.js';
@@ -339,12 +340,12 @@ export class DashboardExtension {
339
340
  DASHBOARD_PROMPT_REQUEST,
340
341
  DASHBOARD_PROMPT_RESPONSE,
341
342
  );
342
- omu.network.addPacketHandler(DASHBOARD_PROMPT_REQUEST, (request) =>
343
- this.handlePromptRequest(request),
344
- );
345
- omu.network.addPacketHandler(DASHBOARD_OPEN_APP_PACKET, (app) =>
346
- this.handleOpenApp(app),
347
- );
343
+ omu.network.addPacketHandler(DASHBOARD_PROMPT_REQUEST, (request) => {
344
+ this.handlePromptRequest(request);
345
+ });
346
+ omu.network.addPacketHandler(DASHBOARD_OPEN_APP_PACKET, (app) => {
347
+ this.handleOpenApp(app);
348
+ });
348
349
  omu.network.addPacketHandler(DASHBOARD_DRAG_DROP_REQUEST_PACKET, (request) => {
349
350
  this.handleDragDropRequest(request);
350
351
  });
@@ -442,55 +443,54 @@ export class DashboardExtension {
442
443
  throw new Error('Dashboard already set');
443
444
  }
444
445
  this.dashboard = dashboard;
446
+
447
+ this.omu.server.apps.event.remove.listen(async (apps) => {
448
+ for (const app of apps.values()) {
449
+ const hosts = await this.allowedHosts.get(app.id.key());
450
+ if (!hosts) continue;
451
+ this.allowedHosts.remove(hosts);
452
+ }
453
+ });
454
+
455
+ const requireHost = async (params: InvokedParams, host: string): Promise<UserResponse<undefined>> => {
456
+ const id = params.caller.key();
457
+ const hostEntry: AllowedHost = await this.allowedHosts.get(id) ?? { id: id, hosts: [] };
458
+ const allowed = hostEntry.hosts.includes(host);
459
+ if (!allowed) {
460
+ const result = await dashboard.handleHostRequest({
461
+ host,
462
+ }, params);
463
+ if (result === 'accept') {
464
+ const hostEntry: AllowedHost = await this.allowedHosts.get(id) ?? { id: id, hosts: [] };
465
+ hostEntry.hosts.push(host);
466
+ await this.allowedHosts.update(hostEntry);
467
+ } else {
468
+ return { type: 'cancelled' };
469
+ }
470
+ }
471
+ return { type: 'ok', value: undefined };
472
+ };
473
+
445
474
  this.omu.endpoints.bind(DASHBOARD_COOKIES_GET, async (request, params): Promise<UserResponse<Cookie[]>> => {
446
475
  const { url } = request;
447
476
  const { host } = new URL(url);
448
- const id = params.caller.key();
449
- const allowedHost: AllowedHost = await this.allowedHosts.get(id) ?? { id, hosts: [] };
450
- const allowed = allowedHost.hosts.includes(host);
451
- if (!allowed) {
452
- return {
453
- type: 'cancelled',
454
- };
477
+ const hostAccessResult = await requireHost(params, host);
478
+ if (hostAccessResult.type !== 'ok') {
479
+ return hostAccessResult;
455
480
  }
456
481
  return await dashboard.getCookies(request);
457
482
  });
458
483
  this.omu.endpoints.bind(DASHBOARD_HOST_REQUEST, async (request, params): Promise<UserResponse> => {
459
484
  const { host } = request;
460
- const id = params.caller.key();
461
- const hostEntry: AllowedHost = await this.allowedHosts.get(id) ?? { id, hosts: [] };
462
- const allowed = hostEntry.hosts.includes(host);
463
- if (allowed) {
464
- return {
465
- type: 'ok',
466
- value: undefined,
467
- };
468
- }
469
- const result = await dashboard.hostRequested(request, params);
470
- if (result.type === 'ok') {
471
- hostEntry.hosts.push(host);
472
- await this.allowedHosts.update(hostEntry);
473
- }
485
+ const result = await requireHost(params, host);
474
486
  return result;
475
487
  });
476
488
  this.omu.endpoints.bind(DASHBOARD_WEBVIEW_REQUEST, async (request, params): Promise<WebviewResponse> => {
477
489
  const url = new URL(request.url);
478
490
  const { host } = url;
479
- {
480
- const id = params.caller.key();
481
- const hostEntry: AllowedHost = await this.allowedHosts.get(id) ?? { id, hosts: [] };
482
- const allowed = hostEntry.hosts.includes(host);
483
- if (!allowed) {
484
- const result = await dashboard.hostRequested({
485
- host,
486
- }, params);
487
- if (result.type === 'ok') {
488
- hostEntry.hosts.push();
489
- await this.allowedHosts.update(hostEntry);
490
- } else {
491
- return { type: 'cancelled' };
492
- }
493
- }
491
+ const hostAccessResult = await requireHost(params, host);
492
+ if (hostAccessResult.type !== 'ok') {
493
+ return hostAccessResult;
494
494
  }
495
495
  const emit = async (event: WebviewEvent) => {
496
496
  this.omu.send(DASHBOARD_WEBVIEW_EVENT_PACKET, {
@@ -15,8 +15,8 @@ export interface DashboardHandler {
15
15
  handleOpenApp(app: App): Promise<void>;
16
16
  handleDragDropRequest(request: DragDropRequestDashboard): Promise<boolean>;
17
17
  handleDragDropReadRequest(request: DragDropReadRequestDashboard): Promise<DragDropReadResponse>;
18
+ handleHostRequest(request: HostRequest, params: InvokedParams): Promise<PromptResult>;
18
19
  getCookies(request: GetCookiesRequest): Promise<UserResponse<Cookie[]>>;
19
- hostRequested(request: HostRequest, params: InvokedParams): Promise<UserResponse>;
20
20
  createWebview(request: WebviewRequest, params: InvokedParams, emit: (event: WebviewEvent) => Promise<void>): Promise<Identifier>;
21
21
  getWebview(request: WebviewPacket, params: InvokedParams): Promise<Identifier | undefined>;
22
22
  closeWebview(request: WebviewPacket, params: InvokedParams): Promise<Identifier | undefined>;
@@ -164,51 +164,137 @@ class RegistryImpl<T> implements Registry<T> {
164
164
  }
165
165
 
166
166
  public compatSvelte(): Writable<T> {
167
- let ready = false;
168
- let value: T = this.value;
167
+ let isReady = false;
168
+ const context = {
169
+ changed: false,
170
+ markChanged: () => {
171
+ context.changed = true;
172
+ this.#set(this.value);
173
+ handle(this.value);
174
+ },
175
+ };
169
176
  const listeners = new Set<(value: T) => void>();
170
- this.listen((newValue) => {
171
- ready = true;
172
- value = newValue;
173
- listeners.forEach((run) => {
174
- run(value);
175
- });
176
- });
177
+
178
+ const handle = (newValue: T) => {
179
+ isReady = true;
180
+ emit(newValue);
181
+ };
182
+
183
+ const unsubscribe = this.listen(handle);
184
+
185
+ const emit = (value: T) => {
186
+ this.value = value;
187
+ const proxied = proxy(value, context);
188
+ listeners.forEach(listener => listener(proxied));
189
+ };
190
+
177
191
  return {
178
192
  set: (value: T) => {
179
- if (!ready) {
193
+ if (!isReady) {
180
194
  throw new Error(`Registry ${this.type.id.key()} is not ready`);
181
195
  }
182
- this.set(value);
196
+ const proxied = value?.[PROXIED_SYMBOL];
197
+ if (proxied && !context.changed) return;
198
+ this.#set(value);
199
+ emit(value);
200
+ context.changed = false;
183
201
  },
184
- subscribe: (run) => {
202
+ subscribe: (run: (value: T) => void) => {
185
203
  listeners.add(run);
186
- run(value);
204
+ run(proxy(this.value, context));
205
+
187
206
  return () => {
188
207
  listeners.delete(run);
208
+ if (listeners.size === 0) {
209
+ unsubscribe?.();
210
+ }
189
211
  };
190
212
  },
191
- update: (fn) => {
192
- if (!ready) {
213
+ update: (fn: (value: T) => T) => {
214
+ if (!isReady) {
193
215
  throw new Error(`Registry ${this.type.id.key()} is not ready`);
194
216
  }
195
217
  this.update(fn);
196
218
  },
197
- wait: () => {
198
- return new Promise<T>((resolve) => {
199
- if (ready) {
200
- resolve(value);
201
- } else {
202
- listeners.add(() => {
219
+ wait: (): Promise<T> => {
220
+ return isReady
221
+ ? Promise.resolve(this.value)
222
+ : new Promise(resolve => {
223
+ const unsubscribe = this.listen((value: T) => {
224
+ unsubscribe?.();
203
225
  resolve(value);
204
226
  });
205
- }
206
- });
227
+ });
207
228
  },
208
229
  };
209
230
  }
210
231
  }
211
232
 
233
+ const PROXIED_SYMBOL = Symbol('ProxiedRegistry');
234
+
235
+ function deepEqual(objA, objB) {
236
+ if (objA === objB) return true; // Check for referential equality and primitive values
237
+
238
+ if (
239
+ typeof objA !== 'object' ||
240
+ typeof objB !== 'object' ||
241
+ objA === null ||
242
+ objB === null
243
+ ) {
244
+ return false;
245
+ }
246
+
247
+ const keysA = Object.keys(objA);
248
+ const keysB = Object.keys(objB);
249
+
250
+ if (keysA.length !== keysB.length) return false; // Different number of properties
251
+
252
+ for (const key of keysA) {
253
+ if (!keysB.includes(key) || !deepEqual(objA[key], objB[key])) {
254
+ return false; // Property missing or values are not deeply equal
255
+ }
256
+ }
257
+
258
+ return true; // All properties and their values are deeply equal
259
+ }
260
+
261
+ type ProxyContext = {
262
+ changed: boolean;
263
+ markChanged: () => void;
264
+ };
265
+
266
+ function proxy<T>(
267
+ value: T,
268
+ context: ProxyContext,
269
+ ) {
270
+ if (typeof value !== 'object' || value === null) {
271
+ return value;
272
+ }
273
+ if (PROXIED_SYMBOL in value) {
274
+ return value;
275
+ }
276
+ let changed = false;
277
+ return new Proxy(value, {
278
+ set(target, prop, value) {
279
+ changed = !deepEqual(target[prop], value);
280
+ if (!changed) return true;
281
+ target[prop] = value;
282
+ context.markChanged();
283
+ return true;
284
+ },
285
+ get(target, prop) {
286
+ if (prop === PROXIED_SYMBOL) {
287
+ return value;
288
+ }
289
+ return proxy(target[prop], context);
290
+ },
291
+ has(target, p) {
292
+ if (p === PROXIED_SYMBOL) return true;
293
+ return p in target;
294
+ },
295
+ });
296
+ }
297
+
212
298
  export const REGISTRY_EXTENSION_TYPE: ExtensionType<RegistryExtension> = new ExtensionType(
213
299
  'registry',
214
300
  (omu: Omu) => new RegistryExtension(omu),
@@ -314,4 +314,9 @@ export class Network {
314
314
  this.status = status;
315
315
  await this.event.status.emit(status);
316
316
  }
317
+
318
+ public close(): void {
319
+ this.setStatus({ type: 'disconnected' });
320
+ this.attempt = 0;
321
+ }
317
322
  }
package/src/omu.ts CHANGED
@@ -132,6 +132,7 @@ export class Omu {
132
132
  public stop(): void {
133
133
  this.running = false;
134
134
  this.ready = false;
135
+ this.network.close();
135
136
  this.event.stopped.emit();
136
137
  }
137
138
 
@@ -257,6 +257,14 @@ export class ByteWriter {
257
257
  this.finished = true;
258
258
  return new Uint8Array(this.buffer, 0, this.offset);
259
259
  }
260
+
261
+ public toUint8Array(): Uint8Array {
262
+ return new Uint8Array(this.buffer, 0, this.offset);
263
+ }
264
+
265
+ public toArrayBuffer(): ArrayBuffer {
266
+ return this.buffer.slice(0, this.offset);
267
+ }
260
268
  }
261
269
 
262
270
  export class ByteReader {
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.9.42';
1
+ export const VERSION = '0.9.47';
2
2
  export const VERSION_MINOR = '0.9.0';
@@ -1,6 +0,0 @@
1
- export interface Address {
2
- host: string;
3
- port: number;
4
- secure: boolean;
5
- hash?: string;
6
- }
@@ -1,25 +0,0 @@
1
- import { Identifier, IntoId } from "../../identifier";
2
- import { Omu } from "../../omu";
3
- import { ExtensionType } from "../extension.js";
4
- export declare const ASSET_EXTENSION_TYPE: ExtensionType<AssetExtension>;
5
- export type Asset = {
6
- id: Identifier;
7
- buffer: Uint8Array;
8
- };
9
- export declare const ASSET_PERMISSION_ID: Identifier;
10
- export declare class AssetExtension {
11
- private readonly omu;
12
- readonly type: ExtensionType<AssetExtension>;
13
- private assetToken;
14
- constructor(omu: Omu);
15
- upload(identifier: IntoId, buffer: Uint8Array): Promise<Identifier>;
16
- uploadMany(...files: Asset[]): Promise<Identifier[]>;
17
- download(identifier: IntoId): Promise<Asset>;
18
- downloadMany(...identifiers: IntoId[]): Promise<Asset[]>;
19
- delete(identifier: IntoId): Promise<void>;
20
- private requestGenerateAssetToken;
21
- url(id: IntoId, options?: {
22
- cache?: "no-cache";
23
- }): string;
24
- proxy(url: string): string;
25
- }
@@ -1,2 +0,0 @@
1
- export { ASSET_PERMISSION_ID } from "./extension";
2
- export type { Asset } from "./extension";
@@ -1,181 +0,0 @@
1
- import { App, AppJson } from "../../app.js";
2
- import { Identifier } from "../../identifier";
3
- import { Omu } from "../../omu.js";
4
- import { PromiseResult } from "../../result.js";
5
- import { ExtensionType } from "../extension.js";
6
- import { PermissionTypeJson } from "../permission/permission.js";
7
- import { PackageInfo } from "../plugin/package-info.js";
8
- import { Registry } from "../registry/registry.js";
9
- import { AppIndexRegistryMeta } from "../server/extension.js";
10
- import type { Table } from "../table/table.js";
11
- import type { DashboardHandler } from "./handler.js";
12
- import { AppInstallResponse, DragDrop, DragDropReadResponse, DragEnter, DragLeave, DragOver, FileDragPacket } from "./packets.js";
13
- export declare const DASHBOARD_EXTENSION_TYPE: ExtensionType<DashboardExtension>;
14
- export declare const DASHBOARD_SET_PERMISSION_ID: Identifier;
15
- export declare const DASHBOARD_OPEN_APP_PERMISSION_ID: Identifier;
16
- export declare const DASHOBARD_APP_READ_PERMISSION_ID: Identifier;
17
- export declare const DASHOBARD_APP_EDIT_PERMISSION_ID: Identifier;
18
- export declare const DASHBOARD_APP_INSTALL_PERMISSION_ID: Identifier;
19
- export declare const DAShBOARD_DRAG_DROP_PERMISSION_ID: Identifier;
20
- type DragDropHandler = {
21
- onEnter(fn: (event: DragEnter) => unknown): void;
22
- onOver(fn: (event: DragOver) => unknown): void;
23
- onDrop(fn: (event: DragDrop) => unknown): void;
24
- onLeave(fn: (event: DragLeave) => unknown): void;
25
- read(id: string): Promise<DragDropReadResponse>;
26
- };
27
- export type Cookie = {
28
- name: string;
29
- value: string;
30
- };
31
- export type WebviewRequest = {
32
- url: string;
33
- script?: string;
34
- };
35
- export type WebviewPacket = {
36
- id: string;
37
- };
38
- export type UserResponse<T = undefined> = {
39
- type: "ok";
40
- value: T;
41
- } | {
42
- type: "blocked";
43
- } | {
44
- type: "cancelled";
45
- };
46
- export type UserError = Exclude<UserResponse, {
47
- type: "ok";
48
- }>;
49
- export type WebviewResponse = UserResponse<WebviewPacket>;
50
- export declare const DASHBOARD_WEBVIEW_PERMISSION_ID: Identifier;
51
- export type HostRequest = {
52
- host: string;
53
- };
54
- export type GetCookiesRequest = {
55
- url: string;
56
- };
57
- export type WebviewEvent = {
58
- type: "closed";
59
- } | {
60
- type: "resize";
61
- dimentions: {
62
- x: number;
63
- y: number;
64
- };
65
- } | {
66
- type: "cookie";
67
- cookies: Cookie[];
68
- };
69
- export type WebviewEventListeners = { [K in WebviewEvent["type"]]? : Array<(event: Extract<WebviewEvent, {
70
- type: K;
71
- }>) => void> };
72
- export type WebviewEventPacket = {
73
- id: Identifier;
74
- target: Identifier;
75
- event: WebviewEvent;
76
- };
77
- export type WebviewHandle = {
78
- readonly id: Identifier;
79
- readonly url: string;
80
- getCookies(): PromiseResult<Cookie[], UserError>;
81
- on<T extends WebviewEvent["type"]>(key: T, callback: (event: Extract<WebviewEvent, {
82
- type: T;
83
- }>) => void): void;
84
- close(): Promise<void>;
85
- join(): Promise<void>;
86
- };
87
- export type WebviewEventEmit = <T extends WebviewEvent["type"]>(event: Extract<WebviewEvent, {
88
- type: T;
89
- }>) => void;
90
- type AllowedHost = {
91
- id: string;
92
- hosts: string[];
93
- };
94
- export declare const DASHBOARD_SPEECH_RECOGNITION_PERMISSION_ID: Identifier;
95
- export type TranscriptSegment = {
96
- confidence: number;
97
- transcript: string;
98
- };
99
- export type TranscriptStatus = {
100
- type: "idle";
101
- } | {
102
- type: "result";
103
- timestamp: number;
104
- segments: TranscriptSegment[];
105
- } | {
106
- type: "final";
107
- timestamp: number;
108
- segments: TranscriptSegment[];
109
- } | {
110
- type: "audio_started";
111
- timestamp: number;
112
- } | {
113
- type: "audio_ended";
114
- timestamp: number;
115
- };
116
- export type SpeechRecognitionStart = {
117
- type: "start";
118
- };
119
- interface PromptRequestBase<T extends string> {
120
- kind: T;
121
- id: string;
122
- }
123
- export interface PromptRequestAppPermissions extends PromptRequestBase<"app/permissions"> {
124
- app: AppJson;
125
- permissions: PermissionTypeJson[];
126
- }
127
- export interface PromptRequestAppPlugins extends PromptRequestBase<"app/plugins"> {
128
- app: AppJson;
129
- packages: PackageInfo[];
130
- }
131
- export interface PromptRequestAppInstall extends PromptRequestBase<"app/install"> {
132
- app: AppJson;
133
- dependencies: Record<string, AppJson>;
134
- }
135
- export interface PromptRequestAppUpdate extends PromptRequestBase<"app/update"> {
136
- old_app: AppJson;
137
- new_app: AppJson;
138
- dependencies: Record<string, AppJson>;
139
- }
140
- export interface PromptRequestIndexInstall extends PromptRequestBase<"index/install"> {
141
- index_url: string;
142
- meta?: AppIndexRegistryMeta;
143
- }
144
- export interface PortProcess {
145
- port: number;
146
- name: string;
147
- exe: string;
148
- }
149
- export interface PromptRequestHttpPort extends PromptRequestBase<"http/port"> {
150
- app: AppJson;
151
- processes: PortProcess[];
152
- }
153
- export type PromptRequest = (PromptRequestAppPermissions | PromptRequestAppPlugins | PromptRequestAppInstall | PromptRequestAppUpdate | PromptRequestIndexInstall | PromptRequestHttpPort);
154
- export type PromptResult = "accept" | "deny" | "block";
155
- export declare class DashboardExtension {
156
- private readonly omu;
157
- readonly type: ExtensionType<DashboardExtension>;
158
- private dashboard;
159
- private dragDropHandler;
160
- private dragDropListeners;
161
- readonly allowedHosts: Table<AllowedHost>;
162
- readonly speechRecognition: Registry<TranscriptStatus>;
163
- private readonly webviewHandles;
164
- constructor(omu: Omu);
165
- private executeRequestForDashboard;
166
- private handlePromptRequest;
167
- private handleOpenApp;
168
- private handleDragDropRequest;
169
- private handleDragDropReadRequest;
170
- private getDashboard;
171
- set(dashboard: DashboardHandler): void;
172
- requestWebview(options: WebviewRequest): PromiseResult<WebviewHandle, UserError>;
173
- getCookies(options: GetCookiesRequest): PromiseResult<Cookie[], UserError>;
174
- openApp(app: App): Promise<void>;
175
- installApp(app: App): Promise<AppInstallResponse>;
176
- clearBlockedPrompts(): Promise<null>;
177
- requestDragDrop(): Promise<DragDropHandler>;
178
- notifyDropDragState(packet: FileDragPacket): Promise<void>;
179
- requestSpeechRecognition(): PromiseResult<Registry<TranscriptStatus>, UserError>;
180
- }
181
- export {};
@@ -1,22 +0,0 @@
1
- import type { App } from "../../app.js";
2
- import { Identifier } from "../../identifier";
3
- import { InvokedParams } from "../endpoint/packets.js";
4
- import { Cookie, GetCookiesRequest, HostRequest, PromptRequestAppInstall, PromptRequestAppPermissions, PromptRequestAppPlugins, PromptRequestAppUpdate, PromptRequestHttpPort, PromptRequestIndexInstall, PromptResult, SpeechRecognitionStart, UserResponse, WebviewEvent, WebviewPacket, WebviewRequest } from "./extension.js";
5
- import type { DragDropReadRequestDashboard, DragDropReadResponse, DragDropRequestDashboard } from "./packets.js";
6
- export interface DashboardHandler {
7
- handlePermissionRequest(request: PromptRequestAppPermissions): Promise<PromptResult>;
8
- handlePluginRequest(request: PromptRequestAppPlugins): Promise<PromptResult>;
9
- handleInstallApp(request: PromptRequestAppInstall): Promise<PromptResult>;
10
- handleUpdateApp(request: PromptRequestAppUpdate): Promise<PromptResult>;
11
- handleIndexInstall(request: PromptRequestIndexInstall): Promise<PromptResult>;
12
- handleHttpPortRequest(request: PromptRequestHttpPort): Promise<PromptResult>;
13
- handleOpenApp(app: App): Promise<void>;
14
- handleDragDropRequest(request: DragDropRequestDashboard): Promise<boolean>;
15
- handleDragDropReadRequest(request: DragDropReadRequestDashboard): Promise<DragDropReadResponse>;
16
- getCookies(request: GetCookiesRequest): Promise<UserResponse<Cookie[]>>;
17
- hostRequested(request: HostRequest, params: InvokedParams): Promise<UserResponse>;
18
- createWebview(request: WebviewRequest, params: InvokedParams, emit: (event: WebviewEvent) => Promise<void>): Promise<Identifier>;
19
- getWebview(request: WebviewPacket, params: InvokedParams): Promise<Identifier | undefined>;
20
- closeWebview(request: WebviewPacket, params: InvokedParams): Promise<Identifier | undefined>;
21
- speechRecognitionStart(request: SpeechRecognitionStart, params: InvokedParams): Promise<UserResponse<undefined>>;
22
- }
@@ -1,3 +0,0 @@
1
- export { Cookie, DASHBOARD_APP_INSTALL_PERMISSION_ID, DAShBOARD_DRAG_DROP_PERMISSION_ID, DASHBOARD_OPEN_APP_PERMISSION_ID, DASHBOARD_SET_PERMISSION_ID, DASHBOARD_SPEECH_RECOGNITION_PERMISSION_ID, DASHBOARD_WEBVIEW_PERMISSION_ID, DASHOBARD_APP_EDIT_PERMISSION_ID, DASHOBARD_APP_READ_PERMISSION_ID, GetCookiesRequest, HostRequest, UserResponse, WebviewPacket, WebviewRequest, type PortProcess, type PromptRequest, type PromptRequestAppInstall, type PromptRequestAppPermissions, type PromptRequestAppPlugins, type PromptRequestAppUpdate, type PromptRequestHttpPort, type PromptRequestIndexInstall, type PromptResult, type SpeechRecognitionStart, type TranscriptSegment, type TranscriptStatus, type WebviewEvent } from "./extension.js";
2
- export type { DashboardHandler } from "./handler";
3
- export { DragDropFile, DragDropReadRequestDashboard, DragDropReadResponse, DragDropRequestDashboard, FileData } from "./packets.js";