surveysparrow-ionic-plugin 2.0.1 → 2.0.2-beta.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/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +51 -3
- package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +3 -1
- package/dist/angular-ui/esm2022/spotchecks/api.mjs +3 -3
- package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +16 -9
- package/dist/angular-ui/esm2022/spotchecks/types.mjs +1 -1
- package/dist/angular-ui/fesm2022/angular-ui.mjs +69 -12
- package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
- package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +1 -0
- package/dist/angular-ui/spotchecks/helpers.d.ts +2 -1
- package/dist/angular-ui/spotchecks/types.d.ts +2 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +48 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +2 -0
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/api.js +4 -3
- package/dist/esm/angular-ui/lib/spotchecks/api.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +2 -1
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js +16 -10
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +2 -0
- package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
- package/dist/plugin.cjs.js +73 -14
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +73 -14
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +54 -1
- package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +2 -0
- package/src/angular-ui/lib/spotchecks/api.ts +2 -2
- package/src/angular-ui/lib/spotchecks/helpers.ts +19 -8
- package/src/angular-ui/lib/spotchecks/types.ts +2 -0
package/dist/plugin.cjs.js
CHANGED
|
@@ -51102,6 +51102,8 @@ let SpotcheckStateService = class SpotcheckStateService {
|
|
|
51102
51102
|
traceId: '',
|
|
51103
51103
|
isClassicLoading: true,
|
|
51104
51104
|
isChatLoading: true,
|
|
51105
|
+
isClassicLoadEventReceived: false,
|
|
51106
|
+
isChatLoadEventReceived: false,
|
|
51105
51107
|
classicUrl: '',
|
|
51106
51108
|
chatUrl: '',
|
|
51107
51109
|
classicWebViewRef: null,
|
|
@@ -51137,6 +51139,7 @@ SpotcheckStateService = __decorate$2([
|
|
|
51137
51139
|
], SpotcheckStateService);
|
|
51138
51140
|
|
|
51139
51141
|
let globalSpotcheckStateService;
|
|
51142
|
+
let globalOS = null;
|
|
51140
51143
|
const getSpotcheckStateService = () => {
|
|
51141
51144
|
if (!globalSpotcheckStateService) {
|
|
51142
51145
|
globalSpotcheckStateService = new SpotcheckStateService();
|
|
@@ -51156,10 +51159,11 @@ const ischatSurvey = (type) => {
|
|
|
51156
51159
|
};
|
|
51157
51160
|
const getOS = async () => {
|
|
51158
51161
|
const info = await device.Device.getInfo();
|
|
51159
|
-
|
|
51162
|
+
globalOS = info.operatingSystem;
|
|
51163
|
+
return globalOS;
|
|
51160
51164
|
};
|
|
51161
51165
|
const setAppearance = async (responseJson, screen, domainName, traceId, variables) => {
|
|
51162
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
51166
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
51163
51167
|
try {
|
|
51164
51168
|
const spotcheckStateService = getSpotcheckStateService();
|
|
51165
51169
|
let state = spotcheckStateService.getState();
|
|
@@ -51206,11 +51210,11 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
51206
51210
|
spotcheckStateService.setState(updatedState);
|
|
51207
51211
|
try {
|
|
51208
51212
|
const response = await axios.get(fullSpotcheckURL);
|
|
51209
|
-
const themeInfo = response.data.config.generatedCSS;
|
|
51213
|
+
const themeInfo = (_p = (_o = response.data) === null || _o === void 0 ? void 0 : _o.config) === null || _p === void 0 ? void 0 : _p.generatedCSS;
|
|
51210
51214
|
const theme_payload = { type: 'THEME_UPDATE_SPOTCHECK', themeInfo };
|
|
51211
51215
|
state = spotcheckStateService.getState();
|
|
51212
51216
|
let webViewRef = chat ? state.chatWebViewRef : state.classicWebViewRef;
|
|
51213
|
-
let isLoading = chat ? state.isChatLoading : state.isClassicLoading;
|
|
51217
|
+
let isLoading = chat ? state.isChatLoading || !state.isChatLoadEventReceived : state.isClassicLoading || !state.isClassicLoadEventReceived;
|
|
51214
51218
|
const resetStateData = {
|
|
51215
51219
|
type: 'RESET_STATE',
|
|
51216
51220
|
state: Object.assign(Object.assign({}, (response.data || {})), { skip: true, spotCheckAppearance: Object.assign(Object.assign({}, (appearance || {})), { targetType: 'MOBILE' }), spotcheckUrl: screen, traceId, elementBuilderParams: Object.assign({}, (variables || {})) }),
|
|
@@ -51241,8 +51245,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
51241
51245
|
else {
|
|
51242
51246
|
// todo: recheck this
|
|
51243
51247
|
const unsubscribe = spotcheckStateService.state$.subscribe((currentState) => {
|
|
51244
|
-
const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, } = currentState;
|
|
51245
|
-
if ((!isChatLoading && chat) || (!isClassicLoading && !chat)) {
|
|
51248
|
+
const { isChatLoading, isClassicLoading, chatWebViewRef, classicWebViewRef, isClassicLoadEventReceived, isChatLoadEventReceived, } = currentState;
|
|
51249
|
+
if ((!isChatLoading && chat && isChatLoadEventReceived) || (!isClassicLoading && !chat && isClassicLoadEventReceived)) {
|
|
51246
51250
|
unsubscribe.unsubscribe();
|
|
51247
51251
|
const activeWebViewRef = chat
|
|
51248
51252
|
? chatWebViewRef
|
|
@@ -51265,8 +51269,8 @@ const setAppearance = async (responseJson, screen, domainName, traceId, variable
|
|
|
51265
51269
|
? currentState.chatWebViewRef
|
|
51266
51270
|
: currentState.classicWebViewRef;
|
|
51267
51271
|
const updatedIsLoading = chat
|
|
51268
|
-
? currentState.isChatLoading
|
|
51269
|
-
: currentState.isClassicLoading;
|
|
51272
|
+
? currentState.isChatLoading || !currentState.isChatLoadEventReceived
|
|
51273
|
+
: currentState.isClassicLoading || !currentState.isClassicLoadEventReceived;
|
|
51270
51274
|
if (updatedWebViewRef) {
|
|
51271
51275
|
if (!updatedIsLoading) {
|
|
51272
51276
|
unsubscribeWebView.unsubscribe();
|
|
@@ -51369,11 +51373,15 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
51369
51373
|
height: '100%',
|
|
51370
51374
|
};
|
|
51371
51375
|
}
|
|
51376
|
+
let marginBottom = globalOS !== 'ios' ? 18 : 0;
|
|
51372
51377
|
if (state.isVisible && state.isMounted) {
|
|
51373
51378
|
let height = Math.min(state.currentQuestionHeight, (state.maxHeight * window.innerHeight));
|
|
51374
51379
|
if (state.spotChecksMode === 'miniCard') {
|
|
51375
51380
|
if (state.avatarEnabled) {
|
|
51376
51381
|
height = height - 56;
|
|
51382
|
+
if (state.spotcheckPosition === 'bottom') {
|
|
51383
|
+
marginBottom += 56;
|
|
51384
|
+
}
|
|
51377
51385
|
}
|
|
51378
51386
|
if (state.isCloseButtonEnabled) {
|
|
51379
51387
|
height = height - 40;
|
|
@@ -51416,8 +51424,8 @@ const getSpotcheckComponentCssStyles = (state) => {
|
|
|
51416
51424
|
}
|
|
51417
51425
|
}
|
|
51418
51426
|
return {
|
|
51419
|
-
wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '
|
|
51420
|
-
styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px' }, styles)
|
|
51427
|
+
wrapperStyles: Object.assign({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', backgroundColor: 'rgba(0, 0, 0, 0.3)', zIndex: '100001', display: 'none', flexDirection: 'column' }, wrapperStyles),
|
|
51428
|
+
styles: Object.assign({ display: 'none', flexDirection: 'column', paddingTop: extraPaddingForMiniCardCloseButtonIfTopPosition + 'px', marginBottom: marginBottom + 'px' }, styles)
|
|
51421
51429
|
};
|
|
51422
51430
|
};
|
|
51423
51431
|
const closeSpotCheckAndHandleSurveyEnd = async () => {
|
|
@@ -51467,6 +51475,7 @@ let WebViewComponent = class WebViewComponent {
|
|
|
51467
51475
|
setupIframeLoadListener() {
|
|
51468
51476
|
const iframe = this.iframe.nativeElement;
|
|
51469
51477
|
iframe.addEventListener('load', () => {
|
|
51478
|
+
this.injectNativeBridgeAdapters(iframe);
|
|
51470
51479
|
const stateService = getSpotcheckStateService();
|
|
51471
51480
|
if (this.webviewType === 'classic') {
|
|
51472
51481
|
stateService.setState({ isClassicLoading: false });
|
|
@@ -51476,6 +51485,45 @@ let WebViewComponent = class WebViewComponent {
|
|
|
51476
51485
|
}
|
|
51477
51486
|
});
|
|
51478
51487
|
}
|
|
51488
|
+
injectNativeBridgeAdapters(iframe) {
|
|
51489
|
+
if (iframe && iframe.contentWindow) {
|
|
51490
|
+
try {
|
|
51491
|
+
const iframeWindow = iframe.contentWindow;
|
|
51492
|
+
if (!iframeWindow.SsAndroidSdk) {
|
|
51493
|
+
iframeWindow.SsAndroidSdk = {
|
|
51494
|
+
shareData: function () { },
|
|
51495
|
+
sendPartialSubmissionData: function () { }
|
|
51496
|
+
};
|
|
51497
|
+
}
|
|
51498
|
+
if (!iframeWindow.Android) {
|
|
51499
|
+
iframeWindow.Android = {
|
|
51500
|
+
onMessageReceive: function () { }
|
|
51501
|
+
};
|
|
51502
|
+
}
|
|
51503
|
+
if (!iframeWindow.webkit) {
|
|
51504
|
+
iframeWindow.webkit = {
|
|
51505
|
+
messageHandlers: {
|
|
51506
|
+
surveyResponse: {
|
|
51507
|
+
postMessage: function () { }
|
|
51508
|
+
},
|
|
51509
|
+
spotCheckData: {
|
|
51510
|
+
postMessage: function () { }
|
|
51511
|
+
},
|
|
51512
|
+
flutterSpotCheckData: {
|
|
51513
|
+
postMessage: function () { }
|
|
51514
|
+
}
|
|
51515
|
+
}
|
|
51516
|
+
};
|
|
51517
|
+
}
|
|
51518
|
+
if (!iframeWindow.flutterSpotCheckData) {
|
|
51519
|
+
iframeWindow.flutterSpotCheckData = {
|
|
51520
|
+
postMessage: function () { }
|
|
51521
|
+
};
|
|
51522
|
+
}
|
|
51523
|
+
}
|
|
51524
|
+
catch (error) { }
|
|
51525
|
+
}
|
|
51526
|
+
}
|
|
51479
51527
|
onMessage(event) {
|
|
51480
51528
|
const stateService = getSpotcheckStateService();
|
|
51481
51529
|
const { data } = event;
|
|
@@ -51501,6 +51549,15 @@ let WebViewComponent = class WebViewComponent {
|
|
|
51501
51549
|
closeSpotCheckAndHandleSurveyEnd();
|
|
51502
51550
|
// spotchecksListener.emitSurveyCompleted(data.response);
|
|
51503
51551
|
break;
|
|
51552
|
+
case 'surveyLoadStarted':
|
|
51553
|
+
// spotchecksListener.emitSurveyLoadStarted(data.surveyDetails);
|
|
51554
|
+
break;
|
|
51555
|
+
case 'classicLoadEvent':
|
|
51556
|
+
stateService.setState({ isClassicLoadEventReceived: true });
|
|
51557
|
+
break;
|
|
51558
|
+
case 'chatLoadEvent':
|
|
51559
|
+
stateService.setState({ isChatLoadEventReceived: true });
|
|
51560
|
+
break;
|
|
51504
51561
|
}
|
|
51505
51562
|
}
|
|
51506
51563
|
};
|
|
@@ -51532,7 +51589,8 @@ WebViewComponent = __decorate$1([
|
|
|
51532
51589
|
template: `
|
|
51533
51590
|
<div style="overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;">
|
|
51534
51591
|
<iframe
|
|
51535
|
-
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write;"
|
|
51592
|
+
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write; fullscreen"
|
|
51593
|
+
allowfullscreen
|
|
51536
51594
|
#iframeRef
|
|
51537
51595
|
[src]="safeUrl"
|
|
51538
51596
|
style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
|
|
@@ -51748,6 +51806,7 @@ const setUUID = (uuid) => {
|
|
|
51748
51806
|
};
|
|
51749
51807
|
|
|
51750
51808
|
const sendTrackScreenRequest = async ({ screen, options, }) => {
|
|
51809
|
+
var _a, _b;
|
|
51751
51810
|
try {
|
|
51752
51811
|
const spotcheckStateService = getSpotcheckStateService();
|
|
51753
51812
|
const oldState = spotcheckStateService.getState();
|
|
@@ -51866,7 +51925,7 @@ const sendTrackScreenRequest = async ({ screen, options, }) => {
|
|
|
51866
51925
|
}
|
|
51867
51926
|
}
|
|
51868
51927
|
}
|
|
51869
|
-
throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
|
|
51928
|
+
throw new Error((_b = (_a = responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 'Spotcheck conditions not met');
|
|
51870
51929
|
}
|
|
51871
51930
|
else {
|
|
51872
51931
|
throw new Error(`Received status code ${response.status}`);
|
|
@@ -51877,7 +51936,7 @@ const sendTrackScreenRequest = async ({ screen, options, }) => {
|
|
|
51877
51936
|
}
|
|
51878
51937
|
};
|
|
51879
51938
|
const sendTrackEventRequest = async ({ screen, event }) => {
|
|
51880
|
-
var _a, _b, _c, _d, _e, _f;
|
|
51939
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
51881
51940
|
try {
|
|
51882
51941
|
const intMax = Number.POSITIVE_INFINITY;
|
|
51883
51942
|
const state = getSpotcheckStateService().getState();
|
|
@@ -51950,7 +52009,7 @@ const sendTrackEventRequest = async ({ screen, event }) => {
|
|
|
51950
52009
|
return { valid: true };
|
|
51951
52010
|
}
|
|
51952
52011
|
}
|
|
51953
|
-
throw new Error(responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason.toString());
|
|
52012
|
+
throw new Error((_h = (_g = responseJson === null || responseJson === void 0 ? void 0 : responseJson.reason) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : 'Event conditions not met');
|
|
51954
52013
|
}
|
|
51955
52014
|
else {
|
|
51956
52015
|
throw new Error(`Received status code ${response.status}`);
|