web-launch-kit 0.0.9 → 0.0.10

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.ko.md CHANGED
@@ -400,6 +400,11 @@ Meta 계열 웹뷰(Facebook, Instagram) 안에서는 차단됩니다. http(s) UR
400
400
  - **웹 폴백은 내비게이션 시점에 resolve합니다.** `fallback`이나 웹스토어 후보는 문서 자체를
401
401
  교체하므로 기다릴 앱 전환이 없습니다. 이동을 시작하는 즉시 resolve하며, 이동이 성공한 뒤에
402
402
  reject되는 일이 없습니다.
403
+ - **예상 밖의 내비게이션도 결과로 확정됩니다.** 앱이 설치되지 않은 유니버설 링크, 브라우저
404
+ 폴백이 실행된 intent처럼 실제 페이지 이동으로 바뀌는 후보는 타임아웃 전에 문서가 내려가
405
+ 결과가 유실됐습니다. 이제 `pagehide`가 해당 후보를 resolve합니다. 앱 전환은 `pagehide` 없이
406
+ `hidden`만 발생하므로 두 경우는 구분됩니다. resolve는 언로드 중에 실행되며, 그 시점에도
407
+ `sendBeacon`은 정상 전송됩니다.
403
408
 
404
409
  ## 브라우저 지원
405
410
 
package/README.md CHANGED
@@ -411,6 +411,11 @@ the button on `utils.canEscapeWebview`.
411
411
  - **Web fallbacks resolve on navigation.** A `fallback` or web-store candidate replaces the
412
412
  document, so there is no app switch to wait for — those resolve as soon as the navigation
413
413
  is issued instead of risking a rejection after the move already succeeded.
414
+ - **Unplanned navigations settle too.** A candidate that turns into a real navigation — a
415
+ universal link whose app is not installed, an intent whose browser fallback fires — used to
416
+ unload the document before the timeout, losing the result. `pagehide` now resolves the
417
+ candidate, and since an app switch fires `hidden` without `pagehide`, the two cases stay
418
+ distinguishable. The resolve runs during unload, where `sendBeacon` still delivers.
414
419
 
415
420
  ## Browser support
416
421
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version$3 = "0.0.9";
5
+ var version$3 = "0.0.10";
6
6
  var packageJSON$3 = {
7
7
  version: version$3};
8
8
 
@@ -2153,6 +2153,13 @@ function resolveFocusEventConfig() {
2153
2153
  };
2154
2154
  }
2155
2155
  }
2156
+ function resolveEventBinding(config) {
2157
+ return {
2158
+ configured: typeof config.target !== 'undefined' && typeof config.type !== 'undefined',
2159
+ target: config.target,
2160
+ type: config.type,
2161
+ };
2162
+ }
2156
2163
  function openURL(tried, url, timeout, terminal) {
2157
2164
  if (terminal === void 0) { terminal = false; }
2158
2165
  var config = resolveFocusEventConfig();
@@ -2226,6 +2233,9 @@ function openURL(tried, url, timeout, terminal) {
2226
2233
  return new Promise(function (resolve, reject) {
2227
2234
  if (DEBUG)
2228
2235
  debugger;
2236
+ var blurBinding = resolveEventBinding(config.blur);
2237
+ var focusBinding = resolveEventBinding(config.focus);
2238
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2229
2239
  var timeoutId;
2230
2240
  var resolved = false;
2231
2241
  function cleanup() {
@@ -2234,12 +2244,14 @@ function openURL(tried, url, timeout, terminal) {
2234
2244
  timeoutId = undefined;
2235
2245
  }
2236
2246
  try {
2237
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2238
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2239
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2240
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2241
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2242
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2247
+ if (blurBinding.configured)
2248
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2249
+ if (focusBinding.configured)
2250
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2251
+ if (visibilityBinding.configured)
2252
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2253
+ if (navigationPagehide)
2254
+ EventKit.remove(top, 'pagehide', onpagehide);
2243
2255
  }
2244
2256
  catch (_) {
2245
2257
  }
@@ -2273,10 +2285,10 @@ function openURL(tried, url, timeout, terminal) {
2273
2285
  clearTimeout(timeoutId);
2274
2286
  timeoutId = undefined;
2275
2287
  }
2276
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2277
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2278
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2279
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2288
+ if (blurBinding.configured)
2289
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2290
+ if (focusBinding.configured)
2291
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2280
2292
  }
2281
2293
  function onfocus() {
2282
2294
  done(true);
@@ -2287,13 +2299,19 @@ function openURL(tried, url, timeout, terminal) {
2287
2299
  else
2288
2300
  onfocus();
2289
2301
  }
2302
+ function onpagehide() {
2303
+ done(true);
2304
+ }
2305
+ var navigationPagehide = config.blur.type !== 'pagehide';
2290
2306
  timeoutId = setTimeout(function () {
2291
2307
  done(false);
2292
2308
  }, timeout);
2293
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2294
- EventKit.add(config.blur.target, config.blur.type, onblur);
2295
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2296
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2309
+ if (blurBinding.configured)
2310
+ EventKit.add(blurBinding.target, blurBinding.type, onblur);
2311
+ if (visibilityBinding.configured)
2312
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2313
+ if (navigationPagehide)
2314
+ EventKit.add(top, 'pagehide', onpagehide);
2297
2315
  if (!hasFocus(topDocument))
2298
2316
  restoreFocus();
2299
2317
  try {
@@ -2897,6 +2915,8 @@ function resolveFile(module) {
2897
2915
  });
2898
2916
  }
2899
2917
  function resolveInput(module, resolve) {
2918
+ var focusBinding = resolveEventBinding(config.focus);
2919
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2900
2920
  var resolved = false;
2901
2921
  function done(success) {
2902
2922
  if (resolved)
@@ -2934,10 +2954,10 @@ function resolveFile(module) {
2934
2954
  }
2935
2955
  else {
2936
2956
  module.onclick = function () {
2937
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2938
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2939
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2940
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2957
+ if (focusBinding.configured)
2958
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2959
+ if (visibilityBinding.configured)
2960
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2941
2961
  setTimeout(function () {
2942
2962
  EventKit.add(topDocument, 'click', onclick);
2943
2963
  }, 100);
@@ -2949,10 +2969,10 @@ function resolveFile(module) {
2949
2969
  function cleanup() {
2950
2970
  CLEANUP_INPUT_ELEMENT = null;
2951
2971
  try {
2952
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2953
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2954
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2955
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2972
+ if (focusBinding.configured)
2973
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2974
+ if (visibilityBinding.configured)
2975
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2956
2976
  EventKit.remove(topDocument, 'click', onclick);
2957
2977
  }
2958
2978
  catch (_) {