@auxilium/datalynk-client 1.2.4 → 1.2.5

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,55 @@
1
+ /**
2
+ * List of functions to handle conversions to and from datalynk syntax
3
+ */
4
+ export declare const Serializer: {
5
+ /**
6
+ * From Datalynk syntax to JS
7
+ */
8
+ deserialize: {
9
+ /**
10
+ * Convert date time string to javascript date object
11
+ *
12
+ * @param {string} datetime datetime string (YYYY/MM/DD hh:mm:ss)
13
+ * @returns {Date} JS Date object
14
+ */
15
+ '$/tools/date': (datetime: string) => Date;
16
+ /**
17
+ * Convert date string to javascript date object
18
+ *
19
+ * @param {string} date date string (YYYY/MM/DD)
20
+ * @returns {Date} JS Date object
21
+ */
22
+ '$/tools/date_strict': (date: string) => Date;
23
+ /**
24
+ * Convert time string to javascript date object
25
+ *
26
+ * @param {string} time time string (YYYY/MM/DD)
27
+ * @returns {Date} JS Date object
28
+ */
29
+ '$/tools/time_strict': (time: string) => Date;
30
+ /**
31
+ * Convert string to constant
32
+ *
33
+ * @param {string} constant string to be converted
34
+ * @returns {any} the actual constant
35
+ */
36
+ '$/tools/const': (constant: string) => any;
37
+ /**
38
+ * Large requests are formatted into parallel arrays
39
+ *
40
+ * @param {object} obj Object of metadata and data
41
+ * @returns {Array} Actual object reconstructed
42
+ */
43
+ '$/tools/dltable': (obj: any) => never[];
44
+ };
45
+ /**
46
+ * From JS to Datalynk syntax
47
+ */
48
+ serialize: {
49
+ /**
50
+ * Convert JS date to datalynk datetime string
51
+ */
52
+ Date: (date: Date) => Object;
53
+ };
54
+ };
55
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU;IAEtB;;OAEG;;QAEF;;;;;WAKG;mCACwB,MAAM,KAAG,IAAI;QAIxC;;;;;WAKG;sCAC2B,MAAM,KAAG,IAAI;QAM3C;;;;;WAKG;sCAC2B,MAAM,KAAG,IAAI;QAS3C;;;;;WAKG;oCACyB,MAAM;QAalC;;;;;WAKG;iCAC8B,GAAG;;IAkErC;;OAEG;;QAEF;;WAEG;qBACY,IAAI,KAAG,MAAM;;CAO7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const cache = "datalynk";
2
+ //# sourceMappingURL=service.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.worker.d.ts","sourceRoot":"","sources":["../src/service.worker.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ const cache = "datalynk";
3
+ self.addEventListener("fetch", (event) => {
4
+ const request = event.request;
5
+ if (navigator.onLine) {
6
+ event.respondWith(fetch(request).then((response) => {
7
+ const responseClone = response.clone();
8
+ if (request.url.startsWith(self.location.origin) || request.url.startsWith("https://datalynk-client"))
9
+ caches.open(cache).then((cache2) => cache2.put(request, responseClone));
10
+ return response;
11
+ }));
12
+ } else {
13
+ event.respondWith(caches.match(request).then((cachedResponse) => cachedResponse || new Response("You are offline", { status: 503, statusText: "Service Unavailable" })));
14
+ }
15
+ });
@@ -0,0 +1,14 @@
1
+ const cache = "datalynk";
2
+ self.addEventListener("fetch", (event) => {
3
+ const request = event.request;
4
+ if (navigator.onLine) {
5
+ event.respondWith(fetch(request).then((response) => {
6
+ const responseClone = response.clone();
7
+ if (request.url.startsWith(self.location.origin) || request.url.startsWith("https://datalynk-client"))
8
+ caches.open(cache).then((cache2) => cache2.put(request, responseClone));
9
+ return response;
10
+ }));
11
+ } else {
12
+ event.respondWith(caches.match(request).then((cachedResponse) => cachedResponse || new Response("You are offline", { status: 503, statusText: "Service Unavailable" })));
13
+ }
14
+ });
@@ -0,0 +1,299 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ import { Api, ApiRequestOptions } from './api';
3
+ import { Meta, SliceInfo } from './meta';
4
+ import { Unsubscribe } from './socket';
5
+ export declare class ApiCall<T extends Meta = any> {
6
+ private readonly api;
7
+ readonly slice: number | string;
8
+ private operation;
9
+ private popField?;
10
+ private request;
11
+ /** Log response automatically */
12
+ debugging?: boolean;
13
+ /** Get raw API request */
14
+ get raw(): Partial<{
15
+ [x: string]: any;
16
+ $pop: string | undefined;
17
+ }>;
18
+ constructor(api: Api, slice: number | string);
19
+ /**
20
+ * Whitelist and alias fields. Alias of `fields()`
21
+ * @example
22
+ * ```ts
23
+ * const id: {id: number, field2: any}[] = await new Slice<T>(12345)
24
+ * .select().alias({id: 'id', field1: 'field2'}).exec().keys();
25
+ * ```
26
+ * @param {object} aliasKeyVals List of properties to whitelist and what to rename them to
27
+ * @return {Slice<T>}
28
+ */
29
+ alias: {
30
+ (whitelist: string[]): this;
31
+ (alias: {
32
+ [key: string]: string | object;
33
+ }): this;
34
+ };
35
+ /**
36
+ * Add an 'AND' condition inside the where argument
37
+ * @example
38
+ * ```ts
39
+ * const rows: T[] = await new Slice<T>(12345).select()
40
+ * .where('field1', '>', 1)
41
+ * .and()
42
+ * .where({field2: 2, field3: 3})
43
+ * .exec().rows();
44
+ * ```
45
+ * @return {Slice<T>}
46
+ */
47
+ and(): this;
48
+ /**
49
+ * Count the returned rows
50
+ * @example
51
+ * ```ts
52
+ * const count = await new Slice(12345).count()
53
+ * .where({field1: 1})
54
+ * .exec().count();
55
+ * ```
56
+ * @param {object | string} arg Count argument
57
+ * @return {Slice<T>}
58
+ */
59
+ count(arg?: object | string): this;
60
+ /**
61
+ * Output the formed request to the console for inspection
62
+ * @param {boolean} enabled Enable/Disable console logging
63
+ * @return {Slice<T>}
64
+ */
65
+ debug(enabled?: boolean): this;
66
+ /**
67
+ * Set the request type to delete
68
+ * @example
69
+ * ```ts
70
+ * await new Slice(12345).delete(id).exec();
71
+ * ```
72
+ * @param {number | number[]} id ID(s) to delete
73
+ * @return {Slice<T>}
74
+ */
75
+ delete(id?: number | number[]): this;
76
+ /**
77
+ * Filter rows from slice based on an excel expression
78
+ * @example
79
+ * ```ts
80
+ * const rows: T[] = await new Slice<T>(12345).select()
81
+ * .excel('contains({property}, foobar)')
82
+ * .exec().rows();
83
+ * ```
84
+ * @param formula Excel formula to use as where clause
85
+ * @return {Slice<T>}
86
+ */
87
+ excel(formula: string): this;
88
+ /**
89
+ * Compile the request and send it
90
+ * @param {ApiRequestOptions} options API Request options
91
+ * @return {Promise<T = any>} API response
92
+ */
93
+ exec<T = any>(options?: ApiRequestOptions): Promise<T>;
94
+ /**
95
+ * Whitelist fields by passing an array of keys or alias fields by using a map
96
+ * @example
97
+ * ```ts
98
+ * const id: {id: number, field1: any}[] = await new Slice<T>(12345)
99
+ * .select().fields(['id', 'field1']).exec().keys();
100
+ * ```
101
+ * @param {object} whitelist Either a list of keys to whitelist or a map of keys to rename
102
+ * @return {Slice<T>}
103
+ */
104
+ fields(whitelist: string[]): this;
105
+ fields(alias: {
106
+ [key: string]: string | object;
107
+ }): this;
108
+ /**
109
+ * Unwrap response returning the first ID
110
+ * @return {Slice<T>}
111
+ */
112
+ id(): this;
113
+ /**
114
+ * Set the request type to insert
115
+ * @example
116
+ * ```ts
117
+ * const id: number = await new Slice<T>(12345).insert([
118
+ * {field1: 1},
119
+ * {field1: 2}
120
+ * ]).exec().keys();
121
+ * ```
122
+ * @param {T | T[]} rows Rows to be inserted into the slice
123
+ * @return {Slice<T>}
124
+ */
125
+ insert(rows: T | T[]): this;
126
+ /**
127
+ * Limit number of rows returned
128
+ * @example
129
+ * ```ts
130
+ * const rows: T[] = await new Slice<T>(12345).select().limit(10)
131
+ * .exec().rows();
132
+ * ```
133
+ * @param {number} num Number of rows to return
134
+ * @return {Slice<T>}
135
+ */
136
+ limit(num: number): this;
137
+ /**
138
+ * Add an 'OR' condition inside the where argument
139
+ * @example
140
+ * ```ts
141
+ * const rows: T[] = await new Slice<T>(12345).select()
142
+ * .where('field1', '>', 1)
143
+ * .or()
144
+ * .where({field2: 2, field3: 3})
145
+ * .or()
146
+ * .where(['$gt', ['$field', field4], 4)
147
+ * .exec().rows();
148
+ * ```
149
+ * @return {Slice<T>}
150
+ */
151
+ or(): this;
152
+ /**
153
+ * Order rows by a field
154
+ * @example
155
+ * ```ts
156
+ * const rows: T[] = new Slice<T>(12345).select().order('field1', true) // true = ascending
157
+ * .exec().rows();
158
+ * ```
159
+ * @param {string} field property name
160
+ * @param {boolean} ascending Sort in ascending or descending order
161
+ * @return {Slice<T>}
162
+ */
163
+ order(field: string, ascending?: boolean): this;
164
+ /**
165
+ * Unwrap response, returning the field
166
+ * @param {string} field Colon seperated path: `rows:0`
167
+ * @return {Slice<T>}
168
+ */
169
+ pop(field: string | null): this;
170
+ /**
171
+ * Unwrap response returning the first row
172
+ * @return {Slice<T>}
173
+ */
174
+ row(): this;
175
+ /**
176
+ * Unwrap response returning the rows
177
+ * @return {Slice<T>}
178
+ */
179
+ rows(): this;
180
+ /**
181
+ * Save multiple rows to the slice, automatically inserts/updates
182
+ * @param {T} rows Rows to add to slice
183
+ * @returns {this<T>}
184
+ */
185
+ save(rows: T | T[]): this;
186
+ /**
187
+ * Set the request type to select
188
+ * @example
189
+ * ```ts
190
+ * const rows: T[] = new Slice<T>(12345).select().exec().rows();
191
+ * const row: T = new Slice<T>(12345).select(id).exec().row();
192
+ * ```
193
+ * @param {number | number[]} id ID(s) to select, leaving blank will return all rows
194
+ * @return {Slice<T>}
195
+ */
196
+ select(id?: number | number[]): this;
197
+ /**
198
+ * Set the request type to update
199
+ * @example
200
+ * ```ts
201
+ * const ids: number[] = await new Slice<Type>(12345).update([
202
+ * {id: 1, field1: 1},
203
+ * {id: 2, field1: 1}
204
+ * ]).exec().keys();
205
+ * ```
206
+ * @param {T | T[]} rows Rows to be updated, each row must have an ID
207
+ * @return {Slice<T>}
208
+ */
209
+ update(rows: T | T[]): this;
210
+ /**
211
+ * Add where condition to request
212
+ * @example
213
+ * ```ts
214
+ * const rows: T[] = await new Slice<T>(12345).select()
215
+ * .where('field1', '>', 1)
216
+ * .where({field2: 2, field3: 3}) // Automatic AND
217
+ * .or()
218
+ * .where(['$gt', ['$field', field4], 4)
219
+ * .exec().rows();
220
+ * ```
221
+ * @param {string | object} field property to compare or a map of equality comparisons
222
+ * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
223
+ * @param {any} value value to compare against
224
+ * @return {Slice<T>}
225
+ */
226
+ where(field: string | object, operator?: string, value?: any): this;
227
+ }
228
+ /**
229
+ * An object to aid in constructing Datalynk requests
230
+ */
231
+ export declare class Slice<T extends Meta = any> {
232
+ private slice;
233
+ private api;
234
+ private table?;
235
+ private info?;
236
+ private pendingInsert;
237
+ /** Unsubscribe from changes, undefined if not subscribed */
238
+ unsubscribe?: Unsubscribe | null;
239
+ /** Cached slice data as an observable */
240
+ cache$: BehaviorSubject<T[]>;
241
+ /** Cached slice data */
242
+ get cache(): T[];
243
+ /** Set cached data & alert subscribers */
244
+ private set cache(value);
245
+ /** Is slice offline support enabled */
246
+ get offlineEnabled(): boolean | undefined;
247
+ /**
248
+ * An object to aid in constructing requests
249
+ *
250
+ * @param {number} slice Slice ID to interact with
251
+ * @param {Api} api Api to send the requests through
252
+ */
253
+ constructor(slice: number | string, api: Api);
254
+ private fixIncrement;
255
+ private execWrapper;
256
+ pushChanges(): Promise<void>;
257
+ /**
258
+ * Get slice information
259
+ * @param reload Ignore cache & reload info
260
+ * @return {Promise<SliceInfo>}
261
+ */
262
+ getInfo(reload?: boolean): Promise<SliceInfo>;
263
+ /**
264
+ * Synchronize cache with server
265
+ * @example
266
+ * ```ts
267
+ * const slice: Slice = new Slice<T>(Slices.Contact);
268
+ * slice.sync().subscribe((rows: T[]) => {});
269
+ * ```
270
+ * @param {boolean} on Enable/disable events
271
+ * @return {BehaviorSubject<T[]>} Cache which can be subscribed to
272
+ */
273
+ sync(on?: boolean): BehaviorSubject<T[]> | undefined;
274
+ /**
275
+ * {@inheritDoc ApiCall.count}
276
+ */
277
+ count(arg?: object | string): ApiCall<T>;
278
+ /**
279
+ * {@inheritDoc ApiCall.delete}
280
+ */
281
+ delete(id: number | number[]): ApiCall<T>;
282
+ /**
283
+ * {@inheritDoc ApiCall.insert}
284
+ */
285
+ insert(rows: T | T[]): ApiCall<T>;
286
+ /**
287
+ * {@inheritDoc ApiCall.save}
288
+ */
289
+ save(rows: T | T[]): ApiCall<T>;
290
+ /**
291
+ * {@inheritDoc ApiCall.select}
292
+ */
293
+ select(id?: number | number[]): ApiCall<T>;
294
+ /**
295
+ * {@inheritDoc ApiCall.update}
296
+ */
297
+ update(rows: T | T[]): ApiCall<T>;
298
+ }
299
+ //# sourceMappingURL=slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../src/slice.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAiC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAC,GAAG,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAmB,WAAW,EAAC,MAAM,UAAU,CAAC;AAEvD,qBAAa,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,GAAG;IAmB5B,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,KAAK,EAAE,MAAM,GAAG,MAAM;IAlB7E,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,OAAO,CAAW;IAE1B,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,0BAA0B;IAC1B,IAAI,GAAG;;;OAQN;gBAE4B,GAAG,EAAE,GAAG,EAAkB,KAAK,EAAE,MAAM,GAAG,MAAM;IAE7E;;;;;;;;;OASG;IACH,KAAK;oBA0Ga,MAAM,EAAE,GAAG,IAAI;gBACnB;YAA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AC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE;IAM5B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;IAMpB;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;IAMlB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAO7B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;CAKpB"}
@@ -0,0 +1,95 @@
1
+ import { Api } from './api';
2
+ export type SocketEvent<T> = {
3
+ channel: string;
4
+ spoke: string;
5
+ type: string;
6
+ data: T;
7
+ };
8
+ export type SocketEventSlice = SocketEvent<{
9
+ slice: number;
10
+ tx: string;
11
+ new: number[];
12
+ lost: number[];
13
+ changed: number[];
14
+ }>;
15
+ export type WebRTCEvent = {
16
+ type: string;
17
+ } & ({
18
+ connected: {
19
+ uid: string;
20
+ username: string;
21
+ };
22
+ } | {
23
+ disconnected: {
24
+ uid: string;
25
+ username: string;
26
+ };
27
+ } | {
28
+ offer: {
29
+ to: string;
30
+ uid: string;
31
+ username: string;
32
+ offer: RTCSessionDescriptionInit;
33
+ };
34
+ } | {
35
+ answer: {
36
+ to: string;
37
+ uid: string;
38
+ username: string;
39
+ offer: RTCSessionDescriptionInit;
40
+ };
41
+ });
42
+ /** Connection options */
43
+ export type SocketOptions = {
44
+ /** Set connection URL or disable with false */
45
+ url?: string | false;
46
+ };
47
+ /** Callback shape */
48
+ export type SocketListener<T = SocketEvent<any>> = (event: T) => any;
49
+ /** Call to unsubscribe callback from event */
50
+ export type Unsubscribe = () => void;
51
+ /** Datalynk Socket connection */
52
+ export declare class Socket {
53
+ private readonly api;
54
+ readonly options: SocketOptions;
55
+ private listeners;
56
+ private retry?;
57
+ private socket?;
58
+ open: boolean;
59
+ constructor(api: Api, options?: SocketOptions);
60
+ /**
61
+ * Add listener for all socket events
62
+ *
63
+ * @param {SocketListener} fn Callback function
64
+ *
65
+ *
66
+ *
67
+ *
68
+ * @return {Unsubscribe} Function to unsubscribe callback
69
+ */
70
+ addListener(fn: SocketListener, reconnect: () => void): Unsubscribe;
71
+ /**
72
+ * Close socket connection
73
+ */
74
+ close(): void;
75
+ /**
76
+ * Connect socket client to socket server
77
+ * @param {number} timeout Retry to connect every x seconds
78
+ */
79
+ connect(timeout?: number): void;
80
+ /**
81
+ * Send data to socket server
82
+ *
83
+ * @param payload Data that will be serialized
84
+ */
85
+ send(payload: any): void;
86
+ /**
87
+ * Run callback whenever the server notifies us of slice changes
88
+ *
89
+ * @param {number | number[]} slice Slice to subscribe to
90
+ * @param {SocketListener<SocketEventSlice>} callback Function to run on changes
91
+ * @return {Unsubscribe} Run returned function to unsubscribe callback
92
+ */
93
+ sliceEvents(slice: number | number[] | string | string[], callback: SocketListener<SocketEventSlice>): Unsubscribe;
94
+ }
95
+ //# sourceMappingURL=socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAA;CACP,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GACvC,CAAC;IAAC,SAAS,EAAE;QAAC,GAAG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;;;OAGG;IACH,OAAO,CAAC,OAAO,GAAE,MAAW;IAgC5B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG;IAKjB;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,gBAAgB,CAAC,GAAG,WAAW;CAUlH"}
@@ -0,0 +1,24 @@
1
+ import { Api } from './api';
2
+ /**
3
+ * Superuser helpers
4
+ */
5
+ export declare class Superuser {
6
+ private readonly api;
7
+ constructor(api: Api);
8
+ /**
9
+ * Switch to another user by ID
10
+ *
11
+ * @param {number} userId User ID
12
+ * @return {Promise<any>} New session
13
+ */
14
+ assume(userId: number): Promise<any>;
15
+ /**
16
+ * Enable the superuser flag, required to make any of the requests in this helper
17
+ *
18
+ * @param {string} username Superuser account
19
+ * @param {string} password Superuser password
20
+ * @return {Promise<any>} Unknown
21
+ */
22
+ enable(username: string, password: string): Promise<any>;
23
+ }
24
+ //# sourceMappingURL=superuser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"superuser.d.ts","sourceRoot":"","sources":["../src/superuser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,qBAAa,SAAS;IAET,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,GAAG;IAErC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;IAOrB;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAMzC"}
@@ -0,0 +1,55 @@
1
+ export interface Theme {
2
+ /** Add links to top of page */
3
+ addLinks?: {
4
+ text: string;
5
+ url: string;
6
+ }[];
7
+ /** Background image URL */
8
+ background?: string;
9
+ /** Background color as hex (overrides background image) */
10
+ backgroundColor?: string;
11
+ /** Primary color as hex: `#000000` */
12
+ color?: string;
13
+ /** Change glow color, defaults to color or set to falsy to disable */
14
+ glow?: string;
15
+ /** Hide app links */
16
+ hideApps?: boolean;
17
+ /** Logo URL */
18
+ logo?: string;
19
+ /** Allow users to stay logged in */
20
+ persist?: boolean;
21
+ /** Header string or HTML: <img alt="logo" src="...">*/
22
+ title?: string;
23
+ /** Color of headers & links */
24
+ textColor?: string;
25
+ /** Custom font for title */
26
+ titleFontFamily?: string;
27
+ /** Import URL for custom font */
28
+ titleFontUrl?: string;
29
+ /** Font size for the title */
30
+ titleFontSize?: string;
31
+ /** Text shadow for the title */
32
+ titleTextShadow?: string;
33
+ /** Subtitle text */
34
+ subtitle?: string;
35
+ /** Custom font for subtitle */
36
+ subtitleFontFamily?: string;
37
+ /** Import URL for subtitle font */
38
+ subtitleFontUrl?: string;
39
+ /** Color for subtitle */
40
+ subtitleTextColor?: string;
41
+ /** Font size for subtitle */
42
+ subtitleFontSize?: string;
43
+ /** Text shadow for subtitle */
44
+ subtitleTextShadow?: string;
45
+ }
46
+ /**
47
+ * Get the theme for a spoke
48
+ * @param {string} spoke Name of spoke
49
+ * @param {string} scope Apply sub-theme
50
+ * @returns {Promise<Theme & {found: boolean}>}
51
+ */
52
+ export declare function getTheme(spoke: string, scope?: string): Promise<Theme & {
53
+ found: boolean;
54
+ }>;
55
+ //# sourceMappingURL=themes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACrB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6BAA6B;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG;IAAC,KAAK,EAAE,OAAO,CAAA;CAAC,CAAC,CA2B/F"}
@@ -0,0 +1,50 @@
1
+ import { Unsubscribe } from '@ztimson/utils';
2
+ import { Api } from './api';
3
+ /** WebRTC peer */
4
+ export type WebRTCPeer = {
5
+ /** Peer connection UID */
6
+ uid: string;
7
+ /** Peer username */
8
+ username: string;
9
+ /** Remote connection to stream */
10
+ connection: RTCPeerConnection;
11
+ };
12
+ /** WebRTC session */
13
+ export type WebRTCSession = {
14
+ /** Is the connection active? */
15
+ open: boolean;
16
+ /** Room ID */
17
+ id: string;
18
+ /** Connection UID */
19
+ uid: string;
20
+ /** Local media stream */
21
+ stream: MediaStream;
22
+ /** Connected peers sorted by UID */
23
+ peers: {
24
+ [key: string]: WebRTCPeer;
25
+ };
26
+ /** Disconnection session */
27
+ disconnect: Unsubscribe;
28
+ /** Callback when peers connect */
29
+ onConnected?: (peer: WebRTCPeer, track: any) => any;
30
+ };
31
+ export declare class WebRtc {
32
+ private api;
33
+ readonly ice: {
34
+ urls: string[];
35
+ username?: string;
36
+ credential?: string;
37
+ }[];
38
+ constructor(api: Api);
39
+ private answer;
40
+ private offer;
41
+ /**
42
+ * Create a new WebRTC connection to a room
43
+ * @param {string} id Room ID
44
+ * @param {boolean} audio Stream local audio to room/peers
45
+ * @param {boolean} video Stream local video to room/peers
46
+ * @returns {Promise<WebRTCSession>} Connection session
47
+ */
48
+ connect(id?: string, audio?: boolean, video?: boolean): Promise<WebRTCSession>;
49
+ }
50
+ //# sourceMappingURL=webrtc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,kBAAkB;AAClB,MAAM,MAAM,UAAU,GAAG;IACxB,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,UAAU,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED,qBAAqB;AACrB,MAAM,MAAM,aAAa,GAAG;IAC3B,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,oCAAoC;IACpC,KAAK,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAA;IAClC,4BAA4B;IAC5B,UAAU,EAAE,WAAW,CAAA;IACvB,kCAAkC;IAClC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;CACnD,CAAA;AAED,qBAAa,MAAM;IAGN,OAAO,CAAC,GAAG;IAFvB,SAAgB,GAAG,EAAG;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;gBAE7D,GAAG,EAAE,GAAG;YAYd,MAAM;YAaN,KAAK;IAWnB;;;;;;OAMG;IACG,OAAO,CAAC,EAAE,GAAE,MAA4C,EAAE,KAAK,UAAO,EAAE,KAAK,UAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAoEnH"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@auxilium/datalynk-client",
3
3
  "description": "Datalynk client library",
4
4
  "repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
5
- "version": "1.2.4",
5
+ "version": "1.2.5",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",