@streamlayer/sdk-web 0.17.5 → 0.18.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/package.json CHANGED
@@ -2,23 +2,22 @@
2
2
  "name": "@streamlayer/sdk-web",
3
3
  "dependencies": {
4
4
  "@streamlayer/sdk-web-api": "workspace:^",
5
+ "@streamlayer/sdk-web-core": "workspace:^",
6
+ "@streamlayer/sdk-web-features": "workspace:^",
5
7
  "@streamlayer/sdk-web-interfaces": "workspace:^",
6
- "@streamlayer/sdk-web-types": "workspace:^",
8
+ "tslib": "^2.6.2",
7
9
  "avvio": "^8.2.1"
8
10
  },
9
- "version": "0.17.5",
11
+ "version": "0.18.0",
10
12
  "type": "module",
11
13
  "main": "./src/index.js",
12
14
  "typings": "./src/index.d.ts",
13
- "exports": {
14
- "import": "./src/main.js",
15
- "default": "./src/main.js"
16
- },
17
15
  "files": [
18
16
  "src/"
19
17
  ],
20
18
  "devDependencies": {
21
- "@swc/helpers": "^0.5.2"
19
+ "@swc/helpers": "^0.5.2",
20
+ "tslib": "^2.6.2"
22
21
  },
23
22
  "module": "./src/index.js"
24
23
  }
package/src/index.d.ts CHANGED
@@ -1,17 +1,7 @@
1
- import { Transport } from '@streamlayer/sdk-web-api';
1
+ import { StreamLayerContext } from '@streamlayer/sdk-web-interfaces';
2
2
  import avvio from 'avvio';
3
- import './store';
4
- import './auth';
5
- import './features';
6
- import './store';
7
- import './core';
8
- import './auth';
9
- import type { StreamLayerSDK } from './core';
10
- export type { CoreStoreInterface } from './store/store';
11
- export { StreamLayerSDK };
12
- export interface StreamLayerContext {
13
- transport: Transport;
14
- }
15
3
  export type StreamLayerInstance = avvio.mixedInstance<StreamLayerContext>;
