1.2.15 • Published 2 years ago

@showell-labs/showell-web-app-client v1.2.15

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Showell Web App Client

This is a tool to make discussing with Showell app or API easier. Import it as regular package, initialize and start communicating!

Import

import WebAppClient from '@showell-labs/showell-web-app-client/lib';

Initialization

WebAppClient.init(
  plugins: RequestedServiceDefinitions,
  env: 'prod' | 'dev',
  channel: 'app' | 'api' | 'auto' = 'auto',
  credentials?: {
      username: string;
      authToken: string;
  }
)

Init returns a promise you can wait for, to ensure that it's ready before you start making any calls.

ParameterMeaningDefault
pluginsImport and include the plugins you want to use here. This is an object where keys are known plugin namesrequired
envIf working in production or developement moderequired
channelUsed to specify if client should try to communicate with App over the postMessage or with API over the Fetch. Auto means that client tries to check if known constants or globals are found that indicate it's being run within WebView of the appauto
credentialsIf you want to use API mode, you must provide credentials for client to fetch identity for youundefined

Plugins

List of supported plugins:

  • DownloadPlugin - Manage offline content, check download status, force downloading etc. App only.
  • FilePlugin - Get information about file(s) or folder(s). App & API.
  • IdentityPlugin - Manage Showell user. This plugin is always included. App & API.
  • SelectedPlugin - Manually use the selected feature of the app. App only.
  • SyncPlugin - Control how app syncs contents between local database and server. App only.
  • UiPlugin - Trigger specific UI actions like showing or hiding navbar. App only.

All plugins can be found from plugins folder. You must provide a set of plugins you plan on using when calling init.

import FilePlugin from '@showell-labs/showell-web-app-client/lib/plugins/FilePlugin';

// ...

WebAppClient.Client.init(
  plugins: { filePlugin: FilePlugin },
  // ...
)

If you don't really care about code splitting and you are feeling lazy, you can also do this:

import { ALL_PLUGINS } from '@showell-labs/showell-web-app-client/lib';

// ...

WebAppClient.Client.init(
  plugins: ALL_PLUGINS,
  // ...
)

Object keys are specific to plugin and it's the same name thats in folder name but the first letter is lower cased.
Prefer TypeScript

Usage

Once you have initialized the client and waited for it to be ready, you can start doing calls. Client provides service method for getting specific plugin. Here's how you would list files in directory called Photos.

const files = await WebAppClient.Client.service('filePlugin').listDir('Photos');

Advanced

In case you need to call plugin directly through postMessage, or call Showell API directly, you can use makePluginCall and makeApiCall functions from client.

1.2.15

2 years ago

1.2.14

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago