Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shipt/osmosis

Package Overview
Dependencies
Maintainers
91
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shipt/osmosis - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

26

dist/setupStore.d.ts

@@ -9,7 +9,8 @@ export function configureSetupStore(config: any): void;

};
export type Store = {
export type useStore<T> = () => T;
export type Store<T> = {
/**
* - The React Context for the store
*/
Context: any;
Context: React.Context<T>;
/**

@@ -19,2 +20,6 @@ * - The higher order component provider for the store

Provider: any;
/**
* - Returns result of useContext(Context)
*/
useStore: useStore<T>;
};

@@ -32,12 +37,19 @@ /**

/**
* @template T
* @callback useStore
* @returns {T}
*/
/**
* @template T
* @typedef Store
* @type {Object}
* @property {Object} Context - The React Context for the store
* @property {React.Context<T>} Context - The React Context for the store
* @property {Object} Provider - The higher order component provider for the store
* @property {useStore<T>} useStore - Returns result of useContext(Context)
*/
/**
* @param {useCustomHook} useCustomHook
* @template T
* @param {function(object) : T} useCustomHook
* @param {SetupStoreConfig} [config = { proxyEnabled: false }] - The setup store config
* @returns {Store}
* @returns {T & Store<T>}
*/
export function setupStore(useCustomHook: useCustomHook, config?: SetupStoreConfig): Store;
export function setupStore<T>(useCustomHook: (arg0: object) => T, config?: SetupStoreConfig): T & Store<T>;

@@ -49,12 +49,20 @@ "use strict";

/**
* @template T
* @callback useStore
* @returns {T}
*/
/**
* @template T
* @typedef Store
* @type {Object}
* @property {Object} Context - The React Context for the store
* @property {React.Context<T>} Context - The React Context for the store
* @property {Object} Provider - The higher order component provider for the store
* @property {useStore<T>} useStore - Returns result of useContext(Context)
*/
/**
* @param {useCustomHook} useCustomHook
* @template T
* @param {function(object) : T} useCustomHook
* @param {SetupStoreConfig} [config = { proxyEnabled: false }] - The setup store config
* @returns {Store}
* @returns {T & Store<T>}
*/

@@ -75,33 +83,4 @@

ref: {}
}; // Legacy Store Provider
}; // Store Provider
var withLegacyStoreContext = function withLegacyStoreContext(WrappedComponent) {
return function (props) {
var storeKey = props.storeKey;
var store = useCustomHook(props);
if (!!store.Context) throw new Error("'Context' property is protected and cannot exist on a store object");
if (!!store.Provider) throw new Error("'Provider' property is protected and cannot exist on a store object");
if (storeProxy) {
if (storeKey) {
storeProxyObject.ref[storeKey] = store;
} else storeProxyObject.ref = store;
} else {
if (storeKey) {
storeRef[storeKey] = store;
} else {
for (var key in store) {
storeRef[key] = store[key];
}
}
}
var value = config.legacyReturnStoreAsArray ? [store] : store;
return /*#__PURE__*/_react["default"].createElement(StoreContext.Provider, {
value: value
}, /*#__PURE__*/_react["default"].createElement(WrappedComponent, props));
};
}; // New Store Provider
var withStoreContext = function withStoreContext(WrappedComponent) {

@@ -116,2 +95,3 @@ var StoreContextWrapper = function StoreContextWrapper(_ref) {

if (!!store.Provider) throw new Error("'Provider' property is protected and cannot exist on a store object");
if (!!store.useStore) throw new Error("'useStore' property is protected and cannot exist on a store object");

@@ -145,8 +125,14 @@ if (storeProxy) {

var useStore = function useStore() {
return (0, _react.useContext)(StoreContext);
};
if (!!Proxy && config.proxyEnabled) {
storeProxy = new Proxy(storeProxyObject, {
get: function get(target, property) {
var _target$ref$property;
if (property === 'Context') return StoreContext;
if (property === 'Provider') return withStoreContext;
if (property === 'LegacyProvider') return withLegacyStoreContext;
if (property === 'useStore') return (_target$ref$property = target.ref[property]) !== null && _target$ref$property !== void 0 ? _target$ref$property : useStore;
return target.ref[property];

@@ -161,3 +147,3 @@ },

storeRef.Provider = withStoreContext;
storeRef.LegacyProvider = withLegacyStoreContext;
storeRef.useStore = useStore;
}

@@ -164,0 +150,0 @@

{
"name": "@shipt/osmosis",
"version": "2.0.1",
"version": "2.0.2",
"description": "A lightweight state management library for React and React Native",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc