🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

resy

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resy - npm Package Compare versions

Comparing version
11.0.3
to
11.1.0
+5
-2
dist/platform.cjs.js

@@ -5,4 +5,7 @@ 'use strict';

var dom = { unstable_batchedUpdates: reactDom.unstable_batchedUpdates };
module.exports = dom;
Object.defineProperty(exports, "unstable_batchedUpdates", {
enumerable: true,
get: function () { return reactDom.unstable_batchedUpdates; }
});

@@ -5,4 +5,7 @@ 'use strict';

var native = { unstable_batchedUpdates: reactNative.unstable_batchedUpdates };
module.exports = native;
Object.defineProperty(exports, "unstable_batchedUpdates", {
enumerable: true,
get: function () { return reactNative.unstable_batchedUpdates; }
});

@@ -1,5 +0,1 @@

import { unstable_batchedUpdates } from 'react-dom';
var dom = { unstable_batchedUpdates };
export { dom as default };
export { unstable_batchedUpdates } from 'react-dom';

@@ -1,5 +0,1 @@

import { unstable_batchedUpdates } from 'react-native';
var native = { unstable_batchedUpdates };
export { native as default };
export { unstable_batchedUpdates } from 'react-native';
'use strict';
var ReactPlatformExports = require('./platform.cjs');
var platform_cjs = require('./platform.cjs');
var useSyncExternalStoreExports = require('use-sync-external-store/shim');

@@ -28,3 +28,3 @@ var react = require('react');

var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
}

@@ -34,3 +34,3 @@ }

return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
writable: !1
writable: false
}), e;

@@ -49,5 +49,5 @@ }

return n >= r.length ? {
done: !0
done: true
} : {
done: !1,
done: false,
value: r[n++]

@@ -65,4 +65,4 @@ };

var o,
a = !0,
u = !1;
a = true,
u = false;
return {

@@ -77,3 +77,3 @@ s: function () {

e: function (r) {
u = !0, o = r;
u = true, o = r;
},

@@ -92,5 +92,5 @@ f: function () {

value: t,
enumerable: !0,
configurable: !0,
writable: !0
enumerable: true,
configurable: true,
writable: true
}) : e[r] = t, e;

@@ -108,7 +108,7 @@ }

value: t,
writable: !0,
configurable: !0
writable: true,
configurable: true
}
}), Object.defineProperty(t, "prototype", {
writable: !1
writable: false
}), e && _setPrototypeOf(t, e);

@@ -132,8 +132,8 @@ }

