@inappstory/slide-api 0.0.2 → 0.0.3
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 +306 -210
- package/dist/index.d.cts +514 -2
- package/dist/index.d.ts +514 -2
- package/dist/index.js +306 -210
- package/package.json +1 -1
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
|
-
|
|
817
|
-
|
|
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
|
-
|
|
849
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
887
|
-
|
|
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
|
-
|
|
900
|
-
*/
|
|
901
|
-
hasInstance(identifier) {
|
|
902
|
-
return this.getInstance(identifier) != null;
|
|
1053
|
+
getStoryLocalData() {
|
|
1054
|
+
return this.sdkBinding().getStoryLocalData();
|
|
903
1055
|
}
|
|
904
|
-
|
|
905
|
-
|
|
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
|
-
|
|
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
|
-
|
|
927
|
-
*/
|
|
928
|
-
setInstance(identifier, instance) {
|
|
929
|
-
this.instances.set(identifier, instance);
|
|
930
|
-
return instance;
|
|
1062
|
+
get storyAnimation() {
|
|
1063
|
+
return animationApi;
|
|
931
1064
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
*/
|
|
935
|
-
getLazyIdentifier(lazyPointer) {
|
|
936
|
-
return (new Proxy({}, { get: (_, key) => lazyPointer()[key] }));
|
|
1065
|
+
get isAndroid() {
|
|
1066
|
+
return false;
|
|
937
1067
|
}
|
|
938
|
-
|
|
939
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1019
|
-
|
|
1074
|
+
pauseUI() {
|
|
1075
|
+
this.sdkBinding().pauseUI();
|
|
1020
1076
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1077
|
+
resumeUI() {
|
|
1078
|
+
this.sdkBinding().resumeUI();
|
|
1023
1079
|
}
|
|
1024
|
-
|
|
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,
|
|
@@ -3044,14 +3136,14 @@ class WidgetQuiz extends WidgetBase {
|
|
|
3044
3136
|
if (this.localData) {
|
|
3045
3137
|
if (this.localData["_q_g_" + this.elementId + "_sa"] !== undefined) {
|
|
3046
3138
|
this._selectAnswer(this.localData["_q_g_" + this.elementId + "_sa"]);
|
|
3047
|
-
this.
|
|
3139
|
+
this.setLocalData(this.localData, false);
|
|
3048
3140
|
}
|
|
3049
3141
|
else {
|
|
3050
3142
|
this._clearAnswerSelection();
|
|
3051
3143
|
}
|
|
3052
3144
|
if (this.localData["_q_fo_at"] === undefined) {
|
|
3053
3145
|
this.localData["_q_fo_at"] = Math.round(new Date().getTime() / 1000);
|
|
3054
|
-
this.
|
|
3146
|
+
this.setLocalData(this.localData, false);
|
|
3055
3147
|
}
|
|
3056
3148
|
}
|
|
3057
3149
|
this.firstOpenTime = new Date().getTime();
|
|
@@ -4888,7 +4980,9 @@ class WidgetVote extends WidgetBase {
|
|
|
4888
4980
|
static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
|
|
4889
4981
|
}
|
|
4890
4982
|
|
|
4983
|
+
let sdkInterface;
|
|
4891
4984
|
const getSlideApi = (_sdkInterface) => {
|
|
4985
|
+
sdkInterface = _sdkInterface;
|
|
4892
4986
|
return {
|
|
4893
4987
|
Animation: animationApi,
|
|
4894
4988
|
WidgetCopy: WidgetCopy.api,
|
|
@@ -4908,4 +5002,6 @@ const getSlideApi = (_sdkInterface) => {
|
|
|
4908
5002
|
};
|
|
4909
5003
|
};
|
|
4910
5004
|
|
|
5005
|
+
container.registerSingleton(() => new EsModuleSdkApi(() => sdkInterface), { identifier: `SDKApi` });
|
|
5006
|
+
|
|
4911
5007
|
exports.getSlideApi = getSlideApi;
|