@omujs/omu 0.9.41 → 0.9.43

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 (47) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/dts/api/asset/extension.d.ts +1 -1
  3. package/dist/dts/api/dashboard/extension.d.ts +13 -31
  4. package/dist/dts/api/http/index.d.ts +2 -1
  5. package/dist/dts/api/registry/registry.d.ts +1 -1
  6. package/dist/dts/api/session/extension.d.ts +5 -4
  7. package/dist/dts/index.d.ts +1 -1
  8. package/dist/dts/network/network.d.ts +2 -2
  9. package/dist/dts/omu.d.ts +3 -3
  10. package/dist/dts/result.d.ts +41 -0
  11. package/dist/dts/token.d.ts +4 -5
  12. package/dist/dts/version.d.ts +1 -1
  13. package/dist/esm/api/asset/extension.js +7 -7
  14. package/dist/esm/api/asset/index.js +7 -7
  15. package/dist/esm/api/dashboard/extension.js +145 -96
  16. package/dist/esm/api/dashboard/index.js +145 -95
  17. package/dist/esm/api/http/index.js +3 -2
  18. package/dist/esm/api/i18n/extension.js +5 -5
  19. package/dist/esm/api/i18n/index.js +5 -5
  20. package/dist/esm/api/registry/extension.js +5 -5
  21. package/dist/esm/api/registry/index.js +5 -5
  22. package/dist/esm/api/registry/registry.js +1 -1
  23. package/dist/esm/api/server/extension.js +5 -5
  24. package/dist/esm/api/server/index.js +5 -5
  25. package/dist/esm/api/session/extension.js +16 -12
  26. package/dist/esm/api/session/index.js +16 -12
  27. package/dist/esm/index.js +171 -120
  28. package/dist/esm/network/index.js +3 -3
  29. package/dist/esm/network/network.js +3 -3
  30. package/dist/esm/omu.js +170 -119
  31. package/dist/esm/result.js +68 -0
  32. package/dist/esm/token.js +7 -10
  33. package/dist/esm/version.js +3 -3
  34. package/package.json +1 -1
  35. package/src/api/asset/extension.ts +6 -6
  36. package/src/api/dashboard/extension.ts +116 -114
  37. package/src/api/http/index.ts +2 -1
  38. package/src/api/registry/extension.ts +4 -4
  39. package/src/api/registry/registry.ts +1 -1
  40. package/src/api/session/extension.ts +15 -10
  41. package/src/index.ts +1 -1
  42. package/src/network/network.ts +2 -2
  43. package/src/omu.ts +4 -4
  44. package/src/result.ts +78 -0
  45. package/src/token.ts +5 -9
  46. package/src/version.ts +1 -1
  47. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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.43 (2025-11-22)
7
+
8
+ **Note:** Version bump only for package @omujs/omu
9
+
10
+
11
+
12
+
13
+
14
+ ## 0.9.42 (2025-11-20)
15
+
16
+ **Note:** Version bump only for package @omujs/omu
17
+
18
+
19
+
20
+
21
+
6
22
  ## 0.9.41 (2025-11-19)
7
23
 
8
24
  **Note:** Version bump only for package @omujs/omu
@@ -3,7 +3,7 @@ import { Omu } from "../../omu";
3
3
  import { ExtensionType } from "../extension.js";
4
4
  export declare const ASSET_EXTENSION_TYPE: ExtensionType<AssetExtension>;
5
5
  export type Asset = {
6
- identifier: Identifier;
6
+ id: Identifier;
7
7
  buffer: Uint8Array;
8
8
  };
9
9
  export declare const ASSET_PERMISSION_ID: Identifier;
@@ -1,6 +1,7 @@
1
1
  import { App, AppJson } from "../../app.js";
2
2
  import { Identifier } from "../../identifier";
3
3
  import { Omu } from "../../omu.js";
4
+ import { PromiseResult } from "../../result.js";
4
5
  import { ExtensionType } from "../extension.js";
5
6
  import { PermissionTypeJson } from "../permission/permission.js";
6
7
  import { PackageInfo } from "../plugin/package-info.js";
@@ -29,10 +30,10 @@ export type Cookie = {
29
30
  };
30
31
  export type WebviewRequest = {
31
32
  url: string;
32
- script: string;
33
+ script?: string;
33
34
  };
34
35
  export type WebviewPacket = {
35
- id: Identifier;
36
+ id: string;
36
37
  };
37
38
  export type UserResponse<T = undefined> = {
38
39
  type: "ok";
@@ -42,26 +43,10 @@ export type UserResponse<T = undefined> = {
42
43
  } | {
43
44
  type: "cancelled";
44
45
  };
45
- export declare class UserResult<T> {
46
- result: {
47
- type: "ok";
48
- value: T;
49
- } | {
50
- type: "blocked";
51
- } | {
52
- type: "cancelled";
53
- };
54
- constructor(result: {
55
- type: "ok";
56
- value: T;
57
- } | {
58
- type: "blocked";
59
- } | {
60
- type: "cancelled";
61
- });
62
- unwrap(): T;
63
- }
64
- export type WebviewResponse = UserResponse & WebviewPacket;
46
+ export type UserError = Exclude<UserResponse, {
47
+ type: "ok";
48
+ }>;
49
+ export type WebviewResponse = UserResponse<WebviewPacket>;
65
50
  export declare const DASHBOARD_WEBVIEW_PERMISSION_ID: Identifier;
66
51
  export type HostRequest = {
67
52
  host: string;
@@ -92,11 +77,11 @@ export type WebviewEventPacket = {
92
77
  export type WebviewHandle = {
93
78
  readonly id: Identifier;
94
79
  readonly url: string;
95
- getCookies(): Promise<Cookie[]>;
96
- close(): void;
80
+ getCookies(): PromiseResult<Cookie[], UserError>;
97
81
  on<T extends WebviewEvent["type"]>(key: T, callback: (event: Extract<WebviewEvent, {
98
82
  type: T;
99
83
  }>) => void): void;
84
+ close(): Promise<void>;
100
85
  join(): Promise<void>;
101
86
  };
102
87
  export type WebviewEventEmit = <T extends WebviewEvent["type"]>(event: Extract<WebviewEvent, {
@@ -184,16 +169,13 @@ export declare class DashboardExtension {
184
169
  private handleDragDropReadRequest;
185
170
  private getDashboard;
186
171
  set(dashboard: DashboardHandler): void;
187
- requestHost(options: {
188
- host: string;
189
- }): Promise<UserResponse>;
190
- requestWebview(options: WebviewRequest): Promise<UserResult<WebviewHandle>>;
191
- getCookies(options: GetCookiesRequest): Promise<UserResult<Cookie[]>>;
172
+ requestWebview(options: WebviewRequest): PromiseResult<WebviewHandle, UserError>;
173
+ getCookies(options: GetCookiesRequest): PromiseResult<Cookie[], UserError>;
192
174
  openApp(app: App): Promise<void>;
193
175
  installApp(app: App): Promise<AppInstallResponse>;
194
176
  clearBlockedPrompts(): Promise<null>;
195
- requireDragDrop(): Promise<DragDropHandler>;
177
+ requestDragDrop(): Promise<DragDropHandler>;
196
178
  notifyDropDragState(packet: FileDragPacket): Promise<void>;
197
- speechRecognitionStart(): Promise<void>;
179
+ requestSpeechRecognition(): PromiseResult<Registry<TranscriptStatus>, UserError>;
198
180
  }
199
181
  export {};
@@ -1 +1,2 @@
1
- export { HTTP_REQUEST_PERMISSION_ID, OmuWS, type WSMsg } from "./extension";
1
+ export { HTTP_REQUEST_PERMISSION_ID } from "./extension";
2
+ export { OmuWS, type WSMsg } from "./websocket";
@@ -39,7 +39,7 @@ export interface Registry<T> {
39
39
  get(): Promise<T>;
40
40
  set(value: T): Promise<void>;
41
41
  update(fn: (value: T) => PromiseLike<T> | T): Promise<T>;
42
- modify(fn: (value: T) => PromiseLike<T> | T): Promise<T>;
42
+ modify(fn: (value: T) => PromiseLike<void> | void): Promise<T>;
43
43
  listen(fn: (value: T) => void): Unlisten;
44
44
  compatSvelte(): Writable<T>;
45
45
  }
@@ -1,6 +1,7 @@
1
1
  import { App } from "../../app";
2
2
  import { Identifier, IntoId } from "../../identifier";
3
3
  import { Omu } from "../../omu";
4
+ import { SessionParam } from "../../token";
4
5
  import { Extension, ExtensionType } from "../extension";
5
6
  import { SessionObserver } from "../server/extension";
6
7
  import { Table } from "../table";
@@ -31,9 +32,9 @@ export declare class SessionExtension implements Extension {
31
32
  private readonly requiredApps;
32
33
  constructor(omu: Omu);
33
34
  has(id: IntoId): Promise<boolean>;
34
- observe(appId: IntoId, { onConnect, onDisconnect }: {
35
- onConnect(app: App): void;
36
- onDisconnect(app: App): void;
35
+ observe(appId: IntoId, options?: {
36
+ onConnect?(app: App): void;
37
+ onDisconnect?(app: App): void;
37
38
  }): SessionObserver;
38
39
  private handleSessionConnect;
39
40
  private handleSessionDisconnect;
@@ -47,5 +48,5 @@ export declare class SessionExtension implements Extension {
47
48
  generateToken(options: {
48
49
  app: App;
49
50
  permissions?: IntoId[];
50
- }): Promise<string>;
51
+ }): Promise<SessionParam>;
51
52
  }
@@ -6,7 +6,7 @@ export * as network from "./network";
6
6
  export { Omu } from "./omu.js";
7
7
  export { Serializer } from "./serialize";
8
8
  export type { Serializable } from "./serialize";
9
- export { BrowserTokenProvider, type SessionParam, type TokenProvider } from "./token";
9
+ export { BrowserSession, type SessionParam, type SessioTokenProvider as TokenProvider } from "./token";
10
10
  import { Identifier } from "./identifier";
11
11
  export declare const OmuPermissions: {
12
12
  readonly ASSET_PERMISSION_ID: Identifier;
@@ -2,7 +2,7 @@ import type { Address } from "../address.js";
2
2
  import { DisconnectReason } from "../errors.js";
3
3
  import { EventEmitter } from "../event";
4
4
  import { Omu } from "../omu.js";
5
- import type { TokenProvider } from "../token.js";
5
+ import type { SessioTokenProvider } from "../token.js";
6
6
  import type { Connection, Transport } from "./connection.js";
7
7
  import { AES } from "./encryption.js";
8
8
  import type { Packet, PacketType } from "./packet/packet.js";
@@ -40,7 +40,7 @@ export declare class Network {
40
40
  private listenTask;
41
41
  reason: DisconnectReason | undefined;
42
42
  private attempt;
43
- constructor(omu: Omu, address: Address, tokenProvider: TokenProvider, transport: Transport, connection?: Connection | undefined, aes?: AES | undefined);
43
+ constructor(omu: Omu, address: Address, tokenProvider: SessioTokenProvider, transport: Transport, connection?: Connection | undefined, aes?: AES | undefined);
44
44
  setConnection(connection: Connection): void;
45
45
  registerPacket(...packetTypes: PacketType<unknown>[]): void;
46
46
  addPacketHandler<T>(type: PacketType<T>, handler: (packet: T) => void): void;
package/dist/dts/omu.d.ts CHANGED
@@ -19,7 +19,7 @@ import type { Address, Connection } from "./network";
19
19
  import { Network } from "./network";
20
20
  import { Transport } from "./network/connection.js";
21
21
  import type { PacketType } from "./network/packet/packet.js";
22
- import { type TokenProvider } from "./token.js";
22
+ import { type SessioTokenProvider } from "./token.js";
23
23
  export type ClientEvents = {
24
24
  started: EventEmitter<[]>;
25
25
  stopped: EventEmitter<[]>;
@@ -30,7 +30,7 @@ export declare class Omu {
30
30
  ready: boolean;
31
31
  running: boolean;
32
32
  readonly event: ClientEvents;
33
- readonly token: TokenProvider;
33
+ readonly token: SessioTokenProvider;
34
34
  readonly address: Address;
35
35
  readonly sessions: SessionExtension;
36
36
  readonly network: Network;
@@ -49,7 +49,7 @@ export declare class Omu {
49
49
  readonly http: HttpExtension;
50
50
  constructor(app: App, options?: {
51
51
  address?: Address;
52
- token?: TokenProvider | string;
52
+ token?: SessioTokenProvider | string;
53
53
  transport?: Transport;
54
54
  connection?: Connection;
55
55
  });
@@ -0,0 +1,41 @@
1
+ export type Success<T> = {
2
+ data: T;
3
+ error: null;
4
+ };
5
+ export type Failure<E> = {
6
+ data: null;
7
+ error: E;
8
+ };
9
+ export type Result<
10
+ T,
11
+ E = Error
12
+ > = Success<T> | Failure<E>;
13
+ export declare function tryCatch<
14
+ T,
15
+ E = Error
16
+ >(promise: Promise<T>): Promise<Result<T, E>>;
17
+ export declare function success<T>(data: T): Result<T>;
18
+ export declare function failure<E>(error: E): Result<null, E>;
19
+ export declare class PromiseResult<
20
+ T,
21
+ E = Error
22
+ > implements Promise<T> {
23
+ private readonly promise;
24
+ private constructor();
25
+ static create<
26
+ T,
27
+ E = Error
28
+ >(): {
29
+ promise: PromiseResult<T, E>;
30
+ resolve: (value: T) => void;
31
+ reject: (error: E) => void;
32
+ };
33
+ then<
34
+ TResult1 = T,
35
+ TResult2 = never
36
+ >(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: E) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
37
+ catch<TResult = never>(onrejected?: ((reason: E) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
38
+ finally(onfinally?: (() => void) | null | undefined): Promise<T>;
39
+ [Symbol.toStringTag]: string;
40
+ toResult(): Promise<Result<T, E>>;
41
+ }
@@ -1,15 +1,14 @@
1
1
  import type { Address } from "./address.js";
2
2
  import type { App } from "./app.js";
3
- export interface TokenProvider {
3
+ export interface SessioTokenProvider {
4
4
  get(serverAddress: Address, app: App): Promise<string | undefined>;
5
5
  }
6
6
  export type SessionParam = {
7
7
  address: Address;
8
8
  token: string;
9
9
  };
10
- export declare class BrowserTokenProvider implements TokenProvider {
11
- static readonly TOKEN_PARAM_KEY = "_omu_session";
12
- private getKey;
13
- get(address: Address, app: App): Promise<string | undefined>;
10
+ export declare class BrowserSession implements SessioTokenProvider {
11
+ static readonly PARAM_NAME = "_omu_session";
12
+ get(address: Address): Promise<string | undefined>;
14
13
  private parseParamSession;
15
14
  }
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.9.41";
1
+ export declare const VERSION = "0.9.43";
2
2
  export declare const VERSION_MINOR = "0.9.0";