@streamlayer/sdk-web 0.1.0
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 +7 -0
- package/package.json +20 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
- package/src/lib/core.d.ts +16 -0
- package/src/lib/core.js +68 -0
- package/src/lib/core.js.map +1 -0
- package/src/lib/store/index.d.ts +11 -0
- package/src/lib/store/index.js +6 -0
- package/src/lib/store/index.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@streamlayer/sdk-web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@swc/helpers": "~0.5.0",
|
|
6
|
+
"@streamlayer/sdk-web-types": "*",
|
|
7
|
+
"nanostores": "^0.9.3"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./src/index.js",
|
|
11
|
+
"typings": "./src/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"src/"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"require": "./src/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/core';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../packages/sdk-web/src/index.ts"],"sourcesContent":["export * from './lib/core'\n"],"names":[],"mappings":"AAAA,cAAc,aAAY"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class Core {
|
|
2
|
+
private test;
|
|
3
|
+
private sdkKey;
|
|
4
|
+
private store;
|
|
5
|
+
constructor(sdkKey: string);
|
|
6
|
+
initializeApp: () => void;
|
|
7
|
+
disableApp: () => void;
|
|
8
|
+
createEventSession: (providerStreamId: string) => void;
|
|
9
|
+
authorizationBypass: () => void;
|
|
10
|
+
logout: () => void;
|
|
11
|
+
isUserAuthorized: () => boolean;
|
|
12
|
+
private getOrganizationSettings;
|
|
13
|
+
private getStreamSettings;
|
|
14
|
+
private storeSubscribe;
|
|
15
|
+
private storeUnsubscribe;
|
|
16
|
+
}
|
package/src/lib/core.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { $coreStore } from './store';
|
|
2
|
+
export class Core {
|
|
3
|
+
constructor(sdkKey){
|
|
4
|
+
this.store = $coreStore;
|
|
5
|
+
this.initializeApp = ()=>{
|
|
6
|
+
this.storeSubscribe();
|
|
7
|
+
this.store.setKey('enabled', true);
|
|
8
|
+
};
|
|
9
|
+
this.disableApp = ()=>{
|
|
10
|
+
this.store.setKey('enabled', false);
|
|
11
|
+
this.storeUnsubscribe();
|
|
12
|
+
};
|
|
13
|
+
this.createEventSession = (providerStreamId)=>{
|
|
14
|
+
const slStreamId = `sl-${providerStreamId}` // await api.resolveEventId(providerStreamId)
|
|
15
|
+
;
|
|
16
|
+
this.store.setKey('providerStreamId', providerStreamId);
|
|
17
|
+
this.store.setKey('slStreamId', slStreamId);
|
|
18
|
+
};
|
|
19
|
+
this.authorizationBypass = ()=>{
|
|
20
|
+
const user = {
|
|
21
|
+
id: 'test'
|
|
22
|
+
};
|
|
23
|
+
this.store.setKey('user', user);
|
|
24
|
+
};
|
|
25
|
+
this.logout = ()=>{
|
|
26
|
+
this.store.setKey('user', undefined);
|
|
27
|
+
};
|
|
28
|
+
this.isUserAuthorized = ()=>{
|
|
29
|
+
return Boolean(this.store.get().user);
|
|
30
|
+
};
|
|
31
|
+
this.getOrganizationSettings = ()=>{
|
|
32
|
+
const settings = {} // await api.getOrganizationSettings()
|
|
33
|
+
;
|
|
34
|
+
this.store.setKey('organizationSettings', settings);
|
|
35
|
+
};
|
|
36
|
+
this.getStreamSettings = (streamId)=>{
|
|
37
|
+
const settings = {} // await api.getStreamSettings(this.store.slStreamId)
|
|
38
|
+
;
|
|
39
|
+
this.store.setKey('streamSettings', settings);
|
|
40
|
+
};
|
|
41
|
+
this.storeSubscribe = ()=>{
|
|
42
|
+
const subscribes = {
|
|
43
|
+
enabled: (enabled)=>{
|
|
44
|
+
if (enabled) {
|
|
45
|
+
this.getOrganizationSettings();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
slStreamId: (streamId)=>{
|
|
49
|
+
if (streamId) {
|
|
50
|
+
this.getStreamSettings(streamId);
|
|
51
|
+
} else {
|
|
52
|
+
this.store.setKey('streamSettings', undefined);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
this.store.listen((store, storeKey)=>{
|
|
57
|
+
console.log(`${storeKey} new value ${store[storeKey]}`);
|
|
58
|
+
subscribes[storeKey]?.(store[storeKey]);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
this.storeUnsubscribe = ()=>{
|
|
62
|
+
this.store.off();
|
|
63
|
+
};
|
|
64
|
+
this.sdkKey = sdkKey;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/sdk-web/src/lib/core.ts"],"sourcesContent":["import { $coreStore, CoreStore } from './store'\n\nexport class Core {\n private test: string\n private sdkKey: string\n private store = $coreStore\n\n constructor(sdkKey: string) {\n this.sdkKey = sdkKey\n }\n\n public initializeApp = () => {\n this.storeSubscribe()\n this.store.setKey('enabled', true)\n }\n\n public disableApp = () => {\n this.store.setKey('enabled', false)\n this.storeUnsubscribe()\n }\n\n public createEventSession = (providerStreamId: string) => {\n const slStreamId = `sl-${providerStreamId}` // await api.resolveEventId(providerStreamId)\n\n this.store.setKey('providerStreamId', providerStreamId)\n this.store.setKey('slStreamId', slStreamId)\n }\n\n public authorizationBypass = () => {\n const user = { id: 'test' }\n\n this.store.setKey('user', user)\n }\n\n public logout = () => {\n this.store.setKey('user', undefined)\n }\n\n public isUserAuthorized = () => {\n return Boolean(this.store.get().user)\n }\n\n private getOrganizationSettings = () => {\n const settings: any = {} // await api.getOrganizationSettings()\n\n this.store.setKey('organizationSettings', settings)\n }\n\n private getStreamSettings = (streamId: string) => {\n const settings = {} // await api.getStreamSettings(this.store.slStreamId)\n\n this.store.setKey('streamSettings', settings)\n }\n\n private storeSubscribe = () => {\n const subscribes: Partial<\n Record<keyof CoreStore, (...args: any[]) => void>\n > = {\n enabled: (enabled) => {\n if (enabled) {\n this.getOrganizationSettings()\n }\n },\n slStreamId: (streamId: string) => {\n if (streamId) {\n this.getStreamSettings(streamId)\n } else {\n this.store.setKey('streamSettings', undefined)\n }\n },\n }\n\n this.store.listen((store, storeKey) => {\n console.log(`${storeKey} new value ${store[storeKey]}`)\n subscribes[storeKey]?.(store[storeKey])\n })\n }\n\n private storeUnsubscribe = () => {\n this.store.off()\n }\n}\n"],"names":["$coreStore","Core","constructor","sdkKey","store","initializeApp","storeSubscribe","setKey","disableApp","storeUnsubscribe","createEventSession","providerStreamId","slStreamId","authorizationBypass","user","id","logout","undefined","isUserAuthorized","Boolean","get","getOrganizationSettings","settings","getStreamSettings","streamId","subscribes","enabled","listen","storeKey","console","log","off"],"mappings":"AAAA,SAASA,UAAU,QAAmB,UAAS;AAE/C,OAAO,MAAMC;IAKXC,YAAYC,MAAc,CAAE;aAFpBC,QAAQJ;aAMTK,gBAAgB,IAAM;YAC3B,IAAI,CAACC,cAAc;YACnB,IAAI,CAACF,KAAK,CAACG,MAAM,CAAC,WAAW,IAAI;QACnC;aAEOC,aAAa,IAAM;YACxB,IAAI,CAACJ,KAAK,CAACG,MAAM,CAAC,WAAW,KAAK;YAClC,IAAI,CAACE,gBAAgB;QACvB;aAEOC,qBAAqB,CAACC,mBAA6B;YACxD,MAAMC,aAAa,CAAC,GAAG,EAAED,iBAAiB,CAAC,CAAC,6CAA6C;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CAAC2B,GAAG;QAChB;QAxEE,IAAI,CAAC5B,MAAM,GAAGA;IAChB;AAwEF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OrganizationSettings } from '@streamlayer/sdk-web-types';
|
|
2
|
+
export interface CoreStore {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
organizationSettings?: OrganizationSettings;
|
|
5
|
+
streamSettings?: Record<string, any>;
|
|
6
|
+
user?: Record<string, any>;
|
|
7
|
+
test?: Record<string, any>;
|
|
8
|
+
providerStreamId?: string;
|
|
9
|
+
slStreamId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const $coreStore: import("nanostores").MapStore<CoreStore>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/sdk-web/src/lib/store/index.ts"],"sourcesContent":["import type { OrganizationSettings } from '@streamlayer/sdk-web-types'\n\nimport { map } from 'nanostores'\n\nexport interface CoreStore {\n enabled: boolean\n organizationSettings?: OrganizationSettings\n streamSettings?: Record<string, any>\n user?: Record<string, any>\n test?: Record<string, any>\n providerStreamId?: string\n slStreamId?: string\n}\n\nexport const $coreStore = map<CoreStore>({\n enabled: false,\n})\n"],"names":["map","$coreStore","enabled"],"mappings":"AAEA,SAASA,GAAG,QAAQ,aAAY;AAYhC,OAAO,MAAMC,aAAaD,IAAe;IACvCE,SAAS,KAAK;AAChB,GAAE"}
|