@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 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
  };
@@ -5290,7 +5296,6 @@ exports.clearCurrentUser = clearCurrentUser;
5290
5296
  exports.clearToken = clearToken;
5291
5297
  exports.compareNum = compareNum;
5292
5298
  exports.copyText = copyText;
5293
- exports.createValtioContext = createValtioContext;
5294
5299
  exports.decimalPlaces = decimalPlaces;
5295
5300
  exports.deepCopy = deepCopy;
5296
5301
  exports.deepEqual = deepEqual;
@@ -5308,6 +5313,7 @@ exports.getCurrentUser = getCurrentUser;
5308
5313
  exports.getDeviceId = getDeviceId;
5309
5314
  exports.getEndOfTimestamp = getEndOfTimestamp;
5310
5315
  exports.getFileName = getFileName;
5316
+ exports.getFileSuffixName = getFileSuffixName;
5311
5317
  exports.getSignPath = getSignPath;
5312
5318
  exports.getStartOfTimestamp = getStartOfTimestamp;
5313
5319
  exports.getTimestamp = getTimestamp;
@@ -5329,6 +5335,7 @@ exports.isExpire = isExpire;
5329
5335
  exports.isExternal = isExternal;
5330
5336
  exports.isFunction = isFunction;
5331
5337
  exports.isInteger = isInteger;
5338
+ exports.isLocalhost = isLocalhost;
5332
5339
  exports.isMap = isMap;
5333
5340
  exports.isNegative = isNegative;
5334
5341
  exports.isNull = isNull;
@@ -5357,6 +5364,7 @@ exports.textAreaView = textAreaView;
5357
5364
  exports.themeConfig = themeConfig;
5358
5365
  exports.times = times;
5359
5366
  exports.toFixed = toFixed;
5367
+ exports.useCreateValtioContext = useCreateValtioContext;
5360
5368
  exports.useDebounce = useDebounce;
5361
5369
  exports.useDeepEffect = useDeepEffect;
5362
5370
  exports.useIframeRelayBridge = useIframeRelayBridge;