fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

21
node_modules/valtio/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020-2022 Poimandres
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2
node_modules/valtio/esm/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { useSnapshot } from './react';
export { ref, proxy, getVersion, subscribe, snapshot, unstable_buildProxyFunction, } from './vanilla';

59
node_modules/valtio/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import { useRef, useCallback, useEffect, useMemo, useDebugValue } from 'react';
import { isChanged, createProxy, affectedToPathList } from 'proxy-compare';
import useSyncExternalStoreExports from 'use-sync-external-store/shim/index.js';
import { subscribe, snapshot } from 'valtio/vanilla';
export { getVersion, proxy, ref, snapshot, subscribe, unstable_buildProxyFunction } from 'valtio/vanilla';
const { useSyncExternalStore } = useSyncExternalStoreExports;
const useAffectedDebugValue = (state, affected) => {
const pathList = useRef();
useEffect(() => {
pathList.current = affectedToPathList(state, affected);
});
useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
const notifyInSync = options == null ? void 0 : options.sync;
const lastSnapshot = useRef();
const lastAffected = useRef();
let inRender = true;
const currSnapshot = useSyncExternalStore(
useCallback(
(callback) => {
const unsub = subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
},
[proxyObject, notifyInSync]
),
() => {
const nextSnapshot = snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !isChanged(
lastSnapshot.current,
nextSnapshot,
lastAffected.current,
/* @__PURE__ */ new WeakMap()
)) {
return lastSnapshot.current;
}
} catch (e) {
}
return nextSnapshot;
},
() => snapshot(proxyObject)
);
inRender = false;
const currAffected = /* @__PURE__ */ new WeakMap();
useEffect(() => {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
if ((import.meta.env && import.meta.env.MODE) !== "production") {
useAffectedDebugValue(currSnapshot, currAffected);
}
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []);
return createProxy(currSnapshot, currAffected, proxyCache);
}
export { useSnapshot };

59
node_modules/valtio/esm/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import { useRef, useCallback, useEffect, useMemo, useDebugValue } from 'react';
import { isChanged, createProxy, affectedToPathList } from 'proxy-compare';
import useSyncExternalStoreExports from 'use-sync-external-store/shim/index.js';
import { subscribe, snapshot } from 'valtio/vanilla';
export { getVersion, proxy, ref, snapshot, subscribe, unstable_buildProxyFunction } from 'valtio/vanilla';
const { useSyncExternalStore } = useSyncExternalStoreExports;
const useAffectedDebugValue = (state, affected) => {
const pathList = useRef();
useEffect(() => {
pathList.current = affectedToPathList(state, affected);
});
useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
const notifyInSync = options == null ? void 0 : options.sync;
const lastSnapshot = useRef();
const lastAffected = useRef();
let inRender = true;
const currSnapshot = useSyncExternalStore(
useCallback(
(callback) => {
const unsub = subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
},
[proxyObject, notifyInSync]
),
() => {
const nextSnapshot = snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !isChanged(
lastSnapshot.current,
nextSnapshot,
lastAffected.current,
/* @__PURE__ */ new WeakMap()
)) {
return lastSnapshot.current;
}
} catch (e) {
}
return nextSnapshot;
},
() => snapshot(proxyObject)
);
inRender = false;
const currAffected = /* @__PURE__ */ new WeakMap();
useEffect(() => {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
if ((import.meta.env && import.meta.env.MODE) !== "production") {
useAffectedDebugValue(currSnapshot, currAffected);
}
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []);
return createProxy(currSnapshot, currAffected, proxyCache);
}
export { useSnapshot };

3
node_modules/valtio/esm/macro.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function useProxy<T extends object>(proxyObject: T): void;
declare const _default: any;
export default _default;

39
node_modules/valtio/esm/macro.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { addNamed } from '@babel/helper-module-imports';
import * as t from '@babel/types';
import { createMacro, MacroError } from 'babel-plugin-macros';
const macro = ({ references }) => {
var _a;
(_a = references.useProxy) == null ? void 0 : _a.forEach((path) => {
var _a2, _b, _c, _d, _e, _f;
const hook = addNamed(path, "useSnapshot", "valtio");
const proxy = (_b = (_a2 = path.parentPath) == null ? void 0 : _a2.get("arguments.0")) == null ? void 0 : _b.node;
if (!t.isIdentifier(proxy))
throw new MacroError("no proxy object");
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_d = (_c = path.parentPath) == null ? void 0 : _c.parentPath) == null ? void 0 : _d.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_f = (_e = path.parentPath) == null ? void 0 : _e.getFunctionParent()) == null ? void 0 : _f.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
});
};
var macro$1 = createMacro(macro, { configName: "valtio" });
export { macro$1 as default };

39
node_modules/valtio/esm/macro.mjs generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { addNamed } from '@babel/helper-module-imports';
import * as t from '@babel/types';
import { createMacro, MacroError } from 'babel-plugin-macros';
const macro = ({ references }) => {
var _a;
(_a = references.useProxy) == null ? void 0 : _a.forEach((path) => {
var _a2, _b, _c, _d, _e, _f;
const hook = addNamed(path, "useSnapshot", "valtio");
const proxy = (_b = (_a2 = path.parentPath) == null ? void 0 : _a2.get("arguments.0")) == null ? void 0 : _b.node;
if (!t.isIdentifier(proxy))
throw new MacroError("no proxy object");
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_d = (_c = path.parentPath) == null ? void 0 : _c.parentPath) == null ? void 0 : _d.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_f = (_e = path.parentPath) == null ? void 0 : _e.getFunctionParent()) == null ? void 0 : _f.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
});
};
var macro$1 = createMacro(macro, { configName: "valtio" });
export { macro$1 as default };

5
node_modules/valtio/esm/macro/vite.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import * as plugin from 'aslemammad-vite-plugin-macro';
export declare const valtioMacro: plugin.Macro;
export declare function provideValtioMacro(): plugin.MacroProvider;
declare const macroPlugin: plugin.MacroPlugin;
export default macroPlugin;

50
node_modules/valtio/esm/macro/vite.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import * as babelModuleImports from '@babel/helper-module-imports';
import * as t from '@babel/types';
import * as plugin from 'aslemammad-vite-plugin-macro';
import * as babelMacro from 'babel-plugin-macros';
const { defineMacro, defineMacroProvider, createMacroPlugin } = "default" in plugin ? plugin.default : plugin;
const valtioMacro = defineMacro(`useProxy`).withSignature(`<T extends object>(proxyObject: T): void`).withHandler((ctx) => {
var _a, _b, _c, _d;
const { path, args } = ctx;
const hook = babelModuleImports.addNamed(path, "useSnapshot", "valtio");
const proxy = (_a = args[0]) == null ? void 0 : _a.node;
if (!t.isIdentifier(proxy)) {
throw new babelMacro.MacroError("no proxy object");
}
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_b = path.parentPath) == null ? void 0 : _b.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_d = (_c = path.parentPath) == null ? void 0 : _c.getFunctionParent()) == null ? void 0 : _d.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
});
function provideValtioMacro() {
return defineMacroProvider({
id: "valtio/macro",
exports: {
"valtio/macro": {
macros: [valtioMacro]
}
}
});
}
const macroPlugin = createMacroPlugin({}).use(provideValtioMacro());
export { macroPlugin as default, provideValtioMacro, valtioMacro };

50
node_modules/valtio/esm/macro/vite.mjs generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import * as babelModuleImports from '@babel/helper-module-imports';
import * as t from '@babel/types';
import * as plugin from 'aslemammad-vite-plugin-macro';
import * as babelMacro from 'babel-plugin-macros';
const { defineMacro, defineMacroProvider, createMacroPlugin } = "default" in plugin ? plugin.default : plugin;
const valtioMacro = defineMacro(`useProxy`).withSignature(`<T extends object>(proxyObject: T): void`).withHandler((ctx) => {
var _a, _b, _c, _d;
const { path, args } = ctx;
const hook = babelModuleImports.addNamed(path, "useSnapshot", "valtio");
const proxy = (_a = args[0]) == null ? void 0 : _a.node;
if (!t.isIdentifier(proxy)) {
throw new babelMacro.MacroError("no proxy object");
}
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_b = path.parentPath) == null ? void 0 : _b.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_d = (_c = path.parentPath) == null ? void 0 : _c.getFunctionParent()) == null ? void 0 : _d.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
});
function provideValtioMacro() {
return defineMacroProvider({
id: "valtio/macro",
exports: {
"valtio/macro": {
macros: [valtioMacro]
}
}
});
}
const macroPlugin = createMacroPlugin({}).use(provideValtioMacro());
export { macroPlugin as default, provideValtioMacro, valtioMacro };

78
node_modules/valtio/esm/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import type { INTERNAL_Snapshot } from './vanilla';
declare type Options = {
sync?: boolean;
};
/**
* useSnapshot
*
* Create a local snapshot that catches changes. This hook actually returns a wrapped snapshot in a proxy for
* render optimization instead of a plain object compared to `snapshot()` method.
* Rule of thumb: read from snapshots, mutate the source.
* The component will only re-render when the parts of the state you access have changed, it is render-optimized.
*
* @example A
* function Counter() {
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.count}
* <button onClick={() => ++state.count}>+1</button>
* </div>
* )
* }
*
* [Notes]
* Every object inside your proxy also becomes a proxy (if you don't use "ref"), so you can also use them to create
* the local snapshot as seen on example B.
*
* @example B
* function ProfileName() {
* const snap = useSnapshot(state.profile)
* return (
* <div>
* {snap.name}
* </div>
* )
* }
*
* Beware that you still can replace the child proxy with something else so it will break your snapshot. You can see
* above what happens with the original proxy when you replace the child proxy.
*
* > console.log(state)
* { profile: { name: "valtio" } }
* > childState = state.profile
* > console.log(childState)
* { name: "valtio" }
* > state.profile.name = "react"
* > console.log(childState)
* { name: "react" }
* > state.profile = { name: "new name" }
* > console.log(childState)
* { name: "react" }
* > console.log(state)
* { profile: { name: "new name" } }
*
* `useSnapshot()` depends on the original reference of the child proxy so if you replace it with a new one, the component
* that is subscribed to the old proxy won't receive new updates because it is still subscribed to the old one.
*
* In this case we recommend the example C or D. On both examples you don't need to worry with re-render,
* because it is render-optimized.
*
* @example C
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.profile.name}
* </div>
* )
*
* @example D
* const { profile } = useSnapshot(state)
* return (
* <div>
* {profile.name}
* </div>
* )
*/
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): INTERNAL_Snapshot<T>;
export {};

9
node_modules/valtio/esm/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export { subscribeKey } from './utils/subscribeKey';
export { watch } from './utils/watch';
export { devtools } from './utils/devtools';
export { derive, underive, unstable_deriveSubscriptions } from './utils/derive';
export { addComputed_DEPRECATED as addComputed } from './utils/addComputed';
export { proxyWithComputed } from './utils/proxyWithComputed';
export { proxyWithHistory } from './utils/proxyWithHistory';
export { proxySet } from './utils/proxySet';
export { proxyMap } from './utils/proxyMap';

577
node_modules/valtio/esm/utils.js generated vendored Normal file
View File

