@zero-library/common 2.0.9 → 2.1.1

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 CHANGED
@@ -352,20 +352,6 @@ var MarkdownPreview_default = ({ fileUrl, searchValue }) => {
352
352
  }, [fileUrl]);
353
353
  return error ? /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "error", title: error }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full", children: /* @__PURE__ */ jsxRuntime.jsx(RenderMarkdown_default, { content, searchValue }) });
354
354
  };
355
- function createValtioContext() {
356
- const Context = React16.createContext(null);
357
- const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value: store, children });
358
- const useValtioStore = () => {
359
- const store = React16.useContext(Context);
360
- if (!store) throw new Error("useStore must be used within Provider");
361
- return store;
362
- };
363
- return {
364
- ValtioProvider,
365
- useValtioStore
366
- // Context
367
- };
368
- }
369
355
 
370
356
  // src/hooks/iframe/iframeRelay.ts
371
357
  function emit(type, data, to = "top") {
@@ -471,6 +457,9 @@ var isExternal = (path) => {
471
457
  var isBlob = (val) => {
472
458
  return is(val, "Blob");
473
459
  };
460
+ var isLocalhost = (host) => {
461
+ return /^(localhost:)/.test(host || location.host);
462
+ };
474
463
 
475
464
  // src/hooks/iframe/useIframeRelayBridge.ts
476
465
  function useIframeRelayBridge(allowedOrigins = ["*"]) {
@@ -501,6 +490,20 @@ function useIframeRelayBridge(allowedOrigins = ["*"]) {
501
490
  }
502
491
  return { on, off };
503
492
  }
493
+ function useCreateValtioContext() {
494
+ const Context = React16.createContext(null);
495
+ const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value: store, children });
496
+ const useValtioStore = () => {
497
+ const store = React16.useContext(Context);
498
+ if (!store) throw new Error("useStore must be used within Provider");
499
+ return store;
500
+ };
501
+ return {
502
+ ValtioProvider,
503
+ useValtioStore
504
+ // Context
505
+ };
506
+ }
504
507
  function useDebounce(func, wait = 400) {
505
508
  const { current } = React16.useRef({ func, timeOut: null });
506
509
  React16.useEffect(() => {
@@ -678,6 +681,9 @@ var generateRandomNumbers = (min, max, count) => {
678
681
  var getFileName = (filePath) => {
679
682
  return filePath.split("?")[0].split("/").pop() || "";
680
683
  };
684
+ var getFileSuffixName = (fileName) => {
685
+ return fileName.split(".").pop() || "";
686
+ };
681
687
  var textAreaView = (con) => {
682
688
  return con ? con.replace(/\r\n/g, "\n").replace(/\n/g, "<br/>") : "";
683
689
  };
@@ -982,7 +988,6 @@ function getSignPath() {
982
988
 
983
989
  // src/utils/request.ts
984
990
  var OK = 200;
985
- var OK2 = "S0000";
986
991
  var ERROR = 500;
987
992
  var MISSING_PARAMETER = 400;
988
993
  var UNAUTHORIZED = 401;
@@ -1022,7 +1027,7 @@ axios__default.default.interceptors.response.use(
1022
1027
  if (isBlob(response.data)) {
1023
1028
  return response;
1024
1029
  }
1025
- if (response.data?.code !== OK && response.data?.code !== OK2) {
1030
+ if (response.data?.code !== OK) {
1026
1031
  const isPermission = response.data?.code === PERMISSION_DENIED;
1027
1032
  if (response.config?.showError !== false) {
1028
1033
  showMessage({
@@ -1345,7 +1350,7 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
1345
1350
  }, 500);
1346
1351
  onSetPageNo?.(currentPage + 1);
1347
1352
  }, [currentPage]);
1348
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Worker, { workerUrl: `/uc/pdf/pdf.worker.min.js`, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { onResize: setSizes, children: [
1353
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Worker, { workerUrl: `logosdata.cn/public/pdf/pdf.worker.min.js`, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { onResize: setSizes, children: [
1349
1354
  isHasThumbnails && /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { resizable: false, size: sizes[0], min: 250, max: 500, collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsx(Thumbnails, {}) }),
1350
1355
  /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "height-full", children: [
1351
1356
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1366,13 +1371,13 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
1366
1371
  // 启用 CMap 支持,解决中文字体显示问题
1367
1372
  // cMapUrl: 指定 CMap 文件的 URL,用于处理非拉丁字符(如中文)
1368
1373
  // cMapPacked: 使用压缩的 CMap 文件以提高性能
1369
- cMapUrl: "/uc/pdf/pdfjs-dist@3.2.146/cmaps/",
1374
+ cMapUrl: "logosdata.cn/public/pdf/pdfjs-dist@3.2.146/cmaps/",
1370
1375
  // 使用可用的源
1371
1376
  cMapPacked: true,
1372
1377
  // 禁用字体子集化,确保完整字体加载
1373
1378
  disableFontFace: false,
1374
1379
  // 启用标准字体支持
1375
- standardFontDataUrl: "/uc/pdf/pdfjs-dist@3.2.146/standard_fonts/",
1380
+ standardFontDataUrl: "logosdata.cn/public/pdf/pdfjs-dist@3.2.146/standard_fonts/",
1376
1381
  // 设置字体回退策略
1377
1382
  fallbackFontName: "Helvetica"
1378
1383
  });
@@ -5272,7 +5277,6 @@ exports.MarkdownEditor = MarkdownEditor_default;
5272
5277
  exports.MarkdownPreview = MarkdownPreview_default;
5273
5278
  exports.NOT_FOUND = NOT_FOUND;
5274
5279
  exports.OK = OK;
5275
- exports.OK2 = OK2;
5276
5280
  exports.PERMISSION_DENIED = PERMISSION_DENIED;
5277
5281
  exports.PdfPreview = PdfPreview_default;
5278
5282
  exports.RenderMarkdown = RenderMarkdown_default;
@@ -5290,7 +5294,6 @@ exports.clearCurrentUser = clearCurrentUser;
5290
5294
  exports.clearToken = clearToken;
5291
5295
  exports.compareNum = compareNum;
5292
5296
  exports.copyText = copyText;
5293
- exports.createValtioContext = createValtioContext;
5294
5297
  exports.decimalPlaces = decimalPlaces;
5295
5298
  exports.deepCopy = deepCopy;
5296
5299
  exports.deepEqual = deepEqual;
@@ -5308,6 +5311,7 @@ exports.getCurrentUser = getCurrentUser;
5308
5311
  exports.getDeviceId = getDeviceId;
5309
5312
  exports.getEndOfTimestamp = getEndOfTimestamp;
5310
5313
  exports.getFileName = getFileName;
5314
+ exports.getFileSuffixName = getFileSuffixName;
5311
5315
  exports.getSignPath = getSignPath;
5312
5316
  exports.getStartOfTimestamp = getStartOfTimestamp;
5313
5317
  exports.getTimestamp = getTimestamp;
@@ -5329,6 +5333,7 @@ exports.isExpire = isExpire;
5329
5333
  exports.isExternal = isExternal;
5330
5334
  exports.isFunction = isFunction;
5331
5335
  exports.isInteger = isInteger;
5336
+ exports.isLocalhost = isLocalhost;
5332
5337
  exports.isMap = isMap;
5333
5338
  exports.isNegative = isNegative;
5334
5339
  exports.isNull = isNull;
@@ -5357,6 +5362,7 @@ exports.textAreaView = textAreaView;
5357
5362
  exports.themeConfig = themeConfig;
5358
5363
  exports.times = times;
5359
5364
  exports.toFixed = toFixed;
5365
+ exports.useCreateValtioContext = useCreateValtioContext;
5360
5366
  exports.useDebounce = useDebounce;
5361
5367
  exports.useDeepEffect = useDeepEffect;
5362
5368
  exports.useIframeRelayBridge = useIframeRelayBridge;