@inappstory/slide-api 0.0.2 → 0.0.4

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/dist/index.cjs CHANGED
@@ -1,5 +1,225 @@
1
1
  'use strict';
2
2
 
3
+ const CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER = `___CTOR_ARGS___`;
4
+ const CONSTRUCTOR_ARGUMENTS_SYMBOL = Symbol.for(CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER);
5
+
6
+ /**
7
+ * A Dependency-Injection container that holds services and can produce instances of them as required.
8
+ * It mimics reflection by parsing the app at compile-time and supporting the generic-reflection syntax.
9
+ * @author Frederik Wessberg
10
+ */
11
+ class DIContainer {
12
+ /**
13
+ * A map between interface names and the services that should be dependency injected
14
+ */
15
+ constructorArguments = new Map();
16
+ /**
17
+ * A Map between identifying names for services and their IRegistrationRecords.
18
+ */
19
+ serviceRegistry = new Map();
20
+ /**
21
+ * A map between identifying names for services and concrete instances of their implementation.
22
+ */
23
+ instances = new Map();
24
+ registerSingleton(newExpression, options) {
25
+ if (options == null) {
26
+ throw new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
27
+ }
28
+ if (newExpression == null) {
29
+ return this.register("SINGLETON", newExpression, options);
30
+ }
31
+ else {
32
+ return this.register("SINGLETON", newExpression, options);
33
+ }
34
+ }
35
+ registerTransient(newExpression, options) {
36
+ if (options == null) {
37
+ throw new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
38
+ }
39
+ if (newExpression == null) {
40
+ return this.register("TRANSIENT", newExpression, options);
41
+ }
42
+ else {
43
+ return this.register("TRANSIENT", newExpression, options);
44
+ }
45
+ }
46
+ /**
47
+ * Gets an instance of the service matching the interface given as a generic type parameter.
48
+ * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the
49
+ * generic interface name.
50
+ *
51
+ * You should not pass any options to the method if using the compiler. It will do that automatically.
52
+ */
53
+ get(options) {
54
+ if (options == null) {
55
+ throw new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
56
+ }
57
+ return this.constructInstance(options);
58
+ }
59
+ /**
60
+ * Returns true if a service has been registered matching the interface given as a generic type parameter.
61
+ * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the
62
+ * generic interface name.
63
+ *
64
+ * You should not pass any options to the method if using the compiler. It will do that automatically.
65
+ */
66
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
67
+ has(options) {
68
+ if (options == null) {
69
+ throw new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
70
+ }
71
+ return this.serviceRegistry.has(options.identifier);
72
+ }
73
+ register(kind, newExpression, options) {
74
+ // Take all of the constructor arguments for the implementation
75
+ const implementationArguments = "implementation" in options &&
76
+ options.implementation != null &&
77
+ options.implementation[CONSTRUCTOR_ARGUMENTS_SYMBOL] != null
78
+ ? options.implementation[CONSTRUCTOR_ARGUMENTS_SYMBOL]
79
+ : [];
80
+ this.constructorArguments.set(options.identifier, implementationArguments);
81
+ this.serviceRegistry.set(options.identifier, "implementation" in options && options.implementation != null
82
+ ? { ...options, kind }
83
+ : { ...options, kind, newExpression: newExpression });
84
+ }
85
+ /**
86
+ * Returns true if an instance exists that matches the given identifier.
87
+ */
88
+ hasInstance(identifier) {
89
+ return this.getInstance(identifier) != null;
90
+ }
91
+ /**
92
+ * Gets the cached instance, if any, associated with the given identifier.
93
+ */
94
+ getInstance(identifier) {
95
+ const instance = this.instances.get(identifier);
96
+ return instance == null ? null : instance;
97
+ }
98
+ /**
99
+ * Gets an IRegistrationRecord associated with the given identifier.
100
+ */
101
+ getRegistrationRecord({ identifier, parentChain, }) {
102
+ const record = this.serviceRegistry.get(identifier);
103
+ if (record == null) {
104
+ throw new ReferenceError(`${this.constructor.name} could not find a service for identifier: "${identifier}". ${parentChain == null || parentChain.length < 1
105
+ ? ""
106
+ : `It is required by the service: '${parentChain
107
+ .map((parent) => parent.identifier)
108
+ .join(" -> ")}'.`} Remember to register it as a service!`);
109
+ }
110
+ return record;
111
+ }
112
+ /**
113
+ * Caches the given instance so that it can be retrieved in the future.
114
+ */
115
+ setInstance(identifier, instance) {
116
+ this.instances.set(identifier, instance);
117
+ return instance;
118
+ }
119
+ /**
120
+ * Gets a lazy reference to another service
121
+ */
122
+ getLazyIdentifier(lazyPointer) {
123
+ return (new Proxy({}, { get: (_, key) => lazyPointer()[key] }));
124
+ }
125
+ /**
126
+ * Constructs a new instance of the given identifier and returns it.
127
+ * It checks the constructor arguments and injects any services it might depend on recursively.
128
+ */
129
+ constructInstance({ identifier, parentChain = [], }) {
130
+ const registrationRecord = this.getRegistrationRecord({
131
+ identifier,
132
+ parentChain,
133
+ });
134
+ // If an instance already exists (and it is a singleton), return that one
135
+ if (this.hasInstance(identifier) &&
136
+ registrationRecord.kind === "SINGLETON") {
137
+ return this.getInstance(identifier);
138
+ }
139
+ // Otherwise, instantiate a new one
140
+ let instance;
141
+ const me = {
142
+ identifier,
143
+ ref: this.getLazyIdentifier(() => instance),
144
+ };
145
+ // If a user-provided new-expression has been provided, invoke that to get an instance.
146
+ if ("newExpression" in registrationRecord) {
147
+ if (typeof registrationRecord.newExpression !== "function") {
148
+ throw new TypeError(`Could not instantiate the service with the identifier: '${registrationRecord.identifier}': You provided a custom instantiation argument, but it wasn't of type function. It has to be a function that returns whatever should be used as an instance of the Service!`);
149
+ }
150
+ try {
151
+ instance = registrationRecord.newExpression();
152
+ }
153
+ catch (ex) {
154
+ throw new Error(`Could not instantiate the service with the identifier: '${registrationRecord.identifier}': When you registered the service, you provided a custom instantiation function, but it threw an exception when it was run!`);
155
+ }
156
+ }
157
+ else {
158
+ // Find the arguments for the identifier
159
+ const mappedArgs = this.constructorArguments.get(identifier);
160
+ if (mappedArgs == null) {
161
+ throw new ReferenceError(`${this.constructor.name} could not find constructor arguments for the service: '${identifier}'. Have you registered it as a service?`);
162
+ }
163
+ // Instantiate all of the argument services (or re-use them if they were registered as singletons)
164
+ const instanceArgs = mappedArgs.map((dep) => {
165
+ if (dep === undefined)
166
+ return undefined;
167
+ const matchedParent = parentChain.find((parent) => parent.identifier === dep);
168
+ if (matchedParent != null)
169
+ return matchedParent.ref;
170
+ return this.constructInstance({
171
+ identifier: dep,
172
+ parentChain: [...parentChain, me],
173
+ });
174
+ });
175
+ try {
176
+ // Try to construct an instance with 'new' and if it fails, call the implementation directly.
177
+ const newable = registrationRecord.implementation;
178
+ instance = new newable(...instanceArgs);
179
+ }
180
+ catch (ex) {
181
+ if (registrationRecord.implementation == null) {
182
+ throw new ReferenceError(`${this.constructor.name} could not construct a new service of kind: ${identifier}. Reason: No implementation was given!`);
183
+ }
184
+ const constructable = registrationRecord.implementation;
185
+ // Try without 'new' and call the implementation as a function.
186
+ instance = constructable(...instanceArgs);
187
+ }
188
+ }
189
+ return registrationRecord.kind === "SINGLETON"
190
+ ? this.setInstance(identifier, instance)
191
+ : instance;
192
+ }
193
+ }
194
+ const DI_COMPILER_ERROR_HINT = `Note: You must use DI-Compiler (https://github.com/wessberg/di-compiler) for this library to work correctly. Please consult the readme for instructions on how to install and configure it for your project.`;
195
+
196
+ const container = new DIContainer();
197
+
198
+ class WidgetsService {
199
+ _env;
200
+ _sdkApi;
201
+ constructor(_env, _sdkApi) {
202
+ this._env = _env;
203
+ this._sdkApi = _sdkApi;
204
+ }
205
+ get env() {
206
+ return this._env;
207
+ }
208
+ get sdkApi() {
209
+ return this._sdkApi;
210
+ }
211
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`]; }
212
+ }
213
+
214
+ container.registerSingleton(undefined, { identifier: `WidgetsService`, implementation: WidgetsService });
215
+
216
+ // import '../adapters/dateTimeSource/composition';
217
+ // import '../adapters/uuidGenerator/composition';
218
+ // import '../effects/eventHandler/composition';
219
+ // import '../effects/logger/composition';
220
+ // import '../effects/timer/composition';
221
+ container.registerSingleton(() => window, { identifier: `Window` });
222
+
3
223
  const arPrototype = Array.prototype;
4
224
  const obPrototype = Object.prototype;
5
225
  const slice = arPrototype.slice;
@@ -813,231 +1033,103 @@ const animationApi = {
813
1033
  },
814
1034
  };
815
1035
 
816
- const CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER = `___CTOR_ARGS___`;
817
- const CONSTRUCTOR_ARGUMENTS_SYMBOL = Symbol.for(CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER);
818
-
819
- /**
820
- * A Dependency-Injection container that holds services and can produce instances of them as required.
821
- * It mimics reflection by parsing the app at compile-time and supporting the generic-reflection syntax.
822
- * @author Frederik Wessberg
823
- */
824
- class DIContainer {
825
- /**
826
- * A map between interface names and the services that should be dependency injected
827
- */
828
- constructorArguments = new Map();
829
- /**
830
- * A Map between identifying names for services and their IRegistrationRecords.
831
- */
832
- serviceRegistry = new Map();
833
- /**
834
- * A map between identifying names for services and concrete instances of their implementation.
835
- */
836
- instances = new Map();
837
- registerSingleton(newExpression, options) {
838
- if (options == null) {
839
- throw new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
840
- }
841
- if (newExpression == null) {
842
- return this.register("SINGLETON", newExpression, options);
843
- }
844
- else {
845
- return this.register("SINGLETON", newExpression, options);
846
- }
1036
+ class EsModuleSdkApi {
1037
+ sdkBinding;
1038
+ constructor(sdkBinding) {
1039
+ this.sdkBinding = sdkBinding;
847
1040
  }
848
- registerTransient(newExpression, options) {
849
- if (options == null) {
850
- throw new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
851
- }
852
- if (newExpression == null) {
853
- return this.register("TRANSIENT", newExpression, options);
854
- }
855
- else {
856
- return this.register("TRANSIENT", newExpression, options);
857
- }
1041
+ getStoryServerData(storyId) {
1042
+ return this.sdkBinding().getStoryServerData(storyId);
858
1043
  }
859
- /**
860
- * Gets an instance of the service matching the interface given as a generic type parameter.
861
- * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the
862
- * generic interface name.
863
- *
864
- * You should not pass any options to the method if using the compiler. It will do that automatically.
865
- */
866
- get(options) {
867
- if (options == null) {
868
- throw new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
869
- }
870
- return this.constructInstance(options);
1044
+ getSlideDuration(storyId, slideIndex) {
1045
+ return this.sdkBinding().getSlideDuration(storyId, slideIndex);
871
1046
  }
872
- /**
873
- * Returns true if a service has been registered matching the interface given as a generic type parameter.
874
- * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the
875
- * generic interface name.
876
- *
877
- * You should not pass any options to the method if using the compiler. It will do that automatically.
878
- */
879
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
880
- has(options) {
881
- if (options == null) {
882
- throw new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);
883
- }
884
- return this.serviceRegistry.has(options.identifier);
1047
+ showNextSlide(duration) {
1048
+ this.sdkBinding().showNextSlide(duration);
885
1049
  }
886
- register(kind, newExpression, options) {
887
- // Take all of the constructor arguments for the implementation
888
- const implementationArguments = "implementation" in options &&
889
- options.implementation != null &&
890
- options.implementation[CONSTRUCTOR_ARGUMENTS_SYMBOL] != null
891
- ? options.implementation[CONSTRUCTOR_ARGUMENTS_SYMBOL]
892
- : [];
893
- this.constructorArguments.set(options.identifier, implementationArguments);
894
- this.serviceRegistry.set(options.identifier, "implementation" in options && options.implementation != null
895
- ? { ...options, kind }
896
- : { ...options, kind, newExpression: newExpression });
1050
+ sendStatisticEvent(name, data, devPayload) {
1051
+ this.sdkBinding().sendStatisticEvent(name, data, devPayload);
897
1052
  }
898
- /**
899
- * Returns true if an instance exists that matches the given identifier.
900
- */
901
- hasInstance(identifier) {
902
- return this.getInstance(identifier) != null;
1053
+ getStoryLocalData() {
1054
+ return this.sdkBinding().getStoryLocalData();
903
1055
  }
904
- /**
905
- * Gets the cached instance, if any, associated with the given identifier.
906
- */
907
- getInstance(identifier) {
908
- const instance = this.instances.get(identifier);
909
- return instance == null ? null : instance;
1056
+ isExistsShowLayer() {
1057
+ return true;
910
1058
  }
911
- /**
912
- * Gets an IRegistrationRecord associated with the given identifier.
913
- */
914
- getRegistrationRecord({ identifier, parentChain, }) {
915
- const record = this.serviceRegistry.get(identifier);
916
- if (record == null) {
917
- throw new ReferenceError(`${this.constructor.name} could not find a service for identifier: "${identifier}". ${parentChain == null || parentChain.length < 1
918
- ? ""
919
- : `It is required by the service: '${parentChain
920
- .map((parent) => parent.identifier)
921
- .join(" -> ")}'.`} Remember to register it as a service!`);
922
- }
923
- return record;
1059
+ showLayer(index) {
1060
+ this.sdkBinding().showLayer(index);
924
1061
  }
925
- /**
926
- * Caches the given instance so that it can be retrieved in the future.
927
- */
928
- setInstance(identifier, instance) {
929
- this.instances.set(identifier, instance);
930
- return instance;
1062
+ get storyAnimation() {
1063
+ return animationApi;
931
1064
  }
932
- /**
933
- * Gets a lazy reference to another service
934
- */
935
- getLazyIdentifier(lazyPointer) {
936
- return (new Proxy({}, { get: (_, key) => lazyPointer()[key] }));
1065
+ get isAndroid() {
1066
+ return false;
937
1067
  }
938
- /**
939
- * Constructs a new instance of the given identifier and returns it.
940
- * It checks the constructor arguments and injects any services it might depend on recursively.
941
- */
942
- constructInstance({ identifier, parentChain = [], }) {
943
- const registrationRecord = this.getRegistrationRecord({
944
- identifier,
945
- parentChain,
946
- });
947
- // If an instance already exists (and it is a singleton), return that one
948
- if (this.hasInstance(identifier) &&
949
- registrationRecord.kind === "SINGLETON") {
950
- return this.getInstance(identifier);
951
- }
952
- // Otherwise, instantiate a new one
953
- let instance;
954
- const me = {
955
- identifier,
956
- ref: this.getLazyIdentifier(() => instance),
957
- };
958
- // If a user-provided new-expression has been provided, invoke that to get an instance.
959
- if ("newExpression" in registrationRecord) {
960
- if (typeof registrationRecord.newExpression !== "function") {
961
- throw new TypeError(`Could not instantiate the service with the identifier: '${registrationRecord.identifier}': You provided a custom instantiation argument, but it wasn't of type function. It has to be a function that returns whatever should be used as an instance of the Service!`);
962
- }
963
- try {
964
- instance = registrationRecord.newExpression();
965
- }
966
- catch (ex) {
967
- throw new Error(`Could not instantiate the service with the identifier: '${registrationRecord.identifier}': When you registered the service, you provided a custom instantiation function, but it threw an exception when it was run!`);
968
- }
969
- }
970
- else {
971
- // Find the arguments for the identifier
972
- const mappedArgs = this.constructorArguments.get(identifier);
973
- if (mappedArgs == null) {
974
- throw new ReferenceError(`${this.constructor.name} could not find constructor arguments for the service: '${identifier}'. Have you registered it as a service?`);
975
- }
976
- // Instantiate all of the argument services (or re-use them if they were registered as singletons)
977
- const instanceArgs = mappedArgs.map((dep) => {
978
- if (dep === undefined)
979
- return undefined;
980
- const matchedParent = parentChain.find((parent) => parent.identifier === dep);
981
- if (matchedParent != null)
982
- return matchedParent.ref;
983
- return this.constructInstance({
984
- identifier: dep,
985
- parentChain: [...parentChain, me],
986
- });
987
- });
988
- try {
989
- // Try to construct an instance with 'new' and if it fails, call the implementation directly.
990
- const newable = registrationRecord.implementation;
991
- instance = new newable(...instanceArgs);
992
- }
993
- catch (ex) {
994
- if (registrationRecord.implementation == null) {
995
- throw new ReferenceError(`${this.constructor.name} could not construct a new service of kind: ${identifier}. Reason: No implementation was given!`);
996
- }
997
- const constructable = registrationRecord.implementation;
998
- // Try without 'new' and call the implementation as a function.
999
- instance = constructable(...instanceArgs);
1000
- }
1001
- }
1002
- return registrationRecord.kind === "SINGLETON"
1003
- ? this.setInstance(identifier, instance)
1004
- : instance;
1068
+ get isIOS() {
1069
+ return false;
1005
1070
  }