@@ -0,0 +1,577 @@
import { subscribe, snapshot, proxy, getVersion, ref } from 'valtio/vanilla';
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return subscribe(
proxyObject,
(ops) => {
if (ops.some((op) => op[1][0] === key)) {
callback(proxyObject[key]);
}
},
notifyInSync
);
}
let currentCleanups;
function watch(callback, options) {
let alive = true;
const cleanups = /* @__PURE__ */ new Set();
const subscriptions = /* @__PURE__ */ new Map();
const cleanup = () => {
if (alive) {
alive = false;
cleanups.forEach((clean) => clean());
cleanups.clear();
subscriptions.forEach((unsubscribe) => unsubscribe());
subscriptions.clear();
}
};
const revalidate = () => {
if (!alive) {
return;
}
cleanups.forEach((clean) => clean());
cleanups.clear();
const proxiesToSubscribe = /* @__PURE__ */ new Set();
const parent = currentCleanups;
currentCleanups = cleanups;
try {
const cleanupReturn = callback((proxyObject) => {
proxiesToSubscribe.add(proxyObject);
return proxyObject;
});
if (cleanupReturn) {
cleanups.add(cleanupReturn);
}
} finally {
currentCleanups = parent;
}
subscriptions.forEach((unsubscribe, proxyObject) => {
if (proxiesToSubscribe.has(proxyObject)) {
proxiesToSubscribe.delete(proxyObject);
} else {
subscriptions.delete(proxyObject);
unsubscribe();
}
});
proxiesToSubscribe.forEach((proxyObject) => {
const unsubscribe = subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync);
subscriptions.set(proxyObject, unsubscribe);
});
};
if (currentCleanups) {
currentCleanups.add(cleanup);
}
revalidate();
return cleanup;
}
const DEVTOOLS = Symbol();
function devtools(proxyObject, options) {
if (typeof options === "string") {
console.warn(
"string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"
);
options = { name: options };
}
const { enabled, name = "" } = options || {};
let extension;
try {
extension = (enabled != null ? enabled : (import.meta.env && import.meta.env.MODE) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
} catch {
}
if (!extension) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && enabled) {
console.warn("[Warning] Please install/enable Redux devtools extension");
}
return;
}
let isTimeTraveling = false;
const devtools2 = extension.connect({ name });
const unsub1 = subscribe(proxyObject, (ops) => {
const action = ops.filter(([_, path]) => path[0] !== DEVTOOLS).map(([op, path]) => `${op}:${path.map(String).join(".")}`).join(", ");
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
const snapWithoutDevtools = Object.assign({}, snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools2.send(
{
type: action,
updatedAt: new Date().toLocaleString()
},
snapWithoutDevtools
);
}
});
const unsub2 = devtools2.subscribe((message) => {
var _a, _b, _c, _d, _e, _f;
if (message.type === "ACTION" && message.payload) {
try {
Object.assign(proxyObject, JSON.parse(message.payload));
} catch (e) {
console.error(
"please dispatch a serializable value that JSON.parse() and proxy() support\n",
e
);
}
}
if (message.type === "DISPATCH" && message.state) {
if (((_a = message.payload) == null ? void 0 : _a.type) === "JUMP_TO_ACTION" || ((_b = message.payload) == null ? void 0 : _b.type) === "JUMP_TO_STATE") {
isTimeTraveling = true;
const state = JSON.parse(message.state);
Object.assign(proxyObject, state);
}
proxyObject[DEVTOOLS] = message;
} else if (message.type === "DISPATCH" && ((_c = message.payload) == null ? void 0 : _c.type) === "COMMIT") {
devtools2.init(snapshot(proxyObject));
} else if (message.type === "DISPATCH" && ((_d = message.payload) == null ? void 0 : _d.type) === "IMPORT_STATE") {
const actions = (_e = message.payload.nextLiftedState) == null ? void 0 : _e.actionsById;
const computedStates = ((_f = message.payload.nextLiftedState) == null ? void 0 : _f.computedStates) || [];
isTimeTraveling = true;
computedStates.forEach(({ state }, index) => {
const action = actions[index] || "No action found";
Object.assign(proxyObject, state);
if (index === 0) {
devtools2.init(snapshot(proxyObject));
} else {
devtools2.send(action, snapshot(proxyObject));
}
});
}
});
devtools2.init(snapshot(proxyObject));
return () => {
unsub1();
unsub2 == null ? void 0 : unsub2();
};
}
const sourceObjectMap = /* @__PURE__ */ new WeakMap();
const derivedObjectMap = /* @__PURE__ */ new WeakMap();
const markPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
markPending(derivedObject);
}
});
++sourceObjectEntry[2];
if (callback) {
sourceObjectEntry[3].add(callback);
}
}
};
const checkPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry == null ? void 0 : sourceObjectEntry[2]) {
sourceObjectEntry[3].add(callback);
return true;
}
return false;
};
const unmarkPending = (sourceObject) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
--sourceObjectEntry[2];
if (!sourceObjectEntry[2]) {
sourceObjectEntry[3].forEach((callback) => callback());
sourceObjectEntry[3].clear();
}
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
unmarkPending(derivedObject);
}
});
}
};
const addSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
let derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (!derivedObjectEntry) {
derivedObjectEntry = [/* @__PURE__ */ new Set()];
derivedObjectMap.set(subscription.d, derivedObjectEntry);
}
derivedObjectEntry[0].add(subscription);
let sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (!sourceObjectEntry) {
const subscriptions = /* @__PURE__ */ new Set();
const unsubscribe = subscribe(
sourceObject,
(ops) => {
subscriptions.forEach((subscription2) => {
const {
d: derivedObject2,
c: callback,
n: notifyInSync,
i: ignoreKeys
} = subscription2;
if (sourceObject === derivedObject2 && ops.every(
(op) => op[1].length === 1 && ignoreKeys.includes(op[1][0])
)) {
return;
}
if (subscription2.p) {
return;
}
markPending(sourceObject, callback);
if (notifyInSync) {
unmarkPending(sourceObject);
} else {
subscription2.p = Promise.resolve().then(() => {
delete subscription2.p;
unmarkPending(sourceObject);
});
}
});
},
true
);
sourceObjectEntry = [subscriptions, unsubscribe, 0, /* @__PURE__ */ new Set()];
sourceObjectMap.set(sourceObject, sourceObjectEntry);
}
sourceObjectEntry[0].add(subscription);
};
const removeSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].delete(subscription);
if ((derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].size) === 0) {
derivedObjectMap.delete(derivedObject);
}
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
const [subscriptions, unsubscribe] = sourceObjectEntry;
subscriptions.delete(subscription);
if (!subscriptions.size) {
unsubscribe();
sourceObjectMap.delete(sourceObject);
}
}
};
const listSubscriptions = (derivedObject) => {
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (derivedObjectEntry) {
return Array.from(derivedObjectEntry[0]);
}
return [];
};
const unstable_deriveSubscriptions = {
add: addSubscription,
remove: removeSubscription,
list: listSubscriptions
};
function derive(derivedFns, options) {
const proxyObject = (options == null ? void 0 : options.proxy) || proxy({});
const notifyInSync = !!(options == null ? void 0 : options.sync);
const derivedKeys = Object.keys(derivedFns);
derivedKeys.forEach((key) => {
if (Object.getOwnPropertyDescriptor(proxyObject, key)) {
throw new Error("object property already defined");
}
const fn = derivedFns[key];
let lastDependencies = null;
const evaluate = () => {
if (lastDependencies) {
if (Array.from(lastDependencies).map(([p]) => checkPending(p, evaluate)).some((isPending) => isPending)) {
return;
}
if (Array.from(lastDependencies).every(
([p, entry]) => getVersion(p) === entry.v
)) {
return;
}
}
const dependencies = /* @__PURE__ */ new Map();
const get = (p) => {
dependencies.set(p, { v: getVersion(p) });
return p;
};
const value = fn(get);
const subscribeToDependencies = () => {
dependencies.forEach((entry, p) => {
var _a;
const lastSubscription = (_a = lastDependencies == null ? void 0 : lastDependencies.get(p)) == null ? void 0 : _a.s;
if (lastSubscription) {
entry.s = lastSubscription;
} else {
const subscription = {
s: p,
d: proxyObject,
k: key,
c: evaluate,
n: notifyInSync,
i: derivedKeys
};
addSubscription(subscription);
entry.s = subscription;
}
});
lastDependencies == null ? void 0 : lastDependencies.forEach((entry, p) => {
if (!dependencies.has(p) && entry.s) {
removeSubscription(entry.s);
}
});
lastDependencies = dependencies;
};
if (value instanceof Promise) {
value.finally(subscribeToDependencies);
} else {
subscribeToDependencies();
}
proxyObject[key] = value;
};
evaluate();
});
return proxyObject;
}
function underive(proxyObject, options) {
const keysToDelete = (options == null ? void 0 : options.delete) ? /* @__PURE__ */ new Set() : null;
listSubscriptions(proxyObject).forEach((subscription) => {
const { k: key } = subscription;
if (!(options == null ? void 0 : options.keys) || options.keys.includes(key)) {
removeSubscription(subscription);
if (keysToDelete) {
keysToDelete.add(key);
}
}
});
if (keysToDelete) {
keysToDelete.forEach((key) => {
delete proxyObject[key];
});
}
}
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject = proxyObject) {
console.warn(
"addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive. https://github.com/pmndrs/valtio/pull/201"
);
const derivedFns = {};
Object.keys(computedFns_FAKE).forEach((key) => {
derivedFns[key] = (get) => computedFns_FAKE[key](get(proxyObject));
});
return derive(derivedFns, { proxy: targetObject });
}
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach((key) => {
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
throw new Error("object property already defined");
}
const computedFn = computedFns[key];
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
const desc = {};
desc.get = () => get(snapshot(proxyObject));
if (set) {
desc.set = (newValue) => set(proxyObject, newValue);
}
Object.defineProperty(initialObject, key, desc);
});
const proxyObject = proxy(initialObject);
return proxyObject;
}
const isObject = (x) => typeof x === "object" && x !== null;
const deepClone = (obj) => {
if (!isObject(obj)) {
return obj;
}
const baseObject = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
Reflect.ownKeys(obj).forEach((key) => {
baseObject[key] = deepClone(obj[key]);
});
return baseObject;
};
function proxyWithHistory(initialValue, skipSubscribe = false) {
const proxyObject = proxy({
value: initialValue,
history: ref({
wip: void 0,
snapshots: [],
index: -1
}),
canUndo: () => proxyObject.history.index > 0,
undo: () => {
if (proxyObject.canUndo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[--proxyObject.history.index]
);
}
},
canRedo: () => proxyObject.history.index < proxyObject.history.snapshots.length - 1,
redo: () => {
if (proxyObject.canRedo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[++proxyObject.history.index]
);
}
},
saveHistory: () => {
proxyObject.history.snapshots.splice(proxyObject.history.index + 1);
proxyObject.history.snapshots.push(snapshot(proxyObject).value);
++proxyObject.history.index;
},
subscribe: () => subscribe(proxyObject, (ops) => {
if (ops.every(
(op) => op[1][0] === "value" && (op[0] !== "set" || op[2] !== proxyObject.history.wip)
)) {
proxyObject.saveHistory();
}
})
});
proxyObject.saveHistory();
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;
}
function proxySet(initialValues) {
const set = proxy({
data: Array.from(new Set(initialValues)),
has(value) {
return this.data.indexOf(value) !== -1;
},
add(value) {
let hasProxy = false;
if (typeof value === "object" && value !== null) {
hasProxy = this.data.indexOf(proxy(value)) !== -1;
}
if (this.data.indexOf(value) === -1 && !hasProxy) {
this.data.push(value);
}
return this;
},
delete(value) {
const index = this.data.indexOf(value);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
forEach(cb) {
this.data.forEach((value) => {
cb(value, value, this);
});
},
get [Symbol.toStringTag]() {
return "Set";
},
toJSON() {
return {};
},
[Symbol.iterator]() {
return this.data[Symbol.iterator]();
},
values() {
return this.data.values();
},
keys() {
return this.data.values();
},
entries() {
return new Set(this.data).entries();
}
});
Object.defineProperties(set, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(set);
return set;
}
function proxyMap(entries) {
const map = proxy({
data: Array.from(entries || []),
has(key) {
return this.data.some((p) => p[0] === key);
},
set(key, value) {
const record = this.data.find((p) => p[0] === key);
if (record) {
record[1] = value;
} else {
this.data.push([key, value]);
}
return this;
},
get(key) {
var _a;
return (_a = this.data.find((p) => p[0] === key)) == null ? void 0 : _a[1];
},
delete(key) {
const index = this.data.findIndex((p) => p[0] === key);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
toJSON() {
return {};
},
forEach(cb) {
this.data.forEach((p) => {
cb(p[1], p[0], this);
});
},
keys() {
return this.data.map((p) => p[0]).values();
},
values() {
return this.data.map((p) => p[1]).values();
},
entries() {
return new Map(this.data).entries();
},
get [Symbol.toStringTag]() {
return "Map";
},
[Symbol.iterator]() {
return this.entries();
}
});
Object.defineProperties(map, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(map);
return map;
}
export { addComputed_DEPRECATED as addComputed, derive, devtools, proxyMap, proxySet, proxyWithComputed, proxyWithHistory, subscribeKey, underive, unstable_deriveSubscriptions, watch };

577
node_modules/valtio/esm/utils.mjs generated vendored Normal file
View File

@@ -0,0 +1,577 @@
import { subscribe, snapshot, proxy, getVersion, ref } from 'valtio/vanilla';
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return subscribe(
proxyObject,
(ops) => {
if (ops.some((op) => op[1][0] === key)) {
callback(proxyObject[key]);
}
},
notifyInSync
);
}
let currentCleanups;
function watch(callback, options) {
let alive = true;
const cleanups = /* @__PURE__ */ new Set();
const subscriptions = /* @__PURE__ */ new Map();
const cleanup = () => {
if (alive) {
alive = false;
cleanups.forEach((clean) => clean());
cleanups.clear();
subscriptions.forEach((unsubscribe) => unsubscribe());
subscriptions.clear();
}
};
const revalidate = () => {
if (!alive) {
return;
}
cleanups.forEach((clean) => clean());
cleanups.clear();
const proxiesToSubscribe = /* @__PURE__ */ new Set();
const parent = currentCleanups;
currentCleanups = cleanups;
try {
const cleanupReturn = callback((proxyObject) => {
proxiesToSubscribe.add(proxyObject);
return proxyObject;
});
if (cleanupReturn) {
cleanups.add(cleanupReturn);
}
} finally {
currentCleanups = parent;
}
subscriptions.forEach((unsubscribe, proxyObject) => {
if (proxiesToSubscribe.has(proxyObject)) {
proxiesToSubscribe.delete(proxyObject);
} else {
subscriptions.delete(proxyObject);
unsubscribe();
}
});
proxiesToSubscribe.forEach((proxyObject) => {
const unsubscribe = subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync);
subscriptions.set(proxyObject, unsubscribe);
});
};
if (currentCleanups) {
currentCleanups.add(cleanup);
}
revalidate();
return cleanup;
}
const DEVTOOLS = Symbol();
function devtools(proxyObject, options) {
if (typeof options === "string") {
console.warn(
"string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"
);
options = { name: options };
}
const { enabled, name = "" } = options || {};
let extension;
try {
extension = (enabled != null ? enabled : (import.meta.env && import.meta.env.MODE) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
} catch {
}
if (!extension) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && enabled) {
console.warn("[Warning] Please install/enable Redux devtools extension");
}
return;
}
let isTimeTraveling = false;
const devtools2 = extension.connect({ name });
const unsub1 = subscribe(proxyObject, (ops) => {
const action = ops.filter(([_, path]) => path[0] !== DEVTOOLS).map(([op, path]) => `${op}:${path.map(String).join(".")}`).join(", ");
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
const snapWithoutDevtools = Object.assign({}, snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools2.send(
{
type: action,
updatedAt: new Date().toLocaleString()
},
snapWithoutDevtools
);
}
});
const unsub2 = devtools2.subscribe((message) => {
var _a, _b, _c, _d, _e, _f;
if (message.type === "ACTION" && message.payload) {
try {
Object.assign(proxyObject, JSON.parse(message.payload));
} catch (e) {
console.error(
"please dispatch a serializable value that JSON.parse() and proxy() support\n",
e
);
}
}
if (message.type === "DISPATCH" && message.state) {
if (((_a = message.payload) == null ? void 0 : _a.type) === "JUMP_TO_ACTION" || ((_b = message.payload) == null ? void 0 : _b.type) === "JUMP_TO_STATE") {
isTimeTraveling = true;
const state = JSON.parse(message.state);
Object.assign(proxyObject, state);
}
proxyObject[DEVTOOLS] = message;
} else if (message.type === "DISPATCH" && ((_c = message.payload) == null ? void 0 : _c.type) === "COMMIT") {
devtools2.init(snapshot(proxyObject));
} else if (message.type === "DISPATCH" && ((_d = message.payload) == null ? void 0 : _d.type) === "IMPORT_STATE") {
const actions = (_e = message.payload.nextLiftedState) == null ? void 0 : _e.actionsById;
const computedStates = ((_f = message.payload.nextLiftedState) == null ? void 0 : _f.computedStates) || [];
isTimeTraveling = true;
computedStates.forEach(({ state }, index) => {
const action = actions[index] || "No action found";
Object.assign(proxyObject, state);
if (index === 0) {
devtools2.init(snapshot(proxyObject));
} else {
devtools2.send(action, snapshot(proxyObject));
}
});
}
});
devtools2.init(snapshot(proxyObject));
return () => {
unsub1();
unsub2 == null ? void 0 : unsub2();
};
}
const sourceObjectMap = /* @__PURE__ */ new WeakMap();
const derivedObjectMap = /* @__PURE__ */ new WeakMap();
const markPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
markPending(derivedObject);
}
});
++sourceObjectEntry[2];
if (callback) {
sourceObjectEntry[3].add(callback);
}
}
};
const checkPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry == null ? void 0 : sourceObjectEntry[2]) {
sourceObjectEntry[3].add(callback);
return true;
}
return false;
};
const unmarkPending = (sourceObject) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
--sourceObjectEntry[2];
if (!sourceObjectEntry[2]) {
sourceObjectEntry[3].forEach((callback) => callback());
sourceObjectEntry[3].clear();
}
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
unmarkPending(derivedObject);
}
});
}
};
const addSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
let derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (!derivedObjectEntry) {
derivedObjectEntry = [/* @__PURE__ */ new Set()];
derivedObjectMap.set(subscription.d, derivedObjectEntry);
}
derivedObjectEntry[0].add(subscription);
let sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (!sourceObjectEntry) {
const subscriptions = /* @__PURE__ */ new Set();
const unsubscribe = subscribe(
sourceObject,
(ops) => {
subscriptions.forEach((subscription2) => {
const {
d: derivedObject2,
c: callback,
n: notifyInSync,
i: ignoreKeys
} = subscription2;
if (sourceObject === derivedObject2 && ops.every(
(op) => op[1].length === 1 && ignoreKeys.includes(op[1][0])
)) {
return;
}
if (subscription2.p) {
return;
}
markPending(sourceObject, callback);
if (notifyInSync) {
unmarkPending(sourceObject);
} else {
subscription2.p = Promise.resolve().then(() => {
delete subscription2.p;
unmarkPending(sourceObject);
});
}
});
},
true
);
sourceObjectEntry = [subscriptions, unsubscribe, 0, /* @__PURE__ */ new Set()];
sourceObjectMap.set(sourceObject, sourceObjectEntry);
}
sourceObjectEntry[0].add(subscription);
};
const removeSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].delete(subscription);
if ((derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].size) === 0) {
derivedObjectMap.delete(derivedObject);
}
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
const [subscriptions, unsubscribe] = sourceObjectEntry;
subscriptions.delete(subscription);
if (!subscriptions.size) {
unsubscribe();
sourceObjectMap.delete(sourceObject);
}
}
};
const listSubscriptions = (derivedObject) => {
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (derivedObjectEntry) {
return Array.from(derivedObjectEntry[0]);
}
return [];
};
const unstable_deriveSubscriptions = {
add: addSubscription,
remove: removeSubscription,
list: listSubscriptions
};
function derive(derivedFns, options) {
const proxyObject = (options == null ? void 0 : options.proxy) || proxy({});
const notifyInSync = !!(options == null ? void 0 : options.sync);
const derivedKeys = Object.keys(derivedFns);
derivedKeys.forEach((key) => {
if (Object.getOwnPropertyDescriptor(proxyObject, key)) {
throw new Error("object property already defined");
}
const fn = derivedFns[key];
let lastDependencies = null;
const evaluate = () => {
if (lastDependencies) {
if (Array.from(lastDependencies).map(([p]) => checkPending(p, evaluate)).some((isPending) => isPending)) {
return;
}
if (Array.from(lastDependencies).every(
([p, entry]) => getVersion(p) === entry.v
)) {
return;
}
}
const dependencies = /* @__PURE__ */ new Map();
const get = (p) => {
dependencies.set(p, { v: getVersion(p) });
return p;
};
const value = fn(get);
const subscribeToDependencies = () => {
dependencies.forEach((entry, p) => {
var _a;
const lastSubscription = (_a = lastDependencies == null ? void 0 : lastDependencies.get(p)) == null ? void 0 : _a.s;
if (lastSubscription) {
entry.s = lastSubscription;
} else {
const subscription = {
s: p,
d: proxyObject,
k: key,
c: evaluate,
n: notifyInSync,
i: derivedKeys
};
addSubscription(subscription);
entry.s = subscription;
}
});
lastDependencies == null ? void 0 : lastDependencies.forEach((entry, p) => {
if (!dependencies.has(p) && entry.s) {
removeSubscription(entry.s);
}
});
lastDependencies = dependencies;
};
if (value instanceof Promise) {
value.finally(subscribeToDependencies);
} else {
subscribeToDependencies();
}
proxyObject[key] = value;
};
evaluate();
});
return proxyObject;
}
function underive(proxyObject, options) {
const keysToDelete = (options == null ? void 0 : options.delete) ? /* @__PURE__ */ new Set() : null;
listSubscriptions(proxyObject).forEach((subscription) => {
const { k: key } = subscription;
if (!(options == null ? void 0 : options.keys) || options.keys.includes(key)) {
removeSubscription(subscription);
if (keysToDelete) {
keysToDelete.add(key);
}
}
});
if (keysToDelete) {
keysToDelete.forEach((key) => {
delete proxyObject[key];
});
}
}
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject = proxyObject) {
console.warn(
"addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive. https://github.com/pmndrs/valtio/pull/201"
);
const derivedFns = {};
Object.keys(computedFns_FAKE).forEach((key) => {
derivedFns[key] = (get) => computedFns_FAKE[key](get(proxyObject));
});
return derive(derivedFns, { proxy: targetObject });
}
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach((key) => {
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
throw new Error("object property already defined");
}
const computedFn = computedFns[key];
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
const desc = {};
desc.get = () => get(snapshot(proxyObject));
if (set) {
desc.set = (newValue) => set(proxyObject, newValue);
}
Object.defineProperty(initialObject, key, desc);
});
const proxyObject = proxy(initialObject);
return proxyObject;
}
const isObject = (x) => typeof x === "object" && x !== null;
const deepClone = (obj) => {
if (!isObject(obj)) {
return obj;
}
const baseObject = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
Reflect.ownKeys(obj).forEach((key) => {
baseObject[key] = deepClone(obj[key]);
});
return baseObject;
};
function proxyWithHistory(initialValue, skipSubscribe = false) {
const proxyObject = proxy({
value: initialValue,
history: ref({
wip: void 0,
snapshots: [],
index: -1
}),
canUndo: () => proxyObject.history.index > 0,
undo: () => {
if (proxyObject.canUndo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[--proxyObject.history.index]
);
}
},
canRedo: () => proxyObject.history.index < proxyObject.history.snapshots.length - 1,
redo: () => {
if (proxyObject.canRedo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[++proxyObject.history.index]
);
}
},
saveHistory: () => {
proxyObject.history.snapshots.splice(proxyObject.history.index + 1);
proxyObject.history.snapshots.push(snapshot(proxyObject).value);
++proxyObject.history.index;
},
subscribe: () => subscribe(proxyObject, (ops) => {
if (ops.every(
(op) => op[1][0] === "value" && (op[0] !== "set" || op[2] !== proxyObject.history.wip)
)) {
proxyObject.saveHistory();
}
})
});
proxyObject.saveHistory();
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;
}
function proxySet(initialValues) {
const set = proxy({
data: Array.from(new Set(initialValues)),
has(value) {
return this.data.indexOf(value) !== -1;
},
add(value) {
let hasProxy = false;
if (typeof value === "object" && value !== null) {
hasProxy = this.data.indexOf(proxy(value)) !== -1;
}
if (this.data.indexOf(value) === -1 && !hasProxy) {
this.data.push(value);
}
return this;
},
delete(value) {
const index = this.data.indexOf(value);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
forEach(cb) {
this.data.forEach((value) => {
cb(value, value, this);
});
},
get [Symbol.toStringTag]() {
return "Set";
},
toJSON() {
return {};
},
[Symbol.iterator]() {
return this.data[Symbol.iterator]();
},
values() {
return this.data.values();
},
keys() {
return this.data.values();
},
entries() {
return new Set(this.data).entries();
}
});
Object.defineProperties(set, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(set);
return set;
}
function proxyMap(entries) {
const map = proxy({
data: Array.from(entries || []),
has(key) {
return this.data.some((p) => p[0] === key);
},
set(key, value) {
const record = this.data.find((p) => p[0] === key);
if (record) {
record[1] = value;
} else {
this.data.push([key, value]);
}
return this;
},
get(key) {
var _a;
return (_a = this.data.find((p) => p[0] === key)) == null ? void 0 : _a[1];
},
delete(key) {
const index = this.data.findIndex((p) => p[0] === key);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
toJSON() {
return {};
},
forEach(cb) {
this.data.forEach((p) => {
cb(p[1], p[0], this);
});
},
keys() {
return this.data.map((p) => p[0]).values();
},
values() {
return this.data.map((p) => p[1]).values();
},
entries() {
return new Map(this.data).entries();
},
get [Symbol.toStringTag]() {
return "Map";
},
[Symbol.iterator]() {
return this.entries();
}
});
Object.defineProperties(map, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(map);
return map;
}
export { addComputed_DEPRECATED as addComputed, derive, devtools, proxyMap, proxySet, proxyWithComputed, proxyWithHistory, subscribeKey, underive, unstable_deriveSubscriptions, watch };

8
node_modules/valtio/esm/utils/addComputed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/**
* addComputed (DEPRECATED)
*
* @deprecated Please consider using `derive` or `proxyWithComputed` instead.
*/
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any): any;

72
node_modules/valtio/esm/utils/derive.d.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
declare type DeriveGet = <T extends object>(proxyObject: T) => T;
declare type Subscription = {
s: object;
d: object;
k: string;
c: () => void;
n: boolean;
i: string[];
p?: Promise<void>;
};
export declare const unstable_deriveSubscriptions: {
add: (subscription: Subscription) => void;
remove: (subscription: Subscription) => void;
list: (derivedObject: object) => Subscription[];
};
/**
* derive
*
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.
*
* @example
* import { proxy } from 'valtio'
* import { derive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* derive({
* tripled: (get) => get(state).count * 3,
* }, {
* proxy: state,
* })
*/
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];
}, options?: {
proxy?: T;
sync?: boolean;
}): T & U;
/**
* underive
*
* This stops derived properties to evaluate.
* It will stop all (or specified by `keys` option) subscriptions.
* If you specify `delete` option, it will delete the properties
* and you can attach new derived properties.
*
* @example
* import { proxy } from 'valtio'
* import { derive, underive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* underive(derivedState)
*/
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
}): void;
export {};

10
node_modules/valtio/esm/utils/devtools.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
declare type Options = {
enabled?: boolean;
name?: string;
};
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;
/**
* @deprecated Please use { name } option
*/
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;
export {};

29
node_modules/valtio/esm/utils/proxyMap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* proxyMap
*
* This is to create a proxy which mimic the native Map behavior.
* The API is the same as Map API
*
* @example
* import { proxyMap } from 'valtio/utils'
* const state = proxyMap([["key", "value"]])
*
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* map: proxyMap()
* })
*
* // When using an object as a key, you can wrap it with `ref` so it's not proxied
* // this is useful if you want to preserve the key equality
* import { ref } from 'valtio'
*
* const key = ref({})
* state.set(key, "value")
* state.get(key) //value
*
* const key = {}
* state.set(key, "value")
* state.get(key) //undefined
*/
export declare function proxyMap<K, V>(entries?: Iterable<readonly [K, V]> | null): Map<K, V>;

16
node_modules/valtio/esm/utils/proxySet.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* proxySet
*
* This is to create a proxy which mimic the native Set behavior.
* The API is the same as Set API
*
* @example
* import { proxySet } from 'valtio/utils'
* const state = proxySet([1,2,3])
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* set: proxySet()
* })
*/
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

31
node_modules/valtio/esm/utils/proxyWithComputed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import type { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithComputed
*
* This is to create a proxy with initial object and additional object,
* which specifies getters for computed values with dependency tracking.
* It also accepts optional setters for computed values.
*
* [Notes]
* This comes with a cost and overlaps with useSnapshot.
* Do not try to optimize too early. It can worsen the performance.
* Measurement and comparison will be very important.
*
* @example
* import { proxyWithComputed } from 'valtio/utils'
* const state = proxyWithComputed({
* count: 1,
* }, {
* doubled: snap => snap.count * 2, // getter only
* tripled: {
* get: snap => snap.count * 3,
* set: (state, newValue) => { state.count = newValue / 3 }
* }, // with optional setter
* })
*/
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: INTERNAL_Snapshot<T>) => U[K]) | {
get: (snap: INTERNAL_Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
};
}): T & U;

40
node_modules/valtio/esm/utils/proxyWithHistory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import type { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithHistory
*
* This creates a new proxy with history support.
* It includes following properties:
* - value: any value (does not have to be an object)
* - history: an array holding the history of snapshots
* - historyIndex: the history index to the current snapshot
* - canUndo: a function to return true if undo is available
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available
* - redo: a function to go forward history
* - saveHistory: a function to save history
*
* [Notes]
* Suspense/promise is not supported.
*
* @example
* import { proxyWithHistory } from 'valtio/utils'
* const state = proxyWithHistory({
* count: 1,
* })
*/
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;
history: {
wip: INTERNAL_Snapshot<V> | undefined;
snapshots: INTERNAL_Snapshot<V>[];
index: number;
} & {
$$valtioRef: true;
};
canUndo: () => boolean;
undo: () => void;
canRedo: () => boolean;
redo: () => void;
saveHistory: () => void;
subscribe: () => () => void;
};

12
node_modules/valtio/esm/utils/subscribeKey.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* subscribeKey
*
* The subscribeKey utility enables subscription to a primitive subproperty of a given state proxy.
* Subscriptions created with subscribeKey will only fire when the specified property changes.
* notifyInSync: same as the parameter to subscribe(); true disables batching of subscriptions.
*
* @example
* import { subscribeKey } from 'valtio/utils'
* subscribeKey(state, 'count', (v) => console.log('state.count has changed to', v))
*/
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

31
node_modules/valtio/esm/utils/watch.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
declare type Cleanup = () => void;
declare type WatchGet = <T extends object>(proxyObject: T) => T;
declare type WatchCallback = (get: WatchGet) => Cleanup | void | undefined;
declare type WatchOptions = {
sync?: boolean;
};
/**
* watch
*
* Creates a reactive effect that automatically tracks proxy objects and
* reevaluates everytime one of the tracked proxy objects updates. It returns
* a cleanup function to stop the reactive effect from reevaluating.
*
* Callback is invoked immediately to detect the tracked objects.
*
* Callback passed to `watch` receives a `get` function that "tracks" the
* passed proxy object.
*
* Watch callbacks may return an optional cleanup function, which is evaluated
* whenever the callback reevaluates or when the cleanup function returned by
* `watch` is evaluated.
*
* `watch` calls inside `watch` are also automatically tracked and cleaned up
* whenever the parent `watch` reevaluates.
*
* @param callback
* @returns A cleanup function that stops the callback from reevaluating and
* also performs cleanups registered into `watch`.
*/
export declare function watch(callback: WatchCallback, options?: WatchOptions): Cleanup;
export {};

20
node_modules/valtio/esm/vanilla.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
declare type AsRef = {
$$valtioRef: true;
};
declare type Path = (string | symbol)[];
declare type Op = [op: 'set', path: Path, value: unknown, prevValue: unknown] | [op: 'delete', path: Path, prevValue: unknown] | [op: 'resolve', path: Path, value: unknown] | [op: 'reject', path: Path, error: unknown];
declare type AnyFunction = (...args: any[]) => any;
/**
* This is not a public API.
* It can be changed without any notice.
*/
export declare type INTERNAL_Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? INTERNAL_Snapshot<V> : {
readonly [K in keyof T]: INTERNAL_Snapshot<T[K]>;
};
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
export declare function snapshot<T extends object>(proxyObject: T): INTERNAL_Snapshot<T>;
export declare function ref<T extends object>(obj: T): T & AsRef;
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, PROMISE_RESULT?: symbol, PROMISE_ERROR?: symbol, snapshotCache?: WeakMap<object, [version: number, snapshot: unknown]>, createSnapshot?: <T_1 extends object>(version: number, target: T_1, receiver: any) => T_1, proxyCache?: WeakMap<object, object>, versionHolder?: [number], proxyFunction?: <T_2 extends object>(initialObject: T_2) => T_2) => readonly [<T_2 extends object>(initialObject: T_2) => T_2, WeakSet<object>, symbol, symbol, symbol, (value1: any, value2: any) => boolean, <T extends object>(target: T, handler: ProxyHandler<T>) => T, (x: unknown) => boolean, symbol, symbol, WeakMap<object, [version: number, snapshot: unknown]>, <T_1 extends object>(version: number, target: T_1, receiver: any) => T_1, WeakMap<object, object>, [number]];
export {};

215
node_modules/valtio/esm/vanilla.js generated vendored Normal file
View File