16
- export type StreamLayerPlugin = (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
4
+ export type StreamLayerPlugin = (instance: StreamLayerContext, opts: unknown, done: DoneFn) => void;
5
+ type DoneFn = Function;
17
6
  export declare function StreamLayer(sdkKey: string): avvio.Avvio<StreamLayerContext>;
7
+ export {};
package/src/index.js CHANGED
@@ -1,36 +1,28 @@
1
- import { Transport } from '@streamlayer/sdk-web-api';
1
+ import { transport } from '@streamlayer/sdk-web-api';
2
+ import { core } from '@streamlayer/sdk-web-core';
3
+ import { features } from '@streamlayer/sdk-web-features';
2
4
  import avvio from 'avvio';
3
- import './store';
4
- import './auth';
5
- import { features } from './features';
6
- import { store } from './store';
7
- import { core } from './core';
8
- import { bypass } from './auth';
5
+ import { store } from '@streamlayer/sdk-web-core/store';
6
+ import { bypass } from '@streamlayer/sdk-web-core/auth';
7
+ import { notifications } from '@streamlayer/sdk-web-core/notifications';
9
8
  export function StreamLayer(sdkKey) {
10
- const streamLayer = avvio(Object.create(null), {
11
- autostart: false
12
- });
9
+ const streamLayer = avvio(Object.create(null), { autostart: false });
13
10
  streamLayer.use(core);
14
- streamLayer.use((instance, opts, done)=>{
15
- instance.transport = new Transport();
16
- instance.transport.setSdkKey(sdkKey);
17
- done();
18
- });
11
+ streamLayer.use(transport, { sdkKey });
19
12
  streamLayer.use(store);
20
13
  streamLayer.use(bypass);
21
14
  streamLayer.use(features);
22
- // eslint-disable-next-line @typescript-eslint/ban-types
23
- streamLayer.after(async (err, context, done)=>{
15
+ streamLayer.use(notifications);
16
+ streamLayer.after(async (err, context, done) => {
24
17
  if (err) {
25
18
  throw err;
26
19
  }
27
20
  await context.sdk.initializeApp();
28
21
  done();
29
22
  });
30
- streamLayer.onClose(()=>{
23
+ streamLayer.onClose(() => {
31
24
  console.log('close');
32
25
  });
33
26
  return streamLayer;
34
27
  }
35
-
36
28
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/sdk-web/src/index.ts"],"sourcesContent":["import { Transport } from '@streamlayer/sdk-web-api'\n\nimport avvio from 'avvio'\n\nimport './store'\nimport './auth'\n\nimport { features } from './features'\nimport { store } from './store'\nimport { core } from './core'\nimport { bypass } from './auth'\nimport type { StreamLayerSDK } from './core'\nexport type { CoreStoreInterface } from './store/store'\n\nexport { StreamLayerSDK }\n\nexport interface StreamLayerContext {\n transport: Transport\n}\n\nexport type StreamLayerInstance = avvio.mixedInstance<StreamLayerContext>\n\nexport type StreamLayerPlugin = (instance: StreamLayerContext, opts: unknown, done: () => void) => void\n\nexport function StreamLayer(sdkKey: string) {\n const streamLayer = avvio<StreamLayerContext>(Object.create(null), { autostart: false })\n\n streamLayer.use(core)\n\n streamLayer.use((instance: StreamLayerContext, opts: unknown, done: () => void) => {\n instance.transport = new Transport()\n instance.transport.setSdkKey(sdkKey)\n done()\n })\n\n streamLayer.use(store)\n streamLayer.use(bypass)\n streamLayer.use(features)\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n streamLayer.after(async (err: Error, context: StreamLayerContext, done: Function) => {\n if (err) {\n throw err\n }\n\n await context.sdk.initializeApp()\n done()\n })\n\n streamLayer.onClose(() => {\n console.log('close')\n })\n\n return streamLayer\n}\n"],"names":["Transport","avvio","features","store","core","bypass","StreamLayer","sdkKey","streamLayer","Object","create","autostart","use","instance","opts","done","transport","setSdkKey","after","err","context","sdk","initializeApp","onClose","console","log"],"mappings":"AAAA,SAASA,SAAS,QAAQ,2BAA0B;AAEpD,OAAOC,WAAW,QAAO;AAEzB,OAAO,UAAS;AAChB,OAAO,SAAQ;AAEf,SAASC,QAAQ,QAAQ,aAAY;AACrC,SAASC,KAAK,QAAQ,UAAS;AAC/B,SAASC,IAAI,QAAQ,SAAQ;AAC7B,SAASC,MAAM,QAAQ,SAAQ;AAc/B,OAAO,SAASC,YAAYC,MAAc;IACxC,MAAMC,cAAcP,MAA0BQ,OAAOC,MAAM,CAAC,OAAO;QAAEC,WAAW;IAAM;IAEtFH,YAAYI,GAAG,CAACR;IAEhBI,YAAYI,GAAG,CAAC,CAACC,UAA8BC,MAAeC;QAC5DF,SAASG,SAAS,GAAG,IAAIhB;QACzBa,SAASG,SAAS,CAACC,SAAS,CAACV;QAC7BQ;IACF;IAEAP,YAAYI,GAAG,CAACT;IAChBK,YAAYI,GAAG,CAACP;IAChBG,YAAYI,GAAG,CAACV;IAEhB,wDAAwD;IACxDM,YAAYU,KAAK,CAAC,OAAOC,KAAYC,SAA6BL;QAChE,IAAII,KAAK;YACP,MAAMA;QACR;QAEA,MAAMC,QAAQC,GAAG,CAACC,aAAa;QAC/BP;IACF;IAEAP,YAAYe,OAAO,CAAC;QAClBC,QAAQC,GAAG,CAAC;IACd;IAEA,OAAOjB;AACT"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/sdk-web/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AASvE,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,WAAW,GAAG,KAAK,CAAqB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;IAExF,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAErB,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACtB,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACvB,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACzB,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAE9B,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,GAAU,EAAE,OAA2B,EAAE,IAAY,EAAE,EAAE;QAChF,IAAI,GAAG,EAAE;YACP,MAAM,GAAG,CAAA;SACV;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAA;QACjC,IAAI,EAAE,CAAA;IACR,CAAC,CAAC,CAAA;IAEF,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -1,22 +0,0 @@
1
- import { AbstractAuthenticationProvider } from '@streamlayer/sdk-web-interfaces';
2
- import { Transport } from '@streamlayer/sdk-web-api';
3
- import { CoreStore } from '../../store/store';
4
- /**
5
- * An authorization service manages user access by providing login, logout,
6
- * authentication checks, and the ability to revoke access.
7
- * Subscribed to $userStore and automatically updates the auth header for the Transport.
8
- */
9
- export declare class BypassAuth extends AbstractAuthenticationProvider {
10
- private readonly $coreStore;
11
- private readonly transport;
12
- private readonly $bypassLogin;
13
- constructor(store: CoreStore, transport: Transport);
14
- me: () => Promise<import("@streamlayer/sl-eslib/users/users_common_pb").User | undefined>;
15
- login: (schema: string, userKey: string) => Promise<import("@streamlayer/sl-eslib/users/users_common_pb").User | undefined>;
16
- isAuthenticated: () => Promise<import("@streamlayer/sl-eslib/users/users_common_pb").User | undefined>;
17
- logout: () => void;
18
- /**
19
- * subscribe to user store and set auth header to the Transport on user update
20
- */
21
- private subscribe;
22
- }
@@ -1,49 +0,0 @@
1
- import { AbstractAuthenticationProvider } from '@streamlayer/sdk-web-interfaces';
2
- import { queries } from '@streamlayer/sdk-web-api';
3
- /**
4
- * An authorization service manages user access by providing login, logout,
5
- * authentication checks, and the ability to revoke access.
6
- * Subscribed to $userStore and automatically updates the auth header for the Transport.
7
- */ export class BypassAuth extends AbstractAuthenticationProvider {
8
- constructor(store, transport){
9
- super();
10
- this.me = async ()=>{
11
- const res = await this.$coreStore.getValues().user.getValue();
12
- return res?.data;
13
- };
14
- this.login = async (schema, userKey)=>{
15
- this.$coreStore.getValues().userKey.setValue(userKey);
16
- await this.$bypassLogin.mutate({
17
- schema,
18
- userKey,
19
- init: false
20
- });
21
- return this.me();
22
- };
23
- this.isAuthenticated = ()=>{
24
- return this.me();
25
- };
26
- this.logout = ()=>{
27
- this.$coreStore.getValues().user.setValue();
28
- this.$coreStore.getValues().userKey.setValue();
29
- this.$coreStore.getValues().userToken.setValue();
30
- this.transport.setAuth('');
31
- };
32
- /**
33
- * subscribe to user store and set auth header to the Transport on user update
34
- */ this.subscribe = ()=>{
35
- this.$bypassLogin.subscribe((user, key)=>{
36
- if (key === 'data') {
37
- this.transport.setAuth(user?.data?.meta?.jwt);
38
- this.$coreStore.getValues().userToken.setValue(user?.data?.meta?.jwt);
39
- }
40
- });
41
- };
42
- this.$coreStore = store;
43
- this.transport = transport;
44
- this.$bypassLogin = queries.$bypassLogin(this.transport);
45
- this.subscribe();
46
- }
47
- }
48
-
49
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/sdk-web/src/auth/bypass/index.ts"],"sourcesContent":["import { AbstractAuthenticationProvider } from '@streamlayer/sdk-web-interfaces'\nimport { queries, Transport } from '@streamlayer/sdk-web-api'\n\nimport { CoreStore } from '../../store/store'\n\n/**\n * An authorization service manages user access by providing login, logout,\n * authentication checks, and the ability to revoke access.\n * Subscribed to $userStore and automatically updates the auth header for the Transport.\n */\nexport class BypassAuth extends AbstractAuthenticationProvider {\n private readonly $coreStore: CoreStore\n private readonly transport: Transport\n private readonly $bypassLogin: ReturnType<typeof queries.$bypassLogin>\n\n constructor(store: CoreStore, transport: Transport) {\n super()\n this.$coreStore = store\n this.transport = transport\n this.$bypassLogin = queries.$bypassLogin(this.transport)\n\n this.subscribe()\n }\n\n public me = async () => {\n const res = await this.$coreStore.getValues().user.getValue()\n\n return res?.data\n }\n\n public login = async (schema: string, userKey: string) => {\n this.$coreStore.getValues().userKey.setValue(userKey)\n\n await this.$bypassLogin.mutate({ schema, userKey, init: false })\n\n return this.me()\n }\n\n public isAuthenticated = () => {\n return this.me()\n }\n\n public logout = () => {\n this.$coreStore.getValues().user.setValue()\n this.$coreStore.getValues().userKey.setValue()\n this.$coreStore.getValues().userToken.setValue()\n this.transport.setAuth('')\n }\n\n /**\n * subscribe to user store and set auth header to the Transport on user update\n */\n private subscribe = () => {\n this.$bypassLogin.subscribe((user, key) => {\n if (key === 'data') {\n this.transport.setAuth(user?.data?.meta?.jwt)\n this.$coreStore.getValues().userToken.setValue(user?.data?.meta?.jwt)\n }\n })\n }\n}\n"],"names":["AbstractAuthenticationProvider","queries","BypassAuth","constructor","store","transport","me","res","$coreStore","getValues","user","getValue","data","login","schema","userKey","setValue","$bypassLogin","mutate","init","isAuthenticated","logout","userToken","setAuth","subscribe","key","meta","jwt"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,kCAAiC;AAChF,SAASC,OAAO,QAAmB,2BAA0B;AAI7D;;;;CAIC,GACD,OAAO,MAAMC,mBAAmBF;IAK9BG,YAAYC,KAAgB,EAAEC,SAAoB,CAAE;QAClD,KAAK;aAQAC,KAAK;YACV,MAAMC,MAAM,MAAM,IAAI,CAACC,UAAU,CAACC,SAAS,GAAGC,IAAI,CAACC,QAAQ;YAE3D,OAAOJ,KAAKK;QACd;aAEOC,QAAQ,OAAOC,QAAgBC;YACpC,IAAI,CAACP,UAAU,CAACC,SAAS,GAAGM,OAAO,CAACC,QAAQ,CAACD;YAE7C,MAAM,IAAI,CAACE,YAAY,CAACC,MAAM,CAAC;gBAAEJ;gBAAQC;gBAASI,MAAM;YAAM;YAE9D,OAAO,IAAI,CAACb,EAAE;QAChB;aAEOc,kBAAkB;YACvB,OAAO,IAAI,CAACd,EAAE;QAChB;aAEOe,SAAS;YACd,IAAI,CAACb,UAAU,CAACC,SAAS,GAAGC,IAAI,CAACM,QAAQ;YACzC,IAAI,CAACR,UAAU,CAACC,SAAS,GAAGM,OAAO,CAACC,QAAQ;YAC5C,IAAI,CAACR,UAAU,CAACC,SAAS,GAAGa,SAAS,CAACN,QAAQ;YAC9C,IAAI,CAACX,SAAS,CAACkB,OAAO,CAAC;QACzB;QAEA;;GAEC,QACOC,YAAY;YAClB,IAAI,CAACP,YAAY,CAACO,SAAS,CAAC,CAACd,MAAMe;gBACjC,IAAIA,QAAQ,QAAQ;oBAClB,IAAI,CAACpB,SAAS,CAACkB,OAAO,CAACb,MAAME,MAAMc,MAAMC;oBACzC,IAAI,CAACnB,UAAU,CAACC,SAAS,GAAGa,SAAS,CAACN,QAAQ,CAACN,MAAME,MAAMc,MAAMC;gBACnE;YACF;QACF;QA1CE,IAAI,CAACnB,UAAU,GAAGJ;QAClB,IAAI,CAACC,SAAS,GAAGA;QACjB,IAAI,CAACY,YAAY,GAAGhB,QAAQgB,YAAY,CAAC,IAAI,CAACZ,SAAS;QAEvD,IAAI,CAACmB,SAAS;IAChB;AAsCF"}
@@ -1,15 +0,0 @@
1
- import { StreamLayerContext } from '../';
2
- import { BypassAuth } from './bypass';
3
- declare module '../core' {
4
- interface StreamLayerSDK {
5
- authorizationBypass: (schema: string, userKey: string) => Promise<void>;
6
- logout: () => void;
7
- isUserAuthorized: BypassAuth['isAuthenticated'];
8
- }
9
- }
10
- declare module '../' {
11
- interface StreamLayerContext {
12
- auth: BypassAuth;
13
- }
14
- }
15
- export declare const bypass: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
package/src/auth/index.js DELETED
@@ -1,16 +0,0 @@
1
- import { BypassAuth } from './bypass';
2
- export const bypass = (instance, opts, done)=>{
3
- instance.auth = new BypassAuth(instance.store, instance.transport);
4
- instance.sdk.authorizationBypass = async (schema, userKey)=>{
5
- await instance.auth.login(schema, userKey);
6
- };
7
- instance.sdk.logout = ()=>{
8
- instance.auth.logout();
9
- };
10
- instance.sdk.isUserAuthorized = ()=>{
11
- return instance.auth.isAuthenticated();
12
- };
13
- done();
14
- };
15
-
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/auth/index.ts"],"sourcesContent":["import { StreamLayerContext } from '../'\n\nimport { BypassAuth } from './bypass'\n\ndeclare module '../core' {\n interface StreamLayerSDK {\n authorizationBypass: (schema: string, userKey: string) => Promise<void>\n logout: () => void\n isUserAuthorized: BypassAuth['isAuthenticated']\n }\n}\n\ndeclare module '../' {\n interface StreamLayerContext {\n auth: BypassAuth\n }\n}\n\nexport const bypass = (instance: StreamLayerContext, opts: unknown, done: () => void) => {\n instance.auth = new BypassAuth(instance.store, instance.transport)\n\n instance.sdk.authorizationBypass = async (schema: string, userKey: string) => {\n await instance.auth.login(schema, userKey)\n }\n\n instance.sdk.logout = () => {\n instance.auth.logout()\n }\n\n instance.sdk.isUserAuthorized = () => {\n return instance.auth.isAuthenticated()\n }\n\n done()\n}\n"],"names":["BypassAuth","bypass","instance","opts","done","auth","store","transport","sdk","authorizationBypass","schema","userKey","login","logout","isUserAuthorized","isAuthenticated"],"mappings":"AAEA,SAASA,UAAU,QAAQ,WAAU;AAgBrC,OAAO,MAAMC,SAAS,CAACC,UAA8BC,MAAeC;IAClEF,SAASG,IAAI,GAAG,IAAIL,WAAWE,SAASI,KAAK,EAAEJ,SAASK,SAAS;IAEjEL,SAASM,GAAG,CAACC,mBAAmB,GAAG,OAAOC,QAAgBC;QACxD,MAAMT,SAASG,IAAI,CAACO,KAAK,CAACF,QAAQC;IACpC;IAEAT,SAASM,GAAG,CAACK,MAAM,GAAG;QACpBX,SAASG,IAAI,CAACQ,MAAM;IACtB;IAEAX,SAASM,GAAG,CAACM,gBAAgB,GAAG;QAC9B,OAAOZ,SAASG,IAAI,CAACU,eAAe;IACtC;IAEAX;AACF,EAAC"}
package/src/core.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { StreamLayerContext } from './';
2
- export interface StreamLayerSDK {
3
- initializeApp: () => Promise<{
4
- enabled?: boolean;
5
- err?: string;
6
- }>;
7
- disableApp: () => void;
8
- invalidateSettings: () => void;
9
- createEventSession: (providerStreamId: string) => void;
10
- }
11
- declare module './' {
12
- interface StreamLayerContext {
13
- sdk: StreamLayerSDK;
14
- }
15
- }
16
- /**
17
- * The main application instance is the core of a application. It includes:
18
- * Store: Manages data storage.
19
- * Public Methods: Provides a way to interact with the application.
20
- * Connect Features: Handles communication between components throught store.
21
- * Connect Transport: Handles communication with api.
22
- * Dependency Injection: Incorporates other necessary instances.
23
- * Error Handling: Manages errors and logs them.
24
- * Security: Implements authentication and authorization.
25
- */
26
- export declare const core: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
package/src/core.js DELETED
@@ -1,59 +0,0 @@
1
- import { CoreStatus } from './store/store';
2
- /**
3
- * The main application instance is the core of a application. It includes:
4
- * Store: Manages data storage.
5
- * Public Methods: Provides a way to interact with the application.
6
- * Connect Features: Handles communication between components throught store.
7
- * Connect Transport: Handles communication with api.
8
- * Dependency Injection: Incorporates other necessary instances.
9
- * Error Handling: Manages errors and logs them.
10
- * Security: Implements authentication and authorization.
11
- */ export const core = (instance, opts, done)=>{
12
- instance.sdk = Object.create(null);
13
- /**
14
- * On initialize we subscribe to store and launch listeners
15
- * that activate data downloading over the network
16
- */ instance.sdk.initializeApp = async ()=>{
17
- instance.storeSubscribe();
18
- instance.stores.enabled.setValue('on');
19
- instance.stores.status.setValue(CoreStatus.INITIALIZATION);
20
- try {
21
- const organizationSettings = await instance.stores.organizationSettings.getValue();
22
- if (organizationSettings) {
23
- instance.stores.status.setValue(CoreStatus.READY);
24
- return {
25
- enabled: !!organizationSettings
26
- };
27
- }
28
- instance.stores.status.setValue(CoreStatus.FAILED);
29
- return {
30
- err: 'failed'
31
- };
32
- } catch (err) {
33
- instance.stores.enabled.setValue();
34
- instance.stores.status.setValue(CoreStatus.FAILED);
35
- return {
36
- err: `${err}`
37
- };
38
- }
39
- };
40
- instance.sdk.disableApp = ()=>{
41
- instance.stores.enabled.setValue();
42
- instance.stores.status.setValue(CoreStatus.DISABLED);
43
- instance.storeUnsubscribe();
44
- };
45
- instance.sdk.invalidateSettings = ()=>{
46
- instance.transport.nanoquery.utils.invalidateKeys(()=>{
47
- return true;
48
- });
49
- };
50
- /**
51
- * Configure the "event id" using the "provider," enabling subscribed stores to
52
- * trigger their logic in response to a new event.
53
- */ instance.sdk.createEventSession = (providerStreamId)=>{
54
- instance.stores.providerStreamId.setValue(providerStreamId);
55
- };
56
- done();
57
- };
58
-
59
- //# sourceMappingURL=core.js.map
package/src/core.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../packages/sdk-web/src/core.ts"],"sourcesContent":["import { CoreStatus } from './store/store'\n\nimport { StreamLayerContext } from './'\n\nexport interface StreamLayerSDK {\n initializeApp: () => Promise<{ enabled?: boolean; err?: string }>\n disableApp: () => void\n invalidateSettings: () => void\n createEventSession: (providerStreamId: string) => void\n}\n\ndeclare module './' {\n interface StreamLayerContext {\n sdk: StreamLayerSDK\n }\n}\n\n/**\n * The main application instance is the core of a application. It includes:\n * Store: Manages data storage.\n * Public Methods: Provides a way to interact with the application.\n * Connect Features: Handles communication between components throught store.\n * Connect Transport: Handles communication with api.\n * Dependency Injection: Incorporates other necessary instances.\n * Error Handling: Manages errors and logs them.\n * Security: Implements authentication and authorization.\n */\nexport const core = (instance: StreamLayerContext, opts: unknown, done: () => void) => {\n instance.sdk = Object.create(null)\n\n /**\n * On initialize we subscribe to store and launch listeners\n * that activate data downloading over the network\n */\n instance.sdk.initializeApp = async () => {\n instance.storeSubscribe()\n instance.stores.enabled.setValue('on')\n instance.stores.status.setValue(CoreStatus.INITIALIZATION)\n\n try {\n const organizationSettings = await instance.stores.organizationSettings.getValue()\n\n if (organizationSettings) {\n instance.stores.status.setValue(CoreStatus.READY)\n\n return { enabled: !!organizationSettings }\n }\n\n instance.stores.status.setValue(CoreStatus.FAILED)\n\n return { err: 'failed' }\n } catch (err) {\n instance.stores.enabled.setValue()\n instance.stores.status.setValue(CoreStatus.FAILED)\n\n return { err: `${err}` }\n }\n }\n\n instance.sdk.disableApp = () => {\n instance.stores.enabled.setValue()\n instance.stores.status.setValue(CoreStatus.DISABLED)\n instance.storeUnsubscribe()\n }\n\n instance.sdk.invalidateSettings = () => {\n instance.transport.nanoquery.utils.invalidateKeys(() => {\n return true\n })\n }\n\n /**\n * Configure the \"event id\" using the \"provider,\" enabling subscribed stores to\n * trigger their logic in response to a new event.\n */\n instance.sdk.createEventSession = (providerStreamId: string) => {\n instance.stores.providerStreamId.setValue(providerStreamId)\n }\n\n done()\n}\n"],"names":["CoreStatus","core","instance","opts","done","sdk","Object","create","initializeApp","storeSubscribe","stores","enabled","setValue","status","INITIALIZATION","organizationSettings","getValue","READY","FAILED","err","disableApp","DISABLED","storeUnsubscribe","invalidateSettings","transport","nanoquery","utils","invalidateKeys","createEventSession","providerStreamId"],"mappings":"AAAA,SAASA,UAAU,QAAQ,gBAAe;AAiB1C;;;;;;;;;CASC,GACD,OAAO,MAAMC,OAAO,CAACC,UAA8BC,MAAeC;IAChEF,SAASG,GAAG,GAAGC,OAAOC,MAAM,CAAC;IAE7B;;;GAGC,GACDL,SAASG,GAAG,CAACG,aAAa,GAAG;QAC3BN,SAASO,cAAc;QACvBP,SAASQ,MAAM,CAACC,OAAO,CAACC,QAAQ,CAAC;QACjCV,SAASQ,MAAM,CAACG,MAAM,CAACD,QAAQ,CAACZ,WAAWc,cAAc;QAEzD,IAAI;YACF,MAAMC,uBAAuB,MAAMb,SAASQ,MAAM,CAACK,oBAAoB,CAACC,QAAQ;YAEhF,IAAID,sBAAsB;gBACxBb,SAASQ,MAAM,CAACG,MAAM,CAACD,QAAQ,CAACZ,WAAWiB,KAAK;gBAEhD,OAAO;oBAAEN,SAAS,CAAC,CAACI;gBAAqB;YAC3C;YAEAb,SAASQ,MAAM,CAACG,MAAM,CAACD,QAAQ,CAACZ,WAAWkB,MAAM;YAEjD,OAAO;gBAAEC,KAAK;YAAS;QACzB,EAAE,OAAOA,KAAK;YACZjB,SAASQ,MAAM,CAACC,OAAO,CAACC,QAAQ;YAChCV,SAASQ,MAAM,CAACG,MAAM,CAACD,QAAQ,CAACZ,WAAWkB,MAAM;YAEjD,OAAO;gBAAEC,KAAK,CAAC,EAAEA,IAAI,CAAC;YAAC;QACzB;IACF;IAEAjB,SAASG,GAAG,CAACe,UAAU,GAAG;QACxBlB,SAASQ,MAAM,CAACC,OAAO,CAACC,QAAQ;QAChCV,SAASQ,MAAM,CAACG,MAAM,CAACD,QAAQ,CAACZ,WAAWqB,QAAQ;QACnDnB,SAASoB,gBAAgB;IAC3B;IAEApB,SAASG,GAAG,CAACkB,kBAAkB,GAAG;QAChCrB,SAASsB,SAAS,CAACC,SAAS,CAACC,KAAK,CAACC,cAAc,CAAC;YAChD,OAAO;QACT;IACF;IAEA;;;GAGC,GACDzB,SAASG,GAAG,CAACuB,kBAAkB,GAAG,CAACC;QACjC3B,SAASQ,MAAM,CAACmB,gBAAgB,CAACjB,QAAQ,CAACiB;IAC5C;IAEAzB;AACF,EAAC"}
@@ -1,3 +0,0 @@
1
- export declare const environment: {
2
- production: boolean;
3
- };
@@ -1,7 +0,0 @@
1
- // This file can be replaced during build by using the `fileReplacements` array.
2
- // When building for production, this file is replaced with `environment.prod.ts`.
3
- export const environment = {
4
- production: false
5
- };
6
-
7
- //# sourceMappingURL=environment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/environments/environment.ts"],"sourcesContent":["// This file can be replaced during build by using the `fileReplacements` array.\n// When building for production, this file is replaced with `environment.prod.ts`.\n\nexport const environment = {\n production: false,\n}\n"],"names":["environment","production"],"mappings":"AAAA,gFAAgF;AAChF,kFAAkF;AAElF,OAAO,MAAMA,cAAc;IACzBC,YAAY;AACd,EAAC"}
@@ -1,3 +0,0 @@
1
- export declare const environment: {
2
- production: boolean;
3
- };
@@ -1,5 +0,0 @@
1
- export const environment = {
2
- production: true
3
- };
4
-
5
- //# sourceMappingURL=environment.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/environments/environment.prod.ts"],"sourcesContent":["export const environment = {\n production: true,\n}\n"],"names":["environment","production"],"mappings":"AAAA,OAAO,MAAMA,cAAc;IACzBC,YAAY;AACd,EAAC"}
@@ -1,21 +0,0 @@
1
- import { FeatureConfig } from '@streamlayer/sdk-web-types';
2
- import { AbstractFeature, FeatureSource } from '@streamlayer/sdk-web-interfaces';
3
- import { StreamLayerContext } from '../';
4
- export declare class Feature extends AbstractFeature {
5
- }
6
- export declare const initFeature: (overlay: FeatureConfig, source: FeatureSource) => Feature;
7
- export { FeatureSource } from '@streamlayer/sdk-web-interfaces';
8
- declare module '../' {
9
- interface StreamLayerContext {
10
- features: Map<FeatureConfig['name'], Feature>;
11
- initFeature: (overlay: FeatureConfig, source?: FeatureSource) => void;
12
- updateFeature: (overlay: FeatureConfig, source: FeatureSource) => void;
13
- destroyFeature: (overlay: FeatureConfig) => void;
14
- }
15
- }
16
- declare module '../core' {
17
- interface StreamLayerSDK {
18
- getFeatures: () => Map<string, Feature>;
19
- }
20
- }
21
- export declare const features: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
@@ -1,26 +0,0 @@
1
- import { AbstractFeature, FeatureSource } from '@streamlayer/sdk-web-interfaces';
2
- export class Feature extends AbstractFeature {
3
- }
4
- export const initFeature = (overlay, source)=>{
5
- return new Feature(overlay, source);
6
- };
7
- export { FeatureSource } from '@streamlayer/sdk-web-interfaces';
8
- export const features = (instance, opts, done)=>{
9
- instance.features = new Map();
10
- instance.sdk.getFeatures = ()=>instance.features;
11
- /**
12
- * A distinct object instance is created and initialized for each overlay.
13
- */ instance.initFeature = (overlay, source = FeatureSource.ORGANIZATION)=>{
14
- const feature = initFeature(overlay, source);
15
- instance.features.set(overlay.name, feature);
16
- };
17
- instance.updateFeature = (overlay, source)=>{
18
- instance.features.get(overlay.name)?.update(overlay, source);
19
- };
20
- instance.destroyFeature = (overlay)=>{
21
- instance.features.delete(overlay.name);
22
- };
23
- done();
24
- };
25
-
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/features/index.ts"],"sourcesContent":["import { FeatureConfig } from '@streamlayer/sdk-web-types'\nimport { AbstractFeature, FeatureSource } from '@streamlayer/sdk-web-interfaces'\n\nimport { StreamLayerContext } from '../'\n\nexport class Feature extends AbstractFeature {}\n\nexport const initFeature = (overlay: FeatureConfig, source: FeatureSource) => {\n return new Feature(overlay, source)\n}\n\nexport { FeatureSource } from '@streamlayer/sdk-web-interfaces'\n\ndeclare module '../' {\n interface StreamLayerContext {\n features: Map<FeatureConfig['name'], Feature>\n initFeature: (overlay: FeatureConfig, source?: FeatureSource) => void\n updateFeature: (overlay: FeatureConfig, source: FeatureSource) => void\n destroyFeature: (overlay: FeatureConfig) => void\n }\n}\n\ndeclare module '../core' {\n interface StreamLayerSDK {\n getFeatures: () => Map<string, Feature>\n }\n}\n\nexport const features = (instance: StreamLayerContext, opts: unknown, done: () => void) => {\n instance.features = new Map<string, Feature>()\n\n instance.sdk.getFeatures = () => instance.features\n\n /**\n * A distinct object instance is created and initialized for each overlay.\n */\n instance.initFeature = (overlay: FeatureConfig, source: FeatureSource = FeatureSource.ORGANIZATION) => {\n const feature = initFeature(overlay, source)\n\n instance.features.set(overlay.name, feature)\n }\n\n instance.updateFeature = (overlay: FeatureConfig, source: FeatureSource) => {\n instance.features.get(overlay.name)?.update(overlay, source)\n }\n\n instance.destroyFeature = (overlay: FeatureConfig) => {\n instance.features.delete(overlay.name)\n }\n\n done()\n}\n"],"names":["AbstractFeature","FeatureSource","Feature","initFeature","overlay","source","features","instance","opts","done","Map","sdk","getFeatures","ORGANIZATION","feature","set","name","updateFeature","get","update","destroyFeature","delete"],"mappings":"AACA,SAASA,eAAe,EAAEC,aAAa,QAAQ,kCAAiC;AAIhF,OAAO,MAAMC,gBAAgBF;AAAiB;AAE9C,OAAO,MAAMG,cAAc,CAACC,SAAwBC;IAClD,OAAO,IAAIH,QAAQE,SAASC;AAC9B,EAAC;AAED,SAASJ,aAAa,QAAQ,kCAAiC;AAiB/D,OAAO,MAAMK,WAAW,CAACC,UAA8BC,MAAeC;IACpEF,SAASD,QAAQ,GAAG,IAAII;IAExBH,SAASI,GAAG,CAACC,WAAW,GAAG,IAAML,SAASD,QAAQ;IAElD;;GAEC,GACDC,SAASJ,WAAW,GAAG,CAACC,SAAwBC,SAAwBJ,cAAcY,YAAY;QAChG,MAAMC,UAAUX,YAAYC,SAASC;QAErCE,SAASD,QAAQ,CAACS,GAAG,CAACX,QAAQY,IAAI,EAAEF;IACtC;IAEAP,SAASU,aAAa,GAAG,CAACb,SAAwBC;QAChDE,SAASD,QAAQ,CAACY,GAAG,CAACd,QAAQY,IAAI,GAAGG,OAAOf,SAASC;IACvD;IAEAE,SAASa,cAAc,GAAG,CAAChB;QACzBG,SAASD,QAAQ,CAACe,MAAM,CAACjB,QAAQY,IAAI;IACvC;IAEAP;AACF,EAAC"}
@@ -1,19 +0,0 @@
1
- import { StreamLayerContext } from '../';
2
- import { CoreStore, StoreObj } from './store';
3
- declare module '../core' {
4
- interface StreamLayerSDK {
5
- sdkStore: () => ReturnType<CoreStore['getStore']>;
6
- }
7
- }
8
- declare module '../' {
9
- interface StreamLayerContext {
10
- store: CoreStore;
11
- stores: StoreObj;
12
- storeSubscribe: () => void;
13
- storeUnsubscribe: () => void;
14
- }
15
- }
16
- /**
17
- * store plugin, connect store to sdk
18
- */
19
- export declare const store: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
@@ -1,59 +0,0 @@
1
- import { FeatureSource } from '@streamlayer/sdk-web-interfaces';
2
- import { CoreStore } from './store';
3
- /**
4
- * store plugin, connect store to sdk
5
- */ export const store = (instance, opts, done)=>{
6
- instance.store = new CoreStore(instance.transport);
7
- instance.stores = instance.store.getValues();
8
- instance.sdk.sdkStore = ()=>instance.store.getStore();
9
- /**
10
- * Essentially, features and stores establish subscriptions to other stores
11
- * based on their dependencies. In certain cases, specific logic is
12
- * directly invoked in response to changes in the store.
13
- */ instance.storeSubscribe = ()=>{
14
- const processSettings = (source, settings)=>{
15
- if (!settings?.overlays) return;
16
- const featureNames = new Set();
17
- for (const overlay of settings.overlays){
18
- const featureName = overlay.name;
19
- featureNames.add(featureName);
20
- instance.initFeature(overlay, source);
21
- }
22
- };
23
- const subscribes = {
24
- /**
25
- * During the initial SDK initialization, it's imperative to initialize features first,
26
- * followed by their direct subscriptions to store fields.
27
- * This section is currently in development, and it's
28
- * essential to implement checks to determine whether a feature
29
- * has already been initialized. If it has, events related to
30
- * that feature should be skipped. Conversely, if a feature is
31
- * missing in the new settings, it should be deinitialized.
32
- */ organizationSettings: (orgSettings)=>{
33
- if (orgSettings.data) {
34
- try {
35
- processSettings(FeatureSource.ORGANIZATION, orgSettings.data);
36
- } catch (err) {
37
- console.log(err);
38
- }
39
- }
40
- },
41
- streamSettings: (streamSettings)=>{
42
- if (streamSettings.data) {
43
- try {
44
- processSettings(FeatureSource.STREAM, streamSettings.data);
45
- } catch (err) {
46
- console.log(err);
47
- }
48
- }
49
- }
50
- };
51
- instance.store.subscribe(subscribes);
52
- };
53
- instance.storeUnsubscribe = ()=>{
54
- instance.store.unsubscribe();
55
- };
56
- done();
57
- };
58
-
59
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/store/index.ts"],"sourcesContent":["import { FeatureSource } from '@streamlayer/sdk-web-interfaces'\n\nimport { StreamLayerContext } from '../'\n\nimport { CoreStore, StoreListeners, StoreObj, CoreStoreInterface } from './store'\n\ndeclare module '../core' {\n interface StreamLayerSDK {\n sdkStore: () => ReturnType<CoreStore['getStore']>\n }\n}\n\ndeclare module '../' {\n interface StreamLayerContext {\n store: CoreStore\n stores: StoreObj\n storeSubscribe: () => void\n storeUnsubscribe: () => void\n }\n}\n\n/**\n * store plugin, connect store to sdk\n */\nexport const store = (instance: StreamLayerContext, opts: unknown, done: () => void) => {\n instance.store = new CoreStore(instance.transport)\n instance.stores = instance.store.getValues()\n\n instance.sdk.sdkStore = () => instance.store.getStore()\n\n /**\n * Essentially, features and stores establish subscriptions to other stores\n * based on their dependencies. In certain cases, specific logic is\n * directly invoked in response to changes in the store.\n */\n instance.storeSubscribe = () => {\n const processSettings = (\n source: FeatureSource,\n settings: CoreStoreInterface['organizationSettings'] | CoreStoreInterface['streamSettings'],\n ) => {\n if (!settings?.overlays) return\n\n const featureNames = new Set()\n\n for (const overlay of settings.overlays) {\n const featureName = overlay.name\n\n featureNames.add(featureName)\n\n instance.initFeature(overlay, source)\n }\n }\n\n const subscribes: Partial<StoreListeners> = {\n /**\n * During the initial SDK initialization, it's imperative to initialize features first,\n * followed by their direct subscriptions to store fields.\n * This section is currently in development, and it's\n * essential to implement checks to determine whether a feature\n * has already been initialized. If it has, events related to\n * that feature should be skipped. Conversely, if a feature is\n * missing in the new settings, it should be deinitialized.\n */\n organizationSettings: (orgSettings) => {\n if (orgSettings.data) {\n try {\n processSettings(FeatureSource.ORGANIZATION, orgSettings.data)\n } catch (err) {\n console.log(err)\n }\n }\n },\n streamSettings: (streamSettings) => {\n if (streamSettings.data) {\n try {\n processSettings(FeatureSource.STREAM, streamSettings.data)\n } catch (err) {\n console.log(err)\n }\n }\n },\n }\n\n instance.store.subscribe(subscribes)\n }\n\n instance.storeUnsubscribe = () => {\n instance.store.unsubscribe()\n }\n\n done()\n}\n"],"names":["FeatureSource","CoreStore","store","instance","opts","done","transport","stores","getValues","sdk","sdkStore","getStore","storeSubscribe","processSettings","source","settings","overlays","featureNames","Set","overlay","featureName","name","add","initFeature","subscribes","organizationSettings","orgSettings","data","ORGANIZATION","err","console","log","streamSettings","STREAM","subscribe","storeUnsubscribe","unsubscribe"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kCAAiC;AAI/D,SAASC,SAAS,QAAsD,UAAS;AAiBjF;;CAEC,GACD,OAAO,MAAMC,QAAQ,CAACC,UAA8BC,MAAeC;IACjEF,SAASD,KAAK,GAAG,IAAID,UAAUE,SAASG,SAAS;IACjDH,SAASI,MAAM,GAAGJ,SAASD,KAAK,CAACM,SAAS;IAE1CL,SAASM,GAAG,CAACC,QAAQ,GAAG,IAAMP,SAASD,KAAK,CAACS,QAAQ;IAErD;;;;GAIC,GACDR,SAASS,cAAc,GAAG;QACxB,MAAMC,kBAAkB,CACtBC,QACAC;YAEA,IAAI,CAACA,UAAUC,UAAU;YAEzB,MAAMC,eAAe,IAAIC;YAEzB,KAAK,MAAMC,WAAWJ,SAASC,QAAQ,CAAE;gBACvC,MAAMI,cAAcD,QAAQE,IAAI;gBAEhCJ,aAAaK,GAAG,CAACF;gBAEjBjB,SAASoB,WAAW,CAACJ,SAASL;YAChC;QACF;QAEA,MAAMU,aAAsC;YAC1C;;;;;;;;OAQC,GACDC,sBAAsB,CAACC;gBACrB,IAAIA,YAAYC,IAAI,EAAE;oBACpB,IAAI;wBACFd,gBAAgBb,cAAc4B,YAAY,EAAEF,YAAYC,IAAI;oBAC9D,EAAE,OAAOE,KAAK;wBACZC,QAAQC,GAAG,CAACF;oBACd;gBACF;YACF;YACAG,gBAAgB,CAACA;gBACf,IAAIA,eAAeL,IAAI,EAAE;oBACvB,IAAI;wBACFd,gBAAgBb,cAAciC,MAAM,EAAED,eAAeL,IAAI;oBAC3D,EAAE,OAAOE,KAAK;wBACZC,QAAQC,GAAG,CAACF;oBACd;gBACF;YACF;QACF;QAEA1B,SAASD,KAAK,CAACgC,SAAS,CAACV;IAC3B;IAEArB,SAASgC,gBAAgB,GAAG;QAC1BhC,SAASD,KAAK,CAACkC,WAAW;IAC5B;IAEA/B;AACF,EAAC"}
@@ -1,133 +0,0 @@
1
- import type { OrganizationAdvertising, StreamSettings, User, UserSettings } from '@streamlayer/sdk-web-types';
2
- import { AbstractStore, SingleStore, mergeStores, ApiStore } from '@streamlayer/sdk-web-interfaces';
3
- import { queries, Transport } from '@streamlayer/sdk-web-api';
4
- export declare enum CoreStatus {
5
- DISABLED = "disabled",
6
- INITIALIZATION = "initialization",
7
- READY = "ready",
8
- FAILED = "failed",
9
- SUSPENDED = "suspended"
10
- }
11
- export interface CoreStoreInterface {
12
- enabled?: 'on';
13
- status: string;
14
- userKey?: string;
15
- userToken?: string;
16
- organizationSettings?: ReturnType<ReturnType<typeof queries.$organizationSettings>['get']>['data'];
17
- organizationAdvertising?: OrganizationAdvertising;
18
- streamSettings?: StreamSettings;
19
- user?: User;
20
- userSettings?: UserSettings;
21
- providerStreamId?: string;
22
- slStreamId?: string;
23
- }
24
- declare const initializeStore: (transport: Transport) => {
25
- readonly enabled: SingleStore<unknown, import("nanostores").WritableAtom<"on" | undefined>>;
26
- readonly status: SingleStore<unknown, import("nanostores").WritableAtom<CoreStatus | undefined>>;
27
- readonly providerStreamId: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
28
- readonly slStreamId: ApiStore<string | undefined, import("@nanostores/query").FetcherStore<string | undefined>>;
29
- readonly streamSettings: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").StreamSettings | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").StreamSettings | undefined>>;
30
- readonly user: ApiStore<import("@streamlayer/sl-eslib/users/users_pb").MeResponse | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/users/users_pb").MeResponse | undefined>>;
31
- readonly userKey: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
32
- readonly userToken: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
33
- readonly userSettings: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/client/client_pb").ClientSettings | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/client/client_pb").ClientSettings | undefined>>;
34
- readonly organizationSettings: ApiStore<{
35
- id: string;
36
- overlays?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").SdkOverlay[] | undefined;
37
- buttonIcon?: string | undefined;
38
- tinodeHost?: string | undefined;
39
- audience?: string | undefined;
40
- name?: string | undefined;
41
- provider?: string | undefined;
42
- primaryColor?: string | undefined;
43
- secondaryColor?: string | undefined;
44
- moderationPrimaryColor?: string | undefined;
45
- linkShareIcon?: string | undefined;
46
- linkShareText?: string | undefined;
47
- brandDefaults?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").BrandDefaults | undefined;
48
- pub?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").JWK | undefined;
49
- getstream?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").GetStreamSettingsClient | undefined;
50
- } | null | undefined, import("@nanostores/query").FetcherStore<{
51
- id: string;
52
- overlays?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").SdkOverlay[] | undefined;
53
- buttonIcon?: string | undefined;
54
- tinodeHost?: string | undefined;
55
- audience?: string | undefined;
56
- name?: string | undefined;
57
- provider?: string | undefined;
58
- primaryColor?: string | undefined;
59
- secondaryColor?: string | undefined;
60
- moderationPrimaryColor?: string | undefined;
61
- linkShareIcon?: string | undefined;
62
- linkShareText?: string | undefined;
63
- brandDefaults?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").BrandDefaults | undefined;
64
- pub?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").JWK | undefined;
65
- getstream?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").GetStreamSettingsClient | undefined;
66
- } | null | undefined>>;
67
- readonly organizationAdvertising: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").Advertising | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").Advertising | undefined>>;
68
- };
69
- export type StoreObj = ReturnType<typeof initializeStore>;
70
- export type CoreStores = {
71
- [Index in keyof StoreObj]: ReturnType<StoreObj[Index]['getStore']>;
72
- };
73
- export type CoreStoreInstance = ReturnType<typeof mergeStores<StoreObj>>;
74
- /**
75
- * @description main app store
76
- */
77
- export declare class CoreStore extends AbstractStore<CoreStoreInstance> {
78
- private stores;
79
- constructor(transport: Transport);
80
- getValue(): unknown;
81
- getValues(): {
82
- readonly enabled: SingleStore<unknown, import("nanostores").WritableAtom<"on" | undefined>>;
83
- readonly status: SingleStore<unknown, import("nanostores").WritableAtom<CoreStatus | undefined>>;
84
- readonly providerStreamId: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
85
- readonly slStreamId: ApiStore<string | undefined, import("@nanostores/query").FetcherStore<string | undefined>>;
86
- readonly streamSettings: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").StreamSettings | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").StreamSettings | undefined>>;
87
- readonly user: ApiStore<import("@streamlayer/sl-eslib/users/users_pb").MeResponse | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/users/users_pb").MeResponse | undefined>>;
88
- readonly userKey: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
89
- readonly userToken: SingleStore<unknown, import("nanostores").WritableAtom<string | undefined>>;
90
- readonly userSettings: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/client/client_pb").ClientSettings | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/client/client_pb").ClientSettings | undefined>>;
91
- readonly organizationSettings: ApiStore<{
92
- id: string;
93
- overlays?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").SdkOverlay[] | undefined;
94
- buttonIcon?: string | undefined;
95
- tinodeHost?: string | undefined;
96
- audience?: string | undefined;
97
- name?: string | undefined;
98
- provider?: string | undefined;
99
- primaryColor?: string | undefined;
100
- secondaryColor?: string | undefined;
101
- moderationPrimaryColor?: string | undefined;
102
- linkShareIcon?: string | undefined;
103
- linkShareText?: string | undefined;
104
- brandDefaults?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").BrandDefaults | undefined;
105
- pub?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").JWK | undefined;
106
- getstream?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").GetStreamSettingsClient | undefined;
107
- } | null | undefined, import("@nanostores/query").FetcherStore<{
108
- id: string;
109
- overlays?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").SdkOverlay[] | undefined;
110
- buttonIcon?: string | undefined;
111
- tinodeHost?: string | undefined;
112
- audience?: string | undefined;
113
- name?: string | undefined;
114
- provider?: string | undefined;
115
- primaryColor?: string | undefined;
116
- secondaryColor?: string | undefined;
117
- moderationPrimaryColor?: string | undefined;
118
- linkShareIcon?: string | undefined;
119
- linkShareText?: string | undefined;
120
- brandDefaults?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").BrandDefaults | undefined;
121
- pub?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").JWK | undefined;
122
- getstream?: import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").GetStreamSettingsClient | undefined;
123
- } | null | undefined>>;
124
- readonly organizationAdvertising: ApiStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").Advertising | undefined, import("@nanostores/query").FetcherStore<import("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb").Advertising | undefined>>;
125
- };
126
- setValue(): void;
127
- subscribe: (subscribes: Partial<StoreListeners>) => void;
128
- unsubscribe: () => void;
129
- }
130
- export type StoreListeners = {
131
- [Index in keyof StoreObj]: Parameters<StoreObj[Index]['subscribe']>[0];
132
- };
133
- export {};
@@ -1,83 +0,0 @@
1
- import { AbstractStore, createSingleStore, SingleStore, mergeStores, ApiStore } from '@streamlayer/sdk-web-interfaces';
2
- import { queries } from '@streamlayer/sdk-web-api';
3
- export var CoreStatus;
4
- (function(CoreStatus) {
5
- CoreStatus["DISABLED"] = "disabled";
6
- CoreStatus["INITIALIZATION"] = "initialization";
7
- CoreStatus["READY"] = "ready";
8
- CoreStatus["FAILED"] = "failed";
9
- CoreStatus["SUSPENDED"] = "suspended";
10
- })(CoreStatus || (CoreStatus = {}));
11
- const initializeStore = (transport)=>{
12
- // sdk toggle
13
- const enabled = new SingleStore(createSingleStore());
14
- // sdk status
15
- const status = new SingleStore(createSingleStore("disabled"));
16
- // host user key
17
- const userKey = new SingleStore(createSingleStore());
18
- // sl user key
19
- const userToken = new SingleStore(createSingleStore());
20
- // host event id
21
- const providerStreamId = new SingleStore(createSingleStore());
22
- // sl event id
23
- const slStreamId = new ApiStore(queries.$retrieveEventId(providerStreamId.getStore(), transport), (data)=>data?.data);
24
- // sl user data
25
- const user = new ApiStore(queries.$user(userToken.getStore(), transport));
26
- // sl user settings
27
- const userSettings = new ApiStore(queries.$userSettings(userToken.getStore(), transport));
28
- // sl stream settings
29
- const streamSettings = new ApiStore(queries.$streamSettings(slStreamId.getAtomStore(), transport));
30
- // sl organization settings
31
- const organizationSettings = new ApiStore(queries.$organizationSettings(enabled.getStore(), transport), (data)=>data?.data?.id);
32
- // sl organization advertising
33
- const organizationAdvertising = new ApiStore(queries.$organizationAdvertising(organizationSettings.getAtomStore(), transport));
34
- return {
35
- enabled,
36
- status,
37
- providerStreamId,
38
- slStreamId,
39
- streamSettings,
40
- user,
41
- userKey,
42
- userToken,
43
- userSettings,
44
- organizationSettings,
45
- organizationAdvertising
46
- };
47
- };
48
- /**
49
- * @description main app store
50
- */ export class CoreStore extends AbstractStore {
51
- constructor(transport){
52
- const storesObj = initializeStore(transport);
53
- const store = mergeStores(storesObj);
54
- super(store);
55
- this.subscribe = (subscribes)=>{
56
- let storeKey;
57
- for(storeKey in this.stores){
58
- const fn = subscribes[storeKey];
59
- if (storeKey in subscribes && fn !== undefined) {
60
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
61
- // @ts-ignore
62
- this.stores[storeKey].subscribe(subscribes[storeKey]);
63
- }
64
- }
65
- };
66
- this.unsubscribe = ()=>{
67
- const store = this.getStore();
68
- return store.off();
69
- };
70
- this.stores = storesObj;
71
- }
72
- getValue() {
73
- throw new Error('Not implemented');
74
- }
75
- getValues() {
76
- return this.stores;
77
- }
78
- setValue() {
79
- throw new Error('Not implemented');
80
- }
81
- }
82
-
83
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../packages/sdk-web/src/store/store.ts"],"sourcesContent":["import type { OrganizationAdvertising, StreamSettings, User, UserSettings } from '@streamlayer/sdk-web-types'\nimport { AbstractStore, createSingleStore, SingleStore, mergeStores, ApiStore } from '@streamlayer/sdk-web-interfaces'\nimport { queries, Transport, GetApiResponseType } from '@streamlayer/sdk-web-api'\n\nexport enum CoreStatus {\n DISABLED = 'disabled',\n INITIALIZATION = 'initialization',\n READY = 'ready',\n FAILED = 'failed',\n SUSPENDED = 'suspended',\n}\n\nexport interface CoreStoreInterface {\n enabled?: 'on'\n status: string\n userKey?: string\n userToken?: string\n organizationSettings?: ReturnType<ReturnType<typeof queries.$organizationSettings>['get']>['data']\n organizationAdvertising?: OrganizationAdvertising\n streamSettings?: StreamSettings\n user?: User\n userSettings?: UserSettings\n providerStreamId?: string\n slStreamId?: string\n}\n\nconst initializeStore = (transport: Transport) => {\n // sdk toggle\n const enabled = new SingleStore(createSingleStore<'on'>())\n // sdk status\n const status = new SingleStore(createSingleStore<CoreStatus>(CoreStatus.DISABLED))\n // host user key\n const userKey = new SingleStore(createSingleStore<string>())\n // sl user key\n const userToken = new SingleStore(createSingleStore<string>())\n // host event id\n const providerStreamId = new SingleStore(createSingleStore<string>())\n // sl event id\n const slStreamId = new ApiStore<GetApiResponseType<typeof queries.$retrieveEventId>>(\n queries.$retrieveEventId(providerStreamId.getStore(), transport),\n (data) => data?.data,\n )\n // sl user data\n const user = new ApiStore<GetApiResponseType<typeof queries.$user>>(queries.$user(userToken.getStore(), transport))\n // sl user settings\n const userSettings = new ApiStore<GetApiResponseType<typeof queries.$userSettings>>(\n queries.$userSettings(userToken.getStore(), transport),\n )\n // sl stream settings\n const streamSettings = new ApiStore<GetApiResponseType<typeof queries.$streamSettings>>(\n queries.$streamSettings(slStreamId.getAtomStore(), transport),\n )\n // sl organization settings\n const organizationSettings = new ApiStore<GetApiResponseType<typeof queries.$organizationSettings>>(\n queries.$organizationSettings(enabled.getStore(), transport),\n (data) => data?.data?.id,\n )\n // sl organization advertising\n const organizationAdvertising = new ApiStore<GetApiResponseType<typeof queries.$organizationAdvertising>>(\n queries.$organizationAdvertising(organizationSettings.getAtomStore(), transport),\n )\n\n return {\n enabled,\n status,\n providerStreamId,\n slStreamId,\n streamSettings,\n user,\n userKey,\n userToken,\n userSettings,\n organizationSettings,\n organizationAdvertising,\n } as const\n}\n\nexport type StoreObj = ReturnType<typeof initializeStore>\nexport type CoreStores = {\n [Index in keyof StoreObj]: ReturnType<StoreObj[Index]['getStore']>\n}\nexport type CoreStoreInstance = ReturnType<typeof mergeStores<StoreObj>>\n\n/**\n * @description main app store\n */\nexport class CoreStore extends AbstractStore<CoreStoreInstance> {\n private stores: StoreObj\n\n constructor(transport: Transport) {\n const storesObj = initializeStore(transport)\n const store = mergeStores<typeof storesObj>(storesObj)\n\n super(store)\n\n this.stores = storesObj\n }\n\n getValue(): unknown {\n throw new Error('Not implemented')\n }\n\n getValues() {\n return this.stores\n }\n\n setValue() {\n throw new Error('Not implemented')\n }\n\n subscribe = (subscribes: Partial<StoreListeners>) => {\n let storeKey: keyof StoreObj\n\n for (storeKey in this.stores) {\n const fn = subscribes[storeKey]\n\n if (storeKey in subscribes && fn !== undefined) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.stores[storeKey].subscribe(subscribes[storeKey])\n }\n }\n }\n\n unsubscribe = () => {\n const store = this.getStore()\n\n return store.off()\n }\n}\n\nexport type StoreListeners = {\n [Index in keyof StoreObj]: Parameters<StoreObj[Index]['subscribe']>[0]\n}\n"],"names":["AbstractStore","createSingleStore","SingleStore","mergeStores","ApiStore","queries","CoreStatus","initializeStore","transport","enabled","status","userKey","userToken","providerStreamId","slStreamId","$retrieveEventId","getStore","data","user","$user","userSettings","$userSettings","streamSettings","$streamSettings","getAtomStore","organizationSettings","$organizationSettings","id","organizationAdvertising","$organizationAdvertising","CoreStore","constructor","storesObj","store","subscribe","subscribes","storeKey","stores","fn","undefined","unsubscribe","off","getValue","Error","getValues","setValue"],"mappings":"AACA,SAASA,aAAa,EAAEC,iBAAiB,EAAEC,WAAW,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,kCAAiC;AACtH,SAASC,OAAO,QAAuC,2BAA0B;;UAErEC;;;;;;GAAAA,eAAAA;AAsBZ,MAAMC,kBAAkB,CAACC;IACvB,aAAa;IACb,MAAMC,UAAU,IAAIP,YAAYD;IAChC,aAAa;IACb,MAAMS,SAAS,IAAIR,YAAYD;IAC/B,gBAAgB;IAChB,MAAMU,UAAU,IAAIT,YAAYD;IAChC,cAAc;IACd,MAAMW,YAAY,IAAIV,YAAYD;IAClC,gBAAgB;IAChB,MAAMY,mBAAmB,IAAIX,YAAYD;IACzC,cAAc;IACd,MAAMa,aAAa,IAAIV,SACrBC,QAAQU,gBAAgB,CAACF,iBAAiBG,QAAQ,IAAIR,YACtD,CAACS,OAASA,MAAMA;IAElB,eAAe;IACf,MAAMC,OAAO,IAAId,SAAmDC,QAAQc,KAAK,CAACP,UAAUI,QAAQ,IAAIR;IACxG,mBAAmB;IACnB,MAAMY,eAAe,IAAIhB,SACvBC,QAAQgB,aAAa,CAACT,UAAUI,QAAQ,IAAIR;IAE9C,qBAAqB;IACrB,MAAMc,iBAAiB,IAAIlB,SACzBC,QAAQkB,eAAe,CAACT,WAAWU,YAAY,IAAIhB;IAErD,2BAA2B;IAC3B,MAAMiB,uBAAuB,IAAIrB,SAC/BC,QAAQqB,qBAAqB,CAACjB,QAAQO,QAAQ,IAAIR,YAClD,CAACS,OAASA,MAAMA,MAAMU;IAExB,8BAA8B;IAC9B,MAAMC,0BAA0B,IAAIxB,SAClCC,QAAQwB,wBAAwB,CAACJ,qBAAqBD,YAAY,IAAIhB;IAGxE,OAAO;QACLC;QACAC;QACAG;QACAC;QACAQ;QACAJ;QACAP;QACAC;QACAQ;QACAK;QACAG;IACF;AACF;AAQA;;CAEC,GACD,OAAO,MAAME,kBAAkB9B;IAG7B+B,YAAYvB,SAAoB,CAAE;QAChC,MAAMwB,YAAYzB,gBAAgBC;QAClC,MAAMyB,QAAQ9B,YAA8B6B;QAE5C,KAAK,CAACC;aAiBRC,YAAY,CAACC;YACX,IAAIC;YAEJ,IAAKA,YAAY,IAAI,CAACC,MAAM,CAAE;gBAC5B,MAAMC,KAAKH,UAAU,CAACC,SAAS;gBAE/B,IAAIA,YAAYD,cAAcG,OAAOC,WAAW;oBAC9C,6DAA6D;oBAC7D,aAAa;oBACb,IAAI,CAACF,MAAM,CAACD,SAAS,CAACF,SAAS,CAACC,UAAU,CAACC,SAAS;gBACtD;YACF;QACF;aAEAI,cAAc;YACZ,MAAMP,QAAQ,IAAI,CAACjB,QAAQ;YAE3B,OAAOiB,MAAMQ,GAAG;QAClB;QAjCE,IAAI,CAACJ,MAAM,GAAGL;IAChB;IAEAU,WAAoB;QAClB,MAAM,IAAIC,MAAM;IAClB;IAEAC,YAAY;QACV,OAAO,IAAI,CAACP,MAAM;IACpB;IAEAQ,WAAW;QACT,MAAM,IAAIF,MAAM;IAClB;AAqBF"}