@scaleflex/widget-companion-client 0.0.1

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.
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * This module serves as an Async wrapper for LocalStorage
5
+ */
6
+ var setItem = function setItem(key, value) {
7
+ return new Promise(function (resolve) {
8
+ localStorage.setItem(key, value);
9
+ resolve();
10
+ });
11
+ };
12
+ var getItem = function getItem(key) {
13
+ return Promise.resolve(localStorage.getItem(key));
14
+ };
15
+ var removeItem = function removeItem(key) {
16
+ return new Promise(function (resolve) {
17
+ localStorage.removeItem(key);
18
+ resolve();
19
+ });
20
+ };
21
+ export { setItem, getItem, removeItem };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@scaleflex/widget-companion-client",
3
+ "description": "Client library for communication with Companion. Intended for use in Scaleflex plugins.",
4
+ "version": "0.0.1",
5
+ "license": "MIT",
6
+ "main": "lib/index.js",
7
+ "types": "types/index.d.ts",
8
+ "files": [
9
+ "/dist",
10
+ "/lib",
11
+ "/types"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "dependencies": {
17
+ "@scaleflex/widget-utils": "^0.0.1",
18
+ "namespace-emitter": "^2.0.1"
19
+ },
20
+ "gitHead": "64ea82e745b7deda36d6794863350e6671e9010d"
21
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Async storage interface, similar to `localStorage`. This can be used to
3
+ * implement custom storages for authentication tokens.
4
+ */
5
+ export interface TokenStorage {
6
+ setItem: (key: string, value: string) => Promise<void>
7
+ getItem: (key: string) => Promise<string>
8
+ removeItem: (key: string) => Promise<void>
9
+ }
10
+
11
+ export interface RequestClientOptions {
12
+ companionUrl: string
13
+ companionHeaders?: object
14
+ }
15
+
16
+ export class RequestClient {
17
+ constructor (filerobot: any, opts: RequestClientOptions)
18
+ get (path: string): Promise<any>
19
+ post (path: string, data: object): Promise<any>
20
+ delete (path: string, data: object): Promise<any>
21
+ }
22
+
23
+ /**
24
+ * Options for Providers that can be passed in by Filerobot users through
25
+ * Plugin constructors.
26
+ */
27
+ export interface PublicProviderOptions extends RequestClientOptions {
28
+ companionAllowedHosts?: string | RegExp | Array<string | RegExp>
29
+ }
30
+
31
+ /**
32
+ * Options for Providers, including internal options that Plugins can set.
33
+ */
34
+ export interface ProviderOptions extends PublicProviderOptions {
35
+ provider: string
36
+ name?: string
37
+ pluginId: string
38
+ }
39
+
40
+ export class Provider extends RequestClient {
41
+ constructor (filerobot: any, opts: ProviderOptions)
42
+ checkAuth (): Promise<boolean>
43
+ authUrl (): string
44
+ fileUrl (id: string): string
45
+ list (directory: string): Promise<any>
46
+ logout (redirect?: string): Promise<any>
47
+ static initPlugin (plugin: any, opts: object, defaultOpts?: object): void
48
+ }
49
+
50
+ export interface SocketOptions {
51
+ target: string
52
+ autoOpen?: boolean
53
+ }
54
+
55
+ export class Socket {
56
+ isOpen: boolean
57
+
58
+ constructor (opts: SocketOptions)
59
+ open (): void
60
+ close (): void
61
+ send (action: string, payload: any): void
62
+ on (action: string, handler: (param: any) => void): void
63
+ once (action: string, handler: (param: any) => void): void
64
+ emit (action: string, payload: (param: any) => void): void
65
+ }