@synopackageland/sdk 0.12.1 → 0.12.2

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.
@@ -96,6 +96,7 @@ export declare function clientTimeout(requestTimeout?: number): number;
96
96
  export interface CallOptions {
97
97
  signal?: AbortSignal;
98
98
  }
99
+ export type LaunchParams = Readonly<Record<string, string>>;
99
100
  export interface Context {
100
101
  requestTimeout?: number;
101
102
  authorization?: AuthorizationAccess;
@@ -115,6 +116,8 @@ export interface Context {
115
116
  portal?: PortalAccess;
116
117
  call<T = unknown>(method: string, params?: Record<string, unknown>, options?: CallOptions): Promise<T>;
117
118
  reopen(fn: () => void): () => void;
119
+ launchParams?: LaunchParams;
120
+ onLaunch?(fn: (params: LaunchParams) => void): () => void;
118
121
  locale: string;
119
122
  lang?: string;
120
123
  t?: (key: string, params?: Record<string, unknown>) => string;
@@ -1,6 +1,7 @@
1
1
  export type * from './context';
2
2
  export { DEFAULT_REQUEST_TIMEOUT, clientTimeout, isFullPage } from './context';
3
3
  export { createStandaloneHost, createStandaloneContext } from './standalone';
4
+ export { launchRoute, followLaunchRoute, dsmLaunchURL, MAX_LAUNCH_ROUTE } from './launch';
4
5
  export { createDsmSession } from './dsm/session.js';
5
6
  export type * from './delegate/long-running';
6
7
  export type * from './delegate/executor-setup';
@@ -0,0 +1,23 @@
1
+ import type { Context, LaunchParams } from './context';
2
+ /** The longest route launchRoute returns. */
3
+ export declare const MAX_LAUNCH_ROUTE = 2048;
4
+ /**
5
+ * The App route in launch params' `route`: a path from the App root, the part
6
+ * a portal link puts after its `#`, such as `/a/notes/42`. One leading `/`, no
7
+ * backslash or control character, at most MAX_LAUNCH_ROUTE characters; any
8
+ * other value gives undefined. Hand it to the App's own router only.
9
+ */
10
+ export declare function launchRoute(params?: LaunchParams): string | undefined;
11
+ /**
12
+ * Runs navigate with the route of the launch that opened the DSM window, then
13
+ * with that of each later launch of the open window. Returns a function that
14
+ * stops following. A context without launch support follows nothing.
15
+ */
16
+ export declare function followLaunchRoute(ctx: Partial<Pick<Context, 'launchParams' | 'onLaunch'>>, navigate: (route: string) => void): () => void;
17
+ /**
18
+ * A DSM desktop link that opens the package's window with params, as
19
+ * `<origin>/?launchApp=SYNO.SDS.<package>.Instance&launchParam=…`. DSM
20
+ * url-decodes launchParam, splits it at `&` and `=`, then url-decodes each
21
+ * key and value, so each is encoded twice here.
22
+ */
23
+ export declare function dsmLaunchURL(origin: string, packageId: string, params: LaunchParams): string;