a = [],
f = !0,
o = !1;
f = true,
o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
o = true, n = r;
} finally {

@@ -165,3 +165,3 @@ try {

var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
_defineProperty(e, r, t[r]);

@@ -191,3 +191,3 @@ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {

if (void 0 !== e) {
var i = e.call(t, r || "default");
var i = e.call(t, r);
if ("object" != typeof i) return i;

@@ -222,9 +222,2 @@ throw new TypeError("@@toPrimitive must return a primitive value.");

var __DEV__ = NODE_ENV === "development";
/**
* @description To be deprecated
* TODO It is anticipated that following the stabilization of React version 19,
* the use of `unstable_batchedUpdates` might be considered for discontinuation,
* given that these unstable APIs were already unsupported in React version 18.
*/
var unstable_batchedUpdates = ReactPlatformExports.unstable_batchedUpdates;
/** Batch processing safety shim */

@@ -234,3 +227,3 @@ var batchUpdateShimRun = function batchUpdateShimRun(fn) {

};
var batchUpdate = unstable_batchedUpdates || batchUpdateShimRun;
var batchUpdate = platform_cjs.unstable_batchedUpdates || batchUpdateShimRun;

@@ -244,2 +237,6 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;

switch (type) {
case "[object Array]":
return "Array";
case "[object Object]":
return "Object";
case "[object String]":

@@ -251,6 +248,2 @@ return "String";

return "Boolean";
case "[object Object]":
return "Object";
case "[object Array]":
return "Array";
case "[object Set]":

@@ -285,3 +278,7 @@ return "Set";

case "[object Array Iterator]":
return "Array Iterator";
return "ArrayIterator";
case "[object Set Iterator]":
return "SetIterator";
case "[object Map Iterator]":
return "MapIterator";
case "[object FormData]":

@@ -348,13 +345,2 @@ return "FormData";

};
// const primitiveMap = new Map<PrimitiveValueType, PrimitiveValueType>(Object.entries({
// Number: "Number",
// String: "String",
// Boolean: "Boolean",
// Undefined: "Undefined",
// Null: "Null",
// Symbol: "Symbol",
// }) as any);
// export const isPrimitive = (value: unknown): boolean => {
// return primitiveMap.has(whatsType(value) as PrimitiveValueType);
// };

@@ -374,10 +360,3 @@ // Check whether the store is generated by Resy's createStore

if (__DEV__ && stateType !== "Object") {
var ucs = options === null || options === void 0 ? void 0 : options.__useConciseState__;
var fnNameTemp = fnName;
if (!fnNameTemp && ucs !== true) {
fnNameTemp = "createStore";
}
if (!fnNameTemp && ucs === true) {
fnNameTemp = "useConciseState";
}
var fnNameTemp = fnName !== null && fnName !== void 0 ? fnName : options === null || options === void 0 ? void 0 : options.__functionName__;
throw new Error("resy's ".concat(fnNameTemp, "(...): takes an object of state variables to update or") + " a function which returns an object of state variables." + " Instead received: ".concat(stateType.toLocaleLowerCase()));

@@ -396,3 +375,5 @@ }

var nsType = whatsType(options === null || options === void 0 ? void 0 : options.namespace);
if (__DEV__ && (optsExist && optionsType !== "Object" || optsExist && optionsType === "Object" && (urType !== "Boolean" && urType !== "Undefined" || ucsType !== "Boolean" && ucsType !== "Undefined" || nsType !== "String" && nsType !== "Undefined"))) {
var emType = whatsType(options === null || options === void 0 ? void 0 : options.__enableMacros__);
var emasType = whatsType(options === null || options === void 0 ? void 0 : options.enableMarcoActionStateful);
if (__DEV__ && (optsExist && optionsType !== "Object" || optsExist && optionsType === "Object" && (urType !== "Boolean" && urType !== "Undefined" || ucsType !== "Boolean" && ucsType !== "Undefined" || nsType !== "String" && nsType !== "Undefined" || emType !== "Boolean" && emType !== "Undefined" || emasType !== "Boolean" && emasType !== "Undefined"))) {
throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params." + " Instead received: ".concat(optionsType.toLocaleLowerCase(), "."));

@@ -687,9 +668,9 @@ }

var singleStoreChangeSet = new Set();
storeMapValue.set("subscribeOriginState", function (onOriginStateChange) {
storeMapValue.set("subscribe", function (onStoreChange) {
// If a component references the data, the update function will be added to singleStoreChangeSet
singleStoreChangeSet.add(onOriginStateChange);
singleStoreChangeSet.add(onStoreChange);
// Increment the reference count by 1 if the component is referenced
storeStateRefCounterMap.set("counter", storeStateRefCounterMap.get("counter") + 1);
return function () {
singleStoreChangeSet["delete"](onOriginStateChange);
singleStoreChangeSet["delete"](onStoreChange);
storeStateRefCounterMap.set("counter", storeStateRefCounterMap.get("counter") - 1);

@@ -704,7 +685,7 @@ deferRestoreProcessing(options, reducerState, stateMap, storeStateRefCounterMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState, function () {

});
storeMapValue.set("getOriginState", function () {
storeMapValue.set("getSnapshot", function () {
return stateMap.get(key);
});
storeMapValue.set("useOriginState", function () {
return useSyncExternalStore(storeMap.get(key).get("subscribeOriginState"), storeMap.get(key).get("getOriginState"), storeMap.get(key).get("getOriginState"));
storeMapValue.set("useSyncExternalStore", function () {
return useSyncExternalStore(storeMap.get(key).get("subscribe"), storeMap.get(key).get("getSnapshot"), storeMap.get(key).get("getSnapshot"));
});

@@ -726,3 +707,3 @@ storeMapValue.set("updater", function () {

initialStateRetrieve(reducerState, stateMap, initialFnCanExecMap, initialState);
return connectStore(key, options, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState).get(key).get("useOriginState")();
return connectStore(key, options, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState).get(key).get("useSyncExternalStore")();
};

@@ -876,2 +857,12 @@ /**

};
if (__DEV__) {
var store_namespace = store[__STORE_NAMESPACE__] ? {
namespace: store[__STORE_NAMESPACE__]
} : null;
// eslint-disable-next-line react-hooks/rules-of-hooks
react.useDebugValue(_objectSpread2({
listener: listener,
stateKeys: stateKeys
}, store_namespace));
}
react.useEffect(function () {

@@ -919,13 +910,15 @@ // Monitor the overall data changes of the store

*/
var createStore = function createStore(initialState, options) {
var _options$__useConcise, _options$unmountResto, _options$namespace;
var _createStore = function createStore(initialState, options) {
var _options$__useConcise, _options$unmountResto, _options$namespace, _options$__enableMacr, _options$enableMarcoA, _options$__functionNa;
/** ============================== For core constant ready start ============================== */
// Retrieve the reducerState
var reducerState = initialState === undefined ? {} : typeof initialState === "function" ? initialState() : initialState;
optionsErrorProcessing(options);
var optionsTemp = options ? {
__useConciseState__: (_options$__useConcise = options.__useConciseState__) !== null && _options$__useConcise !== void 0 ? _options$__useConcise : undefined,
unmountRestore: (_options$unmountResto = options.unmountRestore) !== null && _options$unmountResto !== void 0 ? _options$unmountResto : true,
namespace: (_options$namespace = options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : undefined
} : {
unmountRestore: true
var optionsTemp = {
__useConciseState__: (_options$__useConcise = options === null || options === void 0 ? void 0 : options.__useConciseState__) !== null && _options$__useConcise !== void 0 ? _options$__useConcise : undefined,
unmountRestore: (_options$unmountResto = options === null || options === void 0 ? void 0 : options.unmountRestore) !== null && _options$unmountResto !== void 0 ? _options$unmountResto : true,
namespace: (_options$namespace = options === null || options === void 0 ? void 0 : options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : undefined,
__enableMacros__: (_options$__enableMacr = options === null || options === void 0 ? void 0 : options.__enableMacros__) !== null && _options$__enableMacr !== void 0 ? _options$__enableMacr : undefined,
enableMarcoActionStateful: (_options$enableMarcoA = options === null || options === void 0 ? void 0 : options.enableMarcoActionStateful) !== null && _options$enableMarcoA !== void 0 ? _options$enableMarcoA : undefined,
__functionName__: (_options$__functionNa = options === null || options === void 0 ? void 0 : options.__functionName__) !== null && _options$__functionNa !== void 0 ? _options$__functionNa : _createStore.name
};

@@ -954,2 +947,12 @@ stateErrorProcessing({

var classThisPointerSet = new Set();
/**
* @description Map for additional related internal objects of store
* For example, some related functions or identifiers,
* such as setState, subscribe and internal identity __REGENERATIVE_SYSTEM_KEY__
*/
var externalMap = new Map();
/** ============================== For core constant ready end ============================== */
// for development tools
externalMap.set(__STORE_NAMESPACE__, optionsTemp.namespace);
/** ============================== For core utils use start ============================== */
var setState = function setState(state, callback) {

@@ -1027,7 +1030,8 @@ willUpdatingProcessing(listenerSet, schedulerProcessor, prevBatchState, stateMap);

};
// Change options configuration
var setOptions = function setOptions(options) {
setOptionsErrorProcessing(options);
optionsTemp.unmountRestore = options.unmountRestore;
};
externalMap.set("setState", setState);
externalMap.set("syncUpdate", syncUpdate);
externalMap.set("restore", restore);
externalMap.set("subscribe", subscribe);
/** ============================== For core utils use end ============================== */
/** ============================== For core render use start ============================== */
// Data updates for a single attribute

@@ -1042,8 +1046,2 @@ var singleUpdate = function singleUpdate(key, value, isDelete) {

};
/**
* @description Map for additional related internal objects of store
* For example, some related functions or identifiers,
* such as setState, subscribe and internal identity __REGENERATIVE_SYSTEM_KEY__
*/
var externalMap = new Map();
// Updated handler configuration for proxy

@@ -1059,22 +1057,34 @@ var proxySetHandler = {

};
var macroFnProcessing = function macroFnProcessing(key, value) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
var boundFn = function boundFn() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return value.apply(store, args);
};
boundFn.__bound__ = true;
stateMap.set(key, boundFn);
return boundFn;
};
// A proxy object with the capabilities of updating and data tracking.
var store = new Proxy(storeMap, _objectSpread2({
var store = new Proxy(stateMap, _objectSpread2({
get: function get(_, key, receiver) {
protoPointStoreErrorProcessing(receiver, store);
var value = stateMap.get(key);
return externalMap.get(key) || (typeof value !== "function" ? value : function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return value.apply(store, args);
});
if (typeof value === "function" && !value.__bound__) {
return macroFnProcessing(key, value);
}
return externalMap.get(key) || value;
}
}, proxySetHandler));
// Proxy of driver update re-render for useStore
var engineStore = new Proxy(storeMap, _objectSpread2({
var engineStore = new Proxy(stateMap, _objectSpread2({
get: function get(_, key) {
// Get the latest value
var value = stateMap.get(key);
if (__DEV__ && !externalMap.has(key)) {
var notExternal = !externalMap.has(key);
if (notExternal && typeof value !== "function") {
// eslint-disable-next-line react-hooks/rules-of-hooks
react.useDebugValue(_objectSpread2({
__DEV__ && react.useDebugValue(_objectSpread2({
key: key,

@@ -1085,32 +1095,55 @@ value: value

} : null));
return connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
}
if (typeof value === "function") {
// Invoke a function data hook to grant the ability to update and render function data.
var stateFnValue = connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return stateFnValue.apply(store, args);
};
if (notExternal && typeof value === "function") {
// Avoid memory redundancy waste caused by repeated bindings and maintain the function reference address unchanged.
if (!value.__bound__) {
macroFnProcessing(key, value);
}
var fnStateful = !optionsTemp.__enableMacros__ || optionsTemp.enableMarcoActionStateful;
var newValue = stateMap.get(key);
// eslint-disable-next-line react-hooks/rules-of-hooks
fnStateful && __DEV__ && react.useDebugValue(_objectSpread2({
key: key,
value: newValue
}, optionsTemp.namespace ? {
namespace: optionsTemp.namespace
} : null));
/**
* @description Enable function properties to have the ability to update rendering.
* Placing both the __bound__ and the stateMap's set operation before the connectHook
* can preemptively avoid the tearing synchronization handling inside useSyncExternalStore,
* resulting in twice the redundant rendering execution.
*/
fnStateful && connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return newValue;
}
return externalMap.get(key) || connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return externalMap.get(key);
}
}, proxySetHandler));
externalMap.set("setState", setState);
externalMap.set("syncUpdate", syncUpdate);
externalMap.set("restore", restore);
externalMap.set("subscribe", subscribe);
if (optionsTemp.__useConciseState__) {
// Enable useConciseState to have data tracking capabilities through the store
// Enable useConciseState and defineStore to have data tracking capabilities through the store
if (optionsTemp.__useConciseState__ || optionsTemp.__enableMacros__) {
externalMap.set("store", store);
} else {
/**
* @description useConciseState should not possess the capability
* of the setOptions since local state control would become chaotic if there is local caching.
* Caching is more meaningful in the context of the entire store.
*/
externalMap.set("setOptions", setOptions);
}
/**
* @description Here, __USE_STORE_KEY__ is not placed under the branch where optionsTemp.__mode__ === "state",
* because computed needs the rendering capability of engineStore.
*/
externalMap.set(__USE_STORE_KEY__, engineStore);
externalMap.set(__REGENERATIVE_SYSTEM_KEY__, __REGENERATIVE_SYSTEM_KEY__);
/** ============================== For core render use end ============================== */
/** ============================== For operate options use start ============================== */
// Change options configuration
var setOptions = function setOptions(options) {
setOptionsErrorProcessing(options);
optionsTemp.unmountRestore = options.unmountRestore;
};
var getOptions = function getOptions() {
return Object.assign({}, optionsTemp);
};
externalMap.set("setOptions", setOptions);
externalMap.set("getOptions", getOptions);
/** ============================== For operate options use end ============================== */
/** ============================== For hook components use start ============================== */
/**
* It is convenient for store.useStore() to call directly

@@ -1124,4 +1157,18 @@ * 🌟 The reason why it is not changed to store.useStore

var useSubscription$1 = function useSubscription$1(listener, stateKeys) {
if (__DEV__) {
var store_namespace = optionsTemp.namespace ? {
namespace: optionsTemp.namespace
} : null;
// eslint-disable-next-line react-hooks/rules-of-hooks
react.useDebugValue(_objectSpread2({
listener: listener,
stateKeys: stateKeys
}, store_namespace));
}
useSubscription(store, listener, stateKeys);
};
externalMap.set("useStore", useStore);
externalMap.set("useSubscription", useSubscription$1);
/** ============================== For hook components use end ============================== */
/** ============================== For class components use start ============================== */
// Connecting this pointer of the class component (therefore, this cannot be an arrow function)

@@ -1132,3 +1179,3 @@ function classConnectStore() {

// Data agents for use by class components
var classEngineStore = new Proxy(storeMap, _objectSpread2({
var classEngineStore = new Proxy(stateMap, _objectSpread2({
get: function get(_, key) {

@@ -1143,4 +1190,4 @@ // Compatible with scenarios where both hook components and class components are used together.

: function () {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}

@@ -1162,11 +1209,3 @@ return connectClass.apply(_this, [key, stateMap]).apply(classEngineStore, args);

};
externalMap.set("useStore", useStore);
externalMap.set("useSubscription", useSubscription$1);
/**
* @description Here, __USE_STORE_KEY__ is not placed under the branch where optionsTemp.__mode__ === "state",
* because computed needs the rendering capability of engineStore.
*/
externalMap.set(__USE_STORE_KEY__, engineStore);
externalMap.set(__REGENERATIVE_SYSTEM_KEY__, __REGENERATIVE_SYSTEM_KEY__);
/**
* @description The reason why the three operation functions for class components

@@ -1181,3 +1220,3 @@ * — connect, classUnmountProcessing, and classInitialStateRetrieve

externalMap.set(__CLASS_INITIAL_STATE_RETRIEVE_KEY__, classInitialStateRetrieve);
externalMap.set(__STORE_NAMESPACE__, optionsTemp.namespace);
/** ============================== For class components use end ============================== */
return store;

@@ -1211,8 +1250,9 @@ };

* @param initialState
* @return ConciseStore<S>
* @return MacroStore<S>
*/
var useConciseState = function useConciseState(initialState) {
var _useConciseState = function useConciseState(initialState) {
return react.useMemo(function () {
return createStore(initialState, {
__useConciseState__: true
return _createStore(initialState, {
__useConciseState__: true,
__functionName__: _useConciseState.name
});

@@ -1223,2 +1263,59 @@ // eslint-disable-next-line react-hooks/exhaustive-deps

/**
* @description Define the preprocessed store type for the createStore macro,
* which essentially represents the return type of the useStore function.
*
* 🌟 This API primarily follows the macro definition convention from the C programming language,
* hence the use of "define" as a prefix for naming.
*
* 🌟 `defineStore` will render the functions within the store incapable of updating,
* unlike `createStore`, and they will merely serve as actions.
* If you have a specific reason to enable function properties with the capability to update rendering,
* you can turn it on through the configuration option "enableMarcoActionStateful".
*
* 🌟 In the future, `defineStore` will gradually replace `createStore` as the norm for usage,
* and it possesses more rationality.
* The existence of `defineStore` also implies that Resy's focus will shift towards hooks components,
* moving away from an adherence to class components.
*
* 🌟 `defineStore`, in fact, returns the `useStore` function,
* which on one hand reflects the characteristics of functional programming,
* and on the other hand, stems from React's restrictions on hook usage
*
* 😊 If React had no restrictions on hook usage,
* I would prefer to directly return the final store instead of redundantly calling `useStore()` again.
*
* @example
* ```tsx
* interface StateModel {
* count: number;
* increase(): void;
* }
*
* const useStore = defineStore<StateModel>({
* count: 0,
* increase() {
* this.count += 1;
* },
* });
*
* const App = () => {
* const { count, increase } = useStore();
*
* return (
* <>
* <p>count:{count}</p>
* <button onClick={increase}>increase</button>
* </>
* );
* };
* ```
*/
var _defineStore = function defineStore(initialState, options) {
return _createStore(initialState, _objectSpread2(_objectSpread2({}, options), {}, {
__enableMacros__: true,
__functionName__: _defineStore.name
})).useStore;
};
function constructorProcessing() {

@@ -1239,3 +1336,4 @@ var _this = this;

this.componentWillUnmount = function () {
instanceUnmount === null || instanceUnmount === void 0 || instanceUnmount();
// The original 'this' pointing cannot be missing
instanceUnmount === null || instanceUnmount === void 0 || instanceUnmount.apply(_this);
/**

@@ -1331,5 +1429,6 @@ * @description The strict mode of class components does not provide accurate predictability

exports.PureComponentWithStore = PureComponentWithStore;
exports.createStore = createStore;
exports.useConciseState = useConciseState;
exports.createStore = _createStore;
exports.defineStore = _defineStore;
exports.useConciseState = _useConciseState;
exports.useStore = useStore;
exports.useSubscription = useSubscription;

@@ -1,1 +0,1 @@

"use strict";var e=require("./platform.cjs"),t=require("use-sync-external-store/shim"),n=require("react");function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t,n){return t=i(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],i(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,c,u=[],i=!0,s=!1;try{if(a=(n=n.call(e)).next,0===t);else for(;!(i=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{if(!i&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw o}}return u}}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function v(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}var g=Symbol("regenerativeSystemKey"),h=Symbol("useStoreKey"),S=Symbol("storeNamespace"),m=process.env.NODE_ENV;m||console.error("NODE_ENV not set");var j="development"===m,w=e.unstable_batchedUpdates||function(e){return e()},O=Object.prototype.hasOwnProperty,E=Object.prototype.toString,A=function(e){var t,n=E.call(e);switch(n){case"[object String]":return"String";case"[object Number]":return"Number";case"[object Boolean]":return"Boolean";case"[object Object]":return"Object";case"[object Array]":return"Array";case"[object Set]":return"Set";case"[object Map]":return"Map";case"[object Function]":return"Function";case"[object Date]":return"Date";case"[object Symbol]":return"Symbol";case"[object WeakSet]":return"WeakSet";case"[object WeakMap]":return"WeakMap";case"[object RegExp]":return"RegExp";case"[object WeakRef]":return"WeakRef";case"[object BigInt]":return"BigInt";case"[object Null]":return"Null";case"[object Undefined]":return"Undefined";case"[object Promise]":return"Promise";case"[object AsyncFunction]":return"AsyncFunction";case"[object Array Iterator]":return"Array Iterator";case"[object FormData]":return"FormData";case"[object Blob]":return"Blob";case"[object File]":return"File";case"[object Error]":return"Error";case"[object CustomEvent]":return"CustomEvent";case"[object Storage]":return"Storage";case"[object WebSocket]":return"WebSocket";case"[object ArrayBuffer]":return"ArrayBuffer";case"[object DataView]":return"DataView";case"[object Uint8Array]":return"Uint8Array";case"[object Int8Array]":return"Int8Array";case"[object Uint8ClampedArray]":return"Uint8ClampedArray";case"[object Int16Array]":return"Int16Array";case"[object Uint16Array]":return"Uint16Array";case"[object Int32Array]":return"Int32Array";case"[object Uint32Array]":return"Uint32Array";case"[object Float32Array]":return"Float32Array";case"[object Float64Array]":return"Float64Array";case"[object BigInt64Array]":return"BigInt64Array";case"[object BigUint64Array]":return"BigUint64Array";case"[object XMLHttpRequest]":return"XMLHttpRequest";case"[object Headers]":return"Headers";case"[object Request]":return"Request";case"[object Response]":return"Response";case"[object Window]":return"Window";case"[object Global]":case"[object global]":return"Global";case"[object Arguments]":return"Arguments";default:return null==n||null===(t=n.match(/\[object\s+(.*?)]/))||void 0===t?void 0:t[1]}},k=function(e,t){if(j&&(null==e||!e[g]))throw new Error("resy's ".concat(t,"(...): Expected the 'store' argument should be generated by resy's createStore(...). ")+"Instead received: ".concat(A(e).toLocaleLowerCase(),"."))},P=function(e){var t=e.state,n=e.fnName,r=e.options,o=A(t);if(j&&"Object"!==o){var a=null==r?void 0:r.__useConciseState__,c=n;throw c||!0===a||(c="createStore"),c||!0!==a||(c="useConciseState"),new Error("resy's ".concat(c,"(...): takes an object of state variables to update or")+" a function which returns an object of state variables."+" Instead received: ".concat(o.toLocaleLowerCase()))}j&&null!=t&&t[g]&&console.error("Warning: resy's setState、syncUpdate(...): takes a store of generated by resy's createStore that's has no update significance!")},_=function(e,t){var n=A(e),r=A(t);if(j&&"Function"!==n)throw new Error("resy's subscribe(...): Expected the first optional 'listener' argument to be a function. "+"Instead received: ".concat(n.toLocaleLowerCase(),"."));if(j&&"Undefined"!==r&&"Array"!==r)throw new Error("resy's subscribe(...): Expected the last optional 'stateKeys' argument to be a array. "+"Instead received: ".concat(r.toLocaleLowerCase(),"."))},x=function(e){var t,n={},r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=v(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw a}}}}(e);try{for(r.s();!(t=r.n()).done;){var o=y(t.value,2),a=o[0],c=o[1];n[a]=c}}catch(e){r.e(e)}finally{r.f()}return n},U=function(e){return Object.keys(e).reduce((function(t,n){return t.set(n,e[n]),t}),new Map)},C=function(e,t){var n=!1,r=t&&(null==t?void 0:t.length)>0;return(r&&Object.keys(e).some((function(e){return t.includes(e)}))||!r)&&(n=!0),n},I=function(){var e=new Map,t=new Map,n=new Set,r=new Map;return r.set("isUpdating",null),r.set("willUpdating",null),r.set("deferEffectDestructorExecFlag",null),r.set("pushTask",(function(n,r,o){e.set(n,r),t.set(n,o)})),r.set("pushCallbackStack",(function(e,t,r){if(void 0!==r){!function(e){var t=A(e);if(j&&"Undefined"!==t&&"Function"!==t)throw new Error("resy's stateCallback(...): Expected the last optional 'callback' argument to be a function. "+"Instead received: ".concat(t.toLocaleLowerCase(),"."))}(r);var o=Object.assign({},x(e),t);n.add({nextState:o,callback:r})}})),r.set("flushTask",(function(){e.clear(),t.clear()})),r.set("getSchedulerQueue",(function(){return{taskDataMap:e,taskQueueMap:t,callbackStackSet:n}})),r},R=Symbol("classConnectStoreKey"),M=Symbol("classThisPointerStoresKey"),D=Symbol("classStateRefSetKey"),F=Symbol("classUnmountProcessingKey"),B=Symbol("classInitialStateRetrieveKey"),L=function(e,t){return Array.from(new Set(Object.keys(e).concat(Array.from(t.keys()))))},W=function(e,t){var n;"function"==typeof t&&(n=e,Object.keys(n).forEach((function(e){delete n[e]})),Object.entries(t()).forEach((function(t){var n=y(t,2),r=n[0],o=n[1];e[r]=o})))},N=function(e,t,n){W(e,n),L(e,t).forEach((function(n){O.call(e,n)?t.set(n,e[n]):t.delete(n)}))},T=function(e,t,n,r){n.get("canExec")&&(n.set("canExec",null),N(e,t,r))};function z(e,t,n,r,o,a,c,u,i){o.get("deferEffectDestructorExecFlag")||o.set("deferEffectDestructorExecFlag",Promise.resolve().then((function(){o.set("deferEffectDestructorExecFlag",null),r.get("counter")||c.size||function(e,t,n,r,o,a,c){var u=!a.size&&!r.get("counter");e.unmountRestore&&u&&"function"!=typeof c&&N(t,n,c),"function"==typeof c&&u&&o.set("canExec",!0)}(e,t,n,r,a,c,u),null==i||i()})))}var K=t.useSyncExternalStore,q=function(e,t,n,r,o,a,c,u,i,s){if(a.has(e))return a;var l=new Map,f=new Set;return l.set("subscribeOriginState",(function(l){return f.add(l),o.set("counter",o.get("counter")+1),function(){f.delete(l),o.set("counter",o.get("counter")-1),z(t,n,r,o,c,u,i,s,(function(){f.size||a.delete(e)}))}})),l.set("getOriginState",(function(){return r.get(e)})),l.set("useOriginState",(function(){return K(a.get(e).get("subscribeOriginState"),a.get(e).get("getOriginState"),a.get(e).get("getOriginState"))})),l.set("updater",(function(){f.forEach((function(e){e()}))})),a.set(e,l),a},V=function(e,t,n,r,o,a,c,u,i,s){return T(n,r,u,s),q(e,t,n,r,o,a,c,u,i,s).get(e).get("useOriginState")()};function H(e,t){return this[D].add(e),t.get(e)}var Q=function(e,t,n){null==n||n.forEach((function(r){var o;r.updater.isMounted(r)?(null===(o=r[D])||void 0===o?void 0:o.has(e))&&r.setState(u({},e,t)):n.delete(r)}))},G=function(e,t,n,r,o,a,c,u,i,s,l,f){f?n.delete(e):n.set(e,t),r.get("pushTask")(e,t,(function(){Q(e,t,s),q(e,o,a,n,c,u,r,i,s,l).get(e).get("updater")()}))},X=function(e,t,n,r){var o=e.get("getSchedulerQueue")(),a=o.taskDataMap,c=o.taskQueueMap,u=o.callbackStackSet;(a.size>0||u.size>0)&&!e.get("isUpdating")&&e.set("isUpdating",Promise.resolve().then((function(){e.set("isUpdating",null),e.set("willUpdating",null),w((function(){a.size>0&&c.forEach((function(e){e()}));var o,i,s=r.size>0?(o=a,i=new Map,o.forEach((function(e,t){i.set(t,e)})),i):void 0;if(e.get("flushTask")(),u.size>0&&(u.forEach((function(e){(0,e.callback)(e.nextState)})),u.clear()),r.size>0){var l=new Proxy({},{get:function(e,r){return"effectState"===r?x(s):"nextState"===r?x(n):"prevState"===r?x(t):void 0}});r.forEach((function(e){e(l)}))}}))})))},$=function(e,t,r){k(e,"useSubscription"),_(t,r);var o=n.useRef(null);o.current={listener:t,stateKeys:r},n.useEffect((function(){return e.subscribe((function(e){C(e.effectState,o.current.stateKeys)&&Promise.resolve(e).then((function(e){o.current.listener(e)}))}))}),[])},J=function(e,t,n,r){e.size>0&&!t.get("willUpdating")&&(t.set("willUpdating",!0),n.clear(),r.forEach((function(e,t){n.set(t,e)})))},Y=function(e,t){var r,o,a,c=void 0===e?{}:"function"==typeof e?e():e;!function(e){var t=A(e),n="Undefined"!==t,r=A(null==e?void 0:e.unmountRestore),o=A(null==e?void 0:e.__useConciseState__),a=A(null==e?void 0:e.namespace);if(j&&(n&&"Object"!==t||n&&"Object"===t&&("Boolean"!==r&&"Undefined"!==r||"Boolean"!==o&&"Undefined"!==o||"String"!==a&&"Undefined"!==a)))throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(t);var u=t?{__useConciseState__:null!==(r=t.__useConciseState__)&&void 0!==r?r:void 0,unmountRestore:null===(o=t.unmountRestore)||void 0===o||o,namespace:null!==(a=t.namespace)&&void 0!==a?a:void 0}:{unmountRestore:!0};P({state:c,options:u});var i=I(),s=(new Map).set("counter",0),l=new Map,f=U(c),b=U(c),y=new Set,d=new Map,v=new Set,m=function(t,n){J(y,i,b,f);var r=t;"function"==typeof t&&(r=t(x(f))),null!==r&&(P({state:r,fnName:"setState、syncUpdate"}),Object.keys(r).forEach((function(t){var n=r[t];Object.is(n,f.get(t))||G(t,n,f,i,u,c,s,d,l,v,e)}))),i.get("pushCallbackStack")(f,r,n),X(i,b,f,y)},E=function(t,n,r){return Object.is(n,f.get(t))||(J(y,i,b,f),G(t,n,f,i,u,c,s,d,l,v,e,r),X(i,b,f,y)),!0},k=new Map,M={set:function(e,t,n){return E(t,n)},deleteProperty:function(e,t){return E(t,void 0,!0)}},D=new Proxy(d,p({get:function(e,t,n){!function(e,t){j&&e!==t&&console.error("Warning: It's not recommended to set the store created by createStore as the prototype of some objects as the store internally hijacks the binding of this context for function properties!")}(n,D);var r=f.get(t);return k.get(t)||("function"!=typeof r?r:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(D,t)})}},M)),N=new Proxy(d,p({get:function(t,r){var o=f.get(r);if(j&&!k.has(r)&&n.useDebugValue(p({key:r,value:o},u.namespace?{namespace:u.namespace}:null)),"function"==typeof o){var a=V(r,u,c,f,s,d,i,l,v,e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.apply(D,t)}}return k.get(r)||V(r,u,c,f,s,d,i,l,v,e)}},M));k.set("setState",m),k.set("syncUpdate",(function(t,n){var r=t;"function"==typeof t&&(r=t(x(f))),m(r,n),null!==r&&w((function(){Object.keys(r).forEach((function(t){var n=r[t];Q(t,n,v),q(t,u,c,f,s,d,i,l,v,e).get(t).get("updater")()}))}))})),k.set("restore",(function(t){J(y,i,b,f),W(c,e);var n={};L(c,f).forEach((function(t){var r=c[t];Object.is(r,f.get(t))||(n[t]=r,G(t,r,f,i,u,c,s,d,l,v,e,!O.call(c,t)))})),i.get("pushCallbackStack")(f,n,t),X(i,b,f,y)})),k.set("subscribe",(function(e,t){_(e,t);var n=function(n){C(n.effectState,t)&&e(n)};return y.add(n),function(){return y.delete(n)}})),u.__useConciseState__?k.set("store",D):k.set("setOptions",(function(e){!function(e){var t=A(e),n=A(null==e?void 0:e.unmountRestore);if(j&&("Object"!==t||"Object"===t&&"Boolean"!==n))throw new Error("resy's setOptions(...): Expected the 'options' argument to be an object with a unmountRestore attribute."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(e),u.unmountRestore=e.unmountRestore}));return k.set("useStore",(function(){return N})),k.set("useSubscription",(function(e,t){$(D,e,t)})),k.set(h,N),k.set(g,g),k.set(R,(function(){var e=this;v.add(this);var t=new Proxy(d,p({get:function(n,r){if("useStore"===r)return function(){return t};var o=f.get(r);return k.get(r)||("function"!=typeof o?H.apply(e,[r,f]):function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return H.apply(e,[r,f]).apply(t,o)})}},M));return t})),k.set(F,(function(){v.delete(this),z(u,c,f,s,i,l,v,e)})),k.set(B,(function(){T(c,f,l,e)})),k.set(S,u.namespace),D};function Z(){var e=this,t=this.componentWillUnmount;this.componentWillUnmount=function(){null==t||t(),Promise.resolve().then((function(){e.updater.isMounted(e)||(e[D].clear(),e[M].forEach((function(t){t[F].apply(e)})))}))}}function ee(e){return k(e,"connectStore"),e[B](),this[M].add(e),this[R]=e[R],this[R]()}var te=function(){function e(t){var n;return a(this,e),u(n=o(this,e,[t]),D,new Set),u(n,R,void 0),u(n,M,new Set),Z.apply(n),n}return s(e,n.Component),c(e,[{key:"connectStore",value:function(e){return ee.apply(this,[e])}}])}();u(te,"displayName",void 0);var ne=function(){function e(t){var n;return a(this,e),u(n=o(this,e,[t]),D,new Set),u(n,R,void 0),u(n,M,new Set),Z.apply(n),n}return s(e,n.PureComponent),c(e,[{key:"connectStore",value:function(e){return ee.apply(this,[e])}}])}();u(ne,"displayName",void 0),exports.ComponentWithStore=te,exports.PureComponentWithStore=ne,exports.createStore=Y,exports.useConciseState=function(e){return n.useMemo((function(){return Y(e,{__useConciseState__:!0})}),[])[h]},exports.useStore=function(e){return k(e,"useStore"),e[h]},exports.useSubscription=$;
"use strict";var e=require("./platform.cjs"),t=require("use-sync-external-store/shim"),n=require("react");function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t,n){return t=i(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],i(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,c,u=[],i=!0,s=!1;try{if(a=(n=n.call(e)).next,0===t);else for(;!(i=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{if(!i&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw o}}return u}}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function v(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}var g=Symbol("regenerativeSystemKey"),m=Symbol("useStoreKey"),h=Symbol("storeNamespace"),S=process.env.NODE_ENV;S||console.error("NODE_ENV not set");var j="development"===S,_=e.unstable_batchedUpdates||function(e){return e()},w=Object.prototype.hasOwnProperty,O=Object.prototype.toString,E=function(e){var t,n=O.call(e);switch(n){case"[object Array]":return"Array";case"[object Object]":return"Object";case"[object String]":return"String";case"[object Number]":return"Number";case"[object Boolean]":return"Boolean";case"[object Set]":return"Set";case"[object Map]":return"Map";case"[object Function]":return"Function";case"[object Date]":return"Date";case"[object Symbol]":return"Symbol";case"[object WeakSet]":return"WeakSet";case"[object WeakMap]":return"WeakMap";case"[object RegExp]":return"RegExp";case"[object WeakRef]":return"WeakRef";case"[object BigInt]":return"BigInt";case"[object Null]":return"Null";case"[object Undefined]":return"Undefined";case"[object Promise]":return"Promise";case"[object AsyncFunction]":return"AsyncFunction";case"[object Array Iterator]":return"ArrayIterator";case"[object Set Iterator]":return"SetIterator";case"[object Map Iterator]":return"MapIterator";case"[object FormData]":return"FormData";case"[object Blob]":return"Blob";case"[object File]":return"File";case"[object Error]":return"Error";case"[object CustomEvent]":return"CustomEvent";case"[object Storage]":return"Storage";case"[object WebSocket]":return"WebSocket";case"[object ArrayBuffer]":return"ArrayBuffer";case"[object DataView]":return"DataView";case"[object Uint8Array]":return"Uint8Array";case"[object Int8Array]":return"Int8Array";case"[object Uint8ClampedArray]":return"Uint8ClampedArray";case"[object Int16Array]":return"Int16Array";case"[object Uint16Array]":return"Uint16Array";case"[object Int32Array]":return"Int32Array";case"[object Uint32Array]":return"Uint32Array";case"[object Float32Array]":return"Float32Array";case"[object Float64Array]":return"Float64Array";case"[object BigInt64Array]":return"BigInt64Array";case"[object BigUint64Array]":return"BigUint64Array";case"[object XMLHttpRequest]":return"XMLHttpRequest";case"[object Headers]":return"Headers";case"[object Request]":return"Request";case"[object Response]":return"Response";case"[object Window]":return"Window";case"[object Global]":case"[object global]":return"Global";case"[object Arguments]":return"Arguments";default:return null==n||null===(t=n.match(/\[object\s+(.*?)]/))||void 0===t?void 0:t[1]}},A=function(e,t){if(j&&(null==e||!e[g]))throw new Error("resy's ".concat(t,"(...): Expected the 'store' argument should be generated by resy's createStore(...). ")+"Instead received: ".concat(E(e).toLocaleLowerCase(),"."))},k=function(e){var t=e.state,n=e.fnName,r=e.options,o=E(t);if(j&&"Object"!==o){var a=null!=n?n:null==r?void 0:r.__functionName__;throw new Error("resy's ".concat(a,"(...): takes an object of state variables to update or")+" a function which returns an object of state variables."+" Instead received: ".concat(o.toLocaleLowerCase()))}j&&null!=t&&t[g]&&console.error("Warning: resy's setState、syncUpdate(...): takes a store of generated by resy's createStore that's has no update significance!")},x=function(e,t){var n=E(e),r=E(t);if(j&&"Function"!==n)throw new Error("resy's subscribe(...): Expected the first optional 'listener' argument to be a function. "+"Instead received: ".concat(n.toLocaleLowerCase(),"."));if(j&&"Undefined"!==r&&"Array"!==r)throw new Error("resy's subscribe(...): Expected the last optional 'stateKeys' argument to be a array. "+"Instead received: ".concat(r.toLocaleLowerCase(),"."))},M=function(e){var t,n={},r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=v(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw a}}}}(e);try{for(r.s();!(t=r.n()).done;){var o=y(t.value,2),a=o[0],c=o[1];n[a]=c}}catch(e){r.e(e)}finally{r.f()}return n},U=function(e){return Object.keys(e).reduce((function(t,n){return t.set(n,e[n]),t}),new Map)},P=function(e,t){var n=!1,r=t&&(null==t?void 0:t.length)>0;return(r&&Object.keys(e).some((function(e){return t.includes(e)}))||!r)&&(n=!0),n},I=function(){var e=new Map,t=new Map,n=new Set,r=new Map;return r.set("isUpdating",null),r.set("willUpdating",null),r.set("deferEffectDestructorExecFlag",null),r.set("pushTask",(function(n,r,o){e.set(n,r),t.set(n,o)})),r.set("pushCallbackStack",(function(e,t,r){if(void 0!==r){!function(e){var t=E(e);if(j&&"Undefined"!==t&&"Function"!==t)throw new Error("resy's stateCallback(...): Expected the last optional 'callback' argument to be a function. "+"Instead received: ".concat(t.toLocaleLowerCase(),"."))}(r);var o=Object.assign({},M(e),t);n.add({nextState:o,callback:r})}})),r.set("flushTask",(function(){e.clear(),t.clear()})),r.set("getSchedulerQueue",(function(){return{taskDataMap:e,taskQueueMap:t,callbackStackSet:n}})),r},C=Symbol("classConnectStoreKey"),R=Symbol("classThisPointerStoresKey"),D=Symbol("classStateRefSetKey"),B=Symbol("classUnmountProcessingKey"),N=Symbol("classInitialStateRetrieveKey"),F=function(e,t){return Array.from(new Set(Object.keys(e).concat(Array.from(t.keys()))))},L=function(e,t){var n;"function"==typeof t&&(n=e,Object.keys(n).forEach((function(e){delete n[e]})),Object.entries(t()).forEach((function(t){var n=y(t,2),r=n[0],o=n[1];e[r]=o})))},W=function(e,t,n){L(e,n),F(e,t).forEach((function(n){w.call(e,n)?t.set(n,e[n]):t.delete(n)}))},K=function(e,t,n,r){n.get("canExec")&&(n.set("canExec",null),W(e,t,r))};function T(e,t,n,r,o,a,c,u,i){o.get("deferEffectDestructorExecFlag")||o.set("deferEffectDestructorExecFlag",Promise.resolve().then((function(){o.set("deferEffectDestructorExecFlag",null),r.get("counter")||c.size||function(e,t,n,r,o,a,c){var u=!a.size&&!r.get("counter");e.unmountRestore&&u&&"function"!=typeof c&&W(t,n,c),"function"==typeof c&&u&&o.set("canExec",!0)}(e,t,n,r,a,c,u),null==i||i()})))}var z=t.useSyncExternalStore,V=function(e,t,n,r,o,a,c,u,i,s){if(a.has(e))return a;var l=new Map,f=new Set;return l.set("subscribe",(function(l){return f.add(l),o.set("counter",o.get("counter")+1),function(){f.delete(l),o.set("counter",o.get("counter")-1),T(t,n,r,o,c,u,i,s,(function(){f.size||a.delete(e)}))}})),l.set("getSnapshot",(function(){return r.get(e)})),l.set("useSyncExternalStore",(function(){return z(a.get(e).get("subscribe"),a.get(e).get("getSnapshot"),a.get(e).get("getSnapshot"))})),l.set("updater",(function(){f.forEach((function(e){e()}))})),a.set(e,l),a},q=function(e,t,n,r,o,a,c,u,i,s){return K(n,r,u,s),V(e,t,n,r,o,a,c,u,i,s).get(e).get("useSyncExternalStore")()};function H(e,t){return this[D].add(e),t.get(e)}var Q=function(e,t,n){null==n||n.forEach((function(r){var o;r.updater.isMounted(r)?(null===(o=r[D])||void 0===o?void 0:o.has(e))&&r.setState(u({},e,t)):n.delete(r)}))},G=function(e,t,n,r,o,a,c,u,i,s,l,f){f?n.delete(e):n.set(e,t),r.get("pushTask")(e,t,(function(){Q(e,t,s),V(e,o,a,n,c,u,r,i,s,l).get(e).get("updater")()}))},X=function(e,t,n,r){var o=e.get("getSchedulerQueue")(),a=o.taskDataMap,c=o.taskQueueMap,u=o.callbackStackSet;(a.size>0||u.size>0)&&!e.get("isUpdating")&&e.set("isUpdating",Promise.resolve().then((function(){e.set("isUpdating",null),e.set("willUpdating",null),_((function(){a.size>0&&c.forEach((function(e){e()}));var o,i,s=r.size>0?(o=a,i=new Map,o.forEach((function(e,t){i.set(t,e)})),i):void 0;if(e.get("flushTask")(),u.size>0&&(u.forEach((function(e){(0,e.callback)(e.nextState)})),u.clear()),r.size>0){var l=new Proxy({},{get:function(e,r){return"effectState"===r?M(s):"nextState"===r?M(n):"prevState"===r?M(t):void 0}});r.forEach((function(e){e(l)}))}}))})))},$=function(e,t,r){A(e,"useSubscription"),x(t,r);var o=n.useRef(null);if(o.current={listener:t,stateKeys:r},j){var a=e[h]?{namespace:e[h]}:null;n.useDebugValue(p({listener:t,stateKeys:r},a))}n.useEffect((function(){return e.subscribe((function(e){P(e.effectState,o.current.stateKeys)&&Promise.resolve(e).then((function(e){o.current.listener(e)}))}))}),[])},J=function(e,t,n,r){e.size>0&&!t.get("willUpdating")&&(t.set("willUpdating",!0),n.clear(),r.forEach((function(e,t){n.set(t,e)})))},Y=function(e,t){var r,o,a,c,u,i,s=void 0===e?{}:"function"==typeof e?e():e;!function(e){var t=E(e),n="Undefined"!==t,r=E(null==e?void 0:e.unmountRestore),o=E(null==e?void 0:e.__useConciseState__),a=E(null==e?void 0:e.namespace),c=E(null==e?void 0:e.__enableMacros__),u=E(null==e?void 0:e.enableMarcoActionStateful);if(j&&(n&&"Object"!==t||n&&"Object"===t&&("Boolean"!==r&&"Undefined"!==r||"Boolean"!==o&&"Undefined"!==o||"String"!==a&&"Undefined"!==a||"Boolean"!==c&&"Undefined"!==c||"Boolean"!==u&&"Undefined"!==u)))throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(t);var l={__useConciseState__:null!==(r=null==t?void 0:t.__useConciseState__)&&void 0!==r?r:void 0,unmountRestore:null===(o=null==t?void 0:t.unmountRestore)||void 0===o||o,namespace:null!==(a=null==t?void 0:t.namespace)&&void 0!==a?a:void 0,__enableMacros__:null!==(c=null==t?void 0:t.__enableMacros__)&&void 0!==c?c:void 0,enableMarcoActionStateful:null!==(u=null==t?void 0:t.enableMarcoActionStateful)&&void 0!==u?u:void 0,__functionName__:null!==(i=null==t?void 0:t.__functionName__)&&void 0!==i?i:Y.name};k({state:s,options:l});var f=I(),b=(new Map).set("counter",0),y=new Map,d=U(s),v=U(s),S=new Set,O=new Map,A=new Set,R=new Map;R.set(h,l.namespace);var D=function(t,n){J(S,f,v,d);var r=t;"function"==typeof t&&(r=t(M(d))),null!==r&&(k({state:r,fnName:"setState、syncUpdate"}),Object.keys(r).forEach((function(t){var n=r[t];Object.is(n,d.get(t))||G(t,n,d,f,l,s,b,O,y,A,e)}))),f.get("pushCallbackStack")(d,r,n),X(f,v,d,S)};R.set("setState",D),R.set("syncUpdate",(function(t,n){var r=t;"function"==typeof t&&(r=t(M(d))),D(r,n),null!==r&&_((function(){Object.keys(r).forEach((function(t){var n=r[t];Q(t,n,A),V(t,l,s,d,b,O,f,y,A,e).get(t).get("updater")()}))}))})),R.set("restore",(function(t){J(S,f,v,d),L(s,e);var n={};F(s,d).forEach((function(t){var r=s[t];Object.is(r,d.get(t))||(n[t]=r,G(t,r,d,f,l,s,b,O,y,A,e,!w.call(s,t)))})),f.get("pushCallbackStack")(d,n,t),X(f,v,d,S)})),R.set("subscribe",(function(e,t){x(e,t);var n=function(n){P(n.effectState,t)&&e(n)};return S.add(n),function(){return S.delete(n)}}));var W=function(t,n,r){return Object.is(n,d.get(t))||(J(S,f,v,d),G(t,n,d,f,l,s,b,O,y,A,e,r),X(f,v,d,S)),!0},z={set:function(e,t,n){return W(t,n)},deleteProperty:function(e,t){return W(t,void 0,!0)}},Z=function(e,t){var n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(ee,n)};return n.__bound__=!0,d.set(e,n),n},ee=new Proxy(d,p({get:function(e,t,n){!function(e,t){j&&e!==t&&console.error("Warning: It's not recommended to set the store created by createStore as the prototype of some objects as the store internally hijacks the binding of this context for function properties!")}(n,ee);var r=d.get(t);return"function"!=typeof r||r.__bound__?R.get(t)||r:Z(t,r)}},z)),te=new Proxy(d,p({get:function(t,r){var o=d.get(r),a=!R.has(r);if(a&&"function"!=typeof o)return j&&n.useDebugValue(p({key:r,value:o},l.namespace?{namespace:l.namespace}:null)),q(r,l,s,d,b,O,f,y,A,e);if(a&&"function"==typeof o){o.__bound__||Z(r,o);var c=!l.__enableMacros__||l.enableMarcoActionStateful,u=d.get(r);return c&&j&&n.useDebugValue(p({key:r,value:u},l.namespace?{namespace:l.namespace}:null)),c&&q(r,l,s,d,b,O,f,y,A,e),u}return R.get(r)}},z));(l.__useConciseState__||l.__enableMacros__)&&R.set("store",ee),R.set(m,te),R.set(g,g);R.set("setOptions",(function(e){!function(e){var t=E(e),n=E(null==e?void 0:e.unmountRestore);if(j&&("Object"!==t||"Object"===t&&"Boolean"!==n))throw new Error("resy's setOptions(...): Expected the 'options' argument to be an object with a unmountRestore attribute."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(e),l.unmountRestore=e.unmountRestore})),R.set("getOptions",(function(){return Object.assign({},l)}));R.set("useStore",(function(){return te})),R.set("useSubscription",(function(e,t){if(j){var r=l.namespace?{namespace:l.namespace}:null;n.useDebugValue(p({listener:e,stateKeys:t},r))}$(ee,e,t)}));return R.set(C,(function(){var e=this;A.add(this);var t=new Proxy(d,p({get:function(n,r){if("useStore"===r)return function(){return t};var o=d.get(r);return R.get(r)||("function"!=typeof o?H.apply(e,[r,d]):function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return H.apply(e,[r,d]).apply(t,o)})}},z));return t})),R.set(B,(function(){A.delete(this),T(l,s,d,b,f,y,A,e)})),R.set(N,(function(){K(s,d,y,e)})),ee},Z=function(e){return n.useMemo((function(){return Y(e,{__useConciseState__:!0,__functionName__:Z.name})}),[])[m]},ee=function(e,t){return Y(e,p(p({},t),{},{__enableMacros__:!0,__functionName__:ee.name})).useStore};function te(){var e=this,t=this.componentWillUnmount;this.componentWillUnmount=function(){null==t||t.apply(e),Promise.resolve().then((function(){e.updater.isMounted(e)||(e[D].clear(),e[R].forEach((function(t){t[B].apply(e)})))}))}}function ne(e){return A(e,"connectStore"),e[N](),this[R].add(e),this[C]=e[C],this[C]()}var re=function(){function e(t){var n;return a(this,e),u(n=o(this,e,[t]),D,new Set),u(n,C,void 0),u(n,R,new Set),te.apply(n),n}return s(e,n.Component),c(e,[{key:"connectStore",value:function(e){return ne.apply(this,[e])}}])}();u(re,"displayName",void 0);var oe=function(){function e(t){var n;return a(this,e),u(n=o(this,e,[t]),D,new Set),u(n,C,void 0),u(n,R,new Set),te.apply(n),n}return s(e,n.PureComponent),c(e,[{key:"connectStore",value:function(e){return ne.apply(this,[e])}}])}();u(oe,"displayName",void 0),exports.ComponentWithStore=re,exports.PureComponentWithStore=oe,exports.createStore=Y,exports.defineStore=ee,exports.useConciseState=Z,exports.useStore=function(e){return A(e,"useStore"),e[m]},exports.useSubscription=$;

@@ -5,3 +5,3 @@ /**

* created by liushanbao <1262300490@qq.com>
* (c) 2020-05-05-2024-10-14
* (c) 2020-05-05-2025-3-02
* Released under the MIT License.

@@ -17,3 +17,3 @@ */

type PrimitiveValueType = "Number" | "String" | "Boolean" | "Undefined" | "Null" | "Symbol";
type ComplexValueType = "Object" | "Function" | "Array" | "Date" | "RegExp" | "Map" | "Set" | "WeakMap" | "WeakSet" | "WeakRef" | "BigInt" | "Arguments" | "Promise" | "AsyncFunction" | "Array Iterator" | "FormData" | "Blob" | "File" | "Error" | "CustomEvent" | "Storage" | "WebSocket" | "ArrayBuffer" | "DataView" | "Uint8Array" | "Int8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "XMLHttpRequest" | "Headers" | "Request" | "Response" | "Window" | "Global";
type ComplexValueType = "Object" | "Function" | "Array" | "Date" | "RegExp" | "Map" | "Set" | "WeakMap" | "WeakSet" | "ArrayIterator" | "SetIterator" | "MapIterator" | "WeakRef" | "BigInt" | "Arguments" | "Promise" | "AsyncFunction" | "FormData" | "Blob" | "File" | "Error" | "CustomEvent" | "Storage" | "WebSocket" | "ArrayBuffer" | "DataView" | "Uint8Array" | "Int8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "XMLHttpRequest" | "Headers" | "Request" | "Response" | "Window" | "Global";
type NativeDataType = PrimitiveValueType | ComplexValueType;

@@ -38,3 +38,3 @@

/** Type of subscribe */
interface Subscribe<S extends PrimitiveState> {
type SubscribeType<S extends PrimitiveState> = {
/**

@@ -46,3 +46,3 @@ * @param listener

subscribe(listener: ListenerType<S>, stateKeys?: (keyof S)[]): Unsubscribe;
}
};
type SubscriptionRefType<S extends PrimitiveState> = {

@@ -58,3 +58,3 @@ listener: ListenerType<S>;

/** This is the data type returned by the class after connecting to the store */
type ClassStoreType<S extends PrimitiveState> = S & StoreCoreUtils<S> & Readonly<SetOptions>;
type ClassStoreType<S extends PrimitiveState> = S & StoreCoreUtils<S> & Readonly<SetOptionsType> & Readonly<GetOptionsType>;
type ClassConnectStoreType = {

@@ -81,18 +81,42 @@ [__CLASS_CONNECT_STORE_KEY__]<S extends PrimitiveState>(): ClassStoreType<S>;

* which helps identify specific stores and facilitates finding component elements during debugging.
* @default undefined
*/
readonly namespace?: string;
/**
* @description For the configuration options of defineStore,
* the function properties of defineStore can possess the capability to update and render state data.
* This configuration is not commonly used;
* it aims to maintain a certain level of openness and flexibility in its application.
* @default undefined
*/
readonly enableMarcoActionStateful?: boolean;
}
interface InnerStoreOptions extends StoreOptions {
/**
* @description Configuration for useConciseState hooks (Internal use, do not use externally)
* @default undefined
*/
readonly __useConciseState__?: boolean;
/**
* @description This feature is designed to be used with the defineStore function.
* It enables and optimizes various usage scenarios for stores defined using the defineStore macro.
* @default undefined
*/
readonly __enableMacros__?: boolean;
/**
* @description Call name of function, used for internal processing of error message prompts.
* @default "createStore"
*/
readonly __functionName__?: string;
}
/** Some of the core tool method types of store */
type StoreCoreUtils<S extends PrimitiveState> = Readonly<SetState<S> & SyncUpdate<S> & Restore<S> & Subscribe<S>>;
type StoreHookUtils<S extends PrimitiveState> = Readonly<UseStore<S> & UseSubscription<S>>;
type StoreCoreUtils<S extends PrimitiveState> = Readonly<SetStateType<S> & SyncUpdateType<S> & RestoreType<S> & SubscribeType<S>>;
type StoreHookUtils<S extends PrimitiveState> = Readonly<UseStoreType<S> & UseSubscriptionType<S>>;
/** Tool method type of store */
type StoreUtils<S extends PrimitiveState> = StoreCoreUtils<S> & StoreHookUtils<S> & Readonly<SetOptions>;
type StoreUtils<S extends PrimitiveState> = StoreCoreUtils<S> & StoreHookUtils<S> & Readonly<SetOptionsType> & Readonly<GetOptionsType>;
/** The type of store returned by createStore */
type Store<S extends PrimitiveState> = S & StoreUtils<S>;
type ConciseStoreCore<S extends PrimitiveState> = S & StoreCoreUtils<S> & StoreHookUtils<S>;
interface ConciseStoreHeart<S extends PrimitiveState> {
readonly store: ConciseStoreCore<S>;
interface StoreType<S extends PrimitiveState> {
readonly store: Store<S>;
}
/** Return type of useConciseState */
type ConciseStore<S extends PrimitiveState> = S & StoreCoreUtils<S> & ConciseStoreHeart<S>;
/** Update the data type of the parameter */

@@ -110,3 +134,3 @@ type State<S extends PrimitiveState> = Partial<S> | S | null;

/** Type of setState */
interface SetState<S extends PrimitiveState> {
type SetStateType<S extends PrimitiveState> = {
/**

@@ -117,3 +141,3 @@ * @param state

setState(state: SetStateAction<S>, callback?: StateCallback<S>): void;
}
};
/**

@@ -125,3 +149,3 @@ * Type of callback functions for setState, syncUpdate, and restore

/** Type of syncUpdate */
interface SyncUpdate<S extends PrimitiveState> {
type SyncUpdateType<S extends PrimitiveState> = {
/**

@@ -132,5 +156,5 @@ * @param state

syncUpdate(state: SetStateAction<S>, callback?: StateCallback<S>): void;
}
};
/** Type of restore */
interface Restore<S extends PrimitiveState> {
type RestoreType<S extends PrimitiveState> = {
/**

@@ -145,3 +169,3 @@ * @param callback

restore(callback?: StateCallback<S>): void;
}
};
/**

@@ -159,13 +183,36 @@ * Type of setOptions

*/
interface SetOptions {
type SetOptionsType = {
setOptions(options: Readonly<{
unmountRestore: boolean;
}>): void;
}
/** store.useStore() */
interface UseStore<S extends PrimitiveState> {
useStore(): Store<S>;
}
};
/**
* store.UseSubscription()
* @description When executed in conjunction with "setOptions",
* it allows users to make different coding decisions based on various configurations,
* while being aware of the current settings.
* 🌟 Different from the considerations for the parameter types of "setOptions",
* "getOptions" returns a configuration object for all settings.
* This is because these read-only settings do not affect code security,
* and the parameters for "setOptions" are only aimed at the "unmountRestore" configuration item.
* Providing all configuration items may also be for the convenience of subsequent internal coding considerations.
*/
type GetOptionsType = {
getOptions(): InnerStoreOptions;
};
/** type of useStore */
type UseStoreType<S extends PrimitiveState> = {
useStore(): ClassicStore<S>;
};
/**
* @description The store returned by `createStore`,
* which then calls the result returned by `useStore`,
* is referred to as the classical type of store.
*/
type ClassicStore<S extends PrimitiveState> = Omit<Store<S>, "useStore">;
/** A preprocessed store that is ready for immediate rendering */
type MacroStore<S extends PrimitiveState> = ClassicStore<S> & StoreType<S>;
/** The function type returned by definiteStore */
type UseMacroStore<S extends PrimitiveState> = () => MacroStore<S>;
/**
* type of useSubscription
* @description It`s advantage is that you only need to consider the data you want to subscribe to,

@@ -175,3 +222,3 @@ * rather than the psychological burden to consider whether the data reference inside the function can get the latest value.

*/
interface UseSubscription<S extends PrimitiveState> {
interface UseSubscriptionType<S extends PrimitiveState> {
useSubscription(listener: ListenerType<S>, stateKeys?: (keyof S)[]): void;

@@ -181,4 +228,4 @@ }

type InitialStateForbiddenKeys = keyof StoreUtils<PrimitiveState> | "store";
/** thisType type used to initialize store when initialState is a function */
type InitialStore<S extends PrimitiveState> = {
/** The type of this context in function properties (actions) within initialState. */
type StateThis<S extends PrimitiveState> = {
[K in keyof S]: K extends InitialStateForbiddenKeys ? never : S[K];

@@ -191,3 +238,3 @@ } & Store<S>;

[K in keyof S]: K extends InitialStateForbiddenKeys ? never : S[K];
} & ThisType<InitialStore<S>>;
} & ThisType<StateThis<S>>;
/** Type of initialize data */

@@ -222,3 +269,3 @@ type InitialState<S extends PrimitiveState> = (() => StateWithThisType<S>) | StateWithThisType<S>;

*/
declare const useStore: <S extends PrimitiveState>(store: Store<S> | ConciseStoreCore<S>) => S;
declare const useStore: <S extends PrimitiveState>(store: Store<S>) => ClassicStore<S>;
/**

@@ -239,7 +286,59 @@ * A concise version of useState

* @param initialState
* @return ConciseStore<S>
* @return MacroStore<S>
*/
declare const useConciseState: <S extends PrimitiveState>(initialState?: InitialState<S>) => ConciseStore<S>;
declare const useConciseState: <S extends PrimitiveState>(initialState?: InitialState<S>) => MacroStore<S>;
/**
* @description Define the preprocessed store type for the createStore macro,
* which essentially represents the return type of the useStore function.
*
* 🌟 This API primarily follows the macro definition convention from the C programming language,
* hence the use of "define" as a prefix for naming.
*
* 🌟 `defineStore` will render the functions within the store incapable of updating,
* unlike `createStore`, and they will merely serve as actions.
* If you have a specific reason to enable function properties with the capability to update rendering,
* you can turn it on through the configuration option "enableMarcoActionStateful".
*
* 🌟 In the future, `defineStore` will gradually replace `createStore` as the norm for usage,
* and it possesses more rationality.
* The existence of `defineStore` also implies that Resy's focus will shift towards hooks components,
* moving away from an adherence to class components.
*
* 🌟 `defineStore`, in fact, returns the `useStore` function,
* which on one hand reflects the characteristics of functional programming,
* and on the other hand, stems from React's restrictions on hook usage
*
* 😊 If React had no restrictions on hook usage,
* I would prefer to directly return the final store instead of redundantly calling `useStore()` again.
*
* @example
* ```tsx
* interface StateModel {
* count: number;
* increase(): void;
* }
*
* const useStore = defineStore<StateModel>({
* count: 0,
* increase() {
* this.count += 1;
* },
* });
*
* const App = () => {
* const { count, increase } = useStore();
*
* return (
* <>
* <p>count:{count}</p>
* <button onClick={increase}>increase</button>
* </>
* );
* };
* ```
*/
declare const defineStore: <S extends PrimitiveState>(initialState?: InitialState<S>, options?: StoreOptions) => UseMacroStore<S>;
/**
* @description Hook of subscribe

@@ -262,3 +361,3 @@ * It`s advantage is that you only need to consider the data you want to subscribe to,

[__CLASS_THIS_POINTER_STORES_KEY__]: Set<Store<any>>;
connectStore<S extends PrimitiveState>(store: Store<S> | ConciseStoreCore<S>): ClassStoreType<S>;
connectStore<S extends PrimitiveState>(store: Store<S>): ClassStoreType<S>;
}

@@ -275,5 +374,5 @@ /**

[__CLASS_THIS_POINTER_STORES_KEY__]: Set<Store<any>>;
connectStore<S extends PrimitiveState>(store: Store<S> | ConciseStoreCore<S>): ClassStoreType<S>;
connectStore<S extends PrimitiveState>(store: Store<S>): ClassStoreType<S>;
}
export { type AnyFn, type Callback, type ClassStoreType, type ComplexValueType, ComponentWithStore, type ConciseStore, type ConciseStoreCore, type ConciseStoreHeart, type InitialState, type InitialStateForbiddenKeys, type InitialStore, type ListenerParams, type ListenerType, type MapType, type NativeDataType, type PrimateForbiddenType, type PrimitiveState, type PrimitiveValueType, PureComponentWithStore, type Restore, type SetOptions, type SetState, type SetStateAction, type State, type StateCallback, type StateFnType, type StateWithThisType, type Store, type StoreCoreUtils, type StoreHookUtils, type StoreOptions, type StoreUtils, type Subscribe, type SubscriptionRefType, type SyncUpdate, type Unsubscribe, type UseStore, type ValueOf, createStore, useConciseState, useStore, useSubscription };
export { type AnyFn, type Callback, type ClassStoreType, type ClassicStore, type ComplexValueType, ComponentWithStore, type GetOptionsType, type InitialState, type InitialStateForbiddenKeys, type InnerStoreOptions, type ListenerParams, type ListenerType, type MacroStore, type MapType, type NativeDataType, type PrimateForbiddenType, type PrimitiveState, type PrimitiveValueType, PureComponentWithStore, type RestoreType, type SetOptionsType, type SetStateAction, type SetStateType, type State, type StateCallback, type StateFnType, type StateThis, type StateWithThisType, type Store, type StoreCoreUtils, type StoreHookUtils, type StoreOptions, type StoreType, type StoreUtils, type SubscribeType, type SubscriptionRefType, type SyncUpdateType, type Unsubscribe, type UseStoreType, type UseSubscriptionType, type ValueOf, createStore, defineStore, useConciseState, useStore, useSubscription };

@@ -1,4 +0,4 @@

import ReactPlatformExports from './platform.esm';
import { unstable_batchedUpdates } from './platform.esm';
import useSyncExternalStoreExports from 'use-sync-external-store/shim';
import { useRef, useEffect, useDebugValue, useMemo, Component, PureComponent } from 'react';
import { useRef, useDebugValue, useEffect, useMemo, Component, PureComponent } from 'react';

@@ -26,3 +26,3 @@ function _arrayLikeToArray(r, a) {

var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
}

@@ -32,3 +32,3 @@ }

return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
writable: !1
writable: false
}), e;

@@ -47,5 +47,5 @@ }

return n >= r.length ? {
done: !0
done: true
} : {
done: !1,
done: false,
value: r[n++]

@@ -63,4 +63,4 @@ };

var o,
a = !0,
u = !1;
a = true,
u = false;
return {

@@ -75,3 +75,3 @@ s: function () {

e: function (r) {
u = !0, o = r;
u = true, o = r;
},

@@ -90,5 +90,5 @@ f: function () {

value: t,
enumerable: !0,
configurable: !0,
writable: !0
enumerable: true,
configurable: true,
writable: true
}) : e[r] = t, e;

@@ -106,7 +106,7 @@ }

value: t,
writable: !0,
configurable: !0
writable: true,
configurable: true
}
}), Object.defineProperty(t, "prototype", {
writable: !1
writable: false
}), e && _setPrototypeOf(t, e);

@@ -130,8 +130,8 @@ }

a = [],
f = !0,
o = !1;
f = true,
o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
o = true, n = r;
} finally {

@@ -163,3 +163,3 @@ try {

var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
_defineProperty(e, r, t[r]);

@@ -189,3 +189,3 @@ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {

if (void 0 !== e) {
var i = e.call(t, r || "default");
var i = e.call(t, r);
if ("object" != typeof i) return i;

@@ -220,9 +220,2 @@ throw new TypeError("@@toPrimitive must return a primitive value.");

var __DEV__ = NODE_ENV === "development";
/**
* @description To be deprecated
* TODO It is anticipated that following the stabilization of React version 19,
* the use of `unstable_batchedUpdates` might be considered for discontinuation,
* given that these unstable APIs were already unsupported in React version 18.
*/
var unstable_batchedUpdates = ReactPlatformExports.unstable_batchedUpdates;
/** Batch processing safety shim */

@@ -241,2 +234,6 @@ var batchUpdateShimRun = function batchUpdateShimRun(fn) {

switch (type) {
case "[object Array]":
return "Array";
case "[object Object]":
return "Object";
case "[object String]":

@@ -248,6 +245,2 @@ return "String";

return "Boolean";
case "[object Object]":
return "Object";
case "[object Array]":
return "Array";
case "[object Set]":

@@ -282,3 +275,7 @@ return "Set";

case "[object Array Iterator]":
return "Array Iterator";
return "ArrayIterator";
case "[object Set Iterator]":
return "SetIterator";
case "[object Map Iterator]":
return "MapIterator";
case "[object FormData]":

@@ -345,13 +342,2 @@ return "FormData";

};
// const primitiveMap = new Map<PrimitiveValueType, PrimitiveValueType>(Object.entries({
// Number: "Number",
// String: "String",
// Boolean: "Boolean",
// Undefined: "Undefined",
// Null: "Null",
// Symbol: "Symbol",
// }) as any);
// export const isPrimitive = (value: unknown): boolean => {
// return primitiveMap.has(whatsType(value) as PrimitiveValueType);
// };

@@ -371,10 +357,3 @@ // Check whether the store is generated by Resy's createStore

if (__DEV__ && stateType !== "Object") {
var ucs = options === null || options === void 0 ? void 0 : options.__useConciseState__;
var fnNameTemp = fnName;
if (!fnNameTemp && ucs !== true) {
fnNameTemp = "createStore";
}
if (!fnNameTemp && ucs === true) {
fnNameTemp = "useConciseState";
}
var fnNameTemp = fnName !== null && fnName !== void 0 ? fnName : options === null || options === void 0 ? void 0 : options.__functionName__;
throw new Error("resy's ".concat(fnNameTemp, "(...): takes an object of state variables to update or") + " a function which returns an object of state variables." + " Instead received: ".concat(stateType.toLocaleLowerCase()));

@@ -393,3 +372,5 @@ }

var nsType = whatsType(options === null || options === void 0 ? void 0 : options.namespace);
if (__DEV__ && (optsExist && optionsType !== "Object" || optsExist && optionsType === "Object" && (urType !== "Boolean" && urType !== "Undefined" || ucsType !== "Boolean" && ucsType !== "Undefined" || nsType !== "String" && nsType !== "Undefined"))) {
var emType = whatsType(options === null || options === void 0 ? void 0 : options.__enableMacros__);
var emasType = whatsType(options === null || options === void 0 ? void 0 : options.enableMarcoActionStateful);
if (__DEV__ && (optsExist && optionsType !== "Object" || optsExist && optionsType === "Object" && (urType !== "Boolean" && urType !== "Undefined" || ucsType !== "Boolean" && ucsType !== "Undefined" || nsType !== "String" && nsType !== "Undefined" || emType !== "Boolean" && emType !== "Undefined" || emasType !== "Boolean" && emasType !== "Undefined"))) {
throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params." + " Instead received: ".concat(optionsType.toLocaleLowerCase(), "."));

@@ -684,9 +665,9 @@ }

var singleStoreChangeSet = new Set();
storeMapValue.set("subscribeOriginState", function (onOriginStateChange) {
storeMapValue.set("subscribe", function (onStoreChange) {
// If a component references the data, the update function will be added to singleStoreChangeSet
singleStoreChangeSet.add(onOriginStateChange);
singleStoreChangeSet.add(onStoreChange);
// Increment the reference count by 1 if the component is referenced
storeStateRefCounterMap.set("counter", storeStateRefCounterMap.get("counter") + 1);
return function () {
singleStoreChangeSet["delete"](onOriginStateChange);
singleStoreChangeSet["delete"](onStoreChange);
storeStateRefCounterMap.set("counter", storeStateRefCounterMap.get("counter") - 1);

@@ -701,7 +682,7 @@ deferRestoreProcessing(options, reducerState, stateMap, storeStateRefCounterMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState, function () {

});
storeMapValue.set("getOriginState", function () {
storeMapValue.set("getSnapshot", function () {
return stateMap.get(key);
});
storeMapValue.set("useOriginState", function () {
return useSyncExternalStore(storeMap.get(key).get("subscribeOriginState"), storeMap.get(key).get("getOriginState"), storeMap.get(key).get("getOriginState"));
storeMapValue.set("useSyncExternalStore", function () {
return useSyncExternalStore(storeMap.get(key).get("subscribe"), storeMap.get(key).get("getSnapshot"), storeMap.get(key).get("getSnapshot"));
});

@@ -723,3 +704,3 @@ storeMapValue.set("updater", function () {

initialStateRetrieve(reducerState, stateMap, initialFnCanExecMap, initialState);
return connectStore(key, options, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState).get(key).get("useOriginState")();
return connectStore(key, options, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState).get(key).get("useSyncExternalStore")();
};

@@ -873,2 +854,12 @@ /**

};
if (__DEV__) {
var store_namespace = store[__STORE_NAMESPACE__] ? {
namespace: store[__STORE_NAMESPACE__]
} : null;
// eslint-disable-next-line react-hooks/rules-of-hooks
useDebugValue(_objectSpread2({
listener: listener,
stateKeys: stateKeys
}, store_namespace));
}
useEffect(function () {

@@ -916,13 +907,15 @@ // Monitor the overall data changes of the store

*/
var createStore = function createStore(initialState, options) {
var _options$__useConcise, _options$unmountResto, _options$namespace;
var _createStore = function createStore(initialState, options) {
var _options$__useConcise, _options$unmountResto, _options$namespace, _options$__enableMacr, _options$enableMarcoA, _options$__functionNa;
/** ============================== For core constant ready start ============================== */
// Retrieve the reducerState
var reducerState = initialState === undefined ? {} : typeof initialState === "function" ? initialState() : initialState;
optionsErrorProcessing(options);
var optionsTemp = options ? {
__useConciseState__: (_options$__useConcise = options.__useConciseState__) !== null && _options$__useConcise !== void 0 ? _options$__useConcise : undefined,
unmountRestore: (_options$unmountResto = options.unmountRestore) !== null && _options$unmountResto !== void 0 ? _options$unmountResto : true,
namespace: (_options$namespace = options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : undefined
} : {
unmountRestore: true
var optionsTemp = {
__useConciseState__: (_options$__useConcise = options === null || options === void 0 ? void 0 : options.__useConciseState__) !== null && _options$__useConcise !== void 0 ? _options$__useConcise : undefined,
unmountRestore: (_options$unmountResto = options === null || options === void 0 ? void 0 : options.unmountRestore) !== null && _options$unmountResto !== void 0 ? _options$unmountResto : true,
namespace: (_options$namespace = options === null || options === void 0 ? void 0 : options.namespace) !== null && _options$namespace !== void 0 ? _options$namespace : undefined,
__enableMacros__: (_options$__enableMacr = options === null || options === void 0 ? void 0 : options.__enableMacros__) !== null && _options$__enableMacr !== void 0 ? _options$__enableMacr : undefined,
enableMarcoActionStateful: (_options$enableMarcoA = options === null || options === void 0 ? void 0 : options.enableMarcoActionStateful) !== null && _options$enableMarcoA !== void 0 ? _options$enableMarcoA : undefined,
__functionName__: (_options$__functionNa = options === null || options === void 0 ? void 0 : options.__functionName__) !== null && _options$__functionNa !== void 0 ? _options$__functionNa : _createStore.name
};

@@ -951,2 +944,12 @@ stateErrorProcessing({

var classThisPointerSet = new Set();
/**
* @description Map for additional related internal objects of store
* For example, some related functions or identifiers,
* such as setState, subscribe and internal identity __REGENERATIVE_SYSTEM_KEY__
*/
var externalMap = new Map();
/** ============================== For core constant ready end ============================== */
// for development tools
externalMap.set(__STORE_NAMESPACE__, optionsTemp.namespace);
/** ============================== For core utils use start ============================== */
var setState = function setState(state, callback) {

@@ -1024,7 +1027,8 @@ willUpdatingProcessing(listenerSet, schedulerProcessor, prevBatchState, stateMap);

};
// Change options configuration
var setOptions = function setOptions(options) {
setOptionsErrorProcessing(options);
optionsTemp.unmountRestore = options.unmountRestore;
};
externalMap.set("setState", setState);
externalMap.set("syncUpdate", syncUpdate);
externalMap.set("restore", restore);
externalMap.set("subscribe", subscribe);
/** ============================== For core utils use end ============================== */
/** ============================== For core render use start ============================== */
// Data updates for a single attribute

@@ -1039,8 +1043,2 @@ var singleUpdate = function singleUpdate(key, value, isDelete) {

};
/**
* @description Map for additional related internal objects of store
* For example, some related functions or identifiers,
* such as setState, subscribe and internal identity __REGENERATIVE_SYSTEM_KEY__
*/
var externalMap = new Map();
// Updated handler configuration for proxy

@@ -1056,22 +1054,34 @@ var proxySetHandler = {

};
var macroFnProcessing = function macroFnProcessing(key, value) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
var boundFn = function boundFn() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return value.apply(store, args);
};
boundFn.__bound__ = true;
stateMap.set(key, boundFn);
return boundFn;
};
// A proxy object with the capabilities of updating and data tracking.
var store = new Proxy(storeMap, _objectSpread2({
var store = new Proxy(stateMap, _objectSpread2({
get: function get(_, key, receiver) {
protoPointStoreErrorProcessing(receiver, store);
var value = stateMap.get(key);
return externalMap.get(key) || (typeof value !== "function" ? value : function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return value.apply(store, args);
});
if (typeof value === "function" && !value.__bound__) {
return macroFnProcessing(key, value);
}
return externalMap.get(key) || value;
}
}, proxySetHandler));
// Proxy of driver update re-render for useStore
var engineStore = new Proxy(storeMap, _objectSpread2({
var engineStore = new Proxy(stateMap, _objectSpread2({
get: function get(_, key) {
// Get the latest value
var value = stateMap.get(key);
if (__DEV__ && !externalMap.has(key)) {
var notExternal = !externalMap.has(key);
if (notExternal && typeof value !== "function") {
// eslint-disable-next-line react-hooks/rules-of-hooks
useDebugValue(_objectSpread2({
__DEV__ && useDebugValue(_objectSpread2({
key: key,

@@ -1082,32 +1092,55 @@ value: value

} : null));
return connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
}
if (typeof value === "function") {
// Invoke a function data hook to grant the ability to update and render function data.
var stateFnValue = connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return stateFnValue.apply(store, args);
};
if (notExternal && typeof value === "function") {
// Avoid memory redundancy waste caused by repeated bindings and maintain the function reference address unchanged.
if (!value.__bound__) {
macroFnProcessing(key, value);
}
var fnStateful = !optionsTemp.__enableMacros__ || optionsTemp.enableMarcoActionStateful;
var newValue = stateMap.get(key);
// eslint-disable-next-line react-hooks/rules-of-hooks
fnStateful && __DEV__ && useDebugValue(_objectSpread2({
key: key,
value: newValue
}, optionsTemp.namespace ? {
namespace: optionsTemp.namespace
} : null));
/**
* @description Enable function properties to have the ability to update rendering.
* Placing both the __bound__ and the stateMap's set operation before the connectHook
* can preemptively avoid the tearing synchronization handling inside useSyncExternalStore,
* resulting in twice the redundant rendering execution.
*/
fnStateful && connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return newValue;
}
return externalMap.get(key) || connectHook(key, optionsTemp, reducerState, stateMap, storeStateRefCounterMap, storeMap, schedulerProcessor, initialFnCanExecMap, classThisPointerSet, initialState);
return externalMap.get(key);
}
}, proxySetHandler));
externalMap.set("setState", setState);
externalMap.set("syncUpdate", syncUpdate);
externalMap.set("restore", restore);
externalMap.set("subscribe", subscribe);
if (optionsTemp.__useConciseState__) {
// Enable useConciseState to have data tracking capabilities through the store
// Enable useConciseState and defineStore to have data tracking capabilities through the store
if (optionsTemp.__useConciseState__ || optionsTemp.__enableMacros__) {
externalMap.set("store", store);
} else {
/**
* @description useConciseState should not possess the capability
* of the setOptions since local state control would become chaotic if there is local caching.
* Caching is more meaningful in the context of the entire store.
*/
externalMap.set("setOptions", setOptions);
}
/**
* @description Here, __USE_STORE_KEY__ is not placed under the branch where optionsTemp.__mode__ === "state",
* because computed needs the rendering capability of engineStore.
*/
externalMap.set(__USE_STORE_KEY__, engineStore);
externalMap.set(__REGENERATIVE_SYSTEM_KEY__, __REGENERATIVE_SYSTEM_KEY__);
/** ============================== For core render use end ============================== */
/** ============================== For operate options use start ============================== */
// Change options configuration
var setOptions = function setOptions(options) {
setOptionsErrorProcessing(options);
optionsTemp.unmountRestore = options.unmountRestore;
};
var getOptions = function getOptions() {
return Object.assign({}, optionsTemp);
};
externalMap.set("setOptions", setOptions);
externalMap.set("getOptions", getOptions);
/** ============================== For operate options use end ============================== */
/** ============================== For hook components use start ============================== */
/**
* It is convenient for store.useStore() to call directly

@@ -1121,4 +1154,18 @@ * 🌟 The reason why it is not changed to store.useStore

var useSubscription$1 = function useSubscription$1(listener, stateKeys) {
if (__DEV__) {
var store_namespace = optionsTemp.namespace ? {
namespace: optionsTemp.namespace
} : null;
// eslint-disable-next-line react-hooks/rules-of-hooks
useDebugValue(_objectSpread2({
listener: listener,
stateKeys: stateKeys
}, store_namespace));
}
useSubscription(store, listener, stateKeys);
};
externalMap.set("useStore", useStore);
externalMap.set("useSubscription", useSubscription$1);
/** ============================== For hook components use end ============================== */
/** ============================== For class components use start ============================== */
// Connecting this pointer of the class component (therefore, this cannot be an arrow function)

@@ -1129,3 +1176,3 @@ function classConnectStore() {

// Data agents for use by class components
var classEngineStore = new Proxy(storeMap, _objectSpread2({
var classEngineStore = new Proxy(stateMap, _objectSpread2({
get: function get(_, key) {

@@ -1140,4 +1187,4 @@ // Compatible with scenarios where both hook components and class components are used together.

: function () {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}

@@ -1159,11 +1206,3 @@ return connectClass.apply(_this, [key, stateMap]).apply(classEngineStore, args);

};
externalMap.set("useStore", useStore);
externalMap.set("useSubscription", useSubscription$1);
/**
* @description Here, __USE_STORE_KEY__ is not placed under the branch where optionsTemp.__mode__ === "state",
* because computed needs the rendering capability of engineStore.
*/
externalMap.set(__USE_STORE_KEY__, engineStore);
externalMap.set(__REGENERATIVE_SYSTEM_KEY__, __REGENERATIVE_SYSTEM_KEY__);
/**
* @description The reason why the three operation functions for class components

@@ -1178,3 +1217,3 @@ * — connect, classUnmountProcessing, and classInitialStateRetrieve

externalMap.set(__CLASS_INITIAL_STATE_RETRIEVE_KEY__, classInitialStateRetrieve);
externalMap.set(__STORE_NAMESPACE__, optionsTemp.namespace);
/** ============================== For class components use end ============================== */
return store;

@@ -1208,8 +1247,9 @@ };

* @param initialState
* @return ConciseStore<S>
* @return MacroStore<S>
*/
var useConciseState = function useConciseState(initialState) {
var _useConciseState = function useConciseState(initialState) {
return useMemo(function () {
return createStore(initialState, {
__useConciseState__: true
return _createStore(initialState, {
__useConciseState__: true,
__functionName__: _useConciseState.name
});

@@ -1220,2 +1260,59 @@ // eslint-disable-next-line react-hooks/exhaustive-deps

/**
* @description Define the preprocessed store type for the createStore macro,
* which essentially represents the return type of the useStore function.
*
* 🌟 This API primarily follows the macro definition convention from the C programming language,
* hence the use of "define" as a prefix for naming.
*
* 🌟 `defineStore` will render the functions within the store incapable of updating,
* unlike `createStore`, and they will merely serve as actions.
* If you have a specific reason to enable function properties with the capability to update rendering,
* you can turn it on through the configuration option "enableMarcoActionStateful".
*
* 🌟 In the future, `defineStore` will gradually replace `createStore` as the norm for usage,
* and it possesses more rationality.
* The existence of `defineStore` also implies that Resy's focus will shift towards hooks components,
* moving away from an adherence to class components.
*
* 🌟 `defineStore`, in fact, returns the `useStore` function,
* which on one hand reflects the characteristics of functional programming,
* and on the other hand, stems from React's restrictions on hook usage
*
* 😊 If React had no restrictions on hook usage,
* I would prefer to directly return the final store instead of redundantly calling `useStore()` again.
*
* @example
* ```tsx
* interface StateModel {
* count: number;
* increase(): void;
* }
*
* const useStore = defineStore<StateModel>({
* count: 0,
* increase() {
* this.count += 1;
* },
* });
*
* const App = () => {
* const { count, increase } = useStore();
*
* return (
* <>
* <p>count:{count}</p>
* <button onClick={increase}>increase</button>
* </>
* );
* };
* ```
*/
var _defineStore = function defineStore(initialState, options) {
return _createStore(initialState, _objectSpread2(_objectSpread2({}, options), {}, {
__enableMacros__: true,
__functionName__: _defineStore.name
})).useStore;
};
function constructorProcessing() {

@@ -1236,3 +1333,4 @@ var _this = this;

this.componentWillUnmount = function () {
instanceUnmount === null || instanceUnmount === void 0 || instanceUnmount();
// The original 'this' pointing cannot be missing
instanceUnmount === null || instanceUnmount === void 0 || instanceUnmount.apply(_this);
/**

@@ -1326,2 +1424,2 @@ * @description The strict mode of class components does not provide accurate predictability

export { ComponentWithStore, PureComponentWithStore, createStore, useConciseState, useStore, useSubscription };
export { ComponentWithStore, PureComponentWithStore, _createStore as createStore, _defineStore as defineStore, _useConciseState as useConciseState, useStore, useSubscription };

@@ -1,1 +0,1 @@

import e from"./platform.esm";import t from"use-sync-external-store/shim";import{useRef as n,useEffect as r,useDebugValue as o,useMemo as a,Component as c,PureComponent as u}from"react";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t,n){return t=b(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,n||[],b(e).constructor):t.apply(e,n))}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,j(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(d=function(){return!!e})()}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,c,u=[],i=!0,s=!1;try{if(a=(n=n.call(e)).next,0===t);else for(;!(i=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{if(!i&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw o}}return u}}(e,t)||S(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}var w=Symbol("regenerativeSystemKey"),O=Symbol("useStoreKey"),E=Symbol("storeNamespace"),A=process.env.NODE_ENV;A||console.error("NODE_ENV not set");var k="development"===A,_=e.unstable_batchedUpdates||function(e){return e()},U=Object.prototype.hasOwnProperty,P=Object.prototype.toString,x=function(e){var t,n=P.call(e);switch(n){case"[object String]":return"String";case"[object Number]":return"Number";case"[object Boolean]":return"Boolean";case"[object Object]":return"Object";case"[object Array]":return"Array";case"[object Set]":return"Set";case"[object Map]":return"Map";case"[object Function]":return"Function";case"[object Date]":return"Date";case"[object Symbol]":return"Symbol";case"[object WeakSet]":return"WeakSet";case"[object WeakMap]":return"WeakMap";case"[object RegExp]":return"RegExp";case"[object WeakRef]":return"WeakRef";case"[object BigInt]":return"BigInt";case"[object Null]":return"Null";case"[object Undefined]":return"Undefined";case"[object Promise]":return"Promise";case"[object AsyncFunction]":return"AsyncFunction";case"[object Array Iterator]":return"Array Iterator";case"[object FormData]":return"FormData";case"[object Blob]":return"Blob";case"[object File]":return"File";case"[object Error]":return"Error";case"[object CustomEvent]":return"CustomEvent";case"[object Storage]":return"Storage";case"[object WebSocket]":return"WebSocket";case"[object ArrayBuffer]":return"ArrayBuffer";case"[object DataView]":return"DataView";case"[object Uint8Array]":return"Uint8Array";case"[object Int8Array]":return"Int8Array";case"[object Uint8ClampedArray]":return"Uint8ClampedArray";case"[object Int16Array]":return"Int16Array";case"[object Uint16Array]":return"Uint16Array";case"[object Int32Array]":return"Int32Array";case"[object Uint32Array]":return"Uint32Array";case"[object Float32Array]":return"Float32Array";case"[object Float64Array]":return"Float64Array";case"[object BigInt64Array]":return"BigInt64Array";case"[object BigUint64Array]":return"BigUint64Array";case"[object XMLHttpRequest]":return"XMLHttpRequest";case"[object Headers]":return"Headers";case"[object Request]":return"Request";case"[object Response]":return"Response";case"[object Window]":return"Window";case"[object Global]":case"[object global]":return"Global";case"[object Arguments]":return"Arguments";default:return null==n||null===(t=n.match(/\[object\s+(.*?)]/))||void 0===t?void 0:t[1]}},I=function(e,t){if(k&&(null==e||!e[w]))throw new Error("resy's ".concat(t,"(...): Expected the 'store' argument should be generated by resy's createStore(...). ")+"Instead received: ".concat(x(e).toLocaleLowerCase(),"."))},C=function(e){var t=e.state,n=e.fnName,r=e.options,o=x(t);if(k&&"Object"!==o){var a=null==r?void 0:r.__useConciseState__,c=n;throw c||!0===a||(c="createStore"),c||!0!==a||(c="useConciseState"),new Error("resy's ".concat(c,"(...): takes an object of state variables to update or")+" a function which returns an object of state variables."+" Instead received: ".concat(o.toLocaleLowerCase()))}k&&null!=t&&t[w]&&console.error("Warning: resy's setState、syncUpdate(...): takes a store of generated by resy's createStore that's has no update significance!")},R=function(e,t){var n=x(e),r=x(t);if(k&&"Function"!==n)throw new Error("resy's subscribe(...): Expected the first optional 'listener' argument to be a function. "+"Instead received: ".concat(n.toLocaleLowerCase(),"."));if(k&&"Undefined"!==r&&"Array"!==r)throw new Error("resy's subscribe(...): Expected the last optional 'stateKeys' argument to be a array. "+"Instead received: ".concat(r.toLocaleLowerCase(),"."))},M=function(e){var t,n={},r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=S(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw a}}}}(e);try{for(r.s();!(t=r.n()).done;){var o=m(t.value,2),a=o[0],c=o[1];n[a]=c}}catch(e){r.e(e)}finally{r.f()}return n},D=function(e){return Object.keys(e).reduce((function(t,n){return t.set(n,e[n]),t}),new Map)},F=function(e,t){var n=!1,r=t&&(null==t?void 0:t.length)>0;return(r&&Object.keys(e).some((function(e){return t.includes(e)}))||!r)&&(n=!0),n},B=function(){var e=new Map,t=new Map,n=new Set,r=new Map;return r.set("isUpdating",null),r.set("willUpdating",null),r.set("deferEffectDestructorExecFlag",null),r.set("pushTask",(function(n,r,o){e.set(n,r),t.set(n,o)})),r.set("pushCallbackStack",(function(e,t,r){if(void 0!==r){!function(e){var t=x(e);if(k&&"Undefined"!==t&&"Function"!==t)throw new Error("resy's stateCallback(...): Expected the last optional 'callback' argument to be a function. "+"Instead received: ".concat(t.toLocaleLowerCase(),"."))}(r);var o=Object.assign({},M(e),t);n.add({nextState:o,callback:r})}})),r.set("flushTask",(function(){e.clear(),t.clear()})),r.set("getSchedulerQueue",(function(){return{taskDataMap:e,taskQueueMap:t,callbackStackSet:n}})),r},L=Symbol("classConnectStoreKey"),N=Symbol("classThisPointerStoresKey"),W=Symbol("classStateRefSetKey"),T=Symbol("classUnmountProcessingKey"),z=Symbol("classInitialStateRetrieveKey"),K=function(e,t){return Array.from(new Set(Object.keys(e).concat(Array.from(t.keys()))))},q=function(e,t){var n;"function"==typeof t&&(n=e,Object.keys(n).forEach((function(e){delete n[e]})),Object.entries(t()).forEach((function(t){var n=m(t,2),r=n[0],o=n[1];e[r]=o})))},H=function(e,t,n){q(e,n),K(e,t).forEach((function(n){U.call(e,n)?t.set(n,e[n]):t.delete(n)}))},Q=function(e,t,n,r){n.get("canExec")&&(n.set("canExec",null),H(e,t,r))};function V(e,t,n,r,o,a,c,u,i){o.get("deferEffectDestructorExecFlag")||o.set("deferEffectDestructorExecFlag",Promise.resolve().then((function(){o.set("deferEffectDestructorExecFlag",null),r.get("counter")||c.size||function(e,t,n,r,o,a,c){var u=!a.size&&!r.get("counter");e.unmountRestore&&u&&"function"!=typeof c&&H(t,n,c),"function"==typeof c&&u&&o.set("canExec",!0)}(e,t,n,r,a,c,u),null==i||i()})))}var G=t.useSyncExternalStore,X=function(e,t,n,r,o,a,c,u,i,s){if(a.has(e))return a;var f=new Map,l=new Set;return f.set("subscribeOriginState",(function(f){return l.add(f),o.set("counter",o.get("counter")+1),function(){l.delete(f),o.set("counter",o.get("counter")-1),V(t,n,r,o,c,u,i,s,(function(){l.size||a.delete(e)}))}})),f.set("getOriginState",(function(){return r.get(e)})),f.set("useOriginState",(function(){return G(a.get(e).get("subscribeOriginState"),a.get(e).get("getOriginState"),a.get(e).get("getOriginState"))})),f.set("updater",(function(){l.forEach((function(e){e()}))})),a.set(e,f),a},$=function(e,t,n,r,o,a,c,u,i,s){return Q(n,r,u,s),X(e,t,n,r,o,a,c,u,i,s).get(e).get("useOriginState")()};function J(e,t){return this[W].add(e),t.get(e)}var Y=function(e,t,n){null==n||n.forEach((function(r){var o;r.updater.isMounted(r)?(null===(o=r[W])||void 0===o?void 0:o.has(e))&&r.setState(p({},e,t)):n.delete(r)}))},Z=function(e,t,n,r,o,a,c,u,i,s,f,l){l?n.delete(e):n.set(e,t),r.get("pushTask")(e,t,(function(){Y(e,t,s),X(e,o,a,n,c,u,r,i,s,f).get(e).get("updater")()}))},ee=function(e,t,n,r){var o=e.get("getSchedulerQueue")(),a=o.taskDataMap,c=o.taskQueueMap,u=o.callbackStackSet;(a.size>0||u.size>0)&&!e.get("isUpdating")&&e.set("isUpdating",Promise.resolve().then((function(){e.set("isUpdating",null),e.set("willUpdating",null),_((function(){a.size>0&&c.forEach((function(e){e()}));var o,i,s=r.size>0?(o=a,i=new Map,o.forEach((function(e,t){i.set(t,e)})),i):void 0;if(e.get("flushTask")(),u.size>0&&(u.forEach((function(e){(0,e.callback)(e.nextState)})),u.clear()),r.size>0){var f=new Proxy({},{get:function(e,r){return"effectState"===r?M(s):"nextState"===r?M(n):"prevState"===r?M(t):void 0}});r.forEach((function(e){e(f)}))}}))})))},te=function(e,t,o){I(e,"useSubscription"),R(t,o);var a=n(null);a.current={listener:t,stateKeys:o},r((function(){return e.subscribe((function(e){F(e.effectState,a.current.stateKeys)&&Promise.resolve(e).then((function(e){a.current.listener(e)}))}))}),[])},ne=function(e,t,n,r){e.size>0&&!t.get("willUpdating")&&(t.set("willUpdating",!0),n.clear(),r.forEach((function(e,t){n.set(t,e)})))},re=function(e,t){var n,r,a,c=void 0===e?{}:"function"==typeof e?e():e;!function(e){var t=x(e),n="Undefined"!==t,r=x(null==e?void 0:e.unmountRestore),o=x(null==e?void 0:e.__useConciseState__),a=x(null==e?void 0:e.namespace);if(k&&(n&&"Object"!==t||n&&"Object"===t&&("Boolean"!==r&&"Undefined"!==r||"Boolean"!==o&&"Undefined"!==o||"String"!==a&&"Undefined"!==a)))throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(t);var u=t?{__useConciseState__:null!==(n=t.__useConciseState__)&&void 0!==n?n:void 0,unmountRestore:null===(r=t.unmountRestore)||void 0===r||r,namespace:null!==(a=t.namespace)&&void 0!==a?a:void 0}:{unmountRestore:!0};C({state:c,options:u});var i=B(),s=(new Map).set("counter",0),f=new Map,l=D(c),p=D(c),b=new Set,y=new Map,d=new Set,v=function(t,n){ne(b,i,p,l);var r=t;"function"==typeof t&&(r=t(M(l))),null!==r&&(C({state:r,fnName:"setState、syncUpdate"}),Object.keys(r).forEach((function(t){var n=r[t];Object.is(n,l.get(t))||Z(t,n,l,i,u,c,s,y,f,d,e)}))),i.get("pushCallbackStack")(l,r,n),ee(i,p,l,b)},h=function(t,n,r){return Object.is(n,l.get(t))||(ne(b,i,p,l),Z(t,n,l,i,u,c,s,y,f,d,e,r),ee(i,p,l,b)),!0},m=new Map,j={set:function(e,t,n){return h(t,n)},deleteProperty:function(e,t){return h(t,void 0,!0)}},S=new Proxy(y,g({get:function(e,t,n){!function(e,t){k&&e!==t&&console.error("Warning: It's not recommended to set the store created by createStore as the prototype of some objects as the store internally hijacks the binding of this context for function properties!")}(n,S);var r=l.get(t);return m.get(t)||("function"!=typeof r?r:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(S,t)})}},j)),A=new Proxy(y,g({get:function(t,n){var r=l.get(n);if(k&&!m.has(n)&&o(g({key:n,value:r},u.namespace?{namespace:u.namespace}:null)),"function"==typeof r){var a=$(n,u,c,l,s,y,i,f,d,e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.apply(S,t)}}return m.get(n)||$(n,u,c,l,s,y,i,f,d,e)}},j));m.set("setState",v),m.set("syncUpdate",(function(t,n){var r=t;"function"==typeof t&&(r=t(M(l))),v(r,n),null!==r&&_((function(){Object.keys(r).forEach((function(t){var n=r[t];Y(t,n,d),X(t,u,c,l,s,y,i,f,d,e).get(t).get("updater")()}))}))})),m.set("restore",(function(t){ne(b,i,p,l),q(c,e);var n={};K(c,l).forEach((function(t){var r=c[t];Object.is(r,l.get(t))||(n[t]=r,Z(t,r,l,i,u,c,s,y,f,d,e,!U.call(c,t)))})),i.get("pushCallbackStack")(l,n,t),ee(i,p,l,b)})),m.set("subscribe",(function(e,t){R(e,t);var n=function(n){F(n.effectState,t)&&e(n)};return b.add(n),function(){return b.delete(n)}})),u.__useConciseState__?m.set("store",S):m.set("setOptions",(function(e){!function(e){var t=x(e),n=x(null==e?void 0:e.unmountRestore);if(k&&("Object"!==t||"Object"===t&&"Boolean"!==n))throw new Error("resy's setOptions(...): Expected the 'options' argument to be an object with a unmountRestore attribute."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(e),u.unmountRestore=e.unmountRestore}));return m.set("useStore",(function(){return A})),m.set("useSubscription",(function(e,t){te(S,e,t)})),m.set(O,A),m.set(w,w),m.set(L,(function(){var e=this;d.add(this);var t=new Proxy(y,g({get:function(n,r){if("useStore"===r)return function(){return t};var o=l.get(r);return m.get(r)||("function"!=typeof o?J.apply(e,[r,l]):function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return J.apply(e,[r,l]).apply(t,o)})}},j));return t})),m.set(T,(function(){d.delete(this),V(u,c,l,s,i,f,d,e)})),m.set(z,(function(){Q(c,l,f,e)})),m.set(E,u.namespace),S},oe=function(e){return I(e,"useStore"),e[O]},ae=function(e){return a((function(){return re(e,{__useConciseState__:!0})}),[])[O]};function ce(){var e=this,t=this.componentWillUnmount;this.componentWillUnmount=function(){null==t||t(),Promise.resolve().then((function(){e.updater.isMounted(e)||(e[W].clear(),e[N].forEach((function(t){t[T].apply(e)})))}))}}function ue(e){return I(e,"connectStore"),e[z](),this[N].add(e),this[L]=e[L],this[L]()}var ie=function(){function e(t){var n;return f(this,e),p(n=s(this,e,[t]),W,new Set),p(n,L,void 0),p(n,N,new Set),ce.apply(n),n}return y(e,c),l(e,[{key:"connectStore",value:function(e){return ue.apply(this,[e])}}])}();p(ie,"displayName",void 0);var se=function(){function e(t){var n;return f(this,e),p(n=s(this,e,[t]),W,new Set),p(n,L,void 0),p(n,N,new Set),ce.apply(n),n}return y(e,u),l(e,[{key:"connectStore",value:function(e){return ue.apply(this,[e])}}])}();p(se,"displayName",void 0);export{ie as ComponentWithStore,se as PureComponentWithStore,re as createStore,ae as useConciseState,oe as useStore,te as useSubscription};
import{unstable_batchedUpdates as e}from"./platform.esm";import t from"use-sync-external-store/shim";import{useRef as n,useDebugValue as r,useEffect as o,useMemo as a,Component as c,PureComponent as u}from"react";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t,n){return t=p(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,n||[],p(e).constructor):t.apply(e,n))}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,S(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(d=function(){return!!e})()}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,c,u=[],i=!0,s=!1;try{if(a=(n=n.call(e)).next,0===t);else for(;!(i=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{if(!i&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw o}}return u}}(e,t)||j(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function j(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}var w=Symbol("regenerativeSystemKey"),_=Symbol("useStoreKey"),O=Symbol("storeNamespace"),E=process.env.NODE_ENV;E||console.error("NODE_ENV not set");var A="development"===E,k=e||function(e){return e()},M=Object.prototype.hasOwnProperty,U=Object.prototype.toString,P=function(e){var t,n=U.call(e);switch(n){case"[object Array]":return"Array";case"[object Object]":return"Object";case"[object String]":return"String";case"[object Number]":return"Number";case"[object Boolean]":return"Boolean";case"[object Set]":return"Set";case"[object Map]":return"Map";case"[object Function]":return"Function";case"[object Date]":return"Date";case"[object Symbol]":return"Symbol";case"[object WeakSet]":return"WeakSet";case"[object WeakMap]":return"WeakMap";case"[object RegExp]":return"RegExp";case"[object WeakRef]":return"WeakRef";case"[object BigInt]":return"BigInt";case"[object Null]":return"Null";case"[object Undefined]":return"Undefined";case"[object Promise]":return"Promise";case"[object AsyncFunction]":return"AsyncFunction";case"[object Array Iterator]":return"ArrayIterator";case"[object Set Iterator]":return"SetIterator";case"[object Map Iterator]":return"MapIterator";case"[object FormData]":return"FormData";case"[object Blob]":return"Blob";case"[object File]":return"File";case"[object Error]":return"Error";case"[object CustomEvent]":return"CustomEvent";case"[object Storage]":return"Storage";case"[object WebSocket]":return"WebSocket";case"[object ArrayBuffer]":return"ArrayBuffer";case"[object DataView]":return"DataView";case"[object Uint8Array]":return"Uint8Array";case"[object Int8Array]":return"Int8Array";case"[object Uint8ClampedArray]":return"Uint8ClampedArray";case"[object Int16Array]":return"Int16Array";case"[object Uint16Array]":return"Uint16Array";case"[object Int32Array]":return"Int32Array";case"[object Uint32Array]":return"Uint32Array";case"[object Float32Array]":return"Float32Array";case"[object Float64Array]":return"Float64Array";case"[object BigInt64Array]":return"BigInt64Array";case"[object BigUint64Array]":return"BigUint64Array";case"[object XMLHttpRequest]":return"XMLHttpRequest";case"[object Headers]":return"Headers";case"[object Request]":return"Request";case"[object Response]":return"Response";case"[object Window]":return"Window";case"[object Global]":case"[object global]":return"Global";case"[object Arguments]":return"Arguments";default:return null==n||null===(t=n.match(/\[object\s+(.*?)]/))||void 0===t?void 0:t[1]}},x=function(e,t){if(A&&(null==e||!e[w]))throw new Error("resy's ".concat(t,"(...): Expected the 'store' argument should be generated by resy's createStore(...). ")+"Instead received: ".concat(P(e).toLocaleLowerCase(),"."))},I=function(e){var t=e.state,n=e.fnName,r=e.options,o=P(t);if(A&&"Object"!==o){var a=null!=n?n:null==r?void 0:r.__functionName__;throw new Error("resy's ".concat(a,"(...): takes an object of state variables to update or")+" a function which returns an object of state variables."+" Instead received: ".concat(o.toLocaleLowerCase()))}A&&null!=t&&t[w]&&console.error("Warning: resy's setState、syncUpdate(...): takes a store of generated by resy's createStore that's has no update significance!")},C=function(e,t){var n=P(e),r=P(t);if(A&&"Function"!==n)throw new Error("resy's subscribe(...): Expected the first optional 'listener' argument to be a function. "+"Instead received: ".concat(n.toLocaleLowerCase(),"."));if(A&&"Undefined"!==r&&"Array"!==r)throw new Error("resy's subscribe(...): Expected the last optional 'stateKeys' argument to be a array. "+"Instead received: ".concat(r.toLocaleLowerCase(),"."))},R=function(e){var t,n={},r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=j(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw a}}}}(e);try{for(r.s();!(t=r.n()).done;){var o=h(t.value,2),a=o[0],c=o[1];n[a]=c}}catch(e){r.e(e)}finally{r.f()}return n},B=function(e){return Object.keys(e).reduce((function(t,n){return t.set(n,e[n]),t}),new Map)},D=function(e,t){var n=!1,r=t&&(null==t?void 0:t.length)>0;return(r&&Object.keys(e).some((function(e){return t.includes(e)}))||!r)&&(n=!0),n},N=function(){var e=new Map,t=new Map,n=new Set,r=new Map;return r.set("isUpdating",null),r.set("willUpdating",null),r.set("deferEffectDestructorExecFlag",null),r.set("pushTask",(function(n,r,o){e.set(n,r),t.set(n,o)})),r.set("pushCallbackStack",(function(e,t,r){if(void 0!==r){!function(e){var t=P(e);if(A&&"Undefined"!==t&&"Function"!==t)throw new Error("resy's stateCallback(...): Expected the last optional 'callback' argument to be a function. "+"Instead received: ".concat(t.toLocaleLowerCase(),"."))}(r);var o=Object.assign({},R(e),t);n.add({nextState:o,callback:r})}})),r.set("flushTask",(function(){e.clear(),t.clear()})),r.set("getSchedulerQueue",(function(){return{taskDataMap:e,taskQueueMap:t,callbackStackSet:n}})),r},F=Symbol("classConnectStoreKey"),L=Symbol("classThisPointerStoresKey"),W=Symbol("classStateRefSetKey"),K=Symbol("classUnmountProcessingKey"),T=Symbol("classInitialStateRetrieveKey"),z=function(e,t){return Array.from(new Set(Object.keys(e).concat(Array.from(t.keys()))))},q=function(e,t){var n;"function"==typeof t&&(n=e,Object.keys(n).forEach((function(e){delete n[e]})),Object.entries(t()).forEach((function(t){var n=h(t,2),r=n[0],o=n[1];e[r]=o})))},H=function(e,t,n){q(e,n),z(e,t).forEach((function(n){M.call(e,n)?t.set(n,e[n]):t.delete(n)}))},Q=function(e,t,n,r){n.get("canExec")&&(n.set("canExec",null),H(e,t,r))};function V(e,t,n,r,o,a,c,u,i){o.get("deferEffectDestructorExecFlag")||o.set("deferEffectDestructorExecFlag",Promise.resolve().then((function(){o.set("deferEffectDestructorExecFlag",null),r.get("counter")||c.size||function(e,t,n,r,o,a,c){var u=!a.size&&!r.get("counter");e.unmountRestore&&u&&"function"!=typeof c&&H(t,n,c),"function"==typeof c&&u&&o.set("canExec",!0)}(e,t,n,r,a,c,u),null==i||i()})))}var G=t.useSyncExternalStore,X=function(e,t,n,r,o,a,c,u,i,s){if(a.has(e))return a;var l=new Map,f=new Set;return l.set("subscribe",(function(l){return f.add(l),o.set("counter",o.get("counter")+1),function(){f.delete(l),o.set("counter",o.get("counter")-1),V(t,n,r,o,c,u,i,s,(function(){f.size||a.delete(e)}))}})),l.set("getSnapshot",(function(){return r.get(e)})),l.set("useSyncExternalStore",(function(){return G(a.get(e).get("subscribe"),a.get(e).get("getSnapshot"),a.get(e).get("getSnapshot"))})),l.set("updater",(function(){f.forEach((function(e){e()}))})),a.set(e,l),a},$=function(e,t,n,r,o,a,c,u,i,s){return Q(n,r,u,s),X(e,t,n,r,o,a,c,u,i,s).get(e).get("useSyncExternalStore")()};function J(e,t){return this[W].add(e),t.get(e)}var Y=function(e,t,n){null==n||n.forEach((function(r){var o;r.updater.isMounted(r)?(null===(o=r[W])||void 0===o?void 0:o.has(e))&&r.setState(b({},e,t)):n.delete(r)}))},Z=function(e,t,n,r,o,a,c,u,i,s,l,f){f?n.delete(e):n.set(e,t),r.get("pushTask")(e,t,(function(){Y(e,t,s),X(e,o,a,n,c,u,r,i,s,l).get(e).get("updater")()}))},ee=function(e,t,n,r){var o=e.get("getSchedulerQueue")(),a=o.taskDataMap,c=o.taskQueueMap,u=o.callbackStackSet;(a.size>0||u.size>0)&&!e.get("isUpdating")&&e.set("isUpdating",Promise.resolve().then((function(){e.set("isUpdating",null),e.set("willUpdating",null),k((function(){a.size>0&&c.forEach((function(e){e()}));var o,i,s=r.size>0?(o=a,i=new Map,o.forEach((function(e,t){i.set(t,e)})),i):void 0;if(e.get("flushTask")(),u.size>0&&(u.forEach((function(e){(0,e.callback)(e.nextState)})),u.clear()),r.size>0){var l=new Proxy({},{get:function(e,r){return"effectState"===r?R(s):"nextState"===r?R(n):"prevState"===r?R(t):void 0}});r.forEach((function(e){e(l)}))}}))})))},te=function(e,t,a){x(e,"useSubscription"),C(t,a);var c=n(null);if(c.current={listener:t,stateKeys:a},A){var u=e[O]?{namespace:e[O]}:null;r(m({listener:t,stateKeys:a},u))}o((function(){return e.subscribe((function(e){D(e.effectState,c.current.stateKeys)&&Promise.resolve(e).then((function(e){c.current.listener(e)}))}))}),[])},ne=function(e,t,n,r){e.size>0&&!t.get("willUpdating")&&(t.set("willUpdating",!0),n.clear(),r.forEach((function(e,t){n.set(t,e)})))},re=function(e,t){var n,o,a,c,u,i,s=void 0===e?{}:"function"==typeof e?e():e;!function(e){var t=P(e),n="Undefined"!==t,r=P(null==e?void 0:e.unmountRestore),o=P(null==e?void 0:e.__useConciseState__),a=P(null==e?void 0:e.namespace),c=P(null==e?void 0:e.__enableMacros__),u=P(null==e?void 0:e.enableMarcoActionStateful);if(A&&(n&&"Object"!==t||n&&"Object"===t&&("Boolean"!==r&&"Undefined"!==r||"Boolean"!==o&&"Undefined"!==o||"String"!==a&&"Undefined"!==a||"Boolean"!==c&&"Undefined"!==c||"Boolean"!==u&&"Undefined"!==u)))throw new Error("resy's createStore(...): Expected the last optional 'options' argument to be a StoreOptions type params."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(t);var l={__useConciseState__:null!==(n=null==t?void 0:t.__useConciseState__)&&void 0!==n?n:void 0,unmountRestore:null===(o=null==t?void 0:t.unmountRestore)||void 0===o||o,namespace:null!==(a=null==t?void 0:t.namespace)&&void 0!==a?a:void 0,__enableMacros__:null!==(c=null==t?void 0:t.__enableMacros__)&&void 0!==c?c:void 0,enableMarcoActionStateful:null!==(u=null==t?void 0:t.enableMarcoActionStateful)&&void 0!==u?u:void 0,__functionName__:null!==(i=null==t?void 0:t.__functionName__)&&void 0!==i?i:re.name};I({state:s,options:l});var f=N(),b=(new Map).set("counter",0),p=new Map,y=B(s),d=B(s),v=new Set,g=new Map,h=new Set,S=new Map;S.set(O,l.namespace);var j=function(t,n){ne(v,f,d,y);var r=t;"function"==typeof t&&(r=t(R(y))),null!==r&&(I({state:r,fnName:"setState、syncUpdate"}),Object.keys(r).forEach((function(t){var n=r[t];Object.is(n,y.get(t))||Z(t,n,y,f,l,s,b,g,p,h,e)}))),f.get("pushCallbackStack")(y,r,n),ee(f,d,y,v)};S.set("setState",j),S.set("syncUpdate",(function(t,n){var r=t;"function"==typeof t&&(r=t(R(y))),j(r,n),null!==r&&k((function(){Object.keys(r).forEach((function(t){var n=r[t];Y(t,n,h),X(t,l,s,y,b,g,f,p,h,e).get(t).get("updater")()}))}))})),S.set("restore",(function(t){ne(v,f,d,y),q(s,e);var n={};z(s,y).forEach((function(t){var r=s[t];Object.is(r,y.get(t))||(n[t]=r,Z(t,r,y,f,l,s,b,g,p,h,e,!M.call(s,t)))})),f.get("pushCallbackStack")(y,n,t),ee(f,d,y,v)})),S.set("subscribe",(function(e,t){C(e,t);var n=function(n){D(n.effectState,t)&&e(n)};return v.add(n),function(){return v.delete(n)}}));var E=function(t,n,r){return Object.is(n,y.get(t))||(ne(v,f,d,y),Z(t,n,y,f,l,s,b,g,p,h,e,r),ee(f,d,y,v)),!0},U={set:function(e,t,n){return E(t,n)},deleteProperty:function(e,t){return E(t,void 0,!0)}},x=function(e,t){var n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(L,n)};return n.__bound__=!0,y.set(e,n),n},L=new Proxy(y,m({get:function(e,t,n){!function(e,t){A&&e!==t&&console.error("Warning: It's not recommended to set the store created by createStore as the prototype of some objects as the store internally hijacks the binding of this context for function properties!")}(n,L);var r=y.get(t);return"function"!=typeof r||r.__bound__?S.get(t)||r:x(t,r)}},U)),W=new Proxy(y,m({get:function(t,n){var o=y.get(n),a=!S.has(n);if(a&&"function"!=typeof o)return A&&r(m({key:n,value:o},l.namespace?{namespace:l.namespace}:null)),$(n,l,s,y,b,g,f,p,h,e);if(a&&"function"==typeof o){o.__bound__||x(n,o);var c=!l.__enableMacros__||l.enableMarcoActionStateful,u=y.get(n);return c&&A&&r(m({key:n,value:u},l.namespace?{namespace:l.namespace}:null)),c&&$(n,l,s,y,b,g,f,p,h,e),u}return S.get(n)}},U));(l.__useConciseState__||l.__enableMacros__)&&S.set("store",L),S.set(_,W),S.set(w,w);S.set("setOptions",(function(e){!function(e){var t=P(e),n=P(null==e?void 0:e.unmountRestore);if(A&&("Object"!==t||"Object"===t&&"Boolean"!==n))throw new Error("resy's setOptions(...): Expected the 'options' argument to be an object with a unmountRestore attribute."+" Instead received: ".concat(t.toLocaleLowerCase(),"."))}(e),l.unmountRestore=e.unmountRestore})),S.set("getOptions",(function(){return Object.assign({},l)}));S.set("useStore",(function(){return W})),S.set("useSubscription",(function(e,t){if(A){var n=l.namespace?{namespace:l.namespace}:null;r(m({listener:e,stateKeys:t},n))}te(L,e,t)}));return S.set(F,(function(){var e=this;h.add(this);var t=new Proxy(y,m({get:function(n,r){if("useStore"===r)return function(){return t};var o=y.get(r);return S.get(r)||("function"!=typeof o?J.apply(e,[r,y]):function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return J.apply(e,[r,y]).apply(t,o)})}},U));return t})),S.set(K,(function(){h.delete(this),V(l,s,y,b,f,p,h,e)})),S.set(T,(function(){Q(s,y,p,e)})),L},oe=function(e){return x(e,"useStore"),e[_]},ae=function(e){return a((function(){return re(e,{__useConciseState__:!0,__functionName__:ae.name})}),[])[_]},ce=function(e,t){return re(e,m(m({},t),{},{__enableMacros__:!0,__functionName__:ce.name})).useStore};function ue(){var e=this,t=this.componentWillUnmount;this.componentWillUnmount=function(){null==t||t.apply(e),Promise.resolve().then((function(){e.updater.isMounted(e)||(e[W].clear(),e[L].forEach((function(t){t[K].apply(e)})))}))}}function ie(e){return x(e,"connectStore"),e[T](),this[L].add(e),this[F]=e[F],this[F]()}var se=function(){function e(t){var n;return l(this,e),b(n=s(this,e,[t]),W,new Set),b(n,F,void 0),b(n,L,new Set),ue.apply(n),n}return y(e,c),f(e,[{key:"connectStore",value:function(e){return ie.apply(this,[e])}}])}();b(se,"displayName",void 0);var le=function(){function e(t){var n;return l(this,e),b(n=s(this,e,[t]),W,new Set),b(n,F,void 0),b(n,L,new Set),ue.apply(n),n}return y(e,u),f(e,[{key:"connectStore",value:function(e){return ie.apply(this,[e])}}])}();b(le,"displayName",void 0);export{se as ComponentWithStore,le as PureComponentWithStore,re as createStore,ce as defineStore,ae as useConciseState,oe as useStore,te as useSubscription};
{
"name": "resy",
"version": "11.0.3",
"version": "11.1.0",
"description": "React State Easy",

@@ -40,3 +40,3 @@ "repository": "https://github.com/lsbFlying/resy.git",

"dependencies": {
"use-sync-external-store": "^1.2.2"
"use-sync-external-store": "^1.4.0"
},

@@ -47,39 +47,39 @@ "peerDependencies": {

"devDependencies": {
"@babel/preset-env": "^7.25.0",
"@babel/preset-env": "^7.26.9",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.0.0",
"@types/node": "^22.0.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@rollup/plugin-typescript": "^12.1.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@types/node": "^22.13.8",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@types/rollup-plugin-auto-external": "^2.0.5",
"@types/use-sync-external-store": "0.0.6",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"@vitest/coverage-v8": "^2.0.4",
"@vitest/ui": "^2.0.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"jsdom": "^24.1.1",
"node": "^20.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.74.3",
"rollup": "^4.24.0",
"@typescript-eslint/eslint-plugin": "^8.25.0",
"@typescript-eslint/parser": "^8.25.0",
"@vitest/coverage-v8": "^3.0.7",
"@vitest/ui": "^3.0.7",
"eslint": "^9.21.0",
"eslint-config-prettier": "^10.0.2",
"eslint-import-resolver-typescript": "^3.8.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.2.0",
"jsdom": "^26.0.0",
"node": "^23.9.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-native": "^0.78.0",
"rollup": "^4.34.9",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-dts": "^6.1.1",
"typescript": "^5.5.4",
"vite": "^5.4.8",
"vitest": "^2.0.4"
"typescript": "^5.8.2",
"vite": "^6.2.0",
"vitest": "^3.0.7"
},
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
"node": ">=16.0.0"
},

@@ -86,0 +86,0 @@ "eslintIgnore": [

+136
-9

@@ -31,3 +31,34 @@ <div align="center">

### Usage
#### defineStore
```tsx
import React from "react";
import { defineStore } from "resy";
const useStore = defineStore({
count: 0,
increase() {
this.count++;
},
});
const App = () => {
const { count, increase } = useStore();
return (
<>
<p>count:{count}</p>
<button onClick={increase}>increase</button>
</>
);
};
```
<details>
<summary>
createStore
</summary>
```tsx
import React from "react";
import { createStore, useStore, ComponentWithStore } from "resy";

@@ -65,2 +96,4 @@

</details>
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/sandbox/resy-igo13u?file=%2Fsrc%2FApp.js)

@@ -71,8 +104,9 @@

| API | Description |
|-----------------|--------------------------------------------------------------|
| createStore | Create a store container for state |
| useStore | Use state from the store container generated by createStore |
| setState | Update data |
| syncUpdate | Synchronously update data |
| API | Description |
|-------------|-------------------------------------------------------------|
| defineStore | The macro definition method for createStore |
| createStore | Create a store container for state |
| useStore | Use state from the store container generated by createStore |
| setState | Update data |
| syncUpdate | Synchronously update data |

@@ -83,2 +117,66 @@ ### Detailed introduction of api

<summary>
defineStore
</summary>
##### general use of defineStore
```tsx
const useUserStore = defineStore({
userId: 666,
username: "wenmu",
updateUserInfo() {
this.username = "Shanbao Liu";
},
});
const useThemeStore = defineStore({
themeStyle: "dark",
changeTheme() {
this.themeStyle = "light";
},
});
function App() {
const { username, updateUserInfo } = useUserStore();
const { themeStyle, changeTheme } = useThemeStore();
return (
<>
<p onClick={updateUserInfo}>name:{username}</p>
<p onClick={changeTheme}>theme:{themeStyle}</p>
</>
);
}
```
##### Being able to deconstruct the store and all the tools and methods available for createStore
```tsx
const useStore = defineStore({
count: 0,
increase() {
this.count++;
},
});
function App() {
const {
count, increase, store, useSubscription,
} = useStore();
useSubscription(({ effectState }) => {
console.log(effectState);
}, ["count"]);
return (
<>
<p onClick={increase}>count:{count}</p>
<button onClick={() => store.count++}>
updateCount
</button>
</>
);
}
```
</details>
<details>
<summary>
createStore

@@ -786,2 +884,3 @@ </summary>

| setOptions | Set the options parameter of createStore |
| getOptions | Get the options parameter of createStore |

@@ -871,3 +970,3 @@ ### Detailed introduction of api

```tsx
import { useConciseState, ConciseStoreHeart } from "resy";
import { useConciseState, StoreType } from "resy";

@@ -879,3 +978,3 @@ type State = {

function ChildOne(props: ConciseStoreHeart<State>) {
function ChildOne(props: StoreType<State>) {
const { store } = props;

@@ -902,3 +1001,3 @@ const { count, text } = useStore(store);

function ChildTwo(props: ConciseStoreHeart<State>) {
function ChildTwo(props: StoreType<State>) {
const { store } = props;

@@ -1169,4 +1268,32 @@ const [data, setData] = useState({ count: 0, text: "hello" });

<details>
<summary>getOptions</summary>
```tsx
function App() {
return (
<button
onClick={() => {
/**
* @description When executed in conjunction with "setOptions",
* it allows users to make different coding decisions based on various configurations,
* while being aware of the current settings.
* 🌟 Different from the considerations for the parameter types of "setOptions",
* "getOptions" returns a configuration object for all settings.
* This is because these read-only settings do not affect code security,
* and the parameters for "setOptions" are only aimed at the "unmountRestore" configuration item.
* Providing all configuration items may also be for the convenience of subsequent internal coding considerations.
*/
const currentOptions = store.getOptions();
}}
>
btn
</button>
);
}
```
</details>
### License
[MIT License](https://github.com/lsbFlying/resy/blob/master/LICENSE) (c) [刘善保](https://github.com/lsbFlying)