1006
- }
1007
- const DI_COMPILER_ERROR_HINT = `Note: You must use DI-Compiler (https://github.com/wessberg/di-compiler) for this library to work correctly. Please consult the readme for instructions on how to install and configure it for your project.`;
1008
-
1009
- const container = new DIContainer();
1010
-
1011
- class WidgetsService {
1012
- _env;
1013
- _sdkApi;
1014
- constructor(_env, _sdkApi) {
1015
- this._env = _env;
1016
- this._sdkApi = _sdkApi;
1071
+ get isWeb() {
1072
+ return true;
1017
1073
  }
1018
- get env() {
1019
- return this._env;
1074
+ pauseUI() {
1075
+ this.sdkBinding().pauseUI();
1020
1076
  }
1021
- get sdkApi() {
1022
- return this._sdkApi;
1077
+ resumeUI() {
1078
+ this.sdkBinding().resumeUI();
1023
1079
  }
1024
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`]; }
1080
+ get isExistsShowStoryTextInput() {
1081
+ return true;
1082
+ }
1083
+ showStoryTextInput(id, data) {
1084
+ this.sdkBinding().showStoryTextInput(id, data);
1085
+ }
1086
+ setStoryLocalData(keyValue, sendToServer) {
1087
+ this.sdkBinding().setStoryLocalData(keyValue, sendToServer);
1088
+ }
1089
+ getWidgetsSharedData(storyId, widget) {
1090
+ return this.sdkBinding().getWidgetsSharedData(storyId, widget);
1091
+ }
1092
+ vibrate(pattern) {
1093
+ navigator.vibrate(pattern);
1094
+ }
1095
+ openUrl(target) {
1096
+ this.sdkBinding().openUrl(target);
1097
+ }
1098
+ sendApiRequest(url, method, params, headers, data, profilingKey) {
1099
+ return this.sdkBinding().sendApiRequest(url, method, params, headers, data, profilingKey);
1100
+ }
1101
+ sendApiRequestSupported() {
1102
+ return true;
1103
+ }
1104
+ showToast(text) { }
1105
+ get sdkCanSendShareComplete() {
1106
+ return true;
1107
+ }
1108
+ get isExistsShare() {
1109
+ return true;
1110
+ }
1111
+ share(id, config) {
1112
+ this.sdkBinding().share(id, config);
1113
+ }
1114
+ shareSlideScreenshot(shareId, hideElementsSelector) {
1115
+ this.sdkBinding().shareSlideScreenshot(shareId, hideElementsSelector);
1116
+ }
1117
+ get isExistsShowStorySlide() {
1118
+ return true;
1119
+ }
1120
+ showStorySlide(index) {
1121
+ this.sdkBinding().showStorySlide(index);
1122
+ }
1123
+ get isExistsShowNextStory() {
1124
+ return true;
1125
+ }
1126
+ storyShowNext() {
1127
+ this.sdkBinding().storyShowNext();
1128
+ }
1129
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`() => SDKInterface`]; }
1025
1130
  }
1026
1131
 
1027
- container.registerSingleton(undefined, { identifier: `WidgetsService`, implementation: WidgetsService });
1028
-
1029
- // import '../adapters/dateTimeSource/composition';
1030
- // import '../adapters/uuidGenerator/composition';
1031
- // import '../effects/eventHandler/composition';
1032
- // import '../effects/logger/composition';
1033
- // import '../effects/timer/composition';
1034
- container.registerSingleton(() => window, { identifier: `Window` });
1035
-
1036
1132
  class WidgetBase {
1037
- /**
1038
- * @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146
1039
- */
1040
- ["constructor"];
1041
1133
  static DEFAULTS = {
1042
1134
  slide: null,
1043
1135
  activateAfterCreate: false,
@@ -1250,29 +1342,27 @@ class WidgetBase {
1250
1342
  console.error(error);
1251
1343
  }
1252
1344
  }
1253
- static api = {
1254
- refreshUserData: function (nodes, localData) {
1255
- const cb = (el, localData) => {
1256
- const widgetElement = el.closest(`.${WidgetBase.widgetClassName}`);
1257
- if (widgetElement) {
1258
- const widget = WidgetBase.getInstance(widgetElement);
1259
- if (widget) {
1260
- widget.refreshUserData(localData);
1261
- }
1345
+ static refreshUserData(nodes, localData) {
1346
+ const cb = (el, localData) => {
1347
+ const widgetElement = el.closest(`.${this.widgetClassName}`);
1348
+ if (widgetElement) {
1349
+ const widget = WidgetBase.getInstance(widgetElement);
1350
+ if (widget) {
1351
+ widget.refreshUserData(localData);
1262
1352
  }
1263
- };
1264
- if (localData != null) {
1353
+ }
1354
+ };
1355
+ if (localData != null) {
1356
+ const elements = slice.call(nodes);
1357
+ forEach(elements, el => cb(el, localData));
1358
+ }
1359
+ else {
1360
+ WidgetBase.getLocalData().then(localData => {
1265
1361
  const elements = slice.call(nodes);
1266
1362
  forEach(elements, el => cb(el, localData));
1267
- }
1268
- else {
1269
- WidgetBase.getLocalData().then(localData => {
1270
- const elements = slice.call(nodes);
1271
- forEach(elements, el => cb(el, localData));
1272
- });
1273
- }
1274
- },
1275
- };
1363
+ });
1364
+ }
1365
+ }
1276
1366
  static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
1277
1367
  }
1278
1368
 
@@ -1472,7 +1562,7 @@ class WidgetCopy extends WidgetBase {
1472
1562
  return this.localData["_cp_g_" + this.elementId + "_done_at"] !== undefined;
1473
1563
  }
1474
1564
  static api = {
1475
- ...WidgetBase.api,
1565
+ refreshUserData: WidgetCopy.refreshUserData,
1476
1566
  initWidget: function (nodeList, localData) {
1477
1567
  // prevent initWidget for result layer
1478
1568
  const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
@@ -1664,7 +1754,7 @@ class WidgetDataInput extends WidgetBase {
1664
1754
  }
1665
1755
  }
1666
1756
  static api = {
1667
- ...WidgetBase.api,
1757
+ refreshUserData: WidgetDataInput.refreshUserData,
1668
1758
  initWidget: function (nodeList, localData) {
1669
1759
  WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData);
1670
1760
  },
@@ -1877,7 +1967,7 @@ class WidgetDateCountdown extends WidgetBase {
1877
1967
  return result;
1878
1968
  }
1879
1969
  static api = {
1880
- ...WidgetBase.api,
1970
+ refreshUserData: WidgetDateCountdown.refreshUserData,
1881
1971
  initWidget: function (nodeList, layers, localData) {
1882
1972
  WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), slice.call(nodeList), localData);
1883
1973
  },
@@ -2505,7 +2595,7 @@ class WidgetPoll extends WidgetBase {
2505
2595
  return this.localData["_p_g_" + this.elementId + "_sa"] !== undefined;
2506
2596
  }
2507
2597
  static api = {
2508
- ...WidgetBase.api,
2598
+ refreshUserData: WidgetPoll.refreshUserData,
2509
2599
  initWidget: function (element, localData) {
2510
2600
  WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData);
2511
2601
  },
@@ -2670,7 +2760,7 @@ class WidgetPollLayers extends WidgetBase {
2670
2760
  return this.localData != null && this.localData["_pl_g_" + this.elementId + "_sa"] !== undefined;
2671
2761
  }
2672
2762
  static api = {
2673
- ...WidgetBase.api,
2763
+ refreshUserData: WidgetPollLayers.refreshUserData,
2674
2764
  // signature variants
2675
2765
  // (widget, layers, undefined) - modern web sdk
2676
2766
  // (widget, undefined, layers) - old web sdk and rn
@@ -2977,7 +3067,7 @@ class WidgetQuest extends WidgetBase {
2977
3067
  }
2978
3068
  }
2979
3069
  static api = {
2980
- ...WidgetBase.api,
3070
+ refreshUserData: WidgetQuest.refreshUserData,
2981
3071
  initWidget: function (element, localData) {
2982
3072
  return new Promise(function (resolve, reject) {
2983
3073
  WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
@@ -3044,14 +3134,14 @@ class WidgetQuiz extends WidgetBase {
3044
3134
  if (this.localData) {
3045
3135
  if (this.localData["_q_g_" + this.elementId + "_sa"] !== undefined) {
3046
3136
  this._selectAnswer(this.localData["_q_g_" + this.elementId + "_sa"]);
3047
- this.constructor.setLocalData(this.localData, false);
3137
+ this.setLocalData(this.localData, false);
3048
3138
  }
3049
3139
  else {
3050
3140
  this._clearAnswerSelection();
3051
3141
  }
3052
3142
  if (this.localData["_q_fo_at"] === undefined) {
3053
3143
  this.localData["_q_fo_at"] = Math.round(new Date().getTime() / 1000);
3054
- this.constructor.setLocalData(this.localData, false);
3144
+ this.setLocalData(this.localData, false);
3055
3145
  }
3056
3146
  }
3057
3147
  this.firstOpenTime = new Date().getTime();
@@ -3175,7 +3265,7 @@ class WidgetQuiz extends WidgetBase {
3175
3265
  return this.localData["_q_g_" + this.elementId + "_sa"] !== undefined;
3176
3266
  }
3177
3267
  static api = {
3178
- ...WidgetBase.api,
3268
+ refreshUserData: WidgetQuiz.refreshUserData,
3179
3269
  initWidget: function (element, localData) {
3180
3270
  WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData);
3181
3271
  },
@@ -3369,7 +3459,7 @@ class WidgetQuizGrouped extends WidgetBase {
3369
3459
  return this.localData["_q_gg_" + this.elementId + "_sa"] !== undefined;
3370
3460
  }
3371
3461
  static api = {
3372
- ...WidgetBase.api,
3462
+ refreshUserData: WidgetQuizGrouped.refreshUserData,
3373
3463
  initWidget: function (element, localData) {
3374
3464
  WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData);
3375
3465
  },
@@ -3978,7 +4068,7 @@ class WidgetRangeSlider extends WidgetBase {
3978
4068
  // .removeData('plugin_' + pluginName);
3979
4069
  }
3980
4070
  static api = {
3981
- ...WidgetBase.api,
4071
+ refreshUserData: WidgetRangeSlider.refreshUserData,
3982
4072
  initWidget: function (element, localData) {
3983
4073
  WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData);
3984
4074
  },
@@ -4225,7 +4315,7 @@ class WidgetRate extends WidgetBase {
4225
4315
  return this.localData["_r_g_" + this.elementId + "_sa"] !== undefined;
4226
4316
  }
4227
4317
  static api = {
4228
- ...WidgetBase.api,
4318
+ refreshUserData: WidgetRate.refreshUserData,
4229
4319
  initWidget: function (nodeList, localData) {
4230
4320
  WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), slice.call(nodeList), localData);
4231
4321
  },
@@ -4347,7 +4437,7 @@ class WidgetShare extends WidgetBase {
4347
4437
  return Boolean(this.localData["_s_" + this.elementId + "_ts"]);
4348
4438
  }
4349
4439
  static api = {
4350
- ...WidgetBase.api,
4440
+ refreshUserData: WidgetShare.refreshUserData,
4351
4441
  // signature variants
4352
4442
  // (widget, layers, undefined) - modern web sdk
4353
4443
  // (widget, undefined, layers) - old web sdk and rn
@@ -4587,7 +4677,7 @@ class WidgetTest extends WidgetBase {
4587
4677
  return Boolean(this.withTimeToAnswer && this.answerTimeout);
4588
4678
  }
4589
4679
  static api = {
4590
- ...WidgetBase.api,
4680
+ refreshUserData: WidgetTest.refreshUserData,
4591
4681
  initWidget: function (element, localData) {
4592
4682
  WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData);
4593
4683
  },
@@ -4840,7 +4930,7 @@ class WidgetVote extends WidgetBase {
4840
4930
  return this.localData["_v_g_" + this.elementId + "_sa"] !== undefined;
4841
4931
  }
4842
4932
  static api = {
4843
- ...WidgetBase.api,
4933
+ refreshUserData: WidgetVote.refreshUserData,
4844
4934
  // fix for WidgetVote on every layer of multilayers story
4845
4935
  fallbackInitOnMultiSlide: function (element, localData) {
4846
4936
  if (element.dataset.fallbackInitOnMultiSlide) {
@@ -4888,7 +4978,9 @@ class WidgetVote extends WidgetBase {
4888
4978
  static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
4889
4979
  }
4890
4980
 
4981
+ let sdkInterface;
4891
4982
  const getSlideApi = (_sdkInterface) => {
4983
+ sdkInterface = _sdkInterface;
4892
4984
  return {
4893
4985
  Animation: animationApi,
4894
4986
  WidgetCopy: WidgetCopy.api,
@@ -4908,4 +5000,7 @@ const getSlideApi = (_sdkInterface) => {
4908
5000
  };
4909
5001
  };
4910
5002
 
5003
+ container.registerSingleton(() => new EsModuleSdkApi(() => sdkInterface), { identifier: `SDKApi` });
5004
+
4911
5005
  exports.getSlideApi = getSlideApi;
5006
+ //# sourceMappingURL=index.cjs.map