fix(es,lib): 删除所有es,lib文件夹
This commit is contained in:
parent
ba96f96f58
commit
90b18d2624
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,6 +9,10 @@ vueuse
|
||||
/temp
|
||||
packages/**/es
|
||||
packages/**/lib
|
||||
**/es
|
||||
**/lib
|
||||
**/**/es
|
||||
**/**/lib
|
||||
/es
|
||||
/lib
|
||||
pnpm-lock.yaml
|
||||
|
@ -1,270 +0,0 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
// @ts-nocheck
|
||||
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
||||
import { ConfigProvider, Descriptions, Modal, Tabs, CropperImage, AttachImage, VideoPlayer, BtnGroup, RelatedImage } from '@zhst/meta';
|
||||
import classNames from 'classnames';
|
||||
import { get, isEmpty, pick } from '@zhst/func';
|
||||
import Navigation from "./components/navigation";
|
||||
import CombineImage from "./components/CombineImage";
|
||||
import "./index.less";
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { Fragment as _Fragment } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
var DescriptionsItem = Descriptions.Item;
|
||||
export var componentPrefix = 'zhst-image';
|
||||
|
||||
// 对比图模式、场景图模式、视频模式
|
||||
|
||||
var initialStyle = {
|
||||
fontSize: '12px'
|
||||
};
|
||||
var BigImageModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
var _props$title = props.title,
|
||||
title = _props$title === void 0 ? '-' : _props$title,
|
||||
width = props.width,
|
||||
open = props.open,
|
||||
children = props.children,
|
||||
onCancel = props.onCancel,
|
||||
activeTab = props.activeTab,
|
||||
_props$attributeList = props.attributeList,
|
||||
attributeList = _props$attributeList === void 0 ? [] : _props$attributeList,
|
||||
_props$isRelated = props.isRelated,
|
||||
isRelated = _props$isRelated === void 0 ? false : _props$isRelated,
|
||||
_props$tabs = props.tabs,
|
||||
tabs = _props$tabs === void 0 ? {} : _props$tabs,
|
||||
_props$footer = props.footer,
|
||||
footer = _props$footer === void 0 ? null : _props$footer,
|
||||
_props$dataSource = props.dataSource,
|
||||
dataSource = _props$dataSource === void 0 ? {} : _props$dataSource,
|
||||
onTabChange = props.onTabChange,
|
||||
compareImageProps = props.compareImageProps,
|
||||
showNavigation = props.showNavigation,
|
||||
modalProps = props.modalProps,
|
||||
cropperImageProps = props.cropperImageProps,
|
||||
prevButtonProps = props.prevButtonProps,
|
||||
onPrevButtonClick = props.onPrevButtonClick,
|
||||
onNextButtonClick = props.onNextButtonClick,
|
||||
nextButtonProps = props.nextButtonProps,
|
||||
tabsProps = props.tabsProps,
|
||||
btnGroupProps = props.btnGroupProps,
|
||||
descriptionsProps = props.descriptionsProps,
|
||||
relatedImageProps = props.relatedImageProps,
|
||||
theme = props.theme;
|
||||
var combineImageRef = useRef(null);
|
||||
var videoPlayerRef = useRef(null);
|
||||
var modalRef = useRef(null);
|
||||
|
||||
// ========================== 头切换 =========================
|
||||
var _useState = useState(activeTab || get(tabsProps, 'data[0].key')),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
tab = _useState2[0],
|
||||
setTab = _useState2[1];
|
||||
var _useState3 = useState('related'),
|
||||
_useState4 = _slicedToArray(_useState3, 2),
|
||||
activeKey = _useState4[0],
|
||||
setActiveKey = _useState4[1];
|
||||
|
||||
// ========================= 预览切换下标 =========================
|
||||
var _useState5 = useState('auto'),
|
||||
_useState6 = _slicedToArray(_useState5, 2),
|
||||
cropType = _useState6[0],
|
||||
setCropType = _useState6[1];
|
||||
var cropBtnDataSource = [{
|
||||
key: 'close',
|
||||
icon: 'icon-danchuangguanbi',
|
||||
title: '退出'
|
||||
}, {
|
||||
key: 'auto',
|
||||
icon: 'icon-zidong',
|
||||
title: '智能框选'
|
||||
}, {
|
||||
key: 'custom',
|
||||
icon: 'icon-shoudong',
|
||||
title: '手动框选'
|
||||
}];
|
||||
var handleCropBtnClick = function handleCropBtnClick(v) {
|
||||
setCropType(v);
|
||||
};
|
||||
var defaultTabsProps = !isEmpty(tabs) ? tabs : {
|
||||
items: [{
|
||||
label: '对比图模式',
|
||||
key: 'COMPATER',
|
||||
children: /*#__PURE__*/_jsx(CombineImage, _objectSpread({
|
||||
ref: combineImageRef,
|
||||
data: pick(dataSource, 'compaterImage', 'imgSummary', 'imageKey', 'score')
|
||||
}, compareImageProps))
|
||||
}, {
|
||||
label: '场景图模式',
|
||||
key: 'NORMAL',
|
||||
children: /*#__PURE__*/_jsx("div", {
|
||||
style: {
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
width: '100%'
|
||||
},
|
||||
children: /*#__PURE__*/_jsx("div", {
|
||||
style: {
|
||||
width: '85%',
|
||||
height: '500px'
|
||||
},
|
||||
children: /*#__PURE__*/_jsxs(CropperImage, _objectSpread(_objectSpread({
|
||||
type: "rect",
|
||||
odList: get(dataSource, 'odRect', [])
|
||||
}, cropperImageProps), {}, {
|
||||
children: [!(cropperImageProps !== null && cropperImageProps !== void 0 && cropperImageProps.editAble) && /*#__PURE__*/_jsxs(_Fragment, {
|
||||
children: [/*#__PURE__*/_jsx(AttachImage, {
|
||||
data: [{
|
||||
label: '测试',
|
||||
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
||||
}]
|
||||
}), /*#__PURE__*/_jsx("div", {
|
||||
style: {
|
||||
position: 'absolute',
|
||||
right: '24px',
|
||||
bottom: '24px',
|
||||
fontSize: '18px',
|
||||
color: 'red',
|
||||
cursor: 'default'
|
||||
},
|
||||
children: "\u4EBA\u8138\u8D28\u91CF\u5206\uFF1A".concat(Number(cropperImageProps === null || cropperImageProps === void 0 ? void 0 : cropperImageProps.score).toFixed(2))
|
||||
})]
|
||||
}), (cropperImageProps === null || cropperImageProps === void 0 ? void 0 : cropperImageProps.showEditTools) && /*#__PURE__*/_jsx(BtnGroup, _objectSpread({
|
||||
circle: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
right: 0
|
||||
},
|
||||
dataSource: cropBtnDataSource,
|
||||
onClick: handleCropBtnClick,
|
||||
selectKey: cropType
|
||||
}, btnGroupProps))]
|
||||
}))
|
||||
})
|
||||
})
|
||||
}]
|
||||
};
|
||||
|
||||
// 暴露 ref 实例
|
||||
useImperativeHandle(ref, function () {
|
||||
return {
|
||||
ref: ref,
|
||||
tab: tab,
|
||||
setTab: setTab,
|
||||
modalRef: modalRef,
|
||||
activeKey: activeKey,
|
||||
setActiveKey: setActiveKey,
|
||||
videoPlayerRef: videoPlayerRef,
|
||||
combineImageRef: combineImageRef
|
||||
};
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Modal, _objectSpread(_objectSpread({
|
||||
destroyOnClose: true,
|
||||
width: width,
|
||||
open: open,
|
||||
ref: modalRef,
|
||||
footer: footer,
|
||||
className: componentPrefix,
|
||||
title: title,
|
||||
onCancel: onCancel
|
||||
}, modalProps), {}, {
|
||||
children: [/*#__PURE__*/_jsxs("div", {
|
||||
style: {
|
||||
marginTop: '16px'
|
||||
},
|
||||
children: [/*#__PURE__*/_jsx(ConfigProvider, {
|
||||
theme: _objectSpread({
|
||||
token: {
|
||||
colorTextSecondary: 'rgba(0,0,0,0.45)'
|
||||
},
|
||||
components: {
|
||||
Descriptions: {
|
||||
titleMarginBottom: '20px',
|
||||
viewBg: '#f6f6f6',
|
||||
titleColor: 'rgba(0,0,0,0.45)',
|
||||
colorTextLabel: 'rgba(0,0,0,0.45)',
|
||||
contentColor: 'rgba(0,0,0,0.88)'
|
||||
}
|
||||
}
|
||||
}, theme),
|
||||
children: attributeList.map(function (descriptions) {
|
||||
var _descriptions$childre;
|
||||
return /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({
|
||||
title: /*#__PURE__*/_jsx("p", {
|
||||
style: {
|
||||
margin: '12px 0 0',
|
||||
fontSize: initialStyle.fontSize
|
||||
},
|
||||
children: descriptions.title
|
||||
}),
|
||||
column: 8,
|
||||
style: {
|
||||
padding: '0 64px'
|
||||
}
|
||||
}, descriptionsProps), {}, {
|
||||
children: descriptions === null || descriptions === void 0 || (_descriptions$childre = descriptions.children) === null || _descriptions$childre === void 0 ? void 0 : _descriptions$childre.map(function (item) {
|
||||
return /*#__PURE__*/_jsx(DescriptionsItem, {
|
||||
label: item.label,
|
||||
span: 1,
|
||||
contentStyle: {
|
||||
fontSize: initialStyle.fontSize
|
||||
},
|
||||
labelStyle: {
|
||||
fontSize: initialStyle.fontSize
|
||||
},
|
||||
children: item.children
|
||||
}, item.key);
|
||||
})
|
||||
}), descriptions.title);
|
||||
})
|
||||
}), /*#__PURE__*/_jsxs("div", {
|
||||
className: classNames("".concat(componentPrefix, "-view-container")),
|
||||
children: [/*#__PURE__*/_jsx(Tabs, _objectSpread(_objectSpread({
|
||||
activeKey: tab,
|
||||
centered: true,
|
||||
destroyInactiveTabPane: true,
|
||||
onChange: function onChange(v) {
|
||||
setTab(function (pre) {
|
||||
onTabChange === null || onTabChange === void 0 || onTabChange(v, pre);
|
||||
return v;
|
||||
});
|
||||
},
|
||||
tabBarStyle: {
|
||||
fontSize: '18px',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
}, defaultTabsProps), tabsProps)), tab === 'VIDEO' && /*#__PURE__*/_jsx(VideoPlayer, {
|
||||
ref: videoPlayerRef,
|
||||
url: dataSource === null || dataSource === void 0 ? void 0 : dataSource.flvUrl
|
||||
}), /*#__PURE__*/_jsx(Navigation, _objectSpread({
|
||||
className: classNames("".concat(componentPrefix, "-view-container__nav"), (prevButtonProps === null || prevButtonProps === void 0 ? void 0 : prevButtonProps.disabled) && "".concat(componentPrefix, "-view-container__nav--disabled"), "".concat(componentPrefix, "-view-container__nav--left")),
|
||||
prev: true,
|
||||
show: showNavigation,
|
||||
onClick: onPrevButtonClick
|
||||
}, prevButtonProps)), /*#__PURE__*/_jsx(Navigation, _objectSpread({
|
||||
className: classNames("".concat(componentPrefix, "-view-container__nav"), (nextButtonProps === null || nextButtonProps === void 0 ? void 0 : nextButtonProps.disabled) && "".concat(componentPrefix, "-view-container__nav--disabled"), "".concat(componentPrefix, "-view-container__nav--right")),
|
||||
next: true,
|
||||
show: showNavigation,
|
||||
onClick: onNextButtonClick
|
||||
}, nextButtonProps)), isRelated && /*#__PURE__*/_jsx("div", {
|
||||
style: {
|
||||
margin: '24px 0'
|
||||
},
|
||||
children: /*#__PURE__*/_jsx(RelatedImage, _objectSpread({}, relatedImageProps))
|
||||
})]
|
||||
})]
|
||||
}), children]
|
||||
}));
|
||||
});
|
||||
export default BigImageModal;
|
@ -1,30 +0,0 @@
|
||||
export var OBJECT_GRNER_THRESHOLD = 0.8; //目标图判断性别阈值
|
||||
export var OBJECT_AGE_TYPE_THRESHOLD = 0.5; //目标图判断年龄段阈值
|
||||
export var MODE_KEY = 'test_mode';
|
||||
//业务约定
|
||||
export var SEARCH_IMG_COUNT = 10; //检索图片的最大个数
|
||||
export var GLOBAL_IS_ITEM_NUMBER_SHOW = false; //是否展示索引
|
||||
export var publicPath = 'hummingbird';
|
||||
export var ENTER_CIRCLE = 'MONITORTYPE_ENTER_CIRCLE';
|
||||
export var OUT_CIRCLE = 'MONITORTYPE_OUT_CIRCLE';
|
||||
export var TEMP = 'MONITORTYPE_TEMP';
|
||||
export var GLOBAL_IS_BOX_VMS_SHOW = true; //是否展示盒子vms
|
||||
|
||||
export var BODY_SEARCH_THRESHOID = 0.45; //形体检索阈值
|
||||
export var RECORD_VERSION = '3.0.0'; //保存记录的版本号
|
||||
|
||||
export var DeviceTab = {
|
||||
EMPTY: 0,
|
||||
REAL_CAMERA: 1,
|
||||
PREPROCESS_CAMERA: 2,
|
||||
//摄像头列表
|
||||
TAG_CAMERA: 3,
|
||||
//预案列表
|
||||
HISTORY_VIDEO_GROUP: 4,
|
||||
//录像回放
|
||||
VIRTUAL_CAMERA: 5,
|
||||
//离线视频
|
||||
REAL_CAMERA_NOFACE: 6,
|
||||
REAL_CAMERA_ONLYFACE: 7,
|
||||
REAL_CAMERA_NOFACE_NOBOX_NODIRECONNECT: 8 // 只有普通摄像头,没有人脸、没有盒子、直连
|
||||
};
|
@ -1 +0,0 @@
|
||||
export var TYPE = '';
|
@ -1,3 +0,0 @@
|
||||
export * from "./camera";
|
||||
export * from "./base";
|
||||
export * from "./user";
|
@ -1 +0,0 @@
|
||||
export default {};
|
1
packages/func/dist/func.min.js
vendored
1
packages/func/dist/func.min.js
vendored
File diff suppressed because one or more lines are too long
41
packages/func/es/camera/constants.d.ts
vendored
41
packages/func/es/camera/constants.d.ts
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 设备类型枚举
|
||||
*/
|
||||
export declare const DeviceType: {
|
||||
VMS: string;
|
||||
DIR: string;
|
||||
CAMERA: string;
|
||||
};
|
||||
export declare const LOCAL_KEY = "local";
|
||||
export declare const DIRE_CONNECT_KEY = "direconnect";
|
||||
export declare const BOX_LIST_KEY = "boxlist";
|
||||
export declare enum VmsplatformOpt {
|
||||
VMSPLATFORMOPT_ID = 0,
|
||||
VMSPLATFORMOPT_PLATFORMNAME = 1,
|
||||
VMSPLATFORMOPT_PLUGINNAME = 2,
|
||||
VMSPLATFORMOPT_IP = 3,
|
||||
VMSPLATFORMOPT_PORT = 4,
|
||||
VMSPLATFORMOPT_USERNAME = 5,
|
||||
VMSPLATFORMOPT_PASSWORD = 6
|
||||
}
|
||||
export declare enum OPT {
|
||||
OR = 0,
|
||||
AND = 1,
|
||||
ORNOT = 2,
|
||||
ANDNOT = 3
|
||||
}
|
||||
export declare enum DevicemanagerCameraType {
|
||||
DEVICEMANAGER_CAMERA_TYPE_DEFAULT = 0,
|
||||
DEVICEMANAGER_CAMERA_TYPE_NORMAL = 1,
|
||||
DEVICEMANAGER_CAMERA_TYPE_1400 = 97,
|
||||
DEVICEMANAGER_CAMERA_TYPE_DHGRABBER = 98,
|
||||
DEVICEMANAGER_CAMERA_TYPE_HKGRABBER = 99,
|
||||
DEVICEMANAGER_CAMERA_TYPE_LOCAL = 100
|
||||
}
|
||||
export declare const BOX_DIRECONNECT_PLATFORM_FILTER: {
|
||||
filtervmsplatformList: {
|
||||
opt: OPT;
|
||||
vmsplatformOpt: VmsplatformOpt;
|
||||
value: string;
|
||||
}[];
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
/**
|
||||
* 设备类型枚举
|
||||
*/
|
||||
export var DeviceType = {
|
||||
VMS: 'vms',
|
||||
DIR: 'dir',
|
||||
CAMERA: 'camera'
|
||||
};
|
||||
export var LOCAL_KEY = 'local'; //离线摄像头key 约定
|
||||
export var DIRE_CONNECT_KEY = 'direconnect';
|
||||
export var BOX_LIST_KEY = 'boxlist';
|
||||
export var VmsplatformOpt = /*#__PURE__*/function (VmsplatformOpt) {
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_ID"] = 0] = "VMSPLATFORMOPT_ID";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_PLATFORMNAME"] = 1] = "VMSPLATFORMOPT_PLATFORMNAME";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_PLUGINNAME"] = 2] = "VMSPLATFORMOPT_PLUGINNAME";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_IP"] = 3] = "VMSPLATFORMOPT_IP";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_PORT"] = 4] = "VMSPLATFORMOPT_PORT";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_USERNAME"] = 5] = "VMSPLATFORMOPT_USERNAME";
|
||||
VmsplatformOpt[VmsplatformOpt["VMSPLATFORMOPT_PASSWORD"] = 6] = "VMSPLATFORMOPT_PASSWORD";
|
||||
return VmsplatformOpt;
|
||||
}({});
|
||||
export var OPT = /*#__PURE__*/function (OPT) {
|
||||
OPT[OPT["OR"] = 0] = "OR";
|
||||
OPT[OPT["AND"] = 1] = "AND";
|
||||
OPT[OPT["ORNOT"] = 2] = "ORNOT";
|
||||
OPT[OPT["ANDNOT"] = 3] = "ANDNOT";
|
||||
return OPT;
|
||||
}({});
|
||||
export var DevicemanagerCameraType = /*#__PURE__*/function (DevicemanagerCameraType) {
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_DEFAULT"] = 0] = "DEVICEMANAGER_CAMERA_TYPE_DEFAULT";
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_NORMAL"] = 1] = "DEVICEMANAGER_CAMERA_TYPE_NORMAL";
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_1400"] = 97] = "DEVICEMANAGER_CAMERA_TYPE_1400";
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_DHGRABBER"] = 98] = "DEVICEMANAGER_CAMERA_TYPE_DHGRABBER";
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_HKGRABBER"] = 99] = "DEVICEMANAGER_CAMERA_TYPE_HKGRABBER";
|
||||
DevicemanagerCameraType[DevicemanagerCameraType["DEVICEMANAGER_CAMERA_TYPE_LOCAL"] = 100] = "DEVICEMANAGER_CAMERA_TYPE_LOCAL";
|
||||
return DevicemanagerCameraType;
|
||||
}({});
|
||||
|
||||
// 盒子 直连 平台
|
||||
export var BOX_DIRECONNECT_PLATFORM_FILTER = {
|
||||
filtervmsplatformList: [{
|
||||
opt: OPT.OR,
|
||||
vmsplatformOpt: VmsplatformOpt.VMSPLATFORMOPT_PLATFORMNAME,
|
||||
value: 'direconnect'
|
||||
}, {
|
||||
opt: OPT.OR,
|
||||
vmsplatformOpt: VmsplatformOpt.VMSPLATFORMOPT_PLATFORMNAME,
|
||||
value: 'boxlist'
|
||||
}]
|
||||
};
|
40
packages/func/es/camera/index.d.ts
vendored
40
packages/func/es/camera/index.d.ts
vendored
@ -1,40 +0,0 @@
|
||||
import { DevicemanagerCameraType } from './constants';
|
||||
export declare const isFaceCamera: (type: DevicemanagerCameraType) => boolean;
|
||||
/**
|
||||
*
|
||||
* @param value 传入的数据 可以是 item(camera/vms/dirs)/ deviceID
|
||||
* @param isId
|
||||
*/
|
||||
export declare function getDeviceType(value: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
} | string): any;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param id 设备id
|
||||
* @param type 设备类型
|
||||
*/
|
||||
export declare function deviceIDToDeviceKey(id: any, type: string, vmsId?: any): string;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param item camera/vms/dirs
|
||||
*/
|
||||
export declare function deviceToDeviceKey(item: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
}): string;
|
||||
/**
|
||||
* 设备树key 转 后端设备原始id dirid是string/vms&camera 是number 和后端保持一致
|
||||
* @param deviceKey 设备树的id
|
||||
*/
|
||||
export declare function deviceKeyToDeviceId(deviceKey: {
|
||||
split: (arg0: string) => [any, any];
|
||||
}): any;
|
||||
export declare const getVmsIdByDeviceId: (key: string) => string;
|
||||
/**
|
||||
* 通过设备id或设备key在树里面找摄像头
|
||||
* @param ids cameraId
|
||||
* @param deviceTree 树
|
||||
* @param type "id" | "key"
|
||||
*/
|
||||
export declare const findCamerasByInDeviceTree: (ids: never[] | undefined, deviceTree: any, type?: string) => any[];
|
@ -1,142 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
import { get, has, isString } from 'lodash-es';
|
||||
import { loop } from "../utils";
|
||||
import { DevicemanagerCameraType, DeviceType } from "./constants";
|
||||
export var isFaceCamera = function isFaceCamera(type) {
|
||||
return [DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_1400, DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_HKGRABBER, DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_DHGRABBER].includes(type);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value 传入的数据 可以是 item(camera/vms/dirs)/ deviceID
|
||||
* @param isId
|
||||
*/
|
||||
export function getDeviceType(value) {
|
||||
var type;
|
||||
var isDeviceKey = isString(value);
|
||||
if (isDeviceKey) {
|
||||
type = value.split('_')[0];
|
||||
} else {
|
||||
if (has(value, 'longitude')) {
|
||||
type = DeviceType['CAMERA'];
|
||||
}
|
||||
if (has(value, 'ip')) {
|
||||
type = DeviceType['VMS'];
|
||||
}
|
||||
if (!type) {
|
||||
type = DeviceType['DIR'];
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param id 设备id
|
||||
* @param type 设备类型
|
||||
*/
|
||||
export function deviceIDToDeviceKey(id, type, vmsId) {
|
||||
if (type == DeviceType['DIR']) {
|
||||
return "".concat(type, "_").concat(id, "_").concat(vmsId);
|
||||
} else {
|
||||
return "".concat(type, "_").concat(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param item camera/vms/dirs
|
||||
*/
|
||||
export function deviceToDeviceKey(item) {
|
||||
var deviceKey = '';
|
||||
var type = getDeviceType(item);
|
||||
if (!type) {
|
||||
console.error('device type is null!');
|
||||
}
|
||||
switch (type) {
|
||||
case DeviceType['DIR']:
|
||||
{
|
||||
var dirId = item['dirid'] || item['dirId'];
|
||||
if (!dirId && dirId !== 0) {
|
||||
console.error('dirId type is null!');
|
||||
}
|
||||
var vmsId = get(item, 'extendInfo.vmsPlatformId');
|
||||
if (!vmsId && vmsId !== 0) {
|
||||
console.error('vmsId type is null!');
|
||||
}
|
||||
deviceKey = "".concat(type, "_").concat(dirId, "_").concat(vmsId);
|
||||
}
|
||||
break;
|
||||
case DeviceType['VMS']:
|
||||
deviceKey = "".concat(type, "_").concat(item['id']);
|
||||
break;
|
||||
case DeviceType['CAMERA']:
|
||||
{
|
||||
var _vmsId = get(item, 'extendInfo.vmsPlatformId');
|
||||
if (!_vmsId && _vmsId !== 0) {
|
||||
console.error('vmsId type is null!');
|
||||
}
|
||||
deviceKey = "".concat(type, "_").concat(item.id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return deviceKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备树key 转 后端设备原始id dirid是string/vms&camera 是number 和后端保持一致
|
||||
* @param deviceKey 设备树的id
|
||||
*/
|
||||
export function deviceKeyToDeviceId(deviceKey) {
|
||||
var _deviceKey$split = deviceKey.split('_'),
|
||||
_deviceKey$split2 = _slicedToArray(_deviceKey$split, 2),
|
||||
type = _deviceKey$split2[0],
|
||||
id = _deviceKey$split2[1];
|
||||
return type === DeviceType['DIR'] ? id : Number(id);
|
||||
}
|
||||
export var getVmsIdByDeviceId = function getVmsIdByDeviceId(key) {
|
||||
var type = getDeviceType(key);
|
||||
var vmsId = '';
|
||||
switch (type) {
|
||||
case DeviceType['CAMERA']:
|
||||
case DeviceType['DIR']:
|
||||
vmsId = key.split('_')[2];
|
||||
break;
|
||||
case DeviceType['VMS']:
|
||||
vmsId = key.split('_')[1];
|
||||
break;
|
||||
}
|
||||
if (!vmsId) {
|
||||
console.error('vmsid is null!');
|
||||
}
|
||||
return vmsId;
|
||||
};
|
||||
|
||||
/**
|
||||
* 通过设备id或设备key在树里面找摄像头
|
||||
* @param ids cameraId
|
||||
* @param deviceTree 树
|
||||
* @param type "id" | "key"
|
||||
*/
|
||||
export var findCamerasByInDeviceTree = function findCamerasByInDeviceTree() {
|
||||
var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var deviceTree = arguments.length > 1 ? arguments[1] : undefined;
|
||||
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'id';
|
||||
var cameraInfoList = [];
|
||||
var _ids = ids.map(function (v) {
|
||||
return String(v);
|
||||
}); //都转string在做判断 保证格式一致
|
||||
loop(deviceTree, function (item) {
|
||||
var isCamera = getDeviceType(get(item, 'key', '')) === DeviceType['CAMERA'];
|
||||
var isMatch = type === 'key' ? _ids.includes(get(item, 'key')) : _ids.includes("".concat(get(item, 'origin.id')));
|
||||
if (isCamera && isMatch) {
|
||||
cameraInfoList.push(item);
|
||||
}
|
||||
});
|
||||
return cameraInfoList;
|
||||
};
|
80
packages/func/es/file/index.d.ts
vendored
80
packages/func/es/file/index.d.ts
vendored
@ -1,80 +0,0 @@
|
||||
export declare type Rect = {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param url 需要转为图片的链接
|
||||
* @returns 图片的 dom
|
||||
*/
|
||||
export declare const urlToImg: (url: string) => Promise<HTMLImageElement>;
|
||||
export declare const base64DecodeImageKey: (base64ImgKey: string) => string;
|
||||
/**
|
||||
* 通过url获取图片的base64字符串
|
||||
* @param src 图片链接
|
||||
* @param outputFormat 图片格式
|
||||
* @returns base64 @string
|
||||
*/
|
||||
export declare const getBase64ByUrl: (src: string | URL, outputFormat?: string) => Promise<unknown>;
|
||||
/**
|
||||
* 把文件转base64
|
||||
* @param file @file 文件
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const fileToBase64: (file: any) => Promise<string>;
|
||||
/**
|
||||
*
|
||||
* @param image @file 图片文件
|
||||
* @param width @number 宽度
|
||||
* @param height @number 高度
|
||||
* @returns @string base64
|
||||
*/
|
||||
export declare const getBase64Image: (image: any, width?: any, height?: any) => string;
|
||||
/**
|
||||
* 通过图片获取base64
|
||||
* @param src 图片地址
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const getBase64ByImage: (src: string) => Promise<unknown>;
|
||||
/**
|
||||
* url转base64
|
||||
* @param {String} url - url地址
|
||||
*/
|
||||
export declare const urlToBase64V2: (url: string) => Promise<unknown>;
|
||||
/**
|
||||
* base64转Blob
|
||||
* @param {String} base64 - base64
|
||||
*/
|
||||
export declare function base64toBlob(base64: string): Blob | undefined;
|
||||
/**
|
||||
* 图片集打包压缩下载
|
||||
* 1. url -> base64 -> blob
|
||||
* 2. 将blob加入jsZip文件夹内,用file-saver保存
|
||||
* @param {Array<{url:string,name:string}>} imgDataList
|
||||
* @param {string} zipName
|
||||
*/
|
||||
export declare const downloadPackageImages: (imgDataList: string | any[], zipName: string) => Promise<void>;
|
||||
export declare function getFileSize(size: number): string;
|
||||
export declare const dataURLToBlob: (dataurl: string) => Blob;
|
||||
/**
|
||||
* key 转 http 链接
|
||||
* @param originImgkey 图片的值 ,可以是 base64 也可以是 http链接
|
||||
* @param host 图片的域值
|
||||
* @returns {string}
|
||||
*/
|
||||
export declare const generateImg: (imgKey: string, host?: string) => string;
|
||||
/**
|
||||
* 获取指定字符串后面的部分
|
||||
* @param imageKey v1_开头的字符串
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageKey: (imageKey: string, preFix?: string) => string;
|
||||
/**
|
||||
* 获取图片
|
||||
* @param img 图片的url链接
|
||||
* @param odRect
|
||||
* @returns file
|
||||
*/
|
||||
export declare const getFileByRect: (img: string, odRect: Rect) => Promise<File>;
|
File diff suppressed because one or more lines are too long
10
packages/func/es/index.d.ts
vendored
10
packages/func/es/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
export * from 'lodash-es';
|
||||
export * from './file';
|
||||
export * from './map';
|
||||
export * from './performance';
|
||||
export * from './string';
|
||||
export * from './number';
|
||||
export * from './time';
|
||||
export * from './utils';
|
||||
export * from './camera';
|
||||
export * from './math';
|
@ -1,10 +0,0 @@
|
||||
export * from 'lodash-es';
|
||||
export * from "./file";
|
||||
export * from "./map";
|
||||
export * from "./performance";
|
||||
export * from "./string";
|
||||
export * from "./number";
|
||||
export * from "./time";
|
||||
export * from "./utils";
|
||||
export * from "./camera";
|
||||
export * from "./math";
|
10
packages/func/es/map/index.d.ts
vendored
10
packages/func/es/map/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* 获取经纬信息
|
||||
* @param lngLat 位置信息
|
||||
* @returns @object { long, lat }
|
||||
*/
|
||||
export declare const fixedLngLat: (lngLat?: string) => string;
|
||||
export declare const transformLngLat: (lngLat?: string) => {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
} | null;
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* 获取经纬信息
|
||||
* @param lngLat 位置信息
|
||||
* @returns @object { long, lat }
|
||||
*/
|
||||
export var fixedLngLat = function fixedLngLat(lngLat) {
|
||||
if (!lngLat) {
|
||||
return '';
|
||||
}
|
||||
var lngLatArr = lngLat.split(',');
|
||||
var longitude = Number(lngLatArr[0]).toFixed(6);
|
||||
var latitude = Number(lngLatArr[1]).toFixed(6);
|
||||
if (lngLatArr.length < 2) {
|
||||
return '';
|
||||
}
|
||||
return "".concat(longitude, ",").concat(latitude);
|
||||
};
|
||||
export var transformLngLat = function transformLngLat(lngLat) {
|
||||
if (lngLat) {
|
||||
var lngLatArr = lngLat ? lngLat.split(',') : [];
|
||||
var longitude = Number(lngLatArr[0]);
|
||||
var latitude = Number(lngLatArr[1]);
|
||||
if (lngLatArr.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
longitude: longitude,
|
||||
latitude: latitude
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
2
packages/func/es/math/index.d.ts
vendored
2
packages/func/es/math/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
declare const _default: {};
|
||||
export default _default;
|
@ -1 +0,0 @@
|
||||
export default {};
|
14
packages/func/es/number/index.d.ts
vendored
14
packages/func/es/number/index.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* 设置数据的精度
|
||||
* @param originNumber
|
||||
* @param accuracy 精度 以原点为中心向左为正,向右为负,
|
||||
* @param isCeil 是否为向上取整
|
||||
* @returns number
|
||||
*/
|
||||
export declare const setNumberAccuracy: (originNumber: number, accuracy?: number, isCeil?: boolean) => number;
|
||||
/**
|
||||
* 获取数字
|
||||
* @param number 需要校验的数值
|
||||
* @returns @number
|
||||
*/
|
||||
export declare const toRealNumber: (number: any) => any;
|
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* 设置数据的精度
|
||||
* @param originNumber
|
||||
* @param accuracy 精度 以原点为中心向左为正,向右为负,
|
||||
* @param isCeil 是否为向上取整
|
||||
* @returns number
|
||||
*/
|
||||
export var setNumberAccuracy = function setNumberAccuracy(originNumber) {
|
||||
var accuracy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var isCeil = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
if (originNumber === 0) {
|
||||
return 0;
|
||||
}
|
||||
var returnData = 0;
|
||||
if (isCeil) {
|
||||
returnData = Math.ceil(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
} else {
|
||||
returnData = Math.floor(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
}
|
||||
//设置精度
|
||||
if (accuracy < 0) {
|
||||
returnData = Number(returnData.toFixed(-accuracy));
|
||||
} else {
|
||||
returnData = Number(returnData.toFixed(0));
|
||||
}
|
||||
return returnData;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取数字
|
||||
* @param number 需要校验的数值
|
||||
* @returns @number
|
||||
*/
|
||||
export var toRealNumber = function toRealNumber(number) {
|
||||
if (isNaN(number) || number === Infinity) {
|
||||
return 0;
|
||||
} else return number;
|
||||
};
|
1
packages/func/es/performance/index.d.ts
vendored
1
packages/func/es/performance/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const speedConvert: (bps: number, contertUnit?: number) => string;
|
@ -1,14 +0,0 @@
|
||||
// 1.bps KB/s or MB/s or GB/s 2.保留两位小数 3.默认是bps
|
||||
export var speedConvert = function speedConvert(bps) {
|
||||
var contertUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
||||
if (bps === undefined) return "0KB/s";
|
||||
var byte = bps / contertUnit;
|
||||
if (bps > 1024 * 1024 * 1024) {
|
||||
return "".concat((byte / 1024 / 1024 / 1024).toFixed(2), "GB/s");
|
||||
} else if (byte > 1024 * 1024) {
|
||||
return "".concat((byte / 1024 / 1024).toFixed(2), "MB/s");
|
||||
} else if (byte > 1024) {
|
||||
return "".concat((byte / 1024).toFixed(2), "KB/s");
|
||||
}
|
||||
return "".concat(byte, "KB/s");
|
||||
};
|
@ -1,105 +0,0 @@
|
||||
///<summary>获得字符串实际长度,中文2,英文1</summary>
|
||||
///<param name="str">要获得长度的字符串</param>
|
||||
export var getStrLength = function getStrLength(str) {
|
||||
var realLength = 0,
|
||||
len = str.length,
|
||||
charCode = -1;
|
||||
for (var i = 0; i < len; i++) {
|
||||
charCode = str.charCodeAt(i);
|
||||
if (charCode >= 0 && charCode <= 128) realLength += 1;else realLength += 2;
|
||||
}
|
||||
return realLength;
|
||||
};
|
||||
|
||||
//js截取字符串,中英文都能用
|
||||
//如果给定的字符串大于指定长度,截取指定长度返回,否者返回源字符串。
|
||||
//字符串,长度
|
||||
|
||||
/**
|
||||
* js截取字符串,中英文都能用
|
||||
* @param str:需要截取的字符串
|
||||
* @param len: 需要截取的长度
|
||||
*/
|
||||
export var cutStr = function cutstr(str, len) {
|
||||
var str_length = 0;
|
||||
var str_len = 0;
|
||||
var str_cut = new String();
|
||||
str_len = str.length;
|
||||
for (var i = 0; i < str_len; i++) {
|
||||
var a = str.charAt(i);
|
||||
str_length++;
|
||||
if (escape(a).length > 4) {
|
||||
//中文字符的长度经编码之后大于4
|
||||
str_length++;
|
||||
}
|
||||
str_cut = str_cut.concat(a);
|
||||
if (str_length >= len) {
|
||||
str_cut = str_cut.concat('...');
|
||||
return str_cut;
|
||||
}
|
||||
}
|
||||
//如果给定字符串小于指定长度,则返回源字符串;
|
||||
if (str_length < len) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 查看字符串是否为可访问链接
|
||||
* @param str 待检查链接
|
||||
* @returns
|
||||
*/
|
||||
export var isUrl = function isUrl(str) {
|
||||
try {
|
||||
new URL(str);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 通过url获取值
|
||||
* @param key 想要获取的值
|
||||
* @param url 需要截取的链接
|
||||
*/
|
||||
export var getValueByUrl = function getValueByUrl(key, str) {
|
||||
var result = null;
|
||||
if (isUrl(str)) {
|
||||
result = new URL(str).searchParams.get(key);
|
||||
} else {
|
||||
result = new URLSearchParams(str.indexOf('?') > -1 ? str : "?".concat(str)).get(key);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 行内px 转 rem
|
||||
* @param value px像素
|
||||
* @param rootFontSize 根元素大小: 默认16px
|
||||
*/
|
||||
export var pxToRem = function pxToRem(value, rootFontSize) {
|
||||
var fontSize = rootFontSize || 80 || parseFloat(document.documentElement.style.fontSize);
|
||||
var valueArr = value.split(' ');
|
||||
return valueArr.filter(function (o) {
|
||||
return o;
|
||||
}).map(function (val) {
|
||||
return parseFloat(val) / fontSize + 'rem';
|
||||
}).join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳转到指定URL
|
||||
* @param to 跳转的url
|
||||
* @returns URL
|
||||
*/
|
||||
export var jumpTo = function jumpTo(to) {
|
||||
var from = location.origin + location.pathname;
|
||||
// 检查是否为url,并且跑出错误
|
||||
if (!isUrl(to)) {
|
||||
throw Error("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u94FE\u63A5\uFF0C\u4EE5http(s)://\u5F00\u5934\uFF01'");
|
||||
}
|
||||
var _targetUrl = new URL(to);
|
||||
_targetUrl.searchParams.set('from', from);
|
||||
return _targetUrl;
|
||||
};
|
11
packages/func/es/time/index.d.ts
vendored
11
packages/func/es/time/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export declare const formateDuration: (diff: number) => string;
|
||||
export declare function generateTime(): {
|
||||
startDateTime: number;
|
||||
endDateTime: number;
|
||||
};
|
||||
/**
|
||||
* 格式化时间为 00:00
|
||||
* @param seconds 时间,单位秒
|
||||
* @returns
|
||||
*/
|
||||
export declare function formatDurationTime(seconds: number): string;
|
@ -1,57 +0,0 @@
|
||||
//时间差计算
|
||||
|
||||
import dayjs from "dayjs";
|
||||
|
||||
/*
|
||||
* startDate==>开始时间
|
||||
* endDate==>结束时间
|
||||
* 事例:diffTime(data.createTime,new Date())
|
||||
*
|
||||
* */
|
||||
export var formateDuration = function formateDuration(diff) {
|
||||
//计算出相差天数
|
||||
var days = Math.floor(diff / (24 * 3600 * 1000));
|
||||
|
||||
//计算出小时数
|
||||
var leave1 = diff % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
|
||||
var hours = Math.floor(leave1 / (3600 * 1000));
|
||||
//计算相差分钟数
|
||||
var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
|
||||
var minutes = Math.floor(leave2 / (60 * 1000));
|
||||
|
||||
//计算相差秒数
|
||||
var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
|
||||
var seconds = Math.round(leave3 / 1000);
|
||||
var returnStr = seconds + '秒';
|
||||
if (minutes > 0) {
|
||||
returnStr = minutes + '分'; //+ returnStr;
|
||||
}
|
||||
if (hours > 0) {
|
||||
returnStr = hours + '小时'; // + returnStr;
|
||||
}
|
||||
if (days > 0) {
|
||||
returnStr = days + '天'; //+ returnStr;
|
||||
}
|
||||
return returnStr;
|
||||
};
|
||||
|
||||
//检索默认时间
|
||||
export function generateTime() {
|
||||
var endDateTime = dayjs().endOf('day').unix();
|
||||
var startDateTime = dayjs().startOf('day').unix();
|
||||
return {
|
||||
startDateTime: startDateTime,
|
||||
endDateTime: endDateTime
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间为 00:00
|
||||
* @param seconds 时间,单位秒
|
||||
* @returns
|
||||
*/
|
||||
export function formatDurationTime(seconds) {
|
||||
var minutes = Math.floor(seconds / 60) || 0;
|
||||
var remainingSeconds = Math.floor(seconds % 60);
|
||||
return (minutes < 10 ? "0".concat(minutes) : minutes) + ":" + (remainingSeconds < 10 ? "0" : "") + remainingSeconds;
|
||||
}
|
36
packages/func/es/utils/index.d.ts
vendored
36
packages/func/es/utils/index.d.ts
vendored
@ -1,36 +0,0 @@
|
||||
export { default as isChrome } from './isChrome';
|
||||
export declare const matchS3Prefix: (str: string) => boolean;
|
||||
/**
|
||||
* 通过文件名获取文件类型
|
||||
* @param fileName 文件名称
|
||||
* @returns 文件类型
|
||||
*/
|
||||
export declare const getFileSuffix: (fileName: string) => string;
|
||||
/**
|
||||
* 通过类型获取文件名
|
||||
* @param type 类型
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageSuffixByFileType: (type: string) => string;
|
||||
export declare function getChromeVersion(): number | false;
|
||||
export declare const nextTick: (func: (value: void) => void | PromiseLike<void>) => void;
|
||||
export declare const loop: (items: string | any[], callback: (arg0: any) => any) => void;
|
||||
export declare const addEventListenerWrapper: (target: any, eventType: string, cb: any, option?: any) => {
|
||||
remove: () => void;
|
||||
};
|
||||
/**
|
||||
* Get transforms base on the given object.
|
||||
* @param {Object} obj - The target object.
|
||||
* @returns {string} A string contains transform values.
|
||||
*/
|
||||
export declare function getTransforms({ rotate, scaleX, scaleY, translateX, translateY, }: {
|
||||
rotate?: number;
|
||||
scaleX?: number;
|
||||
scaleY?: number;
|
||||
translateX?: number;
|
||||
translateY?: number;
|
||||
}): {
|
||||
WebkitTransform: string;
|
||||
msTransform: string;
|
||||
transform: string;
|
||||
};
|
@ -1,144 +0,0 @@
|
||||
import { isNumber } from 'lodash-es';
|
||||
import ReactDOM from 'react-dom';
|
||||
export { default as isChrome } from "./isChrome";
|
||||
export var matchS3Prefix = function matchS3Prefix(str) {
|
||||
return /^v[0-9]_/.test(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* 通过文件名获取文件类型
|
||||
* @param fileName 文件名称
|
||||
* @returns 文件类型
|
||||
*/
|
||||
export var getFileSuffix = function getFileSuffix(fileName) {
|
||||
var splitArr = fileName.split('.');
|
||||
return splitArr.length < 2 ? '' : splitArr[splitArr.length - 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* 通过类型获取文件名
|
||||
* @param type 类型
|
||||
* @returns
|
||||
*/
|
||||
export var getImageSuffixByFileType = function getImageSuffixByFileType(type) {
|
||||
var imageSuffix = '';
|
||||
switch (type) {
|
||||
case 'jpeg':
|
||||
{
|
||||
imageSuffix = '.jpg';
|
||||
break;
|
||||
}
|
||||
case 'gif':
|
||||
{
|
||||
imageSuffix = '.gif';
|
||||
break;
|
||||
}
|
||||
case 'png':
|
||||
{
|
||||
imageSuffix = '.png';
|
||||
break;
|
||||
}
|
||||
case 'vnd.wap.wbmp':
|
||||
{
|
||||
imageSuffix = '.wbmp';
|
||||
break;
|
||||
}
|
||||
case 'x-up-wpng':
|
||||
{
|
||||
imageSuffix = '.wpng';
|
||||
break;
|
||||
}
|
||||
case 'nbmp':
|
||||
{
|
||||
imageSuffix = '.nbmp';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageSuffix;
|
||||
};
|
||||
|
||||
// 获取谷歌浏览器版本
|
||||
export function getChromeVersion() {
|
||||
var arr = navigator.userAgent.split(' ');
|
||||
var chromeVersion = '';
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (/chrome/i.test(arr[i])) chromeVersion = arr[i];
|
||||
}
|
||||
if (chromeVersion) {
|
||||
return Number(chromeVersion.split('/')[1].split('.')[0]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export var nextTick = function nextTick(func) {
|
||||
if (queueMicrotask) {
|
||||
queueMicrotask(func);
|
||||
return;
|
||||
}
|
||||
Promise.resolve().then(func);
|
||||
};
|
||||
export var loop = function loop(items, callback) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var element = items[i];
|
||||
var isBreak = callback(element);
|
||||
if (isBreak) {
|
||||
return;
|
||||
}
|
||||
if (element['children']) {
|
||||
loop(element['children'], callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
export var addEventListenerWrapper = function addEventListenerWrapper(target, eventType, cb, option) {
|
||||
/* eslint camelcase: 2 */
|
||||
var callback = ReactDOM.unstable_batchedUpdates ? function run(e) {
|
||||
ReactDOM.unstable_batchedUpdates(cb, e);
|
||||
} : cb;
|
||||
if (target.addEventListener) {
|
||||
target.addEventListener(eventType, callback, option);
|
||||
}
|
||||
return {
|
||||
remove: function remove() {
|
||||
if (target.removeEventListener) {
|
||||
target.removeEventListener(eventType, callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get transforms base on the given object.
|
||||
* @param {Object} obj - The target object.
|
||||
* @returns {string} A string contains transform values.
|
||||
*/
|
||||
export function getTransforms(_ref) {
|
||||
var rotate = _ref.rotate,
|
||||
scaleX = _ref.scaleX,
|
||||
scaleY = _ref.scaleY,
|
||||
translateX = _ref.translateX,
|
||||
translateY = _ref.translateY;
|
||||
var values = [];
|
||||
if (isNumber(translateX) && translateX !== 0) {
|
||||
values.push("translateX(".concat(translateX, "px)"));
|
||||
}
|
||||
if (isNumber(translateY) && translateY !== 0) {
|
||||
values.push("translateY(".concat(translateY, "px)"));
|
||||
}
|
||||
|
||||
// Rotate should come first before scale to match orientation transform
|
||||
if (isNumber(rotate) && rotate !== 0) {
|
||||
values.push("rotate(".concat(rotate, "deg)"));
|
||||
}
|
||||
if (isNumber(scaleX) && scaleX !== 1) {
|
||||
values.push("scaleX(".concat(scaleX, ")"));
|
||||
}
|
||||
if (isNumber(scaleY) && scaleY !== 1) {
|
||||
values.push("scaleY(".concat(scaleY, ")"));
|
||||
}
|
||||
var transform = values.length ? values.join(' ') : 'none';
|
||||
return {
|
||||
WebkitTransform: transform,
|
||||
msTransform: transform,
|
||||
transform: transform
|
||||
};
|
||||
}
|
3
packages/func/es/utils/isChrome.d.ts
vendored
3
packages/func/es/utils/isChrome.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare const isBrowser: boolean;
|
||||
declare const isChrome: () => boolean;
|
||||
export default isChrome;
|
@ -1,17 +0,0 @@
|
||||
export var isBrowser = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||||
var isChrome = function isChrome() {
|
||||
var winNav = isBrowser && window.navigator;
|
||||
var vendorName = winNav && (winNav === null || winNav === void 0 ? void 0 : winNav.vendor);
|
||||
var userAgent = winNav && winNav.userAgent;
|
||||
|
||||
//@ts-ignore
|
||||
var isChromium = isBrowser && typeof chrome !== 'undefined';
|
||||
|
||||
//@ts-ignore
|
||||
var isOpera = isBrowser && typeof opr !== 'undefined';
|
||||
var isIEedge = userAgent && userAgent.indexOf('Edge') > -1;
|
||||
var isIOSChrome = !!(userAgent && userAgent.match('CriOS'));
|
||||
var isDesktopChrome = isChromium && vendorName === 'Google Inc.' && !isOpera && !isIEedge;
|
||||
return isIOSChrome || isDesktopChrome;
|
||||
};
|
||||
export default isChrome;
|
41
packages/func/lib/camera/constants.d.ts
vendored
41
packages/func/lib/camera/constants.d.ts
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 设备类型枚举
|
||||
*/
|
||||
export declare const DeviceType: {
|
||||
VMS: string;
|
||||
DIR: string;
|
||||
CAMERA: string;
|
||||
};
|
||||
export declare const LOCAL_KEY = "local";
|
||||
export declare const DIRE_CONNECT_KEY = "direconnect";
|
||||
export declare const BOX_LIST_KEY = "boxlist";
|
||||
export declare enum VmsplatformOpt {
|
||||
VMSPLATFORMOPT_ID = 0,
|
||||
VMSPLATFORMOPT_PLATFORMNAME = 1,
|
||||
VMSPLATFORMOPT_PLUGINNAME = 2,
|
||||
VMSPLATFORMOPT_IP = 3,
|
||||
VMSPLATFORMOPT_PORT = 4,
|
||||
VMSPLATFORMOPT_USERNAME = 5,
|
||||
VMSPLATFORMOPT_PASSWORD = 6
|
||||
}
|
||||
export declare enum OPT {
|
||||
OR = 0,
|
||||
AND = 1,
|
||||
ORNOT = 2,
|
||||
ANDNOT = 3
|
||||
}
|
||||
export declare enum DevicemanagerCameraType {
|
||||
DEVICEMANAGER_CAMERA_TYPE_DEFAULT = 0,
|
||||
DEVICEMANAGER_CAMERA_TYPE_NORMAL = 1,
|
||||
DEVICEMANAGER_CAMERA_TYPE_1400 = 97,
|
||||
DEVICEMANAGER_CAMERA_TYPE_DHGRABBER = 98,
|
||||
DEVICEMANAGER_CAMERA_TYPE_HKGRABBER = 99,
|
||||
DEVICEMANAGER_CAMERA_TYPE_LOCAL = 100
|
||||
}
|
||||
export declare const BOX_DIRECONNECT_PLATFORM_FILTER: {
|
||||
filtervmsplatformList: {
|
||||
opt: OPT;
|
||||
vmsplatformOpt: VmsplatformOpt;
|
||||
value: string;
|
||||
}[];
|
||||
};
|
@ -1,90 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/camera/constants.ts
|
||||
var constants_exports = {};
|
||||
__export(constants_exports, {
|
||||
BOX_DIRECONNECT_PLATFORM_FILTER: () => BOX_DIRECONNECT_PLATFORM_FILTER,
|
||||
BOX_LIST_KEY: () => BOX_LIST_KEY,
|
||||
DIRE_CONNECT_KEY: () => DIRE_CONNECT_KEY,
|
||||
DeviceType: () => DeviceType,
|
||||
DevicemanagerCameraType: () => DevicemanagerCameraType,
|
||||
LOCAL_KEY: () => LOCAL_KEY,
|
||||
OPT: () => OPT,
|
||||
VmsplatformOpt: () => VmsplatformOpt
|
||||
});
|
||||
module.exports = __toCommonJS(constants_exports);
|
||||
var DeviceType = {
|
||||
VMS: "vms",
|
||||
DIR: "dir",
|
||||
CAMERA: "camera"
|
||||
};
|
||||
var LOCAL_KEY = "local";
|
||||
var DIRE_CONNECT_KEY = "direconnect";
|
||||
var BOX_LIST_KEY = "boxlist";
|
||||
var VmsplatformOpt = /* @__PURE__ */ ((VmsplatformOpt2) => {
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_ID"] = 0] = "VMSPLATFORMOPT_ID";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PLATFORMNAME"] = 1] = "VMSPLATFORMOPT_PLATFORMNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PLUGINNAME"] = 2] = "VMSPLATFORMOPT_PLUGINNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_IP"] = 3] = "VMSPLATFORMOPT_IP";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PORT"] = 4] = "VMSPLATFORMOPT_PORT";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_USERNAME"] = 5] = "VMSPLATFORMOPT_USERNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PASSWORD"] = 6] = "VMSPLATFORMOPT_PASSWORD";
|
||||
return VmsplatformOpt2;
|
||||
})(VmsplatformOpt || {});
|
||||
var OPT = /* @__PURE__ */ ((OPT2) => {
|
||||
OPT2[OPT2["OR"] = 0] = "OR";
|
||||
OPT2[OPT2["AND"] = 1] = "AND";
|
||||
OPT2[OPT2["ORNOT"] = 2] = "ORNOT";
|
||||
OPT2[OPT2["ANDNOT"] = 3] = "ANDNOT";
|
||||
return OPT2;
|
||||
})(OPT || {});
|
||||
var DevicemanagerCameraType = /* @__PURE__ */ ((DevicemanagerCameraType2) => {
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_DEFAULT"] = 0] = "DEVICEMANAGER_CAMERA_TYPE_DEFAULT";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_NORMAL"] = 1] = "DEVICEMANAGER_CAMERA_TYPE_NORMAL";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_1400"] = 97] = "DEVICEMANAGER_CAMERA_TYPE_1400";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_DHGRABBER"] = 98] = "DEVICEMANAGER_CAMERA_TYPE_DHGRABBER";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_HKGRABBER"] = 99] = "DEVICEMANAGER_CAMERA_TYPE_HKGRABBER";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_LOCAL"] = 100] = "DEVICEMANAGER_CAMERA_TYPE_LOCAL";
|
||||
return DevicemanagerCameraType2;
|
||||
})(DevicemanagerCameraType || {});
|
||||
var BOX_DIRECONNECT_PLATFORM_FILTER = {
|
||||
filtervmsplatformList: [
|
||||
{
|
||||
opt: 0 /* OR */,
|
||||
vmsplatformOpt: 1 /* VMSPLATFORMOPT_PLATFORMNAME */,
|
||||
value: "direconnect"
|
||||
},
|
||||
{
|
||||
opt: 0 /* OR */,
|
||||
vmsplatformOpt: 1 /* VMSPLATFORMOPT_PLATFORMNAME */,
|
||||
value: "boxlist"
|
||||
}
|
||||
]
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BOX_DIRECONNECT_PLATFORM_FILTER,
|
||||
BOX_LIST_KEY,
|
||||
DIRE_CONNECT_KEY,
|
||||
DeviceType,
|
||||
DevicemanagerCameraType,
|
||||
LOCAL_KEY,
|
||||
OPT,
|
||||
VmsplatformOpt
|
||||
});
|
40
packages/func/lib/camera/index.d.ts
vendored
40
packages/func/lib/camera/index.d.ts
vendored
@ -1,40 +0,0 @@
|
||||
import { DevicemanagerCameraType } from './constants';
|
||||
export declare const isFaceCamera: (type: DevicemanagerCameraType) => boolean;
|
||||
/**
|
||||
*
|
||||
* @param value 传入的数据 可以是 item(camera/vms/dirs)/ deviceID
|
||||
* @param isId
|
||||
*/
|
||||
export declare function getDeviceType(value: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
} | string): any;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param id 设备id
|
||||
* @param type 设备类型
|
||||
*/
|
||||
export declare function deviceIDToDeviceKey(id: any, type: string, vmsId?: any): string;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param item camera/vms/dirs
|
||||
*/
|
||||
export declare function deviceToDeviceKey(item: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
}): string;
|
||||
/**
|
||||
* 设备树key 转 后端设备原始id dirid是string/vms&camera 是number 和后端保持一致
|
||||
* @param deviceKey 设备树的id
|
||||
*/
|
||||
export declare function deviceKeyToDeviceId(deviceKey: {
|
||||
split: (arg0: string) => [any, any];
|
||||
}): any;
|
||||
export declare const getVmsIdByDeviceId: (key: string) => string;
|
||||
/**
|
||||
* 通过设备id或设备key在树里面找摄像头
|
||||
* @param ids cameraId
|
||||
* @param deviceTree 树
|
||||
* @param type "id" | "key"
|
||||
*/
|
||||
export declare const findCamerasByInDeviceTree: (ids: never[] | undefined, deviceTree: any, type?: string) => any[];
|
@ -1,143 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/camera/index.ts
|
||||
var camera_exports = {};
|
||||
__export(camera_exports, {
|
||||
deviceIDToDeviceKey: () => deviceIDToDeviceKey,
|
||||
deviceKeyToDeviceId: () => deviceKeyToDeviceId,
|
||||
deviceToDeviceKey: () => deviceToDeviceKey,
|
||||
findCamerasByInDeviceTree: () => findCamerasByInDeviceTree,
|
||||
getDeviceType: () => getDeviceType,
|
||||
getVmsIdByDeviceId: () => getVmsIdByDeviceId,
|
||||
isFaceCamera: () => isFaceCamera
|
||||
});
|
||||
module.exports = __toCommonJS(camera_exports);
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_utils = require("../utils");
|
||||
var import_constants = require("./constants");
|
||||
var isFaceCamera = (type) => {
|
||||
return [
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_1400,
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_HKGRABBER,
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_DHGRABBER
|
||||
].includes(type);
|
||||
};
|
||||
function getDeviceType(value) {
|
||||
let type;
|
||||
let isDeviceKey = (0, import_lodash_es.isString)(value);
|
||||
if (isDeviceKey) {
|
||||
type = value.split("_")[0];
|
||||
} else {
|
||||
if ((0, import_lodash_es.has)(value, "longitude")) {
|
||||
type = import_constants.DeviceType["CAMERA"];
|
||||
}
|
||||
if ((0, import_lodash_es.has)(value, "ip")) {
|
||||
type = import_constants.DeviceType["VMS"];
|
||||
}
|
||||
if (!type) {
|
||||
type = import_constants.DeviceType["DIR"];
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
function deviceIDToDeviceKey(id, type, vmsId) {
|
||||
if (type == import_constants.DeviceType["DIR"]) {
|
||||
return `${type}_${id}_${vmsId}`;
|
||||
} else {
|
||||
return `${type}_${id}`;
|
||||
}
|
||||
}
|
||||
function deviceToDeviceKey(item) {
|
||||
let deviceKey = "";
|
||||
let type = getDeviceType(item);
|
||||
if (!type) {
|
||||
console.error("device type is null!");
|
||||
}
|
||||
switch (type) {
|
||||
case import_constants.DeviceType["DIR"]:
|
||||
{
|
||||
let dirId = item["dirid"] || item["dirId"];
|
||||
if (!dirId && dirId !== 0) {
|
||||
console.error("dirId type is null!");
|
||||
}
|
||||
let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId");
|
||||
if (!vmsId && vmsId !== 0) {
|
||||
console.error("vmsId type is null!");
|
||||
}
|
||||
deviceKey = `${type}_${dirId}_${vmsId}`;
|
||||
}
|
||||
break;
|
||||
case import_constants.DeviceType["VMS"]:
|
||||
deviceKey = `${type}_${item["id"]}`;
|
||||
break;
|
||||
case import_constants.DeviceType["CAMERA"]:
|
||||
{
|
||||
let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId");
|
||||
if (!vmsId && vmsId !== 0) {
|
||||
console.error("vmsId type is null!");
|
||||
}
|
||||
deviceKey = `${type}_${item.id}`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return deviceKey;
|
||||
}
|
||||
function deviceKeyToDeviceId(deviceKey) {
|
||||
let [type, id] = deviceKey.split("_");
|
||||
return type === import_constants.DeviceType["DIR"] ? id : Number(id);
|
||||
}
|
||||
var getVmsIdByDeviceId = (key) => {
|
||||
const type = getDeviceType(key);
|
||||
let vmsId = "";
|
||||
switch (type) {
|
||||
case import_constants.DeviceType["CAMERA"]:
|
||||
case import_constants.DeviceType["DIR"]:
|
||||
vmsId = key.split("_")[2];
|
||||
break;
|
||||
case import_constants.DeviceType["VMS"]:
|
||||
vmsId = key.split("_")[1];
|
||||
break;
|
||||
}
|
||||
if (!vmsId) {
|
||||
console.error("vmsid is null!");
|
||||
}
|
||||
return vmsId;
|
||||
};
|
||||
var findCamerasByInDeviceTree = (ids = [], deviceTree, type = "id") => {
|
||||
let cameraInfoList = [];
|
||||
let _ids = ids.map((v) => String(v));
|
||||
(0, import_utils.loop)(deviceTree, (item) => {
|
||||
let isCamera = getDeviceType((0, import_lodash_es.get)(item, "key", "")) === import_constants.DeviceType["CAMERA"];
|
||||
let isMatch = type === "key" ? _ids.includes((0, import_lodash_es.get)(item, "key")) : _ids.includes(`${(0, import_lodash_es.get)(item, "origin.id")}`);
|
||||
if (isCamera && isMatch) {
|
||||
cameraInfoList.push(item);
|
||||
}
|
||||
});
|
||||
return cameraInfoList;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
deviceIDToDeviceKey,
|
||||
deviceKeyToDeviceId,
|
||||
deviceToDeviceKey,
|
||||
findCamerasByInDeviceTree,
|
||||
getDeviceType,
|
||||
getVmsIdByDeviceId,
|
||||
isFaceCamera
|
||||
});
|
80
packages/func/lib/file/index.d.ts
vendored
80
packages/func/lib/file/index.d.ts
vendored
@ -1,80 +0,0 @@
|
||||
export declare type Rect = {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param url 需要转为图片的链接
|
||||
* @returns 图片的 dom
|
||||
*/
|
||||
export declare const urlToImg: (url: string) => Promise<HTMLImageElement>;
|
||||
export declare const base64DecodeImageKey: (base64ImgKey: string) => string;
|
||||
/**
|
||||
* 通过url获取图片的base64字符串
|
||||
* @param src 图片链接
|
||||
* @param outputFormat 图片格式
|
||||
* @returns base64 @string
|
||||
*/
|
||||
export declare const getBase64ByUrl: (src: string | URL, outputFormat?: string) => Promise<unknown>;
|
||||
/**
|
||||
* 把文件转base64
|
||||
* @param file @file 文件
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const fileToBase64: (file: any) => Promise<string>;
|
||||
/**
|
||||
*
|
||||
* @param image @file 图片文件
|
||||
* @param width @number 宽度
|
||||
* @param height @number 高度
|
||||
* @returns @string base64
|
||||
*/
|
||||
export declare const getBase64Image: (image: any, width?: any, height?: any) => string;
|
||||
/**
|
||||
* 通过图片获取base64
|
||||
* @param src 图片地址
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const getBase64ByImage: (src: string) => Promise<unknown>;
|
||||
/**
|
||||
* url转base64
|
||||
* @param {String} url - url地址
|
||||
*/
|
||||
export declare const urlToBase64V2: (url: string) => Promise<unknown>;
|
||||
/**
|
||||
* base64转Blob
|
||||
* @param {String} base64 - base64
|
||||
*/
|
||||
export declare function base64toBlob(base64: string): Blob | undefined;
|
||||
/**
|
||||
* 图片集打包压缩下载
|
||||
* 1. url -> base64 -> blob
|
||||
* 2. 将blob加入jsZip文件夹内,用file-saver保存
|
||||
* @param {Array<{url:string,name:string}>} imgDataList
|
||||
* @param {string} zipName
|
||||
*/
|
||||
export declare const downloadPackageImages: (imgDataList: string | any[], zipName: string) => Promise<void>;
|
||||
export declare function getFileSize(size: number): string;
|
||||
export declare const dataURLToBlob: (dataurl: string) => Blob;
|
||||
/**
|
||||
* key 转 http 链接
|
||||
* @param originImgkey 图片的值 ,可以是 base64 也可以是 http链接
|
||||
* @param host 图片的域值
|
||||
* @returns {string}
|
||||
*/
|
||||
export declare const generateImg: (imgKey: string, host?: string) => string;
|
||||
/**
|
||||
* 获取指定字符串后面的部分
|
||||
* @param imageKey v1_开头的字符串
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageKey: (imageKey: string, preFix?: string) => string;
|
||||
/**
|
||||
* 获取图片
|
||||
* @param img 图片的url链接
|
||||
* @param odRect
|
||||
* @returns file
|
||||
*/
|
||||
export declare const getFileByRect: (img: string, odRect: Rect) => Promise<File>;
|
@ -1,308 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/file/index.ts
|
||||
var file_exports = {};
|
||||
__export(file_exports, {
|
||||
base64DecodeImageKey: () => base64DecodeImageKey,
|
||||
base64toBlob: () => base64toBlob,
|
||||
dataURLToBlob: () => dataURLToBlob,
|
||||
downloadPackageImages: () => downloadPackageImages,
|
||||
fileToBase64: () => fileToBase64,
|
||||
generateImg: () => generateImg,
|
||||
getBase64ByImage: () => getBase64ByImage,
|
||||
getBase64ByUrl: () => getBase64ByUrl,
|
||||
getBase64Image: () => getBase64Image,
|
||||
getFileByRect: () => getFileByRect,
|
||||
getFileSize: () => getFileSize,
|
||||
getImageKey: () => getImageKey,
|
||||
urlToBase64V2: () => urlToBase64V2,
|
||||
urlToImg: () => urlToImg
|
||||
});
|
||||
module.exports = __toCommonJS(file_exports);
|
||||
var import_base_64 = __toESM(require("base-64"));
|
||||
var import_jszip = __toESM(require("jszip"));
|
||||
var import_file_saver = __toESM(require("file-saver"));
|
||||
var import_utils = require("../utils");
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var urlToImg = (url) => {
|
||||
const resImage = new Promise((resolve) => {
|
||||
const image = new Image();
|
||||
image.crossOrigin = "";
|
||||
image.src = url;
|
||||
image.onload = () => {
|
||||
resolve(image);
|
||||
};
|
||||
});
|
||||
return resImage;
|
||||
};
|
||||
var base64DecodeImageKey = (base64ImgKey) => {
|
||||
let tempStr = base64ImgKey;
|
||||
if ((0, import_utils.matchS3Prefix)(tempStr)) {
|
||||
tempStr = tempStr.replace(/^v[0-9]_/, "");
|
||||
tempStr = import_base_64.default.decode(tempStr);
|
||||
}
|
||||
const [bucket, ...pathArr] = tempStr.split("_");
|
||||
return tempStr = `${bucket}/${pathArr.join("_")}`;
|
||||
};
|
||||
var getBase64ByUrl = function(src, outputFormat = "image/png") {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", src, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.onload = function(e) {
|
||||
if (Number(xhr.status) === 200) {
|
||||
const uInt8Array = new Uint8Array(xhr.response);
|
||||
let i = uInt8Array.length;
|
||||
const binaryString = new Array(i);
|
||||
while (i--) {
|
||||
binaryString[i] = String.fromCharCode(uInt8Array[i]);
|
||||
}
|
||||
const data = binaryString.join("");
|
||||
const base64 = window.btoa(data);
|
||||
const dataUrl = "data:" + (outputFormat || "image/png") + ";base64," + base64;
|
||||
resolve(dataUrl);
|
||||
} else {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
xhr.onerror = (e) => {
|
||||
reject(e);
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
};
|
||||
var fileToBase64 = (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function(e) {
|
||||
resolve(e == null ? void 0 : e.target.result);
|
||||
};
|
||||
reader.onerror = function(e) {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
};
|
||||
var getBase64Image = (image, width, height) => {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = width !== void 0 ? width : image.width;
|
||||
canvas.height = height !== void 0 ? height : image.height;
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx == null ? void 0 : ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
const ext = image.src.substring(image.src.lastIndexOf(".") + 1).toLowerCase();
|
||||
const dataURL = canvas.toDataURL("image/" + ext);
|
||||
return dataURL;
|
||||
};
|
||||
var getBase64ByImage = function(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const image = new Image();
|
||||
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
||||
const imgUrl = src + "?" + timestamp;
|
||||
image.src = imgUrl;
|
||||
image.onload = function() {
|
||||
function getBase64Image2(img) {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx == null ? void 0 : ctx.drawImage(img, 0, 0, img.width, img.height);
|
||||
const ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
|
||||
const dataURL = canvas.toDataURL("image/" + ext);
|
||||
return dataURL;
|
||||
}
|
||||
const base64 = getBase64Image2(image);
|
||||
resolve(base64);
|
||||
};
|
||||
image.onerror = (e) => {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
};
|
||||
var urlToBase64V2 = (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let image = new Image();
|
||||
image.onload = function() {
|
||||
var _a;
|
||||
let canvas = document.createElement("canvas");
|
||||
canvas.width = image.naturalWidth;
|
||||
canvas.height = image.naturalHeight;
|
||||
(_a = canvas == null ? void 0 : canvas.getContext("2d")) == null ? void 0 : _a.drawImage(image, 0, 0);
|
||||
let result = canvas.toDataURL("image/png");
|
||||
resolve(result);
|
||||
};
|
||||
const imgUrl = url;
|
||||
image.setAttribute("crossOrigin", "Anonymous");
|
||||
image.src = imgUrl;
|
||||
image.onerror = () => {
|
||||
reject(new Error("Images fail to load"));
|
||||
};
|
||||
}).catch((error) => {
|
||||
throw new Error(error);
|
||||
});
|
||||
};
|
||||
function base64toBlob(base64) {
|
||||
if (!base64) return;
|
||||
var arr = base64.split(","), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], { type: mime });
|
||||
}
|
||||
var downloadPackageImages = async (imgDataList, zipName) => {
|
||||
let imgDataDownLoadList = [];
|
||||
let imgBlobList = [];
|
||||
let imageSuffix = [];
|
||||
let zip = new import_jszip.default();
|
||||
let img = zip.folder(zipName);
|
||||
try {
|
||||
for (let i2 = 0; i2 < imgDataList.length; i2++) {
|
||||
let src = imgDataList[i2].url;
|
||||
let suffix = src.substring(src.lastIndexOf("."));
|
||||
let base64ByUrl = await urlToBase64V2(imgDataList[i2].url);
|
||||
if (!base64ByUrl) continue;
|
||||
let blob = base64toBlob(base64ByUrl);
|
||||
imgDataDownLoadList.push(imgDataList[i2]);
|
||||
imgBlobList.push(blob);
|
||||
imageSuffix.push(suffix);
|
||||
}
|
||||
if (imgBlobList.length === 0) throw new Error("The number of pictures is zero !");
|
||||
if (imgBlobList.length > 0) {
|
||||
for (var i = 0; i < imgBlobList.length; i++) {
|
||||
img == null ? void 0 : img.file(
|
||||
imgDataDownLoadList[i].name + (0, import_lodash_es.get)(imageSuffix, `.${i}`, imageSuffix[0]),
|
||||
// @ts-ignore
|
||||
imgBlobList[i],
|
||||
{
|
||||
base64: true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
zip.generateAsync({ type: "blob" }).then(function(content) {
|
||||
import_file_saver.default.saveAs(content, zipName + ".zip");
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
};
|
||||
function getFileSize(size) {
|
||||
if (!size) return "";
|
||||
var num = 1024;
|
||||
if (size < num) return size + "B";
|
||||
if (size < Math.pow(num, 2)) return (size / num).toFixed(2) + "K";
|
||||
if (size < Math.pow(num, 3)) return (size / Math.pow(num, 2)).toFixed(2) + "M";
|
||||
if (size < Math.pow(num, 4)) return (size / Math.pow(num, 3)).toFixed(2) + "G";
|
||||
return (size / Math.pow(num, 4)).toFixed(2) + "T";
|
||||
}
|
||||
var dataURLToBlob = (dataurl) => {
|
||||
const arr = dataurl.split(",");
|
||||
const mime = arr[0].match(/:(.*?);/)[1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], { type: mime });
|
||||
};
|
||||
var generateImg = (_imgKey, host = "http://10.0.0.120") => {
|
||||
let imgKey = _imgKey;
|
||||
let imgUrl = "";
|
||||
if (!imgKey) return "";
|
||||
if (/(http|https):\/\/([\w.]+\/?)\S*/ig.test(imgKey)) {
|
||||
return imgKey;
|
||||
}
|
||||
try {
|
||||
if ((0, import_utils.matchS3Prefix)(imgKey)) {
|
||||
imgKey = base64DecodeImageKey(imgKey);
|
||||
if (imgKey.endsWith("/")) {
|
||||
const i = imgKey.substring(0, imgKey.length - 1);
|
||||
imgKey = i;
|
||||
}
|
||||
}
|
||||
imgUrl = `${host}/file/${imgKey}`;
|
||||
if (_imgKey.includes("v3")) {
|
||||
imgUrl = `${host}/minio/${imgKey}`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
imgUrl = "";
|
||||
}
|
||||
return imgUrl;
|
||||
};
|
||||
var getImageKey = (imageKey, preFix) => {
|
||||
const splitIndex = preFix || "v1_";
|
||||
if (imageKey.startsWith(splitIndex)) {
|
||||
return window.atob(imageKey.split(splitIndex)[1]).replace("_", "/");
|
||||
} else {
|
||||
return imageKey;
|
||||
}
|
||||
};
|
||||
var getFileByRect = async (img, odRect) => {
|
||||
var _a;
|
||||
let image;
|
||||
if ((0, import_lodash_es.isString)(img)) {
|
||||
const url = generateImg(img);
|
||||
image = await urlToImg(url);
|
||||
} else {
|
||||
image = img;
|
||||
}
|
||||
const commonCanvas = document.createElement("canvas");
|
||||
commonCanvas.width = odRect.w * image.width;
|
||||
commonCanvas.height = odRect.h * image.height;
|
||||
commonCanvas.style.display = "none";
|
||||
document.body.appendChild(commonCanvas);
|
||||
const commonCtx = commonCanvas.getContext("2d");
|
||||
commonCtx == null ? void 0 : commonCtx.translate(-odRect.x * image.width, -odRect.y * image.height);
|
||||
commonCtx == null ? void 0 : commonCtx.drawImage(image, 0, 0);
|
||||
const base64 = commonCanvas.toDataURL("image/jpeg");
|
||||
const blobData = dataURLToBlob(base64);
|
||||
(_a = commonCanvas.parentNode) == null ? void 0 : _a.removeChild(commonCanvas);
|
||||
const file = new window.File([blobData], `${(/* @__PURE__ */ new Date()).getTime()}`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
return file;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
base64DecodeImageKey,
|
||||
base64toBlob,
|
||||
dataURLToBlob,
|
||||
downloadPackageImages,
|
||||
fileToBase64,
|
||||
generateImg,
|
||||
getBase64ByImage,
|
||||
getBase64ByUrl,
|
||||
getBase64Image,
|
||||
getFileByRect,
|
||||
getFileSize,
|
||||
getImageKey,
|
||||
urlToBase64V2,
|
||||
urlToImg
|
||||
});
|
10
packages/func/lib/index.d.ts
vendored
10
packages/func/lib/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
export * from 'lodash-es';
|
||||
export * from './file';
|
||||
export * from './map';
|
||||
export * from './performance';
|
||||
export * from './string';
|
||||
export * from './number';
|
||||
export * from './time';
|
||||
export * from './utils';
|
||||
export * from './camera';
|
||||
export * from './math';
|
@ -1,41 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.tsx
|
||||
var src_exports = {};
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
__reExport(src_exports, require("lodash-es"), module.exports);
|
||||
__reExport(src_exports, require("./file"), module.exports);
|
||||
__reExport(src_exports, require("./map"), module.exports);
|
||||
__reExport(src_exports, require("./performance"), module.exports);
|
||||
__reExport(src_exports, require("./string"), module.exports);
|
||||
__reExport(src_exports, require("./number"), module.exports);
|
||||
__reExport(src_exports, require("./time"), module.exports);
|
||||
__reExport(src_exports, require("./utils"), module.exports);
|
||||
__reExport(src_exports, require("./camera"), module.exports);
|
||||
__reExport(src_exports, require("./math"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("lodash-es"),
|
||||
...require("./file"),
|
||||
...require("./map"),
|
||||
...require("./performance"),
|
||||
...require("./string"),
|
||||
...require("./number"),
|
||||
...require("./time"),
|
||||
...require("./utils"),
|
||||
...require("./camera"),
|
||||
...require("./math")
|
||||
});
|
10
packages/func/lib/map/index.d.ts
vendored
10
packages/func/lib/map/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* 获取经纬信息
|
||||
* @param lngLat 位置信息
|
||||
* @returns @object { long, lat }
|
||||
*/
|
||||
export declare const fixedLngLat: (lngLat?: string) => string;
|
||||
export declare const transformLngLat: (lngLat?: string) => {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
} | null;
|
@ -1,54 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/map/index.ts
|
||||
var map_exports = {};
|
||||
__export(map_exports, {
|
||||
fixedLngLat: () => fixedLngLat,
|
||||
transformLngLat: () => transformLngLat
|
||||
});
|
||||
module.exports = __toCommonJS(map_exports);
|
||||
var fixedLngLat = (lngLat) => {
|
||||
if (!lngLat) {
|
||||
return "";
|
||||
}
|
||||
const lngLatArr = lngLat.split(",");
|
||||
const longitude = Number(lngLatArr[0]).toFixed(6);
|
||||
const latitude = Number(lngLatArr[1]).toFixed(6);
|
||||
if (lngLatArr.length < 2) {
|
||||
return "";
|
||||
}
|
||||
return `${longitude},${latitude}`;
|
||||
};
|
||||
var transformLngLat = (lngLat) => {
|
||||
if (lngLat) {
|
||||
const lngLatArr = lngLat ? lngLat.split(",") : [];
|
||||
const longitude = Number(lngLatArr[0]);
|
||||
const latitude = Number(lngLatArr[1]);
|
||||
if (lngLatArr.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return { longitude, latitude };
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
fixedLngLat,
|
||||
transformLngLat
|
||||
});
|
2
packages/func/lib/math/index.d.ts
vendored
2
packages/func/lib/math/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
declare const _default: {};
|
||||
export default _default;
|
@ -1,25 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/math/index.ts
|
||||
var math_exports = {};
|
||||
__export(math_exports, {
|
||||
default: () => math_default
|
||||
});
|
||||
module.exports = __toCommonJS(math_exports);
|
||||
var math_default = {};
|
14
packages/func/lib/number/index.d.ts
vendored
14
packages/func/lib/number/index.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* 设置数据的精度
|
||||
* @param originNumber
|
||||
* @param accuracy 精度 以原点为中心向左为正,向右为负,
|
||||
* @param isCeil 是否为向上取整
|
||||
* @returns number
|
||||
*/
|
||||
export declare const setNumberAccuracy: (originNumber: number, accuracy?: number, isCeil?: boolean) => number;
|
||||
/**
|
||||
* 获取数字
|
||||
* @param number 需要校验的数值
|
||||
* @returns @number
|
||||
*/
|
||||
export declare const toRealNumber: (number: any) => any;
|
@ -1,52 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/number/index.ts
|
||||
var number_exports = {};
|
||||
__export(number_exports, {
|
||||
setNumberAccuracy: () => setNumberAccuracy,
|
||||
toRealNumber: () => toRealNumber
|
||||
});
|
||||
module.exports = __toCommonJS(number_exports);
|
||||
var setNumberAccuracy = (originNumber, accuracy = 0, isCeil = true) => {
|
||||
if (originNumber === 0) {
|
||||
return 0;
|
||||
}
|
||||
let returnData = 0;
|
||||
if (isCeil) {
|
||||
returnData = Math.ceil(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
} else {
|
||||
returnData = Math.floor(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
}
|
||||
if (accuracy < 0) {
|
||||
returnData = Number(returnData.toFixed(-accuracy));
|
||||
} else {
|
||||
returnData = Number(returnData.toFixed(0));
|
||||
}
|
||||
return returnData;
|
||||
};
|
||||
var toRealNumber = (number) => {
|
||||
if (isNaN(number) || number === Infinity) {
|
||||
return 0;
|
||||
} else return number;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
setNumberAccuracy,
|
||||
toRealNumber
|
||||
});
|
1
packages/func/lib/performance/index.d.ts
vendored
1
packages/func/lib/performance/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const speedConvert: (bps: number, contertUnit?: number) => string;
|
@ -1,40 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/performance/index.ts
|
||||
var performance_exports = {};
|
||||
__export(performance_exports, {
|
||||
speedConvert: () => speedConvert
|
||||
});
|
||||
module.exports = __toCommonJS(performance_exports);
|
||||
var speedConvert = (bps, contertUnit = 8) => {
|
||||
if (bps === void 0) return `0KB/s`;
|
||||
const byte = bps / contertUnit;
|
||||
if (bps > 1024 * 1024 * 1024) {
|
||||
return `${(byte / 1024 / 1024 / 1024).toFixed(2)}GB/s`;
|
||||
} else if (byte > 1024 * 1024) {
|
||||
return `${(byte / 1024 / 1024).toFixed(2)}MB/s`;
|
||||
} else if (byte > 1024) {
|
||||
return `${(byte / 1024).toFixed(2)}KB/s`;
|
||||
}
|
||||
return `${byte}KB/s`;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
speedConvert
|
||||
});
|
@ -1,99 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/string/index.ts
|
||||
var string_exports = {};
|
||||
__export(string_exports, {
|
||||
cutStr: () => cutStr,
|
||||
getStrLength: () => getStrLength,
|
||||
getValueByUrl: () => getValueByUrl,
|
||||
isUrl: () => isUrl,
|
||||
jumpTo: () => jumpTo,
|
||||
pxToRem: () => pxToRem
|
||||
});
|
||||
module.exports = __toCommonJS(string_exports);
|
||||
var getStrLength = function(str) {
|
||||
var realLength = 0, len = str.length, charCode = -1;
|
||||
for (var i = 0; i < len; i++) {
|
||||
charCode = str.charCodeAt(i);
|
||||
if (charCode >= 0 && charCode <= 128) realLength += 1;
|
||||
else realLength += 2;
|
||||
}
|
||||
return realLength;
|
||||
};
|
||||
var cutStr = function cutstr(str, len) {
|
||||
var str_length = 0;
|
||||
var str_len = 0;
|
||||
let str_cut = new String();
|
||||
str_len = str.length;
|
||||
for (var i = 0; i < str_len; i++) {
|
||||
let a = str.charAt(i);
|
||||
str_length++;
|
||||
if (escape(a).length > 4) {
|
||||
str_length++;
|
||||
}
|
||||
str_cut = str_cut.concat(a);
|
||||
if (str_length >= len) {
|
||||
str_cut = str_cut.concat("...");
|
||||
return str_cut;
|
||||
}
|
||||
}
|
||||
if (str_length < len) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
var isUrl = (str) => {
|
||||
try {
|
||||
new URL(str);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var getValueByUrl = (key, str) => {
|
||||
let result = null;
|
||||
if (isUrl(str)) {
|
||||
result = new URL(str).searchParams.get(key);
|
||||
} else {
|
||||
result = new URLSearchParams(str.indexOf("?") > -1 ? str : `?${str}`).get(key);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
var pxToRem = (value, rootFontSize) => {
|
||||
const fontSize = rootFontSize || 80;
|
||||
const valueArr = value.split(" ");
|
||||
return valueArr.filter((o) => o).map((val) => parseFloat(val) / fontSize + "rem").join(" ");
|
||||
};
|
||||
var jumpTo = (to) => {
|
||||
const from = location.origin + location.pathname;
|
||||
if (!isUrl(to)) {
|
||||
throw Error(`\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u94FE\u63A5\uFF0C\u4EE5http(s)://\u5F00\u5934\uFF01'`);
|
||||
}
|
||||
let _targetUrl = new URL(to);
|
||||
_targetUrl.searchParams.set("from", from);
|
||||
return _targetUrl;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
cutStr,
|
||||
getStrLength,
|
||||
getValueByUrl,
|
||||
isUrl,
|
||||
jumpTo,
|
||||
pxToRem
|
||||
});
|
11
packages/func/lib/time/index.d.ts
vendored
11
packages/func/lib/time/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export declare const formateDuration: (diff: number) => string;
|
||||
export declare function generateTime(): {
|
||||
startDateTime: number;
|
||||
endDateTime: number;
|
||||
};
|
||||
/**
|
||||
* 格式化时间为 00:00
|
||||
* @param seconds 时间,单位秒
|
||||
* @returns
|
||||
*/
|
||||
export declare function formatDurationTime(seconds: number): string;
|
@ -1,73 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/time/index.ts
|
||||
var time_exports = {};
|
||||
__export(time_exports, {
|
||||
formatDurationTime: () => formatDurationTime,
|
||||
formateDuration: () => formateDuration,
|
||||
generateTime: () => generateTime
|
||||
});
|
||||
module.exports = __toCommonJS(time_exports);
|
||||
var import_dayjs = __toESM(require("dayjs"));
|
||||
var formateDuration = (diff) => {
|
||||
var days = Math.floor(diff / (24 * 3600 * 1e3));
|
||||
var leave1 = diff % (24 * 3600 * 1e3);
|
||||
var hours = Math.floor(leave1 / (3600 * 1e3));
|
||||
var leave2 = leave1 % (3600 * 1e3);
|
||||
var minutes = Math.floor(leave2 / (60 * 1e3));
|
||||
var leave3 = leave2 % (60 * 1e3);
|
||||
var seconds = Math.round(leave3 / 1e3);
|
||||
var returnStr = seconds + "\u79D2";
|
||||
if (minutes > 0) {
|
||||
returnStr = minutes + "\u5206";
|
||||
}
|
||||
if (hours > 0) {
|
||||
returnStr = hours + "\u5C0F\u65F6";
|
||||
}
|
||||
if (days > 0) {
|
||||
returnStr = days + "\u5929";
|
||||
}
|
||||
return returnStr;
|
||||
};
|
||||
function generateTime() {
|
||||
let endDateTime = (0, import_dayjs.default)().endOf("day").unix();
|
||||
let startDateTime = (0, import_dayjs.default)().startOf("day").unix();
|
||||
return { startDateTime, endDateTime };
|
||||
}
|
||||
function formatDurationTime(seconds) {
|
||||
var minutes = Math.floor(seconds / 60) || 0;
|
||||
var remainingSeconds = Math.floor(seconds % 60);
|
||||
return (minutes < 10 ? `0${minutes}` : minutes) + ":" + (remainingSeconds < 10 ? "0" : "") + remainingSeconds;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
formatDurationTime,
|
||||
formateDuration,
|
||||
generateTime
|
||||
});
|
36
packages/func/lib/utils/index.d.ts
vendored
36
packages/func/lib/utils/index.d.ts
vendored
@ -1,36 +0,0 @@
|
||||
export { default as isChrome } from './isChrome';
|
||||
export declare const matchS3Prefix: (str: string) => boolean;
|
||||
/**
|
||||
* 通过文件名获取文件类型
|
||||
* @param fileName 文件名称
|
||||
* @returns 文件类型
|
||||
*/
|
||||
export declare const getFileSuffix: (fileName: string) => string;
|
||||
/**
|
||||
* 通过类型获取文件名
|
||||
* @param type 类型
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageSuffixByFileType: (type: string) => string;
|
||||
export declare function getChromeVersion(): number | false;
|
||||
export declare const nextTick: (func: (value: void) => void | PromiseLike<void>) => void;
|
||||
export declare const loop: (items: string | any[], callback: (arg0: any) => any) => void;
|
||||
export declare const addEventListenerWrapper: (target: any, eventType: string, cb: any, option?: any) => {
|
||||
remove: () => void;
|
||||
};
|
||||
/**
|
||||
* Get transforms base on the given object.
|
||||
* @param {Object} obj - The target object.
|
||||
* @returns {string} A string contains transform values.
|
||||
*/
|
||||
export declare function getTransforms({ rotate, scaleX, scaleY, translateX, translateY, }: {
|
||||
rotate?: number;
|
||||
scaleX?: number;
|
||||
scaleY?: number;
|
||||
translateX?: number;
|
||||
translateY?: number;
|
||||
}): {
|
||||
WebkitTransform: string;
|
||||
msTransform: string;
|
||||
transform: string;
|
||||
};
|
@ -1,170 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/utils/index.ts
|
||||
var utils_exports = {};
|
||||
__export(utils_exports, {
|
||||
addEventListenerWrapper: () => addEventListenerWrapper,
|
||||
getChromeVersion: () => getChromeVersion,
|
||||
getFileSuffix: () => getFileSuffix,
|
||||
getImageSuffixByFileType: () => getImageSuffixByFileType,
|
||||
getTransforms: () => getTransforms,
|
||||
isChrome: () => import_isChrome.default,
|
||||
loop: () => loop,
|
||||
matchS3Prefix: () => matchS3Prefix,
|
||||
nextTick: () => nextTick
|
||||
});
|
||||
module.exports = __toCommonJS(utils_exports);
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_react_dom = __toESM(require("react-dom"));
|
||||
var import_isChrome = __toESM(require("./isChrome"));
|
||||
var matchS3Prefix = (str) => {
|
||||
return /^v[0-9]_/.test(str);
|
||||
};
|
||||
var getFileSuffix = (fileName) => {
|
||||
const splitArr = fileName.split(".");
|
||||
return splitArr.length < 2 ? "" : splitArr[splitArr.length - 1];
|
||||
};
|
||||
var getImageSuffixByFileType = (type) => {
|
||||
let imageSuffix = "";
|
||||
switch (type) {
|
||||
case "jpeg": {
|
||||
imageSuffix = ".jpg";
|
||||
break;
|
||||
}
|
||||
case "gif": {
|
||||
imageSuffix = ".gif";
|
||||
break;
|
||||
}
|
||||
case "png": {
|
||||
imageSuffix = ".png";
|
||||
break;
|
||||
}
|
||||
case "vnd.wap.wbmp": {
|
||||
imageSuffix = ".wbmp";
|
||||
break;
|
||||
}
|
||||
case "x-up-wpng": {
|
||||
imageSuffix = ".wpng";
|
||||
break;
|
||||
}
|
||||
case "nbmp": {
|
||||
imageSuffix = ".nbmp";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageSuffix;
|
||||
};
|
||||
function getChromeVersion() {
|
||||
const arr = navigator.userAgent.split(" ");
|
||||
let chromeVersion = "";
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (/chrome/i.test(arr[i])) chromeVersion = arr[i];
|
||||
}
|
||||
if (chromeVersion) {
|
||||
return Number(chromeVersion.split("/")[1].split(".")[0]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var nextTick = (func) => {
|
||||
if (queueMicrotask) {
|
||||
queueMicrotask(func);
|
||||
return;
|
||||
}
|
||||
Promise.resolve().then(func);
|
||||
};
|
||||
var loop = (items, callback) => {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const element = items[i];
|
||||
let isBreak = callback(element);
|
||||
if (isBreak) {
|
||||
return;
|
||||
}
|
||||
if (element["children"]) {
|
||||
loop(element["children"], callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
var addEventListenerWrapper = (target, eventType, cb, option) => {
|
||||
const callback = import_react_dom.default.unstable_batchedUpdates ? function run(e) {
|
||||
import_react_dom.default.unstable_batchedUpdates(cb, e);
|
||||
} : cb;
|
||||
if (target.addEventListener) {
|
||||
target.addEventListener(eventType, callback, option);
|
||||
}
|
||||
return {
|
||||
remove: () => {
|
||||
if (target.removeEventListener) {
|
||||
target.removeEventListener(eventType, callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
function getTransforms({
|
||||
rotate,
|
||||
scaleX,
|
||||
scaleY,
|
||||
translateX,
|
||||
translateY
|
||||
}) {
|
||||
const values = [];
|
||||
if ((0, import_lodash_es.isNumber)(translateX) && translateX !== 0) {
|
||||
values.push(`translateX(${translateX}px)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(translateY) && translateY !== 0) {
|
||||
values.push(`translateY(${translateY}px)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(rotate) && rotate !== 0) {
|
||||
values.push(`rotate(${rotate}deg)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(scaleX) && scaleX !== 1) {
|
||||
values.push(`scaleX(${scaleX})`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(scaleY) && scaleY !== 1) {
|
||||
values.push(`scaleY(${scaleY})`);
|
||||
}
|
||||
const transform = values.length ? values.join(" ") : "none";
|
||||
return {
|
||||
WebkitTransform: transform,
|
||||
msTransform: transform,
|
||||
transform
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
addEventListenerWrapper,
|
||||
getChromeVersion,
|
||||
getFileSuffix,
|
||||
getImageSuffixByFileType,
|
||||
getTransforms,
|
||||
isChrome,
|
||||
loop,
|
||||
matchS3Prefix,
|
||||
nextTick
|
||||
});
|
3
packages/func/lib/utils/isChrome.d.ts
vendored
3
packages/func/lib/utils/isChrome.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare const isBrowser: boolean;
|
||||
declare const isChrome: () => boolean;
|
||||
export default isChrome;
|
@ -1,42 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/utils/isChrome.ts
|
||||
var isChrome_exports = {};
|
||||
__export(isChrome_exports, {
|
||||
default: () => isChrome_default,
|
||||
isBrowser: () => isBrowser
|
||||
});
|
||||
module.exports = __toCommonJS(isChrome_exports);
|
||||
var isBrowser = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
||||
var isChrome = () => {
|
||||
const winNav = isBrowser && window.navigator;
|
||||
const vendorName = winNav && (winNav == null ? void 0 : winNav.vendor);
|
||||
const userAgent = winNav && winNav.userAgent;
|
||||
const isChromium = isBrowser && typeof chrome !== "undefined";
|
||||
const isOpera = isBrowser && typeof opr !== "undefined";
|
||||
const isIEedge = userAgent && userAgent.indexOf("Edge") > -1;
|
||||
const isIOSChrome = !!(userAgent && userAgent.match("CriOS"));
|
||||
const isDesktopChrome = isChromium && vendorName === "Google Inc." && !isOpera && !isIEedge;
|
||||
return isIOSChrome || isDesktopChrome;
|
||||
};
|
||||
var isChrome_default = isChrome;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
isBrowser
|
||||
});
|
1
packages/hooks/dist/umd/hooks.min.js
vendored
1
packages/hooks/dist/umd/hooks.min.js
vendored
File diff suppressed because one or more lines are too long
9
packages/hooks/es/index.d.ts
vendored
9
packages/hooks/es/index.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export * from 'ahooks';
|
||||
export { default as useRafLoop } from './useRafLoop';
|
||||
export { default as useActivateWrapper } from './useActivateWrapper';
|
||||
export { default as useBoolLocalStorage } from './useBoolLocalStorage';
|
||||
export { default as useCustomCompareEffect } from './useCustomCompareEffect';
|
||||
export { default as useDeepEffect } from './useDeepEffect';
|
||||
export { default as useDeepMemo } from './useDeepMemo';
|
||||
export { default as useDoubleCheck } from './useDoubleCheck';
|
||||
export { default as useIMEComposition } from './useIMEComposition';
|
@ -1,9 +0,0 @@
|
||||
export * from 'ahooks';
|
||||
export { default as useRafLoop } from "./useRafLoop";
|
||||
export { default as useActivateWrapper } from "./useActivateWrapper";
|
||||
export { default as useBoolLocalStorage } from "./useBoolLocalStorage";
|
||||
export { default as useCustomCompareEffect } from "./useCustomCompareEffect";
|
||||
export { default as useDeepEffect } from "./useDeepEffect";
|
||||
export { default as useDeepMemo } from "./useDeepMemo";
|
||||
export { default as useDoubleCheck } from "./useDoubleCheck";
|
||||
export { default as useIMEComposition } from "./useIMEComposition";
|
@ -1,4 +0,0 @@
|
||||
export declare const useUnActivateWrapper: (cb: () => void) => void;
|
||||
export declare const useActivateWrapper: (cb: any) => null;
|
||||
export declare const useActivateState: () => boolean;
|
||||
export default useActivateWrapper;
|
@ -1,51 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
import { useState, useRef, useCallback } from 'react';
|
||||
import { useActivate, useUnactivate } from 'react-activation';
|
||||
// @ts-ignore
|
||||
import { noop, isFunction } from '@zhst/func';
|
||||
import { useLatest, useMount, useUnmount } from 'ahooks';
|
||||
export var useUnActivateWrapper = function useUnActivateWrapper(cb) {
|
||||
var latestCb = useLatest(cb);
|
||||
var handle = useCallback(function () {
|
||||
var cb = latestCb.current ? latestCb.current : noop;
|
||||
cb();
|
||||
}, []);
|
||||
useUnactivate(handle);
|
||||
useUnmount(handle);
|
||||
};
|
||||
export var useActivateWrapper = function useActivateWrapper(cb) {
|
||||
var latestCb = useLatest(cb);
|
||||
var retRef = useRef(noop);
|
||||
var handle = useCallback(function () {
|
||||
var cb = latestCb.current ? latestCb.current : noop;
|
||||
retRef.current = cb();
|
||||
}, []);
|
||||
var unMountHandle = useCallback(function () {
|
||||
if (isFunction(retRef.current)) {
|
||||
retRef.current();
|
||||
}
|
||||
}, []);
|
||||
useActivate(handle);
|
||||
useMount(handle);
|
||||
useUnActivateWrapper(unMountHandle);
|
||||
return null;
|
||||
};
|
||||
export var useActivateState = function useActivateState() {
|
||||
var _useState = useState(false),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
isActive = _useState2[0],
|
||||
setIsActive = _useState2[1];
|
||||
useActivateWrapper(function () {
|
||||
setIsActive(true);
|
||||
return function () {
|
||||
setIsActive(false);
|
||||
};
|
||||
});
|
||||
return isActive;
|
||||
};
|
||||
export default useActivateWrapper;
|
@ -1,3 +0,0 @@
|
||||
/// <reference types="react" />
|
||||
declare const _default: (key: string, initValue?: boolean) => [boolean, import("react").Dispatch<import("react").SetStateAction<boolean>>];
|
||||
export default _default;
|
@ -1,25 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
//@ts-nocheck
|
||||
import { useLocalStorageState } from 'ahooks';
|
||||
export default (function (key) {
|
||||
var initValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||
//弹窗显示
|
||||
var _useLocalStorageState = useLocalStorageState(key, initValue, {
|
||||
raw: false,
|
||||
serializer: function serializer(v) {
|
||||
return v ? '1' : '0';
|
||||
},
|
||||
deserializer: function deserializer(v) {
|
||||
return v === '1' ? true : false;
|
||||
}
|
||||
}),
|
||||
_useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
|
||||
v = _useLocalStorageState2[0],
|
||||
setV = _useLocalStorageState2[1];
|
||||
return [v, setV];
|
||||
});
|
@ -1,4 +0,0 @@
|
||||
import { DependencyList, EffectCallback } from 'react';
|
||||
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
||||
declare const useCustomCompareEffect: <TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>) => void;
|
||||
export default useCustomCompareEffect;
|
@ -1,21 +0,0 @@
|
||||
//@ts-nocheck
|
||||
//只是删除isPrimitive check
|
||||
|
||||
import { useEffect, useRef } from 'react';
|
||||
var useCustomCompareEffect = function useCustomCompareEffect(effect, deps, depsEqual) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!(deps instanceof Array) || !deps.length) {
|
||||
console.warn('`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
|
||||
}
|
||||
if (typeof depsEqual !== 'function') {
|
||||
console.warn('`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list');
|
||||
}
|
||||
}
|
||||
var _depsEqual = depsEqual;
|
||||
var ref = useRef(undefined);
|
||||
if (!ref.current || !_depsEqual(deps, ref.current)) {
|
||||
ref.current = deps;
|
||||
}
|
||||
useEffect(effect, ref.current);
|
||||
};
|
||||
export default useCustomCompareEffect;
|
3
packages/hooks/es/useDeepEffect/index.d.ts
vendored
3
packages/hooks/es/useDeepEffect/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import type { DependencyList, EffectCallback } from 'react';
|
||||
declare function useDeepEffect(effect: EffectCallback, deps: DependencyList): void;
|
||||
export default useDeepEffect;
|
@ -1,8 +0,0 @@
|
||||
import { isEqual } from '@zhst/func';
|
||||
import useCustomCompareEffect from "../useCustomCompareEffect";
|
||||
function useDeepEffect(effect, deps) {
|
||||
useCustomCompareEffect(effect, deps, function (pre, now) {
|
||||
return isEqual(pre, now);
|
||||
});
|
||||
}
|
||||
export default useDeepEffect;
|
2
packages/hooks/es/useDeepMemo/index.d.ts
vendored
2
packages/hooks/es/useDeepMemo/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { DependencyList } from 'react';
|
||||
export default function useDeepMemo<T>(factory: () => T, deps: DependencyList | undefined): T;
|
@ -1,21 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
//对生成的值做深比较
|
||||
import { useState, useMemo } from 'react';
|
||||
import useDeepEffect from "../useDeepEffect";
|
||||
export default function useDeepMemo(factory, deps) {
|
||||
// @ts-ignore
|
||||
var value = useMemo(factory, deps);
|
||||
var _useState = useState(value),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
state = _useState2[0],
|
||||
setState = _useState2[1];
|
||||
useDeepEffect(function () {
|
||||
setState(value);
|
||||
}, [value]);
|
||||
return state;
|
||||
}
|
3
packages/hooks/es/useDoubleCheck/index.d.ts
vendored
3
packages/hooks/es/useDoubleCheck/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Options } from 'ahooks/lib/createUseStorageState';
|
||||
export declare const isShowDoubleCheck: (key: string) => boolean;
|
||||
export default function useDoubleCheck(key: string, initialState: Options<unknown> | undefined): unknown[];
|
@ -1,19 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
import { useLocalStorageState } from 'ahooks';
|
||||
export var isShowDoubleCheck = function isShowDoubleCheck(key) {
|
||||
var v = localStorage.getItem(key);
|
||||
return v === '1' ? true : false;
|
||||
};
|
||||
export default function useDoubleCheck(key, initialState) {
|
||||
//是否关闭二次提示
|
||||
var _useLocalStorageState = useLocalStorageState(key, initialState),
|
||||
_useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
|
||||
value = _useLocalStorageState2[0],
|
||||
setValue = _useLocalStorageState2[1];
|
||||
return [value, setValue];
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
import { type CompositionEventHandler } from 'react';
|
||||
import type { IUseIMECompositionResult } from './interface';
|
||||
export default function useIMEComposition<OnChange extends (...args: any[]) => any>(propValue: string, onChangeProp?: OnChange, getEventValueProp?: (...args: any[]) => string, onCompositionStartProp?: CompositionEventHandler, onCompositionEndProp?: CompositionEventHandler): IUseIMECompositionResult<OnChange>;
|
@ -1,71 +0,0 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
//@ts-nocheck
|
||||
import { useState, useRef, useCallback } from 'react';
|
||||
import { isChrome } from '@zhst/func';
|
||||
var EMIT_CHANGE_AFTER_COMPOSITION_END = isChrome();
|
||||
var defaultGetEventValue = function defaultGetEventValue(e) {
|
||||
return e.target.value;
|
||||
};
|
||||
export default function useIMEComposition(propValue, onChangeProp, getEventValueProp, onCompositionStartProp, onCompositionEndProp) {
|
||||
var getEventValue = getEventValueProp || defaultGetEventValue;
|
||||
var isCompositionRef = useRef(false);
|
||||
var _useState = useState(propValue),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
compositionValue = _useState2[0],
|
||||
setCompositionValue = _useState2[1];
|
||||
var compositionValueRef = useRef(compositionValue);
|
||||
var onChangeRef = useRef(onChangeProp);
|
||||
var onCompositionStartRef = useRef(onCompositionStartProp);
|
||||
var onCompositionEndRef = useRef(onCompositionEndProp);
|
||||
compositionValueRef.current = compositionValue;
|
||||
onChangeRef.current = onChangeProp;
|
||||
onCompositionStartRef.current = onCompositionStartProp;
|
||||
onCompositionEndRef.current = onCompositionEndProp;
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
var onCompositionValueChange = useCallback(function () {
|
||||
var _onChangeRef$current;
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
if (isCompositionRef.current) {
|
||||
setCompositionValue(getEventValue.apply(void 0, args));
|
||||
// 若输入法正在输入,则不触发上层组件的事件
|
||||
return;
|
||||
}
|
||||
return (_onChangeRef$current = onChangeRef.current) === null || _onChangeRef$current === void 0 ? void 0 : _onChangeRef$current.call.apply(_onChangeRef$current, [onChangeRef].concat(args));
|
||||
}, [onChangeRef]);
|
||||
var onCompositionStart = useCallback(function (e) {
|
||||
var _onCompositionStartRe;
|
||||
isCompositionRef.current = true;
|
||||
(_onCompositionStartRe = onCompositionStartRef.current) === null || _onCompositionStartRe === void 0 || _onCompositionStartRe.call(onCompositionStartRef, e);
|
||||
}, [onCompositionStartRef]);
|
||||
var onCompositionEnd = useCallback(function (e) {
|
||||
var _onCompositionEndRef$;
|
||||
isCompositionRef.current = false;
|
||||
(_onCompositionEndRef$ = onCompositionEndRef.current) === null || _onCompositionEndRef$ === void 0 || _onCompositionEndRef$.call(onCompositionEndRef, e);
|
||||
// chrome 的 onCompositionEnd 事件在 onChange 后触发,需要在 onCompositionEnd 后额外触发一次 onChange 事件
|
||||
if (EMIT_CHANGE_AFTER_COMPOSITION_END) {
|
||||
var _onChangeRef$current2;
|
||||
e.type = 'change';
|
||||
//todo: 此处优化
|
||||
(_onChangeRef$current2 = onChangeRef.current) === null || _onChangeRef$current2 === void 0 || _onChangeRef$current2.call(onChangeRef, compositionValueRef.current, e);
|
||||
}
|
||||
}, [onCompositionEndRef, onChangeRef]);
|
||||
|
||||
// 只处理受控的组件
|
||||
var isControlled = propValue !== undefined;
|
||||
var passCompositionHandler = isControlled;
|
||||
var passCompositionValue = isControlled && isCompositionRef.current;
|
||||
return {
|
||||
value: passCompositionValue ? compositionValue : propValue,
|
||||
onChange: passCompositionHandler ? onCompositionValueChange : onChangeProp,
|
||||
onCompositionStart: passCompositionHandler ? onCompositionStart : onCompositionStartProp,
|
||||
onCompositionEnd: passCompositionHandler ? onCompositionEnd : onCompositionEndProp
|
||||
};
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
/// <reference types="react" />
|
||||
export interface IUseIMECompositionResult<OnChange> {
|
||||
value: string;
|
||||
onChange: OnChange;
|
||||
getEventValue?: (...args: any[]) => string;
|
||||
onCompositionStart: React.CompositionEventHandler;
|
||||
onCompositionEnd: React.CompositionEventHandler;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export {};
|
@ -1,2 +0,0 @@
|
||||
declare const _default: boolean;
|
||||
export default _default;
|
@ -1,2 +0,0 @@
|
||||
//@ts-nocheck
|
||||
export default !!(typeof window !== 'undefined' && window);
|
@ -1,2 +0,0 @@
|
||||
declare const isChrome: boolean;
|
||||
export default isChrome;
|
@ -1,16 +0,0 @@
|
||||
//@ts-nocheck
|
||||
import isBrowser from "./isBrowser";
|
||||
var winNav = isBrowser && window.navigator;
|
||||
var vendorName = winNav && winNav.vendor;
|
||||
var userAgent = winNav && winNav.userAgent;
|
||||
|
||||
//@ts-ignore
|
||||
var isChromium = isBrowser && typeof chrome !== 'undefined';
|
||||
|
||||
//@ts-ignore
|
||||
var isOpera = isBrowser && typeof opr !== 'undefined';
|
||||
var isIEedge = userAgent && userAgent.indexOf('Edge') > -1;
|
||||
var isIOSChrome = !!(userAgent && userAgent.match('CriOS'));
|
||||
var isDesktopChrome = isChromium && vendorName === 'Google Inc.' && !isOpera && !isIEedge;
|
||||
var isChrome = isIOSChrome || isDesktopChrome;
|
||||
export default isChrome;
|
20
packages/hooks/es/useJump/constants.d.ts
vendored
20
packages/hooks/es/useJump/constants.d.ts
vendored
@ -1,20 +0,0 @@
|
||||
export declare const JumpKey = "ROUTER-JUMP";
|
||||
export declare const TYPE: {
|
||||
OFFLINE: number;
|
||||
HISTORY: number;
|
||||
OFFLINE_JUMP: number;
|
||||
HISTORY_JUMP: number;
|
||||
MONITOR_DETAIL_JUMP: number;
|
||||
VIDEOGROUP: number;
|
||||
VIDEOGROUP_JUMP: number;
|
||||
UNKNOW_JUMP: number;
|
||||
MONITOR_MAP_JUMP: number;
|
||||
SEARCH: number;
|
||||
CURRENT_SEARCH: number;
|
||||
TAG_CAMERA: number;
|
||||
TRACK_IMAGE: number;
|
||||
TRACK_CAMERA: number;
|
||||
PEER_ANALYSIS: number;
|
||||
BASELINE_TASKS: number;
|
||||
JOINTASK: number;
|
||||
};
|
@ -1,30 +0,0 @@
|
||||
export var JumpKey = 'ROUTER-JUMP';
|
||||
export var TYPE = {
|
||||
OFFLINE: 1,
|
||||
HISTORY: 2,
|
||||
OFFLINE_JUMP: 3,
|
||||
HISTORY_JUMP: 4,
|
||||
MONITOR_DETAIL_JUMP: 5,
|
||||
VIDEOGROUP: 6,
|
||||
//跳到回溯
|
||||
VIDEOGROUP_JUMP: 7,
|
||||
UNKNOW_JUMP: 8,
|
||||
//未实现
|
||||
MONITOR_MAP_JUMP: 9,
|
||||
SEARCH: 10,
|
||||
//检索界面
|
||||
CURRENT_SEARCH: 11,
|
||||
//
|
||||
TAG_CAMERA: 12,
|
||||
//预案
|
||||
//智能追踪两种方式
|
||||
TRACK_IMAGE: 13,
|
||||
//跳到追踪上传图片
|
||||
TRACK_CAMERA: 14,
|
||||
//跳到追踪选择摄像头
|
||||
PEER_ANALYSIS: 15,
|
||||
//同行人分析
|
||||
BASELINE_TASKS: 16,
|
||||
//线索摸排
|
||||
JOINTASK: 17 //路人库任务
|
||||
};
|
7
packages/hooks/es/useJump/index.d.ts
vendored
7
packages/hooks/es/useJump/index.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import type { JumpType } from './interface';
|
||||
declare const useJump: () => (path: string, data: {
|
||||
[index: string]: any;
|
||||
__key__: JumpType;
|
||||
}) => void;
|
||||
export declare const useListenJump: (handle: (data: any) => void, type: JumpType | JumpType[]) => void;
|
||||
export default useJump;
|
@ -1,67 +0,0 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import { useLatest } from 'ahooks';
|
||||
import events from 'events';
|
||||
import { get, isArray } from '@zhst/func';
|
||||
import { useEffect } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { JumpKey } from "./constants";
|
||||
var emitter = new events.EventEmitter();
|
||||
var useJump = function useJump() {
|
||||
var location = useLocation();
|
||||
var navigate = useNavigate();
|
||||
var jump = function jump(path, data) {
|
||||
if (location.pathname !== path) {
|
||||
navigate(path, {
|
||||
state: {
|
||||
data: data,
|
||||
topic: JumpKey,
|
||||
__from__: location.pathname
|
||||
}
|
||||
});
|
||||
} else {
|
||||
emitter.emit(JumpKey, data);
|
||||
}
|
||||
};
|
||||
return jump;
|
||||
};
|
||||
export var useListenJump = function useListenJump(handle, type) {
|
||||
var latestHandle = useLatest(handle);
|
||||
var navigate = useNavigate();
|
||||
var _type = isArray(type) ? type : [type];
|
||||
var location = useLocation();
|
||||
useEffect(function () {
|
||||
var state = location.state,
|
||||
pathname = location.pathname,
|
||||
search = location.search;
|
||||
if (state) {
|
||||
var topic = state.topic,
|
||||
_data = state.data,
|
||||
__from__ = state.__from__;
|
||||
if (topic === JumpKey && _type.includes(get(_data, '__key__'))) {
|
||||
latestHandle.current(_objectSpread(_objectSpread({}, _data), {}, {
|
||||
__from__: __from__
|
||||
}));
|
||||
}
|
||||
navigate("/".concat(pathname).concat(search), {
|
||||
state: null
|
||||
});
|
||||
}
|
||||
}, [location]);
|
||||
useEffect(function () {
|
||||
var handleEmit = function handleEmit(data) {
|
||||
if (_type.includes(get(data, '__key__'))) {
|
||||
latestHandle.current(data);
|
||||
}
|
||||
};
|
||||
emitter.on(JumpKey, handleEmit);
|
||||
return function () {
|
||||
emitter.removeListener(JumpKey, handleEmit);
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
export default useJump;
|
1
packages/hooks/es/useJump/interface.d.ts
vendored
1
packages/hooks/es/useJump/interface.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare type JumpType = 'warningRecord' | 'targetSearch' | 'passerby' | 'targetDetail' | 'traceAnalysis' | 'offlineAnalysis';
|
@ -1 +0,0 @@
|
||||
export {};
|
2
packages/hooks/es/useRafLoop.d.ts
vendored
2
packages/hooks/es/useRafLoop.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export declare type RafLoopReturns = [() => void, () => void, () => boolean];
|
||||
export default function useRafLoop(callback: FrameRequestCallback, initiallyActive?: boolean): RafLoopReturns;
|
@ -1,40 +0,0 @@
|
||||
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
export default function useRafLoop(callback) {
|
||||
var initiallyActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||
var raf = useRef(null);
|
||||
var rafActivity = useRef(false);
|
||||
var rafCallback = useRef(callback);
|
||||
rafCallback.current = callback;
|
||||
var step = useCallback(function (time) {
|
||||
if (rafActivity.current) {
|
||||
rafCallback.current(time);
|
||||
raf.current = requestAnimationFrame(step);
|
||||
}
|
||||
}, []);
|
||||
var result = useMemo(function () {
|
||||
return [function () {
|
||||
// stop
|
||||
if (rafActivity.current) {
|
||||
rafActivity.current = false;
|
||||
// @ts-ignore
|
||||
raf.current && cancelAnimationFrame(raf.current);
|
||||
}
|
||||
}, function () {
|
||||
// start
|
||||
if (!rafActivity.current) {
|
||||
rafActivity.current = true;
|
||||
raf.current = requestAnimationFrame(step);
|
||||
}
|
||||
}, function () {
|
||||
return rafActivity.current;
|
||||
} // isActive
|
||||
];
|
||||
}, []);
|
||||
useEffect(function () {
|
||||
if (initiallyActive) {
|
||||
result[1]();
|
||||
}
|
||||
return result[0];
|
||||
}, []);
|
||||
return result;
|
||||
}
|
0
packages/hooks/es/useSocket/index.d.ts
vendored
0
packages/hooks/es/useSocket/index.d.ts
vendored
9
packages/hooks/lib/index.d.ts
vendored
9
packages/hooks/lib/index.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export * from 'ahooks';
|
||||
export { default as useRafLoop } from './useRafLoop';
|
||||
export { default as useActivateWrapper } from './useActivateWrapper';
|
||||
export { default as useBoolLocalStorage } from './useBoolLocalStorage';
|
||||
export { default as useCustomCompareEffect } from './useCustomCompareEffect';
|
||||
export { default as useDeepEffect } from './useDeepEffect';
|
||||
export { default as useDeepMemo } from './useDeepMemo';
|
||||
export { default as useDoubleCheck } from './useDoubleCheck';
|
||||
export { default as useIMEComposition } from './useIMEComposition';
|
@ -1,63 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.tsx
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
useActivateWrapper: () => import_useActivateWrapper.default,
|
||||
useBoolLocalStorage: () => import_useBoolLocalStorage.default,
|
||||
useCustomCompareEffect: () => import_useCustomCompareEffect.default,
|
||||
useDeepEffect: () => import_useDeepEffect.default,
|
||||
useDeepMemo: () => import_useDeepMemo.default,
|
||||
useDoubleCheck: () => import_useDoubleCheck.default,
|
||||
useIMEComposition: () => import_useIMEComposition.default,
|
||||
useRafLoop: () => import_useRafLoop.default
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
__reExport(src_exports, require("ahooks"), module.exports);
|
||||
var import_useRafLoop = __toESM(require("./useRafLoop"));
|
||||
var import_useActivateWrapper = __toESM(require("./useActivateWrapper"));
|
||||
var import_useBoolLocalStorage = __toESM(require("./useBoolLocalStorage"));
|
||||
var import_useCustomCompareEffect = __toESM(require("./useCustomCompareEffect"));
|
||||
var import_useDeepEffect = __toESM(require("./useDeepEffect"));
|
||||
var import_useDeepMemo = __toESM(require("./useDeepMemo"));
|
||||
var import_useDoubleCheck = __toESM(require("./useDoubleCheck"));
|
||||
var import_useIMEComposition = __toESM(require("./useIMEComposition"));
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
useActivateWrapper,
|
||||
useBoolLocalStorage,
|
||||
useCustomCompareEffect,
|
||||
useDeepEffect,
|
||||
useDeepMemo,
|
||||
useDoubleCheck,
|
||||
useIMEComposition,
|
||||
useRafLoop,
|
||||
...require("ahooks")
|
||||
});
|
@ -1,4 +0,0 @@
|
||||
export declare const useUnActivateWrapper: (cb: () => void) => void;
|
||||
export declare const useActivateWrapper: (cb: any) => null;
|
||||
export declare const useActivateState: () => boolean;
|
||||
export default useActivateWrapper;
|
@ -1,74 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useActivateWrapper/index.tsx
|
||||
var useActivateWrapper_exports = {};
|
||||
__export(useActivateWrapper_exports, {
|
||||
default: () => useActivateWrapper_default,
|
||||
useActivateState: () => useActivateState,
|
||||
useActivateWrapper: () => useActivateWrapper,
|
||||
useUnActivateWrapper: () => useUnActivateWrapper
|
||||
});
|
||||
module.exports = __toCommonJS(useActivateWrapper_exports);
|
||||
var import_react = require("react");
|
||||
var import_react_activation = require("react-activation");
|
||||
var import_func = require("@zhst/func");
|
||||
var import_ahooks = require("ahooks");
|
||||
var useUnActivateWrapper = (cb) => {
|
||||
const latestCb = (0, import_ahooks.useLatest)(cb);
|
||||
const handle = (0, import_react.useCallback)(() => {
|
||||
const cb2 = latestCb.current ? latestCb.current : import_func.noop;
|
||||
cb2();
|
||||
}, []);
|
||||
(0, import_react_activation.useUnactivate)(handle);
|
||||
(0, import_ahooks.useUnmount)(handle);
|
||||
};
|
||||
var useActivateWrapper = (cb) => {
|
||||
const latestCb = (0, import_ahooks.useLatest)(cb);
|
||||
let retRef = (0, import_react.useRef)(import_func.noop);
|
||||
const handle = (0, import_react.useCallback)(() => {
|
||||
const cb2 = latestCb.current ? latestCb.current : import_func.noop;
|
||||
retRef.current = cb2();
|
||||
}, []);
|
||||
const unMountHandle = (0, import_react.useCallback)(() => {
|
||||
if ((0, import_func.isFunction)(retRef.current)) {
|
||||
retRef.current();
|
||||
}
|
||||
}, []);
|
||||
(0, import_react_activation.useActivate)(handle);
|
||||
(0, import_ahooks.useMount)(handle);
|
||||
useUnActivateWrapper(unMountHandle);
|
||||
return null;
|
||||
};
|
||||
var useActivateState = () => {
|
||||
const [isActive, setIsActive] = (0, import_react.useState)(false);
|
||||
useActivateWrapper(() => {
|
||||
setIsActive(true);
|
||||
return () => {
|
||||
setIsActive(false);
|
||||
};
|
||||
});
|
||||
return isActive;
|
||||
};
|
||||
var useActivateWrapper_default = useActivateWrapper;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
useActivateState,
|
||||
useActivateWrapper,
|
||||
useUnActivateWrapper
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
/// <reference types="react" />
|
||||
declare const _default: (key: string, initValue?: boolean) => [boolean, import("react").Dispatch<import("react").SetStateAction<boolean>>];
|
||||
export default _default;
|
@ -1,33 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useBoolLocalStorage/index.tsx
|
||||
var useBoolLocalStorage_exports = {};
|
||||
__export(useBoolLocalStorage_exports, {
|
||||
default: () => useBoolLocalStorage_default
|
||||
});
|
||||
module.exports = __toCommonJS(useBoolLocalStorage_exports);
|
||||
var import_ahooks = require("ahooks");
|
||||
var useBoolLocalStorage_default = (key, initValue = true) => {
|
||||
const [v, setV] = (0, import_ahooks.useLocalStorageState)(key, initValue, {
|
||||
raw: false,
|
||||
serializer: (v2) => v2 ? "1" : "0",
|
||||
deserializer: (v2) => v2 === "1" ? true : false
|
||||
});
|
||||
return [v, setV];
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
import { DependencyList, EffectCallback } from 'react';
|
||||
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
||||
declare const useCustomCompareEffect: <TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>) => void;
|
||||
export default useCustomCompareEffect;
|
@ -1,46 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useCustomCompareEffect/index.tsx
|
||||
var useCustomCompareEffect_exports = {};
|
||||
__export(useCustomCompareEffect_exports, {
|
||||
default: () => useCustomCompareEffect_default
|
||||
});
|
||||
module.exports = __toCommonJS(useCustomCompareEffect_exports);
|
||||
var import_react = require("react");
|
||||
var useCustomCompareEffect = (effect, deps, depsEqual) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (!(deps instanceof Array) || !deps.length) {
|
||||
console.warn(
|
||||
"`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead."
|
||||
);
|
||||
}
|
||||
if (typeof depsEqual !== "function") {
|
||||
console.warn(
|
||||
"`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list"
|
||||
);
|
||||
}
|
||||
}
|
||||
let _depsEqual = depsEqual;
|
||||
const ref = (0, import_react.useRef)(void 0);
|
||||
if (!ref.current || !_depsEqual(deps, ref.current)) {
|
||||
ref.current = deps;
|
||||
}
|
||||
(0, import_react.useEffect)(effect, ref.current);
|
||||
};
|
||||
var useCustomCompareEffect_default = useCustomCompareEffect;
|
3
packages/hooks/lib/useDeepEffect/index.d.ts
vendored
3
packages/hooks/lib/useDeepEffect/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import type { DependencyList, EffectCallback } from 'react';
|
||||
declare function useDeepEffect(effect: EffectCallback, deps: DependencyList): void;
|
||||
export default useDeepEffect;
|
@ -1,42 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useDeepEffect/index.tsx
|
||||
var useDeepEffect_exports = {};
|
||||
__export(useDeepEffect_exports, {
|
||||
default: () => useDeepEffect_default
|
||||
});
|
||||
module.exports = __toCommonJS(useDeepEffect_exports);
|
||||
var import_func = require("@zhst/func");
|
||||
var import_useCustomCompareEffect = __toESM(require("../useCustomCompareEffect"));
|
||||
function useDeepEffect(effect, deps) {
|
||||
(0, import_useCustomCompareEffect.default)(effect, deps, (pre, now) => {
|
||||
return (0, import_func.isEqual)(pre, now);
|
||||
});
|
||||
}
|
||||
var useDeepEffect_default = useDeepEffect;
|
2
packages/hooks/lib/useDeepMemo/index.d.ts
vendored
2
packages/hooks/lib/useDeepMemo/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { DependencyList } from 'react';
|
||||
export default function useDeepMemo<T>(factory: () => T, deps: DependencyList | undefined): T;
|
@ -1,44 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useDeepMemo/index.ts
|
||||
var useDeepMemo_exports = {};
|
||||
__export(useDeepMemo_exports, {
|
||||
default: () => useDeepMemo
|
||||
});
|
||||
module.exports = __toCommonJS(useDeepMemo_exports);
|
||||
var import_react = require("react");
|
||||
var import_useDeepEffect = __toESM(require("../useDeepEffect"));
|
||||
function useDeepMemo(factory, deps) {
|
||||
const value = (0, import_react.useMemo)(factory, deps);
|
||||
const [state, setState] = (0, import_react.useState)(value);
|
||||
(0, import_useDeepEffect.default)(() => {
|
||||
setState(value);
|
||||
}, [value]);
|
||||
return state;
|
||||
}
|
3
packages/hooks/lib/useDoubleCheck/index.d.ts
vendored
3
packages/hooks/lib/useDoubleCheck/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Options } from 'ahooks/lib/createUseStorageState';
|
||||
export declare const isShowDoubleCheck: (key: string) => boolean;
|
||||
export default function useDoubleCheck(key: string, initialState: Options<unknown> | undefined): unknown[];
|
@ -1,38 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/useDoubleCheck/index.tsx
|
||||
var useDoubleCheck_exports = {};
|
||||
__export(useDoubleCheck_exports, {
|
||||
default: () => useDoubleCheck,
|
||||
isShowDoubleCheck: () => isShowDoubleCheck
|
||||
});
|
||||
module.exports = __toCommonJS(useDoubleCheck_exports);
|
||||
var import_ahooks = require("ahooks");
|
||||
var isShowDoubleCheck = (key) => {
|
||||
const v = localStorage.getItem(key);
|
||||
return v === "1" ? true : false;
|
||||
};
|
||||
function useDoubleCheck(key, initialState) {
|
||||
const [value, setValue] = (0, import_ahooks.useLocalStorageState)(key, initialState);
|
||||
return [value, setValue];
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
isShowDoubleCheck
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user