@streamlayer/sdk-web-core 1.19.2 → 1.20.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.
package/lib/index.js CHANGED
@@ -56,28 +56,32 @@ export const core = (instance, opts, done) => {
56
56
  * On initialize we subscribe to store and launch listeners
57
57
  * that activate data downloading over the network
58
58
  */
59
- instance.sdk.initializeApp = async (contextConfig) => {
59
+ instance.sdk.initializeApp = (contextConfig) => {
60
60
  instance.contextConfig = contextConfig;
61
61
  if (instance.stores.enabled.get() === 'on') {
62
- return { enabled: true };
62
+ return Promise.resolve({ enabled: true });
63
63
  }
64
64
  instance.storeSubscribe();
65
65
  instance.stores.enabled.setValue('on');
66
66
  instance.stores.status.setValue(CoreStatus.INITIALIZATION);
67
- try {
68
- const organizationSettings = await instance.stores.organizationSettings.getValue();
69
- if (organizationSettings) {
70
- instance.stores.status.setValue(CoreStatus.READY);
71
- return { enabled: !!organizationSettings };
72
- }
73
- instance.stores.status.setValue(CoreStatus.FAILED);
74
- return { err: 'failed' };
75
- }
76
- catch (err) {
77
- instance.stores.enabled.setValue();
78
- instance.stores.status.setValue(CoreStatus.FAILED);
79
- return { err: `${err}` };
80
- }
67
+ return new Promise((resolve) => {
68
+ window.requestAnimationFrame(async () => {
69
+ try {
70
+ const organizationSettings = await instance.stores.organizationSettings.getValue();
71
+ if (organizationSettings) {
72
+ instance.stores.status.setValue(CoreStatus.READY);
73
+ return resolve({ enabled: !!organizationSettings });
74
+ }
75
+ instance.stores.status.setValue(CoreStatus.FAILED);
76
+ return resolve({ err: 'failed' });
77
+ }
78
+ catch (err) {
79
+ instance.stores.enabled.setValue();
80
+ instance.stores.status.setValue(CoreStatus.FAILED);
81
+ return resolve({ err: `${err}` });
82
+ }
83
+ });
84
+ });
81
85
  };
82
86
  instance.sdk.disableApp = () => {
83
87
  if (instance.stores.enabled.get() !== 'on') {
package/lib/ui/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export type UIState = {
21
21
  appBanner?: boolean;
22
22
  onboardingNotification?: boolean;
23
23
  exposedPauseAd?: boolean;
24
+ polymarket?: boolean;
24
25
  };
25
26
  export interface UIContext {
26
27
  disableApp: () => void;
@@ -32,6 +33,8 @@ export interface UIContext {
32
33
  onContentActivate?: OnContentActivateCallback;
33
34
  enableExposedPauseAd: () => void;
34
35
  disableExposedPauseAd: () => void;
36
+ enablePolymarket: () => void;
37
+ disablePolymarket: () => void;
35
38
  }
36
39
  declare module '@streamlayer/sdk-web-interfaces' {
37
40
  interface StreamLayerContext {
@@ -43,6 +46,7 @@ declare module '@streamlayer/sdk-web-interfaces' {
43
46
  }
44
47
  interface StreamLayerSDK {
45
48
  uiState: ReturnType<typeof createMapStore<UIState>>;
49
+ uiHandlers: Pick<UIContext, 'enablePolymarket' | 'disablePolymarket'>;
46
50
  }
47
51
  }
48
52
  export declare const ui: (instance: StreamLayerContext, opts: {
package/lib/ui/index.js CHANGED
@@ -30,6 +30,12 @@ export const ui = (instance, opts, done) => {
30
30
  disableOnboardingNotification: function () {
31
31
  instance.sdk.uiState.setKey('onboardingNotification', false);
32
32
  },
33
+ enablePolymarket: function () {
34
+ instance.sdk.uiState.setKey('polymarket', true);
35
+ },
36
+ disablePolymarket: function () {
37
+ instance.sdk.uiState.setKey('polymarket', false);
38
+ },
33
39
  enableApp: function () {
34
40
  instance.sdk.uiState.set({
35
41
  app: true,
@@ -59,6 +65,10 @@ export const ui = (instance, opts, done) => {
59
65
  });
60
66
  },
61
67
  };
68
+ instance.sdk.uiHandlers = {
69
+ enablePolymarket: instance.ui.enablePolymarket,
70
+ disablePolymarket: instance.ui.disablePolymarket,
71
+ };
62
72
  if (opts.onContentActivate) {
63
73
  instance.ui.onContentActivate = opts.onContentActivate;
64
74
  }
package/package.json CHANGED
@@ -7,11 +7,11 @@
7
7
  "@nanostores/query": "^0.3.4",
8
8
  "@streamlayer/sl-eslib": "^5.228.0",
9
9
  "nanostores": "^1.1.0",
10
- "@streamlayer/sdk-web-api": "^1.15.2",
11
- "@streamlayer/sdk-web-interfaces": "^1.9.2",
12
- "@streamlayer/sdk-web-logger": "^1.0.96",
13
- "@streamlayer/sdk-web-storage": "^1.0.96",
14
- "@streamlayer/sdk-web-types": "^1.16.11"
10
+ "@streamlayer/sdk-web-api": "^1.15.4",
11
+ "@streamlayer/sdk-web-interfaces": "^1.9.4",
12
+ "@streamlayer/sdk-web-logger": "^1.0.98",
13
+ "@streamlayer/sdk-web-storage": "^1.0.98",
14
+ "@streamlayer/sdk-web-types": "^1.16.13"
15
15
  },
16
16
  "exports": {
17
17
  ".": {
@@ -50,7 +50,7 @@
50
50
  "default": "./lib/ui/index.js"
51
51
  }
52
52
  },
53
- "version": "1.19.2",
53
+ "version": "1.20.1",
54
54
  "type": "module",
55
55
  "main": "./lib/index.js",
56
56
  "module": "./lib/index.js",