first
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
System.register(['react', 'zustand/traditional'], (function (exports) {
|
||||
'use strict';
|
||||
var ReactExports, useStoreWithEqualityFn;
|
||||
return {
|
||||
setters: [function (module) {
|
||||
ReactExports = module.default;
|
||||
}, function (module) {
|
||||
useStoreWithEqualityFn = module.useStoreWithEqualityFn;
|
||||
}],
|
||||
execute: (function () {
|
||||
|
||||
exports('default', createContext);
|
||||
|
||||
const {
|
||||
createElement,
|
||||
createContext: reactCreateContext,
|
||||
useContext,
|
||||
useMemo,
|
||||
useRef
|
||||
} = ReactExports;
|
||||
function createContext() {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180."
|
||||
);
|
||||
}
|
||||
const ZustandContext = reactCreateContext(void 0);
|
||||
const Provider = ({
|
||||
createStore,
|
||||
children
|
||||
}) => {
|
||||
const storeRef = useRef();
|
||||
if (!storeRef.current) {
|
||||
storeRef.current = createStore();
|
||||
}
|
||||
return createElement(
|
||||
ZustandContext.Provider,
|
||||
{ value: storeRef.current },
|
||||
children
|
||||
);
|
||||
};
|
||||
const useContextStore = (selector, equalityFn) => {
|
||||
const store = useContext(ZustandContext);
|
||||
if (!store) {
|
||||
throw new Error(
|
||||
"Seems like you have not used zustand provider as an ancestor."
|
||||
);
|
||||
}
|
||||
return useStoreWithEqualityFn(
|
||||
store,
|
||||
selector,
|
||||
equalityFn
|
||||
);
|
||||
};
|
||||
const useStoreApi = () => {
|
||||
const store = useContext(ZustandContext);
|
||||
if (!store) {
|
||||
throw new Error(
|
||||
"Seems like you have not used zustand provider as an ancestor."
|
||||
);
|
||||
}
|
||||
return useMemo(() => ({ ...store }), [store]);
|
||||
};
|
||||
return {
|
||||
Provider,
|
||||
useStore: useContextStore,
|
||||
useStoreApi
|
||||
};
|
||||
}
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register(["react","zustand/traditional"],function(a){"use strict";var o,s;return{setters:[function(r){o=r.default},function(r){s=r.useStoreWithEqualityFn}],execute:function(){a("default",l);const{createElement:r,createContext:c,useContext:i,useMemo:d,useRef:f}=o;function l(){const n=c(void 0);return{Provider:({createStore:e,children:u})=>{const t=f();return t.current||(t.current=e()),r(n.Provider,{value:t.current},u)},useStore:(e,u)=>{const t=i(n);if(!t)throw new Error("Seems like you have not used zustand provider as an ancestor.");return s(t,e,u)},useStoreApi:()=>{const e=i(n);if(!e)throw new Error("Seems like you have not used zustand provider as an ancestor.");return d(()=>({...e}),[e])}}}}}});
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
System.register(['zustand/vanilla', 'react', 'use-sync-external-store/shim/with-selector'], (function (exports) {
|
||||
'use strict';
|
||||
var _starExcludes = {
|
||||
create: 1,
|
||||
default: 1,
|
||||
useStore: 1
|
||||
};
|
||||
var createStore, ReactExports, useSyncExternalStoreExports;
|
||||
return {
|
||||
setters: [function (module) {
|
||||
createStore = module.createStore;
|
||||
var setter = {};
|
||||
for (var name in module) {
|
||||
if (!_starExcludes[name]) setter[name] = module[name];
|
||||
}
|
||||
exports(setter);
|
||||
}, function (module) {
|
||||
ReactExports = module.default;
|
||||
}, function (module) {
|
||||
useSyncExternalStoreExports = module.default;
|
||||
}],
|
||||
execute: (function () {
|
||||
|
||||
exports('useStore', useStore);
|
||||
|
||||
const { useDebugValue } = ReactExports;
|
||||
const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
|
||||
let didWarnAboutEqualityFn = false;
|
||||
function useStore(api, selector = api.getState, equalityFn) {
|
||||
if (equalityFn && !didWarnAboutEqualityFn) {
|
||||
console.warn(
|
||||
"[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
|
||||
);
|
||||
didWarnAboutEqualityFn = true;
|
||||
}
|
||||
const slice = useSyncExternalStoreWithSelector(
|
||||
api.subscribe,
|
||||
api.getState,
|
||||
api.getServerState || api.getState,
|
||||
selector,
|
||||
equalityFn
|
||||
);
|
||||
useDebugValue(slice);
|
||||
return slice;
|
||||
}
|
||||
const createImpl = (createState) => {
|
||||
if (typeof createState !== "function") {
|
||||
console.warn(
|
||||
"[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
|
||||
);
|
||||
}
|
||||
const api = typeof createState === "function" ? createStore(createState) : createState;
|
||||
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
||||
Object.assign(useBoundStore, api);
|
||||
return useBoundStore;
|
||||
};
|
||||
const create = exports('create', (createState) => createState ? createImpl(createState) : createImpl);
|
||||
var react = exports('default', (createState) => {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'`."
|
||||
);
|
||||
}
|
||||
return create(createState);
|
||||
});
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register(["zustand/vanilla","react","use-sync-external-store/shim/with-selector"],function(c){"use strict";var l={create:1,default:1,useStore:1},o,i,f;return{setters:[function(t){o=t.createStore;var n={};for(var r in t)l[r]||(n[r]=t[r]);c(n)},function(t){i=t.default},function(t){f=t.default}],execute:function(){c("useStore",r);const{useDebugValue:t}=i,{useSyncExternalStoreWithSelector:n}=f;function r(e,s=e.getState,a){const u=n(e.subscribe,e.getState,e.getServerState||e.getState,s,a);return t(u),u}const S=e=>{const s=typeof e=="function"?o(e):e,a=(u,v)=>r(s,u,v);return Object.assign(a,s),a},g=c("create",e=>e?S(e):S);var b=c("default",e=>g(e))}}});
|
||||
+592
@@ -0,0 +1,592 @@
|
||||
System.register([], (function (exports) {
|
||||
'use strict';
|
||||
return {
|
||||
execute: (function () {
|
||||
|
||||
exports('createJSONStorage', createJSONStorage);
|
||||
|
||||
const reduxImpl = (reducer, initial) => (set, _get, api) => {
|
||||
api.dispatch = (action) => {
|
||||
set((state) => reducer(state, action), false, action);
|
||||
return action;
|
||||
};
|
||||
api.dispatchFromDevtools = true;
|
||||
return { dispatch: (...a) => api.dispatch(...a), ...initial };
|
||||
};
|
||||
const redux = exports('redux', reduxImpl);
|
||||
|
||||
const trackedConnections = /* @__PURE__ */ new Map();
|
||||
const getTrackedConnectionState = (name) => {
|
||||
const api = trackedConnections.get(name);
|
||||
if (!api)
|
||||
return {};
|
||||
return Object.fromEntries(
|
||||
Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])
|
||||
);
|
||||
};
|
||||
const extractConnectionInformation = (store, extensionConnector, options) => {
|
||||
if (store === void 0) {
|
||||
return {
|
||||
type: "untracked",
|
||||
connection: extensionConnector.connect(options)
|
||||
};
|
||||
}
|
||||
const existingConnection = trackedConnections.get(options.name);
|
||||
if (existingConnection) {
|
||||
return { type: "tracked", store, ...existingConnection };
|
||||
}
|
||||
const newConnection = {
|
||||
connection: extensionConnector.connect(options),
|
||||
stores: {}
|
||||
};
|
||||
trackedConnections.set(options.name, newConnection);
|
||||
return { type: "tracked", store, ...newConnection };
|
||||
};
|
||||
const devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {
|
||||
const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;
|
||||
let extensionConnector;
|
||||
try {
|
||||
extensionConnector = (enabled != null ? enabled : true) && window.__REDUX_DEVTOOLS_EXTENSION__;
|
||||
} catch (e) {
|
||||
}
|
||||
if (!extensionConnector) {
|
||||
if (enabled) {
|
||||
console.warn(
|
||||
"[zustand devtools middleware] Please install/enable Redux devtools extension"
|
||||
);
|
||||
}
|
||||
return fn(set, get, api);
|
||||
}
|
||||
const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);
|
||||
let isRecording = true;
|
||||
api.setState = (state, replace, nameOrAction) => {
|
||||
const r = set(state, replace);
|
||||
if (!isRecording)
|
||||
return r;
|
||||
const action = nameOrAction === void 0 ? { type: anonymousActionType || "anonymous" } : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction;
|
||||
if (store === void 0) {
|
||||
connection == null ? void 0 : connection.send(action, get());
|
||||
return r;
|
||||
}
|
||||
connection == null ? void 0 : connection.send(
|
||||
{
|
||||
...action,
|
||||
type: `${store}/${action.type}`
|
||||
},
|
||||
{
|
||||
...getTrackedConnectionState(options.name),
|
||||
[store]: api.getState()
|
||||
}
|
||||
);
|
||||
return r;
|
||||
};
|
||||
const setStateFromDevtools = (...a) => {
|
||||
const originalIsRecording = isRecording;
|
||||
isRecording = false;
|
||||
set(...a);
|
||||
isRecording = originalIsRecording;
|
||||
};
|
||||
const initialState = fn(api.setState, get, api);
|
||||
if (connectionInformation.type === "untracked") {
|
||||
connection == null ? void 0 : connection.init(initialState);
|
||||
} else {
|
||||
connectionInformation.stores[connectionInformation.store] = api;
|
||||
connection == null ? void 0 : connection.init(
|
||||
Object.fromEntries(
|
||||
Object.entries(connectionInformation.stores).map(([key, store2]) => [
|
||||
key,
|
||||
key === connectionInformation.store ? initialState : store2.getState()
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
if (api.dispatchFromDevtools && typeof api.dispatch === "function") {
|
||||
let didWarnAboutReservedActionType = false;
|
||||
const originalDispatch = api.dispatch;
|
||||
api.dispatch = (...a) => {
|
||||
if (a[0].type === "__setState" && !didWarnAboutReservedActionType) {
|
||||
console.warn(
|
||||
'[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'
|
||||
);
|
||||
didWarnAboutReservedActionType = true;
|
||||
}
|
||||
originalDispatch(...a);
|
||||
};
|
||||
}
|
||||
connection.subscribe((message) => {
|
||||
var _a;
|
||||
switch (message.type) {
|
||||
case "ACTION":
|
||||
if (typeof message.payload !== "string") {
|
||||
console.error(
|
||||
"[zustand devtools middleware] Unsupported action format"
|
||||
);
|
||||
return;
|
||||
}
|
||||
return parseJsonThen(
|
||||
message.payload,
|
||||
(action) => {
|
||||
if (action.type === "__setState") {
|
||||
if (store === void 0) {
|
||||
setStateFromDevtools(action.state);
|
||||
return;
|
||||
}
|
||||
if (Object.keys(action.state).length !== 1) {
|
||||
console.error(
|
||||
`
|
||||
[zustand devtools middleware] Unsupported __setState action format.
|
||||
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
||||
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
||||
`
|
||||
);
|
||||
}
|
||||
const stateFromDevtools = action.state[store];
|
||||
if (stateFromDevtools === void 0 || stateFromDevtools === null) {
|
||||
return;
|
||||
}
|
||||
if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {
|
||||
setStateFromDevtools(stateFromDevtools);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!api.dispatchFromDevtools)
|
||||
return;
|
||||
if (typeof api.dispatch !== "function")
|
||||
return;
|
||||
api.dispatch(action);
|
||||
}
|
||||
);
|
||||
case "DISPATCH":
|
||||
switch (message.payload.type) {
|
||||
case "RESET":
|
||||
setStateFromDevtools(initialState);
|
||||
if (store === void 0) {
|
||||
return connection == null ? void 0 : connection.init(api.getState());
|
||||
}
|
||||
return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));
|
||||
case "COMMIT":
|
||||
if (store === void 0) {
|
||||
connection == null ? void 0 : connection.init(api.getState());
|
||||
return;
|
||||
}
|
||||
return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));
|
||||
case "ROLLBACK":
|
||||
return parseJsonThen(message.state, (state) => {
|
||||
if (store === void 0) {
|
||||
setStateFromDevtools(state);
|
||||
connection == null ? void 0 : connection.init(api.getState());
|
||||
return;
|
||||
}
|
||||
setStateFromDevtools(state[store]);
|
||||
connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));
|
||||
});
|
||||
case "JUMP_TO_STATE":
|
||||
case "JUMP_TO_ACTION":
|
||||
return parseJsonThen(message.state, (state) => {
|
||||
if (store === void 0) {
|
||||
setStateFromDevtools(state);
|
||||
return;
|
||||
}
|
||||
if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {
|
||||
setStateFromDevtools(state[store]);
|
||||
}
|
||||
});
|
||||
case "IMPORT_STATE": {
|
||||
const { nextLiftedState } = message.payload;
|
||||
const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;
|
||||
if (!lastComputedState)
|
||||
return;
|
||||
if (store === void 0) {
|
||||
setStateFromDevtools(lastComputedState);
|
||||
} else {
|
||||
setStateFromDevtools(lastComputedState[store]);
|
||||
}
|
||||
connection == null ? void 0 : connection.send(
|
||||
null,
|
||||
// FIXME no-any
|
||||
nextLiftedState
|
||||
);
|
||||
return;
|
||||
}
|
||||
case "PAUSE_RECORDING":
|
||||
return isRecording = !isRecording;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
return initialState;
|
||||
};
|
||||
const devtools = exports('devtools', devtoolsImpl);
|
||||
const parseJsonThen = (stringified, f) => {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(stringified);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"[zustand devtools middleware] Could not parse the received json",
|
||||
e
|
||||
);
|
||||
}
|
||||
if (parsed !== void 0)
|
||||
f(parsed);
|
||||
};
|
||||
|
||||
const subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
||||
const origSubscribe = api.subscribe;
|
||||
api.subscribe = (selector, optListener, options) => {
|
||||
let listener = selector;
|
||||
if (optListener) {
|
||||
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
||||
let currentSlice = selector(api.getState());
|
||||
listener = (state) => {
|
||||
const nextSlice = selector(state);
|
||||
if (!equalityFn(currentSlice, nextSlice)) {
|
||||
const previousSlice = currentSlice;
|
||||
optListener(currentSlice = nextSlice, previousSlice);
|
||||
}
|
||||
};
|
||||
if (options == null ? void 0 : options.fireImmediately) {
|
||||
optListener(currentSlice, currentSlice);
|
||||
}
|
||||
}
|
||||
return origSubscribe(listener);
|
||||
};
|
||||
const initialState = fn(set, get, api);
|
||||
return initialState;
|
||||
};
|
||||
const subscribeWithSelector = exports('subscribeWithSelector', subscribeWithSelectorImpl);
|
||||
|
||||
const combine = exports('combine', (initialState, create) => (...a) => Object.assign({}, initialState, create(...a)));
|
||||
|
||||
function createJSONStorage(getStorage, options) {
|
||||
let storage;
|
||||
try {
|
||||
storage = getStorage();
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
const persistStorage = {
|
||||
getItem: (name) => {
|
||||
var _a;
|
||||
const parse = (str2) => {
|
||||
if (str2 === null) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(str2, options == null ? void 0 : options.reviver);
|
||||
};
|
||||
const str = (_a = storage.getItem(name)) != null ? _a : null;
|
||||
if (str instanceof Promise) {
|
||||
return str.then(parse);
|
||||
}
|
||||
return parse(str);
|
||||
},
|
||||
setItem: (name, newValue) => storage.setItem(
|
||||
name,
|
||||
JSON.stringify(newValue, options == null ? void 0 : options.replacer)
|
||||
),
|
||||
removeItem: (name) => storage.removeItem(name)
|
||||
};
|
||||
return persistStorage;
|
||||
}
|
||||
const toThenable = (fn) => (input) => {
|
||||
try {
|
||||
const result = fn(input);
|
||||
if (result instanceof Promise) {
|
||||
return result;
|
||||
}
|
||||
return {
|
||||
then(onFulfilled) {
|
||||
return toThenable(onFulfilled)(result);
|
||||
},
|
||||
catch(_onRejected) {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
then(_onFulfilled) {
|
||||
return this;
|
||||
},
|
||||
catch(onRejected) {
|
||||
return toThenable(onRejected)(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
const oldImpl = (config, baseOptions) => (set, get, api) => {
|
||||
let options = {
|
||||
getStorage: () => localStorage,
|
||||
serialize: JSON.stringify,
|
||||
deserialize: JSON.parse,
|
||||
partialize: (state) => state,
|
||||
version: 0,
|
||||
merge: (persistedState, currentState) => ({
|
||||
...currentState,
|
||||
...persistedState
|
||||
}),
|
||||
...baseOptions
|
||||
};
|
||||
let hasHydrated = false;
|
||||
const hydrationListeners = /* @__PURE__ */ new Set();
|
||||
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
||||
let storage;
|
||||
try {
|
||||
storage = options.getStorage();
|
||||
} catch (e) {
|
||||
}
|
||||
if (!storage) {
|
||||
return config(
|
||||
(...args) => {
|
||||
console.warn(
|
||||
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
||||
);
|
||||
set(...args);
|
||||
},
|
||||
get,
|
||||
api
|
||||
);
|
||||
}
|
||||
const thenableSerialize = toThenable(options.serialize);
|
||||
const setItem = () => {
|
||||
const state = options.partialize({ ...get() });
|
||||
let errorInSync;
|
||||
const thenable = thenableSerialize({ state, version: options.version }).then(
|
||||
(serializedValue) => storage.setItem(options.name, serializedValue)
|
||||
).catch((e) => {
|
||||
errorInSync = e;
|
||||
});
|
||||
if (errorInSync) {
|
||||
throw errorInSync;
|
||||
}
|
||||
return thenable;
|
||||
};
|
||||
const savedSetState = api.setState;
|
||||
api.setState = (state, replace) => {
|
||||
savedSetState(state, replace);
|
||||
void setItem();
|
||||
};
|
||||
const configResult = config(
|
||||
(...args) => {
|
||||
set(...args);
|
||||
void setItem();
|
||||
},
|
||||
get,
|
||||
api
|
||||
);
|
||||
let stateFromStorage;
|
||||
const hydrate = () => {
|
||||
var _a;
|
||||
if (!storage)
|
||||
return;
|
||||
hasHydrated = false;
|
||||
hydrationListeners.forEach((cb) => cb(get()));
|
||||
const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get())) || void 0;
|
||||
return toThenable(storage.getItem.bind(storage))(options.name).then((storageValue) => {
|
||||
if (storageValue) {
|
||||
return options.deserialize(storageValue);
|
||||
}
|
||||
}).then((deserializedStorageValue) => {
|
||||
if (deserializedStorageValue) {
|
||||
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
||||
if (options.migrate) {
|
||||
return options.migrate(
|
||||
deserializedStorageValue.state,
|
||||
deserializedStorageValue.version
|
||||
);
|
||||
}
|
||||
console.error(
|
||||
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
||||
);
|
||||
} else {
|
||||
return deserializedStorageValue.state;
|
||||
}
|
||||
}
|
||||
}).then((migratedState) => {
|
||||
var _a2;
|
||||
stateFromStorage = options.merge(
|
||||
migratedState,
|
||||
(_a2 = get()) != null ? _a2 : configResult
|
||||
);
|
||||
set(stateFromStorage, true);
|
||||
return setItem();
|
||||
}).then(() => {
|
||||
postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
|
||||
hasHydrated = true;
|
||||
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
||||
}).catch((e) => {
|
||||
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
||||
});
|
||||
};
|
||||
api.persist = {
|
||||
setOptions: (newOptions) => {
|
||||
options = {
|
||||
...options,
|
||||
...newOptions
|
||||
};
|
||||
if (newOptions.getStorage) {
|
||||
storage = newOptions.getStorage();
|
||||
}
|
||||
},
|
||||
clearStorage: () => {
|
||||
storage == null ? void 0 : storage.removeItem(options.name);
|
||||
},
|
||||
getOptions: () => options,
|
||||
rehydrate: () => hydrate(),
|
||||
hasHydrated: () => hasHydrated,
|
||||
onHydrate: (cb) => {
|
||||
hydrationListeners.add(cb);
|
||||
return () => {
|
||||
hydrationListeners.delete(cb);
|
||||
};
|
||||
},
|
||||
onFinishHydration: (cb) => {
|
||||
finishHydrationListeners.add(cb);
|
||||
return () => {
|
||||
finishHydrationListeners.delete(cb);
|
||||
};
|
||||
}
|
||||
};
|
||||
hydrate();
|
||||
return stateFromStorage || configResult;
|
||||
};
|
||||
const newImpl = (config, baseOptions) => (set, get, api) => {
|
||||
let options = {
|
||||
storage: createJSONStorage(() => localStorage),
|
||||
partialize: (state) => state,
|
||||
version: 0,
|
||||
merge: (persistedState, currentState) => ({
|
||||
...currentState,
|
||||
...persistedState
|
||||
}),
|
||||
...baseOptions
|
||||
};
|
||||
let hasHydrated = false;
|
||||
const hydrationListeners = /* @__PURE__ */ new Set();
|
||||
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
||||
let storage = options.storage;
|
||||
if (!storage) {
|
||||
return config(
|
||||
(...args) => {
|
||||
console.warn(
|
||||
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
||||
);
|
||||
set(...args);
|
||||
},
|
||||
get,
|
||||
api
|
||||
);
|
||||
}
|
||||
const setItem = () => {
|
||||
const state = options.partialize({ ...get() });
|
||||
return storage.setItem(options.name, {
|
||||
state,
|
||||
version: options.version
|
||||
});
|
||||
};
|
||||
const savedSetState = api.setState;
|
||||
api.setState = (state, replace) => {
|
||||
savedSetState(state, replace);
|
||||
void setItem();
|
||||
};
|
||||
const configResult = config(
|
||||
(...args) => {
|
||||
set(...args);
|
||||
void setItem();
|
||||
},
|
||||
get,
|
||||
api
|
||||
);
|
||||
let stateFromStorage;
|
||||
const hydrate = () => {
|
||||
var _a, _b;
|
||||
if (!storage)
|
||||
return;
|
||||
hasHydrated = false;
|
||||
hydrationListeners.forEach((cb) => {
|
||||
var _a2;
|
||||
return cb((_a2 = get()) != null ? _a2 : configResult);
|
||||
});
|
||||
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
|
||||
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
||||
if (deserializedStorageValue) {
|
||||
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
||||
if (options.migrate) {
|
||||
return options.migrate(
|
||||
deserializedStorageValue.state,
|
||||
deserializedStorageValue.version
|
||||
);
|
||||
}
|
||||
console.error(
|
||||
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
||||
);
|
||||
} else {
|
||||
return deserializedStorageValue.state;
|
||||
}
|
||||
}
|
||||
}).then((migratedState) => {
|
||||
var _a2;
|
||||
stateFromStorage = options.merge(
|
||||
migratedState,
|
||||
(_a2 = get()) != null ? _a2 : configResult
|
||||
);
|
||||
set(stateFromStorage, true);
|
||||
return setItem();
|
||||
}).then(() => {
|
||||
postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
|
||||
stateFromStorage = get();
|
||||
hasHydrated = true;
|
||||
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
||||
}).catch((e) => {
|
||||
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
||||
});
|
||||
};
|
||||
api.persist = {
|
||||
setOptions: (newOptions) => {
|
||||
options = {
|
||||
...options,
|
||||
...newOptions
|
||||
};
|
||||
if (newOptions.storage) {
|
||||
storage = newOptions.storage;
|
||||
}
|
||||
},
|
||||
clearStorage: () => {
|
||||
storage == null ? void 0 : storage.removeItem(options.name);
|
||||
},
|
||||
getOptions: () => options,
|
||||
rehydrate: () => hydrate(),
|
||||
hasHydrated: () => hasHydrated,
|
||||
onHydrate: (cb) => {
|
||||
hydrationListeners.add(cb);
|
||||
return () => {
|
||||
hydrationListeners.delete(cb);
|
||||
};
|
||||
},
|
||||
onFinishHydration: (cb) => {
|
||||
finishHydrationListeners.add(cb);
|
||||
return () => {
|
||||
finishHydrationListeners.delete(cb);
|
||||
};
|
||||
}
|
||||
};
|
||||
if (!options.skipHydration) {
|
||||
hydrate();
|
||||
}
|
||||
return stateFromStorage || configResult;
|
||||
};
|
||||
const persistImpl = (config, baseOptions) => {
|
||||
if ("getStorage" in baseOptions || "serialize" in baseOptions || "deserialize" in baseOptions) {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."
|
||||
);
|
||||
}
|
||||
return oldImpl(config, baseOptions);
|
||||
}
|
||||
return newImpl(config, baseOptions);
|
||||
};
|
||||
const persist = exports('persist', persistImpl);
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
System.register([],function(b){"use strict";return{execute:function(){b("createJSONStorage",E);const A=b("redux",(d,c)=>(a,o,n)=>(n.dispatch=e=>(a(g=>d(g,e),!1,e),e),n.dispatchFromDevtools=!0,{dispatch:(...e)=>n.dispatch(...e),...c})),I=new Map,w=d=>{const c=I.get(d);return c?Object.fromEntries(Object.entries(c.stores).map(([a,o])=>[a,o.getState()])):{}},T=(d,c,a)=>{if(d===void 0)return{type:"untracked",connection:c.connect(a)};const o=I.get(a.name);if(o)return{type:"tracked",store:d,...o};const n={connection:c.connect(a),stores:{}};return I.set(a.name,n),{type:"tracked",store:d,...n}},P=b("devtools",(d,c={})=>(a,o,n)=>{const{enabled:e,anonymousActionType:g,store:u,...h}=c;let m;try{m=(e!=null?e:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!m)return d(a,o,n);const{connection:l,...y}=T(u,m,h);let p=!0;n.setState=(r,s,i)=>{const t=a(r,s);if(!p)return t;const f=i===void 0?{type:g||"anonymous"}:typeof i=="string"?{type:i}:i;return u===void 0?(l==null||l.send(f,o()),t):(l==null||l.send({...f,type:`${u}/${f.type}`},{...w(h.name),[u]:n.getState()}),t)};const v=(...r)=>{const s=p;p=!1,a(...r),p=s},S=d(n.setState,o,n);if(y.type==="untracked"?l==null||l.init(S):(y.stores[y.store]=n,l==null||l.init(Object.fromEntries(Object.entries(y.stores).map(([r,s])=>[r,r===y.store?S:s.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){const r=n.dispatch;n.dispatch=(...s)=>{r(...s)}}return l.subscribe(r=>{var s;switch(r.type){case"ACTION":if(typeof r.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _(r.payload,i=>{if(i.type==="__setState"){if(u===void 0){v(i.state);return}Object.keys(i.state).length!==1&&console.error(`
|
||||
[zustand devtools middleware] Unsupported __setState action format.
|
||||
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
||||
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
||||
`);const t=i.state[u];if(t==null)return;JSON.stringify(n.getState())!==JSON.stringify(t)&&v(t);return}n.dispatchFromDevtools&&typeof n.dispatch=="function"&&n.dispatch(i)});case"DISPATCH":switch(r.payload.type){case"RESET":return v(S),u===void 0?l==null?void 0:l.init(n.getState()):l==null?void 0:l.init(w(h.name));case"COMMIT":if(u===void 0){l==null||l.init(n.getState());return}return l==null?void 0:l.init(w(h.name));case"ROLLBACK":return _(r.state,i=>{if(u===void 0){v(i),l==null||l.init(n.getState());return}v(i[u]),l==null||l.init(w(h.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return _(r.state,i=>{if(u===void 0){v(i);return}JSON.stringify(n.getState())!==JSON.stringify(i[u])&&v(i[u])});case"IMPORT_STATE":{const{nextLiftedState:i}=r.payload,t=(s=i.computedStates.slice(-1)[0])==null?void 0:s.state;if(!t)return;v(u===void 0?t:t[u]),l==null||l.send(null,i);return}case"PAUSE_RECORDING":return p=!p}return}}),S}),_=(d,c)=>{let a;try{a=JSON.parse(d)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}a!==void 0&&c(a)},H=b("subscribeWithSelector",d=>(c,a,o)=>{const n=o.subscribe;return o.subscribe=(e,g,u)=>{let h=e;if(g){const m=(u==null?void 0:u.equalityFn)||Object.is;let l=e(o.getState());h=y=>{const p=e(y);if(!m(l,p)){const v=l;g(l=p,v)}},u!=null&&u.fireImmediately&&g(l,l)}return n(h)},d(c,a,o)}),R=b("combine",(d,c)=>(...a)=>Object.assign({},d,c(...a)));function E(d,c){let a;try{a=d()}catch{return}return{getItem:o=>{var n;const e=u=>u===null?null:JSON.parse(u,c==null?void 0:c.reviver),g=(n=a.getItem(o))!=null?n:null;return g instanceof Promise?g.then(e):e(g)},setItem:(o,n)=>a.setItem(o,JSON.stringify(n,c==null?void 0:c.replacer)),removeItem:o=>a.removeItem(o)}}const O=d=>c=>{try{const a=d(c);return a instanceof Promise?a:{then(o){return O(o)(a)},catch(o){return this}}}catch(a){return{then(o){return this},catch(o){return O(o)(a)}}}},N=(d,c)=>(a,o,n)=>{let e={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:s=>s,version:0,merge:(s,i)=>({...i,...s}),...c},g=!1;const u=new Set,h=new Set;let m;try{m=e.getStorage()}catch{}if(!m)return d((...s)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...s)},o,n);const l=O(e.serialize),y=()=>{const s=e.partialize({...o()});let i;const t=l({state:s,version:e.version}).then(f=>m.setItem(e.name,f)).catch(f=>{i=f});if(i)throw i;return t},p=n.setState;n.setState=(s,i)=>{p(s,i),y()};const v=d((...s)=>{a(...s),y()},o,n);let S;const r=()=>{var s;if(!m)return;g=!1,u.forEach(t=>t(o()));const i=((s=e.onRehydrateStorage)==null?void 0:s.call(e,o()))||void 0;return O(m.getItem.bind(m))(e.name).then(t=>{if(t)return e.deserialize(t)}).then(t=>{if(t)if(typeof t.version=="number"&&t.version!==e.version){if(e.migrate)return e.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return t.state}).then(t=>{var f;return S=e.merge(t,(f=o())!=null?f:v),a(S,!0),y()}).then(()=>{i==null||i(S,void 0),g=!0,h.forEach(t=>t(S))}).catch(t=>{i==null||i(void 0,t)})};return n.persist={setOptions:s=>{e={...e,...s},s.getStorage&&(m=s.getStorage())},clearStorage:()=>{m==null||m.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>r(),hasHydrated:()=>g,onHydrate:s=>(u.add(s),()=>{u.delete(s)}),onFinishHydration:s=>(h.add(s),()=>{h.delete(s)})},r(),S||v},z=(d,c)=>(a,o,n)=>{let e={storage:E(()=>localStorage),partialize:r=>r,version:0,merge:(r,s)=>({...s,...r}),...c},g=!1;const u=new Set,h=new Set;let m=e.storage;if(!m)return d((...r)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...r)},o,n);const l=()=>{const r=e.partialize({...o()});return m.setItem(e.name,{state:r,version:e.version})},y=n.setState;n.setState=(r,s)=>{y(r,s),l()};const p=d((...r)=>{a(...r),l()},o,n);let v;const S=()=>{var r,s;if(!m)return;g=!1,u.forEach(t=>{var f;return t((f=o())!=null?f:p)});const i=((s=e.onRehydrateStorage)==null?void 0:s.call(e,(r=o())!=null?r:p))||void 0;return O(m.getItem.bind(m))(e.name).then(t=>{if(t)if(typeof t.version=="number"&&t.version!==e.version){if(e.migrate)return e.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return t.state}).then(t=>{var f;return v=e.merge(t,(f=o())!=null?f:p),a(v,!0),l()}).then(()=>{i==null||i(v,void 0),v=o(),g=!0,h.forEach(t=>t(v))}).catch(t=>{i==null||i(void 0,t)})};return n.persist={setOptions:r=>{e={...e,...r},r.storage&&(m=r.storage)},clearStorage:()=>{m==null||m.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>S(),hasHydrated:()=>g,onHydrate:r=>(u.add(r),()=>{u.delete(r)}),onFinishHydration:r=>(h.add(r),()=>{h.delete(r)})},e.skipHydration||S(),v||p},$=b("persist",(d,c)=>"getStorage"in c||"serialize"in c||"deserialize"in c?N(d,c):z(d,c))}}});
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
System.register(['immer'], (function (exports) {
|
||||
'use strict';
|
||||
var produce;
|
||||
return {
|
||||
setters: [function (module) {
|
||||
produce = module.produce;
|
||||
}],
|
||||
execute: (function () {
|
||||
|
||||
const immerImpl = (initializer) => (set, get, store) => {
|
||||
store.setState = (updater, replace, ...a) => {
|
||||
const nextState = typeof updater === "function" ? produce(updater) : updater;
|
||||
return set(nextState, replace, ...a);
|
||||
};
|
||||
return initializer(store.setState, get, store);
|
||||
};
|
||||
const immer = exports('immer', immerImpl);
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register(["immer"],function(c){"use strict";var r;return{setters:[function(n){r=n.produce}],execute:function(){const S=c("immer",s=>(o,u,t)=>(t.setState=(e,i,...m)=>{const f=typeof e=="function"?r(e):e;return o(f,i,...m)},s(t.setState,u,t)))}}});
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
System.register(['react'], (function (exports) {
|
||||
'use strict';
|
||||
var ReactExports;
|
||||
return {
|
||||
setters: [function (module) {
|
||||
ReactExports = module.default;
|
||||
}],
|
||||
execute: (function () {
|
||||
|
||||
exports('useShallow', useShallow);
|
||||
|
||||
function shallow(objA, objB) {
|
||||
if (Object.is(objA, objB)) {
|
||||
return true;
|
||||
}
|
||||
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
||||
return false;
|
||||
}
|
||||
if (objA instanceof Map && objB instanceof Map) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const [key, value] of objA) {
|
||||
if (!Object.is(value, objB.get(key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (objA instanceof Set && objB instanceof Set) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const value of objA) {
|
||||
if (!objB.has(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const keysA = Object.keys(objA);
|
||||
if (keysA.length !== Object.keys(objB).length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const { useRef } = ReactExports;
|
||||
function useShallow(selector) {
|
||||
const prev = useRef();
|
||||
return (state) => {
|
||||
const next = selector(state);
|
||||
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
||||
};
|
||||
}
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register(["react"],function(o){"use strict";var s;return{setters:[function(c){s=c.default}],execute:function(){o("useShallow",f);function c(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}const{useRef:u}=s;function f(e){const t=u();return n=>{const r=e(n);return c(t.current,r)?t.current:t.current=r}}}}});
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
System.register([], (function (exports) {
|
||||
'use strict';
|
||||
return {
|
||||
execute: (function () {
|
||||
|
||||
exports('shallow', shallow$1);
|
||||
|
||||
function shallow$1(objA, objB) {
|
||||
if (Object.is(objA, objB)) {
|
||||
return true;
|
||||
}
|
||||
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
||||
return false;
|
||||
}
|
||||
if (objA instanceof Map && objB instanceof Map) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const [key, value] of objA) {
|
||||
if (!Object.is(value, objB.get(key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (objA instanceof Set && objB instanceof Set) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const value of objA) {
|
||||
if (!objB.has(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const keysA = Object.keys(objA);
|
||||
if (keysA.length !== Object.keys(objB).length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var shallow = exports('default', (objA, objB) => {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] Default export is deprecated. Instead use `import { shallow } from 'zustand/shallow'`."
|
||||
);
|
||||
}
|
||||
return shallow$1(objA, objB);
|
||||
});
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register([],function(f){"use strict";return{execute:function(){f("shallow",i);function i(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[n,o]of t)if(!Object.is(o,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(e,r[n])||!Object.is(t[r[n]],e[r[n]]))return!1;return!0}var s=f("default",(t,e)=>i(t,e))}}});
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
System.register(['react', 'use-sync-external-store/shim/with-selector', 'zustand/vanilla'], (function (exports) {
|
||||
'use strict';
|
||||
var ReactExports, useSyncExternalStoreExports, createStore;
|
||||
return {
|
||||
setters: [function (module) {
|
||||
ReactExports = module.default;
|
||||
}, function (module) {
|
||||
useSyncExternalStoreExports = module.default;
|
||||
}, function (module) {
|
||||
createStore = module.createStore;
|
||||
}],
|
||||
execute: (function () {
|
||||
|
||||
exports('useStoreWithEqualityFn', useStoreWithEqualityFn);
|
||||
|
||||
const { useDebugValue } = ReactExports;
|
||||
const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
|
||||
function useStoreWithEqualityFn(api, selector = api.getState, equalityFn) {
|
||||
const slice = useSyncExternalStoreWithSelector(
|
||||
api.subscribe,
|
||||
api.getState,
|
||||
api.getServerState || api.getState,
|
||||
selector,
|
||||
equalityFn
|
||||
);
|
||||
useDebugValue(slice);
|
||||
return slice;
|
||||
}
|
||||
const createWithEqualityFnImpl = (createState, defaultEqualityFn) => {
|
||||
const api = createStore(createState);
|
||||
const useBoundStoreWithEqualityFn = (selector, equalityFn = defaultEqualityFn) => useStoreWithEqualityFn(api, selector, equalityFn);
|
||||
Object.assign(useBoundStoreWithEqualityFn, api);
|
||||
return useBoundStoreWithEqualityFn;
|
||||
};
|
||||
const createWithEqualityFn = exports('createWithEqualityFn', (createState, defaultEqualityFn) => createState ? createWithEqualityFnImpl(createState, defaultEqualityFn) : createWithEqualityFnImpl);
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register(["react","use-sync-external-store/shim/with-selector","zustand/vanilla"],function(a){"use strict";var c,s,i;return{setters:[function(e){c=e.default},function(e){s=e.default},function(e){i=e.createStore}],execute:function(){a("useStoreWithEqualityFn",o);const{useDebugValue:e}=c,{useSyncExternalStoreWithSelector:S}=s;function o(t,n=t.getState,u){const r=S(t.subscribe,t.getState,t.getServerState||t.getState,n,u);return e(r),r}const l=(t,n)=>{const u=i(t),r=(f,g=n)=>o(u,f,g);return Object.assign(r,u),r},h=a("createWithEqualityFn",(t,n)=>t?l(t,n):l)}}});
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
System.register([], (function (exports) {
|
||||
'use strict';
|
||||
return {
|
||||
execute: (function () {
|
||||
|
||||
const createStoreImpl = (createState) => {
|
||||
let state;
|
||||
const listeners = /* @__PURE__ */ new Set();
|
||||
const setState = (partial, replace) => {
|
||||
const nextState = typeof partial === "function" ? partial(state) : partial;
|
||||
if (!Object.is(nextState, state)) {
|
||||
const previousState = state;
|
||||
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
||||
listeners.forEach((listener) => listener(state, previousState));
|
||||
}
|
||||
};
|
||||
const getState = () => state;
|
||||
const subscribe = (listener) => {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
};
|
||||
const destroy = () => {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
|
||||
);
|
||||
}
|
||||
listeners.clear();
|
||||
};
|
||||
const api = { setState, getState, subscribe, destroy };
|
||||
state = createState(setState, getState, api);
|
||||
return api;
|
||||
};
|
||||
const createStore = exports('createStore', (createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
||||
var vanilla = exports('default', (createState) => {
|
||||
{
|
||||
console.warn(
|
||||
"[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'."
|
||||
);
|
||||
}
|
||||
return createStore(createState);
|
||||
});
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register([],function(s){"use strict";return{execute:function(){const a=e=>{let t;const o=new Set,r=(n,l)=>{const c=typeof n=="function"?n(t):n;if(!Object.is(c,t)){const S=t;t=(l!=null?l:typeof c!="object"||c===null)?c:Object.assign({},t,c),o.forEach(b=>b(t,S))}},i=()=>t,u={setState:r,getState:i,subscribe:n=>(o.add(n),()=>o.delete(n)),destroy:()=>{o.clear()}};return t=e(r,i,u),u},f=s("createStore",e=>e?a(e):a);var d=s("default",e=>f(e))}}});
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
System.register([], (function (exports) {
|
||||
'use strict';
|
||||
return {
|
||||
execute: (function () {
|
||||
|
||||
exports('shallow', shallow);
|
||||
|
||||
function shallow(objA, objB) {
|
||||
if (Object.is(objA, objB)) {
|
||||
return true;
|
||||
}
|
||||
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
||||
return false;
|
||||
}
|
||||
if (objA instanceof Map && objB instanceof Map) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const [key, value] of objA) {
|
||||
if (!Object.is(value, objB.get(key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (objA instanceof Set && objB instanceof Set) {
|
||||
if (objA.size !== objB.size)
|
||||
return false;
|
||||
for (const value of objA) {
|
||||
if (!objB.has(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const keysA = Object.keys(objA);
|
||||
if (keysA.length !== Object.keys(objB).length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
})
|
||||
};
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
System.register([],function(i){"use strict";return{execute:function(){i("shallow",f);function f(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[n,o]of t)if(!Object.is(o,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(e,r[n])||!Object.is(t[r[n]],e[r[n]]))return!1;return!0}}}});
|
||||
Reference in New Issue
Block a user