@zero-library/common 2.0.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +23 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +16 -14
- package/dist/index.d.ts +16 -14
- package/dist/index.esm.js +22 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -137,19 +137,6 @@ interface Props {
|
|
|
137
137
|
}
|
|
138
138
|
declare const _default$1: ({ size, avatarSrc, userName }: Props) => react_jsx_runtime.JSX.Element;
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
* 通用的 Valtio Context 工厂
|
|
142
|
-
* 支持:
|
|
143
|
-
* - useStore() 获取 store 实例
|
|
144
|
-
*/
|
|
145
|
-
declare function createValtioContext<T extends object>(): {
|
|
146
|
-
ValtioProvider: ({ store, children }: {
|
|
147
|
-
store: T;
|
|
148
|
-
children?: ReactNode;
|
|
149
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
150
|
-
useValtioStore: () => T;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
140
|
type Params = Record<string, any>;
|
|
154
141
|
/**
|
|
155
142
|
* 通知当前页面的父页面或者顶级窗口
|
|
@@ -166,6 +153,19 @@ declare function useIframeRelayBridge(allowedOrigins?: string[]): {
|
|
|
166
153
|
off: (type: string, handler: Handler<Params>) => void;
|
|
167
154
|
};
|
|
168
155
|
|
|
156
|
+
/**
|
|
157
|
+
* 通用的 Valtio Context 工厂
|
|
158
|
+
* 支持:
|
|
159
|
+
* - useStore() 获取 store 实例
|
|
160
|
+
*/
|
|
161
|
+
declare function useCreateValtioContext<T extends object>(): {
|
|
162
|
+
ValtioProvider: ({ store, children }: {
|
|
163
|
+
store: T;
|
|
164
|
+
children?: ReactNode;
|
|
165
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
166
|
+
useValtioStore: () => T;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
169
|
/**
|
|
170
170
|
* 防抖hook
|
|
171
171
|
* @param func 需要执行的函数
|
|
@@ -242,6 +242,7 @@ declare const copyText: (text: string) => Promise<void>;
|
|
|
242
242
|
declare function formatNumberWithCommas(number: number | string): string | number;
|
|
243
243
|
declare const generateRandomNumbers: (min: number, max: number, count: number) => number[];
|
|
244
244
|
declare const getFileName: (filePath: string) => string;
|
|
245
|
+
declare const getFileSuffixName: (fileName: string) => string;
|
|
245
246
|
declare const textAreaView: (con?: string) => string;
|
|
246
247
|
/**
|
|
247
248
|
* 将对象转换为 URL 查询参数字符串
|
|
@@ -311,6 +312,7 @@ declare const isClient: boolean;
|
|
|
311
312
|
*/
|
|
312
313
|
declare const isExternal: (path: string) => boolean;
|
|
313
314
|
declare const isBlob: (val: unknown) => boolean;
|
|
315
|
+
declare const isLocalhost: (host?: string) => boolean;
|
|
314
316
|
|
|
315
317
|
interface UserInfo {
|
|
316
318
|
id: number;
|
|
@@ -380,4 +382,4 @@ declare function getSignPath(): string;
|
|
|
380
382
|
declare const LgPrimaryColor: string;
|
|
381
383
|
declare const themeConfig: ThemeConfig;
|
|
382
384
|
|
|
383
|
-
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, type UserInfo, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText,
|
|
385
|
+
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, type UserInfo, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
package/dist/index.d.ts
CHANGED
|
@@ -137,19 +137,6 @@ interface Props {
|
|
|
137
137
|
}
|
|
138
138
|
declare const _default$1: ({ size, avatarSrc, userName }: Props) => react_jsx_runtime.JSX.Element;
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
* 通用的 Valtio Context 工厂
|
|
142
|
-
* 支持:
|
|
143
|
-
* - useStore() 获取 store 实例
|
|
144
|
-
*/
|
|
145
|
-
declare function createValtioContext<T extends object>(): {
|
|
146
|
-
ValtioProvider: ({ store, children }: {
|
|
147
|
-
store: T;
|
|
148
|
-
children?: ReactNode;
|
|
149
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
150
|
-
useValtioStore: () => T;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
140
|
type Params = Record<string, any>;
|
|
154
141
|
/**
|
|
155
142
|
* 通知当前页面的父页面或者顶级窗口
|
|
@@ -166,6 +153,19 @@ declare function useIframeRelayBridge(allowedOrigins?: string[]): {
|
|
|
166
153
|
off: (type: string, handler: Handler<Params>) => void;
|
|
167
154
|
};
|
|
168
155
|
|
|
156
|
+
/**
|
|
157
|
+
* 通用的 Valtio Context 工厂
|
|
158
|
+
* 支持:
|
|
159
|
+
* - useStore() 获取 store 实例
|
|
160
|
+
*/
|
|
161
|
+
declare function useCreateValtioContext<T extends object>(): {
|
|
162
|
+
ValtioProvider: ({ store, children }: {
|
|
163
|
+
store: T;
|
|
164
|
+
children?: ReactNode;
|
|
165
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
166
|
+
useValtioStore: () => T;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
169
|
/**
|
|
170
170
|
* 防抖hook
|
|
171
171
|
* @param func 需要执行的函数
|
|
@@ -242,6 +242,7 @@ declare const copyText: (text: string) => Promise<void>;
|
|
|
242
242
|
declare function formatNumberWithCommas(number: number | string): string | number;
|
|
243
243
|
declare const generateRandomNumbers: (min: number, max: number, count: number) => number[];
|
|
244
244
|
declare const getFileName: (filePath: string) => string;
|
|
245
|
+
declare const getFileSuffixName: (fileName: string) => string;
|
|
245
246
|
declare const textAreaView: (con?: string) => string;
|
|
246
247
|
/**
|
|
247
248
|
* 将对象转换为 URL 查询参数字符串
|
|
@@ -311,6 +312,7 @@ declare const isClient: boolean;
|
|
|
311
312
|
*/
|
|
312
313
|
declare const isExternal: (path: string) => boolean;
|
|
313
314
|
declare const isBlob: (val: unknown) => boolean;
|
|
315
|
+
declare const isLocalhost: (host?: string) => boolean;
|
|
314
316
|
|
|
315
317
|
interface UserInfo {
|
|
316
318
|
id: number;
|
|
@@ -380,4 +382,4 @@ declare function getSignPath(): string;
|
|
|
380
382
|
declare const LgPrimaryColor: string;
|
|
381
383
|
declare const themeConfig: ThemeConfig;
|
|
382
384
|
|
|
383
|
-
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, type UserInfo, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText,
|
|
385
|
+
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, type UserInfo, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined } from '@ant-design/icons';
|
|
3
3
|
import * as React16 from 'react';
|
|
4
|
-
import { forwardRef, useState, useMemo, useEffect, lazy, Suspense,
|
|
4
|
+
import { forwardRef, useState, useMemo, useEffect, lazy, Suspense, useRef, createContext, useCallback, useContext } from 'react';
|
|
5
5
|
import { Spin, notification, Modal, Result, Splitter, Empty, Image, Flex, Drawer, Tag, Avatar, Alert, Form, Input, Button } from 'antd';
|
|
6
6
|
import parse from 'html-react-parser';
|
|
7
7
|
import { jsonrepair } from 'jsonrepair';
|
|
@@ -314,20 +314,6 @@ var MarkdownPreview_default = ({ fileUrl, searchValue }) => {
|
|
|
314
314
|
}, [fileUrl]);
|
|
315
315
|
return error ? /* @__PURE__ */ jsx(Result, { status: "error", title: error }) : /* @__PURE__ */ jsx("div", { className: "height-full", children: /* @__PURE__ */ jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
316
316
|
};
|
|
317
|
-
function createValtioContext() {
|
|
318
|
-
const Context = createContext(null);
|
|
319
|
-
const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsx(Context.Provider, { value: store, children });
|
|
320
|
-
const useValtioStore = () => {
|
|
321
|
-
const store = useContext(Context);
|
|
322
|
-
if (!store) throw new Error("useStore must be used within Provider");
|
|
323
|
-
return store;
|
|
324
|
-
};
|
|
325
|
-
return {
|
|
326
|
-
ValtioProvider,
|
|
327
|
-
useValtioStore
|
|
328
|
-
// Context
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
317
|
|
|
332
318
|
// src/hooks/iframe/iframeRelay.ts
|
|
333
319
|
function emit(type, data, to = "top") {
|
|
@@ -433,6 +419,9 @@ var isExternal = (path) => {
|
|
|
433
419
|
var isBlob = (val) => {
|
|
434
420
|
return is(val, "Blob");
|
|
435
421
|
};
|
|
422
|
+
var isLocalhost = (host) => {
|
|
423
|
+
return /^(localhost:)/.test(host || location.host);
|
|
424
|
+
};
|
|
436
425
|
|
|
437
426
|
// src/hooks/iframe/useIframeRelayBridge.ts
|
|
438
427
|
function useIframeRelayBridge(allowedOrigins = ["*"]) {
|
|
@@ -463,6 +452,20 @@ function useIframeRelayBridge(allowedOrigins = ["*"]) {
|
|
|
463
452
|
}
|
|
464
453
|
return { on, off };
|
|
465
454
|
}
|
|
455
|
+
function useCreateValtioContext() {
|
|
456
|
+
const Context = createContext(null);
|
|
457
|
+
const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsx(Context.Provider, { value: store, children });
|
|
458
|
+
const useValtioStore = () => {
|
|
459
|
+
const store = useContext(Context);
|
|
460
|
+
if (!store) throw new Error("useStore must be used within Provider");
|
|
461
|
+
return store;
|
|
462
|
+
};
|
|
463
|
+
return {
|
|
464
|
+
ValtioProvider,
|
|
465
|
+
useValtioStore
|
|
466
|
+
// Context
|
|
467
|
+
};
|
|
468
|
+
}
|
|
466
469
|
function useDebounce(func, wait = 400) {
|
|
467
470
|
const { current } = useRef({ func, timeOut: null });
|
|
468
471
|
useEffect(() => {
|
|
@@ -640,6 +643,9 @@ var generateRandomNumbers = (min, max, count) => {
|
|
|
640
643
|
var getFileName = (filePath) => {
|
|
641
644
|
return filePath.split("?")[0].split("/").pop() || "";
|
|
642
645
|
};
|
|
646
|
+
var getFileSuffixName = (fileName) => {
|
|
647
|
+
return fileName.split(".").pop() || "";
|
|
648
|
+
};
|
|
643
649
|
var textAreaView = (con) => {
|
|
644
650
|
return con ? con.replace(/\r\n/g, "\n").replace(/\n/g, "<br/>") : "";
|
|
645
651
|
};
|
|
@@ -5215,6 +5221,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
|
5215
5221
|
return avatarSrc ? /* @__PURE__ */ jsx(Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsx(Avatar, { size, className: "cursor-pointer", style: { backgroundColor: LgPrimaryColor }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
5216
5222
|
};
|
|
5217
5223
|
|
|
5218
|
-
export { AudioPlayer_default as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, ILLEGAL_PARAMETER, Iframe_default as Iframe, LazyComponent_default as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, NOT_FOUND, OK, OK2, PERMISSION_DENIED, PdfPreview_default as PdfPreview, RenderMarkdown_default as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText,
|
|
5224
|
+
export { AudioPlayer_default as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, ILLEGAL_PARAMETER, Iframe_default as Iframe, LazyComponent_default as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, NOT_FOUND, OK, OK2, PERMISSION_DENIED, PdfPreview_default as PdfPreview, RenderMarkdown_default as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, request_default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket_default as useWebSocket };
|
|
5219
5225
|
//# sourceMappingURL=index.esm.js.map
|
|
5220
5226
|
//# sourceMappingURL=index.esm.js.map
|