@@ -0,0 +1,215 @@
import { markToTrack, getUntracked } from 'proxy-compare';
const isObject = (x) => typeof x === "object" && x !== null;
const refSet = /* @__PURE__ */ new WeakSet();
const VERSION = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("VERSION") : Symbol();
const LISTENERS = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("LISTENERS") : Symbol();
const SNAPSHOT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("SNAPSHOT") : Symbol();
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), PROMISE_RESULT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_RESULT") : Symbol(), PROMISE_ERROR = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_ERROR") : Symbol(), snapshotCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (version, target, receiver) => {
const cache = snapshotCache.get(receiver);
if ((cache == null ? void 0 : cache[0]) === version) {
return cache[1];
}
const snapshot2 = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
markToTrack(snapshot2, true);
snapshotCache.set(receiver, [version, snapshot2]);
Reflect.ownKeys(target).forEach((key) => {
const value = Reflect.get(target, key, receiver);
if (refSet.has(value)) {
markToTrack(value, false);
snapshot2[key] = value;
} else if (value instanceof Promise) {
if (PROMISE_RESULT in value) {
snapshot2[key] = value[PROMISE_RESULT];
} else {
const errorOrPromise = value[PROMISE_ERROR] || value;
Object.defineProperty(snapshot2, key, {
get() {
if (PROMISE_RESULT in value) {
return value[PROMISE_RESULT];
}
throw errorOrPromise;
}
});
}
} else if (value == null ? void 0 : value[LISTENERS]) {
snapshot2[key] = value[SNAPSHOT];
} else {
snapshot2[key] = value;
}
});
return Object.freeze(snapshot2);
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1], proxyFunction2 = (initialObject) => {
if (!isObject(initialObject)) {
throw new Error("object required");
}
const found = proxyCache.get(initialObject);
if (found) {
return found;
}
let version = versionHolder[0];
const listeners = /* @__PURE__ */ new Set();
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
if (version !== nextVersion) {
version = nextVersion;
listeners.forEach((listener) => listener(op, nextVersion));
}
};
const propListeners = /* @__PURE__ */ new Map();
const getPropListener = (prop) => {
let propListener = propListeners.get(prop);
if (!propListener) {
propListener = (op, nextVersion) => {
const newOp = [...op];
newOp[1] = [prop, ...newOp[1]];
notifyUpdate(newOp, nextVersion);
};
propListeners.set(prop, propListener);
}
return propListener;
};
const popPropListener = (prop) => {
const propListener = propListeners.get(prop);
propListeners.delete(prop);
return propListener;
};
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
const handler = {
get(target, prop, receiver) {
if (prop === VERSION) {
return version;
}
if (prop === LISTENERS) {
return listeners;
}
if (prop === SNAPSHOT) {
return createSnapshot(version, target, receiver);
}
return Reflect.get(target, prop, receiver);
},
deleteProperty(target, prop) {
const prevValue = Reflect.get(target, prop);
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
const deleted = Reflect.deleteProperty(target, prop);
if (deleted) {
notifyUpdate(["delete", [prop], prevValue]);
}
return deleted;
},
set(target, prop, value, receiver) {
var _a;
const hasPrevValue = Reflect.has(target, prop);
const prevValue = Reflect.get(target, prop, receiver);
if (hasPrevValue && objectIs(prevValue, value)) {
return true;
}
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
if (isObject(value)) {
value = getUntracked(value) || value;
}
let nextValue;
if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) {
nextValue = value;
} else if (value instanceof Promise) {
nextValue = value.then((v) => {
nextValue[PROMISE_RESULT] = v;
notifyUpdate(["resolve", [prop], v]);
return v;
}).catch((e) => {
nextValue[PROMISE_ERROR] = e;
notifyUpdate(["reject", [prop], e]);
});
} else if (value == null ? void 0 : value[LISTENERS]) {
nextValue = value;
nextValue[LISTENERS].add(getPropListener(prop));
} else if (canProxy(value)) {
nextValue = proxy(value);
nextValue[LISTENERS].add(getPropListener(prop));
} else {
nextValue = value;
}
Reflect.set(target, prop, nextValue, receiver);
notifyUpdate(["set", [prop], value, prevValue]);
return true;
}
};
const proxyObject = newProxy(baseObject, handler);
proxyCache.set(initialObject, proxyObject);
Reflect.ownKeys(initialObject).forEach((key) => {
const desc = Object.getOwnPropertyDescriptor(
initialObject,
key
);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
proxyObject[key] = initialObject[key];
}
});
return proxyObject;
}) => [
proxyFunction2,
refSet,
VERSION,
LISTENERS,
SNAPSHOT,
objectIs,
newProxy,
canProxy,
PROMISE_RESULT,
PROMISE_ERROR,
snapshotCache,
createSnapshot,
proxyCache,
versionHolder
];
const [proxyFunction] = buildProxyFunction();
function proxy(initialObject = {}) {
return proxyFunction(initialObject);
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : void 0;
}
function subscribe(proxyObject, callback, notifyInSync) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[LISTENERS])) {
console.warn("Please use proxy object");
}
let promise;
const ops = [];
const listener = (op) => {
ops.push(op);
if (notifyInSync) {
callback(ops.splice(0));
return;
}
if (!promise) {
promise = Promise.resolve().then(() => {
promise = void 0;
callback(ops.splice(0));
});
}
};
proxyObject[LISTENERS].add(listener);
return () => {
proxyObject[LISTENERS].delete(listener);
};
}
function snapshot(proxyObject) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[SNAPSHOT])) {
console.warn("Please use proxy object");
}
return proxyObject[SNAPSHOT];
}
function ref(obj) {
refSet.add(obj);
return obj;
}
const unstable_buildProxyFunction = buildProxyFunction;
export { getVersion, proxy, ref, snapshot, subscribe, unstable_buildProxyFunction };

215
node_modules/valtio/esm/vanilla.mjs generated vendored Normal file
View File

@@ -0,0 +1,215 @@
import { markToTrack, getUntracked } from 'proxy-compare';
const isObject = (x) => typeof x === "object" && x !== null;
const refSet = /* @__PURE__ */ new WeakSet();
const VERSION = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("VERSION") : Symbol();
const LISTENERS = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("LISTENERS") : Symbol();
const SNAPSHOT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("SNAPSHOT") : Symbol();
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), PROMISE_RESULT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_RESULT") : Symbol(), PROMISE_ERROR = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_ERROR") : Symbol(), snapshotCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (version, target, receiver) => {
const cache = snapshotCache.get(receiver);
if ((cache == null ? void 0 : cache[0]) === version) {
return cache[1];
}
const snapshot2 = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
markToTrack(snapshot2, true);
snapshotCache.set(receiver, [version, snapshot2]);
Reflect.ownKeys(target).forEach((key) => {
const value = Reflect.get(target, key, receiver);
if (refSet.has(value)) {
markToTrack(value, false);
snapshot2[key] = value;
} else if (value instanceof Promise) {
if (PROMISE_RESULT in value) {
snapshot2[key] = value[PROMISE_RESULT];
} else {
const errorOrPromise = value[PROMISE_ERROR] || value;
Object.defineProperty(snapshot2, key, {
get() {
if (PROMISE_RESULT in value) {
return value[PROMISE_RESULT];
}
throw errorOrPromise;
}
});
}
} else if (value == null ? void 0 : value[LISTENERS]) {
snapshot2[key] = value[SNAPSHOT];
} else {
snapshot2[key] = value;
}
});
return Object.freeze(snapshot2);
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1], proxyFunction2 = (initialObject) => {
if (!isObject(initialObject)) {
throw new Error("object required");
}
const found = proxyCache.get(initialObject);
if (found) {
return found;
}
let version = versionHolder[0];
const listeners = /* @__PURE__ */ new Set();
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
if (version !== nextVersion) {
version = nextVersion;
listeners.forEach((listener) => listener(op, nextVersion));
}
};
const propListeners = /* @__PURE__ */ new Map();
const getPropListener = (prop) => {
let propListener = propListeners.get(prop);
if (!propListener) {
propListener = (op, nextVersion) => {
const newOp = [...op];
newOp[1] = [prop, ...newOp[1]];
notifyUpdate(newOp, nextVersion);
};
propListeners.set(prop, propListener);
}
return propListener;
};
const popPropListener = (prop) => {
const propListener = propListeners.get(prop);
propListeners.delete(prop);
return propListener;
};
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
const handler = {
get(target, prop, receiver) {
if (prop === VERSION) {
return version;
}
if (prop === LISTENERS) {
return listeners;
}
if (prop === SNAPSHOT) {
return createSnapshot(version, target, receiver);
}
return Reflect.get(target, prop, receiver);
},
deleteProperty(target, prop) {
const prevValue = Reflect.get(target, prop);
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
const deleted = Reflect.deleteProperty(target, prop);
if (deleted) {
notifyUpdate(["delete", [prop], prevValue]);
}
return deleted;
},
set(target, prop, value, receiver) {
var _a;
const hasPrevValue = Reflect.has(target, prop);
const prevValue = Reflect.get(target, prop, receiver);
if (hasPrevValue && objectIs(prevValue, value)) {
return true;
}
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
if (isObject(value)) {
value = getUntracked(value) || value;
}
let nextValue;
if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) {
nextValue = value;
} else if (value instanceof Promise) {
nextValue = value.then((v) => {
nextValue[PROMISE_RESULT] = v;
notifyUpdate(["resolve", [prop], v]);
return v;
}).catch((e) => {
nextValue[PROMISE_ERROR] = e;
notifyUpdate(["reject", [prop], e]);
});
} else if (value == null ? void 0 : value[LISTENERS]) {
nextValue = value;
nextValue[LISTENERS].add(getPropListener(prop));
} else if (canProxy(value)) {
nextValue = proxy(value);
nextValue[LISTENERS].add(getPropListener(prop));
} else {
nextValue = value;
}
Reflect.set(target, prop, nextValue, receiver);
notifyUpdate(["set", [prop], value, prevValue]);
return true;
}
};
const proxyObject = newProxy(baseObject, handler);
proxyCache.set(initialObject, proxyObject);
Reflect.ownKeys(initialObject).forEach((key) => {
const desc = Object.getOwnPropertyDescriptor(
initialObject,
key
);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
proxyObject[key] = initialObject[key];
}
});
return proxyObject;
}) => [
proxyFunction2,
refSet,
VERSION,
LISTENERS,
SNAPSHOT,
objectIs,
newProxy,
canProxy,
PROMISE_RESULT,
PROMISE_ERROR,
snapshotCache,
createSnapshot,
proxyCache,
versionHolder
];
const [proxyFunction] = buildProxyFunction();
function proxy(initialObject = {}) {
return proxyFunction(initialObject);
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : void 0;
}
function subscribe(proxyObject, callback, notifyInSync) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[LISTENERS])) {
console.warn("Please use proxy object");
}
let promise;
const ops = [];
const listener = (op) => {
ops.push(op);
if (notifyInSync) {
callback(ops.splice(0));
return;
}
if (!promise) {
promise = Promise.resolve().then(() => {
promise = void 0;
callback(ops.splice(0));
});
}
};
proxyObject[LISTENERS].add(listener);
return () => {
proxyObject[LISTENERS].delete(listener);
};
}
function snapshot(proxyObject) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[SNAPSHOT])) {
console.warn("Please use proxy object");
}
return proxyObject[SNAPSHOT];
}
function ref(obj) {
refSet.add(obj);
return obj;
}
const unstable_buildProxyFunction = buildProxyFunction;
export { getVersion, proxy, ref, snapshot, subscribe, unstable_buildProxyFunction };

2
node_modules/valtio/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { useSnapshot } from './react';
export { ref, proxy, getVersion, subscribe, snapshot, unstable_buildProxyFunction, } from './vanilla';

87
node_modules/valtio/index.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var react = require('react');
var proxyCompare = require('proxy-compare');
var useSyncExternalStoreExports = require('use-sync-external-store/shim');
var vanilla = require('valtio/vanilla');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var useSyncExternalStoreExports__default = /*#__PURE__*/_interopDefaultLegacy(useSyncExternalStoreExports);
var useSyncExternalStore = useSyncExternalStoreExports__default["default"].useSyncExternalStore;
var useAffectedDebugValue = function useAffectedDebugValue(state, affected) {
var pathList = react.useRef();
react.useEffect(function () {
pathList.current = proxyCompare.affectedToPathList(state, affected);
});
react.useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
var notifyInSync = options == null ? void 0 : options.sync;
var lastSnapshot = react.useRef();
var lastAffected = react.useRef();
var inRender = true;
var currSnapshot = useSyncExternalStore(react.useCallback(function (callback) {
var unsub = vanilla.subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
}, [proxyObject, notifyInSync]), function () {
var nextSnapshot = vanilla.snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !proxyCompare.isChanged(lastSnapshot.current, nextSnapshot, lastAffected.current, new WeakMap())) {
return lastSnapshot.current;
}
} catch (e) {}
return nextSnapshot;
}, function () {
return vanilla.snapshot(proxyObject);
});
inRender = false;
var currAffected = new WeakMap();
react.useEffect(function () {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
if (process.env.NODE_ENV !== "production") {
useAffectedDebugValue(currSnapshot, currAffected);
}
var proxyCache = react.useMemo(function () {
return new WeakMap();
}, []);
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache);
}
Object.defineProperty(exports, 'getVersion', {
enumerable: true,
get: function () { return vanilla.getVersion; }
});
Object.defineProperty(exports, 'proxy', {
enumerable: true,
get: function () { return vanilla.proxy; }
});
Object.defineProperty(exports, 'ref', {
enumerable: true,
get: function () { return vanilla.ref; }
});
Object.defineProperty(exports, 'snapshot', {
enumerable: true,
get: function () { return vanilla.snapshot; }
});
Object.defineProperty(exports, 'subscribe', {
enumerable: true,
get: function () { return vanilla.subscribe; }
});
Object.defineProperty(exports, 'unstable_buildProxyFunction', {
enumerable: true,
get: function () { return vanilla.unstable_buildProxyFunction; }
});
exports.useSnapshot = useSnapshot;

3
node_modules/valtio/macro.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function useProxy<T extends object>(proxyObject: T): void;
declare const _default: any;
export default _default;

64
node_modules/valtio/macro.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helperModuleImports = require('@babel/helper-module-imports');
var t = require('@babel/types');
var babelPluginMacros = require('babel-plugin-macros');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var t__namespace = /*#__PURE__*/_interopNamespace(t);
var macro = function macro(_ref) {
var _references$useProxy;
var references = _ref.references;
(_references$useProxy = references.useProxy) == null ? void 0 : _references$useProxy.forEach(function (path) {
var _path$parentPath, _path$parentPath$get, _path$parentPath2, _path$parentPath2$par, _path$parentPath3, _path$parentPath3$get;
var hook = helperModuleImports.addNamed(path, 'useSnapshot', 'valtio');
var proxy = (_path$parentPath = path.parentPath) == null ? void 0 : (_path$parentPath$get = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath$get.node;
if (!t__namespace.isIdentifier(proxy)) throw new babelPluginMacros.MacroError('no proxy object');
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name);
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$par = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2$par.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))]));
var inFunction = 0;
(_path$parentPath3 = path.parentPath) == null ? void 0 : (_path$parentPath3$get = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3$get.traverse({
Identifier: function Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter: function enter() {
++inFunction;
},
exit: function exit() {
--inFunction;
}
}
});
});
};
var macro$1 = babelPluginMacros.createMacro(macro, {
configName: 'valtio'
});
exports["default"] = macro$1;

83
node_modules/valtio/macro/vite.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var babelModuleImports = require('@babel/helper-module-imports');
var t = require('@babel/types');
var plugin = require('aslemammad-vite-plugin-macro');
var babelMacro = require('babel-plugin-macros');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var babelModuleImports__namespace = /*#__PURE__*/_interopNamespace(babelModuleImports);
var t__namespace = /*#__PURE__*/_interopNamespace(t);
var plugin__namespace = /*#__PURE__*/_interopNamespace(plugin);
var babelMacro__namespace = /*#__PURE__*/_interopNamespace(babelMacro);
var _ref = 'default' in plugin__namespace ? plugin__namespace.default : plugin__namespace,
defineMacro = _ref.defineMacro,
defineMacroProvider = _ref.defineMacroProvider,
createMacroPlugin = _ref.createMacroPlugin;
var valtioMacro = defineMacro("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler(function (ctx) {
var _args$, _path$parentPath, _path$parentPath2, _path$parentPath2$get;
var path = ctx.path,
args = ctx.args;
var hook = babelModuleImports__namespace.addNamed(path, 'useSnapshot', 'valtio');
var proxy = (_args$ = args[0]) == null ? void 0 : _args$.node;
if (!t__namespace.isIdentifier(proxy)) {
throw new babelMacro__namespace.MacroError('no proxy object');
}
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name);
(_path$parentPath = path.parentPath) == null ? void 0 : _path$parentPath.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))]));
var inFunction = 0;
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$get = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2$get.traverse({
Identifier: function Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter: function enter() {
++inFunction;
},
exit: function exit() {
--inFunction;
}
}
});
});
function provideValtioMacro() {
return defineMacroProvider({
id: 'valtio/macro',
exports: {
'valtio/macro': {
macros: [valtioMacro]
}
}
});
}
var macroPlugin = createMacroPlugin({}).use(provideValtioMacro());
exports["default"] = macroPlugin;
exports.provideValtioMacro = provideValtioMacro;
exports.valtioMacro = valtioMacro;

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,5 @@
# use-sync-external-store
Backwards-compatible shim for [`React.useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Works with any React that supports Hooks.
See also https://github.com/reactwg/react-18/discussions/86.

View File

@@ -0,0 +1,239 @@
/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var React = require('react');
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function error(format) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
var stack = ReactDebugCurrentFrame.getStackAddendum();
if (stack !== '') {
format += '%s';
args = args.concat([stack]);
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
var objectIs = typeof Object.is === 'function' ? Object.is : is;
// dispatch for CommonJS interop named imports.
var useState = React.useState,
useEffect = React.useEffect,
useLayoutEffect = React.useLayoutEffect,
useDebugValue = React.useDebugValue;
var didWarnOld18Alpha = false;
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions
// -- change any one of them and it will break. The most important assumption
// is that updates are always synchronous, because concurrent rendering is
// only available in versions of React that also have a built-in
// useSyncExternalStore API. And we only use this shim when the built-in API
// does not exist.
//
// Do not assume that the clever hacks used by this hook also work in general.
// The point of this shim is to replace the need for hacks by other libraries.
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
getServerSnapshot) {
{
if (!didWarnOld18Alpha) {
if (React.startTransition !== undefined) {
didWarnOld18Alpha = true;
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
}
}
} // Read the current snapshot from the store on every render. Again, this
// breaks the rules of React, and only works here because of specific
// implementation details, most importantly that updates are
// always synchronous.
var value = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
var cachedValue = getSnapshot();
if (!objectIs(value, cachedValue)) {
error('The result of getSnapshot should be cached to avoid an infinite loop');
didWarnUncachedGetSnapshot = true;
}
}
} // Because updates are synchronous, we don't queue them. Instead we force a
// re-render whenever the subscribed state changes by updating an some
// arbitrary useState hook. Then, during render, we call getSnapshot to read
// the current value.
//
// Because we don't actually use the state returned by the useState hook, we
// can save a bit of memory by storing other stuff in that slot.
//
// To implement the early bailout, we need to track some things on a mutable
// object. Usually, we would put that in a useRef hook, but we can stash it in
// our useState hook instead.
//
// To force a re-render, we call forceUpdate({inst}). That works because the
// new object always fails an equality check.
var _useState = useState({
inst: {
value: value,
getSnapshot: getSnapshot
}
}),
inst = _useState[0].inst,
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
useLayoutEffect(function () {
inst.value = value;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
}, [subscribe, value, getSnapshot]);
useEffect(function () {
// Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
var handleStoreChange = function () {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
}; // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange);
}, [subscribe]);
useDebugValue(value);
return value;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
var prevValue = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(prevValue, nextValue);
} catch (error) {
return true;
}
}
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
return getSnapshot();
}
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
var isServerEnvironment = !canUseDOM;
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
exports.useSyncExternalStore = useSyncExternalStore$2;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

View File

@@ -0,0 +1,227 @@
/**
* @license React
* use-sync-external-store-shim.native.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var React = require('react');
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function error(format) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
var stack = ReactDebugCurrentFrame.getStackAddendum();
if (stack !== '') {
format += '%s';
args = args.concat([stack]);
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
var objectIs = typeof Object.is === 'function' ? Object.is : is;
// dispatch for CommonJS interop named imports.
var useState = React.useState,
useEffect = React.useEffect,
useLayoutEffect = React.useLayoutEffect,
useDebugValue = React.useDebugValue;
var didWarnOld18Alpha = false;
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions
// -- change any one of them and it will break. The most important assumption
// is that updates are always synchronous, because concurrent rendering is
// only available in versions of React that also have a built-in
// useSyncExternalStore API. And we only use this shim when the built-in API
// does not exist.
//
// Do not assume that the clever hacks used by this hook also work in general.
// The point of this shim is to replace the need for hacks by other libraries.
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
getServerSnapshot) {
{
if (!didWarnOld18Alpha) {
if (React.startTransition !== undefined) {
didWarnOld18Alpha = true;
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
}
}
} // Read the current snapshot from the store on every render. Again, this
// breaks the rules of React, and only works here because of specific
// implementation details, most importantly that updates are
// always synchronous.
var value = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
var cachedValue = getSnapshot();
if (!objectIs(value, cachedValue)) {
error('The result of getSnapshot should be cached to avoid an infinite loop');
didWarnUncachedGetSnapshot = true;
}
}
} // Because updates are synchronous, we don't queue them. Instead we force a
// re-render whenever the subscribed state changes by updating an some
// arbitrary useState hook. Then, during render, we call getSnapshot to read
// the current value.
//
// Because we don't actually use the state returned by the useState hook, we
// can save a bit of memory by storing other stuff in that slot.
//
// To implement the early bailout, we need to track some things on a mutable
// object. Usually, we would put that in a useRef hook, but we can stash it in
// our useState hook instead.
//
// To force a re-render, we call forceUpdate({inst}). That works because the
// new object always fails an equality check.
var _useState = useState({
inst: {
value: value,
getSnapshot: getSnapshot
}
}),
inst = _useState[0].inst,
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
useLayoutEffect(function () {
inst.value = value;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
}, [subscribe, value, getSnapshot]);
useEffect(function () {
// Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
var handleStoreChange = function () {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst: inst
});
}
}; // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange);
}, [subscribe]);
useDebugValue(value);
return value;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
var prevValue = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(prevValue, nextValue);
} catch (error) {
return true;
}
}
var shim = useSyncExternalStore;
var useSyncExternalStore$1 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
exports.useSyncExternalStore = useSyncExternalStore$1;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

View File

@@ -0,0 +1,11 @@
/**
* @license React
* use-sync-external-store-shim.native.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var e=require("react");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:q;

View File

@@ -0,0 +1,11 @@
/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var e=require("react");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;

View File

@@ -0,0 +1,165 @@
/**
* @license React
* use-sync-external-store-shim/with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var React = require('react');
var shim = require('use-sync-external-store/shim');
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
var objectIs = typeof Object.is === 'function' ? Object.is : is;
var useSyncExternalStore = shim.useSyncExternalStore;
// for CommonJS interop.
var useRef = React.useRef,
useEffect = React.useEffect,
useMemo = React.useMemo,
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
// Use this to track the rendered snapshot.
var instRef = useRef(null);
var inst;
if (instRef.current === null) {
inst = {
hasValue: false,
value: null
};
instRef.current = inst;
} else {
inst = instRef.current;
}
var _useMemo = useMemo(function () {
// Track the memoized state using closure variables that are local to this
// memoized instance of a getSnapshot function. Intentionally not using a
// useRef hook, because that state would be shared across all concurrent
// copies of the hook/component.
var hasMemo = false;
var memoizedSnapshot;
var memoizedSelection;
var memoizedSelector = function (nextSnapshot) {
if (!hasMemo) {
// The first time the hook is called, there is no memoized result.
hasMemo = true;
memoizedSnapshot = nextSnapshot;
var _nextSelection = selector(nextSnapshot);
if (isEqual !== undefined) {
// Even if the selector has changed, the currently rendered selection
// may be equal to the new selection. We should attempt to reuse the
// current value if possible, to preserve downstream memoizations.
if (inst.hasValue) {
var currentSelection = inst.value;
if (isEqual(currentSelection, _nextSelection)) {
memoizedSelection = currentSelection;
return currentSelection;
}
}
}
memoizedSelection = _nextSelection;
return _nextSelection;
} // We may be able to reuse the previous invocation's result.
// We may be able to reuse the previous invocation's result.
var prevSnapshot = memoizedSnapshot;
var prevSelection = memoizedSelection;
if (objectIs(prevSnapshot, nextSnapshot)) {
// The snapshot is the same as last time. Reuse the previous selection.
return prevSelection;
} // The snapshot has changed, so we need to compute a new selection.
// The snapshot has changed, so we need to compute a new selection.
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
// has changed. If it hasn't, return the previous selection. That signals
// to React that the selections are conceptually equal, and we can bail
// out of rendering.
// If a custom isEqual function is provided, use that to check if the data
// has changed. If it hasn't, return the previous selection. That signals
// to React that the selections are conceptually equal, and we can bail
// out of rendering.
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
return prevSelection;
}
memoizedSnapshot = nextSnapshot;
memoizedSelection = nextSelection;
return nextSelection;
}; // Assigning this to a constant so that Flow knows it can't change.
// Assigning this to a constant so that Flow knows it can't change.
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
var getSnapshotWithSelector = function () {
return memoizedSelector(getSnapshot());
};
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
return memoizedSelector(maybeGetServerSnapshot());
};
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
getSelection = _useMemo[0],
getServerSelection = _useMemo[1];
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
useEffect(function () {
inst.hasValue = true;
inst.value = value;
}, [value]);
useDebugValue(value);
return value;
}
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

View File

@@ -0,0 +1,12 @@
/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var h=require("react"),n=require("use-sync-external-store/shim");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
u(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};

View File

@@ -0,0 +1,164 @@
/**
* @license React
* use-sync-external-store-with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var React = require('react');
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
var objectIs = typeof Object.is === 'function' ? Object.is : is;
var useSyncExternalStore = React.useSyncExternalStore;
// for CommonJS interop.
var useRef = React.useRef,
useEffect = React.useEffect,
useMemo = React.useMemo,
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
// Use this to track the rendered snapshot.
var instRef = useRef(null);
var inst;
if (instRef.current === null) {
inst = {
hasValue: false,
value: null
};
instRef.current = inst;
} else {
inst = instRef.current;
}
var _useMemo = useMemo(function () {
// Track the memoized state using closure variables that are local to this
// memoized instance of a getSnapshot function. Intentionally not using a
// useRef hook, because that state would be shared across all concurrent
// copies of the hook/component.
var hasMemo = false;
var memoizedSnapshot;
var memoizedSelection;
var memoizedSelector = function (nextSnapshot) {
if (!hasMemo) {
// The first time the hook is called, there is no memoized result.
hasMemo = true;
memoizedSnapshot = nextSnapshot;
var _nextSelection = selector(nextSnapshot);
if (isEqual !== undefined) {
// Even if the selector has changed, the currently rendered selection
// may be equal to the new selection. We should attempt to reuse the
// current value if possible, to preserve downstream memoizations.
if (inst.hasValue) {
var currentSelection = inst.value;
if (isEqual(currentSelection, _nextSelection)) {
memoizedSelection = currentSelection;
return currentSelection;
}
}
}
memoizedSelection = _nextSelection;
return _nextSelection;
} // We may be able to reuse the previous invocation's result.
// We may be able to reuse the previous invocation's result.
var prevSnapshot = memoizedSnapshot;
var prevSelection = memoizedSelection;
if (objectIs(prevSnapshot, nextSnapshot)) {
// The snapshot is the same as last time. Reuse the previous selection.
return prevSelection;
} // The snapshot has changed, so we need to compute a new selection.
// The snapshot has changed, so we need to compute a new selection.
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
// has changed. If it hasn't, return the previous selection. That signals
// to React that the selections are conceptually equal, and we can bail
// out of rendering.
// If a custom isEqual function is provided, use that to check if the data
// has changed. If it hasn't, return the previous selection. That signals
// to React that the selections are conceptually equal, and we can bail
// out of rendering.
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
return prevSelection;
}
memoizedSnapshot = nextSnapshot;
memoizedSelection = nextSelection;
return nextSelection;
}; // Assigning this to a constant so that Flow knows it can't change.
// Assigning this to a constant so that Flow knows it can't change.
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
var getSnapshotWithSelector = function () {
return memoizedSelector(getSnapshot());
};
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
return memoizedSelector(maybeGetServerSnapshot());
};
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
getSelection = _useMemo[0],
getServerSelection = _useMemo[1];
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
useEffect(function () {
inst.hasValue = true;
inst.value = value;
}, [value]);
useDebugValue(value);
return value;
}
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

View File

@@ -0,0 +1,12 @@
/**
* @license React
* use-sync-external-store-with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var g=require("react");function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p="function"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;
exports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,h]);var d=q(a,c[0],c[1]);
t(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};

View File

@@ -0,0 +1,84 @@
/**
* @license React
* use-sync-external-store.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var React = require('react');
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function error(format) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
var stack = ReactDebugCurrentFrame.getStackAddendum();
if (stack !== '') {
format += '%s';
args = args.concat([stack]);
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
var useSyncExternalStore = React.useSyncExternalStore;
{
error("The main 'use-sync-external-store' entry point is not supported; all it " + "does is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to a shimmed " + 'implementation when the native one is not available.' + '\n\n' + "If you only support React 18+, you can import directly from 'react'.");
}
exports.useSyncExternalStore = useSyncExternalStore;
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

View File

@@ -0,0 +1,10 @@
/**
* @license React
* use-sync-external-store.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var a=require("react").useSyncExternalStore;exports.useSyncExternalStore=a;

View File

@@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/use-sync-external-store.production.min.js');
} else {
module.exports = require('./cjs/use-sync-external-store.development.js');
}

View File

@@ -0,0 +1,24 @@
{
"name": "use-sync-external-store",
"description": "Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.",
"version": "1.2.0",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/use-sync-external-store"
},
"files": [
"LICENSE",
"README.md",
"index.js",
"index.native.js",
"with-selector.js",
"with-selector.native.js",
"shim/",
"cjs/"
],
"license": "MIT",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
}

View File

@@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');
} else {
module.exports = require('../cjs/use-sync-external-store-shim.development.js');
}

View File

@@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('../cjs/use-sync-external-store-shim.native.production.min.js');
} else {
module.exports = require('../cjs/use-sync-external-store-shim.native.development.js');
}

View File

@@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');
} else {
module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');
}

View File

@@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/use-sync-external-store-with-selector.production.min.js');
} else {
module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');
}

113
node_modules/valtio/package.json generated vendored Normal file
View File

@@ -0,0 +1,113 @@
{
"name": "valtio",
"private": false,
"version": "1.7.0",
"description": "💊 Valtio makes proxy-state simple for React and Vanilla",
"main": "./index.js",
"types": "./index.d.ts",
"typesVersions": {
"<4.0": {
"esm/*": [
"ts3.4/*"
],
"*": [
"ts3.4/*"
]
}
},
"exports": {
"./package.json": "./package.json",
".": {
"types": "./index.d.ts",
"module": "./esm/index.js",
"import": "./esm/index.mjs",
"default": "./index.js"
},
"./vanilla": {
"types": "./vanilla.d.ts",
"module": "./esm/vanilla.js",
"import": "./esm/vanilla.mjs",
"default": "./vanilla.js"
},
"./utils": {
"types": "./utils.d.ts",
"module": "./esm/utils.js",
"import": "./esm/utils.mjs",
"default": "./utils.js"
},
"./macro": {
"types": "./macro.d.ts",
"module": "./esm/macro.js",
"import": "./esm/macro.mjs",
"default": "./macro.js"
},
"./macro/vite": {
"types": "./esm/macro/vite.d.ts",
"module": "./esm/macro/vite.js",
"import": "./esm/macro/vite.mjs",
"default": "./macro/vite.js"
}
},
"files": [
"**"
],
"sideEffects": false,
"engines": {
"node": ">=12.7.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pmndrs/valtio.git"
},
"keywords": [
"react",
"state",
"manager",
"management",
"mobx",
"proxy",
"store"
],
"author": "Daishi Kato",
"contributors": [],
"license": "MIT",
"bugs": {
"url": "https://github.com/pmndrs/valtio/issues"
},
"homepage": "https://github.com/pmndrs/valtio",
"dependencies": {
"proxy-compare": "2.3.0",
"use-sync-external-store": "1.2.0"
},
"resolutions": {
"date-fns": "2.27.0"
},
"peerDependencies": {
"@babel/helper-module-imports": ">=7.12",
"@babel/types": ">=7.13",
"aslemammad-vite-plugin-macro": ">=1.0.0-alpha.1",
"babel-plugin-macros": ">=3.0",
"react": ">=16.8",
"vite": ">=2.8.6"
},
"peerDependenciesMeta": {
"vite": {
"optional": true
},
"aslemammad-vite-plugin-macro": {
"optional": true
},
"@babel/helper-module-imports": {
"optional": true
},
"@babel/types": {
"optional": true
},
"babel-plugin-macros": {
"optional": true
},
"react": {
"optional": true
}
}
}

78
node_modules/valtio/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import type { INTERNAL_Snapshot } from './vanilla';
declare type Options = {
sync?: boolean;
};
/**
* useSnapshot
*
* Create a local snapshot that catches changes. This hook actually returns a wrapped snapshot in a proxy for
* render optimization instead of a plain object compared to `snapshot()` method.
* Rule of thumb: read from snapshots, mutate the source.
* The component will only re-render when the parts of the state you access have changed, it is render-optimized.
*
* @example A
* function Counter() {
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.count}
* <button onClick={() => ++state.count}>+1</button>
* </div>
* )
* }
*
* [Notes]
* Every object inside your proxy also becomes a proxy (if you don't use "ref"), so you can also use them to create
* the local snapshot as seen on example B.
*
* @example B
* function ProfileName() {
* const snap = useSnapshot(state.profile)
* return (
* <div>
* {snap.name}
* </div>
* )
* }
*
* Beware that you still can replace the child proxy with something else so it will break your snapshot. You can see
* above what happens with the original proxy when you replace the child proxy.
*
* > console.log(state)
* { profile: { name: "valtio" } }
* > childState = state.profile
* > console.log(childState)
* { name: "valtio" }
* > state.profile.name = "react"
* > console.log(childState)
* { name: "react" }
* > state.profile = { name: "new name" }
* > console.log(childState)
* { name: "react" }
* > console.log(state)
* { profile: { name: "new name" } }
*
* `useSnapshot()` depends on the original reference of the child proxy so if you replace it with a new one, the component
* that is subscribed to the old proxy won't receive new updates because it is still subscribed to the old one.
*
* In this case we recommend the example C or D. On both examples you don't need to worry with re-render,
* because it is render-optimized.
*
* @example C
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.profile.name}
* </div>
* )
*
* @example D
* const { profile } = useSnapshot(state)
* return (
* <div>
* {profile.name}
* </div>
* )
*/
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): INTERNAL_Snapshot<T>;
export {};

478
node_modules/valtio/readme.md generated vendored Normal file
View File

@@ -0,0 +1,478 @@
<img src="logo.svg" alt="valtio">
<br />
<br />
<code>npm i valtio</code> makes proxy-state simple
[![Build Status](https://img.shields.io/github/workflow/status/pmndrs/valtio/Lint?style=flat&colorA=000000&colorB=000000)](https://github.com/pmndrs/valtio/actions?query=workflow%3ALint)
[![Build Size](https://img.shields.io/bundlephobia/minzip/valtio?label=bundle%20size&style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=valtio)
[![Version](https://img.shields.io/npm/v/valtio?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/valtio)
[![Downloads](https://img.shields.io/npm/dt/valtio.svg?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/valtio)
[![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/poimandres)
#### Wrap your state object
Valtio turns the object you pass it into a self-aware proxy.
```jsx
import { proxy, useSnapshot } from 'valtio'
const state = proxy({ count: 0, text: 'hello' })
```
#### Mutate from anywhere
You can make changes to it in the same way you would to a normal js-object.
```jsx
setInterval(() => {
++state.count
}, 1000)
```
#### React via useSnapshot
Create a local snapshot that catches changes. Rule of thumb: read from snapshots in render function, otherwise use the source. The component will only re-render when the parts of the state you access have changed, it is render-optimized.
```jsx
// This will re-render on `state.count` change but not on `state.text` change
function Counter() {
const snap = useSnapshot(state)
return (
<div>
{snap.count}
<button onClick={() => ++state.count}>+1</button>
</div>
)
}
```
<details>
<summary>Note for TypeScript users: Return type of useSnapshot can be too strict.</summary>
The `snap` variable returned by `useSnapshot` is a (deeply) read-only object.
Its type has `readonly` attribute, which may be too strict for some use cases.
To mitigate typing difficulties, you might want to loosen the type definition:
```ts
declare module 'valtio' {
function useSnapshot<T extends object>(p: T): T
}
```
See [#327](https://github.com/pmndrs/valtio/issues/327) for more information.
</details>
<details>
<summary>Note: useSnapshot returns a new proxy for render optimization.</summary>
Internally, `useSnapshot` calls `snapshot` in valtio/vanilla,
and wraps the snapshot object with another proxy to detect property access.
This feature is based on [proxy-compare](https://github.com/dai-shi/proxy-compare).
Two kinds of proxies are used for different purposes:
- `proxy()` from `valtio/vanilla` is for mutation tracking or write tracking.
- `createProxy()` from `proxy-compare` is for usage tracking or read tracking.
</details>
<details>
<summary>Use of `this` is for expert users.</summary>
Valtio tries best to handle `this` behavior
but it's hard to understand without familiarity.
```js
const state = proxy({
count: 0,
inc() {
++this.count
},
})
state.inc() // `this` points to `state` and it works fine
const snap = useSnapshot(state)
snap.inc() // `this` points to `snap` and it doesn't work because snapshot is frozen
```
To avoid this pitfall, the recommended pattern is not to use `this` and prefer arrow function.
```js
const state = proxy({
count: 0,
inc: () => {
++state.count
},
})
```
</details>
If you are new to this, it's highly recommended to use
[eslint-plugin-valtio](https://github.com/pmndrs/eslint-plugin-valtio).
#### Subscribe from anywhere
You can access state outside of your components and subscribe to changes.
```jsx
import { subscribe } from 'valtio'
// Subscribe to all state changes
const unsubscribe = subscribe(state, () =>
console.log('state has changed to', state)
)
// Unsubscribe by calling the result
unsubscribe()
```
You can also subscribe to a portion of state.
```jsx
const state = proxy({ obj: { foo: 'bar' }, arr: ['hello'] })
subscribe(state.obj, () => console.log('state.obj has changed to', state.obj))
state.obj.foo = 'baz'
subscribe(state.arr, () => console.log('state.arr has changed to', state.arr))
state.arr.push('world')
```
To subscribe to a primitive value of state, consider `subscribeKey` in utils.
```jsx
import { subscribeKey } from 'valtio/utils'
const state = proxy({ count: 0, text: 'hello' })
subscribeKey(state, 'count', (v) =>
console.log('state.count has changed to', v)
)
```
There is another util `watch` which might be convenient in some cases.
```jsx
import { watch } from 'valtio/utils'
const state = proxy({ count: 0 })
const stop = watch((get) => {
console.log('state has changed to', get(state)) // auto-subscribe on use
})
```
#### Suspend your components
Valtio supports React-suspense and will throw promises that you access within a components render function. This eliminates all the async back-and-forth, you can access your data directly while the parent is responsible for fallback state and error handling.
```jsx
const state = proxy({ post: fetch(url).then((res) => res.json()) })
function Post() {
const snap = useSnapshot(state)
return <div>{snap.post.title}</div>
}
function App() {
return (
<Suspense fallback={<span>waiting...</span>}>
<Post />
</Suspense>
)
}
```
#### Holding objects in state without tracking them
This may be useful if you have large, nested objects with accessors that you don't want to proxy. `ref` allows you to keep these objects inside the state model.
See [#61](https://github.com/pmndrs/valtio/issues/61) and [#178](https://github.com/pmndrs/valtio/issues/178) for more information.
```js
import { proxy, ref } from 'valtio'
const state = proxy({
count: 0,
dom: ref(document.body),
})
```
#### Update transiently (for often occurring state-changes)
You can read state in a component without causing re-render.
```jsx
function Foo() {
const { count, text } = state
// ...
```
Or, you can have more control with subscribing in useEffect.
```jsx
function Foo() {
const total = useRef(0)
useEffect(() => subscribe(state.arr, () => {
total.current = state.arr.reduce((p, c) => p + c)
}), [])
// ...
```
#### Update synchronously
By default, state mutations are batched before triggering re-render.
Sometimes, we want to disable the batching.
The known use case of this is `<input>` [#270](https://github.com/pmndrs/valtio/issues/270).
```jsx
function TextBox() {
const snap = useSnapshot(state, { sync: true })
return (
<input value={snap.text} onChange={(e) => (state.text = e.target.value)} />
)
}
```
#### Dev tools
You can use [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension) for plain objects and arrays.
```jsx
import { devtools } from 'valtio/utils'
const state = proxy({ count: 0, text: 'hello' })
const unsub = devtools(state, { name: 'state name', enabled: true })
```
<details>
<summary>Manipulating state with Redux DevTools</summary>
The screenshot below shows how to use Redux DevTools to manipulate state. First select the object from the instances drop down. Then type in a JSON object to dispatch. Then click "Dispatch". Notice how it changes the state.
<br/>
<img width="564" alt="image" src="https://user-images.githubusercontent.com/6372489/141134955-26e9ffce-1e2a-4c8c-a9b3-d9da739610fe.png">
</details>
#### Use it vanilla
Valtio is not tied to React, you can use it in vanilla-js.
```jsx
import { proxy, subscribe, snapshot } from 'valtio/vanilla'
const state = proxy({ count: 0, text: 'hello' })
subscribe(state, () => {
console.log('state is mutated')
const obj = snapshot(state) // A snapshot is an immutable object
})
```
#### `useProxy` macro
We have a convenient macro with
[babel-plugin-macros](https://www.npmjs.com/package/babel-plugin-macros).
```js
import { useProxy } from 'valtio/macro'
const Component = () => {
useProxy(state)
return (
<div>
{state.count}
<button onClick={() => ++state.count}>+1</button>
</div>
)
}
// the code above becomes the code below.
import { useSnapshot } from 'valtio'
const Component = () => {
const snap = useSnapshot(state)
return (
<div>
{snap.count}
<button onClick={() => ++state.count}>+1</button>
</div>
)
}
```
##### vite
```
npm i --save-dev aslemammad-vite-plugin-macro babel-plugin-macros
```
And in your `vite.config.js`
```js
import { defineConfig } from 'vite'
import macro from 'valtio/macro/vite'
export default defineConfig({
plugins: [macro],
})
```
#### `derive` util
You can subscribe to some proxies and create a derived proxy.
```js
import { derive } from 'valtio/utils'
// create a base proxy
const state = proxy({
count: 1,
})
// create a derived proxy
const derived = derive({
doubled: (get) => get(state).count * 2,
})
// alternatively, attach derived properties to an existing proxy
derive(
{
tripled: (get) => get(state).count * 3,
},
{
proxy: state,
}
)
```
#### `proxyWithComputed` util
You can define own computed properties within a proxy.
By combining with a memoization library such as
[proxy-memoize](https://github.com/dai-shi/proxy-memoize),
optimizing function calls is possible.
Be careful not to overuse `proxy-memoize`
because `proxy-memoize` and `useSnapshot` do similar optimization
and double optimization may lead to less performance.
```js
import memoize from 'proxy-memoize'
import { proxyWithComputed } from 'valtio/utils'
const state = proxyWithComputed(
{
count: 1,
},
{
doubled: memoize((snap) => snap.count * 2),
}
)
// Computed values accept custom setters too:
const state2 = proxyWithComputed(
{
firstName: 'Alec',
lastName: 'Baldwin',
},
{
fullName: {
get: memoize((snap) => snap.firstName + ' ' + snap.lastName),
set: (state, newValue) => {
;[state.firstName, state.lastName] = newValue.split(' ')
},
},
}
)
// if you want a computed value to derive from another computed, you must declare the dependency first:
const state = proxyWithComputed(
{
count: 1,
},
{
doubled: memoize((snap) => snap.count * 2),
quadrupled: memoize((snap) => snap.doubled * 2),
}
)
```
The last use case fails to infer types in TypeScript
[#192](https://github.com/pmndrs/valtio/issues/192).
#### `proxyWithHistory` util
This is a utility function to create a proxy with snapshot history.
```js
import { proxyWithHistory } from 'valtio/utils'
const state = proxyWithHistory({ count: 0 })
console.log(state.value) // ---> { count: 0 }
state.value.count += 1
console.log(state.value) // ---> { count: 1 }
state.undo()
console.log(state.value) // ---> { count: 0 }
state.redo()
console.log(state.value) // ---> { count: 1 }
```
#### `proxySet` util
This is to create a proxy which mimic the native Set behavior. The API is the same as Set API
```js
import { proxySet } from 'valtio/utils'
const state = proxySet([1, 2, 3])
//can be used inside a proxy as well
//const state = proxy({
// count: 1,
// set: proxySet()
//})
state.add(4)
state.delete(1)
state.forEach((v) => console.log(v)) // 2,3,4
```
#### `proxyMap` util
This is to create a proxy which emulate the native Map behavior. The API is the same as Map API
```js
import { proxyMap } from 'valtio/utils'
const state = proxyMap([
['key', 'value'],
['key2', 'value2'],
])
state.set('key', 'value')
state.delete('key')
state.get('key') // ---> value
state.forEach((value, key) => console.log(key, value)) // ---> "key", "value", "key2", "value2"
```
#### Compatibility
Valtio works with React with hooks support (>=16.8).
It only depends on `react` and works with any
renderers such as `react-dom`, `react-native`, `react-three-fiber`, and so on.
Valtio works on Node.js, Next.js and other frameworks.
Valtio also works without React. See [vanilla](#use-it-vanilla).
#### Plugins
- [eslint-plugin-valtio](https://github.com/pmndrs/eslint-plugin-valtio)
#### Recipes
Valtio is unopinionated about best practices.
The community is working on recipes on wiki pages.
- [How to organize actions](https://github.com/pmndrs/valtio/wiki/How-to-organize-actions)
- [How to persist states](https://github.com/pmndrs/valtio/wiki/How-to-persist-states)
- [How to use with context](https://github.com/pmndrs/valtio/wiki/How-to-use-with-context)
- [How to split and compose states](https://github.com/pmndrs/valtio/wiki/How-to-split-and-compose-states)

80
node_modules/valtio/system/index.development.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
System.register(['react', 'proxy-compare', 'use-sync-external-store/shim', 'valtio/vanilla'], (function (exports) {
'use strict';
var useRef, useCallback, useEffect, useMemo, useDebugValue, isChanged, createProxy, affectedToPathList, useSyncExternalStoreExports, subscribe, snapshot;
return {
setters: [function (module) {
useRef = module.useRef;
useCallback = module.useCallback;
useEffect = module.useEffect;
useMemo = module.useMemo;
useDebugValue = module.useDebugValue;
}, function (module) {
isChanged = module.isChanged;
createProxy = module.createProxy;
affectedToPathList = module.affectedToPathList;
}, function (module) {
useSyncExternalStoreExports = module["default"];
}, function (module) {
subscribe = module.subscribe;
snapshot = module.snapshot;
exports({ getVersion: module.getVersion, proxy: module.proxy, ref: module.ref, snapshot: module.snapshot, subscribe: module.subscribe, unstable_buildProxyFunction: module.unstable_buildProxyFunction });
}],
execute: (function () {
exports('useSnapshot', useSnapshot);
const { useSyncExternalStore } = useSyncExternalStoreExports;
const useAffectedDebugValue = (state, affected) => {
const pathList = useRef();
useEffect(() => {
pathList.current = affectedToPathList(state, affected);
});
useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
const notifyInSync = options == null ? void 0 : options.sync;
const lastSnapshot = useRef();
const lastAffected = useRef();
let inRender = true;
const currSnapshot = useSyncExternalStore(
useCallback(
(callback) => {
const unsub = subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
},
[proxyObject, notifyInSync]
),
() => {
const nextSnapshot = snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !isChanged(
lastSnapshot.current,
nextSnapshot,
lastAffected.current,
/* @__PURE__ */ new WeakMap()
)) {
return lastSnapshot.current;
}
} catch (e) {
}
return nextSnapshot;
},
() => snapshot(proxyObject)
);
inRender = false;
const currAffected = /* @__PURE__ */ new WeakMap();
useEffect(() => {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
{
useAffectedDebugValue(currSnapshot, currAffected);
}
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []);
return createProxy(currSnapshot, currAffected, proxyCache);
}
})
};
}));

1
node_modules/valtio/system/index.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
System.register(["react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],function(a){"use strict";var r,i,o,f,b,p,y,h,c;return{setters:[function(n){r=n.useRef,i=n.useCallback,o=n.useEffect,f=n.useMemo},function(n){b=n.isChanged,p=n.createProxy},function(n){y=n.default},function(n){h=n.subscribe,c=n.snapshot,a({getVersion:n.getVersion,proxy:n.proxy,ref:n.ref,snapshot:n.snapshot,subscribe:n.subscribe,unstable_buildProxyFunction:n.unstable_buildProxyFunction})}],execute:function(){a("useSnapshot",S);const{useSyncExternalStore:n}=y;function S(t,x){const l=x==null?void 0:x.sync,s=r(),u=r();let g=!0;const k=n(i(e=>{const C=h(t,e,l);return e(),C},[t,l]),()=>{const e=c(t);try{if(!g&&s.current&&u.current&&!b(s.current,e,u.current,new WeakMap))return s.current}catch{}return e},()=>c(t));g=!1;const M=new WeakMap;o(()=>{s.current=k,u.current=M});const v=f(()=>new WeakMap,[]);return p(k,M,v)}}}});

51
node_modules/valtio/system/macro.development.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
System.register(['@babel/helper-module-imports', '@babel/types', 'babel-plugin-macros'], (function (exports) {
'use strict';
var addNamed, t, createMacro, MacroError;
return {
setters: [function (module) {
addNamed = module.addNamed;
}, function (module) {
t = module;
}, function (module) {
createMacro = module.createMacro;
MacroError = module.MacroError;
}],
execute: (function () {
const macro = ({ references }) => {
var _a;
(_a = references.useProxy) == null ? void 0 : _a.forEach((path) => {
var _a2, _b, _c, _d, _e, _f;
const hook = addNamed(path, "useSnapshot", "valtio");
const proxy = (_b = (_a2 = path.parentPath) == null ? void 0 : _a2.get("arguments.0")) == null ? void 0 : _b.node;
if (!t.isIdentifier(proxy))
throw new MacroError("no proxy object");
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_d = (_c = path.parentPath) == null ? void 0 : _c.parentPath) == null ? void 0 : _d.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_f = (_e = path.parentPath) == null ? void 0 : _e.getFunctionParent()) == null ? void 0 : _f.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
});
};
var macro$1 = exports('default', createMacro(macro, { configName: "valtio" }));
})
};
}));

1
node_modules/valtio/system/macro.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
System.register(["@babel/helper-module-imports","@babel/types","babel-plugin-macros"],function(h){"use strict";var i,a,l,c;return{setters:[function(e){i=e.addNamed},function(e){a=e},function(e){l=e.createMacro,c=e.MacroError}],execute:function(){var P=h("default",l(({references:g})=>{var s;(s=g.useProxy)==null||s.forEach(r=>{var u,d,v,m,p,f;const x=i(r,"useSnapshot","valtio"),n=(d=(u=r.parentPath)==null?void 0:u.get("arguments.0"))==null?void 0:d.node;if(!a.isIdentifier(n))throw new c("no proxy object");const b=a.identifier(`valtio_macro_snap_${n.name}`);(m=(v=r.parentPath)==null?void 0:v.parentPath)==null||m.replaceWith(a.variableDeclaration("const",[a.variableDeclarator(b,a.callExpression(x,[n]))]));let t=0;(f=(p=r.parentPath)==null?void 0:p.getFunctionParent())==null||f.traverse({Identifier(o){t===0&&o.node!==n&&o.node.name===n.name&&(o.node.name=b.name)},Function:{enter(){++t},exit(){--t}}})})},{configName:"valtio"}))}}});

64
node_modules/valtio/system/macro/vite.development.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
System.register(['@babel/helper-module-imports', '@babel/types', 'aslemammad-vite-plugin-macro', 'babel-plugin-macros'], (function (exports) {
'use strict';
var babelModuleImports, t, plugin, babelMacro;
return {
setters: [function (module) {
babelModuleImports = module;
}, function (module) {
t = module;
}, function (module) {
plugin = module;
}, function (module) {
babelMacro = module;
}],
execute: (function () {
exports('provideValtioMacro', provideValtioMacro);
const { defineMacro, defineMacroProvider, createMacroPlugin } = "default" in plugin ? plugin.default : plugin;
const valtioMacro = exports('valtioMacro', defineMacro(`useProxy`).withSignature(`<T extends object>(proxyObject: T): void`).withHandler((ctx) => {
var _a, _b, _c, _d;
const { path, args } = ctx;
const hook = babelModuleImports.addNamed(path, "useSnapshot", "valtio");
const proxy = (_a = args[0]) == null ? void 0 : _a.node;
if (!t.isIdentifier(proxy)) {
throw new babelMacro.MacroError("no proxy object");
}
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
(_b = path.parentPath) == null ? void 0 : _b.replaceWith(
t.variableDeclaration("const", [
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
])
);
let inFunction = 0;
(_d = (_c = path.parentPath) == null ? void 0 : _c.getFunctionParent()) == null ? void 0 : _d.traverse({
Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter() {
++inFunction;
},
exit() {
--inFunction;
}
}
});
}));
function provideValtioMacro() {
return defineMacroProvider({
id: "valtio/macro",
exports: {
"valtio/macro": {
macros: [valtioMacro]
}
}
});
}
const macroPlugin = exports('default', createMacroPlugin({}).use(provideValtioMacro()));
})
};
}));

1
node_modules/valtio/system/macro/vite.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
System.register(["@babel/helper-module-imports","@babel/types","aslemammad-vite-plugin-macro","babel-plugin-macros"],function(o){"use strict";var l,t,n,u;return{setters:[function(e){l=e},function(e){t=e},function(e){n=e},function(e){u=e}],execute:function(){o("provideValtioMacro",s);const{defineMacro:e,defineMacroProvider:b,createMacroPlugin:h}="default"in n?n.default:n,M=o("valtioMacro",e("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler(g=>{var d,m,v,f;const{path:r,args:x}=g,P=l.addNamed(r,"useSnapshot","valtio"),a=(d=x[0])==null?void 0:d.node;if(!t.isIdentifier(a))throw new u.MacroError("no proxy object");const p=t.identifier(`valtio_macro_snap_${a.name}`);(m=r.parentPath)==null||m.replaceWith(t.variableDeclaration("const",[t.variableDeclarator(p,t.callExpression(P,[a]))]));let i=0;(f=(v=r.parentPath)==null?void 0:v.getFunctionParent())==null||f.traverse({Identifier(c){i===0&&c.node!==a&&c.node.name===a.name&&(c.node.name=p.name)},Function:{enter(){++i},exit(){--i}}})}));function s(){return b({id:"valtio/macro",exports:{"valtio/macro":{macros:[M]}}})}const y=o("default",h({}).use(s()))}}});

603
node_modules/valtio/system/utils.development.js generated vendored Normal file
View File

@@ -0,0 +1,603 @@
System.register(['valtio/vanilla'], (function (exports) {
'use strict';
var subscribe, snapshot, proxy, getVersion, ref;
return {
setters: [function (module) {
subscribe = module.subscribe;
snapshot = module.snapshot;
proxy = module.proxy;
getVersion = module.getVersion;
ref = module.ref;
}],
execute: (function () {
exports({
addComputed: addComputed_DEPRECATED,
derive: derive,
devtools: devtools,
proxyMap: proxyMap,
proxySet: proxySet,
proxyWithComputed: proxyWithComputed,
proxyWithHistory: proxyWithHistory,
subscribeKey: subscribeKey,
underive: underive,
watch: watch
});
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return subscribe(
proxyObject,
(ops) => {
if (ops.some((op) => op[1][0] === key)) {
callback(proxyObject[key]);
}
},
notifyInSync
);
}
let currentCleanups;
function watch(callback, options) {
let alive = true;
const cleanups = /* @__PURE__ */ new Set();
const subscriptions = /* @__PURE__ */ new Map();
const cleanup = () => {
if (alive) {
alive = false;
cleanups.forEach((clean) => clean());
cleanups.clear();
subscriptions.forEach((unsubscribe) => unsubscribe());
subscriptions.clear();
}
};
const revalidate = () => {
if (!alive) {
return;
}
cleanups.forEach((clean) => clean());
cleanups.clear();
const proxiesToSubscribe = /* @__PURE__ */ new Set();
const parent = currentCleanups;
currentCleanups = cleanups;
try {
const cleanupReturn = callback((proxyObject) => {
proxiesToSubscribe.add(proxyObject);
return proxyObject;
});
if (cleanupReturn) {
cleanups.add(cleanupReturn);
}
} finally {
currentCleanups = parent;
}
subscriptions.forEach((unsubscribe, proxyObject) => {
if (proxiesToSubscribe.has(proxyObject)) {
proxiesToSubscribe.delete(proxyObject);
} else {
subscriptions.delete(proxyObject);
unsubscribe();
}
});
proxiesToSubscribe.forEach((proxyObject) => {
const unsubscribe = subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync);
subscriptions.set(proxyObject, unsubscribe);
});
};
if (currentCleanups) {
currentCleanups.add(cleanup);
}
revalidate();
return cleanup;
}
const DEVTOOLS = Symbol();
function devtools(proxyObject, options) {
if (typeof options === "string") {
console.warn(
"string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"
);
options = { name: options };
}
const { enabled, name = "" } = options || {};
let extension;
try {
extension = (enabled != null ? enabled : true) && window.__REDUX_DEVTOOLS_EXTENSION__;
} catch {
}
if (!extension) {
if (enabled) {
console.warn("[Warning] Please install/enable Redux devtools extension");
}
return;
}
let isTimeTraveling = false;
const devtools2 = extension.connect({ name });
const unsub1 = subscribe(proxyObject, (ops) => {
const action = ops.filter(([_, path]) => path[0] !== DEVTOOLS).map(([op, path]) => `${op}:${path.map(String).join(".")}`).join(", ");
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
const snapWithoutDevtools = Object.assign({}, snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools2.send(
{
type: action,
updatedAt: new Date().toLocaleString()
},
snapWithoutDevtools
);
}
});
const unsub2 = devtools2.subscribe((message) => {
var _a, _b, _c, _d, _e, _f;
if (message.type === "ACTION" && message.payload) {
try {
Object.assign(proxyObject, JSON.parse(message.payload));
} catch (e) {
console.error(
"please dispatch a serializable value that JSON.parse() and proxy() support\n",
e
);
}
}
if (message.type === "DISPATCH" && message.state) {
if (((_a = message.payload) == null ? void 0 : _a.type) === "JUMP_TO_ACTION" || ((_b = message.payload) == null ? void 0 : _b.type) === "JUMP_TO_STATE") {
isTimeTraveling = true;
const state = JSON.parse(message.state);
Object.assign(proxyObject, state);
}
proxyObject[DEVTOOLS] = message;
} else if (message.type === "DISPATCH" && ((_c = message.payload) == null ? void 0 : _c.type) === "COMMIT") {
devtools2.init(snapshot(proxyObject));
} else if (message.type === "DISPATCH" && ((_d = message.payload) == null ? void 0 : _d.type) === "IMPORT_STATE") {
const actions = (_e = message.payload.nextLiftedState) == null ? void 0 : _e.actionsById;
const computedStates = ((_f = message.payload.nextLiftedState) == null ? void 0 : _f.computedStates) || [];
isTimeTraveling = true;
computedStates.forEach(({ state }, index) => {
const action = actions[index] || "No action found";
Object.assign(proxyObject, state);
if (index === 0) {
devtools2.init(snapshot(proxyObject));
} else {
devtools2.send(action, snapshot(proxyObject));
}
});
}
});
devtools2.init(snapshot(proxyObject));
return () => {
unsub1();
unsub2 == null ? void 0 : unsub2();
};
}
const sourceObjectMap = /* @__PURE__ */ new WeakMap();
const derivedObjectMap = /* @__PURE__ */ new WeakMap();
const markPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
markPending(derivedObject);
}
});
++sourceObjectEntry[2];
if (callback) {
sourceObjectEntry[3].add(callback);
}
}
};
const checkPending = (sourceObject, callback) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry == null ? void 0 : sourceObjectEntry[2]) {
sourceObjectEntry[3].add(callback);
return true;
}
return false;
};
const unmarkPending = (sourceObject) => {
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
--sourceObjectEntry[2];
if (!sourceObjectEntry[2]) {
sourceObjectEntry[3].forEach((callback) => callback());
sourceObjectEntry[3].clear();
}
sourceObjectEntry[0].forEach((subscription) => {
const { d: derivedObject } = subscription;
if (sourceObject !== derivedObject) {
unmarkPending(derivedObject);
}
});
}
};
const addSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
let derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (!derivedObjectEntry) {
derivedObjectEntry = [/* @__PURE__ */ new Set()];
derivedObjectMap.set(subscription.d, derivedObjectEntry);
}
derivedObjectEntry[0].add(subscription);
let sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (!sourceObjectEntry) {
const subscriptions = /* @__PURE__ */ new Set();
const unsubscribe = subscribe(
sourceObject,
(ops) => {
subscriptions.forEach((subscription2) => {
const {
d: derivedObject2,
c: callback,
n: notifyInSync,
i: ignoreKeys
} = subscription2;
if (sourceObject === derivedObject2 && ops.every(
(op) => op[1].length === 1 && ignoreKeys.includes(op[1][0])
)) {
return;
}
if (subscription2.p) {
return;
}
markPending(sourceObject, callback);
if (notifyInSync) {
unmarkPending(sourceObject);
} else {
subscription2.p = Promise.resolve().then(() => {
delete subscription2.p;
unmarkPending(sourceObject);
});
}
});
},
true
);
sourceObjectEntry = [subscriptions, unsubscribe, 0, /* @__PURE__ */ new Set()];
sourceObjectMap.set(sourceObject, sourceObjectEntry);
}
sourceObjectEntry[0].add(subscription);
};
const removeSubscription = (subscription) => {
const { s: sourceObject, d: derivedObject } = subscription;
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].delete(subscription);
if ((derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].size) === 0) {
derivedObjectMap.delete(derivedObject);
}
const sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
const [subscriptions, unsubscribe] = sourceObjectEntry;
subscriptions.delete(subscription);
if (!subscriptions.size) {
unsubscribe();
sourceObjectMap.delete(sourceObject);
}
}
};
const listSubscriptions = (derivedObject) => {
const derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (derivedObjectEntry) {
return Array.from(derivedObjectEntry[0]);
}
return [];
};
const unstable_deriveSubscriptions = exports('unstable_deriveSubscriptions', {
add: addSubscription,
remove: removeSubscription,
list: listSubscriptions
});
function derive(derivedFns, options) {
const proxyObject = (options == null ? void 0 : options.proxy) || proxy({});
const notifyInSync = !!(options == null ? void 0 : options.sync);
const derivedKeys = Object.keys(derivedFns);
derivedKeys.forEach((key) => {
if (Object.getOwnPropertyDescriptor(proxyObject, key)) {
throw new Error("object property already defined");
}
const fn = derivedFns[key];
let lastDependencies = null;
const evaluate = () => {
if (lastDependencies) {
if (Array.from(lastDependencies).map(([p]) => checkPending(p, evaluate)).some((isPending) => isPending)) {
return;
}
if (Array.from(lastDependencies).every(
([p, entry]) => getVersion(p) === entry.v
)) {
return;
}
}
const dependencies = /* @__PURE__ */ new Map();
const get = (p) => {
dependencies.set(p, { v: getVersion(p) });
return p;
};
const value = fn(get);
const subscribeToDependencies = () => {
dependencies.forEach((entry, p) => {
var _a;
const lastSubscription = (_a = lastDependencies == null ? void 0 : lastDependencies.get(p)) == null ? void 0 : _a.s;
if (lastSubscription) {
entry.s = lastSubscription;
} else {
const subscription = {
s: p,
d: proxyObject,
k: key,
c: evaluate,
n: notifyInSync,
i: derivedKeys
};
addSubscription(subscription);
entry.s = subscription;
}
});
lastDependencies == null ? void 0 : lastDependencies.forEach((entry, p) => {
if (!dependencies.has(p) && entry.s) {
removeSubscription(entry.s);
}
});
lastDependencies = dependencies;
};
if (value instanceof Promise) {
value.finally(subscribeToDependencies);
} else {
subscribeToDependencies();
}
proxyObject[key] = value;
};
evaluate();
});
return proxyObject;
}
function underive(proxyObject, options) {
const keysToDelete = (options == null ? void 0 : options.delete) ? /* @__PURE__ */ new Set() : null;
listSubscriptions(proxyObject).forEach((subscription) => {
const { k: key } = subscription;
if (!(options == null ? void 0 : options.keys) || options.keys.includes(key)) {
removeSubscription(subscription);
if (keysToDelete) {
keysToDelete.add(key);
}
}
});
if (keysToDelete) {
keysToDelete.forEach((key) => {
delete proxyObject[key];
});
}
}
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject = proxyObject) {
console.warn(
"addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive. https://github.com/pmndrs/valtio/pull/201"
);
const derivedFns = {};
Object.keys(computedFns_FAKE).forEach((key) => {
derivedFns[key] = (get) => computedFns_FAKE[key](get(proxyObject));
});
return derive(derivedFns, { proxy: targetObject });
}
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach((key) => {
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
throw new Error("object property already defined");
}
const computedFn = computedFns[key];
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
const desc = {};
desc.get = () => get(snapshot(proxyObject));
if (set) {
desc.set = (newValue) => set(proxyObject, newValue);
}
Object.defineProperty(initialObject, key, desc);
});
const proxyObject = proxy(initialObject);
return proxyObject;
}
const isObject = (x) => typeof x === "object" && x !== null;
const deepClone = (obj) => {
if (!isObject(obj)) {
return obj;
}
const baseObject = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
Reflect.ownKeys(obj).forEach((key) => {
baseObject[key] = deepClone(obj[key]);
});
return baseObject;
};
function proxyWithHistory(initialValue, skipSubscribe = false) {
const proxyObject = proxy({
value: initialValue,
history: ref({
wip: void 0,
snapshots: [],
index: -1
}),
canUndo: () => proxyObject.history.index > 0,
undo: () => {
if (proxyObject.canUndo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[--proxyObject.history.index]
);
}
},
canRedo: () => proxyObject.history.index < proxyObject.history.snapshots.length - 1,
redo: () => {
if (proxyObject.canRedo()) {
proxyObject.value = proxyObject.history.wip = deepClone(
proxyObject.history.snapshots[++proxyObject.history.index]
);
}
},
saveHistory: () => {
proxyObject.history.snapshots.splice(proxyObject.history.index + 1);
proxyObject.history.snapshots.push(snapshot(proxyObject).value);
++proxyObject.history.index;
},
subscribe: () => subscribe(proxyObject, (ops) => {
if (ops.every(
(op) => op[1][0] === "value" && (op[0] !== "set" || op[2] !== proxyObject.history.wip)
)) {
proxyObject.saveHistory();
}
})
});
proxyObject.saveHistory();
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;
}
function proxySet(initialValues) {
const set = proxy({
data: Array.from(new Set(initialValues)),
has(value) {
return this.data.indexOf(value) !== -1;
},
add(value) {
let hasProxy = false;
if (typeof value === "object" && value !== null) {
hasProxy = this.data.indexOf(proxy(value)) !== -1;
}
if (this.data.indexOf(value) === -1 && !hasProxy) {
this.data.push(value);
}
return this;
},
delete(value) {
const index = this.data.indexOf(value);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
forEach(cb) {
this.data.forEach((value) => {
cb(value, value, this);
});
},
get [Symbol.toStringTag]() {
return "Set";
},
toJSON() {
return {};
},
[Symbol.iterator]() {
return this.data[Symbol.iterator]();
},
values() {
return this.data.values();
},
keys() {
return this.data.values();
},
entries() {
return new Set(this.data).entries();
}
});
Object.defineProperties(set, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(set);
return set;
}
function proxyMap(entries) {
const map = proxy({
data: Array.from(entries || []),
has(key) {
return this.data.some((p) => p[0] === key);
},
set(key, value) {
const record = this.data.find((p) => p[0] === key);
if (record) {
record[1] = value;
} else {
this.data.push([key, value]);
}
return this;
},
get(key) {
var _a;
return (_a = this.data.find((p) => p[0] === key)) == null ? void 0 : _a[1];
},
delete(key) {
const index = this.data.findIndex((p) => p[0] === key);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
toJSON() {
return {};
},
forEach(cb) {
this.data.forEach((p) => {
cb(p[1], p[0], this);
});
},
keys() {
return this.data.map((p) => p[0]).values();
},
values() {
return this.data.map((p) => p[1]).values();
},
entries() {
return new Map(this.data).entries();
},
get [Symbol.toStringTag]() {
return "Map";
},
[Symbol.iterator]() {
return this.entries();
}
});
Object.defineProperties(map, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(map);
return map;
}
})
};
}));

2
node_modules/valtio/system/utils.production.js generated vendored Normal file

File diff suppressed because one or more lines are too long

233
node_modules/valtio/system/vanilla.development.js generated vendored Normal file
View File

@@ -0,0 +1,233 @@
System.register(['proxy-compare'], (function (exports) {
'use strict';
var markToTrack, getUntracked;
return {
setters: [function (module) {
markToTrack = module.markToTrack;
getUntracked = module.getUntracked;
}],
execute: (function () {
exports({
getVersion: getVersion,
proxy: proxy,
ref: ref,
snapshot: snapshot,
subscribe: subscribe
});
const isObject = (x) => typeof x === "object" && x !== null;
const refSet = /* @__PURE__ */ new WeakSet();
const VERSION = Symbol("VERSION") ;
const LISTENERS = Symbol("LISTENERS") ;
const SNAPSHOT = Symbol("SNAPSHOT") ;
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), PROMISE_RESULT = Symbol("PROMISE_RESULT") , PROMISE_ERROR = Symbol("PROMISE_ERROR") , snapshotCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (version, target, receiver) => {
const cache = snapshotCache.get(receiver);
if ((cache == null ? void 0 : cache[0]) === version) {
return cache[1];
}
const snapshot2 = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
markToTrack(snapshot2, true);
snapshotCache.set(receiver, [version, snapshot2]);
Reflect.ownKeys(target).forEach((key) => {
const value = Reflect.get(target, key, receiver);
if (refSet.has(value)) {
markToTrack(value, false);
snapshot2[key] = value;
} else if (value instanceof Promise) {
if (PROMISE_RESULT in value) {
snapshot2[key] = value[PROMISE_RESULT];
} else {
const errorOrPromise = value[PROMISE_ERROR] || value;
Object.defineProperty(snapshot2, key, {
get() {
if (PROMISE_RESULT in value) {
return value[PROMISE_RESULT];
}
throw errorOrPromise;
}
});
}
} else if (value == null ? void 0 : value[LISTENERS]) {
snapshot2[key] = value[SNAPSHOT];
} else {
snapshot2[key] = value;
}
});
return Object.freeze(snapshot2);
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1], proxyFunction2 = (initialObject) => {
if (!isObject(initialObject)) {
throw new Error("object required");
}
const found = proxyCache.get(initialObject);
if (found) {
return found;
}
let version = versionHolder[0];
const listeners = /* @__PURE__ */ new Set();
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
if (version !== nextVersion) {
version = nextVersion;
listeners.forEach((listener) => listener(op, nextVersion));
}
};
const propListeners = /* @__PURE__ */ new Map();
const getPropListener = (prop) => {
let propListener = propListeners.get(prop);
if (!propListener) {
propListener = (op, nextVersion) => {
const newOp = [...op];
newOp[1] = [prop, ...newOp[1]];
notifyUpdate(newOp, nextVersion);
};
propListeners.set(prop, propListener);
}
return propListener;
};
const popPropListener = (prop) => {
const propListener = propListeners.get(prop);
propListeners.delete(prop);
return propListener;
};
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
const handler = {
get(target, prop, receiver) {
if (prop === VERSION) {
return version;
}
if (prop === LISTENERS) {
return listeners;
}
if (prop === SNAPSHOT) {
return createSnapshot(version, target, receiver);
}
return Reflect.get(target, prop, receiver);
},
deleteProperty(target, prop) {
const prevValue = Reflect.get(target, prop);
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
const deleted = Reflect.deleteProperty(target, prop);
if (deleted) {
notifyUpdate(["delete", [prop], prevValue]);
}
return deleted;
},
set(target, prop, value, receiver) {
var _a;
const hasPrevValue = Reflect.has(target, prop);
const prevValue = Reflect.get(target, prop, receiver);
if (hasPrevValue && objectIs(prevValue, value)) {
return true;
}
const childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
if (isObject(value)) {
value = getUntracked(value) || value;
}
let nextValue;
if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) {
nextValue = value;
} else if (value instanceof Promise) {
nextValue = value.then((v) => {
nextValue[PROMISE_RESULT] = v;
notifyUpdate(["resolve", [prop], v]);
return v;
}).catch((e) => {
nextValue[PROMISE_ERROR] = e;
notifyUpdate(["reject", [prop], e]);
});
} else if (value == null ? void 0 : value[LISTENERS]) {
nextValue = value;
nextValue[LISTENERS].add(getPropListener(prop));
} else if (canProxy(value)) {
nextValue = proxy(value);
nextValue[LISTENERS].add(getPropListener(prop));
} else {
nextValue = value;
}
Reflect.set(target, prop, nextValue, receiver);
notifyUpdate(["set", [prop], value, prevValue]);
return true;
}
};
const proxyObject = newProxy(baseObject, handler);
proxyCache.set(initialObject, proxyObject);
Reflect.ownKeys(initialObject).forEach((key) => {
const desc = Object.getOwnPropertyDescriptor(
initialObject,
key
);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
proxyObject[key] = initialObject[key];
}
});
return proxyObject;
}) => [
proxyFunction2,
refSet,
VERSION,
LISTENERS,
SNAPSHOT,
objectIs,
newProxy,
canProxy,
PROMISE_RESULT,
PROMISE_ERROR,
snapshotCache,
createSnapshot,
proxyCache,
versionHolder
];
const [proxyFunction] = buildProxyFunction();
function proxy(initialObject = {}) {
return proxyFunction(initialObject);
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : void 0;
}
function subscribe(proxyObject, callback, notifyInSync) {
if (!(proxyObject == null ? void 0 : proxyObject[LISTENERS])) {
console.warn("Please use proxy object");
}
let promise;
const ops = [];
const listener = (op) => {
ops.push(op);
if (notifyInSync) {
callback(ops.splice(0));
return;
}
if (!promise) {
promise = Promise.resolve().then(() => {
promise = void 0;
callback(ops.splice(0));
});
}
};
proxyObject[LISTENERS].add(listener);
return () => {
proxyObject[LISTENERS].delete(listener);
};
}
function snapshot(proxyObject) {
if (!(proxyObject == null ? void 0 : proxyObject[SNAPSHOT])) {
console.warn("Please use proxy object");
}
return proxyObject[SNAPSHOT];
}
function ref(obj) {
refSet.add(obj);
return obj;
}
const unstable_buildProxyFunction = exports('unstable_buildProxyFunction', buildProxyFunction);
})
};
}));

1
node_modules/valtio/system/vanilla.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
System.register(["proxy-compare"],function(D){"use strict";var A,M;return{setters:[function(d){A=d.markToTrack,M=d.getUntracked}],execute:function(){D({getVersion:_,proxy:V,ref:B,snapshot:z,subscribe:q});const d=o=>typeof o=="object"&&o!==null,k=new WeakSet,E=Symbol(),a=Symbol(),m=Symbol(),F=(o=Object.is,j=(t,f)=>new Proxy(t,f),P=t=>d(t)&&!k.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),u=Symbol(),g=Symbol(),O=new WeakMap,R=(t,f,b)=>{const w=O.get(b);if((w==null?void 0:w[0])===t)return w[1];const s=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f));return A(s,!0),O.set(b,[t,s]),Reflect.ownKeys(f).forEach(i=>{const c=Reflect.get(f,i,b);if(k.has(c))A(c,!1),s[i]=c;else if(c instanceof Promise)if(u in c)s[i]=c[u];else{const S=c[g]||c;Object.defineProperty(s,i,{get(){if(u in c)return c[u];throw S}})}else c!=null&&c[a]?s[i]=c[m]:s[i]=c}),Object.freeze(s)},T=new WeakMap,x=[1],I=t=>{if(!d(t))throw new Error("object required");const f=T.get(t);if(f)return f;let b=x[0];const w=new Set,s=(n,e=++x[0])=>{b!==e&&(b=e,w.forEach(r=>r(n,e)))},i=new Map,c=n=>{let e=i.get(n);return e||(e=(r,p)=>{const y=[...r];y[1]=[n,...y[1]],s(y,p)},i.set(n,e)),e},S=n=>{const e=i.get(n);return i.delete(n),e},K=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),W=j(K,{get(n,e,r){return e===E?b:e===a?w:e===m?R(b,n,r):Reflect.get(n,e,r)},deleteProperty(n,e){const r=Reflect.get(n,e),p=r==null?void 0:r[a];p&&p.delete(S(e));const y=Reflect.deleteProperty(n,e);return y&&s(["delete",[e],r]),y},set(n,e,r,p){var y;const C=Reflect.has(n,e),v=Reflect.get(n,e,p);if(C&&o(v,r))return!0;const N=v==null?void 0:v[a];N&&N.delete(S(e)),d(r)&&(r=M(r)||r);let l;return(y=Object.getOwnPropertyDescriptor(n,e))!=null&&y.set?l=r:r instanceof Promise?l=r.then(h=>(l[u]=h,s(["resolve",[e],h]),h)).catch(h=>{l[g]=h,s(["reject",[e],h])}):r!=null&&r[a]?(l=r,l[a].add(c(e))):P(r)?(l=V(r),l[a].add(c(e))):l=r,Reflect.set(n,e,l,p),s(["set",[e],r,v]),!0}});return T.set(t,W),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);e.get||e.set?Object.defineProperty(K,n,e):W[n]=t[n]}),W})=>[I,k,E,a,m,o,j,P,u,g,O,R,T,x],[U]=F();function V(o={}){return U(o)}function _(o){return d(o)?o[E]:void 0}function q(o,j,P){let u;const g=[],O=R=>{if(g.push(R),P){j(g.splice(0));return}u||(u=Promise.resolve().then(()=>{u=void 0,j(g.splice(0))}))};return o[a].add(O),()=>{o[a].delete(O)}}function z(o){return o[m]}function B(o){return k.add(o),o}const G=D("unstable_buildProxyFunction",F)}}});

2
node_modules/valtio/ts3.4/esm/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { useSnapshot } from './react';
export { ref, proxy, getVersion, subscribe, snapshot, unstable_buildProxyFunction, } from './vanilla';

3
node_modules/valtio/ts3.4/esm/macro.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function useProxy<T extends object>(proxyObject: T): void;
declare const _default: any;
export default _default;

5
node_modules/valtio/ts3.4/esm/macro/vite.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import * as plugin from 'aslemammad-vite-plugin-macro';
export declare const valtioMacro: plugin.Macro;
export declare function provideValtioMacro(): plugin.MacroProvider;
declare const macroPlugin: plugin.MacroPlugin;
export default macroPlugin;

78
node_modules/valtio/ts3.4/esm/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import { INTERNAL_Snapshot } from './vanilla';
declare type Options = {
sync?: boolean;
};
/**
* useSnapshot
*
* Create a local snapshot that catches changes. This hook actually returns a wrapped snapshot in a proxy for
* render optimization instead of a plain object compared to `snapshot()` method.
* Rule of thumb: read from snapshots, mutate the source.
* The component will only re-render when the parts of the state you access have changed, it is render-optimized.
*
* @example A
* function Counter() {
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.count}
* <button onClick={() => ++state.count}>+1</button>
* </div>
* )
* }
*
* [Notes]
* Every object inside your proxy also becomes a proxy (if you don't use "ref"), so you can also use them to create
* the local snapshot as seen on example B.
*
* @example B
* function ProfileName() {
* const snap = useSnapshot(state.profile)
* return (
* <div>
* {snap.name}
* </div>
* )
* }
*
* Beware that you still can replace the child proxy with something else so it will break your snapshot. You can see
* above what happens with the original proxy when you replace the child proxy.
*
* > console.log(state)
* { profile: { name: "valtio" } }
* > childState = state.profile
* > console.log(childState)
* { name: "valtio" }
* > state.profile.name = "react"
* > console.log(childState)
* { name: "react" }
* > state.profile = { name: "new name" }
* > console.log(childState)
* { name: "react" }
* > console.log(state)
* { profile: { name: "new name" } }
*
* `useSnapshot()` depends on the original reference of the child proxy so if you replace it with a new one, the component
* that is subscribed to the old proxy won't receive new updates because it is still subscribed to the old one.
*
* In this case we recommend the example C or D. On both examples you don't need to worry with re-render,
* because it is render-optimized.
*
* @example C
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.profile.name}
* </div>
* )
*
* @example D
* const { profile } = useSnapshot(state)
* return (
* <div>
* {profile.name}
* </div>
* )
*/
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): INTERNAL_Snapshot<T>;
export {};

9
node_modules/valtio/ts3.4/esm/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export { subscribeKey } from './utils/subscribeKey';
export { watch } from './utils/watch';
export { devtools } from './utils/devtools';
export { derive, underive, unstable_deriveSubscriptions } from './utils/derive';
export { addComputed_DEPRECATED as addComputed } from './utils/addComputed';
export { proxyWithComputed } from './utils/proxyWithComputed';
export { proxyWithHistory } from './utils/proxyWithHistory';
export { proxySet } from './utils/proxySet';
export { proxyMap } from './utils/proxyMap';

8
node_modules/valtio/ts3.4/esm/utils/addComputed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/**
* addComputed (DEPRECATED)
*
* @deprecated Please consider using `derive` or `proxyWithComputed` instead.
*/
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any): any;

72
node_modules/valtio/ts3.4/esm/utils/derive.d.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
declare type DeriveGet = <T extends object>(proxyObject: T) => T;
declare type Subscription = {
s: object;
d: object;
k: string;
c: () => void;
n: boolean;
i: string[];
p?: Promise<void>;
};
export declare const unstable_deriveSubscriptions: {
add: (subscription: Subscription) => void;
remove: (subscription: Subscription) => void;
list: (derivedObject: object) => Subscription[];
};
/**
* derive
*
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.
*
* @example
* import { proxy } from 'valtio'
* import { derive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* derive({
* tripled: (get) => get(state).count * 3,
* }, {
* proxy: state,
* })
*/
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];
}, options?: {
proxy?: T;
sync?: boolean;
}): T & U;
/**
* underive
*
* This stops derived properties to evaluate.
* It will stop all (or specified by `keys` option) subscriptions.
* If you specify `delete` option, it will delete the properties
* and you can attach new derived properties.
*
* @example
* import { proxy } from 'valtio'
* import { derive, underive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* underive(derivedState)
*/
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
}): void;
export {};

10
node_modules/valtio/ts3.4/esm/utils/devtools.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
declare type Options = {
enabled?: boolean;
name?: string;
};
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;
/**
* @deprecated Please use { name } option
*/
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;
export {};

32
node_modules/valtio/ts3.4/esm/utils/proxyMap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* proxyMap
*
* This is to create a proxy which mimic the native Map behavior.
* The API is the same as Map API
*
* @example
* import { proxyMap } from 'valtio/utils'
* const state = proxyMap([["key", "value"]])
*
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* map: proxyMap()
* })
*
* // When using an object as a key, you can wrap it with `ref` so it's not proxied
* // this is useful if you want to preserve the key equality
* import { ref } from 'valtio'
*
* const key = ref({})
* state.set(key, "value")
* state.get(key) //value
*
* const key = {}
* state.set(key, "value")
* state.get(key) //undefined
*/
export declare function proxyMap<K, V>(entries?: Iterable<readonly [
K,
V
]> | null): Map<K, V>;

16
node_modules/valtio/ts3.4/esm/utils/proxySet.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* proxySet
*
* This is to create a proxy which mimic the native Set behavior.
* The API is the same as Set API
*
* @example
* import { proxySet } from 'valtio/utils'
* const state = proxySet([1,2,3])
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* set: proxySet()
* })
*/
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

View File

@@ -0,0 +1,31 @@
import { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithComputed
*
* This is to create a proxy with initial object and additional object,
* which specifies getters for computed values with dependency tracking.
* It also accepts optional setters for computed values.
*
* [Notes]
* This comes with a cost and overlaps with useSnapshot.
* Do not try to optimize too early. It can worsen the performance.
* Measurement and comparison will be very important.
*
* @example
* import { proxyWithComputed } from 'valtio/utils'
* const state = proxyWithComputed({
* count: 1,
* }, {
* doubled: snap => snap.count * 2, // getter only
* tripled: {
* get: snap => snap.count * 3,
* set: (state, newValue) => { state.count = newValue / 3 }
* }, // with optional setter
* })
*/
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: INTERNAL_Snapshot<T>) => U[K]) | {
get: (snap: INTERNAL_Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
};
}): T & U;

View File

@@ -0,0 +1,40 @@
import { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithHistory
*
* This creates a new proxy with history support.
* It includes following properties:
* - value: any value (does not have to be an object)
* - history: an array holding the history of snapshots
* - historyIndex: the history index to the current snapshot
* - canUndo: a function to return true if undo is available
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available
* - redo: a function to go forward history
* - saveHistory: a function to save history
*
* [Notes]
* Suspense/promise is not supported.
*
* @example
* import { proxyWithHistory } from 'valtio/utils'
* const state = proxyWithHistory({
* count: 1,
* })
*/
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;
history: {
wip: INTERNAL_Snapshot<V> | undefined;
snapshots: INTERNAL_Snapshot<V>[];
index: number;
} & {
$$valtioRef: true;
};
canUndo: () => boolean;
undo: () => void;
canRedo: () => boolean;
redo: () => void;
saveHistory: () => void;
subscribe: () => () => void;
};

12
node_modules/valtio/ts3.4/esm/utils/subscribeKey.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* subscribeKey
*
* The subscribeKey utility enables subscription to a primitive subproperty of a given state proxy.
* Subscriptions created with subscribeKey will only fire when the specified property changes.
* notifyInSync: same as the parameter to subscribe(); true disables batching of subscriptions.
*
* @example
* import { subscribeKey } from 'valtio/utils'
* subscribeKey(state, 'count', (v) => console.log('state.count has changed to', v))
*/
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

31
node_modules/valtio/ts3.4/esm/utils/watch.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
declare type Cleanup = () => void;
declare type WatchGet = <T extends object>(proxyObject: T) => T;
declare type WatchCallback = (get: WatchGet) => Cleanup | void | undefined;
declare type WatchOptions = {
sync?: boolean;
};
/**
* watch
*
* Creates a reactive effect that automatically tracks proxy objects and
* reevaluates everytime one of the tracked proxy objects updates. It returns
* a cleanup function to stop the reactive effect from reevaluating.
*
* Callback is invoked immediately to detect the tracked objects.
*
* Callback passed to `watch` receives a `get` function that "tracks" the
* passed proxy object.
*
* Watch callbacks may return an optional cleanup function, which is evaluated
* whenever the callback reevaluates or when the cleanup function returned by
* `watch` is evaluated.
*
* `watch` calls inside `watch` are also automatically tracked and cleaned up
* whenever the parent `watch` reevaluates.
*
* @param callback
* @returns A cleanup function that stops the callback from reevaluating and
* also performs cleanups registered into `watch`.
*/
export declare function watch(callback: WatchCallback, options?: WatchOptions): Cleanup;
export {};

62
node_modules/valtio/ts3.4/esm/vanilla.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
declare type AsRef = {
$$valtioRef: true;
};
declare type Path = (string | symbol)[];
declare type Op = [
/*op*/ 'set',
/*path*/ Path,
/*value*/ unknown,
/*prevValue*/ unknown
] | [
/*op*/ 'delete',
/*path*/ Path,
/*prevValue*/ unknown
] | [
/*op*/ 'resolve',
/*path*/ Path,
/*value*/ unknown
] | [
/*op*/ 'reject',
/*path*/ Path,
/*error*/ unknown
];
declare type AnyFunction = (...args: any[]) => any;
/**
* This is not a public API.
* It can be changed without any notice.
*/
export declare type INTERNAL_Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? INTERNAL_Snapshot<V> : {
readonly [K in keyof T]: INTERNAL_Snapshot<T[K]>;
};
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
export declare function snapshot<T extends object>(proxyObject: T): INTERNAL_Snapshot<T>;
export declare function ref<T extends object>(obj: T): T & AsRef;
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, PROMISE_RESULT?: symbol, PROMISE_ERROR?: symbol, snapshotCache?: WeakMap<object, [
/*version*/ number,
/*snapshot*/ unknown
]>, createSnapshot?: <T_1 extends object>(version: number, target: T_1, receiver: any) => T_1, proxyCache?: WeakMap<object, object>, versionHolder?: [
number
], proxyFunction?: <T_2 extends object>(initialObject: T_2) => T_2) => readonly [
<T_2 extends object>(initialObject: T_2) => T_2,
WeakSet<object>,
symbol,
symbol,
symbol,
(value1: any, value2: any) => boolean,
<T extends object>(target: T, handler: ProxyHandler<T>) => T,
(x: unknown) => boolean,
symbol,
symbol,
WeakMap<object, [
/*version*/ number,
/*snapshot*/ unknown
]>,
<T_1 extends object>(version: number, target: T_1, receiver: any) => T_1,
WeakMap<object, object>,
[
number
]
];
export {};

2
node_modules/valtio/ts3.4/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { useSnapshot } from './react';
export { ref, proxy, getVersion, subscribe, snapshot, unstable_buildProxyFunction, } from './vanilla';

3
node_modules/valtio/ts3.4/macro.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function useProxy<T extends object>(proxyObject: T): void;
declare const _default: any;
export default _default;

78
node_modules/valtio/ts3.4/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import { INTERNAL_Snapshot } from './vanilla';
declare type Options = {
sync?: boolean;
};
/**
* useSnapshot
*
* Create a local snapshot that catches changes. This hook actually returns a wrapped snapshot in a proxy for
* render optimization instead of a plain object compared to `snapshot()` method.
* Rule of thumb: read from snapshots, mutate the source.
* The component will only re-render when the parts of the state you access have changed, it is render-optimized.
*
* @example A
* function Counter() {
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.count}
* <button onClick={() => ++state.count}>+1</button>
* </div>
* )
* }
*
* [Notes]
* Every object inside your proxy also becomes a proxy (if you don't use "ref"), so you can also use them to create
* the local snapshot as seen on example B.
*
* @example B
* function ProfileName() {
* const snap = useSnapshot(state.profile)
* return (
* <div>
* {snap.name}
* </div>
* )
* }
*
* Beware that you still can replace the child proxy with something else so it will break your snapshot. You can see
* above what happens with the original proxy when you replace the child proxy.
*
* > console.log(state)
* { profile: { name: "valtio" } }
* > childState = state.profile
* > console.log(childState)
* { name: "valtio" }
* > state.profile.name = "react"
* > console.log(childState)
* { name: "react" }
* > state.profile = { name: "new name" }
* > console.log(childState)
* { name: "react" }
* > console.log(state)
* { profile: { name: "new name" } }
*
* `useSnapshot()` depends on the original reference of the child proxy so if you replace it with a new one, the component
* that is subscribed to the old proxy won't receive new updates because it is still subscribed to the old one.
*
* In this case we recommend the example C or D. On both examples you don't need to worry with re-render,
* because it is render-optimized.
*
* @example C
* const snap = useSnapshot(state)
* return (
* <div>
* {snap.profile.name}
* </div>
* )
*
* @example D
* const { profile } = useSnapshot(state)
* return (
* <div>
* {profile.name}
* </div>
* )
*/
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): INTERNAL_Snapshot<T>;
export {};

9
node_modules/valtio/ts3.4/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export { subscribeKey } from './utils/subscribeKey';
export { watch } from './utils/watch';
export { devtools } from './utils/devtools';
export { derive, underive, unstable_deriveSubscriptions } from './utils/derive';
export { addComputed_DEPRECATED as addComputed } from './utils/addComputed';
export { proxyWithComputed } from './utils/proxyWithComputed';
export { proxyWithHistory } from './utils/proxyWithHistory';
export { proxySet } from './utils/proxySet';
export { proxyMap } from './utils/proxyMap';

8
node_modules/valtio/ts3.4/utils/addComputed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/**
* addComputed (DEPRECATED)
*
* @deprecated Please consider using `derive` or `proxyWithComputed` instead.
*/
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any): any;

72
node_modules/valtio/ts3.4/utils/derive.d.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
declare type DeriveGet = <T extends object>(proxyObject: T) => T;
declare type Subscription = {
s: object;
d: object;
k: string;
c: () => void;
n: boolean;
i: string[];
p?: Promise<void>;
};
export declare const unstable_deriveSubscriptions: {
add: (subscription: Subscription) => void;
remove: (subscription: Subscription) => void;
list: (derivedObject: object) => Subscription[];
};
/**
* derive
*
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.
*
* @example
* import { proxy } from 'valtio'
* import { derive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* derive({
* tripled: (get) => get(state).count * 3,
* }, {
* proxy: state,
* })
*/
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];
}, options?: {
proxy?: T;
sync?: boolean;
}): T & U;
/**
* underive
*
* This stops derived properties to evaluate.
* It will stop all (or specified by `keys` option) subscriptions.
* If you specify `delete` option, it will delete the properties
* and you can attach new derived properties.
*
* @example
* import { proxy } from 'valtio'
* import { derive, underive } from 'valtio/utils'
*
* const state = proxy({
* count: 1,
* })
*
* const derivedState = derive({
* doubled: (get) => get(state).count * 2,
* })
*
* underive(derivedState)
*/
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
}): void;
export {};

10
node_modules/valtio/ts3.4/utils/devtools.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
declare type Options = {
enabled?: boolean;
name?: string;
};
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;
/**
* @deprecated Please use { name } option
*/
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;
export {};

32
node_modules/valtio/ts3.4/utils/proxyMap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* proxyMap
*
* This is to create a proxy which mimic the native Map behavior.
* The API is the same as Map API
*
* @example
* import { proxyMap } from 'valtio/utils'
* const state = proxyMap([["key", "value"]])
*
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* map: proxyMap()
* })
*
* // When using an object as a key, you can wrap it with `ref` so it's not proxied
* // this is useful if you want to preserve the key equality
* import { ref } from 'valtio'
*
* const key = ref({})
* state.set(key, "value")
* state.get(key) //value
*
* const key = {}
* state.set(key, "value")
* state.get(key) //undefined
*/
export declare function proxyMap<K, V>(entries?: Iterable<readonly [
K,
V
]> | null): Map<K, V>;

16
node_modules/valtio/ts3.4/utils/proxySet.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* proxySet
*
* This is to create a proxy which mimic the native Set behavior.
* The API is the same as Set API
*
* @example
* import { proxySet } from 'valtio/utils'
* const state = proxySet([1,2,3])
* //can be used inside a proxy as well
* const state = proxy({
* count: 1,
* set: proxySet()
* })
*/
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

31
node_modules/valtio/ts3.4/utils/proxyWithComputed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithComputed
*
* This is to create a proxy with initial object and additional object,
* which specifies getters for computed values with dependency tracking.
* It also accepts optional setters for computed values.
*
* [Notes]
* This comes with a cost and overlaps with useSnapshot.
* Do not try to optimize too early. It can worsen the performance.
* Measurement and comparison will be very important.
*
* @example
* import { proxyWithComputed } from 'valtio/utils'
* const state = proxyWithComputed({
* count: 1,
* }, {
* doubled: snap => snap.count * 2, // getter only
* tripled: {
* get: snap => snap.count * 3,
* set: (state, newValue) => { state.count = newValue / 3 }
* }, // with optional setter
* })
*/
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: INTERNAL_Snapshot<T>) => U[K]) | {
get: (snap: INTERNAL_Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
};
}): T & U;

40
node_modules/valtio/ts3.4/utils/proxyWithHistory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import { INTERNAL_Snapshot } from '../vanilla';
/**
* proxyWithHistory
*
* This creates a new proxy with history support.
* It includes following properties:
* - value: any value (does not have to be an object)
* - history: an array holding the history of snapshots
* - historyIndex: the history index to the current snapshot
* - canUndo: a function to return true if undo is available
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available
* - redo: a function to go forward history
* - saveHistory: a function to save history
*
* [Notes]
* Suspense/promise is not supported.
*
* @example
* import { proxyWithHistory } from 'valtio/utils'
* const state = proxyWithHistory({
* count: 1,
* })
*/
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;
history: {
wip: INTERNAL_Snapshot<V> | undefined;
snapshots: INTERNAL_Snapshot<V>[];
index: number;
} & {
$$valtioRef: true;
};
canUndo: () => boolean;
undo: () => void;
canRedo: () => boolean;
redo: () => void;
saveHistory: () => void;
subscribe: () => () => void;
};

12
node_modules/valtio/ts3.4/utils/subscribeKey.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* subscribeKey
*
* The subscribeKey utility enables subscription to a primitive subproperty of a given state proxy.
* Subscriptions created with subscribeKey will only fire when the specified property changes.
* notifyInSync: same as the parameter to subscribe(); true disables batching of subscriptions.
*
* @example
* import { subscribeKey } from 'valtio/utils'
* subscribeKey(state, 'count', (v) => console.log('state.count has changed to', v))
*/
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

31
node_modules/valtio/ts3.4/utils/watch.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
declare type Cleanup = () => void;
declare type WatchGet = <T extends object>(proxyObject: T) => T;
declare type WatchCallback = (get: WatchGet) => Cleanup | void | undefined;
declare type WatchOptions = {
sync?: boolean;
};
/**
* watch
*
* Creates a reactive effect that automatically tracks proxy objects and
* reevaluates everytime one of the tracked proxy objects updates. It returns
* a cleanup function to stop the reactive effect from reevaluating.
*
* Callback is invoked immediately to detect the tracked objects.
*
* Callback passed to `watch` receives a `get` function that "tracks" the
* passed proxy object.
*
* Watch callbacks may return an optional cleanup function, which is evaluated
* whenever the callback reevaluates or when the cleanup function returned by
* `watch` is evaluated.
*
* `watch` calls inside `watch` are also automatically tracked and cleaned up
* whenever the parent `watch` reevaluates.
*
* @param callback
* @returns A cleanup function that stops the callback from reevaluating and
* also performs cleanups registered into `watch`.
*/
export declare function watch(callback: WatchCallback, options?: WatchOptions): Cleanup;
export {};

62
node_modules/valtio/ts3.4/vanilla.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
declare type AsRef = {
$$valtioRef: true;
};
declare type Path = (string | symbol)[];
declare type Op = [
/*op*/ 'set',
/*path*/ Path,
/*value*/ unknown,
/*prevValue*/ unknown
] | [
/*op*/ 'delete',
/*path*/ Path,
/*prevValue*/ unknown
] | [
/*op*/ 'resolve',
/*path*/ Path,
/*value*/ unknown
] | [
/*op*/ 'reject',
/*path*/ Path,
/*error*/ unknown
];
declare type AnyFunction = (...args: any[]) => any;
/**
* This is not a public API.
* It can be changed without any notice.
*/
export declare type INTERNAL_Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? INTERNAL_Snapshot<V> : {
readonly [K in keyof T]: INTERNAL_Snapshot<T[K]>;
};
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
export declare function snapshot<T extends object>(proxyObject: T): INTERNAL_Snapshot<T>;
export declare function ref<T extends object>(obj: T): T & AsRef;
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, PROMISE_RESULT?: symbol, PROMISE_ERROR?: symbol, snapshotCache?: WeakMap<object, [
/*version*/ number,
/*snapshot*/ unknown
]>, createSnapshot?: <T_1 extends object>(version: number, target: T_1, receiver: any) => T_1, proxyCache?: WeakMap<object, object>, versionHolder?: [
number
], proxyFunction?: <T_2 extends object>(initialObject: T_2) => T_2) => readonly [
<T_2 extends object>(initialObject: T_2) => T_2,
WeakSet<object>,
symbol,
symbol,
symbol,
(value1: any, value2: any) => boolean,
<T extends object>(target: T, handler: ProxyHandler<T>) => T,
(x: unknown) => boolean,
symbol,
symbol,
WeakMap<object, [
/*version*/ number,
/*snapshot*/ unknown
]>,
<T_1 extends object>(version: number, target: T_1, receiver: any) => T_1,
WeakMap<object, object>,
[
number
]
];
export {};

88
node_modules/valtio/umd/index.development.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('proxy-compare'), require('use-sync-external-store/shim'), require('valtio/vanilla')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'proxy-compare', 'use-sync-external-store/shim', 'valtio/vanilla'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtio = {}, global.React, global.proxyCompare, global.useSyncExternalStoreExports, global.valtioVanilla));
})(this, (function (exports, react, proxyCompare, useSyncExternalStoreExports, vanilla) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var useSyncExternalStoreExports__default = /*#__PURE__*/_interopDefaultLegacy(useSyncExternalStoreExports);
var useSyncExternalStore = useSyncExternalStoreExports__default["default"].useSyncExternalStore;
var useAffectedDebugValue = function useAffectedDebugValue(state, affected) {
var pathList = react.useRef();
react.useEffect(function () {
pathList.current = proxyCompare.affectedToPathList(state, affected);
});
react.useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
var notifyInSync = options == null ? void 0 : options.sync;
var lastSnapshot = react.useRef();
var lastAffected = react.useRef();
var inRender = true;
var currSnapshot = useSyncExternalStore(react.useCallback(function (callback) {
var unsub = vanilla.subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
}, [proxyObject, notifyInSync]), function () {
var nextSnapshot = vanilla.snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !proxyCompare.isChanged(lastSnapshot.current, nextSnapshot, lastAffected.current, new WeakMap())) {
return lastSnapshot.current;
}
} catch (e) {}
return nextSnapshot;
}, function () {
return vanilla.snapshot(proxyObject);
});
inRender = false;
var currAffected = new WeakMap();
react.useEffect(function () {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
{
useAffectedDebugValue(currSnapshot, currAffected);
}
var proxyCache = react.useMemo(function () {
return new WeakMap();
}, []);
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache);
}
Object.defineProperty(exports, 'getVersion', {
enumerable: true,
get: function () { return vanilla.getVersion; }
});
Object.defineProperty(exports, 'proxy', {
enumerable: true,
get: function () { return vanilla.proxy; }
});
Object.defineProperty(exports, 'ref', {
enumerable: true,
get: function () { return vanilla.ref; }
});
Object.defineProperty(exports, 'snapshot', {
enumerable: true,
get: function () { return vanilla.snapshot; }
});
Object.defineProperty(exports, 'subscribe', {
enumerable: true,
get: function () { return vanilla.subscribe; }
});
Object.defineProperty(exports, 'unstable_buildProxyFunction', {
enumerable: true,
get: function () { return vanilla.unstable_buildProxyFunction; }
});
exports.useSnapshot = useSnapshot;
Object.defineProperty(exports, '__esModule', { value: true });
}));

1
node_modules/valtio/umd/index.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("proxy-compare"),require("use-sync-external-store/shim"),require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.React,e.proxyCompare,e.useSyncExternalStoreExports,e.valtioVanilla)}(this,(function(e,r,n,t,u){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(t).default.useSyncExternalStore;Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return u.getVersion}}),Object.defineProperty(e,"proxy",{enumerable:!0,get:function(){return u.proxy}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return u.ref}}),Object.defineProperty(e,"snapshot",{enumerable:!0,get:function(){return u.snapshot}}),Object.defineProperty(e,"subscribe",{enumerable:!0,get:function(){return u.subscribe}}),Object.defineProperty(e,"unstable_buildProxyFunction",{enumerable:!0,get:function(){return u.unstable_buildProxyFunction}}),e.useSnapshot=function(e,t){var o=null==t?void 0:t.sync,a=r.useRef(),c=r.useRef(),s=!0,f=i(r.useCallback((function(r){var n=u.subscribe(e,r,o);return r(),n}),[e,o]),(function(){var r=u.snapshot(e);try{if(!s&&a.current&&c.current&&!n.isChanged(a.current,r,c.current,new WeakMap))return a.current}catch(e){}return r}),(function(){return u.snapshot(e)}));s=!1;var l=new WeakMap;r.useEffect((function(){a.current=f,c.current=l}));var p=r.useMemo((function(){return new WeakMap}),[]);return n.createProxy(f,l,p)},Object.defineProperty(e,"__esModule",{value:!0})}));

66
node_modules/valtio/umd/macro.development.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/helper-module-imports'), require('@babel/types'), require('babel-plugin-macros')) :
typeof define === 'function' && define.amd ? define(['exports', '@babel/helper-module-imports', '@babel/types', 'babel-plugin-macros'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioMacro = {}, global.helperModuleImports, global.t, global.babelPluginMacros));
})(this, (function (exports, helperModuleImports, t, babelPluginMacros) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var t__namespace = /*#__PURE__*/_interopNamespace(t);
var macro = function macro(_ref) {
var _references$useProxy;
var references = _ref.references;
(_references$useProxy = references.useProxy) == null ? void 0 : _references$useProxy.forEach(function (path) {
var _path$parentPath, _path$parentPath$get, _path$parentPath2, _path$parentPath2$par, _path$parentPath3, _path$parentPath3$get;
var hook = helperModuleImports.addNamed(path, 'useSnapshot', 'valtio');
var proxy = (_path$parentPath = path.parentPath) == null ? void 0 : (_path$parentPath$get = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath$get.node;
if (!t__namespace.isIdentifier(proxy)) throw new babelPluginMacros.MacroError('no proxy object');
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name);
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$par = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2$par.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))]));
var inFunction = 0;
(_path$parentPath3 = path.parentPath) == null ? void 0 : (_path$parentPath3$get = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3$get.traverse({
Identifier: function Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter: function enter() {
++inFunction;
},
exit: function exit() {
--inFunction;
}
}
});
});
};
var macro$1 = babelPluginMacros.createMacro(macro, {
configName: 'valtio'
});
exports["default"] = macro$1;
Object.defineProperty(exports, '__esModule', { value: true });
}));

1
node_modules/valtio/umd/macro.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/helper-module-imports"),require("@babel/types"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["exports","@babel/helper-module-imports","@babel/types","babel-plugin-macros"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioMacro={},e.helperModuleImports,e.t,e.babelPluginMacros)}(this,(function(e,t,n,r){"use strict";function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=a(n),i=r.createMacro((function(e){var n;null==(n=e.references.useProxy)||n.forEach((function(e){var n,a,i,l,u,c,f=t.addNamed(e,"useSnapshot","valtio"),s=null==(n=e.parentPath)||null==(a=n.get("arguments.0"))?void 0:a.node;if(!o.isIdentifier(s))throw new r.MacroError("no proxy object");var d=o.identifier("valtio_macro_snap_"+s.name);null==(i=e.parentPath)||null==(l=i.parentPath)||l.replaceWith(o.variableDeclaration("const",[o.variableDeclarator(d,o.callExpression(f,[s]))]));var p=0;null==(u=e.parentPath)||null==(c=u.getFunctionParent())||c.traverse({Identifier:function(e){0===p&&e.node!==s&&e.node.name===s.name&&(e.node.name=d.name)},Function:{enter:function(){++p},exit:function(){--p}}})}))}),{configName:"valtio"});e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}));

84
node_modules/valtio/umd/macro/vite.development.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/helper-module-imports'), require('@babel/types'), require('aslemammad-vite-plugin-macro'), require('babel-plugin-macros')) :
typeof define === 'function' && define.amd ? define(['exports', '@babel/helper-module-imports', '@babel/types', 'aslemammad-vite-plugin-macro', 'babel-plugin-macros'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioVite = {}, global.babelModuleImports, global.t, global.plugin, global.babelMacro));
})(this, (function (exports, babelModuleImports, t, plugin, babelMacro) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var babelModuleImports__namespace = /*#__PURE__*/_interopNamespace(babelModuleImports);
var t__namespace = /*#__PURE__*/_interopNamespace(t);
var plugin__namespace = /*#__PURE__*/_interopNamespace(plugin);
var babelMacro__namespace = /*#__PURE__*/_interopNamespace(babelMacro);
var _ref = 'default' in plugin__namespace ? plugin__namespace.default : plugin__namespace,
defineMacro = _ref.defineMacro,
defineMacroProvider = _ref.defineMacroProvider,
createMacroPlugin = _ref.createMacroPlugin;
var valtioMacro = defineMacro("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler(function (ctx) {
var _args$, _path$parentPath, _path$parentPath2, _path$parentPath2$get;
var path = ctx.path,
args = ctx.args;
var hook = babelModuleImports__namespace.addNamed(path, 'useSnapshot', 'valtio');
var proxy = (_args$ = args[0]) == null ? void 0 : _args$.node;
if (!t__namespace.isIdentifier(proxy)) {
throw new babelMacro__namespace.MacroError('no proxy object');
}
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name);
(_path$parentPath = path.parentPath) == null ? void 0 : _path$parentPath.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))]));
var inFunction = 0;
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$get = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2$get.traverse({
Identifier: function Identifier(p) {
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
p.node.name = snap.name;
}
},
Function: {
enter: function enter() {
++inFunction;
},
exit: function exit() {
--inFunction;
}
}
});
});
function provideValtioMacro() {
return defineMacroProvider({
id: 'valtio/macro',
exports: {
'valtio/macro': {
macros: [valtioMacro]
}
}
});
}
var macroPlugin = createMacroPlugin({}).use(provideValtioMacro());
exports["default"] = macroPlugin;
exports.provideValtioMacro = provideValtioMacro;
exports.valtioMacro = valtioMacro;
Object.defineProperty(exports, '__esModule', { value: true });
}));

1
node_modules/valtio/umd/macro/vite.production.js generated vendored Normal file
View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/helper-module-imports"),require("@babel/types"),require("aslemammad-vite-plugin-macro"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["exports","@babel/helper-module-imports","@babel/types","aslemammad-vite-plugin-macro","babel-plugin-macros"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioVite={},e.babelModuleImports,e.t,e.plugin,e.babelMacro)}(this,(function(e,t,r,a,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=o(t),l=o(r),u=o(a),c=o(n),d="default"in u?u.default:u,f=d.defineMacro,s=d.defineMacroProvider,p=d.createMacroPlugin,b=f("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler((function(e){var t,r,a,n,o=e.path,u=e.args,d=i.addNamed(o,"useSnapshot","valtio"),f=null==(t=u[0])?void 0:t.node;if(!l.isIdentifier(f))throw new c.MacroError("no proxy object");var s=l.identifier("valtio_macro_snap_"+f.name);null==(r=o.parentPath)||r.replaceWith(l.variableDeclaration("const",[l.variableDeclarator(s,l.callExpression(d,[f]))]));var p=0;null==(a=o.parentPath)||null==(n=a.getFunctionParent())||n.traverse({Identifier:function(e){0===p&&e.node!==f&&e.node.name===f.name&&(e.node.name=s.name)},Function:{enter:function(){++p},exit:function(){--p}}})}));function m(){return s({id:"valtio/macro",exports:{"valtio/macro":{macros:[b]}}})}var v=p({}).use(m());e.default=v,e.provideValtioMacro=m,e.valtioMacro=b,Object.defineProperty(e,"__esModule",{value:!0})}));

770
node_modules/valtio/umd/utils.development.js generated vendored Normal file
View File

@@ -0,0 +1,770 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('valtio/vanilla')) :
typeof define === 'function' && define.amd ? define(['exports', 'valtio/vanilla'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioUtils = {}, global.valtioVanilla));
})(this, (function (exports, vanilla) { 'use strict';
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return vanilla.subscribe(proxyObject, function (ops) {
if (ops.some(function (op) {
return op[1][0] === key;
})) {
callback(proxyObject[key]);
}
}, notifyInSync);
}
var currentCleanups;
function watch(callback, options) {
var alive = true;
var cleanups = new Set();
var subscriptions = new Map();
var cleanup = function cleanup() {
if (alive) {
alive = false;
cleanups.forEach(function (clean) {
return clean();
});
cleanups.clear();
subscriptions.forEach(function (unsubscribe) {
return unsubscribe();
});
subscriptions.clear();
}
};
var revalidate = function revalidate() {
if (!alive) {
return;
}
cleanups.forEach(function (clean) {
return clean();
});
cleanups.clear();
var proxiesToSubscribe = new Set();
var parent = currentCleanups;
currentCleanups = cleanups;
try {
var cleanupReturn = callback(function (proxyObject) {
proxiesToSubscribe.add(proxyObject);
return proxyObject;
});
if (cleanupReturn) {
cleanups.add(cleanupReturn);
}
} finally {
currentCleanups = parent;
}
subscriptions.forEach(function (unsubscribe, proxyObject) {
if (proxiesToSubscribe.has(proxyObject)) {
proxiesToSubscribe.delete(proxyObject);
} else {
subscriptions.delete(proxyObject);
unsubscribe();
}
});
proxiesToSubscribe.forEach(function (proxyObject) {
var unsubscribe = vanilla.subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync);
subscriptions.set(proxyObject, unsubscribe);
});
};
if (currentCleanups) {
currentCleanups.add(cleanup);
}
revalidate();
return cleanup;
}
var DEVTOOLS = Symbol();
function devtools(proxyObject, options) {
if (typeof options === 'string') {
console.warn('string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400');
options = {
name: options
};
}
var _ref = options || {},
enabled = _ref.enabled,
_ref$name = _ref.name,
name = _ref$name === void 0 ? '' : _ref$name;
var extension;
try {
extension = (enabled != null ? enabled : true) && window.__REDUX_DEVTOOLS_EXTENSION__;
} catch (_unused) {}
if (!extension) {
if (enabled) {
console.warn('[Warning] Please install/enable Redux devtools extension');
}
return;
}
var isTimeTraveling = false;
var devtools = extension.connect({
name: name
});
var unsub1 = vanilla.subscribe(proxyObject, function (ops) {
var action = ops.filter(function (_ref2) {
_ref2[0];
var path = _ref2[1];
return path[0] !== DEVTOOLS;
}).map(function (_ref3) {
var op = _ref3[0],
path = _ref3[1];
return op + ":" + path.map(String).join('.');
}).join(', ');
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
var snapWithoutDevtools = Object.assign({}, vanilla.snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools.send({
type: action,
updatedAt: new Date().toLocaleString()
}, snapWithoutDevtools);
}
});
var unsub2 = devtools.subscribe(function (message) {
var _message$payload3, _message$payload4;
if (message.type === 'ACTION' && message.payload) {
try {
Object.assign(proxyObject, JSON.parse(message.payload));
} catch (e) {
console.error('please dispatch a serializable value that JSON.parse() and proxy() support\n', e);
}
}
if (message.type === 'DISPATCH' && message.state) {
var _message$payload, _message$payload2;
if (((_message$payload = message.payload) == null ? void 0 : _message$payload.type) === 'JUMP_TO_ACTION' || ((_message$payload2 = message.payload) == null ? void 0 : _message$payload2.type) === 'JUMP_TO_STATE') {
isTimeTraveling = true;
var state = JSON.parse(message.state);
Object.assign(proxyObject, state);
}
proxyObject[DEVTOOLS] = message;
} else if (message.type === 'DISPATCH' && ((_message$payload3 = message.payload) == null ? void 0 : _message$payload3.type) === 'COMMIT') {
devtools.init(vanilla.snapshot(proxyObject));
} else if (message.type === 'DISPATCH' && ((_message$payload4 = message.payload) == null ? void 0 : _message$payload4.type) === 'IMPORT_STATE') {
var _message$payload$next, _message$payload$next2;
var actions = (_message$payload$next = message.payload.nextLiftedState) == null ? void 0 : _message$payload$next.actionsById;
var computedStates = ((_message$payload$next2 = message.payload.nextLiftedState) == null ? void 0 : _message$payload$next2.computedStates) || [];
isTimeTraveling = true;
computedStates.forEach(function (_ref4, index) {
var state = _ref4.state;
var action = actions[index] || 'No action found';
Object.assign(proxyObject, state);
if (index === 0) {
devtools.init(vanilla.snapshot(proxyObject));
} else {
devtools.send(action, vanilla.snapshot(proxyObject));
}
});
}
});
devtools.init(vanilla.snapshot(proxyObject));
return function () {
unsub1();
unsub2 == null ? void 0 : unsub2();
};
}
var sourceObjectMap = new WeakMap();
var derivedObjectMap = new WeakMap();
var markPending = function markPending(sourceObject, callback) {
var sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
sourceObjectEntry[0].forEach(function (subscription) {
var derivedObject = subscription.d;
if (sourceObject !== derivedObject) {
markPending(derivedObject);
}
});
++sourceObjectEntry[2];
if (callback) {
sourceObjectEntry[3].add(callback);
}
}
};
var checkPending = function checkPending(sourceObject, callback) {
var sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry != null && sourceObjectEntry[2]) {
sourceObjectEntry[3].add(callback);
return true;
}
return false;
};
var unmarkPending = function unmarkPending(sourceObject) {
var sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
--sourceObjectEntry[2];
if (!sourceObjectEntry[2]) {
sourceObjectEntry[3].forEach(function (callback) {
return callback();
});
sourceObjectEntry[3].clear();
}
sourceObjectEntry[0].forEach(function (subscription) {
var derivedObject = subscription.d;
if (sourceObject !== derivedObject) {
unmarkPending(derivedObject);
}
});
}
};
var addSubscription = function addSubscription(subscription) {
var sourceObject = subscription.s,
derivedObject = subscription.d;
var derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (!derivedObjectEntry) {
derivedObjectEntry = [new Set()];
derivedObjectMap.set(subscription.d, derivedObjectEntry);
}
derivedObjectEntry[0].add(subscription);
var sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (!sourceObjectEntry) {
var _subscriptions = new Set();
var _unsubscribe = vanilla.subscribe(sourceObject, function (ops) {
_subscriptions.forEach(function (subscription) {
var derivedObject = subscription.d,
callback = subscription.c,
notifyInSync = subscription.n,
ignoreKeys = subscription.i;
if (sourceObject === derivedObject && ops.every(function (op) {
return op[1].length === 1 && ignoreKeys.includes(op[1][0]);
})) {
return;
}
if (subscription.p) {
return;
}
markPending(sourceObject, callback);
if (notifyInSync) {
unmarkPending(sourceObject);
} else {
subscription.p = Promise.resolve().then(function () {
delete subscription.p;
unmarkPending(sourceObject);
});
}
});
}, true);
sourceObjectEntry = [_subscriptions, _unsubscribe, 0, new Set()];
sourceObjectMap.set(sourceObject, sourceObjectEntry);
}
sourceObjectEntry[0].add(subscription);
};
var removeSubscription = function removeSubscription(subscription) {
var sourceObject = subscription.s,
derivedObject = subscription.d;
var derivedObjectEntry = derivedObjectMap.get(derivedObject);
derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].delete(subscription);
if ((derivedObjectEntry == null ? void 0 : derivedObjectEntry[0].size) === 0) {
derivedObjectMap.delete(derivedObject);
}
var sourceObjectEntry = sourceObjectMap.get(sourceObject);
if (sourceObjectEntry) {
var _subscriptions2 = sourceObjectEntry[0],
_unsubscribe2 = sourceObjectEntry[1];
_subscriptions2.delete(subscription);
if (!_subscriptions2.size) {
_unsubscribe2();
sourceObjectMap.delete(sourceObject);
}
}
};
var listSubscriptions = function listSubscriptions(derivedObject) {
var derivedObjectEntry = derivedObjectMap.get(derivedObject);
if (derivedObjectEntry) {
return Array.from(derivedObjectEntry[0]);
}
return [];
};
var unstable_deriveSubscriptions = {
add: addSubscription,
remove: removeSubscription,
list: listSubscriptions
};
function derive(derivedFns, options) {
var proxyObject = (options == null ? void 0 : options.proxy) || vanilla.proxy({});
var notifyInSync = !!(options != null && options.sync);
var derivedKeys = Object.keys(derivedFns);
derivedKeys.forEach(function (key) {
if (Object.getOwnPropertyDescriptor(proxyObject, key)) {
throw new Error('object property already defined');
}
var fn = derivedFns[key];
var lastDependencies = null;
var evaluate = function evaluate() {
if (lastDependencies) {
if (Array.from(lastDependencies).map(function (_ref) {
var p = _ref[0];
return checkPending(p, evaluate);
}).some(function (isPending) {
return isPending;
})) {
return;
}
if (Array.from(lastDependencies).every(function (_ref2) {
var p = _ref2[0],
entry = _ref2[1];
return vanilla.getVersion(p) === entry.v;
})) {
return;
}
}
var dependencies = new Map();
var get = function get(p) {
dependencies.set(p, {
v: vanilla.getVersion(p)
});
return p;
};
var value = fn(get);
var subscribeToDependencies = function subscribeToDependencies() {
var _lastDependencies2;
dependencies.forEach(function (entry, p) {
var _lastDependencies, _lastDependencies$get;
var lastSubscription = (_lastDependencies = lastDependencies) == null ? void 0 : (_lastDependencies$get = _lastDependencies.get(p)) == null ? void 0 : _lastDependencies$get.s;
if (lastSubscription) {
entry.s = lastSubscription;
} else {
var subscription = {
s: p,
d: proxyObject,
k: key,
c: evaluate,
n: notifyInSync,
i: derivedKeys
};
addSubscription(subscription);
entry.s = subscription;
}
});
(_lastDependencies2 = lastDependencies) == null ? void 0 : _lastDependencies2.forEach(function (entry, p) {
if (!dependencies.has(p) && entry.s) {
removeSubscription(entry.s);
}
});
lastDependencies = dependencies;
};
if (value instanceof Promise) {
value.finally(subscribeToDependencies);
} else {
subscribeToDependencies();
}
proxyObject[key] = value;
};
evaluate();
});
return proxyObject;
}
function underive(proxyObject, options) {
var keysToDelete = options != null && options.delete ? new Set() : null;
listSubscriptions(proxyObject).forEach(function (subscription) {
var key = subscription.k;
if (!(options != null && options.keys) || options.keys.includes(key)) {
removeSubscription(subscription);
if (keysToDelete) {
keysToDelete.add(key);
}
}
});
if (keysToDelete) {
keysToDelete.forEach(function (key) {
delete proxyObject[key];
});
}
}
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject) {
if (targetObject === void 0) {
targetObject = proxyObject;
}
console.warn('addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive. https://github.com/pmndrs/valtio/pull/201');
var derivedFns = {};
Object.keys(computedFns_FAKE).forEach(function (key) {
derivedFns[key] = function (get) {
return computedFns_FAKE[key](get(proxyObject));
};
});
return derive(derivedFns, {
proxy: targetObject
});
}
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach(function (key) {
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
throw new Error('object property already defined');
}
var computedFn = computedFns[key];
var _ref = typeof computedFn === 'function' ? {
get: computedFn
} : computedFn,
get = _ref.get,
set = _ref.set;
var desc = {};
desc.get = function () {
return get(vanilla.snapshot(proxyObject));
};
if (set) {
desc.set = function (newValue) {
return set(proxyObject, newValue);
};
}
Object.defineProperty(initialObject, key, desc);
});
var proxyObject = vanilla.proxy(initialObject);
return proxyObject;
}
var isObject = function isObject(x) {
return typeof x === 'object' && x !== null;
};
var deepClone = function deepClone(obj) {
if (!isObject(obj)) {
return obj;
}
var baseObject = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
Reflect.ownKeys(obj).forEach(function (key) {
baseObject[key] = deepClone(obj[key]);
});
return baseObject;
};
function proxyWithHistory(initialValue, skipSubscribe) {
if (skipSubscribe === void 0) {
skipSubscribe = false;
}
var proxyObject = vanilla.proxy({
value: initialValue,
history: vanilla.ref({
wip: undefined,
snapshots: [],
index: -1
}),
canUndo: function canUndo() {
return proxyObject.history.index > 0;
},
undo: function undo() {
if (proxyObject.canUndo()) {
proxyObject.value = proxyObject.history.wip = deepClone(proxyObject.history.snapshots[--proxyObject.history.index]);
}
},
canRedo: function canRedo() {
return proxyObject.history.index < proxyObject.history.snapshots.length - 1;
},
redo: function redo() {
if (proxyObject.canRedo()) {
proxyObject.value = proxyObject.history.wip = deepClone(proxyObject.history.snapshots[++proxyObject.history.index]);
}
},
saveHistory: function saveHistory() {
proxyObject.history.snapshots.splice(proxyObject.history.index + 1);
proxyObject.history.snapshots.push(vanilla.snapshot(proxyObject).value);
++proxyObject.history.index;
},
subscribe: function subscribe() {
return vanilla.subscribe(proxyObject, function (ops) {
if (ops.every(function (op) {
return op[1][0] === 'value' && (op[0] !== 'set' || op[2] !== proxyObject.history.wip);
})) {
proxyObject.saveHistory();
}
});
}
});
proxyObject.saveHistory();
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;
}
function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
function proxySet(initialValues) {
var _Symbol$toStringTag, _proxy, _mutatorMap;
var set = vanilla.proxy((_proxy = {
data: Array.from(new Set(initialValues)),
has: function has(value) {
return this.data.indexOf(value) !== -1;
},
add: function add(value) {
var hasProxy = false;
if (typeof value === 'object' && value !== null) {
hasProxy = this.data.indexOf(vanilla.proxy(value)) !== -1;
}
if (this.data.indexOf(value) === -1 && !hasProxy) {
this.data.push(value);
}
return this;
},
delete: function _delete(value) {
var index = this.data.indexOf(value);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear: function clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
forEach: function forEach(cb) {
var _this = this;
this.data.forEach(function (value) {
cb(value, value, _this);
});
}
}, _Symbol$toStringTag = Symbol.toStringTag, _mutatorMap = {}, _mutatorMap[_Symbol$toStringTag] = _mutatorMap[_Symbol$toStringTag] || {}, _mutatorMap[_Symbol$toStringTag].get = function () {
return 'Set';
}, _proxy.toJSON = function toJSON() {
return {};
}, _proxy[Symbol.iterator] = function () {
return this.data[Symbol.iterator]();
}, _proxy.values = function values() {
return this.data.values();
}, _proxy.keys = function keys() {
return this.data.values();
}, _proxy.entries = function entries() {
return new Set(this.data).entries();
}, _defineEnumerableProperties(_proxy, _mutatorMap), _proxy));
Object.defineProperties(set, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(set);
return set;
}
function proxyMap(entries) {
var _Symbol$toStringTag, _proxy, _mutatorMap;
var map = vanilla.proxy((_proxy = {
data: Array.from(entries || []),
has: function has(key) {
return this.data.some(function (p) {
return p[0] === key;
});
},
set: function set(key, value) {
var record = this.data.find(function (p) {
return p[0] === key;
});
if (record) {
record[1] = value;
} else {
this.data.push([key, value]);
}
return this;
},
get: function get(key) {
var _this$data$find;
return (_this$data$find = this.data.find(function (p) {
return p[0] === key;
})) == null ? void 0 : _this$data$find[1];
},
delete: function _delete(key) {
var index = this.data.findIndex(function (p) {
return p[0] === key;
});
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
},
clear: function clear() {
this.data.splice(0);
},
get size() {
return this.data.length;
},
toJSON: function toJSON() {
return {};
},
forEach: function forEach(cb) {
var _this = this;
this.data.forEach(function (p) {
cb(p[1], p[0], _this);
});
},
keys: function keys() {
return this.data.map(function (p) {
return p[0];
}).values();
},
values: function values() {
return this.data.map(function (p) {
return p[1];
}).values();
},
entries: function entries() {
return new Map(this.data).entries();
}
}, _Symbol$toStringTag = Symbol.toStringTag, _mutatorMap = {}, _mutatorMap[_Symbol$toStringTag] = _mutatorMap[_Symbol$toStringTag] || {}, _mutatorMap[_Symbol$toStringTag].get = function () {
return 'Map';
}, _proxy[Symbol.iterator] = function () {
return this.entries();
}, _defineEnumerableProperties(_proxy, _mutatorMap), _proxy));
Object.defineProperties(map, {
data: {
enumerable: false
},
size: {
enumerable: false
},
toJSON: {
enumerable: false
}
});
Object.seal(map);
return map;
}
exports.addComputed = addComputed_DEPRECATED;
exports.derive = derive;
exports.devtools = devtools;
exports.proxyMap = proxyMap;
exports.proxySet = proxySet;
exports.proxyWithComputed = proxyWithComputed;
exports.proxyWithHistory = proxyWithHistory;
exports.subscribeKey = subscribeKey;
exports.underive = underive;
exports.unstable_deriveSubscriptions = unstable_deriveSubscriptions;
exports.watch = watch;
Object.defineProperty(exports, '__esModule', { value: true });
}));

1
node_modules/valtio/umd/utils.production.js generated vendored Normal file

File diff suppressed because one or more lines are too long

310
node_modules/valtio/umd/vanilla.development.js generated vendored Normal file
View File

@@ -0,0 +1,310 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('proxy-compare')) :
typeof define === 'function' && define.amd ? define(['exports', 'proxy-compare'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioVanilla = {}, global.proxyCompare));
})(this, (function (exports, proxyCompare) { 'use strict';
var isObject = function isObject(x) {
return typeof x === 'object' && x !== null;
};
var refSet = new WeakSet();
var VERSION = Symbol('VERSION') ;
var LISTENERS = Symbol('LISTENERS') ;
var SNAPSHOT = Symbol('SNAPSHOT') ;
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, PROMISE_RESULT, PROMISE_ERROR, snapshotCache, createSnapshot, proxyCache, versionHolder, proxyFunction) {
if (objectIs === void 0) {
objectIs = Object.is;
}
if (newProxy === void 0) {
newProxy = function newProxy(target, handler) {
return new Proxy(target, handler);
};
}
if (canProxy === void 0) {
canProxy = function canProxy(x) {
return isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer);
};
}
if (PROMISE_RESULT === void 0) {
PROMISE_RESULT = Symbol('PROMISE_RESULT') ;
}
if (PROMISE_ERROR === void 0) {
PROMISE_ERROR = Symbol('PROMISE_ERROR') ;
}
if (snapshotCache === void 0) {
snapshotCache = new WeakMap();
}
if (createSnapshot === void 0) {
createSnapshot = function createSnapshot(version, target, receiver) {
var cache = snapshotCache.get(receiver);
if ((cache == null ? void 0 : cache[0]) === version) {
return cache[1];
}
var snapshot = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
proxyCompare.markToTrack(snapshot, true);
snapshotCache.set(receiver, [version, snapshot]);
Reflect.ownKeys(target).forEach(function (key) {
var value = Reflect.get(target, key, receiver);
if (refSet.has(value)) {
proxyCompare.markToTrack(value, false);
snapshot[key] = value;
} else if (value instanceof Promise) {
if (PROMISE_RESULT in value) {
snapshot[key] = value[PROMISE_RESULT];
} else {
var errorOrPromise = value[PROMISE_ERROR] || value;
Object.defineProperty(snapshot, key, {
get: function get() {
if (PROMISE_RESULT in value) {
return value[PROMISE_RESULT];
}
throw errorOrPromise;
}
});
}
} else if (value != null && value[LISTENERS]) {
snapshot[key] = value[SNAPSHOT];
} else {
snapshot[key] = value;
}
});
return Object.freeze(snapshot);
};
}
if (proxyCache === void 0) {
proxyCache = new WeakMap();
}
if (versionHolder === void 0) {
versionHolder = [1];
}
if (proxyFunction === void 0) {
proxyFunction = function proxyFunction(initialObject) {
if (!isObject(initialObject)) {
throw new Error('object required');
}
var found = proxyCache.get(initialObject);
if (found) {
return found;
}
var version = versionHolder[0];
var listeners = new Set();
var notifyUpdate = function notifyUpdate(op, nextVersion) {
if (nextVersion === void 0) {
nextVersion = ++versionHolder[0];
}
if (version !== nextVersion) {
version = nextVersion;
listeners.forEach(function (listener) {
return listener(op, nextVersion);
});
}
};
var propListeners = new Map();
var getPropListener = function getPropListener(prop) {
var propListener = propListeners.get(prop);
if (!propListener) {
propListener = function propListener(op, nextVersion) {
var newOp = [].concat(op);
newOp[1] = [prop].concat(newOp[1]);
notifyUpdate(newOp, nextVersion);
};
propListeners.set(prop, propListener);
}
return propListener;
};
var popPropListener = function popPropListener(prop) {
var propListener = propListeners.get(prop);
propListeners.delete(prop);
return propListener;
};
var baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
var handler = {
get: function get(target, prop, receiver) {
if (prop === VERSION) {
return version;
}
if (prop === LISTENERS) {
return listeners;
}
if (prop === SNAPSHOT) {
return createSnapshot(version, target, receiver);
}
return Reflect.get(target, prop, receiver);
},
deleteProperty: function deleteProperty(target, prop) {
var prevValue = Reflect.get(target, prop);
var childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
var deleted = Reflect.deleteProperty(target, prop);
if (deleted) {
notifyUpdate(['delete', [prop], prevValue]);
}
return deleted;
},
set: function set(target, prop, value, receiver) {
var _Object$getOwnPropert, _value;
var hasPrevValue = Reflect.has(target, prop);
var prevValue = Reflect.get(target, prop, receiver);
if (hasPrevValue && objectIs(prevValue, value)) {
return true;
}
var childListeners = prevValue == null ? void 0 : prevValue[LISTENERS];
if (childListeners) {
childListeners.delete(popPropListener(prop));
}
if (isObject(value)) {
value = proxyCompare.getUntracked(value) || value;
}
var nextValue;
if ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(target, prop)) != null && _Object$getOwnPropert.set) {
nextValue = value;
} else if (value instanceof Promise) {
nextValue = value.then(function (v) {
nextValue[PROMISE_RESULT] = v;
notifyUpdate(['resolve', [prop], v]);
return v;
}).catch(function (e) {
nextValue[PROMISE_ERROR] = e;
notifyUpdate(['reject', [prop], e]);
});
} else if ((_value = value) != null && _value[LISTENERS]) {
nextValue = value;
nextValue[LISTENERS].add(getPropListener(prop));
} else if (canProxy(value)) {
nextValue = proxy(value);
nextValue[LISTENERS].add(getPropListener(prop));
} else {
nextValue = value;
}
Reflect.set(target, prop, nextValue, receiver);
notifyUpdate(['set', [prop], value, prevValue]);
return true;
}
};
var proxyObject = newProxy(baseObject, handler);
proxyCache.set(initialObject, proxyObject);
Reflect.ownKeys(initialObject).forEach(function (key) {
var desc = Object.getOwnPropertyDescriptor(initialObject, key);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
proxyObject[key] = initialObject[key];
}
});
return proxyObject;
};
}
return [proxyFunction, refSet, VERSION, LISTENERS, SNAPSHOT, objectIs, newProxy, canProxy, PROMISE_RESULT, PROMISE_ERROR, snapshotCache, createSnapshot, proxyCache, versionHolder];
};
var _buildProxyFunction = buildProxyFunction(),
proxyFunction = _buildProxyFunction[0];
function proxy(initialObject) {
if (initialObject === void 0) {
initialObject = {};
}
return proxyFunction(initialObject);
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : undefined;
}
function subscribe(proxyObject, callback, notifyInSync) {
if (!(proxyObject != null && proxyObject[LISTENERS])) {
console.warn('Please use proxy object');
}
var promise;
var ops = [];
var listener = function listener(op) {
ops.push(op);
if (notifyInSync) {
callback(ops.splice(0));
return;
}
if (!promise) {
promise = Promise.resolve().then(function () {
promise = undefined;
callback(ops.splice(0));
});
}
};
proxyObject[LISTENERS].add(listener);
return function () {
proxyObject[LISTENERS].delete(listener);
};
}
function snapshot(proxyObject) {
if (!(proxyObject != null && proxyObject[SNAPSHOT])) {
console.warn('Please use proxy object');
}
return proxyObject[SNAPSHOT];
}
function ref(obj) {
refSet.add(obj);
return obj;
}
var unstable_buildProxyFunction = buildProxyFunction;
exports.getVersion = getVersion;
exports.proxy = proxy;
exports.ref = ref;
exports.snapshot = snapshot;
exports.subscribe = subscribe;
exports.unstable_buildProxyFunction = unstable_buildProxyFunction;
Object.defineProperty(exports, '__esModule', { value: true });
}));

Some files were not shown because too many files have changed in this diff Show More