@yorkjs/web-page
Advanced tools
Comparing version 0.0.6 to 0.0.7
/** | ||
* web-page.js v0.0.6 | ||
* web-page.js v0.0.7 | ||
* (c) 2021-2022 musicode | ||
@@ -90,4 +90,2 @@ * Released under the MIT License. | ||
isPageAlive = true; | ||
// @ts-ignore | ||
persisted = event.persisted === true; | ||
fireEvent(ENTER, event); | ||
@@ -102,2 +100,14 @@ }, 200); | ||
}, 200); | ||
function onPageShow(event) { | ||
// @ts-ignore | ||
persisted = event.persisted; | ||
// @ts-ignore | ||
onPageEnter(event); | ||
} | ||
function onPageHide(event) { | ||
// @ts-ignore | ||
persisted = event.persisted; | ||
// @ts-ignore | ||
onPageLeave(event); | ||
} | ||
function onPageFreeze() { | ||
@@ -132,7 +142,9 @@ isPageFrozen = true; | ||
if (supportEvent(window, 'pageshow')) { | ||
addDOMEventListener(window, 'pageshow', onPageEnter); | ||
addDOMEventListener(window, 'pageshow', onPageShow); | ||
} | ||
addDOMEventListener(window, 'load', onPageEnter); | ||
else { | ||
addDOMEventListener(window, 'load', onPageEnter); | ||
} | ||
if (supportEvent(window, 'pagehide')) { | ||
addDOMEventListener(window, 'pagehide', onPageLeave); | ||
addDOMEventListener(window, 'pagehide', onPageHide); | ||
} | ||
@@ -150,5 +162,5 @@ addDOMEventListener(window, 'beforeunload', onPageLeave); | ||
*/ | ||
const version = "0.0.6"; | ||
const version = "0.0.7"; | ||
export { ENTER, HIDE, LEAVE, SHOW, addEventListener, init, version }; | ||
//# sourceMappingURL=web-page.esm.js.map |
@@ -1,2 +0,2 @@ | ||
const n="show",e="hide",t="enter",i="leave";let o,c,d=!1,s=!1;const u={},w={};function r(n,e){return`on${e}`in n}function f(n,e,t){n.addEventListener?n.addEventListener(e,t,!0):n.attachEvent&&n.attachEvent("on"+e,t)}function a(n,e){let t;return function(){t||(n(arguments[0]),t=setTimeout((function(){t=void 0}),e))}}function h(n,e){const t={event:e,visible:o,persisted:c};u[n]=t,d&&!s&&l(n,t)}function l(n,e){const t=w[n];if(t)for(let n=0,i=t.length;n<i;n++)t[n]&&t[n](e)}function v(){const n=document.visibilityState;o="visible"===n||"hidden"!==n&&void 0}const p=a((function(n){d||(d=!0,c=!0===n.persisted,h("enter",n))}),200),g=a((function(n){d&&(h("leave",n),d=!1)}),200);function m(){}function b(n,e){const t=w[n]||(w[n]=[]);return t.push(e),"enter"===n&&u[n]&&l(n,u[n]),{remove(){for(let n=0,i=t.length;n<i;n++)t[n]===e&&t.splice(n,1)}}}v(),r(document,"visibilitychange")&&f(document,"visibilitychange",(function(n){v(),!0===o?h("show",n):!1===o&&h("hide",n)})),r(window,"pageshow")&&f(window,"pageshow",p),f(window,"load",p),r(window,"pagehide")&&f(window,"pagehide",g),f(window,"beforeunload",g),r(window,"freeze")&&f(window,"freeze",(function(){s=!0})),r(window,"resume")&&f(window,"resume",(function(){s=!1}));const E="0.0.6";export{t as ENTER,e as HIDE,i as LEAVE,n as SHOW,b as addEventListener,m as init,E as version}; | ||
const n="show",e="hide",t="enter",i="leave";let o,c,d=!1,s=!1;const u={},w={};function f(n,e){return`on${e}`in n}function r(n,e,t){n.addEventListener?n.addEventListener(e,t,!0):n.attachEvent&&n.attachEvent("on"+e,t)}function a(n,e){let t;return function(){t||(n(arguments[0]),t=setTimeout((function(){t=void 0}),e))}}function h(n,e){const t={event:e,visible:o,persisted:c};u[n]=t,d&&!s&&l(n,t)}function l(n,e){const t=w[n];if(t)for(let n=0,i=t.length;n<i;n++)t[n]&&t[n](e)}function v(){const n=document.visibilityState;o="visible"===n||"hidden"!==n&&void 0}const p=a((function(n){d||(d=!0,h("enter",n))}),200),g=a((function(n){d&&(h("leave",n),d=!1)}),200);function m(){}function b(n,e){const t=w[n]||(w[n]=[]);return t.push(e),"enter"===n&&u[n]&&l(n,u[n]),{remove(){for(let n=0,i=t.length;n<i;n++)t[n]===e&&t.splice(n,1)}}}v(),f(document,"visibilitychange")&&r(document,"visibilitychange",(function(n){v(),!0===o?h("show",n):!1===o&&h("hide",n)})),f(window,"pageshow")?r(window,"pageshow",(function(n){c=n.persisted,p(n)})):r(window,"load",p),f(window,"pagehide")&&r(window,"pagehide",(function(n){c=n.persisted,g(n)})),r(window,"beforeunload",g),f(window,"freeze")&&r(window,"freeze",(function(){s=!0})),f(window,"resume")&&r(window,"resume",(function(){s=!1}));const E="0.0.7";export{t as ENTER,e as HIDE,i as LEAVE,n as SHOW,b as addEventListener,m as init,E as version}; | ||
//# sourceMappingURL=web-page.esm.min.js.map |
/** | ||
* web-page.js v0.0.6 | ||
* web-page.js v0.0.7 | ||
* (c) 2021-2022 musicode | ||
@@ -96,4 +96,2 @@ * Released under the MIT License. | ||
isPageAlive = true; | ||
// @ts-ignore | ||
persisted = event.persisted === true; | ||
fireEvent(ENTER, event); | ||
@@ -108,2 +106,14 @@ }, 200); | ||
}, 200); | ||
function onPageShow(event) { | ||
// @ts-ignore | ||
persisted = event.persisted; | ||
// @ts-ignore | ||
onPageEnter(event); | ||
} | ||
function onPageHide(event) { | ||
// @ts-ignore | ||
persisted = event.persisted; | ||
// @ts-ignore | ||
onPageLeave(event); | ||
} | ||
function onPageFreeze() { | ||
@@ -138,7 +148,9 @@ isPageFrozen = true; | ||
if (supportEvent(window, 'pageshow')) { | ||
addDOMEventListener(window, 'pageshow', onPageEnter); | ||
addDOMEventListener(window, 'pageshow', onPageShow); | ||
} | ||
addDOMEventListener(window, 'load', onPageEnter); | ||
else { | ||
addDOMEventListener(window, 'load', onPageEnter); | ||
} | ||
if (supportEvent(window, 'pagehide')) { | ||
addDOMEventListener(window, 'pagehide', onPageLeave); | ||
addDOMEventListener(window, 'pagehide', onPageHide); | ||
} | ||
@@ -156,3 +168,3 @@ addDOMEventListener(window, 'beforeunload', onPageLeave); | ||
*/ | ||
var version = "0.0.6"; | ||
var version = "0.0.7"; | ||
@@ -159,0 +171,0 @@ exports.ENTER = ENTER; |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).WebPage={})}(this,(function(e){"use strict";var n,i,t="show",o="hide",d="enter",f="leave",r=!1,u=!1,a={},s={};function c(e,n){return"on"+n in e}function v(e,n,i){e.addEventListener?e.addEventListener(n,i,!0):e.attachEvent&&e.attachEvent("on"+n,i)}function w(e,n){var i;return function(){i||(e(arguments[0]),i=setTimeout((function(){i=void 0}),n))}}function l(e,t){var o={event:t,visible:n,persisted:i};a[e]=o,r&&!u&&h(e,o)}function h(e,n){var i=s[e];if(i)for(var t=0,o=i.length;t<o;t++)i[t]&&i[t](n)}function p(){var e=document.visibilityState;n="visible"===e||"hidden"!==e&&void 0}var b=w((function(e){r||(r=!0,i=!0===e.persisted,l(d,e))}),200),g=w((function(e){r&&(l(f,e),r=!1)}),200);p(),c(document,"visibilitychange")&&v(document,"visibilitychange",(function(e){p(),!0===n?l(t,e):!1===n&&l(o,e)})),c(window,"pageshow")&&v(window,"pageshow",b),v(window,"load",b),c(window,"pagehide")&&v(window,"pagehide",g),v(window,"beforeunload",g),c(window,"freeze")&&v(window,"freeze",(function(){u=!0})),c(window,"resume")&&v(window,"resume",(function(){u=!1}));e.ENTER=d,e.HIDE=o,e.LEAVE=f,e.SHOW=t,e.addEventListener=function(e,n){var i=s[e]||(s[e]=[]);return i.push(n),e===d&&a[e]&&h(e,a[e]),{remove:function(){for(var e=0,t=i.length;e<t;e++)i[e]===n&&i.splice(e,1)}}},e.init=function(){},e.version="0.0.6",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).WebPage={})}(this,(function(e){"use strict";var n,i,t="show",o="hide",d="enter",f="leave",u=!1,r=!1,s={},c={};function a(e,n){return"on"+n in e}function v(e,n,i){e.addEventListener?e.addEventListener(n,i,!0):e.attachEvent&&e.attachEvent("on"+n,i)}function w(e,n){var i;return function(){i||(e(arguments[0]),i=setTimeout((function(){i=void 0}),n))}}function l(e,t){var o={event:t,visible:n,persisted:i};s[e]=o,u&&!r&&h(e,o)}function h(e,n){var i=c[e];if(i)for(var t=0,o=i.length;t<o;t++)i[t]&&i[t](n)}function p(){var e=document.visibilityState;n="visible"===e||"hidden"!==e&&void 0}var b=w((function(e){u||(u=!0,l(d,e))}),200),g=w((function(e){u&&(l(f,e),u=!1)}),200);p(),a(document,"visibilitychange")&&v(document,"visibilitychange",(function(e){p(),!0===n?l(t,e):!1===n&&l(o,e)})),a(window,"pageshow")?v(window,"pageshow",(function(e){i=e.persisted,b(e)})):v(window,"load",b),a(window,"pagehide")&&v(window,"pagehide",(function(e){i=e.persisted,g(e)})),v(window,"beforeunload",g),a(window,"freeze")&&v(window,"freeze",(function(){r=!0})),a(window,"resume")&&v(window,"resume",(function(){r=!1}));e.ENTER=d,e.HIDE=o,e.LEAVE=f,e.SHOW=t,e.addEventListener=function(e,n){var i=c[e]||(c[e]=[]);return i.push(n),e===d&&s[e]&&h(e,s[e]),{remove:function(){for(var e=0,t=i.length;e<t;e++)i[e]===n&&i.splice(e,1)}}},e.init=function(){},e.version="0.0.7",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=web-page.min.js.map |
{ | ||
"name": "@yorkjs/web-page", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "web page life cycle", | ||
@@ -5,0 +5,0 @@ "main": "dist/web-page.js", |
@@ -6,2 +6,2 @@ export { SHOW, HIDE, ENTER, LEAVE, } from './constant'; | ||
*/ | ||
export declare const version = "0.0.6"; | ||
export declare const version = "0.0.7"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15516
358