@bearei/react-util
Advanced tools
Comparing version 0.0.1 to 0.0.2
export declare const isMobile: () => boolean; | ||
export declare const getPlatform: () => "app" | "mobile" | "pc"; | ||
export declare const getPlatform: () => "nativeApp" | "mobileBrowser" | "pcBrowser"; |
@@ -37,5 +37,5 @@ /******/ // The require scope | ||
if (!isBrowser) { | ||
return 'app'; | ||
return 'nativeApp'; | ||
} | ||
return isMobile() ? 'mobile' : 'pc'; | ||
return isMobile() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
@@ -42,0 +42,0 @@ var __webpack_exports__getPlatform = __webpack_exports__.X; |
@@ -19,5 +19,5 @@ /******/ var __webpack_modules__ = ({ | ||
if (!isBrowser) { | ||
return 'app'; | ||
return 'nativeApp'; | ||
} | ||
return isMobile() ? 'mobile' : 'pc'; | ||
return isMobile() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
@@ -31,4 +31,8 @@ | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "I": function() { return /* binding */ getPlatformEvent; }, | ||
/* harmony export */ "Z": function() { return /* binding */ handleEvent; } | ||
/* harmony export */ }); | ||
/* harmony import */ var _getPlatform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(405); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var handleEvent = function handleEvent(e, callback) { | ||
@@ -40,2 +44,10 @@ var _a, _b; | ||
}; | ||
var getPlatformEvent = function getPlatformEvent(eventFun) { | ||
var event = { | ||
nativeApp: 'onPress', | ||
pcBrowser: 'onClick', | ||
mobileBrowser: 'onTouchEnd' | ||
}; | ||
return _defineProperty({}, event[(0,_getPlatform__WEBPACK_IMPORTED_MODULE_0__/* .getPlatform */ .X)()], eventFun); | ||
}; | ||
@@ -93,2 +105,3 @@ /***/ }) | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "II": function() { return /* reexport safe */ _userEvent__WEBPACK_IMPORTED_MODULE_1__.I; }, | ||
/* harmony export */ "Xf": function() { return /* reexport safe */ _getPlatform__WEBPACK_IMPORTED_MODULE_0__.X; }, | ||
@@ -104,4 +117,5 @@ /* harmony export */ "Zm": function() { return /* reexport safe */ _userEvent__WEBPACK_IMPORTED_MODULE_1__.Z; }, | ||
var __webpack_exports__getPlatform = __webpack_exports__.Xf; | ||
var __webpack_exports__getPlatformEvent = __webpack_exports__.II; | ||
var __webpack_exports__handleEvent = __webpack_exports__.Zm; | ||
var __webpack_exports__isMobile = __webpack_exports__.tq; | ||
export { __webpack_exports__getPlatform as getPlatform, __webpack_exports__handleEvent as handleEvent, __webpack_exports__isMobile as isMobile }; | ||
export { __webpack_exports__getPlatform as getPlatform, __webpack_exports__getPlatformEvent as getPlatformEvent, __webpack_exports__handleEvent as handleEvent, __webpack_exports__isMobile as isMobile }; |
/// <reference types="react" /> | ||
import { GestureResponderEvent } from 'react-native'; | ||
export declare type EventType = 'onClick' | 'onPress' | 'onTouchEnd'; | ||
export interface Fun { | ||
(...args: unknown[]): void; | ||
} | ||
/** | ||
@@ -7,2 +11,5 @@ * 处理事件 | ||
export declare type HandleEvent = React.MouseEvent<HTMLButtonElement, MouseEvent> | React.TouchEvent<HTMLButtonElement> | GestureResponderEvent; | ||
export declare const handleEvent: (e?: HandleEvent, callback?: ((...args: unknown[]) => void) | undefined) => void | undefined; | ||
export declare const handleEvent: (e?: HandleEvent, callback?: Fun) => void | undefined; | ||
export declare const getPlatformEvent: (eventFun?: Fun) => { | ||
[x: string]: Fun | undefined; | ||
}; |
@@ -1,4 +0,52 @@ | ||
/******/ // The require scope | ||
/******/ var __webpack_require__ = {}; | ||
/******/ var __webpack_modules__ = ({ | ||
/***/ 405: | ||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "X": function() { return /* binding */ getPlatform; } | ||
/* harmony export */ }); | ||
/* unused harmony export isMobile */ | ||
var isMobile = function isMobile() { | ||
var _a, _b; | ||
var agent = (_b = (_a = navigator.userAgent) !== null && _a !== void 0 ? _a : navigator.vendor) !== null && _b !== void 0 ? _b : window.opera; | ||
var platform = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substring(0, 4)); | ||
return platform; | ||
}; | ||
var getPlatform = function getPlatform() { | ||
var isBrowser = navigator !== null && navigator !== void 0 ? navigator : window; | ||
if (!isBrowser) { | ||
return 'nativeApp'; | ||
} | ||
return isMobile() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
@@ -24,5 +72,11 @@ /******/ /* webpack/runtime/define property getters */ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
!function() { | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "I": function() { return /* binding */ getPlatformEvent; }, | ||
/* harmony export */ "Z": function() { return /* binding */ handleEvent; } | ||
/* harmony export */ }); | ||
/* harmony import */ var _getPlatform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(405); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var handleEvent = function handleEvent(e, callback) { | ||
@@ -34,3 +88,13 @@ var _a, _b; | ||
}; | ||
var getPlatformEvent = function getPlatformEvent(eventFun) { | ||
var event = { | ||
nativeApp: 'onPress', | ||
pcBrowser: 'onClick', | ||
mobileBrowser: 'onTouchEnd' | ||
}; | ||
return _defineProperty({}, event[(0,_getPlatform__WEBPACK_IMPORTED_MODULE_0__/* .getPlatform */ .X)()], eventFun); | ||
}; | ||
}(); | ||
var __webpack_exports__getPlatformEvent = __webpack_exports__.I; | ||
var __webpack_exports__handleEvent = __webpack_exports__.Z; | ||
export { __webpack_exports__handleEvent as handleEvent }; | ||
export { __webpack_exports__getPlatformEvent as getPlatformEvent, __webpack_exports__handleEvent as handleEvent }; |
export declare const isMobile: () => boolean; | ||
export declare const getPlatform: () => "app" | "mobile" | "pc"; | ||
export declare const getPlatform: () => "nativeApp" | "mobileBrowser" | "pcBrowser"; |
@@ -24,5 +24,5 @@ /******/ (function() { // webpackBootstrap | ||
if (!isBrowser) { | ||
return 'app'; | ||
return 'nativeApp'; | ||
} | ||
return (0, exports.isMobile)() ? 'mobile' : 'pc'; | ||
return (0, exports.isMobile)() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
@@ -29,0 +29,0 @@ exports.getPlatform = getPlatform; |
@@ -24,5 +24,5 @@ /******/ (function() { // webpackBootstrap | ||
if (!isBrowser) { | ||
return 'app'; | ||
return 'nativeApp'; | ||
} | ||
return (0, exports.isMobile)() ? 'mobile' : 'pc'; | ||
return (0, exports.isMobile)() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
@@ -68,10 +68,12 @@ exports.getPlatform = getPlatform; | ||
/***/ 668: | ||
/***/ (function(__unused_webpack_module, exports) { | ||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.handleEvent = void 0; | ||
exports.getPlatformEvent = exports.handleEvent = void 0; | ||
var getPlatform_1 = __webpack_require__(405); | ||
var handleEvent = function handleEvent(e, callback) { | ||
@@ -84,2 +86,11 @@ var _a, _b; | ||
exports.handleEvent = handleEvent; | ||
var getPlatformEvent = function getPlatformEvent(eventFun) { | ||
var event = { | ||
nativeApp: 'onPress', | ||
pcBrowser: 'onClick', | ||
mobileBrowser: 'onTouchEnd' | ||
}; | ||
return _defineProperty({}, event[(0, getPlatform_1.getPlatform)()], eventFun); | ||
}; | ||
exports.getPlatformEvent = getPlatformEvent; | ||
@@ -86,0 +97,0 @@ /***/ }) |
/// <reference types="react" /> | ||
import { GestureResponderEvent } from 'react-native'; | ||
export declare type EventType = 'onClick' | 'onPress' | 'onTouchEnd'; | ||
export interface Fun { | ||
(...args: unknown[]): void; | ||
} | ||
/** | ||
@@ -7,2 +11,5 @@ * 处理事件 | ||
export declare type HandleEvent = React.MouseEvent<HTMLButtonElement, MouseEvent> | React.TouchEvent<HTMLButtonElement> | GestureResponderEvent; | ||
export declare const handleEvent: (e?: HandleEvent, callback?: ((...args: unknown[]) => void) | undefined) => void | undefined; | ||
export declare const handleEvent: (e?: HandleEvent, callback?: Fun) => void | undefined; | ||
export declare const getPlatformEvent: (eventFun?: Fun) => { | ||
[x: string]: Fun | undefined; | ||
}; |
/******/ (function() { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
/***/ 405: | ||
/***/ (function(__unused_webpack_module, exports) { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.getPlatform = exports.isMobile = void 0; | ||
var isMobile = function isMobile() { | ||
var _a, _b; | ||
var agent = (_b = (_a = navigator.userAgent) !== null && _a !== void 0 ? _a : navigator.vendor) !== null && _b !== void 0 ? _b : window.opera; | ||
var platform = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substring(0, 4)); | ||
return platform; | ||
}; | ||
exports.isMobile = isMobile; | ||
var getPlatform = function getPlatform() { | ||
var isBrowser = navigator !== null && navigator !== void 0 ? navigator : window; | ||
if (!isBrowser) { | ||
return 'nativeApp'; | ||
} | ||
return (0, exports.isMobile)() ? 'mobileBrowser' : 'pcBrowser'; | ||
}; | ||
exports.getPlatform = getPlatform; | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports). | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
!function() { | ||
@@ -9,6 +65,8 @@ var exports = __webpack_exports__; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.handleEvent = void 0; | ||
exports.getPlatformEvent = exports.handleEvent = void 0; | ||
var getPlatform_1 = __webpack_require__(405); | ||
var handleEvent = function handleEvent(e, callback) { | ||
@@ -21,2 +79,11 @@ var _a, _b; | ||
exports.handleEvent = handleEvent; | ||
var getPlatformEvent = function getPlatformEvent(eventFun) { | ||
var event = { | ||
nativeApp: 'onPress', | ||
pcBrowser: 'onClick', | ||
mobileBrowser: 'onTouchEnd' | ||
}; | ||
return _defineProperty({}, event[(0, getPlatform_1.getPlatform)()], eventFun); | ||
}; | ||
exports.getPlatformEvent = getPlatformEvent; | ||
}(); | ||
@@ -23,0 +90,0 @@ var __webpack_export_target__ = exports; |
{ | ||
"name": "@bearei/react-util", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
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
38533
557