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.
@@ -1,4 +1,4 @@
1
- var version$3 = "0.0.9";
1
+ var version$3 = "0.0.10";
2
2
  var packageJSON$3 = {
3
3
  version: version$3};
4
4
 
@@ -2149,6 +2149,13 @@ function resolveFocusEventConfig() {
2149
2149
  };
2150
2150
  }
2151
2151
  }
2152
+ function resolveEventBinding(config) {
2153
+ return {
2154
+ configured: typeof config.target !== 'undefined' && typeof config.type !== 'undefined',
2155
+ target: config.target,
2156
+ type: config.type,
2157
+ };
2158
+ }
2152
2159
  function openURL(tried, url, timeout, terminal) {
2153
2160
  if (terminal === void 0) { terminal = false; }
2154
2161
  var config = resolveFocusEventConfig();
@@ -2222,6 +2229,9 @@ function openURL(tried, url, timeout, terminal) {
2222
2229
  return new Promise(function (resolve, reject) {
2223
2230
  if (DEBUG)
2224
2231
  debugger;
2232
+ var blurBinding = resolveEventBinding(config.blur);
2233
+ var focusBinding = resolveEventBinding(config.focus);
2234
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2225
2235
  var timeoutId;
2226
2236
  var resolved = false;
2227
2237
  function cleanup() {
@@ -2230,12 +2240,14 @@ function openURL(tried, url, timeout, terminal) {
2230
2240
  timeoutId = undefined;
2231
2241
  }
2232
2242
  try {
2233
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2234
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2235
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2236
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2237
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2238
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2243
+ if (blurBinding.configured)
2244
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2245
+ if (focusBinding.configured)
2246
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2247
+ if (visibilityBinding.configured)
2248
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2249
+ if (navigationPagehide)
2250
+ EventKit.remove(top, 'pagehide', onpagehide);
2239
2251
  }
2240
2252
  catch (_) {
2241
2253
  }
@@ -2269,10 +2281,10 @@ function openURL(tried, url, timeout, terminal) {
2269
2281
  clearTimeout(timeoutId);
2270
2282
  timeoutId = undefined;
2271
2283
  }
2272
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2273
- EventKit.remove(config.blur.target, config.blur.type, onblur);
2274
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2275
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2284
+ if (blurBinding.configured)
2285
+ EventKit.remove(blurBinding.target, blurBinding.type, onblur);
2286
+ if (focusBinding.configured)
2287
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2276
2288
  }
2277
2289
  function onfocus() {
2278
2290
  done(true);
@@ -2283,13 +2295,19 @@ function openURL(tried, url, timeout, terminal) {
2283
2295
  else
2284
2296
  onfocus();
2285
2297
  }
2298
+ function onpagehide() {
2299
+ done(true);
2300
+ }
2301
+ var navigationPagehide = config.blur.type !== 'pagehide';
2286
2302
  timeoutId = setTimeout(function () {
2287
2303
  done(false);
2288
2304
  }, timeout);
2289
- if (typeof config.blur.target !== 'undefined' && typeof config.blur.type !== 'undefined')
2290
- EventKit.add(config.blur.target, config.blur.type, onblur);
2291
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2292
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2305
+ if (blurBinding.configured)
2306
+ EventKit.add(blurBinding.target, blurBinding.type, onblur);
2307
+ if (visibilityBinding.configured)
2308
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2309
+ if (navigationPagehide)
2310
+ EventKit.add(top, 'pagehide', onpagehide);
2293
2311
  if (!hasFocus(topDocument))
2294
2312
  restoreFocus();
2295
2313
  try {
@@ -2893,6 +2911,8 @@ function resolveFile(module) {
2893
2911
  });
2894
2912
  }
2895
2913
  function resolveInput(module, resolve) {
2914
+ var focusBinding = resolveEventBinding(config.focus);
2915
+ var visibilityBinding = resolveEventBinding(config.visibilitychange);
2896
2916
  var resolved = false;
2897
2917
  function done(success) {
2898
2918
  if (resolved)
@@ -2930,10 +2950,10 @@ function resolveFile(module) {
2930
2950
  }
2931
2951
  else {
2932
2952
  module.onclick = function () {
2933
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2934
- EventKit.add(config.focus.target, config.focus.type, onfocus);
2935
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2936
- EventKit.add(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2953
+ if (focusBinding.configured)
2954
+ EventKit.add(focusBinding.target, focusBinding.type, onfocus);
2955
+ if (visibilityBinding.configured)
2956
+ EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2937
2957
  setTimeout(function () {
2938
2958
  EventKit.add(topDocument, 'click', onclick);
2939
2959
  }, 100);
@@ -2945,10 +2965,10 @@ function resolveFile(module) {
2945
2965
  function cleanup() {
2946
2966
  CLEANUP_INPUT_ELEMENT = null;
2947
2967
  try {
2948
- if (typeof config.focus.target !== 'undefined' && typeof config.focus.type !== 'undefined')
2949
- EventKit.remove(config.focus.target, config.focus.type, onfocus);
2950
- if (typeof config.visibilitychange.target !== 'undefined' && typeof config.visibilitychange.type !== 'undefined')
2951
- EventKit.remove(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
2968
+ if (focusBinding.configured)
2969
+ EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
2970
+ if (visibilityBinding.configured)
2971
+ EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
2952
2972
  EventKit.remove(topDocument, 'click', onclick);
2953
2973
  }
2954
2974
  catch (_) {