CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
index.js61 linesDownload Raw Back to zustand
1'use strict';2 3var vanilla = require('zustand/vanilla');4var ReactExports = require('react');5var useSyncExternalStoreExports = require('use-sync-external-store/shim/with-selector');6 7var useDebugValue = ReactExports.useDebugValue;8var useSyncExternalStoreWithSelector = useSyncExternalStoreExports.useSyncExternalStoreWithSelector;9var didWarnAboutEqualityFn = false;10var identity = function identity(arg) {11  return arg;12};13function useStore(api, selector, equalityFn) {14  if (selector === void 0) {15    selector = identity;16  }17  if (process.env.NODE_ENV !== 'production' && equalityFn && !didWarnAboutEqualityFn) {18    console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937");19    didWarnAboutEqualityFn = true;20  }21  var slice = useSyncExternalStoreWithSelector(api.subscribe, api.getState, api.getServerState || api.getInitialState, selector, equalityFn);22  useDebugValue(slice);23  return slice;24}25var createImpl = function createImpl(createState) {26  if (process.env.NODE_ENV !== 'production' && typeof createState !== 'function') {27    console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");28  }29  var api = typeof createState === 'function' ? vanilla.createStore(createState) : createState;30  var useBoundStore = function useBoundStore(selector, equalityFn) {31    return useStore(api, selector, equalityFn);32  };33  Object.assign(useBoundStore, api);34  return useBoundStore;35};36var create = function create(createState) {37  return createState ? createImpl(createState) : createImpl;38};39var react = (function (createState) {40  if (process.env.NODE_ENV !== 'production') {41    console.warn("[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'`.");42  }43  return create(createState);44});45 46exports.create = create;47exports.default = react;48exports.useStore = useStore;49Object.keys(vanilla).forEach(function (k) {50  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {51    enumerable: true,52    get: function () { return vanilla[k]; }53  });54});55 56module.exports = react;57module.exports.create = create;58module.exports.useStore = useStore;59module.exports.createStore = vanilla.createStore;60exports.default = module.exports;61