Comparing version 0.11.1 to 0.11.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Utils=t():e.Utils=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=o(r),a=n(2),u=o(a),c=n(3),d=o(c),s=n(4),l=o(s),f=n(5),p=o(f),v=n(6),m=o(v),g=n(7),y=o(g),h=n(8),P=o(h);t.default={getLocation:u.default,getGeohash:i.default,compareVersion:d.default,paramToString:l.default,resolveFetch:p.default,checkoutByApp:m.default,getUrl:y.default,expiredLocalStorage:P.default}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),o=function(){return window.UParams?window.UParams().geohash||"":""},r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=null,o=function(){clearInterval(n)};return new Promise(function(r,i){if(!window.hybridAPI)return i();var a=function(){window.hybridAPI.getGlobalGeohash().then(function(e){e&&(o(),r(e))})};n=setInterval(a,t),a(),setTimeout(function(){o(),i()},e)})},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(window.Geohash.encode(e.coords.latitude,e.coords.longitude))},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},a=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,o=1800,r=e?ap.getLocation({timeout:t,cacheTimeout:o}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:o,requestType:0,bizType:n?"iOS-ele-position":"Android-ele-position"});return r.then(function(e){return window.Geohash.encode(e.latitude,e.longitude)})},u=function(e,t){return r(2*e/3).catch(function(){return t?Promise.reject():i(1*e/3)})},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=o();if(n)return Promise.resolve(n);var r=void 0;return r=/Eleme/i.test(navigator.userAgent)?u(e,t):/AlipayClient/.test(navigator.userAgent)?a():i(e)};c.getParamHash=o,c.useApp=r,c.useGeoAPI=i,c.useAlipay=a,t.default=c},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(o=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&u.return&&u.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=n(3),a=o(i),u=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return window.hybridAPI?new Promise(function(t,n){(0,a.default)("7.26")?hybridAPI.getGlobalGeohash().then(function(e){var n=Geohash.decode(e),o=r(n,2),i=o[0],a=o[1];t({latitude:i,longitude:a})}):hybridAPI.getSyncLocation().then(function(e){t({latitude:e.lat,longitude:e.lng})}),setTimeout(n,e)}):Promise.reject({name:"HYBRIDAPI_NOT_DEFINED"})},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(e.coords)},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},s=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,n=1800,o=e?ap.getLocation({timeout:t,cacheTimeout:n}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:n,requestType:0,bizType:u?"iOS-ele-position":"Android-ele-position"});return o},l=function(e,t){return c(2*e/3).catch(function(){return t?Promise.reject():getNavigatorHash(1*e/3)})},f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=void 0;return n=/Eleme/i.test(navigator.userAgent)?l(e,t):/AlipayClient/.test(navigator.userAgent)?s():d(e)};t.default=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){if(!t&&(t=(window.navigator.userAgent.match(/Eleme\/([\d|\.]+)/i)||[])[1],!t))return!1;e=e.split("."),t=t.split(".");var n=void 0;return e.forEach(function(e,o){var r=t[o];if("undefined"==typeof r&&(r=0),"undefined"==typeof n){var i=Number(e)-Number(r);0!==i&&(n=i>0)}}),!!n};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return Object.prototype.toString.call(e).slice(8,-1)},o=function(e){if("Object"!==n(e))throw"param 必须是一个 object";var t=[];return Object.keys(e).forEach(function(o){var r=e[o];Array.isArray(r)?t=t.concat(r.map(function(e){return encodeURIComponent(o)+"[]="+encodeURIComponent(e)})):"Object"===n(r)?(r=JSON.stringify(r),t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))):"Undefined"!==n(r)&&"Null"!==n(r)&&t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))}),t.join("&")};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){if(204===e.status)return Promise.resolve.bind(Promise);var t=e.json();return e.status>=200&&e.status<300?t:t.then(Promise.reject.bind(Promise))};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=o(r);t.default=function(e){var t=e.id,n=e.entities,o=(e.callback,{clear_cart:!0});(0,i.default)("7.2")?o.add_foods=n.map(function(e){var t=e.id,n=e.quantity,o=e.specs;return{id:t,quantity:n,specs:o.map(function(e){return e.value})}}):o.add_foods=n.map(function(e){var t=e.id,n=e.sku_id,o=e.quantity,r=e.specs,i=e.attrs;return{id:t,sku_id:n||"",quantity:o,specs:r,attrs:i}}),location.href="eleme://checkout?restaurant_id="+t+"&cart_operations="+JSON.stringify(o)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hash",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i="";if("{}"!==JSON.stringify(t)){i="hash"===o?"#":"?";for(var a in t){var u=t[a];i+="object"===("undefined"==typeof u?"undefined":n(u))&&u?encodeURIComponent(a)+"="+encodeURIComponent(JSON.stringify(u))+"&":encodeURIComponent(a)+"="+encodeURIComponent(u)+"&"}}return i=""+e+i.replace(/&$/,""),/Eleme/.test(navigator.userAgent)&&(i="eleme://web?url="+encodeURIComponent(i)+"&animation_type="+r),i};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={set:function(e){var t=e.key,n=e.value,o=e.expiredDate,r=e.expiredDay,i={value:n,expired:""};return o&&(i.expired=o),r&&(i.expired=Date.now()+60*r*60*1e3),localStorage.setItem(t,JSON.stringify(i)),{key:t,value:JSON.stringify(i)}},get:function(e){var t=void 0;try{t=JSON.parse(localStorage.getItem(e))}catch(e){throw e}if(!t)throw"The key: "+e+" you want are not found in localStorage";var n=Date.now()>new Date(t.expired).getTime();return{value:t.value,expired:n}}}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Utils=t():e.Utils=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=o(r),a=n(2),u=o(a),c=n(3),d=o(c),s=n(4),l=o(s),f=n(5),p=o(f),v=n(6),m=o(v),g=n(7),y=o(g),h=n(8),P=o(h);t.default={getLocation:u.default,getGeohash:i.default,compareVersion:d.default,paramToString:l.default,resolveFetch:p.default,checkoutByApp:m.default,getUrl:y.default,expiredLocalStorage:P.default}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),o=function(){var e=window.UParams?window.UParams().geohash||"":"";if(e)try{window.Geohash.decode(e)}catch(t){e=""}return e},r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=null,o=function(){clearInterval(n)};return new Promise(function(r,i){if(!window.hybridAPI)return i();var a=function(){window.hybridAPI.getGlobalGeohash().then(function(e){e&&(o(),r(e))})};n=setInterval(a,t),a(),setTimeout(function(){o(),i()},e)})},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(window.Geohash.encode(e.coords.latitude,e.coords.longitude))},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},a=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,o=1800,r=e?ap.getLocation({timeout:t,cacheTimeout:o}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:o,requestType:0,bizType:n?"iOS-ele-position":"Android-ele-position"});return r.then(function(e){return window.Geohash.encode(e.latitude,e.longitude)})},u=function(e,t){return r(2*e/3).catch(function(){return t?Promise.reject():i(1*e/3)})},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=o();if(n)return Promise.resolve(n);var r=void 0;return r=/Eleme/i.test(navigator.userAgent)?u(e,t):/AlipayClient/.test(navigator.userAgent)?a():i(e)};c.getParamHash=o,c.useApp=r,c.useGeoAPI=i,c.useAlipay=a,t.default=c},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(o=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&u.return&&u.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=n(3),a=o(i),u=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return window.hybridAPI?new Promise(function(t,n){(0,a.default)("7.26")?hybridAPI.getGlobalGeohash().then(function(e){var n=Geohash.decode(e),o=r(n,2),i=o[0],a=o[1];t({latitude:i,longitude:a})}):hybridAPI.getSyncLocation().then(function(e){t({latitude:e.lat,longitude:e.lng})}),setTimeout(n,e)}):Promise.reject({name:"HYBRIDAPI_NOT_DEFINED"})},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(e.coords)},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},s=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,n=1800,o=e?ap.getLocation({timeout:t,cacheTimeout:n}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:n,requestType:0,bizType:u?"iOS-ele-position":"Android-ele-position"});return o},l=function(e,t){return c(2*e/3).catch(function(){return t?Promise.reject():getNavigatorHash(1*e/3)})},f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=void 0;return n=/Eleme/i.test(navigator.userAgent)?l(e,t):/AlipayClient/.test(navigator.userAgent)?s():d(e)};t.default=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){if(!t&&(t=(window.navigator.userAgent.match(/Eleme\/([\d|\.]+)/i)||[])[1],!t))return!1;e=e.split("."),t=t.split(".");var n=void 0;return e.forEach(function(e,o){var r=t[o];if("undefined"==typeof r&&(r=0),"undefined"==typeof n){var i=Number(e)-Number(r);0!==i&&(n=i>0)}}),!!n};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return Object.prototype.toString.call(e).slice(8,-1)},o=function(e){if("Object"!==n(e))throw"param 必须是一个 object";var t=[];return Object.keys(e).forEach(function(o){var r=e[o];Array.isArray(r)?t=t.concat(r.map(function(e){return encodeURIComponent(o)+"[]="+encodeURIComponent(e)})):"Object"===n(r)?(r=JSON.stringify(r),t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))):"Undefined"!==n(r)&&"Null"!==n(r)&&t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))}),t.join("&")};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){if(204===e.status)return Promise.resolve.bind(Promise);var t=e.json();return e.status>=200&&e.status<300?t:t.then(Promise.reject.bind(Promise))};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=o(r);t.default=function(e){var t=e.id,n=e.entities,o=(e.callback,{clear_cart:!0});(0,i.default)("7.2")?o.add_foods=n.map(function(e){var t=e.id,n=e.quantity,o=e.specs;return{id:t,quantity:n,specs:o.map(function(e){return e.value})}}):o.add_foods=n.map(function(e){var t=e.id,n=e.sku_id,o=e.quantity,r=e.specs,i=e.attrs;return{id:t,sku_id:n||"",quantity:o,specs:r,attrs:i}}),location.href="eleme://checkout?restaurant_id="+t+"&cart_operations="+JSON.stringify(o)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hash",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i="";if("{}"!==JSON.stringify(t)){i="hash"===o?"#":"?";for(var a in t){var u=t[a];i+="object"===("undefined"==typeof u?"undefined":n(u))&&u?encodeURIComponent(a)+"="+encodeURIComponent(JSON.stringify(u))+"&":encodeURIComponent(a)+"="+encodeURIComponent(u)+"&"}}return i=""+e+i.replace(/&$/,""),/Eleme/.test(navigator.userAgent)&&(i="eleme://web?url="+encodeURIComponent(i)+"&animation_type="+r),i};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={set:function(e){var t=e.key,n=e.value,o=e.expiredDate,r=e.expiredDay,i={value:n,expired:""};return o&&(i.expired=o),r&&(i.expired=Date.now()+60*r*60*1e3),localStorage.setItem(t,JSON.stringify(i)),{key:t,value:JSON.stringify(i)}},get:function(e){var t=void 0;try{t=JSON.parse(localStorage.getItem(e))}catch(e){throw e}if(!t)throw"The key: "+e+" you want are not found in localStorage";var n=Date.now()>new Date(t.expired).getTime();return{value:t.value,expired:n}}}}])}); |
{ | ||
"name": "h5-utils", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "common methods for eleme h5 project.", | ||
@@ -5,0 +5,0 @@ "main": "h5-utils.js", |
@@ -8,3 +8,13 @@ /* | ||
const getParamHash = () => window.UParams ? (window.UParams().geohash || '') : '' | ||
const getParamHash = () => { | ||
let hash = window.UParams ? (window.UParams().geohash || '') : '' | ||
if (hash) { | ||
try { | ||
window.Geohash.decode(hash) | ||
} catch (err) { | ||
hash = '' | ||
} | ||
} | ||
return hash | ||
} | ||
@@ -11,0 +21,0 @@ const getAppHash = (timeout = 5000, interval = 100) => { |
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
36795
864