@magicfeedback/popup-sdk 1.14.0 → 1.16.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/README.md +6 -1
- package/dist/{chunk-C7VD3HY4.mjs → chunk-AFRHPS3K.mjs} +25 -13
- package/dist/chunk-AFRHPS3K.mjs.map +1 -0
- package/dist/{chunk-GUJSOVS6.mjs → chunk-VHTN5UXD.mjs} +25 -13
- package/dist/chunk-VHTN5UXD.mjs.map +1 -0
- package/dist/index.d.mts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +172 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -77
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +16 -3
- package/dist/react-native.d.ts +16 -3
- package/dist/react-native.js +172 -144
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +63 -77
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-FAEZGWRS.mjs → renderPopup-S3RU3Y6J.mjs} +87 -57
- package/dist/renderPopup-S3RU3Y6J.mjs.map +1 -0
- package/dist/{renderPopup-Z6TENBP6.mjs → renderPopup-YCAQ3ODC.mjs} +87 -57
- package/dist/renderPopup-YCAQ3ODC.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-C7VD3HY4.mjs.map +0 -1
- package/dist/chunk-GUJSOVS6.mjs.map +0 -1
- package/dist/renderPopup-FAEZGWRS.mjs.map +0 -1
- package/dist/renderPopup-Z6TENBP6.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
sdkWarn,
|
|
22
22
|
setLogger,
|
|
23
23
|
style_default
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-AFRHPS3K.mjs";
|
|
25
25
|
|
|
26
26
|
// src/types/index.ts
|
|
27
27
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
@@ -292,12 +292,14 @@ function buildSurveyHtml(opts) {
|
|
|
292
292
|
const startLabel = jsonForScript(initActionLabels.start);
|
|
293
293
|
const completeLabel = jsonForScript(initActionLabels.complete);
|
|
294
294
|
const submitLabel = jsonForScript(initActionLabels.accept);
|
|
295
|
+
const cancelLabel = jsonForScript(initActionLabels.decline);
|
|
295
296
|
const labelsTableJson = jsonForScript(LABELS);
|
|
296
297
|
const actionOverridesJson = jsonForScript({
|
|
297
298
|
accept: trimmedOrNull(opts.actions?.accept?.label),
|
|
298
299
|
start: trimmedOrNull(opts.actions?.start?.label),
|
|
299
300
|
complete: trimmedOrNull(opts.actions?.complete?.label),
|
|
300
|
-
back: trimmedOrNull(opts.actions?.back?.label)
|
|
301
|
+
back: trimmedOrNull(opts.actions?.back?.label),
|
|
302
|
+
decline: trimmedOrNull(opts.actions?.decline?.label)
|
|
301
303
|
});
|
|
302
304
|
const initLangJson = jsonForScript(opts.language ?? "");
|
|
303
305
|
const initDirection = directionFor(opts.language);
|
|
@@ -359,6 +361,7 @@ body.dd-ready #dd-popup{visibility:visible}
|
|
|
359
361
|
#dd-logo{max-height:40px;max-width:100%;object-fit:contain;display:block;margin:12px 0 0 0}
|
|
360
362
|
.deepdots-error-hint{display:none;margin:12px 0 0 0;padding:10px 12px;border-radius:6px;background:#FEF3C7;color:#92400E;border:1px solid #FCD34D;font-size:13px}
|
|
361
363
|
/* Pantalla final: el HTML del editor de la plataforma (imagen + texto), centrado. */
|
|
364
|
+
.deepdots-load-error{display:none;width:100%;text-align:center;padding:24px 0;font-size:15px;color:${textPrimary}}
|
|
362
365
|
.deepdots-success{display:none;width:100%;text-align:center;padding:24px 0;color:${textPrimary}}
|
|
363
366
|
.deepdots-success img{max-width:100%;height:auto;margin:0 auto 16px auto;display:block}
|
|
364
367
|
.deepdots-success p{margin:0;font-size:16px;font-weight:600;line-height:1.4}
|
|
@@ -366,7 +369,7 @@ body.dd-ready #dd-popup{visibility:visible}
|
|
|
366
369
|
.dd-nav-btn{display:none;border:none;min-height:44px;padding:12px 24px;border-radius:999px;cursor:pointer;font-size:15px;font-weight:600;align-items:center;justify-content:center;text-align:center}
|
|
367
370
|
/* Secundario como bot\xF3n de texto: sin borde ni fondo, para que el primario sea la \xFAnica CTA. */
|
|
368
371
|
#dd-back{background:transparent;color:${textMuted};border:none}
|
|
369
|
-
#dd-start,#dd-complete,#dd-submit{background:#1E293B;color:#fff;border:none}
|
|
372
|
+
#dd-start,#dd-complete,#dd-submit,#dd-cancel{background:#1E293B;color:#fff;border:none}
|
|
370
373
|
#dd-submit:disabled,#dd-start:disabled,#dd-back:disabled,#dd-complete:disabled{opacity:0.6;cursor:not-allowed}
|
|
371
374
|
.mf-spinner{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
|
|
372
375
|
.mf-spinner-circle{width:28px;height:28px;border:3px solid #e0e6ed;border-top-color:#1E293B;border-radius:50%;animation:ddspin 0.9s linear infinite}
|
|
@@ -407,6 +410,7 @@ ${customCss}
|
|
|
407
410
|
<div class="mf-spinner" id="dd-spinner" role="status" aria-label="${initLabels.loadingAria}"><div class="mf-spinner-circle"></div></div>
|
|
408
411
|
<div id="mf"></div>
|
|
409
412
|
</div>
|
|
413
|
+
<div class="deepdots-load-error" id="dd-load-error" role="alert"></div>
|
|
410
414
|
<div class="deepdots-error-hint" id="dd-error" role="alert" aria-live="polite"></div>
|
|
411
415
|
</div>
|
|
412
416
|
<div class="deepdots-popup-footer" id="dd-footer">
|
|
@@ -414,6 +418,7 @@ ${customCss}
|
|
|
414
418
|
<button type="button" class="dd-nav-btn" id="dd-back"></button>
|
|
415
419
|
<button type="button" class="dd-nav-btn" id="dd-complete"></button>
|
|
416
420
|
<button type="button" class="dd-nav-btn" id="dd-start"></button>
|
|
421
|
+
<button type="button" class="dd-nav-btn" id="dd-cancel"></button>
|
|
417
422
|
</div>
|
|
418
423
|
</div>
|
|
419
424
|
</div>
|
|
@@ -436,6 +441,8 @@ ${customCss}
|
|
|
436
441
|
var startBtn=document.getElementById('dd-start');
|
|
437
442
|
var completeBtn=document.getElementById('dd-complete');
|
|
438
443
|
var submitBtn=document.getElementById('dd-submit');
|
|
444
|
+
var cancelBtn=document.getElementById('dd-cancel');
|
|
445
|
+
var loadErrorEl=document.getElementById('dd-load-error');
|
|
439
446
|
var titleEl=document.getElementById('dd-title');
|
|
440
447
|
var progressEl=document.getElementById('dd-progress');
|
|
441
448
|
var progressLabel=document.getElementById('dd-progress-label');
|
|
@@ -465,6 +472,8 @@ ${customCss}
|
|
|
465
472
|
startBtn.textContent=DD_ACTION_OVERRIDES.start||next.start;
|
|
466
473
|
completeBtn.textContent=DD_ACTION_OVERRIDES.complete||next.complete;
|
|
467
474
|
submitBtn.textContent=DD_ACTION_OVERRIDES.accept||next.accept;
|
|
475
|
+
cancelBtn.textContent=DD_ACTION_OVERRIDES.decline||next.decline;
|
|
476
|
+
loadErrorEl.textContent=next.errorLoad;
|
|
468
477
|
if(closeEl){ closeEl.setAttribute('aria-label',next.closeAria); }
|
|
469
478
|
if(spinner){ spinner.setAttribute('aria-label',next.loadingAria); }
|
|
470
479
|
progressFollowUp.textContent=next.followUp;
|
|
@@ -519,6 +528,7 @@ ${customCss}
|
|
|
519
528
|
startBtn.textContent=${startLabel};
|
|
520
529
|
completeBtn.textContent=${completeLabel};
|
|
521
530
|
submitBtn.textContent=${submitLabel};
|
|
531
|
+
cancelBtn.textContent=${cancelLabel};
|
|
522
532
|
|
|
523
533
|
closeEl.onclick=function(){ emitJSON('popup_close'); };
|
|
524
534
|
backBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.back){ window.DeepdotsForm.back(); } };
|
|
@@ -530,6 +540,8 @@ ${customCss}
|
|
|
530
540
|
}
|
|
531
541
|
};
|
|
532
542
|
completeBtn.onclick=function(){ emitJSON('popup_close'); };
|
|
543
|
+
// \xDAnica acci\xF3n del survey que no carga: cierra igual que la X.
|
|
544
|
+
cancelBtn.onclick=function(){ emitJSON('popup_close'); };
|
|
533
545
|
var surveyCompletedEmitted=false;
|
|
534
546
|
submitBtn.onclick=function(){
|
|
535
547
|
if(surveyCompletedEmitted) return;
|
|
@@ -571,6 +583,7 @@ ${customCss}
|
|
|
571
583
|
startBtn.style.display='none';
|
|
572
584
|
submitBtn.style.display='none';
|
|
573
585
|
completeBtn.style.display='none';
|
|
586
|
+
cancelBtn.style.display='none';
|
|
574
587
|
backBtn.style.width='';
|
|
575
588
|
startBtn.style.width='';
|
|
576
589
|
submitBtn.style.width='';
|
|
@@ -586,6 +599,8 @@ ${customCss}
|
|
|
586
599
|
} else if(state==='completed'){
|
|
587
600
|
completeBtn.style.display='inline-flex';
|
|
588
601
|
completeBtn.style.width='100%';
|
|
602
|
+
} else if(state==='load_error'){
|
|
603
|
+
cancelBtn.style.display='inline-flex';
|
|
589
604
|
}
|
|
590
605
|
}
|
|
591
606
|
|
|
@@ -632,6 +647,26 @@ ${REVEAL_JS}
|
|
|
632
647
|
}
|
|
633
648
|
setLoading(true);
|
|
634
649
|
|
|
650
|
+
// Survey que no ha cargado (406 de /info, sin red, bundle del CDN ca\xEDdo). Antes se emit\xEDa
|
|
651
|
+
// \`loaded\` y se pintaba un Send sobre un survey vac\xEDo. Espejo de KMP: aviso traducido, la X
|
|
652
|
+
// sigue, un \xFAnico Cancel, y se revela ya (manda \`ready\`): no hay nada m\xE1s que esperar.
|
|
653
|
+
// No es interacci\xF3n del usuario: el renderer no lo convierte en popup_clicked.
|
|
654
|
+
var ddLoadFailed=false;
|
|
655
|
+
function ddShowLoadError(name, reason){
|
|
656
|
+
if(ddLoadFailed){ return; }
|
|
657
|
+
ddLoadFailed=true;
|
|
658
|
+
var why=(reason && reason.message) ? reason.message : String(reason);
|
|
659
|
+
emitJSON(name, { message: why });
|
|
660
|
+
progressEl.style.display='none';
|
|
661
|
+
formWrapper.style.display='none';
|
|
662
|
+
errorHint.style.display='none';
|
|
663
|
+
loadErrorEl.textContent=DD_LABELS_ACTIVE.errorLoad;
|
|
664
|
+
loadErrorEl.style.display='block';
|
|
665
|
+
setLoading(false);
|
|
666
|
+
updateButtons('load_error');
|
|
667
|
+
ddReveal.reveal();
|
|
668
|
+
}
|
|
669
|
+
|
|
635
670
|
var initialized=false;
|
|
636
671
|
function initMF(){
|
|
637
672
|
if(initialized || !window.magicfeedback) return initialized;
|
|
@@ -655,6 +690,7 @@ ${REVEAL_JS}
|
|
|
655
690
|
// de native sin esta opci\xF3n la ignoran.
|
|
656
691
|
autofocus:'navigation',
|
|
657
692
|
onLoadedEvent:function(args){
|
|
693
|
+
if(args && args.error){ ddShowLoadError('error:load', args.error); return; }
|
|
658
694
|
// Idioma en el que native muestra el survey: manda sobre el del init para que el
|
|
659
695
|
// chrome no se quede en ingl\xE9s delante de un survey traducido. Native < 2.3 no lo
|
|
660
696
|
// env\xEDa: entonces el primero de formData.lang (el idioma por defecto).
|
|
@@ -758,13 +794,13 @@ ${REVEAL_JS}
|
|
|
758
794
|
updateProgress({ progress:p&&p.progress, total:form.total, completed:false, followup:p&&p.followup });
|
|
759
795
|
emitJSON('back', p);
|
|
760
796
|
}
|
|
761
|
-
}).catch(function(e){
|
|
762
|
-
}catch(e){
|
|
797
|
+
}).catch(function(e){ ddShowLoadError('error:init', e); });
|
|
798
|
+
}catch(e){ ddShowLoadError('error:exception', e); }
|
|
763
799
|
return true;
|
|
764
800
|
}
|
|
765
801
|
var s=document.createElement('script'); s.src=${JSON.stringify(cdn)}; s.async=true;
|
|
766
802
|
s.onload=function(){ initMF(); };
|
|
767
|
-
s.onerror=function(){
|
|
803
|
+
s.onerror=function(){ ddShowLoadError('error:load', 'survey script failed to load'); };
|
|
768
804
|
document.head.appendChild(s);
|
|
769
805
|
var tries=0, t=setInterval(function(){ if(initMF()||++tries>40){ clearInterval(t); } },150);
|
|
770
806
|
})();
|
|
@@ -881,6 +917,7 @@ var ReactNativePopupRenderer = class {
|
|
|
881
917
|
this.onCloseFn?.();
|
|
882
918
|
break;
|
|
883
919
|
default:
|
|
920
|
+
if (typeof name === "string" && name.startsWith("error:")) this.emitReady(surveyId);
|
|
884
921
|
break;
|
|
885
922
|
}
|
|
886
923
|
}
|
|
@@ -893,7 +930,7 @@ function createReactNativeRenderer() {
|
|
|
893
930
|
}
|
|
894
931
|
|
|
895
932
|
// src/ui/preload.ts
|
|
896
|
-
var defaultLoader = () => import("./renderPopup-
|
|
933
|
+
var defaultLoader = () => import("./renderPopup-YCAQ3ODC.mjs");
|
|
897
934
|
var pending = null;
|
|
898
935
|
function preloadRenderPopup(loader = defaultLoader) {
|
|
899
936
|
if (pending) return pending;
|
|
@@ -966,7 +1003,7 @@ var BrowserPopupRenderer = class {
|
|
|
966
1003
|
if (!this.container) return;
|
|
967
1004
|
this.visible = true;
|
|
968
1005
|
const container = this.container;
|
|
969
|
-
void import("./renderPopup-
|
|
1006
|
+
void import("./renderPopup-YCAQ3ODC.mjs").then(({ renderPopup }) => {
|
|
970
1007
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
|
|
971
1008
|
});
|
|
972
1009
|
}
|
|
@@ -2002,8 +2039,6 @@ var DeepdotsPopups = class {
|
|
|
2002
2039
|
this.renderer = createDefaultRenderer();
|
|
2003
2040
|
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
2004
2041
|
this.logger = console;
|
|
2005
|
-
this.popupContainer = null;
|
|
2006
|
-
// deprecated: mantenido para compatibilidad interna
|
|
2007
2042
|
this.popupDefinitions = [];
|
|
2008
2043
|
this.popupsLoaded = false;
|
|
2009
2044
|
/**
|
|
@@ -2034,6 +2069,7 @@ var DeepdotsPopups = class {
|
|
|
2034
2069
|
this.showProgressBar = void 0;
|
|
2035
2070
|
/** CSS del host inyectado al final de los estilos del popup. */
|
|
2036
2071
|
this.surveyCss = void 0;
|
|
2072
|
+
this.cspNonce = void 0;
|
|
2037
2073
|
/** Identidad + sesión (Fase 1 tracking). Null hasta init(). */
|
|
2038
2074
|
this.tracking = null;
|
|
2039
2075
|
/** Capa de analytics (canal separado del feedback). Null hasta init(). */
|
|
@@ -2106,6 +2142,7 @@ var DeepdotsPopups = class {
|
|
|
2106
2142
|
this.renderChrome = config.renderChrome ?? true;
|
|
2107
2143
|
this.showProgressBar = config.showProgressBar;
|
|
2108
2144
|
this.surveyCss = config.surveyCss;
|
|
2145
|
+
this.cspNonce = config.cspNonce;
|
|
2109
2146
|
this.onFeedbackSession = config.onFeedbackSession;
|
|
2110
2147
|
this.config = {
|
|
2111
2148
|
apiKey: config.apiKey || void 0,
|
|
@@ -2206,7 +2243,6 @@ var DeepdotsPopups = class {
|
|
|
2206
2243
|
this.initialized = true;
|
|
2207
2244
|
this.log("SDK initialized", this.config);
|
|
2208
2245
|
if (this.renderer.init) this.renderer.init();
|
|
2209
|
-
this.setupPopupContainer();
|
|
2210
2246
|
this.awaitingPopups = Boolean(this.config.apiKey && this.baseUrl);
|
|
2211
2247
|
this.fetchPopupsFromServer().then((defs) => {
|
|
2212
2248
|
if (!defs) this.dropPendingTriggers();
|
|
@@ -3177,27 +3213,6 @@ var DeepdotsPopups = class {
|
|
|
3177
3213
|
listeners.delete(listener);
|
|
3178
3214
|
}
|
|
3179
3215
|
}
|
|
3180
|
-
/** Setup popup container element */
|
|
3181
|
-
setupPopupContainer() {
|
|
3182
|
-
if (typeof document === "undefined") {
|
|
3183
|
-
return;
|
|
3184
|
-
}
|
|
3185
|
-
this.popupContainer = document.createElement("div");
|
|
3186
|
-
this.popupContainer.id = "deepdots-popup-container";
|
|
3187
|
-
this.popupContainer.style.cssText = `
|
|
3188
|
-
position: fixed;
|
|
3189
|
-
top: 0;
|
|
3190
|
-
left: 0;
|
|
3191
|
-
width: 100%;
|
|
3192
|
-
height: 100%;
|
|
3193
|
-
display: none;
|
|
3194
|
-
z-index: 999999;
|
|
3195
|
-
background: rgba(0, 0, 0, 0.5);
|
|
3196
|
-
justify-content: center;
|
|
3197
|
-
align-items: center;
|
|
3198
|
-
`;
|
|
3199
|
-
document.body.appendChild(this.popupContainer);
|
|
3200
|
-
}
|
|
3201
3216
|
/** Render the popup UI */
|
|
3202
3217
|
renderPopup(surveyId, productId, actions, style, title) {
|
|
3203
3218
|
const userId = this.tracking?.getUserId() ?? this.config?.userId;
|
|
@@ -3205,54 +3220,25 @@ var DeepdotsPopups = class {
|
|
|
3205
3220
|
const miniService = this.analytics?.getMiniService() ?? void 0;
|
|
3206
3221
|
const analyticsFeedbackSessionId = this.analyticsFeedbackSessionId;
|
|
3207
3222
|
this.log("tracking \xB7 survey identity \u2192", { userId: userId ?? null, sessionId: sessionId ?? null, miniService: miniService ?? null, analyticsFeedbackSessionId: analyticsFeedbackSessionId ?? null });
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
);
|
|
3224
|
-
return;
|
|
3225
|
-
}
|
|
3226
|
-
if (!this.popupContainer) return;
|
|
3227
|
-
const container = this.popupContainer;
|
|
3228
|
-
void import("./renderPopup-Z6TENBP6.mjs").then(({ renderPopup }) => {
|
|
3229
|
-
renderPopup(
|
|
3230
|
-
container,
|
|
3231
|
-
surveyId,
|
|
3232
|
-
productId,
|
|
3233
|
-
actions,
|
|
3234
|
-
(type, id, payload) => this.emitEvent(type, id, payload),
|
|
3235
|
-
() => this.hidePopup(),
|
|
3236
|
-
this.env,
|
|
3237
|
-
userId,
|
|
3238
|
-
style,
|
|
3239
|
-
sessionId,
|
|
3240
|
-
miniService,
|
|
3241
|
-
analyticsFeedbackSessionId,
|
|
3242
|
-
{ title, showProgressBar: this.showProgressBar, surveyCss: this.surveyCss, language: this.language }
|
|
3243
|
-
);
|
|
3244
|
-
});
|
|
3223
|
+
this.renderer.show(
|
|
3224
|
+
surveyId,
|
|
3225
|
+
productId,
|
|
3226
|
+
actions,
|
|
3227
|
+
(type, id, payload) => this.emitEvent(type, id, payload),
|
|
3228
|
+
() => this.hidePopup(),
|
|
3229
|
+
this.env,
|
|
3230
|
+
userId,
|
|
3231
|
+
style,
|
|
3232
|
+
sessionId,
|
|
3233
|
+
miniService,
|
|
3234
|
+
analyticsFeedbackSessionId,
|
|
3235
|
+
this.renderChrome,
|
|
3236
|
+
{ title, showProgressBar: this.showProgressBar, surveyCss: this.surveyCss, language: this.language, cspNonce: this.cspNonce }
|
|
3237
|
+
);
|
|
3245
3238
|
}
|
|
3246
3239
|
/** Hide the popup */
|
|
3247
3240
|
hidePopup() {
|
|
3248
|
-
|
|
3249
|
-
this.renderer.hide();
|
|
3250
|
-
return;
|
|
3251
|
-
}
|
|
3252
|
-
if (this.popupContainer) {
|
|
3253
|
-
this.popupContainer.style.display = "none";
|
|
3254
|
-
this.popupContainer.innerHTML = "";
|
|
3255
|
-
}
|
|
3241
|
+
this.renderer.hide();
|
|
3256
3242
|
}
|
|
3257
3243
|
/** Emit an event */
|
|
3258
3244
|
emitEvent(type, surveyId, data) {
|