@livx.cc/iab-escape 0.4.0 → 0.5.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 +7 -2
- package/dist/IabEscape.d.ts +5 -3
- package/dist/IabEscape.js +30 -9
- package/dist/iab-escape.min.js +2 -2
- package/dist/loader.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,9 +110,14 @@ myUi.onContinue(() => esc.dismiss());
|
|
|
110
110
|
|
|
111
111
|
## Declined the prompt
|
|
112
112
|
|
|
113
|
-
"Continue here" navigates the webview to the destination (`continueUrl` / `data-continue-url`, default: the `url` / `data-url` target; with no url it only removes the overlay). A custom UI calls `esc.continue()`.
|
|
113
|
+
"Continue here" navigates the webview to the destination (`continueUrl` / `data-continue-url`, default: the `url` / `data-url` target; with no url it only removes the overlay). The loader is kept (text `labels.continuing`, "Opening…") until the page unloads, so no bare host page shows in between. A custom UI calls `esc.continue()`.
|
|
114
114
|
|
|
115
|
-
`fallback
|
|
115
|
+
`fallback` (`data-fallback`), default `'manual'`:
|
|
116
|
+
|
|
117
|
+
- `'auto'`: continues by itself when the page is still here `fallbackMs` (default 2500) after the fire. A native confirm may leave the page visible with timers running, so it only continues when `document.visibilityState` is `visible` and `document.hasFocus()` is true, re-checking every 150 ms up to `fallbackMaxMs` (15000). Device-unverified.
|
|
118
|
+
- `'parallel'`: fires the scheme and navigates to the destination `parallelDelayMs` (`data-parallel-delay-ms`, default 0) later, whatever the confirm answer. Risk: navigating may dismiss the app's confirm dialog before the user answers. Device-unverified.
|
|
119
|
+
|
|
120
|
+
No re-fire happens after either navigates.
|
|
116
121
|
|
|
117
122
|
## Limits
|
|
118
123
|
|
package/dist/IabEscape.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type Labels, type Theme } from './loader';
|
|
|
3
3
|
import { type Rule } from './matrix';
|
|
4
4
|
export type { Env, Labels, Rule, Theme };
|
|
5
5
|
export interface State {
|
|
6
|
-
phase: 'opening' | 'fallback' | 'dismissed' | 'reentry';
|
|
6
|
+
phase: 'opening' | 'fallback' | 'continuing' | 'dismissed' | 'reentry';
|
|
7
7
|
url: string | null;
|
|
8
8
|
}
|
|
9
9
|
export interface AttemptInfo {
|
|
@@ -36,9 +36,11 @@ export declare class IabEscapeOptions {
|
|
|
36
36
|
/** Where "Continue here" (and the auto fallback) navigates the webview. Default: `url`; none -> just dismiss. */
|
|
37
37
|
continueUrl: string | null;
|
|
38
38
|
/** 'auto': if the page did not go away after the fire, continue in the webview by itself. Device-unverified. */
|
|
39
|
-
fallback: 'manual' | 'auto';
|
|
39
|
+
fallback: 'manual' | 'auto' | 'parallel';
|
|
40
40
|
/** 'auto' only: wait this long after the fire before the first check. */
|
|
41
41
|
fallbackMs: number;
|
|
42
|
+
/** 'parallel' only: navigate to the destination this long after the scheme fires, whatever the confirm answer. */
|
|
43
|
+
parallelDelayMs: number;
|
|
42
44
|
/** 'auto' only: stop re-checking (every 500 ms while the page is unfocused or hidden) this long after the fire. */
|
|
43
45
|
fallbackMaxMs: number;
|
|
44
46
|
/** Max automatic fires per page lifetime (the first fire + re-entry re-fires). */
|
|
@@ -86,7 +88,7 @@ export declare class IabEscape {
|
|
|
86
88
|
private state;
|
|
87
89
|
/** Stops re-fires and removes the built-in loader. Wire a custom UI's "Continue here" to this. */
|
|
88
90
|
dismiss(): void;
|
|
89
|
-
/** "Continue here":
|
|
91
|
+
/** "Continue here": navigate the current webview to the destination, keeping the loader (no destination: just dismiss). */
|
|
90
92
|
continue(): void;
|
|
91
93
|
private continueTarget;
|
|
92
94
|
/**
|
package/dist/IabEscape.js
CHANGED
|
@@ -12,7 +12,7 @@ function detectEnv(ua) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// src/loader.ts
|
|
15
|
-
var DEFAULT_LABELS = { opening: "Opening in your browser…", open: "Open in browser", stay: "Continue here" };
|
|
15
|
+
var DEFAULT_LABELS = { opening: "Opening in your browser…", open: "Open in browser", stay: "Continue here", continuing: "Opening…" };
|
|
16
16
|
var VARS = {
|
|
17
17
|
bg: "--iab-bg",
|
|
18
18
|
fg: "--iab-fg",
|
|
@@ -42,6 +42,7 @@ class Loader {
|
|
|
42
42
|
open;
|
|
43
43
|
stay;
|
|
44
44
|
spin;
|
|
45
|
+
msg;
|
|
45
46
|
constructor(doc, labels, theme = {}, onStay) {
|
|
46
47
|
this.doc = doc;
|
|
47
48
|
this.labels = labels;
|
|
@@ -65,6 +66,14 @@ class Loader {
|
|
|
65
66
|
this.open.hidden = false;
|
|
66
67
|
this.stay.hidden = false;
|
|
67
68
|
}
|
|
69
|
+
continuing() {
|
|
70
|
+
if (!this.root)
|
|
71
|
+
this.build();
|
|
72
|
+
this.spin.hidden = false;
|
|
73
|
+
this.open.hidden = true;
|
|
74
|
+
this.stay.hidden = true;
|
|
75
|
+
this.msg.textContent = this.labels.continuing;
|
|
76
|
+
}
|
|
68
77
|
hide() {
|
|
69
78
|
this.root?.remove();
|
|
70
79
|
this.root = null;
|
|
@@ -86,7 +95,7 @@ class Loader {
|
|
|
86
95
|
const style = this.doc.createElement("style");
|
|
87
96
|
style.textContent = CSS;
|
|
88
97
|
this.spin = this.el("div", "ie-spin");
|
|
89
|
-
const msg = this.el("div", "ie-msg", this.labels.opening);
|
|
98
|
+
const msg = this.msg = this.el("div", "ie-msg", this.labels.opening);
|
|
90
99
|
this.open = this.el("a", "ie-open", this.labels.open);
|
|
91
100
|
this.stay = this.el("a", "ie-stay", this.labels.stay);
|
|
92
101
|
this.stay.href = "#";
|
|
@@ -153,6 +162,7 @@ class IabEscapeOptions {
|
|
|
153
162
|
continueUrl = null;
|
|
154
163
|
fallback = "manual";
|
|
155
164
|
fallbackMs = 2500;
|
|
165
|
+
parallelDelayMs = 0;
|
|
156
166
|
fallbackMaxMs = 15000;
|
|
157
167
|
maxAutoFires = 3;
|
|
158
168
|
window = null;
|
|
@@ -170,8 +180,11 @@ function optionsFromDataset(d) {
|
|
|
170
180
|
o.url = d.url;
|
|
171
181
|
if (d.continueUrl)
|
|
172
182
|
o.continueUrl = d.continueUrl;
|
|
173
|
-
if (d.fallback === "auto" || d.fallback === "manual")
|
|
183
|
+
if (d.fallback === "auto" || d.fallback === "manual" || d.fallback === "parallel")
|
|
174
184
|
o.fallback = d.fallback;
|
|
185
|
+
const pd = d.parallelDelayMs?.trim();
|
|
186
|
+
if (pd && Number.isFinite(Number(pd)) && Number(pd) >= 0)
|
|
187
|
+
o.parallelDelayMs = Number(pd);
|
|
175
188
|
const fm = d.fallbackMs?.trim();
|
|
176
189
|
if (fm && Number.isFinite(Number(fm)) && Number(fm) >= 0)
|
|
177
190
|
o.fallbackMs = Number(fm);
|
|
@@ -193,6 +206,8 @@ function optionsFromDataset(d) {
|
|
|
193
206
|
labels.open = d.labelOpen;
|
|
194
207
|
if (d.labelStay)
|
|
195
208
|
labels.stay = d.labelStay;
|
|
209
|
+
if (d.labelContinuing)
|
|
210
|
+
labels.continuing = d.labelContinuing;
|
|
196
211
|
if (Object.keys(labels).length)
|
|
197
212
|
o.labels = labels;
|
|
198
213
|
return o;
|
|
@@ -200,14 +215,14 @@ function optionsFromDataset(d) {
|
|
|
200
215
|
var WATCH_MS = 3000;
|
|
201
216
|
var REVEAL_MS = 800;
|
|
202
217
|
var REENTER_LOCK_MS = 1000;
|
|
203
|
-
var AUTO_RECHECK_MS =
|
|
218
|
+
var AUTO_RECHECK_MS = 150;
|
|
204
219
|
var FIRED = "__iabEscapeFired";
|
|
205
220
|
var hasParam = (url, key) => new URLSearchParams(url.split("#")[0].split("?")[1] ?? "").has(key);
|
|
206
221
|
|
|
207
222
|
class IabEscape {
|
|
208
223
|
options;
|
|
209
|
-
static version = "0.
|
|
210
|
-
static buildTime = "2026-11-
|
|
224
|
+
static version = "0.5.0";
|
|
225
|
+
static buildTime = "2026-11-17T10:56:42.504Z";
|
|
211
226
|
ldr = null;
|
|
212
227
|
fires = 0;
|
|
213
228
|
watching = false;
|
|
@@ -325,10 +340,14 @@ class IabEscape {
|
|
|
325
340
|
this.state("dismissed");
|
|
326
341
|
}
|
|
327
342
|
continue() {
|
|
328
|
-
this.dismiss();
|
|
329
343
|
const to = this.continueTarget();
|
|
330
|
-
if (to)
|
|
331
|
-
this.
|
|
344
|
+
if (!to)
|
|
345
|
+
return this.dismiss();
|
|
346
|
+
this.dismissed = true;
|
|
347
|
+
if (this.o.ui)
|
|
348
|
+
this.loader().continuing();
|
|
349
|
+
this.state("continuing");
|
|
350
|
+
this.win.location.href = to;
|
|
332
351
|
}
|
|
333
352
|
continueTarget() {
|
|
334
353
|
const input = this.o.continueUrl ?? this.o.url;
|
|
@@ -379,6 +398,8 @@ class IabEscape {
|
|
|
379
398
|
}, REVEAL_MS);
|
|
380
399
|
if (this.o.fallback === "auto")
|
|
381
400
|
this.armAutoFallback();
|
|
401
|
+
if (this.o.fallback === "parallel" && this.continueTarget())
|
|
402
|
+
this.win.setTimeout(() => this.continue(), this.o.parallelDelayMs);
|
|
382
403
|
return true;
|
|
383
404
|
}
|
|
384
405
|
watchReentry() {
|
package/dist/iab-escape.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var{defineProperty:u,getOwnPropertyNames:A,getOwnPropertyDescriptor:L}=Object,
|
|
1
|
+
(()=>{var{defineProperty:u,getOwnPropertyNames:A,getOwnPropertyDescriptor:L}=Object,M=Object.prototype.hasOwnProperty;function O(e){return this[e]}var S=(e)=>{var t=(d??=new WeakMap).get(e),i;if(t)return t;if(t=u({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of A(e))if(!M.call(t,n))u(t,n,{get:O.bind(e,n),enumerable:!(i=L(e,n))||i.enumerable})}return d.set(e,t),t},d;var _=(e)=>e;function R(e,t){this[e]=_.bind(null,t)}var I=(e,t)=>{for(var i in t)u(e,i,{get:t[i],enumerable:!0,configurable:!0,set:R.bind(t,i)})};var D={};I(D,{boot:()=>x});var U=[["threads",/Barcelona/],["instagram",/Instagram/],["messenger",/FBAN\/MessengerForiOS|FB_IAB\/MESSENGER|Orca/],["facebook",/FBAN|FBAV|FB_IAB/]];function h(e){let t=U.find(([,n])=>n.test(e))?.[0]??null,i=/iPhone|iPad|iPod/.test(e)?"ios":/Android/.test(e)?"android":null;return{app:t,os:i,inApp:t!==null}}var b={opening:"Opening in your browser…",open:"Open in browser",stay:"Continue here",continuing:"Opening…"},f={bg:"--iab-bg",fg:"--iab-fg",accent:"--iab-accent",accentFg:"--iab-accent-fg",radius:"--iab-radius",font:"--iab-font"};class p{doc;labels;theme;onStay;root=null;open;stay;spin;msg;constructor(e,t,i={},n){this.doc=e;this.labels=t;this.theme=i;this.onStay=n}get visible(){return this.root!==null}show(){if(!this.root)this.build();this.spin.hidden=!1,this.open.hidden=!0,this.stay.hidden=!0}reveal(e){if(!this.root)this.build();this.open.href=e,this.open.hidden=!1,this.stay.hidden=!1}continuing(){if(!this.root)this.build();this.spin.hidden=!1,this.open.hidden=!0,this.stay.hidden=!0,this.msg.textContent=this.labels.continuing}hide(){this.root?.remove(),this.root=null}el(e,t,i){let n=this.doc.createElement(e);if(n.className=t,i)n.textContent=i;return n}build(){let e=this.el("div","");e.id="iab-escape",e.setAttribute("role","status");let t=Object.keys(f).filter((s)=>this.theme[s]).map((s)=>`${f[s]}:${this.theme[s]}`).join(";");if(t)e.setAttribute("style",t);let i=this.doc.createElement("style");i.textContent=`
|
|
2
2
|
#iab-escape{position:fixed;inset:0;z-index:2147483647;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;
|
|
3
3
|
padding:max(24px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));
|
|
4
4
|
background:var(--iab-bg,#fff);color:var(--iab-fg,#111);font:var(--iab-font,18px/1.35 -apple-system,system-ui,sans-serif);text-align:center}
|
|
@@ -8,4 +8,4 @@ background:var(--iab-bg,#fff);color:var(--iab-fg,#111);font:var(--iab-font,18px/
|
|
|
8
8
|
#iab-escape [hidden]{display:none}
|
|
9
9
|
@keyframes ie-r{to{transform:rotate(360deg)}}
|
|
10
10
|
@media (prefers-color-scheme:dark){#iab-escape{background:var(--iab-bg,#111);color:var(--iab-fg,#f2f2f2)}}
|
|
11
|
-
@media (prefers-reduced-motion:reduce){#iab-escape .ie-spin{animation:none}}`,this.spin=this.el("div","ie-spin");let n=this.el("div","ie-msg",this.labels.opening);this.open=this.el("a","ie-open",this.labels.open),this.stay=this.el("a","ie-stay",this.labels.stay),this.stay.href="#",this.stay.addEventListener("click",(s)=>{s.preventDefault(),this.hide(),this.onStay?.()});for(let s of[i,this.spin,n,this.open,this.stay])e.appendChild(s);(this.doc.body??this.doc.documentElement).appendChild(e),this.root=e}}var m=(e)=>e.protocol==="https:"?"x-safari-"+e.href:null,g=(e)=>(t)=>`${e}://extbrowser/?url=${encodeURIComponent(t.href)}`,v=(e)=>`intent://${e.noHash.replace(/^https?:\/\//i,"")}#Intent;scheme=${e.protocol.slice(0,-1)};end`;var y=[{app:"instagram",os:"ios",proven:!0,delayMs:0,build:g("instagram"),testedOn:{date:"2026-11-16",os:"iOS 26.7.3",app:"Instagram 455.0.0.35.67"}},{app:"facebook",os:"ios",proven:!0,delayMs:1500,build:m,testedOn:{date:"2026-11-16",os:"iOS 26.7.3",app:"Facebook 587.0.0.31.71"}},{app:"facebook",os:"android",proven:!0,delayMs:0,build:v,testedOn:{date:"2026-11-16",os:"Android 16",app:"Facebook 587.0.0.39.55"}},{app:"instagram",os:"android",proven:!1,delayMs:0,build:v,testedOn:null},{app:"threads",os:"ios",proven:!1,delayMs:0,build:g("barcelona"),testedOn:null},{app:"messenger",os:"ios",proven:!1,delayMs:1500,build:m,testedOn:null}];class k{url=null;userAgent=null;delayMs=null;includeUnproven=!1;markParam="iab_escaped";onAttempt=null;onResult=null;ui=!0;labels={};theme={};onState=null;continueUrl=null;fallback="manual";fallbackMs=2500;fallbackMaxMs=15000;maxAutoFires=3;window=null}function
|
|
11
|
+
@media (prefers-reduced-motion:reduce){#iab-escape .ie-spin{animation:none}}`,this.spin=this.el("div","ie-spin");let n=this.msg=this.el("div","ie-msg",this.labels.opening);this.open=this.el("a","ie-open",this.labels.open),this.stay=this.el("a","ie-stay",this.labels.stay),this.stay.href="#",this.stay.addEventListener("click",(s)=>{s.preventDefault(),this.hide(),this.onStay?.()});for(let s of[i,this.spin,n,this.open,this.stay])e.appendChild(s);(this.doc.body??this.doc.documentElement).appendChild(e),this.root=e}}var m=(e)=>e.protocol==="https:"?"x-safari-"+e.href:null,g=(e)=>(t)=>`${e}://extbrowser/?url=${encodeURIComponent(t.href)}`,v=(e)=>`intent://${e.noHash.replace(/^https?:\/\//i,"")}#Intent;scheme=${e.protocol.slice(0,-1)};end`;var y=[{app:"instagram",os:"ios",proven:!0,delayMs:0,build:g("instagram"),testedOn:{date:"2026-11-16",os:"iOS 26.7.3",app:"Instagram 455.0.0.35.67"}},{app:"facebook",os:"ios",proven:!0,delayMs:1500,build:m,testedOn:{date:"2026-11-16",os:"iOS 26.7.3",app:"Facebook 587.0.0.31.71"}},{app:"facebook",os:"android",proven:!0,delayMs:0,build:v,testedOn:{date:"2026-11-16",os:"Android 16",app:"Facebook 587.0.0.39.55"}},{app:"instagram",os:"android",proven:!1,delayMs:0,build:v,testedOn:null},{app:"threads",os:"ios",proven:!1,delayMs:0,build:g("barcelona"),testedOn:null},{app:"messenger",os:"ios",proven:!1,delayMs:1500,build:m,testedOn:null}];class k{url=null;userAgent=null;delayMs=null;includeUnproven=!1;markParam="iab_escaped";onAttempt=null;onResult=null;ui=!0;labels={};theme={};onState=null;continueUrl=null;fallback="manual";fallbackMs=2500;parallelDelayMs=0;fallbackMaxMs=15000;maxAutoFires=3;window=null}function T(e){let t={},i=e.delayMs?.trim();if(i&&Number.isFinite(Number(i))&&Number(i)>=0)t.delayMs=Number(i);if(e.markParam!==void 0)t.markParam=e.markParam===""?null:e.markParam;if(e.includeUnproven!==void 0)t.includeUnproven=!0;if(e.url)t.url=e.url;if(e.continueUrl)t.continueUrl=e.continueUrl;if(e.fallback==="auto"||e.fallback==="manual"||e.fallback==="parallel")t.fallback=e.fallback;let n=e.parallelDelayMs?.trim();if(n&&Number.isFinite(Number(n))&&Number(n)>=0)t.parallelDelayMs=Number(n);let s=e.fallbackMs?.trim();if(s&&Number.isFinite(Number(s))&&Number(s)>=0)t.fallbackMs=Number(s);if(e.ui!==void 0)t.ui=e.ui!=="false";let a={};if(e.accent)a.accent=e.accent;if(e.bg)a.bg=e.bg;if(e.fg)a.fg=e.fg;if(Object.keys(a).length)t.theme=a;let r={};if(e.labelOpening)r.opening=e.labelOpening;if(e.labelOpen)r.open=e.labelOpen;if(e.labelStay)r.stay=e.labelStay;if(e.labelContinuing)r.continuing=e.labelContinuing;if(Object.keys(r).length)t.labels=r;return t}var F=3000,N=800,P=1000,w=150,l="__iabEscapeFired",E=(e,t)=>new URLSearchParams(e.split("#")[0].split("?")[1]??"").has(t);class c{options;static version="0.5.0";static buildTime="2026-11-17T10:56:42.504Z";ldr=null;fires=0;watching=!1;wentAway=!1;locked=!1;dismissed=!1;fallbackSeq=0;base="";constructor(e){this.options=e;this.options={...new k,...e}}get o(){return this.options}get win(){return this.o.window??globalThis.window}detect(){return h(this.o.userAgent??this.win.navigator.userAgent)}getRule(){let{app:e,os:t}=this.detect(),i=y.find((n)=>n.app===e&&n.os===t);return i&&(i.proven||this.o.includeUnproven)?i:null}buildUrl(){let e=this.getRule(),t=e&&this.target();return e&&t?e.build(t):null}pageUrl(){return this.base||=this.win.location.href}target(){let e=this.pageUrl(),t=this.o.url??e,i;try{i=new URL(t,e)}catch{return null}if(!/^https?:$/.test(i.protocol))return null;let n=/^https?:\/\//i.test(t)?t:i.href,s=n.indexOf("#"),a=s<0?n:n.slice(0,s),r=s<0?"":n.slice(s),o=this.o.markParam;if(o&&!E(a,o))a+=(a.includes("?")?/[?&]$/.test(a)?"":"&":"?")+o+"=1";return{href:a+r,noHash:a,protocol:i.protocol}}escape(){let e=this.getRule(),t=this.buildUrl();if(!e||!t)return!1;return this.o.onAttempt?.({rule:e,url:t}),this.win.location.href=t,this.watch({rule:e,url:t}),!0}auto(){let{win:e}=this,t=this.o.markParam,i=this.getRule();if(!i||e[l]||t&&E(e.location.href,t))return()=>{};e[l]=!0;let{document:n}=e;if(this.dismissed=!1,this.o.ui)this.loader().show();this.state("opening");let s=!1,a,r=()=>{if(s=!0,!this.fireNow())e[l]=!1},o=()=>{if(n.removeEventListener("DOMContentLoaded",o),this.delay(i)<=0)r();else a=e.setTimeout(r,this.delay(i))};if(n.readyState==="loading")n.addEventListener("DOMContentLoaded",o);else o();return()=>{if(s)return;if(n.removeEventListener("DOMContentLoaded",o),a!==void 0)e.clearTimeout(a);e[l]=!1,this.ldr?.hide()}}loader(){return this.ldr??=new p(this.win.document,{...b,...this.o.labels},this.o.theme,()=>this.continue())}state(e){this.o.onState?.({phase:e,url:this.buildUrl()})}dismiss(){this.dismissed=!0,this.ldr?.hide(),this.state("dismissed")}continue(){let e=this.continueTarget();if(!e)return this.dismiss();if(this.dismissed=!0,this.o.ui)this.loader().continuing();this.state("continuing"),this.win.location.href=e}continueTarget(){let e=this.o.continueUrl??this.o.url;if(!e)return null;try{let t=new URL(e,this.pageUrl());return/^https?:$/.test(t.protocol)?/^https?:\/\//i.test(e)?e:t.href:null}catch{return null}}armAutoFallback(){let{win:e}=this,t=e.document,i=++this.fallbackSeq,n=this.o.fallbackMs,s=()=>{if(i!==this.fallbackSeq||this.dismissed||this.wentAway)return;if(t.visibilityState==="visible"&&(t.hasFocus?.()??!0))return this.continue();if(n+=w,n<=this.o.fallbackMaxMs)e.setTimeout(s,w)};e.setTimeout(s,this.o.fallbackMs)}fallback(){let e=this.buildUrl();if(e&&this.o.ui)this.loader().reveal(e);this.state("fallback")}delay(e){return this.o.delayMs??e.delayMs}fireNow(){if(!this.escape())return this.ldr?.hide(),!1;if(this.fires++,this.watchReentry(),this.win.setTimeout(()=>{if(!this.dismissed)this.fallback()},N),this.o.fallback==="auto")this.armAutoFallback();if(this.o.fallback==="parallel"&&this.continueTarget())this.win.setTimeout(()=>this.continue(),this.o.parallelDelayMs);return!0}watchReentry(){if(this.watching)return;this.watching=!0;let{win:e}=this,t=e.document;e.addEventListener("pagehide",()=>{this.wentAway=!0}),t.addEventListener("visibilitychange",()=>{if(t.visibilityState==="hidden")this.wentAway=!0;else this.reenter()}),e.addEventListener("pageshow",(i)=>{if(i.persisted)this.wentAway=!0,this.reenter()})}reenter(){let{win:e}=this,t=this.getRule();if(!this.wentAway||this.locked||this.dismissed||!t)return;if(this.wentAway=!1,this.locked=!0,e.setTimeout(()=>{this.locked=!1},P),this.fires>=this.o.maxAutoFires)return this.fallback();if(this.o.ui)this.loader().show();if(this.state("reentry"),this.delay(t)<=0)this.fireNow();else e.setTimeout(()=>this.fireNow(),this.delay(t))}bindLink(e){let t=this.buildUrl();if(!t)return!1;return e.href=t,!0}watch(e){let{win:t}=this,i=!1,n=()=>{i=!0},s=()=>{if(t.document.visibilityState==="hidden")n()};t.addEventListener("pagehide",n),t.document.addEventListener("visibilitychange",s),t.setTimeout(()=>{t.removeEventListener("pagehide",n),t.document.removeEventListener("visibilitychange",s),this.o.onResult?.({...e,outcome:i?"left":"stayed-or-unknown"})},F)}}function x(e,t,i={}){t.IabEscape=c;let n=e?.currentScript;if(n?.hasAttribute("data-auto"))new c({...T(n.dataset),...i}).auto()}if(typeof document<"u")x(document,globalThis);})();
|
package/dist/loader.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface Labels {
|
|
|
2
2
|
opening: string;
|
|
3
3
|
open: string;
|
|
4
4
|
stay: string;
|
|
5
|
+
continuing: string;
|
|
5
6
|
}
|
|
6
7
|
export declare const DEFAULT_LABELS: Labels;
|
|
7
8
|
/** Styling API: the `#iab-escape` root, the classes below, and these CSS variables (all optional). */
|
|
@@ -23,12 +24,15 @@ export declare class Loader {
|
|
|
23
24
|
private open;
|
|
24
25
|
private stay;
|
|
25
26
|
private spin;
|
|
27
|
+
private msg;
|
|
26
28
|
constructor(doc: Document, labels: Labels, theme?: Theme, onStay?: (() => void) | undefined);
|
|
27
29
|
get visible(): boolean;
|
|
28
30
|
/** Spinner state (also resets a previously revealed button). */
|
|
29
31
|
show(): void;
|
|
30
32
|
/** Reveals the real `<a>` (so a tap works if the automatic fire was ignored) and the "stay" link. */
|
|
31
33
|
reveal(href: string): void;
|
|
34
|
+
/** A continue navigation is under way: keep the overlay (no bare page in between), spinner + short text. */
|
|
35
|
+
continuing(): void;
|
|
32
36
|
hide(): void;
|
|
33
37
|
private el;
|
|
34
38
|
private build;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livx.cc/iab-escape",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Move users from the Facebook / Instagram in-app browser to the device default browser, using only trigger methods proven on real devices.",
|
|
6
6
|
"license": "MIT",
|