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.
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LaunchKit = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var version$3 = "0.0.9";
7
+ var version$3 = "0.0.10";
8
8
  var packageJSON$3 = {
9
9
  version: version$3};
10
10
 
@@ -2155,6 +2155,13 @@
2155
2155
  };
2156
2156
  }
2157
2157
  }
2158
+ function resolveEventBinding(config) {
2159
+ return {
2160
+ configured: typeof config.target !== 'undefined' && typeof config.type !== 'undefined',
2161
+ target: config.target,
2162
+ type: config.type,
2163
+ };
2164
+ }
2158
2165
  function openURL(tried, url, timeout, terminal) {
2159
2166
  if (terminal === void 0) { terminal = false; }
2160
2167
  var config = resolveFocusEventConfig();
@@ -2228,6 +2235,9 @@
2228
2235
  return new Promise(function (resolve, reject) {
2229
2236
  if (DEBUG)
2230
2237
  debugger;
2238
+ var blurBinding = resolveEventBinding(config.blur);
2239
+ var focusBinding = resolveEventBinding(config.focus);
2240
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2231
2241
  var timeoutId;
2232
2242
  var resolved = false;
2233
2243
  function cleanup() {
@@ -2236,12 +2246,14 @@
2236
2246
  timeoutId = undefined;
2237
2247
  }
2238
2248
  try {
2239
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2240
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2241
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2242
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2243
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2244
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2249
+ if (blurBinding.configured)
2250
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2251
+ if (focusBinding.configured)
2252
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2253
+ if (visibilityBinding.configured)
2254
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2255
+ if (navigationPagehide)
2256
+ EventKit.remove(top, 'pagehide', onpagehide);
2245
2257
  }
2246
2258
  catch (_) {
2247
2259
  }
@@ -2275,10 +2287,10 @@
2275
2287
  clearTimeout(timeoutId);
2276
2288
  timeoutId = undefined;
2277
2289
  }
2278
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2279
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2280
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2281
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2290
+ if (blurBinding.configured)
2291
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2292
+ if (focusBinding.configured)
2293
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2282
2294
  }
2283
2295
  function onfocus() {
2284
2296
  done(true);
@@ -2289,13 +2301,19 @@
2289
2301
  else
2290
2302
  onfocus();
2291
2303
  }
2304
+ function onpagehide() {
2305
+ done(true);
2306
+ }
2307
+ var navigationPagehide = config.blur.type !== 'pagehide';
2292
2308
  timeoutId = setTimeout(function () {
2293
2309
  done(false);
2294
2310
  }, timeout);
2295
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2296
- EventKit.add(config.blur.target, config.blur.type, onblur);
2297
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2298
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2311
+ if (blurBinding.configured)
2312
+ EventKit.add(blurBinding.target, blurBinding.type, onblur);
2313
+ if (visibilityBinding.configured)
2314
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2315
+ if (navigationPagehide)
2316
+ EventKit.add(top, 'pagehide', onpagehide);
2299
2317
  if (!hasFocus(topDocument))
2300
2318
  restoreFocus();
2301
2319
  try {
@@ -2899,6 +2917,8 @@
2899
2917
  });
2900
2918
  }
2901
2919
  function resolveInput(module, resolve) {
2920
+ var focusBinding = resolveEventBinding(config.focus);
2921
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2902
2922
  var resolved = false;
2903
2923
  function done(success) {
2904
2924
  if (resolved)
@@ -2936,10 +2956,10 @@
2936
2956
  }
2937
2957
  else {
2938
2958
  module.onclick = function () {
2939
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2940
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2941
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2942
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2959
+ if (focusBinding.configured)
2960
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2961
+ if (visibilityBinding.configured)
2962
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2943
2963
  setTimeout(function () {
2944
2964
  EventKit.add(topDocument, 'click', onclick);
2945
2965
  }, 100);
@@ -2951,10 +2971,10 @@
2951
2971
  function cleanup() {
2952
2972
  CLEANUP_INPUT_ELEMENT = null;
2953
2973
  try {
2954
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2955
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2956
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2957
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2974
+ if (focusBinding.configured)
2975
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2976
+ if (visibilityBinding.configured)
2977
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2958
2978
  EventKit.remove(topDocument, 'click', onclick);
2959
2979
  }
2960
2980
  catch (_) {