@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.
package/README.md CHANGED
@@ -83,6 +83,40 @@ so the DSM window's ctx works as it is.
83
83
  <AppShell v-model="page" :ctx="ctx" :locale="ctx.locale" :pages="pages" sidebar-storage-key="HelloGo" />
84
84
  ```
85
85
 
86
+ ## Launch links
87
+
88
+ A DSM desktop link opens the App's window on one of its pages:
89
+ `https://<nas>:5001/?launchApp=SYNO.SDS.<package>.Instance&launchParam=<params>`,
90
+ or `SYNO.SDS.AppLaunch('SYNO.SDS.<package>.Instance', {route: '/a/notes/42'})`
91
+ from DSM's own JavaScript. The DSM window passes the
92
+ App's string values from the launch that opened it as `ctx.launchParams`, and
93
+ those of each later launch of the open window to `ctx.onLaunch(fn)`. The
94
+ values are untrusted text.
95
+
96
+ `route` is the convention the helpers read: the App route a portal link puts
97
+ after its `#`. `launchRoute(params)` returns it when it is a path from the App
98
+ root (one leading `/`, no backslash or control character, at most 2048
99
+ characters), else `undefined`. `followLaunchRoute(ctx, navigate)` navigates to
100
+ the opening launch's route at once and to each later one's, and returns a
101
+ function that stops; outside DSM it follows nothing. Map both sources onto the
102
+ same router: a portal or full-page launch reads its own `#` as before.
103
+
104
+ ```ts
105
+ // Vue Router with createWebHashHistory: #/a/notes/42 in a portal link, route=/a/notes/42 from DSM.
106
+ const stop = followLaunchRoute(ctx, route => { void router.replace(route) })
107
+ ```
108
+
109
+ `dsmLaunchURL(origin, packageId, params)` builds the desktop link, encoding each
110
+ key and value the way DSM decodes them:
111
+
112
+ ```ts
113
+ dsmLaunchURL('https://nas.example:5001', 'HelloGo', {route: '/a/notes/42'})
114
+ // https://nas.example:5001/?launchApp=SYNO.SDS.HelloGo.Instance&launchParam=route%3D%252Fa%252Fnotes%252F42
115
+ ```
116
+
117
+ DSM replays the opening launch's values when it restores the desktop's windows
118
+ at sign-in, so a restored window opens on the same page.
119
+
86
120
  ## Outside DSM
87
121
 
88
122
  A development page, a preview or a test owns the browser page and has no DSM