@mythryl/app-sdk 0.1.3 → 0.1.4

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
@@ -31,16 +31,17 @@ on the server. Call it from effects and event handlers, which run in the browser
31
31
  | `sdk.openPost(uri)` | Opens a post, by its `at://` URI, and minimises the app. |
32
32
  | `sdk.openTopic(slug)` | Opens a topic, by name without the slash, and minimises the app. |
33
33
  | `sdk.openUrl(url)` | Opens an `https` address in the browser once the person confirms. Rejects with `cancelled` if they decline. |
34
+ | `sdk.openStorePage(domain?)` | Opens an app's store page in the host and minimises this app. Without a domain, it is this app's own page. |
34
35
  | `sdk.openApp({ domain, url? })` | Opens another mini app and closes this one. `url` is where to start, on that app's domain. |
35
36
  | `sdk.compose({ text?, embedUrl? })` | Opens the composer with a draft. `{ uri }` if the person posted, `{}` if they did not. |
37
+ | `sdk.install()` | Asks the person to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. |
36
38
  | `sdk.follow(did)` | Asks the person to follow an account. Rejects with `cancelled` if they decline. |
37
- | `sdk.share()` | Opens the share sheet with a link to the app. |
38
39
  | `sdk.on(event, listener)` | Subscribes to a host event. Returns a function that removes the listener. |
39
40
  | `sdk.dispose()` | Removes listeners and rejects pending calls with `cancelled`. |
40
41
 
41
- `openProfile`, `openPost`, `openTopic`, `openUrl` and `openApp` need the `navigation` capability. `compose`, `follow`
42
- and `share` each have a capability of the same name. Older hosts have none of them: check `sdk.getCapabilities()`
43
- first, or handle the `unsupported` rejection. Anything that writes (`compose`, `follow`) is confirmed by the person. A target the host cannot open rejects with `unavailable`.
42
+ `openProfile`, `openPost`, `openTopic`, `openUrl` and `openApp` need the `navigation` capability. `compose`, `follow` and `install`
43
+ each have a capability of the same name. Older hosts have none of them: check `sdk.getCapabilities()`
44
+ first, or handle the `unsupported` rejection. Anything that writes (`compose`, `follow`, `install`) is confirmed by the person. A target the host cannot open rejects with `unavailable`.
44
45
 
45
46
  ### Events
46
47
 
package/dist/lazy.js CHANGED
@@ -15,10 +15,11 @@ export const lazySdk = (create) => {
15
15
  openPost: (uri) => sdk().openPost(uri),
16
16
  openTopic: (slug) => sdk().openTopic(slug),
17
17
  openUrl: (url) => sdk().openUrl(url),
18
+ openStorePage: (domain) => sdk().openStorePage(domain),
18
19
  openApp: (options) => sdk().openApp(options),
19
20
  compose: (options) => sdk().compose(options),
20
21
  follow: (did) => sdk().follow(did),
21
- share: () => sdk().share(),
22
+ install: () => sdk().install(),
22
23
  on: (event, listener) => sdk().on(event, listener),
23
24
  dispose: () => {
24
25
  current?.dispose();
package/dist/sdk.d.ts CHANGED
@@ -33,6 +33,8 @@ export interface Sdk {
33
33
  openTopic: (slug: string) => Promise<void>;
34
34
  /** Opens an `https` address in the browser after the person confirms. Rejects with `cancelled` if they decline. */
35
35
  openUrl: (url: string) => Promise<void>;
36
+ /** Opens an app's store page in the host and minimises the calling app. `domain` names the app; left out, it is this app's own page. */
37
+ openStorePage: (domain?: string) => Promise<void>;
36
38
  /** Opens another mini app by its domain and closes this one. `url` is where in that app to start, on its own domain. */
37
39
  openApp: (options: {
38
40
  domain: string;
@@ -45,10 +47,10 @@ export interface Sdk {
45
47
  }) => Promise<{
46
48
  uri?: string;
47
49
  }>;
50
+ /** Asks the person to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. Needs the `install` capability. */
51
+ install: () => Promise<void>;
48
52
  /** Asks the person to follow an account, by DID. Rejects with `cancelled` if they decline. Needs the `follow` capability. */
49
53
  follow: (did: string) => Promise<void>;
50
- /** Opens the share sheet with a link to the app. Needs the `share` capability. */
51
- share: () => Promise<void>;
52
54
  on: <E extends EventName>(event: E, listener: (data: Events[E]) => void) => () => void;
53
55
  /** Removes listeners and rejects pending calls with `cancelled`. */
54
56
  dispose: () => void;
package/dist/sdk.js CHANGED
@@ -29,10 +29,11 @@ export const createSdk = (transport = windowTransport()) => {
29
29
  openPost: (uri) => call("openPost", { uri }),
30
30
  openTopic: (slug) => call("openTopic", { slug }),
31
31
  openUrl: (url) => call("openUrl", { url }),
32
+ openStorePage: (domain) => call("openStorePage", domain === undefined ? {} : { domain }),
32
33
  openApp: (options) => call("openApp", options),
33
34
  compose: (options) => call("compose", options ?? {}),
34
35
  follow: (did) => call("follow", { did }),
35
- share: () => call("share", undefined),
36
+ install: () => call("install", undefined),
36
37
  // The host sends events only after the handshake, so subscribing starts it.
37
38
  on: (event, listener) => {
38
39
  connect().catch(() => undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythryl/app-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The browser SDK for Mythryl mini apps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@mythryl/protocol": "0.1.3"
29
+ "@mythryl/protocol": "0.1.4"
30
30
  },
31
31
  "devDependencies": {
32
32
  "typescript": "~6.0.3",